@mog-sdk/node 0.1.12 → 0.1.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -90,10 +90,45 @@ function activeCellToStoreCellData(data, row, col) {
90
90
  }
91
91
  async function getData(ctx, sheetId, row, col) {
92
92
  const cellId = await ctx.computeBridge.getCellIdAt(sheetId, row, col);
93
- if (!cellId) return void 0;
94
- const data = await ctx.computeBridge.getActiveCell(sheetId, cellId);
95
- if (!data) return void 0;
96
- return activeCellToStoreCellData(data, row, col);
93
+ if (cellId) {
94
+ const data = await ctx.computeBridge.getActiveCell(sheetId, cellId);
95
+ if (data) return activeCellToStoreCellData(data, row, col);
96
+ }
97
+ const cellData = await ctx.computeBridge.getCellData(sheetId, row, col);
98
+ if (cellData != null) {
99
+ const obj = cellData;
100
+ const rawValue = obj.value ?? obj.raw;
101
+ if (rawValue != null) {
102
+ const value = parseMirrorValue(rawValue);
103
+ if (value !== null && value !== void 0) {
104
+ return {
105
+ id: obj.cell_id ?? obj.cellId ?? "",
106
+ row,
107
+ col,
108
+ raw: value
109
+ };
110
+ }
111
+ }
112
+ }
113
+ return void 0;
114
+ }
115
+ function parseMirrorValue(json) {
116
+ if (typeof json !== "object" || json === null) return null;
117
+ const obj = json;
118
+ switch (obj.type) {
119
+ case "number":
120
+ return obj.value;
121
+ case "text":
122
+ return obj.value;
123
+ case "boolean":
124
+ return obj.value;
125
+ case "error":
126
+ return obj.value;
127
+ case "null":
128
+ return null;
129
+ default:
130
+ return null;
131
+ }
97
132
  }
