@univerjs/sheets 0.2.9 → 0.2.10

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/index.js CHANGED
@@ -2,7 +2,7 @@ var __defProp = Object.defineProperty;
2
2
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value;
3
3
  var __name = (target, value) => __defProp(target, "name", { value, configurable: !0 });
4
4
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key != "symbol" ? key + "" : key, value);
5
- import { RxDisposable, UniverInstanceType, Disposable, IUniverInstanceService, createInterceptorKey, OnLifecycle, LifecycleStages, toDisposable, remove, composeInterceptors, DisposableCollection, Tools, normalizeTextRuns, CellValueType, isSafeNumeric, isRealNum, isBooleanString, CommandType, ObjectMatrix, ICommandService, IUndoRedoService, sequenceExecute, LocaleService, createIdentifier, IContextService, selectionToArray, Rectangle, RANGE_TYPE, ErrorService, Range, cellToRange, PermissionStatus, IPermissionService, isICellData, Dimension, getArrayLength, insertMatrixArray, spliceArray, sliceMatrixArray, concatMatrixArray, BooleanNumber, Direction, mergeWorksheetSnapshotWithDefault, moveMatrixArray, BorderType, BorderStyleTypes, FontWeight, FontItalic, runOnLifecycle, Inject, Injector, IResourceManagerService, Optional, IConfigService, queryObjectMatrix, InterceptorManager, ILogService, LRUMap, DependentOn, Plugin, mergeOverrideWithDependencies, ColorKit, getCellInfoInMergeData, makeCellRangeToRangeData } from "@univerjs/core";
5
+ import { RxDisposable, UniverInstanceType, Disposable, IUniverInstanceService, createInterceptorKey, toDisposable, remove, composeInterceptors, DisposableCollection, Tools, normalizeTextRuns, CellValueType, isSafeNumeric, isRealNum, isBooleanString, CommandType, ObjectMatrix, ICommandService, IUndoRedoService, sequenceExecute, LocaleService, createIdentifier, IContextService, selectionToArray, Rectangle, RANGE_TYPE, ErrorService, Range, cellToRange, PermissionStatus, IPermissionService, isICellData, Dimension, getArrayLength, insertMatrixArray, spliceArray, sliceMatrixArray, concatMatrixArray, BooleanNumber, Direction, mergeWorksheetSnapshotWithDefault, moveMatrixArray, BorderType, BorderStyleTypes, FontWeight, FontItalic, runOnLifecycle, LifecycleStages, OnLifecycle, Inject, Injector, IResourceManagerService, Optional, IConfigService, queryObjectMatrix, InterceptorManager, ILogService, LRUMap, DependentOn, Plugin, mergeOverrideWithDependencies, ColorKit, getCellInfoInMergeData, makeCellRangeToRangeData, createRowColIter } from "@univerjs/core";
6
6
  import { SetDefinedNameMutation, RemoveDefinedNameMutation, SetFormulaCalculationResultMutation, handleNumfmtInCell, IDefinedNamesService, stripErrorMargin, UniverFormulaEnginePlugin } from "@univerjs/engine-formula";
7
7
  import { DataSyncPrimaryController } from "@univerjs/rpc";
8
8
  import { shareReplay, takeUntil, switchMap, of, Subject, BehaviorSubject, merge, map } from "rxjs";
