@evotecit/officeimo 0.1.3 → 0.1.4

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.
@@ -1389,7 +1389,7 @@ const { captureFields } = _m10;
1389
1389
  /** @internal The workbook owner captures these settings before validation or adapter merging. */
1390
1390
  const workbookOptionFields = ["signal", "onProgress", "limits", "sink", "dateMode", "compression", "invalidCharacterPolicy", "appProperties", "cellValueWriters", "oversizedText", "creator", "title", "subject", "description", "created", "modified"];
1391
1391
  /** @internal Worksheet settings also used by the portable sheet owner. */
1392
- const sheetOptionFields = ["columns", "includeHeader", "headerRows", "freezeHeader", "autoFilter", "boldHeader", "headerFill", "headerStyle", "alternatingRowStyle", "rowStyle", "cellStyle", "rowOutline", "maxOutlineLevel", "rowHeight", "headerHeight", "defaultColumnWidth", "freezeColumns", "table", "autoSize", "footer", "print", "title", "mergedCells", "hyperlinks", "conditionalFormats", "dataValidation"];
1392
+ const sheetOptionFields = ["columns", "includeHeader", "headerRows", "freezeHeader", "autoFilter", "boldHeader", "headerFill", "headerStyle", "alternatingRowStyle", "rowStyle", "cellStyle", "rowOutline", "maxOutlineLevel", "outlineSummaryBelow", "outlineSummaryRight", "columnOutlines", "rowHeight", "headerHeight", "defaultColumnWidth", "freezeColumns", "table", "autoSize", "footer", "print", "title", "mergedCells", "hyperlinks", "conditionalFormats", "dataValidation"];
1393
1393
  /** @internal Includes inherited format-specific ceilings before a wrapper combines stream settings. */
1394
1394
  const workbookLimitFields = ["maxRows", "maxCells", "maxTextCharacters", "maxOutputBytes", "maxStyles", "maxSheets", "maxOverflowCharacters", "maxHyperlinks", "maxImageBytes", "maxBufferedCells", "maxBufferedCharacters", "maxMergedRanges", "maxConditionalFormats", "maxDifferentialStyles", "maxCharts", "maxChartPoints", "maxChartTextCharacters", "maxFormulaCharacters", "maxDataValidations", "maxValidationTextCharacters"];
1395
1395
  /** @internal Capture the workbook's known ceilings without dropping supported prototype fields. */
@@ -2092,7 +2092,16 @@ class OpcPackage {
2092
2092
  throw new OfficeIMOError("INVALID_STATE", "OPC package is finalized."); }
