@univerjs/sheets 0.5.3 → 0.5.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/es/facade.js CHANGED
@@ -1,34 +1,34 @@
1
- var We = Object.defineProperty;
2
- var Te = (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) => Te(o, typeof e != "symbol" ? e + "" : e, t);
4
- import { Inject as m, Injector as v, IAuthzIoService as Se, LocaleService as ke, ICommandService as l, IPermissionService as J, generateRandomId as Ce, FBase as Q, Rectangle as E, HorizontalAlign as R, VerticalAlign as b, isFormulaString as Me, isCellV as je, isICellData as Ae, ObjectMatrix as T, 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 St, SetRangeValuesMutation as _e, SetWorksheetHideCommand as kt, 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, Tt = (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
- (i = o[r]) && (s = (n ? i(e, t, s) : i(s)) || s);
10
- return n && s && Dt(e, t, s), s;
11
- }, w = (o, e) => (t, n) => e(t, n, o);
12
- function Mt(o, e, t) {
13
- const n = t.getDefinedNameMap(o);
1
+ var Ae = Object.defineProperty;
2
+ var Fe = (s, e, t) => e in s ? Ae(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t;
3
+ var k = (s, e, t) => Fe(s, typeof e != "symbol" ? e + "" : e, t);
4
+ import { Inject as u, Injector as b, IAuthzIoService as ve, LocaleService as Re, ICommandService as l, IPermissionService as ee, generateRandomId as be, FBase as te, Rectangle as N, HorizontalAlign as y, VerticalAlign as U, isFormulaString as je, isCellV as Oe, isICellData as Ve, ObjectMatrix as A, Tools as Be, RANGE_TYPE as _, FBaseInitialable as ne, RichTextValue as p, BooleanNumber as m, WrapStrategy as oe, Dimension as ie, ILogService as pe, Registry as ye, toDisposable as F, Direction as D, IResourceLoaderService as Le, FEnum as ze, FEventName as se, mergeWorksheetSnapshotWithDefault as $e, UndoCommand as He, RedoCommand as Ge, UniverInstanceType as R, IUniverInstanceService as J, FUniver as Ue, CanceledError as qe } from "@univerjs/core";
5
+ import { WorksheetProtectionRuleModel as Ee, RangeProtectionRuleModel as Pe, WorksheetProtectionPointModel as xe, SetDefinedNameCommand as Q, SCOPE_WORKBOOK_VALUE_DEFINED_NAME as X, RemoveDefinedNameCommand as Ke, PermissionPointsDefinitions as Ye, WorkbookEditablePermission as Ne, UnitObject as E, AddWorksheetProtectionMutation as Je, DeleteWorksheetProtectionMutation as Qe, getAllWorksheetPermissionPoint as Xe, getAllWorksheetPermissionPointByPointPanel as ae, SetWorksheetPermissionPointsMutation as Ze, AddRangeProtectionMutation as et, DeleteRangeProtectionMutation as tt, SetRangeProtectionMutation as nt, WorksheetEditPermission as st, WorksheetViewPermission as rt, SetStyleCommand as f, SetRangeValuesCommand as P, SetTextWrapCommand as he, SetVerticalTextAlignCommand as ot, SetHorizontalTextAlignCommand as it, addMergeCellsUtil as $, getAddMergeMutationRangeByType as ce, RemoveWorksheetMergeCommand as at, SplitTextToColumnsCommand as ht, SetWorksheetRangeThemeStyleCommand as ct, DeleteWorksheetRangeThemeStyleCommand as dt, SheetRangeThemeService as Me, getPrimaryForRange as Z, SetSelectionsOperation as De, getNextPrimaryCell as ut, SheetsSelectionsService as We, SetWorksheetDefaultStyleMutation as mt, SetColDataCommand as de, SetRowDataCommand as ue, copyRangeStyles as W, InsertRowByRangeCommand as me, RemoveRowByRangeCommand as lt, MoveRowsCommand as gt, SetRowHiddenCommand as le, SetSpecificRowsVisibleCommand as ge, SetRowHeightCommand as _e, SetWorksheetRowIsAutoHeightCommand as _t, InsertColByRangeCommand as we, RemoveColByRangeCommand as wt, MoveColsCommand as kt, SetColHiddenCommand as ke, SetSpecificColsVisibleCommand as Se, SetColWidthCommand as St, SetFrozenCommand as H, CancelFrozenCommand as Ct, ToggleGridlinesCommand as It, SetGridlinesColorCommand as ft, SetTabColorCommand as vt, SetRangeValuesMutation as Ce, SetWorksheetHideCommand as Rt, SetWorksheetShowCommand as bt, SetWorksheetNameCommand as pt, ClearSelectionAllCommand as yt, ClearSelectionContentCommand as Ut, ClearSelectionFormatCommand as Et, InsertSheetCommand as x, SetWorksheetActiveOperation as G, RemoveSheetCommand as Pt, CopySheetCommand as xt, SetWorksheetOrderCommand as Nt, RegisterWorksheetRangeThemeStyleCommand as Mt, UnregisterWorksheetRangeThemeStyleCommand as Dt } from "@univerjs/sheets";
6
+ import { IDefinedNamesService as Te, serializeRange as re, FormulaDataModel as Wt, serializeRangeWithSheet as Tt, deserializeRangeWithSheet as At } from "@univerjs/engine-formula";
7
+ var Ft = Object.defineProperty, jt = Object.getOwnPropertyDescriptor, Ot = (s, e, t, n) => {
8
+ for (var r = n > 1 ? void 0 : n ? jt(e, t) : e, o = s.length - 1, i; o >= 0; o--)
9
+ (i = s[o]) && (r = (n ? i(e, t, r) : i(r)) || r);
10
+ return n && r && Ft(e, t, r), r;
11
+ }, S = (s, e) => (t, n) => e(t, n, s);
12
+ function Vt(s, e, t) {
13
+ const n = t.getDefinedNameMap(s);
14
14
  if (n == null)
15
15
  return e.t("definedName.defaultName") + 1;
16
- const r = Array.from(Object.values(n)).length + 1, i = e.t("definedName.defaultName") + r;
17
- if (t.getValueByName(o, i) == null)
16
+ const o = Array.from(Object.values(n)).length + 1, i = e.t("definedName.defaultName") + o;
17
+ if (t.getValueByName(s, i) == null)
18
18
  return i;
19
- let a = r + 1;
19
+ let a = o + 1;
20
20
  for (; ; ) {
21
21
  const h = e.t("definedName.defaultName") + a;
22
- if (t.getValueByName(o, h) == null)
22
+ if (t.getValueByName(s, h) == null)
23
23
  return h;
24
24
  a++;
25
25
  }
26
26
  }
27
- class F {
27
+ class L {
28
28
  constructor() {
29
- p(this, "_definedNameParam");
29
+ k(this, "_definedNameParam");
30
30
  this._definedNameParam = {
31
- id: Ce(10),
31
+ id: be(10),
32
32
  unitId: "",
33
33
  name: "",
34
34
  formulaOrRefString: ""
@@ -36,12 +36,12 @@ class F {
36
36
  }
37
37
  /**
38
38
  * Sets the name of the defined name builder.
39
- * @param name The name of the defined name.
40
- * @returns The defined name builder.
39
+ * @param {string} name The name of the defined name.
40
+ * @returns {FDefinedNameBuilder} The defined name builder.
41
41
  * @example
42
42
  * ```ts
43
- * const workbook = UniverAPI.getActiveWorkbook();
44
- * const definedNameBuilder = UniverAPI.newDefinedName()
43
+ * const workbook = univerAPI.getActiveWorkbook();
44
+ * const definedNameBuilder = univerAPI.newDefinedName()
45
45
  * .setName('MyDefinedName')
46
46
  * .build();
47
47
  * workbook.insertDefinedNameBuilder(definedNameBuilder);
@@ -52,12 +52,12 @@ class F {
52
52
  }
53
53
  /**
54
54
  * Sets the formula of the defined name builder.
55
- * @param formula The formula of the defined name.
56
- * @returns The defined name builder.
55
+ * @param {string }formula The formula of the defined name.
56
+ * @returns {FDefinedNameBuilder} The defined name builder.
57
57
  * @example
58
58
  * ```ts
59
- * const workbook = UniverAPI.getActiveWorkbook();
60
- * const definedNameBuilder = UniverAPI.newDefinedName()
59
+ * const workbook = univerAPI.getActiveWorkbook();
60
+ * const definedNameBuilder = univerAPI.newDefinedName()
61
61
  * .setFormula('SUM(Sheet1!$A$1)')
62
62
  * .setName('MyDefinedName')
63
63
  * .build();
@@ -69,12 +69,12 @@ class F {
69
69
  }
70
70
  /**
71
71
  * Sets the reference of the defined name builder.
72
- * @param refString The reference of the defined name.
73
- * @returns The defined name builder.
72
+ * @param {string} a1Notation The reference of the defined name.
73
+ * @returns {FDefinedNameBuilder} The defined name builder.
74
74
  * @example
75
75
  * ```ts
76
- * const workbook = UniverAPI.getActiveWorkbook();
77
- * const definedNameBuilder = UniverAPI.newDefinedName()
76
+ * const workbook = univerAPI.getActiveWorkbook();
77
+ * const definedNameBuilder = univerAPI.newDefinedName()
78
78
  * .setRef('Sheet1!$A$1')
79
79
  * .build();
80
80
  * workbook.insertDefinedNameBuilder(definedNameBuilder);
@@ -85,36 +85,36 @@ class F {
85
85
  }
86
86
  /**
87
87
  * Sets the reference of the defined name builder by range .
88
- * @param row The start row of the range.
89
- * @param column The start column of the range.
90
- * @param numRows The number of rows in the range.
91
- * @param numColumns The number of columns in the range.
92
- * @returns The defined name builder.
88
+ * @param {number} row The start row of the range.
89
+ * @param {number} column The start column of the range.
90
+ * @param {number} numRows The number of rows in the range.
91
+ * @param {number} numColumns The number of columns in the range.
92
+ * @returns {FDefinedNameBuilder} The defined name builder.
93
93
  * @example
94
94
  * ```ts
95
- * const workbook = UniverAPI.getActiveWorkbook();
96
- * const definedNameBuilder = UniverAPI.newDefinedName()
95
+ * const workbook = univerAPI.getActiveWorkbook();
96
+ * const definedNameBuilder = univerAPI.newDefinedName()
97
97
  * .setRefByRange(1, 3, 2, 5)
98
98
  * .build();
99
99
  * workbook.insertDefinedNameBuilder(definedNameBuilder);
100
100
  * ```
101
101
  */
102
- setRefByRange(e, t, n, s) {
103
- return this._definedNameParam.formulaOrRefString = Z({
102
+ setRefByRange(e, t, n, r) {
103
+ return this._definedNameParam.formulaOrRefString = re({
104
104
  startRow: e,
105
105
  endRow: e + (n != null ? n : 1) - 1,
106
106
  startColumn: t,
107
- endColumn: t + (s != null ? s : 1) - 1
107
+ endColumn: t + (r != null ? r : 1) - 1
108
108
  }), this;
109
109
  }
110
110
  /**
111
111
  * Sets the comment of the defined name builder.
112
- * @param comment The comment of the defined name.
113
- * @returns The defined name builder.
112
+ * @param {string} comment The comment of the defined name.
113
+ * @returns {FDefinedNameBuilder} The defined name builder.
114
114
  * @example
115
115
  * ```ts
116
- * const workbook = UniverAPI.getActiveWorkbook();
117
- * const definedNameBuilder = UniverAPI.newDefinedName()
116
+ * const workbook = univerAPI.getActiveWorkbook();
117
+ * const definedNameBuilder = univerAPI.newDefinedName()
118
118
  * .setComment('This is a comment')
119
119
  * .build();
120
120
  * workbook.insertDefinedNameBuilder(definedNameBuilder);
@@ -125,12 +125,12 @@ class F {
125
125
  }
126
126
  /**
127
127
  * Sets the hidden status of the defined name builder.
128
- * @param hidden The hidden status of the defined name.
129
- * @returns The defined name builder.
128
+ * @param {boolean} hidden The hidden status of the defined name.
129
+ * @returns {FDefinedNameBuilder} The defined name builder.
130
130
  * @example
131
131
  * ```ts
132
- * const workbook = UniverAPI.getActiveWorkbook();
133
- * const definedNameBuilder = UniverAPI.newDefinedName()
132
+ * const workbook = univerAPI.getActiveWorkbook();
133
+ * const definedNameBuilder = univerAPI.newDefinedName()
134
134
  * .setHidden(true)
135
135
  * .build();
136
136
  * workbook.insertDefinedNameBuilder(definedNameBuilder);
@@ -141,11 +141,11 @@ class F {
141
141
  }
142
142
  /**
143
143
  * Builds the defined name.
144
- * @returns The defined name mutation parameter.
144
+ * @returns {FDefinedNameBuilder} The defined name mutation parameter.
145
145
  * @example
146
146
  * ```ts
147
- * const workbook = UniverAPI.getActiveWorkbook();
148
- * const definedNameBuilder = UniverAPI.newDefinedName()
147
+ * const workbook = univerAPI.getActiveWorkbook();
148
+ * const definedNameBuilder = univerAPI.newDefinedName()
149
149
  * .setRef('Sheet1!$A$1')
150
150
  * .setName('MyDefinedName')
151
151
  * .build();
@@ -159,19 +159,19 @@ class F {
159
159
  return this._definedNameParam = e, this;
160
160
  }
161
161
  }
162
- let M = class extends Q {
163
- constructor(o, e, t, n, s, r, i, a, h, c) {
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;
162
+ let j = class extends te {
163
+ constructor(s, e, t, n, r, o, i, a, h, c) {
164
+ super(), this._definedNameParam = s, this._injector = e, this._commandService = t, this._permissionService = n, this._worksheetProtectionRuleModel = r, this._rangeProtectionRuleModel = o, this._worksheetProtectionPointRuleModel = i, this._authzIoService = a, this._localeService = h, this._definedNamesService = c;
165
165
  }
166
166
  _apply() {
167
- this._definedNameParam.name === "" && (this._definedNameParam.name = Mt(this._definedNameParam.unitId, this._localeService, this._definedNamesService)), this._commandService.syncExecuteCommand(G.id, this._definedNameParam);
167
+ this._definedNameParam.name === "" && (this._definedNameParam.name = Vt(this._definedNameParam.unitId, this._localeService, this._definedNamesService)), this._commandService.syncExecuteCommand(Q.id, this._definedNameParam);
168
168
  }
169
169
  /**
170
170
  * Gets the name of the defined name.
171
- * @returns The name of the defined name.
171
+ * @returns {string} The name of the defined name.
172
172
  * @example
173
173
  * ```ts
174
- * const workbook = UniverAPI.getActiveWorkbook();
174
+ * const workbook = univerAPI.getActiveWorkbook();
175
175
  * const definedName = workbook.getDefinedNames[0];
176
176
  * console.log(definedName.getName());
177
177
  * ```
@@ -181,49 +181,49 @@ let M = class extends Q {
181
181
  }
182
182
  /**
183
183
  * Sets the name of the defined name.
184
- * @param name The name of the defined name.
184
+ * @param {string} name The name of the defined name.
185
185
  * @example
186
186
  * ```ts
187
- * const workbook = UniverAPI.getActiveWorkbook();
187
+ * const workbook = univerAPI.getActiveWorkbook();
188
188
  * const definedName = workbook.getDefinedName('MyDefinedName');
189
189
  * definedName.setName('NewDefinedName');
190
190
  * ```
191
191
  */
192
- setName(o) {
193
- this._definedNameParam.name = o, this._apply();
192
+ setName(s) {
193
+ this._definedNameParam.name = s, this._apply();
194
194
  }
195
195
  /**
196
196
  * Sets the formula of the defined name.
197
- * @param formula The formula of the defined name.
197
+ * @param {string} formula The formula of the defined name.
198
198
  * @example
199
199
  * ```ts
200
- * const workbook = UniverAPI.getActiveWorkbook();
200
+ * const workbook = univerAPI.getActiveWorkbook();
201
201
  * const definedName = workbook.getDefinedName('MyDefinedName');
202
202
  * definedName.setFormula('SUM(Sheet1!$A$1)');
203
203
  * ```
204
204
  */
205
- setFormula(o) {
206
- this._definedNameParam.formulaOrRefString = `=${o}`, this._apply();
205
+ setFormula(s) {
206
+ this._definedNameParam.formulaOrRefString = `=${s}`, this._apply();
207
207
  }
208
208
  /**
209
209
  * Sets the reference of the defined name.
210
- * @param refString The reference of the defined name.
210
+ * @param {string} refString The reference of the defined name.
211
211
  * @example
212
212
  * ```ts
213
- * const workbook = UniverAPI.getActiveWorkbook();
213
+ * const workbook = univerAPI.getActiveWorkbook();
214
214
  * const definedName = workbook.getDefinedNames[0];
215
215
  * definedName.setRef('Sheet1!$A$1');
216
216
  * ```
217
217
  */
218
- setRef(o) {
219
- this._definedNameParam.formulaOrRefString = o, this._apply();
218
+ setRef(s) {
219
+ this._definedNameParam.formulaOrRefString = s, this._apply();
220
220
  }
221
221
  /**
222
222
  * Gets the reference of the defined name.
223
- * @returns The reference of the defined name.
223
+ * @returns {string} The reference of the defined name.
224
224
  * @example
225
225
  * ```ts
226
- * const workbook = UniverAPI.getActiveWorkbook();
226
+ * const workbook = univerAPI.getActiveWorkbook();
227
227
  * const definedName = workbook.getDefinedNames[0];
228
228
  * console.log(definedName.getFormulaOrRefString());
229
229
  * ```
@@ -233,31 +233,31 @@ let M = class extends Q {
233
233
  }
234
234
  /**
235
235
  * Sets the reference of the defined name by range.
236
- * @param row The start row of the range.
237
- * @param column The start column of the range.
238
- * @param numRows The number of rows in the range.
239
- * @param numColumns The number of columns in the range.
236
+ * @param {number} row The start row of the range.
237
+ * @param {number} column The start column of the range.
238
+ * @param {number} numRows The number of rows in the range.
239
+ * @param {number} numColumns The number of columns in the range.
240
240
  * @example
241
241
  * ```ts
242
- * const workbook = UniverAPI.getActiveWorkbook();
242
+ * const workbook = univerAPI.getActiveWorkbook();
243
243
  * const definedName = workbook.getDefinedNames[0];
244
244
  * definedName.setRefByRange(1, 3, 2, 5);
245
245
  * ```
246
246
  */
247
- setRefByRange(o, e, t, n) {
248
- this._definedNameParam.formulaOrRefString = Z({
249
- startRow: o,
250
- endRow: o + (t != null ? t : 1) - 1,
247
+ setRefByRange(s, e, t, n) {
248
+ this._definedNameParam.formulaOrRefString = re({
249
+ startRow: s,
250
+ endRow: s + (t != null ? t : 1) - 1,
251
251
  startColumn: e,
252
252
  endColumn: e + (n != null ? n : 1) - 1
253
253
  }), this._apply();
254
254
  }
255
255
  /**
256
256
  * Gets the comment of the defined name.
257
- * @returns The comment of the defined name.
257
+ * @returns {string | undefined} The comment of the defined name.
258
258
  * @example
259
259
  * ```ts
260
- * const workbook = UniverAPI.getActiveWorkbook();
260
+ * const workbook = univerAPI.getActiveWorkbook();
261
261
  * const definedName = workbook.getDefinedNames[0];
262
262
  * console.log(definedName.getComment());
263
263
  * ```
@@ -267,74 +267,74 @@ let M = class extends Q {
267
267
  }
268
268
  /**
269
269
  * Sets the comment of the defined name.
270
- * @param comment The comment of the defined name.
270
+ * @param {string} comment The comment of the defined name.
271
271
  * @example
272
272
  * ```ts
273
- * const workbook = UniverAPI.getActiveWorkbook();
273
+ * const workbook = univerAPI.getActiveWorkbook();
274
274
  * const definedName = workbook.getDefinedNames[0];
275
275
  * definedName.setComment('This is a comment');
276
276
  * ```
277
277
  */
278
- setComment(o) {
279
- this._definedNameParam.comment = o, this._apply();
278
+ setComment(s) {
279
+ this._definedNameParam.comment = s, this._apply();
280
280
  }
281
281
  /**
282
282
  * Sets the scope of the defined name to the worksheet.
283
- * @param worksheet The worksheet to set the scope to.
283
+ * @param {FWorksheet} worksheet The worksheet to set the scope to.
284
284
  * @example
285
285
  * ```ts
286
- * const workbook = UniverAPI.getActiveWorkbook();
286
+ * const workbook = univerAPI.getActiveWorkbook();
287
287
  * const worksheet = workbook.getWorksheets[0];
288
288
  * const definedName = workbook.getDefinedNames[0];
289
289
  * definedName.setScopeToWorksheet(worksheet);
290
290
  * ```
291
291
  */
292
- setScopeToWorksheet(o) {
293
- this._definedNameParam.localSheetId = o.getSheetId(), this._apply();
292
+ setScopeToWorksheet(s) {
293
+ this._definedNameParam.localSheetId = s.getSheetId(), this._apply();
294
294
  }
295
295
  /**
296
296
  * Sets the scope of the defined name to the workbook.
297
297
  * @example
298
298
  * ```ts
299
- * const workbook = UniverAPI.getActiveWorkbook();
299
+ * const workbook = univerAPI.getActiveWorkbook();
300
300
  * const definedName = workbook.getDefinedNames[0];
301
301
  * definedName.setScopeToWorkbook();
302
302
  * ```
303
303
  */
304
304
  setScopeToWorkbook() {
305
- this._definedNameParam.localSheetId = q, this._apply();
305
+ this._definedNameParam.localSheetId = X, this._apply();
306
306
  }
307
307
  /**
308
308
  * Sets the hidden status of the defined name.
309
- * @param hidden The hidden status of the defined name.
309
+ * @param {boolean} hidden The hidden status of the defined name.
310
310
  * @example
311
311
  * ```ts
312
- * const workbook = UniverAPI.getActiveWorkbook();
312
+ * const workbook = univerAPI.getActiveWorkbook();
313
313
  * const definedName = workbook.getDefinedNames[0];
314
314
  * definedName.setHidden(true);
315
315
  * ```
316
316
  */
317
- setHidden(o) {
318
- this._definedNameParam.hidden = o, this._apply();
317
+ setHidden(s) {
318
+ this._definedNameParam.hidden = s, this._apply();
319
319
  }
320
320
  /**
321
321
  * Deletes the defined name.
322
322
  * @example
323
323
  * ```ts
324
- * const workbook = UniverAPI.getActiveWorkbook();
324
+ * const workbook = univerAPI.getActiveWorkbook();
325
325
  * const definedName = workbook.getDefinedNames[0];
326
326
  * definedName.delete();
327
327
  * ```
328
328
  */
329
329
  delete() {
330
- this._commandService.syncExecuteCommand(Ve.id, this._definedNameParam);
330
+ this._commandService.syncExecuteCommand(Ke.id, this._definedNameParam);
331
331
  }
332
332
  /**
333
333
  * Gets the local sheet id of the defined name.
334
- * @returns The local sheet id of the defined name.
334
+ * @returns {string | undefined} The local sheet id of the defined name.
335
335
  * @example
336
336
  * ```ts
337
- * const workbook = UniverAPI.getActiveWorkbook();
337
+ * const workbook = univerAPI.getActiveWorkbook();
338
338
  * const definedName = workbook.getDefinedNames[0];
339
339
  * console.log(definedName.getLocalSheetId());
340
340
  * ```
@@ -344,23 +344,23 @@ let M = class extends Q {
344
344
  }
345
345
  /**
346
346
  * Checks if the defined name is in the workbook scope.
347
- * @returns True if the defined name is in the workbook scope, false otherwise.
347
+ * @returns {boolean} True if the defined name is in the workbook scope, false otherwise.
348
348
  * @example
349
349
  * ```ts
350
- * const workbook = UniverAPI.getActiveWorkbook();
350
+ * const workbook = univerAPI.getActiveWorkbook();
351
351
  * const definedName = workbook.getDefinedNames[0];
352
352
  * console.log(definedName.isWorkbookScope());
353
353
  * ```
354
354
  */
355
355
  isWorkbookScope() {
356
- return this._definedNameParam.localSheetId === q;
356
+ return this._definedNameParam.localSheetId === X;
357
357
  }
358
358
  /**
359
359
  * Converts the defined name to a defined name builder.
360
- * @returns The defined name builder.
360
+ * @returns {FDefinedNameBuilder} The defined name builder.
361
361
  * @example
362
362
  * ```ts
363
- * const workbook = UniverAPI.getActiveWorkbook();
363
+ * const workbook = univerAPI.getActiveWorkbook();
364
364
  * const definedName = workbook.getDefinedNames[0];
365
365
  * const definedNameBuilder = definedName.toBuilder();
366
366
  * const param definedNameBuilder.setName('NewDefinedName').setFormula('SUM(Sheet1!$A$1)').build();
@@ -368,70 +368,66 @@ let M = class extends Q {
368
368
  * ```
369
369
  */
370
370
  toBuilder() {
371
- const o = this._injector.createInstance(F);
372
- return o.load(this._definedNameParam), o;
371
+ const s = this._injector.createInstance(L);
372
+ return s.load(this._definedNameParam), s;
373
373
  }
374
374
  };
375
- M = Tt([
376
- w(1, m(v)),
377
- w(2, l),
378
- w(3, J),
379
- w(4, m(pe)),
380
- w(5, m(ye)),
381
- w(6, m(Pe)),
382
- w(7, m(Se)),
383
- w(8, m(ke)),
384
- w(9, De)
385
- ], M);
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
- (i = o[r]) && (s = (n ? i(e, t, s) : i(s)) || s);
389
- return n && s && jt(e, t, s), s;
390
- }, f = (o, e) => (t, n) => e(t, n, o);
391
- let j = class extends Q {
392
- constructor(e, t, n, s, r, i, a) {
375
+ j = Ot([
376
+ S(1, u(b)),
377
+ S(2, l),
378
+ S(3, ee),
379
+ S(4, u(Ee)),
380
+ S(5, u(Pe)),
381
+ S(6, u(xe)),
382
+ S(7, u(ve)),
383
+ S(8, u(Re)),
384
+ S(9, Te)
385
+ ], j);
386
+ var Bt = Object.defineProperty, Lt = Object.getOwnPropertyDescriptor, zt = (s, e, t, n) => {
387
+ for (var r = n > 1 ? void 0 : n ? Lt(e, t) : e, o = s.length - 1, i; o >= 0; o--)
388
+ (i = s[o]) && (r = (n ? i(e, t, r) : i(r)) || r);
389
+ return n && r && Bt(e, t, r), r;
390
+ }, v = (s, e) => (t, n) => e(t, n, s);
391
+ let O = class extends te {
392
+ constructor(e, t, n, r, o, i, a) {
393
393
  super();
394
- p(this, "permissionPointsDefinition", He);
395
- this._injector = e, this._commandService = t, this._permissionService = n, this._worksheetProtectionRuleModel = s, this._rangeProtectionRuleModel = r, this._worksheetProtectionPointRuleModel = i, this._authzIoService = a;
394
+ k(this, "permissionPointsDefinition", Ye);
395
+ k(this, "rangeRuleChangedAfterAuth$");
396
+ k(this, "sheetRuleChangedAfterAuth$");
397
+ this._injector = e, this._commandService = t, this._permissionService = n, this._worksheetProtectionRuleModel = r, this._rangeProtectionRuleModel = o, this._worksheetProtectionPointRuleModel = i, this._authzIoService = a, this.rangeRuleChangedAfterAuth$ = this._rangeProtectionRuleModel.ruleRefresh$, this.sheetRuleChangedAfterAuth$ = this._worksheetProtectionRuleModel.ruleRefresh$;
396
398
  }
397
399
  /**
398
400
  * Configures a specific permission point for a workbook.
399
401
  *
400
402
  * This function sets or updates a permission point for a workbook identified by `unitId`.
401
403
  * It creates a new permission point if it does not already exist, and updates the point with the provided value.
402
- *
403
404
  * @param {string} unitId - The unique identifier of the workbook for which the permission is being set.
404
405
  * @param {WorkbookPermissionPointConstructor} FPointClass - The constructor function for creating a permission point instance. Other point constructors can See the [permission-point documentation](https://github.com/dream-num/univer/tree/dev/packages/sheets/src/services/permission/permission-point) for more details.
405
406
  * @param {boolean} value - The boolean value to determine whether the permission point is enabled or disabled.
406
- *
407
407
  */
408
408
  setWorkbookPermissionPoint(e, t, n) {
409
- const s = new t(e);
410
- this._permissionService.getPermissionPoint(s.id) || this._permissionService.addPermissionPoint(s), this._permissionService.updatePermissionPoint(s.id, n);
409
+ const r = new t(e);
410
+ this._permissionService.getPermissionPoint(r.id) || this._permissionService.addPermissionPoint(r), this._permissionService.updatePermissionPoint(r.id, n);
411
411
  }
412
412
  /**
413
413
  * This function is used to set whether the workbook can be edited
414
- *
415
414
  * @param {string} unitId - The unique identifier of the workbook for which the permission is being set.
416
415
  * @param {boolean} value - A value that controls whether the workbook can be edited
417
- *
418
416
  */
419
417
  setWorkbookEditPermission(e, t) {
420
- this.setWorkbookPermissionPoint(e, Ue, t);
418
+ this.setWorkbookPermissionPoint(e, Ne, t);
421
419
  }
422
420
  /**
423
421
  * This function is used to add a base permission for a worksheet.
424
- *
425
422
  * @param {string} unitId - The unique identifier of the workbook for which the permission is being set.
426
423
  * @param {string} subUnitId - The unique identifier of the worksheet for which the permission is being set.
427
- *
428
424
  * @returns {Promise<string | undefined>} - Returns the `permissionId` if the permission is successfully added. If the operation fails or no result is returned, it resolves to `undefined`.
429
425
  */
430
426
  async addWorksheetBasePermission(e, t) {
431
427
  if (this._rangeProtectionRuleModel.getSubunitRuleList(e, t).length > 0)
432
428
  throw new Error("sheet protection cannot intersect with range protection");
433
- const s = await this._authzIoService.create({
434
- objectType: y.Worksheet,
429
+ const r = await this._authzIoService.create({
430
+ objectType: E.Worksheet,
435
431
  worksheetObject: {
436
432
  collaborators: [],
437
433
  unitID: e,
@@ -440,51 +436,48 @@ let j = class extends Q {
440
436
  scope: void 0
441
437
  }
442
438
  });
443
- if (this._commandService.syncExecuteCommand($e.id, {
439
+ if (this._commandService.syncExecuteCommand(Je.id, {
444
440
  unitId: e,
445
441
  subUnitId: t,
446
442
  rule: {
447
- permissionId: s,
448
- unitType: y.Worksheet,
443
+ permissionId: r,
444
+ unitType: E.Worksheet,
449
445
  unitId: e,
450
446
  subUnitId: t
451
447
  }
452
448
  }))
453
- return s;
449
+ return r;
454
450
  }
455
451
  /**
456
452
  * Delete the entire table protection set for the worksheet and reset the point permissions of the worksheet to true
457
- *
458
453
  * @param {string} unitId - The unique identifier of the workbook for which the permission is being set.
459
454
  * @param {string} subUnitId - The unique identifier of the worksheet for which the permission is being set.
460
455
  */
461
456
  removeWorksheetPermission(e, t) {
462
- this._commandService.syncExecuteCommand(Ge.id, {
457
+ this._commandService.syncExecuteCommand(Qe.id, {
463
458
  unitId: e,
464
459
  subUnitId: t
465
- }), [...qe(), ...ne()].forEach((n) => {
466
- const s = new n(e, t);
467
- this._permissionService.updatePermissionPoint(s.id, !0);
460
+ }), [...Xe(), ...ae()].forEach((n) => {
461
+ const r = new n(e, t);
462
+ this._permissionService.updatePermissionPoint(r.id, !0);
468
463
  }), this._worksheetProtectionPointRuleModel.deleteRule(e, t);
469
464
  }
470
465
  /**
471
466
  * Sets the worksheet permission point by updating or adding the permission point for the worksheet.
472
467
  * If the worksheet doesn't have a base permission, it creates one to used render
473
- *
474
468
  * @param {string} unitId - The unique identifier of the workbook.
475
469
  * @param {string} subUnitId - The unique identifier of the worksheet.
476
470
  * @param {WorkSheetPermissionPointConstructor} FPointClass - The constructor for the permission point class.
477
471
  * See the [permission-point documentation](https://github.com/dream-num/univer/tree/dev/packages/sheets/src/services/permission/permission-point) for more details.
478
472
  * @param {boolean} value - The new permission value to be set for the worksheet.
479
- *
480
473
  * @returns {Promise<string | undefined>} - Returns the `permissionId` if the permission point is successfully set or created. If no permission is set, it resolves to `undefined`.
481
474
  */
482
- async setWorksheetPermissionPoint(e, t, n, s) {
483
- const r = this._worksheetProtectionRuleModel.getRule(e, t);
475
+ async setWorksheetPermissionPoint(e, t, n, r) {
476
+ const o = this._worksheetProtectionRuleModel.getRule(e, t);
484
477
  let i;
485
- if (n === Xe || n === Ze)
486
- if (r)
487
- i = r.permissionId;
478
+ if (n === st || n === rt)
479
+ if (o)
480
+ i = o.permissionId;
488
481
  else {
489
482
  if (this._rangeProtectionRuleModel.getSubunitRuleList(e, t).length > 0)
490
483
  throw new Error("sheet protection cannot intersect with range protection");
@@ -493,7 +486,7 @@ let j = class extends Q {
493
486
  else {
494
487
  const d = this._worksheetProtectionPointRuleModel.getRule(e, t);
495
488
  d ? i = d.permissionId : (i = await this._authzIoService.create({
496
- objectType: y.Worksheet,
489
+ objectType: E.Worksheet,
497
490
  worksheetObject: {
498
491
  collaborators: [],
499
492
  unitID: e,
@@ -501,71 +494,67 @@ let j = class extends Q {
501
494
  name: "",
502
495
  scope: void 0
503
496
  }
504
- }), this._commandService.executeCommand(Ke.id, { unitId: e, subUnitId: t, permissionId: i }));
497
+ }), this._commandService.executeCommand(Ze.id, { unitId: e, subUnitId: t, permissionId: i }));
505
498
  }
506
499
  const h = new n(e, t);
507
- return this._permissionService.getPermissionPoint(h.id) || this._permissionService.addPermissionPoint(h), this._permissionService.updatePermissionPoint(h.id, s), i;
500
+ return this._permissionService.getPermissionPoint(h.id) || this._permissionService.addPermissionPoint(h), this._permissionService.updatePermissionPoint(h.id, r), i;
508
501
  }
509
502
  /**
510
503
  * Adds a range protection to the worksheet.
511
- *
512
504
  * @param {string} unitId - The unique identifier of the workbook.
513
505
  * @param {string} subUnitId - The unique identifier of the worksheet.
514
506
  * @param {IRange[]} ranges - The ranges to be protected.
515
- *
516
507
  * @returns {Promise<{ permissionId: string, ruleId: string } | undefined>} - Returns an object containing the `permissionId` and `ruleId` if the range protection is successfully added. If the operation fails or no result is returned, it resolves to `undefined`. permissionId is used to stitch permission point ID,ruleId is used to store permission rules
517
508
  */
518
509
  async addRangeBaseProtection(e, t, n) {
519
- const s = await this._authzIoService.create({
520
- objectType: y.SelectRange,
510
+ const r = await this._authzIoService.create({
511
+ objectType: E.SelectRange,
521
512
  selectRangeObject: {
522
513
  collaborators: [],
523
514
  unitID: e,
524
515
  name: "",
525
516
  scope: void 0
526
517
  }
527
- }), r = `ruleId_${Ce(6)}`;
518
+ }), o = `ruleId_${be(6)}`;
528
519
  if (this._worksheetProtectionRuleModel.getRule(e, t))
529
520
  throw new Error("sheet protection cannot intersect with range protection");
530
- if (this._rangeProtectionRuleModel.getSubunitRuleList(e, t).some((d) => d.ranges.some((O) => n.some((x) => E.intersects(x, O)))))
521
+ if (this._rangeProtectionRuleModel.getSubunitRuleList(e, t).some((d) => d.ranges.some((z) => n.some((M) => N.intersects(M, z)))))
531
522
  throw new Error("range protection cannot intersect");
532
- if (this._commandService.syncExecuteCommand(Ye.id, {
523
+ if (this._commandService.syncExecuteCommand(et.id, {
533
524
  unitId: e,
534
525
  subUnitId: t,
535
526
  rules: [{
536
- permissionId: s,
537
- unitType: y.SelectRange,
527
+ permissionId: r,
528
+ unitType: E.SelectRange,
538
529
  unitId: e,
539
530
  subUnitId: t,
540
531
  ranges: n,
541
- id: r
532
+ id: o
542
533
  }]
543
534
  }))
544
535
  return {
545
- permissionId: s,
546
- ruleId: r
536
+ permissionId: r,
537
+ ruleId: o
547
538
  };
548
539
  }
549
540
  /**
550
541
  * Removes the range protection from the worksheet.
551
- *
552
542
  * @param {string} unitId - The unique identifier of the workbook.
553
543
  * @param {string} subUnitId - The unique identifier of the worksheet.
554
544
  * @param {string[]} ruleIds - The rule IDs of the range protection to be removed.
555
545
  */
556
546
  removeRangeProtection(e, t, n) {
557
- this._commandService.syncExecuteCommand(Je.id, {
547
+ this._commandService.syncExecuteCommand(tt.id, {
558
548
  unitId: e,
559
549
  subUnitId: t,
560
550
  ruleIds: n
561
- }) && this._rangeProtectionRuleModel.getSubunitRuleList(e, t).length === 0 && (this._worksheetProtectionPointRuleModel.deleteRule(e, t), [...ne()].forEach((i) => {
551
+ }) && this._rangeProtectionRuleModel.getSubunitRuleList(e, t).length === 0 && (this._worksheetProtectionPointRuleModel.deleteRule(e, t), [...ae()].forEach((i) => {
562
552
  const a = new i(e, t);
563
553
  this._permissionService.updatePermissionPoint(a.id, a.value);
564
554
  }));
565
555
  }
566
556
  /**
567
557
  * Modify the permission points of a custom area
568
- *
569
558
  * @param {string} unitId - The unique identifier of the workbook.
570
559
  * @param {string} subUnitId - The unique identifier of the worksheet within the workbook.
571
560
  * @param {string} permissionId - The unique identifier of the permission that controls access to the range.
@@ -573,9 +562,9 @@ let j = class extends Q {
573
562
  * See the [permission-point documentation](https://github.com/dream-num/univer/tree/dev/packages/sheets/src/services/permission/permission-point) for more details.
574
563
  * @param {boolean} value - The new permission value to be set for the range (e.g., true for allowing access, false for restricting access).
575
564
  */
576
- setRangeProtectionPermissionPoint(e, t, n, s, r) {
577
- const i = new s(e, t, n);
578
- this._permissionService.getPermissionPoint(i.id) || this._permissionService.addPermissionPoint(i), this._permissionService.updatePermissionPoint(i.id, r);
565
+ setRangeProtectionPermissionPoint(e, t, n, r, o) {
566
+ const i = new r(e, t, n);
567
+ this._permissionService.getPermissionPoint(i.id) || this._permissionService.addPermissionPoint(i), this._permissionService.updatePermissionPoint(i.id, o);
579
568
  }
580
569
  /**
581
570
  * Sets the ranges for range protection in a worksheet.
@@ -583,286 +572,425 @@ let j = class extends Q {
583
572
  * This method finds the rule by unitId, subUnitId, and ruleId, and updates the rule with the provided ranges.
584
573
  * It checks for overlaps with existing ranges in the same subunit and shows an error message if any overlap is detected.
585
574
  * If no overlap is found, it executes the command to update the range protection with the new ranges.
586
- *
587
575
  * @param {string} unitId - The unique identifier of the workbook.
588
576
  * @param {string} subUnitId - The unique identifier of the worksheet within the workbook.
589
577
  * @param {string} ruleId - The ruleId of the range protection rule that is being updated.
590
578
  * @param {IRange[]} ranges - The array of new ranges to be set for the range protection rule.
591
579
  */
592
- setRangeProtectionRanges(e, t, n, s) {
593
- const r = this._rangeProtectionRuleModel.getRule(e, t, n);
594
- if (r) {
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)))))
580
+ setRangeProtectionRanges(e, t, n, r) {
581
+ const o = this._rangeProtectionRuleModel.getRule(e, t, n);
582
+ if (o) {
583
+ if (this._rangeProtectionRuleModel.getSubunitRuleList(e, t).filter((h) => h.id !== n).some((h) => h.ranges.some((c) => r.some((d) => N.intersects(d, c)))))
596
584
  throw new Error("range protection cannot intersect");
597
- this._commandService.syncExecuteCommand(Qe.id, {
585
+ this._commandService.syncExecuteCommand(nt.id, {
598
586
  unitId: e,
599
587
  subUnitId: t,
600
588
  ruleId: n,
601
589
  rule: {
602
- ...r,
603
- ranges: s
590
+ ...o,
591
+ ranges: r
604
592
  }
605
593
  });
606
594
  }
607
595
  }
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
596
  };
617
- j = Ft([
618
- f(0, m(v)),
619
- f(1, l),
620
- f(2, J),
621
- f(3, m(pe)),
622
- f(4, m(ye)),
623
- f(5, m(Pe)),
624
- f(6, m(Se))
625
- ], j);
626
- function Ot(o) {
627
- switch (o) {
597
+ O = zt([
598
+ v(0, u(b)),
599
+ v(1, l),
600
+ v(2, ee),
601
+ v(3, u(Ee)),
602
+ v(4, u(Pe)),
603
+ v(5, u(xe)),
604
+ v(6, u(ve))
605
+ ], O);
606
+ function $t(s) {
607
+ switch (s) {
628
608
  case "left":
629
- return R.LEFT;
609
+ return y.LEFT;
630
610
  case "center":
631
- return R.CENTER;
611
+ return y.CENTER;
632
612
  case "normal":
633
- return R.RIGHT;
613
+ return y.RIGHT;
634
614
  default:
635
- throw new Error(`Invalid horizontal alignment: ${o}`);
615
+ throw new Error(`Invalid horizontal alignment: ${s}`);
636
616
  }
637
617
  }
638
- function Bt(o) {
639
- switch (o) {
640
- case R.LEFT:
618
+ function Ht(s) {
619
+ switch (s) {
620
+ case y.LEFT:
641
621
  return "left";
642
- case R.CENTER:
622
+ case y.CENTER:
643
623
  return "center";
644
- case R.RIGHT:
624
+ case y.RIGHT:
645
625
  return "normal";
646
626
  default:
647
- throw new Error(`Invalid horizontal alignment: ${o}`);
627
+ throw new Error(`Invalid horizontal alignment: ${s}`);
648
628
  }
649
629
  }
650
- function Lt(o) {
651
- switch (o) {
630
+ function Gt(s) {
631
+ switch (s) {
652
632
  case "top":
653
- return b.TOP;
633
+ return U.TOP;
654
634
  case "middle":
655
- return b.MIDDLE;
635
+ return U.MIDDLE;
656
636
  case "bottom":
657
- return b.BOTTOM;
637
+ return U.BOTTOM;
658
638
  default:
659
- throw new Error(`Invalid vertical alignment: ${o}`);
639
+ throw new Error(`Invalid vertical alignment: ${s}`);
660
640
  }
661
641
  }
662
- function zt(o) {
663
- switch (o) {
664
- case b.TOP:
642
+ function qt(s) {
643
+ switch (s) {
644
+ case U.TOP:
665
645
  return "top";
666
- case b.MIDDLE:
646
+ case U.MIDDLE:
667
647
  return "middle";
668
- case b.BOTTOM:
648
+ case U.BOTTOM:
669
649
  return "bottom";
670
650
  default:
671
- throw new Error(`Invalid vertical alignment: ${o}`);
651
+ throw new Error(`Invalid vertical alignment: ${s}`);
672
652
  }
673
653
  }
674
- function Y(o) {
675
- return Me(o) ? {
676
- f: o
677
- } : je(o) ? {
678
- v: o
679
- } : (Ae(o), o);
654
+ function V(s) {
655
+ return je(s) ? {
656
+ f: s
657
+ } : Oe(s) ? {
658
+ v: s
659
+ } : (Ve(s), s);
680
660
  }
681
- function Vt(o, e) {
682
- const t = new T(), { startRow: n, startColumn: s, endRow: r, endColumn: i } = e;
683
- if (Fe.isArray(o))
684
- for (let a = 0; a <= r - n; a++)
685
- for (let h = 0; h <= i - s; h++)
686
- t.setValue(a + n, h + s, Y(o[a][h]));
661
+ function Ie(s, e) {
662
+ const t = new A(), { startRow: n, startColumn: r, endRow: o, endColumn: i } = e;
663
+ if (Be.isArray(s))
664
+ for (let a = 0; a <= o - n; a++)
665
+ for (let h = 0; h <= i - r; h++)
666
+ t.setValue(a + n, h + r, V(s[a][h]));
687
667
  else
688
- new T(o).forValue((h, c, d) => {
689
- t.setValue(h, c, Y(d));
668
+ new A(s).forValue((h, c, d) => {
669
+ t.setValue(h, c, V(d));
690
670
  });
691
671
  return t.getMatrix();
692
672
  }
693
- function V(o, e) {
673
+ function q(s, e) {
694
674
  return {
695
- startRow: o.startRow,
696
- endRow: o.endRow,
675
+ startRow: s.startRow,
676
+ endRow: s.endRow,
697
677
  startColumn: 0,
698
678
  endColumn: e.getColumnCount() - 1,
699
679
  rangeType: _.ROW
700
680
  };
701
681
  }
702
- function H(o, e) {
682
+ function K(s, e) {
703
683
  return {
704
684
  startRow: 0,
705
685
  endRow: e.getRowCount() - 1,
706
- startColumn: o.startColumn,
707
- endColumn: o.endColumn,
686
+ startColumn: s.startColumn,
687
+ endColumn: s.endColumn,
708
688
  rangeType: _.COLUMN
709
689
  };
710
690
  }
711
- var Ht = Object.defineProperty, $t = Object.getOwnPropertyDescriptor, Gt = (o, e, t, n) => {
712
- for (var s = n > 1 ? void 0 : n ? $t(e, t) : e, r = o.length - 1, i; r >= 0; r--)
713
- (i = o[r]) && (s = (n ? i(e, t, s) : i(s)) || s);
714
- return n && s && Ht(e, t, s), s;
715
- }, $ = (o, e) => (t, n) => e(t, n, o);
716
- let k = class extends X {
717
- constructor(o, e, t, n, s, r) {
718
- super(n), this._workbook = o, this._worksheet = e, this._range = t, this._injector = n, this._commandService = s, this._formulaDataModel = r;
691
+ var Kt = Object.defineProperty, Yt = Object.getOwnPropertyDescriptor, Jt = (s, e, t, n) => {
692
+ for (var r = n > 1 ? void 0 : n ? Yt(e, t) : e, o = s.length - 1, i; o >= 0; o--)
693
+ (i = s[o]) && (r = (n ? i(e, t, r) : i(r)) || r);
694
+ return n && r && Kt(e, t, r), r;
695
+ }, Y = (s, e) => (t, n) => e(t, n, s);
696
+ let w = class extends ne {
697
+ constructor(s, e, t, n, r, o) {
698
+ super(n), this._workbook = s, this._worksheet = e, this._range = t, this._injector = n, this._commandService = r, this._formulaDataModel = o;
719
699
  }
720
700
  /**
721
701
  * Get the unit ID of the current workbook
722
- *
723
- * @return The unit ID of the workbook
702
+ * @returns The unit ID of the workbook
724
703
  */
725
704
  getUnitId() {
726
705
  return this._workbook.getUnitId();
727
706
  }
728
707
  /**
729
708
  * Gets the name of the worksheet
730
- *
731
- * @return The name of the worksheet
709
+ * @returns The name of the worksheet
732
710
  */
733
711
  getSheetName() {
734
712
  return this._worksheet.getName();
735
713
  }
714
+ /**
715
+ * Gets the ID of the worksheet
716
+ * @returns The ID of the worksheet
717
+ */
718
+ getSheetId() {
719
+ return this._worksheet.getSheetId();
720
+ }
736
721
  /**
737
722
  * Gets the area where the statement is applied
738
- *
739
- * @return The area where the statement is applied
723
+ * @returns The area where the statement is applied
740
724
  */
741
725
  getRange() {
742
726
  return this._range;
743
727
  }
744
728
  /**
745
729
  * Gets the starting row number of the applied area
746
- *
747
- * @return The starting row number of the area
730
+ * @returns The starting row number of the area
748
731
  */
749
732
  getRow() {
750
733
  return this._range.startRow;
751
734
  }
752
735
  /**
753
736
  * Gets the starting column number of the applied area
754
- *
755
- * @return The starting column number of the area
737
+ * @returns The starting column number of the area
756
738
  */
757
739
  getColumn() {
758
740
  return this._range.startColumn;
759
741
  }
760
742
  /**
761
743
  * Gets the width of the applied area
762
- *
763
- * @return The width of the area
744
+ * @returns The width of the area
764
745
  */
765
746
  getWidth() {
766
747
  return this._range.endColumn - this._range.startColumn + 1;
767
748
  }
768
749
  /**
769
750
  * Gets the height of the applied area
770
- *
771
- * @return The height of the area
751
+ * @returns The height of the area
772
752
  */
773
753
  getHeight() {
774
754
  return this._range.endRow - this._range.startRow + 1;
775
755
  }
776
- /**
777
- * Return first cell model data in this range
778
- * @returns The cell model data
779
- */
780
- getCellData() {
781
- var o;
782
- return (o = this._worksheet.getCell(this._range.startRow, this._range.startColumn)) != null ? o : null;
783
- }
784
756
  /**
785
757
  * Return range whether this range is merged
786
758
  * @returns if true is merged
787
759
  */
788
760
  isMerged() {
789
- const { startColumn: o, startRow: e, endColumn: t, endRow: n } = this._range;
790
- return this._worksheet.getMergedCellRange(e, o, n, t).some((r) => E.equals(r, this._range));
761
+ const { startColumn: s, startRow: e, endColumn: t, endRow: n } = this._range;
762
+ return this._worksheet.getMergedCellRange(e, s, n, t).some((o) => N.equals(o, this._range));
791
763
  }
792
764
  /**
793
765
  * Return first cell style data in this range
794
- * @returns The cell style data
766
+ * @returns {IStyleData | null} The cell style data
795
767
  */
796
768
  getCellStyleData() {
797
769
  var t;
798
- const o = this.getCellData(), e = this._workbook.getStyles();
799
- return o && e && (t = e.getStyleByCell(o)) != null ? t : null;
770
+ const s = this.getCellData(), e = this._workbook.getStyles();
771
+ return s && e && (t = e.getStyleByCell(s)) != null ? t : null;
800
772
  }
801
773
  /**
802
774
  * Returns the value of the cell at the start of this range.
803
- * @returns The value of the cell.
775
+ * @returns {CellValue | null} The value of the cell.
804
776
  */
805
777
  getValue() {
806
- var o, e;
807
- return (e = (o = this._worksheet.getCell(this._range.startRow, this._range.startColumn)) == null ? void 0 : o.v) != null ? e : null;
778
+ var s, e;
779
+ return (e = (s = this._worksheet.getCell(this._range.startRow, this._range.startColumn)) == null ? void 0 : s.v) != null ? e : null;
808
780
  }
809
781
  /**
810
782
  * Returns the rectangular grid of values for this range.
811
783
  * Returns a two-dimensional array of values, indexed by row, then by column.
812
- * @returns A two-dimensional array of values.
784
+ * @returns {Nullable<CellValue>[][]} A two-dimensional array of values.
813
785
  */
814
786
  getValues() {
815
- var r, i;
816
- const { startRow: o, endRow: e, startColumn: t, endColumn: n } = this._range, s = [];
817
- for (let a = o; a <= e; a++) {
787
+ var o, i;
788
+ const { startRow: s, endRow: e, startColumn: t, endColumn: n } = this._range, r = [];
789
+ for (let a = s; a <= e; a++) {
818
790
  const h = [];
819
791
  for (let c = t; c <= n; c++)
820
- h.push((i = (r = this._worksheet.getCell(a, c)) == null ? void 0 : r.v) != null ? i : null);
821
- s.push(h);
792
+ h.push((i = (o = this._worksheet.getCell(a, c)) == null ? void 0 : o.v) != null ? i : null);
793
+ r.push(h);
822
794
  }
823
- return s;
795
+ return r;
796
+ }
797
+ /**
798
+ * Return first cell model data in this range
799
+ * @returns {ICellData | null} The cell model data
800
+ * @example
801
+ * ```
802
+ * univerAPI.getActiveWorkbook()
803
+ * .getActiveSheet()
804
+ * .getActiveRange()
805
+ * .getCellData()
806
+ * ```
807
+ */
808
+ getCellData() {
809
+ var s;
810
+ return (s = this._worksheet.getCell(this._range.startRow, this._range.startColumn)) != null ? s : null;
824
811
  }
825
812
  /**
826
813
  * Returns the cell data for the cells in the range.
827
- * @returns A two-dimensional array of cell data.
814
+ * @returns {Nullable<ICellData>[][]} A two-dimensional array of cell data.
815
+ * @example
816
+ * ```
817
+ * univerAPI.getActiveWorkbook()
818
+ * .getActiveSheet()
819
+ * .getActiveRange()
820
+ * .getCellDatas()
821
+ * ```
828
822
  */
829
- getCellDataGrid() {
830
- const { startRow: o, endRow: e, startColumn: t, endColumn: n } = this._range, s = [];
831
- for (let r = o; r <= e; r++) {
823
+ getCellDatas() {
824
+ const { startRow: s, endRow: e, startColumn: t, endColumn: n } = this._range, r = [];
825
+ for (let o = s; o <= e; o++) {
832
826
  const i = [];
833
827
  for (let a = t; a <= n; a++)
834
- i.push(this._worksheet.getCellRaw(r, a));
835
- s.push(i);
828
+ i.push(this._worksheet.getCellRaw(o, a));
829
+ r.push(i);
836
830
  }
837
- return s;
831
+ return r;
832
+ }
833
+ /**
834
+ * @deprecated use `getCellDatas` instead.
835
+ */
836
+ getCellDataGrid() {
837
+ return this.getCellDatas();
838
+ }
839
+ /**
840
+ * Returns the rich text value for the cell at the start of this range.
841
+ * @returns {Nullable<RichTextValue>} The rich text value
842
+ * @example
843
+ * ```
844
+ * univerAPI.getActiveWorkbook()
845
+ * .getActiveSheet()
846
+ * .getActiveRange()
847
+ * .getRichTextValue()
848
+ * ```
849
+ */
850
+ getRichTextValue() {
851
+ const s = this.getCellData();
852
+ return s != null && s.p ? new p(s.p) : null;
853
+ }
854
+ /**
855
+ * Returns the rich text value for the cells in the range.
856
+ * @returns {Nullable<RichTextValue>[][]} A two-dimensional array of RichTextValue objects.
857
+ * @example
858
+ * ```
859
+ * univerAPI.getActiveWorkbook()
860
+ * .getActiveSheet()
861
+ * .getActiveRange()
862
+ * .getRichTextValues()
863
+ * ```
864
+ */
865
+ getRichTextValues() {
866
+ return this.getCellDataGrid().map((e) => e.map((t) => t != null && t.p ? new p(t.p) : null));
867
+ }
868
+ /**
869
+ * Returns the value and rich text value for the cell at the start of this range.
870
+ * @returns {Nullable<CellValue | RichTextValue>} The value and rich text value
871
+ * @example
872
+ * ```
873
+ * univerAPI.getActiveWorkbook()
874
+ * .getActiveSheet()
875
+ * .getActiveRange()
876
+ * .getValueAndRichTextValue()
877
+ * ```
878
+ */
879
+ getValueAndRichTextValue() {
880
+ const s = this.getCellData();
881
+ return s != null && s.p ? new p(s.p) : s == null ? void 0 : s.v;
882
+ }
883
+ /**
884
+ * Returns the value and rich text value for the cells in the range.
885
+ * @returns {Nullable<CellValue | RichTextValue>[][]} A two-dimensional array of value and rich text value
886
+ * @example
887
+ * ```
888
+ * univerAPI.getActiveWorkbook()
889
+ * .getActiveSheet()
890
+ * .getActiveRange()
891
+ * .getValueAndRichTextValues()
892
+ * ```
893
+ */
894
+ getValueAndRichTextValues() {
895
+ return this.getCellDatas().map((e) => e.map((t) => t != null && t.p ? new p(t.p) : t == null ? void 0 : t.v));
838
896
  }
839
897
  /**
840
898
  * Returns the formulas (A1 notation) for the cells in the range. Entries in the 2D array are empty strings for cells with no formula.
841
- * @returns A two-dimensional array of formulas in string format.
899
+ * @returns {string[][]} A two-dimensional array of formulas in string format.
900
+ * @example
901
+ * ```ts
902
+ * univerAPI.getActiveWorkbook()
903
+ * .getActiveSheet()
904
+ * .getActiveRange()
905
+ * .getFormulas()
906
+ * ```
842
907
  */
843
908
  getFormulas() {
844
- const o = [], { startRow: e, endRow: t, startColumn: n, endColumn: s } = this._range, r = this._worksheet.getSheetId(), i = this._workbook.getUnitId();
909
+ const s = [], { startRow: e, endRow: t, startColumn: n, endColumn: r } = this._range, o = this._worksheet.getSheetId(), i = this._workbook.getUnitId();
845
910
  for (let a = e; a <= t; a++) {
846
911
  const h = [];
847
- for (let c = n; c <= s; c++) {
848
- const d = this._formulaDataModel.getFormulaStringByCell(a, c, r, i);
912
+ for (let c = n; c <= r; c++) {
913
+ const d = this._formulaDataModel.getFormulaStringByCell(a, c, o, i);
849
914
  h.push(d || "");
850
915
  }
851
- o.push(h);
916
+ s.push(h);
852
917
  }
853
- return o;
918
+ return s;
854
919
  }
855
920
  getWrap() {
856
- return this._worksheet.getRange(this._range).getWrap() === u.TRUE;
921
+ return this._worksheet.getRange(this._range).getWrap() === m.TRUE;
857
922
  }
858
923
  getWrapStrategy() {
859
924
  return this._worksheet.getRange(this._range).getWrapStrategy();
860
925
  }
861
926
  getHorizontalAlignment() {
862
- return Bt(this._worksheet.getRange(this._range).getHorizontalAlignment());
927
+ return Ht(this._worksheet.getRange(this._range).getHorizontalAlignment());
863
928
  }
864
929
  getVerticalAlignment() {
865
- return zt(this._worksheet.getRange(this._range).getVerticalAlignment());
930
+ return qt(this._worksheet.getRange(this._range).getVerticalAlignment());
931
+ }
932
+ /**
933
+ * Set custom meta data for first cell in current range.
934
+ * @param {CustomData} data The custom meta data
935
+ * @returns {FRange} This range, for chaining
936
+ * ```ts
937
+ * univerAPI.getActiveWorkbook()
938
+ * .getActiveSheet()
939
+ * .getActiveRange()
940
+ * .setCustomMetaData({ key: 'value' });
941
+ * ```
942
+ */
943
+ setCustomMetaData(s) {
944
+ return this.setValue({
945
+ custom: s
946
+ });
947
+ }
948
+ /**
949
+ * Set custom meta data for current range.
950
+ * @param {CustomData[][]} datas The custom meta data
951
+ * @returns {FRange} This range, for chaining
952
+ * ```ts
953
+ * univerAPI.getActiveWorkbook()
954
+ * .getActiveSheet()
955
+ * .getActiveRange()
956
+ * .setCustomMetaDatas([[{ key: 'value' }]]);
957
+ * ```
958
+ */
959
+ setCustomMetaDatas(s) {
960
+ return this.setValues(s.map((e) => e.map((t) => ({ custom: t }))));
961
+ }
962
+ /**
963
+ * Returns the custom meta data for the cell at the start of this range.
964
+ * @returns {CustomData | null} The custom meta data
965
+ * @example
966
+ * ```
967
+ * univerAPI.getActiveWorkbook()
968
+ * .getActiveSheet()
969
+ * .getActiveRange()
970
+ * .getCustomMetaData()
971
+ * ```
972
+ */
973
+ getCustomMetaData() {
974
+ var e;
975
+ const s = this.getCellData();
976
+ return (e = s == null ? void 0 : s.custom) != null ? e : null;
977
+ }
978
+ /**
979
+ * Returns the custom meta data for the cells in the range.
980
+ * @returns {CustomData[][]} A two-dimensional array of custom meta data
981
+ * @example
982
+ * ```
983
+ * univerAPI.getActiveWorkbook()
984
+ * .getActiveSheet()
985
+ * .getActiveRange()
986
+ * .getCustomMetaDatas()
987
+ * ```
988
+ */
989
+ getCustomMetaDatas() {
990
+ return this.getCellDataGrid().map((e) => e.map((t) => {
991
+ var n;
992
+ return (n = t == null ? void 0 : t.custom) != null ? n : null;
993
+ }));
866
994
  }
867
995
  // #region editing
868
996
  /**
@@ -870,18 +998,21 @@ let k = class extends X {
870
998
  * @param color {string}
871
999
  * @example
872
1000
  * ```
873
- * univerAPI.getActiveWorkbook().getActiveSheet().getActiveRange().setBackgroundColor('red')
1001
+ * univerAPI.getActiveWorkbook()
1002
+ * .getActiveSheet()
1003
+ * .getActiveRange()
1004
+ * .setBackgroundColor('red')
874
1005
  * ```
875
1006
  */
876
- setBackgroundColor(o) {
877
- return this._commandService.syncExecuteCommand(C.id, {
1007
+ setBackgroundColor(s) {
1008
+ return this._commandService.syncExecuteCommand(f.id, {
878
1009
  unitId: this._workbook.getUnitId(),
879
1010
  subUnitId: this._worksheet.getSheetId(),
880
1011
  range: this._range,
881
1012
  style: {
882
1013
  type: "bg",
883
1014
  value: {
884
- rgb: o
1015
+ rgb: s
885
1016
  }
886
1017
  }
887
1018
  }), this;
@@ -889,81 +1020,159 @@ let k = class extends X {
889
1020
  /**
890
1021
  * Set background color for current range.
891
1022
  * @example
892
- * ```
1023
+ * ```typescript
893
1024
  * univerAPI.getActiveWorkbook().getActiveSheet().getActiveRange().setBackground('red')
894
1025
  * ```
895
1026
  * @param color {string}
896
1027
  */
897
- setBackground(o) {
898
- return this.setBackgroundColor(o), this;
1028
+ setBackground(s) {
1029
+ return this.setBackgroundColor(s), this;
899
1030
  }
900
1031
  /**
901
- * 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.
902
- * @param value
1032
+ * Set new value for current cell, first cell in this range.
1033
+ * @param {CellValue | ICellData} value 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.
903
1034
  */
904
- setValue(o) {
905
- const e = Y(o);
1035
+ setValue(s) {
1036
+ const e = V(s);
906
1037
  if (!e)
907
1038
  throw new Error("Invalid value");
908
- return this._commandService.syncExecuteCommand(se.id, {
1039
+ return this._commandService.syncExecuteCommand(P.id, {
909
1040
  unitId: this._workbook.getUnitId(),
910
1041
  subUnitId: this._worksheet.getSheetId(),
911
1042
  range: this._range,
912
1043
  value: e
913
1044
  }), this;
914
1045
  }
1046
+ /**
1047
+ * Set new value for current cell, first cell in this range.
1048
+ * @param {CellValue | ICellData} value 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.
1049
+ * ```ts
1050
+ * univerAPI.getActiveWorkbook()
1051
+ * .getActiveSheet()
1052
+ * .getActiveRange()
1053
+ * .setValueForCell(1);
1054
+ * ```
1055
+ */
1056
+ setValueForCell(s) {
1057
+ const e = V(s);
1058
+ if (!e)
1059
+ throw new Error("Invalid value");
1060
+ return this._commandService.syncExecuteCommand(P.id, {
1061
+ unitId: this._workbook.getUnitId(),
1062
+ subUnitId: this._worksheet.getSheetId(),
1063
+ range: {
1064
+ startColumn: this._range.startColumn,
1065
+ startRow: this._range.startRow,
1066
+ endColumn: this._range.endColumn,
1067
+ endRow: this._range.endRow
1068
+ },
1069
+ value: e
1070
+ }), this;
1071
+ }
1072
+ /**
1073
+ * Set the rich text value for the cell at the start of this range.
1074
+ * @param {RichTextValue | IDocumentData} value The rich text value
1075
+ * @returns {FRange} The range
1076
+ * @example
1077
+ * ```
1078
+ * univerAPI.getActiveWorkbook()
1079
+ * .getActiveSheet()
1080
+ * .getActiveRange()
1081
+ * .setRichTextValueForCell(new RichTextValue().insertText('Hello'));
1082
+ * ```
1083
+ */
1084
+ setRichTextValueForCell(s) {
1085
+ const e = s instanceof p ? s.getData() : s, t = {
1086
+ unitId: this._workbook.getUnitId(),
1087
+ subUnitId: this._worksheet.getSheetId(),
1088
+ range: {
1089
+ startColumn: this._range.startColumn,
1090
+ startRow: this._range.startRow,
1091
+ endColumn: this._range.endColumn,
1092
+ endRow: this._range.endRow
1093
+ },
1094
+ value: { p: e }
1095
+ };
1096
+ return this._commandService.syncExecuteCommand(P.id, t), this;
1097
+ }
1098
+ /**
1099
+ * Set the rich text value for the cells in the range.
1100
+ * @param {RichTextValue[][]} values The rich text value
1101
+ * @returns {FRange} The range
1102
+ * @example
1103
+ * ```ts
1104
+ * univerAPI
1105
+ * .getActiveWorkbook()
1106
+ * .getActiveSheet()
1107
+ * .getActiveRange()
1108
+ * .setRichTextValues([[new RichTextValue().insertText('Hello')]]);
1109
+ * ```
1110
+ */
1111
+ setRichTextValues(s) {
1112
+ const e = s.map((r) => r.map((o) => o && { p: o instanceof p ? o.getData() : o })), t = Ie(e, this._range), n = {
1113
+ unitId: this._workbook.getUnitId(),
1114
+ subUnitId: this._worksheet.getSheetId(),
1115
+ range: this._range,
1116
+ value: t
1117
+ };
1118
+ return this._commandService.syncExecuteCommand(P.id, n), this;
1119
+ }
915
1120
  /**
916
1121
  * Set the cell wrap of the given range.
917
1122
  * 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.
1123
+ * @param isWrapEnabled
918
1124
  */
919
- setWrap(o) {
920
- return this._commandService.syncExecuteCommand(oe.id, {
1125
+ setWrap(s) {
1126
+ return this._commandService.syncExecuteCommand(he.id, {
921
1127
  unitId: this._workbook.getUnitId(),
922
1128
  subUnitId: this._worksheet.getSheetId(),
923
1129
  range: this._range,
924
- value: o ? ee.WRAP : ee.UNSPECIFIED
1130
+ value: s ? oe.WRAP : oe.UNSPECIFIED
925
1131
  }), this;
926
1132
  }
927
1133
  /**
928
1134
  * Sets the text wrapping strategy for the cells in the range.
1135
+ * @param strategy
929
1136
  */
930
- setWrapStrategy(o) {
931
- return this._commandService.syncExecuteCommand(oe.id, {
1137
+ setWrapStrategy(s) {
1138
+ return this._commandService.syncExecuteCommand(he.id, {
932
1139
  unitId: this._workbook.getUnitId(),
933
1140
  subUnitId: this._worksheet.getSheetId(),
934
1141
  range: this._range,
935
- value: o
1142
+ value: s
936
1143
  }), this;
937
1144
  }
938
1145
  /**
939
1146
  * Set the vertical (top to bottom) alignment for the given range (top/middle/bottom).
1147
+ * @param alignment
940
1148
  */
941
- setVerticalAlignment(o) {
942
- return this._commandService.syncExecuteCommand(et.id, {
1149
+ setVerticalAlignment(s) {
1150
+ return this._commandService.syncExecuteCommand(ot.id, {
943
1151
  unitId: this._workbook.getUnitId(),
944
1152
  subUnitId: this._worksheet.getSheetId(),
945
1153
  range: this._range,
946
- value: Lt(o)
1154
+ value: Gt(s)
947
1155
  }), this;
948
1156
  }
949
1157
  /**
950
1158
  * Set the horizontal (left to right) alignment for the given range (left/center/right).
1159
+ * @param alignment
951
1160
  */
952
- setHorizontalAlignment(o) {
953
- return this._commandService.syncExecuteCommand(tt.id, {
1161
+ setHorizontalAlignment(s) {
1162
+ return this._commandService.syncExecuteCommand(it.id, {
954
1163
  unitId: this._workbook.getUnitId(),
955
1164
  subUnitId: this._worksheet.getSheetId(),
956
1165
  range: this._range,
957
- value: Ot(o)
1166
+ value: $t(s)
958
1167
  }), this;
959
1168
  }
960
1169
  /**
961
1170
  * 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.
962
1171
  * @param value
963
1172
  */
964
- setValues(o) {
965
- const e = Vt(o, this._range);
966
- return this._commandService.syncExecuteCommand(se.id, {
1173
+ setValues(s) {
1174
+ const e = Ie(s, this._range);
1175
+ return this._commandService.syncExecuteCommand(P.id, {
967
1176
  unitId: this._workbook.getUnitId(),
968
1177
  subUnitId: this._worksheet.getSheetId(),
969
1178
  range: this._range,
@@ -974,13 +1183,13 @@ let k = class extends X {
974
1183
  * Sets the font weight for the given range (normal/bold),
975
1184
  * @param fontWeight The font weight, either 'normal' or 'bold'; a null value resets the font weight.
976
1185
  */
977
- setFontWeight(o) {
1186
+ setFontWeight(s) {
978
1187
  let e;
979
- if (o === "bold")
980
- e = u.TRUE;
981
- else if (o === "normal")
982
- e = u.FALSE;
983
- else if (o === null)
1188
+ if (s === "bold")
1189
+ e = m.TRUE;
1190
+ else if (s === "normal")
1191
+ e = m.FALSE;
1192
+ else if (s === null)
984
1193
  e = null;
985
1194
  else
986
1195
  throw new Error("Invalid fontWeight");
@@ -993,19 +1202,19 @@ let k = class extends X {
993
1202
  range: this._range,
994
1203
  style: t
995
1204
  };
996
- return this._commandService.executeCommand(C.id, n), this;
1205
+ return this._commandService.executeCommand(f.id, n), this;
997
1206
  }
998
1207
  /**
999
1208
  * Sets the font style for the given range ('italic' or 'normal').
1000
1209
  * @param fontStyle The font style, either 'italic' or 'normal'; a null value resets the font style.
1001
1210
  */
1002
- setFontStyle(o) {
1211
+ setFontStyle(s) {
1003
1212
  let e;
1004
- if (o === "italic")
1005
- e = u.TRUE;
1006
- else if (o === "normal")
1007
- e = u.FALSE;
1008
- else if (o === null)
1213
+ if (s === "italic")
1214
+ e = m.TRUE;
1215
+ else if (s === "normal")
1216
+ e = m.FALSE;
1217
+ else if (s === null)
1009
1218
  e = null;
1010
1219
  else
1011
1220
  throw new Error("Invalid fontStyle");
@@ -1018,28 +1227,28 @@ let k = class extends X {
1018
1227
  range: this._range,
1019
1228
  style: t
1020
1229
  };
1021
- return this._commandService.executeCommand(C.id, n), this;
1230
+ return this._commandService.executeCommand(f.id, n), this;
1022
1231
  }
1023
1232
  /**
1024
1233
  * Sets the font line style of the given range ('underline', 'line-through', or 'none').
1025
1234
  * @param fontLine The font line style, either 'underline', 'line-through', or 'none'; a null value resets the font line style.
1026
1235
  */
1027
- setFontLine(o) {
1028
- if (o === "underline")
1236
+ setFontLine(s) {
1237
+ if (s === "underline")
1029
1238
  this._setFontUnderline({
1030
- s: u.TRUE
1239
+ s: m.TRUE
1031
1240
  });
1032
- else if (o === "line-through")
1241
+ else if (s === "line-through")
1033
1242
  this._setFontStrikethrough({
1034
- s: u.TRUE
1243
+ s: m.TRUE
1035
1244
  });
1036
- else if (o === "none")
1245
+ else if (s === "none")
1037
1246
  this._setFontUnderline({
1038
- s: u.FALSE
1247
+ s: m.FALSE
1039
1248
  }), this._setFontStrikethrough({
1040
- s: u.FALSE
1249
+ s: m.FALSE
1041
1250
  });
1042
- else if (o === null)
1251
+ else if (s === null)
1043
1252
  this._setFontUnderline(null), this._setFontStrikethrough(null);
1044
1253
  else
1045
1254
  throw new Error("Invalid fontLine");
@@ -1047,131 +1256,177 @@ let k = class extends X {
1047
1256
  }
1048
1257
  /**
1049
1258
  * Sets the font underline style of the given ITextDecoration
1259
+ * @param value
1050
1260
  */
1051
- _setFontUnderline(o) {
1261
+ _setFontUnderline(s) {
1052
1262
  const e = {
1053
1263
  type: "ul",
1054
- value: o
1264
+ value: s
1055
1265
  }, t = {
1056
1266
  unitId: this._workbook.getUnitId(),
1057
1267
  subUnitId: this._worksheet.getSheetId(),
1058
1268
  range: this._range,
1059
1269
  style: e
1060
1270
  };
1061
- this._commandService.executeCommand(C.id, t);
1271
+ this._commandService.executeCommand(f.id, t);
1062
1272
  }
1063
1273
  /**
1064
1274
  * Sets the font strikethrough style of the given ITextDecoration
1275
+ * @param value
1065
1276
  */
1066
- _setFontStrikethrough(o) {
1277
+ _setFontStrikethrough(s) {
1067
1278
  const e = {
1068
1279
  type: "st",
1069
- value: o
1280
+ value: s
1070
1281
  }, t = {
1071
1282
  unitId: this._workbook.getUnitId(),
1072
1283
  subUnitId: this._worksheet.getSheetId(),
1073
1284
  range: this._range,
1074
1285
  style: e
1075
1286
  };
1076
- this._commandService.executeCommand(C.id, t);
1287
+ this._commandService.executeCommand(f.id, t);
1077
1288
  }
1078
1289
  /**
1079
1290
  * Sets the font family, such as "Arial" or "Helvetica".
1080
1291
  * @param fontFamily The font family to set; a null value resets the font family.
1081
1292
  */
1082
- setFontFamily(o) {
1293
+ setFontFamily(s) {
1083
1294
  const e = {
1084
1295
  type: "ff",
1085
- value: o
1296
+ value: s
1086
1297
  }, t = {
1087
1298
  unitId: this._workbook.getUnitId(),
1088
1299
  subUnitId: this._worksheet.getSheetId(),
1089
1300
  range: this._range,
1090
1301
  style: e
1091
1302
  };
1092
- return this._commandService.executeCommand(C.id, t), this;
1303
+ return this._commandService.executeCommand(f.id, t), this;
1093
1304
  }
1094
1305
  /**
1095
1306
  * Sets the font size, with the size being the point size to use.
1096
1307
  * @param size A font size in point size. A null value resets the font size.
1097
1308
  */
1098
- setFontSize(o) {
1309
+ setFontSize(s) {
1099
1310
  const e = {
1100
1311
  type: "fs",
1101
- value: o
1312
+ value: s
1102
1313
  }, t = {
1103
1314
  unitId: this._workbook.getUnitId(),
1104
1315
  subUnitId: this._worksheet.getSheetId(),
1105
1316
  range: this._range,
1106
1317
  style: e
1107
1318
  };
1108
- return this._commandService.executeCommand(C.id, t), this;
1319
+ return this._commandService.executeCommand(f.id, t), this;
1109
1320
  }
1110
1321
  /**
1111
1322
  * Sets the font color in CSS notation (such as '#ffffff' or 'white').
1112
1323
  * @param color The font color in CSS notation (such as '#ffffff' or 'white'); a null value resets the color.
1113
1324
  */
1114
- setFontColor(o) {
1325
+ setFontColor(s) {
1115
1326
  const t = {
1116
1327
  type: "cl",
1117
- value: o === null ? null : { rgb: o }
1328
+ value: s === null ? null : { rgb: s }
1118
1329
  }, n = {
1119
1330
  unitId: this._workbook.getUnitId(),
1120
1331
  subUnitId: this._worksheet.getSheetId(),
1121
1332
  range: this._range,
1122
1333
  style: t
1123
1334
  };
1124
- return this._commandService.executeCommand(C.id, n), this;
1335
+ return this._commandService.executeCommand(f.id, n), this;
1125
1336
  }
1126
1337
  // #endregion editing
1127
1338
  //#region Merge cell
1128
1339
  /**
1129
1340
  * Merge cells in a range into one merged cell
1130
- *
1131
1341
  * @param [defaultMerge] - If true, only the value in the upper left cell is retained.
1132
- *
1133
1342
  * @returns This range, for chaining
1343
+ * @example
1344
+ * ```ts
1345
+ * const workbook = univerAPI.getActiveWorkbook();
1346
+ * const worksheet = workbook.getActiveSheet();
1347
+ * const range = worksheet.getRange(0, 0, 2, 2);
1348
+ * const merge = range.merge();
1349
+ * const isMerged = merge.isMerged();
1350
+ * console.log('debugger', isMerged);
1351
+ * ```
1134
1352
  */
1135
- merge(o = !0) {
1353
+ merge(s = !0) {
1136
1354
  const e = this._workbook.getUnitId(), t = this._worksheet.getSheetId();
1137
- return B(this._injector, e, t, [this._range], o), this;
1355
+ return $(this._injector, e, t, [this._range], s), this;
1138
1356
  }
1139
1357
  /**
1140
1358
  * Merges cells in a range horizontally.
1141
- *
1142
1359
  * @param [defaultMerge] - If true, only the value in the upper left cell is retained.
1143
- *
1144
1360
  * @returns This range, for chaining
1361
+ * @example
1362
+ * ```ts
1363
+ * const workbook = univerAPI.getActiveWorkbook();
1364
+ * const worksheet = workbook.getActiveSheet();
1365
+ * const range = worksheet.getRange(2, 2, 2, 2);
1366
+ * const merge = range.mergeAcross();
1367
+ * const allMerge = worksheet.getMergeData();
1368
+ * console.log(allMerge.length); // There will be two merged cells.
1369
+ * ```
1145
1370
  */
1146
- mergeAcross(o = !0) {
1147
- const e = re([this._range], te.ROWS), t = this._workbook.getUnitId(), n = this._worksheet.getSheetId();
1148
- return B(this._injector, t, n, e, o), this;
1371
+ mergeAcross(s = !0) {
1372
+ const e = ce([this._range], ie.ROWS), t = this._workbook.getUnitId(), n = this._worksheet.getSheetId();
1373
+ return $(this._injector, t, n, e, s), this;
1149
1374
  }
1150
1375
  /**
1151
1376
  * Merges cells in a range vertically.
1152
- *
1153
1377
  * @param [defaultMerge] - If true, only the value in the upper left cell is retained.
1154
- *
1155
1378
  * @returns This range, for chaining
1379
+ * @example
1380
+ * ```ts
1381
+ * const workbook = univerAPI.getActiveWorkbook();
1382
+ * const worksheet = workbook.getActiveSheet();
1383
+ * const range = worksheet.getRange(4, 4, 2, 2);
1384
+ * const merge = range.mergeVertically();
1385
+ * const allMerge = worksheet.getMergeData();
1386
+ * console.log(allMerge.length); // There will be two merged cells.
1387
+ * ```
1156
1388
  */
1157
- mergeVertically(o = !0) {
1158
- const e = re([this._range], te.COLUMNS), t = this._workbook.getUnitId(), n = this._worksheet.getSheetId();
1159
- return B(this._injector, t, n, e, o), this;
1389
+ mergeVertically(s = !0) {
1390
+ const e = ce([this._range], ie.COLUMNS), t = this._workbook.getUnitId(), n = this._worksheet.getSheetId();
1391
+ return $(this._injector, t, n, e, s), this;
1160
1392
  }
1161
1393
  /**
1162
1394
  * Returns true if cells in the current range overlap a merged cell.
1163
1395
  * @returns {boolean} is overlap with a merged cell
1396
+ * @example
1397
+ * ```ts
1398
+ * const workbook = univerAPI.getActiveWorkbook();
1399
+ * const worksheet = workbook.getActiveSheet();
1400
+ * const range = worksheet.getRange(0,0,2,2);
1401
+ * const merge = range.merge();
1402
+ * const anchor = worksheet.getRange(0,0);
1403
+ * const isPartOfMerge = anchor.isPartOfMerge();
1404
+ * console.log('debugger, isPartOfMerge) // true
1405
+ * ```
1164
1406
  */
1165
1407
  isPartOfMerge() {
1166
- const { startRow: o, startColumn: e, endRow: t, endColumn: n } = this._range;
1167
- return this._worksheet.getMergedCellRange(o, e, t, n).length > 0;
1408
+ const { startRow: s, startColumn: e, endRow: t, endColumn: n } = this._range;
1409
+ return this._worksheet.getMergedCellRange(s, e, t, n).length > 0;
1168
1410
  }
1169
1411
  /**
1170
1412
  * Break all horizontally- or vertically-merged cells contained within the range list into individual cells again.
1171
1413
  * @returns This range, for chaining
1414
+ * @example
1415
+ * ```ts
1416
+ * const workbook = univerAPI.getActiveWorkbook();
1417
+ * const worksheet = workbook.getActiveSheet();
1418
+ * const range = worksheet.getRange(0,0,2,2);
1419
+ * const merge = range.merge();
1420
+ * const anchor = worksheet.getRange(0,0);
1421
+ * const isPartOfMergeFirst = anchor.isPartOfMerge();
1422
+ * console.log('debugger' isPartOfMergeFirst) // true
1423
+ * range.breakApart();
1424
+ * const isPartOfMergeSecond = anchor.isPartOfMerge();
1425
+ * console.log('debugger' isPartOfMergeSecond) // false
1426
+ * ```
1172
1427
  */
1173
1428
  breakApart() {
1174
- return this._commandService.executeCommand(nt.id, { ranges: [this._range] }), this;
1429
+ return this._commandService.executeCommand(at.id, { ranges: [this._range] }), this;
1175
1430
  }
1176
1431
  //#endregion
1177
1432
  /**
@@ -1189,14 +1444,15 @@ let k = class extends X {
1189
1444
  * });
1190
1445
  * ```
1191
1446
  */
1192
- forEach(o) {
1193
- const { startColumn: e, startRow: t, endColumn: n, endRow: s } = this._range;
1194
- this._worksheet.getMatrixWithMergedCells(t, e, s, n).forValue((r, i, a) => {
1195
- o(r, i, a);
1447
+ forEach(s) {
1448
+ const { startColumn: e, startRow: t, endColumn: n, endRow: r } = this._range;
1449
+ this._worksheet.getMatrixWithMergedCells(t, e, r, n).forValue((o, i, a) => {
1450
+ s(o, i, a);
1196
1451
  });
1197
1452
  }
1198
1453
  /**
1199
1454
  * Returns a string description of the range, in A1 notation.
1455
+ * @param withSheet
1200
1456
  * @returns {string} The A1 notation of the range.
1201
1457
  * ```ts
1202
1458
  * const fWorkbook = univerAPI.getActiveWorkbook();
@@ -1205,8 +1461,8 @@ let k = class extends X {
1205
1461
  * console.log(fRange.getA1Notation()); // A1:B2
1206
1462
  * ```
1207
1463
  */
1208
- getA1Notation(o) {
1209
- return o ? xt(this._worksheet.getName(), this._range) : Z(this._range);
1464
+ getA1Notation(s) {
1465
+ return s ? Tt(this._worksheet.getName(), this._range) : re(this._range);
1210
1466
  }
1211
1467
  /**
1212
1468
  * Sets the specified range as the active range, with the top left cell in the range as the current cell.
@@ -1230,8 +1486,8 @@ let k = class extends X {
1230
1486
  * @description If the range is not a single cell, an error will be thrown.
1231
1487
  */
1232
1488
  activateAsCurrentCell() {
1233
- const o = this._worksheet.getMergedCell(this._range.startRow, this._range.startColumn);
1234
- if (o && E.equals(o, this._range) || !o && this._range.startRow === this._range.endRow && this._range.startColumn === this._range.endColumn)
1489
+ const s = this._worksheet.getMergedCell(this._range.startRow, this._range.startColumn);
1490
+ if (s && N.equals(s, this._range) || !s && this._range.startRow === this._range.endRow && this._range.startColumn === this._range.endColumn)
1235
1491
  return this.activate();
1236
1492
  throw new Error("The range is not a single cell");
1237
1493
  }
@@ -1267,14 +1523,14 @@ let k = class extends X {
1267
1523
  * // 1 | 2 | 3
1268
1524
  * // 4 | 5 | 6
1269
1525
  */
1270
- splitTextToColumns(o, e, t) {
1271
- this._commandService.executeCommand(st.id, {
1526
+ splitTextToColumns(s, e, t) {
1527
+ this._commandService.executeCommand(ht.id, {
1272
1528
  unitId: this._workbook.getUnitId(),
1273
1529
  subUnitId: this._worksheet.getSheetId(),
1274
1530
  range: this._range,
1275
1531
  delimiter: e,
1276
1532
  customDelimiter: t,
1277
- treatMultipleDelimitersAsOne: o
1533
+ treatMultipleDelimitersAsOne: s
1278
1534
  });
1279
1535
  }
1280
1536
  /**
@@ -1288,16 +1544,16 @@ let k = class extends X {
1288
1544
  * fRange.useThemeStyle('default');
1289
1545
  * ```
1290
1546
  */
1291
- useThemeStyle(o) {
1292
- if (o == null) {
1547
+ useThemeStyle(s) {
1548
+ if (s == null) {
1293
1549
  const e = this.getUsedThemeStyle();
1294
1550
  e && this.removeThemeStyle(e);
1295
1551
  } else
1296
- this._commandService.executeCommand(ot.id, {
1552
+ this._commandService.executeCommand(ct.id, {
1297
1553
  unitId: this._workbook.getUnitId(),
1298
1554
  subUnitId: this._worksheet.getSheetId(),
1299
1555
  range: this._range,
1300
- themeName: o
1556
+ themeName: s
1301
1557
  });
1302
1558
  }
1303
1559
  /**
@@ -1311,12 +1567,12 @@ let k = class extends X {
1311
1567
  * fRange.removeThemeStyle('default');
1312
1568
  * ```
1313
1569
  */
1314
- removeThemeStyle(o) {
1315
- this._commandService.executeCommand(rt.id, {
1570
+ removeThemeStyle(s) {
1571
+ this._commandService.executeCommand(dt.id, {
1316
1572
  unitId: this._workbook.getUnitId(),
1317
1573
  subUnitId: this._worksheet.getSheetId(),
1318
1574
  range: this._range,
1319
- themeName: o
1575
+ themeName: s
1320
1576
  });
1321
1577
  }
1322
1578
  /**
@@ -1333,49 +1589,49 @@ let k = class extends X {
1333
1589
  * ```
1334
1590
  */
1335
1591
  getUsedThemeStyle() {
1336
- return this._injector.get(Ee).getAppliedRangeThemeStyle({
1592
+ return this._injector.get(Me).getAppliedRangeThemeStyle({
1337
1593
  unitId: this._workbook.getUnitId(),
1338
1594
  subUnitId: this._worksheet.getSheetId(),
1339
1595
  range: this._range
1340
1596
  });
1341
1597
  }
1342
1598
  };
1343
- k = Gt([
1344
- $(3, m(v)),
1345
- $(4, l),
1346
- $(5, m(Et))
1347
- ], k);
1348
- var qt = Object.defineProperty, Kt = Object.getOwnPropertyDescriptor, Yt = (o, e, t, n) => {
1349
- for (var s = n > 1 ? void 0 : n ? Kt(e, t) : e, r = o.length - 1, i; r >= 0; r--)
1350
- (i = o[r]) && (s = (n ? i(e, t, s) : i(s)) || s);
1351
- return n && s && qt(e, t, s), s;
1352
- }, Jt = (o, e) => (t, n) => e(t, n, o);
1353
- let A = class {
1354
- constructor(o, e, t, n) {
1355
- this._workbook = o, this._worksheet = e, this._selections = t, this._injector = n;
1599
+ w = Jt([
1600
+ Y(3, u(b)),
1601
+ Y(4, l),
1602
+ Y(5, u(Wt))
1603
+ ], w);
1604
+ var Qt = Object.defineProperty, Xt = Object.getOwnPropertyDescriptor, Zt = (s, e, t, n) => {
1605
+ for (var r = n > 1 ? void 0 : n ? Xt(e, t) : e, o = s.length - 1, i; o >= 0; o--)
1606
+ (i = s[o]) && (r = (n ? i(e, t, r) : i(r)) || r);
1607
+ return n && r && Qt(e, t, r), r;
1608
+ }, en = (s, e) => (t, n) => e(t, n, s);
1609
+ let B = class {
1610
+ constructor(s, e, t, n) {
1611
+ this._workbook = s, this._worksheet = e, this._selections = t, this._injector = n;
1356
1612
  }
1357
1613
  /**
1358
1614
  * Represents the active selection in the sheet. Which means the selection contains the active cell.
1359
1615
  * @returns {FRange | null} The active selection.
1360
1616
  */
1361
1617
  getActiveRange() {
1362
- const o = this._selections.find((e) => !!e.primary);
1363
- return o ? this._injector.createInstance(k, this._workbook, this._worksheet, o.range) : null;
1618
+ const s = this._selections.find((e) => !!e.primary);
1619
+ return s ? this._injector.createInstance(w, this._workbook, this._worksheet, s.range) : null;
1364
1620
  }
1365
1621
  /**
1366
1622
  * Represents the active selection list in the sheet.
1367
1623
  * @returns {FRange[]} The active selection list.
1368
1624
  */
1369
1625
  getActiveRangeList() {
1370
- return this._selections.map((o) => this._injector.createInstance(k, this._workbook, this._worksheet, o.range));
1626
+ return this._selections.map((s) => this._injector.createInstance(w, this._workbook, this._worksheet, s.range));
1371
1627
  }
1372
1628
  /**
1373
1629
  * Represents the current select cell in the sheet.
1374
1630
  * @returns {ISelectionCell} The current select cell info.Pay attention to the type of the return value.
1375
1631
  */
1376
1632
  getCurrentCell() {
1377
- const o = this._selections.find((e) => !!e.primary);
1378
- return o ? o.primary : null;
1633
+ const s = this._selections.find((e) => !!e.primary);
1634
+ return s ? s.primary : null;
1379
1635
  }
1380
1636
  /**
1381
1637
  * Returns the active sheet in the spreadsheet.
@@ -1390,8 +1646,8 @@ let A = class {
1390
1646
  * ```
1391
1647
  */
1392
1648
  getActiveSheet() {
1393
- const o = this._injector.createInstance(I, this._workbook);
1394
- return this._injector.createInstance(g, o, this._workbook, this._worksheet);
1649
+ const s = this._injector.createInstance(I, this._workbook);
1650
+ return this._injector.createInstance(g, s, this._workbook, this._worksheet);
1395
1651
  }
1396
1652
  /**
1397
1653
  * 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.
@@ -1407,31 +1663,31 @@ let A = class {
1407
1663
  * console.log(newSelection.getActiveRange().getA1Notation()); // A1
1408
1664
  * ```
1409
1665
  */
1410
- updatePrimaryCell(o) {
1666
+ updatePrimaryCell(s) {
1411
1667
  const e = this._injector.get(l);
1412
1668
  let t = [], n = !1;
1413
- for (const { range: r, style: i } of this._selections)
1414
- E.contains(r, o.getRange()) ? (t.push({
1415
- range: r,
1416
- primary: K(o.getRange(), this._worksheet),
1669
+ for (const { range: o, style: i } of this._selections)
1670
+ N.contains(o, s.getRange()) ? (t.push({
1671
+ range: o,
1672
+ primary: Z(s.getRange(), this._worksheet),
1417
1673
  style: i
1418
1674
  }), n = !0) : t.push({
1419
- range: r,
1675
+ range: o,
1420
1676
  primary: null,
1421
1677
  style: i
1422
1678
  });
1423
1679
  n || (t = [
1424
1680
  {
1425
- range: o.getRange(),
1426
- primary: K(o.getRange(), this._worksheet)
1681
+ range: s.getRange(),
1682
+ primary: Z(s.getRange(), this._worksheet)
1427
1683
  }
1428
1684
  ]);
1429
- const s = {
1685
+ const r = {
1430
1686
  unitId: this._workbook.getUnitId(),
1431
1687
  subUnitId: this._worksheet.getSheetId(),
1432
1688
  selections: t
1433
1689
  };
1434
- return e.syncExecuteCommand(xe.id, s), new A(this._workbook, this._worksheet, t, this._injector);
1690
+ return e.syncExecuteCommand(De.id, r), new B(this._workbook, this._worksheet, t, this._injector);
1435
1691
  }
1436
1692
  /**
1437
1693
  *Get the next primary cell in the specified direction. If the primary cell not exists in selections, return null.
@@ -1448,30 +1704,68 @@ let A = class {
1448
1704
  * console.log(nextCell?.getA1Notation()); // B1
1449
1705
  * ```
1450
1706
  */
1451
- getNextDataRange(o) {
1707
+ getNextDataRange(s) {
1452
1708
  if (!this._selections.find((n) => !!n.primary))
1453
1709
  return null;
1454
- const t = it(this._selections.concat(), o, this._worksheet);
1455
- return t ? this._injector.createInstance(k, this._workbook, this._worksheet, t) : null;
1710
+ const t = ut(this._selections.concat(), s, this._worksheet);
1711
+ return t ? this._injector.createInstance(w, this._workbook, this._worksheet, t) : null;
1456
1712
  }
1457
1713
  };
1458
- A = Yt([
1459
- Jt(3, m(v))
1460
- ], A);
1461
- var Qt = Object.defineProperty, Xt = Object.getOwnPropertyDescriptor, Zt = (o, e, t, n) => {
1462
- for (var s = n > 1 ? void 0 : n ? Xt(e, t) : e, r = o.length - 1, i; r >= 0; r--)
1463
- (i = o[r]) && (s = (n ? i(e, t, s) : i(s)) || s);
1464
- return n && s && Qt(e, t, s), s;
1465
- }, W = (o, e) => (t, n) => e(t, n, o);
1466
- let g = class extends X {
1467
- constructor(e, t, n, s, r, i, a) {
1468
- super(s);
1714
+ B = Zt([
1715
+ en(3, u(b))
1716
+ ], B);
1717
+ var tn = Object.defineProperty, nn = Object.getOwnPropertyDescriptor, sn = (s, e, t, n) => {
1718
+ for (var r = n > 1 ? void 0 : n ? nn(e, t) : e, o = s.length - 1, i; o >= 0; o--)
1719
+ (i = s[o]) && (r = (n ? i(e, t, r) : i(r)) || r);
1720
+ return n && r && tn(e, t, r), r;
1721
+ }, T = (s, e) => (t, n) => e(t, n, s);
1722
+ let g = class extends ne {
1723
+ constructor(e, t, n, r, o, i, a) {
1724
+ super(r);
1725
+ k(this, "_eventRegistry", /* @__PURE__ */ new Map());
1469
1726
  /**
1470
1727
  * Sets the active selection region for this sheet.
1471
1728
  * @param range The range to set as the active selection.
1472
1729
  */
1473
- p(this, "setActiveSelection", this.setActiveRange);
1474
- this._fWorkbook = e, this._workbook = t, this._worksheet = n, this._injector = s, this._selectionManagerService = r, this._logService = i, this._commandService = a;
1730
+ k(this, "setActiveSelection", this.setActiveRange);
1731
+ this._fWorkbook = e, this._workbook = t, this._worksheet = n, this._injector = r, this._selectionManagerService = o, this._logService = i, this._commandService = a;
1732
+ }
1733
+ getSheet() {
1734
+ return this._worksheet;
1735
+ }
1736
+ _ensureEventRegistry(e) {
1737
+ return this._eventRegistry.has(e) || this._eventRegistry.set(e, new ye()), this._eventRegistry.get(e);
1738
+ }
1739
+ /**
1740
+ * Add an event listener
1741
+ * @param event key of event
1742
+ * @param callback callback when event triggered
1743
+ * @returns {Disposable} The Disposable instance, for remove the listener
1744
+ * @example
1745
+ * ```ts
1746
+ * univerAPI.addEvent(univerAPI.event.UnitCreated, (params) => {
1747
+ * console.log('unit created', params);
1748
+ * });
1749
+ * ```
1750
+ */
1751
+ addEvent(e, t) {
1752
+ return this._ensureEventRegistry(e).add(t), F(() => this._ensureEventRegistry(e).delete(t));
1753
+ }
1754
+ /**
1755
+ * Fire an event, used in internal only.
1756
+ * @param event {string} key of event
1757
+ * @param params {any} params of event
1758
+ * @returns {boolean} should cancel
1759
+ * @example
1760
+ * ```ts
1761
+ * this.fireEvent(univerAPI.event.UnitCreated, params);
1762
+ * ```
1763
+ */
1764
+ fireEvent(e, t) {
1765
+ var n;
1766
+ return (n = this._eventRegistry.get(e)) == null || n.getData().forEach((r) => {
1767
+ r(t);
1768
+ }), t.cancel;
1475
1769
  }
1476
1770
  /**
1477
1771
  * Returns the injector
@@ -1507,7 +1801,7 @@ let g = class extends X {
1507
1801
  */
1508
1802
  getSelection() {
1509
1803
  const e = this._selectionManagerService.getCurrentSelections();
1510
- return e ? this._injector.createInstance(A, this._workbook, this._worksheet, e) : null;
1804
+ return e ? this._injector.createInstance(B, this._workbook, this._worksheet, e) : null;
1511
1805
  }
1512
1806
  // #region rows
1513
1807
  // #region default style
@@ -1530,7 +1824,7 @@ let g = class extends X {
1530
1824
  /**
1531
1825
  * Get the default style of the worksheet column
1532
1826
  * @param {number} index The column index
1533
- * @param {boolean} [keepRaw] If true, return the raw style data maybe the style name or style data, otherwise return the data from col manager
1827
+ * @param {boolean} [keepRaw] If true, return the raw style data maybe the style name or style data, otherwise return the data from col manager
1534
1828
  * @returns {Nullable<IStyleData> | string} The default style of the worksheet column name or style data
1535
1829
  */
1536
1830
  getColumnDefaultStyle(e, t = !1) {
@@ -1543,7 +1837,7 @@ let g = class extends X {
1543
1837
  */
1544
1838
  setDefaultStyle(e) {
1545
1839
  const t = this._workbook.getUnitId(), n = this._worksheet.getSheetId();
1546
- return this._commandService.syncExecuteCommand(at.id, {
1840
+ return this._commandService.syncExecuteCommand(mt.id, {
1547
1841
  unitId: t,
1548
1842
  subUnitId: n,
1549
1843
  defaultStyle: e
@@ -1556,16 +1850,16 @@ let g = class extends X {
1556
1850
  * @returns {FWorksheet} This sheet, for chaining.
1557
1851
  */
1558
1852
  setColumnDefaultStyle(e, t) {
1559
- const n = this._workbook.getUnitId(), s = this._worksheet.getSheetId(), r = {
1853
+ const n = this._workbook.getUnitId(), r = this._worksheet.getSheetId(), o = {
1560
1854
  unitId: n,
1561
- subUnitId: s,
1855
+ subUnitId: r,
1562
1856
  columnData: {
1563
1857
  [e]: {
1564
1858
  s: t
1565
1859
  }
1566
1860
  }
1567
1861
  };
1568
- return this._commandService.syncExecuteCommand(ie.id, r), this;
1862
+ return this._commandService.syncExecuteCommand(de.id, o), this;
1569
1863
  }
1570
1864
  /**
1571
1865
  * Set the default style of the worksheet column
@@ -1574,24 +1868,24 @@ let g = class extends X {
1574
1868
  * @returns {FWorksheet} This sheet, for chaining.
1575
1869
  */
1576
1870
  setRowDefaultStyle(e, t) {
1577
- const n = this._workbook.getUnitId(), s = this._worksheet.getSheetId(), r = {
1871
+ const n = this._workbook.getUnitId(), r = this._worksheet.getSheetId(), o = {
1578
1872
  unitId: n,
1579
- subUnitId: s,
1873
+ subUnitId: r,
1580
1874
  rowData: {
1581
1875
  [e]: {
1582
1876
  s: t
1583
1877
  }
1584
1878
  }
1585
1879
  };
1586
- return this._commandService.syncExecuteCommand(ae.id, r), this;
1880
+ return this._commandService.syncExecuteCommand(ue.id, o), this;
1587
1881
  }
1588
- getRange(e, t, n, s) {
1589
- let r, i;
1882
+ getRange(e, t, n, r) {
1883
+ let o, i;
1590
1884
  if (typeof e == "string") {
1591
- const { range: a, sheetName: h } = Nt(e), c = h ? this._workbook.getSheetBySheetName(h) : this._worksheet;
1885
+ const { range: a, sheetName: h } = At(e), c = h ? this._workbook.getSheetBySheetName(h) : this._worksheet;
1592
1886
  if (!c)
1593
1887
  throw new Error("Range not found");
1594
- i = c, r = {
1888
+ i = c, o = {
1595
1889
  ...a,
1596
1890
  unitId: this._workbook.getUnitId(),
1597
1891
  sheetId: i.getSheetId(),
@@ -1604,44 +1898,44 @@ let g = class extends X {
1604
1898
  endColumn: a.rangeType === _.ROW ? i.getMaxColumns() - 1 : a.endColumn
1605
1899
  };
1606
1900
  } else if (typeof e == "number" && t !== void 0)
1607
- i = this._worksheet, r = {
1901
+ i = this._worksheet, o = {
1608
1902
  startRow: e,
1609
1903
  endRow: e + (n != null ? n : 1) - 1,
1610
1904
  startColumn: t,
1611
- endColumn: t + (s != null ? s : 1) - 1,
1905
+ endColumn: t + (r != null ? r : 1) - 1,
1612
1906
  unitId: this._workbook.getUnitId(),
1613
1907
  sheetId: this._worksheet.getSheetId()
1614
1908
  };
1615
1909
  else
1616
1910
  throw new Error("Invalid range specification");
1617
- return this._injector.createInstance(k, this._workbook, i, r);
1911
+ return this._injector.createInstance(w, this._workbook, i, o);
1618
1912
  }
1619
1913
  /**
1620
1914
  * Returns the current number of columns in the sheet, regardless of content.
1621
- * @return The maximum columns count of the sheet
1915
+ * @returns {number} The maximum columns count of the sheet
1622
1916
  */
1623
1917
  getMaxColumns() {
1624
1918
  return this._worksheet.getMaxColumns();
1625
1919
  }
1626
1920
  /**
1627
1921
  * Returns the current number of rows in the sheet, regardless of content.
1628
- * @return The maximum rows count of the sheet
1922
+ * @returns {number}The maximum rows count of the sheet
1629
1923
  */
1630
1924
  getMaxRows() {
1631
1925
  return this._worksheet.getMaxRows();
1632
1926
  }
1633
1927
  /**
1634
1928
  * Inserts a row after the given row position.
1635
- * @param afterPosition The row after which the new row should be added, starting at 0 for the first row.
1636
- * @returns This sheet, for chaining.
1929
+ * @param {number} afterPosition The row after which the new row should be added, starting at 0 for the first row.
1930
+ * @returns {FWorksheet} This sheet, for chaining.
1637
1931
  */
1638
1932
  insertRowAfter(e) {
1639
1933
  return this.insertRowsAfter(e, 1);
1640
1934
  }
1641
1935
  /**
1642
1936
  * Inserts a row before the given row position.
1643
- * @param beforePosition The row before which the new row should be added, starting at 0 for the first row.
1644
- * @returns This sheet, for chaining.
1937
+ * @param {number} beforePosition The row before which the new row should be added, starting at 0 for the first row.
1938
+ * @returns {FWorksheet} This sheet, for chaining.
1645
1939
  */
1646
1940
  insertRowBefore(e) {
1647
1941
  return this.insertRowsBefore(e, 1);
@@ -1662,11 +1956,11 @@ let g = class extends X {
1662
1956
  * @returns This sheet, for chaining.
1663
1957
  */
1664
1958
  insertRowsAfter(e, t) {
1665
- 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);
1666
- return this._commandService.syncExecuteCommand(he.id, {
1959
+ const n = this._workbook.getUnitId(), r = this._worksheet.getSheetId(), o = D.DOWN, i = e + 1, a = e + t, h = 0, c = this._worksheet.getColumnCount() - 1, d = W(this._worksheet, i, a, h, c, !0, e);
1960
+ return this._commandService.syncExecuteCommand(me.id, {
1667
1961
  unitId: n,
1668
- subUnitId: s,
1669
- direction: r,
1962
+ subUnitId: r,
1963
+ direction: o,
1670
1964
  range: {
1671
1965
  startRow: i,
1672
1966
  endRow: a,
@@ -1683,11 +1977,11 @@ let g = class extends X {
1683
1977
  * @returns This sheet, for chaining.
1684
1978
  */
1685
1979
  insertRowsBefore(e, t) {
1686
- 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);
1687
- return this._commandService.syncExecuteCommand(he.id, {
1980
+ const n = this._workbook.getUnitId(), r = this._worksheet.getSheetId(), o = D.UP, i = e, a = e + t - 1, h = 0, c = this._worksheet.getColumnCount() - 1, d = W(this._worksheet, i, a, h, c, !0, e - 1);
1981
+ return this._commandService.syncExecuteCommand(me.id, {
1688
1982
  unitId: n,
1689
- subUnitId: s,
1690
- direction: r,
1983
+ subUnitId: r,
1984
+ direction: o,
1691
1985
  range: {
1692
1986
  startRow: i,
1693
1987
  endRow: a,
@@ -1718,7 +2012,7 @@ let g = class extends X {
1718
2012
  startColumn: 0,
1719
2013
  endColumn: this._worksheet.getColumnCount() - 1
1720
2014
  };
1721
- return this._commandService.syncExecuteCommand(ht.id, {
2015
+ return this._commandService.syncExecuteCommand(lt.id, {
1722
2016
  range: n,
1723
2017
  unitId: this._workbook.getUnitId(),
1724
2018
  subUnitId: this._worksheet.getSheetId()
@@ -1731,16 +2025,16 @@ let g = class extends X {
1731
2025
  * @returns This sheet, for chaining.
1732
2026
  */
1733
2027
  moveRows(e, t) {
1734
- const n = this._workbook.getUnitId(), s = this._worksheet.getSheetId(), r = V(e.getRange(), this._worksheet), i = r, a = {
2028
+ const n = this._workbook.getUnitId(), r = this._worksheet.getSheetId(), o = q(e.getRange(), this._worksheet), i = o, a = {
1735
2029
  startRow: t,
1736
2030
  endRow: t,
1737
- startColumn: r.startColumn,
1738
- endColumn: r.endColumn
2031
+ startColumn: o.startColumn,
2032
+ endColumn: o.endColumn
1739
2033
  };
1740
- return this._commandService.syncExecuteCommand(ct.id, {
2034
+ return this._commandService.syncExecuteCommand(gt.id, {
1741
2035
  unitId: n,
1742
- subUnitId: s,
1743
- range: r,
2036
+ subUnitId: r,
2037
+ range: o,
1744
2038
  fromRange: i,
1745
2039
  toRange: a
1746
2040
  }), this;
@@ -1751,114 +2045,115 @@ let g = class extends X {
1751
2045
  * @returns This sheet, for chaining.
1752
2046
  */
1753
2047
  hideRow(e) {
1754
- const t = this._workbook.getUnitId(), n = this._worksheet.getSheetId(), s = V(e.getRange(), this._worksheet);
1755
- return this._commandService.syncExecuteCommand(ce.id, {
2048
+ const t = this._workbook.getUnitId(), n = this._worksheet.getSheetId(), r = q(e.getRange(), this._worksheet);
2049
+ return this._commandService.syncExecuteCommand(le.id, {
1756
2050
  unitId: t,
1757
2051
  subUnitId: n,
1758
- ranges: [s]
2052
+ ranges: [r]
1759
2053
  }), this;
1760
2054
  }
1761
2055
  /**
1762
2056
  * Hides one or more consecutive rows starting at the given index. Use 0-index for this method.
1763
- * @param rowIndex The starting index of the rows to hide.
1764
- * @param numRows The number of rows to hide.
1765
- * @returns This sheet, for chaining.
2057
+ * @param {number} rowIndex The starting index of the rows to hide.
2058
+ * @param {number} numRows The number of rows to hide.
2059
+ * @returns {FWorksheet} This sheet, for chaining.
1766
2060
  */
1767
2061
  hideRows(e, t = 1) {
1768
- const n = this._workbook.getUnitId(), s = this._worksheet.getSheetId(), r = {
2062
+ const n = this._workbook.getUnitId(), r = this._worksheet.getSheetId(), o = {
1769
2063
  startRow: e,
1770
2064
  endRow: e + t - 1,
1771
2065
  startColumn: 0,
1772
2066
  endColumn: this._worksheet.getColumnCount() - 1,
1773
2067
  rangeType: _.ROW
1774
2068
  };
1775
- return this._commandService.syncExecuteCommand(ce.id, {
2069
+ return this._commandService.syncExecuteCommand(le.id, {
1776
2070
  unitId: n,
1777
- subUnitId: s,
1778
- ranges: [r]
2071
+ subUnitId: r,
2072
+ ranges: [o]
1779
2073
  }), this;
1780
2074
  }
1781
2075
  /**
1782
- * Unhides the row in the given range.
1783
- * @param row The range to unhide, if hidden.
1784
- * @returns This sheet, for chaining.
2076
+ * Make the row in the given range visible.
2077
+ * @param {FRange} row The range to unhide, if hidden.
2078
+ * @returns {FWorksheet} This sheet, for chaining.
1785
2079
  */
1786
2080
  unhideRow(e) {
1787
- const t = this._workbook.getUnitId(), n = this._worksheet.getSheetId(), s = V(e.getRange(), this._worksheet);
1788
- return this._commandService.syncExecuteCommand(de.id, {
2081
+ const t = this._workbook.getUnitId(), n = this._worksheet.getSheetId(), r = q(e.getRange(), this._worksheet);
2082
+ return this._commandService.syncExecuteCommand(ge.id, {
1789
2083
  unitId: t,
1790
2084
  subUnitId: n,
1791
- ranges: [s]
2085
+ ranges: [r]
1792
2086
  }), this;
1793
2087
  }
1794
2088
  /**
1795
- * Unhides one or more consecutive rows starting at the given index. Use 0-index for this method.
1796
- * @param rowIndex The starting index of the rows to unhide.
1797
- * @param numRows The number of rows to unhide.
1798
- * @returns This sheet, for chaining.
2089
+ * Scrolling sheet to make specific rows visible.
2090
+ * @param {number} rowIndex The starting index of the rows
2091
+ * @param {number} numRows The number of rows
2092
+ * @returns {FWorksheet} This sheet, for chaining.
1799
2093
  */
1800
2094
  showRows(e, t = 1) {
1801
- const n = this._workbook.getUnitId(), s = this._worksheet.getSheetId(), r = {
2095
+ const n = this._workbook.getUnitId(), r = this._worksheet.getSheetId(), o = {
1802
2096
  startRow: e,
1803
2097
  endRow: e + t - 1,
1804
2098
  startColumn: 0,
1805
2099
  endColumn: this._worksheet.getColumnCount() - 1,
1806
2100
  rangeType: _.ROW
1807
2101
  };
1808
- return this._commandService.syncExecuteCommand(de.id, {
2102
+ return this._commandService.syncExecuteCommand(ge.id, {
1809
2103
  unitId: n,
1810
- subUnitId: s,
1811
- ranges: [r]
2104
+ subUnitId: r,
2105
+ ranges: [o]
1812
2106
  }), this;
1813
2107
  }
1814
2108
  /**
1815
2109
  * Sets the row height of the given row in pixels. By default, rows grow to fit cell contents. If you want to force rows to a specified height, use setRowHeightsForced(startRow, numRows, height).
1816
- * @param rowPosition The row position to change.
1817
- * @param height The height in pixels to set it to.
1818
- * @returns This sheet, for chaining.
2110
+ * @param {number} rowPosition The row position to change.
2111
+ * @param {number} height The height in pixels to set it to.
2112
+ * @returns {FWorksheet} This sheet, for chaining.
1819
2113
  */
1820
2114
  setRowHeight(e, t) {
1821
2115
  return this.setRowHeights(e, 1, t);
1822
2116
  }
1823
2117
  /**
1824
- * Sets the height of the given rows in pixels. By default, rows grow to fit cell contents. If you want to force rows to a specified height, use setRowHeightsForced(startRow, numRows, height).
1825
- * @param startRow The starting row position to change.
1826
- * @param numRows The number of rows to change.
1827
- * @param height The height in pixels to set it to.
1828
- * @returns This sheet, for chaining.
2118
+ * Sets the height of the given rows in pixels.
2119
+ * By default, rows grow to fit cell contents. If you want to force rows to a specified height, use setRowHeightsForced(startRow, numRows, height).
2120
+ * @param {number} startRow The starting row position to change.
2121
+ * @param {number} numRows The number of rows to change.
2122
+ * @param {number} height The height in pixels to set it to.
2123
+ * @returns {FWorksheet} This sheet, for chaining.
1829
2124
  */
1830
2125
  setRowHeights(e, t, n) {
1831
2126
  var c;
1832
- const s = this._workbook.getUnitId(), r = this._worksheet.getSheetId(), i = this._worksheet.getRowManager(), a = [], h = [];
2127
+ const r = this._workbook.getUnitId(), o = this._worksheet.getSheetId(), i = this._worksheet.getRowManager(), a = [], h = [];
1833
2128
  for (let d = e; d < e + t; d++) {
1834
- const O = ((c = i.getRow(d)) == null ? void 0 : c.ah) || this._worksheet.getConfig().defaultRowHeight, x = {
2129
+ const z = ((c = i.getRow(d)) == null ? void 0 : c.ah) || this._worksheet.getConfig().defaultRowHeight, M = {
1835
2130
  startRow: d,
1836
2131
  endRow: d,
1837
2132
  startColumn: 0,
1838
2133
  endColumn: this._worksheet.getColumnCount() - 1
1839
2134
  };
1840
- n <= O ? a.push(x) : h.push(x);
2135
+ n <= z ? a.push(M) : h.push(M);
1841
2136
  }
1842
- return h.length > 0 && this._commandService.syncExecuteCommand(me.id, {
1843
- unitId: s,
1844
- subUnitId: r,
2137
+ return h.length > 0 && this._commandService.syncExecuteCommand(_e.id, {
2138
+ unitId: r,
2139
+ subUnitId: o,
1845
2140
  ranges: h,
1846
2141
  value: n
1847
- }), a.length > 0 && this._commandService.syncExecuteCommand(dt.id, {
1848
- unitId: s,
1849
- subUnitId: r,
2142
+ }), a.length > 0 && this._commandService.syncExecuteCommand(_t.id, {
2143
+ unitId: r,
2144
+ subUnitId: o,
1850
2145
  ranges: a
1851
2146
  }), this;
1852
2147
  }
1853
2148
  /**
1854
2149
  * Sets the height of the given rows in pixels. By default, rows grow to fit cell contents. When you use setRowHeightsForced, rows are forced to the specified height even if the cell contents are taller than the row height.
1855
- * @param startRow The starting row position to change.
1856
- * @param numRows The number of rows to change.
1857
- * @param height The height in pixels to set it to.
1858
- * @returns This sheet, for chaining.
2150
+ * @param {number} startRow The starting row position to change.
2151
+ * @param {number} numRows The number of rows to change.
2152
+ * @param {number} height The height in pixels to set it to.
2153
+ * @returns {FWorksheet} This sheet, for chaining.
1859
2154
  */
1860
2155
  setRowHeightsForced(e, t, n) {
1861
- const s = this._workbook.getUnitId(), r = this._worksheet.getSheetId(), i = [
2156
+ const r = this._workbook.getUnitId(), o = this._worksheet.getSheetId(), i = [
1862
2157
  {
1863
2158
  startRow: e,
1864
2159
  endRow: e + t - 1,
@@ -1866,9 +2161,9 @@ let g = class extends X {
1866
2161
  endColumn: this._worksheet.getColumnCount() - 1
1867
2162
  }
1868
2163
  ];
1869
- return this._commandService.syncExecuteCommand(me.id, {
1870
- unitId: s,
1871
- subUnitId: r,
2164
+ return this._commandService.syncExecuteCommand(_e.id, {
2165
+ unitId: r,
2166
+ subUnitId: o,
1872
2167
  ranges: i,
1873
2168
  value: n
1874
2169
  }), this;
@@ -1880,17 +2175,17 @@ let g = class extends X {
1880
2175
  * @returns This sheet, for chaining.
1881
2176
  */
1882
2177
  setRowCustom(e) {
1883
- const t = this._workbook.getUnitId(), n = this._worksheet.getSheetId(), s = {};
2178
+ const t = this._workbook.getUnitId(), n = this._worksheet.getSheetId(), r = {};
1884
2179
  for (const [i, a] of Object.entries(e))
1885
- s[Number(i)] = {
2180
+ r[Number(i)] = {
1886
2181
  custom: a
1887
2182
  };
1888
- const r = {
2183
+ const o = {
1889
2184
  unitId: t,
1890
2185
  subUnitId: n,
1891
- rowData: s
2186
+ rowData: r
1892
2187
  };
1893
- return this._commandService.syncExecuteCommand(ae.id, r), this;
2188
+ return this._commandService.syncExecuteCommand(ue.id, o), this;
1894
2189
  }
1895
2190
  // #region Column
1896
2191
  /**
@@ -1925,11 +2220,11 @@ let g = class extends X {
1925
2220
  * @returns This sheet, for chaining.
1926
2221
  */
1927
2222
  insertColumnsAfter(e, t) {
1928
- 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);
1929
- return this._commandService.syncExecuteCommand(ue.id, {
2223
+ const n = this._workbook.getUnitId(), r = this._worksheet.getSheetId(), o = D.RIGHT, i = 0, a = this._worksheet.getRowCount() - 1, h = e + 1, c = e + t, d = W(this._worksheet, i, a, h, c, !1, e);
2224
+ return this._commandService.syncExecuteCommand(we.id, {
1930
2225
  unitId: n,
1931
- subUnitId: s,
1932
- direction: r,
2226
+ subUnitId: r,
2227
+ direction: o,
1933
2228
  range: {
1934
2229
  startRow: i,
1935
2230
  endRow: a,
@@ -1946,11 +2241,11 @@ let g = class extends X {
1946
2241
  * @returns This sheet, for chaining.
1947
2242
  */
1948
2243
  insertColumnsBefore(e, t) {
1949
- 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);
1950
- return this._commandService.syncExecuteCommand(ue.id, {
2244
+ const n = this._workbook.getUnitId(), r = this._worksheet.getSheetId(), o = D.LEFT, i = 0, a = this._worksheet.getRowCount() - 1, h = e, c = e + t - 1, d = W(this._worksheet, i, a, h, c, !1, e - 1);
2245
+ return this._commandService.syncExecuteCommand(we.id, {
1951
2246
  unitId: n,
1952
- subUnitId: s,
1953
- direction: r,
2247
+ subUnitId: r,
2248
+ direction: o,
1954
2249
  range: {
1955
2250
  startRow: i,
1956
2251
  endRow: a,
@@ -1981,7 +2276,7 @@ let g = class extends X {
1981
2276
  startColumn: e,
1982
2277
  endColumn: e + t - 1
1983
2278
  };
1984
- return this._commandService.syncExecuteCommand(mt.id, {
2279
+ return this._commandService.syncExecuteCommand(wt.id, {
1985
2280
  range: n,
1986
2281
  unitId: this._workbook.getUnitId(),
1987
2282
  subUnitId: this._worksheet.getSheetId()
@@ -1994,16 +2289,16 @@ let g = class extends X {
1994
2289
  * @returns This sheet, for chaining.
1995
2290
  */
1996
2291
  moveColumns(e, t) {
1997
- const n = this._workbook.getUnitId(), s = this._worksheet.getSheetId(), r = H(e.getRange(), this._worksheet), i = r, a = {
2292
+ const n = this._workbook.getUnitId(), r = this._worksheet.getSheetId(), o = K(e.getRange(), this._worksheet), i = o, a = {
1998
2293
  startRow: 0,
1999
2294
  endRow: this._worksheet.getRowCount() - 1,
2000
2295
  startColumn: t,
2001
2296
  endColumn: t
2002
2297
  };
2003
- return this._commandService.syncExecuteCommand(ut.id, {
2298
+ return this._commandService.syncExecuteCommand(kt.id, {
2004
2299
  unitId: n,
2005
- subUnitId: s,
2006
- range: r,
2300
+ subUnitId: r,
2301
+ range: o,
2007
2302
  fromRange: i,
2008
2303
  toRange: a
2009
2304
  }), this;
@@ -2014,11 +2309,11 @@ let g = class extends X {
2014
2309
  * @returns This sheet, for chaining.
2015
2310
  */
2016
2311
  hideColumn(e) {
2017
- const t = this._workbook.getUnitId(), n = this._worksheet.getSheetId(), s = H(e.getRange(), this._worksheet);
2018
- return this._commandService.syncExecuteCommand(le.id, {
2312
+ const t = this._workbook.getUnitId(), n = this._worksheet.getSheetId(), r = K(e.getRange(), this._worksheet);
2313
+ return this._commandService.syncExecuteCommand(ke.id, {
2019
2314
  unitId: t,
2020
2315
  subUnitId: n,
2021
- ranges: [s]
2316
+ ranges: [r]
2022
2317
  }), this;
2023
2318
  }
2024
2319
  /**
@@ -2028,50 +2323,50 @@ let g = class extends X {
2028
2323
  * @returns This sheet, for chaining.
2029
2324
  */
2030
2325
  hideColumns(e, t = 1) {
2031
- const n = this._workbook.getUnitId(), s = this._worksheet.getSheetId(), r = {
2326
+ const n = this._workbook.getUnitId(), r = this._worksheet.getSheetId(), o = {
2032
2327
  startRow: 0,
2033
2328
  endRow: this._worksheet.getRowCount() - 1,
2034
2329
  startColumn: e,
2035
2330
  endColumn: e + t - 1,
2036
2331
  rangeType: _.COLUMN
2037
2332
  };
2038
- return this._commandService.syncExecuteCommand(le.id, {
2333
+ return this._commandService.syncExecuteCommand(ke.id, {
2039
2334
  unitId: n,
2040
- subUnitId: s,
2041
- ranges: [r]
2335
+ subUnitId: r,
2336
+ ranges: [o]
2042
2337
  }), this;
2043
2338
  }
2044
2339
  /**
2045
- * Unhides the column in the given range.
2340
+ * Show the column in the given range.
2046
2341
  * @param column The range to unhide, if hidden.
2047
2342
  * @returns This sheet, for chaining.
2048
2343
  */
2049
2344
  unhideColumn(e) {
2050
- const t = this._workbook.getUnitId(), n = this._worksheet.getSheetId(), s = H(e.getRange(), this._worksheet);
2051
- return this._commandService.syncExecuteCommand(ge.id, {
2345
+ const t = this._workbook.getUnitId(), n = this._worksheet.getSheetId(), r = K(e.getRange(), this._worksheet);
2346
+ return this._commandService.syncExecuteCommand(Se.id, {
2052
2347
  unitId: t,
2053
2348
  subUnitId: n,
2054
- ranges: [s]
2349
+ ranges: [r]
2055
2350
  }), this;
2056
2351
  }
2057
2352
  /**
2058
- * Unhides one or more consecutive columns starting at the given index. Use 0-index for this method.
2353
+ * Show one or more consecutive columns starting at the given index. Use 0-index for this method.
2059
2354
  * @param columnIndex The starting index of the columns to unhide.
2060
2355
  * @param numColumns The number of columns to unhide.
2061
2356
  * @returns This sheet, for chaining.
2062
2357
  */
2063
2358
  showColumns(e, t = 1) {
2064
- const n = this._workbook.getUnitId(), s = this._worksheet.getSheetId(), r = {
2359
+ const n = this._workbook.getUnitId(), r = this._worksheet.getSheetId(), o = {
2065
2360
  startRow: 0,
2066
2361
  endRow: this._worksheet.getRowCount() - 1,
2067
2362
  startColumn: e,
2068
2363
  endColumn: e + t - 1,
2069
2364
  rangeType: _.COLUMN
2070
2365
  };
2071
- return this._commandService.syncExecuteCommand(ge.id, {
2366
+ return this._commandService.syncExecuteCommand(Se.id, {
2072
2367
  unitId: n,
2073
- subUnitId: s,
2074
- ranges: [r]
2368
+ subUnitId: r,
2369
+ ranges: [o]
2075
2370
  }), this;
2076
2371
  }
2077
2372
  /**
@@ -2091,7 +2386,7 @@ let g = class extends X {
2091
2386
  * @returns This sheet, for chaining.
2092
2387
  */
2093
2388
  setColumnWidths(e, t, n) {
2094
- const s = this._workbook.getUnitId(), r = this._worksheet.getSheetId(), i = [
2389
+ const r = this._workbook.getUnitId(), o = this._worksheet.getSheetId(), i = [
2095
2390
  {
2096
2391
  startColumn: e,
2097
2392
  endColumn: e + t - 1,
@@ -2099,9 +2394,9 @@ let g = class extends X {
2099
2394
  endRow: this._worksheet.getRowCount() - 1
2100
2395
  }
2101
2396
  ];
2102
- return this._commandService.syncExecuteCommand(lt.id, {
2103
- unitId: s,
2104
- subUnitId: r,
2397
+ return this._commandService.syncExecuteCommand(St.id, {
2398
+ unitId: r,
2399
+ subUnitId: o,
2105
2400
  ranges: i,
2106
2401
  value: n
2107
2402
  }), this;
@@ -2113,17 +2408,17 @@ let g = class extends X {
2113
2408
  * @returns This sheet, for chaining.
2114
2409
  */
2115
2410
  setColumnCustom(e) {
2116
- const t = this._workbook.getUnitId(), n = this._worksheet.getSheetId(), s = {};
2411
+ const t = this._workbook.getUnitId(), n = this._worksheet.getSheetId(), r = {};
2117
2412
  for (const [i, a] of Object.entries(e))
2118
- s[Number(i)] = {
2413
+ r[Number(i)] = {
2119
2414
  custom: a
2120
2415
  };
2121
- const r = {
2416
+ const o = {
2122
2417
  unitId: t,
2123
2418
  subUnitId: n,
2124
- columnData: s
2419
+ columnData: r
2125
2420
  };
2126
- return this._commandService.syncExecuteCommand(ie.id, r), this;
2421
+ return this._commandService.syncExecuteCommand(de.id, o), this;
2127
2422
  }
2128
2423
  // #region merge cells
2129
2424
  /**
@@ -2131,7 +2426,7 @@ let g = class extends X {
2131
2426
  * @returns all merged cells
2132
2427
  */
2133
2428
  getMergedRanges() {
2134
- return this._worksheet.getSnapshot().mergeData.map((t) => this._injector.createInstance(k, this._workbook, this._worksheet, t));
2429
+ return this._worksheet.getSnapshot().mergeData.map((t) => this._injector.createInstance(w, this._workbook, this._worksheet, t));
2135
2430
  }
2136
2431
  /**
2137
2432
  * Get the merged cell data of the specified row and column.
@@ -2140,9 +2435,9 @@ let g = class extends X {
2140
2435
  * @returns {FRange|undefined} The merged cell data, or undefined if the cell is not merged.
2141
2436
  */
2142
2437
  getCellMergeData(e, t) {
2143
- const s = this._worksheet.getMergedCell(e, t);
2144
- if (s)
2145
- return this._injector.createInstance(k, this._workbook, this._worksheet, s);
2438
+ const r = this._worksheet.getMergedCell(e, t);
2439
+ if (r)
2440
+ return this._injector.createInstance(w, this._workbook, this._worksheet, r);
2146
2441
  }
2147
2442
  // #endregion
2148
2443
  /**
@@ -2154,24 +2449,24 @@ let g = class extends X {
2154
2449
  }
2155
2450
  /**
2156
2451
  * Sets the active selection region for this sheet.
2157
- * @param range The range to set as the active selection.
2452
+ * @param {FRange} range The range to set as the active selection.
2453
+ * @returns {FWorksheet} This sheet, for chaining.
2158
2454
  */
2159
2455
  setActiveRange(e) {
2160
2456
  const { unitId: t, sheetId: n } = e.getRange();
2161
2457
  if (t !== this._workbook.getUnitId() || n !== this._worksheet.getSheetId())
2162
2458
  throw new Error("Specified range must be part of the sheet.");
2163
- this._fWorkbook.setActiveRange(e);
2459
+ return this._fWorkbook.setActiveRange(e), this;
2164
2460
  }
2165
2461
  /**
2166
2462
  * Sets the frozen state of the current sheet.
2167
2463
  * @param freeze - the scrolling viewport start range and count of freezed rows and columns.
2168
2464
  * that means if you want to freeze the first 3 rows and 2 columns, you should set freeze as { startRow: 3, startColumn: 2, xSplit: 2, ySplit: 3 }
2169
- *
2170
2465
  * @deprecated use `setFrozenRows` and `setFrozenColumns` instead.
2171
2466
  * @returns True if the command was successful, false otherwise.
2172
2467
  */
2173
2468
  setFreeze(e) {
2174
- return this._logService.warn("setFreeze is deprecated, use setFrozenRows and setFrozenColumns instead"), this._commandService.syncExecuteCommand(L.id, {
2469
+ return this._logService.warn("setFreeze is deprecated, use setFrozenRows and setFrozenColumns instead"), this._commandService.syncExecuteCommand(H.id, {
2175
2470
  ...e,
2176
2471
  unitId: this._workbook.getUnitId(),
2177
2472
  subUnitId: this.getSheetId()
@@ -2182,7 +2477,7 @@ let g = class extends X {
2182
2477
  * @returns True if the command was successful, false otherwise.
2183
2478
  */
2184
2479
  cancelFreeze() {
2185
- return this._commandService.syncExecuteCommand(gt.id, {
2480
+ return this._commandService.syncExecuteCommand(Ct.id, {
2186
2481
  unitId: this._workbook.getUnitId(),
2187
2482
  subUnitId: this.getSheetId()
2188
2483
  }), this;
@@ -2190,7 +2485,6 @@ let g = class extends X {
2190
2485
  /**
2191
2486
  * Get the freeze state of the current sheet.
2192
2487
  * @returns The freeze state of the current sheet.
2193
- *
2194
2488
  * @deprecated use `getRowFreezeStatus` and `getColumnFreezeStatus` instead.
2195
2489
  */
2196
2490
  getFreeze() {
@@ -2206,10 +2500,10 @@ let g = class extends X {
2206
2500
  xSplit: n
2207
2501
  });
2208
2502
  } else if (arguments.length === 2) {
2209
- let [n = 0, s = 0] = e;
2210
- n > s && ([n, s] = [s, n]), this._commandService.syncExecuteCommand(L.id, {
2211
- startColumn: s + 1,
2212
- xSplit: s - n + 1,
2503
+ let [n = 0, r = 0] = e;
2504
+ n > r && ([n, r] = [r, n]), this._commandService.syncExecuteCommand(H.id, {
2505
+ startColumn: r + 1,
2506
+ xSplit: r - n + 1,
2213
2507
  startRow: t.startRow,
2214
2508
  ySplit: t.ySplit,
2215
2509
  unitId: this._workbook.getUnitId(),
@@ -2228,10 +2522,10 @@ let g = class extends X {
2228
2522
  ySplit: n
2229
2523
  });
2230
2524
  } else if (arguments.length === 2) {
2231
- let [n = 0, s = 0] = e;
2232
- n > s && ([n, s] = [s, n]), this._commandService.syncExecuteCommand(L.id, {
2233
- startRow: s + 1,
2234
- ySplit: s - n + 1,
2525
+ let [n = 0, r = 0] = e;
2526
+ n > r && ([n, r] = [r, n]), this._commandService.syncExecuteCommand(H.id, {
2527
+ startRow: r + 1,
2528
+ ySplit: r - n + 1,
2235
2529
  startColumn: t.startColumn,
2236
2530
  xSplit: t.xSplit,
2237
2531
  unitId: this._workbook.getUnitId(),
@@ -2242,8 +2536,7 @@ let g = class extends X {
2242
2536
  }
2243
2537
  /**
2244
2538
  * Get the number of frozen columns.
2245
- * @returns The number of frozen columns.
2246
- * Returns 0 if no columns are frozen.
2539
+ * @returns The number of frozen columns, returns 0 if no columns are frozen.
2247
2540
  */
2248
2541
  getFrozenColumns() {
2249
2542
  const e = this.getFreeze();
@@ -2251,8 +2544,7 @@ let g = class extends X {
2251
2544
  }
2252
2545
  /**
2253
2546
  * Get the number of frozen rows.
2254
- * @returns The number of frozen rows.
2255
- * Returns 0 if no rows are frozen.
2547
+ * @returns The number of frozen rows. returns 0 if no rows are frozen.
2256
2548
  */
2257
2549
  getFrozenRows() {
2258
2550
  const e = this.getFreeze();
@@ -2260,6 +2552,7 @@ let g = class extends X {
2260
2552
  }
2261
2553
  /**
2262
2554
  * Get freezed rows.
2555
+ * @returns {IRowRange} The range of the frozen rows.
2263
2556
  */
2264
2557
  getFrozenRowRange() {
2265
2558
  const e = this._worksheet.getFreeze();
@@ -2270,6 +2563,7 @@ let g = class extends X {
2270
2563
  }
2271
2564
  /**
2272
2565
  * Get freezed columns
2566
+ * @returns {IColumnRange} The range of the frozen columns.
2273
2567
  */
2274
2568
  getFrozenColumnRange() {
2275
2569
  const e = this._worksheet.getFreeze();
@@ -2292,11 +2586,12 @@ let g = class extends X {
2292
2586
  * ```
2293
2587
  */
2294
2588
  hasHiddenGridLines() {
2295
- return this._worksheet.getConfig().showGridlines === u.FALSE;
2589
+ return this._worksheet.getConfig().showGridlines === m.FALSE;
2296
2590
  }
2297
2591
  /**
2298
2592
  * Hides or reveals the sheet gridlines.
2299
2593
  * @param {boolean} hidden If `true`, hide gridlines in this sheet; otherwise show the gridlines.
2594
+ * @returns {FWorksheet} Returns the current worksheet instance for method chaining
2300
2595
  * @example
2301
2596
  * ``` ts
2302
2597
  * const fWorkbook = univerAPI.getActiveWorkbook();
@@ -2306,10 +2601,10 @@ let g = class extends X {
2306
2601
  * ```
2307
2602
  */
2308
2603
  setHiddenGridlines(e) {
2309
- return this._commandService.executeCommand(_t.id, {
2604
+ return this._commandService.executeCommand(It.id, {
2310
2605
  unitId: this._workbook.getUnitId(),
2311
2606
  subUnitId: this._worksheet.getSheetId(),
2312
- showGridlines: e ? u.FALSE : u.TRUE
2607
+ showGridlines: e ? m.FALSE : m.TRUE
2313
2608
  }), this;
2314
2609
  }
2315
2610
  /**
@@ -2325,7 +2620,7 @@ let g = class extends X {
2325
2620
  * ```
2326
2621
  */
2327
2622
  setGridLinesColor(e) {
2328
- return this._commandService.syncExecuteCommand(wt.id, {
2623
+ return this._commandService.syncExecuteCommand(ft.id, {
2329
2624
  unitId: this._workbook.getUnitId(),
2330
2625
  subUnitId: this._worksheet.getSheetId(),
2331
2626
  color: e
@@ -2351,7 +2646,7 @@ let g = class extends X {
2351
2646
  * ```
2352
2647
  */
2353
2648
  setTabColor(e) {
2354
- return this._commandService.executeCommand(St.id, {
2649
+ return this._commandService.executeCommand(vt.id, {
2355
2650
  unitId: this._workbook.getUnitId(),
2356
2651
  subUnitId: this._worksheet.getSheetId(),
2357
2652
  color: e
@@ -2390,9 +2685,9 @@ let g = class extends X {
2390
2685
  */
2391
2686
  onCellDataChange(e) {
2392
2687
  return this._injector.get(l).onCommandExecuted((n) => {
2393
- if (n.id === _e.id) {
2394
- const s = n.params;
2395
- s.unitId === this._workbook.getUnitId() && s.subUnitId === this._worksheet.getSheetId() && s.cellValue && e(new T(s.cellValue));
2688
+ if (n.id === Ce.id) {
2689
+ const r = n.params;
2690
+ r.unitId === this._workbook.getUnitId() && r.subUnitId === this._worksheet.getSheetId() && r.cellValue && e(new A(r.cellValue));
2396
2691
  }
2397
2692
  });
2398
2693
  }
@@ -2414,27 +2709,28 @@ let g = class extends X {
2414
2709
  */
2415
2710
  onBeforeCellDataChange(e) {
2416
2711
  return this._injector.get(l).beforeCommandExecuted((n) => {
2417
- if (n.id === _e.id) {
2418
- const s = n.params;
2419
- s.unitId === this._workbook.getUnitId() && s.subUnitId === this._worksheet.getSheetId() && s.cellValue && e(new T(s.cellValue));
2712
+ if (n.id === Ce.id) {
2713
+ const r = n.params;
2714
+ r.unitId === this._workbook.getUnitId() && r.subUnitId === this._worksheet.getSheetId() && r.cellValue && e(new A(r.cellValue));
2420
2715
  }
2421
2716
  });
2422
2717
  }
2423
2718
  /**
2424
2719
  * Hides this sheet. Has no effect if the sheet is already hidden. If this method is called on the only visible sheet, it throws an exception.
2720
+ * @returns {FWorksheet} Returns the current worksheet instance for method chaining
2425
2721
  * @example
2426
2722
  * ```ts
2427
2723
  * const fWorkbook = univerAPI.getActiveWorkbook();
2428
2724
  * const fWorkSheet = fWorkbook.getActiveSheet();
2429
2725
  * // hide the active sheet
2430
2726
  * fWorkSheet.hideSheet();
2431
- * ``
2727
+ * ```
2432
2728
  */
2433
2729
  hideSheet() {
2434
2730
  const e = this._injector.get(l);
2435
- if (this._workbook.getSheets().filter((r) => r.isSheetHidden() !== u.TRUE).length <= 1)
2731
+ if (this._workbook.getSheets().filter((o) => o.isSheetHidden() !== m.TRUE).length <= 1)
2436
2732
  throw new Error("Cannot hide the only visible sheet");
2437
- return e.syncExecuteCommand(kt.id, {
2733
+ return e.syncExecuteCommand(Rt.id, {
2438
2734
  unitId: this._workbook.getUnitId(),
2439
2735
  subUnitId: this._worksheet.getSheetId()
2440
2736
  }), this;
@@ -2451,7 +2747,7 @@ let g = class extends X {
2451
2747
  * ```
2452
2748
  */
2453
2749
  showSheet() {
2454
- return this._injector.get(l).syncExecuteCommand(Ct.id, {
2750
+ return this._injector.get(l).syncExecuteCommand(bt.id, {
2455
2751
  unitId: this._workbook.getUnitId(),
2456
2752
  subUnitId: this._worksheet.getSheetId()
2457
2753
  }), this;
@@ -2461,7 +2757,7 @@ let g = class extends X {
2461
2757
  * @returns {boolean} True if the sheet is hidden; otherwise, false.
2462
2758
  */
2463
2759
  isSheetHidden() {
2464
- return this._worksheet.isSheetHidden() === u.TRUE;
2760
+ return this._worksheet.isSheetHidden() === m.TRUE;
2465
2761
  }
2466
2762
  /**
2467
2763
  * Sets the sheet name.
@@ -2476,7 +2772,7 @@ let g = class extends X {
2476
2772
  * ```
2477
2773
  */
2478
2774
  setName(e) {
2479
- return this._commandService.syncExecuteCommand(It.id, {
2775
+ return this._commandService.syncExecuteCommand(pt.id, {
2480
2776
  unitId: this._workbook.getUnitId(),
2481
2777
  subUnitId: this._worksheet.getSheetId(),
2482
2778
  name: e
@@ -2521,20 +2817,17 @@ let g = class extends X {
2521
2817
  * ```
2522
2818
  */
2523
2819
  clear(e) {
2524
- if (e && e.contentsOnly && !e.formatOnly)
2525
- return this.clearContents();
2526
- if (e && e.formatOnly && !e.contentsOnly)
2527
- return this.clearFormats();
2528
- const t = this._workbook.getUnitId(), n = this._worksheet.getSheetId(), s = this._injector.get(l), r = {
2820
+ e && e.contentsOnly && !e.formatOnly && this.clearContents(), e && e.formatOnly && !e.contentsOnly && this.clearFormats();
2821
+ const t = this._workbook.getUnitId(), n = this._worksheet.getSheetId(), r = this._injector.get(l), o = {
2529
2822
  startRow: 0,
2530
2823
  endRow: this._worksheet.getRowCount() - 1,
2531
2824
  startColumn: 0,
2532
2825
  endColumn: this._worksheet.getColumnCount() - 1
2533
2826
  };
2534
- return s.syncExecuteCommand(ft.id, {
2827
+ return r.syncExecuteCommand(yt.id, {
2535
2828
  unitId: t,
2536
2829
  subUnitId: n,
2537
- ranges: [r],
2830
+ ranges: [o],
2538
2831
  options: e
2539
2832
  }), this;
2540
2833
  }
@@ -2550,16 +2843,16 @@ let g = class extends X {
2550
2843
  * ```
2551
2844
  */
2552
2845
  clearContents() {
2553
- const e = this._workbook.getUnitId(), t = this._worksheet.getSheetId(), n = this._injector.get(l), s = {
2846
+ const e = this._workbook.getUnitId(), t = this._worksheet.getSheetId(), n = this._injector.get(l), r = {
2554
2847
  startRow: 0,
2555
2848
  endRow: this._worksheet.getRowCount() - 1,
2556
2849
  startColumn: 0,
2557
2850
  endColumn: this._worksheet.getColumnCount() - 1
2558
2851
  };
2559
- return n.syncExecuteCommand(vt.id, {
2852
+ return n.syncExecuteCommand(Ut.id, {
2560
2853
  unitId: e,
2561
2854
  subUnitId: t,
2562
- ranges: [s]
2855
+ ranges: [r]
2563
2856
  }), this;
2564
2857
  }
2565
2858
  /**
@@ -2574,16 +2867,16 @@ let g = class extends X {
2574
2867
  * ```
2575
2868
  */
2576
2869
  clearFormats() {
2577
- const e = this._workbook.getUnitId(), t = this._worksheet.getSheetId(), n = this._injector.get(l), s = {
2870
+ const e = this._workbook.getUnitId(), t = this._worksheet.getSheetId(), n = this._injector.get(l), r = {
2578
2871
  startRow: 0,
2579
2872
  endRow: this._worksheet.getRowCount() - 1,
2580
2873
  startColumn: 0,
2581
2874
  endColumn: this._worksheet.getColumnCount() - 1
2582
2875
  };
2583
- return n.syncExecuteCommand(Rt.id, {
2876
+ return n.syncExecuteCommand(Et.id, {
2584
2877
  unitId: e,
2585
2878
  subUnitId: t,
2586
- ranges: [s]
2879
+ ranges: [r]
2587
2880
  }), this;
2588
2881
  }
2589
2882
  /**
@@ -2619,6 +2912,7 @@ let g = class extends X {
2619
2912
  return this._worksheet.getLastColumnWithContent();
2620
2913
  }
2621
2914
  /**
2915
+ * @deprecated use getLastColumn instead.
2622
2916
  * Returns the position of the last column that has content. Same as getLastColumns.
2623
2917
  * @returns {number} the last column of the sheet that contains content.
2624
2918
  * @example
@@ -2633,6 +2927,7 @@ let g = class extends X {
2633
2927
  return this._worksheet.getLastColumnWithContent();
2634
2928
  }
2635
2929
  /**
2930
+ * @deprecated use getLastRow instead.
2636
2931
  * Returns the position of the last row that has content.
2637
2932
  * @returns {number} the last row of the sheet that contains content.
2638
2933
  * @example
@@ -2688,8 +2983,8 @@ let g = class extends X {
2688
2983
  * ```
2689
2984
  */
2690
2985
  insertDefinedName(e, t) {
2691
- const s = this._injector.createInstance(F).setName(e).setRef(t).build();
2692
- s.localSheetId = this.getSheetId(), this._fWorkbook.insertDefinedNameBuilder(s);
2986
+ const r = this._injector.createInstance(L).setName(e).setRef(t).build();
2987
+ r.localSheetId = this.getSheetId(), this._fWorkbook.insertDefinedNameBuilder(r);
2693
2988
  }
2694
2989
  /**
2695
2990
  * Get all the defined names in the worksheet.
@@ -2705,23 +3000,159 @@ let g = class extends X {
2705
3000
  getDefinedNames() {
2706
3001
  return this._fWorkbook.getDefinedNames().filter((t) => t.getLocalSheetId() === this.getSheetId());
2707
3002
  }
3003
+ /**
3004
+ * Set custom metadata of worksheet
3005
+ * @param {CustomData | undefined} custom custom metadata
3006
+ * @example
3007
+ * ```ts
3008
+ * const fWorkbook = univerAPI.getActiveWorkbook();
3009
+ * const fWorkSheet = fWorkbook.getActiveSheet();
3010
+ * fWorkSheet.setCustomMetadata({ key: 'value' });
3011
+ * ```
3012
+ */
3013
+ setCustomMetadata(e) {
3014
+ return this._worksheet.setCustomMetadata(e), this;
3015
+ }
3016
+ /**
3017
+ * Set custom metadata of row
3018
+ * @param {number} index row index
3019
+ * @param {CustomData | undefined} custom custom metadata
3020
+ * @example
3021
+ * ```ts
3022
+ * const fWorkbook = univerAPI.getActiveWorkbook();
3023
+ * const fWorkSheet = fWorkbook.getActiveSheet();
3024
+ * fWorkSheet.setRowCustomMetadata(0, { key: 'value' });
3025
+ * ```
3026
+ */
3027
+ setRowCustomMetadata(e, t) {
3028
+ return this._worksheet.getRowManager().setCustomMetadata(e, t), this;
3029
+ }
3030
+ /**
3031
+ * Set custom metadata of column
3032
+ * @param {number} index column index
3033
+ * @param {CustomData | undefined} custom custom metadata
3034
+ * @example
3035
+ * ```ts
3036
+ * const fWorkbook = univerAPI.getActiveWorkbook();
3037
+ * const fWorkSheet = fWorkbook.getActiveSheet();
3038
+ * fWorkSheet.setColumnCustomMetadata(0, { key: 'value' });
3039
+ * ```
3040
+ */
3041
+ setColumnCustomMetadata(e, t) {
3042
+ return this._worksheet.getColumnManager().setCustomMetadata(e, t), this;
3043
+ }
3044
+ /**
3045
+ * Get custom metadata of row
3046
+ * @param {number} index row index
3047
+ * @returns {CustomData | undefined} custom metadata
3048
+ * @example
3049
+ * ```ts
3050
+ * const fWorkbook = univerAPI.getActiveWorkbook();
3051
+ * const fWorkSheet = fWorkbook.getActiveSheet();
3052
+ * const custom = fWorkSheet.getRowCustomMetadata(0);
3053
+ * ```
3054
+ */
3055
+ getRowCustomMetadata(e) {
3056
+ return this._worksheet.getRowManager().getCustomMetadata(e);
3057
+ }
3058
+ /**
3059
+ * Get custom metadata of column
3060
+ * @param {number} index column index
3061
+ * @returns {CustomData | undefined} custom metadata
3062
+ * @example
3063
+ * ```ts
3064
+ * const fWorkbook = univerAPI.getActiveWorkbook();
3065
+ * const fWorkSheet = fWorkbook.getActiveSheet();
3066
+ * const custom = fWorkSheet.getColumnCustomMetadata(0);
3067
+ * ```
3068
+ */
3069
+ getColumnCustomMetadata(e) {
3070
+ return this._worksheet.getColumnManager().getCustomMetadata(e);
3071
+ }
3072
+ /**
3073
+ * Get all merged cells in the current worksheet
3074
+ * @returns {FRange[]} All the merged cells in the worksheet
3075
+ * @example
3076
+ * ```ts
3077
+ * const workbook = univerAPI.getActiveWorkbook();
3078
+ * const worksheet = workbook.getActiveSheet();
3079
+ * const rangeFirst = worksheet.getRange(0, 0, 2, 2);
3080
+ * const mergeFirst = rangeFirst.merge();
3081
+ * const rangeSecond = worksheet.getRange(5, 0, 2, 2);
3082
+ * const mergeSecond = rangeSecond.merge();
3083
+ * const mergeData = worksheet.getMergeData();
3084
+ * console.log('debugger', mergeData);
3085
+ * ```
3086
+ */
3087
+ getMergeData() {
3088
+ return this._worksheet.getMergeData().map((e) => this._injector.createInstance(w, this._workbook, this._worksheet, e));
3089
+ }
2708
3090
  };
2709
- g = Zt([
2710
- W(3, m(v)),
2711
- W(4, m(Ne)),
2712
- W(5, m(Ie)),
2713
- W(6, l)
3091
+ g = sn([
3092
+ T(3, u(b)),
3093
+ T(4, u(We)),
3094
+ T(5, u(pe)),
3095
+ T(6, l)
2714
3096
  ], g);
2715
- var en = Object.defineProperty, tn = Object.getOwnPropertyDescriptor, nn = (o, e, t, n) => {
2716
- for (var s = n > 1 ? void 0 : n ? tn(e, t) : e, r = o.length - 1, i; r >= 0; r--)
2717
- (i = o[r]) && (s = (n ? i(e, t, s) : i(s)) || s);
2718
- return n && s && en(e, t, s), s;
2719
- }, S = (o, e) => (t, n) => e(t, n, o);
2720
- let I = class extends X {
2721
- constructor(e, t, n, s, r, i, a, h, c, d) {
3097
+ var rn = Object.defineProperty, on = Object.getOwnPropertyDescriptor, an = (s, e, t, n) => {
3098
+ for (var r = n > 1 ? void 0 : n ? on(e, t) : e, o = s.length - 1, i; o >= 0; o--)
3099
+ (i = s[o]) && (r = (n ? i(e, t, r) : i(r)) || r);
3100
+ return n && r && rn(e, t, r), r;
3101
+ }, C = (s, e) => (t, n) => e(t, n, s);
3102
+ let I = class extends ne {
3103
+ constructor(e, t, n, r, o, i, a, h, c, d) {
2722
3104
  super(t);
2723
- p(this, "id");
2724
- 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();
3105
+ k(this, "id");
3106
+ k(this, "_eventRegistry", /* @__PURE__ */ new Map());
3107
+ this._workbook = e, this._injector = t, this._resourceLoaderService = n, this._selectionManagerService = r, this._univerInstanceService = o, this._commandService = i, this._permissionService = a, this._logService = h, this._localeService = c, this._definedNamesService = d, this.id = this._workbook.getUnitId();
3108
+ }
3109
+ getWorkbook() {
3110
+ return this._workbook;
3111
+ }
3112
+ _ensureEventRegistry(e) {
3113
+ return this._eventRegistry.has(e) || this._eventRegistry.set(e, new ye()), this._eventRegistry.get(e);
3114
+ }
3115
+ /**
3116
+ * Add an event listener
3117
+ * @param event key of event
3118
+ * @param callback callback when event triggered
3119
+ * @returns {Disposable} The Disposable instance, for remove the listener
3120
+ * @example
3121
+ * ```ts
3122
+ * univerAPI.addEvent(univerAPI.event.UnitCreated, (params) => {
3123
+ * console.log('unit created', params);
3124
+ * });
3125
+ * ```
3126
+ */
3127
+ addEvent(e, t) {
3128
+ return this._ensureEventRegistry(e).add(t), this.addUIEvent(e, t), F(() => this._ensureEventRegistry(e).delete(t));
3129
+ }
3130
+ /**
3131
+ * Fire an event, used in internal only.
3132
+ * @param event {string} key of event
3133
+ * @param params {any} params of event
3134
+ * @returns {boolean} should cancel
3135
+ * @example
3136
+ * ```ts
3137
+ * this.fireEvent(univerAPI.event.UnitCreated, params);
3138
+ * ```
3139
+ */
3140
+ fireEvent(e, t) {
3141
+ var n;
3142
+ return (n = this._eventRegistry.get(e)) == null || n.getData().forEach((r) => {
3143
+ r(t);
3144
+ }), t.cancel;
3145
+ }
3146
+ addUIEvent(e, t) {
3147
+ }
3148
+ get Enum() {
3149
+ return ze.get();
3150
+ }
3151
+ /**
3152
+ * @returns {FEventName} The event name.
3153
+ */
3154
+ get Event() {
3155
+ return se.get();
2725
3156
  }
2726
3157
  /**
2727
3158
  * Get the id of the workbook.
@@ -2763,8 +3194,8 @@ let I = class extends X {
2763
3194
  this._workbook.setName(e);
2764
3195
  }
2765
3196
  /**
2766
- * save workbook snapshot data, including conditional formatting, data validation, and other plugin data.
2767
- * @return Workbook snapshot data
3197
+ * Save workbook snapshot data, including conditional formatting, data validation, and other plugin data.
3198
+ * @returns {IWorkbookData} Workbook snapshot data
2768
3199
  * @example
2769
3200
  * ```ts
2770
3201
  * // The code below saves the workbook snapshot data
@@ -2777,7 +3208,7 @@ let I = class extends X {
2777
3208
  }
2778
3209
  /**
2779
3210
  * @deprecated use 'save' instead.
2780
- * @return {*} {IWorkbookData} Workbook snapshot data
3211
+ * @returns {*} {IWorkbookData} Workbook snapshot data
2781
3212
  * @memberof FWorkbook
2782
3213
  */
2783
3214
  getSnapshot() {
@@ -2785,7 +3216,7 @@ let I = class extends X {
2785
3216
  }
2786
3217
  /**
2787
3218
  * Get the active sheet of the workbook.
2788
- * @returns The active sheet of the workbook
3219
+ * @returns {FWorksheet} The active sheet of the workbook
2789
3220
  * @example
2790
3221
  * ```ts
2791
3222
  * // The code below gets the active sheet of the workbook
@@ -2799,7 +3230,7 @@ let I = class extends X {
2799
3230
  }
2800
3231
  /**
2801
3232
  * Gets all the worksheets in this workbook
2802
- * @returns An array of all the worksheets in the workbook
3233
+ * @returns {FWorksheet[]} An array of all the worksheets in the workbook
2803
3234
  * @example
2804
3235
  * ```ts
2805
3236
  * // The code below gets all the worksheets in the workbook
@@ -2824,24 +3255,24 @@ let I = class extends X {
2824
3255
  * ```
2825
3256
  */
2826
3257
  create(e, t, n) {
2827
- const s = Be({});
2828
- s.rowCount = t, s.columnCount = n, s.name = e, s.id = e.toLowerCase().replace(/ /g, "-"), this._commandService.syncExecuteCommand(U.id, {
3258
+ const r = $e({});
3259
+ r.rowCount = t, r.columnCount = n, r.name = e, r.id = e.toLowerCase().replace(/ /g, "-"), this._commandService.syncExecuteCommand(x.id, {
2829
3260
  unitId: this.id,
2830
3261
  index: this._workbook.getSheets().length,
2831
- sheet: s
2832
- }), this._commandService.syncExecuteCommand(z.id, {
3262
+ sheet: r
3263
+ }), this._commandService.syncExecuteCommand(G.id, {
2833
3264
  unitId: this.id,
2834
3265
  subUnitId: this._workbook.getSheets()[this._workbook.getSheets().length - 1].getSheetId()
2835
3266
  });
2836
- const r = this._workbook.getActiveSheet();
2837
- if (!r)
3267
+ const o = this._workbook.getActiveSheet();
3268
+ if (!o)
2838
3269
  throw new Error("No active sheet found");
2839
- return this._injector.createInstance(g, this, this._workbook, r);
3270
+ return this._injector.createInstance(g, this, this._workbook, o);
2840
3271
  }
2841
3272
  /**
2842
3273
  * Get a worksheet by sheet id.
2843
3274
  * @param sheetId The id of the sheet to get.
2844
- * @return The worksheet with given sheet id
3275
+ * @returns The worksheet with given sheet id
2845
3276
  * @example
2846
3277
  * ```ts
2847
3278
  * // The code below gets a worksheet by sheet id
@@ -2881,7 +3312,7 @@ let I = class extends X {
2881
3312
  * ```
2882
3313
  */
2883
3314
  setActiveSheet(e) {
2884
- return this._commandService.syncExecuteCommand(z.id, {
3315
+ return this._commandService.syncExecuteCommand(G.id, {
2885
3316
  unitId: this.id,
2886
3317
  subUnitId: e.getSheetId()
2887
3318
  }), e;
@@ -2903,20 +3334,21 @@ let I = class extends X {
2903
3334
  * ```
2904
3335
  */
2905
3336
  insertSheet(e) {
2906
- e != null ? this._commandService.syncExecuteCommand(U.id, { sheet: { name: e } }) : this._commandService.syncExecuteCommand(U.id);
3337
+ e != null ? this._commandService.syncExecuteCommand(x.id, { sheet: { name: e } }) : this._commandService.syncExecuteCommand(x.id);
2907
3338
  const t = this.id, n = this._workbook.getSheets()[this._workbook.getSheets().length - 1].getSheetId();
2908
- this._commandService.syncExecuteCommand(z.id, {
3339
+ this._commandService.syncExecuteCommand(G.id, {
2909
3340
  unitId: t,
2910
3341
  subUnitId: n
2911
3342
  });
2912
- const s = this._workbook.getActiveSheet();
2913
- if (!s)
3343
+ const r = this._workbook.getActiveSheet();
3344
+ if (!r)
2914
3345
  throw new Error("No active sheet found");
2915
- return this._injector.createInstance(g, this, this._workbook, s);
3346
+ return this._injector.createInstance(g, this, this._workbook, r);
2916
3347
  }
2917
3348
  /**
2918
3349
  * Deletes the specified worksheet.
2919
3350
  * @param sheet The worksheet to delete.
3351
+ * @returns {boolean} True if the worksheet was deleted, false otherwise.
2920
3352
  * @example
2921
3353
  * ```ts
2922
3354
  * // The code below deletes the specified worksheet
@@ -2927,7 +3359,7 @@ let I = class extends X {
2927
3359
  */
2928
3360
  deleteSheet(e) {
2929
3361
  const t = this.id, n = e.getSheetId();
2930
- return this._commandService.syncExecuteCommand(bt.id, {
3362
+ return this._commandService.syncExecuteCommand(Pt.id, {
2931
3363
  unitId: t,
2932
3364
  subUnitId: n
2933
3365
  });
@@ -2935,7 +3367,7 @@ let I = class extends X {
2935
3367
  // #region editing
2936
3368
  /**
2937
3369
  * Undo the last action.
2938
- * @returns A promise that resolves to true if the undo was successful, false otherwise.
3370
+ * @returns {FWorkbook} A promise that resolves to true if the undo was successful, false otherwise.
2939
3371
  * @example
2940
3372
  * ```ts
2941
3373
  * // The code below undoes the last action
@@ -2944,7 +3376,7 @@ let I = class extends X {
2944
3376
  * ```
2945
3377
  */
2946
3378
  undo() {
2947
- return this._univerInstanceService.focusUnit(this.id), this._commandService.syncExecuteCommand(Le.id), this;
3379
+ return this._univerInstanceService.focusUnit(this.id), this._commandService.syncExecuteCommand(He.id), this;
2948
3380
  }
2949
3381
  /**
2950
3382
  * Redo the last undone action.
@@ -2957,7 +3389,7 @@ let I = class extends X {
2957
3389
  * ```
2958
3390
  */
2959
3391
  redo() {
2960
- return this._univerInstanceService.focusUnit(this.id), this._commandService.syncExecuteCommand(ze.id), this;
3392
+ return this._univerInstanceService.focusUnit(this.id), this._commandService.syncExecuteCommand(Ge.id), this;
2961
3393
  }
2962
3394
  /**
2963
3395
  * Callback for command execution.
@@ -3008,7 +3440,6 @@ let I = class extends X {
3008
3440
  }
3009
3441
  /**
3010
3442
  * Callback for selection changes.
3011
- *
3012
3443
  * @callback onSelectionChangeCallback
3013
3444
  * @param {IRange[]} selections The new selection.
3014
3445
  */
@@ -3018,46 +3449,50 @@ let I = class extends X {
3018
3449
  * @returns A function to dispose the listening
3019
3450
  */
3020
3451
  onSelectionChange(e) {
3021
- return fe(
3452
+ return F(
3022
3453
  this._selectionManagerService.selectionMoveEnd$.subscribe((t) => {
3023
- this._univerInstanceService.getCurrentUnitForType(P.UNIVER_SHEET).getUnitId() === this.id && (t != null && t.length ? e(t.map((n) => n.range)) : e([]));
3454
+ this._univerInstanceService.getCurrentUnitForType(R.UNIVER_SHEET).getUnitId() === this.id && (t != null && t.length ? e(t.map((n) => n.range)) : e([]));
3024
3455
  })
3025
3456
  );
3026
3457
  }
3027
3458
  /**
3028
3459
  * Used to modify the editing permissions of the workbook. When the value is false, editing is not allowed.
3029
3460
  * @param {boolean} value editable value want to set
3461
+ * @returns {FWorkbook} FWorkbook instance
3030
3462
  */
3031
3463
  setEditable(e) {
3032
- const t = new Ue(this._workbook.getUnitId());
3033
- this._permissionService.getPermissionPoint(t.id) || this._permissionService.addPermissionPoint(t), this._permissionService.updatePermissionPoint(t.id, e);
3464
+ const t = new Ne(this._workbook.getUnitId());
3465
+ return this._permissionService.getPermissionPoint(t.id) || this._permissionService.addPermissionPoint(t), this._permissionService.updatePermissionPoint(t.id, e), this;
3034
3466
  }
3035
3467
  /**
3036
- * Sets the active selection region for this sheet.
3468
+ * Sets the selection region for active sheet.
3037
3469
  * @param range The range to set as the active selection.
3470
+ * @returns {FWorkbook} FWorkbook instance
3038
3471
  */
3039
3472
  setActiveRange(e) {
3040
- const t = this.getActiveSheet(), n = e.getRange().sheetId || t.getSheetId(), s = n ? this._workbook.getSheetBySheetId(n) : this._workbook.getActiveSheet(!0);
3041
- if (!s)
3473
+ const t = this.getActiveSheet(), n = e.getRange().sheetId || t.getSheetId(), r = n ? this._workbook.getSheetBySheetId(n) : this._workbook.getActiveSheet(!0);
3474
+ if (!r)
3042
3475
  throw new Error("No active sheet found");
3043
- s.getSheetId() !== t.getSheetId() && this.setActiveSheet(this._injector.createInstance(g, this, this._workbook, s));
3044
- const r = {
3476
+ r.getSheetId() !== t.getSheetId() && this.setActiveSheet(this._injector.createInstance(g, this, this._workbook, r));
3477
+ const o = {
3045
3478
  unitId: this.getId(),
3046
3479
  subUnitId: n,
3047
- selections: [e].map((i) => ({ range: i.getRange(), primary: K(i.getRange(), s), style: null }))
3480
+ selections: [e].map((i) => ({ range: i.getRange(), primary: Z(i.getRange(), r), style: null }))
3048
3481
  };
3049
- this._commandService.syncExecuteCommand(xe.id, r);
3482
+ return this._commandService.syncExecuteCommand(De.id, o), this;
3050
3483
  }
3051
3484
  /**
3052
3485
  * Returns the selected range in the active sheet, or null if there is no active range.
3053
3486
  * @returns the active range
3054
3487
  */
3488
+ // could sheet have no active range ?
3055
3489
  getActiveRange() {
3056
- const e = this._workbook.getActiveSheet(), n = this._selectionManagerService.getCurrentSelections().find((s) => !!s.primary);
3057
- return n ? this._injector.createInstance(k, this._workbook, e, n.range) : null;
3490
+ const e = this._workbook.getActiveSheet(), n = this._selectionManagerService.getCurrentSelections().find((r) => !!r.primary);
3491
+ return n ? this._injector.createInstance(w, this._workbook, e, n.range) : null;
3058
3492
  }
3059
3493
  /**
3060
3494
  * Deletes the currently active sheet.
3495
+ * @returns {boolean} true if the sheet was deleted, false otherwise
3061
3496
  * @example
3062
3497
  * ```ts
3063
3498
  * // The code below deletes the currently active sheet and stores the new active
@@ -3082,7 +3517,7 @@ let I = class extends X {
3082
3517
  * ```
3083
3518
  */
3084
3519
  duplicateSheet(e) {
3085
- return this._commandService.syncExecuteCommand(pt.id, {
3520
+ return this._commandService.syncExecuteCommand(xt.id, {
3086
3521
  unitId: e.getWorkbook().getUnitId(),
3087
3522
  subUnitId: e.getSheetId()
3088
3523
  }), this._injector.createInstance(g, this, this._workbook, this._workbook.getActiveSheet());
@@ -3127,9 +3562,17 @@ let I = class extends X {
3127
3562
  getLocale() {
3128
3563
  return this._localeService.getCurrentLocale();
3129
3564
  }
3565
+ /**
3566
+ * @deprecated use setSpreadsheetLocale instead.
3567
+ * @param {LocaleType} locale - The locale to set
3568
+ */
3569
+ setLocale(e) {
3570
+ this._localeService.setLocale(e);
3571
+ }
3130
3572
  /**
3131
3573
  * Set the locale of the workbook.
3132
3574
  * @param {LocaleType} locale The locale to set
3575
+ * @returns {FWorkbook} This workbook, for chaining
3133
3576
  * @example
3134
3577
  * ```ts
3135
3578
  * // The code below sets the locale of the workbook
@@ -3137,8 +3580,8 @@ let I = class extends X {
3137
3580
  * activeSpreadsheet.setLocale(LocaleType.EN_US);
3138
3581
  * ```
3139
3582
  */
3140
- setLocale(e) {
3141
- this._localeService.setLocale(e);
3583
+ setSpreadsheetLocale(e) {
3584
+ return this._localeService.setLocale(e), this;
3142
3585
  }
3143
3586
  /**
3144
3587
  * Get the URL of the workbook.
@@ -3168,7 +3611,7 @@ let I = class extends X {
3168
3611
  */
3169
3612
  moveSheet(e, t) {
3170
3613
  let n = t;
3171
- return n < 0 ? n = 0 : n > this._workbook.getSheets().length - 1 && (n = this._workbook.getSheets().length - 1), this._commandService.syncExecuteCommand(yt.id, {
3614
+ return n < 0 ? n = 0 : n > this._workbook.getSheets().length - 1 && (n = this._workbook.getSheets().length - 1), this._commandService.syncExecuteCommand(Nt.id, {
3172
3615
  unitId: e.getWorkbook().getUnitId(),
3173
3616
  order: n,
3174
3617
  subUnitId: e.getSheetId()
@@ -3191,11 +3634,10 @@ let I = class extends X {
3191
3634
  }
3192
3635
  /**
3193
3636
  * Get the PermissionInstance.
3194
- *
3195
3637
  * @returns {FPermission} - The PermissionInstance.
3196
3638
  */
3197
3639
  getPermission() {
3198
- return this._injector.createInstance(j);
3640
+ return this._injector.createInstance(O);
3199
3641
  }
3200
3642
  /**
3201
3643
  * Get the defined name by name.
@@ -3210,7 +3652,7 @@ let I = class extends X {
3210
3652
  */
3211
3653
  getDefinedName(e) {
3212
3654
  const t = this._definedNamesService.getValueByName(this.id, e);
3213
- return t ? this._injector.createInstance(M, { ...t, unitId: this.id }) : null;
3655
+ return t ? this._injector.createInstance(j, { ...t, unitId: this.id }) : null;
3214
3656
  }
3215
3657
  /**
3216
3658
  * Get all the defined names in the workbook.
@@ -3224,12 +3666,13 @@ let I = class extends X {
3224
3666
  */
3225
3667
  getDefinedNames() {
3226
3668
  const e = this._definedNamesService.getDefinedNameMap(this.id);
3227
- return e ? Object.values(e).map((t) => this._injector.createInstance(M, { ...t, unitId: this.id })) : [];
3669
+ return e ? Object.values(e).map((t) => this._injector.createInstance(j, { ...t, unitId: this.id })) : [];
3228
3670
  }
3229
3671
  /**
3230
3672
  * Insert a defined name.
3231
3673
  * @param {string} name The name of the defined name to insert
3232
3674
  * @param {string} formulaOrRefString The formula(=sum(A2:b10)) or reference(A1) string of the defined name to insert
3675
+ * @returns {FWorkbook} The current FWorkbook instance
3233
3676
  * @example
3234
3677
  * ```ts
3235
3678
  * // The code below inserts a defined name
@@ -3238,8 +3681,8 @@ let I = class extends X {
3238
3681
  * ```
3239
3682
  */
3240
3683
  insertDefinedName(e, t) {
3241
- const s = this._injector.createInstance(F).setName(e).setRef(t).build();
3242
- s.localSheetId = q, this.insertDefinedNameBuilder(s);
3684
+ const r = this._injector.createInstance(L).setName(e).setRef(t).build();
3685
+ return r.localSheetId = X, this.insertDefinedNameBuilder(r), this;
3243
3686
  }
3244
3687
  /**
3245
3688
  * Delete the defined name with the given name.
@@ -3257,7 +3700,7 @@ let I = class extends X {
3257
3700
  return t ? (t.delete(), !0) : !1;
3258
3701
  }
3259
3702
  /**
3260
- * insert a defined name by builder param
3703
+ * Insert a defined name by builder param.
3261
3704
  * @param {ISetDefinedNameMutationParam} param The param to insert the defined name
3262
3705
  * @example
3263
3706
  * ```ts
@@ -3269,7 +3712,7 @@ let I = class extends X {
3269
3712
  * ```
3270
3713
  */
3271
3714
  insertDefinedNameBuilder(e) {
3272
- e.unitId = this.getId(), this._commandService.syncExecuteCommand(G.id, e);
3715
+ e.unitId = this.getId(), this._commandService.syncExecuteCommand(Q.id, e);
3273
3716
  }
3274
3717
  /**
3275
3718
  * Update the defined name with the given name.
@@ -3284,7 +3727,7 @@ let I = class extends X {
3284
3727
  * ```
3285
3728
  */
3286
3729
  updateDefinedNameBuilder(e) {
3287
- this._commandService.syncExecuteCommand(G.id, e);
3730
+ this._commandService.syncExecuteCommand(Q.id, e);
3288
3731
  }
3289
3732
  /**
3290
3733
  * Gets the registered range themes.
@@ -3298,10 +3741,11 @@ let I = class extends X {
3298
3741
  * ```
3299
3742
  */
3300
3743
  getRegisteredRangeThemes() {
3301
- return this._injector.get(Ee).getRegisteredRangeThemes();
3744
+ return this._injector.get(Me).getRegisteredRangeThemes();
3302
3745
  }
3303
3746
  /**
3304
3747
  * Register a custom range theme style.
3748
+ * @param rangeThemeStyle
3305
3749
  * @example
3306
3750
  * ```ts
3307
3751
  * // import {RangeThemeStyle} from '@univerjs/sheets';
@@ -3316,13 +3760,14 @@ let I = class extends X {
3316
3760
  * ```
3317
3761
  */
3318
3762
  registerRangeTheme(e) {
3319
- this._commandService.syncExecuteCommand(Pt.id, {
3763
+ this._commandService.syncExecuteCommand(Mt.id, {
3320
3764
  unitId: this.getId(),
3321
3765
  rangeThemeStyle: e
3322
3766
  });
3323
3767
  }
3324
3768
  /**
3325
3769
  * Unregister a custom range theme style.
3770
+ * @param themeName
3326
3771
  * @example
3327
3772
  * ```ts
3328
3773
  * const fWorkbook = univerAPI.getActiveWorkbook();
@@ -3330,32 +3775,106 @@ let I = class extends X {
3330
3775
  * ```
3331
3776
  */
3332
3777
  unregisterRangeTheme(e) {
3333
- this._commandService.syncExecuteCommand(Ut.id, {
3778
+ this._commandService.syncExecuteCommand(Dt.id, {
3334
3779
  unitId: this.getId(),
3335
3780
  themeName: e
3336
3781
  });
3337
3782
  }
3783
+ /**
3784
+ * Set custom metadata of workbook
3785
+ * @param {CustomData | undefined} custom custom metadata
3786
+ * @returns {FWorkbook} FWorkbook
3787
+ * @example
3788
+ * ```ts
3789
+ * const fWorkbook = univerAPI.getActiveWorkbook();
3790
+ * fWorkbook.setCustomMetadata({ key: 'value' });
3791
+ * ```
3792
+ */
3793
+ setCustomMetadata(e) {
3794
+ return this._workbook.setCustomMetadata(e), this;
3795
+ }
3796
+ /**
3797
+ * Get custom metadata of workbook
3798
+ * @returns {CustomData | undefined} custom metadata
3799
+ * @example
3800
+ * ```ts
3801
+ * const fWorkbook = univerAPI.getActiveWorkbook();
3802
+ * const custom = fWorkbook.getCustomMetadata();
3803
+ * ```
3804
+ */
3805
+ getCustomMetadata() {
3806
+ return this._workbook.getCustomMetadata();
3807
+ }
3338
3808
  };
3339
- I = nn([
3340
- S(1, m(v)),
3341
- S(2, m(Oe)),
3342
- S(3, m(Ne)),
3343
- S(4, ve),
3344
- S(5, l),
3345
- S(6, J),
3346
- S(7, Ie),
3347
- S(8, m(ke)),
3348
- S(9, De)
3809
+ I = an([
3810
+ C(1, u(b)),
3811
+ C(2, u(Le)),
3812
+ C(3, u(We)),
3813
+ C(4, J),
3814
+ C(5, l),
3815
+ C(6, ee),
3816
+ C(7, pe),
3817
+ C(8, u(Re)),
3818
+ C(9, Te)
3349
3819
  ], I);
3350
- class sn extends Re {
3820
+ class hn extends Ue {
3821
+ getCommandSheetTarget(e) {
3822
+ var o;
3823
+ const t = e.params;
3824
+ if (!t) return;
3825
+ const n = t.unitId ? this.getUniverSheet(t.unitId) : (o = this.getActiveWorkbook) == null ? void 0 : o.call(this);
3826
+ if (!n)
3827
+ return;
3828
+ const r = n.getSheetBySheetId(t.subUnitId || t.sheetId) || n.getActiveSheet();
3829
+ if (r)
3830
+ return { workbook: n, worksheet: r };
3831
+ }
3832
+ getSheetTarget(e, t) {
3833
+ const n = this.getUniverSheet(e);
3834
+ if (!n)
3835
+ return;
3836
+ const r = n.getSheetBySheetId(t);
3837
+ if (r)
3838
+ return { workbook: n, worksheet: r };
3839
+ }
3840
+ _initWorkbookEvent(e) {
3841
+ const t = e.get(J);
3842
+ this.disposeWithMe(
3843
+ t.unitDisposed$.subscribe((n) => {
3844
+ this._eventRegistry.get(this.Event.WorkbookDisposed) && n.type === R.UNIVER_SHEET && this.fireEvent(
3845
+ this.Event.WorkbookDisposed,
3846
+ {
3847
+ unitId: n.getUnitId(),
3848
+ unitType: n.type,
3849
+ snapshot: n.getSnapshot()
3850
+ }
3851
+ );
3852
+ })
3853
+ ), this.disposeWithMe(
3854
+ t.unitAdded$.subscribe((n) => {
3855
+ if (this._eventRegistry.get(this.Event.WorkbookCreated) && n.type === R.UNIVER_SHEET) {
3856
+ const r = n, o = e.createInstance(I, r);
3857
+ this.fireEvent(
3858
+ this.Event.WorkbookCreated,
3859
+ {
3860
+ unitId: n.getUnitId(),
3861
+ type: n.type,
3862
+ workbook: o,
3863
+ unit: o
3864
+ }
3865
+ );
3866
+ }
3867
+ })
3868
+ );
3869
+ }
3351
3870
  _initialize(e) {
3352
3871
  const t = e.get(l);
3353
3872
  this.disposeWithMe(
3354
3873
  t.beforeCommandExecuted((n) => {
3355
- var s;
3874
+ var r;
3356
3875
  switch (n.id) {
3357
- case U.id: {
3358
- 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);
3876
+ case x.id: {
3877
+ const o = n.params, { unitId: i, index: a, sheet: h } = o || {}, c = i ? this.getUniverSheet(i) : (r = this.getActiveWorkbook) == null ? void 0 : r.call(this);
3359
3878
  if (!c)
3360
3879
  return;
3361
3880
  const d = {
@@ -3367,17 +3886,17 @@ class sn extends Re {
3367
3886
  this.Event.BeforeSheetCreate,
3368
3887
  d
3369
3888
  ), d.cancel)
3370
- throw new Error("Sheet create canceled by facade api.");
3889
+ throw new qe();
3371
3890
  break;
3372
3891
  }
3373
3892
  }
3374
3893
  })
3375
3894
  ), this.disposeWithMe(
3376
3895
  t.onCommandExecuted((n) => {
3377
- var s;
3896
+ var r;
3378
3897
  switch (n.id) {
3379
- case U.id: {
3380
- const r = n.params, { unitId: i } = r || {}, a = i ? this.getUniverSheet(i) : (s = this.getActiveWorkbook) == null ? void 0 : s.call(this);
3898
+ case x.id: {
3899
+ const o = n.params, { unitId: i } = o || {}, a = i ? this.getUniverSheet(i) : (r = this.getActiveWorkbook) == null ? void 0 : r.call(this);
3381
3900
  if (!a)
3382
3901
  return;
3383
3902
  const h = a.getActiveSheet();
@@ -3395,66 +3914,78 @@ class sn extends Re {
3395
3914
  }
3396
3915
  }
3397
3916
  })
3398
- );
3917
+ ), this._initWorkbookEvent(e);
3399
3918
  }
3400
3919
  createUniverSheet(e) {
3401
- const n = this._injector.get(ve).createUnit(P.UNIVER_SHEET, e);
3920
+ const n = this._injector.get(J).createUnit(R.UNIVER_SHEET, e);
3402
3921
  return this._injector.createInstance(I, n);
3403
3922
  }
3404
- getActiveUniverSheet() {
3405
- const e = this._univerInstanceService.getCurrentUnitForType(P.UNIVER_SHEET);
3406
- return e ? this._injector.createInstance(I, e) : null;
3923
+ createWorkbook(e) {
3924
+ return this.createUniverSheet(e);
3407
3925
  }
3408
3926
  getActiveWorkbook() {
3409
- return this.getActiveUniverSheet();
3927
+ const e = this._univerInstanceService.getCurrentUnitForType(R.UNIVER_SHEET);
3928
+ return e ? this._injector.createInstance(I, e) : null;
3929
+ }
3930
+ getActiveUniverSheet() {
3931
+ return this.getActiveWorkbook();
3410
3932
  }
3411
3933
  getUniverSheet(e) {
3412
- const t = this._univerInstanceService.getUnit(e, P.UNIVER_SHEET);
3934
+ const t = this._univerInstanceService.getUnit(e, R.UNIVER_SHEET);
3413
3935
  return t ? this._injector.createInstance(I, t) : null;
3414
3936
  }
3937
+ getWorkbook(e) {
3938
+ return this.getUniverSheet(e);
3939
+ }
3415
3940
  getPermission() {
3416
- return this._injector.createInstance(j);
3941
+ return this._injector.createInstance(O);
3417
3942
  }
3418
3943
  onUniverSheetCreated(e) {
3419
- const t = this._univerInstanceService.getTypeOfUnitAdded$(P.UNIVER_SHEET).subscribe((n) => {
3420
- const s = this._injector.createInstance(I, n);
3421
- e(s);
3944
+ const t = this._univerInstanceService.getTypeOfUnitAdded$(R.UNIVER_SHEET).subscribe((n) => {
3945
+ const r = this._injector.createInstance(I, n);
3946
+ e(r);
3422
3947
  });
3423
- return fe(t);
3948
+ return F(t);
3424
3949
  }
3425
3950
  newDefinedName() {
3426
- return this._injector.createInstance(F);
3951
+ return this._injector.createInstance(L);
3427
3952
  }
3428
3953
  }
3429
- Re.extend(sn);
3430
- class on extends be {
3954
+ Ue.extend(hn);
3955
+ class cn extends se {
3431
3956
  get SheetCreated() {
3432
3957
  return "SheetCreated";
3433
3958
  }
3434
3959
  get BeforeSheetCreate() {
3435
3960
  return "BeforeSheetCreate";
3436
3961
  }
3962
+ get WorkbookCreated() {
3963
+ return "WorkbookCreated";
3964
+ }
3965
+ get WorkbookDisposed() {
3966
+ return "WorkbookDisposed";
3967
+ }
3437
3968
  }
3438
- be.extend(on);
3439
- var rn = Object.defineProperty, an = Object.getOwnPropertyDescriptor, hn = (o, e, t, n) => {
3440
- for (var s = n > 1 ? void 0 : n ? an(e, t) : e, r = o.length - 1, i; r >= 0; r--)
3441
- (i = o[r]) && (s = (n ? i(e, t, s) : i(s)) || s);
3442
- return n && s && rn(e, t, s), s;
3443
- }, cn = (o, e) => (t, n) => e(t, n, o);
3444
- let we = class extends Q {
3445
- constructor(o) {
3446
- super(), this._injector = o;
3969
+ se.extend(cn);
3970
+ var dn = Object.defineProperty, un = Object.getOwnPropertyDescriptor, mn = (s, e, t, n) => {
3971
+ for (var r = n > 1 ? void 0 : n ? un(e, t) : e, o = s.length - 1, i; o >= 0; o--)
3972
+ (i = s[o]) && (r = (n ? i(e, t, r) : i(r)) || r);
3973
+ return n && r && dn(e, t, r), r;
3974
+ }, ln = (s, e) => (t, n) => e(t, n, s);
3975
+ let fe = class extends te {
3976
+ constructor(s) {
3977
+ super(), this._injector = s;
3447
3978
  }
3448
3979
  };
3449
- we = hn([
3450
- cn(0, m(v))
3451
- ], we);
3980
+ fe = mn([
3981
+ ln(0, u(b))
3982
+ ], fe);
3452
3983
  export {
3453
- j as FPermission,
3454
- k as FRange,
3455
- A as FSelection,
3456
- on as FSheetEventName,
3457
- we as FSheetHooks,
3984
+ O as FPermission,
3985
+ w as FRange,
3986
+ B as FSelection,
3987
+ cn as FSheetEventName,
3988
+ fe as FSheetHooks,
3458
3989
  I as FWorkbook,
3459
3990
  g as FWorksheet
3460
3991
  };