@@ -29,6 +29,9 @@ let SheetsSelectionsService = (_a = class extends RxDisposable {
29
29
  const worksheet = workbook.getActiveSheet();
30
30
  return { unitId: workbook.getUnitId(), sheetId: worksheet.getSheetId() };
31
31
  }
32
+ get currentSelectionParam() {
33
+ return this._currentSelectionPos;
34
+ }
32
35
  _init() {
33
36
  const c$ = this._instanceSrv.getCurrentTypeOfUnit$(UniverInstanceType.UNIVER_SHEET).pipe(shareReplay(1), takeUntil(this.dispose$));
34
37
  this.selectionMoveStart$ = c$.pipe(switchMap((workbook) => workbook ? this._ensureWorkbookSelection(workbook.getUnitId()).selectionMoveStart$ : of())), this.selectionMoving$ = c$.pipe(switchMap((workbook) => workbook ? this._ensureWorkbookSelection(workbook.getUnitId()).selectionMoving$ : of())), this.selectionMoveEnd$ = c$.pipe(switchMap((workbook) => workbook ? this._ensureWorkbookSelection(workbook.getUnitId()).selectionMoveEnd$ : of([]))), this._instanceSrv.getTypeOfUnitDisposed$(UniverInstanceType.UNIVER_SHEET).pipe(takeUntil(this.dispose$)).subscribe((workbook) => {
@@ -162,7 +165,7 @@ const _WorkbookSelections = class _WorkbookSelections extends Disposable {
162
165
  * @param selectionDatas
163
166
  * @param type
164
167
  */
165
- setSelections(sheetId, selectionDatas, type = 2) {
168
+ setSelections(sheetId, selectionDatas, type) {
166
169
  switch (this._ensureSheetSelection(sheetId).length = 0, this._ensureSheetSelection(sheetId).push(...selectionDatas), type) {
167
170
  case 0:
168
171
  this._selectionMoveStart$.next(selectionDatas);
@@ -216,6 +219,7 @@ var InterceptCellContentPriority = /* @__PURE__ */ ((InterceptCellContentPriorit
216
219
  return kind && result && __defProp$h(target, key, result), result;
217
220
  }, "__decorateClass$h"), __decorateParam$e = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$e"), _a2;
218
221
  let SheetInterceptorService = (_a2 = class extends Disposable {
222
+ /** @ignore */
219
223
  constructor(_univerInstanceService) {
220
224
  super();
221
225
  __publicField(this, "_interceptorsByName", /* @__PURE__ */ new Map());
@@ -363,7 +367,7 @@ let SheetInterceptorService = (_a2 = class extends Disposable {
363
367
  }));
364
368
  });
365
369
  }, "interceptViewModel");
366
- workbook.getSheets().forEach((worksheet) => interceptViewModel(worksheet)), disposables.add(toDisposable(workbook.sheetCreated$.subscribe((worksheet) => interceptViewModel(worksheet)))), disposables.add(toDisposable(() => workbook.getSheets().forEach((worksheet) => this._disposeSheetInterceptor(unitId, worksheet)))), disposables.add(toDisposable(workbook.sheetDisposed$.subscribe((worksheet) => this._disposeSheetInterceptor(unitId, worksheet)))), this._workbookDisposables.set(unitId, disposables);
370
+ workbook.getSheets().forEach((worksheet) => interceptViewModel(worksheet)), disposables.add(workbook.sheetCreated$.subscribe((worksheet) => interceptViewModel(worksheet))), disposables.add(toDisposable(() => workbook.getSheets().forEach((worksheet) => this._disposeSheetInterceptor(unitId, worksheet)))), disposables.add(workbook.sheetDisposed$.subscribe((worksheet) => this._disposeSheetInterceptor(unitId, worksheet))), this._workbookDisposables.set(unitId, disposables);
367
371
  }
368
372
  _disposeWorkbookInterceptor(workbook) {
369
373
  const unitId = workbook.getUnitId(), disposable = this._workbookDisposables.get(unitId);
@@ -375,7 +379,6 @@ let SheetInterceptorService = (_a2 = class extends Disposable {
375
379
  }
376
380
  }, __name(_a2, "SheetInterceptorService"), _a2);
377
381
  SheetInterceptorService = __decorateClass$h([
378
- OnLifecycle(LifecycleStages.Starting, SheetInterceptorService),
379
382
  __decorateParam$e(0, IUniverInstanceService)
380
383
  ], SheetInterceptorService);
381
384
  function getWorksheetDisposableID(unitId, worksheet) {
@@ -420,7 +423,7 @@ function mergeStyle(oldStyle, newStyle, isRichText = !1) {
420
423
  const backupStyle = Tools.deepClone(oldStyle) || {};
421
424
  if (backupStyle) {
422
425
  for (const k in newStyle)
423
- isRichText && ["bd", "tr", "td", "ht", "vt", "tb", "pd"].includes(k) || (k in backupStyle && k === "bd" ? backupStyle[k] = Object.assign(backupStyle[k], newStyle[k]) : backupStyle[k] = newStyle[k]);
426
+ isRichText && ["bd", "tr", "td", "ht", "vt", "tb", "pd", "bg"].includes(k) || (k in backupStyle && k === "bd" ? backupStyle[k] = Object.assign(backupStyle[k], newStyle[k]) : backupStyle[k] = newStyle[k]);
424
427
  return "cl" in backupStyle && ("ul" in backupStyle && backupStyle.ul && (backupStyle.ul.cl = backupStyle.cl), "ol" in backupStyle && backupStyle.ol && (backupStyle.ol.cl = backupStyle.cl), "st" in backupStyle && backupStyle.st && (backupStyle.st.cl = backupStyle.cl)), backupStyle;
425
428
  }
426
429
  }
@@ -577,73 +580,6 @@ const SetRangeValuesUndoMutationFactory = /* @__PURE__ */ __name((accessor, para
577
580
  return _initValue++;
578
581
  }, "getKey");
579
582
  }, "createUniqueKey");
580
- function cellHasValue(cell) {
581
- return cell == null ? !1 : cell.v !== void 0 && cell.v !== null && cell.v !== "" || cell.p !== void 0;
582
- }
583
- __name(cellHasValue, "cellHasValue");
584
- function expandToContinuousRange(startRange, directions, worksheet) {
585
- const { left, right, up, down } = directions, maxRow = worksheet.getMaxRows(), maxColumn = worksheet.getMaxColumns();
586
- let changed = !0;
587
- const destRange = { ...startRange }, allMatrix = worksheet.getMatrixWithMergedCells(0, 0, maxRow - 1, maxColumn - 1);
588
- for (; changed; ) {
589
- if (changed = !1, up && destRange.startRow !== 0) {
590
- const destRow = destRange.startRow - 1, checkRange = {
591
- startRow: destRow,
592
- startColumn: destRange.startColumn,
593
- endRow: destRow,
594
- endColumn: destRange.endColumn
595
- };
596
- for (let col = checkRange.startColumn; col <= checkRange.endColumn; col++) {
597
- const cell = allMatrix.getValue(checkRange.startRow, col);
598
- cellHasValue(cell) && (destRange.startRow = Math.min(checkRange.startRow, destRange.startRow), destRange.startColumn = Math.min(col, destRange.startColumn), destRange.endColumn = Math.max(col, destRange.endColumn), changed = !0);
599
- }
600
- }
601
- if (down && destRange.endRow !== maxRow - 1) {
602
- const destRow = destRange.endRow + 1, checkRange = {
603
- startRow: destRow,
604
- startColumn: destRange.startColumn,
605
- endRow: destRow,
606
- endColumn: destRange.endColumn
607
- };
608
- for (let col = checkRange.startColumn; col <= checkRange.endColumn; col++) {
609
- const cellValue = allMatrix.getValue(checkRange.startRow, col);
610
- cellHasValue(cellValue) && (destRange.endRow = Math.max(checkRange.endRow, destRange.endRow), destRange.endRow = Math.max(
611
- checkRange.endRow + (cellValue.rowSpan !== void 0 ? cellValue.rowSpan - 1 : 0),
612
- destRange.endRow
613
- ), destRange.startColumn = Math.min(col, destRange.startColumn), destRange.endColumn = Math.max(col, destRange.endColumn), changed = !0);
614
- }
615
- }
616
- if (left && destRange.startColumn !== 0) {
617
- const destCol = destRange.startColumn - 1, checkRange = {
618
- startRow: destRange.startRow,
619
- startColumn: destCol,
620
- endRow: destRange.endRow,
621
- endColumn: destCol
622
- };
623
- for (let row = checkRange.startRow; row <= checkRange.endRow; row++) {
624
- const cell = allMatrix.getValue(row, checkRange.startColumn);
625
- cellHasValue(cell) && (destRange.startColumn = Math.min(checkRange.startColumn, destRange.startColumn), destRange.startRow = Math.min(row, destRange.startRow), destRange.endRow = Math.max(row, destRange.endRow), changed = !0);
626
- }
627
- }
628
- if (right && destRange.endColumn !== maxColumn - 1) {
629
- const destCol = destRange.endColumn + 1, checkRange = {
630
- startRow: destRange.startRow,
631
- startColumn: destCol,
632
- endRow: destRange.endRow,
633
- endColumn: destCol
634
- };
635
- for (let row = checkRange.startRow; row <= checkRange.endRow; row++) {
636
- const cellValue = allMatrix.getValue(row, checkRange.endColumn);
637
- cellHasValue(cellValue) && (destRange.endColumn = Math.max(
638
- checkRange.endColumn + (cellValue.colSpan !== void 0 ? cellValue.colSpan - 1 : 0),
639
- destRange.endColumn
640
- ), changed = !0);
641
- }
642
- }
643
- }
644
- return destRange;
645
- }
646
- __name(expandToContinuousRange, "expandToContinuousRange");
647
583
  function generateNullCell(range) {
648
584
  const cellValue = new ObjectMatrix();
649
585
  return range.forEach((range2) => {
@@ -933,7 +869,7 @@ const SetSelectionsOperation = {
933
869
  handler: /* @__PURE__ */ __name((accessor, params) => {
934
870
  if (!params) return !1;
935
871
  const { selections, type, unitId, subUnitId } = params;
936
- return getSelectionsService(accessor).setSelections(unitId, subUnitId, selections, type), !0;
872
+ return getSelectionsService(accessor).setSelections(unitId, subUnitId, [...selections], type), !0;
937
873
  }, "handler")
938
874
  };
939
875
  function alignToMergedCellsBorders(startRange, worksheet, shouldRecursive = !0) {
@@ -1036,6 +972,16 @@ function createRangeIteratorWithSkipFilteredRows(sheet) {
1036
972
  };
1037
973
  }
1038
974
  __name(createRangeIteratorWithSkipFilteredRows, "createRangeIteratorWithSkipFilteredRows");
975
+ function copyRangeStyles(worksheet, startRow, endRow, startColumn, endColumn, isRow, styleRowOrColumn) {
976
+ const cellValue = {};
977
+ for (let row = startRow; row <= endRow; row++)
978
+ for (let column = startColumn; column <= endColumn; column++) {
979
+ const cell = isRow ? worksheet.getCell(styleRowOrColumn, column) : worksheet.getCell(row, styleRowOrColumn);
980
+ !cell || !cell.s || (cellValue[row] || (cellValue[row] = {}), cellValue[row][column] = { s: cell.s });
981
+ }
982
+ return cellValue;
983
+ }
984
+ __name(copyRangeStyles, "copyRangeStyles");
1039
985
  const MoveRangeCommandId = "sheet.command.move-range", MoveRangeCommand = {
1040
986
  type: CommandType.COMMAND,
1041
987
  id: MoveRangeCommandId,
@@ -1136,15 +1082,15 @@ function getMoveRangeUndoRedoMutations(accessor, from, to, ignoreMerge = !1) {
1136
1082
  };
1137
1083
  }
1138
1084
  __name(getMoveRangeUndoRedoMutations, "getMoveRangeUndoRedoMutations");
1139
- var I = /* @__PURE__ */ ((E) => (E[E.UNIVER_UNKNOWN = 0] = "UNIVER_UNKNOWN", E[E.UNIVER_DOC = 1] = "UNIVER_DOC", E[E.UNIVER_SHEET = 2] = "UNIVER_SHEET", E[E.UNIVER_SLIDE = 3] = "UNIVER_SLIDE", E[E.UNIVER_PROJECT = 4] = "UNIVER_PROJECT", E[E.UNRECOGNIZED = -1] = "UNRECOGNIZED", E))(I || {}), L = /* @__PURE__ */ ((E) => (E[E.View = 0] = "View", E[E.Edit = 1] = "Edit", E[E.ManageCollaborator = 2] = "ManageCollaborator", E[E.Print = 3] = "Print", E[E.Duplicate = 4] = "Duplicate", E[E.Comment = 5] = "Comment", E[E.Copy = 6] = "Copy", E[E.Share = 7] = "Share", E[E.Export = 8] = "Export", E[E.MoveWorksheet = 9] = "MoveWorksheet", E[E.DeleteWorksheet = 10] = "DeleteWorksheet", E[E.HideWorksheet = 11] = "HideWorksheet", E[E.RenameWorksheet = 12] = "RenameWorksheet", E[E.CreateWorksheet = 13] = "CreateWorksheet", E[E.SetWorksheetStyle = 14] = "SetWorksheetStyle", E[E.EditWorksheetCell = 15] = "EditWorksheetCell", E[E.InsertHyperlink = 16] = "InsertHyperlink", E[E.Sort = 17] = "Sort", E[E.Filter = 18] = "Filter", E[E.PivotTable = 19] = "PivotTable", E[E.FloatImg = 20] = "FloatImg", E[E.History = 21] = "History", E[E.RwHgtClWdt = 22] = "RwHgtClWdt", E[E.ViemRwHgtClWdt = 23] = "ViemRwHgtClWdt", E[E.ViewFilter = 24] = "ViewFilter", E[E.MoveSheet = 25] = "MoveSheet", E[E.DeleteSheet = 26] = "DeleteSheet", E[E.HideSheet = 27] = "HideSheet", E[E.CopySheet = 28] = "CopySheet", E[E.RenameSheet = 29] = "RenameSheet", E[E.CreateSheet = 30] = "CreateSheet", E[E.SelectProtectedCells = 31] = "SelectProtectedCells", E[E.SelectUnProtectedCells = 32] = "SelectUnProtectedCells", E[E.SetCellStyle = 33] = "SetCellStyle", E[E.SetCellValue = 34] = "SetCellValue", E[E.SetRowStyle = 35] = "SetRowStyle", E[E.SetColumnStyle = 36] = "SetColumnStyle", E[E.InsertRow = 37] = "InsertRow", E[E.InsertColumn = 38] = "InsertColumn", E[E.DeleteRow = 39] = "DeleteRow", E[E.DeleteColumn = 40] = "DeleteColumn", E[E.EditExtraObject = 41] = "EditExtraObject", E[E.Delete = 42] = "Delete", E[E.RecoverHistory = 43] = "RecoverHistory", E[E.ViewHistory = 44] = "ViewHistory", E[E.UNRECOGNIZED = -1] = "UNRECOGNIZED", E))(L || {}), M = /* @__PURE__ */ ((E) => (E[E.Unkonwn = 0] = "Unkonwn", E[E.Workbook = 1] = "Workbook", E[E.Worksheet = 2] = "Worksheet", E[E.SelectRange = 3] = "SelectRange", E[E.Document = 4] = "Document", E[E.Slide = 5] = "Slide", E[E.UNRECOGNIZED = -1] = "UNRECOGNIZED", E))(M || {});
1085
+ var I = /* @__PURE__ */ ((E) => (E[E.UNIVER_UNKNOWN = 0] = "UNIVER_UNKNOWN", E[E.UNIVER_DOC = 1] = "UNIVER_DOC", E[E.UNIVER_SHEET = 2] = "UNIVER_SHEET", E[E.UNIVER_SLIDE = 3] = "UNIVER_SLIDE", E[E.UNIVER_PROJECT = 4] = "UNIVER_PROJECT", E[E.UNRECOGNIZED = -1] = "UNRECOGNIZED", E))(I || {}), P = /* @__PURE__ */ ((E) => (E[E.View = 0] = "View", E[E.Edit = 1] = "Edit", E[E.ManageCollaborator = 2] = "ManageCollaborator", E[E.Print = 3] = "Print", E[E.Duplicate = 4] = "Duplicate", E[E.Comment = 5] = "Comment", E[E.Copy = 6] = "Copy", E[E.Share = 7] = "Share", E[E.Export = 8] = "Export", E[E.MoveWorksheet = 9] = "MoveWorksheet", E[E.DeleteWorksheet = 10] = "DeleteWorksheet", E[E.HideWorksheet = 11] = "HideWorksheet", E[E.RenameWorksheet = 12] = "RenameWorksheet", E[E.CreateWorksheet = 13] = "CreateWorksheet", E[E.SetWorksheetStyle = 14] = "SetWorksheetStyle", E[E.EditWorksheetCell = 15] = "EditWorksheetCell", E[E.InsertHyperlink = 16] = "InsertHyperlink", E[E.Sort = 17] = "Sort", E[E.Filter = 18] = "Filter", E[E.PivotTable = 19] = "PivotTable", E[E.FloatImg = 20] = "FloatImg", E[E.History = 21] = "History", E[E.RwHgtClWdt = 22] = "RwHgtClWdt", E[E.ViemRwHgtClWdt = 23] = "ViemRwHgtClWdt", E[E.ViewFilter = 24] = "ViewFilter", E[E.MoveSheet = 25] = "MoveSheet", E[E.DeleteSheet = 26] = "DeleteSheet", E[E.HideSheet = 27] = "HideSheet", E[E.CopySheet = 28] = "CopySheet", E[E.RenameSheet = 29] = "RenameSheet", E[E.CreateSheet = 30] = "CreateSheet", E[E.SelectProtectedCells = 31] = "SelectProtectedCells", E[E.SelectUnProtectedCells = 32] = "SelectUnProtectedCells", E[E.SetCellStyle = 33] = "SetCellStyle", E[E.SetCellValue = 34] = "SetCellValue", E[E.SetRowStyle = 35] = "SetRowStyle", E[E.SetColumnStyle = 36] = "SetColumnStyle", E[E.InsertRow = 37] = "InsertRow", E[E.InsertColumn = 38] = "InsertColumn", E[E.DeleteRow = 39] = "DeleteRow", E[E.DeleteColumn = 40] = "DeleteColumn", E[E.EditExtraObject = 41] = "EditExtraObject", E[E.Delete = 42] = "Delete", E[E.RecoverHistory = 43] = "RecoverHistory", E[E.ViewHistory = 44] = "ViewHistory", E[E.UNRECOGNIZED = -1] = "UNRECOGNIZED", E))(P || {}), M = /* @__PURE__ */ ((E) => (E[E.Unkonwn = 0] = "Unkonwn", E[E.Workbook = 1] = "Workbook", E[E.Worksheet = 2] = "Worksheet", E[E.SelectRange = 3] = "SelectRange", E[E.Document = 4] = "Document", E[E.Slide = 5] = "Slide", E[E.UNRECOGNIZED = -1] = "UNRECOGNIZED", E))(M || {});
1140
1086
  const _WorksheetCopyPermission = class _WorksheetCopyPermission {
1141
1087
  constructor(unitId, subUnitId) {
1142
1088
  __publicField(this, "value", !0);
1143
1089
  __publicField(this, "type", M.Worksheet);
1144
1090
  __publicField(this, "status", PermissionStatus.INIT);
1145
1091
  __publicField(this, "id");
1146
- __publicField(this, "subType", L.Copy);
1147
- this.unitId = unitId, this.subUnitId = subUnitId, this.id = `${this.type}.${L.Copy}_${unitId}_${subUnitId}`;
1092
+ __publicField(this, "subType", P.Copy);
1093
+ this.unitId = unitId, this.subUnitId = subUnitId, this.id = `${this.type}.${P.Copy}_${unitId}_${subUnitId}`;
1148
1094
  }
1149
1095
  };
1150
1096
  __name(_WorksheetCopyPermission, "WorksheetCopyPermission");
@@ -1155,8 +1101,8 @@ const _WorksheetSelectProtectedCellsPermission = class _WorksheetSelectProtected
1155
1101
  __publicField(this, "type", M.Worksheet);
1156
1102
  __publicField(this, "status", PermissionStatus.INIT);
1157
1103
  __publicField(this, "id");
1158
- __publicField(this, "subType", L.SelectProtectedCells);
1159
- this.unitId = unitId, this.subUnitId = subUnitId, this.id = `${this.type}.${L.SelectProtectedCells}_${unitId}_${subUnitId}`;
1104
+ __publicField(this, "subType", P.SelectProtectedCells);
1105
+ this.unitId = unitId, this.subUnitId = subUnitId, this.id = `${this.type}.${P.SelectProtectedCells}_${unitId}_${subUnitId}`;
1160
1106
  }
1161
1107
  };
1162
1108
  __name(_WorksheetSelectProtectedCellsPermission, "WorksheetSelectProtectedCellsPermission");
@@ -1167,8 +1113,8 @@ const _WorksheetSelectUnProtectedCellsPermission = class _WorksheetSelectUnProte
1167
1113
  __publicField(this, "type", M.Worksheet);
1168
1114
  __publicField(this, "status", PermissionStatus.INIT);
1169
1115
  __publicField(this, "id");
1170
- __publicField(this, "subType", L.SelectUnProtectedCells);
1171
- this.unitId = unitId, this.subUnitId = subUnitId, this.id = `${this.type}.${L.SelectUnProtectedCells}_${unitId}_${subUnitId}`;
1116
+ __publicField(this, "subType", P.SelectUnProtectedCells);
1117
+ this.unitId = unitId, this.subUnitId = subUnitId, this.id = `${this.type}.${P.SelectUnProtectedCells}_${unitId}_${subUnitId}`;
1172
1118
  }
1173
1119
  };
1174
1120
  __name(_WorksheetSelectUnProtectedCellsPermission, "WorksheetSelectUnProtectedCellsPermission");
@@ -1179,8 +1125,8 @@ const _WorksheetSetCellStylePermission = class _WorksheetSetCellStylePermission
1179
1125
  __publicField(this, "type", M.Worksheet);
1180
1126
  __publicField(this, "status", PermissionStatus.INIT);
1181
1127
  __publicField(this, "id");
1182
- __publicField(this, "subType", L.SetCellStyle);
1183
- this.unitId = unitId, this.subUnitId = subUnitId, this.id = `${this.type}.${L.SetCellStyle}_${unitId}_${subUnitId}`;
1128
+ __publicField(this, "subType", P.SetCellStyle);
1129
+ this.unitId = unitId, this.subUnitId = subUnitId, this.id = `${this.type}.${P.SetCellStyle}_${unitId}_${subUnitId}`;
1184
1130
  }
1185
1131
  };
1186
1132
  __name(_WorksheetSetCellStylePermission, "WorksheetSetCellStylePermission");
@@ -1191,8 +1137,8 @@ const _WorksheetSetCellValuePermission = class _WorksheetSetCellValuePermission
1191
1137
  __publicField(this, "type", M.Worksheet);
1192
1138
  __publicField(this, "status", PermissionStatus.INIT);
1193
1139
  __publicField(this, "id");
1194
- __publicField(this, "subType", L.SetCellValue);
1195
- this.unitId = unitId, this.subUnitId = subUnitId, this.id = `${this.type}.${L.SetCellValue}_${unitId}_${subUnitId}`;
1140
+ __publicField(this, "subType", P.SetCellValue);
1141
+ this.unitId = unitId, this.subUnitId = subUnitId, this.id = `${this.type}.${P.SetCellValue}_${unitId}_${subUnitId}`;
1196
1142
  }
1197
1143
  };
1198
1144
  __name(_WorksheetSetCellValuePermission, "WorksheetSetCellValuePermission");
@@ -1203,8 +1149,8 @@ const _WorksheetViewPermission = class _WorksheetViewPermission {
1203
1149
  __publicField(this, "type", M.Worksheet);
1204
1150
  __publicField(this, "status", PermissionStatus.INIT);
1205
1151
  __publicField(this, "id");
1206
- __publicField(this, "subType", L.View);
1207
- this.unitId = unitId, this.subUnitId = subUnitId, this.id = `${this.type}.${L.View}_${unitId}_${subUnitId}`;
1152
+ __publicField(this, "subType", P.View);
1153
+ this.unitId = unitId, this.subUnitId = subUnitId, this.id = `${this.type}.${P.View}_${unitId}_${subUnitId}`;
1208
1154
  }
1209
1155
  };
1210
1156
  __name(_WorksheetViewPermission, "WorksheetViewPermission");
@@ -1215,8 +1161,8 @@ const _WorksheetSetRowStylePermission = class _WorksheetSetRowStylePermission {
1215
1161
  __publicField(this, "type", M.Worksheet);
1216
1162
  __publicField(this, "status", PermissionStatus.INIT);
1217
1163
  __publicField(this, "id");
1218
- __publicField(this, "subType", L.SetRowStyle);
1219
- this.unitId = unitId, this.subUnitId = subUnitId, this.id = `${this.type}.${L.SetRowStyle}_${unitId}_${subUnitId}`;
1164
+ __publicField(this, "subType", P.SetRowStyle);
1165
+ this.unitId = unitId, this.subUnitId = subUnitId, this.id = `${this.type}.${P.SetRowStyle}_${unitId}_${subUnitId}`;
1220
1166
  }
