@the-portland-company/canvas-editor 0.3.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,28 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.4.0 — V1-inspired chrome: floating block tray, dashed block outlines, settings on the left
4
+
5
+ Per Spencer's 2026-09-11 direction that V2 (email.politogyvrm.com) take its
6
+ cues from V1 (the app.politogyvrm.com editor):
7
+
8
+ - **Floating block tray** (`BlockToolbar`): a pill docked to the bottom of the
9
+ canvas — move handle (drag it anywhere; double-click re-docks), one icon tile
10
+ per block in V1's order (Text, Image, Button, PDF, Spacer, Divider, Social,
11
+ Raw HTML, Columns, Section, Hero, Card, Container, then Video/Survey/Form),
12
+ the **Side | Center** insert-mode toggle (accent pill), a **T** toggle for
13
+ tile labels, undo/redo, and × to close. Closing moves the palette into the
14
+ left rail with a "pop out" button. Insert mode / open / labels are remembered
15
+ per browser (`ce:insertMode`, `ce:trayOpen`, `ce:trayLabels`); the
16
+ `insertMode` prop is now the initial value and `onInsertModeChange` reports
17
+ switches.
18
+ - **Dashed outlines on every block** in edit mode (1px; 2px for Section/Card/
19
+ Container), solid accent + faint tint when selected, faint tint on hover —
20
+ drawn as outlines so the canvas keeps the sent email's exact layout.
21
+ - **Settings rail moves to the LEFT**; the right rail is gone and the canvas
22
+ takes the width. `.ce-layout` is now `300px 1fr`.
23
+ - **Feather-style inline icons** (`Icon`, `BlockIcon`) replace the emoji
24
+ glyphs in the tray, rail, insert menu and drag ghost — same icon set V1 uses.
25
+
3
26
  ## 0.3.0 — feature + styling parity with the main VRM app's email editor
4
27
 
5
28
  Per Spencer's 2026-09-11 direction: bring the shared editor to parity with the
package/README.md CHANGED
@@ -85,7 +85,7 @@ context. Server code that needs block logic imports the root (`.`) only.
85
85
  initialUpdatedAt={updatedAt}
86
86
  nextAction={{ label: "Next: Sender →", href: senderHref }}
87
87
  metaPanel={({ doc, setMeta }) => <MyEmailMetaPanel doc={doc} setMeta={setMeta} />}
88
- insertMode="center" // or "side" — host owns the preference
88
+ insertMode="center" // initial only; users switch Side/Center in the block tray (remembered per browser)
89
89
  />
