@univerjs/sheets-filter-ui 0.9.1 → 0.9.2-nightly.202507111607

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.
Files changed (44) hide show
  1. package/lib/cjs/index.js +2 -2
  2. package/lib/cjs/locale/en-US.js +1 -1
  3. package/lib/cjs/locale/fa-IR.js +1 -1
  4. package/lib/cjs/locale/fr-FR.js +1 -1
  5. package/lib/cjs/locale/ko-KR.js +1 -1
  6. package/lib/cjs/locale/ru-RU.js +1 -1
  7. package/lib/cjs/locale/vi-VN.js +1 -1
  8. package/lib/cjs/locale/zh-CN.js +1 -1
  9. package/lib/cjs/locale/zh-TW.js +1 -1
  10. package/lib/es/index.js +1121 -815
  11. package/lib/es/locale/en-US.js +4 -0
  12. package/lib/es/locale/fa-IR.js +4 -0
  13. package/lib/es/locale/fr-FR.js +4 -0
  14. package/lib/es/locale/ko-KR.js +4 -0
  15. package/lib/es/locale/ru-RU.js +4 -0
  16. package/lib/es/locale/vi-VN.js +4 -0
  17. package/lib/es/locale/zh-CN.js +4 -0
  18. package/lib/es/locale/zh-TW.js +4 -0
  19. package/lib/index.css +1 -1
  20. package/lib/index.js +1121 -815
  21. package/lib/locale/en-US.js +4 -0
  22. package/lib/locale/fa-IR.js +4 -0
  23. package/lib/locale/fr-FR.js +4 -0
  24. package/lib/locale/ko-KR.js +4 -0
  25. package/lib/locale/ru-RU.js +4 -0
  26. package/lib/locale/vi-VN.js +4 -0
  27. package/lib/locale/zh-CN.js +4 -0
  28. package/lib/locale/zh-TW.js +4 -0
  29. package/lib/types/commands/operations/sheets-filter.operation.d.ts +1 -1
  30. package/lib/types/locale/en-US.d.ts +4 -0
  31. package/lib/types/services/sheets-filter-panel.service.d.ts +51 -5
  32. package/lib/types/views/components/SheetsFilterByColorsPanel.d.ts +7 -0
  33. package/lib/types/worker/generate-filter-values.service.d.ts +5 -2
  34. package/lib/umd/index.js +2 -2
  35. package/lib/umd/locale/en-US.js +1 -1
  36. package/lib/umd/locale/fa-IR.js +1 -1
  37. package/lib/umd/locale/fr-FR.js +1 -1
  38. package/lib/umd/locale/ko-KR.js +1 -1
  39. package/lib/umd/locale/ru-RU.js +1 -1
  40. package/lib/umd/locale/vi-VN.js +1 -1
  41. package/lib/umd/locale/zh-CN.js +1 -1
  42. package/lib/umd/locale/zh-TW.js +1 -1
  43. package/package.json +12 -12
  44. package/LICENSE +0 -176
