@emailens/cli 0.13.11 → 0.13.13

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.
@@ -63268,12 +63268,27 @@ function arcsizeToRadius(arcsize, width, height) {
63268
63268
  return Math.min(shorter / 2, Math.max(0, pct) / 100 * shorter);
63269
63269
  }
63270
63270
  var DOWNLEVEL_REVEALED = /<!--\[if[^\]]*!\s*\(*\s*(?:mso|vml|true)[^\]]*\]>\s*<(?:!-->|!--\s*-->|!\s*-->)([\s\S]*?)(?:<!--\s*<!\[endif\]-->|<!--\[endif\]-*-->)/gi;
63271
- var DOWNLEVEL_HIDDEN = /<!--\[if(?![^\]]*!)[^\]]*(?:mso|vml|true)[^\]]*\]>([\s\S]*?)<!\[endif\]-->/gi;
63271
+ var DOWNLEVEL_HIDDEN = /<!--\[if(?![^\]]*!)([^\]]*(?:mso|vml|true)[^\]]*)\]>([\s\S]*?)<!\[endif\]-->/gi;
63272
+ var WORD_MSO_VERSION = 16;
63273
+ function wordOpens(condition) {
63274
+ const bits = condition.toLowerCase().replace(/\b(?:(lt|lte|gt|gte)\s+)?mso(?:\s+(\d+(?:\.\d+)?))?/g, (_3, op2, n2) => {
63275
+ if (!n2) return "1";
63276
+ const v = Number.parseFloat(n2);
63277
+ const ok = op2 === "lt" ? WORD_MSO_VERSION < v : op2 === "lte" ? WORD_MSO_VERSION <= v : op2 === "gt" ? WORD_MSO_VERSION > v : op2 === "gte" ? WORD_MSO_VERSION >= v : Math.floor(v) === WORD_MSO_VERSION;
63278
+ return ok ? "1" : "0";
63279
+ }).replace(/\b(?:vml|true)\b/g, "1").replace(/[a-z]\w*(?:\s+\d+(?:\.\d+)?)?/g, "0").replace(/\s+/g, "");
63280
+ let s2 = bits;
63281
+ for (let prev2 = ""; prev2 !== s2; ) {
63282
+ prev2 = s2;
63283
+ s2 = s2.replace(/\(([01])\)/g, "$1").replace(/([01])&([01])/g, (_3, a2, b2) => a2 === "1" && b2 === "1" ? "1" : "0").replace(/([01])\|([01])/g, (_3, a2, b2) => a2 === "1" || b2 === "1" ? "1" : "0");
63284
+ }
63285
+ return s2 === "1";
63286
+ }
63272
63287
  var OFFICE_SETTINGS = /<xml\b[^>]*>[\s\S]*?<\/xml>/gi;
63273
63288
  function resolveMsoBranch(html3) {
63274
63289
  return html3.replace(DOWNLEVEL_REVEALED, "").replace(
63275
63290
  DOWNLEVEL_HIDDEN,
63276
- (_3, inner) => /^\s*<style/i.test(inner) ? inner.replace(/(\.[\w-]+\s*\{[^}]*?)font-size\s*:[^;}]*;?/g, "$1") : inner
63291
+ (_3, condition, inner) => !wordOpens(condition) ? "" : /^\s*<style/i.test(inner) ? inner.replace(/(\.[\w-]+\s*\{[^}]*?)font-size\s*:[^;}]*;?/g, "$1") : inner
63277
63292
  ).replace(OFFICE_SETTINGS, "");
63278
63293
  }
63279
63294
  var MSO_HIDE = /mso-hide\s*:\s*all/i;
