@univerjs/sheets-filter 0.10.6 → 0.10.7-nightly.202509080357

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