@ricsam/formula-engine 0.0.13 → 0.0.14

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.
@@ -261,6 +261,285 @@ class CopyManager {
261
261
  }
262
262
  }
263
263
  }
264
+ fillAreas(seedRange, targetRanges, options) {
265
+ for (const targetRange of targetRanges) {
266
+ this.fillRangeWithSeed(seedRange, targetRange, {
267
+ copyContent: options.target !== "style",
268
+ copyStyles: options.target === "all" || options.target === "style",
269
+ contentType: options.type,
270
+ adjustFormulas: true
271
+ });
272
+ }
273
+ if (options.cut) {
274
+ const seedCells = this.expandRangeToCells(seedRange);
275
+ this.clearSourceCells(seedCells);
276
+ }
277
+ }
278
+ fillRangeWithSeed(seedRange, targetRange, options) {
279
+ const seedCells = this.expandRangeToCells(seedRange);
280
+ const seedWidth = this.getRangeWidth(seedRange);
281
+ const seedHeight = this.getRangeHeight(seedRange);
282
+ const targetWidth = this.getRangeWidth(targetRange);
283
+ const targetHeight = this.getRangeHeight(targetRange);
284
+ const filledColumns = new Map;
285
+ for (let col = 0;col < seedWidth; col++) {
286
+ for (let row = 0;row < targetHeight; row++) {
287
+ const seedRow = row % seedHeight;
288
+ const seedCell = seedCells.find((c) => c.colIndex === seedRange.range.start.col + col && c.rowIndex === seedRange.range.start.row + seedRow);
289
+ if (seedCell) {
290
+ const targetCell = {
291
+ workbookName: targetRange.workbookName,
292
+ sheetName: targetRange.sheetName,
293
+ colIndex: targetRange.range.start.col + col,
294
+ rowIndex: targetRange.range.start.row + row
295
+ };
296
+ const rowDelta = targetCell.rowIndex - seedCell.rowIndex;
297
+ const colDelta = targetCell.colIndex - seedCell.colIndex;
298
+ if (options.copyContent) {
299
+ this.copyCellContentWithOffset(seedCell, targetCell, rowDelta, colDelta, {
300
+ type: options.contentType,
301
+ cut: false,
302
+ target: "content"
303
+ });
304
+ }
305
+ if (options.copyStyles) {
306
+ this.copyCellFormatting(seedCell, targetCell);
307
+ }
308
+ const key = `${targetCell.colIndex}-${targetCell.rowIndex}`;
309
+ const sheet = this.workbookManager.getSheet({
310
+ workbookName: targetCell.workbookName,
311
+ sheetName: targetCell.sheetName
312
+ });
313
+ const cellKey = `${String.fromCharCode(65 + targetCell.colIndex)}${targetCell.rowIndex + 1}`;
314
+ const content = sheet?.content.get(cellKey) || "";
315
+ filledColumns.set(key, { cell: targetCell, content });
316
+ }
317
+ }
318
+ }
319
+ if (targetWidth > seedWidth) {
320
+ for (let col = seedWidth;col < targetWidth; col++) {
321
+ const sourceCol = col % seedWidth;
322
+ for (let row = 0;row < targetHeight; row++) {
323
+ const sourceCell = {
324
+ workbookName: targetRange.workbookName,
325
+ sheetName: targetRange.sheetName,
326
+ colIndex: targetRange.range.start.col + sourceCol,
327
+ rowIndex: targetRange.range.start.row + row
328
+ };
329
+ const targetCell = {
330
+ workbookName: targetRange.workbookName,
331
+ sheetName: targetRange.sheetName,
332
+ colIndex: targetRange.range.start.col + col,
333
+ rowIndex: targetRange.range.start.row + row
334
+ };
335
+ const colDelta = targetCell.colIndex - sourceCell.colIndex;
336
+ if (options.copyContent) {
337
+ this.copyCellContentWithOffset(sourceCell, targetCell, 0, colDelta, {
338
+ type: options.contentType,
339
+ cut: false,
340
+ target: "content"
341
+ });
342
+ }
343
+ if (options.copyStyles) {
344
+ this.copyCellFormatting(sourceCell, targetCell);
345
+ }
346
+ }
347
+ }
348
+ }
349
+ }
350
+ getRangeWidth(range) {
351
+ if (range.range.end.col.type === "infinity") {
352
+ return 100;
353
+ }
354
+ return range.range.end.col.value - range.range.start.col + 1;
355
+ }
356
+ getRangeHeight(range) {
357
+ if (range.range.end.row.type === "infinity") {
358
+ return 100;
359
+ }
360
+ return range.range.end.row.value - range.range.start.row + 1;
361
+ }
362
+ expandRangeToCells(rangeAddress) {
363
+ const { workbookName, sheetName, range } = rangeAddress;
364
+ const cells = [];
365
+ const startCol = range.start.col;
366
+ const startRow = range.start.row;
367
+ let endCol;
368
+ if (range.end.col.type === "infinity") {
369
+ endCol = startCol + 99;
370
+ } else {
371
+ endCol = range.end.col.value;
372
+ }
373
+ let endRow;
374
+ if (range.end.row.type === "infinity") {
375
+ endRow = startRow + 99;
376
+ } else {
377
+ endRow = range.end.row.value;
378
+ }
379
+ for (let row = startRow;row <= endRow; row++) {
380
+ for (let col = startCol;col <= endCol; col++) {
381
+ cells.push({
382
+ workbookName,
383
+ sheetName,
384
+ colIndex: col,
385
+ rowIndex: row
386
+ });
387
+ }
388
+ }
389
+ return cells;
390
+ }
391
+ copyCellContentWithOffset(sourceCell, targetCell, rowDelta, colDelta, options) {
392
+ const sheet = this.workbookManager.getSheet({
393
+ workbookName: sourceCell.workbookName,
394
+ sheetName: sourceCell.sheetName
395
+ });
396
+ if (!sheet) {
397
+ return;
398
+ }
399
+ const key = `${String.fromCharCode(65 + sourceCell.colIndex)}${sourceCell.rowIndex + 1}`;
400
+ const cellContent = sheet.content.get(key);
401
+ if (!cellContent) {
402
+ const targetSheet2 = this.workbookManager.getSheet({
403
+ workbookName: targetCell.workbookName,
404
+ sheetName: targetCell.sheetName
405
+ });
406
+ if (targetSheet2) {
407
+ const targetKey = `${String.fromCharCode(65 + targetCell.colIndex)}${targetCell.rowIndex + 1}`;
408
+ targetSheet2.content.delete(targetKey);
409
+ }
410
+ return;
411
+ }
412
+ let targetContent;
413
+ if (options.type === "value") {
414
+ const evalResult = this.evaluationManager.getCellEvaluationResult(sourceCell);
415
+ if (!evalResult || evalResult.type !== "value") {
416
+ targetContent = cellContent;
417
+ } else {
418
+ const result = evalResult.result;
419
+ if (result.type === "number") {
420
+ targetContent = result.value;
421
+ } else if (result.type === "string") {
422
+ targetContent = result.value;
423
+ } else if (result.type === "boolean") {
424
+ targetContent = result.value;
425
+ } else {
426
+ targetContent = cellContent;
427
+ }
428
+ }
429
+ } else {
430
+ if (typeof cellContent === "string" && cellContent.startsWith("=")) {
431
+ targetContent = this.adjustFormulaWithOffset(cellContent, rowDelta, colDelta);
432
+ } else {
433
+ targetContent = cellContent;
434
+ }
435
+ }
436
+ const targetSheet = this.workbookManager.getSheet({
437
+ workbookName: targetCell.workbookName,
438
+ sheetName: targetCell.sheetName
439
+ });
440
+ if (targetSheet) {
441
+ const targetKey = `${String.fromCharCode(65 + targetCell.colIndex)}${targetCell.rowIndex + 1}`;
442
+ targetSheet.content.set(targetKey, targetContent);
443
+ }
444
+ }
445
+ adjustFormulaWithOffset(formula, rowDelta, colDelta) {
446
+ try {
447
+ const ast = import_parser.parseFormula(formula.slice(1));
448
+ const adjustedAst = import_ast_traverser.transformAST(ast, (node) => {
449
+ if (node.type === "reference") {
450
+ const refNode = node;
451
+ return {
452
+ ...refNode,
453
+ address: {
454
+ colIndex: refNode.isAbsolute.col ? refNode.address.colIndex : refNode.address.colIndex + colDelta,
455
+ rowIndex: refNode.isAbsolute.row ? refNode.address.rowIndex : refNode.address.rowIndex + rowDelta
456
+ }
457
+ };
458
+ } else if (node.type === "range") {
459
+ const rangeNode = node;
460
+ return {
461
+ ...rangeNode,
462
+ range: {
463
+ start: {
464
+ col: rangeNode.isAbsolute.start.col ? rangeNode.range.start.col : rangeNode.range.start.col + colDelta,
465
+ row: rangeNode.isAbsolute.start.row ? rangeNode.range.start.row : rangeNode.range.start.row + rowDelta
466
+ },
467
+ end: {
468
+ col: rangeNode.range.end.col.type === "number" ? rangeNode.isAbsolute.end.col ? rangeNode.range.end.col : {
469
+ type: "number",
470
+ value: rangeNode.range.end.col.value + colDelta
471
+ } : rangeNode.range.end.col,
472
+ row: rangeNode.range.end.row.type === "number" ? rangeNode.isAbsolute.end.row ? rangeNode.range.end.row : {
473
+ type: "number",
474
+ value: rangeNode.range.end.row.value + rowDelta
475
+ } : rangeNode.range.end.row
476
+ }
477
+ }
478
+ };
479
+ }
480
+ return node;
481
+ });
482
+ return `=${import_formatter.astToString(adjustedAst)}`;
483
+ } catch (error) {
484
+ console.warn("Failed to adjust formula with offset:", error);
485
+ return formula;
486
+ }
487
+ }
488
+ copyCellFormatting(sourceCell, targetCell) {
489
+ const allConditionalStyles = this.styleManager.getAllConditionalStyles();
490
+ const allCellStyles = this.styleManager.getAllCellStyles();
491
+ const sourceCellRange = {
492
+ start: { col: sourceCell.colIndex, row: sourceCell.rowIndex },
493
+ end: {
494
+ col: { type: "number", value: sourceCell.colIndex },
495
+ row: { type: "number", value: sourceCell.rowIndex }
496
+ }
497
+ };
498
+ for (const style of allConditionalStyles) {
499
+ if (style.area.workbookName === sourceCell.workbookName && style.area.sheetName === sourceCell.sheetName) {
500
+ const intersection = import_range_utils.intersectRanges(style.area.range, sourceCellRange);
501
+ if (intersection) {
502
+ const newStyle = {
503
+ area: {
504
+ workbookName: targetCell.workbookName,
505
+ sheetName: targetCell.sheetName,
506
+ range: {
507
+ start: { col: targetCell.colIndex, row: targetCell.rowIndex },
508
+ end: {
509
+ col: { type: "number", value: targetCell.colIndex },
510
+ row: { type: "number", value: targetCell.rowIndex }
511
+ }
512
+ }
513
+ },
514
+ condition: style.condition
515
+ };
516
+ this.styleManager.addConditionalStyle(newStyle);
517
+ }
518
+ }
519
+ }
520
+ for (const style of allCellStyles) {
521
+ if (style.area.workbookName === sourceCell.workbookName && style.area.sheetName === sourceCell.sheetName) {
522
+ const intersection = import_range_utils.intersectRanges(style.area.range, sourceCellRange);
523
+ if (intersection) {
524
+ const newStyle = {
525
+ area: {
526
+ workbookName: targetCell.workbookName,
527
+ sheetName: targetCell.sheetName,
528
+ range: {
529
+ start: { col: targetCell.colIndex, row: targetCell.rowIndex },
530
+ end: {
531
+ col: { type: "number", value: targetCell.colIndex },
532
+ row: { type: "number", value: targetCell.rowIndex }
533
+ }
534
+ }
535
+ },
536
+ style: style.style
537
+ };
538
+ this.styleManager.addCellStyle(newStyle);
539
+ }
540
+ }
541
+ }
542
+ }
264
543
  }