1221
1167
  };
1222
1168
  __name(_WorksheetSetRowStylePermission, "WorksheetSetRowStylePermission");
@@ -1227,8 +1173,8 @@ const _WorksheetSetColumnStylePermission = class _WorksheetSetColumnStylePermiss
1227
1173
  __publicField(this, "type", M.Worksheet);
1228
1174
  __publicField(this, "status", PermissionStatus.INIT);
1229
1175
  __publicField(this, "id");
1230
- __publicField(this, "subType", L.SetColumnStyle);
1231
- this.unitId = unitId, this.subUnitId = subUnitId, this.id = `${this.type}.${L.SetColumnStyle}_${unitId}_${subUnitId}`;
1176
+ __publicField(this, "subType", P.SetColumnStyle);
1177
+ this.unitId = unitId, this.subUnitId = subUnitId, this.id = `${this.type}.${P.SetColumnStyle}_${unitId}_${subUnitId}`;
1232
1178
  }
1233
1179
  };
1234
1180
  __name(_WorksheetSetColumnStylePermission, "WorksheetSetColumnStylePermission");
@@ -1239,8 +1185,8 @@ const _WorksheetInsertRowPermission = class _WorksheetInsertRowPermission {
1239
1185
  __publicField(this, "type", M.Worksheet);
1240
1186
  __publicField(this, "status", PermissionStatus.INIT);
1241
1187
  __publicField(this, "id");
1242
- __publicField(this, "subType", L.InsertRow);
1243
- this.unitId = unitId, this.subUnitId = subUnitId, this.id = `${this.type}.${L.InsertRow}_${unitId}_${subUnitId}`;
1188
+ __publicField(this, "subType", P.InsertRow);
1189
+ this.unitId = unitId, this.subUnitId = subUnitId, this.id = `${this.type}.${P.InsertRow}_${unitId}_${subUnitId}`;
1244
1190
  }
1245
1191
  };
1246
1192
  __name(_WorksheetInsertRowPermission, "WorksheetInsertRowPermission");
@@ -1251,8 +1197,8 @@ const _WorksheetInsertColumnPermission = class _WorksheetInsertColumnPermission
1251
1197
  __publicField(this, "type", M.Worksheet);
1252
1198
  __publicField(this, "status", PermissionStatus.INIT);
1253
1199
  __publicField(this, "id");
1254
- __publicField(this, "subType", L.InsertColumn);
1255
- this.unitId = unitId, this.subUnitId = subUnitId, this.id = `${this.type}.${L.InsertColumn}_${unitId}_${subUnitId}`;
1200
+ __publicField(this, "subType", P.InsertColumn);
1201
+ this.unitId = unitId, this.subUnitId = subUnitId, this.id = `${this.type}.${P.InsertColumn}_${unitId}_${subUnitId}`;
1256
1202
  }
1257
1203
  };
1258
1204
  __name(_WorksheetInsertColumnPermission, "WorksheetInsertColumnPermission");
@@ -1263,8 +1209,8 @@ const _WorksheetInsertHyperlinkPermission = class _WorksheetInsertHyperlinkPermi
1263
1209
  __publicField(this, "type", M.Worksheet);
1264
1210
  __publicField(this, "status", PermissionStatus.INIT);
1265
1211
  __publicField(this, "id");
1266
- __publicField(this, "subType", L.InsertHyperlink);
1267
- this.unitId = unitId, this.subUnitId = subUnitId, this.id = `${this.type}.${L.InsertHyperlink}_${unitId}_${subUnitId}`;
1212
+ __publicField(this, "subType", P.InsertHyperlink);
1213
+ this.unitId = unitId, this.subUnitId = subUnitId, this.id = `${this.type}.${P.InsertHyperlink}_${unitId}_${subUnitId}`;
1268
1214
  }
1269
1215
  };
1270
1216
  __name(_WorksheetInsertHyperlinkPermission, "WorksheetInsertHyperlinkPermission");
@@ -1275,8 +1221,8 @@ const _WorksheetDeleteRowPermission = class _WorksheetDeleteRowPermission {
1275
1221
  __publicField(this, "type", M.Worksheet);
1276
1222
  __publicField(this, "status", PermissionStatus.INIT);
1277
1223
  __publicField(this, "id");
1278
- __publicField(this, "subType", L.DeleteRow);
1279
- this.unitId = unitId, this.subUnitId = subUnitId, this.id = `${this.type}.${L.DeleteRow}_${unitId}_${subUnitId}`;
1224
+ __publicField(this, "subType", P.DeleteRow);
1225
+ this.unitId = unitId, this.subUnitId = subUnitId, this.id = `${this.type}.${P.DeleteRow}_${unitId}_${subUnitId}`;
1280
1226
  }
1281
1227
  };
1282
1228
  __name(_WorksheetDeleteRowPermission, "WorksheetDeleteRowPermission");
@@ -1287,8 +1233,8 @@ const _WorksheetDeleteColumnPermission = class _WorksheetDeleteColumnPermission
1287
1233
  __publicField(this, "type", M.Worksheet);
1288
1234
  __publicField(this, "status", PermissionStatus.INIT);
1289
1235
  __publicField(this, "id");
1290
- __publicField(this, "subType", L.DeleteColumn);
1291
- this.unitId = unitId, this.subUnitId = subUnitId, this.id = `${this.type}.${L.DeleteColumn}_${unitId}_${subUnitId}`;
1236
+ __publicField(this, "subType", P.DeleteColumn);
1237
+ this.unitId = unitId, this.subUnitId = subUnitId, this.id = `${this.type}.${P.DeleteColumn}_${unitId}_${subUnitId}`;
1292
1238
  }
1293
1239
  };
1294
1240
  __name(_WorksheetDeleteColumnPermission, "WorksheetDeleteColumnPermission");
@@ -1299,8 +1245,8 @@ const _WorksheetSortPermission = class _WorksheetSortPermission {
1299
1245
  __publicField(this, "type", M.Worksheet);
1300
1246
  __publicField(this, "status", PermissionStatus.INIT);
1301
1247
  __publicField(this, "id");
1302
- __publicField(this, "subType", L.Sort);
1303
- this.unitId = unitId, this.subUnitId = subUnitId, this.id = `${this.type}.${L.Sort}_${unitId}_${subUnitId}`;
1248
+ __publicField(this, "subType", P.Sort);
1249
+ this.unitId = unitId, this.subUnitId = subUnitId, this.id = `${this.type}.${P.Sort}_${unitId}_${subUnitId}`;
1304
1250
  }
1305
1251
  };
1306
1252
  __name(_WorksheetSortPermission, "WorksheetSortPermission");
@@ -1311,8 +1257,8 @@ const _WorksheetFilterPermission = class _WorksheetFilterPermission {
1311
1257
  __publicField(this, "type", M.Worksheet);
1312
1258
  __publicField(this, "status", PermissionStatus.INIT);
1313
1259
  __publicField(this, "id");
1314
- __publicField(this, "subType", L.Filter);
1315
- this.unitId = unitId, this.subUnitId = subUnitId, this.id = `${this.type}.${L.Filter}_${unitId}_${subUnitId}`;
1260
+ __publicField(this, "subType", P.Filter);
1261
+ this.unitId = unitId, this.subUnitId = subUnitId, this.id = `${this.type}.${P.Filter}_${unitId}_${subUnitId}`;
1316
1262
  }
1317
1263
  };
1318
1264
  __name(_WorksheetFilterPermission, "WorksheetFilterPermission");
@@ -1323,8 +1269,8 @@ const _WorksheetPivotTablePermission = class _WorksheetPivotTablePermission {
1323
1269
  __publicField(this, "type", M.Worksheet);
1324
1270
  __publicField(this, "status", PermissionStatus.INIT);
1325
1271
  __publicField(this, "id");
1326
- __publicField(this, "subType", L.PivotTable);
1327
- this.unitId = unitId, this.subUnitId = subUnitId, this.id = `${this.type}.${L.PivotTable}_${unitId}_${subUnitId}`;
1272
+ __publicField(this, "subType", P.PivotTable);
1273
+ this.unitId = unitId, this.subUnitId = subUnitId, this.id = `${this.type}.${P.PivotTable}_${unitId}_${subUnitId}`;
1328
1274
  }
1329
1275
  };
1330
1276
  __name(_WorksheetPivotTablePermission, "WorksheetPivotTablePermission");
@@ -1335,8 +1281,8 @@ const _WorksheetEditExtraObjectPermission = class _WorksheetEditExtraObjectPermi
1335
1281
  __publicField(this, "type", M.Worksheet);
1336
1282
  __publicField(this, "status", PermissionStatus.INIT);
1337
1283
  __publicField(this, "id");
1338
- __publicField(this, "subType", L.EditExtraObject);
1339
- this.unitId = unitId, this.subUnitId = subUnitId, this.id = `${this.type}.${L.EditExtraObject}_${unitId}_${subUnitId}`;
1284
+ __publicField(this, "subType", P.EditExtraObject);
1285
+ this.unitId = unitId, this.subUnitId = subUnitId, this.id = `${this.type}.${P.EditExtraObject}_${unitId}_${subUnitId}`;
1340
1286
  }
1341
1287
  };
1342
1288
  __name(_WorksheetEditExtraObjectPermission, "WorksheetEditExtraObjectPermission");
@@ -1347,8 +1293,8 @@ const _WorksheetManageCollaboratorPermission = class _WorksheetManageCollaborato
1347
1293
  __publicField(this, "type", M.Worksheet);
1348
1294
  __publicField(this, "status", PermissionStatus.INIT);
1349
1295
  __publicField(this, "id");
1350
- __publicField(this, "subType", L.ManageCollaborator);
1351
- this.unitId = unitId, this.subUnitId = subUnitId, this.id = `${this.type}.${L.ManageCollaborator}_${unitId}_${subUnitId}`;
1296
+ __publicField(this, "subType", P.ManageCollaborator);
1297
+ this.unitId = unitId, this.subUnitId = subUnitId, this.id = `${this.type}.${P.ManageCollaborator}_${unitId}_${subUnitId}`;
1352
1298
  }
1353
1299
  };
1354
1300
  __name(_WorksheetManageCollaboratorPermission, "WorksheetManageCollaboratorPermission");
@@ -1359,8 +1305,8 @@ const _WorksheetEditPermission = class _WorksheetEditPermission {
1359
1305
  __publicField(this, "type", M.Worksheet);
1360
1306
  __publicField(this, "status", PermissionStatus.INIT);
1361
1307
  __publicField(this, "id");
1362
- __publicField(this, "subType", L.Edit);
1363
- this.unitId = unitId, this.subUnitId = subUnitId, this.id = `${this.type}.${L.Edit}_${unitId}_${subUnitId}`;
1308
+ __publicField(this, "subType", P.Edit);
1309
+ this.unitId = unitId, this.subUnitId = subUnitId, this.id = `${this.type}.${P.Edit}_${unitId}_${subUnitId}`;
1364
1310
  }
1365
1311
  };
1366
1312
  __name(_WorksheetEditPermission, "WorksheetEditPermission");
@@ -1371,8 +1317,8 @@ const _WorkbookCommentPermission = class _WorkbookCommentPermission {
1371
1317
  __publicField(this, "value", !0);
1372
1318
  __publicField(this, "type", M.Workbook);
1373
1319
  __publicField(this, "status", PermissionStatus.INIT);
1374
- __publicField(this, "subType", L.Comment);
1375
- this.unitId = unitId, this.unitId = unitId, this.id = `${this.type}.${L.Comment}_${unitId}`;
1320
+ __publicField(this, "subType", P.Comment);
1321
+ this.unitId = unitId, this.unitId = unitId, this.id = `${this.type}.${P.Comment}_${unitId}`;
1376
1322
  }
1377
1323
  };
1378
1324
  __name(_WorkbookCommentPermission, "WorkbookCommentPermission");
@@ -1383,8 +1329,8 @@ const _WorkbookEditablePermission = class _WorkbookEditablePermission {
1383
1329
  __publicField(this, "value", !0);
1384
1330
  __publicField(this, "type", M.Workbook);
1385
1331
  __publicField(this, "status", PermissionStatus.INIT);
1386
- __publicField(this, "subType", L.Edit);
1387
- this.unitId = unitId, this.unitId = unitId, this.id = `${this.type}.${L.Edit}_${unitId}`;
1332
+ __publicField(this, "subType", P.Edit);
1333
+ this.unitId = unitId, this.unitId = unitId, this.id = `${this.type}.${P.Edit}_${unitId}`;
1388
1334
  }
1389
1335
  };
1390
1336
  __name(_WorkbookEditablePermission, "WorkbookEditablePermission");
@@ -1395,8 +1341,8 @@ const _WorkbookDuplicatePermission = class _WorkbookDuplicatePermission {
1395
1341
  __publicField(this, "value", !0);
1396
1342
  __publicField(this, "type", M.Workbook);
1397
1343
  __publicField(this, "status", PermissionStatus.INIT);
1398
- __publicField(this, "subType", L.Duplicate);
1399
- this.unitId = unitId, this.unitId = unitId, this.id = `${this.type}.${L.Duplicate}_${unitId}`;
1344
+ __publicField(this, "subType", P.Duplicate);
1345
+ this.unitId = unitId, this.unitId = unitId, this.id = `${this.type}.${P.Duplicate}_${unitId}`;
1400
1346
  }
1401
1347
  };
1402
1348
  __name(_WorkbookDuplicatePermission, "WorkbookDuplicatePermission");
@@ -1407,8 +1353,8 @@ const _WorkbookPrintPermission = class _WorkbookPrintPermission {
1407
1353
  __publicField(this, "value", !0);
1408
1354
  __publicField(this, "type", M.Workbook);
1409
1355
  __publicField(this, "status", PermissionStatus.INIT);
1410
- __publicField(this, "subType", L.Print);
1411
- this.unitId = unitId, this.unitId = unitId, this.id = `${this.type}.${L.Print}_${unitId}`;
1356
+ __publicField(this, "subType", P.Print);
1357
+ this.unitId = unitId, this.unitId = unitId, this.id = `${this.type}.${P.Print}_${unitId}`;
1412
1358
  }
