chunk-757T4GCY.js 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742
  1. import {
  2. BehaviorSubject,
  3. Bi,
  4. El,
  5. Fe,
  6. Mt,
  7. Ot,
  8. Pt,
  9. Ra,
  10. SE,
  11. Subject,
  12. Vr,
  13. Ze,
  14. _n,
  15. ar,
  16. cn,
  17. debounceTime,
  18. nt,
  19. nu,
  20. ot,
  21. re
  22. } from "./chunk-23V3HWTR.js";
  23. // node_modules/.pnpm/@univerjs+data-validation@0.5.5_@grpc+grpc-js@1.13.4_react@18.3.1_rxjs@7.8.1/node_modules/@univerjs/data-validation/lib/es/index.js
  24. var J = Object.defineProperty;
  25. var z = (t, e, r) => e in t ? J(t, e, { enumerable: true, configurable: true, writable: true, value: r }) : t[e] = r;
  26. var c = (t, e, r) => z(t, typeof e != "symbol" ? e + "" : e, r);
  27. function q(t) {
  28. return {
  29. type: t.type,
  30. operator: t.operator,
  31. formula1: t.formula1,
  32. formula2: t.formula2,
  33. allowBlank: t.allowBlank
  34. };
  35. }
  36. function H(t) {
  37. return {
  38. error: t.error,
  39. errorStyle: t.errorStyle,
  40. errorTitle: t.errorTitle,
  41. imeMode: t.imeMode,
  42. prompt: t.prompt,
  43. promptTitle: t.promptTitle,
  44. showDropDown: t.showDropDown,
  45. showErrorMessage: t.showErrorMessage,
  46. showInputMessage: t.showInputMessage,
  47. renderMode: t.renderMode,
  48. bizInfo: t.bizInfo
  49. };
  50. }
  51. var h = ((t) => (t[t.SETTING = 0] = "SETTING", t[t.RANGE = 1] = "RANGE", t[t.OPTIONS = 2] = "OPTIONS", t[t.ALL = 3] = "ALL", t))(h || {});
  52. var ne = Object.defineProperty;
  53. var ie = Object.getOwnPropertyDescriptor;
  54. var se = (t, e, r, a) => {
  55. for (var o = a > 1 ? void 0 : a ? ie(e, r) : e, n = t.length - 1, i; n >= 0; n--)
  56. (i = t[n]) && (o = (a ? i(e, r, o) : i(o)) || o);
  57. return a && o && ne(e, r, o), o;
  58. };
  59. var de = (t, e) => (r, a) => e(r, a, t);
  60. var m = class extends nt {
  61. constructor(e) {
  62. super();
  63. c(this, "_model", /* @__PURE__ */ new Map());
  64. c(this, "_ruleChange$", new Subject());
  65. c(this, "ruleChange$", this._ruleChange$.asObservable());
  66. c(this, "ruleChangeDebounce$", this.ruleChange$.pipe(debounceTime(20)));
  67. this._logService = e, this.disposeWithMe({
  68. dispose: () => {
  69. this._ruleChange$.complete();
  70. }
  71. });
  72. }
  73. _ensureMap(e, r) {
  74. this._model.has(e) || this._model.set(e, /* @__PURE__ */ new Map());
  75. const a = this._model.get(e);
  76. if (a.has(r))
  77. return a.get(r);
  78. const o = { map: /* @__PURE__ */ new Map(), list: [] };
  79. return a.set(r, o), o;
  80. }
  81. _addSubUnitRule(e, r, a) {
  82. const { map: o, list: n } = e, l = (Array.isArray(r) ? r : [r]).filter((d) => !o.has(d.uid));
  83. typeof a == "number" && a < n.length ? n.splice(a, 0, ...l) : n.push(...l), l.forEach((d) => {
  84. o.set(d.uid, d);
  85. });
  86. }
  87. _removeSubUnitRule(e, r) {
  88. const { map: a, list: o } = e, n = o.findIndex((i) => i.uid === r);
  89. n > -1 && (o.splice(n, 1), a.delete(r));
  90. }
  91. _updateSubUnitRule(e, r, a) {
  92. const { map: o, list: n } = e, i = o.get(r), l = n.findIndex((u) => r === u.uid);
  93. if (!i)
  94. throw new Error(`Data validation rule is not found, ruleId: ${r}.`);
  95. const d = { ...i };
  96. switch (a.type) {
  97. case h.RANGE: {
  98. d.ranges = a.payload;
  99. break;
  100. }
  101. case h.SETTING: {
  102. Object.assign(d, q(a.payload));
  103. break;
  104. }
  105. case h.OPTIONS: {
  106. Object.assign(d, H(a.payload));
  107. break;
  108. }
  109. case h.ALL: {
  110. Object.assign(d, a.payload);
  111. break;
  112. }
  113. }
  114. return n[l] = d, o.set(r, d), d;
  115. }
  116. _addRuleSideEffect(e, r, a, o) {
  117. if (!this._ensureMap(e, r).map.get(a.uid))
  118. return {
  119. rule: a,
  120. type: "add",
  121. unitId: e,
  122. subUnitId: r,
  123. source: o
  124. };
  125. }
  126. addRule(e, r, a, o, n) {
  127. try {
  128. const i = this._ensureMap(e, r), d = (Array.isArray(a) ? a : [a]).map((u) => this._addRuleSideEffect(e, r, u, o));
  129. this._addSubUnitRule(i, a, n), d.forEach((u) => {
  130. u && this._ruleChange$.next(u);
  131. });
  132. } catch (i) {
  133. this._logService.error(i);
  134. }
  135. }
  136. updateRule(e, r, a, o, n) {
  137. try {
  138. const i = this._ensureMap(e, r), l = re.deepClone(i.map.get(a));
  139. if (!l)
  140. throw new Error(`Data validation rule is not found, ruleId: ${a}.`);
  141. const d = this._updateSubUnitRule(i, a, o);
  142. this._ruleChange$.next({
  143. rule: d,
  144. type: "update",
  145. unitId: e,
  146. subUnitId: r,
  147. source: n,
  148. updatePayload: o,
  149. oldRule: l
  150. });
  151. } catch (i) {
  152. this._logService.error(i);
  153. }
  154. }
  155. removeRule(e, r, a, o) {
  156. try {
  157. const n = this._ensureMap(e, r), i = n.map.get(a);
  158. i && (this._removeSubUnitRule(n, a), this._ruleChange$.next({
  159. rule: i,
  160. type: "remove",
  161. unitId: e,
  162. subUnitId: r,
  163. source: o
  164. }));
  165. } catch (n) {
  166. this._logService.error(n);
  167. }
  168. }
  169. getRuleById(e, r, a) {
  170. return this._ensureMap(e, r).map.get(a);
  171. }
  172. getRuleIndex(e, r, a) {
  173. return this._ensureMap(e, r).list.findIndex((n) => n.uid === a);
  174. }
  175. getRules(e, r) {
  176. return [...this._ensureMap(e, r).list];
  177. }
  178. getUnitRules(e) {
  179. const r = this._model.get(e);
  180. if (!r)
  181. return [];
  182. const a = [];
  183. return r.forEach((o, n) => {
  184. a.push([n, o.list]);
  185. }), a;
  186. }
  187. deleteUnitRules(e) {
  188. this._model.delete(e);
  189. }
  190. getSubUnitIds(e) {
  191. var r, a;
  192. return Array.from((a = (r = this._model.get(e)) == null ? void 0 : r.keys()) != null ? a : []);
  193. }
  194. getAll() {
  195. return Array.from(this._model.keys()).map((e) => [e, this.getUnitRules(e)]);
  196. }
  197. };
  198. m = se([
  199. de(0, Mt)
  200. ], m);
  201. var le = Object.defineProperty;
  202. var ue = Object.getOwnPropertyDescriptor;
  203. var ce = (t, e, r, a) => {
  204. for (var o = a > 1 ? void 0 : a ? ue(e, r) : e, n = t.length - 1, i; n >= 0; n--)
  205. (i = t[n]) && (o = (a ? i(e, r, o) : i(o)) || o);
  206. return a && o && le(e, r, o), o;
  207. };
  208. var y = (t, e) => (r, a) => e(r, a, t);
  209. var pe = "SHEET_DATA_VALIDATION_PLUGIN";
  210. var I = class extends nt {
  211. constructor(t, e, r) {
  212. super(), this._resourceManagerService = t, this._univerInstanceService = e, this._dataValidationModel = r, this._initSnapshot();
  213. }
  214. _initSnapshot() {
  215. const t = (r) => {
  216. const a = this._dataValidationModel.getUnitRules(r), o = {};
  217. return a ? (a.forEach(([n, i]) => {
  218. o[n] = i;
  219. }), JSON.stringify(o)) : "";
  220. }, e = (r) => {
  221. if (!r)
  222. return {};
  223. try {
  224. return JSON.parse(r);
  225. } catch {
  226. return {};
  227. }
  228. };
  229. this.disposeWithMe(
  230. this._resourceManagerService.registerPluginResource({
  231. pluginName: pe,
  232. businesses: [Fe.UNIVER_SHEET],
  233. toJson: (r) => t(r),
  234. parseJson: (r) => e(r),
  235. onUnLoad: (r) => {
  236. this._dataValidationModel.deleteUnitRules(r);
  237. },
  238. onLoad: (r, a) => {
  239. Object.keys(a).forEach((o) => {
  240. a[o].forEach((i) => {
  241. this._dataValidationModel.addRule(r, o, i, "patched");
  242. });
  243. });
  244. }
  245. })
  246. );
  247. }
  248. };
  249. I = ce([
  250. y(0, Bi),
  251. y(1, _n),
  252. y(2, ot(m))
  253. ], I);
  254. var me = ((t) => (t.SHEET = "sheet", t))(me || {});
  255. var j = class {
  256. constructor() {
  257. c(this, "_validatorByScopes", /* @__PURE__ */ new Map());
  258. c(this, "_validatorMap", /* @__PURE__ */ new Map());
  259. c(this, "_validatorsChange$", new BehaviorSubject(void 0));
  260. c(this, "validatorsChange$", this._validatorsChange$.asObservable());
  261. }
  262. _addValidatorToScope(e, r) {
  263. this._validatorByScopes.has(r) || this._validatorByScopes.set(r, []);
  264. const a = this._validatorByScopes.get(r);
  265. if (a.findIndex((o) => o.id === e.id) > -1)
  266. throw new Error(`Validator item with the same id ${e.id} has already been added!`);
  267. a.push(e);
  268. }
  269. _removeValidatorFromScope(e, r) {
  270. const a = this._validatorByScopes.get(r);
  271. if (!a)
  272. return;
  273. const o = a.findIndex((n) => n.id === e.id);
  274. o > -1 && a.splice(o, 1);
  275. }
  276. register(e) {
  277. return this._validatorMap.set(e.id, e), Array.isArray(e.scopes) ? e.scopes.forEach((r) => {
  278. this._addValidatorToScope(e, r);
  279. }) : this._addValidatorToScope(e, e.scopes), this._validatorsChange$.next(), Ze(() => {
  280. this._validatorMap.delete(e.id), Array.isArray(e.scopes) ? e.scopes.forEach((r) => {
  281. this._removeValidatorFromScope(e, r);
  282. }) : this._removeValidatorFromScope(e, e.scopes), this._validatorsChange$.next();
  283. });
  284. }
  285. getValidatorItem(e) {
  286. return this._validatorMap.get(e);
  287. }
  288. getValidatorsByScope(e) {
  289. return this._validatorByScopes.get(e);
  290. }
  291. };
  292. var S = {
  293. type: ar.MUTATION,
  294. id: "data-validation.mutation.addRule",
  295. handler(t, e) {
  296. if (!e)
  297. return false;
  298. const { unitId: r, subUnitId: a, rule: o, index: n, source: i = "command" } = e;
  299. return t.get(m).addRule(r, a, o, i, n), true;
  300. }
  301. };
  302. var v = {
  303. type: ar.MUTATION,
  304. id: "data-validation.mutation.removeRule",
  305. handler(t, e) {
  306. if (!e)
  307. return false;
  308. const { unitId: r, subUnitId: a, ruleId: o, source: n = "command" } = e, i = t.get(m);
  309. return Array.isArray(o) ? o.forEach((l) => {
  310. i.removeRule(r, a, l, n);
  311. }) : i.removeRule(r, a, o, n), true;
  312. }
  313. };
  314. var f = {
  315. type: ar.MUTATION,
  316. id: "data-validation.mutation.updateRule",
  317. handler(t, e) {
  318. if (!e)
  319. return false;
  320. const { unitId: r, subUnitId: a, ruleId: o, payload: n, source: i = "command" } = e;
  321. return t.get(m).updateRule(r, a, o, n, i), true;
  322. }
  323. };
  324. var he = {
  325. type: ar.COMMAND,
  326. id: "data-validation.command.addRule",
  327. async handler(t, e) {
  328. if (t.get(Mt).error("[Deprecated]: `AddDataValidationCommand` is deprecated, please use `AddSheetDataValidationCommand` in `@univerjs/sheets-data-validation` instead!"), !e)
  329. return false;
  330. const { rule: a, unitId: o, subUnitId: n } = e, i = t.get(Pt), l = t.get(cn), d = {
  331. ...e,
  332. rule: {
  333. ...e.rule,
  334. ranges: [e.rule.range]
  335. }
  336. }, u = [{
  337. id: S.id,
  338. params: d
  339. }], p = [{
  340. id: v.id,
  341. params: {
  342. unitId: o,
  343. subUnitId: n,
  344. ruleId: a.uid
  345. }
  346. }];
  347. return l.pushUndoRedo({
  348. unitID: o,
  349. redoMutations: u,
  350. undoMutations: p
  351. }), await i.executeCommand(S.id, d), true;
  352. }
  353. };
  354. var _e = {
  355. type: ar.COMMAND,
  356. id: "data-validation.command.removeRule",
  357. handler(t, e) {
  358. if (t.get(Mt).error("[Deprecated]: `RemoveDataValidationCommand` is deprecated, please use `RemoveSheetDataValidationCommand` in `@univerjs/sheets-data-validation` instead!"), !e)
  359. return false;
  360. const { unitId: a, subUnitId: o, ruleId: n } = e, i = t.get(Pt), l = t.get(cn), d = t.get(m), u = [{
  361. id: v.id,
  362. params: e
  363. }], p = [{
  364. id: S.id,
  365. params: {
  366. unitId: a,
  367. subUnitId: o,
  368. rule: {
  369. ...d.getRuleById(a, o, n)
  370. },
  371. index: d.getRuleIndex(a, o, n)
  372. }
  373. }];
  374. return l.pushUndoRedo({
  375. undoMutations: p,
  376. redoMutations: u,
  377. unitID: e.unitId
  378. }), i.executeCommand(v.id, e), true;
  379. }
  380. };
  381. var Ee = {
  382. type: ar.COMMAND,
  383. id: "data-validation.command.updateDataValidationSetting",
  384. handler(t, e) {
  385. if (t.get(Mt).warn("[Deprecated]: `UpdateDataValidationOptionsCommand` is deprecated, please use `UpdateSheetDataValidationOptionsCommand` in `@univerjs/sheets-data-validation` instead!"), !e)
  386. return false;
  387. const a = t.get(Pt), o = t.get(cn), n = t.get(m), { unitId: i, subUnitId: l, ruleId: d, options: u } = e, p = n.getRuleById(i, l, d);
  388. if (!p)
  389. return false;
  390. const _ = {
  391. unitId: i,
  392. subUnitId: l,
  393. ruleId: d,
  394. payload: {
  395. type: h.OPTIONS,
  396. payload: u
  397. }
  398. }, g = [{
  399. id: f.id,
  400. params: _
  401. }], M = {
  402. unitId: i,
  403. subUnitId: l,
  404. ruleId: d,
  405. payload: {
  406. type: h.OPTIONS,
  407. payload: H(p)
  408. }
  409. }, R = [{
  410. id: f.id,
  411. params: M
  412. }];
  413. return o.pushUndoRedo({
  414. unitID: i,
  415. redoMutations: g,
  416. undoMutations: R
  417. }), a.executeCommand(f.id, _), true;
  418. }
  419. };
  420. var ge = {
  421. type: ar.COMMAND,
  422. id: "data-validation.command.updateDataValidationOptions",
  423. handler(t, e) {
  424. if (t.get(Mt).error("[Deprecated]: `UpdateDataValidationSettingCommand` is deprecated, please use `UpdateSheetDataValidationSettingCommand` in `@univerjs/sheets-data-validation` instead!"), !e)
  425. return false;
  426. const a = t.get(Pt), o = t.get(cn), n = t.get(m), i = t.get(j), { unitId: l, subUnitId: d, ruleId: u, setting: p } = e, _ = i.getValidatorItem(p.type);
  427. if (!_)
  428. return false;
  429. const g = n.getRuleById(l, d, u);
  430. if (!g)
  431. return false;
  432. const M = { ...g, ...p };
  433. if (!_.validatorFormula(M, l, d).success)
  434. return false;
  435. const R = {
  436. unitId: l,
  437. subUnitId: d,
  438. ruleId: u,
  439. payload: {
  440. type: h.SETTING,
  441. payload: {
  442. ...p,
  443. ..._.normalizeFormula(M, l, d)
  444. }
  445. }
  446. }, Q = [{
  447. id: f.id,
  448. params: R
  449. }], F = {
  450. unitId: l,
  451. subUnitId: d,
  452. ruleId: u,
  453. payload: {
  454. type: h.SETTING,
  455. payload: q(g)
  456. }
  457. }, W = [{
  458. id: f.id,
  459. params: F
  460. }];
  461. return o.pushUndoRedo({
  462. unitID: l,
  463. redoMutations: Q,
  464. undoMutations: W
  465. }), a.executeCommand(f.id, R), true;
  466. }
  467. };
  468. var fe = {
  469. type: ar.COMMAND,
  470. id: "data-validation.command.removeAll",
  471. handler(t, e) {
  472. if (t.get(Mt).error("[Deprecated]: `RemoveAllDataValidationCommand` is deprecated, please use `RemoveSheetAllDataValidationCommand` in `@univerjs/sheets-data-validation` instead!"), !e)
  473. return false;
  474. const { unitId: a, subUnitId: o } = e, n = t.get(Pt), i = t.get(m), l = t.get(cn), d = [...i.getRules(a, o)], u = {
  475. unitId: a,
  476. subUnitId: o,
  477. ruleId: d.map((g) => g.uid)
  478. }, p = [{
  479. id: v.id,
  480. params: u
  481. }], _ = [{
  482. id: S.id,
  483. params: {
  484. unitId: a,
  485. subUnitId: o,
  486. rule: d
  487. }
  488. }];
  489. return l.pushUndoRedo({
  490. redoMutations: p,
  491. undoMutations: _,
  492. unitID: a
  493. }), n.executeCommand(v.id, u), true;
  494. }
  495. };
  496. var ve = "data-validation.config";
  497. var U = {};
  498. var Ne = Object.defineProperty;
  499. var Te = Object.getOwnPropertyDescriptor;
  500. var Se = (t, e, r, a) => {
  501. for (var o = a > 1 ? void 0 : a ? Te(e, r) : e, n = t.length - 1, i; n >= 0; n--)
  502. (i = t[n]) && (o = (a ? i(e, r, o) : i(o)) || o);
  503. return a && o && Ne(e, r, o), o;
  504. };
  505. var L = (t, e) => (r, a) => e(r, a, t);
  506. var Ae = "UNIVER_DATA_VALIDATION_PLUGIN";
  507. var V;
  508. var D = (V = class extends Ra {
  509. constructor(t = U, e, r, a) {
  510. super(), this._config = t, this._injector = e, this._commandService = r, this._configService = a;
  511. const { ...o } = nu(
  512. {},
  513. U,
  514. this._config
  515. );
  516. this._configService.setConfig(ve, o);
  517. }
  518. onStarting() {
  519. [
  520. [m],
  521. [j],
  522. [I]
  523. ].forEach((t) => this._injector.add(t)), [
  524. // command
  525. he,
  526. fe,
  527. Ee,
  528. ge,
  529. _e,
  530. // mutation
  531. S,
  532. f,
  533. v
  534. ].forEach((t) => {
  535. this._commandService.registerCommand(t);
  536. });
  537. }
  538. onReady() {
  539. this._injector.get(I);
  540. }
  541. }, c(V, "pluginName", Ae), c(V, "type", Fe.UNIVER_SHEET), V);
  542. D = Se([
  543. L(1, ot(Ot)),
  544. L(2, Pt),
  545. L(3, SE)
  546. ], D);
  547. El.BETWEEN + "", El.EQUAL + "", El.GREATER_THAN + "", El.GREATER_THAN_OR_EQUAL + "", El.LESS_THAN + "", El.LESS_THAN_OR_EQUAL + "", El.NOT_BETWEEN + "", El.NOT_EQUAL + "";
  548. var Me = {
  549. [El.BETWEEN]: "dataValidation.ruleName.between",
  550. [El.EQUAL]: "dataValidation.ruleName.equal",
  551. [El.GREATER_THAN]: "dataValidation.ruleName.greaterThan",
  552. [El.GREATER_THAN_OR_EQUAL]: "dataValidation.ruleName.greaterThanOrEqual",
  553. [El.LESS_THAN]: "dataValidation.ruleName.lessThan",
  554. [El.LESS_THAN_OR_EQUAL]: "dataValidation.ruleName.lessThanOrEqual",
  555. [El.NOT_BETWEEN]: "dataValidation.ruleName.notBetween",
  556. [El.NOT_EQUAL]: "dataValidation.ruleName.notEqual"
  557. };
  558. var Re = {
  559. [El.BETWEEN]: "dataValidation.errorMsg.between",
  560. [El.EQUAL]: "dataValidation.errorMsg.equal",
  561. [El.GREATER_THAN]: "dataValidation.errorMsg.greaterThan",
  562. [El.GREATER_THAN_OR_EQUAL]: "dataValidation.errorMsg.greaterThanOrEqual",
  563. [El.LESS_THAN]: "dataValidation.errorMsg.lessThan",
  564. [El.LESS_THAN_OR_EQUAL]: "dataValidation.errorMsg.lessThanOrEqual",
  565. [El.NOT_BETWEEN]: "dataValidation.errorMsg.notBetween",
  566. [El.NOT_EQUAL]: "dataValidation.errorMsg.notEqual"
  567. };
  568. var we = {
  569. [El.BETWEEN]: "dataValidation.textLength.errorMsg.between",
  570. [El.EQUAL]: "dataValidation.textLength.errorMsg.equal",
  571. [El.GREATER_THAN]: "dataValidation.textLength.errorMsg.greaterThan",
  572. [El.GREATER_THAN_OR_EQUAL]: "dataValidation.textLength.errorMsg.greaterThanOrEqual",
  573. [El.LESS_THAN]: "dataValidation.textLength.errorMsg.lessThan",
  574. [El.LESS_THAN_OR_EQUAL]: "dataValidation.textLength.errorMsg.lessThanOrEqual",
  575. [El.NOT_BETWEEN]: "dataValidation.textLength.errorMsg.notBetween",
  576. [El.NOT_EQUAL]: "dataValidation.textLength.errorMsg.notEqual"
  577. };
  578. var be = [
  579. El.BETWEEN,
  580. El.NOT_BETWEEN
  581. ];
  582. var Ve = Object.defineProperty;
  583. var Oe = Object.getOwnPropertyDescriptor;
  584. var Ie = (t, e, r, a) => {
  585. for (var o = a > 1 ? void 0 : a ? Oe(e, r) : e, n = t.length - 1, i; n >= 0; n--)
  586. (i = t[n]) && (o = (a ? i(e, r, o) : i(o)) || o);
  587. return a && o && Ve(e, r, o), o;
  588. };
  589. var w = (t, e) => (r, a) => e(r, a, t);
  590. var b = "{FORMULA1}";
  591. var C = "{FORMULA2}";
  592. var ye = {
  593. [El.BETWEEN]: "dataValidation.operators.between",
  594. [El.EQUAL]: "dataValidation.operators.equal",
  595. [El.GREATER_THAN]: "dataValidation.operators.greaterThan",
  596. [El.GREATER_THAN_OR_EQUAL]: "dataValidation.operators.greaterThanOrEqual",
  597. [El.LESS_THAN]: "dataValidation.operators.lessThan",
  598. [El.LESS_THAN_OR_EQUAL]: "dataValidation.operators.lessThanOrEqual",
  599. [El.NOT_BETWEEN]: "dataValidation.operators.notBetween",
  600. [El.NOT_EQUAL]: "dataValidation.operators.notEqual"
  601. };
  602. var P = class {
  603. // #endregion
  604. constructor(t, e) {
  605. c(this, "offsetFormulaByRange", true);
  606. c(this, "formulaInput");
  607. c(this, "canvasRender", null);
  608. c(this, "dropdown");
  609. c(this, "optionsInput");
  610. c(this, "skipDefaultFontRender");
  611. this.localeService = t, this.injector = e;
  612. }
  613. get operatorNames() {
  614. return this.operators.map((t) => this.localeService.t(ye[t]));
  615. }
  616. get titleStr() {
  617. return this.localeService.t(this.title);
  618. }
  619. generateRuleName(t) {
  620. var r, a;
  621. if (!t.operator)
  622. return this.titleStr;
  623. const e = this.localeService.t(Me[t.operator]).replace(b, (r = t.formula1) != null ? r : "").replace(C, (a = t.formula2) != null ? a : "");
  624. return `${this.titleStr} ${e}`;
  625. }
  626. generateRuleErrorMessage(t, e) {
  627. var a, o;
  628. return t.operator ? `${this.localeService.t(Re[t.operator]).replace(b, (a = t.formula1) != null ? a : "").replace(C, (o = t.formula2) != null ? o : "")}` : this.titleStr;
  629. }
  630. getExtraStyle(t, e, r, a, o) {
  631. }
  632. getRuleFinalError(t, e) {
  633. return t.showErrorMessage && t.error ? t.error : this.generateRuleErrorMessage(t, e);
  634. }
  635. isEmptyCellValue(t) {
  636. return t === "" || t === void 0 || t === null;
  637. }
  638. normalizeFormula(t, e, r) {
  639. return {
  640. formula1: t.formula1,
  641. formula2: t.formula2
  642. };
  643. }
  644. async isValidType(t, e, r) {
  645. return true;
  646. }
  647. transform(t, e, r) {
  648. return t;
  649. }
  650. async validatorIsEqual(t, e, r) {
  651. const { formula1: a } = e, { value: o } = t;
  652. return Number.isNaN(a) ? true : o === a;
  653. }
  654. async validatorIsNotEqual(t, e, r) {
  655. const { formula1: a } = e;
  656. return Number.isNaN(a) ? true : t.value !== a;
  657. }
  658. async validatorIsBetween(t, e, r) {
  659. const { formula1: a, formula2: o } = e;
  660. if (Number.isNaN(a) || Number.isNaN(o))
  661. return true;
  662. const n = Math.min(a, o), i = Math.max(a, o);
  663. return t.value >= n && t.value <= i;
  664. }
  665. async validatorIsNotBetween(t, e, r) {
  666. const { formula1: a, formula2: o } = e;
  667. if (Number.isNaN(a) || Number.isNaN(o))
  668. return true;
  669. const n = Math.min(a, o), i = Math.max(a, o);
  670. return t.value < n || t.value > i;
  671. }
  672. async validatorIsGreaterThan(t, e, r) {
  673. const { formula1: a } = e;
  674. return Number.isNaN(a) ? true : t.value > a;
  675. }
  676. async validatorIsGreaterThanOrEqual(t, e, r) {
  677. const { formula1: a } = e;
  678. return Number.isNaN(a) ? true : t.value >= a;
  679. }
  680. async validatorIsLessThan(t, e, r) {
  681. const { formula1: a } = e;
  682. return Number.isNaN(a) ? true : t.value < a;
  683. }
  684. async validatorIsLessThanOrEqual(t, e, r) {
  685. const { formula1: a } = e;
  686. return Number.isNaN(a) ? true : t.value <= a;
  687. }
  688. async validator(t, e) {
  689. const { value: r, unitId: a, subUnitId: o } = t, n = this.isEmptyCellValue(r), { allowBlank: i = true, operator: l } = e;
  690. if (n)
  691. return i;
  692. const d = await this.parseFormula(e, a, o, t.row, t.column);
  693. if (!d.isFormulaValid || !await this.isValidType(t, d, e))
  694. return false;
  695. if (!re.isDefine(l))
  696. return true;
  697. const u = this.transform(t, d, e);
  698. switch (l) {
  699. case El.BETWEEN:
  700. return this.validatorIsBetween(u, d, e);
  701. case El.EQUAL:
  702. return this.validatorIsEqual(u, d, e);
  703. case El.GREATER_THAN:
  704. return this.validatorIsGreaterThan(u, d, e);
  705. case El.GREATER_THAN_OR_EQUAL:
  706. return this.validatorIsGreaterThanOrEqual(u, d, e);
  707. case El.LESS_THAN:
  708. return this.validatorIsLessThan(u, d, e);
  709. case El.LESS_THAN_OR_EQUAL:
  710. return this.validatorIsLessThanOrEqual(u, d, e);
  711. case El.NOT_BETWEEN:
  712. return this.validatorIsNotBetween(u, d, e);
  713. case El.NOT_EQUAL:
  714. return this.validatorIsNotEqual(u, d, e);
  715. default:
  716. throw new Error("Unknown operator.");
  717. }
  718. }
  719. };
  720. P = Ie([
  721. w(0, ot(Vr)),
  722. w(1, ot(Ot))
  723. ], P);
  724. export {
  725. q,
  726. H,
  727. h,
  728. m,
  729. I,
  730. me,
  731. j,
  732. S,
  733. v,
  734. f,
  735. D,
  736. we,
  737. be,
  738. P
  739. };
  740. //# sourceMappingURL=chunk-757T4GCY.js.map