@samva/markup 0.1.2 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (92) hide show
  1. package/AGENTS.md +25 -5
  2. package/README.md +92 -26
  3. package/dist/{ast-DAhnAvQN.d.ts → ast-63I-VLQx.d.ts} +15 -2
  4. package/dist/ast.d.ts +2 -2
  5. package/dist/ast.js +14 -1
  6. package/dist/{checks-D-zFQt5R.js → checks-DXuERO4B.js} +36 -2
  7. package/dist/checks.d.ts +8 -1
  8. package/dist/checks.js +2 -2
  9. package/dist/compile-sms.d.ts +2 -2
  10. package/dist/compile-whatsapp.d.ts +2 -2
  11. package/dist/compile.d.ts +9 -84
  12. package/dist/compile.js +11 -920
  13. package/dist/compiler.d.ts +301 -0
  14. package/dist/compiler.js +1389 -0
  15. package/dist/components.d.ts +3 -3
  16. package/dist/corpus-Dz5irJ9x.d.ts +161 -0
  17. package/dist/diagnostics-Djd9ckLg.d.ts +90 -0
  18. package/dist/diagnostics.js +4 -1
  19. package/dist/elements-DtwKlFVH.d.ts +820 -0
  20. package/dist/email/components.d.ts +119 -0
  21. package/dist/email/components.js +207 -0
  22. package/dist/email/diagnostics.d.ts +2 -0
  23. package/dist/email/diagnostics.js +56 -0
  24. package/dist/email/elements.d.ts +2 -0
  25. package/dist/email/elements.js +299 -0
  26. package/dist/email/html.d.ts +42 -0
  27. package/dist/email/html.js +266 -0
  28. package/dist/email/jsx-dev-runtime.d.ts +26 -0
  29. package/dist/email/jsx-dev-runtime.js +12 -0
  30. package/dist/email/jsx-runtime.d.ts +2 -0
  31. package/dist/email/jsx-runtime.js +60 -0
  32. package/dist/email/render.d.ts +36 -0
  33. package/dist/email/render.js +6 -0
  34. package/dist/email/selection.d.ts +102 -0
  35. package/dist/email/selection.js +143 -0
  36. package/dist/email/source-edit.d.ts +67 -0
  37. package/dist/email/source-edit.js +185 -0
  38. package/dist/email/stylesheets.d.ts +2 -0
  39. package/dist/email/stylesheets.js +43 -0
  40. package/dist/email/text.d.ts +7 -0
  41. package/dist/email/text.js +92 -0
  42. package/dist/emit.d.ts +13 -12
  43. package/dist/emit.js +63 -63
  44. package/dist/input-schema-BIfzI63B.d.ts +23 -0
  45. package/dist/input-schema.d.ts +2 -0
  46. package/dist/input-schema.js +170 -0
  47. package/dist/jsx-dev-runtime.d.ts +4 -3
  48. package/dist/jsx-dev-runtime.js +9 -1
  49. package/dist/{jsx-runtime-eNIMY87F.d.ts → jsx-runtime-C5k_Zq0A.d.ts} +3 -3
  50. package/dist/jsx-runtime.d.ts +1 -1
  51. package/dist/jsx-runtime.js +20 -1
  52. package/dist/model.d.ts +1 -1
  53. package/dist/ops.d.ts +1 -1
  54. package/dist/ops.js +1 -1
  55. package/dist/{parser-DkQKIjDa.d.ts → parser-CGBS73Gz.d.ts} +2 -2
  56. package/dist/parser.d.ts +1 -1
  57. package/dist/presets/category-mapping.d.ts +1 -1
  58. package/dist/presets/corpus.d.ts +2 -0
  59. package/dist/presets/corpus.js +186 -0
  60. package/dist/presets/public-gallery.d.ts +272 -2
  61. package/dist/presets/public-gallery.js +305 -6
  62. package/dist/presets/public-handoff.d.ts +140 -2
  63. package/dist/presets/public-handoff.js +130 -33
  64. package/dist/presets/public-preview-artifacts.d.ts +2 -2
  65. package/dist/presets/public-preview-artifacts.js +20 -26
  66. package/dist/presets/public-preview.d.ts +56 -2
  67. package/dist/presets/public-preview.js +388 -1152
  68. package/dist/presets/sources.d.ts +17 -4
  69. package/dist/presets/sources.js +1212 -43
  70. package/dist/presets.d.ts +2 -2
  71. package/dist/printer.d.ts +1 -1
  72. package/dist/render-Cddsy_XF.js +585 -0
  73. package/dist/render-template.d.ts +5 -2
  74. package/dist/render-template.js +3 -1
  75. package/dist/source-locations-BCJQnIfU.d.ts +89 -0
  76. package/dist/source-locations.d.ts +2 -0
  77. package/dist/source-locations.js +125 -0
  78. package/dist/stylesheets-oDRAnYA3.d.ts +94 -0
  79. package/dist/template-Dy5yOPyp.d.ts +60 -0
  80. package/dist/template.d.ts +2 -0
  81. package/dist/template.js +37 -0
  82. package/dist/tsx-source-instrumentation.d.ts +23 -0
  83. package/dist/tsx-source-instrumentation.js +97 -0
  84. package/dist/tsx-tracer.d.ts +116 -0
  85. package/dist/tsx-tracer.js +985 -0
  86. package/generated/sml-agent-contract.json +574 -782
  87. package/generated/sml-email-agent-contract.json +502 -677
  88. package/generated/sml-email-language-reference.md +94 -160
  89. package/generated/sml-language-reference.md +195 -220
  90. package/package.json +111 -9
  91. package/dist/public-gallery-D0Zv0pZE.d.ts +0 -611
  92. package/dist/public-preview-u1Z9aaGq.d.ts +0 -1168