1413
1359
  };
1414
1360
  __name(_WorkbookPrintPermission, "WorkbookPrintPermission");
@@ -1419,8 +1365,8 @@ const _WorkbookExportPermission = class _WorkbookExportPermission {
1419
1365
  __publicField(this, "value", !0);
1420
1366
  __publicField(this, "type", M.Workbook);
1421
1367
  __publicField(this, "status", PermissionStatus.INIT);
1422
- __publicField(this, "subType", L.Export);
1423
- this.unitId = unitId, this.unitId = unitId, this.id = `${this.type}.${L.Export}_${unitId}`;
1368
+ __publicField(this, "subType", P.Export);
1369
+ this.unitId = unitId, this.unitId = unitId, this.id = `${this.type}.${P.Export}_${unitId}`;
1424
1370
  }
1425
1371
  };
1426
1372
  __name(_WorkbookExportPermission, "WorkbookExportPermission");
@@ -1431,8 +1377,8 @@ const _WorkbookMoveSheetPermission = class _WorkbookMoveSheetPermission {
1431
1377
  __publicField(this, "value", !0);
1432
1378
  __publicField(this, "type", M.Workbook);
1433
1379
  __publicField(this, "status", PermissionStatus.INIT);
1434
- __publicField(this, "subType", L.MoveSheet);
1435
- this.unitId = unitId, this.unitId = unitId, this.id = `${this.type}.${L.MoveSheet}_${unitId}`;
1380
+ __publicField(this, "subType", P.MoveSheet);
1381
+ this.unitId = unitId, this.unitId = unitId, this.id = `${this.type}.${P.MoveSheet}_${unitId}`;
1436
1382
  }
1437
1383
  };
1438
1384
  __name(_WorkbookMoveSheetPermission, "WorkbookMoveSheetPermission");
@@ -1443,8 +1389,8 @@ const _WorkbookDeleteSheetPermission = class _WorkbookDeleteSheetPermission {
1443
1389
  __publicField(this, "value", !0);
1444
1390
  __publicField(this, "type", M.Workbook);
1445
1391
  __publicField(this, "status", PermissionStatus.INIT);
1446
- __publicField(this, "subType", L.DeleteSheet);
1447
- this.unitId = unitId, this.unitId = unitId, this.id = `${this.type}.${L.DeleteSheet}_${unitId}`;
1392
+ __publicField(this, "subType", P.DeleteSheet);
1393
+ this.unitId = unitId, this.unitId = unitId, this.id = `${this.type}.${P.DeleteSheet}_${unitId}`;
1448
1394
  }
1449
1395
  };
1450
1396
  __name(_WorkbookDeleteSheetPermission, "WorkbookDeleteSheetPermission");
@@ -1455,8 +1401,8 @@ const _WorkbookHideSheetPermission = class _WorkbookHideSheetPermission {
1455
1401
  __publicField(this, "value", !0);
1456
1402
  __publicField(this, "type", M.Workbook);
1457
1403
  __publicField(this, "status", PermissionStatus.INIT);
1458
- __publicField(this, "subType", L.HideSheet);
1459
- this.unitId = unitId, this.unitId = unitId, this.id = `${this.type}.${L.HideSheet}_${unitId}`;
1404
+ __publicField(this, "subType", P.HideSheet);
1405
+ this.unitId = unitId, this.unitId = unitId, this.id = `${this.type}.${P.HideSheet}_${unitId}`;
1460
1406
  }
1461
1407
  };
1462
1408
  __name(_WorkbookHideSheetPermission, "WorkbookHideSheetPermission");
@@ -1467,8 +1413,8 @@ const _WorkbookRenameSheetPermission = class _WorkbookRenameSheetPermission {
1467
1413
  __publicField(this, "value", !0);
1468
1414
  __publicField(this, "type", M.Workbook);
1469
1415
  __publicField(this, "status", PermissionStatus.INIT);
1470
- __publicField(this, "subType", L.RenameSheet);
1471
- this.unitId = unitId, this.unitId = unitId, this.id = `${this.type}.${L.RenameSheet}_${unitId}`;
1416
+ __publicField(this, "subType", P.RenameSheet);
1417
+ this.unitId = unitId, this.unitId = unitId, this.id = `${this.type}.${P.RenameSheet}_${unitId}`;
1472
1418
  }
1473
1419
  };
1474
1420
  __name(_WorkbookRenameSheetPermission, "WorkbookRenameSheetPermission");
@@ -1479,8 +1425,8 @@ const _WorkbookCreateSheetPermission = class _WorkbookCreateSheetPermission {
1479
1425
  __publicField(this, "value", !0);
1480
1426
  __publicField(this, "type", M.Workbook);
1481
1427
  __publicField(this, "status", PermissionStatus.INIT);
1482
- __publicField(this, "subType", L.CreateSheet);
1483
- this.unitId = unitId, this.unitId = unitId, this.id = `${this.type}.${L.CreateSheet}_${unitId}`;
1428
+ __publicField(this, "subType", P.CreateSheet);
1429
+ this.unitId = unitId, this.unitId = unitId, this.id = `${this.type}.${P.CreateSheet}_${unitId}`;
1484
1430
  }
1485
1431
  };
1486
1432
  __name(_WorkbookCreateSheetPermission, "WorkbookCreateSheetPermission");
@@ -1491,8 +1437,8 @@ const _WorkbookHistoryPermission = class _WorkbookHistoryPermission {
1491
1437
  __publicField(this, "value", !0);
1492
1438
  __publicField(this, "type", M.Workbook);
1493
1439
  __publicField(this, "status", PermissionStatus.INIT);
1494
- __publicField(this, "subType", L.History);
1495
- this.unitId = unitId, this.unitId = unitId, this.id = `${this.type}.${L.History}_${unitId}`;
1440
+ __publicField(this, "subType", P.History);
1441
+ this.unitId = unitId, this.unitId = unitId, this.id = `${this.type}.${P.History}_${unitId}`;
1496
1442
  }
1497
1443
  };
1498
1444
  __name(_WorkbookHistoryPermission, "WorkbookHistoryPermission");
@@ -1503,8 +1449,8 @@ const _WorkbookViewPermission = class _WorkbookViewPermission {
1503
1449
  __publicField(this, "value", !0);
1504
1450
  __publicField(this, "type", M.Workbook);
1505
1451
  __publicField(this, "status", PermissionStatus.INIT);
1506
- __publicField(this, "subType", L.View);
1507
- this.unitId = unitId, this.unitId = unitId, this.id = `${this.type}.${L.View}_${unitId}`;
1452
+ __publicField(this, "subType", P.View);
1453
+ this.unitId = unitId, this.unitId = unitId, this.id = `${this.type}.${P.View}_${unitId}`;
1508
1454
  }
1509
1455
  };
1510
1456
  __name(_WorkbookViewPermission, "WorkbookViewPermission");
@@ -1515,8 +1461,8 @@ const _WorkbookSharePermission = class _WorkbookSharePermission {
1515
1461
  __publicField(this, "value", !0);
1516
1462
  __publicField(this, "type", M.Workbook);
1517
1463
  __publicField(this, "status", PermissionStatus.INIT);
1518
- __publicField(this, "subType", L.Share);
1519
- this.unitId = unitId, this.unitId = unitId, this.id = `${this.type}.${L.Share}_${unitId}`;
1464
+ __publicField(this, "subType", P.Share);
1465
+ this.unitId = unitId, this.unitId = unitId, this.id = `${this.type}.${P.Share}_${unitId}`;
1520
1466
  }
1521
1467
  };
1522
1468
  __name(_WorkbookSharePermission, "WorkbookSharePermission");
@@ -1527,8 +1473,8 @@ const _WorkbookCopyPermission = class _WorkbookCopyPermission {
1527
1473
  __publicField(this, "value", !0);
1528
1474
  __publicField(this, "type", M.Workbook);
1529
1475
  __publicField(this, "status", PermissionStatus.INIT);
1530
- __publicField(this, "subType", L.Copy);
1531
- this.unitId = unitId, this.unitId = unitId, this.id = `${this.type}.${L.Copy}_${unitId}`;
1476
+ __publicField(this, "subType", P.Copy);
1477
+ this.unitId = unitId, this.unitId = unitId, this.id = `${this.type}.${P.Copy}_${unitId}`;
1532
1478
  }
1533
1479
  };
1534
1480
  __name(_WorkbookCopyPermission, "WorkbookCopyPermission");
@@ -1538,9 +1484,9 @@ const _WorkbookCopySheetPermission = class _WorkbookCopySheetPermission {
1538
1484
  __publicField(this, "id");
1539
1485
  __publicField(this, "value", !0);
1540
1486
  __publicField(this, "type", M.Workbook);
1541
- __publicField(this, "subType", L.CopySheet);
1487
+ __publicField(this, "subType", P.CopySheet);
1542
1488
  __publicField(this, "status", PermissionStatus.INIT);
1543
- this.unitId = unitId, this.unitId = unitId, this.id = `${this.type}.${L.CopySheet}_${unitId}`;
1489
+ this.unitId = unitId, this.unitId = unitId, this.id = `${this.type}.${P.CopySheet}_${unitId}`;
1544
1490
  }
1545
1491
  };
1546
1492
  __name(_WorkbookCopySheetPermission, "WorkbookCopySheetPermission");
@@ -1551,8 +1497,8 @@ const _WorkbookManageCollaboratorPermission = class _WorkbookManageCollaboratorP
1551
1497
  __publicField(this, "value", !0);
1552
1498
  __publicField(this, "type", M.Workbook);
1553
1499
  __publicField(this, "status", PermissionStatus.INIT);
1554
- __publicField(this, "subType", L.ManageCollaborator);
1555
- this.unitId = unitId, this.unitId = unitId, this.id = `${this.type}.${L.ManageCollaborator}_${unitId}`;
1500
+ __publicField(this, "subType", P.ManageCollaborator);
1501
+ this.unitId = unitId, this.unitId = unitId, this.id = `${this.type}.${P.ManageCollaborator}_${unitId}`;
1556
1502
  }
1557
1503
  };
1558
1504
  __name(_WorkbookManageCollaboratorPermission, "WorkbookManageCollaboratorPermission");
@@ -1563,8 +1509,8 @@ const _WorkbookViewHistoryPermission = class _WorkbookViewHistoryPermission {
1563
1509
  __publicField(this, "value", !0);
1564
1510
  __publicField(this, "type", M.Workbook);
1565
1511
  __publicField(this, "status", PermissionStatus.INIT);
1566
- __publicField(this, "subType", L.ViewHistory);
1567
- this.unitId = unitId, this.unitId = unitId, this.id = `${this.type}.${L.ViewHistory}_${unitId}`;
1512
+ __publicField(this, "subType", P.ViewHistory);
1513
+ this.unitId = unitId, this.unitId = unitId, this.id = `${this.type}.${P.ViewHistory}_${unitId}`;
1568
1514
  }
1569
1515
  };
1570
1516
  __name(_WorkbookViewHistoryPermission, "WorkbookViewHistoryPermission");
@@ -1575,8 +1521,8 @@ const _WorkbookRecoverHistoryPermission = class _WorkbookRecoverHistoryPermissio
1575
1521
  __publicField(this, "value", !0);
1576
1522
  __publicField(this, "type", M.Workbook);
1577
1523
  __publicField(this, "status", PermissionStatus.INIT);
1578
- __publicField(this, "subType", L.RecoverHistory);
1579
- this.unitId = unitId, this.unitId = unitId, this.id = `${this.type}.${L.RecoverHistory}_${unitId}`;
1524
+ __publicField(this, "subType", P.RecoverHistory);
1525
+ this.unitId = unitId, this.unitId = unitId, this.id = `${this.type}.${P.RecoverHistory}_${unitId}`;
1580
1526
  }
1581
1527
  };
1582
1528
  __name(_WorkbookRecoverHistoryPermission, "WorkbookRecoverHistoryPermission");
@@ -1584,14 +1530,14 @@ let WorkbookRecoverHistoryPermission = _WorkbookRecoverHistoryPermission;
1584
1530
  const _RangeProtectionPermissionEditPoint = class _RangeProtectionPermissionEditPoint {
1585
1531
  constructor(unitId, subUnitId, permissionId) {
1586
1532
  __publicField(this, "type", M.SelectRange);
1587
- __publicField(this, "subType", L.Edit);
1533
+ __publicField(this, "subType", P.Edit);
1588
1534
  __publicField(this, "status", PermissionStatus.INIT);
1589
1535
  __publicField(this, "value", !0);
1590
1536
  __publicField(this, "id");
1591
1537
  __publicField(this, "unitId");
1592
1538
  __publicField(this, "subUnitId");
1593
1539
  __publicField(this, "permissionId");
1594
- this.unitId = unitId, this.subUnitId = subUnitId, this.permissionId = permissionId, this.id = `${M.SelectRange}.${L.Edit}.${permissionId}`;
1540
+ this.unitId = unitId, this.subUnitId = subUnitId, this.permissionId = permissionId, this.id = `${M.SelectRange}.${P.Edit}.${permissionId}`;
1595
1541
  }
1596
1542
  };
1597
1543
  __name(_RangeProtectionPermissionEditPoint, "RangeProtectionPermissionEditPoint");
@@ -1599,14 +1545,14 @@ let RangeProtectionPermissionEditPoint = _RangeProtectionPermissionEditPoint;
1599
1545
  const _RangeProtectionPermissionViewPoint = class _RangeProtectionPermissionViewPoint {
1600
1546
  constructor(unitId, subUnitId, permissionId) {
1601
1547
  __publicField(this, "type", M.SelectRange);
1602
- __publicField(this, "subType", L.View);
1548
+ __publicField(this, "subType", P.View);
1603
1549
  __publicField(this, "status", PermissionStatus.INIT);
1604
1550
  __publicField(this, "value", !0);
1605
1551
  __publicField(this, "id");
1606
1552
  __publicField(this, "unitId");
1607
1553
  __publicField(this, "subUnitId");
1608
1554
  __publicField(this, "permissionId");
1609
- this.unitId = unitId, this.subUnitId = subUnitId, this.permissionId = permissionId, this.id = `${M.SelectRange}.${L.View}.${permissionId}`;
1555
+ this.unitId = unitId, this.subUnitId = subUnitId, this.permissionId = permissionId, this.id = `${M.SelectRange}.${P.View}.${permissionId}`;
1610
1556
  }
1611
1557
  };
