@univerjs/sheets-data-validation 0.5.5-experimental.20250122-3362a4a → 0.5.5-nightly.202501201606

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,455 +1,448 @@
1
- var __defProp = Object.defineProperty;
2
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value;
3
- var __name = (target, value) => __defProp(target, "name", { value, configurable: !0 });
4
- var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key != "symbol" ? key + "" : key, value);
5
- import { Inject, ICommandService, IUniverInstanceService, Disposable, ObjectMatrix, UniverInstanceType, Range, isFormulaString, DataValidationType, getOriginCellValue, RBush, debounce, Rectangle, Tools, DataValidationStatus, WrapStrategy, DataValidationOperator, numfmt, dayjs, DataValidationRenderMode, CommandType, IUndoRedoService, sequenceExecute, isRangesEqual, generateRandomId, toDisposable, IPermissionService, Injector, CellValueType, RxDisposable, LifecycleService, LifecycleStages, bufferDebounceTime, DependentOn, Plugin, merge, IConfigService } from "@univerjs/core";
6
- import { DataValidationModel, DataValidatorRegistryService, UpdateRuleType, BaseDataValidator, TextLengthErrorTitleMap, AddDataValidationMutation, RemoveDataValidationMutation, UpdateDataValidationMutation, getRuleSetting, getRuleOptions, UniverDataValidationPlugin } from "@univerjs/data-validation";
7
- import { SetRangeValuesMutation, RemoveSheetMutation, getSheetCommandTarget, SetRangeValuesUndoMutationFactory, WorksheetViewPermission, RefRangeService, handleCommonDefaultRangeChangeWithEffectRefCommands, SheetInterceptorService, RemoveSheetCommand, SheetsSelectionsService, ClearSelectionAllCommand } from "@univerjs/sheets";
8
- import { Subject, bufferWhen, filter } from "rxjs";
9
- import { RegisterOtherFormulaService, FormulaRefRangeService } from "@univerjs/sheets-formula";
10
- import { ERROR_TYPE_SET, LexerTreeBuilder, isReferenceString, sequenceNodeType, deserializeRangeWithSheet, deserializeRangeWithSheetWithCache, operatorToken } from "@univerjs/engine-formula";
11
- const DATA_VALIDATION_PLUGIN_NAME = "SHEET_DATA_VALIDATION_PLUGIN";
12
- var __defProp$a = Object.defineProperty, __getOwnPropDesc$a = Object.getOwnPropertyDescriptor, __decorateClass$a = /* @__PURE__ */ __name((decorators, target, key, kind) => {
13
- for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$a(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
14
- (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
15
- return kind && result && __defProp$a(target, key, result), result;
16
- }, "__decorateClass$a"), __decorateParam$a = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$a"), _a;
17
- let DataValidationCacheService = (_a = class extends Disposable {
18
- constructor(_commandService, _univerInstanceService) {
1
+ var Rt = Object.defineProperty;
2
+ var St = (s, a, e) => a in s ? Rt(s, a, { enumerable: !0, configurable: !0, writable: !0, value: e }) : s[a] = e;
3
+ var f = (s, a, e) => St(s, typeof a != "symbol" ? a + "" : a, e);
4
+ import { Inject as S, ICommandService as x, IUniverInstanceService as O, Disposable as $, ObjectMatrix as ve, UniverInstanceType as N, Range as b, isFormulaString as v, DataValidationType as T, getOriginCellValue as vt, RBush as Vt, debounce as Mt, Rectangle as I, Tools as V, DataValidationStatus as D, WrapStrategy as Se, DataValidationOperator as h, numfmt as Q, dayjs as at, DataValidationRenderMode as Be, CommandType as z, IUndoRedoService as Z, sequenceExecute as Ie, isRangesEqual as rt, generateRandomId as yt, toDisposable as qe, IPermissionService as Et, Injector as Ge, CellValueType as Tt, RxDisposable as Ft, LifecycleService as Nt, LifecycleStages as ze, bufferDebounceTime as Ct, DependentOn as Ot, Plugin as wt, merge as It, IConfigService as At } from "@univerjs/core";
5
+ import { DataValidationModel as ke, DataValidatorRegistryService as G, UpdateRuleType as y, BaseDataValidator as k, TextLengthErrorTitleMap as Dt, AddDataValidationMutation as L, RemoveDataValidationMutation as A, UpdateDataValidationMutation as E, getRuleSetting as bt, getRuleOptions as Lt, UniverDataValidationPlugin as xt } from "@univerjs/data-validation";
6
+ import { SetRangeValuesMutation as oe, RemoveSheetMutation as it, getSheetCommandTarget as Ye, SetRangeValuesUndoMutationFactory as st, WorksheetViewPermission as Bt, RefRangeService as Ut, handleCommonDefaultRangeChangeWithEffectRefCommands as Pt, SheetInterceptorService as ot, RemoveSheetCommand as $t, SheetsSelectionsService as nt, ClearSelectionAllCommand as Ht } from "@univerjs/sheets";
7
+ import { Subject as Qe, bufferWhen as Wt, filter as Ze } from "rxjs";
8
+ import { RegisterOtherFormulaService as lt, FormulaRefRangeService as ut } from "@univerjs/sheets-formula";
9
+ import { ERROR_TYPE_SET as jt, LexerTreeBuilder as Y, isReferenceString as dt, sequenceNodeType as Qt, deserializeRangeWithSheet as qt, deserializeRangeWithSheetWithCache as Gt, operatorToken as kt } from "@univerjs/engine-formula";
10
+ const Yt = "SHEET_DATA_VALIDATION_PLUGIN";
11
+ var Xt = Object.defineProperty, Kt = Object.getOwnPropertyDescriptor, zt = (s, a, e, t) => {
12
+ for (var r = t > 1 ? void 0 : t ? Kt(a, e) : a, i = s.length - 1, o; i >= 0; i--)
13
+ (o = s[i]) && (r = (t ? o(a, e, r) : o(r)) || r);
14
+ return t && r && Xt(a, e, r), r;
15
+ }, Je = (s, a) => (e, t) => a(e, t, s);
16
+ let q = class extends $ {
17
+ constructor(a, e) {
19
18
  super();
20
- __publicField(this, "_cacheMatrix", /* @__PURE__ */ new Map());
21
- __publicField(this, "_dirtyRanges$", new Subject());
22
- __publicField(this, "dirtyRanges$", this._dirtyRanges$.asObservable());
23
- this._commandService = _commandService, this._univerInstanceService = _univerInstanceService, this._initDirtyRanges(), this._initSheetRemove();
19
+ f(this, "_cacheMatrix", /* @__PURE__ */ new Map());
20
+ f(this, "_dirtyRanges$", new Qe());
21
+ f(this, "dirtyRanges$", this._dirtyRanges$.asObservable());
22
+ this._commandService = a, this._univerInstanceService = e, this._initDirtyRanges(), this._initSheetRemove();
24
23
  }
25
24
  _initDirtyRanges() {
26
- this.disposeWithMe(this._commandService.onCommandExecuted((commandInfo) => {
27
- if (commandInfo.id === SetRangeValuesMutation.id) {
28
- const { cellValue, unitId, subUnitId } = commandInfo.params;
29
- if (cellValue) {
30
- const range = new ObjectMatrix(cellValue).getDataRange();
31
- if (range.endRow === -1) return;
32
- this.markRangeDirty(unitId, subUnitId, [range]);
25
+ this.disposeWithMe(this._commandService.onCommandExecuted((a) => {
26
+ if (a.id === oe.id) {
27
+ const { cellValue: e, unitId: t, subUnitId: r } = a.params;
28
+ if (e) {
29
+ const i = new ve(e).getDataRange();
30
+ if (i.endRow === -1) return;
31
+ this.markRangeDirty(t, r, [i]);
33
32
  }
34
33
  }
35
34
  }));
36
35
  }
37
36
  _initSheetRemove() {
38
- this.disposeWithMe(this._commandService.onCommandExecuted((commandInfo) => {
39
- var _a12;
40
- if (commandInfo.id === RemoveSheetMutation.id) {
41
- const { unitId, subUnitId } = commandInfo.params;
42
- (_a12 = this._cacheMatrix.get(unitId)) == null || _a12.delete(subUnitId);
37
+ this.disposeWithMe(this._commandService.onCommandExecuted((a) => {
38
+ var e;
39
+ if (a.id === it.id) {
40
+ const { unitId: t, subUnitId: r } = a.params;
41
+ (e = this._cacheMatrix.get(t)) == null || e.delete(r);
43
42
  }
44
- })), this.disposeWithMe(this._univerInstanceService.unitDisposed$.subscribe((univerInstance) => {
45
- univerInstance.type === UniverInstanceType.UNIVER_SHEET && this._cacheMatrix.delete(univerInstance.getUnitId());
43
+ })), this.disposeWithMe(this._univerInstanceService.unitDisposed$.subscribe((a) => {
44
+ a.type === N.UNIVER_SHEET && this._cacheMatrix.delete(a.getUnitId());
46
45
  }));
47
46
  }
48
- _ensureCache(unitId, subUnitId) {
49
- let unitMap = this._cacheMatrix.get(unitId);
50
- unitMap || (unitMap = /* @__PURE__ */ new Map(), this._cacheMatrix.set(unitId, unitMap));
51
- let cacheMatrix = unitMap.get(subUnitId);
52
- return cacheMatrix || (cacheMatrix = new ObjectMatrix(), unitMap.set(subUnitId, cacheMatrix)), cacheMatrix;
47
+ _ensureCache(a, e) {
48
+ let t = this._cacheMatrix.get(a);
49
+ t || (t = /* @__PURE__ */ new Map(), this._cacheMatrix.set(a, t));
50
+ let r = t.get(e);
51
+ return r || (r = new ve(), t.set(e, r)), r;
53
52
  }
54
- ensureCache(unitId, subUnitId) {
55
- return this._ensureCache(unitId, subUnitId);
53
+ ensureCache(a, e) {
54
+ return this._ensureCache(a, e);
56
55
  }
57
- addRule(unitId, subUnitId, rule) {
58
- this.markRangeDirty(unitId, subUnitId, rule.ranges);
56
+ addRule(a, e, t) {
57
+ this.markRangeDirty(a, e, t.ranges);
59
58
  }
60
- removeRule(unitId, subUnitId, rule) {
61
- this._deleteRange(unitId, subUnitId, rule.ranges);
59
+ removeRule(a, e, t) {
60
+ this._deleteRange(a, e, t.ranges);
62
61
  }
63
- markRangeDirty(unitId, subUnitId, ranges) {
64
- const cache = this._ensureCache(unitId, subUnitId);
65
- ranges.forEach((range) => {
66
- Range.foreach(range, (row, col) => {
67
- cache.setValue(row, col, void 0);
62
+ markRangeDirty(a, e, t) {
63
+ const r = this._ensureCache(a, e);
64
+ t.forEach((i) => {
65
+ b.foreach(i, (o, n) => {
66
+ r.setValue(o, n, void 0);
68
67
  });
69
- }), this._dirtyRanges$.next({ unitId, subUnitId, ranges });
68
+ }), this._dirtyRanges$.next({ unitId: a, subUnitId: e, ranges: t });
70
69
  }
71
- _deleteRange(unitId, subUnitId, ranges) {
72
- const cache = this._ensureCache(unitId, subUnitId);
73
- ranges.forEach((range) => {
74
- Range.foreach(range, (row, col) => {
75
- cache.realDeleteValue(row, col);
70
+ _deleteRange(a, e, t) {
71
+ const r = this._ensureCache(a, e);
72
+ t.forEach((i) => {
73
+ b.foreach(i, (o, n) => {
74
+ r.realDeleteValue(o, n);
76
75
  });
77
- }), this._dirtyRanges$.next({ unitId, subUnitId, ranges });
78
- }
79
- getValue(unitId, subUnitId, row, col) {
80
- return this._ensureCache(unitId, subUnitId).getValue(row, col);
81
- }
82
- }, __name(_a, "DataValidationCacheService"), _a);
83
- DataValidationCacheService = __decorateClass$a([
84
- __decorateParam$a(0, Inject(ICommandService)),
85
- __decorateParam$a(1, Inject(IUniverInstanceService))
86
- ], DataValidationCacheService);
87
- function getFormulaResult(result) {
88
- var _a12, _b;
89
- return (_b = (_a12 = result == null ? void 0 : result[0]) == null ? void 0 : _a12[0]) == null ? void 0 : _b.v;
76
+ }), this._dirtyRanges$.next({ unitId: a, subUnitId: e, ranges: t });
77
+ }
78
+ getValue(a, e, t, r) {
79
+ return this._ensureCache(a, e).getValue(t, r);
80
+ }
81
+ };
82
+ q = zt([
83
+ Je(0, S(x)),
84
+ Je(1, S(O))
85
+ ], q);
86
+ function se(s) {
87
+ var a, e;
88
+ return (e = (a = s == null ? void 0 : s[0]) == null ? void 0 : a[0]) == null ? void 0 : e.v;
90
89
  }
91
- __name(getFormulaResult, "getFormulaResult");
92
- function getFormulaCellData(result) {
93
- var _a12;
94
- return (_a12 = result == null ? void 0 : result[0]) == null ? void 0 : _a12[0];
90
+ function ge(s) {
91
+ var a;
92
+ return (a = s == null ? void 0 : s[0]) == null ? void 0 : a[0];
95
93
  }
96
- __name(getFormulaCellData, "getFormulaCellData");
97
- function isLegalFormulaResult(res) {
98
- return !ERROR_TYPE_SET.has(res);
94
+ function C(s) {
95
+ return !jt.has(s);
99
96
  }
100
- __name(isLegalFormulaResult, "isLegalFormulaResult");
101
- function shouldOffsetFormulaByRange(type, validatorRegistryService) {
102
- var _a12;
103
- const validator = validatorRegistryService.getValidatorItem(type);
104
- return (_a12 = validator == null ? void 0 : validator.offsetFormulaByRange) != null ? _a12 : !1;
97
+ function de(s, a) {
98
+ var t;
99
+ const e = a.getValidatorItem(s);
100
+ return (t = e == null ? void 0 : e.offsetFormulaByRange) != null ? t : !1;
105
101
  }
106
- __name(shouldOffsetFormulaByRange, "shouldOffsetFormulaByRange");
107
- var __defProp$9 = Object.defineProperty, __getOwnPropDesc$9 = Object.getOwnPropertyDescriptor, __decorateClass$9 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
108
- for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$9(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
109
- (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
110
- return kind && result && __defProp$9(target, key, result), result;
111
- }, "__decorateClass$9"), __decorateParam$9 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$9"), _a2;
112
- let DataValidationCustomFormulaService = (_a2 = class extends Disposable {
113
- constructor(_instanceSrv, _registerOtherFormulaService, _dataValidationModel, _dataValidationCacheService, _validatorRegistryService) {
102
+ var Zt = Object.defineProperty, Jt = Object.getOwnPropertyDescriptor, ea = (s, a, e, t) => {
103
+ for (var r = t > 1 ? void 0 : t ? Jt(a, e) : a, i = s.length - 1, o; i >= 0; i--)
104
+ (o = s[i]) && (r = (t ? o(a, e, r) : o(r)) || r);
105
+ return t && r && Zt(a, e, r), r;
106
+ }, re = (s, a) => (e, t) => a(e, t, s);
107
+ let P = class extends $ {
108
+ constructor(a, e, t, r, i) {
114
109
  super();
115
110
  /**
116
111
  * Map of origin formula of rule
117
112
  */
118
- __publicField(this, "_ruleFormulaMap", /* @__PURE__ */ new Map());
119
- __publicField(this, "_ruleFormulaMap2", /* @__PURE__ */ new Map());
120
- this._instanceSrv = _instanceSrv, this._registerOtherFormulaService = _registerOtherFormulaService, this._dataValidationModel = _dataValidationModel, this._dataValidationCacheService = _dataValidationCacheService, this._validatorRegistryService = _validatorRegistryService, this._initFormulaResultHandler();
113
+ f(this, "_ruleFormulaMap", /* @__PURE__ */ new Map());
114
+ f(this, "_ruleFormulaMap2", /* @__PURE__ */ new Map());
115
+ this._instanceSrv = a, this._registerOtherFormulaService = e, this._dataValidationModel = t, this._dataValidationCacheService = r, this._validatorRegistryService = i, this._initFormulaResultHandler();
121
116
  }
122
117
  _initFormulaResultHandler() {
123
- this.disposeWithMe(this._registerOtherFormulaService.formulaResult$.subscribe((resultMap) => {
124
- for (const unitId in resultMap) {
125
- const unitMap = resultMap[unitId];
126
- if (this._instanceSrv.getUnitType(unitId) === UniverInstanceType.UNIVER_SHEET)
127
- for (const subUnitId in unitMap) {
128
- const results = unitMap[subUnitId], { ruleFormulaMap } = this._ensureMaps(unitId, subUnitId);
129
- results.forEach((result) => {
130
- var _a12, _b;
131
- const ruleInfo = ruleFormulaMap.get((_a12 = result.extra) == null ? void 0 : _a12.ruleId), rule = this._dataValidationModel.getRuleById(unitId, subUnitId, (_b = result.extra) == null ? void 0 : _b.ruleId);
132
- rule && ruleInfo && this._dataValidationCacheService.markRangeDirty(unitId, subUnitId, rule.ranges);
118
+ this.disposeWithMe(this._registerOtherFormulaService.formulaResult$.subscribe((a) => {
119
+ for (const e in a) {
120
+ const t = a[e];
121
+ if (this._instanceSrv.getUnitType(e) === N.UNIVER_SHEET)
122
+ for (const i in t) {
123
+ const o = t[i], { ruleFormulaMap: n } = this._ensureMaps(e, i);
124
+ o.forEach((l) => {
125
+ var c, m;
126
+ const u = n.get((c = l.extra) == null ? void 0 : c.ruleId), d = this._dataValidationModel.getRuleById(e, i, (m = l.extra) == null ? void 0 : m.ruleId);
127
+ d && u && this._dataValidationCacheService.markRangeDirty(e, i, d.ranges);
133
128
  });
134
129
  }
135
130
  }
136
131
  }));
137
132
  }
138
- _ensureMaps(unitId, subUnitId) {
139
- let ruleFormulaUnitMap = this._ruleFormulaMap.get(unitId), ruleFormulaUnitMap2 = this._ruleFormulaMap2.get(unitId);
140
- ruleFormulaUnitMap || (ruleFormulaUnitMap = /* @__PURE__ */ new Map(), this._ruleFormulaMap.set(unitId, ruleFormulaUnitMap)), ruleFormulaUnitMap2 || (ruleFormulaUnitMap2 = /* @__PURE__ */ new Map(), this._ruleFormulaMap2.set(unitId, ruleFormulaUnitMap2));
141
- let ruleFormulaMap = ruleFormulaUnitMap.get(subUnitId);
142
- ruleFormulaMap || (ruleFormulaMap = /* @__PURE__ */ new Map(), ruleFormulaUnitMap.set(subUnitId, ruleFormulaMap));
143
- let ruleFormulaMap2 = ruleFormulaUnitMap2.get(subUnitId);
144
- return ruleFormulaMap2 || (ruleFormulaMap2 = /* @__PURE__ */ new Map(), ruleFormulaUnitMap2.set(subUnitId, ruleFormulaMap2)), { ruleFormulaMap, ruleFormulaMap2 };
133
+ _ensureMaps(a, e) {
134
+ let t = this._ruleFormulaMap.get(a), r = this._ruleFormulaMap2.get(a);
135
+ t || (t = /* @__PURE__ */ new Map(), this._ruleFormulaMap.set(a, t)), r || (r = /* @__PURE__ */ new Map(), this._ruleFormulaMap2.set(a, r));
136
+ let i = t.get(e);
137
+ i || (i = /* @__PURE__ */ new Map(), t.set(e, i));
138
+ let o = r.get(e);
139
+ return o || (o = /* @__PURE__ */ new Map(), r.set(e, o)), { ruleFormulaMap: i, ruleFormulaMap2: o };
145
140
  }
146
- _registerFormula(unitId, subUnitId, ruleId, formulaString, ranges) {
147
- return this._registerOtherFormulaService.registerFormulaWithRange(unitId, subUnitId, formulaString, ranges, { ruleId });
141
+ _registerFormula(a, e, t, r, i) {
142
+ return this._registerOtherFormulaService.registerFormulaWithRange(a, e, r, i, { ruleId: t });
148
143
  }
149
- deleteByRuleId(unitId, subUnitId, ruleId) {
150
- const { ruleFormulaMap, ruleFormulaMap2 } = this._ensureMaps(unitId, subUnitId), rule = this._dataValidationModel.getRuleById(unitId, subUnitId, ruleId), formulaInfo = ruleFormulaMap.get(ruleId);
151
- if (!rule || !formulaInfo)
144
+ deleteByRuleId(a, e, t) {
145
+ const { ruleFormulaMap: r, ruleFormulaMap2: i } = this._ensureMaps(a, e), o = this._dataValidationModel.getRuleById(a, e, t), n = r.get(t);
146
+ if (!o || !n)
152
147
  return;
153
- const current = ruleFormulaMap.get(ruleId);
154
- current && (ruleFormulaMap.delete(ruleId), this._registerOtherFormulaService.deleteFormula(unitId, subUnitId, [current.formulaId]));
155
- const current2 = ruleFormulaMap2.get(ruleId);
156
- current2 && (ruleFormulaMap2.delete(ruleId), this._registerOtherFormulaService.deleteFormula(unitId, subUnitId, [current2.formulaId]));
157
- }
158
- _addFormulaByRange(unitId, subUnitId, ruleId, formula, formula2, ranges) {
159
- const { ruleFormulaMap, ruleFormulaMap2 } = this._ensureMaps(unitId, subUnitId), originRow = ranges[0].startRow, originCol = ranges[0].startColumn;
160
- if (formula && isFormulaString(formula)) {
161
- const formulaId = this._registerFormula(unitId, subUnitId, ruleId, formula, ranges);
162
- ruleFormulaMap.set(ruleId, {
163
- formula,
164
- originCol,
165
- originRow,
166
- formulaId
148
+ const l = r.get(t);
149
+ l && (r.delete(t), this._registerOtherFormulaService.deleteFormula(a, e, [l.formulaId]));
150
+ const u = i.get(t);
151
+ u && (i.delete(t), this._registerOtherFormulaService.deleteFormula(a, e, [u.formulaId]));
152
+ }
153
+ _addFormulaByRange(a, e, t, r, i, o) {
154
+ const { ruleFormulaMap: n, ruleFormulaMap2: l } = this._ensureMaps(a, e), u = o[0].startRow, d = o[0].startColumn;
155
+ if (r && v(r)) {
156
+ const c = this._registerFormula(a, e, t, r, o);
157
+ n.set(t, {
158
+ formula: r,
159
+ originCol: d,
160
+ originRow: u,
161
+ formulaId: c
167
162
  });
168
163
  }
169
- if (formula2 && isFormulaString(formula2)) {
170
- const formulaId2 = this._registerFormula(unitId, subUnitId, ruleId, formula2, ranges);
171
- ruleFormulaMap2.set(ruleId, {
172
- formula: formula2,
173
- originCol,
174
- originRow,
175
- formulaId: formulaId2
164
+ if (i && v(i)) {
165
+ const c = this._registerFormula(a, e, t, i, o);
166
+ l.set(t, {
167
+ formula: i,
168
+ originCol: d,
169
+ originRow: u,
170
+ formulaId: c
176
171
  });
177
172
  }
178
173
  }
179
- addRule(unitId, subUnitId, rule) {
180
- if (shouldOffsetFormulaByRange(rule.type, this._validatorRegistryService)) {
181
- const { ranges, formula1, formula2, uid: ruleId } = rule;
182
- this._addFormulaByRange(unitId, subUnitId, ruleId, formula1, formula2, ranges);
174
+ addRule(a, e, t) {
175
+ if (de(t.type, this._validatorRegistryService)) {
176
+ const { ranges: r, formula1: i, formula2: o, uid: n } = t;
177
+ this._addFormulaByRange(a, e, n, i, o, r);
183
178
  }
184
179
  }
185
- async getCellFormulaValue(unitId, subUnitId, ruleId, row, column) {
186
- var _a12, _b;
187
- const { ruleFormulaMap } = this._ensureMaps(unitId, subUnitId), current = ruleFormulaMap.get(ruleId);
188
- if (!current)
180
+ async getCellFormulaValue(a, e, t, r, i) {
181
+ var _, g;
182
+ const { ruleFormulaMap: o } = this._ensureMaps(a, e), n = o.get(t);
183
+ if (!n)
189
184
  return Promise.resolve(void 0);
190
- const result = await this._registerOtherFormulaService.getFormulaValue(unitId, subUnitId, current.formulaId), { originRow, originCol } = current, offsetRow = row - originRow, offsetCol = column - originCol;
191
- return getFormulaCellData((_b = (_a12 = result == null ? void 0 : result.result) == null ? void 0 : _a12[offsetRow]) == null ? void 0 : _b[offsetCol]);
185
+ const l = await this._registerOtherFormulaService.getFormulaValue(a, e, n.formulaId), { originRow: u, originCol: d } = n, c = r - u, m = i - d;
186
+ return ge((g = (_ = l == null ? void 0 : l.result) == null ? void 0 : _[c]) == null ? void 0 : g[m]);
192
187
  }
193
- async getCellFormula2Value(unitId, subUnitId, ruleId, row, column) {
194
- var _a12, _b;
195
- const { ruleFormulaMap2 } = this._ensureMaps(unitId, subUnitId), current = ruleFormulaMap2.get(ruleId);
196
- if (!current)
188
+ async getCellFormula2Value(a, e, t, r, i) {
189
+ var _, g;
190
+ const { ruleFormulaMap2: o } = this._ensureMaps(a, e), n = o.get(t);
191
+ if (!n)
197
192
  return Promise.resolve(void 0);
198
- const result = await this._registerOtherFormulaService.getFormulaValue(unitId, subUnitId, current.formulaId), { originRow, originCol } = current, offsetRow = row - originRow, offsetCol = column - originCol;
199
- return getFormulaCellData((_b = (_a12 = result == null ? void 0 : result.result) == null ? void 0 : _a12[offsetRow]) == null ? void 0 : _b[offsetCol]);
193
+ const l = await this._registerOtherFormulaService.getFormulaValue(a, e, n.formulaId), { originRow: u, originCol: d } = n, c = r - u, m = i - d;
194
+ return ge((g = (_ = l == null ? void 0 : l.result) == null ? void 0 : _[c]) == null ? void 0 : g[m]);
200
195
  }
201
- getCellFormulaValueSync(unitId, subUnitId, ruleId, row, column) {
202
- var _a12, _b;
203
- const { ruleFormulaMap } = this._ensureMaps(unitId, subUnitId), current = ruleFormulaMap.get(ruleId);
204
- if (!current)
196
+ getCellFormulaValueSync(a, e, t, r, i) {
197
+ var _, g;
198
+ const { ruleFormulaMap: o } = this._ensureMaps(a, e), n = o.get(t);
199
+ if (!n)
205
200
  return;
206
- const result = this._registerOtherFormulaService.getFormulaValueSync(unitId, subUnitId, current.formulaId), { originRow, originCol } = current, offsetRow = row - originRow, offsetCol = column - originCol;
207
- return getFormulaCellData((_b = (_a12 = result == null ? void 0 : result.result) == null ? void 0 : _a12[offsetRow]) == null ? void 0 : _b[offsetCol]);
201
+ const l = this._registerOtherFormulaService.getFormulaValueSync(a, e, n.formulaId), { originRow: u, originCol: d } = n, c = r - u, m = i - d;
202
+ return ge((g = (_ = l == null ? void 0 : l.result) == null ? void 0 : _[c]) == null ? void 0 : g[m]);
208
203
  }
209
- getCellFormula2ValueSync(unitId, subUnitId, ruleId, row, column) {
210
- var _a12, _b;
211
- const { ruleFormulaMap2 } = this._ensureMaps(unitId, subUnitId), current = ruleFormulaMap2.get(ruleId);
212
- if (!current)
204
+ getCellFormula2ValueSync(a, e, t, r, i) {
205
+ var _, g;
206
+ const { ruleFormulaMap2: o } = this._ensureMaps(a, e), n = o.get(t);
207
+ if (!n)
213
208
  return;
214
- const result = this._registerOtherFormulaService.getFormulaValueSync(unitId, subUnitId, current.formulaId), { originRow, originCol } = current, offsetRow = row - originRow, offsetCol = column - originCol;
215
- return getFormulaCellData((_b = (_a12 = result == null ? void 0 : result.result) == null ? void 0 : _a12[offsetRow]) == null ? void 0 : _b[offsetCol]);
216
- }
217
- getRuleFormulaInfo(unitId, subUnitId, ruleId) {
218
- const { ruleFormulaMap } = this._ensureMaps(unitId, subUnitId);
219
- return ruleFormulaMap.get(ruleId);
220
- }
221
- }, __name(_a2, "DataValidationCustomFormulaService"), _a2);
222
- DataValidationCustomFormulaService = __decorateClass$9([
223
- __decorateParam$9(0, IUniverInstanceService),
224
- __decorateParam$9(1, Inject(RegisterOtherFormulaService)),
225
- __decorateParam$9(2, Inject(DataValidationModel)),
226
- __decorateParam$9(3, Inject(DataValidationCacheService)),
227
- __decorateParam$9(4, Inject(DataValidatorRegistryService))
228
- ], DataValidationCustomFormulaService);
229
- var __defProp$8 = Object.defineProperty, __getOwnPropDesc$8 = Object.getOwnPropertyDescriptor, __decorateClass$8 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
230
- for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$8(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
231
- (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
232
- return kind && result && __defProp$8(target, key, result), result;
233
- }, "__decorateClass$8"), __decorateParam$8 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$8"), _a3;
234
- let DataValidationFormulaService = (_a3 = class extends Disposable {
235
- constructor(_instanceService, _registerOtherFormulaService, _dataValidationCacheService, _dataValidationModel, _validatorRegistryService) {
209
+ const l = this._registerOtherFormulaService.getFormulaValueSync(a, e, n.formulaId), { originRow: u, originCol: d } = n, c = r - u, m = i - d;
210
+ return ge((g = (_ = l == null ? void 0 : l.result) == null ? void 0 : _[c]) == null ? void 0 : g[m]);
211
+ }
212
+ getRuleFormulaInfo(a, e, t) {
213
+ const { ruleFormulaMap: r } = this._ensureMaps(a, e);
214
+ return r.get(t);
215
+ }
216
+ };
217
+ P = ea([
218
+ re(0, O),
219
+ re(1, S(lt)),
220
+ re(2, S(ke)),
221
+ re(3, S(q)),
222
+ re(4, S(G))
223
+ ], P);
224
+ var ta = Object.defineProperty, aa = Object.getOwnPropertyDescriptor, ra = (s, a, e, t) => {
225
+ for (var r = t > 1 ? void 0 : t ? aa(a, e) : a, i = s.length - 1, o; i >= 0; i--)
226
+ (o = s[i]) && (r = (t ? o(a, e, r) : o(r)) || r);
227
+ return t && r && ta(a, e, r), r;
228
+ }, ie = (s, a) => (e, t) => a(e, t, s);
229
+ let K = class extends $ {
230
+ constructor(a, e, t, r, i) {
236
231
  super();
237
- __publicField(this, "_formulaRuleMap", /* @__PURE__ */ new Map());
238
- this._instanceService = _instanceService, this._registerOtherFormulaService = _registerOtherFormulaService, this._dataValidationCacheService = _dataValidationCacheService, this._dataValidationModel = _dataValidationModel, this._validatorRegistryService = _validatorRegistryService, this._initFormulaResultHandler();
232
+ f(this, "_formulaRuleMap", /* @__PURE__ */ new Map());
233
+ this._instanceService = a, this._registerOtherFormulaService = e, this._dataValidationCacheService = t, this._dataValidationModel = r, this._validatorRegistryService = i, this._initFormulaResultHandler();
239
234
  }
240
235
  _initFormulaResultHandler() {
241
- this.disposeWithMe(this._registerOtherFormulaService.formulaResult$.subscribe((resultMap) => {
242
- for (const unitId in resultMap) {
243
- const unitMap = resultMap[unitId];
244
- if (this._instanceService.getUnitType(unitId) === UniverInstanceType.UNIVER_SHEET)
245
- for (const subUnitId in unitMap) {
246
- const results = unitMap[subUnitId], formulaMap = this._ensureRuleFormulaMap(unitId, subUnitId);
247
- results.forEach((result) => {
248
- var _a12, _b;
249
- if (formulaMap.get((_a12 = result.extra) == null ? void 0 : _a12.ruleId)) {
250
- const rule = this._dataValidationModel.getRuleById(unitId, subUnitId, (_b = result.extra) == null ? void 0 : _b.ruleId);
251
- rule && this._dataValidationCacheService.markRangeDirty(unitId, subUnitId, rule.ranges);
236
+ this.disposeWithMe(this._registerOtherFormulaService.formulaResult$.subscribe((a) => {
237
+ for (const e in a) {
238
+ const t = a[e];
239
+ if (this._instanceService.getUnitType(e) === N.UNIVER_SHEET)
240
+ for (const i in t) {
241
+ const o = t[i], n = this._ensureRuleFormulaMap(e, i);
242
+ o.forEach((l) => {
243
+ var u, d;
244
+ if (n.get((u = l.extra) == null ? void 0 : u.ruleId)) {
245
+ const c = this._dataValidationModel.getRuleById(e, i, (d = l.extra) == null ? void 0 : d.ruleId);
246
+ c && this._dataValidationCacheService.markRangeDirty(e, i, c.ranges);
252
247
  }
253
248
  });
254
249
  }
255
250
  }
256
251
  }));
257
252
  }
258
- _ensureRuleFormulaMap(unitId, subUnitId) {
259
- let unitMap = this._formulaRuleMap.get(unitId);
260
- unitMap || (unitMap = /* @__PURE__ */ new Map(), this._formulaRuleMap.set(unitId, unitMap));
261
- let subUnitMap = unitMap.get(subUnitId);
262
- return subUnitMap || (subUnitMap = /* @__PURE__ */ new Map(), unitMap.set(subUnitId, subUnitMap)), subUnitMap;
253
+ _ensureRuleFormulaMap(a, e) {
254
+ let t = this._formulaRuleMap.get(a);
255
+ t || (t = /* @__PURE__ */ new Map(), this._formulaRuleMap.set(a, t));
256
+ let r = t.get(e);
257
+ return r || (r = /* @__PURE__ */ new Map(), t.set(e, r)), r;
263
258
  }
264
- _registerSingleFormula(unitId, subUnitId, formula, ruleId) {
265
- const ranges = [{ startColumn: 0, endColumn: 0, startRow: 0, endRow: 0 }];
266
- return this._registerOtherFormulaService.registerFormulaWithRange(unitId, subUnitId, formula, ranges, { ruleId });
259
+ _registerSingleFormula(a, e, t, r) {
260
+ const i = [{ startColumn: 0, endColumn: 0, startRow: 0, endRow: 0 }];
261
+ return this._registerOtherFormulaService.registerFormulaWithRange(a, e, t, i, { ruleId: r });
267
262
  }
268
- addRule(unitId, subUnitId, rule) {
269
- if (!shouldOffsetFormulaByRange(rule.type, this._validatorRegistryService) && rule.type !== DataValidationType.CHECKBOX) {
270
- const { formula1, formula2, uid: ruleId } = rule, isFormula1Legal = isFormulaString(formula1), isFormula2Legal = isFormulaString(formula2);
271
- if (!isFormula1Legal && !isFormula2Legal)
263
+ addRule(a, e, t) {
264
+ if (!de(t.type, this._validatorRegistryService) && t.type !== T.CHECKBOX) {
265
+ const { formula1: r, formula2: i, uid: o } = t, n = v(r), l = v(i);
266
+ if (!n && !l)
272
267
  return;
273
- const formulaRuleMap = this._ensureRuleFormulaMap(unitId, subUnitId), item = [void 0, void 0];
274
- if (isFormula1Legal) {
275
- const id = this._registerSingleFormula(unitId, subUnitId, formula1, ruleId);
276
- item[0] = { id, text: formula1 };
268
+ const u = this._ensureRuleFormulaMap(a, e), d = [void 0, void 0];
269
+ if (n) {
270
+ const c = this._registerSingleFormula(a, e, r, o);
271
+ d[0] = { id: c, text: r };
277
272
  }
278
- if (isFormula2Legal) {
279
- const id = this._registerSingleFormula(unitId, subUnitId, formula2, ruleId);
280
- item[1] = { id, text: formula2 };
273
+ if (l) {
274
+ const c = this._registerSingleFormula(a, e, i, o);
275
+ d[1] = { id: c, text: i };
281
276
  }
282
- formulaRuleMap.set(ruleId, item);
277
+ u.set(o, d);
283
278
  }
284
279
  }
285
- removeRule(unitId, subUnitId, ruleId) {
286
- const item = this._ensureRuleFormulaMap(unitId, subUnitId).get(ruleId);
287
- if (!item)
280
+ removeRule(a, e, t) {
281
+ const i = this._ensureRuleFormulaMap(a, e).get(t);
282
+ if (!i)
288
283
  return;
289
- const [formula1, formula2] = item, idList = [formula1 == null ? void 0 : formula1.id, formula2 == null ? void 0 : formula2.id].filter(Boolean);
290
- idList.length && this._registerOtherFormulaService.deleteFormula(unitId, subUnitId, idList);
284
+ const [o, n] = i, l = [o == null ? void 0 : o.id, n == null ? void 0 : n.id].filter(Boolean);
285
+ l.length && this._registerOtherFormulaService.deleteFormula(a, e, l);
291
286
  }
292
- getRuleFormulaResult(unitId, subUnitId, ruleId) {
293
- const formulaInfo = this._ensureRuleFormulaMap(unitId, subUnitId).get(ruleId);
294
- if (!formulaInfo)
287
+ getRuleFormulaResult(a, e, t) {
288
+ const i = this._ensureRuleFormulaMap(a, e).get(t);
289
+ if (!i)
295
290
  return Promise.resolve(null);
296
- const getResult = /* @__PURE__ */ __name(async (info) => info && this._registerOtherFormulaService.getFormulaValue(unitId, subUnitId, info.id), "getResult");
291
+ const o = async (n) => n && this._registerOtherFormulaService.getFormulaValue(a, e, n.id);
297
292
  return Promise.all([
298
- getResult(formulaInfo[0]),
299
- getResult(formulaInfo[1])
293
+ o(i[0]),
294
+ o(i[1])
300
295
  ]);
301
296
  }
302
- getRuleFormulaResultSync(unitId, subUnitId, ruleId) {
303
- const formulaInfo = this._ensureRuleFormulaMap(unitId, subUnitId).get(ruleId);
304
- if (formulaInfo)
305
- return formulaInfo.map((i) => {
306
- if (i)
307
- return this._registerOtherFormulaService.getFormulaValueSync(unitId, subUnitId, i.id);
297
+ getRuleFormulaResultSync(a, e, t) {
298
+ const i = this._ensureRuleFormulaMap(a, e).get(t);
299
+ if (i)
300
+ return i.map((o) => {
301
+ if (o)
302
+ return this._registerOtherFormulaService.getFormulaValueSync(a, e, o.id);
308
303
  });
309
304
  }
310
- getRuleFormulaInfo(unitId, subUnitId, ruleId) {
311
- return this._ensureRuleFormulaMap(unitId, subUnitId).get(ruleId);
312
- }
313
- }, __name(_a3, "DataValidationFormulaService"), _a3);
314
- DataValidationFormulaService = __decorateClass$8([
315
- __decorateParam$8(0, IUniverInstanceService),
316
- __decorateParam$8(1, Inject(RegisterOtherFormulaService)),
317
- __decorateParam$8(2, Inject(DataValidationCacheService)),
318
- __decorateParam$8(3, Inject(DataValidationModel)),
319
- __decorateParam$8(4, Inject(DataValidatorRegistryService))
320
- ], DataValidationFormulaService);
321
- function getCellValueOrigin(cell) {
322
- return getOriginCellValue(cell);
305
+ getRuleFormulaInfo(a, e, t) {
306
+ return this._ensureRuleFormulaMap(a, e).get(t);
307
+ }
308
+ };
309
+ K = ra([
310
+ ie(0, O),
311
+ ie(1, S(lt)),
312
+ ie(2, S(q)),
313
+ ie(3, S(ke)),
314
+ ie(4, S(G))
315
+ ], K);
316
+ function ne(s) {
317
+ return vt(s);
323
318
  }
324
- __name(getCellValueOrigin, "getCellValueOrigin");
325
- function getStringCellValue(cell) {
326
- var _a12;
327
- return String((_a12 = getCellValueOrigin(cell)) != null ? _a12 : "");
319
+ function ct(s) {
320
+ var a;
321
+ return String((a = ne(s)) != null ? a : "");
328
322
  }
329
- __name(getStringCellValue, "getStringCellValue");
330
- const _RuleMatrix = class _RuleMatrix {
331
- constructor(value, _unitId, _subUnitId, _univerInstanceService, _disableTree = !1) {
332
- __publicField(this, "_map");
333
- __publicField(this, "_tree", new RBush());
334
- __publicField(this, "_dirty", !0);
335
- __publicField(this, "_buildTree", /* @__PURE__ */ __name(() => {
323
+ class Xe {
324
+ constructor(a, e, t, r, i = !1) {
325
+ f(this, "_map");
326
+ f(this, "_tree", new Vt());
327
+ f(this, "_dirty", !0);
328
+ f(this, "_buildTree", () => {
336
329
  if (!this._dirty || this._disableTree)
337
330
  return;
338
331
  this._tree.clear();
339
- const items = [];
340
- this._map.forEach((ranges, ruleId) => {
341
- ranges.forEach((range) => {
342
- items.push({
343
- minX: range.startRow,
344
- maxX: range.endRow,
345
- minY: range.startColumn,
346
- maxY: range.endColumn,
347
- ruleId
332
+ const a = [];
333
+ this._map.forEach((e, t) => {
334
+ e.forEach((r) => {
335
+ a.push({
336
+ minX: r.startRow,
337
+ maxX: r.endRow,
338
+ minY: r.startColumn,
339
+ maxY: r.endColumn,
340
+ ruleId: t
348
341
  });
349
342
  });
350
- }), this._tree.load(items), this._dirty = !1;
351
- }, "_buildTree"));
352
- __publicField(this, "_debonceBuildTree", debounce(this._buildTree, 0));
353
- this._unitId = _unitId, this._subUnitId = _subUnitId, this._univerInstanceService = _univerInstanceService, this._disableTree = _disableTree, this._map = value, this._buildTree();
343
+ }), this._tree.load(a), this._dirty = !1;
344
+ });
345
+ f(this, "_debonceBuildTree", Mt(this._buildTree, 0));
346
+ this._unitId = e, this._subUnitId = t, this._univerInstanceService = r, this._disableTree = i, this._map = a, this._buildTree();
354
347
  }
355
348
  get _worksheet() {
356
- var _a12;
357
- return (_a12 = this._univerInstanceService.getUnit(this._unitId, UniverInstanceType.UNIVER_SHEET)) == null ? void 0 : _a12.getSheetBySheetId(this._subUnitId);
349
+ var a;
350
+ return (a = this._univerInstanceService.getUnit(this._unitId, N.UNIVER_SHEET)) == null ? void 0 : a.getSheetBySheetId(this._subUnitId);
358
351
  }
359
- _addRule(ruleId, _ranges) {
352
+ _addRule(a, e) {
360
353
  if (!this._worksheet)
361
354
  return;
362
- const ranges = Rectangle.mergeRanges(_ranges.map((range) => Range.transformRange(range, this._worksheet)));
363
- this._map.forEach((value, key) => {
364
- const newRanges = Rectangle.subtractMulti(value, ranges);
365
- newRanges.length === 0 ? this._map.delete(key) : this._map.set(key, newRanges);
366
- }), this._dirty = !0, this._map.set(ruleId, ranges), this._debonceBuildTree();
355
+ const t = I.mergeRanges(e.map((r) => b.transformRange(r, this._worksheet)));
356
+ this._map.forEach((r, i) => {
357
+ const o = I.subtractMulti(r, t);
358
+ o.length === 0 ? this._map.delete(i) : this._map.set(i, o);
359
+ }), this._dirty = !0, this._map.set(a, t), this._debonceBuildTree();
367
360
  }
368
- addRule(rule) {
369
- this._addRule(rule.uid, rule.ranges);
361
+ addRule(a) {
362
+ this._addRule(a.uid, a.ranges);
370
363
  }
371
- removeRange(_ranges) {
364
+ removeRange(a) {
372
365
  if (!this._worksheet)
373
366
  return;
374
- const ranges = _ranges.map((range) => Range.transformRange(range, this._worksheet));
375
- this._map.forEach((value, key) => {
376
- const newRanges = Rectangle.subtractMulti(value, ranges);
377
- newRanges.length === 0 ? this._map.delete(key) : this._map.set(key, newRanges);
367
+ const e = a.map((t) => b.transformRange(t, this._worksheet));
368
+ this._map.forEach((t, r) => {
369
+ const i = I.subtractMulti(t, e);
370
+ i.length === 0 ? this._map.delete(r) : this._map.set(r, i);
378
371
  }), this._dirty = !0, this._debonceBuildTree();
379
372
  }
380
- _removeRule(ruleId) {
381
- this._map.delete(ruleId), this._dirty = !0, this._debonceBuildTree();
373
+ _removeRule(a) {
374
+ this._map.delete(a), this._dirty = !0, this._debonceBuildTree();
382
375
  }
383
- removeRule(rule) {
384
- this._removeRule(rule.uid);
376
+ removeRule(a) {
377
+ this._removeRule(a.uid);
385
378
  }
386
- updateRange(ruleId, _newRanges) {
387
- this._removeRule(ruleId), this._addRule(ruleId, _newRanges);
379
+ updateRange(a, e) {
380
+ this._removeRule(a), this._addRule(a, e);
388
381
  }
389
- addRangeRules(rules) {
390
- rules.forEach(({ id: ruleId, ranges }) => {
391
- if (!ranges.length)
382
+ addRangeRules(a) {
383
+ a.forEach(({ id: e, ranges: t }) => {
384
+ if (!t.length)
392
385
  return;
393
- let current = this._map.get(ruleId);
394
- current ? (this._map.set(ruleId, Rectangle.mergeRanges([...current, ...ranges])), current = this._map.get(ruleId)) : (current = ranges, this._map.set(ruleId, current)), this._map.forEach((value, key) => {
395
- if (key === ruleId)
386
+ let r = this._map.get(e);
387
+ r ? (this._map.set(e, I.mergeRanges([...r, ...t])), r = this._map.get(e)) : (r = t, this._map.set(e, r)), this._map.forEach((i, o) => {
388
+ if (o === e)
396
389
  return;
397
- const newRanges = Rectangle.subtractMulti(value, ranges);
398
- newRanges.length === 0 ? this._map.delete(key) : this._map.set(key, newRanges);
390
+ const n = I.subtractMulti(i, t);
391
+ n.length === 0 ? this._map.delete(o) : this._map.set(o, n);
399
392
  });
400
393
  }), this._dirty = !0, this._debonceBuildTree();
401
394
  }
402
- diff(rules) {
403
- const mutations = [];
404
- let deleteIndex = 0;
405
- return rules.forEach((rule, index) => {
406
- var _a12;
407
- const newRanges = (_a12 = this._map.get(rule.uid)) != null ? _a12 : [], oldRanges = rule.ranges;
408
- newRanges.length !== 0 && (newRanges.length !== oldRanges.length || newRanges.some((range, i) => !Rectangle.equals(range, oldRanges[i]))) && mutations.push({
395
+ diff(a) {
396
+ const e = [];
397
+ let t = 0;
398
+ return a.forEach((r, i) => {
399
+ var l;
400
+ const o = (l = this._map.get(r.uid)) != null ? l : [], n = r.ranges;
401
+ o.length !== 0 && (o.length !== n.length || o.some((u, d) => !I.equals(u, n[d]))) && e.push({
409
402
  type: "update",
410
- ruleId: rule.uid,
411
- oldRanges,
412
- newRanges: Rectangle.sort(newRanges),
413
- rule
414
- }), newRanges.length === 0 && (mutations.push({
403
+ ruleId: r.uid,
404
+ oldRanges: n,
405
+ newRanges: I.sort(o),
406
+ rule: r
407
+ }), o.length === 0 && (e.push({
415
408
  type: "delete",
416
- rule,
417
- index: index - deleteIndex
418
- }), deleteIndex++);
419
- }), mutations;
420
- }
421
- diffWithAddition(rules, additionRules) {
422
- const mutations = [];
423
- let deleteIndex = 0;
424
- return rules.forEach((rule, index) => {
425
- var _a12;
426
- const newRanges = (_a12 = this._map.get(rule.uid)) != null ? _a12 : [], oldRanges = rule.ranges;
427
- newRanges.length !== 0 && (newRanges.length !== oldRanges.length || newRanges.some((range, i) => !Rectangle.equals(range, oldRanges[i]))) && mutations.push({
409
+ rule: r,
410
+ index: i - t
411
+ }), t++);
412
+ }), e;
413
+ }
414
+ diffWithAddition(a, e) {
415
+ const t = [];
416
+ let r = 0;
417
+ return a.forEach((i, o) => {
418
+ var u;
419
+ const n = (u = this._map.get(i.uid)) != null ? u : [], l = i.ranges;
420
+ n.length !== 0 && (n.length !== l.length || n.some((d, c) => !I.equals(d, l[c]))) && t.push({
428
421
  type: "update",
429
- ruleId: rule.uid,
430
- oldRanges,
431
- newRanges: Rectangle.sort(newRanges),
432
- rule
433
- }), newRanges.length === 0 && (mutations.push({
422
+ ruleId: i.uid,
423
+ oldRanges: l,
424
+ newRanges: I.sort(n),
425
+ rule: i
426
+ }), n.length === 0 && (t.push({
434
427
  type: "delete",
435
- rule,
436
- index: index - deleteIndex
437
- }), deleteIndex++);
438
- }), Array.from(additionRules).forEach((rule) => {
439
- var _a12;
440
- const newRanges = (_a12 = this._map.get(rule.uid)) != null ? _a12 : [];
441
- mutations.push({
428
+ rule: i,
429
+ index: o - r
430
+ }), r++);
431
+ }), Array.from(e).forEach((i) => {
432
+ var n;
433
+ const o = (n = this._map.get(i.uid)) != null ? n : [];
434
+ t.push({
442
435
  type: "add",
443
436
  rule: {
444
- ...rule,
445
- ranges: Rectangle.sort(newRanges)
437
+ ...i,
438
+ ranges: I.sort(o)
446
439
  }
447
440
  });
448
- }), mutations;
441
+ }), t;
449
442
  }
450
443
  clone() {
451
- return new _RuleMatrix(
452
- new Map(Tools.deepClone(Array.from(this._map.entries()))),
444
+ return new Xe(
445
+ new Map(V.deepClone(Array.from(this._map.entries()))),
453
446
  this._unitId,
454
447
  this._subUnitId,
455
448
  this._univerInstanceService,
@@ -457,606 +450,591 @@ const _RuleMatrix = class _RuleMatrix {
457
450
  !0
458
451
  );
459
452
  }
460
- getValue(row, col) {
453
+ getValue(a, e) {
461
454
  this._dirty && this._buildTree();
462
- const result = this._tree.search({
463
- minX: row,
464
- maxX: row,
465
- minY: col,
466
- maxY: col
455
+ const t = this._tree.search({
456
+ minX: a,
457
+ maxX: a,
458
+ minY: e,
459
+ maxY: e
467
460
  });
468
- return result.length > 0 ? result[0].ruleId : void 0;
461
+ return t.length > 0 ? t[0].ruleId : void 0;
469
462
  }
470
- };
471
- __name(_RuleMatrix, "RuleMatrix");
472
- let RuleMatrix = _RuleMatrix;
473
- var __defProp$7 = Object.defineProperty, __getOwnPropDesc$7 = Object.getOwnPropertyDescriptor, __decorateClass$7 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
474
- for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$7(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
475
- (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
476
- return kind && result && __defProp$7(target, key, result), result;
477
- }, "__decorateClass$7"), __decorateParam$7 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$7"), _a4;
478
- let SheetDataValidationModel = (_a4 = class extends Disposable {
479
- constructor(_dataValidationModel, _univerInstanceService, _dataValidatorRegistryService, _dataValidationCacheService, _dataValidationFormulaService, _dataValidationCustomFormulaService, _commandService) {
463
+ }
464
+ var ia = Object.defineProperty, sa = Object.getOwnPropertyDescriptor, oa = (s, a, e, t) => {
465
+ for (var r = t > 1 ? void 0 : t ? sa(a, e) : a, i = s.length - 1, o; i >= 0; i--)
466
+ (o = s[i]) && (r = (t ? o(a, e, r) : o(r)) || r);
467
+ return t && r && ia(a, e, r), r;
468
+ }, X = (s, a) => (e, t) => a(e, t, s);
469
+ let F = class extends $ {
470
+ constructor(a, e, t, r, i, o, n) {
480
471
  super();
481
- __publicField(this, "_ruleMatrixMap", /* @__PURE__ */ new Map());
482
- __publicField(this, "_validStatusChange$", new Subject());
483
- __publicField(this, "_ruleChange$", new Subject());
484
- __publicField(this, "ruleChange$", this._ruleChange$.asObservable());
485
- __publicField(this, "validStatusChange$", this._validStatusChange$.asObservable());
486
- this._dataValidationModel = _dataValidationModel, this._univerInstanceService = _univerInstanceService, this._dataValidatorRegistryService = _dataValidatorRegistryService, this._dataValidationCacheService = _dataValidationCacheService, this._dataValidationFormulaService = _dataValidationFormulaService, this._dataValidationCustomFormulaService = _dataValidationCustomFormulaService, this._commandService = _commandService, this._initRuleUpdateListener(), this.disposeWithMe(() => {
472
+ f(this, "_ruleMatrixMap", /* @__PURE__ */ new Map());
473
+ f(this, "_validStatusChange$", new Qe());
474
+ f(this, "_ruleChange$", new Qe());
475
+ f(this, "ruleChange$", this._ruleChange$.asObservable());
476
+ f(this, "validStatusChange$", this._validStatusChange$.asObservable());
477
+ this._dataValidationModel = a, this._univerInstanceService = e, this._dataValidatorRegistryService = t, this._dataValidationCacheService = r, this._dataValidationFormulaService = i, this._dataValidationCustomFormulaService = o, this._commandService = n, this._initRuleUpdateListener(), this.disposeWithMe(() => {
487
478
  this._ruleChange$.complete(), this._validStatusChange$.complete();
488
479
  }), this._initUniverInstanceListener();
489
480
  }
490
481
  _initUniverInstanceListener() {
491
482
  this.disposeWithMe(
492
- this._univerInstanceService.unitDisposed$.subscribe((unit) => {
493
- this._ruleMatrixMap.delete(unit.getUnitId());
483
+ this._univerInstanceService.unitDisposed$.subscribe((a) => {
484
+ this._ruleMatrixMap.delete(a.getUnitId());
494
485
  })
495
486
  ), this.disposeWithMe(
496
- this._commandService.onCommandExecuted((command) => {
497
- if (command.id === RemoveSheetMutation.id) {
498
- const { unitId, subUnitId } = command.params, subUnitMap = this._ruleMatrixMap.get(unitId);
499
- subUnitMap && subUnitMap.delete(subUnitId);
487
+ this._commandService.onCommandExecuted((a) => {
488
+ if (a.id === it.id) {
489
+ const { unitId: e, subUnitId: t } = a.params, r = this._ruleMatrixMap.get(e);
490
+ r && r.delete(t);
500
491
  }
501
492
  })
502
493
  );
503
494
  }
504
495
  _initRuleUpdateListener() {
505
- const allRules = this._dataValidationModel.getAll();
506
- for (const [unitId, subUnitMap] of allRules)
507
- for (const [subUnitId, rules] of subUnitMap)
508
- for (const rule of rules)
509
- this._addRule(unitId, subUnitId, rule), this._ruleChange$.next({
496
+ const a = this._dataValidationModel.getAll();
497
+ for (const [e, t] of a)
498
+ for (const [r, i] of t)
499
+ for (const o of i)
500
+ this._addRule(e, r, o), this._ruleChange$.next({
510
501
  type: "add",
511
- unitId,
512
- subUnitId,
513
- rule,
502
+ unitId: e,
503
+ subUnitId: r,
504
+ rule: o,
514
505
  source: "patched"
515
506
  });
516
507
  this.disposeWithMe(
517
- this._dataValidationModel.ruleChange$.subscribe((ruleChange) => {
518
- switch (ruleChange.type) {
508
+ this._dataValidationModel.ruleChange$.subscribe((e) => {
509
+ switch (e.type) {
519
510
  case "add":
520
- this._addRule(ruleChange.unitId, ruleChange.subUnitId, ruleChange.rule);
511
+ this._addRule(e.unitId, e.subUnitId, e.rule);
521
512
  break;
522
513
  case "update":
523
- this._updateRule(ruleChange.unitId, ruleChange.subUnitId, ruleChange.rule.uid, ruleChange.oldRule, ruleChange.updatePayload);
514
+ this._updateRule(e.unitId, e.subUnitId, e.rule.uid, e.oldRule, e.updatePayload);
524
515
  break;
525
516
  case "remove":
526
- this._removeRule(ruleChange.unitId, ruleChange.subUnitId, ruleChange.rule);
517
+ this._removeRule(e.unitId, e.subUnitId, e.rule);
527
518
  break;
528
519
  }
529
- this._ruleChange$.next(ruleChange);
520
+ this._ruleChange$.next(e);
530
521
  })
531
522
  );
532
523
  }
533
- _ensureRuleMatrix(unitId, subUnitId) {
534
- let unitMap = this._ruleMatrixMap.get(unitId);
535
- unitMap || (unitMap = /* @__PURE__ */ new Map(), this._ruleMatrixMap.set(unitId, unitMap));
536
- let matrix = unitMap.get(subUnitId);
537
- return matrix || (matrix = new RuleMatrix(/* @__PURE__ */ new Map(), unitId, subUnitId, this._univerInstanceService), unitMap.set(subUnitId, matrix)), matrix;
524
+ _ensureRuleMatrix(a, e) {
525
+ let t = this._ruleMatrixMap.get(a);
526
+ t || (t = /* @__PURE__ */ new Map(), this._ruleMatrixMap.set(a, t));
527
+ let r = t.get(e);
528
+ return r || (r = new Xe(/* @__PURE__ */ new Map(), a, e, this._univerInstanceService), t.set(e, r)), r;
538
529
  }
539
- _addRuleSideEffect(unitId, subUnitId, rule) {
540
- this._ensureRuleMatrix(unitId, subUnitId).addRule(rule), this._dataValidationCacheService.addRule(unitId, subUnitId, rule), this._dataValidationFormulaService.addRule(unitId, subUnitId, rule), this._dataValidationCustomFormulaService.addRule(unitId, subUnitId, rule);
530
+ _addRuleSideEffect(a, e, t) {
531
+ this._ensureRuleMatrix(a, e).addRule(t), this._dataValidationCacheService.addRule(a, e, t), this._dataValidationFormulaService.addRule(a, e, t), this._dataValidationCustomFormulaService.addRule(a, e, t);
541
532
  }
542
- _addRule(unitId, subUnitId, rule) {
543
- (Array.isArray(rule) ? rule : [rule]).forEach((item) => {
544
- this._addRuleSideEffect(unitId, subUnitId, item);
533
+ _addRule(a, e, t) {
534
+ (Array.isArray(t) ? t : [t]).forEach((i) => {
535
+ this._addRuleSideEffect(a, e, i);
545
536
  });
546
537
  }
547
- _updateRule(unitId, subUnitId, ruleId, oldRule, payload) {
548
- const ruleMatrix = this._ensureRuleMatrix(unitId, subUnitId), newRule = {
549
- ...oldRule,
550
- ...payload.payload
538
+ _updateRule(a, e, t, r, i) {
539
+ const o = this._ensureRuleMatrix(a, e), n = {
540
+ ...r,
541
+ ...i.payload
551
542
  };
552
- payload.type === UpdateRuleType.RANGE ? ruleMatrix.updateRange(ruleId, payload.payload) : payload.type === UpdateRuleType.ALL && ruleMatrix.updateRange(ruleId, payload.payload.ranges), this._dataValidationCacheService.removeRule(unitId, subUnitId, oldRule), this._dataValidationCacheService.addRule(unitId, subUnitId, newRule), this._dataValidationFormulaService.removeRule(unitId, subUnitId, oldRule.uid), this._dataValidationFormulaService.addRule(unitId, subUnitId, newRule), this._dataValidationCustomFormulaService.deleteByRuleId(unitId, subUnitId, ruleId), this._dataValidationCustomFormulaService.addRule(unitId, subUnitId, newRule);
553
- }
554
- _removeRule(unitId, subUnitId, oldRule) {
555
- this._ensureRuleMatrix(unitId, subUnitId).removeRule(oldRule), this._dataValidationCacheService.removeRule(unitId, subUnitId, oldRule), this._dataValidationCustomFormulaService.deleteByRuleId(unitId, subUnitId, oldRule.uid);
556
- }
557
- getValidator(type) {
558
- return this._dataValidatorRegistryService.getValidatorItem(type);
559
- }
560
- getRuleIdByLocation(unitId, subUnitId, row, col) {
561
- return this._ensureRuleMatrix(unitId, subUnitId).getValue(row, col);
562
- }
563
- getRuleByLocation(unitId, subUnitId, row, col) {
564
- const ruleId = this.getRuleIdByLocation(unitId, subUnitId, row, col);
565
- if (ruleId)
566
- return this._dataValidationModel.getRuleById(unitId, subUnitId, ruleId);
567
- }
568
- validator(rule, pos, _onCompete) {
569
- const { col, row, unitId, subUnitId, worksheet } = pos, onCompete = /* @__PURE__ */ __name((status, changed) => {
570
- _onCompete && _onCompete(status, changed), changed && this._validStatusChange$.next({
571
- unitId,
572
- subUnitId,
573
- ruleId: rule.uid,
574
- status,
575
- row,
576
- col
543
+ i.type === y.RANGE ? o.updateRange(t, i.payload) : i.type === y.ALL && o.updateRange(t, i.payload.ranges), this._dataValidationCacheService.removeRule(a, e, r), this._dataValidationCacheService.addRule(a, e, n), this._dataValidationFormulaService.removeRule(a, e, r.uid), this._dataValidationFormulaService.addRule(a, e, n), this._dataValidationCustomFormulaService.deleteByRuleId(a, e, t), this._dataValidationCustomFormulaService.addRule(a, e, n);
544
+ }
545
+ _removeRule(a, e, t) {
546
+ this._ensureRuleMatrix(a, e).removeRule(t), this._dataValidationCacheService.removeRule(a, e, t), this._dataValidationCustomFormulaService.deleteByRuleId(a, e, t.uid);
547
+ }
548
+ getValidator(a) {
549
+ return this._dataValidatorRegistryService.getValidatorItem(a);
550
+ }
551
+ getRuleIdByLocation(a, e, t, r) {
552
+ return this._ensureRuleMatrix(a, e).getValue(t, r);
553
+ }
554
+ getRuleByLocation(a, e, t, r) {
555
+ const i = this.getRuleIdByLocation(a, e, t, r);
556
+ if (i)
557
+ return this._dataValidationModel.getRuleById(a, e, i);
558
+ }
559
+ validator(a, e, t) {
560
+ const { col: r, row: i, unitId: o, subUnitId: n, worksheet: l } = e, u = (g, R) => {
561
+ t && t(g, R), R && this._validStatusChange$.next({
562
+ unitId: o,
563
+ subUnitId: n,
564
+ ruleId: a.uid,
565
+ status: g,
566
+ row: i,
567
+ col: r
577
568
  });
578
- }, "onCompete"), cell = worksheet.getCellValueOnly(row, col), validator = this.getValidator(rule.type), cellRaw = worksheet.getCellRaw(row, col), cellValue = getCellValueOrigin(cellRaw);
579
- if (validator) {
580
- const cache = this._dataValidationCacheService.ensureCache(unitId, subUnitId), current = cache.getValue(row, col);
581
- return current == null ? (cache.setValue(row, col, DataValidationStatus.VALIDATING), validator.validator(
569
+ }, d = l.getCellValueOnly(i, r), c = this.getValidator(a.type), m = l.getCellRaw(i, r), _ = ne(m);
570
+ if (c) {
571
+ const g = this._dataValidationCacheService.ensureCache(o, n), R = g.getValue(i, r);
572
+ return R == null ? (g.setValue(i, r, D.VALIDATING), c.validator(
582
573
  {
583
- value: cellValue,
584
- unitId,
585
- subUnitId,
586
- row,
587
- column: col,
588
- worksheet: pos.worksheet,
589
- workbook: pos.workbook,
590
- interceptValue: getCellValueOrigin(cell),
591
- t: cellRaw == null ? void 0 : cellRaw.t
574
+ value: _,
575
+ unitId: o,
576
+ subUnitId: n,
577
+ row: i,
578
+ column: r,
579
+ worksheet: e.worksheet,
580
+ workbook: e.workbook,
581
+ interceptValue: ne(d),
582
+ t: m == null ? void 0 : m.t
592
583
  },
593
- rule
594
- ).then((status) => {
595
- const realStatus = status ? DataValidationStatus.VALID : DataValidationStatus.INVALID;
596
- realStatus === DataValidationStatus.VALID ? cache.realDeleteValue(row, col) : cache.setValue(row, col, realStatus);
597
- const now = cache.getValue(row, col);
598
- onCompete(realStatus, current !== now);
599
- }), DataValidationStatus.VALIDATING) : (onCompete(current != null ? current : DataValidationStatus.VALID, !1), current != null ? current : DataValidationStatus.VALID);
584
+ a
585
+ ).then((M) => {
586
+ const p = M ? D.VALID : D.INVALID;
587
+ p === D.VALID ? g.realDeleteValue(i, r) : g.setValue(i, r, p);
588
+ const w = g.getValue(i, r);
589
+ u(p, R !== w);
590
+ }), D.VALIDATING) : (u(R != null ? R : D.VALID, !1), R != null ? R : D.VALID);
600
591
  } else
601
- return onCompete(DataValidationStatus.VALID, !1), DataValidationStatus.VALID;
592
+ return u(D.VALID, !1), D.VALID;
602
593
  }
603
- getRuleObjectMatrix(unitId, subUnitId) {
604
- return this._ensureRuleMatrix(unitId, subUnitId);
594
+ getRuleObjectMatrix(a, e) {
595
+ return this._ensureRuleMatrix(a, e);
605
596
  }
606
- getRuleById(unitId, subUnitId, ruleId) {
607
- return this._dataValidationModel.getRuleById(unitId, subUnitId, ruleId);
597
+ getRuleById(a, e, t) {
598
+ return this._dataValidationModel.getRuleById(a, e, t);
608
599
  }
609
- getRuleIndex(unitId, subUnitId, ruleId) {
610
- return this._dataValidationModel.getRuleIndex(unitId, subUnitId, ruleId);
600
+ getRuleIndex(a, e, t) {
601
+ return this._dataValidationModel.getRuleIndex(a, e, t);
611
602
  }
612
- getRules(unitId, subUnitId) {
613
- return [...this._dataValidationModel.getRules(unitId, subUnitId)];
603
+ getRules(a, e) {
604
+ return [...this._dataValidationModel.getRules(a, e)];
614
605
  }
615
- getUnitRules(unitId) {
616
- return this._dataValidationModel.getUnitRules(unitId);
606
+ getUnitRules(a) {
607
+ return this._dataValidationModel.getUnitRules(a);
617
608
  }
618
- deleteUnitRules(unitId) {
619
- return this._dataValidationModel.deleteUnitRules(unitId);
609
+ deleteUnitRules(a) {
610
+ return this._dataValidationModel.deleteUnitRules(a);
620
611
  }
621
- getSubUnitIds(unitId) {
622
- return this._dataValidationModel.getSubUnitIds(unitId);
612
+ getSubUnitIds(a) {
613
+ return this._dataValidationModel.getSubUnitIds(a);
623
614
  }
624
615
  getAll() {
625
616
  return this._dataValidationModel.getAll();
626
617
  }
627
- }, __name(_a4, "SheetDataValidationModel"), _a4);
628
- SheetDataValidationModel = __decorateClass$7([
629
- __decorateParam$7(0, Inject(DataValidationModel)),
630
- __decorateParam$7(1, IUniverInstanceService),
631
- __decorateParam$7(2, Inject(DataValidatorRegistryService)),
632
- __decorateParam$7(3, Inject(DataValidationCacheService)),
633
- __decorateParam$7(4, Inject(DataValidationFormulaService)),
634
- __decorateParam$7(5, Inject(DataValidationCustomFormulaService)),
635
- __decorateParam$7(6, ICommandService)
636
- ], SheetDataValidationModel);
637
- const CHECKBOX_FORMULA_1 = 1, CHECKBOX_FORMULA_2 = 0;
638
- function getFailMessage(formula, localeService) {
639
- return Tools.isBlank(formula) ? localeService.t("dataValidation.validFail.value") : isFormulaString(formula) ? localeService.t("dataValidation.validFail.primitive") : "";
618
+ };
619
+ F = oa([
620
+ X(0, S(ke)),
621
+ X(1, O),
622
+ X(2, S(G)),
623
+ X(3, S(q)),
624
+ X(4, S(K)),
625
+ X(5, S(P)),
626
+ X(6, x)
627
+ ], F);
628
+ const Ve = 1, Me = 0;
629
+ function et(s, a) {
630
+ return V.isBlank(s) ? a.t("dataValidation.validFail.value") : v(s) ? a.t("dataValidation.validFail.primitive") : "";
640
631
  }
641
- __name(getFailMessage, "getFailMessage");
642
- const transformCheckboxValue = /* @__PURE__ */ __name((value) => Tools.isDefine(value) && String(value).toLowerCase() === "true" ? "1" : String(value).toLowerCase() === "false" ? "0" : value, "transformCheckboxValue"), _CheckboxValidator = class _CheckboxValidator extends BaseDataValidator {
632
+ const _e = (s) => V.isDefine(s) && String(s).toLowerCase() === "true" ? "1" : String(s).toLowerCase() === "false" ? "0" : s;
633
+ class na extends k {
643
634
  constructor() {
644
635
  super(...arguments);
645
- __publicField(this, "id", DataValidationType.CHECKBOX);
646
- __publicField(this, "title", "dataValidation.checkbox.title");
647
- __publicField(this, "operators", []);
648
- __publicField(this, "scopes", ["sheet"]);
649
- __publicField(this, "offsetFormulaByRange", !1);
650
- __publicField(this, "_formulaService", this.injector.get(DataValidationFormulaService));
651
- __publicField(this, "skipDefaultFontRender", /* @__PURE__ */ __name((rule, cellValue, pos) => {
652
- const { unitId, subUnitId } = pos, { formula1, formula2 } = this.parseFormulaSync(rule, unitId, subUnitId), valueStr = `${cellValue != null ? cellValue : ""}`;
653
- return !valueStr || valueStr === `${formula1}` || valueStr === `${formula2}`;
654
- }, "skipDefaultFontRender"));
655
- }
656
- validatorFormula(rule, unitId, subUnitId) {
657
- const { formula1, formula2 } = rule, isEqual = formula1 === formula2;
658
- if (Tools.isBlank(formula1) && Tools.isBlank(formula2))
636
+ f(this, "id", T.CHECKBOX);
637
+ f(this, "title", "dataValidation.checkbox.title");
638
+ f(this, "operators", []);
639
+ f(this, "scopes", ["sheet"]);
640
+ f(this, "offsetFormulaByRange", !1);
641
+ f(this, "_formulaService", this.injector.get(K));
642
+ f(this, "skipDefaultFontRender", (e, t, r) => {
643
+ const { unitId: i, subUnitId: o } = r, { formula1: n, formula2: l } = this.parseFormulaSync(e, i, o), u = `${t != null ? t : ""}`;
644
+ return !u || u === `${n}` || u === `${l}`;
645
+ });
646
+ }
647
+ validatorFormula(e, t, r) {
648
+ const { formula1: i, formula2: o } = e, n = i === o;
649
+ if (V.isBlank(i) && V.isBlank(o))
659
650
  return {
660
651
  success: !0
661
652
  };
662
- if (isEqual)
653
+ if (n)
663
654
  return {
664
655
  success: !1,
665
656
  formula1: this.localeService.t("dataValidation.validFail.checkboxEqual"),
666
657
  formula2: this.localeService.t("dataValidation.validFail.checkboxEqual")
667
658
  };
668
- const error1 = getFailMessage(formula1, this.localeService), error2 = getFailMessage(formula2, this.localeService);
659
+ const l = et(i, this.localeService), u = et(o, this.localeService);
669
660
  return {
670
- success: !error1 && !error2,
671
- formula1: error1,
672
- formula2: error2
661
+ success: !l && !u,
662
+ formula1: l,
663
+ formula2: u
673
664
  };
674
665
  }
675
- async parseFormula(rule, unitId, subUnitId) {
676
- var _a12, _b, _c, _d;
677
- const { formula1 = CHECKBOX_FORMULA_1, formula2 = CHECKBOX_FORMULA_2 } = rule, results = await this._formulaService.getRuleFormulaResult(unitId, subUnitId, rule.uid), originFormula1 = isFormulaString(formula1) ? getFormulaResult((_b = (_a12 = results == null ? void 0 : results[0]) == null ? void 0 : _a12.result) == null ? void 0 : _b[0][0]) : formula1, originFormula2 = isFormulaString(formula2) ? getFormulaResult((_d = (_c = results == null ? void 0 : results[1]) == null ? void 0 : _c.result) == null ? void 0 : _d[0][0]) : formula2, isFormulaValid = isLegalFormulaResult(String(originFormula1)) && isLegalFormulaResult(String(originFormula2));
666
+ async parseFormula(e, t, r) {
667
+ var c, m, _, g;
668
+ const { formula1: i = Ve, formula2: o = Me } = e, n = await this._formulaService.getRuleFormulaResult(t, r, e.uid), l = v(i) ? se((m = (c = n == null ? void 0 : n[0]) == null ? void 0 : c.result) == null ? void 0 : m[0][0]) : i, u = v(o) ? se((g = (_ = n == null ? void 0 : n[1]) == null ? void 0 : _.result) == null ? void 0 : g[0][0]) : o, d = C(String(l)) && C(String(u));
678
669
  return {
679
- formula1: transformCheckboxValue(originFormula1),
680
- formula2: transformCheckboxValue(originFormula2),
681
- originFormula1,
682
- originFormula2,
683
- isFormulaValid
670
+ formula1: _e(l),
671
+ formula2: _e(u),
672
+ originFormula1: l,
673
+ originFormula2: u,
674
+ isFormulaValid: d
684
675
  };
685
676
  }
686
- getExtraStyle(rule, value) {
677
+ getExtraStyle(e, t) {
687
678
  return {
688
- tb: WrapStrategy.CLIP
679
+ tb: Se.CLIP
689
680
  };
690
681
  }
691
- parseFormulaSync(rule, unitId, subUnitId) {
692
- var _a12, _b, _c, _d;
693
- const { formula1 = CHECKBOX_FORMULA_1, formula2 = CHECKBOX_FORMULA_2 } = rule, results = this._formulaService.getRuleFormulaResultSync(unitId, subUnitId, rule.uid), originFormula1 = isFormulaString(formula1) ? getFormulaResult((_b = (_a12 = results == null ? void 0 : results[0]) == null ? void 0 : _a12.result) == null ? void 0 : _b[0][0]) : formula1, originFormula2 = isFormulaString(formula2) ? getFormulaResult((_d = (_c = results == null ? void 0 : results[1]) == null ? void 0 : _c.result) == null ? void 0 : _d[0][0]) : formula2, isFormulaValid = isLegalFormulaResult(String(originFormula1)) && isLegalFormulaResult(String(originFormula2));
682
+ parseFormulaSync(e, t, r) {
683
+ var c, m, _, g;
684
+ const { formula1: i = Ve, formula2: o = Me } = e, n = this._formulaService.getRuleFormulaResultSync(t, r, e.uid), l = v(i) ? se((m = (c = n == null ? void 0 : n[0]) == null ? void 0 : c.result) == null ? void 0 : m[0][0]) : i, u = v(o) ? se((g = (_ = n == null ? void 0 : n[1]) == null ? void 0 : _.result) == null ? void 0 : g[0][0]) : o, d = C(String(l)) && C(String(u));
694
685
  return {
695
- formula1: transformCheckboxValue(originFormula1),
696
- formula2: transformCheckboxValue(originFormula2),
697
- originFormula1,
698
- originFormula2,
699
- isFormulaValid
686
+ formula1: _e(l),
687
+ formula2: _e(u),
688
+ originFormula1: l,
689
+ originFormula2: u,
690
+ isFormulaValid: d
700
691
  };
701
692
  }
702
- async isValidType(cellInfo, formula, rule) {
703
- const { value, unitId, subUnitId } = cellInfo, { formula1, formula2, originFormula1, originFormula2 } = await this.parseFormula(rule, unitId, subUnitId);
704
- return !Tools.isDefine(formula1) || !Tools.isDefine(formula2) ? !0 : Tools.isDefine(value) && (String(value) === String(formula1) || String(value) === String(formula2) || String(value) === String(originFormula1 != null ? originFormula1 : "") || String(value) === String(originFormula2 != null ? originFormula2 : ""));
693
+ async isValidType(e, t, r) {
694
+ const { value: i, unitId: o, subUnitId: n } = e, { formula1: l, formula2: u, originFormula1: d, originFormula2: c } = await this.parseFormula(r, o, n);
695
+ return !V.isDefine(l) || !V.isDefine(u) ? !0 : V.isDefine(i) && (String(i) === String(l) || String(i) === String(u) || String(i) === String(d != null ? d : "") || String(i) === String(c != null ? c : ""));
705
696
  }
706
- generateRuleErrorMessage(rule) {
697
+ generateRuleErrorMessage(e) {
707
698
  return this.localeService.t("dataValidation.checkbox.error");
708
699
  }
700
+ }
701
+ const la = {
702
+ [h.BETWEEN]: "dataValidation.date.operators.between",
703
+ [h.EQUAL]: "dataValidation.date.operators.equal",
704
+ [h.GREATER_THAN]: "dataValidation.date.operators.greaterThan",
705
+ [h.GREATER_THAN_OR_EQUAL]: "dataValidation.date.operators.greaterThanOrEqual",
706
+ [h.LESS_THAN]: "dataValidation.date.operators.lessThan",
707
+ [h.LESS_THAN_OR_EQUAL]: "dataValidation.date.operators.lessThanOrEqual",
708
+ [h.NOT_BETWEEN]: "dataValidation.date.operators.notBetween",
709
+ [h.NOT_EQUAL]: "dataValidation.date.operators.notEqual"
709
710
  };
710
- __name(_CheckboxValidator, "CheckboxValidator");
711
- let CheckboxValidator = _CheckboxValidator;
712
- const DateOperatorNameMap = {
713
- [DataValidationOperator.BETWEEN]: "dataValidation.date.operators.between",
714
- [DataValidationOperator.EQUAL]: "dataValidation.date.operators.equal",
715
- [DataValidationOperator.GREATER_THAN]: "dataValidation.date.operators.greaterThan",
716
- [DataValidationOperator.GREATER_THAN_OR_EQUAL]: "dataValidation.date.operators.greaterThanOrEqual",
717
- [DataValidationOperator.LESS_THAN]: "dataValidation.date.operators.lessThan",
718
- [DataValidationOperator.LESS_THAN_OR_EQUAL]: "dataValidation.date.operators.lessThanOrEqual",
719
- [DataValidationOperator.NOT_BETWEEN]: "dataValidation.date.operators.notBetween",
720
- [DataValidationOperator.NOT_EQUAL]: "dataValidation.date.operators.notEqual"
721
- };
722
- DataValidationOperator.BETWEEN + "", DataValidationOperator.EQUAL + "", DataValidationOperator.GREATER_THAN + "", DataValidationOperator.GREATER_THAN_OR_EQUAL + "", DataValidationOperator.LESS_THAN + "", DataValidationOperator.LESS_THAN_OR_EQUAL + "", DataValidationOperator.NOT_BETWEEN + "", DataValidationOperator.NOT_EQUAL + "";
723
- const DateOperatorTitleMap = {
724
- [DataValidationOperator.BETWEEN]: "dataValidation.date.ruleName.between",
725
- [DataValidationOperator.EQUAL]: "dataValidation.date.ruleName.equal",
726
- [DataValidationOperator.GREATER_THAN]: "dataValidation.date.ruleName.greaterThan",
727
- [DataValidationOperator.GREATER_THAN_OR_EQUAL]: "dataValidation.date.ruleName.greaterThanOrEqual",
728
- [DataValidationOperator.LESS_THAN]: "dataValidation.date.ruleName.lessThan",
729
- [DataValidationOperator.LESS_THAN_OR_EQUAL]: "dataValidation.date.ruleName.lessThanOrEqual",
730
- [DataValidationOperator.NOT_BETWEEN]: "dataValidation.date.ruleName.notBetween",
731
- [DataValidationOperator.NOT_EQUAL]: "dataValidation.date.ruleName.notEqual"
732
- }, DateOperatorErrorTitleMap = {
733
- [DataValidationOperator.BETWEEN]: "dataValidation.date.errorMsg.between",
734
- [DataValidationOperator.EQUAL]: "dataValidation.date.errorMsg.equal",
735
- [DataValidationOperator.GREATER_THAN]: "dataValidation.date.errorMsg.greaterThan",
736
- [DataValidationOperator.GREATER_THAN_OR_EQUAL]: "dataValidation.date.errorMsg.greaterThanOrEqual",
737
- [DataValidationOperator.LESS_THAN]: "dataValidation.date.errorMsg.lessThan",
738
- [DataValidationOperator.LESS_THAN_OR_EQUAL]: "dataValidation.date.errorMsg.lessThanOrEqual",
739
- [DataValidationOperator.NOT_BETWEEN]: "dataValidation.date.errorMsg.notBetween",
740
- [DataValidationOperator.NOT_EQUAL]: "dataValidation.date.errorMsg.notEqual"
741
- }, TWO_FORMULA_OPERATOR_COUNT = [
742
- DataValidationOperator.BETWEEN,
743
- DataValidationOperator.NOT_BETWEEN
744
- ], FORMULA1 = "{FORMULA1}", FORMULA2 = "{FORMULA2}";
745
- function serializeListOptions(options) {
746
- return options.filter(Boolean).join(",");
711
+ h.BETWEEN + "", h.EQUAL + "", h.GREATER_THAN + "", h.GREATER_THAN_OR_EQUAL + "", h.LESS_THAN + "", h.LESS_THAN_OR_EQUAL + "", h.NOT_BETWEEN + "", h.NOT_EQUAL + "";
712
+ const ua = {
713
+ [h.BETWEEN]: "dataValidation.date.ruleName.between",
714
+ [h.EQUAL]: "dataValidation.date.ruleName.equal",
715
+ [h.GREATER_THAN]: "dataValidation.date.ruleName.greaterThan",
716
+ [h.GREATER_THAN_OR_EQUAL]: "dataValidation.date.ruleName.greaterThanOrEqual",
717
+ [h.LESS_THAN]: "dataValidation.date.ruleName.lessThan",
718
+ [h.LESS_THAN_OR_EQUAL]: "dataValidation.date.ruleName.lessThanOrEqual",
719
+ [h.NOT_BETWEEN]: "dataValidation.date.ruleName.notBetween",
720
+ [h.NOT_EQUAL]: "dataValidation.date.ruleName.notEqual"
721
+ }, da = {
722
+ [h.BETWEEN]: "dataValidation.date.errorMsg.between",
723
+ [h.EQUAL]: "dataValidation.date.errorMsg.equal",
724
+ [h.GREATER_THAN]: "dataValidation.date.errorMsg.greaterThan",
725
+ [h.GREATER_THAN_OR_EQUAL]: "dataValidation.date.errorMsg.greaterThanOrEqual",
726
+ [h.LESS_THAN]: "dataValidation.date.errorMsg.lessThan",
727
+ [h.LESS_THAN_OR_EQUAL]: "dataValidation.date.errorMsg.lessThanOrEqual",
728
+ [h.NOT_BETWEEN]: "dataValidation.date.errorMsg.notBetween",
729
+ [h.NOT_EQUAL]: "dataValidation.date.errorMsg.notEqual"
730
+ }, Ae = [
731
+ h.BETWEEN,
732
+ h.NOT_BETWEEN
733
+ ], le = "{FORMULA1}", ue = "{FORMULA2}";
734
+ function ir(s) {
735
+ return s.filter(Boolean).join(",");
747
736
  }
748
- __name(serializeListOptions, "serializeListOptions");
749
- function deserializeListOptions(optionsStr) {
750
- return optionsStr.split(",").filter(Boolean);
737
+ function pe(s) {
738
+ return s.split(",").filter(Boolean);
751
739
  }
752
- __name(deserializeListOptions, "deserializeListOptions");
753
- function getDataValidationCellValue(cellData) {
754
- const cellValue = getCellValueOrigin(cellData);
755
- return cellValue == null ? "" : cellValue.toString();
740
+ function sr(s) {
741
+ const a = ne(s);
742
+ return a == null ? "" : a.toString();
756
743
  }
757
- __name(getDataValidationCellValue, "getDataValidationCellValue");
758
- function getTransformedFormula(lexerTreeBuilder, rule, position) {
759
- const { formula1, formula2 } = rule, originStartRow = rule.ranges[0].startRow, originStartColumn = rule.ranges[0].startColumn, offsetRow = position.row - originStartRow, offsetColumn = position.col - originStartColumn, transformedFormula1 = isFormulaString(formula1) ? lexerTreeBuilder.moveFormulaRefOffset(formula1, offsetColumn, offsetRow, !0) : formula1, transformedFormula2 = isFormulaString(formula2) ? lexerTreeBuilder.moveFormulaRefOffset(formula2, offsetColumn, offsetRow, !0) : formula2;
744
+ function De(s, a, e) {
745
+ const { formula1: t, formula2: r } = a, i = a.ranges[0].startRow, o = a.ranges[0].startColumn, n = e.row - i, l = e.col - o, u = v(t) ? s.moveFormulaRefOffset(t, l, n, !0) : t, d = v(r) ? s.moveFormulaRefOffset(r, l, n, !0) : r;
760
746
  return {
761
- transformedFormula1,
762
- transformedFormula2
747
+ transformedFormula1: u,
748
+ transformedFormula2: d
763
749
  };
764
750
  }
765
- __name(getTransformedFormula, "getTransformedFormula");
766
- const transformDate2SerialNumber = /* @__PURE__ */ __name((value) => {
767
- var _a12, _b;
768
- if (value == null || typeof value == "boolean")
751
+ const Ue = (s) => {
752
+ var e, t;
753
+ if (s == null || typeof s == "boolean")
769
754
  return;
770
- if (typeof value == "number" || !Number.isNaN(+value))
771
- return +value;
772
- const v = (_a12 = numfmt.parseDate(value)) == null ? void 0 : _a12.v;
773
- return Tools.isDefine(v) ? v : (_b = numfmt.parseDate(dayjs(value).format("YYYY-MM-DD HH:mm:ss"))) == null ? void 0 : _b.v;
774
- }, "transformDate2SerialNumber"), _DateValidator = class _DateValidator extends BaseDataValidator {
755
+ if (typeof s == "number" || !Number.isNaN(+s))
756
+ return +s;
757
+ const a = (e = Q.parseDate(s)) == null ? void 0 : e.v;
758
+ return V.isDefine(a) ? a : (t = Q.parseDate(at(s).format("YYYY-MM-DD HH:mm:ss"))) == null ? void 0 : t.v;
759
+ };
760
+ class ca extends k {
775
761
  constructor() {
776
762
  super(...arguments);
777
- __publicField(this, "id", DataValidationType.DATE);
778
- __publicField(this, "title", "dataValidation.date.title");
779
- __publicField(this, "operators", [
780
- DataValidationOperator.BETWEEN,
781
- DataValidationOperator.EQUAL,
782
- DataValidationOperator.GREATER_THAN,
783
- DataValidationOperator.GREATER_THAN_OR_EQUAL,
784
- DataValidationOperator.LESS_THAN,
785
- DataValidationOperator.LESS_THAN_OR_EQUAL,
786
- DataValidationOperator.NOT_BETWEEN,
787
- DataValidationOperator.NOT_EQUAL
763
+ f(this, "id", T.DATE);
764
+ f(this, "title", "dataValidation.date.title");
765
+ f(this, "operators", [
766
+ h.BETWEEN,
767
+ h.EQUAL,
768
+ h.GREATER_THAN,
769
+ h.GREATER_THAN_OR_EQUAL,
770
+ h.LESS_THAN,
771
+ h.LESS_THAN_OR_EQUAL,
772
+ h.NOT_BETWEEN,
773
+ h.NOT_EQUAL
788
774
  ]);
789
- __publicField(this, "scopes", ["sheet"]);
790
- __publicField(this, "_customFormulaService", this.injector.get(DataValidationCustomFormulaService));
791
- __publicField(this, "_lexerTreeBuilder", this.injector.get(LexerTreeBuilder));
775
+ f(this, "scopes", ["sheet"]);
776
+ f(this, "_customFormulaService", this.injector.get(P));
777
+ f(this, "_lexerTreeBuilder", this.injector.get(Y));
792
778
  }
793
- async parseFormula(rule, unitId, subUnitId, row, column) {
794
- const formulaResult1 = await this._customFormulaService.getCellFormulaValue(unitId, subUnitId, rule.uid, row, column), formulaResult2 = await this._customFormulaService.getCellFormula2Value(unitId, subUnitId, rule.uid, row, column), { formula1, formula2 } = rule, isFormulaValid = isLegalFormulaResult(String(formulaResult1 == null ? void 0 : formulaResult1.v)) && isLegalFormulaResult(String(formulaResult2 == null ? void 0 : formulaResult2.v));
779
+ async parseFormula(e, t, r, i, o) {
780
+ const n = await this._customFormulaService.getCellFormulaValue(t, r, e.uid, i, o), l = await this._customFormulaService.getCellFormula2Value(t, r, e.uid, i, o), { formula1: u, formula2: d } = e, c = C(String(n == null ? void 0 : n.v)) && C(String(l == null ? void 0 : l.v));
795
781
  return {
796
- formula1: transformDate2SerialNumber(isFormulaString(formula1) ? formulaResult1 == null ? void 0 : formulaResult1.v : formula1),
797
- formula2: transformDate2SerialNumber(isFormulaString(formula2) ? formulaResult2 == null ? void 0 : formulaResult2.v : formula2),
798
- isFormulaValid
782
+ formula1: Ue(v(u) ? n == null ? void 0 : n.v : u),
783
+ formula2: Ue(v(d) ? l == null ? void 0 : l.v : d),
784
+ isFormulaValid: c
799
785
  };
800
786
  }
801
- async isValidType(info) {
802
- const { interceptValue, value } = info;
803
- return typeof value == "number" && typeof interceptValue == "string" ? !0 : typeof interceptValue == "string" ? !!numfmt.parseDate(interceptValue) : !1;
787
+ async isValidType(e) {
788
+ const { interceptValue: t, value: r } = e;
789
+ return typeof r == "number" && typeof t == "string" ? !0 : typeof t == "string" ? !!Q.parseDate(t) : !1;
804
790
  }
805
- _validatorSingleFormula(formula) {
806
- return !Tools.isBlank(formula) && (isFormulaString(formula) || !Number.isNaN(+formula) || !!(formula && numfmt.parseDate(formula)));
791
+ _validatorSingleFormula(e) {
792
+ return !V.isBlank(e) && (v(e) || !Number.isNaN(+e) || !!(e && Q.parseDate(e)));
807
793
  }
808
- validatorFormula(rule, unitId, subUnitId) {
809
- const operator = rule.operator;
810
- if (!operator)
794
+ validatorFormula(e, t, r) {
795
+ const i = e.operator;
796
+ if (!i)
811
797
  return {
812
798
  success: !1
813
799
  };
814
- const formula1Success = this._validatorSingleFormula(rule.formula1), errorMsg = this.localeService.t("dataValidation.validFail.date");
815
- if (TWO_FORMULA_OPERATOR_COUNT.includes(operator)) {
816
- const formula2Success = this._validatorSingleFormula(rule.formula2);
800
+ const o = this._validatorSingleFormula(e.formula1), n = this.localeService.t("dataValidation.validFail.date");
801
+ if (Ae.includes(i)) {
802
+ const u = this._validatorSingleFormula(e.formula2);
817
803
  return {
818
- success: formula1Success && formula2Success,
819
- formula1: formula1Success ? void 0 : errorMsg,
820
- formula2: formula2Success ? void 0 : errorMsg
804
+ success: o && u,
805
+ formula1: o ? void 0 : n,
806
+ formula2: u ? void 0 : n
821
807
  };
822
808
  }
823
809
  return {
824
- success: formula1Success,
825
- formula1: formula1Success ? void 0 : errorMsg
810
+ success: o,
811
+ formula1: o ? void 0 : n
826
812
  };
827
813
  }
828
- normalizeFormula(rule, _unitId, _subUnitId) {
829
- const { formula1, formula2, bizInfo } = rule, normlizeSingleFormula = /* @__PURE__ */ __name((formula) => {
830
- var _a12;
831
- if (!formula)
832
- return formula;
833
- let date;
834
- if (!Number.isNaN(+formula))
835
- date = numfmt.dateFromSerial(+formula);
814
+ normalizeFormula(e, t, r) {
815
+ const { formula1: i, formula2: o, bizInfo: n } = e, l = (u) => {
816
+ var c;
817
+ if (!u)
818
+ return u;
819
+ let d;
820
+ if (!Number.isNaN(+u))
821
+ d = Q.dateFromSerial(+u);
836
822
  else {
837
- const res = (_a12 = numfmt.parseDate(formula)) == null ? void 0 : _a12.v;
838
- if (res == null)
823
+ const m = (c = Q.parseDate(u)) == null ? void 0 : c.v;
824
+ if (m == null)
839
825
  return "";
840
- date = numfmt.dateFromSerial(res);
826
+ d = Q.dateFromSerial(m);
841
827
  }
842
- return dayjs(`${date[0]}/${date[1]}/${date[2]} ${date[3]}:${date[4]}:${date[5]}`).format(bizInfo != null && bizInfo.showTime ? "YYYY-MM-DD HH:mm:ss" : "YYYY-MM-DD");
843
- }, "normlizeSingleFormula");
828
+ return at(`${d[0]}/${d[1]}/${d[2]} ${d[3]}:${d[4]}:${d[5]}`).format(n != null && n.showTime ? "YYYY-MM-DD HH:mm:ss" : "YYYY-MM-DD");
829
+ };
844
830
  return {
845
- formula1: isFormulaString(formula1) ? formula1 : normlizeSingleFormula(`${formula1}`),
846
- formula2: isFormulaString(formula2) ? formula2 : normlizeSingleFormula(`${formula2}`)
831
+ formula1: v(i) ? i : l(`${i}`),
832
+ formula2: v(o) ? o : l(`${o}`)
847
833
  };
848
834
  }
849
- transform(cellInfo, _formula, _rule) {
850
- const { value } = cellInfo;
835
+ transform(e, t, r) {
836
+ const { value: i } = e;
851
837
  return {
852
- ...cellInfo,
853
- value: transformDate2SerialNumber(value)
838
+ ...e,
839
+ value: Ue(i)
854
840
  };
855
841
  }
856
842
  get operatorNames() {
857
- return this.operators.map((operator) => this.localeService.t(DateOperatorNameMap[operator]));
843
+ return this.operators.map((e) => this.localeService.t(la[e]));
858
844
  }
859
- generateRuleName(rule) {
860
- var _a12, _b;
861
- if (!rule.operator)
845
+ generateRuleName(e) {
846
+ var r, i;
847
+ if (!e.operator)
862
848
  return this.titleStr;
863
- const ruleName = this.localeService.t(DateOperatorTitleMap[rule.operator]).replace(FORMULA1, (_a12 = rule.formula1) != null ? _a12 : "").replace(FORMULA2, (_b = rule.formula2) != null ? _b : "");
864
- return `${this.titleStr} ${ruleName}`;
849
+ const t = this.localeService.t(ua[e.operator]).replace(le, (r = e.formula1) != null ? r : "").replace(ue, (i = e.formula2) != null ? i : "");
850
+ return `${this.titleStr} ${t}`;
865
851
  }
866
- generateRuleErrorMessage(rule, pos) {
867
- if (!rule.operator)
852
+ generateRuleErrorMessage(e, t) {
853
+ if (!e.operator)
868
854
  return this.titleStr;
869
- const { transformedFormula1, transformedFormula2 } = getTransformedFormula(this._lexerTreeBuilder, rule, pos);
870
- return `${this.localeService.t(DateOperatorErrorTitleMap[rule.operator]).replace(FORMULA1, transformedFormula1 != null ? transformedFormula1 : "").replace(FORMULA2, transformedFormula2 != null ? transformedFormula2 : "")}`;
855
+ const { transformedFormula1: r, transformedFormula2: i } = De(this._lexerTreeBuilder, e, t);
856
+ return `${this.localeService.t(da[e.operator]).replace(le, r != null ? r : "").replace(ue, i != null ? i : "")}`;
871
857
  }
858
+ }
859
+ h.BETWEEN + "", h.EQUAL + "", h.GREATER_THAN + "", h.GREATER_THAN_OR_EQUAL + "", h.LESS_THAN + "", h.LESS_THAN_OR_EQUAL + "", h.NOT_BETWEEN + "", h.NOT_EQUAL + "";
860
+ h.BETWEEN + "", h.EQUAL + "", h.GREATER_THAN + "", h.GREATER_THAN_OR_EQUAL + "", h.LESS_THAN + "", h.LESS_THAN_OR_EQUAL + "", h.NOT_BETWEEN + "", h.NOT_EQUAL + "";
861
+ const ht = {
862
+ [h.BETWEEN]: "dataValidation.errorMsg.between",
863
+ [h.EQUAL]: "dataValidation.errorMsg.equal",
864
+ [h.GREATER_THAN]: "dataValidation.errorMsg.greaterThan",
865
+ [h.GREATER_THAN_OR_EQUAL]: "dataValidation.errorMsg.greaterThanOrEqual",
866
+ [h.LESS_THAN]: "dataValidation.errorMsg.lessThan",
867
+ [h.LESS_THAN_OR_EQUAL]: "dataValidation.errorMsg.lessThanOrEqual",
868
+ [h.NOT_BETWEEN]: "dataValidation.errorMsg.notBetween",
869
+ [h.NOT_EQUAL]: "dataValidation.errorMsg.notEqual"
872
870
  };
873
- __name(_DateValidator, "DateValidator");
874
- let DateValidator = _DateValidator;
875
- DataValidationOperator.BETWEEN + "", DataValidationOperator.EQUAL + "", DataValidationOperator.GREATER_THAN + "", DataValidationOperator.GREATER_THAN_OR_EQUAL + "", DataValidationOperator.LESS_THAN + "", DataValidationOperator.LESS_THAN_OR_EQUAL + "", DataValidationOperator.NOT_BETWEEN + "", DataValidationOperator.NOT_EQUAL + "";
876
- DataValidationOperator.BETWEEN + "", DataValidationOperator.EQUAL + "", DataValidationOperator.GREATER_THAN + "", DataValidationOperator.GREATER_THAN_OR_EQUAL + "", DataValidationOperator.LESS_THAN + "", DataValidationOperator.LESS_THAN_OR_EQUAL + "", DataValidationOperator.NOT_BETWEEN + "", DataValidationOperator.NOT_EQUAL + "";
877
- const OperatorErrorTitleMap = {
878
- [DataValidationOperator.BETWEEN]: "dataValidation.errorMsg.between",
879
- [DataValidationOperator.EQUAL]: "dataValidation.errorMsg.equal",
880
- [DataValidationOperator.GREATER_THAN]: "dataValidation.errorMsg.greaterThan",
881
- [DataValidationOperator.GREATER_THAN_OR_EQUAL]: "dataValidation.errorMsg.greaterThanOrEqual",
882
- [DataValidationOperator.LESS_THAN]: "dataValidation.errorMsg.lessThan",
883
- [DataValidationOperator.LESS_THAN_OR_EQUAL]: "dataValidation.errorMsg.lessThanOrEqual",
884
- [DataValidationOperator.NOT_BETWEEN]: "dataValidation.errorMsg.notBetween",
885
- [DataValidationOperator.NOT_EQUAL]: "dataValidation.errorMsg.notEqual"
886
- };
887
- function getCellValueNumber(cellValue) {
888
- let str = cellValue;
889
- return typeof cellValue == "string" ? ((cellValue.startsWith("¥") || cellValue.startsWith("$")) && (str = cellValue.slice(1)), +str) : +cellValue;
871
+ function ye(s) {
872
+ let a = s;
873
+ return typeof s == "string" ? ((s.startsWith("¥") || s.startsWith("$")) && (a = s.slice(1)), +a) : +s;
890
874
  }
891
- __name(getCellValueNumber, "getCellValueNumber");
892
- const _DecimalValidator = class _DecimalValidator extends BaseDataValidator {
875
+ class ha extends k {
893
876
  constructor() {
894
877
  super(...arguments);
895
- __publicField(this, "_customFormulaService", this.injector.get(DataValidationCustomFormulaService));
896
- __publicField(this, "id", DataValidationType.DECIMAL);
897
- __publicField(this, "_lexerTreeBuilder", this.injector.get(LexerTreeBuilder));
898
- __publicField(this, "title", "dataValidation.decimal.title");
899
- __publicField(this, "operators", [
900
- DataValidationOperator.BETWEEN,
901
- DataValidationOperator.EQUAL,
902
- DataValidationOperator.GREATER_THAN,
903
- DataValidationOperator.GREATER_THAN_OR_EQUAL,
904
- DataValidationOperator.LESS_THAN,
905
- DataValidationOperator.LESS_THAN_OR_EQUAL,
906
- DataValidationOperator.NOT_BETWEEN,
907
- DataValidationOperator.NOT_EQUAL
878
+ f(this, "_customFormulaService", this.injector.get(P));
879
+ f(this, "id", T.DECIMAL);
880
+ f(this, "_lexerTreeBuilder", this.injector.get(Y));
881
+ f(this, "title", "dataValidation.decimal.title");
882
+ f(this, "operators", [
883
+ h.BETWEEN,
884
+ h.EQUAL,
885
+ h.GREATER_THAN,
886
+ h.GREATER_THAN_OR_EQUAL,
887
+ h.LESS_THAN,
888
+ h.LESS_THAN_OR_EQUAL,
889
+ h.NOT_BETWEEN,
890
+ h.NOT_EQUAL
908
891
  ]);
909
- __publicField(this, "scopes", ["sheet"]);
892
+ f(this, "scopes", ["sheet"]);
910
893
  }
911
- _isFormulaOrNumber(formula) {
912
- return !Tools.isBlank(formula) && (isFormulaString(formula) || !Number.isNaN(+formula));
894
+ _isFormulaOrNumber(e) {
895
+ return !V.isBlank(e) && (v(e) || !Number.isNaN(+e));
913
896
  }
914
- async isValidType(cellInfo, formula, rule) {
915
- const { value: cellValue } = cellInfo;
916
- return !Number.isNaN(getCellValueNumber(cellValue));
897
+ async isValidType(e, t, r) {
898
+ const { value: i } = e;
899
+ return !Number.isNaN(ye(i));
917
900
  }
918
- transform(cellInfo, formula, rule) {
919
- const { value: cellValue } = cellInfo;
901
+ transform(e, t, r) {
902
+ const { value: i } = e;
920
903
  return {
921
- ...cellInfo,
922
- value: getCellValueNumber(cellValue)
904
+ ...e,
905
+ value: ye(i)
923
906
  };
924
907
  }
925
- _parseNumber(formula) {
926
- return formula == null ? Number.NaN : +formula;
908
+ _parseNumber(e) {
909
+ return e == null ? Number.NaN : +e;
927
910
  }
928
- async parseFormula(rule, unitId, subUnitId, row, column) {
929
- const formulaResult1 = await this._customFormulaService.getCellFormulaValue(unitId, subUnitId, rule.uid, row, column), formulaResult2 = await this._customFormulaService.getCellFormula2Value(unitId, subUnitId, rule.uid, row, column), { formula1, formula2 } = rule, isFormulaValid = isLegalFormulaResult(String(formulaResult1 == null ? void 0 : formulaResult1.v)) && isLegalFormulaResult(String(formulaResult2 == null ? void 0 : formulaResult2.v));
911
+ async parseFormula(e, t, r, i, o) {
912
+ const n = await this._customFormulaService.getCellFormulaValue(t, r, e.uid, i, o), l = await this._customFormulaService.getCellFormula2Value(t, r, e.uid, i, o), { formula1: u, formula2: d } = e, c = C(String(n == null ? void 0 : n.v)) && C(String(l == null ? void 0 : l.v));
930
913
  return {
931
- formula1: this._parseNumber(isFormulaString(formula1) ? formulaResult1 == null ? void 0 : formulaResult1.v : formula1),
932
- formula2: this._parseNumber(isFormulaString(formula2) ? formulaResult2 == null ? void 0 : formulaResult2.v : formula2),
933
- isFormulaValid
914
+ formula1: this._parseNumber(v(u) ? n == null ? void 0 : n.v : u),
915
+ formula2: this._parseNumber(v(d) ? l == null ? void 0 : l.v : d),
916
+ isFormulaValid: c
934
917
  };
935
918
  }
936
- validatorFormula(rule, unitId, subUnitId) {
937
- const operator = rule.operator;
938
- if (!operator)
919
+ validatorFormula(e, t, r) {
920
+ const i = e.operator;
921
+ if (!i)
939
922
  return {
940
923
  success: !1
941
924
  };
942
- const formula1Success = Tools.isDefine(rule.formula1) && this._isFormulaOrNumber(rule.formula1), formula2Success = Tools.isDefine(rule.formula2) && this._isFormulaOrNumber(rule.formula2), isTwoFormula = TWO_FORMULA_OPERATOR_COUNT.includes(operator), errorMsg = this.localeService.t("dataValidation.validFail.number");
943
- return isTwoFormula ? {
944
- success: formula1Success && formula2Success,
945
- formula1: formula1Success ? void 0 : errorMsg,
946
- formula2: formula2Success ? void 0 : errorMsg
925
+ const o = V.isDefine(e.formula1) && this._isFormulaOrNumber(e.formula1), n = V.isDefine(e.formula2) && this._isFormulaOrNumber(e.formula2), l = Ae.includes(i), u = this.localeService.t("dataValidation.validFail.number");
926
+ return l ? {
927
+ success: o && n,
928
+ formula1: o ? void 0 : u,
929
+ formula2: n ? void 0 : u
947
930
  } : {
948
- success: formula1Success,
949
- formula1: formula1Success ? "" : errorMsg
931
+ success: o,
932
+ formula1: o ? "" : u
950
933
  };
951
934
  }
952
- generateRuleErrorMessage(rule, position) {
953
- if (!rule.operator)
935
+ generateRuleErrorMessage(e, t) {
936
+ if (!e.operator)
954
937
  return this.titleStr;
955
- const { transformedFormula1, transformedFormula2 } = getTransformedFormula(this._lexerTreeBuilder, rule, position);
956
- return `${this.localeService.t(OperatorErrorTitleMap[rule.operator]).replace(FORMULA1, transformedFormula1 != null ? transformedFormula1 : "").replace(FORMULA2, transformedFormula2 != null ? transformedFormula2 : "")}`;
938
+ const { transformedFormula1: r, transformedFormula2: i } = De(this._lexerTreeBuilder, e, t);
939
+ return `${this.localeService.t(ht[e.operator]).replace(le, r != null ? r : "").replace(ue, i != null ? i : "")}`;
957
940
  }
958
- };
959
- __name(_DecimalValidator, "DecimalValidator");
960
- let DecimalValidator = _DecimalValidator;
961
- function getRuleFormulaResultSet(result) {
962
- if (!result)
941
+ }
942
+ function Pe(s) {
943
+ if (!s)
963
944
  return [];
964
- const resultSet = /* @__PURE__ */ new Set();
965
- return result.forEach(
966
- (row) => {
967
- row.forEach((cell) => {
968
- var _a12, _b;
969
- const value = getCellValueOrigin(cell);
970
- if (value != null) {
971
- if (typeof value != "string" && typeof (cell == null ? void 0 : cell.s) == "object" && ((_b = (_a12 = cell.s) == null ? void 0 : _a12.n) != null && _b.pattern)) {
972
- resultSet.add(numfmt.format(cell.s.n.pattern, value, { throws: !1 }));
945
+ const a = /* @__PURE__ */ new Set();
946
+ return s.forEach(
947
+ (e) => {
948
+ e.forEach((t) => {
949
+ var i, o;
950
+ const r = ne(t);
951
+ if (r != null) {
952
+ if (typeof r != "string" && typeof (t == null ? void 0 : t.s) == "object" && ((o = (i = t.s) == null ? void 0 : i.n) != null && o.pattern)) {
953
+ a.add(Q.format(t.s.n.pattern, r, { throws: !1 }));
973
954
  return;
974
955
  }
975
- isLegalFormulaResult(value.toString()) && resultSet.add(value.toString());
956
+ C(r.toString()) && a.add(r.toString());
976
957
  }
977
958
  });
978
959
  }
979
- ), [...resultSet];
960
+ ), [...a];
980
961
  }
981
- __name(getRuleFormulaResultSet, "getRuleFormulaResultSet");
982
- const supportedFormula = [
962
+ const ma = [
983
963
  "if",
984
964
  "indirect",
985
965
  "choose",
986
966
  "offset"
987
967
  ];
988
- function isValidListFormula(formula, lexer) {
989
- if (!isFormulaString(formula) || isReferenceString(formula.slice(1)))
968
+ function fa(s, a) {
969
+ if (!v(s) || dt(s.slice(1)))
990
970
  return !0;
991
- const nodes = lexer.sequenceNodesBuilder(formula);
992
- return nodes && nodes.some((node) => typeof node == "object" && node.nodeType === sequenceNodeType.FUNCTION && supportedFormula.indexOf(node.token.toLowerCase()) > -1);
971
+ const t = a.sequenceNodesBuilder(s);
972
+ return t && t.some((r) => typeof r == "object" && r.nodeType === Qt.FUNCTION && ma.indexOf(r.token.toLowerCase()) > -1);
993
973
  }
994
- __name(isValidListFormula, "isValidListFormula");
995
- function isRuleIntersects(rule, sheetName) {
996
- const { formula1 = "", ranges } = rule;
997
- if (isReferenceString(formula1.slice(1))) {
998
- const refRange = deserializeRangeWithSheet(formula1.slice(1));
999
- if ((!refRange.sheetName || refRange.sheetName === sheetName) && ranges.some((range) => Rectangle.intersects(range, refRange.range)))
974
+ function ga(s, a) {
975
+ const { formula1: e = "", ranges: t } = s;
976
+ if (dt(e.slice(1))) {
977
+ const i = qt(e.slice(1));
978
+ if ((!i.sheetName || i.sheetName === a) && t.some((o) => I.intersects(o, i.range)))
1000
979
  return !0;
1001
980
  }
1002
981
  return !1;
1003
982
  }
1004
- __name(isRuleIntersects, "isRuleIntersects");
1005
- const _ListValidator = class _ListValidator extends BaseDataValidator {
983
+ class mt extends k {
1006
984
  constructor() {
1007
985
  super(...arguments);
1008
- __publicField(this, "formulaService", this.injector.get(DataValidationFormulaService));
1009
- __publicField(this, "_lexer", this.injector.get(LexerTreeBuilder));
1010
- __publicField(this, "_univerInstanceService", this.injector.get(IUniverInstanceService));
1011
- __publicField(this, "offsetFormulaByRange", !1);
1012
- __publicField(this, "id", DataValidationType.LIST);
1013
- __publicField(this, "title", "dataValidation.list.title");
1014
- __publicField(this, "operators", []);
1015
- __publicField(this, "scopes", ["sheet"]);
1016
- __publicField(this, "skipDefaultFontRender", /* @__PURE__ */ __name((rule) => rule.renderMode !== DataValidationRenderMode.TEXT, "skipDefaultFontRender"));
1017
- }
1018
- validatorFormula(rule, unitId, subUnitId) {
1019
- var _a12, _b, _c;
1020
- const success = !Tools.isBlank(rule.formula1), valid = isValidListFormula((_a12 = rule.formula1) != null ? _a12 : "", this._lexer), sheetName = (_c = (_b = this._univerInstanceService.getUnit(unitId, UniverInstanceType.UNIVER_SHEET)) == null ? void 0 : _b.getSheetBySheetId(subUnitId)) == null ? void 0 : _c.getName(), isIntersects = isRuleIntersects(rule, sheetName != null ? sheetName : "");
986
+ f(this, "formulaService", this.injector.get(K));
987
+ f(this, "_lexer", this.injector.get(Y));
988
+ f(this, "_univerInstanceService", this.injector.get(O));
989
+ f(this, "offsetFormulaByRange", !1);
990
+ f(this, "id", T.LIST);
991
+ f(this, "title", "dataValidation.list.title");
992
+ f(this, "operators", []);
993
+ f(this, "scopes", ["sheet"]);
994
+ f(this, "skipDefaultFontRender", (e) => e.renderMode !== Be.TEXT);
995
+ }
996
+ validatorFormula(e, t, r) {
997
+ var u, d, c;
998
+ const i = !V.isBlank(e.formula1), o = fa((u = e.formula1) != null ? u : "", this._lexer), n = (c = (d = this._univerInstanceService.getUnit(t, N.UNIVER_SHEET)) == null ? void 0 : d.getSheetBySheetId(r)) == null ? void 0 : c.getName(), l = ga(e, n != null ? n : "");
1021
999
  return {
1022
- success: !!(success && valid && !isIntersects),
1023
- formula1: success ? valid ? isIntersects ? this.localeService.t("dataValidation.validFail.listIntersects") : void 0 : this.localeService.t("dataValidation.validFail.listInvalid") : this.localeService.t("dataValidation.validFail.list")
1000
+ success: !!(i && o && !l),
1001
+ formula1: i ? o ? l ? this.localeService.t("dataValidation.validFail.listIntersects") : void 0 : this.localeService.t("dataValidation.validFail.listInvalid") : this.localeService.t("dataValidation.validFail.list")
1024
1002
  };
1025
1003
  }
1026
- getExtraStyle(rule, value, { style: defaultStyle }) {
1027
- var _a12;
1028
- const tb = (_a12 = defaultStyle.tb !== WrapStrategy.OVERFLOW ? defaultStyle.tb : WrapStrategy.CLIP) != null ? _a12 : WrapStrategy.WRAP;
1029
- if (rule.type === DataValidationType.LIST && (rule.renderMode === DataValidationRenderMode.ARROW || rule.renderMode === DataValidationRenderMode.TEXT)) {
1030
- const colorMap = this.getListWithColorMap(rule), valueStr = `${value != null ? value : ""}`, color = colorMap[valueStr];
1031
- if (color)
1004
+ getExtraStyle(e, t, { style: r }) {
1005
+ var o;
1006
+ const i = (o = r.tb !== Se.OVERFLOW ? r.tb : Se.CLIP) != null ? o : Se.WRAP;
1007
+ if (e.type === T.LIST && (e.renderMode === Be.ARROW || e.renderMode === Be.TEXT)) {
1008
+ const n = this.getListWithColorMap(e), l = `${t != null ? t : ""}`, u = n[l];
1009
+ if (u)
1032
1010
  return {
1033
1011
  bg: {
1034
- rgb: color
1012
+ rgb: u
1035
1013
  },
1036
- tb
1014
+ tb: i
1037
1015
  };
1038
1016
  }
1039
1017
  return {
1040
- tb
1018
+ tb: i
1041
1019
  };
1042
1020
  }
1043
- parseCellValue(cellValue) {
1044
- const cellString = cellValue.toString();
1045
- return deserializeListOptions(cellString);
1021
+ parseCellValue(e) {
1022
+ const t = e.toString();
1023
+ return pe(t);
1046
1024
  }
1047
- async parseFormula(rule, unitId, subUnitId) {
1048
- var _a12, _b;
1049
- const results = await this.formulaService.getRuleFormulaResult(unitId, subUnitId, rule.uid), formulaResult1 = getFormulaResult((_b = (_a12 = results == null ? void 0 : results[0]) == null ? void 0 : _a12.result) == null ? void 0 : _b[0][0]);
1025
+ async parseFormula(e, t, r) {
1026
+ var l, u;
1027
+ const i = await this.formulaService.getRuleFormulaResult(t, r, e.uid), o = se((u = (l = i == null ? void 0 : i[0]) == null ? void 0 : l.result) == null ? void 0 : u[0][0]);
1050
1028
  return {
1051
1029
  formula1: void 0,
1052
1030
  formula2: void 0,
1053
- isFormulaValid: isLegalFormulaResult(String(formulaResult1))
1031
+ isFormulaValid: C(String(o))
1054
1032
  };
1055
1033
  }
1056
- async isValidType(cellInfo, formula, rule) {
1057
- var _a12, _b;
1058
- const { value, unitId, subUnitId } = cellInfo, { formula1 = "" } = rule, results = await this.formulaService.getRuleFormulaResult(unitId, subUnitId, rule.uid), formula1Result = isFormulaString(formula1) ? getRuleFormulaResultSet((_b = (_a12 = results == null ? void 0 : results[0]) == null ? void 0 : _a12.result) == null ? void 0 : _b[0][0]) : deserializeListOptions(formula1);
1059
- return this.parseCellValue(value).every((i) => formula1Result.includes(i));
1034
+ async isValidType(e, t, r) {
1035
+ var m, _;
1036
+ const { value: i, unitId: o, subUnitId: n } = e, { formula1: l = "" } = r, u = await this.formulaService.getRuleFormulaResult(o, n, r.uid), d = v(l) ? Pe((_ = (m = u == null ? void 0 : u[0]) == null ? void 0 : m.result) == null ? void 0 : _[0][0]) : pe(l);
1037
+ return this.parseCellValue(i).every((g) => d.includes(g));
1060
1038
  }
1061
1039
  generateRuleName() {
1062
1040
  return this.localeService.t("dataValidation.list.name");
@@ -1064,1383 +1042,1368 @@ const _ListValidator = class _ListValidator extends BaseDataValidator {
1064
1042
  generateRuleErrorMessage() {
1065
1043
  return this.localeService.t("dataValidation.list.error");
1066
1044
  }
1067
- getList(rule, currentUnitId, currentSubUnitId) {
1068
- var _a12, _b, _c, _d;
1069
- const { formula1 = "" } = rule, univerInstanceService = this.injector.get(IUniverInstanceService), workbook = (_a12 = currentUnitId ? univerInstanceService.getUniverSheetInstance(currentUnitId) : void 0) != null ? _a12 : univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET);
1070
- if (!workbook) return [];
1071
- const worksheet = (_b = currentSubUnitId ? workbook.getSheetBySheetId(currentSubUnitId) : void 0) != null ? _b : workbook.getActiveSheet();
1072
- if (!worksheet) return [];
1073
- const unitId = workbook.getUnitId(), subUnitId = worksheet.getSheetId(), results = this.formulaService.getRuleFormulaResultSync(unitId, subUnitId, rule.uid);
1074
- return isFormulaString(formula1) ? getRuleFormulaResultSet((_d = (_c = results == null ? void 0 : results[0]) == null ? void 0 : _c.result) == null ? void 0 : _d[0][0]) : deserializeListOptions(formula1);
1075
- }
1076
- async getListAsync(rule, currentUnitId, currentSubUnitId) {
1077
- var _a12, _b, _c, _d;
1078
- const { formula1 = "" } = rule, univerInstanceService = this.injector.get(IUniverInstanceService), workbook = (_a12 = currentUnitId ? univerInstanceService.getUniverSheetInstance(currentUnitId) : void 0) != null ? _a12 : univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET);
1079
- if (!workbook) return [];
1080
- const worksheet = (_b = currentSubUnitId ? workbook.getSheetBySheetId(currentSubUnitId) : void 0) != null ? _b : workbook.getActiveSheet();
1081
- if (!worksheet) return [];
1082
- const unitId = workbook.getUnitId(), subUnitId = worksheet.getSheetId(), results = await this.formulaService.getRuleFormulaResult(unitId, subUnitId, rule.uid);
1083
- return isFormulaString(formula1) ? getRuleFormulaResultSet((_d = (_c = results == null ? void 0 : results[0]) == null ? void 0 : _c.result) == null ? void 0 : _d[0][0]) : deserializeListOptions(formula1);
1084
- }
1085
- getListWithColor(rule, currentUnitId, currentSubUnitId) {
1086
- const list = this.getList(rule, currentUnitId, currentSubUnitId), colorList = (rule.formula2 || "").split(",");
1087
- return list.map((label, i) => ({ label, color: colorList[i] }));
1088
- }
1089
- getListWithColorMap(rule, currentUnitId, currentSubUnitId) {
1090
- const list = this.getListWithColor(rule, currentUnitId, currentSubUnitId), map = {};
1091
- return list.forEach((item) => {
1092
- item.color && (map[item.label] = item.color);
1093
- }), map;
1045
+ getList(e, t, r) {
1046
+ var m, _, g, R;
1047
+ const { formula1: i = "" } = e, o = this.injector.get(O), n = (m = t ? o.getUniverSheetInstance(t) : void 0) != null ? m : o.getCurrentUnitForType(N.UNIVER_SHEET);
1048
+ if (!n) return [];
1049
+ const l = (_ = r ? n.getSheetBySheetId(r) : void 0) != null ? _ : n.getActiveSheet();
1050
+ if (!l) return [];
1051
+ const u = n.getUnitId(), d = l.getSheetId(), c = this.formulaService.getRuleFormulaResultSync(u, d, e.uid);
1052
+ return v(i) ? Pe((R = (g = c == null ? void 0 : c[0]) == null ? void 0 : g.result) == null ? void 0 : R[0][0]) : pe(i);
1053
+ }
1054
+ async getListAsync(e, t, r) {
1055
+ var m, _, g, R;
1056
+ const { formula1: i = "" } = e, o = this.injector.get(O), n = (m = t ? o.getUniverSheetInstance(t) : void 0) != null ? m : o.getCurrentUnitForType(N.UNIVER_SHEET);
1057
+ if (!n) return [];
1058
+ const l = (_ = r ? n.getSheetBySheetId(r) : void 0) != null ? _ : n.getActiveSheet();
1059
+ if (!l) return [];
1060
+ const u = n.getUnitId(), d = l.getSheetId(), c = await this.formulaService.getRuleFormulaResult(u, d, e.uid);
1061
+ return v(i) ? Pe((R = (g = c == null ? void 0 : c[0]) == null ? void 0 : g.result) == null ? void 0 : R[0][0]) : pe(i);
1062
+ }
1063
+ getListWithColor(e, t, r) {
1064
+ const i = this.getList(e, t, r), o = (e.formula2 || "").split(",");
1065
+ return i.map((n, l) => ({ label: n, color: o[l] }));
1066
+ }
1067
+ getListWithColorMap(e, t, r) {
1068
+ const i = this.getListWithColor(e, t, r), o = {};
1069
+ return i.forEach((n) => {
1070
+ n.color && (o[n.label] = n.color);
1071
+ }), o;
1094
1072
  }
1095
- };
1096
- __name(_ListValidator, "ListValidator");
1097
- let ListValidator = _ListValidator;
1098
- const _TextLengthValidator = class _TextLengthValidator extends BaseDataValidator {
1073
+ }
1074
+ class _a extends k {
1099
1075
  constructor() {
1100
1076
  super(...arguments);
1101
- __publicField(this, "id", DataValidationType.TEXT_LENGTH);
1102
- __publicField(this, "title", "dataValidation.textLength.title");
1103
- __publicField(this, "_lexerTreeBuilder", this.injector.get(LexerTreeBuilder));
1104
- __publicField(this, "operators", [
1105
- DataValidationOperator.BETWEEN,
1106
- DataValidationOperator.EQUAL,
1107
- DataValidationOperator.GREATER_THAN,
1108
- DataValidationOperator.GREATER_THAN_OR_EQUAL,
1109
- DataValidationOperator.LESS_THAN,
1110
- DataValidationOperator.LESS_THAN_OR_EQUAL,
1111
- DataValidationOperator.NOT_BETWEEN,
1112
- DataValidationOperator.NOT_EQUAL
1077
+ f(this, "id", T.TEXT_LENGTH);
1078
+ f(this, "title", "dataValidation.textLength.title");
1079
+ f(this, "_lexerTreeBuilder", this.injector.get(Y));
1080
+ f(this, "operators", [
1081
+ h.BETWEEN,
1082
+ h.EQUAL,
1083
+ h.GREATER_THAN,
1084
+ h.GREATER_THAN_OR_EQUAL,
1085
+ h.LESS_THAN,
1086
+ h.LESS_THAN_OR_EQUAL,
1087
+ h.NOT_BETWEEN,
1088
+ h.NOT_EQUAL
1113
1089
  ]);
1114
- __publicField(this, "scopes", ["sheet"]);
1115
- __publicField(this, "_customFormulaService", this.injector.get(DataValidationCustomFormulaService));
1090
+ f(this, "scopes", ["sheet"]);
1091
+ f(this, "_customFormulaService", this.injector.get(P));
1116
1092
  }
1117
- _isFormulaOrInt(formula) {
1118
- return !Tools.isBlank(formula) && (isFormulaString(formula) || !Number.isNaN(+formula) && Number.isInteger(+formula));
1093
+ _isFormulaOrInt(e) {
1094
+ return !V.isBlank(e) && (v(e) || !Number.isNaN(+e) && Number.isInteger(+e));
1119
1095
  }
1120
- validatorFormula(rule, _unitId, _subUnitId) {
1121
- const operator = rule.operator;
1122
- if (!operator)
1096
+ validatorFormula(e, t, r) {
1097
+ const i = e.operator;
1098
+ if (!i)
1123
1099
  return {
1124
1100
  success: !1
1125
1101
  };
1126
- const formula1Success = Tools.isDefine(rule.formula1) && this._isFormulaOrInt(rule.formula1), formula2Success = Tools.isDefine(rule.formula2) && this._isFormulaOrInt(rule.formula2), isTwoFormula = TWO_FORMULA_OPERATOR_COUNT.includes(operator), errorMsg = this.localeService.t("dataValidation.validFail.number");
1127
- return isTwoFormula ? {
1128
- success: formula1Success && formula2Success,
1129
- formula1: formula1Success ? void 0 : errorMsg,
1130
- formula2: formula2Success ? void 0 : errorMsg
1102
+ const o = V.isDefine(e.formula1) && this._isFormulaOrInt(e.formula1), n = V.isDefine(e.formula2) && this._isFormulaOrInt(e.formula2), l = Ae.includes(i), u = this.localeService.t("dataValidation.validFail.number");
1103
+ return l ? {
1104
+ success: o && n,
1105
+ formula1: o ? void 0 : u,
1106
+ formula2: n ? void 0 : u
1131
1107
  } : {
1132
- success: formula1Success,
1133
- formula1: errorMsg
1108
+ success: o,
1109
+ formula1: u
1134
1110
  };
1135
1111
  }
1136
- _parseNumber(formula) {
1137
- return formula == null ? Number.NaN : +formula;
1112
+ _parseNumber(e) {
1113
+ return e == null ? Number.NaN : +e;
1138
1114
  }
1139
- async parseFormula(rule, unitId, subUnitId, row, column) {
1140
- const formulaResult1 = await this._customFormulaService.getCellFormulaValue(unitId, subUnitId, rule.uid, row, column), formulaResult2 = await this._customFormulaService.getCellFormula2Value(unitId, subUnitId, rule.uid, row, column), { formula1, formula2 } = rule, isFormulaValid = isLegalFormulaResult(String(formulaResult1 == null ? void 0 : formulaResult1.v)) && isLegalFormulaResult(String(formulaResult2 == null ? void 0 : formulaResult2.v));
1115
+ async parseFormula(e, t, r, i, o) {
1116
+ const n = await this._customFormulaService.getCellFormulaValue(t, r, e.uid, i, o), l = await this._customFormulaService.getCellFormula2Value(t, r, e.uid, i, o), { formula1: u, formula2: d } = e, c = C(String(n == null ? void 0 : n.v)) && C(String(l == null ? void 0 : l.v));
1141
1117
  return {
1142
- formula1: this._parseNumber(isFormulaString(formula1) ? formulaResult1 == null ? void 0 : formulaResult1.v : formula1),
1143
- formula2: this._parseNumber(isFormulaString(formula2) ? formulaResult2 == null ? void 0 : formulaResult2.v : formula2),
1144
- isFormulaValid
1118
+ formula1: this._parseNumber(v(u) ? n == null ? void 0 : n.v : u),
1119
+ formula2: this._parseNumber(v(d) ? l == null ? void 0 : l.v : d),
1120
+ isFormulaValid: c
1145
1121
  };
1146
1122
  }
1147
- transform(cellInfo, _formula, _rule) {
1123
+ transform(e, t, r) {
1148
1124
  return {
1149
- ...cellInfo,
1150
- value: cellInfo.value.toString().length
1125
+ ...e,
1126
+ value: e.value.toString().length
1151
1127
  };
1152
1128
  }
1153
- async isValidType(cellInfo, _formula, _rule) {
1154
- const { value: cellValue } = cellInfo;
1155
- return typeof cellValue == "string" || typeof cellValue == "number";
1129
+ async isValidType(e, t, r) {
1130
+ const { value: i } = e;
1131
+ return typeof i == "string" || typeof i == "number";
1156
1132
  }
1157
- generateRuleErrorMessage(rule, pos) {
1158
- if (!rule.operator)
1133
+ generateRuleErrorMessage(e, t) {
1134
+ if (!e.operator)
1159
1135
  return this.titleStr;
1160
- const { transformedFormula1, transformedFormula2 } = getTransformedFormula(this._lexerTreeBuilder, rule, pos);
1161
- return `${this.localeService.t(TextLengthErrorTitleMap[rule.operator]).replace(FORMULA1, transformedFormula1 != null ? transformedFormula1 : "").replace(FORMULA2, transformedFormula2 != null ? transformedFormula2 : "")}`;
1136
+ const { transformedFormula1: r, transformedFormula2: i } = De(this._lexerTreeBuilder, e, t);
1137
+ return `${this.localeService.t(Dt[e.operator]).replace(le, r != null ? r : "").replace(ue, i != null ? i : "")}`;
1162
1138
  }
1163
- };
1164
- __name(_TextLengthValidator, "TextLengthValidator");
1165
- let TextLengthValidator = _TextLengthValidator;
1166
- function isBlankCell(cellData) {
1167
- var _a12, _b;
1168
- return cellData ? cellData.p ? !((_b = (_a12 = cellData.p.body) == null ? void 0 : _a12.dataStream) != null ? _b : "").slice(0, -2).trim() : Tools.isBlank(cellData.v) : !0;
1169
1139
  }
1170
- __name(isBlankCell, "isBlankCell");
1171
- function getDataValidationDiffMutations(unitId, subUnitId, diffs, accessor, source = "command", fillDefaultValue = !0) {
1172
- const lexerTreeBuilder = accessor.get(LexerTreeBuilder), validatorRegistryService = accessor.get(DataValidatorRegistryService), redoMutations = [], undoMutations = [], sheetDataValidationModel = accessor.get(SheetDataValidationModel), univerInstanceService = accessor.get(IUniverInstanceService), target = getSheetCommandTarget(univerInstanceService, { unitId, subUnitId });
1173
- if (!target)
1140
+ function ft(s) {
1141
+ var e, t;
1142
+ return s ? s.p ? !((t = (e = s.p.body) == null ? void 0 : e.dataStream) != null ? t : "").slice(0, -2).trim() : V.isBlank(s.v) : !0;
1143
+ }
1144
+ function be(s, a, e, t, r = "command", i = !0) {
1145
+ const o = t.get(Y), n = t.get(G), l = [], u = [], d = t.get(F), c = t.get(O), m = Ye(c, { unitId: s, subUnitId: a });
1146
+ if (!m)
1174
1147
  return {
1175
- redoMutations,
1176
- undoMutations
1148
+ redoMutations: l,
1149
+ undoMutations: u
1177
1150
  };
1178
- const { worksheet } = target, redoMatrix = new ObjectMatrix();
1179
- let setRangeValue = !1;
1180
- function setRangesDefaultValue(ranges, defaultValue) {
1181
- fillDefaultValue && ranges.forEach((range) => {
1182
- Range.foreach(range, (row, column) => {
1183
- const cellData = worksheet.getCellRaw(row, column), value = getStringCellValue(cellData);
1184
- (isBlankCell(cellData) || value === defaultValue) && !(cellData != null && cellData.p) && (setRangeValue = !0, redoMatrix.setValue(row, column, {
1185
- v: defaultValue,
1151
+ const { worksheet: _ } = m, g = new ve();
1152
+ let R = !1;
1153
+ function M(p, w) {
1154
+ i && p.forEach((H) => {
1155
+ b.foreach(H, (B, W) => {
1156
+ const U = _.getCellRaw(B, W), J = ct(U);
1157
+ (ft(U) || J === w) && !(U != null && U.p) && (R = !0, g.setValue(B, W, {
1158
+ v: w,
1186
1159
  p: null
1187
1160
  }));
1188
1161
  });
1189
1162
  });
1190
1163
  }
1191
- if (__name(setRangesDefaultValue, "setRangesDefaultValue"), diffs.forEach((diff) => {
1192
- switch (diff.type) {
1164
+ if (e.forEach((p) => {
1165
+ switch (p.type) {
1193
1166
  case "delete":
1194
- redoMutations.push({
1195
- id: RemoveDataValidationMutation.id,
1167
+ l.push({
1168
+ id: A.id,
1196
1169
  params: {
1197
- unitId,
1198
- subUnitId,
1199
- ruleId: diff.rule.uid,
1200
- source
1170
+ unitId: s,
1171
+ subUnitId: a,
1172
+ ruleId: p.rule.uid,
1173
+ source: r
1201
1174
  }
1202
- }), undoMutations.unshift({
1203
- id: AddDataValidationMutation.id,
1175
+ }), u.unshift({
1176
+ id: L.id,
1204
1177
  params: {
1205
- unitId,
1206
- subUnitId,
1207
- rule: diff.rule,
1208
- index: diff.index,
1209
- source
1178
+ unitId: s,
1179
+ subUnitId: a,
1180
+ rule: p.rule,
1181
+ index: p.index,
1182
+ source: r
1210
1183
  }
1211
1184
  });
1212
1185
  break;
1213
1186
  case "update": {
1214
- if (shouldOffsetFormulaByRange(diff.rule.type, validatorRegistryService)) {
1215
- const originRow = diff.oldRanges[0].startRow, originColumn = diff.oldRanges[0].startColumn, newRow = diff.newRanges[0].startRow, newColumn = diff.newRanges[0].startColumn, rowDiff = newRow - originRow, columnDiff = newColumn - originColumn, newFormula = isFormulaString(diff.rule.formula1) ? lexerTreeBuilder.moveFormulaRefOffset(diff.rule.formula1, columnDiff, rowDiff) : diff.rule.formula1, newFormula2 = isFormulaString(diff.rule.formula2) ? lexerTreeBuilder.moveFormulaRefOffset(diff.rule.formula2, columnDiff, rowDiff) : diff.rule.formula2;
1216
- newFormula !== diff.rule.formula1 || newFormula2 !== diff.rule.formula2 || !isRangesEqual(diff.newRanges, diff.oldRanges) ? (redoMutations.push({
1217
- id: UpdateDataValidationMutation.id,
1187
+ if (de(p.rule.type, n)) {
1188
+ const H = p.oldRanges[0].startRow, B = p.oldRanges[0].startColumn, W = p.newRanges[0].startRow, U = p.newRanges[0].startColumn, J = W - H, ce = U - B, he = v(p.rule.formula1) ? o.moveFormulaRefOffset(p.rule.formula1, ce, J) : p.rule.formula1, me = v(p.rule.formula2) ? o.moveFormulaRefOffset(p.rule.formula2, ce, J) : p.rule.formula2;
1189
+ he !== p.rule.formula1 || me !== p.rule.formula2 || !rt(p.newRanges, p.oldRanges) ? (l.push({
1190
+ id: E.id,
1218
1191
  params: {
1219
- unitId,
1220
- subUnitId,
1221
- ruleId: diff.ruleId,
1192
+ unitId: s,
1193
+ subUnitId: a,
1194
+ ruleId: p.ruleId,
1222
1195
  payload: {
1223
- type: UpdateRuleType.ALL,
1196
+ type: y.ALL,
1224
1197
  payload: {
1225
- formula1: newFormula,
1226
- formula2: newFormula2,
1227
- ranges: diff.newRanges
1198
+ formula1: he,
1199
+ formula2: me,
1200
+ ranges: p.newRanges
1228
1201
  }
1229
1202
  }
1230
1203
  }
1231
- }), undoMutations.unshift({
1232
- id: UpdateDataValidationMutation.id,
1204
+ }), u.unshift({
1205
+ id: E.id,
1233
1206
  params: {
1234
- unitId,
1235
- subUnitId,
1236
- ruleId: diff.ruleId,
1207
+ unitId: s,
1208
+ subUnitId: a,
1209
+ ruleId: p.ruleId,
1237
1210
  payload: {
1238
- type: UpdateRuleType.ALL,
1211
+ type: y.ALL,
1239
1212
  payload: {
1240
- formula1: diff.rule.formula1,
1241
- formula2: diff.rule.formula2,
1242
- ranges: diff.oldRanges
1213
+ formula1: p.rule.formula1,
1214
+ formula2: p.rule.formula2,
1215
+ ranges: p.oldRanges
1243
1216
  }
1244
1217
  }
1245
1218
  }
1246
- })) : (redoMutations.push({
1247
- id: UpdateDataValidationMutation.id,
1219
+ })) : (l.push({
1220
+ id: E.id,
1248
1221
  params: {
1249
- unitId,
1250
- subUnitId,
1251
- ruleId: diff.ruleId,
1222
+ unitId: s,
1223
+ subUnitId: a,
1224
+ ruleId: p.ruleId,
1252
1225
  payload: {
1253
- type: UpdateRuleType.RANGE,
1254
- payload: diff.newRanges
1226
+ type: y.RANGE,
1227
+ payload: p.newRanges
1255
1228
  },
1256
- source
1229
+ source: r
1257
1230
  }
1258
- }), undoMutations.unshift({
1259
- id: UpdateDataValidationMutation.id,
1231
+ }), u.unshift({
1232
+ id: E.id,
1260
1233
  params: {
1261
- unitId,
1262
- subUnitId,
1263
- ruleId: diff.ruleId,
1234
+ unitId: s,
1235
+ subUnitId: a,
1236
+ ruleId: p.ruleId,
1264
1237
  payload: {
1265
- type: UpdateRuleType.RANGE,
1266
- payload: diff.oldRanges
1238
+ type: y.RANGE,
1239
+ payload: p.oldRanges
1267
1240
  },
1268
- source
1241
+ source: r
1269
1242
  }
1270
1243
  }));
1271
1244
  } else
1272
- redoMutations.push({
1273
- id: UpdateDataValidationMutation.id,
1245
+ l.push({
1246
+ id: E.id,
1274
1247
  params: {
1275
- unitId,
1276
- subUnitId,
1277
- ruleId: diff.ruleId,
1248
+ unitId: s,
1249
+ subUnitId: a,
1250
+ ruleId: p.ruleId,
1278
1251
  payload: {
1279
- type: UpdateRuleType.RANGE,
1280
- payload: diff.newRanges
1252
+ type: y.RANGE,
1253
+ payload: p.newRanges
1281
1254
  },
1282
- source
1255
+ source: r
1283
1256
  }
1284
- }), undoMutations.unshift({
1285
- id: UpdateDataValidationMutation.id,
1257
+ }), u.unshift({
1258
+ id: E.id,
1286
1259
  params: {
1287
- unitId,
1288
- subUnitId,
1289
- ruleId: diff.ruleId,
1260
+ unitId: s,
1261
+ subUnitId: a,
1262
+ ruleId: p.ruleId,
1290
1263
  payload: {
1291
- type: UpdateRuleType.RANGE,
1292
- payload: diff.oldRanges
1264
+ type: y.RANGE,
1265
+ payload: p.oldRanges
1293
1266
  },
1294
- source
1267
+ source: r
1295
1268
  }
1296
1269
  });
1297
- const rule = sheetDataValidationModel.getRuleById(unitId, subUnitId, diff.ruleId);
1298
- if (rule && rule.type === DataValidationType.CHECKBOX) {
1299
- const formula = sheetDataValidationModel.getValidator(DataValidationType.CHECKBOX).parseFormulaSync(rule, unitId, subUnitId);
1300
- setRangesDefaultValue(diff.newRanges, formula.formula2);
1270
+ const w = d.getRuleById(s, a, p.ruleId);
1271
+ if (w && w.type === T.CHECKBOX) {
1272
+ const B = d.getValidator(T.CHECKBOX).parseFormulaSync(w, s, a);
1273
+ M(p.newRanges, B.formula2);
1301
1274
  }
1302
1275
  break;
1303
1276
  }
1304
1277
  case "add": {
1305
- if (redoMutations.push({
1306
- id: AddDataValidationMutation.id,
1278
+ if (l.push({
1279
+ id: L.id,
1307
1280
  params: {
1308
- unitId,
1309
- subUnitId,
1310
- rule: diff.rule,
1311
- source
1281
+ unitId: s,
1282
+ subUnitId: a,
1283
+ rule: p.rule,
1284
+ source: r
1312
1285
  }
1313
- }), undoMutations.unshift({
1314
- id: RemoveDataValidationMutation.id,
1286
+ }), u.unshift({
1287
+ id: A.id,
1315
1288
  params: {
1316
- unitId,
1317
- subUnitId,
1318
- ruleId: diff.rule.uid,
1319
- source
1289
+ unitId: s,
1290
+ subUnitId: a,
1291
+ ruleId: p.rule.uid,
1292
+ source: r
1320
1293
  }
1321
- }), diff.rule.type === DataValidationType.CHECKBOX) {
1322
- const formula = sheetDataValidationModel.getValidator(DataValidationType.CHECKBOX).parseFormulaSync(diff.rule, unitId, subUnitId);
1323
- setRangesDefaultValue(diff.rule.ranges, formula.originFormula2);
1294
+ }), p.rule.type === T.CHECKBOX) {
1295
+ const H = d.getValidator(T.CHECKBOX).parseFormulaSync(p.rule, s, a);
1296
+ M(p.rule.ranges, H.originFormula2);
1324
1297
  }
1325
1298
  break;
1326
1299
  }
1327
1300
  }
1328
- }), setRangeValue) {
1329
- const redoSetRangeValues = {
1330
- id: SetRangeValuesMutation.id,
1301
+ }), R) {
1302
+ const p = {
1303
+ id: oe.id,
1331
1304
  params: {
1332
- unitId,
1333
- subUnitId,
1334
- cellValue: redoMatrix.getData()
1305
+ unitId: s,
1306
+ subUnitId: a,
1307
+ cellValue: g.getData()
1335
1308
  }
1336
- }, undoSetRangeValues = {
1337
- id: SetRangeValuesMutation.id,
1338
- params: SetRangeValuesUndoMutationFactory(accessor, redoSetRangeValues.params)
1309
+ }, w = {
1310
+ id: oe.id,
1311
+ params: st(t, p.params)
1339
1312
  };
1340
- redoMutations.push(redoSetRangeValues), undoMutations.push(undoSetRangeValues);
1313
+ l.push(p), u.push(w);
1341
1314
  }
1342
1315
  return {
1343
- redoMutations,
1344
- undoMutations
1316
+ redoMutations: l,
1317
+ undoMutations: u
1345
1318
  };
1346
1319
  }
1347
- __name(getDataValidationDiffMutations, "getDataValidationDiffMutations");
1348
- const UpdateSheetDataValidationRangeCommand = {
1349
- type: CommandType.COMMAND,
1320
+ const pa = {
1321
+ type: z.COMMAND,
1350
1322
  id: "sheet.command.updateDataValidationRuleRange",
1351
- handler(accessor, params) {
1352
- if (!params)
1323
+ handler(s, a) {
1324
+ if (!a)
1353
1325
  return !1;
1354
- const { unitId, subUnitId, ranges, ruleId } = params, sheetDataValidationModel = accessor.get(SheetDataValidationModel), commandService = accessor.get(ICommandService), undoRedoService = accessor.get(IUndoRedoService);
1355
- if (!sheetDataValidationModel.getRuleById(unitId, subUnitId, ruleId))
1326
+ const { unitId: e, subUnitId: t, ranges: r, ruleId: i } = a, o = s.get(F), n = s.get(x), l = s.get(Z);
1327
+ if (!o.getRuleById(e, t, i))
1356
1328
  return !1;
1357
- const matrix = sheetDataValidationModel.getRuleObjectMatrix(unitId, subUnitId).clone();
1358
- matrix.updateRange(ruleId, ranges);
1359
- const diffs = matrix.diff(sheetDataValidationModel.getRules(unitId, subUnitId)), { redoMutations, undoMutations } = getDataValidationDiffMutations(unitId, subUnitId, diffs, accessor);
1360
- return undoRedoService.pushUndoRedo({
1361
- undoMutations,
1362
- redoMutations,
1363
- unitID: unitId
1364
- }), sequenceExecute(redoMutations, commandService), !0;
1365
- }
1366
- }, AddSheetDataValidationCommand = {
1367
- type: CommandType.COMMAND,
1329
+ const d = o.getRuleObjectMatrix(e, t).clone();
1330
+ d.updateRange(i, r);
1331
+ const c = d.diff(o.getRules(e, t)), { redoMutations: m, undoMutations: _ } = be(e, t, c, s);
1332
+ return l.pushUndoRedo({
1333
+ undoMutations: _,
1334
+ redoMutations: m,
1335
+ unitID: e
1336
+ }), Ie(m, n), !0;
1337
+ }
1338
+ }, Ra = {
1339
+ type: z.COMMAND,
1368
1340
  id: "sheet.command.addDataValidation",
1369
- handler(accessor, params) {
1370
- if (!params)
1341
+ handler(s, a) {
1342
+ if (!a)
1371
1343
  return !1;
1372
- const { unitId, subUnitId, rule } = params, sheetDataValidationModel = accessor.get(SheetDataValidationModel), commandService = accessor.get(ICommandService), undoRedoService = accessor.get(IUndoRedoService), matrix = sheetDataValidationModel.getRuleObjectMatrix(unitId, subUnitId).clone();
1373
- matrix.addRule(rule);
1374
- const diffs = matrix.diff(sheetDataValidationModel.getRules(unitId, subUnitId)), validator = sheetDataValidationModel.getValidator(rule.type), mutationParams = {
1375
- unitId,
1376
- subUnitId,
1344
+ const { unitId: e, subUnitId: t, rule: r } = a, i = s.get(F), o = s.get(x), n = s.get(Z), l = i.getRuleObjectMatrix(e, t).clone();
1345
+ l.addRule(r);
1346
+ const u = l.diff(i.getRules(e, t)), d = i.getValidator(r.type), c = {
1347
+ unitId: e,
1348
+ subUnitId: t,
1377
1349
  rule: {
1378
- ...rule,
1379
- ...validator == null ? void 0 : validator.normalizeFormula(rule, unitId, subUnitId)
1350
+ ...r,
1351
+ ...d == null ? void 0 : d.normalizeFormula(r, e, t)
1380
1352
  }
1381
- }, { redoMutations, undoMutations } = getDataValidationDiffMutations(unitId, subUnitId, diffs, accessor);
1382
- return redoMutations.push({
1383
- id: AddDataValidationMutation.id,
1384
- params: mutationParams
1385
- }), undoMutations.unshift({
1386
- id: RemoveDataValidationMutation.id,
1353
+ }, { redoMutations: m, undoMutations: _ } = be(e, t, u, s);
1354
+ return m.push({
1355
+ id: L.id,
1356
+ params: c
1357
+ }), _.unshift({
1358
+ id: A.id,
1387
1359
  params: {
1388
- unitId,
1389
- subUnitId,
1390
- ruleId: rule.uid
1360
+ unitId: e,
1361
+ subUnitId: t,
1362
+ ruleId: r.uid
1391
1363
  }
1392
- }), undoRedoService.pushUndoRedo({
1393
- unitID: unitId,
1394
- redoMutations,
1395
- undoMutations
1396
- }), sequenceExecute(redoMutations, commandService), !0;
1397
- }
1398
- }, UpdateSheetDataValidationSettingCommand = {
1399
- type: CommandType.COMMAND,
1364
+ }), n.pushUndoRedo({
1365
+ unitID: e,
1366
+ redoMutations: m,
1367
+ undoMutations: _
1368
+ }), Ie(m, o), !0;
1369
+ }
1370
+ }, Sa = {
1371
+ type: z.COMMAND,
1400
1372
  id: "sheets.command.update-data-validation-setting",
1401
1373
  // eslint-disable-next-line max-lines-per-function
1402
- handler(accessor, params) {
1403
- if (!params)
1374
+ handler(s, a) {
1375
+ if (!a)
1404
1376
  return !1;
1405
- const commandService = accessor.get(ICommandService), redoUndoService = accessor.get(IUndoRedoService), sheetDataValidationModel = accessor.get(SheetDataValidationModel), dataValidatorRegistryService = accessor.get(DataValidatorRegistryService), { unitId, subUnitId, ruleId, setting } = params, validator = dataValidatorRegistryService.getValidatorItem(setting.type);
1406
- if (!validator)
1377
+ const e = s.get(x), t = s.get(Z), r = s.get(F), i = s.get(G), { unitId: o, subUnitId: n, ruleId: l, setting: u } = a, d = i.getValidatorItem(u.type);
1378
+ if (!d)
1407
1379
  return !1;
1408
- const rule = sheetDataValidationModel.getRuleById(unitId, subUnitId, ruleId);
1409
- if (!rule)
1380
+ const c = r.getRuleById(o, n, l);
1381
+ if (!c)
1410
1382
  return !1;
1411
- const newRule = { ...rule, ...setting };
1412
- if (!validator.validatorFormula(newRule, unitId, subUnitId).success)
1383
+ const m = { ...c, ...u };
1384
+ if (!d.validatorFormula(m, o, n).success)
1413
1385
  return !1;
1414
- const mutationParams = {
1415
- unitId,
1416
- subUnitId,
1417
- ruleId,
1386
+ const _ = {
1387
+ unitId: o,
1388
+ subUnitId: n,
1389
+ ruleId: l,
1418
1390
  payload: {
1419
- type: UpdateRuleType.SETTING,
1391
+ type: y.SETTING,
1420
1392
  payload: {
1421
- ...setting,
1422
- ...validator.normalizeFormula(newRule, unitId, subUnitId)
1393
+ ...u,
1394
+ ...d.normalizeFormula(m, o, n)
1423
1395
  }
1424
1396
  }
1425
- }, redoMutations = [{
1426
- id: UpdateDataValidationMutation.id,
1427
- params: mutationParams
1428
- }], undoMutationParams = {
1429
- unitId,
1430
- subUnitId,
1431
- ruleId,
1397
+ }, g = [{
1398
+ id: E.id,
1399
+ params: _
1400
+ }], R = {
1401
+ unitId: o,
1402
+ subUnitId: n,
1403
+ ruleId: l,
1432
1404
  payload: {
1433
- type: UpdateRuleType.SETTING,
1434
- payload: getRuleSetting(rule)
1405
+ type: y.SETTING,
1406
+ payload: bt(c)
1435
1407
  }
1436
- }, undoMutations = [{
1437
- id: UpdateDataValidationMutation.id,
1438
- params: undoMutationParams
1408
+ }, M = [{
1409
+ id: E.id,
1410
+ params: R
1439
1411
  }];
1440
- if (setting.type === DataValidationType.CHECKBOX) {
1441
- const ranges = rule.ranges, univerInstanceService = accessor.get(IUniverInstanceService), target = getSheetCommandTarget(univerInstanceService, { unitId, subUnitId });
1442
- if (target) {
1443
- const redoMatrix = new ObjectMatrix(), { worksheet } = target, { formula2: oldFormula2 = CHECKBOX_FORMULA_2, formula1: oldFormula1 = CHECKBOX_FORMULA_1 } = rule, { formula2 = CHECKBOX_FORMULA_2, formula1 = CHECKBOX_FORMULA_1 } = setting;
1444
- let setted = !1;
1445
- if (ranges.forEach((range) => {
1446
- Range.foreach(range, (row, column) => {
1447
- const cellData = worksheet.getCellRaw(row, column), value = getStringCellValue(cellData);
1448
- (isBlankCell(cellData) || value === String(oldFormula2)) && !(cellData != null && cellData.p) ? (redoMatrix.setValue(row, column, {
1449
- v: formula2,
1412
+ if (u.type === T.CHECKBOX) {
1413
+ const w = c.ranges, H = s.get(O), B = Ye(H, { unitId: o, subUnitId: n });
1414
+ if (B) {
1415
+ const W = new ve(), { worksheet: U } = B, { formula2: J = Me, formula1: ce = Ve } = c, { formula2: he = Me, formula1: me = Ve } = u;
1416
+ let Le = !1;
1417
+ if (w.forEach((fe) => {
1418
+ b.foreach(fe, (ae, xe) => {
1419
+ const j = U.getCellRaw(ae, xe), Ke = ct(j);
1420
+ (ft(j) || Ke === String(J)) && !(j != null && j.p) ? (W.setValue(ae, xe, {
1421
+ v: he,
1450
1422
  p: null
1451
- }), setted = !0) : value === String(oldFormula1) && !(cellData != null && cellData.p) && (redoMatrix.setValue(row, column, {
1452
- v: formula1,
1423
+ }), Le = !0) : Ke === String(ce) && !(j != null && j.p) && (W.setValue(ae, xe, {
1424
+ v: me,
1453
1425
  p: null
1454
- }), setted = !0);
1426
+ }), Le = !0);
1455
1427
  });
1456
- }), setted) {
1457
- const redoSetRangeValues = {
1458
- id: SetRangeValuesMutation.id,
1428
+ }), Le) {
1429
+ const fe = {
1430
+ id: oe.id,
1459
1431
  params: {
1460
- unitId,
1461
- subUnitId,
1462
- cellValue: redoMatrix.getData()
1432
+ unitId: o,
1433
+ subUnitId: n,
1434
+ cellValue: W.getData()
1463
1435
  }
1464
- }, undoSetRangeValues = {
1465
- id: SetRangeValuesMutation.id,
1466
- params: SetRangeValuesUndoMutationFactory(accessor, redoSetRangeValues.params)
1436
+ }, ae = {
1437
+ id: oe.id,
1438
+ params: st(s, fe.params)
1467
1439
  };
1468
- redoMutations.push(redoSetRangeValues), undoMutations.push(undoSetRangeValues);
1440
+ g.push(fe), M.push(ae);
1469
1441
  }
1470
1442
  }
1471
1443
  }
1472
- return sequenceExecute(redoMutations, commandService).result ? (redoUndoService.pushUndoRedo({
1473
- unitID: unitId,
1474
- redoMutations,
1475
- undoMutations
1444
+ return Ie(g, e).result ? (t.pushUndoRedo({
1445
+ unitID: o,
1446
+ redoMutations: g,
1447
+ undoMutations: M
1476
1448
  }), !0) : !1;
1477
1449
  }
1478
- }, UpdateSheetDataValidationOptionsCommand = {
1479
- type: CommandType.COMMAND,
1450
+ }, va = {
1451
+ type: z.COMMAND,
1480
1452
  id: "sheets.command.update-data-validation-options",
1481
- handler(accessor, params) {
1482
- if (!params)
1453
+ handler(s, a) {
1454
+ if (!a)
1483
1455
  return !1;
1484
- const commandService = accessor.get(ICommandService), redoUndoService = accessor.get(IUndoRedoService), sheetDataValidationModel = accessor.get(SheetDataValidationModel), { unitId, subUnitId, ruleId, options } = params, rule = sheetDataValidationModel.getRuleById(unitId, subUnitId, ruleId);
1485
- if (!rule)
1456
+ const e = s.get(x), t = s.get(Z), r = s.get(F), { unitId: i, subUnitId: o, ruleId: n, options: l } = a, u = r.getRuleById(i, o, n);
1457
+ if (!u)
1486
1458
  return !1;
1487
- const mutationParams = {
1488
- unitId,
1489
- subUnitId,
1490
- ruleId,
1459
+ const d = {
1460
+ unitId: i,
1461
+ subUnitId: o,
1462
+ ruleId: n,
1491
1463
  payload: {
1492
- type: UpdateRuleType.OPTIONS,
1493
- payload: options
1464
+ type: y.OPTIONS,
1465
+ payload: l
1494
1466
  }
1495
- }, redoMutations = [{
1496
- id: UpdateDataValidationMutation.id,
1497
- params: mutationParams
1498
- }], undoMutationParams = {
1499
- unitId,
1500
- subUnitId,
1501
- ruleId,
1467
+ }, c = [{
1468
+ id: E.id,
1469
+ params: d
1470
+ }], m = {
1471
+ unitId: i,
1472
+ subUnitId: o,
1473
+ ruleId: n,
1502
1474
  payload: {
1503
- type: UpdateRuleType.OPTIONS,
1504
- payload: getRuleOptions(rule)
1475
+ type: y.OPTIONS,
1476
+ payload: Lt(u)
1505
1477
  }
1506
- }, undoMutations = [{
1507
- id: UpdateDataValidationMutation.id,
1508
- params: undoMutationParams
1478
+ }, _ = [{
1479
+ id: E.id,
1480
+ params: m
1509
1481
  }];
1510
- return redoUndoService.pushUndoRedo({
1511
- unitID: unitId,
1512
- redoMutations,
1513
- undoMutations
1514
- }), commandService.executeCommand(UpdateDataValidationMutation.id, mutationParams), !0;
1515
- }
1516
- }, ClearRangeDataValidationCommand = {
1517
- type: CommandType.COMMAND,
1482
+ return t.pushUndoRedo({
1483
+ unitID: i,
1484
+ redoMutations: c,
1485
+ undoMutations: _
1486
+ }), e.executeCommand(E.id, d), !0;
1487
+ }
1488
+ }, Va = {
1489
+ type: z.COMMAND,
1518
1490
  id: "sheets.command.clear-range-data-validation",
1519
- handler(accessor, params) {
1520
- if (!params)
1491
+ handler(s, a) {
1492
+ if (!a)
1521
1493
  return !1;
1522
- const { unitId, subUnitId, ranges } = params, commandService = accessor.get(ICommandService), univerInstanceService = accessor.get(IUniverInstanceService), target = getSheetCommandTarget(univerInstanceService, { unitId, subUnitId }), sheetDataValidationModel = accessor.get(SheetDataValidationModel);
1523
- if (!target) return !1;
1524
- const undoRedoService = accessor.get(IUndoRedoService), matrix = sheetDataValidationModel.getRuleObjectMatrix(unitId, subUnitId).clone();
1525
- matrix.removeRange(ranges);
1526
- const diffs = matrix.diff(sheetDataValidationModel.getRules(unitId, subUnitId)), { redoMutations, undoMutations } = getDataValidationDiffMutations(unitId, subUnitId, diffs, accessor);
1527
- return undoRedoService.pushUndoRedo({
1528
- unitID: unitId,
1529
- redoMutations,
1530
- undoMutations
1531
- }), sequenceExecute(redoMutations, commandService).result;
1532
- }
1533
- }, RemoveSheetAllDataValidationCommand = {
1534
- type: CommandType.COMMAND,
1494
+ const { unitId: e, subUnitId: t, ranges: r } = a, i = s.get(x), o = s.get(O), n = Ye(o, { unitId: e, subUnitId: t }), l = s.get(F);
1495
+ if (!n) return !1;
1496
+ const u = s.get(Z), d = l.getRuleObjectMatrix(e, t).clone();
1497
+ d.removeRange(r);
1498
+ const c = d.diff(l.getRules(e, t)), { redoMutations: m, undoMutations: _ } = be(e, t, c, s);
1499
+ return u.pushUndoRedo({
1500
+ unitID: e,
1501
+ redoMutations: m,
1502
+ undoMutations: _
1503
+ }), Ie(m, i).result;
1504
+ }
1505
+ }, Ma = {
1506
+ type: z.COMMAND,
1535
1507
  id: "sheet.command.remove-all-data-validation",
1536
- handler(accessor, params) {
1537
- if (!params)
1508
+ handler(s, a) {
1509
+ if (!a)
1538
1510
  return !1;
1539
- const { unitId, subUnitId } = params, commandService = accessor.get(ICommandService), sheetDataValidationModel = accessor.get(SheetDataValidationModel), undoRedoService = accessor.get(IUndoRedoService), currentRules = [...sheetDataValidationModel.getRules(unitId, subUnitId)], redoParams = {
1540
- unitId,
1541
- subUnitId,
1542
- ruleId: currentRules.map((rule) => rule.uid)
1543
- }, redoMutations = [{
1544
- id: RemoveDataValidationMutation.id,
1545
- params: redoParams
1546
- }], undoMutations = [{
1547
- id: AddDataValidationMutation.id,
1511
+ const { unitId: e, subUnitId: t } = a, r = s.get(x), i = s.get(F), o = s.get(Z), n = [...i.getRules(e, t)], l = {
1512
+ unitId: e,
1513
+ subUnitId: t,
1514
+ ruleId: n.map((c) => c.uid)
1515
+ }, u = [{
1516
+ id: A.id,
1517
+ params: l
1518
+ }], d = [{
1519
+ id: L.id,
1548
1520
  params: {
1549
- unitId,
1550
- subUnitId,
1551
- rule: currentRules
1521
+ unitId: e,
1522
+ subUnitId: t,
1523
+ rule: n
1552
1524
  }
1553
1525
  }];
1554
- return undoRedoService.pushUndoRedo({
1555
- redoMutations,
1556
- undoMutations,
1557
- unitID: unitId
1558
- }), commandService.executeCommand(RemoveDataValidationMutation.id, redoParams), !0;
1559
- }
1560
- }, removeDataValidationUndoFactory = /* @__PURE__ */ __name((accessor, redoParams) => {
1561
- const sheetDataValidationModel = accessor.get(SheetDataValidationModel), { unitId, subUnitId, ruleId, source } = redoParams;
1562
- if (Array.isArray(ruleId)) {
1563
- const rules = ruleId.map((id) => sheetDataValidationModel.getRuleById(unitId, subUnitId, id)).filter(Boolean);
1526
+ return o.pushUndoRedo({
1527
+ redoMutations: u,
1528
+ undoMutations: d,
1529
+ unitID: e
1530
+ }), r.executeCommand(A.id, l), !0;
1531
+ }
1532
+ }, ya = (s, a) => {
1533
+ const e = s.get(F), { unitId: t, subUnitId: r, ruleId: i, source: o } = a;
1534
+ if (Array.isArray(i)) {
1535
+ const l = i.map((u) => e.getRuleById(t, r, u)).filter(Boolean);
1564
1536
  return [{
1565
- id: AddDataValidationMutation.id,
1537
+ id: L.id,
1566
1538
  params: {
1567
- unitId,
1568
- subUnitId,
1569
- rule: rules,
1570
- source
1539
+ unitId: t,
1540
+ subUnitId: r,
1541
+ rule: l,
1542
+ source: o
1571
1543
  }
1572
1544
  }];
1573
1545
  }
1574
1546
  return [{
1575
- id: AddDataValidationMutation.id,
1547
+ id: L.id,
1576
1548
  params: {
1577
- unitId,
1578
- subUnitId,
1549
+ unitId: t,
1550
+ subUnitId: r,
1579
1551
  rule: {
1580
- ...sheetDataValidationModel.getRuleById(unitId, subUnitId, ruleId)
1552
+ ...e.getRuleById(t, r, i)
1581
1553
  },
1582
- index: sheetDataValidationModel.getRuleIndex(unitId, subUnitId, ruleId)
1554
+ index: e.getRuleIndex(t, r, i)
1583
1555
  }
1584
1556
  }];
1585
- }, "removeDataValidationUndoFactory"), RemoveSheetDataValidationCommand = {
1586
- type: CommandType.COMMAND,
1557
+ }, Ea = {
1558
+ type: z.COMMAND,
1587
1559
  id: "sheet.command.remove-data-validation-rule",
1588
- handler(accessor, params) {
1589
- if (!params)
1560
+ handler(s, a) {
1561
+ if (!a)
1590
1562
  return !1;
1591
- const { unitId, subUnitId, ruleId } = params, commandService = accessor.get(ICommandService), undoRedoService = accessor.get(IUndoRedoService), sheetDataValidationModel = accessor.get(SheetDataValidationModel), redoMutations = [{
1592
- id: RemoveDataValidationMutation.id,
1593
- params
1594
- }], undoMutations = [{
1595
- id: AddDataValidationMutation.id,
1563
+ const { unitId: e, subUnitId: t, ruleId: r } = a, i = s.get(x), o = s.get(Z), n = s.get(F), l = [{
1564
+ id: A.id,
1565
+ params: a
1566
+ }], u = [{
1567
+ id: L.id,
1596
1568
  params: {
1597
- unitId,
1598
- subUnitId,
1569
+ unitId: e,
1570
+ subUnitId: t,
1599
1571
  rule: {
1600
- ...sheetDataValidationModel.getRuleById(unitId, subUnitId, ruleId)
1572
+ ...n.getRuleById(e, t, r)
1601
1573
  },
1602
- index: sheetDataValidationModel.getRuleIndex(unitId, subUnitId, ruleId)
1574
+ index: n.getRuleIndex(e, t, r)
1603
1575
  }
1604
1576
  }];
1605
- return undoRedoService.pushUndoRedo({
1606
- undoMutations,
1607
- redoMutations,
1608
- unitID: params.unitId
1609
- }), commandService.executeCommand(RemoveDataValidationMutation.id, params), !0;
1610
- }
1611
- }, SHEETS_DATA_VALIDATION_PLUGIN_CONFIG_KEY = "sheets-data-validation.config", defaultPluginConfig = {};
1612
- var __defProp$6 = Object.defineProperty, __getOwnPropDesc$6 = Object.getOwnPropertyDescriptor, __decorateClass$6 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
1613
- for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$6(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
1614
- (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
1615
- return kind && result && __defProp$6(target, key, result), result;
1616
- }, "__decorateClass$6"), __decorateParam$6 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$6"), _a5;
1617
- let DataValidationFormulaRefRangeController = (_a5 = class extends Disposable {
1618
- constructor(_dataValidationModel, _formulaRefRangeService, _validatorRegistryService) {
1577
+ return o.pushUndoRedo({
1578
+ undoMutations: u,
1579
+ redoMutations: l,
1580
+ unitID: a.unitId
1581
+ }), i.executeCommand(A.id, a), !0;
1582
+ }
1583
+ }, Ta = "sheets-data-validation.config", tt = {};
1584
+ var Fa = Object.defineProperty, Na = Object.getOwnPropertyDescriptor, Ca = (s, a, e, t) => {
1585
+ for (var r = t > 1 ? void 0 : t ? Na(a, e) : a, i = s.length - 1, o; i >= 0; i--)
1586
+ (o = s[i]) && (r = (t ? o(a, e, r) : o(r)) || r);
1587
+ return t && r && Fa(a, e, r), r;
1588
+ }, $e = (s, a) => (e, t) => a(e, t, s);
1589
+ let Ee = class extends $ {
1590
+ constructor(a, e, t) {
1619
1591
  super();
1620
- __publicField(this, "_disposableMap", /* @__PURE__ */ new Map());
1621
- __publicField(this, "registerRule", /* @__PURE__ */ __name((unitId, subUnitId, rule) => {
1622
- shouldOffsetFormulaByRange(rule.type, this._validatorRegistryService) && this.register(unitId, subUnitId, rule);
1623
- }, "registerRule"));
1624
- this._dataValidationModel = _dataValidationModel, this._formulaRefRangeService = _formulaRefRangeService, this._validatorRegistryService = _validatorRegistryService, this._initRefRange();
1592
+ f(this, "_disposableMap", /* @__PURE__ */ new Map());
1593
+ f(this, "registerRule", (a, e, t) => {
1594
+ de(t.type, this._validatorRegistryService) && this.register(a, e, t);
1595
+ });
1596
+ this._dataValidationModel = a, this._formulaRefRangeService = e, this._validatorRegistryService = t, this._initRefRange();
1625
1597
  }
1626
- _getIdWithUnitId(unitID, subUnitId, ruleId) {
1627
- return `${unitID}_${subUnitId}_${ruleId}`;
1598
+ _getIdWithUnitId(a, e, t) {
1599
+ return `${a}_${e}_${t}`;
1628
1600
  }
1629
1601
  // eslint-disable-next-line max-lines-per-function
1630
- register(unitId, subUnitId, rule) {
1631
- const oldRanges = rule.ranges, oldFormula1 = rule.formula1, oldFormula2 = rule.formula2, disposable = this._formulaRefRangeService.registerRangeFormula(unitId, subUnitId, oldRanges, [oldFormula1 != null ? oldFormula1 : "", oldFormula2 != null ? oldFormula2 : ""], (res) => {
1632
- if (res.length === 0)
1602
+ register(a, e, t) {
1603
+ const r = t.ranges, i = t.formula1, o = t.formula2, n = this._formulaRefRangeService.registerRangeFormula(a, e, r, [i != null ? i : "", o != null ? o : ""], (u) => {
1604
+ if (u.length === 0)
1633
1605
  return {
1634
1606
  undos: [{
1635
- id: AddDataValidationMutation.id,
1607
+ id: L.id,
1636
1608
  params: {
1637
- unitId,
1638
- subUnitId,
1639
- rule,
1609
+ unitId: a,
1610
+ subUnitId: e,
1611
+ rule: t,
1640
1612
  source: "patched"
1641
1613
  }
1642
1614
  }],
1643
1615
  redos: [{
1644
- id: RemoveDataValidationMutation.id,
1616
+ id: A.id,
1645
1617
  params: {
1646
- unitId,
1647
- subUnitId,
1648
- ruleId: rule.uid,
1618
+ unitId: a,
1619
+ subUnitId: e,
1620
+ ruleId: t.uid,
1649
1621
  source: "patched"
1650
1622
  }
1651
1623
  }]
1652
1624
  };
1653
- const redos = [], undos = [], first = res[0];
1654
- redos.push({
1655
- id: UpdateDataValidationMutation.id,
1625
+ const d = [], c = [], m = u[0];
1626
+ d.push({
1627
+ id: E.id,
1656
1628
  params: {
1657
- unitId,
1658
- subUnitId,
1659
- ruleId: rule.uid,
1629
+ unitId: a,
1630
+ subUnitId: e,
1631
+ ruleId: t.uid,
1660
1632
  payload: {
1661
- type: UpdateRuleType.ALL,
1633
+ type: y.ALL,
1662
1634
  payload: {
1663
- ranges: first.ranges,
1664
- formula1: first.formulas[0],
1665
- formula2: first.formulas[1]
1635
+ ranges: m.ranges,
1636
+ formula1: m.formulas[0],
1637
+ formula2: m.formulas[1]
1666
1638
  }
1667
1639
  },
1668
1640
  source: "patched"
1669
1641
  }
1670
- }), undos.push({
1671
- id: UpdateDataValidationMutation.id,
1642
+ }), c.push({
1643
+ id: E.id,
1672
1644
  params: {
1673
- unitId,
1674
- subUnitId,
1675
- ruleId: rule.uid,
1645
+ unitId: a,
1646
+ subUnitId: e,
1647
+ ruleId: t.uid,
1676
1648
  payload: {
1677
- type: UpdateRuleType.ALL,
1649
+ type: y.ALL,
1678
1650
  payload: {
1679
- ranges: oldRanges,
1680
- formula1: oldFormula1,
1681
- formula2: oldFormula2
1651
+ ranges: r,
1652
+ formula1: i,
1653
+ formula2: o
1682
1654
  }
1683
1655
  },
1684
1656
  source: "patched"
1685
1657
  }
1686
1658
  });
1687
- for (let i = 1; i < res.length; i++) {
1688
- const item = res[i], id2 = generateRandomId();
1689
- redos.push({
1690
- id: AddDataValidationMutation.id,
1659
+ for (let _ = 1; _ < u.length; _++) {
1660
+ const g = u[_], R = yt();
1661
+ d.push({
1662
+ id: L.id,
1691
1663
  params: {
1692
- unitId,
1693
- subUnitId,
1664
+ unitId: a,
1665
+ subUnitId: e,
1694
1666
  rule: {
1695
- ...rule,
1696
- uid: id2,
1697
- formula1: item.formulas[0],
1698
- formula2: item.formulas[1],
1699
- ranges: item.ranges
1667
+ ...t,
1668
+ uid: R,
1669
+ formula1: g.formulas[0],
1670
+ formula2: g.formulas[1],
1671
+ ranges: g.ranges
1700
1672
  },
1701
1673
  source: "patched"
1702
1674
  }
1703
- }), undos.push({
1704
- id: RemoveDataValidationMutation.id,
1675
+ }), c.push({
1676
+ id: A.id,
1705
1677
  params: {
1706
- unitId,
1707
- subUnitId,
1708
- ruleId: id2,
1678
+ unitId: a,
1679
+ subUnitId: e,
1680
+ ruleId: R,
1709
1681
  source: "patched"
1710
1682
  }
1711
1683
  });
1712
1684
  }
1713
1685
  return {
1714
- undos,
1715
- redos
1686
+ undos: c,
1687
+ redos: d
1716
1688
  };
1717
- }), id = this._getIdWithUnitId(unitId, subUnitId, rule.uid);
1718
- this._disposableMap.set(id, disposable);
1689
+ }), l = this._getIdWithUnitId(a, e, t.uid);
1690
+ this._disposableMap.set(l, n);
1719
1691
  }
1720
1692
  _initRefRange() {
1721
- const allRules = this._dataValidationModel.getAll();
1722
- for (const [unitId, subUnitMap] of allRules)
1723
- for (const [subUnitId, rules] of subUnitMap)
1724
- for (const rule of rules)
1725
- this.registerRule(unitId, subUnitId, rule);
1693
+ const a = this._dataValidationModel.getAll();
1694
+ for (const [e, t] of a)
1695
+ for (const [r, i] of t)
1696
+ for (const o of i)
1697
+ this.registerRule(e, r, o);
1726
1698
  this.disposeWithMe(
1727
- this._dataValidationModel.ruleChange$.subscribe((option) => {
1728
- const { unitId, subUnitId, rule } = option;
1729
- switch (option.type) {
1699
+ this._dataValidationModel.ruleChange$.subscribe((e) => {
1700
+ const { unitId: t, subUnitId: r, rule: i } = e;
1701
+ switch (e.type) {
1730
1702
  case "add": {
1731
- const rule2 = option.rule;
1732
- this.registerRule(option.unitId, option.subUnitId, rule2);
1703
+ const o = e.rule;
1704
+ this.registerRule(e.unitId, e.subUnitId, o);
1733
1705
  break;
1734
1706
  }
1735
1707
  case "remove": {
1736
- const disposeSet = this._disposableMap.get(this._getIdWithUnitId(unitId, subUnitId, rule.uid));
1737
- disposeSet && disposeSet.dispose();
1708
+ const o = this._disposableMap.get(this._getIdWithUnitId(t, r, i.uid));
1709
+ o && o.dispose();
1738
1710
  break;
1739
1711
  }
1740
1712
  case "update": {
1741
- const rule2 = option.rule, disposeSet = this._disposableMap.get(this._getIdWithUnitId(unitId, subUnitId, rule2.uid));
1742
- disposeSet && disposeSet.dispose(), this.registerRule(option.unitId, option.subUnitId, rule2);
1713
+ const o = e.rule, n = this._disposableMap.get(this._getIdWithUnitId(t, r, o.uid));
1714
+ n && n.dispose(), this.registerRule(e.unitId, e.subUnitId, o);
1743
1715
  break;
1744
1716
  }
1745
1717
  }
1746
1718
  })
1747
- ), this.disposeWithMe(toDisposable(() => {
1748
- this._disposableMap.forEach((item) => {
1749
- item.dispose();
1719
+ ), this.disposeWithMe(qe(() => {
1720
+ this._disposableMap.forEach((e) => {
1721
+ e.dispose();
1750
1722
  }), this._disposableMap.clear();
1751
1723
  }));
1752
1724
  }
1753
- }, __name(_a5, "DataValidationFormulaRefRangeController"), _a5);
1754
- DataValidationFormulaRefRangeController = __decorateClass$6([
1755
- __decorateParam$6(0, Inject(SheetDataValidationModel)),
1756
- __decorateParam$6(1, Inject(FormulaRefRangeService)),
1757
- __decorateParam$6(2, Inject(DataValidatorRegistryService))
1758
- ], DataValidationFormulaRefRangeController);
1759
- var R = /* @__PURE__ */ ((E) => (E[E.View = 0] = "View", E[E.Edit = 1] = "Edit", E[E.ManageCollaborator = 2] = "ManageCollaborator", E[E.Print = 3] = "Print", E[E.Duplicate = 4] = "Duplicate", E[E.Comment = 5] = "Comment", E[E.Copy = 6] = "Copy", E[E.Share = 7] = "Share", E[E.Export = 8] = "Export", E[E.MoveWorksheet = 9] = "MoveWorksheet", E[E.DeleteWorksheet = 10] = "DeleteWorksheet", E[E.HideWorksheet = 11] = "HideWorksheet", E[E.RenameWorksheet = 12] = "RenameWorksheet", E[E.CreateWorksheet = 13] = "CreateWorksheet", E[E.SetWorksheetStyle = 14] = "SetWorksheetStyle", E[E.EditWorksheetCell = 15] = "EditWorksheetCell", E[E.InsertHyperlink = 16] = "InsertHyperlink", E[E.Sort = 17] = "Sort", E[E.Filter = 18] = "Filter", E[E.PivotTable = 19] = "PivotTable", E[E.FloatImg = 20] = "FloatImg", E[E.History = 21] = "History", E[E.RwHgtClWdt = 22] = "RwHgtClWdt", E[E.ViemRwHgtClWdt = 23] = "ViemRwHgtClWdt", E[E.ViewFilter = 24] = "ViewFilter", E[E.MoveSheet = 25] = "MoveSheet", E[E.DeleteSheet = 26] = "DeleteSheet", E[E.HideSheet = 27] = "HideSheet", E[E.CopySheet = 28] = "CopySheet", E[E.RenameSheet = 29] = "RenameSheet", E[E.CreateSheet = 30] = "CreateSheet", E[E.SelectProtectedCells = 31] = "SelectProtectedCells", E[E.SelectUnProtectedCells = 32] = "SelectUnProtectedCells", E[E.SetCellStyle = 33] = "SetCellStyle", E[E.SetCellValue = 34] = "SetCellValue", E[E.SetRowStyle = 35] = "SetRowStyle", E[E.SetColumnStyle = 36] = "SetColumnStyle", E[E.InsertRow = 37] = "InsertRow", E[E.InsertColumn = 38] = "InsertColumn", E[E.DeleteRow = 39] = "DeleteRow", E[E.DeleteColumn = 40] = "DeleteColumn", E[E.EditExtraObject = 41] = "EditExtraObject", E[E.Delete = 42] = "Delete", E[E.RecoverHistory = 43] = "RecoverHistory", E[E.ViewHistory = 44] = "ViewHistory", E[E.CreatePermissionObject = 45] = "CreatePermissionObject", E[E.UNRECOGNIZED = -1] = "UNRECOGNIZED", E))(R || {}), __defProp$5 = Object.defineProperty, __getOwnPropDesc$5 = Object.getOwnPropertyDescriptor, __decorateClass$5 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
1760
- for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$5(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
1761
- (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
1762
- return kind && result && __defProp$5(target, key, result), result;
1763
- }, "__decorateClass$5"), __decorateParam$5 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$5"), _a6;
1764
- let DataValidationFormulaController = (_a6 = class extends Disposable {
1765
- constructor(_univerInstanceService, _permissionService, _lexerTreeBuilder) {
1766
- super(), this._univerInstanceService = _univerInstanceService, this._permissionService = _permissionService, this._lexerTreeBuilder = _lexerTreeBuilder;
1767
- }
1768
- getFormulaRefCheck(formulaString) {
1769
- var _a12, _b;
1770
- const sequenceNodes = this._lexerTreeBuilder.sequenceNodesBuilder(formulaString);
1771
- if (!sequenceNodes)
1725
+ };
1726
+ Ee = Ca([
1727
+ $e(0, S(F)),
1728
+ $e(1, S(ut)),
1729
+ $e(2, S(G))
1730
+ ], Ee);
1731
+ var gt = /* @__PURE__ */ ((s) => (s[s.View = 0] = "View", s[s.Edit = 1] = "Edit", s[s.ManageCollaborator = 2] = "ManageCollaborator", s[s.Print = 3] = "Print", s[s.Duplicate = 4] = "Duplicate", s[s.Comment = 5] = "Comment", s[s.Copy = 6] = "Copy", s[s.Share = 7] = "Share", s[s.Export = 8] = "Export", s[s.MoveWorksheet = 9] = "MoveWorksheet", s[s.DeleteWorksheet = 10] = "DeleteWorksheet", s[s.HideWorksheet = 11] = "HideWorksheet", s[s.RenameWorksheet = 12] = "RenameWorksheet", s[s.CreateWorksheet = 13] = "CreateWorksheet", s[s.SetWorksheetStyle = 14] = "SetWorksheetStyle", s[s.EditWorksheetCell = 15] = "EditWorksheetCell", s[s.InsertHyperlink = 16] = "InsertHyperlink", s[s.Sort = 17] = "Sort", s[s.Filter = 18] = "Filter", s[s.PivotTable = 19] = "PivotTable", s[s.FloatImg = 20] = "FloatImg", s[s.History = 21] = "History", s[s.RwHgtClWdt = 22] = "RwHgtClWdt", s[s.ViemRwHgtClWdt = 23] = "ViemRwHgtClWdt", s[s.ViewFilter = 24] = "ViewFilter", s[s.MoveSheet = 25] = "MoveSheet", s[s.DeleteSheet = 26] = "DeleteSheet", s[s.HideSheet = 27] = "HideSheet", s[s.CopySheet = 28] = "CopySheet", s[s.RenameSheet = 29] = "RenameSheet", s[s.CreateSheet = 30] = "CreateSheet", s[s.SelectProtectedCells = 31] = "SelectProtectedCells", s[s.SelectUnProtectedCells = 32] = "SelectUnProtectedCells", s[s.SetCellStyle = 33] = "SetCellStyle", s[s.SetCellValue = 34] = "SetCellValue", s[s.SetRowStyle = 35] = "SetRowStyle", s[s.SetColumnStyle = 36] = "SetColumnStyle", s[s.InsertRow = 37] = "InsertRow", s[s.InsertColumn = 38] = "InsertColumn", s[s.DeleteRow = 39] = "DeleteRow", s[s.DeleteColumn = 40] = "DeleteColumn", s[s.EditExtraObject = 41] = "EditExtraObject", s[s.Delete = 42] = "Delete", s[s.RecoverHistory = 43] = "RecoverHistory", s[s.ViewHistory = 44] = "ViewHistory", s[s.CreatePermissionObject = 45] = "CreatePermissionObject", s[s.UNRECOGNIZED = -1] = "UNRECOGNIZED", s))(gt || {}), Oa = Object.defineProperty, wa = Object.getOwnPropertyDescriptor, Ia = (s, a, e, t) => {
1732
+ for (var r = t > 1 ? void 0 : t ? wa(a, e) : a, i = s.length - 1, o; i >= 0; i--)
1733
+ (o = s[i]) && (r = (t ? o(a, e, r) : o(r)) || r);
1734
+ return t && r && Oa(a, e, r), r;
1735
+ }, He = (s, a) => (e, t) => a(e, t, s);
1736
+ let Te = class extends $ {
1737
+ constructor(s, a, e) {
1738
+ super(), this._univerInstanceService = s, this._permissionService = a, this._lexerTreeBuilder = e;
1739
+ }
1740
+ getFormulaRefCheck(s) {
1741
+ var e, t;
1742
+ const a = this._lexerTreeBuilder.sequenceNodesBuilder(s);
1743
+ if (!a)
1772
1744
  return !0;
1773
- for (let i = 0; i < sequenceNodes.length; i++) {
1774
- const node = sequenceNodes[i];
1775
- if (typeof node == "string")
1745
+ for (let r = 0; r < a.length; r++) {
1746
+ const i = a[r];
1747
+ if (typeof i == "string")
1776
1748
  continue;
1777
- const { token } = node, sequenceGrid = deserializeRangeWithSheetWithCache(token), workbook = this._univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET);
1778
- let targetSheet = workbook.getActiveSheet();
1779
- const unitId = workbook.getUnitId();
1780
- if (sequenceGrid.sheetName) {
1781
- if (targetSheet = workbook.getSheetBySheetName(sequenceGrid.sheetName), !targetSheet)
1749
+ const { token: o } = i, n = Gt(o), l = this._univerInstanceService.getCurrentUnitForType(N.UNIVER_SHEET);
1750
+ let u = l.getActiveSheet();
1751
+ const d = l.getUnitId();
1752
+ if (n.sheetName) {
1753
+ if (u = l.getSheetBySheetName(n.sheetName), !u)
1782
1754
  return !1;
1783
- const subUnitId = targetSheet == null ? void 0 : targetSheet.getSheetId();
1784
- if (!this._permissionService.getPermissionPoint(new WorksheetViewPermission(unitId, subUnitId).id)) return !1;
1755
+ const R = u == null ? void 0 : u.getSheetId();
1756
+ if (!this._permissionService.getPermissionPoint(new Bt(d, R).id)) return !1;
1785
1757
  }
1786
- if (!targetSheet)
1758
+ if (!u)
1787
1759
  return !1;
1788
- const { startRow, endRow, startColumn, endColumn } = sequenceGrid.range;
1789
- for (let i2 = startRow; i2 <= endRow; i2++)
1790
- for (let j = startColumn; j <= endColumn; j++) {
1791
- const permission = (_b = (_a12 = targetSheet.getCell(i2, j)) == null ? void 0 : _a12.selectionProtection) == null ? void 0 : _b[0];
1792
- if ((permission == null ? void 0 : permission[R.View]) === !1)
1760
+ const { startRow: c, endRow: m, startColumn: _, endColumn: g } = n.range;
1761
+ for (let R = c; R <= m; R++)
1762
+ for (let M = _; M <= g; M++) {
1763
+ const p = (t = (e = u.getCell(R, M)) == null ? void 0 : e.selectionProtection) == null ? void 0 : t[0];
1764
+ if ((p == null ? void 0 : p[gt.View]) === !1)
1793
1765
  return !1;
1794
1766
  }
1795
1767
  }
1796
1768
  return !0;
1797
1769
  }
1798
- }, __name(_a6, "DataValidationFormulaController"), _a6);
1799
- DataValidationFormulaController = __decorateClass$5([
1800
- __decorateParam$5(0, IUniverInstanceService),
1801
- __decorateParam$5(1, IPermissionService),
1802
- __decorateParam$5(2, Inject(LexerTreeBuilder))
1803
- ], DataValidationFormulaController);
1804
- var __defProp$4 = Object.defineProperty, __getOwnPropDesc$4 = Object.getOwnPropertyDescriptor, __decorateClass$4 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
1805
- for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$4(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
1806
- (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
1807
- return kind && result && __defProp$4(target, key, result), result;
1808
- }, "__decorateClass$4"), __decorateParam$4 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$4"), _a7;
1809
- let DataValidationRefRangeController = (_a7 = class extends Disposable {
1810
- constructor(_dataValidationModel, _injector, _refRangeService, _dataValidationFormulaService, _formulaRefRangeService, _validatorRegistryService) {
1770
+ };
1771
+ Te = Ia([
1772
+ He(0, O),
1773
+ He(1, Et),
1774
+ He(2, S(Y))
1775
+ ], Te);
1776
+ var Aa = Object.defineProperty, Da = Object.getOwnPropertyDescriptor, ba = (s, a, e, t) => {
1777
+ for (var r = t > 1 ? void 0 : t ? Da(a, e) : a, i = s.length - 1, o; i >= 0; i--)
1778
+ (o = s[i]) && (r = (t ? o(a, e, r) : o(r)) || r);
1779
+ return t && r && Aa(a, e, r), r;
1780
+ }, ee = (s, a) => (e, t) => a(e, t, s);
1781
+ let Fe = class extends $ {
1782
+ constructor(a, e, t, r, i, o) {
1811
1783
  super();
1812
- __publicField(this, "_disposableMap", /* @__PURE__ */ new Map());
1813
- __publicField(this, "registerRule", /* @__PURE__ */ __name((unitId, subUnitId, rule) => {
1814
- shouldOffsetFormulaByRange(rule.type, this._validatorRegistryService) || (this.register(unitId, subUnitId, rule), this.registerFormula(unitId, subUnitId, rule));
1815
- }, "registerRule"));
1816
- this._dataValidationModel = _dataValidationModel, this._injector = _injector, this._refRangeService = _refRangeService, this._dataValidationFormulaService = _dataValidationFormulaService, this._formulaRefRangeService = _formulaRefRangeService, this._validatorRegistryService = _validatorRegistryService, this._initRefRange();
1784
+ f(this, "_disposableMap", /* @__PURE__ */ new Map());
1785
+ f(this, "registerRule", (a, e, t) => {
1786
+ de(t.type, this._validatorRegistryService) || (this.register(a, e, t), this.registerFormula(a, e, t));
1787
+ });
1788
+ this._dataValidationModel = a, this._injector = e, this._refRangeService = t, this._dataValidationFormulaService = r, this._formulaRefRangeService = i, this._validatorRegistryService = o, this._initRefRange();
1817
1789
  }
1818
- _getIdWithUnitId(unitID, subUnitId, ruleId) {
1819
- return `${unitID}_${subUnitId}_${ruleId}`;
1790
+ _getIdWithUnitId(a, e, t) {
1791
+ return `${a}_${e}_${t}`;
1820
1792
  }
1821
1793
  // eslint-disable-next-line max-lines-per-function
1822
- registerFormula(unitId, subUnitId, rule) {
1823
- var _a12;
1824
- const ruleId = rule.uid, id = this._getIdWithUnitId(unitId, subUnitId, ruleId), disposeSet = (_a12 = this._disposableMap.get(id)) != null ? _a12 : /* @__PURE__ */ new Set(), handleFormulaChange = /* @__PURE__ */ __name((type, formulaString) => {
1825
- const oldRule = this._dataValidationModel.getRuleById(unitId, subUnitId, ruleId);
1826
- if (!oldRule)
1794
+ registerFormula(a, e, t) {
1795
+ var u;
1796
+ const r = t.uid, i = this._getIdWithUnitId(a, e, r), o = (u = this._disposableMap.get(i)) != null ? u : /* @__PURE__ */ new Set(), n = (d, c) => {
1797
+ const m = this._dataValidationModel.getRuleById(a, e, r);
1798
+ if (!m)
1827
1799
  return { redos: [], undos: [] };
1828
- const oldFormula = oldRule[type];
1829
- if (!oldFormula || oldFormula === formulaString)
1800
+ const _ = m[d];
1801
+ if (!_ || _ === c)
1830
1802
  return { redos: [], undos: [] };
1831
- const redoParams = {
1832
- unitId,
1833
- subUnitId,
1834
- ruleId: rule.uid,
1803
+ const g = {
1804
+ unitId: a,
1805
+ subUnitId: e,
1806
+ ruleId: t.uid,
1835
1807
  payload: {
1836
- type: UpdateRuleType.SETTING,
1808
+ type: y.SETTING,
1837
1809
  payload: {
1838
- type: oldRule.type,
1839
- formula1: oldRule.formula1,
1840
- formula2: oldRule.formula2,
1841
- [type]: formulaString
1810
+ type: m.type,
1811
+ formula1: m.formula1,
1812
+ formula2: m.formula2,
1813
+ [d]: c
1842
1814
  }
1843
1815
  },
1844
1816
  source: "patched"
1845
- }, undoParams = {
1846
- unitId,
1847
- subUnitId,
1848
- ruleId: rule.uid,
1817
+ }, R = {
1818
+ unitId: a,
1819
+ subUnitId: e,
1820
+ ruleId: t.uid,
1849
1821
  payload: {
1850
- type: UpdateRuleType.SETTING,
1822
+ type: y.SETTING,
1851
1823
  payload: {
1852
- type: oldRule.type,
1853
- formula1: oldRule.formula1,
1854
- formula2: oldRule.formula2
1824
+ type: m.type,
1825
+ formula1: m.formula1,
1826
+ formula2: m.formula2
1855
1827
  }
1856
1828
  },
1857
1829
  source: "patched"
1858
- }, redos = [
1830
+ }, M = [
1859
1831
  {
1860
- id: UpdateDataValidationMutation.id,
1861
- params: redoParams
1832
+ id: E.id,
1833
+ params: g
1862
1834
  }
1863
- ], undos = [
1835
+ ], p = [
1864
1836
  {
1865
- id: UpdateDataValidationMutation.id,
1866
- params: undoParams
1837
+ id: E.id,
1838
+ params: R
1867
1839
  }
1868
1840
  ];
1869
- return { redos, undos };
1870
- }, "handleFormulaChange"), currentFormula = this._dataValidationFormulaService.getRuleFormulaInfo(unitId, subUnitId, ruleId);
1871
- if (currentFormula) {
1872
- const [formula1, formula2] = currentFormula;
1873
- if (formula1) {
1874
- const disposable = this._formulaRefRangeService.registerFormula(
1875
- unitId,
1876
- subUnitId,
1877
- formula1.text,
1878
- (newFormulaString) => handleFormulaChange("formula1", newFormulaString)
1841
+ return { redos: M, undos: p };
1842
+ }, l = this._dataValidationFormulaService.getRuleFormulaInfo(a, e, r);
1843
+ if (l) {
1844
+ const [d, c] = l;
1845
+ if (d) {
1846
+ const m = this._formulaRefRangeService.registerFormula(
1847
+ a,
1848
+ e,
1849
+ d.text,
1850
+ (_) => n("formula1", _)
1879
1851
  );
1880
- disposeSet.add(() => disposable.dispose());
1852
+ o.add(() => m.dispose());
1881
1853
  }
1882
- if (formula2) {
1883
- const disposable = this._formulaRefRangeService.registerFormula(
1884
- unitId,
1885
- subUnitId,
1886
- formula2.text,
1887
- (newFormulaString) => handleFormulaChange("formula2", newFormulaString)
1854
+ if (c) {
1855
+ const m = this._formulaRefRangeService.registerFormula(
1856
+ a,
1857
+ e,
1858
+ c.text,
1859
+ (_) => n("formula2", _)
1888
1860
  );
1889
- disposeSet.add(() => disposable.dispose());
1861
+ o.add(() => m.dispose());
1890
1862
  }
1891
1863
  }
1892
1864
  }
1893
- register(unitId, subUnitId, rule) {
1894
- var _a12;
1895
- const handleRangeChange = /* @__PURE__ */ __name((commandInfo) => {
1896
- const oldRanges = [...rule.ranges], resultRanges = oldRanges.map((range) => handleCommonDefaultRangeChangeWithEffectRefCommands(range, commandInfo)).filter((range) => !!range).flat();
1897
- if (isRangesEqual(resultRanges, oldRanges))
1865
+ register(a, e, t) {
1866
+ var l;
1867
+ const r = (u) => {
1868
+ const d = [...t.ranges], m = d.map((g) => Pt(g, u)).filter((g) => !!g).flat();
1869
+ if (rt(m, d))
1898
1870
  return { redos: [], undos: [] };
1899
- if (resultRanges.length) {
1900
- const redoParams = {
1901
- unitId,
1902
- subUnitId,
1903
- ruleId: rule.uid,
1871
+ if (m.length) {
1872
+ const g = {
1873
+ unitId: a,
1874
+ subUnitId: e,
1875
+ ruleId: t.uid,
1904
1876
  payload: {
1905
- type: UpdateRuleType.RANGE,
1906
- payload: resultRanges
1877
+ type: y.RANGE,
1878
+ payload: m
1907
1879
  },
1908
1880
  source: "patched"
1909
- }, redos = [{ id: UpdateDataValidationMutation.id, params: redoParams }], undos = [{
1910
- id: UpdateDataValidationMutation.id,
1881
+ }, R = [{ id: E.id, params: g }], M = [{
1882
+ id: E.id,
1911
1883
  params: {
1912
- unitId,
1913
- subUnitId,
1914
- ruleId: rule.uid,
1884
+ unitId: a,
1885
+ subUnitId: e,
1886
+ ruleId: t.uid,
1915
1887
  payload: {
1916
- type: UpdateRuleType.RANGE,
1917
- payload: oldRanges
1888
+ type: y.RANGE,
1889
+ payload: d
1918
1890
  },
1919
1891
  source: "patched"
1920
1892
  }
1921
1893
  }];
1922
- return { redos, undos };
1894
+ return { redos: R, undos: M };
1923
1895
  } else {
1924
- const redoParams = { unitId, subUnitId, ruleId: rule.uid }, redos = [{ id: RemoveDataValidationMutation.id, params: redoParams }], undos = removeDataValidationUndoFactory(this._injector, redoParams);
1925
- return { redos, undos };
1896
+ const g = { unitId: a, subUnitId: e, ruleId: t.uid }, R = [{ id: A.id, params: g }], M = ya(this._injector, g);
1897
+ return { redos: R, undos: M };
1926
1898
  }
1927
- }, "handleRangeChange"), disposeList = [];
1928
- rule.ranges.forEach((range) => {
1929
- const disposable = this._refRangeService.registerRefRange(range, handleRangeChange, unitId, subUnitId);
1930
- disposeList.push(() => disposable.dispose());
1899
+ }, i = [];
1900
+ t.ranges.forEach((u) => {
1901
+ const d = this._refRangeService.registerRefRange(u, r, a, e);
1902
+ i.push(() => d.dispose());
1931
1903
  });
1932
- const id = this._getIdWithUnitId(unitId, subUnitId, rule.uid), current = (_a12 = this._disposableMap.get(id)) != null ? _a12 : /* @__PURE__ */ new Set();
1933
- current.add(() => disposeList.forEach((dispose) => dispose())), this._disposableMap.set(id, current);
1904
+ const o = this._getIdWithUnitId(a, e, t.uid), n = (l = this._disposableMap.get(o)) != null ? l : /* @__PURE__ */ new Set();
1905
+ n.add(() => i.forEach((u) => u())), this._disposableMap.set(o, n);
1934
1906
  }
1935
1907
  _initRefRange() {
1936
- const allRules = this._dataValidationModel.getAll();
1937
- for (const [unitId, subUnitMap] of allRules)
1938
- for (const [subUnitId, rules] of subUnitMap)
1939
- for (const rule of rules)
1940
- this.registerRule(unitId, subUnitId, rule);
1908
+ const a = this._dataValidationModel.getAll();
1909
+ for (const [e, t] of a)
1910
+ for (const [r, i] of t)
1911
+ for (const o of i)
1912
+ this.registerRule(e, r, o);
1941
1913
  this.disposeWithMe(
1942
- this._dataValidationModel.ruleChange$.subscribe((option) => {
1943
- const { unitId, subUnitId, rule } = option;
1944
- switch (option.type) {
1914
+ this._dataValidationModel.ruleChange$.subscribe((e) => {
1915
+ const { unitId: t, subUnitId: r, rule: i } = e;
1916
+ switch (e.type) {
1945
1917
  case "add": {
1946
- const rule2 = option.rule;
1947
- this.registerRule(option.unitId, option.subUnitId, rule2);
1918
+ const o = e.rule;
1919
+ this.registerRule(e.unitId, e.subUnitId, o);
1948
1920
  break;
1949
1921
  }
1950
1922
  case "remove": {
1951
- const disposeSet = this._disposableMap.get(this._getIdWithUnitId(unitId, subUnitId, rule.uid));
1952
- disposeSet && disposeSet.forEach((dispose) => dispose());
1923
+ const o = this._disposableMap.get(this._getIdWithUnitId(t, r, i.uid));
1924
+ o && o.forEach((n) => n());
1953
1925
  break;
1954
1926
  }
1955
1927
  case "update": {
1956
- const rule2 = option.rule, disposeSet = this._disposableMap.get(this._getIdWithUnitId(unitId, subUnitId, rule2.uid));
1957
- disposeSet && disposeSet.forEach((dispose) => dispose()), this.registerRule(option.unitId, option.subUnitId, rule2);
1928
+ const o = e.rule, n = this._disposableMap.get(this._getIdWithUnitId(t, r, o.uid));
1929
+ n && n.forEach((l) => l()), this.registerRule(e.unitId, e.subUnitId, o);
1958
1930
  break;
1959
1931
  }
1960
1932
  }
1961
1933
  })
1962
- ), this.disposeWithMe(toDisposable(() => {
1963
- this._disposableMap.forEach((item) => {
1964
- item.forEach((dispose) => dispose());
1934
+ ), this.disposeWithMe(qe(() => {
1935
+ this._disposableMap.forEach((e) => {
1936
+ e.forEach((t) => t());
1965
1937
  }), this._disposableMap.clear();
1966
1938
  }));
1967
1939
  }
1968
- }, __name(_a7, "DataValidationRefRangeController"), _a7);
1969
- DataValidationRefRangeController = __decorateClass$4([
1970
- __decorateParam$4(0, Inject(SheetDataValidationModel)),
1971
- __decorateParam$4(1, Inject(Injector)),
1972
- __decorateParam$4(2, Inject(RefRangeService)),
1973
- __decorateParam$4(3, Inject(DataValidationFormulaService)),
1974
- __decorateParam$4(4, Inject(FormulaRefRangeService)),
1975
- __decorateParam$4(5, Inject(DataValidatorRegistryService))
1976
- ], DataValidationRefRangeController);
1977
- var __defProp$3 = Object.defineProperty, __getOwnPropDesc$3 = Object.getOwnPropertyDescriptor, __decorateClass$3 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
1978
- for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$3(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
1979
- (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
1980
- return kind && result && __defProp$3(target, key, result), result;
1981
- }, "__decorateClass$3"), __decorateParam$3 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$3"), _a8;
1982
- let SheetDataValidationSheetController = (_a8 = class extends Disposable {
1983
- constructor(_sheetInterceptorService, _univerInstanceService, _sheetDataValidationModel) {
1984
- super(), this._sheetInterceptorService = _sheetInterceptorService, this._univerInstanceService = _univerInstanceService, this._sheetDataValidationModel = _sheetDataValidationModel, this._initSheetChange();
1940
+ };
1941
+ Fe = ba([
1942
+ ee(0, S(F)),
1943
+ ee(1, S(Ge)),
1944
+ ee(2, S(Ut)),
1945
+ ee(3, S(K)),
1946
+ ee(4, S(ut)),
1947
+ ee(5, S(G))
1948
+ ], Fe);
1949
+ var La = Object.defineProperty, xa = Object.getOwnPropertyDescriptor, Ba = (s, a, e, t) => {
1950
+ for (var r = t > 1 ? void 0 : t ? xa(a, e) : a, i = s.length - 1, o; i >= 0; i--)
1951
+ (o = s[i]) && (r = (t ? o(a, e, r) : o(r)) || r);
1952
+ return t && r && La(a, e, r), r;
1953
+ }, We = (s, a) => (e, t) => a(e, t, s);
1954
+ let Ne = class extends $ {
1955
+ constructor(s, a, e) {
1956
+ super(), this._sheetInterceptorService = s, this._univerInstanceService = a, this._sheetDataValidationModel = e, this._initSheetChange();
1985
1957
  }
1986
1958
  _initSheetChange() {
1987
1959
  this.disposeWithMe(
1988
1960
  this._sheetInterceptorService.interceptCommand({
1989
- getMutations: /* @__PURE__ */ __name((commandInfo) => {
1990
- var _a12;
1991
- if (commandInfo.id === RemoveSheetCommand.id) {
1992
- const params = commandInfo.params, unitId = params.unitId || this._univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET).getUnitId(), workbook = this._univerInstanceService.getUniverSheetInstance(unitId);
1993
- if (!workbook)
1961
+ getMutations: (s) => {
1962
+ var a;
1963
+ if (s.id === $t.id) {
1964
+ const e = s.params, t = e.unitId || this._univerInstanceService.getCurrentUnitForType(N.UNIVER_SHEET).getUnitId(), r = this._univerInstanceService.getUniverSheetInstance(t);
1965
+ if (!r)
1994
1966
  return { redos: [], undos: [] };
1995
- const subUnitId = params.subUnitId || ((_a12 = workbook.getActiveSheet()) == null ? void 0 : _a12.getSheetId());
1996
- if (!subUnitId)
1967
+ const i = e.subUnitId || ((a = r.getActiveSheet()) == null ? void 0 : a.getSheetId());
1968
+ if (!i)
1997
1969
  return { redos: [], undos: [] };
1998
- const rules = this._sheetDataValidationModel.getRules(unitId, subUnitId);
1999
- if (rules.length === 0)
1970
+ const o = this._sheetDataValidationModel.getRules(t, i);
1971
+ if (o.length === 0)
2000
1972
  return { redos: [], undos: [] };
2001
- const ids = rules.map((i) => i.uid), redoParams = {
2002
- unitId,
2003
- subUnitId,
2004
- ruleId: ids,
1973
+ const n = o.map((d) => d.uid), l = {
1974
+ unitId: t,
1975
+ subUnitId: i,
1976
+ ruleId: n,
2005
1977
  source: "patched"
2006
- }, undoParams = {
2007
- unitId,
2008
- subUnitId,
2009
- rule: [...rules],
1978
+ }, u = {
1979
+ unitId: t,
1980
+ subUnitId: i,
1981
+ rule: [...o],
2010
1982
  source: "patched"
2011
1983
  };
2012
1984
  return {
2013
1985
  redos: [{
2014
- id: RemoveDataValidationMutation.id,
2015
- params: redoParams
1986
+ id: A.id,
1987
+ params: l
2016
1988
  }],
2017
1989
  undos: [{
2018
- id: AddDataValidationMutation.id,
2019
- params: undoParams
1990
+ id: L.id,
1991
+ params: u
2020
1992
  }]
2021
1993
  };
2022
1994
  }
2023
1995
  return { redos: [], undos: [] };
2024
- }, "getMutations")
1996
+ }
2025
1997
  })
2026
1998
  );
2027
1999
  }
2028
- }, __name(_a8, "SheetDataValidationSheetController"), _a8);
2029
- SheetDataValidationSheetController = __decorateClass$3([
2030
- __decorateParam$3(0, Inject(SheetInterceptorService)),
2031
- __decorateParam$3(1, Inject(IUniverInstanceService)),
2032
- __decorateParam$3(2, Inject(SheetDataValidationModel))
2033
- ], SheetDataValidationSheetController);
2034
- const _AnyValidator = class _AnyValidator extends BaseDataValidator {
2000
+ };
2001
+ Ne = Ba([
2002
+ We(0, S(ot)),
2003
+ We(1, S(O)),
2004
+ We(2, S(F))
2005
+ ], Ne);
2006
+ class Ua extends k {
2035
2007
  constructor() {
2036
2008
  super(...arguments);
2037
- __publicField(this, "id", DataValidationType.ANY);
2038
- __publicField(this, "title", "dataValidation.any.title");
2039
- __publicField(this, "operators", []);
2040
- __publicField(this, "scopes", ["sheet"]);
2041
- __publicField(this, "offsetFormulaByRange", !1);
2009
+ f(this, "id", T.ANY);
2010
+ f(this, "title", "dataValidation.any.title");
2011
+ f(this, "operators", []);
2012
+ f(this, "scopes", ["sheet"]);
2013
+ f(this, "offsetFormulaByRange", !1);
2042
2014
  }
2043
- async parseFormula(rule, unitId, subUnitId) {
2015
+ async parseFormula(e, t, r) {
2044
2016
  return {
2045
- formula1: rule.formula1,
2046
- formula2: rule.formula2,
2017
+ formula1: e.formula1,
2018
+ formula2: e.formula2,
2047
2019
  isFormulaValid: !0
2048
2020
  };
2049
2021
  }
2050
- validatorFormula(rule, unitId, subUnitId) {
2022
+ validatorFormula(e, t, r) {
2051
2023
  return {
2052
2024
  success: !0
2053
2025
  };
2054
2026
  }
2055
- async isValidType(cellInfo, formula, rule) {
2027
+ async isValidType(e, t, r) {
2056
2028
  return !0;
2057
2029
  }
2058
- generateRuleErrorMessage(rule) {
2030
+ generateRuleErrorMessage(e) {
2059
2031
  return this.localeService.t("dataValidation.any.error");
2060
2032
  }
2061
- };
2062
- __name(_AnyValidator, "AnyValidator");
2063
- let AnyValidator = _AnyValidator;
2064
- const _CustomFormulaValidator = class _CustomFormulaValidator extends BaseDataValidator {
2033
+ }
2034
+ class Pa extends k {
2065
2035
  constructor() {
2066
2036
  super(...arguments);
2067
- __publicField(this, "id", DataValidationType.CUSTOM);
2068
- __publicField(this, "title", "dataValidation.custom.title");
2069
- __publicField(this, "operators", []);
2070
- __publicField(this, "scopes", ["sheet"]);
2071
- __publicField(this, "_customFormulaService", this.injector.get(DataValidationCustomFormulaService));
2072
- __publicField(this, "_lexerTreeBuilder", this.injector.get(LexerTreeBuilder));
2073
- }
2074
- validatorFormula(rule, unitId, subUnitId) {
2075
- var _a12;
2076
- const success = isFormulaString(rule.formula1), formulaText = (_a12 = rule.formula1) != null ? _a12 : "", valid = this._lexerTreeBuilder.checkIfAddBracket(formulaText) === 0 && formulaText.startsWith(operatorToken.EQUALS);
2037
+ f(this, "id", T.CUSTOM);
2038
+ f(this, "title", "dataValidation.custom.title");
2039
+ f(this, "operators", []);
2040
+ f(this, "scopes", ["sheet"]);
2041
+ f(this, "_customFormulaService", this.injector.get(P));
2042
+ f(this, "_lexerTreeBuilder", this.injector.get(Y));
2043
+ }
2044
+ validatorFormula(e, t, r) {
2045
+ var u;
2046
+ const i = v(e.formula1), o = (u = e.formula1) != null ? u : "", l = this._lexerTreeBuilder.checkIfAddBracket(o) === 0 && o.startsWith(kt.EQUALS);
2077
2047
  return {
2078
- success: success && valid,
2079
- formula1: success && valid ? "" : this.localeService.t("dataValidation.validFail.formula")
2048
+ success: i && l,
2049
+ formula1: i && l ? "" : this.localeService.t("dataValidation.validFail.formula")
2080
2050
  };
2081
2051
  }
2082
- async parseFormula(_rule, _unitId, _subUnitId) {
2052
+ async parseFormula(e, t, r) {
2083
2053
  return {
2084
2054
  formula1: void 0,
2085
2055
  formula2: void 0,
2086
2056
  isFormulaValid: !0
2087
2057
  };
2088
2058
  }
2089
- async isValidType(cellInfo, _formula, _rule) {
2090
- const { column, row, unitId, subUnitId } = cellInfo, cellData = await this._customFormulaService.getCellFormulaValue(unitId, subUnitId, _rule.uid, row, column), formulaResult = cellData == null ? void 0 : cellData.v;
2091
- return isLegalFormulaResult(String(formulaResult)) && Tools.isDefine(formulaResult) && formulaResult !== "" ? cellData.t === CellValueType.BOOLEAN ? !!formulaResult : typeof formulaResult == "boolean" ? formulaResult : typeof formulaResult == "number" ? !!formulaResult : typeof formulaResult == "string" ? isLegalFormulaResult(formulaResult) : !!formulaResult : !1;
2059
+ async isValidType(e, t, r) {
2060
+ const { column: i, row: o, unitId: n, subUnitId: l } = e, u = await this._customFormulaService.getCellFormulaValue(n, l, r.uid, o, i), d = u == null ? void 0 : u.v;
2061
+ return C(String(d)) && V.isDefine(d) && d !== "" ? u.t === Tt.BOOLEAN ? !!d : typeof d == "boolean" ? d : typeof d == "number" ? !!d : typeof d == "string" ? C(d) : !!d : !1;
2092
2062
  }
2093
- generateRuleErrorMessage(rule) {
2063
+ generateRuleErrorMessage(e) {
2094
2064
  return this.localeService.t("dataValidation.custom.error");
2095
2065
  }
2096
- generateRuleName(rule) {
2097
- var _a12;
2098
- return this.localeService.t("dataValidation.custom.ruleName").replace("{FORMULA1}", (_a12 = rule.formula1) != null ? _a12 : "");
2066
+ generateRuleName(e) {
2067
+ var t;
2068
+ return this.localeService.t("dataValidation.custom.ruleName").replace("{FORMULA1}", (t = e.formula1) != null ? t : "");
2099
2069
  }
2100
- };
2101
- __name(_CustomFormulaValidator, "CustomFormulaValidator");
2102
- let CustomFormulaValidator = _CustomFormulaValidator;
2103
- const _ListMultipleValidator = class _ListMultipleValidator extends ListValidator {
2070
+ }
2071
+ class $a extends mt {
2104
2072
  constructor() {
2105
2073
  super(...arguments);
2106
- __publicField(this, "id", DataValidationType.LIST_MULTIPLE);
2107
- __publicField(this, "title", "dataValidation.listMultiple.title");
2108
- __publicField(this, "offsetFormulaByRange", !1);
2109
- __publicField(this, "skipDefaultFontRender", /* @__PURE__ */ __name(() => !0, "skipDefaultFontRender"));
2074
+ f(this, "id", T.LIST_MULTIPLE);
2075
+ f(this, "title", "dataValidation.listMultiple.title");
2076
+ f(this, "offsetFormulaByRange", !1);
2077
+ f(this, "skipDefaultFontRender", () => !0);
2110
2078
  }
2111
- };
2112
- __name(_ListMultipleValidator, "ListMultipleValidator");
2113
- let ListMultipleValidator = _ListMultipleValidator;
2114
- const _WholeValidator = class _WholeValidator extends BaseDataValidator {
2079
+ }
2080
+ class Ha extends k {
2115
2081
  constructor() {
2116
2082
  super(...arguments);
2117
- __publicField(this, "_customFormulaService", this.injector.get(DataValidationCustomFormulaService));
2118
- __publicField(this, "_lexerTreeBuilder", this.injector.get(LexerTreeBuilder));
2119
- __publicField(this, "id", DataValidationType.WHOLE);
2120
- __publicField(this, "title", "dataValidation.whole.title");
2121
- __publicField(this, "operators", [
2122
- DataValidationOperator.BETWEEN,
2123
- DataValidationOperator.EQUAL,
2124
- DataValidationOperator.GREATER_THAN,
2125
- DataValidationOperator.GREATER_THAN_OR_EQUAL,
2126
- DataValidationOperator.LESS_THAN,
2127
- DataValidationOperator.LESS_THAN_OR_EQUAL,
2128
- DataValidationOperator.NOT_BETWEEN,
2129
- DataValidationOperator.NOT_EQUAL
2083
+ f(this, "_customFormulaService", this.injector.get(P));
2084
+ f(this, "_lexerTreeBuilder", this.injector.get(Y));
2085
+ f(this, "id", T.WHOLE);
2086
+ f(this, "title", "dataValidation.whole.title");
2087
+ f(this, "operators", [
2088
+ h.BETWEEN,
2089
+ h.EQUAL,
2090
+ h.GREATER_THAN,
2091
+ h.GREATER_THAN_OR_EQUAL,
2092
+ h.LESS_THAN,
2093
+ h.LESS_THAN_OR_EQUAL,
2094
+ h.NOT_BETWEEN,
2095
+ h.NOT_EQUAL
2130
2096
  ]);
2131
- __publicField(this, "scopes", ["sheet"]);
2097
+ f(this, "scopes", ["sheet"]);
2132
2098
  }
2133
- _isFormulaOrInt(formula) {
2134
- return !Tools.isBlank(formula) && (isFormulaString(formula) || !Number.isNaN(+formula) && Number.isInteger(+formula));
2099
+ _isFormulaOrInt(e) {
2100
+ return !V.isBlank(e) && (v(e) || !Number.isNaN(+e) && Number.isInteger(+e));
2135
2101
  }
2136
- async isValidType(cellInfo, _formula, _rule) {
2137
- const { value: cellValue } = cellInfo, num = getCellValueNumber(cellValue);
2138
- return !Number.isNaN(num) && Number.isInteger(num);
2102
+ async isValidType(e, t, r) {
2103
+ const { value: i } = e, o = ye(i);
2104
+ return !Number.isNaN(o) && Number.isInteger(o);
2139
2105
  }
2140
- transform(cellInfo, _formula, _rule) {
2141
- const { value: cellValue } = cellInfo;
2106
+ transform(e, t, r) {
2107
+ const { value: i } = e;
2142
2108
  return {
2143
- ...cellInfo,
2144
- value: getCellValueNumber(cellValue)
2109
+ ...e,
2110
+ value: ye(i)
2145
2111
  };
2146
2112
  }
2147
- _parseNumber(formula) {
2148
- return formula == null ? Number.NaN : +formula;
2113
+ _parseNumber(e) {
2114
+ return e == null ? Number.NaN : +e;
2149
2115
  }
2150
- async parseFormula(rule, unitId, subUnitId, row, column) {
2151
- const res1 = await this._customFormulaService.getCellFormulaValue(unitId, subUnitId, rule.uid, row, column), res2 = await this._customFormulaService.getCellFormula2Value(unitId, subUnitId, rule.uid, row, column), { formula1, formula2 } = rule, formula1Result = isFormulaString(formula1) ? res1 == null ? void 0 : res1.v : formula1, formula2Result = isFormulaString(formula2) ? res2 == null ? void 0 : res2.v : formula2, isFormulaValid = isLegalFormulaResult(`${formula1Result}`) && isLegalFormulaResult(`${formula2Result}`);
2116
+ async parseFormula(e, t, r, i, o) {
2117
+ const n = await this._customFormulaService.getCellFormulaValue(t, r, e.uid, i, o), l = await this._customFormulaService.getCellFormula2Value(t, r, e.uid, i, o), { formula1: u, formula2: d } = e, c = v(u) ? n == null ? void 0 : n.v : u, m = v(d) ? l == null ? void 0 : l.v : d, _ = C(`${c}`) && C(`${m}`);
2152
2118
  return {
2153
- formula1: this._parseNumber(formula1Result),
2154
- formula2: this._parseNumber(formula2Result),
2155
- isFormulaValid
2119
+ formula1: this._parseNumber(c),
2120
+ formula2: this._parseNumber(m),
2121
+ isFormulaValid: _
2156
2122
  };
2157
2123
  }
2158
- validatorFormula(rule, _unitId, _subUnitId) {
2159
- const operator = rule.operator;
2160
- if (!operator)
2124
+ validatorFormula(e, t, r) {
2125
+ const i = e.operator;
2126
+ if (!i)
2161
2127
  return {
2162
2128
  success: !1
2163
2129
  };
2164
- const formula1Success = Tools.isDefine(rule.formula1) && this._isFormulaOrInt(rule.formula1), formula2Success = Tools.isDefine(rule.formula2) && this._isFormulaOrInt(rule.formula2), isTwoFormula = TWO_FORMULA_OPERATOR_COUNT.includes(operator), errorMsg = this.localeService.t("dataValidation.validFail.number");
2165
- return isTwoFormula ? {
2166
- success: formula1Success && formula2Success,
2167
- formula1: formula1Success ? void 0 : errorMsg,
2168
- formula2: formula2Success ? void 0 : errorMsg
2130
+ const o = V.isDefine(e.formula1) && this._isFormulaOrInt(e.formula1), n = V.isDefine(e.formula2) && this._isFormulaOrInt(e.formula2), l = Ae.includes(i), u = this.localeService.t("dataValidation.validFail.number");
2131
+ return l ? {
2132
+ success: o && n,
2133
+ formula1: o ? void 0 : u,
2134
+ formula2: n ? void 0 : u
2169
2135
  } : {
2170
- success: formula1Success,
2171
- formula1: errorMsg
2136
+ success: o,
2137
+ formula1: u
2172
2138
  };
2173
2139
  }
2174
- generateRuleErrorMessage(rule, position) {
2175
- if (!rule.operator)
2140
+ generateRuleErrorMessage(e, t) {
2141
+ if (!e.operator)
2176
2142
  return this.titleStr;
2177
- const { transformedFormula1, transformedFormula2 } = getTransformedFormula(this._lexerTreeBuilder, rule, position);
2178
- return `${this.localeService.t(OperatorErrorTitleMap[rule.operator]).replace(FORMULA1, transformedFormula1 != null ? transformedFormula1 : "").replace(FORMULA2, transformedFormula2 != null ? transformedFormula2 : "")}`;
2143
+ const { transformedFormula1: r, transformedFormula2: i } = De(this._lexerTreeBuilder, e, t);
2144
+ return `${this.localeService.t(ht[e.operator]).replace(le, r != null ? r : "").replace(ue, i != null ? i : "")}`;
2179
2145
  }
2180
- };
2181
- __name(_WholeValidator, "WholeValidator");
2182
- let WholeValidator = _WholeValidator;
2183
- var __defProp$2 = Object.defineProperty, __getOwnPropDesc$2 = Object.getOwnPropertyDescriptor, __decorateClass$2 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
2184
- for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$2(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
2185
- (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
2186
- return kind && result && __defProp$2(target, key, result), result;
2187
- }, "__decorateClass$2"), __decorateParam$2 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$2"), _a9;
2188
- let DataValidationController = (_a9 = class extends RxDisposable {
2189
- constructor(_univerInstanceService, _dataValidatorRegistryService, _injector, _selectionManagerService, _sheetInterceptorService, _sheetDataValidationModel) {
2190
- super(), this._univerInstanceService = _univerInstanceService, this._dataValidatorRegistryService = _dataValidatorRegistryService, this._injector = _injector, this._selectionManagerService = _selectionManagerService, this._sheetInterceptorService = _sheetInterceptorService, this._sheetDataValidationModel = _sheetDataValidationModel, this._init();
2146
+ }
2147
+ var Wa = Object.defineProperty, ja = Object.getOwnPropertyDescriptor, Qa = (s, a, e, t) => {
2148
+ for (var r = t > 1 ? void 0 : t ? ja(a, e) : a, i = s.length - 1, o; i >= 0; i--)
2149
+ (o = s[i]) && (r = (t ? o(a, e, r) : o(r)) || r);
2150
+ return t && r && Wa(a, e, r), r;
2151
+ }, te = (s, a) => (e, t) => a(e, t, s);
2152
+ let Ce = class extends Ft {
2153
+ constructor(s, a, e, t, r, i) {
2154
+ super(), this._univerInstanceService = s, this._dataValidatorRegistryService = a, this._injector = e, this._selectionManagerService = t, this._sheetInterceptorService = r, this._sheetDataValidationModel = i, this._init();
2191
2155
  }
2192
2156
  _init() {
2193
2157
  this._registerValidators(), this._initCommandInterceptor();
2194
2158
  }
2195
2159
  _registerValidators() {
2196
2160
  [
2197
- AnyValidator,
2198
- DecimalValidator,
2199
- WholeValidator,
2200
- TextLengthValidator,
2201
- DateValidator,
2202
- CheckboxValidator,
2203
- ListValidator,
2204
- ListMultipleValidator,
2205
- CustomFormulaValidator
2206
- ].forEach((Validator) => {
2207
- const validator = this._injector.createInstance(Validator);
2208
- this.disposeWithMe(this._dataValidatorRegistryService.register(validator)), this.disposeWithMe(toDisposable(() => this._injector.delete(Validator)));
2161
+ Ua,
2162
+ ha,
2163
+ Ha,
2164
+ _a,
2165
+ ca,
2166
+ na,
2167
+ mt,
2168
+ $a,
2169
+ Pa
2170
+ ].forEach((s) => {
2171
+ const a = this._injector.createInstance(s);
2172
+ this.disposeWithMe(this._dataValidatorRegistryService.register(a)), this.disposeWithMe(qe(() => this._injector.delete(s)));
2209
2173
  });
2210
2174
  }
2211
2175
  _initCommandInterceptor() {
2212
2176
  this._sheetInterceptorService.interceptCommand({
2213
- getMutations: /* @__PURE__ */ __name((commandInfo) => {
2214
- var _a12;
2215
- if (commandInfo.id === ClearSelectionAllCommand.id) {
2216
- const workbook = this._univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET), unitId = workbook.getUnitId(), worksheet = workbook.getActiveSheet();
2217
- if (!worksheet)
2177
+ getMutations: (s) => {
2178
+ var a;
2179
+ if (s.id === Ht.id) {
2180
+ const e = this._univerInstanceService.getCurrentUnitForType(N.UNIVER_SHEET), t = e.getUnitId(), r = e.getActiveSheet();
2181
+ if (!r)
2218
2182
  throw new Error("No active sheet found");
2219
- const subUnitId = worksheet.getSheetId(), selections = (_a12 = this._selectionManagerService.getCurrentSelections()) == null ? void 0 : _a12.map((s) => s.range), ruleMatrix = this._sheetDataValidationModel.getRuleObjectMatrix(unitId, subUnitId).clone();
2220
- selections && ruleMatrix.removeRange(selections);
2221
- const diffs = ruleMatrix.diff(this._sheetDataValidationModel.getRules(unitId, subUnitId)), { redoMutations, undoMutations } = getDataValidationDiffMutations(unitId, subUnitId, diffs, this._injector, "patched");
2183
+ const i = r.getSheetId(), o = (a = this._selectionManagerService.getCurrentSelections()) == null ? void 0 : a.map((c) => c.range), n = this._sheetDataValidationModel.getRuleObjectMatrix(t, i).clone();
2184
+ o && n.removeRange(o);
2185
+ const l = n.diff(this._sheetDataValidationModel.getRules(t, i)), { redoMutations: u, undoMutations: d } = be(t, i, l, this._injector, "patched");
2222
2186
  return {
2223
- undos: undoMutations,
2224
- redos: redoMutations
2187
+ undos: d,
2188
+ redos: u
2225
2189
  };
2226
2190
  }
2227
2191
  return {
2228
2192
  undos: [],
2229
2193
  redos: []
2230
2194
  };
2231
- }, "getMutations")
2195
+ }
2232
2196
  });
2233
2197
  }
2234
- }, __name(_a9, "DataValidationController"), _a9);
2235
- DataValidationController = __decorateClass$2([
2236
- __decorateParam$2(0, IUniverInstanceService),
2237
- __decorateParam$2(1, Inject(DataValidatorRegistryService)),
2238
- __decorateParam$2(2, Inject(Injector)),
2239
- __decorateParam$2(3, Inject(SheetsSelectionsService)),
2240
- __decorateParam$2(4, Inject(SheetInterceptorService)),
2241
- __decorateParam$2(5, Inject(SheetDataValidationModel))
2242
- ], DataValidationController);
2243
- var __defProp$1 = Object.defineProperty, __getOwnPropDesc$1 = Object.getOwnPropertyDescriptor, __decorateClass$1 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
2244
- for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$1(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
2245
- (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
2246
- return kind && result && __defProp$1(target, key, result), result;
2247
- }, "__decorateClass$1"), __decorateParam$1 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$1"), _a10;
2248
- let SheetsDataValidationValidatorService = (_a10 = class extends Disposable {
2249
- constructor(_univerInstanceService, _sheetDataValidationModel, _dataValidationCacheService, _lifecycleService) {
2250
- super(), this._univerInstanceService = _univerInstanceService, this._sheetDataValidationModel = _sheetDataValidationModel, this._dataValidationCacheService = _dataValidationCacheService, this._lifecycleService = _lifecycleService, this._initRecalculate();
2198
+ };
2199
+ Ce = Qa([
2200
+ te(0, O),
2201
+ te(1, S(G)),
2202
+ te(2, S(Ge)),
2203
+ te(3, S(nt)),
2204
+ te(4, S(ot)),
2205
+ te(5, S(F))
2206
+ ], Ce);
2207
+ var qa = Object.defineProperty, Ga = Object.getOwnPropertyDescriptor, ka = (s, a, e, t) => {
2208
+ for (var r = t > 1 ? void 0 : t ? Ga(a, e) : a, i = s.length - 1, o; i >= 0; i--)
2209
+ (o = s[i]) && (r = (t ? o(a, e, r) : o(r)) || r);
2210
+ return t && r && qa(a, e, r), r;
2211
+ }, Re = (s, a) => (e, t) => a(e, t, s);
2212
+ let Oe = class extends $ {
2213
+ constructor(s, a, e, t) {
2214
+ super(), this._univerInstanceService = s, this._sheetDataValidationModel = a, this._dataValidationCacheService = e, this._lifecycleService = t, this._initRecalculate();
2251
2215
  }
2252
2216
  _initRecalculate() {
2253
- const handleDirtyRanges = /* @__PURE__ */ __name((ranges) => {
2254
- if (ranges.length === 0)
2217
+ const s = (a) => {
2218
+ if (a.length === 0)
2255
2219
  return;
2256
- const workbook = this._univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET), worksheet = workbook == null ? void 0 : workbook.getActiveSheet(), map = {};
2257
- ranges.flat().forEach((range) => {
2258
- map[range.unitId] || (map[range.unitId] = {}), map[range.unitId][range.subUnitId] || (map[range.unitId][range.subUnitId] = []);
2259
- const workbook2 = this._univerInstanceService.getUnit(range.unitId, UniverInstanceType.UNIVER_SHEET), worksheet2 = workbook2 == null ? void 0 : workbook2.getSheetBySheetId(range.subUnitId);
2260
- worksheet2 && map[range.unitId][range.subUnitId].push(...range.ranges.map((range2) => Range.transformRange(range2, worksheet2)));
2261
- }), Object.entries(map).forEach(([unitId, subUnitMap]) => {
2262
- Object.entries(subUnitMap).forEach(([subUnitId, ranges2]) => {
2263
- (workbook == null ? void 0 : workbook.getUnitId()) === unitId && (worksheet == null ? void 0 : worksheet.getSheetId()) === subUnitId ? this.validatorRanges(unitId, subUnitId, ranges2) : requestIdleCallback(() => {
2264
- this.validatorRanges(unitId, subUnitId, ranges2);
2220
+ const e = this._univerInstanceService.getCurrentUnitForType(N.UNIVER_SHEET), t = e == null ? void 0 : e.getActiveSheet(), r = {};
2221
+ a.flat().forEach((i) => {
2222
+ r[i.unitId] || (r[i.unitId] = {}), r[i.unitId][i.subUnitId] || (r[i.unitId][i.subUnitId] = []);
2223
+ const o = this._univerInstanceService.getUnit(i.unitId, N.UNIVER_SHEET), n = o == null ? void 0 : o.getSheetBySheetId(i.subUnitId);
2224
+ n && r[i.unitId][i.subUnitId].push(...i.ranges.map((l) => b.transformRange(l, n)));
2225
+ }), Object.entries(r).forEach(([i, o]) => {
2226
+ Object.entries(o).forEach(([n, l]) => {
2227
+ (e == null ? void 0 : e.getUnitId()) === i && (t == null ? void 0 : t.getSheetId()) === n ? this.validatorRanges(i, n, l) : requestIdleCallback(() => {
2228
+ this.validatorRanges(i, n, l);
2265
2229
  });
2266
2230
  });
2267
2231
  });
2268
- }, "handleDirtyRanges");
2269
- this.disposeWithMe(this._dataValidationCacheService.dirtyRanges$.pipe(bufferWhen(() => this._lifecycleService.lifecycle$.pipe(filter((stage) => stage === LifecycleStages.Rendered)))).subscribe(handleDirtyRanges)), this.disposeWithMe(this._dataValidationCacheService.dirtyRanges$.pipe(filter(() => this._lifecycleService.stage >= LifecycleStages.Rendered), bufferDebounceTime(20)).subscribe(handleDirtyRanges));
2270
- }
2271
- async _validatorByCell(workbook, worksheet, row, col) {
2272
- const unitId = workbook.getUnitId(), subUnitId = worksheet.getSheetId();
2273
- if (!Tools.isDefine(row) || !Tools.isDefine(col))
2274
- throw new Error(`row or col is not defined, row: ${row}, col: ${col}`);
2275
- const rule = this._sheetDataValidationModel.getRuleByLocation(unitId, subUnitId, row, col);
2276
- return rule ? new Promise((resolve) => {
2277
- this._sheetDataValidationModel.validator(rule, { unitId, subUnitId, row, col, worksheet, workbook }, (status) => {
2278
- resolve(status);
2232
+ };
2233
+ this.disposeWithMe(this._dataValidationCacheService.dirtyRanges$.pipe(Wt(() => this._lifecycleService.lifecycle$.pipe(Ze((a) => a === ze.Rendered)))).subscribe(s)), this.disposeWithMe(this._dataValidationCacheService.dirtyRanges$.pipe(Ze(() => this._lifecycleService.stage >= ze.Rendered), Ct(20)).subscribe(s));
2234
+ }
2235
+ async _validatorByCell(s, a, e, t) {
2236
+ const r = s.getUnitId(), i = a.getSheetId();
2237
+ if (!V.isDefine(e) || !V.isDefine(t))
2238
+ throw new Error(`row or col is not defined, row: ${e}, col: ${t}`);
2239
+ const o = this._sheetDataValidationModel.getRuleByLocation(r, i, e, t);
2240
+ return o ? new Promise((n) => {
2241
+ this._sheetDataValidationModel.validator(o, { unitId: r, subUnitId: i, row: e, col: t, worksheet: a, workbook: s }, (l) => {
2242
+ n(l);
2279
2243
  });
2280
- }) : DataValidationStatus.VALID;
2281
- }
2282
- async validatorCell(unitId, subUnitId, row, col) {
2283
- const workbook = this._univerInstanceService.getUnit(unitId, UniverInstanceType.UNIVER_SHEET);
2284
- if (!workbook)
2285
- throw new Error(`cannot find current workbook, unitId: ${unitId}`);
2286
- const worksheet = workbook.getSheetBySheetId(subUnitId);
2287
- if (!worksheet)
2288
- throw new Error(`cannot find current worksheet, sheetId: ${subUnitId}`);
2289
- return this._validatorByCell(workbook, worksheet, row, col);
2290
- }
2291
- validatorRanges(unitId, subUnitId, ranges) {
2292
- if (!ranges.length)
2244
+ }) : D.VALID;
2245
+ }
2246
+ async validatorCell(s, a, e, t) {
2247
+ const r = this._univerInstanceService.getUnit(s, N.UNIVER_SHEET);
2248
+ if (!r)
2249
+ throw new Error(`cannot find current workbook, unitId: ${s}`);
2250
+ const i = r.getSheetBySheetId(a);
2251
+ if (!i)
2252
+ throw new Error(`cannot find current worksheet, sheetId: ${a}`);
2253
+ return this._validatorByCell(r, i, e, t);
2254
+ }
2255
+ validatorRanges(s, a, e) {
2256
+ if (!e.length)
2293
2257
  return Promise.resolve([]);
2294
- const workbook = this._univerInstanceService.getUnit(unitId, UniverInstanceType.UNIVER_SHEET);
2295
- if (!workbook)
2296
- throw new Error(`cannot find current workbook, unitId: ${unitId}`);
2297
- const worksheet = workbook.getSheetBySheetId(subUnitId);
2298
- if (!worksheet)
2299
- throw new Error(`cannot find current worksheet, sheetId: ${subUnitId}`);
2300
- return Promise.all(ranges.map((range) => {
2301
- const promises = [];
2302
- return Range.foreach(range, (row, col) => {
2303
- promises.push(this._validatorByCell(workbook, worksheet, row, col));
2304
- }), Promise.all(promises);
2258
+ const t = this._univerInstanceService.getUnit(s, N.UNIVER_SHEET);
2259
+ if (!t)
2260
+ throw new Error(`cannot find current workbook, unitId: ${s}`);
2261
+ const r = t.getSheetBySheetId(a);
2262
+ if (!r)
2263
+ throw new Error(`cannot find current worksheet, sheetId: ${a}`);
2264
+ return Promise.all(e.map((i) => {
2265
+ const o = [];
2266
+ return b.foreach(i, (n, l) => {
2267
+ o.push(this._validatorByCell(t, r, n, l));
2268
+ }), Promise.all(o);
2305
2269
  }));
2306
2270
  }
2307
- async validatorWorksheet(unitId, subUnitId) {
2308
- const workbook = this._univerInstanceService.getUnit(unitId, UniverInstanceType.UNIVER_SHEET);
2309
- if (!workbook)
2310
- throw new Error(`cannot find current workbook, unitId: ${unitId}`);
2311
- const worksheet = workbook.getSheetBySheetId(subUnitId);
2312
- if (!worksheet)
2313
- throw new Error(`cannot find current worksheet, sheetId: ${subUnitId}`);
2314
- const rules = this._sheetDataValidationModel.getRules(unitId, subUnitId);
2315
- return await Promise.all(rules.map((rule) => Promise.all(rule.ranges.map((range) => {
2316
- const promises = [];
2317
- return Range.foreach(range, (row, col) => {
2318
- promises.push(this._validatorByCell(workbook, worksheet, row, col));
2319
- }), promises;
2320
- })))), this._dataValidationCacheService.ensureCache(unitId, subUnitId);
2321
- }
2322
- async validatorWorkbook(unitId) {
2323
- const sheetIds = this._sheetDataValidationModel.getSubUnitIds(unitId), results = await Promise.all(sheetIds.map((id) => this.validatorWorksheet(unitId, id))), map = {};
2324
- return results.forEach((result, i) => {
2325
- map[sheetIds[i]] = result;
2326
- }), map;
2327
- }
2328
- getDataValidations(unitId, subUnitId, ranges) {
2329
- const ruleMatrix = this._sheetDataValidationModel.getRuleObjectMatrix(unitId, subUnitId), ruleIdSet = /* @__PURE__ */ new Set();
2330
- return ranges.forEach((range) => {
2331
- Range.foreach(range, (row, col) => {
2332
- const ruleId = ruleMatrix.getValue(row, col);
2333
- ruleId && ruleIdSet.add(ruleId);
2271
+ async validatorWorksheet(s, a) {
2272
+ const e = this._univerInstanceService.getUnit(s, N.UNIVER_SHEET);
2273
+ if (!e)
2274
+ throw new Error(`cannot find current workbook, unitId: ${s}`);
2275
+ const t = e.getSheetBySheetId(a);
2276
+ if (!t)
2277
+ throw new Error(`cannot find current worksheet, sheetId: ${a}`);
2278
+ const r = this._sheetDataValidationModel.getRules(s, a);
2279
+ return await Promise.all(r.map((i) => Promise.all(i.ranges.map((o) => {
2280
+ const n = [];
2281
+ return b.foreach(o, (l, u) => {
2282
+ n.push(this._validatorByCell(e, t, l, u));
2283
+ }), n;
2284
+ })))), this._dataValidationCacheService.ensureCache(s, a);
2285
+ }
2286
+ async validatorWorkbook(s) {
2287
+ const a = this._sheetDataValidationModel.getSubUnitIds(s), e = await Promise.all(a.map((r) => this.validatorWorksheet(s, r))), t = {};
2288
+ return e.forEach((r, i) => {
2289
+ t[a[i]] = r;
2290
+ }), t;
2291
+ }
2292
+ getDataValidations(s, a, e) {
2293
+ const t = this._sheetDataValidationModel.getRuleObjectMatrix(s, a), r = /* @__PURE__ */ new Set();
2294
+ return e.forEach((o) => {
2295
+ b.foreach(o, (n, l) => {
2296
+ const u = t.getValue(n, l);
2297
+ u && r.add(u);
2334
2298
  });
2335
- }), Array.from(ruleIdSet).map((id) => this._sheetDataValidationModel.getRuleById(unitId, subUnitId, id)).filter(Boolean);
2336
- }
2337
- getDataValidation(unitId, subUnitId, ranges) {
2338
- return this.getDataValidations(unitId, subUnitId, ranges)[0];
2339
- }
2340
- }, __name(_a10, "SheetsDataValidationValidatorService"), _a10);
2341
- SheetsDataValidationValidatorService = __decorateClass$1([
2342
- __decorateParam$1(0, IUniverInstanceService),
2343
- __decorateParam$1(1, Inject(SheetDataValidationModel)),
2344
- __decorateParam$1(2, Inject(DataValidationCacheService)),
2345
- __decorateParam$1(3, Inject(LifecycleService))
2346
- ], SheetsDataValidationValidatorService);
2347
- var __defProp2 = Object.defineProperty, __getOwnPropDesc = Object.getOwnPropertyDescriptor, __defNormalProp2 = /* @__PURE__ */ __name((obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value, "__defNormalProp"), __decorateClass = /* @__PURE__ */ __name((decorators, target, key, kind) => {
2348
- for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
2349
- (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
2350
- return kind && result && __defProp2(target, key, result), result;
2351
- }, "__decorateClass"), __decorateParam = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam"), __publicField2 = /* @__PURE__ */ __name((obj, key, value) => __defNormalProp2(obj, typeof key != "symbol" ? key + "" : key, value), "__publicField"), _a11;
2352
- let UniverSheetsDataValidationPlugin = (_a11 = class extends Plugin {
2353
- constructor(_config = defaultPluginConfig, _injector, _commandService, _configService) {
2354
- super(), this._config = _config, this._injector = _injector, this._commandService = _commandService, this._configService = _configService;
2355
- const { ...rest } = merge(
2299
+ }), Array.from(r).map((o) => this._sheetDataValidationModel.getRuleById(s, a, o)).filter(Boolean);
2300
+ }
2301
+ getDataValidation(s, a, e) {
2302
+ return this.getDataValidations(s, a, e)[0];
2303
+ }
2304
+ };
2305
+ Oe = ka([
2306
+ Re(0, O),
2307
+ Re(1, S(F)),
2308
+ Re(2, S(q)),
2309
+ Re(3, S(Nt))
2310
+ ], Oe);
2311
+ var _t = Object.defineProperty, Ya = Object.getOwnPropertyDescriptor, Xa = (s, a, e) => a in s ? _t(s, a, { enumerable: !0, configurable: !0, writable: !0, value: e }) : s[a] = e, Ka = (s, a, e, t) => {
2312
+ for (var r = t > 1 ? void 0 : t ? Ya(a, e) : a, i = s.length - 1, o; i >= 0; i--)
2313
+ (o = s[i]) && (r = (t ? o(a, e, r) : o(r)) || r);
2314
+ return t && r && _t(a, e, r), r;
2315
+ }, je = (s, a) => (e, t) => a(e, t, s), pt = (s, a, e) => Xa(s, typeof a != "symbol" ? a + "" : a, e);
2316
+ let we = class extends wt {
2317
+ constructor(s = tt, a, e, t) {
2318
+ super(), this._config = s, this._injector = a, this._commandService = e, this._configService = t;
2319
+ const { ...r } = It(
2356
2320
  {},
2357
- defaultPluginConfig,
2321
+ tt,
2358
2322
  this._config
2359
2323
  );
2360
- this._configService.setConfig(SHEETS_DATA_VALIDATION_PLUGIN_CONFIG_KEY, rest);
2324
+ this._configService.setConfig(Ta, r);
2361
2325
  }
2362
2326
  onStarting() {
2363
2327
  [
2364
- [DataValidationCacheService],
2365
- [DataValidationFormulaService],
2366
- [DataValidationCustomFormulaService],
2367
- [SheetsDataValidationValidatorService],
2368
- [SheetDataValidationModel],
2369
- [DataValidationController],
2370
- [DataValidationFormulaController],
2371
- [SheetDataValidationSheetController],
2372
- [DataValidationRefRangeController],
2373
- [DataValidationFormulaRefRangeController]
2374
- ].forEach((dep) => {
2375
- this._injector.add(dep);
2328
+ [q],
2329
+ [K],
2330
+ [P],
2331
+ [Oe],
2332
+ [F],
2333
+ [Ce],
2334
+ [Te],
2335
+ [Ne],
2336
+ [Fe],
2337
+ [Ee]
2338
+ ].forEach((s) => {
2339
+ this._injector.add(s);
2376
2340
  }), [
2377
- AddSheetDataValidationCommand,
2378
- UpdateSheetDataValidationRangeCommand,
2379
- UpdateSheetDataValidationSettingCommand,
2380
- UpdateSheetDataValidationOptionsCommand,
2381
- RemoveSheetDataValidationCommand,
2382
- RemoveSheetAllDataValidationCommand,
2383
- ClearRangeDataValidationCommand
2384
- ].forEach((command) => {
2385
- this._commandService.registerCommand(command);
2386
- }), this._injector.get(DataValidationCacheService), this._injector.get(SheetsDataValidationValidatorService), this._injector.get(DataValidationFormulaRefRangeController), this._injector.get(DataValidationRefRangeController);
2341
+ Ra,
2342
+ pa,
2343
+ Sa,
2344
+ va,
2345
+ Ea,
2346
+ Ma,
2347
+ Va
2348
+ ].forEach((s) => {
2349
+ this._commandService.registerCommand(s);
2350
+ }), this._injector.get(q), this._injector.get(Oe), this._injector.get(Ee), this._injector.get(Fe);
2387
2351
  }
2388
2352
  onReady() {
2389
- this._injector.get(SheetDataValidationSheetController);
2353
+ this._injector.get(Ne);
2390
2354
  }
2391
2355
  onRendered() {
2392
- this._injector.get(DataValidationController), this._injector.get(DataValidationFormulaController);
2393
- }
2394
- }, __name(_a11, "UniverSheetsDataValidationPlugin"), _a11);
2395
- __publicField2(UniverSheetsDataValidationPlugin, "pluginName", DATA_VALIDATION_PLUGIN_NAME);
2396
- __publicField2(UniverSheetsDataValidationPlugin, "type", UniverInstanceType.UNIVER_SHEET);
2397
- UniverSheetsDataValidationPlugin = __decorateClass([
2398
- DependentOn(UniverDataValidationPlugin),
2399
- __decorateParam(1, Inject(Injector)),
2400
- __decorateParam(2, ICommandService),
2401
- __decorateParam(3, IConfigService)
2402
- ], UniverSheetsDataValidationPlugin);
2403
- function createDefaultNewRule(accessor) {
2404
- const currentRanges = accessor.get(SheetsSelectionsService).getCurrentSelections().map((s) => s.range);
2356
+ this._injector.get(Ce), this._injector.get(Te);
2357
+ }
2358
+ };
2359
+ pt(we, "pluginName", Yt);
2360
+ pt(we, "type", N.UNIVER_SHEET);
2361
+ we = Ka([
2362
+ Ot(xt),
2363
+ je(1, S(Ge)),
2364
+ je(2, x),
2365
+ je(3, At)
2366
+ ], we);
2367
+ function or(s) {
2368
+ const e = s.get(nt).getCurrentSelections().map((i) => i.range);
2405
2369
  return {
2406
- uid: Tools.generateRandomId(6),
2407
- type: DataValidationType.DECIMAL,
2408
- operator: DataValidationOperator.EQUAL,
2370
+ uid: V.generateRandomId(6),
2371
+ type: T.DECIMAL,
2372
+ operator: h.EQUAL,
2409
2373
  formula1: "100",
2410
- ranges: currentRanges != null ? currentRanges : [{ startColumn: 0, endColumn: 0, startRow: 0, endRow: 0 }]
2374
+ ranges: e != null ? e : [{ startColumn: 0, endColumn: 0, startRow: 0, endRow: 0 }]
2411
2375
  };
2412
2376
  }
2413
- __name(createDefaultNewRule, "createDefaultNewRule");
2414
2377
  export {
2415
- AddSheetDataValidationCommand,
2416
- CHECKBOX_FORMULA_1,
2417
- CHECKBOX_FORMULA_2,
2418
- CheckboxValidator,
2419
- ClearRangeDataValidationCommand,
2420
- DATA_VALIDATION_PLUGIN_NAME,
2421
- DataValidationCacheService,
2422
- DataValidationCustomFormulaService,
2423
- DataValidationFormulaController,
2424
- DataValidationFormulaService,
2425
- DateValidator,
2426
- ListMultipleValidator,
2427
- ListValidator,
2428
- RemoveSheetAllDataValidationCommand,
2429
- RemoveSheetDataValidationCommand,
2430
- SheetDataValidationModel,
2431
- SheetsDataValidationValidatorService,
2432
- UniverSheetsDataValidationPlugin,
2433
- UpdateSheetDataValidationOptionsCommand,
2434
- UpdateSheetDataValidationRangeCommand,
2435
- UpdateSheetDataValidationSettingCommand,
2436
- createDefaultNewRule,
2437
- deserializeListOptions,
2438
- getCellValueOrigin,
2439
- getDataValidationCellValue,
2440
- getDataValidationDiffMutations,
2441
- getFormulaCellData,
2442
- getFormulaResult,
2443
- isLegalFormulaResult,
2444
- serializeListOptions,
2445
- transformCheckboxValue
2378
+ Ra as AddSheetDataValidationCommand,
2379
+ Ve as CHECKBOX_FORMULA_1,
2380
+ Me as CHECKBOX_FORMULA_2,
2381
+ na as CheckboxValidator,
2382
+ Va as ClearRangeDataValidationCommand,
2383
+ Yt as DATA_VALIDATION_PLUGIN_NAME,
2384
+ q as DataValidationCacheService,
2385
+ P as DataValidationCustomFormulaService,
2386
+ Te as DataValidationFormulaController,
2387
+ K as DataValidationFormulaService,
2388
+ ca as DateValidator,
2389
+ $a as ListMultipleValidator,
2390
+ mt as ListValidator,
2391
+ Ma as RemoveSheetAllDataValidationCommand,
2392
+ Ea as RemoveSheetDataValidationCommand,
2393
+ F as SheetDataValidationModel,
2394
+ Oe as SheetsDataValidationValidatorService,
2395
+ we as UniverSheetsDataValidationPlugin,
2396
+ va as UpdateSheetDataValidationOptionsCommand,
2397
+ pa as UpdateSheetDataValidationRangeCommand,
2398
+ Sa as UpdateSheetDataValidationSettingCommand,
2399
+ or as createDefaultNewRule,
2400
+ pe as deserializeListOptions,
2401
+ ne as getCellValueOrigin,
2402
+ sr as getDataValidationCellValue,
2403
+ be as getDataValidationDiffMutations,
2404
+ ge as getFormulaCellData,
2405
+ se as getFormulaResult,
2406
+ C as isLegalFormulaResult,
2407
+ ir as serializeListOptions,
2408
+ _e as transformCheckboxValue
2446
2409
  };