@univerjs/sheets 0.5.2 → 0.5.3-nightly.202501051605

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.
Files changed (37) hide show
  1. package/lib/cjs/facade.js +1 -1
  2. package/lib/cjs/index.js +3 -3
  3. package/lib/es/facade.js +598 -363
  4. package/lib/es/index.js +4605 -3763
  5. package/lib/types/basics/interfaces/mutation-interface.d.ts +7 -0
  6. package/lib/types/commands/commands/__tests__/range-template-command.sepc.d.ts +16 -0
  7. package/lib/types/commands/commands/add-worksheet-merge.command.d.ts +1 -1
  8. package/lib/types/commands/commands/add-worksheet-range-theme.command.d.ts +2 -0
  9. package/lib/types/commands/commands/delete-worksheet-range-theme.command.d.ts +2 -0
  10. package/lib/types/commands/commands/insert-row-col.command.d.ts +2 -0
  11. package/lib/types/commands/commands/register-range-theme.command.d.ts +7 -0
  12. package/lib/types/commands/commands/remove-row-col.command.d.ts +12 -0
  13. package/lib/types/commands/commands/unregister-range-theme.command.d.ts +6 -0
  14. package/lib/types/commands/mutations/add-worksheet-range-theme.mutation.d.ts +9 -0
  15. package/lib/types/commands/mutations/delete-worksheet-range-theme.mutation.d.ts +9 -0
  16. package/lib/types/commands/mutations/register-range-theme.mutation.d.ts +8 -0
  17. package/lib/types/commands/mutations/unregister-range-theme-style.mutation.d.ts +6 -0
  18. package/lib/types/facade/f-event.d.ts +30 -0
  19. package/lib/types/facade/f-permission.d.ts +0 -6
  20. package/lib/types/facade/f-range.d.ts +106 -21
  21. package/lib/types/facade/f-selection.d.ts +1 -1
  22. package/lib/types/facade/f-univer.d.ts +22 -6
  23. package/lib/types/facade/f-workbook.d.ts +52 -16
  24. package/lib/types/facade/f-worksheet.d.ts +75 -59
  25. package/lib/types/facade/index.d.ts +2 -1
  26. package/lib/types/index.d.ts +15 -3
  27. package/lib/types/model/range-theme-model.d.ts +66 -0
  28. package/lib/types/model/range-theme-util.d.ts +97 -0
  29. package/lib/types/model/range-themes/build-in-theme.factory.d.ts +5 -0
  30. package/lib/types/model/range-themes/default.d.ts +2 -0
  31. package/lib/types/services/range-theme-service.d.ts +34 -0
  32. package/lib/types/services/sheet-interceptor/interceptor-const.d.ts +2 -0
  33. package/lib/types/services/sheet-interceptor/sheet-interceptor.service.d.ts +5 -3
  34. package/lib/umd/facade.js +1 -1
  35. package/lib/umd/index.js +3 -3
  36. package/package.json +8 -31
  37. package/LICENSE +0 -176
