@univerjs/preset-sheets-filter 0.5.3 → 0.5.5

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.
@@ -1,4 +1,5 @@
1
1
  import { IPreset } from './types';
2
2
  import '@univerjs/sheets-filter/facade';
3
3
  import '@univerjs/sheets-filter-ui/lib/index.css';
4
+ export type * from '@univerjs/sheets-filter/facade';
4
5
  export declare function UniverSheetsFilterPreset(): IPreset;
package/lib/umd/index.js CHANGED
@@ -7,7 +7,7 @@
7
7
 
8
8
 
9
9
  // @univerjs/sheets-filter-ui/index
10
- (function(v,c){typeof exports=="object"&&typeof module<"u"?c(exports,require("@univerjs/core"),require("@univerjs/rpc"),require("@univerjs/sheets-filter"),require("@univerjs/sheets"),require("@univerjs/sheets-ui"),require("@univerjs/ui"),require("rxjs"),require("@univerjs/design"),require("@univerjs/engine-render"),require("react")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/rpc","@univerjs/sheets-filter","@univerjs/sheets","@univerjs/sheets-ui","@univerjs/ui","rxjs","@univerjs/design","@univerjs/engine-render","react"],c):(v=typeof globalThis<"u"?globalThis:v||self,c(v.UniverSheetsFilterUi={},v.UniverCore,v.UniverRpc,v.UniverSheetsFilter,v.UniverSheets,v.UniverSheetsUi,v.UniverUi,v.rxjs,v.UniverDesign,v.UniverEngineRender,v.React))})(this,function(v,c,k,u,P,U,E,C,L,ie,y){"use strict";var ir=Object.defineProperty;var sr=(v,c,k)=>c in v?ir(v,c,{enumerable:!0,configurable:!0,writable:!0,value:k}):v[c]=k;var S=(v,c,k)=>sr(v,typeof c!="symbol"?c+"":c,k);var Se;const $e="sheets-filter-ui.config",ue={};var R=(t=>(t[t.FIRST=0]="FIRST",t[t.SECOND=1]="SECOND",t))(R||{}),g=(t=>(t.NONE="none",t.STARTS_WITH="startsWith",t.DOES_NOT_START_WITH="doesNotStartWith",t.ENDS_WITH="endsWith",t.DOES_NOT_END_WITH="doesNotEndWith",t.CONTAINS="contains",t.DOES_NOT_CONTAIN="doesNotContain",t.EQUALS="equals",t.NOT_EQUALS="notEquals",t.EMPTY="empty",t.NOT_EMPTY="notEmpty",t.BETWEEN="between",t.NOT_BETWEEN="notBetween",t.CUSTOM="custom",t))(g||{}),d;(t=>{t.NONE={label:"sheets-filter.conditions.none",operator:g.NONE,order:R.SECOND,numOfParameters:0,getDefaultFormParams:()=>{throw new Error("[FilterConditionItems.NONE]: should not have initial form params!")},testMappingParams:n=>n.operator1===g.NONE,mapToFilterColumn:()=>null,testMappingFilterColumn:n=>!n.customFilters&&!n.filters?{}:!1},t.EMPTY={label:"sheets-filter.conditions.empty",operator:g.EMPTY,order:R.SECOND,numOfParameters:0,getDefaultFormParams:()=>{throw new Error("[FilterConditionItems.EMPTY]: should not have initial form params!")},testMappingParams:({operator1:n})=>n===g.EMPTY,mapToFilterColumn:()=>({customFilters:{customFilters:[{val:""}]}}),testMappingFilterColumn:n=>{var h;if(((h=n.customFilters)==null?void 0:h.customFilters.length)!==1)return!1;const o=n.customFilters.customFilters[0];return o.val===""&&o.operator===void 0?{operator1:g.EMPTY}:!1}},t.NOT_EMPTY={label:"sheets-filter.conditions.not-empty",operator:g.NOT_EMPTY,order:R.SECOND,numOfParameters:0,getDefaultFormParams:()=>{throw new Error("[FilterConditionItems.NOT_EMPTY]: should not have initial form params!")},testMappingParams:({operator1:n})=>n===g.NOT_EMPTY,mapToFilterColumn:()=>({customFilters:{customFilters:[{val:"",operator:u.CustomFilterOperator.NOT_EQUALS}]}}),testMappingFilterColumn:n=>{var h;if(((h=n.customFilters)==null?void 0:h.customFilters.length)!==1)return!1;const o=n.customFilters.customFilters[0];return o.val===" "&&o.operator===u.CustomFilterOperator.NOT_EQUALS?{operator1:g.NOT_EMPTY}:!1}},t.TEXT_CONTAINS={label:"sheets-filter.conditions.text-contains",operator:g.CONTAINS,order:R.FIRST,numOfParameters:1,getDefaultFormParams:()=>({operator1:g.CONTAINS,val1:""}),testMappingParams:n=>{const[o]=B(n);return o===g.CONTAINS},mapToFilterColumn:n=>{const{val1:o}=n;return o===""?null:{customFilters:{customFilters:[{val:`*${o}*`}]}}},testMappingFilterColumn:n=>{var h;if(((h=n.customFilters)==null?void 0:h.customFilters.length)!==1)return!1;const o=n.customFilters.customFilters[0],a=o.val.toString();return!o.operator&&a.startsWith("*")&&a.endsWith("*")?{operator1:g.CONTAINS,val1:a.slice(1,-1)}:!1}},t.DOES_NOT_CONTAIN={label:"sheets-filter.conditions.does-not-contain",operator:g.DOES_NOT_CONTAIN,order:R.FIRST,numOfParameters:1,getDefaultFormParams:()=>({operator1:g.DOES_NOT_CONTAIN,val1:""}),mapToFilterColumn:n=>({customFilters:{customFilters:[{val:`*${n.val1}*`,operator:u.CustomFilterOperator.NOT_EQUALS}]}}),testMappingParams:n=>{const[o]=B(n);return o===g.DOES_NOT_CONTAIN},testMappingFilterColumn:n=>{var h;if(((h=n.customFilters)==null?void 0:h.customFilters.length)!==1)return!1;const o=n.customFilters.customFilters[0],a=o.val.toString();return o.operator===u.CustomFilterOperator.NOT_EQUALS&&a.startsWith("*")&&a.endsWith("*")?{operator1:g.DOES_NOT_CONTAIN,val1:a.slice(1,-1)}:!1}},t.STARTS_WITH={label:"sheets-filter.conditions.starts-with",operator:g.STARTS_WITH,order:R.FIRST,numOfParameters:1,getDefaultFormParams:()=>({operator1:g.STARTS_WITH,val1:""}),mapToFilterColumn:n=>({customFilters:{customFilters:[{val:`${n.val1}*`}]}}),testMappingParams:n=>{const[o]=B(n);return o===g.STARTS_WITH},testMappingFilterColumn:n=>{var h;if(((h=n.customFilters)==null?void 0:h.customFilters.length)!==1)return!1;const o=n.customFilters.customFilters[0],a=o.val.toString();return!o.operator&&a.endsWith("*")&&!a.startsWith("*")?{operator1:g.STARTS_WITH,val1:a.slice(0,-1)}:!1}},t.ENDS_WITH={label:"sheets-filter.conditions.ends-with",operator:g.ENDS_WITH,order:R.FIRST,numOfParameters:1,getDefaultFormParams:()=>({operator1:g.ENDS_WITH,val1:""}),mapToFilterColumn:n=>({customFilters:{customFilters:[{val:`*${n.val1}`}]}}),testMappingParams:n=>{const[o]=B(n);return o===g.ENDS_WITH},testMappingFilterColumn:n=>{var h;if(((h=n.customFilters)==null?void 0:h.customFilters.length)!==1)return!1;const o=n.customFilters.customFilters[0],a=o.val.toString();return!o.operator&&a.startsWith("*")&&!a.endsWith("*")?{operator1:g.ENDS_WITH,val1:a.slice(1)}:!1}},t.EQUALS={label:"sheets-filter.conditions.equals",operator:g.EQUALS,order:R.FIRST,numOfParameters:1,getDefaultFormParams:()=>({operator1:g.EQUALS,val1:""}),testMappingParams:n=>{const[o]=B(n);return o===g.EQUALS},mapToFilterColumn:n=>{const{val1:o}=n;return o===""?null:{customFilters:{customFilters:[{val:o}]}}},testMappingFilterColumn:n=>{var o,a,h;return((a=(o=n.filters)==null?void 0:o.filters)==null?void 0:a.length)===1?{operator1:g.EQUALS,val1:""}:((h=n.customFilters)==null?void 0:h.customFilters.length)===1&&!n.customFilters.customFilters[0].operator?{operator1:g.EQUALS,val1:n.customFilters.customFilters[0].val.toString()}:!1}},t.GREATER_THAN={label:"sheets-filter.conditions.greater-than",operator:u.CustomFilterOperator.GREATER_THAN,numOfParameters:1,order:R.FIRST,getDefaultFormParams:()=>({operator1:u.CustomFilterOperator.GREATER_THAN,val1:""}),mapToFilterColumn:n=>({customFilters:{customFilters:[{val:n.val1,operator:u.CustomFilterOperator.GREATER_THAN}]}}),testMappingParams:n=>{const[o]=B(n);return o===u.CustomFilterOperator.GREATER_THAN},testMappingFilterColumn:n=>{var a;if(((a=n.customFilters)==null?void 0:a.customFilters.length)!==1)return!1;const o=n.customFilters.customFilters[0];return o.operator!==u.CustomFilterOperator.GREATER_THAN?!1:{operator1:u.CustomFilterOperator.GREATER_THAN,val1:o.val.toString()}}},t.GREATER_THAN_OR_EQUAL={label:"sheets-filter.conditions.greater-than-or-equal",operator:u.CustomFilterOperator.GREATER_THAN_OR_EQUAL,numOfParameters:1,order:R.FIRST,getDefaultFormParams:()=>({operator1:u.CustomFilterOperator.GREATER_THAN_OR_EQUAL,val1:""}),testMappingParams:n=>{const[o]=B(n);return o===u.CustomFilterOperator.GREATER_THAN_OR_EQUAL},mapToFilterColumn:n=>({customFilters:{customFilters:[{val:n.val1,operator:u.CustomFilterOperator.GREATER_THAN_OR_EQUAL}]}}),testMappingFilterColumn:n=>{var a;if(((a=n.customFilters)==null?void 0:a.customFilters.length)!==1)return!1;const o=n.customFilters.customFilters[0];return o.operator!==u.CustomFilterOperator.GREATER_THAN_OR_EQUAL?!1:{operator1:u.CustomFilterOperator.GREATER_THAN_OR_EQUAL,val1:o.val.toString()}}},t.LESS_THAN={label:"sheets-filter.conditions.less-than",operator:u.CustomFilterOperator.LESS_THAN,numOfParameters:1,order:R.FIRST,getDefaultFormParams:()=>({operator1:u.CustomFilterOperator.LESS_THAN,val1:""}),testMappingParams:n=>{const[o]=B(n);return o===u.CustomFilterOperator.LESS_THAN},mapToFilterColumn:n=>({customFilters:{customFilters:[{val:n.val1,operator:u.CustomFilterOperator.LESS_THAN}]}}),testMappingFilterColumn:n=>{var a;if(((a=n.customFilters)==null?void 0:a.customFilters.length)!==1)return!1;const o=n.customFilters.customFilters[0];return o.operator!==u.CustomFilterOperator.LESS_THAN?!1:{operator1:u.CustomFilterOperator.LESS_THAN,val1:o.val.toString()}}},t.LESS_THAN_OR_EQUAL={label:"sheets-filter.conditions.less-than-or-equal",operator:u.CustomFilterOperator.LESS_THAN_OR_EQUAL,numOfParameters:1,order:R.FIRST,getDefaultFormParams:()=>({operator1:u.CustomFilterOperator.LESS_THAN_OR_EQUAL,val1:""}),testMappingParams:n=>{const[o]=B(n);return o===u.CustomFilterOperator.LESS_THAN_OR_EQUAL},mapToFilterColumn:n=>({customFilters:{customFilters:[{val:n.val1,operator:u.CustomFilterOperator.LESS_THAN_OR_EQUAL}]}}),testMappingFilterColumn:n=>{var a;if(((a=n.customFilters)==null?void 0:a.customFilters.length)!==1)return!1;const o=n.customFilters.customFilters[0];return o.operator!==u.CustomFilterOperator.LESS_THAN_OR_EQUAL?!1:{operator1:u.CustomFilterOperator.LESS_THAN_OR_EQUAL,val1:o.val.toString()}}},t.EQUAL={label:"sheets-filter.conditions.equal",operator:u.CustomFilterOperator.EQUAL,numOfParameters:1,order:R.FIRST,getDefaultFormParams:()=>({operator1:u.CustomFilterOperator.EQUAL,val1:""}),testMappingParams:n=>{const[o]=B(n);return o===u.CustomFilterOperator.EQUAL},mapToFilterColumn:n=>({customFilters:{customFilters:[{val:n.val1,operator:u.CustomFilterOperator.EQUAL}]}}),testMappingFilterColumn:n=>{var a;if(((a=n.customFilters)==null?void 0:a.customFilters.length)!==1)return!1;const o=n.customFilters.customFilters[0];return o.operator!==u.CustomFilterOperator.EQUAL?!1:{operator1:u.CustomFilterOperator.EQUAL,val1:o.val.toString()}}},t.NOT_EQUAL={label:"sheets-filter.conditions.not-equal",operator:u.CustomFilterOperator.NOT_EQUALS,numOfParameters:1,order:R.FIRST,getDefaultFormParams:()=>({operator1:u.CustomFilterOperator.NOT_EQUALS,val1:""}),testMappingParams:n=>{const[o]=B(n);return o===u.CustomFilterOperator.NOT_EQUALS},mapToFilterColumn:n=>({customFilters:{customFilters:[{val:n.val1,operator:u.CustomFilterOperator.NOT_EQUALS}]}}),testMappingFilterColumn:n=>{var a;if(((a=n.customFilters)==null?void 0:a.customFilters.length)!==1)return!1;const o=n.customFilters.customFilters[0];return o.operator!==u.CustomFilterOperator.NOT_EQUALS?!1:{operator1:u.CustomFilterOperator.NOT_EQUALS,val1:o.val.toString()}}},t.BETWEEN={label:"sheets-filter.conditions.between",operator:g.BETWEEN,order:R.SECOND,numOfParameters:2,getDefaultFormParams:()=>({and:!0,operator1:u.CustomFilterOperator.GREATER_THAN_OR_EQUAL,val1:"",operator2:u.CustomFilterOperator.LESS_THAN_OR_EQUAL,val2:""}),testMappingParams:n=>{const{and:o,operator1:a,operator2:h}=n;if(!o)return!1;const m=[a,h];return m.includes(u.CustomFilterOperator.GREATER_THAN_OR_EQUAL)&&m.includes(u.CustomFilterOperator.LESS_THAN_OR_EQUAL)},mapToFilterColumn:n=>{const{val1:o,val2:a,operator1:h}=n,m=h===u.CustomFilterOperator.GREATER_THAN_OR_EQUAL;return{customFilters:{and:c.BooleanNumber.TRUE,customFilters:[{val:m?o:a,operator:u.CustomFilterOperator.GREATER_THAN_OR_EQUAL},{val:m?a:o,operator:u.CustomFilterOperator.LESS_THAN_OR_EQUAL}]}}},testMappingFilterColumn:n=>{var h;if(((h=n.customFilters)==null?void 0:h.customFilters.length)!==2)return!1;const[o,a]=n.customFilters.customFilters;return o.operator===u.CustomFilterOperator.GREATER_THAN_OR_EQUAL&&a.operator===u.CustomFilterOperator.LESS_THAN_OR_EQUAL&&n.customFilters.and?{and:!0,operator1:u.CustomFilterOperator.GREATER_THAN_OR_EQUAL,val1:o.val.toString(),operator2:u.CustomFilterOperator.LESS_THAN_OR_EQUAL,val2:a.val.toString()}:a.operator===u.CustomFilterOperator.GREATER_THAN_OR_EQUAL&&o.operator===u.CustomFilterOperator.LESS_THAN_OR_EQUAL&&n.customFilters.and?{and:!0,operator1:u.CustomFilterOperator.GREATER_THAN_OR_EQUAL,val1:a.val.toString(),operator2:u.CustomFilterOperator.LESS_THAN_OR_EQUAL,val2:o.val.toLocaleString()}:!1}},t.NOT_BETWEEN={label:"sheets-filter.conditions.not-between",operator:g.NOT_BETWEEN,order:R.SECOND,numOfParameters:2,getDefaultFormParams:()=>({operator1:u.CustomFilterOperator.LESS_THAN,val1:"",operator2:u.CustomFilterOperator.GREATER_THAN,val2:""}),testMappingParams:n=>{const{and:o,operator1:a,operator2:h}=n;if(o)return!1;const m=[a,h];return m.includes(u.CustomFilterOperator.GREATER_THAN)&&m.includes(u.CustomFilterOperator.LESS_THAN)},mapToFilterColumn:n=>{const{val1:o,val2:a,operator1:h}=n,m=h===u.CustomFilterOperator.GREATER_THAN;return{customFilters:{customFilters:[{val:m?o:a,operator:u.CustomFilterOperator.GREATER_THAN},{val:m?a:o,operator:u.CustomFilterOperator.LESS_THAN}]}}},testMappingFilterColumn:n=>{var h;if(((h=n.customFilters)==null?void 0:h.customFilters.length)!==2)return!1;const[o,a]=n.customFilters.customFilters;return o.operator===u.CustomFilterOperator.LESS_THAN&&a.operator===u.CustomFilterOperator.GREATER_THAN&&!n.customFilters.and?{operator1:u.CustomFilterOperator.LESS_THAN,val1:o.val.toString(),operator2:u.CustomFilterOperator.GREATER_THAN,val2:a.val.toString()}:a.operator===u.CustomFilterOperator.LESS_THAN&&o.operator===u.CustomFilterOperator.GREATER_THAN&&!n.customFilters.and?{operator1:u.CustomFilterOperator.GREATER_THAN,val1:a.val.toString(),operator2:u.CustomFilterOperator.LESS_THAN,val2:o.val.toLocaleString()}:!1}},t.CUSTOM={label:"sheets-filter.conditions.custom",operator:g.CUSTOM,order:R.SECOND,numOfParameters:2,getDefaultFormParams:()=>({operator1:g.NONE,val1:"",operator2:g.NONE,val2:""}),testMappingParams:()=>!0,mapToFilterColumn:n=>{const{and:o,val1:a,val2:h,operator1:m,operator2:p}=n;function T(w,M){for(const j of t.ALL_CONDITIONS)if(j.operator===w)return j.mapToFilterColumn({val1:M,operator1:w})}const _=!m||m===t.NONE.operator,O=!p||p===t.NONE.operator;if(_&&O)return t.NONE.mapToFilterColumn({});if(_)return T(p,h);if(O)return T(m,a);const F=T(m,a),A=T(p,h),N={customFilters:[F.customFilters.customFilters[0],A.customFilters.customFilters[0]]};return o&&(N.and=c.BooleanNumber.TRUE),{customFilters:N}},testMappingFilterColumn:n=>{var h;if(((h=n.customFilters)==null?void 0:h.customFilters.length)!==2)return!1;const o=n.customFilters.customFilters.map(m=>l({customFilters:{customFilters:[m]}})),a={operator1:o[0][0].operator,val1:o[0][1].val1,operator2:o[1][0].operator,val2:o[1][1].val1};return n.customFilters.and&&(a.and=!0),a}},t.ALL_CONDITIONS=[t.NONE,t.EMPTY,t.NOT_EMPTY,t.TEXT_CONTAINS,t.DOES_NOT_CONTAIN,t.STARTS_WITH,t.ENDS_WITH,t.EQUALS,t.GREATER_THAN,t.GREATER_THAN_OR_EQUAL,t.LESS_THAN,t.LESS_THAN_OR_EQUAL,t.EQUAL,t.NOT_EQUAL,t.BETWEEN,t.NOT_BETWEEN,t.CUSTOM];function e(n){const o=t.ALL_CONDITIONS.find(a=>a.operator===n);if(!o)throw new Error(`[SheetsFilter]: no condition item found for operator: ${n}`);return o}t.getItemByOperator=e;function r(n,o){for(const a of t.ALL_CONDITIONS.filter(h=>h.numOfParameters===o))if(a.numOfParameters!==0&&a.testMappingParams(n))return a;for(const a of t.ALL_CONDITIONS)if(a.testMappingParams(n))return a;throw new Error("[SheetsFilter]: no condition item can be mapped from the filter map params!")}t.testMappingParams=r;function i(n){const o=t.ALL_CONDITIONS.find(a=>a.operator===n);return(o==null?void 0:o.numOfParameters)===0?{operator1:o.operator}:o.getDefaultFormParams()}t.getInitialFormParams=i;function s(n,o){return n.mapToFilterColumn(o)}t.mapToFilterColumn=s;function l(n){if(!n)return[t.NONE,{}];for(const o of t.ALL_CONDITIONS){const a=o.testMappingFilterColumn(n);if(a)return[o,a]}return[t.NONE,{}]}t.testMappingFilterColumn=l})(d||(d={}));function B(t){const{operator1:e,operator2:r,val1:i,val2:s}=t;if(e&&r)throw new Error("Both operator1 and operator2 are set!");if(!e&&!r)throw new Error("Neither operator1 and operator2 and both not set!");return e?[e,i]:[r,s]}function Fe(t){const e=[],r=[];let i=0,s=0;function l(n){n.leaf&&(n.checked?(e.push(n),i+=n.count):(r.push(n),s+=n.count)),n.children&&n.children.forEach(l)}return t.forEach(l),{checkedItems:e,uncheckedItems:r,checked:i,unchecked:s}}var tt=Object.defineProperty,rt=Object.getOwnPropertyDescriptor,nt=(t,e,r,i)=>{for(var s=i>1?void 0:i?rt(e,r):e,l=t.length-1,n;l>=0;l--)(n=t[l])&&(s=(i?n(e,r,s):n(s))||s);return i&&s&&tt(e,r,s),s},Ee=(t,e)=>(r,i)=>e(r,i,t);const Oe="sheets-filter.generate-filter-values.service",he=c.createIdentifier(Oe),it=["yyyy-mm-dd","yyyy-mm-dd;@","yyyy/mm/dd;@","yyyy/mm/dd hh:mm","yyyy-m-d am/pm h:mm","yyyy-MM-dd","yyyy/MM/dd","yyyy/mm/dd",'yyyy"年"MM"月"dd"日"',"MM-dd",'M"月"d"日"',"MM-dd A/P hh:mm"];let Pe=class extends c.Disposable{constructor(t,e,r){super(),this._localeService=t,this._univerInstanceService=e,this._logService=r}async getFilterValues(t){var m;const{unitId:e,subUnitId:r,filteredOutRowsByOtherColumns:i,filters:s,blankChecked:l,iterateRange:n,alreadyChecked:o}=t,a=this._univerInstanceService.getUnit(e),h=(m=this._univerInstanceService.getUnit(e))==null?void 0:m.getSheetBySheetId(r);return!a||!h?[]:(this._logService.debug("[SheetsGenerateFilterValuesService]","getFilterValues for",{unitId:e,subUnitId:r}),De(s,this._localeService,n,h,new Set(i),new Set(o.map(String)),l,a.getStyles()))}};Pe=nt([Ee(0,c.Inject(c.LocaleService)),Ee(1,c.IUniverInstanceService),Ee(2,c.ILogService)],Pe);function De(t,e,r,i,s,l,n,o){var F,A,N,w,M,j,V,ge,Ce;const a=new Map,h=new Map,m="yyyy-mm-dd",p=new Set(it),T="empty";let _=0;for(const $ of i.iterateByColumn(r,!1,!1)){const{row:tr,rowSpan:et=1}=$;let re=0;for(;re<et;){const rr=tr+re;if(s.has(rr)){re++;continue}const q=$!=null&&$.value?c.extractPureTextFromCell($.value):"";if(!q){_+=1,re+=et;continue}const Te=(F=$.value)!=null&&F.v&&!$.value.p?(w=(N=o.get((A=$.value)==null?void 0:A.s))==null?void 0:N.n)==null?void 0:w.pattern:"",nr=Te&&c.numfmt.isDate(Te);if(Te&&nr&&p.has(Te)){const K=(M=i.getCellRaw($.row,$.col))==null?void 0:M.v;if(!K){re++;continue}const ne=c.numfmt.format(m,K),[b,W,ce]=ne.split("-").map(Number);let Z=a.get(`${b}`);Z||(Z={title:`${b}`,key:`${b}`,children:[],count:0,leaf:!1,checked:!1},a.set(`${b}`,Z),h.set(`${b}`,[`${b}`]));let Q=(j=Z.children)==null?void 0:j.find(we=>we.key===`${b}-${W}`);Q||(Q={title:e.t(`sheets-filter.date.${W}`),key:`${b}-${W}`,children:[],count:0,leaf:!1,checked:!1},(V=Z.children)==null||V.push(Q),h.set(`${b}-${W}`,[`${b}`,`${b}-${W}`]));const Ue=(ge=Q==null?void 0:Q.children)==null?void 0:ge.find(we=>we.key===`${b}-${W}-${ce}`);Ue?(Ue.originValues.add(q),Ue.count++,Q.count++,Z.count++):((Ce=Q.children)==null||Ce.push({title:`${ce}`,key:`${b}-${W}-${ce}`,count:1,originValues:new Set([q]),leaf:!0,checked:l.size?l.has(q):!n}),Q.count++,Z.count++,h.set(`${b}-${W}-${ce}`,[`${b}`,`${b}-${W}`,`${b}-${W}-${ce}`]))}else{const K=q;let ne=a.get(K);ne?ne.count++:(ne={title:q,leaf:!0,checked:l.size?l.has(q):!n,key:K,count:1},a.set(K,ne),h.set(K,[K]))}re++}}const O=t?n:!0;if(_>0){const $={title:e.t("sheets-filter.panel.empty"),count:_,leaf:!0,checked:O,key:T};a.set("empty",$),h.set("empty",[T])}return{filterTreeItems:st(Array.from(a.values())),filterTreeMapCache:h}}function st(t){return Array.from(t).sort((e,r)=>e.children&&!r.children?-1:!e.children&&r.children?1:r.title.localeCompare(e.title)).map(e=>(e.children&&e.children.sort((r,i)=>{const s=Number.parseInt(r.key.split("-")[1],10),l=Number.parseInt(i.key.split("-")[1],10);return s-l}).forEach(r=>{r.children&&r.children.sort((i,s)=>{const l=Number.parseInt(i.key.split("-")[2],10),n=Number.parseInt(s.key.split("-")[2],10);return l-n})}),e))}function Ie(t,e){for(const r of t){if(r.key===e)return r;if(r.children){const i=Ie(r.children,e);if(i)return i}}return null}function He(t){return t.leaf?t.checked:t.children?t.children.every(e=>He(e)):!0}function se(t,e){t.leaf&&(e!==void 0?t.checked=e:t.checked=!t.checked),t.children&&t.children.forEach(r=>se(r,e))}function Be(t,e){const r=[];return t.forEach(i=>{const s=i.originValues?e.some(o=>Array.from(i.originValues).some(a=>a.toLowerCase().includes(o.toLowerCase()))):!1,l=!s&&e.some(o=>i.title.toLowerCase().includes(o.toLowerCase()));if(s||l)r.push({...i});else if(i.children){const o=Be(i.children,e);if(o.length>0){const a=o.reduce((h,m)=>h+m.count,0);r.push({...i,count:a,children:o})}}}),r}var ot=Object.defineProperty,at=Object.getOwnPropertyDescriptor,Ne=(t,e,r,i)=>{for(var s=i>1?void 0:i?at(e,r):e,l=t.length-1,n;l>=0;l--)(n=t[l])&&(s=(i?n(e,r,s):n(s))||s);return i&&s&&ot(e,r,s),s},me=(t,e)=>(r,i)=>e(r,i,t),pe=(t=>(t[t.VALUES=0]="VALUES",t[t.CONDITIONS=1]="CONDITIONS",t))(pe||{});c.createIdentifier("sheets-filter-ui.sheets-filter-panel.service");let G=class extends c.Disposable{constructor(e,r){super();S(this,"_filterBy$",new C.BehaviorSubject(0));S(this,"filterBy$",this._filterBy$.asObservable());S(this,"_filterByModel$",new C.ReplaySubject(1));S(this,"filterByModel$",this._filterByModel$.asObservable());S(this,"_filterByModel",null);S(this,"_hasCriteria$",new C.BehaviorSubject(!1));S(this,"hasCriteria$",this._hasCriteria$.asObservable());S(this,"_filterModel",null);S(this,"_col$",new C.BehaviorSubject(-1));S(this,"col$",this._col$.asObservable());S(this,"_filterHeaderListener",null);this._injector=e,this._refRangeService=r}get filterBy(){return this._filterBy$.getValue()}get filterByModel(){return this._filterByModel}set filterByModel(e){this._filterByModel=e,this._filterByModel$.next(e)}get filterModel(){return this._filterModel}get col(){return this._col$.getValue()}dispose(){this._filterBy$.complete(),this._filterByModel$.complete(),this._hasCriteria$.complete()}setupCol(e,r){this.terminate(),this._filterModel=e,this._col$.next(r);const i=e.getFilterColumn(r);if(i){const s=i.getColumnData();if(s.customFilters){this._hasCriteria$.next(!0),this._setupByConditions(e,r);return}if(s.filters){this._hasCriteria$.next(!0),this._setupByValues(e,r);return}this._hasCriteria$.next(!1),this._setupByValues(e,r);return}this._hasCriteria$.next(!1),this._setupByValues(e,r)}changeFilterBy(e){return!this._filterModel||this.col===-1?!1:(e===0?this._setupByValues(this._filterModel,this.col):this._setupByConditions(this._filterModel,this.col),!0)}terminate(){return this._filterModel=null,this._col$.next(-1),this._disposeFilterHeaderChangeListener(),!0}_disposeFilterHeaderChangeListener(){var e;(e=this._filterHeaderListener)==null||e.dispose(),this._filterHeaderListener=null}_listenToFilterHeaderChange(e,r){this._disposeFilterHeaderChangeListener();const i=e.unitId,s=e.subUnitId,l=e.getRange(),n={startColumn:r,startRow:l.startRow,endRow:l.startRow,endColumn:r};this._filterHeaderListener=this._refRangeService.watchRange(i,s,n,(o,a)=>{if(!a)this.terminate();else{const h=a.startColumn-o.startColumn;h!==0&&this._filterByModel.deltaCol(h)}})}async _setupByValues(e,r){this._disposePreviousModel();const i=e.getRange();if(i.startRow===i.endRow)return!1;const s=await fe.fromFilterColumn(this._injector,e,r);return this.filterByModel=s,this._filterBy$.next(0),this._listenToFilterHeaderChange(e,r),!0}_setupByConditions(e,r){this._disposePreviousModel();const i=e.getRange();if(i.startRow===i.endRow)return!1;const s=de.fromFilterColumn(this._injector,e,r,e.getFilterColumn(r));return this.filterByModel=s,this._filterBy$.next(1),this._listenToFilterHeaderChange(e,r),!0}_disposePreviousModel(){var e;(e=this._filterByModel)==null||e.dispose(),this.filterByModel=null}};G=Ne([me(0,c.Inject(c.Injector)),me(1,c.Inject(P.RefRangeService))],G);let de=class extends c.Disposable{constructor(e,r,i,s,l){super();S(this,"canApply$",C.of(!0));S(this,"_conditionItem$");S(this,"conditionItem$");S(this,"_filterConditionFormParams$");S(this,"filterConditionFormParams$");this._filterModel=e,this.col=r,this._commandService=l,this._conditionItem$=new C.BehaviorSubject(i),this.conditionItem$=this._conditionItem$.asObservable(),this._filterConditionFormParams$=new C.BehaviorSubject(s),this.filterConditionFormParams$=this._filterConditionFormParams$.asObservable()}static fromFilterColumn(e,r,i,s){const[l,n]=d.testMappingFilterColumn(s==null?void 0:s.getColumnData());return e.createInstance(de,r,i,l,n)}get conditionItem(){return this._conditionItem$.getValue()}get filterConditionFormParams(){return this._filterConditionFormParams$.getValue()}dispose(){super.dispose(),this._conditionItem$.complete(),this._filterConditionFormParams$.complete()}deltaCol(e){this.col+=e}clear(){return this._disposed?Promise.resolve(!1):this._commandService.executeCommand(u.SetSheetsFilterCriteriaCommand.id,{unitId:this._filterModel.unitId,subUnitId:this._filterModel.subUnitId,col:this.col,criteria:null})}async apply(){if(this._disposed)return!1;const e=d.mapToFilterColumn(this.conditionItem,this.filterConditionFormParams);return this._commandService.executeCommand(u.SetSheetsFilterCriteriaCommand.id,{unitId:this._filterModel.unitId,subUnitId:this._filterModel.subUnitId,col:this.col,criteria:e})}onPrimaryConditionChange(e){const r=d.ALL_CONDITIONS.find(i=>i.operator===e);if(!r)throw new Error(`[ByConditionsModel]: condition item not found for operator: ${e}!`);this._conditionItem$.next(r),this._filterConditionFormParams$.next(d.getInitialFormParams(e))}onConditionFormChange(e){const r={...this.filterConditionFormParams,...e};if(r.and!==!0&&delete r.and,typeof e.and<"u"||typeof e.operator1<"u"||typeof e.operator2<"u"){const i=d.testMappingParams(r,this.conditionItem.numOfParameters);this._conditionItem$.next(i)}this._filterConditionFormParams$.next(r)}};de=Ne([me(4,c.ICommandService)],de);let fe=class extends c.Disposable{constructor(e,r,i,s,l){super();S(this,"_rawFilterItems$");S(this,"rawFilterItems$");S(this,"filterItems$");S(this,"_filterItems",[]);S(this,"_treeMapCache");S(this,"canApply$");S(this,"_manuallyUpdateFilterItems$");S(this,"_searchString$");S(this,"searchString$");this._filterModel=e,this.col=r,this._commandService=l,this._treeMapCache=s,this._searchString$=new C.BehaviorSubject(""),this.searchString$=this._searchString$.asObservable(),this._rawFilterItems$=new C.BehaviorSubject(i),this.rawFilterItems$=this._rawFilterItems$.asObservable(),this._manuallyUpdateFilterItems$=new C.Subject,this.filterItems$=C.merge(C.combineLatest([this._searchString$.pipe(C.throttleTime(500,void 0,{leading:!0,trailing:!0}),C.startWith(void 0)),this._rawFilterItems$]).pipe(C.map(([n,o])=>{if(!n)return o;const h=n.toLowerCase().split(/\s+/).filter(m=>!!m);return Be(o,h)})),this._manuallyUpdateFilterItems$).pipe(C.shareReplay(1)),this.canApply$=this.filterItems$.pipe(C.map(n=>Fe(n).checked>0)),this.disposeWithMe(this.filterItems$.subscribe(n=>this._filterItems=n))}static async fromFilterColumn(e,r,i){var j;const s=e.get(c.IUniverInstanceService),l=e.get(c.LocaleService),n=e.get(he,c.Quantity.OPTIONAL),{unitId:o,subUnitId:a}=r,h=s.getUniverSheetInstance(o);if(!h)throw new Error(`[ByValuesModel]: Workbook not found for filter model with unitId: ${o}!`);const m=h==null?void 0:h.getSheetBySheetId(a);if(!m)throw new Error(`[ByValuesModel]: Worksheet not found for filter model with unitId: ${o} and subUnitId: ${a}!`);const p=r.getRange(),T=i,_=(j=r.getFilterColumn(i))==null?void 0:j.getColumnData().filters,O=new Set(_==null?void 0:_.filters),F=!!(_&&_.blank),A=r.getFilteredOutRowsExceptCol(i),N={...p,startRow:p.startRow+1,startColumn:T,endColumn:T};let w,M;if(n){const V=await n.getFilterValues({unitId:o,subUnitId:a,filteredOutRowsByOtherColumns:Array.from(A),filters:!!_,blankChecked:F,iterateRange:N,alreadyChecked:Array.from(O)});w=V.filterTreeItems,M=V.filterTreeMapCache}else{const V=De(!!_,l,N,m,A,O,F,h.getStyles());w=V.filterTreeItems,M=V.filterTreeMapCache}return e.createInstance(fe,r,i,w,M)}get rawFilterItems(){return this._rawFilterItems$.getValue()}get filterItems(){return this._filterItems}get treeMapCache(){return this._treeMapCache}dispose(){this._rawFilterItems$.complete(),this._searchString$.complete()}deltaCol(e){this.col+=e}setSearchString(e){this._searchString$.next(e)}onCheckAllToggled(e){const r=c.Tools.deepClone(this._filterItems);r.forEach(i=>se(i,e)),this._manuallyUpdateFilterItems(r)}onFilterCheckToggled(e){const r=c.Tools.deepClone(this._filterItems),i=Ie(r,e.key);if(!i)return;const s=He(i);se(i,!s),this._manuallyUpdateFilterItems(r)}onFilterOnly(e){const r=c.Tools.deepClone(this._filterItems);r.forEach(i=>se(i,!1)),e.forEach(i=>{const s=Ie(r,i);s&&se(s,!0)}),this._manuallyUpdateFilterItems(r)}_manuallyUpdateFilterItems(e){this._manuallyUpdateFilterItems$.next(e)}clear(){return this._disposed?Promise.resolve(!1):this._commandService.executeCommand(u.SetSheetsFilterCriteriaCommand.id,{unitId:this._filterModel.unitId,subUnitId:this._filterModel.subUnitId,col:this.col,criteria:null})}async apply(){if(this._disposed)return!1;const e=Fe(this._filterItems),{checked:r,checkedItems:i}=e,s=this.rawFilterItems;let l=0;for(const h of s)l+=h.count;const n=r===0,o=e.checked===l,a={colId:this.col};if(n)throw new Error("[ByValuesModel]: no checked items!");if(o)return this._commandService.executeCommand(u.SetSheetsFilterCriteriaCommand.id,{unitId:this._filterModel.unitId,subUnitId:this._filterModel.subUnitId,col:this.col,criteria:null});{a.filters={};const h=i.filter(p=>p.key!=="empty");h.length>0&&(a.filters={filters:h.flatMap(p=>p.originValues?Array.from(p.originValues):[p.title])}),h.length!==i.length&&(a.filters.blank=!0)}return this._commandService.executeCommand(u.SetSheetsFilterCriteriaCommand.id,{unitId:this._filterModel.unitId,subUnitId:this._filterModel.subUnitId,col:this.col,criteria:a})}};fe=Ne([me(4,c.ICommandService)],fe);const J="FILTER_PANEL_OPENED",oe={id:"sheet.operation.open-filter-panel",type:c.CommandType.OPERATION,handler:(t,e)=>{const r=t.get(c.IContextService),i=t.get(u.SheetsFilterService),s=t.get(G);t.get(c.ICommandService).syncExecuteCommand(U.SetCellEditVisibleOperation.id,{visible:!1});const{unitId:n,subUnitId:o,col:a}=e,h=i.getFilterModel(n,o);return h?(s.setupCol(h,a),r.getContextValue(J)||r.setContextValue(J,!0),!0):!1}},z={id:"sheet.operation.close-filter-panel",type:c.CommandType.OPERATION,handler:t=>{const e=t.get(c.IContextService),r=t.get(G),i=t.get(E.ILayoutService,c.Quantity.OPTIONAL);return e.getContextValue(J)?(e.setContextValue(J,!1),i==null||i.focus(),r.terminate()):!1}},ye={id:"sheet.operation.apply-filter",type:c.CommandType.OPERATION,handler:(t,e)=>{const{filterBy:r}=e;return t.get(G).changeFilterBy(r)}};var lt=Object.defineProperty,ct=Object.getOwnPropertyDescriptor,ut=(t,e,r,i)=>{for(var s=i>1?void 0:i?ct(e,r):e,l=t.length-1,n;l>=0;l--)(n=t[l])&&(s=(i?n(e,r,s):n(s))||s);return i&&s&&lt(e,r,s),s},ee=(t,e)=>(r,i)=>e(r,i,t);let te=class extends c.Disposable{constructor(t,e,r,i,s,l){super(),this._sheetsFilterService=t,this._localeService=e,this._commandService=r,this._sheetPermissionInterceptorBaseController=i,this._injector=s,this._sheetsSelectionService=l,this._commandExecutedListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.beforeCommandExecuted(t=>{var e,r,i;if(t.id===u.SmartToggleSheetsFilterCommand.id){const s=this._injector.get(c.IUniverInstanceService),l=P.getSheetCommandTarget(s);if(!l)return;const{unitId:n,subUnitId:o,worksheet:a}=l,h=(e=this._sheetsFilterService.getFilterModel(n,o))==null?void 0:e.getRange();let m;if(h)m=this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({rangeTypes:[P.RangeProtectionPermissionViewPoint],worksheetTypes:[P.WorksheetFilterPermission,P.WorksheetViewPermission]},[h]);else{const p=(r=this._sheetsSelectionService.getCurrentLastSelection())==null?void 0:r.range;if(p){let T={...p};T=p.startColumn===p.endColumn&&p.startRow===p.endRow?P.expandToContinuousRange(T,{left:!0,right:!0,up:!0,down:!0},a):T,m=this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({rangeTypes:[P.RangeProtectionPermissionViewPoint],worksheetTypes:[P.WorksheetViewPermission,P.WorksheetFilterPermission]},[T],n,o)}else m=this._sheetPermissionInterceptorBaseController.permissionCheckWithoutRange({rangeTypes:[P.RangeProtectionPermissionViewPoint],worksheetTypes:[P.WorksheetViewPermission,P.WorksheetFilterPermission]})}m||this._sheetPermissionInterceptorBaseController.haveNotPermissionHandle(this._localeService.t("permission.dialog.filterErr"))}if(t.id===oe.id){const s=t.params,{unitId:l,subUnitId:n}=s,o=(i=this._sheetsFilterService.getFilterModel(l,n))==null?void 0:i.getRange(),a=c.Tools.deepClone(o);a&&(a.startColumn=s.col,a.endColumn=s.col,this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({rangeTypes:[P.RangeProtectionPermissionViewPoint],worksheetTypes:[P.WorksheetFilterPermission,P.WorksheetViewPermission]},[a])||this._sheetPermissionInterceptorBaseController.haveNotPermissionHandle(this._localeService.t("permission.dialog.filterErr")))}}))}};te=ut([ee(0,c.Inject(u.SheetsFilterService)),ee(1,c.Inject(c.LocaleService)),ee(2,c.ICommandService),ee(3,c.Inject(U.SheetPermissionInterceptorBaseController)),ee(4,c.Inject(c.Injector)),ee(5,c.Inject(P.SheetsSelectionsService))],te);var H=function(){return H=Object.assign||function(t){for(var e,r=1,i=arguments.length;r<i;r++){e=arguments[r];for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&(t[s]=e[s])}return t},H.apply(this,arguments)},ht=function(t,e){var r={};for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&e.indexOf(i)<0&&(r[i]=t[i]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,i=Object.getOwnPropertySymbols(t);s<i.length;s++)e.indexOf(i[s])<0&&Object.prototype.propertyIsEnumerable.call(t,i[s])&&(r[i[s]]=t[i[s]]);return r},je=y.forwardRef(function(t,e){var r=t.icon,i=t.id,s=t.className,l=t.extend,n=ht(t,["icon","id","className","extend"]),o="univerjs-icon univerjs-icon-".concat(i," ").concat(s||"").trim(),a=y.useRef("_".concat(dt()));return Ve(r,"".concat(i),{defIds:r.defIds,idSuffix:a.current},H({ref:e,className:o},n),l)});function Ve(t,e,r,i,s){return y.createElement(t.tag,H(H({key:e},mt(t,r,s)),i),(pt(t,r).children||[]).map(function(l,n){return Ve(l,"".concat(e,"-").concat(t.tag,"-").concat(n),r,void 0,s)}))}function mt(t,e,r){var i=H({},t.attrs);r!=null&&r.colorChannel1&&i.fill==="colorChannel1"&&(i.fill=r.colorChannel1);var s=e.defIds;return!s||s.length===0||(t.tag==="use"&&i["xlink:href"]&&(i["xlink:href"]=i["xlink:href"]+e.idSuffix),Object.entries(i).forEach(function(l){var n=l[0],o=l[1];typeof o=="string"&&(i[n]=o.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))})),i}function pt(t,e){var r,i=e.defIds;return!i||i.length===0?t:t.tag==="defs"&&(!((r=t.children)===null||r===void 0)&&r.length)?H(H({},t),{children:t.children.map(function(s){return typeof s.attrs.id=="string"&&i&&i.indexOf(s.attrs.id)>-1?H(H({},s),{attrs:H(H({},s.attrs),{id:s.attrs.id+e.idSuffix})}):s})}):t}function dt(){return Math.random().toString(36).substring(2,8)}je.displayName="UniverIcon";var ft={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M3.32182 2.60967C2.98161 2.60967 2.79671 3.0074 3.01601 3.2675L6.85819 7.8246C6.94943 7.93282 6.99947 8.06981 6.99947 8.21136V12.7338C6.99947 12.898 7.0998 13.0455 7.2525 13.1058L8.73833 13.6928C9.00085 13.7965 9.28531 13.6031 9.28531 13.3208V8.21136C9.28531 8.06981 9.33535 7.93282 9.42659 7.8246L13.2688 3.2675C13.4881 3.0074 13.3032 2.60967 12.963 2.60967H3.32182ZM2.09858 4.04101C1.22139 3.0006 1.96097 1.40967 3.32182 1.40967H12.963C14.3238 1.40967 15.0634 3.0006 14.1862 4.04101L10.4853 8.43054V13.3208C10.4853 14.4498 9.34747 15.2237 8.29742 14.8089L6.81158 14.2219C6.20078 13.9806 5.79947 13.3905 5.79947 12.7338V8.43054L2.09858 4.04101Z",fillRule:"evenodd",clipRule:"evenodd"}}]},We=y.forwardRef(function(t,e){return y.createElement(je,Object.assign({},t,{id:"filter-single",ref:e,icon:ft}))});We.displayName="FilterSingle";var Re={exports:{}},ae={};/**
10
+ (function(S,u){typeof exports=="object"&&typeof module<"u"?u(exports,require("@univerjs/core"),require("@univerjs/rpc"),require("@univerjs/sheets-filter"),require("@univerjs/sheets"),require("@univerjs/ui"),require("@univerjs/sheets-ui"),require("rxjs"),require("@univerjs/design"),require("@univerjs/engine-render"),require("react")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/rpc","@univerjs/sheets-filter","@univerjs/sheets","@univerjs/ui","@univerjs/sheets-ui","rxjs","@univerjs/design","@univerjs/engine-render","react"],u):(S=typeof globalThis<"u"?globalThis:S||self,u(S.UniverSheetsFilterUi={},S.UniverCore,S.UniverRpc,S.UniverSheetsFilter,S.UniverSheets,S.UniverUi,S.UniverSheetsUi,S.rxjs,S.UniverDesign,S.UniverEngineRender,S.React))})(this,function(S,u,k,c,P,F,$,C,L,ie,y){"use strict";var ir=Object.defineProperty;var sr=(S,u,k)=>u in S?ir(S,u,{enumerable:!0,configurable:!0,writable:!0,value:k}):S[u]=k;var v=(S,u,k)=>sr(S,typeof u!="symbol"?u+"":u,k);var ve;const $e="sheets-filter-ui.config",ce={};var R=(t=>(t[t.FIRST=0]="FIRST",t[t.SECOND=1]="SECOND",t))(R||{}),g=(t=>(t.NONE="none",t.STARTS_WITH="startsWith",t.DOES_NOT_START_WITH="doesNotStartWith",t.ENDS_WITH="endsWith",t.DOES_NOT_END_WITH="doesNotEndWith",t.CONTAINS="contains",t.DOES_NOT_CONTAIN="doesNotContain",t.EQUALS="equals",t.NOT_EQUALS="notEquals",t.EMPTY="empty",t.NOT_EMPTY="notEmpty",t.BETWEEN="between",t.NOT_BETWEEN="notBetween",t.CUSTOM="custom",t))(g||{}),d;(t=>{t.NONE={label:"sheets-filter.conditions.none",operator:g.NONE,order:R.SECOND,numOfParameters:0,getDefaultFormParams:()=>{throw new Error("[FilterConditionItems.NONE]: should not have initial form params!")},testMappingParams:n=>n.operator1===g.NONE,mapToFilterColumn:()=>null,testMappingFilterColumn:n=>!n.customFilters&&!n.filters?{}:!1},t.EMPTY={label:"sheets-filter.conditions.empty",operator:g.EMPTY,order:R.SECOND,numOfParameters:0,getDefaultFormParams:()=>{throw new Error("[FilterConditionItems.EMPTY]: should not have initial form params!")},testMappingParams:({operator1:n})=>n===g.EMPTY,mapToFilterColumn:()=>({customFilters:{customFilters:[{val:""}]}}),testMappingFilterColumn:n=>{var h;if(((h=n.customFilters)==null?void 0:h.customFilters.length)!==1)return!1;const o=n.customFilters.customFilters[0];return o.val===""&&o.operator===void 0?{operator1:g.EMPTY}:!1}},t.NOT_EMPTY={label:"sheets-filter.conditions.not-empty",operator:g.NOT_EMPTY,order:R.SECOND,numOfParameters:0,getDefaultFormParams:()=>{throw new Error("[FilterConditionItems.NOT_EMPTY]: should not have initial form params!")},testMappingParams:({operator1:n})=>n===g.NOT_EMPTY,mapToFilterColumn:()=>({customFilters:{customFilters:[{val:"",operator:c.CustomFilterOperator.NOT_EQUALS}]}}),testMappingFilterColumn:n=>{var h;if(((h=n.customFilters)==null?void 0:h.customFilters.length)!==1)return!1;const o=n.customFilters.customFilters[0];return o.val===" "&&o.operator===c.CustomFilterOperator.NOT_EQUALS?{operator1:g.NOT_EMPTY}:!1}},t.TEXT_CONTAINS={label:"sheets-filter.conditions.text-contains",operator:g.CONTAINS,order:R.FIRST,numOfParameters:1,getDefaultFormParams:()=>({operator1:g.CONTAINS,val1:""}),testMappingParams:n=>{const[o]=j(n);return o===g.CONTAINS},mapToFilterColumn:n=>{const{val1:o}=n;return o===""?null:{customFilters:{customFilters:[{val:`*${o}*`}]}}},testMappingFilterColumn:n=>{var h;if(((h=n.customFilters)==null?void 0:h.customFilters.length)!==1)return!1;const o=n.customFilters.customFilters[0],a=o.val.toString();return!o.operator&&a.startsWith("*")&&a.endsWith("*")?{operator1:g.CONTAINS,val1:a.slice(1,-1)}:!1}},t.DOES_NOT_CONTAIN={label:"sheets-filter.conditions.does-not-contain",operator:g.DOES_NOT_CONTAIN,order:R.FIRST,numOfParameters:1,getDefaultFormParams:()=>({operator1:g.DOES_NOT_CONTAIN,val1:""}),mapToFilterColumn:n=>({customFilters:{customFilters:[{val:`*${n.val1}*`,operator:c.CustomFilterOperator.NOT_EQUALS}]}}),testMappingParams:n=>{const[o]=j(n);return o===g.DOES_NOT_CONTAIN},testMappingFilterColumn:n=>{var h;if(((h=n.customFilters)==null?void 0:h.customFilters.length)!==1)return!1;const o=n.customFilters.customFilters[0],a=o.val.toString();return o.operator===c.CustomFilterOperator.NOT_EQUALS&&a.startsWith("*")&&a.endsWith("*")?{operator1:g.DOES_NOT_CONTAIN,val1:a.slice(1,-1)}:!1}},t.STARTS_WITH={label:"sheets-filter.conditions.starts-with",operator:g.STARTS_WITH,order:R.FIRST,numOfParameters:1,getDefaultFormParams:()=>({operator1:g.STARTS_WITH,val1:""}),mapToFilterColumn:n=>({customFilters:{customFilters:[{val:`${n.val1}*`}]}}),testMappingParams:n=>{const[o]=j(n);return o===g.STARTS_WITH},testMappingFilterColumn:n=>{var h;if(((h=n.customFilters)==null?void 0:h.customFilters.length)!==1)return!1;const o=n.customFilters.customFilters[0],a=o.val.toString();return!o.operator&&a.endsWith("*")&&!a.startsWith("*")?{operator1:g.STARTS_WITH,val1:a.slice(0,-1)}:!1}},t.ENDS_WITH={label:"sheets-filter.conditions.ends-with",operator:g.ENDS_WITH,order:R.FIRST,numOfParameters:1,getDefaultFormParams:()=>({operator1:g.ENDS_WITH,val1:""}),mapToFilterColumn:n=>({customFilters:{customFilters:[{val:`*${n.val1}`}]}}),testMappingParams:n=>{const[o]=j(n);return o===g.ENDS_WITH},testMappingFilterColumn:n=>{var h;if(((h=n.customFilters)==null?void 0:h.customFilters.length)!==1)return!1;const o=n.customFilters.customFilters[0],a=o.val.toString();return!o.operator&&a.startsWith("*")&&!a.endsWith("*")?{operator1:g.ENDS_WITH,val1:a.slice(1)}:!1}},t.EQUALS={label:"sheets-filter.conditions.equals",operator:g.EQUALS,order:R.FIRST,numOfParameters:1,getDefaultFormParams:()=>({operator1:g.EQUALS,val1:""}),testMappingParams:n=>{const[o]=j(n);return o===g.EQUALS},mapToFilterColumn:n=>{const{val1:o}=n;return o===""?null:{customFilters:{customFilters:[{val:o}]}}},testMappingFilterColumn:n=>{var o,a,h;return((a=(o=n.filters)==null?void 0:o.filters)==null?void 0:a.length)===1?{operator1:g.EQUALS,val1:""}:((h=n.customFilters)==null?void 0:h.customFilters.length)===1&&!n.customFilters.customFilters[0].operator?{operator1:g.EQUALS,val1:n.customFilters.customFilters[0].val.toString()}:!1}},t.GREATER_THAN={label:"sheets-filter.conditions.greater-than",operator:c.CustomFilterOperator.GREATER_THAN,numOfParameters:1,order:R.FIRST,getDefaultFormParams:()=>({operator1:c.CustomFilterOperator.GREATER_THAN,val1:""}),mapToFilterColumn:n=>({customFilters:{customFilters:[{val:n.val1,operator:c.CustomFilterOperator.GREATER_THAN}]}}),testMappingParams:n=>{const[o]=j(n);return o===c.CustomFilterOperator.GREATER_THAN},testMappingFilterColumn:n=>{var a;if(((a=n.customFilters)==null?void 0:a.customFilters.length)!==1)return!1;const o=n.customFilters.customFilters[0];return o.operator!==c.CustomFilterOperator.GREATER_THAN?!1:{operator1:c.CustomFilterOperator.GREATER_THAN,val1:o.val.toString()}}},t.GREATER_THAN_OR_EQUAL={label:"sheets-filter.conditions.greater-than-or-equal",operator:c.CustomFilterOperator.GREATER_THAN_OR_EQUAL,numOfParameters:1,order:R.FIRST,getDefaultFormParams:()=>({operator1:c.CustomFilterOperator.GREATER_THAN_OR_EQUAL,val1:""}),testMappingParams:n=>{const[o]=j(n);return o===c.CustomFilterOperator.GREATER_THAN_OR_EQUAL},mapToFilterColumn:n=>({customFilters:{customFilters:[{val:n.val1,operator:c.CustomFilterOperator.GREATER_THAN_OR_EQUAL}]}}),testMappingFilterColumn:n=>{var a;if(((a=n.customFilters)==null?void 0:a.customFilters.length)!==1)return!1;const o=n.customFilters.customFilters[0];return o.operator!==c.CustomFilterOperator.GREATER_THAN_OR_EQUAL?!1:{operator1:c.CustomFilterOperator.GREATER_THAN_OR_EQUAL,val1:o.val.toString()}}},t.LESS_THAN={label:"sheets-filter.conditions.less-than",operator:c.CustomFilterOperator.LESS_THAN,numOfParameters:1,order:R.FIRST,getDefaultFormParams:()=>({operator1:c.CustomFilterOperator.LESS_THAN,val1:""}),testMappingParams:n=>{const[o]=j(n);return o===c.CustomFilterOperator.LESS_THAN},mapToFilterColumn:n=>({customFilters:{customFilters:[{val:n.val1,operator:c.CustomFilterOperator.LESS_THAN}]}}),testMappingFilterColumn:n=>{var a;if(((a=n.customFilters)==null?void 0:a.customFilters.length)!==1)return!1;const o=n.customFilters.customFilters[0];return o.operator!==c.CustomFilterOperator.LESS_THAN?!1:{operator1:c.CustomFilterOperator.LESS_THAN,val1:o.val.toString()}}},t.LESS_THAN_OR_EQUAL={label:"sheets-filter.conditions.less-than-or-equal",operator:c.CustomFilterOperator.LESS_THAN_OR_EQUAL,numOfParameters:1,order:R.FIRST,getDefaultFormParams:()=>({operator1:c.CustomFilterOperator.LESS_THAN_OR_EQUAL,val1:""}),testMappingParams:n=>{const[o]=j(n);return o===c.CustomFilterOperator.LESS_THAN_OR_EQUAL},mapToFilterColumn:n=>({customFilters:{customFilters:[{val:n.val1,operator:c.CustomFilterOperator.LESS_THAN_OR_EQUAL}]}}),testMappingFilterColumn:n=>{var a;if(((a=n.customFilters)==null?void 0:a.customFilters.length)!==1)return!1;const o=n.customFilters.customFilters[0];return o.operator!==c.CustomFilterOperator.LESS_THAN_OR_EQUAL?!1:{operator1:c.CustomFilterOperator.LESS_THAN_OR_EQUAL,val1:o.val.toString()}}},t.EQUAL={label:"sheets-filter.conditions.equal",operator:c.CustomFilterOperator.EQUAL,numOfParameters:1,order:R.FIRST,getDefaultFormParams:()=>({operator1:c.CustomFilterOperator.EQUAL,val1:""}),testMappingParams:n=>{const[o]=j(n);return o===c.CustomFilterOperator.EQUAL},mapToFilterColumn:n=>({customFilters:{customFilters:[{val:n.val1,operator:c.CustomFilterOperator.EQUAL}]}}),testMappingFilterColumn:n=>{var a;if(((a=n.customFilters)==null?void 0:a.customFilters.length)!==1)return!1;const o=n.customFilters.customFilters[0];return o.operator!==c.CustomFilterOperator.EQUAL?!1:{operator1:c.CustomFilterOperator.EQUAL,val1:o.val.toString()}}},t.NOT_EQUAL={label:"sheets-filter.conditions.not-equal",operator:c.CustomFilterOperator.NOT_EQUALS,numOfParameters:1,order:R.FIRST,getDefaultFormParams:()=>({operator1:c.CustomFilterOperator.NOT_EQUALS,val1:""}),testMappingParams:n=>{const[o]=j(n);return o===c.CustomFilterOperator.NOT_EQUALS},mapToFilterColumn:n=>({customFilters:{customFilters:[{val:n.val1,operator:c.CustomFilterOperator.NOT_EQUALS}]}}),testMappingFilterColumn:n=>{var a;if(((a=n.customFilters)==null?void 0:a.customFilters.length)!==1)return!1;const o=n.customFilters.customFilters[0];return o.operator!==c.CustomFilterOperator.NOT_EQUALS?!1:{operator1:c.CustomFilterOperator.NOT_EQUALS,val1:o.val.toString()}}},t.BETWEEN={label:"sheets-filter.conditions.between",operator:g.BETWEEN,order:R.SECOND,numOfParameters:2,getDefaultFormParams:()=>({and:!0,operator1:c.CustomFilterOperator.GREATER_THAN_OR_EQUAL,val1:"",operator2:c.CustomFilterOperator.LESS_THAN_OR_EQUAL,val2:""}),testMappingParams:n=>{const{and:o,operator1:a,operator2:h}=n;if(!o)return!1;const m=[a,h];return m.includes(c.CustomFilterOperator.GREATER_THAN_OR_EQUAL)&&m.includes(c.CustomFilterOperator.LESS_THAN_OR_EQUAL)},mapToFilterColumn:n=>{const{val1:o,val2:a,operator1:h}=n,m=h===c.CustomFilterOperator.GREATER_THAN_OR_EQUAL;return{customFilters:{and:u.BooleanNumber.TRUE,customFilters:[{val:m?o:a,operator:c.CustomFilterOperator.GREATER_THAN_OR_EQUAL},{val:m?a:o,operator:c.CustomFilterOperator.LESS_THAN_OR_EQUAL}]}}},testMappingFilterColumn:n=>{var h;if(((h=n.customFilters)==null?void 0:h.customFilters.length)!==2)return!1;const[o,a]=n.customFilters.customFilters;return o.operator===c.CustomFilterOperator.GREATER_THAN_OR_EQUAL&&a.operator===c.CustomFilterOperator.LESS_THAN_OR_EQUAL&&n.customFilters.and?{and:!0,operator1:c.CustomFilterOperator.GREATER_THAN_OR_EQUAL,val1:o.val.toString(),operator2:c.CustomFilterOperator.LESS_THAN_OR_EQUAL,val2:a.val.toString()}:a.operator===c.CustomFilterOperator.GREATER_THAN_OR_EQUAL&&o.operator===c.CustomFilterOperator.LESS_THAN_OR_EQUAL&&n.customFilters.and?{and:!0,operator1:c.CustomFilterOperator.GREATER_THAN_OR_EQUAL,val1:a.val.toString(),operator2:c.CustomFilterOperator.LESS_THAN_OR_EQUAL,val2:o.val.toLocaleString()}:!1}},t.NOT_BETWEEN={label:"sheets-filter.conditions.not-between",operator:g.NOT_BETWEEN,order:R.SECOND,numOfParameters:2,getDefaultFormParams:()=>({operator1:c.CustomFilterOperator.LESS_THAN,val1:"",operator2:c.CustomFilterOperator.GREATER_THAN,val2:""}),testMappingParams:n=>{const{and:o,operator1:a,operator2:h}=n;if(o)return!1;const m=[a,h];return m.includes(c.CustomFilterOperator.GREATER_THAN)&&m.includes(c.CustomFilterOperator.LESS_THAN)},mapToFilterColumn:n=>{const{val1:o,val2:a,operator1:h}=n,m=h===c.CustomFilterOperator.GREATER_THAN;return{customFilters:{customFilters:[{val:m?o:a,operator:c.CustomFilterOperator.GREATER_THAN},{val:m?a:o,operator:c.CustomFilterOperator.LESS_THAN}]}}},testMappingFilterColumn:n=>{var h;if(((h=n.customFilters)==null?void 0:h.customFilters.length)!==2)return!1;const[o,a]=n.customFilters.customFilters;return o.operator===c.CustomFilterOperator.LESS_THAN&&a.operator===c.CustomFilterOperator.GREATER_THAN&&!n.customFilters.and?{operator1:c.CustomFilterOperator.LESS_THAN,val1:o.val.toString(),operator2:c.CustomFilterOperator.GREATER_THAN,val2:a.val.toString()}:a.operator===c.CustomFilterOperator.LESS_THAN&&o.operator===c.CustomFilterOperator.GREATER_THAN&&!n.customFilters.and?{operator1:c.CustomFilterOperator.GREATER_THAN,val1:a.val.toString(),operator2:c.CustomFilterOperator.LESS_THAN,val2:o.val.toLocaleString()}:!1}},t.CUSTOM={label:"sheets-filter.conditions.custom",operator:g.CUSTOM,order:R.SECOND,numOfParameters:2,getDefaultFormParams:()=>({operator1:g.NONE,val1:"",operator2:g.NONE,val2:""}),testMappingParams:()=>!0,mapToFilterColumn:n=>{const{and:o,val1:a,val2:h,operator1:m,operator2:p}=n;function T(U,M){for(const B of t.ALL_CONDITIONS)if(B.operator===U)return B.mapToFilterColumn({val1:M,operator1:U})}const _=!m||m===t.NONE.operator,O=!p||p===t.NONE.operator;if(_&&O)return t.NONE.mapToFilterColumn({});if(_)return T(p,h);if(O)return T(m,a);const E=T(m,a),A=T(p,h),N={customFilters:[E.customFilters.customFilters[0],A.customFilters.customFilters[0]]};return o&&(N.and=u.BooleanNumber.TRUE),{customFilters:N}},testMappingFilterColumn:n=>{var h;if(((h=n.customFilters)==null?void 0:h.customFilters.length)!==2)return!1;const o=n.customFilters.customFilters.map(m=>l({customFilters:{customFilters:[m]}})),a={operator1:o[0][0].operator,val1:o[0][1].val1,operator2:o[1][0].operator,val2:o[1][1].val1};return n.customFilters.and&&(a.and=!0),a}},t.ALL_CONDITIONS=[t.NONE,t.EMPTY,t.NOT_EMPTY,t.TEXT_CONTAINS,t.DOES_NOT_CONTAIN,t.STARTS_WITH,t.ENDS_WITH,t.EQUALS,t.GREATER_THAN,t.GREATER_THAN_OR_EQUAL,t.LESS_THAN,t.LESS_THAN_OR_EQUAL,t.EQUAL,t.NOT_EQUAL,t.BETWEEN,t.NOT_BETWEEN,t.CUSTOM];function e(n){const o=t.ALL_CONDITIONS.find(a=>a.operator===n);if(!o)throw new Error(`[SheetsFilter]: no condition item found for operator: ${n}`);return o}t.getItemByOperator=e;function r(n,o){for(const a of t.ALL_CONDITIONS.filter(h=>h.numOfParameters===o))if(a.numOfParameters!==0&&a.testMappingParams(n))return a;for(const a of t.ALL_CONDITIONS)if(a.testMappingParams(n))return a;throw new Error("[SheetsFilter]: no condition item can be mapped from the filter map params!")}t.testMappingParams=r;function i(n){const o=t.ALL_CONDITIONS.find(a=>a.operator===n);return(o==null?void 0:o.numOfParameters)===0?{operator1:o.operator}:o.getDefaultFormParams()}t.getInitialFormParams=i;function s(n,o){return n.mapToFilterColumn(o)}t.mapToFilterColumn=s;function l(n){if(!n)return[t.NONE,{}];for(const o of t.ALL_CONDITIONS){const a=o.testMappingFilterColumn(n);if(a)return[o,a]}return[t.NONE,{}]}t.testMappingFilterColumn=l})(d||(d={}));function j(t){const{operator1:e,operator2:r,val1:i,val2:s}=t;if(e&&r)throw new Error("Both operator1 and operator2 are set!");if(!e&&!r)throw new Error("Neither operator1 and operator2 and both not set!");return e?[e,i]:[r,s]}function Ee(t){const e=[],r=[];let i=0,s=0;function l(n){n.leaf&&(n.checked?(e.push(n),i+=n.count):(r.push(n),s+=n.count)),n.children&&n.children.forEach(l)}return t.forEach(l),{checkedItems:e,uncheckedItems:r,checked:i,unchecked:s}}var tt=Object.defineProperty,rt=Object.getOwnPropertyDescriptor,nt=(t,e,r,i)=>{for(var s=i>1?void 0:i?rt(e,r):e,l=t.length-1,n;l>=0;l--)(n=t[l])&&(s=(i?n(e,r,s):n(s))||s);return i&&s&&tt(e,r,s),s},Fe=(t,e)=>(r,i)=>e(r,i,t);const Oe="sheets-filter.generate-filter-values.service",he=u.createIdentifier(Oe),it=["yyyy-mm-dd","yyyy-mm-dd;@","yyyy/mm/dd;@","yyyy/mm/dd hh:mm","yyyy-m-d am/pm h:mm","yyyy-MM-dd","yyyy/MM/dd","yyyy/mm/dd",'yyyy"年"MM"月"dd"日"',"MM-dd",'M"月"d"日"',"MM-dd A/P hh:mm"];let Pe=class extends u.Disposable{constructor(t,e,r){super(),this._localeService=t,this._univerInstanceService=e,this._logService=r}async getFilterValues(t){var m;const{unitId:e,subUnitId:r,filteredOutRowsByOtherColumns:i,filters:s,blankChecked:l,iterateRange:n,alreadyChecked:o}=t,a=this._univerInstanceService.getUnit(e),h=(m=this._univerInstanceService.getUnit(e))==null?void 0:m.getSheetBySheetId(r);return!a||!h?[]:(this._logService.debug("[SheetsGenerateFilterValuesService]","getFilterValues for",{unitId:e,subUnitId:r}),De(s,this._localeService,n,h,new Set(i),new Set(o.map(String)),l,a.getStyles()))}};Pe=nt([Fe(0,u.Inject(u.LocaleService)),Fe(1,u.IUniverInstanceService),Fe(2,u.ILogService)],Pe);function De(t,e,r,i,s,l,n,o){var E,A,N,U,M,B,V,ge,Ce;const a=new Map,h=new Map,m="yyyy-mm-dd",p=new Set(it),T="empty";let _=0;for(const w of i.iterateByColumn(r,!1,!1)){const{row:tr,rowSpan:et=1}=w;let re=0;for(;re<et;){const rr=tr+re;if(s.has(rr)){re++;continue}const q=w!=null&&w.value?u.extractPureTextFromCell(w.value):"";if(!q){_+=1,re+=et;continue}const Te=(E=w.value)!=null&&E.v&&!w.value.p?(U=(N=o.get((A=w.value)==null?void 0:A.s))==null?void 0:N.n)==null?void 0:U.pattern:"",nr=Te&&u.numfmt.isDate(Te);if(Te&&nr&&p.has(Te)){const K=(M=i.getCellRaw(w.row,w.col))==null?void 0:M.v;if(!K){re++;continue}const ne=u.numfmt.format(m,K),[b,W,ue]=ne.split("-").map(Number);let Z=a.get(`${b}`);Z||(Z={title:`${b}`,key:`${b}`,children:[],count:0,leaf:!1,checked:!1},a.set(`${b}`,Z),h.set(`${b}`,[`${b}`]));let Q=(B=Z.children)==null?void 0:B.find(we=>we.key===`${b}-${W}`);Q||(Q={title:e.t(`sheets-filter.date.${W}`),key:`${b}-${W}`,children:[],count:0,leaf:!1,checked:!1},(V=Z.children)==null||V.push(Q),h.set(`${b}-${W}`,[`${b}`,`${b}-${W}`]));const Ue=(ge=Q==null?void 0:Q.children)==null?void 0:ge.find(we=>we.key===`${b}-${W}-${ue}`);Ue?(Ue.originValues.add(q),Ue.count++,Q.count++,Z.count++):((Ce=Q.children)==null||Ce.push({title:`${ue}`,key:`${b}-${W}-${ue}`,count:1,originValues:new Set([q]),leaf:!0,checked:l.size?l.has(q):!n}),Q.count++,Z.count++,h.set(`${b}-${W}-${ue}`,[`${b}`,`${b}-${W}`,`${b}-${W}-${ue}`]))}else{const K=q;let ne=a.get(K);ne?ne.count++:(ne={title:q,leaf:!0,checked:l.size?l.has(q):!n,key:K,count:1},a.set(K,ne),h.set(K,[K]))}re++}}const O=t?n:!0;if(_>0){const w={title:e.t("sheets-filter.panel.empty"),count:_,leaf:!0,checked:O,key:T};a.set("empty",w),h.set("empty",[T])}return{filterTreeItems:st(Array.from(a.values())),filterTreeMapCache:h}}function st(t){return Array.from(t).sort((e,r)=>e.children&&!r.children?-1:!e.children&&r.children?1:r.title.localeCompare(e.title)).map(e=>(e.children&&e.children.sort((r,i)=>{const s=Number.parseInt(r.key.split("-")[1],10),l=Number.parseInt(i.key.split("-")[1],10);return s-l}).forEach(r=>{r.children&&r.children.sort((i,s)=>{const l=Number.parseInt(i.key.split("-")[2],10),n=Number.parseInt(s.key.split("-")[2],10);return l-n})}),e))}function Ie(t,e){for(const r of t){if(r.key===e)return r;if(r.children){const i=Ie(r.children,e);if(i)return i}}return null}function He(t){return t.leaf?t.checked:t.children?t.children.every(e=>He(e)):!0}function se(t,e){t.leaf&&(e!==void 0?t.checked=e:t.checked=!t.checked),t.children&&t.children.forEach(r=>se(r,e))}function je(t,e){const r=[];return t.forEach(i=>{const s=i.originValues?e.some(o=>Array.from(i.originValues).some(a=>a.toLowerCase().includes(o.toLowerCase()))):!1,l=!s&&e.some(o=>i.title.toLowerCase().includes(o.toLowerCase()));if(s||l)r.push({...i});else if(i.children){const o=je(i.children,e);if(o.length>0){const a=o.reduce((h,m)=>h+m.count,0);r.push({...i,count:a,children:o})}}}),r}var ot=Object.defineProperty,at=Object.getOwnPropertyDescriptor,Ne=(t,e,r,i)=>{for(var s=i>1?void 0:i?at(e,r):e,l=t.length-1,n;l>=0;l--)(n=t[l])&&(s=(i?n(e,r,s):n(s))||s);return i&&s&&ot(e,r,s),s},me=(t,e)=>(r,i)=>e(r,i,t),pe=(t=>(t[t.VALUES=0]="VALUES",t[t.CONDITIONS=1]="CONDITIONS",t))(pe||{});u.createIdentifier("sheets-filter-ui.sheets-filter-panel.service");let G=class extends u.Disposable{constructor(e,r){super();v(this,"_filterBy$",new C.BehaviorSubject(0));v(this,"filterBy$",this._filterBy$.asObservable());v(this,"_filterByModel$",new C.ReplaySubject(1));v(this,"filterByModel$",this._filterByModel$.asObservable());v(this,"_filterByModel",null);v(this,"_hasCriteria$",new C.BehaviorSubject(!1));v(this,"hasCriteria$",this._hasCriteria$.asObservable());v(this,"_filterModel",null);v(this,"_col$",new C.BehaviorSubject(-1));v(this,"col$",this._col$.asObservable());v(this,"_filterHeaderListener",null);this._injector=e,this._refRangeService=r}get filterBy(){return this._filterBy$.getValue()}get filterByModel(){return this._filterByModel}set filterByModel(e){this._filterByModel=e,this._filterByModel$.next(e)}get filterModel(){return this._filterModel}get col(){return this._col$.getValue()}dispose(){this._filterBy$.complete(),this._filterByModel$.complete(),this._hasCriteria$.complete()}setupCol(e,r){this.terminate(),this._filterModel=e,this._col$.next(r);const i=e.getFilterColumn(r);if(i){const s=i.getColumnData();if(s.customFilters){this._hasCriteria$.next(!0),this._setupByConditions(e,r);return}if(s.filters){this._hasCriteria$.next(!0),this._setupByValues(e,r);return}this._hasCriteria$.next(!1),this._setupByValues(e,r);return}this._hasCriteria$.next(!1),this._setupByValues(e,r)}changeFilterBy(e){return!this._filterModel||this.col===-1?!1:(e===0?this._setupByValues(this._filterModel,this.col):this._setupByConditions(this._filterModel,this.col),!0)}terminate(){return this._filterModel=null,this._col$.next(-1),this._disposeFilterHeaderChangeListener(),!0}_disposeFilterHeaderChangeListener(){var e;(e=this._filterHeaderListener)==null||e.dispose(),this._filterHeaderListener=null}_listenToFilterHeaderChange(e,r){this._disposeFilterHeaderChangeListener();const i=e.unitId,s=e.subUnitId,l=e.getRange(),n={startColumn:r,startRow:l.startRow,endRow:l.startRow,endColumn:r};this._filterHeaderListener=this._refRangeService.watchRange(i,s,n,(o,a)=>{if(!a)this.terminate();else{const h=a.startColumn-o.startColumn;h!==0&&this._filterByModel.deltaCol(h)}})}async _setupByValues(e,r){this._disposePreviousModel();const i=e.getRange();if(i.startRow===i.endRow)return!1;const s=await fe.fromFilterColumn(this._injector,e,r);return this.filterByModel=s,this._filterBy$.next(0),this._listenToFilterHeaderChange(e,r),!0}_setupByConditions(e,r){this._disposePreviousModel();const i=e.getRange();if(i.startRow===i.endRow)return!1;const s=de.fromFilterColumn(this._injector,e,r,e.getFilterColumn(r));return this.filterByModel=s,this._filterBy$.next(1),this._listenToFilterHeaderChange(e,r),!0}_disposePreviousModel(){var e;(e=this._filterByModel)==null||e.dispose(),this.filterByModel=null}};G=Ne([me(0,u.Inject(u.Injector)),me(1,u.Inject(P.RefRangeService))],G);let de=class extends u.Disposable{constructor(e,r,i,s,l){super();v(this,"canApply$",C.of(!0));v(this,"_conditionItem$");v(this,"conditionItem$");v(this,"_filterConditionFormParams$");v(this,"filterConditionFormParams$");this._filterModel=e,this.col=r,this._commandService=l,this._conditionItem$=new C.BehaviorSubject(i),this.conditionItem$=this._conditionItem$.asObservable(),this._filterConditionFormParams$=new C.BehaviorSubject(s),this.filterConditionFormParams$=this._filterConditionFormParams$.asObservable()}static fromFilterColumn(e,r,i,s){const[l,n]=d.testMappingFilterColumn(s==null?void 0:s.getColumnData());return e.createInstance(de,r,i,l,n)}get conditionItem(){return this._conditionItem$.getValue()}get filterConditionFormParams(){return this._filterConditionFormParams$.getValue()}dispose(){super.dispose(),this._conditionItem$.complete(),this._filterConditionFormParams$.complete()}deltaCol(e){this.col+=e}clear(){return this._disposed?Promise.resolve(!1):this._commandService.executeCommand(c.SetSheetsFilterCriteriaCommand.id,{unitId:this._filterModel.unitId,subUnitId:this._filterModel.subUnitId,col:this.col,criteria:null})}async apply(){if(this._disposed)return!1;const e=d.mapToFilterColumn(this.conditionItem,this.filterConditionFormParams);return this._commandService.executeCommand(c.SetSheetsFilterCriteriaCommand.id,{unitId:this._filterModel.unitId,subUnitId:this._filterModel.subUnitId,col:this.col,criteria:e})}onPrimaryConditionChange(e){const r=d.ALL_CONDITIONS.find(i=>i.operator===e);if(!r)throw new Error(`[ByConditionsModel]: condition item not found for operator: ${e}!`);this._conditionItem$.next(r),this._filterConditionFormParams$.next(d.getInitialFormParams(e))}onConditionFormChange(e){const r={...this.filterConditionFormParams,...e};if(r.and!==!0&&delete r.and,typeof e.and<"u"||typeof e.operator1<"u"||typeof e.operator2<"u"){const i=d.testMappingParams(r,this.conditionItem.numOfParameters);this._conditionItem$.next(i)}this._filterConditionFormParams$.next(r)}};de=Ne([me(4,u.ICommandService)],de);let fe=class extends u.Disposable{constructor(e,r,i,s,l){super();v(this,"_rawFilterItems$");v(this,"rawFilterItems$");v(this,"filterItems$");v(this,"_filterItems",[]);v(this,"_treeMapCache");v(this,"canApply$");v(this,"_manuallyUpdateFilterItems$");v(this,"_searchString$");v(this,"searchString$");this._filterModel=e,this.col=r,this._commandService=l,this._treeMapCache=s,this._searchString$=new C.BehaviorSubject(""),this.searchString$=this._searchString$.asObservable(),this._rawFilterItems$=new C.BehaviorSubject(i),this.rawFilterItems$=this._rawFilterItems$.asObservable(),this._manuallyUpdateFilterItems$=new C.Subject,this.filterItems$=C.merge(C.combineLatest([this._searchString$.pipe(C.throttleTime(500,void 0,{leading:!0,trailing:!0}),C.startWith(void 0)),this._rawFilterItems$]).pipe(C.map(([n,o])=>{if(!n)return o;const h=n.toLowerCase().split(/\s+/).filter(m=>!!m);return je(o,h)})),this._manuallyUpdateFilterItems$).pipe(C.shareReplay(1)),this.canApply$=this.filterItems$.pipe(C.map(n=>Ee(n).checked>0)),this.disposeWithMe(this.filterItems$.subscribe(n=>this._filterItems=n))}static async fromFilterColumn(e,r,i){var B;const s=e.get(u.IUniverInstanceService),l=e.get(u.LocaleService),n=e.get(he,u.Quantity.OPTIONAL),{unitId:o,subUnitId:a}=r,h=s.getUniverSheetInstance(o);if(!h)throw new Error(`[ByValuesModel]: Workbook not found for filter model with unitId: ${o}!`);const m=h==null?void 0:h.getSheetBySheetId(a);if(!m)throw new Error(`[ByValuesModel]: Worksheet not found for filter model with unitId: ${o} and subUnitId: ${a}!`);const p=r.getRange(),T=i,_=(B=r.getFilterColumn(i))==null?void 0:B.getColumnData().filters,O=new Set(_==null?void 0:_.filters),E=!!(_&&_.blank),A=r.getFilteredOutRowsExceptCol(i),N={...p,startRow:p.startRow+1,startColumn:T,endColumn:T};let U,M;if(n){const V=await n.getFilterValues({unitId:o,subUnitId:a,filteredOutRowsByOtherColumns:Array.from(A),filters:!!_,blankChecked:E,iterateRange:N,alreadyChecked:Array.from(O)});U=V.filterTreeItems,M=V.filterTreeMapCache}else{const V=De(!!_,l,N,m,A,O,E,h.getStyles());U=V.filterTreeItems,M=V.filterTreeMapCache}return e.createInstance(fe,r,i,U,M)}get rawFilterItems(){return this._rawFilterItems$.getValue()}get filterItems(){return this._filterItems}get treeMapCache(){return this._treeMapCache}dispose(){this._rawFilterItems$.complete(),this._searchString$.complete()}deltaCol(e){this.col+=e}setSearchString(e){this._searchString$.next(e)}onCheckAllToggled(e){const r=u.Tools.deepClone(this._filterItems);r.forEach(i=>se(i,e)),this._manuallyUpdateFilterItems(r)}onFilterCheckToggled(e){const r=u.Tools.deepClone(this._filterItems),i=Ie(r,e.key);if(!i)return;const s=He(i);se(i,!s),this._manuallyUpdateFilterItems(r)}onFilterOnly(e){const r=u.Tools.deepClone(this._filterItems);r.forEach(i=>se(i,!1)),e.forEach(i=>{const s=Ie(r,i);s&&se(s,!0)}),this._manuallyUpdateFilterItems(r)}_manuallyUpdateFilterItems(e){this._manuallyUpdateFilterItems$.next(e)}clear(){return this._disposed?Promise.resolve(!1):this._commandService.executeCommand(c.SetSheetsFilterCriteriaCommand.id,{unitId:this._filterModel.unitId,subUnitId:this._filterModel.subUnitId,col:this.col,criteria:null})}async apply(){if(this._disposed)return!1;const e=Ee(this._filterItems),{checked:r,checkedItems:i}=e,s=this.rawFilterItems;let l=0;for(const h of s)l+=h.count;const n=r===0,o=e.checked===l,a={colId:this.col};if(n)throw new Error("[ByValuesModel]: no checked items!");if(o)return this._commandService.executeCommand(c.SetSheetsFilterCriteriaCommand.id,{unitId:this._filterModel.unitId,subUnitId:this._filterModel.subUnitId,col:this.col,criteria:null});{a.filters={};const h=i.filter(p=>p.key!=="empty");h.length>0&&(a.filters={filters:h.flatMap(p=>p.originValues?Array.from(p.originValues):[p.title])}),h.length!==i.length&&(a.filters.blank=!0)}return this._commandService.executeCommand(c.SetSheetsFilterCriteriaCommand.id,{unitId:this._filterModel.unitId,subUnitId:this._filterModel.subUnitId,col:this.col,criteria:a})}};fe=Ne([me(4,u.ICommandService)],fe);const J="FILTER_PANEL_OPENED",oe={id:"sheet.operation.open-filter-panel",type:u.CommandType.OPERATION,handler:(t,e)=>{const r=t.get(u.IContextService),i=t.get(c.SheetsFilterService),s=t.get(G);t.get(u.ICommandService).syncExecuteCommand($.SetCellEditVisibleOperation.id,{visible:!1});const{unitId:n,subUnitId:o,col:a}=e,h=i.getFilterModel(n,o);return h?(s.setupCol(h,a),r.getContextValue(J)||r.setContextValue(J,!0),!0):!1}},z={id:"sheet.operation.close-filter-panel",type:u.CommandType.OPERATION,handler:t=>{const e=t.get(u.IContextService),r=t.get(G),i=t.get(F.ILayoutService,u.Quantity.OPTIONAL);return e.getContextValue(J)?(e.setContextValue(J,!1),i==null||i.focus(),r.terminate()):!1}},ye={id:"sheet.operation.apply-filter",type:u.CommandType.OPERATION,handler:(t,e)=>{const{filterBy:r}=e;return t.get(G).changeFilterBy(r)}};var lt=Object.defineProperty,ut=Object.getOwnPropertyDescriptor,ct=(t,e,r,i)=>{for(var s=i>1?void 0:i?ut(e,r):e,l=t.length-1,n;l>=0;l--)(n=t[l])&&(s=(i?n(e,r,s):n(s))||s);return i&&s&&lt(e,r,s),s},ee=(t,e)=>(r,i)=>e(r,i,t);let te=class extends u.Disposable{constructor(t,e,r,i,s,l){super(),this._sheetsFilterService=t,this._localeService=e,this._commandService=r,this._sheetPermissionCheckPermission=i,this._injector=s,this._sheetsSelectionService=l,this._commandExecutedListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.beforeCommandExecuted(t=>{var e,r,i;if(t.id===c.SmartToggleSheetsFilterCommand.id){const s=this._injector.get(u.IUniverInstanceService),l=P.getSheetCommandTarget(s);if(!l)return;const{unitId:n,subUnitId:o,worksheet:a}=l,h=(e=this._sheetsFilterService.getFilterModel(n,o))==null?void 0:e.getRange();let m;if(h)m=this._sheetPermissionCheckPermission.permissionCheckWithRanges({rangeTypes:[P.RangeProtectionPermissionViewPoint],worksheetTypes:[P.WorksheetFilterPermission,P.WorksheetViewPermission]},[h]);else{const p=(r=this._sheetsSelectionService.getCurrentLastSelection())==null?void 0:r.range;if(p){let T={...p};T=p.startColumn===p.endColumn&&p.startRow===p.endRow?P.expandToContinuousRange(T,{left:!0,right:!0,up:!0,down:!0},a):T,m=this._sheetPermissionCheckPermission.permissionCheckWithRanges({rangeTypes:[P.RangeProtectionPermissionViewPoint],worksheetTypes:[P.WorksheetViewPermission,P.WorksheetFilterPermission]},[T],n,o)}else m=this._sheetPermissionCheckPermission.permissionCheckWithoutRange({rangeTypes:[P.RangeProtectionPermissionViewPoint],worksheetTypes:[P.WorksheetViewPermission,P.WorksheetFilterPermission]})}m||this._sheetPermissionCheckPermission.blockExecuteWithoutPermission(this._localeService.t("permission.dialog.filterErr"))}if(t.id===oe.id){const s=t.params,{unitId:l,subUnitId:n}=s,o=(i=this._sheetsFilterService.getFilterModel(l,n))==null?void 0:i.getRange(),a=u.Tools.deepClone(o);a&&(a.startColumn=s.col,a.endColumn=s.col,this._sheetPermissionCheckPermission.permissionCheckWithRanges({rangeTypes:[P.RangeProtectionPermissionViewPoint],worksheetTypes:[P.WorksheetFilterPermission,P.WorksheetViewPermission]},[a])||this._sheetPermissionCheckPermission.blockExecuteWithoutPermission(this._localeService.t("permission.dialog.filterErr")))}}))}};te=ct([ee(0,u.Inject(c.SheetsFilterService)),ee(1,u.Inject(u.LocaleService)),ee(2,u.ICommandService),ee(3,u.Inject(P.SheetPermissionCheckController)),ee(4,u.Inject(u.Injector)),ee(5,u.Inject(P.SheetsSelectionsService))],te);var H=function(){return H=Object.assign||function(t){for(var e,r=1,i=arguments.length;r<i;r++){e=arguments[r];for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&(t[s]=e[s])}return t},H.apply(this,arguments)},ht=function(t,e){var r={};for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&e.indexOf(i)<0&&(r[i]=t[i]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,i=Object.getOwnPropertySymbols(t);s<i.length;s++)e.indexOf(i[s])<0&&Object.prototype.propertyIsEnumerable.call(t,i[s])&&(r[i[s]]=t[i[s]]);return r},Be=y.forwardRef(function(t,e){var r=t.icon,i=t.id,s=t.className,l=t.extend,n=ht(t,["icon","id","className","extend"]),o="univerjs-icon univerjs-icon-".concat(i," ").concat(s||"").trim(),a=y.useRef("_".concat(dt()));return Ve(r,"".concat(i),{defIds:r.defIds,idSuffix:a.current},H({ref:e,className:o},n),l)});function Ve(t,e,r,i,s){return y.createElement(t.tag,H(H({key:e},mt(t,r,s)),i),(pt(t,r).children||[]).map(function(l,n){return Ve(l,"".concat(e,"-").concat(t.tag,"-").concat(n),r,void 0,s)}))}function mt(t,e,r){var i=H({},t.attrs);r!=null&&r.colorChannel1&&i.fill==="colorChannel1"&&(i.fill=r.colorChannel1);var s=e.defIds;return!s||s.length===0||(t.tag==="use"&&i["xlink:href"]&&(i["xlink:href"]=i["xlink:href"]+e.idSuffix),Object.entries(i).forEach(function(l){var n=l[0],o=l[1];typeof o=="string"&&(i[n]=o.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))})),i}function pt(t,e){var r,i=e.defIds;return!i||i.length===0?t:t.tag==="defs"&&(!((r=t.children)===null||r===void 0)&&r.length)?H(H({},t),{children:t.children.map(function(s){return typeof s.attrs.id=="string"&&i&&i.indexOf(s.attrs.id)>-1?H(H({},s),{attrs:H(H({},s.attrs),{id:s.attrs.id+e.idSuffix})}):s})}):t}function dt(){return Math.random().toString(36).substring(2,8)}Be.displayName="UniverIcon";var ft={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M3.32182 2.60967C2.98161 2.60967 2.79671 3.0074 3.01601 3.2675L6.85819 7.8246C6.94943 7.93282 6.99947 8.06981 6.99947 8.21136V12.7338C6.99947 12.898 7.0998 13.0455 7.2525 13.1058L8.73833 13.6928C9.00085 13.7965 9.28531 13.6031 9.28531 13.3208V8.21136C9.28531 8.06981 9.33535 7.93282 9.42659 7.8246L13.2688 3.2675C13.4881 3.0074 13.3032 2.60967 12.963 2.60967H3.32182ZM2.09858 4.04101C1.22139 3.0006 1.96097 1.40967 3.32182 1.40967H12.963C14.3238 1.40967 15.0634 3.0006 14.1862 4.04101L10.4853 8.43054V13.3208C10.4853 14.4498 9.34747 15.2237 8.29742 14.8089L6.81158 14.2219C6.20078 13.9806 5.79947 13.3905 5.79947 12.7338V8.43054L2.09858 4.04101Z",fillRule:"evenodd",clipRule:"evenodd"}}]},We=y.forwardRef(function(t,e){return y.createElement(Be,Object.assign({},t,{id:"filter-single",ref:e,icon:ft}))});We.displayName="FilterSingle";var Re={exports:{}},ae={};/**
11
11
  * @license React
12
12
  * react-jsx-runtime.production.min.js
13
13
  *
@@ -15,7 +15,7 @@
15
15
  *
16
16
  * This source code is licensed under the MIT license found in the
17
17
  * LICENSE file in the root directory of this source tree.
18
- */var ke;function _t(){if(ke)return ae;ke=1;var t=y,e=Symbol.for("react.element"),r=Symbol.for("react.fragment"),i=Object.prototype.hasOwnProperty,s=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,l={key:!0,ref:!0,__self:!0,__source:!0};function n(o,a,h){var m,p={},T=null,_=null;h!==void 0&&(T=""+h),a.key!==void 0&&(T=""+a.key),a.ref!==void 0&&(_=a.ref);for(m in a)i.call(a,m)&&!l.hasOwnProperty(m)&&(p[m]=a[m]);if(o&&o.defaultProps)for(m in a=o.defaultProps,a)p[m]===void 0&&(p[m]=a[m]);return{$$typeof:e,type:o,key:T,ref:_,props:p,_owner:s.current}}return ae.Fragment=r,ae.jsx=n,ae.jsxs=n,ae}var xe;function vt(){return xe||(xe=1,Re.exports=_t()),Re.exports}var f=vt();const I={sheetsFilterPanel:"univer-sheets-filter-panel",sheetsFilterPanelHeader:"univer-sheets-filter-panel-header",sheetsFilterPanelContent:"univer-sheets-filter-panel-content",sheetsFilterPanelSelectAll:"univer-sheets-filter-panel-select-all",sheetsFilterPanelSelectAllCount:"univer-sheets-filter-panel-select-all-count",sheetsFilterPanelValuesContainer:"univer-sheets-filter-panel-values-container",inputAffixWrapper:"univer-input-affix-wrapper",select:"univer-select",radioGroup:"univer-radio-group",sheetsFilterPanelValuesFind:"univer-sheets-filter-panel-values-find",sheetsFilterPanelValuesList:"univer-sheets-filter-panel-values-list",sheetsFilterPanelValuesListInnerContainer:"univer-sheets-filter-panel-values-list-inner-container",sheetsFilterPanelValuesVirtual:"univer-sheets-filter-panel-values-virtual",sheetsFilterPanelValuesItem:"univer-sheets-filter-panel-values-item",sheetsFilterPanelValuesItemInner:"univer-sheets-filter-panel-values-item-inner",sheetsFilterPanelValuesItemCount:"univer-sheets-filter-panel-values-item-count",sheetsFilterPanelValuesItemExcludeButton:"univer-sheets-filter-panel-values-item-exclude-button",sheetsFilterPanelValuesItemText:"univer-sheets-filter-panel-values-item-text",sheetsFilterPanelConditionsContainer:"univer-sheets-filter-panel-conditions-container",sheetsFilterPanelConditionsContainerInner:"univer-sheets-filter-panel-conditions-container-inner",sheetsFilterPanelConditionsDesc:"univer-sheets-filter-panel-conditions-desc",sheetsFilterPanelFooter:"univer-sheets-filter-panel-footer",sheetsFilterPanelFooterPrimaryButtons:"univer-sheets-filter-panel-footer-primary-buttons",button:"univer-button",input:"univer-input",formDualColumnLayout:"univer-form-dual-column-layout",sheetsFilterTreeNode:"univer-sheets-filter-tree-node",sheetsFilterTreeNodeFilterOnly:"univer-sheets-filter-tree-node-filter-only",sheetsFilterTreeNodeAttach:"univer-sheets-filter-tree-node-attach"};function St(t){var _,O;const{model:e}=t,r=c.useDependency(c.LocaleService),i=E.useObservable(e.conditionItem$,void 0),s=E.useObservable(e.filterConditionFormParams$,void 0),l=s!=null&&s.and?"AND":"OR",n=y.useCallback(F=>{e.onConditionFormChange({and:F==="AND"})},[e]),o=gt(r),a=y.useCallback(F=>{e.onPrimaryConditionChange(F)},[e]),h=Ct(r),m=y.useCallback(F=>{e.onConditionFormChange(F)},[e]),p=r.t("sheets-filter.panel.input-values-placeholder");function T(F,A,N){const w=d.getItemByOperator(F).numOfParameters===1;return f.jsxs(f.Fragment,{children:[N==="operator2"&&f.jsxs(L.RadioGroup,{value:l,onChange:n,children:[f.jsx(L.Radio,{value:"AND",children:r.t("sheets-filter.panel.and")}),f.jsx(L.Radio,{value:"OR",children:r.t("sheets-filter.panel.or")})]}),f.jsx(L.Select,{value:F,options:h,onChange:M=>m({[N]:M})}),w&&f.jsx("div",{children:f.jsx(L.Input,{value:A,placeholder:p,onChange:M=>m({[N==="operator1"?"val1":"val2"]:M})})})]})}return f.jsx("div",{className:I.sheetsFilterPanelConditionsContainer,children:i&&s&&f.jsxs(f.Fragment,{children:[f.jsx(L.Select,{value:i.operator,options:o,onChange:a}),d.getItemByOperator(i.operator).numOfParameters!==0?f.jsxs("div",{className:I.sheetsFilterPanelConditionsContainerInner,children:[i.numOfParameters>=1&&T(s.operator1,(_=s.val1)!=null?_:"","operator1"),i.numOfParameters>=2&&T(s.operator2,(O=s.val2)!=null?O:"","operator2"),f.jsxs("div",{className:I.sheetsFilterPanelConditionsDesc,children:[r.t("sheets-filter.panel.?"),f.jsx("br",{}),r.t("sheets-filter.panel.*")]})]}):null]})})}function gt(t){const e=t.getCurrentLocale();return y.useMemo(()=>[{options:[{label:t.t(d.NONE.label),value:d.NONE.operator}]},{options:[{label:t.t(d.EMPTY.label),value:d.EMPTY.operator},{label:t.t(d.NOT_EMPTY.label),value:d.NOT_EMPTY.operator}]},{options:[{label:t.t(d.TEXT_CONTAINS.label),value:d.TEXT_CONTAINS.operator},{label:t.t(d.DOES_NOT_CONTAIN.label),value:d.DOES_NOT_CONTAIN.operator},{label:t.t(d.STARTS_WITH.label),value:d.STARTS_WITH.operator},{label:t.t(d.ENDS_WITH.label),value:d.ENDS_WITH.operator},{label:t.t(d.EQUALS.label),value:d.EQUALS.operator}]},{options:[{label:t.t(d.GREATER_THAN.label),value:d.GREATER_THAN.operator},{label:t.t(d.GREATER_THAN_OR_EQUAL.label),value:d.GREATER_THAN_OR_EQUAL.operator},{label:t.t(d.LESS_THAN.label),value:d.LESS_THAN.operator},{label:t.t(d.LESS_THAN_OR_EQUAL.label),value:d.LESS_THAN_OR_EQUAL.operator},{label:t.t(d.EQUAL.label),value:d.EQUAL.operator},{label:t.t(d.NOT_EQUAL.label),value:d.NOT_EQUAL.operator},{label:t.t(d.BETWEEN.label),value:d.BETWEEN.operator},{label:t.t(d.NOT_BETWEEN.label),value:d.NOT_BETWEEN.operator}]},{options:[{label:t.t(d.CUSTOM.label),value:d.CUSTOM.operator}]}],[e,t])}function Ct(t){const e=t.getCurrentLocale();return y.useMemo(()=>d.ALL_CONDITIONS.filter(r=>r.numOfParameters!==2).map(r=>({label:t.t(r.label),value:r.operator})),[e,t])}function Tt(t){const{model:e}=t,r=c.useDependency(c.LocaleService),i=E.useObservable(e.searchString$,"",!0),s=E.useObservable(e.filterItems$,void 0,!0),l=r.t("sheets-filter.panel.filter-only"),n=Fe(s),o=n.checked>0&&n.unchecked===0,a=n.checked>0&&n.unchecked>0,h=e.treeMapCache,m=y.useCallback(()=>{e.onCheckAllToggled(!o)},[e,o]),p=y.useCallback(_=>{e.setSearchString(_)},[e]);function T(_){let O=[];return _.forEach(F=>{F.checked&&O.push(F.key),F.children&&(O=O.concat(T(F.children)))}),O}return f.jsxs("div",{className:I.sheetsFilterPanelValuesContainer,children:[f.jsx(L.Input,{autoFocus:!0,value:i,placeholder:r.t("sheets-filter.panel.search-placeholder"),onChange:p}),f.jsxs("div",{className:I.sheetsFilterPanelValuesList,children:[f.jsx("div",{className:I.sheetsFilterPanelValuesItem,children:f.jsxs("div",{className:I.sheetsFilterPanelValuesItemInner,children:[f.jsx(L.Checkbox,{indeterminate:a,disabled:s.length===0,checked:o,onChange:m}),f.jsx("span",{className:I.sheetsFilterPanelValuesItemText,children:`${r.t("sheets-filter.panel.select-all")}`}),f.jsx("span",{className:I.sheetsFilterPanelValuesItemCount,children:`(${n.checked}/${n.checked+n.unchecked})`})]})}),f.jsx("div",{className:I.sheetsFilterPanelValuesVirtual,children:f.jsx(L.Tree,{data:s,defaultExpandAll:!1,valueGroup:T(s),height:180,onChange:_=>{e.onFilterCheckToggled(_)},defaultCache:h,itemHeight:28,treeNodeClassName:I.sheetsFilterTreeNode,attachRender:_=>f.jsxs("div",{className:I.sheetsFilterTreeNodeAttach,children:[f.jsx("span",{className:I.sheetsFilterPanelValuesItemCount,children:`(${_.count})`}),f.jsx(L.Button,{className:I.sheetsFilterTreeNodeFilterOnly,size:"small",type:"link",onClick:()=>{const O=[];_.children?_.children.forEach(F=>{F.children?F.children.forEach(A=>{O.push(A.key)}):O.push(F.key)}):O.push(_.key),e.onFilterOnly(O)},children:l})]})})})]})]})}function Ft(){var A;const t=c.useDependency(G),e=c.useDependency(c.LocaleService),r=c.useDependency(c.ICommandService),i=E.useObservable(t.filterBy$,void 0,!0),s=E.useObservable(t.filterByModel$,void 0,!1),l=E.useObservable(()=>(s==null?void 0:s.canApply$)||C.of(!1),void 0,!1,[s]),n=Et(e),o=!E.useObservable(t.hasCriteria$),a=y.useCallback(N=>{r.executeCommand(ye.id,{filterBy:N})},[r]),h=y.useCallback(async()=>{await(s==null?void 0:s.clear()),r.executeCommand(z.id)},[s,r]),m=y.useCallback(()=>{r.executeCommand(z.id)},[r]),p=y.useCallback(async()=>{await(s==null?void 0:s.apply()),r.executeCommand(z.id)},[s,r]),_=(A=c.useDependency(u.SheetsFilterService).activeFilterModel)==null?void 0:A.getRange(),O=t.col,F=E.useComponentsOfPart(U.SheetsUIPart.FILTER_PANEL_EMBED_POINT);return f.jsxs("div",{className:I.sheetsFilterPanel,children:[f.jsx(E.ComponentContainer,{components:F,sharedProps:{range:_,colIndex:O,onClose:m}}),f.jsx("div",{className:I.sheetsFilterPanelHeader,children:f.jsx(L.Segmented,{value:i,options:n,onChange:N=>a(N)})}),s?f.jsx("div",{className:I.sheetsFilterPanelContent,children:i===pe.VALUES?f.jsx(Tt,{model:s}):f.jsx(St,{model:s})}):f.jsx("div",{style:{flex:1}}),f.jsxs("div",{className:I.sheetsFilterPanelFooter,children:[f.jsx(L.Button,{type:"link",onClick:h,disabled:o,children:e.t("sheets-filter.panel.clear-filter")}),f.jsxs("span",{className:I.sheetsFilterPanelFooterPrimaryButtons,children:[f.jsx(L.Button,{type:"default",onClick:m,children:e.t("sheets-filter.panel.cancel")}),f.jsx(L.Button,{disabled:!l,type:"primary",onClick:p,children:e.t("sheets-filter.panel.confirm")})]})]})]})}function Et(t){const e=t.getCurrentLocale();return y.useMemo(()=>[{label:t.t("sheets-filter.panel.by-values"),value:pe.VALUES},{label:t.t("sheets-filter.panel.by-conditions"),value:pe.CONDITIONS}],[e,t])}function Ot(t){const e=t.get(u.SheetsFilterService);return{id:u.SmartToggleSheetsFilterCommand.id,type:E.MenuItemType.BUTTON_SELECTOR,icon:"FilterSingle",tooltip:"sheets-filter.toolbar.smart-toggle-filter-tooltip",hidden$:E.getMenuHiddenObservable(t,c.UniverInstanceType.UNIVER_SHEET),activated$:e.activeFilterModel$.pipe(C.map(r=>!!r)),disabled$:U.getObservableWithExclusiveRange$(t,U.getCurrentRangeDisable$(t,{worksheetTypes:[P.WorksheetFilterPermission,P.WorksheetViewPermission],rangeTypes:[P.RangeProtectionPermissionViewPoint]}))}}function Pt(t){const e=t.get(u.SheetsFilterService);return{id:u.ClearSheetsFilterCriteriaCommand.id,type:E.MenuItemType.BUTTON,title:"sheets-filter.toolbar.clear-filter-criteria",hidden$:E.getMenuHiddenObservable(t,c.UniverInstanceType.UNIVER_SHEET),disabled$:e.activeFilterModel$.pipe(C.switchMap(r=>{var i;return(i=r==null?void 0:r.hasCriteria$.pipe(C.map(s=>!s)))!=null?i:C.of(!0)}))}}function It(t){const e=t.get(u.SheetsFilterService);return{id:u.ReCalcSheetsFilterCommand.id,type:E.MenuItemType.BUTTON,title:"sheets-filter.toolbar.re-calc-filter-conditions",hidden$:E.getMenuHiddenObservable(t,c.UniverInstanceType.UNIVER_SHEET),disabled$:e.activeFilterModel$.pipe(C.switchMap(r=>{var i;return(i=r==null?void 0:r.hasCriteria$.pipe(C.map(s=>!s)))!=null?i:C.of(!0)}))}}const Nt={[E.RibbonStartGroup.FORMULAS_INSERT]:{[u.SmartToggleSheetsFilterCommand.id]:{order:10,menuItemFactory:Ot,[u.ClearSheetsFilterCriteriaCommand.id]:{order:0,menuItemFactory:Pt},[u.ReCalcSheetsFilterCommand.id]:{order:1,menuItemFactory:It}}}},yt={id:u.SmartToggleSheetsFilterCommand.id,binding:E.KeyCode.L|E.MetaKeys.CTRL_COMMAND|E.MetaKeys.SHIFT,description:"sheets-filter.shortcut.smart-toggle-filter",preconditions:U.whenSheetEditorFocused,group:"4_sheet-edit"},Y=16,Rt=new Path2D("M3.30363 3C2.79117 3 2.51457 3.60097 2.84788 3.99024L6.8 8.60593V12.5662C6.8 12.7184 6.8864 12.8575 7.02289 12.9249L8.76717 13.7863C8.96655 13.8847 9.2 13.7396 9.2 13.5173V8.60593L13.1521 3.99024C13.4854 3.60097 13.2088 3 12.6964 3H3.30363Z");class Qe{static drawNoCriteria(e,r,i,s){e.save(),ie.Rect.drawWith(e,{radius:2,width:Y,height:Y,fill:s}),e.lineCap="square",e.strokeStyle=i,e.scale(r/Y,r/Y),e.beginPath(),e.lineWidth=1,e.lineCap="round",e.moveTo(3,4),e.lineTo(13,4),e.moveTo(4.5,8),e.lineTo(11.5,8),e.moveTo(6,12),e.lineTo(10,12),e.stroke(),e.restore()}static drawHasCriteria(e,r,i,s){e.save(),ie.Rect.drawWith(e,{radius:2,width:Y,height:Y,fill:s}),e.scale(r/Y,r/Y),e.fillStyle=i,e.fill(Rt),e.restore()}}var At=Object.defineProperty,bt=Object.getOwnPropertyDescriptor,Lt=(t,e,r,i)=>{for(var s=i>1?void 0:i?bt(e,r):e,l=t.length-1,n;l>=0;l--)(n=t[l])&&(s=(i?n(e,r,s):n(s))||s);return i&&s&&At(e,r,s),s},Ae=(t,e)=>(r,i)=>e(r,i,t);const x=16,_e=1;let be=class extends ie.Shape{constructor(e,r,i,s,l){super(e,r);S(this,"_cellWidth",0);S(this,"_cellHeight",0);S(this,"_filterParams");S(this,"_hovered",!1);this._contextService=i,this._commandService=s,this._themeService=l,this.setShapeProps(r),this.onPointerDown$.subscribeEvent(n=>this.onPointerDown(n)),this.onPointerEnter$.subscribeEvent(()=>this.onPointerEnter()),this.onPointerLeave$.subscribeEvent(()=>this.onPointerLeave())}setShapeProps(e){typeof e.cellHeight<"u"&&(this._cellHeight=e.cellHeight),typeof e.cellWidth<"u"&&(this._cellWidth=e.cellWidth),typeof e.filterParams<"u"&&(this._filterParams=e.filterParams),this.transformByState({width:e.width,height:e.height})}_draw(e){const r=this._cellHeight,i=this._cellWidth,s=x-i,l=x-r;e.save();const n=new Path2D;n.rect(s,l,i,r),e.clip(n);const{hasCriteria:o}=this._filterParams,a=this._themeService.getCurrentTheme().primaryColor,h=this._hovered?this._themeService.getCurrentTheme().grey50:"rgba(255, 255, 255, 1.0)";o?Qe.drawHasCriteria(e,x,a,h):Qe.drawNoCriteria(e,x,a,h),e.restore()}onPointerDown(e){if(e.button===2)return;const{col:r,unitId:i,subUnitId:s}=this._filterParams;this._contextService.getContextValue(J)||!this._commandService.hasCommand(oe.id)||setTimeout(()=>{this._commandService.executeCommand(oe.id,{unitId:i,subUnitId:s,col:r})},200)}onPointerEnter(){this._hovered=!0,this.makeDirty(!0)}onPointerLeave(){this._hovered=!1,this.makeDirty(!0)}};be=Lt([Ae(2,c.IContextService),Ae(3,c.ICommandService),Ae(4,c.Inject(c.ThemeService))],be);var Mt=Object.defineProperty,Ut=Object.getOwnPropertyDescriptor,wt=(t,e,r,i)=>{for(var s=i>1?void 0:i?Ut(e,r):e,l=t.length-1,n;l>=0;l--)(n=t[l])&&(s=(i?n(e,r,s):n(s))||s);return i&&s&&Mt(e,r,s),s},X=(t,e)=>(r,i)=>e(r,i,t);const $t=1e3,Dt=5e3;let Le=class extends c.RxDisposable{constructor(e,r,i,s,l,n,o,a){super();S(this,"_filterRangeShape",null);S(this,"_buttonRenderDisposable",null);S(this,"_filterButtonShapes",[]);this._context=e,this._injector=r,this._sheetSkeletonManagerService=i,this._sheetsFilterService=s,this._themeService=l,this._sheetInterceptorService=n,this._commandService=o,this._selectionRenderService=a,this._initRenderer()}dispose(){super.dispose(),this._disposeRendering()}_initRenderer(){this._sheetSkeletonManagerService.currentSkeleton$.pipe(C.switchMap(e=>{var o,a;if(!e)return C.of(null);const{unit:r,unitId:i}=this._context,s=((o=r.getActiveSheet())==null?void 0:o.getSheetId())||"",l=(a=this._sheetsFilterService.getFilterModel(i,s))!=null?a:void 0,n=()=>({unitId:i,worksheetId:s,filterModel:l,range:l==null?void 0:l.getRange(),skeleton:e.skeleton});return c.fromCallback(this._commandService.onCommandExecuted.bind(this._commandService)).pipe(C.filter(([h])=>{var m;return h.type===c.CommandType.MUTATION&&((m=h.params)==null?void 0:m.unitId)===r.getUnitId()&&(u.FILTER_MUTATIONS.has(h.id)||h.id===P.SetRangeValuesMutation.id)}),C.throttleTime(20,void 0,{leading:!1,trailing:!0}),C.map(n),C.startWith(n()))}),C.takeUntil(this.dispose$)).subscribe(e=>{this._disposeRendering(),!(!e||!e.range)&&(this._renderRange(e.range,e.skeleton),this._renderButtons(e))})}_renderRange(e,r){const{scene:i}=this._context,{rowHeaderWidth:s,columnHeaderHeight:l}=r,n=this._filterRangeShape=new U.SelectionControl(i,$t,this._themeService,{rowHeaderWidth:s,columnHeaderHeight:l,enableAutoFill:!1,highlightHeader:!1}),o={range:e,primary:null,style:{fill:"rgba(0, 0, 0, 0.0)"}},a=U.attachSelectionWithCoord(o,r);n.updateRangeBySelectionWithCoord(a),n.setEvent(!1),i.makeDirty(!0)}_renderButtons(e){const{range:r,filterModel:i,unitId:s,skeleton:l,worksheetId:n}=e,{scene:o}=this._context;this._interceptCellContent(s,n,e.range);const{startColumn:a,endColumn:h,startRow:m}=r;for(let p=a;p<=h;p++){const T=`sheets-filter-button-${p}`,_=U.getCoordByCell(m,p,o,l),{startX:O,startY:F,endX:A,endY:N}=_,w=A-O,M=N-F;if(M<=_e||w<=_e)continue;const j=!!i.getFilterColumn(p),V=A-x-_e,ge=N-x-_e,Ce={left:V,top:ge,height:x,width:x,zIndex:Dt,cellHeight:M,cellWidth:w,filterParams:{unitId:s,subUnitId:n,col:p,hasCriteria:j}},$=this._injector.createInstance(be,T,Ce);this._filterButtonShapes.push($)}o.addObjects(this._filterButtonShapes),o.makeDirty()}_interceptCellContent(e,r,i){const{startRow:s,startColumn:l,endColumn:n}=i;this._buttonRenderDisposable=this._sheetInterceptorService.intercept(P.INTERCEPTOR_POINT.CELL_CONTENT,{effect:c.InterceptorEffectEnum.Style,handler:(o,a,h)=>{const{row:m,col:p,unitId:T,subUnitId:_}=a;return T!==e||_!==r||m!==s||p<l||p>n?h(o):h({...o,fontRenderExtension:{...o==null?void 0:o.fontRenderExtension,rightOffset:x}})},priority:10})}_disposeRendering(){var e,r;(e=this._filterRangeShape)==null||e.dispose(),this._filterButtonShapes.forEach(i=>i.dispose()),(r=this._buttonRenderDisposable)==null||r.dispose(),this._filterRangeShape=null,this._buttonRenderDisposable=null,this._filterButtonShapes=[]}};Le=wt([X(1,c.Inject(c.Injector)),X(2,c.Inject(U.SheetSkeletonManagerService)),X(3,c.Inject(u.SheetsFilterService)),X(4,c.Inject(c.ThemeService)),X(5,c.Inject(P.SheetInterceptorService)),X(6,c.ICommandService),X(7,U.ISheetSelectionRenderService)],Le);var Ht=Object.defineProperty,Bt=Object.getOwnPropertyDescriptor,jt=(t,e,r,i)=>{for(var s=i>1?void 0:i?Bt(e,r):e,l=t.length-1,n;l>=0;l--)(n=t[l])&&(s=(i?n(e,r,s):n(s))||s);return i&&s&&Ht(e,r,s),s},Ge=(t,e)=>(r,i)=>e(r,i,t);let le=class extends c.RxDisposable{constructor(t,e){super(),this._renderManagerService=t,this._sheetsRenderService=e,[u.SetSheetsFilterRangeMutation,u.SetSheetsFilterCriteriaMutation,u.RemoveSheetsFilterMutation,u.ReCalcSheetsFilterMutation].forEach(r=>this.disposeWithMe(this._sheetsRenderService.registerSkeletonChangingMutations(r.id))),this.disposeWithMe(this._renderManagerService.registerRenderModule(c.UniverInstanceType.UNIVER_SHEET,[Le]))}};le=jt([Ge(0,ie.IRenderManagerService),Ge(1,c.Inject(U.SheetsRenderService))],le);var Vt=Object.defineProperty,Wt=Object.getOwnPropertyDescriptor,kt=(t,e,r,i)=>{for(var s=i>1?void 0:i?Wt(e,r):e,l=t.length-1,n;l>=0;l--)(n=t[l])&&(s=(i?n(e,r,s):n(s))||s);return i&&s&&Vt(e,r,s),s},D=(t,e)=>(r,i)=>e(r,i,t);const Ye="FILTER_PANEL_POPUP";let ve=class extends le{constructor(e,r,i,s,l,n,o,a,h,m,p,T,_){super(_,T);S(this,"_popupDisposable");this._injector=e,this._componentManager=r,this._sheetsFilterPanelService=i,this._sheetCanvasPopupService=s,this._sheetsFilterService=l,this._localeService=n,this._shortcutService=o,this._commandService=a,this._menuManagerService=h,this._contextService=m,this._messageService=p,this._initCommands(),this._initShortcuts(),this._initMenuItems(),this._initUI()}dispose(){super.dispose(),this._closeFilterPopup()}_initShortcuts(){[yt].forEach(e=>{this.disposeWithMe(this._shortcutService.registerShortcut(e))})}_initCommands(){[u.SmartToggleSheetsFilterCommand,u.RemoveSheetFilterCommand,u.SetSheetFilterRangeCommand,u.SetSheetsFilterCriteriaCommand,u.ClearSheetsFilterCriteriaCommand,u.ReCalcSheetsFilterCommand,ye,oe,z].forEach(e=>{this.disposeWithMe(this._commandService.registerCommand(e))})}_initMenuItems(){this._menuManagerService.mergeMenu(Nt)}_initUI(){this.disposeWithMe(this._componentManager.register(Ye,Ft)),this.disposeWithMe(this._componentManager.register("FilterSingle",We)),this.disposeWithMe(this._contextService.subscribeContextValue$(J).pipe(C.distinctUntilChanged()).subscribe(e=>{e?this._openFilterPopup():this._closeFilterPopup()})),this.disposeWithMe(this._sheetsFilterService.errorMsg$.subscribe(e=>{e&&this._messageService.show({type:L.MessageType.Error,content:this._localeService.t(e)})}))}_openFilterPopup(){const e=this._sheetsFilterPanelService.filterModel;if(!e)throw new Error("[SheetsFilterUIController]: no filter model when opening filter popup!");const r=e.getRange(),i=this._sheetsFilterPanelService.col,{startRow:s}=r;this._popupDisposable=this._sheetCanvasPopupService.attachPopupToCell(s,i,{componentKey:Ye,direction:"horizontal",onClickOutside:()=>this._commandService.syncExecuteCommand(z.id),offset:[5,0]})}_closeFilterPopup(){var e;(e=this._popupDisposable)==null||e.dispose(),this._popupDisposable=null}};ve=kt([D(0,c.Inject(c.Injector)),D(1,c.Inject(E.ComponentManager)),D(2,c.Inject(G)),D(3,c.Inject(U.SheetCanvasPopManagerService)),D(4,c.Inject(u.SheetsFilterService)),D(5,c.Inject(c.LocaleService)),D(6,E.IShortcutService),D(7,c.ICommandService),D(8,E.IMenuManagerService),D(9,c.IContextService),D(10,E.IMessageService),D(11,c.Inject(U.SheetsRenderService)),D(12,ie.IRenderManagerService)],ve);var Ke=Object.defineProperty,xt=Object.getOwnPropertyDescriptor,Qt=(t,e,r)=>e in t?Ke(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Gt=(t,e,r,i)=>{for(var s=i>1?void 0:i?xt(e,r):e,l=t.length-1,n;l>=0;l--)(n=t[l])&&(s=(i?n(e,r,s):n(s))||s);return i&&s&&Ke(e,r,s),s},Me=(t,e)=>(r,i)=>e(r,i,t),Xe=(t,e,r)=>Qt(t,typeof e!="symbol"?e+"":e,r);const Yt="SHEET_FILTER_UI_PLUGIN";v.UniverSheetsFilterUIPlugin=class extends c.Plugin{constructor(e=ue,r,i,s){super(),this._config=e,this._injector=r,this._configService=i,this._rpcChannelService=s;const{menu:l,...n}=c.merge({},ue,this._config);l&&this._configService.setConfig("menu",l,{merge:!0}),this._configService.setConfig($e,n)}onStarting(){[[G],[te],[ve]].forEach(e=>this._injector.add(e)),this._config.useRemoteFilterValuesGenerator&&this._rpcChannelService&&this._injector.add([he,{useFactory:()=>k.toModule(this._rpcChannelService.requestChannel(Oe))}])}onReady(){this._injector.get(te)}onRendered(){this._injector.get(ve)}},Xe(v.UniverSheetsFilterUIPlugin,"type",c.UniverInstanceType.UNIVER_SHEET),Xe(v.UniverSheetsFilterUIPlugin,"pluginName",Yt),v.UniverSheetsFilterUIPlugin=Gt([c.DependentOn(u.UniverSheetsFilterPlugin),Me(1,c.Inject(c.Injector)),Me(2,c.IConfigService),Me(3,c.Optional(k.IRPCChannelService))],v.UniverSheetsFilterUIPlugin);var qe=Object.defineProperty,Kt=Object.getOwnPropertyDescriptor,Xt=(t,e,r)=>e in t?qe(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,qt=(t,e,r,i)=>{for(var s=i>1?void 0:i?Kt(e,r):e,l=t.length-1,n;l>=0;l--)(n=t[l])&&(s=(i?n(e,r,s):n(s))||s);return i&&s&&qe(e,r,s),s},Ze=(t,e)=>(r,i)=>e(r,i,t),Je=(t,e,r)=>Xt(t,typeof e!="symbol"?e+"":e,r);const Zt="SHEET_FILTER_UI_PLUGIN";v.UniverSheetsFilterMobileUIPlugin=class extends c.Plugin{constructor(e=ue,r,i){super(),this._config=e,this._injector=r,this._configService=i;const{menu:s,...l}=c.merge({},ue,this._config);s&&this._configService.setConfig("menu",s,{merge:!0}),this._configService.setConfig($e,l)}onStarting(){[[te],[le]].forEach(e=>this._injector.add(e))}onReady(){this._injector.get(te)}onRendered(){this._injector.get(le)}},Je(v.UniverSheetsFilterMobileUIPlugin,"type",c.UniverInstanceType.UNIVER_SHEET),Je(v.UniverSheetsFilterMobileUIPlugin,"pluginName",Zt),v.UniverSheetsFilterMobileUIPlugin=qt([c.DependentOn(u.UniverSheetsFilterPlugin),Ze(1,c.Inject(c.Injector)),Ze(2,c.IConfigService)],v.UniverSheetsFilterMobileUIPlugin);var Jt=Object.defineProperty,zt=Object.getOwnPropertyDescriptor,er=(t,e,r,i)=>{for(var s=i>1?void 0:i?zt(e,r):e,l=t.length-1,n;l>=0;l--)(n=t[l])&&(s=(i?n(e,r,s):n(s))||s);return i&&s&&Jt(e,r,s),s},ze=(t,e)=>(r,i)=>e(r,i,t);v.UniverSheetsFilterUIWorkerPlugin=(Se=class extends c.Plugin{constructor(e,r,i){super(),this._config=e,this._injector=r,this._rpcChannelService=i}onStarting(){[[he,{useClass:Pe}]].forEach(e=>this._injector.add(e))}onReady(){this._rpcChannelService.registerChannel(Oe,k.fromModule(this._injector.get(he)))}},S(Se,"type",c.UniverInstanceType.UNIVER_SHEET),S(Se,"pluginName","SHEET_FILTER_UI_WORKER_PLUGIN"),Se),v.UniverSheetsFilterUIWorkerPlugin=er([ze(1,c.Inject(c.Injector)),ze(2,k.IRPCChannelService)],v.UniverSheetsFilterUIWorkerPlugin),v.ChangeFilterByOperation=ye,v.CloseFilterPanelOperation=z,v.OpenFilterPanelOperation=oe,Object.defineProperty(v,Symbol.toStringTag,{value:"Module"})});
18
+ */var ke;function _t(){if(ke)return ae;ke=1;var t=y,e=Symbol.for("react.element"),r=Symbol.for("react.fragment"),i=Object.prototype.hasOwnProperty,s=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,l={key:!0,ref:!0,__self:!0,__source:!0};function n(o,a,h){var m,p={},T=null,_=null;h!==void 0&&(T=""+h),a.key!==void 0&&(T=""+a.key),a.ref!==void 0&&(_=a.ref);for(m in a)i.call(a,m)&&!l.hasOwnProperty(m)&&(p[m]=a[m]);if(o&&o.defaultProps)for(m in a=o.defaultProps,a)p[m]===void 0&&(p[m]=a[m]);return{$$typeof:e,type:o,key:T,ref:_,props:p,_owner:s.current}}return ae.Fragment=r,ae.jsx=n,ae.jsxs=n,ae}var xe;function St(){return xe||(xe=1,Re.exports=_t()),Re.exports}var f=St();const I={sheetsFilterPanel:"univer-sheets-filter-panel",sheetsFilterPanelHeader:"univer-sheets-filter-panel-header",sheetsFilterPanelContent:"univer-sheets-filter-panel-content",sheetsFilterPanelSelectAll:"univer-sheets-filter-panel-select-all",sheetsFilterPanelSelectAllCount:"univer-sheets-filter-panel-select-all-count",sheetsFilterPanelValuesContainer:"univer-sheets-filter-panel-values-container",inputAffixWrapper:"univer-input-affix-wrapper",select:"univer-select",radioGroup:"univer-radio-group",sheetsFilterPanelValuesFind:"univer-sheets-filter-panel-values-find",sheetsFilterPanelValuesList:"univer-sheets-filter-panel-values-list",sheetsFilterPanelValuesListInnerContainer:"univer-sheets-filter-panel-values-list-inner-container",sheetsFilterPanelValuesVirtual:"univer-sheets-filter-panel-values-virtual",sheetsFilterPanelValuesItem:"univer-sheets-filter-panel-values-item",sheetsFilterPanelValuesItemInner:"univer-sheets-filter-panel-values-item-inner",sheetsFilterPanelValuesItemCount:"univer-sheets-filter-panel-values-item-count",sheetsFilterPanelValuesItemExcludeButton:"univer-sheets-filter-panel-values-item-exclude-button",sheetsFilterPanelValuesItemText:"univer-sheets-filter-panel-values-item-text",sheetsFilterPanelConditionsContainer:"univer-sheets-filter-panel-conditions-container",sheetsFilterPanelConditionsContainerInner:"univer-sheets-filter-panel-conditions-container-inner",sheetsFilterPanelConditionsDesc:"univer-sheets-filter-panel-conditions-desc",sheetsFilterPanelFooter:"univer-sheets-filter-panel-footer",sheetsFilterPanelFooterPrimaryButtons:"univer-sheets-filter-panel-footer-primary-buttons",button:"univer-button",input:"univer-input",formDualColumnLayout:"univer-form-dual-column-layout",sheetsFilterTreeNode:"univer-sheets-filter-tree-node",sheetsFilterTreeNodeFilterOnly:"univer-sheets-filter-tree-node-filter-only",sheetsFilterTreeNodeAttach:"univer-sheets-filter-tree-node-attach"};function vt(t){var _,O;const{model:e}=t,r=u.useDependency(u.LocaleService),i=F.useObservable(e.conditionItem$,void 0),s=F.useObservable(e.filterConditionFormParams$,void 0),l=s!=null&&s.and?"AND":"OR",n=y.useCallback(E=>{e.onConditionFormChange({and:E==="AND"})},[e]),o=gt(r),a=y.useCallback(E=>{e.onPrimaryConditionChange(E)},[e]),h=Ct(r),m=y.useCallback(E=>{e.onConditionFormChange(E)},[e]),p=r.t("sheets-filter.panel.input-values-placeholder");function T(E,A,N){const U=d.getItemByOperator(E).numOfParameters===1;return f.jsxs(f.Fragment,{children:[N==="operator2"&&f.jsxs(L.RadioGroup,{value:l,onChange:n,children:[f.jsx(L.Radio,{value:"AND",children:r.t("sheets-filter.panel.and")}),f.jsx(L.Radio,{value:"OR",children:r.t("sheets-filter.panel.or")})]}),f.jsx(L.Select,{value:E,options:h,onChange:M=>m({[N]:M})}),U&&f.jsx("div",{children:f.jsx(L.Input,{value:A,placeholder:p,onChange:M=>m({[N==="operator1"?"val1":"val2"]:M})})})]})}return f.jsx("div",{className:I.sheetsFilterPanelConditionsContainer,children:i&&s&&f.jsxs(f.Fragment,{children:[f.jsx(L.Select,{value:i.operator,options:o,onChange:a}),d.getItemByOperator(i.operator).numOfParameters!==0?f.jsxs("div",{className:I.sheetsFilterPanelConditionsContainerInner,children:[i.numOfParameters>=1&&T(s.operator1,(_=s.val1)!=null?_:"","operator1"),i.numOfParameters>=2&&T(s.operator2,(O=s.val2)!=null?O:"","operator2"),f.jsxs("div",{className:I.sheetsFilterPanelConditionsDesc,children:[r.t("sheets-filter.panel.?"),f.jsx("br",{}),r.t("sheets-filter.panel.*")]})]}):null]})})}function gt(t){const e=t.getCurrentLocale();return y.useMemo(()=>[{options:[{label:t.t(d.NONE.label),value:d.NONE.operator}]},{options:[{label:t.t(d.EMPTY.label),value:d.EMPTY.operator},{label:t.t(d.NOT_EMPTY.label),value:d.NOT_EMPTY.operator}]},{options:[{label:t.t(d.TEXT_CONTAINS.label),value:d.TEXT_CONTAINS.operator},{label:t.t(d.DOES_NOT_CONTAIN.label),value:d.DOES_NOT_CONTAIN.operator},{label:t.t(d.STARTS_WITH.label),value:d.STARTS_WITH.operator},{label:t.t(d.ENDS_WITH.label),value:d.ENDS_WITH.operator},{label:t.t(d.EQUALS.label),value:d.EQUALS.operator}]},{options:[{label:t.t(d.GREATER_THAN.label),value:d.GREATER_THAN.operator},{label:t.t(d.GREATER_THAN_OR_EQUAL.label),value:d.GREATER_THAN_OR_EQUAL.operator},{label:t.t(d.LESS_THAN.label),value:d.LESS_THAN.operator},{label:t.t(d.LESS_THAN_OR_EQUAL.label),value:d.LESS_THAN_OR_EQUAL.operator},{label:t.t(d.EQUAL.label),value:d.EQUAL.operator},{label:t.t(d.NOT_EQUAL.label),value:d.NOT_EQUAL.operator},{label:t.t(d.BETWEEN.label),value:d.BETWEEN.operator},{label:t.t(d.NOT_BETWEEN.label),value:d.NOT_BETWEEN.operator}]},{options:[{label:t.t(d.CUSTOM.label),value:d.CUSTOM.operator}]}],[e,t])}function Ct(t){const e=t.getCurrentLocale();return y.useMemo(()=>d.ALL_CONDITIONS.filter(r=>r.numOfParameters!==2).map(r=>({label:t.t(r.label),value:r.operator})),[e,t])}function Tt(t){const{model:e}=t,r=u.useDependency(u.LocaleService),i=F.useObservable(e.searchString$,"",!0),s=F.useObservable(e.filterItems$,void 0,!0),l=r.t("sheets-filter.panel.filter-only"),n=Ee(s),o=n.checked>0&&n.unchecked===0,a=n.checked>0&&n.unchecked>0,h=e.treeMapCache,m=y.useCallback(()=>{e.onCheckAllToggled(!o)},[e,o]),p=y.useCallback(_=>{e.setSearchString(_)},[e]);function T(_){let O=[];return _.forEach(E=>{E.checked&&O.push(E.key),E.children&&(O=O.concat(T(E.children)))}),O}return f.jsxs("div",{className:I.sheetsFilterPanelValuesContainer,children:[f.jsx(L.Input,{autoFocus:!0,value:i,placeholder:r.t("sheets-filter.panel.search-placeholder"),onChange:p}),f.jsxs("div",{className:I.sheetsFilterPanelValuesList,children:[f.jsx("div",{className:I.sheetsFilterPanelValuesItem,children:f.jsxs("div",{className:I.sheetsFilterPanelValuesItemInner,children:[f.jsx(L.Checkbox,{indeterminate:a,disabled:s.length===0,checked:o,onChange:m}),f.jsx("span",{className:I.sheetsFilterPanelValuesItemText,children:`${r.t("sheets-filter.panel.select-all")}`}),f.jsx("span",{className:I.sheetsFilterPanelValuesItemCount,children:`(${n.checked}/${n.checked+n.unchecked})`})]})}),f.jsx("div",{className:I.sheetsFilterPanelValuesVirtual,children:f.jsx(L.Tree,{data:s,defaultExpandAll:!1,valueGroup:T(s),height:180,onChange:_=>{e.onFilterCheckToggled(_)},defaultCache:h,itemHeight:28,treeNodeClassName:I.sheetsFilterTreeNode,attachRender:_=>f.jsxs("div",{className:I.sheetsFilterTreeNodeAttach,children:[f.jsx("span",{className:I.sheetsFilterPanelValuesItemCount,children:`(${_.count})`}),f.jsx(L.Button,{className:I.sheetsFilterTreeNodeFilterOnly,size:"small",type:"link",onClick:()=>{const O=[];_.children?_.children.forEach(E=>{E.children?E.children.forEach(A=>{O.push(A.key)}):O.push(E.key)}):O.push(_.key),e.onFilterOnly(O)},children:l})]})})})]})]})}function Et(){var A;const t=u.useDependency(G),e=u.useDependency(u.LocaleService),r=u.useDependency(u.ICommandService),i=F.useObservable(t.filterBy$,void 0,!0),s=F.useObservable(t.filterByModel$,void 0,!1),l=F.useObservable(()=>(s==null?void 0:s.canApply$)||C.of(!1),void 0,!1,[s]),n=Ft(e),o=!F.useObservable(t.hasCriteria$),a=y.useCallback(N=>{r.executeCommand(ye.id,{filterBy:N})},[r]),h=y.useCallback(async()=>{await(s==null?void 0:s.clear()),r.executeCommand(z.id)},[s,r]),m=y.useCallback(()=>{r.executeCommand(z.id)},[r]),p=y.useCallback(async()=>{await(s==null?void 0:s.apply()),r.executeCommand(z.id)},[s,r]),_=(A=u.useDependency(c.SheetsFilterService).activeFilterModel)==null?void 0:A.getRange(),O=t.col,E=F.useComponentsOfPart($.SheetsUIPart.FILTER_PANEL_EMBED_POINT);return f.jsxs("div",{className:I.sheetsFilterPanel,children:[f.jsx(F.ComponentContainer,{components:E,sharedProps:{range:_,colIndex:O,onClose:m}}),f.jsx("div",{className:I.sheetsFilterPanelHeader,children:f.jsx(L.Segmented,{value:i,options:n,onChange:N=>a(N)})}),s?f.jsx("div",{className:I.sheetsFilterPanelContent,children:i===pe.VALUES?f.jsx(Tt,{model:s}):f.jsx(vt,{model:s})}):f.jsx("div",{style:{flex:1}}),f.jsxs("div",{className:I.sheetsFilterPanelFooter,children:[f.jsx(L.Button,{type:"link",onClick:h,disabled:o,children:e.t("sheets-filter.panel.clear-filter")}),f.jsxs("span",{className:I.sheetsFilterPanelFooterPrimaryButtons,children:[f.jsx(L.Button,{type:"default",onClick:m,children:e.t("sheets-filter.panel.cancel")}),f.jsx(L.Button,{disabled:!l,type:"primary",onClick:p,children:e.t("sheets-filter.panel.confirm")})]})]})]})}function Ft(t){const e=t.getCurrentLocale();return y.useMemo(()=>[{label:t.t("sheets-filter.panel.by-values"),value:pe.VALUES},{label:t.t("sheets-filter.panel.by-conditions"),value:pe.CONDITIONS}],[e,t])}function Ot(t){const e=t.get(c.SheetsFilterService);return{id:c.SmartToggleSheetsFilterCommand.id,type:F.MenuItemType.BUTTON_SELECTOR,icon:"FilterSingle",tooltip:"sheets-filter.toolbar.smart-toggle-filter-tooltip",hidden$:F.getMenuHiddenObservable(t,u.UniverInstanceType.UNIVER_SHEET),activated$:e.activeFilterModel$.pipe(C.map(r=>!!r)),disabled$:$.getObservableWithExclusiveRange$(t,$.getCurrentRangeDisable$(t,{worksheetTypes:[P.WorksheetFilterPermission,P.WorksheetViewPermission],rangeTypes:[P.RangeProtectionPermissionViewPoint]}))}}function Pt(t){const e=t.get(c.SheetsFilterService);return{id:c.ClearSheetsFilterCriteriaCommand.id,type:F.MenuItemType.BUTTON,title:"sheets-filter.toolbar.clear-filter-criteria",hidden$:F.getMenuHiddenObservable(t,u.UniverInstanceType.UNIVER_SHEET),disabled$:e.activeFilterModel$.pipe(C.switchMap(r=>{var i;return(i=r==null?void 0:r.hasCriteria$.pipe(C.map(s=>!s)))!=null?i:C.of(!0)}))}}function It(t){const e=t.get(c.SheetsFilterService);return{id:c.ReCalcSheetsFilterCommand.id,type:F.MenuItemType.BUTTON,title:"sheets-filter.toolbar.re-calc-filter-conditions",hidden$:F.getMenuHiddenObservable(t,u.UniverInstanceType.UNIVER_SHEET),disabled$:e.activeFilterModel$.pipe(C.switchMap(r=>{var i;return(i=r==null?void 0:r.hasCriteria$.pipe(C.map(s=>!s)))!=null?i:C.of(!0)}))}}const Nt={[F.RibbonStartGroup.FORMULAS_INSERT]:{[c.SmartToggleSheetsFilterCommand.id]:{order:10,menuItemFactory:Ot,[c.ClearSheetsFilterCriteriaCommand.id]:{order:0,menuItemFactory:Pt},[c.ReCalcSheetsFilterCommand.id]:{order:1,menuItemFactory:It}}}},yt={id:c.SmartToggleSheetsFilterCommand.id,binding:F.KeyCode.L|F.MetaKeys.CTRL_COMMAND|F.MetaKeys.SHIFT,description:"sheets-filter.shortcut.smart-toggle-filter",preconditions:$.whenSheetEditorFocused,group:"4_sheet-edit"},Y=16,Rt=new Path2D("M3.30363 3C2.79117 3 2.51457 3.60097 2.84788 3.99024L6.8 8.60593V12.5662C6.8 12.7184 6.8864 12.8575 7.02289 12.9249L8.76717 13.7863C8.96655 13.8847 9.2 13.7396 9.2 13.5173V8.60593L13.1521 3.99024C13.4854 3.60097 13.2088 3 12.6964 3H3.30363Z");class Qe{static drawNoCriteria(e,r,i,s){e.save(),ie.Rect.drawWith(e,{radius:2,width:Y,height:Y,fill:s}),e.lineCap="square",e.strokeStyle=i,e.scale(r/Y,r/Y),e.beginPath(),e.lineWidth=1,e.lineCap="round",e.moveTo(3,4),e.lineTo(13,4),e.moveTo(4.5,8),e.lineTo(11.5,8),e.moveTo(6,12),e.lineTo(10,12),e.stroke(),e.restore()}static drawHasCriteria(e,r,i,s){e.save(),ie.Rect.drawWith(e,{radius:2,width:Y,height:Y,fill:s}),e.scale(r/Y,r/Y),e.fillStyle=i,e.fill(Rt),e.restore()}}var At=Object.defineProperty,bt=Object.getOwnPropertyDescriptor,Lt=(t,e,r,i)=>{for(var s=i>1?void 0:i?bt(e,r):e,l=t.length-1,n;l>=0;l--)(n=t[l])&&(s=(i?n(e,r,s):n(s))||s);return i&&s&&At(e,r,s),s},Ae=(t,e)=>(r,i)=>e(r,i,t);const x=16,_e=1;let be=class extends ie.Shape{constructor(e,r,i,s,l){super(e,r);v(this,"_cellWidth",0);v(this,"_cellHeight",0);v(this,"_filterParams");v(this,"_hovered",!1);this._contextService=i,this._commandService=s,this._themeService=l,this.setShapeProps(r),this.onPointerDown$.subscribeEvent(n=>this.onPointerDown(n)),this.onPointerEnter$.subscribeEvent(()=>this.onPointerEnter()),this.onPointerLeave$.subscribeEvent(()=>this.onPointerLeave())}setShapeProps(e){typeof e.cellHeight<"u"&&(this._cellHeight=e.cellHeight),typeof e.cellWidth<"u"&&(this._cellWidth=e.cellWidth),typeof e.filterParams<"u"&&(this._filterParams=e.filterParams),this.transformByState({width:e.width,height:e.height})}_draw(e){const r=this._cellHeight,i=this._cellWidth,s=x-i,l=x-r;e.save();const n=new Path2D;n.rect(s,l,i,r),e.clip(n);const{hasCriteria:o}=this._filterParams,a=this._themeService.getCurrentTheme().primaryColor,h=this._hovered?this._themeService.getCurrentTheme().grey50:"rgba(255, 255, 255, 1.0)";o?Qe.drawHasCriteria(e,x,a,h):Qe.drawNoCriteria(e,x,a,h),e.restore()}onPointerDown(e){if(e.button===2)return;const{col:r,unitId:i,subUnitId:s}=this._filterParams;this._contextService.getContextValue(J)||!this._commandService.hasCommand(oe.id)||setTimeout(()=>{this._commandService.executeCommand(oe.id,{unitId:i,subUnitId:s,col:r})},200)}onPointerEnter(){this._hovered=!0,this.makeDirty(!0)}onPointerLeave(){this._hovered=!1,this.makeDirty(!0)}};be=Lt([Ae(2,u.IContextService),Ae(3,u.ICommandService),Ae(4,u.Inject(u.ThemeService))],be);var Mt=Object.defineProperty,Ut=Object.getOwnPropertyDescriptor,wt=(t,e,r,i)=>{for(var s=i>1?void 0:i?Ut(e,r):e,l=t.length-1,n;l>=0;l--)(n=t[l])&&(s=(i?n(e,r,s):n(s))||s);return i&&s&&Mt(e,r,s),s},X=(t,e)=>(r,i)=>e(r,i,t);const $t=1e3,Dt=5e3;let Le=class extends u.RxDisposable{constructor(e,r,i,s,l,n,o,a){super();v(this,"_filterRangeShape",null);v(this,"_buttonRenderDisposable",null);v(this,"_filterButtonShapes",[]);this._context=e,this._injector=r,this._sheetSkeletonManagerService=i,this._sheetsFilterService=s,this._themeService=l,this._sheetInterceptorService=n,this._commandService=o,this._selectionRenderService=a,this._initRenderer()}dispose(){super.dispose(),this._disposeRendering()}_initRenderer(){this._sheetSkeletonManagerService.currentSkeleton$.pipe(C.switchMap(e=>{var o,a;if(!e)return C.of(null);const{unit:r,unitId:i}=this._context,s=((o=r.getActiveSheet())==null?void 0:o.getSheetId())||"",l=(a=this._sheetsFilterService.getFilterModel(i,s))!=null?a:void 0,n=()=>({unitId:i,worksheetId:s,filterModel:l,range:l==null?void 0:l.getRange(),skeleton:e.skeleton});return u.fromCallback(this._commandService.onCommandExecuted.bind(this._commandService)).pipe(C.filter(([h])=>{var m;return h.type===u.CommandType.MUTATION&&((m=h.params)==null?void 0:m.unitId)===r.getUnitId()&&(c.FILTER_MUTATIONS.has(h.id)||h.id===P.SetRangeValuesMutation.id)}),C.throttleTime(20,void 0,{leading:!1,trailing:!0}),C.map(n),C.startWith(n()))}),C.takeUntil(this.dispose$)).subscribe(e=>{this._disposeRendering(),!(!e||!e.range)&&(this._renderRange(e.range,e.skeleton),this._renderButtons(e))})}_renderRange(e,r){const{scene:i}=this._context,{rowHeaderWidth:s,columnHeaderHeight:l}=r,n=this._filterRangeShape=new $.SelectionControl(i,$t,this._themeService,{rowHeaderWidth:s,columnHeaderHeight:l,enableAutoFill:!1,highlightHeader:!1}),o={range:e,primary:null,style:{fill:"rgba(0, 0, 0, 0.0)"}},a=$.attachSelectionWithCoord(o,r);n.updateRangeBySelectionWithCoord(a),n.setEvent(!1),i.makeDirty(!0)}_renderButtons(e){const{range:r,filterModel:i,unitId:s,skeleton:l,worksheetId:n}=e,{scene:o}=this._context;this._interceptCellContent(s,n,e.range);const{startColumn:a,endColumn:h,startRow:m}=r;for(let p=a;p<=h;p++){const T=`sheets-filter-button-${p}`,_=$.getCoordByCell(m,p,o,l),{startX:O,startY:E,endX:A,endY:N}=_,U=A-O,M=N-E;if(M<=_e||U<=_e)continue;const B=!!i.getFilterColumn(p),V=A-x-_e,ge=N-x-_e,Ce={left:V,top:ge,height:x,width:x,zIndex:Dt,cellHeight:M,cellWidth:U,filterParams:{unitId:s,subUnitId:n,col:p,hasCriteria:B}},w=this._injector.createInstance(be,T,Ce);this._filterButtonShapes.push(w)}o.addObjects(this._filterButtonShapes),o.makeDirty()}_interceptCellContent(e,r,i){const{startRow:s,startColumn:l,endColumn:n}=i;this._buttonRenderDisposable=this._sheetInterceptorService.intercept(P.INTERCEPTOR_POINT.CELL_CONTENT,{effect:u.InterceptorEffectEnum.Style,handler:(o,a,h)=>{const{row:m,col:p,unitId:T,subUnitId:_}=a;return T!==e||_!==r||m!==s||p<l||p>n?h(o):h({...o,fontRenderExtension:{...o==null?void 0:o.fontRenderExtension,rightOffset:x}})},priority:10})}_disposeRendering(){var e,r;(e=this._filterRangeShape)==null||e.dispose(),this._filterButtonShapes.forEach(i=>i.dispose()),(r=this._buttonRenderDisposable)==null||r.dispose(),this._filterRangeShape=null,this._buttonRenderDisposable=null,this._filterButtonShapes=[]}};Le=wt([X(1,u.Inject(u.Injector)),X(2,u.Inject($.SheetSkeletonManagerService)),X(3,u.Inject(c.SheetsFilterService)),X(4,u.Inject(u.ThemeService)),X(5,u.Inject(P.SheetInterceptorService)),X(6,u.ICommandService),X(7,$.ISheetSelectionRenderService)],Le);var Ht=Object.defineProperty,jt=Object.getOwnPropertyDescriptor,Bt=(t,e,r,i)=>{for(var s=i>1?void 0:i?jt(e,r):e,l=t.length-1,n;l>=0;l--)(n=t[l])&&(s=(i?n(e,r,s):n(s))||s);return i&&s&&Ht(e,r,s),s},Ge=(t,e)=>(r,i)=>e(r,i,t);let le=class extends u.RxDisposable{constructor(t,e){super(),this._renderManagerService=t,this._sheetsRenderService=e,[c.SetSheetsFilterRangeMutation,c.SetSheetsFilterCriteriaMutation,c.RemoveSheetsFilterMutation,c.ReCalcSheetsFilterMutation].forEach(r=>this.disposeWithMe(this._sheetsRenderService.registerSkeletonChangingMutations(r.id))),this.disposeWithMe(this._renderManagerService.registerRenderModule(u.UniverInstanceType.UNIVER_SHEET,[Le]))}};le=Bt([Ge(0,ie.IRenderManagerService),Ge(1,u.Inject($.SheetsRenderService))],le);var Vt=Object.defineProperty,Wt=Object.getOwnPropertyDescriptor,kt=(t,e,r,i)=>{for(var s=i>1?void 0:i?Wt(e,r):e,l=t.length-1,n;l>=0;l--)(n=t[l])&&(s=(i?n(e,r,s):n(s))||s);return i&&s&&Vt(e,r,s),s},D=(t,e)=>(r,i)=>e(r,i,t);const Ye="FILTER_PANEL_POPUP";let Se=class extends le{constructor(e,r,i,s,l,n,o,a,h,m,p,T,_){super(_,T);v(this,"_popupDisposable");this._injector=e,this._componentManager=r,this._sheetsFilterPanelService=i,this._sheetCanvasPopupService=s,this._sheetsFilterService=l,this._localeService=n,this._shortcutService=o,this._commandService=a,this._menuManagerService=h,this._contextService=m,this._messageService=p,this._initCommands(),this._initShortcuts(),this._initMenuItems(),this._initUI()}dispose(){super.dispose(),this._closeFilterPopup()}_initShortcuts(){[yt].forEach(e=>{this.disposeWithMe(this._shortcutService.registerShortcut(e))})}_initCommands(){[c.SmartToggleSheetsFilterCommand,c.RemoveSheetFilterCommand,c.SetSheetFilterRangeCommand,c.SetSheetsFilterCriteriaCommand,c.ClearSheetsFilterCriteriaCommand,c.ReCalcSheetsFilterCommand,ye,oe,z].forEach(e=>{this.disposeWithMe(this._commandService.registerCommand(e))})}_initMenuItems(){this._menuManagerService.mergeMenu(Nt)}_initUI(){this.disposeWithMe(this._componentManager.register(Ye,Et)),this.disposeWithMe(this._componentManager.register("FilterSingle",We)),this.disposeWithMe(this._contextService.subscribeContextValue$(J).pipe(C.distinctUntilChanged()).subscribe(e=>{e?this._openFilterPopup():this._closeFilterPopup()})),this.disposeWithMe(this._sheetsFilterService.errorMsg$.subscribe(e=>{e&&this._messageService.show({type:L.MessageType.Error,content:this._localeService.t(e)})}))}_openFilterPopup(){const e=this._sheetsFilterPanelService.filterModel;if(!e)throw new Error("[SheetsFilterUIController]: no filter model when opening filter popup!");const r=e.getRange(),i=this._sheetsFilterPanelService.col,{startRow:s}=r;this._popupDisposable=this._sheetCanvasPopupService.attachPopupToCell(s,i,{componentKey:Ye,direction:"horizontal",onClickOutside:()=>this._commandService.syncExecuteCommand(z.id),offset:[5,0]})}_closeFilterPopup(){var e;(e=this._popupDisposable)==null||e.dispose(),this._popupDisposable=null}};Se=kt([D(0,u.Inject(u.Injector)),D(1,u.Inject(F.ComponentManager)),D(2,u.Inject(G)),D(3,u.Inject($.SheetCanvasPopManagerService)),D(4,u.Inject(c.SheetsFilterService)),D(5,u.Inject(u.LocaleService)),D(6,F.IShortcutService),D(7,u.ICommandService),D(8,F.IMenuManagerService),D(9,u.IContextService),D(10,F.IMessageService),D(11,u.Inject($.SheetsRenderService)),D(12,ie.IRenderManagerService)],Se);var Ke=Object.defineProperty,xt=Object.getOwnPropertyDescriptor,Qt=(t,e,r)=>e in t?Ke(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Gt=(t,e,r,i)=>{for(var s=i>1?void 0:i?xt(e,r):e,l=t.length-1,n;l>=0;l--)(n=t[l])&&(s=(i?n(e,r,s):n(s))||s);return i&&s&&Ke(e,r,s),s},Me=(t,e)=>(r,i)=>e(r,i,t),Xe=(t,e,r)=>Qt(t,typeof e!="symbol"?e+"":e,r);const Yt="SHEET_FILTER_UI_PLUGIN";S.UniverSheetsFilterUIPlugin=class extends u.Plugin{constructor(e=ce,r,i,s){super(),this._config=e,this._injector=r,this._configService=i,this._rpcChannelService=s;const{menu:l,...n}=u.merge({},ce,this._config);l&&this._configService.setConfig("menu",l,{merge:!0}),this._configService.setConfig($e,n)}onStarting(){[[G],[te],[Se]].forEach(e=>this._injector.add(e)),this._config.useRemoteFilterValuesGenerator&&this._rpcChannelService&&this._injector.add([he,{useFactory:()=>k.toModule(this._rpcChannelService.requestChannel(Oe))}])}onReady(){this._injector.get(te)}onRendered(){this._injector.get(Se)}},Xe(S.UniverSheetsFilterUIPlugin,"type",u.UniverInstanceType.UNIVER_SHEET),Xe(S.UniverSheetsFilterUIPlugin,"pluginName",Yt),S.UniverSheetsFilterUIPlugin=Gt([u.DependentOn(c.UniverSheetsFilterPlugin),Me(1,u.Inject(u.Injector)),Me(2,u.IConfigService),Me(3,u.Optional(k.IRPCChannelService))],S.UniverSheetsFilterUIPlugin);var qe=Object.defineProperty,Kt=Object.getOwnPropertyDescriptor,Xt=(t,e,r)=>e in t?qe(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,qt=(t,e,r,i)=>{for(var s=i>1?void 0:i?Kt(e,r):e,l=t.length-1,n;l>=0;l--)(n=t[l])&&(s=(i?n(e,r,s):n(s))||s);return i&&s&&qe(e,r,s),s},Ze=(t,e)=>(r,i)=>e(r,i,t),Je=(t,e,r)=>Xt(t,typeof e!="symbol"?e+"":e,r);const Zt="SHEET_FILTER_UI_PLUGIN";S.UniverSheetsFilterMobileUIPlugin=class extends u.Plugin{constructor(e=ce,r,i){super(),this._config=e,this._injector=r,this._configService=i;const{menu:s,...l}=u.merge({},ce,this._config);s&&this._configService.setConfig("menu",s,{merge:!0}),this._configService.setConfig($e,l)}onStarting(){[[te],[le]].forEach(e=>this._injector.add(e))}onReady(){this._injector.get(te)}onRendered(){this._injector.get(le)}},Je(S.UniverSheetsFilterMobileUIPlugin,"type",u.UniverInstanceType.UNIVER_SHEET),Je(S.UniverSheetsFilterMobileUIPlugin,"pluginName",Zt),S.UniverSheetsFilterMobileUIPlugin=qt([u.DependentOn(c.UniverSheetsFilterPlugin),Ze(1,u.Inject(u.Injector)),Ze(2,u.IConfigService)],S.UniverSheetsFilterMobileUIPlugin);var Jt=Object.defineProperty,zt=Object.getOwnPropertyDescriptor,er=(t,e,r,i)=>{for(var s=i>1?void 0:i?zt(e,r):e,l=t.length-1,n;l>=0;l--)(n=t[l])&&(s=(i?n(e,r,s):n(s))||s);return i&&s&&Jt(e,r,s),s},ze=(t,e)=>(r,i)=>e(r,i,t);S.UniverSheetsFilterUIWorkerPlugin=(ve=class extends u.Plugin{constructor(e,r,i){super(),this._config=e,this._injector=r,this._rpcChannelService=i}onStarting(){[[he,{useClass:Pe}]].forEach(e=>this._injector.add(e))}onReady(){this._rpcChannelService.registerChannel(Oe,k.fromModule(this._injector.get(he)))}},v(ve,"type",u.UniverInstanceType.UNIVER_SHEET),v(ve,"pluginName","SHEET_FILTER_UI_WORKER_PLUGIN"),ve),S.UniverSheetsFilterUIWorkerPlugin=er([ze(1,u.Inject(u.Injector)),ze(2,k.IRPCChannelService)],S.UniverSheetsFilterUIWorkerPlugin),S.ChangeFilterByOperation=ye,S.CloseFilterPanelOperation=z,S.OpenFilterPanelOperation=oe,Object.defineProperty(S,Symbol.toStringTag,{value:"Module"})});
19
19
 