265
544
 
266
- //# debugId=E593E7EFA7CC85BB64756E2164756E21
545
+ //# debugId=DAB7BAA575141E6064756E2164756E21
@@ -2,9 +2,9 @@
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/core/managers/copy-manager.ts"],
4
4
  "sourcesContent": [
5
- "/**\n * CopyManager - Manages cell copy/paste operations\n */\n\nimport type {\n CellAddress,\n CopyCellsOptions,\n ConditionalStyle,\n DirectCellStyle,\n LocalCellAddress,\n SerializedCellValue,\n SpreadsheetRange,\n} from \"../types.cjs\";\nimport type { WorkbookManager } from \"./workbook-manager.cjs\";\nimport type { EvaluationManager } from \"./evaluation-manager.cjs\";\nimport type { StyleManager } from \"./style-manager.cjs\";\nimport { parseFormula } from \"../../parser/parser.cjs\";\nimport { astToString } from \"../../parser/formatter.cjs\";\nimport { transformAST } from \"../ast-traverser.cjs\";\nimport type { ReferenceNode, RangeNode } from \"../../parser/ast.cjs\";\nimport { isCellInRange } from \"../utils.cjs\";\nimport { intersectRanges } from \"../utils/range-utils.cjs\";\n\nexport class CopyManager {\n constructor(\n private workbookManager: WorkbookManager,\n private evaluationManager: EvaluationManager,\n private styleManager: StyleManager\n ) {}\n\n /**\n * Copy cells from source to target\n */\n copyCells(\n source: CellAddress[],\n target: CellAddress,\n options: CopyCellsOptions\n ): void {\n if (source.length === 0) {\n return;\n }\n\n // Find top-left cell of source (minimum row/col indices)\n const topLeft = this.findTopLeft(source);\n\n // Calculate offset from source top-left to target\n const rowOffset = target.rowIndex - topLeft.rowIndex;\n const colOffset = target.colIndex - topLeft.colIndex;\n\n // Copy cell contents (skip if only copying style)\n if (options.target !== 'style') {\n for (const sourceCell of source) {\n const targetCell: CellAddress = {\n workbookName: target.workbookName,\n sheetName: target.sheetName,\n colIndex: sourceCell.colIndex + colOffset,\n rowIndex: sourceCell.rowIndex + rowOffset,\n };\n\n this.copyCellContent(sourceCell, targetCell, topLeft, options);\n }\n }\n\n // Copy formatting if requested\n if (options.target === 'all' || options.target === 'style') {\n this.copyFormatting(source, topLeft, target, rowOffset, colOffset);\n }\n\n // Clear source cells if cut\n if (options.cut) {\n this.clearSourceCells(source);\n }\n }\n\n /**\n * Find the top-left cell (minimum row/col indices)\n */\n private findTopLeft(cells: CellAddress[]): CellAddress {\n let minRow = Infinity;\n let minCol = Infinity;\n let topLeftCell = cells[0]!;\n\n for (const cell of cells) {\n if (\n cell.rowIndex < minRow ||\n (cell.rowIndex === minRow && cell.colIndex < minCol)\n ) {\n minRow = cell.rowIndex;\n minCol = cell.colIndex;\n topLeftCell = cell;\n }\n }\n\n return topLeftCell;\n }\n\n /**\n * Copy content from one cell to another\n */\n private copyCellContent(\n sourceCell: CellAddress,\n targetCell: CellAddress,\n sourceTopLeft: CellAddress,\n options: CopyCellsOptions\n ): void {\n const sheet = this.workbookManager.getSheet({\n workbookName: sourceCell.workbookName,\n sheetName: sourceCell.sheetName,\n });\n\n if (!sheet) {\n return;\n }\n\n const key = `${String.fromCharCode(65 + sourceCell.colIndex)}${\n sourceCell.rowIndex + 1\n }`;\n const cellContent = sheet.content.get(key);\n\n if (!cellContent) {\n // Source cell is empty\n return;\n }\n\n let targetContent: SerializedCellValue;\n\n if (options.type === \"value\") {\n // Copy evaluated value\n const evalResult = this.evaluationManager.getCellEvaluationResult(sourceCell);\n \n if (!evalResult || evalResult.type !== \"value\") {\n // If evaluation failed or is not a value, copy as-is\n targetContent = cellContent;\n } else {\n // Convert to literal value\n const result = evalResult.result;\n if (result.type === \"number\") {\n targetContent = result.value;\n } else if (result.type === \"string\") {\n targetContent = result.value;\n } else if (result.type === \"boolean\") {\n targetContent = result.value;\n } else {\n // Error or other type, copy as-is\n targetContent = cellContent;\n }\n }\n } else {\n // Copy formula\n if (typeof cellContent === \"string\" && cellContent.startsWith(\"=\")) {\n // Adjust formula references\n targetContent = this.adjustFormulaReferences(\n cellContent,\n {\n colIndex: sourceCell.colIndex,\n rowIndex: sourceCell.rowIndex,\n },\n {\n colIndex: targetCell.colIndex,\n rowIndex: targetCell.rowIndex,\n }\n );\n } else {\n // Not a formula, copy as-is\n targetContent = cellContent;\n }\n }\n\n // Set target cell content (using the engine's method through workbook manager)\n const targetSheet = this.workbookManager.getSheet({\n workbookName: targetCell.workbookName,\n sheetName: targetCell.sheetName,\n });\n\n if (targetSheet) {\n const targetKey = `${String.fromCharCode(65 + targetCell.colIndex)}${\n targetCell.rowIndex + 1\n }`;\n targetSheet.content.set(targetKey, targetContent);\n }\n }\n\n /**\n * Adjust formula references when copying\n * Based on autofill-utils.ts adjustFormulaReferences\n */\n private adjustFormulaReferences(\n formula: string,\n sourceAddress: LocalCellAddress,\n targetAddress: LocalCellAddress\n ): string {\n try {\n const ast = parseFormula(formula.slice(1)); // Remove the \"=\" sign\n\n const rowDelta = targetAddress.rowIndex - sourceAddress.rowIndex;\n const colDelta = targetAddress.colIndex - sourceAddress.colIndex;\n\n const adjustedAst = transformAST(ast, (node) => {\n if (node.type === \"reference\") {\n const refNode = node as ReferenceNode;\n return {\n ...refNode,\n address: {\n colIndex: refNode.isAbsolute.col\n ? refNode.address.colIndex\n : refNode.address.colIndex + colDelta,\n rowIndex: refNode.isAbsolute.row\n ? refNode.address.rowIndex\n : refNode.address.rowIndex + rowDelta,\n },\n };\n } else if (node.type === \"range\") {\n const rangeNode = node as RangeNode;\n return {\n ...rangeNode,\n range: {\n start: {\n col: rangeNode.isAbsolute.start.col\n ? rangeNode.range.start.col\n : rangeNode.range.start.col + colDelta,\n row: rangeNode.isAbsolute.start.row\n ? rangeNode.range.start.row\n : rangeNode.range.start.row + rowDelta,\n },\n end: {\n col:\n rangeNode.range.end.col.type === \"number\"\n ? rangeNode.isAbsolute.end.col\n ? rangeNode.range.end.col\n : {\n type: \"number\" as const,\n value: rangeNode.range.end.col.value + colDelta,\n }\n : rangeNode.range.end.col,\n row:\n rangeNode.range.end.row.type === \"number\"\n ? rangeNode.isAbsolute.end.row\n ? rangeNode.range.end.row\n : {\n type: \"number\" as const,\n value: rangeNode.range.end.row.value + rowDelta,\n }\n : rangeNode.range.end.row,\n },\n },\n };\n }\n return node;\n });\n\n return `=${astToString(adjustedAst)}`;\n } catch (error) {\n // If parsing fails, return the original formula\n console.warn(\"Failed to adjust formula references:\", error);\n return formula;\n }\n }\n\n /**\n * Copy formatting (cellStyles and conditionalStyles) from source to target\n */\n private copyFormatting(\n sourceCells: CellAddress[],\n sourceTopLeft: CellAddress,\n target: CellAddress,\n rowOffset: number,\n colOffset: number\n ): void {\n // Get all styles for the source workbook\n const allConditionalStyles = this.styleManager.getAllConditionalStyles();\n const allCellStyles = this.styleManager.getAllCellStyles();\n\n // Find styles that intersect with source cells\n const sourceRange = this.getBoundingBox(sourceCells);\n\n // Copy conditional styles\n for (const style of allConditionalStyles) {\n if (\n style.area.workbookName === sourceTopLeft.workbookName &&\n style.area.sheetName === sourceTopLeft.sheetName\n ) {\n // Calculate intersection of style range with source bounding box\n const intersection = intersectRanges(style.area.range, sourceRange);\n if (intersection) {\n // Copy only the intersection, offset to target\n const newStyle: ConditionalStyle = {\n area: {\n workbookName: target.workbookName,\n sheetName: target.sheetName,\n range: this.adjustRange(intersection, rowOffset, colOffset),\n },\n condition: style.condition,\n };\n this.styleManager.addConditionalStyle(newStyle);\n }\n }\n }\n\n // Copy cell styles\n for (const style of allCellStyles) {\n if (\n style.area.workbookName === sourceTopLeft.workbookName &&\n style.area.sheetName === sourceTopLeft.sheetName\n ) {\n // Calculate intersection of style range with source bounding box\n const intersection = intersectRanges(style.area.range, sourceRange);\n if (intersection) {\n // Copy only the intersection, offset to target\n const newStyle: DirectCellStyle = {\n area: {\n workbookName: target.workbookName,\n sheetName: target.sheetName,\n range: this.adjustRange(intersection, rowOffset, colOffset),\n },\n style: style.style,\n };\n this.styleManager.addCellStyle(newStyle);\n }\n }\n }\n }\n\n /**\n * Get bounding box for a set of cells\n */\n private getBoundingBox(cells: CellAddress[]): SpreadsheetRange {\n let minRow = Infinity;\n let maxRow = -Infinity;\n let minCol = Infinity;\n let maxCol = -Infinity;\n\n for (const cell of cells) {\n minRow = Math.min(minRow, cell.rowIndex);\n maxRow = Math.max(maxRow, cell.rowIndex);\n minCol = Math.min(minCol, cell.colIndex);\n maxCol = Math.max(maxCol, cell.colIndex);\n }\n\n return {\n start: { col: minCol, row: minRow },\n end: {\n col: { type: \"number\", value: maxCol },\n row: { type: \"number\", value: maxRow },\n },\n };\n }\n\n\n /**\n * Adjust a range by row and column offsets\n */\n private adjustRange(\n range: SpreadsheetRange,\n rowOffset: number,\n colOffset: number\n ): SpreadsheetRange {\n return {\n start: {\n col: range.start.col + colOffset,\n row: range.start.row + rowOffset,\n },\n end: {\n col:\n range.end.col.type === \"number\"\n ? { type: \"number\", value: range.end.col.value + colOffset }\n : range.end.col,\n row:\n range.end.row.type === \"number\"\n ? { type: \"number\", value: range.end.row.value + rowOffset }\n : range.end.row,\n },\n };\n }\n\n /**\n * Clear source cells (for cut operation)\n */\n private clearSourceCells(cells: CellAddress[]): void {\n for (const cell of cells) {\n const sheet = this.workbookManager.getSheet({\n workbookName: cell.workbookName,\n sheetName: cell.sheetName,\n });\n\n if (sheet) {\n const key = `${String.fromCharCode(65 + cell.colIndex)}${\n cell.rowIndex + 1\n }`;\n sheet.content.delete(key);\n }\n }\n }\n}\n\n"
5
+ "/**\n * CopyManager - Manages cell copy/paste operations\n */\n\nimport type {\n CellAddress,\n CopyCellsOptions,\n ConditionalStyle,\n DirectCellStyle,\n LocalCellAddress,\n RangeAddress,\n SerializedCellValue,\n SpreadsheetRange,\n} from \"../types.cjs\";\nimport type { WorkbookManager } from \"./workbook-manager.cjs\";\nimport type { EvaluationManager } from \"./evaluation-manager.cjs\";\nimport type { StyleManager } from \"./style-manager.cjs\";\nimport { parseFormula } from \"../../parser/parser.cjs\";\nimport { astToString } from \"../../parser/formatter.cjs\";\nimport { transformAST } from \"../ast-traverser.cjs\";\nimport type { ReferenceNode, RangeNode } from \"../../parser/ast.cjs\";\nimport { isCellInRange } from \"../utils.cjs\";\nimport { intersectRanges } from \"../utils/range-utils.cjs\";\n\nexport class CopyManager {\n constructor(\n private workbookManager: WorkbookManager,\n private evaluationManager: EvaluationManager,\n private styleManager: StyleManager\n ) {}\n\n /**\n * Paste cells from source to target\n */\n copyCells(\n source: CellAddress[],\n target: CellAddress,\n options: CopyCellsOptions\n ): void {\n if (source.length === 0) {\n return;\n }\n\n // Find top-left cell of source (minimum row/col indices)\n const topLeft = this.findTopLeft(source);\n\n // Calculate offset from source top-left to target\n const rowOffset = target.rowIndex - topLeft.rowIndex;\n const colOffset = target.colIndex - topLeft.colIndex;\n\n // Copy cell contents (skip if only copying style)\n if (options.target !== 'style') {\n for (const sourceCell of source) {\n const targetCell: CellAddress = {\n workbookName: target.workbookName,\n sheetName: target.sheetName,\n colIndex: sourceCell.colIndex + colOffset,\n rowIndex: sourceCell.rowIndex + rowOffset,\n };\n\n this.copyCellContent(sourceCell, targetCell, topLeft, options);\n }\n }\n\n // Copy formatting if requested\n if (options.target === 'all' || options.target === 'style') {\n this.copyFormatting(source, topLeft, target, rowOffset, colOffset);\n }\n\n // Clear source cells if cut\n if (options.cut) {\n this.clearSourceCells(source);\n }\n }\n\n /**\n * Find the top-left cell (minimum row/col indices)\n */\n private findTopLeft(cells: CellAddress[]): CellAddress {\n let minRow = Infinity;\n let minCol = Infinity;\n let topLeftCell = cells[0]!;\n\n for (const cell of cells) {\n if (\n cell.rowIndex < minRow ||\n (cell.rowIndex === minRow && cell.colIndex < minCol)\n ) {\n minRow = cell.rowIndex;\n minCol = cell.colIndex;\n topLeftCell = cell;\n }\n }\n\n return topLeftCell;\n }\n\n /**\n * Copy content from one cell to another\n */\n private copyCellContent(\n sourceCell: CellAddress,\n targetCell: CellAddress,\n sourceTopLeft: CellAddress,\n options: CopyCellsOptions\n ): void {\n const sheet = this.workbookManager.getSheet({\n workbookName: sourceCell.workbookName,\n sheetName: sourceCell.sheetName,\n });\n\n if (!sheet) {\n return;\n }\n\n const key = `${String.fromCharCode(65 + sourceCell.colIndex)}${\n sourceCell.rowIndex + 1\n }`;\n const cellContent = sheet.content.get(key);\n\n if (!cellContent) {\n // Source cell is empty\n return;\n }\n\n let targetContent: SerializedCellValue;\n\n if (options.type === \"value\") {\n // Copy evaluated value\n const evalResult = this.evaluationManager.getCellEvaluationResult(sourceCell);\n \n if (!evalResult || evalResult.type !== \"value\") {\n // If evaluation failed or is not a value, copy as-is\n targetContent = cellContent;\n } else {\n // Convert to literal value\n const result = evalResult.result;\n if (result.type === \"number\") {\n targetContent = result.value;\n } else if (result.type === \"string\") {\n targetContent = result.value;\n } else if (result.type === \"boolean\") {\n targetContent = result.value;\n } else {\n // Error or other type, copy as-is\n targetContent = cellContent;\n }\n }\n } else {\n // Copy formula\n if (typeof cellContent === \"string\" && cellContent.startsWith(\"=\")) {\n // Adjust formula references\n targetContent = this.adjustFormulaReferences(\n cellContent,\n {\n colIndex: sourceCell.colIndex,\n rowIndex: sourceCell.rowIndex,\n },\n {\n colIndex: targetCell.colIndex,\n rowIndex: targetCell.rowIndex,\n }\n );\n } else {\n // Not a formula, copy as-is\n targetContent = cellContent;\n }\n }\n\n // Set target cell content (using the engine's method through workbook manager)\n const targetSheet = this.workbookManager.getSheet({\n workbookName: targetCell.workbookName,\n sheetName: targetCell.sheetName,\n });\n\n if (targetSheet) {\n const targetKey = `${String.fromCharCode(65 + targetCell.colIndex)}${\n targetCell.rowIndex + 1\n }`;\n targetSheet.content.set(targetKey, targetContent);\n }\n }\n\n /**\n * Adjust formula references when copying\n * Based on autofill-utils.ts adjustFormulaReferences\n */\n private adjustFormulaReferences(\n formula: string,\n sourceAddress: LocalCellAddress,\n targetAddress: LocalCellAddress\n ): string {\n try {\n const ast = parseFormula(formula.slice(1)); // Remove the \"=\" sign\n\n const rowDelta = targetAddress.rowIndex - sourceAddress.rowIndex;\n const colDelta = targetAddress.colIndex - sourceAddress.colIndex;\n\n const adjustedAst = transformAST(ast, (node) => {\n if (node.type === \"reference\") {\n const refNode = node as ReferenceNode;\n return {\n ...refNode,\n address: {\n colIndex: refNode.isAbsolute.col\n ? refNode.address.colIndex\n : refNode.address.colIndex + colDelta,\n rowIndex: refNode.isAbsolute.row\n ? refNode.address.rowIndex\n : refNode.address.rowIndex + rowDelta,\n },\n };\n } else if (node.type === \"range\") {\n const rangeNode = node as RangeNode;\n return {\n ...rangeNode,\n range: {\n start: {\n col: rangeNode.isAbsolute.start.col\n ? rangeNode.range.start.col\n : rangeNode.range.start.col + colDelta,\n row: rangeNode.isAbsolute.start.row\n ? rangeNode.range.start.row\n : rangeNode.range.start.row + rowDelta,\n },\n end: {\n col:\n rangeNode.range.end.col.type === \"number\"\n ? rangeNode.isAbsolute.end.col\n ? rangeNode.range.end.col\n : {\n type: \"number\" as const,\n value: rangeNode.range.end.col.value + colDelta,\n }\n : rangeNode.range.end.col,\n row:\n rangeNode.range.end.row.type === \"number\"\n ? rangeNode.isAbsolute.end.row\n ? rangeNode.range.end.row\n : {\n type: \"number\" as const,\n value: rangeNode.range.end.row.value + rowDelta,\n }\n : rangeNode.range.end.row,\n },\n },\n };\n }\n return node;\n });\n\n return `=${astToString(adjustedAst)}`;\n } catch (error) {\n // If parsing fails, return the original formula\n console.warn(\"Failed to adjust formula references:\", error);\n return formula;\n }\n }\n\n /**\n * Copy formatting (cellStyles and conditionalStyles) from source to target\n */\n private copyFormatting(\n sourceCells: CellAddress[],\n sourceTopLeft: CellAddress,\n target: CellAddress,\n rowOffset: number,\n colOffset: number\n ): void {\n // Get all styles for the source workbook\n const allConditionalStyles = this.styleManager.getAllConditionalStyles();\n const allCellStyles = this.styleManager.getAllCellStyles();\n\n // Find styles that intersect with source cells\n const sourceRange = this.getBoundingBox(sourceCells);\n\n // Copy conditional styles\n for (const style of allConditionalStyles) {\n if (\n style.area.workbookName === sourceTopLeft.workbookName &&\n style.area.sheetName === sourceTopLeft.sheetName\n ) {\n // Calculate intersection of style range with source bounding box\n const intersection = intersectRanges(style.area.range, sourceRange);\n if (intersection) {\n // Copy only the intersection, offset to target\n const newStyle: ConditionalStyle = {\n area: {\n workbookName: target.workbookName,\n sheetName: target.sheetName,\n range: this.adjustRange(intersection, rowOffset, colOffset),\n },\n condition: style.condition,\n };\n this.styleManager.addConditionalStyle(newStyle);\n }\n }\n }\n\n // Copy cell styles\n for (const style of allCellStyles) {\n if (\n style.area.workbookName === sourceTopLeft.workbookName &&\n style.area.sheetName === sourceTopLeft.sheetName\n ) {\n // Calculate intersection of style range with source bounding box\n const intersection = intersectRanges(style.area.range, sourceRange);\n if (intersection) {\n // Copy only the intersection, offset to target\n const newStyle: DirectCellStyle = {\n area: {\n workbookName: target.workbookName,\n sheetName: target.sheetName,\n range: this.adjustRange(intersection, rowOffset, colOffset),\n },\n style: style.style,\n };\n this.styleManager.addCellStyle(newStyle);\n }\n }\n }\n }\n\n /**\n * Get bounding box for a set of cells\n */\n private getBoundingBox(cells: CellAddress[]): SpreadsheetRange {\n let minRow = Infinity;\n let maxRow = -Infinity;\n let minCol = Infinity;\n let maxCol = -Infinity;\n\n for (const cell of cells) {\n minRow = Math.min(minRow, cell.rowIndex);\n maxRow = Math.max(maxRow, cell.rowIndex);\n minCol = Math.min(minCol, cell.colIndex);\n maxCol = Math.max(maxCol, cell.colIndex);\n }\n\n return {\n start: { col: minCol, row: minRow },\n end: {\n col: { type: \"number\", value: maxCol },\n row: { type: \"number\", value: maxRow },\n },\n };\n }\n\n\n /**\n * Adjust a range by row and column offsets\n */\n private adjustRange(\n range: SpreadsheetRange,\n rowOffset: number,\n colOffset: number\n ): SpreadsheetRange {\n return {\n start: {\n col: range.start.col + colOffset,\n row: range.start.row + rowOffset,\n },\n end: {\n col:\n range.end.col.type === \"number\"\n ? { type: \"number\", value: range.end.col.value + colOffset }\n : range.end.col,\n row:\n range.end.row.type === \"number\"\n ? { type: \"number\", value: range.end.row.value + rowOffset }\n : range.end.row,\n },\n };\n }\n\n /**\n * Clear source cells (for cut operation)\n */\n private clearSourceCells(cells: CellAddress[]): void {\n for (const cell of cells) {\n const sheet = this.workbookManager.getSheet({\n workbookName: cell.workbookName,\n sheetName: cell.sheetName,\n });\n\n if (sheet) {\n const key = `${String.fromCharCode(65 + cell.colIndex)}${\n cell.rowIndex + 1\n }`;\n sheet.content.delete(key);\n }\n }\n }\n\n /**\n * Fill one or more areas with a seed range's content/style\n * Uses column-first strategy: fills down, then replicates right\n * Formulas are adjusted based on each target cell's offset from the seed\n */\n fillAreas(\n seedRange: RangeAddress,\n targetRanges: RangeAddress[],\n options: CopyCellsOptions\n ): void {\n for (const targetRange of targetRanges) {\n this.fillRangeWithSeed(seedRange, targetRange, {\n copyContent: options.target !== 'style',\n copyStyles: options.target === 'all' || options.target === 'style',\n contentType: options.type,\n adjustFormulas: true,\n });\n }\n\n // Clear seed range if cut operation\n if (options.cut) {\n const seedCells = this.expandRangeToCells(seedRange);\n this.clearSourceCells(seedCells);\n }\n }\n\n /**\n * Fill a target range with a seed range using column-first strategy\n * Step 1: Fill down - extend seed pattern vertically to match target height\n * Step 2: Replicate right - copy filled columns horizontally\n */\n private fillRangeWithSeed(\n seedRange: RangeAddress,\n targetRange: RangeAddress,\n options: {\n copyContent: boolean;\n copyStyles: boolean;\n contentType: \"value\" | \"formula\";\n adjustFormulas: boolean;\n }\n ): void {\n const seedCells = this.expandRangeToCells(seedRange);\n const seedWidth = this.getRangeWidth(seedRange);\n const seedHeight = this.getRangeHeight(seedRange);\n const targetWidth = this.getRangeWidth(targetRange);\n const targetHeight = this.getRangeHeight(targetRange);\n\n // Step 1: Fill down - replicate seed pattern vertically\n const filledColumns: Map<string, { cell: CellAddress; content: SerializedCellValue }> = new Map();\n \n for (let col = 0; col < seedWidth; col++) {\n for (let row = 0; row < targetHeight; row++) {\n const seedRow = row % seedHeight;\n const seedCell = seedCells.find(\n (c) => \n c.colIndex === seedRange.range.start.col + col &&\n c.rowIndex === seedRange.range.start.row + seedRow\n );\n\n if (seedCell) {\n const targetCell: CellAddress = {\n workbookName: targetRange.workbookName,\n sheetName: targetRange.sheetName,\n colIndex: targetRange.range.start.col + col,\n rowIndex: targetRange.range.start.row + row,\n };\n\n const rowDelta = targetCell.rowIndex - seedCell.rowIndex;\n const colDelta = targetCell.colIndex - seedCell.colIndex;\n\n if (options.copyContent) {\n this.copyCellContentWithOffset(seedCell, targetCell, rowDelta, colDelta, {\n type: options.contentType,\n cut: false,\n target: 'content',\n });\n }\n\n if (options.copyStyles) {\n this.copyCellFormatting(seedCell, targetCell);\n }\n\n // Store filled column for horizontal replication\n const key = `${targetCell.colIndex}-${targetCell.rowIndex}`;\n const sheet = this.workbookManager.getSheet({\n workbookName: targetCell.workbookName,\n sheetName: targetCell.sheetName,\n });\n const cellKey = `${String.fromCharCode(65 + targetCell.colIndex)}${targetCell.rowIndex + 1}`;\n const content = sheet?.content.get(cellKey) || \"\";\n filledColumns.set(key, { cell: targetCell, content });\n }\n }\n }\n\n // Step 2: Replicate right - copy filled columns horizontally\n if (targetWidth > seedWidth) {\n for (let col = seedWidth; col < targetWidth; col++) {\n const sourceCol = col % seedWidth;\n \n for (let row = 0; row < targetHeight; row++) {\n const sourceCell: CellAddress = {\n workbookName: targetRange.workbookName,\n sheetName: targetRange.sheetName,\n colIndex: targetRange.range.start.col + sourceCol,\n rowIndex: targetRange.range.start.row + row,\n };\n\n const targetCell: CellAddress = {\n workbookName: targetRange.workbookName,\n sheetName: targetRange.sheetName,\n colIndex: targetRange.range.start.col + col,\n rowIndex: targetRange.range.start.row + row,\n };\n\n const colDelta = targetCell.colIndex - sourceCell.colIndex;\n\n if (options.copyContent) {\n this.copyCellContentWithOffset(sourceCell, targetCell, 0, colDelta, {\n type: options.contentType,\n cut: false,\n target: 'content',\n });\n }\n\n if (options.copyStyles) {\n this.copyCellFormatting(sourceCell, targetCell);\n }\n }\n }\n }\n }\n\n /**\n * Get the width of a range (number of columns)\n */\n private getRangeWidth(range: RangeAddress): number {\n if (range.range.end.col.type === \"infinity\") {\n return 100; // Default for infinite\n }\n return range.range.end.col.value - range.range.start.col + 1;\n }\n\n /**\n * Get the height of a range (number of rows)\n */\n private getRangeHeight(range: RangeAddress): number {\n if (range.range.end.row.type === \"infinity\") {\n return 100; // Default for infinite\n }\n return range.range.end.row.value - range.range.start.row + 1;\n }\n\n /**\n * Expand a RangeAddress into an array of CellAddress\n * Handles finite ranges, row-bounded, and column-bounded ranges\n */\n private expandRangeToCells(rangeAddress: RangeAddress): CellAddress[] {\n const { workbookName, sheetName, range } = rangeAddress;\n const cells: CellAddress[] = [];\n\n const startCol = range.start.col;\n const startRow = range.start.row;\n\n // Determine end column\n let endCol: number;\n if (range.end.col.type === \"infinity\") {\n // Limit infinite column ranges to a reasonable size (e.g., 100 columns)\n endCol = startCol + 99;\n } else {\n endCol = range.end.col.value;\n }\n\n // Determine end row\n let endRow: number;\n if (range.end.row.type === \"infinity\") {\n // Limit infinite row ranges to a reasonable size (e.g., 100 rows)\n endRow = startRow + 99;\n } else {\n endRow = range.end.row.value;\n }\n\n // Generate all cells in the range\n for (let row = startRow; row <= endRow; row++) {\n for (let col = startCol; col <= endCol; col++) {\n cells.push({\n workbookName,\n sheetName,\n colIndex: col,\n rowIndex: row,\n });\n }\n }\n\n return cells;\n }\n\n /**\n * Copy cell content with explicit row/column offset for fill operations\n */\n private copyCellContentWithOffset(\n sourceCell: CellAddress,\n targetCell: CellAddress,\n rowDelta: number,\n colDelta: number,\n options: CopyCellsOptions\n ): void {\n const sheet = this.workbookManager.getSheet({\n workbookName: sourceCell.workbookName,\n sheetName: sourceCell.sheetName,\n });\n\n if (!sheet) {\n return;\n }\n\n const key = `${String.fromCharCode(65 + sourceCell.colIndex)}${\n sourceCell.rowIndex + 1\n }`;\n const cellContent = sheet.content.get(key);\n\n if (!cellContent) {\n // Source cell is empty - clear target\n const targetSheet = this.workbookManager.getSheet({\n workbookName: targetCell.workbookName,\n sheetName: targetCell.sheetName,\n });\n if (targetSheet) {\n const targetKey = `${String.fromCharCode(65 + targetCell.colIndex)}${\n targetCell.rowIndex + 1\n }`;\n targetSheet.content.delete(targetKey);\n }\n return;\n }\n\n let targetContent: SerializedCellValue;\n\n if (options.type === \"value\") {\n // Copy evaluated value\n const evalResult = this.evaluationManager.getCellEvaluationResult(sourceCell);\n \n if (!evalResult || evalResult.type !== \"value\") {\n // If evaluation failed or is not a value, copy as-is\n targetContent = cellContent;\n } else {\n // Convert to literal value\n const result = evalResult.result;\n if (result.type === \"number\") {\n targetContent = result.value;\n } else if (result.type === \"string\") {\n targetContent = result.value;\n } else if (result.type === \"boolean\") {\n targetContent = result.value;\n } else {\n // Error or other type, copy as-is\n targetContent = cellContent;\n }\n }\n } else {\n // Copy formula with offset adjustment\n if (typeof cellContent === \"string\" && cellContent.startsWith(\"=\")) {\n // Adjust formula references based on offset\n targetContent = this.adjustFormulaWithOffset(\n cellContent,\n rowDelta,\n colDelta\n );\n } else {\n // Not a formula, copy as-is\n targetContent = cellContent;\n }\n }\n\n // Set target cell content\n const targetSheet = this.workbookManager.getSheet({\n workbookName: targetCell.workbookName,\n sheetName: targetCell.sheetName,\n });\n\n if (targetSheet) {\n const targetKey = `${String.fromCharCode(65 + targetCell.colIndex)}${\n targetCell.rowIndex + 1\n }`;\n targetSheet.content.set(targetKey, targetContent);\n }\n }\n\n /**\n * Adjust formula references by a specific row/column offset\n */\n private adjustFormulaWithOffset(\n formula: string,\n rowDelta: number,\n colDelta: number\n ): string {\n try {\n const ast = parseFormula(formula.slice(1)); // Remove the \"=\" sign\n\n const adjustedAst = transformAST(ast, (node) => {\n if (node.type === \"reference\") {\n const refNode = node as ReferenceNode;\n return {\n ...refNode,\n address: {\n colIndex: refNode.isAbsolute.col\n ? refNode.address.colIndex\n : refNode.address.colIndex + colDelta,\n rowIndex: refNode.isAbsolute.row\n ? refNode.address.rowIndex\n : refNode.address.rowIndex + rowDelta,\n },\n };\n } else if (node.type === \"range\") {\n const rangeNode = node as RangeNode;\n return {\n ...rangeNode,\n range: {\n start: {\n col: rangeNode.isAbsolute.start.col\n ? rangeNode.range.start.col\n : rangeNode.range.start.col + colDelta,\n row: rangeNode.isAbsolute.start.row\n ? rangeNode.range.start.row\n : rangeNode.range.start.row + rowDelta,\n },\n end: {\n col:\n rangeNode.range.end.col.type === \"number\"\n ? rangeNode.isAbsolute.end.col\n ? rangeNode.range.end.col\n : {\n type: \"number\" as const,\n value: rangeNode.range.end.col.value + colDelta,\n }\n : rangeNode.range.end.col,\n row:\n rangeNode.range.end.row.type === \"number\"\n ? rangeNode.isAbsolute.end.row\n ? rangeNode.range.end.row\n : {\n type: \"number\" as const,\n value: rangeNode.range.end.row.value + rowDelta,\n }\n : rangeNode.range.end.row,\n },\n },\n };\n }\n return node;\n });\n\n return `=${astToString(adjustedAst)}`;\n } catch (error) {\n // If parsing fails, return the original formula\n console.warn(\"Failed to adjust formula with offset:\", error);\n return formula;\n }\n }\n\n /**\n * Copy formatting from one cell to another\n */\n private copyCellFormatting(\n sourceCell: CellAddress,\n targetCell: CellAddress\n ): void {\n // Get all styles that intersect with the source cell\n const allConditionalStyles = this.styleManager.getAllConditionalStyles();\n const allCellStyles = this.styleManager.getAllCellStyles();\n\n const sourceCellRange: SpreadsheetRange = {\n start: { col: sourceCell.colIndex, row: sourceCell.rowIndex },\n end: {\n col: { type: \"number\", value: sourceCell.colIndex },\n row: { type: \"number\", value: sourceCell.rowIndex },\n },\n };\n\n // Copy conditional styles that apply to source cell\n for (const style of allConditionalStyles) {\n if (\n style.area.workbookName === sourceCell.workbookName &&\n style.area.sheetName === sourceCell.sheetName\n ) {\n const intersection = intersectRanges(style.area.range, sourceCellRange);\n if (intersection) {\n // Apply style to target cell\n const newStyle: ConditionalStyle = {\n area: {\n workbookName: targetCell.workbookName,\n sheetName: targetCell.sheetName,\n range: {\n start: { col: targetCell.colIndex, row: targetCell.rowIndex },\n end: {\n col: { type: \"number\", value: targetCell.colIndex },\n row: { type: \"number\", value: targetCell.rowIndex },\n },\n },\n },\n condition: style.condition,\n };\n this.styleManager.addConditionalStyle(newStyle);\n }\n }\n }\n\n // Copy cell styles that apply to source cell\n for (const style of allCellStyles) {\n if (\n style.area.workbookName === sourceCell.workbookName &&\n style.area.sheetName === sourceCell.sheetName\n ) {\n const intersection = intersectRanges(style.area.range, sourceCellRange);\n if (intersection) {\n // Apply style to target cell\n const newStyle: DirectCellStyle = {\n area: {\n workbookName: targetCell.workbookName,\n sheetName: targetCell.sheetName,\n range: {\n start: { col: targetCell.colIndex, row: targetCell.rowIndex },\n end: {\n col: { type: \"number\", value: targetCell.colIndex },\n row: { type: \"number\", value: targetCell.rowIndex },\n },\n },\n },\n style: style.style,\n };\n this.styleManager.addCellStyle(newStyle);\n }\n }\n }\n }\n}\n\n"
6
6
  ],