2093
2093
  reserve(uri, type) {
2094
2094
  this.open();
2095
+ // OPC part names become ZIP entry names. Reject oversized and deeply nested
2096
+ // names before collecting every ancestor prefix.
2097
+ if (typeof uri === "string" && uri.length > 65536)
2098
+ throw new OfficeIMOError("RESOURCE_LIMIT", "OPC part name exceeds the ZIP entry-name limit.");
2095
2099
  uri = partUri(uri);
2100
+ let depth = 0;
2101
+ for (let index = 0; index < uri.length; index++) {
2102
+ if (uri[index] === "/" && ++depth > 64)
2103
+ throw new OfficeIMOError("RESOURCE_LIMIT", "OPC part name exceeds the directory-depth limit.");
2104
+ }
2096
2105
  if (/\/_rels(?:\/|$)/i.test(uri) || uri.toLowerCase() === "/[content_types].xml")
2097
2106
  throw new TypeError("Package metadata part names are reserved.");
2098
2107
  const key = uri.toLowerCase();
@@ -2771,14 +2780,23 @@ function columnName(index) {
2771
2780
  return name;
2772
2781
  }
2773
2782
  function clipName(text, length) { return text.slice(0, length).replace(/[\ud800-\udbff]$/, ""); }
2783
+ function trimSheetNameEdges(text) {
2784
+ let start = 0, end = text.length;
2785
+ const removable = (character) => character === "'" || /\s/u.test(character);
2786
+ while (start < end && removable(text[start]))
2787
+ start++;
2788
+ while (end > start && removable(text[end - 1]))
2789
+ end--;
2790
+ return text.slice(start, end);
2791
+ }
2774
2792
  function sheetName(requested, names, policy, register = true) {
2775
2793
  if (typeof requested !== "string")
2776
2794
  throw new TypeError("Sheet name must be a string.");
2777
2795
  // Validate and deduplicate the decoded literal value, before ST_Xstring attribute encoding.
2778
2796
  // A requested _xHHHH_ token is literal text; the serializer protects its leading underscore.
2779
- let base = cleanXml(requested, policy).replace(/[\[\]:*?/\\]/g, "_").replace(/^[\s']+|[\s']+$/g, "");
2797
+ let base = trimSheetNameEdges(cleanXml(requested, policy).replace(/[\[\]:*?/\\]/g, "_"));
2780
2798
  // Clipping can expose an internal apostrophe or the reserved History name.
2781
- base = clipName(base, 31).replace(/[\s']+$/g, "");
2799
+ base = trimSheetNameEdges(clipName(base, 31));
2782
2800
  if (!base)
2783
2801
  base = "Sheet";
2784
2802
  if (base.toLowerCase() === "history")
@@ -2808,7 +2826,52 @@ const _exports = Object.freeze({ Cell: Cell, assertXlsxValue: assertXlsxValue, c
2808
2826
  return _exports;
2809
2827
  })();
2810
2828
 
2811
- const _m39 = (() => {
2829
+ const _m37 = (() => {
2830
+ const { captureFields } = _m10;
2831
+
2832
+ /** Capture bounded disjoint ranges before asynchronous serialization; absent columns stay visible. */
2833
+ function captureColumnOutlines(input, columns) {
2834
+ if (input === undefined)
2835
+ return undefined;
2836
+ if (!Array.isArray(input) || input.length > columns)
2837
+ throw new TypeError("Column outlines must be bounded, non-overlapping ranges.");
2838
+ let end = 0;
2839
+ return Object.freeze(input.map(range => {
2840
+ if (!range || typeof range !== "object")
2841
+ throw new TypeError("Column outlines require range metadata.");
2842
+ return captureFields(range, ["firstColumn", "columnCount", "level", "hidden", "collapsed"]);
2843
+ }).sort((a, b) => a.firstColumn - b.firstColumn).map(range => {
2844
+ const { firstColumn, columnCount, level = 0, hidden, collapsed } = range;
2845
+ if (!Number.isSafeInteger(firstColumn) || firstColumn < end || !Number.isSafeInteger(columnCount) || columnCount < 1 || firstColumn + columnCount > columns)
2846
+ throw new RangeError("Column outline ranges must be disjoint and within the declared columns.");
2847
+ if (!Number.isInteger(level) || level < 0 || level > 7)
2848
+ throw new RangeError("Column outline level must be from zero through seven.");
2849
+ for (const flag of [hidden, collapsed])
2850
+ if (flag !== undefined && typeof flag !== "boolean")
2851
+ throw new TypeError("Column outline flags must be booleans.");
2852
+ end = firstColumn + columnCount;
2853
+ return Object.freeze({ firstColumn, columnCount, level, ...(hidden === undefined ? {} : { hidden }), ...(collapsed === undefined ? {} : { collapsed }) });
2854
+ }));
2855
+ }
2856
+ /** @internal Positions are captured even when a sheet has only column outlines. */
2857
+ function validateOutlinePositions(options) {
2858
+ for (const flag of [options.outlineSummaryBelow, options.outlineSummaryRight])
2859
+ if (flag !== undefined && typeof flag !== "boolean")
2860
+ throw new TypeError("Outline summary positions must be booleans.");
2861
+ }
2862
+ /** @internal Resolve at most 16,384 columns once, without retaining any worksheet body. */
2863
+ function columnOutlineMap(ranges) {
2864
+ const result = new Map();
2865
+ for (const range of ranges ?? [])
2866
+ for (let index = range.firstColumn; index < range.firstColumn + range.columnCount; index++)
2867
+ result.set(index, range);
2868
+ return result;
2869
+ }
2870
+ const _exports = Object.freeze({ captureColumnOutlines: captureColumnOutlines, validateOutlinePositions: validateOutlinePositions, columnOutlineMap: columnOutlineMap });
2871
+ return _exports;
2872
+ })();
2873
+
2874
+ const _m40 = (() => {
2812
2875
  const { ChunkedTextSink } = _m3;
2813
2876
 
2814
2877
  const { escapeXml, xmlDeclaration } = _m28;
@@ -2920,14 +2983,14 @@ const _exports = Object.freeze({ chartNamespace: chartNamespace, chartContentTyp
2920
2983
  return _exports;
2921
2984
  })();
2922
2985
 
2923
- const _m38 = (() => {
2986
+ const _m39 = (() => {
2924
2987
  const { cleanXml, escapeXml, escapeOoxmlAttribute, xmlDeclaration } = _m28;
2925
2988
 
2926
2989
  const { copyExportLink } = _m7;
2927
2990
 
2928
2991
  const { officeRelationshipsNamespace } = _m25;
2929
2992
 
2930
- const { chartAnchorXml } = _m39;
2993
+ const { chartAnchorXml } = _m40;
2931
2994
 
2932
2995
  const { captureFields } = _m10;
2933
2996
 
@@ -2997,10 +3060,10 @@ const _exports = Object.freeze({ copyDrawingAnchor: copyDrawingAnchor, cellPosit
2997
3060
  return _exports;
2998
3061
  })();
2999
3062
 
3000
- const _m41 = (() => {
3063
+ const _m42 = (() => {
3001
3064
  const { OfficeIMOError } = _m2;
3002
3065
 
3003
- const { cellPosition } = _m38;
3066
+ const { cellPosition } = _m39;
3004
3067
 
3005
3068
  function indexRows(regions) {
3006
3069
  if (!regions.length)
@@ -3101,7 +3164,7 @@ const _exports = Object.freeze({ MergeRegions: MergeRegions });
3101
3164
  return _exports;
3102
3165
  })();
3103
3166
 
3104
- const _m42 = (() => {
3167
+ const _m43 = (() => {
3105
3168
  const { ExportCell } = _m5;
3106
3169
 
3107
3170
  const { tableSpans } = _m18;
@@ -3137,7 +3200,7 @@ const _exports = Object.freeze({ StructuredRows: StructuredRows });
3137
3200
  return _exports;
3138
3201
  })();
3139
3202
 
3140
- const _m40 = (() => {
3203
+ const _m41 = (() => {
3141
3204
  const { ExportCell } = _m5;
3142
3205
 
3143
3206
  const { isDate } = _m6;
@@ -3148,13 +3211,13 @@ const { FormulaCell } = _m36;
3148
3211
 
3149
3212
  const { escapeOoxmlAttribute } = _m28;
3150
3213
 
3151
- const { MergeRegions } = _m41;
3214
+ const { MergeRegions } = _m42;
3152
3215
 
3153
3216
  const { OfficeIMOError } = _m2;
3154
3217
 
3155
3218
  const { createTotals } = _m12;
3156
3219
 
3157
- const { StructuredRows } = _m42;
3220
+ const { StructuredRows } = _m43;
3158
3221
 
3159
3222
  /** @internal A computed formula with a numeric cache; no public arbitrary-formula input. */
3160
3223
  class ComputedTotal {
@@ -3337,7 +3400,7 @@ const _exports = Object.freeze({ ComputedTotal: ComputedTotal, ReportLayout: Rep
3337
3400
  return _exports;
3338
3401
  })();
3339
3402
 
3340
- const _m44 = (() => {
3403
+ const _m45 = (() => {
3341
3404
  const { columnName } = _m35;
3342
3405
 
3343
3406
  /** @internal Data-column selectors use stable keys or one-based worksheet columns. */
@@ -3367,7 +3430,7 @@ const _exports = Object.freeze({ resolveDataColumn: resolveDataColumn, qualified
3367
3430
  return _exports;
3368
3431
  })();
3369
3432
 
3370
- const _m45 = (() => {
3433
+ const _m46 = (() => {
3371
3434
  const { OfficeIMOError } = _m2;
3372
3435
 
3373
3436
  const { columnName } = _m35;
@@ -3413,18 +3476,18 @@ const _exports = Object.freeze({ retainDataRowRanges: retainDataRowRanges, dataR
3413
3476
  return _exports;
3414
3477
  })();
3415
3478
 
3416
- const _m43 = (() => {
3479
+ const _m44 = (() => {
3417
3480
  const { cleanXml, escapeXml, escapeOoxmlAttribute } = _m28;
3418
3481
 
3419
- const { cellPosition } = _m38;
3482
+ const { cellPosition } = _m39;
3420
3483
 
3421
3484
  const { colorArgb } = _m33;
3422
3485
 
3423
3486
  const { fields, optionalBoolean, differentialXml } = _m34;
3424
3487
 
3425
- const { resolveDataColumn } = _m44;
3488
+ const { resolveDataColumn } = _m45;
3426
3489
 
3427
- const { dataRowReference } = _m45;
3490
+ const { dataRowReference } = _m46;
3428
3491
 
3429
3492
  function target(range, columns) {
3430
3493
  if (typeof range === "string") {
@@ -3582,7 +3645,7 @@ const _exports = Object.freeze({ prepareConditionalFormats: prepareConditionalFo
3582
3645
  return _exports;
3583
3646
  })();
3584
3647
 
3585
- const _m46 = (() => {
3648
+ const _m47 = (() => {
3586
3649
  const { OfficeIMOError } = _m2;
3587
3650
 
3588
3651
  const { checkAbort } = _m4;
@@ -3591,9 +3654,9 @@ const { cleanXml, escapeOoxmlAttribute, escapeXml } = _m28;
3591
3654
 
3592
3655
  const { fields, optionalBoolean } = _m34;
3593
3656
 
3594
- const { resolveDataColumn } = _m44;
3657
+ const { resolveDataColumn } = _m45;
3595
3658
 
3596
- const { dataRowReference } = _m45;
3659
+ const { dataRowReference } = _m46;
3597
3660
 
3598
3661
  function message(value, maximum, name) {
3599
3662
  if (value === undefined)
@@ -3685,7 +3748,7 @@ const _exports = Object.freeze({ prepareDataValidations: prepareDataValidations,
3685
3748
  return _exports;
3686
3749
  })();
3687
3750
 
3688
- const _m37 = (() => {
3751
+ const _m38 = (() => {
3689
3752
  const { checkAbort, consumeRows, inputRows, pause, taskYieldDue } = _m4;
3690
3753
 
3691
3754
  const { ChunkedTextSink, BlobByteSink } = _m3;
@@ -3706,25 +3769,27 @@ const { Cell, cellText, columnName, inlineText, excelDate, copyValue } = _m35;
3706
3769
 
3707
3770
  const { spreadsheetNamespace, colorArgb, validateStylePatch, copyStylePatch } = _m32;
3708
3771
 
3709
- const { copyHyperlink, copyImage, hyperlinksXml, cellPosition } = _m38;
3772
+ const { copyHyperlink, copyImage, hyperlinksXml, cellPosition } = _m39;
3710
3773
 
3711
3774
  const { ExportCell, assertScalar } = _m5;
3712
3775
 
3713
- const { ReportLayout, ComputedTotal, printXml } = _m40;
3776
+ const { ReportLayout, ComputedTotal, printXml } = _m41;
3714
3777
 
3715
3778
  const { cleanXml } = _m28;
3716
3779
 
3717
- const { ConditionalFormats, prepareConditionalFormats } = _m43;
3780
+ const { ConditionalFormats, prepareConditionalFormats } = _m44;
3718
3781
 
3719
3782
  const { isDate } = _m6;
3720
3783
 
3721
3784
  const { FormulaCell, formulaXml, isSubtotalFormula } = _m36;
3722
3785
 
3723
- const { prepareDataValidations, dataValidationsXml } = _m46;
3786
+ const { prepareDataValidations, dataValidationsXml } = _m47;
3724
3787
 
3725
- const { qualifiedCell, qualifiedColumnRange, resolveDataColumn } = _m44;
3788
+ const { qualifiedCell, qualifiedColumnRange, resolveDataColumn } = _m45;
3726
3789
 
3727
- const { dataRowRanges, dataRowCount } = _m45;
3790
+ const { dataRowRanges, dataRowCount } = _m46;
3791
+
3792
+ const { captureColumnOutlines, columnOutlineMap, validateOutlinePositions } = _m37;
3728
3793
 
3729
3794
  const maximumHyperlinks = 65530;
3730
3795
  function checkHyperlinkCount(count) {
@@ -3856,6 +3921,8 @@ class Worksheet {
3856
3921
  throw new TypeError("Row and style callbacks must be functions.");
3857
3922
  if (options.maxOutlineLevel !== undefined && (!Number.isInteger(options.maxOutlineLevel) || options.maxOutlineLevel < 0 || options.maxOutlineLevel > 7))
3858
3923
  throw new RangeError("Maximum outline level must be an integer from zero through seven.");
3924
+ validateOutlinePositions(options);
3925
+ captureColumnOutlines(options.columnOutlines, columns.length);
3859
3926
  if (options.rowOutline && options.maxOutlineLevel === undefined)
3860
3927
  throw new TypeError("A row outline callback requires maxOutlineLevel before streamed rows are written.");
3861
3928
  if (!options.rowOutline && options.maxOutlineLevel !== undefined)
@@ -4140,17 +4207,22 @@ class Worksheet {
4140
4207
  const buffer = this.buffer = new ChunkedTextSink(this.entry, this.book.settings.signal), opts = this.options;
4141
4208
  const x = opts.freezeColumns ?? 0, y = opts.freezeHeader ? this.headerRows : 0;
4142
4209
  const pane = x && y ? "bottomRight" : x ? "topRight" : "bottomLeft", cell = columnName(x + 1) + (y + 1);
4210
+ const outlines = columnOutlineMap(opts.columnOutlines), hasOutline = !!opts.rowOutline || outlines.size > 0;
4211
+ const maxColumnLevel = Math.max(0, ...Array.from(outlines.values(), value => value.level ?? 0));
4143
4212
  await buffer.write(xmlDeclaration + '<worksheet xmlns="' + spreadsheetNamespace + '" xmlns:r="' + officeRelationshipsNamespace + '">' +
4144
- (opts.print || opts.rowOutline ? '<sheetPr>' + (opts.rowOutline ? '<outlinePr summaryBelow="1" showOutlineSymbols="1"/>' : "") + (opts.print ? '<pageSetUpPr fitToPage="1"/>' : "") + '</sheetPr>' : "") + '<sheetViews><sheetView workbookViewId="0">' +
4213
+ (opts.print || hasOutline ? '<sheetPr>' + (hasOutline ? '<outlinePr summaryBelow="' + (opts.outlineSummaryBelow === false ? "0" : "1") + '"' + (opts.outlineSummaryRight === undefined ? "" : ' summaryRight="' + (opts.outlineSummaryRight ? "1" : "0") + '"') + ' showOutlineSymbols="1"/>' : "") + (opts.print ? '<pageSetUpPr fitToPage="1"/>' : "") + '</sheetPr>' : "") + '<sheetViews><sheetView workbookViewId="0">' +
4145
4214
  (x || y ? '<pane' + (x ? ' xSplit="' + x + '"' : "") + (y ? ' ySplit="' + y + '"' : "") + ' topLeftCell="' + cell + '" activePane="' + pane + '" state="frozen"/><selection pane="' + pane + '" activeCell="' + cell + '" sqref="' + cell + '"/>' : "") + '</sheetView></sheetViews>' +
4146
- (opts.rowOutline ? '<sheetFormatPr defaultRowHeight="15" outlineLevelRow="' + opts.maxOutlineLevel + '"/>' : ""));
4215
+ (hasOutline ? '<sheetFormatPr defaultRowHeight="15"' + (opts.rowOutline ? ' outlineLevelRow="' + opts.maxOutlineLevel + '"' : "") + (outlines.size ? ' outlineLevelCol="' + maxColumnLevel + '"' : "") + '/>' : ""));
4147
4216
  const defaultWidth = opts.defaultColumnWidth ?? (this.table ? 20 : undefined);
4148
- if (this.columns.some((_, i) => this.layout.widths[i] !== undefined || defaultWidth !== undefined)) {
4217
+ if (this.columns.some((_, i) => this.layout.widths[i] !== undefined || defaultWidth !== undefined || outlines.has(i))) {
4149
4218
  await buffer.write('<cols>');
4150
4219
  for (let i = 0; i < this.columns.length; i++) {
4151
- const width = this.layout.widths[i] ?? defaultWidth;
4152
- if (width !== undefined)
4153
- await buffer.write('<col min="' + (i + 1) + '" max="' + (i + 1) + '" width="' + width + '" customWidth="1"/>');
4220
+ const width = this.layout.widths[i] ?? defaultWidth, outline = outlines.get(i);
4221
+ if (width !== undefined || outline)
4222
+ await buffer.write('<col min="' + (i + 1) + '" max="' + (i + 1) + '"' +
4223
+ (width === undefined ? "" : ' width="' + width + '" customWidth="1"') +
4224
+ (outline?.level ? ' outlineLevel="' + outline.level + '"' : "") + (outline?.hidden ? ' hidden="1"' : "") +
4225
+ (outline?.collapsed ? ' collapsed="1"' : "") + '/>');
4154
4226
  }
4155
4227
  await buffer.write('</cols>');
4156
4228
  }
@@ -4411,7 +4483,7 @@ const _exports = Object.freeze({ Worksheet: Worksheet });
4411
4483
  return _exports;
4412
4484
  })();
4413
4485
 
4414
- const _m47 = (() => {
4486
+ const _m48 = (() => {
4415
4487
  const { escapeOoxmlAttribute, escapeXml, xmlDeclaration } = _m28;
4416
4488
 
4417
4489
  const { cellText, columnName } = _m35;
@@ -4422,7 +4494,7 @@ const { ExportCell } = _m5;
4422
4494
 
4423
4495
  const { Cell } = _m35;
4424
4496
 
4425
- const { totalFormula } = _m40;
4497
+ const { totalFormula } = _m41;
4426
4498
 
4427
4499
  function defineTable(id, options, columns, policy) {
4428
4500
  const name = options.name ?? "Table" + id;
@@ -4457,7 +4529,7 @@ const _exports = Object.freeze({ defineTable: defineTable, tableXml: tableXml })
4457
4529
  return _exports;
4458
4530
  })();
4459
4531
 
4460
- const _m48 = (() => {
4532
+ const _m49 = (() => {
4461
4533
  const { OfficeIMOError } = _m2;
4462
4534
 
4463
4535
  const { cleanXml } = _m28;
@@ -4524,7 +4596,7 @@ const _exports = Object.freeze({ TextOverflow: TextOverflow, clipText: clipText
4524
4596
  return _exports;
4525
4597
  })();
4526
4598
 
4527
- const _m50 = (() => {
4599
+ const _m51 = (() => {
4528
4600
  const { checkAbort } = _m4;
4529
4601
 
4530
4602
  const { NotSupportedError, OfficeIMOError } = _m2;
@@ -4655,18 +4727,18 @@ const _exports = Object.freeze({ captureChartRange: captureChartRange, prepareCh
4655
4727
  return _exports;
4656
4728
  })();
4657
4729
 
4658
- const _m49 = (() => {
4730
+ const _m50 = (() => {
4659
4731
  const { checkAbort } = _m4;
4660
4732
 
4661
4733
  const { NotSupportedError, OfficeIMOError } = _m2;
4662
4734
 
4663
4735
  const { cleanXml } = _m28;
4664
4736
 
4665
- const { copyDrawingAnchor } = _m38;
4737
+ const { copyDrawingAnchor } = _m39;
4666
4738
 
4667
4739
  const { captureFields } = _m10;
4668
4740
 
4669
- const { captureChartRange, prepareChartBinding } = _m50;
4741
+ const { captureChartRange, prepareChartBinding } = _m51;
4670
4742
 
4671
4743
  function fields(value, allowed, context) {
4672
4744
  if (!value || typeof value !== "object" || Array.isArray(value))
@@ -4848,25 +4920,27 @@ const { copyColumns } = _m11;
4848
4920
 
4849
4921
  const { captureFields } = _m10;
4850
4922
 
4923
+ const { captureColumnOutlines } = _m37;
4924
+
4851
4925
  const { captureTableSpans } = _m18;
4852
4926
 
4853
4927
  const { assertExportValue } = _m5;
4854
4928
 
4855
- const { Worksheet } = _m37;
4929
+ const { Worksheet } = _m38;
4856
4930
 
4857
- const { defineTable, tableXml } = _m47;
4931
+ const { defineTable, tableXml } = _m48;
4858
4932
 
4859
- const { copyHyperlink, drawingXml, drawingContentType } = _m38;
4933
+ const { copyHyperlink, drawingXml, drawingContentType } = _m39;
4860
4934
 
4861
- const { TextOverflow } = _m48;
4935
+ const { TextOverflow } = _m49;
4862
4936
 
4863
4937
  const { captureWorkbookOptions, sheetOptionFields } = _m22;
4864
4938
 
4865
- const { prepareChart } = _m49;
4939
+ const { prepareChart } = _m50;
4866
4940
 
4867
- const { qualifiedColumnRange, resolveDataColumn } = _m44;
4941
+ const { qualifiedColumnRange, resolveDataColumn } = _m45;
4868
4942
 
4869
- const { chartContentType, writeChartXml } = _m39;
4943
+ const { chartContentType, writeChartXml } = _m40;
4870
4944
 
4871
4945
  const xlsxMime = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
4872
4946
  const formatType = (name) => "application/vnd.openxmlformats-officedocument.spreadsheetml." + name + "+xml";
@@ -4877,6 +4951,7 @@ function captureSheet(options, policy) {
4877
4951
  const footer = captured.footer && captureFields(captured.footer, ["rows", "values", "totals", "style"]);
4878
4952
  const print = captured.print && captureFields(captured.print, ["paper", "orientation", "fitToWidth", "fitToHeight", "repeatHeaders", "margins", "header", "footer"]);
4879
4953
  return { ...captured, columns,
4954
+ ...(captured.columnOutlines === undefined ? {} : { columnOutlines: captureColumnOutlines(captured.columnOutlines, columns.length) }),
4880
4955
  ...(captured.headerRows === undefined ? {} : { headerRows: captureTableSpans(captured.headerRows, columns.length) }),
4881
4956
  ...(footer ? { footer: { ...footer,
4882
4957
  ...(footer.rows === undefined ? {} : { rows: captureTableSpans(footer.rows, columns.length) }),
@@ -5306,7 +5381,7 @@ const _exports = Object.freeze({ Workbook: Workbook });
5306
5381
  return _exports;
5307
5382
  })();
5308
5383
 
5309
- const _m52 = (() => {
5384
+ const _m53 = (() => {
5310
5385
  const { ExportCell, assertScalar } = _m5;
5311
5386
 
5312
5387
  const { captureWorkbookOptions, sheetOptionFields } = _m22;
@@ -5358,14 +5433,14 @@ const _exports = Object.freeze({ portableSheet: portableSheet, portableWorkbook:
5358
5433
  return _exports;
5359
5434
  })();
5360
5435
 
5361
- const _m51 = (() => {
5436
+ const _m52 = (() => {
5362
5437
  const { withDestination } = _m3;
5363
5438
 
5364
5439
  const { copyColumns } = _m11;
5365
5440
 
5366
5441
  const { Workbook } = _m24;
5367
5442
 
5368
- const { portableSheet, portableWorkbook } = _m52;
5443
+ const { portableSheet, portableWorkbook } = _m53;
5369
5444
 
5370
5445
  const { captureFields } = _m10;
5371
5446
 
@@ -5416,7 +5491,7 @@ const _exports = Object.freeze({ writeXlsx: writeXlsx, writeXlsxTo: writeXlsxTo
5416
5491
  return _exports;
5417
5492
  })();
5418
5493
 
5419
- const _m54 = (() => {
5494
+ const _m55 = (() => {
5420
5495
  const { assertGroupedReportSource } = _m8;
5421
5496
 
5422
5497
  const { captureFields } = _m10;
@@ -5427,9 +5502,9 @@ const { fields } = _m34;
5427
5502
 
5428
5503
  const { sheetOptionFields } = _m22;
5429
5504
 
5430
- const { portableSheet } = _m52;
5505
+ const { portableSheet } = _m53;
5431
5506
 
5432
- const { resolveDataColumn } = _m44;
5507
+ const { resolveDataColumn } = _m45;
5433
5508
 
5434
5509
  const { copyStylePatch } = _m32;
5435
5510
 
@@ -5508,7 +5583,7 @@ const _exports = Object.freeze({ groupedOptionFields: groupedOptionFields, prepa
5508
5583
  return _exports;
5509
5584
  })();
5510
5585
 
5511
- const _m53 = (() => {
5586
+ const _m54 = (() => {
5512
5587
  const { groupedReportOperation } = _m8;
5513
5588
 
5514
5589
  const { checkAbort, withAbort } = _m4;
@@ -5525,9 +5600,9 @@ const { columnName } = _m35;
5525
5600
 
5526
5601
  const { captureWorkbookLimits, workbookOptionFields } = _m22;
5527
5602
 
5528
- const { retainDataRowRanges } = _m45;
5603
+ const { retainDataRowRanges } = _m46;
5529
5604
 
5530
- const { groupedOptionFields, prepareGroupedSheet } = _m54;
5605
+ const { groupedOptionFields, prepareGroupedSheet } = _m55;
5531
5606
 
5532
5607
  const subtotalOperations = { average: 1, count: 2, max: 4, min: 5, sum: 9 };
5533
5608
  function label(value) {
@@ -5686,11 +5761,11 @@ return _exports;
5686
5761
 
5687
5762
  const _m23 = (() => {
5688
5763
 
5689
- const _exports = Object.freeze({ Workbook: _m24.Workbook, writeXlsx: _m51.writeXlsx, writeXlsxTo: _m51.writeXlsxTo, writeGroupedXlsx: _m53.writeGroupedXlsx, writeGroupedXlsxTo: _m53.writeGroupedXlsxTo, addGroupedXlsx: _m53.addGroupedXlsx, createGroupedReport: _m8.createGroupedReport, Worksheet: _m37.Worksheet, Cell: _m35.Cell, FormulaCell: _m36.FormulaCell, StyleRegistry: _m32.StyleRegistry, NumberFormats: _m32.NumberFormats, saveBlob: _m1.saveBlob, ExportCell: _m5.ExportCell });
5764
+ const _exports = Object.freeze({ Workbook: _m24.Workbook, writeXlsx: _m52.writeXlsx, writeXlsxTo: _m52.writeXlsxTo, writeGroupedXlsx: _m54.writeGroupedXlsx, writeGroupedXlsxTo: _m54.writeGroupedXlsxTo, addGroupedXlsx: _m54.addGroupedXlsx, createGroupedReport: _m8.createGroupedReport, Worksheet: _m38.Worksheet, Cell: _m35.Cell, FormulaCell: _m36.FormulaCell, StyleRegistry: _m32.StyleRegistry, NumberFormats: _m32.NumberFormats, saveBlob: _m1.saveBlob, ExportCell: _m5.ExportCell });
5690
5765
  return _exports;
5691
5766
  })();
5692
5767
 
5693
- const _m56 = (() => {
5768
+ const _m57 = (() => {
5694
5769
  const { captureTableSpans, tableSpans } = _m18;
5695
5770
 
5696
5771
  /** Snapshot small report matrices; flattening is an explicit format decision, never inferred from labels. */
@@ -5711,7 +5786,7 @@ const _exports = Object.freeze({ csvStructuredRows: csvStructuredRows });
5711
5786
  return _exports;
5712
5787
  })();
5713
5788
 
5714
- const _m55 = (() => {
5789
+ const _m56 = (() => {
5715
5790
  const { beginTask, checkAbort, consumeRows, taskYieldDue, withAbort } = _m4;
5716
5791
 
5717
5792
  const { BlobByteSink, ChunkedTextSink, withDestination } = _m3;
@@ -5726,7 +5801,7 @@ const { notifyProgress } = _m14;
5726
5801
 
5727
5802
  const { copyColumns, createRowProjector } = _m11;
5728
5803
 
5729
- const { csvStructuredRows } = _m56;
5804
+ const { csvStructuredRows } = _m57;
5730
5805
 
5731
5806
  const { captureBooleanText } = _m21;
5732
5807
 
@@ -5864,7 +5939,7 @@ const _exports = Object.freeze({ saveBlob: _m1.saveBlob, ExportCell: _m5.ExportC
5864
5939
  return _exports;
5865
5940
  })();
5866
5941
 
5867
- const _m61 = (() => {
5942
+ const _m62 = (() => {
5868
5943
  /** @internal One type byte, an eight-byte offset/container number and a two-byte generation/index. */
5869
5944
  const pdfXrefEntryBytes = 11;
5870
5945
  function unsigned(bytes, offset, value, width) {
@@ -5899,12 +5974,12 @@ const _exports = Object.freeze({ pdfXrefEntryBytes: pdfXrefEntryBytes, pdfXrefCh
5899
5974
  return _exports;
5900
5975
  })();
5901
5976
 
5902
- const _m60 = (() => {
5977
+ const _m61 = (() => {
5903
5978
  const { checkAbort, withAbort, pause, taskYieldDue } = _m4;
5904
5979
 
5905
5980
  const { OfficeIMOError } = _m2;
5906
5981
 
5907
- const { pdfXrefChunks, pdfXrefEntryBytes } = _m61;
5982
+ const { pdfXrefChunks, pdfXrefEntryBytes } = _m62;
5908
5983
 
5909
5984
  const compactObjectCount = 256, compactObjectBytes = 32768;
5910
5985
  const compactIndexChunkEntries = 4096;
@@ -6227,7 +6302,7 @@ const _exports = Object.freeze({ pdfNumber: pdfNumber, unicodeHex: unicodeHex, P
6227
6302
  return _exports;
6228
6303
  })();
6229
6304
 
6230
- const _m65 = (() => {
6305
+ const _m66 = (() => {
6231
6306
  /** @internal Bounded big-endian reader used for caller-provided TrueType programs. */
6232
6307
  class FontReader {
6233
6308
  bytes;
@@ -6256,8 +6331,8 @@ const _exports = Object.freeze({ FontReader: FontReader, checksum: checksum, ali
6256
6331
  return _exports;
6257
6332
  })();
6258
6333
 
6259
- const _m66 = (() => {
6260
- const { align4 } = _m65;
6334
+ const _m67 = (() => {
6335
+ const { align4 } = _m66;
6261
6336
 
6262
6337
  const { checkAbort, pause, taskYieldDue } = _m4;
6263
6338
 
@@ -6480,12 +6555,12 @@ const _exports = Object.freeze({ subsetTrueType: subsetTrueType, subsetTrueTypeC
6480
6555
  return _exports;
6481
6556
  })();
6482
6557
 
6483
- const _m64 = (() => {
6558
+ const _m65 = (() => {
6484
6559
  const { NotSupportedError } = _m2;
6485
6560
 
6486
- const { FontReader } = _m65;
6561
+ const { FontReader } = _m66;
6487
6562
 
6488
- const { subsetTrueType, subsetTrueTypeCooperatively } = _m66;
6563
+ const { subsetTrueType, subsetTrueTypeCooperatively } = _m67;
6489
6564
 
6490
6565
  const { checkAbort, pause, taskYieldDue } = _m4;
6491
6566
 
@@ -6724,8 +6799,8 @@ const _exports = Object.freeze({ TrueTypeFont: TrueTypeFont });
6724
6799
  return _exports;
6725
6800
  })();
6726
6801
 
6727
- const _m63 = (() => {
6728
- const { TrueTypeFont } = _m64;
6802
+ const _m64 = (() => {
6803
+ const { TrueTypeFont } = _m65;
6729
6804
 
6730
6805
  const { beginTask, checkAbort } = _m4;
6731
6806
 
@@ -6787,7 +6862,7 @@ const _exports = Object.freeze({ fontProgram: fontProgram, PdfFont: PdfFont });
6787
6862
  return _exports;
6788
6863
  })();
6789
6864
 
6790
- const _m68 = (() => {
6865
+ const _m69 = (() => {
6791
6866
  // Generated by scripts/pdf-widths.mjs from OfficeIMO.Pdf's Adobe AFM-derived metrics.
6792
6867
  const helveticaWidths = new Map([
6793
6868
  [32, [278, 278]],
@@ -7109,12 +7184,12 @@ const _exports = Object.freeze({ helveticaWidths: helveticaWidths });
7109
7184
  return _exports;
7110
7185
  })();
7111
7186
 
7112
- const _m67 = (() => {
7187
+ const _m68 = (() => {
7113
7188
  const { OfficeIMOError } = _m2;
7114
7189
 
7115
- const { PdfFont, fontProgram } = _m63;
7190
+ const { PdfFont, fontProgram } = _m64;
7116
7191
 
7117
- const { helveticaWidths } = _m68;
7192
+ const { helveticaWidths } = _m69;
7118
7193
 
7119
7194
  const winAnsiExtras = new Map([0x20ac, 0, 0x201a, 0x192, 0x201e, 0x2026, 0x2020, 0x2021, 0x2c6, 0x2030, 0x160, 0x2039, 0x152, 0, 0x17d, 0, 0, 0x2018, 0x2019, 0x201c, 0x201d, 0x2022, 0x2013, 0x2014, 0x2dc, 0x2122, 0x161, 0x203a, 0x153, 0, 0x17e, 0x178].map((cp, i) => [cp, i + 128]));
7120
7195
  /** @internal Called after scalar support succeeds when encoding a standard-font run. */
@@ -7177,14 +7252,14 @@ const _exports = Object.freeze({ standardCode: standardCode, resolveScalar: reso
7177
7252
  return _exports;
7178
7253
  })();
7179
7254
 
7180
- const _m62 = (() => {
7255
+ const _m63 = (() => {
7181
7256
  const { NotSupportedError, OfficeIMOError } = _m2;
7182
7257
 
7183
- const { fontProgram } = _m63;
7258
+ const { fontProgram } = _m64;
7184
7259
 
7185
- const { resolveScalar, selectFont, standardCode, validateFonts } = _m67;
7260
+ const { resolveScalar, selectFont, standardCode, validateFonts } = _m68;
7186
7261
 
7187
- const { pdfNumber, unicodeHex } = _m60;
7262
+ const { pdfNumber, unicodeHex } = _m61;
7188
7263
 
7189
7264
  const { checkAbort, pause, taskYieldDue } = _m4;
7190
7265
 
@@ -7408,7 +7483,7 @@ const _exports = Object.freeze({ PdfFontResource: PdfFontResource, PdfFontResour
7408
7483
  return _exports;
7409
7484
  })();
7410
7485
 
7411
- const _m70 = (() => {
7486
+ const _m71 = (() => {
7412
7487
  const { OfficeIMOError } = _m2;
7413
7488
 
7414
7489
  const { ExportCell, assertExportValue } = _m5;
@@ -7519,7 +7594,7 @@ const _exports = Object.freeze({ pdfBudgetText: pdfBudgetText, synchronousText:
7519
7594
  return _exports;
7520
7595
  })();
7521
7596
 
7522
- const _m72 = (() => {
7597
+ const _m73 = (() => {
7523
7598
  const { NotSupportedError, OfficeIMOError } = _m2;
7524
7599
 
7525
7600
  const { checkAbort, pause, taskYieldDue, withAbort } = _m4;
@@ -7731,7 +7806,7 @@ const _exports = Object.freeze({ wrapShapedPdfText: wrapShapedPdfText });
7731
7806
  return _exports;
7732
7807
  })();
7733
7808
 
7734
- const _m71 = (() => {
7809
+ const _m72 = (() => {
7735
7810
  const { NotSupportedError, OfficeIMOError } = _m2;
7736
7811
 
7737
7812
  const { copyExportLink } = _m7;
@@ -7740,11 +7815,11 @@ const { checkAbort, pause, taskYieldDue } = _m4;
7740
7815
 
7741
7816
  const { presentation, color } = _m17;
7742
7817
 
7743
- const { wrapShapedPdfText } = _m72;
7818
+ const { wrapShapedPdfText } = _m73;
7744
7819
 
7745
- const { PdfFont } = _m63;
7820
+ const { PdfFont } = _m64;
7746
7821
 
7747
- const { pdfBudgetText } = _m70;
7822
+ const { pdfBudgetText } = _m71;
7748
7823
 
7749
7824
  /** @internal Callers supply an owned, validated, frozen base presentation. A run list is a PDF presentation value, never an alternate shared table value model. */
7750
7825
  function capturePdfText(value, base, settings, fonts, countEmpty = true, reserveBudget = true) {
@@ -7926,10 +8001,10 @@ const _exports = Object.freeze({ capturePdfText: capturePdfText, wrapPdfText: wr
7926
8001
  return _exports;
7927
8002
  })();
7928
8003
 
7929
- const _m73 = (() => {
8004
+ const _m74 = (() => {
7930
8005
  const { OfficeIMOError } = _m2;
7931
8006
 
7932
- const { wrapPdfText } = _m71;
8007
+ const { wrapPdfText } = _m72;
7933
8008
 
7934
8009
  /** Plan without opening a source. Exact column widths never shrink in band mode. */
7935
8010
  function planTableBands(widths, settings) {
@@ -8024,7 +8099,7 @@ const _exports = Object.freeze({ planTableBands: planTableBands, projectBandRows
8024
8099
  return _exports;
8025
8100
  })();
8026
8101
 
8027
- const _m69 = (() => {
8102
+ const _m70 = (() => {
8028
8103
  const { ExportCell } = _m5;
8029
8104
 
8030
8105
  const { copyExportLink } = _m7;
@@ -8035,11 +8110,11 @@ const { createTotals } = _m12;
8035
8110
 
8036
8111
  const { presentation, positive } = _m17;
8037
8112
 
8038
- const { displayText, pdfBudgetText } = _m70;
8113
+ const { displayText, pdfBudgetText } = _m71;
8039
8114
 
8040
- const { capturePdfText, wrapPdfText } = _m71;
8115
+ const { capturePdfText, wrapPdfText } = _m72;
8041
8116
 
8042
- const { planTableBands, projectBandRows, alignBandBlocks } = _m73;
8117
+ const { planTableBands, projectBandRows, alignBandBlocks } = _m74;
8043
8118
 
8044
8119
  class PdfTableLayout {
8045
8120
  settings;
@@ -8258,7 +8333,7 @@ const _exports = Object.freeze({ PdfTableLayout: PdfTableLayout });
8258
8333
  return _exports;
8259
8334
  })();
8260
8335
 
8261
- const _m75 = (() => {
8336
+ const _m76 = (() => {
8262
8337
  const { OfficeIMOError } = _m2;
8263
8338
 
8264
8339
  const { checkAbort } = _m4;
@@ -8399,7 +8474,7 @@ const _exports = Object.freeze({ PdfTableBandFlow: PdfTableBandFlow });
8399
8474
  return _exports;
8400
8475
  })();
8401
8476
 
8402
- const _m76 = (() => {
8477
+ const _m77 = (() => {
8403
8478
  /** @internal Source-cell identities survive page fragments and horizontal band projections.
8404
8479
  * Only column headers and still-owned row objects remain reachable from this table owner. */
8405
8480
  class PdfTableStructure {
@@ -8513,10 +8588,10 @@ const _exports = Object.freeze({ PdfTableStructure: PdfTableStructure });
8513
8588
  return _exports;
8514
8589
  })();
8515
8590
 
8516
- const _m77 = (() => {
8591
+ const _m78 = (() => {
8517
8592
  const { OfficeIMOError } = _m2;
8518
8593
 
8519
- const { pdfNumber, unicodeHex } = _m60;
8594
+ const { pdfNumber, unicodeHex } = _m61;
8520
8595
 
8521
8596
  const encoder = new TextEncoder();
8522
8597
  /** @internal URI actions are byte strings; tooltips are Unicode PDF text strings. */
@@ -8558,10 +8633,10 @@ const _exports = Object.freeze({ linkAnnotation: linkAnnotation });
8558
8633
  return _exports;
8559
8634
  })();
8560
8635
 
8561
- const _m78 = (() => {
8636
+ const _m79 = (() => {
8562
8637
  const { OfficeIMOError } = _m2;
8563
8638
 
8564
- const { unicodeHex } = _m60;
8639
+ const { unicodeHex } = _m61;
8565
8640
 
8566
8641
  const { captureFields } = _m10;
8567
8642
 
@@ -8606,7 +8681,7 @@ const _exports = Object.freeze({ captureBookmark: captureBookmark, captureSectio
8606
8681
  return _exports;
8607
8682
  })();
8608
8683
 
8609
- const _m79 = (() => {
8684
+ const _m80 = (() => {
8610
8685
  const { settings } = _m17;
8611
8686
 
8612
8687
  /** @internal Every section derives from captured document defaults, never the preceding section. */
@@ -8624,28 +8699,28 @@ const _exports = Object.freeze({ sectionSettings: sectionSettings });
8624
8699
  return _exports;
8625
8700
  })();
8626
8701
 
8627
- const _m74 = (() => {
8702
+ const _m75 = (() => {
8628
8703
  const { OfficeIMOError } = _m2;
8629
8704
 
8630
8705
  const { checkAbort } = _m4;
8631
8706
 
8632
- const { pdfNumber } = _m60;
8707
+ const { pdfNumber } = _m61;
8633
8708
 
8634
8709
  const { color } = _m17;
8635
8710
 
8636
- const { PdfTableBandFlow } = _m75;
8711
+ const { PdfTableBandFlow } = _m76;
8637
8712
 
8638
- const { PdfTableStructure } = _m76;
8713
+ const { PdfTableStructure } = _m77;
8639
8714
 
8640
- const { wrapText, wrapTextCooperatively, synchronousText, pdfBudgetText } = _m70;
8715
+ const { wrapText, wrapTextCooperatively, synchronousText, pdfBudgetText } = _m71;
8641
8716
 
8642
- const { linkAnnotation } = _m77;
8717
+ const { linkAnnotation } = _m78;
8643
8718
 
8644
- const { unicodeHex } = _m60;
8719
+ const { unicodeHex } = _m61;
8645
8720
 
8646
- const { captureSection, captureBookmark } = _m78;
8721
+ const { captureSection, captureBookmark } = _m79;
8647
8722
 
8648
- const { sectionSettings } = _m79;
8723
+ const { sectionSettings } = _m80;
8649
8724
 
8650
8725
  /** @internal One page of drawing commands and O(page count) references, never the complete report body. */
8651
8726
  class PdfPages {
@@ -9365,7 +9440,7 @@ const _exports = Object.freeze({ PdfPages: PdfPages });
9365
9440
  return _exports;
9366
9441
  })();
9367
9442
 
9368
- const _m81 = (() => {
9443
+ const _m82 = (() => {
9369
9444
  /** @internal Incremental PDF number tree: at most 64 entries/children per retained level. */
9370
9445
  class PdfParentTree {
9371
9446
  objects;
@@ -9427,14 +9502,14 @@ const _exports = Object.freeze({ PdfParentTree: PdfParentTree });
9427
9502
  return _exports;
9428
9503
  })();
9429
9504
 
9430
- const _m80 = (() => {
9505
+ const _m81 = (() => {
9431
9506
  const { OfficeIMOError } = _m2;
9432
9507
 
9433
9508
  const { checkAbort } = _m4;
9434
9509
 
9435
- const { unicodeHex } = _m60;
9510
+ const { unicodeHex } = _m61;
9436
9511
 
9437
- const { PdfParentTree } = _m81;
9512
+ const { PdfParentTree } = _m82;
9438
9513
 
9439
9514
  /** Same-page marked content uses integer K; cross-page MCR and annotation OBJR stay explicit. */
9440
9515
  function structureChild(child) {
@@ -9738,12 +9813,12 @@ const _exports = Object.freeze({ PdfStructure: PdfStructure, graphicAlternative:
9738
9813
  return _exports;
9739
9814
  })();
9740
9815
 
9741
- const _m82 = (() => {
9816
+ const _m83 = (() => {
9742
9817
  const { OfficeIMOError } = _m2;
9743
9818
 
9744
9819
  const { checkAbort } = _m4;
9745
9820
 
9746
- const { pdfNumber, unicodeHex } = _m60;
9821
+ const { pdfNumber, unicodeHex } = _m61;
9747
9822
 
9748
9823
  /** @internal Bounded native bookmarks; destinations are captured only when their content is painted. */
9749
9824
  class PdfOutlines {
@@ -9801,18 +9876,18 @@ const _exports = Object.freeze({ PdfOutlines: PdfOutlines });
9801
9876
  return _exports;
9802
9877
  })();
9803
9878
 
9804
- const _m59 = (() => {
9805
- const { PdfObjects, unicodeHex } = _m60;
9879
+ const _m60 = (() => {
9880
+ const { PdfObjects, unicodeHex } = _m61;
9806
9881
 
9807
- const { PdfFontResources } = _m62;
9882
+ const { PdfFontResources } = _m63;
9808
9883
 
9809
- const { PdfTableLayout } = _m69;
9884
+ const { PdfTableLayout } = _m70;
9810
9885
 
9811
- const { PdfPages } = _m74;
9886
+ const { PdfPages } = _m75;
9812
9887
 
9813
- const { PdfStructure } = _m80;
9888
+ const { PdfStructure } = _m81;
9814
9889
 
9815
- const { PdfOutlines } = _m82;
9890
+ const { PdfOutlines } = _m83;
9816
9891
 
9817
9892
  /** One resource/catalog owner shared by table convenience exports and composed documents. */
9818
9893
  class PdfWriteSession {
@@ -9867,7 +9942,7 @@ const _exports = Object.freeze({ PdfWriteSession: PdfWriteSession });
9867
9942
  return _exports;
9868
9943
  })();
9869
9944
 
9870
- const _m58 = (() => {
9945
+ const _m59 = (() => {
9871
9946
  const { BlobByteSink, withDestination } = _m3;
9872
9947
 
9873
9948
  const { beginTask, checkAbort, consumeRows, pause, taskYieldDue } = _m4;
@@ -9878,7 +9953,7 @@ const { createRowProjector } = _m11;
9878
9953
 
9879
9954
  const { settings } = _m17;
9880
9955
 
9881
- const { PdfWriteSession } = _m59;
9956
+ const { PdfWriteSession } = _m60;
9882
9957
 
9883
9958
  async function writePdf(rows, configuration) {
9884
9959
  const sink = new BlobByteSink();
@@ -9935,7 +10010,7 @@ const _exports = Object.freeze({ writePdf: writePdf, writePdfTo: writePdfTo });
9935
10010
  return _exports;
9936
10011
  })();
9937
10012
 
9938
- const _m86 = (() => {
10013
+ const _m87 = (() => {
9939
10014
  const { NotSupportedError, OfficeIMOError } = _m2;
9940
10015
 
9941
10016
  const { checkAbort, pause, taskYieldDue, withAbort } = _m4;
@@ -10202,12 +10277,12 @@ const _exports = Object.freeze({ pngPixels: pngPixels });
10202
10277
  return _exports;
10203
10278
  })();
10204
10279
 
10205
- const _m85 = (() => {
10280
+ const _m86 = (() => {
10206
10281
  const { NotSupportedError, OfficeIMOError } = _m2;
10207
10282
 
10208
10283
  const { checkAbort, pause, taskYieldDue } = _m4;
10209
10284
 
10210
- const { pngPixels } = _m86;
10285
+ const { pngPixels } = _m87;
10211
10286
 
10212
10287
  /** Shared document image resources; source objects are captured on first consumption. */
10213
10288
  class PdfDocumentImages {
@@ -10335,14 +10410,14 @@ const _exports = Object.freeze({ PdfDocumentImages: PdfDocumentImages });
10335
10410
  return _exports;
10336
10411
  })();
10337
10412
 
10338
- const _m87 = (() => {
10413
+ const _m88 = (() => {
10339
10414
  const { OfficeIMOError } = _m2;
10340
10415
 
10341
10416
  const { checkAbort, pause, taskYieldDue } = _m4;
10342
10417
 
10343
10418
  const { color, positive } = _m17;
10344
10419
 
10345
- const { pdfNumber: n } = _m60;
10420
+ const { pdfNumber: n } = _m61;
10346
10421
 
10347
10422
  /** Capture and serialize one bounded display path, with no markup parser or resource loading. */
10348
10423
  async function vectorCommands(block, settings, used) {
@@ -10421,14 +10496,14 @@ const _exports = Object.freeze({ vectorCommands: vectorCommands });
10421
10496
  return _exports;
10422
10497
  })();
10423
10498
 
10424
- const _m88 = (() => {
10499
+ const _m89 = (() => {
10425
10500
  const { NotSupportedError, OfficeIMOError } = _m2;
10426
10501
 
10427
10502
  const { checkAbort, pause, taskYieldDue } = _m4;
10428
10503
 
10429
10504
  const { color, positive } = _m17;
10430
10505
 
10431
- const { pdfNumber: n } = _m60;
10506
+ const { pdfNumber: n } = _m61;
10432
10507
 
10433
10508
  /** Portable drawings are an exact schema: unsupported data must never be silently discarded. */
10434
10509
  function record(value, keys, name) {
@@ -10667,20 +10742,20 @@ const _exports = Object.freeze({ checkDrawingBlock: checkDrawingBlock, prepareDr
10667
10742
  return _exports;
10668
10743
  })();
10669
10744
 
10670
- const _m89 = (() => {
10745
+ const _m90 = (() => {
10671
10746
  const { OfficeIMOError } = _m2;
10672
10747
 
10673
- const { capturePdfText, wrapPdfText } = _m71;
10748
+ const { capturePdfText, wrapPdfText } = _m72;
10674
10749
 
10675
10750
  const { positive } = _m17;
10676
10751
 
10677
10752
  const { resolveParagraphStyle } = _m19;
10678
10753
 
10679
- const { captureBookmark } = _m78;
10754
+ const { captureBookmark } = _m79;
10680
10755
 
10681
10756
  const { captureFields } = _m10;
10682
10757
 
10683
- const { pdfBudgetText } = _m70;
10758
+ const { pdfBudgetText } = _m71;
10684
10759
 
10685
10760
  /** @internal Copy public paragraph input before any cooperative layout or source enumeration. */
10686
10761
  function captureParagraph(block, settings, fonts, budgetOnPaint = false) {
@@ -10750,10 +10825,10 @@ const _exports = Object.freeze({ captureParagraph: captureParagraph, captureCapt
10750
10825
  return _exports;
10751
10826
  })();
10752
10827
 
10753
- const _m90 = (() => {
10754
- const { capturePdfText, wrapPdfText } = _m71;
10828
+ const _m91 = (() => {
10829
+ const { capturePdfText, wrapPdfText } = _m72;
10755
10830
 
10756
- const { captureParagraph, prepareParagraph } = _m89;
10831
+ const { captureParagraph, prepareParagraph } = _m90;
10757
10832
 
10758
10833
  const { resolveParagraphStyle } = _m19;
10759
10834
 
@@ -10807,7 +10882,7 @@ const _exports = Object.freeze({ captureListOptions: captureListOptions, prepare
10807
10882
  return _exports;
10808
10883
  })();
10809
10884
 
10810
- const _m92 = (() => {
10885
+ const _m93 = (() => {
10811
10886
  const { assertGroupedReportSource } = _m8;
10812
10887
 
10813
10888
  const { captureFields } = _m10;
@@ -10856,22 +10931,22 @@ const _exports = Object.freeze({ groupedPdfLabelFields: groupedPdfLabelFields, g
10856
10931
  return _exports;
10857
10932
  })();
10858
10933
 
10859
- const _m91 = (() => {
10934
+ const _m92 = (() => {
10860
10935
  const { assertGroupedReportSource, groupedReportOperation } = _m8;
10861
10936
 
10862
10937
  const { consumeRows } = _m4;
10863
10938
 
10864
10939
  const { ExportCell } = _m5;
10865
10940
 
10866
- const { captureGroupedPdfTableOptions } = _m92;
10941
+ const { captureGroupedPdfTableOptions } = _m93;
10867
10942
 
10868
10943
  const { settings } = _m17;
10869
10944
 
10870
- const { PdfTableLayout } = _m69;
10945
+ const { PdfTableLayout } = _m70;
10871
10946
 
10872
- const { captureCaption, captureParagraph, prepareParagraph } = _m89;
10947
+ const { captureCaption, captureParagraph, prepareParagraph } = _m90;
10873
10948
 
10874
- const { synchronousText } = _m70;
10949
+ const { synchronousText } = _m71;
10875
10950
 
10876
10951
  /** @internal Render one analytical source in the existing document session. Retain one detail row and
10877
10952
  * at most four closing subtotals. All captions, rows, pages, bytes and fonts use the document owners. */
@@ -11113,7 +11188,7 @@ const _exports = Object.freeze({ renderGroupedPdfTable: renderGroupedPdfTable })
11113
11188
  return _exports;
11114
11189
  })();
11115
11190
 
11116
- const _m84 = (() => {
11191
+ const _m85 = (() => {
11117
11192
  const { BlobByteSink, withDestination } = _m3;
11118
11193
 
11119
11194
  const { OfficeIMOError } = _m2;
@@ -11128,27 +11203,27 @@ const { captureFields } = _m10;
11128
11203
 
11129
11204
  const { settings, captureWideTable } = _m17;
11130
11205
 
11131
- const { pdfNumber: n } = _m60;
11206
+ const { pdfNumber: n } = _m61;
11132
11207
 
11133
- const { PdfTableLayout } = _m69;
11208
+ const { PdfTableLayout } = _m70;
11134
11209
 
11135
- const { PdfWriteSession } = _m59;
11210
+ const { PdfWriteSession } = _m60;
11136
11211
 
11137
- const { PdfDocumentImages } = _m85;
11212
+ const { PdfDocumentImages } = _m86;
11138
11213
 
11139
- const { vectorCommands } = _m87;
11214
+ const { vectorCommands } = _m88;
11140
11215
 
11141
- const { graphicAlternative } = _m80;
11216
+ const { graphicAlternative } = _m81;
11142
11217
 
11143
- const { checkDrawingBlock, prepareDrawing } = _m88;
11218
+ const { checkDrawingBlock, prepareDrawing } = _m89;
11144
11219
 
11145
- const { captureParagraph, captureCaption, prepareParagraph, checkParagraphBuffer, paragraphStartHeight } = _m89;
11220
+ const { captureParagraph, captureCaption, prepareParagraph, checkParagraphBuffer, paragraphStartHeight } = _m90;
11146
11221
 
11147
- const { captureListOptions, prepareListItem } = _m90;
11222
+ const { captureListOptions, prepareListItem } = _m91;
11148
11223
 
11149
- const { captureSection } = _m78;
11224
+ const { captureSection } = _m79;
11150
11225
 
11151
- const { renderGroupedPdfTable } = _m91;
11226
+ const { renderGroupedPdfTable } = _m92;
11152
11227
 
11153
11228
  const tableOptionFields = ["columns", "includeHeader", "headerRows", "footer", "headerPresentation", "footerPresentation", "alternateRowColor", "columnWidths", "wideTable", "formatValue", "formatRuns"];
11154
11229
  /** Capture typed columns for a single-use table source in a composed document. */
@@ -11406,18 +11481,18 @@ const _exports = Object.freeze({ pdfTable: pdfTable, writePdfDocument: writePdfD
11406
11481
  return _exports;
11407
11482
  })();
11408
11483
 
11409
- const _m83 = (() => {
11484
+ const _m84 = (() => {
11410
11485
  const { assertGroupedReportSource } = _m8;
11411
11486
 
11412
11487
  const { BlobByteSink } = _m3;
11413
11488
 
11414
- const { writePdfDocumentTo } = _m84;
11489
+ const { writePdfDocumentTo } = _m85;
11415
11490
 
11416
11491
  const { pdfOptionFields } = _m17;
11417
11492
 
11418
11493
  const { captureFields } = _m10;
11419
11494
 
11420
- const { pdfGroupedTable, groupedPdfLabelFields, groupedPdfTableFields } = _m92;
11495
+ const { pdfGroupedTable, groupedPdfLabelFields, groupedPdfTableFields } = _m93;
11421
11496
 
11422
11497
 
11423
11498
 
@@ -11451,14 +11526,14 @@ async function writeGroupedPdfTo(report, destination, configuration) {
11451
11526
  delete documentOptions.footer;
11452
11527
  return writePdfDocumentTo([pdfGroupedTable(report, tableOptions)], destination, documentOptions);
11453
11528
  }
11454
- const _exports = Object.freeze({ pdfGroupedTable: _m92.pdfGroupedTable, writeGroupedPdf: writeGroupedPdf, writeGroupedPdfTo: writeGroupedPdfTo });
11529
+ const _exports = Object.freeze({ pdfGroupedTable: _m93.pdfGroupedTable, writeGroupedPdf: writeGroupedPdf, writeGroupedPdfTo: writeGroupedPdfTo });
11455
11530
  return _exports;
11456
11531
  })();
11457
11532
 
11458
- const _m93 = (() => {
11459
- const { fontProgram } = _m63;
11533
+ const _m94 = (() => {
11534
+ const { fontProgram } = _m64;
11460
11535
 
11461
- const { resolveScalar, selectFont, validateFonts } = _m67;
11536
+ const { resolveScalar, selectFont, validateFonts } = _m68;
11462
11537
 
11463
11538
  /**
11464
11539
  * Check one text run against the writer's selected font and scalar-layout rules.
@@ -11494,13 +11569,107 @@ const _exports = Object.freeze({ preflightPdfText: preflightPdfText });
11494
11569
  return _exports;
11495
11570
  })();
11496
11571
 
11497
- const _m57 = (() => {
11572
+ const _m58 = (() => {
11498
11573
 
11499
- const _exports = Object.freeze({ writePdf: _m58.writePdf, writePdfTo: _m58.writePdfTo, writeGroupedPdf: _m83.writeGroupedPdf, writeGroupedPdfTo: _m83.writeGroupedPdfTo, pdfGroupedTable: _m83.pdfGroupedTable, createGroupedReport: _m8.createGroupedReport, writePdfDocument: _m84.writePdfDocument, writePdfDocumentTo: _m84.writePdfDocumentTo, pdfTable: _m84.pdfTable, PdfFont: _m63.PdfFont, preflightPdfText: _m93.preflightPdfText, ExportCell: _m5.ExportCell, saveBlob: _m1.saveBlob });
11574
+ const _exports = Object.freeze({ writePdf: _m59.writePdf, writePdfTo: _m59.writePdfTo, writeGroupedPdf: _m84.writeGroupedPdf, writeGroupedPdfTo: _m84.writeGroupedPdfTo, pdfGroupedTable: _m84.pdfGroupedTable, createGroupedReport: _m8.createGroupedReport, writePdfDocument: _m85.writePdfDocument, writePdfDocumentTo: _m85.writePdfDocumentTo, pdfTable: _m85.pdfTable, PdfFont: _m64.PdfFont, preflightPdfText: _m94.preflightPdfText, ExportCell: _m5.ExportCell, saveBlob: _m1.saveBlob });
11500
11575
  return _exports;
11501
11576
  })();
11502
11577
 
11503
11578
  const _m95 = (() => {
11579
+ /** One policy for capture diagnostics and unsupported adapter mappings; callbacks stay synchronous. */
11580
+ function canopyDiagnostics(format, options) {
11581
+ const policy = options.unsupportedPresentation ?? (format === "csv" ? "text" : "reject"), notify = options.onDiagnostic;
11582
+ if (policy !== "reject" && policy !== "text")
11583
+ throw new TypeError("unsupportedPresentation must be reject or text.");
11584
+ if (notify !== undefined && typeof notify !== "function")
11585
+ throw new TypeError("onDiagnostic must be a synchronous function.");
11586
+ return diagnostic => {
11587
+ if (policy === "reject")
11588
+ throw new TypeError("Unsupported Canopy presentation: " + diagnostic.code + (diagnostic.columnId ? " (" + diagnostic.columnId + ")" : ""));
11589
+ const result = notify?.(Object.freeze(diagnostic));
11590
+ if (result && typeof result.then === "function") {
11591
+ void Promise.resolve(result).catch(() => { });
11592
+ throw new TypeError("onDiagnostic must be synchronous.");
11593
+ }
11594
+ };
11595
+ }
11596
+ const _exports = Object.freeze({ canopyDiagnostics: canopyDiagnostics });
11597
+ return _exports;
11598
+ })();
11599
+
11600
+ const _m97 = (() => {
11601
+ function presentation(input, axes) {
11602
+ const { axisKey, outlineLevel, summary, grandTotal, hidden, collapsed } = input;
11603
+ if (typeof axisKey !== "string" || !axes.has(axisKey) || !Number.isInteger(outlineLevel) || outlineLevel < 0 || outlineLevel > 7 ||
11604
+ [summary, grandTotal, hidden, collapsed].some(flag => typeof flag !== "boolean"))
11605
+ throw new TypeError("Invalid frozen Canopy pivot axis presentation.");
11606
+ return Object.freeze({ level: outlineLevel, hidden: hidden, collapsed: collapsed });
11607
+ }
11608
+ /** Qualify the explicit pivot path before flat/grouped handling; never evaluate query or aggregate data. */
11609
+ function canopyPivot(request) {
11610
+ if (request.pivot === undefined)
11611
+ return undefined;
11612
+ const pivot = request.pivot;
11613
+ if (!pivot || typeof pivot !== "object" || request.grouping !== undefined || !Array.isArray(request.columns) ||
11614
+ request.scope !== "filtered" || !Number.isSafeInteger(request.recordCount) || request.recordCount < 0 ||
11615
+ !pivot.definition || !Array.isArray(pivot.definition.rows) || pivot.definition.rows.length > 4 ||
11616
+ !Array.isArray(pivot.definition.columns) || pivot.definition.columns.length > 2 ||
11617
+ !Array.isArray(pivot.definition.values) || !pivot.definition.values.length || pivot.definition.values.length > 32 ||
11618
+ pivot.definition.values.some(value => typeof value !== "string") ||
11619
+ !Number.isSafeInteger(pivot.distinctColumns) || pivot.distinctColumns < 0 || typeof pivot.columnsLimited !== "boolean" ||
11620
+ !Array.isArray(pivot.retainedColumns) || !Array.isArray(pivot.columnGroups))
11621
+ throw new TypeError("Invalid explicit Canopy pivot descriptor.");
11622
+ const axes = (nodes) => {
11623
+ if (!Array.isArray(nodes) || nodes.length > 100001)
11624
+ throw new TypeError("Pivot axes require bounded accepted identities.");
11625
+ const keys = new Set();
11626
+ for (const node of nodes) {
11627
+ if (!node || typeof node.key !== "string" || !node.key || keys.has(node.key) || !Array.isArray(node.path) || typeof node.other !== "boolean")
11628
+ throw new TypeError("Invalid or duplicate Canopy pivot axis identity.");
11629
+ keys.add(node.key);
11630
+ }
11631
+ for (const node of nodes)
11632
+ if (node.parent !== undefined && !keys.has(node.parent))
11633
+ throw new TypeError("Unknown Canopy pivot parent identity.");
11634
+ return keys;
11635
+ };
11636
+ const rowKeys = axes(pivot.rowAxis), columnKeys = axes(pivot.columnAxis);
11637
+ const columns = request.columns.map((column, index) => {
11638
+ if (index === 0 && column.axisKey === undefined && column.kind === "text")
11639
+ return Object.freeze({ ...column });
11640
+ const outline = presentation(column, columnKeys);
11641
+ return Object.freeze({ ...column, outlineLevel: outline.level, hidden: outline.hidden, collapsed: outline.collapsed });
11642
+ });
11643
+ // Ranges are descriptor metadata, not another body. Validate them against the same ordered columns.
11644
+ if (pivot.columnGroups.length > columns.length)
11645
+ throw new RangeError("Pivot column group count exceeds projected columns.");
11646
+ for (const group of pivot.columnGroups) {
11647
+ if (!group || !columnKeys.has(group.key) || !Number.isSafeInteger(group.firstColumn) || group.firstColumn < 0 ||
11648
+ !Number.isSafeInteger(group.columnCount) || group.columnCount < 1 || group.firstColumn + group.columnCount > columns.length ||
11649
+ !Number.isInteger(group.depth) || group.depth < 1 || group.depth > 7 ||
11650
+ typeof group.hidden !== "boolean" || typeof group.collapsed !== "boolean")
11651
+ throw new TypeError("Invalid Canopy pivot column range.");
11652
+ }
11653
+ let current;
11654
+ const sheet = Object.freeze({ outlineSummaryBelow: false, outlineSummaryRight: false,
11655
+ maxOutlineLevel: 7, rowOutline: () => current,
11656
+ columnOutlines: Object.freeze(columns.flatMap((column, firstColumn) => column.axisKey === undefined ? [] :
11657
+ [Object.freeze({ firstColumn, columnCount: 1, level: column.outlineLevel, hidden: column.hidden, collapsed: column.collapsed })])) });
11658
+ return Object.freeze({ columns: Object.freeze(columns), sheet,
11659
+ observe(row) { current = presentation(row, rowKeys); } });
11660
+ }
11661
+ /** Per-cell formats preserve already-computed fractional percentages, ranks and differences. */
11662
+ function pivotNumberFormat(cell) {
11663
+ if (!["value", "percentGrandTotal", "percentParent", "percentColumn", "percentRow", "runningTotal", "rank", "difference", "percentChange"].includes(cell.mode ?? "") ||
11664
+ typeof cell.numberFormat !== "string" || !cell.numberFormat.length)
11665
+ throw new TypeError("Numeric pivot cells require a frozen mode and native numberFormat.");
11666
+ return cell.numberFormat;
11667
+ }
11668
+ const _exports = Object.freeze({ canopyPivot: canopyPivot, pivotNumberFormat: pivotNumberFormat });
11669
+ return _exports;
11670
+ })();
11671
+
11672
+ const _m98 = (() => {
11504
11673
  /** @internal Typed conversion follows declared datetime intent, never localized display text. */
11505
11674
  function datetime(value, mode, clock) {
11506
11675
  if (mode === "text")
@@ -11539,29 +11708,7 @@ const _exports = Object.freeze({ datetime: datetime });
11539
11708
  return _exports;
11540
11709
  })();
11541
11710
 
11542
- const _m96 = (() => {
11543
- /** One policy for capture diagnostics and unsupported adapter mappings; callbacks stay synchronous. */
11544
- function canopyDiagnostics(format, options) {
11545
- const policy = options.unsupportedPresentation ?? (format === "csv" ? "text" : "reject"), notify = options.onDiagnostic;
11546
- if (policy !== "reject" && policy !== "text")
11547
- throw new TypeError("unsupportedPresentation must be reject or text.");
11548
- if (notify !== undefined && typeof notify !== "function")
11549
- throw new TypeError("onDiagnostic must be a synchronous function.");
11550
- return diagnostic => {
11551
- if (policy === "reject")
11552
- throw new TypeError("Unsupported Canopy presentation: " + diagnostic.code + (diagnostic.columnId ? " (" + diagnostic.columnId + ")" : ""));
11553
- const result = notify?.(Object.freeze(diagnostic));
11554
- if (result && typeof result.then === "function") {
11555
- void Promise.resolve(result).catch(() => { });
11556
- throw new TypeError("onDiagnostic must be synchronous.");
11557
- }
11558
- };
11559
- }
11560
- const _exports = Object.freeze({ canopyDiagnostics: canopyDiagnostics });
11561
- return _exports;
11562
- })();
11563
-
11564
- const _m97 = (() => {
11711
+ const _m99 = (() => {
11565
11712
  /** Calibri 11, 96-DPI CSS pixels, seven-pixel maximum digit and five-pixel cell padding.
11566
11713
  * Quantize to native 1/256-character units; this is a reproducible profile, not pixel-identical rendering. */
11567
11714
  function canopyXlsxWidth(pixels) {
@@ -11606,10 +11753,12 @@ const _exports = Object.freeze({ canopyXlsxWidth: canopyXlsxWidth, canopyNumberF
11606
11753
  return _exports;
11607
11754
  })();
11608
11755
 
11609
- const _m94 = (() => {
11756
+ const _m96 = (() => {
11610
11757
  const { ExportCell, checkAbort, inputRows } = _m1;
11611
11758
 
11612
- const { datetime } = _m95;
11759
+ const { canopyPivot, pivotNumberFormat } = _m97;
11760
+
11761
+ const { datetime } = _m98;
11613
11762
 
11614
11763
  const { captureFields } = _m10;
11615
11764
 
@@ -11617,11 +11766,19 @@ const { copyColumns } = _m11;
11617
11766
 
11618
11767
  const { copyCellPresentation } = _m5;
11619
11768
 
11620
- const { canopyDiagnostics } = _m96;
11769
+ const { canopyDiagnostics } = _m95;
11621
11770
 
11622
- const { canopyNumberFormat, canopyXlsxWidth } = _m97;
11771
+ const { canopyNumberFormat, canopyXlsxWidth } = _m99;
11623
11772
 
11624
11773
  const columnFields = ["width", "format", "wrapText", "alignment", "rowHeader", "groups"];
11774
+ const rawIdentities = new WeakMap();
11775
+ /** @internal Grouping uses captured identity even when a detail cell displays a relative-link label. */
11776
+ function canopyIdentityValue(value) {
11777
+ if (!(value instanceof ExportCell))
11778
+ return value;
11779
+ const original = rawIdentities.get(value);
11780
+ return original === undefined ? value.value : original;
11781
+ }
11625
11782
  /** Map an immutable CanopyX record capture to a writer without querying the grid or retaining its body. */
11626
11783
  function createCanopyExport(capture, format, options = {}) {
11627
11784
  return prepareCanopyExport(capture, format, options).source;
@@ -11633,12 +11790,16 @@ function prepareCanopyExport(capture, format, options = {}) {
11633
11790
  throw new TypeError("Canopy export format must be xlsx, csv or pdf.");
11634
11791
  if (!capture || typeof capture.rows !== "function" || !capture.request)
11635
11792
  throw new TypeError("A portable CanopyX capture with request and rows() is required.");
11636
- const request = captureFields(capture.request, ["columns", "recordCount", "values", "presentation", "timeZone", "revision", "scope", "total", "matched", "selection", "query", "generatedAt", "grouping", "formatRules"]);
11793
+ const request = captureFields(capture.request, ["columns", "recordCount", "values", "presentation", "timeZone", "revision", "scope", "total", "matched", "selection", "query", "generatedAt", "grouping", "pivot", "formatRules"]);
11794
+ const pivot = canopyPivot(request);
11637
11795
  const signal = options.signal, values = request.values;
11638
11796
  if (!Array.isArray(request.columns) || !request.columns.length || (request.recordCount !== null && (!Number.isSafeInteger(request.recordCount) || request.recordCount < 0)) ||
11639
11797
  (values !== "raw" && values !== "display") || (request.timeZone !== "utc" && request.timeZone !== "local") || typeof request.revision !== "string")
11640
11798
  throw new TypeError("Invalid portable CanopyX capture metadata.");
11641
11799
  const dateMode = options.datetime ?? "preserve", report = canopyDiagnostics(format, options);
11800
+ // These captured presentations have a complete scalar/text projection. Report
11801
+ // their visual loss without treating an ordinary report export as unsupported.
11802
+ const fallback = canopyDiagnostics(format, { ...options, unsupportedPresentation: "text" });
11642
11803
  const clock = options.xlsx?.dateMode ?? request.timeZone;
11643
11804
  if (clock !== "utc" && clock !== "local")
11644
11805
  throw new TypeError("XLSX dateMode must be utc or local.");
@@ -11649,8 +11810,10 @@ function prepareCanopyExport(capture, format, options = {}) {
11649
11810
  return;
11650
11811
  if (!Array.isArray(items) || items.some(item => typeof item !== "string"))
11651
11812
  throw new TypeError("Canopy presentation diagnostics must be strings.");
11652
- for (const code of items)
11653
- report({ code, ...(rowId === undefined ? {} : { rowId }), ...(columnId === undefined ? {} : { columnId }) });
11813
+ for (const code of items) {
11814
+ const diagnostic = { code, ...(rowId === undefined ? {} : { rowId }), ...(columnId === undefined ? {} : { columnId }) };
11815
+ (code === "relative-link" || code === "history-series" ? fallback : report)(diagnostic);
11816
+ }
11654
11817
  };
11655
11818
  if (request.presentation !== "text" && request.presentation !== "semantic")
11656
11819
  throw new TypeError("Canopy captures must declare text or semantic presentation.");
@@ -11666,11 +11829,11 @@ function prepareCanopyExport(capture, format, options = {}) {
11666
11829
  throw new TypeError("Canopy tones must be strings.");
11667
11830
  const style = tones.get(name);
11668
11831
  if (!style && name !== "neutral")
11669
- report({ code: "UNMAPPED_TONE:" + name, rowId, ...(columnId === undefined ? {} : { columnId }) });
11832
+ fallback({ code: "UNMAPPED_TONE:" + name, rowId, ...(columnId === undefined ? {} : { columnId }) });
11670
11833
  return style;
11671
11834
  };
11672
11835
  const ids = new Set();
11673
- const specs = request.columns.map(input => {
11836
+ const specs = (pivot?.columns ?? request.columns).map(input => {
11674
11837
  const fields = captureFields(input, ["id", "title", "kind", "width", "pinned", "format", "wrap", "alignment", "diagnostics"]);
11675
11838
  const column = Object.freeze({ ...fields,
11676
11839
  ...(fields.width === undefined ? {} : { width: Object.freeze(captureFields(fields.width, ["unit", "preferred", "minimum", "maximum"])) }),
@@ -11681,7 +11844,7 @@ function prepareCanopyExport(capture, format, options = {}) {
11681
11844
  (column.width !== undefined && (column.width.unit !== "css-px" || !Number.isFinite(column.width.preferred) ||
11682
11845
  !Number.isFinite(column.width.minimum) || column.width.minimum <= 0 || column.width.preferred < column.width.minimum ||
11683
11846
  column.width.maximum !== undefined && (!Number.isFinite(column.width.maximum) || column.width.maximum < column.width.preferred))) ||
11684
- (request.presentation === "semantic" && (column.wrap === undefined || column.alignment === undefined || column.width === undefined)))
11847
+ (!pivot && request.presentation === "semantic" && (column.wrap === undefined || column.alignment === undefined || column.width === undefined)))
11685
11848
  throw new TypeError("Invalid or duplicate Canopy export column.");
11686
11849
  ids.add(column.id);
11687
11850
  diagnostics(column.diagnostics, undefined, column.id);
@@ -11690,16 +11853,20 @@ function prepareCanopyExport(capture, format, options = {}) {
11690
11853
  if (!columnFields.includes(key))
11691
11854
  throw new TypeError("Unsupported Canopy column option: " + key);
11692
11855
  const override = captureFields(selected, columnFields);
11693
- const numericFormat = format === "xlsx" && values === "raw" && column.kind === "number" && column.format !== undefined && override.format === undefined
11856
+ const numericFormat = (format === "xlsx" || format === "pdf") && values === "raw" && column.kind === "number" && column.format !== undefined && override.format === undefined
11694
11857
  ? canopyNumberFormat(column.format, report, column.id) : undefined;
11695
11858
  const [captured] = copyColumns([{ ...override, key: column.id, header: column.title,
11696
11859
  ...(format === "xlsx" && override.width === undefined && column.width !== undefined ? { width: canopyXlsxWidth(column.width.preferred) } : {}),
11697
11860
  ...(override.format === undefined && numericFormat !== undefined ? { format: numericFormat } : {}),
11698
11861
  ...(format === "xlsx" && values === "raw" && column.kind === "datetime" && override.format === undefined ? { format: "yyyy-mm-dd hh:mm:ss.000" } : {}),
11699
11862
  ...(values === "raw" && column.kind === "number" ? { type: "number" } : {}),
11700
- ...(override.wrapText === undefined && column.wrap === undefined ? {} : { wrapText: override.wrapText ?? column.wrap }),
11701
- ...(override.alignment === undefined && column.alignment === undefined ? {} : { alignment: override.alignment ?? column.alignment }) }]);
11702
- return Object.freeze({ id: column.id, kind: column.kind, input: column, column: Object.freeze(captured) });
11863
+ // Screen nowrap is not a promise that its CSS width will survive PDF fitting.
11864
+ // PDF defaults to lossless wrapping; an explicit writer override stays strict.
11865
+ ...(format === "pdf" ? { wrapText: override.wrapText ?? true } :
11866
+ override.wrapText === undefined && column.wrap === undefined ? {} : { wrapText: override.wrapText ?? column.wrap }),
11867
+ ...(override.alignment === undefined && column.alignment === undefined ?
11868
+ format === "pdf" && column.kind === "number" ? { alignment: "right" } : {} : { alignment: override.alignment ?? column.alignment }) }]);
11869
+ return Object.freeze({ id: column.id, kind: column.kind, input: column, nativeFormatOverride: override.format, column: Object.freeze(captured) });
11703
11870
  });
11704
11871
  const rowCount = request.recordCount;
11705
11872
  const source = Object.freeze({ columns: Object.freeze(specs.map(spec => spec.column)), rowCount, async *rows() {
@@ -11709,6 +11876,7 @@ function prepareCanopyExport(capture, format, options = {}) {
11709
11876
  checkAbort(signal);
11710
11877
  if (!row || typeof row.id !== "string" || !row.cells || typeof row.cells !== "object")
11711
11878
  throw new TypeError("Invalid Canopy export record.");
11879
+ pivot?.observe(row);
11712
11880
  diagnostics(row.diagnostics, row.id);
11713
11881
  const rowStyle = tone(row.tone, row.id), result = [];
11714
11882
  for (const spec of specs) {
@@ -11720,13 +11888,29 @@ function prepareCanopyExport(capture, format, options = {}) {
11720
11888
  (typeof cell.value === "number" && (!Number.isFinite(cell.value) || Math.abs(cell.value) > Number.MAX_SAFE_INTEGER)))
11721
11889
  throw new TypeError("A portable Canopy GridExportCell with scalar value and resolved text is required.");
11722
11890
  diagnostics(cell.diagnostics, row.id, spec.id);
11723
- let value = values === "display" ? cell.text : cell.value;
11891
+ // A relative destination is navigation metadata, not the visible label.
11892
+ // History captures already carry their frozen latest scalar (or null).
11893
+ const relativeLabel = spec.kind === "text" && cell.diagnostics?.includes("relative-link");
11894
+ let value = values === "display" || relativeLabel ? cell.text : cell.value;
11724
11895
  if (format === "xlsx" && values === "raw" && spec.kind === "datetime" && typeof value === "string")
11725
11896
  value = datetime(value, dateMode, clock);
11726
- const cellStyle = tone(cell.tone, row.id, spec.id), presentation = rowStyle || cellStyle ? { ...rowStyle, ...cellStyle } : undefined;
11897
+ const capturedFormat = pivot && spec.kind === "number" && cell.value !== null ? pivotNumberFormat(cell) : undefined;
11898
+ const nativeFormat = capturedFormat === undefined ? undefined : spec.nativeFormatOverride === "" ? "General" : spec.nativeFormatOverride ?? capturedFormat;
11899
+ const summary = format === "pdf" && pivot && (row.summary || row.grandTotal);
11900
+ const cellStyle = tone(cell.tone, row.id, spec.id), presentation = rowStyle || cellStyle || nativeFormat || summary ? {
11901
+ ...rowStyle, ...(summary ? { bold: true } : {}), ...cellStyle,
11902
+ ...((format === "xlsx" || format === "pdf") && values === "raw" && nativeFormat !== undefined ? { numberFormat: nativeFormat } : {})
11903
+ } : undefined;
11727
11904
  // CSV has no presentation or link metadata: emit its selected scalar directly.
11728
11905
  // This also avoids a frozen wrapper for every cell in large CSV captures.
11729
- result.push(format === "csv" ? value : new ExportCell(value, { text: cell.text, ...(presentation ? { presentation } : {}), ...(cell.link === undefined ? {} : { link: cell.link }) }));
11906
+ if (format === "csv")
11907
+ result.push(value);
11908
+ else {
11909
+ const exported = new ExportCell(value, { text: cell.text, ...(presentation ? { presentation } : {}), ...(cell.link === undefined ? {} : { link: cell.link }) });
11910
+ if (relativeLabel)
11911
+ rawIdentities.set(exported, cell.value);
11912
+ result.push(exported);
11913
+ }
11730
11914
  }
11731
11915
  if (rowCount !== null && count >= rowCount)
11732
11916
  throw new TypeError("Canopy capture exceeded its declared recordCount.");
@@ -11736,18 +11920,18 @@ function prepareCanopyExport(capture, format, options = {}) {
11736
11920
  if (rowCount !== null && count !== rowCount)
11737
11921
  throw new TypeError("Canopy capture did not produce its declared recordCount.");
11738
11922
  } });
11739
- return Object.freeze({ source, request: Object.freeze({ ...request, columns: Object.freeze(specs.map(spec => spec.input)) }), report, tones });
11923
+ return Object.freeze({ source, request: Object.freeze({ ...request, columns: Object.freeze(specs.map(spec => spec.input)) }), report, tones, pivot });
11740
11924
  }
11741
- const _exports = Object.freeze({ createCanopyExport: createCanopyExport, prepareCanopyExport: prepareCanopyExport });
11925
+ const _exports = Object.freeze({ canopyIdentityValue: canopyIdentityValue, createCanopyExport: createCanopyExport, prepareCanopyExport: prepareCanopyExport });
11742
11926
  return _exports;
11743
11927
  })();
11744
11928
 
11745
- const _m99 = (() => {
11929
+ const _m101 = (() => {
11746
11930
  const { columnName, excelDate } = _m35;
11747
11931
 
11748
11932
  const { captureFields } = _m10;
11749
11933
 
11750
- const { datetime } = _m95;
11934
+ const { datetime } = _m98;
11751
11935
 
11752
11936
  /** Compile only comparisons whose raw types and native encodings have a faithful bounded mapping. */
11753
11937
  function canopyPredicate(request, grouped, options, root, unsupported, cellTypes) {
@@ -11860,10 +12044,10 @@ const _exports = Object.freeze({ canopyPredicate: canopyPredicate });
11860
12044
  return _exports;
11861
12045
  })();
11862
12046
 
11863
- const _m98 = (() => {
12047
+ const _m100 = (() => {
11864
12048
  const { captureFields } = _m10;
11865
12049
 
11866
- const { canopyPredicate } = _m99;
12050
+ const { canopyPredicate } = _m101;
11867
12051
 
11868
12052
  // Stable document palette. Browser CSS variables and resolved cell.format are never interpreted.
11869
12053
  const palette = {
@@ -12043,21 +12227,21 @@ const _exports = Object.freeze({ canopyRules: canopyRules });
12043
12227
  return _exports;
12044
12228
  })();
12045
12229
 
12046
- const _m100 = (() => {
12230
+ const _m102 = (() => {
12047
12231
  const { createGroupedReport } = _m8;
12048
12232
 
12049
- const { ExportCell } = _m5;
12050
-
12051
12233
  const { checkAbort } = _m4;
12052
12234
 
12053
12235
  const { createTotals } = _m12;
12054
12236
 
12055
12237
  const { captureFields } = _m10;
12056
12238
 
12057
- const { datetime } = _m95;
12239
+ const { datetime } = _m98;
12240
+
12241
+ const { canopyIdentityValue } = _m96;
12058
12242
 
12059
12243
  const identity = (value) => value instanceof Date ? "date:" + value.getTime() : typeof value + ":" + String(value);
12060
- const scalar = (value) => value instanceof ExportCell ? value.value : value;
12244
+ const scalar = canopyIdentityValue;
12061
12245
  /** Validate captured ranges, then use the owned grouping factory and its existing writers.
12062
12246
  * Only ranges, labels and at most four active aggregate vectors are retained; no detail body is buffered. */
12063
12247
  function canopyGrouped(source, request, options, limits, report, format) {
@@ -12224,10 +12408,20 @@ function canopyGrouped(source, request, options, limits, report, format) {
12224
12408
  }
12225
12409
  verify(grand, grandExpected);
12226
12410
  }
12411
+ // The factory's hidden fields keep raw group identity separate from projected
12412
+ // detail labels. Never override a declared output column's value getter.
12413
+ const groupKeys = new Set([...source.columns.map(column => column.key), ...levels.map(level => level.column)]);
12227
12414
  const groupBy = levels.map((level, depth) => {
12228
- const visible = source.columns.some(column => column.key === level.column);
12229
- return { key: level.column,
12230
- ...(visible ? {} : { value: (_row, context) => at(depth, context.rowIndex).value }),
12415
+ const column = source.columns.findIndex(column => column.key === level.column);
12416
+ let key = level.column;
12417
+ if (column >= 0) {
12418
+ do {
12419
+ key += "#raw";
12420
+ } while (groupKeys.has(key));
12421
+ groupKeys.add(key);
12422
+ }
12423
+ return { key,
12424
+ value: (row, context) => column < 0 ? at(depth, context.rowIndex).value : scalar(row[column]),
12231
12425
  label: (value) => labels[depth].get(identity(value)) ?? String(value ?? "") };
12232
12426
  });
12233
12427
  const sourceLimits = limits === undefined ? undefined : {
@@ -12242,7 +12436,7 @@ const _exports = Object.freeze({ canopyGrouped: canopyGrouped });
12242
12436
  return _exports;
12243
12437
  })();
12244
12438
 
12245
- const _m101 = (() => {
12439
+ const _m103 = (() => {
12246
12440
  const { cellText } = _m35;
12247
12441
 
12248
12442
  const { cleanXml } = _m28;
@@ -12300,10 +12494,10 @@ const _exports = Object.freeze({ canopyAbout: canopyAbout });
12300
12494
  return _exports;
12301
12495
  })();
12302
12496
 
12303
- const _m102 = (() => {
12497
+ const _m104 = (() => {
12304
12498
  const { Workbook, addGroupedXlsx } = _m23;
12305
12499
 
12306
- const { portableWorkbook } = _m52;
12500
+ const { portableWorkbook } = _m53;
12307
12501
 
12308
12502
  const { withDestination } = _m3;
12309
12503
 
@@ -12360,6 +12554,184 @@ const _exports = Object.freeze({ writeCanopyWorkbook: writeCanopyWorkbook });
12360
12554
  return _exports;
12361
12555
  })();
12362
12556
 
12557
+ const _m106 = (() => {
12558
+ const { ExportCell } = _m1;
12559
+
12560
+ /** Fixed numeric formats affect PDF text, not the frozen numeric value used by other writers. */
12561
+ function numericProfile(format) {
12562
+ if (format === undefined)
12563
+ return undefined;
12564
+ const match = /^((?:"[^"\\]*")*)(#,##)?0(?:\.([0#]+))?(%)?((?:"[^"\\]*")*)$/.exec(format);
12565
+ if (!match || (match[3]?.length ?? 0) > 10)
12566
+ return undefined;
12567
+ return { minimumFractionDigits: (match[3]?.match(/0/g) ?? []).length, maximumFractionDigits: match[3]?.length ?? 0,
12568
+ percent: !!match[4], grouping: !!match[2], prefix: match[1].replace(/"/g, ""), suffix: match[5].replace(/"/g, "") };
12569
+ }
12570
+ /** Preserve the captured decimal convention across a column, including whole percentages without a separator. */
12571
+ function canopyPdfNumbers(sample, columns) {
12572
+ const formatters = new Map();
12573
+ const decimal = columns.map((column, index) => {
12574
+ let fallback = ".";
12575
+ for (const row of sample) {
12576
+ const cell = row[index];
12577
+ if (!(cell instanceof ExportCell) || typeof cell.value !== "number")
12578
+ continue;
12579
+ const profile = numericProfile(cell.presentation?.numberFormat ?? column.format);
12580
+ if (!profile?.maximumFractionDigits)
12581
+ continue;
12582
+ const match = /([.,])(\d+)[^\d.,]*$/.exec(cell.text ?? "");
12583
+ if (match && match[2].length <= profile.maximumFractionDigits) {
12584
+ const numeric = /([+-]?\d[\d.,]*)[^\d]*$/.exec(cell.text ?? "")?.[1] ?? "";
12585
+ const scaled = cell.value * (profile.percent ? 100 : 1);
12586
+ if (/^[+-]?\d{1,3}(?:,\d{3})+$/.test(numeric) || /^[+-]?\d{1,3}(?:\.\d{3})+$/.test(numeric)) {
12587
+ if (Math.abs(Number(numeric.replace(/[.,]/g, "")) - scaled) < .5) {
12588
+ fallback = match[1] === "," ? "." : ",";
12589
+ continue;
12590
+ }
12591
+ }
12592
+ return match[1];
12593
+ }
12594
+ }
12595
+ return fallback;
12596
+ });
12597
+ return row => row.map((value, index) => {
12598
+ if (!(value instanceof ExportCell) || typeof value.value !== "number")
12599
+ return value;
12600
+ const profile = numericProfile(value.presentation?.numberFormat ?? columns[index].format);
12601
+ if (!profile)
12602
+ return value;
12603
+ const captured = /^([^0-9+-]*)([+-]?\d[\d., \u00a0\u202f]*?)([^0-9]*)$/.exec(value.text ?? "");
12604
+ if (value.text && !captured)
12605
+ return value;
12606
+ const key = [decimal[index], profile.minimumFractionDigits, profile.maximumFractionDigits, profile.grouping].join(":");
12607
+ let formatter = formatters.get(key);
12608
+ if (!formatter) {
12609
+ formatter = new Intl.NumberFormat(decimal[index] === "," ? "de-DE" : "en-US", {
12610
+ minimumFractionDigits: profile.minimumFractionDigits, maximumFractionDigits: profile.maximumFractionDigits, useGrouping: profile.grouping
12611
+ });
12612
+ formatters.set(key, formatter);
12613
+ }
12614
+ const formatted = formatter.format(value.value * (profile.percent ? 100 : 1));
12615
+ const prefix = profile.prefix || captured?.[1] || "";
12616
+ let suffix = profile.suffix || captured?.[3] || "";
12617
+ if (profile.percent && !profile.suffix)
12618
+ suffix = suffix.replace(/%/g, "");
12619
+ return new ExportCell(value.value, { text: prefix + formatted + (profile.percent ? "%" : "") + suffix,
12620
+ ...(value.presentation ? { presentation: value.presentation } : {}), ...(value.link ? { link: value.link } : {}) });
12621
+ });
12622
+ }
12623
+ const _exports = Object.freeze({ canopyPdfNumbers: canopyPdfNumbers });
12624
+ return _exports;
12625
+ })();
12626
+
12627
+ const _m105 = (() => {
12628
+ const { ExportCell, NotSupportedError, OfficeIMOError } = _m1;
12629
+
12630
+ const { inputRows, checkAbort, pause, taskYieldDue } = _m4;
12631
+
12632
+ const { fontProgram } = _m64;
12633
+
12634
+ const { resolveScalar, selectFont, validateFonts } = _m68;
12635
+
12636
+ const { settings } = _m17;
12637
+
12638
+ const { canopyPdfNumbers } = _m106;
12639
+
12640
+ /** A bounded lookahead is replayed once; no second capture, full-dataset copy or smaller font is needed. */
12641
+ async function withCanopyPdfLayout(source, captured, options, write) {
12642
+ const prepared = settings({ ...options, columns: source.columns }), { fontSize, padding, page, margins, limits } = prepared;
12643
+ options = prepared.options;
12644
+ validateFonts(options.fonts, limits.maxFontBytes);
12645
+ const available = page.width - margins.left - margins.right;
12646
+ const iterator = inputRows(source.rows(), options.signal)[Symbol.asyncIterator](), sample = [];
12647
+ let done = false, characters = 0;
12648
+ try {
12649
+ while (sample.length < Math.min(128, options.limits?.maxRows ?? 128) && characters < 262144) {
12650
+ const item = await iterator.next();
12651
+ if (item.done) {
12652
+ done = true;
12653
+ break;
12654
+ }
12655
+ sample.push(item.value);
12656
+ characters += item.value.reduce((n, cell) => n + (cell instanceof ExportCell ? cell.text?.length ?? 0 : String(cell ?? "").length), 0);
12657
+ }
12658
+ const format = canopyPdfNumbers(sample, source.columns), rows = sample.map(format);
12659
+ const measure = (text, bold = false, italic = false) => {
12660
+ if (text.length > limits.maxCellCharacters)
12661
+ throw new OfficeIMOError("RESOURCE_LIMIT", "maxCellCharacters exceeded.");
12662
+ const face = selectFont(options.fonts, bold, italic), program = face.font ? fontProgram(face.font) : undefined;
12663
+ let width = 0;
12664
+ for (const character of text.replace(/\t/g, " ")) {
12665
+ const scalar = resolveScalar(character.codePointAt(0), program, bold);
12666
+ if (!scalar.supported)
12667
+ throw new NotSupportedError(scalar.message);
12668
+ width += scalar.width * fontSize / 1000;
12669
+ }
12670
+ return width;
12671
+ };
12672
+ const largest = (parts, bold = false, italic = false) => parts.reduce((width, part) => Math.max(width, measure(part, bold, italic)), 0);
12673
+ let layout = {};
12674
+ // Explicit points/bands and shaping providers retain their own layout policy.
12675
+ if (!options.columnWidths && typeof options.wideTable !== "object" && !options.textShaper) {
12676
+ const minimum = source.columns.map(column => Math.min(available, largest(column.header.split(/\s+/), prepared.options.headerPresentation?.bold) + padding * 2 + .01));
12677
+ const natural = source.columns.map((column, index) => Math.min(available, Math.max(minimum[index], largest(column.header.split(/\r\n?|\n/), prepared.options.headerPresentation?.bold) + padding * 2 + .01)));
12678
+ for (const row of rows) {
12679
+ for (let i = 0; i < row.length; i++) {
12680
+ const cell = row[i], text = cell instanceof ExportCell ? cell.text ?? String(cell.value ?? "") : String(cell ?? "");
12681
+ const style = cell instanceof ExportCell ? cell.presentation : undefined;
12682
+ const line = largest(text.split(/\r\n?|\n/), style?.bold, style?.italic) + padding * 2 + .01;
12683
+ const word = largest(text.split(/\s+/), style?.bold, style?.italic) + padding * 2 + .01;
12684
+ natural[i] = Math.min(available, Math.max(natural[i], line));
12685
+ minimum[i] = Math.min(available, Math.max(minimum[i], captured[i].kind === "text" ? word : line));
12686
+ }
12687
+ if (taskYieldDue())
12688
+ await pause();
12689
+ checkAbort(options.signal);
12690
+ }
12691
+ const sum = minimum.reduce((total, width) => total + width, 0), widths = [...minimum];
12692
+ if (sum > available + .001)
12693
+ layout = { columnWidths: widths, wideTable: options.wideTable === "reject" ? "reject" : {
12694
+ mode: "bands", repeatColumns: widths[0] + Math.max(...widths.slice(1)) <= available ? [0] : []
12695
+ } };
12696
+ else {
12697
+ let spare = available - sum;
12698
+ const needs = natural.map((width, index) => Math.max(0, width - widths[index])), total = needs.reduce((n, width) => n + width, 0);
12699
+ for (let i = 0; i < widths.length; i++)
12700
+ widths[i] += total ? needs[i] * Math.min(1, spare / total) : 0;
12701
+ spare = available - widths.reduce((n, width) => n + width, 0);
12702
+ const text = captured.flatMap((column, index) => column.kind === "text" ? [index] : []);
12703
+ for (const i of text.length ? text : widths.map((_, index) => index))
12704
+ widths[i] += spare / (text.length || widths.length);
12705
+ layout = { columnWidths: widths };
12706
+ }
12707
+ }
12708
+ const replay = async function* () {
12709
+ for (const row of rows)
12710
+ yield row;
12711
+ while (!done) {
12712
+ const item = await iterator.next();
12713
+ if (item.done) {
12714
+ done = true;
12715
+ break;
12716
+ }
12717
+ yield format(item.value);
12718
+ }
12719
+ };
12720
+ return await write(replay(), layout, prepared.options);
12721
+ }
12722
+ finally {
12723
+ if (!done) {
12724
+ try {
12725
+ void iterator.return(undefined).catch(() => { });
12726
+ }
12727
+ catch { /* Keep the writer's original failure. */ }
12728
+ }
12729
+ }
12730
+ }
12731
+ const _exports = Object.freeze({ withCanopyPdfLayout: withCanopyPdfLayout });
12732
+ return _exports;
12733
+ })();
12734
+
12363
12735
  const _m0 = (() => {
12364
12736
  const { BlobByteSink, ExportCell } = _m1;
12365
12737
 
@@ -12371,21 +12743,25 @@ const { captureCommonLimits, captureXlsxOptions, captureCsvOptions, capturePdfOp
12371
12743
 
12372
12744
  const { writeXlsxTo } = _m23;
12373
12745
 
12374
- const { writeCsvTo } = _m55;
12746
+ const { writeCsvTo } = _m56;
12747
+
12748
+ const { writePdfTo, writeGroupedPdfTo } = _m58;
12749
+
12750
+ const { canopyDiagnostics } = _m95;
12375
12751
 
12376
- const { writePdfTo, writeGroupedPdfTo } = _m57;
12752
+ const { prepareCanopyExport } = _m96;
12377
12753
 
12378
- const { prepareCanopyExport } = _m94;
12754
+ const { canopyPins } = _m99;
12379
12755
 
12380
- const { canopyPins } = _m97;
12756
+ const { canopyRules } = _m100;
12381
12757
 
12382
- const { canopyRules } = _m98;
12758
+ const { canopyGrouped } = _m102;
12383
12759
 
12384
- const { canopyGrouped } = _m100;
12760
+ const { canopyAbout } = _m103;
12385
12761
 
12386
- const { canopyAbout } = _m101;
12762
+ const { writeCanopyWorkbook } = _m104;
12387
12763
 
12388
- const { writeCanopyWorkbook } = _m102;
12764
+ const { withCanopyPdfLayout } = _m105;
12389
12765
 
12390
12766
 
12391
12767
 
@@ -12400,7 +12776,7 @@ async function writeCanopyTo(capture, format, destination, options = {}) {
12400
12776
  const xlsx = captureXlsxOptions(format === "xlsx" ? selected.xlsx : undefined);
12401
12777
  const csv = captureCsvOptions(format === "csv" ? selected.csv : undefined);
12402
12778
  const pdf = capturePdfOptions(format === "pdf" ? selected.pdf : undefined);
12403
- const prepared = prepareCanopyExport(capture, format, { ...selected, xlsx }), { request, report, tones } = prepared;
12779
+ const prepared = prepareCanopyExport(capture, format, { ...selected, xlsx }), { request, report, tones, pivot } = prepared;
12404
12780
  if (selected.about !== undefined && typeof selected.about !== "boolean")
12405
12781
  throw new TypeError("Canopy about must be boolean.");
12406
12782
  const labels = selected.grouped === undefined ? undefined : captureFields(selected.grouped, ["labelColumn", "subtotalLabel", "grandTotalLabel", "includeGrandTotal", "continuationLabel", "groupHeadingLevel"]);
@@ -12431,9 +12807,14 @@ async function writeCanopyTo(capture, format, destination, options = {}) {
12431
12807
  } } : {};
12432
12808
  const stream = { ...(signal ? { signal } : {}), ...progress };
12433
12809
  if (format === "xlsx") {
12434
- const formatLimits = mergeAdapterLimits(xlsx.limits, limits), grouped = canopyGrouped(source, request, { ...selected, xlsx }, formatLimits, report, format);
12810
+ const formatLimits = mergeAdapterLimits(xlsx.limits, limits), grouped = pivot ? undefined : canopyGrouped(source, request, { ...selected, xlsx }, formatLimits, report, format);
12435
12811
  const pinned = canopyPins(request.columns, report), rules = canopyRules(request, format, grouped !== undefined, tones, report, { ...selected, xlsx }, ruleCellTypes);
12436
- const sheet = { ...xlsx.sheet,
12812
+ if (pivot && (xlsx.sheet?.rowOutline !== undefined || xlsx.sheet?.columnOutlines !== undefined || xlsx.sheet?.maxOutlineLevel !== undefined ||
12813
+ xlsx.sheet?.outlineSummaryBelow !== undefined || xlsx.sheet?.outlineSummaryRight !== undefined || xlsx.sheet?.table !== undefined || xlsx.sheet?.footer !== undefined))
12814
+ throw new TypeError("Captured pivot metadata owns outlines and totals; worksheet overrides cannot regroup or recalculate it.");
12815
+ if (pivot && xlsx.cellValueWriters !== undefined)
12816
+ throw new TypeError("Captured pivot exports use frozen values rather than custom cellValueWriters.");
12817
+ const sheet = { ...xlsx.sheet, ...(pivot?.sheet ?? {}), ...(pivot ? { autoFilter: false } : {}),
12437
12818
  freezeHeader: xlsx.sheet?.freezeHeader ?? (xlsx.sheet?.includeHeader !== false),
12438
12819
  freezeColumns: xlsx.sheet?.freezeColumns ?? (pinned ? pinned + (grouped ? 1 : 0) : 0),
12439
12820
  conditionalFormats: [...rules, ...(xlsx.sheet?.conditionalFormats ?? [])] };
@@ -12442,13 +12823,17 @@ async function writeCanopyTo(capture, format, destination, options = {}) {
12442
12823
  return writeCanopyWorkbook(source, grouped, destination, settings, capturedLabels, about);
12443
12824
  return writeXlsxTo(source.rows(), destination, settings);
12444
12825
  }
12826
+ if (pivot)
12827
+ canopyDiagnostics(format, { ...selected, unsupportedPresentation: "text" })({ code: "PIVOT_OUTLINES_XLSX_ONLY" });
12445
12828
  if (format === "pdf") {
12446
- const formatLimits = mergeAdapterLimits(pdf.limits, limits), grouped = canopyGrouped(source, request, selected, formatLimits, report, format);
12829
+ if (pivot && pdf.footer?.totals !== undefined)
12830
+ throw new TypeError("Captured pivot metadata owns totals; PDF footer totals cannot recalculate it.");
12831
+ const formatLimits = mergeAdapterLimits(pdf.limits, limits), grouped = pivot ? undefined : canopyGrouped(source, request, selected, formatLimits, report, format);
12447
12832
  canopyRules(request, format, grouped !== undefined, tones, report, selected);
12448
12833
  // CSS pixels become points before the existing fit/band policy. Explicit PDF point widths win.
12449
12834
  const fitted = request.columns.every(column => column.width !== undefined) ? request.columns.map(column => column.width.preferred * 72 / 96) : undefined;
12450
12835
  const widths = pdf.columnWidths ?? fitted;
12451
- const settings = { ...(fitted === undefined ? {} : { orientation: "landscape", wideTable: "fit" }), ...pdf, ...stream, limits: formatLimits };
12836
+ const settings = { orientation: "landscape", wideTable: "fit", ...pdf, ...stream, limits: formatLimits };
12452
12837
  if (grouped) {
12453
12838
  if (pdf.headerRows !== undefined || pdf.footer !== undefined)
12454
12839
  throw new TypeError("Grouped Canopy PDF owns heading and summary rows.");
@@ -12462,7 +12847,13 @@ async function writeCanopyTo(capture, format, destination, options = {}) {
12462
12847
  ...(capturedLabels?.continuationLabel === undefined ? {} : { continuationLabel: capturedLabels.continuationLabel }),
12463
12848
  ...(capturedLabels?.groupHeadingLevel === undefined ? {} : { groupHeadingLevel: capturedLabels.groupHeadingLevel }) });
12464
12849
  }
12465
- return writePdfTo(source.rows(), destination, { ...settings, columns: source.columns, ...(widths === undefined ? {} : { columnWidths: widths }) });
12850
+ return withCanopyPdfLayout(prepared.source, request.columns, settings, async (rows, layout, captured) => {
12851
+ const counted = async function* () { for await (const row of rows) {
12852
+ consumed++;
12853
+ yield row;
12854
+ } };
12855
+ return writePdfTo(counted(), destination, { ...captured, ...layout, columns: source.columns });
12856
+ });
12466
12857
  }
12467
12858
  return writeCsvTo(source.rows(), destination, { ...csv, ...stream, columns: source.columns, valueMode: request.values,
12468
12859
  limits: mergeAdapterLimits(csv.limits, limits) });
@@ -12479,7 +12870,7 @@ async function exportCanopy(capture, format, options = {}) {
12479
12870
  throw error;
12480
12871
  }
12481
12872
  }
12482
- const _exports = Object.freeze({ createCanopyExport: _m94.createCanopyExport, ExportCell: _m5.ExportCell, PdfFont: _m63.PdfFont, writeCanopyTo: writeCanopyTo, exportCanopy: exportCanopy });
12873
+ const _exports = Object.freeze({ createCanopyExport: _m96.createCanopyExport, ExportCell: _m5.ExportCell, PdfFont: _m64.PdfFont, writeCanopyTo: writeCanopyTo, exportCanopy: exportCanopy });
12483
12874
  return _exports;
12484
12875
  })();
12485
12876
  const { createCanopyExport, ExportCell, PdfFont, writeCanopyTo, exportCanopy } = _m0;