@@ -0,0 +1,1389 @@
1
+ import { a as classListOf, c as finalizeValue, d as resolveVariables, i as applyStylesheet, l as foldCalc, n as compileEmail, o as matchesSelector, r as renderEmail, s as downlevelMediaQuery, t as EMAIL_DOCTYPE, u as renderHeadCss } from "./render-Cddsy_XF.js";
2
+ import { EMAIL_ELEMENTS, EMAIL_GLOBAL_ATTRIBUTES, emailElement, isUrlAttribute } from "./email/elements.js";
3
+ import { EmailElementSelection, EmittedPosition, INSTANCE_PATH_ATTRIBUTE, emailAuthoringTarget, emailDefinitionInstances, emailSelectionAncestry, emailSelectionIndex, emailSelectionSiblings, emailSelections } from "./email/selection.js";
4
+ import { escapeAttribute, escapeText, serializeEmailHtml } from "./email/html.js";
5
+ import { EmailCompileError, EmailDiagnostic, EmailDiagnosticSeverity, formatEmailDiagnostic, hasBlockingDiagnostic } from "./email/diagnostics.js";
6
+ import { collectStylesheets, hasStylesheets, registerStylesheet, resetStylesheets } from "./email/stylesheets.js";
7
+ import { deriveEmailText } from "./email/text.js";
8
+ import { buildLineMap, lineColumn } from "./diagnostics.js";
9
+ import { instrumentTsxSourceForPreview } from "./tsx-source-instrumentation.js";
10
+ import { Predicate } from "effect";
11
+ import { parse } from "@babel/parser";
12
+ import { caniemail, parseHtml, rawData } from "caniemail";
13
+ import { generate, ident, parse as parse$1, walk } from "css-tree";
14
+ import { compile } from "tailwindcss";
15
+ //#region src/email/compatibility-assessment.ts
16
+ const VERIFIED_VALUES = /^(?:left|right|center|justify)$/i;
17
+ const SIMPLE_COLOR = /^(?:#[\da-f]{3,8}|rgba?\([^()]+\)|transparent|white|black)$/i;
18
+ /**
19
+ * A feature matrix establishes support, not the effect on a particular message.
20
+ * These rules interpret the pinned caniemail@2.0.2 limitations using emitted
21
+ * values. Unresolved layout, fallback and client-account behavior stays unverified.
22
+ */
23
+ const assessCompatibility = (title, client, support, context, blocking) => {
24
+ const result = (assessment, heading, explanation) => ({
25
+ assessment,
26
+ title: heading,
27
+ explanation
28
+ });
29
+ if (client === "outlook.windows" && support === "partial" && (title === "display" || title === "display:none") && context.hiddenContentOffsets.length > 0) return result("risk", "Hidden content becomes visible in classic Outlook", "Classic Outlook ignores display:none on images and does not inherit it onto nested tables. The emitted inline styles contain hidden content without a resolved hiding fallback. Add a supported hiding fallback before publishing.");
30
+ if (blocking) return result("risk", `${title} is unavailable in a target client`, "This construct is required for message content, structure or navigation. Replace it with a supported construct before publishing.");
31
+ const explained = context.explanation(title, client, support);
32
+ if (explained !== void 0) return result(title.startsWith("system-ui,") ? "degradation" : "not-applicable", title.startsWith("system-ui,") ? "A fallback font will be used" : `${title}: limitation avoided`, explained);
33
+ const declarations = (property) => context.declarations(property);
34
+ const every = (property, predicate) => {
35
+ const values = declarations(property);
36
+ return context.complete && values.length > 0 && values.every(({ value }) => predicate(value));
37
+ };
38
+ const attributesAvoid = (attribute, unsupportedElement) => {
39
+ const values = context.attributes(attribute);
40
+ return values.length > 0 && values.every(({ element }) => element !== unsupportedElement);
41
+ };
42
+ if (title === "font-size" && support === "partial" && ["outlook.windows", "yahoo.desktop-webmail"].includes(client) && declarations("font-size").some(({ value }) => /\d(?:\.\d+)?rem\b/i.test(value))) return result("risk", "Text sizes use unsupported rem units", "These clients cannot apply the emitted rem font sizes. Use pixel sizes to preserve the intended text size.");
43
+ if (title === "target attribute" && context.attributes("target").some(({ value }) => value !== "_blank")) return result("risk", "Links cannot keep the requested window target", "These clients open links in a new window regardless of the requested target. Use a new-window target or remove the dependency on another browsing context.");
44
+ if (title.startsWith("system-ui,") && declarations("font-family").some(({ value }) => !/(?:^|,)\s*(?:sans-serif|serif|monospace)\s*$/i.test(value))) return result("risk", "An unsupported font stack has no generic fallback", "Declare a generic fallback so the client has an explicit font choice when the requested system font is unavailable.");
45
+ if (title === "border-radius" && support !== "partial") return result("degradation", "Corners may appear square", "CSS corner rounding is unavailable in this client. Uncovered elements appear square; a separate VML shape can retain rounding. This finding does not establish a content or navigation failure.");
46
+ if (title === "border-radius" && client === "yahoo.desktop-webmail" && support === "partial") return result("degradation", "Corner shapes may differ", "This client does not support elliptical slash syntax. Review the recorded values if that corner shape is part of the intended design.");
47
+ if (title === "background") {
48
+ const values = [...declarations("background"), ...declarations("background-color")];
49
+ if (context.complete && values.length > 0 && values.every(({ value }) => SIMPLE_COLOR.test(value)) && declarations("background-image").every(({ value }) => value.toLowerCase() === "none")) return result("not-applicable", "Backgrounds use supported color values", "The emitted backgrounds use simple colors. The cited multiple-background and background-size shorthand limitations do not apply.");
50
+ }
51
+ if (title === "dir attribute" && client === "outlook.windows" && attributesAvoid("dir", "a")) return result("not-applicable", "Direction is set outside links", "The cited direction bug affects anchor elements. No emitted anchor carries a dir attribute.");
52
+ if (title === "lang attribute" && client === "yahoo.desktop-webmail" && attributesAvoid("lang", "td")) return result("not-applicable", "Language is set outside table cells", "The cited language-attribute limitation affects table cells. No emitted td carries a lang attribute.");
53
+ if (title === "role attribute" && client === "yahoo.desktop-webmail" && context.attributes("role").length > 0 && context.attributes("role").every(({ element }) => element === "table")) return result("not-applicable", "Roles are applied to supported tables", "Every emitted role attribute is on a table, matching this client's supported element scope.");
54
+ if (title === "text-align" && support === "partial" && every("text-align", (value) => VERIFIED_VALUES.test(value))) return result("not-applicable", "Text uses supported alignment values", "The emitted alignment values do not use match-parent or flow-relative start/end values.");
55
+ if (title === "font-weight" && support === "partial") {
56
+ const pattern = client === "outlook.windows" ? /^(?:normal|bold|400|700)$/i : /^(?:normal|bold|[1-9]00)$/i;
57
+ if (every("font-weight", (value) => pattern.test(value))) return result("not-applicable", "Font weights avoid the numeric limitation", "The emitted weights use values preserved by this client's pinned numeric-weight rule.");
58
+ return result("degradation", "Font weight may be approximated", "This client may substitute a supported weight. Text remains present, but its emphasis can look different.");
59
+ }
60
+ if (title === "outline" && every("outline", (value) => value === "none" || value === "0")) return result("unverified", "Image outlines need a client check", "The emitted styles remove outlines. The matrix cannot establish whether this client adds its own link or image outline.");
61
+ if (title === "width attribute" && client === "outlook.windows" && context.attributes(title.split(" ")[0]).some(({ value, element }) => element === "img" && value.includes("%"))) return result("risk", "Percentage image dimensions use the wrong reference size", "Classic Outlook sizes percentage image attributes against the image file rather than its parent. Use fixed image dimensions with an appropriate responsive fallback.");
62
+ if (title === "overflow" && declarations("overflow").some(({ value }) => /^(?:auto|scroll)$/i.test(value))) return result("risk", "Scrollable content may be inaccessible", "These clients cannot reliably expose content hidden behind a scrolling container. Keep required email content visible without scrolling inside an element.");
63
+ return result("unverified", {
64
+ "<body> element": "Body styling needs a client check",
65
+ border: "Borders need an Outlook check",
66
+ "color-scheme meta tag": "Dark appearance needs a client check",
67
+ display: "Display behavior needs a client check",
68
+ "display:none": "Hidden content needs an Outlook check",
69
+ "height attribute": "Image sizing needs a high-DPI Outlook check",
70
+ "height property": "Element heights need a client check",
71
+ "line-height": "Line spacing needs an Outlook check",
72
+ margin: "Outer spacing needs a client check",
73
+ "max-height property": "Height limits need an Outlook check",
74
+ "max-width": "Width limits need a client check",
75
+ "@media": "Conditional styles need a client check",
76
+ opacity: "Transparent content needs an Outlook check",
77
+ overflow: "Clipped content needs a client check",
78
+ "overflow-wrap": "Long text wrapping needs a client check",
79
+ padding: "Cell spacing needs an Outlook check",
80
+ "<style> element": "Retained styles need a client check",
81
+ "text-decoration": "Link decoration needs a client check",
82
+ "width attribute": "Image sizing needs a high-DPI Outlook check",
83
+ "width property": "Element widths need an Outlook check",
84
+ "word-break": "Word breaking needs a client check"
85
+ }[title] ?? `${title} needs a client check`, "The feature matrix identifies a support difference but does not establish its effect on this message. Check the affected fixtures in the listed clients before relying on this behavior; no automatic source change is justified by this observation alone.");
86
+ };
87
+ //#endregion
88
+ //#region src/email/compatibility-context.ts
89
+ const NON_HIDING_VALUES = {
90
+ "mso-hide": /^none$/,
91
+ visibility: /^visible$/,
92
+ opacity: /^(?:1(?:\.0+)?|100(?:\.0+)?%)$/,
93
+ overflow: /^visible$/,
94
+ "overflow-y": /^visible$/,
95
+ "overflow-x": /^visible$/,
96
+ clip: /^auto$/,
97
+ "clip-path": /^none$/
98
+ };
99
+ const POSITIVE_FIXED_HEIGHT = /^(?:\d+(?:\.\d+)?|\.\d+)(?:px|pt|pc|in|cm|mm)$/;
100
+ /** Evidence from actual declarations and elements, never a text match in email content. */
101
+ const compatibilityContext = (html, css) => {
102
+ const declarations = /* @__PURE__ */ new Map();
103
+ const attributes = /* @__PURE__ */ new Map();
104
+ const elements = /* @__PURE__ */ new Map();
105
+ let complete = true;
106
+ let unresolvedStyles = false;
107
+ const hiddenContentOffsets = [];
108
+ const addCss = (source, context, offset, element) => {
109
+ const inline = /* @__PURE__ */ new Map();
110
+ if (context === "stylesheet" && source.trim() !== "") unresolvedStyles = true;
111
+ try {
112
+ const ast = parse$1(source, { context });
113
+ walk(ast, (node) => {
114
+ if (node.type === "Raw") complete = false;
115
+ if (node.type !== "Declaration") return;
116
+ const property = node.property.toLowerCase();
117
+ const entries = declarations.get(property) ?? [];
118
+ const value = generate(node.value);
119
+ entries.push({
120
+ value,
121
+ offset,
122
+ element
123
+ });
124
+ if (!inline.get(property)?.important || node.important) inline.set(property, {
125
+ value: value.toLowerCase(),
126
+ important: Boolean(node.important)
127
+ });
128
+ declarations.set(property, entries);
129
+ });
130
+ } catch {
131
+ complete = false;
132
+ }
133
+ return inline;
134
+ };
135
+ const { document } = parseHtml(html);
136
+ const visit = (node, ancestors = []) => {
137
+ let descendants = ancestors;
138
+ if (node.type === "comment" && /\[if\b/i.test(node.data)) unresolvedStyles = true;
139
+ if ("attribs" in node) {
140
+ const offset = node.startIndex ?? void 0;
141
+ if (offset !== void 0) {
142
+ const entries = elements.get(node.name) ?? [];
143
+ entries.push(offset);
144
+ elements.set(node.name, entries);
145
+ }
146
+ for (const [name, value] of Object.entries(node.attribs)) {
147
+ const entries = attributes.get(name) ?? [];
148
+ entries.push({
149
+ value,
150
+ offset,
151
+ element: node.name
152
+ });
153
+ attributes.set(name, entries);
154
+ }
155
+ const styles = node.attribs.style === void 0 ? /* @__PURE__ */ new Map() : addCss(node.attribs.style, "declarationList", offset, node.name);
156
+ descendants = [...ancestors, {
157
+ offset,
158
+ styles
159
+ }];
160
+ const fallback = descendants.some(({ styles: candidate }) => {
161
+ const candidateDisplay = candidate.get("display")?.value;
162
+ return candidateDisplay !== void 0 && !/^(?:none|block|inline|inline-block|table|table-row|table-cell|table-row-group)$/i.test(candidateDisplay) || candidate.has("all") || Object.entries(NON_HIDING_VALUES).some(([property, neutral]) => {
163
+ const value = candidate.get(property)?.value;
164
+ return value !== void 0 && !neutral.test(value);
165
+ }) || ["height", "max-height"].some((property) => {
166
+ const value = candidate.get(property)?.value;
167
+ return value !== void 0 && value !== (property === "height" ? "auto" : "none") && !(POSITIVE_FIXED_HEIGHT.test(value) && Number.parseFloat(value) > 0);
168
+ });
169
+ });
170
+ const hiddenAncestor = ancestors.find(({ styles: candidate }) => candidate.get("display")?.value === "none");
171
+ const display = styles.get("display")?.value;
172
+ if (!fallback && node.name === "img" && display === "none" && hiddenAncestor === void 0 && offset !== void 0) hiddenContentOffsets.push(offset);
173
+ if (!fallback && node.name === "table" && hiddenAncestor !== void 0 && display === void 0 && hiddenAncestor.offset !== void 0) hiddenContentOffsets.push(hiddenAncestor.offset);
174
+ if (node.name === "style") {
175
+ for (const child of node.children) if (child.type === "text") addCss(child.data, "stylesheet");
176
+ }
177
+ }
178
+ if ("children" in node) for (const child of node.children) visit(child, descendants);
179
+ };
180
+ for (const child of document.children) visit(child);
181
+ if (css !== void 0) addCss(css, "stylesheet");
182
+ const everyValue = (property, predicate) => {
183
+ const entries = declarations.get(property);
184
+ return complete && entries !== void 0 && entries.length > 0 && entries.every(({ value }) => predicate(value));
185
+ };
186
+ return {
187
+ /** Known hidden-content failures; unresolved cascade or fallback evidence cannot block. */
188
+ get hiddenContentOffsets() {
189
+ return complete && !unresolvedStyles ? [...new Set(hiddenContentOffsets)] : [];
190
+ },
191
+ /** Incomplete CSS cannot prove that every occurrence avoids a limitation. */
192
+ get complete() {
193
+ return complete;
194
+ },
195
+ declarations(property) {
196
+ return declarations.get(property) ?? [];
197
+ },
198
+ attributes(name) {
199
+ return attributes.get(name) ?? [];
200
+ },
201
+ /** Bounded exceptions to caniemail@2.0.2's feature-wide matrix, tied to its client rules. */
202
+ explanation(title, client, support) {
203
+ if (title === "font-size" && support === "partial" && ["outlook.windows", "yahoo.desktop-webmail"].includes(client) && everyValue("font-size", (value) => /^(?:0|(?:\d+(?:\.\d+)?|\.\d+)px)$/i.test(value))) return "All font sizes use pixels; this client's rem-unit limitation does not apply.";
204
+ if (title === "border-radius" && support === "partial" && client === "yahoo.desktop-webmail" && everyValue("border-radius", (value) => /^(?:0|(?:\d+(?:\.\d+)?|\.\d+)(?:px|%))(?:\s+(?:0|(?:\d+(?:\.\d+)?|\.\d+)(?:px|%))){0,3}$/i.test(value))) return "These corner radii do not use the unsupported elliptical slash syntax.";
205
+ if (title === "target attribute" && [
206
+ "gmail.desktop-webmail",
207
+ "gmail.ios",
208
+ "gmail.android",
209
+ "outlook.outlook-com",
210
+ "yahoo.desktop-webmail",
211
+ "outlook.windows",
212
+ "apple-mail.macos",
213
+ "apple-mail.ios"
214
+ ].includes(client) && attributes.has("target") && attributes.get("target").every(({ value }) => value === "_blank")) return "Links already request a new window, matching the client's enforced behavior.";
215
+ if (title === "system-ui, ui-serif, ui-sans-serif, ui-rounded, ui-monospace" && everyValue("font-family", (value) => /(?:^|,)\s*(?:sans-serif|serif|monospace)\s*$/i.test(value))) return "Every font stack ends with a generic fallback. Font appearance can differ in this client.";
216
+ },
217
+ offsets(title) {
218
+ const element = /^<([a-z0-9]+)> element$/i.exec(title);
219
+ if (element !== null) return elements.get(element[1]) ?? [];
220
+ const attribute = /^([a-z-]+) attribute$/i.exec(title);
221
+ const entries = attribute !== null ? attributes.get(attribute[1]) : declarations.get(title.startsWith("system-ui,") ? "font-family" : title.replace(/ property$/, ""));
222
+ return [...new Set(entries?.flatMap(({ offset }) => offset === void 0 ? [] : [offset]) ?? [])];
223
+ }
224
+ };
225
+ };
226
+ //#endregion
227
+ //#region src/email/compatibility.ts
228
+ /**
229
+ * The pinned matrix. Every finding is reported per client, and a client absent
230
+ * from this list is a client Samva makes no claim about.
231
+ */
232
+ const EMAIL_CLIENT_MATRIX = [
233
+ {
234
+ id: "gmail.desktop-webmail",
235
+ label: "Gmail web"
236
+ },
237
+ {
238
+ id: "gmail.ios",
239
+ label: "Gmail iOS"
240
+ },
241
+ {
242
+ id: "gmail.android",
243
+ label: "Gmail Android"
244
+ },
245
+ {
246
+ id: "apple-mail.macos",
247
+ label: "Apple Mail macOS"
248
+ },
249
+ {
250
+ id: "apple-mail.ios",
251
+ label: "Apple Mail iOS"
252
+ },
253
+ {
254
+ id: "yahoo.desktop-webmail",
255
+ label: "Yahoo web"
256
+ },
257
+ {
258
+ id: "outlook.outlook-com",
259
+ label: "Outlook web and new Windows"
260
+ },
261
+ {
262
+ id: "outlook.windows",
263
+ label: "Outlook classic Windows"
264
+ }
265
+ ];
266
+ const LABELS = new Map(EMAIL_CLIENT_MATRIX.map((target) => [target.id, target.label]));
267
+ const data = rawData;
268
+ const COMPATIBILITY_PROVENANCE = {
269
+ rules: "caniemail@2.0.2",
270
+ apiVersion: data.api_version,
271
+ lastUpdate: data.last_update_date
272
+ };
273
+ /**
274
+ * The constructs whose loss actually breaks a message: the recipient reads
275
+ * something different, in a different order, follows a link that does not work,
276
+ * or sees a layout that has collapsed. A target client dropping one of these
277
+ * blocks publication.
278
+ *
279
+ * The list is deliberately short and enumerated, because the contract is to
280
+ * block *known* failures. Nonessential differences require an assessment of
281
+ * emitted values: a concrete risk warns, expected differences and unverified
282
+ * behavior remain compatibility observations.
283
+ */
284
+ const ESSENTIAL_CONSTRUCTS = /* @__PURE__ */ new Set([
285
+ "<table> element",
286
+ "<div> element",
287
+ "<p> element",
288
+ "<span> element",
289
+ "<ul>, <ol> and <dl>",
290
+ "<h1> to <h6> elements",
291
+ "HTML5 doctype",
292
+ "width attribute",
293
+ "height attribute",
294
+ "align attribute",
295
+ "valign attribute",
296
+ "<img> element",
297
+ "display",
298
+ "mailto: links",
299
+ "Local anchors"
300
+ ]);
301
+ const KNOWN_TITLES = new Set(data.data.map((feature) => feature.title));
302
+ /** The innermost recorded node containing an offset, so a finding names its element. */
303
+ const originsAt = (positions, offset) => {
304
+ let best;
305
+ for (const position of positions) {
306
+ if (offset < position.start || offset >= position.end) continue;
307
+ if (best === void 0 || position.end - position.start < best.end - best.start) best = position;
308
+ }
309
+ return best?.origins ?? [];
310
+ };
311
+ const slug = (title) => title.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
312
+ /**
313
+ * Check the emitted document against the pinned matrix.
314
+ *
315
+ * Findings are grouped by construct rather than repeated per client, so one
316
+ * unsupported property is one diagnostic naming every client that drops it.
317
+ */
318
+ const checkEmailCompatibility = (input) => {
319
+ const targets = input.clients ?? EMAIL_CLIENT_MATRIX;
320
+ const context = compatibilityContext(input.html, input.css);
321
+ const targetClients = targets.map((target) => target.id);
322
+ const reports = [caniemail({
323
+ clients: targetClients,
324
+ html: input.html
325
+ }), ...input.css === void 0 ? [] : [caniemail({
326
+ clients: targetClients,
327
+ css: input.css
328
+ })]];
329
+ const grouped = /* @__PURE__ */ new Map();
330
+ for (const bucket of reports.flatMap((report) => [report.issues.errors, report.issues.warnings])) for (const [client, issues] of bucket) {
331
+ const label = LABELS.get(client) ?? client;
332
+ for (const raw of issues) {
333
+ const hiddenContentFailure = client === "outlook.windows" && raw.support === "partial" && (raw.title === "display" || raw.title === "display:none") && context.hiddenContentOffsets.length > 0;
334
+ const blocking = hiddenContentFailure || raw.support !== "partial" && ESSENTIAL_CONSTRUCTS.has(raw.title);
335
+ const { explanation, ...compatibility } = assessCompatibility(raw.title, client, raw.support, context, blocking);
336
+ const key = JSON.stringify([
337
+ raw.title,
338
+ raw.support,
339
+ compatibility,
340
+ explanation
341
+ ]);
342
+ const offsets = hiddenContentFailure ? context.hiddenContentOffsets : context.offsets(raw.title);
343
+ const entry = grouped.get(key);
344
+ if (entry === void 0) grouped.set(key, {
345
+ title: raw.title,
346
+ support: raw.support,
347
+ clients: /* @__PURE__ */ new Set([label]),
348
+ notes: new Set(raw.notes),
349
+ explanation,
350
+ compatibility,
351
+ blocking,
352
+ offsets
353
+ });
354
+ else {
355
+ entry.clients.add(label);
356
+ for (const note of raw.notes) entry.notes.add(note);
357
+ }
358
+ }
359
+ }
360
+ const findings = [];
361
+ for (const entry of grouped.values()) {
362
+ const severity = entry.blocking ? "error" : entry.compatibility.assessment === "risk" ? "warning" : "info";
363
+ const occurrences = entry.offsets.map((offset) => originsAt(input.positions ?? [], offset)).filter((origins) => origins.length > 0);
364
+ const clients = [...entry.clients].sort();
365
+ const dropped = entry.support === "partial" ? clients.length === 1 ? "partially supports" : "partially support" : clients.length === 1 ? "does not support" : "do not support";
366
+ findings.push({
367
+ code: `caniemail/${slug(entry.title)}`,
368
+ severity,
369
+ message: `${clients.join(", ")} ${dropped} ${entry.title}. ${entry.explanation}`,
370
+ compatibility: entry.compatibility,
371
+ origins: occurrences[0] ?? [],
372
+ ...occurrences.length === 0 ? {} : { occurrences },
373
+ ...input.fixture === void 0 ? {} : { fixtures: [input.fixture] },
374
+ clients,
375
+ ...entry.notes.size === 0 ? {} : { notes: [...entry.notes].join(" ") },
376
+ provenance: `${COMPATIBILITY_PROVENANCE.rules} (caniemail data ${COMPATIBILITY_PROVENANCE.apiVersion}, updated ${COMPATIBILITY_PROVENANCE.lastUpdate})`
377
+ });
378
+ }
379
+ return findings.sort((left, right) => left.code.localeCompare(right.code));
380
+ };
381
+ /**
382
+ * Constructs the pinned data says nothing about for a target client. These are
383
+ * reported so "we did not check that" is never mistaken for "that works".
384
+ */
385
+ const unknownCoverage = (titles) => [...titles].filter((title) => !KNOWN_TITLES.has(title)).sort().map((title) => ({
386
+ code: "caniemail/unknown-coverage",
387
+ severity: "info",
388
+ message: `The pinned rules say nothing about ${title}, so no client claim is made about it. Verify it in a real client before relying on it.`,
389
+ origins: [],
390
+ provenance: `${COMPATIBILITY_PROVENANCE.rules} (caniemail data ${COMPATIBILITY_PROVENANCE.apiVersion}, updated ${COMPATIBILITY_PROVENANCE.lastUpdate})`
391
+ }));
392
+ /** A publication carrying one of these is refused; the message would arrive broken. */
393
+ const hasBlockingCompatibility = (findings) => findings.some((finding) => finding.severity === "error");
394
+ //#endregion
395
+ //#region src/email/assets.ts
396
+ /** Files a template may import, and what they are served as. */
397
+ const ASSET_CONTENT_TYPES = {
398
+ ".png": "image/png",
399
+ ".jpg": "image/jpeg",
400
+ ".jpeg": "image/jpeg",
401
+ ".gif": "image/gif",
402
+ ".webp": "image/webp",
403
+ ".avif": "image/avif",
404
+ ".svg": "image/svg+xml",
405
+ ".ico": "image/x-icon",
406
+ ".woff": "font/woff",
407
+ ".woff2": "font/woff2",
408
+ ".ttf": "font/ttf",
409
+ ".otf": "font/otf",
410
+ ".pdf": "application/pdf",
411
+ ".txt": "text/plain"
412
+ };
413
+ const extensionOf = (path) => {
414
+ const dot = path.lastIndexOf(".");
415
+ return dot < 0 ? "" : path.slice(dot).toLowerCase();
416
+ };
417
+ /** True when the compiler turns this import into a content-addressed asset. */
418
+ const isAssetPath = (path) => Object.hasOwn(ASSET_CONTENT_TYPES, extensionOf(path));
419
+ const hex = (buffer) => Array.from(new Uint8Array(buffer), (byte) => byte.toString(16).padStart(2, "0")).join("");
420
+ /** Address one file by its content. */
421
+ const assetEntry = async (path, bytes) => {
422
+ const extension = extensionOf(path);
423
+ const view = new Uint8Array(bytes.byteLength);
424
+ view.set(bytes);
425
+ const digest = hex(await crypto.subtle.digest("SHA-256", view));
426
+ return {
427
+ path,
428
+ digest,
429
+ bytes: bytes.byteLength,
430
+ contentType: ASSET_CONTENT_TYPES[extension] ?? "application/octet-stream",
431
+ fileName: `${digest}${extension}`
432
+ };
433
+ };
434
+ /**
435
+ * The URL an asset has under a base. The base is a build input: publication
436
+ * passes its hosted origin, and a local export passes whatever it will serve
437
+ * the exported files from.
438
+ */
439
+ const assetUrl = (entry, base) => `${base.replace(/\/+$/, "")}/${entry.fileName}`;
440
+ const EXTERNAL_IMAGE = /^https:\/\//i;
441
+ /** Record, but never fetch, a URL the template points at. */
442
+ const isExternalAsset = (reference) => EXTERNAL_IMAGE.test(reference);
443
+ /**
444
+ * Reject an asset base that would produce URLs a client will not load. The
445
+ * relative forms are the ones a page on disk resolves against its own
446
+ * directory, which is what a local export writes.
447
+ */
448
+ const checkAssetBase = (base) => /^(https:\/\/|\.{1,2}\/|\/)/i.test(base) ? [] : [{
449
+ code: "invalid-asset-base",
450
+ severity: "error",
451
+ message: `Asset base ${JSON.stringify(base)} must be an https URL, an absolute path, or a relative path for a local export.`,
452
+ origins: []
453
+ }];
454
+ //#endregion
455
+ //#region src/email/css-color.ts
456
+ const clamp = (value, low = 0, high = 1) => value < low ? low : value > high ? high : value;
457
+ const toGamma = (channel) => channel <= .0031308 ? 12.92 * channel : 1.055 * channel ** (1 / 2.4) - .055;
458
+ const toLinear = (channel) => channel <= .04045 ? channel / 12.92 : ((channel + .055) / 1.055) ** 2.4;
459
+ /** OKLab is the interpolation space Tailwind mixes in, so conversions run both ways. */
460
+ const oklabToRgb = (lightness, a, b, alpha) => {
461
+ const l = (lightness + .3963377774 * a + .2158037573 * b) ** 3;
462
+ const m = (lightness - .1055613458 * a - .0638541728 * b) ** 3;
463
+ const s = (lightness - .0894841775 * a - 1.291485548 * b) ** 3;
464
+ return {
465
+ r: toGamma(4.0767416621 * l - 3.3077115913 * m + .2309699292 * s),
466
+ g: toGamma(-1.2684380046 * l + 2.6097574011 * m - .3413193965 * s),
467
+ b: toGamma(-.0041960863 * l - .7034186147 * m + 1.707614701 * s),
468
+ a: alpha
469
+ };
470
+ };
471
+ const rgbToOklab = (color) => {
472
+ const r = toLinear(color.r);
473
+ const g = toLinear(color.g);
474
+ const b = toLinear(color.b);
475
+ const l = Math.cbrt(.4122214708 * r + .5363325363 * g + .0514459929 * b);
476
+ const m = Math.cbrt(.2119034982 * r + .6806995451 * g + .1073969566 * b);
477
+ const s = Math.cbrt(.0883024619 * r + .2817188376 * g + .6299787005 * b);
478
+ return {
479
+ L: .2104542553 * l + .793617785 * m - .0040720468 * s,
480
+ a: 1.9779984951 * l - 2.428592205 * m + .4505937099 * s,
481
+ b: .0259040371 * l + .7827717662 * m - .808675766 * s,
482
+ alpha: color.a
483
+ };
484
+ };
485
+ const hslToRgb = (hue, saturation, lightness, alpha) => {
486
+ const h = (hue % 360 + 360) % 360;
487
+ const c = (1 - Math.abs(2 * lightness - 1)) * saturation;
488
+ const x = c * (1 - Math.abs(h / 60 % 2 - 1));
489
+ const m = lightness - c / 2;
490
+ const [r, g, b] = [
491
+ [
492
+ c,
493
+ x,
494
+ 0
495
+ ],
496
+ [
497
+ x,
498
+ c,
499
+ 0
500
+ ],
501
+ [
502
+ 0,
503
+ c,
504
+ x
505
+ ],
506
+ [
507
+ 0,
508
+ x,
509
+ c
510
+ ],
511
+ [
512
+ x,
513
+ 0,
514
+ c
515
+ ],
516
+ [
517
+ c,
518
+ 0,
519
+ x
520
+ ]
521
+ ][Math.min(5, Math.floor(h / 60))];
522
+ return {
523
+ r: r + m,
524
+ g: g + m,
525
+ b: b + m,
526
+ a: alpha
527
+ };
528
+ };
529
+ /** The named colors an email template actually reaches for; anything else stays literal. */
530
+ const NAMED = {
531
+ transparent: "#00000000",
532
+ black: "#000000",
533
+ white: "#ffffff",
534
+ red: "#ff0000",
535
+ green: "#008000",
536
+ blue: "#0000ff",
537
+ gray: "#808080",
538
+ grey: "#808080",
539
+ silver: "#c0c0c0",
540
+ yellow: "#ffff00",
541
+ orange: "#ffa500",
542
+ purple: "#800080",
543
+ navy: "#000080",
544
+ teal: "#008080",
545
+ olive: "#808000",
546
+ maroon: "#800000",
547
+ lime: "#00ff00",
548
+ aqua: "#00ffff",
549
+ cyan: "#00ffff",
550
+ fuchsia: "#ff00ff",
551
+ magenta: "#ff00ff"
552
+ };
553
+ const number = (token, reference = 1) => {
554
+ const text = token.trim();
555
+ if (text === "none") return 0;
556
+ if (text.endsWith("%")) {
557
+ const value = Number.parseFloat(text.slice(0, -1));
558
+ return Number.isFinite(value) ? value / 100 * reference : void 0;
559
+ }
560
+ const value = Number.parseFloat(text);
561
+ return Number.isFinite(value) ? value : void 0;
562
+ };
563
+ const angle = (token) => {
564
+ const text = token.trim();
565
+ const value = Number.parseFloat(text);
566
+ if (!Number.isFinite(value)) return void 0;
567
+ if (text.endsWith("turn")) return value * 360;
568
+ if (text.endsWith("rad")) return value * 180 / Math.PI;
569
+ if (text.endsWith("grad")) return value * .9;
570
+ return value;
571
+ };
572
+ /** Split a function's arguments on top-level commas and `/`, keeping nested calls intact. */
573
+ const argumentTokens = (body) => {
574
+ const parts = [];
575
+ let alpha;
576
+ let depth = 0;
577
+ let current = "";
578
+ let afterSlash = false;
579
+ for (const character of body) {
580
+ if (character === "(") depth += 1;
581
+ if (character === ")") depth -= 1;
582
+ if (depth === 0 && (character === "," || character === " " || character === "/")) {
583
+ if (character === "/") {
584
+ if (current.trim() !== "") parts.push(current.trim());
585
+ current = "";
586
+ afterSlash = true;
587
+ continue;
588
+ }
589
+ if (current.trim() !== "") {
590
+ if (afterSlash) alpha = current.trim();
591
+ else parts.push(current.trim());
592
+ }
593
+ current = "";
594
+ continue;
595
+ }
596
+ current += character;
597
+ }
598
+ if (current.trim() !== "") {
599
+ if (afterSlash) alpha = current.trim();
600
+ else parts.push(current.trim());
601
+ }
602
+ return alpha === void 0 ? { parts } : {
603
+ parts,
604
+ alpha
605
+ };
606
+ };
607
+ /** Read one function call at the start of `value`, returning its name and body. */
608
+ const functionCall = (value) => {
609
+ const match = /^([a-zA-Z-]+)\(/.exec(value.trim());
610
+ if (match === null) return void 0;
611
+ const text = value.trim();
612
+ let depth = 0;
613
+ for (let index = match[0].length - 1; index < text.length; index++) if (text[index] === "(") depth += 1;
614
+ else if (text[index] === ")") {
615
+ depth -= 1;
616
+ if (depth === 0) return {
617
+ name: match[1].toLowerCase(),
618
+ body: text.slice(match[0].length, index)
619
+ };
620
+ }
621
+ };
622
+ /** Parse any supported color notation into extended sRGB. `undefined` means "leave it alone". */
623
+ const parseColor = (value) => {
624
+ const text = value.trim();
625
+ const named = NAMED[text.toLowerCase()];
626
+ if (named !== void 0) return parseColor(named);
627
+ if (text.startsWith("#")) {
628
+ const hex = text.slice(1);
629
+ const expand = (part) => Number.parseInt(part.repeat(2 / part.length), 16) / 255;
630
+ if (hex.length === 3 || hex.length === 4) return {
631
+ r: expand(hex[0]),
632
+ g: expand(hex[1]),
633
+ b: expand(hex[2]),
634
+ a: hex.length === 4 ? expand(hex[3]) : 1
635
+ };
636
+ if (hex.length === 6 || hex.length === 8) return {
637
+ r: Number.parseInt(hex.slice(0, 2), 16) / 255,
638
+ g: Number.parseInt(hex.slice(2, 4), 16) / 255,
639
+ b: Number.parseInt(hex.slice(4, 6), 16) / 255,
640
+ a: hex.length === 8 ? Number.parseInt(hex.slice(6, 8), 16) / 255 : 1
641
+ };
642
+ return;
643
+ }
644
+ const call = functionCall(text);
645
+ if (call === void 0) return void 0;
646
+ const { parts, alpha } = argumentTokens(call.body);
647
+ const opacity = alpha === void 0 ? 1 : number(alpha) ?? 1;
648
+ switch (call.name) {
649
+ case "rgb":
650
+ case "rgba": {
651
+ const [r, g, b, legacy] = parts;
652
+ if (r === void 0 || g === void 0 || b === void 0) return void 0;
653
+ const channel = (token) => {
654
+ const parsed = number(token, 255);
655
+ return parsed === void 0 ? void 0 : parsed / 255;
656
+ };
657
+ const [red, green, blue] = [
658
+ channel(r),
659
+ channel(g),
660
+ channel(b)
661
+ ];
662
+ if (red === void 0 || green === void 0 || blue === void 0) return void 0;
663
+ return {
664
+ r: red,
665
+ g: green,
666
+ b: blue,
667
+ a: legacy === void 0 ? opacity : number(legacy) ?? 1
668
+ };
669
+ }
670
+ case "hsl":
671
+ case "hsla": {
672
+ const [h, s, l, legacy] = parts;
673
+ if (h === void 0 || s === void 0 || l === void 0) return void 0;
674
+ const hue = angle(h);
675
+ const saturation = number(s);
676
+ const lightness = number(l);
677
+ if (hue === void 0 || saturation === void 0 || lightness === void 0) return void 0;
678
+ return hslToRgb(hue, saturation, lightness, legacy === void 0 ? opacity : number(legacy) ?? 1);
679
+ }
680
+ case "oklch": {
681
+ const [l, c, h] = parts;
682
+ if (l === void 0 || c === void 0 || h === void 0) return void 0;
683
+ const lightness = number(l);
684
+ const chroma = number(c, .4);
685
+ const hue = angle(h);
686
+ if (lightness === void 0 || chroma === void 0 || hue === void 0) return void 0;
687
+ const radians = hue * Math.PI / 180;
688
+ return oklabToRgb(lightness, chroma * Math.cos(radians), chroma * Math.sin(radians), opacity);
689
+ }
690
+ case "oklab": {
691
+ const [l, a, b] = parts;
692
+ if (l === void 0 || a === void 0 || b === void 0) return void 0;
693
+ const lightness = number(l);
694
+ const green = number(a, .4);
695
+ const blue = number(b, .4);
696
+ if (lightness === void 0 || green === void 0 || blue === void 0) return void 0;
697
+ return oklabToRgb(lightness, green, blue, opacity);
698
+ }
699
+ case "color-mix": return mixColors(call.body);
700
+ default: return;
701
+ }
702
+ };
703
+ /** `color-mix(in <space>, <color> <pct>?, <color> <pct>?)` — Tailwind's opacity modifier. */
704
+ const mixColors = (body) => {
705
+ const stops = body.split(",").map((part) => part.trim());
706
+ const [space, first, second] = stops;
707
+ if (space === void 0 || first === void 0 || second === void 0 || stops.length !== 3) return void 0;
708
+ const method = /^in\s+([a-z-]+)/i.exec(space)?.[1]?.toLowerCase();
709
+ if (method === void 0) return void 0;
710
+ const stop = (text) => {
711
+ const percentage = /\s([\d.]+)%$/.exec(text);
712
+ const color = parseColor(percentage === null ? text : text.slice(0, percentage.index));
713
+ if (color === void 0) return void 0;
714
+ return {
715
+ color,
716
+ weight: percentage === null ? void 0 : Number.parseFloat(percentage[1]) / 100
717
+ };
718
+ };
719
+ const left = stop(first);
720
+ const right = stop(second);
721
+ if (left === void 0 || right === void 0) return void 0;
722
+ const leftWeight = left.weight ?? (right.weight === void 0 ? .5 : 1 - right.weight);
723
+ const total = leftWeight + (right.weight ?? 1 - leftWeight);
724
+ if (total === 0) return void 0;
725
+ const p = leftWeight / total;
726
+ const alpha = left.color.a * p + right.color.a * (1 - p);
727
+ const mix = (l, r) => alpha === 0 ? 0 : (l * left.color.a * p + r * right.color.a * (1 - p)) / alpha;
728
+ if (method === "srgb") return {
729
+ r: mix(left.color.r, right.color.r),
730
+ g: mix(left.color.g, right.color.g),
731
+ b: mix(left.color.b, right.color.b),
732
+ a: alpha
733
+ };
734
+ const l = rgbToOklab(left.color);
735
+ const r = rgbToOklab(right.color);
736
+ const channel = (a, b) => alpha === 0 ? 0 : (a * left.color.a * p + b * right.color.a * (1 - p)) / alpha;
737
+ return oklabToRgb(channel(l.L, r.L), channel(l.a, r.a), channel(l.b, r.b), alpha);
738
+ };
739
+ const byte = (channel) => Math.round(clamp(channel) * 255).toString(16).padStart(2, "0");
740
+ /** sRGB hex, or `rgba()` when the color is not opaque. */
741
+ const formatColor = (color) => color.a >= 1 ? `#${byte(color.r)}${byte(color.g)}${byte(color.b)}` : `rgba(${Math.round(clamp(color.r) * 255)},${Math.round(clamp(color.g) * 255)},${Math.round(clamp(color.b) * 255)},${Math.round(clamp(color.a) * 1e3) / 1e3})`;
742
+ const MODERN_COLOR = /\b(oklch|oklab|color-mix|lab|lch)\(/i;
743
+ /** Rewrite every modern color function in a declaration value; other text is untouched. */
744
+ const downlevelColors = (value) => {
745
+ if (!MODERN_COLOR.test(value)) return value;
746
+ let result = "";
747
+ let rest = value;
748
+ while (rest.length > 0) {
749
+ const match = MODERN_COLOR.exec(rest);
750
+ if (match === null || match.index === void 0) {
751
+ result += rest;
752
+ break;
753
+ }
754
+ result += rest.slice(0, match.index);
755
+ const remainder = rest.slice(match.index);
756
+ const call = functionCall(remainder);
757
+ if (call === void 0) {
758
+ result += remainder;
759
+ break;
760
+ }
761
+ const consumed = remainder.indexOf("(") + call.body.length + 2;
762
+ const color = parseColor(remainder.slice(0, consumed));
763
+ result += color === void 0 ? remainder.slice(0, consumed) : formatColor(color);
764
+ rest = remainder.slice(consumed);
765
+ }
766
+ return result;
767
+ };
768
+ //#endregion
769
+ //#region src/email/css.ts
770
+ const UNLAYERED = Number.MAX_SAFE_INTEGER;
771
+ const CONDITIONAL_AT_RULES = /* @__PURE__ */ new Set([
772
+ "media",
773
+ "supports",
774
+ "container"
775
+ ]);
776
+ const HEAD_AT_RULES = /* @__PURE__ */ new Set([
777
+ "font-face",
778
+ "page",
779
+ "counter-style",
780
+ "keyframes"
781
+ ]);
782
+ const ROOT_SELECTORS = /* @__PURE__ */ new Set([
783
+ ":root",
784
+ ":host",
785
+ "html",
786
+ "*",
787
+ ":where(:root)"
788
+ ]);
789
+ const text = (node) => node === null || node === void 0 ? "" : generate(node);
790
+ /** The CSS specificity triple for one selector, ignoring the parts email clients drop. */
791
+ const specificityOf = (selector) => {
792
+ let id = 0;
793
+ let cls = 0;
794
+ let type = 0;
795
+ const visit = (node) => {
796
+ switch (node.type) {
797
+ case "IdSelector":
798
+ id += 1;
799
+ break;
800
+ case "ClassSelector":
801
+ case "AttributeSelector":
802
+ cls += 1;
803
+ break;
804
+ case "PseudoClassSelector":
805
+ if (node.name !== "where") cls += 1;
806
+ break;
807
+ case "TypeSelector":
808
+ if (node.name !== "*") type += 1;
809
+ break;
810
+ case "PseudoElementSelector": type += 1;
811
+ }
812
+ if ("children" in node && node.children !== null && node.children !== void 0) for (const child of node.children) visit(child);
813
+ };
814
+ visit(selector);
815
+ return [
816
+ id,
817
+ cls,
818
+ type
819
+ ];
820
+ };
821
+ const hasPseudo = (selector) => {
822
+ let found = false;
823
+ const visit = (node) => {
824
+ if (node.type === "PseudoClassSelector" || node.type === "PseudoElementSelector") found = true;
825
+ if ("children" in node && node.children !== null && node.children !== void 0) for (const child of node.children) visit(child);
826
+ };
827
+ visit(selector);
828
+ return found;
829
+ };
830
+ const COMBINATORS = {
831
+ " ": "descendant",
832
+ ">": "child",
833
+ "+": "adjacent",
834
+ "~": "sibling"
835
+ };
836
+ /** Compile a selector into the plain-data matcher the render lane uses. */
837
+ const compileSelector = (selector) => {
838
+ let ast;
839
+ try {
840
+ ast = parse$1(selector, {
841
+ context: "selector",
842
+ positions: false
843
+ });
844
+ } catch {
845
+ return;
846
+ }
847
+ if (ast.type !== "Selector" || ast.children === null) return void 0;
848
+ const parts = [];
849
+ let tag;
850
+ let id;
851
+ let classes = [];
852
+ let attributes = [];
853
+ let opaque = false;
854
+ const flush = (after) => {
855
+ parts.push({
856
+ compound: {
857
+ tag,
858
+ id,
859
+ classes,
860
+ attributes,
861
+ opaque
862
+ },
863
+ ...after === void 0 ? {} : { after }
864
+ });
865
+ tag = void 0;
866
+ id = void 0;
867
+ classes = [];
868
+ attributes = [];
869
+ opaque = false;
870
+ };
871
+ for (const node of ast.children) switch (node.type) {
872
+ case "TypeSelector":
873
+ if (node.name !== "*") tag = node.name.toLowerCase();
874
+ break;
875
+ case "IdSelector":
876
+ id = node.name;
877
+ break;
878
+ case "ClassSelector":
879
+ classes.push(ident.decode(node.name));
880
+ break;
881
+ case "AttributeSelector":
882
+ attributes.push({
883
+ name: node.name.name,
884
+ operator: node.matcher ?? void 0,
885
+ value: node.value === null || node.value === void 0 ? void 0 : node.value.type === "String" ? node.value.value : node.value.name
886
+ });
887
+ break;
888
+ case "Combinator":
889
+ flush(COMBINATORS[node.name.trim() === "" ? " " : node.name] ?? "descendant");
890
+ break;
891
+ default: opaque = true;
892
+ }
893
+ flush();
894
+ return { parts };
895
+ };
896
+ /** Substitute a nested rule's `&` against its parent selector. */
897
+ const nestSelector = (parent, child) => child.includes("&") ? child.replaceAll("&", parent) : `${parent} ${child}`;
898
+ const selectorFacts = /* @__PURE__ */ new Map();
899
+ /** Everything a rule needs from its selector, computed once per distinct string. */
900
+ const factsFor = (selector) => {
901
+ const cached = selectorFacts.get(selector);
902
+ if (cached !== void 0) return cached;
903
+ let facts;
904
+ try {
905
+ const node = parse$1(selector, {
906
+ context: "selector",
907
+ positions: false
908
+ });
909
+ const classes = /* @__PURE__ */ new Set();
910
+ walk(node, {
911
+ visit: "ClassSelector",
912
+ enter: (part) => {
913
+ classes.add(ident.decode(part.name));
914
+ }
915
+ });
916
+ facts = {
917
+ classes: [...classes],
918
+ specificity: specificityOf(node),
919
+ pseudo: hasPseudo(node),
920
+ matcher: compileSelector(selector)
921
+ };
922
+ } catch {
923
+ facts = {
924
+ classes: [],
925
+ specificity: [
926
+ 0,
927
+ 0,
928
+ 0
929
+ ],
930
+ pseudo: true,
931
+ matcher: void 0
932
+ };
933
+ }
934
+ selectorFacts.set(selector, facts);
935
+ return facts;
936
+ };
937
+ /** Parse one stylesheet into rules, keeping layer, order and conditions. */
938
+ const parseStylesheet = (source, options = {}) => {
939
+ const rules = [];
940
+ const headAtRules = [];
941
+ const variables = {};
942
+ const conditionalVariables = /* @__PURE__ */ new Set();
943
+ const diagnostics = [];
944
+ const layers = /* @__PURE__ */ new Map();
945
+ let order = options.startOrder ?? 0;
946
+ let ast;
947
+ try {
948
+ ast = parse$1(source, {
949
+ parseValue: false,
950
+ parseCustomProperty: false,
951
+ positions: false
952
+ });
953
+ } catch (cause) {
954
+ return {
955
+ rules: [],
956
+ headAtRules: [],
957
+ variables: {},
958
+ diagnostics: [{
959
+ code: "css-parse-error",
960
+ severity: "error",
961
+ message: `${options.origin ?? "stylesheet"} could not be parsed: ${String(cause)}`,
962
+ origins: []
963
+ }]
964
+ };
965
+ }
966
+ const declarationsOf = (block) => {
967
+ const output = [];
968
+ if (block === null || block.type !== "Block" || block.children === null) return output;
969
+ for (const child of block.children) {
970
+ if (child.type !== "Declaration") continue;
971
+ output.push({
972
+ property: child.property,
973
+ value: downlevelColors(text(child.value).trim().replace(/[\t\n\r\f]/g, " ")),
974
+ important: child.important === true
975
+ });
976
+ }
977
+ return output;
978
+ };
979
+ const emit = (selector, context, declarations) => {
980
+ if (declarations.length === 0) return;
981
+ const facts = factsFor(selector);
982
+ if (ROOT_SELECTORS.has(selector.trim())) for (const declaration of declarations) {
983
+ if (!declaration.property.startsWith("--")) continue;
984
+ if (context.conditions.length === 0) variables[declaration.property] = declaration.value;
985
+ else conditionalVariables.add(declaration.property);
986
+ }
987
+ rules.push({
988
+ selector,
989
+ classes: facts.classes,
990
+ specificity: facts.specificity,
991
+ declarations,
992
+ order: order++,
993
+ layer: context.layer,
994
+ conditions: context.conditions,
995
+ inlinable: context.conditions.length === 0 && !facts.pseudo,
996
+ matcher: facts.matcher
997
+ });
998
+ };
999
+ /**
1000
+ * Declarations directly in a block belong to the enclosing selector, whether
1001
+ * that block is the rule's own or a `@media` nested inside it — which is
1002
+ * exactly the shape Tailwind v4 emits for a responsive utility.
1003
+ */
1004
+ const walkBlock = (block, context) => {
1005
+ if (block === null || block.type !== "Block" || block.children === null) return;
1006
+ const declarations = declarationsOf(block);
1007
+ if (declarations.length > 0 && context.selector !== void 0) emit(context.selector, context, declarations);
1008
+ for (const child of block.children) if (child.type !== "Declaration") visitNode(child, context);
1009
+ };
1010
+ const visitNode = (node, context) => {
1011
+ if (node.type === "Rule") {
1012
+ const prelude = node.prelude;
1013
+ const selectors = prelude.type === "SelectorList" && prelude.children !== null ? [...prelude.children] : [prelude];
1014
+ for (const selector of selectors) {
1015
+ const own = text(selector).trim();
1016
+ if (own === "") continue;
1017
+ walkBlock(node.block, {
1018
+ ...context,
1019
+ selector: context.selector === void 0 ? own : nestSelector(context.selector, own)
1020
+ });
1021
+ }
1022
+ return;
1023
+ }
1024
+ if (node.type !== "Atrule") return;
1025
+ const name = node.name.toLowerCase();
1026
+ if (name === "layer") {
1027
+ const prelude = text(node.prelude).trim();
1028
+ if (node.block === null) {
1029
+ for (const declared of prelude.split(",").map((part) => part.trim())) if (declared !== "" && !layers.has(declared)) layers.set(declared, layers.size);
1030
+ return;
1031
+ }
1032
+ const named = prelude.split(",")[0]?.trim() ?? "";
1033
+ if (named !== "" && !layers.has(named)) layers.set(named, layers.size);
1034
+ walkBlock(node.block, {
1035
+ ...context,
1036
+ layer: layers.get(named) ?? context.layer
1037
+ });
1038
+ return;
1039
+ }
1040
+ if (name === "theme" || name === "scope") {
1041
+ for (const declaration of declarationsOf(node.block)) if (declaration.property.startsWith("--")) variables[declaration.property] = declaration.value;
1042
+ for (const child of node.block?.children ?? []) if (child.type !== "Declaration") visitNode(child, context);
1043
+ return;
1044
+ }
1045
+ if (name === "property") {
1046
+ const initial = declarationsOf(node.block).find((declaration) => declaration.property === "initial-value");
1047
+ const property = text(node.prelude).trim();
1048
+ if (initial !== void 0 && property.startsWith("--") && !(property in variables)) variables[property] = initial.value;
1049
+ return;
1050
+ }
1051
+ if (CONDITIONAL_AT_RULES.has(name)) {
1052
+ walkBlock(node.block, {
1053
+ ...context,
1054
+ conditions: [...context.conditions, `@${name} ${text(node.prelude).trim()}`]
1055
+ });
1056
+ return;
1057
+ }
1058
+ if (HEAD_AT_RULES.has(name)) {
1059
+ headAtRules.push(generate(node));
1060
+ return;
1061
+ }
1062
+ if (name === "import") {
1063
+ diagnostics.push({
1064
+ code: "css-import-unresolved",
1065
+ severity: "error",
1066
+ message: `${options.origin ?? "stylesheet"} uses @import ${text(node.prelude).trim()}; import the stylesheet from the template module instead so the compiler can resolve it.`,
1067
+ origins: []
1068
+ });
1069
+ return;
1070
+ }
1071
+ if (name === "charset" || name === "namespace") return;
1072
+ diagnostics.push({
1073
+ code: "css-unsupported-at-rule",
1074
+ severity: "warning",
1075
+ message: `@${name} is not applied to email output; remove it or move the declarations into a class rule.`,
1076
+ origins: []
1077
+ });
1078
+ };
1079
+ if (ast.type === "StyleSheet" && ast.children !== null) for (const child of ast.children) visitNode(child, {
1080
+ conditions: [],
1081
+ layer: UNLAYERED
1082
+ });
1083
+ for (const property of conditionalVariables) if (property in variables) diagnostics.push({
1084
+ code: "css-conditional-variable",
1085
+ severity: "warning",
1086
+ message: `${property} is redefined inside a conditional at-rule. Inlined declarations take the unconditional value; keep the override on a class rule so the retained head rule can apply it.`,
1087
+ origins: []
1088
+ });
1089
+ return {
1090
+ rules,
1091
+ headAtRules,
1092
+ variables,
1093
+ diagnostics
1094
+ };
1095
+ };
1096
+ //#endregion
1097
+ //#region src/email/tailwind-stylesheets.gen.ts
1098
+ /** The exact Tailwind release the compiler runs, recorded in every build manifest. */
1099
+ const TAILWIND_VERSION = "4.3.3";
1100
+ //#endregion
1101
+ //#region src/email/tailwind.ts
1102
+ const STYLESHEETS = {
1103
+ tailwindcss: `@layer theme, base, components, utilities;\n@import "tailwindcss/theme.css" layer(theme);\n@import "tailwindcss/utilities.css" layer(utilities);`,
1104
+ "tailwindcss/theme.css": "@theme default {\n --font-sans:\n -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', 'Noto Sans', Arial,\n sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji';\n --font-serif: ui-serif, Georgia, Cambria, 'Times New Roman', Times, serif;\n --font-mono:\n ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New',\n monospace;\n\n --color-red-50: oklch(97.1% 0.013 17.38);\n --color-red-100: oklch(93.6% 0.032 17.717);\n --color-red-200: oklch(88.5% 0.062 18.334);\n --color-red-300: oklch(80.8% 0.114 19.571);\n --color-red-400: oklch(70.4% 0.191 22.216);\n --color-red-500: oklch(63.7% 0.237 25.331);\n --color-red-600: oklch(57.7% 0.245 27.325);\n --color-red-700: oklch(50.5% 0.213 27.518);\n --color-red-800: oklch(44.4% 0.177 26.899);\n --color-red-900: oklch(39.6% 0.141 25.723);\n --color-red-950: oklch(25.8% 0.092 26.042);\n\n --color-orange-50: oklch(98% 0.016 73.684);\n --color-orange-100: oklch(95.4% 0.038 75.164);\n --color-orange-200: oklch(90.1% 0.076 70.697);\n --color-orange-300: oklch(83.7% 0.128 66.29);\n --color-orange-400: oklch(75% 0.183 55.934);\n --color-orange-500: oklch(70.5% 0.213 47.604);\n --color-orange-600: oklch(64.6% 0.222 41.116);\n --color-orange-700: oklch(55.3% 0.195 38.402);\n --color-orange-800: oklch(47% 0.157 37.304);\n --color-orange-900: oklch(40.8% 0.123 38.172);\n --color-orange-950: oklch(26.6% 0.079 36.259);\n\n --color-amber-50: oklch(98.7% 0.022 95.277);\n --color-amber-100: oklch(96.2% 0.059 95.617);\n --color-amber-200: oklch(92.4% 0.12 95.746);\n --color-amber-300: oklch(87.9% 0.169 91.605);\n --color-amber-400: oklch(82.8% 0.189 84.429);\n --color-amber-500: oklch(76.9% 0.188 70.08);\n --color-amber-600: oklch(66.6% 0.179 58.318);\n --color-amber-700: oklch(55.5% 0.163 48.998);\n --color-amber-800: oklch(47.3% 0.137 46.201);\n --color-amber-900: oklch(41.4% 0.112 45.904);\n --color-amber-950: oklch(27.9% 0.077 45.635);\n\n --color-yellow-50: oklch(98.7% 0.026 102.212);\n --color-yellow-100: oklch(97.3% 0.071 103.193);\n --color-yellow-200: oklch(94.5% 0.129 101.54);\n --color-yellow-300: oklch(90.5% 0.182 98.111);\n --color-yellow-400: oklch(85.2% 0.199 91.936);\n --color-yellow-500: oklch(79.5% 0.184 86.047);\n --color-yellow-600: oklch(68.1% 0.162 75.834);\n --color-yellow-700: oklch(55.4% 0.135 66.442);\n --color-yellow-800: oklch(47.6% 0.114 61.907);\n --color-yellow-900: oklch(42.1% 0.095 57.708);\n --color-yellow-950: oklch(28.6% 0.066 53.813);\n\n --color-lime-50: oklch(98.6% 0.031 120.757);\n --color-lime-100: oklch(96.7% 0.067 122.328);\n --color-lime-200: oklch(93.8% 0.127 124.321);\n --color-lime-300: oklch(89.7% 0.196 126.665);\n --color-lime-400: oklch(84.1% 0.238 128.85);\n --color-lime-500: oklch(76.8% 0.233 130.85);\n --color-lime-600: oklch(64.8% 0.2 131.684);\n --color-lime-700: oklch(53.2% 0.157 131.589);\n --color-lime-800: oklch(45.3% 0.124 130.933);\n --color-lime-900: oklch(40.5% 0.101 131.063);\n --color-lime-950: oklch(27.4% 0.072 132.109);\n\n --color-green-50: oklch(98.2% 0.018 155.826);\n --color-green-100: oklch(96.2% 0.044 156.743);\n --color-green-200: oklch(92.5% 0.084 155.995);\n --color-green-300: oklch(87.1% 0.15 154.449);\n --color-green-400: oklch(79.2% 0.209 151.711);\n --color-green-500: oklch(72.3% 0.219 149.579);\n --color-green-600: oklch(62.7% 0.194 149.214);\n --color-green-700: oklch(52.7% 0.154 150.069);\n --color-green-800: oklch(44.8% 0.119 151.328);\n --color-green-900: oklch(39.3% 0.095 152.535);\n --color-green-950: oklch(26.6% 0.065 152.934);\n\n --color-emerald-50: oklch(97.9% 0.021 166.113);\n --color-emerald-100: oklch(95% 0.052 163.051);\n --color-emerald-200: oklch(90.5% 0.093 164.15);\n --color-emerald-300: oklch(84.5% 0.143 164.978);\n --color-emerald-400: oklch(76.5% 0.177 163.223);\n --color-emerald-500: oklch(69.6% 0.17 162.48);\n --color-emerald-600: oklch(59.6% 0.145 163.225);\n --color-emerald-700: oklch(50.8% 0.118 165.612);\n --color-emerald-800: oklch(43.2% 0.095 166.913);\n --color-emerald-900: oklch(37.8% 0.077 168.94);\n --color-emerald-950: oklch(26.2% 0.051 172.552);\n\n --color-teal-50: oklch(98.4% 0.014 180.72);\n --color-teal-100: oklch(95.3% 0.051 180.801);\n --color-teal-200: oklch(91% 0.096 180.426);\n --color-teal-300: oklch(85.5% 0.138 181.071);\n --color-teal-400: oklch(77.7% 0.152 181.912);\n --color-teal-500: oklch(70.4% 0.14 182.503);\n --color-teal-600: oklch(60% 0.118 184.704);\n --color-teal-700: oklch(51.1% 0.096 186.391);\n --color-teal-800: oklch(43.7% 0.078 188.216);\n --color-teal-900: oklch(38.6% 0.063 188.416);\n --color-teal-950: oklch(27.7% 0.046 192.524);\n\n --color-cyan-50: oklch(98.4% 0.019 200.873);\n --color-cyan-100: oklch(95.6% 0.045 203.388);\n --color-cyan-200: oklch(91.7% 0.08 205.041);\n --color-cyan-300: oklch(86.5% 0.127 207.078);\n --color-cyan-400: oklch(78.9% 0.154 211.53);\n --color-cyan-500: oklch(71.5% 0.143 215.221);\n --color-cyan-600: oklch(60.9% 0.126 221.723);\n --color-cyan-700: oklch(52% 0.105 223.128);\n --color-cyan-800: oklch(45% 0.085 224.283);\n --color-cyan-900: oklch(39.8% 0.07 227.392);\n --color-cyan-950: oklch(30.2% 0.056 229.695);\n\n --color-sky-50: oklch(97.7% 0.013 236.62);\n --color-sky-100: oklch(95.1% 0.026 236.824);\n --color-sky-200: oklch(90.1% 0.058 230.902);\n --color-sky-300: oklch(82.8% 0.111 230.318);\n --color-sky-400: oklch(74.6% 0.16 232.661);\n --color-sky-500: oklch(68.5% 0.169 237.323);\n --color-sky-600: oklch(58.8% 0.158 241.966);\n --color-sky-700: oklch(50% 0.134 242.749);\n --color-sky-800: oklch(44.3% 0.11 240.79);\n --color-sky-900: oklch(39.1% 0.09 240.876);\n --color-sky-950: oklch(29.3% 0.066 243.157);\n\n --color-blue-50: oklch(97% 0.014 254.604);\n --color-blue-100: oklch(93.2% 0.032 255.585);\n --color-blue-200: oklch(88.2% 0.059 254.128);\n --color-blue-300: oklch(80.9% 0.105 251.813);\n --color-blue-400: oklch(70.7% 0.165 254.624);\n --color-blue-500: oklch(62.3% 0.214 259.815);\n --color-blue-600: oklch(54.6% 0.245 262.881);\n --color-blue-700: oklch(48.8% 0.243 264.376);\n --color-blue-800: oklch(42.4% 0.199 265.638);\n --color-blue-900: oklch(37.9% 0.146 265.522);\n --color-blue-950: oklch(28.2% 0.091 267.935);\n\n --color-indigo-50: oklch(96.2% 0.018 272.314);\n --color-indigo-100: oklch(93% 0.034 272.788);\n --color-indigo-200: oklch(87% 0.065 274.039);\n --color-indigo-300: oklch(78.5% 0.115 274.713);\n --color-indigo-400: oklch(67.3% 0.182 276.935);\n --color-indigo-500: oklch(58.5% 0.233 277.117);\n --color-indigo-600: oklch(51.1% 0.262 276.966);\n --color-indigo-700: oklch(45.7% 0.24 277.023);\n --color-indigo-800: oklch(39.8% 0.195 277.366);\n --color-indigo-900: oklch(35.9% 0.144 278.697);\n --color-indigo-950: oklch(25.7% 0.09 281.288);\n\n --color-violet-50: oklch(96.9% 0.016 293.756);\n --color-violet-100: oklch(94.3% 0.029 294.588);\n --color-violet-200: oklch(89.4% 0.057 293.283);\n --color-violet-300: oklch(81.1% 0.111 293.571);\n --color-violet-400: oklch(70.2% 0.183 293.541);\n --color-violet-500: oklch(60.6% 0.25 292.717);\n --color-violet-600: oklch(54.1% 0.281 293.009);\n --color-violet-700: oklch(49.1% 0.27 292.581);\n --color-violet-800: oklch(43.2% 0.232 292.759);\n --color-violet-900: oklch(38% 0.189 293.745);\n --color-violet-950: oklch(28.3% 0.141 291.089);\n\n --color-purple-50: oklch(97.7% 0.014 308.299);\n --color-purple-100: oklch(94.6% 0.033 307.174);\n --color-purple-200: oklch(90.2% 0.063 306.703);\n --color-purple-300: oklch(82.7% 0.119 306.383);\n --color-purple-400: oklch(71.4% 0.203 305.504);\n --color-purple-500: oklch(62.7% 0.265 303.9);\n --color-purple-600: oklch(55.8% 0.288 302.321);\n --color-purple-700: oklch(49.6% 0.265 301.924);\n --color-purple-800: oklch(43.8% 0.218 303.724);\n --color-purple-900: oklch(38.1% 0.176 304.987);\n --color-purple-950: oklch(29.1% 0.149 302.717);\n\n --color-fuchsia-50: oklch(97.7% 0.017 320.058);\n --color-fuchsia-100: oklch(95.2% 0.037 318.852);\n --color-fuchsia-200: oklch(90.3% 0.076 319.62);\n --color-fuchsia-300: oklch(83.3% 0.145 321.434);\n --color-fuchsia-400: oklch(74% 0.238 322.16);\n --color-fuchsia-500: oklch(66.7% 0.295 322.15);\n --color-fuchsia-600: oklch(59.1% 0.293 322.896);\n --color-fuchsia-700: oklch(51.8% 0.253 323.949);\n --color-fuchsia-800: oklch(45.2% 0.211 324.591);\n --color-fuchsia-900: oklch(40.1% 0.17 325.612);\n --color-fuchsia-950: oklch(29.3% 0.136 325.661);\n\n --color-pink-50: oklch(97.1% 0.014 343.198);\n --color-pink-100: oklch(94.8% 0.028 342.258);\n --color-pink-200: oklch(89.9% 0.061 343.231);\n --color-pink-300: oklch(82.3% 0.12 346.018);\n --color-pink-400: oklch(71.8% 0.202 349.761);\n --color-pink-500: oklch(65.6% 0.241 354.308);\n --color-pink-600: oklch(59.2% 0.249 0.584);\n --color-pink-700: oklch(52.5% 0.223 3.958);\n --color-pink-800: oklch(45.9% 0.187 3.815);\n --color-pink-900: oklch(40.8% 0.153 2.432);\n --color-pink-950: oklch(28.4% 0.109 3.907);\n\n --color-rose-50: oklch(96.9% 0.015 12.422);\n --color-rose-100: oklch(94.1% 0.03 12.58);\n --color-rose-200: oklch(89.2% 0.058 10.001);\n --color-rose-300: oklch(81% 0.117 11.638);\n --color-rose-400: oklch(71.2% 0.194 13.428);\n --color-rose-500: oklch(64.5% 0.246 16.439);\n --color-rose-600: oklch(58.6% 0.253 17.585);\n --color-rose-700: oklch(51.4% 0.222 16.935);\n --color-rose-800: oklch(45.5% 0.188 13.697);\n --color-rose-900: oklch(41% 0.159 10.272);\n --color-rose-950: oklch(27.1% 0.105 12.094);\n\n --color-slate-50: oklch(98.4% 0.003 247.858);\n --color-slate-100: oklch(96.8% 0.007 247.896);\n --color-slate-200: oklch(92.9% 0.013 255.508);\n --color-slate-300: oklch(86.9% 0.022 252.894);\n --color-slate-400: oklch(70.4% 0.04 256.788);\n --color-slate-500: oklch(55.4% 0.046 257.417);\n --color-slate-600: oklch(44.6% 0.043 257.281);\n --color-slate-700: oklch(37.2% 0.044 257.287);\n --color-slate-800: oklch(27.9% 0.041 260.031);\n --color-slate-900: oklch(20.8% 0.042 265.755);\n --color-slate-950: oklch(12.9% 0.042 264.695);\n\n --color-gray-50: oklch(98.5% 0.002 247.839);\n --color-gray-100: oklch(96.7% 0.003 264.542);\n --color-gray-200: oklch(92.8% 0.006 264.531);\n --color-gray-300: oklch(87.2% 0.01 258.338);\n --color-gray-400: oklch(70.7% 0.022 261.325);\n --color-gray-500: oklch(55.1% 0.027 264.364);\n --color-gray-600: oklch(44.6% 0.03 256.802);\n --color-gray-700: oklch(37.3% 0.034 259.733);\n --color-gray-800: oklch(27.8% 0.033 256.848);\n --color-gray-900: oklch(21% 0.034 264.665);\n --color-gray-950: oklch(13% 0.028 261.692);\n\n --color-zinc-50: oklch(98.5% 0 none);\n --color-zinc-100: oklch(96.7% 0.001 286.375);\n --color-zinc-200: oklch(92% 0.004 286.32);\n --color-zinc-300: oklch(87.1% 0.006 286.286);\n --color-zinc-400: oklch(70.5% 0.015 286.067);\n --color-zinc-500: oklch(55.2% 0.016 285.938);\n --color-zinc-600: oklch(44.2% 0.017 285.786);\n --color-zinc-700: oklch(37% 0.013 285.805);\n --color-zinc-800: oklch(27.4% 0.006 286.033);\n --color-zinc-900: oklch(21% 0.006 285.885);\n --color-zinc-950: oklch(14.1% 0.005 285.823);\n\n --color-neutral-50: oklch(98.5% 0 none);\n --color-neutral-100: oklch(97% 0 none);\n --color-neutral-200: oklch(92.2% 0 none);\n --color-neutral-300: oklch(87% 0 none);\n --color-neutral-400: oklch(70.8% 0 none);\n --color-neutral-500: oklch(55.6% 0 none);\n --color-neutral-600: oklch(43.9% 0 none);\n --color-neutral-700: oklch(37.1% 0 none);\n --color-neutral-800: oklch(26.9% 0 none);\n --color-neutral-900: oklch(20.5% 0 none);\n --color-neutral-950: oklch(14.5% 0 none);\n\n --color-stone-50: oklch(98.5% 0.001 106.423);\n --color-stone-100: oklch(97% 0.001 106.424);\n --color-stone-200: oklch(92.3% 0.003 48.717);\n --color-stone-300: oklch(86.9% 0.005 56.366);\n --color-stone-400: oklch(70.9% 0.01 56.259);\n --color-stone-500: oklch(55.3% 0.013 58.071);\n --color-stone-600: oklch(44.4% 0.011 73.639);\n --color-stone-700: oklch(37.4% 0.01 67.558);\n --color-stone-800: oklch(26.8% 0.007 34.298);\n --color-stone-900: oklch(21.6% 0.006 56.043);\n --color-stone-950: oklch(14.7% 0.004 49.25);\n\n --color-mauve-50: oklch(98.5% 0 none);\n --color-mauve-100: oklch(96% 0.003 325.6);\n --color-mauve-200: oklch(92.2% 0.005 325.62);\n --color-mauve-300: oklch(86.5% 0.012 325.68);\n --color-mauve-400: oklch(71.1% 0.019 323.02);\n --color-mauve-500: oklch(54.2% 0.034 322.5);\n --color-mauve-600: oklch(43.5% 0.029 321.78);\n --color-mauve-700: oklch(36.4% 0.029 323.89);\n --color-mauve-800: oklch(26.3% 0.024 320.12);\n --color-mauve-900: oklch(21.2% 0.019 322.12);\n --color-mauve-950: oklch(14.5% 0.008 326);\n\n --color-olive-50: oklch(98.8% 0.003 106.5);\n --color-olive-100: oklch(96.6% 0.005 106.5);\n --color-olive-200: oklch(93% 0.007 106.5);\n --color-olive-300: oklch(88% 0.011 106.6);\n --color-olive-400: oklch(73.7% 0.021 106.9);\n --color-olive-500: oklch(58% 0.031 107.3);\n --color-olive-600: oklch(46.6% 0.025 107.3);\n --color-olive-700: oklch(39.4% 0.023 107.4);\n --color-olive-800: oklch(28.6% 0.016 107.4);\n --color-olive-900: oklch(22.8% 0.013 107.4);\n --color-olive-950: oklch(15.3% 0.006 107.1);\n\n --color-mist-50: oklch(98.7% 0.002 197.1);\n --color-mist-100: oklch(96.3% 0.002 197.1);\n --color-mist-200: oklch(92.5% 0.005 214.3);\n --color-mist-300: oklch(87.2% 0.007 219.6);\n --color-mist-400: oklch(72.3% 0.014 214.4);\n --color-mist-500: oklch(56% 0.021 213.5);\n --color-mist-600: oklch(45% 0.017 213.2);\n --color-mist-700: oklch(37.8% 0.015 216);\n --color-mist-800: oklch(27.5% 0.011 216.9);\n --color-mist-900: oklch(21.8% 0.008 223.9);\n --color-mist-950: oklch(14.8% 0.004 228.8);\n\n --color-taupe-50: oklch(98.6% 0.002 67.8);\n --color-taupe-100: oklch(96% 0.002 17.2);\n --color-taupe-200: oklch(92.2% 0.005 34.3);\n --color-taupe-300: oklch(86.8% 0.007 39.5);\n --color-taupe-400: oklch(71.4% 0.014 41.2);\n --color-taupe-500: oklch(54.7% 0.021 43.1);\n --color-taupe-600: oklch(43.8% 0.017 39.3);\n --color-taupe-700: oklch(36.7% 0.016 35.7);\n --color-taupe-800: oklch(26.8% 0.011 36.5);\n --color-taupe-900: oklch(21.4% 0.009 43.1);\n --color-taupe-950: oklch(14.7% 0.004 49.3);\n\n --color-black: #000;\n --color-white: #fff;\n\n --spacing: 0.25rem;\n\n --breakpoint-sm: 40rem;\n --breakpoint-md: 48rem;\n --breakpoint-lg: 64rem;\n --breakpoint-xl: 80rem;\n --breakpoint-2xl: 96rem;\n\n --container-3xs: 16rem;\n --container-2xs: 18rem;\n --container-xs: 20rem;\n --container-sm: 24rem;\n --container-md: 28rem;\n --container-lg: 32rem;\n --container-xl: 36rem;\n --container-2xl: 42rem;\n --container-3xl: 48rem;\n --container-4xl: 56rem;\n --container-5xl: 64rem;\n --container-6xl: 72rem;\n --container-7xl: 80rem;\n\n --text-xs: 0.75rem;\n --text-xs--line-height: calc(1 / 0.75);\n --text-sm: 0.875rem;\n --text-sm--line-height: calc(1.25 / 0.875);\n --text-base: 1rem;\n --text-base--line-height: calc(1.5 / 1);\n --text-lg: 1.125rem;\n --text-lg--line-height: calc(1.75 / 1.125);\n --text-xl: 1.25rem;\n --text-xl--line-height: calc(1.75 / 1.25);\n --text-2xl: 1.5rem;\n --text-2xl--line-height: calc(2 / 1.5);\n --text-3xl: 1.875rem;\n --text-3xl--line-height: calc(2.25 / 1.875);\n --text-4xl: 2.25rem;\n --text-4xl--line-height: calc(2.5 / 2.25);\n --text-5xl: 3rem;\n --text-5xl--line-height: 1;\n --text-6xl: 3.75rem;\n --text-6xl--line-height: 1;\n --text-7xl: 4.5rem;\n --text-7xl--line-height: 1;\n --text-8xl: 6rem;\n --text-8xl--line-height: 1;\n --text-9xl: 8rem;\n --text-9xl--line-height: 1;\n\n --font-weight-thin: 100;\n --font-weight-extralight: 200;\n --font-weight-light: 300;\n --font-weight-normal: 400;\n --font-weight-medium: 500;\n --font-weight-semibold: 600;\n --font-weight-bold: 700;\n --font-weight-extrabold: 800;\n --font-weight-black: 900;\n\n --tracking-tighter: -0.05em;\n --tracking-tight: -0.025em;\n --tracking-normal: 0em;\n --tracking-wide: 0.025em;\n --tracking-wider: 0.05em;\n --tracking-widest: 0.1em;\n\n --leading-tight: 1.25;\n --leading-snug: 1.375;\n --leading-normal: 1.5;\n --leading-relaxed: 1.625;\n --leading-loose: 2;\n\n --radius-xs: 0.125rem;\n --radius-sm: 0.25rem;\n --radius-md: 0.375rem;\n --radius-lg: 0.5rem;\n --radius-xl: 0.75rem;\n --radius-2xl: 1rem;\n --radius-3xl: 1.5rem;\n --radius-4xl: 2rem;\n\n --shadow-2xs: 0 1px rgb(0 0 0 / 0.05);\n --shadow-xs: 0 1px 2px 0 rgb(0 0 0 / 0.05);\n --shadow-sm: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);\n --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);\n --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);\n --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);\n --shadow-2xl: 0 25px 50px -12px rgb(0 0 0 / 0.25);\n\n --inset-shadow-2xs: inset 0 1px rgb(0 0 0 / 0.05);\n --inset-shadow-xs: inset 0 1px 1px rgb(0 0 0 / 0.05);\n --inset-shadow-sm: inset 0 2px 4px rgb(0 0 0 / 0.05);\n\n --drop-shadow-xs: 0 1px 1px rgb(0 0 0 / 0.05);\n --drop-shadow-sm: 0 1px 2px rgb(0 0 0 / 0.15);\n --drop-shadow-md: 0 3px 3px rgb(0 0 0 / 0.12);\n --drop-shadow-lg: 0 4px 4px rgb(0 0 0 / 0.15);\n --drop-shadow-xl: 0 9px 7px rgb(0 0 0 / 0.1);\n --drop-shadow-2xl: 0 25px 25px rgb(0 0 0 / 0.15);\n\n --text-shadow-2xs: 0px 1px 0px rgb(0 0 0 / 0.15);\n --text-shadow-xs: 0px 1px 1px rgb(0 0 0 / 0.2);\n --text-shadow-sm:\n 0px 1px 0px rgb(0 0 0 / 0.075), 0px 1px 1px rgb(0 0 0 / 0.075), 0px 2px 2px rgb(0 0 0 / 0.075);\n --text-shadow-md:\n 0px 1px 1px rgb(0 0 0 / 0.1), 0px 1px 2px rgb(0 0 0 / 0.1), 0px 2px 4px rgb(0 0 0 / 0.1);\n --text-shadow-lg:\n 0px 1px 2px rgb(0 0 0 / 0.1), 0px 3px 2px rgb(0 0 0 / 0.1), 0px 4px 8px rgb(0 0 0 / 0.1);\n\n --ease-in: cubic-bezier(0.4, 0, 1, 1);\n --ease-out: cubic-bezier(0, 0, 0.2, 1);\n --ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);\n\n --animate-spin: spin 1s linear infinite;\n --animate-ping: ping 1s cubic-bezier(0, 0, 0.2, 1) infinite;\n --animate-pulse: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;\n --animate-bounce: bounce 1s infinite;\n\n @keyframes spin {\n to {\n transform: rotate(360deg);\n }\n }\n\n @keyframes ping {\n 75%,\n 100% {\n transform: scale(2);\n opacity: 0;\n }\n }\n\n @keyframes pulse {\n 50% {\n opacity: 0.5;\n }\n }\n\n @keyframes bounce {\n 0%,\n 100% {\n transform: translateY(-25%);\n animation-timing-function: cubic-bezier(0.8, 0, 1, 1);\n }\n\n 50% {\n transform: none;\n animation-timing-function: cubic-bezier(0, 0, 0.2, 1);\n }\n }\n\n --blur-xs: 4px;\n --blur-sm: 8px;\n --blur-md: 12px;\n --blur-lg: 16px;\n --blur-xl: 24px;\n --blur-2xl: 40px;\n --blur-3xl: 64px;\n\n --perspective-dramatic: 100px;\n --perspective-near: 300px;\n --perspective-normal: 500px;\n --perspective-midrange: 800px;\n --perspective-distant: 1200px;\n\n --aspect-video: 16 / 9;\n\n --default-transition-duration: 150ms;\n --default-transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);\n --default-font-family: --theme(--font-sans, initial);\n --default-font-feature-settings: --theme(--font-sans--font-feature-settings, initial);\n --default-font-variation-settings: --theme(--font-sans--font-variation-settings, initial);\n --default-mono-font-family: --theme(--font-mono, initial);\n --default-mono-font-feature-settings: --theme(--font-mono--font-feature-settings, initial);\n --default-mono-font-variation-settings: --theme(--font-mono--font-variation-settings, initial);\n}\n\n/* Deprecated */\n@theme default inline reference {\n --blur: 8px;\n --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);\n --shadow-inner: inset 0 2px 4px 0 rgb(0 0 0 / 0.05);\n --drop-shadow: 0 1px 2px rgb(0 0 0 / 0.1), 0 1px 1px rgb(0 0 0 / 0.06);\n --radius: 0.25rem;\n --max-width-prose: 65ch;\n}\n",
1105
+ "tailwindcss/utilities.css": "@tailwind utilities;\n",
1106
+ "tailwindcss/preflight.css": "/*\n 1. Prevent padding and border from affecting element width. (https://github.com/mozdevs/cssremedy/issues/4)\n 2. Remove default margins and padding\n 3. Reset all borders.\n*/\n\n*,\n::after,\n::before,\n::backdrop,\n::file-selector-button {\n box-sizing: border-box; /* 1 */\n margin: 0; /* 2 */\n padding: 0; /* 2 */\n border: 0 solid; /* 3 */\n}\n\n/*\n 1. Use a consistent sensible line-height in all browsers.\n 2. Prevent adjustments of font size after orientation changes in iOS.\n 3. Use a more readable tab size.\n 4. Use the user's configured `sans` font-family by default.\n 5. Use the user's configured `sans` font-feature-settings by default.\n 6. Use the user's configured `sans` font-variation-settings by default.\n 7. Disable tap highlights on iOS.\n*/\n\nhtml,\n:host {\n line-height: 1.5; /* 1 */\n -webkit-text-size-adjust: 100%; /* 2 */\n tab-size: 4; /* 3 */\n font-family: --theme(\n --default-font-family,\n -apple-system,\n BlinkMacSystemFont,\n 'Segoe UI',\n Roboto,\n 'Helvetica Neue',\n 'Noto Sans',\n Arial,\n sans-serif,\n 'Apple Color Emoji',\n 'Segoe UI Emoji',\n 'Segoe UI Symbol',\n 'Noto Color Emoji'\n ); /* 4 */\n font-feature-settings: --theme(--default-font-feature-settings, normal); /* 5 */\n font-variation-settings: --theme(--default-font-variation-settings, normal); /* 6 */\n -webkit-tap-highlight-color: transparent; /* 7 */\n}\n\n/*\n 1. Add the correct height in Firefox.\n 2. Correct the inheritance of border color in Firefox. (https://bugzilla.mozilla.org/show_bug.cgi?id=190655)\n 3. Reset the default border style to a 1px solid border.\n*/\n\nhr {\n height: 0; /* 1 */\n color: inherit; /* 2 */\n border-top-width: 1px; /* 3 */\n}\n\n/*\n Add the correct text decoration in Chrome, Edge, and Safari.\n*/\n\nabbr:where([title]) {\n -webkit-text-decoration: underline dotted;\n text-decoration: underline dotted;\n}\n\n/*\n Remove the default font size and weight for headings.\n*/\n\nh1,\nh2,\nh3,\nh4,\nh5,\nh6 {\n font-size: inherit;\n font-weight: inherit;\n}\n\n/*\n Reset links to optimize for opt-in styling instead of opt-out.\n*/\n\na {\n color: inherit;\n -webkit-text-decoration: inherit;\n text-decoration: inherit;\n}\n\n/*\n Add the correct font weight in Edge and Safari.\n*/\n\nb,\nstrong {\n font-weight: bolder;\n}\n\n/*\n 1. Use the user's configured `mono` font-family by default.\n 2. Use the user's configured `mono` font-feature-settings by default.\n 3. Use the user's configured `mono` font-variation-settings by default.\n 4. Correct the odd `em` font sizing in all browsers.\n*/\n\ncode,\nkbd,\nsamp,\npre {\n font-family: --theme(\n --default-mono-font-family,\n ui-monospace,\n SFMono-Regular,\n Menlo,\n Monaco,\n Consolas,\n 'Liberation Mono',\n 'Courier New',\n monospace\n ); /* 1 */\n font-feature-settings: --theme(--default-mono-font-feature-settings, normal); /* 2 */\n font-variation-settings: --theme(--default-mono-font-variation-settings, normal); /* 3 */\n font-size: 1em; /* 4 */\n}\n\n/*\n Add the correct font size in all browsers.\n*/\n\nsmall {\n font-size: 80%;\n}\n\n/*\n Prevent `sub` and `sup` elements from affecting the line height in all browsers.\n*/\n\nsub,\nsup {\n font-size: 75%;\n line-height: 0;\n position: relative;\n vertical-align: baseline;\n}\n\nsub {\n bottom: -0.25em;\n}\n\nsup {\n top: -0.5em;\n}\n\n/*\n 1. Remove text indentation from table contents in Chrome and Safari. (https://bugs.chromium.org/p/chromium/issues/detail?id=999088, https://bugs.webkit.org/show_bug.cgi?id=201297)\n 2. Correct table border color inheritance in all Chrome and Safari. (https://bugs.chromium.org/p/chromium/issues/detail?id=935729, https://bugs.webkit.org/show_bug.cgi?id=195016)\n 3. Remove gaps between table borders by default.\n*/\n\ntable {\n text-indent: 0; /* 1 */\n border-color: inherit; /* 2 */\n border-collapse: collapse; /* 3 */\n}\n\n/*\n Use the modern Firefox focus style for all focusable elements.\n*/\n\n:-moz-focusring:where(:not(iframe)) {\n outline: auto;\n}\n\n/*\n Add the correct vertical alignment in Chrome and Firefox.\n*/\n\nprogress {\n vertical-align: baseline;\n}\n\n/*\n Add the correct display in Chrome and Safari.\n*/\n\nsummary {\n display: list-item;\n}\n\n/*\n Make lists unstyled by default.\n*/\n\nol,\nul,\nmenu {\n list-style: none;\n}\n\n/*\n 1. Make replaced elements `display: block` by default. (https://github.com/mozdevs/cssremedy/issues/14)\n 2. Add `vertical-align: middle` to align replaced elements more sensibly by default. (https://github.com/jensimmons/cssremedy/issues/14#issuecomment-634934210)\n This can trigger a poorly considered lint error in some tools but is included by design.\n*/\n\nimg,\nsvg,\nvideo,\ncanvas,\naudio,\niframe,\nembed,\nobject {\n display: block; /* 1 */\n vertical-align: middle; /* 2 */\n}\n\n/*\n Constrain images and videos to the parent width and preserve their intrinsic aspect ratio. (https://github.com/mozdevs/cssremedy/issues/14)\n*/\n\nimg,\nvideo {\n max-width: 100%;\n height: auto;\n}\n\n/*\n 1. Inherit font styles in all browsers.\n 2. Remove border radius in all browsers.\n 3. Remove background color in all browsers.\n 4. Ensure consistent opacity for disabled states in all browsers.\n*/\n\nbutton,\ninput,\nselect,\noptgroup,\ntextarea,\n::file-selector-button {\n font: inherit; /* 1 */\n font-feature-settings: inherit; /* 1 */\n font-variation-settings: inherit; /* 1 */\n letter-spacing: inherit; /* 1 */\n color: inherit; /* 1 */\n border-radius: 0; /* 2 */\n background-color: transparent; /* 3 */\n opacity: 1; /* 4 */\n}\n\n/*\n Restore default font weight.\n*/\n\n:where(select:is([multiple], [size])) optgroup {\n font-weight: bolder;\n}\n\n/*\n Restore indentation.\n*/\n\n:where(select:is([multiple], [size])) optgroup option {\n padding-inline-start: 20px;\n}\n\n/*\n Restore space after button.\n*/\n\n::file-selector-button {\n margin-inline-end: 4px;\n}\n\n/*\n Reset the default placeholder opacity in Firefox. (https://github.com/tailwindlabs/tailwindcss/issues/3300)\n*/\n\n::placeholder {\n opacity: 1;\n}\n\n/*\n Set the default placeholder color to a semi-transparent version of the current text color in browsers that do not\n crash when using `color-mix(…)` with `currentcolor`. (https://github.com/tailwindlabs/tailwindcss/issues/17194)\n*/\n\n@supports (not (-webkit-appearance: -apple-pay-button)) /* Not Safari */ or\n (contain-intrinsic-size: 1px) /* Safari 17+ */ {\n ::placeholder {\n color: color-mix(in oklab, currentcolor 50%, transparent);\n }\n}\n\n/*\n Prevent resizing textareas horizontally by default.\n*/\n\ntextarea {\n resize: vertical;\n}\n\n/*\n Remove the inner padding in Chrome and Safari on macOS.\n*/\n\n::-webkit-search-decoration {\n -webkit-appearance: none;\n}\n\n/*\n 1. Ensure date/time inputs have the same height when empty in iOS Safari.\n 2. Ensure text alignment can be changed on date/time inputs in iOS Safari.\n*/\n\n::-webkit-date-and-time-value {\n min-height: 1lh; /* 1 */\n text-align: inherit; /* 2 */\n}\n\n/*\n Prevent height from changing on date/time inputs in macOS Safari when the input is set to `display: block`.\n*/\n\n::-webkit-datetime-edit {\n display: inline-flex;\n}\n\n/*\n Remove excess padding from pseudo-elements in date/time inputs to ensure consistent height across browsers.\n*/\n\n::-webkit-datetime-edit-fields-wrapper {\n padding: 0;\n}\n\n::-webkit-datetime-edit,\n::-webkit-datetime-edit-year-field,\n::-webkit-datetime-edit-month-field,\n::-webkit-datetime-edit-day-field,\n::-webkit-datetime-edit-hour-field,\n::-webkit-datetime-edit-minute-field,\n::-webkit-datetime-edit-second-field,\n::-webkit-datetime-edit-millisecond-field,\n::-webkit-datetime-edit-meridiem-field {\n padding-block: 0;\n}\n\n/*\n Center dropdown marker shown on inputs with paired `<datalist>`s in Chrome. (https://github.com/tailwindlabs/tailwindcss/issues/18499)\n*/\n\n::-webkit-calendar-picker-indicator {\n line-height: 1;\n}\n\n/*\n Remove the additional `:invalid` styles in Firefox. (https://github.com/mozilla/gecko-dev/blob/2f9eacd9d3d995c937b4251a5557d95d494c9be1/layout/style/res/forms.css#L728-L737)\n*/\n\n:-moz-ui-invalid {\n box-shadow: none;\n}\n\n/*\n Correct the inability to style the border radius in iOS Safari.\n*/\n\nbutton,\ninput:where([type='button'], [type='reset'], [type='submit']),\n::file-selector-button {\n appearance: button;\n}\n\n/*\n Correct the cursor style of increment and decrement buttons in Safari.\n*/\n\n::-webkit-inner-spin-button,\n::-webkit-outer-spin-button {\n height: auto;\n}\n\n/*\n Make elements with the HTML hidden attribute stay hidden by default.\n*/\n\n[hidden]:where(:not([hidden='until-found'])) {\n display: none !important;\n}\n"
1107
+ };
1108
+ /** Compile the discovered class set into CSS with the pinned Tailwind release. */
1109
+ const compileTailwind = async (candidates, options = {}) => {
1110
+ const entry = [
1111
+ "@layer theme, base, components, utilities;",
1112
+ "@import \"tailwindcss/theme.css\" layer(theme);",
1113
+ ...options.preflight === true ? ["@import \"tailwindcss/preflight.css\" layer(base);"] : [],
1114
+ "@import \"tailwindcss/utilities.css\" layer(utilities);",
1115
+ options.css ?? ""
1116
+ ].join("\n");
1117
+ const compiler = await compile(entry, {
1118
+ base: "/",
1119
+ loadStylesheet: (id, base) => Promise.resolve({
1120
+ path: id,
1121
+ base,
1122
+ content: STYLESHEETS[id] ?? ""
1123
+ })
1124
+ });
1125
+ const all = [.../* @__PURE__ */ new Set([...candidates, ...options.safelist ?? []])].sort();
1126
+ const limits = options.limits;
1127
+ if (limits !== void 0 && all.length > limits.candidates) throw new TypeError(`Tailwind candidate limit exceeded: ${all.length} classes, limit ${limits.candidates}. Reduce the utility classes this project uses, or its declared safelist.`);
1128
+ const css = compiler.build(all);
1129
+ const bytes = new TextEncoder().encode(css).length;
1130
+ if (limits !== void 0 && bytes > limits.cssBytes) throw new TypeError(`Generated CSS limit exceeded: ${bytes} bytes, limit ${limits.cssBytes}. Reduce the utility classes this project uses, or its declared safelist.`);
1131
+ return {
1132
+ css,
1133
+ version: TAILWIND_VERSION,
1134
+ candidates: all
1135
+ };
1136
+ };
1137
+ const isRecord = (value) => Predicate.isObject(value) && !Array.isArray(value);
1138
+ const isAstNode = (value) => isRecord(value) && typeof value.type === "string" && typeof value.start === "number" && typeof value.end === "number";
1139
+ const walk$1 = (value, visit) => {
1140
+ if (Array.isArray(value)) {
1141
+ for (const item of value) walk$1(item, visit);
1142
+ return;
1143
+ }
1144
+ if (!isRecord(value)) return;
1145
+ if (isAstNode(value)) visit(value);
1146
+ for (const [key, child] of Object.entries(value)) {
1147
+ if (key === "loc" || key === "extra" || key === "comments" || key === "tokens") continue;
1148
+ walk$1(child, visit);
1149
+ }
1150
+ };
1151
+ const CLASS_KEYS = /* @__PURE__ */ new Set(["class", "className"]);
1152
+ const nameOf = (node) => {
1153
+ if (!isAstNode(node)) return void 0;
1154
+ if (node.type === "JSXIdentifier" || node.type === "Identifier") return typeof node.name === "string" ? node.name : void 0;
1155
+ if (node.type === "StringLiteral") return typeof node.value === "string" ? node.value : void 0;
1156
+ };
1157
+ /**
1158
+ * Collect the class names one module states literally, and report the positions
1159
+ * where a class is assembled from values the compiler cannot see.
1160
+ */
1161
+ const discoverClassCandidates = (source, fileName) => {
1162
+ let parsed;
1163
+ try {
1164
+ parsed = parse(source, {
1165
+ plugins: ["typescript", "jsx"],
1166
+ sourceType: "module"
1167
+ });
1168
+ } catch {
1169
+ return {
1170
+ candidates: [],
1171
+ diagnostics: []
1172
+ };
1173
+ }
1174
+ const lineMap = buildLineMap(source);
1175
+ const candidates = /* @__PURE__ */ new Set();
1176
+ const diagnostics = [];
1177
+ const at = (offset) => {
1178
+ const position = lineColumn(lineMap, offset);
1179
+ return {
1180
+ fileName,
1181
+ lineNumber: position.line,
1182
+ columnNumber: position.column
1183
+ };
1184
+ };
1185
+ /** Returns true when every class in the expression is statically known. */
1186
+ const readValue = (node) => {
1187
+ if (!isAstNode(node)) return false;
1188
+ switch (node.type) {
1189
+ case "StringLiteral":
1190
+ if (typeof node.value !== "string") return false;
1191
+ for (const name of node.value.split(/\s+/)) if (name !== "") candidates.add(name);
1192
+ return true;
1193
+ case "TemplateLiteral": {
1194
+ const quasis = Array.isArray(node.quasis) ? node.quasis : [];
1195
+ for (const quasi of quasis) {
1196
+ const cooked = isAstNode(quasi) && isRecord(quasi.value) ? quasi.value.cooked : void 0;
1197
+ if (typeof cooked !== "string") continue;
1198
+ for (const name of cooked.split(/\s+/)) if (name !== "") candidates.add(name);
1199
+ }
1200
+ return Array.isArray(node.expressions) && node.expressions.length === 0;
1201
+ }
1202
+ case "JSXExpressionContainer": return readValue(node.expression);
1203
+ case "ConditionalExpression": return [node.consequent, node.alternate].every((branch) => readValue(branch));
1204
+ case "LogicalExpression": return readValue(node.right);
1205
+ case "BinaryExpression": return node.operator === "+" && [node.left, node.right].every((side) => readValue(side));
1206
+ case "ArrayExpression": return Array.isArray(node.elements) && node.elements.every((element) => readValue(element));
1207
+ default: return false;
1208
+ }
1209
+ };
1210
+ walk$1(parsed.program, (node) => {
1211
+ const isJsxAttribute = node.type === "JSXAttribute";
1212
+ const isObjectProperty = node.type === "ObjectProperty";
1213
+ if (!isJsxAttribute && !isObjectProperty) return;
1214
+ const key = nameOf(isJsxAttribute ? node.name : node.key);
1215
+ if (key === void 0 || !CLASS_KEYS.has(key)) return;
1216
+ const value = isJsxAttribute ? node.value : node.value;
1217
+ if (value === null || value === void 0) return;
1218
+ if (readValue(value)) return;
1219
+ diagnostics.push({
1220
+ code: "tailwind-dynamic-class",
1221
+ severity: "warning",
1222
+ message: `This ${key} is assembled at run time, so the compiler cannot discover the classes it produces and they will have no styles. Write the classes literally, or declare them in the project's Tailwind safelist.`,
1223
+ origins: [at(node.start)]
1224
+ });
1225
+ });
1226
+ return {
1227
+ candidates: [...candidates].sort(),
1228
+ diagnostics
1229
+ };
1230
+ };
1231
+ //#endregion
1232
+ //#region src/email/transform.ts
1233
+ const STYLESHEET_MODULE = "@samva/markup/email/stylesheets";
1234
+ const SCRIPT = /\.[cm]?[jt]sx?$/;
1235
+ const JSX = /\.[cm]?[jt]sx$/;
1236
+ const stylesheetModule = (id, source, options) => {
1237
+ const sheet = parseStylesheet(source, { origin: id });
1238
+ return {
1239
+ code: `import { registerStylesheet } from ${JSON.stringify(options.stylesheetModule ?? STYLESHEET_MODULE)};\nregisterStylesheet(${JSON.stringify({
1240
+ rules: sheet.rules,
1241
+ headAtRules: sheet.headAtRules,
1242
+ variables: sheet.variables,
1243
+ diagnostics: []
1244
+ })});\n`,
1245
+ diagnostics: sheet.diagnostics
1246
+ };
1247
+ };
1248
+ /**
1249
+ * Transform one project file into a JavaScript module.
1250
+ *
1251
+ * `.tsx`/`.ts` keep their authored semantics and gain source origins. A
1252
+ * stylesheet becomes a module that registers its parsed rules. An imported
1253
+ * binary becomes a module exporting the content-addressed URL of its bytes.
1254
+ */
1255
+ const transformModule = async (id, source, options) => {
1256
+ if (isAssetPath(id)) {
1257
+ const bytes = typeof source === "string" ? new TextEncoder().encode(source) : source;
1258
+ const asset = await assetEntry(id, bytes);
1259
+ return {
1260
+ code: `export default ${JSON.stringify(assetUrl(asset, options.assetBase))};\n`,
1261
+ asset,
1262
+ diagnostics: checkAssetBase(options.assetBase)
1263
+ };
1264
+ }
1265
+ const text = typeof source === "string" ? source : new TextDecoder().decode(source);
1266
+ if (id.endsWith(".css")) return stylesheetModule(id, text, options);
1267
+ if (!SCRIPT.test(id)) return {
1268
+ code: text,
1269
+ diagnostics: []
1270
+ };
1271
+ const discovered = options.tailwind === false ? void 0 : discoverClassCandidates(text, id);
1272
+ return {
1273
+ code: JSX.test(id) ? instrumentTsxSourceForPreview(text, id, void 0, null) : text,
1274
+ classes: discovered?.candidates,
1275
+ diagnostics: discovered?.diagnostics ?? []
1276
+ };
1277
+ };
1278
+ /**
1279
+ * The generated Tailwind module is a real file at the project root, not a
1280
+ * virtual id. A virtual module has no directory, so its own relative imports
1281
+ * resolve differently from the project's and the bundler ends up with a second
1282
+ * copy of the stylesheet registry — the sheet registers into a registry the
1283
+ * render never reads.
1284
+ */
1285
+ const TAILWIND_MODULE_PATH = ".samva-tailwind.css";
1286
+ /** The specifier an entry at this path uses to reach the generated module. */
1287
+ const tailwindSpecifierFor = (entryPoint) => {
1288
+ const depth = entryPoint.split("/").length - 1;
1289
+ return depth === 0 ? `./${TAILWIND_MODULE_PATH}` : `${"../".repeat(depth)}${TAILWIND_MODULE_PATH}`;
1290
+ };
1291
+ /** Run the transform over a whole project, then compile the classes it used. */
1292
+ const transformProject = async (files, options) => {
1293
+ const output = {};
1294
+ const assets = [];
1295
+ const diagnostics = [];
1296
+ const classes = /* @__PURE__ */ new Set();
1297
+ const paths = Object.keys(files).sort();
1298
+ const transformed = await Promise.all(paths.map((path) => transformModule(path, files[path], options)));
1299
+ for (const [index, path] of paths.entries()) {
1300
+ const module = transformed[index];
1301
+ output[path] = module.code;
1302
+ if (module.asset !== void 0) assets.push(module.asset);
1303
+ for (const name of module.classes ?? []) classes.add(name);
1304
+ diagnostics.push(...module.diagnostics);
1305
+ }
1306
+ const wanted = options.tailwind === false ? void 0 : options.tailwind ?? {};
1307
+ if (wanted === void 0 || classes.size === 0 && (wanted.safelist?.length ?? 0) === 0) return {
1308
+ files: output,
1309
+ assets,
1310
+ tailwind: void 0,
1311
+ diagnostics
1312
+ };
1313
+ const compiled = await compileTailwind(classes, wanted);
1314
+ return {
1315
+ files: output,
1316
+ assets,
1317
+ tailwind: {
1318
+ path: TAILWIND_MODULE_PATH,
1319
+ code: stylesheetModule(TAILWIND_MODULE_PATH, compiled.css, options).code
1320
+ },
1321
+ diagnostics
1322
+ };
1323
+ };
1324
+ /**
1325
+ * Put a side-effect import ahead of an entry's own imports, after any leading
1326
+ * comment so a `@jsxImportSource` pragma keeps its position. Import order is
1327
+ * cascade order, so the generated sheet has to be first.
1328
+ */
1329
+ const withLeadingImport = (source, specifier) => {
1330
+ const leading = /^(?:\s|\/\*[\s\S]*?\*\/|\/\/[^\n]*\n)*/.exec(source)?.[0].length ?? 0;
1331
+ return `${source.slice(0, leading)}import ${JSON.stringify(specifier)};\n${source.slice(leading)}`;
1332
+ };
1333
+ /** The generated entry every host builds, so both evaluate the same module. */
1334
+ const EMAIL_ENTRY_WRAPPER = ".samva-email-entry.ts";
1335
+ /**
1336
+ * The generated module that clears the stylesheet registry. It is imported
1337
+ * first, as its own module, because import order is evaluation order: a reset
1338
+ * written as a statement in the wrapper would run after the wrapper's imports
1339
+ * had already registered.
1340
+ */
1341
+ const EMAIL_RESET_MODULE = ".samva-email-reset.ts";
1342
+ /**
1343
+ * The wrapper's source. It re-exports the template beside the renderer so the
1344
+ * render runs inside the project's own module graph — the graph its stylesheets
1345
+ * registered into. Importing the renderer from outside that graph reaches a
1346
+ * second copy of the registry and silently renders unstyled.
1347
+ */
1348
+ const emailEntryWrapper = (entryPoint, imports = []) => `${[`./${EMAIL_RESET_MODULE}`, ...imports].map((specifier) => `import ${JSON.stringify(specifier)};\n`).join("")}import * as entry from ${JSON.stringify(`./${entryPoint}`)};\nexport const template = entry.default;\nexport { renderEmail } from "@samva/markup/email/render";\nexport { isTemplateDefinition } from "@samva/markup/template";\n`;
1349
+ /**
1350
+ * A host that renders more than one project in one process shares the registry
1351
+ * through its module cache, so every project graph starts by clearing it.
1352
+ */
1353
+ const emailResetModule = (options) => `import { resetStylesheets } from ${JSON.stringify(options.stylesheetModule ?? STYLESHEET_MODULE)};\nresetStylesheets();\n`;
1354
+ const RESERVED = [
1355
+ EMAIL_ENTRY_WRAPPER,
1356
+ EMAIL_RESET_MODULE,
1357
+ TAILWIND_MODULE_PATH
1358
+ ];
1359
+ /**
1360
+ * The whole compile step, files in and files out: every module transformed, the
1361
+ * generated Tailwind sheet written, the generated imports added and the wrapper
1362
+ * built. Both hosts call exactly this, which is what stops their outputs from
1363
+ * drifting apart.
1364
+ */
1365
+ const compileEmailProject = async (source, authoredEntry, options) => {
1366
+ for (const reserved of RESERVED) if (reserved in source) throw new TypeError(`Reserved compiler file exists: ${reserved}`);
1367
+ if (!(authoredEntry in source)) throw new TypeError(`Missing email build entry ${authoredEntry}`);
1368
+ const project = await transformProject(source, options);
1369
+ const files = { ...project.files };
1370
+ const generated = [];
1371
+ if (project.tailwind !== void 0) {
1372
+ files[project.tailwind.path] = project.tailwind.code;
1373
+ generated.push(tailwindSpecifierFor(authoredEntry));
1374
+ files[authoredEntry] = withLeadingImport(files[authoredEntry], generated[0]);
1375
+ }
1376
+ files[EMAIL_RESET_MODULE] = emailResetModule(options);
1377
+ files[EMAIL_ENTRY_WRAPPER] = emailEntryWrapper(authoredEntry, project.tailwind === void 0 ? [] : [`./${project.tailwind.path}`]);
1378
+ return {
1379
+ files,
1380
+ entryPoint: EMAIL_ENTRY_WRAPPER,
1381
+ authoredEntry,
1382
+ assets: project.assets,
1383
+ diagnostics: project.diagnostics
1384
+ };
1385
+ };
1386
+ //#endregion
1387
+ export { ASSET_CONTENT_TYPES, COMPATIBILITY_PROVENANCE, EMAIL_CLIENT_MATRIX, EMAIL_DOCTYPE, EMAIL_ELEMENTS, EMAIL_ENTRY_WRAPPER, EMAIL_GLOBAL_ATTRIBUTES, EMAIL_RESET_MODULE, ESSENTIAL_CONSTRUCTS, EmailCompileError, EmailDiagnostic, EmailDiagnosticSeverity, EmailElementSelection, EmittedPosition, INSTANCE_PATH_ATTRIBUTE, TAILWIND_MODULE_PATH, TAILWIND_VERSION, applyStylesheet, assetEntry, assetUrl, checkAssetBase, checkEmailCompatibility, classListOf, collectStylesheets, compileEmail, compileEmailProject, compileSelector, compileTailwind, deriveEmailText, discoverClassCandidates, downlevelColors, downlevelMediaQuery, emailAuthoringTarget, emailDefinitionInstances, emailElement, emailEntryWrapper, emailResetModule, emailSelectionAncestry, emailSelectionIndex, emailSelectionSiblings, emailSelections, escapeAttribute, escapeText, finalizeValue, foldCalc, formatColor, formatEmailDiagnostic, hasBlockingCompatibility, hasBlockingDiagnostic, hasStylesheets, instrumentTsxSourceForPreview, isAssetPath, isExternalAsset, isUrlAttribute, matchesSelector, parseColor, parseStylesheet, registerStylesheet, renderEmail, renderHeadCss, resetStylesheets, resolveVariables, serializeEmailHtml, tailwindSpecifierFor, transformModule, transformProject, unknownCoverage, withLeadingImport };
1388
+
1389
+ //# sourceMappingURL=compiler.js.map