@univerjs/sheets-data-validation 0.4.1 → 0.4.2-nightly.202410301606
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/dv-validator-service-9VDfOza1.mjs +2032 -0
- package/lib/es/facade.js +654 -0
- package/lib/es/index.js +163 -2077
- package/lib/types/facade/f-data-validation-builder.d.ts +247 -0
- package/lib/types/facade/f-data-validation.d.ts +88 -0
- package/lib/types/facade/f-range.d.ts +33 -0
- package/lib/types/facade/f-univer.d.ts +6 -0
- package/lib/types/facade/f-workbook.d.ts +66 -0
- package/lib/types/facade/f-worksheet.d.ts +20 -0
- package/lib/types/facade/index.d.ts +2 -0
- package/lib/types/index.d.ts +1 -0
- package/lib/types/models/rule-matrix.d.ts +1 -0
- package/lib/types/utils/formula.d.ts +1 -0
- package/lib/types/validators/any-validator.d.ts +12 -0
- package/lib/types/validators/custom-validator.d.ts +1 -0
- package/lib/types/validators/decimal-validator.d.ts +1 -0
- package/lib/types/validators/whole-validator.d.ts +1 -0
- package/lib/umd/facade.js +1 -0
- package/lib/umd/index.js +1 -1
- package/package.json +14 -18
- package/LICENSE +0 -176
- package/lib/cjs/index.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(function(k,F){typeof exports=="object"&&typeof module<"u"?F(exports,require("@univerjs/sheets/facade"),require("@univerjs/core"),require("@univerjs/data-validation"),require("@univerjs/engine-formula"),require("@univerjs/sheets"),require("rxjs"),require("@univerjs/sheets-formula")):typeof define=="function"&&define.amd?define(["exports","@univerjs/sheets/facade","@univerjs/core","@univerjs/data-validation","@univerjs/engine-formula","@univerjs/sheets","rxjs","@univerjs/sheets-formula"],F):(k=typeof globalThis<"u"?globalThis:k||self,F(k.UniverSheetsDataValidationFacade={},k["UniverSheets/facade"],k.UniverCore,k.UniverDataValidation,k.UniverEngineFormula,k.UniverSheets,k.rxjs,k.UniverSheetsFormula))})(this,function(k,F,r,R,_t,G,K,Mt){"use strict";var ne=Object.defineProperty;var se=(k,F,r)=>F in k?ne(k,F,{enumerable:!0,configurable:!0,writable:!0,value:r}):k[F]=r;var $=(k,F,r)=>se(k,typeof F!="symbol"?F+"":F,r);var kt=Object.defineProperty,At=Object.getOwnPropertyDescriptor,Ft=(o,t,e,a)=>{for(var i=a>1?void 0:a?At(t,e):t,n=o.length-1,s;n>=0;n--)(s=o[n])&&(i=(a?s(t,e,i):s(i))||i);return a&&i&&kt(t,e,i),i},Ut=(o,t)=>(e,a)=>t(e,a,o);let it=class extends r.Disposable{constructor(t){super();$(this,"_cacheMatrix",new Map);$(this,"_dirtyRanges$",new K.Subject);$(this,"dirtyRanges$",this._dirtyRanges$.asObservable());this._commandService=t,this._initDirtyRanges()}_initDirtyRanges(){this.disposeWithMe(this._commandService.onCommandExecuted(t=>{if(t.id===G.SetRangeValuesMutation.id){const{cellValue:e,unitId:a,subUnitId:i}=t.params;if(e){const n=new r.ObjectMatrix(e).getDataRange();if(n.endRow===-1)return;this._dirtyRanges$.next({unitId:a,subUnitId:i,ranges:[n]})}}}))}_ensureCache(t,e){let a=this._cacheMatrix.get(t);a||(a=new Map,this._cacheMatrix.set(t,a));let i=a.get(e);return i||(i=new r.ObjectMatrix,a.set(e,i)),i}ensureCache(t,e){return this._ensureCache(t,e)}addRule(t,e,a){this.markRangeDirty(t,e,a.ranges)}removeRule(t,e,a){this._deleteRange(t,e,a.ranges)}updateRuleRanges(t,e,a,i,n){const s=this._ensureCache(t,e);n.forEach(l=>{r.Range.foreach(l,(u,h)=>{const p=s.getValue(u,h);p&&(p.temp=!0)})}),i.forEach(l=>{r.Range.foreach(l,(u,h)=>{const p=s.getValue(u,h);p&&p.ruleId===a?p.temp=!1:s.setValue(u,h,void 0)})}),n.forEach(l=>{r.Range.foreach(l,(u,h)=>{const p=s.getValue(u,h);p&&p.temp===!0&&s.realDeleteValue(u,h)})}),this._dirtyRanges$.next({unitId:t,subUnitId:e,ranges:[...n,...i]})}markRangeDirty(t,e,a){const i=this._ensureCache(t,e);a.forEach(n=>{r.Range.foreach(n,(s,l)=>{i.setValue(s,l,void 0)})}),this._dirtyRanges$.next({unitId:t,subUnitId:e,ranges:a})}markCellDirty(t,e,a,i){this._ensureCache(t,e).setValue(a,i,void 0),this._dirtyRanges$.next({unitId:t,subUnitId:e,ranges:[{startRow:a,startColumn:i,endRow:a,endColumn:i}]})}_deleteRange(t,e,a){const i=this._ensureCache(t,e);a.forEach(n=>{r.Range.foreach(n,(s,l)=>{i.realDeleteValue(s,l)})}),this._dirtyRanges$.next({unitId:t,subUnitId:e,ranges:a})}getValue(t,e,a,i){return this._ensureCache(t,e).getValue(a,i)}setValue(t,e,a,i,n){return this._ensureCache(t,e).setValue(a,i,n)}};it=Ft([Ut(0,r.Inject(r.ICommandService))],it);var Nt=Object.defineProperty,Lt=Object.getOwnPropertyDescriptor,Bt=(o,t,e,a)=>{for(var i=a>1?void 0:a?Lt(t,e):t,n=o.length-1,s;n>=0;n--)(s=o[n])&&(i=(a?s(t,e,i):s(i))||i);return a&&i&&Nt(t,e,i),i},rt=(o,t)=>(e,a)=>t(e,a,o);function Vt(o,t,e,a,i,n){return o.moveFormulaRefOffset(t,n-a,i-e)}let gt=class extends r.Disposable{constructor(t,e,a,i,n,s){super();$(this,"_formulaMap",new Map);$(this,"_ruleFormulaMap",new Map);$(this,"_formulaCellMap",new Map);this._instanceSrv=t,this._registerOtherFormulaService=e,this._lexerTreeBuilder=a,this._dataValidationModel=i,this._dataValidationCacheService=n,this._injector=s,this._initFormulaResultHandler()}_initFormulaResultHandler(){this.disposeWithMe(this._registerOtherFormulaService.formulaResult$.subscribe(t=>{for(const e in t){const a=t[e];if(this._instanceSrv.getUnitType(e)===r.UniverInstanceType.UNIVER_SHEET)for(const n in a){const s=a[n],{formulaCellMap:l,ruleFormulaMap:u}=this._ensureMaps(e,n);s.forEach(h=>{var M,O;const p=u.get((M=h.extra)==null?void 0:M.ruleId),_=l.get(h.formulaId),V=this._dataValidationModel.getRuleById(e,n,(O=h.extra)==null?void 0:O.ruleId);V&&p&&!p.isTransformable&&this._dataValidationCacheService.markRangeDirty(e,n,V.ranges),_&&this._dataValidationCacheService.markCellDirty(e,n,_.row,_.column)})}}}))}_ensureMaps(t,e){let a=this._formulaMap.get(t),i=this._ruleFormulaMap.get(t),n=this._formulaCellMap.get(t);(!a||!i||!n)&&(a=new Map,i=new Map,n=new Map,this._formulaMap.set(t,a),this._ruleFormulaMap.set(t,i),this._formulaCellMap.set(t,n));let s=a.get(e),l=i.get(e),u=n.get(e);return(!s||!l||!u)&&(s=new r.ObjectMatrix,a.set(e,s),l=new Map,i.set(e,l),u=new Map,n.set(e,u)),{formulaMap:s,ruleFormulaMap:l,formulaCellMap:u}}_registerFormula(t,e,a,i){return this._registerOtherFormulaService.registerFormula(t,e,i,{ruleId:a})}deleteByRuleId(t,e,a){const{formulaMap:i,formulaCellMap:n,ruleFormulaMap:s}=this._ensureMaps(t,e),l=this._dataValidationModel.getRuleById(t,e,a),u=new Set,h=s.get(a);!l||!h||(s.delete(a),l.ranges.forEach(p=>{r.Range.foreach(p,(_,V)=>{const M=i.getValue(_,V);if(M&&M.ruleId===a){const{formulaId:O}=M;i.realDeleteValue(_,V),u.add(O),n.delete(O)}})}),this._registerOtherFormulaService.deleteFormula(t,e,Array.from(u.values())))}_addFormulaByRange(t,e,a,i,n){const{formulaMap:s,ruleFormulaMap:l,formulaCellMap:u}=this._ensureMaps(t,e);if(!i)return;const h=n[0].startRow,p=n[0].startColumn;let _;n.forEach(V=>{r.Range.foreach(V,(M,O)=>{const U=Vt(this._lexerTreeBuilder,i,h,p,M,O),C=this._registerFormula(t,e,a,U);s.setValue(M,O,{formulaId:C,ruleId:a}),u.set(C,{row:M,column:O})})}),l.set(a,{formula:i,originCol:p,originRow:h,formulaId:_,isTransformable:!0})}addRule(t,e,a){const{ranges:i,formula1:n,uid:s,type:l}=a;l!==r.DataValidationType.CUSTOM||!n||!r.isFormulaString(n)||this._addFormulaByRange(t,e,s,n,i)}updateRuleRanges(t,e,a,i,n){const{formulaMap:s,ruleFormulaMap:l,formulaCellMap:u}=this._ensureMaps(t,e),h=l.get(a);if(!h)return;const{formula:p,originCol:_,originRow:V,isTransformable:M,formulaId:O}=h,U=new Set;i.forEach(C=>{r.Range.foreach(C,(v,w)=>{const D=s.getValue(v,w);D&&D.ruleId===a&&(D.temp=!0)})}),n.forEach(C=>{r.Range.foreach(C,(v,w)=>{var B;const D=(B=s.getValue(v,w))!=null?B:{};if(D.ruleId!==a){const b=l.get(D.ruleId);if(b!=null&&b.isTransformable&&U.add(D.formulaId),M){const j=Vt(this._lexerTreeBuilder,p,V,_,v,w),Q=this._registerFormula(t,e,a,j);s.setValue(v,w,{ruleId:a,formulaId:Q}),u.set(Q,{row:v,column:w})}else s.setValue(v,w,{ruleId:a,formulaId:O})}else D.temp=!1})}),i.forEach(C=>{r.Range.foreach(C,(v,w)=>{const D=s.getValue(v,w);D&&D.ruleId===a&&D.temp===!0&&(s.realDeleteValue(v,w),M&&U.add(D.formulaId))})}),U.forEach(C=>{u.delete(C)}),this._registerOtherFormulaService.deleteFormula(t,e,Array.from(U.values()))}updateRuleFormula(t,e,a,i,n){const{ruleFormulaMap:s}=this._ensureMaps(t,e),l=s.get(a);(!l||l.formula!==n)&&this._addFormulaByRange(t,e,a,n,i)}getCellFormulaValue(t,e,a,i){const{formulaMap:n}=this._ensureMaps(t,e),s=n.getValue(a,i);return s?this._registerOtherFormulaService.getFormulaValue(t,e,s.formulaId):Promise.resolve(void 0)}getRuleFormulaInfo(t,e,a){const{ruleFormulaMap:i}=this._ensureMaps(t,e);return i.get(a)}};gt=Bt([rt(0,r.IUniverInstanceService),rt(1,r.Inject(Mt.RegisterOtherFormulaService)),rt(2,r.Inject(_t.LexerTreeBuilder)),rt(3,r.Inject(R.DataValidationModel)),rt(4,r.Inject(it)),rt(5,r.Inject(r.Injector))],gt);var jt=Object.defineProperty,Ht=Object.getOwnPropertyDescriptor,qt=(o,t,e,a)=>{for(var i=a>1?void 0:a?Ht(t,e):t,n=o.length-1,s;n>=0;n--)(s=o[n])&&(i=(a?s(t,e,i):s(i))||i);return a&&i&&jt(t,e,i),i},dt=(o,t)=>(e,a)=>t(e,a,o);let vt=class extends r.Disposable{constructor(t,e,a,i){super();$(this,"_formulaRuleMap",new Map);this._instanceService=t,this._registerOtherFormulaService=e,this._dataValidationCacheService=a,this._dataValidationModel=i,this._initFormulaResultHandler()}_initFormulaResultHandler(){this.disposeWithMe(this._registerOtherFormulaService.formulaResult$.subscribe(t=>{for(const e in t){const a=t[e];if(this._instanceService.getUnitType(e)===r.UniverInstanceType.UNIVER_SHEET)for(const n in a){const s=a[n],l=this._ensureRuleFormulaMap(e,n);s.forEach(u=>{var h,p;if(l.get((h=u.extra)==null?void 0:h.ruleId)){const _=this._dataValidationModel.getRuleById(e,n,(p=u.extra)==null?void 0:p.ruleId);_&&this._dataValidationCacheService.markRangeDirty(e,n,_.ranges)}})}}}))}_ensureRuleFormulaMap(t,e){let a=this._formulaRuleMap.get(t);a||(a=new Map,this._formulaRuleMap.set(t,a));let i=a.get(e);return i||(i=new Map,a.set(e,i)),i}addRule(t,e,a,i,n){const s=r.isFormulaString(i),l=r.isFormulaString(n);if(!s&&!l)return;const u=this._ensureRuleFormulaMap(t,e),h=[void 0,void 0];if(s){const p=this._registerOtherFormulaService.registerFormula(t,e,i,{ruleId:a});h[0]={id:p,text:i}}if(l){const p=this._registerOtherFormulaService.registerFormula(t,e,n,{ruleId:a});h[1]={id:p,text:n}}u.set(a,h)}removeRule(t,e,a){const n=this._ensureRuleFormulaMap(t,e).get(a);if(!n)return;const[s,l]=n,u=[s==null?void 0:s.id,l==null?void 0:l.id].filter(Boolean);u.length&&this._registerOtherFormulaService.deleteFormula(t,e,u)}updateRuleFormulaText(t,e,a,i,n){const l=this._ensureRuleFormulaMap(t,e).get(a);if(!l){this.addRule(t,e,a,i,n);return}const[u,h]=l;if((u==null?void 0:u.text)!==i)if(u&&this._registerOtherFormulaService.deleteFormula(t,e,[u.id]),r.isFormulaString(i)){const p=this._registerOtherFormulaService.registerFormula(t,e,i,{ruleId:a});l[0]={text:i,id:p}}else l[0]=void 0;if((h==null?void 0:h.text)!==n)if(h&&this._registerOtherFormulaService.deleteFormula(t,e,[h.id]),r.isFormulaString(n)){const p=this._registerOtherFormulaService.registerFormula(t,e,n,{ruleId:a});l[1]={text:n,id:p}}else l[1]=void 0}getRuleFormulaResult(t,e,a){const n=this._ensureRuleFormulaMap(t,e).get(a);if(!n)return Promise.resolve(null);const s=async l=>l&&this._registerOtherFormulaService.getFormulaValue(t,e,l.id);return Promise.all([s(n[0]),s(n[1])])}getRuleFormulaResultSync(t,e,a){const n=this._ensureRuleFormulaMap(t,e).get(a);if(n)return n.map(s=>{if(s)return this._registerOtherFormulaService.getFormulaValueSync(t,e,s.id)})}getRuleFormulaInfo(t,e,a){return this._ensureRuleFormulaMap(t,e).get(a)}};vt=qt([dt(0,r.IUniverInstanceService),dt(1,r.Inject(Mt.RegisterOtherFormulaService)),dt(2,r.Inject(it)),dt(3,r.Inject(R.DataValidationModel))],vt);function ct(o){return r.getOriginCellValue(o)}function Tt(o){var t;return String((t=ct(o))!=null?t:"")}const Wt=class Dt{constructor(t,e){this.low=t,this.high=e}clone(){return new Dt(this.low,this.high)}get max(){return this.clone()}less_than(t){return this.low<t.low||this.low===t.low&&this.high<t.high}equal_to(t){return this.low===t.low&&this.high===t.high}intersect(t){return!this.not_intersect(t)}not_intersect(t){return this.high<t.low||t.high<this.low}merge(t){return new Dt(this.low===void 0?t.low:this.low<t.low?this.low:t.low,this.high===void 0?t.high:this.high>t.high?this.high:t.high)}output(){return[this.low,this.high]}static comparable_max(t,e){return t.merge(e)}static comparable_less_than(t,e){return t<e}},L=0,E=1;class z{constructor(t=void 0,e=void 0,a=null,i=null,n=null,s=E){if(this.left=a,this.right=i,this.parent=n,this.color=s,this.item={key:t,value:e},t&&t instanceof Array&&t.length===2&&!Number.isNaN(t[0])&&!Number.isNaN(t[1])){let[l,u]=t;l>u&&([l,u]=[u,l]),this.item.key=new Wt(l,u)}this.max=this.item.key?this.item.key.max:void 0}isNil(){return this.item.key===void 0&&this.item.value===void 0&&this.left===null&&this.right===null&&this.color===E}_value_less_than(t){return this.item.value&&t.item.value&&this.item.value.less_than?this.item.value.less_than(t.item.value):this.item.value<t.item.value}less_than(t){return this.item.value===this.item.key&&t.item.value===t.item.key?this.item.key.less_than(t.item.key):this.item.key.less_than(t.item.key)||this.item.key.equal_to(t.item.key)&&this._value_less_than(t)}_value_equal(t){return this.item.value&&t.item.value&&this.item.value.equal_to?this.item.value.equal_to(t.item.value):this.item.value===t.item.value}equal_to(t){return this.item.value===this.item.key&&t.item.value===t.item.key?this.item.key.equal_to(t.item.key):this.item.key.equal_to(t.item.key)&&this._value_equal(t)}intersect(t){return this.item.key.intersect(t.item.key)}copy_data(t){this.item.key=t.item.key,this.item.value=t.item.value}update_max(){if(this.max=this.item.key?this.item.key.max:void 0,this.right&&this.right.max){const t=this.item.key.constructor.comparable_max;this.max=t(this.max,this.right.max)}if(this.left&&this.left.max){const t=this.item.key.constructor.comparable_max;this.max=t(this.max,this.left.max)}}not_intersect_left_subtree(t){const e=this.item.key.constructor.comparable_less_than;let a=this.left.max.high!==void 0?this.left.max.high:this.left.max;return e(a,t.item.key.low)}not_intersect_right_subtree(t){const e=this.item.key.constructor.comparable_less_than;let a=this.right.max.low!==void 0?this.right.max.low:this.right.item.key.low;return e(t.item.key.high,a)}}class Rt{constructor(){this.root=null,this.nil_node=new z}get size(){let t=0;return this.tree_walk(this.root,()=>t++),t}get keys(){let t=[];return this.tree_walk(this.root,e=>t.push(e.item.key.output?e.item.key.output():e.item.key)),t}get values(){let t=[];return this.tree_walk(this.root,e=>t.push(e.item.value)),t}get items(){let t=[];return this.tree_walk(this.root,e=>t.push({key:e.item.key.output?e.item.key.output():e.item.key,value:e.item.value})),t}isEmpty(){return this.root==null||this.root===this.nil_node}clear(){this.root=null}insert(t,e=t){if(t===void 0)return;let a=new z(t,e,this.nil_node,this.nil_node,null,L);return this.tree_insert(a),this.recalc_max(a),a}exist(t,e=t){let a=new z(t,e);return!!this.tree_search(this.root,a)}remove(t,e=t){let a=new z(t,e),i=this.tree_search(this.root,a);return i&&this.tree_delete(i),i}search(t,e=(a,i)=>a===i?i.output():a){let a=new z(t),i=[];return this.tree_search_interval(this.root,a,i),i.map(n=>e(n.item.value,n.item.key))}intersect_any(t){let e=new z(t);return this.tree_find_any_interval(this.root,e)}forEach(t){this.tree_walk(this.root,e=>t(e.item.key,e.item.value))}map(t){const e=new Rt;return this.tree_walk(this.root,a=>e.insert(a.item.key,t(a.item.value,a.item.key))),e}*iterate(t,e=(a,i)=>a===i?i.output():a){let a;for(t?a=this.tree_search_nearest_forward(this.root,new z(t)):this.root&&(a=this.local_minimum(this.root));a;)yield e(a.item.value,a.item.key),a=this.tree_successor(a)}recalc_max(t){let e=t;for(;e.parent!=null;)e.parent.update_max(),e=e.parent}tree_insert(t){let e=this.root,a=null;if(this.root==null||this.root===this.nil_node)this.root=t;else{for(;e!==this.nil_node;)a=e,t.less_than(e)?e=e.left:e=e.right;t.parent=a,t.less_than(a)?a.left=t:a.right=t}this.insert_fixup(t)}insert_fixup(t){let e,a;for(e=t;e!==this.root&&e.parent.color===L;)e.parent===e.parent.parent.left?(a=e.parent.parent.right,a.color===L?(e.parent.color=E,a.color=E,e.parent.parent.color=L,e=e.parent.parent):(e===e.parent.right&&(e=e.parent,this.rotate_left(e)),e.parent.color=E,e.parent.parent.color=L,this.rotate_right(e.parent.parent))):(a=e.parent.parent.left,a.color===L?(e.parent.color=E,a.color=E,e.parent.parent.color=L,e=e.parent.parent):(e===e.parent.left&&(e=e.parent,this.rotate_right(e)),e.parent.color=E,e.parent.parent.color=L,this.rotate_left(e.parent.parent)));this.root.color=E}tree_delete(t){let e,a;t.left===this.nil_node||t.right===this.nil_node?e=t:e=this.tree_successor(t),e.left!==this.nil_node?a=e.left:a=e.right,a.parent=e.parent,e===this.root?this.root=a:(e===e.parent.left?e.parent.left=a:e.parent.right=a,e.parent.update_max()),this.recalc_max(a),e!==t&&(t.copy_data(e),t.update_max(),this.recalc_max(t)),e.color===E&&this.delete_fixup(a)}delete_fixup(t){let e=t,a;for(;e!==this.root&&e.parent!=null&&e.color===E;)e===e.parent.left?(a=e.parent.right,a.color===L&&(a.color=E,e.parent.color=L,this.rotate_left(e.parent),a=e.parent.right),a.left.color===E&&a.right.color===E?(a.color=L,e=e.parent):(a.right.color===E&&(a.color=L,a.left.color=E,this.rotate_right(a),a=e.parent.right),a.color=e.parent.color,e.parent.color=E,a.right.color=E,this.rotate_left(e.parent),e=this.root)):(a=e.parent.left,a.color===L&&(a.color=E,e.parent.color=L,this.rotate_right(e.parent),a=e.parent.left),a.left.color===E&&a.right.color===E?(a.color=L,e=e.parent):(a.left.color===E&&(a.color=L,a.right.color=E,this.rotate_left(a),a=e.parent.left),a.color=e.parent.color,e.parent.color=E,a.left.color=E,this.rotate_right(e.parent),e=this.root));e.color=E}tree_search(t,e){if(!(t==null||t===this.nil_node))return e.equal_to(t)?t:e.less_than(t)?this.tree_search(t.left,e):this.tree_search(t.right,e)}tree_search_nearest_forward(t,e){let a,i=t;for(;i&&i!==this.nil_node;)i.less_than(e)?i.intersect(e)?(a=i,i=i.left):i=i.right:((!a||i.less_than(a))&&(a=i),i=i.left);return a||null}tree_search_interval(t,e,a){t!=null&&t!==this.nil_node&&(t.left!==this.nil_node&&!t.not_intersect_left_subtree(e)&&this.tree_search_interval(t.left,e,a),t.intersect(e)&&a.push(t),t.right!==this.nil_node&&!t.not_intersect_right_subtree(e)&&this.tree_search_interval(t.right,e,a))}tree_find_any_interval(t,e){let a=!1;return t!=null&&t!==this.nil_node&&(t.left!==this.nil_node&&!t.not_intersect_left_subtree(e)&&(a=this.tree_find_any_interval(t.left,e)),a||(a=t.intersect(e)),!a&&t.right!==this.nil_node&&!t.not_intersect_right_subtree(e)&&(a=this.tree_find_any_interval(t.right,e))),a}local_minimum(t){let e=t;for(;e.left!=null&&e.left!==this.nil_node;)e=e.left;return e}local_maximum(t){let e=t;for(;e.right!=null&&e.right!==this.nil_node;)e=e.right;return e}tree_successor(t){let e,a,i;if(t.right!==this.nil_node)e=this.local_minimum(t.right);else{for(a=t,i=t.parent;i!=null&&i.right===a;)a=i,i=i.parent;e=i}return e}rotate_left(t){let e=t.right;t.right=e.left,e.left!==this.nil_node&&(e.left.parent=t),e.parent=t.parent,t===this.root?this.root=e:t===t.parent.left?t.parent.left=e:t.parent.right=e,e.left=t,t.parent=e,t!=null&&t!==this.nil_node&&t.update_max(),e=t.parent,e!=null&&e!==this.nil_node&&e.update_max()}rotate_right(t){let e=t.left;t.left=e.right,e.right!==this.nil_node&&(e.right.parent=t),e.parent=t.parent,t===this.root?this.root=e:t===t.parent.left?t.parent.left=e:t.parent.right=e,e.right=t,t.parent=e,t!==null&&t!==this.nil_node&&t.update_max(),e=t.parent,e!=null&&e!==this.nil_node&&e.update_max()}tree_walk(t,e){t!=null&&t!==this.nil_node&&(this.tree_walk(t.left,e),e(t),this.tree_walk(t.right,e))}testRedBlackProperty(){let t=!0;return this.tree_walk(this.root,function(e){e.color===L&&(e.left.color===E&&e.right.color===E||(t=!1))}),t}testBlackHeightProperty(t){let e=0,a=0,i=0;if(t.color===E&&e++,t.left!==this.nil_node?a=this.testBlackHeightProperty(t.left):a=1,t.right!==this.nil_node?i=this.testBlackHeightProperty(t.right):i=1,a!==i)throw new Error("Red-black height property violated");return e+=a,e}}class St{constructor(t,e,a,i,n=!1){$(this,"_map");$(this,"_tree",new Map);$(this,"_dirty",!0);$(this,"_buildTree",()=>{if(!this._dirty||this._disableTree)return;const t=new Map;this._map.forEach((a,i)=>{a.forEach(n=>{for(let s=n.startColumn;s<=n.endColumn;s++){let l=t.get(s);l||(l=[],t.set(s,l)),l.push({startRow:n.startRow,endRow:n.endRow,ruleId:i})}})});const e=new Map;t.forEach((a,i)=>{const n=new Rt;a.forEach(s=>{n.insert([s.startRow,s.endRow],s.ruleId)}),e.set(i,n)}),this._tree=e,this._dirty=!1});$(this,"_debonceBuildTree",r.debounce(this._buildTree,0));this._unitId=e,this._subUnitId=a,this._univerInstanceService=i,this._disableTree=n,this._map=t,this._buildTree()}get _worksheet(){var t;return(t=this._univerInstanceService.getUnit(this._unitId,r.UniverInstanceType.UNIVER_SHEET))==null?void 0:t.getSheetBySheetId(this._subUnitId)}addRule(t){if(!this._worksheet)return;const e=t.uid,a=t.ranges.map(i=>r.Range.transformRange(i,this._worksheet));this._map.forEach((i,n)=>{const s=r.Rectangle.subtractMulti(i,a);s.length===0?this._map.delete(n):this._map.set(n,s)}),this._dirty=!0,this._map.set(e,a),this._debonceBuildTree()}removeRange(t){if(!this._worksheet)return;const e=t.map(a=>r.Range.transformRange(a,this._worksheet));this._map.forEach((a,i)=>{const n=r.Rectangle.subtractMulti(a,e);n.length===0?this._map.delete(i):this._map.set(i,n)}),this._dirty=!0,this._debonceBuildTree()}removeRule(t){this._map.delete(t.uid),this._dirty=!0,this._debonceBuildTree()}updateRange(t,e){if(!this._worksheet)return;this._map.delete(t);const a=e.map(i=>r.Range.transformRange(i,this._worksheet));this._map.forEach((i,n)=>{const s=r.Rectangle.subtractMulti(i,a);s.length===0?this._map.delete(n):this._map.set(n,s)}),this._map.set(t,a),this._dirty=!0,this._debonceBuildTree()}addRangeRules(t){t.forEach(({id:e,ranges:a})=>{if(!a.length)return;let i=this._map.get(e);i?(this._map.set(e,r.Rectangle.mergeRanges([...i,...a])),i=this._map.get(e)):(i=a,this._map.set(e,i)),this._map.forEach((n,s)=>{if(s===e)return;const l=r.Rectangle.subtractMulti(n,a);l.length===0?this._map.delete(s):this._map.set(s,l)})}),this._dirty=!0,this._debonceBuildTree()}diff(t){const e=[];let a=0;return t.forEach((i,n)=>{var u;const s=(u=this._map.get(i.uid))!=null?u:[],l=i.ranges;s.length!==0&&(s.length!==l.length||s.some((h,p)=>!r.Rectangle.equals(h,l[p])))&&e.push({type:"update",ruleId:i.uid,oldRanges:l,newRanges:r.Rectangle.sort(s),rule:i}),s.length===0&&(e.push({type:"delete",rule:i,index:n-a}),a++)}),e}diffWithAddition(t,e){const a=[];let i=0;return t.forEach((n,s)=>{var h;const l=(h=this._map.get(n.uid))!=null?h:[],u=n.ranges;l.length!==0&&(l.length!==u.length||l.some((p,_)=>!r.Rectangle.equals(p,u[_])))&&a.push({type:"update",ruleId:n.uid,oldRanges:u,newRanges:r.Rectangle.sort(l),rule:n}),l.length===0&&(a.push({type:"delete",rule:n,index:s-i}),i++)}),Array.from(e).forEach(n=>{var l;const s=(l=this._map.get(n.uid))!=null?l:[];a.push({type:"add",rule:{...n,ranges:r.Rectangle.sort(s)}})}),a}clone(){return new St(new Map(r.Tools.deepClone(Array.from(this._map.entries()))),this._unitId,this._subUnitId,this._univerInstanceService,!0)}getValue(t,e){this._dirty&&this._buildTree();const a=this._tree.get(e);if(!a)return;const i=a.search([t,t]);return i.length>0?i[0]:void 0}}var Pt=Object.defineProperty,Gt=Object.getOwnPropertyDescriptor,Qt=(o,t,e,a)=>{for(var i=a>1?void 0:a?Gt(t,e):t,n=o.length-1,s;n>=0;n--)(s=o[n])&&(i=(a?s(t,e,i):s(i))||i);return a&&i&&Pt(t,e,i),i},J=(o,t)=>(e,a)=>t(e,a,o);let W=class extends r.Disposable{constructor(t,e,a,i,n,s,l){super();$(this,"_ruleMatrixMap",new Map);$(this,"_validStatusChange$",new K.Subject);$(this,"_ruleChange$",new K.Subject);$(this,"ruleChange$",this._ruleChange$.asObservable());$(this,"validStatusChange$",this._validStatusChange$.asObservable());this._dataValidationModel=t,this._univerInstanceService=e,this._dataValidatorRegistryService=a,this._dataValidationCacheService=i,this._dataValidationFormulaService=n,this._dataValidationCustomFormulaService=s,this._commandService=l,this._initRuleUpdateListener(),this.disposeWithMe(()=>{this._ruleChange$.complete(),this._validStatusChange$.complete()}),this._initUniverInstanceListener()}_initUniverInstanceListener(){this.disposeWithMe(this._univerInstanceService.unitDisposed$.subscribe(t=>{this._ruleMatrixMap.delete(t.getUnitId())})),this.disposeWithMe(this._commandService.onCommandExecuted(t=>{if(t.id===G.RemoveSheetMutation.id){const{unitId:e,subUnitId:a}=t.params,i=this._ruleMatrixMap.get(e);i&&i.delete(a)}}))}_initRuleUpdateListener(){const t=this._dataValidationModel.getAll();for(const[e,a]of t)for(const[i,n]of a)for(const s of n)this._addRule(e,i,s),this._ruleChange$.next({type:"add",unitId:e,subUnitId:i,rule:s,source:"patched"});this.disposeWithMe(this._dataValidationModel.ruleChange$.subscribe(e=>{switch(e.type){case"add":this._addRule(e.unitId,e.subUnitId,e.rule);break;case"update":this._updateRule(e.unitId,e.subUnitId,e.rule.uid,e.oldRule,e.updatePayload);break;case"remove":this._removeRule(e.unitId,e.subUnitId,e.rule);break}this._ruleChange$.next(e)}))}_ensureRuleMatrix(t,e){let a=this._ruleMatrixMap.get(t);a||(a=new Map,this._ruleMatrixMap.set(t,a));let i=a.get(e);return i||(i=new St(new Map,t,e,this._univerInstanceService),a.set(e,i)),i}_addRuleSideEffect(t,e,a){this._ensureRuleMatrix(t,e).addRule(a),this._dataValidationCacheService.addRule(t,e,a),this._dataValidationFormulaService.addRule(t,e,a.uid,a.formula1,a.formula2),a.type===r.DataValidationType.CUSTOM&&this._dataValidationCustomFormulaService.addRule(t,e,a)}_addRule(t,e,a){(Array.isArray(a)?a:[a]).forEach(n=>{this._addRuleSideEffect(t,e,n)})}_updateRule(t,e,a,i,n){const s=this._ensureRuleMatrix(t,e);n.type===R.UpdateRuleType.RANGE?(s.updateRange(a,n.payload),this._dataValidationCacheService.updateRuleRanges(t,e,a,n.payload,i.ranges),i.type===r.DataValidationType.CUSTOM&&this._dataValidationCustomFormulaService.updateRuleRanges(t,e,a,i.ranges,n.payload)):n.type===R.UpdateRuleType.SETTING&&(this._dataValidationCacheService.markRangeDirty(t,e,i.ranges),this._dataValidationFormulaService.updateRuleFormulaText(t,e,a,n.payload.formula1,n.payload.formula2),i.type===r.DataValidationType.CUSTOM?this._dataValidationCustomFormulaService.updateRuleFormula(t,e,a,i.ranges,n.payload.formula1):n.payload.type===r.DataValidationType.CUSTOM&&this._dataValidationCustomFormulaService.addRule(t,e,{...i,...n.payload}))}_removeRule(t,e,a){this._ensureRuleMatrix(t,e).removeRule(a),this._dataValidationCacheService.removeRule(t,e,a),a.type===r.DataValidationType.CUSTOM&&this._dataValidationCustomFormulaService.deleteByRuleId(t,e,a.uid)}getValidator(t){return this._dataValidatorRegistryService.getValidatorItem(t)}getRuleIdByLocation(t,e,a,i){return this._ensureRuleMatrix(t,e).getValue(a,i)}getRuleByLocation(t,e,a,i){const n=this.getRuleIdByLocation(t,e,a,i);if(n)return this._dataValidationModel.getRuleById(t,e,n)}validator(t,e,a){const{col:i,row:n,unitId:s,subUnitId:l,worksheet:u}=e,h=t.uid,p=t.formula1,_=t.formula2,V=(w,D)=>{a&&a(w,D),D&&this._validStatusChange$.next({unitId:s,subUnitId:l,ruleId:t.uid,status:w,row:n,col:i})},M=u.getCellValueOnly(n,i),O=this.getValidator(t.type),U=u.getCellRaw(n,i),C=ct(U),v=ct(M);if(O){const w=this._dataValidationCacheService.ensureCache(s,l),D=w.getValue(n,i);return!D||D.value!==C||D.interceptValue!==v||D.ruleId!==h||D.formula1!==p||D.formula2!==_?(w.setValue(n,i,{value:C,interceptValue:v,status:r.DataValidationStatus.VALIDATING,ruleId:h,formula1:p||"",formula2:_||""}),O.validator({value:C,unitId:s,subUnitId:l,row:n,column:i,worksheet:e.worksheet,workbook:e.workbook,interceptValue:ct(M),t:U==null?void 0:U.t},t).then(B=>{const b=B?r.DataValidationStatus.VALID:r.DataValidationStatus.INVALID;w.setValue(n,i,{value:C,status:b,ruleId:h,interceptValue:v,formula1:p||"",formula2:_||""}),V(b,!0)}),r.DataValidationStatus.VALIDATING):(V(D.status,!1),D.status)}else return V(r.DataValidationStatus.VALID,!1),r.DataValidationStatus.VALID}getRuleErrorMsg(t,e,a){const i=this._dataValidationModel.getRuleById(t,e,a);if(!i)return"";const n=this._dataValidatorRegistryService.getValidatorItem(i.type);return i.error?i.error:n?n.getRuleFinalError(i):""}getRuleObjectMatrix(t,e){return this._ensureRuleMatrix(t,e)}getRuleById(t,e,a){return this._dataValidationModel.getRuleById(t,e,a)}getRuleIndex(t,e,a){return this._dataValidationModel.getRuleIndex(t,e,a)}getRules(t,e){return[...this._dataValidationModel.getRules(t,e)]}getUnitRules(t){return this._dataValidationModel.getUnitRules(t)}deleteUnitRules(t){return this._dataValidationModel.deleteUnitRules(t)}getSubUnitIds(t){return this._dataValidationModel.getSubUnitIds(t)}getAll(){return this._dataValidationModel.getAll()}};W=Qt([J(0,r.Inject(R.DataValidationModel)),J(1,r.IUniverInstanceService),J(2,r.Inject(R.DataValidatorRegistryService)),J(3,r.Inject(it)),J(4,r.Inject(vt)),J(5,r.Inject(gt)),J(6,r.ICommandService)],W);const Et=1,wt=0;var Yt=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},Kt={exports:{}};(function(o,t){(function(e,a){o.exports=a()})(Yt,function(){var e=1e3,a=6e4,i=36e5,n="millisecond",s="second",l="minute",u="hour",h="day",p="week",_="month",V="quarter",M="year",O="date",U="Invalid Date",C=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,v=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,w={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(g){var c=["th","st","nd","rd"],d=g%100;return"["+g+(c[(d-20)%10]||c[d]||c[0])+"]"}},D=function(g,c,d){var f=String(g);return!f||f.length>=c?g:""+Array(c+1-f.length).join(d)+g},B={s:D,z:function(g){var c=-g.utcOffset(),d=Math.abs(c),f=Math.floor(d/60),m=d%60;return(c<=0?"+":"-")+D(f,2,"0")+":"+D(m,2,"0")},m:function g(c,d){if(c.date()<d.date())return-g(d,c);var f=12*(d.year()-c.year())+(d.month()-c.month()),m=c.clone().add(f,_),S=d-m<0,y=c.clone().add(f+(S?-1:1),_);return+(-(f+(d-m)/(S?m-y:y-m))||0)},a:function(g){return g<0?Math.ceil(g)||0:Math.floor(g)},p:function(g){return{M:_,y:M,w:p,d:h,D:O,h:u,m:l,s,ms:n,Q:V}[g]||String(g||"").toLowerCase().replace(/s$/,"")},u:function(g){return g===void 0}},b="en",j={};j[b]=w;var Q="$isDayjsObject",tt=function(g){return g instanceof nt||!(!g||!g[Q])},Y=function g(c,d,f){var m;if(!c)return b;if(typeof c=="string"){var S=c.toLowerCase();j[S]&&(m=S),d&&(j[S]=d,m=S);var y=c.split("-");if(!m&&y.length>1)return g(y[0])}else{var I=c.name;j[I]=c,m=I}return!f&&m&&(b=m),m||!f&&b},A=function(g,c){if(tt(g))return g.clone();var d=typeof c=="object"?c:{};return d.date=g,d.args=arguments,new nt(d)},T=B;T.l=Y,T.i=tt,T.w=function(g,c){return A(g,{locale:c.$L,utc:c.$u,x:c.$x,$offset:c.$offset})};var nt=function(){function g(d){this.$L=Y(d.locale,null,!0),this.parse(d),this.$x=this.$x||d.x||{},this[Q]=!0}var c=g.prototype;return c.parse=function(d){this.$d=function(f){var m=f.date,S=f.utc;if(m===null)return new Date(NaN);if(T.u(m))return new Date;if(m instanceof Date)return new Date(m);if(typeof m=="string"&&!/Z$/i.test(m)){var y=m.match(C);if(y){var I=y[2]-1||0,x=(y[7]||"0").substring(0,3);return S?new Date(Date.UTC(y[1],I,y[3]||1,y[4]||0,y[5]||0,y[6]||0,x)):new Date(y[1],I,y[3]||1,y[4]||0,y[5]||0,y[6]||0,x)}}return new Date(m)}(d),this.init()},c.init=function(){var d=this.$d;this.$y=d.getFullYear(),this.$M=d.getMonth(),this.$D=d.getDate(),this.$W=d.getDay(),this.$H=d.getHours(),this.$m=d.getMinutes(),this.$s=d.getSeconds(),this.$ms=d.getMilliseconds()},c.$utils=function(){return T},c.isValid=function(){return this.$d.toString()!==U},c.isSame=function(d,f){var m=A(d);return this.startOf(f)<=m&&m<=this.endOf(f)},c.isAfter=function(d,f){return A(d)<this.startOf(f)},c.isBefore=function(d,f){return this.endOf(f)<A(d)},c.$g=function(d,f,m){return T.u(d)?this[f]:this.set(m,d)},c.unix=function(){return Math.floor(this.valueOf()/1e3)},c.valueOf=function(){return this.$d.getTime()},c.startOf=function(d,f){var m=this,S=!!T.u(f)||f,y=T.p(d),I=function(at,q){var X=T.w(m.$u?Date.UTC(m.$y,q,at):new Date(m.$y,q,at),m);return S?X:X.endOf(h)},x=function(at,q){return T.w(m.toDate()[at].apply(m.toDate("s"),(S?[0,0,0,0]:[23,59,59,999]).slice(q)),m)},N=this.$W,H=this.$M,P=this.$D,st="set"+(this.$u?"UTC":"");switch(y){case M:return S?I(1,0):I(31,11);case _:return S?I(1,H):I(0,H+1);case p:var et=this.$locale().weekStart||0,ut=(N<et?N+7:N)-et;return I(S?P-ut:P+(6-ut),H);case h:case O:return x(st+"Hours",0);case u:return x(st+"Minutes",1);case l:return x(st+"Seconds",2);case s:return x(st+"Milliseconds",3);default:return this.clone()}},c.endOf=function(d){return this.startOf(d,!1)},c.$set=function(d,f){var m,S=T.p(d),y="set"+(this.$u?"UTC":""),I=(m={},m[h]=y+"Date",m[O]=y+"Date",m[_]=y+"Month",m[M]=y+"FullYear",m[u]=y+"Hours",m[l]=y+"Minutes",m[s]=y+"Seconds",m[n]=y+"Milliseconds",m)[S],x=S===h?this.$D+(f-this.$W):f;if(S===_||S===M){var N=this.clone().set(O,1);N.$d[I](x),N.init(),this.$d=N.set(O,Math.min(this.$D,N.daysInMonth())).$d}else I&&this.$d[I](x);return this.init(),this},c.set=function(d,f){return this.clone().$set(d,f)},c.get=function(d){return this[T.p(d)]()},c.add=function(d,f){var m,S=this;d=Number(d);var y=T.p(f),I=function(H){var P=A(S);return T.w(P.date(P.date()+Math.round(H*d)),S)};if(y===_)return this.set(_,this.$M+d);if(y===M)return this.set(M,this.$y+d);if(y===h)return I(1);if(y===p)return I(7);var x=(m={},m[l]=a,m[u]=i,m[s]=e,m)[y]||1,N=this.$d.getTime()+d*x;return T.w(N,this)},c.subtract=function(d,f){return this.add(-1*d,f)},c.format=function(d){var f=this,m=this.$locale();if(!this.isValid())return m.invalidDate||U;var S=d||"YYYY-MM-DDTHH:mm:ssZ",y=T.z(this),I=this.$H,x=this.$m,N=this.$M,H=m.weekdays,P=m.months,st=m.meridiem,et=function(q,X,ht,ft){return q&&(q[X]||q(f,S))||ht[X].slice(0,ft)},ut=function(q){return T.s(I%12||12,q,"0")},at=st||function(q,X,ht){var ft=q<12?"AM":"PM";return ht?ft.toLowerCase():ft};return S.replace(v,function(q,X){return X||function(ht){switch(ht){case"YY":return String(f.$y).slice(-2);case"YYYY":return T.s(f.$y,4,"0");case"M":return N+1;case"MM":return T.s(N+1,2,"0");case"MMM":return et(m.monthsShort,N,P,3);case"MMMM":return et(P,N);case"D":return f.$D;case"DD":return T.s(f.$D,2,"0");case"d":return String(f.$W);case"dd":return et(m.weekdaysMin,f.$W,H,2);case"ddd":return et(m.weekdaysShort,f.$W,H,3);case"dddd":return H[f.$W];case"H":return String(I);case"HH":return T.s(I,2,"0");case"h":return ut(1);case"hh":return ut(2);case"a":return at(I,x,!0);case"A":return at(I,x,!1);case"m":return String(x);case"mm":return T.s(x,2,"0");case"s":return String(f.$s);case"ss":return T.s(f.$s,2,"0");case"SSS":return T.s(f.$ms,3,"0");case"Z":return y}return null}(q)||y.replace(":","")})},c.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},c.diff=function(d,f,m){var S,y=this,I=T.p(f),x=A(d),N=(x.utcOffset()-this.utcOffset())*a,H=this-x,P=function(){return T.m(y,x)};switch(I){case M:S=P()/12;break;case _:S=P();break;case V:S=P()/3;break;case p:S=(H-N)/6048e5;break;case h:S=(H-N)/864e5;break;case u:S=H/i;break;case l:S=H/a;break;case s:S=H/e;break;default:S=H}return m?S:T.a(S)},c.daysInMonth=function(){return this.endOf(_).$D},c.$locale=function(){return j[this.$L]},c.locale=function(d,f){if(!d)return this.$L;var m=this.clone(),S=Y(d,f,!0);return S&&(m.$L=S),m},c.clone=function(){return T.w(this.$d,this)},c.toDate=function(){return new Date(this.valueOf())},c.toJSON=function(){return this.isValid()?this.toISOString():null},c.toISOString=function(){return this.$d.toISOString()},c.toString=function(){return this.$d.toUTCString()},g}(),pt=nt.prototype;return A.prototype=pt,[["$ms",n],["$s",s],["$m",l],["$H",u],["$W",h],["$M",_],["$y",M],["$D",O]].forEach(function(g){pt[g[1]]=function(c){return this.$g(c,g[0],g[1])}}),A.extend=function(g,c){return g.$i||(g(c,nt,A),g.$i=!0),A},A.locale=Y,A.isDayjs=tt,A.unix=function(g){return A(1e3*g)},A.en=j[b],A.Ls=j,A.p={},A})})(Kt),r.DataValidationOperator.BETWEEN+"",r.DataValidationOperator.EQUAL+"",r.DataValidationOperator.GREATER_THAN+"",r.DataValidationOperator.GREATER_THAN_OR_EQUAL+"",r.DataValidationOperator.LESS_THAN+"",r.DataValidationOperator.LESS_THAN_OR_EQUAL+"",r.DataValidationOperator.NOT_BETWEEN+"",r.DataValidationOperator.NOT_EQUAL+"",r.DataValidationOperator.BETWEEN+"",r.DataValidationOperator.EQUAL+"",r.DataValidationOperator.GREATER_THAN+"",r.DataValidationOperator.GREATER_THAN_OR_EQUAL+"",r.DataValidationOperator.LESS_THAN+"",r.DataValidationOperator.LESS_THAN_OR_EQUAL+"",r.DataValidationOperator.NOT_BETWEEN+"",r.DataValidationOperator.NOT_EQUAL+"",r.DataValidationOperator.BETWEEN+"",r.DataValidationOperator.EQUAL+"",r.DataValidationOperator.GREATER_THAN+"",r.DataValidationOperator.GREATER_THAN_OR_EQUAL+"",r.DataValidationOperator.LESS_THAN+"",r.DataValidationOperator.LESS_THAN_OR_EQUAL+"",r.DataValidationOperator.NOT_BETWEEN+"",r.DataValidationOperator.NOT_EQUAL+"",r.DataValidationOperator.BETWEEN+"",r.DataValidationOperator.EQUAL+"",r.DataValidationOperator.GREATER_THAN+"",r.DataValidationOperator.GREATER_THAN_OR_EQUAL+"",r.DataValidationOperator.LESS_THAN+"",r.DataValidationOperator.LESS_THAN_OR_EQUAL+"",r.DataValidationOperator.NOT_BETWEEN+"",r.DataValidationOperator.NOT_EQUAL+"",r.DataValidationOperator.BETWEEN,r.DataValidationOperator.NOT_BETWEEN;function Ot(o){var e,a;return o?o.p?!((a=(e=o.p.body)==null?void 0:e.dataStream)!=null?a:"").slice(0,-2).trim():r.Tools.isBlank(o.v):!0}function yt(o,t,e,a,i="command",n=!0){const s=a.get(_t.LexerTreeBuilder),l=[],u=[],h=a.get(W),p=a.get(r.IUniverInstanceService),_=G.getSheetCommandTarget(p,{unitId:o,subUnitId:t});if(!_)return{redoMutations:l,undoMutations:u};const{worksheet:V}=_,M=new r.ObjectMatrix;function O(v,w){n&&v.forEach(D=>{r.Range.foreach(D,(B,b)=>{const j=V.getCellRaw(B,b),Q=Tt(j);(Ot(j)||Q===w)&&M.setValue(B,b,{v:w,p:null})})})}e.forEach(v=>{switch(v.type){case"delete":l.push({id:R.RemoveDataValidationMutation.id,params:{unitId:o,subUnitId:t,ruleId:v.rule.uid,source:i}}),u.unshift({id:R.AddDataValidationMutation.id,params:{unitId:o,subUnitId:t,rule:v.rule,index:v.index,source:i}});break;case"update":{if(l.push({id:R.UpdateDataValidationMutation.id,params:{unitId:o,subUnitId:t,ruleId:v.ruleId,payload:{type:R.UpdateRuleType.RANGE,payload:v.newRanges},source:i}}),u.unshift({id:R.UpdateDataValidationMutation.id,params:{unitId:o,subUnitId:t,ruleId:v.ruleId,payload:{type:R.UpdateRuleType.RANGE,payload:v.oldRanges},source:i}}),v.rule.type===r.DataValidationType.CUSTOM){const D=v.oldRanges[0].startRow,B=v.oldRanges[0].startColumn,b=v.newRanges[0].startRow,j=v.newRanges[0].startColumn,Q=b-D,tt=j-B,Y=s.moveFormulaRefOffset(v.rule.formula1,tt,Q);Y!==v.rule.formula1&&(l.push({id:R.UpdateDataValidationMutation.id,params:{unitId:o,subUnitId:t,ruleId:v.ruleId,payload:{type:R.UpdateRuleType.SETTING,payload:{...R.getRuleSetting(v.rule),formula1:Y}}}}),u.unshift({id:R.UpdateDataValidationMutation.id,params:{unitId:o,subUnitId:t,ruleId:v.ruleId,payload:{type:R.UpdateRuleType.SETTING,payload:R.getRuleSetting(v.rule)}}}))}const w=h.getRuleById(o,t,v.ruleId);if(w&&w.type===r.DataValidationType.CHECKBOX){const B=h.getValidator(r.DataValidationType.CHECKBOX).parseFormulaSync(w,o,t);O(v.newRanges,B.formula2)}break}case"add":{if(l.push({id:R.AddDataValidationMutation.id,params:{unitId:o,subUnitId:t,rule:v.rule,source:i}}),u.unshift({id:R.RemoveDataValidationMutation.id,params:{unitId:o,subUnitId:t,ruleId:v.rule.uid,source:i}}),v.rule.type===r.DataValidationType.CHECKBOX){const D=h.getValidator(r.DataValidationType.CHECKBOX).parseFormulaSync(v.rule,o,t);O(v.rule.ranges,D.originFormula2)}break}}});const U={id:G.SetRangeValuesMutation.id,params:{unitId:o,subUnitId:t,cellValue:M.getData()}},C={id:G.SetRangeValuesMutation.id,params:G.SetRangeValuesUndoMutationFactory(a,U.params)};return l.push(U),u.push(C),{redoMutations:l,undoMutations:u}}const It={type:r.CommandType.COMMAND,id:"sheet.command.updateDataValidationRuleRange",handler(o,t){if(!t)return!1;const{unitId:e,subUnitId:a,ranges:i,ruleId:n}=t,s=o.get(W),l=o.get(r.ICommandService),u=o.get(r.IUndoRedoService);if(!s.getRuleById(e,a,n))return!1;const p=s.getRuleObjectMatrix(e,a).clone();p.updateRange(n,i);const _=p.diff(s.getRules(e,a)),{redoMutations:V,undoMutations:M}=yt(e,a,_,o);return u.pushUndoRedo({undoMutations:M,redoMutations:V,unitID:e}),r.sequenceExecute(V,l),!0}},Ct={type:r.CommandType.COMMAND,id:"sheet.command.addDataValidation",handler(o,t){if(!t)return!1;const{unitId:e,subUnitId:a,rule:i}=t,n=o.get(W),s=o.get(r.ICommandService),l=o.get(r.IUndoRedoService),u=n.getRuleObjectMatrix(e,a).clone();u.addRule(i);const h=u.diff(n.getRules(e,a)),p={unitId:e,subUnitId:a,rule:i},{redoMutations:_,undoMutations:V}=yt(e,a,h,o);return _.push({id:R.AddDataValidationMutation.id,params:p}),V.unshift({id:R.RemoveDataValidationMutation.id,params:{unitId:e,subUnitId:a,ruleId:i.uid}}),l.pushUndoRedo({unitID:e,redoMutations:_,undoMutations:V}),r.sequenceExecute(_,s),!0}},bt={type:r.CommandType.COMMAND,id:"sheets.command.update-data-validation-setting",handler(o,t){if(!t)return!1;const e=o.get(r.ICommandService),a=o.get(r.IUndoRedoService),i=o.get(W),n=o.get(R.DataValidatorRegistryService),{unitId:s,subUnitId:l,ruleId:u,setting:h}=t,p=n.getValidatorItem(h.type);if(!p)return!1;const _=i.getRuleById(s,l,u);if(!_)return!1;const V={..._,...h};if(!p.validatorFormula(V,s,l).success)return!1;const M={unitId:s,subUnitId:l,ruleId:u,payload:{type:R.UpdateRuleType.SETTING,payload:{...h,...p.normalizeFormula(V,s,l)}}},O=[{id:R.UpdateDataValidationMutation.id,params:M}],U={unitId:s,subUnitId:l,ruleId:u,payload:{type:R.UpdateRuleType.SETTING,payload:R.getRuleSetting(_)}},C=[{id:R.UpdateDataValidationMutation.id,params:U}];if(h.type===r.DataValidationType.CHECKBOX){const w=_.ranges,D=o.get(r.IUniverInstanceService),B=G.getSheetCommandTarget(D,{unitId:s,subUnitId:l});if(B){const b=new r.ObjectMatrix,{worksheet:j}=B,{formula2:Q=wt,formula1:tt=Et}=_,{formula2:Y=wt,formula1:A=Et}=h;w.forEach(pt=>{r.Range.foreach(pt,(g,c)=>{const d=j.getCellRaw(g,c),f=Tt(d);Ot(d)||f===String(Q)?b.setValue(g,c,{v:Y,p:null}):f===String(tt)&&b.setValue(g,c,{v:A,p:null})})});const T={id:G.SetRangeValuesMutation.id,params:{unitId:s,subUnitId:l,cellValue:b.getData()}},nt={id:G.SetRangeValuesMutation.id,params:G.SetRangeValuesUndoMutationFactory(o,T.params)};O.push(T),C.push(nt)}}return r.sequenceExecute(O,e).result?(a.pushUndoRedo({unitID:s,redoMutations:O,undoMutations:C}),!0):!1}},xt={type:r.CommandType.COMMAND,id:"sheets.command.update-data-validation-options",handler(o,t){if(!t)return!1;const e=o.get(r.ICommandService),a=o.get(r.IUndoRedoService),i=o.get(W),{unitId:n,subUnitId:s,ruleId:l,options:u}=t,h=i.getRuleById(n,s,l);if(!h)return!1;const p={unitId:n,subUnitId:s,ruleId:l,payload:{type:R.UpdateRuleType.OPTIONS,payload:u}},_=[{id:R.UpdateDataValidationMutation.id,params:p}],V={unitId:n,subUnitId:s,ruleId:l,payload:{type:R.UpdateRuleType.OPTIONS,payload:R.getRuleOptions(h)}},M=[{id:R.UpdateDataValidationMutation.id,params:V}];return a.pushUndoRedo({unitID:n,redoMutations:_,undoMutations:M}),e.executeCommand(R.UpdateDataValidationMutation.id,p),!0}},Xt={type:r.CommandType.COMMAND,id:"sheets.command.clear-range-data-validation",handler(o,t){if(!t)return!1;const{unitId:e,subUnitId:a,ranges:i}=t,n=o.get(r.ICommandService),s=o.get(r.IUniverInstanceService),l=G.getSheetCommandTarget(s,{unitId:e,subUnitId:a}),u=o.get(W);if(!l)return!1;const h=o.get(r.IUndoRedoService),p=u.getRuleObjectMatrix(e,a).clone();p.removeRange(i);const _=p.diff(u.getRules(e,a)),{redoMutations:V,undoMutations:M}=yt(e,a,_,o);return h.pushUndoRedo({unitID:e,redoMutations:V,undoMutations:M}),r.sequenceExecute(V,n).result}},zt={type:r.CommandType.COMMAND,id:"sheet.command.remove-all-data-validation",handler(o,t){if(!t)return!1;const{unitId:e,subUnitId:a}=t,i=o.get(r.ICommandService),n=o.get(W),s=o.get(r.IUndoRedoService),l=[...n.getRules(e,a)],u={unitId:e,subUnitId:a,ruleId:l.map(_=>_.uid)},h=[{id:R.RemoveDataValidationMutation.id,params:u}],p=[{id:R.AddDataValidationMutation.id,params:{unitId:e,subUnitId:a,rule:l}}];return s.pushUndoRedo({redoMutations:h,undoMutations:p,unitID:e}),i.executeCommand(R.RemoveDataValidationMutation.id,u),!0}},$t={type:r.CommandType.COMMAND,id:"sheet.command.remove-data-validation-rule",handler(o,t){if(!t)return!1;const{unitId:e,subUnitId:a,ruleId:i}=t,n=o.get(r.ICommandService),s=o.get(r.IUndoRedoService),l=o.get(W),u=[{id:R.RemoveDataValidationMutation.id,params:t}],h=[{id:R.AddDataValidationMutation.id,params:{unitId:e,subUnitId:a,rule:{...l.getRuleById(e,a,i)},index:l.getRuleIndex(e,a,i)}}];return s.pushUndoRedo({undoMutations:h,redoMutations:u,unitID:t.unitId}),n.executeCommand(R.RemoveDataValidationMutation.id,t),!0}};var Jt=Object.defineProperty,Zt=Object.getOwnPropertyDescriptor,te=(o,t,e,a)=>{for(var i=a>1?void 0:a?Zt(t,e):t,n=o.length-1,s;n>=0;n--)(s=o[n])&&(i=(a?s(t,e,i):s(i))||i);return a&&i&&Jt(t,e,i),i},mt=(o,t)=>(e,a)=>t(e,a,o);let Z=class extends r.Disposable{constructor(o,t,e,a){super(),this._univerInstanceService=o,this._sheetDataValidationModel=t,this._dataValidationCacheService=e,this._lifecycleService=a,this._initRecalculate()}_initRecalculate(){const o=t=>{if(t.length===0)return;const e=this._univerInstanceService.getCurrentUnitForType(r.UniverInstanceType.UNIVER_SHEET),a=e==null?void 0:e.getActiveSheet(),i={};t.flat().forEach(n=>{i[n.unitId]||(i[n.unitId]={}),i[n.unitId][n.subUnitId]||(i[n.unitId][n.subUnitId]=[]);const s=this._univerInstanceService.getUnit(n.unitId,r.UniverInstanceType.UNIVER_SHEET),l=s==null?void 0:s.getSheetBySheetId(n.subUnitId);l&&i[n.unitId][n.subUnitId].push(...n.ranges.map(u=>r.Range.transformRange(u,l)))}),Object.entries(i).forEach(([n,s])=>{Object.entries(s).forEach(([l,u])=>{(e==null?void 0:e.getUnitId())===n&&(a==null?void 0:a.getSheetId())===l?this.validatorRanges(n,l,u):requestIdleCallback(()=>{this.validatorRanges(n,l,u)})})})};this.disposeWithMe(this._dataValidationCacheService.dirtyRanges$.pipe(K.bufferWhen(()=>this._lifecycleService.lifecycle$.pipe(K.filter(t=>t===r.LifecycleStages.Rendered)))).subscribe(o)),this.disposeWithMe(this._dataValidationCacheService.dirtyRanges$.pipe(K.filter(()=>this._lifecycleService.stage>=r.LifecycleStages.Rendered),r.bufferDebounceTime(20)).subscribe(o))}async validatorCell(o,t,e,a){const i=this._univerInstanceService.getUnit(o,r.UniverInstanceType.UNIVER_SHEET);if(!i)throw new Error(`cannot find current workbook, unitId: ${o}`);const n=i.getSheetBySheetId(t);if(!n)throw new Error(`cannot find current worksheet, sheetId: ${t}`);if(!r.Tools.isDefine(e)||!r.Tools.isDefine(a))throw new Error(`row or col is not defined, row: ${e}, col: ${a}`);const s=this._sheetDataValidationModel.getRuleByLocation(o,t,e,a);return s?new Promise(l=>{this._sheetDataValidationModel.validator(s,{unitId:o,subUnitId:t,row:e,col:a,worksheet:n,workbook:i},u=>{l(u)})}):r.DataValidationStatus.VALID}validatorRanges(o,t,e){return Promise.all(e.map(a=>{const i=[];return r.Range.foreach(a,(n,s)=>{i.push(this.validatorCell(o,t,n,s))}),i}))}async validatorWorksheet(o,t){const e=this._sheetDataValidationModel.getRules(o,t);return await Promise.all(e.map(a=>Promise.all(a.ranges.map(i=>{const n=[];return r.Range.foreach(i,(s,l)=>{n.push(this.validatorCell(o,t,s,l))}),n})))),this._dataValidationCacheService.ensureCache(o,t)}async validatorWorkbook(o){const t=this._sheetDataValidationModel.getSubUnitIds(o),e=await Promise.all(t.map(i=>this.validatorWorksheet(o,i))),a={};return e.forEach((i,n)=>{a[t[n]]=i}),a}getDataValidations(o,t,e){const a=this._sheetDataValidationModel.getRuleObjectMatrix(o,t),i=new Set;return e.forEach(s=>{r.Range.foreach(s,(l,u)=>{const h=a.getValue(l,u);h&&i.add(h)})}),Array.from(i).map(s=>this._sheetDataValidationModel.getRuleById(o,t,s)).filter(Boolean)}getDataValidation(o,t,e){return this.getDataValidations(o,t,e)[0]}};Z=te([mt(0,r.IUniverInstanceService),mt(1,r.Inject(W)),mt(2,r.Inject(it)),mt(3,r.Inject(r.LifecycleService))],Z);class lt{constructor(t){$(this,"_rule");this._rule=t!=null?t:{uid:r.generateRandomId(),ranges:void 0,type:r.DataValidationType.CUSTOM}}build(){return new ot(this._rule)}copy(){return new lt({...this._rule,uid:r.generateRandomId()})}getAllowInvalid(){return this._rule.errorStyle!==r.DataValidationErrorStyle.STOP}getCriteriaType(){return this._rule.type}getCriteriaValues(){return[this._rule.operator,this._rule.formula1,this._rule.formula2]}getHelpText(){return this._rule.error}requireCheckbox(t,e){return this._rule.type=r.DataValidationType.CHECKBOX,this._rule.formula1=t,this._rule.formula2=e,this}requireDateAfter(t){return this._rule.type=r.DataValidationType.DATE,this._rule.formula1=t.toLocaleDateString(),this._rule.operator=r.DataValidationOperator.GREATER_THAN,this}requireDateBefore(t){return this._rule.type=r.DataValidationType.DATE,this._rule.formula1=t.toLocaleDateString(),this._rule.formula2=void 0,this._rule.operator=r.DataValidationOperator.LESS_THAN,this}requireDateBetween(t,e){return this._rule.type=r.DataValidationType.DATE,this._rule.formula1=t.toLocaleDateString(),this._rule.formula2=e.toLocaleDateString(),this._rule.operator=r.DataValidationOperator.BETWEEN,this}requireDateEqualTo(t){return this._rule.type=r.DataValidationType.DATE,this._rule.formula1=t.toLocaleDateString(),this._rule.formula2=void 0,this._rule.operator=r.DataValidationOperator.EQUAL,this}requireDateNotBetween(t,e){return this._rule.type=r.DataValidationType.DATE,this._rule.formula1=t.toLocaleDateString(),this._rule.formula2=e.toLocaleDateString(),this._rule.operator=r.DataValidationOperator.NOT_BETWEEN,this}requireDateOnOrAfter(t){return this._rule.type=r.DataValidationType.DATE,this._rule.formula1=t.toLocaleDateString(),this._rule.formula2=void 0,this._rule.operator=r.DataValidationOperator.GREATER_THAN_OR_EQUAL,this}requireDateOnOrBefore(t){return this._rule.type=r.DataValidationType.DATE,this._rule.formula1=t.toLocaleDateString(),this._rule.formula2=void 0,this._rule.operator=r.DataValidationOperator.LESS_THAN_OR_EQUAL,this}requireFormulaSatisfied(t){return this._rule.type=r.DataValidationType.CUSTOM,this._rule.formula1=t,this._rule.formula2=void 0,this}requireNumberBetween(t,e,a){return this._rule.formula1=`${t}`,this._rule.formula2=`${e}`,this._rule.operator=r.DataValidationOperator.BETWEEN,this._rule.type=a?r.DataValidationType.WHOLE:r.DataValidationType.DECIMAL,this}requireNumberEqualTo(t,e){return this._rule.formula1=`${t}`,this._rule.formula2=void 0,this._rule.operator=r.DataValidationOperator.EQUAL,this._rule.type=e?r.DataValidationType.WHOLE:r.DataValidationType.DECIMAL,this}requireNumberGreaterThan(t,e){return this._rule.formula1=`${t}`,this._rule.formula2=void 0,this._rule.operator=r.DataValidationOperator.GREATER_THAN,this._rule.type=e?r.DataValidationType.WHOLE:r.DataValidationType.DECIMAL,this}requireNumberGreaterThanOrEqualTo(t,e){return this._rule.formula1=`${t}`,this._rule.formula2=void 0,this._rule.operator=r.DataValidationOperator.GREATER_THAN_OR_EQUAL,this._rule.type=e?r.DataValidationType.WHOLE:r.DataValidationType.DECIMAL,this}requireNumberLessThan(t,e){return this._rule.formula1=`${t}`,this._rule.formula2=void 0,this._rule.operator=r.DataValidationOperator.LESS_THAN,this._rule.type=e?r.DataValidationType.WHOLE:r.DataValidationType.DECIMAL,this}requireNumberLessThanOrEqualTo(t,e){return this._rule.formula1=`${t}`,this._rule.formula2=void 0,this._rule.operator=r.DataValidationOperator.LESS_THAN_OR_EQUAL,this._rule.type=e?r.DataValidationType.WHOLE:r.DataValidationType.DECIMAL,this}requireNumberNotBetween(t,e,a){return this._rule.formula1=`${t}`,this._rule.formula2=`${e}`,this._rule.operator=r.DataValidationOperator.NOT_BETWEEN,this._rule.type=a?r.DataValidationType.WHOLE:r.DataValidationType.DECIMAL,this}requireNumberNotEqualTo(t,e){return this._rule.formula1=`${t}`,this._rule.formula2=void 0,this._rule.operator=r.DataValidationOperator.NOT_EQUAL,this._rule.type=e?r.DataValidationType.WHOLE:r.DataValidationType.DECIMAL,this}requireValueInList(t,e,a){return this._rule.type=e?r.DataValidationType.LIST_MULTIPLE:r.DataValidationType.LIST,this._rule.formula1=t.join(","),this._rule.formula2=void 0,this._rule.showDropDown=a!=null?a:!0,this}requireValueInRange(t,e,a){return this._rule.type=e?r.DataValidationType.LIST_MULTIPLE:r.DataValidationType.LIST,this._rule.formula1=`=${_t.serializeRangeToRefString({unitId:t.getUnitId(),sheetName:t.getSheetName(),range:t.getRange()})}`,this._rule.formula2=void 0,this._rule.showDropDown=a!=null?a:!0,this}setAllowInvalid(t){return this._rule.errorStyle=t?r.DataValidationErrorStyle.WARNING:r.DataValidationErrorStyle.STOP,this}setHelpText(t){return this._rule.error=t,this._rule.showErrorMessage=!0,this}withCriteriaValues(t,e){return this._rule.type=t,this._rule.operator=e[0],this._rule.formula1=e[1],this._rule.formula2=e[2],this}setOptions(t){return Object.assign(this._rule,t),this}}class ot{constructor(t,e){$(this,"rule");$(this,"_worksheet");this.rule=t,this._worksheet=e}getAllowInvalid(){return this.rule.errorStyle!==r.DataValidationErrorStyle.STOP}getCriteriaType(){return this.rule.type}getCriteriaValues(){return[this.rule.operator,this.rule.formula1,this.rule.formula2]}getHelpText(){return this.rule.error}copy(){return new lt(this.rule)}getApplied(){if(!this._worksheet)return!1;const e=this._worksheet.getInject().get(R.DataValidationModel).getRuleById(this._worksheet.getWorkbook().getUnitId(),this._worksheet.getSheetId(),this.rule.uid);return!!(e&&e.ranges.length)}getRanges(){var i;if(!this.getAllowInvalid())return[];const t=(i=this._worksheet)==null?void 0:i.getWorkbook(),e=this.getSheetId();if(!e)return[];const a=t==null?void 0:t.getSheetBySheetId(e);return!t||!a?[]:this.rule.ranges.map(n=>{var s;return(s=this._worksheet)==null?void 0:s.getInject().createInstance(F.FRange,t,a,n)})}getUnitId(){var t;return(t=this._worksheet)==null?void 0:t.getWorkbook().getUnitId()}getSheetId(){var t;return(t=this._worksheet)==null?void 0:t.getSheetId()}setCriteria(t,e){return this.getApplied()&&!this._worksheet.getInject().get(r.ICommandService).syncExecuteCommand(bt.id,{unitId:this.getUnitId(),subUnitId:this.getSheetId(),ruleId:this.rule.uid,setting:{operator:e[0],formula1:e[1],formula2:e[2],type:this.rule.type}})?!1:(this.rule.operator=e[0],this.rule.formula1=e[1],this.rule.formula2=e[2],this.rule.type=t,!0)}setOptions(t){return this.getApplied()&&!this._worksheet.getInject().get(r.ICommandService).syncExecuteCommand(xt.id,{unitId:this.getUnitId(),subUnitId:this.getSheetId(),ruleId:this.rule.uid,options:{...R.getRuleOptions(this.rule),...t}})?!1:(Object.assign(this.rule,t),!0)}setRanges(t){return this.getApplied()&&!this._worksheet.getInject().get(r.ICommandService).syncExecuteCommand(It.id,{unitId:this.getUnitId(),subUnitId:this.getSheetId(),ruleId:this.rule.uid,ranges:t.map(i=>i.getRange())})?!1:(this.rule.ranges=t,!0)}delete(){return this.getApplied()?this._worksheet.getInject().get(r.ICommandService).syncExecuteCommand($t.id,{unitId:this.getUnitId(),subUnitId:this.getSheetId(),ruleId:this.rule.uid}):!1}}class ee extends F.FRange{async setDataValidation(t){if(!t)return this._commandService.executeCommand(Xt.id,{unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId(),ranges:[this._range]}),this;const e={unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId(),rule:{...t.rule,ranges:[this._range]}};return await this._commandService.executeCommand(Ct.id,e),this}getDataValidation(){const e=this._injector.get(Z).getDataValidation(this._workbook.getUnitId(),this._worksheet.getSheetId(),[this._range]);return e&&new ot(e)}getDataValidations(){return this._injector.get(Z).getDataValidations(this._workbook.getUnitId(),this._worksheet.getSheetId(),[this._range]).map(e=>new ot(e))}async getValidatorStatus(){return this._injector.get(Z).validatorRanges(this._workbook.getUnitId(),this._worksheet.getSheetId(),[this._range])}}F.FRange.extend(ee);class ae{static newDataValidation(){return new lt}}r.FUniver.extend(ae);class ie extends F.FWorkbook{_initialize(){Object.defineProperty(this,"_dataValidationModel",{get(){return this._injector.get(W)}})}getValidatorStatus(){return this._injector.get(Z).validatorWorkbook(this._workbook.getUnitId())}onDataValidationChange(t){return r.toDisposable(this._dataValidationModel.ruleChange$.pipe(K.filter(e=>e.unitId===this._workbook.getUnitId())).subscribe(t))}onDataValidationStatusChange(t){return r.toDisposable(this._dataValidationModel.validStatusChange$.pipe(K.filter(e=>e.unitId===this._workbook.getUnitId())).subscribe(t))}onBeforeAddDataValidation(t){return r.toDisposable(this._commandService.beforeCommandExecuted((e,a)=>{const i=e.params;if(e.id===Ct.id){if(i.unitId!==this._workbook.getUnitId())return;if(t(i,a)===!1)throw new Error("Command is stopped by the hook onBeforeAddDataValidation")}}))}onBeforeUpdateDataValidationCriteria(t){return r.toDisposable(this._commandService.beforeCommandExecuted((e,a)=>{const i=e.params;if(e.id===bt.id){if(i.unitId!==this._workbook.getUnitId())return;if(t(i,a)===!1)throw new Error("Command is stopped by the hook onBeforeUpdateDataValidationCriteria")}}))}onBeforeUpdateDataValidationRange(t){return r.toDisposable(this._commandService.beforeCommandExecuted((e,a)=>{const i=e.params;if(e.id===It.id){if(i.unitId!==this._workbook.getUnitId())return;if(t(i,a)===!1)throw new Error("Command is stopped by the hook onBeforeUpdateDataValidationRange")}}))}onBeforeUpdateDataValidationOptions(t){return r.toDisposable(this._commandService.beforeCommandExecuted((e,a)=>{const i=e.params;if(e.id===xt.id){if(i.unitId!==this._workbook.getUnitId())return;if(t(i,a)===!1)throw new Error("Command is stopped by the hook onBeforeUpdateDataValidationOptions")}}))}onBeforeDeleteDataValidation(t){return r.toDisposable(this._commandService.beforeCommandExecuted((e,a)=>{const i=e.params;if(e.id===$t.id){if(i.unitId!==this._workbook.getUnitId())return;if(t(i,a)===!1)throw new Error("Command is stopped by the hook onBeforeDeleteDataValidation")}}))}onBeforeDeleteAllDataValidation(t){return r.toDisposable(this._commandService.beforeCommandExecuted((e,a)=>{const i=e.params;if(e.id===zt.id){if(i.unitId!==this._workbook.getUnitId())return;if(t(i,a)===!1)throw new Error("Command is stopped by the hook onBeforeDeleteAllDataValidation")}}))}}F.FWorkbook.extend(ie);class re extends F.FWorksheet{getDataValidations(){return this._injector.get(R.DataValidationModel).getRules(this._workbook.getUnitId(),this._worksheet.getSheetId()).map(e=>new ot(e))}getValidatorStatus(){return this._injector.get(Z).validatorWorksheet(this._workbook.getUnitId(),this._worksheet.getSheetId())}}F.FWorksheet.extend(re),k.FDataValidation=ot,k.FDataValidationBuilder=lt,Object.defineProperty(k,Symbol.toStringTag,{value:"Module"})});
|