@emailens/cli 0.13.4 → 0.13.6

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.
@@ -62871,21 +62871,6 @@ function rgbToOklab(rgba) {
62871
62871
  0.0259040371 * l2 + 0.7827717662 * m2 - 0.808675766 * s2
62872
62872
  ];
62873
62873
  }
62874
- function oklabToRgb([L3, A3, B2]) {
62875
- const l2 = (L3 + 0.3963377774 * A3 + 0.2158037573 * B2) ** 3;
62876
- const m2 = (L3 - 0.1055613458 * A3 - 0.0638541728 * B2) ** 3;
62877
- const s2 = (L3 - 0.0894841775 * A3 - 1.291485548 * B2) ** 3;
62878
- const toGamma = (c2) => {
62879
- const v = c2 <= 31308e-7 ? 12.92 * c2 : 1.055 * Math.pow(c2, 1 / 2.4) - 0.055;
62880
- return Math.round(Math.min(1, Math.max(0, v)) * 255);
62881
- };
62882
- return {
62883
- r: toGamma(4.0767416621 * l2 - 3.3077115913 * m2 + 0.2309699292 * s2),
62884
- g: toGamma(-1.2684380046 * l2 + 2.6097574011 * m2 - 0.3413193965 * s2),
62885
- b: toGamma(-0.0041960863 * l2 - 0.7034186147 * m2 + 1.707662439 * s2),
62886
- a: 1
62887
- };
62888
- }
62889
62874
  function colorDistance(a2, b2) {
62890
62875
  const [l1, a1, b1] = rgbToOklab(a2);
62891
62876
  const [l2, a22, b22] = rgbToOklab(b2);
@@ -63286,7 +63271,10 @@ var DOWNLEVEL_REVEALED = /<!--\[if[^\]]*!\s*\(*\s*(?:mso|vml|true)[^\]]*\]>\s*<(
63286
63271
  var DOWNLEVEL_HIDDEN = /<!--\[if(?![^\]]*!)[^\]]*(?:mso|vml|true)[^\]]*\]>([\s\S]*?)<!\[endif\]-->/gi;
63287
63272
  var OFFICE_SETTINGS = /<xml\b[^>]*>[\s\S]*?<\/xml>/gi;
63288
63273
  function resolveMsoBranch(html3) {
63289
- return html3.replace(DOWNLEVEL_REVEALED, "").replace(DOWNLEVEL_HIDDEN, "$1").replace(OFFICE_SETTINGS, "");
63274
+ return html3.replace(DOWNLEVEL_REVEALED, "").replace(
63275
+ DOWNLEVEL_HIDDEN,
63276
+ (_3, inner) => /^\s*<style/i.test(inner) ? inner.replace(/(\.[\w-]+\s*\{[^}]*?)font-size\s*:[^;}]*;?/g, "$1") : inner
63277
+ ).replace(OFFICE_SETTINGS, "");
63290
63278
  }
63291
63279
  var MSO_HIDE = /mso-hide\s*:\s*all/i;
