@univerjs/sheets-filter-ui 0.8.3-nightly.202507021607 → 0.8.3
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 +176 -0
- package/lib/cjs/index.js +2 -2
- package/lib/es/index.js +4 -3
- package/lib/index.css +1 -1
- package/lib/index.js +4 -3
- package/lib/umd/index.js +2 -2
- package/package.json +10 -10
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,7 +1,7 @@
|
|
|
1
|
-
"use strict";var Ze=Object.defineProperty;var ze=(t,e,r)=>e in t?Ze(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var v=(t,e,r)=>ze(t,typeof e!="symbol"?e+"":e,r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("@univerjs/core"),c=require("@univerjs/sheets-filter"),C=require("@univerjs/ui"),U=require("@univerjs/sheets-ui"),O=require("@univerjs/sheets"),S=require("rxjs"),ie=require("@univerjs/engine-render"),ge=require("@univerjs/rpc"),y=require("@univerjs/design"),d=require("react/jsx-runtime"),b=require("react");var N=(t=>(t[t.FIRST=0]="FIRST",t[t.SECOND=1]="SECOND",t))(N||{}),g=(t=>(t.NONE="none",t.STARTS_WITH="startsWith",t.DOES_NOT_START_WITH="doesNotStartWith",t.ENDS_WITH="endsWith",t.DOES_NOT_END_WITH="doesNotEndWith",t.CONTAINS="contains",t.DOES_NOT_CONTAIN="doesNotContain",t.EQUALS="equals",t.NOT_EQUALS="notEquals",t.EMPTY="empty",t.NOT_EMPTY="notEmpty",t.BETWEEN="between",t.NOT_BETWEEN="notBetween",t.CUSTOM="custom",t))(g||{}),p;(t=>{t.NONE={label:"sheets-filter.conditions.none",operator:g.NONE,order:N.SECOND,numOfParameters:0,getDefaultFormParams:()=>{throw new Error("[FilterConditionItems.NONE]: should not have initial form params!")},testMappingParams:i=>i.operator1===g.NONE,mapToFilterColumn:()=>null,testMappingFilterColumn:i=>!i.customFilters&&!i.filters?{}:!1},t.EMPTY={label:"sheets-filter.conditions.empty",operator:g.EMPTY,order:N.SECOND,numOfParameters:0,getDefaultFormParams:()=>{throw new Error("[FilterConditionItems.EMPTY]: should not have initial form params!")},testMappingParams:({operator1:i})=>i===g.EMPTY,mapToFilterColumn:()=>({customFilters:{customFilters:[{val:""}]}}),testMappingFilterColumn:i=>{var 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:g.EMPTY}:!1}},t.NOT_EMPTY={label:"sheets-filter.conditions.not-empty",operator:g.NOT_EMPTY,order:N.SECOND,numOfParameters:0,getDefaultFormParams:()=>{throw new Error("[FilterConditionItems.NOT_EMPTY]: should not have initial form params!")},testMappingParams:({operator1:i})=>i===g.NOT_EMPTY,mapToFilterColumn:()=>({customFilters:{customFilters:[{val:"",operator: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:g.NOT_EMPTY}:!1}},t.TEXT_CONTAINS={label:"sheets-filter.conditions.text-contains",operator:g.CONTAINS,order:N.FIRST,numOfParameters:1,getDefaultFormParams:()=>({operator1:g.CONTAINS,val1:""}),testMappingParams:i=>{const[o]=x(i);return o===g.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],a=o.val.toString();return!o.operator&&a.startsWith("*")&&a.endsWith("*")?{operator1:g.CONTAINS,val1:a.slice(1,-1)}:!1}},t.DOES_NOT_CONTAIN={label:"sheets-filter.conditions.does-not-contain",operator:g.DOES_NOT_CONTAIN,order:N.FIRST,numOfParameters:1,getDefaultFormParams:()=>({operator1:g.DOES_NOT_CONTAIN,val1:""}),mapToFilterColumn:i=>({customFilters:{customFilters:[{val:`*${i.val1}*`,operator:c.CustomFilterOperator.NOT_EQUALS}]}}),testMappingParams:i=>{const[o]=x(i);return o===g.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],a=o.val.toString();return o.operator===c.CustomFilterOperator.NOT_EQUALS&&a.startsWith("*")&&a.endsWith("*")?{operator1:g.DOES_NOT_CONTAIN,val1:a.slice(1,-1)}:!1}},t.STARTS_WITH={label:"sheets-filter.conditions.starts-with",operator:g.STARTS_WITH,order:N.FIRST,numOfParameters:1,getDefaultFormParams:()=>({operator1:g.STARTS_WITH,val1:""}),mapToFilterColumn:i=>({customFilters:{customFilters:[{val:`${i.val1}*`}]}}),testMappingParams:i=>{const[o]=x(i);return o===g.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],a=o.val.toString();return!o.operator&&a.endsWith("*")&&!a.startsWith("*")?{operator1:g.STARTS_WITH,val1:a.slice(0,-1)}:!1}},t.ENDS_WITH={label:"sheets-filter.conditions.ends-with",operator:g.ENDS_WITH,order:N.FIRST,numOfParameters:1,getDefaultFormParams:()=>({operator1:g.ENDS_WITH,val1:""}),mapToFilterColumn:i=>({customFilters:{customFilters:[{val:`*${i.val1}`}]}}),testMappingParams:i=>{const[o]=x(i);return o===g.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],a=o.val.toString();return!o.operator&&a.startsWith("*")&&!a.endsWith("*")?{operator1:g.ENDS_WITH,val1:a.slice(1)}:!1}},t.EQUALS={label:"sheets-filter.conditions.equals",operator:g.EQUALS,order:N.FIRST,numOfParameters:1,getDefaultFormParams:()=>({operator1:g.EQUALS,val1:""}),testMappingParams:i=>{const[o]=x(i);return o===g.EQUALS},mapToFilterColumn:i=>{const{val1:o}=i;return o===""?null:{customFilters:{customFilters:[{val:o}]}}},testMappingFilterColumn:i=>{var o,a,h;return((a=(o=i.filters)==null?void 0:o.filters)==null?void 0:a.length)===1?{operator1:g.EQUALS,val1:""}:((h=i.customFilters)==null?void 0:h.customFilters.length)===1&&!i.customFilters.customFilters[0].operator?{operator1:g.EQUALS,val1:i.customFilters.customFilters[0].val.toString()}:!1}},t.GREATER_THAN={label:"sheets-filter.conditions.greater-than",operator:c.CustomFilterOperator.GREATER_THAN,numOfParameters:1,order:N.FIRST,getDefaultFormParams:()=>({operator1:c.CustomFilterOperator.GREATER_THAN,val1:""}),mapToFilterColumn:i=>({customFilters:{customFilters:[{val:i.val1,operator:c.CustomFilterOperator.GREATER_THAN}]}}),testMappingParams:i=>{const[o]=x(i);return o===c.CustomFilterOperator.GREATER_THAN},testMappingFilterColumn:i=>{var a;if(((a=i.customFilters)==null?void 0:a.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()}}},t.GREATER_THAN_OR_EQUAL={label:"sheets-filter.conditions.greater-than-or-equal",operator:c.CustomFilterOperator.GREATER_THAN_OR_EQUAL,numOfParameters:1,order:N.FIRST,getDefaultFormParams:()=>({operator1:c.CustomFilterOperator.GREATER_THAN_OR_EQUAL,val1:""}),testMappingParams:i=>{const[o]=x(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 a;if(((a=i.customFilters)==null?void 0:a.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()}}},t.LESS_THAN={label:"sheets-filter.conditions.less-than",operator:c.CustomFilterOperator.LESS_THAN,numOfParameters:1,order:N.FIRST,getDefaultFormParams:()=>({operator1:c.CustomFilterOperator.LESS_THAN,val1:""}),testMappingParams:i=>{const[o]=x(i);return o===c.CustomFilterOperator.LESS_THAN},mapToFilterColumn:i=>({customFilters:{customFilters:[{val:i.val1,operator:c.CustomFilterOperator.LESS_THAN}]}}),testMappingFilterColumn:i=>{var a;if(((a=i.customFilters)==null?void 0:a.customFilters.length)!==1)return!1;const o=i.customFilters.customFilters[0];return o.operator!==c.CustomFilterOperator.LESS_THAN?!1:{operator1:c.CustomFilterOperator.LESS_THAN,val1:o.val.toString()}}},t.LESS_THAN_OR_EQUAL={label:"sheets-filter.conditions.less-than-or-equal",operator:c.CustomFilterOperator.LESS_THAN_OR_EQUAL,numOfParameters:1,order:N.FIRST,getDefaultFormParams:()=>({operator1:c.CustomFilterOperator.LESS_THAN_OR_EQUAL,val1:""}),testMappingParams:i=>{const[o]=x(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 a;if(((a=i.customFilters)==null?void 0:a.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()}}},t.EQUAL={label:"sheets-filter.conditions.equal",operator:c.CustomFilterOperator.EQUAL,numOfParameters:1,order:N.FIRST,getDefaultFormParams:()=>({operator1:c.CustomFilterOperator.EQUAL,val1:""}),testMappingParams:i=>{const[o]=x(i);return o===c.CustomFilterOperator.EQUAL},mapToFilterColumn:i=>({customFilters:{customFilters:[{val:i.val1,operator:c.CustomFilterOperator.EQUAL}]}}),testMappingFilterColumn:i=>{var a;if(((a=i.customFilters)==null?void 0:a.customFilters.length)!==1)return!1;const o=i.customFilters.customFilters[0];return o.operator!==c.CustomFilterOperator.EQUAL?!1:{operator1:c.CustomFilterOperator.EQUAL,val1:o.val.toString()}}},t.NOT_EQUAL={label:"sheets-filter.conditions.not-equal",operator:c.CustomFilterOperator.NOT_EQUALS,numOfParameters:1,order:N.FIRST,getDefaultFormParams:()=>({operator1:c.CustomFilterOperator.NOT_EQUALS,val1:""}),testMappingParams:i=>{const[o]=x(i);return o===c.CustomFilterOperator.NOT_EQUALS},mapToFilterColumn:i=>({customFilters:{customFilters:[{val:i.val1,operator:c.CustomFilterOperator.NOT_EQUALS}]}}),testMappingFilterColumn:i=>{var a;if(((a=i.customFilters)==null?void 0:a.customFilters.length)!==1)return!1;const o=i.customFilters.customFilters[0];return o.operator!==c.CustomFilterOperator.NOT_EQUALS?!1:{operator1:c.CustomFilterOperator.NOT_EQUALS,val1:o.val.toString()}}},t.BETWEEN={label:"sheets-filter.conditions.between",operator:g.BETWEEN,order:N.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:a,operator2:h}=i;if(!o)return!1;const m=[a,h];return m.includes(c.CustomFilterOperator.GREATER_THAN_OR_EQUAL)&&m.includes(c.CustomFilterOperator.LESS_THAN_OR_EQUAL)},mapToFilterColumn:i=>{const{val1:o,val2:a,operator1:h}=i,m=h===c.CustomFilterOperator.GREATER_THAN_OR_EQUAL;return{customFilters:{and:u.BooleanNumber.TRUE,customFilters:[{val:m?o:a,operator:c.CustomFilterOperator.GREATER_THAN_OR_EQUAL},{val:m?a:o,operator:c.CustomFilterOperator.LESS_THAN_OR_EQUAL}]}}},testMappingFilterColumn:i=>{var h;if(((h=i.customFilters)==null?void 0:h.customFilters.length)!==2)return!1;const[o,a]=i.customFilters.customFilters;return o.operator===c.CustomFilterOperator.GREATER_THAN_OR_EQUAL&&a.operator===c.CustomFilterOperator.LESS_THAN_OR_EQUAL&&i.customFilters.and?{and:!0,operator1:c.CustomFilterOperator.GREATER_THAN_OR_EQUAL,val1:o.val.toString(),operator2:c.CustomFilterOperator.LESS_THAN_OR_EQUAL,val2:a.val.toString()}:a.operator===c.CustomFilterOperator.GREATER_THAN_OR_EQUAL&&o.operator===c.CustomFilterOperator.LESS_THAN_OR_EQUAL&&i.customFilters.and?{and:!0,operator1:c.CustomFilterOperator.GREATER_THAN_OR_EQUAL,val1:a.val.toString(),operator2:c.CustomFilterOperator.LESS_THAN_OR_EQUAL,val2:o.val.toLocaleString()}:!1}},t.NOT_BETWEEN={label:"sheets-filter.conditions.not-between",operator:g.NOT_BETWEEN,order:N.SECOND,numOfParameters:2,getDefaultFormParams:()=>({operator1:c.CustomFilterOperator.LESS_THAN,val1:"",operator2:c.CustomFilterOperator.GREATER_THAN,val2:""}),testMappingParams:i=>{const{and:o,operator1:a,operator2:h}=i;if(o)return!1;const m=[a,h];return m.includes(c.CustomFilterOperator.GREATER_THAN)&&m.includes(c.CustomFilterOperator.LESS_THAN)},mapToFilterColumn:i=>{const{val1:o,val2:a,operator1:h}=i,m=h===c.CustomFilterOperator.GREATER_THAN;return{customFilters:{customFilters:[{val:m?o:a,operator:c.CustomFilterOperator.GREATER_THAN},{val:m?a:o,operator:c.CustomFilterOperator.LESS_THAN}]}}},testMappingFilterColumn:i=>{var h;if(((h=i.customFilters)==null?void 0:h.customFilters.length)!==2)return!1;const[o,a]=i.customFilters.customFilters;return o.operator===c.CustomFilterOperator.LESS_THAN&&a.operator===c.CustomFilterOperator.GREATER_THAN&&!i.customFilters.and?{operator1:c.CustomFilterOperator.LESS_THAN,val1:o.val.toString(),operator2:c.CustomFilterOperator.GREATER_THAN,val2:a.val.toString()}:a.operator===c.CustomFilterOperator.LESS_THAN&&o.operator===c.CustomFilterOperator.GREATER_THAN&&!i.customFilters.and?{operator1:c.CustomFilterOperator.GREATER_THAN,val1:a.val.toString(),operator2:c.CustomFilterOperator.LESS_THAN,val2:o.val.toLocaleString()}:!1}},t.CUSTOM={label:"sheets-filter.conditions.custom",operator:g.CUSTOM,order:N.SECOND,numOfParameters:2,getDefaultFormParams:()=>({operator1:g.NONE,val1:"",operator2:g.NONE,val2:""}),testMappingParams:()=>!0,mapToFilterColumn:i=>{const{and:o,val1:a,val2:h,operator1:m,operator2:f}=i;function T(M,A){for(const k of t.ALL_CONDITIONS)if(k.operator===M)return k.mapToFilterColumn({val1:A,operator1:M})}const _=!m||m===t.NONE.operator,E=!f||f===t.NONE.operator;if(_&&E)return t.NONE.mapToFilterColumn({});if(_)return T(f,h);if(E)return T(m,a);const F=T(m,a),R=T(f,h),I={customFilters:[F.customFilters.customFilters[0],R.customFilters.customFilters[0]]};return o&&(I.and=u.BooleanNumber.TRUE),{customFilters:I}},testMappingFilterColumn:i=>{var h;if(((h=i.customFilters)==null?void 0:h.customFilters.length)!==2)return!1;const o=i.customFilters.customFilters.map(m=>l({customFilters:{customFilters:[m]}})),a={operator1:o[0][0].operator,val1:o[0][1].val1,operator2:o[1][0].operator,val2:o[1][1].val1};return i.customFilters.and&&(a.and=!0),a}},t.ALL_CONDITIONS=[t.NONE,t.EMPTY,t.NOT_EMPTY,t.TEXT_CONTAINS,t.DOES_NOT_CONTAIN,t.STARTS_WITH,t.ENDS_WITH,t.EQUALS,t.GREATER_THAN,t.GREATER_THAN_OR_EQUAL,t.LESS_THAN,t.LESS_THAN_OR_EQUAL,t.EQUAL,t.NOT_EQUAL,t.BETWEEN,t.NOT_BETWEEN,t.CUSTOM];function e(i){const o=t.ALL_CONDITIONS.find(a=>a.operator===i);if(!o)throw new Error(`[SheetsFilter]: no condition item found for operator: ${i}`);return o}t.getItemByOperator=e;function r(i,o){for(const a of t.ALL_CONDITIONS.filter(h=>h.numOfParameters===o))if(a.numOfParameters!==0&&a.testMappingParams(i))return a;for(const a of t.ALL_CONDITIONS)if(a.testMappingParams(i))return a;throw new Error("[SheetsFilter]: no condition item can be mapped from the filter map params!")}t.testMappingParams=r;function s(i){const o=t.ALL_CONDITIONS.find(a=>a.operator===i);return(o==null?void 0:o.numOfParameters)===0?{operator1:o.operator}:o.getDefaultFormParams()}t.getInitialFormParams=s;function n(i,o){return i.mapToFilterColumn(o)}t.mapToFilterColumn=n;function l(i){if(!i)return[t.NONE,{}];for(const o of t.ALL_CONDITIONS){const a=o.testMappingFilterColumn(i);if(a)return[o,a]}return[t.NONE,{}]}t.testMappingFilterColumn=l})(p||(p={}));function x(t){const{operator1:e,operator2:r,val1:s,val2:n}=t;if(e&&r)throw new Error("Both operator1 and operator2 are set!");if(!e&&!r)throw new Error("Neither operator1 and operator2 and both not set!");return e?[e,s]:[r,n]}function Oe(t){const e=[],r=[];let s=0,n=0;function l(i){i.leaf&&(i.checked?(e.push(i),s+=i.count):(r.push(i),n+=i.count)),i.children&&i.children.forEach(l)}return t.forEach(l),{checkedItems:e,uncheckedItems:r,checked:s,unchecked:n}}var Je=Object.getOwnPropertyDescriptor,et=(t,e,r,s)=>{for(var n=s>1?void 0:s?Je(e,r):e,l=t.length-1,i;l>=0;l--)(i=t[l])&&(n=i(n)||n);return n},Fe=(t,e)=>(r,s)=>e(r,s,t);const Pe="sheets-filter.generate-filter-values.service",he=u.createIdentifier(Pe),tt=["yyyy-mm-dd","yyyy-mm-dd;@","yyyy/mm/dd;@","yyyy/mm/dd hh:mm","yyyy-m-d am/pm h:mm","yyyy-MM-dd","yyyy/MM/dd","yyyy/mm/dd",'yyyy"年"MM"月"dd"日"',"MM-dd",'M"月"d"日"',"MM-dd A/P hh:mm"];let Ie=class extends u.Disposable{constructor(t,e,r){super(),this._localeService=t,this._univerInstanceService=e,this._logService=r}async getFilterValues(t){var m;const{unitId:e,subUnitId:r,filteredOutRowsByOtherColumns:s,filters:n,blankChecked:l,iterateRange:i,alreadyChecked:o}=t,a=this._univerInstanceService.getUnit(e),h=(m=this._univerInstanceService.getUnit(e))==null?void 0:m.getSheetBySheetId(r);return!a||!h?[]:(this._logService.debug("[SheetsGenerateFilterValuesService]","getFilterValues for",{unitId:e,subUnitId:r}),De(n,this._localeService,i,h,new Set(s),new Set(o.map(String)),l,a.getStyles()))}};Ie=et([Fe(0,u.Inject(u.LocaleService)),Fe(1,u.IUniverInstanceService),Fe(2,u.ILogService)],Ie);function De(t,e,r,s,n,l,i,o){var F,R,I,M,A,k,D,oe,ae;const a=new Map,h=new Map,m="yyyy-mm-dd",f=new Set(tt),T="empty";let _=0;for(const w of s.iterateByColumn(r,!1,!1)){const{row:qe,rowSpan:Me=1}=w;let K=0;for(;K<Me;){const Ke=qe+K;if(n.has(Ke)){K++;continue}const G=w!=null&&w.value?u.extractPureTextFromCell(w.value):"";if(!G){_+=1,K+=Me;continue}const le=(F=w.value)!=null&&F.v&&!w.value.p?(M=(I=o.get((R=w.value)==null?void 0:R.s))==null?void 0:I.n)==null?void 0:M.pattern:"",Xe=le&&u.numfmt.getFormatInfo(le).isDate;if(le&&Xe&&f.has(le)){const W=(A=s.getCellRaw(w.row,w.col))==null?void 0:A.v;if(!W){K++;continue}const X=u.numfmt.format(m,W),[P,H,te]=X.split("-").map(Number);let Y=a.get(`${P}`);Y||(Y={title:`${P}`,key:`${P}`,children:[],count:0,leaf:!1,checked:!1},a.set(`${P}`,Y),h.set(`${P}`,[`${P}`]));let j=(k=Y.children)==null?void 0:k.find(Ce=>Ce.key===`${P}-${H}`);j||(j={title:e.t(`sheets-filter.date.${H}`),key:`${P}-${H}`,children:[],count:0,leaf:!1,checked:!1},(D=Y.children)==null||D.push(j),h.set(`${P}-${H}`,[`${P}`,`${P}-${H}`]));const Se=(oe=j==null?void 0:j.children)==null?void 0:oe.find(Ce=>Ce.key===`${P}-${H}-${te}`);Se?(Se.originValues.add(G),Se.count++,j.count++,Y.count++):((ae=j.children)==null||ae.push({title:`${te}`,key:`${P}-${H}-${te}`,count:1,originValues:new Set([G]),leaf:!0,checked:l.size?l.has(G):!i}),j.count++,Y.count++,h.set(`${P}-${H}-${te}`,[`${P}`,`${P}-${H}`,`${P}-${H}-${te}`]))}else{const W=G;let X=a.get(W);X?X.count++:(X={title:G,leaf:!0,checked:l.size?l.has(G):!i,key:W,count:1},a.set(W,X),h.set(W,[W]))}K++}}const E=t?i:!0;if(_>0){const w={title:e.t("sheets-filter.panel.empty"),count:_,leaf:!0,checked:E,key:T};a.set("empty",w),h.set("empty",[T])}return{filterTreeItems:rt(Array.from(a.values())),filterTreeMapCache:h}}function rt(t){return Array.from(t).sort((e,r)=>e.children&&!r.children?-1:!e.children&&r.children?1:it(e.title,r.title)).map(e=>(e.children&&e.children.sort((r,s)=>{const n=Number.parseInt(r.key.split("-")[1],10),l=Number.parseInt(s.key.split("-")[1],10);return n-l}).forEach(r=>{r.children&&r.children.sort((s,n)=>{const l=Number.parseInt(s.key.split("-")[2],10),i=Number.parseInt(n.key.split("-")[2],10);return l-i})}),e))}const we=t=>!Number.isNaN(Number(t))&&!Number.isNaN(Number.parseFloat(t));function it(t,e){const r=we(t),s=we(e);return r&&s?Number.parseFloat(t)-Number.parseFloat(e):r&&!s?-1:!r&&s?1:t.localeCompare(e)}function Ne(t,e){for(const r of t){if(r.key===e)return r;if(r.children){const s=Ne(r.children,e);if(s)return s}}return null}function He(t){return t.leaf?t.checked:t.children?t.children.every(e=>He(e)):!0}function re(t,e){t.leaf&&(e!==void 0?t.checked=e:t.checked=!t.checked),t.children&&t.children.forEach(r=>re(r,e))}function je(t,e){const r=[];return t.forEach(s=>{const n=s.originValues?e.some(o=>Array.from(s.originValues).some(a=>a.toLowerCase().includes(o.toLowerCase()))):!1,l=!n&&e.some(o=>s.title.toLowerCase().includes(o.toLowerCase()));if(n||l)r.push({...s});else if(s.children){const o=je(s.children,e);if(o.length>0){const a=o.reduce((h,m)=>h+m.count,0);r.push({...s,count:a,children:o})}}}),r}var st=Object.getOwnPropertyDescriptor,be=(t,e,r,s)=>{for(var n=s>1?void 0:s?st(e,r):e,l=t.length-1,i;l>=0;l--)(i=t[l])&&(n=i(n)||n);return n},me=(t,e)=>(r,s)=>e(r,s,t),pe=(t=>(t[t.VALUES=0]="VALUES",t[t.CONDITIONS=1]="CONDITIONS",t))(pe||{});u.createIdentifier("sheets-filter-ui.sheets-filter-panel.service");let Q=class extends u.Disposable{constructor(e,r){super();v(this,"_filterBy$",new S.BehaviorSubject(0));v(this,"filterBy$",this._filterBy$.asObservable());v(this,"_filterByModel$",new S.ReplaySubject(1));v(this,"filterByModel$",this._filterByModel$.asObservable());v(this,"_filterByModel",null);v(this,"_hasCriteria$",new S.BehaviorSubject(!1));v(this,"hasCriteria$",this._hasCriteria$.asObservable());v(this,"_filterModel",null);v(this,"_col$",new S.BehaviorSubject(-1));v(this,"col$",this._col$.asObservable());v(this,"_filterHeaderListener",null);this._injector=e,this._refRangeService=r}get filterBy(){return this._filterBy$.getValue()}get filterByModel(){return this._filterByModel}set filterByModel(e){this._filterByModel=e,this._filterByModel$.next(e)}get filterModel(){return this._filterModel}get col(){return this._col$.getValue()}dispose(){this._filterBy$.complete(),this._filterByModel$.complete(),this._hasCriteria$.complete()}setupCol(e,r){this.terminate(),this._filterModel=e,this._col$.next(r);const s=e.getFilterColumn(r);if(s){const n=s.getColumnData();if(n.customFilters){this._hasCriteria$.next(!0),this._setupByConditions(e,r);return}if(n.filters){this._hasCriteria$.next(!0),this._setupByValues(e,r);return}this._hasCriteria$.next(!1),this._setupByValues(e,r);return}this._hasCriteria$.next(!1),this._setupByValues(e,r)}changeFilterBy(e){return!this._filterModel||this.col===-1?!1:(e===0?this._setupByValues(this._filterModel,this.col):this._setupByConditions(this._filterModel,this.col),!0)}terminate(){return this._filterModel=null,this._col$.next(-1),this._disposeFilterHeaderChangeListener(),!0}_disposeFilterHeaderChangeListener(){var e;(e=this._filterHeaderListener)==null||e.dispose(),this._filterHeaderListener=null}_listenToFilterHeaderChange(e,r){this._disposeFilterHeaderChangeListener();const s=e.unitId,n=e.subUnitId,l=e.getRange(),i={startColumn:r,startRow:l.startRow,endRow:l.startRow,endColumn:r};this._filterHeaderListener=this._refRangeService.watchRange(s,n,i,(o,a)=>{if(!a)this.terminate();else{const h=a.startColumn-o.startColumn;h!==0&&this._filterByModel.deltaCol(h)}})}async _setupByValues(e,r){this._disposePreviousModel();const s=e.getRange();if(s.startRow===s.endRow)return!1;const n=await fe.fromFilterColumn(this._injector,e,r);return this.filterByModel=n,this._filterBy$.next(0),this._listenToFilterHeaderChange(e,r),!0}_setupByConditions(e,r){this._disposePreviousModel();const s=e.getRange();if(s.startRow===s.endRow)return!1;const n=de.fromFilterColumn(this._injector,e,r,e.getFilterColumn(r));return this.filterByModel=n,this._filterBy$.next(1),this._listenToFilterHeaderChange(e,r),!0}_disposePreviousModel(){var e;(e=this._filterByModel)==null||e.dispose(),this.filterByModel=null}};Q=be([me(0,u.Inject(u.Injector)),me(1,u.Inject(O.RefRangeService))],Q);let de=class extends u.Disposable{constructor(e,r,s,n,l){super();v(this,"canApply$",S.of(!0));v(this,"_conditionItem$");v(this,"conditionItem$");v(this,"_filterConditionFormParams$");v(this,"filterConditionFormParams$");this._filterModel=e,this.col=r,this._commandService=l,this._conditionItem$=new S.BehaviorSubject(s),this.conditionItem$=this._conditionItem$.asObservable(),this._filterConditionFormParams$=new S.BehaviorSubject(n),this.filterConditionFormParams$=this._filterConditionFormParams$.asObservable()}static fromFilterColumn(e,r,s,n){const[l,i]=p.testMappingFilterColumn(n==null?void 0:n.getColumnData());return e.createInstance(de,r,s,l,i)}get conditionItem(){return this._conditionItem$.getValue()}get filterConditionFormParams(){return this._filterConditionFormParams$.getValue()}dispose(){super.dispose(),this._conditionItem$.complete(),this._filterConditionFormParams$.complete()}deltaCol(e){this.col+=e}clear(){return this._disposed?Promise.resolve(!1):this._commandService.executeCommand(c.SetSheetsFilterCriteriaCommand.id,{unitId:this._filterModel.unitId,subUnitId:this._filterModel.subUnitId,col:this.col,criteria:null})}async apply(){if(this._disposed)return!1;const e=p.mapToFilterColumn(this.conditionItem,this.filterConditionFormParams);return this._commandService.executeCommand(c.SetSheetsFilterCriteriaCommand.id,{unitId:this._filterModel.unitId,subUnitId:this._filterModel.subUnitId,col:this.col,criteria:e})}onPrimaryConditionChange(e){const r=p.ALL_CONDITIONS.find(s=>s.operator===e);if(!r)throw new Error(`[ByConditionsModel]: condition item not found for operator: ${e}!`);this._conditionItem$.next(r),this._filterConditionFormParams$.next(p.getInitialFormParams(e))}onConditionFormChange(e){const r={...this.filterConditionFormParams,...e};if(r.and!==!0&&delete r.and,typeof e.and<"u"||typeof e.operator1<"u"||typeof e.operator2<"u"){const s=p.testMappingParams(r,this.conditionItem.numOfParameters);this._conditionItem$.next(s)}this._filterConditionFormParams$.next(r)}};de=be([me(4,u.ICommandService)],de);let fe=class extends u.Disposable{constructor(e,r,s,n,l){super();v(this,"_rawFilterItems$");v(this,"rawFilterItems$");v(this,"filterItems$");v(this,"_filterItems",[]);v(this,"_treeMapCache");v(this,"canApply$");v(this,"_manuallyUpdateFilterItems$");v(this,"_searchString$");v(this,"searchString$");this._filterModel=e,this.col=r,this._commandService=l,this._treeMapCache=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(m=>!!m);return je(o,h)})),this._manuallyUpdateFilterItems$).pipe(S.shareReplay(1)),this.canApply$=this.filterItems$.pipe(S.map(i=>Oe(i).checked>0)),this.disposeWithMe(this.filterItems$.subscribe(i=>this._filterItems=i))}static async fromFilterColumn(e,r,s){var k;const n=e.get(u.IUniverInstanceService),l=e.get(u.LocaleService),i=e.get(he,u.Quantity.OPTIONAL),{unitId:o,subUnitId:a}=r,h=n.getUniverSheetInstance(o);if(!h)throw new Error(`[ByValuesModel]: Workbook not found for filter model with unitId: ${o}!`);const m=h==null?void 0:h.getSheetBySheetId(a);if(!m)throw new Error(`[ByValuesModel]: Worksheet not found for filter model with unitId: ${o} and subUnitId: ${a}!`);const f=r.getRange(),T=s,_=(k=r.getFilterColumn(s))==null?void 0:k.getColumnData().filters,E=new Set(_==null?void 0:_.filters),F=!!(_&&_.blank),R=r.getFilteredOutRowsExceptCol(s),I={...f,startRow:f.startRow+1,startColumn:T,endColumn:T};let M,A;if(i){const D=await i.getFilterValues({unitId:o,subUnitId:a,filteredOutRowsByOtherColumns:Array.from(R),filters:!!_,blankChecked:F,iterateRange:I,alreadyChecked:Array.from(E)});M=D.filterTreeItems,A=D.filterTreeMapCache}else{const D=De(!!_,l,I,m,R,E,F,h.getStyles());M=D.filterTreeItems,A=D.filterTreeMapCache}return e.createInstance(fe,r,s,M,A)}get rawFilterItems(){return this._rawFilterItems$.getValue()}get filterItems(){return this._filterItems}get treeMapCache(){return this._treeMapCache}dispose(){this._rawFilterItems$.complete(),this._searchString$.complete()}deltaCol(e){this.col+=e}setSearchString(e){this._searchString$.next(e)}onCheckAllToggled(e){const r=u.Tools.deepClone(this._filterItems);r.forEach(s=>re(s,e)),this._manuallyUpdateFilterItems(r)}onFilterCheckToggled(e){const r=u.Tools.deepClone(this._filterItems),s=Ne(r,e.key);if(!s)return;const n=He(s);re(s,!n),this._manuallyUpdateFilterItems(r)}onFilterOnly(e){const r=u.Tools.deepClone(this._filterItems);r.forEach(s=>re(s,!1)),e.forEach(s=>{const n=Ne(r,s);n&&re(n,!0)}),this._manuallyUpdateFilterItems(r)}_manuallyUpdateFilterItems(e){this._manuallyUpdateFilterItems$.next(e)}clear(){return this._disposed?Promise.resolve(!1):this._commandService.executeCommand(c.SetSheetsFilterCriteriaCommand.id,{unitId:this._filterModel.unitId,subUnitId:this._filterModel.subUnitId,col:this.col,criteria:null})}async apply(){if(this._disposed)return!1;const e=Oe(this._filterItems),{checked:r,checkedItems:s}=e,n=this.rawFilterItems;let l=0;for(const h of n)l+=h.count;const i=r===0,o=e.checked===l,a={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});{a.filters={};const h=s.filter(f=>f.key!=="empty");h.length>0&&(a.filters={filters:h.flatMap(f=>f.originValues?Array.from(f.originValues):[f.title])}),h.length!==s.length&&(a.filters.blank=!0)}return this._commandService.executeCommand(c.SetSheetsFilterCriteriaCommand.id,{unitId:this._filterModel.unitId,subUnitId:this._filterModel.subUnitId,col:this.col,criteria:a})}};fe=be([me(4,u.ICommandService)],fe);const J="FILTER_PANEL_OPENED",se={id:"sheet.operation.open-filter-panel",type:u.CommandType.OPERATION,handler:(t,e)=>{const r=t.get(u.IContextService),s=t.get(c.SheetsFilterService),n=t.get(Q);t.get(u.ICommandService).syncExecuteCommand(U.SetCellEditVisibleOperation.id,{visible:!1});const{unitId:i,subUnitId:o,col:a}=e,h=s.getFilterModel(i,o);return h?(n.setupCol(h,a),r.getContextValue(J)||r.setContextValue(J,!0),!0):!1}},z={id:"sheet.operation.close-filter-panel",type:u.CommandType.OPERATION,handler:t=>{const e=t.get(u.IContextService),r=t.get(Q),s=t.get(C.ILayoutService,u.Quantity.OPTIONAL);return e.getContextValue(J)?(e.setContextValue(J,!1),s==null||s.focus(),r.terminate()):!1}},Ae={id:"sheet.operation.apply-filter",type:u.CommandType.OPERATION,handler:(t,e)=>{const{filterBy:r}=e;return t.get(Q).changeFilterBy(r)}},Be="sheets-filter-ui.config",_e={};var nt=Object.getOwnPropertyDescriptor,ot=(t,e,r,s)=>{for(var n=s>1?void 0:s?nt(e,r):e,l=t.length-1,i;l>=0;l--)(i=t[l])&&(n=i(n)||n);return n},Z=(t,e)=>(r,s)=>e(r,s,t);let ee=class extends u.Disposable{constructor(t,e,r,s,n,l){super(),this._sheetsFilterService=t,this._localeService=e,this._commandService=r,this._sheetPermissionCheckPermission=s,this._injector=n,this._sheetsSelectionService=l,this._commandExecutedListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.beforeCommandExecuted(t=>{var e,r,s;if(t.id===c.SmartToggleSheetsFilterCommand.id){const n=this._injector.get(u.IUniverInstanceService),l=O.getSheetCommandTarget(n);if(!l)return;const{unitId:i,subUnitId:o,worksheet:a}=l,h=(e=this._sheetsFilterService.getFilterModel(i,o))==null?void 0:e.getRange();let m;if(h)m=this._sheetPermissionCheckPermission.permissionCheckWithRanges({rangeTypes:[O.RangeProtectionPermissionViewPoint],worksheetTypes:[O.WorksheetFilterPermission,O.WorksheetViewPermission]},[h]);else{const f=(r=this._sheetsSelectionService.getCurrentLastSelection())==null?void 0:r.range;if(f){let T={...f};T=f.startColumn===f.endColumn&&f.startRow===f.endRow?O.expandToContinuousRange(T,{left:!0,right:!0,up:!0,down:!0},a):T,m=this._sheetPermissionCheckPermission.permissionCheckWithRanges({rangeTypes:[O.RangeProtectionPermissionViewPoint],worksheetTypes:[O.WorksheetViewPermission,O.WorksheetFilterPermission]},[T],i,o)}else m=this._sheetPermissionCheckPermission.permissionCheckWithoutRange({rangeTypes:[O.RangeProtectionPermissionViewPoint],worksheetTypes:[O.WorksheetViewPermission,O.WorksheetFilterPermission]})}m||this._sheetPermissionCheckPermission.blockExecuteWithoutPermission(this._localeService.t("permission.dialog.filterErr"))}if(t.id===se.id){const n=t.params,{unitId:l,subUnitId:i}=n,o=(s=this._sheetsFilterService.getFilterModel(l,i))==null?void 0:s.getRange(),a=u.Tools.deepClone(o);a&&(a.startColumn=n.col,a.endColumn=n.col,this._sheetPermissionCheckPermission.permissionCheckWithRanges({rangeTypes:[O.RangeProtectionPermissionViewPoint],worksheetTypes:[O.WorksheetFilterPermission,O.WorksheetViewPermission]},[a])||this._sheetPermissionCheckPermission.blockExecuteWithoutPermission(this._localeService.t("permission.dialog.filterErr")))}}))}};ee=ot([Z(0,u.Inject(c.SheetsFilterService)),Z(1,u.Inject(u.LocaleService)),Z(2,u.ICommandService),Z(3,u.Inject(O.SheetPermissionCheckController)),Z(4,u.Inject(u.Injector)),Z(5,u.Inject(O.SheetsSelectionsService))],ee);const V=16,at=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 Le{static drawNoCriteria(e,r,s,n){e.save(),ie.Rect.drawWith(e,{radius:2,width:V,height:V,fill:n}),e.lineCap="square",e.strokeStyle=s,e.scale(r/V,r/V),e.beginPath(),e.lineWidth=1,e.lineCap="round",e.moveTo(3,4),e.lineTo(13,4),e.moveTo(4.5,8),e.lineTo(11.5,8),e.moveTo(6,12),e.lineTo(10,12),e.stroke(),e.restore()}static drawHasCriteria(e,r,s,n){e.save(),ie.Rect.drawWith(e,{radius:2,width:V,height:V,fill:n}),e.scale(r/V,r/V),e.fillStyle=s,e.fill(at),e.restore()}}var lt=Object.getOwnPropertyDescriptor,ct=(t,e,r,s)=>{for(var n=s>1?void 0:s?lt(e,r):e,l=t.length-1,i;l>=0;l--)(i=t[l])&&(n=i(n)||n);return n},Te=(t,e)=>(r,s)=>e(r,s,t);const B=16,ce=1;let ye=class extends ie.Shape{constructor(e,r,s,n,l){super(e,r);v(this,"_cellWidth",0);v(this,"_cellHeight",0);v(this,"_filterParams");v(this,"_hovered",!1);this._contextService=s,this._commandService=n,this._themeService=l,this.setShapeProps(r),this.onPointerDown$.subscribeEvent(i=>this.onPointerDown(i)),this.onPointerEnter$.subscribeEvent(()=>this.onPointerEnter()),this.onPointerLeave$.subscribeEvent(()=>this.onPointerLeave())}setShapeProps(e){typeof e.cellHeight<"u"&&(this._cellHeight=e.cellHeight),typeof e.cellWidth<"u"&&(this._cellWidth=e.cellWidth),typeof e.filterParams<"u"&&(this._filterParams=e.filterParams),this.transformByState({width:e.width,height:e.height})}_draw(e){const r=this._cellHeight,s=this._cellWidth,n=B-s,l=B-r;e.save();const i=new Path2D;i.rect(n,l,s,r),e.clip(i);const{hasCriteria:o}=this._filterParams,a=this._themeService.getColorFromTheme("primary.600"),h=this._hovered?this._themeService.getColorFromTheme("gray.50"):"rgba(255, 255, 255, 1.0)";o?Le.drawHasCriteria(e,B,a,h):Le.drawNoCriteria(e,B,a,h),e.restore()}onPointerDown(e){if(e.button===2)return;const{col:r,unitId:s,subUnitId:n}=this._filterParams;this._contextService.getContextValue(J)||!this._commandService.hasCommand(se.id)||setTimeout(()=>{this._commandService.executeCommand(se.id,{unitId:s,subUnitId:n,col:r})},200)}onPointerEnter(){this._hovered=!0,this.makeDirty(!0)}onPointerLeave(){this._hovered=!1,this.makeDirty(!0)}};ye=ct([Te(2,u.IContextService),Te(3,u.ICommandService),Te(4,u.Inject(u.ThemeService))],ye);var ut=Object.getOwnPropertyDescriptor,ht=(t,e,r,s)=>{for(var n=s>1?void 0:s?ut(e,r):e,l=t.length-1,i;l>=0;l--)(i=t[l])&&(n=i(n)||n);return n},q=(t,e)=>(r,s)=>e(r,s,t);const mt=1e3,pt=5e3;let Re=class extends u.RxDisposable{constructor(e,r,s,n,l,i,o,a){super();v(this,"_filterRangeShape",null);v(this,"_buttonRenderDisposable",null);v(this,"_filterButtonShapes",[]);this._context=e,this._injector=r,this._sheetSkeletonManagerService=s,this._sheetsFilterService=n,this._themeService=l,this._sheetInterceptorService=i,this._commandService=o,this._selectionRenderService=a,this._initRenderer()}dispose(){super.dispose(),this._disposeRendering()}_initRenderer(){this._sheetSkeletonManagerService.currentSkeleton$.pipe(S.switchMap(e=>{var o,a;if(!e)return S.of(null);const{unit:r,unitId:s}=this._context,n=((o=r.getActiveSheet())==null?void 0:o.getSheetId())||"",l=(a=this._sheetsFilterService.getFilterModel(s,n))!=null?a:void 0,i=()=>({unitId:s,worksheetId:n,filterModel:l,range:l==null?void 0:l.getRange(),skeleton:e.skeleton});return u.fromCallback(this._commandService.onCommandExecuted.bind(this._commandService)).pipe(S.filter(([h])=>{var m;return h.type===u.CommandType.MUTATION&&((m=h.params)==null?void 0:m.unitId)===r.getUnitId()&&(c.FILTER_MUTATIONS.has(h.id)||h.id===O.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,r){const{scene:s}=this._context,{rowHeaderWidth:n,columnHeaderHeight:l}=r,i=this._filterRangeShape=new U.SelectionControl(s,mt,this._themeService,{rowHeaderWidth:n,columnHeaderHeight:l,enableAutoFill:!1,highlightHeader:!1}),o={range:e,primary:null,style:{fill:"rgba(0, 0, 0, 0.0)"}},a=U.attachSelectionWithCoord(o,r);i.updateRangeBySelectionWithCoord(a),i.setEvent(!1),s.makeDirty(!0)}_renderButtons(e){const{range:r,filterModel:s,unitId:n,skeleton:l,worksheetId:i}=e,{scene:o}=this._context;this._interceptCellContent(n,i,e.range);const{startColumn:a,endColumn:h,startRow:m}=r;for(let f=a;f<=h;f++){const T=`sheets-filter-button-${f}`,_=U.getCoordByCell(m,f,o,l),{startX:E,startY:F,endX:R,endY:I}=_,M=R-E,A=I-F;if(A<=ce||M<=ce)continue;const k=!!s.getFilterColumn(f),D=R-B-ce,oe=I-B-ce,ae={left:D,top:oe,height:B,width:B,zIndex:pt,cellHeight:A,cellWidth:M,filterParams:{unitId:n,subUnitId:i,col:f,hasCriteria:k}},w=this._injector.createInstance(ye,T,ae);this._filterButtonShapes.push(w)}o.addObjects(this._filterButtonShapes),o.makeDirty()}_interceptCellContent(e,r,s){const{startRow:n,startColumn:l,endColumn:i}=s;this._buttonRenderDisposable=this._sheetInterceptorService.intercept(O.INTERCEPTOR_POINT.CELL_CONTENT,{effect:u.InterceptorEffectEnum.Style,handler:(o,a,h)=>{const{row:m,col:f,unitId:T,subUnitId:_}=a;return T!==e||_!==r||m!==n||f<l||f>i||((!o||o===a.rawData)&&(o={...a.rawData}),o.fontRenderExtension={...o==null?void 0:o.fontRenderExtension,rightOffset:B}),h(o)},priority:10})}_disposeRendering(){var e,r;(e=this._filterRangeShape)==null||e.dispose(),this._filterButtonShapes.forEach(s=>s.dispose()),(r=this._buttonRenderDisposable)==null||r.dispose(),this._filterRangeShape=null,this._buttonRenderDisposable=null,this._filterButtonShapes=[]}};Re=ht([q(1,u.Inject(u.Injector)),q(2,u.Inject(U.SheetSkeletonManagerService)),q(3,u.Inject(c.SheetsFilterService)),q(4,u.Inject(u.ThemeService)),q(5,u.Inject(O.SheetInterceptorService)),q(6,u.ICommandService),q(7,U.ISheetSelectionRenderService)],Re);var dt=Object.getOwnPropertyDescriptor,ft=(t,e,r,s)=>{for(var n=s>1?void 0:s?dt(e,r):e,l=t.length-1,i;l>=0;l--)(i=t[l])&&(n=i(n)||n);return n},Ue=(t,e)=>(r,s)=>e(r,s,t);let ne=class extends u.RxDisposable{constructor(t,e){super(),this._renderManagerService=t,this._sheetsRenderService=e,[c.SetSheetsFilterRangeMutation,c.SetSheetsFilterCriteriaMutation,c.RemoveSheetsFilterMutation,c.ReCalcSheetsFilterMutation].forEach(r=>this.disposeWithMe(this._sheetsRenderService.registerSkeletonChangingMutations(r.id))),this.disposeWithMe(this._renderManagerService.registerRenderModule(u.UniverInstanceType.UNIVER_SHEET,[Re]))}};ne=ft([Ue(0,ie.IRenderManagerService),Ue(1,u.Inject(U.SheetsRenderService))],ne);var _t=Object.defineProperty,vt=Object.getOwnPropertyDescriptor,gt=(t,e,r)=>e in t?_t(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,St=(t,e,r,s)=>{for(var n=s>1?void 0:s?vt(e,r):e,l=t.length-1,i;l>=0;l--)(i=t[l])&&(n=i(n)||n);return n},$e=(t,e)=>(r,s)=>e(r,s,t),We=(t,e,r)=>gt(t,typeof e!="symbol"?e+"":e,r);const Ct="SHEET_FILTER_UI_PLUGIN";exports.UniverSheetsFilterMobileUIPlugin=class extends u.Plugin{constructor(e=_e,r,s){super(),this._config=e,this._injector=r,this._configService=s;const{menu:n,...l}=u.merge({},_e,this._config);n&&this._configService.setConfig("menu",n,{merge:!0}),this._configService.setConfig(Be,l)}onStarting(){[[ee],[ne]].forEach(e=>this._injector.add(e))}onReady(){this._injector.get(ee)}onRendered(){this._injector.get(ne)}};We(exports.UniverSheetsFilterMobileUIPlugin,"type",u.UniverInstanceType.UNIVER_SHEET);We(exports.UniverSheetsFilterMobileUIPlugin,"pluginName",Ct);exports.UniverSheetsFilterMobileUIPlugin=St([u.DependentOn(c.UniverSheetsFilterPlugin),$e(1,u.Inject(u.Injector)),$e(2,u.IConfigService)],exports.UniverSheetsFilterMobileUIPlugin);var $=function(){return $=Object.assign||function(t){for(var e,r=1,s=arguments.length;r<s;r++){e=arguments[r];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])}return t},$.apply(this,arguments)},Ft=function(t,e){var r={};for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&e.indexOf(s)<0&&(r[s]=t[s]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,s=Object.getOwnPropertySymbols(t);n<s.length;n++)e.indexOf(s[n])<0&&Object.prototype.propertyIsEnumerable.call(t,s[n])&&(r[s[n]]=t[s[n]]);return r},Ve=b.forwardRef(function(t,e){var r=t.icon,s=t.id,n=t.className,l=t.extend,i=Ft(t,["icon","id","className","extend"]),o="univerjs-icon univerjs-icon-".concat(s," ").concat(n||"").trim(),a=b.useRef("_".concat(Ot()));return Qe(r,"".concat(s),{defIds:r.defIds,idSuffix:a.current},$({ref:e,className:o},i),l)});function Qe(t,e,r,s,n){return b.createElement(t.tag,$($({key:e},Tt(t,r,n)),s),(Et(t,r).children||[]).map(function(l,i){return Qe(l,"".concat(e,"-").concat(t.tag,"-").concat(i),r,void 0,n)}))}function Tt(t,e,r){var s=$({},t.attrs);r!=null&&r.colorChannel1&&s.fill==="colorChannel1"&&(s.fill=r.colorChannel1),t.tag==="mask"&&s.id&&(s.id=s.id+e.idSuffix),Object.entries(s).forEach(function(l){var i=l[0],o=l[1];i==="mask"&&typeof o=="string"&&(s[i]=o.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))});var n=e.defIds;return!n||n.length===0||(t.tag==="use"&&s["xlink:href"]&&(s["xlink:href"]=s["xlink:href"]+e.idSuffix),Object.entries(s).forEach(function(l){var i=l[0],o=l[1];typeof o=="string"&&(s[i]=o.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))})),s}function Et(t,e){var r,s=e.defIds;return!s||s.length===0?t:t.tag==="defs"&&(!((r=t.children)===null||r===void 0)&&r.length)?$($({},t),{children:t.children.map(function(n){return typeof n.attrs.id=="string"&&s&&s.includes(n.attrs.id)?$($({},n),{attrs:$($({},n.attrs),{id:n.attrs.id+e.idSuffix})}):n})}):t}function Ot(){return Math.random().toString(36).substring(2,8)}Ve.displayName="UniverIcon";var It={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"}}]},Ge=b.forwardRef(function(t,e){return b.createElement(Ve,Object.assign({},t,{id:"filter-icon",ref:e,icon:It}))});Ge.displayName="FilterIcon";function Nt(t){var _,E;const{model:e}=t,r=C.useDependency(u.LocaleService),s=C.useObservable(e.conditionItem$,void 0),n=C.useObservable(e.filterConditionFormParams$,void 0),l=n!=null&&n.and?"AND":"OR",i=b.useCallback(F=>{e.onConditionFormChange({and:F==="AND"})},[e]),o=yt(r),a=b.useCallback(F=>{e.onPrimaryConditionChange(F)},[e]),h=Rt(r),m=b.useCallback(F=>{e.onConditionFormChange(F)},[e]),f=r.t("sheets-filter.panel.input-values-placeholder");function T(F,R,I){const M=p.getItemByOperator(F).numOfParameters===1;return d.jsxs(d.Fragment,{children:[I==="operator2"&&d.jsxs(y.RadioGroup,{value:l,onChange:i,children:[d.jsx(y.Radio,{value:"AND",children:r.t("sheets-filter.panel.and")}),d.jsx(y.Radio,{value:"OR",children:r.t("sheets-filter.panel.or")})]}),d.jsx(y.Select,{value:F,options:h,onChange:A=>m({[I]:A})}),M&&d.jsx("div",{children:d.jsx(y.Input,{className:"univer-mt-2",value:R,placeholder:f,onChange:A=>m({[I==="operator1"?"val1":"val2"]:A})})})]})}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:s&&n&&d.jsxs(d.Fragment,{children:[d.jsx(y.Select,{value:s.operator,options:o,onChange:a}),p.getItemByOperator(s.operator).numOfParameters!==0?d.jsxs("div",{"data-u-comp":"sheets-filter-panel-conditions-container-inner",className:y.clsx("univer-mt-2 univer-flex-grow univer-overflow-hidden univer-rounded-md univer-p-2",y.borderClassName),children:[s.numOfParameters>=1&&T(n.operator1,(_=n.val1)!=null?_:"","operator1"),s.numOfParameters>=2&&T(n.operator2,(E=n.val2)!=null?E:"","operator2"),d.jsxs("div",{"data-u-comp":"sheets-filter-panel-conditions-desc",className:"univer-mt-2 univer-text-xs univer-text-gray-500",children:[r.t("sheets-filter.panel.?"),d.jsx("br",{}),r.t("sheets-filter.panel.*")]})]}):null]})})}function yt(t){const e=t.getCurrentLocale();return b.useMemo(()=>[{options:[{label:t.t(p.NONE.label),value:p.NONE.operator}]},{options:[{label:t.t(p.EMPTY.label),value:p.EMPTY.operator},{label:t.t(p.NOT_EMPTY.label),value:p.NOT_EMPTY.operator}]},{options:[{label:t.t(p.TEXT_CONTAINS.label),value:p.TEXT_CONTAINS.operator},{label:t.t(p.DOES_NOT_CONTAIN.label),value:p.DOES_NOT_CONTAIN.operator},{label:t.t(p.STARTS_WITH.label),value:p.STARTS_WITH.operator},{label:t.t(p.ENDS_WITH.label),value:p.ENDS_WITH.operator},{label:t.t(p.EQUALS.label),value:p.EQUALS.operator}]},{options:[{label:t.t(p.GREATER_THAN.label),value:p.GREATER_THAN.operator},{label:t.t(p.GREATER_THAN_OR_EQUAL.label),value:p.GREATER_THAN_OR_EQUAL.operator},{label:t.t(p.LESS_THAN.label),value:p.LESS_THAN.operator},{label:t.t(p.LESS_THAN_OR_EQUAL.label),value:p.LESS_THAN_OR_EQUAL.operator},{label:t.t(p.EQUAL.label),value:p.EQUAL.operator},{label:t.t(p.NOT_EQUAL.label),value:p.NOT_EQUAL.operator},{label:t.t(p.BETWEEN.label),value:p.BETWEEN.operator},{label:t.t(p.NOT_BETWEEN.label),value:p.NOT_BETWEEN.operator}]},{options:[{label:t.t(p.CUSTOM.label),value:p.CUSTOM.operator}]}],[e,t])}function Rt(t){const e=t.getCurrentLocale();return b.useMemo(()=>p.ALL_CONDITIONS.filter(r=>r.numOfParameters!==2).map(r=>({label:t.t(r.label),value:r.operator})),[e,t])}function Pt(t){const{model:e}=t,r=C.useDependency(u.LocaleService),s=C.useObservable(e.searchString$,"",!0),n=C.useObservable(e.filterItems$,void 0,!0),l=r.t("sheets-filter.panel.filter-only"),i=Oe(n),o=i.checked>0&&i.unchecked===0,a=i.checked>0&&i.unchecked>0,h=e.treeMapCache,m=b.useCallback(()=>{e.onCheckAllToggled(!o)},[e,o]),f=b.useCallback(_=>{e.setSearchString(_)},[e]);function T(_){let E=[];return _.forEach(F=>{F.checked&&E.push(F.key),F.children&&(E=E.concat(T(F.children)))}),E}return d.jsxs("div",{"data-u-comp":"sheets-filter-panel-values-container",className:"univer-flex univer-h-full univer-min-h-[300px] univer-flex-col",children:[d.jsx(y.Input,{autoFocus:!0,value:s,placeholder:r.t("sheets-filter.panel.search-placeholder"),onChange:f}),d.jsxs("div",{"data-u-comp":"sheets-filter-panel",className:y.clsx("univer-mt-2 univer-box-border univer-flex univer-flex-grow univer-flex-col univer-overflow-hidden univer-rounded-md univer-px-2 univer-py-2.5",y.borderClassName),children:[d.jsx("div",{"data-u-comp":"sheets-filter-panel-values-item",className:"univer-box-border univer-h-8 univer-w-full univer-py-0.5",children:d.jsxs("div",{"data-u-comp":"sheets-filter-panel-values-item-inner",className:"univer-box-border univer-flex univer-h-7 univer-items-center univer-rounded-md univer-pb-0 univer-pl-5 univer-pr-0.5 univer-pt-0 univer-text-sm",children:[d.jsx(y.Checkbox,{indeterminate:a,disabled:n.length===0,checked:o,onChange:m}),d.jsx("span",{"data-u-comp":"sheets-filter-panel-values-item-text",className:"univer-mx-1 univer-inline-block univer-flex-shrink univer-overflow-hidden univer-text-ellipsis univer-whitespace-nowrap univer-text-gray-900 dark:!univer-text-white",children:`${r.t("sheets-filter.panel.select-all")}`}),d.jsx("span",{"data-u-comp":"sheets-filter-panel-values-item-count",className:"univer-text-gray-400 dark:!univer-text-gray-500",children:`(${i.checked}/${i.checked+i.unchecked})`})]})}),d.jsx("div",{"data-u-comp":"sheets-filter-panel-values-virtual",className:"univer-flex-grow",children:d.jsx(y.Tree,{data:n,defaultExpandAll:!1,valueGroup:T(n),onChange:_=>{e.onFilterCheckToggled(_)},defaultCache:h,itemHeight:28,treeNodeClassName:`
|
|
1
|
+
"use strict";var Ze=Object.defineProperty;var ze=(t,e,r)=>e in t?Ze(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var v=(t,e,r)=>ze(t,typeof e!="symbol"?e+"":e,r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("@univerjs/core"),c=require("@univerjs/sheets-filter"),C=require("@univerjs/ui"),U=require("@univerjs/sheets-ui"),O=require("@univerjs/sheets"),S=require("rxjs"),ie=require("@univerjs/engine-render"),ge=require("@univerjs/rpc"),y=require("@univerjs/design"),d=require("react/jsx-runtime"),b=require("react");var N=(t=>(t[t.FIRST=0]="FIRST",t[t.SECOND=1]="SECOND",t))(N||{}),g=(t=>(t.NONE="none",t.STARTS_WITH="startsWith",t.DOES_NOT_START_WITH="doesNotStartWith",t.ENDS_WITH="endsWith",t.DOES_NOT_END_WITH="doesNotEndWith",t.CONTAINS="contains",t.DOES_NOT_CONTAIN="doesNotContain",t.EQUALS="equals",t.NOT_EQUALS="notEquals",t.EMPTY="empty",t.NOT_EMPTY="notEmpty",t.BETWEEN="between",t.NOT_BETWEEN="notBetween",t.CUSTOM="custom",t))(g||{}),p;(t=>{t.NONE={label:"sheets-filter.conditions.none",operator:g.NONE,order:N.SECOND,numOfParameters:0,getDefaultFormParams:()=>{throw new Error("[FilterConditionItems.NONE]: should not have initial form params!")},testMappingParams:i=>i.operator1===g.NONE,mapToFilterColumn:()=>null,testMappingFilterColumn:i=>!i.customFilters&&!i.filters?{}:!1},t.EMPTY={label:"sheets-filter.conditions.empty",operator:g.EMPTY,order:N.SECOND,numOfParameters:0,getDefaultFormParams:()=>{throw new Error("[FilterConditionItems.EMPTY]: should not have initial form params!")},testMappingParams:({operator1:i})=>i===g.EMPTY,mapToFilterColumn:()=>({customFilters:{customFilters:[{val:""}]}}),testMappingFilterColumn:i=>{var 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:g.EMPTY}:!1}},t.NOT_EMPTY={label:"sheets-filter.conditions.not-empty",operator:g.NOT_EMPTY,order:N.SECOND,numOfParameters:0,getDefaultFormParams:()=>{throw new Error("[FilterConditionItems.NOT_EMPTY]: should not have initial form params!")},testMappingParams:({operator1:i})=>i===g.NOT_EMPTY,mapToFilterColumn:()=>({customFilters:{customFilters:[{val:"",operator: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:g.NOT_EMPTY}:!1}},t.TEXT_CONTAINS={label:"sheets-filter.conditions.text-contains",operator:g.CONTAINS,order:N.FIRST,numOfParameters:1,getDefaultFormParams:()=>({operator1:g.CONTAINS,val1:""}),testMappingParams:i=>{const[o]=x(i);return o===g.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],a=o.val.toString();return!o.operator&&a.startsWith("*")&&a.endsWith("*")?{operator1:g.CONTAINS,val1:a.slice(1,-1)}:!1}},t.DOES_NOT_CONTAIN={label:"sheets-filter.conditions.does-not-contain",operator:g.DOES_NOT_CONTAIN,order:N.FIRST,numOfParameters:1,getDefaultFormParams:()=>({operator1:g.DOES_NOT_CONTAIN,val1:""}),mapToFilterColumn:i=>({customFilters:{customFilters:[{val:`*${i.val1}*`,operator:c.CustomFilterOperator.NOT_EQUALS}]}}),testMappingParams:i=>{const[o]=x(i);return o===g.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],a=o.val.toString();return o.operator===c.CustomFilterOperator.NOT_EQUALS&&a.startsWith("*")&&a.endsWith("*")?{operator1:g.DOES_NOT_CONTAIN,val1:a.slice(1,-1)}:!1}},t.STARTS_WITH={label:"sheets-filter.conditions.starts-with",operator:g.STARTS_WITH,order:N.FIRST,numOfParameters:1,getDefaultFormParams:()=>({operator1:g.STARTS_WITH,val1:""}),mapToFilterColumn:i=>({customFilters:{customFilters:[{val:`${i.val1}*`}]}}),testMappingParams:i=>{const[o]=x(i);return o===g.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],a=o.val.toString();return!o.operator&&a.endsWith("*")&&!a.startsWith("*")?{operator1:g.STARTS_WITH,val1:a.slice(0,-1)}:!1}},t.ENDS_WITH={label:"sheets-filter.conditions.ends-with",operator:g.ENDS_WITH,order:N.FIRST,numOfParameters:1,getDefaultFormParams:()=>({operator1:g.ENDS_WITH,val1:""}),mapToFilterColumn:i=>({customFilters:{customFilters:[{val:`*${i.val1}`}]}}),testMappingParams:i=>{const[o]=x(i);return o===g.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],a=o.val.toString();return!o.operator&&a.startsWith("*")&&!a.endsWith("*")?{operator1:g.ENDS_WITH,val1:a.slice(1)}:!1}},t.EQUALS={label:"sheets-filter.conditions.equals",operator:g.EQUALS,order:N.FIRST,numOfParameters:1,getDefaultFormParams:()=>({operator1:g.EQUALS,val1:""}),testMappingParams:i=>{const[o]=x(i);return o===g.EQUALS},mapToFilterColumn:i=>{const{val1:o}=i;return o===""?null:{customFilters:{customFilters:[{val:o}]}}},testMappingFilterColumn:i=>{var o,a,h;return((a=(o=i.filters)==null?void 0:o.filters)==null?void 0:a.length)===1?{operator1:g.EQUALS,val1:""}:((h=i.customFilters)==null?void 0:h.customFilters.length)===1&&!i.customFilters.customFilters[0].operator?{operator1:g.EQUALS,val1:i.customFilters.customFilters[0].val.toString()}:!1}},t.GREATER_THAN={label:"sheets-filter.conditions.greater-than",operator:c.CustomFilterOperator.GREATER_THAN,numOfParameters:1,order:N.FIRST,getDefaultFormParams:()=>({operator1:c.CustomFilterOperator.GREATER_THAN,val1:""}),mapToFilterColumn:i=>({customFilters:{customFilters:[{val:i.val1,operator:c.CustomFilterOperator.GREATER_THAN}]}}),testMappingParams:i=>{const[o]=x(i);return o===c.CustomFilterOperator.GREATER_THAN},testMappingFilterColumn:i=>{var a;if(((a=i.customFilters)==null?void 0:a.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()}}},t.GREATER_THAN_OR_EQUAL={label:"sheets-filter.conditions.greater-than-or-equal",operator:c.CustomFilterOperator.GREATER_THAN_OR_EQUAL,numOfParameters:1,order:N.FIRST,getDefaultFormParams:()=>({operator1:c.CustomFilterOperator.GREATER_THAN_OR_EQUAL,val1:""}),testMappingParams:i=>{const[o]=x(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 a;if(((a=i.customFilters)==null?void 0:a.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()}}},t.LESS_THAN={label:"sheets-filter.conditions.less-than",operator:c.CustomFilterOperator.LESS_THAN,numOfParameters:1,order:N.FIRST,getDefaultFormParams:()=>({operator1:c.CustomFilterOperator.LESS_THAN,val1:""}),testMappingParams:i=>{const[o]=x(i);return o===c.CustomFilterOperator.LESS_THAN},mapToFilterColumn:i=>({customFilters:{customFilters:[{val:i.val1,operator:c.CustomFilterOperator.LESS_THAN}]}}),testMappingFilterColumn:i=>{var a;if(((a=i.customFilters)==null?void 0:a.customFilters.length)!==1)return!1;const o=i.customFilters.customFilters[0];return o.operator!==c.CustomFilterOperator.LESS_THAN?!1:{operator1:c.CustomFilterOperator.LESS_THAN,val1:o.val.toString()}}},t.LESS_THAN_OR_EQUAL={label:"sheets-filter.conditions.less-than-or-equal",operator:c.CustomFilterOperator.LESS_THAN_OR_EQUAL,numOfParameters:1,order:N.FIRST,getDefaultFormParams:()=>({operator1:c.CustomFilterOperator.LESS_THAN_OR_EQUAL,val1:""}),testMappingParams:i=>{const[o]=x(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 a;if(((a=i.customFilters)==null?void 0:a.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()}}},t.EQUAL={label:"sheets-filter.conditions.equal",operator:c.CustomFilterOperator.EQUAL,numOfParameters:1,order:N.FIRST,getDefaultFormParams:()=>({operator1:c.CustomFilterOperator.EQUAL,val1:""}),testMappingParams:i=>{const[o]=x(i);return o===c.CustomFilterOperator.EQUAL},mapToFilterColumn:i=>({customFilters:{customFilters:[{val:i.val1,operator:c.CustomFilterOperator.EQUAL}]}}),testMappingFilterColumn:i=>{var a;if(((a=i.customFilters)==null?void 0:a.customFilters.length)!==1)return!1;const o=i.customFilters.customFilters[0];return o.operator!==c.CustomFilterOperator.EQUAL?!1:{operator1:c.CustomFilterOperator.EQUAL,val1:o.val.toString()}}},t.NOT_EQUAL={label:"sheets-filter.conditions.not-equal",operator:c.CustomFilterOperator.NOT_EQUALS,numOfParameters:1,order:N.FIRST,getDefaultFormParams:()=>({operator1:c.CustomFilterOperator.NOT_EQUALS,val1:""}),testMappingParams:i=>{const[o]=x(i);return o===c.CustomFilterOperator.NOT_EQUALS},mapToFilterColumn:i=>({customFilters:{customFilters:[{val:i.val1,operator:c.CustomFilterOperator.NOT_EQUALS}]}}),testMappingFilterColumn:i=>{var a;if(((a=i.customFilters)==null?void 0:a.customFilters.length)!==1)return!1;const o=i.customFilters.customFilters[0];return o.operator!==c.CustomFilterOperator.NOT_EQUALS?!1:{operator1:c.CustomFilterOperator.NOT_EQUALS,val1:o.val.toString()}}},t.BETWEEN={label:"sheets-filter.conditions.between",operator:g.BETWEEN,order:N.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:a,operator2:h}=i;if(!o)return!1;const m=[a,h];return m.includes(c.CustomFilterOperator.GREATER_THAN_OR_EQUAL)&&m.includes(c.CustomFilterOperator.LESS_THAN_OR_EQUAL)},mapToFilterColumn:i=>{const{val1:o,val2:a,operator1:h}=i,m=h===c.CustomFilterOperator.GREATER_THAN_OR_EQUAL;return{customFilters:{and:u.BooleanNumber.TRUE,customFilters:[{val:m?o:a,operator:c.CustomFilterOperator.GREATER_THAN_OR_EQUAL},{val:m?a:o,operator:c.CustomFilterOperator.LESS_THAN_OR_EQUAL}]}}},testMappingFilterColumn:i=>{var h;if(((h=i.customFilters)==null?void 0:h.customFilters.length)!==2)return!1;const[o,a]=i.customFilters.customFilters;return o.operator===c.CustomFilterOperator.GREATER_THAN_OR_EQUAL&&a.operator===c.CustomFilterOperator.LESS_THAN_OR_EQUAL&&i.customFilters.and?{and:!0,operator1:c.CustomFilterOperator.GREATER_THAN_OR_EQUAL,val1:o.val.toString(),operator2:c.CustomFilterOperator.LESS_THAN_OR_EQUAL,val2:a.val.toString()}:a.operator===c.CustomFilterOperator.GREATER_THAN_OR_EQUAL&&o.operator===c.CustomFilterOperator.LESS_THAN_OR_EQUAL&&i.customFilters.and?{and:!0,operator1:c.CustomFilterOperator.GREATER_THAN_OR_EQUAL,val1:a.val.toString(),operator2:c.CustomFilterOperator.LESS_THAN_OR_EQUAL,val2:o.val.toLocaleString()}:!1}},t.NOT_BETWEEN={label:"sheets-filter.conditions.not-between",operator:g.NOT_BETWEEN,order:N.SECOND,numOfParameters:2,getDefaultFormParams:()=>({operator1:c.CustomFilterOperator.LESS_THAN,val1:"",operator2:c.CustomFilterOperator.GREATER_THAN,val2:""}),testMappingParams:i=>{const{and:o,operator1:a,operator2:h}=i;if(o)return!1;const m=[a,h];return m.includes(c.CustomFilterOperator.GREATER_THAN)&&m.includes(c.CustomFilterOperator.LESS_THAN)},mapToFilterColumn:i=>{const{val1:o,val2:a,operator1:h}=i,m=h===c.CustomFilterOperator.GREATER_THAN;return{customFilters:{customFilters:[{val:m?o:a,operator:c.CustomFilterOperator.GREATER_THAN},{val:m?a:o,operator:c.CustomFilterOperator.LESS_THAN}]}}},testMappingFilterColumn:i=>{var h;if(((h=i.customFilters)==null?void 0:h.customFilters.length)!==2)return!1;const[o,a]=i.customFilters.customFilters;return o.operator===c.CustomFilterOperator.LESS_THAN&&a.operator===c.CustomFilterOperator.GREATER_THAN&&!i.customFilters.and?{operator1:c.CustomFilterOperator.LESS_THAN,val1:o.val.toString(),operator2:c.CustomFilterOperator.GREATER_THAN,val2:a.val.toString()}:a.operator===c.CustomFilterOperator.LESS_THAN&&o.operator===c.CustomFilterOperator.GREATER_THAN&&!i.customFilters.and?{operator1:c.CustomFilterOperator.GREATER_THAN,val1:a.val.toString(),operator2:c.CustomFilterOperator.LESS_THAN,val2:o.val.toLocaleString()}:!1}},t.CUSTOM={label:"sheets-filter.conditions.custom",operator:g.CUSTOM,order:N.SECOND,numOfParameters:2,getDefaultFormParams:()=>({operator1:g.NONE,val1:"",operator2:g.NONE,val2:""}),testMappingParams:()=>!0,mapToFilterColumn:i=>{const{and:o,val1:a,val2:h,operator1:m,operator2:f}=i;function T(M,A){for(const k of t.ALL_CONDITIONS)if(k.operator===M)return k.mapToFilterColumn({val1:A,operator1:M})}const _=!m||m===t.NONE.operator,E=!f||f===t.NONE.operator;if(_&&E)return t.NONE.mapToFilterColumn({});if(_)return T(f,h);if(E)return T(m,a);const F=T(m,a),R=T(f,h),I={customFilters:[F.customFilters.customFilters[0],R.customFilters.customFilters[0]]};return o&&(I.and=u.BooleanNumber.TRUE),{customFilters:I}},testMappingFilterColumn:i=>{var h;if(((h=i.customFilters)==null?void 0:h.customFilters.length)!==2)return!1;const o=i.customFilters.customFilters.map(m=>l({customFilters:{customFilters:[m]}})),a={operator1:o[0][0].operator,val1:o[0][1].val1,operator2:o[1][0].operator,val2:o[1][1].val1};return i.customFilters.and&&(a.and=!0),a}},t.ALL_CONDITIONS=[t.NONE,t.EMPTY,t.NOT_EMPTY,t.TEXT_CONTAINS,t.DOES_NOT_CONTAIN,t.STARTS_WITH,t.ENDS_WITH,t.EQUALS,t.GREATER_THAN,t.GREATER_THAN_OR_EQUAL,t.LESS_THAN,t.LESS_THAN_OR_EQUAL,t.EQUAL,t.NOT_EQUAL,t.BETWEEN,t.NOT_BETWEEN,t.CUSTOM];function e(i){const o=t.ALL_CONDITIONS.find(a=>a.operator===i);if(!o)throw new Error(`[SheetsFilter]: no condition item found for operator: ${i}`);return o}t.getItemByOperator=e;function r(i,o){for(const a of t.ALL_CONDITIONS.filter(h=>h.numOfParameters===o))if(a.numOfParameters!==0&&a.testMappingParams(i))return a;for(const a of t.ALL_CONDITIONS)if(a.testMappingParams(i))return a;throw new Error("[SheetsFilter]: no condition item can be mapped from the filter map params!")}t.testMappingParams=r;function s(i){const o=t.ALL_CONDITIONS.find(a=>a.operator===i);return(o==null?void 0:o.numOfParameters)===0?{operator1:o.operator}:o.getDefaultFormParams()}t.getInitialFormParams=s;function n(i,o){return i.mapToFilterColumn(o)}t.mapToFilterColumn=n;function l(i){if(!i)return[t.NONE,{}];for(const o of t.ALL_CONDITIONS){const a=o.testMappingFilterColumn(i);if(a)return[o,a]}return[t.NONE,{}]}t.testMappingFilterColumn=l})(p||(p={}));function x(t){const{operator1:e,operator2:r,val1:s,val2:n}=t;if(e&&r)throw new Error("Both operator1 and operator2 are set!");if(!e&&!r)throw new Error("Neither operator1 and operator2 and both not set!");return e?[e,s]:[r,n]}function Oe(t){const e=[],r=[];let s=0,n=0;function l(i){i.leaf&&(i.checked?(e.push(i),s+=i.count):(r.push(i),n+=i.count)),i.children&&i.children.forEach(l)}return t.forEach(l),{checkedItems:e,uncheckedItems:r,checked:s,unchecked:n}}var Je=Object.getOwnPropertyDescriptor,et=(t,e,r,s)=>{for(var n=s>1?void 0:s?Je(e,r):e,l=t.length-1,i;l>=0;l--)(i=t[l])&&(n=i(n)||n);return n},Fe=(t,e)=>(r,s)=>e(r,s,t);const Pe="sheets-filter.generate-filter-values.service",he=u.createIdentifier(Pe),tt=["yyyy-mm-dd","yyyy-mm-dd;@","yyyy/mm/dd;@","yyyy/mm/dd hh:mm","yyyy-m-d am/pm h:mm","yyyy-MM-dd","yyyy/MM/dd","yyyy/mm/dd",'yyyy"年"MM"月"dd"日"',"MM-dd",'M"月"d"日"',"MM-dd A/P hh:mm"];let Ie=class extends u.Disposable{constructor(t,e,r){super(),this._localeService=t,this._univerInstanceService=e,this._logService=r}async getFilterValues(t){var m;const{unitId:e,subUnitId:r,filteredOutRowsByOtherColumns:s,filters:n,blankChecked:l,iterateRange:i,alreadyChecked:o}=t,a=this._univerInstanceService.getUnit(e),h=(m=this._univerInstanceService.getUnit(e))==null?void 0:m.getSheetBySheetId(r);return!a||!h?[]:(this._logService.debug("[SheetsGenerateFilterValuesService]","getFilterValues for",{unitId:e,subUnitId:r}),De(n,this._localeService,i,h,new Set(s),new Set(o.map(String)),l,a.getStyles()))}};Ie=et([Fe(0,u.Inject(u.LocaleService)),Fe(1,u.IUniverInstanceService),Fe(2,u.ILogService)],Ie);function De(t,e,r,s,n,l,i,o){var F,R,I,M,A,k,D,oe,ae;const a=new Map,h=new Map,m="yyyy-mm-dd",f=new Set(tt),T="empty";let _=0;for(const w of s.iterateByColumn(r,!1,!1)){const{row:qe,rowSpan:Me=1}=w;let K=0;for(;K<Me;){const Ke=qe+K;if(n.has(Ke)){K++;continue}const G=w!=null&&w.value?u.extractPureTextFromCell(w.value):"";if(!G){_+=1,K+=Me;continue}const le=(F=w.value)!=null&&F.v&&!w.value.p?(M=(I=o.get((R=w.value)==null?void 0:R.s))==null?void 0:I.n)==null?void 0:M.pattern:"",Xe=le&&u.numfmt.getFormatInfo(le).isDate;if(le&&Xe&&f.has(le)){const W=(A=s.getCellRaw(w.row,w.col))==null?void 0:A.v;if(!W){K++;continue}const X=u.numfmt.format(m,W),[P,H,te]=X.split("-").map(Number);let Y=a.get(`${P}`);Y||(Y={title:`${P}`,key:`${P}`,children:[],count:0,leaf:!1,checked:!1},a.set(`${P}`,Y),h.set(`${P}`,[`${P}`]));let j=(k=Y.children)==null?void 0:k.find(Ce=>Ce.key===`${P}-${H}`);j||(j={title:e.t(`sheets-filter.date.${H}`),key:`${P}-${H}`,children:[],count:0,leaf:!1,checked:!1},(D=Y.children)==null||D.push(j),h.set(`${P}-${H}`,[`${P}`,`${P}-${H}`]));const Se=(oe=j==null?void 0:j.children)==null?void 0:oe.find(Ce=>Ce.key===`${P}-${H}-${te}`);Se?(Se.originValues.add(G),Se.count++,j.count++,Y.count++):((ae=j.children)==null||ae.push({title:`${te}`,key:`${P}-${H}-${te}`,count:1,originValues:new Set([G]),leaf:!0,checked:l.size?l.has(G):!i}),j.count++,Y.count++,h.set(`${P}-${H}-${te}`,[`${P}`,`${P}-${H}`,`${P}-${H}-${te}`]))}else{const W=G;let X=a.get(W);X?X.count++:(X={title:G,leaf:!0,checked:l.size?l.has(G):!i,key:W,count:1},a.set(W,X),h.set(W,[W]))}K++}}const E=t?i:!0;if(_>0){const w={title:e.t("sheets-filter.panel.empty"),count:_,leaf:!0,checked:E,key:T};a.set("empty",w),h.set("empty",[T])}return{filterTreeItems:rt(Array.from(a.values())),filterTreeMapCache:h}}function rt(t){return Array.from(t).sort((e,r)=>e.children&&!r.children?-1:!e.children&&r.children?1:it(e.title,r.title)).map(e=>(e.children&&e.children.sort((r,s)=>{const n=Number.parseInt(r.key.split("-")[1],10),l=Number.parseInt(s.key.split("-")[1],10);return n-l}).forEach(r=>{r.children&&r.children.sort((s,n)=>{const l=Number.parseInt(s.key.split("-")[2],10),i=Number.parseInt(n.key.split("-")[2],10);return l-i})}),e))}const we=t=>!Number.isNaN(Number(t))&&!Number.isNaN(Number.parseFloat(t));function it(t,e){const r=we(t),s=we(e);return r&&s?Number.parseFloat(t)-Number.parseFloat(e):r&&!s?-1:!r&&s?1:t.localeCompare(e)}function Ne(t,e){for(const r of t){if(r.key===e)return r;if(r.children){const s=Ne(r.children,e);if(s)return s}}return null}function He(t){return t.leaf?t.checked:t.children?t.children.every(e=>He(e)):!0}function re(t,e){t.leaf&&(e!==void 0?t.checked=e:t.checked=!t.checked),t.children&&t.children.forEach(r=>re(r,e))}function je(t,e){const r=[];return t.forEach(s=>{const n=s.originValues?e.some(o=>Array.from(s.originValues).some(a=>a.toLowerCase().includes(o.toLowerCase()))):!1,l=!n&&e.some(o=>s.title.toLowerCase().includes(o.toLowerCase()));if(n||l)r.push({...s});else if(s.children){const o=je(s.children,e);if(o.length>0){const a=o.reduce((h,m)=>h+m.count,0);r.push({...s,count:a,children:o})}}}),r}var st=Object.getOwnPropertyDescriptor,be=(t,e,r,s)=>{for(var n=s>1?void 0:s?st(e,r):e,l=t.length-1,i;l>=0;l--)(i=t[l])&&(n=i(n)||n);return n},me=(t,e)=>(r,s)=>e(r,s,t),pe=(t=>(t[t.VALUES=0]="VALUES",t[t.CONDITIONS=1]="CONDITIONS",t))(pe||{});u.createIdentifier("sheets-filter-ui.sheets-filter-panel.service");let Q=class extends u.Disposable{constructor(e,r){super();v(this,"_filterBy$",new S.BehaviorSubject(0));v(this,"filterBy$",this._filterBy$.asObservable());v(this,"_filterByModel$",new S.ReplaySubject(1));v(this,"filterByModel$",this._filterByModel$.asObservable());v(this,"_filterByModel",null);v(this,"_hasCriteria$",new S.BehaviorSubject(!1));v(this,"hasCriteria$",this._hasCriteria$.asObservable());v(this,"_filterModel",null);v(this,"_col$",new S.BehaviorSubject(-1));v(this,"col$",this._col$.asObservable());v(this,"_filterHeaderListener",null);this._injector=e,this._refRangeService=r}get filterBy(){return this._filterBy$.getValue()}get filterByModel(){return this._filterByModel}set filterByModel(e){this._filterByModel=e,this._filterByModel$.next(e)}get filterModel(){return this._filterModel}get col(){return this._col$.getValue()}dispose(){this._filterBy$.complete(),this._filterByModel$.complete(),this._hasCriteria$.complete()}setupCol(e,r){this.terminate(),this._filterModel=e,this._col$.next(r);const s=e.getFilterColumn(r);if(s){const n=s.getColumnData();if(n.customFilters){this._hasCriteria$.next(!0),this._setupByConditions(e,r);return}if(n.filters){this._hasCriteria$.next(!0),this._setupByValues(e,r);return}this._hasCriteria$.next(!1),this._setupByValues(e,r);return}this._hasCriteria$.next(!1),this._setupByValues(e,r)}changeFilterBy(e){return!this._filterModel||this.col===-1?!1:(e===0?this._setupByValues(this._filterModel,this.col):this._setupByConditions(this._filterModel,this.col),!0)}terminate(){return this._filterModel=null,this._col$.next(-1),this._disposeFilterHeaderChangeListener(),!0}_disposeFilterHeaderChangeListener(){var e;(e=this._filterHeaderListener)==null||e.dispose(),this._filterHeaderListener=null}_listenToFilterHeaderChange(e,r){this._disposeFilterHeaderChangeListener();const s=e.unitId,n=e.subUnitId,l=e.getRange(),i={startColumn:r,startRow:l.startRow,endRow:l.startRow,endColumn:r};this._filterHeaderListener=this._refRangeService.watchRange(s,n,i,(o,a)=>{if(!a)this.terminate();else{const h=a.startColumn-o.startColumn;h!==0&&this._filterByModel.deltaCol(h)}})}async _setupByValues(e,r){this._disposePreviousModel();const s=e.getRange();if(s.startRow===s.endRow)return!1;const n=await fe.fromFilterColumn(this._injector,e,r);return this.filterByModel=n,this._filterBy$.next(0),this._listenToFilterHeaderChange(e,r),!0}_setupByConditions(e,r){this._disposePreviousModel();const s=e.getRange();if(s.startRow===s.endRow)return!1;const n=de.fromFilterColumn(this._injector,e,r,e.getFilterColumn(r));return this.filterByModel=n,this._filterBy$.next(1),this._listenToFilterHeaderChange(e,r),!0}_disposePreviousModel(){var e;(e=this._filterByModel)==null||e.dispose(),this.filterByModel=null}};Q=be([me(0,u.Inject(u.Injector)),me(1,u.Inject(O.RefRangeService))],Q);let de=class extends u.Disposable{constructor(e,r,s,n,l){super();v(this,"canApply$",S.of(!0));v(this,"_conditionItem$");v(this,"conditionItem$");v(this,"_filterConditionFormParams$");v(this,"filterConditionFormParams$");this._filterModel=e,this.col=r,this._commandService=l,this._conditionItem$=new S.BehaviorSubject(s),this.conditionItem$=this._conditionItem$.asObservable(),this._filterConditionFormParams$=new S.BehaviorSubject(n),this.filterConditionFormParams$=this._filterConditionFormParams$.asObservable()}static fromFilterColumn(e,r,s,n){const[l,i]=p.testMappingFilterColumn(n==null?void 0:n.getColumnData());return e.createInstance(de,r,s,l,i)}get conditionItem(){return this._conditionItem$.getValue()}get filterConditionFormParams(){return this._filterConditionFormParams$.getValue()}dispose(){super.dispose(),this._conditionItem$.complete(),this._filterConditionFormParams$.complete()}deltaCol(e){this.col+=e}clear(){return this._disposed?Promise.resolve(!1):this._commandService.executeCommand(c.SetSheetsFilterCriteriaCommand.id,{unitId:this._filterModel.unitId,subUnitId:this._filterModel.subUnitId,col:this.col,criteria:null})}async apply(){if(this._disposed)return!1;const e=p.mapToFilterColumn(this.conditionItem,this.filterConditionFormParams);return this._commandService.executeCommand(c.SetSheetsFilterCriteriaCommand.id,{unitId:this._filterModel.unitId,subUnitId:this._filterModel.subUnitId,col:this.col,criteria:e})}onPrimaryConditionChange(e){const r=p.ALL_CONDITIONS.find(s=>s.operator===e);if(!r)throw new Error(`[ByConditionsModel]: condition item not found for operator: ${e}!`);this._conditionItem$.next(r),this._filterConditionFormParams$.next(p.getInitialFormParams(e))}onConditionFormChange(e){const r={...this.filterConditionFormParams,...e};if(r.and!==!0&&delete r.and,typeof e.and<"u"||typeof e.operator1<"u"||typeof e.operator2<"u"){const s=p.testMappingParams(r,this.conditionItem.numOfParameters);this._conditionItem$.next(s)}this._filterConditionFormParams$.next(r)}};de=be([me(4,u.ICommandService)],de);let fe=class extends u.Disposable{constructor(e,r,s,n,l){super();v(this,"_rawFilterItems$");v(this,"rawFilterItems$");v(this,"filterItems$");v(this,"_filterItems",[]);v(this,"_treeMapCache");v(this,"canApply$");v(this,"_manuallyUpdateFilterItems$");v(this,"_searchString$");v(this,"searchString$");this._filterModel=e,this.col=r,this._commandService=l,this._treeMapCache=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(m=>!!m);return je(o,h)})),this._manuallyUpdateFilterItems$).pipe(S.shareReplay(1)),this.canApply$=this.filterItems$.pipe(S.map(i=>Oe(i).checked>0)),this.disposeWithMe(this.filterItems$.subscribe(i=>this._filterItems=i))}static async fromFilterColumn(e,r,s){var k;const n=e.get(u.IUniverInstanceService),l=e.get(u.LocaleService),i=e.get(he,u.Quantity.OPTIONAL),{unitId:o,subUnitId:a}=r,h=n.getUniverSheetInstance(o);if(!h)throw new Error(`[ByValuesModel]: Workbook not found for filter model with unitId: ${o}!`);const m=h==null?void 0:h.getSheetBySheetId(a);if(!m)throw new Error(`[ByValuesModel]: Worksheet not found for filter model with unitId: ${o} and subUnitId: ${a}!`);const f=r.getRange(),T=s,_=(k=r.getFilterColumn(s))==null?void 0:k.getColumnData().filters,E=new Set(_==null?void 0:_.filters),F=!!(_&&_.blank),R=r.getFilteredOutRowsExceptCol(s),I={...f,startRow:f.startRow+1,startColumn:T,endColumn:T};let M,A;if(i){const D=await i.getFilterValues({unitId:o,subUnitId:a,filteredOutRowsByOtherColumns:Array.from(R),filters:!!_,blankChecked:F,iterateRange:I,alreadyChecked:Array.from(E)});M=D.filterTreeItems,A=D.filterTreeMapCache}else{const D=De(!!_,l,I,m,R,E,F,h.getStyles());M=D.filterTreeItems,A=D.filterTreeMapCache}return e.createInstance(fe,r,s,M,A)}get rawFilterItems(){return this._rawFilterItems$.getValue()}get filterItems(){return this._filterItems}get treeMapCache(){return this._treeMapCache}dispose(){this._rawFilterItems$.complete(),this._searchString$.complete()}deltaCol(e){this.col+=e}setSearchString(e){this._searchString$.next(e)}onCheckAllToggled(e){const r=u.Tools.deepClone(this._filterItems);r.forEach(s=>re(s,e)),this._manuallyUpdateFilterItems(r)}onFilterCheckToggled(e){const r=u.Tools.deepClone(this._filterItems),s=Ne(r,e.key);if(!s)return;const n=He(s);re(s,!n),this._manuallyUpdateFilterItems(r)}onFilterOnly(e){const r=u.Tools.deepClone(this._filterItems);r.forEach(s=>re(s,!1)),e.forEach(s=>{const n=Ne(r,s);n&&re(n,!0)}),this._manuallyUpdateFilterItems(r)}_manuallyUpdateFilterItems(e){this._manuallyUpdateFilterItems$.next(e)}clear(){return this._disposed?Promise.resolve(!1):this._commandService.executeCommand(c.SetSheetsFilterCriteriaCommand.id,{unitId:this._filterModel.unitId,subUnitId:this._filterModel.subUnitId,col:this.col,criteria:null})}async apply(){if(this._disposed)return!1;const e=Oe(this._filterItems),{checked:r,checkedItems:s}=e,n=this.rawFilterItems;let l=0;for(const h of n)l+=h.count;const i=r===0,o=e.checked===l,a={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});{a.filters={};const h=s.filter(f=>f.key!=="empty");h.length>0&&(a.filters={filters:h.flatMap(f=>f.originValues?Array.from(f.originValues):[f.title])}),h.length!==s.length&&(a.filters.blank=!0)}return this._commandService.executeCommand(c.SetSheetsFilterCriteriaCommand.id,{unitId:this._filterModel.unitId,subUnitId:this._filterModel.subUnitId,col:this.col,criteria:a})}};fe=be([me(4,u.ICommandService)],fe);const J="FILTER_PANEL_OPENED",se={id:"sheet.operation.open-filter-panel",type:u.CommandType.OPERATION,handler:(t,e)=>{const r=t.get(u.IContextService),s=t.get(c.SheetsFilterService),n=t.get(Q);t.get(u.ICommandService).syncExecuteCommand(U.SetCellEditVisibleOperation.id,{visible:!1});const{unitId:i,subUnitId:o,col:a}=e,h=s.getFilterModel(i,o);return h?(n.setupCol(h,a),r.getContextValue(J)||r.setContextValue(J,!0),!0):!1}},z={id:"sheet.operation.close-filter-panel",type:u.CommandType.OPERATION,handler:t=>{const e=t.get(u.IContextService),r=t.get(Q),s=t.get(C.ILayoutService,u.Quantity.OPTIONAL);return e.getContextValue(J)?(e.setContextValue(J,!1),s==null||s.focus(),r.terminate()):!1}},Ae={id:"sheet.operation.apply-filter",type:u.CommandType.OPERATION,handler:(t,e)=>{const{filterBy:r}=e;return t.get(Q).changeFilterBy(r)}},Be="sheets-filter-ui.config",_e={};var nt=Object.getOwnPropertyDescriptor,ot=(t,e,r,s)=>{for(var n=s>1?void 0:s?nt(e,r):e,l=t.length-1,i;l>=0;l--)(i=t[l])&&(n=i(n)||n);return n},Z=(t,e)=>(r,s)=>e(r,s,t);let ee=class extends u.Disposable{constructor(t,e,r,s,n,l){super(),this._sheetsFilterService=t,this._localeService=e,this._commandService=r,this._sheetPermissionCheckPermission=s,this._injector=n,this._sheetsSelectionService=l,this._commandExecutedListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.beforeCommandExecuted(t=>{var e,r,s;if(t.id===c.SmartToggleSheetsFilterCommand.id){const n=this._injector.get(u.IUniverInstanceService),l=O.getSheetCommandTarget(n);if(!l)return;const{unitId:i,subUnitId:o,worksheet:a}=l,h=(e=this._sheetsFilterService.getFilterModel(i,o))==null?void 0:e.getRange();let m;if(h)m=this._sheetPermissionCheckPermission.permissionCheckWithRanges({rangeTypes:[O.RangeProtectionPermissionViewPoint],worksheetTypes:[O.WorksheetFilterPermission,O.WorksheetViewPermission]},[h]);else{const f=(r=this._sheetsSelectionService.getCurrentLastSelection())==null?void 0:r.range;if(f){let T={...f};T=f.startColumn===f.endColumn&&f.startRow===f.endRow?O.expandToContinuousRange(T,{left:!0,right:!0,up:!0,down:!0},a):T,m=this._sheetPermissionCheckPermission.permissionCheckWithRanges({rangeTypes:[O.RangeProtectionPermissionViewPoint],worksheetTypes:[O.WorksheetViewPermission,O.WorksheetFilterPermission]},[T],i,o)}else m=this._sheetPermissionCheckPermission.permissionCheckWithoutRange({rangeTypes:[O.RangeProtectionPermissionViewPoint],worksheetTypes:[O.WorksheetViewPermission,O.WorksheetFilterPermission]})}m||this._sheetPermissionCheckPermission.blockExecuteWithoutPermission(this._localeService.t("permission.dialog.filterErr"))}if(t.id===se.id){const n=t.params,{unitId:l,subUnitId:i}=n,o=(s=this._sheetsFilterService.getFilterModel(l,i))==null?void 0:s.getRange(),a=u.Tools.deepClone(o);a&&(a.startColumn=n.col,a.endColumn=n.col,this._sheetPermissionCheckPermission.permissionCheckWithRanges({rangeTypes:[O.RangeProtectionPermissionViewPoint],worksheetTypes:[O.WorksheetFilterPermission,O.WorksheetViewPermission]},[a])||this._sheetPermissionCheckPermission.blockExecuteWithoutPermission(this._localeService.t("permission.dialog.filterErr")))}}))}};ee=ot([Z(0,u.Inject(c.SheetsFilterService)),Z(1,u.Inject(u.LocaleService)),Z(2,u.ICommandService),Z(3,u.Inject(O.SheetPermissionCheckController)),Z(4,u.Inject(u.Injector)),Z(5,u.Inject(O.SheetsSelectionsService))],ee);const V=16,at=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 Le{static drawNoCriteria(e,r,s,n){e.save(),ie.Rect.drawWith(e,{radius:2,width:V,height:V,fill:n}),e.lineCap="square",e.strokeStyle=s,e.scale(r/V,r/V),e.beginPath(),e.lineWidth=1,e.lineCap="round",e.moveTo(3,4),e.lineTo(13,4),e.moveTo(4.5,8),e.lineTo(11.5,8),e.moveTo(6,12),e.lineTo(10,12),e.stroke(),e.restore()}static drawHasCriteria(e,r,s,n){e.save(),ie.Rect.drawWith(e,{radius:2,width:V,height:V,fill:n}),e.scale(r/V,r/V),e.fillStyle=s,e.fill(at),e.restore()}}var lt=Object.getOwnPropertyDescriptor,ct=(t,e,r,s)=>{for(var n=s>1?void 0:s?lt(e,r):e,l=t.length-1,i;l>=0;l--)(i=t[l])&&(n=i(n)||n);return n},Te=(t,e)=>(r,s)=>e(r,s,t);const B=16,ce=1;let ye=class extends ie.Shape{constructor(e,r,s,n,l){super(e,r);v(this,"_cellWidth",0);v(this,"_cellHeight",0);v(this,"_filterParams");v(this,"_hovered",!1);this._contextService=s,this._commandService=n,this._themeService=l,this.setShapeProps(r),this.onPointerDown$.subscribeEvent(i=>this.onPointerDown(i)),this.onPointerEnter$.subscribeEvent(()=>this.onPointerEnter()),this.onPointerLeave$.subscribeEvent(()=>this.onPointerLeave())}setShapeProps(e){typeof e.cellHeight<"u"&&(this._cellHeight=e.cellHeight),typeof e.cellWidth<"u"&&(this._cellWidth=e.cellWidth),typeof e.filterParams<"u"&&(this._filterParams=e.filterParams),this.transformByState({width:e.width,height:e.height})}_draw(e){const r=this._cellHeight,s=this._cellWidth,n=B-s,l=B-r;e.save();const i=new Path2D;i.rect(n,l,s,r),e.clip(i);const{hasCriteria:o}=this._filterParams,a=this._themeService.getColorFromTheme("primary.600"),h=this._hovered?this._themeService.getColorFromTheme("gray.50"):"rgba(255, 255, 255, 1.0)";o?Le.drawHasCriteria(e,B,a,h):Le.drawNoCriteria(e,B,a,h),e.restore()}onPointerDown(e){if(e.button===2)return;const{col:r,unitId:s,subUnitId:n}=this._filterParams;this._contextService.getContextValue(J)||!this._commandService.hasCommand(se.id)||setTimeout(()=>{this._commandService.executeCommand(se.id,{unitId:s,subUnitId:n,col:r})},200)}onPointerEnter(){this._hovered=!0,this.makeDirty(!0)}onPointerLeave(){this._hovered=!1,this.makeDirty(!0)}};ye=ct([Te(2,u.IContextService),Te(3,u.ICommandService),Te(4,u.Inject(u.ThemeService))],ye);var ut=Object.getOwnPropertyDescriptor,ht=(t,e,r,s)=>{for(var n=s>1?void 0:s?ut(e,r):e,l=t.length-1,i;l>=0;l--)(i=t[l])&&(n=i(n)||n);return n},q=(t,e)=>(r,s)=>e(r,s,t);const mt=1e3,pt=5e3;let Re=class extends u.RxDisposable{constructor(e,r,s,n,l,i,o,a){super();v(this,"_filterRangeShape",null);v(this,"_buttonRenderDisposable",null);v(this,"_filterButtonShapes",[]);this._context=e,this._injector=r,this._sheetSkeletonManagerService=s,this._sheetsFilterService=n,this._themeService=l,this._sheetInterceptorService=i,this._commandService=o,this._selectionRenderService=a,this._initRenderer()}dispose(){super.dispose(),this._disposeRendering()}_initRenderer(){this._sheetSkeletonManagerService.currentSkeleton$.pipe(S.switchMap(e=>{var o,a;if(!e)return S.of(null);const{unit:r,unitId:s}=this._context,n=((o=r.getActiveSheet())==null?void 0:o.getSheetId())||"",l=(a=this._sheetsFilterService.getFilterModel(s,n))!=null?a:void 0,i=()=>({unitId:s,worksheetId:n,filterModel:l,range:l==null?void 0:l.getRange(),skeleton:e.skeleton});return u.fromCallback(this._commandService.onCommandExecuted.bind(this._commandService)).pipe(S.filter(([h])=>{var m;return h.type===u.CommandType.MUTATION&&((m=h.params)==null?void 0:m.unitId)===r.getUnitId()&&(c.FILTER_MUTATIONS.has(h.id)||h.id===O.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,r){const{scene:s}=this._context,{rowHeaderWidth:n,columnHeaderHeight:l}=r,i=this._filterRangeShape=new U.SelectionControl(s,mt,this._themeService,{rowHeaderWidth:n,columnHeaderHeight:l,enableAutoFill:!1,highlightHeader:!1}),o={range:e,primary:null,style:{fill:"rgba(0, 0, 0, 0.0)"}},a=U.attachSelectionWithCoord(o,r);i.updateRangeBySelectionWithCoord(a),i.setEvent(!1),s.makeDirty(!0)}_renderButtons(e){const{range:r,filterModel:s,unitId:n,skeleton:l,worksheetId:i}=e,{scene:o}=this._context;this._interceptCellContent(n,i,e.range);const{startColumn:a,endColumn:h,startRow:m}=r;for(let f=a;f<=h;f++){const T=`sheets-filter-button-${f}`,_=U.getCoordByCell(m,f,o,l),{startX:E,startY:F,endX:R,endY:I}=_,M=R-E,A=I-F;if(A<=ce||M<=ce)continue;const k=!!s.getFilterColumn(f),D=R-B-ce,oe=I-B-ce,ae={left:D,top:oe,height:B,width:B,zIndex:pt,cellHeight:A,cellWidth:M,filterParams:{unitId:n,subUnitId:i,col:f,hasCriteria:k}},w=this._injector.createInstance(ye,T,ae);this._filterButtonShapes.push(w)}o.addObjects(this._filterButtonShapes),o.makeDirty()}_interceptCellContent(e,r,s){const{startRow:n,startColumn:l,endColumn:i}=s;this._buttonRenderDisposable=this._sheetInterceptorService.intercept(O.INTERCEPTOR_POINT.CELL_CONTENT,{effect:u.InterceptorEffectEnum.Style,handler:(o,a,h)=>{const{row:m,col:f,unitId:T,subUnitId:_}=a;return T!==e||_!==r||m!==n||f<l||f>i||((!o||o===a.rawData)&&(o={...a.rawData}),o.fontRenderExtension={...o==null?void 0:o.fontRenderExtension,rightOffset:B}),h(o)},priority:10})}_disposeRendering(){var e,r;(e=this._filterRangeShape)==null||e.dispose(),this._filterButtonShapes.forEach(s=>s.dispose()),(r=this._buttonRenderDisposable)==null||r.dispose(),this._filterRangeShape=null,this._buttonRenderDisposable=null,this._filterButtonShapes=[]}};Re=ht([q(1,u.Inject(u.Injector)),q(2,u.Inject(U.SheetSkeletonManagerService)),q(3,u.Inject(c.SheetsFilterService)),q(4,u.Inject(u.ThemeService)),q(5,u.Inject(O.SheetInterceptorService)),q(6,u.ICommandService),q(7,U.ISheetSelectionRenderService)],Re);var dt=Object.getOwnPropertyDescriptor,ft=(t,e,r,s)=>{for(var n=s>1?void 0:s?dt(e,r):e,l=t.length-1,i;l>=0;l--)(i=t[l])&&(n=i(n)||n);return n},Ue=(t,e)=>(r,s)=>e(r,s,t);let ne=class extends u.RxDisposable{constructor(t,e){super(),this._renderManagerService=t,this._sheetsRenderService=e,[c.SetSheetsFilterRangeMutation,c.SetSheetsFilterCriteriaMutation,c.RemoveSheetsFilterMutation,c.ReCalcSheetsFilterMutation].forEach(r=>this.disposeWithMe(this._sheetsRenderService.registerSkeletonChangingMutations(r.id))),this.disposeWithMe(this._renderManagerService.registerRenderModule(u.UniverInstanceType.UNIVER_SHEET,[Re]))}};ne=ft([Ue(0,ie.IRenderManagerService),Ue(1,u.Inject(U.SheetsRenderService))],ne);var _t=Object.defineProperty,vt=Object.getOwnPropertyDescriptor,gt=(t,e,r)=>e in t?_t(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,St=(t,e,r,s)=>{for(var n=s>1?void 0:s?vt(e,r):e,l=t.length-1,i;l>=0;l--)(i=t[l])&&(n=i(n)||n);return n},$e=(t,e)=>(r,s)=>e(r,s,t),We=(t,e,r)=>gt(t,typeof e!="symbol"?e+"":e,r);const Ct="SHEET_FILTER_UI_PLUGIN";exports.UniverSheetsFilterMobileUIPlugin=class extends u.Plugin{constructor(e=_e,r,s){super(),this._config=e,this._injector=r,this._configService=s;const{menu:n,...l}=u.merge({},_e,this._config);n&&this._configService.setConfig("menu",n,{merge:!0}),this._configService.setConfig(Be,l)}onStarting(){[[ee],[ne]].forEach(e=>this._injector.add(e))}onReady(){this._injector.get(ee)}onRendered(){this._injector.get(ne)}};We(exports.UniverSheetsFilterMobileUIPlugin,"type",u.UniverInstanceType.UNIVER_SHEET);We(exports.UniverSheetsFilterMobileUIPlugin,"pluginName",Ct);exports.UniverSheetsFilterMobileUIPlugin=St([u.DependentOn(c.UniverSheetsFilterPlugin),$e(1,u.Inject(u.Injector)),$e(2,u.IConfigService)],exports.UniverSheetsFilterMobileUIPlugin);var $=function(){return $=Object.assign||function(t){for(var e,r=1,s=arguments.length;r<s;r++){e=arguments[r];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])}return t},$.apply(this,arguments)},Ft=function(t,e){var r={};for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&e.indexOf(s)<0&&(r[s]=t[s]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,s=Object.getOwnPropertySymbols(t);n<s.length;n++)e.indexOf(s[n])<0&&Object.prototype.propertyIsEnumerable.call(t,s[n])&&(r[s[n]]=t[s[n]]);return r},Ve=b.forwardRef(function(t,e){var r=t.icon,s=t.id,n=t.className,l=t.extend,i=Ft(t,["icon","id","className","extend"]),o="univerjs-icon univerjs-icon-".concat(s," ").concat(n||"").trim(),a=b.useRef("_".concat(Ot()));return Qe(r,"".concat(s),{defIds:r.defIds,idSuffix:a.current},$({ref:e,className:o},i),l)});function Qe(t,e,r,s,n){return b.createElement(t.tag,$($({key:e},Tt(t,r,n)),s),(Et(t,r).children||[]).map(function(l,i){return Qe(l,"".concat(e,"-").concat(t.tag,"-").concat(i),r,void 0,n)}))}function Tt(t,e,r){var s=$({},t.attrs);r!=null&&r.colorChannel1&&s.fill==="colorChannel1"&&(s.fill=r.colorChannel1),t.tag==="mask"&&s.id&&(s.id=s.id+e.idSuffix),Object.entries(s).forEach(function(l){var i=l[0],o=l[1];i==="mask"&&typeof o=="string"&&(s[i]=o.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))});var n=e.defIds;return!n||n.length===0||(t.tag==="use"&&s["xlink:href"]&&(s["xlink:href"]=s["xlink:href"]+e.idSuffix),Object.entries(s).forEach(function(l){var i=l[0],o=l[1];typeof o=="string"&&(s[i]=o.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))})),s}function Et(t,e){var r,s=e.defIds;return!s||s.length===0?t:t.tag==="defs"&&(!((r=t.children)===null||r===void 0)&&r.length)?$($({},t),{children:t.children.map(function(n){return typeof n.attrs.id=="string"&&s&&s.includes(n.attrs.id)?$($({},n),{attrs:$($({},n.attrs),{id:n.attrs.id+e.idSuffix})}):n})}):t}function Ot(){return Math.random().toString(36).substring(2,8)}Ve.displayName="UniverIcon";var It={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"}}]},Ge=b.forwardRef(function(t,e){return b.createElement(Ve,Object.assign({},t,{id:"filter-icon",ref:e,icon:It}))});Ge.displayName="FilterIcon";function Nt(t){var _,E;const{model:e}=t,r=C.useDependency(u.LocaleService),s=C.useObservable(e.conditionItem$,void 0),n=C.useObservable(e.filterConditionFormParams$,void 0),l=n!=null&&n.and?"AND":"OR",i=b.useCallback(F=>{e.onConditionFormChange({and:F==="AND"})},[e]),o=yt(r),a=b.useCallback(F=>{e.onPrimaryConditionChange(F)},[e]),h=Rt(r),m=b.useCallback(F=>{e.onConditionFormChange(F)},[e]),f=r.t("sheets-filter.panel.input-values-placeholder");function T(F,R,I){const M=p.getItemByOperator(F).numOfParameters===1;return d.jsxs(d.Fragment,{children:[I==="operator2"&&d.jsxs(y.RadioGroup,{value:l,onChange:i,children:[d.jsx(y.Radio,{value:"AND",children:r.t("sheets-filter.panel.and")}),d.jsx(y.Radio,{value:"OR",children:r.t("sheets-filter.panel.or")})]}),d.jsx(y.Select,{value:F,options:h,onChange:A=>m({[I]:A})}),M&&d.jsx("div",{children:d.jsx(y.Input,{className:"univer-mt-2",value:R,placeholder:f,onChange:A=>m({[I==="operator1"?"val1":"val2"]:A})})})]})}return d.jsx("div",{"data-u-comp":"sheets-filter-panel-conditions-container",className:"univer-flex univer-h-full univer-flex-col",children:s&&n&&d.jsxs(d.Fragment,{children:[d.jsx(y.Select,{value:s.operator,options:o,onChange:a}),p.getItemByOperator(s.operator).numOfParameters!==0?d.jsxs("div",{"data-u-comp":"sheets-filter-panel-conditions-container-inner",className:y.clsx("univer-mt-2 univer-flex-grow univer-overflow-hidden univer-rounded-md univer-p-2",y.borderClassName),children:[s.numOfParameters>=1&&T(n.operator1,(_=n.val1)!=null?_:"","operator1"),s.numOfParameters>=2&&T(n.operator2,(E=n.val2)!=null?E:"","operator2"),d.jsxs("div",{"data-u-comp":"sheets-filter-panel-conditions-desc",className:"univer-mt-2 univer-text-xs univer-text-gray-500",children:[r.t("sheets-filter.panel.?"),d.jsx("br",{}),r.t("sheets-filter.panel.*")]})]}):null]})})}function yt(t){const e=t.getCurrentLocale();return b.useMemo(()=>[{options:[{label:t.t(p.NONE.label),value:p.NONE.operator}]},{options:[{label:t.t(p.EMPTY.label),value:p.EMPTY.operator},{label:t.t(p.NOT_EMPTY.label),value:p.NOT_EMPTY.operator}]},{options:[{label:t.t(p.TEXT_CONTAINS.label),value:p.TEXT_CONTAINS.operator},{label:t.t(p.DOES_NOT_CONTAIN.label),value:p.DOES_NOT_CONTAIN.operator},{label:t.t(p.STARTS_WITH.label),value:p.STARTS_WITH.operator},{label:t.t(p.ENDS_WITH.label),value:p.ENDS_WITH.operator},{label:t.t(p.EQUALS.label),value:p.EQUALS.operator}]},{options:[{label:t.t(p.GREATER_THAN.label),value:p.GREATER_THAN.operator},{label:t.t(p.GREATER_THAN_OR_EQUAL.label),value:p.GREATER_THAN_OR_EQUAL.operator},{label:t.t(p.LESS_THAN.label),value:p.LESS_THAN.operator},{label:t.t(p.LESS_THAN_OR_EQUAL.label),value:p.LESS_THAN_OR_EQUAL.operator},{label:t.t(p.EQUAL.label),value:p.EQUAL.operator},{label:t.t(p.NOT_EQUAL.label),value:p.NOT_EQUAL.operator},{label:t.t(p.BETWEEN.label),value:p.BETWEEN.operator},{label:t.t(p.NOT_BETWEEN.label),value:p.NOT_BETWEEN.operator}]},{options:[{label:t.t(p.CUSTOM.label),value:p.CUSTOM.operator}]}],[e,t])}function Rt(t){const e=t.getCurrentLocale();return b.useMemo(()=>p.ALL_CONDITIONS.filter(r=>r.numOfParameters!==2).map(r=>({label:t.t(r.label),value:r.operator})),[e,t])}function Pt(t){const{model:e}=t,r=C.useDependency(u.LocaleService),s=C.useObservable(e.searchString$,"",!0),n=C.useObservable(e.filterItems$,void 0,!0),l=r.t("sheets-filter.panel.filter-only"),i=Oe(n),o=i.checked>0&&i.unchecked===0,a=i.checked>0&&i.unchecked>0,h=e.treeMapCache,m=b.useCallback(()=>{e.onCheckAllToggled(!o)},[e,o]),f=b.useCallback(_=>{e.setSearchString(_)},[e]);function T(_){let E=[];return _.forEach(F=>{F.checked&&E.push(F.key),F.children&&(E=E.concat(T(F.children)))}),E}return d.jsxs("div",{"data-u-comp":"sheets-filter-panel-values-container",className:"univer-flex univer-h-full univer-flex-col",children:[d.jsx(y.Input,{autoFocus:!0,value:s,placeholder:r.t("sheets-filter.panel.search-placeholder"),onChange:f}),d.jsxs("div",{"data-u-comp":"sheets-filter-panel",className:y.clsx("univer-mt-2 univer-box-border univer-flex univer-flex-grow univer-flex-col univer-overflow-hidden univer-rounded-md univer-px-2 univer-py-2.5",y.borderClassName),children:[d.jsx("div",{"data-u-comp":"sheets-filter-panel-values-item",className:"univer-box-border univer-h-8 univer-w-full univer-py-0.5",children:d.jsxs("div",{"data-u-comp":"sheets-filter-panel-values-item-inner",className:"univer-box-border univer-flex univer-h-7 univer-items-center univer-rounded-md univer-pb-0 univer-pl-5 univer-pr-0.5 univer-pt-0 univer-text-sm",children:[d.jsx(y.Checkbox,{indeterminate:a,disabled:n.length===0,checked:o,onChange:m}),d.jsx("span",{"data-u-comp":"sheets-filter-panel-values-item-text",className:"univer-mx-1 univer-inline-block univer-flex-shrink univer-overflow-hidden univer-text-ellipsis univer-whitespace-nowrap univer-text-gray-900 dark:!univer-text-white",children:`${r.t("sheets-filter.panel.select-all")}`}),d.jsx("span",{"data-u-comp":"sheets-filter-panel-values-item-count",className:"univer-text-gray-400 dark:!univer-text-gray-500",children:`(${i.checked}/${i.checked+i.unchecked})`})]})}),d.jsx("div",{"data-u-comp":"sheets-filter-panel-values-virtual",className:"univer-flex-grow",children:d.jsx(y.Tree,{data:n,defaultExpandAll:!1,valueGroup:T(n),height:180,onChange:_=>{e.onFilterCheckToggled(_)},defaultCache:h,itemHeight:28,treeNodeClassName:`
|
|
2
2
|
univer-pr-2 univer-border-box univer-max-w-[245px] univer-rounded-md
|
|
3
3
|
[&:hover_a]:univer-inline-block
|
|
4
4
|
hover:univer-bg-gray-50 univer-h-full
|
|
5
5
|
univer-text-gray-900 dark:hover:!univer-bg-gray-900
|
|
6
6
|
dark:!univer-text-white
|
|
7
|
-
`,attachRender:_=>d.jsxs("div",{className:"univer-ml-1 univer-flex univer-h-5 univer-flex-1 univer-cursor-pointer univer-items-center univer-justify-between univer-text-sm univer-text-primary-500",children:[d.jsx("span",{"data-u-comp":"sheets-filter-panel-values-item-count",className:"univer-text-gray-400 dark:!univer-text-gray-500",children:`(${_.count})`}),d.jsx("a",{className:"univer-box-border univer-hidden univer-h-4 univer-whitespace-nowrap univer-px-1.5",onClick:()=>{const E=[];_.children?_.children.forEach(F=>{F.children?F.children.forEach(R=>{E.push(R.key)}):E.push(F.key)}):E.push(_.key),e.onFilterOnly(E)},children:l})]})})})]})]})}function bt(){var R;const t=C.useDependency(Q),e=C.useDependency(u.LocaleService),r=C.useDependency(u.ICommandService),s=C.useObservable(t.filterBy$,void 0,!0),n=C.useObservable(t.filterByModel$,void 0,!1),l=C.useObservable(()=>(n==null?void 0:n.canApply$)||S.of(!1),void 0,!1,[n]),i=At(e),o=!C.useObservable(t.hasCriteria$),a=b.useCallback(I=>{r.executeCommand(Ae.id,{filterBy:I})},[r]),h=b.useCallback(async()=>{await(n==null?void 0:n.clear()),r.executeCommand(z.id)},[n,r]),m=b.useCallback(()=>{r.executeCommand(z.id)},[r]),f=b.useCallback(async()=>{await(n==null?void 0:n.apply()),r.executeCommand(z.id)},[n,r]),_=(R=C.useDependency(c.SheetsFilterService).activeFilterModel)==null?void 0:R.getRange(),E=t.col,F=C.useComponentsOfPart(U.SheetsUIPart.FILTER_PANEL_EMBED_POINT);return d.jsxs("div",{"data-u-comp":"sheets-filter-panel",className:"univer-box-border univer-flex univer-
|
|
7
|
+
`,attachRender:_=>d.jsxs("div",{className:"univer-ml-1 univer-flex univer-h-5 univer-flex-1 univer-cursor-pointer univer-items-center univer-justify-between univer-text-sm univer-text-primary-500",children:[d.jsx("span",{"data-u-comp":"sheets-filter-panel-values-item-count",className:"univer-text-gray-400 dark:!univer-text-gray-500",children:`(${_.count})`}),d.jsx("a",{className:"univer-box-border univer-hidden univer-h-4 univer-whitespace-nowrap univer-px-1.5",onClick:()=>{const E=[];_.children?_.children.forEach(F=>{F.children?F.children.forEach(R=>{E.push(R.key)}):E.push(F.key)}):E.push(_.key),e.onFilterOnly(E)},children:l})]})})})]})]})}function bt(){var R;const t=C.useDependency(Q),e=C.useDependency(u.LocaleService),r=C.useDependency(u.ICommandService),s=C.useObservable(t.filterBy$,void 0,!0),n=C.useObservable(t.filterByModel$,void 0,!1),l=C.useObservable(()=>(n==null?void 0:n.canApply$)||S.of(!1),void 0,!1,[n]),i=At(e),o=!C.useObservable(t.hasCriteria$),a=b.useCallback(I=>{r.executeCommand(Ae.id,{filterBy:I})},[r]),h=b.useCallback(async()=>{await(n==null?void 0:n.clear()),r.executeCommand(z.id)},[n,r]),m=b.useCallback(()=>{r.executeCommand(z.id)},[r]),f=b.useCallback(async()=>{await(n==null?void 0:n.apply()),r.executeCommand(z.id)},[n,r]),_=(R=C.useDependency(c.SheetsFilterService).activeFilterModel)==null?void 0:R.getRange(),E=t.col,F=C.useComponentsOfPart(U.SheetsUIPart.FILTER_PANEL_EMBED_POINT);return d.jsxs("div",{"data-u-comp":"sheets-filter-panel",className:"univer-box-border univer-flex univer-h-[442px] univer-w-[312px] univer-flex-col univer-rounded-lg univer-bg-white univer-p-4 univer-shadow-lg dark:!univer-border-gray-600 dark:!univer-bg-gray-700",children:[d.jsx(C.ComponentContainer,{components:F,sharedProps:{range:_,colIndex:E,onClose:m}}),d.jsx("div",{className:"univer-mb-1 univer-flex-shrink-0 univer-flex-grow-0",children:d.jsx(y.Segmented,{value:s,items:i,onChange:I=>a(I)})}),n?d.jsx("div",{"data-u-comp":"sheets-filter-panel-content",className:"univer-flex-shrink univer-flex-grow univer-pt-2",children:s===pe.VALUES?d.jsx(Pt,{model:n}):d.jsx(Nt,{model:n})}):d.jsx("div",{className:"univer-flex-1"}),d.jsxs("div",{"data-u-comp":"sheets-filter-panel-footer",className:"univer-mt-4 univer-inline-flex univer-flex-shrink-0 univer-flex-grow-0 univer-flex-nowrap univer-justify-between univer-overflow-hidden",children:[d.jsx(y.Button,{variant:"link",onClick:h,disabled:o,children:e.t("sheets-filter.panel.clear-filter")}),d.jsxs("span",{className:"univer-flex univer-gap-2",children:[d.jsx(y.Button,{variant:"default",onClick:m,children:e.t("sheets-filter.panel.cancel")}),d.jsx(y.Button,{disabled:!l,variant:"primary",onClick:f,children:e.t("sheets-filter.panel.confirm")})]})]})]})}function At(t){const e=t.getCurrentLocale();return b.useMemo(()=>[{label:t.t("sheets-filter.panel.by-values"),value:pe.VALUES},{label:t.t("sheets-filter.panel.by-conditions"),value:pe.CONDITIONS}],[e,t])}function Mt(t){const e=t.get(c.SheetsFilterService);return{id:c.SmartToggleSheetsFilterCommand.id,type:C.MenuItemType.BUTTON_SELECTOR,icon:"FilterIcon",tooltip:"sheets-filter.toolbar.smart-toggle-filter-tooltip",hidden$:C.getMenuHiddenObservable(t,u.UniverInstanceType.UNIVER_SHEET),activated$:e.activeFilterModel$.pipe(S.map(r=>!!r)),disabled$:U.getObservableWithExclusiveRange$(t,U.getCurrentRangeDisable$(t,{worksheetTypes:[O.WorksheetFilterPermission,O.WorksheetViewPermission],rangeTypes:[O.RangeProtectionPermissionViewPoint]}))}}function wt(t){const e=t.get(c.SheetsFilterService);return{id:c.ClearSheetsFilterCriteriaCommand.id,type:C.MenuItemType.BUTTON,title:"sheets-filter.toolbar.clear-filter-criteria",hidden$:C.getMenuHiddenObservable(t,u.UniverInstanceType.UNIVER_SHEET),disabled$:e.activeFilterModel$.pipe(S.switchMap(r=>{var s;return(s=r==null?void 0:r.hasCriteria$.pipe(S.map(n=>!n)))!=null?s:S.of(!0)}))}}function Lt(t){const e=t.get(c.SheetsFilterService);return{id:c.ReCalcSheetsFilterCommand.id,type:C.MenuItemType.BUTTON,title:"sheets-filter.toolbar.re-calc-filter-conditions",hidden$:C.getMenuHiddenObservable(t,u.UniverInstanceType.UNIVER_SHEET),disabled$:e.activeFilterModel$.pipe(S.switchMap(r=>{var s;return(s=r==null?void 0:r.hasCriteria$.pipe(S.map(n=>!n)))!=null?s:S.of(!0)}))}}const Ut={[C.RibbonDataGroup.ORGANIZATION]:{[c.SmartToggleSheetsFilterCommand.id]:{order:2,menuItemFactory:Mt,[c.ClearSheetsFilterCriteriaCommand.id]:{order:0,menuItemFactory:wt},[c.ReCalcSheetsFilterCommand.id]:{order:1,menuItemFactory:Lt}}}},$t={id:c.SmartToggleSheetsFilterCommand.id,binding:C.KeyCode.L|C.MetaKeys.CTRL_COMMAND|C.MetaKeys.SHIFT,description:"sheets-filter.shortcut.smart-toggle-filter",preconditions:U.whenSheetEditorFocused,group:"4_sheet-edit"};var xt=Object.getOwnPropertyDescriptor,kt=(t,e,r,s)=>{for(var n=s>1?void 0:s?xt(e,r):e,l=t.length-1,i;l>=0;l--)(i=t[l])&&(n=i(n)||n);return n},L=(t,e)=>(r,s)=>e(r,s,t);const xe="FILTER_PANEL_POPUP";let ve=class extends ne{constructor(e,r,s,n,l,i,o,a,h,m,f,T,_){super(_,T);v(this,"_popupDisposable");this._injector=e,this._componentManager=r,this._sheetsFilterPanelService=s,this._sheetCanvasPopupService=n,this._sheetsFilterService=l,this._localeService=i,this._shortcutService=o,this._commandService=a,this._menuManagerService=h,this._contextService=m,this._messageService=f,this._initCommands(),this._initShortcuts(),this._initMenuItems(),this._initUI()}dispose(){super.dispose(),this._closeFilterPopup()}_initShortcuts(){[$t].forEach(e=>{this.disposeWithMe(this._shortcutService.registerShortcut(e))})}_initCommands(){[c.SmartToggleSheetsFilterCommand,c.RemoveSheetFilterCommand,c.SetSheetFilterRangeCommand,c.SetSheetsFilterCriteriaCommand,c.ClearSheetsFilterCriteriaCommand,c.ReCalcSheetsFilterCommand,Ae,se,z].forEach(e=>{this.disposeWithMe(this._commandService.registerCommand(e))})}_initMenuItems(){this._menuManagerService.mergeMenu(Ut)}_initUI(){[[xe,bt],["FilterIcon",Ge]].forEach(([e,r])=>{this.disposeWithMe(this._componentManager.register(e,r))}),this.disposeWithMe(this._contextService.subscribeContextValue$(J).pipe(S.distinctUntilChanged()).subscribe(e=>{e?this._openFilterPopup():this._closeFilterPopup()})),this.disposeWithMe(this._sheetsFilterService.errorMsg$.subscribe(e=>{e&&this._messageService.show({type:y.MessageType.Error,content:this._localeService.t(e)})}))}_openFilterPopup(){const e=this._sheetsFilterPanelService.filterModel;if(!e)throw new Error("[SheetsFilterUIController]: no filter model when opening filter popup!");const r=e.getRange(),s=this._sheetsFilterPanelService.col,{startRow:n}=r;this._popupDisposable=this._sheetCanvasPopupService.attachPopupToCell(n,s,{componentKey:xe,direction:"horizontal",onClickOutside:()=>this._commandService.syncExecuteCommand(z.id),offset:[5,0]})}_closeFilterPopup(){var e;(e=this._popupDisposable)==null||e.dispose(),this._popupDisposable=null}};ve=kt([L(0,u.Inject(u.Injector)),L(1,u.Inject(C.ComponentManager)),L(2,u.Inject(Q)),L(3,u.Inject(U.SheetCanvasPopManagerService)),L(4,u.Inject(c.SheetsFilterService)),L(5,u.Inject(u.LocaleService)),L(6,C.IShortcutService),L(7,u.ICommandService),L(8,C.IMenuManagerService),L(9,u.IContextService),L(10,C.IMessageService),L(11,u.Inject(U.SheetsRenderService)),L(12,ie.IRenderManagerService)],ve);var Dt=Object.defineProperty,Ht=Object.getOwnPropertyDescriptor,jt=(t,e,r)=>e in t?Dt(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Bt=(t,e,r,s)=>{for(var n=s>1?void 0:s?Ht(e,r):e,l=t.length-1,i;l>=0;l--)(i=t[l])&&(n=i(n)||n);return n},Ee=(t,e)=>(r,s)=>e(r,s,t),Ye=(t,e,r)=>jt(t,typeof e!="symbol"?e+"":e,r);const Wt="SHEET_FILTER_UI_PLUGIN";exports.UniverSheetsFilterUIPlugin=class extends u.Plugin{constructor(e=_e,r,s,n){super(),this._config=e,this._injector=r,this._configService=s,this._rpcChannelService=n;const{menu:l,...i}=u.merge({},_e,this._config);l&&this._configService.setConfig("menu",l,{merge:!0}),this._configService.setConfig(Be,i)}onStarting(){u.registerDependencies(this._injector,[[Q],[ee],[ve]]),this._config.useRemoteFilterValuesGenerator&&this._rpcChannelService&&this._injector.add([he,{useFactory:()=>ge.toModule(this._rpcChannelService.requestChannel(Pe))}])}onReady(){u.touchDependencies(this._injector,[[ee]])}onRendered(){u.touchDependencies(this._injector,[[ve]])}};Ye(exports.UniverSheetsFilterUIPlugin,"type",u.UniverInstanceType.UNIVER_SHEET);Ye(exports.UniverSheetsFilterUIPlugin,"pluginName",Wt);exports.UniverSheetsFilterUIPlugin=Bt([u.DependentOn(c.UniverSheetsFilterPlugin),Ee(1,u.Inject(u.Injector)),Ee(2,u.IConfigService),Ee(3,u.Optional(ge.IRPCChannelService))],exports.UniverSheetsFilterUIPlugin);var Vt=Object.getOwnPropertyDescriptor,Qt=(t,e,r,s)=>{for(var n=s>1?void 0:s?Vt(e,r):e,l=t.length-1,i;l>=0;l--)(i=t[l])&&(n=i(n)||n);return n},ke=(t,e)=>(r,s)=>e(r,s,t),ue;exports.UniverSheetsFilterUIWorkerPlugin=(ue=class extends u.Plugin{constructor(e,r,s){super(),this._config=e,this._injector=r,this._rpcChannelService=s}onStarting(){[[he,{useClass:Ie}]].forEach(e=>this._injector.add(e))}onReady(){this._rpcChannelService.registerChannel(Pe,ge.fromModule(this._injector.get(he)))}},v(ue,"type",u.UniverInstanceType.UNIVER_SHEET),v(ue,"pluginName","SHEET_FILTER_UI_WORKER_PLUGIN"),ue);exports.UniverSheetsFilterUIWorkerPlugin=Qt([ke(1,u.Inject(u.Injector)),ke(2,ge.IRPCChannelService)],exports.UniverSheetsFilterUIWorkerPlugin);exports.ChangeFilterByOperation=Ae;exports.CloseFilterPanelOperation=z;exports.OpenFilterPanelOperation=se;
|
package/lib/es/index.js
CHANGED
|
@@ -1453,7 +1453,7 @@ function Ri(t) {
|
|
|
1453
1453
|
"div",
|
|
1454
1454
|
{
|
|
1455
1455
|
"data-u-comp": "sheets-filter-panel-conditions-container",
|
|
1456
|
-
className: "univer-flex univer-h-full univer-
|
|
1456
|
+
className: "univer-flex univer-h-full univer-flex-col",
|
|
1457
1457
|
children: s && n && /* @__PURE__ */ b(ct, { children: [
|
|
1458
1458
|
/* @__PURE__ */ S(at, { value: s.operator, options: o, onChange: a }),
|
|
1459
1459
|
d.getItemByOperator(s.operator).numOfParameters !== 0 ? /* @__PURE__ */ b(
|
|
@@ -1545,7 +1545,7 @@ function Pi(t) {
|
|
|
1545
1545
|
"div",
|
|
1546
1546
|
{
|
|
1547
1547
|
"data-u-comp": "sheets-filter-panel-values-container",
|
|
1548
|
-
className: "univer-flex univer-h-full univer-
|
|
1548
|
+
className: "univer-flex univer-h-full univer-flex-col",
|
|
1549
1549
|
children: [
|
|
1550
1550
|
/* @__PURE__ */ S(
|
|
1551
1551
|
Lt,
|
|
@@ -1609,6 +1609,7 @@ function Pi(t) {
|
|
|
1609
1609
|
data: n,
|
|
1610
1610
|
defaultExpandAll: !1,
|
|
1611
1611
|
valueGroup: g(n),
|
|
1612
|
+
height: 180,
|
|
1612
1613
|
onChange: (p) => {
|
|
1613
1614
|
e.onFilterCheckToggled(p);
|
|
1614
1615
|
},
|
|
@@ -1676,7 +1677,7 @@ function bi() {
|
|
|
1676
1677
|
"div",
|
|
1677
1678
|
{
|
|
1678
1679
|
"data-u-comp": "sheets-filter-panel",
|
|
1679
|
-
className: "univer-box-border univer-flex univer-
|
|
1680
|
+
className: "univer-box-border univer-flex univer-h-[442px] univer-w-[312px] univer-flex-col univer-rounded-lg univer-bg-white univer-p-4 univer-shadow-lg dark:!univer-border-gray-600 dark:!univer-bg-gray-700",
|
|
1680
1681
|
children: [
|
|
1681
1682
|
/* @__PURE__ */ S(
|
|
1682
1683
|
hr,
|
package/lib/index.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
.univer-mx-1{margin-left:.25rem;margin-right:.25rem}.univer-mb-1{margin-bottom:.25rem}.univer-ml-1{margin-left:.25rem}.univer-mt-2{margin-top:.5rem}.univer-mt-4{margin-top:1rem}.univer-box-border{box-sizing:border-box}.univer-inline-block{display:inline-block}.univer-flex{display:flex}.univer-inline-flex{display:inline-flex}.univer-hidden{display:none}.univer-h-4{height:1rem}.univer-h-5{height:1.25rem}.univer-h-7{height:1.75rem}.univer-h-8{height:2rem}.univer-h
|
|
1
|
+
.univer-mx-1{margin-left:.25rem;margin-right:.25rem}.univer-mb-1{margin-bottom:.25rem}.univer-ml-1{margin-left:.25rem}.univer-mt-2{margin-top:.5rem}.univer-mt-4{margin-top:1rem}.univer-box-border{box-sizing:border-box}.univer-inline-block{display:inline-block}.univer-flex{display:flex}.univer-inline-flex{display:inline-flex}.univer-hidden{display:none}.univer-h-4{height:1rem}.univer-h-5{height:1.25rem}.univer-h-7{height:1.75rem}.univer-h-8{height:2rem}.univer-h-\[442px\]{height:442px}.univer-h-full{height:100%}.univer-w-\[312px\]{width:312px}.univer-w-full{width:100%}.univer-max-w-\[245px\]{max-width:245px}.univer-flex-1{flex:1 1 0%}.univer-flex-shrink{flex-shrink:1}.univer-flex-shrink-0{flex-shrink:0}.univer-flex-grow{flex-grow:1}.univer-flex-grow-0{flex-grow:0}.univer-cursor-pointer{cursor:pointer}.univer-flex-col{flex-direction:column}.univer-flex-nowrap{flex-wrap:nowrap}.univer-items-center{align-items:center}.univer-justify-between{justify-content:space-between}.univer-gap-2{gap:.5rem}.univer-overflow-hidden{overflow:hidden}.univer-text-ellipsis{text-overflow:ellipsis}.univer-whitespace-nowrap{white-space:nowrap}.univer-rounded-lg{border-radius:.5rem}.univer-rounded-md{border-radius:.375rem}.univer-bg-white{background-color:var(--univer-white)}.univer-p-2{padding:.5rem}.univer-p-4{padding:1rem}.univer-px-1\.5{padding-left:.375rem;padding-right:.375rem}.univer-px-2{padding-left:.5rem;padding-right:.5rem}.univer-py-0\.5{padding-top:.125rem;padding-bottom:.125rem}.univer-py-2\.5{padding-top:.625rem;padding-bottom:.625rem}.univer-pb-0{padding-bottom:0}.univer-pl-5{padding-left:1.25rem}.univer-pr-0\.5{padding-right:.125rem}.univer-pr-2{padding-right:.5rem}.univer-pt-0{padding-top:0}.univer-pt-2{padding-top:.5rem}.univer-text-sm{font-size:.875rem;line-height:1.25rem}.univer-text-xs{font-size:.75rem;line-height:1rem}.univer-text-gray-400{color:var(--univer-gray-400)}.univer-text-gray-500{color:var(--univer-gray-500)}.univer-text-gray-900{color:var(--univer-gray-900)}.univer-text-primary-500{color:var(--univer-primary-500)}.univer-shadow-lg{--tw-shadow: 0px 4px 6px 0px rgba(30, 40, 77, .05), 0px 10px 15px -3px rgba(30, 40, 77, .1);--tw-shadow-colored: 0px 4px 6px 0px var(--tw-shadow-color), 0px 10px 15px -3px var(--tw-shadow-color);box-shadow:0 0 #0000,0 0 #0000,0 4px 6px #1e284d0d,0 10px 15px -3px #1e284d1a;box-shadow:var(--tw-ring-offset-shadow, 0 0 rgba(0,0,0,0)),var(--tw-ring-shadow, 0 0 rgba(0,0,0,0)),var(--tw-shadow)}.hover\:univer-bg-gray-50:hover{background-color:var(--univer-gray-50)}.dark\:\!univer-border-gray-600:where(.univer-dark,.univer-dark *){border-color:var(--univer-gray-600)!important}.dark\:\!univer-bg-gray-700:where(.univer-dark,.univer-dark *){background-color:var(--univer-gray-700)!important}.dark\:\!univer-text-gray-500:where(.univer-dark,.univer-dark *){color:var(--univer-gray-500)!important}.dark\:\!univer-text-white:where(.univer-dark,.univer-dark *){color:var(--univer-white)!important}.dark\:hover\:\!univer-bg-gray-900:hover:where(.univer-dark,.univer-dark *){background-color:var(--univer-gray-900)!important}.\[\&\:hover_a\]\:univer-inline-block:hover a{display:inline-block}
|
package/lib/index.js
CHANGED
|
@@ -1453,7 +1453,7 @@ function Ri(t) {
|
|
|
1453
1453
|
"div",
|
|
1454
1454
|
{
|
|
1455
1455
|
"data-u-comp": "sheets-filter-panel-conditions-container",
|
|
1456
|
-
className: "univer-flex univer-h-full univer-
|
|
1456
|
+
className: "univer-flex univer-h-full univer-flex-col",
|
|
1457
1457
|
children: s && n && /* @__PURE__ */ b(ct, { children: [
|
|
1458
1458
|
/* @__PURE__ */ S(at, { value: s.operator, options: o, onChange: a }),
|
|
1459
1459
|
d.getItemByOperator(s.operator).numOfParameters !== 0 ? /* @__PURE__ */ b(
|
|
@@ -1545,7 +1545,7 @@ function Pi(t) {
|
|
|
1545
1545
|
"div",
|
|
1546
1546
|
{
|
|
1547
1547
|
"data-u-comp": "sheets-filter-panel-values-container",
|
|
1548
|
-
className: "univer-flex univer-h-full univer-
|
|
1548
|
+
className: "univer-flex univer-h-full univer-flex-col",
|
|
1549
1549
|
children: [
|
|
1550
1550
|
/* @__PURE__ */ S(
|
|
1551
1551
|
Lt,
|
|
@@ -1609,6 +1609,7 @@ function Pi(t) {
|
|
|
1609
1609
|
data: n,
|
|
1610
1610
|
defaultExpandAll: !1,
|
|
1611
1611
|
valueGroup: g(n),
|
|
1612
|
+
height: 180,
|
|
1612
1613
|
onChange: (p) => {
|
|
1613
1614
|
e.onFilterCheckToggled(p);
|
|
1614
1615
|
},
|
|
@@ -1676,7 +1677,7 @@ function bi() {
|
|
|
1676
1677
|
"div",
|
|
1677
1678
|
{
|
|
1678
1679
|
"data-u-comp": "sheets-filter-panel",
|
|
1679
|
-
className: "univer-box-border univer-flex univer-
|
|
1680
|
+
className: "univer-box-border univer-flex univer-h-[442px] univer-w-[312px] univer-flex-col univer-rounded-lg univer-bg-white univer-p-4 univer-shadow-lg dark:!univer-border-gray-600 dark:!univer-bg-gray-700",
|
|
1680
1681
|
children: [
|
|
1681
1682
|
/* @__PURE__ */ S(
|
|
1682
1683
|
hr,
|
package/lib/umd/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
(function(v,c){typeof exports=="object"&&typeof module<"u"?c(exports,require("@univerjs/core"),require("@univerjs/sheets-filter"),require("@univerjs/ui"),require("@univerjs/sheets-ui"),require("@univerjs/sheets"),require("rxjs"),require("@univerjs/engine-render"),require("@univerjs/rpc"),require("@univerjs/design"),require("react/jsx-runtime"),require("react")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/sheets-filter","@univerjs/ui","@univerjs/sheets-ui","@univerjs/sheets","rxjs","@univerjs/engine-render","@univerjs/rpc","@univerjs/design","react/jsx-runtime","react"],c):(v=typeof globalThis<"u"?globalThis:v||self,c(v.UniverSheetsFilterUi={},v.UniverCore,v.UniverSheetsFilter,v.UniverUi,v.UniverSheetsUi,v.UniverSheets,v.rxjs,v.UniverEngineRender,v.UniverRpc,v.UniverDesign,v.React,v.React))})(this,function(v,c,u,T,U,N,C,re,ae,y,d,b){"use strict";var jt=Object.defineProperty;var Gt=(v,c,u)=>c in v?jt(v,c,{enumerable:!0,configurable:!0,writable:!0,value:u}):v[c]=u;var S=(v,c,u)=>Gt(v,typeof c!="symbol"?c+"":c,u);var ve;var P=(t=>(t[t.FIRST=0]="FIRST",t[t.SECOND=1]="SECOND",t))(P||{}),g=(t=>(t.NONE="none",t.STARTS_WITH="startsWith",t.DOES_NOT_START_WITH="doesNotStartWith",t.ENDS_WITH="endsWith",t.DOES_NOT_END_WITH="doesNotEndWith",t.CONTAINS="contains",t.DOES_NOT_CONTAIN="doesNotContain",t.EQUALS="equals",t.NOT_EQUALS="notEquals",t.EMPTY="empty",t.NOT_EMPTY="notEmpty",t.BETWEEN="between",t.NOT_BETWEEN="notBetween",t.CUSTOM="custom",t))(g||{}),p;(t=>{t.NONE={label:"sheets-filter.conditions.none",operator:g.NONE,order:P.SECOND,numOfParameters:0,getDefaultFormParams:()=>{throw new Error("[FilterConditionItems.NONE]: should not have initial form params!")},testMappingParams:i=>i.operator1===g.NONE,mapToFilterColumn:()=>null,testMappingFilterColumn:i=>!i.customFilters&&!i.filters?{}:!1},t.EMPTY={label:"sheets-filter.conditions.empty",operator:g.EMPTY,order:P.SECOND,numOfParameters:0,getDefaultFormParams:()=>{throw new Error("[FilterConditionItems.EMPTY]: should not have initial form params!")},testMappingParams:({operator1:i})=>i===g.EMPTY,mapToFilterColumn:()=>({customFilters:{customFilters:[{val:""}]}}),testMappingFilterColumn:i=>{var m;if(((m=i.customFilters)==null?void 0:m.customFilters.length)!==1)return!1;const s=i.customFilters.customFilters[0];return s.val===""&&s.operator===void 0?{operator1:g.EMPTY}:!1}},t.NOT_EMPTY={label:"sheets-filter.conditions.not-empty",operator:g.NOT_EMPTY,order:P.SECOND,numOfParameters:0,getDefaultFormParams:()=>{throw new Error("[FilterConditionItems.NOT_EMPTY]: should not have initial form params!")},testMappingParams:({operator1:i})=>i===g.NOT_EMPTY,mapToFilterColumn:()=>({customFilters:{customFilters:[{val:"",operator:u.CustomFilterOperator.NOT_EQUALS}]}}),testMappingFilterColumn:i=>{var m;if(((m=i.customFilters)==null?void 0:m.customFilters.length)!==1)return!1;const s=i.customFilters.customFilters[0];return s.val===" "&&s.operator===u.CustomFilterOperator.NOT_EQUALS?{operator1:g.NOT_EMPTY}:!1}},t.TEXT_CONTAINS={label:"sheets-filter.conditions.text-contains",operator:g.CONTAINS,order:P.FIRST,numOfParameters:1,getDefaultFormParams:()=>({operator1:g.CONTAINS,val1:""}),testMappingParams:i=>{const[s]=k(i);return s===g.CONTAINS},mapToFilterColumn:i=>{const{val1:s}=i;return s===""?null:{customFilters:{customFilters:[{val:`*${s}*`}]}}},testMappingFilterColumn:i=>{var m;if(((m=i.customFilters)==null?void 0:m.customFilters.length)!==1)return!1;const s=i.customFilters.customFilters[0],a=s.val.toString();return!s.operator&&a.startsWith("*")&&a.endsWith("*")?{operator1:g.CONTAINS,val1:a.slice(1,-1)}:!1}},t.DOES_NOT_CONTAIN={label:"sheets-filter.conditions.does-not-contain",operator:g.DOES_NOT_CONTAIN,order:P.FIRST,numOfParameters:1,getDefaultFormParams:()=>({operator1:g.DOES_NOT_CONTAIN,val1:""}),mapToFilterColumn:i=>({customFilters:{customFilters:[{val:`*${i.val1}*`,operator:u.CustomFilterOperator.NOT_EQUALS}]}}),testMappingParams:i=>{const[s]=k(i);return s===g.DOES_NOT_CONTAIN},testMappingFilterColumn:i=>{var m;if(((m=i.customFilters)==null?void 0:m.customFilters.length)!==1)return!1;const s=i.customFilters.customFilters[0],a=s.val.toString();return s.operator===u.CustomFilterOperator.NOT_EQUALS&&a.startsWith("*")&&a.endsWith("*")?{operator1:g.DOES_NOT_CONTAIN,val1:a.slice(1,-1)}:!1}},t.STARTS_WITH={label:"sheets-filter.conditions.starts-with",operator:g.STARTS_WITH,order:P.FIRST,numOfParameters:1,getDefaultFormParams:()=>({operator1:g.STARTS_WITH,val1:""}),mapToFilterColumn:i=>({customFilters:{customFilters:[{val:`${i.val1}*`}]}}),testMappingParams:i=>{const[s]=k(i);return s===g.STARTS_WITH},testMappingFilterColumn:i=>{var m;if(((m=i.customFilters)==null?void 0:m.customFilters.length)!==1)return!1;const s=i.customFilters.customFilters[0],a=s.val.toString();return!s.operator&&a.endsWith("*")&&!a.startsWith("*")?{operator1:g.STARTS_WITH,val1:a.slice(0,-1)}:!1}},t.ENDS_WITH={label:"sheets-filter.conditions.ends-with",operator:g.ENDS_WITH,order:P.FIRST,numOfParameters:1,getDefaultFormParams:()=>({operator1:g.ENDS_WITH,val1:""}),mapToFilterColumn:i=>({customFilters:{customFilters:[{val:`*${i.val1}`}]}}),testMappingParams:i=>{const[s]=k(i);return s===g.ENDS_WITH},testMappingFilterColumn:i=>{var m;if(((m=i.customFilters)==null?void 0:m.customFilters.length)!==1)return!1;const s=i.customFilters.customFilters[0],a=s.val.toString();return!s.operator&&a.startsWith("*")&&!a.endsWith("*")?{operator1:g.ENDS_WITH,val1:a.slice(1)}:!1}},t.EQUALS={label:"sheets-filter.conditions.equals",operator:g.EQUALS,order:P.FIRST,numOfParameters:1,getDefaultFormParams:()=>({operator1:g.EQUALS,val1:""}),testMappingParams:i=>{const[s]=k(i);return s===g.EQUALS},mapToFilterColumn:i=>{const{val1:s}=i;return s===""?null:{customFilters:{customFilters:[{val:s}]}}},testMappingFilterColumn:i=>{var s,a,m;return((a=(s=i.filters)==null?void 0:s.filters)==null?void 0:a.length)===1?{operator1:g.EQUALS,val1:""}:((m=i.customFilters)==null?void 0:m.customFilters.length)===1&&!i.customFilters.customFilters[0].operator?{operator1:g.EQUALS,val1:i.customFilters.customFilters[0].val.toString()}:!1}},t.GREATER_THAN={label:"sheets-filter.conditions.greater-than",operator:u.CustomFilterOperator.GREATER_THAN,numOfParameters:1,order:P.FIRST,getDefaultFormParams:()=>({operator1:u.CustomFilterOperator.GREATER_THAN,val1:""}),mapToFilterColumn:i=>({customFilters:{customFilters:[{val:i.val1,operator:u.CustomFilterOperator.GREATER_THAN}]}}),testMappingParams:i=>{const[s]=k(i);return s===u.CustomFilterOperator.GREATER_THAN},testMappingFilterColumn:i=>{var a;if(((a=i.customFilters)==null?void 0:a.customFilters.length)!==1)return!1;const s=i.customFilters.customFilters[0];return s.operator!==u.CustomFilterOperator.GREATER_THAN?!1:{operator1:u.CustomFilterOperator.GREATER_THAN,val1:s.val.toString()}}},t.GREATER_THAN_OR_EQUAL={label:"sheets-filter.conditions.greater-than-or-equal",operator:u.CustomFilterOperator.GREATER_THAN_OR_EQUAL,numOfParameters:1,order:P.FIRST,getDefaultFormParams:()=>({operator1:u.CustomFilterOperator.GREATER_THAN_OR_EQUAL,val1:""}),testMappingParams:i=>{const[s]=k(i);return s===u.CustomFilterOperator.GREATER_THAN_OR_EQUAL},mapToFilterColumn:i=>({customFilters:{customFilters:[{val:i.val1,operator:u.CustomFilterOperator.GREATER_THAN_OR_EQUAL}]}}),testMappingFilterColumn:i=>{var a;if(((a=i.customFilters)==null?void 0:a.customFilters.length)!==1)return!1;const s=i.customFilters.customFilters[0];return s.operator!==u.CustomFilterOperator.GREATER_THAN_OR_EQUAL?!1:{operator1:u.CustomFilterOperator.GREATER_THAN_OR_EQUAL,val1:s.val.toString()}}},t.LESS_THAN={label:"sheets-filter.conditions.less-than",operator:u.CustomFilterOperator.LESS_THAN,numOfParameters:1,order:P.FIRST,getDefaultFormParams:()=>({operator1:u.CustomFilterOperator.LESS_THAN,val1:""}),testMappingParams:i=>{const[s]=k(i);return s===u.CustomFilterOperator.LESS_THAN},mapToFilterColumn:i=>({customFilters:{customFilters:[{val:i.val1,operator:u.CustomFilterOperator.LESS_THAN}]}}),testMappingFilterColumn:i=>{var a;if(((a=i.customFilters)==null?void 0:a.customFilters.length)!==1)return!1;const s=i.customFilters.customFilters[0];return s.operator!==u.CustomFilterOperator.LESS_THAN?!1:{operator1:u.CustomFilterOperator.LESS_THAN,val1:s.val.toString()}}},t.LESS_THAN_OR_EQUAL={label:"sheets-filter.conditions.less-than-or-equal",operator:u.CustomFilterOperator.LESS_THAN_OR_EQUAL,numOfParameters:1,order:P.FIRST,getDefaultFormParams:()=>({operator1:u.CustomFilterOperator.LESS_THAN_OR_EQUAL,val1:""}),testMappingParams:i=>{const[s]=k(i);return s===u.CustomFilterOperator.LESS_THAN_OR_EQUAL},mapToFilterColumn:i=>({customFilters:{customFilters:[{val:i.val1,operator:u.CustomFilterOperator.LESS_THAN_OR_EQUAL}]}}),testMappingFilterColumn:i=>{var a;if(((a=i.customFilters)==null?void 0:a.customFilters.length)!==1)return!1;const s=i.customFilters.customFilters[0];return s.operator!==u.CustomFilterOperator.LESS_THAN_OR_EQUAL?!1:{operator1:u.CustomFilterOperator.LESS_THAN_OR_EQUAL,val1:s.val.toString()}}},t.EQUAL={label:"sheets-filter.conditions.equal",operator:u.CustomFilterOperator.EQUAL,numOfParameters:1,order:P.FIRST,getDefaultFormParams:()=>({operator1:u.CustomFilterOperator.EQUAL,val1:""}),testMappingParams:i=>{const[s]=k(i);return s===u.CustomFilterOperator.EQUAL},mapToFilterColumn:i=>({customFilters:{customFilters:[{val:i.val1,operator:u.CustomFilterOperator.EQUAL}]}}),testMappingFilterColumn:i=>{var a;if(((a=i.customFilters)==null?void 0:a.customFilters.length)!==1)return!1;const s=i.customFilters.customFilters[0];return s.operator!==u.CustomFilterOperator.EQUAL?!1:{operator1:u.CustomFilterOperator.EQUAL,val1:s.val.toString()}}},t.NOT_EQUAL={label:"sheets-filter.conditions.not-equal",operator:u.CustomFilterOperator.NOT_EQUALS,numOfParameters:1,order:P.FIRST,getDefaultFormParams:()=>({operator1:u.CustomFilterOperator.NOT_EQUALS,val1:""}),testMappingParams:i=>{const[s]=k(i);return s===u.CustomFilterOperator.NOT_EQUALS},mapToFilterColumn:i=>({customFilters:{customFilters:[{val:i.val1,operator:u.CustomFilterOperator.NOT_EQUALS}]}}),testMappingFilterColumn:i=>{var a;if(((a=i.customFilters)==null?void 0:a.customFilters.length)!==1)return!1;const s=i.customFilters.customFilters[0];return s.operator!==u.CustomFilterOperator.NOT_EQUALS?!1:{operator1:u.CustomFilterOperator.NOT_EQUALS,val1:s.val.toString()}}},t.BETWEEN={label:"sheets-filter.conditions.between",operator:g.BETWEEN,order:P.SECOND,numOfParameters:2,getDefaultFormParams:()=>({and:!0,operator1:u.CustomFilterOperator.GREATER_THAN_OR_EQUAL,val1:"",operator2:u.CustomFilterOperator.LESS_THAN_OR_EQUAL,val2:""}),testMappingParams:i=>{const{and:s,operator1:a,operator2:m}=i;if(!s)return!1;const h=[a,m];return h.includes(u.CustomFilterOperator.GREATER_THAN_OR_EQUAL)&&h.includes(u.CustomFilterOperator.LESS_THAN_OR_EQUAL)},mapToFilterColumn:i=>{const{val1:s,val2:a,operator1:m}=i,h=m===u.CustomFilterOperator.GREATER_THAN_OR_EQUAL;return{customFilters:{and:c.BooleanNumber.TRUE,customFilters:[{val:h?s:a,operator:u.CustomFilterOperator.GREATER_THAN_OR_EQUAL},{val:h?a:s,operator:u.CustomFilterOperator.LESS_THAN_OR_EQUAL}]}}},testMappingFilterColumn:i=>{var m;if(((m=i.customFilters)==null?void 0:m.customFilters.length)!==2)return!1;const[s,a]=i.customFilters.customFilters;return s.operator===u.CustomFilterOperator.GREATER_THAN_OR_EQUAL&&a.operator===u.CustomFilterOperator.LESS_THAN_OR_EQUAL&&i.customFilters.and?{and:!0,operator1:u.CustomFilterOperator.GREATER_THAN_OR_EQUAL,val1:s.val.toString(),operator2:u.CustomFilterOperator.LESS_THAN_OR_EQUAL,val2:a.val.toString()}:a.operator===u.CustomFilterOperator.GREATER_THAN_OR_EQUAL&&s.operator===u.CustomFilterOperator.LESS_THAN_OR_EQUAL&&i.customFilters.and?{and:!0,operator1:u.CustomFilterOperator.GREATER_THAN_OR_EQUAL,val1:a.val.toString(),operator2:u.CustomFilterOperator.LESS_THAN_OR_EQUAL,val2:s.val.toLocaleString()}:!1}},t.NOT_BETWEEN={label:"sheets-filter.conditions.not-between",operator:g.NOT_BETWEEN,order:P.SECOND,numOfParameters:2,getDefaultFormParams:()=>({operator1:u.CustomFilterOperator.LESS_THAN,val1:"",operator2:u.CustomFilterOperator.GREATER_THAN,val2:""}),testMappingParams:i=>{const{and:s,operator1:a,operator2:m}=i;if(s)return!1;const h=[a,m];return h.includes(u.CustomFilterOperator.GREATER_THAN)&&h.includes(u.CustomFilterOperator.LESS_THAN)},mapToFilterColumn:i=>{const{val1:s,val2:a,operator1:m}=i,h=m===u.CustomFilterOperator.GREATER_THAN;return{customFilters:{customFilters:[{val:h?s:a,operator:u.CustomFilterOperator.GREATER_THAN},{val:h?a:s,operator:u.CustomFilterOperator.LESS_THAN}]}}},testMappingFilterColumn:i=>{var m;if(((m=i.customFilters)==null?void 0:m.customFilters.length)!==2)return!1;const[s,a]=i.customFilters.customFilters;return s.operator===u.CustomFilterOperator.LESS_THAN&&a.operator===u.CustomFilterOperator.GREATER_THAN&&!i.customFilters.and?{operator1:u.CustomFilterOperator.LESS_THAN,val1:s.val.toString(),operator2:u.CustomFilterOperator.GREATER_THAN,val2:a.val.toString()}:a.operator===u.CustomFilterOperator.LESS_THAN&&s.operator===u.CustomFilterOperator.GREATER_THAN&&!i.customFilters.and?{operator1:u.CustomFilterOperator.GREATER_THAN,val1:a.val.toString(),operator2:u.CustomFilterOperator.LESS_THAN,val2:s.val.toLocaleString()}:!1}},t.CUSTOM={label:"sheets-filter.conditions.custom",operator:g.CUSTOM,order:P.SECOND,numOfParameters:2,getDefaultFormParams:()=>({operator1:g.NONE,val1:"",operator2:g.NONE,val2:""}),testMappingParams:()=>!0,mapToFilterColumn:i=>{const{and:s,val1:a,val2:m,operator1:h,operator2:f}=i;function O(w,M){for(const H of t.ALL_CONDITIONS)if(H.operator===w)return H.mapToFilterColumn({val1:M,operator1:w})}const _=!h||h===t.NONE.operator,I=!f||f===t.NONE.operator;if(_&&I)return t.NONE.mapToFilterColumn({});if(_)return O(f,m);if(I)return O(h,a);const E=O(h,a),A=O(f,m),F={customFilters:[E.customFilters.customFilters[0],A.customFilters.customFilters[0]]};return s&&(F.and=c.BooleanNumber.TRUE),{customFilters:F}},testMappingFilterColumn:i=>{var m;if(((m=i.customFilters)==null?void 0:m.customFilters.length)!==2)return!1;const s=i.customFilters.customFilters.map(h=>l({customFilters:{customFilters:[h]}})),a={operator1:s[0][0].operator,val1:s[0][1].val1,operator2:s[1][0].operator,val2:s[1][1].val1};return i.customFilters.and&&(a.and=!0),a}},t.ALL_CONDITIONS=[t.NONE,t.EMPTY,t.NOT_EMPTY,t.TEXT_CONTAINS,t.DOES_NOT_CONTAIN,t.STARTS_WITH,t.ENDS_WITH,t.EQUALS,t.GREATER_THAN,t.GREATER_THAN_OR_EQUAL,t.LESS_THAN,t.LESS_THAN_OR_EQUAL,t.EQUAL,t.NOT_EQUAL,t.BETWEEN,t.NOT_BETWEEN,t.CUSTOM];function e(i){const s=t.ALL_CONDITIONS.find(a=>a.operator===i);if(!s)throw new Error(`[SheetsFilter]: no condition item found for operator: ${i}`);return s}t.getItemByOperator=e;function r(i,s){for(const a of t.ALL_CONDITIONS.filter(m=>m.numOfParameters===s))if(a.numOfParameters!==0&&a.testMappingParams(i))return a;for(const a of t.ALL_CONDITIONS)if(a.testMappingParams(i))return a;throw new Error("[SheetsFilter]: no condition item can be mapped from the filter map params!")}t.testMappingParams=r;function n(i){const s=t.ALL_CONDITIONS.find(a=>a.operator===i);return(s==null?void 0:s.numOfParameters)===0?{operator1:s.operator}:s.getDefaultFormParams()}t.getInitialFormParams=n;function o(i,s){return i.mapToFilterColumn(s)}t.mapToFilterColumn=o;function l(i){if(!i)return[t.NONE,{}];for(const s of t.ALL_CONDITIONS){const a=s.testMappingFilterColumn(i);if(a)return[s,a]}return[t.NONE,{}]}t.testMappingFilterColumn=l})(p||(p={}));function k(t){const{operator1:e,operator2:r,val1:n,val2:o}=t;if(e&&r)throw new Error("Both operator1 and operator2 are set!");if(!e&&!r)throw new Error("Neither operator1 and operator2 and both not set!");return e?[e,n]:[r,o]}function Ce(t){const e=[],r=[];let n=0,o=0;function l(i){i.leaf&&(i.checked?(e.push(i),n+=i.count):(r.push(i),o+=i.count)),i.children&&i.children.forEach(l)}return t.forEach(l),{checkedItems:e,uncheckedItems:r,checked:n,unchecked:o}}var Ke=Object.getOwnPropertyDescriptor,Xe=(t,e,r,n)=>{for(var o=n>1?void 0:n?Ke(e,r):e,l=t.length-1,i;l>=0;l--)(i=t[l])&&(o=i(o)||o);return o},Te=(t,e)=>(r,n)=>e(r,n,t);const Ee="sheets-filter.generate-filter-values.service",le=c.createIdentifier(Ee),Ze=["yyyy-mm-dd","yyyy-mm-dd;@","yyyy/mm/dd;@","yyyy/mm/dd hh:mm","yyyy-m-d am/pm h:mm","yyyy-MM-dd","yyyy/MM/dd","yyyy/mm/dd",'yyyy"年"MM"月"dd"日"',"MM-dd",'M"月"d"日"',"MM-dd A/P hh:mm"];let Oe=class extends c.Disposable{constructor(t,e,r){super(),this._localeService=t,this._univerInstanceService=e,this._logService=r}async getFilterValues(t){var h;const{unitId:e,subUnitId:r,filteredOutRowsByOtherColumns:n,filters:o,blankChecked:l,iterateRange:i,alreadyChecked:s}=t,a=this._univerInstanceService.getUnit(e),m=(h=this._univerInstanceService.getUnit(e))==null?void 0:h.getSheetBySheetId(r);return!a||!m?[]:(this._logService.debug("[SheetsGenerateFilterValuesService]","getFilterValues for",{unitId:e,subUnitId:r}),we(o,this._localeService,i,m,new Set(n),new Set(s.map(String)),l,a.getStyles()))}};Oe=Xe([Te(0,c.Inject(c.LocaleService)),Te(1,c.IUniverInstanceService),Te(2,c.ILogService)],Oe);function we(t,e,r,n,o,l,i,s){var E,A,F,w,M,H,B,_e,Se;const a=new Map,m=new Map,h="yyyy-mm-dd",f=new Set(Ze),O="empty";let _=0;for(const L of n.iterateByColumn(r,!1,!1)){const{row:xt,rowSpan:qe=1}=L;let ee=0;for(;ee<qe;){const Vt=xt+ee;if(o.has(Vt)){ee++;continue}const q=L!=null&&L.value?c.extractPureTextFromCell(L.value):"";if(!q){_+=1,ee+=qe;continue}const ge=(E=L.value)!=null&&E.v&&!L.value.p?(w=(F=s.get((A=L.value)==null?void 0:A.s))==null?void 0:F.n)==null?void 0:w.pattern:"",Qt=ge&&c.numfmt.getFormatInfo(ge).isDate;if(ge&&Qt&&f.has(ge)){const G=(M=n.getCellRaw(L.row,L.col))==null?void 0:M.v;if(!G){ee++;continue}const te=c.numfmt.format(h,G),[R,W,se]=te.split("-").map(Number);let K=a.get(`${R}`);K||(K={title:`${R}`,key:`${R}`,children:[],count:0,leaf:!1,checked:!1},a.set(`${R}`,K),m.set(`${R}`,[`${R}`]));let V=(H=K.children)==null?void 0:H.find(Me=>Me.key===`${R}-${W}`);V||(V={title:e.t(`sheets-filter.date.${W}`),key:`${R}-${W}`,children:[],count:0,leaf:!1,checked:!1},(B=K.children)==null||B.push(V),m.set(`${R}-${W}`,[`${R}`,`${R}-${W}`]));const Re=(_e=V==null?void 0:V.children)==null?void 0:_e.find(Me=>Me.key===`${R}-${W}-${se}`);Re?(Re.originValues.add(q),Re.count++,V.count++,K.count++):((Se=V.children)==null||Se.push({title:`${se}`,key:`${R}-${W}-${se}`,count:1,originValues:new Set([q]),leaf:!0,checked:l.size?l.has(q):!i}),V.count++,K.count++,m.set(`${R}-${W}-${se}`,[`${R}`,`${R}-${W}`,`${R}-${W}-${se}`]))}else{const G=q;let te=a.get(G);te?te.count++:(te={title:q,leaf:!0,checked:l.size?l.has(q):!i,key:G,count:1},a.set(G,te),m.set(G,[G]))}ee++}}const I=t?i:!0;if(_>0){const L={title:e.t("sheets-filter.panel.empty"),count:_,leaf:!0,checked:I,key:O};a.set("empty",L),m.set("empty",[O])}return{filterTreeItems:ze(Array.from(a.values())),filterTreeMapCache:m}}function ze(t){return Array.from(t).sort((e,r)=>e.children&&!r.children?-1:!e.children&&r.children?1:Je(e.title,r.title)).map(e=>(e.children&&e.children.sort((r,n)=>{const o=Number.parseInt(r.key.split("-")[1],10),l=Number.parseInt(n.key.split("-")[1],10);return o-l}).forEach(r=>{r.children&&r.children.sort((n,o)=>{const l=Number.parseInt(n.key.split("-")[2],10),i=Number.parseInt(o.key.split("-")[2],10);return l-i})}),e))}const Le=t=>!Number.isNaN(Number(t))&&!Number.isNaN(Number.parseFloat(t));function Je(t,e){const r=Le(t),n=Le(e);return r&&n?Number.parseFloat(t)-Number.parseFloat(e):r&&!n?-1:!r&&n?1:t.localeCompare(e)}function Ie(t,e){for(const r of t){if(r.key===e)return r;if(r.children){const n=Ie(r.children,e);if(n)return n}}return null}function Ue(t){return t.leaf?t.checked:t.children?t.children.every(e=>Ue(e)):!0}function ie(t,e){t.leaf&&(e!==void 0?t.checked=e:t.checked=!t.checked),t.children&&t.children.forEach(r=>ie(r,e))}function $e(t,e){const r=[];return t.forEach(n=>{const o=n.originValues?e.some(s=>Array.from(n.originValues).some(a=>a.toLowerCase().includes(s.toLowerCase()))):!1,l=!o&&e.some(s=>n.title.toLowerCase().includes(s.toLowerCase()));if(o||l)r.push({...n});else if(n.children){const s=$e(n.children,e);if(s.length>0){const a=s.reduce((m,h)=>m+h.count,0);r.push({...n,count:a,children:s})}}}),r}var et=Object.getOwnPropertyDescriptor,Ne=(t,e,r,n)=>{for(var o=n>1?void 0:n?et(e,r):e,l=t.length-1,i;l>=0;l--)(i=t[l])&&(o=i(o)||o);return o},ce=(t,e)=>(r,n)=>e(r,n,t),ue=(t=>(t[t.VALUES=0]="VALUES",t[t.CONDITIONS=1]="CONDITIONS",t))(ue||{});c.createIdentifier("sheets-filter-ui.sheets-filter-panel.service");let Q=class extends c.Disposable{constructor(e,r){super();S(this,"_filterBy$",new C.BehaviorSubject(0));S(this,"filterBy$",this._filterBy$.asObservable());S(this,"_filterByModel$",new C.ReplaySubject(1));S(this,"filterByModel$",this._filterByModel$.asObservable());S(this,"_filterByModel",null);S(this,"_hasCriteria$",new C.BehaviorSubject(!1));S(this,"hasCriteria$",this._hasCriteria$.asObservable());S(this,"_filterModel",null);S(this,"_col$",new C.BehaviorSubject(-1));S(this,"col$",this._col$.asObservable());S(this,"_filterHeaderListener",null);this._injector=e,this._refRangeService=r}get filterBy(){return this._filterBy$.getValue()}get filterByModel(){return this._filterByModel}set filterByModel(e){this._filterByModel=e,this._filterByModel$.next(e)}get filterModel(){return this._filterModel}get col(){return this._col$.getValue()}dispose(){this._filterBy$.complete(),this._filterByModel$.complete(),this._hasCriteria$.complete()}setupCol(e,r){this.terminate(),this._filterModel=e,this._col$.next(r);const n=e.getFilterColumn(r);if(n){const o=n.getColumnData();if(o.customFilters){this._hasCriteria$.next(!0),this._setupByConditions(e,r);return}if(o.filters){this._hasCriteria$.next(!0),this._setupByValues(e,r);return}this._hasCriteria$.next(!1),this._setupByValues(e,r);return}this._hasCriteria$.next(!1),this._setupByValues(e,r)}changeFilterBy(e){return!this._filterModel||this.col===-1?!1:(e===0?this._setupByValues(this._filterModel,this.col):this._setupByConditions(this._filterModel,this.col),!0)}terminate(){return this._filterModel=null,this._col$.next(-1),this._disposeFilterHeaderChangeListener(),!0}_disposeFilterHeaderChangeListener(){var e;(e=this._filterHeaderListener)==null||e.dispose(),this._filterHeaderListener=null}_listenToFilterHeaderChange(e,r){this._disposeFilterHeaderChangeListener();const n=e.unitId,o=e.subUnitId,l=e.getRange(),i={startColumn:r,startRow:l.startRow,endRow:l.startRow,endColumn:r};this._filterHeaderListener=this._refRangeService.watchRange(n,o,i,(s,a)=>{if(!a)this.terminate();else{const m=a.startColumn-s.startColumn;m!==0&&this._filterByModel.deltaCol(m)}})}async _setupByValues(e,r){this._disposePreviousModel();const n=e.getRange();if(n.startRow===n.endRow)return!1;const o=await he.fromFilterColumn(this._injector,e,r);return this.filterByModel=o,this._filterBy$.next(0),this._listenToFilterHeaderChange(e,r),!0}_setupByConditions(e,r){this._disposePreviousModel();const n=e.getRange();if(n.startRow===n.endRow)return!1;const o=me.fromFilterColumn(this._injector,e,r,e.getFilterColumn(r));return this.filterByModel=o,this._filterBy$.next(1),this._listenToFilterHeaderChange(e,r),!0}_disposePreviousModel(){var e;(e=this._filterByModel)==null||e.dispose(),this.filterByModel=null}};Q=Ne([ce(0,c.Inject(c.Injector)),ce(1,c.Inject(N.RefRangeService))],Q);let me=class extends c.Disposable{constructor(e,r,n,o,l){super();S(this,"canApply$",C.of(!0));S(this,"_conditionItem$");S(this,"conditionItem$");S(this,"_filterConditionFormParams$");S(this,"filterConditionFormParams$");this._filterModel=e,this.col=r,this._commandService=l,this._conditionItem$=new C.BehaviorSubject(n),this.conditionItem$=this._conditionItem$.asObservable(),this._filterConditionFormParams$=new C.BehaviorSubject(o),this.filterConditionFormParams$=this._filterConditionFormParams$.asObservable()}static fromFilterColumn(e,r,n,o){const[l,i]=p.testMappingFilterColumn(o==null?void 0:o.getColumnData());return e.createInstance(me,r,n,l,i)}get conditionItem(){return this._conditionItem$.getValue()}get filterConditionFormParams(){return this._filterConditionFormParams$.getValue()}dispose(){super.dispose(),this._conditionItem$.complete(),this._filterConditionFormParams$.complete()}deltaCol(e){this.col+=e}clear(){return this._disposed?Promise.resolve(!1):this._commandService.executeCommand(u.SetSheetsFilterCriteriaCommand.id,{unitId:this._filterModel.unitId,subUnitId:this._filterModel.subUnitId,col:this.col,criteria:null})}async apply(){if(this._disposed)return!1;const e=p.mapToFilterColumn(this.conditionItem,this.filterConditionFormParams);return this._commandService.executeCommand(u.SetSheetsFilterCriteriaCommand.id,{unitId:this._filterModel.unitId,subUnitId:this._filterModel.subUnitId,col:this.col,criteria:e})}onPrimaryConditionChange(e){const r=p.ALL_CONDITIONS.find(n=>n.operator===e);if(!r)throw new Error(`[ByConditionsModel]: condition item not found for operator: ${e}!`);this._conditionItem$.next(r),this._filterConditionFormParams$.next(p.getInitialFormParams(e))}onConditionFormChange(e){const r={...this.filterConditionFormParams,...e};if(r.and!==!0&&delete r.and,typeof e.and<"u"||typeof e.operator1<"u"||typeof e.operator2<"u"){const n=p.testMappingParams(r,this.conditionItem.numOfParameters);this._conditionItem$.next(n)}this._filterConditionFormParams$.next(r)}};me=Ne([ce(4,c.ICommandService)],me);let he=class extends c.Disposable{constructor(e,r,n,o,l){super();S(this,"_rawFilterItems$");S(this,"rawFilterItems$");S(this,"filterItems$");S(this,"_filterItems",[]);S(this,"_treeMapCache");S(this,"canApply$");S(this,"_manuallyUpdateFilterItems$");S(this,"_searchString$");S(this,"searchString$");this._filterModel=e,this.col=r,this._commandService=l,this._treeMapCache=o,this._searchString$=new C.BehaviorSubject(""),this.searchString$=this._searchString$.asObservable(),this._rawFilterItems$=new C.BehaviorSubject(n),this.rawFilterItems$=this._rawFilterItems$.asObservable(),this._manuallyUpdateFilterItems$=new C.Subject,this.filterItems$=C.merge(C.combineLatest([this._searchString$.pipe(C.throttleTime(500,void 0,{leading:!0,trailing:!0}),C.startWith(void 0)),this._rawFilterItems$]).pipe(C.map(([i,s])=>{if(!i)return s;const m=i.toLowerCase().split(/\s+/).filter(h=>!!h);return $e(s,m)})),this._manuallyUpdateFilterItems$).pipe(C.shareReplay(1)),this.canApply$=this.filterItems$.pipe(C.map(i=>Ce(i).checked>0)),this.disposeWithMe(this.filterItems$.subscribe(i=>this._filterItems=i))}static async fromFilterColumn(e,r,n){var H;const o=e.get(c.IUniverInstanceService),l=e.get(c.LocaleService),i=e.get(le,c.Quantity.OPTIONAL),{unitId:s,subUnitId:a}=r,m=o.getUniverSheetInstance(s);if(!m)throw new Error(`[ByValuesModel]: Workbook not found for filter model with unitId: ${s}!`);const h=m==null?void 0:m.getSheetBySheetId(a);if(!h)throw new Error(`[ByValuesModel]: Worksheet not found for filter model with unitId: ${s} and subUnitId: ${a}!`);const f=r.getRange(),O=n,_=(H=r.getFilterColumn(n))==null?void 0:H.getColumnData().filters,I=new Set(_==null?void 0:_.filters),E=!!(_&&_.blank),A=r.getFilteredOutRowsExceptCol(n),F={...f,startRow:f.startRow+1,startColumn:O,endColumn:O};let w,M;if(i){const B=await i.getFilterValues({unitId:s,subUnitId:a,filteredOutRowsByOtherColumns:Array.from(A),filters:!!_,blankChecked:E,iterateRange:F,alreadyChecked:Array.from(I)});w=B.filterTreeItems,M=B.filterTreeMapCache}else{const B=we(!!_,l,F,h,A,I,E,m.getStyles());w=B.filterTreeItems,M=B.filterTreeMapCache}return e.createInstance(he,r,n,w,M)}get rawFilterItems(){return this._rawFilterItems$.getValue()}get filterItems(){return this._filterItems}get treeMapCache(){return this._treeMapCache}dispose(){this._rawFilterItems$.complete(),this._searchString$.complete()}deltaCol(e){this.col+=e}setSearchString(e){this._searchString$.next(e)}onCheckAllToggled(e){const r=c.Tools.deepClone(this._filterItems);r.forEach(n=>ie(n,e)),this._manuallyUpdateFilterItems(r)}onFilterCheckToggled(e){const r=c.Tools.deepClone(this._filterItems),n=Ie(r,e.key);if(!n)return;const o=Ue(n);ie(n,!o),this._manuallyUpdateFilterItems(r)}onFilterOnly(e){const r=c.Tools.deepClone(this._filterItems);r.forEach(n=>ie(n,!1)),e.forEach(n=>{const o=Ie(r,n);o&&ie(o,!0)}),this._manuallyUpdateFilterItems(r)}_manuallyUpdateFilterItems(e){this._manuallyUpdateFilterItems$.next(e)}clear(){return this._disposed?Promise.resolve(!1):this._commandService.executeCommand(u.SetSheetsFilterCriteriaCommand.id,{unitId:this._filterModel.unitId,subUnitId:this._filterModel.subUnitId,col:this.col,criteria:null})}async apply(){if(this._disposed)return!1;const e=Ce(this._filterItems),{checked:r,checkedItems:n}=e,o=this.rawFilterItems;let l=0;for(const m of o)l+=m.count;const i=r===0,s=e.checked===l,a={colId:this.col};if(i)throw new Error("[ByValuesModel]: no checked items!");if(s)return this._commandService.executeCommand(u.SetSheetsFilterCriteriaCommand.id,{unitId:this._filterModel.unitId,subUnitId:this._filterModel.subUnitId,col:this.col,criteria:null});{a.filters={};const m=n.filter(f=>f.key!=="empty");m.length>0&&(a.filters={filters:m.flatMap(f=>f.originValues?Array.from(f.originValues):[f.title])}),m.length!==n.length&&(a.filters.blank=!0)}return this._commandService.executeCommand(u.SetSheetsFilterCriteriaCommand.id,{unitId:this._filterModel.unitId,subUnitId:this._filterModel.subUnitId,col:this.col,criteria:a})}};he=Ne([ce(4,c.ICommandService)],he);const X="FILTER_PANEL_OPENED",ne={id:"sheet.operation.open-filter-panel",type:c.CommandType.OPERATION,handler:(t,e)=>{const r=t.get(c.IContextService),n=t.get(u.SheetsFilterService),o=t.get(Q);t.get(c.ICommandService).syncExecuteCommand(U.SetCellEditVisibleOperation.id,{visible:!1});const{unitId:i,subUnitId:s,col:a}=e,m=n.getFilterModel(i,s);return m?(o.setupCol(m,a),r.getContextValue(X)||r.setContextValue(X,!0),!0):!1}},Z={id:"sheet.operation.close-filter-panel",type:c.CommandType.OPERATION,handler:t=>{const e=t.get(c.IContextService),r=t.get(Q),n=t.get(T.ILayoutService,c.Quantity.OPTIONAL);return e.getContextValue(X)?(e.setContextValue(X,!1),n==null||n.focus(),r.terminate()):!1}},Fe={id:"sheet.operation.apply-filter",type:c.CommandType.OPERATION,handler:(t,e)=>{const{filterBy:r}=e;return t.get(Q).changeFilterBy(r)}},De="sheets-filter-ui.config",pe={};var tt=Object.getOwnPropertyDescriptor,rt=(t,e,r,n)=>{for(var o=n>1?void 0:n?tt(e,r):e,l=t.length-1,i;l>=0;l--)(i=t[l])&&(o=i(o)||o);return o},z=(t,e)=>(r,n)=>e(r,n,t);let J=class extends c.Disposable{constructor(t,e,r,n,o,l){super(),this._sheetsFilterService=t,this._localeService=e,this._commandService=r,this._sheetPermissionCheckPermission=n,this._injector=o,this._sheetsSelectionService=l,this._commandExecutedListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.beforeCommandExecuted(t=>{var e,r,n;if(t.id===u.SmartToggleSheetsFilterCommand.id){const o=this._injector.get(c.IUniverInstanceService),l=N.getSheetCommandTarget(o);if(!l)return;const{unitId:i,subUnitId:s,worksheet:a}=l,m=(e=this._sheetsFilterService.getFilterModel(i,s))==null?void 0:e.getRange();let h;if(m)h=this._sheetPermissionCheckPermission.permissionCheckWithRanges({rangeTypes:[N.RangeProtectionPermissionViewPoint],worksheetTypes:[N.WorksheetFilterPermission,N.WorksheetViewPermission]},[m]);else{const f=(r=this._sheetsSelectionService.getCurrentLastSelection())==null?void 0:r.range;if(f){let O={...f};O=f.startColumn===f.endColumn&&f.startRow===f.endRow?N.expandToContinuousRange(O,{left:!0,right:!0,up:!0,down:!0},a):O,h=this._sheetPermissionCheckPermission.permissionCheckWithRanges({rangeTypes:[N.RangeProtectionPermissionViewPoint],worksheetTypes:[N.WorksheetViewPermission,N.WorksheetFilterPermission]},[O],i,s)}else h=this._sheetPermissionCheckPermission.permissionCheckWithoutRange({rangeTypes:[N.RangeProtectionPermissionViewPoint],worksheetTypes:[N.WorksheetViewPermission,N.WorksheetFilterPermission]})}h||this._sheetPermissionCheckPermission.blockExecuteWithoutPermission(this._localeService.t("permission.dialog.filterErr"))}if(t.id===ne.id){const o=t.params,{unitId:l,subUnitId:i}=o,s=(n=this._sheetsFilterService.getFilterModel(l,i))==null?void 0:n.getRange(),a=c.Tools.deepClone(s);a&&(a.startColumn=o.col,a.endColumn=o.col,this._sheetPermissionCheckPermission.permissionCheckWithRanges({rangeTypes:[N.RangeProtectionPermissionViewPoint],worksheetTypes:[N.WorksheetFilterPermission,N.WorksheetViewPermission]},[a])||this._sheetPermissionCheckPermission.blockExecuteWithoutPermission(this._localeService.t("permission.dialog.filterErr")))}}))}};J=rt([z(0,c.Inject(u.SheetsFilterService)),z(1,c.Inject(c.LocaleService)),z(2,c.ICommandService),z(3,c.Inject(N.SheetPermissionCheckController)),z(4,c.Inject(c.Injector)),z(5,c.Inject(N.SheetsSelectionsService))],J);const j=16,it=new Path2D("M3.30363 3C2.79117 3 2.51457 3.60097 2.84788 3.99024L6.8 8.60593V12.5662C6.8 12.7184 6.8864 12.8575 7.02289 12.9249L8.76717 13.7863C8.96655 13.8847 9.2 13.7396 9.2 13.5173V8.60593L13.1521 3.99024C13.4854 3.60097 13.2088 3 12.6964 3H3.30363Z");class ke{static drawNoCriteria(e,r,n,o){e.save(),re.Rect.drawWith(e,{radius:2,width:j,height:j,fill:o}),e.lineCap="square",e.strokeStyle=n,e.scale(r/j,r/j),e.beginPath(),e.lineWidth=1,e.lineCap="round",e.moveTo(3,4),e.lineTo(13,4),e.moveTo(4.5,8),e.lineTo(11.5,8),e.moveTo(6,12),e.lineTo(10,12),e.stroke(),e.restore()}static drawHasCriteria(e,r,n,o){e.save(),re.Rect.drawWith(e,{radius:2,width:j,height:j,fill:o}),e.scale(r/j,r/j),e.fillStyle=n,e.fill(it),e.restore()}}var nt=Object.getOwnPropertyDescriptor,ot=(t,e,r,n)=>{for(var o=n>1?void 0:n?nt(e,r):e,l=t.length-1,i;l>=0;l--)(i=t[l])&&(o=i(o)||o);return o},ye=(t,e)=>(r,n)=>e(r,n,t);const x=16,de=1;let Pe=class extends re.Shape{constructor(e,r,n,o,l){super(e,r);S(this,"_cellWidth",0);S(this,"_cellHeight",0);S(this,"_filterParams");S(this,"_hovered",!1);this._contextService=n,this._commandService=o,this._themeService=l,this.setShapeProps(r),this.onPointerDown$.subscribeEvent(i=>this.onPointerDown(i)),this.onPointerEnter$.subscribeEvent(()=>this.onPointerEnter()),this.onPointerLeave$.subscribeEvent(()=>this.onPointerLeave())}setShapeProps(e){typeof e.cellHeight<"u"&&(this._cellHeight=e.cellHeight),typeof e.cellWidth<"u"&&(this._cellWidth=e.cellWidth),typeof e.filterParams<"u"&&(this._filterParams=e.filterParams),this.transformByState({width:e.width,height:e.height})}_draw(e){const r=this._cellHeight,n=this._cellWidth,o=x-n,l=x-r;e.save();const i=new Path2D;i.rect(o,l,n,r),e.clip(i);const{hasCriteria:s}=this._filterParams,a=this._themeService.getColorFromTheme("primary.600"),m=this._hovered?this._themeService.getColorFromTheme("gray.50"):"rgba(255, 255, 255, 1.0)";s?ke.drawHasCriteria(e,x,a,m):ke.drawNoCriteria(e,x,a,m),e.restore()}onPointerDown(e){if(e.button===2)return;const{col:r,unitId:n,subUnitId:o}=this._filterParams;this._contextService.getContextValue(X)||!this._commandService.hasCommand(ne.id)||setTimeout(()=>{this._commandService.executeCommand(ne.id,{unitId:n,subUnitId:o,col:r})},200)}onPointerEnter(){this._hovered=!0,this.makeDirty(!0)}onPointerLeave(){this._hovered=!1,this.makeDirty(!0)}};Pe=ot([ye(2,c.IContextService),ye(3,c.ICommandService),ye(4,c.Inject(c.ThemeService))],Pe);var st=Object.getOwnPropertyDescriptor,at=(t,e,r,n)=>{for(var o=n>1?void 0:n?st(e,r):e,l=t.length-1,i;l>=0;l--)(i=t[l])&&(o=i(o)||o);return o},Y=(t,e)=>(r,n)=>e(r,n,t);const lt=1e3,ct=5e3;let be=class extends c.RxDisposable{constructor(e,r,n,o,l,i,s,a){super();S(this,"_filterRangeShape",null);S(this,"_buttonRenderDisposable",null);S(this,"_filterButtonShapes",[]);this._context=e,this._injector=r,this._sheetSkeletonManagerService=n,this._sheetsFilterService=o,this._themeService=l,this._sheetInterceptorService=i,this._commandService=s,this._selectionRenderService=a,this._initRenderer()}dispose(){super.dispose(),this._disposeRendering()}_initRenderer(){this._sheetSkeletonManagerService.currentSkeleton$.pipe(C.switchMap(e=>{var s,a;if(!e)return C.of(null);const{unit:r,unitId:n}=this._context,o=((s=r.getActiveSheet())==null?void 0:s.getSheetId())||"",l=(a=this._sheetsFilterService.getFilterModel(n,o))!=null?a:void 0,i=()=>({unitId:n,worksheetId:o,filterModel:l,range:l==null?void 0:l.getRange(),skeleton:e.skeleton});return c.fromCallback(this._commandService.onCommandExecuted.bind(this._commandService)).pipe(C.filter(([m])=>{var h;return m.type===c.CommandType.MUTATION&&((h=m.params)==null?void 0:h.unitId)===r.getUnitId()&&(u.FILTER_MUTATIONS.has(m.id)||m.id===N.SetRangeValuesMutation.id)}),C.throttleTime(20,void 0,{leading:!1,trailing:!0}),C.map(i),C.startWith(i()))}),C.takeUntil(this.dispose$)).subscribe(e=>{this._disposeRendering(),!(!e||!e.range)&&(this._renderRange(e.range,e.skeleton),this._renderButtons(e))})}_renderRange(e,r){const{scene:n}=this._context,{rowHeaderWidth:o,columnHeaderHeight:l}=r,i=this._filterRangeShape=new U.SelectionControl(n,lt,this._themeService,{rowHeaderWidth:o,columnHeaderHeight:l,enableAutoFill:!1,highlightHeader:!1}),s={range:e,primary:null,style:{fill:"rgba(0, 0, 0, 0.0)"}},a=U.attachSelectionWithCoord(s,r);i.updateRangeBySelectionWithCoord(a),i.setEvent(!1),n.makeDirty(!0)}_renderButtons(e){const{range:r,filterModel:n,unitId:o,skeleton:l,worksheetId:i}=e,{scene:s}=this._context;this._interceptCellContent(o,i,e.range);const{startColumn:a,endColumn:m,startRow:h}=r;for(let f=a;f<=m;f++){const O=`sheets-filter-button-${f}`,_=U.getCoordByCell(h,f,s,l),{startX:I,startY:E,endX:A,endY:F}=_,w=A-I,M=F-E;if(M<=de||w<=de)continue;const H=!!n.getFilterColumn(f),B=A-x-de,_e=F-x-de,Se={left:B,top:_e,height:x,width:x,zIndex:ct,cellHeight:M,cellWidth:w,filterParams:{unitId:o,subUnitId:i,col:f,hasCriteria:H}},L=this._injector.createInstance(Pe,O,Se);this._filterButtonShapes.push(L)}s.addObjects(this._filterButtonShapes),s.makeDirty()}_interceptCellContent(e,r,n){const{startRow:o,startColumn:l,endColumn:i}=n;this._buttonRenderDisposable=this._sheetInterceptorService.intercept(N.INTERCEPTOR_POINT.CELL_CONTENT,{effect:c.InterceptorEffectEnum.Style,handler:(s,a,m)=>{const{row:h,col:f,unitId:O,subUnitId:_}=a;return O!==e||_!==r||h!==o||f<l||f>i||((!s||s===a.rawData)&&(s={...a.rawData}),s.fontRenderExtension={...s==null?void 0:s.fontRenderExtension,rightOffset:x}),m(s)},priority:10})}_disposeRendering(){var e,r;(e=this._filterRangeShape)==null||e.dispose(),this._filterButtonShapes.forEach(n=>n.dispose()),(r=this._buttonRenderDisposable)==null||r.dispose(),this._filterRangeShape=null,this._buttonRenderDisposable=null,this._filterButtonShapes=[]}};be=at([Y(1,c.Inject(c.Injector)),Y(2,c.Inject(U.SheetSkeletonManagerService)),Y(3,c.Inject(u.SheetsFilterService)),Y(4,c.Inject(c.ThemeService)),Y(5,c.Inject(N.SheetInterceptorService)),Y(6,c.ICommandService),Y(7,U.ISheetSelectionRenderService)],be);var ut=Object.getOwnPropertyDescriptor,mt=(t,e,r,n)=>{for(var o=n>1?void 0:n?ut(e,r):e,l=t.length-1,i;l>=0;l--)(i=t[l])&&(o=i(o)||o);return o},He=(t,e)=>(r,n)=>e(r,n,t);let oe=class extends c.RxDisposable{constructor(t,e){super(),this._renderManagerService=t,this._sheetsRenderService=e,[u.SetSheetsFilterRangeMutation,u.SetSheetsFilterCriteriaMutation,u.RemoveSheetsFilterMutation,u.ReCalcSheetsFilterMutation].forEach(r=>this.disposeWithMe(this._sheetsRenderService.registerSkeletonChangingMutations(r.id))),this.disposeWithMe(this._renderManagerService.registerRenderModule(c.UniverInstanceType.UNIVER_SHEET,[be]))}};oe=mt([He(0,re.IRenderManagerService),He(1,c.Inject(U.SheetsRenderService))],oe);var ht=Object.defineProperty,pt=Object.getOwnPropertyDescriptor,dt=(t,e,r)=>e in t?ht(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,ft=(t,e,r,n)=>{for(var o=n>1?void 0:n?pt(e,r):e,l=t.length-1,i;l>=0;l--)(i=t[l])&&(o=i(o)||o);return o},Be=(t,e)=>(r,n)=>e(r,n,t),We=(t,e,r)=>dt(t,typeof e!="symbol"?e+"":e,r);const vt="SHEET_FILTER_UI_PLUGIN";v.UniverSheetsFilterMobileUIPlugin=class extends c.Plugin{constructor(e=pe,r,n){super(),this._config=e,this._injector=r,this._configService=n;const{menu:o,...l}=c.merge({},pe,this._config);o&&this._configService.setConfig("menu",o,{merge:!0}),this._configService.setConfig(De,l)}onStarting(){[[J],[oe]].forEach(e=>this._injector.add(e))}onReady(){this._injector.get(J)}onRendered(){this._injector.get(oe)}},We(v.UniverSheetsFilterMobileUIPlugin,"type",c.UniverInstanceType.UNIVER_SHEET),We(v.UniverSheetsFilterMobileUIPlugin,"pluginName",vt),v.UniverSheetsFilterMobileUIPlugin=ft([c.DependentOn(u.UniverSheetsFilterPlugin),Be(1,c.Inject(c.Injector)),Be(2,c.IConfigService)],v.UniverSheetsFilterMobileUIPlugin);var D=function(){return D=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++){e=arguments[r];for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o])}return t},D.apply(this,arguments)},_t=function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,n=Object.getOwnPropertySymbols(t);o<n.length;o++)e.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(t,n[o])&&(r[n[o]]=t[n[o]]);return r},xe=b.forwardRef(function(t,e){var r=t.icon,n=t.id,o=t.className,l=t.extend,i=_t(t,["icon","id","className","extend"]),s="univerjs-icon univerjs-icon-".concat(n," ").concat(o||"").trim(),a=b.useRef("_".concat(Ct()));return Ve(r,"".concat(n),{defIds:r.defIds,idSuffix:a.current},D({ref:e,className:s},i),l)});function Ve(t,e,r,n,o){return b.createElement(t.tag,D(D({key:e},St(t,r,o)),n),(gt(t,r).children||[]).map(function(l,i){return Ve(l,"".concat(e,"-").concat(t.tag,"-").concat(i),r,void 0,o)}))}function St(t,e,r){var n=D({},t.attrs);r!=null&&r.colorChannel1&&n.fill==="colorChannel1"&&(n.fill=r.colorChannel1),t.tag==="mask"&&n.id&&(n.id=n.id+e.idSuffix),Object.entries(n).forEach(function(l){var i=l[0],s=l[1];i==="mask"&&typeof s=="string"&&(n[i]=s.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))});var o=e.defIds;return!o||o.length===0||(t.tag==="use"&&n["xlink:href"]&&(n["xlink:href"]=n["xlink:href"]+e.idSuffix),Object.entries(n).forEach(function(l){var i=l[0],s=l[1];typeof s=="string"&&(n[i]=s.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))})),n}function gt(t,e){var r,n=e.defIds;return!n||n.length===0?t:t.tag==="defs"&&(!((r=t.children)===null||r===void 0)&&r.length)?D(D({},t),{children:t.children.map(function(o){return typeof o.attrs.id=="string"&&n&&n.includes(o.attrs.id)?D(D({},o),{attrs:D(D({},o.attrs),{id:o.attrs.id+e.idSuffix})}):o})}):t}function Ct(){return Math.random().toString(36).substring(2,8)}xe.displayName="UniverIcon";var Tt={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 17 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M3.32182 2.60967C2.98161 2.60967 2.79671 3.0074 3.01601 3.2675L6.85819 7.8246C6.94943 7.93282 6.99947 8.06981 6.99947 8.21136V12.7338C6.99947 12.898 7.0998 13.0455 7.2525 13.1058L8.73833 13.6928C9.00085 13.7965 9.28531 13.6031 9.28531 13.3208V8.21136C9.28531 8.06981 9.33535 7.93282 9.42659 7.8246L13.2688 3.2675C13.4881 3.0074 13.3032 2.60967 12.963 2.60967H3.32182ZM2.09858 4.04101C1.22139 3.0006 1.96097 1.40967 3.32182 1.40967H12.963C14.3238 1.40967 15.0634 3.0006 14.1862 4.04101L10.4853 8.43054V13.3208C10.4853 14.4498 9.34747 15.2237 8.29742 14.8089L6.81158 14.2219C6.20078 13.9806 5.79947 13.3905 5.79947 12.7338V8.43054L2.09858 4.04101Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Qe=b.forwardRef(function(t,e){return b.createElement(xe,Object.assign({},t,{id:"filter-icon",ref:e,icon:Tt}))});Qe.displayName="FilterIcon";function Et(t){var _,I;const{model:e}=t,r=T.useDependency(c.LocaleService),n=T.useObservable(e.conditionItem$,void 0),o=T.useObservable(e.filterConditionFormParams$,void 0),l=o!=null&&o.and?"AND":"OR",i=b.useCallback(E=>{e.onConditionFormChange({and:E==="AND"})},[e]),s=Ot(r),a=b.useCallback(E=>{e.onPrimaryConditionChange(E)},[e]),m=It(r),h=b.useCallback(E=>{e.onConditionFormChange(E)},[e]),f=r.t("sheets-filter.panel.input-values-placeholder");function O(E,A,F){const w=p.getItemByOperator(E).numOfParameters===1;return d.jsxs(d.Fragment,{children:[F==="operator2"&&d.jsxs(y.RadioGroup,{value:l,onChange:i,children:[d.jsx(y.Radio,{value:"AND",children:r.t("sheets-filter.panel.and")}),d.jsx(y.Radio,{value:"OR",children:r.t("sheets-filter.panel.or")})]}),d.jsx(y.Select,{value:E,options:m,onChange:M=>h({[F]:M})}),w&&d.jsx("div",{children:d.jsx(y.Input,{className:"univer-mt-2",value:A,placeholder:f,onChange:M=>h({[F==="operator1"?"val1":"val2"]:M})})})]})}return d.jsx("div",{"data-u-comp":"sheets-filter-panel-conditions-container",className:"univer-flex univer-h-full univer-min-h-[300px] univer-flex-col",children:n&&o&&d.jsxs(d.Fragment,{children:[d.jsx(y.Select,{value:n.operator,options:s,onChange:a}),p.getItemByOperator(n.operator).numOfParameters!==0?d.jsxs("div",{"data-u-comp":"sheets-filter-panel-conditions-container-inner",className:y.clsx("univer-mt-2 univer-flex-grow univer-overflow-hidden univer-rounded-md univer-p-2",y.borderClassName),children:[n.numOfParameters>=1&&O(o.operator1,(_=o.val1)!=null?_:"","operator1"),n.numOfParameters>=2&&O(o.operator2,(I=o.val2)!=null?I:"","operator2"),d.jsxs("div",{"data-u-comp":"sheets-filter-panel-conditions-desc",className:"univer-mt-2 univer-text-xs univer-text-gray-500",children:[r.t("sheets-filter.panel.?"),d.jsx("br",{}),r.t("sheets-filter.panel.*")]})]}):null]})})}function Ot(t){const e=t.getCurrentLocale();return b.useMemo(()=>[{options:[{label:t.t(p.NONE.label),value:p.NONE.operator}]},{options:[{label:t.t(p.EMPTY.label),value:p.EMPTY.operator},{label:t.t(p.NOT_EMPTY.label),value:p.NOT_EMPTY.operator}]},{options:[{label:t.t(p.TEXT_CONTAINS.label),value:p.TEXT_CONTAINS.operator},{label:t.t(p.DOES_NOT_CONTAIN.label),value:p.DOES_NOT_CONTAIN.operator},{label:t.t(p.STARTS_WITH.label),value:p.STARTS_WITH.operator},{label:t.t(p.ENDS_WITH.label),value:p.ENDS_WITH.operator},{label:t.t(p.EQUALS.label),value:p.EQUALS.operator}]},{options:[{label:t.t(p.GREATER_THAN.label),value:p.GREATER_THAN.operator},{label:t.t(p.GREATER_THAN_OR_EQUAL.label),value:p.GREATER_THAN_OR_EQUAL.operator},{label:t.t(p.LESS_THAN.label),value:p.LESS_THAN.operator},{label:t.t(p.LESS_THAN_OR_EQUAL.label),value:p.LESS_THAN_OR_EQUAL.operator},{label:t.t(p.EQUAL.label),value:p.EQUAL.operator},{label:t.t(p.NOT_EQUAL.label),value:p.NOT_EQUAL.operator},{label:t.t(p.BETWEEN.label),value:p.BETWEEN.operator},{label:t.t(p.NOT_BETWEEN.label),value:p.NOT_BETWEEN.operator}]},{options:[{label:t.t(p.CUSTOM.label),value:p.CUSTOM.operator}]}],[e,t])}function It(t){const e=t.getCurrentLocale();return b.useMemo(()=>p.ALL_CONDITIONS.filter(r=>r.numOfParameters!==2).map(r=>({label:t.t(r.label),value:r.operator})),[e,t])}function Nt(t){const{model:e}=t,r=T.useDependency(c.LocaleService),n=T.useObservable(e.searchString$,"",!0),o=T.useObservable(e.filterItems$,void 0,!0),l=r.t("sheets-filter.panel.filter-only"),i=Ce(o),s=i.checked>0&&i.unchecked===0,a=i.checked>0&&i.unchecked>0,m=e.treeMapCache,h=b.useCallback(()=>{e.onCheckAllToggled(!s)},[e,s]),f=b.useCallback(_=>{e.setSearchString(_)},[e]);function O(_){let I=[];return _.forEach(E=>{E.checked&&I.push(E.key),E.children&&(I=I.concat(O(E.children)))}),I}return d.jsxs("div",{"data-u-comp":"sheets-filter-panel-values-container",className:"univer-flex univer-h-full univer-min-h-[300px] univer-flex-col",children:[d.jsx(y.Input,{autoFocus:!0,value:n,placeholder:r.t("sheets-filter.panel.search-placeholder"),onChange:f}),d.jsxs("div",{"data-u-comp":"sheets-filter-panel",className:y.clsx("univer-mt-2 univer-box-border univer-flex univer-flex-grow univer-flex-col univer-overflow-hidden univer-rounded-md univer-px-2 univer-py-2.5",y.borderClassName),children:[d.jsx("div",{"data-u-comp":"sheets-filter-panel-values-item",className:"univer-box-border univer-h-8 univer-w-full univer-py-0.5",children:d.jsxs("div",{"data-u-comp":"sheets-filter-panel-values-item-inner",className:"univer-box-border univer-flex univer-h-7 univer-items-center univer-rounded-md univer-pb-0 univer-pl-5 univer-pr-0.5 univer-pt-0 univer-text-sm",children:[d.jsx(y.Checkbox,{indeterminate:a,disabled:o.length===0,checked:s,onChange:h}),d.jsx("span",{"data-u-comp":"sheets-filter-panel-values-item-text",className:"univer-mx-1 univer-inline-block univer-flex-shrink univer-overflow-hidden univer-text-ellipsis univer-whitespace-nowrap univer-text-gray-900 dark:!univer-text-white",children:`${r.t("sheets-filter.panel.select-all")}`}),d.jsx("span",{"data-u-comp":"sheets-filter-panel-values-item-count",className:"univer-text-gray-400 dark:!univer-text-gray-500",children:`(${i.checked}/${i.checked+i.unchecked})`})]})}),d.jsx("div",{"data-u-comp":"sheets-filter-panel-values-virtual",className:"univer-flex-grow",children:d.jsx(y.Tree,{data:o,defaultExpandAll:!1,valueGroup:O(o),onChange:_=>{e.onFilterCheckToggled(_)},defaultCache:m,itemHeight:28,treeNodeClassName:`
|
|
1
|
+
(function(_,c){typeof exports=="object"&&typeof module<"u"?c(exports,require("@univerjs/core"),require("@univerjs/sheets-filter"),require("@univerjs/ui"),require("@univerjs/sheets-ui"),require("@univerjs/sheets"),require("rxjs"),require("@univerjs/engine-render"),require("@univerjs/rpc"),require("@univerjs/design"),require("react/jsx-runtime"),require("react")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/sheets-filter","@univerjs/ui","@univerjs/sheets-ui","@univerjs/sheets","rxjs","@univerjs/engine-render","@univerjs/rpc","@univerjs/design","react/jsx-runtime","react"],c):(_=typeof globalThis<"u"?globalThis:_||self,c(_.UniverSheetsFilterUi={},_.UniverCore,_.UniverSheetsFilter,_.UniverUi,_.UniverSheetsUi,_.UniverSheets,_.rxjs,_.UniverEngineRender,_.UniverRpc,_.UniverDesign,_.React,_.React))})(this,function(_,c,u,T,U,N,C,re,ae,y,d,b){"use strict";var jt=Object.defineProperty;var Gt=(_,c,u)=>c in _?jt(_,c,{enumerable:!0,configurable:!0,writable:!0,value:u}):_[c]=u;var S=(_,c,u)=>Gt(_,typeof c!="symbol"?c+"":c,u);var _e;var P=(t=>(t[t.FIRST=0]="FIRST",t[t.SECOND=1]="SECOND",t))(P||{}),g=(t=>(t.NONE="none",t.STARTS_WITH="startsWith",t.DOES_NOT_START_WITH="doesNotStartWith",t.ENDS_WITH="endsWith",t.DOES_NOT_END_WITH="doesNotEndWith",t.CONTAINS="contains",t.DOES_NOT_CONTAIN="doesNotContain",t.EQUALS="equals",t.NOT_EQUALS="notEquals",t.EMPTY="empty",t.NOT_EMPTY="notEmpty",t.BETWEEN="between",t.NOT_BETWEEN="notBetween",t.CUSTOM="custom",t))(g||{}),p;(t=>{t.NONE={label:"sheets-filter.conditions.none",operator:g.NONE,order:P.SECOND,numOfParameters:0,getDefaultFormParams:()=>{throw new Error("[FilterConditionItems.NONE]: should not have initial form params!")},testMappingParams:i=>i.operator1===g.NONE,mapToFilterColumn:()=>null,testMappingFilterColumn:i=>!i.customFilters&&!i.filters?{}:!1},t.EMPTY={label:"sheets-filter.conditions.empty",operator:g.EMPTY,order:P.SECOND,numOfParameters:0,getDefaultFormParams:()=>{throw new Error("[FilterConditionItems.EMPTY]: should not have initial form params!")},testMappingParams:({operator1:i})=>i===g.EMPTY,mapToFilterColumn:()=>({customFilters:{customFilters:[{val:""}]}}),testMappingFilterColumn:i=>{var m;if(((m=i.customFilters)==null?void 0:m.customFilters.length)!==1)return!1;const s=i.customFilters.customFilters[0];return s.val===""&&s.operator===void 0?{operator1:g.EMPTY}:!1}},t.NOT_EMPTY={label:"sheets-filter.conditions.not-empty",operator:g.NOT_EMPTY,order:P.SECOND,numOfParameters:0,getDefaultFormParams:()=>{throw new Error("[FilterConditionItems.NOT_EMPTY]: should not have initial form params!")},testMappingParams:({operator1:i})=>i===g.NOT_EMPTY,mapToFilterColumn:()=>({customFilters:{customFilters:[{val:"",operator:u.CustomFilterOperator.NOT_EQUALS}]}}),testMappingFilterColumn:i=>{var m;if(((m=i.customFilters)==null?void 0:m.customFilters.length)!==1)return!1;const s=i.customFilters.customFilters[0];return s.val===" "&&s.operator===u.CustomFilterOperator.NOT_EQUALS?{operator1:g.NOT_EMPTY}:!1}},t.TEXT_CONTAINS={label:"sheets-filter.conditions.text-contains",operator:g.CONTAINS,order:P.FIRST,numOfParameters:1,getDefaultFormParams:()=>({operator1:g.CONTAINS,val1:""}),testMappingParams:i=>{const[s]=k(i);return s===g.CONTAINS},mapToFilterColumn:i=>{const{val1:s}=i;return s===""?null:{customFilters:{customFilters:[{val:`*${s}*`}]}}},testMappingFilterColumn:i=>{var m;if(((m=i.customFilters)==null?void 0:m.customFilters.length)!==1)return!1;const s=i.customFilters.customFilters[0],a=s.val.toString();return!s.operator&&a.startsWith("*")&&a.endsWith("*")?{operator1:g.CONTAINS,val1:a.slice(1,-1)}:!1}},t.DOES_NOT_CONTAIN={label:"sheets-filter.conditions.does-not-contain",operator:g.DOES_NOT_CONTAIN,order:P.FIRST,numOfParameters:1,getDefaultFormParams:()=>({operator1:g.DOES_NOT_CONTAIN,val1:""}),mapToFilterColumn:i=>({customFilters:{customFilters:[{val:`*${i.val1}*`,operator:u.CustomFilterOperator.NOT_EQUALS}]}}),testMappingParams:i=>{const[s]=k(i);return s===g.DOES_NOT_CONTAIN},testMappingFilterColumn:i=>{var m;if(((m=i.customFilters)==null?void 0:m.customFilters.length)!==1)return!1;const s=i.customFilters.customFilters[0],a=s.val.toString();return s.operator===u.CustomFilterOperator.NOT_EQUALS&&a.startsWith("*")&&a.endsWith("*")?{operator1:g.DOES_NOT_CONTAIN,val1:a.slice(1,-1)}:!1}},t.STARTS_WITH={label:"sheets-filter.conditions.starts-with",operator:g.STARTS_WITH,order:P.FIRST,numOfParameters:1,getDefaultFormParams:()=>({operator1:g.STARTS_WITH,val1:""}),mapToFilterColumn:i=>({customFilters:{customFilters:[{val:`${i.val1}*`}]}}),testMappingParams:i=>{const[s]=k(i);return s===g.STARTS_WITH},testMappingFilterColumn:i=>{var m;if(((m=i.customFilters)==null?void 0:m.customFilters.length)!==1)return!1;const s=i.customFilters.customFilters[0],a=s.val.toString();return!s.operator&&a.endsWith("*")&&!a.startsWith("*")?{operator1:g.STARTS_WITH,val1:a.slice(0,-1)}:!1}},t.ENDS_WITH={label:"sheets-filter.conditions.ends-with",operator:g.ENDS_WITH,order:P.FIRST,numOfParameters:1,getDefaultFormParams:()=>({operator1:g.ENDS_WITH,val1:""}),mapToFilterColumn:i=>({customFilters:{customFilters:[{val:`*${i.val1}`}]}}),testMappingParams:i=>{const[s]=k(i);return s===g.ENDS_WITH},testMappingFilterColumn:i=>{var m;if(((m=i.customFilters)==null?void 0:m.customFilters.length)!==1)return!1;const s=i.customFilters.customFilters[0],a=s.val.toString();return!s.operator&&a.startsWith("*")&&!a.endsWith("*")?{operator1:g.ENDS_WITH,val1:a.slice(1)}:!1}},t.EQUALS={label:"sheets-filter.conditions.equals",operator:g.EQUALS,order:P.FIRST,numOfParameters:1,getDefaultFormParams:()=>({operator1:g.EQUALS,val1:""}),testMappingParams:i=>{const[s]=k(i);return s===g.EQUALS},mapToFilterColumn:i=>{const{val1:s}=i;return s===""?null:{customFilters:{customFilters:[{val:s}]}}},testMappingFilterColumn:i=>{var s,a,m;return((a=(s=i.filters)==null?void 0:s.filters)==null?void 0:a.length)===1?{operator1:g.EQUALS,val1:""}:((m=i.customFilters)==null?void 0:m.customFilters.length)===1&&!i.customFilters.customFilters[0].operator?{operator1:g.EQUALS,val1:i.customFilters.customFilters[0].val.toString()}:!1}},t.GREATER_THAN={label:"sheets-filter.conditions.greater-than",operator:u.CustomFilterOperator.GREATER_THAN,numOfParameters:1,order:P.FIRST,getDefaultFormParams:()=>({operator1:u.CustomFilterOperator.GREATER_THAN,val1:""}),mapToFilterColumn:i=>({customFilters:{customFilters:[{val:i.val1,operator:u.CustomFilterOperator.GREATER_THAN}]}}),testMappingParams:i=>{const[s]=k(i);return s===u.CustomFilterOperator.GREATER_THAN},testMappingFilterColumn:i=>{var a;if(((a=i.customFilters)==null?void 0:a.customFilters.length)!==1)return!1;const s=i.customFilters.customFilters[0];return s.operator!==u.CustomFilterOperator.GREATER_THAN?!1:{operator1:u.CustomFilterOperator.GREATER_THAN,val1:s.val.toString()}}},t.GREATER_THAN_OR_EQUAL={label:"sheets-filter.conditions.greater-than-or-equal",operator:u.CustomFilterOperator.GREATER_THAN_OR_EQUAL,numOfParameters:1,order:P.FIRST,getDefaultFormParams:()=>({operator1:u.CustomFilterOperator.GREATER_THAN_OR_EQUAL,val1:""}),testMappingParams:i=>{const[s]=k(i);return s===u.CustomFilterOperator.GREATER_THAN_OR_EQUAL},mapToFilterColumn:i=>({customFilters:{customFilters:[{val:i.val1,operator:u.CustomFilterOperator.GREATER_THAN_OR_EQUAL}]}}),testMappingFilterColumn:i=>{var a;if(((a=i.customFilters)==null?void 0:a.customFilters.length)!==1)return!1;const s=i.customFilters.customFilters[0];return s.operator!==u.CustomFilterOperator.GREATER_THAN_OR_EQUAL?!1:{operator1:u.CustomFilterOperator.GREATER_THAN_OR_EQUAL,val1:s.val.toString()}}},t.LESS_THAN={label:"sheets-filter.conditions.less-than",operator:u.CustomFilterOperator.LESS_THAN,numOfParameters:1,order:P.FIRST,getDefaultFormParams:()=>({operator1:u.CustomFilterOperator.LESS_THAN,val1:""}),testMappingParams:i=>{const[s]=k(i);return s===u.CustomFilterOperator.LESS_THAN},mapToFilterColumn:i=>({customFilters:{customFilters:[{val:i.val1,operator:u.CustomFilterOperator.LESS_THAN}]}}),testMappingFilterColumn:i=>{var a;if(((a=i.customFilters)==null?void 0:a.customFilters.length)!==1)return!1;const s=i.customFilters.customFilters[0];return s.operator!==u.CustomFilterOperator.LESS_THAN?!1:{operator1:u.CustomFilterOperator.LESS_THAN,val1:s.val.toString()}}},t.LESS_THAN_OR_EQUAL={label:"sheets-filter.conditions.less-than-or-equal",operator:u.CustomFilterOperator.LESS_THAN_OR_EQUAL,numOfParameters:1,order:P.FIRST,getDefaultFormParams:()=>({operator1:u.CustomFilterOperator.LESS_THAN_OR_EQUAL,val1:""}),testMappingParams:i=>{const[s]=k(i);return s===u.CustomFilterOperator.LESS_THAN_OR_EQUAL},mapToFilterColumn:i=>({customFilters:{customFilters:[{val:i.val1,operator:u.CustomFilterOperator.LESS_THAN_OR_EQUAL}]}}),testMappingFilterColumn:i=>{var a;if(((a=i.customFilters)==null?void 0:a.customFilters.length)!==1)return!1;const s=i.customFilters.customFilters[0];return s.operator!==u.CustomFilterOperator.LESS_THAN_OR_EQUAL?!1:{operator1:u.CustomFilterOperator.LESS_THAN_OR_EQUAL,val1:s.val.toString()}}},t.EQUAL={label:"sheets-filter.conditions.equal",operator:u.CustomFilterOperator.EQUAL,numOfParameters:1,order:P.FIRST,getDefaultFormParams:()=>({operator1:u.CustomFilterOperator.EQUAL,val1:""}),testMappingParams:i=>{const[s]=k(i);return s===u.CustomFilterOperator.EQUAL},mapToFilterColumn:i=>({customFilters:{customFilters:[{val:i.val1,operator:u.CustomFilterOperator.EQUAL}]}}),testMappingFilterColumn:i=>{var a;if(((a=i.customFilters)==null?void 0:a.customFilters.length)!==1)return!1;const s=i.customFilters.customFilters[0];return s.operator!==u.CustomFilterOperator.EQUAL?!1:{operator1:u.CustomFilterOperator.EQUAL,val1:s.val.toString()}}},t.NOT_EQUAL={label:"sheets-filter.conditions.not-equal",operator:u.CustomFilterOperator.NOT_EQUALS,numOfParameters:1,order:P.FIRST,getDefaultFormParams:()=>({operator1:u.CustomFilterOperator.NOT_EQUALS,val1:""}),testMappingParams:i=>{const[s]=k(i);return s===u.CustomFilterOperator.NOT_EQUALS},mapToFilterColumn:i=>({customFilters:{customFilters:[{val:i.val1,operator:u.CustomFilterOperator.NOT_EQUALS}]}}),testMappingFilterColumn:i=>{var a;if(((a=i.customFilters)==null?void 0:a.customFilters.length)!==1)return!1;const s=i.customFilters.customFilters[0];return s.operator!==u.CustomFilterOperator.NOT_EQUALS?!1:{operator1:u.CustomFilterOperator.NOT_EQUALS,val1:s.val.toString()}}},t.BETWEEN={label:"sheets-filter.conditions.between",operator:g.BETWEEN,order:P.SECOND,numOfParameters:2,getDefaultFormParams:()=>({and:!0,operator1:u.CustomFilterOperator.GREATER_THAN_OR_EQUAL,val1:"",operator2:u.CustomFilterOperator.LESS_THAN_OR_EQUAL,val2:""}),testMappingParams:i=>{const{and:s,operator1:a,operator2:m}=i;if(!s)return!1;const h=[a,m];return h.includes(u.CustomFilterOperator.GREATER_THAN_OR_EQUAL)&&h.includes(u.CustomFilterOperator.LESS_THAN_OR_EQUAL)},mapToFilterColumn:i=>{const{val1:s,val2:a,operator1:m}=i,h=m===u.CustomFilterOperator.GREATER_THAN_OR_EQUAL;return{customFilters:{and:c.BooleanNumber.TRUE,customFilters:[{val:h?s:a,operator:u.CustomFilterOperator.GREATER_THAN_OR_EQUAL},{val:h?a:s,operator:u.CustomFilterOperator.LESS_THAN_OR_EQUAL}]}}},testMappingFilterColumn:i=>{var m;if(((m=i.customFilters)==null?void 0:m.customFilters.length)!==2)return!1;const[s,a]=i.customFilters.customFilters;return s.operator===u.CustomFilterOperator.GREATER_THAN_OR_EQUAL&&a.operator===u.CustomFilterOperator.LESS_THAN_OR_EQUAL&&i.customFilters.and?{and:!0,operator1:u.CustomFilterOperator.GREATER_THAN_OR_EQUAL,val1:s.val.toString(),operator2:u.CustomFilterOperator.LESS_THAN_OR_EQUAL,val2:a.val.toString()}:a.operator===u.CustomFilterOperator.GREATER_THAN_OR_EQUAL&&s.operator===u.CustomFilterOperator.LESS_THAN_OR_EQUAL&&i.customFilters.and?{and:!0,operator1:u.CustomFilterOperator.GREATER_THAN_OR_EQUAL,val1:a.val.toString(),operator2:u.CustomFilterOperator.LESS_THAN_OR_EQUAL,val2:s.val.toLocaleString()}:!1}},t.NOT_BETWEEN={label:"sheets-filter.conditions.not-between",operator:g.NOT_BETWEEN,order:P.SECOND,numOfParameters:2,getDefaultFormParams:()=>({operator1:u.CustomFilterOperator.LESS_THAN,val1:"",operator2:u.CustomFilterOperator.GREATER_THAN,val2:""}),testMappingParams:i=>{const{and:s,operator1:a,operator2:m}=i;if(s)return!1;const h=[a,m];return h.includes(u.CustomFilterOperator.GREATER_THAN)&&h.includes(u.CustomFilterOperator.LESS_THAN)},mapToFilterColumn:i=>{const{val1:s,val2:a,operator1:m}=i,h=m===u.CustomFilterOperator.GREATER_THAN;return{customFilters:{customFilters:[{val:h?s:a,operator:u.CustomFilterOperator.GREATER_THAN},{val:h?a:s,operator:u.CustomFilterOperator.LESS_THAN}]}}},testMappingFilterColumn:i=>{var m;if(((m=i.customFilters)==null?void 0:m.customFilters.length)!==2)return!1;const[s,a]=i.customFilters.customFilters;return s.operator===u.CustomFilterOperator.LESS_THAN&&a.operator===u.CustomFilterOperator.GREATER_THAN&&!i.customFilters.and?{operator1:u.CustomFilterOperator.LESS_THAN,val1:s.val.toString(),operator2:u.CustomFilterOperator.GREATER_THAN,val2:a.val.toString()}:a.operator===u.CustomFilterOperator.LESS_THAN&&s.operator===u.CustomFilterOperator.GREATER_THAN&&!i.customFilters.and?{operator1:u.CustomFilterOperator.GREATER_THAN,val1:a.val.toString(),operator2:u.CustomFilterOperator.LESS_THAN,val2:s.val.toLocaleString()}:!1}},t.CUSTOM={label:"sheets-filter.conditions.custom",operator:g.CUSTOM,order:P.SECOND,numOfParameters:2,getDefaultFormParams:()=>({operator1:g.NONE,val1:"",operator2:g.NONE,val2:""}),testMappingParams:()=>!0,mapToFilterColumn:i=>{const{and:s,val1:a,val2:m,operator1:h,operator2:f}=i;function O(w,M){for(const H of t.ALL_CONDITIONS)if(H.operator===w)return H.mapToFilterColumn({val1:M,operator1:w})}const v=!h||h===t.NONE.operator,I=!f||f===t.NONE.operator;if(v&&I)return t.NONE.mapToFilterColumn({});if(v)return O(f,m);if(I)return O(h,a);const E=O(h,a),A=O(f,m),F={customFilters:[E.customFilters.customFilters[0],A.customFilters.customFilters[0]]};return s&&(F.and=c.BooleanNumber.TRUE),{customFilters:F}},testMappingFilterColumn:i=>{var m;if(((m=i.customFilters)==null?void 0:m.customFilters.length)!==2)return!1;const s=i.customFilters.customFilters.map(h=>l({customFilters:{customFilters:[h]}})),a={operator1:s[0][0].operator,val1:s[0][1].val1,operator2:s[1][0].operator,val2:s[1][1].val1};return i.customFilters.and&&(a.and=!0),a}},t.ALL_CONDITIONS=[t.NONE,t.EMPTY,t.NOT_EMPTY,t.TEXT_CONTAINS,t.DOES_NOT_CONTAIN,t.STARTS_WITH,t.ENDS_WITH,t.EQUALS,t.GREATER_THAN,t.GREATER_THAN_OR_EQUAL,t.LESS_THAN,t.LESS_THAN_OR_EQUAL,t.EQUAL,t.NOT_EQUAL,t.BETWEEN,t.NOT_BETWEEN,t.CUSTOM];function e(i){const s=t.ALL_CONDITIONS.find(a=>a.operator===i);if(!s)throw new Error(`[SheetsFilter]: no condition item found for operator: ${i}`);return s}t.getItemByOperator=e;function r(i,s){for(const a of t.ALL_CONDITIONS.filter(m=>m.numOfParameters===s))if(a.numOfParameters!==0&&a.testMappingParams(i))return a;for(const a of t.ALL_CONDITIONS)if(a.testMappingParams(i))return a;throw new Error("[SheetsFilter]: no condition item can be mapped from the filter map params!")}t.testMappingParams=r;function n(i){const s=t.ALL_CONDITIONS.find(a=>a.operator===i);return(s==null?void 0:s.numOfParameters)===0?{operator1:s.operator}:s.getDefaultFormParams()}t.getInitialFormParams=n;function o(i,s){return i.mapToFilterColumn(s)}t.mapToFilterColumn=o;function l(i){if(!i)return[t.NONE,{}];for(const s of t.ALL_CONDITIONS){const a=s.testMappingFilterColumn(i);if(a)return[s,a]}return[t.NONE,{}]}t.testMappingFilterColumn=l})(p||(p={}));function k(t){const{operator1:e,operator2:r,val1:n,val2:o}=t;if(e&&r)throw new Error("Both operator1 and operator2 are set!");if(!e&&!r)throw new Error("Neither operator1 and operator2 and both not set!");return e?[e,n]:[r,o]}function Ce(t){const e=[],r=[];let n=0,o=0;function l(i){i.leaf&&(i.checked?(e.push(i),n+=i.count):(r.push(i),o+=i.count)),i.children&&i.children.forEach(l)}return t.forEach(l),{checkedItems:e,uncheckedItems:r,checked:n,unchecked:o}}var Ke=Object.getOwnPropertyDescriptor,Xe=(t,e,r,n)=>{for(var o=n>1?void 0:n?Ke(e,r):e,l=t.length-1,i;l>=0;l--)(i=t[l])&&(o=i(o)||o);return o},Te=(t,e)=>(r,n)=>e(r,n,t);const Ee="sheets-filter.generate-filter-values.service",le=c.createIdentifier(Ee),Ze=["yyyy-mm-dd","yyyy-mm-dd;@","yyyy/mm/dd;@","yyyy/mm/dd hh:mm","yyyy-m-d am/pm h:mm","yyyy-MM-dd","yyyy/MM/dd","yyyy/mm/dd",'yyyy"年"MM"月"dd"日"',"MM-dd",'M"月"d"日"',"MM-dd A/P hh:mm"];let Oe=class extends c.Disposable{constructor(t,e,r){super(),this._localeService=t,this._univerInstanceService=e,this._logService=r}async getFilterValues(t){var h;const{unitId:e,subUnitId:r,filteredOutRowsByOtherColumns:n,filters:o,blankChecked:l,iterateRange:i,alreadyChecked:s}=t,a=this._univerInstanceService.getUnit(e),m=(h=this._univerInstanceService.getUnit(e))==null?void 0:h.getSheetBySheetId(r);return!a||!m?[]:(this._logService.debug("[SheetsGenerateFilterValuesService]","getFilterValues for",{unitId:e,subUnitId:r}),we(o,this._localeService,i,m,new Set(n),new Set(s.map(String)),l,a.getStyles()))}};Oe=Xe([Te(0,c.Inject(c.LocaleService)),Te(1,c.IUniverInstanceService),Te(2,c.ILogService)],Oe);function we(t,e,r,n,o,l,i,s){var E,A,F,w,M,H,B,ve,Se;const a=new Map,m=new Map,h="yyyy-mm-dd",f=new Set(Ze),O="empty";let v=0;for(const L of n.iterateByColumn(r,!1,!1)){const{row:Vt,rowSpan:qe=1}=L;let ee=0;for(;ee<qe;){const xt=Vt+ee;if(o.has(xt)){ee++;continue}const q=L!=null&&L.value?c.extractPureTextFromCell(L.value):"";if(!q){v+=1,ee+=qe;continue}const ge=(E=L.value)!=null&&E.v&&!L.value.p?(w=(F=s.get((A=L.value)==null?void 0:A.s))==null?void 0:F.n)==null?void 0:w.pattern:"",Qt=ge&&c.numfmt.getFormatInfo(ge).isDate;if(ge&&Qt&&f.has(ge)){const G=(M=n.getCellRaw(L.row,L.col))==null?void 0:M.v;if(!G){ee++;continue}const te=c.numfmt.format(h,G),[R,W,se]=te.split("-").map(Number);let K=a.get(`${R}`);K||(K={title:`${R}`,key:`${R}`,children:[],count:0,leaf:!1,checked:!1},a.set(`${R}`,K),m.set(`${R}`,[`${R}`]));let x=(H=K.children)==null?void 0:H.find(Me=>Me.key===`${R}-${W}`);x||(x={title:e.t(`sheets-filter.date.${W}`),key:`${R}-${W}`,children:[],count:0,leaf:!1,checked:!1},(B=K.children)==null||B.push(x),m.set(`${R}-${W}`,[`${R}`,`${R}-${W}`]));const Re=(ve=x==null?void 0:x.children)==null?void 0:ve.find(Me=>Me.key===`${R}-${W}-${se}`);Re?(Re.originValues.add(q),Re.count++,x.count++,K.count++):((Se=x.children)==null||Se.push({title:`${se}`,key:`${R}-${W}-${se}`,count:1,originValues:new Set([q]),leaf:!0,checked:l.size?l.has(q):!i}),x.count++,K.count++,m.set(`${R}-${W}-${se}`,[`${R}`,`${R}-${W}`,`${R}-${W}-${se}`]))}else{const G=q;let te=a.get(G);te?te.count++:(te={title:q,leaf:!0,checked:l.size?l.has(q):!i,key:G,count:1},a.set(G,te),m.set(G,[G]))}ee++}}const I=t?i:!0;if(v>0){const L={title:e.t("sheets-filter.panel.empty"),count:v,leaf:!0,checked:I,key:O};a.set("empty",L),m.set("empty",[O])}return{filterTreeItems:ze(Array.from(a.values())),filterTreeMapCache:m}}function ze(t){return Array.from(t).sort((e,r)=>e.children&&!r.children?-1:!e.children&&r.children?1:Je(e.title,r.title)).map(e=>(e.children&&e.children.sort((r,n)=>{const o=Number.parseInt(r.key.split("-")[1],10),l=Number.parseInt(n.key.split("-")[1],10);return o-l}).forEach(r=>{r.children&&r.children.sort((n,o)=>{const l=Number.parseInt(n.key.split("-")[2],10),i=Number.parseInt(o.key.split("-")[2],10);return l-i})}),e))}const Le=t=>!Number.isNaN(Number(t))&&!Number.isNaN(Number.parseFloat(t));function Je(t,e){const r=Le(t),n=Le(e);return r&&n?Number.parseFloat(t)-Number.parseFloat(e):r&&!n?-1:!r&&n?1:t.localeCompare(e)}function Ie(t,e){for(const r of t){if(r.key===e)return r;if(r.children){const n=Ie(r.children,e);if(n)return n}}return null}function Ue(t){return t.leaf?t.checked:t.children?t.children.every(e=>Ue(e)):!0}function ie(t,e){t.leaf&&(e!==void 0?t.checked=e:t.checked=!t.checked),t.children&&t.children.forEach(r=>ie(r,e))}function $e(t,e){const r=[];return t.forEach(n=>{const o=n.originValues?e.some(s=>Array.from(n.originValues).some(a=>a.toLowerCase().includes(s.toLowerCase()))):!1,l=!o&&e.some(s=>n.title.toLowerCase().includes(s.toLowerCase()));if(o||l)r.push({...n});else if(n.children){const s=$e(n.children,e);if(s.length>0){const a=s.reduce((m,h)=>m+h.count,0);r.push({...n,count:a,children:s})}}}),r}var et=Object.getOwnPropertyDescriptor,Ne=(t,e,r,n)=>{for(var o=n>1?void 0:n?et(e,r):e,l=t.length-1,i;l>=0;l--)(i=t[l])&&(o=i(o)||o);return o},ce=(t,e)=>(r,n)=>e(r,n,t),ue=(t=>(t[t.VALUES=0]="VALUES",t[t.CONDITIONS=1]="CONDITIONS",t))(ue||{});c.createIdentifier("sheets-filter-ui.sheets-filter-panel.service");let Q=class extends c.Disposable{constructor(e,r){super();S(this,"_filterBy$",new C.BehaviorSubject(0));S(this,"filterBy$",this._filterBy$.asObservable());S(this,"_filterByModel$",new C.ReplaySubject(1));S(this,"filterByModel$",this._filterByModel$.asObservable());S(this,"_filterByModel",null);S(this,"_hasCriteria$",new C.BehaviorSubject(!1));S(this,"hasCriteria$",this._hasCriteria$.asObservable());S(this,"_filterModel",null);S(this,"_col$",new C.BehaviorSubject(-1));S(this,"col$",this._col$.asObservable());S(this,"_filterHeaderListener",null);this._injector=e,this._refRangeService=r}get filterBy(){return this._filterBy$.getValue()}get filterByModel(){return this._filterByModel}set filterByModel(e){this._filterByModel=e,this._filterByModel$.next(e)}get filterModel(){return this._filterModel}get col(){return this._col$.getValue()}dispose(){this._filterBy$.complete(),this._filterByModel$.complete(),this._hasCriteria$.complete()}setupCol(e,r){this.terminate(),this._filterModel=e,this._col$.next(r);const n=e.getFilterColumn(r);if(n){const o=n.getColumnData();if(o.customFilters){this._hasCriteria$.next(!0),this._setupByConditions(e,r);return}if(o.filters){this._hasCriteria$.next(!0),this._setupByValues(e,r);return}this._hasCriteria$.next(!1),this._setupByValues(e,r);return}this._hasCriteria$.next(!1),this._setupByValues(e,r)}changeFilterBy(e){return!this._filterModel||this.col===-1?!1:(e===0?this._setupByValues(this._filterModel,this.col):this._setupByConditions(this._filterModel,this.col),!0)}terminate(){return this._filterModel=null,this._col$.next(-1),this._disposeFilterHeaderChangeListener(),!0}_disposeFilterHeaderChangeListener(){var e;(e=this._filterHeaderListener)==null||e.dispose(),this._filterHeaderListener=null}_listenToFilterHeaderChange(e,r){this._disposeFilterHeaderChangeListener();const n=e.unitId,o=e.subUnitId,l=e.getRange(),i={startColumn:r,startRow:l.startRow,endRow:l.startRow,endColumn:r};this._filterHeaderListener=this._refRangeService.watchRange(n,o,i,(s,a)=>{if(!a)this.terminate();else{const m=a.startColumn-s.startColumn;m!==0&&this._filterByModel.deltaCol(m)}})}async _setupByValues(e,r){this._disposePreviousModel();const n=e.getRange();if(n.startRow===n.endRow)return!1;const o=await he.fromFilterColumn(this._injector,e,r);return this.filterByModel=o,this._filterBy$.next(0),this._listenToFilterHeaderChange(e,r),!0}_setupByConditions(e,r){this._disposePreviousModel();const n=e.getRange();if(n.startRow===n.endRow)return!1;const o=me.fromFilterColumn(this._injector,e,r,e.getFilterColumn(r));return this.filterByModel=o,this._filterBy$.next(1),this._listenToFilterHeaderChange(e,r),!0}_disposePreviousModel(){var e;(e=this._filterByModel)==null||e.dispose(),this.filterByModel=null}};Q=Ne([ce(0,c.Inject(c.Injector)),ce(1,c.Inject(N.RefRangeService))],Q);let me=class extends c.Disposable{constructor(e,r,n,o,l){super();S(this,"canApply$",C.of(!0));S(this,"_conditionItem$");S(this,"conditionItem$");S(this,"_filterConditionFormParams$");S(this,"filterConditionFormParams$");this._filterModel=e,this.col=r,this._commandService=l,this._conditionItem$=new C.BehaviorSubject(n),this.conditionItem$=this._conditionItem$.asObservable(),this._filterConditionFormParams$=new C.BehaviorSubject(o),this.filterConditionFormParams$=this._filterConditionFormParams$.asObservable()}static fromFilterColumn(e,r,n,o){const[l,i]=p.testMappingFilterColumn(o==null?void 0:o.getColumnData());return e.createInstance(me,r,n,l,i)}get conditionItem(){return this._conditionItem$.getValue()}get filterConditionFormParams(){return this._filterConditionFormParams$.getValue()}dispose(){super.dispose(),this._conditionItem$.complete(),this._filterConditionFormParams$.complete()}deltaCol(e){this.col+=e}clear(){return this._disposed?Promise.resolve(!1):this._commandService.executeCommand(u.SetSheetsFilterCriteriaCommand.id,{unitId:this._filterModel.unitId,subUnitId:this._filterModel.subUnitId,col:this.col,criteria:null})}async apply(){if(this._disposed)return!1;const e=p.mapToFilterColumn(this.conditionItem,this.filterConditionFormParams);return this._commandService.executeCommand(u.SetSheetsFilterCriteriaCommand.id,{unitId:this._filterModel.unitId,subUnitId:this._filterModel.subUnitId,col:this.col,criteria:e})}onPrimaryConditionChange(e){const r=p.ALL_CONDITIONS.find(n=>n.operator===e);if(!r)throw new Error(`[ByConditionsModel]: condition item not found for operator: ${e}!`);this._conditionItem$.next(r),this._filterConditionFormParams$.next(p.getInitialFormParams(e))}onConditionFormChange(e){const r={...this.filterConditionFormParams,...e};if(r.and!==!0&&delete r.and,typeof e.and<"u"||typeof e.operator1<"u"||typeof e.operator2<"u"){const n=p.testMappingParams(r,this.conditionItem.numOfParameters);this._conditionItem$.next(n)}this._filterConditionFormParams$.next(r)}};me=Ne([ce(4,c.ICommandService)],me);let he=class extends c.Disposable{constructor(e,r,n,o,l){super();S(this,"_rawFilterItems$");S(this,"rawFilterItems$");S(this,"filterItems$");S(this,"_filterItems",[]);S(this,"_treeMapCache");S(this,"canApply$");S(this,"_manuallyUpdateFilterItems$");S(this,"_searchString$");S(this,"searchString$");this._filterModel=e,this.col=r,this._commandService=l,this._treeMapCache=o,this._searchString$=new C.BehaviorSubject(""),this.searchString$=this._searchString$.asObservable(),this._rawFilterItems$=new C.BehaviorSubject(n),this.rawFilterItems$=this._rawFilterItems$.asObservable(),this._manuallyUpdateFilterItems$=new C.Subject,this.filterItems$=C.merge(C.combineLatest([this._searchString$.pipe(C.throttleTime(500,void 0,{leading:!0,trailing:!0}),C.startWith(void 0)),this._rawFilterItems$]).pipe(C.map(([i,s])=>{if(!i)return s;const m=i.toLowerCase().split(/\s+/).filter(h=>!!h);return $e(s,m)})),this._manuallyUpdateFilterItems$).pipe(C.shareReplay(1)),this.canApply$=this.filterItems$.pipe(C.map(i=>Ce(i).checked>0)),this.disposeWithMe(this.filterItems$.subscribe(i=>this._filterItems=i))}static async fromFilterColumn(e,r,n){var H;const o=e.get(c.IUniverInstanceService),l=e.get(c.LocaleService),i=e.get(le,c.Quantity.OPTIONAL),{unitId:s,subUnitId:a}=r,m=o.getUniverSheetInstance(s);if(!m)throw new Error(`[ByValuesModel]: Workbook not found for filter model with unitId: ${s}!`);const h=m==null?void 0:m.getSheetBySheetId(a);if(!h)throw new Error(`[ByValuesModel]: Worksheet not found for filter model with unitId: ${s} and subUnitId: ${a}!`);const f=r.getRange(),O=n,v=(H=r.getFilterColumn(n))==null?void 0:H.getColumnData().filters,I=new Set(v==null?void 0:v.filters),E=!!(v&&v.blank),A=r.getFilteredOutRowsExceptCol(n),F={...f,startRow:f.startRow+1,startColumn:O,endColumn:O};let w,M;if(i){const B=await i.getFilterValues({unitId:s,subUnitId:a,filteredOutRowsByOtherColumns:Array.from(A),filters:!!v,blankChecked:E,iterateRange:F,alreadyChecked:Array.from(I)});w=B.filterTreeItems,M=B.filterTreeMapCache}else{const B=we(!!v,l,F,h,A,I,E,m.getStyles());w=B.filterTreeItems,M=B.filterTreeMapCache}return e.createInstance(he,r,n,w,M)}get rawFilterItems(){return this._rawFilterItems$.getValue()}get filterItems(){return this._filterItems}get treeMapCache(){return this._treeMapCache}dispose(){this._rawFilterItems$.complete(),this._searchString$.complete()}deltaCol(e){this.col+=e}setSearchString(e){this._searchString$.next(e)}onCheckAllToggled(e){const r=c.Tools.deepClone(this._filterItems);r.forEach(n=>ie(n,e)),this._manuallyUpdateFilterItems(r)}onFilterCheckToggled(e){const r=c.Tools.deepClone(this._filterItems),n=Ie(r,e.key);if(!n)return;const o=Ue(n);ie(n,!o),this._manuallyUpdateFilterItems(r)}onFilterOnly(e){const r=c.Tools.deepClone(this._filterItems);r.forEach(n=>ie(n,!1)),e.forEach(n=>{const o=Ie(r,n);o&&ie(o,!0)}),this._manuallyUpdateFilterItems(r)}_manuallyUpdateFilterItems(e){this._manuallyUpdateFilterItems$.next(e)}clear(){return this._disposed?Promise.resolve(!1):this._commandService.executeCommand(u.SetSheetsFilterCriteriaCommand.id,{unitId:this._filterModel.unitId,subUnitId:this._filterModel.subUnitId,col:this.col,criteria:null})}async apply(){if(this._disposed)return!1;const e=Ce(this._filterItems),{checked:r,checkedItems:n}=e,o=this.rawFilterItems;let l=0;for(const m of o)l+=m.count;const i=r===0,s=e.checked===l,a={colId:this.col};if(i)throw new Error("[ByValuesModel]: no checked items!");if(s)return this._commandService.executeCommand(u.SetSheetsFilterCriteriaCommand.id,{unitId:this._filterModel.unitId,subUnitId:this._filterModel.subUnitId,col:this.col,criteria:null});{a.filters={};const m=n.filter(f=>f.key!=="empty");m.length>0&&(a.filters={filters:m.flatMap(f=>f.originValues?Array.from(f.originValues):[f.title])}),m.length!==n.length&&(a.filters.blank=!0)}return this._commandService.executeCommand(u.SetSheetsFilterCriteriaCommand.id,{unitId:this._filterModel.unitId,subUnitId:this._filterModel.subUnitId,col:this.col,criteria:a})}};he=Ne([ce(4,c.ICommandService)],he);const X="FILTER_PANEL_OPENED",ne={id:"sheet.operation.open-filter-panel",type:c.CommandType.OPERATION,handler:(t,e)=>{const r=t.get(c.IContextService),n=t.get(u.SheetsFilterService),o=t.get(Q);t.get(c.ICommandService).syncExecuteCommand(U.SetCellEditVisibleOperation.id,{visible:!1});const{unitId:i,subUnitId:s,col:a}=e,m=n.getFilterModel(i,s);return m?(o.setupCol(m,a),r.getContextValue(X)||r.setContextValue(X,!0),!0):!1}},Z={id:"sheet.operation.close-filter-panel",type:c.CommandType.OPERATION,handler:t=>{const e=t.get(c.IContextService),r=t.get(Q),n=t.get(T.ILayoutService,c.Quantity.OPTIONAL);return e.getContextValue(X)?(e.setContextValue(X,!1),n==null||n.focus(),r.terminate()):!1}},Fe={id:"sheet.operation.apply-filter",type:c.CommandType.OPERATION,handler:(t,e)=>{const{filterBy:r}=e;return t.get(Q).changeFilterBy(r)}},De="sheets-filter-ui.config",pe={};var tt=Object.getOwnPropertyDescriptor,rt=(t,e,r,n)=>{for(var o=n>1?void 0:n?tt(e,r):e,l=t.length-1,i;l>=0;l--)(i=t[l])&&(o=i(o)||o);return o},z=(t,e)=>(r,n)=>e(r,n,t);let J=class extends c.Disposable{constructor(t,e,r,n,o,l){super(),this._sheetsFilterService=t,this._localeService=e,this._commandService=r,this._sheetPermissionCheckPermission=n,this._injector=o,this._sheetsSelectionService=l,this._commandExecutedListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.beforeCommandExecuted(t=>{var e,r,n;if(t.id===u.SmartToggleSheetsFilterCommand.id){const o=this._injector.get(c.IUniverInstanceService),l=N.getSheetCommandTarget(o);if(!l)return;const{unitId:i,subUnitId:s,worksheet:a}=l,m=(e=this._sheetsFilterService.getFilterModel(i,s))==null?void 0:e.getRange();let h;if(m)h=this._sheetPermissionCheckPermission.permissionCheckWithRanges({rangeTypes:[N.RangeProtectionPermissionViewPoint],worksheetTypes:[N.WorksheetFilterPermission,N.WorksheetViewPermission]},[m]);else{const f=(r=this._sheetsSelectionService.getCurrentLastSelection())==null?void 0:r.range;if(f){let O={...f};O=f.startColumn===f.endColumn&&f.startRow===f.endRow?N.expandToContinuousRange(O,{left:!0,right:!0,up:!0,down:!0},a):O,h=this._sheetPermissionCheckPermission.permissionCheckWithRanges({rangeTypes:[N.RangeProtectionPermissionViewPoint],worksheetTypes:[N.WorksheetViewPermission,N.WorksheetFilterPermission]},[O],i,s)}else h=this._sheetPermissionCheckPermission.permissionCheckWithoutRange({rangeTypes:[N.RangeProtectionPermissionViewPoint],worksheetTypes:[N.WorksheetViewPermission,N.WorksheetFilterPermission]})}h||this._sheetPermissionCheckPermission.blockExecuteWithoutPermission(this._localeService.t("permission.dialog.filterErr"))}if(t.id===ne.id){const o=t.params,{unitId:l,subUnitId:i}=o,s=(n=this._sheetsFilterService.getFilterModel(l,i))==null?void 0:n.getRange(),a=c.Tools.deepClone(s);a&&(a.startColumn=o.col,a.endColumn=o.col,this._sheetPermissionCheckPermission.permissionCheckWithRanges({rangeTypes:[N.RangeProtectionPermissionViewPoint],worksheetTypes:[N.WorksheetFilterPermission,N.WorksheetViewPermission]},[a])||this._sheetPermissionCheckPermission.blockExecuteWithoutPermission(this._localeService.t("permission.dialog.filterErr")))}}))}};J=rt([z(0,c.Inject(u.SheetsFilterService)),z(1,c.Inject(c.LocaleService)),z(2,c.ICommandService),z(3,c.Inject(N.SheetPermissionCheckController)),z(4,c.Inject(c.Injector)),z(5,c.Inject(N.SheetsSelectionsService))],J);const j=16,it=new Path2D("M3.30363 3C2.79117 3 2.51457 3.60097 2.84788 3.99024L6.8 8.60593V12.5662C6.8 12.7184 6.8864 12.8575 7.02289 12.9249L8.76717 13.7863C8.96655 13.8847 9.2 13.7396 9.2 13.5173V8.60593L13.1521 3.99024C13.4854 3.60097 13.2088 3 12.6964 3H3.30363Z");class ke{static drawNoCriteria(e,r,n,o){e.save(),re.Rect.drawWith(e,{radius:2,width:j,height:j,fill:o}),e.lineCap="square",e.strokeStyle=n,e.scale(r/j,r/j),e.beginPath(),e.lineWidth=1,e.lineCap="round",e.moveTo(3,4),e.lineTo(13,4),e.moveTo(4.5,8),e.lineTo(11.5,8),e.moveTo(6,12),e.lineTo(10,12),e.stroke(),e.restore()}static drawHasCriteria(e,r,n,o){e.save(),re.Rect.drawWith(e,{radius:2,width:j,height:j,fill:o}),e.scale(r/j,r/j),e.fillStyle=n,e.fill(it),e.restore()}}var nt=Object.getOwnPropertyDescriptor,ot=(t,e,r,n)=>{for(var o=n>1?void 0:n?nt(e,r):e,l=t.length-1,i;l>=0;l--)(i=t[l])&&(o=i(o)||o);return o},ye=(t,e)=>(r,n)=>e(r,n,t);const V=16,de=1;let Pe=class extends re.Shape{constructor(e,r,n,o,l){super(e,r);S(this,"_cellWidth",0);S(this,"_cellHeight",0);S(this,"_filterParams");S(this,"_hovered",!1);this._contextService=n,this._commandService=o,this._themeService=l,this.setShapeProps(r),this.onPointerDown$.subscribeEvent(i=>this.onPointerDown(i)),this.onPointerEnter$.subscribeEvent(()=>this.onPointerEnter()),this.onPointerLeave$.subscribeEvent(()=>this.onPointerLeave())}setShapeProps(e){typeof e.cellHeight<"u"&&(this._cellHeight=e.cellHeight),typeof e.cellWidth<"u"&&(this._cellWidth=e.cellWidth),typeof e.filterParams<"u"&&(this._filterParams=e.filterParams),this.transformByState({width:e.width,height:e.height})}_draw(e){const r=this._cellHeight,n=this._cellWidth,o=V-n,l=V-r;e.save();const i=new Path2D;i.rect(o,l,n,r),e.clip(i);const{hasCriteria:s}=this._filterParams,a=this._themeService.getColorFromTheme("primary.600"),m=this._hovered?this._themeService.getColorFromTheme("gray.50"):"rgba(255, 255, 255, 1.0)";s?ke.drawHasCriteria(e,V,a,m):ke.drawNoCriteria(e,V,a,m),e.restore()}onPointerDown(e){if(e.button===2)return;const{col:r,unitId:n,subUnitId:o}=this._filterParams;this._contextService.getContextValue(X)||!this._commandService.hasCommand(ne.id)||setTimeout(()=>{this._commandService.executeCommand(ne.id,{unitId:n,subUnitId:o,col:r})},200)}onPointerEnter(){this._hovered=!0,this.makeDirty(!0)}onPointerLeave(){this._hovered=!1,this.makeDirty(!0)}};Pe=ot([ye(2,c.IContextService),ye(3,c.ICommandService),ye(4,c.Inject(c.ThemeService))],Pe);var st=Object.getOwnPropertyDescriptor,at=(t,e,r,n)=>{for(var o=n>1?void 0:n?st(e,r):e,l=t.length-1,i;l>=0;l--)(i=t[l])&&(o=i(o)||o);return o},Y=(t,e)=>(r,n)=>e(r,n,t);const lt=1e3,ct=5e3;let be=class extends c.RxDisposable{constructor(e,r,n,o,l,i,s,a){super();S(this,"_filterRangeShape",null);S(this,"_buttonRenderDisposable",null);S(this,"_filterButtonShapes",[]);this._context=e,this._injector=r,this._sheetSkeletonManagerService=n,this._sheetsFilterService=o,this._themeService=l,this._sheetInterceptorService=i,this._commandService=s,this._selectionRenderService=a,this._initRenderer()}dispose(){super.dispose(),this._disposeRendering()}_initRenderer(){this._sheetSkeletonManagerService.currentSkeleton$.pipe(C.switchMap(e=>{var s,a;if(!e)return C.of(null);const{unit:r,unitId:n}=this._context,o=((s=r.getActiveSheet())==null?void 0:s.getSheetId())||"",l=(a=this._sheetsFilterService.getFilterModel(n,o))!=null?a:void 0,i=()=>({unitId:n,worksheetId:o,filterModel:l,range:l==null?void 0:l.getRange(),skeleton:e.skeleton});return c.fromCallback(this._commandService.onCommandExecuted.bind(this._commandService)).pipe(C.filter(([m])=>{var h;return m.type===c.CommandType.MUTATION&&((h=m.params)==null?void 0:h.unitId)===r.getUnitId()&&(u.FILTER_MUTATIONS.has(m.id)||m.id===N.SetRangeValuesMutation.id)}),C.throttleTime(20,void 0,{leading:!1,trailing:!0}),C.map(i),C.startWith(i()))}),C.takeUntil(this.dispose$)).subscribe(e=>{this._disposeRendering(),!(!e||!e.range)&&(this._renderRange(e.range,e.skeleton),this._renderButtons(e))})}_renderRange(e,r){const{scene:n}=this._context,{rowHeaderWidth:o,columnHeaderHeight:l}=r,i=this._filterRangeShape=new U.SelectionControl(n,lt,this._themeService,{rowHeaderWidth:o,columnHeaderHeight:l,enableAutoFill:!1,highlightHeader:!1}),s={range:e,primary:null,style:{fill:"rgba(0, 0, 0, 0.0)"}},a=U.attachSelectionWithCoord(s,r);i.updateRangeBySelectionWithCoord(a),i.setEvent(!1),n.makeDirty(!0)}_renderButtons(e){const{range:r,filterModel:n,unitId:o,skeleton:l,worksheetId:i}=e,{scene:s}=this._context;this._interceptCellContent(o,i,e.range);const{startColumn:a,endColumn:m,startRow:h}=r;for(let f=a;f<=m;f++){const O=`sheets-filter-button-${f}`,v=U.getCoordByCell(h,f,s,l),{startX:I,startY:E,endX:A,endY:F}=v,w=A-I,M=F-E;if(M<=de||w<=de)continue;const H=!!n.getFilterColumn(f),B=A-V-de,ve=F-V-de,Se={left:B,top:ve,height:V,width:V,zIndex:ct,cellHeight:M,cellWidth:w,filterParams:{unitId:o,subUnitId:i,col:f,hasCriteria:H}},L=this._injector.createInstance(Pe,O,Se);this._filterButtonShapes.push(L)}s.addObjects(this._filterButtonShapes),s.makeDirty()}_interceptCellContent(e,r,n){const{startRow:o,startColumn:l,endColumn:i}=n;this._buttonRenderDisposable=this._sheetInterceptorService.intercept(N.INTERCEPTOR_POINT.CELL_CONTENT,{effect:c.InterceptorEffectEnum.Style,handler:(s,a,m)=>{const{row:h,col:f,unitId:O,subUnitId:v}=a;return O!==e||v!==r||h!==o||f<l||f>i||((!s||s===a.rawData)&&(s={...a.rawData}),s.fontRenderExtension={...s==null?void 0:s.fontRenderExtension,rightOffset:V}),m(s)},priority:10})}_disposeRendering(){var e,r;(e=this._filterRangeShape)==null||e.dispose(),this._filterButtonShapes.forEach(n=>n.dispose()),(r=this._buttonRenderDisposable)==null||r.dispose(),this._filterRangeShape=null,this._buttonRenderDisposable=null,this._filterButtonShapes=[]}};be=at([Y(1,c.Inject(c.Injector)),Y(2,c.Inject(U.SheetSkeletonManagerService)),Y(3,c.Inject(u.SheetsFilterService)),Y(4,c.Inject(c.ThemeService)),Y(5,c.Inject(N.SheetInterceptorService)),Y(6,c.ICommandService),Y(7,U.ISheetSelectionRenderService)],be);var ut=Object.getOwnPropertyDescriptor,mt=(t,e,r,n)=>{for(var o=n>1?void 0:n?ut(e,r):e,l=t.length-1,i;l>=0;l--)(i=t[l])&&(o=i(o)||o);return o},He=(t,e)=>(r,n)=>e(r,n,t);let oe=class extends c.RxDisposable{constructor(t,e){super(),this._renderManagerService=t,this._sheetsRenderService=e,[u.SetSheetsFilterRangeMutation,u.SetSheetsFilterCriteriaMutation,u.RemoveSheetsFilterMutation,u.ReCalcSheetsFilterMutation].forEach(r=>this.disposeWithMe(this._sheetsRenderService.registerSkeletonChangingMutations(r.id))),this.disposeWithMe(this._renderManagerService.registerRenderModule(c.UniverInstanceType.UNIVER_SHEET,[be]))}};oe=mt([He(0,re.IRenderManagerService),He(1,c.Inject(U.SheetsRenderService))],oe);var ht=Object.defineProperty,pt=Object.getOwnPropertyDescriptor,dt=(t,e,r)=>e in t?ht(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,ft=(t,e,r,n)=>{for(var o=n>1?void 0:n?pt(e,r):e,l=t.length-1,i;l>=0;l--)(i=t[l])&&(o=i(o)||o);return o},Be=(t,e)=>(r,n)=>e(r,n,t),We=(t,e,r)=>dt(t,typeof e!="symbol"?e+"":e,r);const _t="SHEET_FILTER_UI_PLUGIN";_.UniverSheetsFilterMobileUIPlugin=class extends c.Plugin{constructor(e=pe,r,n){super(),this._config=e,this._injector=r,this._configService=n;const{menu:o,...l}=c.merge({},pe,this._config);o&&this._configService.setConfig("menu",o,{merge:!0}),this._configService.setConfig(De,l)}onStarting(){[[J],[oe]].forEach(e=>this._injector.add(e))}onReady(){this._injector.get(J)}onRendered(){this._injector.get(oe)}},We(_.UniverSheetsFilterMobileUIPlugin,"type",c.UniverInstanceType.UNIVER_SHEET),We(_.UniverSheetsFilterMobileUIPlugin,"pluginName",_t),_.UniverSheetsFilterMobileUIPlugin=ft([c.DependentOn(u.UniverSheetsFilterPlugin),Be(1,c.Inject(c.Injector)),Be(2,c.IConfigService)],_.UniverSheetsFilterMobileUIPlugin);var D=function(){return D=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++){e=arguments[r];for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o])}return t},D.apply(this,arguments)},vt=function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,n=Object.getOwnPropertySymbols(t);o<n.length;o++)e.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(t,n[o])&&(r[n[o]]=t[n[o]]);return r},Ve=b.forwardRef(function(t,e){var r=t.icon,n=t.id,o=t.className,l=t.extend,i=vt(t,["icon","id","className","extend"]),s="univerjs-icon univerjs-icon-".concat(n," ").concat(o||"").trim(),a=b.useRef("_".concat(Ct()));return xe(r,"".concat(n),{defIds:r.defIds,idSuffix:a.current},D({ref:e,className:s},i),l)});function xe(t,e,r,n,o){return b.createElement(t.tag,D(D({key:e},St(t,r,o)),n),(gt(t,r).children||[]).map(function(l,i){return xe(l,"".concat(e,"-").concat(t.tag,"-").concat(i),r,void 0,o)}))}function St(t,e,r){var n=D({},t.attrs);r!=null&&r.colorChannel1&&n.fill==="colorChannel1"&&(n.fill=r.colorChannel1),t.tag==="mask"&&n.id&&(n.id=n.id+e.idSuffix),Object.entries(n).forEach(function(l){var i=l[0],s=l[1];i==="mask"&&typeof s=="string"&&(n[i]=s.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))});var o=e.defIds;return!o||o.length===0||(t.tag==="use"&&n["xlink:href"]&&(n["xlink:href"]=n["xlink:href"]+e.idSuffix),Object.entries(n).forEach(function(l){var i=l[0],s=l[1];typeof s=="string"&&(n[i]=s.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))})),n}function gt(t,e){var r,n=e.defIds;return!n||n.length===0?t:t.tag==="defs"&&(!((r=t.children)===null||r===void 0)&&r.length)?D(D({},t),{children:t.children.map(function(o){return typeof o.attrs.id=="string"&&n&&n.includes(o.attrs.id)?D(D({},o),{attrs:D(D({},o.attrs),{id:o.attrs.id+e.idSuffix})}):o})}):t}function Ct(){return Math.random().toString(36).substring(2,8)}Ve.displayName="UniverIcon";var Tt={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 17 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M3.32182 2.60967C2.98161 2.60967 2.79671 3.0074 3.01601 3.2675L6.85819 7.8246C6.94943 7.93282 6.99947 8.06981 6.99947 8.21136V12.7338C6.99947 12.898 7.0998 13.0455 7.2525 13.1058L8.73833 13.6928C9.00085 13.7965 9.28531 13.6031 9.28531 13.3208V8.21136C9.28531 8.06981 9.33535 7.93282 9.42659 7.8246L13.2688 3.2675C13.4881 3.0074 13.3032 2.60967 12.963 2.60967H3.32182ZM2.09858 4.04101C1.22139 3.0006 1.96097 1.40967 3.32182 1.40967H12.963C14.3238 1.40967 15.0634 3.0006 14.1862 4.04101L10.4853 8.43054V13.3208C10.4853 14.4498 9.34747 15.2237 8.29742 14.8089L6.81158 14.2219C6.20078 13.9806 5.79947 13.3905 5.79947 12.7338V8.43054L2.09858 4.04101Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Qe=b.forwardRef(function(t,e){return b.createElement(Ve,Object.assign({},t,{id:"filter-icon",ref:e,icon:Tt}))});Qe.displayName="FilterIcon";function Et(t){var v,I;const{model:e}=t,r=T.useDependency(c.LocaleService),n=T.useObservable(e.conditionItem$,void 0),o=T.useObservable(e.filterConditionFormParams$,void 0),l=o!=null&&o.and?"AND":"OR",i=b.useCallback(E=>{e.onConditionFormChange({and:E==="AND"})},[e]),s=Ot(r),a=b.useCallback(E=>{e.onPrimaryConditionChange(E)},[e]),m=It(r),h=b.useCallback(E=>{e.onConditionFormChange(E)},[e]),f=r.t("sheets-filter.panel.input-values-placeholder");function O(E,A,F){const w=p.getItemByOperator(E).numOfParameters===1;return d.jsxs(d.Fragment,{children:[F==="operator2"&&d.jsxs(y.RadioGroup,{value:l,onChange:i,children:[d.jsx(y.Radio,{value:"AND",children:r.t("sheets-filter.panel.and")}),d.jsx(y.Radio,{value:"OR",children:r.t("sheets-filter.panel.or")})]}),d.jsx(y.Select,{value:E,options:m,onChange:M=>h({[F]:M})}),w&&d.jsx("div",{children:d.jsx(y.Input,{className:"univer-mt-2",value:A,placeholder:f,onChange:M=>h({[F==="operator1"?"val1":"val2"]:M})})})]})}return d.jsx("div",{"data-u-comp":"sheets-filter-panel-conditions-container",className:"univer-flex univer-h-full univer-flex-col",children:n&&o&&d.jsxs(d.Fragment,{children:[d.jsx(y.Select,{value:n.operator,options:s,onChange:a}),p.getItemByOperator(n.operator).numOfParameters!==0?d.jsxs("div",{"data-u-comp":"sheets-filter-panel-conditions-container-inner",className:y.clsx("univer-mt-2 univer-flex-grow univer-overflow-hidden univer-rounded-md univer-p-2",y.borderClassName),children:[n.numOfParameters>=1&&O(o.operator1,(v=o.val1)!=null?v:"","operator1"),n.numOfParameters>=2&&O(o.operator2,(I=o.val2)!=null?I:"","operator2"),d.jsxs("div",{"data-u-comp":"sheets-filter-panel-conditions-desc",className:"univer-mt-2 univer-text-xs univer-text-gray-500",children:[r.t("sheets-filter.panel.?"),d.jsx("br",{}),r.t("sheets-filter.panel.*")]})]}):null]})})}function Ot(t){const e=t.getCurrentLocale();return b.useMemo(()=>[{options:[{label:t.t(p.NONE.label),value:p.NONE.operator}]},{options:[{label:t.t(p.EMPTY.label),value:p.EMPTY.operator},{label:t.t(p.NOT_EMPTY.label),value:p.NOT_EMPTY.operator}]},{options:[{label:t.t(p.TEXT_CONTAINS.label),value:p.TEXT_CONTAINS.operator},{label:t.t(p.DOES_NOT_CONTAIN.label),value:p.DOES_NOT_CONTAIN.operator},{label:t.t(p.STARTS_WITH.label),value:p.STARTS_WITH.operator},{label:t.t(p.ENDS_WITH.label),value:p.ENDS_WITH.operator},{label:t.t(p.EQUALS.label),value:p.EQUALS.operator}]},{options:[{label:t.t(p.GREATER_THAN.label),value:p.GREATER_THAN.operator},{label:t.t(p.GREATER_THAN_OR_EQUAL.label),value:p.GREATER_THAN_OR_EQUAL.operator},{label:t.t(p.LESS_THAN.label),value:p.LESS_THAN.operator},{label:t.t(p.LESS_THAN_OR_EQUAL.label),value:p.LESS_THAN_OR_EQUAL.operator},{label:t.t(p.EQUAL.label),value:p.EQUAL.operator},{label:t.t(p.NOT_EQUAL.label),value:p.NOT_EQUAL.operator},{label:t.t(p.BETWEEN.label),value:p.BETWEEN.operator},{label:t.t(p.NOT_BETWEEN.label),value:p.NOT_BETWEEN.operator}]},{options:[{label:t.t(p.CUSTOM.label),value:p.CUSTOM.operator}]}],[e,t])}function It(t){const e=t.getCurrentLocale();return b.useMemo(()=>p.ALL_CONDITIONS.filter(r=>r.numOfParameters!==2).map(r=>({label:t.t(r.label),value:r.operator})),[e,t])}function Nt(t){const{model:e}=t,r=T.useDependency(c.LocaleService),n=T.useObservable(e.searchString$,"",!0),o=T.useObservable(e.filterItems$,void 0,!0),l=r.t("sheets-filter.panel.filter-only"),i=Ce(o),s=i.checked>0&&i.unchecked===0,a=i.checked>0&&i.unchecked>0,m=e.treeMapCache,h=b.useCallback(()=>{e.onCheckAllToggled(!s)},[e,s]),f=b.useCallback(v=>{e.setSearchString(v)},[e]);function O(v){let I=[];return v.forEach(E=>{E.checked&&I.push(E.key),E.children&&(I=I.concat(O(E.children)))}),I}return d.jsxs("div",{"data-u-comp":"sheets-filter-panel-values-container",className:"univer-flex univer-h-full univer-flex-col",children:[d.jsx(y.Input,{autoFocus:!0,value:n,placeholder:r.t("sheets-filter.panel.search-placeholder"),onChange:f}),d.jsxs("div",{"data-u-comp":"sheets-filter-panel",className:y.clsx("univer-mt-2 univer-box-border univer-flex univer-flex-grow univer-flex-col univer-overflow-hidden univer-rounded-md univer-px-2 univer-py-2.5",y.borderClassName),children:[d.jsx("div",{"data-u-comp":"sheets-filter-panel-values-item",className:"univer-box-border univer-h-8 univer-w-full univer-py-0.5",children:d.jsxs("div",{"data-u-comp":"sheets-filter-panel-values-item-inner",className:"univer-box-border univer-flex univer-h-7 univer-items-center univer-rounded-md univer-pb-0 univer-pl-5 univer-pr-0.5 univer-pt-0 univer-text-sm",children:[d.jsx(y.Checkbox,{indeterminate:a,disabled:o.length===0,checked:s,onChange:h}),d.jsx("span",{"data-u-comp":"sheets-filter-panel-values-item-text",className:"univer-mx-1 univer-inline-block univer-flex-shrink univer-overflow-hidden univer-text-ellipsis univer-whitespace-nowrap univer-text-gray-900 dark:!univer-text-white",children:`${r.t("sheets-filter.panel.select-all")}`}),d.jsx("span",{"data-u-comp":"sheets-filter-panel-values-item-count",className:"univer-text-gray-400 dark:!univer-text-gray-500",children:`(${i.checked}/${i.checked+i.unchecked})`})]})}),d.jsx("div",{"data-u-comp":"sheets-filter-panel-values-virtual",className:"univer-flex-grow",children:d.jsx(y.Tree,{data:o,defaultExpandAll:!1,valueGroup:O(o),height:180,onChange:v=>{e.onFilterCheckToggled(v)},defaultCache:m,itemHeight:28,treeNodeClassName:`
|
|
2
2
|
univer-pr-2 univer-border-box univer-max-w-[245px] univer-rounded-md
|
|
3
3
|
[&:hover_a]:univer-inline-block
|
|
4
4
|
hover:univer-bg-gray-50 univer-h-full
|
|
5
5
|
univer-text-gray-900 dark:hover:!univer-bg-gray-900
|
|
6
6
|
dark:!univer-text-white
|
|
7
|
-
`,attachRender:
|
|
7
|
+
`,attachRender:v=>d.jsxs("div",{className:"univer-ml-1 univer-flex univer-h-5 univer-flex-1 univer-cursor-pointer univer-items-center univer-justify-between univer-text-sm univer-text-primary-500",children:[d.jsx("span",{"data-u-comp":"sheets-filter-panel-values-item-count",className:"univer-text-gray-400 dark:!univer-text-gray-500",children:`(${v.count})`}),d.jsx("a",{className:"univer-box-border univer-hidden univer-h-4 univer-whitespace-nowrap univer-px-1.5",onClick:()=>{const I=[];v.children?v.children.forEach(E=>{E.children?E.children.forEach(A=>{I.push(A.key)}):I.push(E.key)}):I.push(v.key),e.onFilterOnly(I)},children:l})]})})})]})]})}function Ft(){var A;const t=T.useDependency(Q),e=T.useDependency(c.LocaleService),r=T.useDependency(c.ICommandService),n=T.useObservable(t.filterBy$,void 0,!0),o=T.useObservable(t.filterByModel$,void 0,!1),l=T.useObservable(()=>(o==null?void 0:o.canApply$)||C.of(!1),void 0,!1,[o]),i=yt(e),s=!T.useObservable(t.hasCriteria$),a=b.useCallback(F=>{r.executeCommand(Fe.id,{filterBy:F})},[r]),m=b.useCallback(async()=>{await(o==null?void 0:o.clear()),r.executeCommand(Z.id)},[o,r]),h=b.useCallback(()=>{r.executeCommand(Z.id)},[r]),f=b.useCallback(async()=>{await(o==null?void 0:o.apply()),r.executeCommand(Z.id)},[o,r]),v=(A=T.useDependency(u.SheetsFilterService).activeFilterModel)==null?void 0:A.getRange(),I=t.col,E=T.useComponentsOfPart(U.SheetsUIPart.FILTER_PANEL_EMBED_POINT);return d.jsxs("div",{"data-u-comp":"sheets-filter-panel",className:"univer-box-border univer-flex univer-h-[442px] univer-w-[312px] univer-flex-col univer-rounded-lg univer-bg-white univer-p-4 univer-shadow-lg dark:!univer-border-gray-600 dark:!univer-bg-gray-700",children:[d.jsx(T.ComponentContainer,{components:E,sharedProps:{range:v,colIndex:I,onClose:h}}),d.jsx("div",{className:"univer-mb-1 univer-flex-shrink-0 univer-flex-grow-0",children:d.jsx(y.Segmented,{value:n,items:i,onChange:F=>a(F)})}),o?d.jsx("div",{"data-u-comp":"sheets-filter-panel-content",className:"univer-flex-shrink univer-flex-grow univer-pt-2",children:n===ue.VALUES?d.jsx(Nt,{model:o}):d.jsx(Et,{model:o})}):d.jsx("div",{className:"univer-flex-1"}),d.jsxs("div",{"data-u-comp":"sheets-filter-panel-footer",className:"univer-mt-4 univer-inline-flex univer-flex-shrink-0 univer-flex-grow-0 univer-flex-nowrap univer-justify-between univer-overflow-hidden",children:[d.jsx(y.Button,{variant:"link",onClick:m,disabled:s,children:e.t("sheets-filter.panel.clear-filter")}),d.jsxs("span",{className:"univer-flex univer-gap-2",children:[d.jsx(y.Button,{variant:"default",onClick:h,children:e.t("sheets-filter.panel.cancel")}),d.jsx(y.Button,{disabled:!l,variant:"primary",onClick:f,children:e.t("sheets-filter.panel.confirm")})]})]})]})}function yt(t){const e=t.getCurrentLocale();return b.useMemo(()=>[{label:t.t("sheets-filter.panel.by-values"),value:ue.VALUES},{label:t.t("sheets-filter.panel.by-conditions"),value:ue.CONDITIONS}],[e,t])}function Pt(t){const e=t.get(u.SheetsFilterService);return{id:u.SmartToggleSheetsFilterCommand.id,type:T.MenuItemType.BUTTON_SELECTOR,icon:"FilterIcon",tooltip:"sheets-filter.toolbar.smart-toggle-filter-tooltip",hidden$:T.getMenuHiddenObservable(t,c.UniverInstanceType.UNIVER_SHEET),activated$:e.activeFilterModel$.pipe(C.map(r=>!!r)),disabled$:U.getObservableWithExclusiveRange$(t,U.getCurrentRangeDisable$(t,{worksheetTypes:[N.WorksheetFilterPermission,N.WorksheetViewPermission],rangeTypes:[N.RangeProtectionPermissionViewPoint]}))}}function bt(t){const e=t.get(u.SheetsFilterService);return{id:u.ClearSheetsFilterCriteriaCommand.id,type:T.MenuItemType.BUTTON,title:"sheets-filter.toolbar.clear-filter-criteria",hidden$:T.getMenuHiddenObservable(t,c.UniverInstanceType.UNIVER_SHEET),disabled$:e.activeFilterModel$.pipe(C.switchMap(r=>{var n;return(n=r==null?void 0:r.hasCriteria$.pipe(C.map(o=>!o)))!=null?n:C.of(!0)}))}}function At(t){const e=t.get(u.SheetsFilterService);return{id:u.ReCalcSheetsFilterCommand.id,type:T.MenuItemType.BUTTON,title:"sheets-filter.toolbar.re-calc-filter-conditions",hidden$:T.getMenuHiddenObservable(t,c.UniverInstanceType.UNIVER_SHEET),disabled$:e.activeFilterModel$.pipe(C.switchMap(r=>{var n;return(n=r==null?void 0:r.hasCriteria$.pipe(C.map(o=>!o)))!=null?n:C.of(!0)}))}}const Rt={[T.RibbonDataGroup.ORGANIZATION]:{[u.SmartToggleSheetsFilterCommand.id]:{order:2,menuItemFactory:Pt,[u.ClearSheetsFilterCriteriaCommand.id]:{order:0,menuItemFactory:bt},[u.ReCalcSheetsFilterCommand.id]:{order:1,menuItemFactory:At}}}},Mt={id:u.SmartToggleSheetsFilterCommand.id,binding:T.KeyCode.L|T.MetaKeys.CTRL_COMMAND|T.MetaKeys.SHIFT,description:"sheets-filter.shortcut.smart-toggle-filter",preconditions:U.whenSheetEditorFocused,group:"4_sheet-edit"};var wt=Object.getOwnPropertyDescriptor,Lt=(t,e,r,n)=>{for(var o=n>1?void 0:n?wt(e,r):e,l=t.length-1,i;l>=0;l--)(i=t[l])&&(o=i(o)||o);return o},$=(t,e)=>(r,n)=>e(r,n,t);const je="FILTER_PANEL_POPUP";let fe=class extends oe{constructor(e,r,n,o,l,i,s,a,m,h,f,O,v){super(v,O);S(this,"_popupDisposable");this._injector=e,this._componentManager=r,this._sheetsFilterPanelService=n,this._sheetCanvasPopupService=o,this._sheetsFilterService=l,this._localeService=i,this._shortcutService=s,this._commandService=a,this._menuManagerService=m,this._contextService=h,this._messageService=f,this._initCommands(),this._initShortcuts(),this._initMenuItems(),this._initUI()}dispose(){super.dispose(),this._closeFilterPopup()}_initShortcuts(){[Mt].forEach(e=>{this.disposeWithMe(this._shortcutService.registerShortcut(e))})}_initCommands(){[u.SmartToggleSheetsFilterCommand,u.RemoveSheetFilterCommand,u.SetSheetFilterRangeCommand,u.SetSheetsFilterCriteriaCommand,u.ClearSheetsFilterCriteriaCommand,u.ReCalcSheetsFilterCommand,Fe,ne,Z].forEach(e=>{this.disposeWithMe(this._commandService.registerCommand(e))})}_initMenuItems(){this._menuManagerService.mergeMenu(Rt)}_initUI(){[[je,Ft],["FilterIcon",Qe]].forEach(([e,r])=>{this.disposeWithMe(this._componentManager.register(e,r))}),this.disposeWithMe(this._contextService.subscribeContextValue$(X).pipe(C.distinctUntilChanged()).subscribe(e=>{e?this._openFilterPopup():this._closeFilterPopup()})),this.disposeWithMe(this._sheetsFilterService.errorMsg$.subscribe(e=>{e&&this._messageService.show({type:y.MessageType.Error,content:this._localeService.t(e)})}))}_openFilterPopup(){const e=this._sheetsFilterPanelService.filterModel;if(!e)throw new Error("[SheetsFilterUIController]: no filter model when opening filter popup!");const r=e.getRange(),n=this._sheetsFilterPanelService.col,{startRow:o}=r;this._popupDisposable=this._sheetCanvasPopupService.attachPopupToCell(o,n,{componentKey:je,direction:"horizontal",onClickOutside:()=>this._commandService.syncExecuteCommand(Z.id),offset:[5,0]})}_closeFilterPopup(){var e;(e=this._popupDisposable)==null||e.dispose(),this._popupDisposable=null}};fe=Lt([$(0,c.Inject(c.Injector)),$(1,c.Inject(T.ComponentManager)),$(2,c.Inject(Q)),$(3,c.Inject(U.SheetCanvasPopManagerService)),$(4,c.Inject(u.SheetsFilterService)),$(5,c.Inject(c.LocaleService)),$(6,T.IShortcutService),$(7,c.ICommandService),$(8,T.IMenuManagerService),$(9,c.IContextService),$(10,T.IMessageService),$(11,c.Inject(U.SheetsRenderService)),$(12,re.IRenderManagerService)],fe);var Ut=Object.defineProperty,$t=Object.getOwnPropertyDescriptor,Dt=(t,e,r)=>e in t?Ut(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,kt=(t,e,r,n)=>{for(var o=n>1?void 0:n?$t(e,r):e,l=t.length-1,i;l>=0;l--)(i=t[l])&&(o=i(o)||o);return o},Ae=(t,e)=>(r,n)=>e(r,n,t),Ge=(t,e,r)=>Dt(t,typeof e!="symbol"?e+"":e,r);const Ht="SHEET_FILTER_UI_PLUGIN";_.UniverSheetsFilterUIPlugin=class extends c.Plugin{constructor(e=pe,r,n,o){super(),this._config=e,this._injector=r,this._configService=n,this._rpcChannelService=o;const{menu:l,...i}=c.merge({},pe,this._config);l&&this._configService.setConfig("menu",l,{merge:!0}),this._configService.setConfig(De,i)}onStarting(){c.registerDependencies(this._injector,[[Q],[J],[fe]]),this._config.useRemoteFilterValuesGenerator&&this._rpcChannelService&&this._injector.add([le,{useFactory:()=>ae.toModule(this._rpcChannelService.requestChannel(Ee))}])}onReady(){c.touchDependencies(this._injector,[[J]])}onRendered(){c.touchDependencies(this._injector,[[fe]])}},Ge(_.UniverSheetsFilterUIPlugin,"type",c.UniverInstanceType.UNIVER_SHEET),Ge(_.UniverSheetsFilterUIPlugin,"pluginName",Ht),_.UniverSheetsFilterUIPlugin=kt([c.DependentOn(u.UniverSheetsFilterPlugin),Ae(1,c.Inject(c.Injector)),Ae(2,c.IConfigService),Ae(3,c.Optional(ae.IRPCChannelService))],_.UniverSheetsFilterUIPlugin);var Bt=Object.getOwnPropertyDescriptor,Wt=(t,e,r,n)=>{for(var o=n>1?void 0:n?Bt(e,r):e,l=t.length-1,i;l>=0;l--)(i=t[l])&&(o=i(o)||o);return o},Ye=(t,e)=>(r,n)=>e(r,n,t);_.UniverSheetsFilterUIWorkerPlugin=(_e=class extends c.Plugin{constructor(e,r,n){super(),this._config=e,this._injector=r,this._rpcChannelService=n}onStarting(){[[le,{useClass:Oe}]].forEach(e=>this._injector.add(e))}onReady(){this._rpcChannelService.registerChannel(Ee,ae.fromModule(this._injector.get(le)))}},S(_e,"type",c.UniverInstanceType.UNIVER_SHEET),S(_e,"pluginName","SHEET_FILTER_UI_WORKER_PLUGIN"),_e),_.UniverSheetsFilterUIWorkerPlugin=Wt([Ye(1,c.Inject(c.Injector)),Ye(2,ae.IRPCChannelService)],_.UniverSheetsFilterUIWorkerPlugin),_.ChangeFilterByOperation=Fe,_.CloseFilterPanelOperation=Z,_.OpenFilterPanelOperation=ne,Object.defineProperty(_,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@univerjs/sheets-filter-ui",
|
|
3
|
-
"version": "0.8.3
|
|
3
|
+
"version": "0.8.3",
|
|
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": "^0.4.4",
|
|
56
|
-
"@univerjs/
|
|
57
|
-
"@univerjs/
|
|
58
|
-
"@univerjs/
|
|
59
|
-
"@univerjs/
|
|
60
|
-
"@univerjs/sheets": "0.8.3
|
|
61
|
-
"@univerjs/sheets
|
|
62
|
-
"@univerjs/
|
|
63
|
-
"@univerjs/ui": "0.8.3
|
|
56
|
+
"@univerjs/core": "0.8.3",
|
|
57
|
+
"@univerjs/design": "0.8.3",
|
|
58
|
+
"@univerjs/rpc": "0.8.3",
|
|
59
|
+
"@univerjs/engine-render": "0.8.3",
|
|
60
|
+
"@univerjs/sheets-filter": "0.8.3",
|
|
61
|
+
"@univerjs/sheets": "0.8.3",
|
|
62
|
+
"@univerjs/ui": "0.8.3",
|
|
63
|
+
"@univerjs/sheets-ui": "0.8.3"
|
|
64
64
|
},
|
|
65
65
|
"devDependencies": {
|
|
66
66
|
"postcss": "^8.5.6",
|
|
@@ -71,7 +71,7 @@
|
|
|
71
71
|
"vite": "^6.3.5",
|
|
72
72
|
"vitest": "^3.2.4",
|
|
73
73
|
"@univerjs-infra/shared": "0.8.3",
|
|
74
|
-
"@univerjs/engine-formula": "0.8.3
|
|
74
|
+
"@univerjs/engine-formula": "0.8.3"
|
|
75
75
|
},
|
|
76
76
|
"scripts": {
|
|
77
77
|
"test": "vitest run",
|