@univerjs/sheets-filter 0.10.8 → 0.10.9-experimental.20250925-61b61a0
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/cjs/index.js +1 -1
- package/lib/es/index.js +61 -61
- package/lib/index.js +61 -61
- package/lib/umd/index.js +1 -1
- package/package.json +7 -7
- package/LICENSE +0 -176
package/lib/cjs/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var Re=Object.defineProperty;var Fe=(i,r,e)=>r in i?Re(i,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[r]=e;var R=(i,r,e)=>Fe(i,typeof r!="symbol"?r+"":r,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("@univerjs/core"),S=require("@univerjs/sheets"),O=require("rxjs"),ve=require("@univerjs/engine-render"),pe=require("@univerjs/rpc"),K=require("@univerjs/engine-formula"),te="sheet.mutation.set-filter-range",re="sheet.mutation.set-filter-criteria",ne="sheet.mutation.remove-filter",ie="sheet.mutation.re-calc-filter",q=new Set([te,re,ne,ie]);var A=(i=>(i[i.VALUES=0]="VALUES",i[i.COLORS=1]="COLORS",i[i.CONDITIONS=2]="CONDITIONS",i))(A||{}),T=(i=>(i.EQUAL="equal",i.GREATER_THAN="greaterThan",i.GREATER_THAN_OR_EQUAL="greaterThanOrEqual",i.LESS_THAN="lessThan",i.LESS_THAN_OR_EQUAL="lessThanOrEqual",i.NOT_EQUALS="notEqual",i))(T||{});const se={operator:T.GREATER_THAN,fn:(i,r)=>U(i)?i>r:!1},oe={operator:T.GREATER_THAN_OR_EQUAL,fn:(i,r)=>U(i)?i>=r:!1},le={operator:T.LESS_THAN,fn:(i,r)=>U(i)?i<r:!1},ae={operator:T.LESS_THAN_OR_EQUAL,fn:(i,r)=>U(i)?i<=r:!1},ce={operator:T.EQUAL,fn:(i,r)=>U(i)?i===r:!1},k={operator:T.NOT_EQUALS,fn:(i,r)=>{if(typeof r=="string"){if(r===" ")return i!=null;const e=ue(i);return e&&Ee(r)?!he(r).test(e):e!==r}return U(i)?i!==r:!0}},de=new Map([]),we=[se,oe,le,ae,ce,k];we.forEach(i=>{de.set(i.operator,i)});function Me(i){return!!i}const ye={fn:(i,r)=>{const e=ue(i);return e===null?r==="":he(r).test(e)}};function W(i){return i?de.get(i):ye}function U(i){return typeof i=="number"}function Z(i){return!!(typeof i=="number"||typeof i=="string"&&d.isNumeric(i))}function ue(i){return typeof i=="boolean"||i==null?null:typeof i=="string"?i:i.toString()}function Ee(i){return typeof i=="number"?!1:i.indexOf("*")!==-1||i.indexOf("?")!==-1}function he(i){const r=i.replace(/[.+^${}()|[\]\\]/g,"\\$&").replaceAll("?",".").replace(/[*]/g,".$&");return new RegExp(`^${r}$`)}const H=()=>new Set;class $ extends d.Disposable{constructor(e,t,n){super();R(this,"_filteredOutRows$",new O.BehaviorSubject(H()));R(this,"filteredOutRows$",this._filteredOutRows$.asObservable());R(this,"_hasCriteria$",new O.BehaviorSubject(!1));R(this,"hasCriteria$",this._hasCriteria$.asObservable());R(this,"_filterColumnByIndex",new Map);R(this,"_alreadyFilteredOutRows",H());R(this,"_range");this.unitId=e,this.subUnitId=t,this._worksheet=n}get filteredOutRows(){return this._filteredOutRows$.getValue()}set filteredOutRows(e){this._alreadyFilteredOutRows=e,this._filteredOutRows$.next(e)}dispose(){super.dispose(),this._filteredOutRows$.complete(),this._hasCriteria$.complete()}serialize(){const e={ref:d.Rectangle.clone(this._range),filterColumns:this._getAllFilterColumns(!0).sort(([t],[n])=>t-n).map(([t,n])=>n.serialize())};return this._alreadyFilteredOutRows&&(e.cachedFilteredOut=Array.from(this._alreadyFilteredOutRows).sort()),e}static deserialize(e,t,n,s){const o=new $(e,t,n);return o._dump(s),o}_dump(e){var t;this.setRange(e.ref),(t=e.filterColumns)==null||t.forEach(n=>this._setCriteriaWithoutReCalc(n.colId,n)),e.cachedFilteredOut&&(this._alreadyFilteredOutRows=new Set(e.cachedFilteredOut),this._emit()),this._emitHasCriteria()}isRowFiltered(e){return this._alreadyFilteredOutRows.has(e)}getRange(){if(!this._range)throw new Error("[FilterModel] could not get range before a range is set!");return this._range}getFilteredOutRowsExceptCol(e){return this._getAllFilterColumns(!0).filter(([t])=>t!==e).reduce((t,[,n])=>{const s=n.calc({getAlreadyFilteredOutRows:()=>t});return s?d.mergeSets(t,s):t},new Set)}setRange(e){this._range=e,this._getAllFilterColumns(!0).forEach(([t,n])=>{n.setRangeAndColumn({startRow:e.startRow,endRow:e.endRow,startColumn:t,endColumn:t},t)})}setCriteria(e,t,n=!1){if(!this._range)throw new Error("[FilterModel] could not set criteria before a range is set!");if(!t){this._removeCriteria(e),this._rebuildAlreadyFilteredOutRowsWithCache(),n&&this._reCalcAllColumns(),this._emit(),this._emitHasCriteria();return}this._setCriteriaWithoutReCalc(e,t),n&&(this._rebuildAlreadyFilteredOutRowsWithCache(),this._reCalcWithNoCacheColumns(),this._emit(),this._emitHasCriteria())}getAllFilterColumns(){return this._getAllFilterColumns(!0)}getFilterColumn(e){var t;return(t=this._filterColumnByIndex.get(e))!=null?t:null}reCalc(){this._reCalcAllColumns(),this._emit()}_getAllFilterColumns(e=!1){const t=Array.from(this._filterColumnByIndex.entries());return e?t:t.map(([n,s])=>s)}_reCalcAllColumns(){this._alreadyFilteredOutRows=H(),this._getAllFilterColumns().forEach(e=>e.__clearCache()),this._reCalcWithNoCacheColumns()}_setCriteriaWithoutReCalc(e,t){const n=this._range;if(!n)throw new Error("[FilterModel] could not set criteria before a range is set!");const{startColumn:s,endColumn:o}=n;if(e>o||e<s)throw new Error(`[FilterModel] could not set criteria on column ${e} which is out of range!`);let l;this._filterColumnByIndex.has(e)?l=this._filterColumnByIndex.get(e):(l=new me(this.unitId,this.subUnitId,this._worksheet,t,{getAlreadyFilteredOutRows:()=>this._alreadyFilteredOutRows}),l.setRangeAndColumn(n,e),this._filterColumnByIndex.set(e,l)),l.setCriteria(t)}_removeCriteria(e){const t=this._filterColumnByIndex.get(e);t&&(t.dispose(),this._filterColumnByIndex.delete(e))}_emit(){this._filteredOutRows$.next(this._alreadyFilteredOutRows)}_emitHasCriteria(){this._hasCriteria$.next(this._filterColumnByIndex.size>0)}_rebuildAlreadyFilteredOutRowsWithCache(){const e=this._getAllFilterColumns().filter(t=>t.hasCache()).reduce((t,n)=>d.mergeSets(t,n.filteredOutRows),new Set);this._alreadyFilteredOutRows=e}_reCalcWithNoCacheColumns(){const e=this._getAllFilterColumns().filter(t=>!t.hasCache());for(const t of e){const n=t.reCalc();n&&(this._alreadyFilteredOutRows=d.mergeSets(this._alreadyFilteredOutRows,n))}}}class me extends d.Disposable{constructor(e,t,n,s,o){super();R(this,"_filteredOutRows",null);R(this,"_filterFn",null);R(this,"_range",null);R(this,"_column",0);R(this,"_filterBy",A.VALUES);this.unitId=e,this.subUnitId=t,this._worksheet=n,this._criteria=s,this._filterColumnContext=o}get filteredOutRows(){return this._filteredOutRows}get filterBy(){return this._filterBy}dispose(){super.dispose(),this._filteredOutRows=null}__clearCache(){this._filteredOutRows=null}serialize(){if(!this._criteria)throw new Error("[FilterColumn]: could not serialize without a filter column!");return d.Tools.deepClone({...this._criteria,colId:this._column})}hasCache(){return this._filteredOutRows!==null}setRangeAndColumn(e,t){this._range=e,this._column=t}setCriteria(e){this._criteria=e,this._generateFilterFn(),this._filteredOutRows=null}getColumnData(){return d.Tools.deepClone(this._criteria)}reCalc(){return this._filteredOutRows=this.calc(this._filterColumnContext),this._filteredOutRows}calc(e){if(!this._filterFn)throw new Error("[FilterColumn] cannot calculate without a filter fn!");if(!this._range)throw new Error("[FilterColumn] cannot calculate without a range!");if(typeof this._column!="number")throw new TypeError("[FilterColumn] cannot calculate without a column offset!");const t=this._column,n={startColumn:t,endColumn:t,startRow:this._range.startRow+1,endRow:this._range.endRow},s=new Set,o=e.getAlreadyFilteredOutRows();for(const l of this._worksheet.iterateByColumn(n,!1,!1)){const{row:a,rowSpan:c,col:h}=l;if(o.has(a)&&(!c||c===1))continue;if(!(this._filterBy===A.VALUES?this._filterFn(d.extractPureTextFromCell(this._worksheet.getCell(a,h))):this._filterBy===A.COLORS?this._filterFn(this._worksheet.getComposedCellStyle(a,h)):this._filterFn($e(this._worksheet,a,h)))&&(s.add(a),c))for(let m=1;m<c;m++)s.add(a+m)}return s}_generateFilterFn(){this._criteria&&(this._filterFn=Oe(this._criteria),this._filterBy=this._criteria.filters?A.VALUES:this._criteria.colorFilters?A.COLORS:A.CONDITIONS)}}function Oe(i){if(i.filters)return Ie(i.filters);if(i.colorFilters)return Te(i.colorFilters);if(i.customFilters)return Ae(i.customFilters);throw new Error("[FilterModel]: other types of filters are not supported yet.")}function Ie(i){const r=!!i.blank,e=new Set(i.filters);return t=>t===void 0||t===""?r:e.has(typeof t=="string"?t:`${t}`)}function Te(i){if(i.cellFillColors){const r=new Set(i.cellFillColors);return e=>{var n;if(!e||!((n=e.bg)!=null&&n.rgb))return!!r.has(null);const t=new d.ColorKit(e.bg.rgb).toRgbString();return r.has(t)}}if(i.cellTextColors){const r=new Set(i.cellTextColors);return e=>{var n;if(!e||!((n=e.cl)!=null&&n.rgb))return!!r.has(ve.COLOR_BLACK_RGB);const t=new d.ColorKit(e.cl.rgb).toRgbString();return r.has(t)}}throw new Error("[FilterModel]: color filters are not supported yet.")}function Ae(i){const r=i.customFilters.map(e=>Ue(e));return Ne(r)?i.and?be(r):xe(r):r[0]}function be(i){const[r,e]=i;return t=>r(t)&&e(t)}function xe(i){const[r,e]=i;return t=>r(t)||e(t)}function Ne(i){return i.length===2}function Ue(i){const r=i.val;if(i.operator===T.NOT_EQUALS&&!Z(r))return n=>k.fn(n,r);if(Me(i.operator)){if(!Z(r))return()=>!1;const n=W(i.operator),s=Number(r);return o=>n.fn(o,s)}const e=W(i.operator);return t=>e.fn(t,r)}function $e(i,r,e){const t=i.getCell(r,e);if(!t)return null;const n=i.getCellRaw(r,e);return t&&!n?Y(t):n?t.t===d.CellValueType.NUMBER&&typeof t.v=="string"?n.v:Y(n):null}function Y(i){var t,n;const r=(n=(t=i.p)==null?void 0:t.body)==null?void 0:n.dataStream;if(r)return r.trimEnd();const e=i.v;return typeof e=="string"?i.t===d.CellValueType.BOOLEAN?e.toUpperCase():e:typeof e=="number"?i.t===d.CellValueType.BOOLEAN?e?"TRUE":"FALSE":e:typeof e=="boolean"?e?"TRUE":"FALSE":""}var Le=Object.getOwnPropertyDescriptor,Pe=(i,r,e,t)=>{for(var n=t>1?void 0:t?Le(r,e):r,s=i.length-1,o;s>=0;s--)(o=i[s])&&(n=o(n)||n);return n},z=(i,r)=>(e,t)=>r(e,t,i);const G="SHEET_FILTER_PLUGIN";exports.SheetsFilterService=class extends d.Disposable{constructor(e,t,n){super();R(this,"_filterModels",new Map);R(this,"_loadedUnitId$",new O.BehaviorSubject(null));R(this,"loadedUnitId$",this._loadedUnitId$.asObservable());R(this,"_errorMsg$",new O.BehaviorSubject(null));R(this,"errorMsg$",this._errorMsg$.asObservable());R(this,"_activeFilterModel$",new O.BehaviorSubject(null));R(this,"activeFilterModel$",this._activeFilterModel$.asObservable());this._resourcesManagerService=e,this._univerInstanceService=t,this._commandService=n,this._initModel(),this._initActiveFilterModel()}get activeFilterModel(){return this._activeFilterModel$.getValue()}ensureFilterModel(e,t){const n=this.getFilterModel(e,t);if(n)return n;const s=this._univerInstanceService.getUniverSheetInstance(e);if(!s)throw new Error(`[SheetsFilterService]: could not create "FilterModel" on a non-existing workbook ${e}!`);const o=s.getSheetBySheetId(t);if(!o)throw new Error(`[SheetsFilterService]: could not create "FilterModel" on a non-existing worksheet ${t}!`);const l=new $(e,t,o);return this._cacheFilterModel(e,t,l),l}getFilterModel(e,t){var n,s;return(s=(n=this._filterModels.get(e))==null?void 0:n.get(t))!=null?s:null}removeFilterModel(e,t){const n=this.getFilterModel(e,t);return n?(n.dispose(),this._filterModels.get(e).delete(t),!0):!1}setFilterErrorMsg(e){this._errorMsg$.next(e)}_updateActiveFilterModel(){let e;try{if(e=this._univerInstanceService.getCurrentUnitForType(d.UniverInstanceType.UNIVER_SHEET),!e){this._activeFilterModel$.next(null);return}}catch(l){console.error("[SheetsFilterService]: could not get active workbook!",l);return}const t=e.getActiveSheet(!0);if(!t){this._activeFilterModel$.next(null);return}const n=t.getUnitId(),s=t.getSheetId(),o=this.getFilterModel(n,s);this._activeFilterModel$.next(o)}_initActiveFilterModel(){this.disposeWithMe(O.merge(d.fromCallback(this._commandService.onCommandExecuted.bind(this._commandService)).pipe(O.filter(([e])=>e.type===d.CommandType.MUTATION&&q.has(e.id))),this._univerInstanceService.getCurrentTypeOfUnit$(d.UniverInstanceType.UNIVER_SHEET).pipe(O.switchMap(e=>{var t;return(t=e==null?void 0:e.activeSheet$)!=null?t:O.of(null)}))).subscribe(()=>this._updateActiveFilterModel()))}_serializeAutoFiltersForUnit(e){const t=this._filterModels.get(e);if(!t)return"{}";const n={};return t.forEach((s,o)=>{n[o]=s.serialize()}),JSON.stringify(n)}_deserializeAutoFiltersForUnit(e,t){const n=this._univerInstanceService.getUniverSheetInstance(e);Object.keys(t).forEach(s=>{const o=t[s],l=$.deserialize(e,s,n.getSheetBySheetId(s),o);this._cacheFilterModel(e,s,l)})}_initModel(){this._resourcesManagerService.registerPluginResource({pluginName:G,businesses:[d.UniverInstanceType.UNIVER_SHEET],toJson:e=>this._serializeAutoFiltersForUnit(e),parseJson:e=>JSON.parse(e),onLoad:(e,t)=>{this._deserializeAutoFiltersForUnit(e,t),this._loadedUnitId$.next(e),this._updateActiveFilterModel()},onUnLoad:e=>{const t=this._filterModels.get(e);t&&(t.forEach(n=>n.dispose()),this._filterModels.delete(e))}})}_cacheFilterModel(e,t,n){this._filterModels.has(e)||this._filterModels.set(e,new Map),this._filterModels.get(e).set(t,n)}};exports.SheetsFilterService=Pe([z(0,d.IResourceManagerService),z(1,d.IUniverInstanceService),z(2,d.ICommandService)],exports.SheetsFilterService);const F={id:te,type:d.CommandType.MUTATION,handler:(i,r)=>{const{subUnitId:e,unitId:t,range:n}=r;return i.get(exports.SheetsFilterService).ensureFilterModel(t,e).setRange(n),!0}},v={id:re,type:d.CommandType.MUTATION,handler:(i,r)=>{const{subUnitId:e,unitId:t,criteria:n,col:s,reCalc:o=!0}=r,a=i.get(exports.SheetsFilterService).getFilterModel(t,e);return a?(a.setCriteria(s,n,o),!0):!1}},I={id:ne,type:d.CommandType.MUTATION,handler:(i,r)=>{const{unitId:e,subUnitId:t}=r;return i.get(exports.SheetsFilterService).removeFilterModel(e,t)}},N={id:ie,type:d.CommandType.MUTATION,handler:(i,r)=>{const{unitId:e,subUnitId:t}=r,s=i.get(exports.SheetsFilterService).getFilterModel(e,t);return s?(s.reCalc(),!0):!1}},fe={id:"sheet.command.set-filter-range",type:d.CommandType.COMMAND,handler:(i,r)=>{const e=i.get(exports.SheetsFilterService),t=i.get(d.ICommandService),n=i.get(d.IUndoRedoService),s=i.get(d.IUniverInstanceService),{unitId:o,subUnitId:l,range:a}=r;if(!S.getSheetCommandTarget(s,r)||e.getFilterModel(o,l))return!1;if(a.endRow===a.startRow){const C=i.get(d.ErrorService),_=i.get(d.LocaleService);return C.emit(_.t("sheets-filter.command.not-valid-filter-range")),!1}const u={id:F.id,params:{unitId:o,subUnitId:l,range:a}},m=t.syncExecuteCommand(u.id,u.params);return m&&n.pushUndoRedo({unitID:o,undoMutations:[{id:I.id,params:{unitId:o,subUnitId:l}}],redoMutations:[u]}),m}},ge={id:"sheet.command.remove-sheet-filter",type:d.CommandType.COMMAND,handler:(i,r)=>{const e=i.get(d.IUniverInstanceService),t=i.get(exports.SheetsFilterService),n=i.get(d.ICommandService),s=i.get(d.IUndoRedoService),o=S.getSheetCommandTarget(e,r);if(!o)return!1;const{unitId:l,subUnitId:a}=o,c=t.getFilterModel(l,a);if(!c)return!1;const h=c==null?void 0:c.serialize(),u=ze(l,a,h),m=n.syncExecuteCommand(I.id,{unitId:l,subUnitId:a});return m&&s.pushUndoRedo({unitID:l,undoMutations:u,redoMutations:[{id:I.id,params:{unitId:l,subUnitId:a}}]}),m}},De={id:"sheet.command.smart-toggle-filter",type:d.CommandType.COMMAND,handler:async i=>{const r=i.get(d.IUniverInstanceService),e=i.get(exports.SheetsFilterService),t=i.get(d.ICommandService),n=r.getCurrentUnitForType(d.UniverInstanceType.UNIVER_SHEET),s=n==null?void 0:n.getActiveSheet();if(!s||!n)return!1;const o=n.getUnitId(),l=s.getSheetId();if(e.getFilterModel(o,l))return t.executeCommand(ge.id,{unitId:o,subUnitId:l});const h=i.get(S.SheetsSelectionsService).getCurrentLastSelection();if(!h)return!1;const u=h.range,m=S.isSingleCellSelection(h)?S.expandToContinuousRange(u,{left:!0,right:!0,up:!0,down:!0},s):u;return t.executeCommand(fe.id,{unitId:o,subUnitId:l,range:m})}},Be={id:"sheet.command.set-filter-criteria",type:d.CommandType.COMMAND,handler:(i,r)=>{const e=i.get(exports.SheetsFilterService),t=i.get(d.ICommandService),n=i.get(d.IUndoRedoService),{unitId:s,subUnitId:o,col:l,criteria:a}=r,c=e.getFilterModel(s,o);if(!c)return!1;const h=c.getRange();if(!h||l<h.startColumn||l>h.endColumn)return!1;const u=c.getFilterColumn(l),m=We(s,o,l,u),C={id:v.id,params:{unitId:s,subUnitId:o,col:l,criteria:a}},_=t.syncExecuteCommand(C.id,C.params);return _&&n.pushUndoRedo({unitID:s,undoMutations:[m],redoMutations:[C]}),_}},je={id:"sheet.command.clear-filter-criteria",type:d.CommandType.COMMAND,handler:(i,r)=>{const e=i.get(exports.SheetsFilterService),t=i.get(d.IUndoRedoService),n=i.get(d.ICommandService),s=i.get(d.IUniverInstanceService),o=S.getSheetCommandTarget(s,r);if(!o)return!1;const{unitId:l,subUnitId:a}=o,c=e.getFilterModel(o.unitId,o.subUnitId);if(!c)return!1;const h=c.serialize(),u=Ce(l,a,h),m=Ve(l,a,h);return d.sequenceExecute(m,n).result?(t.pushUndoRedo({unitID:l,undoMutations:u,redoMutations:m}),!0):!1}},He={id:"sheet.command.re-calc-filter",type:d.CommandType.COMMAND,handler:(i,r)=>{const e=i.get(exports.SheetsFilterService),t=i.get(d.ICommandService),n=i.get(d.IUniverInstanceService),s=S.getSheetCommandTarget(n,r);if(!s)return!1;const{unitId:o,subUnitId:l}=s;return e.getFilterModel(s.unitId,s.subUnitId)?t.executeCommand(N.id,{unitId:o,subUnitId:l}):!1}};function ze(i,r,e){const t=[],n={id:F.id,params:{unitId:i,subUnitId:r,range:e.ref}};return t.push(n),Ce(i,r,e).forEach(o=>t.push(o)),t}function Ce(i,r,e){var n;const t=[];return(n=e.filterColumns)==null||n.forEach(s=>{const o={id:v.id,params:{unitId:i,subUnitId:r,col:s.colId,criteria:s}};t.push(o)}),t}function Ve(i,r,e){var n;const t=[];return(n=e.filterColumns)==null||n.forEach(s=>{const o={id:v.id,params:{unitId:i,subUnitId:r,col:s.colId,criteria:null}};t.push(o)}),t}function We(i,r,e,t){if(!t)return{id:v.id,params:{unitId:i,subUnitId:r,col:e,criteria:null}};const n=t.serialize();return{id:v.id,params:{unitId:i,subUnitId:r,col:e,criteria:n}}}const _e="sheets-filter.config",X={};function qe(i,r){for(let e=0;e<i.length;e++){let t=e;if(i[e])for(let n=e+1;n<i.length;n++)i[t]&&i[n]&&r(i[t],i[n])&&(i[t]=null,t=n)}return i.filter(e=>e!==null)}function x(i){return qe(i,(r,e)=>r.id===v.id&&e.id===v.id&&r.params.unitId===e.params.unitId&&r.params.subUnitId===e.params.subUnitId&&r.params.col===e.params.col)}var ke=Object.getOwnPropertyDescriptor,Ge=(i,r,e,t)=>{for(var n=t>1?void 0:t?ke(r,e):r,s=i.length-1,o;s>=0;s--)(o=i[s])&&(n=o(n)||n);return n},b=(i,r)=>(e,t)=>r(e,t,i);let L=class extends d.Disposable{constructor(r,e,t,n,s,o,l){super();R(this,"_disposableCollection",new d.DisposableCollection);this._commandService=r,this._sheetInterceptorService=e,this._sheetsFilterService=t,this._univerInstanceService=n,this._refRangeService=s,this._dataSyncPrimaryController=o,this._zebraCrossingCacheController=l,this._initCommands(),this._initRowFilteredInterceptor(),this._initInterceptors(),this._commandExecutedListener(),this._initErrorHandling(),this._initZebraCrossingCacheListener()}_initZebraCrossingCacheListener(){this.disposeWithMe(this._sheetsFilterService.activeFilterModel$.subscribe(r=>{r&&this.disposeWithMe(r.filteredOutRows$.subscribe(()=>{this._zebraCrossingCacheController.updateZebraCrossingCache(r.unitId,r.subUnitId)}))}))}_initCommands(){[v,F,N,I].forEach(r=>{var e;this.disposeWithMe(this._commandService.registerCommand(r)),(e=this._dataSyncPrimaryController)==null||e.registerSyncingMutations(r)})}_initInterceptors(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:r=>this._getUpdateFilter(r)})),this.disposeWithMe(this._commandService.onCommandExecuted(r=>{if(r.id===S.SetWorksheetActiveOperation.id){const e=r.params,t=e.subUnitId,n=e.unitId;if(!t||!n)return;this._registerRefRange(n,t)}if(r.id===F.id){const e=r.params,t=e.subUnitId,n=e.unitId;if(!t||!n)return;this._registerRefRange(e.unitId,e.subUnitId)}})),this.disposeWithMe(this._sheetsFilterService.loadedUnitId$.subscribe(r=>{if(r){const e=this._univerInstanceService.getUniverSheetInstance(r),t=e==null?void 0:e.getActiveSheet();t&&this._registerRefRange(r,t.getSheetId())}}))}_registerRefRange(r,e){var l;this._disposableCollection.dispose();const t=this._univerInstanceService.getUniverSheetInstance(r),n=t==null?void 0:t.getSheetBySheetId(e);if(!t||!n)return;const s=(l=this._sheetsFilterService.getFilterModel(r,e))==null?void 0:l.getRange(),o=a=>{switch(a.id){case S.InsertRowCommand.id:{const c=a.params,h=c.unitId||r,u=c.subUnitId||e;return this._handleInsertRowCommand(c,h,u)}case S.InsertColCommand.id:{const c=a.params,h=c.unitId||r,u=c.subUnitId||e;return this.handleInsertColCommand(c.range,h,u)}case S.RemoveColCommand.id:{const c=a.params;return this.handleRemoveColCommand(c.range,r,e)}case S.RemoveRowCommand.id:{const c=a.params;return this._handleRemoveRowCommand(c,r,e)}case S.EffectRefRangId.MoveColsCommandId:{const c=a.params;return this.handleMoveColsCommand({fromRange:c.fromRange,toRange:c.toRange},r,e)}case S.EffectRefRangId.MoveRowsCommandId:{const c=a.params;return this._handleMoveRowsCommand(c,r,e)}case S.MoveRangeCommand.id:{const c=a.params;return this._handleMoveRangeCommand(c,r,e)}}return{redos:[],undos:[]}};s&&this._disposableCollection.add(this._refRangeService.registerRefRange(s,o,r,e))}_getUpdateFilter(r){const{id:e}=r;switch(e){case S.RemoveSheetCommand.id:{const t=r.params;return this._handleRemoveSheetCommand(t,t.unitId,t.subUnitId)}case S.CopySheetCommand.id:{const t=r.params,{targetSubUnitId:n,unitId:s,subUnitId:o}=t;return!s||!o||!n?this._handleNull():this._handleCopySheetCommand(s,o,n)}}return{redos:[],undos:[]}}handleInsertColCommand(r,e,t){var f;const n=this._sheetsFilterService.getFilterModel(e,t),s=(f=n==null?void 0:n.getRange())!=null?f:null;if(!n||!s)return this._handleNull();const{startColumn:o,endColumn:l}=s,{startColumn:a,endColumn:c}=r,h=c-a+1;if(c>l)return this._handleNull();const u=[],m=[],C=a,_={unitId:e,subUnitId:t,range:{...s,startColumn:a<=o?o+h:o,endColumn:l+h}},p={unitId:e,subUnitId:t,range:s};u.push({id:F.id,params:_}),m.push({id:F.id,params:p});const w=n.getAllFilterColumns().filter(g=>g[0]>=C);if(w.length!==0){const{newRange:g,oldRange:y}=this._moveCriteria(e,t,w,h);u.push(...y.redos,...g.redos),m.push(...g.undos,...y.undos)}return{redos:x(u),undos:x(m)}}_handleInsertRowCommand(r,e,t){var p;const n=this._sheetsFilterService.getFilterModel(e,t),s=(p=n==null?void 0:n.getRange())!=null?p:null;if(!n||!s)return this._handleNull();const{startRow:o,endRow:l}=s,{startRow:a,endRow:c}=r.range,h=c-a+1;if(c>l)return this._handleNull();const u=[],m=[],C={unitId:e,subUnitId:t,range:{...s,startRow:a<=o?o+h:o,endRow:l+h}},_={unitId:e,subUnitId:t,range:s};return u.push({id:F.id,params:C}),m.push({id:F.id,params:_}),{redos:x(u),undos:x(m)}}handleRemoveColCommand(r,e,t){var w;const n=this._sheetsFilterService.getFilterModel(e,t),s=(w=n==null?void 0:n.getRange())!=null?w:null;if(!n||!s)return this._handleNull();const{startColumn:o,endColumn:l}=s,{startColumn:a,endColumn:c}=r;if(a>l)return this._handleNull();const h=[],u=[],m=c<o?0:Math.min(c,l)-Math.max(a,o)+1,C=c-a+1,_=n.getAllFilterColumns();_.forEach(f=>{const[g,y]=f;g<=c&&g>=a&&(h.push({id:v.id,params:{unitId:e,subUnitId:t,col:g,criteria:null}}),u.push({id:v.id,params:{unitId:e,subUnitId:t,col:g,criteria:{...y.serialize(),colId:g}}}))});const p=_.filter(f=>{const[g,y]=f;return g>c});let M={undos:[],redos:[]};if(p.length>0){const{oldRange:f,newRange:g}=this._moveCriteria(e,t,p,-C);M=g,h.push(...f.redos),u.unshift(...f.undos)}if(m===l-o+1){const f={unitId:e,subUnitId:t};h.push({id:I.id,params:f}),u.unshift({id:F.id,params:{range:s,unitId:e,subUnitId:t}})}else{const f=o<=a?o:m===0?o-C:a,g=o<=a?l-m:l-C,y={unitId:e,subUnitId:t,range:{...s,startColumn:f,endColumn:g}};h.push({id:F.id,params:y}),u.unshift({id:F.id,params:{range:s,unitId:e,subUnitId:t}}),h.push(...M.redos),u.unshift(...M.undos)}return{undos:u,redos:h}}_handleRemoveRowCommand(r,e,t){var p;const n=this._sheetsFilterService.getFilterModel(e,t);if(!n)return this._handleNull();const s=n.getRange(),{startRow:o,endRow:l}=s,{startRow:a,endRow:c}=r.range;if(a>l)return this._handleNull();if(c<o)return{undos:[{id:F.id,params:{range:s,unitId:e,subUnitId:t}}],redos:[{id:F.id,params:{range:{...s,startRow:o-(c-a+1),endRow:l-(c-a+1)},unitId:e,subUnitId:t}}]};const h=[],u=[],m=n.getAllFilterColumns(),C=o<=c&&o>=a;u.push({id:F.id,params:{range:s,unitId:e,subUnitId:t}});const _=Math.min(c,l)-Math.max(a,o)+1;if(_===l-o+1||C){const M={unitId:e,subUnitId:t};h.push({id:I.id,params:M}),m.forEach(w=>{const[f,g]=w,y={unitId:e,subUnitId:t,col:f,criteria:{...g.serialize(),colId:f}};u.push({id:v.id,params:y})})}else{const M=(p=this._univerInstanceService.getUniverSheetInstance(e))==null?void 0:p.getSheetBySheetId(t);if(!M)return this._handleNull();const w=[];for(let E=a;E<=c;E++)M.getRowFiltered(E)&&w.push(E);const f=Math.min(o,a),g=f+(l-o)-_+w.length,y={unitId:e,subUnitId:t,range:{...s,startRow:f,endRow:g}};h.push({id:F.id,params:y})}return{undos:x(u),redos:x(h)}}handleMoveColsCommand({fromRange:r,toRange:e},t,n){var w;const s=this._sheetsFilterService.getFilterModel(t,n),o=(w=s==null?void 0:s.getRange())!=null?w:null;if(!s||!o)return this._handleNull();const{startColumn:l,endColumn:a}=o;if(r.endColumn<l&&e.startColumn<=l||r.startColumn>a&&e.endColumn>a)return this._handleNull();const c=[],h=[],u={};for(let f=l;f<=a;f++)u[f]={colIndex:f,filter:s.getFilterColumn(f)};d.moveMatrixArray(r.startColumn,r.endColumn-r.startColumn+1,e.startColumn,u);let m=o.startColumn,C=o.endColumn;l>=r.startColumn&&l<=r.endColumn&&e.startColumn>r.startColumn&&r.endColumn<a&&(m=r.endColumn+1),a>=r.startColumn&&a<=r.endColumn&&e.startColumn<r.startColumn&&r.startColumn>l&&(C=r.startColumn-1);const _=Object.keys(u).map(f=>Number(f)),p=_.find(f=>u[f].colIndex===C),M=_.find(f=>u[f].colIndex===m);if(_.forEach(f=>{var Q,J;const{colIndex:g,filter:y}=u[f],E=f;if(y){if(E>=M&&E<=p){const j={unitId:t,subUnitId:n,col:E,criteria:{...y.serialize(),colId:E}},Se={unitId:t,subUnitId:n,col:E,criteria:s.getFilterColumn(E)?{...(Q=s.getFilterColumn(E))==null?void 0:Q.serialize(),colId:E}:null};c.push({id:v.id,params:j}),h.push({id:v.id,params:Se})}if(!((J=u[g])!=null&&J.filter)){const j={unitId:t,subUnitId:n,col:g,criteria:null};c.push({id:v.id,params:j}),h.push({id:v.id,params:{unitId:t,subUnitId:n,col:g,criteria:{...y.serialize(),colId:g}}})}}}),l!==M||a!==p){const f={unitId:t,subUnitId:n,range:{...o,startColumn:M,endColumn:p}};c.unshift({id:F.id,params:f}),h.unshift({id:F.id,params:{range:o,unitId:t,subUnitId:n}})}return{undos:h,redos:c}}_handleMoveRowsCommand(r,e,t){var f;const n=this._sheetsFilterService.getFilterModel(e,t),s=(f=n==null?void 0:n.getRange())!=null?f:null;if(!n||!s)return this._handleNull();const{startRow:o,endRow:l}=s,{fromRange:a,toRange:c}=r;if(a.endRow<o&&c.startRow<=o||a.startRow>l&&c.endRow>l)return this._handleNull();const h=[],u=[],m={};for(let g=o;g<=l;g++)m[g]={oldIndex:g};const C=o;let _=l;l>=a.startRow&&l<=a.endRow&&c.startRow<a.startRow&&a.startRow>o&&(_=a.startRow-1),d.moveMatrixArray(a.startRow,a.endRow-a.startRow+1,c.startRow,m);const p=Object.keys(m).map(g=>Number(g)),M=p.find(g=>m[g].oldIndex===_),w=p.find(g=>m[g].oldIndex===C);if(o!==w||l!==M){const g={unitId:e,subUnitId:t,range:{...s,startRow:w,endRow:M}};h.push({id:F.id,params:g},{id:N.id,params:{unitId:e,subUnitId:t}}),u.push({id:F.id,params:{range:s,unitId:e,subUnitId:t}},{id:N.id,params:{unitId:e,subUnitId:t}})}return{redos:h,undos:u}}_handleMoveRangeCommand(r,e,t){const{fromRange:n,toRange:s}=r,o=this._sheetsFilterService.getFilterModel(e,t);if(!o)return this._handleNull();const l=o.getRange();if(!l)return this._handleNull();const a=[],c=[];if(d.Rectangle.contains(n,l)){const h=l.startRow-n.startRow,u=l.startColumn-n.startColumn,m={startRow:s.startRow+h,startColumn:s.startColumn+u,endRow:s.startRow+h+(l.endRow-l.startRow),endColumn:s.startColumn+u+(l.endColumn-l.startColumn)},C={id:I.id,params:{unitId:e,subUnitId:t}},_={id:F.id,params:{unitId:e,subUnitId:t,range:m}},p={id:F.id,params:{unitId:e,subUnitId:t,range:l}};a.push(C,_),c.push(C,p);const M=o.getAllFilterColumns(),w=s.startColumn-n.startColumn;M.forEach(f=>{const[g,y]=f;y&&(a.push({id:v.id,params:{unitId:e,subUnitId:t,col:g+w,criteria:{...y.serialize(),colId:g+w}}}),c.push({id:v.id,params:{unitId:e,subUnitId:t,col:g,criteria:{...y.serialize(),colId:g}}}))})}else if(d.Rectangle.intersects(s,l)){const h={...l,endRow:Math.max(l.endRow,s.endRow)};a.push({id:F.id,params:{unitId:e,subUnitId:t,range:h}}),c.push({id:F.id,params:{unitId:e,subUnitId:t,range:l}})}return{redos:a,undos:c}}_handleRemoveSheetCommand(r,e,t){const n=this._sheetsFilterService.getFilterModel(e,t);if(!n)return this._handleNull();const s=n.getRange();if(!s)return this._handleNull();const o=[],l=[];return n.getAllFilterColumns().forEach(([c,h])=>{l.push({id:v.id,params:{unitId:e,subUnitId:t,col:c,criteria:{...h.serialize(),colId:c}}})}),o.push({id:I.id,params:{unitId:e,subUnitId:t,range:s}}),l.unshift({id:F.id,params:{range:s,unitId:e,subUnitId:t}}),{undos:l,redos:o}}_handleCopySheetCommand(r,e,t){const n=this._sheetsFilterService.getFilterModel(r,e);if(!n)return this._handleNull();const s=n.getRange();if(!s)return this._handleNull();const o=[],l=[],a=[],c=[];return n.getAllFilterColumns().forEach(([u,m])=>{o.push({id:v.id,params:{unitId:r,subUnitId:t,col:u,criteria:{...m.serialize(),colId:u}}}),a.push({id:v.id,params:{unitId:r,subUnitId:t,col:u,criteria:null}})}),a.push({id:I.id,params:{unitId:r,subUnitId:t,range:s}}),o.unshift({id:F.id,params:{range:s,unitId:r,subUnitId:t}}),{undos:l,redos:o,preUndos:a,preRedos:c}}_handleNull(){return{redos:[],undos:[]}}_initRowFilteredInterceptor(){this.disposeWithMe(this._sheetInterceptorService.intercept(S.INTERCEPTOR_POINT.ROW_FILTERED,{handler:(r,e)=>{var t,n;return r?!0:(n=(t=this._sheetsFilterService.getFilterModel(e.unitId,e.subUnitId))==null?void 0:t.isRowFiltered(e.row))!=null?n:!1}}))}_moveCriteria(r,e,t,n){const s={unitId:r,subUnitId:e,criteria:null,col:-1},o=[],l=[],a=[],c=[];return t.forEach(h=>{const[u,m]=h;l.push({id:v.id,params:{...s,col:u}}),o.push({id:v.id,params:{...s,col:u,criteria:{...m.serialize(),colId:u}}})}),t.forEach(h=>{const[u,m]=h;c.push({id:v.id,params:{...s,col:u+n,criteria:{...m.serialize(),colId:u+n}}}),a.push({id:v.id,params:{...s,col:u+n,criteria:null}})}),{newRange:{redos:c,undos:a},oldRange:{redos:l,undos:o}}}_commandExecutedListener(){this.disposeWithMe(this._commandService.onCommandExecuted((r,e)=>{var c,h;const{unitId:t,subUnitId:n}=r.params||{},s=this._sheetsFilterService.getFilterModel(t,n);if(!s)return;const o=Array.from(s.filteredOutRows).sort((u,m)=>u-m),l=[];let a=!1;if(r.id===S.RemoveRowMutation.id){const{startRow:u,endRow:m}=r.params.range,C=o.filter(_=>_>=u&&_<=m);o.forEach(_=>{if(_<u)l.push(_);else if(a=!0,_<=m){const p=Math.max(u,l.length?l[l.length-1]+1:u);l.push(p)}else l.push(_-(m-u+1-C.length))})}if(r.id===S.InsertRowMutation.id){const{startRow:u,endRow:m}=r.params.range;o.forEach(C=>{C>=u?(a=!0,l.push(C+(m-u+1))):l.push(C)})}if(a&&(s.filteredOutRows=new Set(l)),r.id===S.SetRangeValuesMutation.id&&!(e!=null&&e.onlyLocal)){const u=this._getExtendRegion(t,n);if(u){const m=r.params.cellValue;if(m)for(let C=u.startColumn;C<=u.endColumn;C++){const _=(c=m==null?void 0:m[u.startRow])==null?void 0:c[C];if(_&&this._cellHasValue(_)){const p=(h=this._univerInstanceService.getUnit(t))==null?void 0:h.getSheetBySheetId(n);if(p){const M=S.expandToContinuousRange(u,{down:!0},p),w=this._sheetsFilterService.getFilterModel(t,n),f=w.getRange();w.setRange({...f,endRow:M.endRow}),this._registerRefRange(t,n)}}}}}}))}_getExtendRegion(r,e){var a;const t=this._sheetsFilterService.getFilterModel(r,e);if(!t)return null;const n=(a=this._univerInstanceService.getUnit(r))==null?void 0:a.getSheetBySheetId(e);if(!n)return null;const s=t.getRange();if(!s)return null;const o=n.getRowCount()-1,l=n.getRowManager();for(let c=s.endRow+1;c<=o;c++)if(l.getRowRawVisible(c))return{startRow:c,endRow:c,startColumn:s.startColumn,endColumn:s.endColumn};return null}_initErrorHandling(){this.disposeWithMe(this._commandService.beforeCommandExecuted(r=>{const e=r.params,t=S.getSheetCommandTarget(this._univerInstanceService);if(!t)return;const{subUnitId:n,unitId:s}=t,o=this._sheetsFilterService.getFilterModel(s,n);if(!o)return;const l=o.getRange();if(r.id===S.MoveRowsCommand.id&&e.fromRange.startRow<=l.startRow&&e.fromRange.endRow<l.endRow&&e.fromRange.endRow>=l.startRow)throw this._sheetsFilterService.setFilterErrorMsg("sheets-filter.msg.filter-header-forbidden"),new Error("[SheetsFilterController]: Cannot move header row of filter")}))}_cellHasValue(r){const e=Object.values(r);return!(e.length===0||e.every(t=>t==null))}};L=Ge([b(0,d.ICommandService),b(1,d.Inject(S.SheetInterceptorService)),b(2,d.Inject(exports.SheetsFilterService)),b(3,d.IUniverInstanceService),b(4,d.Inject(S.RefRangeService)),b(5,d.Optional(pe.DataSyncPrimaryController)),b(6,d.Inject(S.ZebraCrossingCacheController))],L);var Qe=Object.getOwnPropertyDescriptor,Je=(i,r,e,t)=>{for(var n=t>1?void 0:t?Qe(r,e):r,s=i.length-1,o;s>=0;s--)(o=i[s])&&(n=o(n)||n);return n},V=(i,r)=>(e,t)=>r(e,t,i);const Ke=[v.id,N.id],Ze=[S.InsertColMutation.id,S.RemoveColMutation.id,S.MoveColsMutation.id];exports.SheetsFilterSyncController=class extends d.Disposable{constructor(e,t,n){super();R(this,"_d",new d.DisposableCollection);R(this,"_visible$",new O.BehaviorSubject(!1));R(this,"visible$",this._visible$.asObservable());R(this,"_enabled$",new O.BehaviorSubject(!0));R(this,"enabled$",this._enabled$.asObservable());this._sheetsFilterController=e,this._commandService=t,this._configService=n;const s=this._configService.getConfig(_e);s!=null&&s.enableSyncSwitch&&this._visible$.next(!0)}get visible(){return this._visible$.getValue()}get enabled(){return this._enabled$.getValue()}setEnabled(e){this._enabled$.next(e),e?this._d.dispose():this._initOnlyLocalListener()}_initOnlyLocalListener(){this._d.add(this._commandService.beforeCommandExecuted((e,t)=>{Ke.includes(e.id)&&(t||(t={}),t.onlyLocal=!0)})),this._d.add(this._commandService.onCommandExecuted((e,t)=>{if(Ze.includes(e.id)&&(t!=null&&t.fromCollab)){if(e.id===S.InsertColMutation.id){const{range:n,unitId:s,subUnitId:o}=e.params,{redos:l}=this._sheetsFilterController.handleInsertColCommand(n,s,o);d.sequenceExecute(l,this._commandService,t)}else if(e.id===S.RemoveColMutation.id){const{range:n,unitId:s,subUnitId:o}=e.params,{redos:l}=this._sheetsFilterController.handleRemoveColCommand(n,s,o);d.sequenceExecute(l,this._commandService,t)}else if(e.id===S.MoveColsMutation.id){const{sourceRange:n,targetRange:s,unitId:o,subUnitId:l}=e.params,{redos:a}=this._sheetsFilterController.handleMoveColsCommand({fromRange:n,toRange:s},o,l);d.sequenceExecute(a,this._commandService,t)}}}))}};exports.SheetsFilterSyncController=Je([V(0,d.Inject(L)),V(1,d.ICommandService),V(2,d.IConfigService)],exports.SheetsFilterSyncController);var Ye=Object.getOwnPropertyDescriptor,Xe=(i,r,e,t)=>{for(var n=t>1?void 0:t?Ye(r,e):r,s=i.length-1,o;s>=0;s--)(o=i[s])&&(n=o(n)||n);return n},P=(i,r)=>(e,t)=>r(e,t,i);let B=class extends d.Disposable{constructor(i,r,e,t){super(),this._activeDirtyManagerService=i,this._sheetRowFilteredService=r,this._sheetsFilterService=e,this._univerInstanceService=t,this._initFormulaDirtyRange(),this._registerSheetRowFiltered()}_initFormulaDirtyRange(){q.forEach(i=>{this._activeDirtyManagerService.register(i,{commandId:i,getDirtyData:r=>{const e=r.params,{unitId:t,subUnitId:n}=e;return{dirtyRanges:this._getHideRowMutation(t,n),clearDependencyTreeCache:{[t]:{[n]:"1"}}}}})})}_getHideRowMutation(i,r){var l,a;const e=(l=this._sheetsFilterService.getFilterModel(i,r))==null?void 0:l.getRange(),t=(a=this._univerInstanceService.getUnit(i))==null?void 0:a.getSheetBySheetId(r);if(e==null||t==null)return[];const{startRow:n,endRow:s}=e;return[{unitId:i,sheetId:r,range:{startRow:n,startColumn:0,endRow:s,endColumn:t.getColumnCount()-1}}]}_registerSheetRowFiltered(){this._sheetRowFilteredService.register((i,r,e)=>{var t,n;return(n=(t=this._sheetsFilterService.getFilterModel(i,r))==null?void 0:t.isRowFiltered(e))!=null?n:!1})}};B=Xe([P(0,d.Inject(K.IActiveDirtyManagerService)),P(1,d.Inject(K.ISheetRowFilteredService)),P(2,d.Inject(exports.SheetsFilterService)),P(3,d.IUniverInstanceService)],B);var et=Object.getOwnPropertyDescriptor,tt=(i,r,e,t)=>{for(var n=t>1?void 0:t?et(r,e):r,s=i.length-1,o;s>=0;s--)(o=i[s])&&(n=o(n)||n);return n},ee=(i,r)=>(e,t)=>r(e,t,i),D;exports.UniverSheetsFilterPlugin=(D=class extends d.Plugin{constructor(r=X,e,t){super(),this._config=r,this._injector=e,this._configService=t;const{...n}=d.merge({},X,this._config);this._configService.setConfig(_e,n)}onStarting(){[[B],[exports.SheetsFilterService],[L],[exports.SheetsFilterSyncController]].forEach(r=>this._injector.add(r))}onReady(){d.touchDependencies(this._injector,[[B],[L],[exports.SheetsFilterSyncController]])}},R(D,"type",d.UniverInstanceType.UNIVER_SHEET),R(D,"pluginName",G),D);exports.UniverSheetsFilterPlugin=tt([ee(1,d.Inject(d.Injector)),ee(2,d.IConfigService)],exports.UniverSheetsFilterPlugin);exports.ClearSheetsFilterCriteriaCommand=je;exports.CustomFilterOperator=T;exports.FILTER_MUTATIONS=q;exports.FilterBy=A;exports.FilterColumn=me;exports.FilterModel=$;exports.ReCalcSheetsFilterCommand=He;exports.ReCalcSheetsFilterMutation=N;exports.RemoveSheetFilterCommand=ge;exports.RemoveSheetsFilterMutation=I;exports.SHEET_FILTER_SNAPSHOT_ID=G;exports.SetSheetFilterRangeCommand=fe;exports.SetSheetsFilterCriteriaCommand=Be;exports.SetSheetsFilterCriteriaMutation=v;exports.SetSheetsFilterRangeMutation=F;exports.SmartToggleSheetsFilterCommand=De;exports.equals=ce;exports.getCustomFilterFn=W;exports.greaterThan=se;exports.greaterThanOrEqualTo=oe;exports.lessThan=le;exports.lessThanOrEqualTo=ae;exports.notEquals=k;
|
|
1
|
+
"use strict";var Re=Object.defineProperty;var Fe=(i,n,e)=>n in i?Re(i,n,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[n]=e;var R=(i,n,e)=>Fe(i,typeof n!="symbol"?n+"":n,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("@univerjs/core"),S=require("@univerjs/sheets"),O=require("rxjs"),ve=require("@univerjs/engine-render"),pe=require("@univerjs/rpc"),K=require("@univerjs/engine-formula"),te="sheet.mutation.set-filter-range",re="sheet.mutation.set-filter-criteria",ne="sheet.mutation.remove-filter",ie="sheet.mutation.re-calc-filter",q=new Set([te,re,ne,ie]);var A=(i=>(i[i.VALUES=0]="VALUES",i[i.COLORS=1]="COLORS",i[i.CONDITIONS=2]="CONDITIONS",i))(A||{}),T=(i=>(i.EQUAL="equal",i.GREATER_THAN="greaterThan",i.GREATER_THAN_OR_EQUAL="greaterThanOrEqual",i.LESS_THAN="lessThan",i.LESS_THAN_OR_EQUAL="lessThanOrEqual",i.NOT_EQUALS="notEqual",i))(T||{});const se={operator:T.GREATER_THAN,fn:(i,n)=>U(i)?i>n:!1},oe={operator:T.GREATER_THAN_OR_EQUAL,fn:(i,n)=>U(i)?i>=n:!1},le={operator:T.LESS_THAN,fn:(i,n)=>U(i)?i<n:!1},ae={operator:T.LESS_THAN_OR_EQUAL,fn:(i,n)=>U(i)?i<=n:!1},ce={operator:T.EQUAL,fn:(i,n)=>U(i)?i===n:!1},k={operator:T.NOT_EQUALS,fn:(i,n)=>{if(typeof n=="string"){if(n===" ")return i!=null;const e=ue(i);return e&&Ee(n)?!he(n).test(e):e!==n}return U(i)?i!==n:!0}},de=new Map([]),we=[se,oe,le,ae,ce,k];we.forEach(i=>{de.set(i.operator,i)});function Me(i){return!!i}const ye={fn:(i,n)=>{const e=ue(i);return e===null?n==="":he(n).test(e)}};function W(i){return i?de.get(i):ye}function U(i){return typeof i=="number"}function Z(i){return!!(typeof i=="number"||typeof i=="string"&&d.isNumeric(i))}function ue(i){return typeof i=="boolean"||i==null?null:typeof i=="string"?i:i.toString()}function Ee(i){return typeof i=="number"?!1:i.indexOf("*")!==-1||i.indexOf("?")!==-1}function he(i){const n=i.replace(/[.+^${}()|[\]\\]/g,"\\$&").replaceAll("?",".").replace(/[*]/g,".$&");return new RegExp(`^${n}$`)}const H=()=>new Set;class $ extends d.Disposable{constructor(e,t,r){super();R(this,"_filteredOutRows$",new O.BehaviorSubject(H()));R(this,"filteredOutRows$",this._filteredOutRows$.asObservable());R(this,"_hasCriteria$",new O.BehaviorSubject(!1));R(this,"hasCriteria$",this._hasCriteria$.asObservable());R(this,"_filterColumnByIndex",new Map);R(this,"_alreadyFilteredOutRows",H());R(this,"_range");this.unitId=e,this.subUnitId=t,this._worksheet=r}get filteredOutRows(){return this._filteredOutRows$.getValue()}set filteredOutRows(e){this._alreadyFilteredOutRows=e,this._filteredOutRows$.next(e)}dispose(){super.dispose(),this._filteredOutRows$.complete(),this._hasCriteria$.complete()}serialize(){const e={ref:d.Rectangle.clone(this._range),filterColumns:this._getAllFilterColumns(!0).sort(([t],[r])=>t-r).map(([t,r])=>r.serialize())};return this._alreadyFilteredOutRows&&(e.cachedFilteredOut=Array.from(this._alreadyFilteredOutRows).sort()),e}static deserialize(e,t,r,s){const o=new $(e,t,r);return o._dump(s),o}_dump(e){var t;this.setRange(e.ref),(t=e.filterColumns)==null||t.forEach(r=>this._setCriteriaWithoutReCalc(r.colId,r)),e.cachedFilteredOut&&(this._alreadyFilteredOutRows=new Set(e.cachedFilteredOut),this._emit()),this._emitHasCriteria()}isRowFiltered(e){return this._alreadyFilteredOutRows.has(e)}getRange(){if(!this._range)throw new Error("[FilterModel] could not get range before a range is set!");return this._range}getFilteredOutRowsExceptCol(e){return this._getAllFilterColumns(!0).filter(([t])=>t!==e).reduce((t,[,r])=>{const s=r.calc({getAlreadyFilteredOutRows:()=>t});return s?d.mergeSets(t,s):t},new Set)}setRange(e){this._range=e,this._getAllFilterColumns(!0).forEach(([t,r])=>{r.setRangeAndColumn({startRow:e.startRow,endRow:e.endRow,startColumn:t,endColumn:t},t)})}setCriteria(e,t,r=!1){if(!this._range)throw new Error("[FilterModel] could not set criteria before a range is set!");if(!t){this._removeCriteria(e),this._rebuildAlreadyFilteredOutRowsWithCache(),r&&this._reCalcAllColumns(),this._emit(),this._emitHasCriteria();return}this._setCriteriaWithoutReCalc(e,t),r&&(this._rebuildAlreadyFilteredOutRowsWithCache(),this._reCalcWithNoCacheColumns(),this._emit(),this._emitHasCriteria())}getAllFilterColumns(){return this._getAllFilterColumns(!0)}getFilterColumn(e){var t;return(t=this._filterColumnByIndex.get(e))!=null?t:null}reCalc(){this._reCalcAllColumns(),this._emit()}_getAllFilterColumns(e=!1){const t=Array.from(this._filterColumnByIndex.entries());return e?t:t.map(([r,s])=>s)}_reCalcAllColumns(){this._alreadyFilteredOutRows=H(),this._getAllFilterColumns().forEach(e=>e.__clearCache()),this._reCalcWithNoCacheColumns()}_setCriteriaWithoutReCalc(e,t){const r=this._range;if(!r)throw new Error("[FilterModel] could not set criteria before a range is set!");const{startColumn:s,endColumn:o}=r;if(e>o||e<s)throw new Error(`[FilterModel] could not set criteria on column ${e} which is out of range!`);let l;this._filterColumnByIndex.has(e)?l=this._filterColumnByIndex.get(e):(l=new me(this.unitId,this.subUnitId,this._worksheet,t,{getAlreadyFilteredOutRows:()=>this._alreadyFilteredOutRows}),l.setRangeAndColumn(r,e),this._filterColumnByIndex.set(e,l)),l.setCriteria(t)}_removeCriteria(e){const t=this._filterColumnByIndex.get(e);t&&(t.dispose(),this._filterColumnByIndex.delete(e))}_emit(){this._filteredOutRows$.next(this._alreadyFilteredOutRows)}_emitHasCriteria(){this._hasCriteria$.next(this._filterColumnByIndex.size>0)}_rebuildAlreadyFilteredOutRowsWithCache(){const e=this._getAllFilterColumns().filter(t=>t.hasCache()).reduce((t,r)=>d.mergeSets(t,r.filteredOutRows),new Set);this._alreadyFilteredOutRows=e}_reCalcWithNoCacheColumns(){const e=this._getAllFilterColumns().filter(t=>!t.hasCache());for(const t of e){const r=t.reCalc();r&&(this._alreadyFilteredOutRows=d.mergeSets(this._alreadyFilteredOutRows,r))}}}class me extends d.Disposable{constructor(e,t,r,s,o){super();R(this,"_filteredOutRows",null);R(this,"_filterFn",null);R(this,"_range",null);R(this,"_column",0);R(this,"_filterBy",A.VALUES);this.unitId=e,this.subUnitId=t,this._worksheet=r,this._criteria=s,this._filterColumnContext=o}get filteredOutRows(){return this._filteredOutRows}get filterBy(){return this._filterBy}dispose(){super.dispose(),this._filteredOutRows=null}__clearCache(){this._filteredOutRows=null}serialize(){if(!this._criteria)throw new Error("[FilterColumn]: could not serialize without a filter column!");return d.Tools.deepClone({...this._criteria,colId:this._column})}hasCache(){return this._filteredOutRows!==null}setRangeAndColumn(e,t){this._range=e,this._column=t}setCriteria(e){this._criteria=e,this._generateFilterFn(),this._filteredOutRows=null}getColumnData(){return d.Tools.deepClone(this._criteria)}reCalc(){return this._filteredOutRows=this.calc(this._filterColumnContext),this._filteredOutRows}calc(e){if(!this._filterFn)throw new Error("[FilterColumn] cannot calculate without a filter fn!");if(!this._range)throw new Error("[FilterColumn] cannot calculate without a range!");if(typeof this._column!="number")throw new TypeError("[FilterColumn] cannot calculate without a column offset!");const t=this._column,r={startColumn:t,endColumn:t,startRow:this._range.startRow+1,endRow:this._range.endRow},s=new Set,o=e.getAlreadyFilteredOutRows();for(const l of this._worksheet.iterateByColumn(r,!1,!1)){const{row:a,rowSpan:c,col:h}=l;if(o.has(a)&&(!c||c===1))continue;if(!(this._filterBy===A.VALUES?this._filterFn(d.extractPureTextFromCell(this._worksheet.getCell(a,h))):this._filterBy===A.COLORS?this._filterFn(this._worksheet.getComposedCellStyle(a,h)):this._filterFn($e(this._worksheet,a,h)))&&(s.add(a),c))for(let m=1;m<c;m++)s.add(a+m)}return s}_generateFilterFn(){this._criteria&&(this._filterFn=Oe(this._criteria),this._filterBy=this._criteria.filters?A.VALUES:this._criteria.colorFilters?A.COLORS:A.CONDITIONS)}}function Oe(i){if(i.filters)return Ie(i.filters);if(i.colorFilters)return Te(i.colorFilters);if(i.customFilters)return Ae(i.customFilters);throw new Error("[FilterModel]: other types of filters are not supported yet.")}function Ie(i){const n=!!i.blank,e=new Set(i.filters);return t=>t===void 0||t===""?n:e.has(typeof t=="string"?t:`${t}`)}function Te(i){if(i.cellFillColors){const n=new Set(i.cellFillColors);return e=>{var r;if(!e||!((r=e.bg)!=null&&r.rgb))return!!n.has(null);const t=new d.ColorKit(e.bg.rgb).toRgbString();return n.has(t)}}if(i.cellTextColors){const n=new Set(i.cellTextColors);return e=>{var r;if(!e||!((r=e.cl)!=null&&r.rgb))return!!n.has(ve.COLOR_BLACK_RGB);const t=new d.ColorKit(e.cl.rgb).toRgbString();return n.has(t)}}throw new Error("[FilterModel]: color filters are not supported yet.")}function Ae(i){const n=i.customFilters.map(e=>Ue(e));return xe(n)?i.and?be(n):Ne(n):n[0]}function be(i){const[n,e]=i;return t=>n(t)&&e(t)}function Ne(i){const[n,e]=i;return t=>n(t)||e(t)}function xe(i){return i.length===2}function Ue(i){const n=i.val;if(i.operator===T.NOT_EQUALS&&!Z(n))return r=>k.fn(r,n);if(Me(i.operator)){if(!Z(n))return()=>!1;const r=W(i.operator),s=Number(n);return o=>r.fn(o,s)}const e=W(i.operator);return t=>e.fn(t,n)}function $e(i,n,e){const t=i.getCell(n,e);if(!t)return null;const r=i.getCellRaw(n,e);return t&&!r?Y(t):r?t.t===d.CellValueType.NUMBER&&typeof t.v=="string"?r.v:t.t===d.CellValueType.NUMBER?Number(r.v):Y(r):null}function Y(i){var t,r;const n=(r=(t=i.p)==null?void 0:t.body)==null?void 0:r.dataStream;if(n)return n.trimEnd();const e=i.v;return typeof e=="string"?i.t===d.CellValueType.BOOLEAN?e.toUpperCase():e:typeof e=="number"?i.t===d.CellValueType.BOOLEAN?e?"TRUE":"FALSE":e:typeof e=="boolean"?e?"TRUE":"FALSE":""}var Le=Object.getOwnPropertyDescriptor,Pe=(i,n,e,t)=>{for(var r=t>1?void 0:t?Le(n,e):n,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=o(r)||r);return r},z=(i,n)=>(e,t)=>n(e,t,i);const G="SHEET_FILTER_PLUGIN";exports.SheetsFilterService=class extends d.Disposable{constructor(e,t,r){super();R(this,"_filterModels",new Map);R(this,"_loadedUnitId$",new O.BehaviorSubject(null));R(this,"loadedUnitId$",this._loadedUnitId$.asObservable());R(this,"_errorMsg$",new O.BehaviorSubject(null));R(this,"errorMsg$",this._errorMsg$.asObservable());R(this,"_activeFilterModel$",new O.BehaviorSubject(null));R(this,"activeFilterModel$",this._activeFilterModel$.asObservable());this._resourcesManagerService=e,this._univerInstanceService=t,this._commandService=r,this._initModel(),this._initActiveFilterModel()}get activeFilterModel(){return this._activeFilterModel$.getValue()}ensureFilterModel(e,t){const r=this.getFilterModel(e,t);if(r)return r;const s=this._univerInstanceService.getUniverSheetInstance(e);if(!s)throw new Error(`[SheetsFilterService]: could not create "FilterModel" on a non-existing workbook ${e}!`);const o=s.getSheetBySheetId(t);if(!o)throw new Error(`[SheetsFilterService]: could not create "FilterModel" on a non-existing worksheet ${t}!`);const l=new $(e,t,o);return this._cacheFilterModel(e,t,l),l}getFilterModel(e,t){var r,s;return(s=(r=this._filterModels.get(e))==null?void 0:r.get(t))!=null?s:null}removeFilterModel(e,t){const r=this.getFilterModel(e,t);return r?(r.dispose(),this._filterModels.get(e).delete(t),!0):!1}setFilterErrorMsg(e){this._errorMsg$.next(e)}_updateActiveFilterModel(){let e;try{if(e=this._univerInstanceService.getCurrentUnitForType(d.UniverInstanceType.UNIVER_SHEET),!e){this._activeFilterModel$.next(null);return}}catch(l){console.error("[SheetsFilterService]: could not get active workbook!",l);return}const t=e.getActiveSheet(!0);if(!t){this._activeFilterModel$.next(null);return}const r=t.getUnitId(),s=t.getSheetId(),o=this.getFilterModel(r,s);this._activeFilterModel$.next(o)}_initActiveFilterModel(){this.disposeWithMe(O.merge(d.fromCallback(this._commandService.onCommandExecuted.bind(this._commandService)).pipe(O.filter(([e])=>e.type===d.CommandType.MUTATION&&q.has(e.id))),this._univerInstanceService.getCurrentTypeOfUnit$(d.UniverInstanceType.UNIVER_SHEET).pipe(O.switchMap(e=>{var t;return(t=e==null?void 0:e.activeSheet$)!=null?t:O.of(null)}))).subscribe(()=>this._updateActiveFilterModel()))}_serializeAutoFiltersForUnit(e){const t=this._filterModels.get(e);if(!t)return"{}";const r={};return t.forEach((s,o)=>{r[o]=s.serialize()}),JSON.stringify(r)}_deserializeAutoFiltersForUnit(e,t){const r=this._univerInstanceService.getUniverSheetInstance(e);Object.keys(t).forEach(s=>{const o=t[s],l=$.deserialize(e,s,r.getSheetBySheetId(s),o);this._cacheFilterModel(e,s,l)})}_initModel(){this._resourcesManagerService.registerPluginResource({pluginName:G,businesses:[d.UniverInstanceType.UNIVER_SHEET],toJson:e=>this._serializeAutoFiltersForUnit(e),parseJson:e=>JSON.parse(e),onLoad:(e,t)=>{this._deserializeAutoFiltersForUnit(e,t),this._loadedUnitId$.next(e),this._updateActiveFilterModel()},onUnLoad:e=>{const t=this._filterModels.get(e);t&&(t.forEach(r=>r.dispose()),this._filterModels.delete(e))}})}_cacheFilterModel(e,t,r){this._filterModels.has(e)||this._filterModels.set(e,new Map),this._filterModels.get(e).set(t,r)}};exports.SheetsFilterService=Pe([z(0,d.IResourceManagerService),z(1,d.IUniverInstanceService),z(2,d.ICommandService)],exports.SheetsFilterService);const F={id:te,type:d.CommandType.MUTATION,handler:(i,n)=>{const{subUnitId:e,unitId:t,range:r}=n;return i.get(exports.SheetsFilterService).ensureFilterModel(t,e).setRange(r),!0}},v={id:re,type:d.CommandType.MUTATION,handler:(i,n)=>{const{subUnitId:e,unitId:t,criteria:r,col:s,reCalc:o=!0}=n,a=i.get(exports.SheetsFilterService).getFilterModel(t,e);return a?(a.setCriteria(s,r,o),!0):!1}},I={id:ne,type:d.CommandType.MUTATION,handler:(i,n)=>{const{unitId:e,subUnitId:t}=n;return i.get(exports.SheetsFilterService).removeFilterModel(e,t)}},x={id:ie,type:d.CommandType.MUTATION,handler:(i,n)=>{const{unitId:e,subUnitId:t}=n,s=i.get(exports.SheetsFilterService).getFilterModel(e,t);return s?(s.reCalc(),!0):!1}},fe={id:"sheet.command.set-filter-range",type:d.CommandType.COMMAND,handler:(i,n)=>{const e=i.get(exports.SheetsFilterService),t=i.get(d.ICommandService),r=i.get(d.IUndoRedoService),s=i.get(d.IUniverInstanceService),{unitId:o,subUnitId:l,range:a}=n;if(!S.getSheetCommandTarget(s,n)||e.getFilterModel(o,l))return!1;if(a.endRow===a.startRow){const C=i.get(d.ErrorService),_=i.get(d.LocaleService);return C.emit(_.t("sheets-filter.command.not-valid-filter-range")),!1}const u={id:F.id,params:{unitId:o,subUnitId:l,range:a}},m=t.syncExecuteCommand(u.id,u.params);return m&&r.pushUndoRedo({unitID:o,undoMutations:[{id:I.id,params:{unitId:o,subUnitId:l}}],redoMutations:[u]}),m}},ge={id:"sheet.command.remove-sheet-filter",type:d.CommandType.COMMAND,handler:(i,n)=>{const e=i.get(d.IUniverInstanceService),t=i.get(exports.SheetsFilterService),r=i.get(d.ICommandService),s=i.get(d.IUndoRedoService),o=S.getSheetCommandTarget(e,n);if(!o)return!1;const{unitId:l,subUnitId:a}=o,c=t.getFilterModel(l,a);if(!c)return!1;const h=c==null?void 0:c.serialize(),u=ze(l,a,h),m=r.syncExecuteCommand(I.id,{unitId:l,subUnitId:a});return m&&s.pushUndoRedo({unitID:l,undoMutations:u,redoMutations:[{id:I.id,params:{unitId:l,subUnitId:a}}]}),m}},De={id:"sheet.command.smart-toggle-filter",type:d.CommandType.COMMAND,handler:async i=>{const n=i.get(d.IUniverInstanceService),e=i.get(exports.SheetsFilterService),t=i.get(d.ICommandService),r=n.getCurrentUnitForType(d.UniverInstanceType.UNIVER_SHEET),s=r==null?void 0:r.getActiveSheet();if(!s||!r)return!1;const o=r.getUnitId(),l=s.getSheetId();if(e.getFilterModel(o,l))return t.executeCommand(ge.id,{unitId:o,subUnitId:l});const h=i.get(S.SheetsSelectionsService).getCurrentLastSelection();if(!h)return!1;const u=h.range,m=S.isSingleCellSelection(h)?S.expandToContinuousRange(u,{left:!0,right:!0,up:!0,down:!0},s):u;return t.executeCommand(fe.id,{unitId:o,subUnitId:l,range:m})}},Be={id:"sheet.command.set-filter-criteria",type:d.CommandType.COMMAND,handler:(i,n)=>{const e=i.get(exports.SheetsFilterService),t=i.get(d.ICommandService),r=i.get(d.IUndoRedoService),{unitId:s,subUnitId:o,col:l,criteria:a}=n,c=e.getFilterModel(s,o);if(!c)return!1;const h=c.getRange();if(!h||l<h.startColumn||l>h.endColumn)return!1;const u=c.getFilterColumn(l),m=We(s,o,l,u),C={id:v.id,params:{unitId:s,subUnitId:o,col:l,criteria:a}},_=t.syncExecuteCommand(C.id,C.params);return _&&r.pushUndoRedo({unitID:s,undoMutations:[m],redoMutations:[C]}),_}},je={id:"sheet.command.clear-filter-criteria",type:d.CommandType.COMMAND,handler:(i,n)=>{const e=i.get(exports.SheetsFilterService),t=i.get(d.IUndoRedoService),r=i.get(d.ICommandService),s=i.get(d.IUniverInstanceService),o=S.getSheetCommandTarget(s,n);if(!o)return!1;const{unitId:l,subUnitId:a}=o,c=e.getFilterModel(o.unitId,o.subUnitId);if(!c)return!1;const h=c.serialize(),u=Ce(l,a,h),m=Ve(l,a,h);return d.sequenceExecute(m,r).result?(t.pushUndoRedo({unitID:l,undoMutations:u,redoMutations:m}),!0):!1}},He={id:"sheet.command.re-calc-filter",type:d.CommandType.COMMAND,handler:(i,n)=>{const e=i.get(exports.SheetsFilterService),t=i.get(d.ICommandService),r=i.get(d.IUniverInstanceService),s=S.getSheetCommandTarget(r,n);if(!s)return!1;const{unitId:o,subUnitId:l}=s;return e.getFilterModel(s.unitId,s.subUnitId)?t.executeCommand(x.id,{unitId:o,subUnitId:l}):!1}};function ze(i,n,e){const t=[],r={id:F.id,params:{unitId:i,subUnitId:n,range:e.ref}};return t.push(r),Ce(i,n,e).forEach(o=>t.push(o)),t}function Ce(i,n,e){var r;const t=[];return(r=e.filterColumns)==null||r.forEach(s=>{const o={id:v.id,params:{unitId:i,subUnitId:n,col:s.colId,criteria:s}};t.push(o)}),t}function Ve(i,n,e){var r;const t=[];return(r=e.filterColumns)==null||r.forEach(s=>{const o={id:v.id,params:{unitId:i,subUnitId:n,col:s.colId,criteria:null}};t.push(o)}),t}function We(i,n,e,t){if(!t)return{id:v.id,params:{unitId:i,subUnitId:n,col:e,criteria:null}};const r=t.serialize();return{id:v.id,params:{unitId:i,subUnitId:n,col:e,criteria:r}}}const _e="sheets-filter.config",X={};function qe(i,n){for(let e=0;e<i.length;e++){let t=e;if(i[e])for(let r=e+1;r<i.length;r++)i[t]&&i[r]&&n(i[t],i[r])&&(i[t]=null,t=r)}return i.filter(e=>e!==null)}function N(i){return qe(i,(n,e)=>n.id===v.id&&e.id===v.id&&n.params.unitId===e.params.unitId&&n.params.subUnitId===e.params.subUnitId&&n.params.col===e.params.col)}var ke=Object.getOwnPropertyDescriptor,Ge=(i,n,e,t)=>{for(var r=t>1?void 0:t?ke(n,e):n,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=o(r)||r);return r},b=(i,n)=>(e,t)=>n(e,t,i);let L=class extends d.Disposable{constructor(n,e,t,r,s,o,l){super();R(this,"_disposableCollection",new d.DisposableCollection);this._commandService=n,this._sheetInterceptorService=e,this._sheetsFilterService=t,this._univerInstanceService=r,this._refRangeService=s,this._dataSyncPrimaryController=o,this._zebraCrossingCacheController=l,this._initCommands(),this._initRowFilteredInterceptor(),this._initInterceptors(),this._commandExecutedListener(),this._initErrorHandling(),this._initZebraCrossingCacheListener()}_initZebraCrossingCacheListener(){this.disposeWithMe(this._sheetsFilterService.activeFilterModel$.subscribe(n=>{n&&this.disposeWithMe(n.filteredOutRows$.subscribe(()=>{this._zebraCrossingCacheController.updateZebraCrossingCache(n.unitId,n.subUnitId)}))}))}_initCommands(){[v,F,x,I].forEach(n=>{var e;this.disposeWithMe(this._commandService.registerCommand(n)),(e=this._dataSyncPrimaryController)==null||e.registerSyncingMutations(n)})}_initInterceptors(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:n=>this._getUpdateFilter(n)})),this.disposeWithMe(this._commandService.onCommandExecuted(n=>{if(n.id===S.SetWorksheetActiveOperation.id){const e=n.params,t=e.subUnitId,r=e.unitId;if(!t||!r)return;this._registerRefRange(r,t)}if(n.id===F.id){const e=n.params,t=e.subUnitId,r=e.unitId;if(!t||!r)return;this._registerRefRange(e.unitId,e.subUnitId)}})),this.disposeWithMe(this._sheetsFilterService.loadedUnitId$.subscribe(n=>{if(n){const e=this._univerInstanceService.getUniverSheetInstance(n),t=e==null?void 0:e.getActiveSheet();t&&this._registerRefRange(n,t.getSheetId())}}))}_registerRefRange(n,e){var l;this._disposableCollection.dispose();const t=this._univerInstanceService.getUniverSheetInstance(n),r=t==null?void 0:t.getSheetBySheetId(e);if(!t||!r)return;const s=(l=this._sheetsFilterService.getFilterModel(n,e))==null?void 0:l.getRange(),o=a=>{switch(a.id){case S.InsertRowCommand.id:{const c=a.params,h=c.unitId||n,u=c.subUnitId||e;return this._handleInsertRowCommand(c,h,u)}case S.InsertColCommand.id:{const c=a.params,h=c.unitId||n,u=c.subUnitId||e;return this.handleInsertColCommand(c.range,h,u)}case S.RemoveColCommand.id:{const c=a.params;return this.handleRemoveColCommand(c.range,n,e)}case S.RemoveRowCommand.id:{const c=a.params;return this._handleRemoveRowCommand(c,n,e)}case S.EffectRefRangId.MoveColsCommandId:{const c=a.params;return this.handleMoveColsCommand({fromRange:c.fromRange,toRange:c.toRange},n,e)}case S.EffectRefRangId.MoveRowsCommandId:{const c=a.params;return this._handleMoveRowsCommand(c,n,e)}case S.MoveRangeCommand.id:{const c=a.params;return this._handleMoveRangeCommand(c,n,e)}}return{redos:[],undos:[]}};s&&this._disposableCollection.add(this._refRangeService.registerRefRange(s,o,n,e))}_getUpdateFilter(n){const{id:e}=n;switch(e){case S.RemoveSheetCommand.id:{const t=n.params;return this._handleRemoveSheetCommand(t,t.unitId,t.subUnitId)}case S.CopySheetCommand.id:{const t=n.params,{targetSubUnitId:r,unitId:s,subUnitId:o}=t;return!s||!o||!r?this._handleNull():this._handleCopySheetCommand(s,o,r)}}return{redos:[],undos:[]}}handleInsertColCommand(n,e,t){var f;const r=this._sheetsFilterService.getFilterModel(e,t),s=(f=r==null?void 0:r.getRange())!=null?f:null;if(!r||!s)return this._handleNull();const{startColumn:o,endColumn:l}=s,{startColumn:a,endColumn:c}=n,h=c-a+1;if(c>l)return this._handleNull();const u=[],m=[],C=a,_={unitId:e,subUnitId:t,range:{...s,startColumn:a<=o?o+h:o,endColumn:l+h}},p={unitId:e,subUnitId:t,range:s};u.push({id:F.id,params:_}),m.push({id:F.id,params:p});const w=r.getAllFilterColumns().filter(g=>g[0]>=C);if(w.length!==0){const{newRange:g,oldRange:y}=this._moveCriteria(e,t,w,h);u.push(...y.redos,...g.redos),m.push(...g.undos,...y.undos)}return{redos:N(u),undos:N(m)}}_handleInsertRowCommand(n,e,t){var p;const r=this._sheetsFilterService.getFilterModel(e,t),s=(p=r==null?void 0:r.getRange())!=null?p:null;if(!r||!s)return this._handleNull();const{startRow:o,endRow:l}=s,{startRow:a,endRow:c}=n.range,h=c-a+1;if(c>l)return this._handleNull();const u=[],m=[],C={unitId:e,subUnitId:t,range:{...s,startRow:a<=o?o+h:o,endRow:l+h}},_={unitId:e,subUnitId:t,range:s};return u.push({id:F.id,params:C}),m.push({id:F.id,params:_}),{redos:N(u),undos:N(m)}}handleRemoveColCommand(n,e,t){var w;const r=this._sheetsFilterService.getFilterModel(e,t),s=(w=r==null?void 0:r.getRange())!=null?w:null;if(!r||!s)return this._handleNull();const{startColumn:o,endColumn:l}=s,{startColumn:a,endColumn:c}=n;if(a>l)return this._handleNull();const h=[],u=[],m=c<o?0:Math.min(c,l)-Math.max(a,o)+1,C=c-a+1,_=r.getAllFilterColumns();_.forEach(f=>{const[g,y]=f;g<=c&&g>=a&&(h.push({id:v.id,params:{unitId:e,subUnitId:t,col:g,criteria:null}}),u.push({id:v.id,params:{unitId:e,subUnitId:t,col:g,criteria:{...y.serialize(),colId:g}}}))});const p=_.filter(f=>{const[g,y]=f;return g>c});let M={undos:[],redos:[]};if(p.length>0){const{oldRange:f,newRange:g}=this._moveCriteria(e,t,p,-C);M=g,h.push(...f.redos),u.unshift(...f.undos)}if(m===l-o+1){const f={unitId:e,subUnitId:t};h.push({id:I.id,params:f}),u.unshift({id:F.id,params:{range:s,unitId:e,subUnitId:t}})}else{const f=o<=a?o:m===0?o-C:a,g=o<=a?l-m:l-C,y={unitId:e,subUnitId:t,range:{...s,startColumn:f,endColumn:g}};h.push({id:F.id,params:y}),u.unshift({id:F.id,params:{range:s,unitId:e,subUnitId:t}}),h.push(...M.redos),u.unshift(...M.undos)}return{undos:u,redos:h}}_handleRemoveRowCommand(n,e,t){var p;const r=this._sheetsFilterService.getFilterModel(e,t);if(!r)return this._handleNull();const s=r.getRange(),{startRow:o,endRow:l}=s,{startRow:a,endRow:c}=n.range;if(a>l)return this._handleNull();if(c<o)return{undos:[{id:F.id,params:{range:s,unitId:e,subUnitId:t}}],redos:[{id:F.id,params:{range:{...s,startRow:o-(c-a+1),endRow:l-(c-a+1)},unitId:e,subUnitId:t}}]};const h=[],u=[],m=r.getAllFilterColumns(),C=o<=c&&o>=a;u.push({id:F.id,params:{range:s,unitId:e,subUnitId:t}});const _=Math.min(c,l)-Math.max(a,o)+1;if(_===l-o+1||C){const M={unitId:e,subUnitId:t};h.push({id:I.id,params:M}),m.forEach(w=>{const[f,g]=w,y={unitId:e,subUnitId:t,col:f,criteria:{...g.serialize(),colId:f}};u.push({id:v.id,params:y})})}else{const M=(p=this._univerInstanceService.getUniverSheetInstance(e))==null?void 0:p.getSheetBySheetId(t);if(!M)return this._handleNull();const w=[];for(let E=a;E<=c;E++)M.getRowFiltered(E)&&w.push(E);const f=Math.min(o,a),g=f+(l-o)-_+w.length,y={unitId:e,subUnitId:t,range:{...s,startRow:f,endRow:g}};h.push({id:F.id,params:y})}return{undos:N(u),redos:N(h)}}handleMoveColsCommand({fromRange:n,toRange:e},t,r){var w;const s=this._sheetsFilterService.getFilterModel(t,r),o=(w=s==null?void 0:s.getRange())!=null?w:null;if(!s||!o)return this._handleNull();const{startColumn:l,endColumn:a}=o;if(n.endColumn<l&&e.startColumn<=l||n.startColumn>a&&e.endColumn>a)return this._handleNull();const c=[],h=[],u={};for(let f=l;f<=a;f++)u[f]={colIndex:f,filter:s.getFilterColumn(f)};d.moveMatrixArray(n.startColumn,n.endColumn-n.startColumn+1,e.startColumn,u);let m=o.startColumn,C=o.endColumn;l>=n.startColumn&&l<=n.endColumn&&e.startColumn>n.startColumn&&n.endColumn<a&&(m=n.endColumn+1),a>=n.startColumn&&a<=n.endColumn&&e.startColumn<n.startColumn&&n.startColumn>l&&(C=n.startColumn-1);const _=Object.keys(u).map(f=>Number(f)),p=_.find(f=>u[f].colIndex===C),M=_.find(f=>u[f].colIndex===m);if(_.forEach(f=>{var Q,J;const{colIndex:g,filter:y}=u[f],E=f;if(y){if(E>=M&&E<=p){const j={unitId:t,subUnitId:r,col:E,criteria:{...y.serialize(),colId:E}},Se={unitId:t,subUnitId:r,col:E,criteria:s.getFilterColumn(E)?{...(Q=s.getFilterColumn(E))==null?void 0:Q.serialize(),colId:E}:null};c.push({id:v.id,params:j}),h.push({id:v.id,params:Se})}if(!((J=u[g])!=null&&J.filter)){const j={unitId:t,subUnitId:r,col:g,criteria:null};c.push({id:v.id,params:j}),h.push({id:v.id,params:{unitId:t,subUnitId:r,col:g,criteria:{...y.serialize(),colId:g}}})}}}),l!==M||a!==p){const f={unitId:t,subUnitId:r,range:{...o,startColumn:M,endColumn:p}};c.unshift({id:F.id,params:f}),h.unshift({id:F.id,params:{range:o,unitId:t,subUnitId:r}})}return{undos:h,redos:c}}_handleMoveRowsCommand(n,e,t){var f;const r=this._sheetsFilterService.getFilterModel(e,t),s=(f=r==null?void 0:r.getRange())!=null?f:null;if(!r||!s)return this._handleNull();const{startRow:o,endRow:l}=s,{fromRange:a,toRange:c}=n;if(a.endRow<o&&c.startRow<=o||a.startRow>l&&c.endRow>l)return this._handleNull();const h=[],u=[],m={};for(let g=o;g<=l;g++)m[g]={oldIndex:g};const C=o;let _=l;l>=a.startRow&&l<=a.endRow&&c.startRow<a.startRow&&a.startRow>o&&(_=a.startRow-1),d.moveMatrixArray(a.startRow,a.endRow-a.startRow+1,c.startRow,m);const p=Object.keys(m).map(g=>Number(g)),M=p.find(g=>m[g].oldIndex===_),w=p.find(g=>m[g].oldIndex===C);if(o!==w||l!==M){const g={unitId:e,subUnitId:t,range:{...s,startRow:w,endRow:M}};h.push({id:F.id,params:g},{id:x.id,params:{unitId:e,subUnitId:t}}),u.push({id:F.id,params:{range:s,unitId:e,subUnitId:t}},{id:x.id,params:{unitId:e,subUnitId:t}})}return{redos:h,undos:u}}_handleMoveRangeCommand(n,e,t){const{fromRange:r,toRange:s}=n,o=this._sheetsFilterService.getFilterModel(e,t);if(!o)return this._handleNull();const l=o.getRange();if(!l)return this._handleNull();const a=[],c=[];if(d.Rectangle.contains(r,l)){const h=l.startRow-r.startRow,u=l.startColumn-r.startColumn,m={startRow:s.startRow+h,startColumn:s.startColumn+u,endRow:s.startRow+h+(l.endRow-l.startRow),endColumn:s.startColumn+u+(l.endColumn-l.startColumn)},C={id:I.id,params:{unitId:e,subUnitId:t}},_={id:F.id,params:{unitId:e,subUnitId:t,range:m}},p={id:F.id,params:{unitId:e,subUnitId:t,range:l}};a.push(C,_),c.push(C,p);const M=o.getAllFilterColumns(),w=s.startColumn-r.startColumn;M.forEach(f=>{const[g,y]=f;y&&(a.push({id:v.id,params:{unitId:e,subUnitId:t,col:g+w,criteria:{...y.serialize(),colId:g+w}}}),c.push({id:v.id,params:{unitId:e,subUnitId:t,col:g,criteria:{...y.serialize(),colId:g}}}))})}else if(d.Rectangle.intersects(s,l)){const h={...l,endRow:Math.max(l.endRow,s.endRow)};a.push({id:F.id,params:{unitId:e,subUnitId:t,range:h}}),c.push({id:F.id,params:{unitId:e,subUnitId:t,range:l}})}return{redos:a,undos:c}}_handleRemoveSheetCommand(n,e,t){const r=this._sheetsFilterService.getFilterModel(e,t);if(!r)return this._handleNull();const s=r.getRange();if(!s)return this._handleNull();const o=[],l=[];return r.getAllFilterColumns().forEach(([c,h])=>{l.push({id:v.id,params:{unitId:e,subUnitId:t,col:c,criteria:{...h.serialize(),colId:c}}})}),o.push({id:I.id,params:{unitId:e,subUnitId:t,range:s}}),l.unshift({id:F.id,params:{range:s,unitId:e,subUnitId:t}}),{undos:l,redos:o}}_handleCopySheetCommand(n,e,t){const r=this._sheetsFilterService.getFilterModel(n,e);if(!r)return this._handleNull();const s=r.getRange();if(!s)return this._handleNull();const o=[],l=[],a=[],c=[];return r.getAllFilterColumns().forEach(([u,m])=>{o.push({id:v.id,params:{unitId:n,subUnitId:t,col:u,criteria:{...m.serialize(),colId:u}}}),a.push({id:v.id,params:{unitId:n,subUnitId:t,col:u,criteria:null}})}),a.push({id:I.id,params:{unitId:n,subUnitId:t,range:s}}),o.unshift({id:F.id,params:{range:s,unitId:n,subUnitId:t}}),{undos:l,redos:o,preUndos:a,preRedos:c}}_handleNull(){return{redos:[],undos:[]}}_initRowFilteredInterceptor(){this.disposeWithMe(this._sheetInterceptorService.intercept(S.INTERCEPTOR_POINT.ROW_FILTERED,{handler:(n,e)=>{var t,r;return n?!0:(r=(t=this._sheetsFilterService.getFilterModel(e.unitId,e.subUnitId))==null?void 0:t.isRowFiltered(e.row))!=null?r:!1}}))}_moveCriteria(n,e,t,r){const s={unitId:n,subUnitId:e,criteria:null,col:-1},o=[],l=[],a=[],c=[];return t.forEach(h=>{const[u,m]=h;l.push({id:v.id,params:{...s,col:u}}),o.push({id:v.id,params:{...s,col:u,criteria:{...m.serialize(),colId:u}}})}),t.forEach(h=>{const[u,m]=h;c.push({id:v.id,params:{...s,col:u+r,criteria:{...m.serialize(),colId:u+r}}}),a.push({id:v.id,params:{...s,col:u+r,criteria:null}})}),{newRange:{redos:c,undos:a},oldRange:{redos:l,undos:o}}}_commandExecutedListener(){this.disposeWithMe(this._commandService.onCommandExecuted((n,e)=>{var c,h;const{unitId:t,subUnitId:r}=n.params||{},s=this._sheetsFilterService.getFilterModel(t,r);if(!s)return;const o=Array.from(s.filteredOutRows).sort((u,m)=>u-m),l=[];let a=!1;if(n.id===S.RemoveRowMutation.id){const{startRow:u,endRow:m}=n.params.range,C=o.filter(_=>_>=u&&_<=m);o.forEach(_=>{if(_<u)l.push(_);else if(a=!0,_<=m){const p=Math.max(u,l.length?l[l.length-1]+1:u);l.push(p)}else l.push(_-(m-u+1-C.length))})}if(n.id===S.InsertRowMutation.id){const{startRow:u,endRow:m}=n.params.range;o.forEach(C=>{C>=u?(a=!0,l.push(C+(m-u+1))):l.push(C)})}if(a&&(s.filteredOutRows=new Set(l)),n.id===S.SetRangeValuesMutation.id&&!(e!=null&&e.onlyLocal)){const u=this._getExtendRegion(t,r);if(u){const m=n.params.cellValue;if(m)for(let C=u.startColumn;C<=u.endColumn;C++){const _=(c=m==null?void 0:m[u.startRow])==null?void 0:c[C];if(_&&this._cellHasValue(_)){const p=(h=this._univerInstanceService.getUnit(t))==null?void 0:h.getSheetBySheetId(r);if(p){const M=S.expandToContinuousRange(u,{down:!0},p),w=this._sheetsFilterService.getFilterModel(t,r),f=w.getRange();w.setRange({...f,endRow:M.endRow}),this._registerRefRange(t,r)}}}}}}))}_getExtendRegion(n,e){var a;const t=this._sheetsFilterService.getFilterModel(n,e);if(!t)return null;const r=(a=this._univerInstanceService.getUnit(n))==null?void 0:a.getSheetBySheetId(e);if(!r)return null;const s=t.getRange();if(!s)return null;const o=r.getRowCount()-1,l=r.getRowManager();for(let c=s.endRow+1;c<=o;c++)if(l.getRowRawVisible(c))return{startRow:c,endRow:c,startColumn:s.startColumn,endColumn:s.endColumn};return null}_initErrorHandling(){this.disposeWithMe(this._commandService.beforeCommandExecuted(n=>{const e=n.params,t=S.getSheetCommandTarget(this._univerInstanceService);if(!t)return;const{subUnitId:r,unitId:s}=t,o=this._sheetsFilterService.getFilterModel(s,r);if(!o)return;const l=o.getRange();if(n.id===S.MoveRowsCommand.id&&e.fromRange.startRow<=l.startRow&&e.fromRange.endRow<l.endRow&&e.fromRange.endRow>=l.startRow)throw this._sheetsFilterService.setFilterErrorMsg("sheets-filter.msg.filter-header-forbidden"),new Error("[SheetsFilterController]: Cannot move header row of filter")}))}_cellHasValue(n){const e=Object.values(n);return!(e.length===0||e.every(t=>t==null))}};L=Ge([b(0,d.ICommandService),b(1,d.Inject(S.SheetInterceptorService)),b(2,d.Inject(exports.SheetsFilterService)),b(3,d.IUniverInstanceService),b(4,d.Inject(S.RefRangeService)),b(5,d.Optional(pe.DataSyncPrimaryController)),b(6,d.Inject(S.ZebraCrossingCacheController))],L);var Qe=Object.getOwnPropertyDescriptor,Je=(i,n,e,t)=>{for(var r=t>1?void 0:t?Qe(n,e):n,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=o(r)||r);return r},V=(i,n)=>(e,t)=>n(e,t,i);const Ke=[v.id,x.id],Ze=[S.InsertColMutation.id,S.RemoveColMutation.id,S.MoveColsMutation.id];exports.SheetsFilterSyncController=class extends d.Disposable{constructor(e,t,r){super();R(this,"_d",new d.DisposableCollection);R(this,"_visible$",new O.BehaviorSubject(!1));R(this,"visible$",this._visible$.asObservable());R(this,"_enabled$",new O.BehaviorSubject(!0));R(this,"enabled$",this._enabled$.asObservable());this._sheetsFilterController=e,this._commandService=t,this._configService=r;const s=this._configService.getConfig(_e);s!=null&&s.enableSyncSwitch&&this._visible$.next(!0)}get visible(){return this._visible$.getValue()}get enabled(){return this._enabled$.getValue()}setEnabled(e){this._enabled$.next(e),e?this._d.dispose():this._initOnlyLocalListener()}_initOnlyLocalListener(){this._d.add(this._commandService.beforeCommandExecuted((e,t)=>{Ke.includes(e.id)&&(t||(t={}),t.onlyLocal=!0)})),this._d.add(this._commandService.onCommandExecuted((e,t)=>{if(Ze.includes(e.id)&&(t!=null&&t.fromCollab)){if(e.id===S.InsertColMutation.id){const{range:r,unitId:s,subUnitId:o}=e.params,{redos:l}=this._sheetsFilterController.handleInsertColCommand(r,s,o);d.sequenceExecute(l,this._commandService,t)}else if(e.id===S.RemoveColMutation.id){const{range:r,unitId:s,subUnitId:o}=e.params,{redos:l}=this._sheetsFilterController.handleRemoveColCommand(r,s,o);d.sequenceExecute(l,this._commandService,t)}else if(e.id===S.MoveColsMutation.id){const{sourceRange:r,targetRange:s,unitId:o,subUnitId:l}=e.params,{redos:a}=this._sheetsFilterController.handleMoveColsCommand({fromRange:r,toRange:s},o,l);d.sequenceExecute(a,this._commandService,t)}}}))}};exports.SheetsFilterSyncController=Je([V(0,d.Inject(L)),V(1,d.ICommandService),V(2,d.IConfigService)],exports.SheetsFilterSyncController);var Ye=Object.getOwnPropertyDescriptor,Xe=(i,n,e,t)=>{for(var r=t>1?void 0:t?Ye(n,e):n,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=o(r)||r);return r},P=(i,n)=>(e,t)=>n(e,t,i);let B=class extends d.Disposable{constructor(i,n,e,t){super(),this._activeDirtyManagerService=i,this._sheetRowFilteredService=n,this._sheetsFilterService=e,this._univerInstanceService=t,this._initFormulaDirtyRange(),this._registerSheetRowFiltered()}_initFormulaDirtyRange(){q.forEach(i=>{this._activeDirtyManagerService.register(i,{commandId:i,getDirtyData:n=>{const e=n.params,{unitId:t,subUnitId:r}=e;return{dirtyRanges:this._getHideRowMutation(t,r),clearDependencyTreeCache:{[t]:{[r]:"1"}}}}})})}_getHideRowMutation(i,n){var l,a;const e=(l=this._sheetsFilterService.getFilterModel(i,n))==null?void 0:l.getRange(),t=(a=this._univerInstanceService.getUnit(i))==null?void 0:a.getSheetBySheetId(n);if(e==null||t==null)return[];const{startRow:r,endRow:s}=e;return[{unitId:i,sheetId:n,range:{startRow:r,startColumn:0,endRow:s,endColumn:t.getColumnCount()-1}}]}_registerSheetRowFiltered(){this._sheetRowFilteredService.register((i,n,e)=>{var t,r;return(r=(t=this._sheetsFilterService.getFilterModel(i,n))==null?void 0:t.isRowFiltered(e))!=null?r:!1})}};B=Xe([P(0,d.Inject(K.IActiveDirtyManagerService)),P(1,d.Inject(K.ISheetRowFilteredService)),P(2,d.Inject(exports.SheetsFilterService)),P(3,d.IUniverInstanceService)],B);var et=Object.getOwnPropertyDescriptor,tt=(i,n,e,t)=>{for(var r=t>1?void 0:t?et(n,e):n,s=i.length-1,o;s>=0;s--)(o=i[s])&&(r=o(r)||r);return r},ee=(i,n)=>(e,t)=>n(e,t,i),D;exports.UniverSheetsFilterPlugin=(D=class extends d.Plugin{constructor(n=X,e,t){super(),this._config=n,this._injector=e,this._configService=t;const{...r}=d.merge({},X,this._config);this._configService.setConfig(_e,r)}onStarting(){[[B],[exports.SheetsFilterService],[L],[exports.SheetsFilterSyncController]].forEach(n=>this._injector.add(n))}onReady(){d.touchDependencies(this._injector,[[B],[L],[exports.SheetsFilterSyncController]])}},R(D,"type",d.UniverInstanceType.UNIVER_SHEET),R(D,"pluginName",G),D);exports.UniverSheetsFilterPlugin=tt([ee(1,d.Inject(d.Injector)),ee(2,d.IConfigService)],exports.UniverSheetsFilterPlugin);exports.ClearSheetsFilterCriteriaCommand=je;exports.CustomFilterOperator=T;exports.FILTER_MUTATIONS=q;exports.FilterBy=A;exports.FilterColumn=me;exports.FilterModel=$;exports.ReCalcSheetsFilterCommand=He;exports.ReCalcSheetsFilterMutation=x;exports.RemoveSheetFilterCommand=ge;exports.RemoveSheetsFilterMutation=I;exports.SHEET_FILTER_SNAPSHOT_ID=G;exports.SetSheetFilterRangeCommand=fe;exports.SetSheetsFilterCriteriaCommand=Be;exports.SetSheetsFilterCriteriaMutation=v;exports.SetSheetsFilterRangeMutation=F;exports.SmartToggleSheetsFilterCommand=De;exports.equals=ce;exports.getCustomFilterFn=W;exports.greaterThan=se;exports.greaterThanOrEqualTo=oe;exports.lessThan=le;exports.lessThanOrEqualTo=ae;exports.notEquals=k;
|
package/lib/es/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
var be = Object.defineProperty;
|
|
2
2
|
var $e = (i, t, e) => t in i ? be(i, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : i[t] = e;
|
|
3
3
|
var C = (i, t, e) => $e(i, typeof t != "symbol" ? t + "" : t, e);
|
|
4
|
-
import { isNumeric as Le, Disposable as U, Rectangle as
|
|
4
|
+
import { isNumeric as Le, Disposable as U, Rectangle as te, mergeSets as K, Tools as ie, extractPureTextFromCell as Ue, CellValueType as k, ColorKit as se, UniverInstanceType as D, fromCallback as Pe, CommandType as O, IResourceManagerService as De, IUniverInstanceService as T, ICommandService as N, IUndoRedoService as J, sequenceExecute as j, ErrorService as Be, LocaleService as ze, Inject as A, Optional as He, DisposableCollection as me, moveMatrixArray as oe, IConfigService as ge, Plugin as Ve, merge as We, touchDependencies as je, Injector as ke } from "@univerjs/core";
|
|
5
5
|
import { getSheetCommandTarget as H, SheetsSelectionsService as qe, isSingleCellSelection as Ge, expandToContinuousRange as _e, SheetInterceptorService as Qe, RefRangeService as Je, ZebraCrossingCacheController as Ze, SetWorksheetActiveOperation as Ke, CopySheetCommand as Ye, RemoveSheetCommand as Xe, INTERCEPTOR_POINT as et, RemoveRowMutation as tt, InsertRowMutation as rt, SetRangeValuesMutation as nt, MoveRowsCommand as it, MoveRangeCommand as st, EffectRefRangId as le, RemoveRowCommand as ot, RemoveColCommand as lt, InsertColCommand as at, InsertRowCommand as ct, InsertColMutation as Ce, RemoveColMutation as Re, MoveColsMutation as pe } from "@univerjs/sheets";
|
|
6
6
|
import { BehaviorSubject as $, merge as dt, filter as ut, switchMap as ht, of as ft } from "rxjs";
|
|
7
7
|
import { COLOR_BLACK_RGB as mt } from "@univerjs/engine-render";
|
|
@@ -72,18 +72,18 @@ function Ae(i) {
|
|
|
72
72
|
const t = i.replace(/[.+^${}()|[\]\\]/g, "\\$&").replaceAll("?", ".").replace(/[*]/g, ".$&");
|
|
73
73
|
return new RegExp(`^${t}$`);
|
|
74
74
|
}
|
|
75
|
-
const
|
|
76
|
-
class
|
|
75
|
+
const Y = () => /* @__PURE__ */ new Set();
|
|
76
|
+
class q extends U {
|
|
77
77
|
constructor(e, r, n) {
|
|
78
78
|
super();
|
|
79
|
-
C(this, "_filteredOutRows$", new $(
|
|
79
|
+
C(this, "_filteredOutRows$", new $(Y()));
|
|
80
80
|
/** An observable value. A set of filtered out rows. */
|
|
81
81
|
C(this, "filteredOutRows$", this._filteredOutRows$.asObservable());
|
|
82
82
|
// TODO: we may need to update which cols have criteria rather than simple boolean
|
|
83
83
|
C(this, "_hasCriteria$", new $(!1));
|
|
84
84
|
C(this, "hasCriteria$", this._hasCriteria$.asObservable());
|
|
85
85
|
C(this, "_filterColumnByIndex", /* @__PURE__ */ new Map());
|
|
86
|
-
C(this, "_alreadyFilteredOutRows",
|
|
86
|
+
C(this, "_alreadyFilteredOutRows", Y());
|
|
87
87
|
C(this, "_range");
|
|
88
88
|
this.unitId = e, this.subUnitId = r, this._worksheet = n;
|
|
89
89
|
}
|
|
@@ -101,7 +101,7 @@ class k extends U {
|
|
|
101
101
|
*/
|
|
102
102
|
serialize() {
|
|
103
103
|
const e = {
|
|
104
|
-
ref:
|
|
104
|
+
ref: te.clone(this._range),
|
|
105
105
|
filterColumns: this._getAllFilterColumns(!0).sort(([r], [n]) => r - n).map(([r, n]) => n.serialize())
|
|
106
106
|
};
|
|
107
107
|
return this._alreadyFilteredOutRows && (e.cachedFilteredOut = Array.from(this._alreadyFilteredOutRows).sort()), e;
|
|
@@ -114,7 +114,7 @@ class k extends U {
|
|
|
114
114
|
* @param autoFilter auto filter data
|
|
115
115
|
*/
|
|
116
116
|
static deserialize(e, r, n, s) {
|
|
117
|
-
const o = new
|
|
117
|
+
const o = new q(e, r, n);
|
|
118
118
|
return o._dump(s), o;
|
|
119
119
|
}
|
|
120
120
|
_dump(e) {
|
|
@@ -137,7 +137,7 @@ class k extends U {
|
|
|
137
137
|
getFilteredOutRowsExceptCol(e) {
|
|
138
138
|
return this._getAllFilterColumns(!0).filter(([r]) => r !== e).reduce((r, [, n]) => {
|
|
139
139
|
const s = n.calc({ getAlreadyFilteredOutRows: () => r });
|
|
140
|
-
return s ?
|
|
140
|
+
return s ? K(r, s) : r;
|
|
141
141
|
}, /* @__PURE__ */ new Set());
|
|
142
142
|
}
|
|
143
143
|
/**
|
|
@@ -181,7 +181,7 @@ class k extends U {
|
|
|
181
181
|
return e ? r : r.map(([n, s]) => s);
|
|
182
182
|
}
|
|
183
183
|
_reCalcAllColumns() {
|
|
184
|
-
this._alreadyFilteredOutRows =
|
|
184
|
+
this._alreadyFilteredOutRows = Y(), this._getAllFilterColumns().forEach((e) => e.__clearCache()), this._reCalcWithNoCacheColumns();
|
|
185
185
|
}
|
|
186
186
|
_setCriteriaWithoutReCalc(e, r) {
|
|
187
187
|
const n = this._range;
|
|
@@ -210,14 +210,14 @@ class k extends U {
|
|
|
210
210
|
this._hasCriteria$.next(this._filterColumnByIndex.size > 0);
|
|
211
211
|
}
|
|
212
212
|
_rebuildAlreadyFilteredOutRowsWithCache() {
|
|
213
|
-
const e = this._getAllFilterColumns().filter((r) => r.hasCache()).reduce((r, n) =>
|
|
213
|
+
const e = this._getAllFilterColumns().filter((r) => r.hasCache()).reduce((r, n) => K(r, n.filteredOutRows), /* @__PURE__ */ new Set());
|
|
214
214
|
this._alreadyFilteredOutRows = e;
|
|
215
215
|
}
|
|
216
216
|
_reCalcWithNoCacheColumns() {
|
|
217
217
|
const e = this._getAllFilterColumns().filter((r) => !r.hasCache());
|
|
218
218
|
for (const r of e) {
|
|
219
219
|
const n = r.reCalc();
|
|
220
|
-
n && (this._alreadyFilteredOutRows =
|
|
220
|
+
n && (this._alreadyFilteredOutRows = K(this._alreadyFilteredOutRows, n));
|
|
221
221
|
}
|
|
222
222
|
}
|
|
223
223
|
}
|
|
@@ -301,18 +301,18 @@ class yt extends U {
|
|
|
301
301
|
}
|
|
302
302
|
function At(i) {
|
|
303
303
|
if (i.filters)
|
|
304
|
-
return
|
|
304
|
+
return Nt(i.filters);
|
|
305
305
|
if (i.colorFilters)
|
|
306
|
-
return
|
|
306
|
+
return Tt(i.colorFilters);
|
|
307
307
|
if (i.customFilters)
|
|
308
308
|
return xt(i.customFilters);
|
|
309
309
|
throw new Error("[FilterModel]: other types of filters are not supported yet.");
|
|
310
310
|
}
|
|
311
|
-
function
|
|
311
|
+
function Nt(i) {
|
|
312
312
|
const t = !!i.blank, e = new Set(i.filters);
|
|
313
313
|
return (r) => r === void 0 || r === "" ? t : e.has(typeof r == "string" ? r : `${r}`);
|
|
314
314
|
}
|
|
315
|
-
function
|
|
315
|
+
function Tt(i) {
|
|
316
316
|
if (i.cellFillColors) {
|
|
317
317
|
const t = new Set(i.cellFillColors);
|
|
318
318
|
return (e) => {
|
|
@@ -366,21 +366,21 @@ function Ut(i, t, e) {
|
|
|
366
366
|
const r = i.getCell(t, e);
|
|
367
367
|
if (!r) return null;
|
|
368
368
|
const n = i.getCellRaw(t, e);
|
|
369
|
-
return r && !n ? de(r) : n ? r.t ===
|
|
369
|
+
return r && !n ? de(r) : n ? r.t === k.NUMBER && typeof r.v == "string" ? n.v : r.t === k.NUMBER ? Number(n.v) : de(n) : null;
|
|
370
370
|
}
|
|
371
371
|
function de(i) {
|
|
372
372
|
var r, n;
|
|
373
373
|
const t = (n = (r = i.p) == null ? void 0 : r.body) == null ? void 0 : n.dataStream;
|
|
374
374
|
if (t) return t.trimEnd();
|
|
375
375
|
const e = i.v;
|
|
376
|
-
return typeof e == "string" ? i.t ===
|
|
376
|
+
return typeof e == "string" ? i.t === k.BOOLEAN ? e.toUpperCase() : e : typeof e == "number" ? i.t === k.BOOLEAN ? e ? "TRUE" : "FALSE" : e : typeof e == "boolean" ? e ? "TRUE" : "FALSE" : "";
|
|
377
377
|
}
|
|
378
378
|
var Pt = Object.getOwnPropertyDescriptor, Dt = (i, t, e, r) => {
|
|
379
379
|
for (var n = r > 1 ? void 0 : r ? Pt(t, e) : t, s = i.length - 1, o; s >= 0; s--)
|
|
380
380
|
(o = i[s]) && (n = o(n) || n);
|
|
381
381
|
return n;
|
|
382
|
-
},
|
|
383
|
-
const
|
|
382
|
+
}, X = (i, t) => (e, r) => t(e, r, i);
|
|
383
|
+
const Ne = "SHEET_FILTER_PLUGIN";
|
|
384
384
|
let M = class extends U {
|
|
385
385
|
constructor(t, e, r) {
|
|
386
386
|
super();
|
|
@@ -413,7 +413,7 @@ let M = class extends U {
|
|
|
413
413
|
const s = n.getSheetBySheetId(e);
|
|
414
414
|
if (!s)
|
|
415
415
|
throw new Error(`[SheetsFilterService]: could not create "FilterModel" on a non-existing worksheet ${e}!`);
|
|
416
|
-
const o = new
|
|
416
|
+
const o = new q(t, e, s);
|
|
417
417
|
return this._cacheFilterModel(t, e, o), o;
|
|
418
418
|
}
|
|
419
419
|
getFilterModel(t, e) {
|
|
@@ -471,13 +471,13 @@ let M = class extends U {
|
|
|
471
471
|
_deserializeAutoFiltersForUnit(t, e) {
|
|
472
472
|
const r = this._univerInstanceService.getUniverSheetInstance(t);
|
|
473
473
|
Object.keys(e).forEach((n) => {
|
|
474
|
-
const s = e[n], o =
|
|
474
|
+
const s = e[n], o = q.deserialize(t, n, r.getSheetBySheetId(n), s);
|
|
475
475
|
this._cacheFilterModel(t, n, o);
|
|
476
476
|
});
|
|
477
477
|
}
|
|
478
478
|
_initModel() {
|
|
479
479
|
this._resourcesManagerService.registerPluginResource({
|
|
480
|
-
pluginName:
|
|
480
|
+
pluginName: Ne,
|
|
481
481
|
businesses: [D.UNIVER_SHEET],
|
|
482
482
|
toJson: (t) => this._serializeAutoFiltersForUnit(t),
|
|
483
483
|
parseJson: (t) => JSON.parse(t),
|
|
@@ -495,9 +495,9 @@ let M = class extends U {
|
|
|
495
495
|
}
|
|
496
496
|
};
|
|
497
497
|
M = Dt([
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
498
|
+
X(0, De),
|
|
499
|
+
X(1, T),
|
|
500
|
+
X(2, N)
|
|
501
501
|
], M);
|
|
502
502
|
const R = {
|
|
503
503
|
id: Se,
|
|
@@ -531,7 +531,7 @@ const R = {
|
|
|
531
531
|
id: "sheet.command.set-filter-range",
|
|
532
532
|
type: O.COMMAND,
|
|
533
533
|
handler: (i, t) => {
|
|
534
|
-
const e = i.get(M), r = i.get(
|
|
534
|
+
const e = i.get(M), r = i.get(N), n = i.get(J), s = i.get(T), { unitId: o, subUnitId: l, range: a } = t;
|
|
535
535
|
if (!H(s, t) || e.getFilterModel(o, l)) return !1;
|
|
536
536
|
if (a.endRow === a.startRow) {
|
|
537
537
|
const g = i.get(Be), _ = i.get(ze);
|
|
@@ -548,7 +548,7 @@ const R = {
|
|
|
548
548
|
id: "sheet.command.remove-sheet-filter",
|
|
549
549
|
type: O.COMMAND,
|
|
550
550
|
handler: (i, t) => {
|
|
551
|
-
const e = i.get(
|
|
551
|
+
const e = i.get(T), r = i.get(M), n = i.get(N), s = i.get(J), o = H(e, t);
|
|
552
552
|
if (!o) return !1;
|
|
553
553
|
const { unitId: l, subUnitId: a } = o, c = r.getFilterModel(l, a);
|
|
554
554
|
if (!c) return !1;
|
|
@@ -563,7 +563,7 @@ const R = {
|
|
|
563
563
|
id: "sheet.command.smart-toggle-filter",
|
|
564
564
|
type: O.COMMAND,
|
|
565
565
|
handler: async (i) => {
|
|
566
|
-
const t = i.get(
|
|
566
|
+
const t = i.get(T), e = i.get(M), r = i.get(N), n = t.getCurrentUnitForType(D.UNIVER_SHEET), s = n == null ? void 0 : n.getActiveSheet();
|
|
567
567
|
if (!s || !n) return !1;
|
|
568
568
|
const o = n.getUnitId(), l = s.getSheetId();
|
|
569
569
|
if (e.getFilterModel(o, l))
|
|
@@ -581,7 +581,7 @@ const R = {
|
|
|
581
581
|
id: "sheet.command.set-filter-criteria",
|
|
582
582
|
type: O.COMMAND,
|
|
583
583
|
handler: (i, t) => {
|
|
584
|
-
const e = i.get(M), r = i.get(
|
|
584
|
+
const e = i.get(M), r = i.get(N), n = i.get(J), { unitId: s, subUnitId: o, col: l, criteria: a } = t, c = e.getFilterModel(s, o);
|
|
585
585
|
if (!c) return !1;
|
|
586
586
|
const u = c.getRange();
|
|
587
587
|
if (!u || l < u.startColumn || l > u.endColumn) return !1;
|
|
@@ -604,11 +604,11 @@ const R = {
|
|
|
604
604
|
id: "sheet.command.clear-filter-criteria",
|
|
605
605
|
type: O.COMMAND,
|
|
606
606
|
handler: (i, t) => {
|
|
607
|
-
const e = i.get(M), r = i.get(
|
|
607
|
+
const e = i.get(M), r = i.get(J), n = i.get(N), s = i.get(T), o = H(s, t);
|
|
608
608
|
if (!o) return !1;
|
|
609
609
|
const { unitId: l, subUnitId: a } = o, c = e.getFilterModel(o.unitId, o.subUnitId);
|
|
610
610
|
if (!c) return !1;
|
|
611
|
-
const u = c.serialize(), d =
|
|
611
|
+
const u = c.serialize(), d = Te(l, a, u), h = Vt(l, a, u);
|
|
612
612
|
return j(h, n).result ? (r.pushUndoRedo({
|
|
613
613
|
unitID: l,
|
|
614
614
|
undoMutations: d,
|
|
@@ -619,7 +619,7 @@ const R = {
|
|
|
619
619
|
id: "sheet.command.re-calc-filter",
|
|
620
620
|
type: O.COMMAND,
|
|
621
621
|
handler: (i, t) => {
|
|
622
|
-
const e = i.get(M), r = i.get(
|
|
622
|
+
const e = i.get(M), r = i.get(N), n = i.get(T), s = H(n, t);
|
|
623
623
|
if (!s) return !1;
|
|
624
624
|
const { unitId: o, subUnitId: l } = s;
|
|
625
625
|
return e.getFilterModel(s.unitId, s.subUnitId) ? r.executeCommand(B.id, { unitId: o, subUnitId: l }) : !1;
|
|
@@ -634,9 +634,9 @@ function Ht(i, t, e) {
|
|
|
634
634
|
range: e.ref
|
|
635
635
|
}
|
|
636
636
|
};
|
|
637
|
-
return r.push(n),
|
|
637
|
+
return r.push(n), Te(i, t, e).forEach((o) => r.push(o)), r;
|
|
638
638
|
}
|
|
639
|
-
function
|
|
639
|
+
function Te(i, t, e) {
|
|
640
640
|
var n;
|
|
641
641
|
const r = [];
|
|
642
642
|
return (n = e.filterColumns) == null || n.forEach((s) => {
|
|
@@ -1003,7 +1003,7 @@ let z = class extends U {
|
|
|
1003
1003
|
const { colIndex: m, filter: v } = d[f], E = f;
|
|
1004
1004
|
if (v) {
|
|
1005
1005
|
if (E >= w && E <= S) {
|
|
1006
|
-
const
|
|
1006
|
+
const Z = {
|
|
1007
1007
|
unitId: r,
|
|
1008
1008
|
subUnitId: n,
|
|
1009
1009
|
col: E,
|
|
@@ -1014,16 +1014,16 @@ let z = class extends U {
|
|
|
1014
1014
|
col: E,
|
|
1015
1015
|
criteria: s.getFilterColumn(E) ? { ...(re = s.getFilterColumn(E)) == null ? void 0 : re.serialize(), colId: E } : null
|
|
1016
1016
|
};
|
|
1017
|
-
c.push({ id: p.id, params:
|
|
1017
|
+
c.push({ id: p.id, params: Z }), u.push({ id: p.id, params: Ie });
|
|
1018
1018
|
}
|
|
1019
1019
|
if (!((ne = d[m]) != null && ne.filter)) {
|
|
1020
|
-
const
|
|
1020
|
+
const Z = {
|
|
1021
1021
|
unitId: r,
|
|
1022
1022
|
subUnitId: n,
|
|
1023
1023
|
col: m,
|
|
1024
1024
|
criteria: null
|
|
1025
1025
|
};
|
|
1026
|
-
c.push({ id: p.id, params:
|
|
1026
|
+
c.push({ id: p.id, params: Z }), u.push({ id: p.id, params: { unitId: r, subUnitId: n, col: m, criteria: { ...v.serialize(), colId: m } } });
|
|
1027
1027
|
}
|
|
1028
1028
|
}
|
|
1029
1029
|
}), l !== w || a !== S) {
|
|
@@ -1085,7 +1085,7 @@ let z = class extends U {
|
|
|
1085
1085
|
if (!l)
|
|
1086
1086
|
return this._handleNull();
|
|
1087
1087
|
const a = [], c = [];
|
|
1088
|
-
if (
|
|
1088
|
+
if (te.contains(n, l)) {
|
|
1089
1089
|
const u = l.startRow - n.startRow, d = l.startColumn - n.startColumn, h = {
|
|
1090
1090
|
startRow: s.startRow + u,
|
|
1091
1091
|
startColumn: s.startColumn + d,
|
|
@@ -1104,7 +1104,7 @@ let z = class extends U {
|
|
|
1104
1104
|
const [m, v] = f;
|
|
1105
1105
|
v && (a.push({ id: p.id, params: { unitId: e, subUnitId: r, col: m + F, criteria: { ...v.serialize(), colId: m + F } } }), c.push({ id: p.id, params: { unitId: e, subUnitId: r, col: m, criteria: { ...v.serialize(), colId: m } } }));
|
|
1106
1106
|
});
|
|
1107
|
-
} else if (
|
|
1107
|
+
} else if (te.intersects(s, l)) {
|
|
1108
1108
|
const u = {
|
|
1109
1109
|
...l,
|
|
1110
1110
|
endRow: Math.max(l.endRow, s.endRow)
|
|
@@ -1300,10 +1300,10 @@ let z = class extends U {
|
|
|
1300
1300
|
}
|
|
1301
1301
|
};
|
|
1302
1302
|
z = qt([
|
|
1303
|
-
I(0,
|
|
1303
|
+
I(0, N),
|
|
1304
1304
|
I(1, A(Qe)),
|
|
1305
1305
|
I(2, A(M)),
|
|
1306
|
-
I(3,
|
|
1306
|
+
I(3, T),
|
|
1307
1307
|
I(4, A(Je)),
|
|
1308
1308
|
I(5, He(gt)),
|
|
1309
1309
|
I(6, A(Ze))
|
|
@@ -1312,7 +1312,7 @@ var Gt = Object.getOwnPropertyDescriptor, Qt = (i, t, e, r) => {
|
|
|
1312
1312
|
for (var n = r > 1 ? void 0 : r ? Gt(t, e) : t, s = i.length - 1, o; s >= 0; s--)
|
|
1313
1313
|
(o = i[s]) && (n = o(n) || n);
|
|
1314
1314
|
return n;
|
|
1315
|
-
},
|
|
1315
|
+
}, ee = (i, t) => (e, r) => t(e, r, i);
|
|
1316
1316
|
const Jt = [
|
|
1317
1317
|
p.id,
|
|
1318
1318
|
B.id
|
|
@@ -1321,7 +1321,7 @@ const Jt = [
|
|
|
1321
1321
|
Re.id,
|
|
1322
1322
|
pe.id
|
|
1323
1323
|
];
|
|
1324
|
-
let
|
|
1324
|
+
let G = class extends U {
|
|
1325
1325
|
constructor(t, e, r) {
|
|
1326
1326
|
super();
|
|
1327
1327
|
C(this, "_d", new me());
|
|
@@ -1365,17 +1365,17 @@ let q = class extends U {
|
|
|
1365
1365
|
);
|
|
1366
1366
|
}
|
|
1367
1367
|
};
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
],
|
|
1368
|
+
G = Qt([
|
|
1369
|
+
ee(0, A(z)),
|
|
1370
|
+
ee(1, N),
|
|
1371
|
+
ee(2, ge)
|
|
1372
|
+
], G);
|
|
1373
1373
|
var Kt = Object.getOwnPropertyDescriptor, Yt = (i, t, e, r) => {
|
|
1374
1374
|
for (var n = r > 1 ? void 0 : r ? Kt(t, e) : t, s = i.length - 1, o; s >= 0; s--)
|
|
1375
1375
|
(o = i[s]) && (n = o(n) || n);
|
|
1376
1376
|
return n;
|
|
1377
1377
|
}, V = (i, t) => (e, r) => t(e, r, i);
|
|
1378
|
-
let
|
|
1378
|
+
let Q = class extends U {
|
|
1379
1379
|
constructor(i, t, e, r) {
|
|
1380
1380
|
super(), this._activeDirtyManagerService = i, this._sheetRowFilteredService = t, this._sheetsFilterService = e, this._univerInstanceService = r, this._initFormulaDirtyRange(), this._registerSheetRowFiltered();
|
|
1381
1381
|
}
|
|
@@ -1424,12 +1424,12 @@ let G = class extends U {
|
|
|
1424
1424
|
});
|
|
1425
1425
|
}
|
|
1426
1426
|
};
|
|
1427
|
-
|
|
1427
|
+
Q = Yt([
|
|
1428
1428
|
V(0, A(_t)),
|
|
1429
1429
|
V(1, A(Ct)),
|
|
1430
1430
|
V(2, A(M)),
|
|
1431
|
-
V(3,
|
|
1432
|
-
],
|
|
1431
|
+
V(3, T)
|
|
1432
|
+
], Q);
|
|
1433
1433
|
var Xt = Object.getOwnPropertyDescriptor, er = (i, t, e, r) => {
|
|
1434
1434
|
for (var n = r > 1 ? void 0 : r ? Xt(t, e) : t, s = i.length - 1, o; s >= 0; s--)
|
|
1435
1435
|
(o = i[s]) && (n = o(n) || n);
|
|
@@ -1447,20 +1447,20 @@ let fe = (W = class extends Ve {
|
|
|
1447
1447
|
}
|
|
1448
1448
|
onStarting() {
|
|
1449
1449
|
[
|
|
1450
|
-
[
|
|
1450
|
+
[Q],
|
|
1451
1451
|
[M],
|
|
1452
1452
|
[z],
|
|
1453
|
-
[
|
|
1453
|
+
[G]
|
|
1454
1454
|
].forEach((i) => this._injector.add(i));
|
|
1455
1455
|
}
|
|
1456
1456
|
onReady() {
|
|
1457
1457
|
je(this._injector, [
|
|
1458
|
-
[
|
|
1458
|
+
[Q],
|
|
1459
1459
|
[z],
|
|
1460
|
-
[
|
|
1460
|
+
[G]
|
|
1461
1461
|
]);
|
|
1462
1462
|
}
|
|
1463
|
-
}, C(W, "type", D.UNIVER_SHEET), C(W, "pluginName",
|
|
1463
|
+
}, C(W, "type", D.UNIVER_SHEET), C(W, "pluginName", Ne), W);
|
|
1464
1464
|
fe = er([
|
|
1465
1465
|
he(1, A(ke)),
|
|
1466
1466
|
he(2, ge)
|
|
@@ -1471,18 +1471,18 @@ export {
|
|
|
1471
1471
|
Me as FILTER_MUTATIONS,
|
|
1472
1472
|
b as FilterBy,
|
|
1473
1473
|
yt as FilterColumn,
|
|
1474
|
-
|
|
1474
|
+
q as FilterModel,
|
|
1475
1475
|
ur as ReCalcSheetsFilterCommand,
|
|
1476
1476
|
B as ReCalcSheetsFilterMutation,
|
|
1477
1477
|
zt as RemoveSheetFilterCommand,
|
|
1478
1478
|
y as RemoveSheetsFilterMutation,
|
|
1479
|
-
|
|
1479
|
+
Ne as SHEET_FILTER_SNAPSHOT_ID,
|
|
1480
1480
|
Bt as SetSheetFilterRangeCommand,
|
|
1481
1481
|
cr as SetSheetsFilterCriteriaCommand,
|
|
1482
1482
|
p as SetSheetsFilterCriteriaMutation,
|
|
1483
1483
|
R as SetSheetsFilterRangeMutation,
|
|
1484
1484
|
M as SheetsFilterService,
|
|
1485
|
-
|
|
1485
|
+
G as SheetsFilterSyncController,
|
|
1486
1486
|
ar as SmartToggleSheetsFilterCommand,
|
|
1487
1487
|
fe as UniverSheetsFilterPlugin,
|
|
1488
1488
|
wt as equals,
|