package/lib/es/facade.js CHANGED
@@ -1,15 +1,15 @@
1
- var xe = Object.defineProperty;
2
- var Ee = (o, e, t) => e in o ? xe(o, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[e] = t;
3
- var P = (o, e, t) => Ee(o, typeof e != "symbol" ? e + "" : e, t);
4
- import { Inject as m, Injector as v, IAuthzIoService as we, LocaleService as ke, ICommandService as l, IPermissionService as Q, generateRandomId as Se, FBase as p, Rectangle as N, HorizontalAlign as R, VerticalAlign as b, isFormulaString as De, isCellV as Me, isICellData as je, ObjectMatrix as j, Tools as We, RANGE_TYPE as g, BooleanNumber as u, WrapStrategy as Z, Dimension as ee, ILogService as Ce, Direction as E, IResourceLoaderService as Oe, mergeWorksheetSnapshotWithDefault as Fe, UndoCommand as Ae, RedoCommand as Te, toDisposable as Ie, UniverInstanceType as U, IUniverInstanceService as fe, FUniver as ve } from "@univerjs/core";
5
- import { IDefinedNamesService as Re, serializeRange as X, FormulaDataModel as Le, serializeRangeWithSheet as Be, deserializeRangeWithSheet as ze } from "@univerjs/engine-formula";
6
- import { WorksheetProtectionRuleModel as be, RangeProtectionRuleModel as pe, WorksheetProtectionPointModel as Pe, SetDefinedNameCommand as q, SCOPE_WORKBOOK_VALUE_DEFINED_NAME as K, RemoveDefinedNameCommand as Ve, PermissionPointsDefinitions as He, WorkbookEditablePermission as ye, UnitObject as y, AddWorksheetProtectionMutation as $e, DeleteWorksheetProtectionMutation as Ge, getAllWorksheetPermissionPoint as qe, getAllWorksheetPermissionPointByPointPanel as te, SetWorksheetPermissionPointsMutation as Ke, AddRangeProtectionMutation as Ye, DeleteRangeProtectionMutation as Je, SetRangeProtectionMutation as Qe, WorksheetEditPermission as Xe, WorksheetViewPermission as Ze, SetStyleCommand as C, SetRangeValuesCommand as ne, SetTextWrapCommand as se, SetVerticalTextAlignCommand as et, SetHorizontalTextAlignCommand as tt, addMergeCellsUtil as L, getAddMergeMutationRangeByType as oe, RemoveWorksheetMergeCommand as nt, SplitTextToColumnsCommand as st, getPrimaryForRange as Y, SetSelectionsOperation as Ue, getNextPrimaryCell as ot, SheetsSelectionsService as Ne, SetWorksheetDefaultStyleMutation as rt, SetColDataCommand as re, SetRowDataCommand as ie, copyRangeStyles as D, InsertRowCommand as ae, RemoveRowCommand as it, MoveRowsCommand as at, SetRowHiddenCommand as he, SetSpecificRowsVisibleCommand as ce, SetRowHeightCommand as de, SetWorksheetRowIsAutoHeightCommand as ht, InsertColCommand as me, RemoveColCommand as ct, MoveColsCommand as dt, SetColHiddenCommand as ue, SetSpecificColsVisibleCommand as le, SetColWidthCommand as mt, SetFrozenCommand as B, CancelFrozenCommand as ut, ToggleGridlinesCommand as lt, SetGridlinesColorCommand as gt, SetTabColorCommand as _t, SetRangeValuesMutation as ge, SetWorksheetHideCommand as wt, SetWorksheetShowCommand as kt, SetWorksheetNameCommand as St, ClearSelectionAllCommand as Ct, ClearSelectionContentCommand as It, ClearSelectionFormatCommand as ft, InsertSheetCommand as z, SetWorksheetActiveOperation as V, RemoveSheetCommand as vt, CopySheetCommand as Rt, SetWorksheetOrderCommand as bt } from "@univerjs/sheets";
7
- var pt = Object.defineProperty, Pt = Object.getOwnPropertyDescriptor, yt = (o, e, t, n) => {
8
- for (var s = n > 1 ? void 0 : n ? Pt(e, t) : e, r = o.length - 1, i; r >= 0; r--)
1
+ var We = Object.defineProperty;
2
+ var Me = (o, e, t) => e in o ? We(o, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[e] = t;
3
+ var p = (o, e, t) => Me(o, typeof e != "symbol" ? e + "" : e, t);
4
+ import { Inject as m, Injector as v, IAuthzIoService as ke, LocaleService as Se, ICommandService as l, IPermissionService as J, generateRandomId as Ce, FBase as Q, Rectangle as E, HorizontalAlign as R, VerticalAlign as b, isFormulaString as Te, isCellV as je, isICellData as Ae, ObjectMatrix as M, Tools as Fe, RANGE_TYPE as _, FBaseInitialable as X, BooleanNumber as u, WrapStrategy as ee, Dimension as te, ILogService as Ie, Direction as N, IResourceLoaderService as Oe, mergeWorksheetSnapshotWithDefault as Be, UndoCommand as Le, RedoCommand as ze, toDisposable as fe, UniverInstanceType as P, IUniverInstanceService as ve, FUniver as Re, FEventName as be } from "@univerjs/core";
5
+ import { WorksheetProtectionRuleModel as pe, RangeProtectionRuleModel as ye, WorksheetProtectionPointModel as Pe, SetDefinedNameCommand as G, SCOPE_WORKBOOK_VALUE_DEFINED_NAME as q, RemoveDefinedNameCommand as Ve, PermissionPointsDefinitions as He, WorkbookEditablePermission as Ue, UnitObject as y, AddWorksheetProtectionMutation as $e, DeleteWorksheetProtectionMutation as Ge, getAllWorksheetPermissionPoint as qe, getAllWorksheetPermissionPointByPointPanel as ne, SetWorksheetPermissionPointsMutation as Ke, AddRangeProtectionMutation as Ye, DeleteRangeProtectionMutation as Je, SetRangeProtectionMutation as Qe, WorksheetEditPermission as Xe, WorksheetViewPermission as Ze, SetStyleCommand as C, SetRangeValuesCommand as se, SetTextWrapCommand as oe, SetVerticalTextAlignCommand as et, SetHorizontalTextAlignCommand as tt, addMergeCellsUtil as B, getAddMergeMutationRangeByType as re, RemoveWorksheetMergeCommand as nt, SplitTextToColumnsCommand as st, SetWorksheetRangeThemeStyleCommand as ot, DeleteWorksheetRangeThemeStyleCommand as rt, SheetRangeThemeService as Ee, getPrimaryForRange as K, SetSelectionsOperation as xe, getNextPrimaryCell as it, SheetsSelectionsService as Ne, SetWorksheetDefaultStyleMutation as at, SetColDataCommand as ie, SetRowDataCommand as ae, copyRangeStyles as D, InsertRowByRangeCommand as he, RemoveRowByRangeCommand as ht, MoveRowsCommand as ct, SetRowHiddenCommand as ce, SetSpecificRowsVisibleCommand as de, SetRowHeightCommand as me, SetWorksheetRowIsAutoHeightCommand as dt, InsertColByRangeCommand as ue, RemoveColByRangeCommand as mt, MoveColsCommand as ut, SetColHiddenCommand as le, SetSpecificColsVisibleCommand as ge, SetColWidthCommand as lt, SetFrozenCommand as L, CancelFrozenCommand as gt, ToggleGridlinesCommand as _t, SetGridlinesColorCommand as wt, SetTabColorCommand as kt, SetRangeValuesMutation as _e, SetWorksheetHideCommand as St, SetWorksheetShowCommand as Ct, SetWorksheetNameCommand as It, ClearSelectionAllCommand as ft, ClearSelectionContentCommand as vt, ClearSelectionFormatCommand as Rt, InsertSheetCommand as U, SetWorksheetActiveOperation as z, RemoveSheetCommand as bt, CopySheetCommand as pt, SetWorksheetOrderCommand as yt, RegisterWorksheetRangeThemeStyleCommand as Pt, UnregisterWorksheetRangeThemeStyleCommand as Ut } from "@univerjs/sheets";
6
+ import { IDefinedNamesService as De, serializeRange as Z, FormulaDataModel as Et, serializeRangeWithSheet as xt, deserializeRangeWithSheet as Nt } from "@univerjs/engine-formula";
7
+ var Dt = Object.defineProperty, Wt = Object.getOwnPropertyDescriptor, Mt = (o, e, t, n) => {
8
+ for (var s = n > 1 ? void 0 : n ? Wt(e, t) : e, r = o.length - 1, i; r >= 0; r--)
9
9
  (i = o[r]) && (s = (n ? i(e, t, s) : i(s)) || s);
10
- return n && s && pt(e, t, s), s;
11
- }, w = (o, e) => (t, n) => e(t, n, o);
12
- function Ut(o, e, t) {
10
+ return n && s && Dt(e, t, s), s;
11
+ }, k = (o, e) => (t, n) => e(t, n, o);
12
+ function Tt(o, e, t) {
13
13
  const n = t.getDefinedNameMap(o);
14
14
  if (n == null)
15
15
  return e.t("definedName.defaultName") + 1;
@@ -24,11 +24,11 @@ function Ut(o, e, t) {
24
24
  a++;
25
25
  }
26
26
  }
27
- class A {
27
+ class F {
28
28
  constructor() {
29
- P(this, "_definedNameParam");
29
+ p(this, "_definedNameParam");
30
30
  this._definedNameParam = {
31
- id: Se(10),
31
+ id: Ce(10),
32
32
  unitId: "",
33
33
  name: "",
34
34
  formulaOrRefString: ""
@@ -100,7 +100,7 @@ class A {
100
100
  * ```
101
101
  */
102
102
  setRefByRange(e, t, n, s) {
103
- return this._definedNameParam.formulaOrRefString = X({
103
+ return this._definedNameParam.formulaOrRefString = Z({
104
104
  startRow: e,
105
105
  endRow: e + (n != null ? n : 1) - 1,
106
106
  startColumn: t,
@@ -159,12 +159,12 @@ class A {
159
159
  return this._definedNameParam = e, this;
160
160
  }
161
161
  }
162
- let W = class extends p {
162
+ let T = class extends Q {
163
163
  constructor(o, e, t, n, s, r, i, a, h, c) {
164
164
  super(), this._definedNameParam = o, this._injector = e, this._commandService = t, this._permissionService = n, this._worksheetProtectionRuleModel = s, this._rangeProtectionRuleModel = r, this._worksheetProtectionPointRuleModel = i, this._authzIoService = a, this._localeService = h, this._definedNamesService = c;
165
165
  }
166
166
  _apply() {
167
- this._definedNameParam.name === "" && (this._definedNameParam.name = Ut(this._definedNameParam.unitId, this._localeService, this._definedNamesService)), this._commandService.syncExecuteCommand(q.id, this._definedNameParam);
167
+ this._definedNameParam.name === "" && (this._definedNameParam.name = Tt(this._definedNameParam.unitId, this._localeService, this._definedNamesService)), this._commandService.syncExecuteCommand(G.id, this._definedNameParam);
168
168
  }
169
169
  /**
170
170
  * Gets the name of the defined name.
@@ -245,7 +245,7 @@ let W = class extends p {
245
245
  * ```
246
246
  */
247
247
  setRefByRange(o, e, t, n) {
248
- this._definedNameParam.formulaOrRefString = X({
248
+ this._definedNameParam.formulaOrRefString = Z({
249
249
  startRow: o,
250
250
  endRow: o + (t != null ? t : 1) - 1,
251
251
  startColumn: e,
@@ -302,7 +302,7 @@ let W = class extends p {
302
302
  * ```
303
303
  */
304
304
  setScopeToWorkbook() {
305
- this._definedNameParam.localSheetId = K, this._apply();
305
+ this._definedNameParam.localSheetId = q, this._apply();
306
306
  }
307
307
  /**
308
308
  * Sets the hidden status of the defined name.
@@ -353,7 +353,7 @@ let W = class extends p {
353
353
  * ```
354
354
  */
355
355
  isWorkbookScope() {
356
- return this._definedNameParam.localSheetId === K;
356
+ return this._definedNameParam.localSheetId === q;
357
357
  }
358
358
  /**
359
359
  * Converts the defined name to a defined name builder.
@@ -368,30 +368,30 @@ let W = class extends p {
368
368
  * ```
369
369
  */
370
370
  toBuilder() {
371
- const o = this._injector.createInstance(A);
371
+ const o = this._injector.createInstance(F);
372
372
  return o.load(this._definedNameParam), o;
373
373
  }
374
374
  };
375
- W = yt([
376
- w(1, m(v)),
377
- w(2, l),
378
- w(3, Q),
379
- w(4, m(be)),
380
- w(5, m(pe)),
381
- w(6, m(Pe)),
382
- w(7, m(we)),
383
- w(8, m(ke)),
384
- w(9, Re)
385
- ], W);
386
- var Nt = Object.defineProperty, xt = Object.getOwnPropertyDescriptor, Et = (o, e, t, n) => {
387
- for (var s = n > 1 ? void 0 : n ? xt(e, t) : e, r = o.length - 1, i; r >= 0; r--)
375
+ T = Mt([
376
+ k(1, m(v)),
377
+ k(2, l),
378
+ k(3, J),
379
+ k(4, m(pe)),
380
+ k(5, m(ye)),
381
+ k(6, m(Pe)),
382
+ k(7, m(ke)),
383
+ k(8, m(Se)),
384
+ k(9, De)
385
+ ], T);
386
+ var jt = Object.defineProperty, At = Object.getOwnPropertyDescriptor, Ft = (o, e, t, n) => {
387
+ for (var s = n > 1 ? void 0 : n ? At(e, t) : e, r = o.length - 1, i; r >= 0; r--)
388
388
  (i = o[r]) && (s = (n ? i(e, t, s) : i(s)) || s);
389
- return n && s && Nt(e, t, s), s;
389
+ return n && s && jt(e, t, s), s;
390
390
  }, f = (o, e) => (t, n) => e(t, n, o);
391
- let O = class extends p {
391
+ let j = class extends Q {
392
392
  constructor(e, t, n, s, r, i, a) {
393
393
  super();
394
- P(this, "permissionPointsDefinition", He);
394
+ p(this, "permissionPointsDefinition", He);
395
395
  this._injector = e, this._commandService = t, this._permissionService = n, this._worksheetProtectionRuleModel = s, this._rangeProtectionRuleModel = r, this._worksheetProtectionPointRuleModel = i, this._authzIoService = a;
396
396
  }
397
397
  /**
@@ -417,7 +417,7 @@ let O = class extends p {
417
417
  *
418
418
  */
419
419
  setWorkbookEditPermission(e, t) {
420
- this.setWorkbookPermissionPoint(e, ye, t);
420
+ this.setWorkbookPermissionPoint(e, Ue, t);
421
421
  }
422
422
  /**
423
423
  * This function is used to add a base permission for a worksheet.
@@ -462,7 +462,7 @@ let O = class extends p {
462
462
  this._commandService.syncExecuteCommand(Ge.id, {
463
463
  unitId: e,
464
464
  subUnitId: t
465
- }), [...qe(), ...te()].forEach((n) => {
465
+ }), [...qe(), ...ne()].forEach((n) => {
466
466
  const s = new n(e, t);
467
467
  this._permissionService.updatePermissionPoint(s.id, !0);
468
468
  }), this._worksheetProtectionPointRuleModel.deleteRule(e, t);
@@ -524,10 +524,10 @@ let O = class extends p {
524
524
  name: "",
525
525
  scope: void 0
526
526
  }
527
- }), r = `ruleId_${Se(6)}`;
527
+ }), r = `ruleId_${Ce(6)}`;
528
528
  if (this._worksheetProtectionRuleModel.getRule(e, t))
529
529
  throw new Error("sheet protection cannot intersect with range protection");
530
- if (this._rangeProtectionRuleModel.getSubunitRuleList(e, t).some((d) => d.ranges.some((T) => n.some((x) => N.intersects(x, T)))))
530
+ if (this._rangeProtectionRuleModel.getSubunitRuleList(e, t).some((d) => d.ranges.some((O) => n.some((x) => E.intersects(x, O)))))
531
531
  throw new Error("range protection cannot intersect");
532
532
  if (this._commandService.syncExecuteCommand(Ye.id, {
533
533
  unitId: e,
@@ -558,7 +558,7 @@ let O = class extends p {
558
558
  unitId: e,
559
559
  subUnitId: t,
560
560
  ruleIds: n
561
- }) && this._rangeProtectionRuleModel.getSubunitRuleList(e, t).length === 0 && (this._worksheetProtectionPointRuleModel.deleteRule(e, t), [...te()].forEach((i) => {
561
+ }) && this._rangeProtectionRuleModel.getSubunitRuleList(e, t).length === 0 && (this._worksheetProtectionPointRuleModel.deleteRule(e, t), [...ne()].forEach((i) => {
562
562
  const a = new i(e, t);
563
563
  this._permissionService.updatePermissionPoint(a.id, a.value);
564
564
  }));
@@ -592,7 +592,7 @@ let O = class extends p {
592
592
  setRangeProtectionRanges(e, t, n, s) {
593
593
  const r = this._rangeProtectionRuleModel.getRule(e, t, n);
594
594
  if (r) {
595
- if (this._rangeProtectionRuleModel.getSubunitRuleList(e, t).filter((h) => h.id !== n).some((h) => h.ranges.some((c) => s.some((d) => N.intersects(d, c)))))
595
+ if (this._rangeProtectionRuleModel.getSubunitRuleList(e, t).filter((h) => h.id !== n).some((h) => h.ranges.some((c) => s.some((d) => E.intersects(d, c)))))
596
596
  throw new Error("range protection cannot intersect");
597
597
  this._commandService.syncExecuteCommand(Qe.id, {
598
598
  unitId: e,
@@ -605,25 +605,17 @@ let O = class extends p {
605
605
  });
606
606
  }
607
607
  }
608
- /**
609
- * Set visibility of unauthorized pop-up window
610
- *
611
- * @param {boolean} visible
612
- */
613
- setPermissionDialogVisible(e) {
614
- this._permissionService.setShowComponents(e);
615
- }
616
608
  };
617
- O = Et([
609
+ j = Ft([
618
610
  f(0, m(v)),
619
611
  f(1, l),
620
- f(2, Q),
621
- f(3, m(be)),
622
- f(4, m(pe)),
612
+ f(2, J),
613
+ f(3, m(pe)),
614
+ f(4, m(ye)),
623
615
  f(5, m(Pe)),
624
- f(6, m(we))
625
- ], O);
626
- function Dt(o) {
616
+ f(6, m(ke))
617
+ ], j);
618
+ function Ot(o) {
627
619
  switch (o) {
628
620
  case "left":
629
621
  return R.LEFT;
@@ -635,7 +627,7 @@ function Dt(o) {
635
627
  throw new Error(`Invalid horizontal alignment: ${o}`);
636
628
  }
637
629
  }
638
- function Mt(o) {
630
+ function Bt(o) {
639
631
  switch (o) {
640
632
  case R.LEFT:
641
633
  return "left";
@@ -647,7 +639,7 @@ function Mt(o) {
647
639
  throw new Error(`Invalid horizontal alignment: ${o}`);
648
640
  }
649
641
  }
650
- function jt(o) {
642
+ function Lt(o) {
651
643
  switch (o) {
652
644
  case "top":
653
645
  return b.TOP;
@@ -659,7 +651,7 @@ function jt(o) {
659
651
  throw new Error(`Invalid vertical alignment: ${o}`);
660
652
  }
661
653
  }
662
- function Wt(o) {
654
+ function zt(o) {
663
655
  switch (o) {
664
656
  case b.TOP:
665
657
  return "top";
@@ -671,51 +663,51 @@ function Wt(o) {
671
663
  throw new Error(`Invalid vertical alignment: ${o}`);
672
664
  }
673
665
  }
674
- function J(o) {
675
- return De(o) ? {
666
+ function Y(o) {
667
+ return Te(o) ? {
676
668
  f: o
677
- } : Me(o) ? {
669
+ } : je(o) ? {
678
670
  v: o
679
- } : (je(o), o);
671
+ } : (Ae(o), o);
680
672
  }
681
- function Ot(o, e) {
682
- const t = new j(), { startRow: n, startColumn: s, endRow: r, endColumn: i } = e;
683
- if (We.isArray(o))
673
+ function Vt(o, e) {
674
+ const t = new M(), { startRow: n, startColumn: s, endRow: r, endColumn: i } = e;
675
+ if (Fe.isArray(o))
684
676
  for (let a = 0; a <= r - n; a++)
685
677
  for (let h = 0; h <= i - s; h++)
686
- t.setValue(a + n, h + s, J(o[a][h]));
678
+ t.setValue(a + n, h + s, Y(o[a][h]));
687
679
  else
688
- new j(o).forValue((h, c, d) => {
689
- t.setValue(h, c, J(d));
680
+ new M(o).forValue((h, c, d) => {
681
+ t.setValue(h, c, Y(d));
690
682
  });
691
683
  return t.getMatrix();
692
684
  }
693
- function H(o, e) {
685
+ function V(o, e) {
694
686
  return {
695
687
  startRow: o.startRow,
696
688
  endRow: o.endRow,
697
689
  startColumn: 0,
698
690
  endColumn: e.getColumnCount() - 1,
699
- rangeType: g.ROW
691
+ rangeType: _.ROW
700
692
  };
701
693
  }
702
- function $(o, e) {
694
+ function H(o, e) {
703
695
  return {
704
696
  startRow: 0,
705
697
  endRow: e.getRowCount() - 1,
706
698
  startColumn: o.startColumn,
707
699
  endColumn: o.endColumn,
708
- rangeType: g.COLUMN
700
+ rangeType: _.COLUMN
709
701
  };
710
702
  }
711
- var Ft = Object.defineProperty, At = Object.getOwnPropertyDescriptor, Tt = (o, e, t, n) => {
712
- for (var s = n > 1 ? void 0 : n ? At(e, t) : e, r = o.length - 1, i; r >= 0; r--)
703
+ var Ht = Object.defineProperty, $t = Object.getOwnPropertyDescriptor, Gt = (o, e, t, n) => {
704
+ for (var s = n > 1 ? void 0 : n ? $t(e, t) : e, r = o.length - 1, i; r >= 0; r--)
713
705
  (i = o[r]) && (s = (n ? i(e, t, s) : i(s)) || s);
714
- return n && s && Ft(e, t, s), s;
715
- }, G = (o, e) => (t, n) => e(t, n, o);
716
- let S = class extends p {
706
+ return n && s && Ht(e, t, s), s;
707
+ }, $ = (o, e) => (t, n) => e(t, n, o);
708
+ let w = class extends X {
717
709
  constructor(o, e, t, n, s, r) {
718
- super(), this._workbook = o, this._worksheet = e, this._range = t, this._injector = n, this._commandService = s, this._formulaDataModel = r;
710
+ super(n), this._workbook = o, this._worksheet = e, this._range = t, this._injector = n, this._commandService = s, this._formulaDataModel = r;
719
711
  }
720
712
  /**
721
713
  * Get the unit ID of the current workbook
@@ -787,7 +779,7 @@ let S = class extends p {
787
779
  */
788
780
  isMerged() {
789
781
  const { startColumn: o, startRow: e, endColumn: t, endRow: n } = this._range;
790
- return this._worksheet.getMergedCellRange(e, o, n, t).some((r) => N.equals(r, this._range));
782
+ return this._worksheet.getMergedCellRange(e, o, n, t).some((r) => E.equals(r, this._range));
791
783
  }
792
784
  /**
793
785
  * Return first cell style data in this range
@@ -859,22 +851,22 @@ let S = class extends p {
859
851
  return this._worksheet.getRange(this._range).getWrapStrategy();
860
852
  }
861
853
  getHorizontalAlignment() {
862
- return Mt(this._worksheet.getRange(this._range).getHorizontalAlignment());
854
+ return Bt(this._worksheet.getRange(this._range).getHorizontalAlignment());
863
855
  }
864
856
  getVerticalAlignment() {
865
- return Wt(this._worksheet.getRange(this._range).getVerticalAlignment());
857
+ return zt(this._worksheet.getRange(this._range).getVerticalAlignment());
866
858
  }
867
859
  // #region editing
868
860
  /**
869
861
  * Set background color for current range.
862
+ * @param color {string}
870
863
  * @example
871
864
  * ```
872
865
  * univerAPI.getActiveWorkbook().getActiveSheet().getActiveRange().setBackgroundColor('red')
873
866
  * ```
874
- * @param color {string}
875
867
  */
876
868
  setBackgroundColor(o) {
877
- return this._commandService.executeCommand(C.id, {
869
+ return this._commandService.syncExecuteCommand(C.id, {
878
870
  unitId: this._workbook.getUnitId(),
879
871
  subUnitId: this._worksheet.getSheetId(),
880
872
  range: this._range,
@@ -884,88 +876,91 @@ let S = class extends p {
884
876
  rgb: o
885
877
  }
886
878
  }
887
- });
879
+ }), this;
888
880
  }
889
881
  /**
890
882
  * Set background color for current range.
891
- * e.g. `univerAPI.getActiveWorkbook().getActiveSheet().getActiveRange().setBackground('red')`
883
+ * @example
884
+ * ```
885
+ * univerAPI.getActiveWorkbook().getActiveSheet().getActiveRange().setBackground('red')
886
+ * ```
892
887
  * @param color {string}
893
888
  */
894
889
  setBackground(o) {
895
- return this.setBackgroundColor(o);
890
+ return this.setBackgroundColor(o), this;
896
891
  }
897
892
  /**
898
893
  * The value can be a number, string, boolean, or standard cell format. If it begins with `=`, it is interpreted as a formula. The value is tiled to all cells in the range.
899
894
  * @param value
900
895
  */
901
896
  setValue(o) {
902
- const e = J(o);
897
+ const e = Y(o);
903
898
  if (!e)
904
899
  throw new Error("Invalid value");
905
- return this._commandService.executeCommand(ne.id, {
900
+ return this._commandService.syncExecuteCommand(se.id, {
906
901
  unitId: this._workbook.getUnitId(),
907
902
  subUnitId: this._worksheet.getSheetId(),
908
903
  range: this._range,
909
904
  value: e
910
- });
905
+ }), this;
911
906
  }
912
907
  /**
913
908
  * Set the cell wrap of the given range.
914
909
  * Cells with wrap enabled (the default) resize to display their full content. Cells with wrap disabled display as much as possible in the cell without resizing or running to multiple lines.
915
910
  */
916
911
  setWrap(o) {
917
- return this._commandService.executeCommand(se.id, {
912
+ return this._commandService.syncExecuteCommand(oe.id, {
918
913
  unitId: this._workbook.getUnitId(),
919
914
  subUnitId: this._worksheet.getSheetId(),
920
915
  range: this._range,
921
- value: o ? Z.WRAP : Z.UNSPECIFIED
922
- });
916
+ value: o ? ee.WRAP : ee.UNSPECIFIED
917
+ }), this;
923
918
  }
924
919
  /**
925
920
  * Sets the text wrapping strategy for the cells in the range.
926
921
  */
927
922
  setWrapStrategy(o) {
928
- return this._commandService.executeCommand(se.id, {
923
+ return this._commandService.syncExecuteCommand(oe.id, {
929
924
  unitId: this._workbook.getUnitId(),
930
925
  subUnitId: this._worksheet.getSheetId(),
931
926
  range: this._range,
932
927
  value: o
933
- });
928
+ }), this;
934
929
  }
935
930
  /**
936
931
  * Set the vertical (top to bottom) alignment for the given range (top/middle/bottom).
937
932
  */
938
933
  setVerticalAlignment(o) {
939
- return this._commandService.executeCommand(et.id, {
934
+ return this._commandService.syncExecuteCommand(et.id, {
940
935
  unitId: this._workbook.getUnitId(),
941
936
  subUnitId: this._worksheet.getSheetId(),
942
937
  range: this._range,
943
- value: jt(o)
944
- });
938
+ value: Lt(o)
939
+ }), this;
945
940
  }
946
941
  /**
947
942
  * Set the horizontal (left to right) alignment for the given range (left/center/right).
948
943
  */
949
944
  setHorizontalAlignment(o) {
950
- return this._commandService.executeCommand(tt.id, {
945
+ return this._commandService.syncExecuteCommand(tt.id, {
951
946
  unitId: this._workbook.getUnitId(),
952
947
  subUnitId: this._worksheet.getSheetId(),
953
948
  range: this._range,
954
- value: Dt(o)
955
- });
949
+ value: Ot(o)
950
+ }), this;
956
951
  }
957
952
  /**
958
953
  * Sets a different value for each cell in the range. The value can be a two-dimensional array or a standard range matrix (must match the dimensions of this range), consisting of numbers, strings, Boolean values or Composed of standard cell formats. If a value begins with `=`, it is interpreted as a formula.
959
954
  * @param value
960
955
  */
961
956
  setValues(o) {
962
- const e = Ot(o, this._range);
963
- return this._commandService.executeCommand(ne.id, {
957
+ const e = Vt(o, this._range);
958
+ return this._commandService.syncExecuteCommand(se.id, {
964
959
  unitId: this._workbook.getUnitId(),
965
960
  subUnitId: this._worksheet.getSheetId(),
966
961
  range: this._range,
967
962
  value: e
968
- });
963
+ }), this;
969
964
  }
970
965
  /**
971
966
  * Sets the font weight for the given range (normal/bold),
@@ -1124,40 +1119,71 @@ let S = class extends p {
1124
1119
  //#region Merge cell
1125
1120
  /**
1126
1121
  * Merge cells in a range into one merged cell
1127
- *
1128
1122
  * @param [defaultMerge] - If true, only the value in the upper left cell is retained.
1129
- *
1130
1123
  * @returns This range, for chaining
1124
+ * @example
1125
+ * ```ts
1126
+ * const workbook = univerAPI.getActiveWorkbook();
1127
+ * const worksheet = workbook.getActiveSheet();
1128
+ * const range = worksheet.getRange(0, 0, 2, 2);
1129
+ * const merge = range.merge();
1130
+ * const isMerged = merge.isMerged();
1131
+ * console.log('debugger', isMerged);
1132
+ * ```
1131
1133
  */
1132
- async merge(o = !0) {
1134
+ merge(o = !0) {
1133
1135
  const e = this._workbook.getUnitId(), t = this._worksheet.getSheetId();
1134
- return await L(this._injector, e, t, [this._range], o), this;
1136
+ return B(this._injector, e, t, [this._range], o), this;
1135
1137
  }
1136
1138
  /**
1137
1139
  * Merges cells in a range horizontally.
1138
- *
1139
1140
  * @param [defaultMerge] - If true, only the value in the upper left cell is retained.
1140
- *
1141
1141
  * @returns This range, for chaining
1142
+ * @example
1143
+ * ```ts
1144
+ * const workbook = univerAPI.getActiveWorkbook();
1145
+ * const worksheet = workbook.getActiveSheet();
1146
+ * const range = worksheet.getRange(2, 2, 2, 2);
1147
+ * const merge = range.mergeAcross();
1148
+ * const allMerge = worksheet.getMergeData();
1149
+ * console.log(allMerge.length); // There will be two merged cells.
1150
+ * ```
1142
1151
  */
1143
- async mergeAcross(o = !0) {
1144
- const e = oe([this._range], ee.ROWS), t = this._workbook.getUnitId(), n = this._worksheet.getSheetId();
1145
- return await L(this._injector, t, n, e, o), this;
1152
+ mergeAcross(o = !0) {
1153
+ const e = re([this._range], te.ROWS), t = this._workbook.getUnitId(), n = this._worksheet.getSheetId();
1154
+ return B(this._injector, t, n, e, o), this;
1146
1155
  }
1147
1156
  /**
1148
1157
  * Merges cells in a range vertically.
1149
- *
1150
1158
  * @param [defaultMerge] - If true, only the value in the upper left cell is retained.
1151
- *
1152
1159
  * @returns This range, for chaining
1160
+ * @example
1161
+ * ```ts
1162
+ * const workbook = univerAPI.getActiveWorkbook();
1163
+ * const worksheet = workbook.getActiveSheet();
1164
+ * const range = worksheet.getRange(4, 4, 2, 2);
1165
+ * const merge = range.mergeVertically();
1166
+ * const allMerge = worksheet.getMergeData();
1167
+ * console.log(allMerge.length); // There will be two merged cells.
1168
+ * ```
1153
1169
  */
1154
- async mergeVertically(o = !0) {
1155
- const e = oe([this._range], ee.COLUMNS), t = this._workbook.getUnitId(), n = this._worksheet.getSheetId();
1156
- return await L(this._injector, t, n, e, o), this;
1170
+ mergeVertically(o = !0) {
1171
+ const e = re([this._range], te.COLUMNS), t = this._workbook.getUnitId(), n = this._worksheet.getSheetId();
1172
+ return B(this._injector, t, n, e, o), this;
1157
1173
  }
1158
1174
  /**
1159
1175
  * Returns true if cells in the current range overlap a merged cell.
1160
1176
  * @returns {boolean} is overlap with a merged cell
1177
+ * @example
1178
+ * ```ts
1179
+ * const workbook = univerAPI.getActiveWorkbook();
1180
+ * const worksheet = workbook.getActiveSheet();
1181
+ * const range = worksheet.getRange(0,0,2,2);
1182
+ * const merge = range.merge();
1183
+ * const anchor = worksheet.getRange(0,0);
1184
+ * const isPartOfMerge = anchor.isPartOfMerge();
1185
+ * console.log('debugger, isPartOfMerge) // true
1186
+ * ```
1161
1187
  */
1162
1188
  isPartOfMerge() {
1163
1189
  const { startRow: o, startColumn: e, endRow: t, endColumn: n } = this._range;
@@ -1166,6 +1192,19 @@ let S = class extends p {
1166
1192
  /**
1167
1193
  * Break all horizontally- or vertically-merged cells contained within the range list into individual cells again.
1168
1194
  * @returns This range, for chaining
1195
+ * @example
1196
+ * ```ts
1197
+ * const workbook = univerAPI.getActiveWorkbook();
1198
+ * const worksheet = workbook.getActiveSheet();
1199
+ * const range = worksheet.getRange(0,0,2,2);
1200
+ * const merge = range.merge();
1201
+ * const anchor = worksheet.getRange(0,0);
1202
+ * const isPartOfMergeFirst = anchor.isPartOfMerge();
1203
+ * console.log('debugger' isPartOfMergeFirst) // true
1204
+ * range.breakApart();
1205
+ * const isPartOfMergeSecond = anchor.isPartOfMerge();
1206
+ * console.log('debugger' isPartOfMergeSecond) // false
1207
+ * ```
1169
1208
  */
1170
1209
  breakApart() {
1171
1210
  return this._commandService.executeCommand(nt.id, { ranges: [this._range] }), this;
@@ -1203,7 +1242,7 @@ let S = class extends p {
1203
1242
  * ```
1204
1243
  */
1205
1244
  getA1Notation(o) {
1206
- return o ? Be(this._worksheet.getName(), this._range) : X(this._range);
1245
+ return o ? xt(this._worksheet.getName(), this._range) : Z(this._range);
1207
1246
  }
1208
1247
  /**
1209
1248
  * Sets the specified range as the active range, with the top left cell in the range as the current cell.
@@ -1228,7 +1267,7 @@ let S = class extends p {
1228
1267
  */
1229
1268
  activateAsCurrentCell() {
1230
1269
  const o = this._worksheet.getMergedCell(this._range.startRow, this._range.startColumn);
1231
- if (o && N.equals(o, this._range) || !o && this._range.startRow === this._range.endRow && this._range.startColumn === this._range.endColumn)
1270
+ if (o && E.equals(o, this._range) || !o && this._range.startRow === this._range.endRow && this._range.startColumn === this._range.endColumn)
1232
1271
  return this.activate();
1233
1272
  throw new Error("The range is not a single cell");
1234
1273
  }
@@ -1274,18 +1313,80 @@ let S = class extends p {
1274
1313
  treatMultipleDelimitersAsOne: o
1275
1314
  });
1276
1315
  }
1316
+ /**
1317
+ * Set the theme style for the range.
1318
+ * @param {string|undefined} themeName The name of the theme style to apply.If a undefined value is passed, the theme style will be removed if it exist.
1319
+ * @example
1320
+ * ```ts
1321
+ * const fWorkbook = univerAPI.getActiveWorkbook();
1322
+ * const fWorksheet = fWorkbook.getActiveSheet();
1323
+ * const fRange = fWorksheet.getRange('A1:E20');
1324
+ * fRange.useThemeStyle('default');
1325
+ * ```
1326
+ */
1327
+ useThemeStyle(o) {
1328
+ if (o == null) {
1329
+ const e = this.getUsedThemeStyle();
1330
+ e && this.removeThemeStyle(e);
1331
+ } else
1332
+ this._commandService.executeCommand(ot.id, {
1333
+ unitId: this._workbook.getUnitId(),
1334
+ subUnitId: this._worksheet.getSheetId(),
1335
+ range: this._range,
1336
+ themeName: o
1337
+ });
1338
+ }
1339
+ /**
1340
+ * Remove the theme style for the range.
1341
+ * @param {string} themeName The name of the theme style to remove.
1342
+ * @example
1343
+ * ```ts
1344
+ * const fWorkbook = univerAPI.getActiveWorkbook();
1345
+ * const fWorksheet = fWorkbook.getActiveSheet();
1346
+ * const fRange = fWorksheet.getRange('A1:E20');
1347
+ * fRange.removeThemeStyle('default');
1348
+ * ```
1349
+ */
1350
+ removeThemeStyle(o) {
1351
+ this._commandService.executeCommand(rt.id, {
1352
+ unitId: this._workbook.getUnitId(),
1353
+ subUnitId: this._worksheet.getSheetId(),
1354
+ range: this._range,
1355
+ themeName: o
1356
+ });
1357
+ }
1358
+ /**
1359
+ * Gets the theme style applied to the range.
1360
+ * @returns {string | undefined} The name of the theme style applied to the range or not exist.
1361
+ * @example
1362
+ * ```ts
1363
+ * const fWorkbook = univerAPI.getActiveWorkbook();
1364
+ * const fWorksheet = fWorkbook.getActiveSheet();
1365
+ * const fRange = fWorksheet.getRange('A1:E20');
1366
+ * fRange.useThemeStyle('default');
1367
+ * const themeStyle = fRange.getUsedThemeStyle();
1368
+ * console.log(themeStyle); // 'default'
1369
+ * ```
1370
+ */
1371
+ getUsedThemeStyle() {
1372
+ return this._injector.get(Ee).getAppliedRangeThemeStyle({
1373
+ unitId: this._workbook.getUnitId(),
1374
+ subUnitId: this._worksheet.getSheetId(),
1375
+ range: this._range
1376
+ });
1377
+ }
1277
1378
  };
1278
- S = Tt([
1279
- G(3, m(v)),
1280
- G(4, l),
1281
- G(5, m(Le))
1282
- ], S);
1283
- var Lt = Object.defineProperty, Bt = Object.getOwnPropertyDescriptor, zt = (o, e, t, n) => {
1284
- for (var s = n > 1 ? void 0 : n ? Bt(e, t) : e, r = o.length - 1, i; r >= 0; r--)
1379
+ w = Gt([
1380
+ $(3, m(v)),
1381
+ $(4, l),
1382
+ $(5, m(Et))
1383
+ ], w);
1384
+ var qt = Object.defineProperty, Kt = Object.getOwnPropertyDescriptor, Yt = (o, e, t, n) => {
1385
+ for (var s = n > 1 ? void 0 : n ? Kt(e, t) : e, r = o.length - 1, i; r >= 0; r--)
1285
1386
  (i = o[r]) && (s = (n ? i(e, t, s) : i(s)) || s);
1286
- return n && s && Lt(e, t, s), s;
1287
- }, Vt = (o, e) => (t, n) => e(t, n, o);
1288
- let F = class {
1387
+ return n && s && qt(e, t, s), s;
1388
+ }, Jt = (o, e) => (t, n) => e(t, n, o);
1389
+ let A = class {
1289
1390
  constructor(o, e, t, n) {
1290
1391
  this._workbook = o, this._worksheet = e, this._selections = t, this._injector = n;
1291
1392
  }
@@ -1295,14 +1396,14 @@ let F = class {
1295
1396
  */
1296
1397
  getActiveRange() {
1297
1398
  const o = this._selections.find((e) => !!e.primary);
1298
- return o ? this._injector.createInstance(S, this._workbook, this._worksheet, o.range) : null;
1399
+ return o ? this._injector.createInstance(w, this._workbook, this._worksheet, o.range) : null;
1299
1400
  }
1300
1401
  /**
1301
1402
  * Represents the active selection list in the sheet.
1302
1403
  * @returns {FRange[]} The active selection list.
1303
1404
  */
1304
1405
  getActiveRangeList() {
1305
- return this._selections.map((o) => this._injector.createInstance(S, this._workbook, this._worksheet, o.range));
1406
+ return this._selections.map((o) => this._injector.createInstance(w, this._workbook, this._worksheet, o.range));
1306
1407
  }
1307
1408
  /**
1308
1409
  * Represents the current select cell in the sheet.
@@ -1326,7 +1427,7 @@ let F = class {
1326
1427
  */
1327
1428
  getActiveSheet() {
1328
1429
  const o = this._injector.createInstance(I, this._workbook);
1329
- return this._injector.createInstance(_, o, this._workbook, this._worksheet);
1430
+ return this._injector.createInstance(g, o, this._workbook, this._worksheet);
1330
1431
  }
1331
1432
  /**
1332
1433
  * Update the primary cell in the selection. if the primary cell not exists in selections, add it to the selections and clear the old selections.
@@ -1342,13 +1443,13 @@ let F = class {
1342
1443
  * console.log(newSelection.getActiveRange().getA1Notation()); // A1
1343
1444
  * ```
1344
1445
  */
1345
- async updatePrimaryCell(o) {
1446
+ updatePrimaryCell(o) {
1346
1447
  const e = this._injector.get(l);
1347
1448
  let t = [], n = !1;
1348
1449
  for (const { range: r, style: i } of this._selections)
1349
- N.contains(r, o.getRange()) ? (t.push({
1450
+ E.contains(r, o.getRange()) ? (t.push({
1350
1451
  range: r,
1351
- primary: Y(o.getRange(), this._worksheet),
1452
+ primary: K(o.getRange(), this._worksheet),
1352
1453
  style: i
1353
1454
  }), n = !0) : t.push({
1354
1455
  range: r,
@@ -1358,7 +1459,7 @@ let F = class {
1358
1459
  n || (t = [
1359
1460
  {
1360
1461
  range: o.getRange(),
1361
- primary: Y(o.getRange(), this._worksheet)
1462
+ primary: K(o.getRange(), this._worksheet)
1362
1463
  }
1363
1464
  ]);
1364
1465
  const s = {
@@ -1366,7 +1467,7 @@ let F = class {
1366
1467
  subUnitId: this._worksheet.getSheetId(),
1367
1468
  selections: t
1368
1469
  };
1369
- return await e.syncExecuteCommand(Ue.id, s), new F(this._workbook, this._worksheet, t, this._injector);
1470
+ return e.syncExecuteCommand(xe.id, s), new A(this._workbook, this._worksheet, t, this._injector);
1370
1471
  }
1371
1472
  /**
1372
1473
  *Get the next primary cell in the specified direction. If the primary cell not exists in selections, return null.
@@ -1386,26 +1487,26 @@ let F = class {
1386
1487
  getNextDataRange(o) {
1387
1488
  if (!this._selections.find((n) => !!n.primary))
1388
1489
  return null;
1389
- const t = ot(this._selections.concat(), o, this._worksheet);
1390
- return t ? this._injector.createInstance(S, this._workbook, this._worksheet, t) : null;
1490
+ const t = it(this._selections.concat(), o, this._worksheet);
1491
+ return t ? this._injector.createInstance(w, this._workbook, this._worksheet, t) : null;
1391
1492
  }
1392
1493
  };
1393
- F = zt([
1394
- Vt(3, m(v))
1395
- ], F);
1396
- var Ht = Object.defineProperty, $t = Object.getOwnPropertyDescriptor, Gt = (o, e, t, n) => {
1397
- for (var s = n > 1 ? void 0 : n ? $t(e, t) : e, r = o.length - 1, i; r >= 0; r--)
1494
+ A = Yt([
1495
+ Jt(3, m(v))
1496
+ ], A);
1497
+ var Qt = Object.defineProperty, Xt = Object.getOwnPropertyDescriptor, Zt = (o, e, t, n) => {
1498
+ for (var s = n > 1 ? void 0 : n ? Xt(e, t) : e, r = o.length - 1, i; r >= 0; r--)
1398
1499
  (i = o[r]) && (s = (n ? i(e, t, s) : i(s)) || s);
1399
- return n && s && Ht(e, t, s), s;
1400
- }, M = (o, e) => (t, n) => e(t, n, o);
1401
- let _ = class extends p {
1500
+ return n && s && Qt(e, t, s), s;
1501
+ }, W = (o, e) => (t, n) => e(t, n, o);
1502
+ let g = class extends X {
1402
1503
  constructor(e, t, n, s, r, i, a) {
1403
- super();
1504
+ super(s);
1404
1505
  /**
1405
1506
  * Sets the active selection region for this sheet.
1406
1507
  * @param range The range to set as the active selection.
1407
1508
  */
1408
- P(this, "setActiveSelection", this.setActiveRange);
1509
+ p(this, "setActiveSelection", this.setActiveRange);
1409
1510
  this._fWorkbook = e, this._workbook = t, this._worksheet = n, this._injector = s, this._selectionManagerService = r, this._logService = i, this._commandService = a;
1410
1511
  }
1411
1512
  /**
@@ -1442,7 +1543,7 @@ let _ = class extends p {
1442
1543
  */
1443
1544
  getSelection() {
1444
1545
  const e = this._selectionManagerService.getCurrentSelections();
1445
- return e ? this._injector.createInstance(F, this._workbook, this._worksheet, e) : null;
1546
+ return e ? this._injector.createInstance(A, this._workbook, this._worksheet, e) : null;
1446
1547
  }
1447
1548
  // #region rows
1448
1549
  // #region default style
@@ -1474,11 +1575,11 @@ let _ = class extends p {
1474
1575
  /**
1475
1576
  * Set the default style of the worksheet
1476
1577
  * @param {StyleDataInfo} style default style
1477
- * @returns {Promise<FWorksheet>} This sheet, for chaining.
1578
+ * @returns {FWorksheet} This sheet, for chaining.
1478
1579
  */
1479
- async setDefaultStyle(e) {
1580
+ setDefaultStyle(e) {
1480
1581
  const t = this._workbook.getUnitId(), n = this._worksheet.getSheetId();
1481
- return await this._commandService.executeCommand(rt.id, {
1582
+ return this._commandService.syncExecuteCommand(at.id, {
1482
1583
  unitId: t,
1483
1584
  subUnitId: n,
1484
1585
  defaultStyle: e
@@ -1488,9 +1589,9 @@ let _ = class extends p {
1488
1589
  * Set the default style of the worksheet row
1489
1590
  * @param {number} index The row index
1490
1591
  * @param {string | Nullable<IStyleData>} style The style name or style data
1491
- * @returns {Promise<FWorksheet>} This sheet, for chaining.
1592
+ * @returns {FWorksheet} This sheet, for chaining.
1492
1593
  */
1493
- async setColumnDefaultStyle(e, t) {
1594
+ setColumnDefaultStyle(e, t) {
1494
1595
  const n = this._workbook.getUnitId(), s = this._worksheet.getSheetId(), r = {
1495
1596
  unitId: n,
1496
1597
  subUnitId: s,
@@ -1500,15 +1601,15 @@ let _ = class extends p {
1500
1601
  }
1501
1602
  }
1502
1603
  };
1503
- return await this._commandService.executeCommand(re.id, r), this;
1604
+ return this._commandService.syncExecuteCommand(ie.id, r), this;
1504
1605
  }
1505
1606
  /**
1506
1607
  * Set the default style of the worksheet column
1507
1608
  * @param {number} index The column index
1508
1609
  * @param {string | Nullable<IStyleData>} style The style name or style data
1509
- * @returns {Promise<FWorksheet>} This sheet, for chaining.
1610
+ * @returns {FWorksheet} This sheet, for chaining.
1510
1611
  */
1511
- async setRowDefaultStyle(e, t) {
1612
+ setRowDefaultStyle(e, t) {
1512
1613
  const n = this._workbook.getUnitId(), s = this._worksheet.getSheetId(), r = {
1513
1614
  unitId: n,
1514
1615
  subUnitId: s,
@@ -1518,12 +1619,12 @@ let _ = class extends p {
1518
1619
  }
1519
1620
  }
1520
1621
  };
1521
- return await this._commandService.executeCommand(ie.id, r), this;
1622
+ return this._commandService.syncExecuteCommand(ae.id, r), this;
1522
1623
  }
1523
1624
  getRange(e, t, n, s) {
1524
1625
  let r, i;
1525
1626
  if (typeof e == "string") {
1526
- const { range: a, sheetName: h } = ze(e), c = h ? this._workbook.getSheetBySheetName(h) : this._worksheet;
1627
+ const { range: a, sheetName: h } = Nt(e), c = h ? this._workbook.getSheetBySheetName(h) : this._worksheet;
1527
1628
  if (!c)
1528
1629
  throw new Error("Range not found");
1529
1630
  i = c, r = {
@@ -1532,11 +1633,11 @@ let _ = class extends p {
1532
1633
  sheetId: i.getSheetId(),
1533
1634
  // Use the current range instead of the future actual range to match Apps Script behavior.
1534
1635
  // Users can create the latest range in real time when needed.
1535
- rangeType: g.NORMAL,
1536
- startRow: a.rangeType === g.COLUMN ? 0 : a.startRow,
1537
- endRow: a.rangeType === g.COLUMN ? i.getMaxRows() - 1 : a.endRow,
1538
- startColumn: a.rangeType === g.ROW ? 0 : a.startColumn,
1539
- endColumn: a.rangeType === g.ROW ? i.getMaxColumns() - 1 : a.endColumn
1636
+ rangeType: _.NORMAL,
1637
+ startRow: a.rangeType === _.COLUMN ? 0 : a.startRow,
1638
+ endRow: a.rangeType === _.COLUMN ? i.getMaxRows() - 1 : a.endRow,
1639
+ startColumn: a.rangeType === _.ROW ? 0 : a.startColumn,
1640
+ endColumn: a.rangeType === _.ROW ? i.getMaxColumns() - 1 : a.endColumn
1540
1641
  };
1541
1642
  } else if (typeof e == "number" && t !== void 0)
1542
1643
  i = this._worksheet, r = {
@@ -1549,7 +1650,7 @@ let _ = class extends p {
1549
1650
  };
1550
1651
  else
1551
1652
  throw new Error("Invalid range specification");
1552
- return this._injector.createInstance(S, this._workbook, i, r);
1653
+ return this._injector.createInstance(w, this._workbook, i, r);
1553
1654
  }
1554
1655
  /**
1555
1656
  * Returns the current number of columns in the sheet, regardless of content.
@@ -1570,7 +1671,7 @@ let _ = class extends p {
1570
1671
  * @param afterPosition The row after which the new row should be added, starting at 0 for the first row.
1571
1672
  * @returns This sheet, for chaining.
1572
1673
  */
1573
- async insertRowAfter(e) {
1674
+ insertRowAfter(e) {
1574
1675
  return this.insertRowsAfter(e, 1);
1575
1676
  }
1576
1677
  /**
@@ -1578,7 +1679,7 @@ let _ = class extends p {
1578
1679
  * @param beforePosition The row before which the new row should be added, starting at 0 for the first row.
1579
1680
  * @returns This sheet, for chaining.
1580
1681
  */
1581
- async insertRowBefore(e) {
1682
+ insertRowBefore(e) {
1582
1683
  return this.insertRowsBefore(e, 1);
1583
1684
  }
1584
1685
  /**
@@ -1587,7 +1688,7 @@ let _ = class extends p {
1587
1688
  * @param numRows The number of rows to insert.
1588
1689
  * @returns This sheet, for chaining.
1589
1690
  */
1590
- async insertRows(e, t = 1) {
1691
+ insertRows(e, t = 1) {
1591
1692
  return this.insertRowsBefore(e, t);
1592
1693
  }
1593
1694
  /**
@@ -1596,9 +1697,9 @@ let _ = class extends p {
1596
1697
  * @param howMany The number of rows to insert.
1597
1698
  * @returns This sheet, for chaining.
1598
1699
  */
1599
- async insertRowsAfter(e, t) {
1600
- const n = this._workbook.getUnitId(), s = this._worksheet.getSheetId(), r = E.DOWN, i = e + 1, a = e + t, h = 0, c = this._worksheet.getColumnCount() - 1, d = D(this._worksheet, i, a, h, c, !0, e);
1601
- return await this._commandService.executeCommand(ae.id, {
1700
+ insertRowsAfter(e, t) {
1701
+ const n = this._workbook.getUnitId(), s = this._worksheet.getSheetId(), r = N.DOWN, i = e + 1, a = e + t, h = 0, c = this._worksheet.getColumnCount() - 1, d = D(this._worksheet, i, a, h, c, !0, e);
1702
+ return this._commandService.syncExecuteCommand(he.id, {
1602
1703
  unitId: n,
1603
1704
  subUnitId: s,
1604
1705
  direction: r,
@@ -1617,9 +1718,9 @@ let _ = class extends p {
1617
1718
  * @param howMany The number of rows to insert.
1618
1719
  * @returns This sheet, for chaining.
1619
1720
  */
1620
- async insertRowsBefore(e, t) {
1621
- const n = this._workbook.getUnitId(), s = this._worksheet.getSheetId(), r = E.UP, i = e, a = e + t - 1, h = 0, c = this._worksheet.getColumnCount() - 1, d = D(this._worksheet, i, a, h, c, !0, e - 1);
1622
- return await this._commandService.executeCommand(ae.id, {
1721
+ insertRowsBefore(e, t) {
1722
+ const n = this._workbook.getUnitId(), s = this._worksheet.getSheetId(), r = N.UP, i = e, a = e + t - 1, h = 0, c = this._worksheet.getColumnCount() - 1, d = D(this._worksheet, i, a, h, c, !0, e - 1);
1723
+ return this._commandService.syncExecuteCommand(he.id, {
1623
1724
  unitId: n,
1624
1725
  subUnitId: s,
1625
1726
  direction: r,
@@ -1637,7 +1738,7 @@ let _ = class extends p {
1637
1738
  * @param rowPosition The position of the row, starting at 0 for the first row.
1638
1739
  * @returns This sheet, for chaining.
1639
1740
  */
1640
- async deleteRow(e) {
1741
+ deleteRow(e) {
1641
1742
  return this.deleteRows(e, 1);
1642
1743
  }
1643
1744
  /**
@@ -1646,15 +1747,17 @@ let _ = class extends p {
1646
1747
  * @param howMany The number of rows to delete.
1647
1748
  * @returns This sheet, for chaining.
1648
1749
  */
1649
- async deleteRows(e, t) {
1750
+ deleteRows(e, t) {
1650
1751
  const n = {
1651
1752
  startRow: e,
1652
1753
  endRow: e + t - 1,
1653
1754
  startColumn: 0,
1654
1755
  endColumn: this._worksheet.getColumnCount() - 1
1655
1756
  };
1656
- return await this._commandService.executeCommand(it.id, {
1657
- range: n
1757
+ return this._commandService.syncExecuteCommand(ht.id, {
1758
+ range: n,
1759
+ unitId: this._workbook.getUnitId(),
1760
+ subUnitId: this._worksheet.getSheetId()
1658
1761
  }), this;
1659
1762
  }
1660
1763
  /**
@@ -1663,14 +1766,14 @@ let _ = class extends p {
1663
1766
  * @param destinationIndex The index that the rows should be moved to. Note that this index is based on the coordinates before the rows are moved. Existing data is shifted down to make room for the moved rows while the source rows are removed from the grid. Therefore, the data may end up at a different index than originally specified. Use 0-index for this method.
1664
1767
  * @returns This sheet, for chaining.
1665
1768
  */
1666
- async moveRows(e, t) {
1667
- const n = this._workbook.getUnitId(), s = this._worksheet.getSheetId(), r = H(e.getRange(), this._worksheet), i = r, a = {
1769
+ moveRows(e, t) {
1770
+ const n = this._workbook.getUnitId(), s = this._worksheet.getSheetId(), r = V(e.getRange(), this._worksheet), i = r, a = {
1668
1771
  startRow: t,
1669
1772
  endRow: t,
1670
1773
  startColumn: r.startColumn,
1671
1774
  endColumn: r.endColumn
1672
1775
  };
1673
- return await this._commandService.executeCommand(at.id, {
1776
+ return this._commandService.syncExecuteCommand(ct.id, {
1674
1777
  unitId: n,
1675
1778
  subUnitId: s,
1676
1779
  range: r,
@@ -1683,9 +1786,9 @@ let _ = class extends p {
1683
1786
  * @param row The row range to hide.
1684
1787
  * @returns This sheet, for chaining.
1685
1788
  */
1686
- async hideRow(e) {
1687
- const t = this._workbook.getUnitId(), n = this._worksheet.getSheetId(), s = H(e.getRange(), this._worksheet);
1688
- return await this._commandService.executeCommand(he.id, {
1789
+ hideRow(e) {
1790
+ const t = this._workbook.getUnitId(), n = this._worksheet.getSheetId(), s = V(e.getRange(), this._worksheet);
1791
+ return this._commandService.syncExecuteCommand(ce.id, {
1689
1792
  unitId: t,
1690
1793
  subUnitId: n,
1691
1794
  ranges: [s]
@@ -1697,15 +1800,15 @@ let _ = class extends p {
1697
1800
  * @param numRows The number of rows to hide.
1698
1801
  * @returns This sheet, for chaining.
1699
1802
  */
1700
- async hideRows(e, t = 1) {
1803
+ hideRows(e, t = 1) {
1701
1804
  const n = this._workbook.getUnitId(), s = this._worksheet.getSheetId(), r = {
1702
1805
  startRow: e,
1703
1806
  endRow: e + t - 1,
1704
1807
  startColumn: 0,
1705
1808
  endColumn: this._worksheet.getColumnCount() - 1,
1706
- rangeType: g.ROW
1809
+ rangeType: _.ROW
1707
1810
  };
1708
- return await this._commandService.executeCommand(he.id, {
1811
+ return this._commandService.syncExecuteCommand(ce.id, {
1709
1812
  unitId: n,
1710
1813
  subUnitId: s,
1711
1814
  ranges: [r]
@@ -1716,9 +1819,9 @@ let _ = class extends p {
1716
1819
  * @param row The range to unhide, if hidden.
1717
1820
  * @returns This sheet, for chaining.
1718
1821
  */
1719
- async unhideRow(e) {
1720
- const t = this._workbook.getUnitId(), n = this._worksheet.getSheetId(), s = H(e.getRange(), this._worksheet);
1721
- return await this._commandService.executeCommand(ce.id, {
1822
+ unhideRow(e) {
1823
+ const t = this._workbook.getUnitId(), n = this._worksheet.getSheetId(), s = V(e.getRange(), this._worksheet);
1824
+ return this._commandService.syncExecuteCommand(de.id, {
1722
1825
  unitId: t,
1723
1826
  subUnitId: n,
1724
1827
  ranges: [s]
@@ -1730,15 +1833,15 @@ let _ = class extends p {
1730
1833
  * @param numRows The number of rows to unhide.
1731
1834
  * @returns This sheet, for chaining.
1732
1835
  */
1733
- async showRows(e, t = 1) {
1836
+ showRows(e, t = 1) {
1734
1837
  const n = this._workbook.getUnitId(), s = this._worksheet.getSheetId(), r = {
1735
1838
  startRow: e,
1736
1839
  endRow: e + t - 1,
1737
1840
  startColumn: 0,
1738
1841
  endColumn: this._worksheet.getColumnCount() - 1,
1739
- rangeType: g.ROW
1842
+ rangeType: _.ROW
1740
1843
  };
1741
- return await this._commandService.executeCommand(ce.id, {
1844
+ return this._commandService.syncExecuteCommand(de.id, {
1742
1845
  unitId: n,
1743
1846
  subUnitId: s,
1744
1847
  ranges: [r]
@@ -1750,7 +1853,7 @@ let _ = class extends p {
1750
1853
  * @param height The height in pixels to set it to.
1751
1854
  * @returns This sheet, for chaining.
1752
1855
  */
1753
- async setRowHeight(e, t) {
1856
+ setRowHeight(e, t) {
1754
1857
  return this.setRowHeights(e, 1, t);
1755
1858
  }
1756
1859
  /**
@@ -1760,24 +1863,24 @@ let _ = class extends p {
1760
1863
  * @param height The height in pixels to set it to.
1761
1864
  * @returns This sheet, for chaining.
1762
1865
  */
1763
- async setRowHeights(e, t, n) {
1866
+ setRowHeights(e, t, n) {
1764
1867
  var c;
1765
1868
  const s = this._workbook.getUnitId(), r = this._worksheet.getSheetId(), i = this._worksheet.getRowManager(), a = [], h = [];
1766
1869
  for (let d = e; d < e + t; d++) {
1767
- const T = ((c = i.getRow(d)) == null ? void 0 : c.ah) || this._worksheet.getConfig().defaultRowHeight, x = {
1870
+ const O = ((c = i.getRow(d)) == null ? void 0 : c.ah) || this._worksheet.getConfig().defaultRowHeight, x = {
1768
1871
  startRow: d,
1769
1872
  endRow: d,
1770
1873
  startColumn: 0,
1771
1874
  endColumn: this._worksheet.getColumnCount() - 1
1772
1875
  };
1773
- n <= T ? a.push(x) : h.push(x);
1876
+ n <= O ? a.push(x) : h.push(x);
1774
1877
  }
1775
- return h.length > 0 && await this._commandService.executeCommand(de.id, {
1878
+ return h.length > 0 && this._commandService.syncExecuteCommand(me.id, {
1776
1879
  unitId: s,
1777
1880
  subUnitId: r,
1778
1881
  ranges: h,
1779
1882
  value: n
1780
- }), a.length > 0 && await this._commandService.executeCommand(ht.id, {
1883
+ }), a.length > 0 && this._commandService.syncExecuteCommand(dt.id, {
1781
1884
  unitId: s,
1782
1885
  subUnitId: r,
1783
1886
  ranges: a
@@ -1790,7 +1893,7 @@ let _ = class extends p {
1790
1893
  * @param height The height in pixels to set it to.
1791
1894
  * @returns This sheet, for chaining.
1792
1895
  */
1793
- async setRowHeightsForced(e, t, n) {
1896
+ setRowHeightsForced(e, t, n) {
1794
1897
  const s = this._workbook.getUnitId(), r = this._worksheet.getSheetId(), i = [
1795
1898
  {
1796
1899
  startRow: e,
@@ -1799,7 +1902,7 @@ let _ = class extends p {
1799
1902
  endColumn: this._worksheet.getColumnCount() - 1
1800
1903
  }
1801
1904
  ];
1802
- return await this._commandService.executeCommand(de.id, {
1905
+ return this._commandService.syncExecuteCommand(me.id, {
1803
1906
  unitId: s,
1804
1907
  subUnitId: r,
1805
1908
  ranges: i,
@@ -1812,7 +1915,7 @@ let _ = class extends p {
1812
1915
  * @param custom The custom properties to set.
1813
1916
  * @returns This sheet, for chaining.
1814
1917
  */
1815
- async setRowCustom(e) {
1918
+ setRowCustom(e) {
1816
1919
  const t = this._workbook.getUnitId(), n = this._worksheet.getSheetId(), s = {};
1817
1920
  for (const [i, a] of Object.entries(e))
1818
1921
  s[Number(i)] = {
@@ -1823,7 +1926,7 @@ let _ = class extends p {
1823
1926
  subUnitId: n,
1824
1927
  rowData: s
1825
1928
  };
1826
- return await this._commandService.executeCommand(ie.id, r), this;
1929
+ return this._commandService.syncExecuteCommand(ae.id, r), this;
1827
1930
  }
1828
1931
  // #region Column
1829
1932
  /**
@@ -1831,7 +1934,7 @@ let _ = class extends p {
1831
1934
  * @param afterPosition The column after which the new column should be added, starting at 0 for the first column.
1832
1935
  * @returns This sheet, for chaining.
1833
1936
  */
1834
- async insertColumnAfter(e) {
1937
+ insertColumnAfter(e) {
1835
1938
  return this.insertColumnsAfter(e, 1);
1836
1939
  }
1837
1940
  /**
@@ -1839,7 +1942,7 @@ let _ = class extends p {
1839
1942
  * @param beforePosition The column before which the new column should be added, starting at 0 for the first column.
1840
1943
  * @returns This sheet, for chaining.
1841
1944
  */
1842
- async insertColumnBefore(e) {
1945
+ insertColumnBefore(e) {
1843
1946
  return this.insertColumnsBefore(e, 1);
1844
1947
  }
1845
1948
  /**
@@ -1848,7 +1951,7 @@ let _ = class extends p {
1848
1951
  * @param numColumns The number of columns to insert.
1849
1952
  * @returns This sheet, for chaining.
1850
1953
  */
1851
- async insertColumns(e, t = 1) {
1954
+ insertColumns(e, t = 1) {
1852
1955
  return this.insertColumnsBefore(e, t);
1853
1956
  }
1854
1957
  /**
@@ -1857,9 +1960,9 @@ let _ = class extends p {
1857
1960
  * @param howMany The number of columns to insert.
1858
1961
  * @returns This sheet, for chaining.
1859
1962
  */
1860
- async insertColumnsAfter(e, t) {
1861
- const n = this._workbook.getUnitId(), s = this._worksheet.getSheetId(), r = E.RIGHT, i = 0, a = this._worksheet.getRowCount() - 1, h = e + 1, c = e + t, d = D(this._worksheet, i, a, h, c, !1, e);
1862
- return await this._commandService.executeCommand(me.id, {
1963
+ insertColumnsAfter(e, t) {
1964
+ const n = this._workbook.getUnitId(), s = this._worksheet.getSheetId(), r = N.RIGHT, i = 0, a = this._worksheet.getRowCount() - 1, h = e + 1, c = e + t, d = D(this._worksheet, i, a, h, c, !1, e);
1965
+ return this._commandService.syncExecuteCommand(ue.id, {
1863
1966
  unitId: n,
1864
1967
  subUnitId: s,
1865
1968
  direction: r,
@@ -1878,9 +1981,9 @@ let _ = class extends p {
1878
1981
  * @param howMany The number of columns to insert.
1879
1982
  * @returns This sheet, for chaining.
1880
1983
  */
1881
- async insertColumnsBefore(e, t) {
1882
- const n = this._workbook.getUnitId(), s = this._worksheet.getSheetId(), r = E.LEFT, i = 0, a = this._worksheet.getRowCount() - 1, h = e, c = e + t - 1, d = D(this._worksheet, i, a, h, c, !1, e - 1);
1883
- return await this._commandService.executeCommand(me.id, {
1984
+ insertColumnsBefore(e, t) {
1985
+ const n = this._workbook.getUnitId(), s = this._worksheet.getSheetId(), r = N.LEFT, i = 0, a = this._worksheet.getRowCount() - 1, h = e, c = e + t - 1, d = D(this._worksheet, i, a, h, c, !1, e - 1);
1986
+ return this._commandService.syncExecuteCommand(ue.id, {
1884
1987
  unitId: n,
1885
1988
  subUnitId: s,
1886
1989
  direction: r,
@@ -1898,7 +2001,7 @@ let _ = class extends p {
1898
2001
  * @param columnPosition The position of the column, starting at 0 for the first column.
1899
2002
  * @returns This sheet, for chaining.
1900
2003
  */
1901
- async deleteColumn(e) {
2004
+ deleteColumn(e) {
1902
2005
  return this.deleteColumns(e, 1);
1903
2006
  }
1904
2007
  /**
@@ -1907,15 +2010,17 @@ let _ = class extends p {
1907
2010
  * @param howMany The number of columns to delete.
1908
2011
  * @returns This sheet, for chaining.
1909
2012
  */
1910
- async deleteColumns(e, t) {
2013
+ deleteColumns(e, t) {
1911
2014
  const n = {
1912
2015
  startRow: 0,
1913
2016
  endRow: this._worksheet.getRowCount() - 1,
1914
2017
  startColumn: e,
1915
2018
  endColumn: e + t - 1
1916
2019
  };
1917
- return await this._commandService.executeCommand(ct.id, {
1918
- range: n
2020
+ return this._commandService.syncExecuteCommand(mt.id, {
2021
+ range: n,
2022
+ unitId: this._workbook.getUnitId(),
2023
+ subUnitId: this._worksheet.getSheetId()
1919
2024
  }), this;
1920
2025
  }
1921
2026
  /**
@@ -1924,14 +2029,14 @@ let _ = class extends p {
1924
2029
  * @param destinationIndex The index that the columns should be moved to. Note that this index is based on the coordinates before the columns are moved. Existing data is shifted right to make room for the moved columns while the source columns are removed from the grid. Therefore, the data may end up at a different index than originally specified. Use 0-index for this method.
1925
2030
  * @returns This sheet, for chaining.
1926
2031
  */
1927
- async moveColumns(e, t) {
1928
- const n = this._workbook.getUnitId(), s = this._worksheet.getSheetId(), r = $(e.getRange(), this._worksheet), i = r, a = {
2032
+ moveColumns(e, t) {
2033
+ const n = this._workbook.getUnitId(), s = this._worksheet.getSheetId(), r = H(e.getRange(), this._worksheet), i = r, a = {
1929
2034
  startRow: 0,
1930
2035
  endRow: this._worksheet.getRowCount() - 1,
1931
2036
  startColumn: t,
1932
2037
  endColumn: t
1933
2038
  };
1934
- return await this._commandService.executeCommand(dt.id, {
2039
+ return this._commandService.syncExecuteCommand(ut.id, {
1935
2040
  unitId: n,
1936
2041
  subUnitId: s,
1937
2042
  range: r,
@@ -1944,9 +2049,9 @@ let _ = class extends p {
1944
2049
  * @param column The column range to hide.
1945
2050
  * @returns This sheet, for chaining.
1946
2051
  */
1947
- async hideColumn(e) {
1948
- const t = this._workbook.getUnitId(), n = this._worksheet.getSheetId(), s = $(e.getRange(), this._worksheet);
1949
- return await this._commandService.executeCommand(ue.id, {
2052
+ hideColumn(e) {
2053
+ const t = this._workbook.getUnitId(), n = this._worksheet.getSheetId(), s = H(e.getRange(), this._worksheet);
2054
+ return this._commandService.syncExecuteCommand(le.id, {
1950
2055
  unitId: t,
1951
2056
  subUnitId: n,
1952
2057
  ranges: [s]
@@ -1958,15 +2063,15 @@ let _ = class extends p {
1958
2063
  * @param numColumns The number of columns to hide.
1959
2064
  * @returns This sheet, for chaining.
1960
2065
  */
1961
- async hideColumns(e, t = 1) {
2066
+ hideColumns(e, t = 1) {
1962
2067
  const n = this._workbook.getUnitId(), s = this._worksheet.getSheetId(), r = {
1963
2068
  startRow: 0,
1964
2069
  endRow: this._worksheet.getRowCount() - 1,
1965
2070
  startColumn: e,
1966
2071
  endColumn: e + t - 1,
1967
- rangeType: g.COLUMN
2072
+ rangeType: _.COLUMN
1968
2073
  };
1969
- return await this._commandService.executeCommand(ue.id, {
2074
+ return this._commandService.syncExecuteCommand(le.id, {
1970
2075
  unitId: n,
1971
2076
  subUnitId: s,
1972
2077
  ranges: [r]
@@ -1977,9 +2082,9 @@ let _ = class extends p {
1977
2082
  * @param column The range to unhide, if hidden.
1978
2083
  * @returns This sheet, for chaining.
1979
2084
  */
1980
- async unhideColumn(e) {
1981
- const t = this._workbook.getUnitId(), n = this._worksheet.getSheetId(), s = $(e.getRange(), this._worksheet);
1982
- return await this._commandService.executeCommand(le.id, {
2085
+ unhideColumn(e) {
2086
+ const t = this._workbook.getUnitId(), n = this._worksheet.getSheetId(), s = H(e.getRange(), this._worksheet);
2087
+ return this._commandService.syncExecuteCommand(ge.id, {
1983
2088
  unitId: t,
1984
2089
  subUnitId: n,
1985
2090
  ranges: [s]
@@ -1991,15 +2096,15 @@ let _ = class extends p {
1991
2096
  * @param numColumns The number of columns to unhide.
1992
2097
  * @returns This sheet, for chaining.
1993
2098
  */
1994
- async showColumns(e, t = 1) {
2099
+ showColumns(e, t = 1) {
1995
2100
  const n = this._workbook.getUnitId(), s = this._worksheet.getSheetId(), r = {
1996
2101
  startRow: 0,
1997
2102
  endRow: this._worksheet.getRowCount() - 1,
1998
2103
  startColumn: e,
1999
2104
  endColumn: e + t - 1,
2000
- rangeType: g.COLUMN
2105
+ rangeType: _.COLUMN
2001
2106
  };
2002
- return await this._commandService.executeCommand(le.id, {
2107
+ return this._commandService.syncExecuteCommand(ge.id, {
2003
2108
  unitId: n,
2004
2109
  subUnitId: s,
2005
2110
  ranges: [r]
@@ -2011,7 +2116,7 @@ let _ = class extends p {
2011
2116
  * @param width The width in pixels to set it to.
2012
2117
  * @returns This sheet, for chaining.
2013
2118
  */
2014
- async setColumnWidth(e, t) {
2119
+ setColumnWidth(e, t) {
2015
2120
  return this.setColumnWidths(e, 1, t);
2016
2121
  }
2017
2122
  /**
@@ -2021,7 +2126,7 @@ let _ = class extends p {
2021
2126
  * @param width The width in pixels to set it to.
2022
2127
  * @returns This sheet, for chaining.
2023
2128
  */
2024
- async setColumnWidths(e, t, n) {
2129
+ setColumnWidths(e, t, n) {
2025
2130
  const s = this._workbook.getUnitId(), r = this._worksheet.getSheetId(), i = [
2026
2131
  {
2027
2132
  startColumn: e,
@@ -2030,7 +2135,7 @@ let _ = class extends p {
2030
2135
  endRow: this._worksheet.getRowCount() - 1
2031
2136
  }
2032
2137
  ];
2033
- return await this._commandService.executeCommand(mt.id, {
2138
+ return this._commandService.syncExecuteCommand(lt.id, {
2034
2139
  unitId: s,
2035
2140
  subUnitId: r,
2036
2141
  ranges: i,
@@ -2043,7 +2148,7 @@ let _ = class extends p {
2043
2148
  * @param custom The custom properties to set.
2044
2149
  * @returns This sheet, for chaining.
2045
2150
  */
2046
- async setColumnCustom(e) {
2151
+ setColumnCustom(e) {
2047
2152
  const t = this._workbook.getUnitId(), n = this._worksheet.getSheetId(), s = {};
2048
2153
  for (const [i, a] of Object.entries(e))
2049
2154
  s[Number(i)] = {
@@ -2054,7 +2159,7 @@ let _ = class extends p {
2054
2159
  subUnitId: n,
2055
2160
  columnData: s
2056
2161
  };
2057
- return await this._commandService.executeCommand(re.id, r), this;
2162
+ return this._commandService.syncExecuteCommand(ie.id, r), this;
2058
2163
  }
2059
2164
  // #region merge cells
2060
2165
  /**
@@ -2062,7 +2167,7 @@ let _ = class extends p {
2062
2167
  * @returns all merged cells
2063
2168
  */
2064
2169
  getMergedRanges() {
2065
- return this._worksheet.getSnapshot().mergeData.map((t) => this._injector.createInstance(S, this._workbook, this._worksheet, t));
2170
+ return this._worksheet.getSnapshot().mergeData.map((t) => this._injector.createInstance(w, this._workbook, this._worksheet, t));
2066
2171
  }
2067
2172
  /**
2068
2173
  * Get the merged cell data of the specified row and column.
@@ -2073,7 +2178,7 @@ let _ = class extends p {
2073
2178
  getCellMergeData(e, t) {
2074
2179
  const s = this._worksheet.getMergedCell(e, t);
2075
2180
  if (s)
2076
- return this._injector.createInstance(S, this._workbook, this._worksheet, s);
2181
+ return this._injector.createInstance(w, this._workbook, this._worksheet, s);
2077
2182
  }
2078
2183
  // #endregion
2079
2184
  /**
@@ -2102,21 +2207,21 @@ let _ = class extends p {
2102
2207
  * @returns True if the command was successful, false otherwise.
2103
2208
  */
2104
2209
  setFreeze(e) {
2105
- return this._logService.warn("setFreeze is deprecated, use setFrozenRows and setFrozenColumns instead"), this._commandService.syncExecuteCommand(B.id, {
2210
+ return this._logService.warn("setFreeze is deprecated, use setFrozenRows and setFrozenColumns instead"), this._commandService.syncExecuteCommand(L.id, {
2106
2211
  ...e,
2107
2212
  unitId: this._workbook.getUnitId(),
2108
2213
  subUnitId: this.getSheetId()
2109
- });
2214
+ }), this;
2110
2215
  }
2111
2216
  /**
2112
2217
  * Cancels the frozen state of the current sheet.
2113
2218
  * @returns True if the command was successful, false otherwise.
2114
2219
  */
2115
2220
  cancelFreeze() {
2116
- return this._commandService.syncExecuteCommand(ut.id, {
2221
+ return this._commandService.syncExecuteCommand(gt.id, {
2117
2222
  unitId: this._workbook.getUnitId(),
2118
2223
  subUnitId: this.getSheetId()
2119
- });
2224
+ }), this;
2120
2225
  }
2121
2226
  /**
2122
2227
  * Get the freeze state of the current sheet.
@@ -2138,7 +2243,7 @@ let _ = class extends p {
2138
2243
  });
2139
2244
  } else if (arguments.length === 2) {
2140
2245
  let [n = 0, s = 0] = e;
2141
- n > s && ([n, s] = [s, n]), this._commandService.syncExecuteCommand(B.id, {
2246
+ n > s && ([n, s] = [s, n]), this._commandService.syncExecuteCommand(L.id, {
2142
2247
  startColumn: s + 1,
2143
2248
  xSplit: s - n + 1,
2144
2249
  startRow: t.startRow,
@@ -2147,6 +2252,7 @@ let _ = class extends p {
2147
2252
  subUnitId: this.getSheetId()
2148
2253
  });
2149
2254
  }
2255
+ return this;
2150
2256
  }
2151
2257
  setFrozenRows(...e) {
2152
2258
  const t = this.getFreeze();
@@ -2159,7 +2265,7 @@ let _ = class extends p {
2159
2265
  });
2160
2266
  } else if (arguments.length === 2) {
2161
2267
  let [n = 0, s = 0] = e;
2162
- n > s && ([n, s] = [s, n]), this._commandService.syncExecuteCommand, this._commandService.syncExecuteCommand(B.id, {
2268
+ n > s && ([n, s] = [s, n]), this._commandService.syncExecuteCommand(L.id, {
2163
2269
  startRow: s + 1,
2164
2270
  ySplit: s - n + 1,
2165
2271
  startColumn: t.startColumn,
@@ -2168,6 +2274,7 @@ let _ = class extends p {
2168
2274
  subUnitId: this.getSheetId()
2169
2275
  });
2170
2276
  }
2277
+ return this;
2171
2278
  }
2172
2279
  /**
2173
2280
  * Get the number of frozen columns.
@@ -2235,16 +2342,16 @@ let _ = class extends p {
2235
2342
  * ```
2236
2343
  */
2237
2344
  setHiddenGridlines(e) {
2238
- return this._commandService.executeCommand(lt.id, {
2345
+ return this._commandService.executeCommand(_t.id, {
2239
2346
  unitId: this._workbook.getUnitId(),
2240
2347
  subUnitId: this._worksheet.getSheetId(),
2241
2348
  showGridlines: e ? u.FALSE : u.TRUE
2242
- });
2349
+ }), this;
2243
2350
  }
2244
2351
  /**
2245
2352
  * Set the color of the gridlines in the sheet.
2246
2353
  * @param {string|undefined} color The color to set for the gridlines.Undefined or null to reset to the default color.
2247
- * @returns {Promise<boolean>} True if the command was successful, false otherwise.
2354
+ * @returns {FWorksheet} Returns the current worksheet instance for method chaining
2248
2355
  * @example
2249
2356
  * ```ts
2250
2357
  * const fWorkbook = univerAPI.getActiveWorkbook();
@@ -2254,11 +2361,11 @@ let _ = class extends p {
2254
2361
  * ```
2255
2362
  */
2256
2363
  setGridLinesColor(e) {
2257
- return this._commandService.executeCommand(gt.id, {
2364
+ return this._commandService.syncExecuteCommand(wt.id, {
2258
2365
  unitId: this._workbook.getUnitId(),
2259
2366
  subUnitId: this._worksheet.getSheetId(),
2260
2367
  color: e
2261
- });
2368
+ }), this;
2262
2369
  }
2263
2370
  /**
2264
2371
  * Get the color of the gridlines in the sheet.
@@ -2270,7 +2377,7 @@ let _ = class extends p {
2270
2377
  /**
2271
2378
  * Sets the sheet tab color.
2272
2379
  * @param {string|null|undefined} color A color code in CSS notation (like '#ffffff' or 'white'), or null to reset the tab color.
2273
- * @returns {Promise<boolean>} True if the command was successful, false otherwise.
2380
+ * @returns {FWorksheet} Returns the current worksheet instance for method chaining
2274
2381
  * @example
2275
2382
  * ```ts
2276
2383
  * const fWorkbook = univerAPI.getActiveWorkbook();
@@ -2280,11 +2387,11 @@ let _ = class extends p {
2280
2387
  * ```
2281
2388
  */
2282
2389
  setTabColor(e) {
2283
- return this._commandService.executeCommand(_t.id, {
2390
+ return this._commandService.executeCommand(kt.id, {
2284
2391
  unitId: this._workbook.getUnitId(),
2285
2392
  subUnitId: this._worksheet.getSheetId(),
2286
2393
  color: e
2287
- });
2394
+ }), this;
2288
2395
  }
2289
2396
  /**
2290
2397
  * Get the tab color of the sheet.
@@ -2319,9 +2426,9 @@ let _ = class extends p {
2319
2426
  */
2320
2427
  onCellDataChange(e) {
2321
2428
  return this._injector.get(l).onCommandExecuted((n) => {
2322
- if (n.id === ge.id) {
2429
+ if (n.id === _e.id) {
2323
2430
  const s = n.params;
2324
- s.unitId === this._workbook.getUnitId() && s.subUnitId === this._worksheet.getSheetId() && s.cellValue && e(new j(s.cellValue));
2431
+ s.unitId === this._workbook.getUnitId() && s.subUnitId === this._worksheet.getSheetId() && s.cellValue && e(new M(s.cellValue));
2325
2432
  }
2326
2433
  });
2327
2434
  }
@@ -2343,9 +2450,9 @@ let _ = class extends p {
2343
2450
  */
2344
2451
  onBeforeCellDataChange(e) {
2345
2452
  return this._injector.get(l).beforeCommandExecuted((n) => {
2346
- if (n.id === ge.id) {
2453
+ if (n.id === _e.id) {
2347
2454
  const s = n.params;
2348
- s.unitId === this._workbook.getUnitId() && s.subUnitId === this._worksheet.getSheetId() && s.cellValue && e(new j(s.cellValue));
2455
+ s.unitId === this._workbook.getUnitId() && s.subUnitId === this._worksheet.getSheetId() && s.cellValue && e(new M(s.cellValue));
2349
2456
  }
2350
2457
  });
2351
2458
  }
@@ -2363,14 +2470,14 @@ let _ = class extends p {
2363
2470
  const e = this._injector.get(l);
2364
2471
  if (this._workbook.getSheets().filter((r) => r.isSheetHidden() !== u.TRUE).length <= 1)
2365
2472
  throw new Error("Cannot hide the only visible sheet");
2366
- e.executeCommand(wt.id, {
2473
+ return e.syncExecuteCommand(St.id, {
2367
2474
  unitId: this._workbook.getUnitId(),
2368
2475
  subUnitId: this._worksheet.getSheetId()
2369
- });
2476
+ }), this;
2370
2477
  }
2371
2478
  /**
2372
2479
  * Shows this sheet. Has no effect if the sheet is already visible.
2373
- * @returns {Promise<boolean>} True if the command was successful, false otherwise.
2480
+ * @returns {FWorksheet} Returns the current worksheet instance for method chaining
2374
2481
  * @example
2375
2482
  * ```ts
2376
2483
  * const fWorkbook = univerAPI.getActiveWorkbook();
@@ -2380,10 +2487,10 @@ let _ = class extends p {
2380
2487
  * ```
2381
2488
  */
2382
2489
  showSheet() {
2383
- return this._injector.get(l).executeCommand(kt.id, {
2490
+ return this._injector.get(l).syncExecuteCommand(Ct.id, {
2384
2491
  unitId: this._workbook.getUnitId(),
2385
2492
  subUnitId: this._worksheet.getSheetId()
2386
- });
2493
+ }), this;
2387
2494
  }
2388
2495
  /**
2389
2496
  * Returns true if the sheet is currently hidden.
@@ -2395,7 +2502,7 @@ let _ = class extends p {
2395
2502
  /**
2396
2503
  * Sets the sheet name.
2397
2504
  * @param {string} name The new name for the sheet.
2398
- * @returns {Promise<boolean>} True if the command was successful, false otherwise.
2505
+ * @returns {FWorksheet} Returns the current worksheet instance for method chaining
2399
2506
  * @example
2400
2507
  * ```ts
2401
2508
  * const fWorkbook = univerAPI.getActiveWorkbook();
@@ -2405,11 +2512,11 @@ let _ = class extends p {
2405
2512
  * ```
2406
2513
  */
2407
2514
  setName(e) {
2408
- return this._commandService.executeCommand(St.id, {
2515
+ return this._commandService.syncExecuteCommand(It.id, {
2409
2516
  unitId: this._workbook.getUnitId(),
2410
2517
  subUnitId: this._worksheet.getSheetId(),
2411
2518
  name: e
2412
- });
2519
+ }), this;
2413
2520
  }
2414
2521
  /**
2415
2522
  * Activates this sheet. Does not alter the sheet itself, only the parent's notion of the active sheet.
@@ -2438,7 +2545,7 @@ let _ = class extends p {
2438
2545
  * @param {IFacadeClearOptions} [options] Options for clearing the sheet. If not provided, the contents and formatting are cleared both.
2439
2546
  * @param {boolean} [options.contentsOnly] If true, the contents of the sheet are cleared. If false, the contents and formatting are cleared. Default is false.
2440
2547
  * @param {boolean} [options.formatOnly] If true, the formatting of the sheet is cleared. If false, the contents and formatting are cleared. Default is false.
2441
- * @returns {Promise<boolean>} True if the command was successful, false otherwise.
2548
+ * @returns {FWorksheet} Returns the current worksheet instance for method chaining
2442
2549
  * @example
2443
2550
  * ```ts
2444
2551
  * const fWorkbook = univerAPI.getActiveWorkbook();
@@ -2460,16 +2567,16 @@ let _ = class extends p {
2460
2567
  startColumn: 0,
2461
2568
  endColumn: this._worksheet.getColumnCount() - 1
2462
2569
  };
2463
- return s.executeCommand(Ct.id, {
2570
+ return s.syncExecuteCommand(ft.id, {
2464
2571
  unitId: t,
2465
2572
  subUnitId: n,
2466
2573
  ranges: [r],
2467
2574
  options: e
2468
- });
2575
+ }), this;
2469
2576
  }
2470
2577
  /**
2471
2578
  * Clears the sheet of contents, while preserving formatting information.
2472
- * @returns {Promise<boolean>} True if the command was successful, false otherwise.
2579
+ * @returns {FWorksheet} Returns the current worksheet instance for method chaining
2473
2580
  * @example
2474
2581
  * ```ts
2475
2582
  * const fWorkbook = univerAPI.getActiveWorkbook();
@@ -2485,15 +2592,15 @@ let _ = class extends p {
2485
2592
  startColumn: 0,
2486
2593
  endColumn: this._worksheet.getColumnCount() - 1
2487
2594
  };
2488
- return n.executeCommand(It.id, {
2595
+ return n.syncExecuteCommand(vt.id, {
2489
2596
  unitId: e,
2490
2597
  subUnitId: t,
2491
2598
  ranges: [s]
2492
- });
2599
+ }), this;
2493
2600
  }
2494
2601
  /**
2495
2602
  * Clears the sheet of formatting, while preserving contents.
2496
- * @returns {Promise<boolean>} True if the command was successful, false otherwise.
2603
+ * @returns {FWorksheet} Returns the current worksheet instance for method chaining
2497
2604
  * @example
2498
2605
  * ```ts
2499
2606
  * const fWorkbook = univerAPI.getActiveWorkbook();
@@ -2509,11 +2616,11 @@ let _ = class extends p {
2509
2616
  startColumn: 0,
2510
2617
  endColumn: this._worksheet.getColumnCount() - 1
2511
2618
  };
2512
- return n.executeCommand(ft.id, {
2619
+ return n.syncExecuteCommand(Rt.id, {
2513
2620
  unitId: e,
2514
2621
  subUnitId: t,
2515
2622
  ranges: [s]
2516
- });
2623
+ }), this;
2517
2624
  }
2518
2625
  /**
2519
2626
  * Returns a Range corresponding to the dimensions in which data is present.
@@ -2602,7 +2709,7 @@ let _ = class extends p {
2602
2709
  * ```
2603
2710
  */
2604
2711
  equalTo(e) {
2605
- return e instanceof _ ? this._worksheet.getSheetId() === e.getSheetId() && this._workbook.getUnitId() === e.getWorkbook().getUnitId() : !1;
2712
+ return e instanceof g ? this._worksheet.getSheetId() === e.getSheetId() && this._workbook.getUnitId() === e.getWorkbook().getUnitId() : !1;
2606
2713
  }
2607
2714
  /*
2608
2715
  * Insert a defined name for worksheet.
@@ -2617,7 +2724,7 @@ let _ = class extends p {
2617
2724
  * ```
2618
2725
  */
2619
2726
  insertDefinedName(e, t) {
2620
- const s = this._injector.createInstance(A).setName(e).setRef(t).build();
2727
+ const s = this._injector.createInstance(F).setName(e).setRef(t).build();
2621
2728
  s.localSheetId = this.getSheetId(), this._fWorkbook.insertDefinedNameBuilder(s);
2622
2729
  }
2623
2730
  /**
@@ -2634,22 +2741,40 @@ let _ = class extends p {
2634
2741
  getDefinedNames() {
2635
2742
  return this._fWorkbook.getDefinedNames().filter((t) => t.getLocalSheetId() === this.getSheetId());
2636
2743
  }
2744
+ /**
2745
+ * Get all merged cells in the current worksheet
2746
+ * @returns {FRange[]} All the merged cells in the worksheet
2747
+ * @example
2748
+ * ```ts
2749
+ * const workbook = univerAPI.getActiveWorkbook();
2750
+ * const worksheet = workbook.getActiveSheet();
2751
+ * const rangeFirst = worksheet.getRange(0, 0, 2, 2);
2752
+ * const mergeFirst = rangeFirst.merge();
2753
+ * const rangeSecond = worksheet.getRange(5, 0, 2, 2);
2754
+ * const mergeSecond = rangeSecond.merge();
2755
+ * const mergeData = worksheet.getMergeData();
2756
+ * console.log('debugger', mergeData);
2757
+ * ```
2758
+ */
2759
+ getMergeData() {
2760
+ return this._worksheet.getMergeData().map((e) => this._injector.createInstance(w, this._workbook, this._worksheet, e));
2761
+ }
2637
2762
  };
2638
- _ = Gt([
2639
- M(3, m(v)),
2640
- M(4, m(Ne)),
2641
- M(5, m(Ce)),
2642
- M(6, l)
2643
- ], _);
2644
- var qt = Object.defineProperty, Kt = Object.getOwnPropertyDescriptor, Yt = (o, e, t, n) => {
2645
- for (var s = n > 1 ? void 0 : n ? Kt(e, t) : e, r = o.length - 1, i; r >= 0; r--)
2763
+ g = Zt([
2764
+ W(3, m(v)),
2765
+ W(4, m(Ne)),
2766
+ W(5, m(Ie)),
2767
+ W(6, l)
2768
+ ], g);
2769
+ var en = Object.defineProperty, tn = Object.getOwnPropertyDescriptor, nn = (o, e, t, n) => {
2770
+ for (var s = n > 1 ? void 0 : n ? tn(e, t) : e, r = o.length - 1, i; r >= 0; r--)
2646
2771
  (i = o[r]) && (s = (n ? i(e, t, s) : i(s)) || s);
2647
- return n && s && qt(e, t, s), s;
2648
- }, k = (o, e) => (t, n) => e(t, n, o);
2649
- let I = class extends p {
2772
+ return n && s && en(e, t, s), s;
2773
+ }, S = (o, e) => (t, n) => e(t, n, o);
2774
+ let I = class extends X {
2650
2775
  constructor(e, t, n, s, r, i, a, h, c, d) {
2651
- super();
2652
- P(this, "id");
2776
+ super(t);
2777
+ p(this, "id");
2653
2778
  this._workbook = e, this._injector = t, this._resourceLoaderService = n, this._selectionManagerService = s, this._univerInstanceService = r, this._commandService = i, this._permissionService = a, this._logService = h, this._localeService = c, this._definedNamesService = d, this.id = this._workbook.getUnitId();
2654
2779
  }
2655
2780
  /**
@@ -2724,7 +2849,7 @@ let I = class extends p {
2724
2849
  */
2725
2850
  getActiveSheet() {
2726
2851
  const e = this._workbook.getActiveSheet();
2727
- return this._injector.createInstance(_, this, this._workbook, e);
2852
+ return this._injector.createInstance(g, this, this._workbook, e);
2728
2853
  }
2729
2854
  /**
2730
2855
  * Gets all the worksheets in this workbook
@@ -2737,7 +2862,7 @@ let I = class extends p {
2737
2862
  * ```
2738
2863
  */
2739
2864
  getSheets() {
2740
- return this._workbook.getSheets().map((e) => this._injector.createInstance(_, this, this._workbook, e));
2865
+ return this._workbook.getSheets().map((e) => this._injector.createInstance(g, this, this._workbook, e));
2741
2866
  }
2742
2867
  /**
2743
2868
  * Create a new worksheet and returns a handle to it.
@@ -2753,19 +2878,19 @@ let I = class extends p {
2753
2878
  * ```
2754
2879
  */
2755
2880
  create(e, t, n) {
2756
- const s = Fe({});
2757
- s.rowCount = t, s.columnCount = n, s.name = e, s.id = e.toLowerCase().replace(/ /g, "-"), this._commandService.syncExecuteCommand(z.id, {
2881
+ const s = Be({});
2882
+ s.rowCount = t, s.columnCount = n, s.name = e, s.id = e.toLowerCase().replace(/ /g, "-"), this._commandService.syncExecuteCommand(U.id, {
2758
2883
  unitId: this.id,
2759
2884
  index: this._workbook.getSheets().length,
2760
2885
  sheet: s
2761
- }), this._commandService.syncExecuteCommand(V.id, {
2886
+ }), this._commandService.syncExecuteCommand(z.id, {
2762
2887
  unitId: this.id,
2763
2888
  subUnitId: this._workbook.getSheets()[this._workbook.getSheets().length - 1].getSheetId()
2764
2889
  });
2765
2890
  const r = this._workbook.getActiveSheet();
2766
2891
  if (!r)
2767
2892
  throw new Error("No active sheet found");
2768
- return this._injector.createInstance(_, this, this._workbook, r);
2893
+ return this._injector.createInstance(g, this, this._workbook, r);
2769
2894
  }
2770
2895
  /**
2771
2896
  * Get a worksheet by sheet id.
@@ -2780,7 +2905,7 @@ let I = class extends p {
2780
2905
  */
2781
2906
  getSheetBySheetId(e) {
2782
2907
  const t = this._workbook.getSheetBySheetId(e);
2783
- return t ? this._injector.createInstance(_, this, this._workbook, t) : null;
2908
+ return t ? this._injector.createInstance(g, this, this._workbook, t) : null;
2784
2909
  }
2785
2910
  /**
2786
2911
  * Get a worksheet by sheet name.
@@ -2795,7 +2920,7 @@ let I = class extends p {
2795
2920
  */
2796
2921
  getSheetByName(e) {
2797
2922
  const t = this._workbook.getSheetBySheetName(e);
2798
- return t ? this._injector.createInstance(_, this, this._workbook, t) : null;
2923
+ return t ? this._injector.createInstance(g, this, this._workbook, t) : null;
2799
2924
  }
2800
2925
  /**
2801
2926
  * Sets the given worksheet to be the active worksheet in the workbook.
@@ -2810,7 +2935,7 @@ let I = class extends p {
2810
2935
  * ```
2811
2936
  */
2812
2937
  setActiveSheet(e) {
2813
- return this._commandService.syncExecuteCommand(V.id, {
2938
+ return this._commandService.syncExecuteCommand(z.id, {
2814
2939
  unitId: this.id,
2815
2940
  subUnitId: e.getSheetId()
2816
2941
  }), e;
@@ -2832,16 +2957,16 @@ let I = class extends p {
2832
2957
  * ```
2833
2958
  */
2834
2959
  insertSheet(e) {
2835
- e != null ? this._commandService.syncExecuteCommand(z.id, { sheet: { name: e } }) : this._commandService.syncExecuteCommand(z.id);
2960
+ e != null ? this._commandService.syncExecuteCommand(U.id, { sheet: { name: e } }) : this._commandService.syncExecuteCommand(U.id);
2836
2961
  const t = this.id, n = this._workbook.getSheets()[this._workbook.getSheets().length - 1].getSheetId();
2837
- this._commandService.syncExecuteCommand(V.id, {
2962
+ this._commandService.syncExecuteCommand(z.id, {
2838
2963
  unitId: t,
2839
2964
  subUnitId: n
2840
2965
  });
2841
2966
  const s = this._workbook.getActiveSheet();
2842
2967
  if (!s)
2843
2968
  throw new Error("No active sheet found");
2844
- return this._injector.createInstance(_, this, this._workbook, s);
2969
+ return this._injector.createInstance(g, this, this._workbook, s);
2845
2970
  }
2846
2971
  /**
2847
2972
  * Deletes the specified worksheet.
@@ -2856,7 +2981,7 @@ let I = class extends p {
2856
2981
  */
2857
2982
  deleteSheet(e) {
2858
2983
  const t = this.id, n = e.getSheetId();
2859
- return this._commandService.executeCommand(vt.id, {
2984
+ return this._commandService.syncExecuteCommand(bt.id, {
2860
2985
  unitId: t,
2861
2986
  subUnitId: n
2862
2987
  });
@@ -2873,7 +2998,7 @@ let I = class extends p {
2873
2998
  * ```
2874
2999
  */
2875
3000
  undo() {
2876
- return this._univerInstanceService.focusUnit(this.id), this._commandService.executeCommand(Ae.id);
3001
+ return this._univerInstanceService.focusUnit(this.id), this._commandService.syncExecuteCommand(Le.id), this;
2877
3002
  }
2878
3003
  /**
2879
3004
  * Redo the last undone action.
@@ -2886,7 +3011,7 @@ let I = class extends p {
2886
3011
  * ```
2887
3012
  */
2888
3013
  redo() {
2889
- return this._univerInstanceService.focusUnit(this.id), this._commandService.executeCommand(Te.id);
3014
+ return this._univerInstanceService.focusUnit(this.id), this._commandService.syncExecuteCommand(ze.id), this;
2890
3015
  }
2891
3016
  /**
2892
3017
  * Callback for command execution.
@@ -2947,9 +3072,9 @@ let I = class extends p {
2947
3072
  * @returns A function to dispose the listening
2948
3073
  */
2949
3074
  onSelectionChange(e) {
2950
- return Ie(
3075
+ return fe(
2951
3076
  this._selectionManagerService.selectionMoveEnd$.subscribe((t) => {
2952
- this._univerInstanceService.getCurrentUnitForType(U.UNIVER_SHEET).getUnitId() === this.id && (t != null && t.length ? e(t.map((n) => n.range)) : e([]));
3077
+ this._univerInstanceService.getCurrentUnitForType(P.UNIVER_SHEET).getUnitId() === this.id && (t != null && t.length ? e(t.map((n) => n.range)) : e([]));
2953
3078
  })
2954
3079
  );
2955
3080
  }
@@ -2958,7 +3083,7 @@ let I = class extends p {
2958
3083
  * @param {boolean} value editable value want to set
2959
3084
  */
2960
3085
  setEditable(e) {
2961
- const t = new ye(this._workbook.getUnitId());
3086
+ const t = new Ue(this._workbook.getUnitId());
2962
3087
  this._permissionService.getPermissionPoint(t.id) || this._permissionService.addPermissionPoint(t), this._permissionService.updatePermissionPoint(t.id, e);
2963
3088
  }
2964
3089
  /**
@@ -2969,13 +3094,13 @@ let I = class extends p {
2969
3094
  const t = this.getActiveSheet(), n = e.getRange().sheetId || t.getSheetId(), s = n ? this._workbook.getSheetBySheetId(n) : this._workbook.getActiveSheet(!0);
2970
3095
  if (!s)
2971
3096
  throw new Error("No active sheet found");
2972
- s.getSheetId() !== t.getSheetId() && this.setActiveSheet(this._injector.createInstance(_, this, this._workbook, s));
3097
+ s.getSheetId() !== t.getSheetId() && this.setActiveSheet(this._injector.createInstance(g, this, this._workbook, s));
2973
3098
  const r = {
2974
3099
  unitId: this.getId(),
2975
3100
  subUnitId: n,
2976
- selections: [e].map((i) => ({ range: i.getRange(), primary: Y(i.getRange(), s), style: null }))
3101
+ selections: [e].map((i) => ({ range: i.getRange(), primary: K(i.getRange(), s), style: null }))
2977
3102
  };
2978
- this._commandService.syncExecuteCommand(Ue.id, r);
3103
+ this._commandService.syncExecuteCommand(xe.id, r);
2979
3104
  }
2980
3105
  /**
2981
3106
  * Returns the selected range in the active sheet, or null if there is no active range.
@@ -2983,7 +3108,7 @@ let I = class extends p {
2983
3108
  */
2984
3109
  getActiveRange() {
2985
3110
  const e = this._workbook.getActiveSheet(), n = this._selectionManagerService.getCurrentSelections().find((s) => !!s.primary);
2986
- return n ? this._injector.createInstance(S, this._workbook, e, n.range) : null;
3111
+ return n ? this._injector.createInstance(w, this._workbook, e, n.range) : null;
2987
3112
  }
2988
3113
  /**
2989
3114
  * Deletes the currently active sheet.
@@ -3001,7 +3126,7 @@ let I = class extends p {
3001
3126
  /**
3002
3127
  * Duplicates the given worksheet.
3003
3128
  * @param {FWorksheet} sheet The worksheet to duplicate.
3004
- * @returns {Promise<boolean>} true if the sheet was duplicated, false otherwise
3129
+ * @returns {FWorksheet} The duplicated worksheet
3005
3130
  * @example
3006
3131
  * ```ts
3007
3132
  * // The code below duplicates the given worksheet
@@ -3011,14 +3136,14 @@ let I = class extends p {
3011
3136
  * ```
3012
3137
  */
3013
3138
  duplicateSheet(e) {
3014
- return this._commandService.executeCommand(Rt.id, {
3139
+ return this._commandService.syncExecuteCommand(pt.id, {
3015
3140
  unitId: e.getWorkbook().getUnitId(),
3016
3141
  subUnitId: e.getSheetId()
3017
- });
3142
+ }), this._injector.createInstance(g, this, this._workbook, this._workbook.getActiveSheet());
3018
3143
  }
3019
3144
  /**
3020
3145
  * Duplicates the active sheet.
3021
- * @returns {Promise<boolean>} true if the sheet was duplicated, false otherwise
3146
+ * @returns {FWorksheet} The duplicated worksheet
3022
3147
  * @example
3023
3148
  * ```ts
3024
3149
  * // The code below duplicates the active sheet
@@ -3086,7 +3211,7 @@ let I = class extends p {
3086
3211
  * Move the sheet to the specified index.
3087
3212
  * @param {FWorksheet} sheet The sheet to move
3088
3213
  * @param {number} index The index to move the sheet to
3089
- * @returns {Promise<boolean>} true if the sheet was moved, false otherwise
3214
+ * @returns {FWorkbook} This workbook, for chaining
3090
3215
  * @example
3091
3216
  * ```ts
3092
3217
  * // The code below moves the sheet to the specified index
@@ -3097,16 +3222,16 @@ let I = class extends p {
3097
3222
  */
3098
3223
  moveSheet(e, t) {
3099
3224
  let n = t;
3100
- return n < 0 ? n = 0 : n > this._workbook.getSheets().length - 1 && (n = this._workbook.getSheets().length - 1), this._commandService.executeCommand(bt.id, {
3225
+ return n < 0 ? n = 0 : n > this._workbook.getSheets().length - 1 && (n = this._workbook.getSheets().length - 1), this._commandService.syncExecuteCommand(yt.id, {
3101
3226
  unitId: e.getWorkbook().getUnitId(),
3102
3227
  order: n,
3103
3228
  subUnitId: e.getSheetId()
3104
- });
3229
+ }), this;
3105
3230
  }
3106
3231
  /**
3107
3232
  * Move the active sheet to the specified index.
3108
3233
  * @param {number} index The index to move the active sheet to
3109
- * @returns {Promise<boolean>} true if the sheet was moved, false otherwise
3234
+ * @returns {FWorkbook} This workbook, for chaining
3110
3235
  * @example
3111
3236
  * ```ts
3112
3237
  * // The code below moves the active sheet to the specified index
@@ -3124,7 +3249,7 @@ let I = class extends p {
3124
3249
  * @returns {FPermission} - The PermissionInstance.
3125
3250
  */
3126
3251
  getPermission() {
3127
- return this._injector.createInstance(O);
3252
+ return this._injector.createInstance(j);
3128
3253
  }
3129
3254
  /**
3130
3255
  * Get the defined name by name.
@@ -3139,7 +3264,7 @@ let I = class extends p {
3139
3264
  */
3140
3265
  getDefinedName(e) {
3141
3266
  const t = this._definedNamesService.getValueByName(this.id, e);
3142
- return t ? this._injector.createInstance(W, { ...t, unitId: this.id }) : null;
3267
+ return t ? this._injector.createInstance(T, { ...t, unitId: this.id }) : null;
3143
3268
  }
3144
3269
  /**
3145
3270
  * Get all the defined names in the workbook.
@@ -3153,7 +3278,7 @@ let I = class extends p {
3153
3278
  */
3154
3279
  getDefinedNames() {
3155
3280
  const e = this._definedNamesService.getDefinedNameMap(this.id);
3156
- return e ? Object.values(e).map((t) => this._injector.createInstance(W, { ...t, unitId: this.id })) : [];
3281
+ return e ? Object.values(e).map((t) => this._injector.createInstance(T, { ...t, unitId: this.id })) : [];
3157
3282
  }
3158
3283
  /**
3159
3284
  * Insert a defined name.
@@ -3167,8 +3292,8 @@ let I = class extends p {
3167
3292
  * ```
3168
3293
  */
3169
3294
  insertDefinedName(e, t) {
3170
- const s = this._injector.createInstance(A).setName(e).setRef(t).build();
3171
- s.localSheetId = K, this.insertDefinedNameBuilder(s);
3295
+ const s = this._injector.createInstance(F).setName(e).setRef(t).build();
3296
+ s.localSheetId = q, this.insertDefinedNameBuilder(s);
3172
3297
  }
3173
3298
  /**
3174
3299
  * Delete the defined name with the given name.
@@ -3198,7 +3323,7 @@ let I = class extends p {
3198
3323
  * ```
3199
3324
  */
3200
3325
  insertDefinedNameBuilder(e) {
3201
- e.unitId = this.getId(), this._commandService.syncExecuteCommand(q.id, e);
3326
+ e.unitId = this.getId(), this._commandService.syncExecuteCommand(G.id, e);
3202
3327
  }
3203
3328
  /**
3204
3329
  * Update the defined name with the given name.
@@ -3210,70 +3335,180 @@ let I = class extends p {
3210
3335
  * const builder = activeSpreadsheet.getDefinedName('MyDefinedName').toBuilder();
3211
3336
  * builder.setRef('Sheet1!A2').setName('MyDefinedName1').build();
3212
3337
  * activeSpreadsheet.updateDefinedNameBuilder(param);
3213
- *
3214
3338
  * ```
3215
3339
  */
3216
3340
  updateDefinedNameBuilder(e) {
3217
- this._commandService.syncExecuteCommand(q.id, e);
3341
+ this._commandService.syncExecuteCommand(G.id, e);
3342
+ }
3343
+ /**
3344
+ * Gets the registered range themes.
3345
+ * @returns {string[]} The name list of registered range themes.
3346
+ * @example
3347
+ * ```ts
3348
+ * // The code below gets the registered range themes
3349
+ * const activeSpreadsheet = univerAPI.getActiveWorkbook();
3350
+ * const themes = activeSpreadsheet.getRegisteredRangeThemes();
3351
+ * console.log(themes);
3352
+ * ```
3353
+ */
3354
+ getRegisteredRangeThemes() {
3355
+ return this._injector.get(Ee).getRegisteredRangeThemes();
3356
+ }
3357
+ /**
3358
+ * Register a custom range theme style.
3359
+ * @example
3360
+ * ```ts
3361
+ * // import {RangeThemeStyle} from '@univerjs/sheets';
3362
+ * const fWorkbook = univerAPI.getActiveWorkbook();
3363
+ * const rangeThemeStyle = new RangeThemeStyle('MyTheme');
3364
+ * rangeThemeStyle.setSecondRowStyle({
3365
+ * bg: {
3366
+ * rgb: 'rgb(214,231,241)',
3367
+ * },
3368
+ * });
3369
+ * fWorkbook.registerRangeTheme(rangeThemeStyle);
3370
+ * ```
3371
+ */
3372
+ registerRangeTheme(e) {
3373
+ this._commandService.syncExecuteCommand(Pt.id, {
3374
+ unitId: this.getId(),
3375
+ rangeThemeStyle: e
3376
+ });
3377
+ }
3378
+ /**
3379
+ * Unregister a custom range theme style.
3380
+ * @example
3381
+ * ```ts
3382
+ * const fWorkbook = univerAPI.getActiveWorkbook();
3383
+ * fWorkbook.unregisterRangeTheme('MyTheme');
3384
+ * ```
3385
+ */
3386
+ unregisterRangeTheme(e) {
3387
+ this._commandService.syncExecuteCommand(Ut.id, {
3388
+ unitId: this.getId(),
3389
+ themeName: e
3390
+ });
3218
3391
  }
3219
3392
  };
3220
- I = Yt([
3221
- k(1, m(v)),
3222
- k(2, m(Oe)),
3223
- k(3, m(Ne)),
3224
- k(4, fe),
3225
- k(5, l),
3226
- k(6, Q),
3227
- k(7, Ce),
3228
- k(8, m(ke)),
3229
- k(9, Re)
3393
+ I = nn([
3394
+ S(1, m(v)),
3395
+ S(2, m(Oe)),
3396
+ S(3, m(Ne)),
3397
+ S(4, ve),
3398
+ S(5, l),
3399
+ S(6, J),
3400
+ S(7, Ie),
3401
+ S(8, m(Se)),
3402
+ S(9, De)
3230
3403
  ], I);
3231
- class Jt extends ve {
3404
+ class sn extends Re {
3405
+ _initialize(e) {
3406
+ const t = e.get(l);
3407
+ this.disposeWithMe(
3408
+ t.beforeCommandExecuted((n) => {
3409
+ var s;
3410
+ switch (n.id) {
3411
+ case U.id: {
3412
+ const r = n.params, { unitId: i, index: a, sheet: h } = r || {}, c = i ? this.getUniverSheet(i) : (s = this.getActiveWorkbook) == null ? void 0 : s.call(this);
3413
+ if (!c)
3414
+ return;
3415
+ const d = {
3416
+ workbook: c,
3417
+ index: a,
3418
+ sheet: h
3419
+ };
3420
+ if (this.fireEvent(
3421
+ this.Event.BeforeSheetCreate,
3422
+ d
3423
+ ), d.cancel)
3424
+ throw new Error("Sheet create canceled by facade api.");
3425
+ break;
3426
+ }
3427
+ }
3428
+ })
3429
+ ), this.disposeWithMe(
3430
+ t.onCommandExecuted((n) => {
3431
+ var s;
3432
+ switch (n.id) {
3433
+ case U.id: {
3434
+ const r = n.params, { unitId: i } = r || {}, a = i ? this.getUniverSheet(i) : (s = this.getActiveWorkbook) == null ? void 0 : s.call(this);
3435
+ if (!a)
3436
+ return;
3437
+ const h = a.getActiveSheet();
3438
+ if (!h)
3439
+ return;
3440
+ const c = {
3441
+ workbook: a,
3442
+ worksheet: h
3443
+ };
3444
+ this.fireEvent(
3445
+ this.Event.SheetCreated,
3446
+ c
3447
+ );
3448
+ break;
3449
+ }
3450
+ }
3451
+ })
3452
+ );
3453
+ }
3232
3454
  createUniverSheet(e) {
3233
- const n = this._injector.get(fe).createUnit(U.UNIVER_SHEET, e);
3455
+ const n = this._injector.get(ve).createUnit(P.UNIVER_SHEET, e);
3234
3456
  return this._injector.createInstance(I, n);
3235
3457
  }
3236
- getActiveWorkbook() {
3237
- const e = this._univerInstanceService.getCurrentUnitForType(U.UNIVER_SHEET);
3458
+ getActiveUniverSheet() {
3459
+ const e = this._univerInstanceService.getCurrentUnitForType(P.UNIVER_SHEET);
3238
3460
  return e ? this._injector.createInstance(I, e) : null;
3239
3461
  }
3462
+ getActiveWorkbook() {
3463
+ return this.getActiveUniverSheet();
3464
+ }
3240
3465
  getUniverSheet(e) {
3241
- const t = this._univerInstanceService.getUnit(e, U.UNIVER_SHEET);
3466
+ const t = this._univerInstanceService.getUnit(e, P.UNIVER_SHEET);
3242
3467
  return t ? this._injector.createInstance(I, t) : null;
3243
3468
  }
3244
3469
  getPermission() {
3245
- return this._injector.createInstance(O);
3470
+ return this._injector.createInstance(j);
3246
3471
  }
3247
3472
  onUniverSheetCreated(e) {
3248
- const t = this._univerInstanceService.getTypeOfUnitAdded$(U.UNIVER_SHEET).subscribe((n) => {
3473
+ const t = this._univerInstanceService.getTypeOfUnitAdded$(P.UNIVER_SHEET).subscribe((n) => {
3249
3474
  const s = this._injector.createInstance(I, n);
3250
3475
  e(s);
3251
3476
  });
3252
- return Ie(t);
3477
+ return fe(t);
3253
3478
  }
3254
3479
  newDefinedName() {
3255
- return this._injector.createInstance(A);
3480
+ return this._injector.createInstance(F);
3256
3481
  }
3257
3482
  }
3258
- ve.extend(Jt);
3259
- var Qt = Object.defineProperty, Xt = Object.getOwnPropertyDescriptor, Zt = (o, e, t, n) => {
3260
- for (var s = n > 1 ? void 0 : n ? Xt(e, t) : e, r = o.length - 1, i; r >= 0; r--)
3483
+ Re.extend(sn);
3484
+ class on extends be {
3485
+ get SheetCreated() {
3486
+ return "SheetCreated";
3487
+ }
3488
+ get BeforeSheetCreate() {
3489
+ return "BeforeSheetCreate";
3490
+ }
3491
+ }
3492
+ be.extend(on);
3493
+ var rn = Object.defineProperty, an = Object.getOwnPropertyDescriptor, hn = (o, e, t, n) => {
3494
+ for (var s = n > 1 ? void 0 : n ? an(e, t) : e, r = o.length - 1, i; r >= 0; r--)
3261
3495
  (i = o[r]) && (s = (n ? i(e, t, s) : i(s)) || s);
3262
- return n && s && Qt(e, t, s), s;
3263
- }, en = (o, e) => (t, n) => e(t, n, o);
3264
- let _e = class extends p {
3496
+ return n && s && rn(e, t, s), s;
3497
+ }, cn = (o, e) => (t, n) => e(t, n, o);
3498
+ let we = class extends Q {
3265
3499
  constructor(o) {
3266
3500
  super(), this._injector = o;
3267
3501
  }
3268
3502
  };
3269
- _e = Zt([
3270
- en(0, m(v))
3271
- ], _e);
3503
+ we = hn([
3504
+ cn(0, m(v))
3505
+ ], we);
3272
3506
  export {
3273
- O as FPermission,
3274
- S as FRange,
3275
- F as FSelection,
3276
- _e as FSheetHooks,
3507
+ j as FPermission,
3508
+ w as FRange,
3509
+ A as FSelection,
3510
+ on as FSheetEventName,
3511
+ we as FSheetHooks,
3277
3512
  I as FWorkbook,
3278
- _ as FWorksheet
3513
+ g as FWorksheet
3279
3514
  };