63292
63280
  function applyMsoHide(html3) {
@@ -63625,7 +63613,7 @@ var NATURAL_LINE = 1.15;
63625
63613
  var TABLE_GUTTER = 3.5;
63626
63614
  var INVISIBLE_ONLY = /^[\s\u00a0\u00ad\u034f\u200b-\u200d\u2007\ufeff]+$/;
63627
63615
  var LIST_TRAILING_PX = 18;
63628
- var LIST_INDENT_PX = 24;
63616
+ var LIST_TEXT_INDENT_PX = 48;
63629
63617
  var MAX_BORDER_PX = 8;
63630
63618
  var capBorder = (value) => value.replace(
63631
63619
  /(\d+(?:\.\d+)?)px/gi,
@@ -63677,7 +63665,8 @@ function fontFaceWinners($3, faces) {
63677
63665
  order++;
63678
63666
  for (const one of selector.split(",")) {
63679
63667
  if (!one.trim() || IGNORED_BY_WORD.test(one)) continue;
63680
- const family2 = one.trim() === "*" ? TIMES : drawn;
63668
+ const universal = one.trim() === "*";
63669
+ const family2 = universal ? WORD_DEFAULT : drawn;
63681
63670
  let matched;
63682
63671
  try {
63683
63672
  matched = $3(one).toArray();
@@ -63687,7 +63676,8 @@ function fontFaceWinners($3, faces) {
63687
63676
  const weight = (important ? 1e12 : 0) + specificity(one.trim()) * 1e5 + order;
63688
63677
  for (const el2 of matched) {
63689
63678
  const was = best.get(el2);
63690
- if (!was || weight > was.weight) best.set(el2, { weight, family: family2 });
63679
+ const inherited2 = universal && $3(el2).parents("[style*='font-family']").length > 0;
63680
+ if (!was || weight > was.weight) best.set(el2, { weight, family: inherited2 ? "inherit" : family2 });
63691
63681
  }
63692
63682
  }
63693
63683
  }
@@ -63697,6 +63687,14 @@ function fontFaceWinners($3, faces) {
63697
63687
  return out;
63698
63688
  }
63699
63689
  var IGNORED_BY_WORD = /\[|>|:first-child|:nth-child|:not\(|::?before|\.[\w-]+\.[\w-]/;
63690
+ function matchedByWord($3, selector) {
63691
+ if (!selector.trim() || IGNORED_BY_WORD.test(selector)) return [];
63692
+ try {
63693
+ return $3(selector).toArray();
63694
+ } catch (e2) {
63695
+ return [];
63696
+ }
63697
+ }
63700
63698
  function overrideStylesheetRules($3, faces) {
63701
63699
  var _a22;
63702
63700
  const override = (el2, declarations) => {
@@ -63719,14 +63717,7 @@ function overrideStylesheetRules($3, faces) {
63719
63717
  const hides = props.get("display") === "none";
63720
63718
  if (!hasPadding && !hasSize && !hasBackground && !hides) continue;
63721
63719
  for (const one of selector.split(",")) {
63722
- if (!one.trim() || IGNORED_BY_WORD.test(one)) continue;
63723
- let matched;
63724
- try {
63725
- matched = $3(one).toArray();
63726
- } catch (e2) {
63727
- continue;
63728
- }
63729
- for (const el2 of matched) {
63720
+ for (const el2 of matchedByWord($3, one)) {
63730
63721
  const tag = (_b = el2.tagName) == null ? void 0 : _b.toLowerCase();
63731
63722
  if (hasPadding && (tag === "div" || tag === "p" || tag === "span" || tag === "a"))
63732
63723
  override(el2, "padding:0!important");
@@ -63769,6 +63760,10 @@ function markHiddenCells(html3) {
63769
63760
  const style = (_a22 = dq != null ? dq : sq) != null ? _a22 : "";
63770
63761
  if (!/display\s*:\s*none/i.test(style) || /mso-hide\s*:/i.test(style)) return whole;
63771
63762
  const quote = dq === void 0 ? "'" : '"';
63763
+ if (/^<t[dh]\s/i.test(lead) && /padding/i.test(style)) {
63764
+ const kept = style.replace(/display\s*:\s*none\s*(?:!important)?\s*;?/gi, "");
63765
+ return `${lead}${quote}${kept}${/;\s*$/.test(kept) ? "" : ";"}mso-hollow:1${quote}`;
63766
+ }
63772
63767
  return `${lead}${quote}${style}${/;\s*$/.test(style) ? "" : ";"}mso-hide:all${quote}`;
63773
63768
  }
63774
63769
  );
@@ -63783,22 +63778,24 @@ function declaredFaces($3) {
63783
63778
  for (const [, body] of ((_a22 = $3(block).html()) != null ? _a22 : "").matchAll(/@font-face\s*\{([^}]*)\}/gi)) {
63784
63779
  const props = parseInlineStyle(body);
63785
63780
  const family = props.get("font-family");
63786
- const alt = ((_b = props.get("mso-font-alt")) == null ? void 0 : _b.replace(/["']/g, "").trim()) || null;
63781
+ const named = ((_b = props.get("mso-font-alt")) == null ? void 0 : _b.replace(/["']/g, "").trim()) || null;
63782
+ const alt = named && /^sans-serif$/i.test(named) ? WORD_DEFAULT : named;
63787
63783
  if (family) faces.set(firstFamily(family), (_c2 = alt != null ? alt : faces.get(firstFamily(family))) != null ? _c2 : null);
63788
63784
  }
63789
63785
  });
63790
63786
  return faces;
63791
63787
  }
63792
63788
  var firstFamily = (value) => value.split(",")[0].replace(/["']|!important/gi, "").trim().toLowerCase();
63793
- var TIMES = "'Times New Roman',serif";
63789
+ var WORD_DEFAULT = "Aptos,'Segoe UI',sans-serif";
63794
63790
  function wordFamily(value, faces) {
63795
- if (/(^|,)\s*system-ui\s*(,|$)/i.test(value.replace(/!important/gi, ""))) return TIMES;
63796
- const first2 = firstFamily(value);
63797
- if (!faces.has(first2)) return null;
63791
+ const families = value.replace(/!important/gi, "").split(",");
63792
+ const named = families.filter((f3) => !/^\s*(?:system-ui|ui-[a-z-]+)\s*$/i.test(f3));
63793
+ const first2 = firstFamily(named.join(","));
63794
+ if (!faces.has(first2)) return named.length < families.length ? named.join(",").trim() || WORD_DEFAULT : null;
63798
63795
  const alt = faces.get(first2);
63799
- if (alt) return `'${alt}'`;
63800
- const rest = value.replace(/!important/gi, "").split(",").slice(1).join(",").trim();
63801
- return rest || TIMES;
63796
+ if (alt) return alt === WORD_DEFAULT ? alt : `'${alt}'`;
63797
+ const rest = named.slice(1).join(",").trim();
63798
+ return rest || WORD_DEFAULT;
63802
63799
  }
63803
63800
  function hasBorder(props) {
63804
63801
  for (const prop2 of ["border", "border-top", "border-right", "border-bottom", "border-left"]) {
@@ -63818,7 +63815,7 @@ function leftPadding(props) {
63818
63815
  function applyWordBoxModel($3) {
63819
63816
  const faces = declaredFaces($3);
63820
63817
  $3("[style]").each((_3, node) => {
63821
- var _a22, _b, _c2, _d, _e2, _f, _g;
63818
+ var _a22, _b, _c2, _d, _e2, _f, _g, _h2, _i2, _j, _k, _l2, _m2, _n2;
63822
63819
  const el2 = node;
63823
63820
  const tag = (_a22 = el2.tagName) == null ? void 0 : _a22.toLowerCase();
63824
63821
  const props = parseInlineStyle($3(el2).attr("style") || "");
@@ -63826,20 +63823,37 @@ function applyWordBoxModel($3) {
63826
63823
  for (const prop2 of [...PADDING, ...MARGIN]) {
63827
63824
  if (/\d(?:\.\d+)?rem\b/i.test((_b = props.get(prop2)) != null ? _b : "")) props.delete(prop2);
63828
63825
  }
63829
- const bordered = (tag === "div" || tag === "p") && hasBorder(props);
63830
- if ((tag === "div" || tag === "p" || tag === "span" || tag === "a") && !bordered) {
63826
+ const bordered = (tag === "div" || tag === "p" || tag === "a") && hasBorder(props);
63827
+ if (bordered && tag === "a") {
63828
+ props.set("display", "inline-block");
63829
+ $3(el2).attr("data-word-box", "");
63830
+ const fill = (_c2 = props.get("background-color")) != null ? _c2 : props.get("background");
63831
+ if (fill) {
63832
+ props.delete("background-color");
63833
+ props.delete("background");
63834
+ $3(el2).html(`<span style="background-color:${fill}">${$3(el2).html()}</span>`);
63835
+ }
63836
+ }
63837
+ if (bordered && !props.has("border") && !props.has("border-top")) props.set("padding-top", "0");
63838
+ const spacerRuns = tag === "a" && ((_d = $3(el2).html()) == null ? void 0 : _d.includes("mso-font-width"));
63839
+ if (spacerRuns) props.set("display", "inline-block");
63840
+ if ((tag === "div" || tag === "p" || tag === "span" || tag === "a") && !bordered && !spacerRuns) {
63831
63841
  for (const prop2 of PADDING) props.delete(prop2);
63832
63842
  }
63833
- if (/^(?:fit|max|min)-content$/i.test(((_c2 = props.get("width")) != null ? _c2 : "").replace(/!important/i, "").trim())) props.delete("width");
63843
+ if (/^(?:fit|max|min)-content$/i.test(((_e2 = props.get("width")) != null ? _e2 : "").replace(/!important/i, "").trim())) props.delete("width");
63834
63844
  if (tag === "div" || tag === "span") {
63835
63845
  props.delete("width");
63836
63846
  props.delete("height");
63837
63847
  }
63838
- if (tag === "div") {
63848
+ if (tag === "div" || tag === "table") {
63839
63849
  for (const prop2 of MARGIN) {
63840
63850
  const value = props.get(prop2);
63841
63851
  if (value !== void 0) props.set(prop2, flattenMargin(value));
63842
63852
  }
63853
+ if (tag === "table" && /center/i.test((_f = $3(el2).attr("align")) != null ? _f : "")) {
63854
+ props.delete("margin-top");
63855
+ props.delete("margin-bottom");
63856
+ }
63843
63857
  }
63844
63858
  if ((tag === "div" || tag === "h2") && holdsNoText($3, el2)) {
63845
63859
  props.delete("background");
@@ -63848,18 +63862,24 @@ function applyWordBoxModel($3) {
63848
63862
  const family = props.get("font-family");
63849
63863
  const drawn = family === void 0 ? null : wordFamily(family, faces);
63850
63864
  if (drawn) props.set("font-family", drawn);
63865
+ if ((tag === "body" || tag === "td") && /^\s*sans-serif(?![\w-])/i.test((_g = drawn != null ? drawn : family) != null ? _g : "")) props.set("font-family", WORD_DEFAULT);
63866
+ if (/none/i.test((_h2 = props.get("mso-border-alt")) != null ? _h2 : "")) {
63867
+ for (const prop2 of [...props.keys()]) if (prop2.startsWith("border") && prop2 !== "border-radius") props.delete(prop2);
63868
+ }
63869
+ if (/transparent/i.test((_i2 = props.get("mso-shading")) != null ? _i2 : "")) props.delete("background-color");
63851
63870
  const lineAlt = props.get("mso-line-height-alt");
63852
- if (lineAlt !== void 0) props.set("line-height", lineAlt);
63853
- const lineHeight = /^([\d.]+)px$/i.exec((_d = props.get("line-height")) != null ? _d : "");
63854
- const fontSize = /^([\d.]+)px$/i.exec((_e2 = props.get("font-size")) != null ? _e2 : "");
63855
- if (lineHeight && fontSize && !/exactly/i.test((_f = props.get("mso-line-height-rule")) != null ? _f : "")) {
63871
+ const altEm = /^([\d.]+)em$/i.exec((_j = lineAlt == null ? void 0 : lineAlt.trim()) != null ? _j : "");
63872
+ if (lineAlt !== void 0) props.set("line-height", altEm ? `${Number(altEm[1]) * 16}px` : lineAlt);
63873
+ const lineHeight = /^([\d.]+)px$/i.exec((_k = props.get("line-height")) != null ? _k : "");
63874
+ const fontSize = /^([\d.]+)px$/i.exec((_l2 = props.get("font-size")) != null ? _l2 : "");
63875
+ if (lineHeight && fontSize && !/exactly/i.test((_m2 = props.get("mso-line-height-rule")) != null ? _m2 : "")) {
63856
63876
  const natural = Math.round(Number(fontSize[1]) * NATURAL_LINE);
63857
63877
  if (Number(lineHeight[1]) < natural) props.set("line-height", `${natural}px`);
63858
63878
  }
63859
63879
  for (const prop2 of ["word-spacing", "outline", "outline-width", "outline-style", "outline-color", "outline-offset"]) {
63860
63880
  props.delete(prop2);
63861
63881
  }
63862
- if (tag === "div" && /^center$/i.test((_g = props.get("text-align")) != null ? _g : "") && !$3(el2).attr("align")) {
63882
+ if (tag === "div" && /^center$/i.test((_n2 = props.get("text-align")) != null ? _n2 : "") && !$3(el2).attr("align")) {
63863
63883
  $3(el2).attr("align", "center");
63864
63884
  props.delete("text-align");
63865
63885
  }
@@ -63882,6 +63902,38 @@ function applyWordBoxModel($3) {
63882
63902
  else $3(el2).removeAttr("style");
63883
63903
  }
63884
63904
  });
63905
+ $3("td[style*='mso-hollow'], th[style*='mso-hollow']").each((_3, node) => {
63906
+ const cell = $3(node);
63907
+ const props = parseInlineStyle(cell.attr("style") || "");
63908
+ props.delete("mso-hollow");
63909
+ props.set("display", "table-cell!important");
63910
+ props.set("font-size", "0");
63911
+ props.set("line-height", "0");
63912
+ cell.empty().attr("style", serializeStyle(props));
63913
+ });
63914
+ $3("hr").each((_3, node) => {
63915
+ var _a22, _b, _c2;
63916
+ const props = parseInlineStyle($3(node).attr("style") || "");
63917
+ const [top = "", , bottom = top] = ((_a22 = props.get("margin")) != null ? _a22 : "").trim().split(/\s+/).concat([""]);
63918
+ const px2 = (v) => Number.parseFloat(v != null ? v : "") || 0;
63919
+ const set = /* @__PURE__ */ new Map([
63920
+ ["border", "none"],
63921
+ ["border-top", "1px solid #a0a0a0"],
63922
+ ["height", "0"],
63923
+ ["width", "100%"],
63924
+ ["margin", `${px2((_b = props.get("margin-top")) != null ? _b : top) + 4}px 0 ${px2((_c2 = props.get("margin-bottom")) != null ? _c2 : bottom || top) + 4}px`]
63925
+ ]);
63926
+ $3(node).attr("style", serializeStyle(set));
63927
+ });
63928
+ $3("a").each((_3, node) => {
63929
+ if (!$3(node).children("div").length) return;
63930
+ $3(node).before('<div style="height:21px"></div>').after('<div style="height:20px"></div>');
63931
+ });
63932
+ $3("a[style*='text-decoration-line']").each((_3, node) => {
63933
+ const props = parseInlineStyle($3(node).attr("style") || "");
63934
+ props.delete("text-decoration-line");
63935
+ $3(node).attr("style", serializeStyle(props));
63936
+ });
63885
63937
  $3("td table, th table").each((_3, node) => {
63886
63938
  const table = node;
63887
63939
  const own = parseInlineStyle($3(table).attr("style") || "");
@@ -63898,10 +63950,11 @@ function applyWordBoxModel($3) {
63898
63950
  $3(table).attr("style", serializeStyle(props));
63899
63951
  });
63900
63952
  $3("img").each((_3, node) => {
63901
- var _a22;
63953
+ var _a22, _b, _c2, _d;
63902
63954
  const el2 = node;
63903
63955
  const props = parseInlineStyle($3(el2).attr("style") || "");
63904
63956
  const NUMBER = /^\d+(?:\.\d+)?$/;
63957
+ const percent = /^\d+(?:\.\d+)?%$/.test((_b = (_a22 = $3(el2).attr("width")) == null ? void 0 : _a22.trim()) != null ? _b : "") ? (_c2 = $3(el2).attr("width")) == null ? void 0 : _c2.trim() : void 0;
63905
63958
  const numeric = (name) => {
63906
63959
  var _a32;
63907
63960
  const value = (_a32 = $3(el2).attr(name)) == null ? void 0 : _a32.trim();
@@ -63915,11 +63968,11 @@ function applyWordBoxModel($3) {
63915
63968
  }
63916
63969
  for (const name of ["hspace", "vspace"]) $3(el2).removeAttr(name);
63917
63970
  if ($3(el2).attr("border") !== void 0) $3(el2).attr("border", "0");
63918
- props.set("width", width ? `${width}px!important` : "auto!important");
63971
+ props.set("width", percent ? `${percent}!important` : width ? `${width}px!important` : "auto!important");
63919
63972
  props.set("height", height ? `${height}px!important` : "auto!important");
63920
63973
  props.set("max-width", "none!important");
63921
63974
  props.set("vertical-align", "bottom");
63922
- if (/\.(?:svg|webp)(?:[?#]|$)/i.test((_a22 = $3(el2).attr("src")) != null ? _a22 : "")) props.set("visibility", "hidden");
63975
+ if (/\.(?:svg|webp)(?:[?#]|$)/i.test((_d = $3(el2).attr("src")) != null ? _d : "")) props.set("visibility", "hidden");
63923
63976
  const after2 = serializeStyle(props);
63924
63977
  if (after2) $3(el2).attr("style", after2);
63925
63978
  else $3(el2).removeAttr("style");
@@ -63931,20 +63984,18 @@ function applyWordBoxModel($3) {
63931
63984
  if (text3.length > 20 && INVISIBLE_ONLY.test(text3)) el2.text(String.fromCharCode(160));
63932
63985
  });
63933
63986
  $3("ul,ol").each((_3, node) => {
63934
- var _a22;
63935
63987
  const el2 = node;
63936
63988
  const props = parseInlineStyle($3(el2).attr("style") || "");
63937
- const margin = ((_a22 = props.get("margin")) != null ? _a22 : "").trim().split(/\s+/).filter(Boolean);
63938
- const indented = props.has("margin-left") || props.has("padding-left") || props.has("padding") || margin.length > 0;
63939
63989
  let previous = el2.prev;
63940
63990
  while (previous && previous.type === "text" && !previous.data.trim()) previous = previous.prev;
63941
63991
  const afterBreak = (previous == null ? void 0 : previous.type) === "tag" && previous.name === "br";
63942
- props.set("margin-top", afterBreak ? "1lh!important" : "0!important");
63943
- props.set("margin-bottom", `${LIST_TRAILING_PX}px!important`);
63944
- if (!indented) {
63945
- props.set("margin-left", `${LIST_INDENT_PX}px`);
63946
- props.set("padding-left", `${40 - LIST_INDENT_PX}px`);
63947
- }
63992
+ const tight = $3(el2).children("li").toArray().some((item) => {
63993
+ const style = parseInlineStyle($3(item).attr("style") || "");
63994
+ return style.has("margin") || style.has("margin-top") || style.has("margin-bottom");
63995
+ });
63996
+ props.set("margin-top", afterBreak || previous && !tight ? "1lh!important" : "0!important");
63997
+ props.set("margin-bottom", tight ? "0!important" : `${LIST_TRAILING_PX}px!important`);
63998
+ props.set("padding-left", `${LIST_TEXT_INDENT_PX}px!important`);
63948
63999
  $3(el2).attr("style", serializeStyle(props));
63949
64000
  });
63950
64001
  $3("picture source").remove();
@@ -63982,7 +64033,94 @@ function applyWordBoxModel($3) {
63982
64033
  })) return;
63983
64034
  cell.attr("style", `${style}${style.trim() === "" || /;\s*$/.test(style) ? "" : ";"}text-align:left`);
63984
64035
  });
63985
- const reset = "<style>p,h2{margin:0}</style>";
64036
+ $3("table").each((_3, node) => {
64037
+ var _a22, _b, _c2, _d, _e2, _f, _g, _h2;
64038
+ const table = $3(node);
64039
+ const props = parseInlineStyle(table.attr("style") || "");
64040
+ const box2 = ((_a22 = props.get("margin")) != null ? _a22 : "").trim().split(/\s+/).filter(Boolean);
64041
+ const top = Number.parseFloat((_c2 = (_b = props.get("margin-top")) != null ? _b : box2[0]) != null ? _c2 : "") || 0;
64042
+ const bottom = Number.parseFloat((_f = (_e2 = (_d = props.get("margin-bottom")) != null ? _d : box2[2]) != null ? _e2 : box2[0]) != null ? _f : "") || 0;
64043
+ if (top <= 0 && bottom <= 0 || /center/i.test((_g = table.attr("align")) != null ? _g : "")) return;
64044
+ const rows = table.find("> tr, > tbody > tr");
64045
+ const grow = (row, side, by2) => {
64046
+ row.children("td, th").each((_22, cell) => {
64047
+ var _a32, _b2, _c22, _d2;
64048
+ const own = parseInlineStyle($3(cell).attr("style") || "");
64049
+ const pad = ((_a32 = own.get("padding")) != null ? _a32 : "").trim().split(/\s+/).filter(Boolean);
64050
+ const was = Number.parseFloat((_d2 = (_c22 = own.get(`padding-${side}`)) != null ? _c22 : side === "top" ? pad[0] : (_b2 = pad[2]) != null ? _b2 : pad[0]) != null ? _d2 : "") || 0;
64051
+ own.set(`padding-${side}`, `${was + by2}px`);
64052
+ $3(cell).attr("style", serializeStyle(own));
64053
+ });
64054
+ };
64055
+ if (!rows.length) return;
64056
+ if (top > 0) grow(rows.first(), "top", top);
64057
+ if (bottom > 0) grow(rows.last(), "bottom", bottom);
64058
+ props.delete("margin-top");
64059
+ props.delete("margin-bottom");
64060
+ if (box2.length) {
64061
+ props.delete("margin");
64062
+ if (box2[1]) props.set("margin-left", (_h2 = box2[3]) != null ? _h2 : box2[1]);
64063
+ if (box2[1]) props.set("margin-right", box2[1]);
64064
+ }
64065
+ table.attr("style", serializeStyle(props));
64066
+ });
64067
+ $3("table").each((_3, node) => {
64068
+ var _a22, _b;
64069
+ const props = parseInlineStyle($3(node).attr("style") || "");
64070
+ if (!/para-border-div/i.test((_a22 = props.get("mso-element")) != null ? _a22 : "")) return;
64071
+ const width = Number.parseFloat((_b = props.get("mso-element-frame-width")) != null ? _b : "");
64072
+ if (!width) return;
64073
+ props.delete("max-width");
64074
+ props.set("width", `${width + 17}px`);
64075
+ props.set("box-sizing", "border-box");
64076
+ props.set("margin", "0 auto");
64077
+ props.set("padding", "4px 12px 4px 4px");
64078
+ props.set("border", "1px dotted #a6a6a6");
64079
+ props.set("border-collapse", "separate");
64080
+ props.set("text-align", "justify");
64081
+ $3(node).attr("style", serializeStyle(props));
64082
+ $3(node).removeAttr("width");
64083
+ });
64084
+ $3("table").each((_3, node) => {
64085
+ var _a22, _b;
64086
+ const props = parseInlineStyle($3(node).attr("style") || "");
64087
+ const zero = /^0(?:px)?\s+solid\s+(\S+)/i.exec((_b = (_a22 = props.get("border")) == null ? void 0 : _a22.trim()) != null ? _b : "");
64088
+ if (!zero) return;
64089
+ props.set("border", `1px solid ${zero[1]}`);
64090
+ $3(node).attr("style", serializeStyle(props));
64091
+ });
64092
+ const borderOf = (style) => [...parseInlineStyle(style != null ? style : "")].filter(([k2, v]) => k2.startsWith("border") && !/^0|none/.test(v)).join(";");
64093
+ $3("p").each((_3, node) => {
64094
+ var _a22;
64095
+ const p = $3(node);
64096
+ const next2 = p.next();
64097
+ const border = borderOf(p.attr("style"));
64098
+ if (!border || !next2.is("p") || borderOf(next2.attr("style")) !== border) return;
64099
+ const props = parseInlineStyle((_a22 = p.attr("style")) != null ? _a22 : "");
64100
+ for (const key of [...props.keys()]) if (key.startsWith("border")) props.delete(key);
64101
+ props.set("padding-bottom", "0");
64102
+ p.attr("style", serializeStyle(props));
64103
+ });
64104
+ const margined = /* @__PURE__ */ new Set();
64105
+ $3("style").each((_3, block) => {
64106
+ var _a22;
64107
+ for (const { selector, body } of topLevelRules((_a22 = $3(block).html()) != null ? _a22 : "")) {
64108
+ const props = parseInlineStyle(body);
64109
+ if (!props.has("margin") && !props.has("margin-top") && !props.has("margin-bottom")) continue;
64110
+ for (const one of selector.split(",")) for (const el2 of matchedByWord($3, one)) margined.add(el2);
64111
+ }
64112
+ });
64113
+ $3("p").each((_3, node) => {
64114
+ const p = $3(node);
64115
+ const props = parseInlineStyle(p.attr("style") || "");
64116
+ if (props.has("margin") || props.has("margin-top") || props.has("margin-bottom")) return;
64117
+ if (margined.has(node)) return;
64118
+ if (!p.prev().length) props.set("margin-top", "0");
64119
+ if (!p.next().length) props.set("margin-bottom", "0");
64120
+ const after2 = serializeStyle(props);
64121
+ if (after2) p.attr("style", after2);
64122
+ });
64123
+ const reset = "<style>h2{margin:0}p{margin:14pt 0}</style>";
63986
64124
  const head = $3("head");
63987
64125
  if (head.length) head.prepend(reset);
63988
64126
  else if ($3("p,h2").length) $3.root().prepend(reset);
@@ -65265,12 +65403,12 @@ function outlookWindowsAdditionalChecks($3, clientId, _html, framework) {
65265
65403
  message: "Outlook Classic ignores border-radius. Buttons and containers will have sharp corners."
65266
65404
  }, "border-radius", clientId, framework));
65267
65405
  }
65268
- if ($3("[style*='max-width']").length > 0) {
65406
+ if ($3("[style*='max-width']").not("table").length > 0) {
65269
65407
  warnings.push(makeWarning({
65270
65408
  severity: "warning",
65271
65409
  client: clientId,
65272
65410
  property: "max-width",
65273
- message: "Outlook Classic ignores max-width."
65411
+ message: "Outlook Classic ignores max-width except on tables."
65274
65412
  }, "max-width", clientId, framework));
65275
65413
  }
65276
65414
  const hasDivLayout = $3("div[style*='display']").length > 0 || $3("div[style*='flex']").length > 0 || $3("div[style*='grid']").length > 0;
@@ -65995,6 +66133,7 @@ function applyTransformDom($3, html3, config, framework) {
65995
66133
  const removed = [];
65996
66134
  props.forEach((value, prop2) => {
65997
66135
  var _a32;
66136
+ if (prop2 === "max-width" && clientId === "outlook-windows-legacy" && $3(el2).is("table")) return;
65998
66137
  if (config.strippedProperties.has(prop2)) {
65999
66138
  if (config.stripMode === "strip") {
66000
66139
  removed.push(prop2);
@@ -66480,17 +66619,42 @@ var SAMPLED_DARK = {
66480
66619
  "gmail-ios": { eeeae4: "#4a4438" }
66481
66620
  };
66482
66621
  var hex = (c2) => "#" + [c2.r, c2.g, c2.b].map((v) => v.toString(16).padStart(2, "0")).join("");
66622
+ var APP_BACKGROUND = /* @__PURE__ */ new Set(["#ffffff", "#fefefe", "#fcfcfc", "#fbfbfb", "#f9f9f9"]);
66623
+ var D50 = [0.96422, 1, 0.82521];
66624
+ var TO_XYZ = [
66625
+ [0.4360747, 0.3850649, 0.1430804],
66626
+ [0.2225045, 0.7168786, 0.0606169],
66627
+ [0.0139322, 0.0971045, 0.7141733]
66628
+ ];
66629
+ var FROM_XYZ = [
66630
+ [3.1338561, -1.6168667, -0.4906146],
66631
+ [-0.9787684, 1.9161415, 0.033454],
66632
+ [0.0719453, -0.2289914, 1.4052427]
66633
+ ];
66634
+ var dot = (m2, v) => m2[0] * v[0] + m2[1] * v[1] + m2[2] * v[2];
66635
+ var labF = (t2) => t2 > 216 / 24389 ? Math.cbrt(t2) : 841 / 108 * t2 + 4 / 29;
66636
+ var labFInv = (t2) => t2 > 6 / 29 ? t2 ** 3 : 108 / 841 * (t2 - 4 / 29);
66637
+ function flipLabLightness(c2) {
66638
+ const linear = [c2.r, c2.g, c2.b].map((v) => {
66639
+ const s2 = v / 255;
66640
+ return s2 <= 0.04045 ? s2 / 12.92 : ((s2 + 0.055) / 1.055) ** 2.4;
66641
+ });
66642
+ const [fx, fy2, fz] = TO_XYZ.map((row, i2) => labF(dot(row, linear) / D50[i2]));
66643
+ const y3 = (Math.min(110 - (116 * fy2 - 16), 100) + 16) / 116;
66644
+ const xyz = [fx - fy2 + y3, y3, y3 - (fy2 - fz)].map((t2, i2) => labFInv(t2) * D50[i2]);
66645
+ const [r2, g3, b2] = FROM_XYZ.map((row) => {
66646
+ const v = Math.min(1, Math.max(0, dot(row, xyz)));
66647
+ return Math.round(255 * (v <= 31308e-7 ? 12.92 * v : 1.055 * v ** (1 / 2.4) - 0.055));
66648
+ });
66649
+ return hex({ r: r2, g: g3, b: b2 });
66650
+ }
66483
66651
  function gmailAndroidColor(value, role) {
66484
66652
  const parsed = parseColor(value);
66485
66653
  if (!parsed || parsed.a === 0) return null;
66486
- const [L3, A3, B2] = rgbToOklab(parsed);
66487
- if (role === "bg") {
66488
- if (L3 <= 0.8) return null;
66489
- return hex(oklabToRgb([0.18 + (1 - L3) * 2.3, A3, B2]));
66490
- }
66491
- const lifted = Math.min(1, 1.16 - 0.87 * L3);
66492
- if (lifted <= L3) return null;
66493
- return hex(oklabToRgb([lifted, A3 * 0.6, B2 * 0.6]));
66654
+ const brightness = (parsed.r * 299 + parsed.g * 587 + parsed.b * 114) / 1e3;
66655
+ if (role === "fg") return brightness < 150 ? flipLabLightness(parsed) : null;
66656
+ if (brightness <= 206) return null;
66657
+ return APP_BACKGROUND.has(hex(parsed)) ? "#121212" : flipLabLightness(parsed);
66494
66658
  }
66495
66659
  function invertColor(value, mode, clientId, role = "bg") {
66496
66660
  var _a22;
package/dist/index.js CHANGED
@@ -32,7 +32,7 @@ import {
32
32
  simulateDarkMode,
33
33
  toFramework,
34
34
  transformForAllClients
35
- } from "./chunk-2W2K4VNB.js";
35
+ } from "./chunk-SBRXUNV5.js";
36
36
  import "./chunk-ABDTBRVK.js";
37
37
  import "./chunk-2AP7CT6R.js";
38
38
  import "./chunk-NXBRJX3V.js";
@@ -32902,21 +32902,6 @@ h1 {
32902
32902
  0.0259040371 * l + 0.7827717662 * m - 0.808675766 * s
32903
32903
  ];
32904
32904
  }
32905
- function oklabToRgb([L, A, B]) {
32906
- const l = (L + 0.3963377774 * A + 0.2158037573 * B) ** 3;
32907
- const m = (L - 0.1055613458 * A - 0.0638541728 * B) ** 3;
32908
- const s = (L - 0.0894841775 * A - 1.291485548 * B) ** 3;
32909
- const toGamma = (c) => {
32910
- const v = c <= 31308e-7 ? 12.92 * c : 1.055 * Math.pow(c, 1 / 2.4) - 0.055;
32911
- return Math.round(Math.min(1, Math.max(0, v)) * 255);
32912
- };
32913
- return {
32914
- r: toGamma(4.0767416621 * l - 3.3077115913 * m + 0.2309699292 * s),
32915
- g: toGamma(-1.2684380046 * l + 2.6097574011 * m - 0.3413193965 * s),
32916
- b: toGamma(-0.0041960863 * l - 0.7034186147 * m + 1.707662439 * s),
32917
- a: 1
32918
- };
32919
- }
32920
32905
  function colorDistance(a, b) {
32921
32906
  const [l1, a1, b1] = rgbToOklab(a);
32922
32907
  const [l2, a2, b2] = rgbToOklab(b);
@@ -33320,7 +33305,10 @@ h1 {
33320
33305
  var DOWNLEVEL_HIDDEN = /<!--\[if(?![^\]]*!)[^\]]*(?:mso|vml|true)[^\]]*\]>([\s\S]*?)<!\[endif\]-->/gi;
33321
33306
  var OFFICE_SETTINGS = /<xml\b[^>]*>[\s\S]*?<\/xml>/gi;
33322
33307
  function resolveMsoBranch(html) {
33323
- return html.replace(DOWNLEVEL_REVEALED, "").replace(DOWNLEVEL_HIDDEN, "$1").replace(OFFICE_SETTINGS, "");
33308
+ return html.replace(DOWNLEVEL_REVEALED, "").replace(
33309
+ DOWNLEVEL_HIDDEN,
33310
+ (_, inner) => /^\s*<style/i.test(inner) ? inner.replace(/(\.[\w-]+\s*\{[^}]*?)font-size\s*:[^;}]*;?/g, "$1") : inner
33311
+ ).replace(OFFICE_SETTINGS, "");
33324
33312
  }
33325
33313
  var MSO_HIDE = /mso-hide\s*:\s*all/i;
33326
33314
  function applyMsoHide(html) {
@@ -33663,7 +33651,7 @@ h1 {
33663
33651
  var TABLE_GUTTER = 3.5;
33664
33652
  var INVISIBLE_ONLY = /^[\s\u00a0\u00ad\u034f\u200b-\u200d\u2007\ufeff]+$/;
33665
33653
  var LIST_TRAILING_PX = 18;
33666
- var LIST_INDENT_PX = 24;
33654
+ var LIST_TEXT_INDENT_PX = 48;
33667
33655
  var MAX_BORDER_PX = 8;
33668
33656
  var capBorder = (value) => value.replace(
33669
33657
  /(\d+(?:\.\d+)?)px/gi,
@@ -33715,7 +33703,8 @@ h1 {
33715
33703
  order++;
33716
33704
  for (const one of selector.split(",")) {
33717
33705
  if (!one.trim() || IGNORED_BY_WORD.test(one)) continue;
33718
- const family2 = one.trim() === "*" ? TIMES : drawn;
33706
+ const universal = one.trim() === "*";
33707
+ const family2 = universal ? WORD_DEFAULT : drawn;
33719
33708
  let matched;
33720
33709
  try {
33721
33710
  matched = $(one).toArray();
@@ -33725,7 +33714,8 @@ h1 {
33725
33714
  const weight = (important ? 1e12 : 0) + specificity(one.trim()) * 1e5 + order;
33726
33715
  for (const el of matched) {
33727
33716
  const was = best.get(el);
33728
- if (!was || weight > was.weight) best.set(el, { weight, family: family2 });
33717
+ const inherited2 = universal && $(el).parents("[style*='font-family']").length > 0;
33718
+ if (!was || weight > was.weight) best.set(el, { weight, family: inherited2 ? "inherit" : family2 });
33729
33719
  }
33730
33720
  }
33731
33721
  }
@@ -33735,6 +33725,14 @@ h1 {
33735
33725
  return out;
33736
33726
  }
33737
33727
  var IGNORED_BY_WORD = /\[|>|:first-child|:nth-child|:not\(|::?before|\.[\w-]+\.[\w-]/;
33728
+ function matchedByWord($, selector) {
33729
+ if (!selector.trim() || IGNORED_BY_WORD.test(selector)) return [];
33730
+ try {
33731
+ return $(selector).toArray();
33732
+ } catch (e) {
33733
+ return [];
33734
+ }
33735
+ }
33738
33736
  function overrideStylesheetRules($, faces) {
33739
33737
  var _a2;
33740
33738
  const override = (el, declarations) => {
@@ -33757,14 +33755,7 @@ h1 {
33757
33755
  const hides = props.get("display") === "none";
33758
33756
  if (!hasPadding && !hasSize && !hasBackground && !hides) continue;
33759
33757
  for (const one of selector.split(",")) {
33760
- if (!one.trim() || IGNORED_BY_WORD.test(one)) continue;
33761
- let matched;
33762
- try {
33763
- matched = $(one).toArray();
33764
- } catch (e) {
33765
- continue;
33766
- }
33767
- for (const el of matched) {
33758
+ for (const el of matchedByWord($, one)) {
33768
33759
  const tag = (_b = el.tagName) == null ? void 0 : _b.toLowerCase();
33769
33760
  if (hasPadding && (tag === "div" || tag === "p" || tag === "span" || tag === "a"))
33770
33761
  override(el, "padding:0!important");
@@ -33807,6 +33798,10 @@ h1 {
33807
33798
  const style = (_a2 = dq != null ? dq : sq) != null ? _a2 : "";
33808
33799
  if (!/display\s*:\s*none/i.test(style) || /mso-hide\s*:/i.test(style)) return whole;
33809
33800
  const quote = dq === void 0 ? "'" : '"';
33801
+ if (/^<t[dh]\s/i.test(lead) && /padding/i.test(style)) {
33802
+ const kept = style.replace(/display\s*:\s*none\s*(?:!important)?\s*;?/gi, "");
33803
+ return `${lead}${quote}${kept}${/;\s*$/.test(kept) ? "" : ";"}mso-hollow:1${quote}`;
33804
+ }
33810
33805
  return `${lead}${quote}${style}${/;\s*$/.test(style) ? "" : ";"}mso-hide:all${quote}`;
33811
33806
  }
33812
33807
  );
@@ -33821,22 +33816,24 @@ h1 {
33821
33816
  for (const [, body] of ((_a2 = $(block).html()) != null ? _a2 : "").matchAll(/@font-face\s*\{([^}]*)\}/gi)) {
33822
33817
  const props = parseInlineStyle(body);
33823
33818
  const family = props.get("font-family");
33824
- const alt = ((_b = props.get("mso-font-alt")) == null ? void 0 : _b.replace(/["']/g, "").trim()) || null;
33819
+ const named = ((_b = props.get("mso-font-alt")) == null ? void 0 : _b.replace(/["']/g, "").trim()) || null;
33820
+ const alt = named && /^sans-serif$/i.test(named) ? WORD_DEFAULT : named;
33825
33821
  if (family) faces.set(firstFamily(family), (_c = alt != null ? alt : faces.get(firstFamily(family))) != null ? _c : null);
33826
33822
  }
33827
33823
  });
33828
33824
  return faces;
33829
33825
  }
33830
33826
  var firstFamily = (value) => value.split(",")[0].replace(/["']|!important/gi, "").trim().toLowerCase();
33831
- var TIMES = "'Times New Roman',serif";
33827
+ var WORD_DEFAULT = "Aptos,'Segoe UI',sans-serif";
33832
33828
  function wordFamily(value, faces) {
33833
- if (/(^|,)\s*system-ui\s*(,|$)/i.test(value.replace(/!important/gi, ""))) return TIMES;
33834
- const first = firstFamily(value);
33835
- if (!faces.has(first)) return null;
33829
+ const families = value.replace(/!important/gi, "").split(",");
33830
+ const named = families.filter((f) => !/^\s*(?:system-ui|ui-[a-z-]+)\s*$/i.test(f));
33831
+ const first = firstFamily(named.join(","));
33832
+ if (!faces.has(first)) return named.length < families.length ? named.join(",").trim() || WORD_DEFAULT : null;
33836
33833
  const alt = faces.get(first);
33837
- if (alt) return `'${alt}'`;
33838
- const rest = value.replace(/!important/gi, "").split(",").slice(1).join(",").trim();
33839
- return rest || TIMES;
33834
+ if (alt) return alt === WORD_DEFAULT ? alt : `'${alt}'`;
33835
+ const rest = named.slice(1).join(",").trim();
33836
+ return rest || WORD_DEFAULT;
33840
33837
  }
33841
33838
  function hasBorder(props) {
33842
33839
  for (const prop of ["border", "border-top", "border-right", "border-bottom", "border-left"]) {
@@ -33856,7 +33853,7 @@ h1 {
33856
33853
  function applyWordBoxModel($) {
33857
33854
  const faces = declaredFaces($);
33858
33855
  $("[style]").each((_, node) => {
33859
- var _a2, _b, _c, _d, _e, _f, _g;
33856
+ var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
33860
33857
  const el = node;
33861
33858
  const tag = (_a2 = el.tagName) == null ? void 0 : _a2.toLowerCase();
33862
33859
  const props = parseInlineStyle($(el).attr("style") || "");
@@ -33864,20 +33861,37 @@ h1 {
33864
33861
  for (const prop of [...PADDING, ...MARGIN]) {
33865
33862
  if (/\d(?:\.\d+)?rem\b/i.test((_b = props.get(prop)) != null ? _b : "")) props.delete(prop);
33866
33863
  }
33867
- const bordered = (tag === "div" || tag === "p") && hasBorder(props);
33868
- if ((tag === "div" || tag === "p" || tag === "span" || tag === "a") && !bordered) {
33864
+ const bordered = (tag === "div" || tag === "p" || tag === "a") && hasBorder(props);
33865
+ if (bordered && tag === "a") {
33866
+ props.set("display", "inline-block");
33867
+ $(el).attr("data-word-box", "");
33868
+ const fill = (_c = props.get("background-color")) != null ? _c : props.get("background");
33869
+ if (fill) {
33870
+ props.delete("background-color");
33871
+ props.delete("background");
33872
+ $(el).html(`<span style="background-color:${fill}">${$(el).html()}</span>`);
33873
+ }
33874
+ }
33875
+ if (bordered && !props.has("border") && !props.has("border-top")) props.set("padding-top", "0");
33876
+ const spacerRuns = tag === "a" && ((_d = $(el).html()) == null ? void 0 : _d.includes("mso-font-width"));
33877
+ if (spacerRuns) props.set("display", "inline-block");
33878
+ if ((tag === "div" || tag === "p" || tag === "span" || tag === "a") && !bordered && !spacerRuns) {
33869
33879
  for (const prop of PADDING) props.delete(prop);
33870
33880
  }
33871
- if (/^(?:fit|max|min)-content$/i.test(((_c = props.get("width")) != null ? _c : "").replace(/!important/i, "").trim())) props.delete("width");
33881
+ if (/^(?:fit|max|min)-content$/i.test(((_e = props.get("width")) != null ? _e : "").replace(/!important/i, "").trim())) props.delete("width");
33872
33882
  if (tag === "div" || tag === "span") {
33873
33883
  props.delete("width");
33874
33884
  props.delete("height");
33875
33885
  }
33876
- if (tag === "div") {
33886
+ if (tag === "div" || tag === "table") {
33877
33887
  for (const prop of MARGIN) {
33878
33888
  const value = props.get(prop);
33879
33889
  if (value !== void 0) props.set(prop, flattenMargin(value));
33880
33890
  }
33891
+ if (tag === "table" && /center/i.test((_f = $(el).attr("align")) != null ? _f : "")) {
33892
+ props.delete("margin-top");
33893
+ props.delete("margin-bottom");
33894
+ }
33881
33895
  }
33882
33896
  if ((tag === "div" || tag === "h2") && holdsNoText($, el)) {
33883
33897
  props.delete("background");
@@ -33886,18 +33900,24 @@ h1 {
33886
33900
  const family = props.get("font-family");
33887
33901
  const drawn = family === void 0 ? null : wordFamily(family, faces);
33888
33902
  if (drawn) props.set("font-family", drawn);
33903
+ if ((tag === "body" || tag === "td") && /^\s*sans-serif(?![\w-])/i.test((_g = drawn != null ? drawn : family) != null ? _g : "")) props.set("font-family", WORD_DEFAULT);
33904
+ if (/none/i.test((_h = props.get("mso-border-alt")) != null ? _h : "")) {
33905
+ for (const prop of [...props.keys()]) if (prop.startsWith("border") && prop !== "border-radius") props.delete(prop);
33906
+ }
33907
+ if (/transparent/i.test((_i = props.get("mso-shading")) != null ? _i : "")) props.delete("background-color");
33889
33908
  const lineAlt = props.get("mso-line-height-alt");
33890
- if (lineAlt !== void 0) props.set("line-height", lineAlt);
33891
- const lineHeight = /^([\d.]+)px$/i.exec((_d = props.get("line-height")) != null ? _d : "");
33892
- const fontSize = /^([\d.]+)px$/i.exec((_e = props.get("font-size")) != null ? _e : "");
33893
- if (lineHeight && fontSize && !/exactly/i.test((_f = props.get("mso-line-height-rule")) != null ? _f : "")) {
33909
+ const altEm = /^([\d.]+)em$/i.exec((_j = lineAlt == null ? void 0 : lineAlt.trim()) != null ? _j : "");
33910
+ if (lineAlt !== void 0) props.set("line-height", altEm ? `${Number(altEm[1]) * 16}px` : lineAlt);
33911
+ const lineHeight = /^([\d.]+)px$/i.exec((_k = props.get("line-height")) != null ? _k : "");
33912
+ const fontSize = /^([\d.]+)px$/i.exec((_l = props.get("font-size")) != null ? _l : "");
33913
+ if (lineHeight && fontSize && !/exactly/i.test((_m = props.get("mso-line-height-rule")) != null ? _m : "")) {
33894
33914
  const natural = Math.round(Number(fontSize[1]) * NATURAL_LINE);
33895
33915
  if (Number(lineHeight[1]) < natural) props.set("line-height", `${natural}px`);
33896
33916
  }
33897
33917
  for (const prop of ["word-spacing", "outline", "outline-width", "outline-style", "outline-color", "outline-offset"]) {
33898
33918
  props.delete(prop);
33899
33919
  }
33900
- if (tag === "div" && /^center$/i.test((_g = props.get("text-align")) != null ? _g : "") && !$(el).attr("align")) {
33920
+ if (tag === "div" && /^center$/i.test((_n = props.get("text-align")) != null ? _n : "") && !$(el).attr("align")) {
33901
33921
  $(el).attr("align", "center");
33902
33922
  props.delete("text-align");
33903
33923
  }
@@ -33920,6 +33940,38 @@ h1 {
33920
33940
  else $(el).removeAttr("style");
33921
33941
  }
33922
33942
  });
33943
+ $("td[style*='mso-hollow'], th[style*='mso-hollow']").each((_, node) => {
33944
+ const cell = $(node);
33945
+ const props = parseInlineStyle(cell.attr("style") || "");
33946
+ props.delete("mso-hollow");
33947
+ props.set("display", "table-cell!important");
33948
+ props.set("font-size", "0");
33949
+ props.set("line-height", "0");
33950
+ cell.empty().attr("style", serializeStyle(props));
33951
+ });
33952
+ $("hr").each((_, node) => {
33953
+ var _a2, _b, _c;
33954
+ const props = parseInlineStyle($(node).attr("style") || "");
33955
+ const [top = "", , bottom = top] = ((_a2 = props.get("margin")) != null ? _a2 : "").trim().split(/\s+/).concat([""]);
33956
+ const px2 = (v) => Number.parseFloat(v != null ? v : "") || 0;
33957
+ const set = /* @__PURE__ */ new Map([
33958
+ ["border", "none"],
33959
+ ["border-top", "1px solid #a0a0a0"],
33960
+ ["height", "0"],
33961
+ ["width", "100%"],
33962
+ ["margin", `${px2((_b = props.get("margin-top")) != null ? _b : top) + 4}px 0 ${px2((_c = props.get("margin-bottom")) != null ? _c : bottom || top) + 4}px`]
33963
+ ]);
33964
+ $(node).attr("style", serializeStyle(set));
33965
+ });
33966
+ $("a").each((_, node) => {
33967
+ if (!$(node).children("div").length) return;
33968
+ $(node).before('<div style="height:21px"></div>').after('<div style="height:20px"></div>');
33969
+ });
33970
+ $("a[style*='text-decoration-line']").each((_, node) => {
33971
+ const props = parseInlineStyle($(node).attr("style") || "");
33972
+ props.delete("text-decoration-line");
33973
+ $(node).attr("style", serializeStyle(props));
33974
+ });
33923
33975
  $("td table, th table").each((_, node) => {
33924
33976
  const table = node;
33925
33977
  const own = parseInlineStyle($(table).attr("style") || "");
@@ -33936,10 +33988,11 @@ h1 {
33936
33988
  $(table).attr("style", serializeStyle(props));
33937
33989
  });
33938
33990
  $("img").each((_, node) => {
33939
- var _a2;
33991
+ var _a2, _b, _c, _d;
33940
33992
  const el = node;
33941
33993
  const props = parseInlineStyle($(el).attr("style") || "");
33942
33994
  const NUMBER = /^\d+(?:\.\d+)?$/;
33995
+ const percent = /^\d+(?:\.\d+)?%$/.test((_b = (_a2 = $(el).attr("width")) == null ? void 0 : _a2.trim()) != null ? _b : "") ? (_c = $(el).attr("width")) == null ? void 0 : _c.trim() : void 0;
33943
33996
  const numeric = (name) => {
33944
33997
  var _a3;
33945
33998
  const value = (_a3 = $(el).attr(name)) == null ? void 0 : _a3.trim();
@@ -33953,11 +34006,11 @@ h1 {
33953
34006
  }
33954
34007
  for (const name of ["hspace", "vspace"]) $(el).removeAttr(name);
33955
34008
  if ($(el).attr("border") !== void 0) $(el).attr("border", "0");
33956
- props.set("width", width ? `${width}px!important` : "auto!important");
34009
+ props.set("width", percent ? `${percent}!important` : width ? `${width}px!important` : "auto!important");
33957
34010
  props.set("height", height ? `${height}px!important` : "auto!important");
33958
34011
  props.set("max-width", "none!important");
33959
34012
  props.set("vertical-align", "bottom");
33960
- if (/\.(?:svg|webp)(?:[?#]|$)/i.test((_a2 = $(el).attr("src")) != null ? _a2 : "")) props.set("visibility", "hidden");
34013
+ if (/\.(?:svg|webp)(?:[?#]|$)/i.test((_d = $(el).attr("src")) != null ? _d : "")) props.set("visibility", "hidden");
33961
34014
  const after = serializeStyle(props);
33962
34015
  if (after) $(el).attr("style", after);
33963
34016
  else $(el).removeAttr("style");
@@ -33969,20 +34022,18 @@ h1 {
33969
34022
  if (text.length > 20 && INVISIBLE_ONLY.test(text)) el.text(String.fromCharCode(160));
33970
34023
  });
33971
34024
  $("ul,ol").each((_, node) => {
33972
- var _a2;
33973
34025
  const el = node;
33974
34026
  const props = parseInlineStyle($(el).attr("style") || "");
33975
- const margin = ((_a2 = props.get("margin")) != null ? _a2 : "").trim().split(/\s+/).filter(Boolean);
33976
- const indented = props.has("margin-left") || props.has("padding-left") || props.has("padding") || margin.length > 0;
33977
34027
  let previous = el.prev;
33978
34028
  while (previous && previous.type === "text" && !previous.data.trim()) previous = previous.prev;
33979
34029
  const afterBreak = (previous == null ? void 0 : previous.type) === "tag" && previous.name === "br";
33980
- props.set("margin-top", afterBreak ? "1lh!important" : "0!important");
33981
- props.set("margin-bottom", `${LIST_TRAILING_PX}px!important`);
33982
- if (!indented) {
33983
- props.set("margin-left", `${LIST_INDENT_PX}px`);
33984
- props.set("padding-left", `${40 - LIST_INDENT_PX}px`);
33985
- }
34030
+ const tight = $(el).children("li").toArray().some((item) => {
34031
+ const style = parseInlineStyle($(item).attr("style") || "");
34032
+ return style.has("margin") || style.has("margin-top") || style.has("margin-bottom");
34033
+ });
34034
+ props.set("margin-top", afterBreak || previous && !tight ? "1lh!important" : "0!important");
34035
+ props.set("margin-bottom", tight ? "0!important" : `${LIST_TRAILING_PX}px!important`);
34036
+ props.set("padding-left", `${LIST_TEXT_INDENT_PX}px!important`);
33986
34037
  $(el).attr("style", serializeStyle(props));
33987
34038
  });
33988
34039
  $("picture source").remove();
@@ -34020,7 +34071,94 @@ h1 {
34020
34071
  })) return;
34021
34072
  cell.attr("style", `${style}${style.trim() === "" || /;\s*$/.test(style) ? "" : ";"}text-align:left`);
34022
34073
  });
34023
- const reset = "<style>p,h2{margin:0}</style>";
34074
+ $("table").each((_, node) => {
34075
+ var _a2, _b, _c, _d, _e, _f, _g, _h;
34076
+ const table = $(node);
34077
+ const props = parseInlineStyle(table.attr("style") || "");
34078
+ const box = ((_a2 = props.get("margin")) != null ? _a2 : "").trim().split(/\s+/).filter(Boolean);
34079
+ const top = Number.parseFloat((_c = (_b = props.get("margin-top")) != null ? _b : box[0]) != null ? _c : "") || 0;
34080
+ const bottom = Number.parseFloat((_f = (_e = (_d = props.get("margin-bottom")) != null ? _d : box[2]) != null ? _e : box[0]) != null ? _f : "") || 0;
34081
+ if (top <= 0 && bottom <= 0 || /center/i.test((_g = table.attr("align")) != null ? _g : "")) return;
34082
+ const rows = table.find("> tr, > tbody > tr");
34083
+ const grow = (row, side, by) => {
34084
+ row.children("td, th").each((_2, cell) => {
34085
+ var _a3, _b2, _c2, _d2;
34086
+ const own = parseInlineStyle($(cell).attr("style") || "");
34087
+ const pad = ((_a3 = own.get("padding")) != null ? _a3 : "").trim().split(/\s+/).filter(Boolean);
34088
+ const was = Number.parseFloat((_d2 = (_c2 = own.get(`padding-${side}`)) != null ? _c2 : side === "top" ? pad[0] : (_b2 = pad[2]) != null ? _b2 : pad[0]) != null ? _d2 : "") || 0;
34089
+ own.set(`padding-${side}`, `${was + by}px`);
34090
+ $(cell).attr("style", serializeStyle(own));
34091
+ });
34092
+ };
34093
+ if (!rows.length) return;
34094
+ if (top > 0) grow(rows.first(), "top", top);
34095
+ if (bottom > 0) grow(rows.last(), "bottom", bottom);
34096
+ props.delete("margin-top");
34097
+ props.delete("margin-bottom");
34098
+ if (box.length) {
34099
+ props.delete("margin");
34100
+ if (box[1]) props.set("margin-left", (_h = box[3]) != null ? _h : box[1]);
34101
+ if (box[1]) props.set("margin-right", box[1]);
34102
+ }
34103
+ table.attr("style", serializeStyle(props));
34104
+ });
34105
+ $("table").each((_, node) => {
34106
+ var _a2, _b;
34107
+ const props = parseInlineStyle($(node).attr("style") || "");
34108
+ if (!/para-border-div/i.test((_a2 = props.get("mso-element")) != null ? _a2 : "")) return;
34109
+ const width = Number.parseFloat((_b = props.get("mso-element-frame-width")) != null ? _b : "");
34110
+ if (!width) return;
34111
+ props.delete("max-width");
34112
+ props.set("width", `${width + 17}px`);
34113
+ props.set("box-sizing", "border-box");
34114
+ props.set("margin", "0 auto");
34115
+ props.set("padding", "4px 12px 4px 4px");
34116
+ props.set("border", "1px dotted #a6a6a6");
34117
+ props.set("border-collapse", "separate");
34118
+ props.set("text-align", "justify");
34119
+ $(node).attr("style", serializeStyle(props));
34120
+ $(node).removeAttr("width");
34121
+ });
34122
+ $("table").each((_, node) => {
34123
+ var _a2, _b;
34124
+ const props = parseInlineStyle($(node).attr("style") || "");
34125
+ const zero = /^0(?:px)?\s+solid\s+(\S+)/i.exec((_b = (_a2 = props.get("border")) == null ? void 0 : _a2.trim()) != null ? _b : "");
34126
+ if (!zero) return;
34127
+ props.set("border", `1px solid ${zero[1]}`);
34128
+ $(node).attr("style", serializeStyle(props));
34129
+ });
34130
+ const borderOf = (style) => [...parseInlineStyle(style != null ? style : "")].filter(([k, v]) => k.startsWith("border") && !/^0|none/.test(v)).join(";");
34131
+ $("p").each((_, node) => {
34132
+ var _a2;
34133
+ const p = $(node);
34134
+ const next = p.next();
34135
+ const border = borderOf(p.attr("style"));
34136
+ if (!border || !next.is("p") || borderOf(next.attr("style")) !== border) return;
34137
+ const props = parseInlineStyle((_a2 = p.attr("style")) != null ? _a2 : "");
34138
+ for (const key of [...props.keys()]) if (key.startsWith("border")) props.delete(key);
34139
+ props.set("padding-bottom", "0");
34140
+ p.attr("style", serializeStyle(props));
34141
+ });
34142
+ const margined = /* @__PURE__ */ new Set();
34143
+ $("style").each((_, block) => {
34144
+ var _a2;
34145
+ for (const { selector, body } of topLevelRules((_a2 = $(block).html()) != null ? _a2 : "")) {
34146
+ const props = parseInlineStyle(body);
34147
+ if (!props.has("margin") && !props.has("margin-top") && !props.has("margin-bottom")) continue;
34148
+ for (const one of selector.split(",")) for (const el of matchedByWord($, one)) margined.add(el);
34149
+ }
34150
+ });
34151
+ $("p").each((_, node) => {
34152
+ const p = $(node);
34153
+ const props = parseInlineStyle(p.attr("style") || "");
34154
+ if (props.has("margin") || props.has("margin-top") || props.has("margin-bottom")) return;
34155
+ if (margined.has(node)) return;
34156
+ if (!p.prev().length) props.set("margin-top", "0");
34157
+ if (!p.next().length) props.set("margin-bottom", "0");
34158
+ const after = serializeStyle(props);
34159
+ if (after) p.attr("style", after);
34160
+ });
34161
+ const reset = "<style>h2{margin:0}p{margin:14pt 0}</style>";
34024
34162
  const head = $("head");
34025
34163
  if (head.length) head.prepend(reset);
34026
34164
  else if ($("p,h2").length) $.root().prepend(reset);
@@ -35313,12 +35451,12 @@ h1 {
35313
35451
  message: "Outlook Classic ignores border-radius. Buttons and containers will have sharp corners."
35314
35452
  }, "border-radius", clientId, framework));
35315
35453
  }
35316
- if ($("[style*='max-width']").length > 0) {
35454
+ if ($("[style*='max-width']").not("table").length > 0) {
35317
35455
  warnings.push(makeWarning({
35318
35456
  severity: "warning",
35319
35457
  client: clientId,
35320
35458
  property: "max-width",
35321
- message: "Outlook Classic ignores max-width."
35459
+ message: "Outlook Classic ignores max-width except on tables."
35322
35460
  }, "max-width", clientId, framework));
35323
35461
  }
35324
35462
  const hasDivLayout = $("div[style*='display']").length > 0 || $("div[style*='flex']").length > 0 || $("div[style*='grid']").length > 0;
@@ -36046,6 +36184,7 @@ h1 {
36046
36184
  const removed = [];
36047
36185
  props.forEach((value, prop) => {
36048
36186
  var _a3;
36187
+ if (prop === "max-width" && clientId === "outlook-windows-legacy" && $(el).is("table")) return;
36049
36188
  if (config.strippedProperties.has(prop)) {
36050
36189
  if (config.stripMode === "strip") {
36051
36190
  removed.push(prop);
@@ -36568,17 +36707,42 @@ h1 {
36568
36707
  "gmail-ios": { eeeae4: "#4a4438" }
36569
36708
  };
36570
36709
  var hex = (c) => "#" + [c.r, c.g, c.b].map((v) => v.toString(16).padStart(2, "0")).join("");
36710
+ var APP_BACKGROUND = /* @__PURE__ */ new Set(["#ffffff", "#fefefe", "#fcfcfc", "#fbfbfb", "#f9f9f9"]);
36711
+ var D50 = [0.96422, 1, 0.82521];
36712
+ var TO_XYZ = [
36713
+ [0.4360747, 0.3850649, 0.1430804],
36714
+ [0.2225045, 0.7168786, 0.0606169],
36715
+ [0.0139322, 0.0971045, 0.7141733]
36716
+ ];
36717
+ var FROM_XYZ = [
36718
+ [3.1338561, -1.6168667, -0.4906146],
36719
+ [-0.9787684, 1.9161415, 0.033454],
36720
+ [0.0719453, -0.2289914, 1.4052427]
36721
+ ];
36722
+ var dot = (m, v) => m[0] * v[0] + m[1] * v[1] + m[2] * v[2];
36723
+ var labF = (t) => t > 216 / 24389 ? Math.cbrt(t) : 841 / 108 * t + 4 / 29;
36724
+ var labFInv = (t) => t > 6 / 29 ? t ** 3 : 108 / 841 * (t - 4 / 29);
36725
+ function flipLabLightness(c) {
36726
+ const linear = [c.r, c.g, c.b].map((v) => {
36727
+ const s = v / 255;
36728
+ return s <= 0.04045 ? s / 12.92 : ((s + 0.055) / 1.055) ** 2.4;
36729
+ });
36730
+ const [fx, fy, fz] = TO_XYZ.map((row, i) => labF(dot(row, linear) / D50[i]));
36731
+ const y = (Math.min(110 - (116 * fy - 16), 100) + 16) / 116;
36732
+ const xyz = [fx - fy + y, y, y - (fy - fz)].map((t, i) => labFInv(t) * D50[i]);
36733
+ const [r, g, b] = FROM_XYZ.map((row) => {
36734
+ const v = Math.min(1, Math.max(0, dot(row, xyz)));
36735
+ return Math.round(255 * (v <= 31308e-7 ? 12.92 * v : 1.055 * v ** (1 / 2.4) - 0.055));
36736
+ });
36737
+ return hex({ r, g, b });
36738
+ }
36571
36739
  function gmailAndroidColor(value, role) {
36572
36740
  const parsed = parseColor(value);
36573
36741
  if (!parsed || parsed.a === 0) return null;
36574
- const [L, A, B] = rgbToOklab(parsed);
36575
- if (role === "bg") {
36576
- if (L <= 0.8) return null;
36577
- return hex(oklabToRgb([0.18 + (1 - L) * 2.3, A, B]));
36578
- }
36579
- const lifted = Math.min(1, 1.16 - 0.87 * L);
36580
- if (lifted <= L) return null;
36581
- return hex(oklabToRgb([lifted, A * 0.6, B * 0.6]));
36742
+ const brightness = (parsed.r * 299 + parsed.g * 587 + parsed.b * 114) / 1e3;
36743
+ if (role === "fg") return brightness < 150 ? flipLabLightness(parsed) : null;
36744
+ if (brightness <= 206) return null;
36745
+ return APP_BACKGROUND.has(hex(parsed)) ? "#121212" : flipLabLightness(parsed);
36582
36746
  }
36583
36747
  function invertColor(value, mode, clientId, role = "bg") {
36584
36748
  var _a2;
@@ -42777,7 +42941,7 @@ Href: ${href}`
42777
42941
  // package.json
42778
42942
  var package_default = {
42779
42943
  name: "@emailens/cli",
42780
- version: "0.13.4",
42944
+ version: "0.13.6",
42781
42945
  description: "CLI tool for email compatibility analysis: lint, preview and export HTML, MJML, Maizzle and React Email rendering across 21 email clients.",
42782
42946
  type: "module",
42783
42947
  bin: {
@@ -42818,7 +42982,7 @@ var package_default = {
42818
42982
  },
42819
42983
  devDependencies: {
42820
42984
  "@anthropic-ai/sdk": "^0.52.0",
42821
- "@emailens/engine": "^0.18.6",
42985
+ "@emailens/engine": "^0.18.8",
42822
42986
  "@types/bun": "^1.4.0",
42823
42987
  "@types/mjml": "^4.7.4",
42824
42988
  "@types/node": "^25.9.5",
package/dist/test.js CHANGED
@@ -5,7 +5,7 @@ import {
5
5
  auditEmail,
6
6
  flattenToLintIssues,
7
7
  loadProjectConfig
8
- } from "./chunk-2W2K4VNB.js";
8
+ } from "./chunk-SBRXUNV5.js";
9
9
  import "./chunk-ABDTBRVK.js";
10
10
  import "./chunk-2AP7CT6R.js";
11
11
  import "./chunk-NXBRJX3V.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@emailens/cli",
3
- "version": "0.13.4",
3
+ "version": "0.13.6",
4
4
  "description": "CLI tool for email compatibility analysis: lint, preview and export HTML, MJML, Maizzle and React Email rendering across 21 email clients.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -41,7 +41,7 @@
41
41
  },
42
42
  "devDependencies": {
43
43
  "@anthropic-ai/sdk": "^0.52.0",
44
- "@emailens/engine": "^0.18.6",
44
+ "@emailens/engine": "^0.18.8",
45
45
  "@types/bun": "^1.4.0",
46
46
  "@types/mjml": "^4.7.4",
47
47
  "@types/node": "^25.9.5",