1612
1558
  __name(_RangeProtectionPermissionViewPoint, "RangeProtectionPermissionViewPoint");
@@ -2213,20 +2159,15 @@ const DeleteRangeMoveLeftCommandId = "sheet.command.delete-range-move-left", Del
2213
2159
  const worksheet = workbook.getActiveSheet();
2214
2160
  if (!worksheet)
2215
2161
  return !1;
2216
- const unitId = workbook.getUnitId(), subUnitId = worksheet.getSheetId(), rowCount = range.endRow - range.startRow + 1, cellValue = {};
2217
- Range.foreach(range, (row, col) => {
2218
- const cell = worksheet.getCell(row, col);
2219
- !cell || !cell.s || (cellValue[row] || (cellValue[row] = {}), cellValue[row][col] = { s: cell.s });
2220
- });
2221
- const insertRowParams = {
2162
+ const unitId = workbook.getUnitId(), subUnitId = worksheet.getSheetId(), { startRow, endRow } = range, startColumn = 0, endColumn = worksheet.getColumnCount() - 1, cellValue = copyRangeStyles(worksheet, startRow, endRow, startColumn, endColumn, !0, startRow - 1), insertRowParams = {
2222
2163
  unitId,
2223
2164
  subUnitId,
2224
2165
  direction: Direction.UP,
2225
2166
  range: {
2226
- startRow: range.startRow,
2227
- endRow: range.startRow + rowCount - 1,
2228
- startColumn: 0,
2229
- endColumn: worksheet.getColumnCount() - 1
2167
+ startRow,
2168
+ endRow,
2169
+ startColumn,
2170
+ endColumn
2230
2171
  },
2231
2172
  cellValue
2232
2173
  };
@@ -2249,17 +2190,18 @@ const DeleteRangeMoveLeftCommandId = "sheet.command.delete-range-move-left", Del
2249
2190
  const worksheet = workbook.getActiveSheet();
2250
2191
  if (!worksheet)
2251
2192
  return !1;
2252
- const unitId = workbook.getUnitId(), subUnitId = worksheet.getSheetId(), count = range.endRow - range.startRow + 1, insertRowParams = {
2193
+ const unitId = workbook.getUnitId(), subUnitId = worksheet.getSheetId(), count = range.endRow - range.startRow + 1, startRow = range.endRow + 1, endRow = range.endRow + count, startColumn = 0, endColumn = worksheet.getColumnCount() - 1, cellValue = copyRangeStyles(worksheet, startRow, endRow, startColumn, endColumn, !0, range.endRow), insertRowParams = {
2253
2194
  unitId,
2254
2195
  subUnitId,
2255
2196
  direction: Direction.DOWN,
2256
2197
  range: {
2257
- startRow: range.endRow + 1,
2258
- endRow: range.endRow + count,
2259
- startColumn: 0,
2260
- endColumn: worksheet.getColumnCount() - 1,
2198
+ startRow,
2199
+ endRow,
2200
+ startColumn,
2201
+ endColumn,
2261
2202
  rangeType: RANGE_TYPE.ROW
2262
- }
2203
+ },
2204
+ cellValue
2263
2205
  };
2264
2206
  return accessor.get(ICommandService).executeCommand(InsertRowCommand.id, insertRowParams);
2265
2207
  }, "handler")
@@ -2320,20 +2262,15 @@ const DeleteRangeMoveLeftCommandId = "sheet.command.delete-range-move-left", Del
2320
2262
  const worksheet = workbook.getActiveSheet();
2321
2263
  if (!worksheet)
2322
2264
  return !1;
2323
- const unitId = workbook.getUnitId(), subUnitId = worksheet.getSheetId(), count = range.endColumn - range.startColumn + 1, cellValue = {};
2324
- Range.foreach(range, (row, col) => {
2325
- const cell = worksheet.getCell(row, col);
2326
- !cell || !cell.s || (cellValue[row] || (cellValue[row] = {}), cellValue[row][col] = { s: cell.s });
2327
- });
2328
- const insertColParams = {
2265
+ const unitId = workbook.getUnitId(), subUnitId = worksheet.getSheetId(), { startColumn, endColumn } = range, startRow = 0, endRow = worksheet.getRowCount() - 1, cellValue = copyRangeStyles(worksheet, startRow, endRow, startColumn, endColumn, !1, startColumn - 1), insertColParams = {
2329
2266
  unitId,
2330
2267
  subUnitId,
2331
2268
  direction: Direction.LEFT,
2332
2269
  range: {
2333
- startColumn: range.startColumn,
2334
- endColumn: range.startColumn + count - 1,
2335
- startRow: 0,
2336
- endRow: worksheet.getRowCount() - 1,
2270
+ startColumn,
2271
+ endColumn,
2272
+ startRow,
2273
+ endRow,
2337
2274
  rangeType: RANGE_TYPE.COLUMN
2338
2275
  },
2339
2276
  cellValue
@@ -2356,16 +2293,17 @@ const DeleteRangeMoveLeftCommandId = "sheet.command.delete-range-move-left", Del
2356
2293
  const worksheet = workbook.getActiveSheet();
2357
2294
  if (!worksheet)
2358
2295
  return !1;
2359
- const unitId = workbook.getUnitId(), subUnitId = worksheet.getSheetId(), count = range.endColumn - range.startColumn + 1, insertColParams = {
2296
+ const unitId = workbook.getUnitId(), subUnitId = worksheet.getSheetId(), count = range.endColumn - range.startColumn + 1, startColumn = range.endColumn + 1, endColumn = range.endColumn + count, startRow = 0, endRow = worksheet.getRowCount() - 1, cellValue = copyRangeStyles(worksheet, startRow, endRow, startColumn, endColumn, !1, range.endColumn), insertColParams = {
2360
2297
  unitId,
2361
2298
  subUnitId,
2362
2299
  direction: Direction.RIGHT,
2363
2300
  range: {
2364
- startColumn: range.endColumn + 1,
2365
- endColumn: range.endColumn + count,
2366
- startRow: 0,
2367
- endRow: worksheet.getRowCount() - 1
2368
- }
2301
+ startColumn,
2302
+ endColumn,
2303
+ startRow,
2304
+ endRow
2305
+ },
2306
+ cellValue
2369
2307
  };
2370
2308
  return accessor.get(ICommandService).executeCommand(InsertColCommand.id, insertColParams);
2371
2309
  }, "handler")