20
20
 
21
21
  // index
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@univerjs/preset-sheets-filter",
3
- "version": "0.5.3",
3
+ "version": "0.5.5",
4
4
  "private": false,
5
5
  "description": "",
6
6
  "author": "DreamNum <developer@univer.ai>",
@@ -57,17 +57,18 @@
57
57
  "rxjs": ">=7.0.0"
58
58
  },
59
59
  "dependencies": {
60
- "@univerjs/sheets-filter": "0.5.3",
61
- "@univerjs/sheets-filter-ui": "0.5.3"
60
+ "@univerjs/sheets-filter": "0.5.5",
61
+ "@univerjs/sheets-filter-ui": "0.5.5"
62
62
  },
63
63
  "devDependencies": {
64
- "@univerjs/core": "0.5.3",
64
+ "@univerjs/core": "0.5.5",
65
65
  "typescript": "^5.7.2",
66
- "@univerjs-infra/shared": "0.5.3"
66
+ "@univerjs-infra/shared": "0.5.5"
67
67
  },
68
68
  "scripts": {
69
69
  "prebuild:preset": "tsx prepare.ts",
70
- "build:preset": "tsx build.ts"
70
+ "build:preset": "tsx build.ts",
71
+ "lint:types": "tsc --noEmit"
71
72
  },
72
73
  "module": "./lib/es/index.js"
73
74
  }