@office-open/core 0.6.3 → 0.6.5

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.
@@ -0,0 +1,4155 @@
1
+ import { a as BuilderElement, b as XmlComponent } from "./xml-components-CADgke8j.mjs";
2
+ import hash from "hash.js";
3
+ import { customAlphabet, nanoid } from "nanoid/non-secure";
4
+ //#region src/converters.ts
5
+ /**
6
+ * OOXML unit conversion utilities.
7
+ *
8
+ * @module
9
+ */
10
+ /**
11
+ * Converts millimeters to TWIP (twentieths of a point).
12
+ */
13
+ const convertMillimetersToTwip = (millimeters) => Math.floor(millimeters / 25.4 * 72 * 20);
14
+ /**
15
+ * Converts inches to TWIP (twentieths of a point).
16
+ */
17
+ const convertInchesToTwip = (inches) => Math.floor(inches * 72 * 20);
18
+ /**
19
+ * Converts pixels to EMU (96 DPI).
20
+ */
21
+ const convertPixelsToEmu = (pixels) => Math.round(pixels * 9525);
22
+ /**
23
+ * Converts EMU to pixels (96 DPI).
24
+ */
25
+ const convertEmuToPixels = (emus) => Math.round(emus / 9525);
26
+ /**
27
+ * Converts inches to EMU.
28
+ */
29
+ const convertInchesToEmu = (inches) => Math.round(inches * 914400);
30
+ /**
31
+ * Converts EMU to inches.
32
+ */
33
+ const convertEmuToInches = (emus) => emus / 914400;
34
+ /**
35
+ * Converts points to EMU.
36
+ */
37
+ const convertPointsToEmu = (points) => Math.round(points * 12700);
38
+ /**
39
+ * Converts EMU to points.
40
+ */
41
+ const convertEmuToPoints = (emus) => emus / 12700;
42
+ //#endregion
43
+ //#region src/id-generators.ts
44
+ /**
45
+ * Unique ID generation utilities.
46
+ *
47
+ * @module
48
+ */
49
+ /**
50
+ * Creates a unique numeric ID generator with sequential numbering.
51
+ */
52
+ const uniqueNumericIdCreator = (initial = 0) => {
53
+ let currentCount = initial;
54
+ return () => ++currentCount;
55
+ };
56
+ /**
57
+ * Generates a unique lowercase alphanumeric ID using nanoid.
58
+ */
59
+ const uniqueId = () => nanoid().toLowerCase();
60
+ /**
61
+ * Generates a SHA-1 hash of the provided data.
62
+ */
63
+ const hashedId = (data) => hash.sha1().update(data instanceof ArrayBuffer ? new Uint8Array(data) : data).digest("hex");
64
+ /**
65
+ * Generates a random hexadecimal string of specified length.
66
+ */
67
+ const generateUuidPart = (count) => customAlphabet("1234567890abcdef", count)();
68
+ /**
69
+ * Generates a UUID v4-style unique identifier.
70
+ */
71
+ const uniqueUuid = () => `${generateUuidPart(8)}-${generateUuidPart(4)}-${generateUuidPart(4)}-${generateUuidPart(4)}-${generateUuidPart(12)}`;
72
+ //#endregion
73
+ //#region src/drawingml/color/color-transform.ts
74
+ /**
75
+ * Color transform elements for DrawingML colors.
76
+ *
77
+ * This module provides color transformation elements defined in EG_ColorTransform,
78
+ * which can be applied as child elements to any color type (srgbClr, schemeClr, etc.).
79
+ *
80
+ * Reference: ISO/IEC 29500-4, dml-main.xsd, EG_ColorTransform
81
+ *
82
+ * @module
83
+ */
84
+ /**
85
+ * Creates color transform child elements.
86
+ *
87
+ * These elements modify the parent color according to OOXML color transform rules.
88
+ * Multiple transforms can be applied in sequence.
89
+ *
90
+ * @example
91
+ * ```typescript
92
+ * // Lighten accent1 by 40%
93
+ * createColorTransforms({ tint: 40000 });
94
+ * // Semi-transparent red with 50% alpha
95
+ * createColorTransforms({ alpha: 50000 });
96
+ * ```
97
+ */
98
+ const createColorTransforms = (options) => {
99
+ const transforms = [];
100
+ if (options.tint !== void 0) transforms.push(new BuilderElement({
101
+ attributes: { val: {
102
+ key: "val",
103
+ value: options.tint
104
+ } },
105
+ name: "a:tint"
106
+ }));
107
+ if (options.shade !== void 0) transforms.push(new BuilderElement({
108
+ attributes: { val: {
109
+ key: "val",
110
+ value: options.shade
111
+ } },
112
+ name: "a:shade"
113
+ }));
114
+ if (options.comp) transforms.push(new BuilderElement({ name: "a:comp" }));
115
+ if (options.inv) transforms.push(new BuilderElement({ name: "a:inv" }));
116
+ if (options.gray) transforms.push(new BuilderElement({ name: "a:gray" }));
117
+ if (options.alpha !== void 0) transforms.push(new BuilderElement({
118
+ attributes: { val: {
119
+ key: "val",
120
+ value: options.alpha
121
+ } },
122
+ name: "a:alpha"
123
+ }));
124
+ if (options.alphaOff !== void 0) transforms.push(new BuilderElement({
125
+ attributes: { val: {
126
+ key: "val",
127
+ value: options.alphaOff
128
+ } },
129
+ name: "a:alphaOff"
130
+ }));
131
+ if (options.alphaMod !== void 0) transforms.push(new BuilderElement({
132
+ attributes: { val: {
133
+ key: "val",
134
+ value: options.alphaMod
135
+ } },
136
+ name: "a:alphaMod"
137
+ }));
138
+ if (options.hue !== void 0) transforms.push(new BuilderElement({
139
+ attributes: { val: {
140
+ key: "val",
141
+ value: options.hue
142
+ } },
143
+ name: "a:hue"
144
+ }));
145
+ if (options.hueOff !== void 0) transforms.push(new BuilderElement({
146
+ attributes: { val: {
147
+ key: "val",
148
+ value: options.hueOff
149
+ } },
150
+ name: "a:hueOff"
151
+ }));
152
+ if (options.hueMod !== void 0) transforms.push(new BuilderElement({
153
+ attributes: { val: {
154
+ key: "val",
155
+ value: options.hueMod
156
+ } },
157
+ name: "a:hueMod"
158
+ }));
159
+ if (options.sat !== void 0) transforms.push(new BuilderElement({
160
+ attributes: { val: {
161
+ key: "val",
162
+ value: options.sat
163
+ } },
164
+ name: "a:sat"
165
+ }));
166
+ if (options.satOff !== void 0) transforms.push(new BuilderElement({
167
+ attributes: { val: {
168
+ key: "val",
169
+ value: options.satOff
170
+ } },
171
+ name: "a:satOff"
172
+ }));
173
+ if (options.satMod !== void 0) transforms.push(new BuilderElement({
174
+ attributes: { val: {
175
+ key: "val",
176
+ value: options.satMod
177
+ } },
178
+ name: "a:satMod"
179
+ }));
180
+ if (options.lum !== void 0) transforms.push(new BuilderElement({
181
+ attributes: { val: {
182
+ key: "val",
183
+ value: options.lum
184
+ } },
185
+ name: "a:lum"
186
+ }));
187
+ if (options.lumOff !== void 0) transforms.push(new BuilderElement({
188
+ attributes: { val: {
189
+ key: "val",
190
+ value: options.lumOff
191
+ } },
192
+ name: "a:lumOff"
193
+ }));
194
+ if (options.lumMod !== void 0) transforms.push(new BuilderElement({
195
+ attributes: { val: {
196
+ key: "val",
197
+ value: options.lumMod
198
+ } },
199
+ name: "a:lumMod"
200
+ }));
201
+ if (options.red !== void 0) transforms.push(new BuilderElement({
202
+ attributes: { val: {
203
+ key: "val",
204
+ value: options.red
205
+ } },
206
+ name: "a:red"
207
+ }));
208
+ if (options.redOff !== void 0) transforms.push(new BuilderElement({
209
+ attributes: { val: {
210
+ key: "val",
211
+ value: options.redOff
212
+ } },
213
+ name: "a:redOff"
214
+ }));
215
+ if (options.redMod !== void 0) transforms.push(new BuilderElement({
216
+ attributes: { val: {
217
+ key: "val",
218
+ value: options.redMod
219
+ } },
220
+ name: "a:redMod"
221
+ }));
222
+ if (options.green !== void 0) transforms.push(new BuilderElement({
223
+ attributes: { val: {
224
+ key: "val",
225
+ value: options.green
226
+ } },
227
+ name: "a:green"
228
+ }));
229
+ if (options.greenOff !== void 0) transforms.push(new BuilderElement({
230
+ attributes: { val: {
231
+ key: "val",
232
+ value: options.greenOff
233
+ } },
234
+ name: "a:greenOff"
235
+ }));
236
+ if (options.greenMod !== void 0) transforms.push(new BuilderElement({
237
+ attributes: { val: {
238
+ key: "val",
239
+ value: options.greenMod
240
+ } },
241
+ name: "a:greenMod"
242
+ }));
243
+ if (options.blue !== void 0) transforms.push(new BuilderElement({
244
+ attributes: { val: {
245
+ key: "val",
246
+ value: options.blue
247
+ } },
248
+ name: "a:blue"
249
+ }));
250
+ if (options.blueOff !== void 0) transforms.push(new BuilderElement({
251
+ attributes: { val: {
252
+ key: "val",
253
+ value: options.blueOff
254
+ } },
255
+ name: "a:blueOff"
256
+ }));
257
+ if (options.blueMod !== void 0) transforms.push(new BuilderElement({
258
+ attributes: { val: {
259
+ key: "val",
260
+ value: options.blueMod
261
+ } },
262
+ name: "a:blueMod"
263
+ }));
264
+ if (options.gamma) transforms.push(new BuilderElement({ name: "a:gamma" }));
265
+ if (options.invGamma) transforms.push(new BuilderElement({ name: "a:invGamma" }));
266
+ return transforms;
267
+ };
268
+ //#endregion
269
+ //#region src/drawingml/color/hsl-color.ts
270
+ /**
271
+ * HSL color element for DrawingML.
272
+ *
273
+ * This module provides HSL (Hue, Saturation, Luminance) color support.
274
+ *
275
+ * Reference: ISO/IEC 29500-4, dml-main.xsd, CT_HslColor
276
+ *
277
+ * @module
278
+ */
279
+ /**
280
+ * Creates an HSL color element.
281
+ *
282
+ * Specifies a color using Hue, Saturation, and Luminance values.
283
+ *
284
+ * ## XSD Schema
285
+ * ```xml
286
+ * <xsd:complexType name="CT_HslColor">
287
+ * <xsd:sequence>
288
+ * <xsd:group ref="EG_ColorTransform" minOccurs="0" maxOccurs="unbounded"/>
289
+ * </xsd:sequence>
290
+ * <xsd:attribute name="hue" type="ST_PositiveFixedAngle" use="required"/>
291
+ * <xsd:attribute name="sat" type="ST_Percentage" use="required"/>
292
+ * <xsd:attribute name="lum" type="ST_Percentage" use="required"/>
293
+ * </xsd:complexType>
294
+ * ```
295
+ */
296
+ const createHslColor = (options) => {
297
+ const transforms = options.transforms ? createColorTransforms(options.transforms) : [];
298
+ return new BuilderElement({
299
+ attributes: {
300
+ hue: {
301
+ key: "hue",
302
+ value: options.hue
303
+ },
304
+ lum: {
305
+ key: "lum",
306
+ value: options.luminance
307
+ },
308
+ sat: {
309
+ key: "sat",
310
+ value: options.saturation
311
+ }
312
+ },
313
+ children: [...transforms],
314
+ name: "a:hslClr"
315
+ });
316
+ };
317
+ //#endregion
318
+ //#region src/drawingml/color/preset-color.ts
319
+ /**
320
+ * Preset color element for DrawingML.
321
+ *
322
+ * This module provides named preset colors (CSS named colors).
323
+ *
324
+ * Reference: ISO/IEC 29500-4, dml-main.xsd, CT_PresetColor / ST_PresetColorVal
325
+ *
326
+ * @module
327
+ */
328
+ /**
329
+ * Preset color values (CSS named colors).
330
+ *
331
+ * ## XSD Schema
332
+ * ```xml
333
+ * <xsd:simpleType name="ST_PresetColorVal">
334
+ * <xsd:restriction base="xsd:token">
335
+ * <xsd:enumeration value="aliceBlue"/>
336
+ * ...
337
+ * <xsd:enumeration value="yellowGreen"/>
338
+ * </xsd:restriction>
339
+ * </xsd:simpleType>
340
+ * ```
341
+ */
342
+ const PresetColor = {
343
+ ALICE_BLUE: "aliceBlue",
344
+ ANTIQUE_WHITE: "antiqueWhite",
345
+ AQUA: "aqua",
346
+ AQUAMARINE: "aquamarine",
347
+ AZURE: "azure",
348
+ BEIGE: "beige",
349
+ BISQUE: "bisque",
350
+ BLACK: "black",
351
+ BLANCHED_ALMOND: "blanchedAlmond",
352
+ BLUE: "blue",
353
+ BLUE_VIOLET: "blueViolet",
354
+ BROWN: "brown",
355
+ BURLY_WOOD: "burlyWood",
356
+ CADET_BLUE: "cadetBlue",
357
+ CHARTREUSE: "chartreuse",
358
+ CHOCOLATE: "chocolate",
359
+ CORAL: "coral",
360
+ CORNFLOWER_BLUE: "cornflowerBlue",
361
+ CORNSILK: "cornsilk",
362
+ CRIMSON: "crimson",
363
+ CYAN: "cyan",
364
+ DARK_BLUE: "darkBlue",
365
+ DARK_CYAN: "darkCyan",
366
+ DARK_GOLDENROD: "darkGoldenrod",
367
+ DARK_GRAY: "darkGray",
368
+ DARK_GREY: "darkGrey",
369
+ DARK_GREEN: "darkGreen",
370
+ DARK_KHAKI: "darkKhaki",
371
+ DARK_MAGENTA: "darkMagenta",
372
+ DARK_OLIVE_GREEN: "darkOliveGreen",
373
+ DARK_ORANGE: "darkOrange",
374
+ DARK_ORCHID: "darkOrchid",
375
+ DARK_RED: "darkRed",
376
+ DARK_SALMON: "darkSalmon",
377
+ DARK_SEA_GREEN: "darkSeaGreen",
378
+ DARK_SLATE_BLUE: "darkSlateBlue",
379
+ DARK_SLATE_GRAY: "darkSlateGray",
380
+ DARK_SLATE_GREY: "darkSlateGrey",
381
+ DARK_TURQUOISE: "darkTurquoise",
382
+ DARK_VIOLET: "darkViolet",
383
+ DEEP_PINK: "deepPink",
384
+ DEEP_SKY_BLUE: "deepSkyBlue",
385
+ DIM_GRAY: "dimGray",
386
+ DIM_GREY: "dimGrey",
387
+ DODGER_BLUE: "dodgerBlue",
388
+ FIREBRICK: "firebrick",
389
+ FLORAL_WHITE: "floralWhite",
390
+ FOREST_GREEN: "forestGreen",
391
+ FUCHSIA: "fuchsia",
392
+ GAINSBORO: "gainsboro",
393
+ GHOST_WHITE: "ghostWhite",
394
+ GOLD: "gold",
395
+ GOLDENROD: "goldenrod",
396
+ GRAY: "gray",
397
+ GREY: "grey",
398
+ GREEN: "green",
399
+ GREEN_YELLOW: "greenYellow",
400
+ HONEYDEW: "honeydew",
401
+ HOT_PINK: "hotPink",
402
+ INDIAN_RED: "indianRed",
403
+ INDIGO: "indigo",
404
+ IVORY: "ivory",
405
+ KHAKI: "khaki",
406
+ LAVENDER: "lavender",
407
+ LAVENDER_BLUSH: "lavenderBlush",
408
+ LAWN_GREEN: "lawnGreen",
409
+ LEMON_CHIFFON: "lemonChiffon",
410
+ LIGHT_BLUE: "lightBlue",
411
+ LIGHT_CORAL: "lightCoral",
412
+ LIGHT_CYAN: "lightCyan",
413
+ LIGHT_GOLDENROD_YELLOW: "lightGoldenrodYellow",
414
+ LIGHT_GRAY: "lightGray",
415
+ LIGHT_GREY: "lightGrey",
416
+ LIGHT_GREEN: "lightGreen",
417
+ LIGHT_PINK: "lightPink",
418
+ LIGHT_SALMON: "lightSalmon",
419
+ LIGHT_SEA_GREEN: "lightSeaGreen",
420
+ LIGHT_SKY_BLUE: "lightSkyBlue",
421
+ LIGHT_SLATE_GRAY: "lightSlateGray",
422
+ LIGHT_SLATE_GREY: "lightSlateGrey",
423
+ LIGHT_STEEL_BLUE: "lightSteelBlue",
424
+ LIGHT_YELLOW: "lightYellow",
425
+ LIME: "lime",
426
+ LIME_GREEN: "limeGreen",
427
+ LINEN: "linen",
428
+ MAGENTA: "magenta",
429
+ MAROON: "maroon",
430
+ MEDIUM_AQUAMARINE: "mediumAquamarine",
431
+ MEDIUM_BLUE: "mediumBlue",
432
+ MEDIUM_ORCHID: "mediumOrchid",
433
+ MEDIUM_PURPLE: "mediumPurple",
434
+ MEDIUM_SEA_GREEN: "mediumSeaGreen",
435
+ MEDIUM_SLATE_BLUE: "mediumSlateBlue",
436
+ MEDIUM_SPRING_GREEN: "mediumSpringGreen",
437
+ MEDIUM_TURQUOISE: "mediumTurquoise",
438
+ MEDIUM_VIOLET_RED: "mediumVioletRed",
439
+ MIDNIGHT_BLUE: "midnightBlue",
440
+ MINT_CREAM: "mintCream",
441
+ MISTY_ROSE: "mistyRose",
442
+ MOCCASIN: "moccasin",
443
+ NAVAJO_WHITE: "navajoWhite",
444
+ NAVY: "navy",
445
+ OLD_LACE: "oldLace",
446
+ OLIVE: "olive",
447
+ OLIVE_DRAB: "oliveDrab",
448
+ ORANGE: "orange",
449
+ ORANGE_RED: "orangeRed",
450
+ ORCHID: "orchid",
451
+ PALE_GOLDENROD: "paleGoldenrod",
452
+ PALE_GREEN: "paleGreen",
453
+ PALE_TURQUOISE: "paleTurquoise",
454
+ PALE_VIOLET_RED: "paleVioletRed",
455
+ PAPAYA_WHIP: "papayaWhip",
456
+ PEACH_PUFF: "peachPuff",
457
+ PERU: "peru",
458
+ PINK: "pink",
459
+ PLUM: "plum",
460
+ POWDER_BLUE: "powderBlue",
461
+ PURPLE: "purple",
462
+ RED: "red",
463
+ ROSY_BROWN: "rosyBrown",
464
+ ROYAL_BLUE: "royalBlue",
465
+ SADDLE_BROWN: "saddleBrown",
466
+ SALMON: "salmon",
467
+ SANDY_BROWN: "sandyBrown",
468
+ SEA_GREEN: "seaGreen",
469
+ SEA_SHELL: "seaShell",
470
+ SIENNA: "sienna",
471
+ SILVER: "silver",
472
+ SKY_BLUE: "skyBlue",
473
+ SLATE_BLUE: "slateBlue",
474
+ SLATE_GRAY: "slateGray",
475
+ SLATE_GREY: "slateGrey",
476
+ SNOW: "snow",
477
+ SPRING_GREEN: "springGreen",
478
+ STEEL_BLUE: "steelBlue",
479
+ TAN: "tan",
480
+ TEAL: "teal",
481
+ THISTLE: "thistle",
482
+ TOMATO: "tomato",
483
+ TURQUOISE: "turquoise",
484
+ VIOLET: "violet",
485
+ WHEAT: "wheat",
486
+ WHITE: "white",
487
+ WHITE_SMOKE: "whiteSmoke",
488
+ YELLOW: "yellow",
489
+ YELLOW_GREEN: "yellowGreen"
490
+ };
491
+ /**
492
+ * Creates a preset color element.
493
+ *
494
+ * Specifies a color using a named preset (CSS named color).
495
+ *
496
+ * ## XSD Schema
497
+ * ```xml
498
+ * <xsd:complexType name="CT_PresetColor">
499
+ * <xsd:sequence>
500
+ * <xsd:group ref="EG_ColorTransform" minOccurs="0" maxOccurs="unbounded"/>
501
+ * </xsd:sequence>
502
+ * <xsd:attribute name="val" type="ST_PresetColorVal" use="required"/>
503
+ * </xsd:complexType>
504
+ * ```
505
+ */
506
+ const createPresetColor = (options) => {
507
+ const transforms = options.transforms ? createColorTransforms(options.transforms) : [];
508
+ return new BuilderElement({
509
+ attributes: { value: {
510
+ key: "val",
511
+ value: options.value
512
+ } },
513
+ children: [...transforms],
514
+ name: "a:prstClr"
515
+ });
516
+ };
517
+ //#endregion
518
+ //#region src/drawingml/color/rgb-color.ts
519
+ /**
520
+ * RGB color element for DrawingML shapes.
521
+ *
522
+ * This module provides RGB color support for solid fills.
523
+ *
524
+ * Reference: ISO/IEC 29500-4, dml-main.xsd, CT_SRgbColor
525
+ *
526
+ * @module
527
+ */
528
+ /**
529
+ * Creates an sRGB color element.
530
+ *
531
+ * Specifies a color using RGB hex values.
532
+ *
533
+ * ## XSD Schema
534
+ * ```xml
535
+ * <xsd:complexType name="CT_SRgbColor">
536
+ * <xsd:sequence>
537
+ * <xsd:group ref="EG_ColorTransform" minOccurs="0" maxOccurs="unbounded"/>
538
+ * </xsd:sequence>
539
+ * <xsd:attribute name="val" type="s:ST_HexColorRGB" use="required"/>
540
+ * </xsd:complexType>
541
+ * ```
542
+ *
543
+ * @example
544
+ * ```typescript
545
+ * const redColor = createRgbColor({ value: "FF0000" });
546
+ * // With alpha transform
547
+ * const semiRed = createRgbColor({ value: "FF0000", transforms: { alpha: 50000 } });
548
+ * ```
549
+ */
550
+ const createRgbColor = (options) => {
551
+ const transforms = options.transforms ? createColorTransforms(options.transforms) : [];
552
+ return new BuilderElement({
553
+ attributes: { value: {
554
+ key: "val",
555
+ value: options.value
556
+ } },
557
+ children: [...transforms],
558
+ name: "a:srgbClr"
559
+ });
560
+ };
561
+ //#endregion
562
+ //#region src/drawingml/color/sc-rgb-color.ts
563
+ /**
564
+ * ScRGB color element for DrawingML shapes.
565
+ *
566
+ * This module provides scRGB color support using percentage-based RGB values.
567
+ *
568
+ * Reference: ISO/IEC 29500-4, dml-main.xsd, CT_ScRgbColor
569
+ *
570
+ * @module
571
+ */
572
+ /**
573
+ * Creates an scRGB color element.
574
+ *
575
+ * Specifies a color using percentage-based RGB values.
576
+ *
577
+ * ## XSD Schema
578
+ * ```xml
579
+ * <xsd:complexType name="CT_ScRgbColor">
580
+ * <xsd:sequence>
581
+ * <xsd:group ref="EG_ColorTransform" minOccurs="0" maxOccurs="unbounded"/>
582
+ * </xsd:sequence>
583
+ * <xsd:attribute name="r" type="ST_Percentage" use="required"/>
584
+ * <xsd:attribute name="g" type="ST_Percentage" use="required"/>
585
+ * <xsd:attribute name="b" type="ST_Percentage" use="required"/>
586
+ * </xsd:complexType>
587
+ * ```
588
+ *
589
+ * @example
590
+ * ```typescript
591
+ * const redColor = createScRgbColor({ r: "100%", g: "0%", b: "0%" });
592
+ * // With alpha transform
593
+ * const semiRed = createScRgbColor({ r: "100%", g: "0%", b: "0%", transforms: { alpha: 50000 } });
594
+ * ```
595
+ */
596
+ const createScRgbColor = (options) => {
597
+ const transforms = options.transforms ? createColorTransforms(options.transforms) : [];
598
+ return new BuilderElement({
599
+ attributes: {
600
+ r: {
601
+ key: "r",
602
+ value: options.r
603
+ },
604
+ g: {
605
+ key: "g",
606
+ value: options.g
607
+ },
608
+ b: {
609
+ key: "b",
610
+ value: options.b
611
+ }
612
+ },
613
+ children: [...transforms],
614
+ name: "a:scrgbClr"
615
+ });
616
+ };
617
+ //#endregion
618
+ //#region src/drawingml/color/scheme-color.ts
619
+ /**
620
+ * Scheme color element for DrawingML shapes.
621
+ *
622
+ * This module provides scheme-based color support for solid fills,
623
+ * allowing colors to be defined using theme color schemes.
624
+ *
625
+ * Reference: ISO/IEC 29500-4, dml-main.xsd, CT_SchemeColor / ST_SchemeColorVal
626
+ *
627
+ * @module
628
+ */
629
+ /**
630
+ * Scheme color values for theme-based colors.
631
+ *
632
+ * These values reference colors defined in the document's color scheme/theme.
633
+ */
634
+ const SchemeColor = {
635
+ /** Background color 1 */
636
+ BG1: "bg1",
637
+ /** Text color 1 */
638
+ TX1: "tx1",
639
+ /** Background color 2 */
640
+ BG2: "bg2",
641
+ /** Text color 2 */
642
+ TX2: "tx2",
643
+ /** Accent color 1 */
644
+ ACCENT1: "accent1",
645
+ /** Accent color 2 */
646
+ ACCENT2: "accent2",
647
+ /** Accent color 3 */
648
+ ACCENT3: "accent3",
649
+ /** Accent color 4 */
650
+ ACCENT4: "accent4",
651
+ /** Accent color 5 */
652
+ ACCENT5: "accent5",
653
+ /** Accent color 6 */
654
+ ACCENT6: "accent6",
655
+ /** Hyperlink color */
656
+ HLINK: "hlink",
657
+ /** Followed hyperlink color */
658
+ FOLHLINK: "folHlink",
659
+ /** Dark color 1 */
660
+ DK1: "dk1",
661
+ /** Light color 1 */
662
+ LT1: "lt1",
663
+ /** Dark color 2 */
664
+ DK2: "dk2",
665
+ /** Light color 2 */
666
+ LT2: "lt2",
667
+ /** Placeholder color */
668
+ PHCLR: "phClr"
669
+ };
670
+ /**
671
+ * Creates a scheme color element.
672
+ *
673
+ * Specifies a color using a theme color scheme reference.
674
+ *
675
+ * ## XSD Schema
676
+ * ```xml
677
+ * <xsd:complexType name="CT_SchemeColor">
678
+ * <xsd:sequence>
679
+ * <xsd:group ref="EG_ColorTransform" minOccurs="0" maxOccurs="unbounded"/>
680
+ * </xsd:sequence>
681
+ * <xsd:attribute name="val" type="ST_SchemeColorVal" use="required"/>
682
+ * </xsd:complexType>
683
+ * ```
684
+ *
685
+ * @example
686
+ * ```typescript
687
+ * const accentColor = createSchemeColor({ value: SchemeColor.ACCENT1 });
688
+ * // With tint transform
689
+ * const lightAccent = createSchemeColor({
690
+ * value: SchemeColor.ACCENT1,
691
+ * transforms: { tint: 40000 },
692
+ * });
693
+ * ```
694
+ */
695
+ const createSchemeColor = (options) => {
696
+ const transforms = options.transforms ? createColorTransforms(options.transforms) : [];
697
+ return new BuilderElement({
698
+ attributes: { value: {
699
+ key: "val",
700
+ value: options.value
701
+ } },
702
+ children: [...transforms],
703
+ name: "a:schemeClr"
704
+ });
705
+ };
706
+ //#endregion
707
+ //#region src/drawingml/color/system-color.ts
708
+ /**
709
+ * System color element for DrawingML.
710
+ *
711
+ * This module provides system color support, referencing OS-level UI colors.
712
+ *
713
+ * Reference: ISO/IEC 29500-4, dml-main.xsd, CT_SystemColor / ST_SystemColorVal
714
+ *
715
+ * @module
716
+ */
717
+ /**
718
+ * System color values referencing OS UI colors.
719
+ *
720
+ * ## XSD Schema
721
+ * ```xml
722
+ * <xsd:simpleType name="ST_SystemColorVal">
723
+ * <xsd:restriction base="xsd:token">
724
+ * <xsd:enumeration value="scrollBar"/>
725
+ * <xsd:enumeration value="background"/>
726
+ * ...
727
+ * <xsd:enumeration value="menuBar"/>
728
+ * </xsd:restriction>
729
+ * </xsd:simpleType>
730
+ * ```
731
+ */
732
+ const SystemColor = {
733
+ SCROLL_BAR: "scrollBar",
734
+ BACKGROUND: "background",
735
+ ACTIVE_CAPTION: "activeCaption",
736
+ INACTIVE_CAPTION: "inactiveCaption",
737
+ MENU: "menu",
738
+ WINDOW: "window",
739
+ WINDOW_FRAME: "windowFrame",
740
+ MENU_TEXT: "menuText",
741
+ WINDOW_TEXT: "windowText",
742
+ CAPTION_TEXT: "captionText",
743
+ ACTIVE_BORDER: "activeBorder",
744
+ INACTIVE_BORDER: "inactiveBorder",
745
+ APP_WORKSPACE: "appWorkspace",
746
+ HIGHLIGHT: "highlight",
747
+ HIGHLIGHT_TEXT: "highlightText",
748
+ BTN_FACE: "btnFace",
749
+ BTN_SHADOW: "btnShadow",
750
+ GRAY_TEXT: "grayText",
751
+ BTN_TEXT: "btnText",
752
+ INACTIVE_CAPTION_TEXT: "inactiveCaptionText",
753
+ BTN_HIGHLIGHT: "btnHighlight",
754
+ THREE_D_DK_SHADOW: "3dDkShadow",
755
+ THREE_D_LIGHT: "3dLight",
756
+ INFO_TEXT: "infoText",
757
+ INFO_BK: "infoBk",
758
+ HOT_LIGHT: "hotLight",
759
+ GRADIENT_ACTIVE_CAPTION: "gradientActiveCaption",
760
+ GRADIENT_INACTIVE_CAPTION: "gradientInactiveCaption",
761
+ MENU_HIGHLIGHT: "menuHighlight",
762
+ MENU_BAR: "menuBar"
763
+ };
764
+ /**
765
+ * Creates a system color element.
766
+ *
767
+ * References a system-defined UI color (e.g., window background, button face).
768
+ *
769
+ * ## XSD Schema
770
+ * ```xml
771
+ * <xsd:complexType name="CT_SystemColor">
772
+ * <xsd:sequence>
773
+ * <xsd:group ref="EG_ColorTransform" minOccurs="0" maxOccurs="unbounded"/>
774
+ * </xsd:sequence>
775
+ * <xsd:attribute name="val" type="ST_SystemColorVal" use="required"/>
776
+ * <xsd:attribute name="lastClr" type="s:ST_HexColorRGB" use="optional"/>
777
+ * </xsd:complexType>
778
+ * ```
779
+ */
780
+ const createSystemColor = (options) => {
781
+ const transforms = options.transforms ? createColorTransforms(options.transforms) : [];
782
+ return new BuilderElement({
783
+ attributes: {
784
+ lastClr: {
785
+ key: "lastClr",
786
+ value: options.lastClr
787
+ },
788
+ value: {
789
+ key: "val",
790
+ value: options.value
791
+ }
792
+ },
793
+ children: [...transforms],
794
+ name: "a:sysClr"
795
+ });
796
+ };
797
+ //#endregion
798
+ //#region src/drawingml/color/solid-fill.ts
799
+ /**
800
+ * Solid fill element for DrawingML shapes.
801
+ *
802
+ * This module provides solid fill support for outlines and shapes,
803
+ * supporting RGB, scheme, HSL, system, and preset colors.
804
+ *
805
+ * Reference: ISO/IEC 29500-4, dml-main.xsd, CT_SolidColorFillProperties
806
+ *
807
+ * @module
808
+ */
809
+ /**
810
+ * Creates the color child element for a solid fill based on the color type.
811
+ */
812
+ const SYSTEM_COLOR_VALUES = new Set(Object.values(SystemColor));
813
+ const PRESET_COLOR_VALUES = new Set(Object.values(PresetColor));
814
+ const SCHEME_COLOR_VALUES = new Set(Object.values(SchemeColor));
815
+ const createColorElement = (color) => {
816
+ if ("hue" in color && "saturation" in color && "luminance" in color) return createHslColor(color);
817
+ if ("r" in color && "g" in color && "b" in color) return createScRgbColor(color);
818
+ const colorValue = color.value;
819
+ if (SYSTEM_COLOR_VALUES.has(colorValue)) return createSystemColor(color);
820
+ if (PRESET_COLOR_VALUES.has(colorValue)) return createPresetColor(color);
821
+ if (SCHEME_COLOR_VALUES.has(colorValue)) return createSchemeColor(color);
822
+ return createRgbColor(color);
823
+ };
824
+ /**
825
+ * Creates a solid fill element.
826
+ *
827
+ * Specifies a solid color fill using any supported color type.
828
+ *
829
+ * ## XSD Schema
830
+ * ```xml
831
+ * <xsd:complexType name="CT_SolidColorFillProperties">
832
+ * <xsd:sequence>
833
+ * <xsd:group ref="EG_ColorChoice" minOccurs="0"/>
834
+ * <xsd:group ref="EG_EffectProperties" minOccurs="0"/>
835
+ * </xsd:sequence>
836
+ * </xsd:complexType>
837
+ * ```
838
+ *
839
+ * @example
840
+ * ```typescript
841
+ * // RGB solid fill
842
+ * const fill = createSolidFill({ value: "FF0000" });
843
+ * // Scheme solid fill with tint
844
+ * const schemeFill = createSolidFill({
845
+ * value: SchemeColor.ACCENT1, transforms: { tint: 40000 },
846
+ * });
847
+ * // HSL solid fill
848
+ * const hslFill = createSolidFill({ hue: 120000, saturation: 100000, luminance: 50000 });
849
+ * ```
850
+ */
851
+ const createSolidFill = (options) => new BuilderElement({
852
+ children: [createColorElement(options)],
853
+ name: "a:solidFill"
854
+ });
855
+ //#endregion
856
+ //#region src/drawingml/blip/blip-effects.ts
857
+ /**
858
+ * Blip image adjustment effects for DrawingML.
859
+ *
860
+ * These effects are applied directly to the image data within the `<a:blip>` element,
861
+ * corresponding to Word's "Picture Format > Adjust" features (brightness, contrast,
862
+ * grayscale, tint, duotone, etc.).
863
+ *
864
+ * Reference: ISO/IEC 29500-4, dml-main.xsd, CT_Blip children
865
+ *
866
+ * @module
867
+ */
868
+ /**
869
+ * Creates blip effect elements from BlipEffectsOptions.
870
+ *
871
+ * @returns Array of XML components representing blip effects
872
+ */
873
+ const createBlipEffects = (options) => {
874
+ const children = [];
875
+ if (options.grayscale) children.push(new BuilderElement({ name: "a:grayscl" }));
876
+ if (options.luminance) {
877
+ const attrs = {};
878
+ if (options.luminance.bright !== void 0) attrs.bright = {
879
+ key: "bright",
880
+ value: `${options.luminance.bright}%`
881
+ };
882
+ if (options.luminance.contrast !== void 0) attrs.contrast = {
883
+ key: "contrast",
884
+ value: `${options.luminance.contrast}%`
885
+ };
886
+ children.push(new BuilderElement({
887
+ attributes: attrs,
888
+ name: "a:lum"
889
+ }));
890
+ }
891
+ if (options.hsl) {
892
+ const attrs = {};
893
+ if (options.hsl.hue !== void 0) attrs.hue = {
894
+ key: "hue",
895
+ value: String(options.hsl.hue)
896
+ };
897
+ if (options.hsl.saturation !== void 0) attrs.sat = {
898
+ key: "sat",
899
+ value: `${options.hsl.saturation}%`
900
+ };
901
+ if (options.hsl.luminance !== void 0) attrs.lum = {
902
+ key: "lum",
903
+ value: `${options.hsl.luminance}%`
904
+ };
905
+ children.push(new BuilderElement({
906
+ attributes: attrs,
907
+ name: "a:hsl"
908
+ }));
909
+ }
910
+ if (options.tint) {
911
+ const attrs = {};
912
+ if (options.tint.hue !== void 0) attrs.hue = {
913
+ key: "hue",
914
+ value: String(options.tint.hue)
915
+ };
916
+ if (options.tint.amount !== void 0) attrs.amt = {
917
+ key: "amt",
918
+ value: `${options.tint.amount}%`
919
+ };
920
+ children.push(new BuilderElement({
921
+ attributes: attrs,
922
+ name: "a:tint"
923
+ }));
924
+ }
925
+ if (options.duotone) children.push(new BuilderElement({
926
+ children: [createColorElement(options.duotone.color1), createColorElement(options.duotone.color2)],
927
+ name: "a:duotone"
928
+ }));
929
+ if (options.biLevel) children.push(new BuilderElement({
930
+ attributes: { thresh: {
931
+ key: "thresh",
932
+ value: `${options.biLevel.threshold}%`
933
+ } },
934
+ name: "a:biLevel"
935
+ }));
936
+ if (options.alphaCeiling) children.push(new BuilderElement({ name: "a:alphaCeiling" }));
937
+ if (options.alphaFloor) children.push(new BuilderElement({ name: "a:alphaFloor" }));
938
+ if (options.alphaInverse !== void 0) if (typeof options.alphaInverse === "boolean") children.push(new BuilderElement({ name: "a:alphaInv" }));
939
+ else children.push(new BuilderElement({
940
+ children: [createColorElement(options.alphaInverse)],
941
+ name: "a:alphaInv"
942
+ }));
943
+ if (options.alphaModFix) {
944
+ const amt = options.alphaModFix.amount ?? 100;
945
+ children.push(new BuilderElement({
946
+ attributes: { amt: {
947
+ key: "amt",
948
+ value: `${amt}%`
949
+ } },
950
+ name: "a:alphaModFix"
951
+ }));
952
+ }
953
+ if (options.alphaRepl) children.push(new BuilderElement({
954
+ attributes: { a: {
955
+ key: "a",
956
+ value: `${options.alphaRepl.amount}%`
957
+ } },
958
+ name: "a:alphaRepl"
959
+ }));
960
+ if (options.alphaBiLevel) children.push(new BuilderElement({
961
+ attributes: { thresh: {
962
+ key: "thresh",
963
+ value: `${options.alphaBiLevel.threshold}%`
964
+ } },
965
+ name: "a:alphaBiLevel"
966
+ }));
967
+ if (options.colorChange) {
968
+ const attrs = {};
969
+ if (options.colorChange.useAlpha === false) attrs.useA = {
970
+ key: "useA",
971
+ value: "0"
972
+ };
973
+ children.push(new BuilderElement({
974
+ attributes: attrs,
975
+ children: [new BuilderElement({
976
+ children: [createColorElement(options.colorChange.from)],
977
+ name: "a:clrFrom"
978
+ }), new BuilderElement({
979
+ children: [createColorElement(options.colorChange.to)],
980
+ name: "a:clrTo"
981
+ })],
982
+ name: "a:clrChange"
983
+ }));
984
+ }
985
+ if (options.colorRepl) children.push(new BuilderElement({
986
+ children: [createColorElement(options.colorRepl.color)],
987
+ name: "a:clrRepl"
988
+ }));
989
+ if (options.blur) {
990
+ const attrs = {};
991
+ if (options.blur.radius !== void 0) attrs.rad = {
992
+ key: "rad",
993
+ value: options.blur.radius
994
+ };
995
+ if (options.blur.grow === false) attrs.grow = {
996
+ key: "grow",
997
+ value: 0
998
+ };
999
+ children.push(new BuilderElement({
1000
+ attributes: attrs,
1001
+ name: "a:blur"
1002
+ }));
1003
+ }
1004
+ return children;
1005
+ };
1006
+ //#endregion
1007
+ //#region src/drawingml/blip/source-rectangle.ts
1008
+ /**
1009
+ * Source rectangle module for blip fills.
1010
+ *
1011
+ * This module defines the portion of an image to use when filling a shape.
1012
+ *
1013
+ * Reference: ISO/IEC 29500-4, dml-main.xsd, CT_RelativeRect
1014
+ *
1015
+ * @module
1016
+ */
1017
+ /**
1018
+ * Creates a source rectangle element for blip fill cropping.
1019
+ *
1020
+ * This element specifies a portion of the blip (image) to use as the fill.
1021
+ * When no options are provided, the entire blip is used.
1022
+ *
1023
+ * Reference: ISO/IEC 29500-4, dml-main.xsd, CT_RelativeRect
1024
+ *
1025
+ * ## XSD Schema
1026
+ * ```xml
1027
+ * <xsd:complexType name="CT_RelativeRect">
1028
+ * <xsd:attribute name="l" type="ST_Percentage" use="optional" default="0"/>
1029
+ * <xsd:attribute name="t" type="ST_Percentage" use="optional" default="0"/>
1030
+ * <xsd:attribute name="r" type="ST_Percentage" use="optional" default="0"/>
1031
+ * <xsd:attribute name="b" type="ST_Percentage" use="optional" default="0"/>
1032
+ * </xsd:complexType>
1033
+ * ```
1034
+ *
1035
+ * @example
1036
+ * ```typescript
1037
+ * // Crop 10% from left and right
1038
+ * createSourceRectangle({ left: 10000, right: 10000 });
1039
+ * ```
1040
+ */
1041
+ const createSourceRectangle = (options) => {
1042
+ if (!options) return new BuilderElement({ name: "a:srcRect" });
1043
+ const attributes = {};
1044
+ if (options.left !== void 0) attributes.l = {
1045
+ key: "l",
1046
+ value: options.left
1047
+ };
1048
+ if (options.top !== void 0) attributes.t = {
1049
+ key: "t",
1050
+ value: options.top
1051
+ };
1052
+ if (options.right !== void 0) attributes.r = {
1053
+ key: "r",
1054
+ value: options.right
1055
+ };
1056
+ if (options.bottom !== void 0) attributes.b = {
1057
+ key: "b",
1058
+ value: options.bottom
1059
+ };
1060
+ return new BuilderElement({
1061
+ attributes,
1062
+ name: "a:srcRect"
1063
+ });
1064
+ };
1065
+ //#endregion
1066
+ //#region src/drawingml/blip/stretch.ts
1067
+ /**
1068
+ * Stretch fill module for blip fills.
1069
+ *
1070
+ * This module defines how images are stretched to fill shapes.
1071
+ *
1072
+ * Reference: http://officeopenxml.com/drwPic.php
1073
+ *
1074
+ * @module
1075
+ */
1076
+ /**
1077
+ * Represents a fill rectangle for stretch fill mode.
1078
+ *
1079
+ * This element specifies the rectangular area of the shape to which
1080
+ * the blip fill should be stretched.
1081
+ *
1082
+ * Reference: http://officeopenxml.com/drwPic.php
1083
+ *
1084
+ * ## XSD Schema
1085
+ * ```xml
1086
+ * <xsd:complexType name="CT_RelativeRect">
1087
+ * <xsd:attribute name="l" type="ST_Percentage" use="optional" default="0"/>
1088
+ * <xsd:attribute name="t" type="ST_Percentage" use="optional" default="0"/>
1089
+ * <xsd:attribute name="r" type="ST_Percentage" use="optional" default="0"/>
1090
+ * <xsd:attribute name="b" type="ST_Percentage" use="optional" default="0"/>
1091
+ * </xsd:complexType>
1092
+ * ```
1093
+ */
1094
+ var FillRectangle = class extends XmlComponent {
1095
+ constructor() {
1096
+ super("a:fillRect");
1097
+ }
1098
+ };
1099
+ /**
1100
+ * Represents a stretch fill mode for blip fills.
1101
+ *
1102
+ * This element specifies that the blip (image) should be stretched to fill
1103
+ * the entire shape. The stretch fill is one of the fill mode properties
1104
+ * that determines how an image is applied to a shape.
1105
+ *
1106
+ * Reference: http://officeopenxml.com/drwPic.php
1107
+ *
1108
+ * ## XSD Schema
1109
+ * ```xml
1110
+ * <xsd:complexType name="CT_StretchInfoProperties">
1111
+ * <xsd:sequence>
1112
+ * <xsd:element name="fillRect" type="CT_RelativeRect" minOccurs="0" maxOccurs="1"/>
1113
+ * </xsd:sequence>
1114
+ * </xsd:complexType>
1115
+ * ```
1116
+ *
1117
+ * @example
1118
+ * ```typescript
1119
+ * const stretch = new Stretch();
1120
+ * ```
1121
+ */
1122
+ var Stretch = class extends XmlComponent {
1123
+ constructor() {
1124
+ super("a:stretch");
1125
+ this.root.push(new FillRectangle());
1126
+ }
1127
+ };
1128
+ //#endregion
1129
+ //#region src/xsd-mappings.ts
1130
+ /**
1131
+ * Bidirectional mappings between user-friendly values and XSD abbreviated values.
1132
+ *
1133
+ * When XSD uses full English words (e.g. "center", "start"), values are used directly — no mapping needed.
1134
+ * When XSD uses abbreviations (e.g. "ctr", "l", "rnd"), this module maps them to full words.
1135
+ *
1136
+ * Usage in generation (Options → XML): xsdAlign.to("center") → "ctr"
1137
+ * Usage in parsing (XML → Options): xsdAlign.from("ctr") → "center"
1138
+ */
1139
+ /** Invert a Record<K, V> into Record<V, K>. */
1140
+ function invertMap(map) {
1141
+ const result = {};
1142
+ for (const key in map) result[map[key]] = key;
1143
+ return result;
1144
+ }
1145
+ /** Create a bidirectional mapping helper from a single forward map. */
1146
+ function bidi(forward) {
1147
+ const reverse = invertMap(forward);
1148
+ return {
1149
+ /** User-friendly value → XSD value */
1150
+ to: (key) => forward[key] ?? key,
1151
+ /** XSD value → user-friendly value */
1152
+ from: (xsd) => reverse[xsd] ?? xsd,
1153
+ /** The forward map (user → XSD) */
1154
+ forward,
1155
+ /** The reverse map (XSD → user) */
1156
+ reverse
1157
+ };
1158
+ }
1159
+ const xsdRectAlignment = bidi({
1160
+ topLeft: "tl",
1161
+ top: "t",
1162
+ topRight: "tr",
1163
+ left: "l",
1164
+ center: "ctr",
1165
+ right: "r",
1166
+ bottomLeft: "bl",
1167
+ bottom: "b",
1168
+ bottomRight: "br"
1169
+ });
1170
+ const xsdTextAlign = bidi({
1171
+ left: "l",
1172
+ center: "ctr",
1173
+ right: "r",
1174
+ justify: "just"
1175
+ });
1176
+ const xsdTextAnchor = bidi({
1177
+ top: "t",
1178
+ center: "ctr",
1179
+ bottom: "b"
1180
+ });
1181
+ const xsdLineCap = bidi({
1182
+ round: "rnd",
1183
+ square: "sq",
1184
+ flat: "flat"
1185
+ });
1186
+ const xsdCompoundLine = bidi({
1187
+ single: "sng",
1188
+ double: "dbl",
1189
+ thickThin: "thickThin",
1190
+ thinThick: "thinThick",
1191
+ triple: "tri"
1192
+ });
1193
+ const xsdPenAlignment = bidi({
1194
+ center: "ctr",
1195
+ inside: "in"
1196
+ });
1197
+ const xsdLineEndSize = bidi({
1198
+ small: "sm",
1199
+ medium: "med",
1200
+ large: "lg"
1201
+ });
1202
+ const xsdBlendMode = bidi({
1203
+ over: "over",
1204
+ multiply: "mult",
1205
+ screen: "screen",
1206
+ darken: "darken",
1207
+ lighten: "lighten"
1208
+ });
1209
+ const xsdPathFillMode = bidi({
1210
+ none: "none",
1211
+ normal: "norm",
1212
+ lighten: "lighten",
1213
+ lightenLess: "lightenLess",
1214
+ darken: "darken",
1215
+ darkenLess: "darkenLess"
1216
+ });
1217
+ const xsdEffectContainer = bidi({
1218
+ sibling: "sib",
1219
+ tree: "tree"
1220
+ });
1221
+ const xsdPresetShadow = bidi({
1222
+ shadow1: "shdw1",
1223
+ shadow2: "shdw2",
1224
+ shadow3: "shdw3",
1225
+ shadow4: "shdw4",
1226
+ shadow5: "shdw5",
1227
+ shadow6: "shdw6",
1228
+ shadow7: "shdw7",
1229
+ shadow8: "shdw8",
1230
+ shadow9: "shdw9",
1231
+ shadow10: "shdw10",
1232
+ shadow11: "shdw11",
1233
+ shadow12: "shdw12",
1234
+ shadow13: "shdw13",
1235
+ shadow14: "shdw14",
1236
+ shadow15: "shdw15",
1237
+ shadow16: "shdw16",
1238
+ shadow17: "shdw17",
1239
+ shadow18: "shdw18",
1240
+ shadow19: "shdw19",
1241
+ shadow20: "shdw20"
1242
+ });
1243
+ const xsdMaterialType = bidi({
1244
+ legacyMatte: "legacyMatte",
1245
+ legacyPlastic: "legacyPlastic",
1246
+ legacyMetal: "legacyMetal",
1247
+ legacyWireframe: "legacyWireframe",
1248
+ matte: "matte",
1249
+ plastic: "plastic",
1250
+ metal: "metal",
1251
+ warmMatte: "warmMatte",
1252
+ translucentPowder: "translucentPowder",
1253
+ powder: "powder",
1254
+ darkEdge: "dkEdge",
1255
+ softEdge: "softEdge",
1256
+ clear: "clear",
1257
+ flat: "flat",
1258
+ softMetal: "softmetal"
1259
+ });
1260
+ const xsdPattern = bidi({
1261
+ percent5: "pct5",
1262
+ percent10: "pct10",
1263
+ percent20: "pct20",
1264
+ percent25: "pct25",
1265
+ percent30: "pct30",
1266
+ percent40: "pct40",
1267
+ percent50: "pct50",
1268
+ percent60: "pct60",
1269
+ percent70: "pct70",
1270
+ percent75: "pct75",
1271
+ percent80: "pct80",
1272
+ percent90: "pct90",
1273
+ horizontal: "horz",
1274
+ vertical: "vert",
1275
+ lightHorizontal: "ltHorz",
1276
+ lightVertical: "ltVert",
1277
+ darkHorizontal: "dkHorz",
1278
+ darkVertical: "dkVert",
1279
+ narrowHorizontal: "narHorz",
1280
+ narrowVertical: "narVert",
1281
+ dashedHorizontal: "dashHorz",
1282
+ dashedVertical: "dashVert",
1283
+ cross: "cross",
1284
+ downDiagonal: "dnDiag",
1285
+ upDiagonal: "upDiag",
1286
+ lightDownDiagonal: "ltDnDiag",
1287
+ lightUpDiagonal: "ltUpDiag",
1288
+ darkDownDiagonal: "dkDnDiag",
1289
+ darkUpDiagonal: "dkUpDiag",
1290
+ wideDownDiagonal: "wdDnDiag",
1291
+ wideUpDiagonal: "wdUpDiag",
1292
+ dashedDownDiagonal: "dashDnDiag",
1293
+ dashedUpDiagonal: "dashUpDiag",
1294
+ diagonalCross: "diagCross",
1295
+ smallChecker: "smCheck",
1296
+ largeChecker: "lgCheck",
1297
+ smallGrid: "smGrid",
1298
+ largeGrid: "lgGrid",
1299
+ dotGrid: "dotGrid",
1300
+ smallConfetti: "smConfetti",
1301
+ largeConfetti: "lgConfetti",
1302
+ horizontalBrick: "horzBrick",
1303
+ diagonalBrick: "diagBrick",
1304
+ solidDiamond: "solidDmnd",
1305
+ openDiamond: "openDmnd",
1306
+ dottedDiamond: "dotDmnd",
1307
+ plaid: "plaid",
1308
+ sphere: "sphere",
1309
+ weave: "weave",
1310
+ divot: "divot",
1311
+ shingle: "shingle",
1312
+ wave: "wave",
1313
+ trellis: "trellis",
1314
+ zigZag: "zigZag"
1315
+ });
1316
+ const xsdVerticalMergeRev = bidi({
1317
+ continue: "cont",
1318
+ restart: "rest"
1319
+ });
1320
+ const xsdUnderlineStyle = bidi({
1321
+ single: "sng",
1322
+ double: "dbl",
1323
+ none: "none"
1324
+ });
1325
+ const xsdStrikeStyle = bidi({
1326
+ singleStrike: "sngStrike",
1327
+ doubleStrike: "dblStrike",
1328
+ noStrike: "noStrike"
1329
+ });
1330
+ const xsdTextCaps = bidi({
1331
+ none: "none",
1332
+ all: "all",
1333
+ small: "small"
1334
+ });
1335
+ //#endregion
1336
+ //#region src/drawingml/blip/tile.ts
1337
+ /**
1338
+ * Tile fill module for blip fills.
1339
+ *
1340
+ * This module defines how images are tiled (repeated) to fill shapes.
1341
+ *
1342
+ * Reference: ISO/IEC 29500-4, dml-main.xsd, CT_TileInfoProperties
1343
+ *
1344
+ * @module
1345
+ */
1346
+ /**
1347
+ * Tile alignment within the shape.
1348
+ *
1349
+ * Specifies the anchor position of the first tile relative to the shape.
1350
+ */
1351
+ const TileAlignment = {
1352
+ /** Top-left corner */
1353
+ TOP_LEFT: "topLeft",
1354
+ /** Top center */
1355
+ TOP: "top",
1356
+ /** Top-right corner */
1357
+ TOP_RIGHT: "topRight",
1358
+ /** Middle-left */
1359
+ LEFT: "left",
1360
+ /** Center */
1361
+ CENTER: "center",
1362
+ /** Middle-right */
1363
+ RIGHT: "right",
1364
+ /** Bottom-left corner */
1365
+ BOTTOM_LEFT: "bottomLeft",
1366
+ /** Bottom center */
1367
+ BOTTOM: "bottom",
1368
+ /** Bottom-right corner */
1369
+ BOTTOM_RIGHT: "bottomRight"
1370
+ };
1371
+ /**
1372
+ * Creates a tile fill mode element for blip fills.
1373
+ *
1374
+ * When a blip fill uses tile mode, the image is repeated (tiled) to fill
1375
+ * the shape instead of being stretched. This element controls the tiling
1376
+ * parameters such as offset, scale, flip, and alignment.
1377
+ *
1378
+ * Reference: ISO/IEC 29500-4, dml-main.xsd, CT_TileInfoProperties
1379
+ *
1380
+ * ## XSD Schema
1381
+ * ```xml
1382
+ * <xsd:complexType name="CT_TileInfoProperties">
1383
+ * <xsd:attribute name="tx" type="ST_Coordinate" use="optional"/>
1384
+ * <xsd:attribute name="ty" type="ST_Coordinate" use="optional"/>
1385
+ * <xsd:attribute name="sx" type="ST_Percentage" use="optional"/>
1386
+ * <xsd:attribute name="sy" type="ST_Percentage" use="optional"/>
1387
+ * <xsd:attribute name="flip" type="ST_TileFlipMode" default="none"/>
1388
+ * <xsd:attribute name="algn" type="ST_RectAlignment" use="optional"/>
1389
+ * </xsd:complexType>
1390
+ * ```
1391
+ *
1392
+ * @example
1393
+ * ```typescript
1394
+ * // Tile with 50% scale
1395
+ * createTileInfo({ sx: 50, sy: 50 });
1396
+ * // Tile with flip and alignment
1397
+ * createTileInfo({ flip: "XY", align: "CENTER" });
1398
+ * ```
1399
+ */
1400
+ const createTileInfo = (options) => {
1401
+ if (!options) return new BuilderElement({ name: "a:tile" });
1402
+ const attributes = {};
1403
+ if (options.tx !== void 0) attributes.tx = {
1404
+ key: "tx",
1405
+ value: options.tx
1406
+ };
1407
+ if (options.ty !== void 0) attributes.ty = {
1408
+ key: "ty",
1409
+ value: options.ty
1410
+ };
1411
+ if (options.sx !== void 0) attributes.sx = {
1412
+ key: "sx",
1413
+ value: options.sx
1414
+ };
1415
+ if (options.sy !== void 0) attributes.sy = {
1416
+ key: "sy",
1417
+ value: options.sy
1418
+ };
1419
+ if (options.flip !== void 0) attributes.flip = {
1420
+ key: "flip",
1421
+ value: options.flip
1422
+ };
1423
+ if (options.align !== void 0) attributes.algn = {
1424
+ key: "algn",
1425
+ value: xsdRectAlignment.to(options.align)
1426
+ };
1427
+ return new BuilderElement({
1428
+ attributes: Object.keys(attributes).length > 0 ? attributes : void 0,
1429
+ name: "a:tile"
1430
+ });
1431
+ };
1432
+ //#endregion
1433
+ //#region src/drawingml/fill/gradient-fill.ts
1434
+ /**
1435
+ * Gradient fill element for DrawingML shapes.
1436
+ *
1437
+ * This module provides gradient fill support with linear and path shading.
1438
+ *
1439
+ * Reference: ISO/IEC 29500-4, dml-main.xsd, CT_GradientFillProperties
1440
+ *
1441
+ * @module
1442
+ */
1443
+ /**
1444
+ * Path shade type for radial gradients.
1445
+ */
1446
+ const PathShadeType = {
1447
+ /** Follow shape path */
1448
+ SHAPE: "shape",
1449
+ /** Circular gradient */
1450
+ CIRCLE: "circle",
1451
+ /** Rectangular gradient */
1452
+ RECT: "rect"
1453
+ };
1454
+ /**
1455
+ * Tile flip mode for gradient fill.
1456
+ *
1457
+ * ## XSD Schema
1458
+ * ```xml
1459
+ * <xsd:simpleType name="ST_TileFlipMode">
1460
+ * <xsd:restriction base="xsd:string">
1461
+ * <xsd:enumeration value="none"/>
1462
+ * <xsd:enumeration value="x"/>
1463
+ * <xsd:enumeration value="y"/>
1464
+ * <xsd:enumeration value="xy"/>
1465
+ * </xsd:restriction>
1466
+ * </xsd:simpleType>
1467
+ * ```
1468
+ */
1469
+ const TileFlipMode = {
1470
+ /** No flip */
1471
+ NONE: "none",
1472
+ /** Flip horizontally */
1473
+ X: "x",
1474
+ /** Flip vertically */
1475
+ Y: "y",
1476
+ /** Flip both horizontally and vertically */
1477
+ XY: "xy"
1478
+ };
1479
+ /**
1480
+ * Creates a gradient stop element (a:gs).
1481
+ *
1482
+ * @example
1483
+ * ```typescript
1484
+ * createGradientStop({ position: 0, color: { value: "FF0000" } });
1485
+ * createGradientStop({ position: 100000, color: { value: "0000FF" } });
1486
+ * ```
1487
+ */
1488
+ const createGradientStop = (stop) => new BuilderElement({
1489
+ attributes: { pos: {
1490
+ key: "pos",
1491
+ value: stop.position
1492
+ } },
1493
+ children: [createColorElement(stop.color)],
1494
+ name: "a:gs"
1495
+ });
1496
+ /**
1497
+ * Creates a relative rect element.
1498
+ */
1499
+ const createRelativeRect = (name, rect) => new BuilderElement({
1500
+ attributes: {
1501
+ l: {
1502
+ key: "l",
1503
+ value: rect?.left
1504
+ },
1505
+ t: {
1506
+ key: "t",
1507
+ value: rect?.top
1508
+ },
1509
+ r: {
1510
+ key: "r",
1511
+ value: rect?.right
1512
+ },
1513
+ b: {
1514
+ key: "b",
1515
+ value: rect?.bottom
1516
+ }
1517
+ },
1518
+ name
1519
+ });
1520
+ /**
1521
+ * Creates the shade element (a:lin or a:path).
1522
+ */
1523
+ const createShadeElement = (shade) => {
1524
+ if ("angle" in shade) return new BuilderElement({
1525
+ attributes: {
1526
+ ang: {
1527
+ key: "ang",
1528
+ value: shade.angle
1529
+ },
1530
+ scaled: {
1531
+ key: "scaled",
1532
+ value: shade.scaled
1533
+ }
1534
+ },
1535
+ name: "a:lin"
1536
+ });
1537
+ const pathShade = shade;
1538
+ const children = [];
1539
+ if (pathShade.fillToRect) children.push(createRelativeRect("a:fillToRect", pathShade.fillToRect));
1540
+ return new BuilderElement({
1541
+ attributes: { path: {
1542
+ key: "path",
1543
+ value: pathShade.path
1544
+ } },
1545
+ children,
1546
+ name: "a:path"
1547
+ });
1548
+ };
1549
+ /**
1550
+ * Creates a gradient fill element.
1551
+ *
1552
+ * ## XSD Schema
1553
+ * ```xml
1554
+ * <xsd:complexType name="CT_GradientFillProperties">
1555
+ * <xsd:sequence>
1556
+ * <xsd:element name="gsLst" type="CT_GradientStopList" minOccurs="0"/>
1557
+ * <xsd:group ref="EG_ShadeProperties" minOccurs="0"/>
1558
+ * </xsd:sequence>
1559
+ * <xsd:attribute name="rotWithShape" type="xsd:boolean" use="optional"/>
1560
+ * </xsd:complexType>
1561
+ * ```
1562
+ *
1563
+ * @example
1564
+ * ```typescript
1565
+ * // Linear gradient from red to blue
1566
+ * createGradientFill({
1567
+ * stops: [
1568
+ * { position: 0, color: { value: "FF0000" } },
1569
+ * { position: 100000, color: { value: "0000FF" } },
1570
+ * ],
1571
+ * shade: { angle: 5400000 },
1572
+ * });
1573
+ * ```
1574
+ */
1575
+ const createGradientFill = (options) => {
1576
+ const children = [];
1577
+ children.push(new BuilderElement({
1578
+ children: options.stops.map(createGradientStop),
1579
+ name: "a:gsLst"
1580
+ }));
1581
+ if (options.shade) children.push(createShadeElement(options.shade));
1582
+ if (options.tileRect) children.push(createRelativeRect("a:tileRect", options.tileRect));
1583
+ return new BuilderElement({
1584
+ attributes: {
1585
+ flip: {
1586
+ key: "flip",
1587
+ value: options.flip
1588
+ },
1589
+ rotWithShape: {
1590
+ key: "rotWithShape",
1591
+ value: options.rotateWithShape
1592
+ }
1593
+ },
1594
+ children,
1595
+ name: "a:gradFill"
1596
+ });
1597
+ };
1598
+ //#endregion
1599
+ //#region src/drawingml/fill/pattern-fill.ts
1600
+ /**
1601
+ * Pattern fill element for DrawingML shapes.
1602
+ *
1603
+ * This module provides pattern fill support with preset patterns and
1604
+ * optional foreground/background colors.
1605
+ *
1606
+ * Reference: ISO/IEC 29500-4, dml-main.xsd, CT_PatternFillProperties
1607
+ *
1608
+ * @module
1609
+ */
1610
+ /**
1611
+ * Preset pattern values for pattern fill.
1612
+ *
1613
+ * ## XSD Schema
1614
+ * ```xml
1615
+ * <xsd:simpleType name="ST_PresetPatternVal">
1616
+ * <xsd:restriction base="xsd:token">
1617
+ * <xsd:enumeration value="pct5"/> ... <xsd:enumeration value="zigZag"/>
1618
+ * </xsd:restriction>
1619
+ * </xsd:simpleType>
1620
+ * ```
1621
+ *
1622
+ * @publicApi
1623
+ */
1624
+ const PresetPattern = {
1625
+ /** 5% pattern */
1626
+ PCT5: "percent5",
1627
+ /** 10% pattern */
1628
+ PCT10: "percent10",
1629
+ /** 20% pattern */
1630
+ PCT20: "percent20",
1631
+ /** 25% pattern */
1632
+ PCT25: "percent25",
1633
+ /** 30% pattern */
1634
+ PCT30: "percent30",
1635
+ /** 40% pattern */
1636
+ PCT40: "percent40",
1637
+ /** 50% pattern */
1638
+ PCT50: "percent50",
1639
+ /** 60% pattern */
1640
+ PCT60: "percent60",
1641
+ /** 70% pattern */
1642
+ PCT70: "percent70",
1643
+ /** 75% pattern */
1644
+ PCT75: "percent75",
1645
+ /** 80% pattern */
1646
+ PCT80: "percent80",
1647
+ /** 90% pattern */
1648
+ PCT90: "percent90",
1649
+ /** Horizontal lines */
1650
+ HORZ: "horizontal",
1651
+ /** Vertical lines */
1652
+ VERT: "vertical",
1653
+ /** Light horizontal lines */
1654
+ LT_HORZ: "lightHorizontal",
1655
+ /** Light vertical lines */
1656
+ LT_VERT: "lightVertical",
1657
+ /** Dark horizontal lines */
1658
+ DK_HORZ: "darkHorizontal",
1659
+ /** Dark vertical lines */
1660
+ DK_VERT: "darkVertical",
1661
+ /** Narrow horizontal lines */
1662
+ NAR_HORZ: "narrowHorizontal",
1663
+ /** Narrow vertical lines */
1664
+ NAR_VERT: "narrowVertical",
1665
+ /** Dashed horizontal lines */
1666
+ DASH_HORZ: "dashedHorizontal",
1667
+ /** Dashed vertical lines */
1668
+ DASH_VERT: "dashedVertical",
1669
+ /** Cross pattern (+) */
1670
+ CROSS: "cross",
1671
+ /** Downward diagonal lines (\) */
1672
+ DN_DIAG: "downDiagonal",
1673
+ /** Upward diagonal lines (/) */
1674
+ UP_DIAG: "upDiagonal",
1675
+ /** Light downward diagonal lines */
1676
+ LT_DN_DIAG: "lightDownDiagonal",
1677
+ /** Light upward diagonal lines */
1678
+ LT_UP_DIAG: "lightUpDiagonal",
1679
+ /** Dark downward diagonal lines */
1680
+ DK_DN_DIAG: "darkDownDiagonal",
1681
+ /** Dark upward diagonal lines */
1682
+ DK_UP_DIAG: "darkUpDiagonal",
1683
+ /** Wide downward diagonal lines */
1684
+ WD_DN_DIAG: "wideDownDiagonal",
1685
+ /** Wide upward diagonal lines */
1686
+ WD_UP_DIAG: "wideUpDiagonal",
1687
+ /** Dashed downward diagonal lines */
1688
+ DASH_DN_DIAG: "dashedDownDiagonal",
1689
+ /** Dashed upward diagonal lines */
1690
+ DASH_UP_DIAG: "dashedUpDiagonal",
1691
+ /** Diagonal cross pattern (X) */
1692
+ DIAG_CROSS: "diagonalCross",
1693
+ /** Small checkerboard */
1694
+ SM_CHECK: "smallChecker",
1695
+ /** Large checkerboard */
1696
+ LG_CHECK: "largeChecker",
1697
+ /** Small grid */
1698
+ SM_GRID: "smallGrid",
1699
+ /** Large grid */
1700
+ LG_GRID: "largeGrid",
1701
+ /** Dot grid */
1702
+ DOT_GRID: "dotGrid",
1703
+ /** Small confetti */
1704
+ SM_CONFETTI: "smallConfetti",
1705
+ /** Large confetti */
1706
+ LG_CONFETTI: "largeConfetti",
1707
+ /** Horizontal brick pattern */
1708
+ HORZ_BRICK: "horizontalBrick",
1709
+ /** Diagonal brick pattern */
1710
+ DIAG_BRICK: "diagonalBrick",
1711
+ /** Solid diamond */
1712
+ SOLID_DMND: "solidDiamond",
1713
+ /** Open diamond */
1714
+ OPEN_DMND: "openDiamond",
1715
+ /** Dotted diamond */
1716
+ DOT_DMND: "dottedDiamond",
1717
+ /** Plaid pattern */
1718
+ PLAID: "plaid",
1719
+ /** Sphere pattern */
1720
+ SPHERE: "sphere",
1721
+ /** Weave pattern */
1722
+ WEAVE: "weave",
1723
+ /** Divot pattern */
1724
+ DIVOT: "divot",
1725
+ /** Shingle pattern */
1726
+ SHINGLE: "shingle",
1727
+ /** Wave pattern */
1728
+ WAVE: "wave",
1729
+ /** Trellis pattern */
1730
+ TRELLIS: "trellis",
1731
+ /** Zigzag pattern */
1732
+ ZIG_ZAG: "zigZag"
1733
+ };
1734
+ /**
1735
+ * Creates a pattern fill element (a:pattFill).
1736
+ *
1737
+ * Specifies a pattern fill using preset patterns with optional
1738
+ * foreground and background colors.
1739
+ *
1740
+ * ## XSD Schema
1741
+ * ```xml
1742
+ * <xsd:complexType name="CT_PatternFillProperties">
1743
+ * <xsd:sequence>
1744
+ * <xsd:element name="fgClr" type="CT_Color" minOccurs="0"/>
1745
+ * <xsd:element name="bgClr" type="CT_Color" minOccurs="0"/>
1746
+ * </xsd:sequence>
1747
+ * <xsd:attribute name="prst" type="ST_PresetPatternVal" use="optional"/>
1748
+ * </xsd:complexType>
1749
+ * ```
1750
+ *
1751
+ * @example
1752
+ * ```typescript
1753
+ * // Simple crosshatch pattern
1754
+ * createPatternFill({ pattern: PresetPattern.CROSS });
1755
+ * // Pattern with foreground color
1756
+ * createPatternFill({
1757
+ * pattern: PresetPattern.DIAG_CROSS,
1758
+ * foregroundColor: { value: "FF0000" },
1759
+ * });
1760
+ * // Pattern with foreground and background colors
1761
+ * createPatternFill({
1762
+ * pattern: PresetPattern.HORZ,
1763
+ * foregroundColor: { value: "0000FF" },
1764
+ * backgroundColor: { value: "FFFF00" },
1765
+ * });
1766
+ * ```
1767
+ */
1768
+ const createPatternFill = (options) => {
1769
+ const children = [];
1770
+ if (options.foregroundColor) children.push(new BuilderElement({
1771
+ children: [createColorElement(options.foregroundColor)],
1772
+ name: "a:fgClr"
1773
+ }));
1774
+ if (options.backgroundColor) children.push(new BuilderElement({
1775
+ children: [createColorElement(options.backgroundColor)],
1776
+ name: "a:bgClr"
1777
+ }));
1778
+ return new BuilderElement({
1779
+ attributes: { prst: {
1780
+ key: "prst",
1781
+ value: xsdPattern.to(options.pattern)
1782
+ } },
1783
+ children,
1784
+ name: "a:pattFill"
1785
+ });
1786
+ };
1787
+ //#endregion
1788
+ //#region src/drawingml/fill/fill-options.ts
1789
+ function normalizeColor(color) {
1790
+ return typeof color === "string" ? { value: color.replace("#", "") } : color;
1791
+ }
1792
+ function toUint8Array(data) {
1793
+ return data instanceof Uint8Array ? data : new Uint8Array(data);
1794
+ }
1795
+ /**
1796
+ * Extracts media data from a blip fill option, if present.
1797
+ * Returns undefined for non-blip fills.
1798
+ *
1799
+ * The returned data should be registered with the document's media store
1800
+ * during `prepForXml` so the packer can resolve the `{fileName}` placeholder.
1801
+ */
1802
+ const extractBlipFillMedia = (fill) => {
1803
+ if (typeof fill === "string" || fill.type !== "blip") return void 0;
1804
+ const raw = toUint8Array(fill.data);
1805
+ return {
1806
+ data: raw,
1807
+ fileName: `${hashedId(raw)}.${fill.imageType}`,
1808
+ type: fill.imageType
1809
+ };
1810
+ };
1811
+ /**
1812
+ * Builds a DrawingML fill XmlComponent from a FillOptions config.
1813
+ */
1814
+ const buildFill = (options) => {
1815
+ if (typeof options === "string") return createSolidFill({ value: options.replace("#", "") });
1816
+ switch (options.type) {
1817
+ case "solid": return createSolidFill(normalizeColor(options.color));
1818
+ case "none": return new BuilderElement({ name: "a:noFill" });
1819
+ case "gradient":
1820
+ if ("options" in options) return createGradientFill(options.options);
1821
+ return createGradientFill({
1822
+ stops: options.stops.map((stop) => ({
1823
+ position: stop.position * 1e3,
1824
+ color: normalizeColor(stop.color)
1825
+ })),
1826
+ ...!options.path && options.angle !== void 0 && { shade: {
1827
+ angle: options.angle * 6e4,
1828
+ scaled: options.scaled ?? true
1829
+ } },
1830
+ ...options.path && { shade: { path: options.path } }
1831
+ });
1832
+ case "blip": {
1833
+ const fileName = `${hashedId(toUint8Array(options.data))}.${options.imageType}`;
1834
+ const blipChildren = [];
1835
+ if (options.blipEffects) blipChildren.push(...createBlipEffects(options.blipEffects));
1836
+ const children = [new BuilderElement({
1837
+ attributes: {
1838
+ cstate: {
1839
+ key: "cstate",
1840
+ value: "none"
1841
+ },
1842
+ embed: {
1843
+ key: "r:embed",
1844
+ value: `{${fileName}}`
1845
+ }
1846
+ },
1847
+ children: blipChildren,
1848
+ name: "a:blip"
1849
+ }), createSourceRectangle(options.srcRect)];
1850
+ if (options.tile) children.push(createTileInfo(options.tile));
1851
+ else children.push(new Stretch());
1852
+ const attributes = {};
1853
+ if (options.dpi !== void 0) attributes.dpi = {
1854
+ key: "dpi",
1855
+ value: options.dpi
1856
+ };
1857
+ if (options.rotWithShape !== void 0) attributes.rotWithShape = {
1858
+ key: "rotWithShape",
1859
+ value: options.rotWithShape ? 1 : 0
1860
+ };
1861
+ return new BuilderElement({
1862
+ attributes: Object.keys(attributes).length > 0 ? attributes : void 0,
1863
+ children,
1864
+ name: "a:blipFill"
1865
+ });
1866
+ }
1867
+ case "pattern": return createPatternFill({
1868
+ pattern: options.pattern,
1869
+ ...options.foregroundColor && { foregroundColor: normalizeColor(options.foregroundColor) },
1870
+ ...options.backgroundColor && { backgroundColor: normalizeColor(options.backgroundColor) }
1871
+ });
1872
+ case "group": return new BuilderElement({ name: "a:grpFill" });
1873
+ }
1874
+ };
1875
+ //#endregion
1876
+ //#region src/drawingml/fill/no-fill.ts
1877
+ /**
1878
+ * No fill element for DrawingML shapes.
1879
+ *
1880
+ * This module provides the no-fill option for outline and shape fills.
1881
+ *
1882
+ * @module
1883
+ */
1884
+ /**
1885
+ * Creates a no-fill element.
1886
+ *
1887
+ * Specifies that the outline or shape should have no fill applied.
1888
+ *
1889
+ * ## XSD Schema
1890
+ * ```xml
1891
+ * <xsd:element name="noFill" type="CT_Empty"/>
1892
+ * ```
1893
+ *
1894
+ * @example
1895
+ * ```typescript
1896
+ * const noFill = createNoFill();
1897
+ * ```
1898
+ */
1899
+ const createNoFill = () => new BuilderElement({ name: "a:noFill" });
1900
+ //#endregion
1901
+ //#region src/drawingml/fill/group-fill.ts
1902
+ /**
1903
+ * Group fill element for DrawingML shapes.
1904
+ *
1905
+ * This module provides group fill support which inherits the fill
1906
+ * from the parent group shape.
1907
+ *
1908
+ * Reference: ISO/IEC 29500-4, dml-main.xsd, CT_GroupFillProperties
1909
+ *
1910
+ * @module
1911
+ */
1912
+ /**
1913
+ * Creates a group fill element (a:grpFill).
1914
+ *
1915
+ * This element specifies that the shape should inherit its fill
1916
+ * from the parent group shape. This is useful when shapes are
1917
+ * grouped together and should share the same fill.
1918
+ *
1919
+ * ## XSD Schema
1920
+ * ```xml
1921
+ * <xsd:complexType name="CT_GroupFillProperties"/>
1922
+ * ```
1923
+ *
1924
+ * @example
1925
+ * ```typescript
1926
+ * // Shape inherits fill from parent group
1927
+ * createGroupFill();
1928
+ * ```
1929
+ */
1930
+ const createGroupFill = () => new BuilderElement({ name: "a:grpFill" });
1931
+ //#endregion
1932
+ //#region src/drawingml/outline/custom-dash.ts
1933
+ /**
1934
+ * Custom dash pattern for DrawingML outlines.
1935
+ *
1936
+ * This module provides support for custom dash patterns defined by
1937
+ * a list of dash stops, each specifying dash and space lengths as
1938
+ * percentages relative to line width.
1939
+ *
1940
+ * Reference: ISO/IEC 29500-4, dml-main.xsd, CT_DashStopList, CT_DashStop
1941
+ *
1942
+ * @module
1943
+ */
1944
+ /**
1945
+ * Creates a custom dash element (a:custDash) for outlines.
1946
+ *
1947
+ * The custom dash element specifies a repeating pattern of dash and space
1948
+ * segments. Each segment is defined by a `DashStop` with dash (`d`) and
1949
+ * space (`sp`) lengths as positive percentages of the line width.
1950
+ *
1951
+ * ## XSD Schema
1952
+ * ```xml
1953
+ * <xsd:complexType name="CT_DashStopList">
1954
+ * <xsd:sequence>
1955
+ * <xsd:element name="ds" type="CT_DashStop" minOccurs="0" maxOccurs="unbounded"/>
1956
+ * </xsd:sequence>
1957
+ * </xsd:complexType>
1958
+ * ```
1959
+ *
1960
+ * @example
1961
+ * ```typescript
1962
+ * // Simple dash pattern
1963
+ * createCustomDash([
1964
+ * { d: "500%", sp: "200%" },
1965
+ * ]);
1966
+ *
1967
+ * // Complex alternating pattern
1968
+ * createCustomDash([
1969
+ * { d: "500%", sp: "200%" },
1970
+ * { d: "100%", sp: "200%" },
1971
+ * ]);
1972
+ * ```
1973
+ */
1974
+ const createCustomDash = (stops) => {
1975
+ const children = [];
1976
+ for (const stop of stops) children.push(new BuilderElement({
1977
+ attributes: {
1978
+ d: {
1979
+ key: "d",
1980
+ value: stop.d
1981
+ },
1982
+ sp: {
1983
+ key: "sp",
1984
+ value: stop.sp
1985
+ }
1986
+ },
1987
+ name: "a:ds"
1988
+ }));
1989
+ return new BuilderElement({
1990
+ children,
1991
+ name: "a:custDash"
1992
+ });
1993
+ };
1994
+ //#endregion
1995
+ //#region src/drawingml/outline/line-end.ts
1996
+ /**
1997
+ * Line end (arrow) properties for DrawingML outlines.
1998
+ *
1999
+ * This module provides support for line end markers (arrows) on shape outlines.
2000
+ *
2001
+ * Reference: ISO/IEC 29500-4, dml-main.xsd, CT_LineEndProperties
2002
+ *
2003
+ * @module
2004
+ */
2005
+ /**
2006
+ * Line end types (arrow head styles).
2007
+ *
2008
+ * ## XSD Schema
2009
+ * ```xml
2010
+ * <xsd:simpleType name="ST_LineEndType">
2011
+ * <xsd:restriction base="xsd:token">
2012
+ * <xsd:enumeration value="none"/>
2013
+ * <xsd:enumeration value="triangle"/>
2014
+ * <xsd:enumeration value="stealth"/>
2015
+ * <xsd:enumeration value="diamond"/>
2016
+ * <xsd:enumeration value="oval"/>
2017
+ * <xsd:enumeration value="arrow"/>
2018
+ * </xsd:restriction>
2019
+ * </xsd:simpleType>
2020
+ * ```
2021
+ *
2022
+ * @publicApi
2023
+ */
2024
+ const LineEndType = {
2025
+ /** No line end */
2026
+ NONE: "none",
2027
+ /** Triangle arrow */
2028
+ TRIANGLE: "triangle",
2029
+ /** Stealth arrow (filled triangle) */
2030
+ STEALTH: "stealth",
2031
+ /** Diamond shape */
2032
+ DIAMOND: "diamond",
2033
+ /** Oval shape */
2034
+ OVAL: "oval",
2035
+ /** Simple arrow */
2036
+ ARROW: "arrow"
2037
+ };
2038
+ /**
2039
+ * Line end width options.
2040
+ *
2041
+ * ## XSD Schema
2042
+ * ```xml
2043
+ * <xsd:simpleType name="ST_LineEndWidth">
2044
+ * <xsd:restriction base="xsd:token">
2045
+ * <xsd:enumeration value="sm"/>
2046
+ * <xsd:enumeration value="med"/>
2047
+ * <xsd:enumeration value="lg"/>
2048
+ * </xsd:restriction>
2049
+ * </xsd:simpleType>
2050
+ * ```
2051
+ *
2052
+ * @publicApi
2053
+ */
2054
+ const LineEndWidth = {
2055
+ /** Small width */
2056
+ SMALL: "small",
2057
+ /** Medium width */
2058
+ MEDIUM: "medium",
2059
+ /** Large width */
2060
+ LARGE: "large"
2061
+ };
2062
+ /**
2063
+ * Line end length options.
2064
+ *
2065
+ * ## XSD Schema
2066
+ * ```xml
2067
+ * <xsd:simpleType name="ST_LineEndLength">
2068
+ * <xsd:restriction base="xsd:token">
2069
+ * <xsd:enumeration value="sm"/>
2070
+ * <xsd:enumeration value="med"/>
2071
+ * <xsd:enumeration value="lg"/>
2072
+ * </xsd:restriction>
2073
+ * </xsd:simpleType>
2074
+ * ```
2075
+ *
2076
+ * @publicApi
2077
+ */
2078
+ const LineEndLength = {
2079
+ /** Small length */
2080
+ SMALL: "small",
2081
+ /** Medium length */
2082
+ MEDIUM: "medium",
2083
+ /** Large length */
2084
+ LARGE: "large"
2085
+ };
2086
+ /**
2087
+ * Creates a line end element (a:headEnd or a:tailEnd).
2088
+ *
2089
+ * @example
2090
+ * ```typescript
2091
+ * // Stealth arrow at start, medium size
2092
+ * createLineEnd("a:headEnd", { type: "STEALTH", width: "MEDIUM", length: "MEDIUM" });
2093
+ * // Triangle arrow at end
2094
+ * createLineEnd("a:tailEnd", { type: "TRIANGLE" });
2095
+ * ```
2096
+ */
2097
+ const createLineEnd = (name, options) => new BuilderElement({
2098
+ attributes: {
2099
+ type: {
2100
+ key: "type",
2101
+ value: options.type
2102
+ },
2103
+ w: {
2104
+ key: "w",
2105
+ value: options.width ? xsdLineEndSize.to(options.width) : void 0
2106
+ },
2107
+ len: {
2108
+ key: "len",
2109
+ value: options.length ? xsdLineEndSize.to(options.length) : void 0
2110
+ }
2111
+ },
2112
+ name
2113
+ });
2114
+ //#endregion
2115
+ //#region src/drawingml/outline/outline.ts
2116
+ /**
2117
+ * Outline (line) properties for DrawingML shapes.
2118
+ *
2119
+ * This module provides support for configuring outline properties including
2120
+ * width, cap style, compound line types, fill properties, dash, and join.
2121
+ *
2122
+ * Reference: ISO/IEC 29500-4, dml-main.xsd, CT_LineProperties
2123
+ *
2124
+ * @module
2125
+ */
2126
+ /**
2127
+ * Line cap styles for outline endpoints.
2128
+ *
2129
+ * Defines how the ends of a line are rendered.
2130
+ */
2131
+ const LineCap = {
2132
+ /** Round cap style */
2133
+ ROUND: "round",
2134
+ /** Square cap style */
2135
+ SQUARE: "square",
2136
+ /** Flat cap style */
2137
+ FLAT: "flat"
2138
+ };
2139
+ /**
2140
+ * Compound line types for outlines.
2141
+ *
2142
+ * Defines the structure of compound lines (single, double, etc.).
2143
+ */
2144
+ const CompoundLine = {
2145
+ /** Single line */
2146
+ SINGLE: "single",
2147
+ /** Double line */
2148
+ DOUBLE: "double",
2149
+ /** Thick-thin double line */
2150
+ THICK_THIN: "thickThin",
2151
+ /** Thin-thick double line */
2152
+ THIN_THICK: "thinThick",
2153
+ /** Triple line */
2154
+ TRI: "triple"
2155
+ };
2156
+ /**
2157
+ * Pen alignment options for outline positioning.
2158
+ *
2159
+ * Defines how the outline is aligned relative to the shape edge.
2160
+ */
2161
+ const PenAlignment = {
2162
+ /** Center alignment */
2163
+ CENTER: "center",
2164
+ /** Inset alignment */
2165
+ INSET: "inside"
2166
+ };
2167
+ /**
2168
+ * Preset dash styles for outlines.
2169
+ *
2170
+ * ## XSD Schema
2171
+ * ```xml
2172
+ * <xsd:simpleType name="ST_PresetLineDashVal">
2173
+ * <xsd:restriction base="xsd:token">
2174
+ * <xsd:enumeration value="solid"/>
2175
+ * <xsd:enumeration value="dot"/>
2176
+ * <xsd:enumeration value="dash"/>
2177
+ * <xsd:enumeration value="lgDash"/>
2178
+ * <xsd:enumeration value="dashDot"/>
2179
+ * <xsd:enumeration value="lgDashDot"/>
2180
+ * <xsd:enumeration value="lgDashDotDot"/>
2181
+ * <xsd:enumeration value="sysDash"/>
2182
+ * <xsd:enumeration value="sysDot"/>
2183
+ * <xsd:enumeration value="sysDashDot"/>
2184
+ * <xsd:enumeration value="sysDashDotDot"/>
2185
+ * </xsd:restriction>
2186
+ * </xsd:simpleType>
2187
+ * ```
2188
+ */
2189
+ const PresetDash = {
2190
+ SOLID: "solid",
2191
+ DOT: "dot",
2192
+ DASH: "dash",
2193
+ LG_DASH: "lgDash",
2194
+ DASH_DOT: "dashDot",
2195
+ LG_DASH_DOT: "lgDashDot",
2196
+ LG_DASH_DOT_DOT: "lgDashDotDot",
2197
+ SYS_DASH: "sysDash",
2198
+ SYS_DOT: "sysDot",
2199
+ SYS_DASH_DOT: "sysDashDot",
2200
+ SYS_DASH_DOT_DOT: "sysDashDotDot"
2201
+ };
2202
+ /**
2203
+ * Line join styles.
2204
+ */
2205
+ const LineJoin = {
2206
+ ROUND: "round",
2207
+ BEVEL: "bevel",
2208
+ MITER: "miter"
2209
+ };
2210
+ /**
2211
+ * Creates the fill child element for an outline.
2212
+ *
2213
+ * Returns null when no fill type is specified (OOXML allows outline without fill).
2214
+ */
2215
+ const createOutlineFill = (options) => {
2216
+ if (options.type === "noFill") return createNoFill();
2217
+ if (options.type === "solidFill" && options.color) return createSolidFill(options.color);
2218
+ if (options.type === "gradFill" && options.gradientFill) return createGradientFill(options.gradientFill);
2219
+ if (options.type === "pattFill" && options.patternFill) return createPatternFill(options.patternFill);
2220
+ return null;
2221
+ };
2222
+ /**
2223
+ * Creates an outline element for DrawingML shapes.
2224
+ *
2225
+ * The outline element specifies the line properties for the shape border,
2226
+ * including width, cap style, compound line type, alignment, dash, join, and fill.
2227
+ *
2228
+ * ## XSD Schema
2229
+ * ```xml
2230
+ * <xsd:complexType name="CT_LineProperties">
2231
+ * <xsd:sequence>
2232
+ * <xsd:group ref="EG_FillProperties" minOccurs="0"/>
2233
+ * <xsd:group ref="EG_LineDashProperties" minOccurs="0"/>
2234
+ * <xsd:group ref="EG_LineJoinProperties" minOccurs="0"/>
2235
+ * </xsd:sequence>
2236
+ * <xsd:attribute name="w" use="optional" type="a:ST_LineWidth"/>
2237
+ * <xsd:attribute name="cap" use="optional" type="ST_LineCap"/>
2238
+ * <xsd:attribute name="cmpd" use="optional" type="ST_CompoundLine"/>
2239
+ * <xsd:attribute name="algn" use="optional" type="ST_PenAlignment"/>
2240
+ * </xsd:complexType>
2241
+ * ```
2242
+ *
2243
+ * @example
2244
+ * ```typescript
2245
+ * // Outline with RGB color and dash
2246
+ * const outline = createOutline({
2247
+ * width: 9525,
2248
+ * type: "solidFill",
2249
+ * color: { value: "FF0000" },
2250
+ * dash: "DASH",
2251
+ * });
2252
+ * ```
2253
+ */
2254
+ const createOutline = (options) => {
2255
+ const children = [];
2256
+ const fill = createOutlineFill(options);
2257
+ if (fill) children.push(fill);
2258
+ if (options.customDash !== void 0) children.push(createCustomDash(options.customDash));
2259
+ else if (options.dash !== void 0) children.push(new BuilderElement({
2260
+ attributes: { val: {
2261
+ key: "val",
2262
+ value: options.dash
2263
+ } },
2264
+ name: "a:prstDash"
2265
+ }));
2266
+ if (options.join !== void 0) if (options.join === "miter" && options.miterLimit !== void 0) children.push(new BuilderElement({
2267
+ attributes: { lim: {
2268
+ key: "lim",
2269
+ value: options.miterLimit
2270
+ } },
2271
+ name: "a:miter"
2272
+ }));
2273
+ else children.push(new BuilderElement({ name: `a:${options.join}` }));
2274
+ if (options.headEnd) children.push(createLineEnd("a:headEnd", options.headEnd));
2275
+ if (options.tailEnd) children.push(createLineEnd("a:tailEnd", options.tailEnd));
2276
+ return new BuilderElement({
2277
+ attributes: {
2278
+ align: {
2279
+ key: "algn",
2280
+ value: options.align ? xsdPenAlignment.to(options.align) : void 0
2281
+ },
2282
+ cap: {
2283
+ key: "cap",
2284
+ value: options.cap ? xsdLineCap.to(options.cap) : void 0
2285
+ },
2286
+ compoundLine: {
2287
+ key: "cmpd",
2288
+ value: options.compoundLine ? xsdCompoundLine.to(options.compoundLine) : void 0
2289
+ },
2290
+ width: {
2291
+ key: "w",
2292
+ value: options.width
2293
+ }
2294
+ },
2295
+ children,
2296
+ name: "a:ln"
2297
+ });
2298
+ };
2299
+ //#endregion
2300
+ //#region src/drawingml/effects/fill-overlay.ts
2301
+ /**
2302
+ * Fill overlay effect for DrawingML shapes.
2303
+ *
2304
+ * Reference: ISO/IEC 29500-4, dml-main.xsd, CT_FillOverlayEffect
2305
+ *
2306
+ * @module
2307
+ */
2308
+ /**
2309
+ * Blend modes for fill overlay effect.
2310
+ *
2311
+ * ## XSD Schema
2312
+ * ```xml
2313
+ * <xsd:simpleType name="ST_BlendMode">
2314
+ * <xsd:restriction base="xsd:token">
2315
+ * <xsd:enumeration value="over"/>
2316
+ * <xsd:enumeration value="mult"/>
2317
+ * <xsd:enumeration value="screen"/>
2318
+ * <xsd:enumeration value="darken"/>
2319
+ * <xsd:enumeration value="lighten"/>
2320
+ * </xsd:restriction>
2321
+ * </xsd:simpleType>
2322
+ * ```
2323
+ */
2324
+ const BlendMode = {
2325
+ /** Over blend mode */
2326
+ OVER: "over",
2327
+ /** Multiply blend mode */
2328
+ MULTIPLY: "multiply",
2329
+ /** Screen blend mode */
2330
+ SCREEN: "screen",
2331
+ /** Darken blend mode */
2332
+ DARKEN: "darken",
2333
+ /** Lighten blend mode */
2334
+ LIGHTEN: "lighten"
2335
+ };
2336
+ /**
2337
+ * Creates a fill overlay effect element.
2338
+ *
2339
+ * ## XSD Schema
2340
+ * ```xml
2341
+ * <xsd:complexType name="CT_FillOverlayEffect">
2342
+ * <xsd:sequence>
2343
+ * <xsd:group ref="EG_FillProperties" minOccurs="1" maxOccurs="1"/>
2344
+ * </xsd:sequence>
2345
+ * <xsd:attribute name="blend" type="ST_BlendMode" use="required"/>
2346
+ * </xsd:complexType>
2347
+ * ```
2348
+ *
2349
+ * @example
2350
+ * ```typescript
2351
+ * // Solid fill overlay
2352
+ * const fillOverlay = createFillOverlayEffect({
2353
+ * blend: BlendMode.MULTIPLY,
2354
+ * solidFill: { value: "FF0000" },
2355
+ * });
2356
+ *
2357
+ * // Gradient fill overlay
2358
+ * const fillOverlay = createFillOverlayEffect({
2359
+ * blend: BlendMode.SCREEN,
2360
+ * gradientFill: { type: "linear", stops: [...] },
2361
+ * });
2362
+ * ```
2363
+ */
2364
+ const createFillOverlayEffect = (options) => {
2365
+ let fillElement;
2366
+ if (options.noFill) fillElement = createNoFill();
2367
+ else if (options.solidFill) fillElement = createSolidFill(options.solidFill);
2368
+ else if (options.gradientFill) fillElement = createGradientFill(options.gradientFill);
2369
+ else if (options.patternFill) fillElement = createPatternFill(options.patternFill);
2370
+ else if (options.groupFill) fillElement = createGroupFill();
2371
+ else fillElement = createSolidFill({ value: "000000" });
2372
+ return new BuilderElement({
2373
+ attributes: { blend: {
2374
+ key: "blend",
2375
+ value: xsdBlendMode.to(options.blend)
2376
+ } },
2377
+ children: [fillElement],
2378
+ name: "a:fillOverlay"
2379
+ });
2380
+ };
2381
+ //#endregion
2382
+ //#region src/drawingml/effects/glow.ts
2383
+ /**
2384
+ * Glow effect for DrawingML shapes.
2385
+ *
2386
+ * Reference: ISO/IEC 29500-4, dml-main.xsd, CT_GlowEffect
2387
+ *
2388
+ * @module
2389
+ */
2390
+ /**
2391
+ * Creates a glow effect element.
2392
+ *
2393
+ * ## XSD Schema
2394
+ * ```xml
2395
+ * <xsd:complexType name="CT_GlowEffect">
2396
+ * <xsd:sequence>
2397
+ * <xsd:group ref="EG_ColorChoice" minOccurs="1" maxOccurs="1"/>
2398
+ * </xsd:sequence>
2399
+ * <xsd:attribute name="rad" type="ST_PositiveCoordinate" use="optional" default="0"/>
2400
+ * </xsd:complexType>
2401
+ * ```
2402
+ */
2403
+ const createGlowEffect = (options) => {
2404
+ if (options.radius === void 0) return new BuilderElement({
2405
+ children: [createColorElement(options.color)],
2406
+ name: "a:glow"
2407
+ });
2408
+ return new BuilderElement({
2409
+ attributes: { rad: {
2410
+ key: "rad",
2411
+ value: options.radius
2412
+ } },
2413
+ children: [createColorElement(options.color)],
2414
+ name: "a:glow"
2415
+ });
2416
+ };
2417
+ //#endregion
2418
+ //#region src/drawingml/effects/inner-shadow.ts
2419
+ /**
2420
+ * Inner shadow effect for DrawingML shapes.
2421
+ *
2422
+ * Reference: ISO/IEC 29500-4, dml-main.xsd, CT_InnerShadowEffect
2423
+ *
2424
+ * @module
2425
+ */
2426
+ /**
2427
+ * Creates an inner shadow effect element.
2428
+ *
2429
+ * ## XSD Schema
2430
+ * ```xml
2431
+ * <xsd:complexType name="CT_InnerShadowEffect">
2432
+ * <xsd:sequence>
2433
+ * <xsd:group ref="EG_ColorChoice" minOccurs="1" maxOccurs="1"/>
2434
+ * </xsd:sequence>
2435
+ * <xsd:attribute name="blurRad" type="ST_PositiveCoordinate" default="0"/>
2436
+ * <xsd:attribute name="dist" type="ST_PositiveCoordinate" default="0"/>
2437
+ * <xsd:attribute name="dir" type="ST_PositiveFixedAngle" default="0"/>
2438
+ * </xsd:complexType>
2439
+ * ```
2440
+ */
2441
+ const createInnerShadowEffect = (options) => {
2442
+ if (!(options.blurRadius !== void 0 || options.distance !== void 0 || options.direction !== void 0)) return new BuilderElement({
2443
+ children: [createColorElement(options.color)],
2444
+ name: "a:innerShdw"
2445
+ });
2446
+ return new BuilderElement({
2447
+ attributes: {
2448
+ ...options.blurRadius !== void 0 && { blurRad: {
2449
+ key: "blurRad",
2450
+ value: options.blurRadius
2451
+ } },
2452
+ ...options.distance !== void 0 && { dist: {
2453
+ key: "dist",
2454
+ value: options.distance
2455
+ } },
2456
+ ...options.direction !== void 0 && { dir: {
2457
+ key: "dir",
2458
+ value: options.direction
2459
+ } }
2460
+ },
2461
+ children: [createColorElement(options.color)],
2462
+ name: "a:innerShdw"
2463
+ });
2464
+ };
2465
+ //#endregion
2466
+ //#region src/drawingml/effects/outer-shadow.ts
2467
+ /**
2468
+ * Outer shadow effect for DrawingML shapes.
2469
+ *
2470
+ * Reference: ISO/IEC 29500-4, dml-main.xsd, CT_OuterShadowEffect
2471
+ *
2472
+ * @module
2473
+ */
2474
+ /**
2475
+ * Rectangle alignment for shadow positioning.
2476
+ */
2477
+ const RectAlignment = {
2478
+ TOP_LEFT: "topLeft",
2479
+ TOP: "top",
2480
+ TOP_RIGHT: "topRight",
2481
+ LEFT: "left",
2482
+ CENTER: "center",
2483
+ RIGHT: "right",
2484
+ BOTTOM_LEFT: "bottomLeft",
2485
+ BOTTOM: "bottom",
2486
+ BOTTOM_RIGHT: "bottomRight"
2487
+ };
2488
+ /**
2489
+ * Creates an outer shadow effect element.
2490
+ *
2491
+ * ## XSD Schema
2492
+ * ```xml
2493
+ * <xsd:complexType name="CT_OuterShadowEffect">
2494
+ * <xsd:sequence>
2495
+ * <xsd:group ref="EG_ColorChoice" minOccurs="1" maxOccurs="1"/>
2496
+ * </xsd:sequence>
2497
+ * <xsd:attribute name="blurRad" type="ST_PositiveCoordinate" default="0"/>
2498
+ * <xsd:attribute name="dist" type="ST_PositiveCoordinate" default="0"/>
2499
+ * <xsd:attribute name="dir" type="ST_PositiveFixedAngle" default="0"/>
2500
+ * <xsd:attribute name="sx" type="ST_Percentage" default="100%"/>
2501
+ * <xsd:attribute name="sy" type="ST_Percentage" default="100%"/>
2502
+ * <xsd:attribute name="kx" type="ST_FixedAngle" default="0"/>
2503
+ * <xsd:attribute name="ky" type="ST_FixedAngle" default="0"/>
2504
+ * <xsd:attribute name="algn" type="ST_RectAlignment" default="b"/>
2505
+ * <xsd:attribute name="rotWithShape" type="xsd:boolean" default="true"/>
2506
+ * </xsd:complexType>
2507
+ * ```
2508
+ */
2509
+ const createOuterShadowEffect = (options) => {
2510
+ const attributes = {};
2511
+ if (options.blurRadius !== void 0) attributes.blurRad = {
2512
+ key: "blurRad",
2513
+ value: options.blurRadius
2514
+ };
2515
+ if (options.distance !== void 0) attributes.dist = {
2516
+ key: "dist",
2517
+ value: options.distance
2518
+ };
2519
+ if (options.direction !== void 0) attributes.dir = {
2520
+ key: "dir",
2521
+ value: options.direction
2522
+ };
2523
+ if (options.scaleX !== void 0) attributes.sx = {
2524
+ key: "sx",
2525
+ value: options.scaleX
2526
+ };
2527
+ if (options.scaleY !== void 0) attributes.sy = {
2528
+ key: "sy",
2529
+ value: options.scaleY
2530
+ };
2531
+ if (options.skewX !== void 0) attributes.kx = {
2532
+ key: "kx",
2533
+ value: options.skewX
2534
+ };
2535
+ if (options.skewY !== void 0) attributes.ky = {
2536
+ key: "ky",
2537
+ value: options.skewY
2538
+ };
2539
+ if (options.alignment !== void 0) attributes.algn = {
2540
+ key: "algn",
2541
+ value: xsdRectAlignment.to(options.alignment)
2542
+ };
2543
+ if (options.rotWithShape === false) attributes.rotWithShape = {
2544
+ key: "rotWithShape",
2545
+ value: 0
2546
+ };
2547
+ return new BuilderElement({
2548
+ attributes,
2549
+ children: [createColorElement(options.color)],
2550
+ name: "a:outerShdw"
2551
+ });
2552
+ };
2553
+ //#endregion
2554
+ //#region src/drawingml/effects/preset-shadow.ts
2555
+ /**
2556
+ * Preset shadow effect for DrawingML shapes.
2557
+ *
2558
+ * Reference: ISO/IEC 29500-4, dml-main.xsd, CT_PresetShadowEffect
2559
+ *
2560
+ * @module
2561
+ */
2562
+ /**
2563
+ * Preset shadow types (20 variations).
2564
+ *
2565
+ * Reference: ISO/IEC 29500-4, dml-main.xsd, ST_PresetShadowVal
2566
+ */
2567
+ const PresetShadowVal = {
2568
+ SHDW1: "shadow1",
2569
+ SHDW2: "shadow2",
2570
+ SHDW3: "shadow3",
2571
+ SHDW4: "shadow4",
2572
+ SHDW5: "shadow5",
2573
+ SHDW6: "shadow6",
2574
+ SHDW7: "shadow7",
2575
+ SHDW8: "shadow8",
2576
+ SHDW9: "shadow9",
2577
+ SHDW10: "shadow10",
2578
+ SHDW11: "shadow11",
2579
+ SHDW12: "shadow12",
2580
+ SHDW13: "shadow13",
2581
+ SHDW14: "shadow14",
2582
+ SHDW15: "shadow15",
2583
+ SHDW16: "shadow16",
2584
+ SHDW17: "shadow17",
2585
+ SHDW18: "shadow18",
2586
+ SHDW19: "shadow19",
2587
+ SHDW20: "shadow20"
2588
+ };
2589
+ /**
2590
+ * Creates a preset shadow effect element.
2591
+ *
2592
+ * ## XSD Schema
2593
+ * ```xml
2594
+ * <xsd:complexType name="CT_PresetShadowEffect">
2595
+ * <xsd:sequence>
2596
+ * <xsd:group ref="EG_ColorChoice" minOccurs="1" maxOccurs="1"/>
2597
+ * </xsd:sequence>
2598
+ * <xsd:attribute name="prst" type="ST_PresetShadowVal" use="required"/>
2599
+ * <xsd:attribute name="dist" type="ST_PositiveCoordinate" default="0"/>
2600
+ * <xsd:attribute name="dir" type="ST_PositiveFixedAngle" default="0"/>
2601
+ * </xsd:complexType>
2602
+ * ```
2603
+ */
2604
+ const createPresetShadowEffect = (options) => {
2605
+ const attributes = { prst: {
2606
+ key: "prst",
2607
+ value: xsdPresetShadow.to(options.preset)
2608
+ } };
2609
+ if (options.distance !== void 0) attributes.dist = {
2610
+ key: "dist",
2611
+ value: options.distance
2612
+ };
2613
+ if (options.direction !== void 0) attributes.dir = {
2614
+ key: "dir",
2615
+ value: options.direction
2616
+ };
2617
+ return new BuilderElement({
2618
+ attributes,
2619
+ children: [createColorElement(options.color)],
2620
+ name: "a:prstShdw"
2621
+ });
2622
+ };
2623
+ //#endregion
2624
+ //#region src/drawingml/effects/reflection.ts
2625
+ /**
2626
+ * Reflection effect for DrawingML shapes.
2627
+ *
2628
+ * Reference: ISO/IEC 29500-4, dml-main.xsd, CT_ReflectionEffect
2629
+ *
2630
+ * @module
2631
+ */
2632
+ /**
2633
+ * Creates a reflection effect element.
2634
+ *
2635
+ * ## XSD Schema
2636
+ * ```xml
2637
+ * <xsd:complexType name="CT_ReflectionEffect">
2638
+ * <xsd:attribute name="blurRad" type="ST_PositiveCoordinate" default="0"/>
2639
+ * <xsd:attribute name="stA" type="ST_PositiveFixedPercentage" default="100%"/>
2640
+ * <xsd:attribute name="stPos" type="ST_PositiveFixedPercentage" default="0%"/>
2641
+ * <xsd:attribute name="endA" type="ST_PositiveFixedPercentage" default="0%"/>
2642
+ * <xsd:attribute name="endPos" type="ST_PositiveFixedPercentage" default="100%"/>
2643
+ * <xsd:attribute name="dist" type="ST_PositiveCoordinate" default="0"/>
2644
+ * <xsd:attribute name="dir" type="ST_PositiveFixedAngle" default="0"/>
2645
+ * <xsd:attribute name="fadeDir" type="ST_PositiveFixedAngle" default="5400000"/>
2646
+ * <xsd:attribute name="sx" type="ST_Percentage" default="100%"/>
2647
+ * <xsd:attribute name="sy" type="ST_Percentage" default="100%"/>
2648
+ * <xsd:attribute name="kx" type="ST_FixedAngle" default="0"/>
2649
+ * <xsd:attribute name="ky" type="ST_FixedAngle" default="0"/>
2650
+ * <xsd:attribute name="algn" type="ST_RectAlignment" default="b"/>
2651
+ * <xsd:attribute name="rotWithShape" type="xsd:boolean" default="true"/>
2652
+ * </xsd:complexType>
2653
+ * ```
2654
+ */
2655
+ const createReflectionEffect = (options) => {
2656
+ if (!options) return new BuilderElement({ name: "a:reflection" });
2657
+ const attributes = {};
2658
+ if (options.blurRadius !== void 0) attributes.blurRad = {
2659
+ key: "blurRad",
2660
+ value: options.blurRadius
2661
+ };
2662
+ if (options.startAlpha !== void 0) attributes.stA = {
2663
+ key: "stA",
2664
+ value: options.startAlpha
2665
+ };
2666
+ if (options.startPosition !== void 0) attributes.stPos = {
2667
+ key: "stPos",
2668
+ value: options.startPosition
2669
+ };
2670
+ if (options.endAlpha !== void 0) attributes.endA = {
2671
+ key: "endA",
2672
+ value: options.endAlpha
2673
+ };
2674
+ if (options.endPosition !== void 0) attributes.endPos = {
2675
+ key: "endPos",
2676
+ value: options.endPosition
2677
+ };
2678
+ if (options.distance !== void 0) attributes.dist = {
2679
+ key: "dist",
2680
+ value: options.distance
2681
+ };
2682
+ if (options.direction !== void 0) attributes.dir = {
2683
+ key: "dir",
2684
+ value: options.direction
2685
+ };
2686
+ if (options.fadeDirection !== void 0) attributes.fadeDir = {
2687
+ key: "fadeDir",
2688
+ value: options.fadeDirection
2689
+ };
2690
+ if (options.scaleX !== void 0) attributes.sx = {
2691
+ key: "sx",
2692
+ value: options.scaleX
2693
+ };
2694
+ if (options.scaleY !== void 0) attributes.sy = {
2695
+ key: "sy",
2696
+ value: options.scaleY
2697
+ };
2698
+ if (options.skewX !== void 0) attributes.kx = {
2699
+ key: "kx",
2700
+ value: options.skewX
2701
+ };
2702
+ if (options.skewY !== void 0) attributes.ky = {
2703
+ key: "ky",
2704
+ value: options.skewY
2705
+ };
2706
+ if (options.alignment !== void 0) attributes.algn = {
2707
+ key: "algn",
2708
+ value: xsdRectAlignment.to(options.alignment)
2709
+ };
2710
+ if (options.rotWithShape === false) attributes.rotWithShape = {
2711
+ key: "rotWithShape",
2712
+ value: 0
2713
+ };
2714
+ return new BuilderElement({
2715
+ attributes,
2716
+ name: "a:reflection"
2717
+ });
2718
+ };
2719
+ //#endregion
2720
+ //#region src/drawingml/effects/soft-edge.ts
2721
+ /**
2722
+ * Soft edge effect for DrawingML shapes.
2723
+ *
2724
+ * Reference: ISO/IEC 29500-4, dml-main.xsd, CT_SoftEdgesEffect
2725
+ *
2726
+ * @module
2727
+ */
2728
+ /**
2729
+ * Creates a soft edge effect element.
2730
+ *
2731
+ * ## XSD Schema
2732
+ * ```xml
2733
+ * <xsd:complexType name="CT_SoftEdgesEffect">
2734
+ * <xsd:attribute name="rad" type="ST_PositiveCoordinate" use="required"/>
2735
+ * </xsd:complexType>
2736
+ * ```
2737
+ *
2738
+ * @param rad - Soft edge radius in EMUs (required)
2739
+ */
2740
+ const createSoftEdgeEffect = (rad) => new BuilderElement({
2741
+ attributes: { rad: {
2742
+ key: "rad",
2743
+ value: rad
2744
+ } },
2745
+ name: "a:softEdge"
2746
+ });
2747
+ //#endregion
2748
+ //#region src/drawingml/effects/effect-list.ts
2749
+ /**
2750
+ * Effect list container for DrawingML shapes.
2751
+ *
2752
+ * Reference: ISO/IEC 29500-4, dml-main.xsd, CT_EffectList, EG_EffectProperties
2753
+ *
2754
+ * @module
2755
+ */
2756
+ /**
2757
+ * Creates a blur effect element.
2758
+ *
2759
+ * ## XSD Schema
2760
+ * ```xml
2761
+ * <xsd:complexType name="CT_BlurEffect">
2762
+ * <xsd:attribute name="rad" type="ST_PositiveCoordinate" default="0"/>
2763
+ * <xsd:attribute name="grow" type="xsd:boolean" default="true"/>
2764
+ * </xsd:complexType>
2765
+ * ```
2766
+ */
2767
+ const createBlurEffect$1 = (options) => {
2768
+ if (!(options.radius !== void 0 || options.grow === false)) return new BuilderElement({ name: "a:blur" });
2769
+ return new BuilderElement({
2770
+ attributes: {
2771
+ ...options.radius !== void 0 && { rad: {
2772
+ key: "rad",
2773
+ value: options.radius
2774
+ } },
2775
+ ...options.grow === false && { grow: {
2776
+ key: "grow",
2777
+ value: 0
2778
+ } }
2779
+ },
2780
+ name: "a:blur"
2781
+ });
2782
+ };
2783
+ /**
2784
+ * Creates an effect list element (a:effectLst).
2785
+ *
2786
+ * This is the EG_EffectProperties choice for a flat list of effects.
2787
+ * Effects are emitted in XSD order: blur, glow, innerShdw, outerShdw, prstShdw, reflection, softEdge.
2788
+ *
2789
+ * ## XSD Schema
2790
+ * ```xml
2791
+ * <xsd:complexType name="CT_EffectList">
2792
+ * <xsd:sequence>
2793
+ * <xsd:element name="blur" type="CT_BlurEffect" minOccurs="0"/>
2794
+ * <xsd:element name="fillOverlay" type="CT_FillOverlayEffect" minOccurs="0"/>
2795
+ * <xsd:element name="glow" type="CT_GlowEffect" minOccurs="0"/>
2796
+ * <xsd:element name="innerShdw" type="CT_InnerShadowEffect" minOccurs="0"/>
2797
+ * <xsd:element name="outerShdw" type="CT_OuterShadowEffect" minOccurs="0"/>
2798
+ * <xsd:element name="prstShdw" type="CT_PresetShadowEffect" minOccurs="0"/>
2799
+ * <xsd:element name="reflection" type="CT_ReflectionEffect" minOccurs="0"/>
2800
+ * <xsd:element name="softEdge" type="CT_SoftEdgesEffect" minOccurs="0"/>
2801
+ * </xsd:sequence>
2802
+ * </xsd:complexType>
2803
+ * ```
2804
+ */
2805
+ const createEffectList = (options) => {
2806
+ const children = [];
2807
+ if (options.blur) children.push(createBlurEffect$1(options.blur));
2808
+ if (options.fillOverlay) children.push(createFillOverlayEffect(options.fillOverlay));
2809
+ if (options.glow) children.push(createGlowEffect(options.glow));
2810
+ if (options.innerShadow) children.push(createInnerShadowEffect(options.innerShadow));
2811
+ if (options.outerShadow) children.push(createOuterShadowEffect(options.outerShadow));
2812
+ if (options.presetShadow) children.push(createPresetShadowEffect(options.presetShadow));
2813
+ if (options.reflection) children.push(createReflectionEffect(options.reflection === true ? void 0 : options.reflection));
2814
+ if (options.softEdge !== void 0) children.push(createSoftEdgeEffect(options.softEdge));
2815
+ return new BuilderElement({
2816
+ children,
2817
+ name: "a:effectLst"
2818
+ });
2819
+ };
2820
+ //#endregion
2821
+ //#region src/drawingml/effects/effect-dag.ts
2822
+ /**
2823
+ * Effect container (effectDag) for DrawingML shapes.
2824
+ *
2825
+ * Provides CT_EffectContainer — a directed acyclic graph (DAG) of effects
2826
+ * supporting 28 effect types including alpha/color operations, nested containers,
2827
+ * and all effects from CT_EffectList.
2828
+ *
2829
+ * Reference: ISO/IEC 29500-4, dml-main.xsd, CT_EffectContainer, EG_Effect
2830
+ *
2831
+ * @module
2832
+ */
2833
+ const buildOptionalAttributes = (options) => {
2834
+ const attrs = {};
2835
+ for (const [key, value] of Object.entries(options)) if (value !== void 0) attrs[key] = {
2836
+ key,
2837
+ value
2838
+ };
2839
+ return Object.keys(attrs).length > 0 ? attrs : void 0;
2840
+ };
2841
+ const createAlphaBiLevelEffect = (options) => new BuilderElement({
2842
+ name: "a:alphaBiLevel",
2843
+ attributes: { thresh: {
2844
+ key: "thresh",
2845
+ value: options.threshold
2846
+ } }
2847
+ });
2848
+ const createAlphaCeilingEffect = () => new BuilderElement({ name: "a:alphaCeiling" });
2849
+ const createAlphaFloorEffect = () => new BuilderElement({ name: "a:alphaFloor" });
2850
+ const createAlphaInverseEffect = (options) => new BuilderElement({
2851
+ name: "a:alphaInv",
2852
+ children: options?.color ? [createColorElement(options.color)] : void 0
2853
+ });
2854
+ const createAlphaModulateFixedEffect = (options) => {
2855
+ if (options?.amount === void 0) return new BuilderElement({ name: "a:alphaModFix" });
2856
+ return new BuilderElement({
2857
+ name: "a:alphaModFix",
2858
+ attributes: { amt: {
2859
+ key: "amt",
2860
+ value: options.amount
2861
+ } }
2862
+ });
2863
+ };
2864
+ const createAlphaOutsetEffect = (options) => {
2865
+ if (options?.radius === void 0) return new BuilderElement({ name: "a:alphaOutset" });
2866
+ return new BuilderElement({
2867
+ name: "a:alphaOutset",
2868
+ attributes: { rad: {
2869
+ key: "rad",
2870
+ value: options.radius
2871
+ } }
2872
+ });
2873
+ };
2874
+ const createAlphaReplaceEffect = (options) => new BuilderElement({
2875
+ name: "a:alphaRepl",
2876
+ attributes: { a: {
2877
+ key: "a",
2878
+ value: options.alpha
2879
+ } }
2880
+ });
2881
+ const createBiLevelEffect = (thresh) => new BuilderElement({
2882
+ name: "a:biLevel",
2883
+ attributes: { thresh: {
2884
+ key: "thresh",
2885
+ value: thresh
2886
+ } }
2887
+ });
2888
+ const createBlendEffect = (options) => new BuilderElement({
2889
+ name: "a:blend",
2890
+ attributes: { blend: {
2891
+ key: "blend",
2892
+ value: xsdBlendMode.to(options.blend)
2893
+ } },
2894
+ children: [createEffectContainer(options.container)]
2895
+ });
2896
+ const createColorChangeEffect = (options) => {
2897
+ const children = [new BuilderElement({
2898
+ name: "a:clrFrom",
2899
+ children: [createColorElement(options.from)]
2900
+ }), new BuilderElement({
2901
+ name: "a:clrTo",
2902
+ children: [createColorElement(options.to)]
2903
+ })];
2904
+ if (options.useA === false) return new BuilderElement({
2905
+ name: "a:clrChange",
2906
+ attributes: { useA: {
2907
+ key: "useA",
2908
+ value: 0
2909
+ } },
2910
+ children
2911
+ });
2912
+ return new BuilderElement({
2913
+ name: "a:clrChange",
2914
+ children
2915
+ });
2916
+ };
2917
+ const createColorReplaceEffect = (color) => new BuilderElement({
2918
+ name: "a:clrRepl",
2919
+ children: [createColorElement(color)]
2920
+ });
2921
+ const createDuotoneEffect = (options) => new BuilderElement({
2922
+ name: "a:duotone",
2923
+ children: [createColorElement(options.color1), createColorElement(options.color2)]
2924
+ });
2925
+ const createFillEffect = (options) => {
2926
+ let fillElement;
2927
+ if (options.noFill) fillElement = createNoFill();
2928
+ else if (options.solidFill) fillElement = createSolidFill(options.solidFill);
2929
+ else if (options.gradientFill) fillElement = createGradientFill(options.gradientFill);
2930
+ else if (options.patternFill) fillElement = createPatternFill(options.patternFill);
2931
+ else if (options.groupFill) fillElement = createGroupFill();
2932
+ else fillElement = createNoFill();
2933
+ return new BuilderElement({
2934
+ name: "a:fill",
2935
+ children: [fillElement]
2936
+ });
2937
+ };
2938
+ const createGrayscaleEffect = () => new BuilderElement({ name: "a:grayscl" });
2939
+ const createHSLEffect = (options) => {
2940
+ return new BuilderElement({
2941
+ name: "a:hsl",
2942
+ attributes: buildOptionalAttributes({
2943
+ hue: options?.hue,
2944
+ sat: options?.saturation,
2945
+ lum: options?.luminance
2946
+ })
2947
+ });
2948
+ };
2949
+ const createLuminanceEffect = (options) => {
2950
+ return new BuilderElement({
2951
+ name: "a:lum",
2952
+ attributes: buildOptionalAttributes({
2953
+ bright: options?.bright,
2954
+ contrast: options?.contrast
2955
+ })
2956
+ });
2957
+ };
2958
+ const createTintEffect = (options) => {
2959
+ return new BuilderElement({
2960
+ name: "a:tint",
2961
+ attributes: buildOptionalAttributes({
2962
+ hue: options?.hue,
2963
+ amt: options?.amount
2964
+ })
2965
+ });
2966
+ };
2967
+ const createRelativeOffsetEffect = (options) => {
2968
+ return new BuilderElement({
2969
+ name: "a:relOff",
2970
+ attributes: buildOptionalAttributes({
2971
+ tx: options?.translateX,
2972
+ ty: options?.translateY
2973
+ })
2974
+ });
2975
+ };
2976
+ const createTransformEffect = (options) => {
2977
+ return new BuilderElement({
2978
+ name: "a:xfrm",
2979
+ attributes: buildOptionalAttributes({
2980
+ sx: options?.scaleX,
2981
+ sy: options?.scaleY,
2982
+ kx: options?.skewX,
2983
+ ky: options?.skewY,
2984
+ tx: options?.translateX,
2985
+ ty: options?.translateY
2986
+ })
2987
+ });
2988
+ };
2989
+ const createEffectReference = (options) => new BuilderElement({
2990
+ name: "a:effect",
2991
+ attributes: { ref: {
2992
+ key: "ref",
2993
+ value: options.ref
2994
+ } }
2995
+ });
2996
+ const createBlurEffect = (options) => {
2997
+ if (!(options.radius !== void 0 || options.grow === false)) return new BuilderElement({ name: "a:blur" });
2998
+ return new BuilderElement({
2999
+ attributes: {
3000
+ ...options.radius !== void 0 && { rad: {
3001
+ key: "rad",
3002
+ value: options.radius
3003
+ } },
3004
+ ...options.grow === false && { grow: {
3005
+ key: "grow",
3006
+ value: 0
3007
+ } }
3008
+ },
3009
+ name: "a:blur"
3010
+ });
3011
+ };
3012
+ /**
3013
+ * Creates an effect container element (a:effectDag or a:cont).
3014
+ *
3015
+ * This is the CT_EffectContainer type — a recursive DAG of effects.
3016
+ * All 28 EG_Effect types are supported.
3017
+ *
3018
+ * ## XSD Schema
3019
+ * ```xml
3020
+ * <xsd:complexType name="CT_EffectContainer">
3021
+ * <xsd:group ref="EG_Effect" minOccurs="0" maxOccurs="unbounded"/>
3022
+ * <xsd:attribute name="type" type="ST_EffectContainerType" default="sib"/>
3023
+ * <xsd:attribute name="name" type="xsd:token" use="optional"/>
3024
+ * </xsd:complexType>
3025
+ * ```
3026
+ *
3027
+ * @param options - Container options with effects
3028
+ * @param elementName - Element name, defaults to "a:effectDag" for top-level
3029
+ */
3030
+ const createEffectContainer = (options, elementName = "a:cont") => {
3031
+ const attrs = buildOptionalAttributes({
3032
+ type: options.type ? xsdEffectContainer.to(options.type) : void 0,
3033
+ name: options.name
3034
+ });
3035
+ const children = [];
3036
+ if (options.blur) children.push(createBlurEffect(options.blur));
3037
+ if (options.fillOverlay) children.push(createFillOverlayEffect(options.fillOverlay));
3038
+ if (options.glow) children.push(createGlowEffect(options.glow));
3039
+ if (options.innerShadow) children.push(createInnerShadowEffect(options.innerShadow));
3040
+ if (options.outerShadow) children.push(createOuterShadowEffect(options.outerShadow));
3041
+ if (options.presetShadow) children.push(createPresetShadowEffect(options.presetShadow));
3042
+ if (options.reflection) children.push(createReflectionEffect(options.reflection === true ? void 0 : options.reflection));
3043
+ if (options.softEdge !== void 0) children.push(createSoftEdgeEffect(options.softEdge));
3044
+ if (options.containers) for (const nested of options.containers) children.push(createEffectContainer(nested));
3045
+ if (options.effectRefs) for (const ref of options.effectRefs) children.push(createEffectReference(ref));
3046
+ if (options.alphaBiLevel) children.push(createAlphaBiLevelEffect(options.alphaBiLevel));
3047
+ if (options.alphaCeiling) children.push(createAlphaCeilingEffect());
3048
+ if (options.alphaFloor) children.push(createAlphaFloorEffect());
3049
+ if (options.alphaInverse) children.push(createAlphaInverseEffect(options.alphaInverse));
3050
+ if (options.alphaModulate) children.push(new BuilderElement({
3051
+ name: "a:alphaMod",
3052
+ children: [createEffectContainer(options.alphaModulate)]
3053
+ }));
3054
+ if (options.alphaModulateFixed) children.push(createAlphaModulateFixedEffect(options.alphaModulateFixed));
3055
+ if (options.alphaOutset) children.push(createAlphaOutsetEffect(options.alphaOutset));
3056
+ if (options.alphaReplace) children.push(createAlphaReplaceEffect(options.alphaReplace));
3057
+ if (options.biLevel) children.push(createBiLevelEffect(options.biLevel.threshold));
3058
+ if (options.blend) children.push(createBlendEffect(options.blend));
3059
+ if (options.colorChange) children.push(createColorChangeEffect(options.colorChange));
3060
+ if (options.colorReplace) children.push(createColorReplaceEffect(options.colorReplace));
3061
+ if (options.duotone) children.push(createDuotoneEffect(options.duotone));
3062
+ if (options.fill) children.push(createFillEffect(options.fill));
3063
+ if (options.grayscale) children.push(createGrayscaleEffect());
3064
+ if (options.hsl) children.push(createHSLEffect(options.hsl));
3065
+ if (options.luminance) children.push(createLuminanceEffect(options.luminance));
3066
+ if (options.tint) children.push(createTintEffect(options.tint));
3067
+ if (options.relativeOffset) children.push(createRelativeOffsetEffect(options.relativeOffset));
3068
+ if (options.transform) children.push(createTransformEffect(options.transform));
3069
+ return new BuilderElement({
3070
+ name: elementName,
3071
+ attributes: attrs,
3072
+ children: children.length > 0 ? children : void 0
3073
+ });
3074
+ };
3075
+ /**
3076
+ * Creates an effect DAG element (a:effectDag).
3077
+ *
3078
+ * This is the EG_EffectProperties choice alternative to effectLst,
3079
+ * supporting all 28 effect types with recursive nesting.
3080
+ *
3081
+ * @example
3082
+ * ```typescript
3083
+ * // Simple effect DAG with glow and outer shadow
3084
+ * createEffectDag({
3085
+ * glow: { radius: 50800, color: { value: "FF0000" } },
3086
+ * outerShadow: { color: { value: "000000" }, blurRadius: 76200 },
3087
+ * });
3088
+ *
3089
+ * // DAG with alpha effects and nested container
3090
+ * createEffectDag({
3091
+ * type: "tree",
3092
+ * alphaBiLevel: { threshold: 50000 },
3093
+ * containers: [{
3094
+ * glow: { color: { value: "FF0000" } },
3095
+ * }],
3096
+ * });
3097
+ * ```
3098
+ */
3099
+ const createEffectDag = (options) => createEffectContainer(options, "a:effectDag");
3100
+ //#endregion
3101
+ //#region src/drawingml/three-d/scene-3d.ts
3102
+ /**
3103
+ * 3D scene module for DrawingML shapes.
3104
+ *
3105
+ * Provides CT_Scene3D — the 3D scene properties including camera, light rig,
3106
+ * and optional backdrop that define how a 3D shape is rendered.
3107
+ *
3108
+ * Reference: ISO/IEC 29500-4, dml-main.xsd, CT_Scene3D
3109
+ *
3110
+ * @module
3111
+ */
3112
+ const createSphereCoords = (coords) => new BuilderElement({
3113
+ name: "a:rot",
3114
+ attributes: {
3115
+ lat: {
3116
+ key: "lat",
3117
+ value: coords.lat
3118
+ },
3119
+ lon: {
3120
+ key: "lon",
3121
+ value: coords.lon
3122
+ },
3123
+ rev: {
3124
+ key: "rev",
3125
+ value: coords.rev
3126
+ }
3127
+ }
3128
+ });
3129
+ const createCamera = (options) => {
3130
+ const children = [];
3131
+ if (options.rotation) children.push(createSphereCoords(options.rotation));
3132
+ const attrs = { prst: {
3133
+ key: "prst",
3134
+ value: options.preset
3135
+ } };
3136
+ if (options.fov !== void 0) attrs.fov = {
3137
+ key: "fov",
3138
+ value: options.fov
3139
+ };
3140
+ if (options.zoom !== void 0) attrs.zoom = {
3141
+ key: "zoom",
3142
+ value: options.zoom
3143
+ };
3144
+ return new BuilderElement({
3145
+ name: "a:camera",
3146
+ attributes: attrs,
3147
+ children: children.length > 0 ? children : void 0
3148
+ });
3149
+ };
3150
+ const createLightRig = (options) => {
3151
+ const children = [];
3152
+ if (options.rotation) children.push(createSphereCoords(options.rotation));
3153
+ return new BuilderElement({
3154
+ name: "a:lightRig",
3155
+ attributes: {
3156
+ rig: {
3157
+ key: "rig",
3158
+ value: options.rig
3159
+ },
3160
+ dir: {
3161
+ key: "dir",
3162
+ value: options.direction
3163
+ }
3164
+ },
3165
+ children: children.length > 0 ? children : void 0
3166
+ });
3167
+ };
3168
+ const createPoint3D = (name, point) => new BuilderElement({
3169
+ name,
3170
+ attributes: {
3171
+ x: {
3172
+ key: "x",
3173
+ value: point.x
3174
+ },
3175
+ y: {
3176
+ key: "y",
3177
+ value: point.y
3178
+ },
3179
+ z: {
3180
+ key: "z",
3181
+ value: point.z
3182
+ }
3183
+ }
3184
+ });
3185
+ const createVector3D = (name, vector) => new BuilderElement({
3186
+ name,
3187
+ attributes: {
3188
+ dx: {
3189
+ key: "dx",
3190
+ value: vector.dx
3191
+ },
3192
+ dy: {
3193
+ key: "dy",
3194
+ value: vector.dy
3195
+ },
3196
+ dz: {
3197
+ key: "dz",
3198
+ value: vector.dz
3199
+ }
3200
+ }
3201
+ });
3202
+ const createBackdrop = (options) => new BuilderElement({
3203
+ name: "a:backdrop",
3204
+ children: [
3205
+ createPoint3D("a:anchor", options.anchor),
3206
+ createVector3D("a:norm", options.normal),
3207
+ createVector3D("a:up", options.up)
3208
+ ]
3209
+ });
3210
+ /**
3211
+ * Creates a 3D scene element (a:scene3d).
3212
+ *
3213
+ * @example
3214
+ * ```typescript
3215
+ * // Simple scene with default camera and lighting
3216
+ * createScene3D({
3217
+ * camera: { preset: "perspectiveFront" },
3218
+ * lightRig: { rig: "threePt", direction: "t" },
3219
+ * });
3220
+ *
3221
+ * // Scene with rotated camera and backdrop
3222
+ * createScene3D({
3223
+ * camera: {
3224
+ * preset: "isometricTopUp",
3225
+ * rotation: { lat: 0, lon: 0, rev: 5400000 },
3226
+ * },
3227
+ * lightRig: { rig: "balanced", direction: "tl" },
3228
+ * backdrop: {
3229
+ * anchor: { x: 0, y: 0, z: 0 },
3230
+ * normal: { dx: 0, dy: 0, dz: 1 },
3231
+ * up: { dx: 0, dy: 1, dz: 0 },
3232
+ * },
3233
+ * });
3234
+ * ```
3235
+ */
3236
+ const createScene3D = (options) => {
3237
+ const children = [createCamera(options.camera), createLightRig(options.lightRig)];
3238
+ if (options.backdrop) children.push(createBackdrop(options.backdrop));
3239
+ return new BuilderElement({
3240
+ name: "a:scene3d",
3241
+ children
3242
+ });
3243
+ };
3244
+ //#endregion
3245
+ //#region src/drawingml/three-d/bevel.ts
3246
+ /**
3247
+ * Bevel element for DrawingML 3D shapes.
3248
+ *
3249
+ * Reference: ISO/IEC 29500-4, dml-main.xsd, CT_Bevel
3250
+ *
3251
+ * @module
3252
+ */
3253
+ /**
3254
+ * Bevel preset types (12 variations).
3255
+ *
3256
+ * Reference: ISO/IEC 29500-4, dml-main.xsd, ST_BevelPresetType
3257
+ */
3258
+ const BevelPresetType = {
3259
+ RELAXED_INSET: "relaxedInset",
3260
+ CIRCLE: "circle",
3261
+ SLOPE: "slope",
3262
+ CROSS: "cross",
3263
+ ANGLE: "angle",
3264
+ SOFT_ROUND: "softRound",
3265
+ CONVEX: "convex",
3266
+ COOL_SLANT: "coolSlant",
3267
+ DIVOT: "divot",
3268
+ RIBLET: "riblet",
3269
+ HARD_EDGE: "hardEdge",
3270
+ ART_DECO: "artDeco"
3271
+ };
3272
+ /**
3273
+ * Creates a bevel element.
3274
+ *
3275
+ * ## XSD Schema
3276
+ * ```xml
3277
+ * <xsd:complexType name="CT_Bevel">
3278
+ * <xsd:attribute name="w" type="ST_PositiveCoordinate" default="76200"/>
3279
+ * <xsd:attribute name="h" type="ST_PositiveCoordinate" default="76200"/>
3280
+ * <xsd:attribute name="prst" type="ST_BevelPresetType" default="circle"/>
3281
+ * </xsd:complexType>
3282
+ * ```
3283
+ */
3284
+ const createBevel = (options) => {
3285
+ if (!options) return new BuilderElement({ name: "a:bevelT" });
3286
+ const attributes = {};
3287
+ if (options.w !== void 0) attributes.w = {
3288
+ key: "w",
3289
+ value: options.w
3290
+ };
3291
+ if (options.h !== void 0) attributes.h = {
3292
+ key: "h",
3293
+ value: options.h
3294
+ };
3295
+ if (options.prst !== void 0) attributes.prst = {
3296
+ key: "prst",
3297
+ value: options.prst
3298
+ };
3299
+ return new BuilderElement({
3300
+ attributes,
3301
+ name: "a:bevelT"
3302
+ });
3303
+ };
3304
+ /**
3305
+ * Creates a bottom bevel element (a:bevelB).
3306
+ */
3307
+ const createBottomBevel = (options) => {
3308
+ if (!options) return new BuilderElement({ name: "a:bevelB" });
3309
+ const attributes = {};
3310
+ if (options.w !== void 0) attributes.w = {
3311
+ key: "w",
3312
+ value: options.w
3313
+ };
3314
+ if (options.h !== void 0) attributes.h = {
3315
+ key: "h",
3316
+ value: options.h
3317
+ };
3318
+ if (options.prst !== void 0) attributes.prst = {
3319
+ key: "prst",
3320
+ value: options.prst
3321
+ };
3322
+ return new BuilderElement({
3323
+ attributes,
3324
+ name: "a:bevelB"
3325
+ });
3326
+ };
3327
+ //#endregion
3328
+ //#region src/drawingml/three-d/shape-3d.ts
3329
+ /**
3330
+ * 3D shape properties for DrawingML.
3331
+ *
3332
+ * Reference: ISO/IEC 29500-4, dml-main.xsd, CT_Shape3D
3333
+ *
3334
+ * @module
3335
+ */
3336
+ /**
3337
+ * Preset material types for 3D shapes (15 variations).
3338
+ *
3339
+ * Reference: ISO/IEC 29500-4, dml-main.xsd, ST_PresetMaterialType
3340
+ */
3341
+ const PresetMaterialType = {
3342
+ LEGACY_MATTE: "legacyMatte",
3343
+ LEGACY_PLASTIC: "legacyPlastic",
3344
+ LEGACY_METAL: "legacyMetal",
3345
+ LEGACY_WIREFRAME: "legacyWireframe",
3346
+ MATTE: "matte",
3347
+ PLASTIC: "plastic",
3348
+ METAL: "metal",
3349
+ WARM_MATTE: "warmMatte",
3350
+ TRANSLUCENT_POWDER: "translucentPowder",
3351
+ POWDER: "powder",
3352
+ DK_EDGE: "darkEdge",
3353
+ SOFT_EDGE: "softEdge",
3354
+ CLEAR: "clear",
3355
+ FLAT: "flat",
3356
+ SOFT_METAL: "softMetal"
3357
+ };
3358
+ /**
3359
+ * Creates a 3D shape properties element (a:sp3d).
3360
+ *
3361
+ * ## XSD Schema
3362
+ * ```xml
3363
+ * <xsd:complexType name="CT_Shape3D">
3364
+ * <xsd:sequence>
3365
+ * <xsd:element name="bevelT" type="CT_Bevel" minOccurs="0"/>
3366
+ * <xsd:element name="bevelB" type="CT_Bevel" minOccurs="0"/>
3367
+ * <xsd:element name="extrusionClr" type="CT_Color" minOccurs="0"/>
3368
+ * <xsd:element name="contourClr" type="CT_Color" minOccurs="0"/>
3369
+ * </xsd:sequence>
3370
+ * <xsd:attribute name="z" type="ST_Coordinate" default="0"/>
3371
+ * <xsd:attribute name="extrusionH" type="ST_PositiveCoordinate" default="0"/>
3372
+ * <xsd:attribute name="contourW" type="ST_PositiveCoordinate" default="0"/>
3373
+ * <xsd:attribute name="prstMaterial" type="ST_PresetMaterialType" default="warmMatte"/>
3374
+ * </xsd:complexType>
3375
+ * ```
3376
+ */
3377
+ const createShape3D = (options) => {
3378
+ const children = [];
3379
+ if (options.bevelT) children.push(createBevel(options.bevelT));
3380
+ if (options.bevelB) children.push(createBottomBevel(options.bevelB));
3381
+ if (options.extrusionColor) children.push(new BuilderElement({
3382
+ children: [createColorElement(options.extrusionColor)],
3383
+ name: "a:extrusionClr"
3384
+ }));
3385
+ if (options.contourColor) children.push(new BuilderElement({
3386
+ children: [createColorElement(options.contourColor)],
3387
+ name: "a:contourClr"
3388
+ }));
3389
+ return new BuilderElement({
3390
+ attributes: options.z !== void 0 || options.extrusionH !== void 0 || options.contourW !== void 0 || options.prstMaterial !== void 0 ? {
3391
+ ...options.z !== void 0 && { z: {
3392
+ key: "z",
3393
+ value: options.z
3394
+ } },
3395
+ ...options.extrusionH !== void 0 && { extrusionH: {
3396
+ key: "extrusionH",
3397
+ value: options.extrusionH
3398
+ } },
3399
+ ...options.contourW !== void 0 && { contourW: {
3400
+ key: "contourW",
3401
+ value: options.contourW
3402
+ } },
3403
+ ...options.prstMaterial !== void 0 && { prstMaterial: {
3404
+ key: "prstMaterial",
3405
+ value: xsdMaterialType.to(options.prstMaterial)
3406
+ } }
3407
+ } : void 0,
3408
+ children,
3409
+ name: "a:sp3d"
3410
+ });
3411
+ };
3412
+ //#endregion
3413
+ //#region src/drawingml/geometry/adjustment-values.ts
3414
+ /**
3415
+ * Adjustment values module for preset geometries.
3416
+ *
3417
+ * This module provides adjustment value lists that can modify the appearance
3418
+ * of preset shape geometries.
3419
+ *
3420
+ * Reference: ISO/IEC 29500-4, dml-main.xsd, CT_GeomGuideList, CT_GeomGuide
3421
+ *
3422
+ * @module
3423
+ */
3424
+ /**
3425
+ * Creates an adjustment values list element (a:avLst).
3426
+ *
3427
+ * The adjustment values list contains geometry guides that modify
3428
+ * the appearance of a preset geometric shape. When empty, default
3429
+ * values are used.
3430
+ *
3431
+ * ## XSD Schema
3432
+ * ```xml
3433
+ * <xsd:complexType name="CT_GeomGuideList">
3434
+ * <xsd:sequence>
3435
+ * <xsd:element name="gd" type="CT_GeomGuide" minOccurs="0" maxOccurs="unbounded"/>
3436
+ * </xsd:sequence>
3437
+ * </xsd:complexType>
3438
+ * ```
3439
+ *
3440
+ * @example
3441
+ * ```typescript
3442
+ * // Empty adjustment values (defaults)
3443
+ * createAdjustmentValues();
3444
+ *
3445
+ * // With guides
3446
+ * createAdjustmentValues([
3447
+ * { name: "adj", formula: "val 16667" },
3448
+ * ]);
3449
+ * ```
3450
+ */
3451
+ const createAdjustmentValues = (guides) => {
3452
+ const children = [];
3453
+ if (guides) for (const guide of guides) children.push(new BuilderElement({
3454
+ attributes: {
3455
+ name: {
3456
+ key: "name",
3457
+ value: guide.name
3458
+ },
3459
+ fmla: {
3460
+ key: "fmla",
3461
+ value: guide.formula
3462
+ }
3463
+ },
3464
+ name: "a:gd"
3465
+ }));
3466
+ return new BuilderElement({
3467
+ children,
3468
+ name: "a:avLst"
3469
+ });
3470
+ };
3471
+ //#endregion
3472
+ //#region src/drawingml/geometry/preset-geometry.ts
3473
+ /**
3474
+ * Preset geometry module for DrawingML shapes.
3475
+ *
3476
+ * This module provides predefined shape geometries that can be applied
3477
+ * to pictures and shapes without requiring custom path definitions.
3478
+ *
3479
+ * Reference: ISO/IEC 29500-4, dml-main.xsd, CT_PresetGeometry2D
3480
+ *
3481
+ * @module
3482
+ */
3483
+ /**
3484
+ * Represents a preset geometry for a DrawingML shape.
3485
+ *
3486
+ * This element specifies when a preset geometric shape should be used instead
3487
+ * of a custom geometry. It includes a shape preset identifier and optional
3488
+ * adjustment values that modify the base shape.
3489
+ *
3490
+ * ## XSD Schema
3491
+ * ```xml
3492
+ * <xsd:complexType name="CT_PresetGeometry2D">
3493
+ * <xsd:sequence>
3494
+ * <xsd:element name="avLst" type="CT_GeomGuideList" minOccurs="0" maxOccurs="1"/>
3495
+ * </xsd:sequence>
3496
+ * <xsd:attribute name="prst" type="ST_ShapeType" use="required"/>
3497
+ * </xsd:complexType>
3498
+ * ```
3499
+ *
3500
+ * @example
3501
+ * ```typescript
3502
+ * // Default rectangle
3503
+ * const geometry = new PresetGeometry();
3504
+ *
3505
+ * // Rounded rectangle with adjustment
3506
+ * const geometry = new PresetGeometry({
3507
+ * preset: "roundRect",
3508
+ * adjustmentValues: [{ name: "adj", formula: "val 16667" }],
3509
+ * });
3510
+ * ```
3511
+ */
3512
+ var PresetGeometry = class extends XmlComponent {
3513
+ constructor(options) {
3514
+ super("a:prstGeom");
3515
+ this.root.push({ _attr: { prst: options?.preset ?? "rect" } });
3516
+ this.root.push(createAdjustmentValues(options?.adjustmentValues));
3517
+ }
3518
+ };
3519
+ //#endregion
3520
+ //#region src/drawingml/geometry/custom-geometry.ts
3521
+ /**
3522
+ * Custom geometry module for DrawingML shapes.
3523
+ *
3524
+ * Provides CT_CustomGeometry2D — user-defined 2D geometry with paths,
3525
+ * guides, adjust handles, connection sites, and a text insertion rectangle.
3526
+ *
3527
+ * Reference: ISO/IEC 29500-4, dml-main.xsd, CT_CustomGeometry2D
3528
+ *
3529
+ * @module
3530
+ */
3531
+ /**
3532
+ * Creates a geometry guide list element (a:avLst or a:gdLst).
3533
+ *
3534
+ * Both CT_GeomGuideList types share the same structure — a list of `a:gd` children.
3535
+ * The only difference is the wrapper element name.
3536
+ */
3537
+ const createGuideList = (name, guides) => {
3538
+ return new BuilderElement({
3539
+ name,
3540
+ children: guides.map((guide) => new BuilderElement({
3541
+ attributes: {
3542
+ name: {
3543
+ key: "name",
3544
+ value: guide.name
3545
+ },
3546
+ fmla: {
3547
+ key: "fmla",
3548
+ value: guide.formula
3549
+ }
3550
+ },
3551
+ name: "a:gd"
3552
+ }))
3553
+ });
3554
+ };
3555
+ const createAdjPoint = (name, point) => new BuilderElement({
3556
+ name,
3557
+ children: [new BuilderElement({
3558
+ name: "a:pt",
3559
+ attributes: {
3560
+ x: {
3561
+ key: "x",
3562
+ value: point.x
3563
+ },
3564
+ y: {
3565
+ key: "y",
3566
+ value: point.y
3567
+ }
3568
+ }
3569
+ })]
3570
+ });
3571
+ const createPathCommand = (cmd) => {
3572
+ switch (cmd.command) {
3573
+ case "moveTo": return createAdjPoint("a:moveTo", cmd.point);
3574
+ case "lineTo": return createAdjPoint("a:lnTo", cmd.point);
3575
+ case "arcTo": return new BuilderElement({
3576
+ name: "a:arcTo",
3577
+ attributes: {
3578
+ wR: {
3579
+ key: "wR",
3580
+ value: cmd.widthRadius
3581
+ },
3582
+ hR: {
3583
+ key: "hR",
3584
+ value: cmd.heightRadius
3585
+ },
3586
+ stAng: {
3587
+ key: "stAng",
3588
+ value: cmd.startAngle
3589
+ },
3590
+ swAng: {
3591
+ key: "swAng",
3592
+ value: cmd.sweepAngle
3593
+ }
3594
+ }
3595
+ });
3596
+ case "quadBezTo": return new BuilderElement({
3597
+ name: "a:quadBezTo",
3598
+ children: cmd.points.map((pt) => new BuilderElement({
3599
+ name: "a:pt",
3600
+ attributes: {
3601
+ x: {
3602
+ key: "x",
3603
+ value: pt.x
3604
+ },
3605
+ y: {
3606
+ key: "y",
3607
+ value: pt.y
3608
+ }
3609
+ }
3610
+ }))
3611
+ });
3612
+ case "cubicBezTo": return new BuilderElement({
3613
+ name: "a:cubicBezTo",
3614
+ children: cmd.points.map((pt) => new BuilderElement({
3615
+ name: "a:pt",
3616
+ attributes: {
3617
+ x: {
3618
+ key: "x",
3619
+ value: pt.x
3620
+ },
3621
+ y: {
3622
+ key: "y",
3623
+ value: pt.y
3624
+ }
3625
+ }
3626
+ }))
3627
+ });
3628
+ case "close": return new BuilderElement({ name: "a:close" });
3629
+ }
3630
+ };
3631
+ const createPath = (options) => {
3632
+ const attrs = {};
3633
+ if (options.w !== void 0) attrs.w = {
3634
+ key: "w",
3635
+ value: options.w
3636
+ };
3637
+ if (options.h !== void 0) attrs.h = {
3638
+ key: "h",
3639
+ value: options.h
3640
+ };
3641
+ if (options.fill !== void 0) attrs.fill = {
3642
+ key: "fill",
3643
+ value: xsdPathFillMode.to(options.fill)
3644
+ };
3645
+ if (options.stroke !== void 0) attrs.stroke = {
3646
+ key: "stroke",
3647
+ value: options.stroke
3648
+ };
3649
+ if (options.extrusionOk !== void 0) attrs.extrusionOk = {
3650
+ key: "extrusionOk",
3651
+ value: options.extrusionOk
3652
+ };
3653
+ return new BuilderElement({
3654
+ name: "a:path",
3655
+ attributes: Object.keys(attrs).length > 0 ? attrs : void 0,
3656
+ children: options.commands.map(createPathCommand)
3657
+ });
3658
+ };
3659
+ const createAdjustHandlePos = (position) => new BuilderElement({
3660
+ name: "a:pos",
3661
+ attributes: {
3662
+ x: {
3663
+ key: "x",
3664
+ value: position.x
3665
+ },
3666
+ y: {
3667
+ key: "y",
3668
+ value: position.y
3669
+ }
3670
+ }
3671
+ });
3672
+ const createXYAdjustHandle = (handle) => {
3673
+ const attrs = {};
3674
+ if (handle.guideRefX !== void 0) attrs.gdRefX = {
3675
+ key: "gdRefX",
3676
+ value: handle.guideRefX
3677
+ };
3678
+ if (handle.minX !== void 0) attrs.minX = {
3679
+ key: "minX",
3680
+ value: handle.minX
3681
+ };
3682
+ if (handle.maxX !== void 0) attrs.maxX = {
3683
+ key: "maxX",
3684
+ value: handle.maxX
3685
+ };
3686
+ if (handle.guideRefY !== void 0) attrs.gdRefY = {
3687
+ key: "gdRefY",
3688
+ value: handle.guideRefY
3689
+ };
3690
+ if (handle.minY !== void 0) attrs.minY = {
3691
+ key: "minY",
3692
+ value: handle.minY
3693
+ };
3694
+ if (handle.maxY !== void 0) attrs.maxY = {
3695
+ key: "maxY",
3696
+ value: handle.maxY
3697
+ };
3698
+ return new BuilderElement({
3699
+ name: "a:ahXY",
3700
+ attributes: Object.keys(attrs).length > 0 ? attrs : void 0,
3701
+ children: [createAdjustHandlePos(handle.position)]
3702
+ });
3703
+ };
3704
+ const createPolarAdjustHandle = (handle) => {
3705
+ const attrs = {};
3706
+ if (handle.guideRefRadius !== void 0) attrs.gdRefR = {
3707
+ key: "gdRefR",
3708
+ value: handle.guideRefRadius
3709
+ };
3710
+ if (handle.minRadius !== void 0) attrs.minR = {
3711
+ key: "minR",
3712
+ value: handle.minRadius
3713
+ };
3714
+ if (handle.maxRadius !== void 0) attrs.maxR = {
3715
+ key: "maxR",
3716
+ value: handle.maxRadius
3717
+ };
3718
+ if (handle.guideRefAngle !== void 0) attrs.gdRefAng = {
3719
+ key: "gdRefAng",
3720
+ value: handle.guideRefAngle
3721
+ };
3722
+ if (handle.minAngle !== void 0) attrs.minAng = {
3723
+ key: "minAng",
3724
+ value: handle.minAngle
3725
+ };
3726
+ if (handle.maxAngle !== void 0) attrs.maxAng = {
3727
+ key: "maxAng",
3728
+ value: handle.maxAngle
3729
+ };
3730
+ return new BuilderElement({
3731
+ name: "a:ahPolar",
3732
+ attributes: Object.keys(attrs).length > 0 ? attrs : void 0,
3733
+ children: [createAdjustHandlePos(handle.position)]
3734
+ });
3735
+ };
3736
+ const createConnectionSite = (site) => new BuilderElement({
3737
+ name: "a:cxn",
3738
+ attributes: { ang: {
3739
+ key: "ang",
3740
+ value: site.angle
3741
+ } },
3742
+ children: [createAdjustHandlePos(site.position)]
3743
+ });
3744
+ const createGeomRect = (rect) => new BuilderElement({
3745
+ name: "a:rect",
3746
+ attributes: {
3747
+ l: {
3748
+ key: "l",
3749
+ value: rect.left
3750
+ },
3751
+ t: {
3752
+ key: "t",
3753
+ value: rect.top
3754
+ },
3755
+ r: {
3756
+ key: "r",
3757
+ value: rect.right
3758
+ },
3759
+ b: {
3760
+ key: "b",
3761
+ value: rect.bottom
3762
+ }
3763
+ }
3764
+ });
3765
+ /**
3766
+ * Creates a custom 2D geometry element (a:custGeom).
3767
+ *
3768
+ * @example
3769
+ * ```typescript
3770
+ * // Diamond shape
3771
+ * const geom = createCustomGeometry({
3772
+ * pathList: [{
3773
+ * commands: [
3774
+ * { command: "moveTo", point: { x: "5000000", y: "0" } },
3775
+ * { command: "lineTo", point: { x: "10000000", y: "5000000" } },
3776
+ * { command: "lineTo", point: { x: "5000000", y: "10000000" } },
3777
+ * { command: "lineTo", point: { x: "0", y: "5000000" } },
3778
+ * { command: "close" },
3779
+ * ],
3780
+ * }],
3781
+ * textRect: { left: "2000000", top: "2000000", right: "8000000", bottom: "8000000" },
3782
+ * });
3783
+ * ```
3784
+ */
3785
+ const createCustomGeometry = (options) => {
3786
+ const children = [];
3787
+ if (options.adjustmentValues) children.push(createGuideList("a:avLst", options.adjustmentValues));
3788
+ if (options.guides) children.push(createGuideList("a:gdLst", options.guides));
3789
+ if (options.adjustHandles && options.adjustHandles.length > 0) children.push(new BuilderElement({
3790
+ name: "a:ahLst",
3791
+ children: options.adjustHandles.map((h) => h.type === "xy" ? createXYAdjustHandle(h) : createPolarAdjustHandle(h))
3792
+ }));
3793
+ if (options.connectionSites && options.connectionSites.length > 0) children.push(new BuilderElement({
3794
+ name: "a:cxnLst",
3795
+ children: options.connectionSites.map(createConnectionSite)
3796
+ }));
3797
+ if (options.textRect) children.push(createGeomRect(options.textRect));
3798
+ children.push(new BuilderElement({
3799
+ name: "a:pathLst",
3800
+ children: options.pathList.map(createPath)
3801
+ }));
3802
+ return new BuilderElement({
3803
+ name: "a:custGeom",
3804
+ children
3805
+ });
3806
+ };
3807
+ //#endregion
3808
+ //#region src/drawingml/blip/blip-extentions.ts
3809
+ /**
3810
+ * Blip extensions module for SVG support.
3811
+ *
3812
+ * This module provides extension elements that enable SVG image support
3813
+ * within blip elements using Office-specific extensions.
3814
+ *
3815
+ * Reference: http://officeopenxml.com/drwPic.php
3816
+ *
3817
+ * @module
3818
+ */
3819
+ /**
3820
+ * Creates an SVG blip element for embedding SVG images.
3821
+ *
3822
+ * This element is a Microsoft Office extension that allows SVG images
3823
+ * to be referenced within a blip.
3824
+ *
3825
+ * @param svgReferenceId - The reference ID for the SVG image
3826
+ * @returns An XML component representing the SVG blip element
3827
+ * @internal
3828
+ */
3829
+ const createSvgBlip = (svgReferenceId) => new BuilderElement({
3830
+ attributes: {
3831
+ asvg: {
3832
+ key: "xmlns:asvg",
3833
+ value: "http://schemas.microsoft.com/office/drawing/2016/SVG/main"
3834
+ },
3835
+ embed: {
3836
+ key: "r:embed",
3837
+ value: `{${svgReferenceId}}`
3838
+ }
3839
+ },
3840
+ name: "asvg:svgBlip"
3841
+ });
3842
+ /**
3843
+ * Creates an extension element for SVG support.
3844
+ *
3845
+ * This element wraps the SVG blip extension with the appropriate URI
3846
+ * to identify it as an SVG extension.
3847
+ *
3848
+ * @param svgReferenceId - The reference ID for the SVG image
3849
+ * @returns An XML component representing the extension element
3850
+ * @internal
3851
+ */
3852
+ const createExtention = (svgReferenceId) => new BuilderElement({
3853
+ attributes: { uri: {
3854
+ key: "uri",
3855
+ value: "{96DAC541-7B7A-43D3-8B79-37D633B846F1}"
3856
+ } },
3857
+ children: [createSvgBlip(svgReferenceId)],
3858
+ name: "a:ext"
3859
+ });
3860
+ /**
3861
+ * Creates an extension list for SVG images.
3862
+ *
3863
+ * This element contains the extensions needed to embed SVG images
3864
+ * within a blip. It wraps the SVG-specific extension elements.
3865
+ *
3866
+ * ## XSD Schema
3867
+ * ```xml
3868
+ * <xsd:complexType name="CT_OfficeArtExtensionList">
3869
+ * <xsd:sequence>
3870
+ * <xsd:element name="ext" type="CT_OfficeArtExtension" minOccurs="0" maxOccurs="unbounded"/>
3871
+ * </xsd:sequence>
3872
+ * </xsd:complexType>
3873
+ * ```
3874
+ *
3875
+ * @param svgReferenceId - The reference ID for the SVG image
3876
+ * @returns An XML component representing the extension list
3877
+ */
3878
+ const createExtentionList = (svgReferenceId) => new BuilderElement({
3879
+ children: [createExtention(svgReferenceId)],
3880
+ name: "a:extLst"
3881
+ });
3882
+ //#endregion
3883
+ //#region src/drawingml/blip/blip.ts
3884
+ /**
3885
+ * Blip (Binary Large Image or Picture) module for DrawingML.
3886
+ *
3887
+ * This module provides the blip element that references the actual
3888
+ * image data within a picture.
3889
+ *
3890
+ * Reference: http://officeopenxml.com/drwPic.php
3891
+ *
3892
+ * @module
3893
+ */
3894
+ /**
3895
+ * Creates a blip element for an image.
3896
+ *
3897
+ * A blip references the actual image data stored in the document package
3898
+ * through a relationship ID. For SVG images, it includes extensions that
3899
+ * reference the SVG data.
3900
+ *
3901
+ * Reference: http://officeopenxml.com/drwPic.php
3902
+ *
3903
+ * ## XSD Schema
3904
+ * ```xml
3905
+ * <xsd:complexType name="CT_Blip">
3906
+ * <xsd:sequence>
3907
+ * <xsd:choice minOccurs="0" maxOccurs="unbounded">
3908
+ * <xsd:element name="alphaBiLevel" type="CT_AlphaBiLevelEffect"/>
3909
+ * <xsd:element name="alphaCeiling" type="CT_AlphaCeilingEffect"/>
3910
+ * <xsd:element name="alphaFloor" type="CT_AlphaFloorEffect"/>
3911
+ * <xsd:element name="alphaInv" type="CT_AlphaInverseEffect"/>
3912
+ * <xsd:element name="alphaMod" type="CT_AlphaModulateEffect"/>
3913
+ * <xsd:element name="alphaModFix" type="CT_AlphaModulateFixedEffect"/>
3914
+ * <xsd:element name="alphaRepl" type="CT_AlphaReplaceEffect"/>
3915
+ * <xsd:element name="biLevel" type="CT_BiLevelEffect"/>
3916
+ * <xsd:element name="blur" type="CT_BlurEffect"/>
3917
+ * <xsd:element name="clrChange" type="CT_ColorChangeEffect"/>
3918
+ * <xsd:element name="clrRepl" type="CT_ColorReplaceEffect"/>
3919
+ * <xsd:element name="duotone" type="CT_DuotoneEffect"/>
3920
+ * <xsd:element name="fillOverlay" type="CT_FillOverlayEffect"/>
3921
+ * <xsd:element name="grayscl" type="CT_GrayscaleEffect"/>
3922
+ * <xsd:element name="hsl" type="CT_HSLEffect"/>
3923
+ * <xsd:element name="lum" type="CT_LuminanceEffect"/>
3924
+ * <xsd:element name="tint" type="CT_TintEffect"/>
3925
+ * </xsd:choice>
3926
+ * <xsd:element name="extLst" type="CT_OfficeArtExtensionList" minOccurs="0"/>
3927
+ * </xsd:sequence>
3928
+ * <xsd:attribute ref="r:embed"/>
3929
+ * <xsd:attribute ref="r:link"/>
3930
+ * <xsd:attribute name="cstate" type="ST_BlipCompression"/>
3931
+ * </xsd:complexType>
3932
+ * ```
3933
+ *
3934
+ * @param options - Blip options including referenceId and type
3935
+ * @param blipEffects - Optional blip effects (brightness, contrast, etc.)
3936
+ * @returns An XML component representing the blip element
3937
+ */
3938
+ const createBlip = (options, blipEffects) => {
3939
+ const children = [];
3940
+ if (blipEffects) children.push(...createBlipEffects(blipEffects));
3941
+ if (options.type === "svg" && options.fallbackFileName) children.push(createExtentionList(options.referenceId));
3942
+ return new BuilderElement({
3943
+ attributes: {
3944
+ cstate: {
3945
+ key: "cstate",
3946
+ value: "none"
3947
+ },
3948
+ embed: {
3949
+ key: "r:embed",
3950
+ value: `{${options.type === "svg" && options.fallbackFileName ? options.fallbackFileName : options.referenceId}}`
3951
+ }
3952
+ },
3953
+ children,
3954
+ name: "a:blip"
3955
+ });
3956
+ };
3957
+ //#endregion
3958
+ //#region src/drawingml/blip/blip-fill.ts
3959
+ /**
3960
+ * Blip fill module for DrawingML pictures.
3961
+ *
3962
+ * This module defines how an image (blip) fills a picture shape,
3963
+ * including stretching and cropping options.
3964
+ *
3965
+ * Reference: ISO/IEC 29500-4, dml-main.xsd, CT_BlipFillProperties
3966
+ *
3967
+ * @module
3968
+ */
3969
+ /**
3970
+ * Creates a blip fill element.
3971
+ *
3972
+ * This element specifies the type of fill used for a picture. It contains the blip (image)
3973
+ * reference, an optional source rectangle for cropping, and the fill mode (typically stretch).
3974
+ *
3975
+ * Reference: ISO/IEC 29500-4, dml-main.xsd, CT_BlipFillProperties
3976
+ *
3977
+ * ## XSD Schema
3978
+ * ```xml
3979
+ * <xsd:complexType name="CT_BlipFillProperties">
3980
+ * <xsd:sequence>
3981
+ * <xsd:element name="blip" type="CT_Blip" minOccurs="0" maxOccurs="1"/>
3982
+ * <xsd:element name="srcRect" type="CT_RelativeRect" minOccurs="0" maxOccurs="1"/>
3983
+ * <xsd:group ref="EG_FillModeProperties" minOccurs="0" maxOccurs="1"/>
3984
+ * </xsd:sequence>
3985
+ * <xsd:attribute name="dpi" type="xsd:unsignedInt" use="optional"/>
3986
+ * <xsd:attribute name="rotWithShape" type="xsd:boolean" use="optional"/>
3987
+ * </xsd:complexType>
3988
+ * ```
3989
+ *
3990
+ * @param blipOptions - Blip options including referenceId and type
3991
+ * @param fillOptions - Optional blip fill options
3992
+ */
3993
+ const createBlipFill = (blipOptions, fillOptions) => {
3994
+ const children = [];
3995
+ children.push(createBlip(blipOptions, fillOptions?.blipEffects));
3996
+ children.push(createSourceRectangle(fillOptions?.srcRect));
3997
+ if (fillOptions?.tile) children.push(createTileInfo(fillOptions.tile));
3998
+ else children.push(new Stretch());
3999
+ const attributes = {};
4000
+ if (fillOptions?.dpi !== void 0) attributes.dpi = {
4001
+ key: "dpi",
4002
+ value: fillOptions.dpi
4003
+ };
4004
+ if (fillOptions?.rotWithShape !== void 0) attributes.rotWithShape = {
4005
+ key: "rotWithShape",
4006
+ value: fillOptions.rotWithShape ? 1 : 0
4007
+ };
4008
+ return new BuilderElement({
4009
+ attributes: Object.keys(attributes).length > 0 ? attributes : void 0,
4010
+ children,
4011
+ name: "pic:blipFill"
4012
+ });
4013
+ };
4014
+ //#endregion
4015
+ //#region src/drawingml/transform.ts
4016
+ /**
4017
+ * 2D transform for DrawingML shapes.
4018
+ *
4019
+ * This module provides factory functions for creating transform elements
4020
+ * (a:xfrm) used in shape properties, picture properties, and group shapes.
4021
+ *
4022
+ * Reference: ISO/IEC 29500-4, dml-main.xsd, CT_Transform2D / CT_GroupTransform2D
4023
+ *
4024
+ * @module
4025
+ */
4026
+ function buildXfrmAttrs(options) {
4027
+ const attrs = {};
4028
+ if (options.flipHorizontal !== void 0) attrs.flipH = {
4029
+ key: "flipH",
4030
+ value: options.flipHorizontal
4031
+ };
4032
+ if (options.flipVertical !== void 0) attrs.flipV = {
4033
+ key: "flipV",
4034
+ value: options.flipVertical
4035
+ };
4036
+ if (options.rotation !== void 0) attrs.rot = {
4037
+ key: "rot",
4038
+ value: options.rotation
4039
+ };
4040
+ return Object.keys(attrs).length > 0 ? attrs : void 0;
4041
+ }
4042
+ /**
4043
+ * Creates a 2D transform element (a:xfrm).
4044
+ *
4045
+ * @param options - Transform options including position, size, rotation, and flip.
4046
+ * @param elementName - Element name, defaults to "a:xfrm".
4047
+ */
4048
+ const createTransform2D = (options, elementName = "a:xfrm") => {
4049
+ const children = [];
4050
+ if (options.x !== void 0 || options.y !== void 0) children.push(new BuilderElement({
4051
+ name: "a:off",
4052
+ attributes: {
4053
+ x: {
4054
+ key: "x",
4055
+ value: options.x ?? 0
4056
+ },
4057
+ y: {
4058
+ key: "y",
4059
+ value: options.y ?? 0
4060
+ }
4061
+ }
4062
+ }));
4063
+ if (options.width !== void 0 || options.height !== void 0) children.push(new BuilderElement({
4064
+ name: "a:ext",
4065
+ attributes: {
4066
+ cx: {
4067
+ key: "cx",
4068
+ value: options.width ?? 0
4069
+ },
4070
+ cy: {
4071
+ key: "cy",
4072
+ value: options.height ?? 0
4073
+ }
4074
+ }
4075
+ }));
4076
+ return new BuilderElement({
4077
+ name: elementName,
4078
+ attributes: buildXfrmAttrs(options),
4079
+ children: children.length > 0 ? children : void 0
4080
+ });
4081
+ };
4082
+ /**
4083
+ * Creates a group transform element (a:xfrm with chOff/chExt children).
4084
+ */
4085
+ const createGroupTransform2D = (options, elementName = "a:xfrm") => {
4086
+ const base = createTransform2D(options, elementName);
4087
+ base["root"].push(new BuilderElement({
4088
+ name: "a:chOff",
4089
+ attributes: {
4090
+ x: {
4091
+ key: "x",
4092
+ value: options.childOffsetX ?? 0
4093
+ },
4094
+ y: {
4095
+ key: "y",
4096
+ value: options.childOffsetY ?? 0
4097
+ }
4098
+ }
4099
+ }));
4100
+ base["root"].push(new BuilderElement({
4101
+ name: "a:chExt",
4102
+ attributes: {
4103
+ cx: {
4104
+ key: "cx",
4105
+ value: options.childExtentWidth ?? 0
4106
+ },
4107
+ cy: {
4108
+ key: "cy",
4109
+ value: options.childExtentHeight ?? 0
4110
+ }
4111
+ }
4112
+ }));
4113
+ return base;
4114
+ };
4115
+ //#endregion
4116
+ //#region src/drawingml/media/transformation.ts
4117
+ /**
4118
+ * Media transformation utilities for DrawingML.
4119
+ *
4120
+ * Converts user-facing transformation options (pixels) to internal
4121
+ * transformation data (pixels + EMUs).
4122
+ *
4123
+ * @module
4124
+ */
4125
+ /**
4126
+ * Converts user-facing transformation options (pixels) to internal
4127
+ * transformation data (pixels + EMUs).
4128
+ *
4129
+ * @param options - User-facing transformation in pixels
4130
+ * @returns Internal transformation data with both pixel and EMU values
4131
+ */
4132
+ const createTransformation = (options) => ({
4133
+ emus: {
4134
+ x: convertPixelsToEmu(options.width),
4135
+ y: convertPixelsToEmu(options.height)
4136
+ },
4137
+ flip: options.flip,
4138
+ offset: {
4139
+ emus: {
4140
+ x: convertPixelsToEmu(options.offset?.left ?? 0),
4141
+ y: convertPixelsToEmu(options.offset?.top ?? 0)
4142
+ },
4143
+ pixels: {
4144
+ x: Math.round(options.offset?.left ?? 0),
4145
+ y: Math.round(options.offset?.top ?? 0)
4146
+ }
4147
+ },
4148
+ pixels: {
4149
+ x: Math.round(options.width),
4150
+ y: Math.round(options.height)
4151
+ },
4152
+ rotation: options.rotation ? options.rotation * 6e4 : void 0
4153
+ });
4154
+ //#endregion
4155
+ export { xsdCompoundLine as $, LineJoin as A, hashedId as At, createNoFill as B, convertPixelsToEmu as Bt, createOuterShadowEffect as C, createSchemeColor as Ct, createFillOverlayEffect as D, createPresetColor as Dt, BlendMode as E, PresetColor as Et, LineEndType as F, convertEmuToPixels as Ft, PathShadeType as G, extractBlipFillMedia as H, LineEndWidth as I, convertEmuToPoints as It, createGradientStop as J, TileFlipMode as K, createLineEnd as L, convertInchesToEmu as Lt, PresetDash as M, uniqueNumericIdCreator as Mt, createOutline as N, uniqueUuid as Nt, CompoundLine as O, createHslColor as Ot, LineEndLength as P, convertEmuToInches as Pt, xsdBlendMode as Q, createCustomDash as R, convertInchesToTwip as Rt, RectAlignment as S, SchemeColor as St, createGlowEffect as T, createRgbColor as Tt, PresetPattern as U, buildFill as V, convertPointsToEmu as Vt, createPatternFill as W, createTileInfo as X, TileAlignment as Y, invertMap as Z, createEffectList as _, createBlipEffects as _t, createBlip as a, xsdPattern as at, PresetShadowVal as b, SystemColor as bt, PresetGeometry as c, xsdRectAlignment as ct, createShape3D as d, xsdTextAnchor as dt, xsdEffectContainer as et, BevelPresetType as f, xsdTextCaps as ft, createEffectDag as g, createSourceRectangle as gt, createScene3D as h, Stretch as ht, createBlipFill as i, xsdPathFillMode as it, PenAlignment as j, uniqueId as jt, LineCap as k, createColorTransforms as kt, createAdjustmentValues as l, xsdStrikeStyle as lt, createBottomBevel as m, xsdVerticalMergeRev as mt, createGroupTransform2D as n, xsdLineEndSize as nt, createExtentionList as o, xsdPenAlignment as ot, createBevel as p, xsdUnderlineStyle as pt, createGradientFill as q, createTransform2D as r, xsdMaterialType as rt, createCustomGeometry as s, xsdPresetShadow as st, createTransformation as t, xsdLineCap as tt, PresetMaterialType as u, xsdTextAlign as ut, createSoftEdgeEffect as v, createColorElement as vt, createInnerShadowEffect as w, createScRgbColor as wt, createPresetShadowEffect as x, createSystemColor as xt, createReflectionEffect as y, createSolidFill as yt, createGroupFill as z, convertMillimetersToTwip as zt };