7
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgB6B,IAA7B;AAC4B,IAA5B;AAC6B,IAA7B;AAGgC,IAAhC;AAAA;AAEO,MAAM,YAAY;AAAA,EAEb;AAAA,EACA;AAAA,EACA;AAAA,EAHV,WAAW,CACD,iBACA,mBACA,cACR;AAAA,IAHQ;AAAA,IACA;AAAA,IACA;AAAA;AAAA,EAMV,SAAS,CACP,QACA,QACA,SACM;AAAA,IACN,IAAI,OAAO,WAAW,GAAG;AAAA,MACvB;AAAA,IACF;AAAA,IAGA,MAAM,UAAU,KAAK,YAAY,MAAM;AAAA,IAGvC,MAAM,YAAY,OAAO,WAAW,QAAQ;AAAA,IAC5C,MAAM,YAAY,OAAO,WAAW,QAAQ;AAAA,IAG5C,IAAI,QAAQ,WAAW,SAAS;AAAA,MAC9B,WAAW,cAAc,QAAQ;AAAA,QAC/B,MAAM,aAA0B;AAAA,UAC9B,cAAc,OAAO;AAAA,UACrB,WAAW,OAAO;AAAA,UAClB,UAAU,WAAW,WAAW;AAAA,UAChC,UAAU,WAAW,WAAW;AAAA,QAClC;AAAA,QAEA,KAAK,gBAAgB,YAAY,YAAY,SAAS,OAAO;AAAA,MAC/D;AAAA,IACF;AAAA,IAGA,IAAI,QAAQ,WAAW,SAAS,QAAQ,WAAW,SAAS;AAAA,MAC1D,KAAK,eAAe,QAAQ,SAAS,QAAQ,WAAW,SAAS;AAAA,IACnE;AAAA,IAGA,IAAI,QAAQ,KAAK;AAAA,MACf,KAAK,iBAAiB,MAAM;AAAA,IAC9B;AAAA;AAAA,EAMM,WAAW,CAAC,OAAmC;AAAA,IAC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164756E21",
9
9
  "names": []