90
90
  ```
91
91
 
package/dist/canvas.css CHANGED
@@ -73,8 +73,11 @@
73
73
  Everything is token-driven (var(--color-*)); `.dark` overrides exist only
74
74
  where a token cannot express the value (shadow alpha, device chrome).
75
75
 
76
- .ce-layout 3-column editor grid: 300px rail / canvas / 300px rail
76
+ .ce-layout 2-column editor grid: 300px settings rail / canvas
77
77
  .ce-layout.is-left-collapsed left rail collapsed to a 44px strip
78
+ .ce-tray-dock / .ce-tray floating block palette docked under the canvas
79
+ .ce-tile an icon tile in the tray (drag source)
80
+ .ce-seg / .ce-seg-btn Side | Center segmented toggle
78
81
  .ce-rail a side rail panel (surface, border, scrolls)
79
82
  .ce-rail-header sticky rail heading row
80
83
  .ce-canvas center scroll column, 24px padding
@@ -113,20 +116,28 @@
113
116
 
114
117
  /* ---- layout -------------------------------------------------------------- */
115
118
 
119
+ /* Settings rail on the left, canvas on the right; the block palette floats
120
+ over the canvas as the tray (.ce-tray) — the VRM app's arrangement. */
116
121
  .ce-layout {
117
122
  display: grid;
118
- grid-template-columns: 300px 1fr 300px;
123
+ grid-template-columns: 300px 1fr;
119
124
  gap: 1rem;
120
125
  height: calc(100vh - 8rem);
121
126
  min-height: 32rem;
122
127
  }
123
128
 
124
- .ce-layout.is-left-collapsed { grid-template-columns: 44px 1fr 300px; }
129
+ .ce-layout.is-left-collapsed { grid-template-columns: 44px 1fr; }
125
130
 
126
131
  @media (max-width: 1100px) {
127
132
  .ce-layout, .ce-layout.is-left-collapsed { grid-template-columns: 1fr; height: auto; }
128
133
  }
129
134
 
135
+ .ce-rail-section {
136
+ display: flex; flex-direction: column; gap: 0.5rem;
137
+ padding-bottom: 0.75rem; margin-bottom: 0.25rem;
138
+ border-bottom: 1px solid var(--color-border);
139
+ }
140
+
130
141
  .ce-rail {
131
142
  background: var(--color-surface);
132
143
  border: 1px solid var(--color-border);
@@ -147,6 +158,8 @@
147
158
  }
148
159
 
149
160
  .ce-canvas {
161
+ position: relative;
162
+ display: flex; flex-direction: column;
150
163
  flex: 1 1 auto;
151
164
  overflow: auto;
152
165
  padding: 1.5rem;
@@ -156,6 +169,89 @@
156
169
  min-height: 0;
157
170
  }
158
171
 
172
+ /* Content grows; the tray dock below it sticks to the bottom of the scroll box. */
173
+ .ce-canvas-body { flex: 1 0 auto; padding-bottom: 4.5rem; }
174
+
175
+ /* ---- block tray (floating palette) --------------------------------------- */
176
+
177
+ .ce-tray-dock {
178
+ position: sticky; bottom: 0.25rem; z-index: 10;
179
+ display: flex; justify-content: center;
180
+ margin-top: auto;
181
+ pointer-events: none;
182
+ }
183
+
184
+ .ce-tray-dock.is-floating { position: fixed; bottom: auto; margin: 0; }
185
+
186
+ .ce-tray {
187
+ pointer-events: auto;
188
+ display: flex; align-items: center; gap: 1rem;
189
+ width: fit-content; max-width: 100%;
190
+ padding: 9px 10px 4px;
191
+ background: var(--color-surface);
192
+ border: 1px solid var(--color-border);
193
+ border-radius: 11px;
194
+ box-shadow: 0 10px 15px -3px rgba(15, 23, 42, 0.12), 0 4px 6px -4px rgba(15, 23, 42, 0.12);
195
+ }
196
+
197
+ .dark .ce-tray { box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.5), 0 4px 6px -4px rgba(0, 0, 0, 0.5); }
198
+
199
+ .ce-tray-tiles {
200
+ display: flex; align-items: stretch; gap: 0.5rem;
201
+ overflow-x: auto; padding-bottom: 0.25rem;
202
+ scrollbar-width: thin;
203
+ }
204
+
205
+ .ce-tile {
206
+ display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.25rem;
207
+ min-width: 2.75rem; height: 2.75rem; padding: 0.5rem;
208
+ background: var(--color-surface);
209
+ border: 1px solid var(--color-border);
210
+ border-radius: 0.375rem;
211
+ color: var(--color-text);
212
+ cursor: grab; touch-action: none;
213
+ transition: background 0.2s, opacity 0.2s;
214
+ }
215
+
216
+ .ce-tile.has-label { height: auto; min-width: 3.75rem; padding: 0.4rem 0.5rem; }
217
+ .ce-tile:hover { background: var(--color-surface-2); }
218
+ .ce-tile:active { cursor: grabbing; }
219
+ .ce-tile-label { font-size: 0.6rem; line-height: 1; white-space: nowrap; color: var(--color-text-muted); }
220
+
221
+ .ce-tray-btn {
222
+ display: inline-flex; align-items: center; justify-content: center;
223
+ width: 2rem; height: 2rem;
224
+ border: 0; border-radius: 0.375rem; background: transparent;
225
+ color: var(--color-text-muted); cursor: pointer;
226
+ transition: background 0.15s, color 0.15s;
227
+ }
228
+
229
+ .ce-tray-btn:hover { background: var(--color-surface-2); color: var(--color-text); }
230
+ .ce-tray-btn:disabled { opacity: 0.4; cursor: not-allowed; background: transparent; }
231
+ .ce-tray-btn.is-active { color: var(--color-accent); background: color-mix(in srgb, var(--color-accent) 12%, transparent); }
232
+ .ce-tray-btn.is-grab { cursor: grab; touch-action: none; }
233
+ .ce-tray-btn.is-grab:active { cursor: grabbing; }
234
+
235
+ /* Segmented Side | Center toggle: pill track, solid accent on the active half. */
236
+ .ce-seg {
237
+ display: inline-flex; align-items: center; gap: 0.125rem;
238
+ padding: 0.125rem;
239
+ border: 1px solid var(--color-border);
240
+ border-radius: 999px;
241
+ background: var(--color-surface-2);
242
+ }
243
+
244
+ .ce-seg-btn {
245
+ min-height: 24px; padding: 0 0.6rem;
246
+ border: 0; border-radius: 999px; background: transparent;
247
+ color: var(--color-text-muted); font-size: 10px; font-weight: 600; line-height: 1;
248
+ cursor: pointer; transition: background 0.15s, color 0.15s;
249
+ }
250
+
251
+ .ce-seg-btn:hover { color: var(--color-text); }
252
+ .ce-seg-btn.is-active { background: var(--color-accent); color: #fff; }
253
+ .ce-seg-btn.is-active:hover { background: var(--color-accent-hover, var(--color-accent)); color: #fff; }
254
+
159
255
  .ce-canvas-sheet {
160
256
  margin: 0 auto;
161
257
  max-width: 640px;
@@ -168,17 +264,28 @@
168
264
 
169
265
  /* ---- blocks -------------------------------------------------------------- */
170
266
 
267
+ /* Every block shows a dashed edit-mode boundary (the VRM app's dashed
268
+ component borders); containers draw it heavier. Outlines, not borders, so
269
+ the canvas keeps the sent email's exact layout. Selected = solid accent +
270
+ faint tint; hover = faint tint only. */
171
271
  .ce-block {
172
272
  position: relative;
173
- outline: 2px solid transparent;
174
- outline-offset: 2px;
273
+ outline: 1px dashed color-mix(in srgb, var(--color-text) 28%, transparent);
274
+ outline-offset: -1px;
175
275
  border-radius: var(--radius, 0.375rem);
176
276
  transition: outline-color 0.12s, background 0.12s;
177
277
  }
178
278
 
179
- .ce-block:hover { outline-color: color-mix(in srgb, var(--color-accent) 45%, transparent); }
279
+ .ce-block.is-container { outline-width: 2px; outline-offset: -2px; }
280
+
281
+ .ce-block:hover { background: color-mix(in srgb, var(--color-text) 4%, transparent); }
180
282
 
181
- .ce-block.is-selected { outline: 2px solid var(--color-accent); }
283
+ .ce-block.is-selected {
284
+ outline: 2px solid var(--color-accent);
285
+ outline-offset: -2px;
286
+ background: color-mix(in srgb, var(--color-accent) 5%, transparent);
287
+ z-index: 20;
288
+ }
182
289
 
183
290
  .ce-block-toolbar {
184
291
  position: absolute; top: -40px; right: 0; z-index: 5;
@@ -722,6 +722,6 @@ function pinBlockSchemaVersion(blocks) {
722
722
  return blocks.map((b) => ({ ...b, version: b.version ?? 1 }));
723
723
  }
724
724
 
725
- export { DEFAULT_FOOTER_PROPS, clearMobileOverrides, columnWidths, effectiveMobileProps, formatPaidForLine, isMobileOverridden, mobileOverrideCss, pinBlockSchemaVersion, renderEmailHtml, renderEmailText, renderFooterHtml, resetMobileOverride, resolveFooterProps, sanitizeEmbeddedHtml, sanitizeRichText, sanitizeSvg, setMobileOverride };
726
- //# sourceMappingURL=chunk-6XOUU7UE.js.map
727
- //# sourceMappingURL=chunk-6XOUU7UE.js.map
725
+ export { DEFAULT_CANVAS_PADDING_Y, DEFAULT_CONTENT_WIDTH, DEFAULT_FOOTER_PROPS, clearMobileOverrides, columnWidths, effectiveMobileProps, formatPaidForLine, isMobileOverridden, mobileOverrideCss, pinBlockSchemaVersion, renderEmailHtml, renderEmailText, renderFooterHtml, resetMobileOverride, resolveFooterProps, sanitizeEmbeddedHtml, sanitizeRichText, sanitizeSvg, setMobileOverride };
726
+ //# sourceMappingURL=chunk-6WG7YK6K.js.map
727
+ //# sourceMappingURL=chunk-6WG7YK6K.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/blocks/footer.ts","../src/blocks/mobile.ts","../src/blocks/sanitize.ts","../src/blocks/render.ts"],"names":["cssValue","FONT_STACK","esc"],"mappings":";AAuDO,IAAM,oBAAA,GAAoC;AAAA,EAC/C,SAAA,EAAW,EAAA;AAAA,EACX,UAAA,EAAY,IAAA;AAAA,EACZ,SAAA,EAAW,SAAA;AAAA,EACX,SAAA,EAAW,SAAA;AAAA,EACX,UAAA,EAAY,IAAA;AAAA,EACZ,OAAA,EAAS,IAAA;AAAA,EACT,OAAA,EAAS,EAAA;AAAA,EACT,gBAAA,EAAkB,IAAA;AAAA,EAClB,YAAA,EAAc,EAAE,CAAA,EAAG,QAAA,EAAU,GAAG,KAAA,EAAM;AAAA,EACtC,SAAA,EAAW,IAAA;AAAA,EACX,OAAO,EAAC;AAAA,EACR,aAAA,EAAe,EAAE,CAAA,EAAG,QAAA,EAAU,GAAG,QAAA,EAAS;AAAA,EAC1C,OAAA,EAAS,IAAA;AAAA,EACT,OAAA,EAAS,EAAE,CAAA,EAAG,EAAA,EAAI,GAAG,CAAA,EAAG,CAAA,EAAG,EAAA,EAAI,CAAA,EAAG,CAAA,EAAE;AAAA,EACpC,WAAA,EAAa,IAAA;AAAA,EACb,aAAA,EAAe,IAAA;AAAA,EACf,OAAA,EAAS,IAAA;AAAA,EACT,WAAA,EAAa,KAAA;AAAA,EACb,WAAA,EAAa,EAAA;AAAA,EACb,UAAA,EAAY,EAAA;AAAA,EACZ,WAAA,EAAa,KAAA;AAAA,EACb,WAAA,EAA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A;AAEA;AAIJ,IAAA,MAAM,MAAA,GAAS,CAAC,GAAI,CAAA,CAAE,QAAA,IAAY,EAAC,EAAI,GAAA,CAAI,CAAA,CAAE,cAAA,IAAkB,EAAC,EAAG,MAAM,CAAA;AACzE,IAAA,IAAI,MAAA,CAAO,QAAQ,KAAA,CAAM,IAAA,CAAK,GAAG,gBAAA,CAAiB,MAAA,EAAQ,GAAG,CAAC,CAAA;AAAA,EAChE;AACA,EAAA,OAAO,KAAA;AACT;AAEO,SAAS,eAAA,CAAgB,QAAiB,GAAA,EAA4B;AAC3E,EAAA,MAAM,KAAA,GAAQ,gBAAA,CAAiB,MAAA,EAAQ,GAAG,CAAA;AAC1C,EAAA,KAAA,CAAM,KAAK,EAAA,EAAI,GAAA,CAAI,iBAAiB,CAAA,aAAA,EAAgB,GAAA,CAAI,cAAc,CAAA,CAAE,CAAA;AACxE,EAAA,OAAO,KAAA,CAAM,MAAA,CAAO,OAAO,CAAA,CAAE,KAAK,MAAM,CAAA;AAC1C;AAEO,SAAS,sBAAsB,MAAA,EAA0B;AAC9D,EAAA,OAAO,MAAA,CAAO,GAAA,CAAI,CAAC,CAAA,MAAO,EAAE,GAAG,CAAA,EAAG,OAAA,EAAS,CAAA,CAAE,OAAA,IAAW,CAAA,EAAE,CAAE,CAAA;AAC9D","file":"chunk-6WG7YK6K.js","sourcesContent":["// Footer block schema + renderer (Specs_Email-Engine \"Items to add to\n// creative canvass\" #9). CAN-SPAM constraints are structural, not\n// configurable: the physical mailing address and the unsubscribe link are\n// always appended by the renderer, the unsubscribe link always renders\n// bottom-center, and neither can be removed via props.\n\nexport type FooterHPosition = \"left\" | \"center\" | \"right\";\nexport type FooterVPosition = \"top\" | \"middle\" | \"bottom\";\n\nexport type FooterLink = { label: string; url: string };\n\nexport type FooterPaidFor = {\n pacName: string;\n pac: string;\n pacId: string;\n};\n\nexport type FooterPadding = { t: number; r: number; b: number; l: number };\n\nexport type FooterProps = {\n extraText: string;\n background: string | null;\n fontColor: string | null;\n linkColor: string | null;\n fontFamily: string | null;\n logoUrl: string | null;\n logoAlt: string;\n logoMediaAssetId: string | null;\n logoPosition: { h: FooterHPosition; v: FooterVPosition };\n /** Rendered logo width in px (auto when null). */\n logoWidth: number | null;\n links: FooterLink[];\n linksPosition: { h: FooterHPosition; v: FooterVPosition };\n paidFor: FooterPaidFor | null;\n padding: FooterPadding;\n /** Org identity line — renders as \"© {copyrightYear} {companyName}\". */\n companyName: string | null;\n copyrightYear: string | null;\n /** Optional extra address line. The CAN-SPAM physical address comes from the\n * render context and is ALWAYS rendered; this prop only adds a second line\n * when the host has a different display address, and is skipped when it\n * matches. It exists so a V1 footer's `address` round-trips instead of\n * being dropped on import. */\n address: string | null;\n showWebsite: boolean;\n websiteText: string;\n websiteUrl: string;\n showPrivacy: boolean;\n privacyText: string;\n privacyUrl: string;\n showContact: boolean;\n contactText: string;\n contactUrl: string;\n};\n\nexport const DEFAULT_FOOTER_PROPS: FooterProps = {\n extraText: \"\",\n background: null,\n fontColor: \"#8a8a8a\",\n linkColor: \"#8a8a8a\",\n fontFamily: null,\n logoUrl: null,\n logoAlt: \"\",\n logoMediaAssetId: null,\n logoPosition: { h: \"center\", v: \"top\" },\n logoWidth: null,\n links: [],\n linksPosition: { h: \"center\", v: \"middle\" },\n paidFor: null,\n padding: { t: 16, r: 8, b: 16, l: 8 },\n companyName: null,\n copyrightYear: null,\n address: null,\n showWebsite: false,\n websiteText: \"\",\n websiteUrl: \"\",\n showPrivacy: false,\n privacyText: \"Privacy Policy\",\n privacyUrl: \"\",\n showContact: false,\n contactText: \"Contact Us\",\n contactUrl: \"\",\n};\n\n/** The org facts a footer derives its defaults from (a subset of\n * `BrandInfo[\"org\"]`, so the editor can pass `useBrand().org` straight in). */\nexport type FooterOrgInfo = {\n companyName?: string | null;\n address?: string | null;\n websiteUrl?: string | null;\n privacyUrl?: string | null;\n contactUrl?: string | null;\n logoUrl?: string | null;\n};\n\nfunction normalizeUrl(value: unknown): string {\n const s = typeof value === \"string\" ? value.trim() : \"\";\n if (!s || s === \"#\") return \"\";\n if (/^(mailto:|tel:|https?:\\/\\/|\\/)/i.test(s)) return s;\n return `https://${s.replace(/^\\/+/, \"\")}`;\n}\n\n/**\n * Footer props with org-derived defaults filled in.\n *\n * CLEARED vs UNSET is the whole point (ported from the app's\n * `resolveFooterContent`): a field that was never set (`undefined`) gets the\n * org default, but a field the user explicitly emptied (`\"\"`) is respected and\n * NOT re-populated — otherwise deleting the pre-filled company name types it\n * straight back in. Toggles work the same way: an explicit boolean wins, and a\n * toggle can only be on if there is a URL behind it.\n */\nexport function resolveFooterProps(rawProps: Record<string, unknown> | undefined, org?: FooterOrgInfo | null): FooterProps {\n const src = rawProps ?? {};\n const orgWebsite = normalizeUrl(org?.websiteUrl);\n const orgPrivacy = normalizeUrl(org?.privacyUrl);\n const orgContact = normalizeUrl(org?.contactUrl || org?.websiteUrl);\n const unset = (key: string) => src[key] === undefined || src[key] === null;\n const str = (key: string, fallback: string) => (unset(key) ? fallback : String(src[key]));\n const bool = (key: string, fallback: boolean) => (typeof src[key] === \"boolean\" ? (src[key] as boolean) : fallback);\n\n const websiteUrl = normalizeUrl(str(\"websiteUrl\", orgWebsite));\n const privacyUrl = normalizeUrl(str(\"privacyUrl\", orgPrivacy));\n const contactUrl = normalizeUrl(str(\"contactUrl\", orgContact));\n\n return {\n ...DEFAULT_FOOTER_PROPS,\n ...(src as Partial<FooterProps>),\n companyName: unset(\"companyName\") ? (org?.companyName ?? null) : (src.companyName as string),\n copyrightYear: unset(\"copyrightYear\") ? String(new Date().getFullYear()) : (src.copyrightYear as string),\n address: unset(\"address\") ? (org?.address ?? null) : (src.address as string),\n logoUrl: unset(\"logoUrl\") ? (org?.logoUrl ?? null) : (src.logoUrl as string),\n websiteUrl,\n websiteText: str(\"websiteText\", websiteUrl),\n privacyUrl,\n privacyText: str(\"privacyText\", DEFAULT_FOOTER_PROPS.privacyText),\n contactUrl,\n contactText: str(\"contactText\", DEFAULT_FOOTER_PROPS.contactText),\n showWebsite: bool(\"showWebsite\", Boolean(orgWebsite)) && Boolean(websiteUrl),\n showPrivacy: bool(\"showPrivacy\", false) && Boolean(privacyUrl),\n showContact: bool(\"showContact\", false) && Boolean(contactUrl),\n };\n}\n\nconst FONT_STACK = \"Arial, Helvetica, sans-serif\";\n\nfunction esc(s: string): string {\n return s.replace(/&/g, \"&amp;\").replace(/</g, \"&lt;\").replace(/>/g, \"&gt;\").replace(/\"/g, \"&quot;\");\n}\n\nfunction alignFor(h: FooterHPosition | undefined): string {\n return h === \"left\" ? \"left\" : h === \"right\" ? \"right\" : \"center\";\n}\n\n/** \"Paid for by {PAC NAME} ({PAC}) {PAC ID}\" — omitted entirely when incomplete. */\nexport function formatPaidForLine(paidFor: FooterPaidFor | null | undefined): string | null {\n if (!paidFor) return null;\n const { pacName, pac, pacId } = paidFor;\n if (!pacName?.trim() || !pac?.trim() || !pacId?.trim()) return null;\n return `Paid for by ${pacName} (${pac}) ${pacId}`;\n}\n\nexport function renderFooterHtml(\n rawProps: Record<string, unknown>,\n ctx: { physicalAddress: string; unsubscribeUrl: string; org?: FooterOrgInfo | null },\n): string {\n const p = resolveFooterProps(rawProps, ctx.org);\n const bg = p.background || \"transparent\";\n const color = p.fontColor || \"#8a8a8a\";\n const linkColor = p.linkColor || color;\n const font = p.fontFamily || FONT_STACK;\n const paidForLine = formatPaidForLine(p.paidFor);\n\n // Logo drops INSIDE the footer container and auto-sizes to the column while\n // capping so it never dominates the footer (was a fixed 40px cap that also\n // ignored width). Vertical placement is honored below by slotting the row.\n const logoWidthCss = p.logoWidth && p.logoWidth > 0 ? `width:${Math.round(p.logoWidth)}px;` : \"width:auto;\";\n const logo = p.logoUrl\n ? `<tr><td style=\"text-align:${alignFor(p.logoPosition?.h)};padding:0 0 8px;\">\n <img src=\"${esc(p.logoUrl)}\" alt=\"${esc(p.logoAlt || \"\")}\" style=\"display:inline-block;${logoWidthCss}height:auto;max-width:200px;max-height:80px;border:0;\" />\n </td></tr>`\n : \"\";\n\n // Org links (website / privacy / contact) sit alongside the custom links,\n // each shown only when its toggle is on AND it has a URL.\n const orgLinks: FooterLink[] = [\n p.showWebsite && p.websiteUrl ? { label: p.websiteText || p.websiteUrl, url: p.websiteUrl } : null,\n p.showPrivacy && p.privacyUrl ? { label: p.privacyText || \"Privacy Policy\", url: p.privacyUrl } : null,\n p.showContact && p.contactUrl ? { label: p.contactText || \"Contact Us\", url: p.contactUrl } : null,\n ].filter(Boolean) as FooterLink[];\n\n const links = [...(p.links || []), ...orgLinks].filter((l) => l.url && l.label);\n const linksRow = links.length\n ? `<tr><td style=\"text-align:${alignFor(p.linksPosition?.h)};padding:0 0 8px;\">\n ${links.map((l) => `<a href=\"${esc(l.url)}\" target=\"_blank\" rel=\"noopener noreferrer\" style=\"color:${esc(linkColor)};text-decoration:underline;margin:0 6px;\">${esc(l.label)}</a>`).join(\"\")}\n </td></tr>`\n : \"\";\n\n const companyLine = p.companyName?.trim()\n ? `<tr><td style=\"text-align:center;padding:0 0 6px;\">© ${esc(p.copyrightYear || String(new Date().getFullYear()))} ${esc(p.companyName.trim())}</td></tr>`\n : \"\";\n const extra = p.extraText ? `<tr><td style=\"text-align:center;padding:0 0 6px;\">${esc(p.extraText)}</td></tr>` : \"\";\n const paidFor = paidForLine ? `<tr><td style=\"text-align:center;padding:0 0 6px;\">${esc(paidForLine)}</td></tr>` : \"\";\n\n // Unsubscribe: always bottom-center, always present, never sourced from props.\n const unsubscribeRow = `<tr><td style=\"text-align:center;padding:0;\">\n <a href=\"${esc(ctx.unsubscribeUrl)}\" style=\"color:${esc(linkColor)};text-decoration:underline;\">Unsubscribe</a>\n </td></tr>`;\n const addressRow = `<tr><td style=\"text-align:center;padding:0 0 6px;\">${esc(ctx.physicalAddress)}</td></tr>`;\n // A display address different from the CAN-SPAM one renders above it; an\n // identical (or empty) one is skipped so the address is never doubled.\n const displayAddress = p.address?.trim();\n const displayAddressRow =\n displayAddress && displayAddress !== ctx.physicalAddress.trim()\n ? `<tr><td style=\"text-align:center;padding:0 0 6px;\">${esc(displayAddress)}</td></tr>`\n : \"\";\n\n // Vertical position (top | middle | bottom) slots the logo and links rows\n // among the stacked footer rows. Address stays above the always-last\n // unsubscribe row (CAN-SPAM), so \"bottom\" means just above the address block.\n const atTop = (v: FooterVPosition | undefined) => v === \"top\" || v === undefined;\n const atMiddle = (v: FooterVPosition | undefined) => v === \"middle\";\n const slot = (test: (v: FooterVPosition | undefined) => boolean) =>\n [test(p.logoPosition?.v) ? logo : \"\", test(p.linksPosition?.v) ? linksRow : \"\"].join(\"\");\n\n const pad = { ...DEFAULT_FOOTER_PROPS.padding, ...(p.padding || {}) };\n\n return `<tr><td style=\"background:${esc(bg)};padding:${pad.t}px ${pad.r}px ${pad.b}px ${pad.l}px;font-family:${font};font-size:12px;color:${esc(color)};border-top:1px solid #eaeaea;\">\n <table role=\"presentation\" width=\"100%\" cellpadding=\"0\" cellspacing=\"0\">\n ${slot(atTop)}\n ${companyLine}\n ${extra}\n ${paidFor}\n ${slot(atMiddle)}\n ${slot((v) => v === \"bottom\")}\n ${displayAddressRow}\n ${addressRow}\n ${unsubscribeRow}\n </table>\n </td></tr>`;\n}\n","// Mobile-mode override merge (Specs_Email-Engine \"Items to add to creative\n// canvass\" #5): edits made while the canvas is in mobile view write to\n// `block.mobile` (a partial prop override) instead of `block.props`, so\n// desktop values are never touched. Pure/serializable — used by both the\n// client editor (to compute what a settings field should display/write) and\n// the renderer (to compute the mobile media-query CSS override).\n\n/** Props as they should read while editing/previewing in mobile view: desktop\n * props with any mobile overrides layered on top. Never mutates its inputs. */\nexport function effectiveMobileProps(\n props: Record<string, unknown>,\n mobile: Record<string, unknown> | undefined,\n): Record<string, unknown> {\n return { ...props, ...(mobile ?? {}) };\n}\n\n/** True if `key` has a mobile-only override distinct from the desktop value. */\nexport function isMobileOverridden(mobile: Record<string, unknown> | undefined, key: string): boolean {\n return !!mobile && Object.prototype.hasOwnProperty.call(mobile, key);\n}\n\n/** Merge a patch into the mobile override map (does not touch `props`). */\nexport function setMobileOverride(\n mobile: Record<string, unknown> | undefined,\n patch: Record<string, unknown>,\n): Record<string, unknown> {\n return { ...(mobile ?? {}), ...patch };\n}\n\n/** Remove one key's mobile override, reverting that field to the desktop value. */\nexport function resetMobileOverride(\n mobile: Record<string, unknown> | undefined,\n key: string,\n): Record<string, unknown> {\n const next = { ...(mobile ?? {}) };\n delete next[key];\n return next;\n}\n\n/** Clear every mobile override on a block (\"Reset to desktop\" for the whole panel). */\nexport function clearMobileOverrides(): Record<string, unknown> {\n return {};\n}\n\n/** CSS-safe declaration list for one prop key's mobile value, keyed by CSS property. */\nconst CSS_PROP_MAP: Record<string, string> = {\n padding: \"padding\",\n fontSize: \"font-size\",\n color: \"color\",\n background: \"background\",\n bg: \"background\",\n};\n\n/**\n * Build the `@media (max-width: 600px)` class-scoped override block for one\n * block's mobile overrides. Class-based (not inline !important on the base\n * element) so it stays email-client-safe — clients that ignore <style>/media\n * queries just keep the desktop-rendered inline styles.\n */\nexport function mobileOverrideCss(blockId: string, mobile: Record<string, unknown> | undefined): string {\n if (!mobile || Object.keys(mobile).length === 0) return \"\";\n const decls: string[] = [];\n for (const [key, cssProp] of Object.entries(CSS_PROP_MAP)) {\n if (!(key in mobile)) continue;\n const value = mobile[key];\n if (value == null || value === \"\") continue;\n const cssValue = typeof value === \"number\" && (key === \"padding\" || key === \"fontSize\") ? `${value}px` : String(value);\n decls.push(`${cssProp}:${cssValue} !important;`);\n }\n if (mobile.align) decls.push(`text-align:${String(mobile.align)} !important;`);\n if (mobile.hide === true) decls.push(\"display:none !important;\");\n if (decls.length === 0) return \"\";\n return `@media (max-width: 600px) { .pg-block-${blockId} { ${decls.join(\" \")} } }`;\n}\n","// Sanitization for user-authored content (Specs_Email-Engine §15 Security:\n// \"Asset sanitization (SVG, uploaded files scanned)\"; \"HTML sanitization in\n// custom code blocks\"). No DOM sanitizer library is in this app's dependency\n// tree yet, so this is a conservative, dependency-free ALLOWLIST sanitizer —\n// it walks tag/attribute text rather than trusting a blocklist. Runs on both\n// server (media upload, render) and client (rich-text editor output) — no\n// `server-only` import here.\n\n// ---- Rich text HTML (Creative Canvas Text block) ----\n\nconst ALLOWED_TAGS = new Set([\n \"p\", \"br\", \"b\", \"strong\", \"i\", \"em\", \"u\", \"s\", \"strike\",\n \"h1\", \"h2\", \"h3\", \"h4\", \"h5\", \"h6\", \"ul\", \"ol\", \"li\", \"a\", \"span\", \"div\",\n]);\n\nconst ALLOWED_ATTRS: Record<string, Set<string>> = {\n a: new Set([\"href\", \"target\", \"rel\"]),\n span: new Set([\"style\"]),\n div: new Set([\"style\"]),\n p: new Set([\"style\"]),\n // tiptap writes text-align / line-height inline on headings and list items.\n h1: new Set([\"style\"]), h2: new Set([\"style\"]), h3: new Set([\"style\"]),\n h4: new Set([\"style\"]), h5: new Set([\"style\"]), h6: new Set([\"style\"]),\n li: new Set([\"style\"]), ul: new Set([\"style\"]), ol: new Set([\"style\"]),\n};\n\n// Only a small, safe subset of inline CSS properties (color/background/align/font).\nconst ALLOWED_STYLE_PROPS = new Set([\n \"color\", \"background-color\", \"text-align\", \"font-family\", \"font-size\", \"font-weight\", \"font-style\", \"text-decoration\",\n // tiptap's LineHeight extension writes an inline line-height on p/h*/li.\n \"line-height\",\n]);\n\nfunction sanitizeStyleValue(style: string): string {\n return style\n .split(\";\")\n .map((decl) => decl.trim())\n .filter(Boolean)\n .filter((decl) => {\n const [prop] = decl.split(\":\");\n return prop && ALLOWED_STYLE_PROPS.has(prop.trim().toLowerCase());\n })\n // strip anything that could break out of the value (url(), expression(), etc.)\n .filter((decl) => !/url\\s*\\(|expression\\s*\\(|javascript:/i.test(decl))\n .join(\"; \");\n}\n\nfunction sanitizeHref(href: string): string | null {\n const trimmed = href.trim();\n if (/^(https?:|mailto:|tel:)/i.test(trimmed)) return trimmed;\n if (trimmed.startsWith(\"#\") || trimmed.startsWith(\"/\")) return trimmed;\n return null; // reject javascript:, data:, vbscript:, unknown schemes\n}\n\n/**\n * Allowlist-sanitize rich-text HTML produced by the Text block editor.\n * Strips scripts/handlers/styles-with-injection and unknown tags/attrs,\n * unwrapping disallowed tags rather than dropping their text content.\n */\nexport function sanitizeRichText(html: string): string {\n if (!html) return \"\";\n // Fast rejects for the obviously dangerous constructs before parsing.\n let out = html\n .replace(/<!--([\\s\\S]*?)-->/g, \"\")\n .replace(/<script[\\s\\S]*?<\\/script>/gi, \"\")\n .replace(/<style[\\s\\S]*?<\\/style>/gi, \"\")\n .replace(/<iframe[\\s\\S]*?<\\/iframe>/gi, \"\");\n\n out = out.replace(/<\\/?([a-zA-Z0-9]+)((?:\\s+[^<>]*)?)\\/?>/g, (match, rawTag: string, rawAttrs: string) => {\n const tag = rawTag.toLowerCase();\n const isClosing = match.startsWith(\"</\");\n if (!ALLOWED_TAGS.has(tag)) return \"\"; // unwrap: drop the tag, keep surrounding text\n if (isClosing) return `</${tag}>`;\n\n const allowed = ALLOWED_ATTRS[tag];\n if (!allowed || !rawAttrs?.trim()) return `<${tag}>`;\n\n const attrs: string[] = [];\n const attrRe = /([a-zA-Z-]+)\\s*=\\s*\"([^\"]*)\"|([a-zA-Z-]+)\\s*=\\s*'([^']*)'/g;\n let m: RegExpExecArray | null;\n while ((m = attrRe.exec(rawAttrs))) {\n const name = (m[1] || m[3] || \"\").toLowerCase();\n let value = m[2] ?? m[4] ?? \"\";\n if (!allowed.has(name)) continue;\n if (name.startsWith(\"on\")) continue; // belt & suspenders — handlers never allowed\n if (name === \"href\") {\n const safe = sanitizeHref(value);\n if (!safe) continue;\n value = safe;\n }\n if (name === \"style\") {\n value = sanitizeStyleValue(value);\n if (!value) continue;\n }\n attrs.push(`${name}=\"${value.replace(/\"/g, \"&quot;\")}\"`);\n }\n if (tag === \"a\") attrs.push('rel=\"noopener noreferrer\"');\n return attrs.length ? `<${tag} ${attrs.join(\" \")}>` : `<${tag}>`;\n });\n\n // Strip any leftover inline event-handler attributes or javascript: URLs\n // that slipped through as raw text (defense in depth).\n out = out.replace(/\\son\\w+\\s*=\\s*\"[^\"]*\"/gi, \"\").replace(/\\son\\w+\\s*=\\s*'[^']*'/gi, \"\");\n return out.trim();\n}\n\n// ---- SVG sanitization (Media Library uploads) ----\n\nconst SVG_DANGEROUS = [\n /<script[\\s\\S]*?<\\/script>/gi,\n /<foreignObject[\\s\\S]*?<\\/foreignObject>/gi,\n /\\son\\w+\\s*=\\s*\"[^\"]*\"/gi,\n /\\son\\w+\\s*=\\s*'[^']*'/gi,\n /xlink:href\\s*=\\s*\"javascript:[^\"]*\"/gi,\n /href\\s*=\\s*\"javascript:[^\"]*\"/gi,\n];\n\n/**\n * Strip scripts, event handlers, and foreignObject payloads from an SVG file\n * before it enters the Media Library. Returns null if the input doesn't look\n * like an SVG at all (caller should reject the upload).\n */\nexport function sanitizeSvg(svg: string): string | null {\n if (!/<svg[\\s>]/i.test(svg)) return null;\n let out = svg;\n for (const re of SVG_DANGEROUS) out = out.replace(re, \"\");\n out = out.replace(/<!DOCTYPE[^>]*>/gi, \"\").replace(/<!ENTITY[^>]*>/gi, \"\");\n return out;\n}\n","// Renders an Email's blocks[] into table-based responsive HTML + a plain-text\n// fallback (Specs_Email-Engine §11 \"Renderer: responsive HTML output\").\n//\n// Block schema versioning (§17.1): each Block carries its own `version`. This\n// renderer keeps a case per shipped version per block type so a historical\n// email always renders the same way it did when it was sent, even after the\n// registry's *current* version for that type moves forward. Today there is\n// only version 1 of every block, so every switch has one case — the shape is\n// what future block-version bumps hook into (add a case, never mutate one).\nimport type { Block, EmailSettings } from \"../model/types\";\nimport type {\n ButtonSize, ButtonStyle, CardShadow, ColumnDistribution, PdfLinkMode,\n SocialColorScheme, SocialShape, SocialStyle, SocialVariant,\n} from \"./registry\";\nimport { sanitizeRichText } from \"./sanitize\";\nimport { mobileOverrideCss } from \"./mobile\";\nimport { renderFooterHtml, type FooterOrgInfo } from \"./footer\";\n\nexport type RenderContext = {\n /** CAN-SPAM physical mailing address (account-level, §15). */\n physicalAddress: string;\n /** Absolute unsubscribe URL for this send/recipient. */\n unsubscribeUrl: string;\n /** Personalization token values; missing tokens render as an empty string. */\n tokens?: Record<string, string>;\n darkMode?: boolean;\n /** Email-level outer/body background (v3 item 1); null/absent = renderer defaults. */\n settings?: EmailSettings | null;\n /** Active org's brand body font (UI-Platform §Typography). Used when a text/\n * heading block has no explicit font family, so the default follows brand\n * settings instead of a hardcoded Arial; null/absent falls back to FONT_STACK. */\n brandFontFamily?: string | null;\n /** Org facts the Footer block derives its defaults from (company name,\n * address, website/privacy/contact URLs, logo). Absent = no org defaults;\n * explicit footer props still render. */\n org?: FooterOrgInfo | null;\n};\n\nconst FONT_STACK = \"Arial, Helvetica, sans-serif\";\n\n// Official brand colors for the \"branded\" social-icon variant (canvas UX\n// feedback #8). Keyed by lowercased network name.\nconst SOCIAL_BRAND_COLORS: Record<string, string> = {\n facebook: \"#1877F2\",\n x: \"#000000\",\n twitter: \"#1DA1F2\",\n instagram: \"#E4405F\",\n linkedin: \"#0A66C2\",\n youtube: \"#FF0000\",\n tiktok: \"#000000\",\n threads: \"#000000\",\n pinterest: \"#BD081C\",\n snapchat: \"#FFFC00\",\n whatsapp: \"#25D366\",\n telegram: \"#26A5E4\",\n reddit: \"#FF4500\",\n bluesky: \"#0285FF\",\n mastodon: \"#6364FF\",\n};\n\nfunction esc(s: string): string {\n return s.replace(/&/g, \"&amp;\").replace(/</g, \"&lt;\").replace(/>/g, \"&gt;\").replace(/\"/g, \"&quot;\");\n}\n\nfunction applyTokens(html: string, tokens: Record<string, string> = {}): string {\n return html.replace(/\\{\\{\\s*([a-zA-Z0-9_]+)\\s*\\}\\}/g, (_m, key) => esc(tokens[key] ?? \"\"));\n}\n\nfunction addUtm(url: string): string {\n if (!url) return url;\n try {\n const u = new URL(url);\n if (!u.searchParams.has(\"utm_source\")) u.searchParams.set(\"utm_source\", \"politogy_email\");\n if (!u.searchParams.has(\"utm_medium\")) u.searchParams.set(\"utm_medium\", \"email\");\n return u.toString();\n } catch {\n return url; // relative/invalid URL — leave as-is rather than throw\n }\n}\n\nfunction mobileStyle(props: Record<string, unknown>, blockId?: string): string {\n const overrides = (props.mobileOverrides ?? {}) as { hide_on_mobile?: boolean };\n const classes = [overrides.hide_on_mobile ? \"pg-hide-mobile\" : null, blockId ? `pg-block-${blockId}` : null].filter(Boolean);\n return classes.length ? ` class=\"${classes.join(\" \")}\"` : \"\";\n}\n\n/** Shared padding (v3 item 7) — every content block reads `props.padding`; a\n * v1 block (or a v2 block that never set it) falls back to the same 8px\n * top/bottom default the renderer always used, so nothing shifts on upgrade. */\nfunction paddingStyle(props: Record<string, unknown>): string {\n const pad = (props.padding ?? {}) as Partial<{ t: number; r: number; b: number; l: number }>;\n const t = Number(pad.t ?? 8);\n const r = Number(pad.r ?? 0);\n const b = Number(pad.b ?? 8);\n const l = Number(pad.l ?? 0);\n return `padding:${t}px ${r}px ${b}px ${l}px;`;\n}\n\n/** Canvas defaults for the email-level width/padding settings (v4). Absent\n * settings must render exactly as they did before the fields existed. */\nexport const DEFAULT_CONTENT_WIDTH = 600;\nexport const DEFAULT_CANVAS_PADDING_Y = 20;\n\nfunction contentWidthPx(settings: EmailSettings | null | undefined): number {\n const w = Number(settings?.contentWidth ?? DEFAULT_CONTENT_WIDTH);\n return Number.isFinite(w) && w > 0 ? Math.round(w) : DEFAULT_CONTENT_WIDTH;\n}\n\n/**\n * Sanitize a CSS shorthand value coming from a prop (`padding: \"60px 20px\"`,\n * `margin: \"0 auto\"`, `height: \"300px\"`). These props are free text in the\n * settings panel, so anything that could close the declaration and start a new\n * one — `;`, `{`, quotes, `url(`, `expression(` — is dropped rather than\n * escaped. Empty/garbage input falls back to the block's own default.\n */\nfunction cssValue(raw: unknown, fallback: string): string {\n if (typeof raw !== \"string\" && typeof raw !== \"number\") return fallback;\n const s = String(raw).split(\";\")[0].trim();\n if (!s) return fallback;\n if (/url\\s*\\(|expression\\s*\\(|javascript:|[{}<>\"']/i.test(s)) return fallback;\n return /^[a-zA-Z0-9 .,%#()/_-]+$/.test(s) ? s : fallback;\n}\n\n/** First px/number in a CSS length (\"300px\" → 300, 24 → 24); fallback otherwise. */\nfunction cssLengthPx(raw: unknown, fallback: number): number {\n if (typeof raw === \"number\" && Number.isFinite(raw)) return raw;\n const m = typeof raw === \"string\" ? raw.match(/-?\\d+(\\.\\d+)?/) : null;\n return m ? Number(m[0]) : fallback;\n}\n\n/** Only http(s) image URLs reach a `background-image:url(...)` — never data:,\n * never javascript:, and never anything carrying a paren/quote that could\n * break out of the url() token. */\nfunction safeImageUrl(raw: unknown): string | null {\n if (typeof raw !== \"string\") return null;\n const s = raw.trim();\n if (!s) return null;\n if (!/^https?:\\/\\//i.test(s)) return null;\n if (/[\"'()\\s\\\\]/.test(s)) return null;\n return s;\n}\n\n/** Clamp an overlay opacity prop into 0–1. */\nfunction overlayOpacity(raw: unknown): number {\n const n = Number(raw ?? 0.4);\n if (!Number.isFinite(n)) return 0.4;\n return Math.max(0, Math.min(1, n));\n}\n\nconst CARD_SHADOW: Record<CardShadow, string> = {\n none: \"\",\n sm: \"box-shadow:0 1px 2px rgba(0,0,0,0.08);\",\n md: \"box-shadow:0 4px 8px rgba(0,0,0,0.10);\",\n lg: \"box-shadow:0 10px 20px rgba(0,0,0,0.12);\",\n};\n\n/**\n * Percentage width of each column for a distribution. Ratios are two-column by\n * definition; anything else (3+ columns, an unknown value) falls back to an\n * even split so a bad prop can never collapse a layout to 0%.\n */\nexport function columnWidths(columns: number, distribution?: ColumnDistribution | string | null): number[] {\n const cols = Math.max(1, Math.min(4, Math.floor(columns) || 1));\n const even = () => Array.from({ length: cols }, () => Math.floor(100 / cols));\n if (cols !== 2 || !distribution || distribution === \"equal\") return even();\n switch (distribution) {\n case \"1-2\": return [33, 67];\n case \"2-1\": return [67, 33];\n case \"1-3\": return [25, 75];\n case \"3-1\": return [75, 25];\n default: return even();\n }\n}\n\n/**\n * Raw-HTML sanitizer for the `html` block. Deliberately more permissive than\n * sanitizeRichText — an author pasting a designed email fragment needs tables,\n * images and a <style> block — but every active construct is removed: script/\n * iframe/object/embed/link/meta/base elements, every on* handler, and\n * javascript: URLs. Inside a surviving <style>, @import and expression() are\n * stripped so the tag can't pull in or execute anything either.\n */\nexport function sanitizeEmbeddedHtml(html: string): string {\n if (!html) return \"\";\n let out = html\n .replace(/<script[\\s\\S]*?<\\/script>/gi, \"\")\n .replace(/<script[^>]*\\/?>/gi, \"\")\n .replace(/<(iframe|object|embed|applet|form|frameset|frame)[\\s\\S]*?<\\/\\1>/gi, \"\")\n .replace(/<(iframe|object|embed|applet|form|frameset|frame|link|meta|base)[^>]*\\/?>/gi, \"\");\n out = out.replace(/<style([^>]*)>([\\s\\S]*?)<\\/style>/gi, (_m, attrs: string, css: string) => {\n const safeCss = css\n .replace(/@import[^;]*;?/gi, \"\")\n .replace(/expression\\s*\\([^)]*\\)/gi, \"\")\n .replace(/javascript:/gi, \"\")\n .replace(/behavior\\s*:[^;]*;?/gi, \"\");\n return `<style${attrs.replace(/\\son\\w+\\s*=\\s*(\"[^\"]*\"|'[^']*')/gi, \"\")}>${safeCss}</style>`;\n });\n out = out\n .replace(/\\son\\w+\\s*=\\s*\"[^\"]*\"/gi, \"\")\n .replace(/\\son\\w+\\s*=\\s*'[^']*'/gi, \"\")\n .replace(/\\son\\w+\\s*=\\s*[^\\s>]+/gi, \"\")\n .replace(/(href|src|action|xlink:href)\\s*=\\s*\"\\s*(javascript|vbscript|data):[^\"]*\"/gi, \"\")\n .replace(/(href|src|action|xlink:href)\\s*=\\s*'\\s*(javascript|vbscript|data):[^']*'/gi, \"\");\n return out;\n}\n\nconst BUTTON_SIZE: Record<ButtonSize, { fontSize: number; padY: number; padX: number }> = {\n sm: { fontSize: 13, padY: 8, padX: 16 },\n md: { fontSize: 15, padY: 12, padX: 24 },\n lg: { fontSize: 17, padY: 16, padX: 32 },\n};\n\n/** Button style variants (v3 item 4). Email-safe: no reliance on border-radius\n * beyond what mainstream clients (incl. Outlook via VML fallback elsewhere)\n * already tolerate on an <a>; underline/text-only drop the background entirely. */\nfunction buttonStyle(style: ButtonStyle, bg: string, color: string): string {\n switch (style) {\n case \"square\":\n return `background:${esc(bg)};border-radius:0;`;\n case \"underline\":\n return `background:transparent;color:${esc(color)};text-decoration:underline;border-radius:0;`;\n case \"text_only\":\n return `background:transparent;color:${esc(color)};text-decoration:none;border-radius:0;`;\n case \"rounded\":\n default:\n return `background:${esc(bg)};border-radius:6px;`;\n }\n}\n\n/** Renders a flat list of blocks as <tr> rows, for use inside a Section's <td> or a Column's cell. */\nfunction renderChildRows(children: Block[] | undefined, ctx: RenderContext, idPrefix: string): string {\n if (!children || children.length === 0) return \"\";\n return `<table role=\"presentation\" width=\"100%\" cellpadding=\"0\" cellspacing=\"0\">${children\n .map((c, i) => renderBlock(c, ctx, `${idPrefix}-${i}`))\n .join(\"\\n\")}</table>`;\n}\n\n/**\n * The `<td>` cells of a multi-column row. Shared by the Column block and by a\n * Section that carries `columnChildren` (V1 sections had their own columns).\n *\n * Two width models:\n * - `distribution` ratios → percentage widths (equal / 1-2 / 2-1 / 1-3 / 3-1);\n * - `sidebarWidth` (px, 2 columns only) → the Sidebar preset: that many px for\n * the sidebar cell, the remainder for the content cell. `sidebarPosition`\n * says which cell IS the sidebar — \"left\" = cell 0, \"right\" = cell 1 — so a\n * V1 sidebar node maps its sidebarChildren onto the matching index.\n */\nfunction renderColumnCells(block: Block, ctx: RenderContext, idPrefix: string, columns: number): string {\n const p = block.props as Record<string, unknown>;\n const cols = Math.max(1, Math.min(4, Math.floor(columns) || 1));\n const gap = Number(p.gap ?? 16);\n const colPad = Math.max(0, cssLengthPx(p.columnPadding, 0));\n const backgrounds = (p.columnBackgrounds as Array<string | null> | undefined) ?? [];\n const colChildren = block.columnChildren ?? [];\n\n const sidebarPx = Number(p.sidebarWidth ?? 0);\n const useSidebar = cols === 2 && Number.isFinite(sidebarPx) && sidebarPx > 0;\n let widths: string[];\n if (useSidebar) {\n const avail = contentWidthPx(ctx.settings);\n const side = Math.max(1, Math.min(avail - 1, Math.round(sidebarPx)));\n const rest = Math.max(1, avail - side);\n widths = p.sidebarPosition === \"right\" ? [`${rest}px`, `${side}px`] : [`${side}px`, `${rest}px`];\n } else {\n widths = columnWidths(cols, p.distribution as ColumnDistribution | undefined).map((w) => `${w}%`);\n }\n\n return Array.from({ length: cols })\n .map((_, i) => {\n const bg = backgrounds[i];\n const bgCss = bg ? `background:${esc(bg)};` : \"\";\n const inner = renderChildRows(colChildren[i], ctx, `${idPrefix}-${i}`) || \"&nbsp;\";\n return `<td style=\"width:${widths[i]};${bgCss}padding:${colPad}px ${gap / 2}px;vertical-align:top;\" class=\"pg-col\">${inner}</td>`;\n })\n .join(\"\");\n}\n\nfunction renderBlockHtml(block: Block, ctx: RenderContext, blockId?: string): string {\n const p = block.props as Record<string, unknown>;\n const wrapAttr = mobileStyle(p, blockId);\n\n switch (block.type) {\n case \"section\": {\n const bg = (p.background as string) || \"transparent\";\n const pad = Number(p.padding ?? 16);\n const bgImage = safeImageUrl(p.backgroundImage);\n const radius = cssLengthPx(p.borderRadius, 0);\n const bgImageCss = bgImage ? `background-image:url(${bgImage});background-size:cover;background-position:center;` : \"\";\n const radiusCss = radius ? `border-radius:${radius}px;` : \"\";\n // A section carrying columnChildren renders them as cells (V1 parity:\n // the app's Section has its own columns/distribution); otherwise it is\n // the flat children list it has always been.\n const secCols = Number(p.columns ?? 0);\n const inner =\n secCols > 1 && block.columnChildren\n ? renderColumnCells(block, ctx, blockId ?? \"s\", secCols)\n : renderChildRows(block.children, ctx, blockId ?? \"s\");\n return `<tr${wrapAttr}><td style=\"background:${esc(bg)};${bgImageCss}${radiusCss}padding:${pad}px;\">${inner}</td></tr>`;\n }\n case \"column\": {\n const cols = Math.max(1, Math.min(4, Number(p.columns ?? 2)));\n return `<tr${wrapAttr}><td><table role=\"presentation\" width=\"100%\"><tr class=\"pg-stack-mobile\">${renderColumnCells(block, ctx, blockId ?? \"c\", cols)}</tr></table></td></tr>`;\n }\n case \"hero\": {\n const bgColor = (p.backgroundColor as string) || \"#3182ce\";\n const bgImage = safeImageUrl(p.backgroundImage);\n const heightCss = cssValue(p.height, \"300px\");\n const padCss = cssValue(p.padding, \"60px 20px\");\n const align = [\"left\", \"center\", \"right\"].includes(String(p.textAlign)) ? String(p.textAlign) : \"center\";\n const radius = cssValue(p.borderRadius, \"12px\");\n const font = ctx.brandFontFamily || FONT_STACK;\n const width = contentWidthPx(ctx.settings);\n const heightPx = Math.max(1, cssLengthPx(p.height, 300));\n // Outlook ignores CSS background-image on a <td>; VML paints it there.\n const vmlOpen = bgImage\n ? `<!--[if gte mso 9]><v:rect xmlns:v=\"urn:schemas-microsoft-com:vml\" fill=\"true\" stroke=\"false\" style=\"width:${width}px;height:${heightPx}px;\"><v:fill type=\"frame\" src=\"${bgImage}\" color=\"${esc(bgColor)}\" /><v:textbox inset=\"0,0,0,0\"><![endif]-->`\n : \"\";\n const vmlClose = bgImage ? \"<!--[if gte mso 9]></v:textbox></v:rect><![endif]-->\" : \"\";\n // Overlay only means anything over an image; rgba degrades to no tint in\n // clients that drop it, which is the correct failure (text stays white on\n // the image rather than disappearing).\n const wantsOverlay = !!bgImage && p.overlay !== false;\n const overlayOpen = wantsOverlay ? `<div style=\"background-color:rgba(0,0,0,${overlayOpacity(p.overlayOpacity)});\">` : \"\";\n const overlayClose = wantsOverlay ? \"</div>\" : \"\";\n const titleRow = `<tr><td align=\"${align}\" style=\"padding:0 0 16px 0;color:#ffffff;font-family:${font};font-size:36px;line-height:1.2;font-weight:700;mso-line-height-rule:exactly;\">${applyTokens(esc((p.heroTitle as string) || \"\"), ctx.tokens)}</td></tr>`;\n const subtitleRow = (p.heroSubtitle as string)\n ? `<tr><td align=\"${align}\" style=\"padding:0;color:#f8fbff;font-family:${font};font-size:18px;line-height:1.4;mso-line-height-rule:exactly;\">${applyTokens(esc(p.heroSubtitle as string), ctx.tokens)}</td></tr>`\n : \"\";\n const childRows = block.children && block.children.length\n ? `<tr><td>${renderChildRows(block.children, ctx, `${blockId ?? \"h\"}-c`)}</td></tr>`\n : \"\";\n return `<tr${wrapAttr}><td bgcolor=\"${esc(bgColor)}\" align=\"${align}\" valign=\"middle\" style=\"background-color:${esc(bgColor)};${bgImage ? `background-image:url(${bgImage});background-size:cover;background-position:center;` : \"\"}padding:${padCss};text-align:${align};height:${heightCss};border-radius:${radius};overflow:hidden;color:#ffffff;font-family:${font};\">${vmlOpen}${overlayOpen}<table role=\"presentation\" width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\" style=\"width:100%;border-collapse:collapse;\">${titleRow}${subtitleRow}${childRows}</table>${overlayClose}${vmlClose}</td></tr>`;\n }\n case \"card\": {\n const bg = (p.backgroundColor as string) || \"#f7fafc\";\n const borderColor = (p.borderColor as string) || \"#e2e8f0\";\n const borderWidth = cssValue(p.borderWidth, \"1px\");\n const radius = cssValue(p.borderRadius, \"8px\");\n const padCss = cssValue(p.padding, \"20px\");\n const shadow = CARD_SHADOW[(p.shadow as CardShadow) || \"sm\"] ?? CARD_SHADOW.sm;\n return `<tr${wrapAttr}><td style=\"padding:8px 0;\"><table role=\"presentation\" width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\" style=\"width:100%;border-collapse:separate;background-color:${esc(bg)};border:${borderWidth} solid ${esc(borderColor)};border-radius:${radius};${shadow}\"><tr><td style=\"padding:${padCss};\">${renderChildRows(block.children, ctx, `${blockId ?? \"cd\"}`)}</td></tr></table></td></tr>`;\n }\n case \"container\": {\n const bg = (p.backgroundColor as string) || \"transparent\";\n const maxWidthCss = cssValue(p.maxWidth, \"600px\");\n const maxWidthPx = Math.max(1, cssLengthPx(p.maxWidth, contentWidthPx(ctx.settings)));\n const padCss = cssValue(p.padding, \"20px\");\n const marginCss = cssValue(p.margin, \"0 auto\");\n const align = /auto/.test(marginCss) ? \"center\" : \"left\";\n return `<tr${wrapAttr}><td align=\"${align}\" style=\"background:${esc(bg)};\"><table role=\"presentation\" width=\"${maxWidthPx}\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\" align=\"${align}\" style=\"width:100%;max-width:${maxWidthCss};margin:${marginCss};border-collapse:collapse;\"><tr><td style=\"padding:${padCss};\">${renderChildRows(block.children, ctx, `${blockId ?? \"ct\"}`)}</td></tr></table></td></tr>`;\n }\n case \"pdf\": {\n const url = (p.url as string) || \"\";\n const fileName = (p.fileName as string) || \"Document.pdf\";\n const linkMode = ((p.linkMode as PdfLinkMode) || \"download\") as PdfLinkMode;\n const title = (p.title as string) || (linkMode === \"download\" ? \"Download PDF\" : \"Open PDF\");\n const align = [\"left\", \"center\", \"right\"].includes(String(p.align)) ? String(p.align) : \"left\";\n const bg = (p.backgroundColor as string) || \"#f8fafc\";\n const textColor = (p.textColor as string) || \"#1f2937\";\n const accent = (p.accentColor as string) || \"#ea580c\";\n const radius = cssValue(p.borderRadius, \"12px\");\n const padCss = cssValue(p.padding, \"16px\");\n const href = url ? esc(addUtm(url)) : \"#\";\n const downloadAttr = linkMode === \"download\" ? ` download=\"${esc(fileName)}\"` : \"\";\n return `<tr${wrapAttr}><td align=\"${align}\" style=\"text-align:${align};padding:8px 0;\"><table role=\"presentation\" width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\" style=\"width:100%;border-collapse:separate;background-color:${esc(bg)};border:1px solid #e5e7eb;border-radius:${radius};\"><tr><td style=\"padding:${padCss};font-family:${FONT_STACK};color:${esc(textColor)};\">\n <div style=\"font-size:14px;font-weight:600;margin-bottom:4px;\">${esc(fileName)}</div>\n <div style=\"font-size:13px;line-height:1.5;margin-bottom:12px;\">${esc((p.description as string) || \"\")}</div>\n <a href=\"${href}\" target=\"_blank\" rel=\"noopener noreferrer\"${downloadAttr} style=\"display:inline-block;padding:10px 14px;background-color:${esc(accent)};color:#ffffff;text-decoration:none;border-radius:8px;font-weight:600;font-family:${FONT_STACK};\">${esc(title)}</a>\n </td></tr></table></td></tr>`;\n }\n case \"html\": {\n // Author-supplied markup: sanitized (scripts/handlers/frames removed,\n // <style> kept) but otherwise emitted as written.\n const bg = (p.backgroundColor as string) || \"transparent\";\n return `<tr${wrapAttr}><td style=\"background:${esc(bg)};\">${applyTokens(sanitizeEmbeddedHtml((p.html as string) || \"\"), ctx.tokens)}</td></tr>`;\n }\n case \"spacer\":\n return `<tr${wrapAttr}><td style=\"height:${Number(p.height ?? 24)}px;line-height:${Number(p.height ?? 24)}px;font-size:1px;\">&nbsp;</td></tr>`;\n case \"divider\":\n return `<tr${wrapAttr}><td style=\"padding:8px 0;\"><hr style=\"border:none;border-top:${Number(p.thickness ?? 1)}px solid ${esc((p.color as string) || \"#e2e2e2\")};\" /></td></tr>`;\n case \"heading\": {\n const level = Math.max(1, Math.min(4, Number(p.level ?? 2)));\n const sizeMap: Record<number, number> = { 1: 32, 2: 26, 3: 22, 4: 18 };\n const color = (p.color as string) || \"#111111\";\n const headingFont = (p.fontFamily as string) || ctx.brandFontFamily || FONT_STACK;\n return `<tr${wrapAttr}><td style=\"${paddingStyle(p)}\"><h${level} style=\"margin:0;font-family:${headingFont};font-size:${sizeMap[level]}px;color:${esc(color)};text-align:${esc((p.align as string) || \"left\")};\">${applyTokens(esc((p.text as string) || \"\"), ctx.tokens)}</h${level}></td></tr>`;\n }\n case \"text\": {\n const html = sanitizeRichText((p.html as string) || \"\");\n const font = (p.fontFamily as string) || ctx.brandFontFamily || FONT_STACK;\n const size = Number(p.fontSize ?? 16);\n const color = (p.color as string) || \"#111111\";\n const bg = (p.background as string) || \"transparent\";\n const align = (p.align as string) || \"left\";\n // Line height (canvas UX feedback: single / 1.5 / double). Back-compat:\n // a v1/v2 block that never set it keeps the 1.5 the renderer always used.\n const lineHeight = Number(p.lineHeight ?? 1.5);\n return `<tr${wrapAttr}><td style=\"${paddingStyle(p)}background:${esc(bg)};\"><div style=\"font-family:${font};font-size:${size}px;color:${esc(color)};text-align:${esc(align)};line-height:${lineHeight};\">${applyTokens(html, ctx.tokens)}</div></td></tr>`;\n }\n case \"image\": {\n const url = (p.url as string) || \"\";\n const alt = (p.alt as string) || \"\";\n if (!url) return `<tr${wrapAttr}><td></td></tr>`;\n const link = p.link as string | null;\n const img = `<img src=\"${esc(url)}\" alt=\"${esc(alt)}\" width=\"100%\" style=\"display:block;width:100%;max-width:${esc((p.width as string) || \"100%\")};height:auto;border:0;\" />`;\n return `<tr${wrapAttr}><td style=\"${paddingStyle(p)}\">${link ? `<a href=\"${esc(addUtm(link))}\" target=\"_blank\" rel=\"noopener noreferrer\">${img}</a>` : img}</td></tr>`;\n }\n case \"button\": {\n const url = addUtm((p.url as string) || \"\");\n const bg = (p.bg as string) || \"#1d4ed8\";\n const color = (p.color as string) || \"#ffffff\";\n const align = (p.align as string) || \"center\";\n const style = ((p.style as ButtonStyle) || \"rounded\") as ButtonStyle;\n const size = BUTTON_SIZE[(p.size as ButtonSize) || \"md\"];\n const variantCss = buttonStyle(style, bg, color);\n return `<tr${wrapAttr}><td style=\"${paddingStyle(p)}text-align:${esc(align)};\"><a href=\"${esc(url)}\" target=\"_blank\" rel=\"noopener noreferrer\" style=\"display:inline-block;${variantCss}color:${esc(color)};padding:${size.padY}px ${size.padX}px;font-family:${FONT_STACK};font-size:${size.fontSize}px;font-weight:600;\">${applyTokens(esc((p.text as string) || \"Click here\"), ctx.tokens)}</a></td></tr>`;\n }\n case \"video\": {\n const thumb = (p.thumbnailUrl as string) || \"\";\n const link = (p.link as string) || \"\";\n if (!thumb) return `<tr${wrapAttr}><td></td></tr>`;\n const img = `<img src=\"${esc(thumb)}\" alt=\"${esc((p.thumbnailAlt as string) || \"Video\")}\" width=\"100%\" style=\"display:block;width:100%;height:auto;border:0;\" />`;\n return `<tr${wrapAttr}><td style=\"${paddingStyle(p)}\">${link ? `<a href=\"${esc(link)}\" target=\"_blank\" rel=\"noopener noreferrer\">${img}</a>` : img}</td></tr>`;\n }\n case \"social_icons\": {\n const links = (p.links as Array<{ network: string; url: string; enabled?: boolean }>) ?? [];\n const size = Number(p.size ?? 24);\n const variant = ((p.variant as SocialVariant) || \"branded\") as SocialVariant;\n const shape = ((p.shape as SocialShape) || \"circle\") as SocialShape;\n const iconColor = (p.iconColor as string) || \"#ffffff\";\n // \"branded\" now paints each swatch in that network's official brand color\n // (so branded ≠ solid); \"solid\" uses the one user-chosen bgColor for all.\n // Glyph is still the network initial — a hosted brand-glyph image set is\n // tracked separately (email clients strip inline SVG), so this is an\n // honest color-only branding, not a faked icon set.\n const solidBg = (p.bgColor as string) || \"#111827\";\n // VRM-app parity props (`style` solid|outline|minimal, `colorScheme`\n // brand|black|white|custom). They are opt-in: a block that never set\n // colorScheme keeps the legacy variant/bgColor behavior byte-for-byte,\n // and a block that never set style keeps the filled swatch.\n const hasScheme = p.colorScheme !== undefined;\n const scheme = (p.colorScheme as SocialColorScheme) || \"brand\";\n const iconStyle = ((p.style as SocialStyle) || \"solid\") as SocialStyle;\n const spacing = Number(p.spacing ?? 12);\n const brandFor = (network: string) => SOCIAL_BRAND_COLORS[network.trim().toLowerCase()] || solidBg;\n const colorFor = (network: string) => {\n if (!hasScheme) return variant === \"solid\" ? solidBg : brandFor(network);\n if (scheme === \"custom\") return (p.customColor as string) || brandFor(network);\n if (scheme === \"black\") return \"#000000\";\n if (scheme === \"white\") return \"#ffffff\";\n return brandFor(network);\n };\n const radius = shape === \"circle\" ? \"50%\" : \"8px\";\n const cells = links\n .filter((l) => l.enabled !== false)\n .map((l) => {\n const c = colorFor(l.network);\n const bg = iconStyle === \"solid\" ? esc(c) : \"transparent\";\n const border = iconStyle === \"outline\" ? `border:2px solid ${esc(c)};` : \"\";\n const glyph = iconStyle === \"solid\" ? esc(iconColor) : esc(c);\n const margin = Math.max(0, Math.round(spacing / 2));\n return `<a href=\"${esc(l.url)}\" target=\"_blank\" rel=\"noopener noreferrer\" style=\"display:inline-block;margin:0 ${margin}px;\"><span style=\"display:inline-block;width:${size}px;height:${size}px;background:${bg};${border}border-radius:${radius};text-align:center;color:${glyph};font-family:${FONT_STACK};font-size:${Math.floor(size / 2)}px;line-height:${size}px;\">${esc(l.network.slice(0, 1).toUpperCase())}</span></a>`;\n })\n .join(\"\");\n return `<tr${wrapAttr}><td style=\"${paddingStyle(p)}text-align:${esc((p.align as string) || \"center\")};\">${cells}</td></tr>`;\n }\n case \"footer\":\n return renderFooterHtml(p, ctx);\n case \"unsupported\": {\n // Passthrough: re-emit the host's pre-rendered HTML verbatim so a\n // foreign/legacy block round-trips losslessly. Empty/missing html leaves\n // a marker comment rather than an empty row — never crashes on bad props.\n const html = typeof p.html === \"string\" ? p.html : \"\";\n return html ? html : \"<!-- unsupported block preserved -->\";\n }\n case \"survey\": {\n const idOrUrl = (p.surveyIdOrUrl as string) || \"\";\n const url = /^https?:/i.test(idOrUrl) ? idOrUrl : `https://surveys.politogyvrm.com/s/${encodeURIComponent(idOrUrl)}`;\n return `<tr${wrapAttr}><td style=\"${paddingStyle(p)}text-align:center;\"><a href=\"${esc(addUtm(url))}\" target=\"_blank\" rel=\"noopener noreferrer\" style=\"display:inline-block;background:#111827;color:#fff;padding:12px 24px;border-radius:6px;font-family:${FONT_STACK};font-weight:600;text-decoration:none;\">${esc((p.ctaText as string) || \"Take the survey\")}</a></td></tr>`;\n }\n case \"form\": {\n // Contract-only per §17.5 — no Forms data contract yet, so this\n // renders an honest disabled card rather than a broken/fake form.\n return `<tr${wrapAttr}><td style=\"${paddingStyle(p)}border:1px dashed #c9c9c9;border-radius:8px;text-align:center;font-family:${FONT_STACK};font-size:13px;color:#8a8a8a;\">Form block activates when Forms ships</td></tr>`;\n }\n default:\n return `<tr${wrapAttr}><td></td></tr>`;\n }\n}\n\n/**\n * v1/v2 rendering for every block type. v2 (registry bump, v3 items 4/7/8)\n * only ADDED optional props with backward-compatible defaults in\n * renderBlockHtml, so a v1 block renders through the same code path unchanged.\n */\nfunction renderBlock(block: Block, ctx: RenderContext, blockId?: string): string {\n if (block.version === 1 || block.version === 2) return renderBlockHtml(block, ctx, blockId);\n // Unknown/future version: fall back to the shared renderer rather than crash.\n return renderBlockHtml(block, ctx, blockId);\n}\n\n/**\n * Guarantee exactly ONE footer, always the last top-level row (CAN-SPAM). A\n * footer can end up nested inside a Section/Column (dropped there by mistake)\n * or duplicated; the top-level \"has a footer?\" check missed the nested case and\n * appended a second, so the preview showed two footers while the canvas showed\n * one. This strips every footer from anywhere in the tree and re-appends a\n * single one at the end, carrying the first found footer's props forward.\n */\nfunction normalizeFooter(blocks: Block[]): Block[] {\n const found: Block[] = [];\n // Single depth-first pass in document order, generic over BOTH nested-content\n // shapes so a footer dropped into any container (Section, Card, Container,\n // Hero, a Column cell) is found — and so \"the first footer\" means the same\n // thing here as it does in the editor's tree-level normalizeFooter.\n const strip = (list: Block[] | undefined): Block[] => {\n const out: Block[] = [];\n for (const b of list ?? []) {\n if (b.type === \"footer\") {\n found.push(b);\n continue;\n }\n let next = b;\n if (b.children) next = { ...next, children: strip(b.children) };\n if (b.columnChildren) next = { ...next, columnChildren: b.columnChildren.map((c) => strip(c)) };\n out.push(next);\n }\n return out;\n };\n const stripped = strip(blocks);\n return [...stripped, found[0] ?? ({ type: \"footer\" as const, version: 1, props: {} } as Block)];\n}\n\nexport function renderEmailHtml(blocks: Block[], ctx: RenderContext): string {\n const withFooter = normalizeFooter(blocks);\n const rows = withFooter.map((b, i) => renderBlock(b, ctx, String(i))).join(\"\\n\");\n const mobileCss = withFooter\n .map((b, i) => mobileOverrideCss(String(i), b.mobile))\n .filter(Boolean)\n .join(\"\\n \");\n const darkBg = ctx.darkMode ? \"#161616\" : \"#ffffff\";\n const darkText = ctx.darkMode ? \"#f2f2f2\" : \"#111111\";\n // v3 item 1: Canvas Settings outer/body background. Explicit settings\n // always win over the dark/light default so a chosen brand color survives\n // a preview theme toggle; unset falls back to the existing dark/light bg.\n const outerBg = ctx.settings?.outerBackground || darkBg;\n const bodyBg = ctx.settings?.bodyBackground || darkBg;\n // v4: content column width + vertical canvas padding. Absent settings must\n // render exactly as before the fields existed — fixed 600px, 20px top/bottom.\n const fluid = ctx.settings?.widthMode === \"fluid\";\n const cw = contentWidthPx(ctx.settings);\n const padTop = Math.max(0, Number(ctx.settings?.paddingTop ?? DEFAULT_CANVAS_PADDING_Y));\n const padBottom = Math.max(0, Number(ctx.settings?.paddingBottom ?? DEFAULT_CANVAS_PADDING_Y));\n const contentWidthAttr = fluid ? `width=\"100%\"` : `width=\"${cw}\"`;\n const contentWidthCss = fluid ? \"width:100%;\" : `width:${cw}px;max-width:100%;`;\n return `<!doctype html>\n<html>\n<head>\n<meta charset=\"utf-8\" />\n<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" />\n<style>\n body { margin:0; padding:0; background:${outerBg}; color:${darkText}; }\n .pg-hide-mobile { }\n @media (max-width: 480px) {\n .pg-hide-mobile { display:none !important; }\n .pg-stack-mobile { display:block !important; width:100% !important; }\n .pg-col { display:block !important; width:100% !important; padding:8px 0 !important; }\n }\n ${mobileCss}\n</style>\n</head>\n<body>\n<table role=\"presentation\" width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" style=\"background:${outerBg};\">\n<tr><td align=\"center\" style=\"padding:${padTop}px 0 ${padBottom}px 0;\">\n<table role=\"presentation\" ${contentWidthAttr} cellpadding=\"0\" cellspacing=\"0\" style=\"${contentWidthCss}background:${bodyBg};\">\n${rows}\n</table>\n</td></tr>\n</table>\n</body>\n</html>`;\n}\n\nfunction stripTags(html: string): string {\n return html\n .replace(/<br\\s*\\/?>/gi, \"\\n\")\n .replace(/<\\/(p|div|h[1-4]|li|tr)>/gi, \"\\n\")\n .replace(/<[^>]+>/g, \"\")\n .replace(/&nbsp;/g, \" \")\n .replace(/&amp;/g, \"&\")\n .replace(/&lt;/g, \"<\")\n .replace(/&gt;/g, \">\")\n .replace(/&quot;/g, '\"')\n .replace(/\\n{3,}/g, \"\\n\\n\")\n .trim();\n}\n\nfunction renderBlocksText(blocks: Block[], ctx: RenderContext): string[] {\n const lines: string[] = [];\n for (const b of blocks) {\n const p = b.props as Record<string, unknown>;\n switch (b.type) {\n case \"heading\":\n lines.push(applyTokens((p.text as string) || \"\", ctx.tokens));\n break;\n case \"text\":\n lines.push(stripTags(applyTokens(sanitizeRichText((p.html as string) || \"\"), ctx.tokens)));\n break;\n case \"button\":\n lines.push(`${applyTokens((p.text as string) || \"Click here\", ctx.tokens)}: ${addUtm((p.url as string) || \"\")}`);\n break;\n case \"survey\":\n lines.push(`${(p.ctaText as string) || \"Take the survey\"}: ${p.surveyIdOrUrl as string}`);\n break;\n case \"hero\":\n lines.push(applyTokens((p.heroTitle as string) || \"\", ctx.tokens));\n lines.push(applyTokens((p.heroSubtitle as string) || \"\", ctx.tokens));\n break;\n case \"pdf\":\n lines.push(`${(p.title as string) || (p.fileName as string) || \"PDF\"}: ${(p.url as string) || \"\"}`);\n break;\n case \"html\":\n lines.push(stripTags(sanitizeEmbeddedHtml((p.html as string) || \"\")));\n break;\n default:\n break;\n }\n // Nested content (Section/Card/Container/Hero children, Column cells) is\n // part of the message, so the plain-text alternative must include it too.\n const nested = [...(b.children ?? []), ...(b.columnChildren ?? []).flat()];\n if (nested.length) lines.push(...renderBlocksText(nested, ctx));\n }\n return lines;\n}\n\nexport function renderEmailText(blocks: Block[], ctx: RenderContext): string {\n const lines = renderBlocksText(blocks, ctx);\n lines.push(\"\", ctx.physicalAddress, `Unsubscribe: ${ctx.unsubscribeUrl}`);\n return lines.filter(Boolean).join(\"\\n\\n\");\n}\n\nexport function pinBlockSchemaVersion(blocks: Block[]): Block[] {\n return blocks.map((b) => ({ ...b, version: b.version ?? 1 }));\n}\n"]}
@@ -1,4 +1,4 @@
1
- import { DEFAULT_FOOTER_PROPS } from './chunk-6XOUU7UE.js';
1
+ import { DEFAULT_FOOTER_PROPS } from './chunk-6WG7YK6K.js';
2
2
 