@@ -63419,27 +63434,28 @@ function vmlToCss(html3) {
63419
63434
  out = out.replace(
63420
63435
  /<v:roundrect([^>]*)>([\s\S]*?)<\/v:roundrect>/gi,
63421
63436
  (_m2, rawAttrs, inner) => {
63422
- var _a22, _b, _c2, _d, _e2, _f, _g, _h2;
63437
+ var _a22, _b, _c2, _d, _e2, _f, _g, _h2, _i2, _j;
63423
63438
  const a2 = attrs(rawAttrs);
63424
63439
  const s2 = styleProps((_a22 = a2.style) != null ? _a22 : "");
63425
- const w2 = (_b = px(s2.width)) != null ? _b : 0;
63426
- const h = (_c2 = px(s2.height)) != null ? _c2 : 0;
63427
- const radius = arcsizeToRadius((_d = a2.arcsize) != null ? _d : "20%", w2, h);
63440
+ const auto = /^auto$/i.test((_c2 = (_b = s2.width) == null ? void 0 : _b.trim()) != null ? _c2 : "");
63441
+ const w2 = auto ? 64 : (_d = px(s2.width)) != null ? _d : 0;
63442
+ const h = (_e2 = px(s2.height)) != null ? _e2 : 0;
63443
+ const radius = arcsizeToRadius((_f = a2.arcsize) != null ? _f : "20%", w2, h);
63428
63444
  const fillTag = inner.match(/<v:fill([^>]*?)\/?>/i);
63429
63445
  const f3 = fillTag ? attrs(fillTag[1]) : {};
63430
63446
  const imageData = inner.match(/<v:imagedata([^>]*?)\/?>/i);
63431
63447
  const imageSrc = imageData ? attrs(imageData[1]).src : void 0;
63432
- const fill = (_f = (_e2 = f3.color) != null ? _e2 : a2.fillcolor) != null ? _f : "transparent";
63448
+ const fill = (_h2 = (_g = f3.color) != null ? _g : a2.fillcolor) != null ? _h2 : "transparent";
63433
63449
  const image = imageSrc ? `;background-image:url('${imageSrc}');background-size:100% 100%;background-repeat:no-repeat` : "";
63434
63450
  const stroked = !(a2.stroke === "f" || a2.stroke === "false");
63435
- const middle = /middle/i.test((_g = s2["v-text-anchor"]) != null ? _g : "");
63436
- const label = inner.replace(/<v:fill[^>]*?\/?>(?:\s*<\/v:fill>)?/gi, "").replace(/<v:imagedata[^>]*?\/?>(?:\s*<\/v:imagedata>)?/gi, "").replace(/<\/?w:anchorlock[^>]*>/gi, "").replace(/<center\b/gi, "<span").replace(/<\/center>/gi, "</span>").trim();
63451
+ const middle = /middle/i.test((_i2 = s2["v-text-anchor"]) != null ? _i2 : "");
63452
+ const label = inner.replace(/<v:fill[^>]*?\/?>(?:\s*<\/v:fill>)?/gi, "").replace(/<v:imagedata[^>]*?\/?>(?:\s*<\/v:imagedata>)?/gi, "").replace(/<\/?w:anchorlock[^>]*>/gi, "").replace(/<center\b/gi, "<span").replace(/<\/center>/gi, "</span>").trim().replace(/^<span(?: style="([^"]*)")?/i, (tag, style) => auto ? `<span style="display:block;max-height:1lh;overflow:hidden;padding:0 9.6px;${style != null ? style : ""}"` : tag);
63437
63453
  const box2 = [
63438
63454
  w2 ? `width:${w2}px` : "",
63439
63455
  h ? `height:${h}px` : "",
63440
63456
  `border-radius:${radius}px`,
63441
63457
  `background:${fill}${image}`,
63442
- stroked ? `border:1px solid ${(_h2 = a2.strokecolor) != null ? _h2 : "#000"}` : "border:none",
63458
+ stroked ? `border:1px solid ${(_j = a2.strokecolor) != null ? _j : "#000"}` : "border:none",
63443
63459
  "display:inline-flex",
63444
63460
  "justify-content:center",
63445
63461
  `align-items:${middle ? "center" : "flex-start"}`,
@@ -63610,6 +63626,14 @@ var BORDER_WIDTH = [
63610
63626
  "border-left-width"
63611
63627
  ];
63612
63628
  var NATURAL_LINE = 1.15;
63629
+ var GILL_VDMX = [14, 14, 15, 16, 18, 18, 21, 21, 23, 25, 27, 27, 29, 30, 31];
63630
+ var isGill = (family = "") => /^\s*['"]?gill sans/i.test(family);
63631
+ var naturalHeight = (size, family = "") => {
63632
+ if (!isGill(family)) return Math.round(size * NATURAL_LINE);
63633
+ const ppem = Math.round(size);
63634
+ return ppem <= 22 ? GILL_VDMX[Math.max(ppem, 8) - 8] : Math.ceil(0.9292 * size) + Math.ceil(0.2305 * size);
63635
+ };
63636
+ var GILL_LARGE = "'Gill Sans MT Large'";
63613
63637
  var TABLE_GUTTER = 3.5;
63614
63638
  var INVISIBLE_ONLY = /^[\s\u00a0\u00ad\u034f\u200b-\u200d\u2007\ufeff]+$/;
63615
63639
  var LIST_TRAILING_PX = 18;
@@ -63770,8 +63794,27 @@ function markHiddenCells(html3) {
63770
63794
  );
63771
63795
  }
63772
63796
  function prepareWordSource(html3) {
63773
- return markHiddenCells(dropWordUnknownColors(html3));
63774
- }
63797
+ return wordSubstitutes(markHiddenCells(dropWordUnknownColors(html3)));
63798
+ }
63799
+ var WORD_SUBSTITUTES = { rubik: "Calibri" };
63800
+ var SUBSTITUTED = new RegExp(String.raw`(font(?:-family)?\s*:[^;"}]*?)(['"]?)\b(${Object.keys(WORD_SUBSTITUTES).join("|")})\b\2`, "gi");
63801
+ var wordSubstitutes = (html3) => html3.replace(SUBSTITUTED, (_3, lead, _q, name) => `${lead}${WORD_SUBSTITUTES[name.toLowerCase()]}`);
63802
+ var OFFICE_CLOUD_FONTS = [
63803
+ "Work Sans",
63804
+ "Lato",
63805
+ "Montserrat",
63806
+ "Nunito",
63807
+ "Nunito Sans",
63808
+ "Open Sans",
63809
+ "DM Sans",
63810
+ "IBM Plex Sans",
63811
+ "Ubuntu",
63812
+ "Source Code Pro",
63813
+ "Raleway",
63814
+ "Playfair Display",
63815
+ "Poppins"
63816
+ ];
63817
+ var CLOUD = new Set(OFFICE_CLOUD_FONTS.map((f3) => f3.toLowerCase()));
63775
63818
  function declaredFaces($3) {
63776
63819
  const faces = /* @__PURE__ */ new Map();
63777
63820
  $3("style").each((_3, block) => {
@@ -63781,7 +63824,7 @@ function declaredFaces($3) {
63781
63824
  const family = props.get("font-family");
63782
63825
  const named = ((_b = props.get("mso-font-alt")) == null ? void 0 : _b.replace(/["']/g, "").trim()) || null;
63783
63826
  const alt = named && /^sans-serif$/i.test(named) ? WORD_DEFAULT : named;
63784
- if (family) faces.set(firstFamily(family), (_c2 = alt != null ? alt : faces.get(firstFamily(family))) != null ? _c2 : null);
63827
+ if (family && !CLOUD.has(firstFamily(family))) faces.set(firstFamily(family), (_c2 = alt != null ? alt : faces.get(firstFamily(family))) != null ? _c2 : null);
63785
63828
  }
63786
63829
  });
63787
63830
  return faces;
@@ -63813,8 +63856,36 @@ function leftPadding(props) {
63813
63856
  const value = parts.length === 4 ? parts[3] : parts.length >= 2 ? parts[1] : parts[0];
63814
63857
  return /^\d+(?:\.\d+)?(?:px)?$/.test(value != null ? value : "") ? parseFloat(value) : 0;
63815
63858
  }
63859
+ var SPACING = /^(?:line-height|mso-line-height-rule|mso-line-height-alt|font-size|font|font-family|background|background-color)$/;
63860
+ function sheetSpacing($3) {
63861
+ const found = /* @__PURE__ */ new Map();
63862
+ $3("style").each((_3, block) => {
63863
+ var _a22, _b;
63864
+ for (const { selector, body } of topLevelRules((_a22 = $3(block).html()) != null ? _a22 : "")) {
63865
+ const rule = [...parseInlineStyle(body.replace(/!important/gi, ""))].filter(([k2]) => SPACING.test(k2));
63866
+ if (!rule.length) continue;
63867
+ for (const one of selector.split(",")) {
63868
+ for (const el2 of matchedByWord($3, one)) {
63869
+ const has2 = (_b = found.get(el2)) != null ? _b : /* @__PURE__ */ new Map();
63870
+ for (const [k2, v] of rule) has2.set(k2, v);
63871
+ found.set(el2, has2);
63872
+ }
63873
+ }
63874
+ }
63875
+ });
63876
+ return found;
63877
+ }
63816
63878
  function applyWordBoxModel($3) {
63817
63879
  const faces = declaredFaces($3);
63880
+ const sheet = sheetSpacing($3);
63881
+ const spacingOf = (el2) => {
63882
+ var _a22, _b;
63883
+ const all = new Map([...(_a22 = sheet.get(el2)) != null ? _a22 : [], ...parseInlineStyle($3(el2).attr("style") || "")]);
63884
+ const alt = (_b = all.get("mso-line-height-alt")) == null ? void 0 : _b.trim();
63885
+ const altEm = /^([\d.]+)em$/i.exec(alt != null ? alt : "");
63886
+ if (alt) all.set("line-height", altEm ? `${Number(altEm[1]) * 16}px` : alt);
63887
+ return all;
63888
+ };
63818
63889
  $3("[style]").each((_3, node) => {
63819
63890
  var _a22, _b, _c2, _d, _e2, _f, _g, _h2, _i2, _j, _k, _l2, _m2, _n2;
63820
63891
  const el2 = node;
@@ -63874,7 +63945,7 @@ function applyWordBoxModel($3) {
63874
63945
  const lineHeight = /^([\d.]+)px$/i.exec((_k = props.get("line-height")) != null ? _k : "");
63875
63946
  const fontSize = /^([\d.]+)px$/i.exec((_l2 = props.get("font-size")) != null ? _l2 : "");
63876
63947
  if (lineHeight && fontSize && !/exactly/i.test((_m2 = props.get("mso-line-height-rule")) != null ? _m2 : "")) {
63877
- const natural = Math.round(Number(fontSize[1]) * NATURAL_LINE);
63948
+ const natural = naturalHeight(Number(fontSize[1]), props.get("font-family"));
63878
63949
  if (Number(lineHeight[1]) < natural) props.set("line-height", `${natural}px`);
63879
63950
  }
63880
63951
  for (const prop2 of ["word-spacing", "outline", "outline-width", "outline-style", "outline-color", "outline-offset"]) {
@@ -63912,6 +63983,18 @@ function applyWordBoxModel($3) {
63912
63983
  props.set("line-height", "0");
63913
63984
  cell.empty().attr("style", serializeStyle(props));
63914
63985
  });
63986
+ $3("p").each((_3, node) => {
63987
+ if (!$3(node).children().length && !/[^ \t\r\n]/.test($3(node).text())) $3(node).remove();
63988
+ });
63989
+ $3("img").each((_3, node) => {
63990
+ var _a22, _b;
63991
+ const img = $3(node);
63992
+ const props = parseInlineStyle(img.attr("style") || "");
63993
+ const height = Number.parseFloat((_b = (_a22 = props.get("height")) != null ? _a22 : img.attr("height")) != null ? _b : "");
63994
+ if (img.closest("td, th").length || !(height <= 1)) return;
63995
+ props.set("display", "block");
63996
+ img.attr("style", serializeStyle(props));
63997
+ });
63915
63998
  $3("hr").each((_3, node) => {
63916
63999
  var _a22, _b, _c2;
63917
64000
  const props = parseInlineStyle($3(node).attr("style") || "");
@@ -63927,7 +64010,7 @@ function applyWordBoxModel($3) {
63927
64010
  $3(node).attr("style", serializeStyle(set));
63928
64011
  });
63929
64012
  $3("a").each((_3, node) => {
63930
- if (!$3(node).children("div").length) return;
64013
+ if (!$3(node).children("div, p").length) return;
63931
64014
  $3(node).before('<div style="height:21px"></div>').after('<div style="height:20px"></div>');
63932
64015
  });
63933
64016
  $3("a[style*='text-decoration-line']").each((_3, node) => {
@@ -64034,37 +64117,91 @@ function applyWordBoxModel($3) {
64034
64117
  })) return;
64035
64118
  cell.attr("style", `${style}${style.trim() === "" || /;\s*$/.test(style) ? "" : ";"}text-align:left`);
64036
64119
  });
64120
+ const sheetMargins = /* @__PURE__ */ new Map();
64121
+ $3("style").each((_3, block) => {
64122
+ var _a22, _b;
64123
+ for (const { selector, body } of topLevelRules((_a22 = $3(block).html()) != null ? _a22 : "")) {
64124
+ if (!/margin/i.test(body)) continue;
64125
+ let cells = [];
64126
+ try {
64127
+ cells = $3(selector).filter("td, th").toArray();
64128
+ } catch (e2) {
64129
+ continue;
64130
+ }
64131
+ const rule = parseInlineStyle(body.replace(/!important/gi, ""));
64132
+ for (const cell of cells) {
64133
+ const has2 = (_b = sheetMargins.get(cell)) != null ? _b : /* @__PURE__ */ new Map();
64134
+ for (const [k2, v] of rule) if (/^margin(?:-top|-bottom)?$/.test(k2)) has2.set(k2, v);
64135
+ sheetMargins.set(cell, has2);
64136
+ }
64137
+ }
64138
+ });
64139
+ const verticalMargins = (props) => {
64140
+ var _a22, _b, _c2, _d;
64141
+ const box2 = ((_a22 = props.get("margin")) != null ? _a22 : "").trim().split(/\s+/).filter(Boolean);
64142
+ const read = (v) => v === void 0 ? void 0 : Number.parseFloat(v) || 0;
64143
+ return { top: read((_b = props.get("margin-top")) != null ? _b : box2[0]), bottom: read((_d = (_c2 = props.get("margin-bottom")) != null ? _c2 : box2[2]) != null ? _d : box2[0]) };
64144
+ };
64145
+ const holdsBareText = (cell) => {
64146
+ const inline = $3(cell).clone();
64147
+ inline.find("table, div, p, ul, ol, h1, h2, h3, h4, h5, h6").remove();
64148
+ return /[^\s ]/.test(inline.text());
64149
+ };
64037
64150
  $3("table").each((_3, node) => {
64038
- var _a22, _b, _c2, _d, _e2, _f, _g, _h2;
64151
+ var _a22, _b, _c2, _d, _e2;
64039
64152
  const table = $3(node);
64040
64153
  const props = parseInlineStyle(table.attr("style") || "");
64041
64154
  const box2 = ((_a22 = props.get("margin")) != null ? _a22 : "").trim().split(/\s+/).filter(Boolean);
64042
- const top = Number.parseFloat((_c2 = (_b = props.get("margin-top")) != null ? _b : box2[0]) != null ? _c2 : "") || 0;
64043
- const bottom = Number.parseFloat((_f = (_e2 = (_d = props.get("margin-bottom")) != null ? _d : box2[2]) != null ? _e2 : box2[0]) != null ? _f : "") || 0;
64044
- if (top <= 0 && bottom <= 0 || /center/i.test((_g = table.attr("align")) != null ? _g : "")) return;
64045
- const rows = table.find("> tr, > tbody > tr");
64046
- const grow = (row, side, by2) => {
64047
- row.children("td, th").each((_22, cell) => {
64048
- var _a32, _b2, _c22, _d2;
64049
- const own = parseInlineStyle($3(cell).attr("style") || "");
64050
- const pad = ((_a32 = own.get("padding")) != null ? _a32 : "").trim().split(/\s+/).filter(Boolean);
64051
- 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;
64052
- own.set(`padding-${side}`, `${was + by2}px`);
64053
- $3(cell).attr("style", serializeStyle(own));
64054
- });
64055
- };
64056
- if (!rows.length) return;
64057
- if (top > 0) grow(rows.first(), "top", top);
64058
- if (bottom > 0) grow(rows.last(), "bottom", bottom);
64155
+ const centred = /center/i.test((_b = table.attr("align")) != null ? _b : "");
64156
+ const margins = verticalMargins(props);
64157
+ const top = centred ? 0 : (_c2 = margins.top) != null ? _c2 : 0;
64158
+ const bottom = centred ? 0 : (_d = margins.bottom) != null ? _d : 0;
64159
+ table.find("> tr, > tbody > tr").each((_22, row) => {
64160
+ var _a32, _b2, _c22, _d2, _e22, _f, _g;
64161
+ const cells = $3(row).children("td, th").toArray();
64162
+ const bare = cells.filter(holdsBareText);
64163
+ if (!bare.length) return;
64164
+ for (const cell of cells) {
64165
+ const mine = bare.includes(cell) ? verticalMargins(new Map([...(_a32 = sheetMargins.get(cell)) != null ? _a32 : [], ...parseInlineStyle($3(cell).attr("style") || "")])) : { top: void 0, bottom: void 0 };
64166
+ const style = parseInlineStyle($3(cell).attr("style") || "");
64167
+ const pad = ((_b2 = style.get("padding")) != null ? _b2 : "").trim().split(/\s+/).filter(Boolean);
64168
+ for (const [side, by2] of [["top", (_c22 = mine.top) != null ? _c22 : top], ["bottom", (_d2 = mine.bottom) != null ? _d2 : bottom]]) {
64169
+ if (by2 <= 0) continue;
64170
+ const was = Number.parseFloat((_g = (_f = style.get(`padding-${side}`)) != null ? _f : side === "top" ? pad[0] : (_e22 = pad[2]) != null ? _e22 : pad[0]) != null ? _g : "") || 0;
64171
+ style.set(`padding-${side}`, `${was + by2}px`);
64172
+ }
64173
+ $3(cell).attr("style", serializeStyle(style));
64174
+ }
64175
+ });
64176
+ if (top <= 0 && bottom <= 0 || centred) return;
64059
64177
  props.delete("margin-top");
64060
64178
  props.delete("margin-bottom");
64061
64179
  if (box2.length) {
64062
64180
  props.delete("margin");
64063
- if (box2[1]) props.set("margin-left", (_h2 = box2[3]) != null ? _h2 : box2[1]);
64181
+ if (box2[1]) props.set("margin-left", (_e2 = box2[3]) != null ? _e2 : box2[1]);
64064
64182
  if (box2[1]) props.set("margin-right", box2[1]);
64065
64183
  }
64066
64184
  table.attr("style", serializeStyle(props));
64067
64185
  });
64186
+ $3("tr").each((_3, row) => {
64187
+ const cells = $3(row).children("td, th").toArray();
64188
+ if (cells.length < 2) return;
64189
+ const sides = cells.map((cell) => {
64190
+ var _a22, _b, _c2, _d;
64191
+ const style = parseInlineStyle($3(cell).attr("style") || "");
64192
+ const pad = ((_a22 = style.get("padding")) != null ? _a22 : "").trim().split(/\s+/).filter(Boolean);
64193
+ const read = (v) => Number.parseFloat(v != null ? v : "") || 0;
64194
+ return { style, top: read((_b = style.get("padding-top")) != null ? _b : pad[0]), bottom: read((_d = (_c2 = style.get("padding-bottom")) != null ? _c2 : pad[2]) != null ? _d : pad[0]) };
64195
+ });
64196
+ const top = Math.max(...sides.map((s2) => s2.top));
64197
+ const bottom = Math.max(...sides.map((s2) => s2.bottom));
64198
+ cells.forEach((cell, i2) => {
64199
+ const { style } = sides[i2];
64200
+ if (sides[i2].top < top) style.set("padding-top", `${top}px`);
64201
+ if (sides[i2].bottom < bottom) style.set("padding-bottom", `${bottom}px`);
64202
+ if (sides[i2].top < top || sides[i2].bottom < bottom) $3(cell).attr("style", serializeStyle(style));
64203
+ });
64204
+ });
64068
64205
  $3("table").each((_3, node) => {
64069
64206
  var _a22, _b;
64070
64207
  const props = parseInlineStyle($3(node).attr("style") || "");
@@ -64121,10 +64258,84 @@ function applyWordBoxModel($3) {
64121
64258
  const after2 = serializeStyle(props);
64122
64259
  if (after2) p.attr("style", after2);
64123
64260
  });
64124
- const reset = "<style>h2{margin:0}p{margin:14pt 0}</style>";
64261
+ $3("span, a, strong, b, em, i, u, font").each((_3, node) => {
64262
+ var _a22, _b, _c2;
64263
+ const el2 = node;
64264
+ const props = parseInlineStyle($3(el2).attr("style") || "");
64265
+ if (/block/i.test((_a22 = props.get("display")) != null ? _a22 : "")) return;
64266
+ const spacing = $3(el2).parents().toArray().map(spacingOf).find((st2) => st2.has("line-height"));
64267
+ if (!/^[\d.]+px$/i.test((_b = spacing == null ? void 0 : spacing.get("line-height")) != null ? _b : "") || /exactly/i.test((_c2 = spacing == null ? void 0 : spacing.get("mso-line-height-rule")) != null ? _c2 : "")) return;
64268
+ props.set("line-height", "normal");
64269
+ $3(el2).attr("style", serializeStyle(props));
64270
+ });
64271
+ const inherited2 = (el2, prop2) => [el2, ...$3(el2).parents().toArray()].map(spacingOf).find((st2) => st2.has(prop2));
64272
+ const sizeOf = (el2) => {
64273
+ var _a22, _b, _c2;
64274
+ const sized = [el2, ...$3(el2).parents().toArray()].map(spacingOf).find((st2) => {
64275
+ var _a32;
64276
+ return st2.has("font-size") || /\d(?:\.\d+)?px/.test((_a32 = st2.get("font")) != null ? _a32 : "");
64277
+ });
64278
+ const px2 = (_c2 = /^([\d.]+)px$/i.exec((_a22 = sized == null ? void 0 : sized.get("font-size")) != null ? _a22 : "")) != null ? _c2 : /(?:^|\s)([\d.]+)px/.exec((_b = sized == null ? void 0 : sized.get("font")) != null ? _b : "");
64279
+ return px2 ? Number(px2[1]) : void 0;
64280
+ };
64281
+ $3("p, div, h1, h2, h3, h4, h5, h6, li, td, th").each((_3, node) => {
64282
+ var _a22, _b, _c2, _d;
64283
+ const el2 = node;
64284
+ const block = $3(el2);
64285
+ if (block.find("p, div, h1, h2, h3, h4, h5, h6, li, table, ul, ol").length || !/[^\s ]/.test(block.text())) return;
64286
+ const own = parseInlineStyle(block.attr("style") || "");
64287
+ if (hasBorder(own)) return;
64288
+ const mine = spacingOf(el2);
64289
+ const spacing = inherited2(el2, "line-height");
64290
+ const line = /^([\d.]+)px$/i.exec((_a22 = spacing == null ? void 0 : spacing.get("line-height")) != null ? _a22 : "");
64291
+ const size = sizeOf(el2);
64292
+ if (!line || !size) return;
64293
+ let largest = size;
64294
+ block.find("*").each((_22, inner) => {
64295
+ var _a32;
64296
+ const px2 = /^([\d.]+)px$/i.exec((_a32 = spacingOf(inner).get("font-size")) != null ? _a32 : "");
64297
+ if (px2) largest = Math.max(largest, Number(px2[1]));
64298
+ });
64299
+ const exactly = /exactly/i.test((_b = spacing == null ? void 0 : spacing.get("mso-line-height-rule")) != null ? _b : "");
64300
+ const natural = naturalHeight(size, (_c2 = inherited2(el2, "font-family")) == null ? void 0 : _c2.get("font-family"));
64301
+ if (!exactly && largest === size && Number(line[1]) < natural) {
64302
+ own.set("line-height", `${natural}px`);
64303
+ block.attr("style", serializeStyle(own));
64304
+ return;
64305
+ }
64306
+ const leading = Math.round((Number(line[1]) - largest * NATURAL_LINE) * 10) / 10;
64307
+ const shift = Math.round(leading * (exactly ? 0.3 : 0.5) * 10) / 10;
64308
+ if (shift <= 0) return;
64309
+ block.wrapInner(
64310
+ exactly ? `<span style="position:relative;top:${shift}px"></span>` : `<span style="vertical-align:bottom;line-height:normal"></span>`
64311
+ );
64312
+ const tag = el2.tagName.toLowerCase();
64313
+ const fill = (_d = mine.get("background-color")) != null ? _d : mine.get("background");
64314
+ if (exactly || tag === "td" || tag === "th" || !fill || /\(|\s/.test(fill.trim())) return;
64315
+ own.delete("background-color");
64316
+ own.set("background", `linear-gradient(transparent ${leading}px, ${fill.trim()} ${leading}px)`);
64317
+ block.attr("style", serializeStyle(own));
64318
+ });
64319
+ $3("body *").each((_3, node) => {
64320
+ var _a22, _b;
64321
+ const el2 = node;
64322
+ if (!$3(el2).contents().toArray().some((n2) => n2.type === "text" && /[^\s ]/.test(n2.data))) return;
64323
+ const family = (_b = (_a22 = inherited2(el2, "font-family")) == null ? void 0 : _a22.get("font-family")) != null ? _b : "";
64324
+ const size = sizeOf(el2);
64325
+ if (!isGill(family) || size === void 0) return;
64326
+ const block = $3(el2).closest("p, div, li, td, th, h1, h2, h3, h4, h5, h6").get(0);
64327
+ const blockSize = block && block !== el2 ? sizeOf(block) : void 0;
64328
+ const large = family.trim().startsWith(GILL_LARGE);
64329
+ if (large === (size > 22 || blockSize !== void 0 && size > blockSize)) return;
64330
+ const props = parseInlineStyle($3(el2).attr("style") || "");
64331
+ const stack = family.replace(new RegExp(String.raw`^\s*${GILL_LARGE},\s*`), "");
64332
+ props.set("font-family", large ? stack : `${GILL_LARGE}, ${stack}`);
64333
+ $3(el2).attr("style", serializeStyle(props));
64334
+ });
64335
+ const reset = "<style>h2{margin:0}p{margin:14pt 0}td,th{box-sizing:border-box}</style>";
64125
64336
  const head = $3("head");
64126
64337
  if (head.length) head.prepend(reset);
64127
- else if ($3("p,h2").length) $3.root().prepend(reset);
64338
+ else if ($3("p,h2,td,th").length) $3.root().prepend(reset);
64128
64339
  }
64129
64340
  var MAX_HTML_SIZE = 2 * 1024 * 1024;
64130
64341
  var MAX_WARNING_LOCATIONS = 100;
@@ -66601,7 +66812,7 @@ function simulateDarkMode(html3, clientId) {
66601
66812
  }
66602
66813
  break;
66603
66814
  case "outlook-windows-legacy":
66604
- applyColorInversion($3, "full", clientId);
66815
+ applyColorInversion($3, "outlook-classic", clientId);
66605
66816
  if (!html3.includes("prefers-color-scheme")) {
66606
66817
  warnings.push({
66607
66818
  severity: "info",
@@ -66683,7 +66894,9 @@ function simulateDarkMode(html3, clientId) {
66683
66894
  return { html: $3.html(), warnings };
66684
66895
  }
66685
66896
  var MEASURED_CANVAS = {
66686
- "outlook-macos": { bg: "#1e1e1e", fg: "#ffffff" }
66897
+ "outlook-macos": { bg: "#1e1e1e", fg: "#ffffff" },
66898
+ // ponytail: fg unmeasured; Word's automatic text is black, which maps here.
66899
+ "outlook-windows-legacy": { bg: "#262626", fg: "#f6f6f6" }
66687
66900
  };
66688
66901
  var SAMPLED_DARK = {
66689
66902
  "outlook-web": { eeeae4: "#595651" },
@@ -66740,6 +66953,53 @@ function outlookMacColor(value, role) {
66740
66953
  if (c2.r === c2.g && c2.g === c2.b) return withLabLightness(c2, (l2) => Math.min(l2, 88.5 - 0.772 * l2), D65);
66741
66954
  return withLabLightness(c2, () => 34.6, D65);
66742
66955
  }
66956
+ var WORD_DARK_GREYS = [
66957
+ [0, 246],
66958
+ [15, 233],
66959
+ [30, 225],
66960
+ [45, 216],
66961
+ [60, 206],
66962
+ [75, 196],
66963
+ [90, 185],
66964
+ [105, 174],
66965
+ [120, 163],
66966
+ [135, 151],
66967
+ [150, 139],
66968
+ [165, 126],
66969
+ [180, 113],
66970
+ [195, 99],
66971
+ [210, 85],
66972
+ [225, 70],
66973
+ [240, 55],
66974
+ [255, 38]
66975
+ ];
66976
+ var greyL = (v) => {
66977
+ const s2 = v / 255;
66978
+ return 116 * labF(s2 <= 0.04045 ? s2 / 12.92 : ((s2 + 0.055) / 1.055) ** 2.4) - 16;
66979
+ };
66980
+ var WORD_DARK_L = WORD_DARK_GREYS.map(([from, to2]) => [greyL(from), greyL(to2)]);
66981
+ var wordDarkL = (l2) => {
66982
+ const i2 = Math.max(1, WORD_DARK_L.findIndex(([x2]) => x2 >= Math.min(l2, 100)));
66983
+ const [[x0, y0], [x1, y1]] = [WORD_DARK_L[i2 - 1], WORD_DARK_L[i2]];
66984
+ return y0 + (y1 - y0) * (l2 - x0) / (x1 - x0);
66985
+ };
66986
+ function outlookClassicColor(value) {
66987
+ const c2 = parseColor(value);
66988
+ if (!c2 || c2.a === 0) return null;
66989
+ const linear = [c2.r, c2.g, c2.b].map((v) => {
66990
+ const s2 = v / 255;
66991
+ return s2 <= 0.04045 ? s2 / 12.92 : ((s2 + 0.055) / 1.055) ** 2.4;
66992
+ });
66993
+ const y3 = 0.2126 * linear[0] + 0.7152 * linear[1] + 0.0722 * linear[2];
66994
+ const l2 = 116 * labF(y3) - 16;
66995
+ const out = labFInv((wordDarkL(l2) + 16) / 116);
66996
+ const k2 = y3 > 0 ? Math.sqrt(out / y3) : 1;
66997
+ const [r2, g3, b2] = linear.map((v) => {
66998
+ const t2 = Math.min(1, Math.max(0, out + k2 * (v - y3)));
66999
+ return Math.round(255 * (t2 <= 31308e-7 ? 12.92 * t2 : 1.055 * t2 ** (1 / 2.4) - 0.055));
67000
+ });
67001
+ return hex({ r: r2, g: g3, b: b2 });
67002
+ }
66743
67003
  function gmailAndroidColor(value, role) {
66744
67004
  const parsed = parseColor(value);
66745
67005
  if (!parsed || parsed.a === 0) return null;
@@ -66752,6 +67012,7 @@ function invertColor(value, mode, clientId, role = "bg") {
66752
67012
  var _a22;
66753
67013
  if (mode === "gmail-android") return gmailAndroidColor(value, role);
66754
67014
  if (mode === "outlook-macos") return outlookMacColor(value, role);
67015
+ if (mode === "outlook-classic") return outlookClassicColor(value);
66755
67016
  const pinned = clientId && ((_a22 = SAMPLED_DARK[clientId]) == null ? void 0 : _a22[value.trim().replace("#", "").toLowerCase()]);
66756
67017
  if (pinned) return pinned;
66757
67018
  const parsed = parseColor(value);
@@ -66793,12 +67054,25 @@ function extractBackgroundColor(value) {
66793
67054
  }
66794
67055
  return null;
66795
67056
  }
67057
+ var BORDER_SHORTHAND = /^border(-(top|right|bottom|left))?$/;
67058
+ function invertBorder(value, mode, clientId) {
67059
+ let changed = false;
67060
+ const next2 = value.replace(/#[0-9a-f]{3,8}(?![0-9a-z])|rgba?\([^)]*\)/gi, (token) => {
67061
+ const inverted = invertColor(token, mode, clientId);
67062
+ if (!inverted) return token;
67063
+ changed = true;
67064
+ return inverted;
67065
+ });
67066
+ return changed ? next2 : null;
67067
+ }
66796
67068
  function applyColorInversion($3, mode, clientId) {
66797
67069
  $3("[style]").each((_3, el2) => {
66798
67070
  const style = $3(el2).attr("style") || "";
66799
67071
  const props = parseInlineStyle(style);
66800
67072
  let changed = false;
67073
+ const keepFill = mode === "outlook-classic" && $3(el2).is("[data-vml]");
66801
67074
  props.forEach((value, prop2) => {
67075
+ if (keepFill && prop2 !== "color") return;
66802
67076
  if (COLOR_PROPS.has(prop2)) {
66803
67077
  const inverted = invertColor(value, mode, clientId, prop2 === "color" ? "fg" : "bg");
66804
67078
  if (inverted) {
@@ -66806,6 +67080,13 @@ function applyColorInversion($3, mode, clientId) {
66806
67080
  changed = true;
66807
67081
  }
66808
67082
  }
67083
+ if (BORDER_SHORTHAND.test(prop2)) {
67084
+ const inverted = invertBorder(value, mode, clientId);
67085
+ if (inverted) {
67086
+ props.set(prop2, inverted);
67087
+ changed = true;
67088
+ }
67089
+ }
66809
67090
  if (prop2 === "background") {
66810
67091
  const bgColor = extractBackgroundColor(value);
66811
67092
  if (bgColor) {
@@ -66830,9 +67111,16 @@ function applyColorInversion($3, mode, clientId) {
66830
67111
  enter(node) {
66831
67112
  if (node.type !== "Declaration") return;
66832
67113
  const prop2 = node.property.toLowerCase();
66833
- if (!COLOR_PROPS.has(prop2) && prop2 !== "background") return;
67114
+ const border = BORDER_SHORTHAND.test(prop2);
67115
+ if (!COLOR_PROPS.has(prop2) && prop2 !== "background" && !border) return;
66834
67116
  const valueStr = hy(node.value);
66835
- if (prop2 === "background") {
67117
+ if (border) {
67118
+ const inverted = invertBorder(valueStr, mode, clientId);
67119
+ if (inverted) {
67120
+ node.value = py(inverted, { context: "value" });
67121
+ modified = true;
67122
+ }
67123
+ } else if (prop2 === "background") {
66836
67124
  const bgColor = extractBackgroundColor(valueStr);
66837
67125
  if (bgColor) {
66838
67126
  const inverted = invertColor(bgColor, mode, clientId);
package/dist/index.js CHANGED
@@ -32,7 +32,7 @@ import {
32
32
  simulateDarkMode,
33
33
  toFramework,
34
34
  transformForAllClients
35
- } from "./chunk-HJEE6UV2.js";
35
+ } from "./chunk-Y3WSDM76.js";
36
36
  import "./chunk-ABDTBRVK.js";
37
37
  import "./chunk-2AP7CT6R.js";
38
38
  import "./chunk-NXBRJX3V.js";
@@ -33302,12 +33302,27 @@ h1 {
33302
33302
  return Math.min(shorter / 2, Math.max(0, pct) / 100 * shorter);
33303
33303
  }
33304
33304
  var DOWNLEVEL_REVEALED = /<!--\[if[^\]]*!\s*\(*\s*(?:mso|vml|true)[^\]]*\]>\s*<(?:!-->|!--\s*-->|!\s*-->)([\s\S]*?)(?:<!--\s*<!\[endif\]-->|<!--\[endif\]-*-->)/gi;
33305
- var DOWNLEVEL_HIDDEN = /<!--\[if(?![^\]]*!)[^\]]*(?:mso|vml|true)[^\]]*\]>([\s\S]*?)<!\[endif\]-->/gi;
33305
+ var DOWNLEVEL_HIDDEN = /<!--\[if(?![^\]]*!)([^\]]*(?:mso|vml|true)[^\]]*)\]>([\s\S]*?)<!\[endif\]-->/gi;
33306
+ var WORD_MSO_VERSION = 16;
33307
+ function wordOpens(condition) {
33308
+ const bits = condition.toLowerCase().replace(/\b(?:(lt|lte|gt|gte)\s+)?mso(?:\s+(\d+(?:\.\d+)?))?/g, (_, op, n) => {
33309
+ if (!n) return "1";
33310
+ const v = Number.parseFloat(n);
33311
+ const ok = op === "lt" ? WORD_MSO_VERSION < v : op === "lte" ? WORD_MSO_VERSION <= v : op === "gt" ? WORD_MSO_VERSION > v : op === "gte" ? WORD_MSO_VERSION >= v : Math.floor(v) === WORD_MSO_VERSION;
33312
+ return ok ? "1" : "0";
33313
+ }).replace(/\b(?:vml|true)\b/g, "1").replace(/[a-z]\w*(?:\s+\d+(?:\.\d+)?)?/g, "0").replace(/\s+/g, "");
33314
+ let s = bits;
33315
+ for (let prev = ""; prev !== s; ) {
33316
+ prev = s;
33317
+ s = s.replace(/\(([01])\)/g, "$1").replace(/([01])&([01])/g, (_, a, b) => a === "1" && b === "1" ? "1" : "0").replace(/([01])\|([01])/g, (_, a, b) => a === "1" || b === "1" ? "1" : "0");
33318
+ }
33319
+ return s === "1";
33320
+ }
33306
33321
  var OFFICE_SETTINGS = /<xml\b[^>]*>[\s\S]*?<\/xml>/gi;
33307
33322
  function resolveMsoBranch(html) {
33308
33323
  return html.replace(DOWNLEVEL_REVEALED, "").replace(
33309
33324
  DOWNLEVEL_HIDDEN,
33310
- (_, inner) => /^\s*<style/i.test(inner) ? inner.replace(/(\.[\w-]+\s*\{[^}]*?)font-size\s*:[^;}]*;?/g, "$1") : inner
33325
+ (_, condition, inner) => !wordOpens(condition) ? "" : /^\s*<style/i.test(inner) ? inner.replace(/(\.[\w-]+\s*\{[^}]*?)font-size\s*:[^;}]*;?/g, "$1") : inner
33311
33326
  ).replace(OFFICE_SETTINGS, "");
33312
33327
  }
33313
33328
  var MSO_HIDE = /mso-hide\s*:\s*all/i;
@@ -33453,27 +33468,28 @@ h1 {
33453
33468
  out = out.replace(
33454
33469
  /<v:roundrect([^>]*)>([\s\S]*?)<\/v:roundrect>/gi,
33455
33470
  (_m, rawAttrs, inner) => {
33456
- var _a2, _b, _c, _d, _e, _f, _g, _h;
33471
+ var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j;
33457
33472
  const a = attrs(rawAttrs);
33458
33473
  const s = styleProps((_a2 = a.style) != null ? _a2 : "");
33459
- const w = (_b = px(s.width)) != null ? _b : 0;
33460
- const h = (_c = px(s.height)) != null ? _c : 0;
33461
- const radius = arcsizeToRadius((_d = a.arcsize) != null ? _d : "20%", w, h);
33474
+ const auto = /^auto$/i.test((_c = (_b = s.width) == null ? void 0 : _b.trim()) != null ? _c : "");
33475
+ const w = auto ? 64 : (_d = px(s.width)) != null ? _d : 0;
33476
+ const h = (_e = px(s.height)) != null ? _e : 0;
33477
+ const radius = arcsizeToRadius((_f = a.arcsize) != null ? _f : "20%", w, h);
33462
33478
  const fillTag = inner.match(/<v:fill([^>]*?)\/?>/i);
33463
33479
  const f = fillTag ? attrs(fillTag[1]) : {};
33464
33480
  const imageData = inner.match(/<v:imagedata([^>]*?)\/?>/i);
33465
33481
  const imageSrc = imageData ? attrs(imageData[1]).src : void 0;
33466
- const fill = (_f = (_e = f.color) != null ? _e : a.fillcolor) != null ? _f : "transparent";
33482
+ const fill = (_h = (_g = f.color) != null ? _g : a.fillcolor) != null ? _h : "transparent";
33467
33483
  const image = imageSrc ? `;background-image:url('${imageSrc}');background-size:100% 100%;background-repeat:no-repeat` : "";
33468
33484
  const stroked = !(a.stroke === "f" || a.stroke === "false");
33469
- const middle = /middle/i.test((_g = s["v-text-anchor"]) != null ? _g : "");
33470
- const label = inner.replace(/<v:fill[^>]*?\/?>(?:\s*<\/v:fill>)?/gi, "").replace(/<v:imagedata[^>]*?\/?>(?:\s*<\/v:imagedata>)?/gi, "").replace(/<\/?w:anchorlock[^>]*>/gi, "").replace(/<center\b/gi, "<span").replace(/<\/center>/gi, "</span>").trim();
33485
+ const middle = /middle/i.test((_i = s["v-text-anchor"]) != null ? _i : "");
33486
+ const label = inner.replace(/<v:fill[^>]*?\/?>(?:\s*<\/v:fill>)?/gi, "").replace(/<v:imagedata[^>]*?\/?>(?:\s*<\/v:imagedata>)?/gi, "").replace(/<\/?w:anchorlock[^>]*>/gi, "").replace(/<center\b/gi, "<span").replace(/<\/center>/gi, "</span>").trim().replace(/^<span(?: style="([^"]*)")?/i, (tag, style) => auto ? `<span style="display:block;max-height:1lh;overflow:hidden;padding:0 9.6px;${style != null ? style : ""}"` : tag);
33471
33487
  const box = [
33472
33488
  w ? `width:${w}px` : "",
33473
33489
  h ? `height:${h}px` : "",
33474
33490
  `border-radius:${radius}px`,
33475
33491
  `background:${fill}${image}`,
33476
- stroked ? `border:1px solid ${(_h = a.strokecolor) != null ? _h : "#000"}` : "border:none",
33492
+ stroked ? `border:1px solid ${(_j = a.strokecolor) != null ? _j : "#000"}` : "border:none",
33477
33493
  "display:inline-flex",
33478
33494
  "justify-content:center",
33479
33495
  `align-items:${middle ? "center" : "flex-start"}`,
@@ -33648,6 +33664,14 @@ h1 {
33648
33664
  "border-left-width"
33649
33665
  ];
33650
33666
  var NATURAL_LINE = 1.15;
33667
+ var GILL_VDMX = [14, 14, 15, 16, 18, 18, 21, 21, 23, 25, 27, 27, 29, 30, 31];
33668
+ var isGill = (family = "") => /^\s*['"]?gill sans/i.test(family);
33669
+ var naturalHeight = (size, family = "") => {
33670
+ if (!isGill(family)) return Math.round(size * NATURAL_LINE);
33671
+ const ppem = Math.round(size);
33672
+ return ppem <= 22 ? GILL_VDMX[Math.max(ppem, 8) - 8] : Math.ceil(0.9292 * size) + Math.ceil(0.2305 * size);
33673
+ };
33674
+ var GILL_LARGE = "'Gill Sans MT Large'";
33651
33675
  var TABLE_GUTTER = 3.5;
33652
33676
  var INVISIBLE_ONLY = /^[\s\u00a0\u00ad\u034f\u200b-\u200d\u2007\ufeff]+$/;
33653
33677
  var LIST_TRAILING_PX = 18;
@@ -33808,8 +33832,27 @@ h1 {
33808
33832
  );
33809
33833
  }
33810
33834
  function prepareWordSource(html) {
33811
- return markHiddenCells(dropWordUnknownColors(html));
33812
- }
33835
+ return wordSubstitutes(markHiddenCells(dropWordUnknownColors(html)));
33836
+ }
33837
+ var WORD_SUBSTITUTES = { rubik: "Calibri" };
33838
+ var SUBSTITUTED = new RegExp(String.raw`(font(?:-family)?\s*:[^;"}]*?)(['"]?)\b(${Object.keys(WORD_SUBSTITUTES).join("|")})\b\2`, "gi");
33839
+ var wordSubstitutes = (html) => html.replace(SUBSTITUTED, (_, lead, _q, name) => `${lead}${WORD_SUBSTITUTES[name.toLowerCase()]}`);
33840
+ var OFFICE_CLOUD_FONTS = [
33841
+ "Work Sans",
33842
+ "Lato",
33843
+ "Montserrat",
33844
+ "Nunito",
33845
+ "Nunito Sans",
33846
+ "Open Sans",
33847
+ "DM Sans",
33848
+ "IBM Plex Sans",
33849
+ "Ubuntu",
33850
+ "Source Code Pro",
33851
+ "Raleway",
33852
+ "Playfair Display",
33853
+ "Poppins"
33854
+ ];
33855
+ var CLOUD = new Set(OFFICE_CLOUD_FONTS.map((f) => f.toLowerCase()));
33813
33856
  function declaredFaces($) {
33814
33857
  const faces = /* @__PURE__ */ new Map();
33815
33858
  $("style").each((_, block) => {
@@ -33819,7 +33862,7 @@ h1 {
33819
33862
  const family = props.get("font-family");
33820
33863
  const named = ((_b = props.get("mso-font-alt")) == null ? void 0 : _b.replace(/["']/g, "").trim()) || null;
33821
33864
  const alt = named && /^sans-serif$/i.test(named) ? WORD_DEFAULT : named;
33822
- if (family) faces.set(firstFamily(family), (_c = alt != null ? alt : faces.get(firstFamily(family))) != null ? _c : null);
33865
+ if (family && !CLOUD.has(firstFamily(family))) faces.set(firstFamily(family), (_c = alt != null ? alt : faces.get(firstFamily(family))) != null ? _c : null);
33823
33866
  }
33824
33867
  });
33825
33868
  return faces;
@@ -33851,8 +33894,36 @@ h1 {
33851
33894
  const value = parts.length === 4 ? parts[3] : parts.length >= 2 ? parts[1] : parts[0];
33852
33895
  return /^\d+(?:\.\d+)?(?:px)?$/.test(value != null ? value : "") ? parseFloat(value) : 0;
33853
33896
  }
33897
+ var SPACING = /^(?:line-height|mso-line-height-rule|mso-line-height-alt|font-size|font|font-family|background|background-color)$/;
33898
+ function sheetSpacing($) {
33899
+ const found = /* @__PURE__ */ new Map();
33900
+ $("style").each((_, block) => {
33901
+ var _a2, _b;
33902
+ for (const { selector, body } of topLevelRules((_a2 = $(block).html()) != null ? _a2 : "")) {
33903
+ const rule = [...parseInlineStyle(body.replace(/!important/gi, ""))].filter(([k]) => SPACING.test(k));
33904
+ if (!rule.length) continue;
33905
+ for (const one of selector.split(",")) {
33906
+ for (const el of matchedByWord($, one)) {
33907
+ const has = (_b = found.get(el)) != null ? _b : /* @__PURE__ */ new Map();
33908
+ for (const [k, v] of rule) has.set(k, v);
33909
+ found.set(el, has);
33910
+ }
33911
+ }
33912
+ }
33913
+ });
33914
+ return found;
33915
+ }
33854
33916
  function applyWordBoxModel($) {
33855
33917
  const faces = declaredFaces($);
33918
+ const sheet = sheetSpacing($);
33919
+ const spacingOf = (el) => {
33920
+ var _a2, _b;
33921
+ const all = new Map([...(_a2 = sheet.get(el)) != null ? _a2 : [], ...parseInlineStyle($(el).attr("style") || "")]);
33922
+ const alt = (_b = all.get("mso-line-height-alt")) == null ? void 0 : _b.trim();
33923
+ const altEm = /^([\d.]+)em$/i.exec(alt != null ? alt : "");
33924
+ if (alt) all.set("line-height", altEm ? `${Number(altEm[1]) * 16}px` : alt);
33925
+ return all;
33926
+ };
33856
33927
  $("[style]").each((_, node) => {
33857
33928
  var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
33858
33929
  const el = node;
@@ -33912,7 +33983,7 @@ h1 {
33912
33983
  const lineHeight = /^([\d.]+)px$/i.exec((_k = props.get("line-height")) != null ? _k : "");
33913
33984
  const fontSize = /^([\d.]+)px$/i.exec((_l = props.get("font-size")) != null ? _l : "");
33914
33985
  if (lineHeight && fontSize && !/exactly/i.test((_m = props.get("mso-line-height-rule")) != null ? _m : "")) {
33915
- const natural = Math.round(Number(fontSize[1]) * NATURAL_LINE);
33986
+ const natural = naturalHeight(Number(fontSize[1]), props.get("font-family"));
33916
33987
  if (Number(lineHeight[1]) < natural) props.set("line-height", `${natural}px`);
33917
33988
  }
33918
33989
  for (const prop of ["word-spacing", "outline", "outline-width", "outline-style", "outline-color", "outline-offset"]) {
@@ -33950,6 +34021,18 @@ h1 {
33950
34021
  props.set("line-height", "0");
33951
34022
  cell.empty().attr("style", serializeStyle(props));
33952
34023
  });
34024
+ $("p").each((_, node) => {
34025
+ if (!$(node).children().length && !/[^ \t\r\n]/.test($(node).text())) $(node).remove();
34026
+ });
34027
+ $("img").each((_, node) => {
34028
+ var _a2, _b;
34029
+ const img = $(node);
34030
+ const props = parseInlineStyle(img.attr("style") || "");
34031
+ const height = Number.parseFloat((_b = (_a2 = props.get("height")) != null ? _a2 : img.attr("height")) != null ? _b : "");
34032
+ if (img.closest("td, th").length || !(height <= 1)) return;
34033
+ props.set("display", "block");
34034
+ img.attr("style", serializeStyle(props));
34035
+ });
33953
34036
  $("hr").each((_, node) => {
33954
34037
  var _a2, _b, _c;
33955
34038
  const props = parseInlineStyle($(node).attr("style") || "");
@@ -33965,7 +34048,7 @@ h1 {
33965
34048
  $(node).attr("style", serializeStyle(set));
33966
34049
  });
33967
34050
  $("a").each((_, node) => {
33968
- if (!$(node).children("div").length) return;
34051
+ if (!$(node).children("div, p").length) return;
33969
34052
  $(node).before('<div style="height:21px"></div>').after('<div style="height:20px"></div>');
33970
34053
  });
33971
34054
  $("a[style*='text-decoration-line']").each((_, node) => {
@@ -34072,37 +34155,91 @@ h1 {
34072
34155
  })) return;
34073
34156
  cell.attr("style", `${style}${style.trim() === "" || /;\s*$/.test(style) ? "" : ";"}text-align:left`);
34074
34157
  });
34158
+ const sheetMargins = /* @__PURE__ */ new Map();
34159
+ $("style").each((_, block) => {
34160
+ var _a2, _b;
34161
+ for (const { selector, body } of topLevelRules((_a2 = $(block).html()) != null ? _a2 : "")) {
34162
+ if (!/margin/i.test(body)) continue;
34163
+ let cells = [];
34164
+ try {
34165
+ cells = $(selector).filter("td, th").toArray();
34166
+ } catch (e) {
34167
+ continue;
34168
+ }
34169
+ const rule = parseInlineStyle(body.replace(/!important/gi, ""));
34170
+ for (const cell of cells) {
34171
+ const has = (_b = sheetMargins.get(cell)) != null ? _b : /* @__PURE__ */ new Map();
34172
+ for (const [k, v] of rule) if (/^margin(?:-top|-bottom)?$/.test(k)) has.set(k, v);
34173
+ sheetMargins.set(cell, has);
34174
+ }
34175
+ }
34176
+ });
34177
+ const verticalMargins = (props) => {
34178
+ var _a2, _b, _c, _d;
34179
+ const box = ((_a2 = props.get("margin")) != null ? _a2 : "").trim().split(/\s+/).filter(Boolean);
34180
+ const read = (v) => v === void 0 ? void 0 : Number.parseFloat(v) || 0;
34181
+ return { top: read((_b = props.get("margin-top")) != null ? _b : box[0]), bottom: read((_d = (_c = props.get("margin-bottom")) != null ? _c : box[2]) != null ? _d : box[0]) };
34182
+ };
34183
+ const holdsBareText = (cell) => {
34184
+ const inline = $(cell).clone();
34185
+ inline.find("table, div, p, ul, ol, h1, h2, h3, h4, h5, h6").remove();
34186
+ return /[^\s ]/.test(inline.text());
34187
+ };
34075
34188
  $("table").each((_, node) => {
34076
- var _a2, _b, _c, _d, _e, _f, _g, _h;
34189
+ var _a2, _b, _c, _d, _e;
34077
34190
  const table = $(node);
34078
34191
  const props = parseInlineStyle(table.attr("style") || "");
34079
34192
  const box = ((_a2 = props.get("margin")) != null ? _a2 : "").trim().split(/\s+/).filter(Boolean);
34080
- const top = Number.parseFloat((_c = (_b = props.get("margin-top")) != null ? _b : box[0]) != null ? _c : "") || 0;
34081
- const bottom = Number.parseFloat((_f = (_e = (_d = props.get("margin-bottom")) != null ? _d : box[2]) != null ? _e : box[0]) != null ? _f : "") || 0;
34082
- if (top <= 0 && bottom <= 0 || /center/i.test((_g = table.attr("align")) != null ? _g : "")) return;
34083
- const rows = table.find("> tr, > tbody > tr");
34084
- const grow = (row, side, by) => {
34085
- row.children("td, th").each((_2, cell) => {
34086
- var _a3, _b2, _c2, _d2;
34087
- const own = parseInlineStyle($(cell).attr("style") || "");
34088
- const pad = ((_a3 = own.get("padding")) != null ? _a3 : "").trim().split(/\s+/).filter(Boolean);
34089
- 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;
34090
- own.set(`padding-${side}`, `${was + by}px`);
34091
- $(cell).attr("style", serializeStyle(own));
34092
- });
34093
- };
34094
- if (!rows.length) return;
34095
- if (top > 0) grow(rows.first(), "top", top);
34096
- if (bottom > 0) grow(rows.last(), "bottom", bottom);
34193
+ const centred = /center/i.test((_b = table.attr("align")) != null ? _b : "");
34194
+ const margins = verticalMargins(props);
34195
+ const top = centred ? 0 : (_c = margins.top) != null ? _c : 0;
34196
+ const bottom = centred ? 0 : (_d = margins.bottom) != null ? _d : 0;
34197
+ table.find("> tr, > tbody > tr").each((_2, row) => {
34198
+ var _a3, _b2, _c2, _d2, _e2, _f, _g;
34199
+ const cells = $(row).children("td, th").toArray();
34200
+ const bare = cells.filter(holdsBareText);
34201
+ if (!bare.length) return;
34202
+ for (const cell of cells) {
34203
+ const mine = bare.includes(cell) ? verticalMargins(new Map([...(_a3 = sheetMargins.get(cell)) != null ? _a3 : [], ...parseInlineStyle($(cell).attr("style") || "")])) : { top: void 0, bottom: void 0 };
34204
+ const style = parseInlineStyle($(cell).attr("style") || "");
34205
+ const pad = ((_b2 = style.get("padding")) != null ? _b2 : "").trim().split(/\s+/).filter(Boolean);
34206
+ for (const [side, by] of [["top", (_c2 = mine.top) != null ? _c2 : top], ["bottom", (_d2 = mine.bottom) != null ? _d2 : bottom]]) {
34207
+ if (by <= 0) continue;
34208
+ const was = Number.parseFloat((_g = (_f = style.get(`padding-${side}`)) != null ? _f : side === "top" ? pad[0] : (_e2 = pad[2]) != null ? _e2 : pad[0]) != null ? _g : "") || 0;
34209
+ style.set(`padding-${side}`, `${was + by}px`);
34210
+ }
34211
+ $(cell).attr("style", serializeStyle(style));
34212
+ }
34213
+ });
34214
+ if (top <= 0 && bottom <= 0 || centred) return;
34097
34215
  props.delete("margin-top");
34098
34216
  props.delete("margin-bottom");
34099
34217
  if (box.length) {
34100
34218
  props.delete("margin");
34101
- if (box[1]) props.set("margin-left", (_h = box[3]) != null ? _h : box[1]);
34219
+ if (box[1]) props.set("margin-left", (_e = box[3]) != null ? _e : box[1]);
34102
34220
  if (box[1]) props.set("margin-right", box[1]);
34103
34221
  }
34104
34222
  table.attr("style", serializeStyle(props));
34105
34223
  });
34224
+ $("tr").each((_, row) => {
34225
+ const cells = $(row).children("td, th").toArray();
34226
+ if (cells.length < 2) return;
34227
+ const sides = cells.map((cell) => {
34228
+ var _a2, _b, _c, _d;
34229
+ const style = parseInlineStyle($(cell).attr("style") || "");
34230
+ const pad = ((_a2 = style.get("padding")) != null ? _a2 : "").trim().split(/\s+/).filter(Boolean);
34231
+ const read = (v) => Number.parseFloat(v != null ? v : "") || 0;
34232
+ return { style, top: read((_b = style.get("padding-top")) != null ? _b : pad[0]), bottom: read((_d = (_c = style.get("padding-bottom")) != null ? _c : pad[2]) != null ? _d : pad[0]) };
34233
+ });
34234
+ const top = Math.max(...sides.map((s) => s.top));
34235
+ const bottom = Math.max(...sides.map((s) => s.bottom));
34236
+ cells.forEach((cell, i) => {
34237
+ const { style } = sides[i];
34238
+ if (sides[i].top < top) style.set("padding-top", `${top}px`);
34239
+ if (sides[i].bottom < bottom) style.set("padding-bottom", `${bottom}px`);
34240
+ if (sides[i].top < top || sides[i].bottom < bottom) $(cell).attr("style", serializeStyle(style));
34241
+ });
34242
+ });
34106
34243
  $("table").each((_, node) => {
34107
34244
  var _a2, _b;
34108
34245
  const props = parseInlineStyle($(node).attr("style") || "");
@@ -34159,10 +34296,84 @@ h1 {
34159
34296
  const after = serializeStyle(props);
34160
34297
  if (after) p.attr("style", after);
34161
34298
  });
34162
- const reset = "<style>h2{margin:0}p{margin:14pt 0}</style>";
34299
+ $("span, a, strong, b, em, i, u, font").each((_, node) => {
34300
+ var _a2, _b, _c;
34301
+ const el = node;
34302
+ const props = parseInlineStyle($(el).attr("style") || "");
34303
+ if (/block/i.test((_a2 = props.get("display")) != null ? _a2 : "")) return;
34304
+ const spacing = $(el).parents().toArray().map(spacingOf).find((st) => st.has("line-height"));
34305
+ if (!/^[\d.]+px$/i.test((_b = spacing == null ? void 0 : spacing.get("line-height")) != null ? _b : "") || /exactly/i.test((_c = spacing == null ? void 0 : spacing.get("mso-line-height-rule")) != null ? _c : "")) return;
34306
+ props.set("line-height", "normal");
34307
+ $(el).attr("style", serializeStyle(props));
34308
+ });
34309
+ const inherited2 = (el, prop) => [el, ...$(el).parents().toArray()].map(spacingOf).find((st) => st.has(prop));
34310
+ const sizeOf = (el) => {
34311
+ var _a2, _b, _c;
34312
+ const sized = [el, ...$(el).parents().toArray()].map(spacingOf).find((st) => {
34313
+ var _a3;
34314
+ return st.has("font-size") || /\d(?:\.\d+)?px/.test((_a3 = st.get("font")) != null ? _a3 : "");
34315
+ });
34316
+ const px2 = (_c = /^([\d.]+)px$/i.exec((_a2 = sized == null ? void 0 : sized.get("font-size")) != null ? _a2 : "")) != null ? _c : /(?:^|\s)([\d.]+)px/.exec((_b = sized == null ? void 0 : sized.get("font")) != null ? _b : "");
34317
+ return px2 ? Number(px2[1]) : void 0;
34318
+ };
34319
+ $("p, div, h1, h2, h3, h4, h5, h6, li, td, th").each((_, node) => {
34320
+ var _a2, _b, _c, _d;
34321
+ const el = node;
34322
+ const block = $(el);
34323
+ if (block.find("p, div, h1, h2, h3, h4, h5, h6, li, table, ul, ol").length || !/[^\s ]/.test(block.text())) return;
34324
+ const own = parseInlineStyle(block.attr("style") || "");
34325
+ if (hasBorder(own)) return;
34326
+ const mine = spacingOf(el);
34327
+ const spacing = inherited2(el, "line-height");
34328
+ const line = /^([\d.]+)px$/i.exec((_a2 = spacing == null ? void 0 : spacing.get("line-height")) != null ? _a2 : "");
34329
+ const size = sizeOf(el);
34330
+ if (!line || !size) return;
34331
+ let largest = size;
34332
+ block.find("*").each((_2, inner) => {
34333
+ var _a3;
34334
+ const px2 = /^([\d.]+)px$/i.exec((_a3 = spacingOf(inner).get("font-size")) != null ? _a3 : "");
34335
+ if (px2) largest = Math.max(largest, Number(px2[1]));
34336
+ });
34337
+ const exactly = /exactly/i.test((_b = spacing == null ? void 0 : spacing.get("mso-line-height-rule")) != null ? _b : "");
34338
+ const natural = naturalHeight(size, (_c = inherited2(el, "font-family")) == null ? void 0 : _c.get("font-family"));
34339
+ if (!exactly && largest === size && Number(line[1]) < natural) {
34340
+ own.set("line-height", `${natural}px`);
34341
+ block.attr("style", serializeStyle(own));
34342
+ return;
34343
+ }
34344
+ const leading = Math.round((Number(line[1]) - largest * NATURAL_LINE) * 10) / 10;
34345
+ const shift = Math.round(leading * (exactly ? 0.3 : 0.5) * 10) / 10;
34346
+ if (shift <= 0) return;
34347
+ block.wrapInner(
34348
+ exactly ? `<span style="position:relative;top:${shift}px"></span>` : `<span style="vertical-align:bottom;line-height:normal"></span>`
34349
+ );
34350
+ const tag = el.tagName.toLowerCase();
34351
+ const fill = (_d = mine.get("background-color")) != null ? _d : mine.get("background");
34352
+ if (exactly || tag === "td" || tag === "th" || !fill || /\(|\s/.test(fill.trim())) return;
34353
+ own.delete("background-color");
34354
+ own.set("background", `linear-gradient(transparent ${leading}px, ${fill.trim()} ${leading}px)`);
34355
+ block.attr("style", serializeStyle(own));
34356
+ });
34357
+ $("body *").each((_, node) => {
34358
+ var _a2, _b;
34359
+ const el = node;
34360
+ if (!$(el).contents().toArray().some((n) => n.type === "text" && /[^\s ]/.test(n.data))) return;
34361
+ const family = (_b = (_a2 = inherited2(el, "font-family")) == null ? void 0 : _a2.get("font-family")) != null ? _b : "";
34362
+ const size = sizeOf(el);
34363
+ if (!isGill(family) || size === void 0) return;
34364
+ const block = $(el).closest("p, div, li, td, th, h1, h2, h3, h4, h5, h6").get(0);
34365
+ const blockSize = block && block !== el ? sizeOf(block) : void 0;
34366
+ const large = family.trim().startsWith(GILL_LARGE);
34367
+ if (large === (size > 22 || blockSize !== void 0 && size > blockSize)) return;
34368
+ const props = parseInlineStyle($(el).attr("style") || "");
34369
+ const stack = family.replace(new RegExp(String.raw`^\s*${GILL_LARGE},\s*`), "");
34370
+ props.set("font-family", large ? stack : `${GILL_LARGE}, ${stack}`);
34371
+ $(el).attr("style", serializeStyle(props));
34372
+ });
34373
+ const reset = "<style>h2{margin:0}p{margin:14pt 0}td,th{box-sizing:border-box}</style>";
34163
34374
  const head = $("head");
34164
34375
  if (head.length) head.prepend(reset);
34165
- else if ($("p,h2").length) $.root().prepend(reset);
34376
+ else if ($("p,h2,td,th").length) $.root().prepend(reset);
34166
34377
  }
34167
34378
  var MAX_HTML_SIZE = 2 * 1024 * 1024;
34168
34379
  var MAX_WARNING_LOCATIONS = 100;
@@ -36689,7 +36900,7 @@ h1 {
36689
36900
  }
36690
36901
  break;
36691
36902
  case "outlook-windows-legacy":
36692
- applyColorInversion($, "full", clientId);
36903
+ applyColorInversion($, "outlook-classic", clientId);
36693
36904
  if (!html.includes("prefers-color-scheme")) {
36694
36905
  warnings.push({
36695
36906
  severity: "info",
@@ -36771,7 +36982,9 @@ h1 {
36771
36982
  return { html: $.html(), warnings };
36772
36983
  }
36773
36984
  var MEASURED_CANVAS = {
36774
- "outlook-macos": { bg: "#1e1e1e", fg: "#ffffff" }
36985
+ "outlook-macos": { bg: "#1e1e1e", fg: "#ffffff" },
36986
+ // ponytail: fg unmeasured; Word's automatic text is black, which maps here.
36987
+ "outlook-windows-legacy": { bg: "#262626", fg: "#f6f6f6" }
36775
36988
  };
36776
36989
  var SAMPLED_DARK = {
36777
36990
  "outlook-web": { eeeae4: "#595651" },
@@ -36828,6 +37041,53 @@ h1 {
36828
37041
  if (c.r === c.g && c.g === c.b) return withLabLightness(c, (l) => Math.min(l, 88.5 - 0.772 * l), D65);
36829
37042
  return withLabLightness(c, () => 34.6, D65);
36830
37043
  }
37044
+ var WORD_DARK_GREYS = [
37045
+ [0, 246],
37046
+ [15, 233],
37047
+ [30, 225],
37048
+ [45, 216],
37049
+ [60, 206],
37050
+ [75, 196],
37051
+ [90, 185],
37052
+ [105, 174],
37053
+ [120, 163],
37054
+ [135, 151],
37055
+ [150, 139],
37056
+ [165, 126],
37057
+ [180, 113],
37058
+ [195, 99],
37059
+ [210, 85],
37060
+ [225, 70],
37061
+ [240, 55],
37062
+ [255, 38]
37063
+ ];
37064
+ var greyL = (v) => {
37065
+ const s = v / 255;
37066
+ return 116 * labF(s <= 0.04045 ? s / 12.92 : ((s + 0.055) / 1.055) ** 2.4) - 16;
37067
+ };
37068
+ var WORD_DARK_L = WORD_DARK_GREYS.map(([from, to]) => [greyL(from), greyL(to)]);
37069
+ var wordDarkL = (l) => {
37070
+ const i = Math.max(1, WORD_DARK_L.findIndex(([x]) => x >= Math.min(l, 100)));
37071
+ const [[x0, y0], [x1, y1]] = [WORD_DARK_L[i - 1], WORD_DARK_L[i]];
37072
+ return y0 + (y1 - y0) * (l - x0) / (x1 - x0);
37073
+ };
37074
+ function outlookClassicColor(value) {
37075
+ const c = parseColor(value);
37076
+ if (!c || c.a === 0) return null;
37077
+ const linear = [c.r, c.g, c.b].map((v) => {
37078
+ const s = v / 255;
37079
+ return s <= 0.04045 ? s / 12.92 : ((s + 0.055) / 1.055) ** 2.4;
37080
+ });
37081
+ const y = 0.2126 * linear[0] + 0.7152 * linear[1] + 0.0722 * linear[2];
37082
+ const l = 116 * labF(y) - 16;
37083
+ const out = labFInv((wordDarkL(l) + 16) / 116);
37084
+ const k = y > 0 ? Math.sqrt(out / y) : 1;
37085
+ const [r, g, b] = linear.map((v) => {
37086
+ const t = Math.min(1, Math.max(0, out + k * (v - y)));
37087
+ return Math.round(255 * (t <= 31308e-7 ? 12.92 * t : 1.055 * t ** (1 / 2.4) - 0.055));
37088
+ });
37089
+ return hex({ r, g, b });
37090
+ }
36831
37091
  function gmailAndroidColor(value, role) {
36832
37092
  const parsed = parseColor(value);
36833
37093
  if (!parsed || parsed.a === 0) return null;
@@ -36840,6 +37100,7 @@ h1 {
36840
37100
  var _a2;
36841
37101
  if (mode === "gmail-android") return gmailAndroidColor(value, role);
36842
37102
  if (mode === "outlook-macos") return outlookMacColor(value, role);
37103
+ if (mode === "outlook-classic") return outlookClassicColor(value);
36843
37104
  const pinned = clientId && ((_a2 = SAMPLED_DARK[clientId]) == null ? void 0 : _a2[value.trim().replace("#", "").toLowerCase()]);
36844
37105
  if (pinned) return pinned;
36845
37106
  const parsed = parseColor(value);
@@ -36881,12 +37142,25 @@ h1 {
36881
37142
  }
36882
37143
  return null;
36883
37144
  }
37145
+ var BORDER_SHORTHAND = /^border(-(top|right|bottom|left))?$/;
37146
+ function invertBorder(value, mode, clientId) {
37147
+ let changed = false;
37148
+ const next = value.replace(/#[0-9a-f]{3,8}(?![0-9a-z])|rgba?\([^)]*\)/gi, (token) => {
37149
+ const inverted = invertColor(token, mode, clientId);
37150
+ if (!inverted) return token;
37151
+ changed = true;
37152
+ return inverted;
37153
+ });
37154
+ return changed ? next : null;
37155
+ }
36884
37156
  function applyColorInversion($, mode, clientId) {
36885
37157
  $("[style]").each((_, el) => {
36886
37158
  const style = $(el).attr("style") || "";
36887
37159
  const props = parseInlineStyle(style);
36888
37160
  let changed = false;
37161
+ const keepFill = mode === "outlook-classic" && $(el).is("[data-vml]");
36889
37162
  props.forEach((value, prop) => {
37163
+ if (keepFill && prop !== "color") return;
36890
37164
  if (COLOR_PROPS.has(prop)) {
36891
37165
  const inverted = invertColor(value, mode, clientId, prop === "color" ? "fg" : "bg");
36892
37166
  if (inverted) {
@@ -36894,6 +37168,13 @@ h1 {
36894
37168
  changed = true;
36895
37169
  }
36896
37170
  }
37171
+ if (BORDER_SHORTHAND.test(prop)) {
37172
+ const inverted = invertBorder(value, mode, clientId);
37173
+ if (inverted) {
37174
+ props.set(prop, inverted);
37175
+ changed = true;
37176
+ }
37177
+ }
36897
37178
  if (prop === "background") {
36898
37179
  const bgColor = extractBackgroundColor(value);
36899
37180
  if (bgColor) {
@@ -36918,9 +37199,16 @@ h1 {
36918
37199
  enter(node) {
36919
37200
  if (node.type !== "Declaration") return;
36920
37201
  const prop = node.property.toLowerCase();
36921
- if (!COLOR_PROPS.has(prop) && prop !== "background") return;
37202
+ const border = BORDER_SHORTHAND.test(prop);
37203
+ if (!COLOR_PROPS.has(prop) && prop !== "background" && !border) return;
36922
37204
  const valueStr = csstree4.generate(node.value);
36923
- if (prop === "background") {
37205
+ if (border) {
37206
+ const inverted = invertBorder(valueStr, mode, clientId);
37207
+ if (inverted) {
37208
+ node.value = csstree4.parse(inverted, { context: "value" });
37209
+ modified = true;
37210
+ }
37211
+ } else if (prop === "background") {
36924
37212
  const bgColor = extractBackgroundColor(valueStr);
36925
37213
  if (bgColor) {
36926
37214
  const inverted = invertColor(bgColor, mode, clientId);
@@ -43070,7 +43358,7 @@ Href: ${href}`
43070
43358
  // package.json
43071
43359
  var package_default = {
43072
43360
  name: "@emailens/cli",
43073
- version: "0.13.11",
43361
+ version: "0.13.13",
43074
43362
  description: "CLI tool for email compatibility analysis: lint, preview and export HTML, MJML, Maizzle and React Email rendering across 21 email clients.",
43075
43363
  type: "module",
43076
43364
  bin: {
@@ -43111,7 +43399,7 @@ var package_default = {
43111
43399
  },
43112
43400
  devDependencies: {
43113
43401
  "@anthropic-ai/sdk": "^0.52.0",
43114
- "@emailens/engine": "^0.18.13",
43402
+ "@emailens/engine": "^0.18.15",
43115
43403
  "@types/bun": "^1.4.0",
43116
43404
  "@types/mjml": "^4.7.4",
43117
43405
  "@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-HJEE6UV2.js";
8
+ } from "./chunk-Y3WSDM76.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.11",
3
+ "version": "0.13.13",
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.13",
44
+ "@emailens/engine": "^0.18.15",
45
45
  "@types/bun": "^1.4.0",
46
46
  "@types/mjml": "^4.7.4",
47
47
  "@types/node": "^25.9.5",