@univerjs/sheets-filter 0.6.3 → 0.6.4-nightly.202503101606

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
@@ -1,86 +1,87 @@
1
- var Fe = Object.defineProperty;
2
- var we = (i, r, e) => r in i ? Fe(i, r, { enumerable: !0, configurable: !0, writable: !0, value: e }) : i[r] = e;
3
- var w = (i, r, e) => we(i, typeof r != "symbol" ? r + "" : r, e);
4
- import { isNumeric as Se, Disposable as V, Rectangle as J, mergeSets as q, Tools as Z, extractPureTextFromCell as ve, CellValueType as Y, UniverInstanceType as P, fromCallback as Me, CommandType as E, IResourceManagerService as Ee, IUniverInstanceService as x, ICommandService as T, Inject as z, DisposableCollection as Oe, moveMatrixArray as ee, Plugin as ye, merge as Ae, Injector as Te, IConfigService as Ne, IUndoRedoService as j, sequenceExecute as xe, ErrorService as Ie, LocaleService as $e } from "@univerjs/core";
5
- import { SheetInterceptorService as Ue, RefRangeService as Pe, SetWorksheetActiveOperation as Le, CopySheetCommand as be, RemoveSheetCommand as Be, INTERCEPTOR_POINT as ze, RemoveRowMutation as He, InsertRowMutation as De, SetRangeValuesMutation as We, expandToContinuousRange as ae, getSheetCommandTarget as b, MoveRowsCommand as Ve, MoveRangeCommand as je, EffectRefRangId as te, RemoveRowCommand as ke, RemoveColCommand as qe, InsertColCommand as Qe, InsertRowCommand as Ge, SheetsSelectionsService as Je, isSingleCellSelection as Ye } from "@univerjs/sheets";
6
- import { BehaviorSubject as L, merge as Ke, filter as Xe, switchMap as Ze, of as et } from "rxjs";
7
- const tt = "sheets-filter.config", re = {}, ce = "sheet.mutation.set-filter-range", de = "sheet.mutation.set-filter-criteria", ue = "sheet.mutation.remove-filter", he = "sheet.mutation.re-calc-filter", rt = /* @__PURE__ */ new Set([
8
- ce,
1
+ var ve = Object.defineProperty;
2
+ var Me = (i, r, e) => r in i ? ve(i, r, { enumerable: !0, configurable: !0, writable: !0, value: e }) : i[r] = e;
3
+ var w = (i, r, e) => Me(i, typeof r != "symbol" ? r + "" : r, e);
4
+ import { isNumeric as Ee, Disposable as B, Rectangle as K, mergeSets as Q, Tools as te, extractPureTextFromCell as ye, CellValueType as X, UniverInstanceType as D, fromCallback as Oe, CommandType as E, IResourceManagerService as Ae, IUniverInstanceService as T, ICommandService as N, Inject as $, DisposableCollection as Te, moveMatrixArray as re, Plugin as Ne, merge as xe, touchDependencies as Ie, Injector as $e, IConfigService as Ue, IUndoRedoService as k, sequenceExecute as Pe, ErrorService as De, LocaleService as Le } from "@univerjs/core";
5
+ import { SheetInterceptorService as Be, RefRangeService as be, SetWorksheetActiveOperation as He, CopySheetCommand as ze, RemoveSheetCommand as We, INTERCEPTOR_POINT as Ve, RemoveRowMutation as je, InsertRowMutation as ke, SetRangeValuesMutation as qe, expandToContinuousRange as ue, getSheetCommandTarget as b, MoveRowsCommand as Qe, MoveRangeCommand as Ge, EffectRefRangId as ne, RemoveRowCommand as Je, RemoveColCommand as Ye, InsertColCommand as Ke, InsertRowCommand as Xe, SheetsSelectionsService as Ze, isSingleCellSelection as et } from "@univerjs/sheets";
6
+ import { BehaviorSubject as L, merge as tt, filter as rt, switchMap as nt, of as it } from "rxjs";
7
+ import { IActiveDirtyManagerService as st } from "@univerjs/engine-formula";
8
+ const ot = "sheets-filter.config", ie = {}, de = "sheet.mutation.set-filter-range", he = "sheet.mutation.set-filter-criteria", me = "sheet.mutation.remove-filter", fe = "sheet.mutation.re-calc-filter", ge = /* @__PURE__ */ new Set([
9
9
  de,
10
- ue,
11
- he
10
+ he,
11
+ me,
12
+ fe
12
13
  ]);
13
- var N = /* @__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))(N || {});
14
- const nt = {
15
- operator: N.GREATER_THAN,
16
- fn: (i, r) => $(i) ? i > r : !1
17
- }, it = {
18
- operator: N.GREATER_THAN_OR_EQUAL,
19
- fn: (i, r) => $(i) ? i >= r : !1
20
- }, st = {
21
- operator: N.LESS_THAN,
22
- fn: (i, r) => $(i) ? i < r : !1
23
- }, ot = {
24
- operator: N.LESS_THAN_OR_EQUAL,
25
- fn: (i, r) => $(i) ? i <= r : !1
26
- }, lt = {
27
- operator: N.EQUAL,
28
- fn: (i, r) => $(i) ? i === r : !1
29
- }, me = {
30
- operator: N.NOT_EQUALS,
14
+ var x = /* @__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))(x || {});
15
+ const lt = {
16
+ operator: x.GREATER_THAN,
17
+ fn: (i, r) => U(i) ? i > r : !1
18
+ }, at = {
19
+ operator: x.GREATER_THAN_OR_EQUAL,
20
+ fn: (i, r) => U(i) ? i >= r : !1
21
+ }, ct = {
22
+ operator: x.LESS_THAN,
23
+ fn: (i, r) => U(i) ? i < r : !1
24
+ }, ut = {
25
+ operator: x.LESS_THAN_OR_EQUAL,
26
+ fn: (i, r) => U(i) ? i <= r : !1
27
+ }, dt = {
28
+ operator: x.EQUAL,
29
+ fn: (i, r) => U(i) ? i === r : !1
30
+ }, _e = {
31
+ operator: x.NOT_EQUALS,
31
32
  fn: (i, r) => {
32
33
  if (typeof r == "string") {
33
34
  if (r === " ")
34
35
  return i != null;
35
- const e = ge(i);
36
- return e && ut(r) ? !_e(r).test(e) : e !== r;
36
+ const e = Ce(i);
37
+ return e && gt(r) ? !pe(r).test(e) : e !== r;
37
38
  }
38
- return $(i) ? i !== r : !0;
39
+ return U(i) ? i !== r : !0;
39
40
  }
40
- }, fe = /* @__PURE__ */ new Map([]), at = [nt, it, st, ot, lt, me];
41
- at.forEach((i) => {
42
- fe.set(i.operator, i);
41
+ }, Re = /* @__PURE__ */ new Map([]), ht = [lt, at, ct, ut, dt, _e];
42
+ ht.forEach((i) => {
43
+ Re.set(i.operator, i);
43
44
  });
44
- function ct(i) {
45
+ function mt(i) {
45
46
  return !!i;
46
47
  }
47
- const dt = {
48
+ const ft = {
48
49
  fn: (i, r) => {
49
- const e = ge(i);
50
- return e === null ? r === "" : _e(r).test(e);
50
+ const e = Ce(i);
51
+ return e === null ? r === "" : pe(r).test(e);
51
52
  }
52
53
  };
53
- function ne(i) {
54
- return i ? fe.get(i) : dt;
54
+ function se(i) {
55
+ return i ? Re.get(i) : ft;
55
56
  }
56
- function $(i) {
57
+ function U(i) {
57
58
  return typeof i == "number";
58
59
  }
59
- function ie(i) {
60
- return !!(typeof i == "number" || typeof i == "string" && Se(i));
60
+ function oe(i) {
61
+ return !!(typeof i == "number" || typeof i == "string" && Ee(i));
61
62
  }
62
- function ge(i) {
63
+ function Ce(i) {
63
64
  return typeof i == "boolean" || i == null ? null : typeof i == "string" ? i : i.toString();
64
65
  }
65
- function ut(i) {
66
+ function gt(i) {
66
67
  return typeof i == "number" ? !1 : i.indexOf("*") !== -1 || i.indexOf("?") !== -1;
67
68
  }
68
- function _e(i) {
69
+ function pe(i) {
69
70
  const r = i.replace(/[.+^${}()|[\]\\]/g, "\\$&").replaceAll("?", ".").replace(/[*]/g, ".$&");
70
71
  return new RegExp(`^${r}$`);
71
72
  }
72
- const Q = () => /* @__PURE__ */ new Set();
73
- class D extends V {
73
+ const G = () => /* @__PURE__ */ new Set();
74
+ class W extends B {
74
75
  constructor(e, t, n) {
75
76
  super();
76
- w(this, "_filteredOutRows$", new L(Q()));
77
+ w(this, "_filteredOutRows$", new L(G()));
77
78
  /** An observable value. A set of filtered out rows. */
78
79
  w(this, "filteredOutRows$", this._filteredOutRows$.asObservable());
79
80
  // TODO: we may need to update which cols have criteria rather than simple boolean
80
81
  w(this, "_hasCriteria$", new L(!1));
81
82
  w(this, "hasCriteria$", this._hasCriteria$.asObservable());
82
83
  w(this, "_filterColumnByIndex", /* @__PURE__ */ new Map());
83
- w(this, "_alreadyFilteredOutRows", Q());
84
+ w(this, "_alreadyFilteredOutRows", G());
84
85
  w(this, "_range");
85
86
  this.unitId = e, this.subUnitId = t, this._worksheet = n;
86
87
  }
@@ -98,7 +99,7 @@ class D extends V {
98
99
  */
99
100
  serialize() {
100
101
  const e = {
101
- ref: J.clone(this._range),
102
+ ref: K.clone(this._range),
102
103
  filterColumns: this._getAllFilterColumns(!0).sort(([t], [n]) => t - n).map(([t, n]) => n.serialize())
103
104
  };
104
105
  return this._alreadyFilteredOutRows && (e.cachedFilteredOut = Array.from(this._alreadyFilteredOutRows).sort()), e;
@@ -111,7 +112,7 @@ class D extends V {
111
112
  * @param autoFilter auto filter data
112
113
  */
113
114
  static deserialize(e, t, n, s) {
114
- const o = new D(e, t, n);
115
+ const o = new W(e, t, n);
115
116
  return o._dump(s), o;
116
117
  }
117
118
  _dump(e) {
@@ -134,7 +135,7 @@ class D extends V {
134
135
  getFilteredOutRowsExceptCol(e) {
135
136
  return this._getAllFilterColumns(!0).filter(([t]) => t !== e).reduce((t, [, n]) => {
136
137
  const s = n.calc({ getAlreadyFilteredOutRows: () => t });
137
- return s ? q(t, s) : t;
138
+ return s ? Q(t, s) : t;
138
139
  }, /* @__PURE__ */ new Set());
139
140
  }
140
141
  /**
@@ -178,7 +179,7 @@ class D extends V {
178
179
  return e ? t : t.map(([n, s]) => s);
179
180
  }
180
181
  _reCalcAllColumns() {
181
- this._alreadyFilteredOutRows = Q(), this._getAllFilterColumns().forEach((e) => e.__clearCache()), this._reCalcWithNoCacheColumns();
182
+ this._alreadyFilteredOutRows = G(), this._getAllFilterColumns().forEach((e) => e.__clearCache()), this._reCalcWithNoCacheColumns();
182
183
  }
183
184
  _setCriteriaWithoutReCalc(e, t) {
184
185
  const n = this._range;
@@ -188,7 +189,7 @@ class D extends V {
188
189
  if (e > o || e < s)
189
190
  throw new Error(`[FilterModel] could not set criteria on column ${e} which is out of range!`);
190
191
  let l;
191
- this._filterColumnByIndex.has(e) ? l = this._filterColumnByIndex.get(e) : (l = new ht(
192
+ this._filterColumnByIndex.has(e) ? l = this._filterColumnByIndex.get(e) : (l = new _t(
192
193
  this.unitId,
193
194
  this.subUnitId,
194
195
  this._worksheet,
@@ -207,18 +208,18 @@ class D extends V {
207
208
  this._hasCriteria$.next(this._filterColumnByIndex.size > 0);
208
209
  }
209
210
  _rebuildAlreadyFilteredOutRowsWithCache() {
210
- const e = this._getAllFilterColumns().filter((t) => t.hasCache()).reduce((t, n) => q(t, n.filteredOutRows), /* @__PURE__ */ new Set());
211
+ const e = this._getAllFilterColumns().filter((t) => t.hasCache()).reduce((t, n) => Q(t, n.filteredOutRows), /* @__PURE__ */ new Set());
211
212
  this._alreadyFilteredOutRows = e;
212
213
  }
213
214
  _reCalcWithNoCacheColumns() {
214
215
  const e = this._getAllFilterColumns().filter((t) => !t.hasCache());
215
216
  for (const t of e) {
216
217
  const n = t.reCalc();
217
- n && (this._alreadyFilteredOutRows = q(this._alreadyFilteredOutRows, n));
218
+ n && (this._alreadyFilteredOutRows = Q(this._alreadyFilteredOutRows, n));
218
219
  }
219
220
  }
220
221
  }
221
- class ht extends V {
222
+ class _t extends B {
222
223
  constructor(e, t, n, s, o) {
223
224
  super();
224
225
  w(this, "_filteredOutRows", null);
@@ -244,7 +245,7 @@ class ht extends V {
244
245
  serialize() {
245
246
  if (!this._criteria)
246
247
  throw new Error("[FilterColumn]: could not serialize without a filter column!");
247
- return Z.deepClone({
248
+ return te.deepClone({
248
249
  ...this._criteria,
249
250
  colId: this._column
250
251
  });
@@ -260,7 +261,7 @@ class ht extends V {
260
261
  this._criteria = e, this._generateFilterFn(), this._filteredOutRows = null;
261
262
  }
262
263
  getColumnData() {
263
- return Z.deepClone(this._criteria);
264
+ return te.deepClone(this._criteria);
264
265
  }
265
266
  /**
266
267
  * Trigger new calculation on this `FilterModel` instance.
@@ -283,75 +284,75 @@ class ht extends V {
283
284
  const { row: a, rowSpan: c, col: h } = l;
284
285
  if (o.has(a) && (!c || c === 1))
285
286
  continue;
286
- const d = this._filterByValues ? ve(this._worksheet.getCell(a, h)) : Ft(this._worksheet, a, h);
287
- if (!this._filterFn(d) && (s.add(a), c))
288
- for (let u = 1; u < c; u++)
289
- s.add(a + u);
287
+ const u = this._filterByValues ? ye(this._worksheet.getCell(a, h)) : Mt(this._worksheet, a, h);
288
+ if (!this._filterFn(u) && (s.add(a), c))
289
+ for (let d = 1; d < c; d++)
290
+ s.add(a + d);
290
291
  }
291
292
  return s;
292
293
  }
293
294
  _generateFilterFn() {
294
- this._criteria && (this._filterFn = mt(this._criteria), this._filterByValues = !!this._criteria.filters);
295
+ this._criteria && (this._filterFn = Rt(this._criteria), this._filterByValues = !!this._criteria.filters);
295
296
  }
296
297
  }
297
- function mt(i) {
298
+ function Rt(i) {
298
299
  if (i.filters)
299
- return ft(i.filters);
300
+ return Ct(i.filters);
300
301
  if (i.customFilters)
301
- return gt(i.customFilters);
302
+ return pt(i.customFilters);
302
303
  throw new Error("[FilterModel]: other types of filters are not supported yet.");
303
304
  }
304
- function ft(i) {
305
+ function Ct(i) {
305
306
  const r = !!i.blank, e = new Set(i.filters);
306
307
  return (t) => t === void 0 || t === "" ? r : e.has(typeof t == "string" ? t : `${t}`);
307
308
  }
308
- function gt(i) {
309
- const r = i.customFilters.map((e) => pt(e));
310
- return Ct(r) ? i.and ? _t(r) : Rt(r) : r[0];
309
+ function pt(i) {
310
+ const r = i.customFilters.map((e) => vt(e));
311
+ return St(r) ? i.and ? Ft(r) : wt(r) : r[0];
311
312
  }
312
- function _t(i) {
313
+ function Ft(i) {
313
314
  const [r, e] = i;
314
315
  return (t) => r(t) && e(t);
315
316
  }
316
- function Rt(i) {
317
+ function wt(i) {
317
318
  const [r, e] = i;
318
319
  return (t) => r(t) || e(t);
319
320
  }
320
- function Ct(i) {
321
+ function St(i) {
321
322
  return i.length === 2;
322
323
  }
323
- function pt(i) {
324
+ function vt(i) {
324
325
  const r = i.val;
325
- if (i.operator === N.NOT_EQUALS && !ie(r))
326
- return (n) => me.fn(n, r);
327
- if (ct(i.operator)) {
328
- if (!ie(r)) return () => !1;
329
- const n = ne(i.operator), s = Number(r);
326
+ if (i.operator === x.NOT_EQUALS && !oe(r))
327
+ return (n) => _e.fn(n, r);
328
+ if (mt(i.operator)) {
329
+ if (!oe(r)) return () => !1;
330
+ const n = se(i.operator), s = Number(r);
330
331
  return (o) => n.fn(o, s);
331
332
  }
332
- const e = ne(i.operator);
333
+ const e = se(i.operator);
333
334
  return (t) => e.fn(t, r);
334
335
  }
335
- function Ft(i, r, e) {
336
+ function Mt(i, r, e) {
336
337
  const t = i.getCell(r, e);
337
338
  if (!t) return null;
338
339
  const n = i.getCellRaw(r, e);
339
- return t && !n ? se(t) : n ? t.t === Y.NUMBER && typeof t.v == "string" ? n.v : se(n) : null;
340
+ return t && !n ? le(t) : n ? t.t === X.NUMBER && typeof t.v == "string" ? n.v : le(n) : null;
340
341
  }
341
- function se(i) {
342
+ function le(i) {
342
343
  var t, n;
343
344
  const r = (n = (t = i.p) == null ? void 0 : t.body) == null ? void 0 : n.dataStream;
344
345
  if (r) return r.trimEnd();
345
346
  const e = i.v;
346
- return typeof e == "string" ? i.t === Y.BOOLEAN ? e.toUpperCase() : e : typeof e == "number" ? i.t === Y.BOOLEAN ? e ? "TRUE" : "FALSE" : e : typeof e == "boolean" ? e ? "TRUE" : "FALSE" : "";
347
+ return typeof e == "string" ? i.t === X.BOOLEAN ? e.toUpperCase() : e : typeof e == "number" ? i.t === X.BOOLEAN ? e ? "TRUE" : "FALSE" : e : typeof e == "boolean" ? e ? "TRUE" : "FALSE" : "";
347
348
  }
348
- var wt = Object.getOwnPropertyDescriptor, St = (i, r, e, t) => {
349
- for (var n = t > 1 ? void 0 : t ? wt(r, e) : r, s = i.length - 1, o; s >= 0; s--)
349
+ var Et = Object.getOwnPropertyDescriptor, yt = (i, r, e, t) => {
350
+ for (var n = t > 1 ? void 0 : t ? Et(r, e) : r, s = i.length - 1, o; s >= 0; s--)
350
351
  (o = i[s]) && (n = o(n) || n);
351
352
  return n;
352
- }, G = (i, r) => (e, t) => r(e, t, i);
353
- const Re = "SHEET_FILTER_PLUGIN";
354
- let M = class extends V {
353
+ }, J = (i, r) => (e, t) => r(e, t, i);
354
+ const Fe = "SHEET_FILTER_PLUGIN";
355
+ let M = class extends B {
355
356
  constructor(r, e, t) {
356
357
  super();
357
358
  w(this, "_filterModels", /* @__PURE__ */ new Map());
@@ -383,7 +384,7 @@ let M = class extends V {
383
384
  const s = n.getSheetBySheetId(e);
384
385
  if (!s)
385
386
  throw new Error(`[SheetsFilterService]: could not create "FilterModel" on a non-existing worksheet ${e}!`);
386
- const o = new D(r, e, s);
387
+ const o = new W(r, e, s);
387
388
  return this._cacheFilterModel(r, e, o), o;
388
389
  }
389
390
  getFilterModel(r, e) {
@@ -400,7 +401,7 @@ let M = class extends V {
400
401
  _updateActiveFilterModel() {
401
402
  let r;
402
403
  try {
403
- if (r = this._univerInstanceService.getCurrentUnitForType(P.UNIVER_SHEET), !r) {
404
+ if (r = this._univerInstanceService.getCurrentUnitForType(D.UNIVER_SHEET), !r) {
404
405
  this._activeFilterModel$.next(null);
405
406
  return;
406
407
  }
@@ -418,13 +419,13 @@ let M = class extends V {
418
419
  }
419
420
  _initActiveFilterModel() {
420
421
  this.disposeWithMe(
421
- Ke(
422
+ tt(
422
423
  // source1: executing filter related mutations
423
- Me(this._commandService.onCommandExecuted.bind(this._commandService)).pipe(Xe(([r]) => r.type === E.MUTATION && rt.has(r.id))),
424
+ Oe(this._commandService.onCommandExecuted.bind(this._commandService)).pipe(rt(([r]) => r.type === E.MUTATION && ge.has(r.id))),
424
425
  // source2: activate sheet changes
425
- this._univerInstanceService.getCurrentTypeOfUnit$(P.UNIVER_SHEET).pipe(Ze((r) => {
426
+ this._univerInstanceService.getCurrentTypeOfUnit$(D.UNIVER_SHEET).pipe(nt((r) => {
426
427
  var e;
427
- return (e = r == null ? void 0 : r.activeSheet$) != null ? e : et(null);
428
+ return (e = r == null ? void 0 : r.activeSheet$) != null ? e : it(null);
428
429
  }))
429
430
  ).subscribe(() => this._updateActiveFilterModel())
430
431
  );
@@ -441,14 +442,14 @@ let M = class extends V {
441
442
  _deserializeAutoFiltersForUnit(r, e) {
442
443
  const t = this._univerInstanceService.getUniverSheetInstance(r);
443
444
  Object.keys(e).forEach((n) => {
444
- const s = e[n], o = D.deserialize(r, n, t.getSheetBySheetId(n), s);
445
+ const s = e[n], o = W.deserialize(r, n, t.getSheetBySheetId(n), s);
445
446
  this._cacheFilterModel(r, n, o);
446
447
  });
447
448
  }
448
449
  _initModel() {
449
450
  this._resourcesManagerService.registerPluginResource({
450
- pluginName: Re,
451
- businesses: [P.UNIVER_SHEET],
451
+ pluginName: Fe,
452
+ businesses: [D.UNIVER_SHEET],
452
453
  toJson: (r) => this._serializeAutoFiltersForUnit(r),
453
454
  parseJson: (r) => JSON.parse(r),
454
455
  onLoad: (r, e) => {
@@ -464,41 +465,41 @@ let M = class extends V {
464
465
  this._filterModels.has(r) || this._filterModels.set(r, /* @__PURE__ */ new Map()), this._filterModels.get(r).set(e, t);
465
466
  }
466
467
  };
467
- M = St([
468
- G(0, Ee),
469
- G(1, x),
470
- G(2, T)
468
+ M = yt([
469
+ J(0, Ae),
470
+ J(1, T),
471
+ J(2, N)
471
472
  ], M);
472
473
  const R = {
473
- id: ce,
474
+ id: de,
474
475
  type: E.MUTATION,
475
476
  handler: (i, r) => {
476
477
  const { subUnitId: e, unitId: t, range: n } = r;
477
478
  return i.get(M).ensureFilterModel(t, e).setRange(n), !0;
478
479
  }
479
480
  }, p = {
480
- id: de,
481
+ id: he,
481
482
  type: E.MUTATION,
482
483
  handler: (i, r) => {
483
484
  const { subUnitId: e, unitId: t, criteria: n, col: s, reCalc: o = !0 } = r, a = i.get(M).getFilterModel(t, e);
484
485
  return a ? (a.setCriteria(s, n, o), !0) : !1;
485
486
  }
486
- }, O = {
487
- id: ue,
487
+ }, y = {
488
+ id: me,
488
489
  type: E.MUTATION,
489
490
  handler: (i, r) => {
490
491
  const { unitId: e, subUnitId: t } = r;
491
492
  return i.get(M).removeFilterModel(e, t);
492
493
  }
493
- }, H = {
494
- id: he,
494
+ }, z = {
495
+ id: fe,
495
496
  type: E.MUTATION,
496
497
  handler: (i, r) => {
497
498
  const { unitId: e, subUnitId: t } = r, s = i.get(M).getFilterModel(e, t);
498
499
  return s ? (s.reCalc(), !0) : !1;
499
500
  }
500
501
  };
501
- function vt(i, r) {
502
+ function Ot(i, r) {
502
503
  for (let e = 0; e < i.length; e++) {
503
504
  let t = e;
504
505
  if (i[e])
@@ -508,32 +509,32 @@ function vt(i, r) {
508
509
  return i.filter((e) => e !== null);
509
510
  }
510
511
  function I(i) {
511
- return vt(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);
512
+ return Ot(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);
512
513
  }
513
- var Mt = Object.getOwnPropertyDescriptor, Et = (i, r, e, t) => {
514
- for (var n = t > 1 ? void 0 : t ? Mt(r, e) : r, s = i.length - 1, o; s >= 0; s--)
514
+ var At = Object.getOwnPropertyDescriptor, Tt = (i, r, e, t) => {
515
+ for (var n = t > 1 ? void 0 : t ? At(r, e) : r, s = i.length - 1, o; s >= 0; s--)
515
516
  (o = i[s]) && (n = o(n) || n);
516
517
  return n;
517
- }, U = (i, r) => (e, t) => r(e, t, i);
518
- let W = class extends V {
518
+ }, P = (i, r) => (e, t) => r(e, t, i);
519
+ let V = class extends B {
519
520
  constructor(r, e, t, n, s) {
520
521
  super();
521
- w(this, "_disposableCollection", new Oe());
522
+ w(this, "_disposableCollection", new Te());
522
523
  this._commandService = r, this._sheetInterceptorService = e, this._sheetsFilterService = t, this._univerInstanceService = n, this._refRangeService = s, this._initCommands(), this._initRowFilteredInterceptor(), this._initInterceptors(), this._commandExecutedListener(), this._initErrorHandling();
523
524
  }
524
525
  _initCommands() {
525
526
  [
526
527
  p,
527
528
  R,
528
- H,
529
- O
529
+ z,
530
+ y
530
531
  ].forEach((r) => this.disposeWithMe(this._commandService.registerCommand(r)));
531
532
  }
532
533
  _initInterceptors() {
533
534
  this.disposeWithMe(this._sheetInterceptorService.interceptCommand({
534
535
  getMutations: (r) => this._getUpdateFilter(r)
535
536
  })), this.disposeWithMe(this._commandService.onCommandExecuted((r) => {
536
- if (r.id === Le.id) {
537
+ if (r.id === He.id) {
537
538
  const e = r.params, t = e.subUnitId, n = e.unitId;
538
539
  if (!t || !n)
539
540
  return;
@@ -559,31 +560,31 @@ let W = class extends V {
559
560
  if (!t || !n) return;
560
561
  const s = (l = this._sheetsFilterService.getFilterModel(r, e)) == null ? void 0 : l.getRange(), o = (a) => {
561
562
  switch (a.id) {
562
- case Ge.id: {
563
- const c = a.params, h = c.unitId || r, d = c.subUnitId || e;
564
- return this._handleInsertRowCommand(c, h, d);
563
+ case Xe.id: {
564
+ const c = a.params, h = c.unitId || r, u = c.subUnitId || e;
565
+ return this._handleInsertRowCommand(c, h, u);
565
566
  }
566
- case Qe.id: {
567
- const c = a.params, h = c.unitId || r, d = c.subUnitId || e;
568
- return this._handleInsertColCommand(c, h, d);
567
+ case Ke.id: {
568
+ const c = a.params, h = c.unitId || r, u = c.subUnitId || e;
569
+ return this._handleInsertColCommand(c, h, u);
569
570
  }
570
- case qe.id: {
571
+ case Ye.id: {
571
572
  const c = a.params;
572
573
  return this._handleRemoveColCommand(c, r, e);
573
574
  }
574
- case ke.id: {
575
+ case Je.id: {
575
576
  const c = a.params;
576
577
  return this._handleRemoveRowCommand(c, r, e);
577
578
  }
578
- case te.MoveColsCommandId: {
579
+ case ne.MoveColsCommandId: {
579
580
  const c = a.params;
580
581
  return this._handleMoveColsCommand(c, r, e);
581
582
  }
582
- case te.MoveRowsCommandId: {
583
+ case ne.MoveRowsCommandId: {
583
584
  const c = a.params;
584
585
  return this._handleMoveRowsCommand(c, r, e);
585
586
  }
586
- case je.id: {
587
+ case Ge.id: {
587
588
  const c = a.params;
588
589
  return this._handleMoveRangeCommand(c, r, e);
589
590
  }
@@ -595,11 +596,11 @@ let W = class extends V {
595
596
  _getUpdateFilter(r) {
596
597
  const { id: e } = r;
597
598
  switch (e) {
598
- case Be.id: {
599
+ case We.id: {
599
600
  const t = r.params;
600
601
  return this._handleRemoveSheetCommand(t, t.unitId, t.subUnitId);
601
602
  }
602
- case be.id: {
603
+ case ze.id: {
603
604
  const t = r.params, { targetSubUnitId: n, unitId: s, subUnitId: o } = t;
604
605
  return !s || !o || !n ? this._handleNull() : this._handleCopySheetCommand(s, o, n);
605
606
  }
@@ -617,7 +618,7 @@ let W = class extends V {
617
618
  const { startColumn: o, endColumn: l } = s, { startColumn: a, endColumn: c } = r.range, h = c - a + 1;
618
619
  if (c > l)
619
620
  return this._handleNull();
620
- const d = [], u = [], f = a, g = {
621
+ const u = [], d = [], f = a, g = {
621
622
  unitId: e,
622
623
  subUnitId: t,
623
624
  range: {
@@ -630,13 +631,13 @@ let W = class extends V {
630
631
  subUnitId: t,
631
632
  range: s
632
633
  };
633
- d.push({ id: R.id, params: g }), u.push({ id: R.id, params: C });
634
+ u.push({ id: R.id, params: g }), d.push({ id: R.id, params: C });
634
635
  const F = n.getAllFilterColumns().filter((m) => m[0] >= f);
635
636
  if (F.length !== 0) {
636
637
  const { newRange: m, oldRange: v } = this._moveCriteria(e, t, F, h);
637
- d.push(...m.redos, ...v.redos), u.push(...m.undos, ...v.undos);
638
+ u.push(...m.redos, ...v.redos), d.push(...m.undos, ...v.undos);
638
639
  }
639
- return { redos: I(d), undos: I(u) };
640
+ return { redos: I(u), undos: I(d) };
640
641
  }
641
642
  _handleInsertRowCommand(r, e, t) {
642
643
  var C;
@@ -646,7 +647,7 @@ let W = class extends V {
646
647
  const { startRow: o, endRow: l } = s, { startRow: a, endRow: c } = r.range, h = c - a + 1;
647
648
  if (c > l)
648
649
  return this._handleNull();
649
- const d = [], u = [], f = {
650
+ const u = [], d = [], f = {
650
651
  unitId: e,
651
652
  subUnitId: t,
652
653
  range: {
@@ -659,9 +660,9 @@ let W = class extends V {
659
660
  subUnitId: t,
660
661
  range: s
661
662
  };
662
- return d.push({ id: R.id, params: f }), u.push({ id: R.id, params: g }), {
663
- redos: I(d),
664
- undos: I(u)
663
+ return u.push({ id: R.id, params: f }), d.push({ id: R.id, params: g }), {
664
+ redos: I(u),
665
+ undos: I(d)
665
666
  };
666
667
  }
667
668
  _handleRemoveColCommand(r, e, t) {
@@ -672,10 +673,10 @@ let W = class extends V {
672
673
  const { startColumn: o, endColumn: l } = s, { startColumn: a, endColumn: c } = r.range;
673
674
  if (a > l)
674
675
  return this._handleNull();
675
- const h = [], d = [], u = c < o ? 0 : Math.min(c, l) - Math.max(a, o) + 1, f = c - a + 1, g = n.getAllFilterColumns();
676
+ const h = [], u = [], d = c < o ? 0 : Math.min(c, l) - Math.max(a, o) + 1, f = c - a + 1, g = n.getAllFilterColumns();
676
677
  g.forEach((_) => {
677
678
  const [m, v] = _;
678
- m <= c && m >= a && (h.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 } } }));
679
+ m <= c && m >= a && (h.push({ id: p.id, params: { unitId: e, subUnitId: t, col: m, criteria: null } }), u.push({ id: p.id, params: { unitId: e, subUnitId: t, col: m, criteria: { ...v.serialize(), colId: m } } }));
679
680
  });
680
681
  const C = g.filter((_) => {
681
682
  const [m, v] = _;
@@ -684,24 +685,24 @@ let W = class extends V {
684
685
  let S = { undos: [], redos: [] };
685
686
  if (C.length > 0) {
686
687
  const { oldRange: _, newRange: m } = this._moveCriteria(e, t, C, -f);
687
- S = m, h.push(..._.redos), d.unshift(..._.undos);
688
+ S = m, h.push(..._.redos), u.unshift(..._.undos);
688
689
  }
689
- if (u === l - o + 1) {
690
+ if (d === l - o + 1) {
690
691
  const _ = {
691
692
  unitId: e,
692
693
  subUnitId: t
693
694
  };
694
- h.push({ id: O.id, params: _ }), d.unshift({ id: R.id, params: { range: s, unitId: e, subUnitId: t } });
695
+ h.push({ id: y.id, params: _ }), u.unshift({ id: R.id, params: { range: s, unitId: e, subUnitId: t } });
695
696
  } else {
696
- const _ = o <= a ? o : u === 0 ? o - f : a, m = o <= a ? l - u : l - f, v = {
697
+ const _ = o <= a ? o : d === 0 ? o - f : a, m = o <= a ? l - d : l - f, v = {
697
698
  unitId: e,
698
699
  subUnitId: t,
699
700
  range: { ...s, startColumn: _, endColumn: m }
700
701
  };
701
- h.push({ id: R.id, params: v }), d.unshift({ id: R.id, params: { range: s, unitId: e, subUnitId: t } }), h.push(...S.redos), d.unshift(...S.undos);
702
+ h.push({ id: R.id, params: v }), u.unshift({ id: R.id, params: { range: s, unitId: e, subUnitId: t } }), h.push(...S.redos), u.unshift(...S.undos);
702
703
  }
703
704
  return {
704
- undos: d,
705
+ undos: u,
705
706
  redos: h
706
707
  };
707
708
  }
@@ -729,30 +730,30 @@ let W = class extends V {
729
730
  }
730
731
  }]
731
732
  };
732
- const h = [], d = [], u = n.getAllFilterColumns(), f = o <= c && o >= a;
733
- d.push({ id: R.id, params: { range: s, unitId: e, subUnitId: t } });
733
+ const h = [], u = [], d = n.getAllFilterColumns(), f = o <= c && o >= a;
734
+ u.push({ id: R.id, params: { range: s, unitId: e, subUnitId: t } });
734
735
  const g = Math.min(c, l) - Math.max(a, o) + 1;
735
736
  if (g === l - o + 1 || f) {
736
737
  const S = {
737
738
  unitId: e,
738
739
  subUnitId: t
739
740
  };
740
- h.push({ id: O.id, params: S }), u.forEach((F) => {
741
+ h.push({ id: y.id, params: S }), d.forEach((F) => {
741
742
  const [_, m] = F, v = {
742
743
  unitId: e,
743
744
  subUnitId: t,
744
745
  col: _,
745
746
  criteria: { ...m.serialize(), colId: _ }
746
747
  };
747
- d.push({ id: p.id, params: v });
748
+ u.push({ id: p.id, params: v });
748
749
  });
749
750
  } else {
750
751
  const S = (C = this._univerInstanceService.getUniverSheetInstance(e)) == null ? void 0 : C.getSheetBySheetId(t);
751
752
  if (!S)
752
753
  return this._handleNull();
753
754
  const F = [];
754
- for (let y = a; y <= c; y++)
755
- S.getRowFiltered(y) && F.push(y);
755
+ for (let O = a; O <= c; O++)
756
+ S.getRowFiltered(O) && F.push(O);
756
757
  const _ = Math.min(o, a), m = _ + (l - o) - g + F.length, v = {
757
758
  unitId: e,
758
759
  subUnitId: t,
@@ -765,7 +766,7 @@ let W = class extends V {
765
766
  h.push({ id: R.id, params: v });
766
767
  }
767
768
  return {
768
- undos: I(d),
769
+ undos: I(u),
769
770
  redos: I(h)
770
771
  };
771
772
  }
@@ -778,42 +779,42 @@ let W = class extends V {
778
779
  const { startColumn: o, endColumn: l } = s, { fromRange: a, toRange: c } = r;
779
780
  if (a.endColumn < o && c.startColumn <= o || a.startColumn > l && c.endColumn > l)
780
781
  return this._handleNull();
781
- const h = [], d = [], u = {};
782
+ const h = [], u = [], d = {};
782
783
  for (let m = o; m <= l; m++)
783
- u[m] = {
784
+ d[m] = {
784
785
  colIndex: m,
785
786
  filter: n.getFilterColumn(m)
786
787
  };
787
- ee(a.startColumn, a.endColumn - a.startColumn + 1, c.startColumn, u);
788
+ re(a.startColumn, a.endColumn - a.startColumn + 1, c.startColumn, d);
788
789
  let f = s.startColumn, g = s.endColumn;
789
790
  o >= a.startColumn && o <= a.endColumn && c.startColumn > a.startColumn && a.endColumn < l && (f = a.endColumn + 1), l >= a.startColumn && l <= a.endColumn && c.startColumn < a.startColumn && a.startColumn > o && (g = a.startColumn - 1);
790
- const C = Object.keys(u).map((m) => Number(m)), S = C.find((m) => u[m].colIndex === g), F = C.find((m) => u[m].colIndex === f);
791
+ const C = Object.keys(d).map((m) => Number(m)), S = C.find((m) => d[m].colIndex === g), F = C.find((m) => d[m].colIndex === f);
791
792
  if (C.forEach((m) => {
792
- var K, X;
793
- const { colIndex: v, filter: y } = u[m], A = m;
794
- if (y) {
793
+ var Z, ee;
794
+ const { colIndex: v, filter: O } = d[m], A = m;
795
+ if (O) {
795
796
  if (A >= F && A <= S) {
796
- const k = {
797
+ const q = {
797
798
  unitId: e,
798
799
  subUnitId: t,
799
800
  col: A,
800
- criteria: { ...y.serialize(), colId: A }
801
- }, pe = {
801
+ criteria: { ...O.serialize(), colId: A }
802
+ }, Se = {
802
803
  unitId: e,
803
804
  subUnitId: t,
804
805
  col: A,
805
- criteria: n.getFilterColumn(A) ? { ...(K = n.getFilterColumn(A)) == null ? void 0 : K.serialize(), colId: A } : null
806
+ criteria: n.getFilterColumn(A) ? { ...(Z = n.getFilterColumn(A)) == null ? void 0 : Z.serialize(), colId: A } : null
806
807
  };
807
- h.push({ id: p.id, params: k }), d.push({ id: p.id, params: pe });
808
+ h.push({ id: p.id, params: q }), u.push({ id: p.id, params: Se });
808
809
  }
809
- if (!((X = u[v]) != null && X.filter)) {
810
- const k = {
810
+ if (!((ee = d[v]) != null && ee.filter)) {
811
+ const q = {
811
812
  unitId: e,
812
813
  subUnitId: t,
813
814
  col: v,
814
815
  criteria: null
815
816
  };
816
- h.push({ id: p.id, params: k }), d.push({ id: p.id, params: { unitId: e, subUnitId: t, col: v, criteria: { ...y.serialize(), colId: v } } });
817
+ h.push({ id: p.id, params: q }), u.push({ id: p.id, params: { unitId: e, subUnitId: t, col: v, criteria: { ...O.serialize(), colId: v } } });
817
818
  }
818
819
  }
819
820
  }), o !== F || l !== S) {
@@ -826,10 +827,10 @@ let W = class extends V {
826
827
  endColumn: S
827
828
  }
828
829
  };
829
- h.unshift({ id: R.id, params: m }), d.unshift({ id: R.id, params: { range: s, unitId: e, subUnitId: t } });
830
+ h.unshift({ id: R.id, params: m }), u.unshift({ id: R.id, params: { range: s, unitId: e, subUnitId: t } });
830
831
  }
831
832
  return {
832
- undos: d,
833
+ undos: u,
833
834
  redos: h
834
835
  };
835
836
  }
@@ -841,15 +842,15 @@ let W = class extends V {
841
842
  const { startRow: o, endRow: l } = s, { fromRange: a, toRange: c } = r;
842
843
  if (a.endRow < o && c.startRow <= o || a.startRow > l && c.endRow > l)
843
844
  return this._handleNull();
844
- const h = [], d = [], u = {};
845
+ const h = [], u = [], d = {};
845
846
  for (let m = o; m <= l; m++)
846
- u[m] = {
847
+ d[m] = {
847
848
  oldIndex: m
848
849
  };
849
850
  const f = o;
850
851
  let g = l;
851
- l >= a.startRow && l <= a.endRow && c.startRow < a.startRow && a.startRow > o && (g = a.startRow - 1), ee(a.startRow, a.endRow - a.startRow + 1, c.startRow, u);
852
- const C = Object.keys(u).map((m) => Number(m)), S = C.find((m) => u[m].oldIndex === g), F = C.find((m) => u[m].oldIndex === f);
852
+ l >= a.startRow && l <= a.endRow && c.startRow < a.startRow && a.startRow > o && (g = a.startRow - 1), re(a.startRow, a.endRow - a.startRow + 1, c.startRow, d);
853
+ const C = Object.keys(d).map((m) => Number(m)), S = C.find((m) => d[m].oldIndex === g), F = C.find((m) => d[m].oldIndex === f);
853
854
  if (o !== F || l !== S) {
854
855
  const m = {
855
856
  unitId: e,
@@ -860,11 +861,11 @@ let W = class extends V {
860
861
  endRow: S
861
862
  }
862
863
  };
863
- h.push({ id: R.id, params: m }, { id: H.id, params: { unitId: e, subUnitId: t } }), d.push({ id: R.id, params: { range: s, unitId: e, subUnitId: t } }, { id: H.id, params: { unitId: e, subUnitId: t } });
864
+ h.push({ id: R.id, params: m }, { id: z.id, params: { unitId: e, subUnitId: t } }), u.push({ id: R.id, params: { range: s, unitId: e, subUnitId: t } }, { id: z.id, params: { unitId: e, subUnitId: t } });
864
865
  }
865
866
  return {
866
867
  redos: h,
867
- undos: d
868
+ undos: u
868
869
  };
869
870
  }
870
871
  _handleMoveRangeCommand(r, e, t) {
@@ -875,26 +876,26 @@ let W = class extends V {
875
876
  if (!l)
876
877
  return this._handleNull();
877
878
  const a = [], c = [];
878
- if (J.contains(n, l)) {
879
- const h = l.startRow - n.startRow, d = l.startColumn - n.startColumn, u = {
879
+ if (K.contains(n, l)) {
880
+ const h = l.startRow - n.startRow, u = l.startColumn - n.startColumn, d = {
880
881
  startRow: s.startRow + h,
881
- startColumn: s.startColumn + d,
882
+ startColumn: s.startColumn + u,
882
883
  endRow: s.startRow + h + (l.endRow - l.startRow),
883
- endColumn: s.startColumn + d + (l.endColumn - l.startColumn)
884
+ endColumn: s.startColumn + u + (l.endColumn - l.startColumn)
884
885
  }, f = {
885
- id: O.id,
886
+ id: y.id,
886
887
  params: {
887
888
  unitId: e,
888
889
  subUnitId: t
889
890
  }
890
- }, g = { id: R.id, params: { unitId: e, subUnitId: t, range: u } }, C = { id: R.id, params: { unitId: e, subUnitId: t, range: l } };
891
+ }, g = { id: R.id, params: { unitId: e, subUnitId: t, range: d } }, C = { id: R.id, params: { unitId: e, subUnitId: t, range: l } };
891
892
  a.push(f, g), c.push(f, C);
892
893
  const S = o.getAllFilterColumns(), F = s.startColumn - n.startColumn;
893
894
  S.forEach((_) => {
894
895
  const [m, v] = _;
895
896
  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 } } }));
896
897
  });
897
- } else if (J.intersects(s, l)) {
898
+ } else if (K.intersects(s, l)) {
898
899
  const h = {
899
900
  ...l,
900
901
  endRow: Math.max(l.endRow, s.endRow)
@@ -916,7 +917,7 @@ let W = class extends V {
916
917
  const o = [], l = [];
917
918
  return n.getAllFilterColumns().forEach(([c, h]) => {
918
919
  l.push({ id: p.id, params: { unitId: e, subUnitId: t, col: c, criteria: { ...h.serialize(), colId: c } } });
919
- }), o.push({ id: O.id, params: { unitId: e, subUnitId: t, range: s } }), l.unshift({ id: R.id, params: { range: s, unitId: e, subUnitId: t } }), {
920
+ }), o.push({ id: y.id, params: { unitId: e, subUnitId: t, range: s } }), l.unshift({ id: R.id, params: { range: s, unitId: e, subUnitId: t } }), {
920
921
  undos: l,
921
922
  redos: o
922
923
  };
@@ -929,9 +930,9 @@ let W = class extends V {
929
930
  if (!s)
930
931
  return this._handleNull();
931
932
  const o = [], l = [], a = [], c = [];
932
- return n.getAllFilterColumns().forEach(([d, u]) => {
933
- o.push({ id: p.id, params: { unitId: r, subUnitId: t, col: d, criteria: { ...u.serialize(), colId: d } } }), a.push({ id: p.id, params: { unitId: r, subUnitId: t, col: d, criteria: null } });
934
- }), a.push({ id: O.id, params: { unitId: r, subUnitId: t, range: s } }), o.unshift({ id: R.id, params: { range: s, unitId: r, subUnitId: t } }), {
933
+ return n.getAllFilterColumns().forEach(([u, d]) => {
934
+ o.push({ id: p.id, params: { unitId: r, subUnitId: t, col: u, criteria: { ...d.serialize(), colId: u } } }), a.push({ id: p.id, params: { unitId: r, subUnitId: t, col: u, criteria: null } });
935
+ }), a.push({ id: y.id, params: { unitId: r, subUnitId: t, range: s } }), o.unshift({ id: R.id, params: { range: s, unitId: r, subUnitId: t } }), {
935
936
  undos: l,
936
937
  redos: o,
937
938
  preUndos: a,
@@ -942,7 +943,7 @@ let W = class extends V {
942
943
  return { redos: [], undos: [] };
943
944
  }
944
945
  _initRowFilteredInterceptor() {
945
- this.disposeWithMe(this._sheetInterceptorService.intercept(ze.ROW_FILTERED, {
946
+ this.disposeWithMe(this._sheetInterceptorService.intercept(Ve.ROW_FILTERED, {
946
947
  // sheet-interceptor.service.ts
947
948
  handler: (r, e) => {
948
949
  var t, n;
@@ -961,35 +962,35 @@ let W = class extends V {
961
962
  col: -1
962
963
  }, o = [], l = [], a = [], c = [];
963
964
  return t.forEach((h) => {
964
- const [d, u] = h;
965
+ const [u, d] = h;
965
966
  l.push({
966
967
  id: p.id,
967
968
  params: {
968
969
  ...s,
969
- col: d
970
+ col: u
970
971
  }
971
972
  }), o.push({
972
973
  id: p.id,
973
974
  params: {
974
975
  ...s,
975
- col: d,
976
- criteria: { ...u.serialize(), colId: d }
976
+ col: u,
977
+ criteria: { ...d.serialize(), colId: u }
977
978
  }
978
979
  });
979
980
  }), t.forEach((h) => {
980
- const [d, u] = h;
981
+ const [u, d] = h;
981
982
  c.push({
982
983
  id: p.id,
983
984
  params: {
984
985
  ...s,
985
- col: d + n,
986
- criteria: { ...u.serialize(), colId: d + n }
986
+ col: u + n,
987
+ criteria: { ...d.serialize(), colId: u + n }
987
988
  }
988
989
  }), a.push({
989
990
  id: p.id,
990
991
  params: {
991
992
  ...s,
992
- col: d + n,
993
+ col: u + n,
993
994
  criteria: null
994
995
  }
995
996
  });
@@ -1009,37 +1010,37 @@ let W = class extends V {
1009
1010
  var c, h;
1010
1011
  const { unitId: t, subUnitId: n } = r.params || {}, s = this._sheetsFilterService.getFilterModel(t, n);
1011
1012
  if (!s) return;
1012
- const o = Array.from(s.filteredOutRows).sort((d, u) => d - u), l = [];
1013
+ const o = Array.from(s.filteredOutRows).sort((u, d) => u - d), l = [];
1013
1014
  let a = !1;
1014
- if (r.id === He.id) {
1015
- const { startRow: d, endRow: u } = r.params.range, f = o.filter((g) => g >= d && g <= u);
1015
+ if (r.id === je.id) {
1016
+ const { startRow: u, endRow: d } = r.params.range, f = o.filter((g) => g >= u && g <= d);
1016
1017
  o.forEach((g) => {
1017
- if (g < d)
1018
+ if (g < u)
1018
1019
  l.push(g);
1019
- else if (a = !0, g <= u) {
1020
- const C = Math.max(d, l.length ? l[l.length - 1] + 1 : d);
1020
+ else if (a = !0, g <= d) {
1021
+ const C = Math.max(u, l.length ? l[l.length - 1] + 1 : u);
1021
1022
  l.push(C);
1022
1023
  } else
1023
- l.push(g - (u - d + 1 - f.length));
1024
+ l.push(g - (d - u + 1 - f.length));
1024
1025
  });
1025
1026
  }
1026
- if (r.id === De.id) {
1027
- const { startRow: d, endRow: u } = r.params.range;
1027
+ if (r.id === ke.id) {
1028
+ const { startRow: u, endRow: d } = r.params.range;
1028
1029
  o.forEach((f) => {
1029
- f >= d ? (a = !0, l.push(f + (u - d + 1))) : l.push(f);
1030
+ f >= u ? (a = !0, l.push(f + (d - u + 1))) : l.push(f);
1030
1031
  });
1031
1032
  }
1032
- if (a && (s.filteredOutRows = new Set(l)), r.id === We.id && !(e != null && e.onlyLocal)) {
1033
- const d = this._getExtendRegion(t, n);
1034
- if (d) {
1035
- const u = r.params.cellValue;
1036
- if (u)
1037
- for (let f = d.startColumn; f <= d.endColumn; f++) {
1038
- const g = (c = u == null ? void 0 : u[d.startRow]) == null ? void 0 : c[f];
1033
+ if (a && (s.filteredOutRows = new Set(l)), r.id === qe.id && !(e != null && e.onlyLocal)) {
1034
+ const u = this._getExtendRegion(t, n);
1035
+ if (u) {
1036
+ const d = r.params.cellValue;
1037
+ if (d)
1038
+ for (let f = u.startColumn; f <= u.endColumn; f++) {
1039
+ const g = (c = d == null ? void 0 : d[u.startRow]) == null ? void 0 : c[f];
1039
1040
  if (g && this._cellHasValue(g)) {
1040
1041
  const C = (h = this._univerInstanceService.getUnit(t)) == null ? void 0 : h.getSheetBySheetId(n);
1041
1042
  if (C) {
1042
- const S = ae(d, { down: !0 }, C), F = this._sheetsFilterService.getFilterModel(t, n), _ = F.getRange();
1043
+ const S = ue(u, { down: !0 }, C), F = this._sheetsFilterService.getFilterModel(t, n), _ = F.getRange();
1043
1044
  F.setRange({
1044
1045
  ..._,
1045
1046
  endRow: S.endRow
@@ -1080,7 +1081,7 @@ let W = class extends V {
1080
1081
  const { subUnitId: n, unitId: s } = t, o = this._sheetsFilterService.getFilterModel(s, n);
1081
1082
  if (!o) return;
1082
1083
  const l = o.getRange();
1083
- if (r.id === Ve.id && e.fromRange.startRow <= l.startRow && e.fromRange.endRow < l.endRow && e.fromRange.endRow >= l.startRow)
1084
+ if (r.id === Qe.id && e.fromRange.startRow <= l.startRow && e.fromRange.endRow < l.endRow && e.fromRange.endRow >= l.startRow)
1084
1085
  throw this._sheetsFilterService.setFilterErrorMsg("sheets-filter.msg.filter-header-forbidden"), new Error("[SheetsFilterController]: Cannot move header row of filter");
1085
1086
  }));
1086
1087
  }
@@ -1089,101 +1090,158 @@ let W = class extends V {
1089
1090
  return !(e.length === 0 || e.every((t) => t == null));
1090
1091
  }
1091
1092
  };
1092
- W = Et([
1093
- U(0, T),
1094
- U(1, z(Ue)),
1095
- U(2, z(M)),
1096
- U(3, x),
1097
- U(4, z(Pe))
1098
- ], W);
1099
- var Ot = Object.getOwnPropertyDescriptor, yt = (i, r, e, t) => {
1100
- for (var n = t > 1 ? void 0 : t ? Ot(r, e) : r, s = i.length - 1, o; s >= 0; s--)
1093
+ V = Tt([
1094
+ P(0, N),
1095
+ P(1, $(Be)),
1096
+ P(2, $(M)),
1097
+ P(3, T),
1098
+ P(4, $(be))
1099
+ ], V);
1100
+ var Nt = Object.getOwnPropertyDescriptor, xt = (i, r, e, t) => {
1101
+ for (var n = t > 1 ? void 0 : t ? Nt(r, e) : r, s = i.length - 1, o; s >= 0; s--)
1102
+ (o = i[s]) && (n = o(n) || n);
1103
+ return n;
1104
+ }, Y = (i, r) => (e, t) => r(e, t, i);
1105
+ let j = class extends B {
1106
+ constructor(i, r, e) {
1107
+ super(), this._activeDirtyManagerService = i, this._sheetsFilterService = r, this._univerInstanceService = e, this._initFormulaDirtyRange();
1108
+ }
1109
+ _initFormulaDirtyRange() {
1110
+ ge.forEach((i) => {
1111
+ this._activeDirtyManagerService.register(
1112
+ i,
1113
+ {
1114
+ commandId: i,
1115
+ getDirtyData: (r) => {
1116
+ const e = r.params, { unitId: t, subUnitId: n } = e;
1117
+ return {
1118
+ dirtyRanges: this._getHideRowMutation(t, n),
1119
+ clearDependencyTreeCache: {
1120
+ [t]: {
1121
+ [n]: "1"
1122
+ }
1123
+ }
1124
+ };
1125
+ }
1126
+ }
1127
+ );
1128
+ });
1129
+ }
1130
+ _getHideRowMutation(i, r) {
1131
+ var l, a;
1132
+ 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);
1133
+ if (e == null || t == null)
1134
+ return [];
1135
+ const { startRow: n, endRow: s } = e;
1136
+ return [{
1137
+ unitId: i,
1138
+ sheetId: r,
1139
+ range: {
1140
+ startRow: n,
1141
+ startColumn: 0,
1142
+ endRow: s,
1143
+ endColumn: t.getColumnCount() - 1
1144
+ }
1145
+ }];
1146
+ }
1147
+ };
1148
+ j = xt([
1149
+ Y(0, $(st)),
1150
+ Y(1, $(M)),
1151
+ Y(2, T)
1152
+ ], j);
1153
+ var It = Object.getOwnPropertyDescriptor, $t = (i, r, e, t) => {
1154
+ for (var n = t > 1 ? void 0 : t ? It(r, e) : r, s = i.length - 1, o; s >= 0; s--)
1101
1155
  (o = i[s]) && (n = o(n) || n);
1102
1156
  return n;
1103
- }, oe = (i, r) => (e, t) => r(e, t, i), B;
1104
- let le = (B = class extends ye {
1105
- constructor(i = re, r, e) {
1157
+ }, ae = (i, r) => (e, t) => r(e, t, i), H;
1158
+ let ce = (H = class extends Ne {
1159
+ constructor(i = ie, r, e) {
1106
1160
  super(), this._config = i, this._injector = r, this._configService = e;
1107
- const { ...t } = Ae(
1161
+ const { ...t } = xe(
1108
1162
  {},
1109
- re,
1163
+ ie,
1110
1164
  this._config
1111
1165
  );
1112
- this._configService.setConfig(tt, t);
1166
+ this._configService.setConfig(ot, t);
1113
1167
  }
1114
1168
  onStarting() {
1115
1169
  [
1170
+ [j],
1116
1171
  [M],
1117
- [W]
1172
+ [V]
1118
1173
  ].forEach((i) => this._injector.add(i));
1119
1174
  }
1120
1175
  onReady() {
1121
- this._injector.get(W);
1122
- }
1123
- }, w(B, "type", P.UNIVER_SHEET), w(B, "pluginName", Re), B);
1124
- le = yt([
1125
- oe(1, z(Te)),
1126
- oe(2, Ne)
1127
- ], le);
1128
- const At = {
1176
+ Ie(this._injector, [
1177
+ [j],
1178
+ [V]
1179
+ ]);
1180
+ }
1181
+ }, w(H, "type", D.UNIVER_SHEET), w(H, "pluginName", Fe), H);
1182
+ ce = $t([
1183
+ ae(1, $($e)),
1184
+ ae(2, Ue)
1185
+ ], ce);
1186
+ const Ut = {
1129
1187
  id: "sheet.command.set-filter-range",
1130
1188
  type: E.COMMAND,
1131
1189
  handler: (i, r) => {
1132
- const e = i.get(M), t = i.get(T), n = i.get(j), s = i.get(x), { unitId: o, subUnitId: l, range: a } = r;
1190
+ const e = i.get(M), t = i.get(N), n = i.get(k), s = i.get(T), { unitId: o, subUnitId: l, range: a } = r;
1133
1191
  if (!b(s, r) || e.getFilterModel(o, l)) return !1;
1134
1192
  if (a.endRow === a.startRow) {
1135
- const f = i.get(Ie), g = i.get($e);
1193
+ const f = i.get(De), g = i.get(Le);
1136
1194
  return f.emit(g.t("sheets-filter.command.not-valid-filter-range")), !1;
1137
1195
  }
1138
- const d = { id: R.id, params: { unitId: o, subUnitId: l, range: a } }, u = t.syncExecuteCommand(d.id, d.params);
1139
- return u && n.pushUndoRedo({
1196
+ const u = { id: R.id, params: { unitId: o, subUnitId: l, range: a } }, d = t.syncExecuteCommand(u.id, u.params);
1197
+ return d && n.pushUndoRedo({
1140
1198
  unitID: o,
1141
- undoMutations: [{ id: O.id, params: { unitId: o, subUnitId: l } }],
1142
- redoMutations: [d]
1143
- }), u;
1199
+ undoMutations: [{ id: y.id, params: { unitId: o, subUnitId: l } }],
1200
+ redoMutations: [u]
1201
+ }), d;
1144
1202
  }
1145
- }, Tt = {
1203
+ }, Pt = {
1146
1204
  id: "sheet.command.remove-sheet-filter",
1147
1205
  type: E.COMMAND,
1148
1206
  handler: (i, r) => {
1149
- const e = i.get(x), t = i.get(M), n = i.get(T), s = i.get(j), o = b(e, r);
1207
+ const e = i.get(T), t = i.get(M), n = i.get(N), s = i.get(k), o = b(e, r);
1150
1208
  if (!o) return !1;
1151
1209
  const { unitId: l, subUnitId: a } = o, c = t.getFilterModel(l, a);
1152
1210
  if (!c) return !1;
1153
- const h = c == null ? void 0 : c.serialize(), d = Nt(l, a, h), u = n.syncExecuteCommand(O.id, { unitId: l, subUnitId: a });
1154
- return u && s.pushUndoRedo({
1211
+ const h = c == null ? void 0 : c.serialize(), u = Dt(l, a, h), d = n.syncExecuteCommand(y.id, { unitId: l, subUnitId: a });
1212
+ return d && s.pushUndoRedo({
1155
1213
  unitID: l,
1156
- undoMutations: d,
1157
- redoMutations: [{ id: O.id, params: { unitId: l, subUnitId: a } }]
1158
- }), u;
1214
+ undoMutations: u,
1215
+ redoMutations: [{ id: y.id, params: { unitId: l, subUnitId: a } }]
1216
+ }), d;
1159
1217
  }
1160
- }, bt = {
1218
+ }, jt = {
1161
1219
  id: "sheet.command.smart-toggle-filter",
1162
1220
  type: E.COMMAND,
1163
1221
  handler: async (i) => {
1164
- const r = i.get(x), e = i.get(M), t = i.get(T), n = r.getCurrentUnitForType(P.UNIVER_SHEET), s = n == null ? void 0 : n.getActiveSheet();
1222
+ 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();
1165
1223
  if (!s || !n) return !1;
1166
1224
  const o = n.getUnitId(), l = s.getSheetId();
1167
1225
  if (e.getFilterModel(o, l))
1168
- return t.executeCommand(Tt.id, { unitId: o, subUnitId: l });
1169
- const h = i.get(Je).getCurrentLastSelection();
1226
+ return t.executeCommand(Pt.id, { unitId: o, subUnitId: l });
1227
+ const h = i.get(Ze).getCurrentLastSelection();
1170
1228
  if (!h) return !1;
1171
- const d = h.range, u = Ye(h) ? ae(d, { left: !0, right: !0, up: !0, down: !0 }, s) : d;
1172
- return t.executeCommand(At.id, {
1229
+ const u = h.range, d = et(h) ? ue(u, { left: !0, right: !0, up: !0, down: !0 }, s) : u;
1230
+ return t.executeCommand(Ut.id, {
1173
1231
  unitId: o,
1174
1232
  subUnitId: l,
1175
- range: u
1233
+ range: d
1176
1234
  });
1177
1235
  }
1178
- }, Bt = {
1236
+ }, kt = {
1179
1237
  id: "sheet.command.set-filter-criteria",
1180
1238
  type: E.COMMAND,
1181
1239
  handler: (i, r) => {
1182
- const e = i.get(M), t = i.get(T), n = i.get(j), { unitId: s, subUnitId: o, col: l, criteria: a } = r, c = e.getFilterModel(s, o);
1240
+ const e = i.get(M), t = i.get(N), n = i.get(k), { unitId: s, subUnitId: o, col: l, criteria: a } = r, c = e.getFilterModel(s, o);
1183
1241
  if (!c) return !1;
1184
1242
  const h = c.getRange();
1185
1243
  if (!h || l < h.startColumn || l > h.endColumn) return !1;
1186
- const d = c.getFilterColumn(l), u = It(s, o, l, d), f = {
1244
+ const u = c.getFilterColumn(l), d = Bt(s, o, l, u), f = {
1187
1245
  id: p.id,
1188
1246
  params: {
1189
1247
  unitId: s,
@@ -1194,36 +1252,36 @@ const At = {
1194
1252
  }, g = t.syncExecuteCommand(f.id, f.params);
1195
1253
  return g && n.pushUndoRedo({
1196
1254
  unitID: s,
1197
- undoMutations: [u],
1255
+ undoMutations: [d],
1198
1256
  redoMutations: [f]
1199
1257
  }), g;
1200
1258
  }
1201
- }, zt = {
1259
+ }, qt = {
1202
1260
  id: "sheet.command.clear-filter-criteria",
1203
1261
  type: E.COMMAND,
1204
1262
  handler: (i, r) => {
1205
- const e = i.get(M), t = i.get(j), n = i.get(T), s = i.get(x), o = b(s, r);
1263
+ const e = i.get(M), t = i.get(k), n = i.get(N), s = i.get(T), o = b(s, r);
1206
1264
  if (!o) return !1;
1207
1265
  const { unitId: l, subUnitId: a } = o, c = e.getFilterModel(o.unitId, o.subUnitId);
1208
1266
  if (!c) return !1;
1209
- const h = c.serialize(), d = Ce(l, a, h), u = xt(l, a, h);
1210
- return xe(u, n).result ? (t.pushUndoRedo({
1267
+ const h = c.serialize(), u = we(l, a, h), d = Lt(l, a, h);
1268
+ return Pe(d, n).result ? (t.pushUndoRedo({
1211
1269
  unitID: l,
1212
- undoMutations: d,
1213
- redoMutations: u
1270
+ undoMutations: u,
1271
+ redoMutations: d
1214
1272
  }), !0) : !1;
1215
1273
  }
1216
- }, Ht = {
1274
+ }, Qt = {
1217
1275
  id: "sheet.command.re-calc-filter",
1218
1276
  type: E.COMMAND,
1219
1277
  handler: (i, r) => {
1220
- const e = i.get(M), t = i.get(T), n = i.get(x), s = b(n, r);
1278
+ const e = i.get(M), t = i.get(N), n = i.get(T), s = b(n, r);
1221
1279
  if (!s) return !1;
1222
1280
  const { unitId: o, subUnitId: l } = s;
1223
- return e.getFilterModel(s.unitId, s.subUnitId) ? t.executeCommand(H.id, { unitId: o, subUnitId: l }) : !1;
1281
+ return e.getFilterModel(s.unitId, s.subUnitId) ? t.executeCommand(z.id, { unitId: o, subUnitId: l }) : !1;
1224
1282
  }
1225
1283
  };
1226
- function Nt(i, r, e) {
1284
+ function Dt(i, r, e) {
1227
1285
  const t = [], n = {
1228
1286
  id: R.id,
1229
1287
  params: {
@@ -1232,9 +1290,9 @@ function Nt(i, r, e) {
1232
1290
  range: e.ref
1233
1291
  }
1234
1292
  };
1235
- return t.push(n), Ce(i, r, e).forEach((o) => t.push(o)), t;
1293
+ return t.push(n), we(i, r, e).forEach((o) => t.push(o)), t;
1236
1294
  }
1237
- function Ce(i, r, e) {
1295
+ function we(i, r, e) {
1238
1296
  var n;
1239
1297
  const t = [];
1240
1298
  return (n = e.filterColumns) == null || n.forEach((s) => {
@@ -1250,7 +1308,7 @@ function Ce(i, r, e) {
1250
1308
  t.push(o);
1251
1309
  }), t;
1252
1310
  }
1253
- function xt(i, r, e) {
1311
+ function Lt(i, r, e) {
1254
1312
  var n;
1255
1313
  const t = [];
1256
1314
  return (n = e.filterColumns) == null || n.forEach((s) => {
@@ -1266,7 +1324,7 @@ function xt(i, r, e) {
1266
1324
  t.push(o);
1267
1325
  }), t;
1268
1326
  }
1269
- function It(i, r, e, t) {
1327
+ function Bt(i, r, e, t) {
1270
1328
  if (!t)
1271
1329
  return {
1272
1330
  id: p.id,
@@ -1289,28 +1347,28 @@ function It(i, r, e, t) {
1289
1347
  };
1290
1348
  }
1291
1349
  export {
1292
- zt as ClearSheetsFilterCriteriaCommand,
1293
- N as CustomFilterOperator,
1294
- rt as FILTER_MUTATIONS,
1295
- ht as FilterColumn,
1296
- D as FilterModel,
1297
- Ht as ReCalcSheetsFilterCommand,
1298
- H as ReCalcSheetsFilterMutation,
1299
- Tt as RemoveSheetFilterCommand,
1300
- O as RemoveSheetsFilterMutation,
1301
- Re as SHEET_FILTER_SNAPSHOT_ID,
1302
- At as SetSheetFilterRangeCommand,
1303
- Bt as SetSheetsFilterCriteriaCommand,
1350
+ qt as ClearSheetsFilterCriteriaCommand,
1351
+ x as CustomFilterOperator,
1352
+ ge as FILTER_MUTATIONS,
1353
+ _t as FilterColumn,
1354
+ W as FilterModel,
1355
+ Qt as ReCalcSheetsFilterCommand,
1356
+ z as ReCalcSheetsFilterMutation,
1357
+ Pt as RemoveSheetFilterCommand,
1358
+ y as RemoveSheetsFilterMutation,
1359
+ Fe as SHEET_FILTER_SNAPSHOT_ID,
1360
+ Ut as SetSheetFilterRangeCommand,
1361
+ kt as SetSheetsFilterCriteriaCommand,
1304
1362
  p as SetSheetsFilterCriteriaMutation,
1305
1363
  R as SetSheetsFilterRangeMutation,
1306
1364
  M as SheetsFilterService,
1307
- bt as SmartToggleSheetsFilterCommand,
1308
- le as UniverSheetsFilterPlugin,
1309
- lt as equals,
1310
- ne as getCustomFilterFn,
1311
- nt as greaterThan,
1312
- it as greaterThanOrEqualTo,
1313
- st as lessThan,
1314
- ot as lessThanOrEqualTo,
1315
- me as notEquals
1365
+ jt as SmartToggleSheetsFilterCommand,
1366
+ ce as UniverSheetsFilterPlugin,
1367
+ dt as equals,
1368
+ se as getCustomFilterFn,
1369
+ lt as greaterThan,
1370
+ at as greaterThanOrEqualTo,
1371
+ ct as lessThan,
1372
+ ut as lessThanOrEqualTo,
1373
+ _e as notEquals
1316
1374
  };