@univerjs/sheets-filter-ui 0.16.1-insiders.20260311-074e8ca → 0.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,176 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
package/lib/cjs/index.js CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";var nt=Object.defineProperty;var ot=(r,e,t)=>e in r?nt(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var _=(r,e,t)=>ot(r,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("@univerjs/core"),c=require("@univerjs/sheets-filter"),$=require("@univerjs/sheets-ui"),g=require("@univerjs/ui"),X=require("@univerjs/engine-render"),y=require("@univerjs/sheets"),S=require("rxjs"),Te=require("@univerjs/rpc"),N=require("@univerjs/design"),I=require("react"),m=require("react/jsx-runtime");var w=(r=>(r[r.FIRST=0]="FIRST",r[r.SECOND=1]="SECOND",r))(w||{}),F=(r=>(r.NONE="none",r.STARTS_WITH="startsWith",r.DOES_NOT_START_WITH="doesNotStartWith",r.ENDS_WITH="endsWith",r.DOES_NOT_END_WITH="doesNotEndWith",r.CONTAINS="contains",r.DOES_NOT_CONTAIN="doesNotContain",r.EQUALS="equals",r.NOT_EQUALS="notEquals",r.EMPTY="empty",r.NOT_EMPTY="notEmpty",r.BETWEEN="between",r.NOT_BETWEEN="notBetween",r.CUSTOM="custom",r))(F||{}),f;(r=>{r.NONE={label:"sheets-filter.conditions.none",operator:F.NONE,order:w.SECOND,numOfParameters:0,getDefaultFormParams:()=>{throw new Error("[FilterConditionItems.NONE]: should not have initial form params!")},testMappingParams:i=>i.operator1===F.NONE,mapToFilterColumn:()=>null,testMappingFilterColumn:i=>!i.customFilters&&!i.filters?{}:!1},r.EMPTY={label:"sheets-filter.conditions.empty",operator:F.EMPTY,order:w.SECOND,numOfParameters:0,getDefaultFormParams:()=>{throw new Error("[FilterConditionItems.EMPTY]: should not have initial form params!")},testMappingParams:({operator1:i})=>i===F.EMPTY,mapToFilterColumn:()=>({customFilters:{customFilters:[{val:""}]}}),testMappingFilterColumn:i=>{var h;if(((h=i.customFilters)==null?void 0:h.customFilters.length)!==1)return!1;const o=i.customFilters.customFilters[0];return o.val===""&&o.operator===void 0?{operator1:F.EMPTY}:!1}},r.NOT_EMPTY={label:"sheets-filter.conditions.not-empty",operator:F.NOT_EMPTY,order:w.SECOND,numOfParameters:0,getDefaultFormParams:()=>{throw new Error("[FilterConditionItems.NOT_EMPTY]: should not have initial form params!")},testMappingParams:({operator1:i})=>i===F.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 o=i.customFilters.customFilters[0];return o.val===" "&&o.operator===c.CustomFilterOperator.NOT_EQUALS?{operator1:F.NOT_EMPTY}:!1}},r.TEXT_CONTAINS={label:"sheets-filter.conditions.text-contains",operator:F.CONTAINS,order:w.FIRST,numOfParameters:1,getDefaultFormParams:()=>({operator1:F.CONTAINS,val1:""}),testMappingParams:i=>{const[o]=j(i);return o===F.CONTAINS},mapToFilterColumn:i=>{const{val1:o}=i;return o===""?null:{customFilters:{customFilters:[{val:`*${o}*`}]}}},testMappingFilterColumn:i=>{var h;if(((h=i.customFilters)==null?void 0:h.customFilters.length)!==1)return!1;const o=i.customFilters.customFilters[0],l=o.val.toString();return!o.operator&&l.startsWith("*")&&l.endsWith("*")?{operator1:F.CONTAINS,val1:l.slice(1,-1)}:!1}},r.DOES_NOT_CONTAIN={label:"sheets-filter.conditions.does-not-contain",operator:F.DOES_NOT_CONTAIN,order:w.FIRST,numOfParameters:1,getDefaultFormParams:()=>({operator1:F.DOES_NOT_CONTAIN,val1:""}),mapToFilterColumn:i=>({customFilters:{customFilters:[{val:`*${i.val1}*`,operator:c.CustomFilterOperator.NOT_EQUALS}]}}),testMappingParams:i=>{const[o]=j(i);return o===F.DOES_NOT_CONTAIN},testMappingFilterColumn:i=>{var h;if(((h=i.customFilters)==null?void 0:h.customFilters.length)!==1)return!1;const o=i.customFilters.customFilters[0],l=o.val.toString();return o.operator===c.CustomFilterOperator.NOT_EQUALS&&l.startsWith("*")&&l.endsWith("*")?{operator1:F.DOES_NOT_CONTAIN,val1:l.slice(1,-1)}:!1}},r.STARTS_WITH={label:"sheets-filter.conditions.starts-with",operator:F.STARTS_WITH,order:w.FIRST,numOfParameters:1,getDefaultFormParams:()=>({operator1:F.STARTS_WITH,val1:""}),mapToFilterColumn:i=>({customFilters:{customFilters:[{val:`${i.val1}*`}]}}),testMappingParams:i=>{const[o]=j(i);return o===F.STARTS_WITH},testMappingFilterColumn:i=>{var h;if(((h=i.customFilters)==null?void 0:h.customFilters.length)!==1)return!1;const o=i.customFilters.customFilters[0],l=o.val.toString();return!o.operator&&l.endsWith("*")&&!l.startsWith("*")?{operator1:F.STARTS_WITH,val1:l.slice(0,-1)}:!1}},r.ENDS_WITH={label:"sheets-filter.conditions.ends-with",operator:F.ENDS_WITH,order:w.FIRST,numOfParameters:1,getDefaultFormParams:()=>({operator1:F.ENDS_WITH,val1:""}),mapToFilterColumn:i=>({customFilters:{customFilters:[{val:`*${i.val1}`}]}}),testMappingParams:i=>{const[o]=j(i);return o===F.ENDS_WITH},testMappingFilterColumn:i=>{var h;if(((h=i.customFilters)==null?void 0:h.customFilters.length)!==1)return!1;const o=i.customFilters.customFilters[0],l=o.val.toString();return!o.operator&&l.startsWith("*")&&!l.endsWith("*")?{operator1:F.ENDS_WITH,val1:l.slice(1)}:!1}},r.EQUALS={label:"sheets-filter.conditions.equals",operator:F.EQUALS,order:w.FIRST,numOfParameters:1,getDefaultFormParams:()=>({operator1:F.EQUALS,val1:""}),testMappingParams:i=>{const[o]=j(i);return o===F.EQUALS},mapToFilterColumn:i=>{const{val1:o}=i;return o===""?null:{customFilters:{customFilters:[{val:o}]}}},testMappingFilterColumn:i=>{var o,l,h;return((l=(o=i.filters)==null?void 0:o.filters)==null?void 0:l.length)===1?{operator1:F.EQUALS,val1:""}:((h=i.customFilters)==null?void 0:h.customFilters.length)===1&&!i.customFilters.customFilters[0].operator?{operator1:F.EQUALS,val1:i.customFilters.customFilters[0].val.toString()}:!1}},r.GREATER_THAN={label:"sheets-filter.conditions.greater-than",operator:c.CustomFilterOperator.GREATER_THAN,numOfParameters:1,order:w.FIRST,getDefaultFormParams:()=>({operator1:c.CustomFilterOperator.GREATER_THAN,val1:""}),mapToFilterColumn:i=>({customFilters:{customFilters:[{val:i.val1,operator:c.CustomFilterOperator.GREATER_THAN}]}}),testMappingParams:i=>{const[o]=j(i);return o===c.CustomFilterOperator.GREATER_THAN},testMappingFilterColumn:i=>{var l;if(((l=i.customFilters)==null?void 0:l.customFilters.length)!==1)return!1;const o=i.customFilters.customFilters[0];return o.operator!==c.CustomFilterOperator.GREATER_THAN?!1:{operator1:c.CustomFilterOperator.GREATER_THAN,val1:o.val.toString()}}},r.GREATER_THAN_OR_EQUAL={label:"sheets-filter.conditions.greater-than-or-equal",operator:c.CustomFilterOperator.GREATER_THAN_OR_EQUAL,numOfParameters:1,order:w.FIRST,getDefaultFormParams:()=>({operator1:c.CustomFilterOperator.GREATER_THAN_OR_EQUAL,val1:""}),testMappingParams:i=>{const[o]=j(i);return o===c.CustomFilterOperator.GREATER_THAN_OR_EQUAL},mapToFilterColumn:i=>({customFilters:{customFilters:[{val:i.val1,operator:c.CustomFilterOperator.GREATER_THAN_OR_EQUAL}]}}),testMappingFilterColumn:i=>{var l;if(((l=i.customFilters)==null?void 0:l.customFilters.length)!==1)return!1;const o=i.customFilters.customFilters[0];return o.operator!==c.CustomFilterOperator.GREATER_THAN_OR_EQUAL?!1:{operator1:c.CustomFilterOperator.GREATER_THAN_OR_EQUAL,val1:o.val.toString()}}},r.LESS_THAN={label:"sheets-filter.conditions.less-than",operator:c.CustomFilterOperator.LESS_THAN,numOfParameters:1,order:w.FIRST,getDefaultFormParams:()=>({operator1:c.CustomFilterOperator.LESS_THAN,val1:""}),testMappingParams:i=>{const[o]=j(i);return o===c.CustomFilterOperator.LESS_THAN},mapToFilterColumn:i=>({customFilters:{customFilters:[{val:i.val1,operator:c.CustomFilterOperator.LESS_THAN}]}}),testMappingFilterColumn:i=>{var l;if(((l=i.customFilters)==null?void 0:l.customFilters.length)!==1)return!1;const o=i.customFilters.customFilters[0];return o.operator!==c.CustomFilterOperator.LESS_THAN?!1:{operator1:c.CustomFilterOperator.LESS_THAN,val1:o.val.toString()}}},r.LESS_THAN_OR_EQUAL={label:"sheets-filter.conditions.less-than-or-equal",operator:c.CustomFilterOperator.LESS_THAN_OR_EQUAL,numOfParameters:1,order:w.FIRST,getDefaultFormParams:()=>({operator1:c.CustomFilterOperator.LESS_THAN_OR_EQUAL,val1:""}),testMappingParams:i=>{const[o]=j(i);return o===c.CustomFilterOperator.LESS_THAN_OR_EQUAL},mapToFilterColumn:i=>({customFilters:{customFilters:[{val:i.val1,operator:c.CustomFilterOperator.LESS_THAN_OR_EQUAL}]}}),testMappingFilterColumn:i=>{var l;if(((l=i.customFilters)==null?void 0:l.customFilters.length)!==1)return!1;const o=i.customFilters.customFilters[0];return o.operator!==c.CustomFilterOperator.LESS_THAN_OR_EQUAL?!1:{operator1:c.CustomFilterOperator.LESS_THAN_OR_EQUAL,val1:o.val.toString()}}},r.EQUAL={label:"sheets-filter.conditions.equal",operator:c.CustomFilterOperator.EQUAL,numOfParameters:1,order:w.FIRST,getDefaultFormParams:()=>({operator1:c.CustomFilterOperator.EQUAL,val1:""}),testMappingParams:i=>{const[o]=j(i);return o===c.CustomFilterOperator.EQUAL},mapToFilterColumn:i=>({customFilters:{customFilters:[{val:i.val1,operator:c.CustomFilterOperator.EQUAL}]}}),testMappingFilterColumn:i=>{var l;if(((l=i.customFilters)==null?void 0:l.customFilters.length)!==1)return!1;const o=i.customFilters.customFilters[0];return o.operator!==c.CustomFilterOperator.EQUAL?!1:{operator1:c.CustomFilterOperator.EQUAL,val1:o.val.toString()}}},r.NOT_EQUAL={label:"sheets-filter.conditions.not-equal",operator:c.CustomFilterOperator.NOT_EQUALS,numOfParameters:1,order:w.FIRST,getDefaultFormParams:()=>({operator1:c.CustomFilterOperator.NOT_EQUALS,val1:""}),testMappingParams:i=>{const[o]=j(i);return o===c.CustomFilterOperator.NOT_EQUALS},mapToFilterColumn:i=>({customFilters:{customFilters:[{val:i.val1,operator:c.CustomFilterOperator.NOT_EQUALS}]}}),testMappingFilterColumn:i=>{var l;if(((l=i.customFilters)==null?void 0:l.customFilters.length)!==1)return!1;const o=i.customFilters.customFilters[0];return o.operator!==c.CustomFilterOperator.NOT_EQUALS?!1:{operator1:c.CustomFilterOperator.NOT_EQUALS,val1:o.val.toString()}}},r.BETWEEN={label:"sheets-filter.conditions.between",operator:F.BETWEEN,order:w.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:o,operator1:l,operator2:h}=i;if(!o)return!1;const d=[l,h];return d.includes(c.CustomFilterOperator.GREATER_THAN_OR_EQUAL)&&d.includes(c.CustomFilterOperator.LESS_THAN_OR_EQUAL)},mapToFilterColumn:i=>{const{val1:o,val2:l,operator1:h}=i,d=h===c.CustomFilterOperator.GREATER_THAN_OR_EQUAL;return{customFilters:{and:u.BooleanNumber.TRUE,customFilters:[{val:d?o:l,operator:c.CustomFilterOperator.GREATER_THAN_OR_EQUAL},{val:d?l:o,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[o,l]=i.customFilters.customFilters;return o.operator===c.CustomFilterOperator.GREATER_THAN_OR_EQUAL&&l.operator===c.CustomFilterOperator.LESS_THAN_OR_EQUAL&&i.customFilters.and?{and:!0,operator1:c.CustomFilterOperator.GREATER_THAN_OR_EQUAL,val1:o.val.toString(),operator2:c.CustomFilterOperator.LESS_THAN_OR_EQUAL,val2:l.val.toString()}:l.operator===c.CustomFilterOperator.GREATER_THAN_OR_EQUAL&&o.operator===c.CustomFilterOperator.LESS_THAN_OR_EQUAL&&i.customFilters.and?{and:!0,operator1:c.CustomFilterOperator.GREATER_THAN_OR_EQUAL,val1:l.val.toString(),operator2:c.CustomFilterOperator.LESS_THAN_OR_EQUAL,val2:o.val.toLocaleString()}:!1}},r.NOT_BETWEEN={label:"sheets-filter.conditions.not-between",operator:F.NOT_BETWEEN,order:w.SECOND,numOfParameters:2,getDefaultFormParams:()=>({operator1:c.CustomFilterOperator.LESS_THAN,val1:"",operator2:c.CustomFilterOperator.GREATER_THAN,val2:""}),testMappingParams:i=>{const{and:o,operator1:l,operator2:h}=i;if(o)return!1;const d=[l,h];return d.includes(c.CustomFilterOperator.GREATER_THAN)&&d.includes(c.CustomFilterOperator.LESS_THAN)},mapToFilterColumn:i=>{const{val1:o,val2:l,operator1:h}=i,d=h===c.CustomFilterOperator.GREATER_THAN;return{customFilters:{customFilters:[{val:d?o:l,operator:c.CustomFilterOperator.GREATER_THAN},{val:d?l:o,operator:c.CustomFilterOperator.LESS_THAN}]}}},testMappingFilterColumn:i=>{var h;if(((h=i.customFilters)==null?void 0:h.customFilters.length)!==2)return!1;const[o,l]=i.customFilters.customFilters;return o.operator===c.CustomFilterOperator.LESS_THAN&&l.operator===c.CustomFilterOperator.GREATER_THAN&&!i.customFilters.and?{operator1:c.CustomFilterOperator.LESS_THAN,val1:o.val.toString(),operator2:c.CustomFilterOperator.GREATER_THAN,val2:l.val.toString()}:l.operator===c.CustomFilterOperator.LESS_THAN&&o.operator===c.CustomFilterOperator.GREATER_THAN&&!i.customFilters.and?{operator1:c.CustomFilterOperator.GREATER_THAN,val1:l.val.toString(),operator2:c.CustomFilterOperator.LESS_THAN,val2:o.val.toLocaleString()}:!1}},r.CUSTOM={label:"sheets-filter.conditions.custom",operator:F.CUSTOM,order:w.SECOND,numOfParameters:2,getDefaultFormParams:()=>({operator1:F.NONE,val1:"",operator2:F.NONE,val2:""}),testMappingParams:()=>!0,mapToFilterColumn:i=>{const{and:o,val1:l,val2:h,operator1:d,operator2:p}=i;function T(x,A){for(const L of r.ALL_CONDITIONS)if(L.operator===x)return L.mapToFilterColumn({val1:A,operator1:x})}const v=!d||d===r.NONE.operator,C=!p||p===r.NONE.operator;if(v&&C)return r.NONE.mapToFilterColumn({});if(v)return T(p,h);if(C)return T(d,l);const E=T(d,l),b=T(p,h),R={customFilters:[E.customFilters.customFilters[0],b.customFilters.customFilters[0]]};return o&&(R.and=u.BooleanNumber.TRUE),{customFilters:R}},testMappingFilterColumn:i=>{var h;if(((h=i.customFilters)==null?void 0:h.customFilters.length)!==2)return!1;const o=i.customFilters.customFilters.map(d=>a({customFilters:{customFilters:[d]}})),l={operator1:o[0][0].operator,val1:o[0][1].val1,operator2:o[1][0].operator,val2:o[1][1].val1};return i.customFilters.and&&(l.and=!0),l}},r.ALL_CONDITIONS=[r.NONE,r.EMPTY,r.NOT_EMPTY,r.TEXT_CONTAINS,r.DOES_NOT_CONTAIN,r.STARTS_WITH,r.ENDS_WITH,r.EQUALS,r.GREATER_THAN,r.GREATER_THAN_OR_EQUAL,r.LESS_THAN,r.LESS_THAN_OR_EQUAL,r.EQUAL,r.NOT_EQUAL,r.BETWEEN,r.NOT_BETWEEN,r.CUSTOM];function e(i){const o=r.ALL_CONDITIONS.find(l=>l.operator===i);if(!o)throw new Error(`[SheetsFilter]: no condition item found for operator: ${i}`);return o}r.getItemByOperator=e;function t(i,o){for(const l of r.ALL_CONDITIONS.filter(h=>h.numOfParameters===o))if(l.numOfParameters!==0&&l.testMappingParams(i))return l;for(const l of r.ALL_CONDITIONS)if(l.testMappingParams(i))return l;throw new Error("[SheetsFilter]: no condition item can be mapped from the filter map params!")}r.testMappingParams=t;function s(i){const o=r.ALL_CONDITIONS.find(l=>l.operator===i);return(o==null?void 0:o.numOfParameters)===0?{operator1:o.operator}:o.getDefaultFormParams()}r.getInitialFormParams=s;function n(i,o){return i.mapToFilterColumn(o)}r.mapToFilterColumn=n;function a(i){if(!i)return[r.NONE,{}];for(const o of r.ALL_CONDITIONS){const l=o.testMappingFilterColumn(i);if(l)return[o,l]}return[r.NONE,{}]}r.testMappingFilterColumn=a})(f||(f={}));function j(r){const{operator1:e,operator2:t,val1:s,val2:n}=r;if(e&&t)throw new Error("Both operator1 and operator2 are set!");if(!e&&!t)throw new Error("Neither operator1 and operator2 and both not set!");return e?[e,s]:[t,n]}function we(r){const e=[],t=[];let s=0,n=0;function a(i){i.leaf&&(i.checked?(e.push(i),s+=i.count):(t.push(i),n+=i.count)),i.children&&i.children.forEach(a)}return r.forEach(a),{checkedItems:e,uncheckedItems:t,checked:s,unchecked:n}}var lt=Object.getOwnPropertyDescriptor,at=(r,e,t,s)=>{for(var n=s>1?void 0:s?lt(e,t):e,a=r.length-1,i;a>=0;a--)(i=r[a])&&(n=i(n)||n);return n},Re=(r,e)=>(t,s)=>e(t,s,r);const Ue="sheets-filter.generate-filter-values.service",ve=u.createIdentifier(Ue);let xe=class extends u.Disposable{constructor(r,e,t){super(),this._localeService=r,this._univerInstanceService=e,this._logService=t}async getFilterValues(r){var p;const{unitId:e,subUnitId:t,filteredOutRowsByOtherColumns:s,filterColumn:n,filters:a,blankChecked:i,iterateRange:o,alreadyChecked:l}=r,h=this._univerInstanceService.getUnit(e),d=(p=this._univerInstanceService.getUnit(e))==null?void 0:p.getSheetBySheetId(t);return!h||!d?[]:(this._logService.debug("[SheetsGenerateFilterValuesService]","getFilterValues for",{unitId:e,subUnitId:t}),qe(a,this._localeService,o,d,new Set(s),n,new Set(l.map(String)),i,h.getStyles()))}};xe=at([Re(0,u.Inject(u.LocaleService)),Re(1,u.IUniverInstanceService),Re(2,u.ILogService)],xe);function qe(r,e,t,s,n,a,i,o,l){var b,R,x,A,L,M,V,Q,J,k;const h=new Map,d=new Map,p="yyyy-mm-dd",T="empty",v=!r&&((a==null?void 0:a.filterBy)===c.FilterBy.COLORS||(a==null?void 0:a.filterBy)===c.FilterBy.CONDITIONS)&&((b=a.filteredOutRows)==null?void 0:b.size);let C=0;for(const O of s.iterateByColumn(t,!1,!1)){const{row:Ne,rowSpan:pe=1}=O;let ee=0;for(;ee<pe;){const st=Ne+ee;if(n.has(st)){ee++;continue}const Z=O!=null&&O.value?u.extractPureTextFromCell(O.value):"";if(!Z){C+=1,ee+=pe;continue}const fe=(R=O.value)!=null&&R.v&&!O.value.p?(L=(A=l.get((x=O.value)==null?void 0:x.s))==null?void 0:A.n)==null?void 0:L.pattern:"",je=fe&&u.numfmt.getFormatInfo(fe).isDate;let Be=!1;if(je){const{year:B,month:G,day:P}=u.numfmt.getFormatDateInfo(fe);Be=B||G||P}if(fe&&je&&Be){const B=(M=s.getCellRaw(O.row,O.col))==null?void 0:M.v;if(!B){ee++;continue}const G=u.numfmt.format(p,Number(B)),[P,D,ae]=G.split("-").map(Number);let K=h.get(`${P}`);K||(K={title:`${P}`,key:`${P}`,children:[],count:0,leaf:!1,checked:!1},h.set(`${P}`,K),d.set(`${P}`,[`${P}`]));let W=(V=K.children)==null?void 0:V.find(ye=>ye.key===`${P}-${D}`);W||(W={title:e.t(`sheets-filter.date.${D}`),key:`${P}-${D}`,children:[],count:0,leaf:!1,checked:!1},(Q=K.children)==null||Q.push(W),d.set(`${P}-${D}`,[`${P}`,`${P}-${D}`]));const be=(J=W==null?void 0:W.children)==null?void 0:J.find(ye=>ye.key===`${P}-${D}-${ae}`);be?(be.originValues.add(Z),be.count++,W.count++,K.count++):((k=W.children)==null||k.push({title:`${ae}`,key:`${P}-${D}-${ae}`,count:1,originValues:new Set([Z]),leaf:!0,checked:v?!1:i.size?i.has(Z):!o}),W.count++,K.count++,d.set(`${P}-${D}-${ae}`,[`${P}`,`${P}-${D}`,`${P}-${D}-${ae}`]))}else{const B=Z;let G=h.get(B);G?G.count++:(G={title:Z,leaf:!0,checked:v?!1:i.size?i.has(Z):!o,key:B,count:1},h.set(B,G),d.set(B,[B]))}ee++}}const E=v?!1:r?o:!0;if(C>0){const O={title:e.t("sheets-filter.panel.empty"),count:C,leaf:!0,checked:E,key:T};h.set("empty",O),d.set("empty",[T])}return{filterTreeItems:ct(Array.from(h.values())),filterTreeMapCache:d}}function ct(r){return Array.from(r).sort((e,t)=>e.children&&!t.children?-1:!e.children&&t.children?1:ut(e.title,t.title)).map(e=>(e.children&&e.children.sort((t,s)=>{const n=Number.parseInt(t.key.split("-")[1],10),a=Number.parseInt(s.key.split("-")[1],10);return n-a}).forEach(t=>{t.children&&t.children.sort((s,n)=>{const a=Number.parseInt(s.key.split("-")[2],10),i=Number.parseInt(n.key.split("-")[2],10);return a-i})}),e))}const De=r=>!Number.isNaN(Number(r))&&!Number.isNaN(Number.parseFloat(r));function ut(r,e){const t=De(r),s=De(e);return t&&s?Number.parseFloat(r)-Number.parseFloat(e):t&&!s?-1:!t&&s?1:r.localeCompare(e)}function Le(r,e){for(const t of r){if(t.key===e)return t;if(t.children){const s=Le(t.children,e);if(s)return s}}return null}function Ze(r){return r.leaf?r.checked:r.children?r.children.every(e=>Ze(e)):!0}function ce(r,e){r.leaf&&(e!==void 0?r.checked=e:r.checked=!r.checked),r.children&&r.children.forEach(t=>ce(t,e))}function Ke(r,e){const t=[];return r.forEach(s=>{const n=s.originValues?e.some(o=>Array.from(s.originValues).some(l=>l.toLowerCase().includes(o.toLowerCase()))):!1,a=!n&&e.some(o=>s.title.toLowerCase().includes(o.toLowerCase()));if(n||a)t.push({...s});else if(s.children){const o=Ke(s.children,e);if(o.length>0){const l=o.reduce((h,d)=>h+d.count,0);t.push({...s,count:l,children:o})}}}),t}var ht=Object.getOwnPropertyDescriptor,Ee=(r,e,t,s)=>{for(var n=s>1?void 0:s?ht(e,t):e,a=r.length-1,i;a>=0;a--)(i=r[a])&&(n=i(n)||n);return n},he=(r,e)=>(t,s)=>e(t,s,r);u.createIdentifier("sheets-filter-ui.sheets-filter-panel.service");let q=class extends u.Disposable{constructor(e,t){super();_(this,"_filterBy$",new S.BehaviorSubject(c.FilterBy.VALUES));_(this,"filterBy$",this._filterBy$.asObservable());_(this,"_filterByModel$",new S.ReplaySubject(1));_(this,"filterByModel$",this._filterByModel$.asObservable());_(this,"_filterByModel",null);_(this,"_hasCriteria$",new S.BehaviorSubject(!1));_(this,"hasCriteria$",this._hasCriteria$.asObservable());_(this,"_filterModel",null);_(this,"_col$",new S.BehaviorSubject(-1));_(this,"col$",this._col$.asObservable());_(this,"_filterHeaderListener",null);this._injector=e,this._refRangeService=t}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,t){this.terminate(),this._filterModel=e,this._col$.next(t);const s=e.getFilterColumn(t);if(s){const n=s.getColumnData();if(n.customFilters){this._hasCriteria$.next(!0),this._setupByConditions(e,t);return}if(n.colorFilters){this._hasCriteria$.next(!0),this._setupByColors(e,t);return}if(n.filters){this._hasCriteria$.next(!0),this._setupByValues(e,t);return}this._hasCriteria$.next(!1),this._setupByValues(e,t);return}this._hasCriteria$.next(!1),this._setupByValues(e,t)}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,t){this._disposeFilterHeaderChangeListener();const s=e.unitId,n=e.subUnitId,a=e.getRange(),i={startColumn:t,startRow:a.startRow,endRow:a.startRow,endColumn:t};this._filterHeaderListener=this._refRangeService.watchRange(s,n,i,(o,l)=>{if(!l)this.terminate();else{const h=l.startColumn-o.startColumn;h!==0&&this._filterByModel.deltaCol(h)}})}async _setupByValues(e,t){this._disposePreviousModel();const s=e.getRange();if(s.startRow===s.endRow)return!1;const n=await ge.fromFilterColumn(this._injector,e,t);return this.filterByModel=n,this._filterBy$.next(c.FilterBy.VALUES),this._listenToFilterHeaderChange(e,t),!0}async _setupByColors(e,t){this._disposePreviousModel();const s=e.getRange();if(s.startRow===s.endRow)return!1;const n=await Ce.fromFilterColumn(this._injector,e,t);return this.filterByModel=n,this._filterBy$.next(c.FilterBy.COLORS),this._listenToFilterHeaderChange(e,t),!0}_setupByConditions(e,t){this._disposePreviousModel();const s=e.getRange();if(s.startRow===s.endRow)return!1;const n=_e.fromFilterColumn(this._injector,e,t,e.getFilterColumn(t));return this.filterByModel=n,this._filterBy$.next(c.FilterBy.CONDITIONS),this._listenToFilterHeaderChange(e,t),!0}_disposePreviousModel(){var e;(e=this._filterByModel)==null||e.dispose(),this.filterByModel=null}};q=Ee([he(0,u.Inject(u.Injector)),he(1,u.Inject(y.RefRangeService))],q);let _e=class extends u.Disposable{constructor(e,t,s,n,a){super();_(this,"canApply$",S.of(!0));_(this,"_conditionItem$");_(this,"conditionItem$");_(this,"_filterConditionFormParams$");_(this,"filterConditionFormParams$");this._filterModel=e,this.col=t,this._commandService=a,this._conditionItem$=new S.BehaviorSubject(s),this.conditionItem$=this._conditionItem$.asObservable(),this._filterConditionFormParams$=new S.BehaviorSubject(n),this.filterConditionFormParams$=this._filterConditionFormParams$.asObservable()}static fromFilterColumn(e,t,s,n){const[a,i]=f.testMappingFilterColumn(n==null?void 0:n.getColumnData());return e.createInstance(_e,t,s,a,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 t=f.ALL_CONDITIONS.find(s=>s.operator===e);if(!t)throw new Error(`[ByConditionsModel]: condition item not found for operator: ${e}!`);this._conditionItem$.next(t),this._filterConditionFormParams$.next(f.getInitialFormParams(e))}onConditionFormChange(e){const t={...this.filterConditionFormParams,...e};if(t.and!==!0&&delete t.and,typeof e.and<"u"||typeof e.operator1<"u"||typeof e.operator2<"u"){const s=f.testMappingParams(t,this.conditionItem.numOfParameters);this._conditionItem$.next(s)}this._filterConditionFormParams$.next(t)}};_e=Ee([he(4,u.ICommandService)],_e);let ge=class extends u.Disposable{constructor(e,t,s,n,a){super();_(this,"_rawFilterItems$");_(this,"rawFilterItems$");_(this,"filterItems$");_(this,"_filterItems",[]);_(this,"_treeMapCache");_(this,"canApply$");_(this,"_manuallyUpdateFilterItems$");_(this,"_searchString$");_(this,"searchString$");this._filterModel=e,this.col=t,this._commandService=a,this._treeMapCache=n,this._searchString$=new S.BehaviorSubject(""),this.searchString$=this._searchString$.asObservable(),this._rawFilterItems$=new S.BehaviorSubject(s),this.rawFilterItems$=this._rawFilterItems$.asObservable(),this._manuallyUpdateFilterItems$=new S.Subject,this.filterItems$=S.merge(S.combineLatest([this._searchString$.pipe(S.throttleTime(500,void 0,{leading:!0,trailing:!0}),S.startWith(void 0)),this._rawFilterItems$]).pipe(S.map(([i,o])=>{if(!i)return o;const h=i.toLowerCase().split(/\s+/).filter(d=>!!d);return Ke(o,h)})),this._manuallyUpdateFilterItems$).pipe(S.shareReplay(1)),this.canApply$=this.filterItems$.pipe(S.map(i=>we(i).checked>0)),this.disposeWithMe(this.filterItems$.subscribe(i=>this._filterItems=i))}static async fromFilterColumn(e,t,s){const n=e.get(u.IUniverInstanceService),a=e.get(u.LocaleService),i=e.get(ve,u.Quantity.OPTIONAL),{unitId:o,subUnitId:l}=t,h=n.getUniverSheetInstance(o);if(!h)throw new Error(`[ByValuesModel]: Workbook not found for filter model with unitId: ${o}!`);const d=h==null?void 0:h.getSheetBySheetId(l);if(!d)throw new Error(`[ByValuesModel]: Worksheet not found for filter model with unitId: ${o} and subUnitId: ${l}!`);const p=t.getRange(),T=s,v=t.getFilterColumn(s),C=v==null?void 0:v.getColumnData().filters,E=new Set(C==null?void 0:C.filters),b=!!(C&&C.blank),R=t.getFilteredOutRowsExceptCol(s),x={...p,startRow:p.startRow+1,startColumn:T,endColumn:T};let A,L;if(i){const M=await i.getFilterValues({unitId:o,subUnitId:l,filteredOutRowsByOtherColumns:Array.from(R),filterColumn:v,filters:!!C,blankChecked:b,iterateRange:x,alreadyChecked:Array.from(E)});A=M.filterTreeItems,L=M.filterTreeMapCache}else{const M=qe(!!C,a,x,d,R,v,E,b,h.getStyles());A=M.filterTreeItems,L=M.filterTreeMapCache}return e.createInstance(ge,t,s,A,L)}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 t=u.Tools.deepClone(this._filterItems);t.forEach(s=>ce(s,e)),this._manuallyUpdateFilterItems(t)}onFilterCheckToggled(e){const t=u.Tools.deepClone(this._filterItems),s=Le(t,e.key);if(!s)return;const n=Ze(s);ce(s,!n),this._manuallyUpdateFilterItems(t)}onFilterOnly(e){const t=u.Tools.deepClone(this._filterItems);t.forEach(s=>ce(s,!1)),e.forEach(s=>{const n=Le(t,s);n&&ce(n,!0)}),this._manuallyUpdateFilterItems(t)}_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=we(this._filterItems),{checked:t,checkedItems:s}=e,n=this.rawFilterItems;let a=0;for(const h of n)a+=h.count;const i=t===0,o=e.checked===a,l={colId:this.col};if(i)throw new Error("[ByValuesModel]: no checked items!");if(o)return this._commandService.executeCommand(c.SetSheetsFilterCriteriaCommand.id,{unitId:this._filterModel.unitId,subUnitId:this._filterModel.subUnitId,col:this.col,criteria:null});{l.filters={};const h=s.filter(p=>p.key!=="empty");h.length>0&&(l.filters={filters:h.flatMap(p=>p.originValues?Array.from(p.originValues):[p.title])}),h.length!==s.length&&(l.filters.blank=!0)}return this._commandService.executeCommand(c.SetSheetsFilterCriteriaCommand.id,{unitId:this._filterModel.unitId,subUnitId:this._filterModel.subUnitId,col:this.col,criteria:l})}};ge=Ee([he(4,u.ICommandService)],ge);let Ce=class extends u.Disposable{constructor(e,t,s,n,a){super();_(this,"canApply$",S.of(!0));_(this,"_cellFillColors$");_(this,"cellFillColors$");_(this,"_cellTextColors$");_(this,"cellTextColors$");this._filterModel=e,this.col=t,this._commandService=a,this._cellFillColors$=new S.BehaviorSubject(Array.from(s.values())),this.cellFillColors$=this._cellFillColors$.asObservable(),this._cellTextColors$=new S.BehaviorSubject(Array.from(n.values())),this.cellTextColors$=this._cellTextColors$.asObservable()}static async fromFilterColumn(e,t,s){var x,A,L;const n=e.get(u.IUniverInstanceService),{unitId:a,subUnitId:i}=t,o=n.getUniverSheetInstance(a);if(!o)throw new Error(`[ByColorsModel]: Workbook not found for filter model with unitId: ${a}!`);const l=o==null?void 0:o.getSheetBySheetId(i);if(!l)throw new Error(`[ByColorsModel]: Worksheet not found for filter model with unitId: ${a} and subUnitId: ${i}!`);const h=t.getRange(),d=s,p=(x=t.getFilterColumn(s))==null?void 0:x.getColumnData().colorFilters,T=t.getFilteredOutRowsExceptCol(s),v={...h,startRow:h.startRow+1,startColumn:d,endColumn:d},C=new Map,E=new Set((A=p==null?void 0:p.cellFillColors)!=null?A:[]),b=new Map,R=new Set((L=p==null?void 0:p.cellTextColors)!=null?L:[]);for(const M of l.iterateByColumn(v,!1,!0)){const{row:V,col:Q,value:J}=M;if(T.has(V))continue;const k=l.getComposedCellStyleByCellData(V,Q,J);if(k.bg&&k.bg.rgb){const O=new u.ColorKit(k.bg.rgb).toRgbString();C.has(O)||C.set(O,{color:O,checked:E.has(O)})}else C.set("default-fill-color",{color:null,checked:E.has(null)});if(k.cl&&k.cl.rgb){const O=new u.ColorKit(k.cl.rgb).toRgbString();b.has(O)||b.set(O,{color:O,checked:R.has(O)})}else b.set("default-font-color",{color:X.COLOR_BLACK_RGB,checked:R.has(X.COLOR_BLACK_RGB)})}return e.createInstance(Ce,t,s,C,b)}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,t=!0){const s=t?this.cellFillColors:this.cellTextColors,n=[];let a=!1;for(let i=0;i<s.length;i++){const o=s[i];if(o.color===e.color){a=!0,n.push({color:o.color,checked:!o.checked});continue}n.push({color:o.color,checked:o.checked})}a&&(this._resetColorsCheckedStatus(!t),t?this._cellFillColors$.next([...n]):this._cellTextColors$.next([...n]))}_resetColorsCheckedStatus(e=!0){const t=e?this.cellFillColors:this.cellTextColors,s=[];for(let n=0;n<t.length;n++)s.push({color:t[n].color,checked:!1});e?this._cellFillColors$.next([...s]):this._cellTextColors$.next([...s])}async apply(){if(this._disposed)return!1;const e=this.cellFillColors.filter(n=>n.checked).map(n=>n.color),t=this.cellTextColors.filter(n=>n.checked).map(n=>n.color);if(e.length===0&&t.length===0)return this._commandService.executeCommand(c.SetSheetsFilterCriteriaCommand.id,{unitId:this._filterModel.unitId,subUnitId:this._filterModel.subUnitId,col:this.col,criteria:null});const s={colId:this.col};return e.length>0?s.colorFilters={cellFillColors:e}:t.length>0&&(s.colorFilters={cellTextColors:t}),this._commandService.executeCommand(c.SetSheetsFilterCriteriaCommand.id,{unitId:this._filterModel.unitId,subUnitId:this._filterModel.subUnitId,col:this.col,criteria:s})}};Ce=Ee([he(4,u.ICommandService)],Ce);const se="FILTER_PANEL_OPENED",me={id:"sheet.operation.open-filter-panel",type:u.CommandType.OPERATION,handler:(r,e)=>{const t=r.get(u.IContextService),s=r.get(c.SheetsFilterService),n=r.get(q),a=r.get(u.ICommandService),i=r.has($.IEditorBridgeService)?r.get($.IEditorBridgeService):null;i!=null&&i.isVisible().visible&&a.syncExecuteCommand($.SetCellEditVisibleOperation.id,{visible:!1});const{unitId:o,subUnitId:l,col:h}=e,d=s.getFilterModel(o,l);return d?(n.setupCol(d,h),t.getContextValue(se)||t.setContextValue(se,!0),!0):!1}},ie={id:"sheet.operation.close-filter-panel",type:u.CommandType.OPERATION,handler:r=>{const e=r.get(u.IContextService),t=r.get(q),s=r.get(g.ILayoutService,u.Quantity.OPTIONAL);return e.getContextValue(se)?(e.setContextValue(se,!1),s==null||s.focus(),t.terminate()):!1}},ke={id:"sheet.operation.apply-filter",type:u.CommandType.OPERATION,handler:(r,e)=>{const{filterBy:t}=e;return r.get(q).changeFilterBy(t)}},mt="@univerjs/sheets-filter-ui",dt="0.16.1-insiders.20260311-074e8ca",ne={name:mt,version:dt},ze="sheets-filter-ui.config",Se={};var pt=Object.getOwnPropertyDescriptor,ft=(r,e,t,s)=>{for(var n=s>1?void 0:s?pt(e,t):e,a=r.length-1,i;a>=0;a--)(i=r[a])&&(n=i(n)||n);return n},te=(r,e)=>(t,s)=>e(t,s,r);let oe=class extends u.Disposable{constructor(r,e,t,s,n,a){super(),this._sheetsFilterService=r,this._localeService=e,this._commandService=t,this._sheetPermissionCheckPermission=s,this._injector=n,this._sheetsSelectionService=a,this._commandExecutedListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.beforeCommandExecuted(r=>{var e,t,s;if(r.id===c.SmartToggleSheetsFilterCommand.id){const n=this._injector.get(u.IUniverInstanceService),a=y.getSheetCommandTarget(n);if(!a)return;const{unitId:i,subUnitId:o,worksheet:l}=a,h=(e=this._sheetsFilterService.getFilterModel(i,o))==null?void 0:e.getRange();let d;if(h)d=this._sheetPermissionCheckPermission.permissionCheckWithRanges({rangeTypes:[y.RangeProtectionPermissionViewPoint],worksheetTypes:[y.WorksheetFilterPermission,y.WorksheetViewPermission]},[h],i,o);else{const p=(t=this._sheetsSelectionService.getCurrentLastSelection())==null?void 0:t.range;if(p){let T={...p};T=p.startColumn===p.endColumn&&p.startRow===p.endRow?y.expandToContinuousRange(T,{left:!0,right:!0,up:!0,down:!0},l):T,d=this._sheetPermissionCheckPermission.permissionCheckWithRanges({rangeTypes:[y.RangeProtectionPermissionViewPoint],worksheetTypes:[y.WorksheetViewPermission,y.WorksheetFilterPermission]},[T],i,o)}else d=this._sheetPermissionCheckPermission.permissionCheckWithoutRange({rangeTypes:[y.RangeProtectionPermissionViewPoint],worksheetTypes:[y.WorksheetViewPermission,y.WorksheetFilterPermission]})}d||this._sheetPermissionCheckPermission.blockExecuteWithoutPermission(this._localeService.t("permission.dialog.filterErr"))}if(r.id===me.id){const n=r.params,{unitId:a,subUnitId:i}=n,o=(s=this._sheetsFilterService.getFilterModel(a,i))==null?void 0:s.getRange(),l=u.Tools.deepClone(o);l&&(l.startColumn=n.col,l.endColumn=n.col,this._sheetPermissionCheckPermission.permissionCheckWithRanges({rangeTypes:[y.RangeProtectionPermissionViewPoint],worksheetTypes:[y.WorksheetFilterPermission,y.WorksheetViewPermission]},[l],a,i)||this._sheetPermissionCheckPermission.blockExecuteWithoutPermission(this._localeService.t("permission.dialog.filterErr")))}}))}};oe=ft([te(0,u.Inject(c.SheetsFilterService)),te(1,u.Inject(u.LocaleService)),te(2,u.ICommandService),te(3,u.Inject(y.SheetPermissionCheckController)),te(4,u.Inject(u.Injector)),te(5,u.Inject(y.SheetsSelectionsService))],oe);const Y=16,vt=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 He{static drawNoCriteria(e,t,s,n){e.save(),X.Rect.drawWith(e,{radius:2,width:Y,height:Y,fill:n}),e.lineCap="square",e.strokeStyle=s,e.scale(t/Y,t/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,t,s,n){e.save(),X.Rect.drawWith(e,{radius:2,width:Y,height:Y,fill:n}),e.scale(t/Y,t/Y),e.fillStyle=s,e.fill(vt),e.restore()}}var _t=Object.getOwnPropertyDescriptor,gt=(r,e,t,s)=>{for(var n=s>1?void 0:s?_t(e,t):e,a=r.length-1,i;a>=0;a--)(i=r[a])&&(n=i(n)||n);return n},Pe=(r,e)=>(t,s)=>e(t,s,r);const H=16,ue=1;let $e=class extends X.Shape{constructor(e,t,s,n,a){super(e,t);_(this,"_cellWidth",0);_(this,"_cellHeight",0);_(this,"_filterParams");_(this,"_hovered",!1);this._contextService=s,this._commandService=n,this._themeService=a,this.setShapeProps(t),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 t=this._cellHeight,s=this._cellWidth,n=H-s,a=H-t;e.save();const i=new Path2D;i.rect(n,a,s,t),e.clip(i);const{hasCriteria:o}=this._filterParams,l=this._themeService.getColorFromTheme("primary.600"),h=this._hovered?this._themeService.getColorFromTheme("gray.50"):"rgba(255, 255, 255, 1.0)";o?He.drawHasCriteria(e,H,l,h):He.drawNoCriteria(e,H,l,h),e.restore()}onPointerDown(e){if(e.button===2)return;const{col:t,unitId:s,subUnitId:n}=this._filterParams;this._contextService.getContextValue(se)||!this._commandService.hasCommand(me.id)||setTimeout(()=>{this._commandService.executeCommand(me.id,{unitId:s,subUnitId:n,col:t})},200)}onPointerEnter(){this._hovered=!0,this.makeDirty(!0)}onPointerLeave(){this._hovered=!1,this.makeDirty(!0)}};$e=gt([Pe(2,u.IContextService),Pe(3,u.ICommandService),Pe(4,u.Inject(u.ThemeService))],$e);var Ct=Object.getOwnPropertyDescriptor,St=(r,e,t,s)=>{for(var n=s>1?void 0:s?Ct(e,t):e,a=r.length-1,i;a>=0;a--)(i=r[a])&&(n=i(n)||n);return n},z=(r,e)=>(t,s)=>e(t,s,r);const Ft=1e3,Tt=5e3;function Et(r,e,t,s){switch(s){case u.VerticalAlign.TOP:return r+ue;case u.VerticalAlign.MIDDLE:return r+Math.max(0,(t-H)/2);case u.VerticalAlign.BOTTOM:default:return e-H-ue}}let Me=class extends u.RxDisposable{constructor(e,t,s,n,a,i,o,l){super();_(this,"_filterRangeShape",null);_(this,"_buttonRenderDisposable",null);_(this,"_filterButtonShapes",[]);this._context=e,this._injector=t,this._sheetSkeletonManagerService=s,this._sheetsFilterService=n,this._themeService=a,this._sheetInterceptorService=i,this._commandService=o,this._selectionRenderService=l,this._initRenderer()}dispose(){super.dispose(),this._disposeRendering()}_initRenderer(){this._sheetSkeletonManagerService.currentSkeleton$.pipe(S.switchMap(e=>{var o,l;if(!e)return S.of(null);const{unit:t,unitId:s}=this._context,n=((o=t.getActiveSheet())==null?void 0:o.getSheetId())||"",a=(l=this._sheetsFilterService.getFilterModel(s,n))!=null?l:void 0,i=()=>({unitId:s,worksheetId:n,filterModel:a,range:a==null?void 0:a.getRange(),skeleton:e.skeleton});return u.fromCallback(this._commandService.onCommandExecuted.bind(this._commandService)).pipe(S.filter(([h])=>{var d;return h.type===u.CommandType.MUTATION&&((d=h.params)==null?void 0:d.unitId)===t.getUnitId()&&(c.FILTER_MUTATIONS.has(h.id)||h.id===y.SetRangeValuesMutation.id)}),S.throttleTime(20,void 0,{leading:!1,trailing:!0}),S.map(i),S.startWith(i()))}),S.takeUntil(this.dispose$)).subscribe(e=>{this._disposeRendering(),!(!e||!e.range)&&(this._renderRange(e.range,e.skeleton),this._renderButtons(e))})}_renderRange(e,t){const{scene:s}=this._context,{rowHeaderWidth:n,columnHeaderHeight:a}=t,i=this._filterRangeShape=new $.SelectionControl(s,Ft,this._themeService,{rowHeaderWidth:n,columnHeaderHeight:a,enableAutoFill:!1,highlightHeader:!1}),o={range:e,primary:null,style:{fill:"rgba(0, 0, 0, 0.0)"}},l=$.attachSelectionWithCoord(o,t);i.updateRangeBySelectionWithCoord(l),i.setEvent(!1),s.makeDirty(!0)}_renderButtons(e){const{range:t,filterModel:s,unitId:n,skeleton:a,worksheetId:i}=e,{unit:o,scene:l}=this._context,h=o.getSheetBySheetId(i);if(!h)return;this._interceptCellContent(n,i,e.range);const{startColumn:d,endColumn:p,startRow:T}=t;for(let v=d;v<=p;v++){const C=`sheets-filter-button-${v}`,E=$.getCoordByCell(T,v,l,a),b=h.getComposedCellStyle(T,v),R=(b==null?void 0:b.vt)||u.VerticalAlign.BOTTOM,{startX:x,startY:A,endX:L,endY:M}=E,V=L-x,Q=M-A;if(Q<=ue||V<=ue)continue;const J=!!s.getFilterColumn(v),k=L-H-ue,O=Et(A,M,Q,R),Ne={left:k,top:O,height:H,width:H,zIndex:Tt,cellHeight:Q,cellWidth:V,filterParams:{unitId:n,subUnitId:i,col:v,hasCriteria:J}},pe=this._injector.createInstance($e,C,Ne);this._filterButtonShapes.push(pe)}l.addObjects(this._filterButtonShapes),l.makeDirty()}_interceptCellContent(e,t,s){const{startRow:n,startColumn:a,endColumn:i}=s;this._buttonRenderDisposable=this._sheetInterceptorService.intercept(y.INTERCEPTOR_POINT.CELL_CONTENT,{effect:u.InterceptorEffectEnum.Style,handler:(o,l,h)=>{const{row:d,col:p,unitId:T,subUnitId:v}=l;return T!==e||v!==t||d!==n||p<a||p>i||((!o||o===l.rawData)&&(o={...l.rawData}),o.fontRenderExtension={...o==null?void 0:o.fontRenderExtension,rightOffset:H}),h(o)},priority:10})}_disposeRendering(){var e,t;(e=this._filterRangeShape)==null||e.dispose(),this._filterButtonShapes.forEach(s=>s.dispose()),(t=this._buttonRenderDisposable)==null||t.dispose(),this._filterRangeShape=null,this._buttonRenderDisposable=null,this._filterButtonShapes=[]}};Me=St([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(y.SheetInterceptorService)),z(6,u.ICommandService),z(7,$.ISheetSelectionRenderService)],Me);var It=Object.getOwnPropertyDescriptor,Ot=(r,e,t,s)=>{for(var n=s>1?void 0:s?It(e,t):e,a=r.length-1,i;a>=0;a--)(i=r[a])&&(n=i(n)||n);return n},We=(r,e)=>(t,s)=>e(t,s,r);let de=class extends u.RxDisposable{constructor(r,e){super(),this._renderManagerService=r,this._sheetsRenderService=e,[c.SetSheetsFilterRangeMutation,c.SetSheetsFilterCriteriaMutation,c.RemoveSheetsFilterMutation,c.ReCalcSheetsFilterMutation].forEach(t=>this.disposeWithMe(this._sheetsRenderService.registerSkeletonChangingMutations(t.id))),this.disposeWithMe(this._renderManagerService.registerRenderModule(u.UniverInstanceType.UNIVER_SHEET,[Me]))}};de=Ot([We(0,X.IRenderManagerService),We(1,u.Inject($.SheetsRenderService))],de);var Nt=Object.defineProperty,bt=Object.getOwnPropertyDescriptor,yt=(r,e,t)=>e in r?Nt(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Rt=(r,e,t,s)=>{for(var n=s>1?void 0:s?bt(e,t):e,a=r.length-1,i;a>=0;a--)(i=r[a])&&(n=i(n)||n);return n},Ve=(r,e)=>(t,s)=>e(t,s,r),Ie=(r,e,t)=>yt(r,typeof e!="symbol"?e+"":e,t);exports.UniverSheetsFilterMobileUIPlugin=class extends u.Plugin{constructor(e=Se,t,s){super(),this._config=e,this._injector=t,this._configService=s;const{menu:n,...a}=u.merge({},Se,this._config);n&&this._configService.setConfig("menu",n,{merge:!0}),this._configService.setConfig(ze,a)}onStarting(){[[oe],[de]].forEach(e=>this._injector.add(e))}onReady(){this._injector.get(oe)}onRendered(){this._injector.get(de)}};Ie(exports.UniverSheetsFilterMobileUIPlugin,"type",u.UniverInstanceType.UNIVER_SHEET);Ie(exports.UniverSheetsFilterMobileUIPlugin,"pluginName","SHEET_FILTER_UI_PLUGIN");Ie(exports.UniverSheetsFilterMobileUIPlugin,"packageName",ne.name);Ie(exports.UniverSheetsFilterMobileUIPlugin,"version",ne.version);exports.UniverSheetsFilterMobileUIPlugin=Rt([u.DependentOn(c.UniverSheetsFilterPlugin),Ve(1,u.Inject(u.Injector)),Ve(2,u.IConfigService)],exports.UniverSheetsFilterMobileUIPlugin);function le({ref:r,...e}){const{icon:t,id:s,className:n,extend:a,...i}=e,o=`univerjs-icon univerjs-icon-${s} ${n||""}`.trim(),l=I.useRef(`_${wt()}`);return Xe(t,`${s}`,{defIds:t.defIds,idSuffix:l.current},{ref:r,className:o,...i},a)}function Xe(r,e,t,s,n){return I.createElement(r.tag,{key:e,...Pt(r,t,n),...s},(At(r,t).children||[]).map((a,i)=>Xe(a,`${e}-${r.tag}-${i}`,t,void 0,n)))}function Pt(r,e,t){const s={...r.attrs};t!=null&&t.colorChannel1&&s.fill==="colorChannel1"&&(s.fill=t.colorChannel1),r.tag==="mask"&&s.id&&(s.id=s.id+e.idSuffix),Object.entries(s).forEach(([a,i])=>{a==="mask"&&typeof i=="string"&&(s[a]=i.replace(/url\(#(.*)\)/,`url(#$1${e.idSuffix})`))});const{defIds:n}=e;return!n||n.length===0||(r.tag==="use"&&s["xlink:href"]&&(s["xlink:href"]=s["xlink:href"]+e.idSuffix),Object.entries(s).forEach(([a,i])=>{typeof i=="string"&&(s[a]=i.replace(/url\(#(.*)\)/,`url(#$1${e.idSuffix})`))})),s}function At(r,e){var s;const{defIds:t}=e;return!t||t.length===0?r:r.tag==="defs"&&((s=r.children)!=null&&s.length)?{...r,children:r.children.map(n=>typeof n.attrs.id=="string"&&t&&t.includes(n.attrs.id)?{...n,attrs:{...n.attrs,id:n.attrs.id+e.idSuffix}}:n)}:r}function wt(){return Math.random().toString(36).substring(2,8)}le.displayName="UniverIcon";const xt={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"}}]},Je=I.forwardRef(function(e,t){return I.createElement(le,Object.assign({},e,{id:"a-icon",ref:t,icon:xt}))});Je.displayName="AIcon";const Lt={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"}}]},et=I.forwardRef(function(e,t){return I.createElement(le,Object.assign({},e,{id:"ban-icon",ref:t,icon:Lt}))});et.displayName="BanIcon";const $t={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"}}]},tt=I.forwardRef(function(e,t){return I.createElement(le,Object.assign({},e,{id:"filter-icon",ref:t,icon:$t}))});tt.displayName="FilterIcon";const Mt={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.00016 1.33203C6.68162 1.33203 5.39269 1.72302 4.29636 2.45557C3.20004 3.18811 2.34555 4.2293 1.84097 5.44747C1.33638 6.66565 1.20436 8.00609 1.4616 9.2993C1.71883 10.5925 2.35377 11.7804 3.28612 12.7127C4.21847 13.6451 5.40636 14.28 6.69956 14.5373C7.99277 14.7945 9.33321 14.6625 10.5514 14.1579C11.7696 13.6533 12.8108 12.7988 13.5433 11.7025C14.2758 10.6062 14.6668 9.31724 14.6668 7.9987C14.6649 6.23118 13.9619 4.53662 12.7121 3.2868C11.4622 2.03697 9.76768 1.33397 8.00016 1.33203ZM7.66683 3.9987C7.86461 3.9987 8.05795 4.05735 8.2224 4.16723C8.38685 4.27711 8.51502 4.43329 8.59071 4.61601C8.6664 4.79874 8.6862 4.99981 8.64762 5.19379C8.60903 5.38777 8.51379 5.56595 8.37394 5.7058C8.23409 5.84566 8.0559 5.9409 7.86192 5.97948C7.66794 6.01807 7.46687 5.99826 7.28415 5.92258C7.10142 5.84689 6.94524 5.71872 6.83536 5.55427C6.72548 5.38982 6.66683 5.19648 6.66683 4.9987C6.66683 4.73348 6.77219 4.47913 6.95972 4.29159C7.14726 4.10405 7.40162 3.9987 7.66683 3.9987ZM9.3335 11.332H6.66683C6.49002 11.332 6.32045 11.2618 6.19543 11.1368C6.0704 11.0117 6.00016 10.8422 6.00016 10.6654C6.00016 10.4886 6.0704 10.319 6.19543 10.194C6.32045 10.0689 6.49002 9.9987 6.66683 9.9987H7.3335V7.9987H6.66683C6.49002 7.9987 6.32045 7.92846 6.19543 7.80343C6.0704 7.67841 6.00016 7.50884 6.00016 7.33203C6.00016 7.15522 6.0704 6.98565 6.19543 6.86063C6.32045 6.7356 6.49002 6.66536 6.66683 6.66536H8.00016C8.17698 6.66536 8.34655 6.7356 8.47157 6.86063C8.59659 6.98565 8.66683 7.15522 8.66683 7.33203V9.9987H9.3335C9.51031 9.9987 9.67988 10.0689 9.8049 10.194C9.92993 10.319 10.0002 10.4886 10.0002 10.6654C10.0002 10.8422 9.92993 11.0117 9.8049 11.1368C9.67988 11.2618 9.51031 11.332 9.3335 11.332Z"}}]},rt=I.forwardRef(function(e,t){return I.createElement(le,Object.assign({},e,{id:"info-icon",ref:t,icon:Mt}))});rt.displayName="InfoIcon";const Ut={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"}}]},it=I.forwardRef(function(e,t){return I.createElement(le,Object.assign({},e,{id:"success-icon",ref:t,icon:Ut}))});it.displayName="SuccessIcon";function kt(r){const e=r.get(c.SheetsFilterService);return{id:c.SmartToggleSheetsFilterCommand.id,type:g.MenuItemType.BUTTON_SELECTOR,icon:"FilterIcon",tooltip:"sheets-filter.toolbar.smart-toggle-filter-tooltip",hidden$:g.getMenuHiddenObservable(r,u.UniverInstanceType.UNIVER_SHEET),activated$:e.activeFilterModel$.pipe(S.map(t=>!!t)),disabled$:$.getObservableWithExclusiveRange$(r,$.getCurrentRangeDisable$(r,{worksheetTypes:[y.WorksheetFilterPermission,y.WorksheetViewPermission],rangeTypes:[y.RangeProtectionPermissionViewPoint]}))}}function jt(r){const e=r.get(c.SheetsFilterService);return{id:c.ClearSheetsFilterCriteriaCommand.id,type:g.MenuItemType.BUTTON,title:"sheets-filter.toolbar.clear-filter-criteria",hidden$:g.getMenuHiddenObservable(r,u.UniverInstanceType.UNIVER_SHEET),disabled$:e.activeFilterModel$.pipe(S.switchMap(t=>{var s;return(s=t==null?void 0:t.hasCriteria$.pipe(S.map(n=>!n)))!=null?s:S.of(!0)}))}}function Bt(r){const e=r.get(c.SheetsFilterService);return{id:c.ReCalcSheetsFilterCommand.id,type:g.MenuItemType.BUTTON,title:"sheets-filter.toolbar.re-calc-filter-conditions",hidden$:g.getMenuHiddenObservable(r,u.UniverInstanceType.UNIVER_SHEET),disabled$:e.activeFilterModel$.pipe(S.switchMap(t=>{var s;return(s=t==null?void 0:t.hasCriteria$.pipe(S.map(n=>!n)))!=null?s:S.of(!0)}))}}const Dt={[g.RibbonDataGroup.ORGANIZATION]:{[c.SmartToggleSheetsFilterCommand.id]:{order:2,menuItemFactory:kt,[c.ClearSheetsFilterCriteriaCommand.id]:{order:0,menuItemFactory:jt},[c.ReCalcSheetsFilterCommand.id]:{order:1,menuItemFactory:Bt}}}};function Ht(r){const{model:e}=r,t=g.useDependency(u.LocaleService),s=g.useObservable(e.cellFillColors$,[],!0),n=g.useObservable(e.cellTextColors$,[],!0),a=I.useCallback(o=>{e.onFilterCheckToggled(o)},[e]),i=I.useCallback(o=>{e.onFilterCheckToggled(o,!1)},[e]);return m.jsx("div",{"data-u-comp":"sheets-filter-panel-colors-container",className:"univer-flex univer-h-full univer-min-h-[300px] univer-flex-col",children:m.jsxs("div",{"data-u-comp":"sheets-filter-panel",className:N.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",N.borderClassName),children:[s.length>1&&m.jsxs("div",{children:[m.jsx("div",{className:"univer-mb-2 univer-text-sm univer-text-gray-900 dark:!univer-text-white",children:t.t("sheets-filter.panel.filter-by-cell-fill-color")}),m.jsx("div",{className:"univer-grid univer-grid-cols-8 univer-items-center univer-justify-start univer-gap-2",children:s.map((o,l)=>m.jsxs("div",{className:"univer-relative univer-size-6",onClick:()=>a(o),children:[o.color?m.jsx("button",{type:"button",className:N.clsx("univer-box-border univer-size-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:o.color}}):m.jsx(et,{className:"univer-size-6 univer-cursor-pointer univer-rounded-full hover:univer-ring-2 hover:univer-ring-offset-2 hover:univer-ring-offset-white"}),o.checked&&m.jsx(Qe,{})]},`sheets-filter-cell-fill-color-${l}`))})]}),n.length>1&&m.jsxs("div",{children:[m.jsx("div",{className:"univer-mb-2 univer-text-sm univer-text-gray-900 dark:!univer-text-white",children:t.t("sheets-filter.panel.filter-by-cell-text-color")}),m.jsx("div",{className:"univer-grid univer-grid-cols-8 univer-items-center univer-justify-start univer-gap-2",children:n.map((o,l)=>m.jsxs("div",{className:"univer-relative univer-size-6",onClick:()=>i(o),children:[m.jsx("div",{className:"univer-box-border univer-flex univer-size-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:m.jsx(Je,{style:{color:o.color}})}),o.checked&&m.jsx(Qe,{})]},`sheets-filter-cell-text-color-${l}`))})]}),s.length<=1&&n.length<=1&&m.jsx("div",{className:"univer-flex univer-size-full univer-items-center univer-justify-center univer-text-sm univer-text-gray-900 dark:!univer-text-gray-200",children:t.t("sheets-filter.panel.filter-by-color-none")})]})})}function Qe(){return m.jsx("div",{className:"univer-absolute -univer-bottom-0.5 -univer-right-0.5 univer-flex univer-size-3 univer-cursor-pointer univer-items-center univer-justify-center univer-rounded-full univer-bg-white",children:m.jsx(it,{className:"univer-size-full univer-font-bold univer-text-[#418F1F]"})})}function Wt(r){var v,C;const{model:e}=r,t=g.useDependency(u.LocaleService),s=g.useObservable(e.conditionItem$,void 0),n=g.useObservable(e.filterConditionFormParams$,void 0),a=n!=null&&n.and?"AND":"OR",i=I.useCallback(E=>{e.onConditionFormChange({and:E==="AND"})},[e]),o=Vt(t),l=I.useCallback(E=>{e.onPrimaryConditionChange(E)},[e]),h=Qt(t),d=I.useCallback(E=>{e.onConditionFormChange(E)},[e]),p=t.t("sheets-filter.panel.input-values-placeholder");function T(E,b,R){const x=f.getItemByOperator(E).numOfParameters===1;return m.jsxs(m.Fragment,{children:[R==="operator2"&&m.jsxs(N.RadioGroup,{value:a,onChange:i,children:[m.jsx(N.Radio,{value:"AND",children:t.t("sheets-filter.panel.and")}),m.jsx(N.Radio,{value:"OR",children:t.t("sheets-filter.panel.or")})]}),m.jsx(N.Select,{value:E,options:h,onChange:A=>d({[R]:A})}),x&&m.jsx("div",{children:m.jsx(N.Input,{className:"univer-mt-2",value:b,placeholder:p,onChange:A=>d({[R==="operator1"?"val1":"val2"]:A})})})]})}return m.jsx("div",{"data-u-comp":"sheets-filter-panel-conditions-container",className:"univer-flex univer-h-full univer-min-h-[300px] univer-flex-col",children:s&&n&&m.jsxs(m.Fragment,{children:[m.jsx(N.Select,{value:s.operator,options:o,onChange:l}),f.getItemByOperator(s.operator).numOfParameters!==0?m.jsxs("div",{"data-u-comp":"sheets-filter-panel-conditions-container-inner",className:N.clsx("univer-mt-2 univer-flex-grow univer-overflow-hidden univer-rounded-md univer-p-2",N.borderClassName),children:[s.numOfParameters>=1&&T(n.operator1,(v=n.val1)!=null?v:"","operator1"),s.numOfParameters>=2&&T(n.operator2,(C=n.val2)!=null?C:"","operator2"),m.jsxs("div",{"data-u-comp":"sheets-filter-panel-conditions-desc",className:"univer-mt-2 univer-text-xs univer-text-gray-500",children:[t.t("sheets-filter.panel.?"),m.jsx("br",{}),t.t("sheets-filter.panel.*")]})]}):null]})})}function Vt(r){const e=r.getCurrentLocale();return I.useMemo(()=>[{options:[{label:r.t(f.NONE.label),value:f.NONE.operator}]},{options:[{label:r.t(f.EMPTY.label),value:f.EMPTY.operator},{label:r.t(f.NOT_EMPTY.label),value:f.NOT_EMPTY.operator}]},{options:[{label:r.t(f.TEXT_CONTAINS.label),value:f.TEXT_CONTAINS.operator},{label:r.t(f.DOES_NOT_CONTAIN.label),value:f.DOES_NOT_CONTAIN.operator},{label:r.t(f.STARTS_WITH.label),value:f.STARTS_WITH.operator},{label:r.t(f.ENDS_WITH.label),value:f.ENDS_WITH.operator},{label:r.t(f.EQUALS.label),value:f.EQUALS.operator}]},{options:[{label:r.t(f.GREATER_THAN.label),value:f.GREATER_THAN.operator},{label:r.t(f.GREATER_THAN_OR_EQUAL.label),value:f.GREATER_THAN_OR_EQUAL.operator},{label:r.t(f.LESS_THAN.label),value:f.LESS_THAN.operator},{label:r.t(f.LESS_THAN_OR_EQUAL.label),value:f.LESS_THAN_OR_EQUAL.operator},{label:r.t(f.EQUAL.label),value:f.EQUAL.operator},{label:r.t(f.NOT_EQUAL.label),value:f.NOT_EQUAL.operator},{label:r.t(f.BETWEEN.label),value:f.BETWEEN.operator},{label:r.t(f.NOT_BETWEEN.label),value:f.NOT_BETWEEN.operator}]},{options:[{label:r.t(f.CUSTOM.label),value:f.CUSTOM.operator}]}],[e,r])}function Qt(r){const e=r.getCurrentLocale();return I.useMemo(()=>f.ALL_CONDITIONS.filter(t=>t.numOfParameters!==2).map(t=>({label:r.t(t.label),value:t.operator})),[e,r])}function Gt(r){const{model:e}=r,t=g.useDependency(u.LocaleService),s=g.useObservable(e.searchString$,"",!0),n=g.useObservable(e.filterItems$,void 0,!0),a=t.t("sheets-filter.panel.filter-only"),i=we(n),o=i.checked>0&&i.unchecked===0,l=i.checked>0&&i.unchecked>0,h=e.treeMapCache,d=I.useCallback(()=>{e.onCheckAllToggled(!o)},[e,o]),p=I.useCallback(v=>{e.setSearchString(v)},[e]);function T(v){let C=[];return v.forEach(E=>{E.checked&&C.push(E.key),E.children&&(C=C.concat(T(E.children)))}),C}return m.jsxs("div",{"data-u-comp":"sheets-filter-panel-values-container",className:"univer-flex univer-h-full univer-min-h-[300px] univer-flex-col",children:[m.jsx(N.Input,{autoFocus:!0,value:s,placeholder:t.t("sheets-filter.panel.search-placeholder"),onChange:p}),m.jsxs("div",{"data-u-comp":"sheets-filter-panel",className:N.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",N.borderClassName),children:[m.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:m.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-py-0 univer-pl-5 univer-pr-0.5 univer-text-sm",children:[m.jsx(N.Checkbox,{indeterminate:l,disabled:n.length===0,checked:o,onChange:d}),m.jsx("span",{"data-u-comp":"sheets-filter-panel-values-item-text",className:"univer-mx-1 univer-inline-block univer-flex-shrink univer-truncate univer-text-gray-900 dark:!univer-text-white",children:`${t.t("sheets-filter.panel.select-all")}`}),m.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})`})]})}),m.jsx("div",{"data-u-comp":"sheets-filter-panel-values-virtual",className:"univer-flex-grow",children:m.jsx(N.Tree,{data:n,defaultExpandAll:!1,valueGroup:T(n),onChange:v=>{e.onFilterCheckToggled(v)},defaultCache:h,itemHeight:28,treeNodeClassName:`
1
+ "use strict";var nt=Object.defineProperty;var ot=(r,e,t)=>e in r?nt(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var _=(r,e,t)=>ot(r,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("@univerjs/core"),c=require("@univerjs/sheets-filter"),$=require("@univerjs/sheets-ui"),g=require("@univerjs/ui"),X=require("@univerjs/engine-render"),y=require("@univerjs/sheets"),S=require("rxjs"),Te=require("@univerjs/rpc"),N=require("@univerjs/design"),I=require("react"),m=require("react/jsx-runtime");var w=(r=>(r[r.FIRST=0]="FIRST",r[r.SECOND=1]="SECOND",r))(w||{}),F=(r=>(r.NONE="none",r.STARTS_WITH="startsWith",r.DOES_NOT_START_WITH="doesNotStartWith",r.ENDS_WITH="endsWith",r.DOES_NOT_END_WITH="doesNotEndWith",r.CONTAINS="contains",r.DOES_NOT_CONTAIN="doesNotContain",r.EQUALS="equals",r.NOT_EQUALS="notEquals",r.EMPTY="empty",r.NOT_EMPTY="notEmpty",r.BETWEEN="between",r.NOT_BETWEEN="notBetween",r.CUSTOM="custom",r))(F||{}),f;(r=>{r.NONE={label:"sheets-filter.conditions.none",operator:F.NONE,order:w.SECOND,numOfParameters:0,getDefaultFormParams:()=>{throw new Error("[FilterConditionItems.NONE]: should not have initial form params!")},testMappingParams:i=>i.operator1===F.NONE,mapToFilterColumn:()=>null,testMappingFilterColumn:i=>!i.customFilters&&!i.filters?{}:!1},r.EMPTY={label:"sheets-filter.conditions.empty",operator:F.EMPTY,order:w.SECOND,numOfParameters:0,getDefaultFormParams:()=>{throw new Error("[FilterConditionItems.EMPTY]: should not have initial form params!")},testMappingParams:({operator1:i})=>i===F.EMPTY,mapToFilterColumn:()=>({customFilters:{customFilters:[{val:""}]}}),testMappingFilterColumn:i=>{var h;if(((h=i.customFilters)==null?void 0:h.customFilters.length)!==1)return!1;const o=i.customFilters.customFilters[0];return o.val===""&&o.operator===void 0?{operator1:F.EMPTY}:!1}},r.NOT_EMPTY={label:"sheets-filter.conditions.not-empty",operator:F.NOT_EMPTY,order:w.SECOND,numOfParameters:0,getDefaultFormParams:()=>{throw new Error("[FilterConditionItems.NOT_EMPTY]: should not have initial form params!")},testMappingParams:({operator1:i})=>i===F.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 o=i.customFilters.customFilters[0];return o.val===" "&&o.operator===c.CustomFilterOperator.NOT_EQUALS?{operator1:F.NOT_EMPTY}:!1}},r.TEXT_CONTAINS={label:"sheets-filter.conditions.text-contains",operator:F.CONTAINS,order:w.FIRST,numOfParameters:1,getDefaultFormParams:()=>({operator1:F.CONTAINS,val1:""}),testMappingParams:i=>{const[o]=j(i);return o===F.CONTAINS},mapToFilterColumn:i=>{const{val1:o}=i;return o===""?null:{customFilters:{customFilters:[{val:`*${o}*`}]}}},testMappingFilterColumn:i=>{var h;if(((h=i.customFilters)==null?void 0:h.customFilters.length)!==1)return!1;const o=i.customFilters.customFilters[0],l=o.val.toString();return!o.operator&&l.startsWith("*")&&l.endsWith("*")?{operator1:F.CONTAINS,val1:l.slice(1,-1)}:!1}},r.DOES_NOT_CONTAIN={label:"sheets-filter.conditions.does-not-contain",operator:F.DOES_NOT_CONTAIN,order:w.FIRST,numOfParameters:1,getDefaultFormParams:()=>({operator1:F.DOES_NOT_CONTAIN,val1:""}),mapToFilterColumn:i=>({customFilters:{customFilters:[{val:`*${i.val1}*`,operator:c.CustomFilterOperator.NOT_EQUALS}]}}),testMappingParams:i=>{const[o]=j(i);return o===F.DOES_NOT_CONTAIN},testMappingFilterColumn:i=>{var h;if(((h=i.customFilters)==null?void 0:h.customFilters.length)!==1)return!1;const o=i.customFilters.customFilters[0],l=o.val.toString();return o.operator===c.CustomFilterOperator.NOT_EQUALS&&l.startsWith("*")&&l.endsWith("*")?{operator1:F.DOES_NOT_CONTAIN,val1:l.slice(1,-1)}:!1}},r.STARTS_WITH={label:"sheets-filter.conditions.starts-with",operator:F.STARTS_WITH,order:w.FIRST,numOfParameters:1,getDefaultFormParams:()=>({operator1:F.STARTS_WITH,val1:""}),mapToFilterColumn:i=>({customFilters:{customFilters:[{val:`${i.val1}*`}]}}),testMappingParams:i=>{const[o]=j(i);return o===F.STARTS_WITH},testMappingFilterColumn:i=>{var h;if(((h=i.customFilters)==null?void 0:h.customFilters.length)!==1)return!1;const o=i.customFilters.customFilters[0],l=o.val.toString();return!o.operator&&l.endsWith("*")&&!l.startsWith("*")?{operator1:F.STARTS_WITH,val1:l.slice(0,-1)}:!1}},r.ENDS_WITH={label:"sheets-filter.conditions.ends-with",operator:F.ENDS_WITH,order:w.FIRST,numOfParameters:1,getDefaultFormParams:()=>({operator1:F.ENDS_WITH,val1:""}),mapToFilterColumn:i=>({customFilters:{customFilters:[{val:`*${i.val1}`}]}}),testMappingParams:i=>{const[o]=j(i);return o===F.ENDS_WITH},testMappingFilterColumn:i=>{var h;if(((h=i.customFilters)==null?void 0:h.customFilters.length)!==1)return!1;const o=i.customFilters.customFilters[0],l=o.val.toString();return!o.operator&&l.startsWith("*")&&!l.endsWith("*")?{operator1:F.ENDS_WITH,val1:l.slice(1)}:!1}},r.EQUALS={label:"sheets-filter.conditions.equals",operator:F.EQUALS,order:w.FIRST,numOfParameters:1,getDefaultFormParams:()=>({operator1:F.EQUALS,val1:""}),testMappingParams:i=>{const[o]=j(i);return o===F.EQUALS},mapToFilterColumn:i=>{const{val1:o}=i;return o===""?null:{customFilters:{customFilters:[{val:o}]}}},testMappingFilterColumn:i=>{var o,l,h;return((l=(o=i.filters)==null?void 0:o.filters)==null?void 0:l.length)===1?{operator1:F.EQUALS,val1:""}:((h=i.customFilters)==null?void 0:h.customFilters.length)===1&&!i.customFilters.customFilters[0].operator?{operator1:F.EQUALS,val1:i.customFilters.customFilters[0].val.toString()}:!1}},r.GREATER_THAN={label:"sheets-filter.conditions.greater-than",operator:c.CustomFilterOperator.GREATER_THAN,numOfParameters:1,order:w.FIRST,getDefaultFormParams:()=>({operator1:c.CustomFilterOperator.GREATER_THAN,val1:""}),mapToFilterColumn:i=>({customFilters:{customFilters:[{val:i.val1,operator:c.CustomFilterOperator.GREATER_THAN}]}}),testMappingParams:i=>{const[o]=j(i);return o===c.CustomFilterOperator.GREATER_THAN},testMappingFilterColumn:i=>{var l;if(((l=i.customFilters)==null?void 0:l.customFilters.length)!==1)return!1;const o=i.customFilters.customFilters[0];return o.operator!==c.CustomFilterOperator.GREATER_THAN?!1:{operator1:c.CustomFilterOperator.GREATER_THAN,val1:o.val.toString()}}},r.GREATER_THAN_OR_EQUAL={label:"sheets-filter.conditions.greater-than-or-equal",operator:c.CustomFilterOperator.GREATER_THAN_OR_EQUAL,numOfParameters:1,order:w.FIRST,getDefaultFormParams:()=>({operator1:c.CustomFilterOperator.GREATER_THAN_OR_EQUAL,val1:""}),testMappingParams:i=>{const[o]=j(i);return o===c.CustomFilterOperator.GREATER_THAN_OR_EQUAL},mapToFilterColumn:i=>({customFilters:{customFilters:[{val:i.val1,operator:c.CustomFilterOperator.GREATER_THAN_OR_EQUAL}]}}),testMappingFilterColumn:i=>{var l;if(((l=i.customFilters)==null?void 0:l.customFilters.length)!==1)return!1;const o=i.customFilters.customFilters[0];return o.operator!==c.CustomFilterOperator.GREATER_THAN_OR_EQUAL?!1:{operator1:c.CustomFilterOperator.GREATER_THAN_OR_EQUAL,val1:o.val.toString()}}},r.LESS_THAN={label:"sheets-filter.conditions.less-than",operator:c.CustomFilterOperator.LESS_THAN,numOfParameters:1,order:w.FIRST,getDefaultFormParams:()=>({operator1:c.CustomFilterOperator.LESS_THAN,val1:""}),testMappingParams:i=>{const[o]=j(i);return o===c.CustomFilterOperator.LESS_THAN},mapToFilterColumn:i=>({customFilters:{customFilters:[{val:i.val1,operator:c.CustomFilterOperator.LESS_THAN}]}}),testMappingFilterColumn:i=>{var l;if(((l=i.customFilters)==null?void 0:l.customFilters.length)!==1)return!1;const o=i.customFilters.customFilters[0];return o.operator!==c.CustomFilterOperator.LESS_THAN?!1:{operator1:c.CustomFilterOperator.LESS_THAN,val1:o.val.toString()}}},r.LESS_THAN_OR_EQUAL={label:"sheets-filter.conditions.less-than-or-equal",operator:c.CustomFilterOperator.LESS_THAN_OR_EQUAL,numOfParameters:1,order:w.FIRST,getDefaultFormParams:()=>({operator1:c.CustomFilterOperator.LESS_THAN_OR_EQUAL,val1:""}),testMappingParams:i=>{const[o]=j(i);return o===c.CustomFilterOperator.LESS_THAN_OR_EQUAL},mapToFilterColumn:i=>({customFilters:{customFilters:[{val:i.val1,operator:c.CustomFilterOperator.LESS_THAN_OR_EQUAL}]}}),testMappingFilterColumn:i=>{var l;if(((l=i.customFilters)==null?void 0:l.customFilters.length)!==1)return!1;const o=i.customFilters.customFilters[0];return o.operator!==c.CustomFilterOperator.LESS_THAN_OR_EQUAL?!1:{operator1:c.CustomFilterOperator.LESS_THAN_OR_EQUAL,val1:o.val.toString()}}},r.EQUAL={label:"sheets-filter.conditions.equal",operator:c.CustomFilterOperator.EQUAL,numOfParameters:1,order:w.FIRST,getDefaultFormParams:()=>({operator1:c.CustomFilterOperator.EQUAL,val1:""}),testMappingParams:i=>{const[o]=j(i);return o===c.CustomFilterOperator.EQUAL},mapToFilterColumn:i=>({customFilters:{customFilters:[{val:i.val1,operator:c.CustomFilterOperator.EQUAL}]}}),testMappingFilterColumn:i=>{var l;if(((l=i.customFilters)==null?void 0:l.customFilters.length)!==1)return!1;const o=i.customFilters.customFilters[0];return o.operator!==c.CustomFilterOperator.EQUAL?!1:{operator1:c.CustomFilterOperator.EQUAL,val1:o.val.toString()}}},r.NOT_EQUAL={label:"sheets-filter.conditions.not-equal",operator:c.CustomFilterOperator.NOT_EQUALS,numOfParameters:1,order:w.FIRST,getDefaultFormParams:()=>({operator1:c.CustomFilterOperator.NOT_EQUALS,val1:""}),testMappingParams:i=>{const[o]=j(i);return o===c.CustomFilterOperator.NOT_EQUALS},mapToFilterColumn:i=>({customFilters:{customFilters:[{val:i.val1,operator:c.CustomFilterOperator.NOT_EQUALS}]}}),testMappingFilterColumn:i=>{var l;if(((l=i.customFilters)==null?void 0:l.customFilters.length)!==1)return!1;const o=i.customFilters.customFilters[0];return o.operator!==c.CustomFilterOperator.NOT_EQUALS?!1:{operator1:c.CustomFilterOperator.NOT_EQUALS,val1:o.val.toString()}}},r.BETWEEN={label:"sheets-filter.conditions.between",operator:F.BETWEEN,order:w.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:o,operator1:l,operator2:h}=i;if(!o)return!1;const d=[l,h];return d.includes(c.CustomFilterOperator.GREATER_THAN_OR_EQUAL)&&d.includes(c.CustomFilterOperator.LESS_THAN_OR_EQUAL)},mapToFilterColumn:i=>{const{val1:o,val2:l,operator1:h}=i,d=h===c.CustomFilterOperator.GREATER_THAN_OR_EQUAL;return{customFilters:{and:u.BooleanNumber.TRUE,customFilters:[{val:d?o:l,operator:c.CustomFilterOperator.GREATER_THAN_OR_EQUAL},{val:d?l:o,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[o,l]=i.customFilters.customFilters;return o.operator===c.CustomFilterOperator.GREATER_THAN_OR_EQUAL&&l.operator===c.CustomFilterOperator.LESS_THAN_OR_EQUAL&&i.customFilters.and?{and:!0,operator1:c.CustomFilterOperator.GREATER_THAN_OR_EQUAL,val1:o.val.toString(),operator2:c.CustomFilterOperator.LESS_THAN_OR_EQUAL,val2:l.val.toString()}:l.operator===c.CustomFilterOperator.GREATER_THAN_OR_EQUAL&&o.operator===c.CustomFilterOperator.LESS_THAN_OR_EQUAL&&i.customFilters.and?{and:!0,operator1:c.CustomFilterOperator.GREATER_THAN_OR_EQUAL,val1:l.val.toString(),operator2:c.CustomFilterOperator.LESS_THAN_OR_EQUAL,val2:o.val.toLocaleString()}:!1}},r.NOT_BETWEEN={label:"sheets-filter.conditions.not-between",operator:F.NOT_BETWEEN,order:w.SECOND,numOfParameters:2,getDefaultFormParams:()=>({operator1:c.CustomFilterOperator.LESS_THAN,val1:"",operator2:c.CustomFilterOperator.GREATER_THAN,val2:""}),testMappingParams:i=>{const{and:o,operator1:l,operator2:h}=i;if(o)return!1;const d=[l,h];return d.includes(c.CustomFilterOperator.GREATER_THAN)&&d.includes(c.CustomFilterOperator.LESS_THAN)},mapToFilterColumn:i=>{const{val1:o,val2:l,operator1:h}=i,d=h===c.CustomFilterOperator.GREATER_THAN;return{customFilters:{customFilters:[{val:d?o:l,operator:c.CustomFilterOperator.GREATER_THAN},{val:d?l:o,operator:c.CustomFilterOperator.LESS_THAN}]}}},testMappingFilterColumn:i=>{var h;if(((h=i.customFilters)==null?void 0:h.customFilters.length)!==2)return!1;const[o,l]=i.customFilters.customFilters;return o.operator===c.CustomFilterOperator.LESS_THAN&&l.operator===c.CustomFilterOperator.GREATER_THAN&&!i.customFilters.and?{operator1:c.CustomFilterOperator.LESS_THAN,val1:o.val.toString(),operator2:c.CustomFilterOperator.GREATER_THAN,val2:l.val.toString()}:l.operator===c.CustomFilterOperator.LESS_THAN&&o.operator===c.CustomFilterOperator.GREATER_THAN&&!i.customFilters.and?{operator1:c.CustomFilterOperator.GREATER_THAN,val1:l.val.toString(),operator2:c.CustomFilterOperator.LESS_THAN,val2:o.val.toLocaleString()}:!1}},r.CUSTOM={label:"sheets-filter.conditions.custom",operator:F.CUSTOM,order:w.SECOND,numOfParameters:2,getDefaultFormParams:()=>({operator1:F.NONE,val1:"",operator2:F.NONE,val2:""}),testMappingParams:()=>!0,mapToFilterColumn:i=>{const{and:o,val1:l,val2:h,operator1:d,operator2:p}=i;function T(x,A){for(const L of r.ALL_CONDITIONS)if(L.operator===x)return L.mapToFilterColumn({val1:A,operator1:x})}const v=!d||d===r.NONE.operator,C=!p||p===r.NONE.operator;if(v&&C)return r.NONE.mapToFilterColumn({});if(v)return T(p,h);if(C)return T(d,l);const E=T(d,l),b=T(p,h),R={customFilters:[E.customFilters.customFilters[0],b.customFilters.customFilters[0]]};return o&&(R.and=u.BooleanNumber.TRUE),{customFilters:R}},testMappingFilterColumn:i=>{var h;if(((h=i.customFilters)==null?void 0:h.customFilters.length)!==2)return!1;const o=i.customFilters.customFilters.map(d=>a({customFilters:{customFilters:[d]}})),l={operator1:o[0][0].operator,val1:o[0][1].val1,operator2:o[1][0].operator,val2:o[1][1].val1};return i.customFilters.and&&(l.and=!0),l}},r.ALL_CONDITIONS=[r.NONE,r.EMPTY,r.NOT_EMPTY,r.TEXT_CONTAINS,r.DOES_NOT_CONTAIN,r.STARTS_WITH,r.ENDS_WITH,r.EQUALS,r.GREATER_THAN,r.GREATER_THAN_OR_EQUAL,r.LESS_THAN,r.LESS_THAN_OR_EQUAL,r.EQUAL,r.NOT_EQUAL,r.BETWEEN,r.NOT_BETWEEN,r.CUSTOM];function e(i){const o=r.ALL_CONDITIONS.find(l=>l.operator===i);if(!o)throw new Error(`[SheetsFilter]: no condition item found for operator: ${i}`);return o}r.getItemByOperator=e;function t(i,o){for(const l of r.ALL_CONDITIONS.filter(h=>h.numOfParameters===o))if(l.numOfParameters!==0&&l.testMappingParams(i))return l;for(const l of r.ALL_CONDITIONS)if(l.testMappingParams(i))return l;throw new Error("[SheetsFilter]: no condition item can be mapped from the filter map params!")}r.testMappingParams=t;function s(i){const o=r.ALL_CONDITIONS.find(l=>l.operator===i);return(o==null?void 0:o.numOfParameters)===0?{operator1:o.operator}:o.getDefaultFormParams()}r.getInitialFormParams=s;function n(i,o){return i.mapToFilterColumn(o)}r.mapToFilterColumn=n;function a(i){if(!i)return[r.NONE,{}];for(const o of r.ALL_CONDITIONS){const l=o.testMappingFilterColumn(i);if(l)return[o,l]}return[r.NONE,{}]}r.testMappingFilterColumn=a})(f||(f={}));function j(r){const{operator1:e,operator2:t,val1:s,val2:n}=r;if(e&&t)throw new Error("Both operator1 and operator2 are set!");if(!e&&!t)throw new Error("Neither operator1 and operator2 and both not set!");return e?[e,s]:[t,n]}function we(r){const e=[],t=[];let s=0,n=0;function a(i){i.leaf&&(i.checked?(e.push(i),s+=i.count):(t.push(i),n+=i.count)),i.children&&i.children.forEach(a)}return r.forEach(a),{checkedItems:e,uncheckedItems:t,checked:s,unchecked:n}}var lt=Object.getOwnPropertyDescriptor,at=(r,e,t,s)=>{for(var n=s>1?void 0:s?lt(e,t):e,a=r.length-1,i;a>=0;a--)(i=r[a])&&(n=i(n)||n);return n},Re=(r,e)=>(t,s)=>e(t,s,r);const Ue="sheets-filter.generate-filter-values.service",ve=u.createIdentifier(Ue);let xe=class extends u.Disposable{constructor(r,e,t){super(),this._localeService=r,this._univerInstanceService=e,this._logService=t}async getFilterValues(r){var p;const{unitId:e,subUnitId:t,filteredOutRowsByOtherColumns:s,filterColumn:n,filters:a,blankChecked:i,iterateRange:o,alreadyChecked:l}=r,h=this._univerInstanceService.getUnit(e),d=(p=this._univerInstanceService.getUnit(e))==null?void 0:p.getSheetBySheetId(t);return!h||!d?[]:(this._logService.debug("[SheetsGenerateFilterValuesService]","getFilterValues for",{unitId:e,subUnitId:t}),qe(a,this._localeService,o,d,new Set(s),n,new Set(l.map(String)),i,h.getStyles()))}};xe=at([Re(0,u.Inject(u.LocaleService)),Re(1,u.IUniverInstanceService),Re(2,u.ILogService)],xe);function qe(r,e,t,s,n,a,i,o,l){var b,R,x,A,L,M,V,Q,J,k;const h=new Map,d=new Map,p="yyyy-mm-dd",T="empty",v=!r&&((a==null?void 0:a.filterBy)===c.FilterBy.COLORS||(a==null?void 0:a.filterBy)===c.FilterBy.CONDITIONS)&&((b=a.filteredOutRows)==null?void 0:b.size);let C=0;for(const O of s.iterateByColumn(t,!1,!1)){const{row:Ne,rowSpan:pe=1}=O;let ee=0;for(;ee<pe;){const st=Ne+ee;if(n.has(st)){ee++;continue}const Z=O!=null&&O.value?u.extractPureTextFromCell(O.value):"";if(!Z){C+=1,ee+=pe;continue}const fe=(R=O.value)!=null&&R.v&&!O.value.p?(L=(A=l.get((x=O.value)==null?void 0:x.s))==null?void 0:A.n)==null?void 0:L.pattern:"",je=fe&&u.numfmt.getFormatInfo(fe).isDate;let Be=!1;if(je){const{year:B,month:G,day:P}=u.numfmt.getFormatDateInfo(fe);Be=B||G||P}if(fe&&je&&Be){const B=(M=s.getCellRaw(O.row,O.col))==null?void 0:M.v;if(!B){ee++;continue}const G=u.numfmt.format(p,Number(B)),[P,D,ae]=G.split("-").map(Number);let K=h.get(`${P}`);K||(K={title:`${P}`,key:`${P}`,children:[],count:0,leaf:!1,checked:!1},h.set(`${P}`,K),d.set(`${P}`,[`${P}`]));let W=(V=K.children)==null?void 0:V.find(ye=>ye.key===`${P}-${D}`);W||(W={title:e.t(`sheets-filter.date.${D}`),key:`${P}-${D}`,children:[],count:0,leaf:!1,checked:!1},(Q=K.children)==null||Q.push(W),d.set(`${P}-${D}`,[`${P}`,`${P}-${D}`]));const be=(J=W==null?void 0:W.children)==null?void 0:J.find(ye=>ye.key===`${P}-${D}-${ae}`);be?(be.originValues.add(Z),be.count++,W.count++,K.count++):((k=W.children)==null||k.push({title:`${ae}`,key:`${P}-${D}-${ae}`,count:1,originValues:new Set([Z]),leaf:!0,checked:v?!1:i.size?i.has(Z):!o}),W.count++,K.count++,d.set(`${P}-${D}-${ae}`,[`${P}`,`${P}-${D}`,`${P}-${D}-${ae}`]))}else{const B=Z;let G=h.get(B);G?G.count++:(G={title:Z,leaf:!0,checked:v?!1:i.size?i.has(Z):!o,key:B,count:1},h.set(B,G),d.set(B,[B]))}ee++}}const E=v?!1:r?o:!0;if(C>0){const O={title:e.t("sheets-filter.panel.empty"),count:C,leaf:!0,checked:E,key:T};h.set("empty",O),d.set("empty",[T])}return{filterTreeItems:ct(Array.from(h.values())),filterTreeMapCache:d}}function ct(r){return Array.from(r).sort((e,t)=>e.children&&!t.children?-1:!e.children&&t.children?1:ut(e.title,t.title)).map(e=>(e.children&&e.children.sort((t,s)=>{const n=Number.parseInt(t.key.split("-")[1],10),a=Number.parseInt(s.key.split("-")[1],10);return n-a}).forEach(t=>{t.children&&t.children.sort((s,n)=>{const a=Number.parseInt(s.key.split("-")[2],10),i=Number.parseInt(n.key.split("-")[2],10);return a-i})}),e))}const De=r=>!Number.isNaN(Number(r))&&!Number.isNaN(Number.parseFloat(r));function ut(r,e){const t=De(r),s=De(e);return t&&s?Number.parseFloat(r)-Number.parseFloat(e):t&&!s?-1:!t&&s?1:r.localeCompare(e)}function Le(r,e){for(const t of r){if(t.key===e)return t;if(t.children){const s=Le(t.children,e);if(s)return s}}return null}function Ze(r){return r.leaf?r.checked:r.children?r.children.every(e=>Ze(e)):!0}function ce(r,e){r.leaf&&(e!==void 0?r.checked=e:r.checked=!r.checked),r.children&&r.children.forEach(t=>ce(t,e))}function Ke(r,e){const t=[];return r.forEach(s=>{const n=s.originValues?e.some(o=>Array.from(s.originValues).some(l=>l.toLowerCase().includes(o.toLowerCase()))):!1,a=!n&&e.some(o=>s.title.toLowerCase().includes(o.toLowerCase()));if(n||a)t.push({...s});else if(s.children){const o=Ke(s.children,e);if(o.length>0){const l=o.reduce((h,d)=>h+d.count,0);t.push({...s,count:l,children:o})}}}),t}var ht=Object.getOwnPropertyDescriptor,Ee=(r,e,t,s)=>{for(var n=s>1?void 0:s?ht(e,t):e,a=r.length-1,i;a>=0;a--)(i=r[a])&&(n=i(n)||n);return n},he=(r,e)=>(t,s)=>e(t,s,r);u.createIdentifier("sheets-filter-ui.sheets-filter-panel.service");let q=class extends u.Disposable{constructor(e,t){super();_(this,"_filterBy$",new S.BehaviorSubject(c.FilterBy.VALUES));_(this,"filterBy$",this._filterBy$.asObservable());_(this,"_filterByModel$",new S.ReplaySubject(1));_(this,"filterByModel$",this._filterByModel$.asObservable());_(this,"_filterByModel",null);_(this,"_hasCriteria$",new S.BehaviorSubject(!1));_(this,"hasCriteria$",this._hasCriteria$.asObservable());_(this,"_filterModel",null);_(this,"_col$",new S.BehaviorSubject(-1));_(this,"col$",this._col$.asObservable());_(this,"_filterHeaderListener",null);this._injector=e,this._refRangeService=t}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,t){this.terminate(),this._filterModel=e,this._col$.next(t);const s=e.getFilterColumn(t);if(s){const n=s.getColumnData();if(n.customFilters){this._hasCriteria$.next(!0),this._setupByConditions(e,t);return}if(n.colorFilters){this._hasCriteria$.next(!0),this._setupByColors(e,t);return}if(n.filters){this._hasCriteria$.next(!0),this._setupByValues(e,t);return}this._hasCriteria$.next(!1),this._setupByValues(e,t);return}this._hasCriteria$.next(!1),this._setupByValues(e,t)}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,t){this._disposeFilterHeaderChangeListener();const s=e.unitId,n=e.subUnitId,a=e.getRange(),i={startColumn:t,startRow:a.startRow,endRow:a.startRow,endColumn:t};this._filterHeaderListener=this._refRangeService.watchRange(s,n,i,(o,l)=>{if(!l)this.terminate();else{const h=l.startColumn-o.startColumn;h!==0&&this._filterByModel.deltaCol(h)}})}async _setupByValues(e,t){this._disposePreviousModel();const s=e.getRange();if(s.startRow===s.endRow)return!1;const n=await ge.fromFilterColumn(this._injector,e,t);return this.filterByModel=n,this._filterBy$.next(c.FilterBy.VALUES),this._listenToFilterHeaderChange(e,t),!0}async _setupByColors(e,t){this._disposePreviousModel();const s=e.getRange();if(s.startRow===s.endRow)return!1;const n=await Ce.fromFilterColumn(this._injector,e,t);return this.filterByModel=n,this._filterBy$.next(c.FilterBy.COLORS),this._listenToFilterHeaderChange(e,t),!0}_setupByConditions(e,t){this._disposePreviousModel();const s=e.getRange();if(s.startRow===s.endRow)return!1;const n=_e.fromFilterColumn(this._injector,e,t,e.getFilterColumn(t));return this.filterByModel=n,this._filterBy$.next(c.FilterBy.CONDITIONS),this._listenToFilterHeaderChange(e,t),!0}_disposePreviousModel(){var e;(e=this._filterByModel)==null||e.dispose(),this.filterByModel=null}};q=Ee([he(0,u.Inject(u.Injector)),he(1,u.Inject(y.RefRangeService))],q);let _e=class extends u.Disposable{constructor(e,t,s,n,a){super();_(this,"canApply$",S.of(!0));_(this,"_conditionItem$");_(this,"conditionItem$");_(this,"_filterConditionFormParams$");_(this,"filterConditionFormParams$");this._filterModel=e,this.col=t,this._commandService=a,this._conditionItem$=new S.BehaviorSubject(s),this.conditionItem$=this._conditionItem$.asObservable(),this._filterConditionFormParams$=new S.BehaviorSubject(n),this.filterConditionFormParams$=this._filterConditionFormParams$.asObservable()}static fromFilterColumn(e,t,s,n){const[a,i]=f.testMappingFilterColumn(n==null?void 0:n.getColumnData());return e.createInstance(_e,t,s,a,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 t=f.ALL_CONDITIONS.find(s=>s.operator===e);if(!t)throw new Error(`[ByConditionsModel]: condition item not found for operator: ${e}!`);this._conditionItem$.next(t),this._filterConditionFormParams$.next(f.getInitialFormParams(e))}onConditionFormChange(e){const t={...this.filterConditionFormParams,...e};if(t.and!==!0&&delete t.and,typeof e.and<"u"||typeof e.operator1<"u"||typeof e.operator2<"u"){const s=f.testMappingParams(t,this.conditionItem.numOfParameters);this._conditionItem$.next(s)}this._filterConditionFormParams$.next(t)}};_e=Ee([he(4,u.ICommandService)],_e);let ge=class extends u.Disposable{constructor(e,t,s,n,a){super();_(this,"_rawFilterItems$");_(this,"rawFilterItems$");_(this,"filterItems$");_(this,"_filterItems",[]);_(this,"_treeMapCache");_(this,"canApply$");_(this,"_manuallyUpdateFilterItems$");_(this,"_searchString$");_(this,"searchString$");this._filterModel=e,this.col=t,this._commandService=a,this._treeMapCache=n,this._searchString$=new S.BehaviorSubject(""),this.searchString$=this._searchString$.asObservable(),this._rawFilterItems$=new S.BehaviorSubject(s),this.rawFilterItems$=this._rawFilterItems$.asObservable(),this._manuallyUpdateFilterItems$=new S.Subject,this.filterItems$=S.merge(S.combineLatest([this._searchString$.pipe(S.throttleTime(500,void 0,{leading:!0,trailing:!0}),S.startWith(void 0)),this._rawFilterItems$]).pipe(S.map(([i,o])=>{if(!i)return o;const h=i.toLowerCase().split(/\s+/).filter(d=>!!d);return Ke(o,h)})),this._manuallyUpdateFilterItems$).pipe(S.shareReplay(1)),this.canApply$=this.filterItems$.pipe(S.map(i=>we(i).checked>0)),this.disposeWithMe(this.filterItems$.subscribe(i=>this._filterItems=i))}static async fromFilterColumn(e,t,s){const n=e.get(u.IUniverInstanceService),a=e.get(u.LocaleService),i=e.get(ve,u.Quantity.OPTIONAL),{unitId:o,subUnitId:l}=t,h=n.getUniverSheetInstance(o);if(!h)throw new Error(`[ByValuesModel]: Workbook not found for filter model with unitId: ${o}!`);const d=h==null?void 0:h.getSheetBySheetId(l);if(!d)throw new Error(`[ByValuesModel]: Worksheet not found for filter model with unitId: ${o} and subUnitId: ${l}!`);const p=t.getRange(),T=s,v=t.getFilterColumn(s),C=v==null?void 0:v.getColumnData().filters,E=new Set(C==null?void 0:C.filters),b=!!(C&&C.blank),R=t.getFilteredOutRowsExceptCol(s),x={...p,startRow:p.startRow+1,startColumn:T,endColumn:T};let A,L;if(i){const M=await i.getFilterValues({unitId:o,subUnitId:l,filteredOutRowsByOtherColumns:Array.from(R),filterColumn:v,filters:!!C,blankChecked:b,iterateRange:x,alreadyChecked:Array.from(E)});A=M.filterTreeItems,L=M.filterTreeMapCache}else{const M=qe(!!C,a,x,d,R,v,E,b,h.getStyles());A=M.filterTreeItems,L=M.filterTreeMapCache}return e.createInstance(ge,t,s,A,L)}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 t=u.Tools.deepClone(this._filterItems);t.forEach(s=>ce(s,e)),this._manuallyUpdateFilterItems(t)}onFilterCheckToggled(e){const t=u.Tools.deepClone(this._filterItems),s=Le(t,e.key);if(!s)return;const n=Ze(s);ce(s,!n),this._manuallyUpdateFilterItems(t)}onFilterOnly(e){const t=u.Tools.deepClone(this._filterItems);t.forEach(s=>ce(s,!1)),e.forEach(s=>{const n=Le(t,s);n&&ce(n,!0)}),this._manuallyUpdateFilterItems(t)}_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=we(this._filterItems),{checked:t,checkedItems:s}=e,n=this.rawFilterItems;let a=0;for(const h of n)a+=h.count;const i=t===0,o=e.checked===a,l={colId:this.col};if(i)throw new Error("[ByValuesModel]: no checked items!");if(o)return this._commandService.executeCommand(c.SetSheetsFilterCriteriaCommand.id,{unitId:this._filterModel.unitId,subUnitId:this._filterModel.subUnitId,col:this.col,criteria:null});{l.filters={};const h=s.filter(p=>p.key!=="empty");h.length>0&&(l.filters={filters:h.flatMap(p=>p.originValues?Array.from(p.originValues):[p.title])}),h.length!==s.length&&(l.filters.blank=!0)}return this._commandService.executeCommand(c.SetSheetsFilterCriteriaCommand.id,{unitId:this._filterModel.unitId,subUnitId:this._filterModel.subUnitId,col:this.col,criteria:l})}};ge=Ee([he(4,u.ICommandService)],ge);let Ce=class extends u.Disposable{constructor(e,t,s,n,a){super();_(this,"canApply$",S.of(!0));_(this,"_cellFillColors$");_(this,"cellFillColors$");_(this,"_cellTextColors$");_(this,"cellTextColors$");this._filterModel=e,this.col=t,this._commandService=a,this._cellFillColors$=new S.BehaviorSubject(Array.from(s.values())),this.cellFillColors$=this._cellFillColors$.asObservable(),this._cellTextColors$=new S.BehaviorSubject(Array.from(n.values())),this.cellTextColors$=this._cellTextColors$.asObservable()}static async fromFilterColumn(e,t,s){var x,A,L;const n=e.get(u.IUniverInstanceService),{unitId:a,subUnitId:i}=t,o=n.getUniverSheetInstance(a);if(!o)throw new Error(`[ByColorsModel]: Workbook not found for filter model with unitId: ${a}!`);const l=o==null?void 0:o.getSheetBySheetId(i);if(!l)throw new Error(`[ByColorsModel]: Worksheet not found for filter model with unitId: ${a} and subUnitId: ${i}!`);const h=t.getRange(),d=s,p=(x=t.getFilterColumn(s))==null?void 0:x.getColumnData().colorFilters,T=t.getFilteredOutRowsExceptCol(s),v={...h,startRow:h.startRow+1,startColumn:d,endColumn:d},C=new Map,E=new Set((A=p==null?void 0:p.cellFillColors)!=null?A:[]),b=new Map,R=new Set((L=p==null?void 0:p.cellTextColors)!=null?L:[]);for(const M of l.iterateByColumn(v,!1,!0)){const{row:V,col:Q,value:J}=M;if(T.has(V))continue;const k=l.getComposedCellStyleByCellData(V,Q,J);if(k.bg&&k.bg.rgb){const O=new u.ColorKit(k.bg.rgb).toRgbString();C.has(O)||C.set(O,{color:O,checked:E.has(O)})}else C.set("default-fill-color",{color:null,checked:E.has(null)});if(k.cl&&k.cl.rgb){const O=new u.ColorKit(k.cl.rgb).toRgbString();b.has(O)||b.set(O,{color:O,checked:R.has(O)})}else b.set("default-font-color",{color:X.COLOR_BLACK_RGB,checked:R.has(X.COLOR_BLACK_RGB)})}return e.createInstance(Ce,t,s,C,b)}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,t=!0){const s=t?this.cellFillColors:this.cellTextColors,n=[];let a=!1;for(let i=0;i<s.length;i++){const o=s[i];if(o.color===e.color){a=!0,n.push({color:o.color,checked:!o.checked});continue}n.push({color:o.color,checked:o.checked})}a&&(this._resetColorsCheckedStatus(!t),t?this._cellFillColors$.next([...n]):this._cellTextColors$.next([...n]))}_resetColorsCheckedStatus(e=!0){const t=e?this.cellFillColors:this.cellTextColors,s=[];for(let n=0;n<t.length;n++)s.push({color:t[n].color,checked:!1});e?this._cellFillColors$.next([...s]):this._cellTextColors$.next([...s])}async apply(){if(this._disposed)return!1;const e=this.cellFillColors.filter(n=>n.checked).map(n=>n.color),t=this.cellTextColors.filter(n=>n.checked).map(n=>n.color);if(e.length===0&&t.length===0)return this._commandService.executeCommand(c.SetSheetsFilterCriteriaCommand.id,{unitId:this._filterModel.unitId,subUnitId:this._filterModel.subUnitId,col:this.col,criteria:null});const s={colId:this.col};return e.length>0?s.colorFilters={cellFillColors:e}:t.length>0&&(s.colorFilters={cellTextColors:t}),this._commandService.executeCommand(c.SetSheetsFilterCriteriaCommand.id,{unitId:this._filterModel.unitId,subUnitId:this._filterModel.subUnitId,col:this.col,criteria:s})}};Ce=Ee([he(4,u.ICommandService)],Ce);const se="FILTER_PANEL_OPENED",me={id:"sheet.operation.open-filter-panel",type:u.CommandType.OPERATION,handler:(r,e)=>{const t=r.get(u.IContextService),s=r.get(c.SheetsFilterService),n=r.get(q),a=r.get(u.ICommandService),i=r.has($.IEditorBridgeService)?r.get($.IEditorBridgeService):null;i!=null&&i.isVisible().visible&&a.syncExecuteCommand($.SetCellEditVisibleOperation.id,{visible:!1});const{unitId:o,subUnitId:l,col:h}=e,d=s.getFilterModel(o,l);return d?(n.setupCol(d,h),t.getContextValue(se)||t.setContextValue(se,!0),!0):!1}},ie={id:"sheet.operation.close-filter-panel",type:u.CommandType.OPERATION,handler:r=>{const e=r.get(u.IContextService),t=r.get(q),s=r.get(g.ILayoutService,u.Quantity.OPTIONAL);return e.getContextValue(se)?(e.setContextValue(se,!1),s==null||s.focus(),t.terminate()):!1}},ke={id:"sheet.operation.apply-filter",type:u.CommandType.OPERATION,handler:(r,e)=>{const{filterBy:t}=e;return r.get(q).changeFilterBy(t)}},mt="@univerjs/sheets-filter-ui",dt="0.17.0",ne={name:mt,version:dt},ze="sheets-filter-ui.config",Se={};var pt=Object.getOwnPropertyDescriptor,ft=(r,e,t,s)=>{for(var n=s>1?void 0:s?pt(e,t):e,a=r.length-1,i;a>=0;a--)(i=r[a])&&(n=i(n)||n);return n},te=(r,e)=>(t,s)=>e(t,s,r);let oe=class extends u.Disposable{constructor(r,e,t,s,n,a){super(),this._sheetsFilterService=r,this._localeService=e,this._commandService=t,this._sheetPermissionCheckPermission=s,this._injector=n,this._sheetsSelectionService=a,this._commandExecutedListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.beforeCommandExecuted(r=>{var e,t,s;if(r.id===c.SmartToggleSheetsFilterCommand.id){const n=this._injector.get(u.IUniverInstanceService),a=y.getSheetCommandTarget(n);if(!a)return;const{unitId:i,subUnitId:o,worksheet:l}=a,h=(e=this._sheetsFilterService.getFilterModel(i,o))==null?void 0:e.getRange();let d;if(h)d=this._sheetPermissionCheckPermission.permissionCheckWithRanges({rangeTypes:[y.RangeProtectionPermissionViewPoint],worksheetTypes:[y.WorksheetFilterPermission,y.WorksheetViewPermission]},[h],i,o);else{const p=(t=this._sheetsSelectionService.getCurrentLastSelection())==null?void 0:t.range;if(p){let T={...p};T=p.startColumn===p.endColumn&&p.startRow===p.endRow?y.expandToContinuousRange(T,{left:!0,right:!0,up:!0,down:!0},l):T,d=this._sheetPermissionCheckPermission.permissionCheckWithRanges({rangeTypes:[y.RangeProtectionPermissionViewPoint],worksheetTypes:[y.WorksheetViewPermission,y.WorksheetFilterPermission]},[T],i,o)}else d=this._sheetPermissionCheckPermission.permissionCheckWithoutRange({rangeTypes:[y.RangeProtectionPermissionViewPoint],worksheetTypes:[y.WorksheetViewPermission,y.WorksheetFilterPermission]})}d||this._sheetPermissionCheckPermission.blockExecuteWithoutPermission(this._localeService.t("permission.dialog.filterErr"))}if(r.id===me.id){const n=r.params,{unitId:a,subUnitId:i}=n,o=(s=this._sheetsFilterService.getFilterModel(a,i))==null?void 0:s.getRange(),l=u.Tools.deepClone(o);l&&(l.startColumn=n.col,l.endColumn=n.col,this._sheetPermissionCheckPermission.permissionCheckWithRanges({rangeTypes:[y.RangeProtectionPermissionViewPoint],worksheetTypes:[y.WorksheetFilterPermission,y.WorksheetViewPermission]},[l],a,i)||this._sheetPermissionCheckPermission.blockExecuteWithoutPermission(this._localeService.t("permission.dialog.filterErr")))}}))}};oe=ft([te(0,u.Inject(c.SheetsFilterService)),te(1,u.Inject(u.LocaleService)),te(2,u.ICommandService),te(3,u.Inject(y.SheetPermissionCheckController)),te(4,u.Inject(u.Injector)),te(5,u.Inject(y.SheetsSelectionsService))],oe);const Y=16,vt=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 He{static drawNoCriteria(e,t,s,n){e.save(),X.Rect.drawWith(e,{radius:2,width:Y,height:Y,fill:n}),e.lineCap="square",e.strokeStyle=s,e.scale(t/Y,t/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,t,s,n){e.save(),X.Rect.drawWith(e,{radius:2,width:Y,height:Y,fill:n}),e.scale(t/Y,t/Y),e.fillStyle=s,e.fill(vt),e.restore()}}var _t=Object.getOwnPropertyDescriptor,gt=(r,e,t,s)=>{for(var n=s>1?void 0:s?_t(e,t):e,a=r.length-1,i;a>=0;a--)(i=r[a])&&(n=i(n)||n);return n},Pe=(r,e)=>(t,s)=>e(t,s,r);const H=16,ue=1;let $e=class extends X.Shape{constructor(e,t,s,n,a){super(e,t);_(this,"_cellWidth",0);_(this,"_cellHeight",0);_(this,"_filterParams");_(this,"_hovered",!1);this._contextService=s,this._commandService=n,this._themeService=a,this.setShapeProps(t),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 t=this._cellHeight,s=this._cellWidth,n=H-s,a=H-t;e.save();const i=new Path2D;i.rect(n,a,s,t),e.clip(i);const{hasCriteria:o}=this._filterParams,l=this._themeService.getColorFromTheme("primary.600"),h=this._hovered?this._themeService.getColorFromTheme("gray.50"):"rgba(255, 255, 255, 1.0)";o?He.drawHasCriteria(e,H,l,h):He.drawNoCriteria(e,H,l,h),e.restore()}onPointerDown(e){if(e.button===2)return;const{col:t,unitId:s,subUnitId:n}=this._filterParams;this._contextService.getContextValue(se)||!this._commandService.hasCommand(me.id)||setTimeout(()=>{this._commandService.executeCommand(me.id,{unitId:s,subUnitId:n,col:t})},200)}onPointerEnter(){this._hovered=!0,this.makeDirty(!0)}onPointerLeave(){this._hovered=!1,this.makeDirty(!0)}};$e=gt([Pe(2,u.IContextService),Pe(3,u.ICommandService),Pe(4,u.Inject(u.ThemeService))],$e);var Ct=Object.getOwnPropertyDescriptor,St=(r,e,t,s)=>{for(var n=s>1?void 0:s?Ct(e,t):e,a=r.length-1,i;a>=0;a--)(i=r[a])&&(n=i(n)||n);return n},z=(r,e)=>(t,s)=>e(t,s,r);const Ft=1e3,Tt=5e3;function Et(r,e,t,s){switch(s){case u.VerticalAlign.TOP:return r+ue;case u.VerticalAlign.MIDDLE:return r+Math.max(0,(t-H)/2);case u.VerticalAlign.BOTTOM:default:return e-H-ue}}let Me=class extends u.RxDisposable{constructor(e,t,s,n,a,i,o,l){super();_(this,"_filterRangeShape",null);_(this,"_buttonRenderDisposable",null);_(this,"_filterButtonShapes",[]);this._context=e,this._injector=t,this._sheetSkeletonManagerService=s,this._sheetsFilterService=n,this._themeService=a,this._sheetInterceptorService=i,this._commandService=o,this._selectionRenderService=l,this._initRenderer()}dispose(){super.dispose(),this._disposeRendering()}_initRenderer(){this._sheetSkeletonManagerService.currentSkeleton$.pipe(S.switchMap(e=>{var o,l;if(!e)return S.of(null);const{unit:t,unitId:s}=this._context,n=((o=t.getActiveSheet())==null?void 0:o.getSheetId())||"",a=(l=this._sheetsFilterService.getFilterModel(s,n))!=null?l:void 0,i=()=>({unitId:s,worksheetId:n,filterModel:a,range:a==null?void 0:a.getRange(),skeleton:e.skeleton});return u.fromCallback(this._commandService.onCommandExecuted.bind(this._commandService)).pipe(S.filter(([h])=>{var d;return h.type===u.CommandType.MUTATION&&((d=h.params)==null?void 0:d.unitId)===t.getUnitId()&&(c.FILTER_MUTATIONS.has(h.id)||h.id===y.SetRangeValuesMutation.id)}),S.throttleTime(20,void 0,{leading:!1,trailing:!0}),S.map(i),S.startWith(i()))}),S.takeUntil(this.dispose$)).subscribe(e=>{this._disposeRendering(),!(!e||!e.range)&&(this._renderRange(e.range,e.skeleton),this._renderButtons(e))})}_renderRange(e,t){const{scene:s}=this._context,{rowHeaderWidth:n,columnHeaderHeight:a}=t,i=this._filterRangeShape=new $.SelectionControl(s,Ft,this._themeService,{rowHeaderWidth:n,columnHeaderHeight:a,enableAutoFill:!1,highlightHeader:!1}),o={range:e,primary:null,style:{fill:"rgba(0, 0, 0, 0.0)"}},l=$.attachSelectionWithCoord(o,t);i.updateRangeBySelectionWithCoord(l),i.setEvent(!1),s.makeDirty(!0)}_renderButtons(e){const{range:t,filterModel:s,unitId:n,skeleton:a,worksheetId:i}=e,{unit:o,scene:l}=this._context,h=o.getSheetBySheetId(i);if(!h)return;this._interceptCellContent(n,i,e.range);const{startColumn:d,endColumn:p,startRow:T}=t;for(let v=d;v<=p;v++){const C=`sheets-filter-button-${v}`,E=$.getCoordByCell(T,v,l,a),b=h.getComposedCellStyle(T,v),R=(b==null?void 0:b.vt)||u.VerticalAlign.BOTTOM,{startX:x,startY:A,endX:L,endY:M}=E,V=L-x,Q=M-A;if(Q<=ue||V<=ue)continue;const J=!!s.getFilterColumn(v),k=L-H-ue,O=Et(A,M,Q,R),Ne={left:k,top:O,height:H,width:H,zIndex:Tt,cellHeight:Q,cellWidth:V,filterParams:{unitId:n,subUnitId:i,col:v,hasCriteria:J}},pe=this._injector.createInstance($e,C,Ne);this._filterButtonShapes.push(pe)}l.addObjects(this._filterButtonShapes),l.makeDirty()}_interceptCellContent(e,t,s){const{startRow:n,startColumn:a,endColumn:i}=s;this._buttonRenderDisposable=this._sheetInterceptorService.intercept(y.INTERCEPTOR_POINT.CELL_CONTENT,{effect:u.InterceptorEffectEnum.Style,handler:(o,l,h)=>{const{row:d,col:p,unitId:T,subUnitId:v}=l;return T!==e||v!==t||d!==n||p<a||p>i||((!o||o===l.rawData)&&(o={...l.rawData}),o.fontRenderExtension={...o==null?void 0:o.fontRenderExtension,rightOffset:H}),h(o)},priority:10})}_disposeRendering(){var e,t;(e=this._filterRangeShape)==null||e.dispose(),this._filterButtonShapes.forEach(s=>s.dispose()),(t=this._buttonRenderDisposable)==null||t.dispose(),this._filterRangeShape=null,this._buttonRenderDisposable=null,this._filterButtonShapes=[]}};Me=St([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(y.SheetInterceptorService)),z(6,u.ICommandService),z(7,$.ISheetSelectionRenderService)],Me);var It=Object.getOwnPropertyDescriptor,Ot=(r,e,t,s)=>{for(var n=s>1?void 0:s?It(e,t):e,a=r.length-1,i;a>=0;a--)(i=r[a])&&(n=i(n)||n);return n},We=(r,e)=>(t,s)=>e(t,s,r);let de=class extends u.RxDisposable{constructor(r,e){super(),this._renderManagerService=r,this._sheetsRenderService=e,[c.SetSheetsFilterRangeMutation,c.SetSheetsFilterCriteriaMutation,c.RemoveSheetsFilterMutation,c.ReCalcSheetsFilterMutation].forEach(t=>this.disposeWithMe(this._sheetsRenderService.registerSkeletonChangingMutations(t.id))),this.disposeWithMe(this._renderManagerService.registerRenderModule(u.UniverInstanceType.UNIVER_SHEET,[Me]))}};de=Ot([We(0,X.IRenderManagerService),We(1,u.Inject($.SheetsRenderService))],de);var Nt=Object.defineProperty,bt=Object.getOwnPropertyDescriptor,yt=(r,e,t)=>e in r?Nt(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Rt=(r,e,t,s)=>{for(var n=s>1?void 0:s?bt(e,t):e,a=r.length-1,i;a>=0;a--)(i=r[a])&&(n=i(n)||n);return n},Ve=(r,e)=>(t,s)=>e(t,s,r),Ie=(r,e,t)=>yt(r,typeof e!="symbol"?e+"":e,t);exports.UniverSheetsFilterMobileUIPlugin=class extends u.Plugin{constructor(e=Se,t,s){super(),this._config=e,this._injector=t,this._configService=s;const{menu:n,...a}=u.merge({},Se,this._config);n&&this._configService.setConfig("menu",n,{merge:!0}),this._configService.setConfig(ze,a)}onStarting(){[[oe],[de]].forEach(e=>this._injector.add(e))}onReady(){this._injector.get(oe)}onRendered(){this._injector.get(de)}};Ie(exports.UniverSheetsFilterMobileUIPlugin,"type",u.UniverInstanceType.UNIVER_SHEET);Ie(exports.UniverSheetsFilterMobileUIPlugin,"pluginName","SHEET_FILTER_UI_PLUGIN");Ie(exports.UniverSheetsFilterMobileUIPlugin,"packageName",ne.name);Ie(exports.UniverSheetsFilterMobileUIPlugin,"version",ne.version);exports.UniverSheetsFilterMobileUIPlugin=Rt([u.DependentOn(c.UniverSheetsFilterPlugin),Ve(1,u.Inject(u.Injector)),Ve(2,u.IConfigService)],exports.UniverSheetsFilterMobileUIPlugin);function le({ref:r,...e}){const{icon:t,id:s,className:n,extend:a,...i}=e,o=`univerjs-icon univerjs-icon-${s} ${n||""}`.trim(),l=I.useRef(`_${wt()}`);return Xe(t,`${s}`,{defIds:t.defIds,idSuffix:l.current},{ref:r,className:o,...i},a)}function Xe(r,e,t,s,n){return I.createElement(r.tag,{key:e,...Pt(r,t,n),...s},(At(r,t).children||[]).map((a,i)=>Xe(a,`${e}-${r.tag}-${i}`,t,void 0,n)))}function Pt(r,e,t){const s={...r.attrs};t!=null&&t.colorChannel1&&s.fill==="colorChannel1"&&(s.fill=t.colorChannel1),r.tag==="mask"&&s.id&&(s.id=s.id+e.idSuffix),Object.entries(s).forEach(([a,i])=>{a==="mask"&&typeof i=="string"&&(s[a]=i.replace(/url\(#(.*)\)/,`url(#$1${e.idSuffix})`))});const{defIds:n}=e;return!n||n.length===0||(r.tag==="use"&&s["xlink:href"]&&(s["xlink:href"]=s["xlink:href"]+e.idSuffix),Object.entries(s).forEach(([a,i])=>{typeof i=="string"&&(s[a]=i.replace(/url\(#(.*)\)/,`url(#$1${e.idSuffix})`))})),s}function At(r,e){var s;const{defIds:t}=e;return!t||t.length===0?r:r.tag==="defs"&&((s=r.children)!=null&&s.length)?{...r,children:r.children.map(n=>typeof n.attrs.id=="string"&&t&&t.includes(n.attrs.id)?{...n,attrs:{...n.attrs,id:n.attrs.id+e.idSuffix}}:n)}:r}function wt(){return Math.random().toString(36).substring(2,8)}le.displayName="UniverIcon";const xt={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"}}]},Je=I.forwardRef(function(e,t){return I.createElement(le,Object.assign({},e,{id:"a-icon",ref:t,icon:xt}))});Je.displayName="AIcon";const Lt={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"}}]},et=I.forwardRef(function(e,t){return I.createElement(le,Object.assign({},e,{id:"ban-icon",ref:t,icon:Lt}))});et.displayName="BanIcon";const $t={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"}}]},tt=I.forwardRef(function(e,t){return I.createElement(le,Object.assign({},e,{id:"filter-icon",ref:t,icon:$t}))});tt.displayName="FilterIcon";const Mt={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.00016 1.33203C6.68162 1.33203 5.39269 1.72302 4.29636 2.45557C3.20004 3.18811 2.34555 4.2293 1.84097 5.44747C1.33638 6.66565 1.20436 8.00609 1.4616 9.2993C1.71883 10.5925 2.35377 11.7804 3.28612 12.7127C4.21847 13.6451 5.40636 14.28 6.69956 14.5373C7.99277 14.7945 9.33321 14.6625 10.5514 14.1579C11.7696 13.6533 12.8108 12.7988 13.5433 11.7025C14.2758 10.6062 14.6668 9.31724 14.6668 7.9987C14.6649 6.23118 13.9619 4.53662 12.7121 3.2868C11.4622 2.03697 9.76768 1.33397 8.00016 1.33203ZM7.66683 3.9987C7.86461 3.9987 8.05795 4.05735 8.2224 4.16723C8.38685 4.27711 8.51502 4.43329 8.59071 4.61601C8.6664 4.79874 8.6862 4.99981 8.64762 5.19379C8.60903 5.38777 8.51379 5.56595 8.37394 5.7058C8.23409 5.84566 8.0559 5.9409 7.86192 5.97948C7.66794 6.01807 7.46687 5.99826 7.28415 5.92258C7.10142 5.84689 6.94524 5.71872 6.83536 5.55427C6.72548 5.38982 6.66683 5.19648 6.66683 4.9987C6.66683 4.73348 6.77219 4.47913 6.95972 4.29159C7.14726 4.10405 7.40162 3.9987 7.66683 3.9987ZM9.3335 11.332H6.66683C6.49002 11.332 6.32045 11.2618 6.19543 11.1368C6.0704 11.0117 6.00016 10.8422 6.00016 10.6654C6.00016 10.4886 6.0704 10.319 6.19543 10.194C6.32045 10.0689 6.49002 9.9987 6.66683 9.9987H7.3335V7.9987H6.66683C6.49002 7.9987 6.32045 7.92846 6.19543 7.80343C6.0704 7.67841 6.00016 7.50884 6.00016 7.33203C6.00016 7.15522 6.0704 6.98565 6.19543 6.86063C6.32045 6.7356 6.49002 6.66536 6.66683 6.66536H8.00016C8.17698 6.66536 8.34655 6.7356 8.47157 6.86063C8.59659 6.98565 8.66683 7.15522 8.66683 7.33203V9.9987H9.3335C9.51031 9.9987 9.67988 10.0689 9.8049 10.194C9.92993 10.319 10.0002 10.4886 10.0002 10.6654C10.0002 10.8422 9.92993 11.0117 9.8049 11.1368C9.67988 11.2618 9.51031 11.332 9.3335 11.332Z"}}]},rt=I.forwardRef(function(e,t){return I.createElement(le,Object.assign({},e,{id:"info-icon",ref:t,icon:Mt}))});rt.displayName="InfoIcon";const Ut={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"}}]},it=I.forwardRef(function(e,t){return I.createElement(le,Object.assign({},e,{id:"success-icon",ref:t,icon:Ut}))});it.displayName="SuccessIcon";function kt(r){const e=r.get(c.SheetsFilterService);return{id:c.SmartToggleSheetsFilterCommand.id,type:g.MenuItemType.BUTTON_SELECTOR,icon:"FilterIcon",tooltip:"sheets-filter.toolbar.smart-toggle-filter-tooltip",hidden$:g.getMenuHiddenObservable(r,u.UniverInstanceType.UNIVER_SHEET),activated$:e.activeFilterModel$.pipe(S.map(t=>!!t)),disabled$:$.getObservableWithExclusiveRange$(r,$.getCurrentRangeDisable$(r,{worksheetTypes:[y.WorksheetFilterPermission,y.WorksheetViewPermission],rangeTypes:[y.RangeProtectionPermissionViewPoint]}))}}function jt(r){const e=r.get(c.SheetsFilterService);return{id:c.ClearSheetsFilterCriteriaCommand.id,type:g.MenuItemType.BUTTON,title:"sheets-filter.toolbar.clear-filter-criteria",hidden$:g.getMenuHiddenObservable(r,u.UniverInstanceType.UNIVER_SHEET),disabled$:e.activeFilterModel$.pipe(S.switchMap(t=>{var s;return(s=t==null?void 0:t.hasCriteria$.pipe(S.map(n=>!n)))!=null?s:S.of(!0)}))}}function Bt(r){const e=r.get(c.SheetsFilterService);return{id:c.ReCalcSheetsFilterCommand.id,type:g.MenuItemType.BUTTON,title:"sheets-filter.toolbar.re-calc-filter-conditions",hidden$:g.getMenuHiddenObservable(r,u.UniverInstanceType.UNIVER_SHEET),disabled$:e.activeFilterModel$.pipe(S.switchMap(t=>{var s;return(s=t==null?void 0:t.hasCriteria$.pipe(S.map(n=>!n)))!=null?s:S.of(!0)}))}}const Dt={[g.RibbonDataGroup.ORGANIZATION]:{[c.SmartToggleSheetsFilterCommand.id]:{order:2,menuItemFactory:kt,[c.ClearSheetsFilterCriteriaCommand.id]:{order:0,menuItemFactory:jt},[c.ReCalcSheetsFilterCommand.id]:{order:1,menuItemFactory:Bt}}}};function Ht(r){const{model:e}=r,t=g.useDependency(u.LocaleService),s=g.useObservable(e.cellFillColors$,[],!0),n=g.useObservable(e.cellTextColors$,[],!0),a=I.useCallback(o=>{e.onFilterCheckToggled(o)},[e]),i=I.useCallback(o=>{e.onFilterCheckToggled(o,!1)},[e]);return m.jsx("div",{"data-u-comp":"sheets-filter-panel-colors-container",className:"univer-flex univer-h-full univer-min-h-[300px] univer-flex-col",children:m.jsxs("div",{"data-u-comp":"sheets-filter-panel",className:N.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",N.borderClassName),children:[s.length>1&&m.jsxs("div",{children:[m.jsx("div",{className:"univer-mb-2 univer-text-sm univer-text-gray-900 dark:!univer-text-white",children:t.t("sheets-filter.panel.filter-by-cell-fill-color")}),m.jsx("div",{className:"univer-grid univer-grid-cols-8 univer-items-center univer-justify-start univer-gap-2",children:s.map((o,l)=>m.jsxs("div",{className:"univer-relative univer-size-6",onClick:()=>a(o),children:[o.color?m.jsx("button",{type:"button",className:N.clsx("univer-box-border univer-size-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:o.color}}):m.jsx(et,{className:"univer-size-6 univer-cursor-pointer univer-rounded-full hover:univer-ring-2 hover:univer-ring-offset-2 hover:univer-ring-offset-white"}),o.checked&&m.jsx(Qe,{})]},`sheets-filter-cell-fill-color-${l}`))})]}),n.length>1&&m.jsxs("div",{children:[m.jsx("div",{className:"univer-mb-2 univer-text-sm univer-text-gray-900 dark:!univer-text-white",children:t.t("sheets-filter.panel.filter-by-cell-text-color")}),m.jsx("div",{className:"univer-grid univer-grid-cols-8 univer-items-center univer-justify-start univer-gap-2",children:n.map((o,l)=>m.jsxs("div",{className:"univer-relative univer-size-6",onClick:()=>i(o),children:[m.jsx("div",{className:"univer-box-border univer-flex univer-size-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:m.jsx(Je,{style:{color:o.color}})}),o.checked&&m.jsx(Qe,{})]},`sheets-filter-cell-text-color-${l}`))})]}),s.length<=1&&n.length<=1&&m.jsx("div",{className:"univer-flex univer-size-full univer-items-center univer-justify-center univer-text-sm univer-text-gray-900 dark:!univer-text-gray-200",children:t.t("sheets-filter.panel.filter-by-color-none")})]})})}function Qe(){return m.jsx("div",{className:"univer-absolute -univer-bottom-0.5 -univer-right-0.5 univer-flex univer-size-3 univer-cursor-pointer univer-items-center univer-justify-center univer-rounded-full univer-bg-white",children:m.jsx(it,{className:"univer-size-full univer-font-bold univer-text-[#418F1F]"})})}function Wt(r){var v,C;const{model:e}=r,t=g.useDependency(u.LocaleService),s=g.useObservable(e.conditionItem$,void 0),n=g.useObservable(e.filterConditionFormParams$,void 0),a=n!=null&&n.and?"AND":"OR",i=I.useCallback(E=>{e.onConditionFormChange({and:E==="AND"})},[e]),o=Vt(t),l=I.useCallback(E=>{e.onPrimaryConditionChange(E)},[e]),h=Qt(t),d=I.useCallback(E=>{e.onConditionFormChange(E)},[e]),p=t.t("sheets-filter.panel.input-values-placeholder");function T(E,b,R){const x=f.getItemByOperator(E).numOfParameters===1;return m.jsxs(m.Fragment,{children:[R==="operator2"&&m.jsxs(N.RadioGroup,{value:a,onChange:i,children:[m.jsx(N.Radio,{value:"AND",children:t.t("sheets-filter.panel.and")}),m.jsx(N.Radio,{value:"OR",children:t.t("sheets-filter.panel.or")})]}),m.jsx(N.Select,{value:E,options:h,onChange:A=>d({[R]:A})}),x&&m.jsx("div",{children:m.jsx(N.Input,{className:"univer-mt-2",value:b,placeholder:p,onChange:A=>d({[R==="operator1"?"val1":"val2"]:A})})})]})}return m.jsx("div",{"data-u-comp":"sheets-filter-panel-conditions-container",className:"univer-flex univer-h-full univer-min-h-[300px] univer-flex-col",children:s&&n&&m.jsxs(m.Fragment,{children:[m.jsx(N.Select,{value:s.operator,options:o,onChange:l}),f.getItemByOperator(s.operator).numOfParameters!==0?m.jsxs("div",{"data-u-comp":"sheets-filter-panel-conditions-container-inner",className:N.clsx("univer-mt-2 univer-flex-grow univer-overflow-hidden univer-rounded-md univer-p-2",N.borderClassName),children:[s.numOfParameters>=1&&T(n.operator1,(v=n.val1)!=null?v:"","operator1"),s.numOfParameters>=2&&T(n.operator2,(C=n.val2)!=null?C:"","operator2"),m.jsxs("div",{"data-u-comp":"sheets-filter-panel-conditions-desc",className:"univer-mt-2 univer-text-xs univer-text-gray-500",children:[t.t("sheets-filter.panel.?"),m.jsx("br",{}),t.t("sheets-filter.panel.*")]})]}):null]})})}function Vt(r){const e=r.getCurrentLocale();return I.useMemo(()=>[{options:[{label:r.t(f.NONE.label),value:f.NONE.operator}]},{options:[{label:r.t(f.EMPTY.label),value:f.EMPTY.operator},{label:r.t(f.NOT_EMPTY.label),value:f.NOT_EMPTY.operator}]},{options:[{label:r.t(f.TEXT_CONTAINS.label),value:f.TEXT_CONTAINS.operator},{label:r.t(f.DOES_NOT_CONTAIN.label),value:f.DOES_NOT_CONTAIN.operator},{label:r.t(f.STARTS_WITH.label),value:f.STARTS_WITH.operator},{label:r.t(f.ENDS_WITH.label),value:f.ENDS_WITH.operator},{label:r.t(f.EQUALS.label),value:f.EQUALS.operator}]},{options:[{label:r.t(f.GREATER_THAN.label),value:f.GREATER_THAN.operator},{label:r.t(f.GREATER_THAN_OR_EQUAL.label),value:f.GREATER_THAN_OR_EQUAL.operator},{label:r.t(f.LESS_THAN.label),value:f.LESS_THAN.operator},{label:r.t(f.LESS_THAN_OR_EQUAL.label),value:f.LESS_THAN_OR_EQUAL.operator},{label:r.t(f.EQUAL.label),value:f.EQUAL.operator},{label:r.t(f.NOT_EQUAL.label),value:f.NOT_EQUAL.operator},{label:r.t(f.BETWEEN.label),value:f.BETWEEN.operator},{label:r.t(f.NOT_BETWEEN.label),value:f.NOT_BETWEEN.operator}]},{options:[{label:r.t(f.CUSTOM.label),value:f.CUSTOM.operator}]}],[e,r])}function Qt(r){const e=r.getCurrentLocale();return I.useMemo(()=>f.ALL_CONDITIONS.filter(t=>t.numOfParameters!==2).map(t=>({label:r.t(t.label),value:t.operator})),[e,r])}function Gt(r){const{model:e}=r,t=g.useDependency(u.LocaleService),s=g.useObservable(e.searchString$,"",!0),n=g.useObservable(e.filterItems$,void 0,!0),a=t.t("sheets-filter.panel.filter-only"),i=we(n),o=i.checked>0&&i.unchecked===0,l=i.checked>0&&i.unchecked>0,h=e.treeMapCache,d=I.useCallback(()=>{e.onCheckAllToggled(!o)},[e,o]),p=I.useCallback(v=>{e.setSearchString(v)},[e]);function T(v){let C=[];return v.forEach(E=>{E.checked&&C.push(E.key),E.children&&(C=C.concat(T(E.children)))}),C}return m.jsxs("div",{"data-u-comp":"sheets-filter-panel-values-container",className:"univer-flex univer-h-full univer-min-h-[300px] univer-flex-col",children:[m.jsx(N.Input,{autoFocus:!0,value:s,placeholder:t.t("sheets-filter.panel.search-placeholder"),onChange:p}),m.jsxs("div",{"data-u-comp":"sheets-filter-panel",className:N.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",N.borderClassName),children:[m.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:m.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-py-0 univer-pl-5 univer-pr-0.5 univer-text-sm",children:[m.jsx(N.Checkbox,{indeterminate:l,disabled:n.length===0,checked:o,onChange:d}),m.jsx("span",{"data-u-comp":"sheets-filter-panel-values-item-text",className:"univer-mx-1 univer-inline-block univer-flex-shrink univer-truncate univer-text-gray-900 dark:!univer-text-white",children:`${t.t("sheets-filter.panel.select-all")}`}),m.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})`})]})}),m.jsx("div",{"data-u-comp":"sheets-filter-panel-values-virtual",className:"univer-flex-grow",children:m.jsx(N.Tree,{data:n,defaultExpandAll:!1,valueGroup:T(n),onChange:v=>{e.onFilterCheckToggled(v)},defaultCache:h,itemHeight:28,treeNodeClassName:`
2
2
  univer-pr-2 univer-border-box univer-rounded-md
3
3
  [&:hover_a]:univer-inline-block
4
4
  hover:univer-bg-gray-50 univer-h-full
package/lib/es/index.js CHANGED
@@ -1,10 +1,10 @@
1
1
  var cr = Object.defineProperty;
2
2
  var ur = (t, e, r) => e in t ? cr(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r;
3
3
  var v = (t, e, r) => ur(t, typeof e != "symbol" ? e + "" : e, r);
4
- import { BooleanNumber as _t, createIdentifier as Mt, Inject as T, LocaleService as G, extractPureTextFromCell as hr, numfmt as Ke, Disposable as fe, IUniverInstanceService as Be, ILogService as dr, Injector as re, Quantity as xt, Tools as Pe, ColorKit as gt, ICommandService as j, CommandType as We, IContextService as Ve, ThemeService as Ut, RxDisposable as kt, fromCallback as mr, VerticalAlign as we, InterceptorEffectEnum as fr, UniverInstanceType as ie, DependentOn as Ht, Plugin as ot, merge as Dt, IConfigService as Bt, Optional as pr, registerDependencies as vr, touchDependencies as St } from "@univerjs/core";
4
+ import { BooleanNumber as _t, createIdentifier as Mt, Inject as T, LocaleService as G, IUniverInstanceService as Be, ILogService as hr, extractPureTextFromCell as dr, numfmt as Ke, Disposable as fe, Injector as re, Quantity as xt, Tools as Pe, ColorKit as gt, ICommandService as j, CommandType as We, IContextService as Ve, ThemeService as Ut, RxDisposable as kt, fromCallback as mr, VerticalAlign as we, InterceptorEffectEnum as fr, UniverInstanceType as ie, DependentOn as Ht, IConfigService as Dt, Plugin as ot, merge as Bt, Optional as pr, registerDependencies as vr, touchDependencies as St } from "@univerjs/core";
5
5
  import { CustomFilterOperator as u, FilterBy as P, SetSheetsFilterCriteriaCommand as V, SheetsFilterService as X, SmartToggleSheetsFilterCommand as Oe, FILTER_MUTATIONS as _r, SetSheetsFilterRangeMutation as gr, SetSheetsFilterCriteriaMutation as Sr, RemoveSheetsFilterMutation as Cr, ReCalcSheetsFilterMutation as Tr, UniverSheetsFilterPlugin as Wt, ReCalcSheetsFilterCommand as lt, ClearSheetsFilterCriteriaCommand as at, SheetsFilterSyncController as Er, RemoveSheetFilterCommand as Nr, SetSheetFilterRangeCommand as Fr } from "@univerjs/sheets-filter";
6
- import { IEditorBridgeService as Ct, SetCellEditVisibleOperation as Ir, SheetSkeletonManagerService as yr, SelectionControl as Or, attachSelectionWithCoord as br, getCoordByCell as Rr, ISheetSelectionRenderService as Ar, SheetsRenderService as Vt, getObservableWithExclusiveRange$ as Pr, getCurrentRangeDisable$ as wr, SheetsUIPart as $r, whenSheetEditorFocused as Lr, SheetCanvasPopManagerService as Mr } from "@univerjs/sheets-ui";
7
- import { ILayoutService as xr, MenuItemType as ct, getMenuHiddenObservable as ut, RibbonDataGroup as Ur, useDependency as D, useObservable as L, IMessageService as Qt, useComponentsOfPart as kr, ComponentContainer as Hr, KeyCode as Dr, MetaKeys as Tt, ComponentManager as Br, IShortcutService as Wr, IMenuManagerService as Vr } from "@univerjs/ui";
6
+ import { IEditorBridgeService as Ct, SetCellEditVisibleOperation as Ir, SheetSkeletonManagerService as yr, ISheetSelectionRenderService as Or, SelectionControl as br, attachSelectionWithCoord as Rr, getCoordByCell as Ar, SheetsRenderService as Vt, getObservableWithExclusiveRange$ as Pr, getCurrentRangeDisable$ as wr, SheetsUIPart as $r, whenSheetEditorFocused as Lr, SheetCanvasPopManagerService as Mr } from "@univerjs/sheets-ui";
7
+ import { ILayoutService as xr, getMenuHiddenObservable as ct, MenuItemType as ut, RibbonDataGroup as Ur, useDependency as D, useObservable as L, IMessageService as Qt, useComponentsOfPart as kr, ComponentContainer as Hr, KeyCode as Dr, MetaKeys as Tt, ComponentManager as Br, IShortcutService as Wr, IMenuManagerService as Vr } from "@univerjs/ui";
8
8
  import { COLOR_BLACK_RGB as Et, Rect as Nt, Shape as Qr, IRenderManagerService as Gt } from "@univerjs/engine-render";
9
9
  import { RefRangeService as Gr, SheetPermissionCheckController as jr, SheetsSelectionsService as Yr, getSheetCommandTarget as Zr, WorksheetFilterPermission as Se, WorksheetViewPermission as Ce, RangeProtectionPermissionViewPoint as Te, expandToContinuousRange as zr, SheetInterceptorService as Kr, SetRangeValuesMutation as qr, INTERCEPTOR_POINT as Xr } from "@univerjs/sheets";
10
10
  import { BehaviorSubject as Q, ReplaySubject as Jr, Subject as ei, merge as ti, combineLatest as ri, throttleTime as jt, startWith as Yt, map as ae, shareReplay as ii, of as pe, switchMap as ht, filter as si, takeUntil as ni, distinctUntilChanged as oi } from "rxjs";
@@ -534,7 +534,7 @@ let rt = class extends fe {
534
534
  rt = _i([
535
535
  Xe(0, T(G)),
536
536
  Xe(1, Be),
537
- Xe(2, dr)
537
+ Xe(2, hr)
538
538
  ], rt);
539
539
  function qt(t, e, r, s, n, a, i, o, l) {
540
540
  var N, F, R, O, A, w, Y, Z, se, M;
@@ -549,7 +549,7 @@ function qt(t, e, r, s, n, a, i, o, l) {
549
549
  ne++;
550
550
  continue;
551
551
  }
552
- const J = E != null && E.value ? hr(E.value) : "";
552
+ const J = E != null && E.value ? dr(E.value) : "";
553
553
  if (!J) {
554
554
  _ += 1, ne += Re;
555
555
  continue;
@@ -1226,7 +1226,7 @@ const ce = "FILTER_PANEL_OPENED", ke = {
1226
1226
  const { filterBy: r } = e;
1227
1227
  return t.get(q).changeFilterBy(r);
1228
1228
  }
1229
- }, Ti = "@univerjs/sheets-filter-ui", Ei = "0.16.1-insiders.20260311-074e8ca", ue = {
1229
+ }, Ti = "@univerjs/sheets-filter-ui", Ei = "0.17.0", ue = {
1230
1230
  name: Ti,
1231
1231
  version: Ei
1232
1232
  }, tr = "sheets-filter-ui.config", He = {};
@@ -1419,7 +1419,7 @@ let nt = class extends kt {
1419
1419
  });
1420
1420
  }
1421
1421
  _renderRange(e, r) {
1422
- const { scene: s } = this._context, { rowHeaderWidth: n, columnHeaderHeight: a } = r, i = this._filterRangeShape = new Or(
1422
+ const { scene: s } = this._context, { rowHeaderWidth: n, columnHeaderHeight: a } = r, i = this._filterRangeShape = new br(
1423
1423
  s,
1424
1424
  Ai,
1425
1425
  this._themeService,
@@ -1429,7 +1429,7 @@ let nt = class extends kt {
1429
1429
  enableAutoFill: !1,
1430
1430
  highlightHeader: !1
1431
1431
  }
1432
- ), l = br({
1432
+ ), l = Rr({
1433
1433
  range: e,
1434
1434
  primary: null,
1435
1435
  style: { fill: "rgba(0, 0, 0, 0.0)" }
@@ -1443,7 +1443,7 @@ let nt = class extends kt {
1443
1443
  this._interceptCellContent(n, i, e.range);
1444
1444
  const { startColumn: h, endColumn: m, startRow: S } = r;
1445
1445
  for (let p = h; p <= m; p++) {
1446
- const _ = `sheets-filter-button-${p}`, C = Rr(S, p, l, a), N = c.getComposedCellStyle(S, p), F = (N == null ? void 0 : N.vt) || we.BOTTOM, { startX: R, startY: O, endX: A, endY: w } = C, Y = A - R, Z = w - O;
1446
+ const _ = `sheets-filter-button-${p}`, C = Ar(S, p, l, a), N = c.getComposedCellStyle(S, p), F = (N == null ? void 0 : N.vt) || we.BOTTOM, { startX: R, startY: O, endX: A, endY: w } = C, Y = A - R, Z = w - O;
1447
1447
  if (Z <= Fe || Y <= Fe)
1448
1448
  continue;
1449
1449
  const se = !!s.getFilterColumn(p), M = A - B - Fe, E = wi(O, w, Z, F), Ye = {
@@ -1486,7 +1486,7 @@ nt = Ri([
1486
1486
  te(4, T(Ut)),
1487
1487
  te(5, T(Kr)),
1488
1488
  te(6, j),
1489
- te(7, Ar)
1489
+ te(7, Or)
1490
1490
  ], nt);
1491
1491
  var $i = Object.getOwnPropertyDescriptor, Li = (t, e, r, s) => {
1492
1492
  for (var n = s > 1 ? void 0 : s ? $i(e, r) : e, a = t.length - 1, i; a >= 0; a--)
@@ -1518,7 +1518,7 @@ var Mi = Object.defineProperty, xi = Object.getOwnPropertyDescriptor, Ui = (t, e
1518
1518
  let de = class extends ot {
1519
1519
  constructor(t = He, e, r) {
1520
1520
  super(), this._config = t, this._injector = e, this._configService = r;
1521
- const { menu: s, ...n } = Dt(
1521
+ const { menu: s, ...n } = Bt(
1522
1522
  {},
1523
1523
  He,
1524
1524
  this._config
@@ -1545,7 +1545,7 @@ Ge(de, "version", ue.version);
1545
1545
  de = ki([
1546
1546
  Ht(Wt),
1547
1547
  At(1, T(re)),
1548
- At(2, Bt)
1548
+ At(2, Dt)
1549
1549
  ], de);
1550
1550
  function _e({ ref: t, ...e }) {
1551
1551
  const { icon: r, id: s, className: n, extend: a, ...i } = e, o = `univerjs-icon univerjs-icon-${s} ${n || ""}`.trim(), l = pi(`_${Bi()}`);
@@ -1733,10 +1733,10 @@ function Yi(t) {
1733
1733
  const e = t.get(X);
1734
1734
  return {
1735
1735
  id: Oe.id,
1736
- type: ct.BUTTON_SELECTOR,
1736
+ type: ut.BUTTON_SELECTOR,
1737
1737
  icon: "FilterIcon",
1738
1738
  tooltip: "sheets-filter.toolbar.smart-toggle-filter-tooltip",
1739
- hidden$: ut(t, ie.UNIVER_SHEET),
1739
+ hidden$: ct(t, ie.UNIVER_SHEET),
1740
1740
  activated$: e.activeFilterModel$.pipe(ae((r) => !!r)),
1741
1741
  disabled$: Pr(
1742
1742
  t,
@@ -1754,9 +1754,9 @@ function Zi(t) {
1754
1754
  const e = t.get(X);
1755
1755
  return {
1756
1756
  id: at.id,
1757
- type: ct.BUTTON,
1757
+ type: ut.BUTTON,
1758
1758
  title: "sheets-filter.toolbar.clear-filter-criteria",
1759
- hidden$: ut(t, ie.UNIVER_SHEET),
1759
+ hidden$: ct(t, ie.UNIVER_SHEET),
1760
1760
  disabled$: e.activeFilterModel$.pipe(ht((r) => {
1761
1761
  var s;
1762
1762
  return (s = r == null ? void 0 : r.hasCriteria$.pipe(ae((n) => !n))) != null ? s : pe(!0);
@@ -1767,9 +1767,9 @@ function zi(t) {
1767
1767
  const e = t.get(X);
1768
1768
  return {
1769
1769
  id: lt.id,
1770
- type: ct.BUTTON,
1770
+ type: ut.BUTTON,
1771
1771
  title: "sheets-filter.toolbar.re-calc-filter-conditions",
1772
- hidden$: ut(t, ie.UNIVER_SHEET),
1772
+ hidden$: ct(t, ie.UNIVER_SHEET),
1773
1773
  disabled$: e.activeFilterModel$.pipe(ht((r) => {
1774
1774
  var s;
1775
1775
  return (s = r == null ? void 0 : r.hasCriteria$.pipe(ae((n) => !n))) != null ? s : pe(!0);
@@ -2364,7 +2364,7 @@ var as = Object.defineProperty, cs = Object.getOwnPropertyDescriptor, us = (t, e
2364
2364
  let me = class extends ot {
2365
2365
  constructor(t = He, e, r, s) {
2366
2366
  super(), this._config = t, this._injector = e, this._configService = r, this._rpcChannelService = s;
2367
- const { menu: n, ...a } = Dt(
2367
+ const { menu: n, ...a } = Bt(
2368
2368
  {},
2369
2369
  He,
2370
2370
  this._config
@@ -2400,7 +2400,7 @@ je(me, "version", ue.version);
2400
2400
  me = hs([
2401
2401
  Ht(Wt),
2402
2402
  et(1, T(re)),
2403
- et(2, Bt),
2403
+ et(2, Dt),
2404
2404
  et(3, pr(Zt))
2405
2405
  ], me);
2406
2406
  var ds = Object.getOwnPropertyDescriptor, ms = (t, e, r, s) => {
package/lib/index.js CHANGED
@@ -1,10 +1,10 @@
1
1
  var cr = Object.defineProperty;
2
2
  var ur = (t, e, r) => e in t ? cr(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r;
3
3
  var v = (t, e, r) => ur(t, typeof e != "symbol" ? e + "" : e, r);
4
- import { BooleanNumber as _t, createIdentifier as Mt, Inject as T, LocaleService as G, extractPureTextFromCell as hr, numfmt as Ke, Disposable as fe, IUniverInstanceService as Be, ILogService as dr, Injector as re, Quantity as xt, Tools as Pe, ColorKit as gt, ICommandService as j, CommandType as We, IContextService as Ve, ThemeService as Ut, RxDisposable as kt, fromCallback as mr, VerticalAlign as we, InterceptorEffectEnum as fr, UniverInstanceType as ie, DependentOn as Ht, Plugin as ot, merge as Dt, IConfigService as Bt, Optional as pr, registerDependencies as vr, touchDependencies as St } from "@univerjs/core";
4
+ import { BooleanNumber as _t, createIdentifier as Mt, Inject as T, LocaleService as G, IUniverInstanceService as Be, ILogService as hr, extractPureTextFromCell as dr, numfmt as Ke, Disposable as fe, Injector as re, Quantity as xt, Tools as Pe, ColorKit as gt, ICommandService as j, CommandType as We, IContextService as Ve, ThemeService as Ut, RxDisposable as kt, fromCallback as mr, VerticalAlign as we, InterceptorEffectEnum as fr, UniverInstanceType as ie, DependentOn as Ht, IConfigService as Dt, Plugin as ot, merge as Bt, Optional as pr, registerDependencies as vr, touchDependencies as St } from "@univerjs/core";
5
5
  import { CustomFilterOperator as u, FilterBy as P, SetSheetsFilterCriteriaCommand as V, SheetsFilterService as X, SmartToggleSheetsFilterCommand as Oe, FILTER_MUTATIONS as _r, SetSheetsFilterRangeMutation as gr, SetSheetsFilterCriteriaMutation as Sr, RemoveSheetsFilterMutation as Cr, ReCalcSheetsFilterMutation as Tr, UniverSheetsFilterPlugin as Wt, ReCalcSheetsFilterCommand as lt, ClearSheetsFilterCriteriaCommand as at, SheetsFilterSyncController as Er, RemoveSheetFilterCommand as Nr, SetSheetFilterRangeCommand as Fr } from "@univerjs/sheets-filter";
6
- import { IEditorBridgeService as Ct, SetCellEditVisibleOperation as Ir, SheetSkeletonManagerService as yr, SelectionControl as Or, attachSelectionWithCoord as br, getCoordByCell as Rr, ISheetSelectionRenderService as Ar, SheetsRenderService as Vt, getObservableWithExclusiveRange$ as Pr, getCurrentRangeDisable$ as wr, SheetsUIPart as $r, whenSheetEditorFocused as Lr, SheetCanvasPopManagerService as Mr } from "@univerjs/sheets-ui";
7
- import { ILayoutService as xr, MenuItemType as ct, getMenuHiddenObservable as ut, RibbonDataGroup as Ur, useDependency as D, useObservable as L, IMessageService as Qt, useComponentsOfPart as kr, ComponentContainer as Hr, KeyCode as Dr, MetaKeys as Tt, ComponentManager as Br, IShortcutService as Wr, IMenuManagerService as Vr } from "@univerjs/ui";
6
+ import { IEditorBridgeService as Ct, SetCellEditVisibleOperation as Ir, SheetSkeletonManagerService as yr, ISheetSelectionRenderService as Or, SelectionControl as br, attachSelectionWithCoord as Rr, getCoordByCell as Ar, SheetsRenderService as Vt, getObservableWithExclusiveRange$ as Pr, getCurrentRangeDisable$ as wr, SheetsUIPart as $r, whenSheetEditorFocused as Lr, SheetCanvasPopManagerService as Mr } from "@univerjs/sheets-ui";
7
+ import { ILayoutService as xr, getMenuHiddenObservable as ct, MenuItemType as ut, RibbonDataGroup as Ur, useDependency as D, useObservable as L, IMessageService as Qt, useComponentsOfPart as kr, ComponentContainer as Hr, KeyCode as Dr, MetaKeys as Tt, ComponentManager as Br, IShortcutService as Wr, IMenuManagerService as Vr } from "@univerjs/ui";
8
8
  import { COLOR_BLACK_RGB as Et, Rect as Nt, Shape as Qr, IRenderManagerService as Gt } from "@univerjs/engine-render";
9
9
  import { RefRangeService as Gr, SheetPermissionCheckController as jr, SheetsSelectionsService as Yr, getSheetCommandTarget as Zr, WorksheetFilterPermission as Se, WorksheetViewPermission as Ce, RangeProtectionPermissionViewPoint as Te, expandToContinuousRange as zr, SheetInterceptorService as Kr, SetRangeValuesMutation as qr, INTERCEPTOR_POINT as Xr } from "@univerjs/sheets";
10
10
  import { BehaviorSubject as Q, ReplaySubject as Jr, Subject as ei, merge as ti, combineLatest as ri, throttleTime as jt, startWith as Yt, map as ae, shareReplay as ii, of as pe, switchMap as ht, filter as si, takeUntil as ni, distinctUntilChanged as oi } from "rxjs";
@@ -534,7 +534,7 @@ let rt = class extends fe {
534
534
  rt = _i([
535
535
  Xe(0, T(G)),
536
536
  Xe(1, Be),
537
- Xe(2, dr)
537
+ Xe(2, hr)
538
538
  ], rt);
539
539
  function qt(t, e, r, s, n, a, i, o, l) {
540
540
  var N, F, R, O, A, w, Y, Z, se, M;
@@ -549,7 +549,7 @@ function qt(t, e, r, s, n, a, i, o, l) {
549
549
  ne++;
550
550
  continue;
551
551
  }
552
- const J = E != null && E.value ? hr(E.value) : "";
552
+ const J = E != null && E.value ? dr(E.value) : "";
553
553
  if (!J) {
554
554
  _ += 1, ne += Re;
555
555
  continue;
@@ -1226,7 +1226,7 @@ const ce = "FILTER_PANEL_OPENED", ke = {
1226
1226
  const { filterBy: r } = e;
1227
1227
  return t.get(q).changeFilterBy(r);
1228
1228
  }
1229
- }, Ti = "@univerjs/sheets-filter-ui", Ei = "0.16.1-insiders.20260311-074e8ca", ue = {
1229
+ }, Ti = "@univerjs/sheets-filter-ui", Ei = "0.17.0", ue = {
1230
1230
  name: Ti,
1231
1231
  version: Ei
1232
1232
  }, tr = "sheets-filter-ui.config", He = {};
@@ -1419,7 +1419,7 @@ let nt = class extends kt {
1419
1419
  });
1420
1420
  }
1421
1421
  _renderRange(e, r) {
1422
- const { scene: s } = this._context, { rowHeaderWidth: n, columnHeaderHeight: a } = r, i = this._filterRangeShape = new Or(
1422
+ const { scene: s } = this._context, { rowHeaderWidth: n, columnHeaderHeight: a } = r, i = this._filterRangeShape = new br(
1423
1423
  s,
1424
1424
  Ai,
1425
1425
  this._themeService,
@@ -1429,7 +1429,7 @@ let nt = class extends kt {
1429
1429
  enableAutoFill: !1,
1430
1430
  highlightHeader: !1
1431
1431
  }
1432
- ), l = br({
1432
+ ), l = Rr({
1433
1433
  range: e,
1434
1434
  primary: null,
1435
1435
  style: { fill: "rgba(0, 0, 0, 0.0)" }
@@ -1443,7 +1443,7 @@ let nt = class extends kt {
1443
1443
  this._interceptCellContent(n, i, e.range);
1444
1444
  const { startColumn: h, endColumn: m, startRow: S } = r;
1445
1445
  for (let p = h; p <= m; p++) {
1446
- const _ = `sheets-filter-button-${p}`, C = Rr(S, p, l, a), N = c.getComposedCellStyle(S, p), F = (N == null ? void 0 : N.vt) || we.BOTTOM, { startX: R, startY: O, endX: A, endY: w } = C, Y = A - R, Z = w - O;
1446
+ const _ = `sheets-filter-button-${p}`, C = Ar(S, p, l, a), N = c.getComposedCellStyle(S, p), F = (N == null ? void 0 : N.vt) || we.BOTTOM, { startX: R, startY: O, endX: A, endY: w } = C, Y = A - R, Z = w - O;
1447
1447
  if (Z <= Fe || Y <= Fe)
1448
1448
  continue;
1449
1449
  const se = !!s.getFilterColumn(p), M = A - B - Fe, E = wi(O, w, Z, F), Ye = {
@@ -1486,7 +1486,7 @@ nt = Ri([
1486
1486
  te(4, T(Ut)),
1487
1487
  te(5, T(Kr)),
1488
1488
  te(6, j),
1489
- te(7, Ar)
1489
+ te(7, Or)
1490
1490
  ], nt);
1491
1491
  var $i = Object.getOwnPropertyDescriptor, Li = (t, e, r, s) => {
1492
1492
  for (var n = s > 1 ? void 0 : s ? $i(e, r) : e, a = t.length - 1, i; a >= 0; a--)
@@ -1518,7 +1518,7 @@ var Mi = Object.defineProperty, xi = Object.getOwnPropertyDescriptor, Ui = (t, e
1518
1518
  let de = class extends ot {
1519
1519
  constructor(t = He, e, r) {
1520
1520
  super(), this._config = t, this._injector = e, this._configService = r;
1521
- const { menu: s, ...n } = Dt(
1521
+ const { menu: s, ...n } = Bt(
1522
1522
  {},
1523
1523
  He,
1524
1524
  this._config
@@ -1545,7 +1545,7 @@ Ge(de, "version", ue.version);
1545
1545
  de = ki([
1546
1546
  Ht(Wt),
1547
1547
  At(1, T(re)),
1548
- At(2, Bt)
1548
+ At(2, Dt)
1549
1549
  ], de);
1550
1550
  function _e({ ref: t, ...e }) {
1551
1551
  const { icon: r, id: s, className: n, extend: a, ...i } = e, o = `univerjs-icon univerjs-icon-${s} ${n || ""}`.trim(), l = pi(`_${Bi()}`);
@@ -1733,10 +1733,10 @@ function Yi(t) {
1733
1733
  const e = t.get(X);
1734
1734
  return {
1735
1735
  id: Oe.id,
1736
- type: ct.BUTTON_SELECTOR,
1736
+ type: ut.BUTTON_SELECTOR,
1737
1737
  icon: "FilterIcon",
1738
1738
  tooltip: "sheets-filter.toolbar.smart-toggle-filter-tooltip",
1739
- hidden$: ut(t, ie.UNIVER_SHEET),
1739
+ hidden$: ct(t, ie.UNIVER_SHEET),
1740
1740
  activated$: e.activeFilterModel$.pipe(ae((r) => !!r)),
1741
1741
  disabled$: Pr(
1742
1742
  t,
@@ -1754,9 +1754,9 @@ function Zi(t) {
1754
1754
  const e = t.get(X);
1755
1755
  return {
1756
1756
  id: at.id,
1757
- type: ct.BUTTON,
1757
+ type: ut.BUTTON,
1758
1758
  title: "sheets-filter.toolbar.clear-filter-criteria",
1759
- hidden$: ut(t, ie.UNIVER_SHEET),
1759
+ hidden$: ct(t, ie.UNIVER_SHEET),
1760
1760
  disabled$: e.activeFilterModel$.pipe(ht((r) => {
1761
1761
  var s;
1762
1762
  return (s = r == null ? void 0 : r.hasCriteria$.pipe(ae((n) => !n))) != null ? s : pe(!0);
@@ -1767,9 +1767,9 @@ function zi(t) {
1767
1767
  const e = t.get(X);
1768
1768
  return {
1769
1769
  id: lt.id,
1770
- type: ct.BUTTON,
1770
+ type: ut.BUTTON,
1771
1771
  title: "sheets-filter.toolbar.re-calc-filter-conditions",
1772
- hidden$: ut(t, ie.UNIVER_SHEET),
1772
+ hidden$: ct(t, ie.UNIVER_SHEET),
1773
1773
  disabled$: e.activeFilterModel$.pipe(ht((r) => {
1774
1774
  var s;
1775
1775
  return (s = r == null ? void 0 : r.hasCriteria$.pipe(ae((n) => !n))) != null ? s : pe(!0);
@@ -2364,7 +2364,7 @@ var as = Object.defineProperty, cs = Object.getOwnPropertyDescriptor, us = (t, e
2364
2364
  let me = class extends ot {
2365
2365
  constructor(t = He, e, r, s) {
2366
2366
  super(), this._config = t, this._injector = e, this._configService = r, this._rpcChannelService = s;
2367
- const { menu: n, ...a } = Dt(
2367
+ const { menu: n, ...a } = Bt(
2368
2368
  {},
2369
2369
  He,
2370
2370
  this._config
@@ -2400,7 +2400,7 @@ je(me, "version", ue.version);
2400
2400
  me = hs([
2401
2401
  Ht(Wt),
2402
2402
  et(1, T(re)),
2403
- et(2, Bt),
2403
+ et(2, Dt),
2404
2404
  et(3, pr(Zt))
2405
2405
  ], me);
2406
2406
  var ds = Object.getOwnPropertyDescriptor, ms = (t, e, r, s) => {
package/lib/umd/index.js CHANGED
@@ -1,4 +1,4 @@
1
- (function(g,c){typeof exports=="object"&&typeof module<"u"?c(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"),require("react/jsx-runtime")):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","react/jsx-runtime"],c):(g=typeof globalThis<"u"?globalThis:g||self,c(g.UniverSheetsFilterUi={},g.UniverCore,g.UniverSheetsFilter,g.UniverSheetsUi,g.UniverUi,g.UniverEngineRender,g.UniverSheets,g.rxjs,g.UniverRpc,g.UniverDesign,g.React,g.React))})(this,(function(g,c,u,$,C,K,y,S,fe,N,F,d){"use strict";var rr=Object.defineProperty;var ir=(g,c,u)=>c in g?rr(g,c,{enumerable:!0,configurable:!0,writable:!0,value:u}):g[c]=u;var _=(g,c,u)=>ir(g,typeof c!="symbol"?c+"":c,u);var se;var R=(r=>(r[r.FIRST=0]="FIRST",r[r.SECOND=1]="SECOND",r))(R||{}),E=(r=>(r.NONE="none",r.STARTS_WITH="startsWith",r.DOES_NOT_START_WITH="doesNotStartWith",r.ENDS_WITH="endsWith",r.DOES_NOT_END_WITH="doesNotEndWith",r.CONTAINS="contains",r.DOES_NOT_CONTAIN="doesNotContain",r.EQUALS="equals",r.NOT_EQUALS="notEquals",r.EMPTY="empty",r.NOT_EMPTY="notEmpty",r.BETWEEN="between",r.NOT_BETWEEN="notBetween",r.CUSTOM="custom",r))(E||{}),f;(r=>{r.NONE={label:"sheets-filter.conditions.none",operator:E.NONE,order:R.SECOND,numOfParameters:0,getDefaultFormParams:()=>{throw new Error("[FilterConditionItems.NONE]: should not have initial form params!")},testMappingParams:i=>i.operator1===E.NONE,mapToFilterColumn:()=>null,testMappingFilterColumn:i=>!i.customFilters&&!i.filters?{}:!1},r.EMPTY={label:"sheets-filter.conditions.empty",operator:E.EMPTY,order:R.SECOND,numOfParameters:0,getDefaultFormParams:()=>{throw new Error("[FilterConditionItems.EMPTY]: should not have initial form params!")},testMappingParams:({operator1:i})=>i===E.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:E.EMPTY}:!1}},r.NOT_EMPTY={label:"sheets-filter.conditions.not-empty",operator:E.NOT_EMPTY,order:R.SECOND,numOfParameters:0,getDefaultFormParams:()=>{throw new Error("[FilterConditionItems.NOT_EMPTY]: should not have initial form params!")},testMappingParams:({operator1:i})=>i===E.NOT_EMPTY,mapToFilterColumn:()=>({customFilters:{customFilters:[{val:"",operator:u.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===u.CustomFilterOperator.NOT_EQUALS?{operator1:E.NOT_EMPTY}:!1}},r.TEXT_CONTAINS={label:"sheets-filter.conditions.text-contains",operator:E.CONTAINS,order:R.FIRST,numOfParameters:1,getDefaultFormParams:()=>({operator1:E.CONTAINS,val1:""}),testMappingParams:i=>{const[s]=D(i);return s===E.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:E.CONTAINS,val1:a.slice(1,-1)}:!1}},r.DOES_NOT_CONTAIN={label:"sheets-filter.conditions.does-not-contain",operator:E.DOES_NOT_CONTAIN,order:R.FIRST,numOfParameters:1,getDefaultFormParams:()=>({operator1:E.DOES_NOT_CONTAIN,val1:""}),mapToFilterColumn:i=>({customFilters:{customFilters:[{val:`*${i.val1}*`,operator:u.CustomFilterOperator.NOT_EQUALS}]}}),testMappingParams:i=>{const[s]=D(i);return s===E.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===u.CustomFilterOperator.NOT_EQUALS&&a.startsWith("*")&&a.endsWith("*")?{operator1:E.DOES_NOT_CONTAIN,val1:a.slice(1,-1)}:!1}},r.STARTS_WITH={label:"sheets-filter.conditions.starts-with",operator:E.STARTS_WITH,order:R.FIRST,numOfParameters:1,getDefaultFormParams:()=>({operator1:E.STARTS_WITH,val1:""}),mapToFilterColumn:i=>({customFilters:{customFilters:[{val:`${i.val1}*`}]}}),testMappingParams:i=>{const[s]=D(i);return s===E.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:E.STARTS_WITH,val1:a.slice(0,-1)}:!1}},r.ENDS_WITH={label:"sheets-filter.conditions.ends-with",operator:E.ENDS_WITH,order:R.FIRST,numOfParameters:1,getDefaultFormParams:()=>({operator1:E.ENDS_WITH,val1:""}),mapToFilterColumn:i=>({customFilters:{customFilters:[{val:`*${i.val1}`}]}}),testMappingParams:i=>{const[s]=D(i);return s===E.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:E.ENDS_WITH,val1:a.slice(1)}:!1}},r.EQUALS={label:"sheets-filter.conditions.equals",operator:E.EQUALS,order:R.FIRST,numOfParameters:1,getDefaultFormParams:()=>({operator1:E.EQUALS,val1:""}),testMappingParams:i=>{const[s]=D(i);return s===E.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:E.EQUALS,val1:""}:((h=i.customFilters)==null?void 0:h.customFilters.length)===1&&!i.customFilters.customFilters[0].operator?{operator1:E.EQUALS,val1:i.customFilters.customFilters[0].val.toString()}:!1}},r.GREATER_THAN={label:"sheets-filter.conditions.greater-than",operator:u.CustomFilterOperator.GREATER_THAN,numOfParameters:1,order:R.FIRST,getDefaultFormParams:()=>({operator1:u.CustomFilterOperator.GREATER_THAN,val1:""}),mapToFilterColumn:i=>({customFilters:{customFilters:[{val:i.val1,operator:u.CustomFilterOperator.GREATER_THAN}]}}),testMappingParams:i=>{const[s]=D(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()}}},r.GREATER_THAN_OR_EQUAL={label:"sheets-filter.conditions.greater-than-or-equal",operator:u.CustomFilterOperator.GREATER_THAN_OR_EQUAL,numOfParameters:1,order:R.FIRST,getDefaultFormParams:()=>({operator1:u.CustomFilterOperator.GREATER_THAN_OR_EQUAL,val1:""}),testMappingParams:i=>{const[s]=D(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()}}},r.LESS_THAN={label:"sheets-filter.conditions.less-than",operator:u.CustomFilterOperator.LESS_THAN,numOfParameters:1,order:R.FIRST,getDefaultFormParams:()=>({operator1:u.CustomFilterOperator.LESS_THAN,val1:""}),testMappingParams:i=>{const[s]=D(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()}}},r.LESS_THAN_OR_EQUAL={label:"sheets-filter.conditions.less-than-or-equal",operator:u.CustomFilterOperator.LESS_THAN_OR_EQUAL,numOfParameters:1,order:R.FIRST,getDefaultFormParams:()=>({operator1:u.CustomFilterOperator.LESS_THAN_OR_EQUAL,val1:""}),testMappingParams:i=>{const[s]=D(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()}}},r.EQUAL={label:"sheets-filter.conditions.equal",operator:u.CustomFilterOperator.EQUAL,numOfParameters:1,order:R.FIRST,getDefaultFormParams:()=>({operator1:u.CustomFilterOperator.EQUAL,val1:""}),testMappingParams:i=>{const[s]=D(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()}}},r.NOT_EQUAL={label:"sheets-filter.conditions.not-equal",operator:u.CustomFilterOperator.NOT_EQUALS,numOfParameters:1,order:R.FIRST,getDefaultFormParams:()=>({operator1:u.CustomFilterOperator.NOT_EQUALS,val1:""}),testMappingParams:i=>{const[s]=D(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()}}},r.BETWEEN={label:"sheets-filter.conditions.between",operator:E.BETWEEN,order:R.SECOND,numOfParameters:2,getDefaultFormParams:()=>({and:!0,operator1:u.CustomFilterOperator.GREATER_THAN_OR_EQUAL,val1:"",operator2:u.CustomFilterOperator.LESS_THAN_OR_EQUAL,val2:""}),testMappingParams:i=>{const{and:s,operator1:a,operator2:h}=i;if(!s)return!1;const m=[a,h];return m.includes(u.CustomFilterOperator.GREATER_THAN_OR_EQUAL)&&m.includes(u.CustomFilterOperator.LESS_THAN_OR_EQUAL)},mapToFilterColumn:i=>{const{val1:s,val2:a,operator1:h}=i,m=h===u.CustomFilterOperator.GREATER_THAN_OR_EQUAL;return{customFilters:{and:c.BooleanNumber.TRUE,customFilters:[{val:m?s:a,operator:u.CustomFilterOperator.GREATER_THAN_OR_EQUAL},{val:m?a:s,operator:u.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===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}},r.NOT_BETWEEN={label:"sheets-filter.conditions.not-between",operator:E.NOT_BETWEEN,order:R.SECOND,numOfParameters:2,getDefaultFormParams:()=>({operator1:u.CustomFilterOperator.LESS_THAN,val1:"",operator2:u.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(u.CustomFilterOperator.GREATER_THAN)&&m.includes(u.CustomFilterOperator.LESS_THAN)},mapToFilterColumn:i=>{const{val1:s,val2:a,operator1:h}=i,m=h===u.CustomFilterOperator.GREATER_THAN;return{customFilters:{customFilters:[{val:m?s:a,operator:u.CustomFilterOperator.GREATER_THAN},{val:m?a:s,operator:u.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===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}},r.CUSTOM={label:"sheets-filter.conditions.custom",operator:E.CUSTOM,order:R.SECOND,numOfParameters:2,getDefaultFormParams:()=>({operator1:E.NONE,val1:"",operator2:E.NONE,val2:""}),testMappingParams:()=>!0,mapToFilterColumn:i=>{const{and:s,val1:a,val2:h,operator1:m,operator2:p}=i;function I(M,L){for(const U of r.ALL_CONDITIONS)if(U.operator===M)return U.mapToFilterColumn({val1:L,operator1:M})}const v=!m||m===r.NONE.operator,T=!p||p===r.NONE.operator;if(v&&T)return r.NONE.mapToFilterColumn({});if(v)return I(p,h);if(T)return I(m,a);const O=I(m,a),P=I(p,h),A={customFilters:[O.customFilters.customFilters[0],P.customFilters.customFilters[0]]};return s&&(A.and=c.BooleanNumber.TRUE),{customFilters:A}},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}},r.ALL_CONDITIONS=[r.NONE,r.EMPTY,r.NOT_EMPTY,r.TEXT_CONTAINS,r.DOES_NOT_CONTAIN,r.STARTS_WITH,r.ENDS_WITH,r.EQUALS,r.GREATER_THAN,r.GREATER_THAN_OR_EQUAL,r.LESS_THAN,r.LESS_THAN_OR_EQUAL,r.EQUAL,r.NOT_EQUAL,r.BETWEEN,r.NOT_BETWEEN,r.CUSTOM];function e(i){const s=r.ALL_CONDITIONS.find(a=>a.operator===i);if(!s)throw new Error(`[SheetsFilter]: no condition item found for operator: ${i}`);return s}r.getItemByOperator=e;function t(i,s){for(const a of r.ALL_CONDITIONS.filter(h=>h.numOfParameters===s))if(a.numOfParameters!==0&&a.testMappingParams(i))return a;for(const a of r.ALL_CONDITIONS)if(a.testMappingParams(i))return a;throw new Error("[SheetsFilter]: no condition item can be mapped from the filter map params!")}r.testMappingParams=t;function n(i){const s=r.ALL_CONDITIONS.find(a=>a.operator===i);return(s==null?void 0:s.numOfParameters)===0?{operator1:s.operator}:s.getDefaultFormParams()}r.getInitialFormParams=n;function o(i,s){return i.mapToFilterColumn(s)}r.mapToFilterColumn=o;function l(i){if(!i)return[r.NONE,{}];for(const s of r.ALL_CONDITIONS){const a=s.testMappingFilterColumn(i);if(a)return[s,a]}return[r.NONE,{}]}r.testMappingFilterColumn=l})(f||(f={}));function D(r){const{operator1:e,operator2:t,val1:n,val2:o}=r;if(e&&t)throw new Error("Both operator1 and operator2 are set!");if(!e&&!t)throw new Error("Neither operator1 and operator2 and both not set!");return e?[e,n]:[t,o]}function be(r){const e=[],t=[];let n=0,o=0;function l(i){i.leaf&&(i.checked?(e.push(i),n+=i.count):(t.push(i),o+=i.count)),i.children&&i.children.forEach(l)}return r.forEach(l),{checkedItems:e,uncheckedItems:t,checked:n,unchecked:o}}var ot=Object.getOwnPropertyDescriptor,st=(r,e,t,n)=>{for(var o=n>1?void 0:n?ot(e,t):e,l=r.length-1,i;l>=0;l--)(i=r[l])&&(o=i(o)||o);return o},ye=(r,e)=>(t,n)=>e(t,n,r);const Pe="sheets-filter.generate-filter-values.service",ve=c.createIdentifier(Pe);let Ae=class extends c.Disposable{constructor(r,e,t){super(),this._localeService=r,this._univerInstanceService=e,this._logService=t}async getFilterValues(r){var p;const{unitId:e,subUnitId:t,filteredOutRowsByOtherColumns:n,filterColumn:o,filters:l,blankChecked:i,iterateRange:s,alreadyChecked:a}=r,h=this._univerInstanceService.getUnit(e),m=(p=this._univerInstanceService.getUnit(e))==null?void 0:p.getSheetBySheetId(t);return!h||!m?[]:(this._logService.debug("[SheetsGenerateFilterValuesService]","getFilterValues for",{unitId:e,subUnitId:t}),He(l,this._localeService,s,m,new Set(n),o,new Set(a.map(String)),i,h.getStyles()))}};Ae=st([ye(0,c.Inject(c.LocaleService)),ye(1,c.IUniverInstanceService),ye(2,c.ILogService)],Ae);function He(r,e,t,n,o,l,i,s,a){var P,A,M,L,U,B,Y,q,ae,H;const h=new Map,m=new Map,p="yyyy-mm-dd",I="empty",v=!r&&((l==null?void 0:l.filterBy)===u.FilterBy.COLORS||(l==null?void 0:l.filterBy)===u.FilterBy.CONDITIONS)&&((P=l.filteredOutRows)==null?void 0:P.size);let T=0;for(const b of n.iterateByColumn(t,!1,!1)){const{row:ke,rowSpan:Fe=1}=b;let le=0;for(;le<Fe;){const tr=ke+le;if(o.has(tr)){le++;continue}const X=b!=null&&b.value?c.extractPureTextFromCell(b.value):"";if(!X){T+=1,le+=Fe;continue}const Ne=(A=b.value)!=null&&A.v&&!b.value.p?(U=(L=a.get((M=b.value)==null?void 0:M.s))==null?void 0:L.n)==null?void 0:U.pattern:"",it=Ne&&c.numfmt.getFormatInfo(Ne).isDate;let nt=!1;if(it){const{year:W,month:Z,day:w}=c.numfmt.getFormatDateInfo(Ne);nt=W||Z||w}if(Ne&&it&&nt){const W=(B=n.getCellRaw(b.row,b.col))==null?void 0:B.v;if(!W){le++;continue}const Z=c.numfmt.format(p,Number(W)),[w,V,pe]=Z.split("-").map(Number);let J=h.get(`${w}`);J||(J={title:`${w}`,key:`${w}`,children:[],count:0,leaf:!1,checked:!1},h.set(`${w}`,J),m.set(`${w}`,[`${w}`]));let j=(Y=J.children)==null?void 0:Y.find(De=>De.key===`${w}-${V}`);j||(j={title:e.t(`sheets-filter.date.${V}`),key:`${w}-${V}`,children:[],count:0,leaf:!1,checked:!1},(q=J.children)==null||q.push(j),m.set(`${w}-${V}`,[`${w}`,`${w}-${V}`]));const Be=(ae=j==null?void 0:j.children)==null?void 0:ae.find(De=>De.key===`${w}-${V}-${pe}`);Be?(Be.originValues.add(X),Be.count++,j.count++,J.count++):((H=j.children)==null||H.push({title:`${pe}`,key:`${w}-${V}-${pe}`,count:1,originValues:new Set([X]),leaf:!0,checked:v?!1:i.size?i.has(X):!s}),j.count++,J.count++,m.set(`${w}-${V}-${pe}`,[`${w}`,`${w}-${V}`,`${w}-${V}-${pe}`]))}else{const W=X;let Z=h.get(W);Z?Z.count++:(Z={title:X,leaf:!0,checked:v?!1:i.size?i.has(X):!s,key:W,count:1},h.set(W,Z),m.set(W,[W]))}le++}}const O=v?!1:r?s:!0;if(T>0){const b={title:e.t("sheets-filter.panel.empty"),count:T,leaf:!0,checked:O,key:I};h.set("empty",b),m.set("empty",[I])}return{filterTreeItems:at(Array.from(h.values())),filterTreeMapCache:m}}function at(r){return Array.from(r).sort((e,t)=>e.children&&!t.children?-1:!e.children&&t.children?1:lt(e.title,t.title)).map(e=>(e.children&&e.children.sort((t,n)=>{const o=Number.parseInt(t.key.split("-")[1],10),l=Number.parseInt(n.key.split("-")[1],10);return o-l}).forEach(t=>{t.children&&t.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 xe=r=>!Number.isNaN(Number(r))&&!Number.isNaN(Number.parseFloat(r));function lt(r,e){const t=xe(r),n=xe(e);return t&&n?Number.parseFloat(r)-Number.parseFloat(e):t&&!n?-1:!t&&n?1:r.localeCompare(e)}function we(r,e){for(const t of r){if(t.key===e)return t;if(t.children){const n=we(t.children,e);if(n)return n}}return null}function We(r){return r.leaf?r.checked:r.children?r.children.every(e=>We(e)):!0}function ce(r,e){r.leaf&&(e!==void 0?r.checked=e:r.checked=!r.checked),r.children&&r.children.forEach(t=>ce(t,e))}function Ve(r,e){const t=[];return r.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)t.push({...n});else if(n.children){const s=Ve(n.children,e);if(s.length>0){const a=s.reduce((h,m)=>h+m.count,0);t.push({...n,count:a,children:s})}}}),t}var ct=Object.getOwnPropertyDescriptor,_e=(r,e,t,n)=>{for(var o=n>1?void 0:n?ct(e,t):e,l=r.length-1,i;l>=0;l--)(i=r[l])&&(o=i(o)||o);return o},ue=(r,e)=>(t,n)=>e(t,n,r);c.createIdentifier("sheets-filter-ui.sheets-filter-panel.service");let Q=class extends c.Disposable{constructor(e,t){super();_(this,"_filterBy$",new S.BehaviorSubject(u.FilterBy.VALUES));_(this,"filterBy$",this._filterBy$.asObservable());_(this,"_filterByModel$",new S.ReplaySubject(1));_(this,"filterByModel$",this._filterByModel$.asObservable());_(this,"_filterByModel",null);_(this,"_hasCriteria$",new S.BehaviorSubject(!1));_(this,"hasCriteria$",this._hasCriteria$.asObservable());_(this,"_filterModel",null);_(this,"_col$",new S.BehaviorSubject(-1));_(this,"col$",this._col$.asObservable());_(this,"_filterHeaderListener",null);this._injector=e,this._refRangeService=t}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,t){this.terminate(),this._filterModel=e,this._col$.next(t);const n=e.getFilterColumn(t);if(n){const o=n.getColumnData();if(o.customFilters){this._hasCriteria$.next(!0),this._setupByConditions(e,t);return}if(o.colorFilters){this._hasCriteria$.next(!0),this._setupByColors(e,t);return}if(o.filters){this._hasCriteria$.next(!0),this._setupByValues(e,t);return}this._hasCriteria$.next(!1),this._setupByValues(e,t);return}this._hasCriteria$.next(!1),this._setupByValues(e,t)}changeFilterBy(e){if(!this._filterModel||this.col===-1)return!1;switch(e){case u.FilterBy.VALUES:this._setupByValues(this._filterModel,this.col);break;case u.FilterBy.COLORS:this._setupByColors(this._filterModel,this.col);break;case u.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,t){this._disposeFilterHeaderChangeListener();const n=e.unitId,o=e.subUnitId,l=e.getRange(),i={startColumn:t,startRow:l.startRow,endRow:l.startRow,endColumn:t};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,t){this._disposePreviousModel();const n=e.getRange();if(n.startRow===n.endRow)return!1;const o=await Ce.fromFilterColumn(this._injector,e,t);return this.filterByModel=o,this._filterBy$.next(u.FilterBy.VALUES),this._listenToFilterHeaderChange(e,t),!0}async _setupByColors(e,t){this._disposePreviousModel();const n=e.getRange();if(n.startRow===n.endRow)return!1;const o=await Se.fromFilterColumn(this._injector,e,t);return this.filterByModel=o,this._filterBy$.next(u.FilterBy.COLORS),this._listenToFilterHeaderChange(e,t),!0}_setupByConditions(e,t){this._disposePreviousModel();const n=e.getRange();if(n.startRow===n.endRow)return!1;const o=ge.fromFilterColumn(this._injector,e,t,e.getFilterColumn(t));return this.filterByModel=o,this._filterBy$.next(u.FilterBy.CONDITIONS),this._listenToFilterHeaderChange(e,t),!0}_disposePreviousModel(){var e;(e=this._filterByModel)==null||e.dispose(),this.filterByModel=null}};Q=_e([ue(0,c.Inject(c.Injector)),ue(1,c.Inject(y.RefRangeService))],Q);let ge=class extends c.Disposable{constructor(e,t,n,o,l){super();_(this,"canApply$",S.of(!0));_(this,"_conditionItem$");_(this,"conditionItem$");_(this,"_filterConditionFormParams$");_(this,"filterConditionFormParams$");this._filterModel=e,this.col=t,this._commandService=l,this._conditionItem$=new S.BehaviorSubject(n),this.conditionItem$=this._conditionItem$.asObservable(),this._filterConditionFormParams$=new S.BehaviorSubject(o),this.filterConditionFormParams$=this._filterConditionFormParams$.asObservable()}static fromFilterColumn(e,t,n,o){const[l,i]=f.testMappingFilterColumn(o==null?void 0:o.getColumnData());return e.createInstance(ge,t,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=f.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 t=f.ALL_CONDITIONS.find(n=>n.operator===e);if(!t)throw new Error(`[ByConditionsModel]: condition item not found for operator: ${e}!`);this._conditionItem$.next(t),this._filterConditionFormParams$.next(f.getInitialFormParams(e))}onConditionFormChange(e){const t={...this.filterConditionFormParams,...e};if(t.and!==!0&&delete t.and,typeof e.and<"u"||typeof e.operator1<"u"||typeof e.operator2<"u"){const n=f.testMappingParams(t,this.conditionItem.numOfParameters);this._conditionItem$.next(n)}this._filterConditionFormParams$.next(t)}};ge=_e([ue(4,c.ICommandService)],ge);let Ce=class extends c.Disposable{constructor(e,t,n,o,l){super();_(this,"_rawFilterItems$");_(this,"rawFilterItems$");_(this,"filterItems$");_(this,"_filterItems",[]);_(this,"_treeMapCache");_(this,"canApply$");_(this,"_manuallyUpdateFilterItems$");_(this,"_searchString$");_(this,"searchString$");this._filterModel=e,this.col=t,this._commandService=l,this._treeMapCache=o,this._searchString$=new S.BehaviorSubject(""),this.searchString$=this._searchString$.asObservable(),this._rawFilterItems$=new S.BehaviorSubject(n),this.rawFilterItems$=this._rawFilterItems$.asObservable(),this._manuallyUpdateFilterItems$=new S.Subject,this.filterItems$=S.merge(S.combineLatest([this._searchString$.pipe(S.throttleTime(500,void 0,{leading:!0,trailing:!0}),S.startWith(void 0)),this._rawFilterItems$]).pipe(S.map(([i,s])=>{if(!i)return s;const h=i.toLowerCase().split(/\s+/).filter(m=>!!m);return Ve(s,h)})),this._manuallyUpdateFilterItems$).pipe(S.shareReplay(1)),this.canApply$=this.filterItems$.pipe(S.map(i=>be(i).checked>0)),this.disposeWithMe(this.filterItems$.subscribe(i=>this._filterItems=i))}static async fromFilterColumn(e,t,n){const o=e.get(c.IUniverInstanceService),l=e.get(c.LocaleService),i=e.get(ve,c.Quantity.OPTIONAL),{unitId:s,subUnitId:a}=t,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=t.getRange(),I=n,v=t.getFilterColumn(n),T=v==null?void 0:v.getColumnData().filters,O=new Set(T==null?void 0:T.filters),P=!!(T&&T.blank),A=t.getFilteredOutRowsExceptCol(n),M={...p,startRow:p.startRow+1,startColumn:I,endColumn:I};let L,U;if(i){const B=await i.getFilterValues({unitId:s,subUnitId:a,filteredOutRowsByOtherColumns:Array.from(A),filterColumn:v,filters:!!T,blankChecked:P,iterateRange:M,alreadyChecked:Array.from(O)});L=B.filterTreeItems,U=B.filterTreeMapCache}else{const B=He(!!T,l,M,m,A,v,O,P,h.getStyles());L=B.filterTreeItems,U=B.filterTreeMapCache}return e.createInstance(Ce,t,n,L,U)}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 t=c.Tools.deepClone(this._filterItems);t.forEach(n=>ce(n,e)),this._manuallyUpdateFilterItems(t)}onFilterCheckToggled(e){const t=c.Tools.deepClone(this._filterItems),n=we(t,e.key);if(!n)return;const o=We(n);ce(n,!o),this._manuallyUpdateFilterItems(t)}onFilterOnly(e){const t=c.Tools.deepClone(this._filterItems);t.forEach(n=>ce(n,!1)),e.forEach(n=>{const o=we(t,n);o&&ce(o,!0)}),this._manuallyUpdateFilterItems(t)}_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=be(this._filterItems),{checked:t,checkedItems:n}=e,o=this.rawFilterItems;let l=0;for(const h of o)l+=h.count;const i=t===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 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(u.SetSheetsFilterCriteriaCommand.id,{unitId:this._filterModel.unitId,subUnitId:this._filterModel.subUnitId,col:this.col,criteria:a})}};Ce=_e([ue(4,c.ICommandService)],Ce);let Se=class extends c.Disposable{constructor(e,t,n,o,l){super();_(this,"canApply$",S.of(!0));_(this,"_cellFillColors$");_(this,"cellFillColors$");_(this,"_cellTextColors$");_(this,"cellTextColors$");this._filterModel=e,this.col=t,this._commandService=l,this._cellFillColors$=new S.BehaviorSubject(Array.from(n.values())),this.cellFillColors$=this._cellFillColors$.asObservable(),this._cellTextColors$=new S.BehaviorSubject(Array.from(o.values())),this.cellTextColors$=this._cellTextColors$.asObservable()}static async fromFilterColumn(e,t,n){var M,L,U;const o=e.get(c.IUniverInstanceService),{unitId:l,subUnitId:i}=t,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=t.getRange(),m=n,p=(M=t.getFilterColumn(n))==null?void 0:M.getColumnData().colorFilters,I=t.getFilteredOutRowsExceptCol(n),v={...h,startRow:h.startRow+1,startColumn:m,endColumn:m},T=new Map,O=new Set((L=p==null?void 0:p.cellFillColors)!=null?L:[]),P=new Map,A=new Set((U=p==null?void 0:p.cellTextColors)!=null?U:[]);for(const B of a.iterateByColumn(v,!1,!0)){const{row:Y,col:q,value:ae}=B;if(I.has(Y))continue;const H=a.getComposedCellStyleByCellData(Y,q,ae);if(H.bg&&H.bg.rgb){const b=new c.ColorKit(H.bg.rgb).toRgbString();T.has(b)||T.set(b,{color:b,checked:O.has(b)})}else T.set("default-fill-color",{color:null,checked:O.has(null)});if(H.cl&&H.cl.rgb){const b=new c.ColorKit(H.cl.rgb).toRgbString();P.has(b)||P.set(b,{color:b,checked:A.has(b)})}else P.set("default-font-color",{color:K.COLOR_BLACK_RGB,checked:A.has(K.COLOR_BLACK_RGB)})}return e.createInstance(Se,t,n,T,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(u.SetSheetsFilterCriteriaCommand.id,{unitId:this._filterModel.unitId,subUnitId:this._filterModel.subUnitId,col:this.col,criteria:null})}onFilterCheckToggled(e,t=!0){const n=t?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(!t),t?this._cellFillColors$.next([...o]):this._cellTextColors$.next([...o]))}_resetColorsCheckedStatus(e=!0){const t=e?this.cellFillColors:this.cellTextColors,n=[];for(let o=0;o<t.length;o++)n.push({color:t[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),t=this.cellTextColors.filter(o=>o.checked).map(o=>o.color);if(e.length===0&&t.length===0)return this._commandService.executeCommand(u.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}:t.length>0&&(n.colorFilters={cellTextColors:t}),this._commandService.executeCommand(u.SetSheetsFilterCriteriaCommand.id,{unitId:this._filterModel.unitId,subUnitId:this._filterModel.subUnitId,col:this.col,criteria:n})}};Se=_e([ue(4,c.ICommandService)],Se);const ee="FILTER_PANEL_OPENED",he={id:"sheet.operation.open-filter-panel",type:c.CommandType.OPERATION,handler:(r,e)=>{const t=r.get(c.IContextService),n=r.get(u.SheetsFilterService),o=r.get(Q),l=r.get(c.ICommandService),i=r.has($.IEditorBridgeService)?r.get($.IEditorBridgeService):null;i!=null&&i.isVisible().visible&&l.syncExecuteCommand($.SetCellEditVisibleOperation.id,{visible:!1});const{unitId:s,subUnitId:a,col:h}=e,m=n.getFilterModel(s,a);return m?(o.setupCol(m,h),t.getContextValue(ee)||t.setContextValue(ee,!0),!0):!1}},te={id:"sheet.operation.close-filter-panel",type:c.CommandType.OPERATION,handler:r=>{const e=r.get(c.IContextService),t=r.get(Q),n=r.get(C.ILayoutService,c.Quantity.OPTIONAL);return e.getContextValue(ee)?(e.setContextValue(ee,!1),n==null||n.focus(),t.terminate()):!1}},Re={id:"sheet.operation.apply-filter",type:c.CommandType.OPERATION,handler:(r,e)=>{const{filterBy:t}=e;return r.get(Q).changeFilterBy(t)}},re={name:"@univerjs/sheets-filter-ui",version:"0.16.1-insiders.20260311-074e8ca"},je="sheets-filter-ui.config",Te={};var ut=Object.getOwnPropertyDescriptor,ht=(r,e,t,n)=>{for(var o=n>1?void 0:n?ut(e,t):e,l=r.length-1,i;l>=0;l--)(i=r[l])&&(o=i(o)||o);return o},ie=(r,e)=>(t,n)=>e(t,n,r);let ne=class extends c.Disposable{constructor(r,e,t,n,o,l){super(),this._sheetsFilterService=r,this._localeService=e,this._commandService=t,this._sheetPermissionCheckPermission=n,this._injector=o,this._sheetsSelectionService=l,this._commandExecutedListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.beforeCommandExecuted(r=>{var e,t,n;if(r.id===u.SmartToggleSheetsFilterCommand.id){const o=this._injector.get(c.IUniverInstanceService),l=y.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:[y.RangeProtectionPermissionViewPoint],worksheetTypes:[y.WorksheetFilterPermission,y.WorksheetViewPermission]},[h],i,s);else{const p=(t=this._sheetsSelectionService.getCurrentLastSelection())==null?void 0:t.range;if(p){let I={...p};I=p.startColumn===p.endColumn&&p.startRow===p.endRow?y.expandToContinuousRange(I,{left:!0,right:!0,up:!0,down:!0},a):I,m=this._sheetPermissionCheckPermission.permissionCheckWithRanges({rangeTypes:[y.RangeProtectionPermissionViewPoint],worksheetTypes:[y.WorksheetViewPermission,y.WorksheetFilterPermission]},[I],i,s)}else m=this._sheetPermissionCheckPermission.permissionCheckWithoutRange({rangeTypes:[y.RangeProtectionPermissionViewPoint],worksheetTypes:[y.WorksheetViewPermission,y.WorksheetFilterPermission]})}m||this._sheetPermissionCheckPermission.blockExecuteWithoutPermission(this._localeService.t("permission.dialog.filterErr"))}if(r.id===he.id){const o=r.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:[y.RangeProtectionPermissionViewPoint],worksheetTypes:[y.WorksheetFilterPermission,y.WorksheetViewPermission]},[a],l,i)||this._sheetPermissionCheckPermission.blockExecuteWithoutPermission(this._localeService.t("permission.dialog.filterErr")))}}))}};ne=ht([ie(0,c.Inject(u.SheetsFilterService)),ie(1,c.Inject(c.LocaleService)),ie(2,c.ICommandService),ie(3,c.Inject(y.SheetPermissionCheckController)),ie(4,c.Inject(c.Injector)),ie(5,c.Inject(y.SheetsSelectionsService))],ne);const G=16,dt=new Path2D("M3.30363 3C2.79117 3 2.51457 3.60097 2.84788 3.99024L6.8 8.60593V12.5662C6.8 12.7184 6.8864 12.8575 7.02289 12.9249L8.76717 13.7863C8.96655 13.8847 9.2 13.7396 9.2 13.5173V8.60593L13.1521 3.99024C13.4854 3.60097 13.2088 3 12.6964 3H3.30363Z");class Qe{static drawNoCriteria(e,t,n,o){e.save(),K.Rect.drawWith(e,{radius:2,width:G,height:G,fill:o}),e.lineCap="square",e.strokeStyle=n,e.scale(t/G,t/G),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,t,n,o){e.save(),K.Rect.drawWith(e,{radius:2,width:G,height:G,fill:o}),e.scale(t/G,t/G),e.fillStyle=n,e.fill(dt),e.restore()}}var mt=Object.getOwnPropertyDescriptor,pt=(r,e,t,n)=>{for(var o=n>1?void 0:n?mt(e,t):e,l=r.length-1,i;l>=0;l--)(i=r[l])&&(o=i(o)||o);return o},Le=(r,e)=>(t,n)=>e(t,n,r);const x=16,de=1;let $e=class extends K.Shape{constructor(e,t,n,o,l){super(e,t);_(this,"_cellWidth",0);_(this,"_cellHeight",0);_(this,"_filterParams");_(this,"_hovered",!1);this._contextService=n,this._commandService=o,this._themeService=l,this.setShapeProps(t),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 t=this._cellHeight,n=this._cellWidth,o=x-n,l=x-t;e.save();const i=new Path2D;i.rect(o,l,n,t),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?Qe.drawHasCriteria(e,x,a,h):Qe.drawNoCriteria(e,x,a,h),e.restore()}onPointerDown(e){if(e.button===2)return;const{col:t,unitId:n,subUnitId:o}=this._filterParams;this._contextService.getContextValue(ee)||!this._commandService.hasCommand(he.id)||setTimeout(()=>{this._commandService.executeCommand(he.id,{unitId:n,subUnitId:o,col:t})},200)}onPointerEnter(){this._hovered=!0,this.makeDirty(!0)}onPointerLeave(){this._hovered=!1,this.makeDirty(!0)}};$e=pt([Le(2,c.IContextService),Le(3,c.ICommandService),Le(4,c.Inject(c.ThemeService))],$e);var ft=Object.getOwnPropertyDescriptor,vt=(r,e,t,n)=>{for(var o=n>1?void 0:n?ft(e,t):e,l=r.length-1,i;l>=0;l--)(i=r[l])&&(o=i(o)||o);return o},z=(r,e)=>(t,n)=>e(t,n,r);const _t=1e3,gt=5e3;function Ct(r,e,t,n){switch(n){case c.VerticalAlign.TOP:return r+de;case c.VerticalAlign.MIDDLE:return r+Math.max(0,(t-x)/2);case c.VerticalAlign.BOTTOM:default:return e-x-de}}let Me=class extends c.RxDisposable{constructor(e,t,n,o,l,i,s,a){super();_(this,"_filterRangeShape",null);_(this,"_buttonRenderDisposable",null);_(this,"_filterButtonShapes",[]);this._context=e,this._injector=t,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(S.switchMap(e=>{var s,a;if(!e)return S.of(null);const{unit:t,unitId:n}=this._context,o=((s=t.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(S.filter(([h])=>{var m;return h.type===c.CommandType.MUTATION&&((m=h.params)==null?void 0:m.unitId)===t.getUnitId()&&(u.FILTER_MUTATIONS.has(h.id)||h.id===y.SetRangeValuesMutation.id)}),S.throttleTime(20,void 0,{leading:!1,trailing:!0}),S.map(i),S.startWith(i()))}),S.takeUntil(this.dispose$)).subscribe(e=>{this._disposeRendering(),!(!e||!e.range)&&(this._renderRange(e.range,e.skeleton),this._renderButtons(e))})}_renderRange(e,t){const{scene:n}=this._context,{rowHeaderWidth:o,columnHeaderHeight:l}=t,i=this._filterRangeShape=new $.SelectionControl(n,_t,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,t);i.updateRangeBySelectionWithCoord(a),i.setEvent(!1),n.makeDirty(!0)}_renderButtons(e){const{range:t,filterModel:n,unitId:o,skeleton:l,worksheetId:i}=e,{unit:s,scene:a}=this._context,h=s.getSheetBySheetId(i);if(!h)return;this._interceptCellContent(o,i,e.range);const{startColumn:m,endColumn:p,startRow:I}=t;for(let v=m;v<=p;v++){const T=`sheets-filter-button-${v}`,O=$.getCoordByCell(I,v,a,l),P=h.getComposedCellStyle(I,v),A=(P==null?void 0:P.vt)||c.VerticalAlign.BOTTOM,{startX:M,startY:L,endX:U,endY:B}=O,Y=U-M,q=B-L;if(q<=de||Y<=de)continue;const ae=!!n.getFilterColumn(v),H=U-x-de,b=Ct(L,B,q,A),ke={left:H,top:b,height:x,width:x,zIndex:gt,cellHeight:q,cellWidth:Y,filterParams:{unitId:o,subUnitId:i,col:v,hasCriteria:ae}},Fe=this._injector.createInstance($e,T,ke);this._filterButtonShapes.push(Fe)}a.addObjects(this._filterButtonShapes),a.makeDirty()}_interceptCellContent(e,t,n){const{startRow:o,startColumn:l,endColumn:i}=n;this._buttonRenderDisposable=this._sheetInterceptorService.intercept(y.INTERCEPTOR_POINT.CELL_CONTENT,{effect:c.InterceptorEffectEnum.Style,handler:(s,a,h)=>{const{row:m,col:p,unitId:I,subUnitId:v}=a;return I!==e||v!==t||m!==o||p<l||p>i||((!s||s===a.rawData)&&(s={...a.rawData}),s.fontRenderExtension={...s==null?void 0:s.fontRenderExtension,rightOffset:x}),h(s)},priority:10})}_disposeRendering(){var e,t;(e=this._filterRangeShape)==null||e.dispose(),this._filterButtonShapes.forEach(n=>n.dispose()),(t=this._buttonRenderDisposable)==null||t.dispose(),this._filterRangeShape=null,this._buttonRenderDisposable=null,this._filterButtonShapes=[]}};Me=vt([z(1,c.Inject(c.Injector)),z(2,c.Inject($.SheetSkeletonManagerService)),z(3,c.Inject(u.SheetsFilterService)),z(4,c.Inject(c.ThemeService)),z(5,c.Inject(y.SheetInterceptorService)),z(6,c.ICommandService),z(7,$.ISheetSelectionRenderService)],Me);var St=Object.getOwnPropertyDescriptor,Tt=(r,e,t,n)=>{for(var o=n>1?void 0:n?St(e,t):e,l=r.length-1,i;l>=0;l--)(i=r[l])&&(o=i(o)||o);return o},Ge=(r,e)=>(t,n)=>e(t,n,r);let me=class extends c.RxDisposable{constructor(r,e){super(),this._renderManagerService=r,this._sheetsRenderService=e,[u.SetSheetsFilterRangeMutation,u.SetSheetsFilterCriteriaMutation,u.RemoveSheetsFilterMutation,u.ReCalcSheetsFilterMutation].forEach(t=>this.disposeWithMe(this._sheetsRenderService.registerSkeletonChangingMutations(t.id))),this.disposeWithMe(this._renderManagerService.registerRenderModule(c.UniverInstanceType.UNIVER_SHEET,[Me]))}};me=Tt([Ge(0,K.IRenderManagerService),Ge(1,c.Inject($.SheetsRenderService))],me);var Et=Object.defineProperty,It=Object.getOwnPropertyDescriptor,Ot=(r,e,t)=>e in r?Et(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Ft=(r,e,t,n)=>{for(var o=n>1?void 0:n?It(e,t):e,l=r.length-1,i;l>=0;l--)(i=r[l])&&(o=i(o)||o);return o},Ye=(r,e)=>(t,n)=>e(t,n,r),Ee=(r,e,t)=>Ot(r,typeof e!="symbol"?e+"":e,t);g.UniverSheetsFilterMobileUIPlugin=class extends c.Plugin{constructor(e=Te,t,n){super(),this._config=e,this._injector=t,this._configService=n;const{menu:o,...l}=c.merge({},Te,this._config);o&&this._configService.setConfig("menu",o,{merge:!0}),this._configService.setConfig(je,l)}onStarting(){[[ne],[me]].forEach(e=>this._injector.add(e))}onReady(){this._injector.get(ne)}onRendered(){this._injector.get(me)}},Ee(g.UniverSheetsFilterMobileUIPlugin,"type",c.UniverInstanceType.UNIVER_SHEET),Ee(g.UniverSheetsFilterMobileUIPlugin,"pluginName","SHEET_FILTER_UI_PLUGIN"),Ee(g.UniverSheetsFilterMobileUIPlugin,"packageName",re.name),Ee(g.UniverSheetsFilterMobileUIPlugin,"version",re.version),g.UniverSheetsFilterMobileUIPlugin=Ft([c.DependentOn(u.UniverSheetsFilterPlugin),Ye(1,c.Inject(c.Injector)),Ye(2,c.IConfigService)],g.UniverSheetsFilterMobileUIPlugin);function oe({ref:r,...e}){const{icon:t,id:n,className:o,extend:l,...i}=e,s=`univerjs-icon univerjs-icon-${n} ${o||""}`.trim(),a=F.useRef(`_${yt()}`);return qe(t,`${n}`,{defIds:t.defIds,idSuffix:a.current},{ref:r,className:s,...i},l)}function qe(r,e,t,n,o){return F.createElement(r.tag,{key:e,...Nt(r,t,o),...n},(bt(r,t).children||[]).map((l,i)=>qe(l,`${e}-${r.tag}-${i}`,t,void 0,o)))}function Nt(r,e,t){const n={...r.attrs};t!=null&&t.colorChannel1&&n.fill==="colorChannel1"&&(n.fill=t.colorChannel1),r.tag==="mask"&&n.id&&(n.id=n.id+e.idSuffix),Object.entries(n).forEach(([l,i])=>{l==="mask"&&typeof i=="string"&&(n[l]=i.replace(/url\(#(.*)\)/,`url(#$1${e.idSuffix})`))});const{defIds:o}=e;return!o||o.length===0||(r.tag==="use"&&n["xlink:href"]&&(n["xlink:href"]=n["xlink:href"]+e.idSuffix),Object.entries(n).forEach(([l,i])=>{typeof i=="string"&&(n[l]=i.replace(/url\(#(.*)\)/,`url(#$1${e.idSuffix})`))})),n}function bt(r,e){var n;const{defIds:t}=e;return!t||t.length===0?r:r.tag==="defs"&&((n=r.children)!=null&&n.length)?{...r,children:r.children.map(o=>typeof o.attrs.id=="string"&&t&&t.includes(o.attrs.id)?{...o,attrs:{...o.attrs,id:o.attrs.id+e.idSuffix}}:o)}:r}function yt(){return Math.random().toString(36).substring(2,8)}oe.displayName="UniverIcon";const 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:"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"}}]},Ze=F.forwardRef(function(e,t){return F.createElement(oe,Object.assign({},e,{id:"a-icon",ref:t,icon:Pt}))});Ze.displayName="AIcon";const At={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"}}]},Ke=F.forwardRef(function(e,t){return F.createElement(oe,Object.assign({},e,{id:"ban-icon",ref:t,icon:At}))});Ke.displayName="BanIcon";const wt={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"}}]},ze=F.forwardRef(function(e,t){return F.createElement(oe,Object.assign({},e,{id:"filter-icon",ref:t,icon:wt}))});ze.displayName="FilterIcon";const Rt={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.00016 1.33203C6.68162 1.33203 5.39269 1.72302 4.29636 2.45557C3.20004 3.18811 2.34555 4.2293 1.84097 5.44747C1.33638 6.66565 1.20436 8.00609 1.4616 9.2993C1.71883 10.5925 2.35377 11.7804 3.28612 12.7127C4.21847 13.6451 5.40636 14.28 6.69956 14.5373C7.99277 14.7945 9.33321 14.6625 10.5514 14.1579C11.7696 13.6533 12.8108 12.7988 13.5433 11.7025C14.2758 10.6062 14.6668 9.31724 14.6668 7.9987C14.6649 6.23118 13.9619 4.53662 12.7121 3.2868C11.4622 2.03697 9.76768 1.33397 8.00016 1.33203ZM7.66683 3.9987C7.86461 3.9987 8.05795 4.05735 8.2224 4.16723C8.38685 4.27711 8.51502 4.43329 8.59071 4.61601C8.6664 4.79874 8.6862 4.99981 8.64762 5.19379C8.60903 5.38777 8.51379 5.56595 8.37394 5.7058C8.23409 5.84566 8.0559 5.9409 7.86192 5.97948C7.66794 6.01807 7.46687 5.99826 7.28415 5.92258C7.10142 5.84689 6.94524 5.71872 6.83536 5.55427C6.72548 5.38982 6.66683 5.19648 6.66683 4.9987C6.66683 4.73348 6.77219 4.47913 6.95972 4.29159C7.14726 4.10405 7.40162 3.9987 7.66683 3.9987ZM9.3335 11.332H6.66683C6.49002 11.332 6.32045 11.2618 6.19543 11.1368C6.0704 11.0117 6.00016 10.8422 6.00016 10.6654C6.00016 10.4886 6.0704 10.319 6.19543 10.194C6.32045 10.0689 6.49002 9.9987 6.66683 9.9987H7.3335V7.9987H6.66683C6.49002 7.9987 6.32045 7.92846 6.19543 7.80343C6.0704 7.67841 6.00016 7.50884 6.00016 7.33203C6.00016 7.15522 6.0704 6.98565 6.19543 6.86063C6.32045 6.7356 6.49002 6.66536 6.66683 6.66536H8.00016C8.17698 6.66536 8.34655 6.7356 8.47157 6.86063C8.59659 6.98565 8.66683 7.15522 8.66683 7.33203V9.9987H9.3335C9.51031 9.9987 9.67988 10.0689 9.8049 10.194C9.92993 10.319 10.0002 10.4886 10.0002 10.6654C10.0002 10.8422 9.92993 11.0117 9.8049 11.1368C9.67988 11.2618 9.51031 11.332 9.3335 11.332Z"}}]},Xe=F.forwardRef(function(e,t){return F.createElement(oe,Object.assign({},e,{id:"info-icon",ref:t,icon:Rt}))});Xe.displayName="InfoIcon";const Lt={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"}}]},Je=F.forwardRef(function(e,t){return F.createElement(oe,Object.assign({},e,{id:"success-icon",ref:t,icon:Lt}))});Je.displayName="SuccessIcon";function $t(r){const e=r.get(u.SheetsFilterService);return{id:u.SmartToggleSheetsFilterCommand.id,type:C.MenuItemType.BUTTON_SELECTOR,icon:"FilterIcon",tooltip:"sheets-filter.toolbar.smart-toggle-filter-tooltip",hidden$:C.getMenuHiddenObservable(r,c.UniverInstanceType.UNIVER_SHEET),activated$:e.activeFilterModel$.pipe(S.map(t=>!!t)),disabled$:$.getObservableWithExclusiveRange$(r,$.getCurrentRangeDisable$(r,{worksheetTypes:[y.WorksheetFilterPermission,y.WorksheetViewPermission],rangeTypes:[y.RangeProtectionPermissionViewPoint]}))}}function Mt(r){const e=r.get(u.SheetsFilterService);return{id:u.ClearSheetsFilterCriteriaCommand.id,type:C.MenuItemType.BUTTON,title:"sheets-filter.toolbar.clear-filter-criteria",hidden$:C.getMenuHiddenObservable(r,c.UniverInstanceType.UNIVER_SHEET),disabled$:e.activeFilterModel$.pipe(S.switchMap(t=>{var n;return(n=t==null?void 0:t.hasCriteria$.pipe(S.map(o=>!o)))!=null?n:S.of(!0)}))}}function Ut(r){const e=r.get(u.SheetsFilterService);return{id:u.ReCalcSheetsFilterCommand.id,type:C.MenuItemType.BUTTON,title:"sheets-filter.toolbar.re-calc-filter-conditions",hidden$:C.getMenuHiddenObservable(r,c.UniverInstanceType.UNIVER_SHEET),disabled$:e.activeFilterModel$.pipe(S.switchMap(t=>{var n;return(n=t==null?void 0:t.hasCriteria$.pipe(S.map(o=>!o)))!=null?n:S.of(!0)}))}}const kt={[C.RibbonDataGroup.ORGANIZATION]:{[u.SmartToggleSheetsFilterCommand.id]:{order:2,menuItemFactory:$t,[u.ClearSheetsFilterCriteriaCommand.id]:{order:0,menuItemFactory:Mt},[u.ReCalcSheetsFilterCommand.id]:{order:1,menuItemFactory:Ut}}}};function Bt(r){const{model:e}=r,t=C.useDependency(c.LocaleService),n=C.useObservable(e.cellFillColors$,[],!0),o=C.useObservable(e.cellTextColors$,[],!0),l=F.useCallback(s=>{e.onFilterCheckToggled(s)},[e]),i=F.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:N.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",N.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:t.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-size-6",onClick:()=>l(s),children:[s.color?d.jsx("button",{type:"button",className:N.clsx("univer-box-border univer-size-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(Ke,{className:"univer-size-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(et,{})]},`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:t.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-size-6",onClick:()=>i(s),children:[d.jsx("div",{className:"univer-box-border univer-flex univer-size-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(Ze,{style:{color:s.color}})}),s.checked&&d.jsx(et,{})]},`sheets-filter-cell-text-color-${a}`))})]}),n.length<=1&&o.length<=1&&d.jsx("div",{className:"univer-flex univer-size-full univer-items-center univer-justify-center univer-text-sm univer-text-gray-900 dark:!univer-text-gray-200",children:t.t("sheets-filter.panel.filter-by-color-none")})]})})}function et(){return d.jsx("div",{className:"univer-absolute -univer-bottom-0.5 -univer-right-0.5 univer-flex univer-size-3 univer-cursor-pointer univer-items-center univer-justify-center univer-rounded-full univer-bg-white",children:d.jsx(Je,{className:"univer-size-full univer-font-bold univer-text-[#418F1F]"})})}function Dt(r){var v,T;const{model:e}=r,t=C.useDependency(c.LocaleService),n=C.useObservable(e.conditionItem$,void 0),o=C.useObservable(e.filterConditionFormParams$,void 0),l=o!=null&&o.and?"AND":"OR",i=F.useCallback(O=>{e.onConditionFormChange({and:O==="AND"})},[e]),s=Ht(t),a=F.useCallback(O=>{e.onPrimaryConditionChange(O)},[e]),h=xt(t),m=F.useCallback(O=>{e.onConditionFormChange(O)},[e]),p=t.t("sheets-filter.panel.input-values-placeholder");function I(O,P,A){const M=f.getItemByOperator(O).numOfParameters===1;return d.jsxs(d.Fragment,{children:[A==="operator2"&&d.jsxs(N.RadioGroup,{value:l,onChange:i,children:[d.jsx(N.Radio,{value:"AND",children:t.t("sheets-filter.panel.and")}),d.jsx(N.Radio,{value:"OR",children:t.t("sheets-filter.panel.or")})]}),d.jsx(N.Select,{value:O,options:h,onChange:L=>m({[A]:L})}),M&&d.jsx("div",{children:d.jsx(N.Input,{className:"univer-mt-2",value:P,placeholder:p,onChange:L=>m({[A==="operator1"?"val1":"val2"]:L})})})]})}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(N.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:N.clsx("univer-mt-2 univer-flex-grow univer-overflow-hidden univer-rounded-md univer-p-2",N.borderClassName),children:[n.numOfParameters>=1&&I(o.operator1,(v=o.val1)!=null?v:"","operator1"),n.numOfParameters>=2&&I(o.operator2,(T=o.val2)!=null?T:"","operator2"),d.jsxs("div",{"data-u-comp":"sheets-filter-panel-conditions-desc",className:"univer-mt-2 univer-text-xs univer-text-gray-500",children:[t.t("sheets-filter.panel.?"),d.jsx("br",{}),t.t("sheets-filter.panel.*")]})]}):null]})})}function Ht(r){const e=r.getCurrentLocale();return F.useMemo(()=>[{options:[{label:r.t(f.NONE.label),value:f.NONE.operator}]},{options:[{label:r.t(f.EMPTY.label),value:f.EMPTY.operator},{label:r.t(f.NOT_EMPTY.label),value:f.NOT_EMPTY.operator}]},{options:[{label:r.t(f.TEXT_CONTAINS.label),value:f.TEXT_CONTAINS.operator},{label:r.t(f.DOES_NOT_CONTAIN.label),value:f.DOES_NOT_CONTAIN.operator},{label:r.t(f.STARTS_WITH.label),value:f.STARTS_WITH.operator},{label:r.t(f.ENDS_WITH.label),value:f.ENDS_WITH.operator},{label:r.t(f.EQUALS.label),value:f.EQUALS.operator}]},{options:[{label:r.t(f.GREATER_THAN.label),value:f.GREATER_THAN.operator},{label:r.t(f.GREATER_THAN_OR_EQUAL.label),value:f.GREATER_THAN_OR_EQUAL.operator},{label:r.t(f.LESS_THAN.label),value:f.LESS_THAN.operator},{label:r.t(f.LESS_THAN_OR_EQUAL.label),value:f.LESS_THAN_OR_EQUAL.operator},{label:r.t(f.EQUAL.label),value:f.EQUAL.operator},{label:r.t(f.NOT_EQUAL.label),value:f.NOT_EQUAL.operator},{label:r.t(f.BETWEEN.label),value:f.BETWEEN.operator},{label:r.t(f.NOT_BETWEEN.label),value:f.NOT_BETWEEN.operator}]},{options:[{label:r.t(f.CUSTOM.label),value:f.CUSTOM.operator}]}],[e,r])}function xt(r){const e=r.getCurrentLocale();return F.useMemo(()=>f.ALL_CONDITIONS.filter(t=>t.numOfParameters!==2).map(t=>({label:r.t(t.label),value:t.operator})),[e,r])}function Wt(r){const{model:e}=r,t=C.useDependency(c.LocaleService),n=C.useObservable(e.searchString$,"",!0),o=C.useObservable(e.filterItems$,void 0,!0),l=t.t("sheets-filter.panel.filter-only"),i=be(o),s=i.checked>0&&i.unchecked===0,a=i.checked>0&&i.unchecked>0,h=e.treeMapCache,m=F.useCallback(()=>{e.onCheckAllToggled(!s)},[e,s]),p=F.useCallback(v=>{e.setSearchString(v)},[e]);function I(v){let T=[];return v.forEach(O=>{O.checked&&T.push(O.key),O.children&&(T=T.concat(I(O.children)))}),T}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(N.Input,{autoFocus:!0,value:n,placeholder:t.t("sheets-filter.panel.search-placeholder"),onChange:p}),d.jsxs("div",{"data-u-comp":"sheets-filter-panel",className:N.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",N.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-py-0 univer-pl-5 univer-pr-0.5 univer-text-sm",children:[d.jsx(N.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-truncate univer-text-gray-900 dark:!univer-text-white",children:`${t.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(N.Tree,{data:o,defaultExpandAll:!1,valueGroup:I(o),onChange:v=>{e.onFilterCheckToggled(v)},defaultCache:h,itemHeight:28,treeNodeClassName:`
1
+ (function(g,c){typeof exports=="object"&&typeof module<"u"?c(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"),require("react/jsx-runtime")):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","react/jsx-runtime"],c):(g=typeof globalThis<"u"?globalThis:g||self,c(g.UniverSheetsFilterUi={},g.UniverCore,g.UniverSheetsFilter,g.UniverSheetsUi,g.UniverUi,g.UniverEngineRender,g.UniverSheets,g.rxjs,g.UniverRpc,g.UniverDesign,g.React,g.React))})(this,(function(g,c,u,$,C,K,y,S,fe,N,F,d){"use strict";var rr=Object.defineProperty;var ir=(g,c,u)=>c in g?rr(g,c,{enumerable:!0,configurable:!0,writable:!0,value:u}):g[c]=u;var _=(g,c,u)=>ir(g,typeof c!="symbol"?c+"":c,u);var se;var R=(r=>(r[r.FIRST=0]="FIRST",r[r.SECOND=1]="SECOND",r))(R||{}),E=(r=>(r.NONE="none",r.STARTS_WITH="startsWith",r.DOES_NOT_START_WITH="doesNotStartWith",r.ENDS_WITH="endsWith",r.DOES_NOT_END_WITH="doesNotEndWith",r.CONTAINS="contains",r.DOES_NOT_CONTAIN="doesNotContain",r.EQUALS="equals",r.NOT_EQUALS="notEquals",r.EMPTY="empty",r.NOT_EMPTY="notEmpty",r.BETWEEN="between",r.NOT_BETWEEN="notBetween",r.CUSTOM="custom",r))(E||{}),f;(r=>{r.NONE={label:"sheets-filter.conditions.none",operator:E.NONE,order:R.SECOND,numOfParameters:0,getDefaultFormParams:()=>{throw new Error("[FilterConditionItems.NONE]: should not have initial form params!")},testMappingParams:i=>i.operator1===E.NONE,mapToFilterColumn:()=>null,testMappingFilterColumn:i=>!i.customFilters&&!i.filters?{}:!1},r.EMPTY={label:"sheets-filter.conditions.empty",operator:E.EMPTY,order:R.SECOND,numOfParameters:0,getDefaultFormParams:()=>{throw new Error("[FilterConditionItems.EMPTY]: should not have initial form params!")},testMappingParams:({operator1:i})=>i===E.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:E.EMPTY}:!1}},r.NOT_EMPTY={label:"sheets-filter.conditions.not-empty",operator:E.NOT_EMPTY,order:R.SECOND,numOfParameters:0,getDefaultFormParams:()=>{throw new Error("[FilterConditionItems.NOT_EMPTY]: should not have initial form params!")},testMappingParams:({operator1:i})=>i===E.NOT_EMPTY,mapToFilterColumn:()=>({customFilters:{customFilters:[{val:"",operator:u.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===u.CustomFilterOperator.NOT_EQUALS?{operator1:E.NOT_EMPTY}:!1}},r.TEXT_CONTAINS={label:"sheets-filter.conditions.text-contains",operator:E.CONTAINS,order:R.FIRST,numOfParameters:1,getDefaultFormParams:()=>({operator1:E.CONTAINS,val1:""}),testMappingParams:i=>{const[s]=D(i);return s===E.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:E.CONTAINS,val1:a.slice(1,-1)}:!1}},r.DOES_NOT_CONTAIN={label:"sheets-filter.conditions.does-not-contain",operator:E.DOES_NOT_CONTAIN,order:R.FIRST,numOfParameters:1,getDefaultFormParams:()=>({operator1:E.DOES_NOT_CONTAIN,val1:""}),mapToFilterColumn:i=>({customFilters:{customFilters:[{val:`*${i.val1}*`,operator:u.CustomFilterOperator.NOT_EQUALS}]}}),testMappingParams:i=>{const[s]=D(i);return s===E.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===u.CustomFilterOperator.NOT_EQUALS&&a.startsWith("*")&&a.endsWith("*")?{operator1:E.DOES_NOT_CONTAIN,val1:a.slice(1,-1)}:!1}},r.STARTS_WITH={label:"sheets-filter.conditions.starts-with",operator:E.STARTS_WITH,order:R.FIRST,numOfParameters:1,getDefaultFormParams:()=>({operator1:E.STARTS_WITH,val1:""}),mapToFilterColumn:i=>({customFilters:{customFilters:[{val:`${i.val1}*`}]}}),testMappingParams:i=>{const[s]=D(i);return s===E.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:E.STARTS_WITH,val1:a.slice(0,-1)}:!1}},r.ENDS_WITH={label:"sheets-filter.conditions.ends-with",operator:E.ENDS_WITH,order:R.FIRST,numOfParameters:1,getDefaultFormParams:()=>({operator1:E.ENDS_WITH,val1:""}),mapToFilterColumn:i=>({customFilters:{customFilters:[{val:`*${i.val1}`}]}}),testMappingParams:i=>{const[s]=D(i);return s===E.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:E.ENDS_WITH,val1:a.slice(1)}:!1}},r.EQUALS={label:"sheets-filter.conditions.equals",operator:E.EQUALS,order:R.FIRST,numOfParameters:1,getDefaultFormParams:()=>({operator1:E.EQUALS,val1:""}),testMappingParams:i=>{const[s]=D(i);return s===E.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:E.EQUALS,val1:""}:((h=i.customFilters)==null?void 0:h.customFilters.length)===1&&!i.customFilters.customFilters[0].operator?{operator1:E.EQUALS,val1:i.customFilters.customFilters[0].val.toString()}:!1}},r.GREATER_THAN={label:"sheets-filter.conditions.greater-than",operator:u.CustomFilterOperator.GREATER_THAN,numOfParameters:1,order:R.FIRST,getDefaultFormParams:()=>({operator1:u.CustomFilterOperator.GREATER_THAN,val1:""}),mapToFilterColumn:i=>({customFilters:{customFilters:[{val:i.val1,operator:u.CustomFilterOperator.GREATER_THAN}]}}),testMappingParams:i=>{const[s]=D(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()}}},r.GREATER_THAN_OR_EQUAL={label:"sheets-filter.conditions.greater-than-or-equal",operator:u.CustomFilterOperator.GREATER_THAN_OR_EQUAL,numOfParameters:1,order:R.FIRST,getDefaultFormParams:()=>({operator1:u.CustomFilterOperator.GREATER_THAN_OR_EQUAL,val1:""}),testMappingParams:i=>{const[s]=D(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()}}},r.LESS_THAN={label:"sheets-filter.conditions.less-than",operator:u.CustomFilterOperator.LESS_THAN,numOfParameters:1,order:R.FIRST,getDefaultFormParams:()=>({operator1:u.CustomFilterOperator.LESS_THAN,val1:""}),testMappingParams:i=>{const[s]=D(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()}}},r.LESS_THAN_OR_EQUAL={label:"sheets-filter.conditions.less-than-or-equal",operator:u.CustomFilterOperator.LESS_THAN_OR_EQUAL,numOfParameters:1,order:R.FIRST,getDefaultFormParams:()=>({operator1:u.CustomFilterOperator.LESS_THAN_OR_EQUAL,val1:""}),testMappingParams:i=>{const[s]=D(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()}}},r.EQUAL={label:"sheets-filter.conditions.equal",operator:u.CustomFilterOperator.EQUAL,numOfParameters:1,order:R.FIRST,getDefaultFormParams:()=>({operator1:u.CustomFilterOperator.EQUAL,val1:""}),testMappingParams:i=>{const[s]=D(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()}}},r.NOT_EQUAL={label:"sheets-filter.conditions.not-equal",operator:u.CustomFilterOperator.NOT_EQUALS,numOfParameters:1,order:R.FIRST,getDefaultFormParams:()=>({operator1:u.CustomFilterOperator.NOT_EQUALS,val1:""}),testMappingParams:i=>{const[s]=D(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()}}},r.BETWEEN={label:"sheets-filter.conditions.between",operator:E.BETWEEN,order:R.SECOND,numOfParameters:2,getDefaultFormParams:()=>({and:!0,operator1:u.CustomFilterOperator.GREATER_THAN_OR_EQUAL,val1:"",operator2:u.CustomFilterOperator.LESS_THAN_OR_EQUAL,val2:""}),testMappingParams:i=>{const{and:s,operator1:a,operator2:h}=i;if(!s)return!1;const m=[a,h];return m.includes(u.CustomFilterOperator.GREATER_THAN_OR_EQUAL)&&m.includes(u.CustomFilterOperator.LESS_THAN_OR_EQUAL)},mapToFilterColumn:i=>{const{val1:s,val2:a,operator1:h}=i,m=h===u.CustomFilterOperator.GREATER_THAN_OR_EQUAL;return{customFilters:{and:c.BooleanNumber.TRUE,customFilters:[{val:m?s:a,operator:u.CustomFilterOperator.GREATER_THAN_OR_EQUAL},{val:m?a:s,operator:u.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===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}},r.NOT_BETWEEN={label:"sheets-filter.conditions.not-between",operator:E.NOT_BETWEEN,order:R.SECOND,numOfParameters:2,getDefaultFormParams:()=>({operator1:u.CustomFilterOperator.LESS_THAN,val1:"",operator2:u.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(u.CustomFilterOperator.GREATER_THAN)&&m.includes(u.CustomFilterOperator.LESS_THAN)},mapToFilterColumn:i=>{const{val1:s,val2:a,operator1:h}=i,m=h===u.CustomFilterOperator.GREATER_THAN;return{customFilters:{customFilters:[{val:m?s:a,operator:u.CustomFilterOperator.GREATER_THAN},{val:m?a:s,operator:u.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===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}},r.CUSTOM={label:"sheets-filter.conditions.custom",operator:E.CUSTOM,order:R.SECOND,numOfParameters:2,getDefaultFormParams:()=>({operator1:E.NONE,val1:"",operator2:E.NONE,val2:""}),testMappingParams:()=>!0,mapToFilterColumn:i=>{const{and:s,val1:a,val2:h,operator1:m,operator2:p}=i;function I(M,L){for(const U of r.ALL_CONDITIONS)if(U.operator===M)return U.mapToFilterColumn({val1:L,operator1:M})}const v=!m||m===r.NONE.operator,T=!p||p===r.NONE.operator;if(v&&T)return r.NONE.mapToFilterColumn({});if(v)return I(p,h);if(T)return I(m,a);const O=I(m,a),P=I(p,h),A={customFilters:[O.customFilters.customFilters[0],P.customFilters.customFilters[0]]};return s&&(A.and=c.BooleanNumber.TRUE),{customFilters:A}},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}},r.ALL_CONDITIONS=[r.NONE,r.EMPTY,r.NOT_EMPTY,r.TEXT_CONTAINS,r.DOES_NOT_CONTAIN,r.STARTS_WITH,r.ENDS_WITH,r.EQUALS,r.GREATER_THAN,r.GREATER_THAN_OR_EQUAL,r.LESS_THAN,r.LESS_THAN_OR_EQUAL,r.EQUAL,r.NOT_EQUAL,r.BETWEEN,r.NOT_BETWEEN,r.CUSTOM];function e(i){const s=r.ALL_CONDITIONS.find(a=>a.operator===i);if(!s)throw new Error(`[SheetsFilter]: no condition item found for operator: ${i}`);return s}r.getItemByOperator=e;function t(i,s){for(const a of r.ALL_CONDITIONS.filter(h=>h.numOfParameters===s))if(a.numOfParameters!==0&&a.testMappingParams(i))return a;for(const a of r.ALL_CONDITIONS)if(a.testMappingParams(i))return a;throw new Error("[SheetsFilter]: no condition item can be mapped from the filter map params!")}r.testMappingParams=t;function n(i){const s=r.ALL_CONDITIONS.find(a=>a.operator===i);return(s==null?void 0:s.numOfParameters)===0?{operator1:s.operator}:s.getDefaultFormParams()}r.getInitialFormParams=n;function o(i,s){return i.mapToFilterColumn(s)}r.mapToFilterColumn=o;function l(i){if(!i)return[r.NONE,{}];for(const s of r.ALL_CONDITIONS){const a=s.testMappingFilterColumn(i);if(a)return[s,a]}return[r.NONE,{}]}r.testMappingFilterColumn=l})(f||(f={}));function D(r){const{operator1:e,operator2:t,val1:n,val2:o}=r;if(e&&t)throw new Error("Both operator1 and operator2 are set!");if(!e&&!t)throw new Error("Neither operator1 and operator2 and both not set!");return e?[e,n]:[t,o]}function be(r){const e=[],t=[];let n=0,o=0;function l(i){i.leaf&&(i.checked?(e.push(i),n+=i.count):(t.push(i),o+=i.count)),i.children&&i.children.forEach(l)}return r.forEach(l),{checkedItems:e,uncheckedItems:t,checked:n,unchecked:o}}var ot=Object.getOwnPropertyDescriptor,st=(r,e,t,n)=>{for(var o=n>1?void 0:n?ot(e,t):e,l=r.length-1,i;l>=0;l--)(i=r[l])&&(o=i(o)||o);return o},ye=(r,e)=>(t,n)=>e(t,n,r);const Pe="sheets-filter.generate-filter-values.service",ve=c.createIdentifier(Pe);let Ae=class extends c.Disposable{constructor(r,e,t){super(),this._localeService=r,this._univerInstanceService=e,this._logService=t}async getFilterValues(r){var p;const{unitId:e,subUnitId:t,filteredOutRowsByOtherColumns:n,filterColumn:o,filters:l,blankChecked:i,iterateRange:s,alreadyChecked:a}=r,h=this._univerInstanceService.getUnit(e),m=(p=this._univerInstanceService.getUnit(e))==null?void 0:p.getSheetBySheetId(t);return!h||!m?[]:(this._logService.debug("[SheetsGenerateFilterValuesService]","getFilterValues for",{unitId:e,subUnitId:t}),He(l,this._localeService,s,m,new Set(n),o,new Set(a.map(String)),i,h.getStyles()))}};Ae=st([ye(0,c.Inject(c.LocaleService)),ye(1,c.IUniverInstanceService),ye(2,c.ILogService)],Ae);function He(r,e,t,n,o,l,i,s,a){var P,A,M,L,U,B,Y,q,ae,H;const h=new Map,m=new Map,p="yyyy-mm-dd",I="empty",v=!r&&((l==null?void 0:l.filterBy)===u.FilterBy.COLORS||(l==null?void 0:l.filterBy)===u.FilterBy.CONDITIONS)&&((P=l.filteredOutRows)==null?void 0:P.size);let T=0;for(const b of n.iterateByColumn(t,!1,!1)){const{row:ke,rowSpan:Fe=1}=b;let le=0;for(;le<Fe;){const tr=ke+le;if(o.has(tr)){le++;continue}const X=b!=null&&b.value?c.extractPureTextFromCell(b.value):"";if(!X){T+=1,le+=Fe;continue}const Ne=(A=b.value)!=null&&A.v&&!b.value.p?(U=(L=a.get((M=b.value)==null?void 0:M.s))==null?void 0:L.n)==null?void 0:U.pattern:"",it=Ne&&c.numfmt.getFormatInfo(Ne).isDate;let nt=!1;if(it){const{year:W,month:Z,day:w}=c.numfmt.getFormatDateInfo(Ne);nt=W||Z||w}if(Ne&&it&&nt){const W=(B=n.getCellRaw(b.row,b.col))==null?void 0:B.v;if(!W){le++;continue}const Z=c.numfmt.format(p,Number(W)),[w,V,pe]=Z.split("-").map(Number);let J=h.get(`${w}`);J||(J={title:`${w}`,key:`${w}`,children:[],count:0,leaf:!1,checked:!1},h.set(`${w}`,J),m.set(`${w}`,[`${w}`]));let j=(Y=J.children)==null?void 0:Y.find(De=>De.key===`${w}-${V}`);j||(j={title:e.t(`sheets-filter.date.${V}`),key:`${w}-${V}`,children:[],count:0,leaf:!1,checked:!1},(q=J.children)==null||q.push(j),m.set(`${w}-${V}`,[`${w}`,`${w}-${V}`]));const Be=(ae=j==null?void 0:j.children)==null?void 0:ae.find(De=>De.key===`${w}-${V}-${pe}`);Be?(Be.originValues.add(X),Be.count++,j.count++,J.count++):((H=j.children)==null||H.push({title:`${pe}`,key:`${w}-${V}-${pe}`,count:1,originValues:new Set([X]),leaf:!0,checked:v?!1:i.size?i.has(X):!s}),j.count++,J.count++,m.set(`${w}-${V}-${pe}`,[`${w}`,`${w}-${V}`,`${w}-${V}-${pe}`]))}else{const W=X;let Z=h.get(W);Z?Z.count++:(Z={title:X,leaf:!0,checked:v?!1:i.size?i.has(X):!s,key:W,count:1},h.set(W,Z),m.set(W,[W]))}le++}}const O=v?!1:r?s:!0;if(T>0){const b={title:e.t("sheets-filter.panel.empty"),count:T,leaf:!0,checked:O,key:I};h.set("empty",b),m.set("empty",[I])}return{filterTreeItems:at(Array.from(h.values())),filterTreeMapCache:m}}function at(r){return Array.from(r).sort((e,t)=>e.children&&!t.children?-1:!e.children&&t.children?1:lt(e.title,t.title)).map(e=>(e.children&&e.children.sort((t,n)=>{const o=Number.parseInt(t.key.split("-")[1],10),l=Number.parseInt(n.key.split("-")[1],10);return o-l}).forEach(t=>{t.children&&t.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 xe=r=>!Number.isNaN(Number(r))&&!Number.isNaN(Number.parseFloat(r));function lt(r,e){const t=xe(r),n=xe(e);return t&&n?Number.parseFloat(r)-Number.parseFloat(e):t&&!n?-1:!t&&n?1:r.localeCompare(e)}function we(r,e){for(const t of r){if(t.key===e)return t;if(t.children){const n=we(t.children,e);if(n)return n}}return null}function We(r){return r.leaf?r.checked:r.children?r.children.every(e=>We(e)):!0}function ce(r,e){r.leaf&&(e!==void 0?r.checked=e:r.checked=!r.checked),r.children&&r.children.forEach(t=>ce(t,e))}function Ve(r,e){const t=[];return r.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)t.push({...n});else if(n.children){const s=Ve(n.children,e);if(s.length>0){const a=s.reduce((h,m)=>h+m.count,0);t.push({...n,count:a,children:s})}}}),t}var ct=Object.getOwnPropertyDescriptor,_e=(r,e,t,n)=>{for(var o=n>1?void 0:n?ct(e,t):e,l=r.length-1,i;l>=0;l--)(i=r[l])&&(o=i(o)||o);return o},ue=(r,e)=>(t,n)=>e(t,n,r);c.createIdentifier("sheets-filter-ui.sheets-filter-panel.service");let Q=class extends c.Disposable{constructor(e,t){super();_(this,"_filterBy$",new S.BehaviorSubject(u.FilterBy.VALUES));_(this,"filterBy$",this._filterBy$.asObservable());_(this,"_filterByModel$",new S.ReplaySubject(1));_(this,"filterByModel$",this._filterByModel$.asObservable());_(this,"_filterByModel",null);_(this,"_hasCriteria$",new S.BehaviorSubject(!1));_(this,"hasCriteria$",this._hasCriteria$.asObservable());_(this,"_filterModel",null);_(this,"_col$",new S.BehaviorSubject(-1));_(this,"col$",this._col$.asObservable());_(this,"_filterHeaderListener",null);this._injector=e,this._refRangeService=t}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,t){this.terminate(),this._filterModel=e,this._col$.next(t);const n=e.getFilterColumn(t);if(n){const o=n.getColumnData();if(o.customFilters){this._hasCriteria$.next(!0),this._setupByConditions(e,t);return}if(o.colorFilters){this._hasCriteria$.next(!0),this._setupByColors(e,t);return}if(o.filters){this._hasCriteria$.next(!0),this._setupByValues(e,t);return}this._hasCriteria$.next(!1),this._setupByValues(e,t);return}this._hasCriteria$.next(!1),this._setupByValues(e,t)}changeFilterBy(e){if(!this._filterModel||this.col===-1)return!1;switch(e){case u.FilterBy.VALUES:this._setupByValues(this._filterModel,this.col);break;case u.FilterBy.COLORS:this._setupByColors(this._filterModel,this.col);break;case u.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,t){this._disposeFilterHeaderChangeListener();const n=e.unitId,o=e.subUnitId,l=e.getRange(),i={startColumn:t,startRow:l.startRow,endRow:l.startRow,endColumn:t};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,t){this._disposePreviousModel();const n=e.getRange();if(n.startRow===n.endRow)return!1;const o=await Ce.fromFilterColumn(this._injector,e,t);return this.filterByModel=o,this._filterBy$.next(u.FilterBy.VALUES),this._listenToFilterHeaderChange(e,t),!0}async _setupByColors(e,t){this._disposePreviousModel();const n=e.getRange();if(n.startRow===n.endRow)return!1;const o=await Se.fromFilterColumn(this._injector,e,t);return this.filterByModel=o,this._filterBy$.next(u.FilterBy.COLORS),this._listenToFilterHeaderChange(e,t),!0}_setupByConditions(e,t){this._disposePreviousModel();const n=e.getRange();if(n.startRow===n.endRow)return!1;const o=ge.fromFilterColumn(this._injector,e,t,e.getFilterColumn(t));return this.filterByModel=o,this._filterBy$.next(u.FilterBy.CONDITIONS),this._listenToFilterHeaderChange(e,t),!0}_disposePreviousModel(){var e;(e=this._filterByModel)==null||e.dispose(),this.filterByModel=null}};Q=_e([ue(0,c.Inject(c.Injector)),ue(1,c.Inject(y.RefRangeService))],Q);let ge=class extends c.Disposable{constructor(e,t,n,o,l){super();_(this,"canApply$",S.of(!0));_(this,"_conditionItem$");_(this,"conditionItem$");_(this,"_filterConditionFormParams$");_(this,"filterConditionFormParams$");this._filterModel=e,this.col=t,this._commandService=l,this._conditionItem$=new S.BehaviorSubject(n),this.conditionItem$=this._conditionItem$.asObservable(),this._filterConditionFormParams$=new S.BehaviorSubject(o),this.filterConditionFormParams$=this._filterConditionFormParams$.asObservable()}static fromFilterColumn(e,t,n,o){const[l,i]=f.testMappingFilterColumn(o==null?void 0:o.getColumnData());return e.createInstance(ge,t,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=f.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 t=f.ALL_CONDITIONS.find(n=>n.operator===e);if(!t)throw new Error(`[ByConditionsModel]: condition item not found for operator: ${e}!`);this._conditionItem$.next(t),this._filterConditionFormParams$.next(f.getInitialFormParams(e))}onConditionFormChange(e){const t={...this.filterConditionFormParams,...e};if(t.and!==!0&&delete t.and,typeof e.and<"u"||typeof e.operator1<"u"||typeof e.operator2<"u"){const n=f.testMappingParams(t,this.conditionItem.numOfParameters);this._conditionItem$.next(n)}this._filterConditionFormParams$.next(t)}};ge=_e([ue(4,c.ICommandService)],ge);let Ce=class extends c.Disposable{constructor(e,t,n,o,l){super();_(this,"_rawFilterItems$");_(this,"rawFilterItems$");_(this,"filterItems$");_(this,"_filterItems",[]);_(this,"_treeMapCache");_(this,"canApply$");_(this,"_manuallyUpdateFilterItems$");_(this,"_searchString$");_(this,"searchString$");this._filterModel=e,this.col=t,this._commandService=l,this._treeMapCache=o,this._searchString$=new S.BehaviorSubject(""),this.searchString$=this._searchString$.asObservable(),this._rawFilterItems$=new S.BehaviorSubject(n),this.rawFilterItems$=this._rawFilterItems$.asObservable(),this._manuallyUpdateFilterItems$=new S.Subject,this.filterItems$=S.merge(S.combineLatest([this._searchString$.pipe(S.throttleTime(500,void 0,{leading:!0,trailing:!0}),S.startWith(void 0)),this._rawFilterItems$]).pipe(S.map(([i,s])=>{if(!i)return s;const h=i.toLowerCase().split(/\s+/).filter(m=>!!m);return Ve(s,h)})),this._manuallyUpdateFilterItems$).pipe(S.shareReplay(1)),this.canApply$=this.filterItems$.pipe(S.map(i=>be(i).checked>0)),this.disposeWithMe(this.filterItems$.subscribe(i=>this._filterItems=i))}static async fromFilterColumn(e,t,n){const o=e.get(c.IUniverInstanceService),l=e.get(c.LocaleService),i=e.get(ve,c.Quantity.OPTIONAL),{unitId:s,subUnitId:a}=t,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=t.getRange(),I=n,v=t.getFilterColumn(n),T=v==null?void 0:v.getColumnData().filters,O=new Set(T==null?void 0:T.filters),P=!!(T&&T.blank),A=t.getFilteredOutRowsExceptCol(n),M={...p,startRow:p.startRow+1,startColumn:I,endColumn:I};let L,U;if(i){const B=await i.getFilterValues({unitId:s,subUnitId:a,filteredOutRowsByOtherColumns:Array.from(A),filterColumn:v,filters:!!T,blankChecked:P,iterateRange:M,alreadyChecked:Array.from(O)});L=B.filterTreeItems,U=B.filterTreeMapCache}else{const B=He(!!T,l,M,m,A,v,O,P,h.getStyles());L=B.filterTreeItems,U=B.filterTreeMapCache}return e.createInstance(Ce,t,n,L,U)}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 t=c.Tools.deepClone(this._filterItems);t.forEach(n=>ce(n,e)),this._manuallyUpdateFilterItems(t)}onFilterCheckToggled(e){const t=c.Tools.deepClone(this._filterItems),n=we(t,e.key);if(!n)return;const o=We(n);ce(n,!o),this._manuallyUpdateFilterItems(t)}onFilterOnly(e){const t=c.Tools.deepClone(this._filterItems);t.forEach(n=>ce(n,!1)),e.forEach(n=>{const o=we(t,n);o&&ce(o,!0)}),this._manuallyUpdateFilterItems(t)}_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=be(this._filterItems),{checked:t,checkedItems:n}=e,o=this.rawFilterItems;let l=0;for(const h of o)l+=h.count;const i=t===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 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(u.SetSheetsFilterCriteriaCommand.id,{unitId:this._filterModel.unitId,subUnitId:this._filterModel.subUnitId,col:this.col,criteria:a})}};Ce=_e([ue(4,c.ICommandService)],Ce);let Se=class extends c.Disposable{constructor(e,t,n,o,l){super();_(this,"canApply$",S.of(!0));_(this,"_cellFillColors$");_(this,"cellFillColors$");_(this,"_cellTextColors$");_(this,"cellTextColors$");this._filterModel=e,this.col=t,this._commandService=l,this._cellFillColors$=new S.BehaviorSubject(Array.from(n.values())),this.cellFillColors$=this._cellFillColors$.asObservable(),this._cellTextColors$=new S.BehaviorSubject(Array.from(o.values())),this.cellTextColors$=this._cellTextColors$.asObservable()}static async fromFilterColumn(e,t,n){var M,L,U;const o=e.get(c.IUniverInstanceService),{unitId:l,subUnitId:i}=t,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=t.getRange(),m=n,p=(M=t.getFilterColumn(n))==null?void 0:M.getColumnData().colorFilters,I=t.getFilteredOutRowsExceptCol(n),v={...h,startRow:h.startRow+1,startColumn:m,endColumn:m},T=new Map,O=new Set((L=p==null?void 0:p.cellFillColors)!=null?L:[]),P=new Map,A=new Set((U=p==null?void 0:p.cellTextColors)!=null?U:[]);for(const B of a.iterateByColumn(v,!1,!0)){const{row:Y,col:q,value:ae}=B;if(I.has(Y))continue;const H=a.getComposedCellStyleByCellData(Y,q,ae);if(H.bg&&H.bg.rgb){const b=new c.ColorKit(H.bg.rgb).toRgbString();T.has(b)||T.set(b,{color:b,checked:O.has(b)})}else T.set("default-fill-color",{color:null,checked:O.has(null)});if(H.cl&&H.cl.rgb){const b=new c.ColorKit(H.cl.rgb).toRgbString();P.has(b)||P.set(b,{color:b,checked:A.has(b)})}else P.set("default-font-color",{color:K.COLOR_BLACK_RGB,checked:A.has(K.COLOR_BLACK_RGB)})}return e.createInstance(Se,t,n,T,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(u.SetSheetsFilterCriteriaCommand.id,{unitId:this._filterModel.unitId,subUnitId:this._filterModel.subUnitId,col:this.col,criteria:null})}onFilterCheckToggled(e,t=!0){const n=t?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(!t),t?this._cellFillColors$.next([...o]):this._cellTextColors$.next([...o]))}_resetColorsCheckedStatus(e=!0){const t=e?this.cellFillColors:this.cellTextColors,n=[];for(let o=0;o<t.length;o++)n.push({color:t[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),t=this.cellTextColors.filter(o=>o.checked).map(o=>o.color);if(e.length===0&&t.length===0)return this._commandService.executeCommand(u.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}:t.length>0&&(n.colorFilters={cellTextColors:t}),this._commandService.executeCommand(u.SetSheetsFilterCriteriaCommand.id,{unitId:this._filterModel.unitId,subUnitId:this._filterModel.subUnitId,col:this.col,criteria:n})}};Se=_e([ue(4,c.ICommandService)],Se);const ee="FILTER_PANEL_OPENED",he={id:"sheet.operation.open-filter-panel",type:c.CommandType.OPERATION,handler:(r,e)=>{const t=r.get(c.IContextService),n=r.get(u.SheetsFilterService),o=r.get(Q),l=r.get(c.ICommandService),i=r.has($.IEditorBridgeService)?r.get($.IEditorBridgeService):null;i!=null&&i.isVisible().visible&&l.syncExecuteCommand($.SetCellEditVisibleOperation.id,{visible:!1});const{unitId:s,subUnitId:a,col:h}=e,m=n.getFilterModel(s,a);return m?(o.setupCol(m,h),t.getContextValue(ee)||t.setContextValue(ee,!0),!0):!1}},te={id:"sheet.operation.close-filter-panel",type:c.CommandType.OPERATION,handler:r=>{const e=r.get(c.IContextService),t=r.get(Q),n=r.get(C.ILayoutService,c.Quantity.OPTIONAL);return e.getContextValue(ee)?(e.setContextValue(ee,!1),n==null||n.focus(),t.terminate()):!1}},Re={id:"sheet.operation.apply-filter",type:c.CommandType.OPERATION,handler:(r,e)=>{const{filterBy:t}=e;return r.get(Q).changeFilterBy(t)}},re={name:"@univerjs/sheets-filter-ui",version:"0.17.0"},je="sheets-filter-ui.config",Te={};var ut=Object.getOwnPropertyDescriptor,ht=(r,e,t,n)=>{for(var o=n>1?void 0:n?ut(e,t):e,l=r.length-1,i;l>=0;l--)(i=r[l])&&(o=i(o)||o);return o},ie=(r,e)=>(t,n)=>e(t,n,r);let ne=class extends c.Disposable{constructor(r,e,t,n,o,l){super(),this._sheetsFilterService=r,this._localeService=e,this._commandService=t,this._sheetPermissionCheckPermission=n,this._injector=o,this._sheetsSelectionService=l,this._commandExecutedListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.beforeCommandExecuted(r=>{var e,t,n;if(r.id===u.SmartToggleSheetsFilterCommand.id){const o=this._injector.get(c.IUniverInstanceService),l=y.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:[y.RangeProtectionPermissionViewPoint],worksheetTypes:[y.WorksheetFilterPermission,y.WorksheetViewPermission]},[h],i,s);else{const p=(t=this._sheetsSelectionService.getCurrentLastSelection())==null?void 0:t.range;if(p){let I={...p};I=p.startColumn===p.endColumn&&p.startRow===p.endRow?y.expandToContinuousRange(I,{left:!0,right:!0,up:!0,down:!0},a):I,m=this._sheetPermissionCheckPermission.permissionCheckWithRanges({rangeTypes:[y.RangeProtectionPermissionViewPoint],worksheetTypes:[y.WorksheetViewPermission,y.WorksheetFilterPermission]},[I],i,s)}else m=this._sheetPermissionCheckPermission.permissionCheckWithoutRange({rangeTypes:[y.RangeProtectionPermissionViewPoint],worksheetTypes:[y.WorksheetViewPermission,y.WorksheetFilterPermission]})}m||this._sheetPermissionCheckPermission.blockExecuteWithoutPermission(this._localeService.t("permission.dialog.filterErr"))}if(r.id===he.id){const o=r.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:[y.RangeProtectionPermissionViewPoint],worksheetTypes:[y.WorksheetFilterPermission,y.WorksheetViewPermission]},[a],l,i)||this._sheetPermissionCheckPermission.blockExecuteWithoutPermission(this._localeService.t("permission.dialog.filterErr")))}}))}};ne=ht([ie(0,c.Inject(u.SheetsFilterService)),ie(1,c.Inject(c.LocaleService)),ie(2,c.ICommandService),ie(3,c.Inject(y.SheetPermissionCheckController)),ie(4,c.Inject(c.Injector)),ie(5,c.Inject(y.SheetsSelectionsService))],ne);const G=16,dt=new Path2D("M3.30363 3C2.79117 3 2.51457 3.60097 2.84788 3.99024L6.8 8.60593V12.5662C6.8 12.7184 6.8864 12.8575 7.02289 12.9249L8.76717 13.7863C8.96655 13.8847 9.2 13.7396 9.2 13.5173V8.60593L13.1521 3.99024C13.4854 3.60097 13.2088 3 12.6964 3H3.30363Z");class Qe{static drawNoCriteria(e,t,n,o){e.save(),K.Rect.drawWith(e,{radius:2,width:G,height:G,fill:o}),e.lineCap="square",e.strokeStyle=n,e.scale(t/G,t/G),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,t,n,o){e.save(),K.Rect.drawWith(e,{radius:2,width:G,height:G,fill:o}),e.scale(t/G,t/G),e.fillStyle=n,e.fill(dt),e.restore()}}var mt=Object.getOwnPropertyDescriptor,pt=(r,e,t,n)=>{for(var o=n>1?void 0:n?mt(e,t):e,l=r.length-1,i;l>=0;l--)(i=r[l])&&(o=i(o)||o);return o},Le=(r,e)=>(t,n)=>e(t,n,r);const x=16,de=1;let $e=class extends K.Shape{constructor(e,t,n,o,l){super(e,t);_(this,"_cellWidth",0);_(this,"_cellHeight",0);_(this,"_filterParams");_(this,"_hovered",!1);this._contextService=n,this._commandService=o,this._themeService=l,this.setShapeProps(t),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 t=this._cellHeight,n=this._cellWidth,o=x-n,l=x-t;e.save();const i=new Path2D;i.rect(o,l,n,t),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?Qe.drawHasCriteria(e,x,a,h):Qe.drawNoCriteria(e,x,a,h),e.restore()}onPointerDown(e){if(e.button===2)return;const{col:t,unitId:n,subUnitId:o}=this._filterParams;this._contextService.getContextValue(ee)||!this._commandService.hasCommand(he.id)||setTimeout(()=>{this._commandService.executeCommand(he.id,{unitId:n,subUnitId:o,col:t})},200)}onPointerEnter(){this._hovered=!0,this.makeDirty(!0)}onPointerLeave(){this._hovered=!1,this.makeDirty(!0)}};$e=pt([Le(2,c.IContextService),Le(3,c.ICommandService),Le(4,c.Inject(c.ThemeService))],$e);var ft=Object.getOwnPropertyDescriptor,vt=(r,e,t,n)=>{for(var o=n>1?void 0:n?ft(e,t):e,l=r.length-1,i;l>=0;l--)(i=r[l])&&(o=i(o)||o);return o},z=(r,e)=>(t,n)=>e(t,n,r);const _t=1e3,gt=5e3;function Ct(r,e,t,n){switch(n){case c.VerticalAlign.TOP:return r+de;case c.VerticalAlign.MIDDLE:return r+Math.max(0,(t-x)/2);case c.VerticalAlign.BOTTOM:default:return e-x-de}}let Me=class extends c.RxDisposable{constructor(e,t,n,o,l,i,s,a){super();_(this,"_filterRangeShape",null);_(this,"_buttonRenderDisposable",null);_(this,"_filterButtonShapes",[]);this._context=e,this._injector=t,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(S.switchMap(e=>{var s,a;if(!e)return S.of(null);const{unit:t,unitId:n}=this._context,o=((s=t.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(S.filter(([h])=>{var m;return h.type===c.CommandType.MUTATION&&((m=h.params)==null?void 0:m.unitId)===t.getUnitId()&&(u.FILTER_MUTATIONS.has(h.id)||h.id===y.SetRangeValuesMutation.id)}),S.throttleTime(20,void 0,{leading:!1,trailing:!0}),S.map(i),S.startWith(i()))}),S.takeUntil(this.dispose$)).subscribe(e=>{this._disposeRendering(),!(!e||!e.range)&&(this._renderRange(e.range,e.skeleton),this._renderButtons(e))})}_renderRange(e,t){const{scene:n}=this._context,{rowHeaderWidth:o,columnHeaderHeight:l}=t,i=this._filterRangeShape=new $.SelectionControl(n,_t,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,t);i.updateRangeBySelectionWithCoord(a),i.setEvent(!1),n.makeDirty(!0)}_renderButtons(e){const{range:t,filterModel:n,unitId:o,skeleton:l,worksheetId:i}=e,{unit:s,scene:a}=this._context,h=s.getSheetBySheetId(i);if(!h)return;this._interceptCellContent(o,i,e.range);const{startColumn:m,endColumn:p,startRow:I}=t;for(let v=m;v<=p;v++){const T=`sheets-filter-button-${v}`,O=$.getCoordByCell(I,v,a,l),P=h.getComposedCellStyle(I,v),A=(P==null?void 0:P.vt)||c.VerticalAlign.BOTTOM,{startX:M,startY:L,endX:U,endY:B}=O,Y=U-M,q=B-L;if(q<=de||Y<=de)continue;const ae=!!n.getFilterColumn(v),H=U-x-de,b=Ct(L,B,q,A),ke={left:H,top:b,height:x,width:x,zIndex:gt,cellHeight:q,cellWidth:Y,filterParams:{unitId:o,subUnitId:i,col:v,hasCriteria:ae}},Fe=this._injector.createInstance($e,T,ke);this._filterButtonShapes.push(Fe)}a.addObjects(this._filterButtonShapes),a.makeDirty()}_interceptCellContent(e,t,n){const{startRow:o,startColumn:l,endColumn:i}=n;this._buttonRenderDisposable=this._sheetInterceptorService.intercept(y.INTERCEPTOR_POINT.CELL_CONTENT,{effect:c.InterceptorEffectEnum.Style,handler:(s,a,h)=>{const{row:m,col:p,unitId:I,subUnitId:v}=a;return I!==e||v!==t||m!==o||p<l||p>i||((!s||s===a.rawData)&&(s={...a.rawData}),s.fontRenderExtension={...s==null?void 0:s.fontRenderExtension,rightOffset:x}),h(s)},priority:10})}_disposeRendering(){var e,t;(e=this._filterRangeShape)==null||e.dispose(),this._filterButtonShapes.forEach(n=>n.dispose()),(t=this._buttonRenderDisposable)==null||t.dispose(),this._filterRangeShape=null,this._buttonRenderDisposable=null,this._filterButtonShapes=[]}};Me=vt([z(1,c.Inject(c.Injector)),z(2,c.Inject($.SheetSkeletonManagerService)),z(3,c.Inject(u.SheetsFilterService)),z(4,c.Inject(c.ThemeService)),z(5,c.Inject(y.SheetInterceptorService)),z(6,c.ICommandService),z(7,$.ISheetSelectionRenderService)],Me);var St=Object.getOwnPropertyDescriptor,Tt=(r,e,t,n)=>{for(var o=n>1?void 0:n?St(e,t):e,l=r.length-1,i;l>=0;l--)(i=r[l])&&(o=i(o)||o);return o},Ge=(r,e)=>(t,n)=>e(t,n,r);let me=class extends c.RxDisposable{constructor(r,e){super(),this._renderManagerService=r,this._sheetsRenderService=e,[u.SetSheetsFilterRangeMutation,u.SetSheetsFilterCriteriaMutation,u.RemoveSheetsFilterMutation,u.ReCalcSheetsFilterMutation].forEach(t=>this.disposeWithMe(this._sheetsRenderService.registerSkeletonChangingMutations(t.id))),this.disposeWithMe(this._renderManagerService.registerRenderModule(c.UniverInstanceType.UNIVER_SHEET,[Me]))}};me=Tt([Ge(0,K.IRenderManagerService),Ge(1,c.Inject($.SheetsRenderService))],me);var Et=Object.defineProperty,It=Object.getOwnPropertyDescriptor,Ot=(r,e,t)=>e in r?Et(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Ft=(r,e,t,n)=>{for(var o=n>1?void 0:n?It(e,t):e,l=r.length-1,i;l>=0;l--)(i=r[l])&&(o=i(o)||o);return o},Ye=(r,e)=>(t,n)=>e(t,n,r),Ee=(r,e,t)=>Ot(r,typeof e!="symbol"?e+"":e,t);g.UniverSheetsFilterMobileUIPlugin=class extends c.Plugin{constructor(e=Te,t,n){super(),this._config=e,this._injector=t,this._configService=n;const{menu:o,...l}=c.merge({},Te,this._config);o&&this._configService.setConfig("menu",o,{merge:!0}),this._configService.setConfig(je,l)}onStarting(){[[ne],[me]].forEach(e=>this._injector.add(e))}onReady(){this._injector.get(ne)}onRendered(){this._injector.get(me)}},Ee(g.UniverSheetsFilterMobileUIPlugin,"type",c.UniverInstanceType.UNIVER_SHEET),Ee(g.UniverSheetsFilterMobileUIPlugin,"pluginName","SHEET_FILTER_UI_PLUGIN"),Ee(g.UniverSheetsFilterMobileUIPlugin,"packageName",re.name),Ee(g.UniverSheetsFilterMobileUIPlugin,"version",re.version),g.UniverSheetsFilterMobileUIPlugin=Ft([c.DependentOn(u.UniverSheetsFilterPlugin),Ye(1,c.Inject(c.Injector)),Ye(2,c.IConfigService)],g.UniverSheetsFilterMobileUIPlugin);function oe({ref:r,...e}){const{icon:t,id:n,className:o,extend:l,...i}=e,s=`univerjs-icon univerjs-icon-${n} ${o||""}`.trim(),a=F.useRef(`_${yt()}`);return qe(t,`${n}`,{defIds:t.defIds,idSuffix:a.current},{ref:r,className:s,...i},l)}function qe(r,e,t,n,o){return F.createElement(r.tag,{key:e,...Nt(r,t,o),...n},(bt(r,t).children||[]).map((l,i)=>qe(l,`${e}-${r.tag}-${i}`,t,void 0,o)))}function Nt(r,e,t){const n={...r.attrs};t!=null&&t.colorChannel1&&n.fill==="colorChannel1"&&(n.fill=t.colorChannel1),r.tag==="mask"&&n.id&&(n.id=n.id+e.idSuffix),Object.entries(n).forEach(([l,i])=>{l==="mask"&&typeof i=="string"&&(n[l]=i.replace(/url\(#(.*)\)/,`url(#$1${e.idSuffix})`))});const{defIds:o}=e;return!o||o.length===0||(r.tag==="use"&&n["xlink:href"]&&(n["xlink:href"]=n["xlink:href"]+e.idSuffix),Object.entries(n).forEach(([l,i])=>{typeof i=="string"&&(n[l]=i.replace(/url\(#(.*)\)/,`url(#$1${e.idSuffix})`))})),n}function bt(r,e){var n;const{defIds:t}=e;return!t||t.length===0?r:r.tag==="defs"&&((n=r.children)!=null&&n.length)?{...r,children:r.children.map(o=>typeof o.attrs.id=="string"&&t&&t.includes(o.attrs.id)?{...o,attrs:{...o.attrs,id:o.attrs.id+e.idSuffix}}:o)}:r}function yt(){return Math.random().toString(36).substring(2,8)}oe.displayName="UniverIcon";const 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:"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"}}]},Ze=F.forwardRef(function(e,t){return F.createElement(oe,Object.assign({},e,{id:"a-icon",ref:t,icon:Pt}))});Ze.displayName="AIcon";const At={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"}}]},Ke=F.forwardRef(function(e,t){return F.createElement(oe,Object.assign({},e,{id:"ban-icon",ref:t,icon:At}))});Ke.displayName="BanIcon";const wt={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"}}]},ze=F.forwardRef(function(e,t){return F.createElement(oe,Object.assign({},e,{id:"filter-icon",ref:t,icon:wt}))});ze.displayName="FilterIcon";const Rt={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.00016 1.33203C6.68162 1.33203 5.39269 1.72302 4.29636 2.45557C3.20004 3.18811 2.34555 4.2293 1.84097 5.44747C1.33638 6.66565 1.20436 8.00609 1.4616 9.2993C1.71883 10.5925 2.35377 11.7804 3.28612 12.7127C4.21847 13.6451 5.40636 14.28 6.69956 14.5373C7.99277 14.7945 9.33321 14.6625 10.5514 14.1579C11.7696 13.6533 12.8108 12.7988 13.5433 11.7025C14.2758 10.6062 14.6668 9.31724 14.6668 7.9987C14.6649 6.23118 13.9619 4.53662 12.7121 3.2868C11.4622 2.03697 9.76768 1.33397 8.00016 1.33203ZM7.66683 3.9987C7.86461 3.9987 8.05795 4.05735 8.2224 4.16723C8.38685 4.27711 8.51502 4.43329 8.59071 4.61601C8.6664 4.79874 8.6862 4.99981 8.64762 5.19379C8.60903 5.38777 8.51379 5.56595 8.37394 5.7058C8.23409 5.84566 8.0559 5.9409 7.86192 5.97948C7.66794 6.01807 7.46687 5.99826 7.28415 5.92258C7.10142 5.84689 6.94524 5.71872 6.83536 5.55427C6.72548 5.38982 6.66683 5.19648 6.66683 4.9987C6.66683 4.73348 6.77219 4.47913 6.95972 4.29159C7.14726 4.10405 7.40162 3.9987 7.66683 3.9987ZM9.3335 11.332H6.66683C6.49002 11.332 6.32045 11.2618 6.19543 11.1368C6.0704 11.0117 6.00016 10.8422 6.00016 10.6654C6.00016 10.4886 6.0704 10.319 6.19543 10.194C6.32045 10.0689 6.49002 9.9987 6.66683 9.9987H7.3335V7.9987H6.66683C6.49002 7.9987 6.32045 7.92846 6.19543 7.80343C6.0704 7.67841 6.00016 7.50884 6.00016 7.33203C6.00016 7.15522 6.0704 6.98565 6.19543 6.86063C6.32045 6.7356 6.49002 6.66536 6.66683 6.66536H8.00016C8.17698 6.66536 8.34655 6.7356 8.47157 6.86063C8.59659 6.98565 8.66683 7.15522 8.66683 7.33203V9.9987H9.3335C9.51031 9.9987 9.67988 10.0689 9.8049 10.194C9.92993 10.319 10.0002 10.4886 10.0002 10.6654C10.0002 10.8422 9.92993 11.0117 9.8049 11.1368C9.67988 11.2618 9.51031 11.332 9.3335 11.332Z"}}]},Xe=F.forwardRef(function(e,t){return F.createElement(oe,Object.assign({},e,{id:"info-icon",ref:t,icon:Rt}))});Xe.displayName="InfoIcon";const Lt={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"}}]},Je=F.forwardRef(function(e,t){return F.createElement(oe,Object.assign({},e,{id:"success-icon",ref:t,icon:Lt}))});Je.displayName="SuccessIcon";function $t(r){const e=r.get(u.SheetsFilterService);return{id:u.SmartToggleSheetsFilterCommand.id,type:C.MenuItemType.BUTTON_SELECTOR,icon:"FilterIcon",tooltip:"sheets-filter.toolbar.smart-toggle-filter-tooltip",hidden$:C.getMenuHiddenObservable(r,c.UniverInstanceType.UNIVER_SHEET),activated$:e.activeFilterModel$.pipe(S.map(t=>!!t)),disabled$:$.getObservableWithExclusiveRange$(r,$.getCurrentRangeDisable$(r,{worksheetTypes:[y.WorksheetFilterPermission,y.WorksheetViewPermission],rangeTypes:[y.RangeProtectionPermissionViewPoint]}))}}function Mt(r){const e=r.get(u.SheetsFilterService);return{id:u.ClearSheetsFilterCriteriaCommand.id,type:C.MenuItemType.BUTTON,title:"sheets-filter.toolbar.clear-filter-criteria",hidden$:C.getMenuHiddenObservable(r,c.UniverInstanceType.UNIVER_SHEET),disabled$:e.activeFilterModel$.pipe(S.switchMap(t=>{var n;return(n=t==null?void 0:t.hasCriteria$.pipe(S.map(o=>!o)))!=null?n:S.of(!0)}))}}function Ut(r){const e=r.get(u.SheetsFilterService);return{id:u.ReCalcSheetsFilterCommand.id,type:C.MenuItemType.BUTTON,title:"sheets-filter.toolbar.re-calc-filter-conditions",hidden$:C.getMenuHiddenObservable(r,c.UniverInstanceType.UNIVER_SHEET),disabled$:e.activeFilterModel$.pipe(S.switchMap(t=>{var n;return(n=t==null?void 0:t.hasCriteria$.pipe(S.map(o=>!o)))!=null?n:S.of(!0)}))}}const kt={[C.RibbonDataGroup.ORGANIZATION]:{[u.SmartToggleSheetsFilterCommand.id]:{order:2,menuItemFactory:$t,[u.ClearSheetsFilterCriteriaCommand.id]:{order:0,menuItemFactory:Mt},[u.ReCalcSheetsFilterCommand.id]:{order:1,menuItemFactory:Ut}}}};function Bt(r){const{model:e}=r,t=C.useDependency(c.LocaleService),n=C.useObservable(e.cellFillColors$,[],!0),o=C.useObservable(e.cellTextColors$,[],!0),l=F.useCallback(s=>{e.onFilterCheckToggled(s)},[e]),i=F.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:N.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",N.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:t.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-size-6",onClick:()=>l(s),children:[s.color?d.jsx("button",{type:"button",className:N.clsx("univer-box-border univer-size-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(Ke,{className:"univer-size-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(et,{})]},`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:t.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-size-6",onClick:()=>i(s),children:[d.jsx("div",{className:"univer-box-border univer-flex univer-size-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(Ze,{style:{color:s.color}})}),s.checked&&d.jsx(et,{})]},`sheets-filter-cell-text-color-${a}`))})]}),n.length<=1&&o.length<=1&&d.jsx("div",{className:"univer-flex univer-size-full univer-items-center univer-justify-center univer-text-sm univer-text-gray-900 dark:!univer-text-gray-200",children:t.t("sheets-filter.panel.filter-by-color-none")})]})})}function et(){return d.jsx("div",{className:"univer-absolute -univer-bottom-0.5 -univer-right-0.5 univer-flex univer-size-3 univer-cursor-pointer univer-items-center univer-justify-center univer-rounded-full univer-bg-white",children:d.jsx(Je,{className:"univer-size-full univer-font-bold univer-text-[#418F1F]"})})}function Dt(r){var v,T;const{model:e}=r,t=C.useDependency(c.LocaleService),n=C.useObservable(e.conditionItem$,void 0),o=C.useObservable(e.filterConditionFormParams$,void 0),l=o!=null&&o.and?"AND":"OR",i=F.useCallback(O=>{e.onConditionFormChange({and:O==="AND"})},[e]),s=Ht(t),a=F.useCallback(O=>{e.onPrimaryConditionChange(O)},[e]),h=xt(t),m=F.useCallback(O=>{e.onConditionFormChange(O)},[e]),p=t.t("sheets-filter.panel.input-values-placeholder");function I(O,P,A){const M=f.getItemByOperator(O).numOfParameters===1;return d.jsxs(d.Fragment,{children:[A==="operator2"&&d.jsxs(N.RadioGroup,{value:l,onChange:i,children:[d.jsx(N.Radio,{value:"AND",children:t.t("sheets-filter.panel.and")}),d.jsx(N.Radio,{value:"OR",children:t.t("sheets-filter.panel.or")})]}),d.jsx(N.Select,{value:O,options:h,onChange:L=>m({[A]:L})}),M&&d.jsx("div",{children:d.jsx(N.Input,{className:"univer-mt-2",value:P,placeholder:p,onChange:L=>m({[A==="operator1"?"val1":"val2"]:L})})})]})}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(N.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:N.clsx("univer-mt-2 univer-flex-grow univer-overflow-hidden univer-rounded-md univer-p-2",N.borderClassName),children:[n.numOfParameters>=1&&I(o.operator1,(v=o.val1)!=null?v:"","operator1"),n.numOfParameters>=2&&I(o.operator2,(T=o.val2)!=null?T:"","operator2"),d.jsxs("div",{"data-u-comp":"sheets-filter-panel-conditions-desc",className:"univer-mt-2 univer-text-xs univer-text-gray-500",children:[t.t("sheets-filter.panel.?"),d.jsx("br",{}),t.t("sheets-filter.panel.*")]})]}):null]})})}function Ht(r){const e=r.getCurrentLocale();return F.useMemo(()=>[{options:[{label:r.t(f.NONE.label),value:f.NONE.operator}]},{options:[{label:r.t(f.EMPTY.label),value:f.EMPTY.operator},{label:r.t(f.NOT_EMPTY.label),value:f.NOT_EMPTY.operator}]},{options:[{label:r.t(f.TEXT_CONTAINS.label),value:f.TEXT_CONTAINS.operator},{label:r.t(f.DOES_NOT_CONTAIN.label),value:f.DOES_NOT_CONTAIN.operator},{label:r.t(f.STARTS_WITH.label),value:f.STARTS_WITH.operator},{label:r.t(f.ENDS_WITH.label),value:f.ENDS_WITH.operator},{label:r.t(f.EQUALS.label),value:f.EQUALS.operator}]},{options:[{label:r.t(f.GREATER_THAN.label),value:f.GREATER_THAN.operator},{label:r.t(f.GREATER_THAN_OR_EQUAL.label),value:f.GREATER_THAN_OR_EQUAL.operator},{label:r.t(f.LESS_THAN.label),value:f.LESS_THAN.operator},{label:r.t(f.LESS_THAN_OR_EQUAL.label),value:f.LESS_THAN_OR_EQUAL.operator},{label:r.t(f.EQUAL.label),value:f.EQUAL.operator},{label:r.t(f.NOT_EQUAL.label),value:f.NOT_EQUAL.operator},{label:r.t(f.BETWEEN.label),value:f.BETWEEN.operator},{label:r.t(f.NOT_BETWEEN.label),value:f.NOT_BETWEEN.operator}]},{options:[{label:r.t(f.CUSTOM.label),value:f.CUSTOM.operator}]}],[e,r])}function xt(r){const e=r.getCurrentLocale();return F.useMemo(()=>f.ALL_CONDITIONS.filter(t=>t.numOfParameters!==2).map(t=>({label:r.t(t.label),value:t.operator})),[e,r])}function Wt(r){const{model:e}=r,t=C.useDependency(c.LocaleService),n=C.useObservable(e.searchString$,"",!0),o=C.useObservable(e.filterItems$,void 0,!0),l=t.t("sheets-filter.panel.filter-only"),i=be(o),s=i.checked>0&&i.unchecked===0,a=i.checked>0&&i.unchecked>0,h=e.treeMapCache,m=F.useCallback(()=>{e.onCheckAllToggled(!s)},[e,s]),p=F.useCallback(v=>{e.setSearchString(v)},[e]);function I(v){let T=[];return v.forEach(O=>{O.checked&&T.push(O.key),O.children&&(T=T.concat(I(O.children)))}),T}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(N.Input,{autoFocus:!0,value:n,placeholder:t.t("sheets-filter.panel.search-placeholder"),onChange:p}),d.jsxs("div",{"data-u-comp":"sheets-filter-panel",className:N.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",N.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-py-0 univer-pl-5 univer-pr-0.5 univer-text-sm",children:[d.jsx(N.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-truncate univer-text-gray-900 dark:!univer-text-white",children:`${t.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(N.Tree,{data:o,defaultExpandAll:!1,valueGroup:I(o),onChange:v=>{e.onFilterCheckToggled(v)},defaultCache:h,itemHeight:28,treeNodeClassName:`
2
2
  univer-pr-2 univer-border-box univer-rounded-md
3
3
  [&:hover_a]:univer-inline-block
4
4
  hover:univer-bg-gray-50 univer-h-full
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@univerjs/sheets-filter-ui",
3
- "version": "0.16.1-insiders.20260311-074e8ca",
3
+ "version": "0.17.0",
4
4
  "private": false,
5
5
  "description": "Univer Sheets Filter UI",
6
6
  "author": "DreamNum <developer@univer.ai>",
@@ -53,14 +53,14 @@
53
53
  },
54
54
  "dependencies": {
55
55
  "@univerjs/icons": "^1.1.1",
56
- "@univerjs/core": "0.16.1-insiders.20260311-074e8ca",
57
- "@univerjs/rpc": "0.16.1-insiders.20260311-074e8ca",
58
- "@univerjs/design": "0.16.1-insiders.20260311-074e8ca",
59
- "@univerjs/engine-render": "0.16.1-insiders.20260311-074e8ca",
60
- "@univerjs/sheets-filter": "0.16.1-insiders.20260311-074e8ca",
61
- "@univerjs/sheets": "0.16.1-insiders.20260311-074e8ca",
62
- "@univerjs/ui": "0.16.1-insiders.20260311-074e8ca",
63
- "@univerjs/sheets-ui": "0.16.1-insiders.20260311-074e8ca"
56
+ "@univerjs/core": "0.17.0",
57
+ "@univerjs/design": "0.17.0",
58
+ "@univerjs/rpc": "0.17.0",
59
+ "@univerjs/engine-render": "0.17.0",
60
+ "@univerjs/sheets": "0.17.0",
61
+ "@univerjs/sheets-filter": "0.17.0",
62
+ "@univerjs/sheets-ui": "0.17.0",
63
+ "@univerjs/ui": "0.17.0"
64
64
  },
65
65
  "devDependencies": {
66
66
  "postcss": "^8.5.8",
@@ -70,8 +70,8 @@
70
70
  "typescript": "^5.9.3",
71
71
  "vite": "^7.3.1",
72
72
  "vitest": "^4.0.18",
73
- "@univerjs-infra/shared": "0.16.1",
74
- "@univerjs/engine-formula": "0.16.1-insiders.20260311-074e8ca"
73
+ "@univerjs-infra/shared": "0.17.0",
74
+ "@univerjs/engine-formula": "0.17.0"
75
75
  },
76
76
  "scripts": {
77
77
  "test": "vitest run",