3
3
  // src/blocks/registry.ts
4
4
  var DEFAULT_BLOCK_PADDING = { t: 8, r: 0, b: 8, l: 0 };
@@ -250,6 +250,21 @@ var BLOCK_LIBRARY = [
250
250
  function getBlockDefinition(type) {
251
251
  return BLOCK_LIBRARY.find((b) => b.type === type);
252
252
  }
253
+ var CHILD_CONTAINER_TYPES = ["section", "card", "container"];
254
+ function isChildContainerType(type) {
255
+ return CHILD_CONTAINER_TYPES.includes(type);
256
+ }
257
+ function createBlockFromLibrary(type) {
258
+ const def = getBlockDefinition(type);
259
+ if (!def) return null;
260
+ return {
261
+ type: def.type,
262
+ version: def.version,
263
+ props: { ...def.defaultProps },
264
+ ...isChildContainerType(def.type) ? { children: (def.defaultChildren ?? []).map((c) => ({ ...c, props: { ...c.props } })) } : {},
265
+ ...def.type === "column" ? { columnChildren: Array.from({ length: Number(def.defaultProps.columns ?? 2) }, () => []) } : {}
266
+ };
267
+ }
253
268
  function libraryByCategory() {
254
269
  const shown = BLOCK_LIBRARY.filter((b) => !b.hiddenFromLibrary);
255
270
  return {
@@ -632,6 +647,6 @@ function shouldReseed({ incomingUpdatedAt, lastSavedUpdatedAt }) {
632
647
  return incomingUpdatedAt >= lastSavedUpdatedAt;
633
648
  }
634
649
 
635
- export { BLOCK_LIBRARY, DEFAULT_BLOCK_PADDING, EMAIL_SAFE_FONTS, FONT_CATALOG, NON_EMAIL_SAFE_FONTS, PADDING_SIZE_OPTIONS, PERSONALIZATION_TOKENS, applyPaddingPreset, buildDraftSignature, buildFontMenu, containerDropId, containerOf, findById, getBlockDefinition, getButtonSpacingPreset, getFontFamilyLabel, getPresetShorthand, getPresetsForKind, getPrimaryFontFamily, hasMirroredSides, insertInto, isContainerWithin, isEmailSafeFontFamily, libraryByCategory, mapById, moveAcross, normalizeFooter, paddingToShorthand, parseContainerDropId, removeById, reorderWithin, resolveButtonSpacingPreset, resolvePaddingPreset, shorthandToPadding, shouldReseed, stepPaddingSide, stripIds, withIds };
636
- //# sourceMappingURL=chunk-XQ4AURVN.js.map
637
- //# sourceMappingURL=chunk-XQ4AURVN.js.map
650
+ export { BLOCK_LIBRARY, CHILD_CONTAINER_TYPES, DEFAULT_BLOCK_PADDING, EMAIL_SAFE_FONTS, FONT_CATALOG, NON_EMAIL_SAFE_FONTS, PADDING_SIZE_OPTIONS, PERSONALIZATION_TOKENS, applyPaddingPreset, buildDraftSignature, buildFontMenu, containerDropId, containerOf, createBlockFromLibrary, findById, getBlockDefinition, getButtonSpacingPreset, getFontFamilyLabel, getPresetShorthand, getPresetsForKind, getPrimaryFontFamily, hasMirroredSides, insertInto, isChildContainerType, isContainerWithin, isEmailSafeFontFamily, libraryByCategory, mapById, moveAcross, normalizeFooter, paddingToShorthand, parseContainerDropId, removeById, reorderWithin, resolveButtonSpacingPreset, resolvePaddingPreset, shorthandToPadding, shouldReseed, stepPaddingSide, stripIds, withIds };
651
+ //# sourceMappingURL=chunk-M6WYBQCT.js.map
652
+ //# sourceMappingURL=chunk-M6WYBQCT.js.map