@univerjs/sheets-filter 0.10.10-experimental.20251016-33b0941 → 0.10.10-nightly.202510180256

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/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  var be = Object.defineProperty;
2
- var $e = (i, r, e) => r in i ? be(i, r, { enumerable: !0, configurable: !0, writable: !0, value: e }) : i[r] = e;
3
- var C = (i, r, e) => $e(i, typeof r != "symbol" ? r + "" : r, e);
2
+ var $e = (i, t, e) => t in i ? be(i, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : i[t] = e;
3
+ var C = (i, t, e) => $e(i, typeof t != "symbol" ? t + "" : t, e);
4
4
  import { createREGEXFromWildChar as me, isNumeric as Le, Disposable as U, Rectangle as te, mergeSets as K, Tools as ie, extractPureTextFromCell as Ue, CellValueType as k, ColorKit as se, UniverInstanceType as D, fromCallback as Pe, CommandType as O, IResourceManagerService as De, IUniverInstanceService as T, ICommandService as N, IUndoRedoService as J, sequenceExecute as j, ErrorService as Be, LocaleService as ze, Inject as A, Optional as He, DisposableCollection as ge, moveMatrixArray as oe, IConfigService as _e, Plugin as Ve, merge as We, touchDependencies as je, Injector as ke } from "@univerjs/core";
5
5
  import { getSheetCommandTarget as H, SheetsSelectionsService as qe, isSingleCellSelection as Ge, expandToContinuousRange as Ce, SheetInterceptorService as Qe, RefRangeService as Je, ZebraCrossingCacheController as Ze, SetWorksheetActiveOperation as Ke, CopySheetCommand as Ye, RemoveSheetCommand as Xe, INTERCEPTOR_POINT as et, RemoveRowMutation as tt, InsertRowMutation as rt, SetRangeValuesMutation as nt, MoveRowsCommand as it, MoveRangeCommand as st, EffectRefRangId as le, RemoveRowCommand as ot, RemoveColCommand as lt, InsertColCommand as at, InsertRowCommand as ct, InsertColMutation as Re, RemoveColMutation as pe, MoveColsMutation as Se } from "@univerjs/sheets";
6
6
  import { BehaviorSubject as $, merge as dt, filter as ut, switchMap as ht, of as ft } from "rxjs";
@@ -16,29 +16,29 @@ const Fe = "sheet.mutation.set-filter-range", we = "sheet.mutation.set-filter-cr
16
16
  var b = /* @__PURE__ */ ((i) => (i[i.VALUES = 0] = "VALUES", i[i.COLORS = 1] = "COLORS", i[i.CONDITIONS = 2] = "CONDITIONS", i))(b || {}), I = /* @__PURE__ */ ((i) => (i.EQUAL = "equal", i.GREATER_THAN = "greaterThan", i.GREATER_THAN_OR_EQUAL = "greaterThanOrEqual", i.LESS_THAN = "lessThan", i.LESS_THAN_OR_EQUAL = "lessThanOrEqual", i.NOT_EQUALS = "notEqual", i))(I || {});
17
17
  const Rt = {
18
18
  operator: I.GREATER_THAN,
19
- fn: (i, r) => P(i) ? i > r : !1
19
+ fn: (i, t) => P(i) ? i > t : !1
20
20
  }, pt = {
21
21
  operator: I.GREATER_THAN_OR_EQUAL,
22
- fn: (i, r) => P(i) ? i >= r : !1
22
+ fn: (i, t) => P(i) ? i >= t : !1
23
23
  }, St = {
24
24
  operator: I.LESS_THAN,
25
- fn: (i, r) => P(i) ? i < r : !1
25
+ fn: (i, t) => P(i) ? i < t : !1
26
26
  }, Ft = {
27
27
  operator: I.LESS_THAN_OR_EQUAL,
28
- fn: (i, r) => P(i) ? i <= r : !1
28
+ fn: (i, t) => P(i) ? i <= t : !1
29
29
  }, wt = {
30
30
  operator: I.EQUAL,
31
- fn: (i, r) => P(i) ? i === r : !1
31
+ fn: (i, t) => P(i) ? i === t : !1
32
32
  }, Oe = {
33
33
  operator: I.NOT_EQUALS,
34
- fn: (i, r) => {
35
- if (typeof r == "string") {
36
- if (r === " ")
34
+ fn: (i, t) => {
35
+ if (typeof t == "string") {
36
+ if (t === " ")
37
37
  return i != null;
38
38
  const e = Ae(i);
39
- return e && Ot(r) ? !me(r).test(e) : e !== r;
39
+ return e && Ot(t) ? !me(t).test(e) : e !== t;
40
40
  }
41
- return P(i) ? i !== r : !0;
41
+ return P(i) ? i !== t : !0;
42
42
  }
43
43
  }, ye = /* @__PURE__ */ new Map([]), vt = [Rt, pt, St, Ft, wt, Oe];
44
44
  vt.forEach((i) => {
@@ -48,9 +48,9 @@ function Mt(i) {
48
48
  return !!i;
49
49
  }
50
50
  const Et = {
51
- fn: (i, r) => {
51
+ fn: (i, t) => {
52
52
  const e = Ae(i);
53
- return e === null ? r === "" : me(r).test(e);
53
+ return e === null ? t === "" : me(t).test(e);
54
54
  }
55
55
  };
56
56
  function ae(i) {
@@ -70,7 +70,7 @@ function Ot(i) {
70
70
  }
71
71
  const Y = () => /* @__PURE__ */ new Set();
72
72
  class q extends U {
73
- constructor(e, t, n) {
73
+ constructor(e, r, n) {
74
74
  super();
75
75
  C(this, "_filteredOutRows$", new $(Y()));
76
76
  /** An observable value. A set of filtered out rows. */
@@ -81,7 +81,7 @@ class q extends U {
81
81
  C(this, "_filterColumnByIndex", /* @__PURE__ */ new Map());
82
82
  C(this, "_alreadyFilteredOutRows", Y());
83
83
  C(this, "_range");
84
- this.unitId = e, this.subUnitId = t, this._worksheet = n;
84
+ this.unitId = e, this.subUnitId = r, this._worksheet = n;
85
85
  }
86
86
  get filteredOutRows() {
87
87
  return this._filteredOutRows$.getValue();
@@ -90,7 +90,7 @@ class q extends U {
90
90
  this._alreadyFilteredOutRows = e, this._filteredOutRows$.next(e);
91
91
  }
92
92
  dispose() {
93
- super.dispose(), this._filteredOutRows$.complete(), this._hasCriteria$.complete();
93
+ super.dispose(), this._filteredOutRows$.complete(), this._hasCriteria$.complete(), this._worksheet = null;
94
94
  }
95
95
  /**
96
96
  * Serialize this filter model to the JSON format representation.
@@ -98,7 +98,7 @@ class q extends U {
98
98
  serialize() {
99
99
  const e = {
100
100
  ref: te.clone(this._range),
101
- filterColumns: this._getAllFilterColumns(!0).sort(([t], [n]) => t - n).map(([t, n]) => n.serialize())
101
+ filterColumns: this._getAllFilterColumns(!0).sort(([r], [n]) => r - n).map(([r, n]) => n.serialize())
102
102
  };
103
103
  return this._alreadyFilteredOutRows && (e.cachedFilteredOut = Array.from(this._alreadyFilteredOutRows).sort()), e;
104
104
  }
@@ -109,13 +109,13 @@ class q extends U {
109
109
  * @param worksheet the Worksheet object
110
110
  * @param autoFilter auto filter data
111
111
  */
112
- static deserialize(e, t, n, s) {
113
- const o = new q(e, t, n);
112
+ static deserialize(e, r, n, s) {
113
+ const o = new q(e, r, n);
114
114
  return o._dump(s), o;
115
115
  }
116
116
  _dump(e) {
117
- var t;
118
- this.setRange(e.ref), (t = e.filterColumns) == null || t.forEach((n) => this._setCriteriaWithoutReCalc(n.colId, n)), e.cachedFilteredOut && (this._alreadyFilteredOutRows = new Set(e.cachedFilteredOut), this._emit()), this._emitHasCriteria();
117
+ var r;
118
+ this.setRange(e.ref), (r = e.filterColumns) == null || r.forEach((n) => this._setCriteriaWithoutReCalc(n.colId, n)), e.cachedFilteredOut && (this._alreadyFilteredOutRows = new Set(e.cachedFilteredOut), this._emit()), this._emitHasCriteria();
119
119
  }
120
120
  isRowFiltered(e) {
121
121
  return this._alreadyFilteredOutRows.has(e);
@@ -131,9 +131,9 @@ class q extends U {
131
131
  * @param col
132
132
  */
133
133
  getFilteredOutRowsExceptCol(e) {
134
- return this._getAllFilterColumns(!0).filter(([t]) => t !== e).reduce((t, [, n]) => {
135
- const s = n.calc({ getAlreadyFilteredOutRows: () => t });
136
- return s ? K(t, s) : t;
134
+ return this._getAllFilterColumns(!0).filter(([r]) => r !== e).reduce((r, [, n]) => {
135
+ const s = n.calc({ getAlreadyFilteredOutRows: () => r });
136
+ return s ? K(r, s) : r;
137
137
  }, /* @__PURE__ */ new Set());
138
138
  }
139
139
  /**
@@ -141,45 +141,45 @@ class q extends U {
141
141
  * if the new range not overlaps the old range.
142
142
  */
143
143
  setRange(e) {
144
- this._range = e, this._getAllFilterColumns(!0).forEach(([t, n]) => {
144
+ this._range = e, this._getAllFilterColumns(!0).forEach(([r, n]) => {
145
145
  n.setRangeAndColumn({
146
146
  startRow: e.startRow,
147
147
  endRow: e.endRow,
148
- startColumn: t,
149
- endColumn: t
150
- }, t);
148
+ startColumn: r,
149
+ endColumn: r
150
+ }, r);
151
151
  });
152
152
  }
153
153
  /**
154
154
  * Set or remove filter criteria on a specific row.
155
155
  */
156
- setCriteria(e, t, n = !1) {
156
+ setCriteria(e, r, n = !1) {
157
157
  if (!this._range)
158
158
  throw new Error("[FilterModel] could not set criteria before a range is set!");
159
- if (!t) {
159
+ if (!r) {
160
160
  this._removeCriteria(e), this._rebuildAlreadyFilteredOutRowsWithCache(), n && this._reCalcAllColumns(), this._emit(), this._emitHasCriteria();
161
161
  return;
162
162
  }
163
- this._setCriteriaWithoutReCalc(e, t), n && (this._rebuildAlreadyFilteredOutRowsWithCache(), this._reCalcWithNoCacheColumns(), this._emit(), this._emitHasCriteria());
163
+ this._setCriteriaWithoutReCalc(e, r), n && (this._rebuildAlreadyFilteredOutRowsWithCache(), this._reCalcWithNoCacheColumns(), this._emit(), this._emitHasCriteria());
164
164
  }
165
165
  getAllFilterColumns() {
166
166
  return this._getAllFilterColumns(!0);
167
167
  }
168
168
  getFilterColumn(e) {
169
- var t;
170
- return (t = this._filterColumnByIndex.get(e)) != null ? t : null;
169
+ var r;
170
+ return (r = this._filterColumnByIndex.get(e)) != null ? r : null;
171
171
  }
172
172
  reCalc() {
173
173
  this._reCalcAllColumns(), this._emit();
174
174
  }
175
175
  _getAllFilterColumns(e = !1) {
176
- const t = Array.from(this._filterColumnByIndex.entries());
177
- return e ? t : t.map(([n, s]) => s);
176
+ const r = Array.from(this._filterColumnByIndex.entries());
177
+ return e ? r : r.map(([n, s]) => s);
178
178
  }
179
179
  _reCalcAllColumns() {
180
180
  this._alreadyFilteredOutRows = Y(), this._getAllFilterColumns().forEach((e) => e.__clearCache()), this._reCalcWithNoCacheColumns();
181
181
  }
182
- _setCriteriaWithoutReCalc(e, t) {
182
+ _setCriteriaWithoutReCalc(e, r) {
183
183
  const n = this._range;
184
184
  if (!n)
185
185
  throw new Error("[FilterModel] could not set criteria before a range is set!");
@@ -191,13 +191,13 @@ class q extends U {
191
191
  this.unitId,
192
192
  this.subUnitId,
193
193
  this._worksheet,
194
- t,
194
+ r,
195
195
  { getAlreadyFilteredOutRows: () => this._alreadyFilteredOutRows }
196
- ), l.setRangeAndColumn(n, e), this._filterColumnByIndex.set(e, l)), l.setCriteria(t);
196
+ ), l.setRangeAndColumn(n, e), this._filterColumnByIndex.set(e, l)), l.setCriteria(r);
197
197
  }
198
198
  _removeCriteria(e) {
199
- const t = this._filterColumnByIndex.get(e);
200
- t && (t.dispose(), this._filterColumnByIndex.delete(e));
199
+ const r = this._filterColumnByIndex.get(e);
200
+ r && (r.dispose(), this._filterColumnByIndex.delete(e));
201
201
  }
202
202
  _emit() {
203
203
  this._filteredOutRows$.next(this._alreadyFilteredOutRows);
@@ -206,19 +206,19 @@ class q extends U {
206
206
  this._hasCriteria$.next(this._filterColumnByIndex.size > 0);
207
207
  }
208
208
  _rebuildAlreadyFilteredOutRowsWithCache() {
209
- const e = this._getAllFilterColumns().filter((t) => t.hasCache()).reduce((t, n) => K(t, n.filteredOutRows), /* @__PURE__ */ new Set());
209
+ const e = this._getAllFilterColumns().filter((r) => r.hasCache()).reduce((r, n) => K(r, n.filteredOutRows), /* @__PURE__ */ new Set());
210
210
  this._alreadyFilteredOutRows = e;
211
211
  }
212
212
  _reCalcWithNoCacheColumns() {
213
- const e = this._getAllFilterColumns().filter((t) => !t.hasCache());
214
- for (const t of e) {
215
- const n = t.reCalc();
213
+ const e = this._getAllFilterColumns().filter((r) => !r.hasCache());
214
+ for (const r of e) {
215
+ const n = r.reCalc();
216
216
  n && (this._alreadyFilteredOutRows = K(this._alreadyFilteredOutRows, n));
217
217
  }
218
218
  }
219
219
  }
220
220
  class yt extends U {
221
- constructor(e, t, n, s, o) {
221
+ constructor(e, r, n, s, o) {
222
222
  super();
223
223
  C(this, "_filteredOutRows", null);
224
224
  /** Cache the filter function. */
@@ -226,7 +226,7 @@ class yt extends U {
226
226
  C(this, "_range", null);
227
227
  C(this, "_column", 0);
228
228
  C(this, "_filterBy", b.VALUES);
229
- this.unitId = e, this.subUnitId = t, this._worksheet = n, this._criteria = s, this._filterColumnContext = o;
229
+ this.unitId = e, this.subUnitId = r, this._worksheet = n, this._criteria = s, this._filterColumnContext = o;
230
230
  }
231
231
  get filteredOutRows() {
232
232
  return this._filteredOutRows;
@@ -255,8 +255,8 @@ class yt extends U {
255
255
  return this._filteredOutRows !== null;
256
256
  }
257
257
  // The first row should be omitted!
258
- setRangeAndColumn(e, t) {
259
- this._range = e, this._column = t;
258
+ setRangeAndColumn(e, r) {
259
+ this._range = e, this._column = r;
260
260
  }
261
261
  setCriteria(e) {
262
262
  this._criteria = e, this._generateFilterFn(), this._filteredOutRows = null;
@@ -280,7 +280,7 @@ class yt extends U {
280
280
  throw new Error("[FilterColumn] cannot calculate without a range!");
281
281
  if (typeof this._column != "number")
282
282
  throw new TypeError("[FilterColumn] cannot calculate without a column offset!");
283
- const t = this._column, n = { startColumn: t, endColumn: t, startRow: this._range.startRow + 1, endRow: this._range.endRow }, s = /* @__PURE__ */ new Set(), o = e.getAlreadyFilteredOutRows();
283
+ const r = this._column, n = { startColumn: r, endColumn: r, startRow: this._range.startRow + 1, endRow: this._range.endRow }, s = /* @__PURE__ */ new Set(), o = e.getAlreadyFilteredOutRows();
284
284
  for (const l of this._worksheet.iterateByColumn(n, !1, !1)) {
285
285
  const { row: a, rowSpan: c, col: u } = l;
286
286
  if (o.has(a) && (!c || c === 1))
@@ -305,80 +305,80 @@ function At(i) {
305
305
  throw new Error("[FilterModel]: other types of filters are not supported yet.");
306
306
  }
307
307
  function Nt(i) {
308
- const r = !!i.blank, e = new Set(i.filters);
309
- return (t) => t === void 0 || t === "" ? r : e.has(typeof t == "string" ? t : `${t}`);
308
+ const t = !!i.blank, e = new Set(i.filters);
309
+ return (r) => r === void 0 || r === "" ? t : e.has(typeof r == "string" ? r : `${r}`);
310
310
  }
311
311
  function Tt(i) {
312
312
  if (i.cellFillColors) {
313
- const r = new Set(i.cellFillColors);
313
+ const t = new Set(i.cellFillColors);
314
314
  return (e) => {
315
315
  var n;
316
316
  if (!e || !((n = e.bg) != null && n.rgb))
317
- return !!r.has(null);
318
- const t = new se(e.bg.rgb).toRgbString();
319
- return r.has(t);
317
+ return !!t.has(null);
318
+ const r = new se(e.bg.rgb).toRgbString();
319
+ return t.has(r);
320
320
  };
321
321
  }
322
322
  if (i.cellTextColors) {
323
- const r = new Set(i.cellTextColors);
323
+ const t = new Set(i.cellTextColors);
324
324
  return (e) => {
325
325
  var n;
326
326
  if (!e || !((n = e.cl) != null && n.rgb))
327
- return !!r.has(mt);
328
- const t = new se(e.cl.rgb).toRgbString();
329
- return r.has(t);
327
+ return !!t.has(mt);
328
+ const r = new se(e.cl.rgb).toRgbString();
329
+ return t.has(r);
330
330
  };
331
331
  }
332
332
  throw new Error("[FilterModel]: color filters are not supported yet.");
333
333
  }
334
334
  function It(i) {
335
- const r = i.customFilters.map((e) => Lt(e));
336
- return $t(r) ? i.and ? xt(r) : bt(r) : r[0];
335
+ const t = i.customFilters.map((e) => Lt(e));
336
+ return $t(t) ? i.and ? xt(t) : bt(t) : t[0];
337
337
  }
338
338
  function xt(i) {
339
- const [r, e] = i;
340
- return (t) => r(t) && e(t);
339
+ const [t, e] = i;
340
+ return (r) => t(r) && e(r);
341
341
  }
342
342
  function bt(i) {
343
- const [r, e] = i;
344
- return (t) => r(t) || e(t);
343
+ const [t, e] = i;
344
+ return (r) => t(r) || e(r);
345
345
  }
346
346
  function $t(i) {
347
347
  return i.length === 2;
348
348
  }
349
349
  function Lt(i) {
350
- const r = i.val;
351
- if (i.operator === I.NOT_EQUALS && !ce(r))
352
- return (n) => Oe.fn(n, r);
350
+ const t = i.val;
351
+ if (i.operator === I.NOT_EQUALS && !ce(t))
352
+ return (n) => Oe.fn(n, t);
353
353
  if (Mt(i.operator)) {
354
- if (!ce(r)) return () => !1;
355
- const n = ae(i.operator), s = Number(r);
354
+ if (!ce(t)) return () => !1;
355
+ const n = ae(i.operator), s = Number(t);
356
356
  return (o) => n.fn(o, s);
357
357
  }
358
358
  const e = ae(i.operator);
359
- return (t) => e.fn(t, r);
359
+ return (r) => e.fn(r, t);
360
360
  }
361
- function Ut(i, r, e) {
362
- const t = i.getCell(r, e);
363
- if (!t) return null;
364
- const n = i.getCellRaw(r, e);
365
- return t && !n ? de(t) : n ? t.t === k.NUMBER && typeof t.v == "string" ? n.v : t.t === k.NUMBER ? Number(n.v) : de(n) : null;
361
+ function Ut(i, t, e) {
362
+ const r = i.getCell(t, e);
363
+ if (!r) return null;
364
+ const n = i.getCellRaw(t, e);
365
+ return r && !n ? de(r) : n ? r.t === k.NUMBER && typeof r.v == "string" ? n.v : r.t === k.NUMBER ? Number(n.v) : de(n) : null;
366
366
  }
367
367
  function de(i) {
368
- var t, n;
369
- const r = (n = (t = i.p) == null ? void 0 : t.body) == null ? void 0 : n.dataStream;
370
- if (r) return r.trimEnd();
368
+ var r, n;
369
+ const t = (n = (r = i.p) == null ? void 0 : r.body) == null ? void 0 : n.dataStream;
370
+ if (t) return t.trimEnd();
371
371
  const e = i.v;
372
372
  return typeof e == "string" ? i.t === k.BOOLEAN ? e.toUpperCase() : e : typeof e == "number" ? i.t === k.BOOLEAN ? e ? "TRUE" : "FALSE" : e : typeof e == "boolean" ? e ? "TRUE" : "FALSE" : "";
373
373
  }
374
- var Pt = Object.getOwnPropertyDescriptor, Dt = (i, r, e, t) => {
375
- for (var n = t > 1 ? void 0 : t ? Pt(r, e) : r, s = i.length - 1, o; s >= 0; s--)
374
+ var Pt = Object.getOwnPropertyDescriptor, Dt = (i, t, e, r) => {
375
+ for (var n = r > 1 ? void 0 : r ? Pt(t, e) : t, s = i.length - 1, o; s >= 0; s--)
376
376
  (o = i[s]) && (n = o(n) || n);
377
377
  return n;
378
- }, X = (i, r) => (e, t) => r(e, t, i);
378
+ }, X = (i, t) => (e, r) => t(e, r, i);
379
379
  const Ne = "SHEET_FILTER_PLUGIN";
380
380
  let M = class extends U {
381
- constructor(r, e, t) {
381
+ constructor(t, e, r) {
382
382
  super();
383
383
  C(this, "_filterModels", /* @__PURE__ */ new Map());
384
384
  C(this, "_loadedUnitId$", new $(null));
@@ -388,7 +388,7 @@ let M = class extends U {
388
388
  C(this, "_activeFilterModel$", new $(null));
389
389
  /** An observable value emitting the current Workbook's active Worksheet's filter model (if there is one). */
390
390
  C(this, "activeFilterModel$", this._activeFilterModel$.asObservable());
391
- this._resourcesManagerService = r, this._univerInstanceService = e, this._commandService = t, this._initModel(), this._initActiveFilterModel();
391
+ this._resourcesManagerService = t, this._univerInstanceService = e, this._commandService = r, this._initModel(), this._initActiveFilterModel();
392
392
  }
393
393
  /** The current Workbook's active Worksheet's filter model (if there is one). */
394
394
  get activeFilterModel() {
@@ -399,34 +399,34 @@ let M = class extends U {
399
399
  * @param unitId
400
400
  * @param subUnitId
401
401
  */
402
- ensureFilterModel(r, e) {
403
- const t = this.getFilterModel(r, e);
404
- if (t)
405
- return t;
406
- const n = this._univerInstanceService.getUniverSheetInstance(r);
402
+ ensureFilterModel(t, e) {
403
+ const r = this.getFilterModel(t, e);
404
+ if (r)
405
+ return r;
406
+ const n = this._univerInstanceService.getUniverSheetInstance(t);
407
407
  if (!n)
408
- throw new Error(`[SheetsFilterService]: could not create "FilterModel" on a non-existing workbook ${r}!`);
408
+ throw new Error(`[SheetsFilterService]: could not create "FilterModel" on a non-existing workbook ${t}!`);
409
409
  const s = n.getSheetBySheetId(e);
410
410
  if (!s)
411
411
  throw new Error(`[SheetsFilterService]: could not create "FilterModel" on a non-existing worksheet ${e}!`);
412
- const o = new q(r, e, s);
413
- return this._cacheFilterModel(r, e, o), o;
412
+ const o = new q(t, e, s);
413
+ return this._cacheFilterModel(t, e, o), o;
414
414
  }
415
- getFilterModel(r, e) {
416
- var t, n;
417
- return (n = (t = this._filterModels.get(r)) == null ? void 0 : t.get(e)) != null ? n : null;
415
+ getFilterModel(t, e) {
416
+ var r, n;
417
+ return (n = (r = this._filterModels.get(t)) == null ? void 0 : r.get(e)) != null ? n : null;
418
418
  }
419
- removeFilterModel(r, e) {
420
- const t = this.getFilterModel(r, e);
421
- return t ? (t.dispose(), this._filterModels.get(r).delete(e), !0) : !1;
419
+ removeFilterModel(t, e) {
420
+ const r = this.getFilterModel(t, e);
421
+ return r ? (r.dispose(), this._filterModels.get(t).delete(e), !0) : !1;
422
422
  }
423
- setFilterErrorMsg(r) {
424
- this._errorMsg$.next(r);
423
+ setFilterErrorMsg(t) {
424
+ this._errorMsg$.next(t);
425
425
  }
426
426
  _updateActiveFilterModel() {
427
- let r;
427
+ let t;
428
428
  try {
429
- if (r = this._univerInstanceService.getCurrentUnitForType(D.UNIVER_SHEET), !r) {
429
+ if (t = this._univerInstanceService.getCurrentUnitForType(D.UNIVER_SHEET), !t) {
430
430
  this._activeFilterModel$.next(null);
431
431
  return;
432
432
  }
@@ -434,60 +434,65 @@ let M = class extends U {
434
434
  console.error("[SheetsFilterService]: could not get active workbook!", o);
435
435
  return;
436
436
  }
437
- const e = r.getActiveSheet(!0);
437
+ const e = t.getActiveSheet(!0);
438
438
  if (!e) {
439
439
  this._activeFilterModel$.next(null);
440
440
  return;
441
441
  }
442
- const t = e.getUnitId(), n = e.getSheetId(), s = this.getFilterModel(t, n);
442
+ const r = e.getUnitId(), n = e.getSheetId(), s = this.getFilterModel(r, n);
443
443
  this._activeFilterModel$.next(s);
444
444
  }
445
445
  _initActiveFilterModel() {
446
446
  this.disposeWithMe(
447
447
  dt(
448
448
  // source1: executing filter related mutations
449
- Pe(this._commandService.onCommandExecuted.bind(this._commandService)).pipe(ut(([r]) => r.type === O.MUTATION && Ee.has(r.id))),
449
+ Pe(this._commandService.onCommandExecuted.bind(this._commandService)).pipe(ut(([t]) => t.type === O.MUTATION && Ee.has(t.id))),
450
450
  // source2: activate sheet changes
451
- this._univerInstanceService.getCurrentTypeOfUnit$(D.UNIVER_SHEET).pipe(ht((r) => {
451
+ this._univerInstanceService.getCurrentTypeOfUnit$(D.UNIVER_SHEET).pipe(ht((t) => {
452
452
  var e;
453
- return (e = r == null ? void 0 : r.activeSheet$) != null ? e : ft(null);
453
+ return (e = t == null ? void 0 : t.activeSheet$) != null ? e : ft(null);
454
454
  }))
455
455
  ).subscribe(() => this._updateActiveFilterModel())
456
456
  );
457
457
  }
458
- _serializeAutoFiltersForUnit(r) {
459
- const e = this._filterModels.get(r);
458
+ _serializeAutoFiltersForUnit(t) {
459
+ const e = this._filterModels.get(t);
460
460
  if (!e)
461
461
  return "{}";
462
- const t = {};
462
+ const r = {};
463
463
  return e.forEach((n, s) => {
464
- t[s] = n.serialize();
465
- }), JSON.stringify(t);
464
+ r[s] = n.serialize();
465
+ }), JSON.stringify(r);
466
466
  }
467
- _deserializeAutoFiltersForUnit(r, e) {
468
- const t = this._univerInstanceService.getUniverSheetInstance(r);
467
+ _deserializeAutoFiltersForUnit(t, e) {
468
+ const r = this._univerInstanceService.getUniverSheetInstance(t);
469
469
  Object.keys(e).forEach((n) => {
470
- const s = e[n], o = q.deserialize(r, n, t.getSheetBySheetId(n), s);
471
- this._cacheFilterModel(r, n, o);
470
+ const s = e[n], o = q.deserialize(t, n, r.getSheetBySheetId(n), s);
471
+ this._cacheFilterModel(t, n, o);
472
472
  });
473
473
  }
474
+ dispose() {
475
+ super.dispose(), this._loadedUnitId$.complete(), this._errorMsg$.complete(), this._activeFilterModel$.complete(), this._filterModels.forEach((t) => {
476
+ t.forEach((e) => e.dispose()), t.clear();
477
+ }), this._filterModels.clear();
478
+ }
474
479
  _initModel() {
475
480
  this._resourcesManagerService.registerPluginResource({
476
481
  pluginName: Ne,
477
482
  businesses: [D.UNIVER_SHEET],
478
- toJson: (r) => this._serializeAutoFiltersForUnit(r),
479
- parseJson: (r) => JSON.parse(r),
480
- onLoad: (r, e) => {
481
- this._deserializeAutoFiltersForUnit(r, e), this._loadedUnitId$.next(r), this._updateActiveFilterModel();
483
+ toJson: (t) => this._serializeAutoFiltersForUnit(t),
484
+ parseJson: (t) => JSON.parse(t),
485
+ onLoad: (t, e) => {
486
+ this._deserializeAutoFiltersForUnit(t, e), this._loadedUnitId$.next(t), this._updateActiveFilterModel();
482
487
  },
483
- onUnLoad: (r) => {
484
- const e = this._filterModels.get(r);
485
- e && (e.forEach((t) => t.dispose()), this._filterModels.delete(r));
488
+ onUnLoad: (t) => {
489
+ const e = this._filterModels.get(t);
490
+ e && (e.forEach((r) => r.dispose()), this._filterModels.delete(t));
486
491
  }
487
492
  });
488
493
  }
489
- _cacheFilterModel(r, e, t) {
490
- this._filterModels.has(r) || this._filterModels.set(r, /* @__PURE__ */ new Map()), this._filterModels.get(r).set(e, t);
494
+ _cacheFilterModel(t, e, r) {
495
+ this._filterModels.has(t) || this._filterModels.set(t, /* @__PURE__ */ new Map()), this._filterModels.get(t).set(e, r);
491
496
  }
492
497
  };
493
498
  M = Dt([
@@ -498,42 +503,42 @@ M = Dt([
498
503
  const R = {
499
504
  id: Fe,
500
505
  type: O.MUTATION,
501
- handler: (i, r) => {
502
- const { subUnitId: e, unitId: t, range: n } = r;
503
- return i.get(M).ensureFilterModel(t, e).setRange(n), !0;
506
+ handler: (i, t) => {
507
+ const { subUnitId: e, unitId: r, range: n } = t;
508
+ return i.get(M).ensureFilterModel(r, e).setRange(n), !0;
504
509
  }
505
510
  }, p = {
506
511
  id: we,
507
512
  type: O.MUTATION,
508
- handler: (i, r) => {
509
- const { subUnitId: e, unitId: t, criteria: n, col: s, reCalc: o = !0 } = r, a = i.get(M).getFilterModel(t, e);
513
+ handler: (i, t) => {
514
+ const { subUnitId: e, unitId: r, criteria: n, col: s, reCalc: o = !0 } = t, a = i.get(M).getFilterModel(r, e);
510
515
  return a ? (a.setCriteria(s, n, o), !0) : !1;
511
516
  }
512
517
  }, y = {
513
518
  id: ve,
514
519
  type: O.MUTATION,
515
- handler: (i, r) => {
516
- const { unitId: e, subUnitId: t } = r;
517
- return i.get(M).removeFilterModel(e, t);
520
+ handler: (i, t) => {
521
+ const { unitId: e, subUnitId: r } = t;
522
+ return i.get(M).removeFilterModel(e, r);
518
523
  }
519
524
  }, B = {
520
525
  id: Me,
521
526
  type: O.MUTATION,
522
- handler: (i, r) => {
523
- const { unitId: e, subUnitId: t } = r, s = i.get(M).getFilterModel(e, t);
527
+ handler: (i, t) => {
528
+ const { unitId: e, subUnitId: r } = t, s = i.get(M).getFilterModel(e, r);
524
529
  return s ? (s.reCalc(), !0) : !1;
525
530
  }
526
531
  }, Bt = {
527
532
  id: "sheet.command.set-filter-range",
528
533
  type: O.COMMAND,
529
- handler: (i, r) => {
530
- const e = i.get(M), t = i.get(N), n = i.get(J), s = i.get(T), { unitId: o, subUnitId: l, range: a } = r;
531
- if (!H(s, r) || e.getFilterModel(o, l)) return !1;
534
+ handler: (i, t) => {
535
+ const e = i.get(M), r = i.get(N), n = i.get(J), s = i.get(T), { unitId: o, subUnitId: l, range: a } = t;
536
+ if (!H(s, t) || e.getFilterModel(o, l)) return !1;
532
537
  if (a.endRow === a.startRow) {
533
538
  const g = i.get(Be), _ = i.get(ze);
534
539
  return g.emit(_.t("sheets-filter.command.not-valid-filter-range")), !1;
535
540
  }
536
- const d = { id: R.id, params: { unitId: o, subUnitId: l, range: a } }, h = t.syncExecuteCommand(d.id, d.params);
541
+ const d = { id: R.id, params: { unitId: o, subUnitId: l, range: a } }, h = r.syncExecuteCommand(d.id, d.params);
537
542
  return h && n.pushUndoRedo({
538
543
  unitID: o,
539
544
  undoMutations: [{ id: y.id, params: { unitId: o, subUnitId: l } }],
@@ -543,10 +548,10 @@ const R = {
543
548
  }, zt = {
544
549
  id: "sheet.command.remove-sheet-filter",
545
550
  type: O.COMMAND,
546
- handler: (i, r) => {
547
- const e = i.get(T), t = i.get(M), n = i.get(N), s = i.get(J), o = H(e, r);
551
+ handler: (i, t) => {
552
+ const e = i.get(T), r = i.get(M), n = i.get(N), s = i.get(J), o = H(e, t);
548
553
  if (!o) return !1;
549
- const { unitId: l, subUnitId: a } = o, c = t.getFilterModel(l, a);
554
+ const { unitId: l, subUnitId: a } = o, c = r.getFilterModel(l, a);
550
555
  if (!c) return !1;
551
556
  const u = c == null ? void 0 : c.serialize(), d = Ht(l, a, u), h = n.syncExecuteCommand(y.id, { unitId: l, subUnitId: a });
552
557
  return h && s.pushUndoRedo({
@@ -559,15 +564,15 @@ const R = {
559
564
  id: "sheet.command.smart-toggle-filter",
560
565
  type: O.COMMAND,
561
566
  handler: async (i) => {
562
- const r = i.get(T), e = i.get(M), t = i.get(N), n = r.getCurrentUnitForType(D.UNIVER_SHEET), s = n == null ? void 0 : n.getActiveSheet();
567
+ const t = i.get(T), e = i.get(M), r = i.get(N), n = t.getCurrentUnitForType(D.UNIVER_SHEET), s = n == null ? void 0 : n.getActiveSheet();
563
568
  if (!s || !n) return !1;
564
569
  const o = n.getUnitId(), l = s.getSheetId();
565
570
  if (e.getFilterModel(o, l))
566
- return t.executeCommand(zt.id, { unitId: o, subUnitId: l });
571
+ return r.executeCommand(zt.id, { unitId: o, subUnitId: l });
567
572
  const u = i.get(qe).getCurrentLastSelection();
568
573
  if (!u) return !1;
569
574
  const d = u.range, h = Ge(u) ? Ce(d, { left: !0, right: !0, up: !0, down: !0 }, s) : d;
570
- return t.executeCommand(Bt.id, {
575
+ return r.executeCommand(Bt.id, {
571
576
  unitId: o,
572
577
  subUnitId: l,
573
578
  range: h
@@ -576,8 +581,8 @@ const R = {
576
581
  }, cr = {
577
582
  id: "sheet.command.set-filter-criteria",
578
583
  type: O.COMMAND,
579
- handler: (i, r) => {
580
- const e = i.get(M), t = i.get(N), n = i.get(J), { unitId: s, subUnitId: o, col: l, criteria: a } = r, c = e.getFilterModel(s, o);
584
+ handler: (i, t) => {
585
+ const e = i.get(M), r = i.get(N), n = i.get(J), { unitId: s, subUnitId: o, col: l, criteria: a } = t, c = e.getFilterModel(s, o);
581
586
  if (!c) return !1;
582
587
  const u = c.getRange();
583
588
  if (!u || l < u.startColumn || l > u.endColumn) return !1;
@@ -589,7 +594,7 @@ const R = {
589
594
  col: l,
590
595
  criteria: a
591
596
  }
592
- }, _ = t.syncExecuteCommand(g.id, g.params);
597
+ }, _ = r.syncExecuteCommand(g.id, g.params);
593
598
  return _ && n.pushUndoRedo({
594
599
  unitID: s,
595
600
  undoMutations: [h],
@@ -599,13 +604,13 @@ const R = {
599
604
  }, dr = {
600
605
  id: "sheet.command.clear-filter-criteria",
601
606
  type: O.COMMAND,
602
- handler: (i, r) => {
603
- const e = i.get(M), t = i.get(J), n = i.get(N), s = i.get(T), o = H(s, r);
607
+ handler: (i, t) => {
608
+ const e = i.get(M), r = i.get(J), n = i.get(N), s = i.get(T), o = H(s, t);
604
609
  if (!o) return !1;
605
610
  const { unitId: l, subUnitId: a } = o, c = e.getFilterModel(o.unitId, o.subUnitId);
606
611
  if (!c) return !1;
607
612
  const u = c.serialize(), d = Te(l, a, u), h = Vt(l, a, u);
608
- return j(h, n).result ? (t.pushUndoRedo({
613
+ return j(h, n).result ? (r.pushUndoRedo({
609
614
  unitID: l,
610
615
  undoMutations: d,
611
616
  redoMutations: h
@@ -614,108 +619,108 @@ const R = {
614
619
  }, ur = {
615
620
  id: "sheet.command.re-calc-filter",
616
621
  type: O.COMMAND,
617
- handler: (i, r) => {
618
- const e = i.get(M), t = i.get(N), n = i.get(T), s = H(n, r);
622
+ handler: (i, t) => {
623
+ const e = i.get(M), r = i.get(N), n = i.get(T), s = H(n, t);
619
624
  if (!s) return !1;
620
625
  const { unitId: o, subUnitId: l } = s;
621
- return e.getFilterModel(s.unitId, s.subUnitId) ? t.executeCommand(B.id, { unitId: o, subUnitId: l }) : !1;
626
+ return e.getFilterModel(s.unitId, s.subUnitId) ? r.executeCommand(B.id, { unitId: o, subUnitId: l }) : !1;
622
627
  }
623
628
  };
624
- function Ht(i, r, e) {
625
- const t = [], n = {
629
+ function Ht(i, t, e) {
630
+ const r = [], n = {
626
631
  id: R.id,
627
632
  params: {
628
633
  unitId: i,
629
- subUnitId: r,
634
+ subUnitId: t,
630
635
  range: e.ref
631
636
  }
632
637
  };
633
- return t.push(n), Te(i, r, e).forEach((o) => t.push(o)), t;
638
+ return r.push(n), Te(i, t, e).forEach((o) => r.push(o)), r;
634
639
  }
635
- function Te(i, r, e) {
640
+ function Te(i, t, e) {
636
641
  var n;
637
- const t = [];
642
+ const r = [];
638
643
  return (n = e.filterColumns) == null || n.forEach((s) => {
639
644
  const o = {
640
645
  id: p.id,
641
646
  params: {
642
647
  unitId: i,
643
- subUnitId: r,
648
+ subUnitId: t,
644
649
  col: s.colId,
645
650
  criteria: s
646
651
  }
647
652
  };
648
- t.push(o);
649
- }), t;
653
+ r.push(o);
654
+ }), r;
650
655
  }
651
- function Vt(i, r, e) {
656
+ function Vt(i, t, e) {
652
657
  var n;
653
- const t = [];
658
+ const r = [];
654
659
  return (n = e.filterColumns) == null || n.forEach((s) => {
655
660
  const o = {
656
661
  id: p.id,
657
662
  params: {
658
663
  unitId: i,
659
- subUnitId: r,
664
+ subUnitId: t,
660
665
  col: s.colId,
661
666
  criteria: null
662
667
  }
663
668
  };
664
- t.push(o);
665
- }), t;
669
+ r.push(o);
670
+ }), r;
666
671
  }
667
- function Wt(i, r, e, t) {
668
- if (!t)
672
+ function Wt(i, t, e, r) {
673
+ if (!r)
669
674
  return {
670
675
  id: p.id,
671
676
  params: {
672
677
  unitId: i,
673
- subUnitId: r,
678
+ subUnitId: t,
674
679
  col: e,
675
680
  criteria: null
676
681
  }
677
682
  };
678
- const n = t.serialize();
683
+ const n = r.serialize();
679
684
  return {
680
685
  id: p.id,
681
686
  params: {
682
687
  unitId: i,
683
- subUnitId: r,
688
+ subUnitId: t,
684
689
  col: e,
685
690
  criteria: n
686
691
  }
687
692
  };
688
693
  }
689
694
  const Ie = "sheets-filter.config", ue = {};
690
- function jt(i, r) {
695
+ function jt(i, t) {
691
696
  for (let e = 0; e < i.length; e++) {
692
- let t = e;
697
+ let r = e;
693
698
  if (i[e])
694
699
  for (let n = e + 1; n < i.length; n++)
695
- i[t] && i[n] && r(i[t], i[n]) && (i[t] = null, t = n);
700
+ i[r] && i[n] && t(i[r], i[n]) && (i[r] = null, r = n);
696
701
  }
697
702
  return i.filter((e) => e !== null);
698
703
  }
699
704
  function L(i) {
700
- return jt(i, (r, e) => r.id === p.id && e.id === p.id && r.params.unitId === e.params.unitId && r.params.subUnitId === e.params.subUnitId && r.params.col === e.params.col);
705
+ return jt(i, (t, e) => t.id === p.id && e.id === p.id && t.params.unitId === e.params.unitId && t.params.subUnitId === e.params.subUnitId && t.params.col === e.params.col);
701
706
  }
702
- var kt = Object.getOwnPropertyDescriptor, qt = (i, r, e, t) => {
703
- for (var n = t > 1 ? void 0 : t ? kt(r, e) : r, s = i.length - 1, o; s >= 0; s--)
707
+ var kt = Object.getOwnPropertyDescriptor, qt = (i, t, e, r) => {
708
+ for (var n = r > 1 ? void 0 : r ? kt(t, e) : t, s = i.length - 1, o; s >= 0; s--)
704
709
  (o = i[s]) && (n = o(n) || n);
705
710
  return n;
706
- }, x = (i, r) => (e, t) => r(e, t, i);
711
+ }, x = (i, t) => (e, r) => t(e, r, i);
707
712
  let z = class extends U {
708
- constructor(r, e, t, n, s, o, l) {
713
+ constructor(t, e, r, n, s, o, l) {
709
714
  super();
710
715
  C(this, "_disposableCollection", new ge());
711
- this._commandService = r, this._sheetInterceptorService = e, this._sheetsFilterService = t, this._univerInstanceService = n, this._refRangeService = s, this._dataSyncPrimaryController = o, this._zebraCrossingCacheController = l, this._initCommands(), this._initRowFilteredInterceptor(), this._initInterceptors(), this._commandExecutedListener(), this._initErrorHandling(), this._initZebraCrossingCacheListener();
716
+ this._commandService = t, this._sheetInterceptorService = e, this._sheetsFilterService = r, this._univerInstanceService = n, this._refRangeService = s, this._dataSyncPrimaryController = o, this._zebraCrossingCacheController = l, this._initCommands(), this._initRowFilteredInterceptor(), this._initInterceptors(), this._commandExecutedListener(), this._initErrorHandling(), this._initZebraCrossingCacheListener();
712
717
  }
713
718
  _initZebraCrossingCacheListener() {
714
719
  this.disposeWithMe(
715
- this._sheetsFilterService.activeFilterModel$.subscribe((r) => {
716
- r && this.disposeWithMe(
717
- r.filteredOutRows$.subscribe(() => {
718
- this._zebraCrossingCacheController.updateZebraCrossingCache(r.unitId, r.subUnitId);
720
+ this._sheetsFilterService.activeFilterModel$.subscribe((t) => {
721
+ t && this.disposeWithMe(
722
+ t.filteredOutRows$.subscribe(() => {
723
+ this._zebraCrossingCacheController.updateZebraCrossingCache(t.unitId, t.subUnitId);
719
724
  })
720
725
  );
721
726
  })
@@ -727,86 +732,86 @@ let z = class extends U {
727
732
  R,
728
733
  B,
729
734
  y
730
- ].forEach((r) => {
735
+ ].forEach((t) => {
731
736
  var e;
732
- this.disposeWithMe(this._commandService.registerCommand(r)), (e = this._dataSyncPrimaryController) == null || e.registerSyncingMutations(r);
737
+ this.disposeWithMe(this._commandService.registerCommand(t)), (e = this._dataSyncPrimaryController) == null || e.registerSyncingMutations(t);
733
738
  });
734
739
  }
735
740
  _initInterceptors() {
736
741
  this.disposeWithMe(this._sheetInterceptorService.interceptCommand({
737
- getMutations: (r) => this._getUpdateFilter(r)
738
- })), this.disposeWithMe(this._commandService.onCommandExecuted((r) => {
739
- if (r.id === Ke.id) {
740
- const e = r.params, t = e.subUnitId, n = e.unitId;
741
- if (!t || !n)
742
+ getMutations: (t) => this._getUpdateFilter(t)
743
+ })), this.disposeWithMe(this._commandService.onCommandExecuted((t) => {
744
+ if (t.id === Ke.id) {
745
+ const e = t.params, r = e.subUnitId, n = e.unitId;
746
+ if (!r || !n)
742
747
  return;
743
- this._registerRefRange(n, t);
748
+ this._registerRefRange(n, r);
744
749
  }
745
- if (r.id === R.id) {
746
- const e = r.params, t = e.subUnitId, n = e.unitId;
747
- if (!t || !n)
750
+ if (t.id === R.id) {
751
+ const e = t.params, r = e.subUnitId, n = e.unitId;
752
+ if (!r || !n)
748
753
  return;
749
754
  this._registerRefRange(e.unitId, e.subUnitId);
750
755
  }
751
- })), this.disposeWithMe(this._sheetsFilterService.loadedUnitId$.subscribe((r) => {
752
- if (r) {
753
- const e = this._univerInstanceService.getUniverSheetInstance(r), t = e == null ? void 0 : e.getActiveSheet();
754
- t && this._registerRefRange(r, t.getSheetId());
756
+ })), this.disposeWithMe(this._sheetsFilterService.loadedUnitId$.subscribe((t) => {
757
+ if (t) {
758
+ const e = this._univerInstanceService.getUniverSheetInstance(t), r = e == null ? void 0 : e.getActiveSheet();
759
+ r && this._registerRefRange(t, r.getSheetId());
755
760
  }
756
761
  }));
757
762
  }
758
- _registerRefRange(r, e) {
763
+ _registerRefRange(t, e) {
759
764
  var l;
760
765
  this._disposableCollection.dispose();
761
- const t = this._univerInstanceService.getUniverSheetInstance(r), n = t == null ? void 0 : t.getSheetBySheetId(e);
762
- if (!t || !n) return;
763
- const s = (l = this._sheetsFilterService.getFilterModel(r, e)) == null ? void 0 : l.getRange(), o = (a) => {
766
+ const r = this._univerInstanceService.getUniverSheetInstance(t), n = r == null ? void 0 : r.getSheetBySheetId(e);
767
+ if (!r || !n) return;
768
+ const s = (l = this._sheetsFilterService.getFilterModel(t, e)) == null ? void 0 : l.getRange(), o = (a) => {
764
769
  switch (a.id) {
765
770
  case ct.id: {
766
- const c = a.params, u = c.unitId || r, d = c.subUnitId || e;
771
+ const c = a.params, u = c.unitId || t, d = c.subUnitId || e;
767
772
  return this._handleInsertRowCommand(c, u, d);
768
773
  }
769
774
  case at.id: {
770
- const c = a.params, u = c.unitId || r, d = c.subUnitId || e;
775
+ const c = a.params, u = c.unitId || t, d = c.subUnitId || e;
771
776
  return this.handleInsertColCommand(c.range, u, d);
772
777
  }
773
778
  case lt.id: {
774
779
  const c = a.params;
775
- return this.handleRemoveColCommand(c.range, r, e);
780
+ return this.handleRemoveColCommand(c.range, t, e);
776
781
  }
777
782
  case ot.id: {
778
783
  const c = a.params;
779
- return this._handleRemoveRowCommand(c, r, e);
784
+ return this._handleRemoveRowCommand(c, t, e);
780
785
  }
781
786
  case le.MoveColsCommandId: {
782
787
  const c = a.params;
783
788
  return this.handleMoveColsCommand({
784
789
  fromRange: c.fromRange,
785
790
  toRange: c.toRange
786
- }, r, e);
791
+ }, t, e);
787
792
  }
788
793
  case le.MoveRowsCommandId: {
789
794
  const c = a.params;
790
- return this._handleMoveRowsCommand(c, r, e);
795
+ return this._handleMoveRowsCommand(c, t, e);
791
796
  }
792
797
  case st.id: {
793
798
  const c = a.params;
794
- return this._handleMoveRangeCommand(c, r, e);
799
+ return this._handleMoveRangeCommand(c, t, e);
795
800
  }
796
801
  }
797
802
  return { redos: [], undos: [] };
798
803
  };
799
- s && this._disposableCollection.add(this._refRangeService.registerRefRange(s, o, r, e));
804
+ s && this._disposableCollection.add(this._refRangeService.registerRefRange(s, o, t, e));
800
805
  }
801
- _getUpdateFilter(r) {
802
- const { id: e } = r;
806
+ _getUpdateFilter(t) {
807
+ const { id: e } = t;
803
808
  switch (e) {
804
809
  case Xe.id: {
805
- const t = r.params;
806
- return this._handleRemoveSheetCommand(t, t.unitId, t.subUnitId);
810
+ const r = t.params;
811
+ return this._handleRemoveSheetCommand(r, r.unitId, r.subUnitId);
807
812
  }
808
813
  case Ye.id: {
809
- const t = r.params, { targetSubUnitId: n, unitId: s, subUnitId: o } = t;
814
+ const r = t.params, { targetSubUnitId: n, unitId: s, subUnitId: o } = r;
810
815
  return !s || !o || !n ? this._handleNull() : this._handleCopySheetCommand(s, o, n);
811
816
  }
812
817
  }
@@ -815,17 +820,17 @@ let z = class extends U {
815
820
  undos: []
816
821
  };
817
822
  }
818
- handleInsertColCommand(r, e, t) {
823
+ handleInsertColCommand(t, e, r) {
819
824
  var f;
820
- const n = this._sheetsFilterService.getFilterModel(e, t), s = (f = n == null ? void 0 : n.getRange()) != null ? f : null;
825
+ const n = this._sheetsFilterService.getFilterModel(e, r), s = (f = n == null ? void 0 : n.getRange()) != null ? f : null;
821
826
  if (!n || !s)
822
827
  return this._handleNull();
823
- const { startColumn: o, endColumn: l } = s, { startColumn: a, endColumn: c } = r, u = c - a + 1;
828
+ const { startColumn: o, endColumn: l } = s, { startColumn: a, endColumn: c } = t, u = c - a + 1;
824
829
  if (c > l)
825
830
  return this._handleNull();
826
831
  const d = [], h = [], g = a, _ = {
827
832
  unitId: e,
828
- subUnitId: t,
833
+ subUnitId: r,
829
834
  range: {
830
835
  ...s,
831
836
  startColumn: a <= o ? o + u : o,
@@ -833,28 +838,28 @@ let z = class extends U {
833
838
  }
834
839
  }, S = {
835
840
  unitId: e,
836
- subUnitId: t,
841
+ subUnitId: r,
837
842
  range: s
838
843
  };
839
844
  d.push({ id: R.id, params: _ }), h.push({ id: R.id, params: S });
840
845
  const F = n.getAllFilterColumns().filter((m) => m[0] >= g);
841
846
  if (F.length !== 0) {
842
- const { newRange: m, oldRange: v } = this._moveCriteria(e, t, F, u);
847
+ const { newRange: m, oldRange: v } = this._moveCriteria(e, r, F, u);
843
848
  d.push(...v.redos, ...m.redos), h.push(...m.undos, ...v.undos);
844
849
  }
845
850
  return { redos: L(d), undos: L(h) };
846
851
  }
847
- _handleInsertRowCommand(r, e, t) {
852
+ _handleInsertRowCommand(t, e, r) {
848
853
  var S;
849
- const n = this._sheetsFilterService.getFilterModel(e, t), s = (S = n == null ? void 0 : n.getRange()) != null ? S : null;
854
+ const n = this._sheetsFilterService.getFilterModel(e, r), s = (S = n == null ? void 0 : n.getRange()) != null ? S : null;
850
855
  if (!n || !s)
851
856
  return this._handleNull();
852
- const { startRow: o, endRow: l } = s, { startRow: a, endRow: c } = r.range, u = c - a + 1;
857
+ const { startRow: o, endRow: l } = s, { startRow: a, endRow: c } = t.range, u = c - a + 1;
853
858
  if (c > l)
854
859
  return this._handleNull();
855
860
  const d = [], h = [], g = {
856
861
  unitId: e,
857
- subUnitId: t,
862
+ subUnitId: r,
858
863
  range: {
859
864
  ...s,
860
865
  startRow: a <= o ? o + u : o,
@@ -862,7 +867,7 @@ let z = class extends U {
862
867
  }
863
868
  }, _ = {
864
869
  unitId: e,
865
- subUnitId: t,
870
+ subUnitId: r,
866
871
  range: s
867
872
  };
868
873
  return d.push({ id: R.id, params: g }), h.push({ id: R.id, params: _ }), {
@@ -870,18 +875,18 @@ let z = class extends U {
870
875
  undos: L(h)
871
876
  };
872
877
  }
873
- handleRemoveColCommand(r, e, t) {
878
+ handleRemoveColCommand(t, e, r) {
874
879
  var F;
875
- const n = this._sheetsFilterService.getFilterModel(e, t), s = (F = n == null ? void 0 : n.getRange()) != null ? F : null;
880
+ const n = this._sheetsFilterService.getFilterModel(e, r), s = (F = n == null ? void 0 : n.getRange()) != null ? F : null;
876
881
  if (!n || !s)
877
882
  return this._handleNull();
878
- const { startColumn: o, endColumn: l } = s, { startColumn: a, endColumn: c } = r;
883
+ const { startColumn: o, endColumn: l } = s, { startColumn: a, endColumn: c } = t;
879
884
  if (a > l)
880
885
  return this._handleNull();
881
886
  const u = [], d = [], h = c < o ? 0 : Math.min(c, l) - Math.max(a, o) + 1, g = c - a + 1, _ = n.getAllFilterColumns();
882
887
  _.forEach((f) => {
883
888
  const [m, v] = f;
884
- m <= c && m >= a && (u.push({ id: p.id, params: { unitId: e, subUnitId: t, col: m, criteria: null } }), d.push({ id: p.id, params: { unitId: e, subUnitId: t, col: m, criteria: { ...v.serialize(), colId: m } } }));
889
+ m <= c && m >= a && (u.push({ id: p.id, params: { unitId: e, subUnitId: r, col: m, criteria: null } }), d.push({ id: p.id, params: { unitId: e, subUnitId: r, col: m, criteria: { ...v.serialize(), colId: m } } }));
885
890
  });
886
891
  const S = _.filter((f) => {
887
892
  const [m, v] = f;
@@ -889,39 +894,39 @@ let z = class extends U {
889
894
  });
890
895
  let w = { undos: [], redos: [] };
891
896
  if (S.length > 0) {
892
- const { oldRange: f, newRange: m } = this._moveCriteria(e, t, S, -g);
897
+ const { oldRange: f, newRange: m } = this._moveCriteria(e, r, S, -g);
893
898
  w = m, u.push(...f.redos), d.unshift(...f.undos);
894
899
  }
895
900
  if (h === l - o + 1) {
896
901
  const f = {
897
902
  unitId: e,
898
- subUnitId: t
903
+ subUnitId: r
899
904
  };
900
- u.push({ id: y.id, params: f }), d.unshift({ id: R.id, params: { range: s, unitId: e, subUnitId: t } });
905
+ u.push({ id: y.id, params: f }), d.unshift({ id: R.id, params: { range: s, unitId: e, subUnitId: r } });
901
906
  } else {
902
907
  const f = o <= a ? o : h === 0 ? o - g : a, m = o <= a ? l - h : l - g, v = {
903
908
  unitId: e,
904
- subUnitId: t,
909
+ subUnitId: r,
905
910
  range: { ...s, startColumn: f, endColumn: m }
906
911
  };
907
- u.push({ id: R.id, params: v }), d.unshift({ id: R.id, params: { range: s, unitId: e, subUnitId: t } }), u.push(...w.redos), d.unshift(...w.undos);
912
+ u.push({ id: R.id, params: v }), d.unshift({ id: R.id, params: { range: s, unitId: e, subUnitId: r } }), u.push(...w.redos), d.unshift(...w.undos);
908
913
  }
909
914
  return {
910
915
  undos: d,
911
916
  redos: u
912
917
  };
913
918
  }
914
- _handleRemoveRowCommand(r, e, t) {
919
+ _handleRemoveRowCommand(t, e, r) {
915
920
  var S;
916
- const n = this._sheetsFilterService.getFilterModel(e, t);
921
+ const n = this._sheetsFilterService.getFilterModel(e, r);
917
922
  if (!n)
918
923
  return this._handleNull();
919
- const s = n.getRange(), { startRow: o, endRow: l } = s, { startRow: a, endRow: c } = r.range;
924
+ const s = n.getRange(), { startRow: o, endRow: l } = s, { startRow: a, endRow: c } = t.range;
920
925
  if (a > l)
921
926
  return this._handleNull();
922
927
  if (c < o)
923
928
  return {
924
- undos: [{ id: R.id, params: { range: s, unitId: e, subUnitId: t } }],
929
+ undos: [{ id: R.id, params: { range: s, unitId: e, subUnitId: r } }],
925
930
  redos: [{
926
931
  id: R.id,
927
932
  params: {
@@ -931,29 +936,29 @@ let z = class extends U {
931
936
  endRow: l - (c - a + 1)
932
937
  },
933
938
  unitId: e,
934
- subUnitId: t
939
+ subUnitId: r
935
940
  }
936
941
  }]
937
942
  };
938
943
  const u = [], d = [], h = n.getAllFilterColumns(), g = o <= c && o >= a;
939
- d.push({ id: R.id, params: { range: s, unitId: e, subUnitId: t } });
944
+ d.push({ id: R.id, params: { range: s, unitId: e, subUnitId: r } });
940
945
  const _ = Math.min(c, l) - Math.max(a, o) + 1;
941
946
  if (_ === l - o + 1 || g) {
942
947
  const w = {
943
948
  unitId: e,
944
- subUnitId: t
949
+ subUnitId: r
945
950
  };
946
951
  u.push({ id: y.id, params: w }), h.forEach((F) => {
947
952
  const [f, m] = F, v = {
948
953
  unitId: e,
949
- subUnitId: t,
954
+ subUnitId: r,
950
955
  col: f,
951
956
  criteria: { ...m.serialize(), colId: f }
952
957
  };
953
958
  d.push({ id: p.id, params: v });
954
959
  });
955
960
  } else {
956
- const w = (S = this._univerInstanceService.getUniverSheetInstance(e)) == null ? void 0 : S.getSheetBySheetId(t);
961
+ const w = (S = this._univerInstanceService.getUniverSheetInstance(e)) == null ? void 0 : S.getSheetBySheetId(r);
957
962
  if (!w)
958
963
  return this._handleNull();
959
964
  const F = [];
@@ -961,7 +966,7 @@ let z = class extends U {
961
966
  w.getRowFiltered(E) && F.push(E);
962
967
  const f = Math.min(o, a), m = f + (l - o) - _ + F.length, v = {
963
968
  unitId: e,
964
- subUnitId: t,
969
+ subUnitId: r,
965
970
  range: {
966
971
  ...s,
967
972
  startRow: f,
@@ -976,13 +981,13 @@ let z = class extends U {
976
981
  };
977
982
  }
978
983
  // eslint-disable-next-line max-lines-per-function
979
- handleMoveColsCommand({ fromRange: r, toRange: e }, t, n) {
984
+ handleMoveColsCommand({ fromRange: t, toRange: e }, r, n) {
980
985
  var F;
981
- const s = this._sheetsFilterService.getFilterModel(t, n), o = (F = s == null ? void 0 : s.getRange()) != null ? F : null;
986
+ const s = this._sheetsFilterService.getFilterModel(r, n), o = (F = s == null ? void 0 : s.getRange()) != null ? F : null;
982
987
  if (!s || !o)
983
988
  return this._handleNull();
984
989
  const { startColumn: l, endColumn: a } = o;
985
- if (r.endColumn < l && e.startColumn <= l || r.startColumn > a && e.endColumn > a)
990
+ if (t.endColumn < l && e.startColumn <= l || t.startColumn > a && e.endColumn > a)
986
991
  return this._handleNull();
987
992
  const c = [], u = [], d = {};
988
993
  for (let f = l; f <= a; f++)
@@ -990,9 +995,9 @@ let z = class extends U {
990
995
  colIndex: f,
991
996
  filter: s.getFilterColumn(f)
992
997
  };
993
- oe(r.startColumn, r.endColumn - r.startColumn + 1, e.startColumn, d);
998
+ oe(t.startColumn, t.endColumn - t.startColumn + 1, e.startColumn, d);
994
999
  let h = o.startColumn, g = o.endColumn;
995
- l >= r.startColumn && l <= r.endColumn && e.startColumn > r.startColumn && r.endColumn < a && (h = r.endColumn + 1), a >= r.startColumn && a <= r.endColumn && e.startColumn < r.startColumn && r.startColumn > l && (g = r.startColumn - 1);
1000
+ l >= t.startColumn && l <= t.endColumn && e.startColumn > t.startColumn && t.endColumn < a && (h = t.endColumn + 1), a >= t.startColumn && a <= t.endColumn && e.startColumn < t.startColumn && t.startColumn > l && (g = t.startColumn - 1);
996
1001
  const _ = Object.keys(d).map((f) => Number(f)), S = _.find((f) => d[f].colIndex === g), w = _.find((f) => d[f].colIndex === h);
997
1002
  if (_.forEach((f) => {
998
1003
  var re, ne;
@@ -1000,12 +1005,12 @@ let z = class extends U {
1000
1005
  if (v) {
1001
1006
  if (E >= w && E <= S) {
1002
1007
  const Z = {
1003
- unitId: t,
1008
+ unitId: r,
1004
1009
  subUnitId: n,
1005
1010
  col: E,
1006
1011
  criteria: { ...v.serialize(), colId: E }
1007
1012
  }, xe = {
1008
- unitId: t,
1013
+ unitId: r,
1009
1014
  subUnitId: n,
1010
1015
  col: E,
1011
1016
  criteria: s.getFilterColumn(E) ? { ...(re = s.getFilterColumn(E)) == null ? void 0 : re.serialize(), colId: E } : null
@@ -1014,17 +1019,17 @@ let z = class extends U {
1014
1019
  }
1015
1020
  if (!((ne = d[m]) != null && ne.filter)) {
1016
1021
  const Z = {
1017
- unitId: t,
1022
+ unitId: r,
1018
1023
  subUnitId: n,
1019
1024
  col: m,
1020
1025
  criteria: null
1021
1026
  };
1022
- c.push({ id: p.id, params: Z }), u.push({ id: p.id, params: { unitId: t, subUnitId: n, col: m, criteria: { ...v.serialize(), colId: m } } });
1027
+ c.push({ id: p.id, params: Z }), u.push({ id: p.id, params: { unitId: r, subUnitId: n, col: m, criteria: { ...v.serialize(), colId: m } } });
1023
1028
  }
1024
1029
  }
1025
1030
  }), l !== w || a !== S) {
1026
1031
  const f = {
1027
- unitId: t,
1032
+ unitId: r,
1028
1033
  subUnitId: n,
1029
1034
  range: {
1030
1035
  ...o,
@@ -1032,19 +1037,19 @@ let z = class extends U {
1032
1037
  endColumn: S
1033
1038
  }
1034
1039
  };
1035
- c.unshift({ id: R.id, params: f }), u.unshift({ id: R.id, params: { range: o, unitId: t, subUnitId: n } });
1040
+ c.unshift({ id: R.id, params: f }), u.unshift({ id: R.id, params: { range: o, unitId: r, subUnitId: n } });
1036
1041
  }
1037
1042
  return {
1038
1043
  undos: u,
1039
1044
  redos: c
1040
1045
  };
1041
1046
  }
1042
- _handleMoveRowsCommand(r, e, t) {
1047
+ _handleMoveRowsCommand(t, e, r) {
1043
1048
  var f;
1044
- const n = this._sheetsFilterService.getFilterModel(e, t), s = (f = n == null ? void 0 : n.getRange()) != null ? f : null;
1049
+ const n = this._sheetsFilterService.getFilterModel(e, r), s = (f = n == null ? void 0 : n.getRange()) != null ? f : null;
1045
1050
  if (!n || !s)
1046
1051
  return this._handleNull();
1047
- const { startRow: o, endRow: l } = s, { fromRange: a, toRange: c } = r;
1052
+ const { startRow: o, endRow: l } = s, { fromRange: a, toRange: c } = t;
1048
1053
  if (a.endRow < o && c.startRow <= o || a.startRow > l && c.endRow > l)
1049
1054
  return this._handleNull();
1050
1055
  const u = [], d = [], h = {};
@@ -1059,22 +1064,22 @@ let z = class extends U {
1059
1064
  if (o !== F || l !== w) {
1060
1065
  const m = {
1061
1066
  unitId: e,
1062
- subUnitId: t,
1067
+ subUnitId: r,
1063
1068
  range: {
1064
1069
  ...s,
1065
1070
  startRow: F,
1066
1071
  endRow: w
1067
1072
  }
1068
1073
  };
1069
- u.push({ id: R.id, params: m }, { id: B.id, params: { unitId: e, subUnitId: t } }), d.push({ id: R.id, params: { range: s, unitId: e, subUnitId: t } }, { id: B.id, params: { unitId: e, subUnitId: t } });
1074
+ u.push({ id: R.id, params: m }, { id: B.id, params: { unitId: e, subUnitId: r } }), d.push({ id: R.id, params: { range: s, unitId: e, subUnitId: r } }, { id: B.id, params: { unitId: e, subUnitId: r } });
1070
1075
  }
1071
1076
  return {
1072
1077
  redos: u,
1073
1078
  undos: d
1074
1079
  };
1075
1080
  }
1076
- _handleMoveRangeCommand(r, e, t) {
1077
- const { fromRange: n, toRange: s } = r, o = this._sheetsFilterService.getFilterModel(e, t);
1081
+ _handleMoveRangeCommand(t, e, r) {
1082
+ const { fromRange: n, toRange: s } = t, o = this._sheetsFilterService.getFilterModel(e, r);
1078
1083
  if (!o)
1079
1084
  return this._handleNull();
1080
1085
  const l = o.getRange();
@@ -1091,29 +1096,29 @@ let z = class extends U {
1091
1096
  id: y.id,
1092
1097
  params: {
1093
1098
  unitId: e,
1094
- subUnitId: t
1099
+ subUnitId: r
1095
1100
  }
1096
- }, _ = { id: R.id, params: { unitId: e, subUnitId: t, range: h } }, S = { id: R.id, params: { unitId: e, subUnitId: t, range: l } };
1101
+ }, _ = { id: R.id, params: { unitId: e, subUnitId: r, range: h } }, S = { id: R.id, params: { unitId: e, subUnitId: r, range: l } };
1097
1102
  a.push(g, _), c.push(g, S);
1098
1103
  const w = o.getAllFilterColumns(), F = s.startColumn - n.startColumn;
1099
1104
  w.forEach((f) => {
1100
1105
  const [m, v] = f;
1101
- v && (a.push({ id: p.id, params: { unitId: e, subUnitId: t, col: m + F, criteria: { ...v.serialize(), colId: m + F } } }), c.push({ id: p.id, params: { unitId: e, subUnitId: t, col: m, criteria: { ...v.serialize(), colId: m } } }));
1106
+ v && (a.push({ id: p.id, params: { unitId: e, subUnitId: r, col: m + F, criteria: { ...v.serialize(), colId: m + F } } }), c.push({ id: p.id, params: { unitId: e, subUnitId: r, col: m, criteria: { ...v.serialize(), colId: m } } }));
1102
1107
  });
1103
1108
  } else if (te.intersects(s, l)) {
1104
1109
  const u = {
1105
1110
  ...l,
1106
1111
  endRow: Math.max(l.endRow, s.endRow)
1107
1112
  };
1108
- a.push({ id: R.id, params: { unitId: e, subUnitId: t, range: u } }), c.push({ id: R.id, params: { unitId: e, subUnitId: t, range: l } });
1113
+ a.push({ id: R.id, params: { unitId: e, subUnitId: r, range: u } }), c.push({ id: R.id, params: { unitId: e, subUnitId: r, range: l } });
1109
1114
  }
1110
1115
  return {
1111
1116
  redos: a,
1112
1117
  undos: c
1113
1118
  };
1114
1119
  }
1115
- _handleRemoveSheetCommand(r, e, t) {
1116
- const n = this._sheetsFilterService.getFilterModel(e, t);
1120
+ _handleRemoveSheetCommand(t, e, r) {
1121
+ const n = this._sheetsFilterService.getFilterModel(e, r);
1117
1122
  if (!n)
1118
1123
  return this._handleNull();
1119
1124
  const s = n.getRange();
@@ -1121,14 +1126,14 @@ let z = class extends U {
1121
1126
  return this._handleNull();
1122
1127
  const o = [], l = [];
1123
1128
  return n.getAllFilterColumns().forEach(([c, u]) => {
1124
- l.push({ id: p.id, params: { unitId: e, subUnitId: t, col: c, criteria: { ...u.serialize(), colId: c } } });
1125
- }), o.push({ id: y.id, params: { unitId: e, subUnitId: t, range: s } }), l.unshift({ id: R.id, params: { range: s, unitId: e, subUnitId: t } }), {
1129
+ l.push({ id: p.id, params: { unitId: e, subUnitId: r, col: c, criteria: { ...u.serialize(), colId: c } } });
1130
+ }), o.push({ id: y.id, params: { unitId: e, subUnitId: r, range: s } }), l.unshift({ id: R.id, params: { range: s, unitId: e, subUnitId: r } }), {
1126
1131
  undos: l,
1127
1132
  redos: o
1128
1133
  };
1129
1134
  }
1130
- _handleCopySheetCommand(r, e, t) {
1131
- const n = this._sheetsFilterService.getFilterModel(r, e);
1135
+ _handleCopySheetCommand(t, e, r) {
1136
+ const n = this._sheetsFilterService.getFilterModel(t, e);
1132
1137
  if (!n)
1133
1138
  return this._handleNull();
1134
1139
  const s = n.getRange();
@@ -1136,8 +1141,8 @@ let z = class extends U {
1136
1141
  return this._handleNull();
1137
1142
  const o = [], l = [], a = [], c = [];
1138
1143
  return n.getAllFilterColumns().forEach(([d, h]) => {
1139
- o.push({ id: p.id, params: { unitId: r, subUnitId: t, col: d, criteria: { ...h.serialize(), colId: d } } }), a.push({ id: p.id, params: { unitId: r, subUnitId: t, col: d, criteria: null } });
1140
- }), a.push({ id: y.id, params: { unitId: r, subUnitId: t, range: s } }), o.unshift({ id: R.id, params: { range: s, unitId: r, subUnitId: t } }), {
1144
+ o.push({ id: p.id, params: { unitId: t, subUnitId: r, col: d, criteria: { ...h.serialize(), colId: d } } }), a.push({ id: p.id, params: { unitId: t, subUnitId: r, col: d, criteria: null } });
1145
+ }), a.push({ id: y.id, params: { unitId: t, subUnitId: r, range: s } }), o.unshift({ id: R.id, params: { range: s, unitId: t, subUnitId: r } }), {
1141
1146
  undos: l,
1142
1147
  redos: o,
1143
1148
  preUndos: a,
@@ -1150,23 +1155,23 @@ let z = class extends U {
1150
1155
  _initRowFilteredInterceptor() {
1151
1156
  this.disposeWithMe(this._sheetInterceptorService.intercept(et.ROW_FILTERED, {
1152
1157
  // sheet-interceptor.service.ts
1153
- handler: (r, e) => {
1154
- var t, n;
1155
- return r ? !0 : (n = (t = this._sheetsFilterService.getFilterModel(
1158
+ handler: (t, e) => {
1159
+ var r, n;
1160
+ return t ? !0 : (n = (r = this._sheetsFilterService.getFilterModel(
1156
1161
  e.unitId,
1157
1162
  e.subUnitId
1158
- )) == null ? void 0 : t.isRowFiltered(e.row)) != null ? n : !1;
1163
+ )) == null ? void 0 : r.isRowFiltered(e.row)) != null ? n : !1;
1159
1164
  }
1160
1165
  }));
1161
1166
  }
1162
- _moveCriteria(r, e, t, n) {
1167
+ _moveCriteria(t, e, r, n) {
1163
1168
  const s = {
1164
- unitId: r,
1169
+ unitId: t,
1165
1170
  subUnitId: e,
1166
1171
  criteria: null,
1167
1172
  col: -1
1168
1173
  }, o = [], l = [], a = [], c = [];
1169
- return t.forEach((u) => {
1174
+ return r.forEach((u) => {
1170
1175
  const [d, h] = u;
1171
1176
  l.push({
1172
1177
  id: p.id,
@@ -1182,7 +1187,7 @@ let z = class extends U {
1182
1187
  criteria: { ...h.serialize(), colId: d }
1183
1188
  }
1184
1189
  });
1185
- }), t.forEach((u) => {
1190
+ }), r.forEach((u) => {
1186
1191
  const [d, h] = u;
1187
1192
  c.push({
1188
1193
  id: p.id,
@@ -1211,14 +1216,14 @@ let z = class extends U {
1211
1216
  };
1212
1217
  }
1213
1218
  _commandExecutedListener() {
1214
- this.disposeWithMe(this._commandService.onCommandExecuted((r, e) => {
1219
+ this.disposeWithMe(this._commandService.onCommandExecuted((t, e) => {
1215
1220
  var c, u;
1216
- const { unitId: t, subUnitId: n } = r.params || {}, s = this._sheetsFilterService.getFilterModel(t, n);
1221
+ const { unitId: r, subUnitId: n } = t.params || {}, s = this._sheetsFilterService.getFilterModel(r, n);
1217
1222
  if (!s) return;
1218
1223
  const o = Array.from(s.filteredOutRows).sort((d, h) => d - h), l = [];
1219
1224
  let a = !1;
1220
- if (r.id === tt.id) {
1221
- const { startRow: d, endRow: h } = r.params.range, g = o.filter((_) => _ >= d && _ <= h);
1225
+ if (t.id === tt.id) {
1226
+ const { startRow: d, endRow: h } = t.params.range, g = o.filter((_) => _ >= d && _ <= h);
1222
1227
  o.forEach((_) => {
1223
1228
  if (_ < d)
1224
1229
  l.push(_);
@@ -1229,27 +1234,27 @@ let z = class extends U {
1229
1234
  l.push(_ - (h - d + 1 - g.length));
1230
1235
  });
1231
1236
  }
1232
- if (r.id === rt.id) {
1233
- const { startRow: d, endRow: h } = r.params.range;
1237
+ if (t.id === rt.id) {
1238
+ const { startRow: d, endRow: h } = t.params.range;
1234
1239
  o.forEach((g) => {
1235
1240
  g >= d ? (a = !0, l.push(g + (h - d + 1))) : l.push(g);
1236
1241
  });
1237
1242
  }
1238
- if (a && (s.filteredOutRows = new Set(l)), r.id === nt.id && !(e != null && e.onlyLocal)) {
1239
- const d = this._getExtendRegion(t, n);
1243
+ if (a && (s.filteredOutRows = new Set(l)), t.id === nt.id && !(e != null && e.onlyLocal)) {
1244
+ const d = this._getExtendRegion(r, n);
1240
1245
  if (d) {
1241
- const h = r.params.cellValue;
1246
+ const h = t.params.cellValue;
1242
1247
  if (h)
1243
1248
  for (let g = d.startColumn; g <= d.endColumn; g++) {
1244
1249
  const _ = (c = h == null ? void 0 : h[d.startRow]) == null ? void 0 : c[g];
1245
1250
  if (_ && this._cellHasValue(_)) {
1246
- const S = (u = this._univerInstanceService.getUnit(t)) == null ? void 0 : u.getSheetBySheetId(n);
1251
+ const S = (u = this._univerInstanceService.getUnit(r)) == null ? void 0 : u.getSheetBySheetId(n);
1247
1252
  if (S) {
1248
- const w = Ce(d, { down: !0 }, S), F = this._sheetsFilterService.getFilterModel(t, n), f = F.getRange();
1253
+ const w = Ce(d, { down: !0 }, S), F = this._sheetsFilterService.getFilterModel(r, n), f = F.getRange();
1249
1254
  F.setRange({
1250
1255
  ...f,
1251
1256
  endRow: w.endRow
1252
- }), this._registerRefRange(t, n);
1257
+ }), this._registerRefRange(r, n);
1253
1258
  }
1254
1259
  }
1255
1260
  }
@@ -1257,15 +1262,15 @@ let z = class extends U {
1257
1262
  }
1258
1263
  }));
1259
1264
  }
1260
- _getExtendRegion(r, e) {
1265
+ _getExtendRegion(t, e) {
1261
1266
  var a;
1262
- const t = this._sheetsFilterService.getFilterModel(r, e);
1263
- if (!t)
1267
+ const r = this._sheetsFilterService.getFilterModel(t, e);
1268
+ if (!r)
1264
1269
  return null;
1265
- const n = (a = this._univerInstanceService.getUnit(r)) == null ? void 0 : a.getSheetBySheetId(e);
1270
+ const n = (a = this._univerInstanceService.getUnit(t)) == null ? void 0 : a.getSheetBySheetId(e);
1266
1271
  if (!n)
1267
1272
  return null;
1268
- const s = t.getRange();
1273
+ const s = r.getRange();
1269
1274
  if (!s)
1270
1275
  return null;
1271
1276
  const o = n.getRowCount() - 1, l = n.getRowManager();
@@ -1280,19 +1285,19 @@ let z = class extends U {
1280
1285
  return null;
1281
1286
  }
1282
1287
  _initErrorHandling() {
1283
- this.disposeWithMe(this._commandService.beforeCommandExecuted((r) => {
1284
- const e = r.params, t = H(this._univerInstanceService);
1285
- if (!t) return;
1286
- const { subUnitId: n, unitId: s } = t, o = this._sheetsFilterService.getFilterModel(s, n);
1288
+ this.disposeWithMe(this._commandService.beforeCommandExecuted((t) => {
1289
+ const e = t.params, r = H(this._univerInstanceService);
1290
+ if (!r) return;
1291
+ const { subUnitId: n, unitId: s } = r, o = this._sheetsFilterService.getFilterModel(s, n);
1287
1292
  if (!o) return;
1288
1293
  const l = o.getRange();
1289
- if (r.id === it.id && e.fromRange.startRow <= l.startRow && e.fromRange.endRow < l.endRow && e.fromRange.endRow >= l.startRow)
1294
+ if (t.id === it.id && e.fromRange.startRow <= l.startRow && e.fromRange.endRow < l.endRow && e.fromRange.endRow >= l.startRow)
1290
1295
  throw this._sheetsFilterService.setFilterErrorMsg("sheets-filter.msg.filter-header-forbidden"), new Error("[SheetsFilterController]: Cannot move header row of filter");
1291
1296
  }));
1292
1297
  }
1293
- _cellHasValue(r) {
1294
- const e = Object.values(r);
1295
- return !(e.length === 0 || e.every((t) => t == null));
1298
+ _cellHasValue(t) {
1299
+ const e = Object.values(t);
1300
+ return !(e.length === 0 || e.every((r) => r == null));
1296
1301
  }
1297
1302
  };
1298
1303
  z = qt([
@@ -1304,11 +1309,11 @@ z = qt([
1304
1309
  x(5, He(gt)),
1305
1310
  x(6, A(Ze))
1306
1311
  ], z);
1307
- var Gt = Object.getOwnPropertyDescriptor, Qt = (i, r, e, t) => {
1308
- for (var n = t > 1 ? void 0 : t ? Gt(r, e) : r, s = i.length - 1, o; s >= 0; s--)
1312
+ var Gt = Object.getOwnPropertyDescriptor, Qt = (i, t, e, r) => {
1313
+ for (var n = r > 1 ? void 0 : r ? Gt(t, e) : t, s = i.length - 1, o; s >= 0; s--)
1309
1314
  (o = i[s]) && (n = o(n) || n);
1310
1315
  return n;
1311
- }, ee = (i, r) => (e, t) => r(e, t, i);
1316
+ }, ee = (i, t) => (e, r) => t(e, r, i);
1312
1317
  const Jt = [
1313
1318
  p.id,
1314
1319
  B.id
@@ -1318,14 +1323,14 @@ const Jt = [
1318
1323
  Se.id
1319
1324
  ];
1320
1325
  let G = class extends U {
1321
- constructor(r, e, t) {
1326
+ constructor(t, e, r) {
1322
1327
  super();
1323
1328
  C(this, "_d", new ge());
1324
1329
  C(this, "_visible$", new $(!1));
1325
1330
  C(this, "visible$", this._visible$.asObservable());
1326
1331
  C(this, "_enabled$", new $(!0));
1327
1332
  C(this, "enabled$", this._enabled$.asObservable());
1328
- this._sheetsFilterController = r, this._commandService = e, this._configService = t;
1333
+ this._sheetsFilterController = t, this._commandService = e, this._configService = r;
1329
1334
  const n = this._configService.getConfig(Ie);
1330
1335
  n != null && n.enableSyncSwitch && this._visible$.next(!0);
1331
1336
  }
@@ -1335,25 +1340,25 @@ let G = class extends U {
1335
1340
  get enabled() {
1336
1341
  return this._enabled$.getValue();
1337
1342
  }
1338
- setEnabled(r) {
1339
- this._enabled$.next(r), r ? this._d.dispose() : this._initOnlyLocalListener();
1343
+ setEnabled(t) {
1344
+ this._enabled$.next(t), t ? this._d.dispose() : this._initOnlyLocalListener();
1340
1345
  }
1341
1346
  _initOnlyLocalListener() {
1342
1347
  this._d.add(
1343
- this._commandService.beforeCommandExecuted((r, e) => {
1344
- Jt.includes(r.id) && (e || (e = {}), e.onlyLocal = !0);
1348
+ this._commandService.beforeCommandExecuted((t, e) => {
1349
+ Jt.includes(t.id) && (e || (e = {}), e.onlyLocal = !0);
1345
1350
  })
1346
1351
  ), this._d.add(
1347
- this._commandService.onCommandExecuted((r, e) => {
1348
- if (Zt.includes(r.id) && (e != null && e.fromCollab)) {
1349
- if (r.id === Re.id) {
1350
- const { range: t, unitId: n, subUnitId: s } = r.params, { redos: o } = this._sheetsFilterController.handleInsertColCommand(t, n, s);
1352
+ this._commandService.onCommandExecuted((t, e) => {
1353
+ if (Zt.includes(t.id) && (e != null && e.fromCollab)) {
1354
+ if (t.id === Re.id) {
1355
+ const { range: r, unitId: n, subUnitId: s } = t.params, { redos: o } = this._sheetsFilterController.handleInsertColCommand(r, n, s);
1351
1356
  j(o, this._commandService, e);
1352
- } else if (r.id === pe.id) {
1353
- const { range: t, unitId: n, subUnitId: s } = r.params, { redos: o } = this._sheetsFilterController.handleRemoveColCommand(t, n, s);
1357
+ } else if (t.id === pe.id) {
1358
+ const { range: r, unitId: n, subUnitId: s } = t.params, { redos: o } = this._sheetsFilterController.handleRemoveColCommand(r, n, s);
1354
1359
  j(o, this._commandService, e);
1355
- } else if (r.id === Se.id) {
1356
- const { sourceRange: t, targetRange: n, unitId: s, subUnitId: o } = r.params, { redos: l } = this._sheetsFilterController.handleMoveColsCommand({ fromRange: t, toRange: n }, s, o);
1360
+ } else if (t.id === Se.id) {
1361
+ const { sourceRange: r, targetRange: n, unitId: s, subUnitId: o } = t.params, { redos: l } = this._sheetsFilterController.handleMoveColsCommand({ fromRange: r, toRange: n }, s, o);
1357
1362
  j(l, this._commandService, e);
1358
1363
  }
1359
1364
  }
@@ -1366,14 +1371,14 @@ G = Qt([
1366
1371
  ee(1, N),
1367
1372
  ee(2, _e)
1368
1373
  ], G);
1369
- var Kt = Object.getOwnPropertyDescriptor, Yt = (i, r, e, t) => {
1370
- for (var n = t > 1 ? void 0 : t ? Kt(r, e) : r, s = i.length - 1, o; s >= 0; s--)
1374
+ var Kt = Object.getOwnPropertyDescriptor, Yt = (i, t, e, r) => {
1375
+ for (var n = r > 1 ? void 0 : r ? Kt(t, e) : t, s = i.length - 1, o; s >= 0; s--)
1371
1376
  (o = i[s]) && (n = o(n) || n);
1372
1377
  return n;
1373
- }, V = (i, r) => (e, t) => r(e, t, i);
1378
+ }, V = (i, t) => (e, r) => t(e, r, i);
1374
1379
  let Q = class extends U {
1375
- constructor(i, r, e, t) {
1376
- super(), this._activeDirtyManagerService = i, this._sheetRowFilteredService = r, this._sheetsFilterService = e, this._univerInstanceService = t, this._initFormulaDirtyRange(), this._registerSheetRowFiltered();
1380
+ constructor(i, t, e, r) {
1381
+ super(), this._activeDirtyManagerService = i, this._sheetRowFilteredService = t, this._sheetsFilterService = e, this._univerInstanceService = r, this._initFormulaDirtyRange(), this._registerSheetRowFiltered();
1377
1382
  }
1378
1383
  _initFormulaDirtyRange() {
1379
1384
  Ee.forEach((i) => {
@@ -1381,12 +1386,12 @@ let Q = class extends U {
1381
1386
  i,
1382
1387
  {
1383
1388
  commandId: i,
1384
- getDirtyData: (r) => {
1385
- const e = r.params, { unitId: t, subUnitId: n } = e;
1389
+ getDirtyData: (t) => {
1390
+ const e = t.params, { unitId: r, subUnitId: n } = e;
1386
1391
  return {
1387
- dirtyRanges: this._getHideRowMutation(t, n),
1392
+ dirtyRanges: this._getHideRowMutation(r, n),
1388
1393
  clearDependencyTreeCache: {
1389
- [t]: {
1394
+ [r]: {
1390
1395
  [n]: "1"
1391
1396
  }
1392
1397
  }
@@ -1396,27 +1401,27 @@ let Q = class extends U {
1396
1401
  );
1397
1402
  });
1398
1403
  }
1399
- _getHideRowMutation(i, r) {
1404
+ _getHideRowMutation(i, t) {
1400
1405
  var l, a;
1401
- const e = (l = this._sheetsFilterService.getFilterModel(i, r)) == null ? void 0 : l.getRange(), t = (a = this._univerInstanceService.getUnit(i)) == null ? void 0 : a.getSheetBySheetId(r);
1402
- if (e == null || t == null)
1406
+ const e = (l = this._sheetsFilterService.getFilterModel(i, t)) == null ? void 0 : l.getRange(), r = (a = this._univerInstanceService.getUnit(i)) == null ? void 0 : a.getSheetBySheetId(t);
1407
+ if (e == null || r == null)
1403
1408
  return [];
1404
1409
  const { startRow: n, endRow: s } = e;
1405
1410
  return [{
1406
1411
  unitId: i,
1407
- sheetId: r,
1412
+ sheetId: t,
1408
1413
  range: {
1409
1414
  startRow: n,
1410
1415
  startColumn: 0,
1411
1416
  endRow: s,
1412
- endColumn: t.getColumnCount() - 1
1417
+ endColumn: r.getColumnCount() - 1
1413
1418
  }
1414
1419
  }];
1415
1420
  }
1416
1421
  _registerSheetRowFiltered() {
1417
- this._sheetRowFilteredService.register((i, r, e) => {
1418
- var t, n;
1419
- return (n = (t = this._sheetsFilterService.getFilterModel(i, r)) == null ? void 0 : t.isRowFiltered(e)) != null ? n : !1;
1422
+ this._sheetRowFilteredService.register((i, t, e) => {
1423
+ var r, n;
1424
+ return (n = (r = this._sheetsFilterService.getFilterModel(i, t)) == null ? void 0 : r.isRowFiltered(e)) != null ? n : !1;
1420
1425
  });
1421
1426
  }
1422
1427
  };
@@ -1426,20 +1431,20 @@ Q = Yt([
1426
1431
  V(2, A(M)),
1427
1432
  V(3, T)
1428
1433
  ], Q);
1429
- var Xt = Object.getOwnPropertyDescriptor, er = (i, r, e, t) => {
1430
- for (var n = t > 1 ? void 0 : t ? Xt(r, e) : r, s = i.length - 1, o; s >= 0; s--)
1434
+ var Xt = Object.getOwnPropertyDescriptor, er = (i, t, e, r) => {
1435
+ for (var n = r > 1 ? void 0 : r ? Xt(t, e) : t, s = i.length - 1, o; s >= 0; s--)
1431
1436
  (o = i[s]) && (n = o(n) || n);
1432
1437
  return n;
1433
- }, he = (i, r) => (e, t) => r(e, t, i), W;
1438
+ }, he = (i, t) => (e, r) => t(e, r, i), W;
1434
1439
  let fe = (W = class extends Ve {
1435
- constructor(i = ue, r, e) {
1436
- super(), this._config = i, this._injector = r, this._configService = e;
1437
- const { ...t } = We(
1440
+ constructor(i = ue, t, e) {
1441
+ super(), this._config = i, this._injector = t, this._configService = e;
1442
+ const { ...r } = We(
1438
1443
  {},
1439
1444
  ue,
1440
1445
  this._config
1441
1446
  );
1442
- this._configService.setConfig(Ie, t);
1447
+ this._configService.setConfig(Ie, r);
1443
1448
  }
1444
1449
  onStarting() {
1445
1450
  [