@aglyn/shared-util-email 1.0.0-beta.264 → 1.0.0-beta.268
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +3 -3
- package/src/index.d.ts +1 -0
- package/src/index.js +1 -0
- package/src/index.js.map +1 -1
- package/src/lib/email-render.d.ts +22 -1
- package/src/lib/email-render.js +138 -10
- package/src/lib/email-render.js.map +1 -1
- package/src/lib/risk-notice-emails.js +28 -3
- package/src/lib/risk-notice-emails.js.map +1 -1
- package/src/lib/system-email-catalog.d.ts +5 -1
- package/src/lib/system-email-catalog.js +774 -94
- package/src/lib/system-email-catalog.js.map +1 -1
- package/src/lib/tenant-emails.generated.js +338 -98
- package/src/lib/tenant-emails.generated.js.map +1 -1
- package/src/lib/welcome-email.d.ts +37 -0
- package/src/lib/welcome-email.js +49 -0
- package/src/lib/welcome-email.js.map +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aglyn/shared-util-email",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.268",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"homepage": "https://aglyn.com",
|
|
6
6
|
"repository": {
|
|
@@ -25,8 +25,8 @@
|
|
|
25
25
|
"./package.json": "./package.json"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@aglyn/shared-data-enums": "1.0.0-beta.
|
|
29
|
-
"@aglyn/shared-util-http": "1.0.0-beta.
|
|
28
|
+
"@aglyn/shared-data-enums": "1.0.0-beta.268",
|
|
29
|
+
"@aglyn/shared-util-http": "1.0.0-beta.268",
|
|
30
30
|
"@msgpack/msgpack": "^3.1.3",
|
|
31
31
|
"@swc/helpers": "0.5.23"
|
|
32
32
|
},
|
package/src/index.d.ts
CHANGED
|
@@ -28,6 +28,7 @@ export * from './lib/platform-sending-domain';
|
|
|
28
28
|
export * from './lib/email-health';
|
|
29
29
|
export * from './lib/system-email-catalog';
|
|
30
30
|
export * from './lib/retention-emails';
|
|
31
|
+
export * from './lib/welcome-email';
|
|
31
32
|
export * from './lib/tenant-email-catalog';
|
|
32
33
|
export * from './lib/host-email-render';
|
|
33
34
|
export * from './lib/email-render';
|
package/src/index.js
CHANGED
|
@@ -32,6 +32,7 @@ export * from "./lib/platform-sending-domain.js";
|
|
|
32
32
|
export * from "./lib/email-health.js";
|
|
33
33
|
export * from "./lib/system-email-catalog.js";
|
|
34
34
|
export * from "./lib/retention-emails.js";
|
|
35
|
+
export * from "./lib/welcome-email.js";
|
|
35
36
|
export * from "./lib/tenant-email-catalog.js";
|
|
36
37
|
export * from "./lib/host-email-render.js";
|
|
37
38
|
export * from "./lib/email-render.js";
|
package/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../libs/shared/util/email/src/index.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport * from './lib/send-email'\n// Who carries the mail (AGL-3080): the provider contract, and the selection\n// of the deployment's provider from the built-ins and any a plugin\n// registered. The providers themselves are imported by their own paths —\n// `@aglyn/shared-util-email/mail-provider-resend`, `…/mail-provider-webhook`\n// — because nothing outside the seam should name one.\nexport * from './lib/mail-provider'\nexport * from './lib/mail-providers'\nexport * from './lib/send-rate'\nexport * from './lib/sender-reputation'\nexport * from './lib/send-ceilings'\nexport * from './lib/sending-domain'\nexport * from './lib/tracking-host'\nexport * from './lib/sending-mailbox'\nexport * from './lib/host-sender'\nexport * from './lib/platform-sending-domain'\nexport * from './lib/email-health'\nexport * from './lib/system-email-catalog'\nexport * from './lib/retention-emails'\nexport * from './lib/tenant-email-catalog'\nexport * from './lib/host-email-render'\nexport * from './lib/email-render'\nexport * from './lib/text-email-html'\nexport * from './lib/marketing-send'\n// The List-Unsubscribe setting sequences and campaigns share (AGL-3307).\nexport * from './lib/list-unsubscribe'\nexport * from './lib/email-delivery-events'\n// Received mail in the platform's vocabulary, which the CRM's capture route\n// files from (AGL-2657); the provider reads it.\n// Its neighbor `./lib/svix-signature` is deliberately NOT re-exported here:\n// it holds a `crypto` HMAC, and this barrel is reached from the browser\n// through `@aglyn/shared-ui-email-campaigns`, so a webhook imports it by its\n// own path — `@aglyn/shared-util-email/svix-signature`.\nexport * from './lib/received-email'\nexport * from './lib/email-revenue-window'\n// Exported so the console drift guard can pin it against @aglyn/aglyn.\nexport * from './lib/email-media-src'\n// Same arrangement, same reason (AGL-1223): a copy of `decodeStoredNodes`\n// this scope:shared lib may not import, pinned by `email-nodes-drift.spec.ts`.\nexport * from './lib/stored-email-nodes'\nexport * from './lib/email-merge'\n// The deliverability engine every send path asks (AGL-3328): the gateway an\n// MX names and its ledger, the bounce reader, and the address verdicts. Pure\n// — the DNS lookup and the store are injected by `@aglyn/tenant-data-admin`,\n// so nothing here reaches `node:dns` from the browser.\nexport * from './lib/mail-gateway'\nexport * from './lib/mail-bounce'\nexport * from './lib/email-deliverability'\n// The sender's side of the same engine (AGL-3328): SPF, DKIM and DMARC for\n// the domain mail leaves from, and whether they align. Pure as well; the\n// lookups are `@aglyn/tenant-data-admin`'s.\nexport * from './lib/sender-readiness'\n// The outbound phishing screen a young workspace's campaigns and automated\n// email pass (AGL-3356). Pure; the hold it leads to is `tenant-data-admin`'s.\nexport * from './lib/outbound-phishing-screen'\n// The send seam's gate for that screen — the store a hold writes is injected\n// by `@aglyn/tenant-data-admin`, like the governor's.\nexport * from './lib/outbound-screen-gate'\n// The same screen read over a published page (AGL-3356): lookalike links and\n// embeds, author-defined credential fields, a brand's call to action.\nexport * from './lib/hosted-page-screen'\n// The reputation lookup every foreign link a page, an email or a redirect\n// points at passes (AGL-3451). Pure; the lookup is injected by\n// `@aglyn/tenant-data-admin`, which holds the credential and the cache.\nexport * from './lib/link-reputation'\n// The site's theme palette as plain data (AGL-3370), so a palette token an\n// author picked resolves in mail. Built without MUI; `shared-ui-theme`'s\n// parity spec holds it equal to the theme.\nexport * from './lib/email-palette'\nexport * from './lib/email-design-chrome'\n"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED,cAAc,sBAAkB;AAChC,4EAA4E;AAC5E,mEAAmE;AACnE,yEAAyE;AACzE,6EAA6E;AAC7E,sDAAsD;AACtD,cAAc,yBAAqB;AACnC,cAAc,0BAAsB;AACpC,cAAc,qBAAiB;AAC/B,cAAc,6BAAyB;AACvC,cAAc,yBAAqB;AACnC,cAAc,0BAAsB;AACpC,cAAc,yBAAqB;AACnC,cAAc,2BAAuB;AACrC,cAAc,uBAAmB;AACjC,cAAc,mCAA+B;AAC7C,cAAc,wBAAoB;AAClC,cAAc,gCAA4B;AAC1C,cAAc,4BAAwB;AACtC,cAAc,gCAA4B;AAC1C,cAAc,6BAAyB;AACvC,cAAc,wBAAoB;AAClC,cAAc,2BAAuB;AACrC,cAAc,0BAAsB;AACpC,yEAAyE;AACzE,cAAc,4BAAwB;AACtC,cAAc,iCAA6B;AAC3C,4EAA4E;AAC5E,gDAAgD;AAChD,4EAA4E;AAC5E,wEAAwE;AACxE,6EAA6E;AAC7E,wDAAwD;AACxD,cAAc,0BAAsB;AACpC,cAAc,gCAA4B;AAC1C,uEAAuE;AACvE,cAAc,2BAAuB;AACrC,0EAA0E;AAC1E,+EAA+E;AAC/E,cAAc,8BAA0B;AACxC,cAAc,uBAAmB;AACjC,4EAA4E;AAC5E,6EAA6E;AAC7E,6EAA6E;AAC7E,uDAAuD;AACvD,cAAc,wBAAoB;AAClC,cAAc,uBAAmB;AACjC,cAAc,gCAA4B;AAC1C,2EAA2E;AAC3E,yEAAyE;AACzE,4CAA4C;AAC5C,cAAc,4BAAwB;AACtC,2EAA2E;AAC3E,8EAA8E;AAC9E,cAAc,oCAAgC;AAC9C,6EAA6E;AAC7E,sDAAsD;AACtD,cAAc,gCAA4B;AAC1C,6EAA6E;AAC7E,sEAAsE;AACtE,cAAc,8BAA0B;AACxC,0EAA0E;AAC1E,+DAA+D;AAC/D,wEAAwE;AACxE,cAAc,2BAAuB;AACrC,2EAA2E;AAC3E,yEAAyE;AACzE,2CAA2C;AAC3C,cAAc,yBAAqB;AACnC,cAAc,+BAA2B"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../libs/shared/util/email/src/index.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport * from './lib/send-email'\n// Who carries the mail (AGL-3080): the provider contract, and the selection\n// of the deployment's provider from the built-ins and any a plugin\n// registered. The providers themselves are imported by their own paths —\n// `@aglyn/shared-util-email/mail-provider-resend`, `…/mail-provider-webhook`\n// — because nothing outside the seam should name one.\nexport * from './lib/mail-provider'\nexport * from './lib/mail-providers'\nexport * from './lib/send-rate'\nexport * from './lib/sender-reputation'\nexport * from './lib/send-ceilings'\nexport * from './lib/sending-domain'\nexport * from './lib/tracking-host'\nexport * from './lib/sending-mailbox'\nexport * from './lib/host-sender'\nexport * from './lib/platform-sending-domain'\nexport * from './lib/email-health'\nexport * from './lib/system-email-catalog'\nexport * from './lib/retention-emails'\nexport * from './lib/welcome-email'\nexport * from './lib/tenant-email-catalog'\nexport * from './lib/host-email-render'\nexport * from './lib/email-render'\nexport * from './lib/text-email-html'\nexport * from './lib/marketing-send'\n// The List-Unsubscribe setting sequences and campaigns share (AGL-3307).\nexport * from './lib/list-unsubscribe'\nexport * from './lib/email-delivery-events'\n// Received mail in the platform's vocabulary, which the CRM's capture route\n// files from (AGL-2657); the provider reads it.\n// Its neighbor `./lib/svix-signature` is deliberately NOT re-exported here:\n// it holds a `crypto` HMAC, and this barrel is reached from the browser\n// through `@aglyn/shared-ui-email-campaigns`, so a webhook imports it by its\n// own path — `@aglyn/shared-util-email/svix-signature`.\nexport * from './lib/received-email'\nexport * from './lib/email-revenue-window'\n// Exported so the console drift guard can pin it against @aglyn/aglyn.\nexport * from './lib/email-media-src'\n// Same arrangement, same reason (AGL-1223): a copy of `decodeStoredNodes`\n// this scope:shared lib may not import, pinned by `email-nodes-drift.spec.ts`.\nexport * from './lib/stored-email-nodes'\nexport * from './lib/email-merge'\n// The deliverability engine every send path asks (AGL-3328): the gateway an\n// MX names and its ledger, the bounce reader, and the address verdicts. Pure\n// — the DNS lookup and the store are injected by `@aglyn/tenant-data-admin`,\n// so nothing here reaches `node:dns` from the browser.\nexport * from './lib/mail-gateway'\nexport * from './lib/mail-bounce'\nexport * from './lib/email-deliverability'\n// The sender's side of the same engine (AGL-3328): SPF, DKIM and DMARC for\n// the domain mail leaves from, and whether they align. Pure as well; the\n// lookups are `@aglyn/tenant-data-admin`'s.\nexport * from './lib/sender-readiness'\n// The outbound phishing screen a young workspace's campaigns and automated\n// email pass (AGL-3356). Pure; the hold it leads to is `tenant-data-admin`'s.\nexport * from './lib/outbound-phishing-screen'\n// The send seam's gate for that screen — the store a hold writes is injected\n// by `@aglyn/tenant-data-admin`, like the governor's.\nexport * from './lib/outbound-screen-gate'\n// The same screen read over a published page (AGL-3356): lookalike links and\n// embeds, author-defined credential fields, a brand's call to action.\nexport * from './lib/hosted-page-screen'\n// The reputation lookup every foreign link a page, an email or a redirect\n// points at passes (AGL-3451). Pure; the lookup is injected by\n// `@aglyn/tenant-data-admin`, which holds the credential and the cache.\nexport * from './lib/link-reputation'\n// The site's theme palette as plain data (AGL-3370), so a palette token an\n// author picked resolves in mail. Built without MUI; `shared-ui-theme`'s\n// parity spec holds it equal to the theme.\nexport * from './lib/email-palette'\nexport * from './lib/email-design-chrome'\n"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED,cAAc,sBAAkB;AAChC,4EAA4E;AAC5E,mEAAmE;AACnE,yEAAyE;AACzE,6EAA6E;AAC7E,sDAAsD;AACtD,cAAc,yBAAqB;AACnC,cAAc,0BAAsB;AACpC,cAAc,qBAAiB;AAC/B,cAAc,6BAAyB;AACvC,cAAc,yBAAqB;AACnC,cAAc,0BAAsB;AACpC,cAAc,yBAAqB;AACnC,cAAc,2BAAuB;AACrC,cAAc,uBAAmB;AACjC,cAAc,mCAA+B;AAC7C,cAAc,wBAAoB;AAClC,cAAc,gCAA4B;AAC1C,cAAc,4BAAwB;AACtC,cAAc,yBAAqB;AACnC,cAAc,gCAA4B;AAC1C,cAAc,6BAAyB;AACvC,cAAc,wBAAoB;AAClC,cAAc,2BAAuB;AACrC,cAAc,0BAAsB;AACpC,yEAAyE;AACzE,cAAc,4BAAwB;AACtC,cAAc,iCAA6B;AAC3C,4EAA4E;AAC5E,gDAAgD;AAChD,4EAA4E;AAC5E,wEAAwE;AACxE,6EAA6E;AAC7E,wDAAwD;AACxD,cAAc,0BAAsB;AACpC,cAAc,gCAA4B;AAC1C,uEAAuE;AACvE,cAAc,2BAAuB;AACrC,0EAA0E;AAC1E,+EAA+E;AAC/E,cAAc,8BAA0B;AACxC,cAAc,uBAAmB;AACjC,4EAA4E;AAC5E,6EAA6E;AAC7E,6EAA6E;AAC7E,uDAAuD;AACvD,cAAc,wBAAoB;AAClC,cAAc,uBAAmB;AACjC,cAAc,gCAA4B;AAC1C,2EAA2E;AAC3E,yEAAyE;AACzE,4CAA4C;AAC5C,cAAc,4BAAwB;AACtC,2EAA2E;AAC3E,8EAA8E;AAC9E,cAAc,oCAAgC;AAC9C,6EAA6E;AAC7E,sDAAsD;AACtD,cAAc,gCAA4B;AAC1C,6EAA6E;AAC7E,sEAAsE;AACtE,cAAc,8BAA0B;AACxC,0EAA0E;AAC1E,+DAA+D;AAC/D,wEAAwE;AACxE,cAAc,2BAAuB;AACrC,2EAA2E;AAC3E,yEAAyE;AACzE,2CAA2C;AAC3C,cAAc,yBAAqB;AACnC,cAAc,+BAA2B"}
|
|
@@ -122,6 +122,18 @@ export interface EmailRenderOptions {
|
|
|
122
122
|
* the Besigner canvas draws the button with. Absent is MUI's default, 4.
|
|
123
123
|
*/
|
|
124
124
|
buttonRadius?: number;
|
|
125
|
+
/**
|
|
126
|
+
* How a button's label is set: the theme's own button type — its case,
|
|
127
|
+
* weight and letter spacing — so a button reads like the buttons on the
|
|
128
|
+
* console or the site it comes from (AGL-3897). Absent, mixed case at 600.
|
|
129
|
+
*/
|
|
130
|
+
buttonText?: EmailButtonText;
|
|
131
|
+
}
|
|
132
|
+
/** A button label's type, from a theme's `typography.button`. */
|
|
133
|
+
export interface EmailButtonText {
|
|
134
|
+
transform?: 'uppercase' | 'none' | 'capitalize' | 'lowercase';
|
|
135
|
+
weight?: number;
|
|
136
|
+
letterSpacing?: string;
|
|
125
137
|
}
|
|
126
138
|
/**
|
|
127
139
|
* The row above the body that says who sent the mail.
|
|
@@ -179,7 +191,7 @@ export interface EmailChrome {
|
|
|
179
191
|
* every color an author picked and colors what they did not, and its button
|
|
180
192
|
* radius. Spread into {@link EmailRenderOptions}.
|
|
181
193
|
*/
|
|
182
|
-
export type EmailTheme = Pick<EmailRenderOptions, 'palette' | 'buttonRadius'>;
|
|
194
|
+
export type EmailTheme = Pick<EmailRenderOptions, 'palette' | 'buttonRadius' | 'buttonText'>;
|
|
183
195
|
export interface RenderedEmail {
|
|
184
196
|
html: string;
|
|
185
197
|
text: string;
|
|
@@ -187,6 +199,15 @@ export interface RenderedEmail {
|
|
|
187
199
|
export declare function escapeEmailHtml(value: string): string;
|
|
188
200
|
/** Substitutes {{token}} occurrences; unknown tokens stay visible. */
|
|
189
201
|
export declare function substituteMergeTokens(value: string, merge: Record<string, string> | undefined): string;
|
|
202
|
+
/**
|
|
203
|
+
* One line of a details panel split into its label and its value: at the
|
|
204
|
+
* first ": " ("Device: Chrome on macOS"), else at the last " — " ("House
|
|
205
|
+
* Blend × 2 — $24.00"). A line with neither is drawn across both columns.
|
|
206
|
+
*/
|
|
207
|
+
export declare function splitEmailDetailLine(line: string): {
|
|
208
|
+
label: string;
|
|
209
|
+
value: string;
|
|
210
|
+
} | null;
|
|
190
211
|
/**
|
|
191
212
|
* The id the besigner roots every stored node map at — `CANVAS_ROOT_ELEMENT_ID`
|
|
192
213
|
* in `@aglyn/aglyn`. `renderEmailHtml` still defaults `rootId` to `'root'` for
|
package/src/lib/email-render.js
CHANGED
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
* page is the ordinary way that happens.
|
|
44
44
|
*/ import { hasSafeLinkScheme, hasSafeMediaScheme } from "@aglyn/shared-util-http/safe-url-scheme";
|
|
45
45
|
import { linkifyEscapedText } from "./email-linkify.js";
|
|
46
|
-
import { emailAccent, resolveEmailColor } from "./email-palette.js";
|
|
46
|
+
import { emailAccent, PLATFORM_EMAIL_PALETTE, resolveEmailColor } from "./email-palette.js";
|
|
47
47
|
import { resolveEmailMediaSrc } from "./email-media-src.js";
|
|
48
48
|
const FONT = 'Helvetica, Arial, sans-serif';
|
|
49
49
|
/**
|
|
@@ -73,8 +73,45 @@ const TEXT_STYLES = {
|
|
|
73
73
|
heading: `font-size:28px;font-weight:700;line-height:1.25`,
|
|
74
74
|
subheading: `font-size:20px;font-weight:600;line-height:1.3`,
|
|
75
75
|
body: `font-size:15px;font-weight:400;line-height:1.55`,
|
|
76
|
-
caption: `font-size:12px;font-weight:400;line-height:1.
|
|
76
|
+
caption: `font-size:12px;font-weight:400;line-height:1.5`,
|
|
77
|
+
// A small label above a heading saying what the email is about: the site,
|
|
78
|
+
// the workspace (AGL-3897).
|
|
79
|
+
eyebrow: `font-size:12px;font-weight:700;line-height:1.4;letter-spacing:0.06em;text-transform:uppercase`,
|
|
80
|
+
// The rows of a details panel; see `detailsHtml`.
|
|
81
|
+
details: `font-size:14px;font-weight:400;line-height:1.45`,
|
|
82
|
+
// A list of next steps or help, each a link; see `linksHtml`.
|
|
83
|
+
links: `font-size:15px;font-weight:600;line-height:1.4`
|
|
77
84
|
};
|
|
85
|
+
/** The space around each text style's row: a heading needs room below it, an eyebrow sits tight above one. */ const TEXT_PADDING = {
|
|
86
|
+
heading: 'padding:4px 0 10px;',
|
|
87
|
+
subheading: 'padding:14px 0 4px;',
|
|
88
|
+
body: 'padding:5px 0;',
|
|
89
|
+
caption: 'padding:5px 0;',
|
|
90
|
+
eyebrow: 'padding:0 0 2px;',
|
|
91
|
+
details: 'padding:10px 0;',
|
|
92
|
+
links: 'padding:8px 0;'
|
|
93
|
+
};
|
|
94
|
+
/** A details value longer than this reads as a paragraph under its label rather than beside it. */ const DETAIL_INLINE_MAX = 48;
|
|
95
|
+
/** The styles whose words are secondary, drawn in the theme's muted text color unless a color is set. */ const MUTED_TEXT_STYLES = new Set([
|
|
96
|
+
'caption'
|
|
97
|
+
]);
|
|
98
|
+
/**
|
|
99
|
+
* One line of a details panel split into its label and its value: at the
|
|
100
|
+
* first ": " ("Device: Chrome on macOS"), else at the last " — " ("House
|
|
101
|
+
* Blend × 2 — $24.00"). A line with neither is drawn across both columns.
|
|
102
|
+
*/ export function splitEmailDetailLine(line) {
|
|
103
|
+
const colon = line.indexOf(': ');
|
|
104
|
+
if (colon > 0 && colon <= 48) return {
|
|
105
|
+
label: line.slice(0, colon).trim(),
|
|
106
|
+
value: line.slice(colon + 2).trim()
|
|
107
|
+
};
|
|
108
|
+
const dash = line.lastIndexOf(' — ');
|
|
109
|
+
if (dash > 0) return {
|
|
110
|
+
label: line.slice(0, dash).trim(),
|
|
111
|
+
value: line.slice(dash + 3).trim()
|
|
112
|
+
};
|
|
113
|
+
return null;
|
|
114
|
+
}
|
|
78
115
|
/** One full-width table row wrapping arbitrary cell HTML. */ const row = (cellHtml, cellStyle = '')=>`<tr><td style="${cellStyle}">${cellHtml}</td></tr>`;
|
|
79
116
|
/**
|
|
80
117
|
* The id the besigner roots every stored node map at — `CANVAS_ROOT_ELEMENT_ID`
|
|
@@ -87,8 +124,10 @@ const TEXT_STYLES = {
|
|
|
87
124
|
export function renderEmailHtml(options) {
|
|
88
125
|
var _imageSrc, _ref;
|
|
89
126
|
var _nodes_rootId;
|
|
90
|
-
const { nodes, rootId = 'root', subject = '', preheader = '', merge, products, sanitize, mediaOrigin, mediaHostId, brandLogoUrl, chrome, palette, buttonRadius } = options;
|
|
127
|
+
const { nodes, rootId = 'root', subject = '', preheader = '', merge, products, sanitize, mediaOrigin, mediaHostId, brandLogoUrl, chrome, palette, buttonRadius, buttonText } = options;
|
|
91
128
|
const radius = Number.isFinite(buttonRadius) && Number(buttonRadius) >= 0 ? Math.min(Number(buttonRadius), 48) : 4;
|
|
129
|
+
const labelWeight = Number.isFinite(buttonText == null ? void 0 : buttonText.weight) && Number(buttonText == null ? void 0 : buttonText.weight) >= 100 ? Number(buttonText == null ? void 0 : buttonText.weight) : 600;
|
|
130
|
+
const labelCase = ((buttonText == null ? void 0 : buttonText.transform) && /^(uppercase|none|capitalize|lowercase)$/.test(buttonText.transform) ? `text-transform:${buttonText.transform};` : '') + ((buttonText == null ? void 0 : buttonText.letterSpacing) && /^-?[\d.]+(em|px|rem)$/.test(buttonText.letterSpacing) ? `letter-spacing:${buttonText.letterSpacing};` : '');
|
|
92
131
|
/**
|
|
93
132
|
* A stored color, resolved: a palette token against the theme, a literal
|
|
94
133
|
* as written, anything else to the fallback. The only way a color prop
|
|
@@ -98,6 +137,74 @@ export function renderEmailHtml(options) {
|
|
|
98
137
|
var _resolveEmailColor;
|
|
99
138
|
return (_resolveEmailColor = resolveEmailColor(value, palette)) != null ? _resolveEmailColor : fallback;
|
|
100
139
|
};
|
|
140
|
+
/** A theme token's color, from the email's palette, else the platform's, which resolves every one. */ const themeColor = (token)=>{
|
|
141
|
+
var _ref, _resolveEmailColor;
|
|
142
|
+
return (_ref = (_resolveEmailColor = resolveEmailColor(token, palette)) != null ? _resolveEmailColor : resolveEmailColor(token, PLATFORM_EMAIL_PALETTE)) != null ? _ref : 'inherit';
|
|
143
|
+
};
|
|
144
|
+
/**
|
|
145
|
+
* A list of links (AGL-3897): each "Label — https://…" line a row whose
|
|
146
|
+
* label is the link, in the theme's link color, with an arrow after it and
|
|
147
|
+
* a hairline between rows — next steps, help pages. A line with no address
|
|
148
|
+
* is drawn as plain text; an address the link check refuses drops the link
|
|
149
|
+
* and keeps the words.
|
|
150
|
+
*/ const linksHtml = (text, style)=>{
|
|
151
|
+
const rule = themeColor('divider');
|
|
152
|
+
const lines = text.split('\n').map((line)=>line.trim()).filter(Boolean);
|
|
153
|
+
const rows = lines.map((line, index)=>{
|
|
154
|
+
const split = splitEmailDetailLine(line);
|
|
155
|
+
const href = split ? linkHref(split.value) : undefined;
|
|
156
|
+
const label = escapeEmailHtml(split ? split.label : line);
|
|
157
|
+
const border = index > 0 ? `border-top:1px solid ${rule};` : '';
|
|
158
|
+
const inner = href ? `<a href="${escapeEmailHtml(href)}" target="_blank" style="color:${accent.link};text-decoration:none;">${label} →</a>` : `<span style="color:${themeColor('text.primary')};">${label}</span>`;
|
|
159
|
+
return `<tr><td style="font-family:${FONT};${style};padding:10px 0;${border}">${inner}</td></tr>`;
|
|
160
|
+
});
|
|
161
|
+
return `<table role="presentation" width="100%" cellpadding="0" cellspacing="0">${rows.join('')}</table>`;
|
|
162
|
+
};
|
|
163
|
+
/**
|
|
164
|
+
* A details panel (AGL-3897): each line a row, its label muted on the left
|
|
165
|
+
* and its value on the right, on a tinted ground with a hairline between
|
|
166
|
+
* rows. A row whose label begins "Total" is the sum of the rows above it,
|
|
167
|
+
* so it is drawn bold with a rule over it. A line that empties out — a
|
|
168
|
+
* token the send left blank — draws no row.
|
|
169
|
+
*/ const detailsHtml = (text, style, valueColor)=>{
|
|
170
|
+
var _resolveEmailColor;
|
|
171
|
+
const muted = themeColor('text.secondary');
|
|
172
|
+
const rule = themeColor('divider');
|
|
173
|
+
// A line whose value a token left blank ("Location:") is not drawn.
|
|
174
|
+
const lines = text.split('\n').map((line)=>line.trim()).filter((line)=>line && !line.endsWith(':'));
|
|
175
|
+
const cell = (value)=>linkifyEscapedText(escapeEmailHtml(value), accent.link).replace(/\n/g, '<br />');
|
|
176
|
+
// A line with no label of its own continues the value above it: a form
|
|
177
|
+
// answer that ran over two lines is one row, not two.
|
|
178
|
+
const entries = [];
|
|
179
|
+
for (const line of lines){
|
|
180
|
+
const split = splitEmailDetailLine(line);
|
|
181
|
+
const last = entries[entries.length - 1];
|
|
182
|
+
if (!split && (last == null ? void 0 : last.label)) last.value += `\n${line}`;
|
|
183
|
+
else entries.push(split ? {
|
|
184
|
+
label: split.label,
|
|
185
|
+
value: split.value
|
|
186
|
+
} : {
|
|
187
|
+
label: null,
|
|
188
|
+
value: line
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
const rows = entries.map((entry, index)=>{
|
|
192
|
+
const total = Boolean(entry.label && /^total\b/i.test(entry.label));
|
|
193
|
+
const border = index > 0 ? `border-top:1px solid ${rule};` : '';
|
|
194
|
+
const base = `font-family:${FONT};${style};padding:9px 0;vertical-align:top;${border}`;
|
|
195
|
+
if (!entry.label) {
|
|
196
|
+
return `<tr><td colspan="2" style="${base}color:${valueColor};">${cell(entry.value)}</td></tr>`;
|
|
197
|
+
}
|
|
198
|
+
// A long answer — a message, a note — reads as a paragraph under its
|
|
199
|
+
// label, not as a bold run squeezed against the right edge.
|
|
200
|
+
if (!total && (entry.value.length > DETAIL_INLINE_MAX || entry.value.includes('\n'))) {
|
|
201
|
+
return `<tr><td colspan="2" style="${base}">` + `<div style="color:${muted};padding-bottom:2px;">${cell(entry.label)}</div>` + `<div style="color:${valueColor};">${cell(entry.value)}</div>` + `</td></tr>`;
|
|
202
|
+
}
|
|
203
|
+
return `<tr>` + `<td style="${base}color:${total ? valueColor : muted};${total ? 'font-weight:700;' : ''}padding-right:16px;">${cell(entry.label)}</td>` + `<td style="${base}color:${valueColor};font-weight:${total ? 700 : 600};text-align:right;word-break:break-word;">${cell(entry.value)}</td>` + `</tr>`;
|
|
204
|
+
});
|
|
205
|
+
return `<table role="presentation" width="100%" cellpadding="0" cellspacing="0" ` + // On the theme's primary tint, the brand's own light ground.
|
|
206
|
+
`style="background-color:${(_resolveEmailColor = resolveEmailColor('tint.primary', palette)) != null ? _resolveEmailColor : themeColor('grey.50')};border-radius:8px;">` + `<tr><td style="padding:4px 16px;">` + `<table role="presentation" width="100%" cellpadding="0" cellspacing="0">${rows.join('')}</table>` + `</td></tr></table>`;
|
|
207
|
+
};
|
|
101
208
|
/**
|
|
102
209
|
* The theme's accent, for what the author left unset: the fill, its label,
|
|
103
210
|
* and the accent AS TEXT (`primary.dark`, where the fill itself may be too
|
|
@@ -211,17 +318,30 @@ export function renderEmailHtml(options) {
|
|
|
211
318
|
}
|
|
212
319
|
case 'emailText':
|
|
213
320
|
{
|
|
214
|
-
var
|
|
215
|
-
const
|
|
321
|
+
var _TEXT_PADDING_variant;
|
|
322
|
+
const merged = sub(props.children);
|
|
323
|
+
// An eyebrow is a few parts joined by " · "; one a token left empty
|
|
324
|
+
// ("{{host.businessName}} · Order #1042" on a site with no name) loses
|
|
325
|
+
// its separator rather than starting with one.
|
|
326
|
+
const text = props.variant === 'eyebrow' ? merged.replace(/^(\s*·\s*)+|(\s*·\s*)+$/g, '').replace(/(\s*·\s*){2,}/g, ' · ') : merged;
|
|
216
327
|
// A block whose copy is only a token the send left empty (a
|
|
217
328
|
// notification with no detail line, AGL-3367) draws nothing, rather
|
|
218
329
|
// than an empty row and a blank paragraph in the text part.
|
|
219
330
|
if (!text.trim()) return '';
|
|
220
331
|
textParts.push(text);
|
|
221
|
-
const
|
|
222
|
-
const
|
|
332
|
+
const variant = TEXT_STYLES[props.variant] ? props.variant : 'body';
|
|
333
|
+
const style = TEXT_STYLES[variant];
|
|
334
|
+
// Unpicked, secondary words take the theme's muted text, and an
|
|
335
|
+
// eyebrow its brand color in the shade that reads as text.
|
|
336
|
+
const color = props.color ? colorOf(props.color, '#1a1a1a') : variant === 'eyebrow' ? themeColor('primary.dark') : MUTED_TEXT_STYLES.has(variant) ? themeColor('text.secondary') : '#1a1a1a';
|
|
223
337
|
const align = props.align || 'left';
|
|
224
|
-
|
|
338
|
+
if (variant === 'links') {
|
|
339
|
+
return row(linksHtml(text, style), TEXT_PADDING['links']);
|
|
340
|
+
}
|
|
341
|
+
if (variant === 'details') {
|
|
342
|
+
return row(detailsHtml(text, style, props.color ? color : themeColor('text.primary')), TEXT_PADDING['details']);
|
|
343
|
+
}
|
|
344
|
+
return row(`<div style="font-family:${FONT};${style};color:${color};text-align:${align};">` + linkifyEscapedText(escapeEmailHtml(text), accent.link).replace(/\n/g, '<br />') + `</div>`, (_TEXT_PADDING_variant = TEXT_PADDING[variant]) != null ? _TEXT_PADDING_variant : TEXT_PADDING['body']);
|
|
225
345
|
}
|
|
226
346
|
case 'emailRichtext':
|
|
227
347
|
case 'emailHtml':
|
|
@@ -248,6 +368,11 @@ export function renderEmailHtml(options) {
|
|
|
248
368
|
case 'emailButton':
|
|
249
369
|
{
|
|
250
370
|
var _props_children, _linkHref, _props_href;
|
|
371
|
+
// A button written as merge tokens that the send left empty is one
|
|
372
|
+
// this email has nothing to point at (an alert about no one item),
|
|
373
|
+
// so it is left out rather than drawn going nowhere.
|
|
374
|
+
const tokenOnly = (value)=>/\{\{[^}]+\}\}/.test(String(value != null ? value : '')) && !sub(value).trim();
|
|
375
|
+
if (tokenOnly(props.href) || tokenOnly(props.children)) return '';
|
|
251
376
|
const label = sub((_props_children = props.children) != null ? _props_children : 'Call to action');
|
|
252
377
|
// A refused href falls back to the placeholder the empty case already
|
|
253
378
|
// uses, so the button keeps its place in the layout and goes nowhere.
|
|
@@ -262,7 +387,7 @@ export function renderEmailHtml(options) {
|
|
|
262
387
|
const align = props.align || 'center';
|
|
263
388
|
textParts.push(`${label}: ${href}`);
|
|
264
389
|
// Bulletproof-ish button: padded anchor, table-aligned.
|
|
265
|
-
return row(`<a href="${escapeEmailHtml(href)}" target="_blank" ` + `style="display:inline-block;padding:12px 28px;border-radius:${radius}px;` + `background-color:${background};color:${color};font-family:${FONT};` + `font-size:15px;font-weight
|
|
390
|
+
return row(`<a href="${escapeEmailHtml(href)}" target="_blank" ` + `style="display:inline-block;padding:12px 28px;border-radius:${radius}px;` + `background-color:${background};color:${color};font-family:${FONT};` + `font-size:15px;font-weight:${labelWeight};text-decoration:none;${labelCase}">` + escapeEmailHtml(label) + `</a>`, `padding:12px 0;text-align:${align};`);
|
|
266
391
|
}
|
|
267
392
|
case 'emailDivider':
|
|
268
393
|
{
|
|
@@ -394,7 +519,10 @@ export function renderEmailHtml(options) {
|
|
|
394
519
|
return row(htmlLines.map((line, index)=>`<div style="font-family:${FONT};font-size:12px;font-weight:400;line-height:1.4;color:${CHROME_PALETTE.caption};` + `${index ? 'margin-top:8px;' : ''}">${line.replace(/\n/g, '<br />')}</div>`).join(''), `padding:24px;text-align:center;background-color:${CHROME_PALETTE.band};`);
|
|
395
520
|
};
|
|
396
521
|
const footerHtml = (chrome == null ? void 0 : chrome.footer) ? renderChromeFooter(chrome.footer) : '';
|
|
397
|
-
const html = `<!DOCTYPE html><html><head><meta charset="utf-8" />` + `<meta name="viewport" content="width=device-width, initial-scale=1" />` +
|
|
522
|
+
const html = `<!DOCTYPE html><html><head><meta charset="utf-8" />` + `<meta name="viewport" content="width=device-width, initial-scale=1" />` + // Drawn for a light ground in the theme's colors: a client that offers
|
|
523
|
+
// its own dark rendering (Apple Mail) is asked to show it as designed
|
|
524
|
+
// rather than invert the brand's colors (AGL-3897).
|
|
525
|
+
`<meta name="color-scheme" content="light only" />` + `<meta name="supported-color-schemes" content="light only" />` + `<style>:root{color-scheme:light only;supported-color-schemes:light only;}</style>` + `<title>${escapeEmailHtml(sub(subject))}</title></head>` + `<body style="margin:0;padding:0;background-color:#f4f4f4;">` + preheaderHtml + `<table role="presentation" width="100%" cellpadding="0" cellspacing="0" style="background-color:#f4f4f4;">` + row(`<table role="presentation" width="600" cellpadding="0" cellspacing="0" align="center" style="max-width:600px;width:100%;margin:0 auto;">` + headerHtml + body + footerHtml + `</table>`, 'padding:24px 8px;') + `</table></body></html>`;
|
|
398
526
|
return {
|
|
399
527
|
html,
|
|
400
528
|
text: textParts.join('\n\n')
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../libs/shared/util/email/src/lib/email-render.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Email render pipeline (AGL-348): converts a designed email screen's\n * node map into email-client-compatible HTML (600px table layout,\n * inlined styles, bulletproof buttons) plus a plain-text alternative.\n * Pure — no I/O; callers resolve products/merge data first.\n *\n * Merge tokens ({{contact.firstName}}, {{unsubscribeUrl}}, …) substitute\n * from the provided map; unknown tokens are left in place so a missing\n * field is visible in test sends instead of silently blank.\n *\n * ## The safety contract, in one place\n *\n * Everything this emits is author-controlled, and it is emitted into mail\n * that has left the building. Three rules, all applied here rather than\n * left to a caller:\n *\n * 1. Block HTML goes through {@link EmailRenderOptions.sanitize}, which is\n * REQUIRED. There is no identity default to fall back into.\n * 2. Every URL is scheme-checked against `@aglyn/shared-util-http` before it\n * is escaped into an attribute — escaping stops an attribute breakout and\n * says nothing at all about `javascript:`.\n * 3. Merge substitution into a URL cannot draw from the `contact.` namespace,\n * so no template can route a recipient's own address into a query string.\n *\n * Mail clients strip most of this themselves, so none of the three is the\n * last line of defense in an inbox. They are the only line the moment one of\n * these documents renders outside one — a \"view this email in your browser\"\n * page is the ordinary way that happens.\n */\n\nimport {\n hasSafeLinkScheme,\n hasSafeMediaScheme,\n} from '@aglyn/shared-util-http/safe-url-scheme'\n\nimport { linkifyEscapedText } from './email-linkify'\nimport { emailAccent, resolveEmailColor, type EmailPalette } from './email-palette'\nimport { resolveEmailMediaSrc } from './email-media-src'\n\nexport interface EmailRenderProduct {\n name: string\n priceLabel?: string\n imageUrl?: string\n url?: string\n}\n\nexport interface EmailRenderNode {\n componentId?: string\n props?: Record<string, any>\n nodes?: string[]\n}\n\nexport interface EmailRenderOptions {\n /** Flat node map (screen version `nodes`). */\n nodes: Record<string, EmailRenderNode | undefined>\n /** Root node id (defaults to 'root'). */\n rootId?: string\n subject?: string\n /** Hidden preview line shown next to the subject in inboxes. */\n preheader?: string\n /** Merge values keyed by token body, e.g. 'contact.firstName'. */\n merge?: Record<string, string>\n /** Product data by id for emailProduct blocks. */\n products?: Record<string, EmailRenderProduct | undefined>\n /**\n * The HTML policy applied to every `emailRichtext` / `emailHtml` block.\n *\n * REQUIRED, and required is the point. A policy a caller may omit is a\n * policy that gets omitted, and an omitted one here is not a rendering\n * bug: the console renders these same nodes through `sanitizeCustomHtml`\n * before an author ever sees them, so an unpoliced mail render means two\n * renderers of one document disagreeing about safety, with the unsafe one\n * being the one that sends.\n *\n * This module cannot pick the policy for itself — it is `scope:shared` and\n * the sanitizer is aglyn-scoped, which nx forbids it to import — so the\n * choice belongs to the caller, and the type is what makes the caller make\n * it. Every send path passes `sanitizeAuthorHtml`, which is exactly what\n * `sanitizeCustomHtml` delegates to, so the mailed copy and the previewed\n * copy are the same function of the same string.\n */\n sanitize: (html: string) => string\n /**\n * Absolute origin serving this email's media, e.g. `https://acme.com`\n * (AGL-1224).\n *\n * An image an author picked with \"Browse media\" is stored as a\n * `media:{scope}/{mediaId}` reference, which resolves to the SITE-RELATIVE\n * CDN path `/api/media/cdn/…`. A browser has a page to resolve that\n * against; an inbox has nothing. Without this, every picked image is a\n * broken-image box in the delivered mail.\n *\n * It is an input rather than a lookup because this module is pure, and\n * because the CDN route is mounted in BOTH the console and the tenant app\n * — which origin is correct depends on whose email this is.\n */\n mediaOrigin?: string\n /**\n * Host doc id of the site sending, so an `org:`-scoped reference is\n * host-qualified. The CDN is unauthenticated and decides from the URL\n * alone, so an org asset restricted to particular sites is only served\n * through the qualified form.\n */\n mediaHostId?: string\n /**\n * Absolute URL of the sender's EMAIL logo, prepended as a centred row at\n * the top of the 600px table (AGL-2139).\n *\n * `emailLogoUrl` was a first-class field of `OrgBrandingProfile`, resolved,\n * collected in the branding editor, https-validated and persisted — and read\n * at ZERO render sites. An agency admin on the tier that costs the most\n * filled it in, the form saved, the value round-tripped, and it appeared in\n * no email ever. This is the consumer that makes it a live capability\n * rather than a stored string.\n *\n * Absent or blank emits NOTHING — not an empty row, not a spacer. An email\n * with a gap where a logo should be reads as broken; one without a logo\n * reads as plain, which is the correct appearance for an org that has not\n * set one.\n *\n * Ignored when {@link EmailRenderOptions.chrome} carries a header: that\n * header is the logo row, and a caller that has one passes the org's logo\n * through it, so a message never opens with two.\n */\n brandLogoUrl?: string\n /**\n * The sender's header and footer, drawn around the body (AGL-3322). See\n * {@link EmailChrome}. Absent draws neither.\n */\n chrome?: EmailChrome\n /**\n * The theme the email is sent under (AGL-3370): the console brand for the\n * platform's own mail, a white-label org's color over it, or the site's\n * theme for a site's mail. See {@link buildEmailPalette}.\n *\n * It does two things. A color an author picked in the Besigner is stored as\n * a palette token (`primary.main`), which a mail client cannot resolve, so\n * every color prop is resolved against this before it is written. And\n * what nobody picked (a button's fill and label, a link) takes the theme's\n * accent rather than a color of the renderer's own. Absent keeps the\n * renderer's neutral defaults and drops an unresolvable token.\n */\n palette?: EmailPalette\n /**\n * A button's corner radius in px: the theme's `shape.borderRadius`, which\n * the Besigner canvas draws the button with. Absent is MUI's default, 4.\n */\n buttonRadius?: number\n}\n\n/**\n * The row above the body that says who sent the mail.\n *\n * `logoAlt` is required because it does two jobs. It is the logo's `alt`,\n * which is what most inboxes show, since they block images by default. And\n * it is the header itself when there is no logo to draw — none was given, or\n * the one given cannot be fetched from an inbox — so the sender is named in\n * bold text rather than by a broken-image box.\n */\nexport interface EmailChromeHeader {\n /** The logo. Resolved and scheme-checked like every other image here. */\n logoUrl?: string\n /** The sender's name: the logo's alt text, or the header when no logo draws. */\n logoAlt: string\n /** Where the logo or name links. A refused scheme drops the link, not the header. */\n href?: string\n}\n\n/**\n * The rows under the body, in the order they draw. Each is optional, and a\n * footer with none of them draws nothing.\n */\nexport interface EmailChromeFooter {\n /** Why the recipient is getting this mail. */\n reason?: string\n /** Where to get help. Drawn as a link; dropped whole when the href is refused. */\n support?: { label: string; href: string }\n /** Who sent it, and from where: a copyright and postal line. */\n legal?: string\n}\n\n/**\n * A sender's header and footer, drawn by the renderer rather than placed by a\n * designer (AGL-3322).\n *\n * For mail whose body carries no header or footer of its own: a system\n * email's built-in copy, or a design sent under a brand whose own blocks it\n * may not carry. The caller decides WHICH brand; this only draws.\n *\n * Every string goes through the same merge substitution as the body, so\n * `{{org.name}}` in a footer line reads as the organization it names, and is\n * escaped like body text. Every URL goes through the same scheme checks as a\n * body link or image. The footer lines are appended to the plain-text part\n * too, the support link as its bare address, because a reader of that part is\n * owed the same reason and the same way to get help.\n */\nexport interface EmailChrome {\n header?: EmailChromeHeader\n footer?: EmailChromeFooter\n}\n\n/**\n * The theme an email is drawn in (AGL-3370): its palette, which resolves\n * every color an author picked and colors what they did not, and its button\n * radius. Spread into {@link EmailRenderOptions}.\n */\nexport type EmailTheme = Pick<EmailRenderOptions, 'palette' | 'buttonRadius'>\n\nexport interface RenderedEmail {\n html: string\n text: string\n}\n\nconst FONT = 'Helvetica, Arial, sans-serif'\n\n/**\n * The colours the chrome is drawn in (AGL-3322), named once.\n *\n * Literal because this is email HTML: mail clients strip `<style>` and read no\n * CSS variables, so no theme token reaches the wire. They are the values\n * already in the mail, not new ones — the ink and card of a default body\n * block, and the band and caption grey of the email footer block the\n * platform's own mail wears — so the chrome and the body it frames agree.\n */\nconst CHROME_PALETTE = {\n /** The sender's name in the header: body text's ink. */\n ink: '#1a1a1a',\n /** The header band: a default section's card. */\n card: '#ffffff',\n /** The footer band. */\n band: '#F8F9FA',\n /** Footer lines and the support link. */\n caption: '#757575',\n} as const\n\nexport function escapeEmailHtml(value: string): string {\n return value\n .replace(/&/g, '&')\n .replace(/</g, '<')\n .replace(/>/g, '>')\n .replace(/\"/g, '"')\n}\n\n/** Substitutes {{token}} occurrences; unknown tokens stay visible. */\nexport function substituteMergeTokens(\n value: string,\n merge: Record<string, string> | undefined,\n): string {\n return value.replace(/\\{\\{\\s*([\\w.]+)\\s*\\}\\}/g, (match, token: string) => {\n const replacement = merge?.[token]\n return replacement !== undefined ? replacement : match\n })\n}\n\nconst TEXT_STYLES: Record<string, string> = {\n heading: `font-size:28px;font-weight:700;line-height:1.25`,\n subheading: `font-size:20px;font-weight:600;line-height:1.3`,\n body: `font-size:15px;font-weight:400;line-height:1.55`,\n caption: `font-size:12px;font-weight:400;line-height:1.4`,\n}\n\n/** One full-width table row wrapping arbitrary cell HTML. */\nconst row = (cellHtml: string, cellStyle = ''): string =>\n `<tr><td style=\"${cellStyle}\">${cellHtml}</td></tr>`\n\n/**\n * The id the besigner roots every stored node map at — `CANVAS_ROOT_ELEMENT_ID`\n * in `@aglyn/aglyn`. `renderEmailHtml` still defaults `rootId` to `'root'` for\n * ad-hoc callers, but anything rendering a real besigner document MUST pass\n * this: rendering a besigner map as `'root'` finds no root and emits nothing\n * (AGL-765). Kept here so server code need not import the heavy `@aglyn/aglyn`\n * barrel; a drift guard in the console specs asserts the two stay equal.\n */\nexport const EMAIL_NODE_ROOT_ID = '_@_'\n\nexport function renderEmailHtml(options: EmailRenderOptions): RenderedEmail {\n const {\n nodes,\n rootId = 'root',\n subject = '',\n preheader = '',\n merge,\n products,\n sanitize,\n mediaOrigin,\n mediaHostId,\n brandLogoUrl,\n chrome,\n palette,\n buttonRadius,\n } = options\n const radius =\n Number.isFinite(buttonRadius) && Number(buttonRadius) >= 0\n ? Math.min(Number(buttonRadius), 48)\n : 4\n\n /**\n * A stored color, resolved: a palette token against the theme, a literal\n * as written, anything else to the fallback. The only way a color prop\n * reaches the markup, so nothing unresolvable or unsafe is ever written\n * into a style attribute.\n */\n const colorOf = (value: unknown, fallback: string): string =>\n resolveEmailColor(value, palette) ?? fallback\n /**\n * The theme's accent, for what the author left unset: the fill, its label,\n * and the accent AS TEXT (`primary.dark`, where the fill itself may be too\n * pale to read as a link). The platform's stands in for a missing palette.\n */\n const accent = emailAccent(palette)\n\n const textParts: string[] = []\n const sub = (value: unknown): string =>\n substituteMergeTokens(String(value ?? ''), merge)\n\n /**\n * The merge map as it applies inside a URL: everything except the\n * `contact.` namespace.\n *\n * That namespace is the recipient — `contact.email`, `contact.name`,\n * `contact.firstName` are what campaign-send puts in the map. Substituting\n * them into an `href` or a `src` is how a template like\n * `https://example.test/?e={{contact.email}}` turns every send into the\n * recipient's own address on somebody's query string, and putting personal\n * data in a URL is a line this codebase does not cross. The refusal has to\n * live here because it is the SUBSTITUTION that creates the value: no\n * scheme check and no sanitizer can see the address, since the template\n * the author wrote and the editor reviewed contains only the token.\n *\n * Nothing else narrows: `{{unsubscribeUrl}}` and `{{site.url}}` ARE URLs\n * and are the reason a token appears in this position at all.\n *\n * A refused token is left standing rather than blanked, which is this\n * module's existing convention for a token it will not fill — a test send\n * shows `?e={{contact.email}}` in the link, which names the problem to the\n * author instead of silently shipping a subtly different URL.\n */\n const urlMerge = merge\n ? Object.fromEntries(\n Object.entries(merge).filter(\n ([token]) => !token.startsWith('contact.'),\n ),\n )\n : undefined\n\n /** {@link sub} for a value that lands in a URL — see {@link urlMerge}. */\n const subUrl = (value: unknown): string =>\n substituteMergeTokens(String(value ?? ''), urlMerge)\n\n /**\n * A link target safe to emit, or undefined.\n *\n * Escaping the value into the attribute stops a breakout and says nothing\n * about the scheme, so `escapeEmailHtml` on its own passes a stored\n * `javascript:` or `data:` href through verbatim. The check runs on the\n * SUBSTITUTED string, because a merge value is part of the final URL and a\n * template that reads clean can resolve to one that does not.\n */\n const linkHref = (value: unknown): string | undefined => {\n const href = subUrl(value)\n if (!href) return undefined\n return hasSafeLinkScheme(href) ? href : undefined\n }\n\n const origin = mediaOrigin?.replace(/\\/+$/, '')\n\n /**\n * A stored image value turned into something an inbox can actually fetch,\n * or undefined (AGL-1224).\n *\n * `resolveEmailMediaSrc` handles the three stored generations — a `media:`\n * reference, the AGL-175 relative CDN path, and a plain absolute URL an\n * author typed — but the first two come back site-relative, which is the\n * whole bug: only a browser has a page to resolve them against.\n *\n * With no origin to absolutize against, the image is DROPPED rather than\n * emitted relative. Both are a missing picture; a dropped one leaves a gap,\n * while `src=\"/api/media/cdn/…\"` renders as a broken-image box, which reads\n * to a recipient as a broken email rather than a plain one.\n *\n * ⚠️ This comment used to claim \"neither send path relies on this — both\n * supply an origin\", and treated reaching the drop as hypothetical. It was\n * wrong, and it was wrong in the direction that hides the bug: campaign-send\n * passed no `mediaOrigin`/`mediaHostId` at all, so every author-picked image\n * was silently dropped from every marketing campaign until AGL-1394. The\n * quiet failure IS still the right one for a caller that genuinely has no\n * origin — but \"no caller reaches this\" is a claim about the whole repo, and\n * it decays the moment someone adds a third send path. Verify it before\n * relying on it; do not restore a count here.\n *\n * A protocol-relative `//host/x.png` is passed through untouched: it is\n * already absolute enough to name a host, and prefixing an origin would\n * corrupt it.\n *\n * The scheme is checked on the way out. `resolveEmailMediaSrc` recognizes\n * the two stored reference forms and passes anything else through as an\n * author-typed URL, so it is this check and nothing else that stands\n * between what an author types and the `src` attribute. A refusal drops\n * the image on the same reasoning as everything else here that cannot be\n * made fetchable: a gap reads as a plain email, and a `src` we would not\n * stand behind is not made safer by shipping it.\n */\n const imageSrc = (value: unknown): string | undefined => {\n const resolved = resolveEmailMediaSrc(subUrl(value), mediaHostId)\n if (!resolved || !hasSafeMediaScheme(resolved)) return undefined\n if (!resolved.startsWith('/') || resolved.startsWith('//')) return resolved\n if (origin) return `${origin}${resolved}`\n // A Storage download URL resolves to the CDN path (AGL-3506). With no\n // origin to send it from, the absolute URL it already was still fetches,\n // which beats dropping the picture.\n const stored = subUrl(value)\n return stored && /^https:\\/\\//i.test(stored) ? stored : undefined\n }\n\n const renderChildren = (ids: string[] | undefined): string =>\n (ids ?? [])\n .map((id) => renderNode(id))\n .filter(Boolean)\n .join('')\n\n const renderNode = (id: string): string => {\n const node = nodes[id]\n if (!node) return ''\n const props = node.props ?? {}\n switch (node.componentId) {\n case 'emailSection': {\n const background = colorOf(props.backgroundColor, '#ffffff')\n const padding = Number.isFinite(Number(props.padding))\n ? Number(props.padding)\n : 24\n const align = props.align || 'left'\n // A ROW, like every other block, with the band's table inside its\n // cell. Whatever encloses a section is a table — the 600px column, or\n // another section's inner table — and a `<table>` placed straight into\n // a table's rows is not a child an HTML parser keeps there: it closes\n // the enclosing table and lands after it. Emitted bare, a section would\n // draw outside the column, as wide as the viewport rather than the\n // 600px the editor shows, and take every row after it out too.\n return row(\n `<table role=\"presentation\" width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" ` +\n `style=\"background-color:${background};\">` +\n row(\n `<table role=\"presentation\" width=\"100%\" cellpadding=\"0\" cellspacing=\"0\">` +\n renderChildren(node.nodes) +\n `</table>`,\n `padding:${padding}px;text-align:${align};`,\n ) +\n `</table>`,\n )\n }\n case 'emailText': {\n const text = sub(props.children)\n // A block whose copy is only a token the send left empty (a\n // notification with no detail line, AGL-3367) draws nothing, rather\n // than an empty row and a blank paragraph in the text part.\n if (!text.trim()) return ''\n textParts.push(text)\n const style = TEXT_STYLES[props.variant as string] ?? TEXT_STYLES['body']\n const color = colorOf(props.color, '#1a1a1a')\n const align = props.align || 'left'\n return row(\n `<div style=\"font-family:${FONT};${style};color:${color};text-align:${align};\">` +\n linkifyEscapedText(escapeEmailHtml(text), accent.link).replace(/\\n/g, '<br />') +\n `</div>`,\n 'padding:4px 0;',\n )\n }\n case 'emailRichtext':\n case 'emailHtml': {\n const html = sanitize(sub(props.html))\n if (!html.trim()) return ''\n textParts.push(html.replace(/<[^>]+>/g, ' ').trim())\n return row(\n `<div style=\"font-family:${FONT};font-size:15px;line-height:1.55;\">${html}</div>`,\n 'padding:4px 0;',\n )\n }\n case 'emailImage': {\n const src = imageSrc(props.src)\n if (!src) return ''\n const width = Number(props.width) > 0 ? Number(props.width) : 600\n const alt = escapeEmailHtml(String(props.alt ?? ''))\n const align = props.align || 'center'\n const img =\n `<img src=\"${escapeEmailHtml(src)}\" alt=\"${alt}\" width=\"${Math.min(width, 600)}\" ` +\n `style=\"display:inline-block;max-width:100%;height:auto;border:0;\" />`\n // A refused href drops the WRAPPER, not the picture: the image is the\n // content and the link is decoration on it.\n const href = linkHref(props.href)\n return row(\n href\n ? `<a href=\"${escapeEmailHtml(href)}\" target=\"_blank\">${img}</a>`\n : img,\n `padding:8px 0;text-align:${align};`,\n )\n }\n case 'emailButton': {\n const label = sub(props.children ?? 'Call to action')\n // A refused href falls back to the placeholder the empty case already\n // uses, so the button keeps its place in the layout and goes nowhere.\n // Dropping the row instead would take the author's copy with it, and\n // an inert button reads as an unfinished email rather than a broken\n // one. The plain-text alternative gets the same value the anchor\n // does — a text/plain body is inert, but it is still delivered mail\n // and a refused URL does not belong in it either.\n const href = linkHref(props.href ?? '#') ?? '#'\n const background = colorOf(props.backgroundColor, accent.fill)\n const color = colorOf(props.color, accent.label)\n const align = props.align || 'center'\n textParts.push(`${label}: ${href}`)\n // Bulletproof-ish button: padded anchor, table-aligned.\n return row(\n `<a href=\"${escapeEmailHtml(href)}\" target=\"_blank\" ` +\n `style=\"display:inline-block;padding:12px 28px;border-radius:${radius}px;` +\n `background-color:${background};color:${color};font-family:${FONT};` +\n `font-size:15px;font-weight:600;text-decoration:none;\">` +\n escapeEmailHtml(label) +\n `</a>`,\n `padding:12px 0;text-align:${align};`,\n )\n }\n case 'emailDivider': {\n const color = colorOf(props.color, '#e0e0e0')\n return row(\n `<div style=\"border-top:1px solid ${color};font-size:0;line-height:0;\"> </div>`,\n 'padding:12px 0;',\n )\n }\n case 'emailSpacer': {\n const height = Number(props.height) > 0 ? Number(props.height) : 24\n return row(\n `<div style=\"height:${height}px;font-size:0;line-height:0;\"> </div>`,\n )\n }\n case 'emailProduct': {\n const product = props.productId\n ? products?.[String(props.productId)]\n : undefined\n if (!product) return ''\n const label = sub(props.buttonLabel ?? 'Shop now')\n // Catalog data rather than author markup, and the caller absolutizes\n // it before it arrives — but \"it came from a trusted table\" is a\n // claim about every writer of that table, so the same rule applies\n // here as to an author-typed href. Refused means no button and no\n // line in the text part; the product card itself still renders.\n const productUrl =\n product.url && hasSafeLinkScheme(product.url)\n ? product.url\n : undefined\n textParts.push(\n `${product.name}${product.priceLabel ? ` — ${product.priceLabel}` : ''}` +\n (productUrl ? `: ${productUrl}` : ''),\n )\n // Same treatment as emailImage: a catalog image can be a picked\n // asset, so it carries the same reference/relative forms (AGL-1224).\n const productImage = imageSrc(product.imageUrl)\n const image = productImage\n ? `<img src=\"${escapeEmailHtml(productImage)}\" alt=\"${escapeEmailHtml(product.name)}\" width=\"280\" style=\"max-width:100%;height:auto;border:0;border-radius:6px;\" /><br />`\n : ''\n const button = productUrl\n ? `<a href=\"${escapeEmailHtml(productUrl)}\" target=\"_blank\" style=\"display:inline-block;margin-top:8px;padding:10px 24px;border-radius:${radius}px;background-color:${accent.fill};color:${accent.label};font-family:${FONT};font-size:14px;font-weight:600;text-decoration:none;\">${escapeEmailHtml(label)}</a>`\n : ''\n return row(\n `<div style=\"border:1px solid #e0e0e0;border-radius:8px;padding:16px;text-align:center;font-family:${FONT};\">` +\n image +\n `<div style=\"font-size:16px;font-weight:600;margin-top:8px;\">${escapeEmailHtml(product.name)}</div>` +\n (product.priceLabel\n ? `<div style=\"font-size:14px;color:#555555;margin-top:2px;\">${escapeEmailHtml(product.priceLabel)}</div>`\n : '') +\n button +\n `</div>`,\n 'padding:8px 0;',\n )\n }\n default: {\n // Unknown/web components: render their children so mixed documents\n // degrade gracefully instead of dropping content.\n return renderChildren(node.nodes)\n }\n }\n }\n\n const body = renderNode(rootId) || renderChildren(nodes[rootId]?.nodes)\n const preheaderHtml = preheader\n ? `<div style=\"display:none;max-height:0;overflow:hidden;mso-hide:all;\">` +\n escapeEmailHtml(sub(preheader)) +\n `</div>`\n : ''\n\n // INSIDE the 600px table, above the designed body, so it inherits the\n // column's width on a phone instead of being centred against the viewport.\n // `alt` is the product name where one is known, because a logo blocked by\n // the client (which is the default in most inboxes) must still say who sent\n // the mail. Height is capped rather than set, so a wordmark and a square\n // mark both land at a sane size without the sender supplying dimensions.\n //\n // The src goes through `imageSrc` like every other image in the message\n // (AGL-2230), and NOT into the tag raw. `emailLogoUrl` is collected by\n // `MediaUrlField`, whose \"Browse\" button writes the picked asset's\n // site-relative `cdnPath` — and the org DAM's other generation stores a\n // `media:{scope}/{mediaId}` reference. Neither is a URL an inbox can\n // resolve: there is no page to resolve it against, so a raw pass-through\n // put `src=\"media:h1/med9\"` at the top of every transactional email a\n // white-label org sent. `imageSrc` absolutizes both forms against\n // `mediaOrigin`, passes a real https URL through untouched, and returns\n // undefined when it cannot produce something fetchable — in which case the\n // row is dropped, on the same reasoning as AGL-1224: a gap reads as a plain\n // email, a broken-image box reads as a broken one.\n const brandLogo = imageSrc(String(brandLogoUrl ?? '').trim()) ?? ''\n // The product name from the merge map, because most inboxes block images by\n // default — a logo with no `alt` is a blank box where the sender's identity\n // should be. Falls back to nothing rather than to a literal, which would\n // reintroduce the hard-coded brand this whole change removes.\n const brandLogoAlt = merge?.['brand.productName'] ?? ''\n const brandLogoHtml = brandLogo\n ? row(\n `<img src=\"${escapeEmailHtml(brandLogo)}\" alt=\"${escapeEmailHtml(brandLogoAlt)}\" ` +\n `style=\"max-height:48px;max-width:200px;display:block;margin:0 auto;border:0;\" />`,\n 'padding:24px 24px 0;text-align:center;',\n )\n : ''\n\n /**\n * The chrome header row, or '' when it has nothing to draw.\n *\n * Same placement and the same `imageSrc` as the logo row above, which it\n * replaces. Height is capped at 40px rather than set, so a wordmark and a\n * square mark both land at a sane size; the `height` attribute is for the\n * desktop clients that ignore CSS `max-height` and would otherwise draw the\n * file at its own size. A logo that cannot be fetched from an inbox falls\n * back to the name in bold, never to an `<img>` that draws a broken box.\n * White, so the header and a default body read as one card.\n */\n const renderChromeHeader = (header: EmailChromeHeader): string => {\n const logo = imageSrc(String(header.logoUrl ?? '').trim())\n const name = sub(header.logoAlt).trim()\n const href = linkHref(header.href)\n const link = (inner: string, style: string): string =>\n href\n ? `<a href=\"${escapeEmailHtml(href)}\" target=\"_blank\" style=\"${style}\">${inner}</a>`\n : inner\n let mark: string\n if (logo) {\n mark = link(\n `<img src=\"${escapeEmailHtml(logo)}\" alt=\"${escapeEmailHtml(name)}\" height=\"40\" ` +\n `style=\"display:block;margin:0 auto;border:0;height:auto;width:auto;max-height:40px;max-width:200px;\" />`,\n 'text-decoration:none;',\n )\n } else if (name) {\n mark =\n `<div style=\"font-family:${FONT};font-size:20px;font-weight:700;line-height:1.3;color:${CHROME_PALETTE.ink};text-align:center;\">` +\n link(escapeEmailHtml(name), `color:${CHROME_PALETTE.ink};text-decoration:none;`) +\n `</div>`\n } else {\n return ''\n }\n return row(\n mark,\n `padding:24px 24px 0;text-align:center;background-color:${CHROME_PALETTE.card};`,\n )\n }\n\n const headerHtml = chrome?.header\n ? renderChromeHeader(chrome.header)\n : brandLogoHtml\n\n /**\n * The chrome footer: rows under the body in the look of the email footer\n * block the platform's own mail wears (a `#F8F9FA` section, padded 24,\n * centered captions), and the same lines appended to the plain-text part.\n *\n * Rendered AFTER the body on purpose: the body's blocks push their text as\n * they draw, and the footer's lines belong after all of it. A line that\n * resolves to nothing is left out rather than drawn as an empty row.\n */\n const renderChromeFooter = (footer: EmailChromeFooter): string => {\n const htmlLines: string[] = []\n const textLines: string[] = []\n const reason = sub(footer.reason).trim()\n if (reason) {\n htmlLines.push(escapeEmailHtml(reason))\n textLines.push(reason)\n }\n const supportLabel = sub(footer.support?.label).trim()\n const supportHref = linkHref(footer.support?.href)\n if (supportLabel && supportHref) {\n htmlLines.push(\n `<a href=\"${escapeEmailHtml(supportHref)}\" target=\"_blank\" ` +\n `style=\"color:${CHROME_PALETTE.caption};text-decoration:underline;\">${escapeEmailHtml(supportLabel)}</a>`,\n )\n // A plain-text reader gets the address itself, bare: a mailto's\n // mailbox, or the URL. \"Get help: https://…\" names where it goes; a\n // label that already IS the mailbox is not repeated.\n const bare = /^mailto:/i.test(supportHref)\n ? supportHref.slice('mailto:'.length).split('?')[0]\n : supportHref\n textLines.push(supportLabel === bare ? bare : `${supportLabel}: ${bare}`)\n }\n const legal = sub(footer.legal).trim()\n if (legal) {\n htmlLines.push(escapeEmailHtml(legal))\n textLines.push(legal)\n }\n if (!htmlLines.length) return ''\n textParts.push(textLines.join('\\n'))\n return row(\n htmlLines\n .map(\n (line, index) =>\n `<div style=\"font-family:${FONT};font-size:12px;font-weight:400;line-height:1.4;color:${CHROME_PALETTE.caption};` +\n `${index ? 'margin-top:8px;' : ''}\">${line.replace(/\\n/g, '<br />')}</div>`,\n )\n .join(''),\n `padding:24px;text-align:center;background-color:${CHROME_PALETTE.band};`,\n )\n }\n\n const footerHtml = chrome?.footer ? renderChromeFooter(chrome.footer) : ''\n\n const html =\n `<!DOCTYPE html><html><head><meta charset=\"utf-8\" />` +\n `<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" />` +\n `<title>${escapeEmailHtml(sub(subject))}</title></head>` +\n `<body style=\"margin:0;padding:0;background-color:#f4f4f4;\">` +\n preheaderHtml +\n `<table role=\"presentation\" width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" style=\"background-color:#f4f4f4;\">` +\n row(\n `<table role=\"presentation\" width=\"600\" cellpadding=\"0\" cellspacing=\"0\" align=\"center\" style=\"max-width:600px;width:100%;margin:0 auto;\">` +\n headerHtml +\n body +\n footerHtml +\n `</table>`,\n 'padding:24px 8px;',\n ) +\n `</table></body></html>`\n\n return { html, text: textParts.join('\\n\\n') }\n}\n"],"names":["hasSafeLinkScheme","hasSafeMediaScheme","linkifyEscapedText","emailAccent","resolveEmailColor","resolveEmailMediaSrc","FONT","CHROME_PALETTE","ink","card","band","caption","escapeEmailHtml","value","replace","substituteMergeTokens","merge","match","token","replacement","undefined","TEXT_STYLES","heading","subheading","body","row","cellHtml","cellStyle","EMAIL_NODE_ROOT_ID","renderEmailHtml","options","imageSrc","nodes","rootId","subject","preheader","products","sanitize","mediaOrigin","mediaHostId","brandLogoUrl","chrome","palette","buttonRadius","radius","Number","isFinite","Math","min","colorOf","fallback","accent","textParts","sub","String","urlMerge","Object","fromEntries","entries","filter","startsWith","subUrl","linkHref","href","origin","resolved","stored","test","renderChildren","ids","map","id","renderNode","Boolean","join","node","props","componentId","background","backgroundColor","padding","align","text","children","trim","push","style","variant","color","link","html","src","width","alt","img","label","fill","height","product","productId","buttonLabel","productUrl","url","name","priceLabel","productImage","imageUrl","image","button","preheaderHtml","brandLogo","brandLogoAlt","brandLogoHtml","renderChromeHeader","header","logo","logoUrl","logoAlt","inner","mark","headerHtml","renderChromeFooter","footer","htmlLines","textLines","reason","supportLabel","support","supportHref","bare","slice","length","split","legal","line","index","footerHtml"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4BC,GAED,SACEA,iBAAiB,EACjBC,kBAAkB,QACb,0CAAyC;AAEhD,SAASC,kBAAkB,QAAQ,qBAAiB;AACpD,SAASC,WAAW,EAAEC,iBAAiB,QAA2B,qBAAiB;AACnF,SAASC,oBAAoB,QAAQ,uBAAmB;AAgLxD,MAAMC,OAAO;AAEb;;;;;;;;CAQC,GACD,MAAMC,iBAAiB;IACrB,sDAAsD,GACtDC,KAAK;IACL,+CAA+C,GAC/CC,MAAM;IACN,qBAAqB,GACrBC,MAAM;IACN,uCAA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,CAAC,GAC7D2E,gBACA,CAAC,0GAA0G,CAAC,GAC5GpF,IACE,CAAC,wIAAwI,CAAC,GACxI+F,aACAhG,OACAgH,aACA,CAAC,QAAQ,CAAC,EACZ,uBAEF,CAAC,sBAAsB,CAAC;IAE1B,OAAO;QAAE9C;QAAMR,MAAM9B,UAAUsB,IAAI,CAAC;IAAQ;AAC9C"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/shared/util/email/src/lib/email-render.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Email render pipeline (AGL-348): converts a designed email screen's\n * node map into email-client-compatible HTML (600px table layout,\n * inlined styles, bulletproof buttons) plus a plain-text alternative.\n * Pure — no I/O; callers resolve products/merge data first.\n *\n * Merge tokens ({{contact.firstName}}, {{unsubscribeUrl}}, …) substitute\n * from the provided map; unknown tokens are left in place so a missing\n * field is visible in test sends instead of silently blank.\n *\n * ## The safety contract, in one place\n *\n * Everything this emits is author-controlled, and it is emitted into mail\n * that has left the building. Three rules, all applied here rather than\n * left to a caller:\n *\n * 1. Block HTML goes through {@link EmailRenderOptions.sanitize}, which is\n * REQUIRED. There is no identity default to fall back into.\n * 2. Every URL is scheme-checked against `@aglyn/shared-util-http` before it\n * is escaped into an attribute — escaping stops an attribute breakout and\n * says nothing at all about `javascript:`.\n * 3. Merge substitution into a URL cannot draw from the `contact.` namespace,\n * so no template can route a recipient's own address into a query string.\n *\n * Mail clients strip most of this themselves, so none of the three is the\n * last line of defense in an inbox. They are the only line the moment one of\n * these documents renders outside one — a \"view this email in your browser\"\n * page is the ordinary way that happens.\n */\n\nimport {\n hasSafeLinkScheme,\n hasSafeMediaScheme,\n} from '@aglyn/shared-util-http/safe-url-scheme'\n\nimport { linkifyEscapedText } from './email-linkify'\nimport {\n emailAccent,\n PLATFORM_EMAIL_PALETTE,\n resolveEmailColor,\n type EmailPalette,\n} from './email-palette'\nimport { resolveEmailMediaSrc } from './email-media-src'\n\nexport interface EmailRenderProduct {\n name: string\n priceLabel?: string\n imageUrl?: string\n url?: string\n}\n\nexport interface EmailRenderNode {\n componentId?: string\n props?: Record<string, any>\n nodes?: string[]\n}\n\nexport interface EmailRenderOptions {\n /** Flat node map (screen version `nodes`). */\n nodes: Record<string, EmailRenderNode | undefined>\n /** Root node id (defaults to 'root'). */\n rootId?: string\n subject?: string\n /** Hidden preview line shown next to the subject in inboxes. */\n preheader?: string\n /** Merge values keyed by token body, e.g. 'contact.firstName'. */\n merge?: Record<string, string>\n /** Product data by id for emailProduct blocks. */\n products?: Record<string, EmailRenderProduct | undefined>\n /**\n * The HTML policy applied to every `emailRichtext` / `emailHtml` block.\n *\n * REQUIRED, and required is the point. A policy a caller may omit is a\n * policy that gets omitted, and an omitted one here is not a rendering\n * bug: the console renders these same nodes through `sanitizeCustomHtml`\n * before an author ever sees them, so an unpoliced mail render means two\n * renderers of one document disagreeing about safety, with the unsafe one\n * being the one that sends.\n *\n * This module cannot pick the policy for itself — it is `scope:shared` and\n * the sanitizer is aglyn-scoped, which nx forbids it to import — so the\n * choice belongs to the caller, and the type is what makes the caller make\n * it. Every send path passes `sanitizeAuthorHtml`, which is exactly what\n * `sanitizeCustomHtml` delegates to, so the mailed copy and the previewed\n * copy are the same function of the same string.\n */\n sanitize: (html: string) => string\n /**\n * Absolute origin serving this email's media, e.g. `https://acme.com`\n * (AGL-1224).\n *\n * An image an author picked with \"Browse media\" is stored as a\n * `media:{scope}/{mediaId}` reference, which resolves to the SITE-RELATIVE\n * CDN path `/api/media/cdn/…`. A browser has a page to resolve that\n * against; an inbox has nothing. Without this, every picked image is a\n * broken-image box in the delivered mail.\n *\n * It is an input rather than a lookup because this module is pure, and\n * because the CDN route is mounted in BOTH the console and the tenant app\n * — which origin is correct depends on whose email this is.\n */\n mediaOrigin?: string\n /**\n * Host doc id of the site sending, so an `org:`-scoped reference is\n * host-qualified. The CDN is unauthenticated and decides from the URL\n * alone, so an org asset restricted to particular sites is only served\n * through the qualified form.\n */\n mediaHostId?: string\n /**\n * Absolute URL of the sender's EMAIL logo, prepended as a centred row at\n * the top of the 600px table (AGL-2139).\n *\n * `emailLogoUrl` was a first-class field of `OrgBrandingProfile`, resolved,\n * collected in the branding editor, https-validated and persisted — and read\n * at ZERO render sites. An agency admin on the tier that costs the most\n * filled it in, the form saved, the value round-tripped, and it appeared in\n * no email ever. This is the consumer that makes it a live capability\n * rather than a stored string.\n *\n * Absent or blank emits NOTHING — not an empty row, not a spacer. An email\n * with a gap where a logo should be reads as broken; one without a logo\n * reads as plain, which is the correct appearance for an org that has not\n * set one.\n *\n * Ignored when {@link EmailRenderOptions.chrome} carries a header: that\n * header is the logo row, and a caller that has one passes the org's logo\n * through it, so a message never opens with two.\n */\n brandLogoUrl?: string\n /**\n * The sender's header and footer, drawn around the body (AGL-3322). See\n * {@link EmailChrome}. Absent draws neither.\n */\n chrome?: EmailChrome\n /**\n * The theme the email is sent under (AGL-3370): the console brand for the\n * platform's own mail, a white-label org's color over it, or the site's\n * theme for a site's mail. See {@link buildEmailPalette}.\n *\n * It does two things. A color an author picked in the Besigner is stored as\n * a palette token (`primary.main`), which a mail client cannot resolve, so\n * every color prop is resolved against this before it is written. And\n * what nobody picked (a button's fill and label, a link) takes the theme's\n * accent rather than a color of the renderer's own. Absent keeps the\n * renderer's neutral defaults and drops an unresolvable token.\n */\n palette?: EmailPalette\n /**\n * A button's corner radius in px: the theme's `shape.borderRadius`, which\n * the Besigner canvas draws the button with. Absent is MUI's default, 4.\n */\n buttonRadius?: number\n /**\n * How a button's label is set: the theme's own button type — its case,\n * weight and letter spacing — so a button reads like the buttons on the\n * console or the site it comes from (AGL-3897). Absent, mixed case at 600.\n */\n buttonText?: EmailButtonText\n}\n\n/** A button label's type, from a theme's `typography.button`. */\nexport interface EmailButtonText {\n transform?: 'uppercase' | 'none' | 'capitalize' | 'lowercase'\n weight?: number\n letterSpacing?: string\n}\n\n/**\n * The row above the body that says who sent the mail.\n *\n * `logoAlt` is required because it does two jobs. It is the logo's `alt`,\n * which is what most inboxes show, since they block images by default. And\n * it is the header itself when there is no logo to draw — none was given, or\n * the one given cannot be fetched from an inbox — so the sender is named in\n * bold text rather than by a broken-image box.\n */\nexport interface EmailChromeHeader {\n /** The logo. Resolved and scheme-checked like every other image here. */\n logoUrl?: string\n /** The sender's name: the logo's alt text, or the header when no logo draws. */\n logoAlt: string\n /** Where the logo or name links. A refused scheme drops the link, not the header. */\n href?: string\n}\n\n/**\n * The rows under the body, in the order they draw. Each is optional, and a\n * footer with none of them draws nothing.\n */\nexport interface EmailChromeFooter {\n /** Why the recipient is getting this mail. */\n reason?: string\n /** Where to get help. Drawn as a link; dropped whole when the href is refused. */\n support?: { label: string; href: string }\n /** Who sent it, and from where: a copyright and postal line. */\n legal?: string\n}\n\n/**\n * A sender's header and footer, drawn by the renderer rather than placed by a\n * designer (AGL-3322).\n *\n * For mail whose body carries no header or footer of its own: a system\n * email's built-in copy, or a design sent under a brand whose own blocks it\n * may not carry. The caller decides WHICH brand; this only draws.\n *\n * Every string goes through the same merge substitution as the body, so\n * `{{org.name}}` in a footer line reads as the organization it names, and is\n * escaped like body text. Every URL goes through the same scheme checks as a\n * body link or image. The footer lines are appended to the plain-text part\n * too, the support link as its bare address, because a reader of that part is\n * owed the same reason and the same way to get help.\n */\nexport interface EmailChrome {\n header?: EmailChromeHeader\n footer?: EmailChromeFooter\n}\n\n/**\n * The theme an email is drawn in (AGL-3370): its palette, which resolves\n * every color an author picked and colors what they did not, and its button\n * radius. Spread into {@link EmailRenderOptions}.\n */\nexport type EmailTheme = Pick<EmailRenderOptions, 'palette' | 'buttonRadius' | 'buttonText'>\n\nexport interface RenderedEmail {\n html: string\n text: string\n}\n\nconst FONT = 'Helvetica, Arial, sans-serif'\n\n/**\n * The colours the chrome is drawn in (AGL-3322), named once.\n *\n * Literal because this is email HTML: mail clients strip `<style>` and read no\n * CSS variables, so no theme token reaches the wire. They are the values\n * already in the mail, not new ones — the ink and card of a default body\n * block, and the band and caption grey of the email footer block the\n * platform's own mail wears — so the chrome and the body it frames agree.\n */\nconst CHROME_PALETTE = {\n /** The sender's name in the header: body text's ink. */\n ink: '#1a1a1a',\n /** The header band: a default section's card. */\n card: '#ffffff',\n /** The footer band. */\n band: '#F8F9FA',\n /** Footer lines and the support link. */\n caption: '#757575',\n} as const\n\nexport function escapeEmailHtml(value: string): string {\n return value\n .replace(/&/g, '&')\n .replace(/</g, '<')\n .replace(/>/g, '>')\n .replace(/\"/g, '"')\n}\n\n/** Substitutes {{token}} occurrences; unknown tokens stay visible. */\nexport function substituteMergeTokens(\n value: string,\n merge: Record<string, string> | undefined,\n): string {\n return value.replace(/\\{\\{\\s*([\\w.]+)\\s*\\}\\}/g, (match, token: string) => {\n const replacement = merge?.[token]\n return replacement !== undefined ? replacement : match\n })\n}\n\nconst TEXT_STYLES: Record<string, string> = {\n heading: `font-size:28px;font-weight:700;line-height:1.25`,\n subheading: `font-size:20px;font-weight:600;line-height:1.3`,\n body: `font-size:15px;font-weight:400;line-height:1.55`,\n caption: `font-size:12px;font-weight:400;line-height:1.5`,\n // A small label above a heading saying what the email is about: the site,\n // the workspace (AGL-3897).\n eyebrow: `font-size:12px;font-weight:700;line-height:1.4;letter-spacing:0.06em;text-transform:uppercase`,\n // The rows of a details panel; see `detailsHtml`.\n details: `font-size:14px;font-weight:400;line-height:1.45`,\n // A list of next steps or help, each a link; see `linksHtml`.\n links: `font-size:15px;font-weight:600;line-height:1.4`,\n}\n\n/** The space around each text style's row: a heading needs room below it, an eyebrow sits tight above one. */\nconst TEXT_PADDING: Record<string, string> = {\n heading: 'padding:4px 0 10px;',\n subheading: 'padding:14px 0 4px;',\n body: 'padding:5px 0;',\n caption: 'padding:5px 0;',\n eyebrow: 'padding:0 0 2px;',\n details: 'padding:10px 0;',\n links: 'padding:8px 0;',\n}\n\n/** A details value longer than this reads as a paragraph under its label rather than beside it. */\nconst DETAIL_INLINE_MAX = 48\n\n/** The styles whose words are secondary, drawn in the theme's muted text color unless a color is set. */\nconst MUTED_TEXT_STYLES: ReadonlySet<string> = new Set(['caption'])\n\n/**\n * One line of a details panel split into its label and its value: at the\n * first \": \" (\"Device: Chrome on macOS\"), else at the last \" — \" (\"House\n * Blend × 2 — $24.00\"). A line with neither is drawn across both columns.\n */\nexport function splitEmailDetailLine(line: string): { label: string; value: string } | null {\n const colon = line.indexOf(': ')\n if (colon > 0 && colon <= 48) return { label: line.slice(0, colon).trim(), value: line.slice(colon + 2).trim() }\n const dash = line.lastIndexOf(' — ')\n if (dash > 0) return { label: line.slice(0, dash).trim(), value: line.slice(dash + 3).trim() }\n return null\n}\n\n/** One full-width table row wrapping arbitrary cell HTML. */\nconst row = (cellHtml: string, cellStyle = ''): string =>\n `<tr><td style=\"${cellStyle}\">${cellHtml}</td></tr>`\n\n/**\n * The id the besigner roots every stored node map at — `CANVAS_ROOT_ELEMENT_ID`\n * in `@aglyn/aglyn`. `renderEmailHtml` still defaults `rootId` to `'root'` for\n * ad-hoc callers, but anything rendering a real besigner document MUST pass\n * this: rendering a besigner map as `'root'` finds no root and emits nothing\n * (AGL-765). Kept here so server code need not import the heavy `@aglyn/aglyn`\n * barrel; a drift guard in the console specs asserts the two stay equal.\n */\nexport const EMAIL_NODE_ROOT_ID = '_@_'\n\nexport function renderEmailHtml(options: EmailRenderOptions): RenderedEmail {\n const {\n nodes,\n rootId = 'root',\n subject = '',\n preheader = '',\n merge,\n products,\n sanitize,\n mediaOrigin,\n mediaHostId,\n brandLogoUrl,\n chrome,\n palette,\n buttonRadius,\n buttonText,\n } = options\n const radius =\n Number.isFinite(buttonRadius) && Number(buttonRadius) >= 0\n ? Math.min(Number(buttonRadius), 48)\n : 4\n const labelWeight =\n Number.isFinite(buttonText?.weight) && Number(buttonText?.weight) >= 100 ? Number(buttonText?.weight) : 600\n const labelCase =\n (buttonText?.transform && /^(uppercase|none|capitalize|lowercase)$/.test(buttonText.transform)\n ? `text-transform:${buttonText.transform};`\n : '') +\n (buttonText?.letterSpacing && /^-?[\\d.]+(em|px|rem)$/.test(buttonText.letterSpacing)\n ? `letter-spacing:${buttonText.letterSpacing};`\n : '')\n\n /**\n * A stored color, resolved: a palette token against the theme, a literal\n * as written, anything else to the fallback. The only way a color prop\n * reaches the markup, so nothing unresolvable or unsafe is ever written\n * into a style attribute.\n */\n const colorOf = (value: unknown, fallback: string): string =>\n resolveEmailColor(value, palette) ?? fallback\n\n /** A theme token's color, from the email's palette, else the platform's, which resolves every one. */\n const themeColor = (token: string): string =>\n resolveEmailColor(token, palette) ?? resolveEmailColor(token, PLATFORM_EMAIL_PALETTE) ?? 'inherit'\n\n /**\n * A list of links (AGL-3897): each \"Label — https://…\" line a row whose\n * label is the link, in the theme's link color, with an arrow after it and\n * a hairline between rows — next steps, help pages. A line with no address\n * is drawn as plain text; an address the link check refuses drops the link\n * and keeps the words.\n */\n const linksHtml = (text: string, style: string): string => {\n const rule = themeColor('divider')\n const lines = text.split('\\n').map((line) => line.trim()).filter(Boolean)\n const rows = lines.map((line, index) => {\n const split = splitEmailDetailLine(line)\n const href = split ? linkHref(split.value) : undefined\n const label = escapeEmailHtml(split ? split.label : line)\n const border = index > 0 ? `border-top:1px solid ${rule};` : ''\n const inner = href\n ? `<a href=\"${escapeEmailHtml(href)}\" target=\"_blank\" style=\"color:${accent.link};text-decoration:none;\">${label} →</a>`\n : `<span style=\"color:${themeColor('text.primary')};\">${label}</span>`\n return `<tr><td style=\"font-family:${FONT};${style};padding:10px 0;${border}\">${inner}</td></tr>`\n })\n return `<table role=\"presentation\" width=\"100%\" cellpadding=\"0\" cellspacing=\"0\">${rows.join('')}</table>`\n }\n\n /**\n * A details panel (AGL-3897): each line a row, its label muted on the left\n * and its value on the right, on a tinted ground with a hairline between\n * rows. A row whose label begins \"Total\" is the sum of the rows above it,\n * so it is drawn bold with a rule over it. A line that empties out — a\n * token the send left blank — draws no row.\n */\n const detailsHtml = (text: string, style: string, valueColor: string): string => {\n const muted = themeColor('text.secondary')\n const rule = themeColor('divider')\n // A line whose value a token left blank (\"Location:\") is not drawn.\n const lines = text\n .split('\\n')\n .map((line) => line.trim())\n .filter((line) => line && !line.endsWith(':'))\n const cell = (value: string) => linkifyEscapedText(escapeEmailHtml(value), accent.link).replace(/\\n/g, '<br />')\n // A line with no label of its own continues the value above it: a form\n // answer that ran over two lines is one row, not two.\n const entries: Array<{ label: string | null; value: string }> = []\n for (const line of lines) {\n const split = splitEmailDetailLine(line)\n const last = entries[entries.length - 1]\n if (!split && last?.label) last.value += `\\n${line}`\n else entries.push(split ? { label: split.label, value: split.value } : { label: null, value: line })\n }\n const rows = entries.map((entry, index) => {\n const total = Boolean(entry.label && /^total\\b/i.test(entry.label))\n const border = index > 0 ? `border-top:1px solid ${rule};` : ''\n const base = `font-family:${FONT};${style};padding:9px 0;vertical-align:top;${border}`\n if (!entry.label) {\n return `<tr><td colspan=\"2\" style=\"${base}color:${valueColor};\">${cell(entry.value)}</td></tr>`\n }\n // A long answer — a message, a note — reads as a paragraph under its\n // label, not as a bold run squeezed against the right edge.\n if (!total && (entry.value.length > DETAIL_INLINE_MAX || entry.value.includes('\\n'))) {\n return (\n `<tr><td colspan=\"2\" style=\"${base}\">` +\n `<div style=\"color:${muted};padding-bottom:2px;\">${cell(entry.label)}</div>` +\n `<div style=\"color:${valueColor};\">${cell(entry.value)}</div>` +\n `</td></tr>`\n )\n }\n return (\n `<tr>` +\n `<td style=\"${base}color:${total ? valueColor : muted};${total ? 'font-weight:700;' : ''}padding-right:16px;\">${cell(entry.label)}</td>` +\n `<td style=\"${base}color:${valueColor};font-weight:${total ? 700 : 600};text-align:right;word-break:break-word;\">${cell(entry.value)}</td>` +\n `</tr>`\n )\n })\n return (\n `<table role=\"presentation\" width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" ` +\n // On the theme's primary tint, the brand's own light ground.\n `style=\"background-color:${resolveEmailColor('tint.primary', palette) ?? themeColor('grey.50')};border-radius:8px;\">` +\n `<tr><td style=\"padding:4px 16px;\">` +\n `<table role=\"presentation\" width=\"100%\" cellpadding=\"0\" cellspacing=\"0\">${rows.join('')}</table>` +\n `</td></tr></table>`\n )\n }\n /**\n * The theme's accent, for what the author left unset: the fill, its label,\n * and the accent AS TEXT (`primary.dark`, where the fill itself may be too\n * pale to read as a link). The platform's stands in for a missing palette.\n */\n const accent = emailAccent(palette)\n\n const textParts: string[] = []\n const sub = (value: unknown): string =>\n substituteMergeTokens(String(value ?? ''), merge)\n\n /**\n * The merge map as it applies inside a URL: everything except the\n * `contact.` namespace.\n *\n * That namespace is the recipient — `contact.email`, `contact.name`,\n * `contact.firstName` are what campaign-send puts in the map. Substituting\n * them into an `href` or a `src` is how a template like\n * `https://example.test/?e={{contact.email}}` turns every send into the\n * recipient's own address on somebody's query string, and putting personal\n * data in a URL is a line this codebase does not cross. The refusal has to\n * live here because it is the SUBSTITUTION that creates the value: no\n * scheme check and no sanitizer can see the address, since the template\n * the author wrote and the editor reviewed contains only the token.\n *\n * Nothing else narrows: `{{unsubscribeUrl}}` and `{{site.url}}` ARE URLs\n * and are the reason a token appears in this position at all.\n *\n * A refused token is left standing rather than blanked, which is this\n * module's existing convention for a token it will not fill — a test send\n * shows `?e={{contact.email}}` in the link, which names the problem to the\n * author instead of silently shipping a subtly different URL.\n */\n const urlMerge = merge\n ? Object.fromEntries(\n Object.entries(merge).filter(\n ([token]) => !token.startsWith('contact.'),\n ),\n )\n : undefined\n\n /** {@link sub} for a value that lands in a URL — see {@link urlMerge}. */\n const subUrl = (value: unknown): string =>\n substituteMergeTokens(String(value ?? ''), urlMerge)\n\n /**\n * A link target safe to emit, or undefined.\n *\n * Escaping the value into the attribute stops a breakout and says nothing\n * about the scheme, so `escapeEmailHtml` on its own passes a stored\n * `javascript:` or `data:` href through verbatim. The check runs on the\n * SUBSTITUTED string, because a merge value is part of the final URL and a\n * template that reads clean can resolve to one that does not.\n */\n const linkHref = (value: unknown): string | undefined => {\n const href = subUrl(value)\n if (!href) return undefined\n return hasSafeLinkScheme(href) ? href : undefined\n }\n\n const origin = mediaOrigin?.replace(/\\/+$/, '')\n\n /**\n * A stored image value turned into something an inbox can actually fetch,\n * or undefined (AGL-1224).\n *\n * `resolveEmailMediaSrc` handles the three stored generations — a `media:`\n * reference, the AGL-175 relative CDN path, and a plain absolute URL an\n * author typed — but the first two come back site-relative, which is the\n * whole bug: only a browser has a page to resolve them against.\n *\n * With no origin to absolutize against, the image is DROPPED rather than\n * emitted relative. Both are a missing picture; a dropped one leaves a gap,\n * while `src=\"/api/media/cdn/…\"` renders as a broken-image box, which reads\n * to a recipient as a broken email rather than a plain one.\n *\n * ⚠️ This comment used to claim \"neither send path relies on this — both\n * supply an origin\", and treated reaching the drop as hypothetical. It was\n * wrong, and it was wrong in the direction that hides the bug: campaign-send\n * passed no `mediaOrigin`/`mediaHostId` at all, so every author-picked image\n * was silently dropped from every marketing campaign until AGL-1394. The\n * quiet failure IS still the right one for a caller that genuinely has no\n * origin — but \"no caller reaches this\" is a claim about the whole repo, and\n * it decays the moment someone adds a third send path. Verify it before\n * relying on it; do not restore a count here.\n *\n * A protocol-relative `//host/x.png` is passed through untouched: it is\n * already absolute enough to name a host, and prefixing an origin would\n * corrupt it.\n *\n * The scheme is checked on the way out. `resolveEmailMediaSrc` recognizes\n * the two stored reference forms and passes anything else through as an\n * author-typed URL, so it is this check and nothing else that stands\n * between what an author types and the `src` attribute. A refusal drops\n * the image on the same reasoning as everything else here that cannot be\n * made fetchable: a gap reads as a plain email, and a `src` we would not\n * stand behind is not made safer by shipping it.\n */\n const imageSrc = (value: unknown): string | undefined => {\n const resolved = resolveEmailMediaSrc(subUrl(value), mediaHostId)\n if (!resolved || !hasSafeMediaScheme(resolved)) return undefined\n if (!resolved.startsWith('/') || resolved.startsWith('//')) return resolved\n if (origin) return `${origin}${resolved}`\n // A Storage download URL resolves to the CDN path (AGL-3506). With no\n // origin to send it from, the absolute URL it already was still fetches,\n // which beats dropping the picture.\n const stored = subUrl(value)\n return stored && /^https:\\/\\//i.test(stored) ? stored : undefined\n }\n\n const renderChildren = (ids: string[] | undefined): string =>\n (ids ?? [])\n .map((id) => renderNode(id))\n .filter(Boolean)\n .join('')\n\n const renderNode = (id: string): string => {\n const node = nodes[id]\n if (!node) return ''\n const props = node.props ?? {}\n switch (node.componentId) {\n case 'emailSection': {\n const background = colorOf(props.backgroundColor, '#ffffff')\n const padding = Number.isFinite(Number(props.padding))\n ? Number(props.padding)\n : 24\n const align = props.align || 'left'\n // A ROW, like every other block, with the band's table inside its\n // cell. Whatever encloses a section is a table — the 600px column, or\n // another section's inner table — and a `<table>` placed straight into\n // a table's rows is not a child an HTML parser keeps there: it closes\n // the enclosing table and lands after it. Emitted bare, a section would\n // draw outside the column, as wide as the viewport rather than the\n // 600px the editor shows, and take every row after it out too.\n return row(\n `<table role=\"presentation\" width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" ` +\n `style=\"background-color:${background};\">` +\n row(\n `<table role=\"presentation\" width=\"100%\" cellpadding=\"0\" cellspacing=\"0\">` +\n renderChildren(node.nodes) +\n `</table>`,\n `padding:${padding}px;text-align:${align};`,\n ) +\n `</table>`,\n )\n }\n case 'emailText': {\n const merged = sub(props.children)\n // An eyebrow is a few parts joined by \" · \"; one a token left empty\n // (\"{{host.businessName}} · Order #1042\" on a site with no name) loses\n // its separator rather than starting with one.\n const text =\n props.variant === 'eyebrow'\n ? merged.replace(/^(\\s*·\\s*)+|(\\s*·\\s*)+$/g, '').replace(/(\\s*·\\s*){2,}/g, ' · ')\n : merged\n // A block whose copy is only a token the send left empty (a\n // notification with no detail line, AGL-3367) draws nothing, rather\n // than an empty row and a blank paragraph in the text part.\n if (!text.trim()) return ''\n textParts.push(text)\n const variant = TEXT_STYLES[props.variant as string] ? (props.variant as string) : 'body'\n const style = TEXT_STYLES[variant]\n // Unpicked, secondary words take the theme's muted text, and an\n // eyebrow its brand color in the shade that reads as text.\n const color = props.color\n ? colorOf(props.color, '#1a1a1a')\n : variant === 'eyebrow'\n ? themeColor('primary.dark')\n : MUTED_TEXT_STYLES.has(variant)\n ? themeColor('text.secondary')\n : '#1a1a1a'\n const align = props.align || 'left'\n if (variant === 'links') {\n return row(linksHtml(text, style), TEXT_PADDING['links'])\n }\n if (variant === 'details') {\n return row(detailsHtml(text, style, props.color ? color : themeColor('text.primary')), TEXT_PADDING['details'])\n }\n return row(\n `<div style=\"font-family:${FONT};${style};color:${color};text-align:${align};\">` +\n linkifyEscapedText(escapeEmailHtml(text), accent.link).replace(/\\n/g, '<br />') +\n `</div>`,\n TEXT_PADDING[variant] ?? TEXT_PADDING['body'],\n )\n }\n case 'emailRichtext':\n case 'emailHtml': {\n const html = sanitize(sub(props.html))\n if (!html.trim()) return ''\n textParts.push(html.replace(/<[^>]+>/g, ' ').trim())\n return row(\n `<div style=\"font-family:${FONT};font-size:15px;line-height:1.55;\">${html}</div>`,\n 'padding:4px 0;',\n )\n }\n case 'emailImage': {\n const src = imageSrc(props.src)\n if (!src) return ''\n const width = Number(props.width) > 0 ? Number(props.width) : 600\n const alt = escapeEmailHtml(String(props.alt ?? ''))\n const align = props.align || 'center'\n const img =\n `<img src=\"${escapeEmailHtml(src)}\" alt=\"${alt}\" width=\"${Math.min(width, 600)}\" ` +\n `style=\"display:inline-block;max-width:100%;height:auto;border:0;\" />`\n // A refused href drops the WRAPPER, not the picture: the image is the\n // content and the link is decoration on it.\n const href = linkHref(props.href)\n return row(\n href\n ? `<a href=\"${escapeEmailHtml(href)}\" target=\"_blank\">${img}</a>`\n : img,\n `padding:8px 0;text-align:${align};`,\n )\n }\n case 'emailButton': {\n // A button written as merge tokens that the send left empty is one\n // this email has nothing to point at (an alert about no one item),\n // so it is left out rather than drawn going nowhere.\n const tokenOnly = (value: unknown): boolean =>\n /\\{\\{[^}]+\\}\\}/.test(String(value ?? '')) && !sub(value).trim()\n if (tokenOnly(props.href) || tokenOnly(props.children)) return ''\n const label = sub(props.children ?? 'Call to action')\n // A refused href falls back to the placeholder the empty case already\n // uses, so the button keeps its place in the layout and goes nowhere.\n // Dropping the row instead would take the author's copy with it, and\n // an inert button reads as an unfinished email rather than a broken\n // one. The plain-text alternative gets the same value the anchor\n // does — a text/plain body is inert, but it is still delivered mail\n // and a refused URL does not belong in it either.\n const href = linkHref(props.href ?? '#') ?? '#'\n const background = colorOf(props.backgroundColor, accent.fill)\n const color = colorOf(props.color, accent.label)\n const align = props.align || 'center'\n textParts.push(`${label}: ${href}`)\n // Bulletproof-ish button: padded anchor, table-aligned.\n return row(\n `<a href=\"${escapeEmailHtml(href)}\" target=\"_blank\" ` +\n `style=\"display:inline-block;padding:12px 28px;border-radius:${radius}px;` +\n `background-color:${background};color:${color};font-family:${FONT};` +\n `font-size:15px;font-weight:${labelWeight};text-decoration:none;${labelCase}\">` +\n escapeEmailHtml(label) +\n `</a>`,\n `padding:12px 0;text-align:${align};`,\n )\n }\n case 'emailDivider': {\n const color = colorOf(props.color, '#e0e0e0')\n return row(\n `<div style=\"border-top:1px solid ${color};font-size:0;line-height:0;\"> </div>`,\n 'padding:12px 0;',\n )\n }\n case 'emailSpacer': {\n const height = Number(props.height) > 0 ? Number(props.height) : 24\n return row(\n `<div style=\"height:${height}px;font-size:0;line-height:0;\"> </div>`,\n )\n }\n case 'emailProduct': {\n const product = props.productId\n ? products?.[String(props.productId)]\n : undefined\n if (!product) return ''\n const label = sub(props.buttonLabel ?? 'Shop now')\n // Catalog data rather than author markup, and the caller absolutizes\n // it before it arrives — but \"it came from a trusted table\" is a\n // claim about every writer of that table, so the same rule applies\n // here as to an author-typed href. Refused means no button and no\n // line in the text part; the product card itself still renders.\n const productUrl =\n product.url && hasSafeLinkScheme(product.url)\n ? product.url\n : undefined\n textParts.push(\n `${product.name}${product.priceLabel ? ` — ${product.priceLabel}` : ''}` +\n (productUrl ? `: ${productUrl}` : ''),\n )\n // Same treatment as emailImage: a catalog image can be a picked\n // asset, so it carries the same reference/relative forms (AGL-1224).\n const productImage = imageSrc(product.imageUrl)\n const image = productImage\n ? `<img src=\"${escapeEmailHtml(productImage)}\" alt=\"${escapeEmailHtml(product.name)}\" width=\"280\" style=\"max-width:100%;height:auto;border:0;border-radius:6px;\" /><br />`\n : ''\n const button = productUrl\n ? `<a href=\"${escapeEmailHtml(productUrl)}\" target=\"_blank\" style=\"display:inline-block;margin-top:8px;padding:10px 24px;border-radius:${radius}px;background-color:${accent.fill};color:${accent.label};font-family:${FONT};font-size:14px;font-weight:600;text-decoration:none;\">${escapeEmailHtml(label)}</a>`\n : ''\n return row(\n `<div style=\"border:1px solid #e0e0e0;border-radius:8px;padding:16px;text-align:center;font-family:${FONT};\">` +\n image +\n `<div style=\"font-size:16px;font-weight:600;margin-top:8px;\">${escapeEmailHtml(product.name)}</div>` +\n (product.priceLabel\n ? `<div style=\"font-size:14px;color:#555555;margin-top:2px;\">${escapeEmailHtml(product.priceLabel)}</div>`\n : '') +\n button +\n `</div>`,\n 'padding:8px 0;',\n )\n }\n default: {\n // Unknown/web components: render their children so mixed documents\n // degrade gracefully instead of dropping content.\n return renderChildren(node.nodes)\n }\n }\n }\n\n const body = renderNode(rootId) || renderChildren(nodes[rootId]?.nodes)\n const preheaderHtml = preheader\n ? `<div style=\"display:none;max-height:0;overflow:hidden;mso-hide:all;\">` +\n escapeEmailHtml(sub(preheader)) +\n `</div>`\n : ''\n\n // INSIDE the 600px table, above the designed body, so it inherits the\n // column's width on a phone instead of being centred against the viewport.\n // `alt` is the product name where one is known, because a logo blocked by\n // the client (which is the default in most inboxes) must still say who sent\n // the mail. Height is capped rather than set, so a wordmark and a square\n // mark both land at a sane size without the sender supplying dimensions.\n //\n // The src goes through `imageSrc` like every other image in the message\n // (AGL-2230), and NOT into the tag raw. `emailLogoUrl` is collected by\n // `MediaUrlField`, whose \"Browse\" button writes the picked asset's\n // site-relative `cdnPath` — and the org DAM's other generation stores a\n // `media:{scope}/{mediaId}` reference. Neither is a URL an inbox can\n // resolve: there is no page to resolve it against, so a raw pass-through\n // put `src=\"media:h1/med9\"` at the top of every transactional email a\n // white-label org sent. `imageSrc` absolutizes both forms against\n // `mediaOrigin`, passes a real https URL through untouched, and returns\n // undefined when it cannot produce something fetchable — in which case the\n // row is dropped, on the same reasoning as AGL-1224: a gap reads as a plain\n // email, a broken-image box reads as a broken one.\n const brandLogo = imageSrc(String(brandLogoUrl ?? '').trim()) ?? ''\n // The product name from the merge map, because most inboxes block images by\n // default — a logo with no `alt` is a blank box where the sender's identity\n // should be. Falls back to nothing rather than to a literal, which would\n // reintroduce the hard-coded brand this whole change removes.\n const brandLogoAlt = merge?.['brand.productName'] ?? ''\n const brandLogoHtml = brandLogo\n ? row(\n `<img src=\"${escapeEmailHtml(brandLogo)}\" alt=\"${escapeEmailHtml(brandLogoAlt)}\" ` +\n `style=\"max-height:48px;max-width:200px;display:block;margin:0 auto;border:0;\" />`,\n 'padding:24px 24px 0;text-align:center;',\n )\n : ''\n\n /**\n * The chrome header row, or '' when it has nothing to draw.\n *\n * Same placement and the same `imageSrc` as the logo row above, which it\n * replaces. Height is capped at 40px rather than set, so a wordmark and a\n * square mark both land at a sane size; the `height` attribute is for the\n * desktop clients that ignore CSS `max-height` and would otherwise draw the\n * file at its own size. A logo that cannot be fetched from an inbox falls\n * back to the name in bold, never to an `<img>` that draws a broken box.\n * White, so the header and a default body read as one card.\n */\n const renderChromeHeader = (header: EmailChromeHeader): string => {\n const logo = imageSrc(String(header.logoUrl ?? '').trim())\n const name = sub(header.logoAlt).trim()\n const href = linkHref(header.href)\n const link = (inner: string, style: string): string =>\n href\n ? `<a href=\"${escapeEmailHtml(href)}\" target=\"_blank\" style=\"${style}\">${inner}</a>`\n : inner\n let mark: string\n if (logo) {\n mark = link(\n `<img src=\"${escapeEmailHtml(logo)}\" alt=\"${escapeEmailHtml(name)}\" height=\"40\" ` +\n `style=\"display:block;margin:0 auto;border:0;height:auto;width:auto;max-height:40px;max-width:200px;\" />`,\n 'text-decoration:none;',\n )\n } else if (name) {\n mark =\n `<div style=\"font-family:${FONT};font-size:20px;font-weight:700;line-height:1.3;color:${CHROME_PALETTE.ink};text-align:center;\">` +\n link(escapeEmailHtml(name), `color:${CHROME_PALETTE.ink};text-decoration:none;`) +\n `</div>`\n } else {\n return ''\n }\n return row(\n mark,\n `padding:24px 24px 0;text-align:center;background-color:${CHROME_PALETTE.card};`,\n )\n }\n\n const headerHtml = chrome?.header\n ? renderChromeHeader(chrome.header)\n : brandLogoHtml\n\n /**\n * The chrome footer: rows under the body in the look of the email footer\n * block the platform's own mail wears (a `#F8F9FA` section, padded 24,\n * centered captions), and the same lines appended to the plain-text part.\n *\n * Rendered AFTER the body on purpose: the body's blocks push their text as\n * they draw, and the footer's lines belong after all of it. A line that\n * resolves to nothing is left out rather than drawn as an empty row.\n */\n const renderChromeFooter = (footer: EmailChromeFooter): string => {\n const htmlLines: string[] = []\n const textLines: string[] = []\n const reason = sub(footer.reason).trim()\n if (reason) {\n htmlLines.push(escapeEmailHtml(reason))\n textLines.push(reason)\n }\n const supportLabel = sub(footer.support?.label).trim()\n const supportHref = linkHref(footer.support?.href)\n if (supportLabel && supportHref) {\n htmlLines.push(\n `<a href=\"${escapeEmailHtml(supportHref)}\" target=\"_blank\" ` +\n `style=\"color:${CHROME_PALETTE.caption};text-decoration:underline;\">${escapeEmailHtml(supportLabel)}</a>`,\n )\n // A plain-text reader gets the address itself, bare: a mailto's\n // mailbox, or the URL. \"Get help: https://…\" names where it goes; a\n // label that already IS the mailbox is not repeated.\n const bare = /^mailto:/i.test(supportHref)\n ? supportHref.slice('mailto:'.length).split('?')[0]\n : supportHref\n textLines.push(supportLabel === bare ? bare : `${supportLabel}: ${bare}`)\n }\n const legal = sub(footer.legal).trim()\n if (legal) {\n htmlLines.push(escapeEmailHtml(legal))\n textLines.push(legal)\n }\n if (!htmlLines.length) return ''\n textParts.push(textLines.join('\\n'))\n return row(\n htmlLines\n .map(\n (line, index) =>\n `<div style=\"font-family:${FONT};font-size:12px;font-weight:400;line-height:1.4;color:${CHROME_PALETTE.caption};` +\n `${index ? 'margin-top:8px;' : ''}\">${line.replace(/\\n/g, '<br />')}</div>`,\n )\n .join(''),\n `padding:24px;text-align:center;background-color:${CHROME_PALETTE.band};`,\n )\n }\n\n const footerHtml = chrome?.footer ? renderChromeFooter(chrome.footer) : ''\n\n const html =\n `<!DOCTYPE html><html><head><meta charset=\"utf-8\" />` +\n `<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" />` +\n // Drawn for a light ground in the theme's colors: a client that offers\n // its own dark rendering (Apple Mail) is asked to show it as designed\n // rather than invert the brand's colors (AGL-3897).\n `<meta name=\"color-scheme\" content=\"light only\" />` +\n `<meta name=\"supported-color-schemes\" content=\"light only\" />` +\n `<style>:root{color-scheme:light only;supported-color-schemes:light only;}</style>` +\n `<title>${escapeEmailHtml(sub(subject))}</title></head>` +\n `<body style=\"margin:0;padding:0;background-color:#f4f4f4;\">` +\n preheaderHtml +\n `<table role=\"presentation\" width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" style=\"background-color:#f4f4f4;\">` +\n row(\n `<table role=\"presentation\" width=\"600\" cellpadding=\"0\" cellspacing=\"0\" align=\"center\" style=\"max-width:600px;width:100%;margin:0 auto;\">` +\n headerHtml +\n body +\n footerHtml +\n `</table>`,\n 'padding:24px 8px;',\n ) +\n `</table></body></html>`\n\n return { html, text: textParts.join('\\n\\n') }\n}\n"],"names":["hasSafeLinkScheme","hasSafeMediaScheme","linkifyEscapedText","emailAccent","PLATFORM_EMAIL_PALETTE","resolveEmailColor","resolveEmailMediaSrc","FONT","CHROME_PALETTE","ink","card","band","caption","escapeEmailHtml","value","replace","substituteMergeTokens","merge","match","token","replacement","undefined","TEXT_STYLES","heading","subheading","body","eyebrow","details","links","TEXT_PADDING","DETAIL_INLINE_MAX","MUTED_TEXT_STYLES","Set","splitEmailDetailLine","line","colon","indexOf","label","slice","trim","dash","lastIndexOf","row","cellHtml","cellStyle","EMAIL_NODE_ROOT_ID","renderEmailHtml","options","imageSrc","nodes","rootId","subject","preheader","products","sanitize","mediaOrigin","mediaHostId","brandLogoUrl","chrome","palette","buttonRadius","buttonText","radius","Number","isFinite","Math","min","labelWeight","weight","labelCase","transform","test","letterSpacing","colorOf","fallback","themeColor","linksHtml","text","style","rule","lines","split","map","filter","Boolean","rows","index","href","linkHref","border","inner","accent","link","join","detailsHtml","valueColor","muted","endsWith","cell","entries","last","length","push","entry","total","base","includes","textParts","sub","String","urlMerge","Object","fromEntries","startsWith","subUrl","origin","resolved","stored","renderChildren","ids","id","renderNode","node","props","componentId","background","backgroundColor","padding","align","merged","children","variant","color","has","html","src","width","alt","img","tokenOnly","fill","height","product","productId","buttonLabel","productUrl","url","name","priceLabel","productImage","imageUrl","image","button","preheaderHtml","brandLogo","brandLogoAlt","brandLogoHtml","renderChromeHeader","header","logo","logoUrl","logoAlt","mark","headerHtml","renderChromeFooter","footer","htmlLines","textLines","reason","supportLabel","support","supportHref","bare","legal","footerHtml"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4BC,GAED,SACEA,iBAAiB,EACjBC,kBAAkB,QACb,0CAAyC;AAEhD,SAASC,kBAAkB,QAAQ,qBAAiB;AACpD,SACEC,WAAW,EACXC,sBAAsB,EACtBC,iBAAiB,QAEZ,qBAAiB;AACxB,SAASC,oBAAoB,QAAQ,uBAAmB;AA6LxD,MAAMC,OAAO;AAEb;;;;;;;;CAQC,GACD,MAAMC,iBAAiB;IACrB,sDAAsD,GACtDC,KAAK;IACL,+CAA+C,GAC/CC,MAAM;IACN,qBAAqB,GACrBC,MAAM;IACN,uCAAuC,GACvCC,SAAS;AACX;AAEA,OAAO,SAASC,gBAAgBC,KAAa;IA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