@emabuild/email-renderer 0.7.1 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,64 +1,93 @@
1
- function A(e) {
1
+ function T(e) {
2
+ return typeof e == "object" && e !== null && !Array.isArray(e);
3
+ }
4
+ function ue(e) {
5
+ return T(e) ? e : {};
6
+ }
7
+ function j(e) {
2
8
  return typeof e != "string" && typeof e != "number" ? null : String(e).replace(/[;{}<>"]/g, "").replace(/!important/gi, "").trim() || null;
3
9
  }
4
- function K(e) {
5
- return typeof e == "string" && e.trim() !== "" && A(e) === e.trim();
10
+ function Z(e) {
11
+ return typeof e == "string" && e.trim() !== "" && j(e) === e.trim();
6
12
  }
7
- function ee(e) {
13
+ function se(e) {
8
14
  const t = e?.body;
9
15
  return t ? [...t.headers ?? [], ...t.rows ?? [], ...t.footers ?? []] : [];
10
16
  }
11
- const G = (e) => typeof e == "string" ? e.trim() : "", Oe = (e) => typeof e == "string" && /^[a-z]{2,3}(-[A-Za-z0-9]{2,8})*$/.test(e);
12
- function me(e, t) {
13
- return G(t) || G(e?.title) || G(e?.subject);
17
+ const Y = (e) => typeof e == "string" ? e.trim() : "", Fe = (e) => typeof e == "string" && /^[a-z]{2,3}(-[A-Za-z0-9]{2,8})*$/.test(e);
18
+ function we(e, t) {
19
+ return Y(t) || Y(e?.title) || Y(e?.subject);
14
20
  }
15
- function ge(e) {
16
- return Oe(e?.language) ? e.language : "";
21
+ function ke(e) {
22
+ const t = e?.language;
23
+ return Fe(t) ? t : "";
17
24
  }
18
- function he(e) {
25
+ function xe(e) {
19
26
  const t = String(e?.fontWeight ?? "");
20
27
  return /^\d{3}$|^(normal|bold)$/.test(t) ? t : "";
21
28
  }
22
- function Me(e) {
29
+ function ee(e) {
23
30
  return e.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
24
31
  }
25
- function ze(e) {
32
+ const He = /[\u00AD\u034F\u200B-\u200F\u2060\uFEFF]/g;
33
+ function de(e) {
34
+ return e.replace(He, "");
35
+ }
36
+ function S(e) {
37
+ return e.replace(/&(?![a-zA-Z0-9#]+;)/g, "&amp;").replace(/"/g, "&quot;");
38
+ }
39
+ function Ue(e) {
26
40
  return e.trim().replace(/['"()\\\s<>]/g, (t) => `%${t.charCodeAt(0).toString(16).toUpperCase().padStart(2, "0")}`);
27
41
  }
28
- function De(e, t) {
29
- const o = e.backgroundImage;
30
- if (!o || typeof o != "object" || typeof o.url != "string" || !o.url.trim()) return { attr: "", css: "", vml: "" };
31
- const n = ze(o.url), s = o.repeat === !0 || o.repeat === "repeat" ? "repeat" : "no-repeat", i = o.cover === !0 ? "cover" : o.fullWidth === !0 ? "100% auto" : "auto", r = o.center !== !1 ? "center top" : "left top", c = s === "repeat" ? "tile" : "frame";
42
+ function ie(e) {
43
+ if (!T(e) || typeof e.url != "string" || !e.url.trim()) return null;
44
+ const t = Ue(e.url), n = e.repeat === !0 || e.repeat === "repeat" ? "repeat" : "no-repeat", o = e.cover === !0 ? "cover" : e.fullWidth === !0 ? "100% auto" : "auto", s = e.center !== !1 ? "center top" : "left top";
32
45
  return {
33
- attr: ` background="${W(n)}"`,
34
- css: `background-image:url('${n}');background-repeat:${s};background-position:${r};background-size:${i};`,
35
- vml: `<!--[if gte mso 9]><v:background xmlns:v="urn:schemas-microsoft-com:vml" fill="t"><v:fill type="${c}" src="${W(n)}" color="${W(t)}"/></v:background><![endif]-->
36
- `
46
+ url: t,
47
+ repeat: n,
48
+ css: `background-image:url('${t}');background-repeat:${n};background-position:${s};background-size:${o};`,
49
+ fillType: n === "repeat" ? "tile" : "frame"
37
50
  };
38
51
  }
39
- function W(e) {
40
- return e.replace(/&(?![a-zA-Z0-9#]+;)/g, "&amp;").replace(/"/g, "&quot;");
52
+ function Ce(e) {
53
+ return ie(e)?.css ?? "";
54
+ }
55
+ function Ge(e, t, n) {
56
+ const o = `<v:fill type="${e.fillType}" src="${S(e.url)}"${n ? ` color="${S(n)}"` : ""}/>`;
57
+ return {
58
+ open: `<!--[if gte mso 9]><v:rect xmlns:v="urn:schemas-microsoft-com:vml" fill="true" stroke="false" style="width:${t}px;">${o}<v:textbox style="mso-fit-shape-to-text:true" inset="0,0,0,0"><![endif]-->`,
59
+ close: "<!--[if gte mso 9]></v:textbox></v:rect><![endif]-->"
60
+ };
61
+ }
62
+ function Ke(e, t) {
63
+ const n = ie(e.backgroundImage);
64
+ return n ? {
65
+ attr: ` background="${S(n.url)}"`,
66
+ css: n.css,
67
+ vml: `<!--[if gte mso 9]><v:background xmlns:v="urn:schemas-microsoft-com:vml" fill="t"><v:fill type="${n.fillType}" src="${S(n.url)}" color="${S(t)}"/></v:background><![endif]-->
68
+ `
69
+ } : { attr: "", css: "", vml: "" };
41
70
  }
42
- function Be(e, t, o, n = {}) {
43
- const s = o.backgroundColor || "transparent", i = o.contentWidth || "600px", r = o.fontFamily?.value || "arial,helvetica,sans-serif", c = o.textColor || "#000000", l = o.preheaderText || "", u = me(o, n.title), a = ge(o), d = a ? ` lang="${a}" xml:lang="${a}"` : "", h = u ? Me(u) : "", m = he(o), p = m ? `font-weight:${m};` : "", f = De(o, s), g = (n.fontUrls ?? []).length ? `
71
+ function Ze(e, t, n, o = {}) {
72
+ const s = n.backgroundColor || "transparent", i = n.contentWidth || "600px", r = n.fontFamily?.value || "arial,helvetica,sans-serif", c = n.textColor || "#000000", l = n.preheaderText || "", d = we(n, o.title), u = ke(n), a = u ? ` lang="${u}" xml:lang="${u}"` : "", h = ee(d || l.trim()), m = o.darkMode ? "light dark" : "light", y = xe(n), b = y ? `font-weight:${y};` : "", f = Ke(n, s), p = (o.fontUrls ?? []).length ? `
44
73
  <!--[if !mso]><!-->
45
- ${n.fontUrls.map((w) => ` <link href="${W(w)}" rel="stylesheet" type="text/css">`).join(`
74
+ ${o.fontUrls.map((v) => ` <link href="${S(v)}" rel="stylesheet" type="text/css">`).join(`
46
75
  `)}
47
- <!--<![endif]-->` : "", y = (n.styles ?? []).map((w) => `
76
+ <!--<![endif]-->` : "", g = (o.styles ?? []).map((v) => `
48
77
  <style type="text/css">
49
- ${w}
50
- </style>`).join(""), v = `<div style="display:none;font-size:1px;color:${s};line-height:1px;max-height:0px;max-width:0px;opacity:0;overflow:hidden;">${l || "&zwnj;"}${"&zwnj;&nbsp;".repeat(80)}</div>`;
78
+ ${v}
79
+ </style>`).join(""), $ = l ? ee(l) : "&zwnj;", w = `<div style="display:none;mso-hide:all;font-size:1px;color:${s};line-height:1px;max-height:0px;max-width:0px;opacity:0;overflow:hidden;">${$}${"&zwnj;&nbsp;".repeat(80)}</div>`;
51
80
  return `<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
52
- <html${d} xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office">
81
+ <html${a} xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office">
53
82
  <head>
54
83
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
55
84
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
56
85
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
57
86
  <meta name="x-apple-disable-message-reformatting">
58
87
  <meta name="format-detection" content="telephone=no,address=no,email=no,date=no,url=no">
59
- <meta name="color-scheme" content="light dark">
60
- <meta name="supported-color-schemes" content="light dark">
61
- <title>${h}</title>${g}
88
+ <meta name="color-scheme" content="${m}">
89
+ <meta name="supported-color-schemes" content="${m}">
90
+ <title>${h}</title>${p}
62
91
  <!--[if mso]>
63
92
  <noscript><xml>
64
93
  <o:OfficeDocumentSettings>
@@ -79,10 +108,10 @@ ${w}
79
108
  table, tr, td { vertical-align: top; border-collapse: collapse; }
80
109
  p { margin: 0; }
81
110
  a[x-apple-data-detectors='true'] { color: inherit !important; text-decoration: none !important; }
82
- </style>${y}
111
+ </style>${g}
83
112
  </head>
84
- <body class="clean-body u_body" style="margin:0;padding:0;-webkit-text-size-adjust:100%;background-color:${s};color:${c};${p}">
85
- ${f.vml}${v}
113
+ <body class="clean-body u_body" style="margin:0;padding:0;-webkit-text-size-adjust:100%;background-color:${s};color:${c};${b}">
114
+ ${f.vml}${w}
86
115
  <table id="u_body" role="presentation"${f.attr} style="border-collapse:collapse;border-spacing:0;margin:0 auto;background-color:${s};${f.css}width:100%;" cellpadding="0" cellspacing="0" border="0">
87
116
  <tbody>
88
117
  <tr>
@@ -97,21 +126,21 @@ ${w}
97
126
  </body>
98
127
  </html>`;
99
128
  }
100
- function te(e, t) {
129
+ function re(e, t) {
101
130
  if (!t || typeof t != "object") return e;
102
- const o = typeof t.before == "string" ? t.before : "", n = typeof t.after == "string" ? t.after : "";
103
- return !o && !n ? e : `${o}${e}${n}`;
131
+ const n = typeof t.before == "string" ? t.before : "", o = typeof t.after == "string" ? t.after : "";
132
+ return !n && !o ? e : `${n}${e}${o}`;
104
133
  }
105
- function ne(e) {
134
+ function N(e) {
106
135
  return `only screen and (max-width: ${e + 20}px)`;
107
136
  }
108
- function We(e) {
137
+ function Ye(e) {
109
138
  return `
110
139
  @media only screen and (min-width: ${e + 20}px) {
111
140
  .u_row .u_column { display: inline-block !important; }
112
141
  }
113
142
 
114
- @media ${ne(e)} {
143
+ @media ${N(e)} {
115
144
  .u_row .u_column {
116
145
  display: block !important;
117
146
  width: 100% !important;
@@ -119,13 +148,14 @@ function We(e) {
119
148
  }
120
149
  .u_row {
121
150
  width: 100% !important;
151
+ box-sizing: border-box !important;
122
152
  }
123
153
  .u_row.no-stack .u_column_ns {
124
154
  display: inline-block !important;
125
155
  }
126
156
  }
127
157
 
128
- @media only screen and (max-width: 620px) {
158
+ @media ${N(e)} {
129
159
  .u_row-container {
130
160
  max-width: 100% !important;
131
161
  padding-left: 0 !important;
@@ -133,17 +163,6 @@ function We(e) {
133
163
  }
134
164
  }
135
165
 
136
- @media (prefers-color-scheme: dark) {
137
- /* Dark mode overrides — add per-client rules as needed */
138
- }
139
-
140
- /* Outlook dark mode */
141
- [data-ogsb] body,
142
- [data-ogsb] table,
143
- [data-ogsb] td {
144
- /* Preserve original colors */
145
- }
146
-
147
166
  .u_hide_desktop { display: block !important; }
148
167
  .u_hide_mobile { display: block !important; }
149
168
 
@@ -157,33 +176,38 @@ function We(e) {
157
176
  .u_hide_mobile { display: block !important; }
158
177
  }`;
159
178
  }
160
- function N(e) {
179
+ function L(e) {
161
180
  return e.replace(/([a-z0-9])([A-Z])/g, "$1-$2").replace(/_/g, "-").toLowerCase();
162
181
  }
163
- function Ne(e) {
164
- return `v-${N(e)}`;
182
+ function Xe(e) {
183
+ return `v-${L(e)}`;
165
184
  }
166
- const R = (e) => !!e && typeof e == "object" && !Array.isArray(e), M = (e) => typeof e == "string" ? e.trim().replace(/[^A-Za-z0-9_:.-]/g, "-") : "";
167
- function q(e) {
168
- return e.replace(/[:.]/g, "\\$&").replace(/^(-?)(\d)/, (t, o, n) => `${o}\\3${n} `);
185
+ const te = (e) => typeof e == "string" ? e.trim().replace(/[^A-Za-z0-9_:.-]/g, "-") : "";
186
+ function F(e) {
187
+ return e.replace(/[:.]/g, "\\$&").replace(/^(-?)(\d)/, (t, n, o) => `${n}\\3${o} `);
169
188
  }
170
- function ye(e, t) {
171
- return M(`${e}${typeof t == "string" || typeof t == "number" ? t : ""}`);
189
+ function Je(e, t) {
190
+ return te(`${e}${typeof t == "string" || typeof t == "number" ? t : ""}`);
172
191
  }
173
- function oe(e) {
174
- const t = e.values ?? {};
175
- return M(t.anchor) || M(R(t._meta) ? t._meta.htmlID : "") || ye("u_content_", e.id);
192
+ function le(e) {
193
+ return _e(e, "u_content_");
176
194
  }
177
195
  function H(e) {
178
- const t = e.values ?? {};
179
- return M(t.anchor) || M(R(t._meta) ? t._meta.htmlID : "") || ye("u_row_", e.id);
196
+ return _e(e, "u_row_");
180
197
  }
181
- function D(e) {
182
- if (!R(e) || !R(e._override)) return null;
183
- const t = e._override.mobile;
184
- return !R(t) || Object.keys(t).length === 0 ? null : t;
198
+ function _e(e, t) {
199
+ const n = ue(e.values);
200
+ return te(n.anchor) || te(ue(n._meta).htmlID) || Je(t, e.id);
201
+ }
202
+ function Se(e, t) {
203
+ if (!T(e) || !T(e._override)) return null;
204
+ const n = e._override[t];
205
+ return T(n) && Object.keys(n).length > 0 ? n : null;
185
206
  }
186
- const Pe = /* @__PURE__ */ new Set([
207
+ function B(e) {
208
+ return Se(e, "mobile");
209
+ }
210
+ const Qe = /* @__PURE__ */ new Set([
187
211
  "_meta",
188
212
  "_override",
189
213
  "text",
@@ -200,175 +224,184 @@ const Pe = /* @__PURE__ */ new Set([
200
224
  "name",
201
225
  "calculatedWidth",
202
226
  "calculatedHeight"
203
- ]), Le = /* @__PURE__ */ new Set(["fontSize", "letterSpacing", "width", "height", "maxWidth", "borderRadius", "iconSize", "spacing"]), qe = {
227
+ ]), Ve = /* @__PURE__ */ new Set(["fontSize", "letterSpacing", "width", "height", "maxWidth", "borderRadius", "iconSize", "spacing"]), et = {
204
228
  containerPadding: "padding",
205
229
  columnsBackgroundColor: "background-color"
206
230
  };
207
- function Y(e, t) {
208
- return typeof t == "number" ? isFinite(t) ? Le.has(e) ? `${t}px` : String(t) : null : typeof t == "string" ? A(t) : null;
231
+ function X(e, t) {
232
+ return typeof t == "number" ? isFinite(t) ? Ve.has(e) ? `${t}px` : String(t) : null : typeof t == "string" ? j(t) : null;
209
233
  }
210
- function F(e) {
234
+ function U(e) {
211
235
  const t = [];
212
- for (const [o, n] of Object.entries(e)) {
213
- if (Pe.has(o)) continue;
214
- if (R(n)) {
215
- if (o === "border")
216
- for (const [i, r] of Object.entries(n)) {
236
+ for (const [n, o] of Object.entries(e)) {
237
+ if (Qe.has(n)) continue;
238
+ if (T(o)) {
239
+ if (n === "border")
240
+ for (const [i, r] of Object.entries(o)) {
217
241
  if (!/^border(Top|Right|Bottom|Left)?(Width|Style|Color)$/.test(i)) continue;
218
- const c = Y(i, r);
219
- c && t.push({ className: "v-border", property: N(i), value: c });
242
+ const c = X(i, r);
243
+ c && t.push({ className: "v-border", property: L(i), value: c });
220
244
  }
221
- else if (o === "buttonColors")
245
+ else if (n === "buttonColors")
222
246
  for (const i of ["backgroundColor", "color"]) {
223
- const r = Y(i, n[i]);
224
- r && t.push({ className: "v-button-colors", property: N(i), value: r });
247
+ const r = X(i, o[i]);
248
+ r && t.push({ className: "v-button-colors", property: L(i), value: r });
225
249
  }
226
250
  continue;
227
251
  }
228
- const s = Y(o, n);
229
- s && t.push({ className: Ne(o), property: qe[o] ?? N(o), value: s });
252
+ const s = X(n, o);
253
+ s && t.push({ className: Xe(n), property: et[n] ?? L(n), value: s });
230
254
  }
231
255
  return t;
232
256
  }
233
- function be(e, t) {
234
- const o = /* @__PURE__ */ new Map();
235
- for (const n of e) {
236
- const s = o.get(n.className) ?? [];
237
- s.push(`${n.property}: ${n.value} !important;`), o.set(n.className, s);
257
+ function Ae(e, t) {
258
+ const n = /* @__PURE__ */ new Map();
259
+ for (const o of e) {
260
+ const s = n.get(o.className) ?? [];
261
+ s.push(`${o.property}: ${o.value} !important;`), n.set(o.className, s);
238
262
  }
239
- return [...o].map(([n, s]) => ` ${t(n)} { ${s.join(" ")} }`);
263
+ return [...n].map(([o, s]) => ` ${t(o)} { ${s.join(" ")} }`);
240
264
  }
241
- function He(e) {
242
- const t = D(e.values);
265
+ function tt(e) {
266
+ const t = B(e.values);
243
267
  if (!t) return [];
244
- const o = q(oe(e));
245
- return o ? be(F(t), (n) => `#${o} .${n}, #${o}.${n}`) : [];
268
+ const n = F(le(e));
269
+ return n ? Ae(U(t), (o) => `#${n} .${o}, #${n}.${o}`) : [];
246
270
  }
247
- function Fe(e) {
248
- const t = D(e.values);
271
+ function nt(e) {
272
+ const t = B(e.values);
249
273
  if (!t) return [];
250
- const o = q(H(e));
251
- return o ? be(
252
- F(t),
253
- (n) => n === "v-columns-background-color" ? `#${o} .${n}` : `#${o}.${n}`
274
+ const n = F(H(e));
275
+ return n ? Ae(
276
+ U(t),
277
+ (o) => o === "v-columns-background-color" ? `#${n} .${o}` : `#${n}.${o}`
254
278
  ) : [];
255
279
  }
256
- function $e(e) {
257
- const t = Fe(e);
258
- for (const o of e.columns ?? [])
259
- for (const n of o.contents ?? []) t.push(...He(n));
280
+ function Te(e) {
281
+ const t = nt(e);
282
+ for (const n of e.columns ?? [])
283
+ for (const o of n.contents ?? []) t.push(...tt(o));
260
284
  return t;
261
285
  }
262
- function ve(e, t) {
263
- return e.length ? `@media ${ne(t)} {
286
+ function Ee(e, t) {
287
+ return e.length ? `@media ${N(t)} {
264
288
  ${e.join(`
265
289
  `)}
266
290
  }` : "";
267
291
  }
268
- function Yt(e) {
292
+ function gn(e) {
269
293
  const t = e?.body;
270
294
  if (!t) return "";
271
- const o = parseInt(String(t.values?.contentWidth || "600")) || 600, n = [];
272
- for (const s of ee(e))
273
- n.push(...$e(s));
274
- return ve(n, o);
275
- }
276
- function we(e) {
277
- if (!e || typeof e != "object") return "";
278
- const t = e;
279
- let o = "";
295
+ const n = parseInt(String(t.values?.contentWidth || "600")) || 600, o = [];
296
+ for (const s of se(e))
297
+ o.push(...Te(s));
298
+ return Ee(o, n);
299
+ }
300
+ const J = (e) => typeof e == "string" || typeof e == "number" ? String(e) : "";
301
+ function Ie(e) {
302
+ if (!T(e)) return "";
303
+ let t = "";
280
304
  for (const n of ["Top", "Right", "Bottom", "Left"]) {
281
- const s = String(t[`border${n}Width`] ?? "").trim();
282
- if (!K(s) || parseFloat(s) <= 0) continue;
283
- const i = String(t[`border${n}Style`] || "solid"), r = String(t[`border${n}Color`] || "#CCCCCC");
284
- !K(i) || !K(r) || (o += `border-${n.toLowerCase()}:${s} ${i} ${r};`);
305
+ const o = J(e[`border${n}Width`]).trim();
306
+ if (!Z(o) || parseFloat(o) <= 0) continue;
307
+ const s = J(e[`border${n}Style`]) || "solid", i = J(e[`border${n}Color`]) || "#CCCCCC";
308
+ !Z(s) || !Z(i) || (t += `border-${n.toLowerCase()}:${o} ${s} ${i};`);
285
309
  }
286
- return o;
287
- }
288
- const ke = (e) => e.replace(/&(?![a-zA-Z0-9#]+;)/g, "&amp;").replace(/"/g, "&quot;");
289
- function Ue(e, t, o, n = "email") {
290
- const s = parseInt(t.contentWidth || "600"), i = e.values.backgroundColor || "", r = e.values.columnsBackgroundColor || "", c = e.values.padding || "0px", l = e.cells.reduce((C, E) => C + E, 0), u = i ? `background-color:${i};` : "", a = e.values.backgroundImage;
291
- let d = "";
292
- if (a?.url) {
293
- const C = a.repeat === !0 || a.repeat === "repeat" ? "repeat" : "no-repeat", E = a.cover === !0 ? "cover" : a.fullWidth === !0 ? "100% auto" : "auto", I = a.center !== !1 ? "center top" : "left top";
294
- d = `background-image:url('${a.url}');background-repeat:${C};background-position:${I};background-size:${E};`;
295
- }
296
- const h = e.columns.length > 1, m = D(e.values), p = !!e.values.noStackMobile && e.columns.length > 1, f = !!m && "columnsBackgroundColor" in m, g = e.columns.map((C, E) => {
297
- const I = Math.round(e.cells[E] / l * s), Re = p ? +(e.cells[E] / l * 100).toFixed(4) : 0;
298
- return { colHtml: Ze(C, I, r, t, o, { pct: Re, colsBgHook: f, displayMode: n }), colWidthPx: I };
310
+ return t;
311
+ }
312
+ function Re(e) {
313
+ const t = (e ?? "").trim().split(/\s+/).filter(Boolean);
314
+ if (!t.length) return ["0px", "0px", "0px", "0px"];
315
+ const [n = "0px", o = n, s = n, i = o] = t;
316
+ return [n, o, s, i];
317
+ }
318
+ function ot(e) {
319
+ return Re(e).every((t) => /^0(\.0+)?([a-z%]+)?$/i.test(t));
320
+ }
321
+ function je(e, t = "") {
322
+ if (ot(e) && !t) return { open: "", close: "" };
323
+ const n = t ? `background-color:${t};` : "";
324
+ return {
325
+ open: `<!--[if mso]><table role="presentation" width="100%" cellpadding="0" cellspacing="0" border="0"><tr><td${t && /^#[0-9a-f]{3,8}$/i.test(t) ? ` bgcolor="${t}"` : ""} style="padding:${e};${n}"><![endif]-->`,
326
+ close: "<!--[if mso]></td></tr></table><![endif]-->"
327
+ };
328
+ }
329
+ function Oe(e) {
330
+ return `<!--[if !mso]><!-->${e}<!--<![endif]-->`;
331
+ }
332
+ function st(e, t, n, o = "email") {
333
+ const s = parseInt(t.contentWidth || "600"), i = e.values.backgroundColor || "", r = e.values.columnsBackgroundColor || "", c = e.values.padding || "0px", l = e.cells.reduce((_, M) => _ + M, 0), d = i ? `background-color:${i};` : "", u = ie(e.values.backgroundImage), a = u?.css ?? "", h = e.columns.length > 1, m = B(e.values), y = !!e.values.noStackMobile && e.columns.length > 1, b = !!m && "columnsBackgroundColor" in m, f = e.columns.map((_, M) => {
334
+ const z = (e.cells[M] ?? 0) / l, ae = Math.round(z * s), qe = y ? +(z * 100).toFixed(4) : 0;
335
+ return { colHtml: it(_, ae, r, t, n, { pct: qe, colsBgHook: b, displayMode: o }), colWidthPx: ae };
299
336
  });
300
- let y;
337
+ let p;
301
338
  if (h) {
302
- const C = g.map(
303
- ({ colHtml: E, colWidthPx: I }) => `<!--[if (mso)|(IE)]><td align="center" width="${I}" style="width:${I}px;padding:0px;" valign="top"><![endif]-->${E}<!--[if (mso)|(IE)]></td><![endif]-->`
339
+ const _ = f.map(
340
+ ({ colHtml: M, colWidthPx: z }) => `<!--[if (mso)|(IE)]><td align="center" width="${z}" style="width:${z}px;padding:0px;" valign="top"><![endif]-->${M}<!--[if (mso)|(IE)]></td><![endif]-->`
304
341
  );
305
- y = `<!--[if (mso)|(IE)]><table role="presentation" width="${s}" cellpadding="0" cellspacing="0" border="0"><tr><![endif]-->${C.join("")}<!--[if (mso)|(IE)]></tr></table><![endif]-->`;
342
+ p = `<!--[if (mso)|(IE)]><table role="presentation" width="${s}" cellpadding="0" cellspacing="0" border="0"><tr><![endif]-->${_.join("")}<!--[if (mso)|(IE)]></tr></table><![endif]-->`;
306
343
  } else
307
- y = g.map(({ colHtml: C }) => C).join("");
308
- const b = e.values.hideDesktop ? " u_hide_desktop" : "", v = e.values.hideMobile ? " u_hide_mobile" : "", w = h ? "font-size:0;" : "", $ = p ? " no-stack" : "", j = m ? ["padding", "backgroundColor"].filter((C) => C in m).map((C) => C === "padding" ? " v-padding" : " v-background-color").join("") : "", O = e.values._meta, _ = e.values.anchor || O?.htmlID || m ? H(e) : "", k = _ ? ` id="${ke(_)}"` : "", x = `<div class="u_row${$}${b}${v}${j}"${k} style="padding:${c};${u}${d}">
309
- <div style="margin:0 auto;max-width:${s}px;${w}text-align:center;">${y}</div>
344
+ p = f.map(({ colHtml: _ }) => _).join("");
345
+ const g = e.values.hideDesktop ? " u_hide_desktop" : "", $ = e.values.hideMobile ? " u_hide_mobile" : "", w = h ? "font-size:0;" : "", v = y ? " no-stack" : "", x = m ? ["padding", "backgroundColor"].filter((_) => _ in m).map((_) => _ === "padding" ? " v-padding" : " v-background-color").join("") : "", E = e.values.anchor || e.values._meta?.htmlID || m ? H(e) : "", W = E ? ` id="${S(E)}"` : "", [A, , C] = Re(c), k = je(`${A} 0px ${C} 0px`), ce = u ? Ge(u, s, i) : { open: "", close: "" };
346
+ let K = `<div class="u_row${v}${g}${$}${x}"${W} style="padding:${c};${d}${a}">
347
+ ${ce.open}${k.open}<div style="margin:0 auto;max-width:${s}px;${w}text-align:center;">${p}</div>${k.close}${ce.close}
310
348
  </div>`;
311
- return te(x, e.values.displayCondition);
349
+ return e.values.hideDesktop && (K = Oe(K)), re(K, e.values.displayCondition);
312
350
  }
313
- function Ze(e, t, o, n, s, i) {
314
- const r = e.values?.backgroundColor || "", c = r || o || "", l = i.colsBgHook && !r ? ' class="v-columns-background-color"' : "", u = e.values.padding || "0px", a = e.values.borderRadius || "0px", d = c ? `background-color:${c};` : "", h = xe(e, t, n, s, i.displayMode), m = `<div${l} style="width:100%;box-sizing:border-box;${d}${we(e.values.border)}${a !== "0px" ? `border-radius:${a};` : ""}">
315
- <div style="padding:${u};">
351
+ function it(e, t, n, o, s, i) {
352
+ const r = e.values?.backgroundColor || "", c = r || n || "", l = i.colsBgHook && !r ? ' class="v-columns-background-color"' : "", d = e.values.padding || "0px", u = e.values.borderRadius || "0px", a = c ? `background-color:${c};` : "", h = Me(e, t, o, s, i.displayMode), m = je(d), y = `<div${l} style="width:100%;box-sizing:border-box;${a}${Ie(e.values.border)}${u !== "0px" ? `border-radius:${u};` : ""}">
353
+ ${m.open}<div style="padding:${d};">
316
354
  ${h || "&nbsp;"}
317
- </div>
355
+ </div>${m.close}
318
356
  </div>`;
319
357
  return i.pct ? `<div class="u_column_ns" style="display:inline-block;vertical-align:top;width:${i.pct}%;max-width:${t}px;">
320
358
  <div class="u_column" style="display:inline-block;vertical-align:top;width:100%;font-size:14px;text-align:left;">
321
- ${m}
359
+ ${y}
322
360
  </div>
323
- </div>` : `<div class="u_column" style="display:inline-block;vertical-align:top;width:${t}px;max-width:${t}px;font-size:14px;text-align:left;">
324
- ${m}
361
+ </div>` : `<div class="u_column" style="display:inline-block;vertical-align:top;width:100%;max-width:${t}px;font-size:14px;text-align:left;">
362
+ ${y}
325
363
  </div>`;
326
364
  }
327
- function xe(e, t, o, n, s) {
328
- const i = parseInt(o.contentWidth || "600");
365
+ function Me(e, t, n, o, s) {
366
+ const i = parseInt(n.contentWidth || "600");
329
367
  return e.contents.map((r) => {
330
- const c = n.get(r.type);
368
+ const c = o.get(r.type);
331
369
  if (!c) return `<!-- unknown tool: ${r.type} -->`;
332
- const l = { columnWidth: t, displayMode: s, contentWidth: i, bodyValues: o };
333
- let u = c(r.values, l);
334
- const a = !!r.values.hideDesktop, d = !!r.values.hideMobile;
335
- if ((a || d) && (u = `<div class="${[a && "u_hide_desktop", d && "u_hide_mobile"].filter(Boolean).join(" ")}">${u}</div>`), D(r.values)) {
336
- const h = oe(r);
337
- h && !u.includes(`id="${h}"`) && (u = `<div id="${ke(h)}">${u}</div>`);
370
+ const l = { columnWidth: t, displayMode: s, contentWidth: i, bodyValues: n };
371
+ let d = c(r.values, l);
372
+ const u = !!r.values.hideDesktop, a = !!r.values.hideMobile;
373
+ if ((u || a) && (d = `<div class="${[u && "u_hide_desktop", a && "u_hide_mobile"].filter(Boolean).join(" ")}">${d}</div>`, u && s === "email" && (d = Oe(d))), B(r.values)) {
374
+ const h = le(r);
375
+ h && !d.includes(`id="${h}"`) && (d = `<div id="${S(h)}">${d}</div>`);
338
376
  }
339
- return te(u, r.values.displayCondition);
377
+ return re(d, r.values.displayCondition);
340
378
  }).join(`
341
379
  `);
342
380
  }
343
- const J = (e) => e.replace(/&(?![a-zA-Z0-9#]+;)/g, "&amp;").replace(/"/g, "&quot;"), Ke = (e) => e.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;"), Ge = (e) => e.trim().replace(/['"()\\\s<>]/g, (t) => `%${t.charCodeAt(0).toString(16).toUpperCase().padStart(2, "0")}`), S = (e) => A(e) ?? "";
344
- function Ce(e) {
345
- if (!e || typeof e != "object" || typeof e.url != "string" || !e.url.trim()) return "";
346
- const t = e.repeat === !0 || e.repeat === "repeat" ? "repeat" : "no-repeat", o = e.cover === !0 ? "cover" : e.fullWidth === !0 ? "100% auto" : "auto", n = e.center !== !1 ? "center top" : "left top";
347
- return `background-image:url('${Ge(e.url)}');background-repeat:${t};background-position:${n};background-size:${o};`;
348
- }
349
- function Ye(e, t, o) {
350
- const n = parseInt(t.contentWidth || "600") || 600, s = e.cells.reduce((b, v) => b + v, 0) || 1, i = e.values.backgroundColor ? `background-color:${S(e.values.backgroundColor)};` : "", r = Ce(e.values.backgroundImage), c = S(e.values.padding || "0px"), l = D(e.values), u = !!e.values.noStackMobile && e.columns.length > 1, a = !!l && "columnsBackgroundColor" in l, d = e.values.columnsBackgroundColor || "", h = e.columns.map((b, v) => Xe(b, e.cells[v] ?? 1, Math.round((e.cells[v] ?? 1) / s * n), d, a, t, o)).join(`
381
+ const I = (e) => j(e) ?? "";
382
+ function rt(e, t, n) {
383
+ const o = parseInt(t.contentWidth || "600") || 600, s = e.cells.reduce((p, g) => p + g, 0) || 1, i = e.values.backgroundColor ? `background-color:${I(e.values.backgroundColor)};` : "", r = Ce(e.values.backgroundImage), c = I(e.values.padding || "0px"), l = B(e.values), d = !!e.values.noStackMobile && e.columns.length > 1, u = !!l && "columnsBackgroundColor" in l, a = e.values.columnsBackgroundColor || "", h = e.columns.map((p, g) => lt(p, e.cells[g] ?? 1, Math.round((e.cells[g] ?? 1) / s * o), a, u, t, n)).join(`
351
384
  `), m = ["u_row"];
352
- u && m.push("no-stack"), e.values.hideDesktop && m.push("u_hide_desktop"), e.values.hideMobile && m.push("u_hide_mobile"), l && ("padding" in l && m.push("v-padding"), "backgroundColor" in l && m.push("v-background-color"));
353
- const p = e.values._meta, f = e.values.anchor || p?.htmlID || l ? H(e) : "", g = f ? ` id="${J(f)}"` : "", y = `<div class="${m.join(" ")}"${g} style="padding:${c};${i}${r}">
385
+ d && m.push("no-stack"), e.values.hideDesktop && m.push("u_hide_desktop"), e.values.hideMobile && m.push("u_hide_mobile"), l && ("padding" in l && m.push("v-padding"), "backgroundColor" in l && m.push("v-background-color"));
386
+ const y = e.values.anchor || e.values._meta?.htmlID || l ? H(e) : "", b = y ? ` id="${S(y)}"` : "", f = `<div class="${m.join(" ")}"${b} style="padding:${c};${i}${r}">
354
387
  <div class="u_row_inner">
355
388
  ${h}
356
389
  </div>
357
390
  </div>`;
358
- return te(Je(y), e.values.displayCondition);
391
+ return re(ct(f), e.values.displayCondition);
359
392
  }
360
- function Xe(e, t, o, n, s, i, r) {
361
- const c = e.values?.backgroundColor || "", l = c || n, u = s && !c ? " v-columns-background-color" : "", a = e.values?.borderRadius && e.values.borderRadius !== "0px" ? `border-radius:${S(e.values.borderRadius)};` : "", d = S(e.values?.padding || "0px"), h = xe(e, o, i, r, "web");
393
+ function lt(e, t, n, o, s, i, r) {
394
+ const c = e.values?.backgroundColor || "", l = c || o, d = s && !c ? " v-columns-background-color" : "", u = e.values?.borderRadius && e.values.borderRadius !== "0px" ? `border-radius:${I(e.values.borderRadius)};` : "", a = I(e.values?.padding || "0px"), h = Me(e, n, i, r, "web");
362
395
  return ` <div class="u_column" style="flex:${+t || 1} 1 0%;">
363
- <div class="u_column_inner${u}" style="${l ? `background-color:${S(l)};` : ""}${we(e.values?.border)}${a}padding:${d};">
396
+ <div class="u_column_inner${d}" style="${l ? `background-color:${I(l)};` : ""}${Ie(e.values?.border)}${u}padding:${a};">
364
397
  ${h}
365
398
  </div>
366
399
  </div>`;
367
400
  }
368
- function Je(e) {
401
+ function ct(e) {
369
402
  return !e.includes("<!--[if") && !e.includes("<![endif]") ? e : e.replace(/<!--\[if [^\]]*\]>(?!<!-->)[\s\S]*?<!\[endif\]-->/gi, "").replace(/<!--\[if [^\]]*\]><!-->/gi, "").replace(/<!--<!\[endif\]-->/gi, "");
370
403
  }
371
- function Qe(e) {
404
+ function at(e) {
372
405
  return `*, *::before, *::after { box-sizing: border-box; }
373
406
  html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
374
407
  body { margin: 0; padding: 0; }
@@ -380,7 +413,7 @@ table { border-collapse: collapse; }
380
413
  .u_row_inner { display: flex; flex-wrap: nowrap; align-items: stretch; max-width: ${e}px; margin: 0 auto; }
381
414
  .u_column { min-width: 0; }
382
415
  .u_column_inner { height: 100%; }
383
- @media ${ne(e)} {
416
+ @media ${N(e)} {
384
417
  .u_row:not(.no-stack) > .u_row_inner { flex-direction: column; }
385
418
  .u_row:not(.no-stack) > .u_row_inner > .u_column { flex: 0 0 auto !important; width: 100% !important; }
386
419
  .u_hide_mobile { display: none !important; }
@@ -389,29 +422,29 @@ table { border-collapse: collapse; }
389
422
  .u_hide_desktop { display: none !important; }
390
423
  }`;
391
424
  }
392
- function Ve(e) {
425
+ function ut(e) {
393
426
  if (!e || typeof e != "object") return "";
394
- const t = (s, i) => [s ? `color: ${S(s)};` : "", typeof i == "boolean" ? `text-decoration: ${i ? "underline" : "none"};` : ""].filter(Boolean).join(" "), o = t(e.linkColor, e.linkUnderline), n = t(e.linkHoverColor, e.linkHoverUnderline);
395
- return (o ? `
396
- .u_body a { ${o} }` : "") + (n ? `
397
- .u_body a:hover { ${n} }` : "");
398
- }
399
- function et(e, t, o = {}) {
400
- const n = parseInt(t.contentWidth || "600") || 600, s = S(t.backgroundColor || "#ffffff"), i = S(t.textColor || "#000000"), r = S(t.fontFamily?.value || "arial,helvetica,sans-serif"), c = he(t), l = c ? ` font-weight: ${c};` : "", u = me(t, o.title), a = Ce(t.backgroundImage), d = Ve(t.linkStyle), h = (o.fontUrls ?? []).map((f) => `
401
- <link href="${J(f)}" rel="stylesheet">`).join(""), m = (o.styles ?? []).map((f) => `
427
+ const t = (s, i) => [s ? `color: ${I(s)};` : "", typeof i == "boolean" ? `text-decoration: ${i ? "underline" : "none"};` : ""].filter(Boolean).join(" "), n = t(e.linkColor, e.linkUnderline), o = t(e.linkHoverColor, e.linkHoverUnderline);
428
+ return (n ? `
429
+ .u_body a { ${n} }` : "") + (o ? `
430
+ .u_body a:hover { ${o} }` : "");
431
+ }
432
+ function dt(e, t, n = {}) {
433
+ const o = parseInt(t.contentWidth || "600") || 600, s = I(t.backgroundColor || "#ffffff"), i = I(t.textColor || "#000000"), r = I(t.fontFamily?.value || "arial,helvetica,sans-serif"), c = xe(t), l = c ? ` font-weight: ${c};` : "", d = we(t, n.title), u = Ce(t.backgroundImage), a = ut(t.linkStyle), h = (n.fontUrls ?? []).map((b) => `
434
+ <link href="${S(b)}" rel="stylesheet">`).join(""), m = (n.styles ?? []).map((b) => `
402
435
  <style>
403
- ${f}
436
+ ${b}
404
437
  </style>`).join("");
405
438
  return `<!DOCTYPE html>
406
- <html lang="${J(o.lang || ge(t) || "en")}">
439
+ <html lang="${S(n.lang || ke(t) || "en")}">
407
440
  <head>
408
441
  <meta charset="utf-8">
409
442
  <meta name="viewport" content="width=device-width, initial-scale=1">
410
- <title>${u ? Ke(u) : ""}</title>${h}
443
+ <title>${d ? ee(d) : ""}</title>${h}
411
444
  <style>
412
- ${Qe(n)}
445
+ ${at(o)}
413
446
  body { background-color: ${s}; color: ${i}; font-family: ${r};${l} }
414
- .u_body { background-color: ${s};${a ? ` ${a.replace(/;(?=.)/g, "; ")}` : ""} }${d}
447
+ .u_body { background-color: ${s};${u ? ` ${u.replace(/;(?=.)/g, "; ")}` : ""} }${a}
415
448
  </style>${m}
416
449
  </head>
417
450
  <body>
@@ -421,60 +454,57 @@ ${e}
421
454
  </body>
422
455
  </html>`;
423
456
  }
424
- const P = (e) => !!e && typeof e == "object" && !Array.isArray(e);
425
- function _e(e) {
426
- if (!P(e) || !P(e._override)) return null;
427
- const t = e._override.dark;
428
- return P(t) && Object.keys(t).length ? t : null;
457
+ function ze(e) {
458
+ return Se(e, "dark");
429
459
  }
430
- const tt = (e) => /color$/.test(e.property);
431
- function Se(e, t) {
432
- const o = /* @__PURE__ */ new Map();
433
- for (const n of e.filter(tt)) o.set(n.className, [...o.get(n.className) ?? [], n]);
434
- return [...o].map(([n, s]) => ({ selector: t(n), decls: s }));
460
+ const ft = (e) => /color$/.test(e.property);
461
+ function De(e, t) {
462
+ const n = /* @__PURE__ */ new Map();
463
+ for (const o of e.filter(ft)) n.set(o.className, [...n.get(o.className) ?? [], o]);
464
+ return [...n].map(([o, s]) => ({ selector: t(o), decls: s }));
435
465
  }
436
- function nt(e) {
437
- const t = _e(e.values);
466
+ function pt(e) {
467
+ const t = ze(e.values);
438
468
  if (!t) return [];
439
- const o = q(oe(e));
440
- return o ? Se(F(t), (n) => `#${o} .${n}, #${o}.${n}`) : [];
469
+ const n = F(le(e));
470
+ return n ? De(U(t), (o) => `#${n} .${o}, #${n}.${o}`) : [];
441
471
  }
442
- function ot(e) {
443
- const t = _e(e.values);
472
+ function mt(e) {
473
+ const t = ze(e.values);
444
474
  if (!t) return [];
445
- const o = q(H(e));
446
- return o ? Se(F(t), (n) => n === "v-columns-background-color" ? `#${o} .${n}` : `#${o}.${n}`) : [];
475
+ const n = F(H(e));
476
+ return n ? De(U(t), (o) => o === "v-columns-background-color" ? `#${n} .${o}` : `#${n}.${o}`) : [];
447
477
  }
448
- function st(e) {
478
+ function ht(e) {
449
479
  const t = e.body?.values?.darkMode;
450
- if (!P(t)) return [];
451
- const o = [], n = A(t.backgroundColor), s = A(t.textColor), i = A(t.linkColor);
452
- return n && o.push({ selector: "body, .u_body, #u_body", decls: [{ className: "", property: "background-color", value: n }] }), s && o.push({ selector: "body, .u_body, #u_body, .u_body .v-color", decls: [{ className: "", property: "color", value: s }] }), i && o.push({ selector: ".u_body a, #u_body a", decls: [{ className: "", property: "color", value: i }] }), o;
453
- }
454
- function Xt(e) {
455
- return Te(e) !== "";
456
- }
457
- function Te(e) {
458
- const t = [...st(e)];
459
- for (const r of ee(e)) {
460
- t.push(...ot(r));
461
- for (const c of r.columns ?? []) for (const l of c.contents ?? []) t.push(...nt(l));
480
+ if (!T(t)) return [];
481
+ const n = [], o = j(t.backgroundColor), s = j(t.textColor), i = j(t.linkColor);
482
+ return o && n.push({ selector: "body, .u_body, #u_body", decls: [{ className: "", property: "background-color", value: o }] }), s && n.push({ selector: "body, .u_body, #u_body, .u_body .v-color", decls: [{ className: "", property: "color", value: s }] }), i && n.push({ selector: ".u_body a, #u_body a", decls: [{ className: "", property: "color", value: i }] }), n;
483
+ }
484
+ function yn(e) {
485
+ return Be(e) !== "";
486
+ }
487
+ function Be(e) {
488
+ const t = [...ht(e)];
489
+ for (const r of se(e)) {
490
+ t.push(...mt(r));
491
+ for (const c of r.columns ?? []) for (const l of c.contents ?? []) t.push(...pt(l));
462
492
  }
463
493
  if (!t.length) return "";
464
- const o = (r) => `${r.property}: ${r.value} !important;`, n = t.map((r) => ` ${r.selector} { ${r.decls.map(o).join(" ")} }`).join(`
465
- `), s = (r, c) => t.map((l) => ({ sel: l.selector.split(",").map((u) => `[${r}] ${u.trim()}`).join(", "), decls: l.decls.filter(c) })).filter((l) => l.decls.length).map((l) => `${l.sel} { ${l.decls.map(o).join(" ")} }`).join(`
494
+ const n = (r) => `${r.property}: ${r.value} !important;`, o = t.map((r) => ` ${r.selector} { ${r.decls.map(n).join(" ")} }`).join(`
495
+ `), s = (r, c) => t.map((l) => ({ sel: l.selector.split(",").map((d) => `[${r}] ${d.trim()}`).join(", "), decls: l.decls.filter(c) })).filter((l) => l.decls.length).map((l) => `${l.sel} { ${l.decls.map(n).join(" ")} }`).join(`
466
496
  `), i = (r) => r.property === "background-color";
467
497
  return [
468
498
  ":root { color-scheme: light dark; supported-color-schemes: light dark; }",
469
499
  `@media (prefers-color-scheme: dark) {
470
- ${n}
500
+ ${o}
471
501
  }`,
472
502
  s("data-ogsc", (r) => !i(r)),
473
503
  s("data-ogsb", i)
474
504
  ].filter(Boolean).join(`
475
505
  `);
476
506
  }
477
- const it = [
507
+ const gt = [
478
508
  "box-sizing",
479
509
  "overflow-wrap",
480
510
  "word-break",
@@ -488,17 +518,17 @@ const it = [
488
518
  "display:\\s*flex",
489
519
  "display:\\s*grid",
490
520
  "gap"
491
- ], rt = new RegExp(
492
- `(?:;\\s*|^\\s*)(${it.join("|")})\\s*:[^;]*`,
521
+ ], yt = new RegExp(
522
+ `(?:;\\s*|^\\s*)(${gt.join("|")})\\s*:[^;]*`,
493
523
  "gi"
494
- ), lt = /var\(--[^)]*\)/gi;
495
- function at(e) {
496
- return e.replace(/style="([^"]*)"/gi, (t, o) => {
497
- let n = o;
498
- return n = n.replace(rt, ";"), n = n.replace(lt, "inherit"), n = n.replace(/;(\s*;)+/g, ";").replace(/^\s*;\s*/, "").replace(/;\s*$/, "").trim(), n ? `style="${n}"` : "";
524
+ ), bt = /var\(--[^)]*\)/gi;
525
+ function $t(e) {
526
+ return e.replace(/style="([^"]*)"/gi, (t, n) => {
527
+ let o = n;
528
+ return o = o.replace(yt, ";"), o = o.replace(bt, "inherit"), o = o.replace(/;(\s*;)+/g, ";").replace(/^\s*;\s*/, "").replace(/;\s*$/, "").trim(), o ? `style="${o}"` : "";
499
529
  });
500
530
  }
501
- const ct = /* @__PURE__ */ new Set(["style", "script", "textarea", "title"]), Q = /* @__PURE__ */ new Set([
531
+ const vt = /* @__PURE__ */ new Set(["style", "script", "textarea", "title"]), ne = /* @__PURE__ */ new Set([
502
532
  "area",
503
533
  "base",
504
534
  "br",
@@ -514,199 +544,199 @@ const ct = /* @__PURE__ */ new Set(["style", "script", "textarea", "title"]), Q
514
544
  "track",
515
545
  "wbr"
516
546
  ]);
517
- function B(e) {
518
- const t = [], o = e.length;
519
- let n = 0, s = 0;
547
+ function O(e) {
548
+ const t = [], n = e.length;
549
+ let o = 0, s = 0;
520
550
  const i = (r) => {
521
551
  r > s && t.push({ type: "text", raw: e.slice(s, r) });
522
552
  };
523
- for (; n < o; ) {
524
- const r = e.indexOf("<", n);
553
+ for (; o < n; ) {
554
+ const r = e.indexOf("<", o);
525
555
  if (r === -1) break;
526
556
  const c = e.charAt(r + 1);
527
557
  if (e.startsWith("<!--", r)) {
528
- const l = e.indexOf("-->", r + 4), u = l === -1 ? o : l + 3;
529
- i(r), t.push({ type: "comment", raw: e.slice(r, u) }), n = s = u;
558
+ const l = e.indexOf("-->", r + 4), d = l === -1 ? n : l + 3;
559
+ i(r), t.push({ type: "comment", raw: e.slice(r, d) }), o = s = d;
530
560
  continue;
531
561
  }
532
562
  if (c === "!" || c === "?") {
533
- const l = e.indexOf(">", r + 2), u = l === -1 ? o : l + 1;
534
- i(r), t.push({ type: "doctype", raw: e.slice(r, u) }), n = s = u;
563
+ const l = e.indexOf(">", r + 2), d = l === -1 ? n : l + 1;
564
+ i(r), t.push({ type: "doctype", raw: e.slice(r, d) }), o = s = d;
535
565
  continue;
536
566
  }
537
567
  if (c === "/" && /[a-zA-Z]/.test(e.charAt(r + 2))) {
538
- const l = e.indexOf(">", r + 2), u = l === -1 ? o : l + 1, a = e.slice(r + 2, l === -1 ? o : l).trim().split(/\s/)[0].toLowerCase();
539
- i(r), t.push({ type: "close", name: a, raw: e.slice(r, u) }), n = s = u;
568
+ const l = e.indexOf(">", r + 2), d = l === -1 ? n : l + 1, u = e.slice(r + 2, l === -1 ? n : l).trim().split(/\s/, 1)[0]?.toLowerCase() ?? "";
569
+ i(r), t.push({ type: "close", name: u, raw: e.slice(r, d) }), o = s = d;
540
570
  continue;
541
571
  }
542
572
  if (/[a-zA-Z]/.test(c)) {
543
- const l = ut(e, r);
573
+ const l = wt(e, r);
544
574
  if (!l) {
545
- n = r + 1;
575
+ o = r + 1;
546
576
  continue;
547
577
  }
548
- if (i(r), t.push(l.token), n = s = l.end, ct.has(l.token.name) && !l.token.selfClosing) {
549
- const u = new RegExp(`</${l.token.name}\\s*>`, "ig");
550
- u.lastIndex = n;
551
- const a = u.exec(e), d = a ? a.index : o;
552
- d > n && t.push({ type: "rawtext", parent: l.token.name, raw: e.slice(n, d) }), a ? (t.push({ type: "close", name: l.token.name, raw: a[0] }), n = s = d + a[0].length) : n = s = o;
578
+ if (i(r), t.push(l.token), o = s = l.end, vt.has(l.token.name) && !l.token.selfClosing) {
579
+ const d = new RegExp(`</${l.token.name}\\s*>`, "ig");
580
+ d.lastIndex = o;
581
+ const u = d.exec(e), a = u ? u.index : n;
582
+ a > o && t.push({ type: "rawtext", parent: l.token.name, raw: e.slice(o, a) }), u ? (t.push({ type: "close", name: l.token.name, raw: u[0] }), o = s = a + u[0].length) : o = s = n;
553
583
  }
554
584
  continue;
555
585
  }
556
- n = r + 1;
586
+ o = r + 1;
557
587
  }
558
- return i(o), t;
588
+ return i(n), t;
559
589
  }
560
- function ut(e, t) {
561
- const o = e.length;
562
- let n = t + 1;
563
- const s = /^[a-zA-Z][^\s/>]*/.exec(e.slice(n, n + 128));
590
+ function wt(e, t) {
591
+ const n = e.length;
592
+ let o = t + 1;
593
+ const s = /^[a-zA-Z][^\s/>]*/.exec(e.slice(o, o + 128));
564
594
  if (!s) return null;
565
595
  const i = s[0].toLowerCase();
566
- n += s[0].length;
596
+ o += s[0].length;
567
597
  const r = [];
568
598
  let c = !1;
569
- for (; n < o; ) {
570
- for (; n < o && /\s/.test(e.charAt(n)); ) n++;
571
- const l = e.charAt(n);
599
+ for (; o < n; ) {
600
+ for (; o < n && /\s/.test(e.charAt(o)); ) o++;
601
+ const l = e.charAt(o);
572
602
  if (l === ">")
573
- return n++, { token: { type: "open", name: i, attrs: r, selfClosing: c, raw: e.slice(t, n) }, end: n };
603
+ return o++, { token: { type: "open", name: i, attrs: r, selfClosing: c, raw: e.slice(t, o) }, end: o };
574
604
  if (l === "/") {
575
- if (n++, e.charAt(n) === ">")
576
- return c = !0, n++, { token: { type: "open", name: i, attrs: r, selfClosing: c, raw: e.slice(t, n) }, end: n };
605
+ if (o++, e.charAt(o) === ">")
606
+ return c = !0, o++, { token: { type: "open", name: i, attrs: r, selfClosing: c, raw: e.slice(t, o) }, end: o };
577
607
  continue;
578
608
  }
579
- if (n >= o) break;
580
- const u = n;
581
- for (; n < o && !/[\s=/>]/.test(e.charAt(n)); ) n++;
582
- if (n === u) {
583
- n++;
609
+ if (o >= n) break;
610
+ const d = o;
611
+ for (; o < n && !/[\s=/>]/.test(e.charAt(o)); ) o++;
612
+ if (o === d) {
613
+ o++;
584
614
  continue;
585
615
  }
586
- const a = e.slice(u, n).toLowerCase();
587
- let d = n;
588
- for (; d < o && /\s/.test(e.charAt(d)); ) d++;
589
- if (e.charAt(d) === "=") {
590
- for (d++; d < o && /\s/.test(e.charAt(d)); ) d++;
591
- const h = e.charAt(d);
616
+ const u = e.slice(d, o).toLowerCase();
617
+ let a = o;
618
+ for (; a < n && /\s/.test(e.charAt(a)); ) a++;
619
+ if (e.charAt(a) === "=") {
620
+ for (a++; a < n && /\s/.test(e.charAt(a)); ) a++;
621
+ const h = e.charAt(a);
592
622
  if (h === '"' || h === "'") {
593
- const m = e.indexOf(h, d + 1), p = m === -1 ? o : m;
594
- r.push({ name: a, value: e.slice(d + 1, p), quote: h }), n = m === -1 ? o : m + 1;
623
+ const m = e.indexOf(h, a + 1), y = m === -1 ? n : m;
624
+ r.push({ name: u, value: e.slice(a + 1, y), quote: h }), o = m === -1 ? n : m + 1;
595
625
  } else {
596
- const m = d;
597
- for (; d < o && !/[\s>]/.test(e.charAt(d)); ) d++;
598
- r.push({ name: a, value: e.slice(m, d), quote: "" }), n = d;
626
+ const m = a;
627
+ for (; a < n && !/[\s>]/.test(e.charAt(a)); ) a++;
628
+ r.push({ name: u, value: e.slice(m, a), quote: "" }), o = a;
599
629
  }
600
630
  } else
601
- r.push({ name: a, value: null, quote: "" });
631
+ r.push({ name: u, value: null, quote: "" });
602
632
  }
603
633
  return null;
604
634
  }
605
- function dt(e) {
635
+ function kt(e) {
606
636
  let t = `<${e.name}`;
607
- for (const o of e.attrs) {
608
- if (o.value === null) {
609
- t += ` ${o.name}`;
637
+ for (const n of e.attrs) {
638
+ if (n.value === null) {
639
+ t += ` ${n.name}`;
610
640
  continue;
611
641
  }
612
- let n = o.quote || '"';
613
- n === "'" && o.value.includes("'") && (n = '"');
614
- const s = n === '"' ? o.value.replace(/"/g, "&quot;") : o.value;
615
- t += ` ${o.name}=${n}${s}${n}`;
642
+ let o = n.quote || '"';
643
+ o === "'" && n.value.includes("'") && (o = '"');
644
+ const s = o === '"' ? n.value.replace(/"/g, "&quot;") : n.value;
645
+ t += ` ${n.name}=${o}${s}${o}`;
616
646
  }
617
647
  return t += e.selfClosing ? " />" : ">", t;
618
648
  }
619
- function U(e) {
649
+ function P(e) {
620
650
  let t = "";
621
- for (const o of e)
622
- t += o.type === "open" && o.dirty ? dt(o) : o.raw;
651
+ for (const n of e)
652
+ t += n.type === "open" && n.dirty ? kt(n) : n.raw;
623
653
  return t;
624
654
  }
625
- function T(e, t) {
626
- const o = e.attrs.find((n) => n.name === t);
627
- return o ? o.value : void 0;
655
+ function R(e, t) {
656
+ const n = e.attrs.find((o) => o.name === t);
657
+ return n ? n.value : void 0;
628
658
  }
629
- function ft(e, t, o) {
630
- const n = e.attrs.find((s) => s.name === t);
631
- n ? (n.value = o, n.quote || (n.quote = '"')) : e.attrs.push({ name: t, value: o, quote: '"' }), e.dirty = !0;
659
+ function xt(e, t, n) {
660
+ const o = e.attrs.find((s) => s.name === t);
661
+ o ? (o.value = n, o.quote || (o.quote = '"')) : e.attrs.push({ name: t, value: n, quote: '"' }), e.dirty = !0;
632
662
  }
633
- function pt(e) {
663
+ function Ct(e) {
634
664
  const t = e.slice(4, e.endsWith("-->") ? -3 : void 0).trim();
635
665
  return /^\[if\b/i.test(t) || /^<!\[endif\]/i.test(t) || /<!\[endif\]$/i.test(t);
636
666
  }
637
- function Ee(e) {
638
- let t = "", o = 0;
639
- for (; o < e.length; ) {
640
- const n = e[o];
641
- if (n === '"' || n === "'") {
642
- const s = Z(e, o);
643
- t += e.slice(o, s), o = s;
644
- } else if (n === "/" && e[o + 1] === "*") {
645
- const s = e.indexOf("*/", o + 2);
646
- o = s === -1 ? e.length : s + 2;
667
+ function Pe(e) {
668
+ let t = "", n = 0;
669
+ for (; n < e.length; ) {
670
+ const o = e.charAt(n);
671
+ if (o === '"' || o === "'") {
672
+ const s = G(e, n);
673
+ t += e.slice(n, s), n = s;
674
+ } else if (o === "/" && e[n + 1] === "*") {
675
+ const s = e.indexOf("*/", n + 2);
676
+ n = s === -1 ? e.length : s + 2;
647
677
  } else
648
- t += n, o++;
678
+ t += o, n++;
649
679
  }
650
680
  return t;
651
681
  }
652
- function Z(e, t) {
653
- const o = e[t];
654
- let n = t + 1;
655
- for (; n < e.length; ) {
656
- if (e[n] === "\\") {
657
- n += 2;
682
+ function G(e, t) {
683
+ const n = e.charAt(t);
684
+ let o = t + 1;
685
+ for (; o < e.length; ) {
686
+ if (e[o] === "\\") {
687
+ o += 2;
658
688
  continue;
659
689
  }
660
- if (e[n] === o || e[n] === `
661
- `) return n + 1;
662
- n++;
690
+ if (e[o] === n || e[o] === `
691
+ `) return o + 1;
692
+ o++;
663
693
  }
664
694
  return e.length;
665
695
  }
666
- function L(e, t, o) {
667
- let n = 0, s = t;
696
+ function q(e, t, n) {
697
+ let o = 0, s = t;
668
698
  for (; s < e.length; ) {
669
- const i = e[s];
699
+ const i = e.charAt(s);
670
700
  if (i === '"' || i === "'") {
671
- s = Z(e, s);
701
+ s = G(e, s);
672
702
  continue;
673
703
  }
674
- if (i === "(" || i === "[") n++;
675
- else if (i === ")" || i === "]") n = Math.max(0, n - 1);
676
- else if (n === 0 && o.includes(i)) return s;
704
+ if (i === "(" || i === "[") o++;
705
+ else if (i === ")" || i === "]") o = Math.max(0, o - 1);
706
+ else if (o === 0 && n.includes(i)) return s;
677
707
  s++;
678
708
  }
679
709
  return -1;
680
710
  }
681
- function se(e, t) {
682
- let o = 0, n = t;
683
- for (; n < e.length; ) {
684
- const s = e[n];
711
+ function fe(e, t) {
712
+ let n = 0, o = t;
713
+ for (; o < e.length; ) {
714
+ const s = e.charAt(o);
685
715
  if (s === '"' || s === "'") {
686
- n = Z(e, n);
716
+ o = G(e, o);
687
717
  continue;
688
718
  }
689
- if (s === "{") o++;
690
- else if (s === "}" && (o--, o === 0))
691
- return n;
692
- n++;
719
+ if (s === "{") n++;
720
+ else if (s === "}" && (n--, n === 0))
721
+ return o;
722
+ o++;
693
723
  }
694
724
  return e.length - 1;
695
725
  }
696
- function Ie(e, t) {
697
- const o = [];
698
- let n = 0, s = L(e, 0, t);
726
+ function We(e, t) {
727
+ const n = [];
728
+ let o = 0, s = q(e, 0, t);
699
729
  for (; s !== -1; )
700
- o.push(e.slice(n, s)), n = s + 1, s = L(e, n, t);
701
- return o.push(e.slice(n)), o;
730
+ n.push(e.slice(o, s)), o = s + 1, s = q(e, o, t);
731
+ return n.push(e.slice(o)), n;
702
732
  }
703
- function je(e) {
733
+ function Le(e) {
704
734
  const t = [];
705
- for (const o of Ie(e, ";")) {
706
- const n = o.indexOf(":");
707
- if (n === -1) continue;
708
- const s = o.slice(0, n).trim().toLowerCase();
709
- let i = o.slice(n + 1).trim();
735
+ for (const n of We(e, ";")) {
736
+ const o = n.indexOf(":");
737
+ if (o === -1) continue;
738
+ const s = n.slice(0, o).trim().toLowerCase();
739
+ let i = n.slice(o + 1).trim();
710
740
  if (!s || !i) continue;
711
741
  let r = !1;
712
742
  const c = /\s*!\s*important\s*$/i.exec(i);
@@ -714,230 +744,232 @@ function je(e) {
714
744
  }
715
745
  return t;
716
746
  }
717
- function ie(e) {
747
+ function pe(e) {
718
748
  return e.map((t) => `${t.property}:${t.value}${t.important ? " !important" : ""}`).join(";");
719
749
  }
720
- function mt(e) {
721
- const t = Ee(e), o = [];
722
- let n = 0;
723
- for (; n < t.length; ) {
724
- for (; n < t.length && /[\s;]/.test(t[n]); ) n++;
725
- if (t.startsWith("<!--", n)) {
726
- n += 4;
750
+ function _t(e) {
751
+ const t = Pe(e), n = [];
752
+ let o = 0;
753
+ for (; o < t.length; ) {
754
+ for (; o < t.length && /[\s;]/.test(t.charAt(o)); ) o++;
755
+ if (t.startsWith("<!--", o)) {
756
+ o += 4;
727
757
  continue;
728
758
  }
729
- if (t.startsWith("-->", n)) {
730
- n += 3;
759
+ if (t.startsWith("-->", o)) {
760
+ o += 3;
731
761
  continue;
732
762
  }
733
- if (n >= t.length) break;
734
- if (t[n] === "@") {
735
- const u = (/^@([\w-]+)/.exec(t.slice(n))?.[1] ?? "").toLowerCase(), a = L(t, n, ";{");
736
- if (a === -1) {
737
- o.push({ type: "at-rule", name: u, raw: t.slice(n).trim() });
763
+ if (o >= t.length) break;
764
+ if (t[o] === "@") {
765
+ const d = (/^@([\w-]+)/.exec(t.slice(o))?.[1] ?? "").toLowerCase(), u = q(t, o, ";{");
766
+ if (u === -1) {
767
+ n.push({ type: "at-rule", name: d, raw: t.slice(o).trim() });
738
768
  break;
739
769
  }
740
- if (t[a] === ";")
741
- o.push({ type: "at-rule", name: u, raw: t.slice(n, a + 1).trim() }), n = a + 1;
770
+ if (t[u] === ";")
771
+ n.push({ type: "at-rule", name: d, raw: t.slice(o, u + 1).trim() }), o = u + 1;
742
772
  else {
743
- const d = se(t, a);
744
- o.push({ type: "at-rule", name: u, raw: t.slice(n, d + 1).trim() }), n = d + 1;
773
+ const a = fe(t, u);
774
+ n.push({ type: "at-rule", name: d, raw: t.slice(o, a + 1).trim() }), o = a + 1;
745
775
  }
746
776
  continue;
747
777
  }
748
- const s = L(t, n, "{");
778
+ const s = q(t, o, "{");
749
779
  if (s === -1) break;
750
- const i = se(t, s), r = t.slice(n, s).trim(), c = t.slice(s + 1, i);
751
- o.push({
780
+ const i = fe(t, s), r = t.slice(o, s).trim(), c = t.slice(s + 1, i);
781
+ n.push({
752
782
  type: "rule",
753
- selectors: Ie(r, ",").map((l) => l.trim()).filter(Boolean),
754
- declarations: je(c),
755
- raw: t.slice(n, i + 1).trim()
756
- }), n = i + 1;
783
+ selectors: We(r, ",").map((l) => l.trim()).filter(Boolean),
784
+ declarations: Le(c),
785
+ raw: t.slice(o, i + 1).trim()
786
+ }), o = i + 1;
757
787
  }
758
- return o;
788
+ return n;
759
789
  }
760
- const gt = /^@(?:-[a-z]+-)?(?:media|supports|document|container|layer|keyframes)\b/i;
761
- function ht(e) {
762
- const t = Ee(e);
763
- let o = "", n = 0;
790
+ const St = /^@(?:-[a-z]+-)?(?:media|supports|document|container|layer|keyframes)\b/i;
791
+ function At(e) {
792
+ const t = Pe(e);
793
+ let n = "", o = 0;
764
794
  const s = [];
765
795
  let i = 0;
766
796
  const r = () => s.length > 0 && s[s.length - 1];
767
- for (; n < t.length; ) {
768
- const c = t[n];
797
+ for (; o < t.length; ) {
798
+ const c = t.charAt(o);
769
799
  if (c === '"' || c === "'") {
770
- const l = Z(t, n);
771
- o += t.slice(n, l), n = l;
800
+ const l = G(t, o);
801
+ n += t.slice(o, l), o = l;
772
802
  continue;
773
803
  }
774
804
  if (/\s/.test(c)) {
775
- for (; n < t.length && /\s/.test(t[n]); ) n++;
776
- const l = o[o.length - 1], u = t[n];
777
- if (l === void 0 || u === void 0 || "{};,>".includes(l) || "{};,>".includes(u) || l === ":" || u === ":" && r()) continue;
778
- o += " ";
805
+ for (; o < t.length && /\s/.test(t.charAt(o)); ) o++;
806
+ const l = n.at(-1);
807
+ if (l === void 0 || o >= t.length) continue;
808
+ const d = t.charAt(o);
809
+ if ("{};,>".includes(l) || "{};,>".includes(d) || l === ":" || d === ":" && r()) continue;
810
+ n += " ";
779
811
  continue;
780
812
  }
781
813
  if (c === "{") {
782
- const l = o.slice(i).trim();
783
- s.push(!gt.test(l)), o += c, i = o.length, n++;
814
+ const l = n.slice(i).trim();
815
+ s.push(!St.test(l)), n += c, i = n.length, o++;
784
816
  continue;
785
817
  }
786
- c === "}" && (o[o.length - 1] === ";" && (o = o.slice(0, -1)), s.pop()), o += c, (c === "}" || c === ";") && (i = o.length), n++;
818
+ c === "}" && (n[n.length - 1] === ";" && (n = n.slice(0, -1)), s.pop()), n += c, (c === "}" || c === ";") && (i = n.length), o++;
787
819
  }
788
- return o.trim();
820
+ return n.trim();
789
821
  }
790
- const yt = /^[a-zA-Z0-9_\-#.*\s>]+$/, bt = /^(\*|[a-zA-Z][a-zA-Z0-9-]*)?((?:[#.][a-zA-Z_\-][a-zA-Z0-9_-]*)*)$/;
791
- function $t(e) {
822
+ const Tt = /^[a-zA-Z0-9_\-#.*\s>]+$/, Et = /^(\*|[a-zA-Z][a-zA-Z0-9-]*)?((?:[#.][a-zA-Z_-][a-zA-Z0-9_-]*)*)$/;
823
+ function It(e) {
792
824
  const t = e.trim();
793
- if (!t || !yt.test(t)) return null;
794
- const o = t.replace(/\s*>\s*/g, " > ").trim().split(/\s+/), n = [], s = [], i = [0, 0, 0];
825
+ if (!t || !Tt.test(t)) return null;
826
+ const n = t.replace(/\s*>\s*/g, " > ").trim().split(/\s+/), o = [], s = [], i = [0, 0, 0];
795
827
  let r = null;
796
- for (const c of o) {
828
+ for (const c of n) {
797
829
  if (c === ">") {
798
- if (n.length === 0 || r === ">") return null;
830
+ if (o.length === 0 || r === ">") return null;
799
831
  r = ">";
800
832
  continue;
801
833
  }
802
- const l = bt.exec(c);
834
+ const l = Et.exec(c);
803
835
  if (!l || !l[1] && !l[2]) return null;
804
- const u = { tag: null, id: null, classes: [] };
805
- l[1] && l[1] !== "*" && (u.tag = l[1].toLowerCase(), i[2]++);
806
- for (const a of l[2].match(/[#.][^#.]+/g) ?? [])
807
- if (a[0] === "#") {
808
- if (u.id !== null && u.id !== a.slice(1)) return null;
809
- u.id = a.slice(1), i[0]++;
836
+ const d = { tag: null, id: null, classes: [] };
837
+ l[1] && l[1] !== "*" && (d.tag = l[1].toLowerCase(), i[2]++);
838
+ for (const u of l[2]?.match(/[#.][^#.]+/g) ?? [])
839
+ if (u[0] === "#") {
840
+ if (d.id !== null && d.id !== u.slice(1)) return null;
841
+ d.id = u.slice(1), i[0]++;
810
842
  } else
811
- u.classes.push(a.slice(1)), i[1]++;
812
- n.length > 0 && s.push(r ?? " "), r = null, n.push(u);
843
+ d.classes.push(u.slice(1)), i[1]++;
844
+ o.length > 0 && s.push(r ?? " "), r = null, o.push(d);
813
845
  }
814
- return r !== null || n.length === 0 ? null : (n.reverse(), s.reverse(), { compounds: n, combinators: s, specificity: i });
846
+ return r !== null || o.length === 0 ? null : (o.reverse(), s.reverse(), { compounds: o, combinators: s, specificity: i });
815
847
  }
816
- function vt(e, t) {
848
+ function Rt(e, t) {
817
849
  if (t.tag !== null && e.token.name !== t.tag || t.id !== null && e.id !== t.id) return !1;
818
- for (const o of t.classes)
819
- if (!e.classes.includes(o)) return !1;
850
+ for (const n of t.classes)
851
+ if (!e.classes.includes(n)) return !1;
820
852
  return !0;
821
853
  }
822
- function V(e, t, o) {
823
- if (!vt(e, t.compounds[o])) return !1;
824
- if (o === t.compounds.length - 1) return !0;
825
- if (t.combinators[o] === ">")
826
- return e.parent !== null && V(e.parent, t, o + 1);
827
- for (let s = e.parent; s; s = s.parent)
828
- if (V(s, t, o + 1)) return !0;
854
+ function oe(e, t, n) {
855
+ const o = t.compounds[n];
856
+ if (!o || !Rt(e, o)) return !1;
857
+ if (n === t.compounds.length - 1) return !0;
858
+ if (t.combinators[n] === ">")
859
+ return e.parent !== null && oe(e.parent, t, n + 1);
860
+ for (let i = e.parent; i; i = i.parent)
861
+ if (oe(i, t, n + 1)) return !0;
829
862
  return !1;
830
863
  }
831
- function wt(e, t) {
832
- return V(e, t, 0);
864
+ function jt(e, t) {
865
+ return oe(e, t, 0);
833
866
  }
834
- function kt(e, t) {
867
+ function Ot(e, t) {
835
868
  return e[0] - t[0] || e[1] - t[1] || e[2] - t[2];
836
869
  }
837
- function xt(e) {
838
- const t = [], o = [];
839
- for (const n of e)
840
- if (n.type === "open") {
841
- const s = T(n, "id"), i = T(n, "class"), r = {
842
- token: n,
843
- parent: o[o.length - 1] ?? null,
870
+ function Mt(e) {
871
+ const t = [], n = [];
872
+ for (const o of e)
873
+ if (o.type === "open") {
874
+ const s = R(o, "id"), i = R(o, "class"), r = {
875
+ token: o,
876
+ parent: n[n.length - 1] ?? null,
844
877
  id: s ? s.trim() : null,
845
878
  classes: i ? i.trim().split(/\s+/).filter(Boolean) : []
846
879
  };
847
- t.push(r), !n.selfClosing && !Q.has(n.name) && o.push(r);
848
- } else if (n.type === "close") {
849
- for (let s = o.length - 1; s >= 0; s--)
850
- if (o[s].token.name === n.name) {
851
- o.length = s;
880
+ t.push(r), !o.selfClosing && !ne.has(o.name) && n.push(r);
881
+ } else if (o.type === "close") {
882
+ for (let s = n.length - 1; s >= 0; s--)
883
+ if (n[s]?.token.name === o.name) {
884
+ n.length = s;
852
885
  break;
853
886
  }
854
887
  }
855
888
  return t;
856
889
  }
857
- function Ct(e) {
890
+ function zt(e) {
858
891
  for (let t = e; t; t = t.parent)
859
892
  if (t.token.name === "body") return !0;
860
893
  return !1;
861
894
  }
862
- function _t(e, t = {}) {
863
- const o = t.removeInlinedRules !== !1, n = B(e), s = [];
895
+ function Dt(e, t = {}) {
896
+ const n = t.removeInlinedRules !== !1, o = O(e), s = [];
864
897
  let i = 0;
865
898
  const r = /* @__PURE__ */ new Map();
866
- for (let a = 0; a < n.length; a++) {
867
- const d = n[a];
868
- if (d.type !== "open" || d.name !== "style" || T(d, "media") !== void 0) continue;
869
- const h = n[a + 1];
899
+ for (const [u, a] of o.entries()) {
900
+ if (a.type !== "open" || a.name !== "style" || R(a, "media") !== void 0) continue;
901
+ const h = o[u + 1];
870
902
  if (!h || h.type !== "rawtext") continue;
871
903
  const m = [];
872
- let p = !1;
873
- for (const f of mt(h.raw)) {
874
- if (f.type === "at-rule") {
875
- m.push(f.raw);
904
+ let y = !1;
905
+ for (const b of _t(h.raw)) {
906
+ if (b.type === "at-rule") {
907
+ m.push(b.raw);
876
908
  continue;
877
909
  }
878
- const g = [], y = [];
879
- for (const v of f.selectors) {
880
- const w = $t(v);
910
+ const f = [], p = [];
911
+ for (const $ of b.selectors) {
912
+ const w = It($);
881
913
  if (w) {
882
- g.push(v);
883
- const $ = f.declarations.filter((j) => !j.important);
884
- $.length > 0 && s.push({ selector: w, declarations: $, order: i++ });
914
+ f.push($);
915
+ const v = b.declarations.filter((x) => !x.important);
916
+ v.length > 0 && s.push({ selector: w, declarations: v, order: i++ });
885
917
  } else
886
- y.push(v);
918
+ p.push($);
887
919
  }
888
- if (g.length === 0 || !o) {
889
- m.push(f.raw);
920
+ if (f.length === 0 || !n) {
921
+ m.push(b.raw);
890
922
  continue;
891
923
  }
892
- p = !0, y.length > 0 && m.push(`${y.join(", ")} { ${ie(f.declarations)} }`);
893
- const b = f.declarations.filter((v) => v.important);
894
- b.length > 0 && m.push(`${g.join(", ")} { ${ie(b)} }`);
924
+ y = !0, p.length > 0 && m.push(`${p.join(", ")} { ${pe(b.declarations)} }`);
925
+ const g = b.declarations.filter(($) => $.important);
926
+ g.length > 0 && m.push(`${f.join(", ")} { ${pe(g)} }`);
895
927
  }
896
- p && r.set(a + 1, m.join(`
928
+ y && r.set(u + 1, m.join(`
897
929
  `));
898
930
  }
899
931
  if (s.length === 0) return e;
900
- s.sort((a, d) => kt(a.selector.specificity, d.selector.specificity) || a.order - d.order);
901
- const c = xt(n), l = c.some((a) => a.token.name === "body");
902
- for (const a of c) {
903
- if (l && !Ct(a)) continue;
904
- const d = /* @__PURE__ */ new Map();
905
- for (const y of s)
906
- if (wt(a, y.selector))
907
- for (const b of y.declarations)
908
- d.delete(b.property), d.set(b.property, b.value);
909
- if (d.size === 0) continue;
910
- const h = (T(a.token, "style") ?? "").trim(), m = new Set(je(h).map((y) => y.property)), p = [];
911
- for (const [y, b] of d)
912
- m.has(y) || p.push(`${y}:${b}`);
913
- if (p.length === 0) continue;
914
- const f = h.replace(/^;+/, ""), g = f ? `${p.join(";")};${f}` : `${p.join(";")};`;
915
- ft(a.token, "style", g);
932
+ s.sort((u, a) => Ot(u.selector.specificity, a.selector.specificity) || u.order - a.order);
933
+ const c = Mt(o), l = c.some((u) => u.token.name === "body");
934
+ for (const u of c) {
935
+ if (l && !zt(u)) continue;
936
+ const a = /* @__PURE__ */ new Map();
937
+ for (const p of s)
938
+ if (jt(u, p.selector))
939
+ for (const g of p.declarations)
940
+ a.delete(g.property), a.set(g.property, g.value);
941
+ if (a.size === 0) continue;
942
+ const h = (R(u.token, "style") ?? "").trim(), m = new Set(Le(h).map((p) => p.property)), y = [];
943
+ for (const [p, g] of a)
944
+ m.has(p) || y.push(`${p}:${g}`);
945
+ if (y.length === 0) continue;
946
+ const b = h.replace(/^;+/, ""), f = b ? `${y.join(";")};${b}` : `${y.join(";")};`;
947
+ xt(u.token, "style", f);
916
948
  }
917
- const u = /* @__PURE__ */ new Set();
918
- for (const [a, d] of r)
919
- d.trim() ? n[a] = { type: "rawtext", parent: "style", raw: `
920
- ${d}
921
- ` } : (u.add(a - 1), u.add(a), n[a + 1]?.type === "close" && u.add(a + 1));
922
- return U(n.filter((a, d) => !u.has(d)));
923
- }
924
- const St = /* @__PURE__ */ new Set(["class", "style", "id"]), Tt = /* @__PURE__ */ new Set([
949
+ const d = /* @__PURE__ */ new Set();
950
+ for (const [u, a] of r)
951
+ a.trim() ? o[u] = { type: "rawtext", parent: "style", raw: `
952
+ ${a}
953
+ ` } : (d.add(u - 1), d.add(u), o[u + 1]?.type === "close" && d.add(u + 1));
954
+ return P(o.filter((u, a) => !d.has(a)));
955
+ }
956
+ const Bt = /* @__PURE__ */ new Set(["class", "style", "id"]), Pt = /* @__PURE__ */ new Set([
925
957
  "contenteditable",
926
958
  "spellcheck",
927
959
  "data-content-id",
928
960
  "data-column-id",
929
961
  "data-row-id"
930
962
  ]);
931
- function Et(e) {
932
- const t = B(e);
933
- for (const o of t) {
934
- if (o.type !== "open" || o.attrs.length === 0) continue;
935
- const n = o.attrs.filter((s) => !(Tt.has(s.name) || St.has(s.name) && (s.value === null || !s.value.trim())));
936
- n.length !== o.attrs.length && (o.attrs = n, o.dirty = !0);
963
+ function Wt(e) {
964
+ const t = O(e);
965
+ for (const n of t) {
966
+ if (n.type !== "open" || n.attrs.length === 0) continue;
967
+ const o = n.attrs.filter((s) => !(Pt.has(s.name) || Bt.has(s.name) && (s.value === null || !s.value.trim())));
968
+ o.length !== n.attrs.length && (n.attrs = o, n.dirty = !0);
937
969
  }
938
- return U(t);
970
+ return P(t);
939
971
  }
940
- const It = /* @__PURE__ */ new Set([
972
+ const Lt = /* @__PURE__ */ new Set([
941
973
  "html",
942
974
  "head",
943
975
  "body",
@@ -989,14 +1021,14 @@ const It = /* @__PURE__ */ new Set([
989
1021
  "noscript",
990
1022
  "xml",
991
1023
  "pre"
992
- ]), jt = /[ \t\n\r\f]+/g, At = /^[ \t\n\r\f]*$/;
993
- function re(e) {
994
- return !e || e.type === "comment" || e.type === "doctype" ? !0 : e.type === "open" || e.type === "close" ? It.has(e.name) || e.name.includes(":") : !1;
1024
+ ]), Nt = /[ \t\n\r\f]+/g, qt = /^[ \t\n\r\f]*$/;
1025
+ function me(e) {
1026
+ return !e || e.type === "comment" || e.type === "doctype" ? !0 : e.type === "open" || e.type === "close" ? Lt.has(e.name) || e.name.includes(":") : !1;
995
1027
  }
996
- function Rt(e) {
1028
+ function Ft(e) {
997
1029
  const t = [];
998
- for (const s of B(e)) {
999
- if (s.type === "comment" && !pt(s.raw)) continue;
1030
+ for (const s of O(e)) {
1031
+ if (s.type === "comment" && !Ct(s.raw)) continue;
1000
1032
  const i = t[t.length - 1];
1001
1033
  if (s.type === "text" && i?.type === "text") {
1002
1034
  t[t.length - 1] = { type: "text", raw: i.raw + s.raw };
@@ -1004,30 +1036,110 @@ function Rt(e) {
1004
1036
  }
1005
1037
  t.push(s);
1006
1038
  }
1007
- const o = [];
1008
- let n = 0;
1009
- for (let s = 0; s < t.length; s++) {
1010
- const i = t[s];
1011
- if (i.type === "open" && i.name === "pre" && !i.selfClosing && n++, i.type === "close" && i.name === "pre" && (n = Math.max(0, n - 1)), i.type === "rawtext") {
1012
- i.parent === "style" ? o.push({ ...i, raw: ht(i.raw) }) : o.push(i);
1039
+ const n = [];
1040
+ let o = 0;
1041
+ for (const [s, i] of t.entries()) {
1042
+ if (i.type === "open" && i.name === "pre" && !i.selfClosing && o++, i.type === "close" && i.name === "pre" && (o = Math.max(0, o - 1)), i.type === "rawtext") {
1043
+ i.parent === "style" ? n.push({ ...i, raw: At(i.raw) }) : n.push(i);
1013
1044
  continue;
1014
1045
  }
1015
- if (i.type !== "text" || n > 0) {
1016
- o.push(i);
1046
+ if (i.type !== "text" || o > 0) {
1047
+ n.push(i);
1017
1048
  continue;
1018
1049
  }
1019
- const r = re(t[s - 1]), c = re(t[s + 1]);
1020
- if (At.test(i.raw)) {
1050
+ const r = me(t[s - 1]), c = me(t[s + 1]);
1051
+ if (qt.test(i.raw)) {
1021
1052
  if (r || c) continue;
1022
- o.push({ type: "text", raw: " " });
1053
+ n.push({ type: "text", raw: " " });
1023
1054
  continue;
1024
1055
  }
1025
- let l = i.raw.replace(jt, " ");
1026
- r && (l = l.replace(/^ /, "")), c && (l = l.replace(/ $/, "")), o.push({ type: "text", raw: l });
1056
+ let l = i.raw.replace(Nt, " ");
1057
+ r && (l = l.replace(/^ /, "")), c && (l = l.replace(/ $/, "")), n.push({ type: "text", raw: l });
1027
1058
  }
1028
- return U(o).trim();
1059
+ return P(n).trim();
1029
1060
  }
1030
- const le = {
1061
+ const Ht = /* @__PURE__ */ new Set([
1062
+ "iframe",
1063
+ "frame",
1064
+ "frameset",
1065
+ "object",
1066
+ "embed",
1067
+ "applet",
1068
+ "base",
1069
+ "animate",
1070
+ "set",
1071
+ "animatemotion",
1072
+ "animatetransform",
1073
+ "animatecolor",
1074
+ "discard",
1075
+ "handler",
1076
+ "listener"
1077
+ ]), Ut = /* @__PURE__ */ new Set([
1078
+ "href",
1079
+ "src",
1080
+ "action",
1081
+ "background",
1082
+ "poster",
1083
+ "lowsrc",
1084
+ "dynsrc",
1085
+ "data",
1086
+ "codebase",
1087
+ "cite",
1088
+ "longdesc",
1089
+ "usemap",
1090
+ "ping",
1091
+ "xlink:href",
1092
+ "srcset"
1093
+ ]), Gt = /^(?:javascript|vbscript|livescript):|^data:(?:text\/html|application\/(?:x?html|javascript))/i, Kt = /^data:image\/svg/i, Zt = /(?:javascript|vbscript|livescript):/i, Yt = /expression\s*\(|javascript:|vbscript:|-moz-binding|behavior\s*:/i, Xt = /<(?:script|i?frame|object|embed|applet|base|meta[^>]*refresh|animate|set|discard|handler|listener)\b|\son[a-z]+\s*=|srcdoc|formaction|script\s*:|data\s*:|expression|behavior|binding|&#|&colon|&tab|&newline/i;
1094
+ function Q(e) {
1095
+ return e.replace(/&#x0*([0-9a-f]+);?/gi, (t, n) => String.fromCodePoint(parseInt(n, 16) % 1114112)).replace(/&#0*(\d+);?/g, (t, n) => String.fromCodePoint(Number(n) % 1114112)).replace(/&colon;?/gi, ":").replace(/&tab;?/gi, "").replace(/&newline;?/gi, "").replace(/[\u0000- \u007f-\u009f]/g, "");
1096
+ }
1097
+ function Jt(e, t) {
1098
+ if (e.startsWith("on") || e === "srcdoc" || e === "formaction") return !0;
1099
+ if (t === null) return !1;
1100
+ if (e === "srcset") return Zt.test(Q(t));
1101
+ if (Ut.has(e) || e.endsWith(":href")) {
1102
+ const n = Q(t);
1103
+ return Gt.test(n) || (e === "href" || e.endsWith(":href")) && Kt.test(n);
1104
+ }
1105
+ return e === "style" ? Yt.test(Q(t)) : !1;
1106
+ }
1107
+ function Qt(e) {
1108
+ if (!Xt.test(e)) return e;
1109
+ const t = O(e), n = [];
1110
+ let o = !1, s = !1;
1111
+ for (const i of t) {
1112
+ if (s) {
1113
+ o = !0, i.type === "close" && i.name === "script" && (s = !1);
1114
+ continue;
1115
+ }
1116
+ if (i.type === "open" || i.type === "close") {
1117
+ if (i.name === "script") {
1118
+ o = !0, i.type === "open" && !i.selfClosing && (s = !0);
1119
+ continue;
1120
+ }
1121
+ if (Ht.has(i.name)) {
1122
+ o = !0;
1123
+ continue;
1124
+ }
1125
+ }
1126
+ if (i.type === "rawtext" && i.parent === "script") {
1127
+ o = !0;
1128
+ continue;
1129
+ }
1130
+ if (i.type === "open") {
1131
+ if (i.name === "meta" && i.attrs.some((c) => c.name === "http-equiv" && /refresh/i.test(c.value ?? ""))) {
1132
+ o = !0;
1133
+ continue;
1134
+ }
1135
+ const r = i.attrs.filter((c) => !Jt(c.name, c.value));
1136
+ r.length !== i.attrs.length && (i.attrs = r, i.dirty = !0, o = !0);
1137
+ }
1138
+ n.push(i);
1139
+ }
1140
+ return o ? P(n) : e;
1141
+ }
1142
+ const he = {
1031
1143
  amp: "&",
1032
1144
  lt: "<",
1033
1145
  gt: ">",
@@ -1104,17 +1216,17 @@ const le = {
1104
1216
  hearts: "♥",
1105
1217
  star: "☆",
1106
1218
  check: "✓"
1107
- }, ae = /[­͏​-‏⁠]/g;
1108
- function X(e) {
1109
- return e.replace(/&(#x[0-9a-f]+|#[0-9]+|[a-z][a-z0-9]*);/gi, (t, o) => {
1110
- if (o[0] === "#") {
1111
- const n = o[1] === "x" || o[1] === "X" ? parseInt(o.slice(2), 16) : parseInt(o.slice(1), 10);
1112
- return !isFinite(n) || n <= 0 || n > 1114111 ? "" : n === 160 ? " " : String.fromCodePoint(n);
1219
+ };
1220
+ function V(e) {
1221
+ return e.replace(/&(#x[0-9a-f]+|#[0-9]+|[a-z][a-z0-9]*);/gi, (t, n) => {
1222
+ if (n[0] === "#") {
1223
+ const o = n[1] === "x" || n[1] === "X" ? parseInt(n.slice(2), 16) : parseInt(n.slice(1), 10);
1224
+ return !isFinite(o) || o <= 0 || o > 1114111 ? "" : o === 160 ? " " : String.fromCodePoint(o);
1113
1225
  }
1114
- return o in le ? le[o] : t;
1226
+ return (Object.hasOwn(he, n) ? he[n] : void 0) ?? t;
1115
1227
  });
1116
1228
  }
1117
- const ce = /* @__PURE__ */ new Set(["h1", "h2", "h3", "h4", "h5", "h6"]), ue = /* @__PURE__ */ new Set([
1229
+ const ge = /* @__PURE__ */ new Set(["h1", "h2", "h3", "h4", "h5", "h6"]), ye = /* @__PURE__ */ new Set([
1118
1230
  "div",
1119
1231
  "table",
1120
1232
  "tbody",
@@ -1139,119 +1251,119 @@ const ce = /* @__PURE__ */ new Set(["h1", "h2", "h3", "h4", "h5", "h6"]), ue = /
1139
1251
  "figcaption",
1140
1252
  "pre",
1141
1253
  "address"
1142
- ]), de = /* @__PURE__ */ new Set(["p", "blockquote"]), Ot = /* @__PURE__ */ new Set(["head", "style", "script", "title", "noscript", "template", "svg", "select", "textarea", "object", "video", "audio", "map"]);
1143
- function Mt(e) {
1144
- if (T(e, "hidden") !== void 0 || T(e, "aria-hidden") === "true" && e.name !== "img") return !0;
1145
- const t = (T(e, "style") ?? "").toLowerCase().replace(/\s+/g, "");
1254
+ ]), be = /* @__PURE__ */ new Set(["p", "blockquote"]), Vt = /* @__PURE__ */ new Set(["head", "style", "script", "title", "noscript", "template", "svg", "select", "textarea", "object", "video", "audio", "map"]);
1255
+ function en(e) {
1256
+ if (R(e, "hidden") !== void 0 || R(e, "aria-hidden") === "true" && e.name !== "img") return !0;
1257
+ const t = (R(e, "style") ?? "").toLowerCase().replace(/\s+/g, "");
1146
1258
  return /(^|;)display:none/.test(t) || /mso-hide:all/.test(t) || /(^|;)max-height:0(px|em|%)?(;|$|!)/.test(t);
1147
1259
  }
1148
- function zt(e, t) {
1149
- const o = (n) => n.trim().toLowerCase().replace(/^(mailto:|tel:|sms:)/, "").replace(/^https?:\/\//, "").replace(/^www\./, "").replace(/\/+$/, "");
1150
- return o(e) === o(t);
1151
- }
1152
- function Dt(e, t = {}) {
1153
- const o = t.linkStyle ?? "inline", n = [], s = [{ kind: "root", buf: "" }], i = [], r = () => s[s.length - 1], c = () => {
1154
- const p = r();
1155
- p.buf = p.buf.replace(/[ \t]+$/, "");
1156
- }, l = (p) => {
1157
- let f = X(p.replace(/\s+/g, " ")).replace(ae, "").replace(/[ \t ]+/g, " ");
1158
- if (!f) return;
1159
- const g = r();
1160
- (!g.buf || /[\s]$/.test(g.buf)) && (f = f.replace(/^ /, "")), g.buf += f;
1161
- }, u = (p) => {
1162
- c();
1163
- const f = r();
1164
- if (!f.buf) return;
1165
- const g = /\n*$/.exec(f.buf)[0].length;
1166
- g < p && (f.buf += `
1167
- `.repeat(p - g));
1168
- }, a = () => {
1169
- const p = r();
1170
- p.buf && !/\s$/.test(p.buf) && (p.buf += " ");
1260
+ function tn(e, t) {
1261
+ const n = (o) => o.trim().toLowerCase().replace(/^(mailto:|tel:|sms:)/, "").replace(/^https?:\/\//, "").replace(/^www\./, "").replace(/\/+$/, "");
1262
+ return n(e) === n(t);
1263
+ }
1264
+ function nn(e, t = {}) {
1265
+ const n = t.linkStyle ?? "inline", o = [], s = { kind: "root", buf: "" }, i = [s], r = [], c = () => i.at(-1) ?? s, l = () => (i.length > 1 ? i.pop() : void 0) ?? s, d = () => {
1266
+ const f = c();
1267
+ f.buf = f.buf.replace(/[ \t]+$/, "");
1268
+ }, u = (f) => {
1269
+ let p = de(V(f.replace(/\s+/g, " "))).replace(/[ \t\u00A0]+/g, " ");
1270
+ if (!p) return;
1271
+ const g = c();
1272
+ (!g.buf || /[\s]$/.test(g.buf)) && (p = p.replace(/^ /, "")), g.buf += p;
1273
+ }, a = (f) => {
1274
+ d();
1275
+ const p = c();
1276
+ if (!p.buf) return;
1277
+ const g = p.buf.length - p.buf.replace(/\n+$/, "").length;
1278
+ g < f && (p.buf += `
1279
+ `.repeat(f - g));
1280
+ }, h = () => {
1281
+ const f = c();
1282
+ f.buf && !/\s$/.test(f.buf) && (f.buf += " ");
1171
1283
  };
1172
- let d = "", h = 0;
1173
- for (const p of B(e)) {
1174
- if (h) {
1175
- p.type === "open" && p.name === d && !p.selfClosing && !Q.has(p.name) ? h++ : p.type === "close" && p.name === d && h--;
1284
+ let m = "", y = 0;
1285
+ for (const f of O(e)) {
1286
+ if (y) {
1287
+ f.type === "open" && f.name === m && !f.selfClosing && !ne.has(f.name) ? y++ : f.type === "close" && f.name === m && y--;
1176
1288
  continue;
1177
1289
  }
1178
- if (p.type === "text") {
1179
- l(p.raw);
1290
+ if (f.type === "text") {
1291
+ u(f.raw);
1180
1292
  continue;
1181
1293
  }
1182
- if (p.type !== "open" && p.type !== "close") continue;
1183
- const f = p.name;
1184
- if (p.type === "open") {
1185
- const g = Q.has(f) || p.selfClosing;
1186
- if (Ot.has(f) || Mt(p) && f !== "br") {
1187
- g || (d = f, h = 1);
1294
+ if (f.type !== "open" && f.type !== "close") continue;
1295
+ const p = f.name;
1296
+ if (f.type === "open") {
1297
+ const g = ne.has(p) || f.selfClosing;
1298
+ if (Vt.has(p) || en(f) && p !== "br") {
1299
+ g || (m = p, y = 1);
1188
1300
  continue;
1189
1301
  }
1190
- if (f === "br")
1191
- c(), r().buf += `
1302
+ if (p === "br")
1303
+ d(), c().buf += `
1192
1304
  `;
1193
- else if (f === "img") {
1194
- const y = X(T(p, "alt") ?? "").replace(ae, "").trim();
1195
- y && (a(), r().buf += `[${y}]`);
1196
- } else if (f === "hr")
1197
- u(1), r().buf += "---", u(1);
1198
- else if (ce.has(f))
1199
- u(2), s.push({ kind: "heading", buf: "" });
1200
- else if (f === "a")
1201
- s.push({ kind: "link", buf: "", href: X(T(p, "href") ?? "").trim() });
1202
- else if (f === "ul" || f === "ol")
1203
- u(1), i.push({ ordered: f === "ol", n: 0 });
1204
- else if (f === "li") {
1205
- u(1);
1206
- const y = i[i.length - 1], b = " ".repeat(Math.max(0, i.length - 1));
1207
- r().buf += y?.ordered ? `${b}${++y.n}. ` : `${b}- `;
1208
- } else de.has(f) ? u(2) : ue.has(f) ? u(1) : (f === "td" || f === "th") && a();
1305
+ else if (p === "img") {
1306
+ const $ = de(V(R(f, "alt") ?? "")).trim();
1307
+ $ && (h(), c().buf += `[${$}]`);
1308
+ } else if (p === "hr")
1309
+ a(1), c().buf += "---", a(1);
1310
+ else if (ge.has(p))
1311
+ a(2), i.push({ kind: "heading", buf: "" });
1312
+ else if (p === "a")
1313
+ i.push({ kind: "link", buf: "", href: V(R(f, "href") ?? "").trim() });
1314
+ else if (p === "ul" || p === "ol")
1315
+ a(1), r.push({ ordered: p === "ol", n: 0 });
1316
+ else if (p === "li") {
1317
+ a(1);
1318
+ const $ = r[r.length - 1], w = " ".repeat(Math.max(0, r.length - 1));
1319
+ c().buf += $?.ordered ? `${w}${++$.n}. ` : `${w}- `;
1320
+ } else be.has(p) ? a(2) : ye.has(p) ? a(1) : (p === "td" || p === "th") && h();
1209
1321
  continue;
1210
1322
  }
1211
- if (ce.has(f) && r().kind === "heading") {
1212
- const g = s.pop().buf.trim().toUpperCase();
1213
- u(2), g && (r().buf += g), u(2);
1214
- } else if (f === "a" && r().kind === "link") {
1215
- const g = s.pop(), y = g.buf.replace(/\s+/g, " ").trim(), b = g.href ?? "", v = b && !b.startsWith("#") && !/^javascript:/i.test(b);
1216
- let w = y;
1217
- if (v && !zt(b, y))
1218
- if (!y) w = b;
1219
- else if (o === "footnote") {
1220
- let $ = n.indexOf(b);
1221
- $ === -1 && ($ = n.push(b) - 1), w = `${y} [${$ + 1}]`;
1222
- } else w = `${y} (${b})`;
1223
- w && (a(), r().buf += w);
1224
- } else f === "ul" || f === "ol" ? (i.pop(), u(1)) : f === "table" ? u(2) : f === "li" || ue.has(f) ? u(1) : de.has(f) ? u(2) : (f === "td" || f === "th") && a();
1323
+ if (ge.has(p) && c().kind === "heading") {
1324
+ const g = l().buf.trim().toUpperCase();
1325
+ a(2), g && (c().buf += g), a(2);
1326
+ } else if (p === "a" && c().kind === "link") {
1327
+ const g = l(), $ = g.buf.replace(/\s+/g, " ").trim(), w = g.href ?? "", v = w && !w.startsWith("#") && !/^javascript:/i.test(w);
1328
+ let x = $;
1329
+ if (v && !tn(w, $))
1330
+ if (!$) x = w;
1331
+ else if (n === "footnote") {
1332
+ let E = o.indexOf(w);
1333
+ E === -1 && (E = o.push(w) - 1), x = `${$} [${E + 1}]`;
1334
+ } else x = `${$} (${w})`;
1335
+ x && (h(), c().buf += x);
1336
+ } else p === "ul" || p === "ol" ? (r.pop(), a(1)) : p === "table" ? a(2) : p === "li" || ye.has(p) ? a(1) : be.has(p) ? a(2) : (p === "td" || p === "th") && h();
1225
1337
  }
1226
- for (; s.length > 1; ) {
1227
- const p = s.pop();
1228
- r().buf += p.kind === "heading" ? p.buf.toUpperCase() : p.buf;
1338
+ for (; i.length > 1; ) {
1339
+ const f = l();
1340
+ c().buf += f.kind === "heading" ? f.buf.toUpperCase() : f.buf;
1229
1341
  }
1230
- let m = r().buf.split(`
1231
- `).map((p) => p.replace(/[ \t]+/g, " ").trim()).join(`
1342
+ let b = c().buf.split(`
1343
+ `).map((f) => f.replace(/[ \t]+/g, " ").trim()).join(`
1232
1344
  `).replace(/\n{4,}/g, `
1233
1345
 
1234
1346
 
1235
1347
  `).trim();
1236
- return t.wordwrap && (m = Bt(m, t.wordwrap)), n.length && (m += `
1348
+ return t.wordwrap && (b = on(b, t.wordwrap)), o.length && (b += `
1237
1349
 
1238
- ${n.map((p, f) => `[${f + 1}] ${p}`).join(`
1239
- `)}`), m;
1350
+ ${o.map((f, p) => `[${p + 1}] ${f}`).join(`
1351
+ `)}`), b;
1240
1352
  }
1241
- function Bt(e, t) {
1353
+ function on(e, t) {
1242
1354
  return t > 0 ? e.split(`
1243
- `).map((o) => {
1244
- if (o.length <= t) return o;
1245
- const n = /^(\s*(?:- |\d+\. ))?/.exec(o)[0].replace(/./g, " "), s = [];
1355
+ `).map((n) => {
1356
+ if (n.length <= t) return n;
1357
+ const o = /^(\s*(?:- |\d+\. ))?/.exec(n)[0].replace(/./g, " "), s = [];
1246
1358
  let i = "";
1247
- for (const r of o.split(" "))
1248
- i ? i.length + 1 + r.length <= t ? i += ` ${r}` : (s.push(i), i = n + r) : i = r;
1359
+ for (const r of n.split(" "))
1360
+ i ? i.length + 1 + r.length <= t ? i += ` ${r}` : (s.push(i), i = o + r) : i = r;
1249
1361
  return i && s.push(i), s.join(`
1250
1362
  `);
1251
1363
  }).join(`
1252
1364
  `) : e;
1253
1365
  }
1254
- class Ae {
1366
+ class Ne {
1255
1367
  constructor() {
1256
1368
  this.rows = /* @__PURE__ */ new WeakMap(), this.stats = { hits: 0, misses: 0 };
1257
1369
  }
@@ -1259,229 +1371,231 @@ class Ae {
1259
1371
  this.rows = /* @__PURE__ */ new WeakMap(), this.stats = { hits: 0, misses: 0 };
1260
1372
  }
1261
1373
  }
1262
- function Jt() {
1263
- return new Ae();
1374
+ function bn() {
1375
+ return new Ne();
1264
1376
  }
1265
- const fe = /* @__PURE__ */ new WeakMap();
1266
- let Wt = 1;
1267
- function Nt(e) {
1268
- let t = fe.get(e);
1269
- return t === void 0 && (t = Wt++, fe.set(e, t)), t;
1377
+ const $e = /* @__PURE__ */ new WeakMap();
1378
+ let sn = 1;
1379
+ function rn(e) {
1380
+ let t = $e.get(e);
1381
+ return t === void 0 && (t = sn++, $e.set(e, t)), t;
1270
1382
  }
1271
- const Pt = /* @__PURE__ */ new Set(["preheaderText"]);
1272
- function Lt(e, t, o) {
1273
- const n = {};
1274
- for (const s of Object.keys(e ?? {})) Pt.has(s) || (n[s] = e[s]);
1275
- return `${t}|${Nt(o)}|${JSON.stringify(n)}`;
1383
+ const ln = /* @__PURE__ */ new Set(["preheaderText"]);
1384
+ function cn(e, t, n) {
1385
+ const o = {};
1386
+ for (const s of Object.keys(e ?? {})) ln.has(s) || (o[s] = e[s]);
1387
+ return `${t}|${rn(n)}|${JSON.stringify(o)}`;
1276
1388
  }
1277
- function pe(e, t, o, n) {
1278
- const s = n ? Ye(e, t, o) : Ue(e, t, o, "email"), i = Ut(s), r = /* @__PURE__ */ new Set();
1279
- for (const c of e.columns ?? []) for (const l of c.contents ?? []) z(l.values, r);
1389
+ function ve(e, t, n, o) {
1390
+ const s = o ? rt(e, t, n) : st(e, t, n, "email"), i = fn(s), r = /* @__PURE__ */ new Set();
1391
+ for (const c of e.columns ?? []) for (const l of c.contents ?? []) D(l.values, r);
1280
1392
  return {
1281
1393
  // Web pages keep modern CSS (flex, grid, …); email strips what clients don't support
1282
- html: n ? i.html : at(i.html),
1394
+ html: o ? i.html : $t(i.html),
1283
1395
  styles: i.styles,
1284
1396
  fonts: [...r],
1285
- overrides: $e(e)
1397
+ overrides: Te(e)
1286
1398
  };
1287
1399
  }
1288
- function qt(e, t, o, n) {
1289
- const s = e.body.values, i = parseInt(s.contentWidth || "600") || 600, r = o?.displayMode === "web", c = n?.cache ?? o?.cache, l = c instanceof Ae, u = l ? Lt(s, r ? "web" : "email", t) : "", a = [
1400
+ function an(e, t, n, o) {
1401
+ const s = e.body.values, i = parseInt(s.contentWidth || "600") || 600, r = n?.displayMode === "web", c = o?.cache ?? n?.cache, l = c instanceof Ne, d = l ? cn(s, r ? "web" : "email", t) : "", u = [
1290
1402
  ...e.body.headers ?? [],
1291
1403
  ...e.body.rows ?? [],
1292
1404
  ...e.body.footers ?? []
1293
- ], d = [], h = [], m = /* @__PURE__ */ new Set(), p = /* @__PURE__ */ new Set();
1294
- z({ fontFamily: s?.fontFamily }, p);
1295
- const f = [];
1296
- for (const _ of a) {
1297
- let k;
1405
+ ], a = [], h = [], m = /* @__PURE__ */ new Set(), y = /* @__PURE__ */ new Set();
1406
+ D({ fontFamily: s?.fontFamily }, y);
1407
+ const b = [];
1408
+ for (const A of u) {
1409
+ let C;
1298
1410
  if (l) {
1299
- const x = c.rows.get(_);
1300
- x && x.key === u ? (k = x.parts, c.stats.hits++) : (k = pe(_, s, t, r), c.rows.set(_, { key: u, parts: k }), c.stats.misses++);
1411
+ const k = c.rows.get(A);
1412
+ k && k.key === d ? (C = k.parts, c.stats.hits++) : (C = ve(A, s, t, r), c.rows.set(A, { key: d, parts: C }), c.stats.misses++);
1301
1413
  } else
1302
- k = pe(_, s, t, r);
1303
- d.push(k.html);
1304
- for (const x of k.styles)
1305
- m.has(x) || (m.add(x), h.push(x));
1306
- for (const x of k.fonts) p.add(x);
1307
- for (const x of k.overrides) f.push(x);
1414
+ C = ve(A, s, t, r);
1415
+ a.push(C.html);
1416
+ for (const k of C.styles)
1417
+ m.has(k) || (m.add(k), h.push(k));
1418
+ for (const k of C.fonts) y.add(k);
1419
+ for (const k of C.overrides) b.push(k);
1308
1420
  }
1309
- const g = d.join(`
1310
- `), y = [...p], b = ve(f, i), v = Te(e), w = [...h, ...b ? [b] : [], ...v ? [v] : []];
1311
- let $ = r ? et(g, s, { fontUrls: y, styles: w, title: o?.title }) : Be(g, We(i), s, {
1312
- fontUrls: y,
1421
+ const f = a.join(`
1422
+ `), p = [...y], g = Ee(b, i), $ = Be(e), w = [...h, ...g ? [g] : [], ...$ ? [$] : []];
1423
+ let v = r ? dt(f, s, { fontUrls: p, styles: w, title: n?.title }) : Ze(f, Ye(i), s, {
1424
+ fontUrls: p,
1313
1425
  styles: w,
1314
- title: o?.title
1426
+ title: n?.title,
1427
+ darkMode: !!$
1315
1428
  });
1316
- if (o?.mergeTags)
1317
- for (const [_, k] of Object.entries(o.mergeTags))
1318
- $ = $.replaceAll(`{{${_}}}`, k);
1319
- o?.designTags && ($ = Ht($, o.designTags, o.designTagsDelimiter)), o?.inlineStyles && ($ = _t($)), o?.cleanup && ($ = Et($)), o?.minify && ($ = Rt($));
1320
- const j = Zt($), O = {
1321
- html: $,
1429
+ if (n?.mergeTags)
1430
+ for (const [A, C] of Object.entries(n.mergeTags))
1431
+ v = v.replaceAll(`{{${A}}}`, C);
1432
+ n?.designTags && (v = un(v, n.designTags, n.designTagsDelimiter)), !r && n?.displayMode !== "popup" && (v = Qt(v)), n?.inlineStyles && (v = Dt(v)), n?.cleanup && (v = Wt(v)), (n?.minify ?? !r) && (v = Ft(v));
1433
+ const x = pn(v), E = {
1434
+ html: v,
1322
1435
  chunks: {
1323
- body: j.body,
1324
- css: j.css,
1325
- fonts: y,
1436
+ body: x.body,
1437
+ css: x.css,
1438
+ fonts: p,
1326
1439
  js: ""
1327
1440
  }
1328
1441
  };
1329
- if (l) {
1330
- let _;
1331
- Object.defineProperty(O, "design", {
1332
- enumerable: !0,
1333
- configurable: !0,
1334
- get: () => _ ??= structuredClone(e),
1335
- set: (k) => {
1336
- _ = k;
1337
- }
1338
- });
1339
- } else
1340
- O.design = structuredClone(e);
1341
- return O;
1442
+ if (!l) return { ...E, design: structuredClone(e) };
1443
+ let W;
1444
+ return {
1445
+ ...E,
1446
+ get design() {
1447
+ return W ??= structuredClone(e);
1448
+ },
1449
+ set design(A) {
1450
+ W = A;
1451
+ }
1452
+ };
1342
1453
  }
1343
- function Qt(e, t, o, n) {
1344
- const { html: s } = qt(
1454
+ function $n(e, t, n, o) {
1455
+ const { html: s } = an(
1345
1456
  e,
1346
1457
  t,
1347
- { ...o, inlineStyles: !1, minify: !1, cleanup: !1 },
1348
- n
1458
+ { ...n, inlineStyles: !1, minify: !1, cleanup: !1 },
1459
+ o
1349
1460
  );
1350
- return Dt(s, { wordwrap: o?.wordwrap, linkStyle: o?.linkStyle });
1461
+ return nn(s, { wordwrap: n?.wordwrap, linkStyle: n?.linkStyle });
1351
1462
  }
1352
- function Ht(e, t, o = ["{{", "}}"]) {
1353
- const [n, s] = o;
1463
+ function un(e, t, n = ["{{", "}}"]) {
1464
+ const [o, s] = n;
1354
1465
  let i = e;
1355
1466
  for (const [r, c] of Object.entries(t))
1356
- i = i.replaceAll(`${n}${r}${s}`, String(c));
1467
+ i = i.replaceAll(`${o}${r}${s}`, String(c));
1357
1468
  return i;
1358
1469
  }
1359
- function Ft(e) {
1470
+ function dn(e) {
1360
1471
  return e === "fontFamily" || e.endsWith("FontFamily");
1361
1472
  }
1362
- function z(e, t, o = 0) {
1363
- if (!(!e || typeof e != "object" || o > 4)) {
1364
- for (const [n, s] of Object.entries(e))
1473
+ function D(e, t, n = 0) {
1474
+ if (!(!T(e) || n > 4)) {
1475
+ for (const [o, s] of Object.entries(e))
1365
1476
  if (!(!s || typeof s != "object"))
1366
- if (Ft(n)) {
1367
- const i = s.url;
1477
+ if (dn(o)) {
1478
+ const i = T(s) ? s.url : void 0;
1368
1479
  typeof i == "string" && i.trim() && t.add(i.trim());
1369
1480
  } else
1370
- z(s, t, o + 1);
1481
+ D(s, t, n + 1);
1371
1482
  }
1372
1483
  }
1373
- function Vt(e) {
1484
+ function vn(e) {
1374
1485
  const t = /* @__PURE__ */ new Set();
1375
- z({ fontFamily: e.body.values?.fontFamily }, t);
1376
- const o = ee(e);
1377
- for (const n of o)
1378
- for (const s of n.columns ?? [])
1486
+ D({ fontFamily: e.body.values?.fontFamily }, t);
1487
+ const n = se(e);
1488
+ for (const o of n)
1489
+ for (const s of o.columns ?? [])
1379
1490
  for (const i of s.contents ?? [])
1380
- z(i.values, t);
1491
+ D(i.values, t);
1381
1492
  return [...t];
1382
1493
  }
1383
- function Ut(e) {
1384
- const t = B(e), o = [], n = /* @__PURE__ */ new Set(), s = [];
1494
+ function fn(e) {
1495
+ const t = O(e), n = [], o = /* @__PURE__ */ new Set(), s = [];
1385
1496
  for (let i = 0; i < t.length; i++) {
1386
1497
  const r = t[i];
1387
1498
  if (r.type === "open" && r.name === "style" && !r.selfClosing) {
1388
1499
  let c = i + 1, l = "";
1389
- t[c]?.type === "rawtext" && (l = t[c].raw.trim(), c++);
1390
- const u = r.attrs.find((a) => a.name === "media")?.value?.trim();
1391
- if (l && u && u !== "all" && (l = `@media ${u} {
1500
+ const d = t[c];
1501
+ d?.type === "rawtext" && (l = d.raw.trim(), c++);
1502
+ const u = r.attrs.find((h) => h.name === "media")?.value?.trim();
1503
+ l && u && u !== "all" && (l = `@media ${u} {
1392
1504
  ${l}
1393
- }`), t[c]?.type === "close" && t[c].name === "style") {
1394
- l && !n.has(l) && (n.add(l), o.push(l)), i = c;
1505
+ }`);
1506
+ const a = t[c];
1507
+ if (a?.type === "close" && a.name === "style") {
1508
+ l && !o.has(l) && (o.add(l), n.push(l)), i = c;
1395
1509
  continue;
1396
1510
  }
1397
1511
  }
1398
1512
  s.push(r);
1399
1513
  }
1400
- return { html: o.length || s.length !== t.length ? U(s) : e, styles: o };
1514
+ return { html: n.length || s.length !== t.length ? P(s) : e, styles: n };
1401
1515
  }
1402
- function Zt(e) {
1403
- const t = e.match(/<body[^>]*>([\s\S]*)<\/body>/i);
1516
+ function pn(e) {
1404
1517
  return {
1405
- body: t ? t[1].trim() : e,
1406
- css: Kt(e)
1518
+ body: e.match(/<body[^>]*>([\s\S]*)<\/body>/i)?.[1]?.trim() ?? e,
1519
+ css: mn(e)
1407
1520
  };
1408
1521
  }
1409
- function Kt(e) {
1410
- const t = /<!--[\s\S]*?-->|<(script|textarea)\b[^>]*>[\s\S]*?<\/\1\s*>|<style\b[^>]*>([\s\S]*?)<\/style\s*>/gi, o = [];
1411
- let n;
1412
- for (; n = t.exec(e); ) {
1413
- if (n[2] === void 0) continue;
1414
- const s = n[2].trim();
1415
- s && o.push(s);
1522
+ function mn(e) {
1523
+ const t = /<!--[\s\S]*?-->|<(script|textarea)\b[^>]*>[\s\S]*?<\/\1\s*>|<style\b[^>]*>([\s\S]*?)<\/style\s*>/gi, n = [];
1524
+ let o;
1525
+ for (; o = t.exec(e); ) {
1526
+ if (o[2] === void 0) continue;
1527
+ const s = o[2].trim();
1528
+ s && n.push(s);
1416
1529
  }
1417
- return o.join(`
1530
+ return n.join(`
1418
1531
  `);
1419
1532
  }
1420
- function en(e) {
1421
- const t = [], o = [];
1422
- e.includes("<!DOCTYPE") || t.push({ rule: "doctype", message: "Missing <!DOCTYPE> declaration. Required for consistent rendering.", severity: "error" }), (!e.includes("<meta") || !e.includes("charset")) && t.push({ rule: "charset", message: 'Missing charset meta tag. Add <meta charset="UTF-8">.', severity: "error" }), e.includes("viewport") || o.push({ rule: "viewport", message: "Missing viewport meta tag. Needed for responsive rendering on mobile.", severity: "warning" });
1423
- const n = (e.match(/<table/gi) || []).length, s = (e.match(/role="presentation"/gi) || []).length;
1424
- n > 0 && s < n * 0.5 && o.push({ rule: "table-role", message: `Only ${s}/${n} tables have role="presentation". Screen readers may interpret layout tables as data tables.`, severity: "warning" });
1533
+ function wn(e) {
1534
+ const t = [], n = [];
1535
+ e.includes("<!DOCTYPE") || t.push({ rule: "doctype", message: "Missing <!DOCTYPE> declaration. Required for consistent rendering.", severity: "error" }), (!e.includes("<meta") || !e.includes("charset")) && t.push({ rule: "charset", message: 'Missing charset meta tag. Add <meta charset="UTF-8">.', severity: "error" }), e.includes("viewport") || n.push({ rule: "viewport", message: "Missing viewport meta tag. Needed for responsive rendering on mobile.", severity: "warning" });
1536
+ const o = (e.match(/<table/gi) || []).length, s = (e.match(/role="presentation"/gi) || []).length;
1537
+ o > 0 && s < o * 0.5 && n.push({ rule: "table-role", message: `Only ${s}/${o} tables have role="presentation". Screen readers may interpret layout tables as data tables.`, severity: "warning" });
1425
1538
  const i = e.match(/<img[^>]*>/gi) || [];
1426
- for (const g of i)
1427
- g.includes("alt=") || t.push({ rule: "img-alt", message: "Image missing alt attribute. Required for accessibility and when images are blocked.", severity: "error" }), (!g.includes("style=") || !g.includes("display")) && o.push({ rule: "img-display", message: "Image without display:block may have a bottom gap in some email clients.", severity: "warning" }), (g.includes('width="100%"') || !g.includes("width=") && !g.includes("width:")) && o.push({ rule: "img-width", message: "Image without explicit pixel width. Some email clients ignore percentage widths.", severity: "warning" });
1539
+ for (const f of i)
1540
+ f.includes("alt=") || t.push({ rule: "img-alt", message: "Image missing alt attribute. Required for accessibility and when images are blocked.", severity: "error" }), (!f.includes("style=") || !f.includes("display")) && n.push({ rule: "img-display", message: "Image without display:block may have a bottom gap in some email clients.", severity: "warning" }), (f.includes('width="100%"') || !f.includes("width=") && !f.includes("width:")) && n.push({ rule: "img-width", message: "Image without explicit pixel width. Some email clients ignore percentage widths.", severity: "warning" });
1428
1541
  const r = e.match(/<style[^>]*>[\s\S]*?<\/style>/gi) || [], c = e.includes('style="');
1429
- r.length > 0 && !e.includes("@media") && o.push({ rule: "no-media-queries", message: "Style block found but no @media queries. Consider adding responsive breakpoints.", severity: "warning" }), !c && n > 0 && t.push({ rule: "inline-styles", message: "No inline styles detected. Gmail and many clients strip <style> tags — inline styles are essential.", severity: "error" });
1542
+ r.length > 0 && !e.includes("@media") && n.push({ rule: "no-media-queries", message: "Style block found but no @media queries. Consider adding responsive breakpoints.", severity: "warning" }), !c && o > 0 && t.push({ rule: "inline-styles", message: "No inline styles detected. Gmail and many clients strip <style> tags — inline styles are essential.", severity: "error" });
1430
1543
  const l = ["position:fixed", "position:absolute", "display:flex", "display:grid", "gap:", "transform:", "animation:"];
1431
- for (const g of l)
1432
- e.includes('style="') && e.match(new RegExp(`style="[^"]*${g.replace(":", ":\\s*")}`, "i")) && o.push({ rule: "unsupported-css", message: `CSS property "${g.replace(":", "")}" not supported in most email clients.`, severity: "warning" });
1433
- e.includes("<!--[if") || o.push({ rule: "mso-conditionals", message: "No MSO conditional comments found. Outlook may not render multi-column layouts correctly.", severity: "warning" }), !e.includes("xmlns:v") && !e.includes("xmlns:o") && o.push({ rule: "mso-namespace", message: "Missing Microsoft Office XML namespaces. May affect Outlook rendering.", severity: "warning" });
1434
- const a = (e.match(/<a[^>]*>/gi) || []).filter((g) => !g.includes("style="));
1435
- a.length > 0 && o.push({ rule: "link-color", message: `${a.length} link(s) without inline styles. Email clients override unstyled link colors.`, severity: "warning" }), !e.includes("color-scheme") && !e.includes("prefers-color-scheme") && o.push({ rule: "dark-mode", message: "No dark mode support detected. Consider adding color-scheme meta and prefers-color-scheme media query.", severity: "warning" });
1436
- const d = Math.round(e.length / 1024);
1437
- d > 102 ? t.push({ rule: "size-limit", message: `Email HTML is ${d}KB. Gmail clips emails larger than 102KB.`, severity: "error" }) : d > 80 && o.push({ rule: "size-warning", message: `Email HTML is ${d}KB. Getting close to Gmail's 102KB clip limit.`, severity: "warning" }), !e.includes("display:none") && !e.includes("max-height:0") && o.push({ rule: "preheader", message: "No preheader text detected. Preheader text improves open rates in inbox previews.", severity: "warning" });
1438
- const h = 100, m = t.length * 15, p = o.length * 5, f = Math.max(0, h - m - p);
1544
+ for (const f of l)
1545
+ e.includes('style="') && e.match(new RegExp(`style="[^"]*${f.replace(":", ":\\s*")}`, "i")) && n.push({ rule: "unsupported-css", message: `CSS property "${f.replace(":", "")}" not supported in most email clients.`, severity: "warning" });
1546
+ e.includes("<!--[if") || n.push({ rule: "mso-conditionals", message: "No MSO conditional comments found. Outlook may not render multi-column layouts correctly.", severity: "warning" }), !e.includes("xmlns:v") && !e.includes("xmlns:o") && n.push({ rule: "mso-namespace", message: "Missing Microsoft Office XML namespaces. May affect Outlook rendering.", severity: "warning" });
1547
+ const u = (e.match(/<a[^>]*>/gi) || []).filter((f) => !f.includes("style="));
1548
+ u.length > 0 && n.push({ rule: "link-color", message: `${u.length} link(s) without inline styles. Email clients override unstyled link colors.`, severity: "warning" }), !e.includes("color-scheme") && !e.includes("prefers-color-scheme") && n.push({ rule: "dark-mode", message: "No dark mode support detected. Consider adding color-scheme meta and prefers-color-scheme media query.", severity: "warning" });
1549
+ const a = Math.round(e.length / 1024);
1550
+ a > 102 ? t.push({ rule: "size-limit", message: `Email HTML is ${a}KB. Gmail clips emails larger than 102KB.`, severity: "error" }) : a > 80 && n.push({ rule: "size-warning", message: `Email HTML is ${a}KB. Getting close to Gmail's 102KB clip limit.`, severity: "warning" }), !e.includes("display:none") && !e.includes("max-height:0") && n.push({ rule: "preheader", message: "No preheader text detected. Preheader text improves open rates in inbox previews.", severity: "warning" });
1551
+ const h = 100, m = t.length * 15, y = n.length * 5, b = Math.max(0, h - m - y);
1439
1552
  return {
1440
1553
  valid: t.length === 0,
1441
1554
  errors: t,
1442
- warnings: o,
1443
- score: f
1555
+ warnings: n,
1556
+ score: b
1444
1557
  };
1445
1558
  }
1446
1559
  export {
1447
- ee as allRows,
1448
- he as bodyFontWeight,
1449
- Te as buildDarkModeCss,
1450
- Yt as buildResponsiveOverridesCss,
1451
- A as cleanCssValue,
1452
- Et as cleanupHtml,
1453
- Vt as collectFontUrls,
1454
- oe as contentElementId,
1455
- Jt as createRenderCache,
1456
- X as decodeEntities,
1457
- ge as documentLanguage,
1458
- me as documentTitle,
1459
- _e as getDarkOverrides,
1460
- D as getMobileOverrides,
1461
- We as getResponsiveCss,
1462
- Qe as getWebCss,
1463
- Xt as hasDarkMode,
1464
- _t as inlineCss,
1465
- Oe as isLanguageCode,
1466
- K as isSafeCssValue,
1467
- N as kebabKey,
1468
- ht as minifyCss,
1469
- Rt as minifyHtml,
1470
- ne as mobileMediaQuery,
1471
- Ne as overrideClass,
1472
- F as overrideDeclarations,
1473
- qt as renderDesignToHtml,
1474
- Qt as renderDesignToPlainText,
1475
- Dt as renderPlainText,
1476
- Ue as renderRow,
1477
- Ye as renderWebRow,
1478
- Ht as replaceDesignTags,
1560
+ se as allRows,
1561
+ xe as bodyFontWeight,
1562
+ Be as buildDarkModeCss,
1563
+ gn as buildResponsiveOverridesCss,
1564
+ j as cleanCssValue,
1565
+ Wt as cleanupHtml,
1566
+ vn as collectFontUrls,
1567
+ le as contentElementId,
1568
+ bn as createRenderCache,
1569
+ V as decodeEntities,
1570
+ ke as documentLanguage,
1571
+ we as documentTitle,
1572
+ ze as getDarkOverrides,
1573
+ B as getMobileOverrides,
1574
+ Ye as getResponsiveCss,
1575
+ at as getWebCss,
1576
+ yn as hasDarkMode,
1577
+ Dt as inlineCss,
1578
+ Fe as isLanguageCode,
1579
+ Z as isSafeCssValue,
1580
+ L as kebabKey,
1581
+ At as minifyCss,
1582
+ Ft as minifyHtml,
1583
+ N as mobileMediaQuery,
1584
+ Xe as overrideClass,
1585
+ U as overrideDeclarations,
1586
+ an as renderDesignToHtml,
1587
+ $n as renderDesignToPlainText,
1588
+ nn as renderPlainText,
1589
+ st as renderRow,
1590
+ rt as renderWebRow,
1591
+ un as replaceDesignTags,
1479
1592
  H as rowElementId,
1480
- Je as stripMsoConditionals,
1481
- en as validateEmailHtml,
1482
- Be as wrapInDocumentShell,
1483
- et as wrapInWebShell,
1484
- Bt as wrapText,
1485
- te as wrapWithDisplayCondition
1593
+ Qt as stripActiveContent,
1594
+ ct as stripMsoConditionals,
1595
+ wn as validateEmailHtml,
1596
+ Ze as wrapInDocumentShell,
1597
+ dt as wrapInWebShell,
1598
+ on as wrapText,
1599
+ re as wrapWithDisplayCondition
1486
1600
  };
1487
1601
  //# sourceMappingURL=index.js.map