10
10
  }
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@ricsam/formula-engine",
3
- "version": "0.0.13",
3
+ "version": "0.0.14",
4
4
  "type": "commonjs"
5
5
  }
@@ -3,12 +3,15 @@ import { parseFormula } from "../parser/parser.mjs";
3
3
  import { astToString } from "../parser/formatter.mjs";
4
4
  import { transformAST } from "./ast-traverser.mjs";
5
5
  import { getCellReference } from "./utils.mjs";
6
+ import { intersectRanges } from "./utils/range-utils.mjs";
6
7
 
7
8
  class AutoFill {
8
9
  workbookManager;
10
+ styleManager;
9
11
  engine;
10
- constructor(workbookManager, engine) {
12
+ constructor(workbookManager, styleManager, engine) {
11
13
  this.workbookManager = workbookManager;
14
+ this.styleManager = styleManager;
12
15
  this.engine = engine;
13
16
  }
14
17
  toFiniteRange(range) {
@@ -30,7 +33,12 @@ class AutoFill {
30
33
  }
31
34
  return sheet.content.get(getCellReference(address));
32
35
  }
33
- fill(opts, seedRange, fillRange, direction) {
36
+ fill(opts, seedRange, fillRanges, direction) {
37
+ for (const fillRange of fillRanges) {
38
+ this.fillSingleRange(opts, seedRange, fillRange, direction);
39
+ }
40
+ }
41
+ fillSingleRange(opts, seedRange, fillRange, direction) {
34
42
  const finiteSeedRange = this.toFiniteRange(seedRange);
35
43
  const finiteFillRange = this.toFiniteRange(fillRange);
36
44
  const seedCells = this.getSeedCells(opts, finiteSeedRange);
@@ -54,6 +62,7 @@ class AutoFill {
54
62
  }
55
63
  });
56
64
  this.engine.setSheetContent(opts, newContent);
65
+ this.fillStyles(opts, finiteSeedRange, finiteFillRange, direction);
57
66
  }
58
67
  getSeedCells(opts, seedRange) {
59
68
  const cells = [];
@@ -266,9 +275,92 @@ class AutoFill {
266
275
  return formula;
267
276
  }
268
277
  }
278
+ fillStyles(opts, seedRange, fillRange, direction) {
279
+ const seedWidth = seedRange.end.col - seedRange.start.col + 1;
280
+ const seedHeight = seedRange.end.row - seedRange.start.row + 1;
281
+ const seedSpreadsheetRange = {
282
+ start: { col: seedRange.start.col, row: seedRange.start.row },
283
+ end: {
284
+ col: { type: "number", value: seedRange.end.col },
285
+ row: { type: "number", value: seedRange.end.row }
286
+ }
287
+ };
288
+ const allConditionalStyles = this.styleManager.getAllConditionalStyles();
289
+ const allCellStyles = this.styleManager.getAllCellStyles();
290
+ for (let row = fillRange.start.row;row <= fillRange.end.row; row++) {
291
+ for (let col = fillRange.start.col;col <= fillRange.end.col; col++) {
292
+ let seedCol;
293
+ let seedRow;
294
+ if (direction === "down" || direction === "up") {
295
+ seedCol = seedRange.start.col + (col - fillRange.start.col) % seedWidth;
296
+ seedRow = seedRange.start.row + (row - fillRange.start.row) % seedHeight;
297
+ } else {
298
+ seedRow = seedRange.start.row + (row - fillRange.start.row) % seedHeight;
299
+ seedCol = seedRange.start.col + (col - fillRange.start.col) % seedWidth;
300
+ }
301
+ const sourceCellRange = {
302
+ start: { col: seedCol, row: seedRow },
303
+ end: {
304
+ col: { type: "number", value: seedCol },
305
+ row: { type: "number", value: seedRow }
306
+ }
307
+ };
308
+ const targetCell = {
309
+ workbookName: opts.workbookName,
310
+ sheetName: opts.sheetName,
311
+ colIndex: col,
312
+ rowIndex: row
313
+ };
314
+ for (const style of allConditionalStyles) {
315
+ if (style.area.workbookName === opts.workbookName && style.area.sheetName === opts.sheetName) {
316
+ const intersection = intersectRanges(style.area.range, sourceCellRange);
317
+ if (intersection) {
318
+ const newStyle = {
319
+ area: {
320
+ workbookName: opts.workbookName,
321
+ sheetName: opts.sheetName,
322
+ range: {
323
+ start: { col: targetCell.colIndex, row: targetCell.rowIndex },
324
+ end: {
325
+ col: { type: "number", value: targetCell.colIndex },
326
+ row: { type: "number", value: targetCell.rowIndex }
327
+ }
328
+ }
329
+ },
330
+ condition: style.condition
331
+ };
332
+ this.styleManager.addConditionalStyle(newStyle);
333
+ }
334
+ }
335
+ }
336
+ for (const style of allCellStyles) {
337
+ if (style.area.workbookName === opts.workbookName && style.area.sheetName === opts.sheetName) {
338
+ const intersection = intersectRanges(style.area.range, sourceCellRange);
339
+ if (intersection) {
340
+ const newStyle = {
341
+ area: {
342
+ workbookName: opts.workbookName,
343
+ sheetName: opts.sheetName,
344
+ range: {
345
+ start: { col: targetCell.colIndex, row: targetCell.rowIndex },
346
+ end: {
347
+ col: { type: "number", value: targetCell.colIndex },
348
+ row: { type: "number", value: targetCell.rowIndex }
349
+ }
350
+ }
351
+ },
352
+ style: style.style
353
+ };
354
+ this.styleManager.addCellStyle(newStyle);
355
+ }
356
+ }
357
+ }
358
+ }
359
+ }
360
+ }
269
361
  }
270
362
  export {
271
363
  AutoFill
272
364
  };
273
365
 
274
- //# debugId=F06B199CC2D5C89664756E2164756E21
366
+ //# debugId=2BE8A5E965C079A064756E2164756E21