98
133
  function getEffectiveValue(data) {
99
134
  if (data.formula !== void 0) {
@@ -5033,10 +5068,11 @@ var init_compute_core = __esm({
5033
5068
  * Requires at least CONTEXT_SET phase (the engine may or may not have been started yet).
5034
5069
  * After fullRecalc completes, the bridge transitions to STARTED phase.
5035
5070
  */
5036
- async fullRecalc() {
5071
+ async fullRecalc(options) {
5037
5072
  this.ensurePhase("CONTEXT_SET", "fullRecalc");
5038
5073
  const result = await this.transport.call("compute_full_recalc", {
5039
- docId: this.docId
5074
+ docId: this.docId,
5075
+ options: options ?? {}
5040
5076
  });
5041
5077
  this._phase = "STARTED";
5042
5078
  this.mutationHandler?.applyAndNotify({ recalc: result });
@@ -6672,6 +6708,9 @@ var init_compute_bridge_gen = __esm({
6672
6708
  pivotUnregisterDef(sheetId, pivotName) {
6673
6709
  return this.core.mutatePlain(this.core.transport.call("compute_pivot_unregister_def", { docId: this.core.docId, sheetId, pivotName }));
6674
6710
  }
6711
+ pivotMaterialize(sheetId, pivotId, expansionState) {
6712
+ return this.core.query(this.core.transport.call("compute_pivot_materialize", { docId: this.core.docId, sheetId, pivotId, expansionState }));
6713
+ }
6675
6714
  registerViewport(viewportId, sheetId, startRow, startCol, endRow, endCol) {
6676
6715
  return this.core.mutatePlain(this.core.transport.call("compute_register_viewport", { docId: this.core.docId, viewportId, sheetId, startRow, startCol, endRow, endCol }));
6677
6716
  }
@@ -6928,8 +6967,8 @@ var init_compute_bridge = __esm({
6928
6967
  // ===========================================================================
6929
6968
  // Error Recovery delegates
6930
6969
  // ===========================================================================
6931
- fullRecalc() {
6932
- return this.core.fullRecalc();
6970
+ fullRecalc(options) {
6971
+ return this.core.fullRecalc(options);
6933
6972
  }
6934
6973
  exportToXlsxBytes() {
6935
6974
  return this.core.exportToXlsxBytes();
@@ -7815,6 +7854,15 @@ function letterToCol(letters) {
7815
7854
  function toA12(row, col) {
7816
7855
  return `${colToLetter3(col)}${row + 1}`;
7817
7856
  }
7857
+ function quoteSheetName(name) {
7858
+ if (/[^A-Za-z0-9_]/.test(name) || /^\d/.test(name)) {
7859
+ return `'${name.replace(/'/g, "''")}'`;
7860
+ }
7861
+ return name;
7862
+ }
7863
+ function toSheetA1(row, col, sheetName) {
7864
+ return `${quoteSheetName(sheetName)}!${colToLetter3(col)}${row + 1}`;
7865
+ }
7818
7866
  function parseCellAddress(ref) {
7819
7867
  const match = ref.match(CELL_ADDRESS_REGEX);
7820
7868
  if (!match) return null;
@@ -13241,6 +13289,15 @@ __export(chart_bridge_exports, {
13241
13289
  createChartBridge: () => createChartBridge,
13242
13290
  initChartWasm: () => initChartWasm
13243
13291
  });
13292
+ function normalizeAxisForRendering(axis) {
13293
+ const normAxis = (a) => a ? { ...a, type: a.type ?? a.axisType, show: a.show ?? a.visible } : a;
13294
+ return {
13295
+ ...axis,
13296
+ xAxis: normAxis(axis.categoryAxis ?? axis.xAxis),
13297
+ yAxis: normAxis(axis.valueAxis ?? axis.yAxis),
13298
+ secondaryYAxis: normAxis(axis.secondaryValueAxis ?? axis.secondaryYAxis)
13299
+ };
13300
+ }
13244
13301
  function toChartConfig(chart) {
13245
13302
  return {
13246
13303
  type: chart.chartType ?? "bar",
@@ -13255,12 +13312,13 @@ function toChartConfig(chart) {
13255
13312
  title: chart.title,
13256
13313
  subtitle: chart.subtitle,
13257
13314
  legend: chart.legend,
13258
- axis: chart.axis,
13315
+ axis: chart.axis ? normalizeAxisForRendering(chart.axis) : chart.axis,
13259
13316
  colors: chart.colors,
13260
13317
  series: chart.series,
13261
13318
  dataLabels: chart.dataLabels,
13262
13319
  pieSlice: chart.pieSlice,
13263
- trendline: chart.trendline,
13320
+ trendline: Array.isArray(chart.trendline) ? chart.trendline[0] : chart.trendline,
13321
+ trendlines: chart.trendline,
13264
13322
  showLines: chart.showLines,
13265
13323
  smoothLines: chart.smoothLines,
13266
13324
  radarFilled: chart.radarFilled,
@@ -13276,7 +13334,7 @@ function toChartConfig(chart) {
13276
13334
  splitType: chart.splitType,
13277
13335
  splitValue: chart.splitValue,
13278
13336
  subType: chart.subType,
13279
- extra: chart.definition
13337
+ extra: chart.ooxml
13280
13338
  };
13281
13339
  }
13282
13340
  function initChartWasm(exports2) {
@@ -13674,7 +13732,7 @@ var init_chart_bridge = __esm({
13674
13732
  type: "nominal"
13675
13733
  };
13676
13734
  }
13677
- const chartTitle = chart.definition && typeof chart.definition === "object" ? chart.definition.chartTitle : void 0;
13735
+ const chartTitle = chart.ooxml && typeof chart.ooxml === "object" ? chart.ooxml.chartTitle : void 0;
13678
13736
  let titleSpec;
13679
13737
  if (chart.title) {
13680
13738
  titleSpec = {
@@ -13716,7 +13774,7 @@ var init_chart_bridge = __esm({
13716
13774
  if (chart.colors && chart.colors.length > 0) {
13717
13775
  specConfig.range = { category: chart.colors };
13718
13776
  }
13719
- const chartArea = chart.definition && typeof chart.definition === "object" ? chart.definition.chartArea : void 0;
13777
+ const chartArea = chart.ooxml && typeof chart.ooxml === "object" ? chart.ooxml.chartArea : void 0;
13720
13778
  if (chartArea?.fill && typeof chartArea.fill === "object") {
13721
13779
  specConfig.background = chartArea.fill.color;
13722
13780
  }
@@ -15741,10 +15799,11 @@ var init_cell_properties = __esm({
15741
15799
  });
15742
15800
 
15743
15801
  // ../../kernel/src/api/internal/value-conversions.ts
15744
- function viewportCellValueToCellValue(cv) {
15802
+ function normalizeCellValue(cv) {
15803
+ if (cv !== null && isCellError(cv)) return errorDisplayString(cv.value);
15745
15804
  return cv;
15746
15805
  }
15747
- function viewportCellValueToString(cv) {
15806
+ function cellValueToString(cv) {
15748
15807
  if (cv === null || cv === void 0) return "";
15749
15808
  if (typeof cv === "string") return cv;
15750
15809
  if (typeof cv === "number") return String(cv);
@@ -15908,15 +15967,14 @@ function buildBaseFields(data) {
15908
15967
  name: data.name,
15909
15968
  visible: data.visible,
15910
15969
  groupId: data.groupId,
15911
- altText: data.altText,
15970
+ altText: "altText" in data ? data.altText : void 0,
15912
15971
  createdAt: data.createdAt,
15913
15972
  updatedAt: data.updatedAt
15914
15973
  };
15915
15974
  }
15916
- function toShapeObject(data) {
15917
- const d = data;
15975
+ function toShapeObject(d) {
15918
15976
  return {
15919
- ...buildBaseFields(data),
15977
+ ...buildBaseFields(d),
15920
15978
  type: "shape",
15921
15979
  shapeType: d.shapeType ?? "rect",
15922
15980
  fill: d.fill,
@@ -15926,10 +15984,9 @@ function toShapeObject(data) {
15926
15984
  adjustments: d.adjustments
15927
15985
  };
15928
15986
  }
15929
- function toPictureObject(data) {
15930
- const d = data;
15987
+ function toPictureObject(d) {
15931
15988
  return {
15932
- ...buildBaseFields(data),
15989
+ ...buildBaseFields(d),
15933
15990
  type: "picture",
15934
15991
  src: d.src ?? "",
15935
15992
  originalWidth: d.originalWidth ?? 0,
@@ -15938,10 +15995,9 @@ function toPictureObject(data) {
15938
15995
  adjustments: d.adjustments
15939
15996
  };
15940
15997
  }
15941
- function toTextBoxObject(data) {
15942
- const d = data;
15998
+ function toTextBoxObject(d) {
15943
15999
  return {
15944
- ...buildBaseFields(data),
16000
+ ...buildBaseFields(d),
15945
16001
  type: "textbox",
15946
16002
  content: d.content ?? "",
15947
16003
  defaultFormat: d.defaultFormat,
@@ -15952,10 +16008,9 @@ function toTextBoxObject(data) {
15952
16008
  wordArt: d.wordArt
15953
16009
  };
15954
16010
  }
15955
- function toConnectorObject(data) {
15956
- const d = data;
16011
+ function toConnectorObject(d) {
15957
16012
  return {
15958
- ...buildBaseFields(data),
16013
+ ...buildBaseFields(d),
15959
16014
  type: "connector",
15960
16015
  shapeType: d.shapeType ?? "connector",
15961
16016
  startConnection: d.startConnection,
@@ -15964,8 +16019,7 @@ function toConnectorObject(data) {
15964
16019
  outline: d.outline
15965
16020
  };
15966
16021
  }
15967
- function toChartObject(data) {
15968
- const d = data;
16022
+ function toChartObject(d) {
15969
16023
  const chartConfig = {
15970
16024
  subType: d.subType,
15971
16025
  seriesOrientation: d.seriesOrientation,
@@ -15994,41 +16048,38 @@ function toChartObject(data) {
15994
16048
  tableCategoryColumn: d.tableCategoryColumn,
15995
16049
  useTableColumnNamesAsLabels: d.useTableColumnNamesAsLabels,
15996
16050
  tableColumnNames: d.tableColumnNames,
15997
- definition: d.definition,
15998
16051
  ooxml: d.ooxml
15999
16052
  };
16000
16053
  return {
16001
- ...buildBaseFields(data),
16054
+ ...buildBaseFields(d),
16002
16055
  type: "chart",
16003
16056
  chartType: d.chartType ?? "column",
16004
- anchorMode: data.anchor.anchorMode === "twoCell" ? "twoCell" : "oneCell",
16005
- widthCells: d.widthCells ?? data.width ?? 8,
16006
- heightCells: d.heightCells ?? data.height ?? 15,
16057
+ anchorMode: d.anchor.anchorMode === "twoCell" ? "twoCell" : "oneCell",
16058
+ widthCells: d.widthCells ?? d.width ?? 8,
16059
+ heightCells: d.heightCells ?? d.height ?? 15,
16007
16060
  chartConfig,
16008
16061
  dataRangeIdentity: d.dataRangeIdentity,
16009
16062
  seriesRangeIdentity: d.seriesRangeIdentity,
16010
16063
  categoryRangeIdentity: d.categoryRangeIdentity
16011
16064
  };
16012
16065
  }
16013
- function toEquationObject(data) {
16014
- const d = data;
16066
+ function toEquationObject(d) {
16067
+ const equation = typeof d.equation === "string" ? { id: d.id, omml: d.equation } : d.equation;
16015
16068
  return {
16016
- ...buildBaseFields(data),
16069
+ ...buildBaseFields(d),
16017
16070
  type: "equation",
16018
- equation: d.equation
16071
+ equation
16019
16072
  };
16020
16073
  }
16021
- function toSmartArtObject(data) {
16022
- const d = data;
16074
+ function toSmartArtObject(d) {
16023
16075
  return {
16024
- ...buildBaseFields(data),
16076
+ ...buildBaseFields(d),
16025
16077
  type: "smartart",
16026
16078
  diagram: d.definition ?? {}
16027
16079
  };
16028
16080
  }
16029
- function toDrawingObject(data) {
16030
- const common = buildBaseFields(data);
16031
- const d = data;
16081
+ function toDrawingObject(d) {
16082
+ const common = buildBaseFields(d);
16032
16083
  const strokes = /* @__PURE__ */ new Map();
16033
16084
  if (d.strokes) {
16034
16085
  for (const [id, stroke] of Object.entries(d.strokes)) {
@@ -16053,10 +16104,9 @@ function toDrawingObject(data) {
16053
16104
  backgroundColor: d.backgroundColor
16054
16105
  };
16055
16106
  }
16056
- function toOleObjectObject(data) {
16057
- const d = data;
16107
+ function toOleObjectObject(d) {
16058
16108
  return {
16059
- ...buildBaseFields(data),
16109
+ ...buildBaseFields(d),
16060
16110
  type: "oleObject",
16061
16111
  progId: d.progId ?? "",
16062
16112
  dvAspect: d.dvAspect ?? "content",
@@ -16067,8 +16117,7 @@ function toOleObjectObject(data) {
16067
16117
  };
16068
16118
  }
16069
16119
  function toFloatingObject(data) {
16070
- const objectType = data.type ?? "shape";
16071
- switch (objectType) {
16120
+ switch (data.type) {
16072
16121
  case "shape":
16073
16122
  return toShapeObject(data);
16074
16123
  case "picture":
@@ -16088,10 +16137,43 @@ function toFloatingObject(data) {
16088
16137
  case "drawing":
16089
16138
  return toDrawingObject(data);
16090
16139
  case "slicer":
16091
- default:
16092
- return toShapeObject({ ...data, type: "shape" });
16140
+ case "camera":
16141
+ case "formControl":
16142
+ default: {
16143
+ const fallback = Object.assign({}, data, { type: "shape" });
16144
+ return toShapeObject(fallback);
16145
+ }
16093
16146
  }
16094
16147
  }
16148
+ function createMinimalFloatingObject(type, id, sheetId, extras) {
16149
+ const wire = {
16150
+ id,
16151
+ sheetId,
16152
+ type,
16153
+ anchor: {
16154
+ anchorRow: 0,
16155
+ anchorCol: 0,
16156
+ anchorRowOffset: 0,
16157
+ anchorColOffset: 0,
16158
+ anchorMode: "absolute"
16159
+ },
16160
+ width: 100,
16161
+ height: 100,
16162
+ zIndex: 0,
16163
+ rotation: 0,
16164
+ flipH: false,
16165
+ flipV: false,
16166
+ locked: false,
16167
+ visible: true,
16168
+ printable: true,
16169
+ opacity: 1,
16170
+ name: "",
16171
+ createdAt: 0,
16172
+ updatedAt: 0,
16173
+ ...extras
16174
+ };
16175
+ return toFloatingObject(wire);
16176
+ }
16095
16177
  var init_floating_object_mapper = __esm({
16096
16178
  "../../kernel/src/bridges/compute/floating-object-mapper.ts"() {
16097
16179
  "use strict";
@@ -25216,7 +25298,7 @@ var init_pivot_bridge = __esm({
25216
25298
  expandedColumns: {}
25217
25299
  };
25218
25300
  try {
25219
- const result = await this.ctx.computeBridge.pivotComputeFromSource(
25301
+ const result = await this.ctx.computeBridge.pivotMaterialize(
25220
25302
  sheetId,
25221
25303
  pivotId,
25222
25304
  expansionState ?? null
@@ -25420,7 +25502,7 @@ var init_pivot_bridge = __esm({
25420
25502
  const rowData = [];
25421
25503
  for (let col = range2.startCol; col <= range2.endCol; col++) {
25422
25504
  const cell = cellMap.get(`${row},${col}`);
25423
- rowData.push(cell ? viewportCellValueToCellValue(cell.value) ?? null : null);
25505
+ rowData.push(cell ? normalizeCellValue(cell.value) ?? null : null);
25424
25506
  }
25425
25507
  data.push(rowData);
25426
25508
  }
@@ -78877,22 +78959,18 @@ async function batchGetCellPositions(ctx, sheetId, cellIds) {
78877
78959
 
78878
78960
  // ../../kernel/src/api/worksheet/operations/dependency-operations.ts
78879
78961
  init_cjs_shims();
78880
- function colToLetter4(col) {
78881
- let result = "";
78882
- let c = col;
78883
- while (c >= 0) {
78884
- result = String.fromCharCode(c % 26 + 65) + result;
78885
- c = Math.floor(c / 26) - 1;
78886
- }
78887
- return result;
78888
- }
78962
+ init_a1();
78889
78963
  async function getDependents(ctx, sheetId, row, col) {
78890
78964
  const results = await ctx.computeBridge.getDependents(sheetId, row, col);
78891
- return results.map((r) => `${colToLetter4(r.col)}${r.row + 1}`);
78965
+ return results.map(
78966
+ (r) => r.sheetId === sheetId ? toA12(r.row, r.col) : toSheetA1(r.row, r.col, r.sheetName)
78967
+ );
78892
78968
  }
78893
78969
  async function getPrecedents(ctx, sheetId, row, col) {
78894
78970
  const results = await ctx.computeBridge.getPrecedents(sheetId, row, col);
78895
- return results.map((r) => `${colToLetter4(r.col)}${r.row + 1}`);
78971
+ return results.map(
78972
+ (r) => r.sheetId === sheetId ? toA12(r.row, r.col) : toSheetA1(r.row, r.col, r.sheetName)
78973
+ );
78896
78974
  }
78897
78975
 
78898
78976
  // ../../kernel/src/api/worksheet/operations/fill-operations.ts
@@ -79213,7 +79291,7 @@ async function findCells(ctx, sheetId, predicate) {
79213
79291
  const results = [];
79214
79292
  for (const cell of rangeResult.cells) {
79215
79293
  const cellData = {
79216
- value: viewportCellValueToCellValue(cell.value),
79294
+ value: normalizeCellValue(cell.value),
79217
79295
  formula: cell.formula
79218
79296
  };
79219
79297
  if (predicate(cellData, cell.row, cell.col)) {
@@ -79266,18 +79344,18 @@ async function regexSearch(ctx, sheetId, patterns, options) {
79266
79344
  bounds.maxCol
79267
79345
  );
79268
79346
  for (const cell of rangeResult.cells) {
79269
- const valueStr = cell.formatted ?? viewportCellValueToString(cell.value);
79347
+ const valueStr = cell.formatted ?? cellValueToString(cell.value);
79270
79348
  for (const { regex, source } of compiledPatterns) {
79271
79349
  regex.lastIndex = 0;
79272
79350
  if (regex.test(valueStr)) {
79273
- const address = `${colToLetter3(cell.col)}${cell.row + 1}`;
79351
+ const address = toA12(cell.row, cell.col);
79274
79352
  results.push({ address, value: valueStr, sheetName, matchedPattern: source });
79275
79353
  break;
79276
79354
  }
79277
79355
  if (options?.includeFormulas && cell.formula) {
79278
79356
  regex.lastIndex = 0;
79279
79357
  if (regex.test(cell.formula)) {
79280
- const address = `${colToLetter3(cell.col)}${cell.row + 1}`;
79358
+ const address = toA12(cell.row, cell.col);
79281
79359
  results.push({ address, value: valueStr, sheetName, matchedPattern: source });
79282
79360
  break;
79283
79361
  }
@@ -79310,9 +79388,9 @@ async function getRangeWithIdentity(ctx, sheetId, startRow, startCol, endRow, en
79310
79388
  cellId: cell.cellId,
79311
79389
  row: cell.row,
79312
79390
  col: cell.col,
79313
- value: viewportCellValueToCellValue(cell.value),
79391
+ value: normalizeCellValue(cell.value),
79314
79392
  formulaText: cell.formula,
79315
- displayString: cell.formatted ?? viewportCellValueToString(cell.value)
79393
+ displayString: cell.formatted ?? cellValueToString(cell.value)
79316
79394
  }));
79317
79395
  }
79318
79396
 
@@ -79341,7 +79419,7 @@ async function getRange(ctx, sheetId, range2) {
79341
79419
  if (!cell) {
79342
79420
  rowData.push({ value: null });
79343
79421
  } else {
79344
- const value = viewportCellValueToCellValue(cell.value);
79422
+ const value = normalizeCellValue(cell.value);
79345
79423
  rowData.push({
79346
79424
  value: value ?? null,
79347
79425
  formula: cell.formula,
@@ -79520,7 +79598,7 @@ async function getDisplayText(ctx, sheetId, range2) {
79520
79598
  if (!cell) {
79521
79599
  rowData.push("");
79522
79600
  } else {
79523
- rowData.push(cell.formatted ?? viewportCellValueToString(cell.value));
79601
+ rowData.push(cell.formatted ?? cellValueToString(cell.value));
79524
79602
  }
79525
79603
  }
79526
79604
  result.push(rowData);
@@ -79548,7 +79626,7 @@ async function getValueTypes(ctx, sheetId, range2) {
79548
79626
  if (!cell) {
79549
79627
  rowData.push(import_api3.RangeValueType.Empty);
79550
79628
  } else {
79551
- rowData.push(classifyValueType(viewportCellValueToCellValue(cell.value)));
79629
+ rowData.push(classifyValueType(normalizeCellValue(cell.value)));
79552
79630
  }
79553
79631
  }
79554
79632
  result.push(rowData);
@@ -79557,7 +79635,11 @@ async function getValueTypes(ctx, sheetId, range2) {
79557
79635
  }
79558
79636
  function classifyValueType(value) {
79559
79637
  if (value === null || value === void 0) return import_api3.RangeValueType.Empty;
79560
- if (typeof value === "string") return value === "" ? import_api3.RangeValueType.Empty : import_api3.RangeValueType.String;
79638
+ if (typeof value === "string") {
79639
+ if (value === "") return import_api3.RangeValueType.Empty;
79640
+ if (value.startsWith("#")) return import_api3.RangeValueType.Error;
79641
+ return import_api3.RangeValueType.String;
79642
+ }
79561
79643
  if (typeof value === "number") return import_api3.RangeValueType.Double;
79562
79644
  if (typeof value === "boolean") return import_api3.RangeValueType.Boolean;
79563
79645
  if (typeof value === "object" && value !== null && "type" in value) return import_api3.RangeValueType.Error;
@@ -79583,7 +79665,7 @@ async function findInRange(ctx, sheetId, range2, text, options) {
79583
79665
  n.endCol
79584
79666
  );
79585
79667
  for (const cell of rangeResult.cells) {
79586
- const valueStr = cell.formatted ?? viewportCellValueToString(cell.value);
79668
+ const valueStr = cell.formatted ?? cellValueToString(cell.value);
79587
79669
  if (pattern.test(valueStr)) {
79588
79670
  return {
79589
79671
  address: `${colToLetter3(cell.col)}${cell.row + 1}`,
@@ -79615,7 +79697,7 @@ async function replaceAll(ctx, sheetId, range2, text, replacement, options) {
79615
79697
  const edits = [];
79616
79698
  for (const cell of rangeResult.cells) {
79617
79699
  if (cell.formula) continue;
79618
- const valueStr = viewportCellValueToString(cell.value);
79700
+ const valueStr = cellValueToString(cell.value);
79619
79701
  if (!valueStr) continue;
79620
79702
  pattern.lastIndex = 0;
79621
79703
  if (pattern.test(valueStr)) {
@@ -79740,9 +79822,18 @@ init_cjs_shims();
79740
79822
  // ../../kernel/src/api/worksheet/collections/object-collection-impl.ts
79741
79823
  init_cjs_shims();
79742
79824
 
79825
+ // ../../kernel/src/api/worksheet/handles/floating-object-handle-factory.ts
79826
+ init_cjs_shims();
79827
+
79743
79828
  // ../../kernel/src/api/worksheet/handles/floating-object-handle-impl.ts
79744
79829
  init_cjs_shims();
79745
79830
  init_errors();
79831
+ function narrowHandle(handle, expected) {
79832
+ if (handle.type !== expected) {
79833
+ throw new KernelError("OPERATION_FAILED", `Expected ${expected}, got ${handle.type}`);
79834
+ }
79835
+ return handle;
79836
+ }
79746
79837
  var FloatingObjectHandleImpl = class _FloatingObjectHandleImpl {
79747
79838
  constructor(id, type, objectsImpl, boundsReader) {
79748
79839
  this.id = id;
@@ -79789,11 +79880,11 @@ var FloatingObjectHandleImpl = class _FloatingObjectHandleImpl {
79789
79880
  return this.boundsReader?.getBounds(this.id) ?? null;
79790
79881
  }
79791
79882
  async getData() {
79792
- const info = await this.objectsImpl.get(this.id);
79793
- if (!info) throw new KernelError("OPERATION_FAILED", `Object ${this.id} not found`);
79794
- return info;
79883
+ const obj = await this.objectsImpl.getFullObject(this.id);
79884
+ if (!obj) throw new KernelError("OPERATION_FAILED", `Object ${this.id} not found`);
79885
+ return obj;
79795
79886
  }
79796
- // -- Type narrowing --
79887
+ // -- Type narrowing (is* predicates) --
79797
79888
  isShape() {
79798
79889
  return this.type === "shape";
79799
79890
  }
@@ -79830,58 +79921,43 @@ var FloatingObjectHandleImpl = class _FloatingObjectHandleImpl {
79830
79921
  isSlicer() {
79831
79922
  return this.type === "slicer";
79832
79923
  }
79833
- /** @internal Throw if this handle's type doesn't match expected. */
79834
- assertType(expected) {
79835
- if (this.type !== expected) {
79836
- throw new KernelError("OPERATION_FAILED", `Expected ${expected}, got ${this.type}`);
79837
- }
79838
- }
79924
+ /**
79925
+ * Type-checked narrowing — throws if this handle's type does not match.
79926
+ * The factory (createFloatingObjectHandle) guarantees that when type === 'shape',
79927
+ * `this` is a ShapeHandleImpl which implements ShapeHandle, etc.
79928
+ */
79839
79929
  asShape() {
79840
- this.assertType("shape");
79841
- return this;
79930
+ return narrowHandle(this, "shape");
79842
79931
  }
79843
79932
  asPicture() {
79844
- this.assertType("picture");
79845
- return this;
79933
+ return narrowHandle(this, "picture");
79846
79934
  }
79847
79935
  asTextBox() {
79848
- this.assertType("textbox");
79849
- return this;
79936
+ return narrowHandle(this, "textbox");
79850
79937
  }
79851
79938
  asDrawing() {
79852
- this.assertType("drawing");
79853
- return this;
79939
+ return narrowHandle(this, "drawing");
79854
79940
  }
79855
79941
  asEquation() {
79856
- this.assertType("equation");
79857
- return this;
79942
+ return narrowHandle(this, "equation");
79858
79943
  }
79859
79944
  asWordArt() {
79860
- this.assertType("wordart");
79861
- return this;
79945
+ throw new KernelError("OPERATION_FAILED", `Expected wordart, got ${this.type}`);
79862
79946
  }
79863
79947
  asSmartArt() {
79864
- this.assertType("smartart");
79865
- return this;
79948
+ return narrowHandle(this, "smartart");
79866
79949
  }
79867
79950
  asChart() {
79868
- this.assertType("chart");
79869
- return this;
79870
- }
79871
- asCamera() {
79872
- throw new KernelError("OPERATION_FAILED", "Camera objects are no longer supported");
79951
+ return narrowHandle(this, "chart");
79873
79952
  }
79874
79953
  asConnector() {
79875
- this.assertType("connector");
79876
- return this;
79954
+ return narrowHandle(this, "connector");
79877
79955
  }
79878
79956
  asOleObject() {
79879
- this.assertType("oleObject");
79880
- return this;
79957
+ return narrowHandle(this, "oleObject");
79881
79958
  }
79882
79959
  asSlicer() {
79883
- this.assertType("slicer");
79884
- return this;
79960
+ return narrowHandle(this, "slicer");
79885
79961
  }
79886
79962
  };
79887
79963
 
@@ -79901,9 +79977,9 @@ var ShapeHandleImpl = class _ShapeHandleImpl extends FloatingObjectHandleImpl {
79901
79977
  return new _ShapeHandleImpl(receipt.id, this.shapeType, this.objectsImpl, this.boundsReader);
79902
79978
  }
79903
79979
  async getData() {
79904
- const shape = await this.objectsImpl.getShape(this.id);
79905
- if (!shape) throw new KernelError("OPERATION_FAILED", `Shape ${this.id} not found`);
79906
- return shape;
79980
+ const obj = await this.objectsImpl.getFullObject(this.id);
79981
+ if (!obj || obj.type !== "shape") throw new KernelError("OPERATION_FAILED", `Shape ${this.id} not found`);
79982
+ return obj;
79907
79983
  }
79908
79984
  };
79909
79985
 
@@ -79922,9 +79998,9 @@ var PictureHandleImpl = class _PictureHandleImpl extends FloatingObjectHandleImp
79922
79998
  return new _PictureHandleImpl(receipt.id, this.objectsImpl, this.boundsReader);
79923
79999
  }
79924
80000
  async getData() {
79925
- const info = await this.objectsImpl.get(this.id);
79926
- if (!info) throw new KernelError("OPERATION_FAILED", `Picture ${this.id} not found`);
79927
- return info;
80001
+ const obj = await this.objectsImpl.getFullObject(this.id);
80002
+ if (!obj || obj.type !== "picture") throw new KernelError("OPERATION_FAILED", `Picture ${this.id} not found`);
80003
+ return obj;
79928
80004
  }
79929
80005
  };
79930
80006
 
@@ -79943,9 +80019,9 @@ var TextBoxHandleImpl = class _TextBoxHandleImpl extends FloatingObjectHandleImp
79943
80019
  return new _TextBoxHandleImpl(receipt.id, this.objectsImpl, this.boundsReader);
79944
80020
  }
79945
80021
  async getData() {
79946
- const info = await this.objectsImpl.get(this.id);
79947
- if (!info) throw new KernelError("OPERATION_FAILED", `TextBox ${this.id} not found`);
79948
- return info;
80022
+ const obj = await this.objectsImpl.getFullObject(this.id);
80023
+ if (!obj || obj.type !== "textbox") throw new KernelError("OPERATION_FAILED", `TextBox ${this.id} not found`);
80024
+ return obj;
79949
80025
  }
79950
80026
  };
79951
80027
 
@@ -80000,9 +80076,9 @@ var EquationHandleImpl = class _EquationHandleImpl extends FloatingObjectHandleI
80000
80076
  return new _EquationHandleImpl(receipt.id, this.objectsImpl, this.boundsReader);
80001
80077
  }
80002
80078
  async getData() {
80003
- const info = await this.objectsImpl.get(this.id);
80004
- if (!info) throw new KernelError("OPERATION_FAILED", `Equation ${this.id} not found`);
80005
- return info;
80079
+ const obj = await this.objectsImpl.getFullObject(this.id);
80080
+ if (!obj || obj.type !== "equation") throw new KernelError("OPERATION_FAILED", `Equation ${this.id} not found`);
80081
+ return obj;
80006
80082
  }
80007
80083
  };
80008
80084
 
@@ -80021,9 +80097,9 @@ var ConnectorHandleImpl = class _ConnectorHandleImpl extends FloatingObjectHandl
80021
80097
  return new _ConnectorHandleImpl(receipt.id, this.objectsImpl, this.boundsReader);
80022
80098
  }
80023
80099
  async getData() {
80024
- const info = await this.objectsImpl.get(this.id);
80025
- if (!info) throw new KernelError("OPERATION_FAILED", `Connector ${this.id} not found`);
80026
- return info;
80100
+ const obj = await this.objectsImpl.getFullObject(this.id);
80101
+ if (!obj || obj.type !== "connector") throw new KernelError("OPERATION_FAILED", `Connector ${this.id} not found`);
80102
+ return obj;
80027
80103
  }
80028
80104
  };
80029
80105
 
@@ -80039,9 +80115,9 @@ var ChartHandleImpl = class _ChartHandleImpl extends FloatingObjectHandleImpl {
80039
80115
  return new _ChartHandleImpl(receipt.id, this.objectsImpl, this.boundsReader);
80040
80116
  }
80041
80117
  async getData() {
80042
- const info = await this.objectsImpl.get(this.id);
80043
- if (!info) throw new KernelError("OPERATION_FAILED", `Chart ${this.id} not found`);
80044
- return info;
80118
+ const obj = await this.objectsImpl.getFullObject(this.id);
80119
+ if (!obj || obj.type !== "chart") throw new KernelError("OPERATION_FAILED", `Chart ${this.id} not found`);
80120
+ return obj;
80045
80121
  }
80046
80122
  };
80047
80123
 
@@ -80057,9 +80133,9 @@ var SmartArtHandleImpl = class _SmartArtHandleImpl extends FloatingObjectHandleI
80057
80133
  return new _SmartArtHandleImpl(receipt.id, this.objectsImpl, this.boundsReader);
80058
80134
  }
80059
80135
  async getData() {
80060
- const info = await this.objectsImpl.get(this.id);
80061
- if (!info) throw new KernelError("OPERATION_FAILED", `SmartArt ${this.id} not found`);
80062
- return info;
80136
+ const obj = await this.objectsImpl.getFullObject(this.id);
80137
+ if (!obj || obj.type !== "smartart") throw new KernelError("OPERATION_FAILED", `SmartArt ${this.id} not found`);
80138
+ return obj;
80063
80139
  }
80064
80140
  };
80065
80141
 
@@ -80075,9 +80151,9 @@ var SlicerHandleImpl = class _SlicerHandleImpl extends FloatingObjectHandleImpl
80075
80151
  return new _SlicerHandleImpl(receipt.id, this.objectsImpl, this.boundsReader);
80076
80152
  }
80077
80153
  async getData() {
80078
- const info = await this.objectsImpl.get(this.id);
80079
- if (!info) throw new KernelError("OPERATION_FAILED", `Slicer ${this.id} not found`);
80080
- return info;
80154
+ const obj = await this.objectsImpl.getFullObject(this.id);
80155
+ if (!obj) throw new KernelError("OPERATION_FAILED", `Slicer ${this.id} not found`);
80156
+ return obj;
80081
80157
  }
80082
80158
  };
80083
80159
 
@@ -80093,12 +80169,50 @@ var OleObjectHandleImpl = class _OleObjectHandleImpl extends FloatingObjectHandl
80093
80169
  return new _OleObjectHandleImpl(receipt.id, this.objectsImpl, this.boundsReader);
80094
80170
  }
80095
80171
  async getData() {
80096
- const info = await this.objectsImpl.get(this.id);
80097
- if (!info) throw new KernelError("OPERATION_FAILED", `OleObject ${this.id} not found`);
80098
- return info;
80172
+ const obj = await this.objectsImpl.getFullObject(this.id);
80173
+ if (!obj || obj.type !== "oleObject") throw new KernelError("OPERATION_FAILED", `OleObject ${this.id} not found`);
80174
+ return obj;
80099
80175
  }
80100
80176
  };
80101
80177
 
80178
+ // ../../kernel/src/api/worksheet/handles/floating-object-handle-factory.ts
80179
+ function createFloatingObjectHandle(id, type, objectsImpl, boundsReader, shapeType) {
80180
+ switch (type) {
80181
+ case "shape":
80182
+ return new ShapeHandleImpl(
80183
+ id,
80184
+ shapeType ?? "rect",
80185
+ objectsImpl,
80186
+ boundsReader
80187
+ );
80188
+ case "picture":
80189
+ return new PictureHandleImpl(id, objectsImpl, boundsReader);
80190
+ case "textbox":
80191
+ return new TextBoxHandleImpl(id, objectsImpl, boundsReader);
80192
+ case "drawing":
80193
+ return new DrawingHandleImpl(id, objectsImpl, boundsReader);
80194
+ case "equation":
80195
+ return new EquationHandleImpl(id, objectsImpl, boundsReader);
80196
+ case "connector":
80197
+ return new ConnectorHandleImpl(id, objectsImpl, boundsReader);
80198
+ case "chart":
80199
+ return new ChartHandleImpl(id, objectsImpl, boundsReader);
80200
+ case "smartart":
80201
+ return new SmartArtHandleImpl(id, objectsImpl, boundsReader);
80202
+ case "slicer":
80203
+ return new SlicerHandleImpl(id, objectsImpl, boundsReader);
80204
+ case "oleObject":
80205
+ return new OleObjectHandleImpl(id, objectsImpl, boundsReader);
80206
+ default:
80207
+ return new FloatingObjectHandleImpl(
80208
+ id,
80209
+ type,
80210
+ objectsImpl,
80211
+ boundsReader
80212
+ );
80213
+ }
80214
+ }
80215
+
80102
80216
  // ../../kernel/src/api/worksheet/collections/object-collection-impl.ts
80103
80217
  var WorksheetObjectCollectionImpl = class {
80104
80218
  constructor(objectsImpl, boundsReader) {
@@ -80167,30 +80281,7 @@ var WorksheetObjectCollectionImpl = class {
80167
80281
  return this.objectsImpl.ungroup(groupId);
80168
80282
  }
80169
80283
  createHandle(id, type) {
80170
- switch (type) {
80171
- case "shape":
80172
- return new ShapeHandleImpl(id, "rect", this.objectsImpl, this.boundsReader);
80173
- case "picture":
80174
- return new PictureHandleImpl(id, this.objectsImpl, this.boundsReader);
80175
- case "textbox":
80176
- return new TextBoxHandleImpl(id, this.objectsImpl, this.boundsReader);
80177
- case "drawing":
80178
- return new DrawingHandleImpl(id, this.objectsImpl, this.boundsReader);
80179
- case "equation":
80180
- return new EquationHandleImpl(id, this.objectsImpl, this.boundsReader);
80181
- case "connector":
80182
- return new ConnectorHandleImpl(id, this.objectsImpl, this.boundsReader);
80183
- case "chart":
80184
- return new ChartHandleImpl(id, this.objectsImpl, this.boundsReader);
80185
- case "smartart":
80186
- return new SmartArtHandleImpl(id, this.objectsImpl, this.boundsReader);
80187
- case "slicer":
80188
- return new SlicerHandleImpl(id, this.objectsImpl, this.boundsReader);
80189
- case "oleObject":
80190
- return new OleObjectHandleImpl(id, this.objectsImpl, this.boundsReader);
80191
- default:
80192
- return new FloatingObjectHandleImpl(id, type, this.objectsImpl, this.boundsReader);
80193
- }
80284
+ return createFloatingObjectHandle(id, type, this.objectsImpl, this.boundsReader);
80194
80285
  }
80195
80286
  };
80196
80287
 
@@ -80338,9 +80429,9 @@ var WordArtHandleImpl = class _WordArtHandleImpl extends FloatingObjectHandleImp
80338
80429
  return new _WordArtHandleImpl(receipt.id, this.objectsImpl, this.boundsReader);
80339
80430
  }
80340
80431
  async getData() {
80341
- const info = await this.objectsImpl.get(this.id);
80342
- if (!info) throw new KernelError("OPERATION_FAILED", `WordArt ${this.id} not found`);
80343
- return info;
80432
+ const obj = await this.objectsImpl.getFullObject(this.id);
80433
+ if (!obj || obj.type !== "textbox") throw new KernelError("OPERATION_FAILED", `WordArt ${this.id} not found`);
80434
+ return obj;
80344
80435
  }
80345
80436
  };
80346
80437
 
@@ -80618,7 +80709,7 @@ function chartConfigToInternal(config) {
80618
80709
  series: config.series,
80619
80710
  dataLabels: config.dataLabels,
80620
80711
  pieSlice: config.pieSlice,
80621
- trendline: config.trendline,
80712
+ trendline: config.trendlines ?? (config.trendline ? [config.trendline] : void 0),
80622
80713
  showLines: config.showLines,
80623
80714
  smoothLines: config.smoothLines,
80624
80715
  radarFilled: config.radarFilled,
@@ -80635,7 +80726,7 @@ function chartConfigToInternal(config) {
80635
80726
  splitValue: config.splitValue,
80636
80727
  widthCells: config.width,
80637
80728
  heightCells: config.height,
80638
- definition: buildStatisticalExtra(config)
80729
+ ooxml: buildStatisticalExtra(config)
80639
80730
  };
80640
80731
  }
80641
80732
  function chartUpdatesToInternal(updates) {
@@ -80662,7 +80753,11 @@ function chartUpdatesToInternal(updates) {
80662
80753
  if (updates.series !== void 0) result.series = updates.series;
80663
80754
  if (updates.dataLabels !== void 0) result.dataLabels = updates.dataLabels;
80664
80755
  if (updates.pieSlice !== void 0) result.pieSlice = updates.pieSlice;
80665
- if (updates.trendline !== void 0) result.trendline = updates.trendline;
80756
+ if (updates.trendlines !== void 0) {
80757
+ result.trendline = updates.trendlines;
80758
+ } else if (updates.trendline !== void 0) {
80759
+ result.trendline = updates.trendline ? [updates.trendline] : void 0;
80760
+ }
80666
80761
  if (updates.showLines !== void 0) result.showLines = updates.showLines;
80667
80762
  if (updates.smoothLines !== void 0) result.smoothLines = updates.smoothLines;
80668
80763
  if (updates.radarFilled !== void 0) result.radarFilled = updates.radarFilled;
@@ -80679,7 +80774,7 @@ function chartUpdatesToInternal(updates) {
80679
80774
  if (updates.splitValue !== void 0) result.splitValue = updates.splitValue;
80680
80775
  if (updates.name !== void 0) result.name = updates.name;
80681
80776
  const statisticalExtra = buildStatisticalExtra(updates);
80682
- if (statisticalExtra) result.definition = statisticalExtra;
80777
+ if (statisticalExtra) result.ooxml = statisticalExtra;
80683
80778
  return result;
80684
80779
  }
80685
80780
  function serializedChartToChart(chart) {
@@ -80704,7 +80799,8 @@ function serializedChartToChart(chart) {
80704
80799
  series: chart.series,
80705
80800
  dataLabels: chart.dataLabels,
80706
80801
  pieSlice: chart.pieSlice,
80707
- trendline: chart.trendline,
80802
+ trendline: Array.isArray(chart.trendline) ? chart.trendline[0] : chart.trendline,
80803
+ trendlines: chart.trendline,
80708
80804
  showLines: chart.showLines,
80709
80805
  smoothLines: chart.smoothLines,
80710
80806
  radarFilled: chart.radarFilled,
@@ -80719,7 +80815,7 @@ function serializedChartToChart(chart) {
80719
80815
  bubbleScale: chart.bubbleScale,
80720
80816
  splitType: chart.splitType,
80721
80817
  splitValue: chart.splitValue,
80722
- ...unpackStatisticalExtra(chart.definition),
80818
+ ...unpackStatisticalExtra(chart.ooxml),
80723
80819
  name: chart.name || void 0,
80724
80820
  createdAt: chart.createdAt,
80725
80821
  updatedAt: chart.updatedAt
@@ -80747,7 +80843,10 @@ async function applyUpdate(ctx, sheetId, chartId, updates) {
80747
80843
  function ensurePointsArray(series, minLength) {
80748
80844
  const points = [...series.points ?? []];
80749
80845
  while (points.length <= minLength) {
80750
- points.push({});
80846
+ points.push({ idx: points.length });
80847
+ }
80848
+ for (let i = 0; i < points.length; i++) {
80849
+ points[i].idx = i;
80751
80850
  }
80752
80851
  return points;
80753
80852
  }
@@ -80974,40 +81073,6 @@ init_cjs_shims();
80974
81073
  init_a1();
80975
81074
  init_compute_core();
80976
81075
  init_errors();
80977
- function cellRefToA1(cellRef) {
80978
- const parts = cellRef.split(":");
80979
- if (parts.length !== 2) return cellRef;
80980
- const col = parseInt(parts[0], 10);
80981
- const row = parseInt(parts[1], 10);
80982
- if (isNaN(col) || isNaN(row)) return cellRef;
80983
- return toA12(row, col);
80984
- }
80985
- function toApiComment(c) {
80986
- const text = c.content ?? c.runs.map((r) => r.text).join("");
80987
- return {
80988
- id: c.id,
80989
- cellId: c.cellRef,
80990
- cellAddress: cellRefToA1(c.cellRef),
80991
- author: c.author,
80992
- authorId: c.authorId,
80993
- text,
80994
- content: c.runs.length > 0 ? c.runs.map((r) => ({
80995
- text: r.text,
80996
- bold: r.bold || void 0,
80997
- italic: r.italic || void 0,
80998
- underline: r.underline || void 0,
80999
- strikethrough: r.strikethrough || void 0,
81000
- color: r.color ?? void 0,
81001
- fontName: r.fontName ?? void 0,
81002
- fontSize: r.fontSize ?? void 0
81003
- })) : void 0,
81004
- threadId: c.threadId || void 0,
81005
- parentId: c.parentId ?? void 0,
81006
- resolved: c.resolved ?? void 0,
81007
- createdAt: c.createdAt ?? 0,
81008
- modifiedAt: c.modifiedAt ?? void 0
81009
- };
81010
- }
81011
81076
  function propagateResolved(comments) {
81012
81077
  const rootResolved = /* @__PURE__ */ new Map();
81013
81078
  for (const c of comments) {
@@ -81133,7 +81198,7 @@ var WorksheetCommentsImpl = class {
81133
81198
  "addCommentByPosition: no comment returned in MutationResult.data"
81134
81199
  );
81135
81200
  }
81136
- return toApiComment(comment);
81201
+ return comment;
81137
81202
  }
81138
81203
  async update(commentId, text) {
81139
81204
  if (!text || text.trim().length === 0) {
@@ -81152,7 +81217,7 @@ var WorksheetCommentsImpl = class {
81152
81217
  }
81153
81218
  async list() {
81154
81219
  const comments = await this.ctx.computeBridge.getAllComments(this.sheetId);
81155
- return propagateResolved(comments.map(toApiComment));
81220
+ return propagateResolved(comments);
81156
81221
  }
81157
81222
  async getForCell(a, b) {
81158
81223
  const { row, col } = resolveCell(a, b);
@@ -81161,7 +81226,7 @@ var WorksheetCommentsImpl = class {
81161
81226
  row,
81162
81227
  col
81163
81228
  );
81164
- return comments.map(toApiComment);
81229
+ return comments;
81165
81230
  }
81166
81231
  async addReply(commentId, text, author) {
81167
81232
  const parent = await this.ctx.computeBridge.getComment(this.sheetId, commentId);
@@ -81178,7 +81243,7 @@ var WorksheetCommentsImpl = class {
81178
81243
  author,
81179
81244
  { parentId: commentId }
81180
81245
  );
81181
- return toApiComment(comment);
81246
+ return comment;
81182
81247
  }
81183
81248
  async getThread(commentId) {
81184
81249
  const comment = await this.ctx.computeBridge.getComment(this.sheetId, commentId);
@@ -81187,11 +81252,11 @@ var WorksheetCommentsImpl = class {
81187
81252
  }
81188
81253
  const threadId = comment.threadId ?? comment.id;
81189
81254
  const thread = await this.ctx.computeBridge.getCommentThread(this.sheetId, threadId);
81190
- return propagateResolved(thread.map(toApiComment));
81255
+ return propagateResolved(thread);
81191
81256
  }
81192
81257
  async getById(commentId) {
81193
81258
  const comment = await this.ctx.computeBridge.getComment(this.sheetId, commentId);
81194
- return comment ? toApiComment(comment) : null;
81259
+ return comment ?? null;
81195
81260
  }
81196
81261
  };
81197
81262
 
@@ -81414,18 +81479,9 @@ var WorksheetFiltersImpl = class {
81414
81479
  const filters = await this.ctx.computeBridge.getFiltersInSheet(this.sheetId);
81415
81480
  if (filters.length === 0) return null;
81416
81481
  const filter = filters[0];
81417
- const columns = /* @__PURE__ */ new Map();
81418
- if (filter.columnFilters) {
81419
- for (const [key, value] of Object.entries(filter.columnFilters)) {
81420
- const colIdx = parseInt(key, 10);
81421
- if (!isNaN(colIdx) && value) {
81422
- columns.set(colIdx, value);
81423
- }
81424
- }
81425
- }
81426
81482
  return {
81427
81483
  range: `${toA12(filter.startRow ?? 0, filter.startCol ?? 0)}:${toA12(filter.endRow ?? 0, filter.endCol ?? 0)}`,
81428
- columns
81484
+ columnFilters: filter.columnFilters ?? {}
81429
81485
  };
81430
81486
  }
81431
81487
  async getForRange(range2) {
@@ -81496,9 +81552,9 @@ var WorksheetFiltersImpl = class {
81496
81552
  async list() {
81497
81553
  const raw = await this.ctx.computeBridge.getFiltersInSheet(this.sheetId);
81498
81554
  return raw.map((f) => ({
81499
- id: f.id ?? f.filterId,
81500
- range: f.range,
81501
- columns: f.columns
81555
+ id: f.id,
81556
+ range: void 0,
81557
+ columnFilters: f.columnFilters
81502
81558
  }));
81503
81559
  }
81504
81560
  async listDetails() {
@@ -81516,13 +81572,22 @@ var WorksheetFiltersImpl = class {
81516
81572
  }
81517
81573
  async getSortState(filterId) {
81518
81574
  try {
81519
- return await this.ctx.computeBridge.getFilterSortState(this.sheetId, filterId);
81575
+ const sortState = await this.ctx.computeBridge.getFilterSortState(this.sheetId, filterId);
81576
+ if (!sortState) return null;
81577
+ return {
81578
+ column: sortState.columnCellId,
81579
+ direction: sortState.order === "asc" ? "asc" : "desc"
81580
+ };
81520
81581
  } catch {
81521
81582
  return null;
81522
81583
  }
81523
81584
  }
81524
81585
  async setSortState(filterId, state) {
81525
- await this.ctx.computeBridge.setFilterSortState(this.sheetId, filterId, state);
81586
+ await this.ctx.computeBridge.setFilterSortState(this.sheetId, filterId, {
81587
+ columnCellId: String(state.column),
81588
+ order: state.direction === "asc" ? "asc" : "desc",
81589
+ sortBy: "value"
81590
+ });
81526
81591
  }
81527
81592
  };
81528
81593
 
@@ -81556,6 +81621,7 @@ init_cjs_shims();
81556
81621
 
81557
81622
  // ../../number-formats/src/constants.ts
81558
81623
  init_cjs_shims();
81624
+ var import_constants4 = require("@mog-sdk/spreadsheet-contracts/number-formats/constants");
81559
81625
 
81560
81626
  // ../../number-formats/src/format-utils.ts
81561
81627
  init_cjs_shims();
@@ -82898,7 +82964,12 @@ var WorksheetPivotsImpl = class _WorksheetPivotsImpl {
82898
82964
  }
82899
82965
  async queryPivot(pivotName, filters) {
82900
82966
  const pivot = await this.findPivotByName(pivotName);
82901
- if (!pivot) return null;
82967
+ if (!pivot) {
82968
+ throw new KernelError(
82969
+ "COMPUTE_ERROR",
82970
+ `queryPivot: Pivot table "${pivotName}" not found on this sheet`
82971
+ );
82972
+ }
82902
82973
  const pivotId = pivot.id ?? pivot.name;
82903
82974
  const result = await this.ctx.pivot.compute(this.sheetId, pivotId);
82904
82975
  if (!result) return null;
@@ -83679,12 +83750,35 @@ var WorksheetSlicersImpl = class {
83679
83750
  }
83680
83751
  async add(config) {
83681
83752
  const caption = config.caption ?? config.name ?? "";
83753
+ const source = config.source ?? {
83754
+ type: "table",
83755
+ tableId: config.tableName ?? "",
83756
+ columnCellId: config.columnName ?? ""
83757
+ };
83758
+ const defaultStyle = {
83759
+ columnCount: 1,
83760
+ buttonHeight: 30,
83761
+ showSelectionIndicator: true,
83762
+ crossFilter: "showItemsWithDataAtTop",
83763
+ customListSort: true,
83764
+ showItemsWithNoData: true,
83765
+ sortOrder: "ascending"
83766
+ };
83682
83767
  const storedConfig = {
83683
- ...config,
83684
- caption
83768
+ id: config.id ?? "",
83769
+ sheetId: config.sheetId ?? "",
83770
+ source,
83771
+ caption,
83772
+ style: config.style ?? defaultStyle,
83773
+ position: config.position,
83774
+ zIndex: config.zIndex ?? 0,
83775
+ locked: config.locked ?? false,
83776
+ showHeader: config.showHeader ?? true,
83777
+ multiSelect: config.multiSelect ?? true,
83778
+ selectedValues: config.selectedValues ?? []
83685
83779
  };
83686
83780
  await this.ctx.computeBridge.createSlicer(this.sheetId, storedConfig);
83687
- return storedConfig.id ?? "";
83781
+ return storedConfig.id;
83688
83782
  }
83689
83783
  async remove(slicerId) {
83690
83784
  validateSlicerId(slicerId, "deleteSlicer");
@@ -83846,11 +83940,15 @@ var WorksheetSlicersImpl = class {
83846
83940
  }
83847
83941
  async updateConfig(slicerId, updates) {
83848
83942
  validateSlicerId(slicerId, "updateSlicerConfig");
83849
- await this.ctx.computeBridge.updateSlicerConfig(
83850
- this.sheetId,
83851
- slicerId,
83852
- updates
83853
- );
83943
+ const bridgeUpdate = {};
83944
+ if (updates.caption !== void 0) bridgeUpdate.caption = updates.caption;
83945
+ if (updates.name !== void 0 && bridgeUpdate.caption === void 0) {
83946
+ bridgeUpdate.caption = updates.name;
83947
+ }
83948
+ if (updates.style !== void 0) bridgeUpdate.style = updates.style;
83949
+ if (updates.position !== void 0) bridgeUpdate.position = updates.position;
83950
+ if (updates.showHeader !== void 0) bridgeUpdate.showHeader = updates.showHeader;
83951
+ await this.ctx.computeBridge.updateSlicerConfig(this.sheetId, slicerId, bridgeUpdate);
83854
83952
  }
83855
83953
  async getState(slicerId) {
83856
83954
  const state = await this.ctx.computeBridge.getSlicerState(this.sheetId, slicerId);
@@ -84444,6 +84542,7 @@ function toBridgeTextToColumnsOptions(options) {
84444
84542
  // ../../kernel/src/api/worksheet/tables.ts
84445
84543
  init_cjs_shims();
84446
84544
  init_errors();
84545
+ init_value_conversions();
84447
84546
 
84448
84547
  // ../../kernel/src/api/worksheet/operations/table-operations.ts
84449
84548
  init_cjs_shims();
@@ -84465,31 +84564,15 @@ function bridgeTableToTableInfo(table) {
84465
84564
  const endRowA1 = table.range.endRow + 1;
84466
84565
  const range2 = `${startLetter}${startRowA1}:${endLetter}${endRowA1}`;
84467
84566
  return {
84468
- id: table.id,
84469
- name: table.name,
84470
- range: range2,
84471
- hasHeaders: table.hasHeaderRow,
84472
- showTotals: table.hasTotalsRow,
84473
- style: table.style || void 0,
84474
- highlightFirstColumn: table.emphasizeFirstColumn,
84475
- highlightLastColumn: table.emphasizeLastColumn,
84476
- showBandedColumns: table.bandedColumns,
84477
- showBandedRows: table.bandedRows,
84478
- showFilterButton: table.showFilterButtons,
84479
- showHeaders: table.hasHeaderRow,
84480
- columns: table.columns.map((col) => ({
84481
- name: col.name,
84482
- index: col.index,
84483
- totalFunction: col.totalsFunction ?? void 0,
84484
- calculatedFormula: col.calculatedFormula ?? void 0
84485
- }))
84567
+ ...table,
84568
+ range: range2
84486
84569
  };
84487
84570
  }
84488
84571
  function getTableColumnDataCellsFromInfo(table, colIndex) {
84489
84572
  const parsed = parseA1Range(table.range);
84490
84573
  if (!parsed) return [];
84491
- const dataStartRow = table.hasHeaders ? parsed.startRow + 1 : parsed.startRow;
84492
- const dataEndRow = table.showTotals ? parsed.endRow - 1 : parsed.endRow;
84574
+ const dataStartRow = table.hasHeaderRow ? parsed.startRow + 1 : parsed.startRow;
84575
+ const dataEndRow = table.hasTotalsRow ? parsed.endRow - 1 : parsed.endRow;
84493
84576
  if (dataStartRow > dataEndRow) return [];
84494
84577
  const col = parsed.startCol + colIndex;
84495
84578
  if (col > parsed.endCol) return [];
@@ -84502,15 +84585,15 @@ function getTableColumnDataCellsFromInfo(table, colIndex) {
84502
84585
  function getDataBodyRangeFromInfo(table) {
84503
84586
  const parsed = parseA1Range(table.range);
84504
84587
  if (!parsed) return null;
84505
- const dataStartRow = table.hasHeaders ? parsed.startRow + 1 : parsed.startRow;
84506
- const dataEndRow = table.showTotals ? parsed.endRow - 1 : parsed.endRow;
84588
+ const dataStartRow = table.hasHeaderRow ? parsed.startRow + 1 : parsed.startRow;
84589
+ const dataEndRow = table.hasTotalsRow ? parsed.endRow - 1 : parsed.endRow;
84507
84590
  if (dataStartRow > dataEndRow) return null;
84508
84591
  const startLetter = colToLetter3(parsed.startCol);
84509
84592
  const endLetter = colToLetter3(parsed.endCol);
84510
84593
  return `${startLetter}${dataStartRow + 1}:${endLetter}${dataEndRow + 1}`;
84511
84594
  }
84512
84595
  function getHeaderRowRangeFromInfo(table) {
84513
- if (!table.hasHeaders) return null;
84596
+ if (!table.hasHeaderRow) return null;
84514
84597
  const parsed = parseA1Range(table.range);
84515
84598
  if (!parsed) return null;
84516
84599
  const startLetter = colToLetter3(parsed.startCol);
@@ -84519,7 +84602,7 @@ function getHeaderRowRangeFromInfo(table) {
84519
84602
  return `${startLetter}${headerRow}:${endLetter}${headerRow}`;
84520
84603
  }
84521
84604
  function getTotalRowRangeFromInfo(table) {
84522
- if (!table.showTotals) return null;
84605
+ if (!table.hasTotalsRow) return null;
84523
84606
  const parsed = parseA1Range(table.range);
84524
84607
  if (!parsed) return null;
84525
84608
  const startLetter = colToLetter3(parsed.startCol);
@@ -84615,23 +84698,23 @@ var WorksheetTablesImpl = class {
84615
84698
  if (updates.name !== void 0) {
84616
84699
  await this.ctx.computeBridge.renameTable(tableName, updates.name);
84617
84700
  }
84618
- const boolOptionMap = {
84619
- highlightFirstColumn: "emphasizeFirstColumn",
84620
- highlightLastColumn: "emphasizeLastColumn",
84621
- showBandedColumns: "bandedColumns",
84622
- showBandedRows: "bandedRows",
84623
- showFilterButton: "showFilterButtons"
84624
- };
84625
- for (const [key, bridgeOption] of Object.entries(boolOptionMap)) {
84701
+ const boolOptions = [
84702
+ "emphasizeFirstColumn",
84703
+ "emphasizeLastColumn",
84704
+ "bandedColumns",
84705
+ "bandedRows",
84706
+ "showFilterButtons"
84707
+ ];
84708
+ for (const key of boolOptions) {
84626
84709
  if (updates[key] !== void 0) {
84627
- await this.ctx.computeBridge.setTableBoolOption(tableName, bridgeOption, updates[key]);
84710
+ await this.ctx.computeBridge.setTableBoolOption(tableName, key, updates[key]);
84628
84711
  }
84629
84712
  }
84630
- if (updates.showHeaders !== void 0) {
84631
- await this.setShowHeaders(tableName, updates.showHeaders);
84713
+ if (updates.hasHeaderRow !== void 0) {
84714
+ await this.setShowHeaders(tableName, updates.hasHeaderRow);
84632
84715
  }
84633
- if (updates.showTotals !== void 0) {
84634
- await this.setShowTotals(tableName, updates.showTotals);
84716
+ if (updates.hasTotalsRow !== void 0) {
84717
+ await this.setShowTotals(tableName, updates.hasTotalsRow);
84635
84718
  }
84636
84719
  }
84637
84720
  async getAtCell(row, col) {
@@ -84752,14 +84835,14 @@ var WorksheetTablesImpl = class {
84752
84835
  async setShowHeaders(tableName, visible) {
84753
84836
  const table = await this.get(tableName);
84754
84837
  if (!table) throw new KernelError("COMPUTE_ERROR", `Table not found: ${tableName}`);
84755
- if (table.hasHeaders !== visible) {
84838
+ if (table.hasHeaderRow !== visible) {
84756
84839
  await this.ctx.computeBridge.toggleHeaderRow(tableName);
84757
84840
  }
84758
84841
  }
84759
84842
  async setShowTotals(tableName, visible) {
84760
84843
  const table = await this.get(tableName);
84761
84844
  if (!table) throw new KernelError("COMPUTE_ERROR", `Table not found: ${tableName}`);
84762
- if ((table.showTotals ?? false) !== visible) {
84845
+ if (table.hasTotalsRow !== visible) {
84763
84846
  await this.ctx.computeBridge.toggleTotalsRow(tableName);
84764
84847
  }
84765
84848
  }
@@ -84793,8 +84876,8 @@ var WorksheetTablesImpl = class {
84793
84876
  if (!table) throw new KernelError("COMPUTE_ERROR", `Table not found: ${tableName}`);
84794
84877
  const parsed = parseA1Range2(table.range);
84795
84878
  if (!parsed) return 0;
84796
- const dataStartRow = table.hasHeaders ? parsed.startRow + 1 : parsed.startRow;
84797
- const dataEndRow = table.showTotals ? parsed.endRow - 1 : parsed.endRow;
84879
+ const dataStartRow = table.hasHeaderRow ? parsed.startRow + 1 : parsed.startRow;
84880
+ const dataEndRow = table.hasTotalsRow ? parsed.endRow - 1 : parsed.endRow;
84798
84881
  return Math.max(0, dataEndRow - dataStartRow + 1);
84799
84882
  }
84800
84883
  async getRowRange(tableName, index) {
@@ -84802,7 +84885,7 @@ var WorksheetTablesImpl = class {
84802
84885
  if (!table) throw new KernelError("COMPUTE_ERROR", `Table not found: ${tableName}`);
84803
84886
  const parsed = parseA1Range2(table.range);
84804
84887
  if (!parsed) throw new KernelError("COMPUTE_ERROR", `Invalid table range: ${table.range}`);
84805
- const dataStartRow = table.hasHeaders ? parsed.startRow + 1 : parsed.startRow;
84888
+ const dataStartRow = table.hasHeaderRow ? parsed.startRow + 1 : parsed.startRow;
84806
84889
  const absRow = dataStartRow + index;
84807
84890
  const startLetter = colToLetter3(parsed.startCol);
84808
84891
  const endLetter = colToLetter3(parsed.endCol);
@@ -84813,7 +84896,7 @@ var WorksheetTablesImpl = class {
84813
84896
  if (!table) throw new KernelError("COMPUTE_ERROR", `Table not found: ${tableName}`);
84814
84897
  const parsed = parseA1Range2(table.range);
84815
84898
  if (!parsed) return [];
84816
- const dataStartRow = table.hasHeaders ? parsed.startRow + 1 : parsed.startRow;
84899
+ const dataStartRow = table.hasHeaderRow ? parsed.startRow + 1 : parsed.startRow;
84817
84900
  const absRow = dataStartRow + index;
84818
84901
  return queryRangeValues(this.ctx, this.sheetId, absRow, parsed.startCol, absRow, parsed.endCol);
84819
84902
  }
@@ -84822,7 +84905,7 @@ var WorksheetTablesImpl = class {
84822
84905
  if (!table) throw new KernelError("COMPUTE_ERROR", `Table not found: ${tableName}`);
84823
84906
  const parsed = parseA1Range2(table.range);
84824
84907
  if (!parsed) return;
84825
- const dataStartRow = table.hasHeaders ? parsed.startRow + 1 : parsed.startRow;
84908
+ const dataStartRow = table.hasHeaderRow ? parsed.startRow + 1 : parsed.startRow;
84826
84909
  const absRow = dataStartRow + index;
84827
84910
  const edits = values.map((val, i) => ({
84828
84911
  row: absRow,
@@ -84841,15 +84924,15 @@ var WorksheetTablesImpl = class {
84841
84924
  if (!parsed) return null;
84842
84925
  const col = parsed.startCol + columnIndex;
84843
84926
  if (col > parsed.endCol) return null;
84844
- const dataStartRow = table.hasHeaders ? parsed.startRow + 1 : parsed.startRow;
84845
- const dataEndRow = table.showTotals ? parsed.endRow - 1 : parsed.endRow;
84927
+ const dataStartRow = table.hasHeaderRow ? parsed.startRow + 1 : parsed.startRow;
84928
+ const dataEndRow = table.hasTotalsRow ? parsed.endRow - 1 : parsed.endRow;
84846
84929
  if (dataStartRow > dataEndRow) return null;
84847
84930
  const letter = colToLetter3(col);
84848
84931
  return `${letter}${dataStartRow + 1}:${letter}${dataEndRow + 1}`;
84849
84932
  }
84850
84933
  async getColumnHeaderRange(tableName, columnIndex) {
84851
84934
  const table = await this.get(tableName);
84852
- if (!table || !table.hasHeaders) return null;
84935
+ if (!table || !table.hasHeaderRow) return null;
84853
84936
  const parsed = parseA1Range2(table.range);
84854
84937
  if (!parsed) return null;
84855
84938
  const col = parsed.startCol + columnIndex;
@@ -84870,7 +84953,7 @@ var WorksheetTablesImpl = class {
84870
84953
  }
84871
84954
  async getColumnTotalRange(tableName, columnIndex) {
84872
84955
  const table = await this.get(tableName);
84873
- if (!table || !table.showTotals) return null;
84956
+ if (!table || !table.hasTotalsRow) return null;
84874
84957
  const parsed = parseA1Range2(table.range);
84875
84958
  if (!parsed) return null;
84876
84959
  const col = parsed.startCol + columnIndex;
@@ -84886,8 +84969,8 @@ var WorksheetTablesImpl = class {
84886
84969
  if (!parsed) return [];
84887
84970
  const col = parsed.startCol + columnIndex;
84888
84971
  if (col > parsed.endCol) return [];
84889
- const dataStartRow = table.hasHeaders ? parsed.startRow + 1 : parsed.startRow;
84890
- const dataEndRow = table.showTotals ? parsed.endRow - 1 : parsed.endRow;
84972
+ const dataStartRow = table.hasHeaderRow ? parsed.startRow + 1 : parsed.startRow;
84973
+ const dataEndRow = table.hasTotalsRow ? parsed.endRow - 1 : parsed.endRow;
84891
84974
  if (dataStartRow > dataEndRow) return [];
84892
84975
  return queryRangeValues(this.ctx, this.sheetId, dataStartRow, col, dataEndRow, col);
84893
84976
  }
@@ -84898,7 +84981,7 @@ var WorksheetTablesImpl = class {
84898
84981
  if (!parsed) return;
84899
84982
  const col = parsed.startCol + columnIndex;
84900
84983
  if (col > parsed.endCol) return;
84901
- const dataStartRow = table.hasHeaders ? parsed.startRow + 1 : parsed.startRow;
84984
+ const dataStartRow = table.hasHeaderRow ? parsed.startRow + 1 : parsed.startRow;
84902
84985
  const edits = values.map((val, i) => ({
84903
84986
  row: dataStartRow + i,
84904
84987
  col,
@@ -84914,8 +84997,8 @@ var WorksheetTablesImpl = class {
84914
84997
  if (!table) throw new KernelError("COMPUTE_ERROR", `Table not found: ${tableName}`);
84915
84998
  const parsed = parseA1Range2(table.range);
84916
84999
  if (!parsed) return;
84917
- const dataStartRow = table.hasHeaders ? parsed.startRow + 1 : parsed.startRow;
84918
- const dataEndRow = table.showTotals ? parsed.endRow - 1 : parsed.endRow;
85000
+ const dataStartRow = table.hasHeaderRow ? parsed.startRow + 1 : parsed.startRow;
85001
+ const dataEndRow = table.hasTotalsRow ? parsed.endRow - 1 : parsed.endRow;
84919
85002
  if (dataStartRow > dataEndRow) return;
84920
85003
  const numCols = parsed.endCol - parsed.startCol + 1;
84921
85004
  const numRows = dataEndRow - dataStartRow + 1;
@@ -84935,7 +85018,7 @@ var WorksheetTablesImpl = class {
84935
85018
  const row = [];
84936
85019
  for (let c = 0; c < numCols; c++) {
84937
85020
  const cell = cellMap.get(`${dataStartRow + r},${parsed.startCol + c}`);
84938
- row.push(cell?.value ?? null);
85021
+ row.push(normalizeCellValue(cell?.value ?? null));
84939
85022
  }
84940
85023
  rows.push(row);
84941
85024
  }
@@ -85007,7 +85090,7 @@ async function queryRangeValues(ctx, sheetId, startRow, startCol, endRow, endCol
85007
85090
  for (let r = startRow; r <= endRow; r++) {
85008
85091
  for (let c = startCol; c <= endCol; c++) {
85009
85092
  const cell = cellMap.get(`${r},${c}`);
85010
- values.push(cell?.value ?? null);
85093
+ values.push(normalizeCellValue(cell?.value ?? null));
85011
85094
  }
85012
85095
  }
85013
85096
  return values;
@@ -85597,6 +85680,117 @@ var WorksheetViewImpl = class {
85597
85680
  }
85598
85681
  };
85599
85682
 
85683
+ // ../../kernel/src/api/worksheet/what-if.ts
85684
+ init_cjs_shims();
85685
+
85686
+ // ../../kernel/src/api/worksheet/operations/data-table-operations.ts
85687
+ init_cjs_shims();
85688
+ init_errors();
85689
+ async function dataTable(ctx, sheetId, formulaCell, options) {
85690
+ const formulaPos = resolveCell(formulaCell);
85691
+ const formulaCellId = await getCellIdAt2(ctx, sheetId, formulaPos.row, formulaPos.col);
85692
+ if (!formulaCellId) {
85693
+ throw new KernelError("COMPUTE_ERROR", `Formula cell ${formulaCell} has no content.`);
85694
+ }
85695
+ let rowInputCellId = null;
85696
+ if (options.rowInputCell) {
85697
+ const pos = resolveCell(options.rowInputCell);
85698
+ const cid = await getCellIdAt2(ctx, sheetId, pos.row, pos.col);
85699
+ if (!cid) {
85700
+ throw new KernelError(
85701
+ "COMPUTE_ERROR",
85702
+ `Row input cell ${options.rowInputCell} must contain a value before calling dataTable().`
85703
+ );
85704
+ }
85705
+ rowInputCellId = cid;
85706
+ }
85707
+ let colInputCellId = null;
85708
+ if (options.colInputCell) {
85709
+ const pos = resolveCell(options.colInputCell);
85710
+ const cid = await getCellIdAt2(ctx, sheetId, pos.row, pos.col);
85711
+ if (!cid) {
85712
+ throw new KernelError(
85713
+ "COMPUTE_ERROR",
85714
+ `Column input cell ${options.colInputCell} must contain a value before calling dataTable().`
85715
+ );
85716
+ }
85717
+ colInputCellId = cid;
85718
+ }
85719
+ const bridgeResult = await ctx.computeBridge.dataTable({
85720
+ formula_cell: formulaCellId,
85721
+ row_input_cell: rowInputCellId,
85722
+ col_input_cell: colInputCellId,
85723
+ row_values: options.rowValues,
85724
+ col_values: options.colValues
85725
+ });
85726
+ const result = bridgeResult;
85727
+ return {
85728
+ results: result.results,
85729
+ cellCount: result.cellCount ?? result.cell_count ?? 0,
85730
+ elapsedMs: result.elapsedMs ?? result.elapsed_ms ?? 0,
85731
+ cancelled: result.cancelled ?? false
85732
+ };
85733
+ }
85734
+
85735
+ // ../../kernel/src/api/worksheet/operations/goal-seek-operations.ts
85736
+ init_cjs_shims();
85737
+ init_errors();
85738
+ async function goalSeek(ctx, sheetId, targetCell, targetValue, changingCell) {
85739
+ const targetPos = resolveCell(targetCell);
85740
+ const changingPos = resolveCell(changingCell);
85741
+ const formulaCellId = await getCellIdAt2(
85742
+ ctx,
85743
+ sheetId,
85744
+ targetPos.row,
85745
+ targetPos.col
85746
+ );
85747
+ if (!formulaCellId) {
85748
+ throw new KernelError("COMPUTE_ERROR", `Target cell ${targetCell} has no content.`);
85749
+ }
85750
+ const inputCellId = await getCellIdAt2(
85751
+ ctx,
85752
+ sheetId,
85753
+ changingPos.row,
85754
+ changingPos.col
85755
+ );
85756
+ if (!inputCellId) {
85757
+ throw new KernelError("COMPUTE_ERROR", `Changing cell ${changingCell} has no content.`);
85758
+ }
85759
+ const changingData = await getCell(ctx, sheetId, changingPos.row, changingPos.col);
85760
+ const initialGuess = typeof changingData?.value === "number" ? changingData.value : 0;
85761
+ const bridgeResult = await ctx.computeBridge.goalSeek({
85762
+ formula_cell: formulaCellId,
85763
+ target: targetValue,
85764
+ input_cell: inputCellId,
85765
+ initial_guess: initialGuess
85766
+ });
85767
+ const result = bridgeResult;
85768
+ const solutionValue = result.solutionValue ?? result.solution_value;
85769
+ const iterations = result.iterations;
85770
+ if (result.found && solutionValue != null) {
85771
+ await setCell(ctx, sheetId, changingPos.row, changingPos.col, solutionValue);
85772
+ }
85773
+ return {
85774
+ found: result.found,
85775
+ value: solutionValue,
85776
+ iterations
85777
+ };
85778
+ }
85779
+
85780
+ // ../../kernel/src/api/worksheet/what-if.ts
85781
+ var WorksheetWhatIfImpl = class {
85782
+ constructor(ctx, sheetId) {
85783
+ this.ctx = ctx;
85784
+ this.sheetId = sheetId;
85785
+ }
85786
+ async goalSeek(targetCell, targetValue, changingCell) {
85787
+ return goalSeek(this.ctx, this.sheetId, targetCell, targetValue, changingCell);
85788
+ }
85789
+ async dataTable(formulaCell, options) {
85790
+ return dataTable(this.ctx, this.sheetId, formulaCell, options);
85791
+ }
85792
+ };
85793
+
85600
85794
  // ../../kernel/src/api/worksheet/objects.ts
85601
85795
  init_cjs_shims();
85602
85796
  init_errors();
@@ -86300,8 +86494,8 @@ function objectToInfo(obj) {
86300
86494
  flipH: obj.position?.flipH,
86301
86495
  flipV: obj.position?.flipV,
86302
86496
  zIndex: obj.zIndex,
86303
- visible: obj.visible,
86304
- groupId: obj.groupId,
86497
+ visible: "visible" in obj ? obj.visible : void 0,
86498
+ groupId: "groupId" in obj ? obj.groupId : void 0,
86305
86499
  anchorType: obj.position?.anchorType,
86306
86500
  altText: obj.altText
86307
86501
  };
@@ -86514,7 +86708,7 @@ async function getConnectorData(manager, connectorId) {
86514
86708
  }
86515
86709
  async function getGroupMembers(manager, _ctx, sheetId, groupId) {
86516
86710
  const objects = await manager.getObjectsInSheet(sheetId);
86517
- return objects.filter((obj) => obj.groupId === groupId).map((obj) => obj.id);
86711
+ return objects.filter((obj) => "groupId" in obj && obj.groupId === groupId).map((obj) => obj.id);
86518
86712
  }
86519
86713
  function deriveImageFormat(src) {
86520
86714
  const dataUrlMatch = src.match(/^data:image\/([^;,]+)/);
@@ -86563,6 +86757,7 @@ async function getConnectionSiteCount(manager, objectId) {
86563
86757
 
86564
86758
  // ../../kernel/src/api/worksheet/operations/shape-operations.ts
86565
86759
  init_cjs_shims();
86760
+ init_floating_object_mapper();
86566
86761
  function shapeObjectToShape(shape, sheetId) {
86567
86762
  return {
86568
86763
  id: shape.id,
@@ -86602,7 +86797,7 @@ function buildMutationReceipt2(change, action) {
86602
86797
  domain: "floatingObject",
86603
86798
  action,
86604
86799
  id: change.objectId,
86605
- object: change.data,
86800
+ object: change.data ? toFloatingObject(change.data) : createMinimalFloatingObject("shape", change.objectId, ""),
86606
86801
  bounds
86607
86802
  };
86608
86803
  }
@@ -86637,7 +86832,7 @@ async function createShape(ctx, sheetId, config) {
86637
86832
  domain: "floatingObject",
86638
86833
  action: "create",
86639
86834
  id: "",
86640
- object: { id: "", sheetId, type: "shape", shapeType: config.type },
86835
+ object: createMinimalFloatingObject("shape", "", sheetId),
86641
86836
  bounds: {
86642
86837
  x: 0,
86643
86838
  y: 0,
@@ -86727,7 +86922,7 @@ async function updateShape(ctx, sheetId, shapeId, updates) {
86727
86922
  domain: "floatingObject",
86728
86923
  action: "update",
86729
86924
  id: shapeId,
86730
- object: { id: shapeId, sheetId, type: "shape" },
86925
+ object: createMinimalFloatingObject("shape", shapeId, sheetId),
86731
86926
  bounds: { x: 0, y: 0, width: 0, height: 0, rotation: 0 }
86732
86927
  };
86733
86928
  }
@@ -87003,6 +87198,15 @@ var WorksheetObjectsImpl = class {
87003
87198
  async get(objectId) {
87004
87199
  return await getFloatingObject(this.mgr, this.ctx, this.sheetId, objectId);
87005
87200
  }
87201
+ /**
87202
+ * Get the full domain-typed FloatingObject for an object by ID.
87203
+ * Returns the discriminated union variant (ShapeObject, PictureObject, etc.)
87204
+ * directly from the manager, bypassing the API-level FloatingObjectInfo projection.
87205
+ */
87206
+ async getFullObject(objectId) {
87207
+ const obj = await this.mgr.getObject(objectId);
87208
+ return obj ?? null;
87209
+ }
87006
87210
  async computeObjectBounds(objectId) {
87007
87211
  const obj = await this.mgr.getObject(objectId);
87008
87212
  if (!obj) return null;
@@ -87371,7 +87575,7 @@ var WorksheetImpl = class {
87371
87575
  async getValue(a, b) {
87372
87576
  const { row, col } = resolveCell(a, b);
87373
87577
  const data = await getCell(this.ctx, this.sheetId, row, col);
87374
- return data?.value ?? null;
87578
+ return normalizeCellValue(data?.value ?? null);
87375
87579
  }
87376
87580
  async getData() {
87377
87581
  const range2 = await getUsedRange2(this.ctx, this.sheetId);
@@ -87383,7 +87587,7 @@ var WorksheetImpl = class {
87383
87587
  endRow: range2.endRow,
87384
87588
  endCol: range2.endCol
87385
87589
  });
87386
- return cellData.map((row) => row.map((cell) => cell.value ?? null));
87590
+ return cellData.map((row) => row.map((cell) => normalizeCellValue(cell.value ?? null)));
87387
87591
  }
87388
87592
  async getRange(a, b, c, d) {
87389
87593
  const bounds = resolveRange(a, b, c, d);
@@ -87507,7 +87711,7 @@ var WorksheetImpl = class {
87507
87711
  rowData.push({ value: null });
87508
87712
  } else {
87509
87713
  rowData.push({
87510
- value: viewportCellValueToCellValue(vc.value) ?? null,
87714
+ value: normalizeCellValue(vc.value) ?? null,
87511
87715
  formula: vc.formula,
87512
87716
  format: vc.format ?? void 0
87513
87717
  });
@@ -87534,10 +87738,10 @@ var WorksheetImpl = class {
87534
87738
  const { row, col } = resolveCell(address);
87535
87739
  const data = await getCell(this.ctx, this.sheetId, row, col);
87536
87740
  if (!data) return "";
87537
- const displayValue = await getDisplayValue2(this.ctx, this.sheetId, row, col);
87538
- let result = displayValue;
87741
+ const rawValue = cellValueToString(data.value);
87742
+ let result = rawValue;
87539
87743
  if (data.formula) {
87540
- result = displayValue !== "" ? `${displayValue}(${data.formula})` : `(${data.formula})`;
87744
+ result = rawValue !== "" ? `${rawValue}(${data.formula})` : `(${data.formula})`;
87541
87745
  }
87542
87746
  const styleHintsStr = await getStyleHints(this.ctx, this.sheetId, row, col);
87543
87747
  if (styleHintsStr) {
@@ -87578,7 +87782,7 @@ var WorksheetImpl = class {
87578
87782
  row,
87579
87783
  col,
87580
87784
  formula: vc.formula,
87581
- value: viewportCellValueToCellValue(vc.value)
87785
+ value: normalizeCellValue(vc.value)
87582
87786
  });
87583
87787
  }
87584
87788
  }
@@ -87603,8 +87807,8 @@ var WorksheetImpl = class {
87603
87807
  rowValues.push(`${cellAddr}:`);
87604
87808
  continue;
87605
87809
  }
87606
- const displayValue = vc.formatted ?? viewportCellValueToString(vc.value);
87607
- let cellStr = displayValue;
87810
+ const rawValue = cellValueToString(vc.value);
87811
+ let cellStr = rawValue;
87608
87812
  if (vc.formula) {
87609
87813
  const abbreviation = formulaAnalysis.formulaToId.get(`${row},${col}`);
87610
87814
  if (abbreviation) {
@@ -87625,7 +87829,7 @@ var WorksheetImpl = class {
87625
87829
  const styleCells = rangeData.cells.map((vc) => ({
87626
87830
  row: vc.row,
87627
87831
  col: vc.col,
87628
- value: viewportCellValueToCellValue(vc.value),
87832
+ value: normalizeCellValue(vc.value),
87629
87833
  format: vc.format
87630
87834
  }));
87631
87835
  const styleLines = analyzeStylePatterns(styleCells);
@@ -87647,7 +87851,7 @@ var WorksheetImpl = class {
87647
87851
  const leftCellData = leftRange.cells.map((vc) => ({
87648
87852
  row: vc.row,
87649
87853
  col: vc.col,
87650
- value: viewportCellValueToCellValue(vc.value),
87854
+ value: normalizeCellValue(vc.value),
87651
87855
  formatted: vc.formatted ?? void 0,
87652
87856
  indent: 0
87653
87857
  // indent not available from queryRange; would need format.indent
@@ -87676,7 +87880,7 @@ var WorksheetImpl = class {
87676
87880
  const aboveCellData = aboveRange.cells.map((vc) => ({
87677
87881
  row: vc.row,
87678
87882
  col: vc.col,
87679
- value: viewportCellValueToCellValue(vc.value),
87883
+ value: normalizeCellValue(vc.value),
87680
87884
  formatted: vc.formatted ?? void 0
87681
87885
  }));
87682
87886
  const aboveLine = buildAboveContext(
@@ -87815,7 +88019,7 @@ var WorksheetImpl = class {
87815
88019
  const cells = (rowMap.get(row) ?? []).slice().sort((a, b) => a.col - b.col);
87816
88020
  const rowData = [];
87817
88021
  for (const vc of cells) {
87818
- const rawValue = viewportCellValueToString(vc.value);
88022
+ const rawValue = cellValueToString(vc.value);
87819
88023
  const addr = toA12(vc.row, vc.col);
87820
88024
  if (vc.formula) {
87821
88025
  rowData.push(`${addr}:${rawValue}(=${vc.formula})`);
@@ -88023,7 +88227,7 @@ var WorksheetImpl = class {
88023
88227
  fields.push("");
88024
88228
  continue;
88025
88229
  }
88026
- let str = cell.formatted != null && cell.formatted !== "" ? cell.formatted : isCellError(val) ? `#${val.value}!` : String(val);
88230
+ let str = cell.formatted != null && cell.formatted !== "" ? cell.formatted : String(normalizeCellValue(val));
88027
88231
  if (str.length > 0 && "=+-@".includes(str[0])) {
88028
88232
  str = " " + str;
88029
88233
  }
@@ -88076,7 +88280,7 @@ var WorksheetImpl = class {
88076
88280
  const row = cellData[i];
88077
88281
  const obj = {};
88078
88282
  for (let j = 0; j < headers.length; j++) {
88079
- obj[headers[j]] = row[j]?.value ?? null;
88283
+ obj[headers[j]] = normalizeCellValue(row[j]?.value ?? null);
88080
88284
  }
88081
88285
  result.push(obj);
88082
88286
  }
@@ -88127,48 +88331,6 @@ var WorksheetImpl = class {
88127
88331
  });
88128
88332
  return formatValues(this.ctx, bridgeEntries);
88129
88333
  }
88130
- async goalSeek(targetCell, targetValue, changingCell) {
88131
- const sheetId = this.sheetId;
88132
- const targetPos = resolveCell(targetCell);
88133
- const changingPos = resolveCell(changingCell);
88134
- const formulaCellId = await getCellIdAt2(
88135
- this.ctx,
88136
- sheetId,
88137
- targetPos.row,
88138
- targetPos.col
88139
- );
88140
- if (!formulaCellId) {
88141
- throw new KernelError("COMPUTE_ERROR", `Target cell ${targetCell} has no content.`);
88142
- }
88143
- const inputCellId = await getCellIdAt2(
88144
- this.ctx,
88145
- sheetId,
88146
- changingPos.row,
88147
- changingPos.col
88148
- );
88149
- if (!inputCellId) {
88150
- throw new KernelError("COMPUTE_ERROR", `Changing cell ${changingCell} has no content.`);
88151
- }
88152
- const changingData = await getCell(this.ctx, sheetId, changingPos.row, changingPos.col);
88153
- const initialGuess = typeof changingData?.value === "number" ? changingData.value : 0;
88154
- const bridgeResult = await this.ctx.computeBridge.goalSeek({
88155
- formula_cell: formulaCellId,
88156
- target: targetValue,
88157
- input_cell: inputCellId,
88158
- initial_guess: initialGuess
88159
- });
88160
- const result = bridgeResult;
88161
- const solutionValue = result.solutionValue ?? result.solution_value;
88162
- const iterations = result.iterations;
88163
- if (result.found && solutionValue != null) {
88164
- await setCell(this.ctx, sheetId, changingPos.row, changingPos.col, solutionValue);
88165
- }
88166
- return {
88167
- found: result.found,
88168
- value: solutionValue,
88169
- iterations
88170
- };
88171
- }
88172
88334
  // ===========================================================================
88173
88335
  // Visibility
88174
88336
  // ===========================================================================
@@ -88506,6 +88668,9 @@ var WorksheetImpl = class {
88506
88668
  get protection() {
88507
88669
  return this._protection ??= new WorksheetProtectionImpl(this.ctx, this.sheetId);
88508
88670
  }
88671
+ get whatIf() {
88672
+ return this._whatIf ??= new WorksheetWhatIfImpl(this.ctx, this.sheetId);
88673
+ }
88509
88674
  get print() {
88510
88675
  return this._print ??= new WorksheetPrintImpl(this.ctx, this.sheetId);
88511
88676
  }
@@ -88737,8 +88902,7 @@ var WorkbookStylesImpl = class {
88737
88902
  this.ctx = ctx;
88738
88903
  }
88739
88904
  async getTableStyles() {
88740
- const styles = await this.ctx.computeBridge.getAllCustomTableStyles();
88741
- return styles;
88905
+ return this.ctx.computeBridge.getAllCustomTableStyles();
88742
88906
  }
88743
88907
  async createTableStyle(config) {
88744
88908
  const result = await this.ctx.computeBridge.createCustomTableStyle(
@@ -90666,24 +90830,41 @@ var WorkbookImpl = class {
90666
90830
  timestamp: cp.timestamp
90667
90831
  }));
90668
90832
  }
90669
- async calculate(calculationType) {
90670
- const type = calculationType ?? "full";
90671
- try {
90672
- switch (type) {
90673
- case "recalculate":
90674
- await this.ctx.computeBridge.fullRecalc();
90675
- break;
90676
- case "full":
90677
- await this.ctx.computeBridge.fullRecalc();
90678
- break;
90679
- case "fullRebuild":
90680
- await this.ctx.computeBridge.fullRecalc();
90681
- break;
90833
+ async calculate(options) {
90834
+ const opts = typeof options === "string" ? { calculationType: options } : options ?? {};
90835
+ const recalcOptions = {};
90836
+ if (opts.iterative !== void 0) {
90837
+ if (typeof opts.iterative === "boolean") {
90838
+ recalcOptions.iterative = opts.iterative;
90839
+ } else {
90840
+ recalcOptions.iterative = true;
90841
+ if (opts.iterative.maxIterations !== void 0) {
90842
+ recalcOptions.maxIterations = opts.iterative.maxIterations;
90843
+ }
90844
+ if (opts.iterative.maxChange !== void 0) {
90845
+ recalcOptions.maxChange = opts.iterative.maxChange;
90846
+ }
90682
90847
  }
90848
+ }
90849
+ try {
90850
+ const result = await this.ctx.computeBridge.fullRecalc(recalcOptions);
90851
+ return {
90852
+ hasCircularRefs: result.metrics?.hasCircularRefs ?? false,
90853
+ converged: result.metrics?.iterativeConverged ?? false,
90854
+ iterations: result.metrics?.iterativeIterations ?? 0,
90855
+ maxDelta: result.metrics?.iterativeMaxDelta ?? 0,
90856
+ circularCellCount: result.metrics?.circularCellCount ?? 0
90857
+ };
90683
90858
  } catch (e) {
90684
90859
  const msg = String(e);
90685
90860
  if (msg.includes("Unknown napi method") || msg.includes("not a function") || msg.includes("not found")) {
90686
- return;
90861
+ return {
90862
+ hasCircularRefs: false,
90863
+ converged: false,
90864
+ iterations: 0,
90865
+ maxDelta: 0,
90866
+ circularCellCount: 0
90867
+ };
90687
90868
  }
90688
90869
  throw new KernelError("COMPUTE_ERROR", `Full recalculation failed: ${msg}`);
90689
90870
  }
@@ -91145,6 +91326,7 @@ var api_spec_default = {
91145
91326
  viewport: "WorkbookViewport"
91146
91327
  },
91147
91328
  ws: {
91329
+ whatIf: "WorksheetWhatIf",
91148
91330
  smartArt: "WorksheetSmartArt",
91149
91331
  changes: "WorksheetChanges",
91150
91332
  formats: "WorksheetFormats",
@@ -91242,10 +91424,12 @@ var api_spec_default = {
91242
91424
  ]
91243
91425
  },
91244
91426
  calculate: {
91245
- signature: "calculate(calculationType?: CalculationType): Promise<void>;",
91246
- docstring: "Trigger recalculation of formulas.\n@param calculationType - Type of recalculation (default: 'full')\n - 'recalculate' \u2014 recalculate dirty cells only\n - 'full' \u2014 recalculate all cells\n - 'fullRebuild' \u2014 rebuild dependency graph and recalculate all",
91427
+ signature: "calculate(options?: CalculateOptions | CalculationType): Promise<CalculateResult>;",
91428
+ docstring: "Trigger recalculation of formulas.\n@param options - Calculation options, or a CalculationType string for backward compatibility",
91247
91429
  usedTypes: [
91248
- "CalculationType"
91430
+ "CalculateOptions",
91431
+ "CalculationType",
91432
+ "CalculateResult"
91249
91433
  ]
91250
91434
  },
91251
91435
  getCalculationMode: {
@@ -91265,17 +91449,17 @@ var api_spec_default = {
91265
91449
  },
91266
91450
  setIterativeCalculation: {
91267
91451
  signature: "setIterativeCalculation(enabled: boolean): Promise<void>;",
91268
- docstring: "Set whether iterative calculation is enabled for circular references.\nConvenience mutator \u2014 patches `calculationSettings.enableIterativeCalculation`.",
91452
+ docstring: "Set whether iterative calculation is enabled for circular references.\nConvenience mutator \u2014 patches `calculationSettings.enableIterativeCalculation`.\n@deprecated Use calculate({ iterative: ... }) instead.",
91269
91453
  usedTypes: []
91270
91454
  },
91271
91455
  setMaxIterations: {
91272
91456
  signature: "setMaxIterations(n: number): Promise<void>;",
91273
- docstring: "Set the maximum number of iterations for iterative calculation.\nConvenience mutator \u2014 patches `calculationSettings.maxIterations`.",
91457
+ docstring: "Set the maximum number of iterations for iterative calculation.\nConvenience mutator \u2014 patches `calculationSettings.maxIterations`.\n@deprecated Use calculate({ iterative: { maxIterations: n } }) instead.",
91274
91458
  usedTypes: []
91275
91459
  },
91276
91460
  setConvergenceThreshold: {
91277
91461
  signature: "setConvergenceThreshold(threshold: number): Promise<void>;",
91278
- docstring: "Set the convergence threshold (maximum change) for iterative calculation.\nConvenience mutator \u2014 patches `calculationSettings.maxChange`.",
91462
+ docstring: "Set the convergence threshold (maximum change) for iterative calculation.\nConvenience mutator \u2014 patches `calculationSettings.maxChange`.\n@deprecated Use calculate({ iterative: { maxChange: threshold } }) instead.",
91279
91463
  usedTypes: []
91280
91464
  },
91281
91465
  getUsePrecisionAsDisplayed: {
@@ -91733,13 +91917,6 @@ var api_spec_default = {
91733
91917
  "FormatEntry"
91734
91918
  ]
91735
91919
  },
91736
- goalSeek: {
91737
- signature: "goalSeek(targetCell: string, targetValue: number, changingCell: string): Promise<GoalSeekResult>;",
91738
- docstring: "Run a goal seek to find the input value that produces a target result.",
91739
- usedTypes: [
91740
- "GoalSeekResult"
91741
- ]
91742
- },
91743
91920
  isVisible: {
91744
91921
  signature: "isVisible(): boolean;",
91745
91922
  docstring: "Check if the sheet is visible (sync -- local metadata).",
@@ -92261,6 +92438,25 @@ var api_spec_default = {
92261
92438
  }
92262
92439
  }
92263
92440
  },
92441
+ WorksheetWhatIf: {
92442
+ docstring: "Sub-API for What-If analysis operations.",
92443
+ functions: {
92444
+ goalSeek: {
92445
+ signature: "goalSeek(targetCell: string, targetValue: number, changingCell: string): Promise<GoalSeekResult>;",
92446
+ docstring: "Run a goal seek to find the input value that produces a target result.",
92447
+ usedTypes: [
92448
+ "GoalSeekResult"
92449
+ ]
92450
+ },
92451
+ dataTable: {
92452
+ signature: "dataTable(\n formulaCell: string,\n options: {\n rowInputCell?: string | null;\n colInputCell?: string | null;\n rowValues: (string | number | boolean | null)[];\n colValues: (string | number | boolean | null)[];\n },\n ): Promise<DataTableResult>;",
92453
+ docstring: "Evaluate a formula with different input values (What-If Data Table).\n\nOne-variable table: provide either `rowInputCell` or `colInputCell` (not both).\nTwo-variable table: provide both `rowInputCell` and `colInputCell`.\n\nFor one-variable tables, pass an empty array for the unused dimension's values.\n\nInput cells must already contain a value before calling this method.\n\n@param formulaCell - A1 address of the cell containing the formula to evaluate\n@param options - Input cells and substitution values\n@returns 2D grid of computed results",
92454
+ usedTypes: [
92455
+ "DataTableResult"
92456
+ ]
92457
+ }
92458
+ }
92459
+ },
92264
92460
  WorksheetSmartArt: {
92265
92461
  docstring: "",
92266
92462
  functions: {
@@ -92400,7 +92596,18 @@ var api_spec_default = {
92400
92596
  functions: {
92401
92597
  set: {
92402
92598
  signature: "set(address: string, format: CellFormat): Promise<FormatChangeResult>;",
92403
- docstring: 'Set format for a single cell.\n\n@param address - A1-style cell address (e.g. "A1", "B3")\n@param format - Format properties to apply',
92599
+ docstring: `Set format for a single cell.
92600
+
92601
+ @param address - A1-style cell address (e.g. "A1", "B3")
92602
+ @param format - Format properties to apply
92603
+
92604
+ @example
92605
+ // Bold red currency
92606
+ await ws.formats.set('A1', { bold: true, fontColor: '#ff0000', numberFormat: '$#,##0.00' });
92607
+ // Date format
92608
+ await ws.formats.set('B1', { numberFormat: 'YYYY-MM-DD' });
92609
+ // Header style
92610
+ await ws.formats.set('A1', { bold: true, fontSize: 14, backgroundColor: '#4472c4', fontColor: '#ffffff' });`,
92404
92611
  usedTypes: [
92405
92612
  "CellFormat",
92406
92613
  "FormatChangeResult"
@@ -92408,7 +92615,21 @@ var api_spec_default = {
92408
92615
  },
92409
92616
  setRange: {
92410
92617
  signature: "setRange(range: string, format: CellFormat): Promise<FormatChangeResult>;",
92411
- docstring: 'Set format for a contiguous range.\n\n@param range - A1-style range string (e.g. "A1:B2")\n@param format - Format properties to apply',
92618
+ docstring: `Set format for a contiguous range.
92619
+
92620
+ @param range - A1-style range string (e.g. "A1:B2")
92621
+ @param format - Format properties to apply
92622
+
92623
+ @example
92624
+ // Currency column
92625
+ await ws.formats.setRange('B2:B100', { numberFormat: '$#,##0.00' });
92626
+ // Header row with borders
92627
+ await ws.formats.setRange('A1:F1', {
92628
+ bold: true,
92629
+ backgroundColor: '#4472c4',
92630
+ fontColor: '#ffffff',
92631
+ borders: { bottom: { style: 'medium', color: '#2f5496' } }
92632
+ });`,
92412
92633
  usedTypes: [
92413
92634
  "CellFormat",
92414
92635
  "FormatChangeResult"
@@ -94585,8 +94806,8 @@ var api_spec_default = {
94585
94806
  },
94586
94807
  AxisConfig: {
94587
94808
  name: "AxisConfig",
94588
- definition: "{\n xAxis?: {\n type: AxisType;\n title?: string;\n min?: number;\n max?: number;\n gridLines?: boolean;\n /** Show minor gridlines between major gridlines */\n minorGridLines?: boolean;\n majorUnit?: number;\n minorUnit?: number;\n tickMarks?: 'inside' | 'outside' | 'cross' | 'none';\n /** Minor tick mark style (separate from major tickMarks) */\n minorTickMarks?: 'inside' | 'outside' | 'cross' | 'none';\n numberFormat?: string;\n reverse?: boolean;\n visible?: boolean;\n position?: 'bottom' | 'top' | 'left' | 'right';\n logBase?: number;\n displayUnit?: string;\n };\n yAxis?: {\n type: AxisType;\n title?: string;\n min?: number;\n max?: number;\n gridLines?: boolean;\n /** Show minor gridlines between major gridlines */\n minorGridLines?: boolean;\n majorUnit?: number;\n minorUnit?: number;\n tickMarks?: 'inside' | 'outside' | 'cross' | 'none';\n /** Minor tick mark style (separate from major tickMarks) */\n minorTickMarks?: 'inside' | 'outside' | 'cross' | 'none';\n numberFormat?: string;\n reverse?: boolean;\n visible?: boolean;\n position?: 'bottom' | 'top' | 'left' | 'right';\n logBase?: number;\n displayUnit?: string;\n };\n secondaryYAxis?: {\n type: AxisType;\n title?: string;\n min?: number;\n max?: number;\n show: boolean;\n majorUnit?: number;\n minorUnit?: number;\n tickMarks?: 'inside' | 'outside' | 'cross' | 'none';\n /** Minor tick mark style (separate from major tickMarks) */\n minorTickMarks?: 'inside' | 'outside' | 'cross' | 'none';\n numberFormat?: string;\n reverse?: boolean;\n visible?: boolean;\n position?: 'bottom' | 'top' | 'left' | 'right';\n logBase?: number;\n displayUnit?: string;\n };\n}",
94589
- docstring: "Axis configuration"
94809
+ definition: "{\n categoryAxis?: SingleAxisConfig;\n valueAxis?: SingleAxisConfig;\n secondaryCategoryAxis?: SingleAxisConfig;\n secondaryValueAxis?: SingleAxisConfig;\n /** @deprecated Use categoryAxis instead */\n xAxis?: SingleAxisConfig;\n /** @deprecated Use valueAxis instead */\n yAxis?: SingleAxisConfig;\n /** @deprecated Use secondaryValueAxis instead */\n secondaryYAxis?: SingleAxisConfig;\n}",
94810
+ docstring: "Axis configuration (matches AxisData wire type).\n\nWire field names: categoryAxis, valueAxis, secondaryCategoryAxis, secondaryValueAxis.\nLegacy aliases: xAxis, yAxis, secondaryYAxis (mapped in chart-bridge)."
94590
94811
  },
94591
94812
  AxisType: {
94592
94813
  name: "AxisType",
@@ -94741,7 +94962,34 @@ var api_spec_default = {
94741
94962
  CellFormat: {
94742
94963
  name: "CellFormat",
94743
94964
  definition: `{
94965
+ /** Excel-compatible number format code string.
94966
+
94967
+ Common format codes:
94968
+ - Currency: '$#,##0.00'
94969
+ - Accounting: '_($* #,##0.00_);_($* (#,##0.00);_($* "-"??_);_(@_)'
94970
+ - Percentage: '0.00%'
94971
+ - Date: 'M/D/YYYY', 'YYYY-MM-DD', 'MMM D, YYYY'
94972
+ - Time: 'h:mm AM/PM', 'HH:mm:ss'
94973
+ - Number: '#,##0.00', '0.00'
94974
+ - Scientific: '0.00E+00'
94975
+ - Text: '@'
94976
+ - Fraction: '# ?/?'
94977
+
94978
+ See the \`formatPresets\` section in api-spec.json for the full catalog
94979
+ of 85+ pre-defined format codes with examples.
94980
+
94981
+ @example
94982
+ // Currency
94983
+ { numberFormat: '$#,##0.00' }
94984
+ // Percentage with 1 decimal
94985
+ { numberFormat: '0.0%' }
94986
+ // ISO date
94987
+ { numberFormat: 'YYYY-MM-DD' } */
94744
94988
  numberFormat?: string;
94989
+ /** Number format category hint. Auto-detected from numberFormat when not set.
94990
+ Valid values: 'general' | 'number' | 'currency' | 'accounting' | 'date' |
94991
+ 'time' | 'percentage' | 'fraction' | 'scientific' | 'text' |
94992
+ 'special' | 'custom' */
94745
94993
  numberFormatType?: NumberFormatType;
94746
94994
  fontFamily?: string;
94747
94995
  fontSize?: number;
@@ -94960,8 +95208,8 @@ Example: { ignoreError: true } to suppress error indicators. */
94960
95208
  },
94961
95209
  ChartBorder: {
94962
95210
  name: "ChartBorder",
94963
- definition: "{\n color?: string;\n width?: number;\n style?: 'solid' | 'dashed' | 'dotted' | 'none';\n}",
94964
- docstring: "Shared chart border configuration"
95211
+ definition: "{\n color?: string;\n width?: number;\n style?: string;\n}",
95212
+ docstring: "Shared chart border configuration (matches ChartBorderData wire type)"
94965
95213
  },
94966
95214
  ChartConfig: {
94967
95215
  name: "ChartConfig",
@@ -94992,7 +95240,10 @@ Example: { ignoreError: true } to suppress error indicators. */
94992
95240
  series?: SeriesConfig[];
94993
95241
  dataLabels?: DataLabelConfig;
94994
95242
  pieSlice?: PieSliceConfig;
95243
+ /** @deprecated Use trendlines[] instead \u2014 kept for backward compat */
94995
95244
  trendline?: TrendlineConfig;
95245
+ /** Wire-compatible trendline array */
95246
+ trendlines?: TrendlineConfig[];
94996
95247
  /** Connect scatter points with lines (scatter-lines variant) */
94997
95248
  showLines?: boolean;
94998
95249
  /** Use smooth curves for scatter lines (scatter-smooth-lines variant) */
@@ -95102,11 +95353,6 @@ that are stored on the chart but not part of the core config schema. */
95102
95353
  definition: "{\n /** Column index to write to (0-indexed) */\n columnIndex: number;\n /** JSONPath or field name to extract from data */\n dataPath: string;\n /** Optional transform formula (receives value as input) */\n transform?: string;\n /** Header text (if headerRow >= 0) */\n headerText?: string;\n}",
95103
95354
  docstring: "Column mapping for a sheet data binding."
95104
95355
  },
95105
- Comment: {
95106
- name: "Comment",
95107
- definition: "{\n id: string;\n cellId: string;\n cellAddress: string;\n text: string;\n author: string;\n threadId?: string;\n resolved?: boolean;\n createdAt?: number;\n parentId?: string;\n authorId?: string;\n modifiedAt?: number;\n content?: RichTextSegment[];\n}",
95108
- docstring: "A cell comment (thread-aware)."
95109
- },
95110
95356
  ConditionalFormat: {
95111
95357
  name: "ConditionalFormat",
95112
95358
  definition: "{\n /** Unique format identifier. */\n id: string;\n /** Cell ranges this format applies to. */\n ranges: CellRange[];\n /** Rules to evaluate (sorted by priority). */\n rules: CFRule[];\n}",
@@ -95164,8 +95410,8 @@ that are stored on the chart but not part of the core config schema. */
95164
95410
  },
95165
95411
  DataLabelConfig: {
95166
95412
  name: "DataLabelConfig",
95167
- definition: "{\n show: boolean;\n position?: 'inside' | 'outside' | 'top' | 'bottom' | 'left' | 'right';\n format?: string;\n showCategoryName?: boolean;\n showSeriesName?: boolean;\n showPercentage?: boolean;\n showBubbleSize?: boolean;\n showLegendKey?: boolean;\n separator?: string;\n /** Show leader lines connecting data labels to their data points (pie/doughnut charts) */\n showLeaderLines?: boolean;\n}",
95168
- docstring: "Data label configuration"
95413
+ definition: "{\n show: boolean;\n position?: string;\n format?: string;\n showValue?: boolean;\n showCategoryName?: boolean;\n showSeriesName?: boolean;\n showPercentage?: boolean;\n showBubbleSize?: boolean;\n showLegendKey?: boolean;\n separator?: string;\n showLeaderLines?: boolean;\n text?: string;\n}",
95414
+ docstring: "Data label configuration (matches DataLabelData wire type)"
95169
95415
  },
95170
95416
  DatePeriod: {
95171
95417
  name: "DatePeriod",
@@ -95219,8 +95465,8 @@ that are stored on the chart but not part of the core config schema. */
95219
95465
  },
95220
95466
  ErrorBarConfig: {
95221
95467
  name: "ErrorBarConfig",
95222
- definition: "{\n visible?: boolean;\n type?: 'fixedValue' | 'percentage' | 'standardDeviation' | 'standardError' | 'custom';\n include?: 'both' | 'plus' | 'minus';\n value?: number;\n}",
95223
- docstring: "Error bar configuration for series"
95468
+ definition: "{\n visible?: boolean;\n direction?: string;\n barType?: string;\n valueType?: string;\n value?: number;\n noEndCap?: boolean;\n}",
95469
+ docstring: "Error bar configuration for series (matches ErrorBarData wire type)"
95224
95470
  },
95225
95471
  ErrorVariant: {
95226
95472
  name: "ErrorVariant",
@@ -95262,7 +95508,7 @@ Used in condition filters where users specify rules like
95262
95508
  },
95263
95509
  FilterDetailInfo: {
95264
95510
  name: "FilterDetailInfo",
95265
- definition: "{\n /** Filter ID */\n id: string;\n /** Resolved numeric range of the filter */\n range: { startRow: number; startCol: number; endRow: number; endCol: number };\n /** Per-column filter criteria, keyed by header cell ID */\n columnFilters: Record<string, ColumnFilterCriteria>;\n}",
95511
+ definition: "{\n /** Filter ID */\n id: string;\n /** Resolved numeric range of the filter */\n range: { startRow: number; startCol: number; endRow: number; endCol: number };\n /** Per-column filter criteria, keyed by header cell ID */\n columnFilters: Record<string, ColumnFilter>;\n}",
95266
95512
  docstring: "Detailed filter information including resolved numeric range and column filters."
95267
95513
  },
95268
95514
  FilterInfo: {
@@ -95277,8 +95523,8 @@ Used in condition filters where users specify rules like
95277
95523
  },
95278
95524
  FilterState: {
95279
95525
  name: "FilterState",
95280
- definition: "{\n /** The range the auto-filter is applied to (A1 notation) */\n range: string;\n /** Per-column filter criteria, keyed by column index */\n columns: Map<number, ColumnFilterCriteria>;\n}",
95281
- docstring: "Current auto-filter state for a sheet."
95526
+ definition: "{\n /** The range the auto-filter is applied to (A1 notation) */\n range: string;\n /** Per-column filter criteria, keyed by column identifier (string) */\n columnFilters: Record<string, ColumnFilter>;\n}",
95527
+ docstring: "API filter state \u2014 derived from Rust FilterState with A1-notation range."
95282
95528
  },
95283
95529
  FloatingObject: {
95284
95530
  name: "FloatingObject",
@@ -95380,13 +95626,8 @@ Used in condition filters where users specify rules like
95380
95626
  },
95381
95627
  LegendConfig: {
95382
95628
  name: "LegendConfig",
95383
- definition: "{\n show: boolean;\n position: LegendPosition;\n visible?: boolean;\n overlay?: boolean;\n font?: ChartFont;\n}",
95384
- docstring: "Legend configuration"
95385
- },
95386
- LegendPosition: {
95387
- name: "LegendPosition",
95388
- definition: "'top' | 'bottom' | 'left' | 'right' | 'none'",
95389
- docstring: "Legend position options"
95629
+ definition: "{\n show: boolean;\n position: string;\n visible: boolean;\n overlay?: boolean;\n font?: ChartFont;\n}",
95630
+ docstring: "Legend configuration (matches LegendData wire type)"
95390
95631
  },
95391
95632
  LineDash: {
95392
95633
  name: "LineDash",
@@ -95451,7 +95692,7 @@ Used in condition filters where users specify rules like
95451
95692
  Note: {
95452
95693
  name: "Note",
95453
95694
  definition: "{\n content: string;\n author: string;\n cellAddress: string;\n}",
95454
- docstring: "A cell note (simple, single string per cell)."
95695
+ docstring: "A cell note (simple, single string per cell). API-only type (no Rust equivalent)."
95455
95696
  },
95456
95697
  NumberFormatCategory: {
95457
95698
  name: "NumberFormatCategory",
@@ -95472,11 +95713,6 @@ Used in condition filters where users specify rules like
95472
95713
  },
95473
95714
  docstring: "Number format category classification.\nMatches the FormatType enum from Rust compute-formats."
95474
95715
  },
95475
- NumberFormatType: {
95476
- name: "NumberFormatType",
95477
- definition: "| 'general'\n | 'number'\n | 'currency'\n | 'accounting'\n | 'date'\n | 'time'\n | 'percentage'\n | 'fraction'\n | 'scientific'\n | 'text'\n | 'special'\n | 'custom'",
95478
- docstring: "Number format types"
95479
- },
95480
95716
  ObjectAnchorType: {
95481
95717
  name: "ObjectAnchorType",
95482
95718
  definition: "| 'twoCell' // Anchored to two cells (moves and resizes with cells)\n | 'oneCell' // Anchored to one cell (moves but doesn't resize)\n | 'absolute'",
@@ -95588,8 +95824,8 @@ Used in condition filters where users specify rules like
95588
95824
  },
95589
95825
  PieSliceConfig: {
95590
95826
  name: "PieSliceConfig",
95591
- definition: "{\n /** Index of slice to explode (pull out from center) */\n explodedIndex?: number;\n /** Array of indices to explode */\n explodedIndices?: number[];\n /** Distance to explode (0-1, default 0.1) */\n explodeOffset?: number;\n /** Allow clicking to select/explode slices */\n selectable?: boolean;\n}",
95592
- docstring: "Pie/doughnut slice configuration for exploded slices"
95827
+ definition: "{\n explosion?: number;\n explodedIndices?: number[];\n explodeOffset?: number;\n}",
95828
+ docstring: "Pie/doughnut slice configuration (matches PieSliceData wire type)"
95593
95829
  },
95594
95830
  PivotQueryRecord: {
95595
95831
  name: "PivotQueryRecord",
@@ -95628,8 +95864,8 @@ Used in condition filters where users specify rules like
95628
95864
  },
95629
95865
  PointFormat: {
95630
95866
  name: "PointFormat",
95631
- definition: "{\n fill?: string;\n border?: ChartBorder;\n dataLabel?: DataLabelConfig;\n}",
95632
- docstring: "Per-point formatting for individual data points in a series"
95867
+ definition: "{\n idx: number;\n fill?: string;\n border?: ChartBorder;\n dataLabel?: DataLabelConfig;\n}",
95868
+ docstring: "Per-point formatting for individual data points (matches PointFormatData wire type)"
95633
95869
  },
95634
95870
  PrintSettings: {
95635
95871
  name: "PrintSettings",
@@ -95678,11 +95914,6 @@ Used in condition filters where users specify rules like
95678
95914
  definition: "{\n [K in keyof CellFormat]-?: CellFormat[K] | null;\n}",
95679
95915
  docstring: "Dense cell format where every property is explicitly present (null when unset). Returned by formats.get()."
95680
95916
  },
95681
- RichTextSegment: {
95682
- name: "RichTextSegment",
95683
- definition: "{\n text: string;\n bold?: boolean;\n italic?: boolean;\n underline?: boolean;\n strikethrough?: boolean;\n color?: string;\n fontName?: string;\n fontSize?: number;\n}",
95684
- docstring: "A single segment of rich text content."
95685
- },
95686
95917
  Scenario: {
95687
95918
  name: "Scenario",
95688
95919
  definition: "{\n /** Unique scenario ID */\n id: string;\n /** Creation timestamp (Unix ms) */\n createdAt: number;\n}",
@@ -95710,46 +95941,8 @@ Used in condition filters where users specify rules like
95710
95941
  },
95711
95942
  SeriesConfig: {
95712
95943
  name: "SeriesConfig",
95713
- definition: `{
95714
- name?: string;
95715
- type?: ChartType;
95716
- color?: string;
95717
- yAxisIndex?: 0 | 1;
95718
- showMarkers?: boolean;
95719
- markerSize?: number;
95720
- markerStyle?: | 'circle'
95721
- | 'dash'
95722
- | 'diamond'
95723
- | 'dot'
95724
- | 'picture'
95725
- | 'plus'
95726
- | 'square'
95727
- | 'star'
95728
- | 'triangle'
95729
- | 'x'
95730
- | 'auto'
95731
- | 'none';
95732
- lineWidth?: number;
95733
- smooth?: boolean;
95734
- dataLabels?: DataLabelConfig;
95735
- trendline?: TrendlineConfig;
95736
- errorBars?: ErrorBarConfig;
95737
- /** Separate X-axis error bars (for scatter/bubble charts) */
95738
- xErrorBars?: ErrorBarConfig;
95739
- /** Separate Y-axis error bars (for scatter/bubble charts) */
95740
- yErrorBars?: ErrorBarConfig;
95741
- /** Whether to invert the fill color for negative values */
95742
- invertIfNegative?: boolean;
95743
- /** Explosion distance for pie/doughnut per-series (0-400%) */
95744
- explosion?: number;
95745
- /** Data values range in A1 notation (e.g., "B2:B10") */
95746
- values?: string;
95747
- /** Category labels range in A1 notation (e.g., "A2:A10") */
95748
- categories?: string;
95749
- /** Per-point formatting overrides */
95750
- points?: PointFormat[];
95751
- }`,
95752
- docstring: "Individual series configuration"
95944
+ definition: "{\n name?: string;\n type?: string;\n color?: string;\n values?: string;\n categories?: string;\n bubbleSize?: string;\n smooth?: boolean;\n explosion?: number;\n invertIfNegative?: boolean;\n yAxisIndex?: number;\n showMarkers?: boolean;\n markerSize?: number;\n markerStyle?: string;\n lineWidth?: number;\n points?: PointFormat[];\n dataLabels?: DataLabelConfig;\n trendlines?: TrendlineConfig[];\n errorBars?: ErrorBarConfig;\n xErrorBars?: ErrorBarConfig;\n yErrorBars?: ErrorBarConfig;\n idx?: number;\n order?: number;\n /** @deprecated Use trendlines[] instead */\n trendline?: TrendlineConfig;\n}",
95945
+ docstring: "Individual series configuration (matches ChartSeriesData wire type)"
95753
95946
  },
95754
95947
  SeriesOrientation: {
95755
95948
  name: "SeriesOrientation",
@@ -95826,6 +96019,11 @@ Used in condition filters where users specify rules like
95826
96019
  definition: "{\n /** Sheet ID */\n id: string;\n /** Sheet name */\n name: string;\n /** Sheet index (0-based) */\n index: number;\n /** Range containing all non-empty cells (A1 notation), or null if empty */\n usedRange: string | null;\n /** Number of cells with data */\n cellCount: number;\n /** Number of cells with formulas */\n formulaCount: number;\n /** Number of charts in this sheet */\n chartCount: number;\n /** Sheet dimensions */\n dimensions: { rows: number; cols: number };\n}",
95827
96020
  docstring: "A summary snapshot of a single sheet."
95828
96021
  },
96022
+ SingleAxisConfig: {
96023
+ name: "SingleAxisConfig",
96024
+ definition: "{\n title?: string;\n visible: boolean;\n min?: number;\n max?: number;\n axisType?: string;\n gridLines?: boolean;\n minorGridLines?: boolean;\n majorUnit?: number;\n minorUnit?: number;\n tickMarks?: string;\n minorTickMarks?: string;\n numberFormat?: string;\n reverse?: boolean;\n position?: string;\n logBase?: number;\n displayUnit?: string;\n /** @deprecated Alias for axisType \u2014 kept for backward compat with charts package */\n type?: AxisType;\n /** @deprecated Alias for visible \u2014 kept for backward compat with charts package */\n show?: boolean;\n}",
96025
+ docstring: "Single axis configuration (matches SingleAxisData wire type)."
96026
+ },
95829
96027
  Slicer: {
95830
96028
  name: "Slicer",
95831
96029
  definition: "{\n /** Currently selected filter items */\n selectedItems: CellValue[];\n /** Position and dimensions in pixels */\n position: { x: number; y: number; width: number; height: number };\n}",
@@ -95833,7 +96031,7 @@ Used in condition filters where users specify rules like
95833
96031
  },
95834
96032
  SlicerConfig: {
95835
96033
  name: "SlicerConfig",
95836
- definition: "{\n /** Name of the table to connect the slicer to */\n tableName?: string;\n /** Column name within the table to filter on */\n columnName?: string;\n /** Display name for the slicer (auto-generated if omitted) */\n name?: string;\n /** Position and dimensions in pixels */\n position?: { x: number; y: number; width: number; height: number };\n /** Data source connection (rich alternative to tableName/columnName) */\n source?: SlicerSource;\n /** Slicer caption (header text) */\n caption?: string;\n /** Style configuration (partial for incremental updates) */\n style?: Partial<SlicerStyle>;\n /** Show slicer header */\n showHeader?: boolean;\n /** Currently selected date range start (timeline slicers) */\n selectedStartDate?: number;\n /** Currently selected date range end (timeline slicers) */\n selectedEndDate?: number;\n /** Current aggregation level (timeline slicers) */\n timelineLevel?: TimelineLevel;\n}",
96034
+ definition: "{\n /** Slicer ID (generated if omitted) */\n id?: string;\n /** Sheet ID the slicer belongs to */\n sheetId?: string;\n /** Name of the table to connect the slicer to */\n tableName?: string;\n /** Column name within the table to filter on */\n columnName?: string;\n /** Display name for the slicer (auto-generated if omitted) */\n name?: string;\n /** Position and dimensions in pixels */\n position?: { x: number; y: number; width: number; height: number };\n /** Data source connection (rich alternative to tableName/columnName) */\n source?: SlicerSource;\n /** Slicer caption (header text) */\n caption?: string;\n /** Style configuration */\n style?: SlicerStyle;\n /** Show slicer header */\n showHeader?: boolean;\n /** Z-order within the sheet */\n zIndex?: number;\n /** Whether slicer position is locked */\n locked?: boolean;\n /** Whether multi-select is enabled */\n multiSelect?: boolean;\n /** Initial selected values */\n selectedValues?: CellValue[];\n /** Currently selected date range start (timeline slicers) */\n selectedStartDate?: number;\n /** Currently selected date range end (timeline slicers) */\n selectedEndDate?: number;\n /** Current aggregation level (timeline slicers) */\n timelineLevel?: TimelineLevel;\n}",
95837
96035
  docstring: "Configuration for creating a new slicer."
95838
96036
  },
95839
96037
  SlicerCustomStyle: {
@@ -95943,13 +96141,13 @@ Used in condition filters where users specify rules like
95943
96141
  },
95944
96142
  TableColumn: {
95945
96143
  name: "TableColumn",
95946
- definition: "{\n /** Column header name */\n name: string;\n /** Column index within the table (0-based) */\n index: number;\n /** Total row function type */\n totalFunction?: TotalFunction;\n /** Calculated column formula */\n calculatedFormula?: string;\n}",
95947
- docstring: "A single column in a table."
96144
+ definition: "{\n /** Unique column ID */\n id: string;\n /** Column header name */\n name: string;\n /** Column index within the table (0-based) */\n index: number;\n /** Total row function type */\n totalsFunction: TotalsFunction | null;\n /** Total row label */\n totalsLabel: string | null;\n /** Calculated column formula */\n calculatedFormula?: string;\n}",
96145
+ docstring: "A single column in a table.\n\nField names match the Rust-generated `TableColumn` type (compute-types.gen.ts)."
95948
96146
  },
95949
96147
  TableInfo: {
95950
96148
  name: "TableInfo",
95951
- definition: "{\n /** Internal table identifier (opaque string) */\n id?: string;\n /** Table name */\n name: string;\n /** Table range in A1 notation */\n range: string;\n /** Whether the table has a header row */\n hasHeaders: boolean;\n /** Table style preset name */\n style?: TableStylePreset;\n /** Column definitions */\n columns: TableColumn[];\n /** Whether the total row is visible */\n showTotals?: boolean;\n /** Whether first column is highlighted */\n highlightFirstColumn?: boolean;\n /** Whether last column is highlighted */\n highlightLastColumn?: boolean;\n /** Whether banded columns are shown */\n showBandedColumns?: boolean;\n /** Whether banded rows are shown */\n showBandedRows?: boolean;\n /** Whether filter buttons are shown */\n showFilterButton?: boolean;\n /** Whether the header row is shown (mirrors hasHeaders) */\n showHeaders?: boolean;\n}",
95952
- docstring: "Information about an existing table."
96149
+ definition: "{\n /** Internal table identifier */\n id: string;\n /** Table name */\n name: string;\n /** Display name */\n displayName: string;\n /** Sheet the table belongs to */\n sheetId: string;\n /** Table range in A1 notation (converted from Rust SheetRange) */\n range: string;\n /** Column definitions */\n columns: TableColumn[];\n /** Whether the table has a header row */\n hasHeaderRow: boolean;\n /** Whether the totals row is visible */\n hasTotalsRow: boolean;\n /** Table style name */\n style: string;\n /** Whether banded rows are shown */\n bandedRows: boolean;\n /** Whether banded columns are shown */\n bandedColumns: boolean;\n /** Whether first column is emphasized */\n emphasizeFirstColumn: boolean;\n /** Whether last column is emphasized */\n emphasizeLastColumn: boolean;\n /** Whether filter buttons are shown */\n showFilterButtons: boolean;\n}",
96150
+ docstring: "Information about an existing table.\n\nField names match the Rust-generated `Table` type (compute-types.gen.ts)\nexcept `range` which is converted from `SheetRange` to A1 notation string."
95953
96151
  },
95954
96152
  TableOptions: {
95955
96153
  name: "TableOptions",
@@ -95961,16 +96159,6 @@ Used in condition filters where users specify rules like
95961
96159
  definition: "{\n /** Style name */\n name: string;\n}",
95962
96160
  docstring: "Configuration for creating/updating a custom table style."
95963
96161
  },
95964
- TableStyleInfo: {
95965
- name: "TableStyleInfo",
95966
- definition: "{\n /** Style name/ID */\n name: string;\n /** Display name */\n displayName?: string;\n /** Whether this is a built-in style */\n isBuiltIn?: boolean;\n}",
95967
- docstring: "Information about a custom table style."
95968
- },
95969
- TableStylePreset: {
95970
- name: "TableStylePreset",
95971
- definition: "| 'none'\n // Light styles\n | 'light1'\n | 'light2'\n | 'light3'\n | 'light4'\n | 'light5'\n | 'light6'\n | 'light7'\n | 'light8'\n | 'light9'\n | 'light10'\n | 'light11'\n | 'light12'\n | 'light13'\n | 'light14'\n | 'light15'\n | 'light16'\n | 'light17'\n | 'light18'\n | 'light19'\n | 'light20'\n | 'light21'\n // Medium styles\n | 'medium1'\n | 'medium2'\n | 'medium3'\n | 'medium4'\n | 'medium5'\n | 'medium6'\n | 'medium7'\n | 'medium8'\n | 'medium9'\n | 'medium10'\n | 'medium11'\n | 'medium12'\n | 'medium13'\n | 'medium14'\n | 'medium15'\n | 'medium16'\n | 'medium17'\n | 'medium18'\n | 'medium19'\n | 'medium20'\n | 'medium21'\n | 'medium22'\n | 'medium23'\n | 'medium24'\n | 'medium25'\n | 'medium26'\n | 'medium27'\n | 'medium28'\n // Dark styles\n | 'dark1'\n | 'dark2'\n | 'dark3'\n | 'dark4'\n | 'dark5'\n | 'dark6'\n | 'dark7'\n | 'dark8'\n | 'dark9'\n | 'dark10'\n | 'dark11'",
95972
- docstring: "Table style presets matching Excel's table style gallery.\nLight styles (1-21), Medium styles (1-28), Dark styles (1-11)."
95973
- },
95974
96162
  TextBoxBorder: {
95975
96163
  name: "TextBoxBorder",
95976
96164
  definition: "{\n /** Corner radius in pixels (for rounded corners) */\n radius?: number;\n}",
@@ -96030,20 +96218,15 @@ Used in condition filters where users specify rules like
96030
96218
  definition: "{\n text?: string;\n visible?: boolean;\n position?: 'top' | 'bottom' | 'left' | 'right' | 'overlay';\n font?: ChartFont;\n}",
96031
96219
  docstring: "Rich title configuration"
96032
96220
  },
96033
- TotalFunction: {
96034
- name: "TotalFunction",
96035
- definition: "| 'none'\n | 'sum'\n | 'count'\n | 'average'\n | 'min'\n | 'max'\n | 'stdDev'\n | 'var'\n | 'countNums'\n | 'custom'",
96036
- docstring: "Total row function types.\nMaps to Excel's total row dropdown options."
96221
+ TotalsFunction: {
96222
+ name: "TotalsFunction",
96223
+ definition: "| 'average'\n | 'count'\n | 'countNums'\n | 'max'\n | 'min'\n | 'stdDev'\n | 'sum'\n | 'var'\n | 'custom'\n | 'none'",
96224
+ docstring: "Totals function type (matches Rust TotalsFunction)."
96037
96225
  },
96038
96226
  TrendlineConfig: {
96039
96227
  name: "TrendlineConfig",
96040
- definition: "{\n show: boolean;\n type: TrendlineType;\n color?: string;\n lineWidth?: number;\n showEquation?: boolean;\n showR2?: boolean;\n order?: number;\n period?: number;\n intercept?: number;\n forwardPeriod?: number;\n backwardPeriod?: number;\n name?: string;\n}",
96041
- docstring: "Trendline configuration"
96042
- },
96043
- TrendlineType: {
96044
- name: "TrendlineType",
96045
- definition: "| 'linear'\n | 'exponential'\n | 'logarithmic'\n | 'polynomial'\n | 'power'\n | 'moving-average'",
96046
- docstring: "Trendline types for scatter charts"
96228
+ definition: "{\n show?: boolean;\n type?: string;\n color?: string;\n lineWidth?: number;\n order?: number;\n period?: number;\n forward?: number;\n backward?: number;\n intercept?: number;\n displayEquation?: boolean;\n displayRSquared?: boolean;\n name?: string;\n /** @deprecated Use displayEquation instead */\n showEquation?: boolean;\n /** @deprecated Use displayRSquared instead */\n showR2?: boolean;\n /** @deprecated Use forward instead */\n forwardPeriod?: number;\n /** @deprecated Use backward instead */\n backwardPeriod?: number;\n}",
96229
+ docstring: "Trendline configuration (matches TrendlineData wire type)"
96047
96230
  },
96048
96231
  UndoHistoryEntry: {
96049
96232
  name: "UndoHistoryEntry",
@@ -96162,6 +96345,415 @@ Used in condition filters where users specify rules like
96162
96345
  definition: "{\n /** All sheets in the workbook */\n sheets: SheetSnapshot[];\n /** ID of the currently active sheet */\n activeSheetId: string;\n /** Total number of sheets */\n sheetCount: number;\n}",
96163
96346
  docstring: "A summary snapshot of the entire workbook state."
96164
96347
  }
96348
+ },
96349
+ formatPresets: {
96350
+ general: {
96351
+ default: {
96352
+ code: "General",
96353
+ description: "",
96354
+ example: "1234.5"
96355
+ }
96356
+ },
96357
+ number: {
96358
+ integer: {
96359
+ code: "0",
96360
+ description: "No decimal places",
96361
+ example: "1235"
96362
+ },
96363
+ decimal1: {
96364
+ code: "0.0",
96365
+ description: "1 decimal place",
96366
+ example: "1234.5"
96367
+ },
96368
+ decimal2: {
96369
+ code: "0.00",
96370
+ description: "2 decimal places",
96371
+ example: "1234.50"
96372
+ },
96373
+ decimal3: {
96374
+ code: "0.000",
96375
+ description: "3 decimal places",
96376
+ example: "1234.500"
96377
+ },
96378
+ thousands: {
96379
+ code: "#,##0",
96380
+ description: "Thousands separator, no decimals",
96381
+ example: "1,235"
96382
+ },
96383
+ thousandsDecimal1: {
96384
+ code: "#,##0.0",
96385
+ description: "Thousands separator, 1 decimal",
96386
+ example: "1,234.5"
96387
+ },
96388
+ thousandsDecimal2: {
96389
+ code: "#,##0.00",
96390
+ description: "Thousands separator, 2 decimals",
96391
+ example: "1,234.50"
96392
+ },
96393
+ negativeRed: {
96394
+ code: "#,##0.00;[Red]-#,##0.00",
96395
+ description: "Red negative numbers",
96396
+ example: "-1,234.50"
96397
+ },
96398
+ negativeParens: {
96399
+ code: "#,##0.00;(#,##0.00)",
96400
+ description: "Parentheses for negatives",
96401
+ example: "(1,234.50)"
96402
+ },
96403
+ negativeParensRed: {
96404
+ code: "#,##0.00;[Red](#,##0.00)",
96405
+ description: "Red parentheses for negatives",
96406
+ example: "(1,234.50)"
96407
+ }
96408
+ },
96409
+ currency: {
96410
+ usd: {
96411
+ code: "$#,##0.00",
96412
+ description: "US Dollar",
96413
+ example: "$1,234.50"
96414
+ },
96415
+ usdNegMinus: {
96416
+ code: "$#,##0.00;-$#,##0.00",
96417
+ description: "USD minus",
96418
+ example: "-$1,234.50"
96419
+ },
96420
+ usdNegParens: {
96421
+ code: "$#,##0.00;($#,##0.00)",
96422
+ description: "USD parentheses",
96423
+ example: "($1,234.50)"
96424
+ },
96425
+ usdNegRed: {
96426
+ code: "$#,##0.00;[Red]-$#,##0.00",
96427
+ description: "USD red minus",
96428
+ example: "-$1,234.50"
96429
+ },
96430
+ usdNegParensRed: {
96431
+ code: "$#,##0.00;[Red]($#,##0.00)",
96432
+ description: "USD red parentheses",
96433
+ example: "($1,234.50)"
96434
+ },
96435
+ eur: {
96436
+ code: "\u20AC#,##0.00",
96437
+ description: "Euro",
96438
+ example: "\u20AC1,234.50"
96439
+ },
96440
+ gbp: {
96441
+ code: "\xA3#,##0.00",
96442
+ description: "British Pound",
96443
+ example: "\xA31,234.50"
96444
+ },
96445
+ jpy: {
96446
+ code: "\xA5#,##0",
96447
+ description: "Japanese Yen (no decimals)",
96448
+ example: "\xA51,235"
96449
+ },
96450
+ cny: {
96451
+ code: "\xA5#,##0.00",
96452
+ description: "Chinese Yuan",
96453
+ example: "\xA51,234.50"
96454
+ },
96455
+ inr: {
96456
+ code: "\u20B9#,##0.00",
96457
+ description: "Indian Rupee",
96458
+ example: "\u20B91,234.50"
96459
+ },
96460
+ krw: {
96461
+ code: "\u20A9#,##0",
96462
+ description: "Korean Won (no decimals)",
96463
+ example: "\u20A91,235"
96464
+ },
96465
+ chf: {
96466
+ code: "CHF #,##0.00",
96467
+ description: "Swiss Franc",
96468
+ example: "CHF 1,234.50"
96469
+ },
96470
+ cad: {
96471
+ code: "CA$#,##0.00",
96472
+ description: "Canadian Dollar",
96473
+ example: "CA$1,234.50"
96474
+ },
96475
+ aud: {
96476
+ code: "A$#,##0.00",
96477
+ description: "Australian Dollar",
96478
+ example: "A$1,234.50"
96479
+ }
96480
+ },
96481
+ accounting: {
96482
+ usd: {
96483
+ code: '_($* #,##0.00_);_($* (#,##0.00);_($* "-"??_);_(@_)',
96484
+ description: "USD Accounting",
96485
+ example: "$ 1,234.50"
96486
+ },
96487
+ eur: {
96488
+ code: '_(\u20AC* #,##0.00_);_(\u20AC* (#,##0.00);_(\u20AC* "-"??_);_(@_)',
96489
+ description: "EUR Accounting",
96490
+ example: "\u20AC 1,234.50"
96491
+ },
96492
+ gbp: {
96493
+ code: '_(\xA3* #,##0.00_);_(\xA3* (#,##0.00);_(\xA3* "-"??_);_(@_)',
96494
+ description: "GBP Accounting",
96495
+ example: "\xA3 1,234.50"
96496
+ }
96497
+ },
96498
+ date: {
96499
+ shortUS: {
96500
+ code: "m/d/yyyy",
96501
+ description: "Short date (US)",
96502
+ example: "12/13/2025"
96503
+ },
96504
+ mediumUS: {
96505
+ code: "mmm d, yyyy",
96506
+ description: "Medium date (US)",
96507
+ example: "Dec 13, 2025"
96508
+ },
96509
+ longUS: {
96510
+ code: "mmmm d, yyyy",
96511
+ description: "Long date (US)",
96512
+ example: "December 13, 2025"
96513
+ },
96514
+ fullUS: {
96515
+ code: "dddd, mmmm d, yyyy",
96516
+ description: "Full date (US)",
96517
+ example: "Saturday, December 13, 2025"
96518
+ },
96519
+ iso: {
96520
+ code: "yyyy-mm-dd",
96521
+ description: "ISO 8601",
96522
+ example: "2025-12-13"
96523
+ },
96524
+ shortEU: {
96525
+ code: "d/m/yyyy",
96526
+ description: "Short date (EU)",
96527
+ example: "13/12/2025"
96528
+ },
96529
+ mediumEU: {
96530
+ code: "d mmm yyyy",
96531
+ description: "Medium date (EU)",
96532
+ example: "13 Dec 2025"
96533
+ },
96534
+ longEU: {
96535
+ code: "d mmmm yyyy",
96536
+ description: "Long date (EU)",
96537
+ example: "13 December 2025"
96538
+ },
96539
+ monthYear: {
96540
+ code: "mmmm yyyy",
96541
+ description: "Month and year",
96542
+ example: "December 2025"
96543
+ },
96544
+ monthYearShort: {
96545
+ code: "mmm yyyy",
96546
+ description: "Short month and year",
96547
+ example: "Dec 2025"
96548
+ },
96549
+ dayMonth: {
96550
+ code: "d mmmm",
96551
+ description: "Day and month",
96552
+ example: "13 December"
96553
+ },
96554
+ dayMonthShort: {
96555
+ code: "d mmm",
96556
+ description: "Short day and month",
96557
+ example: "13 Dec"
96558
+ },
96559
+ excelShort: {
96560
+ code: "m/d/yy",
96561
+ description: "Excel short date",
96562
+ example: "12/13/25"
96563
+ },
96564
+ excelMedium: {
96565
+ code: "d-mmm-yy",
96566
+ description: "Excel medium date",
96567
+ example: "13-Dec-25"
96568
+ },
96569
+ excelLong: {
96570
+ code: "d-mmm-yyyy",
96571
+ description: "Excel long date",
96572
+ example: "13-Dec-2025"
96573
+ }
96574
+ },
96575
+ time: {
96576
+ short12: {
96577
+ code: "h:mm AM/PM",
96578
+ description: "12-hour short",
96579
+ example: "3:45 PM"
96580
+ },
96581
+ long12: {
96582
+ code: "h:mm:ss AM/PM",
96583
+ description: "12-hour with seconds",
96584
+ example: "3:45:30 PM"
96585
+ },
96586
+ short24: {
96587
+ code: "HH:mm",
96588
+ description: "24-hour short",
96589
+ example: "15:45"
96590
+ },
96591
+ long24: {
96592
+ code: "HH:mm:ss",
96593
+ description: "24-hour with seconds",
96594
+ example: "15:45:30"
96595
+ },
96596
+ dateTime12: {
96597
+ code: "m/d/yyyy h:mm AM/PM",
96598
+ description: "Date and 12-hour time",
96599
+ example: "12/13/2025 3:45 PM"
96600
+ },
96601
+ dateTime24: {
96602
+ code: "yyyy-mm-dd HH:mm",
96603
+ description: "ISO date and 24-hour time",
96604
+ example: "2025-12-13 15:45"
96605
+ },
96606
+ durationHM: {
96607
+ code: "[h]:mm",
96608
+ description: "Hours and minutes (elapsed)",
96609
+ example: "25:30"
96610
+ },
96611
+ durationHMS: {
96612
+ code: "[h]:mm:ss",
96613
+ description: "Hours, minutes, seconds (elapsed)",
96614
+ example: "25:30:45"
96615
+ },
96616
+ durationMS: {
96617
+ code: "[mm]:ss",
96618
+ description: "Minutes and seconds (elapsed)",
96619
+ example: "1530:45"
96620
+ }
96621
+ },
96622
+ percentage: {
96623
+ integer: {
96624
+ code: "0%",
96625
+ description: "No decimal places",
96626
+ example: "50%"
96627
+ },
96628
+ decimal1: {
96629
+ code: "0.0%",
96630
+ description: "1 decimal place",
96631
+ example: "50.0%"
96632
+ },
96633
+ decimal2: {
96634
+ code: "0.00%",
96635
+ description: "2 decimal places",
96636
+ example: "50.00%"
96637
+ },
96638
+ decimal3: {
96639
+ code: "0.000%",
96640
+ description: "3 decimal places",
96641
+ example: "50.000%"
96642
+ }
96643
+ },
96644
+ fraction: {
96645
+ halves: {
96646
+ code: "# ?/2",
96647
+ description: "Halves (1/2)",
96648
+ example: "1 1/2"
96649
+ },
96650
+ quarters: {
96651
+ code: "# ?/4",
96652
+ description: "Quarters (1/4)",
96653
+ example: "1 1/4"
96654
+ },
96655
+ eighths: {
96656
+ code: "# ?/8",
96657
+ description: "Eighths (1/8)",
96658
+ example: "1 3/8"
96659
+ },
96660
+ sixteenths: {
96661
+ code: "# ??/16",
96662
+ description: "Sixteenths (1/16)",
96663
+ example: "1 5/16"
96664
+ },
96665
+ tenths: {
96666
+ code: "# ?/10",
96667
+ description: "Tenths (1/10)",
96668
+ example: "1 3/10"
96669
+ },
96670
+ hundredths: {
96671
+ code: "# ??/100",
96672
+ description: "Hundredths (1/100)",
96673
+ example: "1 25/100"
96674
+ },
96675
+ upToOneDigit: {
96676
+ code: "# ?/?",
96677
+ description: "Up to one digit (1/4)",
96678
+ example: "1 2/3"
96679
+ },
96680
+ upToTwoDigits: {
96681
+ code: "# ??/??",
96682
+ description: "Up to two digits (21/25)",
96683
+ example: "1 25/67"
96684
+ },
96685
+ upToThreeDigits: {
96686
+ code: "# ???/???",
96687
+ description: "Up to three digits (312/943)",
96688
+ example: "1 312/943"
96689
+ }
96690
+ },
96691
+ scientific: {
96692
+ default: {
96693
+ code: "0.00E+00",
96694
+ description: "2 decimal places",
96695
+ example: "1.23E+03"
96696
+ },
96697
+ decimal1: {
96698
+ code: "0.0E+00",
96699
+ description: "1 decimal place",
96700
+ example: "1.2E+03"
96701
+ },
96702
+ decimal3: {
96703
+ code: "0.000E+00",
96704
+ description: "3 decimal places",
96705
+ example: "1.235E+03"
96706
+ },
96707
+ noDecimals: {
96708
+ code: "0E+00",
96709
+ description: "No decimal places",
96710
+ example: "1E+03"
96711
+ }
96712
+ },
96713
+ text: {
96714
+ default: {
96715
+ code: "@",
96716
+ description: "Display as entered",
96717
+ example: "1234"
96718
+ }
96719
+ },
96720
+ special: {
96721
+ zipCode: {
96722
+ code: "00000",
96723
+ description: "ZIP Code (5-digit)",
96724
+ example: "01234"
96725
+ },
96726
+ zipPlus4: {
96727
+ code: "00000-0000",
96728
+ description: "ZIP+4 Code",
96729
+ example: "01234-5678"
96730
+ },
96731
+ phone: {
96732
+ code: "(###) ###-####",
96733
+ description: "Phone Number",
96734
+ example: "(555) 123-4567"
96735
+ },
96736
+ ssn: {
96737
+ code: "000-00-0000",
96738
+ description: "Social Security Number",
96739
+ example: "123-45-6789"
96740
+ }
96741
+ },
96742
+ custom: {}
96743
+ },
96744
+ defaultFormats: {
96745
+ accounting: '_($* #,##0.00_);_($* (#,##0.00);_($* "-"??_);_(@_)',
96746
+ currency: "$#,##0.00",
96747
+ custom: "General",
96748
+ date: "m/d/yyyy",
96749
+ fraction: "# ?/?",
96750
+ general: "General",
96751
+ number: "#,##0.00",
96752
+ percentage: "0.00%",
96753
+ scientific: "0.00E+00",
96754
+ special: "00000",
96755
+ text: "@",
96756
+ time: "h:mm AM/PM"
96165
96757
  }
96166
96758
  };
96167
96759