@@ -16,6 +16,10 @@ const e = {
16
16
  cancel: "Cancel",
17
17
  confirm: "Confirm",
18
18
  "by-values": "By Values",
19
+ "by-colors": "By Colors",
20
+ "filter-by-cell-fill-color": "Filter by cell fill color",
21
+ "filter-by-cell-text-color": "Filter by cell text color",
22
+ "filter-by-color-none": "The column contains only one color",
19
23
  "by-conditions": "By Conditions",
20
24
  "filter-only": "Filter Only",
21
25
  "search-placeholder": "Use space to separate keywords",
@@ -16,6 +16,10 @@ const e = {
16
16
  cancel: "انصراف",
17
17
  confirm: "تایید",
18
18
  "by-values": "بر اساس مقادیر",
19
+ "by-colors": "بر اساس رنگ‌ها",
20
+ "filter-by-cell-fill-color": "فیلتر بر اساس رنگ پر کردن سلول",
21
+ "filter-by-cell-text-color": "فیلتر بر اساس رنگ متن سلول",
22
+ "filter-by-color-none": "این ستون فقط شامل یک رنگ است",
19
23
  "by-conditions": "بر اساس شرایط",
20
24
  "filter-only": "فقط فیلتر",
21
25
  "search-placeholder": "برای جداسازی کلیدواژه‌ها از فاصله استفاده کنید",
@@ -16,6 +16,10 @@ const e = {
16
16
  cancel: "Annuler",
17
17
  confirm: "Confirmer",
18
18
  "by-values": "Par valeurs",
19
+ "by-colors": "Par couleurs",
20
+ "filter-by-cell-fill-color": "Filtrer par couleur de remplissage de cellule",
21
+ "filter-by-cell-text-color": "Filtrer par couleur de texte de cellule",
22
+ "filter-by-color-none": "Cette colonne ne contient qu'une seule couleur",
19
23
  "by-conditions": "Par conditions",
20
24
  "filter-only": "Filtrer uniquement",
21
25
  "search-placeholder": "Utilisez un espace pour séparer les mots-clés",
@@ -16,6 +16,10 @@ const e = {
16
16
  cancel: "취소",
17
17
  confirm: "확인",
18
18
  "by-values": "값으로 필터",
19
+ "by-colors": "색상으로 필터",
20
+ "filter-by-cell-fill-color": "셀 채우기 색상으로 필터",
21
+ "filter-by-cell-text-color": "셀 텍스트 색상으로 필터",
22
+ "filter-by-color-none": "이 열은 단일 색상만 포함합니다",
19
23
  "by-conditions": "조건으로 필터",
20
24
  "filter-only": "필터만 보기",
21
25
  "search-placeholder": "검색어는 공백으로 구분",
@@ -16,6 +16,10 @@ const e = {
16
16
  cancel: "Отмена",
17
17
  confirm: "Подтвердить",
18
18
  "by-values": "По значениям",
19
+ "by-colors": "По цветам",
20
+ "filter-by-cell-fill-color": "Фильтр по цвету заливки ячейки",
21
+ "filter-by-cell-text-color": "Фильтр по цвету текста ячейки",
22
+ "filter-by-color-none": "Этот столбец содержит только один цвет",
19
23
  "by-conditions": "По условиям",
20
24
  "filter-only": "Только фильтр",
21
25
  "search-placeholder": "Используйте пробел для разделения ключевых слов",
@@ -16,6 +16,10 @@ const n = {
16
16
  cancel: "Hủy bỏ",
17
17
  confirm: "Xác nhận",
18
18
  "by-values": "Theo giá trị",
19
+ "by-colors": "Theo màu sắc",
20
+ "filter-by-cell-fill-color": "Lọc theo màu nền ô",
21
+ "filter-by-cell-text-color": "Lọc theo màu chữ ô",
22
+ "filter-by-color-none": "Cột này chỉ chứa một màu",
19
23
  "by-conditions": "Theo điều kiện",
20
24
  "filter-only": "Chỉ lọc",
21
25
  "search-placeholder": "Sử dụng khoảng trắng để tách các từ khóa",
@@ -16,6 +16,10 @@ const e = {
16
16
  cancel: "取消",
17
17
  confirm: "确认",
18
18
  "by-values": "按值",
19
+ "by-colors": "按颜色",
20
+ "filter-by-cell-fill-color": "按单元格填充颜色筛选",
21
+ "filter-by-cell-text-color": "按单元格文本颜色筛选",
22
+ "filter-by-color-none": "该列仅包含一种颜色",
19
23
  "by-conditions": "按条件",
20
24
  "filter-only": "仅筛选",
21
25
  "search-placeholder": "使用空格分隔关键字",
@@ -16,6 +16,10 @@ const e = {
16
16
  cancel: "取消",
17
17
  confirm: "確認",
18
18
  "by-values": "按值",
19
+ "by-colors": "按顏色",
20
+ "filter-by-cell-fill-color": "按單元格填充顏色篩選",
21
+ "filter-by-cell-text-color": "按單元格文本顏色篩選",
22
+ "filter-by-color-none": "該列僅包含一種顏色",
19
23
  "by-conditions": "按條件",
20
24
  "filter-only": "僅篩選",
21
25
  "search-placeholder": "使用空格分隔關鍵字",
@@ -1,5 +1,5 @@
1
1
  import { IOperation } from '@univerjs/core';
2
- import { FilterBy } from '../../services/sheets-filter-panel.service';
2
+ import { FilterBy } from '@univerjs/sheets-filter';
3
3
  export declare const FILTER_PANEL_OPENED_KEY = "FILTER_PANEL_OPENED";
4
4
  export interface IOpenFilterPanelOperationParams {
5
5
  unitId: string;
@@ -31,6 +31,10 @@ declare const locale: {
31
31
  cancel: string;
32
32
  confirm: string;
33
33
  'by-values': string;
34
+ 'by-colors': string;
35
+ 'filter-by-cell-fill-color': string;
36
+ 'filter-by-cell-text-color': string;
37
+ 'filter-by-color-none': string;
34
38
  'by-conditions': string;
35
39
  'filter-only': string;
36
40
  'search-placeholder': string;
@@ -1,12 +1,8 @@
1
1
  import { IDisposable, Nullable, Disposable, ICommandService, Injector } from '@univerjs/core';
2
- import { FilterColumn, FilterModel } from '@univerjs/sheets-filter';
2
+ import { FilterColumn, FilterModel, FilterBy } from '@univerjs/sheets-filter';
3
3
  import { Observable } from 'rxjs';
4
4
  import { FilterOperator, IFilterConditionFormParams, IFilterConditionItem } from '../models/conditions';
5
5
  import { RefRangeService } from '@univerjs/sheets';
6
- export declare enum FilterBy {
7
- VALUES = 0,
8
- CONDITIONS = 1
9
- }
10
6
  export interface IFilterByValueItem {
11
7
  value: string;
12
8
  checked: boolean;
@@ -26,6 +22,10 @@ export interface IFilterByValueWithTreeItem {
26
22
  originValues?: Set<string>;
27
23
  children?: IFilterByValueWithTreeItem[];
28
24
  }
25
+ export interface IFilterByColorItem {
26
+ color: string | null;
27
+ checked?: boolean;
28
+ }
29
29
  export interface ISheetsFilterPanelService {
30
30
  /**
31
31
  * Set up the panel to change the filter condition on a specific column.
@@ -77,6 +77,7 @@ export declare class SheetsFilterPanelService extends Disposable {
77
77
  private _disposeFilterHeaderChangeListener;
78
78
  private _listenToFilterHeaderChange;
79
79
  private _setupByValues;
80
+ private _setupByColors;
80
81
  private _setupByConditions;
81
82
  private _disposePreviousModel;
82
83
  }
@@ -191,3 +192,48 @@ export declare class ByValuesModel extends Disposable implements IFilterByModel
191
192
  */
192
193
  apply(): Promise<boolean>;
193
194
  }
195
+ /**
196
+ * This model would be used to control the "Filter By Colors" panel. It should be reconstructed in the following
197
+ * situations:
198
+ *
199
+ * 1. The target `FilterColumn` object is changed
200
+ * 2. User toggles "Filter By"
201
+ */
202
+ export declare class ByColorsModel extends Disposable implements IFilterByModel {
203
+ private readonly _filterModel;
204
+ col: number;
205
+ private readonly _commandService;
206
+ /**
207
+ * Create a model with targeting filter column. If there is not a filter column, the model would be created with
208
+ * default values.
209
+ *
210
+ * @param injector
211
+ * @param filterModel
212
+ * @param col
213
+ *
214
+ * @returns the model to control the panel's state
215
+ */
216
+ static fromFilterColumn(injector: Injector, filterModel: FilterModel, col: number): Promise<ByColorsModel>;
217
+ canApply$: Observable<boolean>;
218
+ private readonly _cellFillColors$;
219
+ readonly cellFillColors$: Observable<IFilterByColorItem[]>;
220
+ get cellFillColors(): IFilterByColorItem[];
221
+ private readonly _cellTextColors$;
222
+ readonly cellTextColors$: Observable<IFilterByColorItem[]>;
223
+ get cellTextColors(): IFilterByColorItem[];
224
+ constructor(_filterModel: FilterModel, col: number,
225
+ /**
226
+ * Filter items would remain unchanged after we create them,
227
+ * though data may change after.
228
+ */
229
+ cellFillColors: Map<string, IFilterByColorItem>, cellTextColors: Map<string, IFilterByColorItem>, _commandService: ICommandService);
230
+ dispose(): void;
231
+ deltaCol(offset: number): void;
232
+ clear(): Promise<boolean>;
233
+ onFilterCheckToggled(item: IFilterByColorItem, isFillColor?: boolean): void;
234
+ private _resetColorsCheckedStatus;
235
+ /**
236
+ * Apply the filter condition to the target filter column.
237
+ */
238
+ apply(): Promise<boolean>;
239
+ }
@@ -0,0 +1,7 @@
1
+ import { ByColorsModel } from '../../services/sheets-filter-panel.service';
2
+ /**
3
+ * Filter by colors.
4
+ */
5
+ export declare function FilterByColor(props: {
6
+ model: ByColorsModel;
7
+ }): import("react/jsx-runtime").JSX.Element;
@@ -1,10 +1,12 @@
1
- import { IRange, Styles, Worksheet, Disposable, ILogService, IUniverInstanceService, LocaleService } from '@univerjs/core';
1
+ import { IRange, Nullable, Styles, Worksheet, Disposable, ILogService, IUniverInstanceService, LocaleService } from '@univerjs/core';
2
+ import { FilterColumn } from '@univerjs/sheets-filter';
2
3
  import { IFilterByValueItem, IFilterByValueWithTreeItem } from '../services/sheets-filter-panel.service';
3
4
  export interface ISheetsGenerateFilterValuesService {
4
5
  getFilterValues(params: {
5
6
  unitId: string;
6
7
  subUnitId: string;
7
8
  filteredOutRowsByOtherColumns: number[];
9
+ filterColumn: Nullable<FilterColumn>;
8
10
  filters: boolean;
9
11
  blankChecked: boolean;
10
12
  iterateRange: IRange;
@@ -25,6 +27,7 @@ export declare class SheetsGenerateFilterValuesService extends Disposable {
25
27
  unitId: string;
26
28
  subUnitId: string;
27
29
  filteredOutRowsByOtherColumns: number[];
30
+ filterColumn: Nullable<FilterColumn>;
28
31
  filters: boolean;
29
32
  blankChecked: boolean;
30
33
  iterateRange: IRange;
@@ -35,7 +38,7 @@ export declare class SheetsGenerateFilterValuesService extends Disposable {
35
38
  }>;
36
39
  }
37
40
  export declare function getFilterByValueItems(filters: boolean, blankChecked: boolean, localeService: LocaleService, iterateRange: IRange, worksheet: Worksheet, alreadyChecked: Set<string>, filteredOutRowsByOtherColumns: Set<number>): IFilterByValueItem[];
38
- export declare function getFilterTreeByValueItems(filters: boolean, localeService: LocaleService, iterateRange: IRange, worksheet: Worksheet, filteredOutRowsByOtherColumns: Set<number>, alreadyChecked: Set<string>, blankChecked: boolean, styles: Styles): {
41
+ export declare function getFilterTreeByValueItems(filters: boolean, localeService: LocaleService, iterateRange: IRange, worksheet: Worksheet, filteredOutRowsByOtherColumns: Set<number>, filterColumn: Nullable<FilterColumn>, alreadyChecked: Set<string>, blankChecked: boolean, styles: Styles): {
39
42
  filterTreeItems: IFilterByValueWithTreeItem[];
40
43
  filterTreeMapCache: Map<string, string[]>;
41
44
  };
package/lib/umd/index.js CHANGED
@@ -1,7 +1,7 @@
1
- (function(v,c){typeof exports=="object"&&typeof module<"u"?c(exports,require("@univerjs/core"),require("@univerjs/sheets-filter"),require("@univerjs/ui"),require("@univerjs/sheets-ui"),require("@univerjs/sheets"),require("rxjs"),require("@univerjs/engine-render"),require("@univerjs/rpc"),require("@univerjs/design"),require("react/jsx-runtime"),require("react")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/sheets-filter","@univerjs/ui","@univerjs/sheets-ui","@univerjs/sheets","rxjs","@univerjs/engine-render","@univerjs/rpc","@univerjs/design","react/jsx-runtime","react"],c):(v=typeof globalThis<"u"?globalThis:v||self,c(v.UniverSheetsFilterUi={},v.UniverCore,v.UniverSheetsFilter,v.UniverUi,v.UniverSheetsUi,v.UniverSheets,v.rxjs,v.UniverEngineRender,v.UniverRpc,v.UniverDesign,v.React,v.React))})(this,function(v,c,u,T,U,N,C,re,ae,y,d,b){"use strict";var jt=Object.defineProperty;var Gt=(v,c,u)=>c in v?jt(v,c,{enumerable:!0,configurable:!0,writable:!0,value:u}):v[c]=u;var S=(v,c,u)=>Gt(v,typeof c!="symbol"?c+"":c,u);var ve;var P=(t=>(t[t.FIRST=0]="FIRST",t[t.SECOND=1]="SECOND",t))(P||{}),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||{}),p;(t=>{t.NONE={label:"sheets-filter.conditions.none",operator:g.NONE,order:P.SECOND,numOfParameters:0,getDefaultFormParams:()=>{throw new Error("[FilterConditionItems.NONE]: should not have initial form params!")},testMappingParams:i=>i.operator1===g.NONE,mapToFilterColumn:()=>null,testMappingFilterColumn:i=>!i.customFilters&&!i.filters?{}:!1},t.EMPTY={label:"sheets-filter.conditions.empty",operator:g.EMPTY,order:P.SECOND,numOfParameters:0,getDefaultFormParams:()=>{throw new Error("[FilterConditionItems.EMPTY]: should not have initial form params!")},testMappingParams:({operator1:i})=>i===g.EMPTY,mapToFilterColumn:()=>({customFilters:{customFilters:[{val:""}]}}),testMappingFilterColumn:i=>{var m;if(((m=i.customFilters)==null?void 0:m.customFilters.length)!==1)return!1;const s=i.customFilters.customFilters[0];return s.val===""&&s.operator===void 0?{operator1:g.EMPTY}:!1}},t.NOT_EMPTY={label:"sheets-filter.conditions.not-empty",operator:g.NOT_EMPTY,order:P.SECOND,numOfParameters:0,getDefaultFormParams:()=>{throw new Error("[FilterConditionItems.NOT_EMPTY]: should not have initial form params!")},testMappingParams:({operator1:i})=>i===g.NOT_EMPTY,mapToFilterColumn:()=>({customFilters:{customFilters:[{val:"",operator:u.CustomFilterOperator.NOT_EQUALS}]}}),testMappingFilterColumn:i=>{var m;if(((m=i.customFilters)==null?void 0:m.customFilters.length)!==1)return!1;const s=i.customFilters.customFilters[0];return s.val===" "&&s.operator===u.CustomFilterOperator.NOT_EQUALS?{operator1:g.NOT_EMPTY}:!1}},t.TEXT_CONTAINS={label:"sheets-filter.conditions.text-contains",operator:g.CONTAINS,order:P.FIRST,numOfParameters:1,getDefaultFormParams:()=>({operator1:g.CONTAINS,val1:""}),testMappingParams:i=>{const[s]=k(i);return s===g.CONTAINS},mapToFilterColumn:i=>{const{val1:s}=i;return s===""?null:{customFilters:{customFilters:[{val:`*${s}*`}]}}},testMappingFilterColumn:i=>{var m;if(((m=i.customFilters)==null?void 0:m.customFilters.length)!==1)return!1;const s=i.customFilters.customFilters[0],a=s.val.toString();return!s.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:P.FIRST,numOfParameters:1,getDefaultFormParams:()=>({operator1:g.DOES_NOT_CONTAIN,val1:""}),mapToFilterColumn:i=>({customFilters:{customFilters:[{val:`*${i.val1}*`,operator:u.CustomFilterOperator.NOT_EQUALS}]}}),testMappingParams:i=>{const[s]=k(i);return s===g.DOES_NOT_CONTAIN},testMappingFilterColumn:i=>{var m;if(((m=i.customFilters)==null?void 0:m.customFilters.length)!==1)return!1;const s=i.customFilters.customFilters[0],a=s.val.toString();return s.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:P.FIRST,numOfParameters:1,getDefaultFormParams:()=>({operator1:g.STARTS_WITH,val1:""}),mapToFilterColumn:i=>({customFilters:{customFilters:[{val:`${i.val1}*`}]}}),testMappingParams:i=>{const[s]=k(i);return s===g.STARTS_WITH},testMappingFilterColumn:i=>{var m;if(((m=i.customFilters)==null?void 0:m.customFilters.length)!==1)return!1;const s=i.customFilters.customFilters[0],a=s.val.toString();return!s.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:P.FIRST,numOfParameters:1,getDefaultFormParams:()=>({operator1:g.ENDS_WITH,val1:""}),mapToFilterColumn:i=>({customFilters:{customFilters:[{val:`*${i.val1}`}]}}),testMappingParams:i=>{const[s]=k(i);return s===g.ENDS_WITH},testMappingFilterColumn:i=>{var m;if(((m=i.customFilters)==null?void 0:m.customFilters.length)!==1)return!1;const s=i.customFilters.customFilters[0],a=s.val.toString();return!s.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:P.FIRST,numOfParameters:1,getDefaultFormParams:()=>({operator1:g.EQUALS,val1:""}),testMappingParams:i=>{const[s]=k(i);return s===g.EQUALS},mapToFilterColumn:i=>{const{val1:s}=i;return s===""?null:{customFilters:{customFilters:[{val:s}]}}},testMappingFilterColumn:i=>{var s,a,m;return((a=(s=i.filters)==null?void 0:s.filters)==null?void 0:a.length)===1?{operator1:g.EQUALS,val1:""}:((m=i.customFilters)==null?void 0:m.customFilters.length)===1&&!i.customFilters.customFilters[0].operator?{operator1:g.EQUALS,val1:i.customFilters.customFilters[0].val.toString()}:!1}},t.GREATER_THAN={label:"sheets-filter.conditions.greater-than",operator:u.CustomFilterOperator.GREATER_THAN,numOfParameters:1,order:P.FIRST,getDefaultFormParams:()=>({operator1:u.CustomFilterOperator.GREATER_THAN,val1:""}),mapToFilterColumn:i=>({customFilters:{customFilters:[{val:i.val1,operator:u.CustomFilterOperator.GREATER_THAN}]}}),testMappingParams:i=>{const[s]=k(i);return s===u.CustomFilterOperator.GREATER_THAN},testMappingFilterColumn:i=>{var a;if(((a=i.customFilters)==null?void 0:a.customFilters.length)!==1)return!1;const s=i.customFilters.customFilters[0];return s.operator!==u.CustomFilterOperator.GREATER_THAN?!1:{operator1:u.CustomFilterOperator.GREATER_THAN,val1:s.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:P.FIRST,getDefaultFormParams:()=>({operator1:u.CustomFilterOperator.GREATER_THAN_OR_EQUAL,val1:""}),testMappingParams:i=>{const[s]=k(i);return s===u.CustomFilterOperator.GREATER_THAN_OR_EQUAL},mapToFilterColumn:i=>({customFilters:{customFilters:[{val:i.val1,operator:u.CustomFilterOperator.GREATER_THAN_OR_EQUAL}]}}),testMappingFilterColumn:i=>{var a;if(((a=i.customFilters)==null?void 0:a.customFilters.length)!==1)return!1;const s=i.customFilters.customFilters[0];return s.operator!==u.CustomFilterOperator.GREATER_THAN_OR_EQUAL?!1:{operator1:u.CustomFilterOperator.GREATER_THAN_OR_EQUAL,val1:s.val.toString()}}},t.LESS_THAN={label:"sheets-filter.conditions.less-than",operator:u.CustomFilterOperator.LESS_THAN,numOfParameters:1,order:P.FIRST,getDefaultFormParams:()=>({operator1:u.CustomFilterOperator.LESS_THAN,val1:""}),testMappingParams:i=>{const[s]=k(i);return s===u.CustomFilterOperator.LESS_THAN},mapToFilterColumn:i=>({customFilters:{customFilters:[{val:i.val1,operator:u.CustomFilterOperator.LESS_THAN}]}}),testMappingFilterColumn:i=>{var a;if(((a=i.customFilters)==null?void 0:a.customFilters.length)!==1)return!1;const s=i.customFilters.customFilters[0];return s.operator!==u.CustomFilterOperator.LESS_THAN?!1:{operator1:u.CustomFilterOperator.LESS_THAN,val1:s.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:P.FIRST,getDefaultFormParams:()=>({operator1:u.CustomFilterOperator.LESS_THAN_OR_EQUAL,val1:""}),testMappingParams:i=>{const[s]=k(i);return s===u.CustomFilterOperator.LESS_THAN_OR_EQUAL},mapToFilterColumn:i=>({customFilters:{customFilters:[{val:i.val1,operator:u.CustomFilterOperator.LESS_THAN_OR_EQUAL}]}}),testMappingFilterColumn:i=>{var a;if(((a=i.customFilters)==null?void 0:a.customFilters.length)!==1)return!1;const s=i.customFilters.customFilters[0];return s.operator!==u.CustomFilterOperator.LESS_THAN_OR_EQUAL?!1:{operator1:u.CustomFilterOperator.LESS_THAN_OR_EQUAL,val1:s.val.toString()}}},t.EQUAL={label:"sheets-filter.conditions.equal",operator:u.CustomFilterOperator.EQUAL,numOfParameters:1,order:P.FIRST,getDefaultFormParams:()=>({operator1:u.CustomFilterOperator.EQUAL,val1:""}),testMappingParams:i=>{const[s]=k(i);return s===u.CustomFilterOperator.EQUAL},mapToFilterColumn:i=>({customFilters:{customFilters:[{val:i.val1,operator:u.CustomFilterOperator.EQUAL}]}}),testMappingFilterColumn:i=>{var a;if(((a=i.customFilters)==null?void 0:a.customFilters.length)!==1)return!1;const s=i.customFilters.customFilters[0];return s.operator!==u.CustomFilterOperator.EQUAL?!1:{operator1:u.CustomFilterOperator.EQUAL,val1:s.val.toString()}}},t.NOT_EQUAL={label:"sheets-filter.conditions.not-equal",operator:u.CustomFilterOperator.NOT_EQUALS,numOfParameters:1,order:P.FIRST,getDefaultFormParams:()=>({operator1:u.CustomFilterOperator.NOT_EQUALS,val1:""}),testMappingParams:i=>{const[s]=k(i);return s===u.CustomFilterOperator.NOT_EQUALS},mapToFilterColumn:i=>({customFilters:{customFilters:[{val:i.val1,operator:u.CustomFilterOperator.NOT_EQUALS}]}}),testMappingFilterColumn:i=>{var a;if(((a=i.customFilters)==null?void 0:a.customFilters.length)!==1)return!1;const s=i.customFilters.customFilters[0];return s.operator!==u.CustomFilterOperator.NOT_EQUALS?!1:{operator1:u.CustomFilterOperator.NOT_EQUALS,val1:s.val.toString()}}},t.BETWEEN={label:"sheets-filter.conditions.between",operator:g.BETWEEN,order:P.SECOND,numOfParameters:2,getDefaultFormParams:()=>({and:!0,operator1:u.CustomFilterOperator.GREATER_THAN_OR_EQUAL,val1:"",operator2:u.CustomFilterOperator.LESS_THAN_OR_EQUAL,val2:""}),testMappingParams:i=>{const{and:s,operator1:a,operator2:m}=i;if(!s)return!1;const h=[a,m];return h.includes(u.CustomFilterOperator.GREATER_THAN_OR_EQUAL)&&h.includes(u.CustomFilterOperator.LESS_THAN_OR_EQUAL)},mapToFilterColumn:i=>{const{val1:s,val2:a,operator1:m}=i,h=m===u.CustomFilterOperator.GREATER_THAN_OR_EQUAL;return{customFilters:{and:c.BooleanNumber.TRUE,customFilters:[{val:h?s:a,operator:u.CustomFilterOperator.GREATER_THAN_OR_EQUAL},{val:h?a:s,operator:u.CustomFilterOperator.LESS_THAN_OR_EQUAL}]}}},testMappingFilterColumn:i=>{var m;if(((m=i.customFilters)==null?void 0:m.customFilters.length)!==2)return!1;const[s,a]=i.customFilters.customFilters;return s.operator===u.CustomFilterOperator.GREATER_THAN_OR_EQUAL&&a.operator===u.CustomFilterOperator.LESS_THAN_OR_EQUAL&&i.customFilters.and?{and:!0,operator1:u.CustomFilterOperator.GREATER_THAN_OR_EQUAL,val1:s.val.toString(),operator2:u.CustomFilterOperator.LESS_THAN_OR_EQUAL,val2:a.val.toString()}:a.operator===u.CustomFilterOperator.GREATER_THAN_OR_EQUAL&&s.operator===u.CustomFilterOperator.LESS_THAN_OR_EQUAL&&i.customFilters.and?{and:!0,operator1:u.CustomFilterOperator.GREATER_THAN_OR_EQUAL,val1:a.val.toString(),operator2:u.CustomFilterOperator.LESS_THAN_OR_EQUAL,val2:s.val.toLocaleString()}:!1}},t.NOT_BETWEEN={label:"sheets-filter.conditions.not-between",operator:g.NOT_BETWEEN,order:P.SECOND,numOfParameters:2,getDefaultFormParams:()=>({operator1:u.CustomFilterOperator.LESS_THAN,val1:"",operator2:u.CustomFilterOperator.GREATER_THAN,val2:""}),testMappingParams:i=>{const{and:s,operator1:a,operator2:m}=i;if(s)return!1;const h=[a,m];return h.includes(u.CustomFilterOperator.GREATER_THAN)&&h.includes(u.CustomFilterOperator.LESS_THAN)},mapToFilterColumn:i=>{const{val1:s,val2:a,operator1:m}=i,h=m===u.CustomFilterOperator.GREATER_THAN;return{customFilters:{customFilters:[{val:h?s:a,operator:u.CustomFilterOperator.GREATER_THAN},{val:h?a:s,operator:u.CustomFilterOperator.LESS_THAN}]}}},testMappingFilterColumn:i=>{var m;if(((m=i.customFilters)==null?void 0:m.customFilters.length)!==2)return!1;const[s,a]=i.customFilters.customFilters;return s.operator===u.CustomFilterOperator.LESS_THAN&&a.operator===u.CustomFilterOperator.GREATER_THAN&&!i.customFilters.and?{operator1:u.CustomFilterOperator.LESS_THAN,val1:s.val.toString(),operator2:u.CustomFilterOperator.GREATER_THAN,val2:a.val.toString()}:a.operator===u.CustomFilterOperator.LESS_THAN&&s.operator===u.CustomFilterOperator.GREATER_THAN&&!i.customFilters.and?{operator1:u.CustomFilterOperator.GREATER_THAN,val1:a.val.toString(),operator2:u.CustomFilterOperator.LESS_THAN,val2:s.val.toLocaleString()}:!1}},t.CUSTOM={label:"sheets-filter.conditions.custom",operator:g.CUSTOM,order:P.SECOND,numOfParameters:2,getDefaultFormParams:()=>({operator1:g.NONE,val1:"",operator2:g.NONE,val2:""}),testMappingParams:()=>!0,mapToFilterColumn:i=>{const{and:s,val1:a,val2:m,operator1:h,operator2:f}=i;function O(w,M){for(const H of t.ALL_CONDITIONS)if(H.operator===w)return H.mapToFilterColumn({val1:M,operator1:w})}const _=!h||h===t.NONE.operator,I=!f||f===t.NONE.operator;if(_&&I)return t.NONE.mapToFilterColumn({});if(_)return O(f,m);if(I)return O(h,a);const E=O(h,a),A=O(f,m),F={customFilters:[E.customFilters.customFilters[0],A.customFilters.customFilters[0]]};return s&&(F.and=c.BooleanNumber.TRUE),{customFilters:F}},testMappingFilterColumn:i=>{var m;if(((m=i.customFilters)==null?void 0:m.customFilters.length)!==2)return!1;const s=i.customFilters.customFilters.map(h=>l({customFilters:{customFilters:[h]}})),a={operator1:s[0][0].operator,val1:s[0][1].val1,operator2:s[1][0].operator,val2:s[1][1].val1};return i.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(i){const s=t.ALL_CONDITIONS.find(a=>a.operator===i);if(!s)throw new Error(`[SheetsFilter]: no condition item found for operator: ${i}`);return s}t.getItemByOperator=e;function r(i,s){for(const a of t.ALL_CONDITIONS.filter(m=>m.numOfParameters===s))if(a.numOfParameters!==0&&a.testMappingParams(i))return a;for(const a of t.ALL_CONDITIONS)if(a.testMappingParams(i))return a;throw new Error("[SheetsFilter]: no condition item can be mapped from the filter map params!")}t.testMappingParams=r;function n(i){const s=t.ALL_CONDITIONS.find(a=>a.operator===i);return(s==null?void 0:s.numOfParameters)===0?{operator1:s.operator}:s.getDefaultFormParams()}t.getInitialFormParams=n;function o(i,s){return i.mapToFilterColumn(s)}t.mapToFilterColumn=o;function l(i){if(!i)return[t.NONE,{}];for(const s of t.ALL_CONDITIONS){const a=s.testMappingFilterColumn(i);if(a)return[s,a]}return[t.NONE,{}]}t.testMappingFilterColumn=l})(p||(p={}));function k(t){const{operator1:e,operator2:r,val1:n,val2:o}=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,n]:[r,o]}function Ce(t){const e=[],r=[];let n=0,o=0;function l(i){i.leaf&&(i.checked?(e.push(i),n+=i.count):(r.push(i),o+=i.count)),i.children&&i.children.forEach(l)}return t.forEach(l),{checkedItems:e,uncheckedItems:r,checked:n,unchecked:o}}var Ke=Object.getOwnPropertyDescriptor,Xe=(t,e,r,n)=>{for(var o=n>1?void 0:n?Ke(e,r):e,l=t.length-1,i;l>=0;l--)(i=t[l])&&(o=i(o)||o);return o},Te=(t,e)=>(r,n)=>e(r,n,t);const Ee="sheets-filter.generate-filter-values.service",le=c.createIdentifier(Ee),Ze=["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 Oe=class extends c.Disposable{constructor(t,e,r){super(),this._localeService=t,this._univerInstanceService=e,this._logService=r}async getFilterValues(t){var h;const{unitId:e,subUnitId:r,filteredOutRowsByOtherColumns:n,filters:o,blankChecked:l,iterateRange:i,alreadyChecked:s}=t,a=this._univerInstanceService.getUnit(e),m=(h=this._univerInstanceService.getUnit(e))==null?void 0:h.getSheetBySheetId(r);return!a||!m?[]:(this._logService.debug("[SheetsGenerateFilterValuesService]","getFilterValues for",{unitId:e,subUnitId:r}),we(o,this._localeService,i,m,new Set(n),new Set(s.map(String)),l,a.getStyles()))}};Oe=Xe([Te(0,c.Inject(c.LocaleService)),Te(1,c.IUniverInstanceService),Te(2,c.ILogService)],Oe);function we(t,e,r,n,o,l,i,s){var E,A,F,w,M,H,B,_e,Se;const a=new Map,m=new Map,h="yyyy-mm-dd",f=new Set(Ze),O="empty";let _=0;for(const L of n.iterateByColumn(r,!1,!1)){const{row:xt,rowSpan:qe=1}=L;let ee=0;for(;ee<qe;){const Vt=xt+ee;if(o.has(Vt)){ee++;continue}const q=L!=null&&L.value?c.extractPureTextFromCell(L.value):"";if(!q){_+=1,ee+=qe;continue}const ge=(E=L.value)!=null&&E.v&&!L.value.p?(w=(F=s.get((A=L.value)==null?void 0:A.s))==null?void 0:F.n)==null?void 0:w.pattern:"",Qt=ge&&c.numfmt.getFormatInfo(ge).isDate;if(ge&&Qt&&f.has(ge)){const G=(M=n.getCellRaw(L.row,L.col))==null?void 0:M.v;if(!G){ee++;continue}const te=c.numfmt.format(h,G),[R,W,se]=te.split("-").map(Number);let K=a.get(`${R}`);K||(K={title:`${R}`,key:`${R}`,children:[],count:0,leaf:!1,checked:!1},a.set(`${R}`,K),m.set(`${R}`,[`${R}`]));let V=(H=K.children)==null?void 0:H.find(Me=>Me.key===`${R}-${W}`);V||(V={title:e.t(`sheets-filter.date.${W}`),key:`${R}-${W}`,children:[],count:0,leaf:!1,checked:!1},(B=K.children)==null||B.push(V),m.set(`${R}-${W}`,[`${R}`,`${R}-${W}`]));const Re=(_e=V==null?void 0:V.children)==null?void 0:_e.find(Me=>Me.key===`${R}-${W}-${se}`);Re?(Re.originValues.add(q),Re.count++,V.count++,K.count++):((Se=V.children)==null||Se.push({title:`${se}`,key:`${R}-${W}-${se}`,count:1,originValues:new Set([q]),leaf:!0,checked:l.size?l.has(q):!i}),V.count++,K.count++,m.set(`${R}-${W}-${se}`,[`${R}`,`${R}-${W}`,`${R}-${W}-${se}`]))}else{const G=q;let te=a.get(G);te?te.count++:(te={title:q,leaf:!0,checked:l.size?l.has(q):!i,key:G,count:1},a.set(G,te),m.set(G,[G]))}ee++}}const I=t?i:!0;if(_>0){const L={title:e.t("sheets-filter.panel.empty"),count:_,leaf:!0,checked:I,key:O};a.set("empty",L),m.set("empty",[O])}return{filterTreeItems:ze(Array.from(a.values())),filterTreeMapCache:m}}function ze(t){return Array.from(t).sort((e,r)=>e.children&&!r.children?-1:!e.children&&r.children?1:Je(e.title,r.title)).map(e=>(e.children&&e.children.sort((r,n)=>{const o=Number.parseInt(r.key.split("-")[1],10),l=Number.parseInt(n.key.split("-")[1],10);return o-l}).forEach(r=>{r.children&&r.children.sort((n,o)=>{const l=Number.parseInt(n.key.split("-")[2],10),i=Number.parseInt(o.key.split("-")[2],10);return l-i})}),e))}const Le=t=>!Number.isNaN(Number(t))&&!Number.isNaN(Number.parseFloat(t));function Je(t,e){const r=Le(t),n=Le(e);return r&&n?Number.parseFloat(t)-Number.parseFloat(e):r&&!n?-1:!r&&n?1:t.localeCompare(e)}function Ie(t,e){for(const r of t){if(r.key===e)return r;if(r.children){const n=Ie(r.children,e);if(n)return n}}return null}function Ue(t){return t.leaf?t.checked:t.children?t.children.every(e=>Ue(e)):!0}function ie(t,e){t.leaf&&(e!==void 0?t.checked=e:t.checked=!t.checked),t.children&&t.children.forEach(r=>ie(r,e))}function $e(t,e){const r=[];return t.forEach(n=>{const o=n.originValues?e.some(s=>Array.from(n.originValues).some(a=>a.toLowerCase().includes(s.toLowerCase()))):!1,l=!o&&e.some(s=>n.title.toLowerCase().includes(s.toLowerCase()));if(o||l)r.push({...n});else if(n.children){const s=$e(n.children,e);if(s.length>0){const a=s.reduce((m,h)=>m+h.count,0);r.push({...n,count:a,children:s})}}}),r}var et=Object.getOwnPropertyDescriptor,Ne=(t,e,r,n)=>{for(var o=n>1?void 0:n?et(e,r):e,l=t.length-1,i;l>=0;l--)(i=t[l])&&(o=i(o)||o);return o},ce=(t,e)=>(r,n)=>e(r,n,t),ue=(t=>(t[t.VALUES=0]="VALUES",t[t.CONDITIONS=1]="CONDITIONS",t))(ue||{});c.createIdentifier("sheets-filter-ui.sheets-filter-panel.service");let Q=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 n=e.getFilterColumn(r);if(n){const o=n.getColumnData();if(o.customFilters){this._hasCriteria$.next(!0),this._setupByConditions(e,r);return}if(o.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 n=e.unitId,o=e.subUnitId,l=e.getRange(),i={startColumn:r,startRow:l.startRow,endRow:l.startRow,endColumn:r};this._filterHeaderListener=this._refRangeService.watchRange(n,o,i,(s,a)=>{if(!a)this.terminate();else{const m=a.startColumn-s.startColumn;m!==0&&this._filterByModel.deltaCol(m)}})}async _setupByValues(e,r){this._disposePreviousModel();const n=e.getRange();if(n.startRow===n.endRow)return!1;const o=await he.fromFilterColumn(this._injector,e,r);return this.filterByModel=o,this._filterBy$.next(0),this._listenToFilterHeaderChange(e,r),!0}_setupByConditions(e,r){this._disposePreviousModel();const n=e.getRange();if(n.startRow===n.endRow)return!1;const o=me.fromFilterColumn(this._injector,e,r,e.getFilterColumn(r));return this.filterByModel=o,this._filterBy$.next(1),this._listenToFilterHeaderChange(e,r),!0}_disposePreviousModel(){var e;(e=this._filterByModel)==null||e.dispose(),this.filterByModel=null}};Q=Ne([ce(0,c.Inject(c.Injector)),ce(1,c.Inject(N.RefRangeService))],Q);let me=class extends c.Disposable{constructor(e,r,n,o,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(n),this.conditionItem$=this._conditionItem$.asObservable(),this._filterConditionFormParams$=new C.BehaviorSubject(o),this.filterConditionFormParams$=this._filterConditionFormParams$.asObservable()}static fromFilterColumn(e,r,n,o){const[l,i]=p.testMappingFilterColumn(o==null?void 0:o.getColumnData());return e.createInstance(me,r,n,l,i)}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=p.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=p.ALL_CONDITIONS.find(n=>n.operator===e);if(!r)throw new Error(`[ByConditionsModel]: condition item not found for operator: ${e}!`);this._conditionItem$.next(r),this._filterConditionFormParams$.next(p.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 n=p.testMappingParams(r,this.conditionItem.numOfParameters);this._conditionItem$.next(n)}this._filterConditionFormParams$.next(r)}};me=Ne([ce(4,c.ICommandService)],me);let he=class extends c.Disposable{constructor(e,r,n,o,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=o,this._searchString$=new C.BehaviorSubject(""),this.searchString$=this._searchString$.asObservable(),this._rawFilterItems$=new C.BehaviorSubject(n),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(([i,s])=>{if(!i)return s;const m=i.toLowerCase().split(/\s+/).filter(h=>!!h);return $e(s,m)})),this._manuallyUpdateFilterItems$).pipe(C.shareReplay(1)),this.canApply$=this.filterItems$.pipe(C.map(i=>Ce(i).checked>0)),this.disposeWithMe(this.filterItems$.subscribe(i=>this._filterItems=i))}static async fromFilterColumn(e,r,n){var H;const o=e.get(c.IUniverInstanceService),l=e.get(c.LocaleService),i=e.get(le,c.Quantity.OPTIONAL),{unitId:s,subUnitId:a}=r,m=o.getUniverSheetInstance(s);if(!m)throw new Error(`[ByValuesModel]: Workbook not found for filter model with unitId: ${s}!`);const h=m==null?void 0:m.getSheetBySheetId(a);if(!h)throw new Error(`[ByValuesModel]: Worksheet not found for filter model with unitId: ${s} and subUnitId: ${a}!`);const f=r.getRange(),O=n,_=(H=r.getFilterColumn(n))==null?void 0:H.getColumnData().filters,I=new Set(_==null?void 0:_.filters),E=!!(_&&_.blank),A=r.getFilteredOutRowsExceptCol(n),F={...f,startRow:f.startRow+1,startColumn:O,endColumn:O};let w,M;if(i){const B=await i.getFilterValues({unitId:s,subUnitId:a,filteredOutRowsByOtherColumns:Array.from(A),filters:!!_,blankChecked:E,iterateRange:F,alreadyChecked:Array.from(I)});w=B.filterTreeItems,M=B.filterTreeMapCache}else{const B=we(!!_,l,F,h,A,I,E,m.getStyles());w=B.filterTreeItems,M=B.filterTreeMapCache}return e.createInstance(he,r,n,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(n=>ie(n,e)),this._manuallyUpdateFilterItems(r)}onFilterCheckToggled(e){const r=c.Tools.deepClone(this._filterItems),n=Ie(r,e.key);if(!n)return;const o=Ue(n);ie(n,!o),this._manuallyUpdateFilterItems(r)}onFilterOnly(e){const r=c.Tools.deepClone(this._filterItems);r.forEach(n=>ie(n,!1)),e.forEach(n=>{const o=Ie(r,n);o&&ie(o,!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=Ce(this._filterItems),{checked:r,checkedItems:n}=e,o=this.rawFilterItems;let l=0;for(const m of o)l+=m.count;const i=r===0,s=e.checked===l,a={colId:this.col};if(i)throw new Error("[ByValuesModel]: no checked items!");if(s)return this._commandService.executeCommand(u.SetSheetsFilterCriteriaCommand.id,{unitId:this._filterModel.unitId,subUnitId:this._filterModel.subUnitId,col:this.col,criteria:null});{a.filters={};const m=n.filter(f=>f.key!=="empty");m.length>0&&(a.filters={filters:m.flatMap(f=>f.originValues?Array.from(f.originValues):[f.title])}),m.length!==n.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})}};he=Ne([ce(4,c.ICommandService)],he);const X="FILTER_PANEL_OPENED",ne={id:"sheet.operation.open-filter-panel",type:c.CommandType.OPERATION,handler:(t,e)=>{const r=t.get(c.IContextService),n=t.get(u.SheetsFilterService),o=t.get(Q);t.get(c.ICommandService).syncExecuteCommand(U.SetCellEditVisibleOperation.id,{visible:!1});const{unitId:i,subUnitId:s,col:a}=e,m=n.getFilterModel(i,s);return m?(o.setupCol(m,a),r.getContextValue(X)||r.setContextValue(X,!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(Q),n=t.get(T.ILayoutService,c.Quantity.OPTIONAL);return e.getContextValue(X)?(e.setContextValue(X,!1),n==null||n.focus(),r.terminate()):!1}},Fe={id:"sheet.operation.apply-filter",type:c.CommandType.OPERATION,handler:(t,e)=>{const{filterBy:r}=e;return t.get(Q).changeFilterBy(r)}},De="sheets-filter-ui.config",pe={};var tt=Object.getOwnPropertyDescriptor,rt=(t,e,r,n)=>{for(var o=n>1?void 0:n?tt(e,r):e,l=t.length-1,i;l>=0;l--)(i=t[l])&&(o=i(o)||o);return o},z=(t,e)=>(r,n)=>e(r,n,t);let J=class extends c.Disposable{constructor(t,e,r,n,o,l){super(),this._sheetsFilterService=t,this._localeService=e,this._commandService=r,this._sheetPermissionCheckPermission=n,this._injector=o,this._sheetsSelectionService=l,this._commandExecutedListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.beforeCommandExecuted(t=>{var e,r,n;if(t.id===u.SmartToggleSheetsFilterCommand.id){const o=this._injector.get(c.IUniverInstanceService),l=N.getSheetCommandTarget(o);if(!l)return;const{unitId:i,subUnitId:s,worksheet:a}=l,m=(e=this._sheetsFilterService.getFilterModel(i,s))==null?void 0:e.getRange();let h;if(m)h=this._sheetPermissionCheckPermission.permissionCheckWithRanges({rangeTypes:[N.RangeProtectionPermissionViewPoint],worksheetTypes:[N.WorksheetFilterPermission,N.WorksheetViewPermission]},[m]);else{const f=(r=this._sheetsSelectionService.getCurrentLastSelection())==null?void 0:r.range;if(f){let O={...f};O=f.startColumn===f.endColumn&&f.startRow===f.endRow?N.expandToContinuousRange(O,{left:!0,right:!0,up:!0,down:!0},a):O,h=this._sheetPermissionCheckPermission.permissionCheckWithRanges({rangeTypes:[N.RangeProtectionPermissionViewPoint],worksheetTypes:[N.WorksheetViewPermission,N.WorksheetFilterPermission]},[O],i,s)}else h=this._sheetPermissionCheckPermission.permissionCheckWithoutRange({rangeTypes:[N.RangeProtectionPermissionViewPoint],worksheetTypes:[N.WorksheetViewPermission,N.WorksheetFilterPermission]})}h||this._sheetPermissionCheckPermission.blockExecuteWithoutPermission(this._localeService.t("permission.dialog.filterErr"))}if(t.id===ne.id){const o=t.params,{unitId:l,subUnitId:i}=o,s=(n=this._sheetsFilterService.getFilterModel(l,i))==null?void 0:n.getRange(),a=c.Tools.deepClone(s);a&&(a.startColumn=o.col,a.endColumn=o.col,this._sheetPermissionCheckPermission.permissionCheckWithRanges({rangeTypes:[N.RangeProtectionPermissionViewPoint],worksheetTypes:[N.WorksheetFilterPermission,N.WorksheetViewPermission]},[a])||this._sheetPermissionCheckPermission.blockExecuteWithoutPermission(this._localeService.t("permission.dialog.filterErr")))}}))}};J=rt([z(0,c.Inject(u.SheetsFilterService)),z(1,c.Inject(c.LocaleService)),z(2,c.ICommandService),z(3,c.Inject(N.SheetPermissionCheckController)),z(4,c.Inject(c.Injector)),z(5,c.Inject(N.SheetsSelectionsService))],J);const j=16,it=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 ke{static drawNoCriteria(e,r,n,o){e.save(),re.Rect.drawWith(e,{radius:2,width:j,height:j,fill:o}),e.lineCap="square",e.strokeStyle=n,e.scale(r/j,r/j),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,n,o){e.save(),re.Rect.drawWith(e,{radius:2,width:j,height:j,fill:o}),e.scale(r/j,r/j),e.fillStyle=n,e.fill(it),e.restore()}}var nt=Object.getOwnPropertyDescriptor,ot=(t,e,r,n)=>{for(var o=n>1?void 0:n?nt(e,r):e,l=t.length-1,i;l>=0;l--)(i=t[l])&&(o=i(o)||o);return o},ye=(t,e)=>(r,n)=>e(r,n,t);const x=16,de=1;let Pe=class extends re.Shape{constructor(e,r,n,o,l){super(e,r);S(this,"_cellWidth",0);S(this,"_cellHeight",0);S(this,"_filterParams");S(this,"_hovered",!1);this._contextService=n,this._commandService=o,this._themeService=l,this.setShapeProps(r),this.onPointerDown$.subscribeEvent(i=>this.onPointerDown(i)),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,n=this._cellWidth,o=x-n,l=x-r;e.save();const i=new Path2D;i.rect(o,l,n,r),e.clip(i);const{hasCriteria:s}=this._filterParams,a=this._themeService.getColorFromTheme("primary.600"),m=this._hovered?this._themeService.getColorFromTheme("gray.50"):"rgba(255, 255, 255, 1.0)";s?ke.drawHasCriteria(e,x,a,m):ke.drawNoCriteria(e,x,a,m),e.restore()}onPointerDown(e){if(e.button===2)return;const{col:r,unitId:n,subUnitId:o}=this._filterParams;this._contextService.getContextValue(X)||!this._commandService.hasCommand(ne.id)||setTimeout(()=>{this._commandService.executeCommand(ne.id,{unitId:n,subUnitId:o,col:r})},200)}onPointerEnter(){this._hovered=!0,this.makeDirty(!0)}onPointerLeave(){this._hovered=!1,this.makeDirty(!0)}};Pe=ot([ye(2,c.IContextService),ye(3,c.ICommandService),ye(4,c.Inject(c.ThemeService))],Pe);var st=Object.getOwnPropertyDescriptor,at=(t,e,r,n)=>{for(var o=n>1?void 0:n?st(e,r):e,l=t.length-1,i;l>=0;l--)(i=t[l])&&(o=i(o)||o);return o},Y=(t,e)=>(r,n)=>e(r,n,t);const lt=1e3,ct=5e3;let be=class extends c.RxDisposable{constructor(e,r,n,o,l,i,s,a){super();S(this,"_filterRangeShape",null);S(this,"_buttonRenderDisposable",null);S(this,"_filterButtonShapes",[]);this._context=e,this._injector=r,this._sheetSkeletonManagerService=n,this._sheetsFilterService=o,this._themeService=l,this._sheetInterceptorService=i,this._commandService=s,this._selectionRenderService=a,this._initRenderer()}dispose(){super.dispose(),this._disposeRendering()}_initRenderer(){this._sheetSkeletonManagerService.currentSkeleton$.pipe(C.switchMap(e=>{var s,a;if(!e)return C.of(null);const{unit:r,unitId:n}=this._context,o=((s=r.getActiveSheet())==null?void 0:s.getSheetId())||"",l=(a=this._sheetsFilterService.getFilterModel(n,o))!=null?a:void 0,i=()=>({unitId:n,worksheetId:o,filterModel:l,range:l==null?void 0:l.getRange(),skeleton:e.skeleton});return c.fromCallback(this._commandService.onCommandExecuted.bind(this._commandService)).pipe(C.filter(([m])=>{var h;return m.type===c.CommandType.MUTATION&&((h=m.params)==null?void 0:h.unitId)===r.getUnitId()&&(u.FILTER_MUTATIONS.has(m.id)||m.id===N.SetRangeValuesMutation.id)}),C.throttleTime(20,void 0,{leading:!1,trailing:!0}),C.map(i),C.startWith(i()))}),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:n}=this._context,{rowHeaderWidth:o,columnHeaderHeight:l}=r,i=this._filterRangeShape=new U.SelectionControl(n,lt,this._themeService,{rowHeaderWidth:o,columnHeaderHeight:l,enableAutoFill:!1,highlightHeader:!1}),s={range:e,primary:null,style:{fill:"rgba(0, 0, 0, 0.0)"}},a=U.attachSelectionWithCoord(s,r);i.updateRangeBySelectionWithCoord(a),i.setEvent(!1),n.makeDirty(!0)}_renderButtons(e){const{range:r,filterModel:n,unitId:o,skeleton:l,worksheetId:i}=e,{scene:s}=this._context;this._interceptCellContent(o,i,e.range);const{startColumn:a,endColumn:m,startRow:h}=r;for(let f=a;f<=m;f++){const O=`sheets-filter-button-${f}`,_=U.getCoordByCell(h,f,s,l),{startX:I,startY:E,endX:A,endY:F}=_,w=A-I,M=F-E;if(M<=de||w<=de)continue;const H=!!n.getFilterColumn(f),B=A-x-de,_e=F-x-de,Se={left:B,top:_e,height:x,width:x,zIndex:ct,cellHeight:M,cellWidth:w,filterParams:{unitId:o,subUnitId:i,col:f,hasCriteria:H}},L=this._injector.createInstance(Pe,O,Se);this._filterButtonShapes.push(L)}s.addObjects(this._filterButtonShapes),s.makeDirty()}_interceptCellContent(e,r,n){const{startRow:o,startColumn:l,endColumn:i}=n;this._buttonRenderDisposable=this._sheetInterceptorService.intercept(N.INTERCEPTOR_POINT.CELL_CONTENT,{effect:c.InterceptorEffectEnum.Style,handler:(s,a,m)=>{const{row:h,col:f,unitId:O,subUnitId:_}=a;return O!==e||_!==r||h!==o||f<l||f>i||((!s||s===a.rawData)&&(s={...a.rawData}),s.fontRenderExtension={...s==null?void 0:s.fontRenderExtension,rightOffset:x}),m(s)},priority:10})}_disposeRendering(){var e,r;(e=this._filterRangeShape)==null||e.dispose(),this._filterButtonShapes.forEach(n=>n.dispose()),(r=this._buttonRenderDisposable)==null||r.dispose(),this._filterRangeShape=null,this._buttonRenderDisposable=null,this._filterButtonShapes=[]}};be=at([Y(1,c.Inject(c.Injector)),Y(2,c.Inject(U.SheetSkeletonManagerService)),Y(3,c.Inject(u.SheetsFilterService)),Y(4,c.Inject(c.ThemeService)),Y(5,c.Inject(N.SheetInterceptorService)),Y(6,c.ICommandService),Y(7,U.ISheetSelectionRenderService)],be);var ut=Object.getOwnPropertyDescriptor,mt=(t,e,r,n)=>{for(var o=n>1?void 0:n?ut(e,r):e,l=t.length-1,i;l>=0;l--)(i=t[l])&&(o=i(o)||o);return o},He=(t,e)=>(r,n)=>e(r,n,t);let oe=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,[be]))}};oe=mt([He(0,re.IRenderManagerService),He(1,c.Inject(U.SheetsRenderService))],oe);var ht=Object.defineProperty,pt=Object.getOwnPropertyDescriptor,dt=(t,e,r)=>e in t?ht(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,ft=(t,e,r,n)=>{for(var o=n>1?void 0:n?pt(e,r):e,l=t.length-1,i;l>=0;l--)(i=t[l])&&(o=i(o)||o);return o},Be=(t,e)=>(r,n)=>e(r,n,t),We=(t,e,r)=>dt(t,typeof e!="symbol"?e+"":e,r);const vt="SHEET_FILTER_UI_PLUGIN";v.UniverSheetsFilterMobileUIPlugin=class extends c.Plugin{constructor(e=pe,r,n){super(),this._config=e,this._injector=r,this._configService=n;const{menu:o,...l}=c.merge({},pe,this._config);o&&this._configService.setConfig("menu",o,{merge:!0}),this._configService.setConfig(De,l)}onStarting(){[[J],[oe]].forEach(e=>this._injector.add(e))}onReady(){this._injector.get(J)}onRendered(){this._injector.get(oe)}},We(v.UniverSheetsFilterMobileUIPlugin,"type",c.UniverInstanceType.UNIVER_SHEET),We(v.UniverSheetsFilterMobileUIPlugin,"pluginName",vt),v.UniverSheetsFilterMobileUIPlugin=ft([c.DependentOn(u.UniverSheetsFilterPlugin),Be(1,c.Inject(c.Injector)),Be(2,c.IConfigService)],v.UniverSheetsFilterMobileUIPlugin);var D=function(){return D=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++){e=arguments[r];for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o])}return t},D.apply(this,arguments)},_t=function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,n=Object.getOwnPropertySymbols(t);o<n.length;o++)e.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(t,n[o])&&(r[n[o]]=t[n[o]]);return r},xe=b.forwardRef(function(t,e){var r=t.icon,n=t.id,o=t.className,l=t.extend,i=_t(t,["icon","id","className","extend"]),s="univerjs-icon univerjs-icon-".concat(n," ").concat(o||"").trim(),a=b.useRef("_".concat(Ct()));return Ve(r,"".concat(n),{defIds:r.defIds,idSuffix:a.current},D({ref:e,className:s},i),l)});function Ve(t,e,r,n,o){return b.createElement(t.tag,D(D({key:e},St(t,r,o)),n),(gt(t,r).children||[]).map(function(l,i){return Ve(l,"".concat(e,"-").concat(t.tag,"-").concat(i),r,void 0,o)}))}function St(t,e,r){var n=D({},t.attrs);r!=null&&r.colorChannel1&&n.fill==="colorChannel1"&&(n.fill=r.colorChannel1),t.tag==="mask"&&n.id&&(n.id=n.id+e.idSuffix),Object.entries(n).forEach(function(l){var i=l[0],s=l[1];i==="mask"&&typeof s=="string"&&(n[i]=s.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))});var o=e.defIds;return!o||o.length===0||(t.tag==="use"&&n["xlink:href"]&&(n["xlink:href"]=n["xlink:href"]+e.idSuffix),Object.entries(n).forEach(function(l){var i=l[0],s=l[1];typeof s=="string"&&(n[i]=s.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))})),n}function gt(t,e){var r,n=e.defIds;return!n||n.length===0?t:t.tag==="defs"&&(!((r=t.children)===null||r===void 0)&&r.length)?D(D({},t),{children:t.children.map(function(o){return typeof o.attrs.id=="string"&&n&&n.includes(o.attrs.id)?D(D({},o),{attrs:D(D({},o.attrs),{id:o.attrs.id+e.idSuffix})}):o})}):t}function Ct(){return Math.random().toString(36).substring(2,8)}xe.displayName="UniverIcon";var Tt={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",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"}}]},Qe=b.forwardRef(function(t,e){return b.createElement(xe,Object.assign({},t,{id:"filter-icon",ref:e,icon:Tt}))});Qe.displayName="FilterIcon";function Et(t){var _,I;const{model:e}=t,r=T.useDependency(c.LocaleService),n=T.useObservable(e.conditionItem$,void 0),o=T.useObservable(e.filterConditionFormParams$,void 0),l=o!=null&&o.and?"AND":"OR",i=b.useCallback(E=>{e.onConditionFormChange({and:E==="AND"})},[e]),s=Ot(r),a=b.useCallback(E=>{e.onPrimaryConditionChange(E)},[e]),m=It(r),h=b.useCallback(E=>{e.onConditionFormChange(E)},[e]),f=r.t("sheets-filter.panel.input-values-placeholder");function O(E,A,F){const w=p.getItemByOperator(E).numOfParameters===1;return d.jsxs(d.Fragment,{children:[F==="operator2"&&d.jsxs(y.RadioGroup,{value:l,onChange:i,children:[d.jsx(y.Radio,{value:"AND",children:r.t("sheets-filter.panel.and")}),d.jsx(y.Radio,{value:"OR",children:r.t("sheets-filter.panel.or")})]}),d.jsx(y.Select,{value:E,options:m,onChange:M=>h({[F]:M})}),w&&d.jsx("div",{children:d.jsx(y.Input,{className:"univer-mt-2",value:A,placeholder:f,onChange:M=>h({[F==="operator1"?"val1":"val2"]:M})})})]})}return d.jsx("div",{"data-u-comp":"sheets-filter-panel-conditions-container",className:"univer-flex univer-h-full univer-min-h-[300px] univer-flex-col",children:n&&o&&d.jsxs(d.Fragment,{children:[d.jsx(y.Select,{value:n.operator,options:s,onChange:a}),p.getItemByOperator(n.operator).numOfParameters!==0?d.jsxs("div",{"data-u-comp":"sheets-filter-panel-conditions-container-inner",className:y.clsx("univer-mt-2 univer-flex-grow univer-overflow-hidden univer-rounded-md univer-p-2",y.borderClassName),children:[n.numOfParameters>=1&&O(o.operator1,(_=o.val1)!=null?_:"","operator1"),n.numOfParameters>=2&&O(o.operator2,(I=o.val2)!=null?I:"","operator2"),d.jsxs("div",{"data-u-comp":"sheets-filter-panel-conditions-desc",className:"univer-mt-2 univer-text-xs univer-text-gray-500",children:[r.t("sheets-filter.panel.?"),d.jsx("br",{}),r.t("sheets-filter.panel.*")]})]}):null]})})}function Ot(t){const e=t.getCurrentLocale();return b.useMemo(()=>[{options:[{label:t.t(p.NONE.label),value:p.NONE.operator}]},{options:[{label:t.t(p.EMPTY.label),value:p.EMPTY.operator},{label:t.t(p.NOT_EMPTY.label),value:p.NOT_EMPTY.operator}]},{options:[{label:t.t(p.TEXT_CONTAINS.label),value:p.TEXT_CONTAINS.operator},{label:t.t(p.DOES_NOT_CONTAIN.label),value:p.DOES_NOT_CONTAIN.operator},{label:t.t(p.STARTS_WITH.label),value:p.STARTS_WITH.operator},{label:t.t(p.ENDS_WITH.label),value:p.ENDS_WITH.operator},{label:t.t(p.EQUALS.label),value:p.EQUALS.operator}]},{options:[{label:t.t(p.GREATER_THAN.label),value:p.GREATER_THAN.operator},{label:t.t(p.GREATER_THAN_OR_EQUAL.label),value:p.GREATER_THAN_OR_EQUAL.operator},{label:t.t(p.LESS_THAN.label),value:p.LESS_THAN.operator},{label:t.t(p.LESS_THAN_OR_EQUAL.label),value:p.LESS_THAN_OR_EQUAL.operator},{label:t.t(p.EQUAL.label),value:p.EQUAL.operator},{label:t.t(p.NOT_EQUAL.label),value:p.NOT_EQUAL.operator},{label:t.t(p.BETWEEN.label),value:p.BETWEEN.operator},{label:t.t(p.NOT_BETWEEN.label),value:p.NOT_BETWEEN.operator}]},{options:[{label:t.t(p.CUSTOM.label),value:p.CUSTOM.operator}]}],[e,t])}function It(t){const e=t.getCurrentLocale();return b.useMemo(()=>p.ALL_CONDITIONS.filter(r=>r.numOfParameters!==2).map(r=>({label:t.t(r.label),value:r.operator})),[e,t])}function Nt(t){const{model:e}=t,r=T.useDependency(c.LocaleService),n=T.useObservable(e.searchString$,"",!0),o=T.useObservable(e.filterItems$,void 0,!0),l=r.t("sheets-filter.panel.filter-only"),i=Ce(o),s=i.checked>0&&i.unchecked===0,a=i.checked>0&&i.unchecked>0,m=e.treeMapCache,h=b.useCallback(()=>{e.onCheckAllToggled(!s)},[e,s]),f=b.useCallback(_=>{e.setSearchString(_)},[e]);function O(_){let I=[];return _.forEach(E=>{E.checked&&I.push(E.key),E.children&&(I=I.concat(O(E.children)))}),I}return d.jsxs("div",{"data-u-comp":"sheets-filter-panel-values-container",className:"univer-flex univer-h-full univer-min-h-[300px] univer-flex-col",children:[d.jsx(y.Input,{autoFocus:!0,value:n,placeholder:r.t("sheets-filter.panel.search-placeholder"),onChange:f}),d.jsxs("div",{"data-u-comp":"sheets-filter-panel",className:y.clsx("univer-mt-2 univer-box-border univer-flex univer-flex-grow univer-flex-col univer-overflow-hidden univer-rounded-md univer-px-2 univer-py-2.5",y.borderClassName),children:[d.jsx("div",{"data-u-comp":"sheets-filter-panel-values-item",className:"univer-box-border univer-h-8 univer-w-full univer-py-0.5",children:d.jsxs("div",{"data-u-comp":"sheets-filter-panel-values-item-inner",className:"univer-box-border univer-flex univer-h-7 univer-items-center univer-rounded-md univer-pb-0 univer-pl-5 univer-pr-0.5 univer-pt-0 univer-text-sm",children:[d.jsx(y.Checkbox,{indeterminate:a,disabled:o.length===0,checked:s,onChange:h}),d.jsx("span",{"data-u-comp":"sheets-filter-panel-values-item-text",className:"univer-mx-1 univer-inline-block univer-flex-shrink univer-overflow-hidden univer-text-ellipsis univer-whitespace-nowrap univer-text-gray-900 dark:!univer-text-white",children:`${r.t("sheets-filter.panel.select-all")}`}),d.jsx("span",{"data-u-comp":"sheets-filter-panel-values-item-count",className:"univer-text-gray-400 dark:!univer-text-gray-500",children:`(${i.checked}/${i.checked+i.unchecked})`})]})}),d.jsx("div",{"data-u-comp":"sheets-filter-panel-values-virtual",className:"univer-flex-grow",children:d.jsx(y.Tree,{data:o,defaultExpandAll:!1,valueGroup:O(o),onChange:_=>{e.onFilterCheckToggled(_)},defaultCache:m,itemHeight:28,treeNodeClassName:`
1
+ (function(_,u){typeof exports=="object"&&typeof module<"u"?u(exports,require("@univerjs/core"),require("@univerjs/sheets-filter"),require("@univerjs/sheets-ui"),require("@univerjs/ui"),require("@univerjs/engine-render"),require("@univerjs/sheets"),require("rxjs"),require("@univerjs/rpc"),require("@univerjs/design"),require("react/jsx-runtime"),require("react")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/sheets-filter","@univerjs/sheets-ui","@univerjs/ui","@univerjs/engine-render","@univerjs/sheets","rxjs","@univerjs/rpc","@univerjs/design","react/jsx-runtime","react"],u):(_=typeof globalThis<"u"?globalThis:_||self,u(_.UniverSheetsFilterUi={},_.UniverCore,_.UniverSheetsFilter,_.UniverSheetsUi,_.UniverUi,_.UniverEngineRender,_.UniverSheets,_.rxjs,_.UniverRpc,_.UniverDesign,_.React,_.React))})(this,function(_,u,c,$,E,K,F,g,pe,b,d,I){"use strict";var rr=Object.defineProperty;var ir=(_,u,c)=>u in _?rr(_,u,{enumerable:!0,configurable:!0,writable:!0,value:c}):_[u]=c;var v=(_,u,c)=>ir(_,typeof u!="symbol"?u+"":u,c);var Oe;var A=(t=>(t[t.FIRST=0]="FIRST",t[t.SECOND=1]="SECOND",t))(A||{}),T=(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))(T||{}),f;(t=>{t.NONE={label:"sheets-filter.conditions.none",operator:T.NONE,order:A.SECOND,numOfParameters:0,getDefaultFormParams:()=>{throw new Error("[FilterConditionItems.NONE]: should not have initial form params!")},testMappingParams:i=>i.operator1===T.NONE,mapToFilterColumn:()=>null,testMappingFilterColumn:i=>!i.customFilters&&!i.filters?{}:!1},t.EMPTY={label:"sheets-filter.conditions.empty",operator:T.EMPTY,order:A.SECOND,numOfParameters:0,getDefaultFormParams:()=>{throw new Error("[FilterConditionItems.EMPTY]: should not have initial form params!")},testMappingParams:({operator1:i})=>i===T.EMPTY,mapToFilterColumn:()=>({customFilters:{customFilters:[{val:""}]}}),testMappingFilterColumn:i=>{var h;if(((h=i.customFilters)==null?void 0:h.customFilters.length)!==1)return!1;const s=i.customFilters.customFilters[0];return s.val===""&&s.operator===void 0?{operator1:T.EMPTY}:!1}},t.NOT_EMPTY={label:"sheets-filter.conditions.not-empty",operator:T.NOT_EMPTY,order:A.SECOND,numOfParameters:0,getDefaultFormParams:()=>{throw new Error("[FilterConditionItems.NOT_EMPTY]: should not have initial form params!")},testMappingParams:({operator1:i})=>i===T.NOT_EMPTY,mapToFilterColumn:()=>({customFilters:{customFilters:[{val:"",operator:c.CustomFilterOperator.NOT_EQUALS}]}}),testMappingFilterColumn:i=>{var h;if(((h=i.customFilters)==null?void 0:h.customFilters.length)!==1)return!1;const s=i.customFilters.customFilters[0];return s.val===" "&&s.operator===c.CustomFilterOperator.NOT_EQUALS?{operator1:T.NOT_EMPTY}:!1}},t.TEXT_CONTAINS={label:"sheets-filter.conditions.text-contains",operator:T.CONTAINS,order:A.FIRST,numOfParameters:1,getDefaultFormParams:()=>({operator1:T.CONTAINS,val1:""}),testMappingParams:i=>{const[s]=H(i);return s===T.CONTAINS},mapToFilterColumn:i=>{const{val1:s}=i;return s===""?null:{customFilters:{customFilters:[{val:`*${s}*`}]}}},testMappingFilterColumn:i=>{var h;if(((h=i.customFilters)==null?void 0:h.customFilters.length)!==1)return!1;const s=i.customFilters.customFilters[0],a=s.val.toString();return!s.operator&&a.startsWith("*")&&a.endsWith("*")?{operator1:T.CONTAINS,val1:a.slice(1,-1)}:!1}},t.DOES_NOT_CONTAIN={label:"sheets-filter.conditions.does-not-contain",operator:T.DOES_NOT_CONTAIN,order:A.FIRST,numOfParameters:1,getDefaultFormParams:()=>({operator1:T.DOES_NOT_CONTAIN,val1:""}),mapToFilterColumn:i=>({customFilters:{customFilters:[{val:`*${i.val1}*`,operator:c.CustomFilterOperator.NOT_EQUALS}]}}),testMappingParams:i=>{const[s]=H(i);return s===T.DOES_NOT_CONTAIN},testMappingFilterColumn:i=>{var h;if(((h=i.customFilters)==null?void 0:h.customFilters.length)!==1)return!1;const s=i.customFilters.customFilters[0],a=s.val.toString();return s.operator===c.CustomFilterOperator.NOT_EQUALS&&a.startsWith("*")&&a.endsWith("*")?{operator1:T.DOES_NOT_CONTAIN,val1:a.slice(1,-1)}:!1}},t.STARTS_WITH={label:"sheets-filter.conditions.starts-with",operator:T.STARTS_WITH,order:A.FIRST,numOfParameters:1,getDefaultFormParams:()=>({operator1:T.STARTS_WITH,val1:""}),mapToFilterColumn:i=>({customFilters:{customFilters:[{val:`${i.val1}*`}]}}),testMappingParams:i=>{const[s]=H(i);return s===T.STARTS_WITH},testMappingFilterColumn:i=>{var h;if(((h=i.customFilters)==null?void 0:h.customFilters.length)!==1)return!1;const s=i.customFilters.customFilters[0],a=s.val.toString();return!s.operator&&a.endsWith("*")&&!a.startsWith("*")?{operator1:T.STARTS_WITH,val1:a.slice(0,-1)}:!1}},t.ENDS_WITH={label:"sheets-filter.conditions.ends-with",operator:T.ENDS_WITH,order:A.FIRST,numOfParameters:1,getDefaultFormParams:()=>({operator1:T.ENDS_WITH,val1:""}),mapToFilterColumn:i=>({customFilters:{customFilters:[{val:`*${i.val1}`}]}}),testMappingParams:i=>{const[s]=H(i);return s===T.ENDS_WITH},testMappingFilterColumn:i=>{var h;if(((h=i.customFilters)==null?void 0:h.customFilters.length)!==1)return!1;const s=i.customFilters.customFilters[0],a=s.val.toString();return!s.operator&&a.startsWith("*")&&!a.endsWith("*")?{operator1:T.ENDS_WITH,val1:a.slice(1)}:!1}},t.EQUALS={label:"sheets-filter.conditions.equals",operator:T.EQUALS,order:A.FIRST,numOfParameters:1,getDefaultFormParams:()=>({operator1:T.EQUALS,val1:""}),testMappingParams:i=>{const[s]=H(i);return s===T.EQUALS},mapToFilterColumn:i=>{const{val1:s}=i;return s===""?null:{customFilters:{customFilters:[{val:s}]}}},testMappingFilterColumn:i=>{var s,a,h;return((a=(s=i.filters)==null?void 0:s.filters)==null?void 0:a.length)===1?{operator1:T.EQUALS,val1:""}:((h=i.customFilters)==null?void 0:h.customFilters.length)===1&&!i.customFilters.customFilters[0].operator?{operator1:T.EQUALS,val1:i.customFilters.customFilters[0].val.toString()}:!1}},t.GREATER_THAN={label:"sheets-filter.conditions.greater-than",operator:c.CustomFilterOperator.GREATER_THAN,numOfParameters:1,order:A.FIRST,getDefaultFormParams:()=>({operator1:c.CustomFilterOperator.GREATER_THAN,val1:""}),mapToFilterColumn:i=>({customFilters:{customFilters:[{val:i.val1,operator:c.CustomFilterOperator.GREATER_THAN}]}}),testMappingParams:i=>{const[s]=H(i);return s===c.CustomFilterOperator.GREATER_THAN},testMappingFilterColumn:i=>{var a;if(((a=i.customFilters)==null?void 0:a.customFilters.length)!==1)return!1;const s=i.customFilters.customFilters[0];return s.operator!==c.CustomFilterOperator.GREATER_THAN?!1:{operator1:c.CustomFilterOperator.GREATER_THAN,val1:s.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:A.FIRST,getDefaultFormParams:()=>({operator1:c.CustomFilterOperator.GREATER_THAN_OR_EQUAL,val1:""}),testMappingParams:i=>{const[s]=H(i);return s===c.CustomFilterOperator.GREATER_THAN_OR_EQUAL},mapToFilterColumn:i=>({customFilters:{customFilters:[{val:i.val1,operator:c.CustomFilterOperator.GREATER_THAN_OR_EQUAL}]}}),testMappingFilterColumn:i=>{var a;if(((a=i.customFilters)==null?void 0:a.customFilters.length)!==1)return!1;const s=i.customFilters.customFilters[0];return s.operator!==c.CustomFilterOperator.GREATER_THAN_OR_EQUAL?!1:{operator1:c.CustomFilterOperator.GREATER_THAN_OR_EQUAL,val1:s.val.toString()}}},t.LESS_THAN={label:"sheets-filter.conditions.less-than",operator:c.CustomFilterOperator.LESS_THAN,numOfParameters:1,order:A.FIRST,getDefaultFormParams:()=>({operator1:c.CustomFilterOperator.LESS_THAN,val1:""}),testMappingParams:i=>{const[s]=H(i);return s===c.CustomFilterOperator.LESS_THAN},mapToFilterColumn:i=>({customFilters:{customFilters:[{val:i.val1,operator:c.CustomFilterOperator.LESS_THAN}]}}),testMappingFilterColumn:i=>{var a;if(((a=i.customFilters)==null?void 0:a.customFilters.length)!==1)return!1;const s=i.customFilters.customFilters[0];return s.operator!==c.CustomFilterOperator.LESS_THAN?!1:{operator1:c.CustomFilterOperator.LESS_THAN,val1:s.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:A.FIRST,getDefaultFormParams:()=>({operator1:c.CustomFilterOperator.LESS_THAN_OR_EQUAL,val1:""}),testMappingParams:i=>{const[s]=H(i);return s===c.CustomFilterOperator.LESS_THAN_OR_EQUAL},mapToFilterColumn:i=>({customFilters:{customFilters:[{val:i.val1,operator:c.CustomFilterOperator.LESS_THAN_OR_EQUAL}]}}),testMappingFilterColumn:i=>{var a;if(((a=i.customFilters)==null?void 0:a.customFilters.length)!==1)return!1;const s=i.customFilters.customFilters[0];return s.operator!==c.CustomFilterOperator.LESS_THAN_OR_EQUAL?!1:{operator1:c.CustomFilterOperator.LESS_THAN_OR_EQUAL,val1:s.val.toString()}}},t.EQUAL={label:"sheets-filter.conditions.equal",operator:c.CustomFilterOperator.EQUAL,numOfParameters:1,order:A.FIRST,getDefaultFormParams:()=>({operator1:c.CustomFilterOperator.EQUAL,val1:""}),testMappingParams:i=>{const[s]=H(i);return s===c.CustomFilterOperator.EQUAL},mapToFilterColumn:i=>({customFilters:{customFilters:[{val:i.val1,operator:c.CustomFilterOperator.EQUAL}]}}),testMappingFilterColumn:i=>{var a;if(((a=i.customFilters)==null?void 0:a.customFilters.length)!==1)return!1;const s=i.customFilters.customFilters[0];return s.operator!==c.CustomFilterOperator.EQUAL?!1:{operator1:c.CustomFilterOperator.EQUAL,val1:s.val.toString()}}},t.NOT_EQUAL={label:"sheets-filter.conditions.not-equal",operator:c.CustomFilterOperator.NOT_EQUALS,numOfParameters:1,order:A.FIRST,getDefaultFormParams:()=>({operator1:c.CustomFilterOperator.NOT_EQUALS,val1:""}),testMappingParams:i=>{const[s]=H(i);return s===c.CustomFilterOperator.NOT_EQUALS},mapToFilterColumn:i=>({customFilters:{customFilters:[{val:i.val1,operator:c.CustomFilterOperator.NOT_EQUALS}]}}),testMappingFilterColumn:i=>{var a;if(((a=i.customFilters)==null?void 0:a.customFilters.length)!==1)return!1;const s=i.customFilters.customFilters[0];return s.operator!==c.CustomFilterOperator.NOT_EQUALS?!1:{operator1:c.CustomFilterOperator.NOT_EQUALS,val1:s.val.toString()}}},t.BETWEEN={label:"sheets-filter.conditions.between",operator:T.BETWEEN,order:A.SECOND,numOfParameters:2,getDefaultFormParams:()=>({and:!0,operator1:c.CustomFilterOperator.GREATER_THAN_OR_EQUAL,val1:"",operator2:c.CustomFilterOperator.LESS_THAN_OR_EQUAL,val2:""}),testMappingParams:i=>{const{and:s,operator1:a,operator2:h}=i;if(!s)return!1;const m=[a,h];return m.includes(c.CustomFilterOperator.GREATER_THAN_OR_EQUAL)&&m.includes(c.CustomFilterOperator.LESS_THAN_OR_EQUAL)},mapToFilterColumn:i=>{const{val1:s,val2:a,operator1:h}=i,m=h===c.CustomFilterOperator.GREATER_THAN_OR_EQUAL;return{customFilters:{and:u.BooleanNumber.TRUE,customFilters:[{val:m?s:a,operator:c.CustomFilterOperator.GREATER_THAN_OR_EQUAL},{val:m?a:s,operator:c.CustomFilterOperator.LESS_THAN_OR_EQUAL}]}}},testMappingFilterColumn:i=>{var h;if(((h=i.customFilters)==null?void 0:h.customFilters.length)!==2)return!1;const[s,a]=i.customFilters.customFilters;return s.operator===c.CustomFilterOperator.GREATER_THAN_OR_EQUAL&&a.operator===c.CustomFilterOperator.LESS_THAN_OR_EQUAL&&i.customFilters.and?{and:!0,operator1:c.CustomFilterOperator.GREATER_THAN_OR_EQUAL,val1:s.val.toString(),operator2:c.CustomFilterOperator.LESS_THAN_OR_EQUAL,val2:a.val.toString()}:a.operator===c.CustomFilterOperator.GREATER_THAN_OR_EQUAL&&s.operator===c.CustomFilterOperator.LESS_THAN_OR_EQUAL&&i.customFilters.and?{and:!0,operator1:c.CustomFilterOperator.GREATER_THAN_OR_EQUAL,val1:a.val.toString(),operator2:c.CustomFilterOperator.LESS_THAN_OR_EQUAL,val2:s.val.toLocaleString()}:!1}},t.NOT_BETWEEN={label:"sheets-filter.conditions.not-between",operator:T.NOT_BETWEEN,order:A.SECOND,numOfParameters:2,getDefaultFormParams:()=>({operator1:c.CustomFilterOperator.LESS_THAN,val1:"",operator2:c.CustomFilterOperator.GREATER_THAN,val2:""}),testMappingParams:i=>{const{and:s,operator1:a,operator2:h}=i;if(s)return!1;const m=[a,h];return m.includes(c.CustomFilterOperator.GREATER_THAN)&&m.includes(c.CustomFilterOperator.LESS_THAN)},mapToFilterColumn:i=>{const{val1:s,val2:a,operator1:h}=i,m=h===c.CustomFilterOperator.GREATER_THAN;return{customFilters:{customFilters:[{val:m?s:a,operator:c.CustomFilterOperator.GREATER_THAN},{val:m?a:s,operator:c.CustomFilterOperator.LESS_THAN}]}}},testMappingFilterColumn:i=>{var h;if(((h=i.customFilters)==null?void 0:h.customFilters.length)!==2)return!1;const[s,a]=i.customFilters.customFilters;return s.operator===c.CustomFilterOperator.LESS_THAN&&a.operator===c.CustomFilterOperator.GREATER_THAN&&!i.customFilters.and?{operator1:c.CustomFilterOperator.LESS_THAN,val1:s.val.toString(),operator2:c.CustomFilterOperator.GREATER_THAN,val2:a.val.toString()}:a.operator===c.CustomFilterOperator.LESS_THAN&&s.operator===c.CustomFilterOperator.GREATER_THAN&&!i.customFilters.and?{operator1:c.CustomFilterOperator.GREATER_THAN,val1:a.val.toString(),operator2:c.CustomFilterOperator.LESS_THAN,val2:s.val.toLocaleString()}:!1}},t.CUSTOM={label:"sheets-filter.conditions.custom",operator:T.CUSTOM,order:A.SECOND,numOfParameters:2,getDefaultFormParams:()=>({operator1:T.NONE,val1:"",operator2:T.NONE,val2:""}),testMappingParams:()=>!0,mapToFilterColumn:i=>{const{and:s,val1:a,val2:h,operator1:m,operator2:p}=i;function y(L,w){for(const M of t.ALL_CONDITIONS)if(M.operator===L)return M.mapToFilterColumn({val1:w,operator1:L})}const S=!m||m===t.NONE.operator,C=!p||p===t.NONE.operator;if(S&&C)return t.NONE.mapToFilterColumn({});if(S)return y(p,h);if(C)return y(m,a);const O=y(m,a),P=y(p,h),N={customFilters:[O.customFilters.customFilters[0],P.customFilters.customFilters[0]]};return s&&(N.and=u.BooleanNumber.TRUE),{customFilters:N}},testMappingFilterColumn:i=>{var h;if(((h=i.customFilters)==null?void 0:h.customFilters.length)!==2)return!1;const s=i.customFilters.customFilters.map(m=>l({customFilters:{customFilters:[m]}})),a={operator1:s[0][0].operator,val1:s[0][1].val1,operator2:s[1][0].operator,val2:s[1][1].val1};return i.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(i){const s=t.ALL_CONDITIONS.find(a=>a.operator===i);if(!s)throw new Error(`[SheetsFilter]: no condition item found for operator: ${i}`);return s}t.getItemByOperator=e;function r(i,s){for(const a of t.ALL_CONDITIONS.filter(h=>h.numOfParameters===s))if(a.numOfParameters!==0&&a.testMappingParams(i))return a;for(const a of t.ALL_CONDITIONS)if(a.testMappingParams(i))return a;throw new Error("[SheetsFilter]: no condition item can be mapped from the filter map params!")}t.testMappingParams=r;function n(i){const s=t.ALL_CONDITIONS.find(a=>a.operator===i);return(s==null?void 0:s.numOfParameters)===0?{operator1:s.operator}:s.getDefaultFormParams()}t.getInitialFormParams=n;function o(i,s){return i.mapToFilterColumn(s)}t.mapToFilterColumn=o;function l(i){if(!i)return[t.NONE,{}];for(const s of t.ALL_CONDITIONS){const a=s.testMappingFilterColumn(i);if(a)return[s,a]}return[t.NONE,{}]}t.testMappingFilterColumn=l})(f||(f={}));function H(t){const{operator1:e,operator2:r,val1:n,val2:o}=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,n]:[r,o]}function Ie(t){const e=[],r=[];let n=0,o=0;function l(i){i.leaf&&(i.checked?(e.push(i),n+=i.count):(r.push(i),o+=i.count)),i.children&&i.children.forEach(l)}return t.forEach(l),{checkedItems:e,uncheckedItems:r,checked:n,unchecked:o}}var rt=Object.getOwnPropertyDescriptor,it=(t,e,r,n)=>{for(var o=n>1?void 0:n?rt(e,r):e,l=t.length-1,i;l>=0;l--)(i=t[l])&&(o=i(o)||o);return o},Fe=(t,e)=>(r,n)=>e(r,n,t);const Ne="sheets-filter.generate-filter-values.service",fe=u.createIdentifier(Ne),nt=["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 be=class extends u.Disposable{constructor(t,e,r){super(),this._localeService=t,this._univerInstanceService=e,this._logService=r}async getFilterValues(t){var p;const{unitId:e,subUnitId:r,filteredOutRowsByOtherColumns:n,filterColumn:o,filters:l,blankChecked:i,iterateRange:s,alreadyChecked:a}=t,h=this._univerInstanceService.getUnit(e),m=(p=this._univerInstanceService.getUnit(e))==null?void 0:p.getSheetBySheetId(r);return!h||!m?[]:(this._logService.debug("[SheetsGenerateFilterValuesService]","getFilterValues for",{unitId:e,subUnitId:r}),ke(l,this._localeService,s,m,new Set(n),o,new Set(a.map(String)),i,h.getStyles()))}};be=it([Fe(0,u.Inject(u.LocaleService)),Fe(1,u.IUniverInstanceService),Fe(2,u.ILogService)],be);function ke(t,e,r,n,o,l,i,s,a){var N,L,w,M,B,X,ne,oe,V,D;const h=new Map,m=new Map,p="yyyy-mm-dd",y=new Set(nt),S="empty",C=!t&&((l==null?void 0:l.filterBy)===c.FilterBy.COLORS||(l==null?void 0:l.filterBy)===c.FilterBy.CONDITIONS)&&((N=l.filteredOutRows)==null?void 0:N.size);let O=0;for(const x of n.iterateByColumn(r,!1,!1)){const{row:Jt,rowSpan:tt=1}=x;let se=0;for(;se<tt;){const er=Jt+se;if(o.has(er)){se++;continue}const z=x!=null&&x.value?u.extractPureTextFromCell(x.value):"";if(!z){O+=1,se+=tt;continue}const ye=(L=x.value)!=null&&L.v&&!x.value.p?(B=(M=a.get((w=x.value)==null?void 0:w.s))==null?void 0:M.n)==null?void 0:B.pattern:"",tr=ye&&u.numfmt.getFormatInfo(ye).isDate;if(ye&&tr&&y.has(ye)){const q=(X=n.getCellRaw(x.row,x.col))==null?void 0:X.v;if(!q){se++;continue}const ae=u.numfmt.format(p,q),[R,W,me]=ae.split("-").map(Number);let J=h.get(`${R}`);J||(J={title:`${R}`,key:`${R}`,children:[],count:0,leaf:!1,checked:!1},h.set(`${R}`,J),m.set(`${R}`,[`${R}`]));let Q=(ne=J.children)==null?void 0:ne.find(Ue=>Ue.key===`${R}-${W}`);Q||(Q={title:e.t(`sheets-filter.date.${W}`),key:`${R}-${W}`,children:[],count:0,leaf:!1,checked:!1},(oe=J.children)==null||oe.push(Q),m.set(`${R}-${W}`,[`${R}`,`${R}-${W}`]));const $e=(V=Q==null?void 0:Q.children)==null?void 0:V.find(Ue=>Ue.key===`${R}-${W}-${me}`);$e?($e.originValues.add(z),$e.count++,Q.count++,J.count++):((D=Q.children)==null||D.push({title:`${me}`,key:`${R}-${W}-${me}`,count:1,originValues:new Set([z]),leaf:!0,checked:C?!1:i.size?i.has(z):!s}),Q.count++,J.count++,m.set(`${R}-${W}-${me}`,[`${R}`,`${R}-${W}`,`${R}-${W}-${me}`]))}else{const q=z;let ae=h.get(q);ae?ae.count++:(ae={title:z,leaf:!0,checked:C?!1:i.size?i.has(z):!s,key:q,count:1},h.set(q,ae),m.set(q,[q]))}se++}}const P=C?!1:t?s:!0;if(O>0){const x={title:e.t("sheets-filter.panel.empty"),count:O,leaf:!0,checked:P,key:S};h.set("empty",x),m.set("empty",[S])}return{filterTreeItems:ot(Array.from(h.values())),filterTreeMapCache:m}}function ot(t){return Array.from(t).sort((e,r)=>e.children&&!r.children?-1:!e.children&&r.children?1:st(e.title,r.title)).map(e=>(e.children&&e.children.sort((r,n)=>{const o=Number.parseInt(r.key.split("-")[1],10),l=Number.parseInt(n.key.split("-")[1],10);return o-l}).forEach(r=>{r.children&&r.children.sort((n,o)=>{const l=Number.parseInt(n.key.split("-")[2],10),i=Number.parseInt(o.key.split("-")[2],10);return l-i})}),e))}const Be=t=>!Number.isNaN(Number(t))&&!Number.isNaN(Number.parseFloat(t));function st(t,e){const r=Be(t),n=Be(e);return r&&n?Number.parseFloat(t)-Number.parseFloat(e):r&&!n?-1:!r&&n?1:t.localeCompare(e)}function Pe(t,e){for(const r of t){if(r.key===e)return r;if(r.children){const n=Pe(r.children,e);if(n)return n}}return null}function De(t){return t.leaf?t.checked:t.children?t.children.every(e=>De(e)):!0}function le(t,e){t.leaf&&(e!==void 0?t.checked=e:t.checked=!t.checked),t.children&&t.children.forEach(r=>le(r,e))}function xe(t,e){const r=[];return t.forEach(n=>{const o=n.originValues?e.some(s=>Array.from(n.originValues).some(a=>a.toLowerCase().includes(s.toLowerCase()))):!1,l=!o&&e.some(s=>n.title.toLowerCase().includes(s.toLowerCase()));if(o||l)r.push({...n});else if(n.children){const s=xe(n.children,e);if(s.length>0){const a=s.reduce((h,m)=>h+m.count,0);r.push({...n,count:a,children:s})}}}),r}var at=Object.getOwnPropertyDescriptor,ve=(t,e,r,n)=>{for(var o=n>1?void 0:n?at(e,r):e,l=t.length-1,i;l>=0;l--)(i=t[l])&&(o=i(o)||o);return o},ce=(t,e)=>(r,n)=>e(r,n,t);u.createIdentifier("sheets-filter-ui.sheets-filter-panel.service");let G=class extends u.Disposable{constructor(e,r){super();v(this,"_filterBy$",new g.BehaviorSubject(c.FilterBy.VALUES));v(this,"filterBy$",this._filterBy$.asObservable());v(this,"_filterByModel$",new g.ReplaySubject(1));v(this,"filterByModel$",this._filterByModel$.asObservable());v(this,"_filterByModel",null);v(this,"_hasCriteria$",new g.BehaviorSubject(!1));v(this,"hasCriteria$",this._hasCriteria$.asObservable());v(this,"_filterModel",null);v(this,"_col$",new g.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 n=e.getFilterColumn(r);if(n){const o=n.getColumnData();if(o.customFilters){this._hasCriteria$.next(!0),this._setupByConditions(e,r);return}if(o.colorFilters){this._hasCriteria$.next(!0),this._setupByColors(e,r);return}if(o.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){if(!this._filterModel||this.col===-1)return!1;switch(e){case c.FilterBy.VALUES:this._setupByValues(this._filterModel,this.col);break;case c.FilterBy.COLORS:this._setupByColors(this._filterModel,this.col);break;case c.FilterBy.CONDITIONS:this._setupByConditions(this._filterModel,this.col);break}return!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 n=e.unitId,o=e.subUnitId,l=e.getRange(),i={startColumn:r,startRow:l.startRow,endRow:l.startRow,endColumn:r};this._filterHeaderListener=this._refRangeService.watchRange(n,o,i,(s,a)=>{if(!a)this.terminate();else{const h=a.startColumn-s.startColumn;h!==0&&this._filterByModel.deltaCol(h)}})}async _setupByValues(e,r){this._disposePreviousModel();const n=e.getRange();if(n.startRow===n.endRow)return!1;const o=await ge.fromFilterColumn(this._injector,e,r);return this.filterByModel=o,this._filterBy$.next(c.FilterBy.VALUES),this._listenToFilterHeaderChange(e,r),!0}async _setupByColors(e,r){this._disposePreviousModel();const n=e.getRange();if(n.startRow===n.endRow)return!1;const o=await Se.fromFilterColumn(this._injector,e,r);return this.filterByModel=o,this._filterBy$.next(c.FilterBy.COLORS),this._listenToFilterHeaderChange(e,r),!0}_setupByConditions(e,r){this._disposePreviousModel();const n=e.getRange();if(n.startRow===n.endRow)return!1;const o=_e.fromFilterColumn(this._injector,e,r,e.getFilterColumn(r));return this.filterByModel=o,this._filterBy$.next(c.FilterBy.CONDITIONS),this._listenToFilterHeaderChange(e,r),!0}_disposePreviousModel(){var e;(e=this._filterByModel)==null||e.dispose(),this.filterByModel=null}};G=ve([ce(0,u.Inject(u.Injector)),ce(1,u.Inject(F.RefRangeService))],G);let _e=class extends u.Disposable{constructor(e,r,n,o,l){super();v(this,"canApply$",g.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 g.BehaviorSubject(n),this.conditionItem$=this._conditionItem$.asObservable(),this._filterConditionFormParams$=new g.BehaviorSubject(o),this.filterConditionFormParams$=this._filterConditionFormParams$.asObservable()}static fromFilterColumn(e,r,n,o){const[l,i]=f.testMappingFilterColumn(o==null?void 0:o.getColumnData());return e.createInstance(_e,r,n,l,i)}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=f.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=f.ALL_CONDITIONS.find(n=>n.operator===e);if(!r)throw new Error(`[ByConditionsModel]: condition item not found for operator: ${e}!`);this._conditionItem$.next(r),this._filterConditionFormParams$.next(f.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 n=f.testMappingParams(r,this.conditionItem.numOfParameters);this._conditionItem$.next(n)}this._filterConditionFormParams$.next(r)}};_e=ve([ce(4,u.ICommandService)],_e);let ge=class extends u.Disposable{constructor(e,r,n,o,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=o,this._searchString$=new g.BehaviorSubject(""),this.searchString$=this._searchString$.asObservable(),this._rawFilterItems$=new g.BehaviorSubject(n),this.rawFilterItems$=this._rawFilterItems$.asObservable(),this._manuallyUpdateFilterItems$=new g.Subject,this.filterItems$=g.merge(g.combineLatest([this._searchString$.pipe(g.throttleTime(500,void 0,{leading:!0,trailing:!0}),g.startWith(void 0)),this._rawFilterItems$]).pipe(g.map(([i,s])=>{if(!i)return s;const h=i.toLowerCase().split(/\s+/).filter(m=>!!m);return xe(s,h)})),this._manuallyUpdateFilterItems$).pipe(g.shareReplay(1)),this.canApply$=this.filterItems$.pipe(g.map(i=>Ie(i).checked>0)),this.disposeWithMe(this.filterItems$.subscribe(i=>this._filterItems=i))}static async fromFilterColumn(e,r,n){const o=e.get(u.IUniverInstanceService),l=e.get(u.LocaleService),i=e.get(fe,u.Quantity.OPTIONAL),{unitId:s,subUnitId:a}=r,h=o.getUniverSheetInstance(s);if(!h)throw new Error(`[ByValuesModel]: Workbook not found for filter model with unitId: ${s}!`);const m=h==null?void 0:h.getSheetBySheetId(a);if(!m)throw new Error(`[ByValuesModel]: Worksheet not found for filter model with unitId: ${s} and subUnitId: ${a}!`);const p=r.getRange(),y=n,S=r.getFilterColumn(n),C=S==null?void 0:S.getColumnData().filters,O=new Set(C==null?void 0:C.filters),P=!!(C&&C.blank),N=r.getFilteredOutRowsExceptCol(n),L={...p,startRow:p.startRow+1,startColumn:y,endColumn:y};let w,M;if(i){const B=await i.getFilterValues({unitId:s,subUnitId:a,filteredOutRowsByOtherColumns:Array.from(N),filterColumn:S,filters:!!C,blankChecked:P,iterateRange:L,alreadyChecked:Array.from(O)});w=B.filterTreeItems,M=B.filterTreeMapCache}else{const B=ke(!!C,l,L,m,N,S,O,P,h.getStyles());w=B.filterTreeItems,M=B.filterTreeMapCache}return e.createInstance(ge,r,n,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=u.Tools.deepClone(this._filterItems);r.forEach(n=>le(n,e)),this._manuallyUpdateFilterItems(r)}onFilterCheckToggled(e){const r=u.Tools.deepClone(this._filterItems),n=Pe(r,e.key);if(!n)return;const o=De(n);le(n,!o),this._manuallyUpdateFilterItems(r)}onFilterOnly(e){const r=u.Tools.deepClone(this._filterItems);r.forEach(n=>le(n,!1)),e.forEach(n=>{const o=Pe(r,n);o&&le(o,!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=Ie(this._filterItems),{checked:r,checkedItems:n}=e,o=this.rawFilterItems;let l=0;for(const h of o)l+=h.count;const i=r===0,s=e.checked===l,a={colId:this.col};if(i)throw new Error("[ByValuesModel]: no checked items!");if(s)return this._commandService.executeCommand(c.SetSheetsFilterCriteriaCommand.id,{unitId:this._filterModel.unitId,subUnitId:this._filterModel.subUnitId,col:this.col,criteria:null});{a.filters={};const h=n.filter(p=>p.key!=="empty");h.length>0&&(a.filters={filters:h.flatMap(p=>p.originValues?Array.from(p.originValues):[p.title])}),h.length!==n.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})}};ge=ve([ce(4,u.ICommandService)],ge);let Se=class extends u.Disposable{constructor(e,r,n,o,l){super();v(this,"canApply$",g.of(!0));v(this,"_cellFillColors$");v(this,"cellFillColors$");v(this,"_cellTextColors$");v(this,"cellTextColors$");this._filterModel=e,this.col=r,this._commandService=l,this._cellFillColors$=new g.BehaviorSubject(Array.from(n.values())),this.cellFillColors$=this._cellFillColors$.asObservable(),this._cellTextColors$=new g.BehaviorSubject(Array.from(o.values())),this.cellTextColors$=this._cellTextColors$.asObservable()}static async fromFilterColumn(e,r,n){var L,w,M;const o=e.get(u.IUniverInstanceService),{unitId:l,subUnitId:i}=r,s=o.getUniverSheetInstance(l);if(!s)throw new Error(`[ByColorsModel]: Workbook not found for filter model with unitId: ${l}!`);const a=s==null?void 0:s.getSheetBySheetId(i);if(!a)throw new Error(`[ByColorsModel]: Worksheet not found for filter model with unitId: ${l} and subUnitId: ${i}!`);const h=r.getRange(),m=n,p=(L=r.getFilterColumn(n))==null?void 0:L.getColumnData().colorFilters,y=r.getFilteredOutRowsExceptCol(n),S={...h,startRow:h.startRow+1,startColumn:m,endColumn:m},C=new Map,O=new Set((w=p==null?void 0:p.cellFillColors)!=null?w:[]),P=new Map,N=new Set((M=p==null?void 0:p.cellTextColors)!=null?M:[]);for(const B of a.iterateByColumn(S,!1,!0)){const{row:X,col:ne,value:oe}=B;if(y.has(X))continue;const V=a.getComposedCellStyleByCellData(X,ne,oe);if(V.bg&&V.bg.rgb){const D=new u.ColorKit(V.bg.rgb).toRgbString();C.has(D)||C.set(D,{color:D,checked:O.has(D)})}else C.set("default-fill-color",{color:null,checked:O.has(null)});if(V.cl&&V.cl.rgb){const D=new u.ColorKit(V.cl.rgb).toRgbString();P.has(D)||P.set(D,{color:D,checked:N.has(D)})}else P.set("default-font-color",{color:K.COLOR_BLACK_RGB,checked:N.has(K.COLOR_BLACK_RGB)})}return e.createInstance(Se,r,n,C,P)}get cellFillColors(){return this._cellFillColors$.getValue()}get cellTextColors(){return this._cellTextColors$.getValue()}dispose(){super.dispose(),this._cellFillColors$.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})}onFilterCheckToggled(e,r=!0){const n=r?this.cellFillColors:this.cellTextColors,o=[];let l=!1;for(let i=0;i<n.length;i++){const s=n[i];if(s.color===e.color){l=!0,o.push({color:s.color,checked:!s.checked});continue}o.push({color:s.color,checked:s.checked})}l&&(this._resetColorsCheckedStatus(!r),r?this._cellFillColors$.next([...o]):this._cellTextColors$.next([...o]))}_resetColorsCheckedStatus(e=!0){const r=e?this.cellFillColors:this.cellTextColors,n=[];for(let o=0;o<r.length;o++)n.push({color:r[o].color,checked:!1});e?this._cellFillColors$.next([...n]):this._cellTextColors$.next([...n])}async apply(){if(this._disposed)return!1;const e=this.cellFillColors.filter(o=>o.checked).map(o=>o.color),r=this.cellTextColors.filter(o=>o.checked).map(o=>o.color);if(e.length===0&&r.length===0)return this._commandService.executeCommand(c.SetSheetsFilterCriteriaCommand.id,{unitId:this._filterModel.unitId,subUnitId:this._filterModel.subUnitId,col:this.col,criteria:null});const n={colId:this.col};return e.length>0?n.colorFilters={cellFillColors:e}:r.length>0&&(n.colorFilters={cellTextColors:r}),this._commandService.executeCommand(c.SetSheetsFilterCriteriaCommand.id,{unitId:this._filterModel.unitId,subUnitId:this._filterModel.subUnitId,col:this.col,criteria:n})}};Se=ve([ce(4,u.ICommandService)],Se);const ee="FILTER_PANEL_OPENED",ue={id:"sheet.operation.open-filter-panel",type:u.CommandType.OPERATION,handler:(t,e)=>{const r=t.get(u.IContextService),n=t.get(c.SheetsFilterService),o=t.get(G);t.get(u.ICommandService).syncExecuteCommand($.SetCellEditVisibleOperation.id,{visible:!1});const{unitId:i,subUnitId:s,col:a}=e,h=n.getFilterModel(i,s);return h?(o.setupCol(h,a),r.getContextValue(ee)||r.setContextValue(ee,!0),!0):!1}},te={id:"sheet.operation.close-filter-panel",type:u.CommandType.OPERATION,handler:t=>{const e=t.get(u.IContextService),r=t.get(G),n=t.get(E.ILayoutService,u.Quantity.OPTIONAL);return e.getContextValue(ee)?(e.setContextValue(ee,!1),n==null||n.focus(),r.terminate()):!1}},Ae={id:"sheet.operation.apply-filter",type:u.CommandType.OPERATION,handler:(t,e)=>{const{filterBy:r}=e;return t.get(G).changeFilterBy(r)}},He="sheets-filter-ui.config",Ce={};var lt=Object.getOwnPropertyDescriptor,ct=(t,e,r,n)=>{for(var o=n>1?void 0:n?lt(e,r):e,l=t.length-1,i;l>=0;l--)(i=t[l])&&(o=i(o)||o);return o},re=(t,e)=>(r,n)=>e(r,n,t);let ie=class extends u.Disposable{constructor(t,e,r,n,o,l){super(),this._sheetsFilterService=t,this._localeService=e,this._commandService=r,this._sheetPermissionCheckPermission=n,this._injector=o,this._sheetsSelectionService=l,this._commandExecutedListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.beforeCommandExecuted(t=>{var e,r,n;if(t.id===c.SmartToggleSheetsFilterCommand.id){const o=this._injector.get(u.IUniverInstanceService),l=F.getSheetCommandTarget(o);if(!l)return;const{unitId:i,subUnitId:s,worksheet:a}=l,h=(e=this._sheetsFilterService.getFilterModel(i,s))==null?void 0:e.getRange();let m;if(h)m=this._sheetPermissionCheckPermission.permissionCheckWithRanges({rangeTypes:[F.RangeProtectionPermissionViewPoint],worksheetTypes:[F.WorksheetFilterPermission,F.WorksheetViewPermission]},[h]);else{const p=(r=this._sheetsSelectionService.getCurrentLastSelection())==null?void 0:r.range;if(p){let y={...p};y=p.startColumn===p.endColumn&&p.startRow===p.endRow?F.expandToContinuousRange(y,{left:!0,right:!0,up:!0,down:!0},a):y,m=this._sheetPermissionCheckPermission.permissionCheckWithRanges({rangeTypes:[F.RangeProtectionPermissionViewPoint],worksheetTypes:[F.WorksheetViewPermission,F.WorksheetFilterPermission]},[y],i,s)}else m=this._sheetPermissionCheckPermission.permissionCheckWithoutRange({rangeTypes:[F.RangeProtectionPermissionViewPoint],worksheetTypes:[F.WorksheetViewPermission,F.WorksheetFilterPermission]})}m||this._sheetPermissionCheckPermission.blockExecuteWithoutPermission(this._localeService.t("permission.dialog.filterErr"))}if(t.id===ue.id){const o=t.params,{unitId:l,subUnitId:i}=o,s=(n=this._sheetsFilterService.getFilterModel(l,i))==null?void 0:n.getRange(),a=u.Tools.deepClone(s);a&&(a.startColumn=o.col,a.endColumn=o.col,this._sheetPermissionCheckPermission.permissionCheckWithRanges({rangeTypes:[F.RangeProtectionPermissionViewPoint],worksheetTypes:[F.WorksheetFilterPermission,F.WorksheetViewPermission]},[a])||this._sheetPermissionCheckPermission.blockExecuteWithoutPermission(this._localeService.t("permission.dialog.filterErr")))}}))}};ie=ct([re(0,u.Inject(c.SheetsFilterService)),re(1,u.Inject(u.LocaleService)),re(2,u.ICommandService),re(3,u.Inject(F.SheetPermissionCheckController)),re(4,u.Inject(u.Injector)),re(5,u.Inject(F.SheetsSelectionsService))],ie);const Y=16,ut=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 We{static drawNoCriteria(e,r,n,o){e.save(),K.Rect.drawWith(e,{radius:2,width:Y,height:Y,fill:o}),e.lineCap="square",e.strokeStyle=n,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,n,o){e.save(),K.Rect.drawWith(e,{radius:2,width:Y,height:Y,fill:o}),e.scale(r/Y,r/Y),e.fillStyle=n,e.fill(ut),e.restore()}}var ht=Object.getOwnPropertyDescriptor,dt=(t,e,r,n)=>{for(var o=n>1?void 0:n?ht(e,r):e,l=t.length-1,i;l>=0;l--)(i=t[l])&&(o=i(o)||o);return o},we=(t,e)=>(r,n)=>e(r,n,t);const j=16,Te=1;let Re=class extends K.Shape{constructor(e,r,n,o,l){super(e,r);v(this,"_cellWidth",0);v(this,"_cellHeight",0);v(this,"_filterParams");v(this,"_hovered",!1);this._contextService=n,this._commandService=o,this._themeService=l,this.setShapeProps(r),this.onPointerDown$.subscribeEvent(i=>this.onPointerDown(i)),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,n=this._cellWidth,o=j-n,l=j-r;e.save();const i=new Path2D;i.rect(o,l,n,r),e.clip(i);const{hasCriteria:s}=this._filterParams,a=this._themeService.getColorFromTheme("primary.600"),h=this._hovered?this._themeService.getColorFromTheme("gray.50"):"rgba(255, 255, 255, 1.0)";s?We.drawHasCriteria(e,j,a,h):We.drawNoCriteria(e,j,a,h),e.restore()}onPointerDown(e){if(e.button===2)return;const{col:r,unitId:n,subUnitId:o}=this._filterParams;this._contextService.getContextValue(ee)||!this._commandService.hasCommand(ue.id)||setTimeout(()=>{this._commandService.executeCommand(ue.id,{unitId:n,subUnitId:o,col:r})},200)}onPointerEnter(){this._hovered=!0,this.makeDirty(!0)}onPointerLeave(){this._hovered=!1,this.makeDirty(!0)}};Re=dt([we(2,u.IContextService),we(3,u.ICommandService),we(4,u.Inject(u.ThemeService))],Re);var mt=Object.getOwnPropertyDescriptor,pt=(t,e,r,n)=>{for(var o=n>1?void 0:n?mt(e,r):e,l=t.length-1,i;l>=0;l--)(i=t[l])&&(o=i(o)||o);return o},Z=(t,e)=>(r,n)=>e(r,n,t);const ft=1e3,vt=5e3;let Le=class extends u.RxDisposable{constructor(e,r,n,o,l,i,s,a){super();v(this,"_filterRangeShape",null);v(this,"_buttonRenderDisposable",null);v(this,"_filterButtonShapes",[]);this._context=e,this._injector=r,this._sheetSkeletonManagerService=n,this._sheetsFilterService=o,this._themeService=l,this._sheetInterceptorService=i,this._commandService=s,this._selectionRenderService=a,this._initRenderer()}dispose(){super.dispose(),this._disposeRendering()}_initRenderer(){this._sheetSkeletonManagerService.currentSkeleton$.pipe(g.switchMap(e=>{var s,a;if(!e)return g.of(null);const{unit:r,unitId:n}=this._context,o=((s=r.getActiveSheet())==null?void 0:s.getSheetId())||"",l=(a=this._sheetsFilterService.getFilterModel(n,o))!=null?a:void 0,i=()=>({unitId:n,worksheetId:o,filterModel:l,range:l==null?void 0:l.getRange(),skeleton:e.skeleton});return u.fromCallback(this._commandService.onCommandExecuted.bind(this._commandService)).pipe(g.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===F.SetRangeValuesMutation.id)}),g.throttleTime(20,void 0,{leading:!1,trailing:!0}),g.map(i),g.startWith(i()))}),g.takeUntil(this.dispose$)).subscribe(e=>{this._disposeRendering(),!(!e||!e.range)&&(this._renderRange(e.range,e.skeleton),this._renderButtons(e))})}_renderRange(e,r){const{scene:n}=this._context,{rowHeaderWidth:o,columnHeaderHeight:l}=r,i=this._filterRangeShape=new $.SelectionControl(n,ft,this._themeService,{rowHeaderWidth:o,columnHeaderHeight:l,enableAutoFill:!1,highlightHeader:!1}),s={range:e,primary:null,style:{fill:"rgba(0, 0, 0, 0.0)"}},a=$.attachSelectionWithCoord(s,r);i.updateRangeBySelectionWithCoord(a),i.setEvent(!1),n.makeDirty(!0)}_renderButtons(e){const{range:r,filterModel:n,unitId:o,skeleton:l,worksheetId:i}=e,{scene:s}=this._context;this._interceptCellContent(o,i,e.range);const{startColumn:a,endColumn:h,startRow:m}=r;for(let p=a;p<=h;p++){const y=`sheets-filter-button-${p}`,S=$.getCoordByCell(m,p,s,l),{startX:C,startY:O,endX:P,endY:N}=S,L=P-C,w=N-O;if(w<=Te||L<=Te)continue;const M=!!n.getFilterColumn(p),B=P-j-Te,X=N-j-Te,ne={left:B,top:X,height:j,width:j,zIndex:vt,cellHeight:w,cellWidth:L,filterParams:{unitId:o,subUnitId:i,col:p,hasCriteria:M}},oe=this._injector.createInstance(Re,y,ne);this._filterButtonShapes.push(oe)}s.addObjects(this._filterButtonShapes),s.makeDirty()}_interceptCellContent(e,r,n){const{startRow:o,startColumn:l,endColumn:i}=n;this._buttonRenderDisposable=this._sheetInterceptorService.intercept(F.INTERCEPTOR_POINT.CELL_CONTENT,{effect:u.InterceptorEffectEnum.Style,handler:(s,a,h)=>{const{row:m,col:p,unitId:y,subUnitId:S}=a;return y!==e||S!==r||m!==o||p<l||p>i||((!s||s===a.rawData)&&(s={...a.rawData}),s.fontRenderExtension={...s==null?void 0:s.fontRenderExtension,rightOffset:j}),h(s)},priority:10})}_disposeRendering(){var e,r;(e=this._filterRangeShape)==null||e.dispose(),this._filterButtonShapes.forEach(n=>n.dispose()),(r=this._buttonRenderDisposable)==null||r.dispose(),this._filterRangeShape=null,this._buttonRenderDisposable=null,this._filterButtonShapes=[]}};Le=pt([Z(1,u.Inject(u.Injector)),Z(2,u.Inject($.SheetSkeletonManagerService)),Z(3,u.Inject(c.SheetsFilterService)),Z(4,u.Inject(u.ThemeService)),Z(5,u.Inject(F.SheetInterceptorService)),Z(6,u.ICommandService),Z(7,$.ISheetSelectionRenderService)],Le);var _t=Object.getOwnPropertyDescriptor,gt=(t,e,r,n)=>{for(var o=n>1?void 0:n?_t(e,r):e,l=t.length-1,i;l>=0;l--)(i=t[l])&&(o=i(o)||o);return o},je=(t,e)=>(r,n)=>e(r,n,t);let he=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]))}};he=gt([je(0,K.IRenderManagerService),je(1,u.Inject($.SheetsRenderService))],he);var St=Object.defineProperty,Ct=Object.getOwnPropertyDescriptor,Tt=(t,e,r)=>e in t?St(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Et=(t,e,r,n)=>{for(var o=n>1?void 0:n?Ct(e,r):e,l=t.length-1,i;l>=0;l--)(i=t[l])&&(o=i(o)||o);return o},Ve=(t,e)=>(r,n)=>e(r,n,t),Qe=(t,e,r)=>Tt(t,typeof e!="symbol"?e+"":e,r);const Ot="SHEET_FILTER_UI_PLUGIN";_.UniverSheetsFilterMobileUIPlugin=class extends u.Plugin{constructor(e=Ce,r,n){super(),this._config=e,this._injector=r,this._configService=n;const{menu:o,...l}=u.merge({},Ce,this._config);o&&this._configService.setConfig("menu",o,{merge:!0}),this._configService.setConfig(He,l)}onStarting(){[[ie],[he]].forEach(e=>this._injector.add(e))}onReady(){this._injector.get(ie)}onRendered(){this._injector.get(he)}},Qe(_.UniverSheetsFilterMobileUIPlugin,"type",u.UniverInstanceType.UNIVER_SHEET),Qe(_.UniverSheetsFilterMobileUIPlugin,"pluginName",Ot),_.UniverSheetsFilterMobileUIPlugin=Et([u.DependentOn(c.UniverSheetsFilterPlugin),Ve(1,u.Inject(u.Injector)),Ve(2,u.IConfigService)],_.UniverSheetsFilterMobileUIPlugin);var k=function(){return k=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++){e=arguments[r];for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o])}return t},k.apply(this,arguments)},yt=function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,n=Object.getOwnPropertySymbols(t);o<n.length;o++)e.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(t,n[o])&&(r[n[o]]=t[n[o]]);return r},de=I.forwardRef(function(t,e){var r=t.icon,n=t.id,o=t.className,l=t.extend,i=yt(t,["icon","id","className","extend"]),s="univerjs-icon univerjs-icon-".concat(n," ").concat(o||"").trim(),a=I.useRef("_".concat(Nt()));return Ge(r,"".concat(n),{defIds:r.defIds,idSuffix:a.current},k({ref:e,className:s},i),l)});function Ge(t,e,r,n,o){return I.createElement(t.tag,k(k({key:e},It(t,r,o)),n),(Ft(t,r).children||[]).map(function(l,i){return Ge(l,"".concat(e,"-").concat(t.tag,"-").concat(i),r,void 0,o)}))}function It(t,e,r){var n=k({},t.attrs);r!=null&&r.colorChannel1&&n.fill==="colorChannel1"&&(n.fill=r.colorChannel1),t.tag==="mask"&&n.id&&(n.id=n.id+e.idSuffix),Object.entries(n).forEach(function(l){var i=l[0],s=l[1];i==="mask"&&typeof s=="string"&&(n[i]=s.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))});var o=e.defIds;return!o||o.length===0||(t.tag==="use"&&n["xlink:href"]&&(n["xlink:href"]=n["xlink:href"]+e.idSuffix),Object.entries(n).forEach(function(l){var i=l[0],s=l[1];typeof s=="string"&&(n[i]=s.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))})),n}function Ft(t,e){var r,n=e.defIds;return!n||n.length===0?t:t.tag==="defs"&&(!((r=t.children)===null||r===void 0)&&r.length)?k(k({},t),{children:t.children.map(function(o){return typeof o.attrs.id=="string"&&n&&n.includes(o.attrs.id)?k(k({},o),{attrs:k(k({},o.attrs),{id:o.attrs.id+e.idSuffix})}):o})}):t}function Nt(){return Math.random().toString(36).substring(2,8)}de.displayName="UniverIcon";var bt={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 20 20",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M10 1.05957C10.356 1.05957 10.6816 1.26162 10.8408 1.58008L18.8408 17.5801L18.8799 17.668C19.0486 18.1134 18.8551 18.6232 18.4199 18.8408C17.9557 19.0727 17.3913 18.8841 17.1592 18.4199L10 4.10156L2.84082 18.4199C2.60871 18.8841 2.04434 19.0727 1.58008 18.8408C1.11587 18.6087 0.92731 18.0443 1.15918 17.5801L9.15918 1.58008C9.31841 1.26162 9.64395 1.05957 10 1.05957Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M15.3337 11.7261L15.4294 11.731C15.9035 11.779 16.2732 12.1798 16.2732 12.6665C16.2732 13.1532 15.9035 13.554 15.4294 13.602L15.3337 13.6069H4.66675C4.1476 13.6069 3.72632 13.1856 3.72632 12.6665C3.72632 12.1474 4.1476 11.7261 4.66675 11.7261H15.3337Z"}}]},Ye=I.forwardRef(function(t,e){return I.createElement(de,Object.assign({},t,{id:"a-icon",ref:e,icon:bt}))});Ye.displayName="AIcon";var Pt={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 20 20",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M17.0596 10C17.0596 6.10087 13.8992 2.94043 10 2.94043C6.10087 2.94043 2.94043 6.10087 2.94043 10C2.94043 13.8992 6.10087 17.0596 10 17.0596C13.8992 17.0596 17.0596 13.8992 17.0596 10ZM18.9404 10C18.9404 14.9374 14.9374 18.9404 10 18.9404C5.06257 18.9404 1.05957 14.9374 1.05957 10C1.05957 5.06257 5.06257 1.05957 10 1.05957C14.9374 1.05957 18.9404 5.06257 18.9404 10Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M4.29492 4.13476C4.63911 3.79057 5.1845 3.76906 5.55371 4.07031L5.625 4.13476L16.0244 14.5352L16.0889 14.6064C16.3902 14.9757 16.3686 15.52 16.0244 15.8643C15.6573 16.2313 15.0624 16.2313 14.6953 15.8643L4.29492 5.46484L4.23047 5.39355C3.92922 5.02434 3.95073 4.47895 4.29492 4.13476Z"}}]},qe=I.forwardRef(function(t,e){return I.createElement(de,Object.assign({},t,{id:"ban-icon",ref:e,icon:Pt}))});qe.displayName="BanIcon";var At={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",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"}}]},Ke=I.forwardRef(function(t,e){return I.createElement(de,Object.assign({},t,{id:"filter-icon",ref:e,icon:At}))});Ke.displayName="FilterIcon";var wt={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M8 15C11.866 15 15 11.866 15 8C15 4.13401 11.866 1 8 1C4.13401 1 1 4.13401 1 8C1 11.866 4.13401 15 8 15ZM11.7245 6.42417C11.9588 6.18985 11.9588 5.80995 11.7245 5.57564C11.4901 5.34132 11.1102 5.34132 10.8759 5.57564L7.3002 9.15137L5.72446 7.57564C5.49014 7.34132 5.11025 7.34132 4.87593 7.57564C4.64162 7.80995 4.64162 8.18985 4.87593 8.42417L6.87593 10.4242C7.11025 10.6585 7.49014 10.6585 7.72446 10.4242L11.7245 6.42417Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Ze=I.forwardRef(function(t,e){return I.createElement(de,Object.assign({},t,{id:"success-icon",ref:e,icon:wt}))});Ze.displayName="SuccessIcon";function Rt(t){const{model:e}=t,r=E.useDependency(u.LocaleService),n=E.useObservable(e.cellFillColors$,[],!0),o=E.useObservable(e.cellTextColors$,[],!0),l=I.useCallback(s=>{e.onFilterCheckToggled(s)},[e]),i=I.useCallback(s=>{e.onFilterCheckToggled(s,!1)},[e]);return d.jsx("div",{"data-u-comp":"sheets-filter-panel-colors-container",className:"univer-flex univer-h-full univer-min-h-[300px] univer-flex-col",children:d.jsxs("div",{"data-u-comp":"sheets-filter-panel",className:b.clsx("univer-mt-2 univer-box-border univer-flex univer-h-[300px] univer-flex-grow univer-flex-col univer-gap-4 univer-overflow-auto univer-rounded-md univer-px-2 univer-py-2.5",b.borderClassName),children:[n.length>1&&d.jsxs("div",{children:[d.jsx("div",{className:"univer-mb-2 univer-text-sm univer-text-gray-900 dark:!univer-text-white",children:r.t("sheets-filter.panel.filter-by-cell-fill-color")}),d.jsx("div",{className:"univer-grid univer-grid-cols-8 univer-items-center univer-justify-start univer-gap-2",children:n.map((s,a)=>d.jsxs("div",{className:"univer-relative univer-h-6 univer-w-6",onClick:()=>l(s),children:[s.color?d.jsx("button",{type:"button",className:b.clsx("univer-box-border univer-h-6 univer-w-6 univer-cursor-pointer univer-rounded-full univer-border univer-border-solid univer-border-transparent univer-bg-gray-300 univer-transition-shadow hover:univer-ring-2 hover:univer-ring-offset-2 hover:univer-ring-offset-white"),style:{backgroundColor:s.color}}):d.jsx(qe,{className:"univer-h-6 univer-w-6 univer-cursor-pointer univer-rounded-full hover:univer-ring-2 hover:univer-ring-offset-2 hover:univer-ring-offset-white"}),s.checked&&d.jsx(Xe,{})]},`sheets-filter-cell-fill-color-${a}`))})]}),o.length>1&&d.jsxs("div",{children:[d.jsx("div",{className:"univer-mb-2 univer-text-sm univer-text-gray-900 dark:!univer-text-white",children:r.t("sheets-filter.panel.filter-by-cell-text-color")}),d.jsx("div",{className:"univer-grid univer-grid-cols-8 univer-items-center univer-justify-start univer-gap-2",children:o.map((s,a)=>d.jsxs("div",{className:"univer-relative univer-h-6 univer-w-6",onClick:()=>i(s),children:[d.jsx("div",{className:"univer-box-border univer-flex univer-h-full univer-w-full univer-cursor-pointer univer-items-center univer-justify-center univer-rounded-full univer-border univer-border-solid univer-border-[rgba(13,13,13,0.06)] univer-p-0.5 hover:univer-ring-2 hover:univer-ring-offset-2 hover:univer-ring-offset-white dark:!univer-border-[rgba(255,255,255,0.06)]",children:d.jsx(Ye,{style:{color:s.color}})}),s.checked&&d.jsx(Xe,{})]},`sheets-filter-cell-text-color-${a}`))})]}),n.length<=1&&o.length<=1&&d.jsx("div",{className:"univer-flex univer-h-full univer-w-full univer-items-center univer-justify-center univer-text-sm univer-text-gray-900 dark:!univer-text-gray-200",children:r.t("sheets-filter.panel.filter-by-color-none")})]})})}function Xe(){return d.jsx("div",{className:"univer-absolute -univer-bottom-0.5 -univer-right-0.5 univer-flex univer-h-3 univer-w-3 univer-cursor-pointer univer-items-center univer-justify-center univer-rounded-full univer-bg-white",children:d.jsx(Ze,{className:"univer-h-full univer-w-full univer-font-bold univer-text-[#418F1F]"})})}function Lt(t){var S,C;const{model:e}=t,r=E.useDependency(u.LocaleService),n=E.useObservable(e.conditionItem$,void 0),o=E.useObservable(e.filterConditionFormParams$,void 0),l=o!=null&&o.and?"AND":"OR",i=I.useCallback(O=>{e.onConditionFormChange({and:O==="AND"})},[e]),s=Mt(r),a=I.useCallback(O=>{e.onPrimaryConditionChange(O)},[e]),h=$t(r),m=I.useCallback(O=>{e.onConditionFormChange(O)},[e]),p=r.t("sheets-filter.panel.input-values-placeholder");function y(O,P,N){const L=f.getItemByOperator(O).numOfParameters===1;return d.jsxs(d.Fragment,{children:[N==="operator2"&&d.jsxs(b.RadioGroup,{value:l,onChange:i,children:[d.jsx(b.Radio,{value:"AND",children:r.t("sheets-filter.panel.and")}),d.jsx(b.Radio,{value:"OR",children:r.t("sheets-filter.panel.or")})]}),d.jsx(b.Select,{value:O,options:h,onChange:w=>m({[N]:w})}),L&&d.jsx("div",{children:d.jsx(b.Input,{className:"univer-mt-2",value:P,placeholder:p,onChange:w=>m({[N==="operator1"?"val1":"val2"]:w})})})]})}return d.jsx("div",{"data-u-comp":"sheets-filter-panel-conditions-container",className:"univer-flex univer-h-full univer-min-h-[300px] univer-flex-col",children:n&&o&&d.jsxs(d.Fragment,{children:[d.jsx(b.Select,{value:n.operator,options:s,onChange:a}),f.getItemByOperator(n.operator).numOfParameters!==0?d.jsxs("div",{"data-u-comp":"sheets-filter-panel-conditions-container-inner",className:b.clsx("univer-mt-2 univer-flex-grow univer-overflow-hidden univer-rounded-md univer-p-2",b.borderClassName),children:[n.numOfParameters>=1&&y(o.operator1,(S=o.val1)!=null?S:"","operator1"),n.numOfParameters>=2&&y(o.operator2,(C=o.val2)!=null?C:"","operator2"),d.jsxs("div",{"data-u-comp":"sheets-filter-panel-conditions-desc",className:"univer-mt-2 univer-text-xs univer-text-gray-500",children:[r.t("sheets-filter.panel.?"),d.jsx("br",{}),r.t("sheets-filter.panel.*")]})]}):null]})})}function Mt(t){const e=t.getCurrentLocale();return I.useMemo(()=>[{options:[{label:t.t(f.NONE.label),value:f.NONE.operator}]},{options:[{label:t.t(f.EMPTY.label),value:f.EMPTY.operator},{label:t.t(f.NOT_EMPTY.label),value:f.NOT_EMPTY.operator}]},{options:[{label:t.t(f.TEXT_CONTAINS.label),value:f.TEXT_CONTAINS.operator},{label:t.t(f.DOES_NOT_CONTAIN.label),value:f.DOES_NOT_CONTAIN.operator},{label:t.t(f.STARTS_WITH.label),value:f.STARTS_WITH.operator},{label:t.t(f.ENDS_WITH.label),value:f.ENDS_WITH.operator},{label:t.t(f.EQUALS.label),value:f.EQUALS.operator}]},{options:[{label:t.t(f.GREATER_THAN.label),value:f.GREATER_THAN.operator},{label:t.t(f.GREATER_THAN_OR_EQUAL.label),value:f.GREATER_THAN_OR_EQUAL.operator},{label:t.t(f.LESS_THAN.label),value:f.LESS_THAN.operator},{label:t.t(f.LESS_THAN_OR_EQUAL.label),value:f.LESS_THAN_OR_EQUAL.operator},{label:t.t(f.EQUAL.label),value:f.EQUAL.operator},{label:t.t(f.NOT_EQUAL.label),value:f.NOT_EQUAL.operator},{label:t.t(f.BETWEEN.label),value:f.BETWEEN.operator},{label:t.t(f.NOT_BETWEEN.label),value:f.NOT_BETWEEN.operator}]},{options:[{label:t.t(f.CUSTOM.label),value:f.CUSTOM.operator}]}],[e,t])}function $t(t){const e=t.getCurrentLocale();return I.useMemo(()=>f.ALL_CONDITIONS.filter(r=>r.numOfParameters!==2).map(r=>({label:t.t(r.label),value:r.operator})),[e,t])}function Ut(t){const{model:e}=t,r=E.useDependency(u.LocaleService),n=E.useObservable(e.searchString$,"",!0),o=E.useObservable(e.filterItems$,void 0,!0),l=r.t("sheets-filter.panel.filter-only"),i=Ie(o),s=i.checked>0&&i.unchecked===0,a=i.checked>0&&i.unchecked>0,h=e.treeMapCache,m=I.useCallback(()=>{e.onCheckAllToggled(!s)},[e,s]),p=I.useCallback(S=>{e.setSearchString(S)},[e]);function y(S){let C=[];return S.forEach(O=>{O.checked&&C.push(O.key),O.children&&(C=C.concat(y(O.children)))}),C}return d.jsxs("div",{"data-u-comp":"sheets-filter-panel-values-container",className:"univer-flex univer-h-full univer-min-h-[300px] univer-flex-col",children:[d.jsx(b.Input,{autoFocus:!0,value:n,placeholder:r.t("sheets-filter.panel.search-placeholder"),onChange:p}),d.jsxs("div",{"data-u-comp":"sheets-filter-panel",className:b.clsx("univer-mt-2 univer-box-border univer-flex univer-flex-grow univer-flex-col univer-overflow-hidden univer-rounded-md univer-px-2 univer-py-2.5",b.borderClassName),children:[d.jsx("div",{"data-u-comp":"sheets-filter-panel-values-item",className:"univer-box-border univer-h-8 univer-w-full univer-py-0.5",children:d.jsxs("div",{"data-u-comp":"sheets-filter-panel-values-item-inner",className:"univer-box-border univer-flex univer-h-7 univer-items-center univer-rounded-md univer-pb-0 univer-pl-5 univer-pr-0.5 univer-pt-0 univer-text-sm",children:[d.jsx(b.Checkbox,{indeterminate:a,disabled:o.length===0,checked:s,onChange:m}),d.jsx("span",{"data-u-comp":"sheets-filter-panel-values-item-text",className:"univer-mx-1 univer-inline-block univer-flex-shrink univer-overflow-hidden univer-text-ellipsis univer-whitespace-nowrap univer-text-gray-900 dark:!univer-text-white",children:`${r.t("sheets-filter.panel.select-all")}`}),d.jsx("span",{"data-u-comp":"sheets-filter-panel-values-item-count",className:"univer-text-gray-400 dark:!univer-text-gray-500",children:`(${i.checked}/${i.checked+i.unchecked})`})]})}),d.jsx("div",{"data-u-comp":"sheets-filter-panel-values-virtual",className:"univer-flex-grow",children:d.jsx(b.Tree,{data:o,defaultExpandAll:!1,valueGroup:y(o),onChange:S=>{e.onFilterCheckToggled(S)},defaultCache:h,itemHeight:28,treeNodeClassName:`
2
2
  univer-pr-2 univer-border-box univer-max-w-[245px] univer-rounded-md
3
3
  [&:hover_a]:univer-inline-block
4
4
  hover:univer-bg-gray-50 univer-h-full
5
5
  univer-text-gray-900 dark:hover:!univer-bg-gray-900
6
6
  dark:!univer-text-white
7
- `,attachRender:_=>d.jsxs("div",{className:"univer-ml-1 univer-flex univer-h-5 univer-flex-1 univer-cursor-pointer univer-items-center univer-justify-between univer-text-sm univer-text-primary-500",children:[d.jsx("span",{"data-u-comp":"sheets-filter-panel-values-item-count",className:"univer-text-gray-400 dark:!univer-text-gray-500",children:`(${_.count})`}),d.jsx("a",{className:"univer-box-border univer-hidden univer-h-4 univer-whitespace-nowrap univer-px-1.5",onClick:()=>{const I=[];_.children?_.children.forEach(E=>{E.children?E.children.forEach(A=>{I.push(A.key)}):I.push(E.key)}):I.push(_.key),e.onFilterOnly(I)},children:l})]})})})]})]})}function Ft(){var A;const t=T.useDependency(Q),e=T.useDependency(c.LocaleService),r=T.useDependency(c.ICommandService),n=T.useObservable(t.filterBy$,void 0,!0),o=T.useObservable(t.filterByModel$,void 0,!1),l=T.useObservable(()=>(o==null?void 0:o.canApply$)||C.of(!1),void 0,!1,[o]),i=yt(e),s=!T.useObservable(t.hasCriteria$),a=b.useCallback(F=>{r.executeCommand(Fe.id,{filterBy:F})},[r]),m=b.useCallback(async()=>{await(o==null?void 0:o.clear()),r.executeCommand(Z.id)},[o,r]),h=b.useCallback(()=>{r.executeCommand(Z.id)},[r]),f=b.useCallback(async()=>{await(o==null?void 0:o.apply()),r.executeCommand(Z.id)},[o,r]),_=(A=T.useDependency(u.SheetsFilterService).activeFilterModel)==null?void 0:A.getRange(),I=t.col,E=T.useComponentsOfPart(U.SheetsUIPart.FILTER_PANEL_EMBED_POINT);return d.jsxs("div",{"data-u-comp":"sheets-filter-panel",className:"univer-box-border univer-flex univer-max-h-[500px] univer-w-[312px] univer-flex-col univer-rounded-lg univer-bg-white univer-p-4 univer-shadow-lg dark:!univer-border-gray-600 dark:!univer-bg-gray-700",children:[d.jsx(T.ComponentContainer,{components:E,sharedProps:{range:_,colIndex:I,onClose:h}}),d.jsx("div",{className:"univer-mb-1 univer-flex-shrink-0 univer-flex-grow-0",children:d.jsx(y.Segmented,{value:n,items:i,onChange:F=>a(F)})}),o?d.jsx("div",{"data-u-comp":"sheets-filter-panel-content",className:"univer-flex-shrink univer-flex-grow univer-pt-2",children:n===ue.VALUES?d.jsx(Nt,{model:o}):d.jsx(Et,{model:o})}):d.jsx("div",{className:"univer-flex-1"}),d.jsxs("div",{"data-u-comp":"sheets-filter-panel-footer",className:"univer-mt-4 univer-inline-flex univer-flex-shrink-0 univer-flex-grow-0 univer-flex-nowrap univer-justify-between univer-overflow-hidden",children:[d.jsx(y.Button,{variant:"link",onClick:m,disabled:s,children:e.t("sheets-filter.panel.clear-filter")}),d.jsxs("span",{className:"univer-flex univer-gap-2",children:[d.jsx(y.Button,{variant:"default",onClick:h,children:e.t("sheets-filter.panel.cancel")}),d.jsx(y.Button,{disabled:!l,variant:"primary",onClick:f,children:e.t("sheets-filter.panel.confirm")})]})]})]})}function yt(t){const e=t.getCurrentLocale();return b.useMemo(()=>[{label:t.t("sheets-filter.panel.by-values"),value:ue.VALUES},{label:t.t("sheets-filter.panel.by-conditions"),value:ue.CONDITIONS}],[e,t])}function Pt(t){const e=t.get(u.SheetsFilterService);return{id:u.SmartToggleSheetsFilterCommand.id,type:T.MenuItemType.BUTTON_SELECTOR,icon:"FilterIcon",tooltip:"sheets-filter.toolbar.smart-toggle-filter-tooltip",hidden$:T.getMenuHiddenObservable(t,c.UniverInstanceType.UNIVER_SHEET),activated$:e.activeFilterModel$.pipe(C.map(r=>!!r)),disabled$:U.getObservableWithExclusiveRange$(t,U.getCurrentRangeDisable$(t,{worksheetTypes:[N.WorksheetFilterPermission,N.WorksheetViewPermission],rangeTypes:[N.RangeProtectionPermissionViewPoint]}))}}function bt(t){const e=t.get(u.SheetsFilterService);return{id:u.ClearSheetsFilterCriteriaCommand.id,type:T.MenuItemType.BUTTON,title:"sheets-filter.toolbar.clear-filter-criteria",hidden$:T.getMenuHiddenObservable(t,c.UniverInstanceType.UNIVER_SHEET),disabled$:e.activeFilterModel$.pipe(C.switchMap(r=>{var n;return(n=r==null?void 0:r.hasCriteria$.pipe(C.map(o=>!o)))!=null?n:C.of(!0)}))}}function At(t){const e=t.get(u.SheetsFilterService);return{id:u.ReCalcSheetsFilterCommand.id,type:T.MenuItemType.BUTTON,title:"sheets-filter.toolbar.re-calc-filter-conditions",hidden$:T.getMenuHiddenObservable(t,c.UniverInstanceType.UNIVER_SHEET),disabled$:e.activeFilterModel$.pipe(C.switchMap(r=>{var n;return(n=r==null?void 0:r.hasCriteria$.pipe(C.map(o=>!o)))!=null?n:C.of(!0)}))}}const Rt={[T.RibbonDataGroup.ORGANIZATION]:{[u.SmartToggleSheetsFilterCommand.id]:{order:2,menuItemFactory:Pt,[u.ClearSheetsFilterCriteriaCommand.id]:{order:0,menuItemFactory:bt},[u.ReCalcSheetsFilterCommand.id]:{order:1,menuItemFactory:At}}}},Mt={id:u.SmartToggleSheetsFilterCommand.id,binding:T.KeyCode.L|T.MetaKeys.CTRL_COMMAND|T.MetaKeys.SHIFT,description:"sheets-filter.shortcut.smart-toggle-filter",preconditions:U.whenSheetEditorFocused,group:"4_sheet-edit"};var wt=Object.getOwnPropertyDescriptor,Lt=(t,e,r,n)=>{for(var o=n>1?void 0:n?wt(e,r):e,l=t.length-1,i;l>=0;l--)(i=t[l])&&(o=i(o)||o);return o},$=(t,e)=>(r,n)=>e(r,n,t);const je="FILTER_PANEL_POPUP";let fe=class extends oe{constructor(e,r,n,o,l,i,s,a,m,h,f,O,_){super(_,O);S(this,"_popupDisposable");this._injector=e,this._componentManager=r,this._sheetsFilterPanelService=n,this._sheetCanvasPopupService=o,this._sheetsFilterService=l,this._localeService=i,this._shortcutService=s,this._commandService=a,this._menuManagerService=m,this._contextService=h,this._messageService=f,this._initCommands(),this._initShortcuts(),this._initMenuItems(),this._initUI()}dispose(){super.dispose(),this._closeFilterPopup()}_initShortcuts(){[Mt].forEach(e=>{this.disposeWithMe(this._shortcutService.registerShortcut(e))})}_initCommands(){[u.SmartToggleSheetsFilterCommand,u.RemoveSheetFilterCommand,u.SetSheetFilterRangeCommand,u.SetSheetsFilterCriteriaCommand,u.ClearSheetsFilterCriteriaCommand,u.ReCalcSheetsFilterCommand,Fe,ne,Z].forEach(e=>{this.disposeWithMe(this._commandService.registerCommand(e))})}_initMenuItems(){this._menuManagerService.mergeMenu(Rt)}_initUI(){[[je,Ft],["FilterIcon",Qe]].forEach(([e,r])=>{this.disposeWithMe(this._componentManager.register(e,r))}),this.disposeWithMe(this._contextService.subscribeContextValue$(X).pipe(C.distinctUntilChanged()).subscribe(e=>{e?this._openFilterPopup():this._closeFilterPopup()})),this.disposeWithMe(this._sheetsFilterService.errorMsg$.subscribe(e=>{e&&this._messageService.show({type:y.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(),n=this._sheetsFilterPanelService.col,{startRow:o}=r;this._popupDisposable=this._sheetCanvasPopupService.attachPopupToCell(o,n,{componentKey:je,direction:"horizontal",onClickOutside:()=>this._commandService.syncExecuteCommand(Z.id),offset:[5,0]})}_closeFilterPopup(){var e;(e=this._popupDisposable)==null||e.dispose(),this._popupDisposable=null}};fe=Lt([$(0,c.Inject(c.Injector)),$(1,c.Inject(T.ComponentManager)),$(2,c.Inject(Q)),$(3,c.Inject(U.SheetCanvasPopManagerService)),$(4,c.Inject(u.SheetsFilterService)),$(5,c.Inject(c.LocaleService)),$(6,T.IShortcutService),$(7,c.ICommandService),$(8,T.IMenuManagerService),$(9,c.IContextService),$(10,T.IMessageService),$(11,c.Inject(U.SheetsRenderService)),$(12,re.IRenderManagerService)],fe);var Ut=Object.defineProperty,$t=Object.getOwnPropertyDescriptor,Dt=(t,e,r)=>e in t?Ut(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,kt=(t,e,r,n)=>{for(var o=n>1?void 0:n?$t(e,r):e,l=t.length-1,i;l>=0;l--)(i=t[l])&&(o=i(o)||o);return o},Ae=(t,e)=>(r,n)=>e(r,n,t),Ge=(t,e,r)=>Dt(t,typeof e!="symbol"?e+"":e,r);const Ht="SHEET_FILTER_UI_PLUGIN";v.UniverSheetsFilterUIPlugin=class extends c.Plugin{constructor(e=pe,r,n,o){super(),this._config=e,this._injector=r,this._configService=n,this._rpcChannelService=o;const{menu:l,...i}=c.merge({},pe,this._config);l&&this._configService.setConfig("menu",l,{merge:!0}),this._configService.setConfig(De,i)}onStarting(){c.registerDependencies(this._injector,[[Q],[J],[fe]]),this._config.useRemoteFilterValuesGenerator&&this._rpcChannelService&&this._injector.add([le,{useFactory:()=>ae.toModule(this._rpcChannelService.requestChannel(Ee))}])}onReady(){c.touchDependencies(this._injector,[[J]])}onRendered(){c.touchDependencies(this._injector,[[fe]])}},Ge(v.UniverSheetsFilterUIPlugin,"type",c.UniverInstanceType.UNIVER_SHEET),Ge(v.UniverSheetsFilterUIPlugin,"pluginName",Ht),v.UniverSheetsFilterUIPlugin=kt([c.DependentOn(u.UniverSheetsFilterPlugin),Ae(1,c.Inject(c.Injector)),Ae(2,c.IConfigService),Ae(3,c.Optional(ae.IRPCChannelService))],v.UniverSheetsFilterUIPlugin);var Bt=Object.getOwnPropertyDescriptor,Wt=(t,e,r,n)=>{for(var o=n>1?void 0:n?Bt(e,r):e,l=t.length-1,i;l>=0;l--)(i=t[l])&&(o=i(o)||o);return o},Ye=(t,e)=>(r,n)=>e(r,n,t);v.UniverSheetsFilterUIWorkerPlugin=(ve=class extends c.Plugin{constructor(e,r,n){super(),this._config=e,this._injector=r,this._rpcChannelService=n}onStarting(){[[le,{useClass:Oe}]].forEach(e=>this._injector.add(e))}onReady(){this._rpcChannelService.registerChannel(Ee,ae.fromModule(this._injector.get(le)))}},S(ve,"type",c.UniverInstanceType.UNIVER_SHEET),S(ve,"pluginName","SHEET_FILTER_UI_WORKER_PLUGIN"),ve),v.UniverSheetsFilterUIWorkerPlugin=Wt([Ye(1,c.Inject(c.Injector)),Ye(2,ae.IRPCChannelService)],v.UniverSheetsFilterUIWorkerPlugin),v.ChangeFilterByOperation=Fe,v.CloseFilterPanelOperation=Z,v.OpenFilterPanelOperation=ne,Object.defineProperty(v,Symbol.toStringTag,{value:"Module"})});
7
+ `,attachRender:S=>d.jsxs("div",{className:"univer-ml-1 univer-flex univer-h-5 univer-flex-1 univer-cursor-pointer univer-items-center univer-justify-between univer-text-sm univer-text-primary-500",children:[d.jsx("span",{"data-u-comp":"sheets-filter-panel-values-item-count",className:"univer-text-gray-400 dark:!univer-text-gray-500",children:`(${S.count})`}),d.jsx("a",{className:"univer-box-border univer-hidden univer-h-4 univer-whitespace-nowrap univer-px-1.5",onClick:()=>{const C=[];S.children?S.children.forEach(O=>{O.children?O.children.forEach(P=>{C.push(P.key)}):C.push(O.key)}):C.push(S.key),e.onFilterOnly(C)},children:l})]})})})]})]})}function kt(){var P;const t=E.useDependency(G),e=E.useDependency(u.LocaleService),r=E.useDependency(u.ICommandService),n=E.useObservable(t.filterBy$,void 0,!0),o=E.useObservable(t.filterByModel$,void 0,!1),l=E.useObservable(()=>(o==null?void 0:o.canApply$)||g.of(!1),void 0,!1,[o]),i=Bt(e),s=!E.useObservable(t.hasCriteria$),a=I.useCallback(N=>{r.executeCommand(Ae.id,{filterBy:N})},[r]),h=I.useCallback(async()=>{await(o==null?void 0:o.clear()),r.executeCommand(te.id)},[o,r]),m=I.useCallback(()=>{r.executeCommand(te.id)},[r]),p=I.useCallback(async()=>{await(o==null?void 0:o.apply()),r.executeCommand(te.id)},[o,r]),S=(P=E.useDependency(c.SheetsFilterService).activeFilterModel)==null?void 0:P.getRange(),C=t.col,O=E.useComponentsOfPart($.SheetsUIPart.FILTER_PANEL_EMBED_POINT);return d.jsxs("div",{"data-u-comp":"sheets-filter-panel",className:"univer-box-border univer-flex univer-max-h-[500px] univer-w-[400px] univer-flex-col univer-rounded-lg univer-bg-white univer-p-4 univer-shadow-lg dark:!univer-border-gray-600 dark:!univer-bg-gray-700",children:[d.jsx(E.ComponentContainer,{components:O,sharedProps:{range:S,colIndex:C,onClose:m}}),d.jsx("div",{className:"univer-mb-1 univer-flex-shrink-0 univer-flex-grow-0",children:d.jsx(b.Segmented,{value:n,items:i,onChange:N=>a(N)})}),o?d.jsx("div",{"data-u-comp":"sheets-filter-panel-content",className:"univer-flex-shrink univer-flex-grow univer-pt-2",children:n===c.FilterBy.VALUES?d.jsx(Ut,{model:o}):n===c.FilterBy.COLORS?d.jsx(Rt,{model:o}):d.jsx(Lt,{model:o})}):d.jsx("div",{className:"univer-flex-1"}),d.jsxs("div",{"data-u-comp":"sheets-filter-panel-footer",className:"univer-mt-4 univer-inline-flex univer-flex-shrink-0 univer-flex-grow-0 univer-flex-nowrap univer-justify-between univer-overflow-hidden",children:[d.jsx(b.Button,{variant:"link",onClick:h,disabled:s,children:e.t("sheets-filter.panel.clear-filter")}),d.jsxs("span",{className:"univer-flex univer-gap-2",children:[d.jsx(b.Button,{variant:"default",onClick:m,children:e.t("sheets-filter.panel.cancel")}),d.jsx(b.Button,{disabled:!l,variant:"primary",onClick:p,children:e.t("sheets-filter.panel.confirm")})]})]})]})}function Bt(t){const e=t.getCurrentLocale();return I.useMemo(()=>[{label:t.t("sheets-filter.panel.by-values"),value:c.FilterBy.VALUES},{label:t.t("sheets-filter.panel.by-colors"),value:c.FilterBy.COLORS},{label:t.t("sheets-filter.panel.by-conditions"),value:c.FilterBy.CONDITIONS}],[e,t])}function Dt(t){const e=t.get(c.SheetsFilterService);return{id:c.SmartToggleSheetsFilterCommand.id,type:E.MenuItemType.BUTTON_SELECTOR,icon:"FilterIcon",tooltip:"sheets-filter.toolbar.smart-toggle-filter-tooltip",hidden$:E.getMenuHiddenObservable(t,u.UniverInstanceType.UNIVER_SHEET),activated$:e.activeFilterModel$.pipe(g.map(r=>!!r)),disabled$:$.getObservableWithExclusiveRange$(t,$.getCurrentRangeDisable$(t,{worksheetTypes:[F.WorksheetFilterPermission,F.WorksheetViewPermission],rangeTypes:[F.RangeProtectionPermissionViewPoint]}))}}function xt(t){const e=t.get(c.SheetsFilterService);return{id:c.ClearSheetsFilterCriteriaCommand.id,type:E.MenuItemType.BUTTON,title:"sheets-filter.toolbar.clear-filter-criteria",hidden$:E.getMenuHiddenObservable(t,u.UniverInstanceType.UNIVER_SHEET),disabled$:e.activeFilterModel$.pipe(g.switchMap(r=>{var n;return(n=r==null?void 0:r.hasCriteria$.pipe(g.map(o=>!o)))!=null?n:g.of(!0)}))}}function Ht(t){const e=t.get(c.SheetsFilterService);return{id:c.ReCalcSheetsFilterCommand.id,type:E.MenuItemType.BUTTON,title:"sheets-filter.toolbar.re-calc-filter-conditions",hidden$:E.getMenuHiddenObservable(t,u.UniverInstanceType.UNIVER_SHEET),disabled$:e.activeFilterModel$.pipe(g.switchMap(r=>{var n;return(n=r==null?void 0:r.hasCriteria$.pipe(g.map(o=>!o)))!=null?n:g.of(!0)}))}}const Wt={[E.RibbonDataGroup.ORGANIZATION]:{[c.SmartToggleSheetsFilterCommand.id]:{order:2,menuItemFactory:Dt,[c.ClearSheetsFilterCriteriaCommand.id]:{order:0,menuItemFactory:xt},[c.ReCalcSheetsFilterCommand.id]:{order:1,menuItemFactory:Ht}}}},jt={id:c.SmartToggleSheetsFilterCommand.id,binding:E.KeyCode.L|E.MetaKeys.CTRL_COMMAND|E.MetaKeys.SHIFT,description:"sheets-filter.shortcut.smart-toggle-filter",preconditions:$.whenSheetEditorFocused,group:"4_sheet-edit"};var Vt=Object.getOwnPropertyDescriptor,Qt=(t,e,r,n)=>{for(var o=n>1?void 0:n?Vt(e,r):e,l=t.length-1,i;l>=0;l--)(i=t[l])&&(o=i(o)||o);return o},U=(t,e)=>(r,n)=>e(r,n,t);const ze="FILTER_PANEL_POPUP";let Ee=class extends he{constructor(e,r,n,o,l,i,s,a,h,m,p,y,S){super(S,y);v(this,"_popupDisposable");this._injector=e,this._componentManager=r,this._sheetsFilterPanelService=n,this._sheetCanvasPopupService=o,this._sheetsFilterService=l,this._localeService=i,this._shortcutService=s,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(){[jt].forEach(e=>{this.disposeWithMe(this._shortcutService.registerShortcut(e))})}_initCommands(){[c.SmartToggleSheetsFilterCommand,c.RemoveSheetFilterCommand,c.SetSheetFilterRangeCommand,c.SetSheetsFilterCriteriaCommand,c.ClearSheetsFilterCriteriaCommand,c.ReCalcSheetsFilterCommand,Ae,ue,te].forEach(e=>{this.disposeWithMe(this._commandService.registerCommand(e))})}_initMenuItems(){this._menuManagerService.mergeMenu(Wt)}_initUI(){[[ze,kt],["FilterIcon",Ke]].forEach(([e,r])=>{this.disposeWithMe(this._componentManager.register(e,r))}),this.disposeWithMe(this._contextService.subscribeContextValue$(ee).pipe(g.distinctUntilChanged()).subscribe(e=>{e?this._openFilterPopup():this._closeFilterPopup()})),this.disposeWithMe(this._sheetsFilterService.errorMsg$.subscribe(e=>{e&&this._messageService.show({type:b.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(),n=this._sheetsFilterPanelService.col,{startRow:o}=r;this._popupDisposable=this._sheetCanvasPopupService.attachPopupToCell(o,n,{componentKey:ze,direction:"horizontal",onClickOutside:()=>this._commandService.syncExecuteCommand(te.id),offset:[5,0]})}_closeFilterPopup(){var e;(e=this._popupDisposable)==null||e.dispose(),this._popupDisposable=null}};Ee=Qt([U(0,u.Inject(u.Injector)),U(1,u.Inject(E.ComponentManager)),U(2,u.Inject(G)),U(3,u.Inject($.SheetCanvasPopManagerService)),U(4,u.Inject(c.SheetsFilterService)),U(5,u.Inject(u.LocaleService)),U(6,E.IShortcutService),U(7,u.ICommandService),U(8,E.IMenuManagerService),U(9,u.IContextService),U(10,E.IMessageService),U(11,u.Inject($.SheetsRenderService)),U(12,K.IRenderManagerService)],Ee);var Gt=Object.defineProperty,Yt=Object.getOwnPropertyDescriptor,qt=(t,e,r)=>e in t?Gt(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Kt=(t,e,r,n)=>{for(var o=n>1?void 0:n?Yt(e,r):e,l=t.length-1,i;l>=0;l--)(i=t[l])&&(o=i(o)||o);return o},Me=(t,e)=>(r,n)=>e(r,n,t),Je=(t,e,r)=>qt(t,typeof e!="symbol"?e+"":e,r);const Zt="SHEET_FILTER_UI_PLUGIN";_.UniverSheetsFilterUIPlugin=class extends u.Plugin{constructor(e=Ce,r,n,o){super(),this._config=e,this._injector=r,this._configService=n,this._rpcChannelService=o;const{menu:l,...i}=u.merge({},Ce,this._config);l&&this._configService.setConfig("menu",l,{merge:!0}),this._configService.setConfig(He,i)}onStarting(){u.registerDependencies(this._injector,[[G],[ie],[Ee]]),this._config.useRemoteFilterValuesGenerator&&this._rpcChannelService&&this._injector.add([fe,{useFactory:()=>pe.toModule(this._rpcChannelService.requestChannel(Ne))}])}onReady(){u.touchDependencies(this._injector,[[ie]])}onRendered(){u.touchDependencies(this._injector,[[Ee]])}},Je(_.UniverSheetsFilterUIPlugin,"type",u.UniverInstanceType.UNIVER_SHEET),Je(_.UniverSheetsFilterUIPlugin,"pluginName",Zt),_.UniverSheetsFilterUIPlugin=Kt([u.DependentOn(c.UniverSheetsFilterPlugin),Me(1,u.Inject(u.Injector)),Me(2,u.IConfigService),Me(3,u.Optional(pe.IRPCChannelService))],_.UniverSheetsFilterUIPlugin);var Xt=Object.getOwnPropertyDescriptor,zt=(t,e,r,n)=>{for(var o=n>1?void 0:n?Xt(e,r):e,l=t.length-1,i;l>=0;l--)(i=t[l])&&(o=i(o)||o);return o},et=(t,e)=>(r,n)=>e(r,n,t);_.UniverSheetsFilterUIWorkerPlugin=(Oe=class extends u.Plugin{constructor(e,r,n){super(),this._config=e,this._injector=r,this._rpcChannelService=n}onStarting(){[[fe,{useClass:be}]].forEach(e=>this._injector.add(e))}onReady(){this._rpcChannelService.registerChannel(Ne,pe.fromModule(this._injector.get(fe)))}},v(Oe,"type",u.UniverInstanceType.UNIVER_SHEET),v(Oe,"pluginName","SHEET_FILTER_UI_WORKER_PLUGIN"),Oe),_.UniverSheetsFilterUIWorkerPlugin=zt([et(1,u.Inject(u.Injector)),et(2,pe.IRPCChannelService)],_.UniverSheetsFilterUIWorkerPlugin),_.ChangeFilterByOperation=Ae,_.CloseFilterPanelOperation=te,_.OpenFilterPanelOperation=ue,Object.defineProperty(_,Symbol.toStringTag,{value:"Module"})});
@@ -1 +1 @@
1
- (function(e,t){typeof exports=="object"&&typeof module<"u"?module.exports=t():typeof define=="function"&&define.amd?define(t):(e=typeof globalThis<"u"?globalThis:e||self,e.UniverSheetsFilterUiEnUS=t())})(this,function(){"use strict";return{"sheets-filter":{toolbar:{"smart-toggle-filter-tooltip":"Toggle Filter","clear-filter-criteria":"Clear Filter Conditions","re-calc-filter-conditions":"Re-calc Filter Conditions"},command:{"not-valid-filter-range":"The selected range only has one row and not valid for filter."},shortcut:{"smart-toggle-filter":"Toggle Filter"},panel:{"clear-filter":"Clear Filter",cancel:"Cancel",confirm:"Confirm","by-values":"By Values","by-conditions":"By Conditions","filter-only":"Filter Only","search-placeholder":"Use space to separate keywords","select-all":"Select All","input-values-placeholder":"Input Values",and:"AND",or:"OR",empty:"(empty)","?":"Use “?” to represent a single character.","*":"Use “*” to represent multiple characters."},conditions:{none:"None",empty:"Is Empty","not-empty":"Is Not Empty","text-contains":"Text Contains","does-not-contain":"Text Does Not Contain","starts-with":"Text Starts With","ends-with":"Text Ends With",equals:"Text Equals","greater-than":"Greater Than","greater-than-or-equal":"Greater Than Or Equal To","less-than":"Less Than","less-than-or-equal":"Less Than Or Equal To",equal:"Equal","not-equal":"Not Equal",between:"Between","not-between":"Not Between",custom:"Custom"},msg:{"filter-header-forbidden":"You can't move the header row of a filter."},date:{1:"January",2:"February",3:"March",4:"April",5:"May",6:"June",7:"July",8:"August",9:"September",10:"October",11:"November",12:"December"}}}});
1
+ (function(e,t){typeof exports=="object"&&typeof module<"u"?module.exports=t():typeof define=="function"&&define.amd?define(t):(e=typeof globalThis<"u"?globalThis:e||self,e.UniverSheetsFilterUiEnUS=t())})(this,function(){"use strict";return{"sheets-filter":{toolbar:{"smart-toggle-filter-tooltip":"Toggle Filter","clear-filter-criteria":"Clear Filter Conditions","re-calc-filter-conditions":"Re-calc Filter Conditions"},command:{"not-valid-filter-range":"The selected range only has one row and not valid for filter."},shortcut:{"smart-toggle-filter":"Toggle Filter"},panel:{"clear-filter":"Clear Filter",cancel:"Cancel",confirm:"Confirm","by-values":"By Values","by-colors":"By Colors","filter-by-cell-fill-color":"Filter by cell fill color","filter-by-cell-text-color":"Filter by cell text color","filter-by-color-none":"The column contains only one color","by-conditions":"By Conditions","filter-only":"Filter Only","search-placeholder":"Use space to separate keywords","select-all":"Select All","input-values-placeholder":"Input Values",and:"AND",or:"OR",empty:"(empty)","?":"Use “?” to represent a single character.","*":"Use “*” to represent multiple characters."},conditions:{none:"None",empty:"Is Empty","not-empty":"Is Not Empty","text-contains":"Text Contains","does-not-contain":"Text Does Not Contain","starts-with":"Text Starts With","ends-with":"Text Ends With",equals:"Text Equals","greater-than":"Greater Than","greater-than-or-equal":"Greater Than Or Equal To","less-than":"Less Than","less-than-or-equal":"Less Than Or Equal To",equal:"Equal","not-equal":"Not Equal",between:"Between","not-between":"Not Between",custom:"Custom"},msg:{"filter-header-forbidden":"You can't move the header row of a filter."},date:{1:"January",2:"February",3:"March",4:"April",5:"May",6:"June",7:"July",8:"August",9:"September",10:"October",11:"November",12:"December"}}}});