@bendyline/squisq 2.0.1 → 2.1.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/dist/{Doc-ylqWKDc_.d.ts → Doc-DynJleo-.d.ts} +159 -2
- package/dist/{ImageEditDoc-D828IXJ1.d.ts → ImageEditDoc-Ca4Tr9uN.d.ts} +1 -1
- package/dist/{chunk-PXLVXTLW.js → chunk-ILWDXLUK.js} +24 -6
- package/dist/chunk-ILWDXLUK.js.map +1 -0
- package/dist/{chunk-W4O2TX5I.js → chunk-JHZWYRSW.js} +569 -1
- package/dist/chunk-JHZWYRSW.js.map +1 -0
- package/dist/{chunk-X6DUONGT.js → chunk-JI77MGAK.js} +123 -10
- package/dist/chunk-JI77MGAK.js.map +1 -0
- package/dist/{chunk-TFJVXUHH.js → chunk-OTKVFVL6.js} +1403 -41
- package/dist/chunk-OTKVFVL6.js.map +1 -0
- package/dist/{chunk-MMPBOUK7.js → chunk-QUUPYOSP.js} +8 -2
- package/dist/chunk-QUUPYOSP.js.map +1 -0
- package/dist/chunk-VWCJ2WXC.js +215 -0
- package/dist/chunk-VWCJ2WXC.js.map +1 -0
- package/dist/{chunk-2PWOO4ZE.js → chunk-VYFRI7R6.js} +2 -2
- package/dist/{chunk-CY2R2VPR.js → chunk-XNLB57UD.js} +2 -2
- package/dist/doc/index.d.ts +144 -5
- package/dist/doc/index.js +24 -4
- package/dist/generate/index.d.ts +1 -1
- package/dist/imageEdit/index.d.ts +3 -3
- package/dist/index.d.ts +6 -5
- package/dist/index.js +66 -8
- package/dist/jsonForm/index.d.ts +1 -1
- package/dist/jsonForm/index.js +4 -4
- package/dist/materializePageSection-DDzubQXo.d.ts +223 -0
- package/dist/narration/index.d.ts +1 -1
- package/dist/narration/index.js +3 -3
- package/dist/schemas/index.d.ts +30 -5
- package/dist/schemas/index.js +41 -3
- package/dist/{themeLibrary-RjVgLpUi.d.ts → themeLibrary-B72m0W1y.d.ts} +1 -1
- package/dist/transform/index.d.ts +8 -9
- package/dist/transform/index.js +1 -1
- package/package.json +1 -1
- package/src/__tests__/materializeBlockLayers.test.ts +32 -0
- package/src/__tests__/materializePageSections.test.ts +404 -0
- package/src/__tests__/pageStyle.test.ts +258 -0
- package/src/__tests__/templateAnnotationParse.test.ts +13 -0
- package/src/doc/index.ts +34 -0
- package/src/doc/materializeBlockLayers.ts +170 -9
- package/src/doc/page/PageSection.ts +174 -0
- package/src/doc/page/materializePageSection.ts +616 -0
- package/src/doc/page/resolvePageBlock.ts +108 -0
- package/src/doc/page/sectionExtractors.ts +466 -0
- package/src/doc/pageCss.ts +628 -0
- package/src/doc/templateInputs.ts +1 -0
- package/src/schemas/Doc.ts +22 -1
- package/src/schemas/PageStyle.ts +213 -0
- package/src/schemas/Theme.ts +7 -0
- package/src/schemas/index.ts +2 -0
- package/src/schemas/pageStyleDefaults.ts +204 -0
- package/src/schemas/themeCompile.ts +7 -0
- package/src/schemas/themeValidator.ts +183 -0
- package/src/schemas/themes/bold.json +29 -0
- package/src/schemas/themes/cinematic.json +32 -0
- package/src/schemas/themes/documentary.json +29 -0
- package/src/schemas/themes/gezellig.json +30 -0
- package/src/schemas/themes/magazine.json +37 -0
- package/src/schemas/themes/minimalist.json +29 -0
- package/src/schemas/themes/morning-light.json +32 -0
- package/src/schemas/themes/standard-dark.json +24 -0
- package/src/schemas/themes/standard.json +24 -0
- package/src/schemas/themes/tech-dark.json +42 -0
- package/src/schemas/themes/warm-earth.json +24 -0
- package/src/transform/registry.ts +19 -0
- package/src/transform/styles/dataDriven.ts +1 -0
- package/src/transform/styles/documentary.ts +1 -0
- package/src/transform/styles/magazine.ts +1 -0
- package/src/transform/styles/minimal.ts +1 -0
- package/src/transform/styles/narrative.ts +1 -0
- package/src/transform/types.ts +7 -0
- package/dist/chunk-FVJUUTEM.js +0 -74
- package/dist/chunk-FVJUUTEM.js.map +0 -1
- package/dist/chunk-MMPBOUK7.js.map +0 -1
- package/dist/chunk-PXLVXTLW.js.map +0 -1
- package/dist/chunk-TFJVXUHH.js.map +0 -1
- package/dist/chunk-W4O2TX5I.js.map +0 -1
- package/dist/chunk-X6DUONGT.js.map +0 -1
- /package/dist/{chunk-2PWOO4ZE.js.map → chunk-VYFRI7R6.js.map} +0 -0
- /package/dist/{chunk-CY2R2VPR.js.map → chunk-XNLB57UD.js.map} +0 -0
|
@@ -1142,6 +1142,138 @@ interface ProgressIndicatorConfig {
|
|
|
1142
1142
|
color?: string;
|
|
1143
1143
|
}
|
|
1144
1144
|
|
|
1145
|
+
/**
|
|
1146
|
+
* Page Style — the theme's art-direction layer for Page (linear) mode.
|
|
1147
|
+
*
|
|
1148
|
+
* Slides render through fixed-viewport SVG templates; pages render through
|
|
1149
|
+
* a small closed vocabulary of variable-height HTML section layouts
|
|
1150
|
+
* (`PageSectionKind`). A `ThemePageStyle` is how a theme art-directs that
|
|
1151
|
+
* page rendition: it picks a design family, sets page-wide tokens
|
|
1152
|
+
* (column widths, spacing, dividers, hero treatment, image framing …),
|
|
1153
|
+
* and can override how individual section kinds or block templates map
|
|
1154
|
+
* onto the section vocabulary.
|
|
1155
|
+
*
|
|
1156
|
+
* Design principles (mirrors the rest of the Theme schema):
|
|
1157
|
+
* - Fully JSON-serializable — rides the `squisq-custom-themes` frontmatter
|
|
1158
|
+
* codec unchanged.
|
|
1159
|
+
* - Closed enums everywhere so renderers can switch exhaustively and the
|
|
1160
|
+
* validator can reject typos.
|
|
1161
|
+
* - Optional on `Theme`; `resolvePageStyle`/`defaultPageStyle` derive a
|
|
1162
|
+
* complete style from existing theme fields when absent, so legacy and
|
|
1163
|
+
* customizer themes keep working without edits.
|
|
1164
|
+
*/
|
|
1165
|
+
/**
|
|
1166
|
+
* The closed set of page section layouts. Every block template maps onto
|
|
1167
|
+
* one of these kinds (see `doc/page/sectionExtractors.ts`); themes may
|
|
1168
|
+
* remap via `ThemePageStyle.sections` / `.templates`.
|
|
1169
|
+
*/
|
|
1170
|
+
declare const PAGE_SECTION_KINDS: readonly ["hero", "banner", "stat-band", "quote-band", "feature-split", "media-figure", "gallery", "callout", "card-grid", "item-list", "timeline-rail", "table-section", "canvas-embed", "prose", "footer"];
|
|
1171
|
+
type PageSectionKind = (typeof PAGE_SECTION_KINDS)[number];
|
|
1172
|
+
/** Relative visual weight of a section within the page. */
|
|
1173
|
+
type PageEmphasis = 'lead' | 'strong' | 'standard' | 'quiet';
|
|
1174
|
+
/** Which background treatment a section sits on. */
|
|
1175
|
+
type PageBackground = 'base' | 'alternate' | 'accent' | 'media';
|
|
1176
|
+
/**
|
|
1177
|
+
* Broad page design personalities. A family selects the structural
|
|
1178
|
+
* skeleton (how sections compose); tokens parameterize it per theme.
|
|
1179
|
+
*/
|
|
1180
|
+
declare const PAGE_DESIGN_FAMILIES: readonly ["clean", "editorial", "brutalist", "terminal", "cinematic", "documentary", "organic", "soft"];
|
|
1181
|
+
type PageDesignFamily = (typeof PAGE_DESIGN_FAMILIES)[number];
|
|
1182
|
+
/** How headings announce themselves across the page. */
|
|
1183
|
+
interface PageHeadingTreatment {
|
|
1184
|
+
/** Small label above headings: none, plain kicker, "01 —" numbering, or a mono tag. */
|
|
1185
|
+
eyebrow: 'none' | 'kicker' | 'numbered' | 'mono-tag';
|
|
1186
|
+
/** Overall heading size register. */
|
|
1187
|
+
scale: 'regular' | 'display' | 'oversized';
|
|
1188
|
+
/** Optional case transform for headings/eyebrows. */
|
|
1189
|
+
case?: 'none' | 'uppercase';
|
|
1190
|
+
/** Optional decoration under headings. */
|
|
1191
|
+
underline?: 'none' | 'accent-bar' | 'full-rule';
|
|
1192
|
+
}
|
|
1193
|
+
/**
|
|
1194
|
+
* Page-wide design tokens. Structural CSS reads these via
|
|
1195
|
+
* `--squisq-page-*` custom properties (see `doc/pageCss.ts`).
|
|
1196
|
+
*/
|
|
1197
|
+
interface PageTokens {
|
|
1198
|
+
/** Reading-column max width in px (prose, callouts, quotes). */
|
|
1199
|
+
contentMaxWidth: number;
|
|
1200
|
+
/** Wide-band inner max width in px (figures, tables, feature splits). */
|
|
1201
|
+
wideMaxWidth: number;
|
|
1202
|
+
/** Vertical rhythm between sections. */
|
|
1203
|
+
sectionSpacing: 'compact' | 'comfortable' | 'generous';
|
|
1204
|
+
/** Corner radius for cards, media frames, panels (px). */
|
|
1205
|
+
cornerRadius: number;
|
|
1206
|
+
/** Divider treatment between sections. */
|
|
1207
|
+
divider: 'none' | 'gap-only' | 'hairline' | 'thick-rule' | 'double-rule' | 'dotted';
|
|
1208
|
+
/** How section backgrounds vary down the page. */
|
|
1209
|
+
backgroundRhythm: 'flat' | 'alternate' | 'accent-bands' | 'tinted-panels';
|
|
1210
|
+
/** Hero (cover/title) composition. */
|
|
1211
|
+
heroStyle: 'stacked' | 'split' | 'full-bleed' | 'letterbox' | 'oversized-type';
|
|
1212
|
+
/** Heading voice across the page. */
|
|
1213
|
+
headingTreatment: PageHeadingTreatment;
|
|
1214
|
+
/** Frame treatment for photographic media. */
|
|
1215
|
+
imageFraming: 'flush' | 'rounded' | 'bordered' | 'polaroid' | 'letterboxed' | 'circle-accent';
|
|
1216
|
+
/** Shadow language for elevated elements. */
|
|
1217
|
+
shadow: 'none' | 'soft' | 'crisp' | 'heavy';
|
|
1218
|
+
/** Decoration on quote sections. */
|
|
1219
|
+
quoteMark: 'none' | 'oversized-glyph' | 'accent-bar';
|
|
1220
|
+
/** Treatment of large stat numerals. */
|
|
1221
|
+
numeralStyle: 'plain' | 'oversized' | 'boxed' | 'mono';
|
|
1222
|
+
/** Optional page background pattern. */
|
|
1223
|
+
pattern?: 'none' | 'dots' | 'grid' | 'diagonal' | 'noise';
|
|
1224
|
+
}
|
|
1225
|
+
/**
|
|
1226
|
+
* A theme's override for one section kind or one block template —
|
|
1227
|
+
* remap the kind, force a variant, adjust emphasis/background, or pass
|
|
1228
|
+
* freeform scalar hints the section renderer understands.
|
|
1229
|
+
*/
|
|
1230
|
+
interface PageSectionOverride {
|
|
1231
|
+
kind?: PageSectionKind;
|
|
1232
|
+
variant?: string;
|
|
1233
|
+
emphasis?: PageEmphasis;
|
|
1234
|
+
background?: PageBackground;
|
|
1235
|
+
/** Freeform scalar hints (e.g. `dropCap: true`, `frame: "terminal"`). */
|
|
1236
|
+
hints?: Record<string, string | number | boolean>;
|
|
1237
|
+
}
|
|
1238
|
+
/** How named color schemes rotate across accent-bearing sections. */
|
|
1239
|
+
interface PageAccentRotation {
|
|
1240
|
+
strategy: 'primary-only' | 'cycle' | 'alternate-two' | 'none';
|
|
1241
|
+
/**
|
|
1242
|
+
* ColorScheme names (keys of `theme.colorSchemes`) to rotate through.
|
|
1243
|
+
* Defaults to all schemes in insertion order.
|
|
1244
|
+
*/
|
|
1245
|
+
schemes?: string[];
|
|
1246
|
+
}
|
|
1247
|
+
/**
|
|
1248
|
+
* The complete page art direction for a theme. Optional on `Theme`;
|
|
1249
|
+
* `defaultPageStyle(theme)` derives one from existing theme fields.
|
|
1250
|
+
*/
|
|
1251
|
+
interface ThemePageStyle {
|
|
1252
|
+
family: PageDesignFamily;
|
|
1253
|
+
tokens: PageTokens;
|
|
1254
|
+
/** Per-section-kind overrides. */
|
|
1255
|
+
sections?: Partial<Record<PageSectionKind, PageSectionOverride>>;
|
|
1256
|
+
/** Per-template overrides (canonical template ids); win over `sections`. */
|
|
1257
|
+
templates?: Record<string, PageSectionOverride>;
|
|
1258
|
+
accentRotation: PageAccentRotation;
|
|
1259
|
+
}
|
|
1260
|
+
declare const PAGE_SECTION_SPACINGS: readonly ["compact", "comfortable", "generous"];
|
|
1261
|
+
declare const PAGE_DIVIDERS: readonly ["none", "gap-only", "hairline", "thick-rule", "double-rule", "dotted"];
|
|
1262
|
+
declare const PAGE_BACKGROUND_RHYTHMS: readonly ["flat", "alternate", "accent-bands", "tinted-panels"];
|
|
1263
|
+
declare const PAGE_HERO_STYLES: readonly ["stacked", "split", "full-bleed", "letterbox", "oversized-type"];
|
|
1264
|
+
declare const PAGE_EYEBROWS: readonly ["none", "kicker", "numbered", "mono-tag"];
|
|
1265
|
+
declare const PAGE_HEADING_SCALES: readonly ["regular", "display", "oversized"];
|
|
1266
|
+
declare const PAGE_HEADING_CASES: readonly ["none", "uppercase"];
|
|
1267
|
+
declare const PAGE_HEADING_UNDERLINES: readonly ["none", "accent-bar", "full-rule"];
|
|
1268
|
+
declare const PAGE_IMAGE_FRAMINGS: readonly ["flush", "rounded", "bordered", "polaroid", "letterboxed", "circle-accent"];
|
|
1269
|
+
declare const PAGE_SHADOWS: readonly ["none", "soft", "crisp", "heavy"];
|
|
1270
|
+
declare const PAGE_QUOTE_MARKS: readonly ["none", "oversized-glyph", "accent-bar"];
|
|
1271
|
+
declare const PAGE_NUMERAL_STYLES: readonly ["plain", "oversized", "boxed", "mono"];
|
|
1272
|
+
declare const PAGE_PATTERNS: readonly ["none", "dots", "grid", "diagonal", "noise"];
|
|
1273
|
+
declare const PAGE_EMPHASES: readonly ["lead", "strong", "standard", "quiet"];
|
|
1274
|
+
declare const PAGE_BACKGROUNDS: readonly ["base", "alternate", "accent", "media"];
|
|
1275
|
+
declare const PAGE_ACCENT_STRATEGIES: readonly ["primary-only", "cycle", "alternate-two", "none"];
|
|
1276
|
+
|
|
1145
1277
|
/** Current Theme schema version. Bump on breaking changes; loader migrates. */
|
|
1146
1278
|
declare const THEME_SCHEMA_VERSION: "1";
|
|
1147
1279
|
|
|
@@ -1344,6 +1476,12 @@ interface Theme {
|
|
|
1344
1476
|
colorSchemes: Record<string, ThemeColorScheme>;
|
|
1345
1477
|
/** Optional persistent layers baked into the theme */
|
|
1346
1478
|
persistentLayers?: PersistentLayerConfig;
|
|
1479
|
+
/**
|
|
1480
|
+
* Optional page art direction for Page (linear) mode. When absent,
|
|
1481
|
+
* `resolvePageStyle`/`defaultPageStyle` derive one from the fields above,
|
|
1482
|
+
* so legacy themes render pages without declaring this.
|
|
1483
|
+
*/
|
|
1484
|
+
pageStyle?: ThemePageStyle;
|
|
1347
1485
|
}
|
|
1348
1486
|
/**
|
|
1349
1487
|
* Recursively makes every property optional.
|
|
@@ -1819,7 +1957,7 @@ interface Block {
|
|
|
1819
1957
|
* A visual element within a block.
|
|
1820
1958
|
* Layers are composited back-to-front (first layer is background).
|
|
1821
1959
|
*/
|
|
1822
|
-
type Layer = ImageLayer | TextLayer | ShapeLayer | PathLayer | MapLayer | VideoLayer | TableLayer | TreeLayer;
|
|
1960
|
+
type Layer = ImageLayer | TextLayer | ShapeLayer | PathLayer | MapLayer | VideoLayer | TableLayer | TreeLayer | MermaidLayer;
|
|
1823
1961
|
interface BaseLayer {
|
|
1824
1962
|
/** Unique identifier for this layer */
|
|
1825
1963
|
id: string;
|
|
@@ -2176,6 +2314,25 @@ interface TreeLayerStyle {
|
|
|
2176
2314
|
/** FontAwesome icon token for leaves (default `file`). */
|
|
2177
2315
|
fileIcon?: string;
|
|
2178
2316
|
}
|
|
2317
|
+
/**
|
|
2318
|
+
* Mermaid diagram layer — renders an authored `mermaid` code fence through
|
|
2319
|
+
* the official Mermaid runtime while keeping the fence source authoritative.
|
|
2320
|
+
* Like video/table/tree layers, the browser renderer hosts the diagram in an
|
|
2321
|
+
* SVG `<foreignObject>` so it participates in slide layout and frame capture.
|
|
2322
|
+
*/
|
|
2323
|
+
interface MermaidLayer extends BaseLayer {
|
|
2324
|
+
type: 'mermaid';
|
|
2325
|
+
content: {
|
|
2326
|
+
/** Complete Mermaid source, excluding the Markdown fence delimiters. */
|
|
2327
|
+
source: string;
|
|
2328
|
+
/** Theme-derived panel color behind the generated SVG. */
|
|
2329
|
+
background?: string;
|
|
2330
|
+
/** Theme-derived foreground used by loading/error states. */
|
|
2331
|
+
foreground?: string;
|
|
2332
|
+
/** Inner panel padding in pixels. */
|
|
2333
|
+
padding?: number;
|
|
2334
|
+
};
|
|
2335
|
+
}
|
|
2179
2336
|
/**
|
|
2180
2337
|
* Available map tile styles from free/open-source providers.
|
|
2181
2338
|
*/
|
|
@@ -2385,4 +2542,4 @@ declare function getBlockAtTime(blocks: Block[], time: number): Block | null;
|
|
|
2385
2542
|
*/
|
|
2386
2543
|
declare function getCaptionAtTime(captions: CaptionTrack | undefined, time: number): CaptionPhrase | null;
|
|
2387
2544
|
|
|
2388
|
-
export { type MapBlockInput as $, type AccentImage as A, type Block as B, type CaptionPhrase as C, DARK_SURFACE as D, type DiagramTemplateNode as E, type Doc as F, type DocBlock as G, type DocDiagnostic as H, type DrawingBlockInput as I, FRONTMATTER_CUSTOM_TEMPLATES_KEY as J, FRONTMATTER_CUSTOM_THEMES_KEY as K, type FactCardInput as L, type FontFamily as M, type FontFamilyKind as N, type FullBleedQuoteInput as O, type GradientBackgroundConfig as P, type ImageBackgroundConfig as Q, type ImageLayer as R, type ImageTreatment as S, type ImageWithCaptionInput as T, LIGHT_SURFACE as U, type Layer as V, type LayerRepeat as W, type LayoutHints as X, type LeftFeatureInput as Y, type LinearGradient as Z, type ListBlockInput as _, type AccentPosition as a, type
|
|
2545
|
+
export { type MapBlockInput as $, type AccentImage as A, type Block as B, type CaptionPhrase as C, DARK_SURFACE as D, type DiagramTemplateNode as E, type Doc as F, type DocBlock as G, type DocDiagnostic as H, type DrawingBlockInput as I, FRONTMATTER_CUSTOM_TEMPLATES_KEY as J, FRONTMATTER_CUSTOM_THEMES_KEY as K, type FactCardInput as L, type FontFamily as M, type FontFamilyKind as N, type FullBleedQuoteInput as O, type GradientBackgroundConfig as P, type ImageBackgroundConfig as Q, type ImageLayer as R, type ImageTreatment as S, type ImageWithCaptionInput as T, LIGHT_SURFACE as U, type Layer as V, type LayerRepeat as W, type LayoutHints as X, type LeftFeatureInput as Y, type LinearGradient as Z, type ListBlockInput as _, type AccentPosition as a, type TextLayer as a$, type MapLayer as a0, type MapMarker as a1, type MapTileStyle as a2, type MarkerStyle as a3, type MediaClip as a4, type MermaidLayer as a5, PAGE_ACCENT_STRATEGIES as a6, PAGE_BACKGROUNDS as a7, PAGE_BACKGROUND_RHYTHMS as a8, PAGE_DESIGN_FAMILIES as a9, type PersistentLayerTemplate as aA, type PersistentLayerTemplateConfig as aB, type PersistentLayerTemplateType as aC, type PhotoGridInput as aD, type Position as aE, type ProgressIndicatorConfig as aF, type PullQuoteInput as aG, type QuoteBlockInput as aH, type RawLayersInput as aI, type RenderStyle as aJ, type RightFeatureInput as aK, type ScheduledClip as aL, type SectionHeaderInput as aM, type ShapeFilter as aN, type ShapeLayer as aO, type ShapePattern as aP, type SolidBackgroundConfig as aQ, type StartBlockConfig as aR, type StatHighlightInput as aS, type SurfaceScheme as aT, THEME_SCHEMA_VERSION as aU, type TableLayer as aV, type TableLayerStyle as aW, type TemplateBlock as aX, type TemplateContext as aY, type TemplateFunction as aZ, type TemplateRegistry as a_, PAGE_DIVIDERS as aa, PAGE_EMPHASES as ab, PAGE_EYEBROWS as ac, PAGE_HEADING_CASES as ad, PAGE_HEADING_SCALES as ae, PAGE_HEADING_UNDERLINES as af, PAGE_HERO_STYLES as ag, PAGE_IMAGE_FRAMINGS as ah, PAGE_NUMERAL_STYLES as ai, PAGE_PATTERNS as aj, PAGE_QUOTE_MARKS as ak, PAGE_SECTION_KINDS as al, PAGE_SECTION_SPACINGS as am, PAGE_SHADOWS as an, type PageAccentRotation as ao, type PageBackground as ap, type PageDesignFamily as aq, type PageEmphasis as ar, type PageHeadingTreatment as as, type PageSectionKind as at, type PageSectionOverride as au, type PageTokens as av, type PathLayer as aw, type PatternBackgroundConfig as ax, type PersistentLayer as ay, type PersistentLayerConfig as az, type AmbientGradientConfig as b, type TextStyle as b0, type Theme as b1, type ThemeColorPalette as b2, type ThemeColorScheme as b3, type ThemePageStyle as b4, type ThemeRegistry as b5, type ThemeSchemaVersion as b6, type ThemeSeedColors as b7, type ThemeStyle as b8, type ThemeTypography as b9, getAspectRatioString as bA, getBlockAtTime as bB, getCaptionAtTime as bC, getDocPlaybackDuration as bD, getLayoutHints as bE, getSafeTextBounds as bF, getSegmentAtTime as bG, getTwoColumnPositions as bH, getViewport as bI, getViewportOrientation as bJ, isPersistentLayerTemplate as bK, isTemplateBlock as bL, scaledFontSize$1 as bM, resolveMediaSchedule as bN, scaledFontSize as bO, type TimelineBlockInput as ba, type TimelineTemplateEvent as bb, type TimelineTemplateLink as bc, type TimelineTemplateTrack as bd, type TitleBlockInput as be, type TitleCaptionConfig as bf, type TreeBlockInput as bg, type TreeLayer as bh, type TreeLayerItem as bi, type TreeLayerStyle as bj, type TreeTemplateItem as bk, type TwoColumnInput as bl, VIEWPORT_PRESETS as bm, type VideoLayer as bn, type VideoPullQuoteInput as bo, type VideoWithCaptionInput as bp, type ViewportConfig as bq, type ViewportOrientation as br, type ViewportPreset as bs, type VignetteConfig as bt, applySurface as bu, calculateDuration as bv, calculateFontScale as bw, createTemplateContext as bx, createTheme as by, createThemeRegistry as bz, type Animation as c, type AnimationType as d, type AudioBookmark as e, type AudioSegment as f, type AudioTimingData as g, type AudioTrack as h, type BlockConnection as i, type BorderStyle as j, type CaptionTrack as k, type CaptionWord as l, type ColorScheme as m, type ComparisonBarInput as n, type CornerBrandingConfig as o, type CustomTemplateDefinition as p, type CustomTemplateLayer as q, DEFAULT_DOC_FONT as r, DEFAULT_TITLE_FONT as s, type DataTableInput as t, type DateEventInput as u, type DeepPartial as v, type DefinitionCardInput as w, type DiagramBlockInput as x, type DiagramEdgeAnchor as y, type DiagramTemplateEdge as z };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { R as ImageLayer,
|
|
1
|
+
import { R as ImageLayer, a$ as TextLayer, aO as ShapeLayer, aw as PathLayer } from './Doc-DynJleo-.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* ImageEditDoc — JSON document describing a layered, editable image.
|
|
@@ -32,7 +32,8 @@ var documentaryStyle = {
|
|
|
32
32
|
interleaveImages: true,
|
|
33
33
|
blocksPerSection: { max: 3 },
|
|
34
34
|
transitionStyle: "fade",
|
|
35
|
-
suggestedThemeId: "documentary"
|
|
35
|
+
suggestedThemeId: "documentary",
|
|
36
|
+
page: { spacing: "generous", emphasisCurve: "front-loaded" }
|
|
36
37
|
};
|
|
37
38
|
|
|
38
39
|
// src/transform/styles/magazine.ts
|
|
@@ -49,7 +50,8 @@ var magazineStyle = {
|
|
|
49
50
|
blocksPerSection: { max: 5 },
|
|
50
51
|
transitionStyle: "dissolve",
|
|
51
52
|
suggestedThemeId: "magazine",
|
|
52
|
-
templateMap: { quote: "pullQuote", impactLine: "fullBleedQuote" }
|
|
53
|
+
templateMap: { quote: "pullQuote", impactLine: "fullBleedQuote" },
|
|
54
|
+
page: { spacing: "comfortable", emphasisCurve: "front-loaded" }
|
|
53
55
|
};
|
|
54
56
|
|
|
55
57
|
// src/transform/styles/dataDriven.ts
|
|
@@ -65,7 +67,8 @@ var dataDrivenStyle = {
|
|
|
65
67
|
interleaveImages: false,
|
|
66
68
|
blocksPerSection: { max: 6 },
|
|
67
69
|
transitionStyle: "cut",
|
|
68
|
-
suggestedThemeId: "tech-dark"
|
|
70
|
+
suggestedThemeId: "tech-dark",
|
|
71
|
+
page: { spacing: "compact", emphasisCurve: "even" }
|
|
69
72
|
};
|
|
70
73
|
|
|
71
74
|
// src/transform/styles/narrative.ts
|
|
@@ -82,7 +85,8 @@ var narrativeStyle = {
|
|
|
82
85
|
blocksPerSection: { max: 4 },
|
|
83
86
|
transitionStyle: "fade",
|
|
84
87
|
suggestedThemeId: "cinematic",
|
|
85
|
-
pacing: { intro: true, outro: true }
|
|
88
|
+
pacing: { intro: true, outro: true },
|
|
89
|
+
page: { spacing: "comfortable", emphasisCurve: "even" }
|
|
86
90
|
};
|
|
87
91
|
|
|
88
92
|
// src/transform/styles/minimal.ts
|
|
@@ -98,7 +102,8 @@ var minimalStyle = {
|
|
|
98
102
|
interleaveImages: false,
|
|
99
103
|
blocksPerSection: { max: 2 },
|
|
100
104
|
transitionStyle: "fade",
|
|
101
|
-
suggestedThemeId: "minimalist"
|
|
105
|
+
suggestedThemeId: "minimalist",
|
|
106
|
+
page: { spacing: "generous", emphasisCurve: "even" }
|
|
102
107
|
};
|
|
103
108
|
|
|
104
109
|
// src/transform/registry.ts
|
|
@@ -189,6 +194,19 @@ function validateTransformStyle(style) {
|
|
|
189
194
|
fail("budget.slidesPerMinute must be a positive finite number");
|
|
190
195
|
}
|
|
191
196
|
}
|
|
197
|
+
const pageValue = candidate.page;
|
|
198
|
+
if (pageValue !== void 0) {
|
|
199
|
+
if (!pageValue || typeof pageValue !== "object" || Array.isArray(pageValue)) {
|
|
200
|
+
fail("page must be an object");
|
|
201
|
+
}
|
|
202
|
+
const page = pageValue;
|
|
203
|
+
if (page.spacing !== void 0 && !["compact", "comfortable", "generous"].includes(page.spacing)) {
|
|
204
|
+
fail("page.spacing must be compact, comfortable, or generous");
|
|
205
|
+
}
|
|
206
|
+
if (page.emphasisCurve !== void 0 && !["even", "front-loaded"].includes(page.emphasisCurve)) {
|
|
207
|
+
fail("page.emphasisCurve must be even or front-loaded");
|
|
208
|
+
}
|
|
209
|
+
}
|
|
192
210
|
}
|
|
193
211
|
function styleSnapshot(style) {
|
|
194
212
|
validateTransformStyle(style);
|
|
@@ -791,4 +809,4 @@ export {
|
|
|
791
809
|
analyzeBlocks,
|
|
792
810
|
applyTransform
|
|
793
811
|
};
|
|
794
|
-
//# sourceMappingURL=chunk-
|
|
812
|
+
//# sourceMappingURL=chunk-ILWDXLUK.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/transform/styles/documentary.ts","../src/transform/styles/magazine.ts","../src/transform/styles/dataDriven.ts","../src/transform/styles/narrative.ts","../src/transform/styles/minimal.ts","../src/transform/registry.ts","../src/transform/blockAnalyzer.ts","../src/transform/templateSelector.ts","../src/transform/timingAllocator.ts","../src/transform/applyTransform.ts"],"sourcesContent":["import type { TransformStyleConfig } from '../types.js';\n\n/** Conservative style — sparse highlights, preserves most text as-is. */\nexport const documentaryStyle: TransformStyleConfig = {\n id: 'documentary',\n name: 'Documentary',\n description: 'Conservative — highlights only the strongest stats, dates, and quotes',\n minConfidence: 0.5,\n transformRatio: 0.3,\n preferredTypes: ['stat', 'date', 'quote', 'fact'],\n colorSchemes: ['blue', 'green', 'purple'],\n insertSectionHeaders: false,\n interleaveImages: true,\n blocksPerSection: { max: 3 },\n transitionStyle: 'fade',\n suggestedThemeId: 'documentary',\n page: { spacing: 'generous', emphasisCurve: 'front-loaded' },\n};\n","import type { TransformStyleConfig } from '../types.js';\n\n/** Visual variety — pull quotes, definitions, image-heavy layout. */\nexport const magazineStyle: TransformStyleConfig = {\n id: 'magazine',\n name: 'Magazine',\n description: 'Visual variety with pull quotes, facts, and rich image layouts',\n minConfidence: 0.4,\n transformRatio: 0.6,\n preferredTypes: ['quote', 'fact', 'list', 'definition', 'stat', 'impactLine'],\n colorSchemes: ['blue', 'green', 'purple', 'orange', 'red'],\n insertSectionHeaders: true,\n interleaveImages: true,\n blocksPerSection: { max: 5 },\n transitionStyle: 'dissolve',\n suggestedThemeId: 'magazine',\n templateMap: { quote: 'pullQuote', impactLine: 'fullBleedQuote' },\n page: { spacing: 'comfortable', emphasisCurve: 'front-loaded' },\n};\n","import type { TransformStyleConfig } from '../types.js';\n\n/** Numbers-forward — aggressively extracts stats, comparisons, and dates. */\nexport const dataDrivenStyle: TransformStyleConfig = {\n id: 'data-driven',\n name: 'Data-Driven',\n description: 'Aggressively highlights statistics, comparisons, and timelines',\n minConfidence: 0.3,\n transformRatio: 0.8,\n preferredTypes: ['stat', 'comparison', 'date', 'list', 'fact'],\n colorSchemes: ['blue', 'orange', 'green', 'purple', 'red'],\n insertSectionHeaders: true,\n interleaveImages: false,\n blocksPerSection: { max: 6 },\n transitionStyle: 'cut',\n suggestedThemeId: 'tech-dark',\n page: { spacing: 'compact', emphasisCurve: 'even' },\n};\n","import type { TransformStyleConfig } from '../types.js';\n\n/** Timeline-focused — emphasizes dates, quotes, and story arc. */\nexport const narrativeStyle: TransformStyleConfig = {\n id: 'narrative',\n name: 'Narrative',\n description: 'Story-driven with timeline events, quotes, and impact moments',\n minConfidence: 0.4,\n transformRatio: 0.5,\n preferredTypes: ['date', 'quote', 'impactLine', 'fact', 'stat'],\n colorSchemes: ['blue', 'purple', 'green'],\n insertSectionHeaders: true,\n interleaveImages: true,\n blocksPerSection: { max: 4 },\n transitionStyle: 'fade',\n suggestedThemeId: 'cinematic',\n pacing: { intro: true, outro: true },\n page: { spacing: 'comfortable', emphasisCurve: 'even' },\n};\n","import type { TransformStyleConfig } from '../types.js';\n\n/** Light touch — only the highest-confidence items get transformed. */\nexport const minimalStyle: TransformStyleConfig = {\n id: 'minimal',\n name: 'Minimal',\n description: 'Light touch — only the strongest highlights, mostly text',\n minConfidence: 0.6,\n transformRatio: 0.2,\n preferredTypes: ['stat', 'quote'],\n colorSchemes: ['blue', 'green'],\n insertSectionHeaders: false,\n interleaveImages: false,\n blocksPerSection: { max: 2 },\n transitionStyle: 'fade',\n suggestedThemeId: 'minimalist',\n page: { spacing: 'generous', emphasisCurve: 'even' },\n};\n","/**\n * Transform Style Registry\n *\n * Immutable built-in lookup plus explicit caller-owned custom registries.\n * There is deliberately no process-global mutable registry.\n */\n\nimport type { TransformStyleConfig, TransformStyleInput, TransformStyleRegistry } from './types.js';\nimport { documentaryStyle } from './styles/documentary.js';\nimport { magazineStyle } from './styles/magazine.js';\nimport { dataDrivenStyle } from './styles/dataDriven.js';\nimport { narrativeStyle } from './styles/narrative.js';\nimport { minimalStyle } from './styles/minimal.js';\nimport { cloneAndFreezeData } from '../internal/immutable.js';\n\n/** All built-in transform styles, keyed by id. */\nconst TRANSFORM_STYLES: Readonly<Record<string, TransformStyleConfig>> = Object.freeze({\n [documentaryStyle.id]: cloneAndFreezeData(documentaryStyle),\n [magazineStyle.id]: cloneAndFreezeData(magazineStyle),\n [dataDrivenStyle.id]: cloneAndFreezeData(dataDrivenStyle),\n [narrativeStyle.id]: cloneAndFreezeData(narrativeStyle),\n [minimalStyle.id]: cloneAndFreezeData(minimalStyle),\n});\n\n/** Default style used when no id is provided. */\nexport const DEFAULT_TRANSFORM_STYLE_ID = 'documentary';\n\nconst EXTRACTION_TYPES = new Set([\n 'stat',\n 'date',\n 'quote',\n 'comparison',\n 'fact',\n 'impactLine',\n 'list',\n 'definition',\n]);\nconst TRANSITION_STYLES = new Set(['cut', 'fade', 'dissolve', 'mixed']);\n\nfunction validateTransformStyle(style: TransformStyleConfig): void {\n const candidate = style as unknown as Record<string, unknown>;\n const fail = (message: string): never => {\n throw new TypeError(`Invalid transform style: ${message}`);\n };\n for (const key of ['id', 'name', 'description']) {\n if (typeof candidate[key] !== 'string' || !(candidate[key] as string).trim()) {\n fail(`${key} must be a non-empty string`);\n }\n }\n for (const key of ['minConfidence', 'transformRatio']) {\n const value = candidate[key];\n if (typeof value !== 'number' || !Number.isFinite(value) || value < 0 || value > 1) {\n fail(`${key} must be a finite number between 0 and 1`);\n }\n }\n if (\n !Array.isArray(candidate.preferredTypes) ||\n candidate.preferredTypes.some((type) => !EXTRACTION_TYPES.has(type))\n ) {\n fail('preferredTypes contains an unknown extraction type');\n }\n if (\n !Array.isArray(candidate.colorSchemes) ||\n candidate.colorSchemes.length === 0 ||\n candidate.colorSchemes.some((scheme) => typeof scheme !== 'string' || !scheme)\n ) {\n fail('colorSchemes must contain at least one non-empty string');\n }\n for (const key of ['insertSectionHeaders', 'interleaveImages']) {\n if (typeof candidate[key] !== 'boolean') fail(`${key} must be a boolean`);\n }\n const blocks = candidate.blocksPerSection as { max?: unknown } | undefined;\n if (!blocks || !Number.isInteger(blocks.max) || (blocks.max as number) < 1) {\n fail('blocksPerSection.max must be a positive integer');\n }\n if (\n typeof candidate.transitionStyle !== 'string' ||\n !TRANSITION_STYLES.has(candidate.transitionStyle)\n ) {\n fail('transitionStyle must be cut, fade, dissolve, or mixed');\n }\n const templateMap = candidate.templateMap;\n if (templateMap !== undefined) {\n if (!templateMap || typeof templateMap !== 'object' || Array.isArray(templateMap)) {\n fail('templateMap must be an object');\n }\n for (const [type, template] of Object.entries(templateMap as Record<string, unknown>)) {\n if (!EXTRACTION_TYPES.has(type) || typeof template !== 'string' || !template) {\n fail('templateMap must map known extraction types to non-empty template names');\n }\n }\n }\n if (\n candidate.suggestedThemeId !== undefined &&\n (typeof candidate.suggestedThemeId !== 'string' || !candidate.suggestedThemeId)\n ) {\n fail('suggestedThemeId must be a non-empty string');\n }\n const pacingValue = candidate.pacing;\n if (pacingValue !== undefined) {\n if (!pacingValue || typeof pacingValue !== 'object' || Array.isArray(pacingValue)) {\n fail('pacing must be an object');\n }\n const pacing = pacingValue as { intro?: unknown; outro?: unknown };\n for (const key of ['intro', 'outro'] as const) {\n if (pacing[key] !== undefined && typeof pacing[key] !== 'boolean') {\n fail(`pacing.${key} must be a boolean`);\n }\n }\n }\n const budget = candidate.budget as { slidesPerMinute?: unknown } | undefined;\n if (\n candidate.budget !== undefined &&\n (!budget || typeof budget !== 'object' || Array.isArray(budget))\n ) {\n fail('budget must be an object');\n }\n if (budget && budget.slidesPerMinute !== undefined) {\n const value = budget.slidesPerMinute;\n if (typeof value !== 'number' || !Number.isFinite(value) || value <= 0) {\n fail('budget.slidesPerMinute must be a positive finite number');\n }\n }\n const pageValue = candidate.page;\n if (pageValue !== undefined) {\n if (!pageValue || typeof pageValue !== 'object' || Array.isArray(pageValue)) {\n fail('page must be an object');\n }\n const page = pageValue as { spacing?: unknown; emphasisCurve?: unknown };\n if (\n page.spacing !== undefined &&\n !['compact', 'comfortable', 'generous'].includes(page.spacing as string)\n ) {\n fail('page.spacing must be compact, comfortable, or generous');\n }\n if (\n page.emphasisCurve !== undefined &&\n !['even', 'front-loaded'].includes(page.emphasisCurve as string)\n ) {\n fail('page.emphasisCurve must be even or front-loaded');\n }\n }\n}\n\nfunction styleSnapshot(style: TransformStyleConfig): TransformStyleConfig {\n validateTransformStyle(style);\n return cloneAndFreezeData(style);\n}\n\n/** Stored documents emitted before the canonical kebab-case id. Not exported. */\nfunction normalizeBuiltinStyleId(id: string): string {\n return id === 'dataDriven' ? 'data-driven' : id;\n}\n\nfunction resolveBuiltinStyle(id: string): TransformStyleConfig {\n return (\n TRANSFORM_STYLES[normalizeBuiltinStyleId(id)] ?? TRANSFORM_STYLES[DEFAULT_TRANSFORM_STYLE_ID]\n );\n}\n\n/**\n * Create a caller-owned registry. Custom styles are validated, cloned, and\n * deeply frozen at registration time. Built-in resolution remains in the\n * top-level helpers, separate from the registry's caller-owned state.\n */\nexport function createTransformStyleRegistry(\n initialStyles: readonly TransformStyleConfig[] = [],\n): TransformStyleRegistry {\n const registeredStyles = new Map<string, TransformStyleConfig>();\n const registry: TransformStyleRegistry = {\n register(style): void {\n const snapshot = styleSnapshot(style);\n registeredStyles.set(snapshot.id, snapshot);\n },\n unregister(id): boolean {\n return registeredStyles.delete(id);\n },\n get(id): TransformStyleConfig | undefined {\n return registeredStyles.get(id);\n },\n list(): TransformStyleConfig[] {\n return Array.from(registeredStyles.values());\n },\n };\n for (const style of initialStyles) registry.register(style);\n return Object.freeze(registry);\n}\n\n/**\n * Resolve a built-in id, explicit-registry id, or call-scoped style config.\n * Unknown ids fall back to the default style.\n */\nexport function resolveTransformStyle(\n style: TransformStyleInput,\n registry?: TransformStyleRegistry,\n): TransformStyleConfig {\n if (typeof style !== 'string') return styleSnapshot(style);\n return registry?.get(style) ?? resolveBuiltinStyle(style);\n}\n\n/** Get built-in ids plus ids from an optional caller-owned registry. */\nexport function getTransformStyleIds(registry?: TransformStyleRegistry): string[] {\n return Array.from(\n new Set([\n ...Object.keys(TRANSFORM_STYLES),\n ...(registry?.list().map((style) => style.id) ?? []),\n ]),\n );\n}\n\n/** Get summaries for built-ins plus an optional caller-owned registry. */\nexport function getTransformStyleSummaries(registry?: TransformStyleRegistry) {\n return getTransformStyleIds(registry).map((id) => {\n const { name, description } = resolveTransformStyle(id, registry);\n return { id, name, description };\n });\n}\n","/**\n * Block Analyzer\n *\n * Walks Doc blocks, extracts plain text from their markdown contents,\n * and runs the content extractor on each block to identify stats, dates,\n * quotes, etc. that can be promoted to visual template blocks.\n */\n\nimport type { Block } from '../schemas/Doc.js';\nimport type { MarkdownBlockNode, MarkdownNode } from '../markdown/types.js';\nimport type { ExtractedElement, ExtractionOptions } from '../generate/contentExtractor.js';\nimport type { TransformImage } from './types.js';\nimport { extractContent, stripMarkdown } from '../generate/contentExtractor.js';\nimport { extractPlainText, getChildren } from '../markdown/utils.js';\n\n/** An image found in a block's markdown contents. */\nexport interface BlockImage {\n /** Image URL (relative or absolute). */\n src: string;\n /** Alt text. */\n alt: string;\n /** Index of the source block in the analyzed array. */\n sourceBlockIndex: number;\n}\n\n/** A block enriched with extraction analysis. */\nexport interface AnalyzedBlock {\n /** The original block. */\n block: Block;\n /** Plain text extracted from the block's contents. */\n plainText: string;\n /** Content extractions found in the block's text. */\n extractions: ExtractedElement[];\n /** Whether this block has child blocks. */\n hasChildren: boolean;\n /** Word count of the block's body text. */\n bodyWordCount: number;\n /** Images found in this block's markdown contents. */\n images: BlockImage[];\n}\n\n/**\n * Extract plain text from an array of MarkdownBlockNodes.\n */\nfunction contentsToPlainText(contents: MarkdownBlockNode[]): string {\n return contents.map((node) => extractPlainText(node)).join('\\n');\n}\n\n/**\n * Recursively walk a markdown node tree and collect all images.\n */\nfunction collectImages(node: MarkdownNode): Array<{ src: string; alt: string }> {\n const results: Array<{ src: string; alt: string }> = [];\n\n if ('type' in node && node.type === 'image' && 'url' in node) {\n const img = node as { url: string; alt?: string };\n if (img.url) {\n results.push({ src: img.url, alt: img.alt ?? '' });\n }\n }\n\n for (const child of getChildren(node)) {\n results.push(...collectImages(child));\n }\n\n return results;\n}\n\n/**\n * Extract images from a block's markdown contents.\n */\nfunction extractBlockImages(block: Block, blockIndex: number): BlockImage[] {\n if (!block.contents || block.contents.length === 0) return [];\n\n const images: BlockImage[] = [];\n for (const node of block.contents) {\n for (const img of collectImages(node)) {\n images.push({ ...img, sourceBlockIndex: blockIndex });\n }\n }\n return images;\n}\n\n/**\n * Collect all unique images from all blocks in a Doc.\n * Returns them as TransformImages for use in the transform pipeline.\n */\nexport function extractDocImages(blocks: Block[]): TransformImage[] {\n const seen = new Set<string>();\n const images: TransformImage[] = [];\n\n function walk(blockList: Block[]): void {\n for (const block of blockList) {\n if (block.contents) {\n for (const node of block.contents) {\n for (const img of collectImages(node)) {\n if (!seen.has(img.src)) {\n seen.add(img.src);\n images.push({ src: img.src, alt: img.alt });\n }\n }\n }\n }\n if (block.children) {\n walk(block.children);\n }\n }\n }\n\n walk(blocks);\n return images;\n}\n\n/**\n * Collect leaf blocks from a nested block tree.\n * Only returns blocks that have their own `contents` but no children,\n * preventing parent blocks from duplicating text that also appears\n * in their children. Parent-only blocks (with a title but no body\n * content) are included as structural placeholders.\n */\nfunction collectLeafBlocks(blocks: Block[]): Block[] {\n const result: Block[] = [];\n for (const block of blocks) {\n if (block.children && block.children.length > 0) {\n // Parent block — only include it as a structural marker\n // (title only, no body extraction) if it has no contents of its own.\n // Then recurse into children for the actual content.\n if (!block.contents || block.contents.length === 0) {\n result.push(block);\n }\n result.push(...collectLeafBlocks(block.children));\n } else {\n // Leaf block — include for content analysis\n result.push(block);\n }\n }\n return result;\n}\n\n/**\n * Analyze all blocks in a Doc, extracting text and running content extraction.\n *\n * @param blocks - The Doc's block array (may be nested via children).\n * @param options - Extraction options (minConfidence, types filter).\n * @returns Analyzed blocks with extractions, in flattened order.\n */\nexport function analyzeBlocks(blocks: Block[], options?: ExtractionOptions): AnalyzedBlock[] {\n const flat = collectLeafBlocks(blocks);\n const results: AnalyzedBlock[] = [];\n\n for (const block of flat) {\n let plainText = '';\n\n if (block.contents && block.contents.length > 0) {\n plainText = contentsToPlainText(block.contents);\n } else if (block.title) {\n plainText = block.title;\n }\n\n // Strip any remaining markdown syntax\n const stripped = stripMarkdown(plainText);\n const bodyWordCount = stripped.split(/\\s+/).filter((w) => w.length > 0).length;\n\n // Run content extraction\n const extraction = extractContent(stripped, options);\n\n // Extract images from markdown contents\n const images = extractBlockImages(block, results.length);\n\n results.push({\n block,\n plainText: stripped,\n extractions: extraction.elements,\n hasChildren: !!(block.children && block.children.length > 0),\n bodyWordCount,\n images,\n });\n }\n\n return results;\n}\n","/**\n * Template Selector\n *\n * Selects which extracted elements to promote to visual template blocks\n * and handles color scheme rotation, image interleaving, and template\n * variety. Ported and generalized from qualla-internal's TemplateSelector.\n */\n\nimport type { Block, TransitionType } from '../schemas/Doc.js';\nimport type {\n TemplateBlock,\n AccentImage,\n AccentPosition,\n ImageWithCaptionInput,\n SectionHeaderInput,\n QuoteBlockInput,\n FullBleedQuoteInput,\n StatHighlightInput,\n} from '../schemas/BlockTemplates.js';\nimport type { ExtractedElement } from '../generate/contentExtractor.js';\nimport type { TransformStyleConfig, TransformImage } from './types.js';\nimport type { AnalyzedBlock } from './blockAnalyzer.js';\nimport { mapElementToBlock } from '../generate/templateMapper.js';\nimport { SeededRandom } from '../random/SeededRandom.js';\nimport { estimateTimeFromText } from '../timing/narrationTiming.js';\n\n/** Accent positions to rotate through. */\nconst ACCENT_POSITIONS: AccentPosition[] = [\n 'left-strip',\n 'right-strip',\n 'bottom-strip',\n 'corner-inset',\n];\n\n/** Ambient motions to rotate on image blocks. */\nconst AMBIENT_MOTIONS: Array<'zoomIn' | 'zoomOut' | 'panLeft' | 'panRight'> = [\n 'zoomIn',\n 'zoomOut',\n 'panLeft',\n 'panRight',\n];\n\n/** A selected element paired with its source block. */\ninterface SelectedExtraction {\n element: ExtractedElement;\n sourceBlock: Block;\n /** Index in the original analyzed blocks array. */\n sourceIndex: number;\n}\n\n/** Result of template selection. */\nexport interface SelectionResult {\n /** Replacement blocks: a mix of original blocks and new template blocks. */\n blocks: Array<Block | TemplateBlock>;\n /** How many blocks were transformed. */\n transformedCount: number;\n /** How many blocks were inserted (images, section headers). */\n insertedCount: number;\n}\n\n/**\n * Select extractions and build a transformed block sequence.\n *\n * @param analyzed - Analyzed blocks from blockAnalyzer.\n * @param config - The transform style configuration.\n * @param images - Available images for interleaving.\n * @param seed - Random seed for deterministic output.\n */\nexport function selectAndBuild(\n analyzed: AnalyzedBlock[],\n config: TransformStyleConfig,\n images: TransformImage[],\n seed: number,\n): SelectionResult {\n const rng = new SeededRandom(seed);\n\n // 1. Collect all extractions across all blocks, filtered by config\n const candidates = collectCandidates(analyzed, config);\n\n // 2. Determine how many blocks to transform. `transformRatio` scales\n // with block count; an optional duration-based budget (slides per\n // minute) caps runaway promotion on long dense documents.\n const ratioCap = Math.max(1, Math.floor(analyzed.length * config.transformRatio));\n const slidesPerMinute = config.budget?.slidesPerMinute;\n const totalDurationSeconds = analyzed.reduce((sum, ab) => sum + (ab.block.duration || 0), 0);\n const budgetCap =\n slidesPerMinute && totalDurationSeconds > 0\n ? Math.max(1, Math.round((totalDurationSeconds / 60) * slidesPerMinute))\n : Infinity;\n const maxTransforms = Math.min(ratioCap, budgetCap);\n const selected = candidates.slice(0, maxTransforms);\n\n // 3. Build the output block sequence\n const result = buildBlockSequence(analyzed, selected, config, images, rng);\n\n return result;\n}\n\n/**\n * Collect candidate extractions from all analyzed blocks, sorted by\n * a combined score of confidence and type preference.\n */\nfunction collectCandidates(\n analyzed: AnalyzedBlock[],\n config: TransformStyleConfig,\n): SelectedExtraction[] {\n const candidates: SelectedExtraction[] = [];\n\n for (let i = 0; i < analyzed.length; i++) {\n const ab = analyzed[i];\n // Skip blocks with no meaningful text\n if (ab.bodyWordCount < 5) continue;\n\n for (const element of ab.extractions) {\n if (element.confidence < config.minConfidence) continue;\n\n candidates.push({\n element,\n sourceBlock: ab.block,\n sourceIndex: i,\n });\n }\n }\n\n // Sort by: preferred type rank (lower = better), then confidence (higher = better)\n const typeRank = new Map(config.preferredTypes.map((t, i) => [t, i]));\n const maxRank = config.preferredTypes.length;\n\n candidates.sort((a, b) => {\n const rankA = typeRank.get(a.element.type) ?? maxRank;\n const rankB = typeRank.get(b.element.type) ?? maxRank;\n if (rankA !== rankB) return rankA - rankB;\n return b.element.confidence - a.element.confidence;\n });\n\n // Deduplicate: if the same extracted text appears multiple times\n // (e.g., from overlapping parent/child blocks), keep only the\n // highest-ranked occurrence.\n const seenTexts = new Set<string>();\n const deduplicated: SelectedExtraction[] = [];\n for (const candidate of candidates) {\n const key = candidate.element.text.trim().toLowerCase();\n if (seenTexts.has(key)) continue;\n seenTexts.add(key);\n deduplicated.push(candidate);\n }\n\n return deduplicated;\n}\n\n/**\n * Build the output block sequence, replacing source blocks with template\n * blocks where extractions were selected, and interleaving images.\n */\nfunction buildBlockSequence(\n analyzed: AnalyzedBlock[],\n selected: SelectedExtraction[],\n config: TransformStyleConfig,\n images: TransformImage[],\n rng: SeededRandom,\n): SelectionResult {\n // Map: sourceIndex → list of selected extractions for that block\n const blockExtractions = new Map<number, SelectedExtraction[]>();\n for (const sel of selected) {\n const list = blockExtractions.get(sel.sourceIndex) ?? [];\n list.push(sel);\n blockExtractions.set(sel.sourceIndex, list);\n }\n\n // Limit extractions per block: cap at blocksPerSection.max and ensure\n // template type variety within each block (no two same-type extractions).\n for (const [idx, list] of blockExtractions) {\n const diverse: SelectedExtraction[] = [];\n const usedTypes = new Set<string>();\n for (const sel of list) {\n if (usedTypes.has(sel.element.type)) continue;\n usedTypes.add(sel.element.type);\n diverse.push(sel);\n if (diverse.length >= config.blocksPerSection.max) break;\n }\n blockExtractions.set(idx, diverse);\n }\n\n const blocks: Array<Block | TemplateBlock> = [];\n let transformedCount = 0;\n let insertedCount = 0;\n let colorIndex = 0;\n let blockIdCounter = 0;\n let imageIndex = 0;\n let accentPositionIndex = 0;\n let elementsSinceImage = 0;\n let prevTemplateType = '';\n\n // Calculate image interleaving interval\n const totalTransformed = Array.from(blockExtractions.values()).reduce(\n (sum, list) => sum + list.length,\n 0,\n );\n const imageInterval =\n config.interleaveImages && images.length > 0 && totalTransformed > 0\n ? Math.max(2, Math.floor(totalTransformed / (images.length + 1)))\n : Infinity;\n\n for (let i = 0; i < analyzed.length; i++) {\n const ab = analyzed[i];\n const extractions = blockExtractions.get(i);\n\n if (!extractions || extractions.length === 0) {\n // Keep the original block unchanged\n blocks.push(ab.block);\n continue;\n }\n\n // Insert section header before a group of transformed blocks (if enabled)\n if (config.insertSectionHeaders && ab.block.title) {\n const headerBlock: SectionHeaderInput = {\n template: 'sectionHeader',\n id: `transform-header-${blockIdCounter++}`,\n duration: ab.block.duration > 0 ? Math.min(3, ab.block.duration * 0.2) : 3,\n audioSegment: ab.block.audioSegment,\n title: ab.block.title,\n colorScheme: config.colorSchemes[colorIndex % config.colorSchemes.length],\n sourceBlockId: ab.block.id,\n };\n blocks.push(headerBlock);\n insertedCount++;\n }\n\n // Convert each selected extraction to a template block.\n // Track the last template used globally (not just within this block)\n // to avoid consecutive same-template slides across the entire output.\n for (const sel of extractions) {\n const colorScheme = config.colorSchemes[colorIndex % config.colorSchemes.length];\n\n // Build accent image if we have images in the pool\n let accentImage: AccentImage | undefined;\n if (images.length > 0 && config.interleaveImages) {\n const img = images[imageIndex % images.length];\n accentImage = {\n src: img.src,\n alt: img.alt ?? '',\n position: ACCENT_POSITIONS[accentPositionIndex % ACCENT_POSITIONS.length],\n ambientMotion: rng.pick(AMBIENT_MOTIONS) ?? 'zoomIn',\n credit: img.credit,\n license: img.license,\n };\n accentPositionIndex++;\n }\n\n // `sourcePosition` is a CHAR OFFSET into the analyzed plain text;\n // `sourceStartTime` is doc-timeline SECONDS. Convert via spoken-word\n // proportion over the source block's timing — which, when the doc\n // carries a narration take (applyNarrationTiming ran upstream), is\n // the recorded voice: summarized slides land where the words are\n // actually spoken.\n const slideShare = ab.block.duration > 0 ? ab.block.duration / extractions.length : 6;\n const offsetInBlock =\n ab.block.duration > 0\n ? estimateTimeFromText(ab.plainText, sel.element.sourcePosition, ab.block.duration)\n : 0;\n let templateBlock = mapElementToBlock(sel.element, {\n id: `transform-${blockIdCounter++}`,\n duration: slideShare,\n audioSegment: ab.block.audioSegment,\n colorScheme,\n accentImage,\n sourceStartTime: ab.block.startTime + offsetInBlock,\n sourceDuration: slideShare,\n sourceBlockId: ab.block.id,\n sourceCharOffset: sel.element.sourcePosition,\n });\n\n // Style-level extraction→template remap (v2 contract). Only known\n // text-compatible pairings translate; image-backed targets consume\n // the accent image as their background. Unknown pairings keep the\n // default mapping.\n const remapTarget = config.templateMap?.[sel.element.data.type];\n if (remapTarget && remapTarget !== templateBlock.template) {\n const translated = translateTemplateBlock(templateBlock, remapTarget);\n if (translated) templateBlock = translated;\n }\n\n // Apply transition based on style\n if (config.transitionStyle !== 'cut') {\n const transitionType: TransitionType =\n config.transitionStyle === 'mixed'\n ? (rng.pick<TransitionType>(['fade', 'dissolve']) ?? 'fade')\n : config.transitionStyle;\n templateBlock.transition = {\n type: transitionType,\n duration: 0.5,\n };\n }\n\n // Avoid consecutive same-template blocks by bumping color for variety\n if (templateBlock.template === prevTemplateType) {\n colorIndex++;\n }\n prevTemplateType = templateBlock.template;\n\n blocks.push(templateBlock);\n transformedCount++;\n colorIndex++;\n elementsSinceImage++;\n\n // Interleave standalone image at intervals\n if (\n config.interleaveImages &&\n imageIndex < images.length &&\n elementsSinceImage >= imageInterval\n ) {\n const img = images[imageIndex];\n const imageBlock: ImageWithCaptionInput = {\n template: 'imageWithCaption',\n id: `transform-img-${blockIdCounter++}`,\n duration: 4,\n audioSegment: ab.block.audioSegment,\n imageSrc: img.src,\n imageAlt: img.alt ?? '',\n ambientMotion: rng.pick(AMBIENT_MOTIONS) ?? 'zoomIn',\n sourceBlockId: ab.block.id,\n };\n blocks.push(imageBlock);\n imageIndex++;\n insertedCount++;\n elementsSinceImage = 0;\n }\n }\n }\n\n return { blocks, transformedCount, insertedCount };\n}\n\n/**\n * Translate a mapped template block into a style-requested target\n * template. Only text-compatible pairings are supported; returns null\n * (keep the default) for unknown pairs or when a required input —\n * a background image for `pullQuote` — is unavailable.\n */\nfunction translateTemplateBlock(block: TemplateBlock, target: string): TemplateBlock | null {\n const base = {\n id: block.id,\n duration: block.duration,\n audioSegment: block.audioSegment,\n sourceStartTime: block.sourceStartTime,\n sourceDuration: block.sourceDuration,\n sourceBlockId: block.sourceBlockId,\n sourceCharOffset: block.sourceCharOffset,\n };\n\n if (block.template === 'quote') {\n const quote = block as QuoteBlockInput;\n if (target === 'fullBleedQuote') {\n return { ...base, template: 'fullBleedQuote', text: quote.quote };\n }\n if (target === 'pullQuote') {\n // pullQuote requires a full-bleed background image — reuse the\n // accent image the selector already assigned to this block.\n const bg = quote.accentImage;\n if (!bg) return null;\n return {\n ...base,\n template: 'pullQuote',\n text: quote.quote,\n attribution: quote.attribution,\n backgroundImage: { src: bg.src, alt: bg.alt, credit: bg.credit, license: bg.license },\n };\n }\n return null;\n }\n\n if (block.template === 'fullBleedQuote' && target === 'quote') {\n const fbq = block as FullBleedQuoteInput;\n return { ...base, template: 'quote', quote: fbq.text };\n }\n\n if (block.template === 'statHighlight' && target === 'factCard') {\n const stat = block as StatHighlightInput;\n return {\n ...base,\n template: 'factCard',\n fact: stat.stat,\n explanation: stat.description,\n accentImage: stat.accentImage,\n };\n }\n\n return null;\n}\n","/**\n * Timing Allocator\n *\n * Distributes timing (startTime, duration) across transformed blocks.\n * When the source Doc has audio, blocks are fitted to the overall duration.\n * When no audio is present, uses reading-time estimation.\n */\n\nimport type { Block } from '../schemas/Doc.js';\nimport type { TemplateBlock } from '../schemas/BlockTemplates.js';\nimport { isTemplateBlock } from '../schemas/BlockTemplates.js';\n\n/** Minimum block duration in seconds. */\nconst MIN_BLOCK_DURATION = 3;\n/** Maximum block duration in seconds. */\nconst MAX_BLOCK_DURATION = 20;\n/** Default duration when no timing info is available. */\nconst DEFAULT_BLOCK_DURATION = 6;\n\n/**\n * Allocate startTime and duration across a mixed array of blocks and\n * template blocks. Template blocks get timing assigned; existing blocks\n * retain their original timing when possible.\n *\n * @param blocks - The output from templateSelector (mixed Block | TemplateBlock).\n * @param totalDuration - The Doc's total duration (from audio or estimation).\n * @returns A new array of Blocks with consistent timing. Template blocks\n * are returned as Blocks (with startTime/duration set, layers empty).\n */\nexport function allocateTiming(\n blocks: Array<Block | TemplateBlock>,\n totalDuration: number,\n): Block[] {\n if (blocks.length === 0) return [];\n\n // Template blocks carrying a numeric `sourceStartTime` are ANCHORED to\n // the doc timeline — when the source doc is narration-timed\n // (`applyNarrationTiming`), those anchors are where the words are\n // actually spoken, and rescaling would tear the slides away from the\n // voice. Anchored blocks keep their positions; floating blocks\n // (intro/outro bookends, section headers, interleaved images) fill the\n // gaps between anchors. With no anchors at all, behavior is the\n // historical rescale-to-fit.\n const hasAnchors = blocks.some(\n (b) => isTemplateBlock(b) && typeof b.sourceStartTime === 'number',\n );\n return hasAnchors\n ? allocateAnchored(blocks, totalDuration)\n : allocateRescaled(blocks, totalDuration);\n}\n\n/** Historical behavior: scale every duration to fill the total, clamp 3–20 s. */\nfunction allocateRescaled(blocks: Array<Block | TemplateBlock>, totalDuration: number): Block[] {\n const effectiveDuration = totalDuration > 0 ? totalDuration : estimateDefaultDuration(blocks);\n\n // First pass: assign raw durations\n const durations = blocks.map((block) => {\n if (!isTemplateBlock(block) && block.duration > 0) {\n // Existing block with known duration — keep it\n return block.duration;\n }\n if (isTemplateBlock(block) && block.duration > 0) {\n return block.duration;\n }\n return DEFAULT_BLOCK_DURATION;\n });\n\n // Scale durations to fit the total\n const rawTotal = durations.reduce((sum, d) => sum + d, 0);\n if (rawTotal > 0 && effectiveDuration > 0) {\n const scale = effectiveDuration / rawTotal;\n for (let i = 0; i < durations.length; i++) {\n durations[i] = clampDuration(durations[i] * scale);\n }\n }\n\n // Second pass: assign startTimes and build output Blocks\n let currentTime = 0;\n const result: Block[] = [];\n for (let i = 0; i < blocks.length; i++) {\n result.push(toOutputBlock(blocks[i], currentTime, durations[i]));\n currentTime += durations[i];\n }\n return result;\n}\n\n/** Minimum duration for a floating block squeezed between anchors. */\nconst MIN_FLOATING_DURATION = 1;\n\n/**\n * Anchor-aware allocation: anchored entries (template blocks with a\n * numeric `sourceStartTime`, and untransformed source Blocks with their\n * own real timing) are PLACED at their timeline positions; runs of\n * floating blocks (bookends, headers, images) distribute across the gap\n * before the next anchor. Durations then derive from consecutive starts\n * so the timeline stays CONTIGUOUS — a slide summarizing unpromoted\n * source content simply holds until the next slide begins, which is\n * what keeps every narration second covered by some block.\n */\nfunction allocateAnchored(blocks: Array<Block | TemplateBlock>, totalDuration: number): Block[] {\n interface Entry {\n block: Block | TemplateBlock;\n anchorStart: number | null;\n rawDuration: number;\n }\n const entries: Entry[] = blocks.map((block) => {\n if (isTemplateBlock(block)) {\n return {\n block,\n anchorStart: typeof block.sourceStartTime === 'number' ? block.sourceStartTime : null,\n rawDuration: block.duration > 0 ? block.duration : DEFAULT_BLOCK_DURATION,\n };\n }\n // Untransformed source blocks carry real (possibly narration) timing.\n return {\n block,\n anchorStart: block.startTime,\n rawDuration: block.duration > 0 ? block.duration : DEFAULT_BLOCK_DURATION,\n };\n });\n\n // Pass 1: starts. Anchors pin their positions (the cursor then jumps\n // past the anchor's authored span, so following floats land AFTER it).\n // Float runs place differently by position: LEADING floats (before any\n // anchor — intro bookends) fill the opening gap from t=0; MID floats\n // (section headers, images) end-align just before the next anchor —\n // a header belongs to the section it introduces; TRAILING floats\n // (outro) run sequentially after the last anchor's span.\n const starts = new Array<number>(entries.length);\n let cursor = 0;\n let seenAnchor = false;\n let i = 0;\n while (i < entries.length) {\n const entry = entries[i];\n if (entry.anchorStart !== null) {\n const start = Math.max(cursor, entry.anchorStart);\n starts[i] = start;\n const hint = isTemplateBlock(entry.block)\n ? (entry.block.sourceDuration ?? entry.rawDuration)\n : entry.rawDuration;\n cursor = start + Math.max(MIN_FLOATING_DURATION, hint);\n seenAnchor = true;\n i++;\n continue;\n }\n const runStart = i;\n while (i < entries.length && entries[i].anchorStart === null) i++;\n const run = entries.slice(runStart, i);\n const rawSum = run.reduce((sum, e) => sum + e.rawDuration, 0);\n const nextAnchorStart =\n i < entries.length ? Math.max(entries[i].anchorStart ?? cursor, cursor) : null;\n\n if (nextAnchorStart === null) {\n // Trailing floats: natural sizes after the last anchor's span.\n let acc = cursor;\n for (let k = 0; k < run.length; k++) {\n starts[runStart + k] = acc;\n acc += run[k].rawDuration;\n }\n cursor = acc;\n } else if (!seenAnchor) {\n // Leading floats: fill [cursor, nextAnchorStart) proportionally.\n const gap = nextAnchorStart - cursor;\n let acc = cursor;\n for (let k = 0; k < run.length; k++) {\n starts[runStart + k] = acc;\n acc += rawSum > 0 ? (run[k].rawDuration / rawSum) * gap : gap / run.length;\n }\n cursor = nextAnchorStart;\n } else {\n // Mid floats: end-aligned at natural size, capped by the gap.\n const gap = Math.max(0, nextAnchorStart - cursor);\n const scale = rawSum > 0 ? Math.min(1, gap / rawSum) : 0;\n let acc = Math.max(cursor, nextAnchorStart - rawSum * scale);\n for (let k = 0; k < run.length; k++) {\n starts[runStart + k] = acc;\n acc += run[k].rawDuration * scale;\n }\n cursor = nextAnchorStart;\n }\n }\n\n // Pass 2: strictly increasing starts, then contiguous durations.\n for (let k = 0; k < starts.length; k++) {\n const floor = k > 0 ? starts[k - 1] + MIN_FLOATING_DURATION : 0;\n if (starts[k] < floor) starts[k] = floor;\n }\n const result: Block[] = [];\n for (let k = 0; k < entries.length; k++) {\n const entry = entries[k];\n let duration: number;\n if (k + 1 < entries.length) {\n duration = Math.max(MIN_FLOATING_DURATION, starts[k + 1] - starts[k]);\n } else {\n const authored = isTemplateBlock(entry.block)\n ? (entry.block.sourceDuration ?? entry.rawDuration)\n : entry.rawDuration;\n // The final block covers through the end of the doc/narration when\n // the caller knows it runs longer.\n duration = Math.max(MIN_FLOATING_DURATION, authored, totalDuration - starts[k]);\n }\n result.push(toOutputBlock(entry.block, starts[k], duration));\n }\n return result;\n}\n\n/**\n * Convert an entry to an output Block shell. Template blocks preserve all\n * template-specific fields (stat, quote, description, …) so they survive\n * through to the player's template expansion step.\n */\nfunction toOutputBlock(block: Block | TemplateBlock, startTime: number, duration: number): Block {\n if (isTemplateBlock(block)) {\n return {\n ...block,\n startTime,\n duration,\n title: getTemplateTitle(block),\n } as unknown as Block;\n }\n return { ...block, startTime, duration };\n}\n\n/** Clamp a duration to the min/max range. */\nfunction clampDuration(d: number): number {\n return Math.max(MIN_BLOCK_DURATION, Math.min(MAX_BLOCK_DURATION, d));\n}\n\n/** Estimate a total duration from block contents when no audio is available. */\nfunction estimateDefaultDuration(blocks: Array<Block | TemplateBlock>): number {\n let totalSeconds = 0;\n for (const block of blocks) {\n if (!isTemplateBlock(block) && block.duration > 0) {\n totalSeconds += block.duration;\n } else {\n totalSeconds += DEFAULT_BLOCK_DURATION;\n }\n }\n return Math.max(totalSeconds, blocks.length * MIN_BLOCK_DURATION);\n}\n\n/** Extract a display title from a template block if available. */\nfunction getTemplateTitle(block: TemplateBlock): string | undefined {\n if ('title' in block && typeof block.title === 'string') {\n return block.title;\n }\n if ('stat' in block && typeof block.stat === 'string') {\n return block.stat;\n }\n if ('fact' in block && typeof block.fact === 'string') {\n return block.fact;\n }\n if ('quote' in block && typeof block.quote === 'string') {\n return block.quote.slice(0, 60);\n }\n return undefined;\n}\n","/**\n * Apply Transform\n *\n * Main entry point for the transform module. Takes a Doc and a style,\n * analyzes block content, selects extractions to promote, and returns\n * a new Doc with blocks optimized for visual presentation.\n *\n * The input Doc is never mutated — a fresh Doc is always returned.\n */\n\nimport type { Doc } from '../schemas/Doc.js';\nimport type { DocBlock, TitleBlockInput, SectionHeaderInput } from '../schemas/BlockTemplates.js';\nimport type { TransformStyleInput, TransformOptions, TransformResult } from './types.js';\nimport { resolveTransformStyle } from './registry.js';\nimport { analyzeBlocks, extractDocImages } from './blockAnalyzer.js';\nimport { selectAndBuild } from './templateSelector.js';\nimport { allocateTiming } from './timingAllocator.js';\nimport { hashString } from '../random/SeededRandom.js';\n\n/**\n * Apply a transform style to a Doc, producing a new Doc with blocks\n * optimized for visual presentation.\n *\n * @param doc - The source Doc (not mutated).\n * @param style - Built-in/registry id or a call-scoped declarative style.\n * @param options - Optional seed, images, theme override, and explicit registry.\n * @returns TransformResult with the new Doc and stats.\n */\nexport function applyTransform(\n doc: Doc,\n style: TransformStyleInput,\n options?: TransformOptions,\n): TransformResult {\n const baseConfig = resolveTransformStyle(style, options?.registry);\n const config = options?.overrides\n ? { ...baseConfig, ...options.overrides, id: baseConfig.id }\n : baseConfig;\n\n const seed = options?.seed ?? hashString(doc.articleId || 'transform');\n\n // Use provided images or auto-extract from the doc's markdown content\n const images = options?.images ?? extractDocImages(doc.blocks);\n\n // 1. Analyze blocks\n const analyzed = analyzeBlocks(doc.blocks, {\n minConfidence: config.minConfidence,\n types: config.preferredTypes,\n });\n\n // If no blocks have meaningful content, return the doc unchanged\n const hasContent = analyzed.some((ab) => ab.bodyWordCount >= 5);\n if (!hasContent) {\n return {\n doc: { ...doc },\n stats: {\n totalInputBlocks: doc.blocks.length,\n transformedBlocks: 0,\n insertedBlocks: 0,\n },\n };\n }\n\n // 2. Select extractions and build template blocks\n const selection = selectAndBuild(analyzed, config, images, seed);\n\n // 2b. Pacing bookends: an opening title beat and/or a closing beat.\n let paced: DocBlock[] = selection.blocks;\n let pacingInserted = 0;\n const docTitle = firstTitle(doc);\n if (config.pacing?.intro && docTitle && !doc.startBlock) {\n const intro: TitleBlockInput = {\n template: 'title',\n id: 'transform-intro',\n duration: 4,\n audioSegment: 0,\n title: docTitle,\n };\n paced = [intro, ...paced];\n pacingInserted++;\n }\n if (config.pacing?.outro && docTitle) {\n const outro: SectionHeaderInput = {\n template: 'sectionHeader',\n id: 'transform-outro',\n duration: 3,\n audioSegment: 0,\n title: docTitle,\n colorScheme: config.colorSchemes[0],\n };\n paced = [...paced, outro];\n pacingInserted++;\n }\n\n // 3. Allocate timing across the new block sequence\n const timedBlocks = allocateTiming(paced, doc.duration);\n\n // 4. Assemble the output Doc. A style's suggested theme applies only\n // when neither the caller nor the doc declares one.\n const transformedDoc: Doc = {\n ...doc,\n blocks: timedBlocks,\n themeId: options?.themeId ?? doc.themeId ?? config.suggestedThemeId,\n };\n\n return {\n doc: transformedDoc,\n stats: {\n totalInputBlocks: doc.blocks.length,\n transformedBlocks: selection.transformedCount,\n insertedBlocks: selection.insertedCount + pacingInserted,\n },\n };\n}\n\n/** First non-empty block title (the doc's working title). */\nfunction firstTitle(doc: Doc): string | undefined {\n if (doc.startBlock?.title) return doc.startBlock.title;\n for (const block of doc.blocks) {\n if (block.title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