@@ -2480,23 +2418,21 @@ __name(columnAcrossMergedCell, "columnAcrossMergedCell");
2480
2418
  const MoveRowsCommandId = "sheet.command.move-rows", MoveRowsCommand = {
2481
2419
  id: MoveRowsCommandId,
2482
2420
  type: CommandType.COMMAND,
2421
+ // eslint-disable-next-line max-lines-per-function
2483
2422
  handler: /* @__PURE__ */ __name(async (accessor, params) => {
2484
2423
  var _a20, _b;
2485
- const selections = accessor.get(SheetsSelectionsService).getCurrentSelections(), {
2424
+ const selectionManagerService = accessor.get(SheetsSelectionsService), {
2486
2425
  fromRange: { startRow: fromRow },
2487
- toRange: { startRow: toRow }
2488
- } = params, filteredSelections = selections == null ? void 0 : selections.filter(
2426
+ toRange: { startRow: toRow },
2427
+ range
2428
+ } = params, selections = range ? [covertRangeToSelection(range)] : selectionManagerService.getCurrentSelections(), filteredSelections = selections == null ? void 0 : selections.filter(
2489
2429
  (selection) => selection.range.rangeType === RANGE_TYPE.ROW && selection.range.startRow <= fromRow && fromRow <= selection.range.endRow
2490
2430
  );
2491
2431
  if ((filteredSelections == null ? void 0 : filteredSelections.length) !== 1)
2492
2432
  return !1;
2493
- const sheetInterceptorService = accessor.get(SheetInterceptorService), workbook = accessor.get(IUniverInstanceService).getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET);
2494
- if (!workbook)
2495
- return !1;
2496
- const worksheet = workbook.getActiveSheet();
2497
- if (!worksheet)
2498
- return !1;
2499
- const unitId = workbook.getUnitId(), subUnitId = worksheet.getSheetId(), errorService = accessor.get(ErrorService), localeService = accessor.get(LocaleService), rangeToMove = filteredSelections[0].range, beforePrimary = filteredSelections[0].primary, alignedRange = alignToMergedCellsBorders(rangeToMove, worksheet, !1);
2433
+ const sheetInterceptorService = accessor.get(SheetInterceptorService), univerInstanceService = accessor.get(IUniverInstanceService), target = getSheetCommandTarget(univerInstanceService, params);
2434
+ if (!target) return !1;
2435
+ const { workbook, worksheet } = target, unitId = workbook.getUnitId(), subUnitId = worksheet.getSheetId(), errorService = accessor.get(ErrorService), localeService = accessor.get(LocaleService), rangeToMove = filteredSelections[0].range, beforePrimary = filteredSelections[0].primary, alignedRange = alignToMergedCellsBorders(rangeToMove, worksheet, !1);
2500
2436
  if (!Rectangle.equals(rangeToMove, alignedRange))
2501
2437
  return errorService.emit(localeService.t("sheets.info.partOfCell")), !1;
2502
2438
  if (rowAcrossMergedCell(toRow, worksheet))
@@ -2510,30 +2446,30 @@ const MoveRowsCommandId = "sheet.command.move-rows", MoveRowsCommand = {
2510
2446
  subUnitId,
2511
2447
  sourceRange: rangeToMove,
2512
2448
  targetRange: destinationRange
2513
- }, undoMoveRowsParams = MoveRowsMutationUndoFactory(accessor, moveRowsParams), moveBackward = toRow - fromRow < 0, count = rangeToMove.endRow - rangeToMove.startRow + 1, destSelection = moveBackward ? destinationRange : {
2514
- ...destinationRange,
2515
- startRow: destinationRange.startRow - count,
2516
- endRow: destinationRange.endRow - count
2517
- }, setSelectionsParam = {
2518
- unitId,
2519
- subUnitId,
2520
- selections: [{ range: destSelection, primary: getPrimaryForRange(destSelection, worksheet), style: null }]
2521
- }, undoSetSelectionsParam = {
2522
- unitId,
2523
- subUnitId,
2524
- selections: [{ range: rangeToMove, primary: beforePrimary, style: null }]
2525
- }, commandService = accessor.get(ICommandService), interceptorCommands = sheetInterceptorService.onCommandExecute({ id: MoveRowsCommand.id, params }), redos = [
2449
+ }, undoMoveRowsParams = MoveRowsMutationUndoFactory(accessor, moveRowsParams), commandService = accessor.get(ICommandService), interceptorCommands = sheetInterceptorService.onCommandExecute({ id: MoveRowsCommand.id, params }), redos = [
2526
2450
  ...(_a20 = interceptorCommands.preRedos) != null ? _a20 : [],
2527
- { id: MoveRowsMutation.id, params: moveRowsParams },
2528
- { id: SetSelectionsOperation.id, params: setSelectionsParam },
2529
- ...interceptorCommands.redos
2451
+ { id: MoveRowsMutation.id, params: moveRowsParams }
2530
2452
  ], undos = [
2531
2453
  ...(_b = interceptorCommands.preUndos) != null ? _b : [],
2532
- { id: MoveRowsMutation.id, params: undoMoveRowsParams },
2533
- { id: SetSelectionsOperation.id, params: undoSetSelectionsParam },
2534
- ...interceptorCommands.undos
2454
+ { id: MoveRowsMutation.id, params: undoMoveRowsParams }
2535
2455
  ];
2536
- return sequenceExecute(redos, commandService).result ? (accessor.get(IUndoRedoService).pushUndoRedo({
2456
+ if (beforePrimary) {
2457
+ const moveBackward = toRow - fromRow < 0, count = rangeToMove.endRow - rangeToMove.startRow + 1, destSelection = moveBackward ? destinationRange : {
2458
+ ...destinationRange,
2459
+ startRow: destinationRange.startRow - count,
2460
+ endRow: destinationRange.endRow - count
2461
+ }, setSelectionsParam = {
2462
+ unitId,
2463
+ subUnitId,
2464
+ selections: [{ range: destSelection, primary: getPrimaryForRange(destSelection, worksheet), style: null }]
2465
+ }, undoSetSelectionsParam = {
2466
+ unitId,
2467
+ subUnitId,
2468
+ selections: [{ range: rangeToMove, primary: beforePrimary, style: null }]
2469
+ };
2470
+ redos.push({ id: SetSelectionsOperation.id, params: setSelectionsParam }), undos.push({ id: SetSelectionsOperation.id, params: undoSetSelectionsParam });
2471
+ }
2472
+ return redos.push(...interceptorCommands.redos), undos.push(...interceptorCommands.undos), sequenceExecute(redos, commandService).result ? (accessor.get(IUndoRedoService).pushUndoRedo({
2537
2473
  unitID: unitId,
2538
2474
  undoMutations: undos,
2539
2475
  redoMutations: redos
@@ -2542,23 +2478,21 @@ const MoveRowsCommandId = "sheet.command.move-rows", MoveRowsCommand = {
2542
2478
  }, MoveColsCommandId = "sheet.command.move-cols", MoveColsCommand = {
2543
2479
  id: MoveColsCommandId,
2544
2480
  type: CommandType.COMMAND,
2481
+ // eslint-disable-next-line max-lines-per-function
2545
2482
  handler: /* @__PURE__ */ __name(async (accessor, params) => {
2546
2483
  var _a20, _b;
2547
- const selections = accessor.get(SheetsSelectionsService).getCurrentSelections(), {
2484
+ const selectionManagerService = accessor.get(SheetsSelectionsService), {
2548
2485
  fromRange: { startColumn: fromCol },
2549
- toRange: { startColumn: toCol }
2550
- } = params, filteredSelections = selections == null ? void 0 : selections.filter(
2486
+ toRange: { startColumn: toCol },
2487
+ range
2488
+ } = params, selections = range ? [covertRangeToSelection(range)] : selectionManagerService.getCurrentSelections(), filteredSelections = selections == null ? void 0 : selections.filter(
2551
2489
  (selection) => selection.range.rangeType === RANGE_TYPE.COLUMN && selection.range.startColumn <= fromCol && fromCol <= selection.range.endColumn
2552
2490
  );
2553
2491
  if ((filteredSelections == null ? void 0 : filteredSelections.length) !== 1)
2554
2492
  return !1;
2555
- const sheetInterceptorService = accessor.get(SheetInterceptorService), workbook = accessor.get(IUniverInstanceService).getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET);
2556
- if (!workbook)
2557
- return !1;
2558
- const worksheet = workbook.getActiveSheet();
2559
- if (!worksheet)
2560
- return !1;
2561
- const unitId = workbook.getUnitId(), subUnitId = worksheet.getSheetId(), errorService = accessor.get(ErrorService), localeService = accessor.get(LocaleService), rangeToMove = filteredSelections[0].range, beforePrimary = filteredSelections[0].primary, alignedRange = alignToMergedCellsBorders(rangeToMove, worksheet, !1);
2493
+ const sheetInterceptorService = accessor.get(SheetInterceptorService), univerInstanceService = accessor.get(IUniverInstanceService), target = getSheetCommandTarget(univerInstanceService, params);
2494
+ if (!target) return !1;
2495
+ const { workbook, worksheet } = target, unitId = workbook.getUnitId(), subUnitId = worksheet.getSheetId(), errorService = accessor.get(ErrorService), localeService = accessor.get(LocaleService), rangeToMove = filteredSelections[0].range, beforePrimary = filteredSelections[0].primary, alignedRange = alignToMergedCellsBorders(rangeToMove, worksheet, !1);
2562
2496
  if (!Rectangle.equals(rangeToMove, alignedRange))
2563
2497
  return errorService.emit(localeService.t("sheets.info.partOfCell")), !1;
2564
2498
  if (columnAcrossMergedCell(toCol, worksheet))
@@ -2572,36 +2506,45 @@ const MoveRowsCommandId = "sheet.command.move-rows", MoveRowsCommand = {
2572
2506
  subUnitId,
2573
2507
  sourceRange: rangeToMove,
2574
2508
  targetRange: destinationRange
2575
- }, undoMoveColsParams = MoveColsMutationUndoFactory(accessor, moveColsParams), count = rangeToMove.endColumn - rangeToMove.startColumn + 1, destSelection = toCol - fromCol < 0 ? destinationRange : {
2576
- ...destinationRange,
2577
- startColumn: destinationRange.startColumn - count,
2578
- endColumn: destinationRange.endColumn - count
2579
- }, setSelectionsParam = {
2580
- unitId,
2581
- subUnitId,
2582
- selections: [{ range: destSelection, primary: getPrimaryForRange(destSelection, worksheet), style: null }]
2583
- }, undoSetSelectionsParam = {
2584
- unitId,
2585
- subUnitId,
2586
- selections: [{ range: rangeToMove, primary: beforePrimary, style: null }]
2587
- }, commandService = accessor.get(ICommandService), interceptorCommands = sheetInterceptorService.onCommandExecute({ id: MoveColsCommand.id, params }), redos = [
2509
+ }, undoMoveColsParams = MoveColsMutationUndoFactory(accessor, moveColsParams), commandService = accessor.get(ICommandService), interceptorCommands = sheetInterceptorService.onCommandExecute({ id: MoveColsCommand.id, params }), redos = [
2588
2510
  ...(_a20 = interceptorCommands.preRedos) != null ? _a20 : [],
2589
- { id: MoveColsMutation.id, params: moveColsParams },
2590
- { id: SetSelectionsOperation.id, params: setSelectionsParam },
2591
- ...interceptorCommands.redos
2511
+ { id: MoveColsMutation.id, params: moveColsParams }
2592
2512
  ], undos = [
2593
2513
  ...(_b = interceptorCommands.preUndos) != null ? _b : [],
2594
- { id: MoveColsMutation.id, params: undoMoveColsParams },
2595
- { id: SetSelectionsOperation.id, params: undoSetSelectionsParam },
2596
- ...interceptorCommands.undos
2514
+ { id: MoveColsMutation.id, params: undoMoveColsParams }
2597
2515
  ];
2598
- return sequenceExecute(redos, commandService).result && accessor.get(IUndoRedoService).pushUndoRedo({
2516
+ if (beforePrimary) {
2517
+ const count = rangeToMove.endColumn - rangeToMove.startColumn + 1, destSelection = toCol - fromCol < 0 ? destinationRange : {
2518
+ ...destinationRange,
2519
+ startColumn: destinationRange.startColumn - count,
2520
+ endColumn: destinationRange.endColumn - count
2521
+ }, setSelectionsParam = {
2522
+ unitId,
2523
+ subUnitId,
2524
+ selections: [{ range: destSelection, primary: getPrimaryForRange(destSelection, worksheet), style: null }]
2525
+ }, undoSetSelectionsParam = {
2526
+ unitId,
2527
+ subUnitId,
2528
+ selections: [{ range: rangeToMove, primary: beforePrimary, style: null }]
2529
+ };
2530
+ redos.push({ id: SetSelectionsOperation.id, params: setSelectionsParam }), undos.push({ id: SetSelectionsOperation.id, params: undoSetSelectionsParam });
2531
+ }
2532
+ return redos.push(...interceptorCommands.redos), undos.push(...interceptorCommands.undos), sequenceExecute(redos, commandService).result && accessor.get(IUndoRedoService).pushUndoRedo({
2599
2533
  unitID: unitId,
2600
2534
  undoMutations: undos,
2601
2535
  redoMutations: redos
2602
2536
  }), !0;
2603
2537
  }, "handler")
2604
- }, RemoveRowCommandId = "sheet.command.remove-row", RemoveRowCommand = {
2538
+ };
2539
+ function covertRangeToSelection(range) {
2540
+ return {
2541
+ range,
2542
+ primary: null,
2543
+ style: null
2544
+ };
2545
+ }
2546
+ __name(covertRangeToSelection, "covertRangeToSelection");
2547
+ const RemoveRowCommandId = "sheet.command.remove-row", RemoveRowCommand = {
2605
2548
  type: CommandType.COMMAND,
2606
2549
  id: RemoveRowCommandId,
2607
2550
  // eslint-disable-next-line max-lines-per-function
@@ -3333,12 +3276,12 @@ const SetBorderBasicCommand = {
3333
3276
  }, SetColHiddenCommand = {
3334
3277
  type: CommandType.COMMAND,
3335
3278
  id: "sheet.command.set-col-hidden",
3336
- handler: /* @__PURE__ */ __name(async (accessor) => {
3337
- var _a20, _b, _c;
3279
+ handler: /* @__PURE__ */ __name(async (accessor, params) => {
3280
+ var _a20, _b, _c, _d;
3338
3281
  const selectionManagerService = accessor.get(SheetsSelectionsService), sheetInterceptorService = accessor.get(SheetInterceptorService), univerInstanceService = accessor.get(IUniverInstanceService), commandService = accessor.get(ICommandService);
3339
- let ranges = (_a20 = selectionManagerService.getCurrentSelections()) == null ? void 0 : _a20.map((s) => s.range).filter((r) => r.rangeType === RANGE_TYPE.COLUMN);
3282
+ let ranges = (_a20 = params == null ? void 0 : params.ranges) != null && _a20.length ? params.ranges : (_b = selectionManagerService.getCurrentSelections()) == null ? void 0 : _b.map((s) => s.range).filter((r) => r.rangeType === RANGE_TYPE.COLUMN);
3340
3283
  if (!(ranges != null && ranges.length)) return !1;
3341
- const target = getSheetCommandTarget(univerInstanceService);
3284
+ const target = getSheetCommandTarget(univerInstanceService, params);
3342
3285
  if (!target) return !1;
3343
3286
  const { worksheet, unitId, subUnitId } = target;
3344
3287
  ranges = divideRangesByHiddenCols(target.worksheet, ranges);
@@ -3370,10 +3313,10 @@ const SetBorderBasicCommand = {
3370
3313
  undoMutations: [
3371
3314
  { id: SetColVisibleMutation.id, params: undoMutationParams },
3372
3315
  { id: SetSelectionsOperation.id, params: undoSetSelectionsOperationParams },
3373
- ...(_b = intercepted.undos) != null ? _b : []
3316
+ ...(_c = intercepted.undos) != null ? _c : []
3374
3317
  ],
3375
3318
  redoMutations: [
3376
- ...(_c = intercepted.preRedos) != null ? _c : [],
3319
+ ...(_d = intercepted.preRedos) != null ? _d : [],
3377
3320
  { id: SetColHiddenMutation.id, params: redoMutationParams },
3378
3321
  { id: SetSelectionsOperation.id, params: setSelectionOperationParams },
3379
3322
  ...intercepted.redos
@@ -3601,12 +3544,12 @@ const SetFrozenMutationFactory = /* @__PURE__ */ __name((accessor, params) => {
3601
3544
  }, SetRowHiddenCommand = {
3602
3545
  type: CommandType.COMMAND,
3603
3546
  id: "sheet.command.set-rows-hidden",
3604
- handler: /* @__PURE__ */ __name(async (accessor) => {
3605
- var _a20, _b, _c, _d, _e;
3547
+ handler: /* @__PURE__ */ __name(async (accessor, params) => {
3548
+ var _a20, _b, _c, _d, _e, _f;
3606
3549
  const selectionManagerService = accessor.get(SheetsSelectionsService), commandService = accessor.get(ICommandService), undoRedoService = accessor.get(IUndoRedoService), univerInstanceService = accessor.get(IUniverInstanceService), sheetInterceptorService = accessor.get(SheetInterceptorService);
3607
- let ranges = (_a20 = selectionManagerService.getCurrentSelections()) == null ? void 0 : _a20.map((s) => s.range).filter((r) => r.rangeType === RANGE_TYPE.ROW);
3550
+ let ranges = (_a20 = params == null ? void 0 : params.ranges) != null && _a20.length ? params.ranges : (_b = selectionManagerService.getCurrentSelections()) == null ? void 0 : _b.map((s) => s.range).filter((r) => r.rangeType === RANGE_TYPE.ROW);
3608
3551
  if (!(ranges != null && ranges.length)) return !1;
3609
- const target = getSheetCommandTarget(univerInstanceService);
3552
+ const target = getSheetCommandTarget(univerInstanceService, params);
3610
3553
  if (!target) return !1;
3611
3554
  ranges = divideRangesByHiddenRows(target.worksheet, ranges);
3612
3555
  const { unitId, subUnitId, worksheet } = target, redoMutationParams = { unitId, subUnitId, ranges }, setSelectionOperationParams = {
@@ -3627,20 +3570,20 @@ const SetFrozenMutationFactory = /* @__PURE__ */ __name((accessor, params) => {
3627
3570
  }))
3628
3571
  }, intercepted = sheetInterceptorService.onCommandExecute({ id: SetRowHiddenCommand.id, params: redoMutationParams });
3629
3572
  return sequenceExecute([
3630
- ...(_b = intercepted.preRedos) != null ? _b : [],
3573
+ ...(_c = intercepted.preRedos) != null ? _c : [],
3631
3574
  { id: SetRowHiddenMutation.id, params: redoMutationParams },
3632
3575
  { id: SetSelectionsOperation.id, params: setSelectionOperationParams },
3633
3576
  ...intercepted.redos
3634
3577
  ], commandService).result && undoRedoService.pushUndoRedo({
3635
3578
  unitID: unitId,
3636
3579
  undoMutations: [
3637
- ...(_c = intercepted.preUndos) != null ? _c : [],
3580
+ ...(_d = intercepted.preUndos) != null ? _d : [],
3638
3581
  { id: SetRowVisibleMutation.id, params: undoMutationParams },
3639
3582
  { id: SetSelectionsOperation.id, params: undoSetSelectionsOperationParams },
3640
- ...(_d = intercepted.undos) != null ? _d : []
3583
+ ...(_e = intercepted.undos) != null ? _e : []
3641
3584
  ],
3642
3585
  redoMutations: [
3643
- ...(_e = intercepted.preRedos) != null ? _e : [],
3586
+ ...(_f = intercepted.preRedos) != null ? _f : [],
3644
3587
  { id: SetRowHiddenMutation.id, params: redoMutationParams },
3645
3588
  { id: SetSelectionsOperation.id, params: setSelectionOperationParams },
3646
3589
  ...intercepted.redos
@@ -4154,10 +4097,10 @@ const SetStyleCommand = {
4154
4097
  type: CommandType.COMMAND,
4155
4098
  id: "sheet.command.set-worksheet-col-width",
4156
4099
  handler: /* @__PURE__ */ __name(async (accessor, params) => {
4157
- var _a20, _b, _c;
4158
- const selectionManagerService = accessor.get(SheetsSelectionsService), commandService = accessor.get(ICommandService), undoRedoService = accessor.get(IUndoRedoService), sheetInterceptorService = accessor.get(SheetInterceptorService), selections = (_a20 = selectionManagerService.getCurrentSelections()) == null ? void 0 : _a20.map((s) => s.range);
4100
+ var _a20, _b, _c, _d;
4101
+ const selectionManagerService = accessor.get(SheetsSelectionsService), commandService = accessor.get(ICommandService), undoRedoService = accessor.get(IUndoRedoService), sheetInterceptorService = accessor.get(SheetInterceptorService), selections = (_a20 = params == null ? void 0 : params.ranges) != null && _a20.length ? params.ranges : (_b = selectionManagerService.getCurrentSelections()) == null ? void 0 : _b.map((s) => s.range);
4159
4102
  if (!(selections != null && selections.length)) return !1;
4160
- const target = getSheetCommandTarget(accessor.get(IUniverInstanceService));
4103
+ const target = getSheetCommandTarget(accessor.get(IUniverInstanceService), params);
4161
4104
  if (!target) return !1;
4162
4105
  const { subUnitId, unitId } = target, redoMutationParams = {
4163
4106
  subUnitId,
@@ -4179,8 +4122,8 @@ const SetStyleCommand = {
4179
4122
  }), result = sequenceExecute([...redos, ...intercepted.redos], commandService);
4180
4123
  return setColWidthResult && result.result ? (undoRedoService.pushUndoRedo({
4181
4124
  unitID: unitId,
4182
- undoMutations: [...(_b = intercepted.preUndos) != null ? _b : [], { id: SetWorksheetColWidthMutation.id, params: undoMutationParams }, ...undos],
4183
- redoMutations: [...(_c = intercepted.preRedos) != null ? _c : [], { id: SetWorksheetColWidthMutation.id, params: redoMutationParams }, ...redos]
4125
+ undoMutations: [...(_c = intercepted.preUndos) != null ? _c : [], { id: SetWorksheetColWidthMutation.id, params: undoMutationParams }, ...undos],
4126
+ redoMutations: [...(_d = intercepted.preRedos) != null ? _d : [], { id: SetWorksheetColWidthMutation.id, params: redoMutationParams }, ...redos]
4184
4127
  }), !0) : !1;
4185
4128
  }, "handler")
4186
4129
  }, SetWorksheetHideMutationFactory = /* @__PURE__ */ __name((accessor, params) => {
@@ -4383,7 +4326,7 @@ const SetStyleCommand = {
4383
4326
  for (const { startRow, endRow } of ranges)
4384
4327
  for (let rowIndex = startRow; rowIndex <= endRow; rowIndex++) {
4385
4328
  const row = manager.getRowOrCreate(rowIndex);
4386
- typeof autoHeightInfo == "number" ? row.ia = autoHeightInfo : row.ia = (_a20 = autoHeightInfo[rowIndex - startRow]) != null ? _a20 : defaultRowIsAutoHeight;
4329
+ typeof autoHeightInfo == "number" ? row.ia = autoHeightInfo : row.ia = (_a20 = autoHeightInfo[rowIndex]) != null ? _a20 : defaultRowIsAutoHeight;
4387
4330
  }
4388
4331
  return !0;
4389
4332
  }, "handler")
@@ -4499,11 +4442,11 @@ const SetStyleCommand = {
4499
4442
  id: "sheet.command.set-row-height",
4500
4443
  // eslint-disable-next-line max-lines-per-function
4501
4444
  handler: /* @__PURE__ */ __name((accessor, params) => {
4502
- var _a20, _b, _c;
4503
- const selectionManagerService = accessor.get(SheetsSelectionsService), commandService = accessor.get(ICommandService), undoRedoService = accessor.get(IUndoRedoService), univerInstanceService = accessor.get(IUniverInstanceService), sheetInterceptorService = accessor.get(SheetInterceptorService), selections = (_a20 = selectionManagerService.getCurrentSelections()) == null ? void 0 : _a20.map((s) => s.range);
4445
+ var _a20, _b, _c, _d;
4446
+ const selectionManagerService = accessor.get(SheetsSelectionsService), commandService = accessor.get(ICommandService), undoRedoService = accessor.get(IUndoRedoService), univerInstanceService = accessor.get(IUniverInstanceService), sheetInterceptorService = accessor.get(SheetInterceptorService), selections = (_a20 = params == null ? void 0 : params.ranges) != null && _a20.length ? params.ranges : (_b = selectionManagerService.getCurrentSelections()) == null ? void 0 : _b.map((s) => s.range);
4504
4447
  if (!(selections != null && selections.length))
4505
4448
  return !1;
4506
- const target = getSheetCommandTarget(univerInstanceService);
4449
+ const target = getSheetCommandTarget(univerInstanceService, params);
4507
4450
  if (!target) return !1;
4508
4451
  const { unitId, subUnitId } = target, redoMutationParams = {
4509
4452
  subUnitId,
@@ -4534,7 +4477,7 @@ const SetStyleCommand = {
4534
4477
  return result.result && sheetInterceptorResult.result ? (undoRedoService.pushUndoRedo({
4535
4478
  unitID: unitId,
4536
4479
  undoMutations: [
4537
- ...(_b = intercepted.preRedos) != null ? _b : [],
4480
+ ...(_c = intercepted.preRedos) != null ? _c : [],
4538
4481
  {
4539
4482
  id: SetWorksheetRowHeightMutation.id,
4540
4483
  params: undoMutationParams
@@ -4546,7 +4489,7 @@ const SetStyleCommand = {
4546
4489
  ...intercepted.undos
4547
4490
  ],
4548
4491
  redoMutations: [
4549
- ...(_c = intercepted.preRedos) != null ? _c : [],
4492
+ ...(_d = intercepted.preRedos) != null ? _d : [],
4550
4493
  {
4551
4494
  id: SetWorksheetRowHeightMutation.id,
4552
4495
  params: redoMutationParams
@@ -4563,17 +4506,10 @@ const SetStyleCommand = {
4563
4506
  type: CommandType.COMMAND,
4564
4507
  id: "sheet.command.set-row-is-auto-height",
4565
4508
  handler: /* @__PURE__ */ __name(async (accessor, params) => {
4566
- var _a20;
4567
- const commandService = accessor.get(ICommandService), undoRedoService = accessor.get(IUndoRedoService), selectionManagerService = accessor.get(SheetsSelectionsService), univerInstanceService = accessor.get(IUniverInstanceService), target = getSheetCommandTarget(univerInstanceService);
4509
+ var _a20, _b;
4510
+ const commandService = accessor.get(ICommandService), undoRedoService = accessor.get(IUndoRedoService), selectionManagerService = accessor.get(SheetsSelectionsService), univerInstanceService = accessor.get(IUniverInstanceService), target = getSheetCommandTarget(univerInstanceService, params);
4568
4511
  if (!target) return !1;
4569
- const { unitId, subUnitId, worksheet } = target, { anchorRow } = params != null ? params : {}, ranges = anchorRow != null ? [
4570
- {
4571
- startRow: anchorRow,
4572
- endRow: anchorRow,
4573
- startColumn: 0,
4574
- endColumn: worksheet.getMaxColumns() - 1
4575
- }
4576
- ] : (_a20 = selectionManagerService.getCurrentSelections()) == null ? void 0 : _a20.map((s) => s.range);
4512
+ const { unitId, subUnitId } = target, ranges = (_a20 = params == null ? void 0 : params.ranges) != null && _a20.length ? params.ranges : (_b = selectionManagerService.getCurrentSelections()) == null ? void 0 : _b.map((s) => s.range);
4577
4513
  if (!(ranges != null && ranges.length))
4578
4514
  return !1;
4579
4515
  const redoMutationParams = {
@@ -5105,20 +5041,20 @@ const getAllWorksheetPermissionPoint = /* @__PURE__ */ __name(() => [
5105
5041
  WorksheetSetRowStylePermission,
5106
5042
  WorksheetSortPermission
5107
5043
  ], "getAllWorksheetPermissionPointByPointPanel"), defaultWorksheetPermissionPoint = [
5108
- L.Copy,
5109
- L.DeleteColumn,
5110
- L.DeleteRow,
5111
- L.EditExtraObject,
5112
- L.Filter,
5113
- L.InsertColumn,
5114
- L.InsertRow,
5115
- L.InsertHyperlink,
5116
- L.PivotTable,
5117
- L.SetCellStyle,
5118
- L.SetCellValue,
5119
- L.SetColumnStyle,
5120
- L.SetRowStyle,
5121
- L.Sort
5044
+ P.Copy,
5045
+ P.DeleteColumn,
5046
+ P.DeleteRow,
5047
+ P.EditExtraObject,
5048
+ P.Filter,
5049
+ P.InsertColumn,
5050
+ P.InsertRow,
5051
+ P.InsertHyperlink,
5052
+ P.PivotTable,
5053
+ P.SetCellStyle,
5054
+ P.SetCellValue,
5055
+ P.SetColumnStyle,
5056
+ P.SetRowStyle,
5057
+ P.Sort
5122
5058
  ];
5123
5059
  var __defProp$d = Object.defineProperty, __getOwnPropDesc$d = Object.getOwnPropertyDescriptor, __decorateClass$d = /* @__PURE__ */ __name((decorators, target, key, kind) => {
5124
5060
  for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$d(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
@@ -6314,7 +6250,7 @@ const handleInsertRow = /* @__PURE__ */ __name((param, targetRange) => {
6314
6250
  return handleRemoveRowCommon(commandInfo.params, range);
6315
6251
  }
6316
6252
  return runRefRangeMutations(operator, range);
6317
- }, "handleCommonDefaultRangeChangeWithEffectRefCommands"), handleCommonRangeChangeWithEffectRefCommandsSkipNoInterests = /* @__PURE__ */ __name((range, commandInfo, deps) => [DeleteRangeMoveLeftCommand.id, DeleteRangeMoveUpCommand.id].includes(commandInfo.id) || getEffectedRangesOnCommand(commandInfo, deps).some((effectRange) => Rectangle.intersects(effectRange, range)) ? handleCommonDefaultRangeChangeWithEffectRefCommands(range, commandInfo) : range, "handleCommonRangeChangeWithEffectRefCommandsSkipNoInterests");
6253
+ }, "handleCommonDefaultRangeChangeWithEffectRefCommands"), handleCommonRangeChangeWithEffectRefCommandsSkipNoInterests = /* @__PURE__ */ __name((range, commandInfo, deps) => [DeleteRangeMoveLeftCommand.id, DeleteRangeMoveUpCommand.id, InsertRangeMoveDownCommand.id, InsertRangeMoveRightCommandId].includes(commandInfo.id) || getEffectedRangesOnCommand(commandInfo, deps).some((effectRange) => Rectangle.intersects(effectRange, range)) ? handleCommonDefaultRangeChangeWithEffectRefCommands(range, commandInfo) : range, "handleCommonRangeChangeWithEffectRefCommandsSkipNoInterests");
6318
6254
  function adjustRangeOnMutation(range, mutation) {
6319
6255
  const { id, params } = mutation;
6320
6256
  let baseRangeOperator = {
@@ -7654,21 +7590,23 @@ const getAllWorkbookPermissionPoint = /* @__PURE__ */ __name(() => [
7654
7590
  WorkbookViewHistoryPermission,
7655
7591
  WorkbookRecoverHistoryPermission
7656
7592
  ], "getAllWorkbookPermissionPoint"), defaultWorkbookPermissionPoints = [
7657
- L.Edit,
7658
- L.Print,
7659
- L.Comment,
7660
- L.View,
7661
- L.Copy,
7662
- L.Export,
7663
- L.ManageCollaborator,
7664
- L.CreateSheet,
7665
- L.DeleteSheet,
7666
- L.RenameSheet,
7667
- L.HideSheet,
7668
- L.Duplicate,
7669
- L.Share,
7670
- L.MoveSheet,
7671
- L.CopySheet
7593
+ P.Edit,
7594
+ P.Print,
7595
+ P.Comment,
7596
+ P.View,
7597
+ P.Copy,
7598
+ P.Export,
7599
+ P.ManageCollaborator,
7600
+ P.CreateSheet,
7601
+ P.DeleteSheet,
7602
+ P.RenameSheet,
7603
+ P.HideSheet,
7604
+ P.Duplicate,
7605
+ P.Share,
7606
+ P.MoveSheet,
7607
+ P.CopySheet,
7608
+ P.RecoverHistory,
7609
+ P.ViewHistory
7672
7610
  ];
7673
7611
  var __defProp$6 = Object.defineProperty, __getOwnPropDesc$6 = Object.getOwnPropertyDescriptor, __decorateClass$6 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
7674
7612
  for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$6(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
@@ -8122,7 +8060,7 @@ let RangeProtectionService = (_a17 = class extends Disposable {
8122
8060
  objectID: rule.permissionId,
8123
8061
  unitID: unitId,
8124
8062
  objectType: M.SelectRange,
8125
- actions: [L.View, L.Edit]
8063
+ actions: [P.View, P.Edit]
8126
8064
  });
8127
8065
  }), list.forEach((rule) => {
8128
8066
  getAllRangePermissionPoint().forEach((Factor) => {
@@ -8140,7 +8078,6 @@ let RangeProtectionService = (_a17 = class extends Disposable {
8140
8078
  }
8141
8079
  }, __name(_a17, "RangeProtectionService"), _a17);
8142
8080
  RangeProtectionService = __decorateClass$2([
8143
- OnLifecycle(LifecycleStages.Starting, RangeProtectionService),
8144
8081
  __decorateParam$2(0, Inject(RangeProtectionRuleModel)),
8145
8082
  __decorateParam$2(1, Inject(IPermissionService)),
8146
8083
  __decorateParam$2(2, Inject(IResourceManagerService))
@@ -8185,8 +8122,8 @@ var __defProp2 = Object.defineProperty, __getOwnPropDesc = Object.getOwnProperty
8185
8122
  const PLUGIN_NAME = "SHEET_PLUGIN";
8186
8123
  var _a19;
8187
8124
  let UniverSheetsPlugin = (_a19 = class extends Plugin {
8188
- constructor(_config, _commandService, _configService, _localeService, _injector) {
8189
- super(), this._config = _config, this._commandService = _commandService, this._configService = _configService, this._localeService = _localeService, this._injector = _injector, this._initConfig(), this._initDependencies(_injector);
8125
+ constructor(_config, _configService, _injector) {
8126
+ super(), this._config = _config, this._configService = _configService, this._injector = _injector, this._initConfig(), this._initDependencies(_injector);
8190
8127
  }
8191
8128
  onRendered() {
8192
8129
  }
@@ -8219,21 +8156,17 @@ let UniverSheetsPlugin = (_a19 = class extends Plugin {
8219
8156
  [RangeProtectionRefRangeService],
8220
8157
  [RangeProtectionService]
8221
8158
  ];
8222
- (_a20 = this._config) != null && _a20.notExecuteFormula || dependencies.push(
8223
- [CalculateResultApplyController]
8224
- ), mergeOverrideWithDependencies(dependencies, (_b = this._config) == null ? void 0 : _b.override).forEach((d) => {
8159
+ (_a20 = this._config) != null && _a20.notExecuteFormula || dependencies.push([CalculateResultApplyController]), mergeOverrideWithDependencies(dependencies, (_b = this._config) == null ? void 0 : _b.override).forEach((d) => {
8225
8160
  sheetInjector.add(d);
8226
- });
8161
+ }), this._injector.get(SheetInterceptorService), this._injector.get(RangeProtectionService);
8227
8162
  }
8228
8163
  }, __name(_a19, "UniverSheetsPlugin"), _a19);
8229
8164
  __publicField2(UniverSheetsPlugin, "pluginName", PLUGIN_NAME);
8230
8165
  __publicField2(UniverSheetsPlugin, "type", UniverInstanceType.UNIVER_SHEET);
8231
8166
  UniverSheetsPlugin = __decorateClass([
8232
8167
  DependentOn(UniverFormulaEnginePlugin),
8233
- __decorateParam(1, ICommandService),
8234
- __decorateParam(2, IConfigService),
8235
- __decorateParam(3, Inject(LocaleService)),
8236
- __decorateParam(4, Inject(Injector))
8168
+ __decorateParam(1, IConfigService),
8169
+ __decorateParam(2, Inject(Injector))
8237
8170
  ], UniverSheetsPlugin);
8238
8171
  const COMMAND_LISTENER_SKELETON_CHANGE = [
8239
8172
  SetWorksheetRowHeightMutation.id,
@@ -8380,7 +8313,193 @@ const AddMergeRedoSelectionsOperationFactory = /* @__PURE__ */ __name((accessor,
8380
8313
  };
8381
8314
  }
8382
8315
  return null;
8383
- }, "AddMergeUndoSelectionsOperationFactory"), checkRangesEditablePermission = /* @__PURE__ */ __name((accessor, unitId, subUnitId, ranges) => {
8316
+ }, "AddMergeUndoSelectionsOperationFactory");
8317
+ function cellHasValue(cell) {
8318
+ return cell == null ? !1 : cell.v !== void 0 && cell.v !== null && cell.v !== "" || cell.p !== void 0;
8319
+ }
8320
+ __name(cellHasValue, "cellHasValue");
8321
+ function hasValueFromMatrixWithSpanInfo(cell, matrix) {
8322
+ return cell && cell.spanAnchor ? cellHasValue(matrix.getValue(cell.spanAnchor.startRow, cell.spanAnchor.startColumn)) : cellHasValue(cell);
8323
+ }
8324
+ __name(hasValueFromMatrixWithSpanInfo, "hasValueFromMatrixWithSpanInfo");
8325
+ function getMatrixWithSpanInfo(worksheet, startRow, startColumn, endRow, endColumn) {
8326
+ const matrix = worksheet.getCellMatrix(), mergedCellsInRange = worksheet.getSnapshot().mergeData.filter(
8327
+ (rect) => Rectangle.intersects({ startRow, startColumn, endRow, endColumn }, rect)
8328
+ ), returnCellMatrix = new ObjectMatrix();
8329
+ return matrix.forValue((row, col) => {
8330
+ const v = matrix.getValue(row, col);
8331
+ v && returnCellMatrix.setValue(row, col, v);
8332
+ }), mergedCellsInRange.forEach((mergedCell) => {
8333
+ const { startColumn: startColumn2, startRow: startRow2, endColumn: endColumn2, endRow: endRow2 } = mergedCell;
8334
+ createRowColIter(startRow2, endRow2, startColumn2, endColumn2).forEach((row, col) => {
8335
+ row === startRow2 && col === startColumn2 && returnCellMatrix.setValue(row, col, {
8336
+ ...matrix.getValue(row, col),
8337
+ spanAnchor: { startRow: startRow2, endRow: endRow2, startColumn: startColumn2, endColumn: endColumn2 }
8338
+ }), (row !== startRow2 || col !== startColumn2) && (returnCellMatrix.realDeleteValue(row, col), returnCellMatrix.setValue(row, col, {
8339
+ spanAnchor: { startRow: startRow2, endRow: endRow2, startColumn: startColumn2, endColumn: endColumn2 }
8340
+ }));
8341
+ });
8342
+ }), returnCellMatrix;
8343
+ }
8344
+ __name(getMatrixWithSpanInfo, "getMatrixWithSpanInfo");
8345
+ function getExpandedRangeLeft(range, allMatrixWithSpan, leftOffset, isWorksheetHasSpan) {
8346
+ const { startRow, startColumn, endRow } = range;
8347
+ let spanAnchor = null, hasValue = !1;
8348
+ for (let i = startRow; i <= endRow; i++) {
8349
+ const cell = allMatrixWithSpan.getValue(i, startColumn - leftOffset);
8350
+ if (hasValue = hasValue || hasValueFromMatrixWithSpanInfo(cell, allMatrixWithSpan), !isWorksheetHasSpan && hasValue)
8351
+ break;
8352
+ cell && cell.spanAnchor && (spanAnchor ? spanAnchor = {
8353
+ startRow: Math.min(cell.spanAnchor.startRow, spanAnchor.startRow),
8354
+ startColumn: Math.min(cell.spanAnchor.startColumn, spanAnchor.startColumn),
8355
+ endRow: Math.max(cell.spanAnchor.endRow, spanAnchor.endRow),
8356
+ endColumn: Math.max(cell.spanAnchor.endColumn, spanAnchor.endColumn)
8357
+ } : spanAnchor = {
8358
+ startRow: cell.spanAnchor.startRow,
8359
+ startColumn: cell.spanAnchor.startColumn,
8360
+ endRow: cell.spanAnchor.endRow,
8361
+ endColumn: cell.spanAnchor.endColumn
8362
+ });
8363
+ }
8364
+ return hasValue ? (range.startColumn = range.startColumn - leftOffset, {
8365
+ spanAnchor,
8366
+ hasValue: !0,
8367
+ range
8368
+ }) : {
8369
+ spanAnchor: null,
8370
+ hasValue: !1,
8371
+ range
8372
+ };
8373
+ }
8374
+ __name(getExpandedRangeLeft, "getExpandedRangeLeft");
8375
+ function getExpandedRangeRight(range, allMatrixWithSpan, rightOffset, isWorksheetHasSpan) {
8376
+ const { startRow, endColumn, endRow } = range;
8377
+ let spanAnchor = null, hasValue = !1;
8378
+ for (let i = startRow; i <= endRow; i++) {
8379
+ const cell = allMatrixWithSpan.getValue(i, endColumn + rightOffset);
8380
+ if (hasValue = hasValue || hasValueFromMatrixWithSpanInfo(cell, allMatrixWithSpan), !isWorksheetHasSpan && hasValue)
8381
+ break;
8382
+ cell && cell.spanAnchor && (spanAnchor ? spanAnchor = {
8383
+ startRow: Math.min(cell.spanAnchor.startRow, spanAnchor.startRow),
8384
+ startColumn: Math.min(cell.spanAnchor.startColumn, spanAnchor.startColumn),
8385
+ endRow: Math.max(cell.spanAnchor.endRow, spanAnchor.endRow),
8386
+ endColumn: Math.max(cell.spanAnchor.endColumn, spanAnchor.endColumn)
8387
+ } : spanAnchor = {
8388
+ startRow: cell.spanAnchor.startRow,
8389
+ startColumn: cell.spanAnchor.startColumn,
8390
+ endRow: cell.spanAnchor.endRow,
8391
+ endColumn: cell.spanAnchor.endColumn
8392
+ });
8393
+ }
8394
+ return hasValue ? (range.endColumn = range.endColumn + rightOffset, {
8395
+ spanAnchor,
8396
+ hasValue: !0,
8397
+ range
8398
+ }) : {
8399
+ spanAnchor: null,
8400
+ hasValue: !1,
8401
+ range
8402
+ };
8403
+ }
8404
+ __name(getExpandedRangeRight, "getExpandedRangeRight");
8405
+ function getExpandedRangeUp(range, allMatrixWithSpan, upOffset, isWorksheetHasSpan) {
8406
+ const { startRow, startColumn, endColumn } = range;
8407
+ let spanAnchor = null, hasValue = !1;
8408
+ for (let i = startColumn; i <= endColumn; i++) {
8409
+ const cell = allMatrixWithSpan.getValue(startRow - upOffset, i);
8410
+ if (hasValue = hasValue || hasValueFromMatrixWithSpanInfo(cell, allMatrixWithSpan), !isWorksheetHasSpan && hasValue)
8411
+ break;
8412
+ cell && cell.spanAnchor && (spanAnchor ? spanAnchor = {
8413
+ startRow: Math.min(cell.spanAnchor.startRow, spanAnchor.startRow),
8414
+ startColumn: Math.min(cell.spanAnchor.startColumn, spanAnchor.startColumn),
8415
+ endRow: Math.max(cell.spanAnchor.endRow, spanAnchor.endRow),
8416
+ endColumn: Math.max(cell.spanAnchor.endColumn, spanAnchor.endColumn)
8417
+ } : spanAnchor = {
8418
+ startRow: cell.spanAnchor.startRow,
8419
+ startColumn: cell.spanAnchor.startColumn,
8420
+ endRow: cell.spanAnchor.endRow,
8421
+ endColumn: cell.spanAnchor.endColumn
8422
+ });
8423
+ }
8424
+ return hasValue ? (range.startRow = range.startRow - upOffset, {
8425
+ spanAnchor,
8426
+ hasValue: !0,
8427
+ range
8428
+ }) : {
8429
+ spanAnchor: null,
8430
+ hasValue: !1,
8431
+ range
8432
+ };
8433
+ }
8434
+ __name(getExpandedRangeUp, "getExpandedRangeUp");
8435
+ function getExpandedRangeDown(range, allMatrixWithSpan, downOffset, isWorksheetHasSpan) {
8436
+ const { startColumn, endColumn, endRow } = range;
8437
+ let spanAnchor = null, hasValue = !1;
8438
+ for (let i = startColumn; i <= endColumn; i++) {
8439
+ const cell = allMatrixWithSpan.getValue(endRow + downOffset, i);
8440
+ if (hasValue = hasValue || hasValueFromMatrixWithSpanInfo(cell, allMatrixWithSpan), !isWorksheetHasSpan && hasValue)
8441
+ break;
8442
+ cell && cell.spanAnchor && (spanAnchor ? spanAnchor = {
8443
+ startRow: Math.min(cell.spanAnchor.startRow, spanAnchor.startRow),
8444
+ startColumn: Math.min(cell.spanAnchor.startColumn, spanAnchor.startColumn),
8445
+ endRow: Math.max(cell.spanAnchor.endRow, spanAnchor.endRow),
8446
+ endColumn: Math.max(cell.spanAnchor.endColumn, spanAnchor.endColumn)
8447
+ } : spanAnchor = {
8448
+ startRow: cell.spanAnchor.startRow,
8449
+ startColumn: cell.spanAnchor.startColumn,
8450
+ endRow: cell.spanAnchor.endRow,
8451
+ endColumn: cell.spanAnchor.endColumn
8452
+ });
8453
+ }
8454
+ return hasValue ? (range.endRow = range.endRow + downOffset, {
8455
+ spanAnchor,
8456
+ hasValue: !0,
8457
+ range
8458
+ }) : {
8459
+ spanAnchor: null,
8460
+ hasValue: !1,
8461
+ range
8462
+ };
8463
+ }
8464
+ __name(getExpandedRangeDown, "getExpandedRangeDown");
8465
+ function expandToContinuousRange(startRange, directions, worksheet) {
8466
+ const maxRow = worksheet.getMaxRows(), maxColumn = worksheet.getMaxColumns(), allMatrixWithSpan = getMatrixWithSpanInfo(worksheet, 0, 0, maxRow - 1, maxColumn - 1), worksheetHasSpan = worksheet.getSnapshot().mergeData.length > 0, { left, right, up, down } = directions;
8467
+ let changed = !0, destRange = { ...startRange };
8468
+ const spanAnchors = [];
8469
+ for (; changed; ) {
8470
+ if (changed = !1, up && destRange.startRow !== 0) {
8471
+ const { hasValue, range, spanAnchor } = getExpandedRangeUp(destRange, allMatrixWithSpan, 1, worksheetHasSpan);
8472
+ if (spanAnchor && spanAnchors.push(spanAnchor), hasValue) {
8473
+ destRange = range, changed = !0;
8474
+ continue;
8475
+ }
8476
+ }
8477
+ if (down && destRange.endRow !== maxRow - 1) {
8478
+ const { hasValue, range, spanAnchor } = getExpandedRangeDown(destRange, allMatrixWithSpan, 1, worksheetHasSpan);
8479
+ if (spanAnchor && spanAnchors.push(spanAnchor), hasValue) {
8480
+ destRange = range, changed = !0;
8481
+ continue;
8482
+ }
8483
+ }
8484
+ if (left && destRange.startColumn !== 0) {
8485
+ const { hasValue, range, spanAnchor } = getExpandedRangeLeft(destRange, allMatrixWithSpan, 1, worksheetHasSpan);
8486
+ if (spanAnchor && spanAnchors.push(spanAnchor), hasValue) {
8487
+ destRange = range, changed = !0;
8488
+ continue;
8489
+ }
8490
+ }
8491
+ if (right && destRange.endColumn !== maxColumn - 1) {
8492
+ const { hasValue, range, spanAnchor } = getExpandedRangeRight(destRange, allMatrixWithSpan, 1, worksheetHasSpan);
8493
+ if (spanAnchor && spanAnchors.push(spanAnchor), hasValue) {
8494
+ destRange = range, changed = !0;
8495
+ continue;
8496
+ }
8497
+ }
8498
+ }
8499
+ return spanAnchors.length > 0 && (destRange = Rectangle.union(destRange, ...spanAnchors)), destRange;
8500
+ }
8501
+ __name(expandToContinuousRange, "expandToContinuousRange");
8502
+ const checkRangesEditablePermission = /* @__PURE__ */ __name((accessor, unitId, subUnitId, ranges) => {
8384
8503
  const permissionService = accessor.get(IPermissionService), rangeProtectionRuleModel = accessor.get(RangeProtectionRuleModel$1), workbookEditablePermission = permissionService.getPermissionPoint(new WorkbookEditablePermission$1(unitId).id);
8385
8504
  if (!(workbookEditablePermission != null && workbookEditablePermission.value))
8386
8505
  return !1;
@@ -8818,6 +8937,7 @@ export {
8818
8937
  checkRangesEditablePermission,
8819
8938
  convertPrimaryWithCoordToPrimary,
8820
8939
  convertSelectionDataToRange,
8940
+ copyRangeStyles,
8821
8941
  createTopMatrixFromMatrix,
8822
8942
  createTopMatrixFromRanges,
8823
8943
  defaultWorkbookPermissionPoints,