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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,176 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
package/lib/cjs/index.js CHANGED
@@ -1,3 +1,3 @@
1
1
  "use strict";var _t=Object.defineProperty;var wt=(i,e,n)=>e in i?_t(i,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):i[e]=n;var z=(i,e,n)=>wt(i,typeof e!="symbol"?e+"":e,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("@univerjs/core"),O=require("@univerjs/sheets"),t=require("@univerjs/sheets-conditional-formatting"),D=require("@univerjs/ui"),u=require("react/jsx-runtime"),C=require("react"),j=require("@univerjs/design"),We=require("@univerjs/engine-formula"),fe=require("@univerjs/sheets-formula-ui"),W=require("@univerjs/sheets-ui"),K=require("rxjs"),mt=require("@univerjs/sheets-formula"),vt=require("@univerjs/engine-render"),de=require("rxjs/operators"),qe={type:l.CommandType.COMMAND,id:"sheet.command.add-average-conditional-rule",handler(i,e){if(!e)return!1;const{ranges:n,style:r,stopIfTrue:o,operator:s}=e,a=i.get(t.ConditionalFormattingRuleModel),m=i.get(l.ICommandService),d=i.get(l.IUniverInstanceService),h=O.getSheetCommandTarget(d);if(!h)return!1;const{unitId:c,subUnitId:v}=h,p=a.createCfId(c,v),b={ranges:n,cfId:p,stopIfTrue:!!o,rule:{type:t.CFRuleType.highlightCell,subType:t.CFSubRuleType.average,operator:s,style:r}};return m.executeCommand(t.AddConditionalRuleMutation.id,{unitId:c,subUnitId:v,rule:b})}},Ge={type:l.CommandType.COMMAND,id:"sheet.command.add-color-scale-conditional-rule",handler(i,e){if(!e)return!1;const{ranges:n,config:r,stopIfTrue:o}=e,s=i.get(t.ConditionalFormattingRuleModel),a=i.get(l.ICommandService),m=i.get(l.IUniverInstanceService),d=O.getSheetCommandTarget(m);if(!d)return!1;const{unitId:h,subUnitId:c}=d,v=s.createCfId(h,c),p={ranges:n,cfId:v,stopIfTrue:!!o,rule:{type:t.CFRuleType.colorScale,config:r}};return a.executeCommand(t.AddConditionalRuleMutation.id,{unitId:h,subUnitId:c,rule:p})}},Ze={type:l.CommandType.COMMAND,id:"sheet.command.add-data-bar-conditional-rule",handler(i,e){if(!e)return!1;const{ranges:n,min:r,max:o,nativeColor:s,positiveColor:a,isGradient:m,stopIfTrue:d,isShowValue:h}=e,c=i.get(t.ConditionalFormattingRuleModel),v=i.get(l.IUniverInstanceService),p=O.getSheetCommandTarget(v);if(!p)return!1;const{unitId:b,subUnitId:S}=p,y=i.get(l.ICommandService),_=c.createCfId(b,S),R={ranges:n,cfId:_,stopIfTrue:!!d,rule:{type:t.CFRuleType.dataBar,isShowValue:h,config:{min:r,max:o,nativeColor:s,positiveColor:a,isGradient:m}}};return y.executeCommand(t.AddConditionalRuleMutation.id,{unitId:b,subUnitId:S,rule:R})}},Ye={type:l.CommandType.COMMAND,id:"sheet.command.add-duplicate-values-conditional-rule",handler(i,e){if(!e)return!1;const{ranges:n,style:r,stopIfTrue:o}=e,s=i.get(t.ConditionalFormattingRuleModel),a=i.get(l.ICommandService),m=i.get(l.IUniverInstanceService),d=O.getSheetCommandTarget(m);if(!d)return!1;const{unitId:h,subUnitId:c}=d,v=s.createCfId(h,c),p={ranges:n,cfId:v,stopIfTrue:!!o,rule:{type:t.CFRuleType.highlightCell,subType:t.CFSubRuleType.duplicateValues,style:r}};return a.executeCommand(t.AddConditionalRuleMutation.id,{unitId:h,subUnitId:c,rule:p})}},ze={type:l.CommandType.COMMAND,id:"sheet.command.add-number-conditional-rule",handler(i,e){if(!e)return!1;const{ranges:n,style:r,stopIfTrue:o,operator:s,value:a}=e,m=i.get(t.ConditionalFormattingRuleModel),d=i.get(l.ICommandService),h=i.get(l.IUniverInstanceService),c=O.getSheetCommandTarget(h);if(!c)return!1;const{unitId:v,subUnitId:p}=c,b=m.createCfId(v,p);let S;if([t.CFNumberOperator.between,t.CFNumberOperator.notBetween].includes(s)){const y=a;if(y.length!==2||!Array.isArray(y))return!1;S={ranges:n,cfId:b,stopIfTrue:!!o,rule:{type:t.CFRuleType.highlightCell,subType:t.CFSubRuleType.number,operator:s,style:r,value:y}}}else{const y=a;if(typeof y!="number")return!1;S={ranges:n,cfId:b,stopIfTrue:!!o,rule:{type:t.CFRuleType.highlightCell,subType:t.CFSubRuleType.number,operator:s,style:r,value:y}}}return d.executeCommand(t.AddConditionalRuleMutation.id,{unitId:v,subUnitId:p,rule:S})}},Ke={type:l.CommandType.COMMAND,id:"sheet.command.add-rank-conditional-rule",handler(i,e){if(!e)return!1;const{ranges:n,style:r,stopIfTrue:o,isPercent:s,isBottom:a,value:m}=e,d=i.get(t.ConditionalFormattingRuleModel),h=i.get(l.IUniverInstanceService),c=i.get(l.ICommandService),v=O.getSheetCommandTarget(h);if(!v)return!1;const{unitId:p,subUnitId:b}=v,S=d.createCfId(p,b),y={ranges:n,cfId:S,stopIfTrue:!!o,rule:{type:t.CFRuleType.highlightCell,subType:t.CFSubRuleType.rank,isPercent:s,isBottom:a,style:r,value:m}};return c.executeCommand(t.AddConditionalRuleMutation.id,{unitId:p,subUnitId:b,rule:y})}},Xe={type:l.CommandType.COMMAND,id:"sheet.command.add-text-conditional-rule",handler(i,e){if(!e)return!1;const{ranges:n,style:r,stopIfTrue:o,operator:s,value:a}=e,m=i.get(t.ConditionalFormattingRuleModel),d=i.get(l.IUniverInstanceService),h=O.getSheetCommandTarget(d);if(!h)return!1;const{unitId:c,subUnitId:v}=h,p=i.get(l.ICommandService),b=m.createCfId(c,v),S={ranges:n,cfId:b,stopIfTrue:!!o,rule:{type:t.CFRuleType.highlightCell,subType:t.CFSubRuleType.text,operator:s,style:r,value:a}};return p.executeCommand(t.AddConditionalRuleMutation.id,{unitId:c,subUnitId:v,rule:S})}},Je={type:l.CommandType.COMMAND,id:"sheet.command.add-time-period-conditional-rule",handler(i,e){if(!e)return!1;const{ranges:n,style:r,stopIfTrue:o,operator:s}=e,a=i.get(t.ConditionalFormattingRuleModel),m=i.get(l.IUniverInstanceService),d=i.get(l.ICommandService),h=O.getSheetCommandTarget(m);if(!h)return!1;const{unitId:c,subUnitId:v}=h,p=a.createCfId(c,v),b={ranges:n,cfId:p,stopIfTrue:!!o,rule:{type:t.CFRuleType.highlightCell,subType:t.CFSubRuleType.timePeriod,operator:s,style:r}};return d.executeCommand(t.AddConditionalRuleMutation.id,{unitId:c,subUnitId:v,rule:b})}},Qe={type:l.CommandType.COMMAND,id:"sheet.command.add-uniqueValues-conditional-rule",handler(i,e){if(!e)return!1;const{ranges:n,style:r,stopIfTrue:o}=e,s=i.get(t.ConditionalFormattingRuleModel),a=i.get(l.IUniverInstanceService),m=i.get(l.ICommandService),d=O.getSheetCommandTarget(a);if(!d)return!1;const{unitId:h,subUnitId:c}=d,v=s.createCfId(h,c),p={ranges:n,cfId:v,stopIfTrue:!!o,rule:{type:t.CFRuleType.highlightCell,subType:t.CFSubRuleType.uniqueValues,style:r}};return m.executeCommand(t.AddConditionalRuleMutation.id,{unitId:h,subUnitId:c,rule:p})}};function Z({ref:i,...e}){const{icon:n,id:r,className:o,extend:s,...a}=e,m=`univerjs-icon univerjs-icon-${r} ${o||""}`.trim(),d=C.useRef(`_${jt()}`);return ht(n,`${r}`,{defIds:n.defIds,idSuffix:d.current},{ref:i,className:m,...a},s)}function ht(i,e,n,r,o){return C.createElement(i.tag,{key:e,...Nt(i,n,o),...r},(Et(i,n).children||[]).map((s,a)=>ht(s,`${e}-${i.tag}-${a}`,n,void 0,o)))}function Nt(i,e,n){const r={...i.attrs};n!=null&&n.colorChannel1&&r.fill==="colorChannel1"&&(r.fill=n.colorChannel1),i.tag==="mask"&&r.id&&(r.id=r.id+e.idSuffix),Object.entries(r).forEach(([s,a])=>{s==="mask"&&typeof a=="string"&&(r[s]=a.replace(/url\(#(.*)\)/,`url(#$1${e.idSuffix})`))});const{defIds:o}=e;return!o||o.length===0||(i.tag==="use"&&r["xlink:href"]&&(r["xlink:href"]=r["xlink:href"]+e.idSuffix),Object.entries(r).forEach(([s,a])=>{typeof a=="string"&&(r[s]=a.replace(/url\(#(.*)\)/,`url(#$1${e.idSuffix})`))})),r}function Et(i,e){var r;const{defIds:n}=e;return!n||n.length===0?i:i.tag==="defs"&&((r=i.children)!=null&&r.length)?{...i,children:i.children.map(o=>typeof o.attrs.id=="string"&&n&&n.includes(o.attrs.id)?{...o,attrs:{...o.attrs,id:o.attrs.id+e.idSuffix}}:o)}:i}function jt(){return Math.random().toString(36).substring(2,8)}Z.displayName="UniverIcon";const Mt={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M4.65791 1.30005C3.77355 1.30005 3.05664 2.01696 3.05664 2.90132V12.8588C3.05664 13.8755 3.88086 14.6998 4.89759 14.6998H9.1016C11.2233 14.6998 12.9433 12.9798 12.9433 10.8581C12.9433 9.13925 11.8145 7.68407 10.2578 7.1934C10.8806 6.56856 11.2655 5.70659 11.2655 4.75472C11.2655 2.84676 9.71883 1.30005 7.81087 1.30005H4.65791ZM4.25664 2.90132C4.25664 2.6797 4.4363 2.50005 4.65791 2.50005H7.81087C9.05609 2.50005 10.0655 3.5095 10.0655 4.75472C10.0655 5.99993 9.05609 7.00938 7.81087 7.00938H4.25664V2.90132ZM4.25664 12.8588V8.21636H9.1016C10.5606 8.21636 11.7433 9.39909 11.7433 10.8581C11.7433 12.317 10.5606 13.4998 9.1016 13.4998H4.89759C4.5436 13.4998 4.25664 13.2128 4.25664 12.8588Z",fillRule:"evenodd",clipRule:"evenodd"}}]},pt=C.forwardRef(function(e,n){return C.createElement(Z,Object.assign({},e,{id:"bold-icon",ref:n,icon:Mt}))});pt.displayName="BoldIcon";const Vt={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M5.3313 1.4667C5.3313 1.13533 5.59993 0.866699 5.9313 0.866699H10.069C10.4004 0.866699 10.669 1.13533 10.669 1.4667C10.669 1.79807 10.4004 2.0667 10.069 2.0667H5.9313C5.59993 2.0667 5.3313 1.79807 5.3313 1.4667Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M1.09985 3.64443C1.09985 3.31306 1.36848 3.04443 1.69985 3.04443H14.2999C14.6312 3.04443 14.8999 3.31306 14.8999 3.64443C14.8999 3.9758 14.6312 4.24443 14.2999 4.24443H1.69985C1.36848 4.24443 1.09985 3.9758 1.09985 3.64443Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M6.12398 8.30171C6.35829 8.0674 6.73819 8.0674 6.97251 8.30171L8.00007 9.32928L9.02764 8.30171C9.26195 8.0674 9.64185 8.0674 9.87617 8.30171C10.1105 8.53603 10.1105 8.91593 9.87617 9.15024L8.8486 10.1778L9.87617 11.2054C10.1105 11.4397 10.1105 11.8196 9.87617 12.0539C9.64185 12.2882 9.26195 12.2882 9.02764 12.0539L8.00007 11.0263L6.97251 12.0539C6.73819 12.2882 6.35829 12.2882 6.12398 12.0539C5.88966 11.8196 5.88966 11.4397 6.12398 11.2054L7.15154 10.1778L6.12398 9.15024C5.88966 8.91593 5.88966 8.53603 6.12398 8.30171Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M4.75332 5.22217C3.86966 5.22217 3.15332 5.93851 3.15332 6.82217V12.5331C3.15332 13.9691 4.31738 15.1332 5.75332 15.1332H10.2465C11.6825 15.1332 12.8465 13.9691 12.8465 12.5331V6.82217C12.8465 5.93851 12.1302 5.22217 11.2465 5.22217H4.75332ZM4.35332 6.82217C4.35332 6.60125 4.53241 6.42217 4.75332 6.42217H11.2465C11.4674 6.42217 11.6465 6.60125 11.6465 6.82217V12.5331C11.6465 13.3063 11.0197 13.9332 10.2465 13.9332H5.75332C4.98012 13.9332 4.35332 13.3063 4.35332 12.5331V6.82217Z",fillRule:"evenodd",clipRule:"evenodd"}}]},_e=C.forwardRef(function(e,n){return C.createElement(Z,Object.assign({},e,{id:"delete-icon",ref:n,icon:Vt}))});_e.displayName="DeleteIcon";const Ot={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M8.6 1.99991C8.60001 1.66854 8.33138 1.39991 8.00001 1.3999C7.66864 1.3999 7.40001 1.66853 7.4 1.9999L7.39996 7.3999H1.9999C1.66853 7.3999 1.3999 7.66853 1.3999 7.9999C1.3999 8.33127 1.66853 8.5999 1.9999 8.5999H7.39995L7.3999 13.9999C7.3999 14.3313 7.66853 14.5999 7.9999 14.5999C8.33127 14.5999 8.5999 14.3313 8.5999 13.9999L8.59995 8.5999H13.9999C14.3313 8.5999 14.5999 8.33127 14.5999 7.9999C14.5999 7.66853 14.3313 7.3999 13.9999 7.3999H8.59996L8.6 1.99991Z"}}]},gt=C.forwardRef(function(e,n){return C.createElement(Z,Object.assign({},e,{id:"increase-icon",ref:n,icon:Ot}))});gt.displayName="IncreaseIcon";const Ut={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M9.80385 1.40005H11.9997C12.3311 1.40005 12.5997 1.66868 12.5997 2.00005C12.5997 2.33143 12.3311 2.60005 11.9997 2.60005H10.1185L7.12251 13.4001H9.33324C9.66461 13.4001 9.93324 13.6687 9.93324 14.0001C9.93324 14.3314 9.66461 14.6001 9.33324 14.6001H6.34785C6.33847 14.6003 6.32905 14.6003 6.31962 14.6001H3.9999C3.66853 14.6001 3.3999 14.3314 3.3999 14.0001C3.3999 13.6687 3.66853 13.4001 3.9999 13.4001H5.87719L8.87322 2.60005H6.66641C6.33504 2.60005 6.06641 2.33143 6.06641 2.00005C6.06641 1.66868 6.33504 1.40005 6.66641 1.40005H9.52916C9.61698 1.37929 9.71064 1.3781 9.80385 1.40005Z"}}]},ft=C.forwardRef(function(e,n){return C.createElement(Z,Object.assign({},e,{id:"italic-icon",ref:n,icon:Ut}))});ft.displayName="ItalicIcon";const kt={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M11.3536 6.14645C11.5488 6.34171 11.5488 6.65829 11.3536 6.85355L8.35355 9.85355C8.15829 10.0488 7.84171 10.0488 7.64645 9.85355L4.64645 6.85355C4.45118 6.65829 4.45118 6.34171 4.64645 6.14645C4.84171 5.95118 5.15829 5.95118 5.35355 6.14645L8 8.79289L10.6464 6.14645C10.8417 5.95118 11.1583 5.95118 11.3536 6.14645Z",fillRule:"evenodd",clipRule:"evenodd"}}]},et=C.forwardRef(function(e,n){return C.createElement(Z,Object.assign({},e,{id:"more-down-icon",ref:n,icon:kt}))});et.displayName="MoreDownIcon";const Pt={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M6 5C6.55228 5 7 4.55228 7 4C7 3.44772 6.55228 3 6 3C5.44772 3 5 3.44772 5 4C5 4.55228 5.44772 5 6 5Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M6 9C6.55228 9 7 8.55229 7 8C7 7.44772 6.55228 7 6 7C5.44772 7 5 7.44772 5 8C5 8.55229 5.44772 9 6 9Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M7 12C7 12.5523 6.55228 13 6 13C5.44772 13 5 12.5523 5 12C5 11.4477 5.44772 11 6 11C6.55228 11 7 11.4477 7 12Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M10 5C10.5523 5 11 4.55228 11 4C11 3.44772 10.5523 3 10 3C9.44771 3 9 3.44772 9 4C9 4.55228 9.44771 5 10 5Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M11 8C11 8.55229 10.5523 9 10 9C9.44771 9 9 8.55229 9 8C9 7.44772 9.44771 7 10 7C10.5523 7 11 7.44772 11 8Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M10 13C10.5523 13 11 12.5523 11 12C11 11.4477 10.5523 11 10 11C9.44771 11 9 11.4477 9 12C9 12.5523 9.44771 13 10 13Z"}}]},Ct=C.forwardRef(function(e,n){return C.createElement(Z,Object.assign({},e,{id:"sequence-icon",ref:n,icon:Pt}))});Ct.displayName="SequenceIcon";const Dt={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M8.00033 1.20996C6.43345 1.20996 5.23596 1.88077 4.64804 2.94304C4.06338 3.99943 4.15123 5.32084 4.90099 6.47062C5.08199 6.7482 5.45374 6.82648 5.73131 6.64548C6.00888 6.46448 6.08716 6.09273 5.90616 5.81516C5.36418 4.98402 5.35768 4.13897 5.69797 3.52412C6.035 2.91515 6.78176 2.40996 8.00033 2.40996C9.19423 2.40996 10.0017 2.93409 10.5236 3.46755C10.7871 3.73682 10.9756 4.00712 11.0974 4.20903C11.158 4.30951 11.2013 4.39164 11.2284 4.44625C11.2419 4.47351 11.2514 4.49377 11.2568 4.50588L11.2621 4.51771C11.3901 4.82216 11.7407 4.96686 12.046 4.83992C12.3519 4.71267 12.4968 4.36149 12.3695 4.05552L11.8231 4.28278C12.3695 4.05552 12.3697 4.0558 12.3695 4.05552L12.3691 4.05437L12.3685 4.05298L12.367 4.04953L12.3629 4.03993L12.3498 4.01036C12.3388 3.98619 12.3234 3.95326 12.3033 3.91282C12.2632 3.83203 12.2043 3.72072 12.1249 3.58908C11.9666 3.32674 11.7235 2.97805 11.3814 2.62834C10.6921 1.92381 9.59192 1.20996 8.00033 1.20996Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M2.11953 8.5999H7.88935C10.1109 9.46549 10.5895 10.7649 10.4268 11.6869C10.2475 12.703 9.26939 13.5898 8.00009 13.5898C6.63323 13.5898 5.77631 13.0502 5.25534 12.528C4.99021 12.2623 4.80823 11.9965 4.69365 11.7993C4.63659 11.7011 4.59698 11.6211 4.5727 11.5686C4.56059 11.5424 4.55236 11.5231 4.54774 11.512L4.54352 11.5016C4.4267 11.193 4.0823 11.0363 3.77279 11.1516C3.46228 11.2673 3.30438 11.6129 3.4201 11.9234L3.9649 11.7203C3.4201 11.9234 3.41998 11.9231 3.4201 11.9234L3.4206 11.9247L3.42118 11.9263L3.42262 11.9301L3.42661 11.9403C3.42977 11.9484 3.43394 11.9588 3.43914 11.9713C3.44956 11.9965 3.46418 12.0304 3.48334 12.0719C3.52161 12.1547 3.57828 12.2682 3.65608 12.4021C3.81124 12.6692 4.0534 13.0223 4.40584 13.3756C5.12 14.0914 6.27196 14.7898 8.00009 14.7898C9.82574 14.7898 11.3236 13.5101 11.6085 11.8955C11.812 10.7422 11.3901 9.55402 10.2665 8.5999H13.8804C14.2117 8.5999 14.4803 8.33127 14.4803 7.9999C14.4803 7.66853 14.2117 7.3999 13.8804 7.3999H8.01411C8.0048 7.39968 7.99551 7.39969 7.98625 7.3999H2.11953C1.78816 7.3999 1.51953 7.66853 1.51953 7.9999C1.51953 8.33127 1.78816 8.5999 2.11953 8.5999Z"}}]},yt=C.forwardRef(function(e,n){return C.createElement(Z,Object.assign({},e,{id:"strikethrough-icon",ref:n,icon:Dt}))});yt.displayName="StrikethroughIcon";const Lt={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M4.46416 2.03237C4.46416 1.701 4.19553 1.43237 3.86416 1.43237C3.53279 1.43237 3.26416 1.701 3.26416 2.03237V7.33338C3.26416 10.0313 5.35834 12.2667 7.9999 12.2667C10.6415 12.2667 12.7356 10.0313 12.7356 7.33338V2.03237C12.7356 1.701 12.467 1.43237 12.1356 1.43237C11.8043 1.43237 11.5356 1.701 11.5356 2.03237V7.33338C11.5356 9.42194 9.92656 11.0667 7.9999 11.0667C6.07325 11.0667 4.46416 9.42194 4.46416 7.33338V2.03237Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M2.66641 13.4663C2.33504 13.4663 2.06641 13.7349 2.06641 14.0663C2.06641 14.3977 2.33504 14.6663 2.66641 14.6663H13.3331C13.6644 14.6663 13.9331 14.3977 13.9331 14.0663C13.9331 13.7349 13.6644 13.4663 13.3331 13.4663H2.66641Z"}}]},bt=C.forwardRef(function(e,n){return C.createElement(Z,Object.assign({},e,{id:"underline-icon",ref:n,icon:Lt}))});bt.displayName="UnderlineIcon";const At={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 17 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"colorChannel1",d:"M1.98682 13.4992C1.98682 12.5603 2.74793 11.7992 3.68682 11.7992H14.2868C15.2257 11.7992 15.9868 12.5603 15.9868 13.4992V13.4992C15.9868 14.4381 15.2257 15.1992 14.2868 15.1992H3.68682C2.74793 15.1992 1.98682 14.4381 1.98682 13.4992V13.4992Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M10.3014 1.70389C9.85268 0.479568 8.12109 0.479557 7.67238 1.70389L4.72235 9.75326C4.60832 10.0644 4.76811 10.4091 5.07924 10.5231C5.39038 10.6371 5.73504 10.4773 5.84907 10.1662L6.99975 7.02646C7.03588 7.03324 7.07314 7.03679 7.11123 7.03679H10.9778L12.1247 10.1662C12.2387 10.4773 12.5834 10.6371 12.8945 10.5231C13.2057 10.4091 13.3654 10.0644 13.2514 9.75326L10.3014 1.70389ZM10.538 5.83679L9.17467 2.11682C9.11057 1.94192 8.8632 1.94192 8.7991 2.11682L7.43576 5.83679H10.538Z",fillRule:"evenodd",clipRule:"evenodd"}}]},It=C.forwardRef(function(e,n){return C.createElement(Z,Object.assign({},e,{id:"font-color-double-icon",ref:n,icon:At}))});It.displayName="FontColorDoubleIcon";const $t={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 17 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M8.01281 1.36643C8.79386 0.585377 10.0602 0.585378 10.8412 1.36643L12.9223 3.44752C13.7034 4.22857 13.7034 5.4949 12.9223 6.27595L9.36445 9.83383C8.5834 10.6149 7.31707 10.6149 6.53602 9.83383L4.45493 7.75273C3.67388 6.97168 3.67388 5.70535 4.45493 4.9243L8.01281 1.36643ZM9.9927 2.21495C9.68028 1.90253 9.17375 1.90253 8.86133 2.21495L5.30346 5.77283L5.29671 5.77966L10.839 6.66224L12.0738 5.42742C12.3862 5.115 12.3862 4.60847 12.0738 4.29605L9.9927 2.21495Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M14.5179 9.48875C14.5179 9.99175 14.1101 10.3995 13.607 10.3995C13.1041 10.3995 12.6963 9.99175 12.6963 9.48875C12.6963 9.1773 13.0455 8.59966 13.3114 8.20487C13.4549 7.99177 13.7591 7.99177 13.9027 8.20486C14.1687 8.59965 14.5179 9.1773 14.5179 9.48875Z"}},{tag:"path",attrs:{fill:"colorChannel1",d:"M1.98682 13.4992C1.98682 12.5603 2.74793 11.7992 3.68682 11.7992H14.2868C15.2257 11.7992 15.9868 12.5603 15.9868 13.4992V13.4992C15.9868 14.4381 15.2257 15.1992 14.2868 15.1992H3.68682C2.74793 15.1992 1.98682 14.4381 1.98682 13.4992V13.4992Z"}}]},St=C.forwardRef(function(e,n){return C.createElement(Z,Object.assign({},e,{id:"paint-bucket-double-icon",ref:n,icon:$t}))});St.displayName="PaintBucketDoubleIcon";const Bt={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M2.27177 13.714L13.5855 2.40025L14.434 3.24878L3.1203 14.5625L2.27177 13.714Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"colorChannel1",d:"M4.2603 1.82495L2.89617 1.82495C2.23343 1.82495 1.69617 2.36221 1.69617 3.02495L1.69617 4.38908L3.02617 4.38908L3.02617 3.15495L4.2603 3.15495L4.2603 1.82495ZM15.0092 4.38908L15.0092 3.02495C15.0092 2.36221 14.4719 1.82495 13.8092 1.82495L12.4451 1.82495L12.4451 3.15495L13.6792 3.15495L13.6792 4.38908L15.0092 4.38908ZM6.98856 1.82495L6.98856 3.15495L9.71681 3.15495L9.71681 1.82495L6.98856 1.82495ZM15.0092 7.11734L13.6792 7.11734L13.6792 9.84559L15.0092 9.84559L15.0092 7.11734ZM15.0092 12.5739L13.6792 12.5739L13.6792 13.808L12.4451 13.808L12.4451 15.138L13.8092 15.138C14.4719 15.138 15.0092 14.6007 15.0092 13.938L15.0092 12.5739ZM9.71681 15.138L9.71681 13.808L6.98856 13.808L6.98856 15.138L9.71681 15.138ZM4.2603 15.138L4.2603 13.808L3.02617 13.808L3.02617 12.5739L1.69617 12.5739L1.69617 13.938C1.69617 14.6007 2.23343 15.138 2.89617 15.138L4.2603 15.138ZM1.69617 9.8456L3.02617 9.8456L3.02617 7.11734L1.69617 7.11734L1.69617 9.8456Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Ce=C.forwardRef(function(e,n){return C.createElement(Z,Object.assign({},e,{id:"slash-double-icon",ref:n,icon:Bt}))});Ce.displayName="SlashDoubleIcon";const ee=i=>{const{color:e,onChange:n,disable:r=!1,Icon:o=St,className:s}=i,a=C.useMemo(()=>new l.ColorKit(e),[e]),m=()=>{const d={className:j.clsx("univer-fill-primary-600",r&&s),extend:{colorChannel1:a.isValid?e:""}};return u.jsx(o,{...d})};return r?m():u.jsx(j.Dropdown,{overlay:u.jsx("div",{className:"univer-rounded-lg univer-p-4",children:u.jsx(j.ColorPicker,{value:e,onChange:n})}),children:u.jsx("span",{className:j.clsx("univer-flex univer-cursor-pointer univer-items-center univer-rounded univer-p-1 hover:univer-bg-gray-100 dark:hover:!univer-bg-gray-700",s),children:m()})})},oe=i=>{var s,a,m,d,h;const e=i.rule;if(!e)return null;const n=C.useMemo(()=>{if(e.type===t.CFRuleType.colorScale){const c=e.config.map((b,S)=>({color:new l.ColorKit(b.color),value:S})),v=c.length-1;return new Array(5).fill("").map((b,S,y)=>S*v/(y.length-1)).map(b=>t.getColorScaleFromValue(c,b))}return null},[e]),r=C.useMemo(()=>{if(e.type===t.CFRuleType.iconSet)return e.config.map(c=>{const v=t.iconMap[c.iconType];return v&&v[Number(c.iconId)]})},[e]),o="univer-pointer-events-none univer-flex univer-h-5 univer-min-w-[72px] univer-items-center univer-justify-center univer-text-xs";switch(e.type){case t.CFRuleType.dataBar:{const{isGradient:c}=e.config,v=c?`linear-gradient(to right, ${e.config.positiveColor||t.defaultDataBarPositiveColor}, rgb(255 255 255))`:e.config.positiveColor,p=c?`linear-gradient(to right, rgb(255 255 255),${e.config.nativeColor||t.defaultDataBarNativeColor})`:e.config.nativeColor;return u.jsxs("div",{className:o,children:[u.jsx("div",{className:"univer-h-full univer-w-1/2 univer-border univer-border-solid",style:{background:p,borderColor:(s=e.config.nativeColor)!=null?s:t.defaultDataBarNativeColor}}),u.jsx("div",{className:"univer-h-full univer-w-1/2 univer-border univer-border-solid",style:{background:v,borderColor:(a=e.config.positiveColor)!=null?a:t.defaultDataBarPositiveColor}})]})}case t.CFRuleType.colorScale:return n&&u.jsx("div",{className:o,children:n.map((c,v)=>u.jsx("div",{className:"univer-h-full",style:{width:`${100/n.length}%`,background:c}},v))});case t.CFRuleType.iconSet:return r&&u.jsx("div",{className:o,children:r.map((c,v)=>c?u.jsx("img",{className:"univer-h-full",src:c,draggable:!1},v):u.jsx(Ce,{},v))});case t.CFRuleType.highlightCell:{const{ul:c,st:v,it:p,bl:b,bg:S,cl:y}=e.style,_=(c==null?void 0:c.s)===l.BooleanNumber.TRUE,R=(v==null?void 0:v.s)===l.BooleanNumber.TRUE,w=p===l.BooleanNumber.TRUE,E=b===l.BooleanNumber.TRUE,N=(m=S==null?void 0:S.rgb)!=null?m:t.DEFAULT_BG_COLOR,g=(d=y==null?void 0:y.rgb)!=null?d:t.DEFAULT_FONT_COLOR,T={textDecoration:(h=`${_?"underline":""} ${R?"line-through":""}`.replace(/^ /,""))!=null?h:void 0,backgroundColor:N,color:g};return u.jsx("div",{className:j.clsx(o,{"univer-font-bold":E,"univer-italic":w}),style:T,children:"123"})}}},ye=j.clsx("univer-mt-5 univer-px-1 univer-py-2 univer-rounded",j.borderClassName),Q=(i,e)=>({label:e.t(`sheet.cf.valueType.${i}`),value:i}),De=i=>{var S;const{type:e,className:n,onChange:r,id:o,value:s}=i,a=D.useDependency(l.IUniverInstanceService),m=a.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET).getUnitId(),d=(S=a.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:S.getSheetId(),h=C.useMemo(()=>String(s).startsWith("=")?String(s):"=",[s]),c=C.useMemo(()=>[t.CFValueType.max,t.CFValueType.min,"none"].includes(e)?{disabled:!0}:[t.CFValueType.percent,t.CFValueType.percentile].includes(e)?{min:0,max:100}:{min:Number.MIN_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER},[e]),v=C.useRef(null),[p,b]=C.useState(!1);return D.useSidebarClick(y=>{var R;(R=v.current)!=null&&R.isClickOutSide(y)&&b(!1)}),e===t.CFValueType.formula?u.jsx("div",{className:"univer-ml-1 univer-w-full",children:u.jsx(fe.FormulaEditor,{ref:v,className:j.clsx("univer-box-border univer-h-8 univer-w-full univer-cursor-pointer univer-items-center univer-rounded-lg univer-bg-white univer-pt-2 univer-transition-colors hover:univer-border-primary-600 dark:!univer-bg-gray-700 dark:!univer-text-white [&>div:first-child]:univer-px-2.5 [&>div]:univer-h-5 [&>div]:univer-ring-transparent",j.borderClassName),initValue:h,unitId:m,subUnitId:d,isFocus:p,onChange:(y="")=>{r(y||"")},onFocus:()=>b(!0)})}):u.jsx(j.InputNumber,{className:n,value:Number(i.value)||0,onChange:y=>i.onChange(y||0),...c})},Ht=i=>{var P;const{interceptorManager:e}=i,n=D.useDependency(l.LocaleService),r=((P=i.rule)==null?void 0:P.type)===t.CFRuleType.colorScale?i.rule:void 0,o=[Q(t.CFValueType.num,n),Q(t.CFValueType.percent,n),Q(t.CFValueType.percentile,n),Q(t.CFValueType.formula,n)],s=[Q(t.CFValueType.min,n),...o],a=[Q("none",n),...o],m=[Q(t.CFValueType.max,n),...o],[d,h]=C.useState(()=>{var F;const f=t.CFValueType.min;return r&&((F=r.config[0])==null?void 0:F.value.type)||f}),[c,v]=C.useState(()=>{var F;const f="none";return!r||r.config.length!==3?f:((F=r.config[1])==null?void 0:F.value.type)||f}),[p,b]=C.useState(()=>{var F;const f=t.CFValueType.max;return r&&((F=r.config[r.config.length-1])==null?void 0:F.value.type)||f}),[S,y]=C.useState(()=>{if(!r)return 10;const F=r.config[0];return(F==null?void 0:F.value.value)===void 0?10:F==null?void 0:F.value.value}),[_,R]=C.useState(()=>{var A;if(!r||r.config.length!==3)return 50;const F=(A=r.config[1])==null?void 0:A.value.value;return F===void 0?50:F}),[w,E]=C.useState(()=>{var A;if(!r)return 90;const F=(A=r.config[r.config.length-1])==null?void 0:A.value.value;return F===void 0?90:F}),[N,g]=C.useState(()=>{var F;const f="#d0d9fb";return r&&((F=r.config[0])==null?void 0:F.color)||f}),[T,x]=C.useState(()=>{var F;const f="#7790f3";return!r||r.config.length!==3?f:((F=r.config[1])==null?void 0:F.color)||f}),[I,V]=C.useState(()=>{var F;const f="#2e55ef";return r&&((F=r.config[r.config.length-1])==null?void 0:F.color)||f}),M=C.useMemo(()=>f=>{const{minType:F,medianType:A,maxType:U,minValue:L,medianValue:B,maxValue:H,minColor:q,medianColor:X,maxColor:J}=f,Y=[];return Y.push({color:q,value:{type:F,value:L}}),A!=="none"&&Y.push({color:X,value:{type:A,value:B}}),Y.push({color:J,value:{type:U,value:H}}),{config:Y.map((Ie,Se)=>({...Ie,index:Se})),type:t.CFRuleType.colorScale}},[]);C.useEffect(()=>e.intercept(e.getInterceptPoints().submit,{handler(){return M({minType:d,medianType:c,maxType:p,minValue:S,medianValue:_,maxValue:w,minColor:N,medianColor:T,maxColor:I})}}),[M,d,c,p,S,_,w,N,T,I,e]);const k=f=>{i.onChange(M(f))};return u.jsxs("div",{children:[u.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:n.t("sheet.cf.panel.styleRule")}),u.jsx("div",{className:ye,children:u.jsx(oe,{rule:M({minType:d,medianType:c,maxType:p,minValue:S,medianValue:_,maxValue:w,minColor:N,medianColor:T,maxColor:I})})}),u.jsx("div",{className:"univer-mt-3 univer-text-xs univer-text-gray-600 dark:!univer-text-gray-200",children:n.t("sheet.cf.valueType.min")}),u.jsxs("div",{className:"univer-mt-3 univer-flex univer-h-8 univer-items-center",children:[u.jsx(j.Select,{className:"univer-flex-shrink-0",options:s,value:d,onChange:f=>{h(f);const F=t.createDefaultValueByValueType(f,10);y(F),k({minType:f,medianType:c,maxType:p,minValue:F,medianValue:_,maxValue:w,minColor:N,medianColor:T,maxColor:I})}}),u.jsx(De,{id:"min",className:"univer-ml-1",value:S,type:d,onChange:f=>{y(f),k({minType:d,medianType:c,maxType:p,minValue:f,medianValue:_,maxValue:w,minColor:N,medianColor:T,maxColor:I})}}),u.jsx(ee,{className:"univer-ml-1",color:N,onChange:f=>{g(f),k({minType:d,medianType:c,maxType:p,minValue:S,medianValue:_,maxValue:w,minColor:f,medianColor:T,maxColor:I})}})]}),u.jsx("div",{className:"univer-text-gray-600dark:!univer-text-gray-200 univer-mt-3 univer-text-xs",children:n.t("sheet.cf.panel.medianValue")}),u.jsxs("div",{className:"univer-mt-3 univer-flex univer-h-8 univer-items-center",children:[u.jsx(j.Select,{className:"univer-flex-shrink-0",options:a,value:c,onChange:f=>{v(f);const F=t.createDefaultValueByValueType(f,50);R(F),k({minType:d,medianType:f,maxType:p,minValue:S,medianValue:F,maxValue:w,minColor:N,medianColor:T,maxColor:I})}}),u.jsx(De,{id:"median",className:"univer-ml-1",value:_,type:c,onChange:f=>{R(f),k({minType:d,medianType:c,maxType:p,minValue:S,medianValue:f,maxValue:w,minColor:N,medianColor:T,maxColor:I})}}),c!=="none"&&u.jsx(ee,{className:"univer-ml-1",color:T,onChange:f=>{x(f),k({minType:d,medianType:c,maxType:p,minValue:S,medianValue:_,maxValue:w,minColor:N,medianColor:f,maxColor:I})}})]}),u.jsx("div",{className:"univer-mt-3 univer-text-xs univer-text-gray-600 dark:!univer-text-gray-200",children:n.t("sheet.cf.valueType.max")}),u.jsxs("div",{className:"univer-mt-3 univer-flex univer-h-8 univer-items-center",children:[u.jsx(j.Select,{className:"univer-flex-shrink-0",options:m,value:p,onChange:f=>{b(f);const F=t.createDefaultValueByValueType(f,90);E(F),k({minType:d,medianType:c,maxType:f,minValue:S,medianValue:_,maxValue:F,minColor:N,medianColor:T,maxColor:I})}}),u.jsx(De,{id:"max",className:"univer-ml-1",value:w,type:p,onChange:f=>{E(f),k({minType:d,medianType:c,maxType:p,minValue:S,medianValue:_,maxValue:f,minColor:N,medianColor:T,maxColor:I})}}),u.jsx(ee,{className:"univer-ml-1",color:I,onChange:f=>{V(f),k({minType:d,medianType:c,maxType:p,minValue:S,medianValue:_,maxValue:w,minColor:N,medianColor:T,maxColor:f})}})]})]})},te=(i,e)=>({label:e.t(`sheet.cf.valueType.${i}`),value:i}),nt=i=>{var y;const{onChange:e,className:n,value:r,type:o,id:s,disabled:a=!1}=i,m=D.useDependency(l.IUniverInstanceService),d=m.getCurrentUnitOfType(l.UniverInstanceType.UNIVER_SHEET).getUnitId(),h=(y=m.getCurrentUnitOfType(l.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:y.getSheetId(),c=C.useRef(null),[v,p]=C.useState(!1);D.useSidebarClick(_=>{var w;(w=c.current)!=null&&w.isClickOutSide(_)&&p(!1)});const b=C.useRef(r),S=C.useMemo(()=>[t.CFValueType.percentile,t.CFValueType.percent].includes(o)?{max:100,min:0}:{min:Number.MIN_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER},[o]);if(o===t.CFValueType.formula){const _=String(b.current).startsWith("=")?String(b.current)||"":"=";return u.jsx("div",{className:"univer-ml-3 univer-w-full",children:u.jsx(fe.FormulaEditor,{ref:c,className:j.clsx("univer-box-border univer-h-8 univer-w-full univer-cursor-pointer univer-items-center univer-rounded-lg univer-bg-white univer-pt-2 univer-transition-colors hover:univer-border-primary-600 dark:!univer-bg-gray-700 dark:!univer-text-white [&>div:first-child]:univer-px-2.5 [&>div]:univer-h-5 [&>div]:univer-ring-transparent",j.borderClassName),initValue:_,unitId:d,subUnitId:h,isFocus:v,onChange:(R="")=>{e(R||"")},onFocus:()=>p(!0)})})}return u.jsx(j.InputNumber,{className:n,value:Number(r)||0,disabled:a,onChange:_=>{e(_||0)},...S})},Wt=i=>{var P;const{interceptorManager:e}=i,n=D.useDependency(l.LocaleService),r=((P=i.rule)==null?void 0:P.type)===t.CFRuleType.dataBar?i.rule:void 0,[o,s]=C.useState(()=>{var F;return r&&(F=r.config)!=null&&F.isGradient?"1":"0"}),[a,m]=C.useState(()=>{var f;return r&&((f=r.config)==null?void 0:f.positiveColor)||t.defaultDataBarPositiveColor}),[d,h]=C.useState(()=>{var f;return r&&((f=r.config)==null?void 0:f.nativeColor)||t.defaultDataBarNativeColor}),c=[te(t.CFValueType.num,n),te(t.CFValueType.percent,n),te(t.CFValueType.percentile,n),te(t.CFValueType.formula,n)],v=[te(t.CFValueType.min,n),...c],p=[te(t.CFValueType.max,n),...c],[b,S]=C.useState(()=>{var F;const f=v[0].value;return r&&((F=r.config)==null?void 0:F.min.type)||f}),[y,_]=C.useState(()=>{var F;const f=p[0].value;return r&&((F=r.config)==null?void 0:F.max.type)||f}),[R,w]=C.useState(()=>{var A;if(!r)return 0;const F=((A=r.config)==null?void 0:A.min)||{};return F.type===t.CFValueType.formula?F.value||"=":F.value||0}),[E,N]=C.useState(()=>{var A;if(!r)return 100;const F=((A=r.config)==null?void 0:A.max)||{};return F.type===t.CFValueType.formula?F.value||"=":F.value===void 0?100:F.value}),[g,T]=C.useState(()=>r?r.isShowValue===void 0?!0:!!r.isShowValue:!0),x=f=>({config:{min:{type:f.minValueType,value:f.minValue},max:{type:f.maxValueType,value:f.maxValue},isGradient:f.isGradient==="1",positiveColor:f.positiveColor||t.defaultDataBarPositiveColor,nativeColor:f.nativeColor||t.defaultDataBarNativeColor},type:t.CFRuleType.dataBar,isShowValue:f.isShowValue});C.useEffect(()=>e.intercept(e.getInterceptPoints().submit,{handler(){return x({isGradient:o,minValue:R,minValueType:b,maxValue:E,maxValueType:y,positiveColor:a,nativeColor:d,isShowValue:g})}}),[o,R,b,E,y,a,d,e,g]);const I=f=>{i.onChange(x(f))},V=f=>{m(f),I({isGradient:o,minValue:R,minValueType:b,maxValue:E,maxValueType:y,positiveColor:f,nativeColor:d,isShowValue:g})},M=f=>{h(f),I({isGradient:o,minValue:R,minValueType:b,maxValue:E,maxValueType:y,positiveColor:a,nativeColor:f,isShowValue:g})},k=f=>c.map(F=>F.value).includes(f);return u.jsxs("div",{children:[u.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:n.t("sheet.cf.panel.styleRule")}),u.jsx("div",{className:ye,children:u.jsx(oe,{rule:x({isGradient:o,minValue:R,minValueType:b,maxValue:E,maxValueType:y,positiveColor:a,nativeColor:d,isShowValue:g})})}),u.jsxs("div",{children:[u.jsx("div",{className:"univer-mt-3 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:n.t("sheet.cf.panel.fillType")}),u.jsxs("div",{className:"univer-ml-1 univer-mt-3 univer-flex univer-items-center",children:[u.jsxs(j.RadioGroup,{value:o,onChange:f=>{s(f),I({isGradient:f,minValue:R,minValueType:b,maxValue:E,maxValueType:y,positiveColor:a,nativeColor:d,isShowValue:g})},children:[u.jsx(j.Radio,{value:"0",children:u.jsx("span",{className:"univer-text-xs",children:n.t("sheet.cf.panel.pureColor")})}),u.jsx(j.Radio,{value:"1",children:u.jsx("span",{className:"univer-text-xs",children:n.t("sheet.cf.panel.gradient")})})]}),u.jsxs("div",{className:"univer-ml-6 univer-flex univer-items-center univer-text-xs",children:[u.jsx(j.Checkbox,{checked:!g,onChange:f=>{T(!f),I({isGradient:f,minValue:R,minValueType:b,maxValue:E,maxValueType:y,positiveColor:a,nativeColor:d,isShowValue:!f})}}),n.t("sheet.cf.panel.onlyShowDataBar")]})]})]}),u.jsxs("div",{children:[u.jsx("div",{className:"univer-mt-3 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:n.t("sheet.cf.panel.colorSet")}),u.jsxs("div",{className:"univer-ml-1 univer-mt-3 univer-flex univer-items-center",children:[u.jsxs("div",{className:"univer-flex univer-items-center",children:[u.jsx("div",{className:"univer-text-xs",children:n.t("sheet.cf.panel.native")}),u.jsx(ee,{color:d,onChange:M})]}),u.jsxs("div",{className:"univer-ml-3 univer-flex univer-items-center",children:[u.jsx("div",{className:"univer-text-xs",children:n.t("sheet.cf.panel.positive")}),u.jsx(ee,{color:a,onChange:V})]})]})]}),u.jsxs("div",{children:[u.jsx("div",{className:"univer-mt-3 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:n.t("sheet.cf.valueType.min")}),u.jsxs("div",{className:"univer-mt-3 univer-flex univer-items-center",children:[u.jsx(j.Select,{className:"univer-w-1/2 univer-flex-shrink-0",options:v,value:b,onChange:f=>{S(f);const F=t.createDefaultValueByValueType(f,10);w(F),I({isGradient:o,minValue:F,minValueType:f,maxValue:E,maxValueType:y,positiveColor:a,nativeColor:d,isShowValue:g})}}),u.jsx(nt,{id:"min",className:"univer-ml-3",disabled:!k(b),type:b,value:R,onChange:f=>{w(f||0),I({isGradient:o,minValue:f||0,minValueType:b,maxValue:E,maxValueType:y,positiveColor:a,nativeColor:d,isShowValue:g})}})]}),u.jsx("div",{className:"univer-mt-3 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:n.t("sheet.cf.valueType.max")}),u.jsxs("div",{className:"univer-mt-3 univer-flex univer-items-center",children:[u.jsx(j.Select,{className:"univer-w-1/2 univer-flex-shrink-0",options:p,value:y,onChange:f=>{_(f);const F=t.createDefaultValueByValueType(f,90);N(F),I({isGradient:o,minValue:R,minValueType:b,maxValue:F,maxValueType:f,positiveColor:a,nativeColor:d,isShowValue:g})}}),u.jsx(nt,{className:"univer-ml-3",disabled:!k(y),id:"max",type:y,value:E,onChange:f=>{N(f||0),I({isGradient:o,minValue:R,minValueType:b,maxValue:f||0,maxValueType:y,positiveColor:a,nativeColor:d,isShowValue:g})}})]})]})]})},Te=i=>[l.BooleanNumber.FALSE,void 0].includes(i)?l.BooleanNumber.TRUE:l.BooleanNumber.FALSE,xe=i=>i!==l.BooleanNumber.FALSE,tt=i=>{const{style:e,onChange:n,className:r}=i,[o,s]=C.useState(()=>{if(e!=null&&e.bl)return e.bl}),[a,m]=C.useState(()=>{if(e!=null&&e.it)return e.it}),[d,h]=C.useState(()=>{if(e!=null&&e.ul)return e.ul.s}),[c,v]=C.useState(()=>{if(e!=null&&e.st)return e.st.s}),[p,b]=C.useState(()=>{var w;const R="#2f56ef";return(w=e==null?void 0:e.cl)!=null&&w.rgb?e.cl.rgb:R}),[S,y]=C.useState(()=>{var w;const R="#e8ecfc";return(w=e==null?void 0:e.bg)!=null&&w.rgb?e.bg.rgb:R});C.useEffect(()=>{const R={bl:o,it:a};p!==void 0&&(R.cl={rgb:p}),S!==void 0&&(R.bg={rgb:S}),c!==void 0&&(R.st={s:c}),d!==void 0&&(R.ul={s:d}),n(t.removeUndefinedAttr(R))},[o,a,d,c,p,S]);const _="univer-flex univer-cursor-pointer univer-items-center univer-rounded univer-px-1";return u.jsxs("div",{className:j.clsx("univer-my-2.5 univer-flex univer-justify-between",r),children:[u.jsx("div",{className:j.clsx(_,{"univer-bg-gray-100 dark:!univer-bg-gray-700":xe(o||l.BooleanNumber.FALSE)}),onClick:()=>s(Te(o)),children:u.jsx(pt,{})}),u.jsx("div",{className:j.clsx(_,{"univer-bg-gray-100 dark:!univer-bg-gray-700":xe(a||l.BooleanNumber.FALSE)}),onClick:()=>m(Te(a)),children:u.jsx(ft,{})}),u.jsx("div",{className:j.clsx(_,{"univer-bg-gray-100 dark:!univer-bg-gray-700":xe(d||l.BooleanNumber.FALSE)}),onClick:()=>h(Te(d)),children:u.jsx(bt,{})}),u.jsx("div",{className:j.clsx(_,{"univer-bg-gray-100 dark:!univer-bg-gray-700":xe(c||l.BooleanNumber.FALSE)}),onClick:()=>v(Te(c)),children:u.jsx(yt,{})}),u.jsx(ee,{color:p,onChange:b,Icon:It}),u.jsx(ee,{color:S,onChange:y})]})},qt=i=>{var N;const{onChange:e,interceptorManager:n}=i,r=D.useDependency(l.LocaleService),s=D.useDependency(l.IUniverInstanceService).getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET),a=s.getActiveSheet(),m=((N=i.rule)==null?void 0:N.type)===t.CFRuleType.highlightCell?i.rule:void 0,d=C.useRef(null),[h,c]=C.useState(!1),v=C.useRef(null),[p,b]=C.useState({}),[S,y]=C.useState(()=>(m==null?void 0:m.subType)===t.CFSubRuleType.formula?m.value:"="),[_,R]=C.useState(void 0),w=g=>({style:g.style,value:S,type:t.CFRuleType.highlightCell,subType:t.CFSubRuleType.formula});C.useEffect(()=>n.intercept(n.getInterceptPoints().submit,{handler(){return w({style:p})}}),[p,S,n]),C.useEffect(()=>n.intercept(n.getInterceptPoints().beforeSubmit,{handler:(T,x,I)=>_||S.length===1||!S.startsWith("=")?(R(r.t("sheet.cf.errorMessage.formulaError")),!1):I(T)}),[_,S]);const E=g=>{e(w(g))};return D.useSidebarClick(g=>{var x;(x=v.current)!=null&&x.isClickOutSide(g)&&c(!1)}),u.jsxs("div",{ref:d,children:[u.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:r.t("sheet.cf.panel.styleRule")}),u.jsx("div",{className:"univer-mt-3",children:u.jsx(fe.FormulaEditor,{ref:v,className:j.clsx("univer-box-border univer-h-8 univer-w-full univer-cursor-pointer univer-items-center univer-rounded-lg univer-bg-white univer-pt-2 univer-transition-colors hover:univer-border-primary-600 dark:!univer-bg-gray-700 dark:!univer-text-white [&>div:first-child]:univer-px-2.5 [&>div]:univer-h-5 [&>div]:univer-ring-transparent",j.borderClassName),errorText:_,isFocus:h,initValue:S,unitId:s.getUnitId(),subUnitId:a==null?void 0:a.getSheetId(),onFocus:()=>{c(!0)},onChange:g=>{y(g),E({style:p})},onVerify:(g,T)=>{!g||T.length===1?R(r.t("sheet.cf.errorMessage.formulaError")):R(void 0)}})}),u.jsx("div",{className:ye,children:u.jsx(oe,{rule:w({style:p})})}),u.jsx(tt,{style:m==null?void 0:m.style,className:"univer-mt-3",onChange:g=>{b(g),E({style:g})}})]})},Re=i=>u.jsxs("div",{className:"univer-relative",children:[u.jsx("div",{className:"univer-absolute univer-bottom-[-13px] univer-z-[999] univer-text-[10px] univer-text-red-500",children:i.errorText}),i.children]}),$=(i,e)=>({label:e.t(`sheet.cf.operator.${i}`),value:i}),Gt=i=>{const{type:e,operator:n,onChange:r,value:o,interceptorManager:s}=i,a=D.useDependency(l.LocaleService),[m,d]=C.useState(()=>typeof o=="number"?o:0),[h,c]=C.useState(""),[v,p]=C.useState(()=>typeof o=="string"?o:""),[b,S]=C.useState(""),[y,_]=C.useState(()=>Array.isArray(o)?o[0]===void 0?0:o[0]:0),[R,w]=C.useState(""),[E,N]=C.useState(()=>Array.isArray(o)?o[1]===void 0?100:o[1]:100),[g,T]=C.useState("");switch(C.useEffect(()=>{switch(e){case t.CFSubRuleType.text:{[t.CFTextOperator.beginsWith,t.CFTextOperator.endsWith,t.CFTextOperator.containsText,t.CFTextOperator.notContainsText,t.CFTextOperator.equal,t.CFTextOperator.notEqual].includes(n)&&r(v);break}case t.CFSubRuleType.number:{[t.CFNumberOperator.equal,t.CFNumberOperator.notEqual,t.CFNumberOperator.greaterThan,t.CFNumberOperator.greaterThanOrEqual,t.CFNumberOperator.lessThan,t.CFNumberOperator.lessThanOrEqual].includes(n)&&r(m),[t.CFNumberOperator.between,t.CFNumberOperator.notBetween].includes(n)&&r([y,E]);break}}},[e]),C.useEffect(()=>{const x=s.intercept(s.getInterceptPoints().beforeSubmit,{handler:(I,V,M)=>{switch(e){case t.CFSubRuleType.text:if([t.CFTextOperator.beginsWith,t.CFTextOperator.containsText,t.CFTextOperator.endsWith,t.CFTextOperator.notEqual,t.CFTextOperator.notContainsText,t.CFTextOperator.equal].includes(n))return v?M(I):(S(a.t("sheet.cf.errorMessage.notBlank")),!1)}return M(I)}});return()=>{x()}},[e,m,v,n]),e){case t.CFSubRuleType.text:{if([t.CFTextOperator.beginsWith,t.CFTextOperator.endsWith,t.CFTextOperator.containsText,t.CFTextOperator.notContainsText,t.CFTextOperator.equal,t.CFTextOperator.notEqual].includes(n)){const x=I=>{p(I),r(I)};return u.jsx("div",{className:"univer-mt-3",children:u.jsx(Re,{errorText:b,children:u.jsx(j.Input,{value:v,onChange:I=>{S(""),x(I)}})})})}break}case t.CFSubRuleType.number:{if([t.CFNumberOperator.equal,t.CFNumberOperator.notEqual,t.CFNumberOperator.greaterThan,t.CFNumberOperator.greaterThanOrEqual,t.CFNumberOperator.lessThan,t.CFNumberOperator.lessThanOrEqual].includes(n)){const x=I=>{d(I||0),r(I||0),c("")};return u.jsx("div",{className:"univer-mt-3",children:u.jsx(Re,{errorText:h,children:u.jsx(j.InputNumber,{className:"univer-w-full",min:Number.MIN_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER,value:m,onChange:x})})})}if([t.CFNumberOperator.between,t.CFNumberOperator.notBetween].includes(n)){const x=V=>{_(V||0),r([V||0,E]),w("")},I=V=>{N(V||0),r([y,V||0]),T("")};return u.jsxs("div",{className:"univer-mt-3 univer-flex univer-items-center",children:[u.jsx(Re,{errorText:R,children:u.jsx(j.InputNumber,{min:Number.MIN_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER,value:y,onChange:x})}),u.jsx(Re,{errorText:g,children:u.jsx(j.InputNumber,{className:"univer-ml-3",min:Number.MIN_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER,value:E,onChange:I})})]})}}}return null},rt=(i,e)=>{switch(i){case t.CFSubRuleType.text:return[$(t.CFTextOperator.containsText,e),$(t.CFTextOperator.notContainsText,e),$(t.CFTextOperator.beginsWith,e),$(t.CFTextOperator.endsWith,e),$(t.CFTextOperator.equal,e),$(t.CFTextOperator.notEqual,e),$(t.CFTextOperator.containsBlanks,e),$(t.CFTextOperator.notContainsBlanks,e),$(t.CFTextOperator.containsErrors,e),$(t.CFTextOperator.notContainsErrors,e)];case t.CFSubRuleType.number:return[$(t.CFNumberOperator.between,e),$(t.CFNumberOperator.notBetween,e),$(t.CFNumberOperator.equal,e),$(t.CFNumberOperator.notEqual,e),$(t.CFNumberOperator.greaterThan,e),$(t.CFNumberOperator.greaterThanOrEqual,e),$(t.CFNumberOperator.lessThan,e),$(t.CFNumberOperator.lessThanOrEqual,e)];case t.CFSubRuleType.timePeriod:return[$(t.CFTimePeriodOperator.yesterday,e),$(t.CFTimePeriodOperator.today,e),$(t.CFTimePeriodOperator.tomorrow,e),$(t.CFTimePeriodOperator.last7Days,e),$(t.CFTimePeriodOperator.lastWeek,e),$(t.CFTimePeriodOperator.thisWeek,e),$(t.CFTimePeriodOperator.nextWeek,e),$(t.CFTimePeriodOperator.lastMonth,e),$(t.CFTimePeriodOperator.thisMonth,e),$(t.CFTimePeriodOperator.nextMonth,e)]}},it=i=>{var N;const{interceptorManager:e,onChange:n}=i,r=D.useDependency(l.LocaleService),o=((N=i.rule)==null?void 0:N.type)===t.CFRuleType.highlightCell?i.rule:void 0,[s,a]=C.useState(()=>{const g=t.CFSubRuleType.text;return o&&o.subType||g}),m=[{value:t.CFSubRuleType.text,label:r.t("sheet.cf.subRuleType.text")},{value:t.CFSubRuleType.number,label:r.t("sheet.cf.subRuleType.number")},{value:t.CFSubRuleType.timePeriod,label:r.t("sheet.cf.subRuleType.timePeriod")},{value:t.CFSubRuleType.duplicateValues,label:r.t("sheet.cf.subRuleType.duplicateValues")},{value:t.CFSubRuleType.uniqueValues,label:r.t("sheet.cf.subRuleType.uniqueValues")}],d=C.useMemo(()=>rt(s,r),[s]),[h,c]=C.useState(()=>{const g=d?d[0].value:void 0;return o&&o.operator||g}),[v,p]=C.useState(()=>{var x;return o?(x=o.value)!=null?x:t.createDefaultValue(o.subType,o.operator):""}),[b,S]=C.useState({}),y=C.useMemo(()=>g=>{var T,x,I,V,M,k,P,f,F,A,U,L,B,H,q;switch(g.subType||s){case t.CFSubRuleType.text:{if([t.CFTextOperator.beginsWith,t.CFTextOperator.endsWith,t.CFTextOperator.containsText,t.CFTextOperator.notContainsText,t.CFTextOperator.equal,t.CFTextOperator.notEqual].includes(h))return{type:t.CFRuleType.highlightCell,subType:(T=g.subType)!=null?T:s,operator:(x=g.operator)!=null?x:h,style:(I=g.style)!=null?I:b,value:(V=g.value)!=null?V:v};break}case t.CFSubRuleType.number:{if([t.CFNumberOperator.equal,t.CFNumberOperator.notEqual,t.CFNumberOperator.greaterThan,t.CFNumberOperator.greaterThanOrEqual,t.CFNumberOperator.lessThan,t.CFNumberOperator.lessThanOrEqual].includes(h))return{type:t.CFRuleType.highlightCell,subType:(M=g.subType)!=null?M:s,operator:(k=g.operator)!=null?k:h,style:(P=g.style)!=null?P:b,value:(f=g.value)!=null?f:v};if([t.CFNumberOperator.between,t.CFNumberOperator.notBetween].includes(h))return{type:t.CFRuleType.highlightCell,subType:(F=g.subType)!=null?F:s,operator:(A=g.operator)!=null?A:h,style:(U=g.style)!=null?U:b,value:(L=g.value)!=null?L:v};break}}return{type:t.CFRuleType.highlightCell,subType:(B=g.subType)!=null?B:s,operator:(H=g.operator)!=null?H:h,style:(q=g.style)!=null?q:b}},[s,h,v,b]);C.useEffect(()=>e.intercept(e.getInterceptPoints().submit,{handler(){return y({})}}),[y,e]),C.useEffect(()=>{m.some(g=>g.value===s)||a(m[0].value)},[m]);const _=g=>{const T=g,x=rt(T,r),I=x&&x[0].value;a(T),c(I),I&&p(t.createDefaultValue(T,I)),n(y({subType:T,operator:I}))},R=g=>{const T=g;c(T),n(y({operator:T}))},w=g=>{p(g),n(y({value:g}))},E=C.useMemo(()=>`${s}_${h}_${Math.random()}`,[s,h]);return u.jsxs("div",{children:[u.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:r.t("sheet.cf.panel.styleRule")}),u.jsxs("div",{className:"univer-flex univer-justify-between univer-gap-4",children:[u.jsx(j.Select,{className:"univer-mt-3 univer-w-full",onChange:_,value:s,options:m}),(d==null?void 0:d.length)&&u.jsx(j.Select,{className:"univer-mt-3 univer-w-full",onChange:R,value:h||"",options:d})]}),u.jsx(Gt,{value:v,interceptorManager:e,type:s,operator:h,rule:o,onChange:w},E),u.jsx("div",{className:ye,children:u.jsx(oe,{rule:y({})})}),u.jsx(tt,{style:o==null?void 0:o.style,className:"univer-ml-1",onChange:g=>{S(g),n(y({style:g}))}})]})},Tt=(i,e)=>(t.iconMap[i]||[])[Number(e)]||"",Zt=i=>{var c;const{error:e,type:n,onChange:r}=i,o=D.useDependency(l.IUniverInstanceService),s=o.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET).getUnitId(),a=(c=o.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:c.getSheetId(),m=C.useRef(null),[d,h]=C.useState(!1);return D.useSidebarClick(v=>{var b;(b=m.current)!=null&&b.isClickOutSide(v)&&h(!1)}),u.jsx("div",{className:"univer-relative",children:n!==t.CFValueType.formula?u.jsxs(u.Fragment,{children:[u.jsx(j.InputNumber,{className:j.clsx({"univer-border-red-500":e}),value:Number(i.value)||0,onChange:v=>r(v!=null?v:0)}),e&&u.jsx("div",{className:"univer-absolute univer-text-xs univer-text-red-500",children:e})]}):u.jsx("div",{className:"univer-w-full",children:u.jsx(fe.FormulaEditor,{ref:m,className:j.clsx("univer-box-border univer-h-8 univer-w-full univer-cursor-pointer univer-items-center univer-rounded-lg univer-bg-white univer-pt-2 univer-transition-colors hover:univer-border-primary-600 dark:!univer-bg-gray-700 dark:!univer-text-white [&>div:first-child]:univer-px-2.5 [&>div]:univer-h-5 [&>div]:univer-ring-transparent",j.borderClassName),initValue:String(i.value),unitId:s,subUnitId:a,isFocus:d,onChange:(v="")=>{r(v||"")},onFocus:()=>h(!0)})})})},ot=(i,e,n)=>({operator:t.CFNumberOperator.greaterThan,value:{type:t.CFValueType.num,value:(n.length-1-e)*10},iconType:i,iconId:String(e)}),Yt=C.forwardRef((i,e)=>{const{onClick:n}=i,r=D.useDependency(l.LocaleService),o=s=>{n(s)};return u.jsx("div",{ref:e,className:"univer-w-80",children:t.iconGroup.map((s,a)=>u.jsxs("div",{className:"univer-mb-3",children:[u.jsx("div",{className:"univer-mb-1 univer-text-sm",children:r.t(s.title)}),u.jsx("div",{className:"univer-flex univer-flex-wrap",children:s.group.map(m=>u.jsx("div",{className:"univer-mb-1 univer-flex univer-w-1/2 univer-items-center",onClick:()=>{o(m.name)},children:u.jsx("a",{className:"univer-flex univer-cursor-pointer univer-rounded hover:univer-bg-gray-100 dark:hover:!univer-bg-gray-700",children:m.list.map((d,h)=>u.jsx("img",{className:"univer-size-5",src:d,draggable:!1},h))})},m.name))})]},a))})}),zt=i=>{const{onClick:e}=i,n=C.useMemo(()=>{const o=[];for(const s in t.iconMap){const a=t.iconMap[s],m=s;a.forEach((d,h)=>{o.push({iconType:m,base64:d,iconId:String(h)})})}return o},[]),r=o=>{e(o.iconType,o.iconId)};return u.jsxs("div",{children:[u.jsxs("div",{className:"univer-mb-2.5 univer-flex univer-cursor-pointer univer-items-center univer-pl-1",onClick:()=>r({iconType:t.EMPTY_ICON_TYPE,iconId:""}),children:[u.jsx(Ce,{className:"univer-size-5"}),u.jsx("span",{className:"univer-ml-2",children:"无单元格图标"})]}),u.jsx("div",{className:"univer-flex univer-w-64 univer-flex-wrap",children:n.map(o=>u.jsx("div",{className:"univer-mb-2 univer-mr-2 univer-flex univer-cursor-pointer univer-items-center univer-justify-center univer-rounded hover:univer-bg-gray-100 dark:hover:!univer-bg-gray-700",children:u.jsx("img",{className:"univer-size-5",src:o.base64,draggable:!1,onClick:()=>r(o)})},`${o.iconType}_${o.iconId}`))})]})},Kt=i=>{const{onChange:e,configList:n,errorMap:r={}}=i,o=D.useDependency(l.LocaleService),s=[{label:o.t(`sheet.cf.symbol.${t.CFNumberOperator.greaterThan}`),value:t.CFNumberOperator.greaterThan},{label:o.t(`sheet.cf.symbol.${t.CFNumberOperator.greaterThanOrEqual}`),value:t.CFNumberOperator.greaterThanOrEqual}],a=[{label:o.t(`sheet.cf.valueType.${t.CFValueType.num}`),value:t.CFValueType.num},{label:o.t(`sheet.cf.valueType.${t.CFValueType.percent}`),value:t.CFValueType.percent},{label:o.t(`sheet.cf.valueType.${t.CFValueType.percentile}`),value:t.CFValueType.percentile},{label:o.t(`sheet.cf.valueType.${t.CFValueType.formula}`),value:t.CFValueType.formula}],m=(v,p)=>{e([String(p),"value","value"],v)},d=(v,p)=>{e([String(p),"operator"],v);const b=t.createDefaultValue(t.CFSubRuleType.number,v);m(b,p)},h=(v,p)=>{e([String(p),"value","type"],v);const b=n[p],S=t.createDefaultValue(t.CFSubRuleType.number,b.operator);m(S,p)};return C.useMemo(()=>n.map((v,p)=>{const b=r[p],S=Tt(v.iconType,v.iconId),y=p===n.length-1,_=p===0,R=n[p-1],w=(R==null?void 0:R.value.type)===t.CFValueType.formula?o.t("sheet.cf.valueType.formula"):R==null?void 0:R.value.value,E=(N,g)=>{const T={...v,iconId:g,iconType:N};e([String(p)],T)};return u.jsxs("div",{className:p?"univer-mt-6":"univer-mt-3",children:[u.jsxs("div",{className:"univer-mt-3 univer-flex univer-items-center univer-justify-between univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:[u.jsxs("div",{className:"univer-w-[45%]",children:[o.t("sheet.cf.iconSet.icon"),p+1]}),u.jsx("div",{className:"univer-w-[45%]",children:u.jsxs(u.Fragment,{children:[!_&&!y&&o.t("sheet.cf.iconSet.rule"),!_&&!y&&u.jsxs("span",{className:"univer-font-medium univer-text-gray-600 dark:!univer-text-gray-200",children:[o.t("sheet.cf.iconSet.when"),o.t(`sheet.cf.symbol.${t.getOppositeOperator(R.operator)}`),w,y?"":` ${o.t("sheet.cf.iconSet.and")} `]})]})})]}),u.jsxs("div",{className:"univer-mt-3 univer-grid univer-grid-cols-2 univer-gap-4",children:[u.jsx("div",{className:"univer-flex univer-items-center",children:u.jsx(j.Dropdown,{overlay:u.jsx("div",{className:"univer-rounded-lg univer-p-4",children:u.jsx(zt,{onClick:E,iconId:v.iconId,iconType:v.iconType})}),children:u.jsxs("div",{className:j.clsx("univer-box-border univer-flex univer-h-8 univer-w-full univer-items-center univer-justify-between univer-rounded-md univer-bg-white univer-px-4 univer-py-2 univer-text-xs univer-text-gray-600 univer-transition-all hover:univer-border-primary-600 dark:!univer-text-gray-200",j.borderClassName),children:[S?u.jsx("img",{src:S,className:"univer-size-4",draggable:!1}):u.jsx(Ce,{className:"univer-size-4"}),u.jsx(et,{})]})})}),y?u.jsxs("div",{className:"univer-mt-0 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:[o.t("sheet.cf.iconSet.rule"),u.jsxs("span",{className:"univer-font-medium",children:[o.t("sheet.cf.iconSet.when"),o.t(`sheet.cf.symbol.${t.getOppositeOperator(R.operator)}`),w,y?"":` ${o.t("sheet.cf.iconSet.and")} `]})]}):u.jsx(j.Select,{options:s,value:v.operator,onChange:N=>{d(N,p)}})]}),y?u.jsx("div",{}):u.jsxs(u.Fragment,{children:[u.jsxs("div",{className:"univer-mt-3 univer-grid univer-grid-cols-2 univer-gap-4 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:[u.jsx("div",{children:o.t("sheet.cf.iconSet.type")}),u.jsx("div",{children:o.t("sheet.cf.iconSet.value")})]}),u.jsxs("div",{className:"univer-mt-3 univer-grid univer-grid-cols-2 univer-gap-4",children:[u.jsx(j.Select,{options:a,value:v.value.type,onChange:N=>{h(N,p)}}),u.jsx(Zt,{id:p,type:v.value.type,error:b,value:v.value.value||"",onChange:N=>{m(N,p)}})]})]})]},p)}),[n,r])},Xt=i=>{var N;const{interceptorManager:e}=i,n=((N=i.rule)==null?void 0:N.type)===t.CFRuleType.iconSet?i.rule:void 0,r=D.useDependency(l.LocaleService),[o,s]=C.useState({}),[a,m]=C.useState(()=>{const g=Object.keys(t.iconMap)[0];if(n&&n.config.length){const T=n.config[0].iconType;if(!n.config.some(I=>I.iconType!==T))return T}return g}),[d,h]=C.useState(()=>{if(n&&n.config.length)return l.Tools.deepClone(n==null?void 0:n.config);const g=t.iconMap[a]||[];return new Array(g.length).fill("").map((T,x,I)=>x===I.length-1?{operator:t.CFNumberOperator.lessThanOrEqual,value:{type:t.CFValueType.num,value:Number.MAX_SAFE_INTEGER},iconType:a,iconId:String(x)}:ot(a,x,I))}),[c,v]=C.useState(()=>n?!!n.isShowValue:!0),p=C.useMemo(()=>{const g=d.map(T=>Tt(T.iconType,T.iconId));return u.jsx("div",{className:"univer-flex univer-items-center",children:g.map((T,x)=>T?u.jsx("img",{className:"univer-size-5",src:T},x):u.jsx(Ce,{className:"univer-size-5"},x))})},[d]),b=g=>{if(g.reduce((x,I,V)=>x.preType&&!x.result||g.length-1===V?x:I.value.type===t.CFValueType.formula?{preType:t.CFValueType.formula,result:!1}:x.preType?{result:x.preType===I.value.type,preType:I.value.type}:{result:!0,preType:I.value.type},{result:!0,preType:""}).result&&[t.CFValueType.num,t.CFValueType.percent,t.CFValueType.percentile].includes(g[0].value.type)){const x={};return g.forEach((I,V,M)=>{if(V-1<0||V===M.length-1)return;const P=g[V-1],f=t.getOppositeOperator(P.operator);t.compareWithNumber({operator:f,value:P.value.value},I.value.value)||(x[V]=`${r.t(`sheet.cf.form.${f}`,String(P.value.value))} `)}),x}return{}},S=(g,T)=>{l.get(d,g)!==T&&(l.set(d,g,T),h([...d]),s(b(d)))},y=g=>{m(g);const T=t.iconMap[g]||[],x=new Array(T.length).fill("").map((I,V,M)=>ot(g,V,M));h(x),s(b(x))};C.useEffect(()=>{const g=e.intercept(e.getInterceptPoints().submit,{handler(){return{type:t.CFRuleType.iconSet,isShowValue:c,config:d}}});return()=>{g()}},[c,d,e]),C.useEffect(()=>{const g=e.intercept(e.getInterceptPoints().beforeSubmit,{handler(){return Object.keys(o).length===0}});return()=>{g()}},[c,d,e,o]);const _=()=>{const g=d.map(T=>({...T}));d.forEach((T,x)=>{const I=d.length-1-x,V=g[I];T.iconId=V.iconId,T.iconType=V.iconType}),h([...d])},R=D.useDependency(D.ILayoutService),[w,E]=C.useState();return D.useScrollYOverContainer(w,R.rootContainerElement),u.jsxs("div",{children:[u.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-600",children:r.t("sheet.cf.panel.styleRule")}),u.jsx("div",{className:"univer-mt-3",children:u.jsx(j.Dropdown,{overlay:u.jsx("div",{className:"univer-rounded-lg univer-p-4",children:u.jsx(Yt,{ref:g=>{!w&&g&&E(g)},iconType:a,onClick:y})}),children:u.jsxs("div",{className:j.clsx("univer-box-border univer-flex univer-h-8 univer-w-full univer-items-center univer-justify-between univer-rounded-md univer-bg-white univer-px-4 univer-py-2 univer-text-xs univer-text-gray-600 univer-transition-all hover:univer-border-primary-600",j.borderClassName),children:[p,u.jsx(et,{})]})})}),u.jsxs("div",{className:"univer-mt-3 univer-flex univer-items-center univer-text-xs",children:[u.jsxs("div",{className:"univer-flex univer-items-center univer-text-xs",children:[u.jsx(j.Checkbox,{onChange:_}),r.t("sheet.cf.iconSet.reverseIconOrder")]}),u.jsxs("div",{className:"univer-ml-6 univer-flex univer-items-center univer-text-xs",children:[u.jsx(j.Checkbox,{checked:!c,onChange:g=>{v(!g)}}),r.t("sheet.cf.iconSet.onlyShowIcon")]})]}),u.jsx(Kt,{errorMap:o,onChange:S,configList:d})]})},Jt=i=>{var _;const{onChange:e,interceptorManager:n}=i,r=D.useDependency(l.LocaleService),o=((_=i.rule)==null?void 0:_.type)===t.CFRuleType.highlightCell?i.rule:void 0,s=[{label:r.t("sheet.cf.panel.isNotBottom"),value:"isNotBottom"},{label:r.t("sheet.cf.panel.isBottom"),value:"isBottom"},{label:r.t("sheet.cf.panel.greaterThanAverage"),value:"greaterThanAverage"},{label:r.t("sheet.cf.panel.lessThanAverage"),value:"lessThanAverage"}],[a,m]=C.useState(()=>{const R=s[0].value,w=o==null?void 0:o.type;if(!o)return R;switch(w){case t.CFRuleType.highlightCell:switch(o.subType){case t.CFSubRuleType.average:return[t.CFNumberOperator.greaterThan,t.CFNumberOperator.greaterThanOrEqual].includes(o.operator)?"greaterThanAverage":[t.CFNumberOperator.lessThan,t.CFNumberOperator.lessThanOrEqual].includes(o.operator)?"lessThanAverage":R;case t.CFSubRuleType.rank:return o.isBottom?"isBottom":"isNotBottom"}}return R}),[d,h]=C.useState(()=>{const w=o==null?void 0:o.type;if(!o)return 10;switch(w){case t.CFRuleType.highlightCell:if(o.subType===t.CFSubRuleType.rank)return o.value||10}return 10}),[c,v]=C.useState(()=>{const w=o==null?void 0:o.type;if(!o)return!1;switch(w){case t.CFRuleType.highlightCell:if(o.subType===t.CFSubRuleType.rank)return o.isPercent||!1}return!1}),[p,b]=C.useState({}),S=R=>{const{type:w,isPercent:E,value:N,style:g}=R;if(w==="isNotBottom")return{type:t.CFRuleType.highlightCell,subType:t.CFSubRuleType.rank,isPercent:E,isBottom:!1,value:N,style:g};if(w==="isBottom")return{type:t.CFRuleType.highlightCell,subType:t.CFSubRuleType.rank,isPercent:E,isBottom:!0,value:N,style:g};if(w==="greaterThanAverage")return{type:t.CFRuleType.highlightCell,subType:t.CFSubRuleType.average,operator:t.CFNumberOperator.greaterThan,style:g};if(w==="lessThanAverage")return{type:t.CFRuleType.highlightCell,subType:t.CFSubRuleType.average,operator:t.CFNumberOperator.lessThan,style:g}};C.useEffect(()=>n.intercept(n.getInterceptPoints().submit,{handler(){return S({type:a,isPercent:c,value:d,style:p})}}),[a,c,d,p,n]);const y=R=>{e(S(R))};return u.jsxs("div",{children:[u.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:r.t("sheet.cf.panel.styleRule")}),u.jsx(j.Select,{className:"univer-mt-3 univer-w-full",value:a,options:s,onChange:R=>{m(R),y({type:R,isPercent:c,value:d,style:p})}}),["isNotBottom","isBottom"].includes(a)&&u.jsxs("div",{className:"univer-mt-3 univer-flex univer-items-center",children:[u.jsx(j.InputNumber,{min:1,max:1e3,value:d,onChange:R=>{const w=R||0;h(w),y({type:a,isPercent:c,value:w,style:p})}}),u.jsxs("div",{className:"univer-ml-3 univer-flex univer-items-center univer-text-xs",children:[u.jsx(j.Checkbox,{checked:c,onChange:R=>{v(!!R),y({type:a,isPercent:!!R,value:d,style:p})}}),r.t("sheet.cf.valueType.percent")]})]}),u.jsx("div",{className:ye,children:u.jsx(oe,{rule:S({type:a,isPercent:c,value:d,style:p})})}),u.jsx(tt,{style:o==null?void 0:o.style,className:"univer-mt-3",onChange:R=>{b(R),y({type:a,isPercent:c,value:d,style:R})}})]})},Qt=l.createInterceptorKey("beforeSubmit"),en=l.createInterceptorKey("submit"),st=i=>i.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET).getUnitId(),at=i=>{var e;return(e=i.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:e.getSheetId()},tn=i=>{var x,I,V;const e=D.useDependency(l.LocaleService),n=D.useDependency(l.ICommandService),r=D.useDependency(l.IUniverInstanceService),o=D.useDependency(t.ConditionalFormattingRuleModel),s=D.useDependency(O.SheetsSelectionsService),a=st(r),m=at(r),[d,h]=C.useState(void 0),c=C.useRef((I=(x=i.rule)==null?void 0:x.ranges)!=null?I:[]),v=C.useMemo(()=>{var k,P,f;let M=(k=i.rule)==null?void 0:k.ranges;return M!=null&&M.length||(M=(f=(P=s.getCurrentSelections())==null?void 0:P.map(F=>F.range))!=null?f:[]),c.current=M,M!=null&&M.length?M.map(F=>{const A=We.serializeRange(F);return A==="NaN"?"":A}).filter(F=>!!F).join(","):""},[i.rule]),p=[{label:e.t("sheet.cf.ruleType.highlightCell"),value:"1"},{label:e.t("sheet.cf.panel.rankAndAverage"),value:"2"},{label:e.t("sheet.cf.ruleType.dataBar"),value:"3"},{label:e.t("sheet.cf.ruleType.colorScale"),value:"4"},{label:e.t("sheet.cf.ruleType.formula"),value:"5"},{label:e.t("sheet.cf.ruleType.iconSet"),value:"6"}],[b,S]=C.useState(()=>{var P,f;const M=(P=i.rule)==null?void 0:P.rule.type,k=p[0].value;if(!M)return k;switch(M){case t.CFRuleType.highlightCell:{switch((f=i.rule)==null?void 0:f.rule.subType){case t.CFSubRuleType.number:case t.CFSubRuleType.text:case t.CFSubRuleType.duplicateValues:case t.CFSubRuleType.uniqueValues:case t.CFSubRuleType.timePeriod:return"1";case t.CFSubRuleType.average:case t.CFSubRuleType.rank:return"2";case t.CFSubRuleType.formula:return"5"}break}case t.CFRuleType.dataBar:return"3";case t.CFRuleType.colorScale:return"4";case t.CFRuleType.iconSet:return"6"}return k}),y=C.useRef(void 0),_=C.useMemo(()=>new l.InterceptorManager({beforeSubmit:Qt,submit:en}),[]),R=C.useMemo(()=>{switch(b){case"1":return it;case"2":return Jt;case"3":return Wt;case"4":return Ht;case"5":return qt;case"6":return Xt;default:return it}},[b]);C.useEffect(()=>{const M=n.onCommandExecuted(k=>{if(k.id===O.RemoveSheetMutation.id){const P=k.params;P.subUnitId===m&&P.unitId===a&&i.onCancel()}k.id===O.SetWorksheetActiveOperation.id&&i.onCancel()});return()=>M.dispose()},[]);const w=M=>{y.current=M},E=M=>{const k=M.split(",").filter(P=>!!P).map(We.deserializeRangeWithSheet).map(P=>P.range);c.current=k},N=()=>{if(d)return;const k=(()=>{const f=r.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET).getActiveSheet();if(!f)throw new Error("No active sheet found");return c.current.map(U=>O.setEndForRange(U,f.getRowCount(),f.getColumnCount())).filter(U=>!(Number.isNaN(U.startRow)||Number.isNaN(U.startColumn)))})();if(_.fetchThroughInterceptors(_.getInterceptPoints().beforeSubmit)(!0,null)){const f=_.fetchThroughInterceptors(_.getInterceptPoints().submit)(null,null);if(f){const F=st(r),A=at(r);if(!F||!A)throw new Error("No active sheet found");let U={};i.rule&&i.rule.cfId?(U={...i.rule,ranges:k,rule:f},n.executeCommand(t.SetCfCommand.id,{unitId:F,subUnitId:A,rule:U}),i.onCancel()):(U={cfId:o.createCfId(F,A),ranges:k,rule:f,stopIfTrue:!1},n.executeCommand(t.AddCfCommand.id,{unitId:F,subUnitId:A,rule:U}),i.onCancel())}}},g=()=>{i.onCancel()},T=(M,k)=>{M?k.length<1?h(e.t("sheet.cf.errorMessage.rangeError")):h(void 0):h(e.t("sheet.cf.errorMessage.rangeError"))};return u.jsxs("div",{children:[u.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:e.t("sheet.cf.panel.range")}),u.jsxs("div",{className:"univer-mt-4",children:[u.jsx(fe.RangeSelector,{unitId:a,subUnitId:m,initialValue:v,onChange:(M,k)=>E(k),onVerify:T}),d&&u.jsx("div",{className:"univer-mt-1 univer-text-xs univer-text-red-500",children:d})]}),u.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:e.t("sheet.cf.panel.styleType")}),u.jsx(j.Select,{className:"univer-mt-4 univer-w-full",value:b,options:p,onChange:M=>S(M)}),u.jsx(R,{interceptorManager:_,rule:(V=i.rule)==null?void 0:V.rule,onChange:w}),u.jsxs("div",{className:"univer-mt-4 univer-flex univer-justify-end",children:[u.jsx(j.Button,{onClick:g,children:e.t("sheet.cf.panel.cancel")}),u.jsx(j.Button,{className:"univer-ml-3",variant:"primary",onClick:N,children:e.t("sheet.cf.panel.submit")})]})]})};var nn=Object.getOwnPropertyDescriptor,rn=(i,e,n,r)=>{for(var o=r>1?void 0:r?nn(e,n):e,s=i.length-1,a;s>=0;s--)(a=i[s])&&(o=a(o)||o);return o},on=(i,e)=>(n,r)=>e(n,r,i);let ie=class extends l.Disposable{constructor(e){super();z(this,"_initLocal",()=>{});z(this,"_findReplaceIndex",e=>{const n=/\{([^}]+)?\}/g,r=[];let o=n.exec(e);for(;o;)r.push({startIndex:o.index,key:Number(o[1]),endIndex:o.index+o[0].length-1}),o=n.exec(e);return r});this._localeService=e,this._initLocal()}tWithReactNode(e,...n){const r=this._localeService.getLocales(),o=e.split("."),s=r&&this._localeService.resolveKeyPath(r,o);if(typeof s=="string"){const a=[];return this._findReplaceIndex(s).forEach((m,d,h)=>{const c=h[d-1]||{endIndex:-1};if(c.endIndex+1<m.startIndex){const v=s.slice(c.endIndex+1,m.startIndex);v&&a.push(v)}if(n[m.key]&&a.push(n[m.key]),d===h.length-1){const v=s.slice(m.endIndex+1);v&&a.push(v)}}),a}return[]}};ie=rn([on(0,l.Inject(l.LocaleService))],ie);const sn=(i,e)=>{const n=i.rule;switch(n.type){case t.CFRuleType.colorScale:return e.t("sheet.cf.ruleType.colorScale");case t.CFRuleType.dataBar:return e.t("sheet.cf.ruleType.dataBar");case t.CFRuleType.iconSet:return e.t("sheet.cf.ruleType.iconSet");case t.CFRuleType.highlightCell:switch(n.subType){case t.CFSubRuleType.average:{const r=n.operator;return e.t(`sheet.cf.preview.describe.${r}`,e.t("sheet.cf.subRuleType.average"))}case t.CFSubRuleType.duplicateValues:return e.t("sheet.cf.subRuleType.duplicateValues");case t.CFSubRuleType.uniqueValues:return e.t("sheet.cf.subRuleType.uniqueValues");case t.CFSubRuleType.number:{const r=n.operator;return e.t(`sheet.cf.preview.describe.${r}`,...Array.isArray(n.value)?n.value.map(o=>String(o)):[String(n.value||"")])}case t.CFSubRuleType.text:{const r=n.operator;return e.t(`sheet.cf.preview.describe.${r}`,n.value||"")}case t.CFSubRuleType.timePeriod:{const r=n.operator;return e.t(`sheet.cf.preview.describe.${r}`)}case t.CFSubRuleType.rank:return n.isPercent?n.isBottom?e.t("sheet.cf.preview.describe.bottomNPercent",String(n.value)):e.t("sheet.cf.preview.describe.topNPercent",String(n.value)):n.isBottom?e.t("sheet.cf.preview.describe.bottomN",String(n.value)):e.t("sheet.cf.preview.describe.topN",String(n.value));case t.CFSubRuleType.formula:return e.t("sheet.cf.ruleType.formula")}}},an=i=>{const{onClick:e}=i,n=D.useDependency(t.ConditionalFormattingRuleModel),r=D.useDependency(l.IUniverInstanceService),o=D.useDependency(O.SheetsSelectionsService),s=D.useDependency(l.ICommandService),a=D.useDependency(l.LocaleService),m=D.useDependency(l.Injector),d=D.useDependency(ie),h=D.useObservable(()=>r.getCurrentTypeOfUnit$(l.UniverInstanceType.UNIVER_SHEET),void 0,void 0,[]),c=h.getUnitId(),v=h.getActiveSheet();if(!v)throw new Error("No active sheet found");const p=v.getSheetId(),[b,S]=C.useState([]),[y,_]=C.useState("2"),[R,w]=C.useState(0),[E,N]=C.useState(""),g=[{label:a.t("sheet.cf.panel.workSheet"),value:"2"},{label:a.t("sheet.cf.panel.selectedRange"),value:"1"}],T=()=>{const U=n.getSubunitRules(c,p);if(!U||!U.length)return[];if(y==="1"){const L=o.getCurrentLastSelection();if(!L)return[];const B=L.range;return U.filter(q=>q.ranges.some(X=>l.Rectangle.intersects(X,B)))}else if(y==="2")return[...U];return[]},[x,I]=C.useState(T);W.useHighlightRange(b),C.useEffect(()=>{const U=s.onCommandExecuted(L=>{L.id===O.SetWorksheetActiveOperation.id&&w(Math.random())});return()=>U.dispose()}),C.useEffect(()=>{I(T)},[y,R,c,p]),C.useEffect(()=>{if(y==="2")return;const U=new K.Observable(L=>{const B=[O.SetSelectionsOperation.id,t.AddConditionalRuleMutation.id,t.SetConditionalRuleMutation.id,t.DeleteConditionalRuleMutation.id,t.MoveConditionalRuleMutation.id],H=s.onCommandExecuted(q=>{const{id:X,params:J}=q,Y=r.getCurrentUnitOfType(l.UniverInstanceType.UNIVER_SHEET).getUnitId();B.includes(X)&&J.unitId===Y&&L.next(null)});return()=>H.dispose()}).pipe(K.debounceTime(16)).subscribe(()=>{I(T)});return()=>{U.unsubscribe()}},[r,y,c,p]),C.useEffect(()=>{const U=n.$ruleChange.subscribe(()=>{w(Math.random())});return()=>U.unsubscribe()},[n]);const V=U=>{var H;const L=r.getCurrentUnitOfType(l.UniverInstanceType.UNIVER_SHEET).getUnitId(),B=(H=r.getCurrentUnitOfType(l.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:H.getSheetId();if(!L||!B)throw new Error("No active sheet found");s.executeCommand(t.DeleteCfCommand.id,{unitId:L,subUnitId:B,cfId:U.cfId})},M=(U,L)=>{var H;const B=F[L.y];N((H=B==null?void 0:B.cfId)!=null?H:"")},k=(U,L,B)=>{var Pe,Ie,Se;N("");const H=r.getCurrentUnitOfType(l.UniverInstanceType.UNIVER_SHEET).getUnitId(),q=(Pe=r.getCurrentUnitOfType(l.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:Pe.getSheetId();if(!H||!q)throw new Error("No active sheet found");const X=Rt=>{const Ft=F.length;return Math.min(Ft-1,Math.max(0,Rt))},J=(Ie=F[X(L.y)])==null?void 0:Ie.cfId,Y=(Se=F[X(B.y)])==null?void 0:Se.cfId;!J||!Y||J!==Y&&s.executeCommand(t.MoveCfCommand.id,{unitId:H,subUnitId:q,start:{id:J,type:"self"},end:{id:Y,type:B.y>L.y?"after":"before"}})},P=()=>{i.onCreate()},f=()=>{y==="2"?s.executeCommand(t.ClearWorksheetCfCommand.id):y==="1"&&x.map(L=>({unitId:c,subUnitId:p,cfId:L.cfId})).forEach(L=>{s.executeCommand(t.DeleteCfCommand.id,L)})},F=C.useMemo(()=>{const U=r.getCurrentUnitOfType(l.UniverInstanceType.UNIVER_SHEET),L=U.getActiveSheet();return x.filter(B=>{const H=B.ranges;return O.checkRangesEditablePermission(m,U.getUnitId(),L.getSheetId(),H)})},[x]),A=C.useMemo(()=>{const U=r.getCurrentUnitOfType(l.UniverInstanceType.UNIVER_SHEET),L=U.getActiveSheet();return x.every(B=>{const H=B.ranges;return O.checkRangesEditablePermission(m,U.getUnitId(),L.getSheetId(),H)})},[x]);return u.jsxs("div",{children:[u.jsxs("div",{className:`
2
2
  univer-mb-2 univer-flex univer-items-center univer-justify-between univer-gap-2 univer-text-sm
3
- `,children:[u.jsx("div",{className:"univer-flex univer-items-center univer-gap-2",children:d.tWithReactNode("sheet.cf.panel.managerRuleSelect",u.jsx(j.Select,{className:"univer-w-36",options:g,value:y,onChange:U=>{_(U)}})).map((U,L)=>u.jsx("span",{children:U},L))}),u.jsxs("div",{className:"univer-flex univer-justify-end univer-space-x-2",children:[u.jsx(j.Tooltip,{title:a.t("sheet.cf.panel.createRule"),placement:"bottom",children:u.jsx("a",{className:"univer-size-5 univer-cursor-pointer",onClick:P,children:u.jsx(gt,{})})}),x.length&&A?u.jsx(j.Tooltip,{title:a.t("sheet.cf.panel.clear"),placement:"bottom",children:u.jsx("a",{className:"univer-size-5 univer-cursor-pointer",onClick:f,children:u.jsx(_e,{className:"univer-text-red-500"})})}):u.jsx("div",{children:u.jsx(_e,{className:"univer-text-gray-300"})})]})]}),u.jsx("div",{children:u.jsx(j.DraggableList,{className:"univer-w-full",draggableHandle:".draggableHandle",list:F,onListChange:()=>{},idKey:"cfId",rowHeight:60,margin:[0,10],onDragStop:k,onDragStart:M,itemRender:U=>u.jsxs("div",{className:j.clsx("univer-group univer-relative univer-flex univer-items-center univer-justify-between univer-rounded univer-py-2 univer-pl-5 univer-pr-8 hover:univer-bg-gray-100 dark:hover:!univer-bg-gray-700",{"univer-bg-gray-100 dark:!univer-bg-gray-700":E===U.cfId}),onMouseMove:()=>{U.ranges!==b&&S(U.ranges)},onMouseLeave:()=>S([]),onClick:()=>{e(U)},children:[u.jsx("div",{className:j.clsx("univer-absolute univer-left-0 univer-hidden univer-size-5 univer-cursor-grab univer-items-center univer-justify-center univer-rounded group-hover:univer-flex","draggableHandle"),onClick:L=>L.stopPropagation(),children:u.jsx(Ct,{})}),u.jsxs("div",{className:"univer-min-w-0 univer-max-w-full univer-flex-shrink univer-overflow-hidden",children:[u.jsx("div",{className:"univer-text-sm univer-text-gray-900 dark:!univer-text-white",children:sn(U,a)}),u.jsx("div",{className:"univer-text-xs univer-text-gray-400",children:U.ranges.map(L=>We.serializeRange(L)).join(",")})]}),u.jsx("div",{children:u.jsx(oe,{rule:U.rule})}),u.jsx("div",{className:j.clsx("univer-absolute univer-right-1 univer-hidden univer-size-6 univer-cursor-pointer univer-items-center univer-justify-center univer-rounded univer-text-red-500 group-hover:univer-flex hover:univer-bg-gray-200",{"univer-flex univer-items-center univer-justify-center":E===U.cfId}),onClick:L=>{L.stopPropagation(),V(U),S([])},children:u.jsx(_e,{})})]})})})]})},ln=i=>{const[e,n]=C.useState(i.rule),[r,o]=C.useState(!!i.rule),s=()=>{o(!0)},a=()=>{o(!1),n(void 0)},m=d=>{n(d),o(!0)};return u.jsx("div",{className:"univer-flex univer-h-full univer-flex-col univer-justify-between univer-py-4",children:r?u.jsx(tn,{onCancel:a,rule:e}):u.jsx(an,{onClick:m,onCreate:s})})};var un=Object.getOwnPropertyDescriptor,cn=(i,e,n,r)=>{for(var o=r>1?void 0:r?un(e,n):e,s=i.length-1,a;s>=0;s--)(a=i[s])&&(o=a(o)||o);return o},se=(i,e)=>(n,r)=>e(n,r,i);const Fe="sheet.conditional.formatting.panel";let me=class extends l.Disposable{constructor(e,n,r,o,s){super();z(this,"_sidebarDisposable",null);this._univerInstanceService=e,this._injector=n,this._componentManager=r,this._sidebarService=o,this._localeService=s,this._initPanel(),this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(l.UniverInstanceType.UNIVER_SHEET).subscribe(a=>{var m;a||(m=this._sidebarDisposable)==null||m.dispose()})),this.disposeWithMe(this._sidebarService.sidebarOptions$.subscribe(a=>{a.id===Fe&&(a.visible||setTimeout(()=>{this._sidebarService.sidebarOptions$.next({visible:!1})}))}))}openPanel(e){const n={id:Fe,header:{title:this._localeService.t("sheet.cf.title")},children:{label:Fe,rule:e,key:l.generateRandomId(4)},onClose:()=>this._sidebarDisposable=null};this._sidebarDisposable=this._sidebarService.open(n)}_initPanel(){this.disposeWithMe(this._componentManager.register(Fe,ln))}};me=cn([se(0,l.IUniverInstanceService),se(1,l.Inject(l.Injector)),se(2,l.Inject(D.ComponentManager)),se(3,l.Inject(D.ISidebarService)),se(4,l.Inject(l.LocaleService))],me);var G=(i=>(i[i.createRule=1]="createRule",i[i.viewRule=2]="viewRule",i[i.highlightCell=3]="highlightCell",i[i.rank=4]="rank",i[i.formula=5]="formula",i[i.colorScale=6]="colorScale",i[i.dataBar=7]="dataBar",i[i.icon=8]="icon",i[i.clearRangeRules=9]="clearRangeRules",i[i.clearWorkSheetRules=10]="clearWorkSheetRules",i))(G||{});const be={id:"sheet.operation.open.conditional.formatting.panel",type:l.CommandType.OPERATION,handler:(i,e)=>{var m;const n=i.get(me),r=i.get(O.SheetsSelectionsService),o=i.get(l.ICommandService),s=((m=r.getCurrentSelections())==null?void 0:m.map(d=>d.range))||[];switch(e.value){case 3:{n.openPanel({...t.createDefaultRule(),ranges:s});break}case 4:{const d={...t.createDefaultRule,ranges:s,rule:{type:t.CFRuleType.highlightCell,subType:t.CFSubRuleType.rank}};n.openPanel(d);break}case 5:{const d={...t.createDefaultRule,ranges:s,rule:{type:t.CFRuleType.highlightCell,subType:t.CFSubRuleType.formula,value:"="}};n.openPanel(d);break}case 6:{const d={...t.createDefaultRule,ranges:s,rule:{type:t.CFRuleType.colorScale,config:[]}};n.openPanel(d);break}case 7:{const d={...t.createDefaultRule,ranges:s,rule:{type:t.CFRuleType.dataBar,isShowValue:!0}};n.openPanel(d);break}case 8:{const d={...t.createDefaultRule,ranges:s,rule:{type:t.CFRuleType.iconSet,config:[],isShowValue:!0}};n.openPanel(d);break}case 2:{n.openPanel();break}case 1:{n.openPanel({...t.createDefaultRule(),ranges:s});break}case 9:{o.executeCommand(t.ClearRangeCfCommand.id,{ranges:s});break}case 10:{o.executeCommand(t.ClearWorksheetCfCommand.id);break}}return!0}};var dn=Object.getOwnPropertyDescriptor,mn=(i,e,n,r)=>{for(var o=r>1?void 0:r?dn(e,n):e,s=i.length-1,a;s>=0;s--)(a=i[s])&&(o=a(o)||o);return o},ae=(i,e)=>(n,r)=>e(n,r,i);exports.ConditionalFormattingClearController=class extends l.Disposable{constructor(e,n,r,o,s){super(),this._injector=e,this._univerInstanceService=n,this._sheetInterceptorService=r,this._selectionManagerService=o,this._conditionalFormattingRuleModel=s,this._init()}_init(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:e=>{var s;const n=[],r=[],o={redos:n,undos:r};if([O.ClearSelectionFormatCommand.id,O.ClearSelectionAllCommand.id].includes(e.id)){const a=(s=this._selectionManagerService.getCurrentSelections())==null?void 0:s.map(S=>S.range);if(!a)return o;const m=this._univerInstanceService.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET),d=m.getActiveSheet();if(!d)return o;const h=m.getUnitId(),c=d.getSheetId(),v=this._conditionalFormattingRuleModel.getSubunitRules(h,c);if(!v||!v.length)return o;const{redos:p,undos:b}=lt(this._injector,v,a,h,c);n.push(...p),r.push(...b)}return o}})),this.disposeWithMe(this._sheetInterceptorService.interceptRanges({getMutations:({unitId:e,subUnitId:n,ranges:r})=>{const o=[],s=[],a={redos:o,undos:s};if(!r||!r.length)return a;const m=this._conditionalFormattingRuleModel.getSubunitRules(e,n);if(!m||!m.length)return a;const{redos:d,undos:h}=lt(this._injector,m,r,e,n);return o.push(...d),s.push(...h),a}}))}};exports.ConditionalFormattingClearController=mn([ae(0,l.Inject(l.Injector)),ae(1,l.Inject(l.IUniverInstanceService)),ae(2,l.Inject(O.SheetInterceptorService)),ae(3,l.Inject(O.SheetsSelectionsService)),ae(4,l.Inject(t.ConditionalFormattingRuleModel))],exports.ConditionalFormattingClearController);function lt(i,e,n,r,o){const s=[],a=[];return e.filter(m=>n.some(d=>m.ranges.some(h=>l.Rectangle.getIntersects(h,d)))).forEach(m=>{const h=new O.RangeMergeUtil().add(...m.ranges).subtract(...n).merge();if(h.length){const c={id:t.SetConditionalRuleMutation.id,params:{unitId:r,subUnitId:o,rule:{...m,ranges:h}}},v=t.setConditionalRuleMutationUndoFactory(i,c.params);s.push(c),a.push(...v)}else{const c={id:t.DeleteConditionalRuleMutation.id,params:{unitId:r,subUnitId:o,cfId:m.cfId}},v=t.DeleteConditionalRuleMutationUndoFactory(i,c.params);s.push(c),a.push(...v)}}),{redos:s,undos:a}}const vn="@univerjs/sheets-conditional-formatting-ui",hn="0.16.1-insiders.20260311-074e8ca",Oe={name:vn,version:hn},xt="sheets-conditional-formatting-ui.config",we={};var pn=Object.getOwnPropertyDescriptor,gn=(i,e,n,r)=>{for(var o=r>1?void 0:r?pn(e,n):e,s=i.length-1,a;s>=0;s--)(a=i[s])&&(o=a(o)||o);return o},Le=(i,e)=>(n,r)=>e(n,r,i);let ve=class extends l.Disposable{constructor(e,n,r){super();z(this,"_disposableMap",new Map);this._conditionalFormattingRuleModel=e,this._formulaRefRangeService=n,this._injector=r,this._initRefRange()}_getIdWithUnitId(e,n,r){return`${e}_${n}_${r}`}_getRuleFormulas(e){const n=[],r=e.rule;switch(r.type){case t.CFRuleType.highlightCell:r.subType===t.CFSubRuleType.formula&&n.push(r.value);break;case t.CFRuleType.dataBar:{const o=r;o.config.min.type===t.CFValueType.formula&&n.push(o.config.min.value),o.config.max.type===t.CFValueType.formula&&n.push(o.config.max.value);break}case t.CFRuleType.colorScale:{r.config.forEach(s=>{s.value.type===t.CFValueType.formula&&n.push(s.value.value)});break}case t.CFRuleType.iconSet:{r.config.forEach(s=>{s.value.type===t.CFValueType.formula&&n.push(s.value.value)});break}}return n}_updateRuleFormulas(e,n){const r=l.Tools.deepClone(e),o=r.rule;let s=0;switch(o.type){case t.CFRuleType.highlightCell:o.subType===t.CFSubRuleType.formula&&(o.value=n[s++]);break;case t.CFRuleType.dataBar:{const a=o;a.config.min.type===t.CFValueType.formula&&(a.config.min.value=n[s++]),a.config.max.type===t.CFValueType.formula&&(a.config.max.value=n[s++]);break}case t.CFRuleType.colorScale:{o.config.forEach(m=>{m.value.type===t.CFValueType.formula&&(m.value.value=n[s++])});break}case t.CFRuleType.iconSet:{o.config.forEach(m=>{m.value.type===t.CFValueType.formula&&(m.value.value=n[s++])});break}}return r}register(e,n,r){const o=r.ranges,s=this._getRuleFormulas(r),a=this._formulaRefRangeService.registerRangeFormula(e,n,o,s,d=>{if(d.length===0)return{undos:[{id:t.AddConditionalRuleMutation.id,params:{unitId:e,subUnitId:n,rule:r}}],redos:[{id:t.DeleteConditionalRuleMutation.id,params:{unitId:e,subUnitId:n,cfId:r.cfId}}]};const h=[],c=[],v=d[0],p=this._updateRuleFormulas(r,v.formulas);p.ranges=v.ranges,h.push({id:t.SetConditionalRuleMutation.id,params:{unitId:e,subUnitId:n,cfId:r.cfId,rule:p}}),c.push(...t.setConditionalRuleMutationUndoFactory(this._injector,{unitId:e,subUnitId:n,cfId:r.cfId,rule:p}));for(let b=1;b<d.length;b++){const S=d[b],y=t.createCfId(),_=this._updateRuleFormulas(r,S.formulas);_.cfId=y,_.ranges=S.ranges,h.push({id:t.AddConditionalRuleMutation.id,params:{unitId:e,subUnitId:n,rule:_}}),c.push(t.AddConditionalRuleMutationUndoFactory(this._injector,{unitId:e,subUnitId:n,rule:_}))}return{undos:c,redos:h}}),m=this._getIdWithUnitId(e,n,r.cfId);this._disposableMap.set(m,a)}_initRefRange(){const e=this._conditionalFormattingRuleModel.getAll();for(const[n,r]of e)for(const[o,s]of r)for(const a of s)this.register(n,o,a);this.disposeWithMe(this._conditionalFormattingRuleModel.$ruleChange.subscribe(n=>{const{unitId:r,subUnitId:o,rule:s}=n;switch(n.type){case"add":{this.register(r,o,s);break}case"delete":{const a=this._getIdWithUnitId(r,o,s.cfId),m=this._disposableMap.get(a);m&&(m.dispose(),this._disposableMap.delete(a));break}case"set":{const a=this._getIdWithUnitId(r,o,s.cfId),m=this._disposableMap.get(a);m&&(m.dispose(),this._disposableMap.delete(a)),this.register(r,o,s);break}}})),this.disposeWithMe(l.toDisposable(()=>{this._disposableMap.forEach(n=>{n.dispose()}),this._disposableMap.clear()}))}};ve=gn([Le(0,l.Inject(t.ConditionalFormattingRuleModel)),Le(1,l.Inject(mt.FormulaRefRangeService)),Le(2,l.Inject(l.Injector))],ve);var fn=Object.getOwnPropertyDescriptor,Cn=(i,e,n,r)=>{for(var o=r>1?void 0:r?fn(e,n):e,s=i.length-1,a;s>=0;s--)(a=i[s])&&(o=a(o)||o);return o},le=(i,e)=>(n,r)=>e(n,r,i);let he=class extends l.Disposable{constructor(e,n,r,o,s){super();z(this,"_copyInfo");this._sheetClipboardService=e,this._conditionalFormattingRuleModel=n,this._injector=r,this._conditionalFormattingViewModel=o,this._univerInstanceService=s,this._initClipboardHook()}_initClipboardHook(){this.disposeWithMe(this._sheetClipboardService.addClipboardHook({id:t.SHEET_CONDITIONAL_FORMATTING_PLUGIN,onBeforeCopy:(e,n,r)=>this._collectConditionalRule(e,n,r),onPasteCells:(e,n,r,o)=>{const{copyType:s=W.COPY_TYPE.COPY,pasteType:a}=o,{range:m}=e||{},{range:d}=n;return this._generateConditionalFormattingMutations(d,{copyType:s,pasteType:a,copyRange:m})}}))}_collectConditionalRule(e,n,r){const o=new l.ObjectMatrix,s={};this._copyInfo={matrix:o,info:{unitId:e,subUnitId:n,cfMap:s}};const a=this._injector.invoke(c=>O.rangeToDiscreteRange(r,c,e,n));if(!a)return;const{rows:m,cols:d}=a,h=new Set;m.forEach((c,v)=>{d.forEach((p,b)=>{const S=this._conditionalFormattingViewModel.getCellCfs(e,n,c,p);S&&(S.forEach(y=>h.add(y.cfId)),o.setValue(v,b,S.map(y=>y.cfId)))})}),h.forEach(c=>{const v=this._conditionalFormattingRuleModel.getRule(e,n,c);v&&(s[c]=v.rule)})}_generateConditionalFormattingMutations(e,n){const r=this._univerInstanceService.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET),o=r.getActiveSheet(),s=r.getUnitId();if(!o)return{redos:[],undos:[]};const a=o.getSheetId();if(n.copyType===W.COPY_TYPE.CUT)return this._copyInfo=null,{redos:[],undos:[]};if(!this._copyInfo||!n.copyRange)return{redos:[],undos:[]};if(![W.PREDEFINED_HOOK_NAME_PASTE.SPECIAL_PASTE_FORMAT,W.PREDEFINED_HOOK_NAME_PASTE.DEFAULT_PASTE,W.PREDEFINED_HOOK_NAME_PASTE.SPECIAL_PASTE_BESIDES_BORDER].includes(n.pasteType))return{redos:[],undos:[]};const{ranges:[d,h],mapFunc:c}=W.virtualizeDiscreteRanges([n.copyRange,e]),v=W.getRepeatRange(d,h,!0),p={};l.Range.foreach(h,(g,T)=>{const{row:x,col:I}=c(g,T),V=this._conditionalFormattingViewModel.getCellCfs(s,a,x,I);V&&V.forEach(M=>{if(!p[M.cfId]){const k=new l.ObjectMatrix;p[M.cfId]=k;const P=this._conditionalFormattingRuleModel.getRule(s,a,M.cfId);P==null||P.ranges.forEach(f=>{l.Range.foreach(f,(F,A)=>{k.setValue(F,A,1)})})}p[M.cfId].realDeleteValue(x,I)})});const{matrix:b,info:S}=this._copyInfo,y=[];let _=this._conditionalFormattingRuleModel.createCfId(s,a);const R={},w=g=>{if(R[g])return R[g];const T=S==null?void 0:S.cfMap[g],x=[...this._conditionalFormattingRuleModel.getSubunitRules(s,a)||[],...y].find(I=>l.Tools.diffValue(I.rule,T));if(x)return R[g]=x,x;{const I={rule:T,cfId:_,ranges:[],stopIfTrue:!1};return R[g]=I,y.push(I),_=`${Number(_)+1}`,I}};v.forEach(g=>{b&&b.forValue((T,x,I)=>{const V=l.Rectangle.getPositionRange({startRow:T,endRow:T,startColumn:x,endColumn:x},g.startRange),{row:M,col:k}=c(V.startRow,V.startColumn);I.forEach(P=>{if(!p[P]){const f=w(P),F=new l.ObjectMatrix;p[P]=F,f.ranges.forEach(A=>{l.Range.foreach(A,(U,L)=>{F.setValue(U,L,1)})})}p[P].setValue(M,k,1)})})});const E=[],N=[];for(const g in p){const T=p[g],x=O.findAllRectangle(O.createTopMatrixFromMatrix(T));if(!x.length){const I={unitId:s,subUnitId:a,cfId:g};E.push({id:t.DeleteConditionalRuleMutation.id,params:I}),N.push(...t.DeleteConditionalRuleMutationUndoFactory(this._injector,I))}if(y.some(I=>I.cfId===g)){const I=w(g),V={unitId:s,subUnitId:a,rule:{...I,ranges:x}};E.push({id:t.AddConditionalRuleMutation.id,params:V}),N.push(t.AddConditionalRuleMutationUndoFactory(this._injector,V))}else{const I=this._conditionalFormattingRuleModel.getRule(s,a,g);if(!I)continue;const V={unitId:s,subUnitId:a,rule:{...I,ranges:x}};E.push({id:t.SetConditionalRuleMutation.id,params:V}),N.push(...t.setConditionalRuleMutationUndoFactory(this._injector,V))}}return{redos:E,undos:N}}};he=Cn([le(0,l.Inject(W.ISheetClipboardService)),le(1,l.Inject(t.ConditionalFormattingRuleModel)),le(2,l.Inject(l.Injector)),le(3,l.Inject(t.ConditionalFormattingViewModel)),le(4,l.Inject(l.IUniverInstanceService))],he);var yn=Object.getOwnPropertyDescriptor,bn=(i,e,n,r)=>{for(var o=r>1?void 0:r?yn(e,n):e,s=i.length-1,a;s>=0;s--)(a=i[s])&&(o=a(o)||o);return o},Ae=(i,e)=>(n,r)=>e(n,r,i);let pe=class extends l.Disposable{constructor(i,e,n){super(),this._localeService=i,this._commandService=e,this._sheetPermissionCheckController=n,this._commandExecutedListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.beforeCommandExecuted(i=>{if(i.id===t.AddCfCommand.id){const{unitId:e,subUnitId:n,rule:{ranges:r}}=i.params;this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[O.WorkbookEditablePermission],rangeTypes:[O.RangeProtectionPermissionEditPoint],worksheetTypes:[O.WorksheetEditPermission,O.WorksheetSetCellStylePermission]},r,e,n)||this._sheetPermissionCheckController.blockExecuteWithoutPermission(this._localeService.t("permission.dialog.setStyleErr"))}}))}};pe=bn([Ae(0,l.Inject(l.LocaleService)),Ae(1,l.ICommandService),Ae(2,l.Inject(O.SheetPermissionCheckController))],pe);var In=Object.getOwnPropertyDescriptor,Sn=(i,e,n,r)=>{for(var o=r>1?void 0:r?In(e,n):e,s=i.length-1,a;s>=0;s--)(a=i[s])&&(o=a(o)||o);return o},ne=(i,e)=>(n,r)=>e(n,r,i);let ge=class extends l.Disposable{constructor(e,n,r,o,s,a){super();z(this,"_ruleChangeCacheMap",new Map);this._sheetInterceptorService=e,this._conditionalFormattingService=n,this._univerInstanceService=r,this._renderManagerService=o,this._conditionalFormattingViewModel=s,this._conditionalFormattingRuleModel=a,this._initViewModelInterceptor(),this._initSkeleton(),this.disposeWithMe(()=>{this._ruleChangeCacheMap.clear()})}_markDirtySkeleton(){var n,r,o;const e=this._univerInstanceService.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET).getUnitId();(n=this._renderManagerService.getRenderById(e))==null||n.with(W.SheetSkeletonManagerService).reCalculate(),(o=(r=this._renderManagerService.getRenderById(e))==null?void 0:r.mainComponent)==null||o.makeDirty()}_initSkeleton(){this.disposeWithMe(K.merge(this._conditionalFormattingRuleModel.$ruleChange,this._conditionalFormattingViewModel.markDirty$).pipe(de.bufferTime(16),de.filter(e=>!!e.length),de.filter(e=>{const n=this._univerInstanceService.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET);if(!n)return!1;const r=n.getActiveSheet();return r?e.filter(o=>o.unitId===n.getUnitId()&&o.subUnitId===r.getSheetId()).length>0:!1})).subscribe(()=>this._markDirtySkeleton()))}_initViewModelInterceptor(){this.disposeWithMe(this._sheetInterceptorService.intercept(O.INTERCEPTOR_POINT.CELL_CONTENT,{effect:l.InterceptorEffectEnum.Style,handler:(e,n,r)=>{const o=this._conditionalFormattingService.composeStyle(n.unitId,n.subUnitId,n.row,n.col);if(!o)return r(e);const s=n.workbook.getStyles(),a=(typeof(e==null?void 0:e.s)=="string"?s.get(e==null?void 0:e.s):e==null?void 0:e.s)||{},m=e===n.rawData?{...n.rawData}:e;if(o.style){const d={...a,...o.style};Object.assign(m,{s:d})}return m.fontRenderExtension||(m.fontRenderExtension={},o.isShowValue!==void 0&&(m.fontRenderExtension.isSkip=!o.isShowValue)),o.dataBar&&(m.dataBar=o.dataBar),o.iconSet&&(m.iconSet=o.iconSet,m.fontRenderExtension.leftOffset=t.DEFAULT_PADDING+t.DEFAULT_WIDTH),r(m)},priority:10}))}};ge=Sn([ne(0,l.Inject(O.SheetInterceptorService)),ne(1,l.Inject(t.ConditionalFormattingService)),ne(2,l.Inject(l.IUniverInstanceService)),ne(3,l.Inject(vt.IRenderManagerService)),ne(4,l.Inject(t.ConditionalFormattingViewModel)),ne(5,l.Inject(t.ConditionalFormattingRuleModel))],ge);var Tn=Object.defineProperty,xn=Object.getOwnPropertyDescriptor,Rn=(i,e,n)=>e in i?Tn(i,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):i[e]=n,Fn=(i,e,n,r)=>{for(var o=r>1?void 0:r?xn(e,n):e,s=i.length-1,a;s>=0;s--)(a=i[s])&&(o=a(o)||o);return o},$e=(i,e)=>(n,r)=>e(n,r,i),Ue=(i,e,n)=>Rn(i,typeof e!="symbol"?e+"":e,n);exports.UniverSheetsConditionalFormattingMobileUIPlugin=class extends l.Plugin{constructor(e=we,n,r,o){super(),this._config=e,this._injector=n,this._commandService=r,this._configService=o;const{menu:s,...a}=l.merge({},we,this._config);s&&this._configService.setConfig("menu",s,{merge:!0}),this._configService.setConfig(xt,a),this._initCommand(),this._injector.add([ge]),this._injector.add([he]),this._injector.add([pe]),this._injector.add([ie]),this._injector.add([ve])}_initCommand(){[qe,Ge,Ze,Ye,ze,Ke,Xe,Je,Qe,be].forEach(e=>{this._commandService.registerCommand(e)})}};Ue(exports.UniverSheetsConditionalFormattingMobileUIPlugin,"pluginName",`${t.SHEET_CONDITIONAL_FORMATTING_PLUGIN}_MOBILE_UI_PLUGIN`);Ue(exports.UniverSheetsConditionalFormattingMobileUIPlugin,"packageName",Oe.name);Ue(exports.UniverSheetsConditionalFormattingMobileUIPlugin,"version",Oe.version);Ue(exports.UniverSheetsConditionalFormattingMobileUIPlugin,"type",l.UniverInstanceType.UNIVER_SHEET);exports.UniverSheetsConditionalFormattingMobileUIPlugin=Fn([l.DependentOn(t.UniverSheetsConditionalFormattingPlugin),$e(1,l.Inject(l.Injector)),$e(2,l.Inject(l.ICommandService)),$e(3,l.IConfigService)],exports.UniverSheetsConditionalFormattingMobileUIPlugin);var _n=Object.getOwnPropertyDescriptor,wn=(i,e,n,r)=>{for(var o=r>1?void 0:r?_n(e,n):e,s=i.length-1,a;s>=0;s--)(a=i[s])&&(o=a(o)||o);return o},ue=(i,e)=>(n,r)=>e(n,r,i);let Ne=class extends l.Disposable{constructor(i,e,n,r,o){super(),this._injector=i,this._univerInstanceService=e,this._autoFillService=n,this._conditionalFormattingRuleModel=r,this._conditionalFormattingViewModel=o,this._initAutoFill()}_initAutoFill(){const i=()=>({redos:[],undos:[]}),e=(o,s,a,m,d)=>{var b;const h=this._univerInstanceService.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET).getUnitId(),c=(b=this._univerInstanceService.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:b.getSheetId();if(!h||!c)return;const v={startRow:o.row,startColumn:o.col,endColumn:o.col,endRow:o.row},p={startRow:s.row,startColumn:s.col,endColumn:s.col,endRow:s.row};l.Range.foreach(a,(S,y)=>{const _=l.Rectangle.getPositionRange({startRow:S,startColumn:y,endColumn:y,endRow:S},v),R=l.Rectangle.getPositionRange({startRow:S,startColumn:y,endColumn:y,endRow:S},p),{row:w,col:E}=d(_.startRow,_.startColumn),N=this._conditionalFormattingViewModel.getCellCfs(h,c,w,E),{row:g,col:T}=d(R.startRow,R.startColumn),x=this._conditionalFormattingViewModel.getCellCfs(h,c,g,T);x&&x.forEach(I=>{let V=m.get(I.cfId);if(!m.get(I.cfId)){const M=this._conditionalFormattingRuleModel.getRule(h,c,I.cfId);if(!M)return;V=new l.ObjectMatrix,M.ranges.forEach(k=>{l.Range.foreach(k,(P,f)=>{V.setValue(P,f,1)})}),m.set(I.cfId,V)}V.realDeleteValue(g,T)}),N&&N.forEach(I=>{let V=m.get(I.cfId);if(!m.get(I.cfId)){const M=this._conditionalFormattingRuleModel.getRule(h,c,I.cfId);if(!M)return;V=new l.ObjectMatrix,M.ranges.forEach(k=>{l.Range.foreach(k,(P,f)=>{V.setValue(P,f,1)})}),m.set(I.cfId,V)}V.setValue(g,T,1)})})},n=(o,s)=>{var R,w,E;const a=(R=this._univerInstanceService.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET))==null?void 0:R.getUnitId(),m=(E=(w=this._univerInstanceService.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET))==null?void 0:w.getActiveSheet())==null?void 0:E.getSheetId(),d=new Map,h=[],c=[];if(!a||!m)return i();const v=W.virtualizeDiscreteRanges([o,s]),[p,b]=v.ranges,{mapFunc:S}=v,y={row:p.startRow,col:p.startColumn};return O.AutoFillTools.getAutoFillRepeatRange(p,b).forEach(N=>{e(y,N.repeatStartCell,N.relativeRange,d,S)}),d.forEach((N,g)=>{const T=this._conditionalFormattingRuleModel.getRule(a,m,g);if(!T)return;const x=O.findAllRectangle(O.createTopMatrixFromMatrix(N));if(x.length){const I={unitId:a,subUnitId:m,rule:{...T,ranges:x}};h.push({id:t.SetConditionalRuleMutation.id,params:I}),c.push(...t.setConditionalRuleMutationUndoFactory(this._injector,I))}else{const I={unitId:a,subUnitId:m,cfId:T.cfId};h.push({id:t.DeleteConditionalRuleMutation.id,params:I}),c.push(...t.DeleteConditionalRuleMutationUndoFactory(this._injector,I))}}),{undos:c,redos:h}},r={id:t.SHEET_CONDITIONAL_FORMATTING_PLUGIN,onFillData:(o,s,a)=>{if(a===O.AUTO_FILL_APPLY_TYPE.COPY||a===O.AUTO_FILL_APPLY_TYPE.ONLY_FORMAT||a===O.AUTO_FILL_APPLY_TYPE.SERIES){const{source:m,target:d}=o;return n(m,d)}return i()}};this.disposeWithMe(this._autoFillService.addHook(r))}};Ne=wn([ue(0,l.Inject(l.Injector)),ue(1,l.Inject(l.IUniverInstanceService)),ue(2,l.Inject(O.IAutoFillService)),ue(3,l.Inject(t.ConditionalFormattingRuleModel)),ue(4,l.Inject(t.ConditionalFormattingViewModel))],Ne);var Nn=Object.getOwnPropertyDescriptor,En=(i,e,n,r)=>{for(var o=r>1?void 0:r?Nn(e,n):e,s=i.length-1,a;s>=0;s--)(a=i[s])&&(o=a(o)||o);return o},ut=(i,e)=>(n,r)=>e(n,r,i);let Ee=class extends l.Disposable{constructor(i,e){super(),this._sheetInterceptorService=i,this._conditionalFormattingService=e,this._initInterceptorEditorEnd()}_initInterceptorEditorEnd(){this.disposeWithMe(l.toDisposable(this._sheetInterceptorService.writeCellInterceptor.intercept(O.AFTER_CELL_EDIT,{handler:(i,e,n)=>{var a,m,d;i||n(i);const r=this._conditionalFormattingService.composeStyle(e.unitId,e.subUnitId,e.row,e.col),o=(a=r==null?void 0:r.style)!=null?a:{},s=Object.keys(o);if(i!=null&&i.p)return(d=(m=i.p.body)==null?void 0:m.textRuns)==null||d.forEach(h=>{h.ts&&s.forEach(c=>{var v;(v=h.ts)==null||delete v[c]})}),n(i);{const h={...(typeof(i==null?void 0:i.s)=="string"?e.workbook.getStyles().get(i.s):i==null?void 0:i.s)||{}};s.forEach(v=>{delete h[v]});const c={...i,s:{...h}};return n(c)}}})))}};Ee=En([ut(0,l.Inject(O.SheetInterceptorService)),ut(1,l.Inject(t.ConditionalFormattingService))],Ee);var jn=Object.getOwnPropertyDescriptor,Mn=(i,e,n,r)=>{for(var o=r>1?void 0:r?jn(e,n):e,s=i.length-1,a;s>=0;s--)(a=i[s])&&(o=a(o)||o);return o},re=(i,e)=>(n,r)=>e(n,r,i);const Vn=(i,e)=>{const n=c=>c.endRow-c.startRow+1,r=c=>c.endColumn-c.startColumn+1,o=n(e)%n(i),s=r(e)%r(i),a=Math.floor(n(e)/n(i)),m=Math.floor(r(e)/r(i)),d=[],h={startRow:0,endRow:n(i)-1,startColumn:0,endColumn:r(i)-1};if(n(e)===1&&r(e)===1){const c={startRow:e.startRow,endRow:e.startRow,startColumn:e.startColumn,endColumn:e.startColumn};return d.push({repeatRelativeRange:h,startRange:c}),d}for(let c=0;c<a+(o?.1:0);c++)for(let v=0;v<m+(s?.1:0);v++){const p=n(i)*c,b=r(i)*v,S={startRow:p+e.startRow,endRow:p+e.startRow,startColumn:b+e.startColumn,endColumn:b+e.startColumn};let y=h;c===a&&o&&(y={...y},y.endRow=y.endRow-(n(i)-o)),v===m&&s&&(y={...y},y.endColumn=y.endColumn-(r(i)-s)),d.push({repeatRelativeRange:y,startRange:S})}return d};let je=class extends l.Disposable{constructor(e,n,r,o,s,a){super();z(this,"_painterConfig",null);this._injector=e,this._univerInstanceService=n,this._formatPainterService=r,this._sheetsSelectionsService=o,this._conditionalFormattingRuleModel=s,this._conditionalFormattingViewModel=a,this._initFormattingPainter()}_initFormattingPainter(){const e=()=>({redos:[],undos:[]}),n=(s,a,m,d,h)=>{const{unitId:c,subUnitId:v}=this._painterConfig,{targetUnitId:p,targetSubUnitId:b}=h,S={startRow:s.row,startColumn:s.col,endColumn:s.col,endRow:s.row},y={startRow:a.row,startColumn:a.col,endColumn:a.col,endRow:a.row};l.Range.foreach(m,(_,R)=>{const w=l.Rectangle.getPositionRange({startRow:_,startColumn:R,endColumn:R,endRow:_},S),E=l.Rectangle.getPositionRange({startRow:_,startColumn:R,endColumn:R,endRow:_},y),N=this._conditionalFormattingViewModel.getCellCfs(c,v,w.startRow,w.startColumn),g=this._conditionalFormattingViewModel.getCellCfs(p,b,E.startRow,E.startColumn);g&&g.forEach(T=>{let x=d.get(T.cfId);if(!d.get(T.cfId)){const I=this._conditionalFormattingRuleModel.getRule(p,b,T.cfId);if(!I)return;x=new l.ObjectMatrix,I.ranges.forEach(V=>{l.Range.foreach(V,(M,k)=>{x.setValue(M,k,1)})}),d.set(T.cfId,x)}x.realDeleteValue(E.startRow,E.startColumn)}),N&&N.forEach(T=>{const x=d.get(T.cfId);x&&x.setValue(E.startRow,E.startColumn,1)})})},r=(s,a,m)=>{var w;const{range:d,unitId:h,subUnitId:c}=this._painterConfig,v=s!==h||c!==a,p=new Map,b=[],S=[];if(!s||!a||!h||!c)return e();const y=(w=this._conditionalFormattingRuleModel.getSubunitRules(h,c))!=null?w:[];y==null||y.forEach(E=>{const{ranges:N,cfId:g}=E;if(N.some(T=>l.Rectangle.intersects(d,T))){const T=new l.ObjectMatrix;v||N.forEach(x=>{l.Range.foreach(x,(I,V)=>{T.setValue(I,V,1)})}),p.set(g,T)}});const _={row:d.startRow,col:d.startColumn};return Vn(d,m).forEach(E=>{n(_,{row:E.startRange.startRow,col:E.startRange.startColumn},E.repeatRelativeRange,p,{targetUnitId:s,targetSubUnitId:a})}),p.forEach((E,N)=>{if(v){const g=this._conditionalFormattingRuleModel.getRule(s,a,N),T=O.findAllRectangle(O.createTopMatrixFromMatrix(E));if(g)if(T.length){const x={unitId:s,subUnitId:a,rule:{...g,ranges:T}};b.push({id:t.SetConditionalRuleMutation.id,params:x}),S.push(...t.setConditionalRuleMutationUndoFactory(this._injector,x))}else{const x={unitId:s,subUnitId:a,cfId:g.cfId};b.push({id:t.DeleteConditionalRuleMutation.id,params:x}),S.push(...t.DeleteConditionalRuleMutationUndoFactory(this._injector,x))}else if(T.length){const x=this._conditionalFormattingRuleModel.getRule(h,c,N);if(x){const I={unitId:s,subUnitId:a,rule:{...l.Tools.deepClone(x),cfId:this._conditionalFormattingRuleModel.createCfId(s,a),ranges:T}};b.push({id:t.AddConditionalRuleMutation.id,params:I}),S.push(t.AddConditionalRuleMutationUndoFactory(this._injector,I))}}}else{const g=this._conditionalFormattingRuleModel.getRule(h,c,N);if(!g)return;const T=O.findAllRectangle(O.createTopMatrixFromMatrix(E));if(T.length){const x={unitId:h,subUnitId:c,rule:{...g,ranges:T}};b.push({id:t.SetConditionalRuleMutation.id,params:x}),S.push(...t.setConditionalRuleMutationUndoFactory(this._injector,x))}else{const x={unitId:h,subUnitId:c,cfId:g.cfId};b.push({id:t.DeleteConditionalRuleMutation.id,params:x}),S.push(...t.DeleteConditionalRuleMutationUndoFactory(this._injector,x))}}}),{undos:S,redos:b}},o={id:t.SHEET_CONDITIONAL_FORMATTING_PLUGIN,onStatusChange:s=>{var a,m,d;switch(s){case W.FormatPainterStatus.INFINITE:case W.FormatPainterStatus.ONCE:{const h=(a=this._univerInstanceService.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET))==null?void 0:a.getUnitId(),c=(d=(m=this._univerInstanceService.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET))==null?void 0:m.getActiveSheet())==null?void 0:d.getSheetId(),v=this._sheetsSelectionsService.getCurrentLastSelection(),p=v==null?void 0:v.range;h&&c&&p&&(this._painterConfig={unitId:h,subUnitId:c,range:p});break}case W.FormatPainterStatus.OFF:{this._painterConfig=null;break}}},onApply:(s,a,m)=>this._painterConfig?r(s,a,m):{redos:[],undos:[]}};this._formatPainterService.addHook(o)}};je=Mn([re(0,l.Inject(l.Injector)),re(1,l.Inject(l.IUniverInstanceService)),re(2,l.Inject(W.IFormatPainterService)),re(3,l.Inject(O.SheetsSelectionsService)),re(4,l.Inject(t.ConditionalFormattingRuleModel)),re(5,l.Inject(t.ConditionalFormattingViewModel))],je);var On=Object.getOwnPropertyDescriptor,Un=(i,e,n,r)=>{for(var o=r>1?void 0:r?On(e,n):e,s=i.length-1,a;s>=0;s--)(a=i[s])&&(o=a(o)||o);return o},Be=(i,e)=>(n,r)=>e(n,r,i);let Me=class extends l.Disposable{constructor(i,e,n){super(),this._conditionalFormattingViewModel=i,this._univerInstanceService=e,this._renderManagerService=n,this._init()}_init(){const i=this._univerInstanceService.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET),e=n=>{const r=n.getUnitId(),o=this._renderManagerService.getRenderById(r);if(!o)return;const s=o.with(W.SheetSkeletonManagerService);this.disposeWithMe(s.currentSkeleton$.subscribe(a=>{if(a){const m=a.skeleton.rowColumnSegment,d=m.endColumn-m.startColumn+1,c=(m.endRow-m.startRow+1)*d*9,v=Math.max(t.CONDITIONAL_FORMATTING_VIEWPORT_CACHE_LENGTH,c);this._conditionalFormattingViewModel.setCacheLength(v)}}))};i&&e(i),this._univerInstanceService.getCurrentTypeOfUnit$(l.UniverInstanceType.UNIVER_SHEET).subscribe(n=>{n&&e(n)})}};Me=Un([Be(0,l.Inject(t.ConditionalFormattingViewModel)),Be(1,l.IUniverInstanceService),Be(2,vt.IRenderManagerService)],Me);const ct=[O.SetWorksheetActiveOperation.id,t.AddConditionalRuleMutation.id,t.SetConditionalRuleMutation.id,t.DeleteConditionalRuleMutation.id,t.MoveConditionalRuleMutation.id],ce=[{label:{name:"sheet.cf.ruleType.highlightCell",selectable:!1},value:G.highlightCell},{label:{name:"sheet.cf.panel.rankAndAverage",selectable:!1},value:G.rank},{label:{name:"sheet.cf.ruleType.formula",selectable:!1},value:G.formula},{label:{name:"sheet.cf.ruleType.colorScale",selectable:!1},value:G.colorScale},{label:{name:"sheet.cf.ruleType.dataBar",selectable:!1},value:G.dataBar},{label:{name:"sheet.cf.ruleType.iconSet",selectable:!1},value:G.icon},{label:{name:"sheet.cf.menu.manageConditionalFormatting",selectable:!1},value:G.viewRule},{label:{name:"sheet.cf.menu.createConditionalFormatting",selectable:!1},value:G.createRule},{label:{name:"sheet.cf.menu.clearRangeRules",selectable:!1},value:G.clearRangeRules,disabled:!1},{label:{name:"sheet.cf.menu.clearWorkSheetRules",selectable:!1},value:G.clearWorkSheetRules}],kn=i=>{const e=i.get(O.SheetsSelectionsService),n=i.get(l.ICommandService),r=i.get(l.IUniverInstanceService),o=i.get(t.ConditionalFormattingRuleModel),s=new K.Observable(d=>K.merge(e.selectionMoveEnd$,e.selectionSet$,new K.Observable(h=>{const c=n.onCommandExecuted(v=>{var y;const{id:p,params:b}=v,S=(y=r.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET))==null?void 0:y.getUnitId();ct.includes(p)&&b.unitId===S&&h.next(null)});return()=>c.dispose()})).pipe(de.debounceTime(16)).subscribe(()=>{var y;const h=((y=e.getCurrentSelections())==null?void 0:y.map(_=>_.range))||[],c=r.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET);if(!c)return;const v=c.getActiveSheet();if(!v)return;const S=(o.getSubunitRules(c.getUnitId(),v.getSheetId())||[]).filter(_=>_.ranges.some(R=>h.some(w=>l.Rectangle.intersects(w,R)))).map(_=>_.ranges).every(_=>O.checkRangesEditablePermission(i,c.getUnitId(),v.getSheetId(),_));d.next(S)})),a=new K.Observable(d=>new K.Observable(h=>{const c=n.onCommandExecuted(v=>{var y;const{id:p,params:b}=v,S=(y=r.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET))==null?void 0:y.getUnitId();ct.includes(p)&&b.unitId===S&&h.next(null)});return()=>c.dispose()}).pipe(de.debounceTime(16)).subscribe(()=>{const h=r.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET);if(!h)return;const c=h.getActiveSheet();if(!c)return;const v=o.getSubunitRules(h.getUnitId(),c.getSheetId())||[];if(!v.length)return d.next(!1),!1;const p=v.map(b=>b.ranges).every(b=>O.checkRangesEditablePermission(i,h.getUnitId(),c.getSheetId(),b));d.next(p)})),m=new K.Observable(d=>{s.subscribe(h=>{const c=ce.find(v=>v.value===G.clearRangeRules);c&&(c.disabled=!h,d.next(ce))}),a.subscribe(h=>{const c=ce.find(v=>v.value===G.clearWorkSheetRules);c&&(c.disabled=!h,d.next(ce))}),d.next(ce)});return{id:be.id,type:D.MenuItemType.SELECTOR,icon:"ConditionsDoubleIcon",tooltip:"sheet.cf.title",selections:m,hidden$:D.getMenuHiddenObservable(i,l.UniverInstanceType.UNIVER_SHEET),disabled$:W.getCurrentRangeDisable$(i,{workbookTypes:[O.WorkbookEditablePermission],worksheetTypes:[O.WorksheetSetCellStylePermission,O.WorksheetEditPermission],rangeTypes:[O.RangeProtectionPermissionEditPoint]})}},Pn={[D.RibbonDataGroup.RULES]:{[be.id]:{order:1,menuItemFactory:kn}}};var Dn=Object.getOwnPropertyDescriptor,Ln=(i,e,n,r)=>{for(var o=r>1?void 0:r?Dn(e,n):e,s=i.length-1,a;s>=0;s--)(a=i[s])&&(o=a(o)||o);return o},dt=(i,e)=>(n,r)=>e(n,r,i);let Ve=class extends l.Disposable{constructor(e,n){super();z(this,"_sidebarDisposable",null);this._injector=e,this._menuManagerService=n,this._menuManagerService.mergeMenu(Pn)}};Ve=Ln([dt(0,l.Inject(l.Injector)),dt(1,D.IMenuManagerService)],Ve);var An=Object.defineProperty,$n=Object.getOwnPropertyDescriptor,Bn=(i,e,n)=>e in i?An(i,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):i[e]=n,Hn=(i,e,n,r)=>{for(var o=r>1?void 0:r?$n(e,n):e,s=i.length-1,a;s>=0;s--)(a=i[s])&&(o=a(o)||o);return o},He=(i,e)=>(n,r)=>e(n,r,i),ke=(i,e,n)=>Bn(i,typeof e!="symbol"?e+"":e,n);exports.UniverSheetsConditionalFormattingUIPlugin=class extends l.Plugin{constructor(e=we,n,r,o){super(),this._config=e,this._injector=n,this._commandService=r,this._configService=o;const{menu:s,...a}=l.merge({},we,this._config);s&&this._configService.setConfig("menu",s,{merge:!0}),this._configService.setConfig(xt,a),this._initCommand()}onStarting(){l.registerDependencies(this._injector,[[ge],[he],[Ne],[pe],[me],[Ve],[ie],[Ee],[exports.ConditionalFormattingClearController],[je],[Me],[ve]]),l.touchDependencies(this._injector,[[ge],[ve]])}onReady(){l.touchDependencies(this._injector,[[Ve],[me]])}onRendered(){l.touchDependencies(this._injector,[[Ne],[exports.ConditionalFormattingClearController],[he],[Ee],[ie],[je],[pe],[Me]])}_initCommand(){[qe,Ge,Ze,Ye,ze,Ke,Xe,Je,Qe,be].forEach(e=>{this._commandService.registerCommand(e)})}};ke(exports.UniverSheetsConditionalFormattingUIPlugin,"pluginName",`${t.SHEET_CONDITIONAL_FORMATTING_PLUGIN}_UI_PLUGIN`);ke(exports.UniverSheetsConditionalFormattingUIPlugin,"packageName",Oe.name);ke(exports.UniverSheetsConditionalFormattingUIPlugin,"version",Oe.version);ke(exports.UniverSheetsConditionalFormattingUIPlugin,"type",l.UniverInstanceType.UNIVER_SHEET);exports.UniverSheetsConditionalFormattingUIPlugin=Hn([l.DependentOn(t.UniverSheetsConditionalFormattingPlugin,mt.UniverSheetsFormulaPlugin),He(1,l.Inject(l.Injector)),He(2,l.Inject(l.ICommandService)),He(3,l.IConfigService)],exports.UniverSheetsConditionalFormattingUIPlugin);exports.AddAverageCfCommand=qe;exports.AddColorScaleConditionalRuleCommand=Ge;exports.AddDataBarConditionalRuleCommand=Ze;exports.AddDuplicateValuesCfCommand=Ye;exports.AddNumberCfCommand=ze;exports.AddRankCfCommand=Ke;exports.AddTextCfCommand=Xe;exports.AddTimePeriodCfCommand=Je;exports.AddUniqueValuesCfCommand=Qe;exports.OpenConditionalFormattingOperator=be;
3
+ `,children:[u.jsx("div",{className:"univer-flex univer-items-center univer-gap-2",children:d.tWithReactNode("sheet.cf.panel.managerRuleSelect",u.jsx(j.Select,{className:"univer-w-36",options:g,value:y,onChange:U=>{_(U)}})).map((U,L)=>u.jsx("span",{children:U},L))}),u.jsxs("div",{className:"univer-flex univer-justify-end univer-space-x-2",children:[u.jsx(j.Tooltip,{title:a.t("sheet.cf.panel.createRule"),placement:"bottom",children:u.jsx("a",{className:"univer-size-5 univer-cursor-pointer",onClick:P,children:u.jsx(gt,{})})}),x.length&&A?u.jsx(j.Tooltip,{title:a.t("sheet.cf.panel.clear"),placement:"bottom",children:u.jsx("a",{className:"univer-size-5 univer-cursor-pointer",onClick:f,children:u.jsx(_e,{className:"univer-text-red-500"})})}):u.jsx("div",{children:u.jsx(_e,{className:"univer-text-gray-300"})})]})]}),u.jsx("div",{children:u.jsx(j.DraggableList,{className:"univer-w-full",draggableHandle:".draggableHandle",list:F,onListChange:()=>{},idKey:"cfId",rowHeight:60,margin:[0,10],onDragStop:k,onDragStart:M,itemRender:U=>u.jsxs("div",{className:j.clsx("univer-group univer-relative univer-flex univer-items-center univer-justify-between univer-rounded univer-py-2 univer-pl-5 univer-pr-8 hover:univer-bg-gray-100 dark:hover:!univer-bg-gray-700",{"univer-bg-gray-100 dark:!univer-bg-gray-700":E===U.cfId}),onMouseMove:()=>{U.ranges!==b&&S(U.ranges)},onMouseLeave:()=>S([]),onClick:()=>{e(U)},children:[u.jsx("div",{className:j.clsx("univer-absolute univer-left-0 univer-hidden univer-size-5 univer-cursor-grab univer-items-center univer-justify-center univer-rounded group-hover:univer-flex","draggableHandle"),onClick:L=>L.stopPropagation(),children:u.jsx(Ct,{})}),u.jsxs("div",{className:"univer-min-w-0 univer-max-w-full univer-flex-shrink univer-overflow-hidden",children:[u.jsx("div",{className:"univer-text-sm univer-text-gray-900 dark:!univer-text-white",children:sn(U,a)}),u.jsx("div",{className:"univer-text-xs univer-text-gray-400",children:U.ranges.map(L=>We.serializeRange(L)).join(",")})]}),u.jsx("div",{children:u.jsx(oe,{rule:U.rule})}),u.jsx("div",{className:j.clsx("univer-absolute univer-right-1 univer-hidden univer-size-6 univer-cursor-pointer univer-items-center univer-justify-center univer-rounded univer-text-red-500 group-hover:univer-flex hover:univer-bg-gray-200",{"univer-flex univer-items-center univer-justify-center":E===U.cfId}),onClick:L=>{L.stopPropagation(),V(U),S([])},children:u.jsx(_e,{})})]})})})]})},ln=i=>{const[e,n]=C.useState(i.rule),[r,o]=C.useState(!!i.rule),s=()=>{o(!0)},a=()=>{o(!1),n(void 0)},m=d=>{n(d),o(!0)};return u.jsx("div",{className:"univer-flex univer-h-full univer-flex-col univer-justify-between univer-py-4",children:r?u.jsx(tn,{onCancel:a,rule:e}):u.jsx(an,{onClick:m,onCreate:s})})};var un=Object.getOwnPropertyDescriptor,cn=(i,e,n,r)=>{for(var o=r>1?void 0:r?un(e,n):e,s=i.length-1,a;s>=0;s--)(a=i[s])&&(o=a(o)||o);return o},se=(i,e)=>(n,r)=>e(n,r,i);const Fe="sheet.conditional.formatting.panel";let me=class extends l.Disposable{constructor(e,n,r,o,s){super();z(this,"_sidebarDisposable",null);this._univerInstanceService=e,this._injector=n,this._componentManager=r,this._sidebarService=o,this._localeService=s,this._initPanel(),this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(l.UniverInstanceType.UNIVER_SHEET).subscribe(a=>{var m;a||(m=this._sidebarDisposable)==null||m.dispose()})),this.disposeWithMe(this._sidebarService.sidebarOptions$.subscribe(a=>{a.id===Fe&&(a.visible||setTimeout(()=>{this._sidebarService.sidebarOptions$.next({visible:!1})}))}))}openPanel(e){const n={id:Fe,header:{title:this._localeService.t("sheet.cf.title")},children:{label:Fe,rule:e,key:l.generateRandomId(4)},onClose:()=>this._sidebarDisposable=null};this._sidebarDisposable=this._sidebarService.open(n)}_initPanel(){this.disposeWithMe(this._componentManager.register(Fe,ln))}};me=cn([se(0,l.IUniverInstanceService),se(1,l.Inject(l.Injector)),se(2,l.Inject(D.ComponentManager)),se(3,l.Inject(D.ISidebarService)),se(4,l.Inject(l.LocaleService))],me);var G=(i=>(i[i.createRule=1]="createRule",i[i.viewRule=2]="viewRule",i[i.highlightCell=3]="highlightCell",i[i.rank=4]="rank",i[i.formula=5]="formula",i[i.colorScale=6]="colorScale",i[i.dataBar=7]="dataBar",i[i.icon=8]="icon",i[i.clearRangeRules=9]="clearRangeRules",i[i.clearWorkSheetRules=10]="clearWorkSheetRules",i))(G||{});const be={id:"sheet.operation.open.conditional.formatting.panel",type:l.CommandType.OPERATION,handler:(i,e)=>{var m;const n=i.get(me),r=i.get(O.SheetsSelectionsService),o=i.get(l.ICommandService),s=((m=r.getCurrentSelections())==null?void 0:m.map(d=>d.range))||[];switch(e.value){case 3:{n.openPanel({...t.createDefaultRule(),ranges:s});break}case 4:{const d={...t.createDefaultRule,ranges:s,rule:{type:t.CFRuleType.highlightCell,subType:t.CFSubRuleType.rank}};n.openPanel(d);break}case 5:{const d={...t.createDefaultRule,ranges:s,rule:{type:t.CFRuleType.highlightCell,subType:t.CFSubRuleType.formula,value:"="}};n.openPanel(d);break}case 6:{const d={...t.createDefaultRule,ranges:s,rule:{type:t.CFRuleType.colorScale,config:[]}};n.openPanel(d);break}case 7:{const d={...t.createDefaultRule,ranges:s,rule:{type:t.CFRuleType.dataBar,isShowValue:!0}};n.openPanel(d);break}case 8:{const d={...t.createDefaultRule,ranges:s,rule:{type:t.CFRuleType.iconSet,config:[],isShowValue:!0}};n.openPanel(d);break}case 2:{n.openPanel();break}case 1:{n.openPanel({...t.createDefaultRule(),ranges:s});break}case 9:{o.executeCommand(t.ClearRangeCfCommand.id,{ranges:s});break}case 10:{o.executeCommand(t.ClearWorksheetCfCommand.id);break}}return!0}};var dn=Object.getOwnPropertyDescriptor,mn=(i,e,n,r)=>{for(var o=r>1?void 0:r?dn(e,n):e,s=i.length-1,a;s>=0;s--)(a=i[s])&&(o=a(o)||o);return o},ae=(i,e)=>(n,r)=>e(n,r,i);exports.ConditionalFormattingClearController=class extends l.Disposable{constructor(e,n,r,o,s){super(),this._injector=e,this._univerInstanceService=n,this._sheetInterceptorService=r,this._selectionManagerService=o,this._conditionalFormattingRuleModel=s,this._init()}_init(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:e=>{var s;const n=[],r=[],o={redos:n,undos:r};if([O.ClearSelectionFormatCommand.id,O.ClearSelectionAllCommand.id].includes(e.id)){const a=(s=this._selectionManagerService.getCurrentSelections())==null?void 0:s.map(S=>S.range);if(!a)return o;const m=this._univerInstanceService.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET),d=m.getActiveSheet();if(!d)return o;const h=m.getUnitId(),c=d.getSheetId(),v=this._conditionalFormattingRuleModel.getSubunitRules(h,c);if(!v||!v.length)return o;const{redos:p,undos:b}=lt(this._injector,v,a,h,c);n.push(...p),r.push(...b)}return o}})),this.disposeWithMe(this._sheetInterceptorService.interceptRanges({getMutations:({unitId:e,subUnitId:n,ranges:r})=>{const o=[],s=[],a={redos:o,undos:s};if(!r||!r.length)return a;const m=this._conditionalFormattingRuleModel.getSubunitRules(e,n);if(!m||!m.length)return a;const{redos:d,undos:h}=lt(this._injector,m,r,e,n);return o.push(...d),s.push(...h),a}}))}};exports.ConditionalFormattingClearController=mn([ae(0,l.Inject(l.Injector)),ae(1,l.Inject(l.IUniverInstanceService)),ae(2,l.Inject(O.SheetInterceptorService)),ae(3,l.Inject(O.SheetsSelectionsService)),ae(4,l.Inject(t.ConditionalFormattingRuleModel))],exports.ConditionalFormattingClearController);function lt(i,e,n,r,o){const s=[],a=[];return e.filter(m=>n.some(d=>m.ranges.some(h=>l.Rectangle.getIntersects(h,d)))).forEach(m=>{const h=new O.RangeMergeUtil().add(...m.ranges).subtract(...n).merge();if(h.length){const c={id:t.SetConditionalRuleMutation.id,params:{unitId:r,subUnitId:o,rule:{...m,ranges:h}}},v=t.setConditionalRuleMutationUndoFactory(i,c.params);s.push(c),a.push(...v)}else{const c={id:t.DeleteConditionalRuleMutation.id,params:{unitId:r,subUnitId:o,cfId:m.cfId}},v=t.DeleteConditionalRuleMutationUndoFactory(i,c.params);s.push(c),a.push(...v)}}),{redos:s,undos:a}}const vn="@univerjs/sheets-conditional-formatting-ui",hn="0.17.0",Oe={name:vn,version:hn},xt="sheets-conditional-formatting-ui.config",we={};var pn=Object.getOwnPropertyDescriptor,gn=(i,e,n,r)=>{for(var o=r>1?void 0:r?pn(e,n):e,s=i.length-1,a;s>=0;s--)(a=i[s])&&(o=a(o)||o);return o},Le=(i,e)=>(n,r)=>e(n,r,i);let ve=class extends l.Disposable{constructor(e,n,r){super();z(this,"_disposableMap",new Map);this._conditionalFormattingRuleModel=e,this._formulaRefRangeService=n,this._injector=r,this._initRefRange()}_getIdWithUnitId(e,n,r){return`${e}_${n}_${r}`}_getRuleFormulas(e){const n=[],r=e.rule;switch(r.type){case t.CFRuleType.highlightCell:r.subType===t.CFSubRuleType.formula&&n.push(r.value);break;case t.CFRuleType.dataBar:{const o=r;o.config.min.type===t.CFValueType.formula&&n.push(o.config.min.value),o.config.max.type===t.CFValueType.formula&&n.push(o.config.max.value);break}case t.CFRuleType.colorScale:{r.config.forEach(s=>{s.value.type===t.CFValueType.formula&&n.push(s.value.value)});break}case t.CFRuleType.iconSet:{r.config.forEach(s=>{s.value.type===t.CFValueType.formula&&n.push(s.value.value)});break}}return n}_updateRuleFormulas(e,n){const r=l.Tools.deepClone(e),o=r.rule;let s=0;switch(o.type){case t.CFRuleType.highlightCell:o.subType===t.CFSubRuleType.formula&&(o.value=n[s++]);break;case t.CFRuleType.dataBar:{const a=o;a.config.min.type===t.CFValueType.formula&&(a.config.min.value=n[s++]),a.config.max.type===t.CFValueType.formula&&(a.config.max.value=n[s++]);break}case t.CFRuleType.colorScale:{o.config.forEach(m=>{m.value.type===t.CFValueType.formula&&(m.value.value=n[s++])});break}case t.CFRuleType.iconSet:{o.config.forEach(m=>{m.value.type===t.CFValueType.formula&&(m.value.value=n[s++])});break}}return r}register(e,n,r){const o=r.ranges,s=this._getRuleFormulas(r),a=this._formulaRefRangeService.registerRangeFormula(e,n,o,s,d=>{if(d.length===0)return{undos:[{id:t.AddConditionalRuleMutation.id,params:{unitId:e,subUnitId:n,rule:r}}],redos:[{id:t.DeleteConditionalRuleMutation.id,params:{unitId:e,subUnitId:n,cfId:r.cfId}}]};const h=[],c=[],v=d[0],p=this._updateRuleFormulas(r,v.formulas);p.ranges=v.ranges,h.push({id:t.SetConditionalRuleMutation.id,params:{unitId:e,subUnitId:n,cfId:r.cfId,rule:p}}),c.push(...t.setConditionalRuleMutationUndoFactory(this._injector,{unitId:e,subUnitId:n,cfId:r.cfId,rule:p}));for(let b=1;b<d.length;b++){const S=d[b],y=t.createCfId(),_=this._updateRuleFormulas(r,S.formulas);_.cfId=y,_.ranges=S.ranges,h.push({id:t.AddConditionalRuleMutation.id,params:{unitId:e,subUnitId:n,rule:_}}),c.push(t.AddConditionalRuleMutationUndoFactory(this._injector,{unitId:e,subUnitId:n,rule:_}))}return{undos:c,redos:h}}),m=this._getIdWithUnitId(e,n,r.cfId);this._disposableMap.set(m,a)}_initRefRange(){const e=this._conditionalFormattingRuleModel.getAll();for(const[n,r]of e)for(const[o,s]of r)for(const a of s)this.register(n,o,a);this.disposeWithMe(this._conditionalFormattingRuleModel.$ruleChange.subscribe(n=>{const{unitId:r,subUnitId:o,rule:s}=n;switch(n.type){case"add":{this.register(r,o,s);break}case"delete":{const a=this._getIdWithUnitId(r,o,s.cfId),m=this._disposableMap.get(a);m&&(m.dispose(),this._disposableMap.delete(a));break}case"set":{const a=this._getIdWithUnitId(r,o,s.cfId),m=this._disposableMap.get(a);m&&(m.dispose(),this._disposableMap.delete(a)),this.register(r,o,s);break}}})),this.disposeWithMe(l.toDisposable(()=>{this._disposableMap.forEach(n=>{n.dispose()}),this._disposableMap.clear()}))}};ve=gn([Le(0,l.Inject(t.ConditionalFormattingRuleModel)),Le(1,l.Inject(mt.FormulaRefRangeService)),Le(2,l.Inject(l.Injector))],ve);var fn=Object.getOwnPropertyDescriptor,Cn=(i,e,n,r)=>{for(var o=r>1?void 0:r?fn(e,n):e,s=i.length-1,a;s>=0;s--)(a=i[s])&&(o=a(o)||o);return o},le=(i,e)=>(n,r)=>e(n,r,i);let he=class extends l.Disposable{constructor(e,n,r,o,s){super();z(this,"_copyInfo");this._sheetClipboardService=e,this._conditionalFormattingRuleModel=n,this._injector=r,this._conditionalFormattingViewModel=o,this._univerInstanceService=s,this._initClipboardHook()}_initClipboardHook(){this.disposeWithMe(this._sheetClipboardService.addClipboardHook({id:t.SHEET_CONDITIONAL_FORMATTING_PLUGIN,onBeforeCopy:(e,n,r)=>this._collectConditionalRule(e,n,r),onPasteCells:(e,n,r,o)=>{const{copyType:s=W.COPY_TYPE.COPY,pasteType:a}=o,{range:m}=e||{},{range:d}=n;return this._generateConditionalFormattingMutations(d,{copyType:s,pasteType:a,copyRange:m})}}))}_collectConditionalRule(e,n,r){const o=new l.ObjectMatrix,s={};this._copyInfo={matrix:o,info:{unitId:e,subUnitId:n,cfMap:s}};const a=this._injector.invoke(c=>O.rangeToDiscreteRange(r,c,e,n));if(!a)return;const{rows:m,cols:d}=a,h=new Set;m.forEach((c,v)=>{d.forEach((p,b)=>{const S=this._conditionalFormattingViewModel.getCellCfs(e,n,c,p);S&&(S.forEach(y=>h.add(y.cfId)),o.setValue(v,b,S.map(y=>y.cfId)))})}),h.forEach(c=>{const v=this._conditionalFormattingRuleModel.getRule(e,n,c);v&&(s[c]=v.rule)})}_generateConditionalFormattingMutations(e,n){const r=this._univerInstanceService.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET),o=r.getActiveSheet(),s=r.getUnitId();if(!o)return{redos:[],undos:[]};const a=o.getSheetId();if(n.copyType===W.COPY_TYPE.CUT)return this._copyInfo=null,{redos:[],undos:[]};if(!this._copyInfo||!n.copyRange)return{redos:[],undos:[]};if(![W.PREDEFINED_HOOK_NAME_PASTE.SPECIAL_PASTE_FORMAT,W.PREDEFINED_HOOK_NAME_PASTE.DEFAULT_PASTE,W.PREDEFINED_HOOK_NAME_PASTE.SPECIAL_PASTE_BESIDES_BORDER].includes(n.pasteType))return{redos:[],undos:[]};const{ranges:[d,h],mapFunc:c}=W.virtualizeDiscreteRanges([n.copyRange,e]),v=W.getRepeatRange(d,h,!0),p={};l.Range.foreach(h,(g,T)=>{const{row:x,col:I}=c(g,T),V=this._conditionalFormattingViewModel.getCellCfs(s,a,x,I);V&&V.forEach(M=>{if(!p[M.cfId]){const k=new l.ObjectMatrix;p[M.cfId]=k;const P=this._conditionalFormattingRuleModel.getRule(s,a,M.cfId);P==null||P.ranges.forEach(f=>{l.Range.foreach(f,(F,A)=>{k.setValue(F,A,1)})})}p[M.cfId].realDeleteValue(x,I)})});const{matrix:b,info:S}=this._copyInfo,y=[];let _=this._conditionalFormattingRuleModel.createCfId(s,a);const R={},w=g=>{if(R[g])return R[g];const T=S==null?void 0:S.cfMap[g],x=[...this._conditionalFormattingRuleModel.getSubunitRules(s,a)||[],...y].find(I=>l.Tools.diffValue(I.rule,T));if(x)return R[g]=x,x;{const I={rule:T,cfId:_,ranges:[],stopIfTrue:!1};return R[g]=I,y.push(I),_=`${Number(_)+1}`,I}};v.forEach(g=>{b&&b.forValue((T,x,I)=>{const V=l.Rectangle.getPositionRange({startRow:T,endRow:T,startColumn:x,endColumn:x},g.startRange),{row:M,col:k}=c(V.startRow,V.startColumn);I.forEach(P=>{if(!p[P]){const f=w(P),F=new l.ObjectMatrix;p[P]=F,f.ranges.forEach(A=>{l.Range.foreach(A,(U,L)=>{F.setValue(U,L,1)})})}p[P].setValue(M,k,1)})})});const E=[],N=[];for(const g in p){const T=p[g],x=O.findAllRectangle(O.createTopMatrixFromMatrix(T));if(!x.length){const I={unitId:s,subUnitId:a,cfId:g};E.push({id:t.DeleteConditionalRuleMutation.id,params:I}),N.push(...t.DeleteConditionalRuleMutationUndoFactory(this._injector,I))}if(y.some(I=>I.cfId===g)){const I=w(g),V={unitId:s,subUnitId:a,rule:{...I,ranges:x}};E.push({id:t.AddConditionalRuleMutation.id,params:V}),N.push(t.AddConditionalRuleMutationUndoFactory(this._injector,V))}else{const I=this._conditionalFormattingRuleModel.getRule(s,a,g);if(!I)continue;const V={unitId:s,subUnitId:a,rule:{...I,ranges:x}};E.push({id:t.SetConditionalRuleMutation.id,params:V}),N.push(...t.setConditionalRuleMutationUndoFactory(this._injector,V))}}return{redos:E,undos:N}}};he=Cn([le(0,l.Inject(W.ISheetClipboardService)),le(1,l.Inject(t.ConditionalFormattingRuleModel)),le(2,l.Inject(l.Injector)),le(3,l.Inject(t.ConditionalFormattingViewModel)),le(4,l.Inject(l.IUniverInstanceService))],he);var yn=Object.getOwnPropertyDescriptor,bn=(i,e,n,r)=>{for(var o=r>1?void 0:r?yn(e,n):e,s=i.length-1,a;s>=0;s--)(a=i[s])&&(o=a(o)||o);return o},Ae=(i,e)=>(n,r)=>e(n,r,i);let pe=class extends l.Disposable{constructor(i,e,n){super(),this._localeService=i,this._commandService=e,this._sheetPermissionCheckController=n,this._commandExecutedListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.beforeCommandExecuted(i=>{if(i.id===t.AddCfCommand.id){const{unitId:e,subUnitId:n,rule:{ranges:r}}=i.params;this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[O.WorkbookEditablePermission],rangeTypes:[O.RangeProtectionPermissionEditPoint],worksheetTypes:[O.WorksheetEditPermission,O.WorksheetSetCellStylePermission]},r,e,n)||this._sheetPermissionCheckController.blockExecuteWithoutPermission(this._localeService.t("permission.dialog.setStyleErr"))}}))}};pe=bn([Ae(0,l.Inject(l.LocaleService)),Ae(1,l.ICommandService),Ae(2,l.Inject(O.SheetPermissionCheckController))],pe);var In=Object.getOwnPropertyDescriptor,Sn=(i,e,n,r)=>{for(var o=r>1?void 0:r?In(e,n):e,s=i.length-1,a;s>=0;s--)(a=i[s])&&(o=a(o)||o);return o},ne=(i,e)=>(n,r)=>e(n,r,i);let ge=class extends l.Disposable{constructor(e,n,r,o,s,a){super();z(this,"_ruleChangeCacheMap",new Map);this._sheetInterceptorService=e,this._conditionalFormattingService=n,this._univerInstanceService=r,this._renderManagerService=o,this._conditionalFormattingViewModel=s,this._conditionalFormattingRuleModel=a,this._initViewModelInterceptor(),this._initSkeleton(),this.disposeWithMe(()=>{this._ruleChangeCacheMap.clear()})}_markDirtySkeleton(){var n,r,o;const e=this._univerInstanceService.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET).getUnitId();(n=this._renderManagerService.getRenderById(e))==null||n.with(W.SheetSkeletonManagerService).reCalculate(),(o=(r=this._renderManagerService.getRenderById(e))==null?void 0:r.mainComponent)==null||o.makeDirty()}_initSkeleton(){this.disposeWithMe(K.merge(this._conditionalFormattingRuleModel.$ruleChange,this._conditionalFormattingViewModel.markDirty$).pipe(de.bufferTime(16),de.filter(e=>!!e.length),de.filter(e=>{const n=this._univerInstanceService.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET);if(!n)return!1;const r=n.getActiveSheet();return r?e.filter(o=>o.unitId===n.getUnitId()&&o.subUnitId===r.getSheetId()).length>0:!1})).subscribe(()=>this._markDirtySkeleton()))}_initViewModelInterceptor(){this.disposeWithMe(this._sheetInterceptorService.intercept(O.INTERCEPTOR_POINT.CELL_CONTENT,{effect:l.InterceptorEffectEnum.Style,handler:(e,n,r)=>{const o=this._conditionalFormattingService.composeStyle(n.unitId,n.subUnitId,n.row,n.col);if(!o)return r(e);const s=n.workbook.getStyles(),a=(typeof(e==null?void 0:e.s)=="string"?s.get(e==null?void 0:e.s):e==null?void 0:e.s)||{},m=e===n.rawData?{...n.rawData}:e;if(o.style){const d={...a,...o.style};Object.assign(m,{s:d})}return m.fontRenderExtension||(m.fontRenderExtension={},o.isShowValue!==void 0&&(m.fontRenderExtension.isSkip=!o.isShowValue)),o.dataBar&&(m.dataBar=o.dataBar),o.iconSet&&(m.iconSet=o.iconSet,m.fontRenderExtension.leftOffset=t.DEFAULT_PADDING+t.DEFAULT_WIDTH),r(m)},priority:10}))}};ge=Sn([ne(0,l.Inject(O.SheetInterceptorService)),ne(1,l.Inject(t.ConditionalFormattingService)),ne(2,l.Inject(l.IUniverInstanceService)),ne(3,l.Inject(vt.IRenderManagerService)),ne(4,l.Inject(t.ConditionalFormattingViewModel)),ne(5,l.Inject(t.ConditionalFormattingRuleModel))],ge);var Tn=Object.defineProperty,xn=Object.getOwnPropertyDescriptor,Rn=(i,e,n)=>e in i?Tn(i,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):i[e]=n,Fn=(i,e,n,r)=>{for(var o=r>1?void 0:r?xn(e,n):e,s=i.length-1,a;s>=0;s--)(a=i[s])&&(o=a(o)||o);return o},$e=(i,e)=>(n,r)=>e(n,r,i),Ue=(i,e,n)=>Rn(i,typeof e!="symbol"?e+"":e,n);exports.UniverSheetsConditionalFormattingMobileUIPlugin=class extends l.Plugin{constructor(e=we,n,r,o){super(),this._config=e,this._injector=n,this._commandService=r,this._configService=o;const{menu:s,...a}=l.merge({},we,this._config);s&&this._configService.setConfig("menu",s,{merge:!0}),this._configService.setConfig(xt,a),this._initCommand(),this._injector.add([ge]),this._injector.add([he]),this._injector.add([pe]),this._injector.add([ie]),this._injector.add([ve])}_initCommand(){[qe,Ge,Ze,Ye,ze,Ke,Xe,Je,Qe,be].forEach(e=>{this._commandService.registerCommand(e)})}};Ue(exports.UniverSheetsConditionalFormattingMobileUIPlugin,"pluginName",`${t.SHEET_CONDITIONAL_FORMATTING_PLUGIN}_MOBILE_UI_PLUGIN`);Ue(exports.UniverSheetsConditionalFormattingMobileUIPlugin,"packageName",Oe.name);Ue(exports.UniverSheetsConditionalFormattingMobileUIPlugin,"version",Oe.version);Ue(exports.UniverSheetsConditionalFormattingMobileUIPlugin,"type",l.UniverInstanceType.UNIVER_SHEET);exports.UniverSheetsConditionalFormattingMobileUIPlugin=Fn([l.DependentOn(t.UniverSheetsConditionalFormattingPlugin),$e(1,l.Inject(l.Injector)),$e(2,l.Inject(l.ICommandService)),$e(3,l.IConfigService)],exports.UniverSheetsConditionalFormattingMobileUIPlugin);var _n=Object.getOwnPropertyDescriptor,wn=(i,e,n,r)=>{for(var o=r>1?void 0:r?_n(e,n):e,s=i.length-1,a;s>=0;s--)(a=i[s])&&(o=a(o)||o);return o},ue=(i,e)=>(n,r)=>e(n,r,i);let Ne=class extends l.Disposable{constructor(i,e,n,r,o){super(),this._injector=i,this._univerInstanceService=e,this._autoFillService=n,this._conditionalFormattingRuleModel=r,this._conditionalFormattingViewModel=o,this._initAutoFill()}_initAutoFill(){const i=()=>({redos:[],undos:[]}),e=(o,s,a,m,d)=>{var b;const h=this._univerInstanceService.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET).getUnitId(),c=(b=this._univerInstanceService.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:b.getSheetId();if(!h||!c)return;const v={startRow:o.row,startColumn:o.col,endColumn:o.col,endRow:o.row},p={startRow:s.row,startColumn:s.col,endColumn:s.col,endRow:s.row};l.Range.foreach(a,(S,y)=>{const _=l.Rectangle.getPositionRange({startRow:S,startColumn:y,endColumn:y,endRow:S},v),R=l.Rectangle.getPositionRange({startRow:S,startColumn:y,endColumn:y,endRow:S},p),{row:w,col:E}=d(_.startRow,_.startColumn),N=this._conditionalFormattingViewModel.getCellCfs(h,c,w,E),{row:g,col:T}=d(R.startRow,R.startColumn),x=this._conditionalFormattingViewModel.getCellCfs(h,c,g,T);x&&x.forEach(I=>{let V=m.get(I.cfId);if(!m.get(I.cfId)){const M=this._conditionalFormattingRuleModel.getRule(h,c,I.cfId);if(!M)return;V=new l.ObjectMatrix,M.ranges.forEach(k=>{l.Range.foreach(k,(P,f)=>{V.setValue(P,f,1)})}),m.set(I.cfId,V)}V.realDeleteValue(g,T)}),N&&N.forEach(I=>{let V=m.get(I.cfId);if(!m.get(I.cfId)){const M=this._conditionalFormattingRuleModel.getRule(h,c,I.cfId);if(!M)return;V=new l.ObjectMatrix,M.ranges.forEach(k=>{l.Range.foreach(k,(P,f)=>{V.setValue(P,f,1)})}),m.set(I.cfId,V)}V.setValue(g,T,1)})})},n=(o,s)=>{var R,w,E;const a=(R=this._univerInstanceService.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET))==null?void 0:R.getUnitId(),m=(E=(w=this._univerInstanceService.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET))==null?void 0:w.getActiveSheet())==null?void 0:E.getSheetId(),d=new Map,h=[],c=[];if(!a||!m)return i();const v=W.virtualizeDiscreteRanges([o,s]),[p,b]=v.ranges,{mapFunc:S}=v,y={row:p.startRow,col:p.startColumn};return O.AutoFillTools.getAutoFillRepeatRange(p,b).forEach(N=>{e(y,N.repeatStartCell,N.relativeRange,d,S)}),d.forEach((N,g)=>{const T=this._conditionalFormattingRuleModel.getRule(a,m,g);if(!T)return;const x=O.findAllRectangle(O.createTopMatrixFromMatrix(N));if(x.length){const I={unitId:a,subUnitId:m,rule:{...T,ranges:x}};h.push({id:t.SetConditionalRuleMutation.id,params:I}),c.push(...t.setConditionalRuleMutationUndoFactory(this._injector,I))}else{const I={unitId:a,subUnitId:m,cfId:T.cfId};h.push({id:t.DeleteConditionalRuleMutation.id,params:I}),c.push(...t.DeleteConditionalRuleMutationUndoFactory(this._injector,I))}}),{undos:c,redos:h}},r={id:t.SHEET_CONDITIONAL_FORMATTING_PLUGIN,onFillData:(o,s,a)=>{if(a===O.AUTO_FILL_APPLY_TYPE.COPY||a===O.AUTO_FILL_APPLY_TYPE.ONLY_FORMAT||a===O.AUTO_FILL_APPLY_TYPE.SERIES){const{source:m,target:d}=o;return n(m,d)}return i()}};this.disposeWithMe(this._autoFillService.addHook(r))}};Ne=wn([ue(0,l.Inject(l.Injector)),ue(1,l.Inject(l.IUniverInstanceService)),ue(2,l.Inject(O.IAutoFillService)),ue(3,l.Inject(t.ConditionalFormattingRuleModel)),ue(4,l.Inject(t.ConditionalFormattingViewModel))],Ne);var Nn=Object.getOwnPropertyDescriptor,En=(i,e,n,r)=>{for(var o=r>1?void 0:r?Nn(e,n):e,s=i.length-1,a;s>=0;s--)(a=i[s])&&(o=a(o)||o);return o},ut=(i,e)=>(n,r)=>e(n,r,i);let Ee=class extends l.Disposable{constructor(i,e){super(),this._sheetInterceptorService=i,this._conditionalFormattingService=e,this._initInterceptorEditorEnd()}_initInterceptorEditorEnd(){this.disposeWithMe(l.toDisposable(this._sheetInterceptorService.writeCellInterceptor.intercept(O.AFTER_CELL_EDIT,{handler:(i,e,n)=>{var a,m,d;i||n(i);const r=this._conditionalFormattingService.composeStyle(e.unitId,e.subUnitId,e.row,e.col),o=(a=r==null?void 0:r.style)!=null?a:{},s=Object.keys(o);if(i!=null&&i.p)return(d=(m=i.p.body)==null?void 0:m.textRuns)==null||d.forEach(h=>{h.ts&&s.forEach(c=>{var v;(v=h.ts)==null||delete v[c]})}),n(i);{const h={...(typeof(i==null?void 0:i.s)=="string"?e.workbook.getStyles().get(i.s):i==null?void 0:i.s)||{}};s.forEach(v=>{delete h[v]});const c={...i,s:{...h}};return n(c)}}})))}};Ee=En([ut(0,l.Inject(O.SheetInterceptorService)),ut(1,l.Inject(t.ConditionalFormattingService))],Ee);var jn=Object.getOwnPropertyDescriptor,Mn=(i,e,n,r)=>{for(var o=r>1?void 0:r?jn(e,n):e,s=i.length-1,a;s>=0;s--)(a=i[s])&&(o=a(o)||o);return o},re=(i,e)=>(n,r)=>e(n,r,i);const Vn=(i,e)=>{const n=c=>c.endRow-c.startRow+1,r=c=>c.endColumn-c.startColumn+1,o=n(e)%n(i),s=r(e)%r(i),a=Math.floor(n(e)/n(i)),m=Math.floor(r(e)/r(i)),d=[],h={startRow:0,endRow:n(i)-1,startColumn:0,endColumn:r(i)-1};if(n(e)===1&&r(e)===1){const c={startRow:e.startRow,endRow:e.startRow,startColumn:e.startColumn,endColumn:e.startColumn};return d.push({repeatRelativeRange:h,startRange:c}),d}for(let c=0;c<a+(o?.1:0);c++)for(let v=0;v<m+(s?.1:0);v++){const p=n(i)*c,b=r(i)*v,S={startRow:p+e.startRow,endRow:p+e.startRow,startColumn:b+e.startColumn,endColumn:b+e.startColumn};let y=h;c===a&&o&&(y={...y},y.endRow=y.endRow-(n(i)-o)),v===m&&s&&(y={...y},y.endColumn=y.endColumn-(r(i)-s)),d.push({repeatRelativeRange:y,startRange:S})}return d};let je=class extends l.Disposable{constructor(e,n,r,o,s,a){super();z(this,"_painterConfig",null);this._injector=e,this._univerInstanceService=n,this._formatPainterService=r,this._sheetsSelectionsService=o,this._conditionalFormattingRuleModel=s,this._conditionalFormattingViewModel=a,this._initFormattingPainter()}_initFormattingPainter(){const e=()=>({redos:[],undos:[]}),n=(s,a,m,d,h)=>{const{unitId:c,subUnitId:v}=this._painterConfig,{targetUnitId:p,targetSubUnitId:b}=h,S={startRow:s.row,startColumn:s.col,endColumn:s.col,endRow:s.row},y={startRow:a.row,startColumn:a.col,endColumn:a.col,endRow:a.row};l.Range.foreach(m,(_,R)=>{const w=l.Rectangle.getPositionRange({startRow:_,startColumn:R,endColumn:R,endRow:_},S),E=l.Rectangle.getPositionRange({startRow:_,startColumn:R,endColumn:R,endRow:_},y),N=this._conditionalFormattingViewModel.getCellCfs(c,v,w.startRow,w.startColumn),g=this._conditionalFormattingViewModel.getCellCfs(p,b,E.startRow,E.startColumn);g&&g.forEach(T=>{let x=d.get(T.cfId);if(!d.get(T.cfId)){const I=this._conditionalFormattingRuleModel.getRule(p,b,T.cfId);if(!I)return;x=new l.ObjectMatrix,I.ranges.forEach(V=>{l.Range.foreach(V,(M,k)=>{x.setValue(M,k,1)})}),d.set(T.cfId,x)}x.realDeleteValue(E.startRow,E.startColumn)}),N&&N.forEach(T=>{const x=d.get(T.cfId);x&&x.setValue(E.startRow,E.startColumn,1)})})},r=(s,a,m)=>{var w;const{range:d,unitId:h,subUnitId:c}=this._painterConfig,v=s!==h||c!==a,p=new Map,b=[],S=[];if(!s||!a||!h||!c)return e();const y=(w=this._conditionalFormattingRuleModel.getSubunitRules(h,c))!=null?w:[];y==null||y.forEach(E=>{const{ranges:N,cfId:g}=E;if(N.some(T=>l.Rectangle.intersects(d,T))){const T=new l.ObjectMatrix;v||N.forEach(x=>{l.Range.foreach(x,(I,V)=>{T.setValue(I,V,1)})}),p.set(g,T)}});const _={row:d.startRow,col:d.startColumn};return Vn(d,m).forEach(E=>{n(_,{row:E.startRange.startRow,col:E.startRange.startColumn},E.repeatRelativeRange,p,{targetUnitId:s,targetSubUnitId:a})}),p.forEach((E,N)=>{if(v){const g=this._conditionalFormattingRuleModel.getRule(s,a,N),T=O.findAllRectangle(O.createTopMatrixFromMatrix(E));if(g)if(T.length){const x={unitId:s,subUnitId:a,rule:{...g,ranges:T}};b.push({id:t.SetConditionalRuleMutation.id,params:x}),S.push(...t.setConditionalRuleMutationUndoFactory(this._injector,x))}else{const x={unitId:s,subUnitId:a,cfId:g.cfId};b.push({id:t.DeleteConditionalRuleMutation.id,params:x}),S.push(...t.DeleteConditionalRuleMutationUndoFactory(this._injector,x))}else if(T.length){const x=this._conditionalFormattingRuleModel.getRule(h,c,N);if(x){const I={unitId:s,subUnitId:a,rule:{...l.Tools.deepClone(x),cfId:this._conditionalFormattingRuleModel.createCfId(s,a),ranges:T}};b.push({id:t.AddConditionalRuleMutation.id,params:I}),S.push(t.AddConditionalRuleMutationUndoFactory(this._injector,I))}}}else{const g=this._conditionalFormattingRuleModel.getRule(h,c,N);if(!g)return;const T=O.findAllRectangle(O.createTopMatrixFromMatrix(E));if(T.length){const x={unitId:h,subUnitId:c,rule:{...g,ranges:T}};b.push({id:t.SetConditionalRuleMutation.id,params:x}),S.push(...t.setConditionalRuleMutationUndoFactory(this._injector,x))}else{const x={unitId:h,subUnitId:c,cfId:g.cfId};b.push({id:t.DeleteConditionalRuleMutation.id,params:x}),S.push(...t.DeleteConditionalRuleMutationUndoFactory(this._injector,x))}}}),{undos:S,redos:b}},o={id:t.SHEET_CONDITIONAL_FORMATTING_PLUGIN,onStatusChange:s=>{var a,m,d;switch(s){case W.FormatPainterStatus.INFINITE:case W.FormatPainterStatus.ONCE:{const h=(a=this._univerInstanceService.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET))==null?void 0:a.getUnitId(),c=(d=(m=this._univerInstanceService.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET))==null?void 0:m.getActiveSheet())==null?void 0:d.getSheetId(),v=this._sheetsSelectionsService.getCurrentLastSelection(),p=v==null?void 0:v.range;h&&c&&p&&(this._painterConfig={unitId:h,subUnitId:c,range:p});break}case W.FormatPainterStatus.OFF:{this._painterConfig=null;break}}},onApply:(s,a,m)=>this._painterConfig?r(s,a,m):{redos:[],undos:[]}};this._formatPainterService.addHook(o)}};je=Mn([re(0,l.Inject(l.Injector)),re(1,l.Inject(l.IUniverInstanceService)),re(2,l.Inject(W.IFormatPainterService)),re(3,l.Inject(O.SheetsSelectionsService)),re(4,l.Inject(t.ConditionalFormattingRuleModel)),re(5,l.Inject(t.ConditionalFormattingViewModel))],je);var On=Object.getOwnPropertyDescriptor,Un=(i,e,n,r)=>{for(var o=r>1?void 0:r?On(e,n):e,s=i.length-1,a;s>=0;s--)(a=i[s])&&(o=a(o)||o);return o},Be=(i,e)=>(n,r)=>e(n,r,i);let Me=class extends l.Disposable{constructor(i,e,n){super(),this._conditionalFormattingViewModel=i,this._univerInstanceService=e,this._renderManagerService=n,this._init()}_init(){const i=this._univerInstanceService.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET),e=n=>{const r=n.getUnitId(),o=this._renderManagerService.getRenderById(r);if(!o)return;const s=o.with(W.SheetSkeletonManagerService);this.disposeWithMe(s.currentSkeleton$.subscribe(a=>{if(a){const m=a.skeleton.rowColumnSegment,d=m.endColumn-m.startColumn+1,c=(m.endRow-m.startRow+1)*d*9,v=Math.max(t.CONDITIONAL_FORMATTING_VIEWPORT_CACHE_LENGTH,c);this._conditionalFormattingViewModel.setCacheLength(v)}}))};i&&e(i),this._univerInstanceService.getCurrentTypeOfUnit$(l.UniverInstanceType.UNIVER_SHEET).subscribe(n=>{n&&e(n)})}};Me=Un([Be(0,l.Inject(t.ConditionalFormattingViewModel)),Be(1,l.IUniverInstanceService),Be(2,vt.IRenderManagerService)],Me);const ct=[O.SetWorksheetActiveOperation.id,t.AddConditionalRuleMutation.id,t.SetConditionalRuleMutation.id,t.DeleteConditionalRuleMutation.id,t.MoveConditionalRuleMutation.id],ce=[{label:{name:"sheet.cf.ruleType.highlightCell",selectable:!1},value:G.highlightCell},{label:{name:"sheet.cf.panel.rankAndAverage",selectable:!1},value:G.rank},{label:{name:"sheet.cf.ruleType.formula",selectable:!1},value:G.formula},{label:{name:"sheet.cf.ruleType.colorScale",selectable:!1},value:G.colorScale},{label:{name:"sheet.cf.ruleType.dataBar",selectable:!1},value:G.dataBar},{label:{name:"sheet.cf.ruleType.iconSet",selectable:!1},value:G.icon},{label:{name:"sheet.cf.menu.manageConditionalFormatting",selectable:!1},value:G.viewRule},{label:{name:"sheet.cf.menu.createConditionalFormatting",selectable:!1},value:G.createRule},{label:{name:"sheet.cf.menu.clearRangeRules",selectable:!1},value:G.clearRangeRules,disabled:!1},{label:{name:"sheet.cf.menu.clearWorkSheetRules",selectable:!1},value:G.clearWorkSheetRules}],kn=i=>{const e=i.get(O.SheetsSelectionsService),n=i.get(l.ICommandService),r=i.get(l.IUniverInstanceService),o=i.get(t.ConditionalFormattingRuleModel),s=new K.Observable(d=>K.merge(e.selectionMoveEnd$,e.selectionSet$,new K.Observable(h=>{const c=n.onCommandExecuted(v=>{var y;const{id:p,params:b}=v,S=(y=r.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET))==null?void 0:y.getUnitId();ct.includes(p)&&b.unitId===S&&h.next(null)});return()=>c.dispose()})).pipe(de.debounceTime(16)).subscribe(()=>{var y;const h=((y=e.getCurrentSelections())==null?void 0:y.map(_=>_.range))||[],c=r.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET);if(!c)return;const v=c.getActiveSheet();if(!v)return;const S=(o.getSubunitRules(c.getUnitId(),v.getSheetId())||[]).filter(_=>_.ranges.some(R=>h.some(w=>l.Rectangle.intersects(w,R)))).map(_=>_.ranges).every(_=>O.checkRangesEditablePermission(i,c.getUnitId(),v.getSheetId(),_));d.next(S)})),a=new K.Observable(d=>new K.Observable(h=>{const c=n.onCommandExecuted(v=>{var y;const{id:p,params:b}=v,S=(y=r.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET))==null?void 0:y.getUnitId();ct.includes(p)&&b.unitId===S&&h.next(null)});return()=>c.dispose()}).pipe(de.debounceTime(16)).subscribe(()=>{const h=r.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET);if(!h)return;const c=h.getActiveSheet();if(!c)return;const v=o.getSubunitRules(h.getUnitId(),c.getSheetId())||[];if(!v.length)return d.next(!1),!1;const p=v.map(b=>b.ranges).every(b=>O.checkRangesEditablePermission(i,h.getUnitId(),c.getSheetId(),b));d.next(p)})),m=new K.Observable(d=>{s.subscribe(h=>{const c=ce.find(v=>v.value===G.clearRangeRules);c&&(c.disabled=!h,d.next(ce))}),a.subscribe(h=>{const c=ce.find(v=>v.value===G.clearWorkSheetRules);c&&(c.disabled=!h,d.next(ce))}),d.next(ce)});return{id:be.id,type:D.MenuItemType.SELECTOR,icon:"ConditionsDoubleIcon",tooltip:"sheet.cf.title",selections:m,hidden$:D.getMenuHiddenObservable(i,l.UniverInstanceType.UNIVER_SHEET),disabled$:W.getCurrentRangeDisable$(i,{workbookTypes:[O.WorkbookEditablePermission],worksheetTypes:[O.WorksheetSetCellStylePermission,O.WorksheetEditPermission],rangeTypes:[O.RangeProtectionPermissionEditPoint]})}},Pn={[D.RibbonDataGroup.RULES]:{[be.id]:{order:1,menuItemFactory:kn}}};var Dn=Object.getOwnPropertyDescriptor,Ln=(i,e,n,r)=>{for(var o=r>1?void 0:r?Dn(e,n):e,s=i.length-1,a;s>=0;s--)(a=i[s])&&(o=a(o)||o);return o},dt=(i,e)=>(n,r)=>e(n,r,i);let Ve=class extends l.Disposable{constructor(e,n){super();z(this,"_sidebarDisposable",null);this._injector=e,this._menuManagerService=n,this._menuManagerService.mergeMenu(Pn)}};Ve=Ln([dt(0,l.Inject(l.Injector)),dt(1,D.IMenuManagerService)],Ve);var An=Object.defineProperty,$n=Object.getOwnPropertyDescriptor,Bn=(i,e,n)=>e in i?An(i,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):i[e]=n,Hn=(i,e,n,r)=>{for(var o=r>1?void 0:r?$n(e,n):e,s=i.length-1,a;s>=0;s--)(a=i[s])&&(o=a(o)||o);return o},He=(i,e)=>(n,r)=>e(n,r,i),ke=(i,e,n)=>Bn(i,typeof e!="symbol"?e+"":e,n);exports.UniverSheetsConditionalFormattingUIPlugin=class extends l.Plugin{constructor(e=we,n,r,o){super(),this._config=e,this._injector=n,this._commandService=r,this._configService=o;const{menu:s,...a}=l.merge({},we,this._config);s&&this._configService.setConfig("menu",s,{merge:!0}),this._configService.setConfig(xt,a),this._initCommand()}onStarting(){l.registerDependencies(this._injector,[[ge],[he],[Ne],[pe],[me],[Ve],[ie],[Ee],[exports.ConditionalFormattingClearController],[je],[Me],[ve]]),l.touchDependencies(this._injector,[[ge],[ve]])}onReady(){l.touchDependencies(this._injector,[[Ve],[me]])}onRendered(){l.touchDependencies(this._injector,[[Ne],[exports.ConditionalFormattingClearController],[he],[Ee],[ie],[je],[pe],[Me]])}_initCommand(){[qe,Ge,Ze,Ye,ze,Ke,Xe,Je,Qe,be].forEach(e=>{this._commandService.registerCommand(e)})}};ke(exports.UniverSheetsConditionalFormattingUIPlugin,"pluginName",`${t.SHEET_CONDITIONAL_FORMATTING_PLUGIN}_UI_PLUGIN`);ke(exports.UniverSheetsConditionalFormattingUIPlugin,"packageName",Oe.name);ke(exports.UniverSheetsConditionalFormattingUIPlugin,"version",Oe.version);ke(exports.UniverSheetsConditionalFormattingUIPlugin,"type",l.UniverInstanceType.UNIVER_SHEET);exports.UniverSheetsConditionalFormattingUIPlugin=Hn([l.DependentOn(t.UniverSheetsConditionalFormattingPlugin,mt.UniverSheetsFormulaPlugin),He(1,l.Inject(l.Injector)),He(2,l.Inject(l.ICommandService)),He(3,l.IConfigService)],exports.UniverSheetsConditionalFormattingUIPlugin);exports.AddAverageCfCommand=qe;exports.AddColorScaleConditionalRuleCommand=Ge;exports.AddDataBarConditionalRuleCommand=Ze;exports.AddDuplicateValuesCfCommand=Ye;exports.AddNumberCfCommand=ze;exports.AddRankCfCommand=Ke;exports.AddTextCfCommand=Xe;exports.AddTimePeriodCfCommand=Je;exports.AddUniqueValuesCfCommand=Qe;exports.OpenConditionalFormattingOperator=be;
package/lib/es/index.js CHANGED
@@ -1,10 +1,10 @@
1
1
  var nr = Object.defineProperty;
2
2
  var rr = (n, e, t) => e in n ? nr(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
3
3
  var ge = (n, e, t) => rr(n, typeof e != "symbol" ? e + "" : e, t);
4
- import { CommandType as he, ICommandService as Q, IUniverInstanceService as G, ColorKit as vn, BooleanNumber as ie, LocaleService as te, UniverInstanceType as H, Tools as _t, get as ir, set as or, createInterceptorKey as gn, InterceptorManager as sr, Inject as $, Disposable as se, Injector as ve, Rectangle as me, generateRandomId as ar, toDisposable as mn, ObjectMatrix as Re, Range as fe, InterceptorEffectEnum as lr, DependentOn as fn, Plugin as pn, merge as Cn, IConfigService as yn, registerDependencies as cr, touchDependencies as Vt } from "@univerjs/core";
4
+ import { CommandType as he, ICommandService as Q, IUniverInstanceService as G, ColorKit as vn, BooleanNumber as ie, LocaleService as te, UniverInstanceType as H, Tools as _t, get as ir, set as or, createInterceptorKey as gn, InterceptorManager as sr, Inject as $, Disposable as se, Injector as ve, Rectangle as me, generateRandomId as ar, toDisposable as mn, ObjectMatrix as Re, Range as fe, InterceptorEffectEnum as lr, DependentOn as fn, IConfigService as pn, Plugin as Cn, merge as yn, registerDependencies as cr, touchDependencies as Vt } from "@univerjs/core";
5
5
  import { getSheetCommandTarget as Ce, SheetsSelectionsService as $e, RemoveSheetMutation as ur, SetWorksheetActiveOperation as Bt, setEndForRange as dr, SetSelectionsOperation as hr, checkRangesEditablePermission as dt, SheetInterceptorService as Wt, ClearSelectionFormatCommand as vr, ClearSelectionAllCommand as gr, RangeMergeUtil as mr, rangeToDiscreteRange as fr, findAllRectangle as ht, createTopMatrixFromMatrix as vt, SheetPermissionCheckController as pr, WorksheetEditPermission as bn, WorksheetSetCellStylePermission as In, RangeProtectionPermissionEditPoint as Sn, WorkbookEditablePermission as _n, INTERCEPTOR_POINT as Cr, IAutoFillService as yr, AUTO_FILL_APPLY_TYPE as kt, AutoFillTools as br, AFTER_CELL_EDIT as Ir } from "@univerjs/sheets";
6
6
  import { ConditionalFormattingRuleModel as X, CFSubRuleType as k, CFRuleType as M, AddConditionalRuleMutation as ee, CFNumberOperator as O, getColorScaleFromValue as Sr, iconMap as Te, DEFAULT_BG_COLOR as _r, DEFAULT_FONT_COLOR as wr, defaultDataBarPositiveColor as qe, defaultDataBarNativeColor as Ge, CFValueType as P, createDefaultValueByValueType as Ze, removeUndefinedAttr as Rr, createDefaultValue as gt, CFTextOperator as j, CFTimePeriodOperator as de, iconGroup as Tr, getOppositeOperator as Ht, compareWithNumber as xr, EMPTY_ICON_TYPE as Er, SetCfCommand as Nr, AddCfCommand as wn, SetConditionalRuleMutation as be, DeleteConditionalRuleMutation as Ie, MoveConditionalRuleMutation as Rn, ClearWorksheetCfCommand as Tn, DeleteCfCommand as Yt, MoveCfCommand as Mr, ClearRangeCfCommand as Vr, createDefaultRule as _e, setConditionalRuleMutationUndoFactory as Le, DeleteConditionalRuleMutationUndoFactory as ze, createCfId as kr, AddConditionalRuleMutationUndoFactory as qt, ConditionalFormattingViewModel as et, SHEET_CONDITIONAL_FORMATTING_PLUGIN as tt, ConditionalFormattingService as xn, DEFAULT_PADDING as Fr, DEFAULT_WIDTH as Lr, UniverSheetsConditionalFormattingPlugin as En, CONDITIONAL_FORMATTING_VIEWPORT_CACHE_LENGTH as Pr } from "@univerjs/sheets-conditional-formatting";
7
- import { useDependency as q, useSidebarClick as wt, ILayoutService as Ur, useScrollYOverContainer as Or, useObservable as $r, ComponentManager as Dr, ISidebarService as Ar, MenuItemType as Hr, getMenuHiddenObservable as jr, RibbonDataGroup as Br, IMenuManagerService as Wr } from "@univerjs/ui";
7
+ import { useDependency as q, useSidebarClick as wt, ILayoutService as Ur, useScrollYOverContainer as Or, useObservable as $r, ComponentManager as Dr, ISidebarService as Ar, getMenuHiddenObservable as Hr, MenuItemType as jr, RibbonDataGroup as Br, IMenuManagerService as Wr } from "@univerjs/ui";
8
8
  import { jsx as c, jsxs as F, Fragment as jt } from "react/jsx-runtime";
9
9
  import { useRef as pe, createElement as ae, forwardRef as le, useMemo as K, useState as N, useEffect as J } from "react";
10
10
  import { Dropdown as Gt, clsx as Y, ColorPicker as qr, borderClassName as Ne, Select as oe, InputNumber as xe, RadioGroup as Gr, Radio as Kt, Checkbox as mt, Input as Zr, Button as Xt, Tooltip as Jt, DraggableList as zr } from "@univerjs/design";
@@ -2979,7 +2979,7 @@ function cn(n, e, t, r, i) {
2979
2979
  }
2980
2980
  }), { redos: o, undos: s };
2981
2981
  }
2982
- const Bi = "@univerjs/sheets-conditional-formatting-ui", Wi = "0.16.1-insiders.20260311-074e8ca", xt = {
2982
+ const Bi = "@univerjs/sheets-conditional-formatting-ui", Wi = "0.17.0", xt = {
2983
2983
  name: Bi,
2984
2984
  version: Wi
2985
2985
  }, Qn = "sheets-conditional-formatting-ui.config", pt = {};
@@ -3409,10 +3409,10 @@ var Qi = Object.defineProperty, eo = Object.getOwnPropertyDescriptor, to = (n, e
3409
3409
  (s = n[o]) && (i = s(i) || i);
3410
3410
  return i;
3411
3411
  }, $t = (n, e) => (t, r) => e(t, r, n), Et = (n, e, t) => to(n, typeof e != "symbol" ? e + "" : e, t);
3412
- let Ue = class extends pn {
3412
+ let Ue = class extends Cn {
3413
3413
  constructor(n = pt, e, t, r) {
3414
3414
  super(), this._config = n, this._injector = e, this._commandService = t, this._configService = r;
3415
- const { menu: i, ...o } = Cn(
3415
+ const { menu: i, ...o } = yn(
3416
3416
  {},
3417
3417
  pt,
3418
3418
  this._config
@@ -3444,7 +3444,7 @@ Ue = no([
3444
3444
  fn(En),
3445
3445
  $t(1, $(ve)),
3446
3446
  $t(2, $(Q)),
3447
- $t(3, yn)
3447
+ $t(3, pn)
3448
3448
  ], Ue);
3449
3449
  var ro = Object.getOwnPropertyDescriptor, io = (n, e, t, r) => {
3450
3450
  for (var i = r > 1 ? void 0 : r ? ro(e, t) : e, o = n.length - 1, s; o >= 0; o--)
@@ -4009,11 +4009,11 @@ const dn = [
4009
4009
  });
4010
4010
  return {
4011
4011
  id: Tt.id,
4012
- type: Hr.SELECTOR,
4012
+ type: jr.SELECTOR,
4013
4013
  icon: "ConditionsDoubleIcon",
4014
4014
  tooltip: "sheet.cf.title",
4015
4015
  selections: u,
4016
- hidden$: jr(n, H.UNIVER_SHEET),
4016
+ hidden$: Hr(n, H.UNIVER_SHEET),
4017
4017
  disabled$: ti(n, { workbookTypes: [_n], worksheetTypes: [In, bn], rangeTypes: [Sn] })
4018
4018
  };
4019
4019
  }, go = {
@@ -4045,10 +4045,10 @@ var po = Object.defineProperty, Co = Object.getOwnPropertyDescriptor, yo = (n, e
4045
4045
  (s = n[o]) && (i = s(i) || i);
4046
4046
  return i;
4047
4047
  }, At = (n, e) => (t, r) => e(t, r, n), Nt = (n, e, t) => yo(n, typeof e != "symbol" ? e + "" : e, t);
4048
- let Oe = class extends pn {
4048
+ let Oe = class extends Cn {
4049
4049
  constructor(n = pt, e, t, r) {
4050
4050
  super(), this._config = n, this._injector = e, this._commandService = t, this._configService = r;
4051
- const { menu: i, ...o } = Cn(
4051
+ const { menu: i, ...o } = yn(
4052
4052
  {},
4053
4053
  pt,
4054
4054
  this._config
@@ -4117,7 +4117,7 @@ Oe = bo([
4117
4117
  fn(En, ii),
4118
4118
  At(1, $(ve)),
4119
4119
  At(2, $(Q)),
4120
- At(3, yn)
4120
+ At(3, pn)
4121
4121
  ], Oe);
4122
4122
  export {
4123
4123
  Ln as AddAverageCfCommand,
package/lib/index.js CHANGED
@@ -1,10 +1,10 @@
1
1
  var nr = Object.defineProperty;
2
2
  var rr = (n, e, t) => e in n ? nr(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
3
3
  var ge = (n, e, t) => rr(n, typeof e != "symbol" ? e + "" : e, t);
4
- import { CommandType as he, ICommandService as Q, IUniverInstanceService as G, ColorKit as vn, BooleanNumber as ie, LocaleService as te, UniverInstanceType as H, Tools as _t, get as ir, set as or, createInterceptorKey as gn, InterceptorManager as sr, Inject as $, Disposable as se, Injector as ve, Rectangle as me, generateRandomId as ar, toDisposable as mn, ObjectMatrix as Re, Range as fe, InterceptorEffectEnum as lr, DependentOn as fn, Plugin as pn, merge as Cn, IConfigService as yn, registerDependencies as cr, touchDependencies as Vt } from "@univerjs/core";
4
+ import { CommandType as he, ICommandService as Q, IUniverInstanceService as G, ColorKit as vn, BooleanNumber as ie, LocaleService as te, UniverInstanceType as H, Tools as _t, get as ir, set as or, createInterceptorKey as gn, InterceptorManager as sr, Inject as $, Disposable as se, Injector as ve, Rectangle as me, generateRandomId as ar, toDisposable as mn, ObjectMatrix as Re, Range as fe, InterceptorEffectEnum as lr, DependentOn as fn, IConfigService as pn, Plugin as Cn, merge as yn, registerDependencies as cr, touchDependencies as Vt } from "@univerjs/core";
5
5
  import { getSheetCommandTarget as Ce, SheetsSelectionsService as $e, RemoveSheetMutation as ur, SetWorksheetActiveOperation as Bt, setEndForRange as dr, SetSelectionsOperation as hr, checkRangesEditablePermission as dt, SheetInterceptorService as Wt, ClearSelectionFormatCommand as vr, ClearSelectionAllCommand as gr, RangeMergeUtil as mr, rangeToDiscreteRange as fr, findAllRectangle as ht, createTopMatrixFromMatrix as vt, SheetPermissionCheckController as pr, WorksheetEditPermission as bn, WorksheetSetCellStylePermission as In, RangeProtectionPermissionEditPoint as Sn, WorkbookEditablePermission as _n, INTERCEPTOR_POINT as Cr, IAutoFillService as yr, AUTO_FILL_APPLY_TYPE as kt, AutoFillTools as br, AFTER_CELL_EDIT as Ir } from "@univerjs/sheets";
6
6
  import { ConditionalFormattingRuleModel as X, CFSubRuleType as k, CFRuleType as M, AddConditionalRuleMutation as ee, CFNumberOperator as O, getColorScaleFromValue as Sr, iconMap as Te, DEFAULT_BG_COLOR as _r, DEFAULT_FONT_COLOR as wr, defaultDataBarPositiveColor as qe, defaultDataBarNativeColor as Ge, CFValueType as P, createDefaultValueByValueType as Ze, removeUndefinedAttr as Rr, createDefaultValue as gt, CFTextOperator as j, CFTimePeriodOperator as de, iconGroup as Tr, getOppositeOperator as Ht, compareWithNumber as xr, EMPTY_ICON_TYPE as Er, SetCfCommand as Nr, AddCfCommand as wn, SetConditionalRuleMutation as be, DeleteConditionalRuleMutation as Ie, MoveConditionalRuleMutation as Rn, ClearWorksheetCfCommand as Tn, DeleteCfCommand as Yt, MoveCfCommand as Mr, ClearRangeCfCommand as Vr, createDefaultRule as _e, setConditionalRuleMutationUndoFactory as Le, DeleteConditionalRuleMutationUndoFactory as ze, createCfId as kr, AddConditionalRuleMutationUndoFactory as qt, ConditionalFormattingViewModel as et, SHEET_CONDITIONAL_FORMATTING_PLUGIN as tt, ConditionalFormattingService as xn, DEFAULT_PADDING as Fr, DEFAULT_WIDTH as Lr, UniverSheetsConditionalFormattingPlugin as En, CONDITIONAL_FORMATTING_VIEWPORT_CACHE_LENGTH as Pr } from "@univerjs/sheets-conditional-formatting";
7
- import { useDependency as q, useSidebarClick as wt, ILayoutService as Ur, useScrollYOverContainer as Or, useObservable as $r, ComponentManager as Dr, ISidebarService as Ar, MenuItemType as Hr, getMenuHiddenObservable as jr, RibbonDataGroup as Br, IMenuManagerService as Wr } from "@univerjs/ui";
7
+ import { useDependency as q, useSidebarClick as wt, ILayoutService as Ur, useScrollYOverContainer as Or, useObservable as $r, ComponentManager as Dr, ISidebarService as Ar, getMenuHiddenObservable as Hr, MenuItemType as jr, RibbonDataGroup as Br, IMenuManagerService as Wr } from "@univerjs/ui";
8
8
  import { jsx as c, jsxs as F, Fragment as jt } from "react/jsx-runtime";
9
9
  import { useRef as pe, createElement as ae, forwardRef as le, useMemo as K, useState as N, useEffect as J } from "react";
10
10
  import { Dropdown as Gt, clsx as Y, ColorPicker as qr, borderClassName as Ne, Select as oe, InputNumber as xe, RadioGroup as Gr, Radio as Kt, Checkbox as mt, Input as Zr, Button as Xt, Tooltip as Jt, DraggableList as zr } from "@univerjs/design";
@@ -2979,7 +2979,7 @@ function cn(n, e, t, r, i) {
2979
2979
  }
2980
2980
  }), { redos: o, undos: s };
2981
2981
  }
2982
- const Bi = "@univerjs/sheets-conditional-formatting-ui", Wi = "0.16.1-insiders.20260311-074e8ca", xt = {
2982
+ const Bi = "@univerjs/sheets-conditional-formatting-ui", Wi = "0.17.0", xt = {
2983
2983
  name: Bi,
2984
2984
  version: Wi
2985
2985
  }, Qn = "sheets-conditional-formatting-ui.config", pt = {};
@@ -3409,10 +3409,10 @@ var Qi = Object.defineProperty, eo = Object.getOwnPropertyDescriptor, to = (n, e
3409
3409
  (s = n[o]) && (i = s(i) || i);
3410
3410
  return i;
3411
3411
  }, $t = (n, e) => (t, r) => e(t, r, n), Et = (n, e, t) => to(n, typeof e != "symbol" ? e + "" : e, t);
3412
- let Ue = class extends pn {
3412
+ let Ue = class extends Cn {
3413
3413
  constructor(n = pt, e, t, r) {
3414
3414
  super(), this._config = n, this._injector = e, this._commandService = t, this._configService = r;
3415
- const { menu: i, ...o } = Cn(
3415
+ const { menu: i, ...o } = yn(
3416
3416
  {},
3417
3417
  pt,
3418
3418
  this._config
@@ -3444,7 +3444,7 @@ Ue = no([
3444
3444
  fn(En),
3445
3445
  $t(1, $(ve)),
3446
3446
  $t(2, $(Q)),
3447
- $t(3, yn)
3447
+ $t(3, pn)
3448
3448
  ], Ue);
3449
3449
  var ro = Object.getOwnPropertyDescriptor, io = (n, e, t, r) => {
3450
3450
  for (var i = r > 1 ? void 0 : r ? ro(e, t) : e, o = n.length - 1, s; o >= 0; o--)
@@ -4009,11 +4009,11 @@ const dn = [
4009
4009
  });
4010
4010
  return {
4011
4011
  id: Tt.id,
4012
- type: Hr.SELECTOR,
4012
+ type: jr.SELECTOR,
4013
4013
  icon: "ConditionsDoubleIcon",
4014
4014
  tooltip: "sheet.cf.title",
4015
4015
  selections: u,
4016
- hidden$: jr(n, H.UNIVER_SHEET),
4016
+ hidden$: Hr(n, H.UNIVER_SHEET),
4017
4017
  disabled$: ti(n, { workbookTypes: [_n], worksheetTypes: [In, bn], rangeTypes: [Sn] })
4018
4018
  };
4019
4019
  }, go = {
@@ -4045,10 +4045,10 @@ var po = Object.defineProperty, Co = Object.getOwnPropertyDescriptor, yo = (n, e
4045
4045
  (s = n[o]) && (i = s(i) || i);
4046
4046
  return i;
4047
4047
  }, At = (n, e) => (t, r) => e(t, r, n), Nt = (n, e, t) => yo(n, typeof e != "symbol" ? e + "" : e, t);
4048
- let Oe = class extends pn {
4048
+ let Oe = class extends Cn {
4049
4049
  constructor(n = pt, e, t, r) {
4050
4050
  super(), this._config = n, this._injector = e, this._commandService = t, this._configService = r;
4051
- const { menu: i, ...o } = Cn(
4051
+ const { menu: i, ...o } = yn(
4052
4052
  {},
4053
4053
  pt,
4054
4054
  this._config
@@ -4117,7 +4117,7 @@ Oe = bo([
4117
4117
  fn(En, ii),
4118
4118
  At(1, $(ve)),
4119
4119
  At(2, $(Q)),
4120
- At(3, yn)
4120
+ At(3, pn)
4121
4121
  ], Oe);
4122
4122
  export {
4123
4123
  Ln as AddAverageCfCommand,
package/lib/umd/index.js CHANGED
@@ -1,3 +1,3 @@
1
1
  (function(P,s){typeof exports=="object"&&typeof module<"u"?s(exports,require("@univerjs/core"),require("@univerjs/sheets"),require("@univerjs/sheets-conditional-formatting"),require("@univerjs/ui"),require("react/jsx-runtime"),require("react"),require("@univerjs/design"),require("@univerjs/engine-formula"),require("@univerjs/sheets-formula-ui"),require("@univerjs/sheets-ui"),require("rxjs"),require("@univerjs/sheets-formula"),require("@univerjs/engine-render"),require("rxjs/operators")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/sheets","@univerjs/sheets-conditional-formatting","@univerjs/ui","react/jsx-runtime","react","@univerjs/design","@univerjs/engine-formula","@univerjs/sheets-formula-ui","@univerjs/sheets-ui","rxjs","@univerjs/sheets-formula","@univerjs/engine-render","rxjs/operators"],s):(P=typeof globalThis<"u"?globalThis:P||self,s(P.UniverSheetsConditionalFormattingUi={},P.UniverCore,P.UniverSheets,P.UniverSheetsConditionalFormatting,P.UniverUi,P.React,P.React,P.UniverDesign,P.UniverEngineFormula,P.UniverSheetsFormulaUi,P.UniverSheetsUi,P.rxjs,P.UniverSheetsFormula,P.UniverEngineRender,P.rxjs.operators))})(this,(function(P,s,O,r,A,c,C,V,je,ie,q,K,nr,lr,se){"use strict";var Ft=Object.defineProperty;var $t=(P,s,O)=>s in P?Ft(P,s,{enumerable:!0,configurable:!0,writable:!0,value:O}):P[s]=O;var X=(P,s,O)=>$t(P,typeof s!="symbol"?s+"":s,O);const Ae={type:s.CommandType.COMMAND,id:"sheet.command.add-average-conditional-rule",handler(a,e){if(!e)return!1;const{ranges:t,style:n,stopIfTrue:l,operator:u}=e,i=a.get(r.ConditionalFormattingRuleModel),v=a.get(s.ICommandService),d=a.get(s.IUniverInstanceService),f=O.getSheetCommandTarget(d);if(!f)return!1;const{unitId:o,subUnitId:p}=f,h=i.createCfId(o,p),b={ranges:t,cfId:h,stopIfTrue:!!l,rule:{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.average,operator:u,style:n}};return v.executeCommand(r.AddConditionalRuleMutation.id,{unitId:o,subUnitId:p,rule:b})}},Fe={type:s.CommandType.COMMAND,id:"sheet.command.add-color-scale-conditional-rule",handler(a,e){if(!e)return!1;const{ranges:t,config:n,stopIfTrue:l}=e,u=a.get(r.ConditionalFormattingRuleModel),i=a.get(s.ICommandService),v=a.get(s.IUniverInstanceService),d=O.getSheetCommandTarget(v);if(!d)return!1;const{unitId:f,subUnitId:o}=d,p=u.createCfId(f,o),h={ranges:t,cfId:p,stopIfTrue:!!l,rule:{type:r.CFRuleType.colorScale,config:n}};return i.executeCommand(r.AddConditionalRuleMutation.id,{unitId:f,subUnitId:o,rule:h})}},$e={type:s.CommandType.COMMAND,id:"sheet.command.add-data-bar-conditional-rule",handler(a,e){if(!e)return!1;const{ranges:t,min:n,max:l,nativeColor:u,positiveColor:i,isGradient:v,stopIfTrue:d,isShowValue:f}=e,o=a.get(r.ConditionalFormattingRuleModel),p=a.get(s.IUniverInstanceService),h=O.getSheetCommandTarget(p);if(!h)return!1;const{unitId:b,subUnitId:S}=h,m=a.get(s.ICommandService),N=o.createCfId(b,S),w={ranges:t,cfId:N,stopIfTrue:!!d,rule:{type:r.CFRuleType.dataBar,isShowValue:f,config:{min:n,max:l,nativeColor:u,positiveColor:i,isGradient:v}}};return m.executeCommand(r.AddConditionalRuleMutation.id,{unitId:b,subUnitId:S,rule:w})}},Be={type:s.CommandType.COMMAND,id:"sheet.command.add-duplicate-values-conditional-rule",handler(a,e){if(!e)return!1;const{ranges:t,style:n,stopIfTrue:l}=e,u=a.get(r.ConditionalFormattingRuleModel),i=a.get(s.ICommandService),v=a.get(s.IUniverInstanceService),d=O.getSheetCommandTarget(v);if(!d)return!1;const{unitId:f,subUnitId:o}=d,p=u.createCfId(f,o),h={ranges:t,cfId:p,stopIfTrue:!!l,rule:{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.duplicateValues,style:n}};return i.executeCommand(r.AddConditionalRuleMutation.id,{unitId:f,subUnitId:o,rule:h})}},He={type:s.CommandType.COMMAND,id:"sheet.command.add-number-conditional-rule",handler(a,e){if(!e)return!1;const{ranges:t,style:n,stopIfTrue:l,operator:u,value:i}=e,v=a.get(r.ConditionalFormattingRuleModel),d=a.get(s.ICommandService),f=a.get(s.IUniverInstanceService),o=O.getSheetCommandTarget(f);if(!o)return!1;const{unitId:p,subUnitId:h}=o,b=v.createCfId(p,h);let S;if([r.CFNumberOperator.between,r.CFNumberOperator.notBetween].includes(u)){const m=i;if(m.length!==2||!Array.isArray(m))return!1;S={ranges:t,cfId:b,stopIfTrue:!!l,rule:{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.number,operator:u,style:n,value:m}}}else{const m=i;if(typeof m!="number")return!1;S={ranges:t,cfId:b,stopIfTrue:!!l,rule:{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.number,operator:u,style:n,value:m}}}return d.executeCommand(r.AddConditionalRuleMutation.id,{unitId:p,subUnitId:h,rule:S})}},We={type:s.CommandType.COMMAND,id:"sheet.command.add-rank-conditional-rule",handler(a,e){if(!e)return!1;const{ranges:t,style:n,stopIfTrue:l,isPercent:u,isBottom:i,value:v}=e,d=a.get(r.ConditionalFormattingRuleModel),f=a.get(s.IUniverInstanceService),o=a.get(s.ICommandService),p=O.getSheetCommandTarget(f);if(!p)return!1;const{unitId:h,subUnitId:b}=p,S=d.createCfId(h,b),m={ranges:t,cfId:S,stopIfTrue:!!l,rule:{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.rank,isPercent:u,isBottom:i,style:n,value:v}};return o.executeCommand(r.AddConditionalRuleMutation.id,{unitId:h,subUnitId:b,rule:m})}},qe={type:s.CommandType.COMMAND,id:"sheet.command.add-text-conditional-rule",handler(a,e){if(!e)return!1;const{ranges:t,style:n,stopIfTrue:l,operator:u,value:i}=e,v=a.get(r.ConditionalFormattingRuleModel),d=a.get(s.IUniverInstanceService),f=O.getSheetCommandTarget(d);if(!f)return!1;const{unitId:o,subUnitId:p}=f,h=a.get(s.ICommandService),b=v.createCfId(o,p),S={ranges:t,cfId:b,stopIfTrue:!!l,rule:{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.text,operator:u,style:n,value:i}};return h.executeCommand(r.AddConditionalRuleMutation.id,{unitId:o,subUnitId:p,rule:S})}},Ge={type:s.CommandType.COMMAND,id:"sheet.command.add-time-period-conditional-rule",handler(a,e){if(!e)return!1;const{ranges:t,style:n,stopIfTrue:l,operator:u}=e,i=a.get(r.ConditionalFormattingRuleModel),v=a.get(s.IUniverInstanceService),d=a.get(s.ICommandService),f=O.getSheetCommandTarget(v);if(!f)return!1;const{unitId:o,subUnitId:p}=f,h=i.createCfId(o,p),b={ranges:t,cfId:h,stopIfTrue:!!l,rule:{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.timePeriod,operator:u,style:n}};return d.executeCommand(r.AddConditionalRuleMutation.id,{unitId:o,subUnitId:p,rule:b})}},Ze={type:s.CommandType.COMMAND,id:"sheet.command.add-uniqueValues-conditional-rule",handler(a,e){if(!e)return!1;const{ranges:t,style:n,stopIfTrue:l}=e,u=a.get(r.ConditionalFormattingRuleModel),i=a.get(s.IUniverInstanceService),v=a.get(s.ICommandService),d=O.getSheetCommandTarget(i);if(!d)return!1;const{unitId:f,subUnitId:o}=d,p=u.createCfId(f,o),h={ranges:t,cfId:p,stopIfTrue:!!l,rule:{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.uniqueValues,style:n}};return v.executeCommand(r.AddConditionalRuleMutation.id,{unitId:f,subUnitId:o,rule:h})}};function Y({ref:a,...e}){const{icon:t,id:n,className:l,extend:u,...i}=e,v=`univerjs-icon univerjs-icon-${n} ${l||""}`.trim(),d=C.useRef(`_${Er()}`);return ar(t,`${n}`,{defIds:t.defIds,idSuffix:d.current},{ref:a,className:v,...i},u)}function ar(a,e,t,n,l){return C.createElement(a.tag,{key:e,...xr(a,t,l),...n},(Nr(a,t).children||[]).map((u,i)=>ar(u,`${e}-${a.tag}-${i}`,t,void 0,l)))}function xr(a,e,t){const n={...a.attrs};t!=null&&t.colorChannel1&&n.fill==="colorChannel1"&&(n.fill=t.colorChannel1),a.tag==="mask"&&n.id&&(n.id=n.id+e.idSuffix),Object.entries(n).forEach(([u,i])=>{u==="mask"&&typeof i=="string"&&(n[u]=i.replace(/url\(#(.*)\)/,`url(#$1${e.idSuffix})`))});const{defIds:l}=e;return!l||l.length===0||(a.tag==="use"&&n["xlink:href"]&&(n["xlink:href"]=n["xlink:href"]+e.idSuffix),Object.entries(n).forEach(([u,i])=>{typeof i=="string"&&(n[u]=i.replace(/url\(#(.*)\)/,`url(#$1${e.idSuffix})`))})),n}function Nr(a,e){var n;const{defIds:t}=e;return!t||t.length===0?a:a.tag==="defs"&&((n=a.children)!=null&&n.length)?{...a,children:a.children.map(l=>typeof l.attrs.id=="string"&&t&&t.includes(l.attrs.id)?{...l,attrs:{...l.attrs,id:l.attrs.id+e.idSuffix}}:l)}:a}function Er(){return Math.random().toString(36).substring(2,8)}Y.displayName="UniverIcon";const Rr={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M4.65791 1.30005C3.77355 1.30005 3.05664 2.01696 3.05664 2.90132V12.8588C3.05664 13.8755 3.88086 14.6998 4.89759 14.6998H9.1016C11.2233 14.6998 12.9433 12.9798 12.9433 10.8581C12.9433 9.13925 11.8145 7.68407 10.2578 7.1934C10.8806 6.56856 11.2655 5.70659 11.2655 4.75472C11.2655 2.84676 9.71883 1.30005 7.81087 1.30005H4.65791ZM4.25664 2.90132C4.25664 2.6797 4.4363 2.50005 4.65791 2.50005H7.81087C9.05609 2.50005 10.0655 3.5095 10.0655 4.75472C10.0655 5.99993 9.05609 7.00938 7.81087 7.00938H4.25664V2.90132ZM4.25664 12.8588V8.21636H9.1016C10.5606 8.21636 11.7433 9.39909 11.7433 10.8581C11.7433 12.317 10.5606 13.4998 9.1016 13.4998H4.89759C4.5436 13.4998 4.25664 13.2128 4.25664 12.8588Z",fillRule:"evenodd",clipRule:"evenodd"}}]},ur=C.forwardRef(function(e,t){return C.createElement(Y,Object.assign({},e,{id:"bold-icon",ref:t,icon:Rr}))});ur.displayName="BoldIcon";const Mr={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M5.3313 1.4667C5.3313 1.13533 5.59993 0.866699 5.9313 0.866699H10.069C10.4004 0.866699 10.669 1.13533 10.669 1.4667C10.669 1.79807 10.4004 2.0667 10.069 2.0667H5.9313C5.59993 2.0667 5.3313 1.79807 5.3313 1.4667Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M1.09985 3.64443C1.09985 3.31306 1.36848 3.04443 1.69985 3.04443H14.2999C14.6312 3.04443 14.8999 3.31306 14.8999 3.64443C14.8999 3.9758 14.6312 4.24443 14.2999 4.24443H1.69985C1.36848 4.24443 1.09985 3.9758 1.09985 3.64443Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M6.12398 8.30171C6.35829 8.0674 6.73819 8.0674 6.97251 8.30171L8.00007 9.32928L9.02764 8.30171C9.26195 8.0674 9.64185 8.0674 9.87617 8.30171C10.1105 8.53603 10.1105 8.91593 9.87617 9.15024L8.8486 10.1778L9.87617 11.2054C10.1105 11.4397 10.1105 11.8196 9.87617 12.0539C9.64185 12.2882 9.26195 12.2882 9.02764 12.0539L8.00007 11.0263L6.97251 12.0539C6.73819 12.2882 6.35829 12.2882 6.12398 12.0539C5.88966 11.8196 5.88966 11.4397 6.12398 11.2054L7.15154 10.1778L6.12398 9.15024C5.88966 8.91593 5.88966 8.53603 6.12398 8.30171Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M4.75332 5.22217C3.86966 5.22217 3.15332 5.93851 3.15332 6.82217V12.5331C3.15332 13.9691 4.31738 15.1332 5.75332 15.1332H10.2465C11.6825 15.1332 12.8465 13.9691 12.8465 12.5331V6.82217C12.8465 5.93851 12.1302 5.22217 11.2465 5.22217H4.75332ZM4.35332 6.82217C4.35332 6.60125 4.53241 6.42217 4.75332 6.42217H11.2465C11.4674 6.42217 11.6465 6.60125 11.6465 6.82217V12.5331C11.6465 13.3063 11.0197 13.9332 10.2465 13.9332H5.75332C4.98012 13.9332 4.35332 13.3063 4.35332 12.5331V6.82217Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Se=C.forwardRef(function(e,t){return C.createElement(Y,Object.assign({},e,{id:"delete-icon",ref:t,icon:Mr}))});Se.displayName="DeleteIcon";const Vr={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M8.6 1.99991C8.60001 1.66854 8.33138 1.39991 8.00001 1.3999C7.66864 1.3999 7.40001 1.66853 7.4 1.9999L7.39996 7.3999H1.9999C1.66853 7.3999 1.3999 7.66853 1.3999 7.9999C1.3999 8.33127 1.66853 8.5999 1.9999 8.5999H7.39995L7.3999 13.9999C7.3999 14.3313 7.66853 14.5999 7.9999 14.5999C8.33127 14.5999 8.5999 14.3313 8.5999 13.9999L8.59995 8.5999H13.9999C14.3313 8.5999 14.5999 8.33127 14.5999 7.9999C14.5999 7.66853 14.3313 7.3999 13.9999 7.3999H8.59996L8.6 1.99991Z"}}]},ir=C.forwardRef(function(e,t){return C.createElement(Y,Object.assign({},e,{id:"increase-icon",ref:t,icon:Vr}))});ir.displayName="IncreaseIcon";const Or={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M9.80385 1.40005H11.9997C12.3311 1.40005 12.5997 1.66868 12.5997 2.00005C12.5997 2.33143 12.3311 2.60005 11.9997 2.60005H10.1185L7.12251 13.4001H9.33324C9.66461 13.4001 9.93324 13.6687 9.93324 14.0001C9.93324 14.3314 9.66461 14.6001 9.33324 14.6001H6.34785C6.33847 14.6003 6.32905 14.6003 6.31962 14.6001H3.9999C3.66853 14.6001 3.3999 14.3314 3.3999 14.0001C3.3999 13.6687 3.66853 13.4001 3.9999 13.4001H5.87719L8.87322 2.60005H6.66641C6.33504 2.60005 6.06641 2.33143 6.06641 2.00005C6.06641 1.66868 6.33504 1.40005 6.66641 1.40005H9.52916C9.61698 1.37929 9.71064 1.3781 9.80385 1.40005Z"}}]},sr=C.forwardRef(function(e,t){return C.createElement(Y,Object.assign({},e,{id:"italic-icon",ref:t,icon:Or}))});sr.displayName="ItalicIcon";const Ur={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M11.3536 6.14645C11.5488 6.34171 11.5488 6.65829 11.3536 6.85355L8.35355 9.85355C8.15829 10.0488 7.84171 10.0488 7.64645 9.85355L4.64645 6.85355C4.45118 6.65829 4.45118 6.34171 4.64645 6.14645C4.84171 5.95118 5.15829 5.95118 5.35355 6.14645L8 8.79289L10.6464 6.14645C10.8417 5.95118 11.1583 5.95118 11.3536 6.14645Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Ye=C.forwardRef(function(e,t){return C.createElement(Y,Object.assign({},e,{id:"more-down-icon",ref:t,icon:Ur}))});Ye.displayName="MoreDownIcon";const kr={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M6 5C6.55228 5 7 4.55228 7 4C7 3.44772 6.55228 3 6 3C5.44772 3 5 3.44772 5 4C5 4.55228 5.44772 5 6 5Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M6 9C6.55228 9 7 8.55229 7 8C7 7.44772 6.55228 7 6 7C5.44772 7 5 7.44772 5 8C5 8.55229 5.44772 9 6 9Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M7 12C7 12.5523 6.55228 13 6 13C5.44772 13 5 12.5523 5 12C5 11.4477 5.44772 11 6 11C6.55228 11 7 11.4477 7 12Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M10 5C10.5523 5 11 4.55228 11 4C11 3.44772 10.5523 3 10 3C9.44771 3 9 3.44772 9 4C9 4.55228 9.44771 5 10 5Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M11 8C11 8.55229 10.5523 9 10 9C9.44771 9 9 8.55229 9 8C9 7.44772 9.44771 7 10 7C10.5523 7 11 7.44772 11 8Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M10 13C10.5523 13 11 12.5523 11 12C11 11.4477 10.5523 11 10 11C9.44771 11 9 11.4477 9 12C9 12.5523 9.44771 13 10 13Z"}}]},cr=C.forwardRef(function(e,t){return C.createElement(Y,Object.assign({},e,{id:"sequence-icon",ref:t,icon:kr}))});cr.displayName="SequenceIcon";const Pr={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M8.00033 1.20996C6.43345 1.20996 5.23596 1.88077 4.64804 2.94304C4.06338 3.99943 4.15123 5.32084 4.90099 6.47062C5.08199 6.7482 5.45374 6.82648 5.73131 6.64548C6.00888 6.46448 6.08716 6.09273 5.90616 5.81516C5.36418 4.98402 5.35768 4.13897 5.69797 3.52412C6.035 2.91515 6.78176 2.40996 8.00033 2.40996C9.19423 2.40996 10.0017 2.93409 10.5236 3.46755C10.7871 3.73682 10.9756 4.00712 11.0974 4.20903C11.158 4.30951 11.2013 4.39164 11.2284 4.44625C11.2419 4.47351 11.2514 4.49377 11.2568 4.50588L11.2621 4.51771C11.3901 4.82216 11.7407 4.96686 12.046 4.83992C12.3519 4.71267 12.4968 4.36149 12.3695 4.05552L11.8231 4.28278C12.3695 4.05552 12.3697 4.0558 12.3695 4.05552L12.3691 4.05437L12.3685 4.05298L12.367 4.04953L12.3629 4.03993L12.3498 4.01036C12.3388 3.98619 12.3234 3.95326 12.3033 3.91282C12.2632 3.83203 12.2043 3.72072 12.1249 3.58908C11.9666 3.32674 11.7235 2.97805 11.3814 2.62834C10.6921 1.92381 9.59192 1.20996 8.00033 1.20996Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M2.11953 8.5999H7.88935C10.1109 9.46549 10.5895 10.7649 10.4268 11.6869C10.2475 12.703 9.26939 13.5898 8.00009 13.5898C6.63323 13.5898 5.77631 13.0502 5.25534 12.528C4.99021 12.2623 4.80823 11.9965 4.69365 11.7993C4.63659 11.7011 4.59698 11.6211 4.5727 11.5686C4.56059 11.5424 4.55236 11.5231 4.54774 11.512L4.54352 11.5016C4.4267 11.193 4.0823 11.0363 3.77279 11.1516C3.46228 11.2673 3.30438 11.6129 3.4201 11.9234L3.9649 11.7203C3.4201 11.9234 3.41998 11.9231 3.4201 11.9234L3.4206 11.9247L3.42118 11.9263L3.42262 11.9301L3.42661 11.9403C3.42977 11.9484 3.43394 11.9588 3.43914 11.9713C3.44956 11.9965 3.46418 12.0304 3.48334 12.0719C3.52161 12.1547 3.57828 12.2682 3.65608 12.4021C3.81124 12.6692 4.0534 13.0223 4.40584 13.3756C5.12 14.0914 6.27196 14.7898 8.00009 14.7898C9.82574 14.7898 11.3236 13.5101 11.6085 11.8955C11.812 10.7422 11.3901 9.55402 10.2665 8.5999H13.8804C14.2117 8.5999 14.4803 8.33127 14.4803 7.9999C14.4803 7.66853 14.2117 7.3999 13.8804 7.3999H8.01411C8.0048 7.39968 7.99551 7.39969 7.98625 7.3999H2.11953C1.78816 7.3999 1.51953 7.66853 1.51953 7.9999C1.51953 8.33127 1.78816 8.5999 2.11953 8.5999Z"}}]},or=C.forwardRef(function(e,t){return C.createElement(Y,Object.assign({},e,{id:"strikethrough-icon",ref:t,icon:Pr}))});or.displayName="StrikethroughIcon";const Dr={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M4.46416 2.03237C4.46416 1.701 4.19553 1.43237 3.86416 1.43237C3.53279 1.43237 3.26416 1.701 3.26416 2.03237V7.33338C3.26416 10.0313 5.35834 12.2667 7.9999 12.2667C10.6415 12.2667 12.7356 10.0313 12.7356 7.33338V2.03237C12.7356 1.701 12.467 1.43237 12.1356 1.43237C11.8043 1.43237 11.5356 1.701 11.5356 2.03237V7.33338C11.5356 9.42194 9.92656 11.0667 7.9999 11.0667C6.07325 11.0667 4.46416 9.42194 4.46416 7.33338V2.03237Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M2.66641 13.4663C2.33504 13.4663 2.06641 13.7349 2.06641 14.0663C2.06641 14.3977 2.33504 14.6663 2.66641 14.6663H13.3331C13.6644 14.6663 13.9331 14.3977 13.9331 14.0663C13.9331 13.7349 13.6644 13.4663 13.3331 13.4663H2.66641Z"}}]},dr=C.forwardRef(function(e,t){return C.createElement(Y,Object.assign({},e,{id:"underline-icon",ref:t,icon:Dr}))});dr.displayName="UnderlineIcon";const Lr={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:"colorChannel1",d:"M1.98682 13.4992C1.98682 12.5603 2.74793 11.7992 3.68682 11.7992H14.2868C15.2257 11.7992 15.9868 12.5603 15.9868 13.4992V13.4992C15.9868 14.4381 15.2257 15.1992 14.2868 15.1992H3.68682C2.74793 15.1992 1.98682 14.4381 1.98682 13.4992V13.4992Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M10.3014 1.70389C9.85268 0.479568 8.12109 0.479557 7.67238 1.70389L4.72235 9.75326C4.60832 10.0644 4.76811 10.4091 5.07924 10.5231C5.39038 10.6371 5.73504 10.4773 5.84907 10.1662L6.99975 7.02646C7.03588 7.03324 7.07314 7.03679 7.11123 7.03679H10.9778L12.1247 10.1662C12.2387 10.4773 12.5834 10.6371 12.8945 10.5231C13.2057 10.4091 13.3654 10.0644 13.2514 9.75326L10.3014 1.70389ZM10.538 5.83679L9.17467 2.11682C9.11057 1.94192 8.8632 1.94192 8.7991 2.11682L7.43576 5.83679H10.538Z",fillRule:"evenodd",clipRule:"evenodd"}}]},vr=C.forwardRef(function(e,t){return C.createElement(Y,Object.assign({},e,{id:"font-color-double-icon",ref:t,icon:Lr}))});vr.displayName="FontColorDoubleIcon";const jr={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:"M8.01281 1.36643C8.79386 0.585377 10.0602 0.585378 10.8412 1.36643L12.9223 3.44752C13.7034 4.22857 13.7034 5.4949 12.9223 6.27595L9.36445 9.83383C8.5834 10.6149 7.31707 10.6149 6.53602 9.83383L4.45493 7.75273C3.67388 6.97168 3.67388 5.70535 4.45493 4.9243L8.01281 1.36643ZM9.9927 2.21495C9.68028 1.90253 9.17375 1.90253 8.86133 2.21495L5.30346 5.77283L5.29671 5.77966L10.839 6.66224L12.0738 5.42742C12.3862 5.115 12.3862 4.60847 12.0738 4.29605L9.9927 2.21495Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M14.5179 9.48875C14.5179 9.99175 14.1101 10.3995 13.607 10.3995C13.1041 10.3995 12.6963 9.99175 12.6963 9.48875C12.6963 9.1773 13.0455 8.59966 13.3114 8.20487C13.4549 7.99177 13.7591 7.99177 13.9027 8.20486C14.1687 8.59965 14.5179 9.1773 14.5179 9.48875Z"}},{tag:"path",attrs:{fill:"colorChannel1",d:"M1.98682 13.4992C1.98682 12.5603 2.74793 11.7992 3.68682 11.7992H14.2868C15.2257 11.7992 15.9868 12.5603 15.9868 13.4992V13.4992C15.9868 14.4381 15.2257 15.1992 14.2868 15.1992H3.68682C2.74793 15.1992 1.98682 14.4381 1.98682 13.4992V13.4992Z"}}]},pr=C.forwardRef(function(e,t){return C.createElement(Y,Object.assign({},e,{id:"paint-bucket-double-icon",ref:t,icon:jr}))});pr.displayName="PaintBucketDoubleIcon";const Ar={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M2.27177 13.714L13.5855 2.40025L14.434 3.24878L3.1203 14.5625L2.27177 13.714Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"colorChannel1",d:"M4.2603 1.82495L2.89617 1.82495C2.23343 1.82495 1.69617 2.36221 1.69617 3.02495L1.69617 4.38908L3.02617 4.38908L3.02617 3.15495L4.2603 3.15495L4.2603 1.82495ZM15.0092 4.38908L15.0092 3.02495C15.0092 2.36221 14.4719 1.82495 13.8092 1.82495L12.4451 1.82495L12.4451 3.15495L13.6792 3.15495L13.6792 4.38908L15.0092 4.38908ZM6.98856 1.82495L6.98856 3.15495L9.71681 3.15495L9.71681 1.82495L6.98856 1.82495ZM15.0092 7.11734L13.6792 7.11734L13.6792 9.84559L15.0092 9.84559L15.0092 7.11734ZM15.0092 12.5739L13.6792 12.5739L13.6792 13.808L12.4451 13.808L12.4451 15.138L13.8092 15.138C14.4719 15.138 15.0092 14.6007 15.0092 13.938L15.0092 12.5739ZM9.71681 15.138L9.71681 13.808L6.98856 13.808L6.98856 15.138L9.71681 15.138ZM4.2603 15.138L4.2603 13.808L3.02617 13.808L3.02617 12.5739L1.69617 12.5739L1.69617 13.938C1.69617 14.6007 2.23343 15.138 2.89617 15.138L4.2603 15.138ZM1.69617 9.8456L3.02617 9.8456L3.02617 7.11734L1.69617 7.11734L1.69617 9.8456Z",fillRule:"evenodd",clipRule:"evenodd"}}]},ce=C.forwardRef(function(e,t){return C.createElement(Y,Object.assign({},e,{id:"slash-double-icon",ref:t,icon:Ar}))});ce.displayName="SlashDoubleIcon";const Q=a=>{const{color:e,onChange:t,disable:n=!1,Icon:l=pr,className:u}=a,i=C.useMemo(()=>new s.ColorKit(e),[e]),v=()=>{const d={className:V.clsx("univer-fill-primary-600",n&&u),extend:{colorChannel1:i.isValid?e:""}};return c.jsx(l,{...d})};return n?v():c.jsx(V.Dropdown,{overlay:c.jsx("div",{className:"univer-rounded-lg univer-p-4",children:c.jsx(V.ColorPicker,{value:e,onChange:t})}),children:c.jsx("span",{className:V.clsx("univer-flex univer-cursor-pointer univer-items-center univer-rounded univer-p-1 hover:univer-bg-gray-100 dark:hover:!univer-bg-gray-700",u),children:v()})})},te=a=>{var u,i,v,d,f;const e=a.rule;if(!e)return null;const t=C.useMemo(()=>{if(e.type===r.CFRuleType.colorScale){const o=e.config.map((b,S)=>({color:new s.ColorKit(b.color),value:S})),p=o.length-1;return new Array(5).fill("").map((b,S,m)=>S*p/(m.length-1)).map(b=>r.getColorScaleFromValue(o,b))}return null},[e]),n=C.useMemo(()=>{if(e.type===r.CFRuleType.iconSet)return e.config.map(o=>{const p=r.iconMap[o.iconType];return p&&p[Number(o.iconId)]})},[e]),l="univer-pointer-events-none univer-flex univer-h-5 univer-min-w-[72px] univer-items-center univer-justify-center univer-text-xs";switch(e.type){case r.CFRuleType.dataBar:{const{isGradient:o}=e.config,p=o?`linear-gradient(to right, ${e.config.positiveColor||r.defaultDataBarPositiveColor}, rgb(255 255 255))`:e.config.positiveColor,h=o?`linear-gradient(to right, rgb(255 255 255),${e.config.nativeColor||r.defaultDataBarNativeColor})`:e.config.nativeColor;return c.jsxs("div",{className:l,children:[c.jsx("div",{className:"univer-h-full univer-w-1/2 univer-border univer-border-solid",style:{background:h,borderColor:(u=e.config.nativeColor)!=null?u:r.defaultDataBarNativeColor}}),c.jsx("div",{className:"univer-h-full univer-w-1/2 univer-border univer-border-solid",style:{background:p,borderColor:(i=e.config.positiveColor)!=null?i:r.defaultDataBarPositiveColor}})]})}case r.CFRuleType.colorScale:return t&&c.jsx("div",{className:l,children:t.map((o,p)=>c.jsx("div",{className:"univer-h-full",style:{width:`${100/t.length}%`,background:o}},p))});case r.CFRuleType.iconSet:return n&&c.jsx("div",{className:l,children:n.map((o,p)=>o?c.jsx("img",{className:"univer-h-full",src:o,draggable:!1},p):c.jsx(ce,{},p))});case r.CFRuleType.highlightCell:{const{ul:o,st:p,it:h,bl:b,bg:S,cl:m}=e.style,N=(o==null?void 0:o.s)===s.BooleanNumber.TRUE,w=(p==null?void 0:p.s)===s.BooleanNumber.TRUE,E=h===s.BooleanNumber.TRUE,M=b===s.BooleanNumber.TRUE,R=(v=S==null?void 0:S.rgb)!=null?v:r.DEFAULT_BG_COLOR,g=(d=m==null?void 0:m.rgb)!=null?d:r.DEFAULT_FONT_COLOR,T={textDecoration:(f=`${N?"underline":""} ${w?"line-through":""}`.replace(/^ /,""))!=null?f:void 0,backgroundColor:R,color:g};return c.jsx("div",{className:V.clsx(l,{"univer-font-bold":M,"univer-italic":E}),style:T,children:"123"})}}},oe=V.clsx("univer-mt-5 univer-px-1 univer-py-2 univer-rounded",V.borderClassName),ee=(a,e)=>({label:e.t(`sheet.cf.valueType.${a}`),value:a}),ze=a=>{var S;const{type:e,className:t,onChange:n,id:l,value:u}=a,i=A.useDependency(s.IUniverInstanceService),v=i.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET).getUnitId(),d=(S=i.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:S.getSheetId(),f=C.useMemo(()=>String(u).startsWith("=")?String(u):"=",[u]),o=C.useMemo(()=>[r.CFValueType.max,r.CFValueType.min,"none"].includes(e)?{disabled:!0}:[r.CFValueType.percent,r.CFValueType.percentile].includes(e)?{min:0,max:100}:{min:Number.MIN_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER},[e]),p=C.useRef(null),[h,b]=C.useState(!1);return A.useSidebarClick(m=>{var w;(w=p.current)!=null&&w.isClickOutSide(m)&&b(!1)}),e===r.CFValueType.formula?c.jsx("div",{className:"univer-ml-1 univer-w-full",children:c.jsx(ie.FormulaEditor,{ref:p,className:V.clsx("univer-box-border univer-h-8 univer-w-full univer-cursor-pointer univer-items-center univer-rounded-lg univer-bg-white univer-pt-2 univer-transition-colors hover:univer-border-primary-600 dark:!univer-bg-gray-700 dark:!univer-text-white [&>div:first-child]:univer-px-2.5 [&>div]:univer-h-5 [&>div]:univer-ring-transparent",V.borderClassName),initValue:f,unitId:v,subUnitId:d,isFocus:h,onChange:(m="")=>{n(m||"")},onFocus:()=>b(!0)})}):c.jsx(V.InputNumber,{className:t,value:Number(a.value)||0,onChange:m=>a.onChange(m||0),...o})},Fr=a=>{var j;const{interceptorManager:e}=a,t=A.useDependency(s.LocaleService),n=((j=a.rule)==null?void 0:j.type)===r.CFRuleType.colorScale?a.rule:void 0,l=[ee(r.CFValueType.num,t),ee(r.CFValueType.percent,t),ee(r.CFValueType.percentile,t),ee(r.CFValueType.formula,t)],u=[ee(r.CFValueType.min,t),...l],i=[ee("none",t),...l],v=[ee(r.CFValueType.max,t),...l],[d,f]=C.useState(()=>{var x;const y=r.CFValueType.min;return n&&((x=n.config[0])==null?void 0:x.value.type)||y}),[o,p]=C.useState(()=>{var x;const y="none";return!n||n.config.length!==3?y:((x=n.config[1])==null?void 0:x.value.type)||y}),[h,b]=C.useState(()=>{var x;const y=r.CFValueType.max;return n&&((x=n.config[n.config.length-1])==null?void 0:x.value.type)||y}),[S,m]=C.useState(()=>{if(!n)return 10;const x=n.config[0];return(x==null?void 0:x.value.value)===void 0?10:x==null?void 0:x.value.value}),[N,w]=C.useState(()=>{var $;if(!n||n.config.length!==3)return 50;const x=($=n.config[1])==null?void 0:$.value.value;return x===void 0?50:x}),[E,M]=C.useState(()=>{var $;if(!n)return 90;const x=($=n.config[n.config.length-1])==null?void 0:$.value.value;return x===void 0?90:x}),[R,g]=C.useState(()=>{var x;const y="#d0d9fb";return n&&((x=n.config[0])==null?void 0:x.color)||y}),[T,_]=C.useState(()=>{var x;const y="#7790f3";return!n||n.config.length!==3?y:((x=n.config[1])==null?void 0:x.color)||y}),[I,k]=C.useState(()=>{var x;const y="#2e55ef";return n&&((x=n.config[n.config.length-1])==null?void 0:x.color)||y}),U=C.useMemo(()=>y=>{const{minType:x,medianType:$,maxType:D,minValue:F,medianValue:H,maxValue:W,minColor:Z,medianColor:J,maxColor:re}=y,z=[];return z.push({color:Z,value:{type:x,value:F}}),$!=="none"&&z.push({color:J,value:{type:$,value:H}}),z.push({color:re,value:{type:D,value:W}}),{config:z.map((De,Le)=>({...De,index:Le})),type:r.CFRuleType.colorScale}},[]);C.useEffect(()=>e.intercept(e.getInterceptPoints().submit,{handler(){return U({minType:d,medianType:o,maxType:h,minValue:S,medianValue:N,maxValue:E,minColor:R,medianColor:T,maxColor:I})}}),[U,d,o,h,S,N,E,R,T,I,e]);const L=y=>{a.onChange(U(y))};return c.jsxs("div",{children:[c.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:t.t("sheet.cf.panel.styleRule")}),c.jsx("div",{className:oe,children:c.jsx(te,{rule:U({minType:d,medianType:o,maxType:h,minValue:S,medianValue:N,maxValue:E,minColor:R,medianColor:T,maxColor:I})})}),c.jsx("div",{className:"univer-mt-3 univer-text-xs univer-text-gray-600 dark:!univer-text-gray-200",children:t.t("sheet.cf.valueType.min")}),c.jsxs("div",{className:"univer-mt-3 univer-flex univer-h-8 univer-items-center",children:[c.jsx(V.Select,{className:"univer-flex-shrink-0",options:u,value:d,onChange:y=>{f(y);const x=r.createDefaultValueByValueType(y,10);m(x),L({minType:y,medianType:o,maxType:h,minValue:x,medianValue:N,maxValue:E,minColor:R,medianColor:T,maxColor:I})}}),c.jsx(ze,{id:"min",className:"univer-ml-1",value:S,type:d,onChange:y=>{m(y),L({minType:d,medianType:o,maxType:h,minValue:y,medianValue:N,maxValue:E,minColor:R,medianColor:T,maxColor:I})}}),c.jsx(Q,{className:"univer-ml-1",color:R,onChange:y=>{g(y),L({minType:d,medianType:o,maxType:h,minValue:S,medianValue:N,maxValue:E,minColor:y,medianColor:T,maxColor:I})}})]}),c.jsx("div",{className:"univer-text-gray-600dark:!univer-text-gray-200 univer-mt-3 univer-text-xs",children:t.t("sheet.cf.panel.medianValue")}),c.jsxs("div",{className:"univer-mt-3 univer-flex univer-h-8 univer-items-center",children:[c.jsx(V.Select,{className:"univer-flex-shrink-0",options:i,value:o,onChange:y=>{p(y);const x=r.createDefaultValueByValueType(y,50);w(x),L({minType:d,medianType:y,maxType:h,minValue:S,medianValue:x,maxValue:E,minColor:R,medianColor:T,maxColor:I})}}),c.jsx(ze,{id:"median",className:"univer-ml-1",value:N,type:o,onChange:y=>{w(y),L({minType:d,medianType:o,maxType:h,minValue:S,medianValue:y,maxValue:E,minColor:R,medianColor:T,maxColor:I})}}),o!=="none"&&c.jsx(Q,{className:"univer-ml-1",color:T,onChange:y=>{_(y),L({minType:d,medianType:o,maxType:h,minValue:S,medianValue:N,maxValue:E,minColor:R,medianColor:y,maxColor:I})}})]}),c.jsx("div",{className:"univer-mt-3 univer-text-xs univer-text-gray-600 dark:!univer-text-gray-200",children:t.t("sheet.cf.valueType.max")}),c.jsxs("div",{className:"univer-mt-3 univer-flex univer-h-8 univer-items-center",children:[c.jsx(V.Select,{className:"univer-flex-shrink-0",options:v,value:h,onChange:y=>{b(y);const x=r.createDefaultValueByValueType(y,90);M(x),L({minType:d,medianType:o,maxType:y,minValue:S,medianValue:N,maxValue:x,minColor:R,medianColor:T,maxColor:I})}}),c.jsx(ze,{id:"max",className:"univer-ml-1",value:E,type:h,onChange:y=>{M(y),L({minType:d,medianType:o,maxType:h,minValue:S,medianValue:N,maxValue:y,minColor:R,medianColor:T,maxColor:I})}}),c.jsx(Q,{className:"univer-ml-1",color:I,onChange:y=>{k(y),L({minType:d,medianType:o,maxType:h,minValue:S,medianValue:N,maxValue:E,minColor:R,medianColor:T,maxColor:y})}})]})]})},ne=(a,e)=>({label:e.t(`sheet.cf.valueType.${a}`),value:a}),fr=a=>{var m;const{onChange:e,className:t,value:n,type:l,id:u,disabled:i=!1}=a,v=A.useDependency(s.IUniverInstanceService),d=v.getCurrentUnitOfType(s.UniverInstanceType.UNIVER_SHEET).getUnitId(),f=(m=v.getCurrentUnitOfType(s.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:m.getSheetId(),o=C.useRef(null),[p,h]=C.useState(!1);A.useSidebarClick(N=>{var E;(E=o.current)!=null&&E.isClickOutSide(N)&&h(!1)});const b=C.useRef(n),S=C.useMemo(()=>[r.CFValueType.percentile,r.CFValueType.percent].includes(l)?{max:100,min:0}:{min:Number.MIN_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER},[l]);if(l===r.CFValueType.formula){const N=String(b.current).startsWith("=")?String(b.current)||"":"=";return c.jsx("div",{className:"univer-ml-3 univer-w-full",children:c.jsx(ie.FormulaEditor,{ref:o,className:V.clsx("univer-box-border univer-h-8 univer-w-full univer-cursor-pointer univer-items-center univer-rounded-lg univer-bg-white univer-pt-2 univer-transition-colors hover:univer-border-primary-600 dark:!univer-bg-gray-700 dark:!univer-text-white [&>div:first-child]:univer-px-2.5 [&>div]:univer-h-5 [&>div]:univer-ring-transparent",V.borderClassName),initValue:N,unitId:d,subUnitId:f,isFocus:p,onChange:(w="")=>{e(w||"")},onFocus:()=>h(!0)})})}return c.jsx(V.InputNumber,{className:t,value:Number(n)||0,disabled:i,onChange:N=>{e(N||0)},...S})},$r=a=>{var j;const{interceptorManager:e}=a,t=A.useDependency(s.LocaleService),n=((j=a.rule)==null?void 0:j.type)===r.CFRuleType.dataBar?a.rule:void 0,[l,u]=C.useState(()=>{var x;return n&&(x=n.config)!=null&&x.isGradient?"1":"0"}),[i,v]=C.useState(()=>{var y;return n&&((y=n.config)==null?void 0:y.positiveColor)||r.defaultDataBarPositiveColor}),[d,f]=C.useState(()=>{var y;return n&&((y=n.config)==null?void 0:y.nativeColor)||r.defaultDataBarNativeColor}),o=[ne(r.CFValueType.num,t),ne(r.CFValueType.percent,t),ne(r.CFValueType.percentile,t),ne(r.CFValueType.formula,t)],p=[ne(r.CFValueType.min,t),...o],h=[ne(r.CFValueType.max,t),...o],[b,S]=C.useState(()=>{var x;const y=p[0].value;return n&&((x=n.config)==null?void 0:x.min.type)||y}),[m,N]=C.useState(()=>{var x;const y=h[0].value;return n&&((x=n.config)==null?void 0:x.max.type)||y}),[w,E]=C.useState(()=>{var $;if(!n)return 0;const x=(($=n.config)==null?void 0:$.min)||{};return x.type===r.CFValueType.formula?x.value||"=":x.value||0}),[M,R]=C.useState(()=>{var $;if(!n)return 100;const x=(($=n.config)==null?void 0:$.max)||{};return x.type===r.CFValueType.formula?x.value||"=":x.value===void 0?100:x.value}),[g,T]=C.useState(()=>n?n.isShowValue===void 0?!0:!!n.isShowValue:!0),_=y=>({config:{min:{type:y.minValueType,value:y.minValue},max:{type:y.maxValueType,value:y.maxValue},isGradient:y.isGradient==="1",positiveColor:y.positiveColor||r.defaultDataBarPositiveColor,nativeColor:y.nativeColor||r.defaultDataBarNativeColor},type:r.CFRuleType.dataBar,isShowValue:y.isShowValue});C.useEffect(()=>e.intercept(e.getInterceptPoints().submit,{handler(){return _({isGradient:l,minValue:w,minValueType:b,maxValue:M,maxValueType:m,positiveColor:i,nativeColor:d,isShowValue:g})}}),[l,w,b,M,m,i,d,e,g]);const I=y=>{a.onChange(_(y))},k=y=>{v(y),I({isGradient:l,minValue:w,minValueType:b,maxValue:M,maxValueType:m,positiveColor:y,nativeColor:d,isShowValue:g})},U=y=>{f(y),I({isGradient:l,minValue:w,minValueType:b,maxValue:M,maxValueType:m,positiveColor:i,nativeColor:y,isShowValue:g})},L=y=>o.map(x=>x.value).includes(y);return c.jsxs("div",{children:[c.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:t.t("sheet.cf.panel.styleRule")}),c.jsx("div",{className:oe,children:c.jsx(te,{rule:_({isGradient:l,minValue:w,minValueType:b,maxValue:M,maxValueType:m,positiveColor:i,nativeColor:d,isShowValue:g})})}),c.jsxs("div",{children:[c.jsx("div",{className:"univer-mt-3 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:t.t("sheet.cf.panel.fillType")}),c.jsxs("div",{className:"univer-ml-1 univer-mt-3 univer-flex univer-items-center",children:[c.jsxs(V.RadioGroup,{value:l,onChange:y=>{u(y),I({isGradient:y,minValue:w,minValueType:b,maxValue:M,maxValueType:m,positiveColor:i,nativeColor:d,isShowValue:g})},children:[c.jsx(V.Radio,{value:"0",children:c.jsx("span",{className:"univer-text-xs",children:t.t("sheet.cf.panel.pureColor")})}),c.jsx(V.Radio,{value:"1",children:c.jsx("span",{className:"univer-text-xs",children:t.t("sheet.cf.panel.gradient")})})]}),c.jsxs("div",{className:"univer-ml-6 univer-flex univer-items-center univer-text-xs",children:[c.jsx(V.Checkbox,{checked:!g,onChange:y=>{T(!y),I({isGradient:y,minValue:w,minValueType:b,maxValue:M,maxValueType:m,positiveColor:i,nativeColor:d,isShowValue:!y})}}),t.t("sheet.cf.panel.onlyShowDataBar")]})]})]}),c.jsxs("div",{children:[c.jsx("div",{className:"univer-mt-3 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:t.t("sheet.cf.panel.colorSet")}),c.jsxs("div",{className:"univer-ml-1 univer-mt-3 univer-flex univer-items-center",children:[c.jsxs("div",{className:"univer-flex univer-items-center",children:[c.jsx("div",{className:"univer-text-xs",children:t.t("sheet.cf.panel.native")}),c.jsx(Q,{color:d,onChange:U})]}),c.jsxs("div",{className:"univer-ml-3 univer-flex univer-items-center",children:[c.jsx("div",{className:"univer-text-xs",children:t.t("sheet.cf.panel.positive")}),c.jsx(Q,{color:i,onChange:k})]})]})]}),c.jsxs("div",{children:[c.jsx("div",{className:"univer-mt-3 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:t.t("sheet.cf.valueType.min")}),c.jsxs("div",{className:"univer-mt-3 univer-flex univer-items-center",children:[c.jsx(V.Select,{className:"univer-w-1/2 univer-flex-shrink-0",options:p,value:b,onChange:y=>{S(y);const x=r.createDefaultValueByValueType(y,10);E(x),I({isGradient:l,minValue:x,minValueType:y,maxValue:M,maxValueType:m,positiveColor:i,nativeColor:d,isShowValue:g})}}),c.jsx(fr,{id:"min",className:"univer-ml-3",disabled:!L(b),type:b,value:w,onChange:y=>{E(y||0),I({isGradient:l,minValue:y||0,minValueType:b,maxValue:M,maxValueType:m,positiveColor:i,nativeColor:d,isShowValue:g})}})]}),c.jsx("div",{className:"univer-mt-3 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:t.t("sheet.cf.valueType.max")}),c.jsxs("div",{className:"univer-mt-3 univer-flex univer-items-center",children:[c.jsx(V.Select,{className:"univer-w-1/2 univer-flex-shrink-0",options:h,value:m,onChange:y=>{N(y);const x=r.createDefaultValueByValueType(y,90);R(x),I({isGradient:l,minValue:w,minValueType:b,maxValue:x,maxValueType:y,positiveColor:i,nativeColor:d,isShowValue:g})}}),c.jsx(fr,{className:"univer-ml-3",disabled:!L(m),id:"max",type:m,value:M,onChange:y=>{R(y||0),I({isGradient:l,minValue:w,minValueType:b,maxValue:y||0,maxValueType:m,positiveColor:i,nativeColor:d,isShowValue:g})}})]})]})]})},Te=a=>[s.BooleanNumber.FALSE,void 0].includes(a)?s.BooleanNumber.TRUE:s.BooleanNumber.FALSE,_e=a=>a!==s.BooleanNumber.FALSE,Ke=a=>{const{style:e,onChange:t,className:n}=a,[l,u]=C.useState(()=>{if(e!=null&&e.bl)return e.bl}),[i,v]=C.useState(()=>{if(e!=null&&e.it)return e.it}),[d,f]=C.useState(()=>{if(e!=null&&e.ul)return e.ul.s}),[o,p]=C.useState(()=>{if(e!=null&&e.st)return e.st.s}),[h,b]=C.useState(()=>{var E;const w="#2f56ef";return(E=e==null?void 0:e.cl)!=null&&E.rgb?e.cl.rgb:w}),[S,m]=C.useState(()=>{var E;const w="#e8ecfc";return(E=e==null?void 0:e.bg)!=null&&E.rgb?e.bg.rgb:w});C.useEffect(()=>{const w={bl:l,it:i};h!==void 0&&(w.cl={rgb:h}),S!==void 0&&(w.bg={rgb:S}),o!==void 0&&(w.st={s:o}),d!==void 0&&(w.ul={s:d}),t(r.removeUndefinedAttr(w))},[l,i,d,o,h,S]);const N="univer-flex univer-cursor-pointer univer-items-center univer-rounded univer-px-1";return c.jsxs("div",{className:V.clsx("univer-my-2.5 univer-flex univer-justify-between",n),children:[c.jsx("div",{className:V.clsx(N,{"univer-bg-gray-100 dark:!univer-bg-gray-700":_e(l||s.BooleanNumber.FALSE)}),onClick:()=>u(Te(l)),children:c.jsx(ur,{})}),c.jsx("div",{className:V.clsx(N,{"univer-bg-gray-100 dark:!univer-bg-gray-700":_e(i||s.BooleanNumber.FALSE)}),onClick:()=>v(Te(i)),children:c.jsx(sr,{})}),c.jsx("div",{className:V.clsx(N,{"univer-bg-gray-100 dark:!univer-bg-gray-700":_e(d||s.BooleanNumber.FALSE)}),onClick:()=>f(Te(d)),children:c.jsx(dr,{})}),c.jsx("div",{className:V.clsx(N,{"univer-bg-gray-100 dark:!univer-bg-gray-700":_e(o||s.BooleanNumber.FALSE)}),onClick:()=>p(Te(o)),children:c.jsx(or,{})}),c.jsx(Q,{color:h,onChange:b,Icon:vr}),c.jsx(Q,{color:S,onChange:m})]})},Br=a=>{var R;const{onChange:e,interceptorManager:t}=a,n=A.useDependency(s.LocaleService),u=A.useDependency(s.IUniverInstanceService).getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET),i=u.getActiveSheet(),v=((R=a.rule)==null?void 0:R.type)===r.CFRuleType.highlightCell?a.rule:void 0,d=C.useRef(null),[f,o]=C.useState(!1),p=C.useRef(null),[h,b]=C.useState({}),[S,m]=C.useState(()=>(v==null?void 0:v.subType)===r.CFSubRuleType.formula?v.value:"="),[N,w]=C.useState(void 0),E=g=>({style:g.style,value:S,type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.formula});C.useEffect(()=>t.intercept(t.getInterceptPoints().submit,{handler(){return E({style:h})}}),[h,S,t]),C.useEffect(()=>t.intercept(t.getInterceptPoints().beforeSubmit,{handler:(T,_,I)=>N||S.length===1||!S.startsWith("=")?(w(n.t("sheet.cf.errorMessage.formulaError")),!1):I(T)}),[N,S]);const M=g=>{e(E(g))};return A.useSidebarClick(g=>{var _;(_=p.current)!=null&&_.isClickOutSide(g)&&o(!1)}),c.jsxs("div",{ref:d,children:[c.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:n.t("sheet.cf.panel.styleRule")}),c.jsx("div",{className:"univer-mt-3",children:c.jsx(ie.FormulaEditor,{ref:p,className:V.clsx("univer-box-border univer-h-8 univer-w-full univer-cursor-pointer univer-items-center univer-rounded-lg univer-bg-white univer-pt-2 univer-transition-colors hover:univer-border-primary-600 dark:!univer-bg-gray-700 dark:!univer-text-white [&>div:first-child]:univer-px-2.5 [&>div]:univer-h-5 [&>div]:univer-ring-transparent",V.borderClassName),errorText:N,isFocus:f,initValue:S,unitId:u.getUnitId(),subUnitId:i==null?void 0:i.getSheetId(),onFocus:()=>{o(!0)},onChange:g=>{m(g),M({style:h})},onVerify:(g,T)=>{!g||T.length===1?w(n.t("sheet.cf.errorMessage.formulaError")):w(void 0)}})}),c.jsx("div",{className:oe,children:c.jsx(te,{rule:E({style:h})})}),c.jsx(Ke,{style:v==null?void 0:v.style,className:"univer-mt-3",onChange:g=>{b(g),M({style:g})}})]})},we=a=>c.jsxs("div",{className:"univer-relative",children:[c.jsx("div",{className:"univer-absolute univer-bottom-[-13px] univer-z-[999] univer-text-[10px] univer-text-red-500",children:a.errorText}),a.children]}),B=(a,e)=>({label:e.t(`sheet.cf.operator.${a}`),value:a}),Hr=a=>{const{type:e,operator:t,onChange:n,value:l,interceptorManager:u}=a,i=A.useDependency(s.LocaleService),[v,d]=C.useState(()=>typeof l=="number"?l:0),[f,o]=C.useState(""),[p,h]=C.useState(()=>typeof l=="string"?l:""),[b,S]=C.useState(""),[m,N]=C.useState(()=>Array.isArray(l)?l[0]===void 0?0:l[0]:0),[w,E]=C.useState(""),[M,R]=C.useState(()=>Array.isArray(l)?l[1]===void 0?100:l[1]:100),[g,T]=C.useState("");switch(C.useEffect(()=>{switch(e){case r.CFSubRuleType.text:{[r.CFTextOperator.beginsWith,r.CFTextOperator.endsWith,r.CFTextOperator.containsText,r.CFTextOperator.notContainsText,r.CFTextOperator.equal,r.CFTextOperator.notEqual].includes(t)&&n(p);break}case r.CFSubRuleType.number:{[r.CFNumberOperator.equal,r.CFNumberOperator.notEqual,r.CFNumberOperator.greaterThan,r.CFNumberOperator.greaterThanOrEqual,r.CFNumberOperator.lessThan,r.CFNumberOperator.lessThanOrEqual].includes(t)&&n(v),[r.CFNumberOperator.between,r.CFNumberOperator.notBetween].includes(t)&&n([m,M]);break}}},[e]),C.useEffect(()=>{const _=u.intercept(u.getInterceptPoints().beforeSubmit,{handler:(I,k,U)=>{switch(e){case r.CFSubRuleType.text:if([r.CFTextOperator.beginsWith,r.CFTextOperator.containsText,r.CFTextOperator.endsWith,r.CFTextOperator.notEqual,r.CFTextOperator.notContainsText,r.CFTextOperator.equal].includes(t))return p?U(I):(S(i.t("sheet.cf.errorMessage.notBlank")),!1)}return U(I)}});return()=>{_()}},[e,v,p,t]),e){case r.CFSubRuleType.text:{if([r.CFTextOperator.beginsWith,r.CFTextOperator.endsWith,r.CFTextOperator.containsText,r.CFTextOperator.notContainsText,r.CFTextOperator.equal,r.CFTextOperator.notEqual].includes(t)){const _=I=>{h(I),n(I)};return c.jsx("div",{className:"univer-mt-3",children:c.jsx(we,{errorText:b,children:c.jsx(V.Input,{value:p,onChange:I=>{S(""),_(I)}})})})}break}case r.CFSubRuleType.number:{if([r.CFNumberOperator.equal,r.CFNumberOperator.notEqual,r.CFNumberOperator.greaterThan,r.CFNumberOperator.greaterThanOrEqual,r.CFNumberOperator.lessThan,r.CFNumberOperator.lessThanOrEqual].includes(t)){const _=I=>{d(I||0),n(I||0),o("")};return c.jsx("div",{className:"univer-mt-3",children:c.jsx(we,{errorText:f,children:c.jsx(V.InputNumber,{className:"univer-w-full",min:Number.MIN_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER,value:v,onChange:_})})})}if([r.CFNumberOperator.between,r.CFNumberOperator.notBetween].includes(t)){const _=k=>{N(k||0),n([k||0,M]),E("")},I=k=>{R(k||0),n([m,k||0]),T("")};return c.jsxs("div",{className:"univer-mt-3 univer-flex univer-items-center",children:[c.jsx(we,{errorText:w,children:c.jsx(V.InputNumber,{min:Number.MIN_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER,value:m,onChange:_})}),c.jsx(we,{errorText:g,children:c.jsx(V.InputNumber,{className:"univer-ml-3",min:Number.MIN_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER,value:M,onChange:I})})]})}}}return null},hr=(a,e)=>{switch(a){case r.CFSubRuleType.text:return[B(r.CFTextOperator.containsText,e),B(r.CFTextOperator.notContainsText,e),B(r.CFTextOperator.beginsWith,e),B(r.CFTextOperator.endsWith,e),B(r.CFTextOperator.equal,e),B(r.CFTextOperator.notEqual,e),B(r.CFTextOperator.containsBlanks,e),B(r.CFTextOperator.notContainsBlanks,e),B(r.CFTextOperator.containsErrors,e),B(r.CFTextOperator.notContainsErrors,e)];case r.CFSubRuleType.number:return[B(r.CFNumberOperator.between,e),B(r.CFNumberOperator.notBetween,e),B(r.CFNumberOperator.equal,e),B(r.CFNumberOperator.notEqual,e),B(r.CFNumberOperator.greaterThan,e),B(r.CFNumberOperator.greaterThanOrEqual,e),B(r.CFNumberOperator.lessThan,e),B(r.CFNumberOperator.lessThanOrEqual,e)];case r.CFSubRuleType.timePeriod:return[B(r.CFTimePeriodOperator.yesterday,e),B(r.CFTimePeriodOperator.today,e),B(r.CFTimePeriodOperator.tomorrow,e),B(r.CFTimePeriodOperator.last7Days,e),B(r.CFTimePeriodOperator.lastWeek,e),B(r.CFTimePeriodOperator.thisWeek,e),B(r.CFTimePeriodOperator.nextWeek,e),B(r.CFTimePeriodOperator.lastMonth,e),B(r.CFTimePeriodOperator.thisMonth,e),B(r.CFTimePeriodOperator.nextMonth,e)]}},gr=a=>{var R;const{interceptorManager:e,onChange:t}=a,n=A.useDependency(s.LocaleService),l=((R=a.rule)==null?void 0:R.type)===r.CFRuleType.highlightCell?a.rule:void 0,[u,i]=C.useState(()=>{const g=r.CFSubRuleType.text;return l&&l.subType||g}),v=[{value:r.CFSubRuleType.text,label:n.t("sheet.cf.subRuleType.text")},{value:r.CFSubRuleType.number,label:n.t("sheet.cf.subRuleType.number")},{value:r.CFSubRuleType.timePeriod,label:n.t("sheet.cf.subRuleType.timePeriod")},{value:r.CFSubRuleType.duplicateValues,label:n.t("sheet.cf.subRuleType.duplicateValues")},{value:r.CFSubRuleType.uniqueValues,label:n.t("sheet.cf.subRuleType.uniqueValues")}],d=C.useMemo(()=>hr(u,n),[u]),[f,o]=C.useState(()=>{const g=d?d[0].value:void 0;return l&&l.operator||g}),[p,h]=C.useState(()=>{var _;return l?(_=l.value)!=null?_:r.createDefaultValue(l.subType,l.operator):""}),[b,S]=C.useState({}),m=C.useMemo(()=>g=>{var T,_,I,k,U,L,j,y,x,$,D,F,H,W,Z;switch(g.subType||u){case r.CFSubRuleType.text:{if([r.CFTextOperator.beginsWith,r.CFTextOperator.endsWith,r.CFTextOperator.containsText,r.CFTextOperator.notContainsText,r.CFTextOperator.equal,r.CFTextOperator.notEqual].includes(f))return{type:r.CFRuleType.highlightCell,subType:(T=g.subType)!=null?T:u,operator:(_=g.operator)!=null?_:f,style:(I=g.style)!=null?I:b,value:(k=g.value)!=null?k:p};break}case r.CFSubRuleType.number:{if([r.CFNumberOperator.equal,r.CFNumberOperator.notEqual,r.CFNumberOperator.greaterThan,r.CFNumberOperator.greaterThanOrEqual,r.CFNumberOperator.lessThan,r.CFNumberOperator.lessThanOrEqual].includes(f))return{type:r.CFRuleType.highlightCell,subType:(U=g.subType)!=null?U:u,operator:(L=g.operator)!=null?L:f,style:(j=g.style)!=null?j:b,value:(y=g.value)!=null?y:p};if([r.CFNumberOperator.between,r.CFNumberOperator.notBetween].includes(f))return{type:r.CFRuleType.highlightCell,subType:(x=g.subType)!=null?x:u,operator:($=g.operator)!=null?$:f,style:(D=g.style)!=null?D:b,value:(F=g.value)!=null?F:p};break}}return{type:r.CFRuleType.highlightCell,subType:(H=g.subType)!=null?H:u,operator:(W=g.operator)!=null?W:f,style:(Z=g.style)!=null?Z:b}},[u,f,p,b]);C.useEffect(()=>e.intercept(e.getInterceptPoints().submit,{handler(){return m({})}}),[m,e]),C.useEffect(()=>{v.some(g=>g.value===u)||i(v[0].value)},[v]);const N=g=>{const T=g,_=hr(T,n),I=_&&_[0].value;i(T),o(I),I&&h(r.createDefaultValue(T,I)),t(m({subType:T,operator:I}))},w=g=>{const T=g;o(T),t(m({operator:T}))},E=g=>{h(g),t(m({value:g}))},M=C.useMemo(()=>`${u}_${f}_${Math.random()}`,[u,f]);return c.jsxs("div",{children:[c.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:n.t("sheet.cf.panel.styleRule")}),c.jsxs("div",{className:"univer-flex univer-justify-between univer-gap-4",children:[c.jsx(V.Select,{className:"univer-mt-3 univer-w-full",onChange:N,value:u,options:v}),(d==null?void 0:d.length)&&c.jsx(V.Select,{className:"univer-mt-3 univer-w-full",onChange:w,value:f||"",options:d})]}),c.jsx(Hr,{value:p,interceptorManager:e,type:u,operator:f,rule:l,onChange:E},M),c.jsx("div",{className:oe,children:c.jsx(te,{rule:m({})})}),c.jsx(Ke,{style:l==null?void 0:l.style,className:"univer-ml-1",onChange:g=>{S(g),t(m({style:g}))}})]})},yr=(a,e)=>(r.iconMap[a]||[])[Number(e)]||"",Wr=a=>{var o;const{error:e,type:t,onChange:n}=a,l=A.useDependency(s.IUniverInstanceService),u=l.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET).getUnitId(),i=(o=l.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:o.getSheetId(),v=C.useRef(null),[d,f]=C.useState(!1);return A.useSidebarClick(p=>{var b;(b=v.current)!=null&&b.isClickOutSide(p)&&f(!1)}),c.jsx("div",{className:"univer-relative",children:t!==r.CFValueType.formula?c.jsxs(c.Fragment,{children:[c.jsx(V.InputNumber,{className:V.clsx({"univer-border-red-500":e}),value:Number(a.value)||0,onChange:p=>n(p!=null?p:0)}),e&&c.jsx("div",{className:"univer-absolute univer-text-xs univer-text-red-500",children:e})]}):c.jsx("div",{className:"univer-w-full",children:c.jsx(ie.FormulaEditor,{ref:v,className:V.clsx("univer-box-border univer-h-8 univer-w-full univer-cursor-pointer univer-items-center univer-rounded-lg univer-bg-white univer-pt-2 univer-transition-colors hover:univer-border-primary-600 dark:!univer-bg-gray-700 dark:!univer-text-white [&>div:first-child]:univer-px-2.5 [&>div]:univer-h-5 [&>div]:univer-ring-transparent",V.borderClassName),initValue:String(a.value),unitId:u,subUnitId:i,isFocus:d,onChange:(p="")=>{n(p||"")},onFocus:()=>f(!0)})})})},Cr=(a,e,t)=>({operator:r.CFNumberOperator.greaterThan,value:{type:r.CFValueType.num,value:(t.length-1-e)*10},iconType:a,iconId:String(e)}),qr=C.forwardRef((a,e)=>{const{onClick:t}=a,n=A.useDependency(s.LocaleService),l=u=>{t(u)};return c.jsx("div",{ref:e,className:"univer-w-80",children:r.iconGroup.map((u,i)=>c.jsxs("div",{className:"univer-mb-3",children:[c.jsx("div",{className:"univer-mb-1 univer-text-sm",children:n.t(u.title)}),c.jsx("div",{className:"univer-flex univer-flex-wrap",children:u.group.map(v=>c.jsx("div",{className:"univer-mb-1 univer-flex univer-w-1/2 univer-items-center",onClick:()=>{l(v.name)},children:c.jsx("a",{className:"univer-flex univer-cursor-pointer univer-rounded hover:univer-bg-gray-100 dark:hover:!univer-bg-gray-700",children:v.list.map((d,f)=>c.jsx("img",{className:"univer-size-5",src:d,draggable:!1},f))})},v.name))})]},i))})}),Gr=a=>{const{onClick:e}=a,t=C.useMemo(()=>{const l=[];for(const u in r.iconMap){const i=r.iconMap[u],v=u;i.forEach((d,f)=>{l.push({iconType:v,base64:d,iconId:String(f)})})}return l},[]),n=l=>{e(l.iconType,l.iconId)};return c.jsxs("div",{children:[c.jsxs("div",{className:"univer-mb-2.5 univer-flex univer-cursor-pointer univer-items-center univer-pl-1",onClick:()=>n({iconType:r.EMPTY_ICON_TYPE,iconId:""}),children:[c.jsx(ce,{className:"univer-size-5"}),c.jsx("span",{className:"univer-ml-2",children:"无单元格图标"})]}),c.jsx("div",{className:"univer-flex univer-w-64 univer-flex-wrap",children:t.map(l=>c.jsx("div",{className:"univer-mb-2 univer-mr-2 univer-flex univer-cursor-pointer univer-items-center univer-justify-center univer-rounded hover:univer-bg-gray-100 dark:hover:!univer-bg-gray-700",children:c.jsx("img",{className:"univer-size-5",src:l.base64,draggable:!1,onClick:()=>n(l)})},`${l.iconType}_${l.iconId}`))})]})},Zr=a=>{const{onChange:e,configList:t,errorMap:n={}}=a,l=A.useDependency(s.LocaleService),u=[{label:l.t(`sheet.cf.symbol.${r.CFNumberOperator.greaterThan}`),value:r.CFNumberOperator.greaterThan},{label:l.t(`sheet.cf.symbol.${r.CFNumberOperator.greaterThanOrEqual}`),value:r.CFNumberOperator.greaterThanOrEqual}],i=[{label:l.t(`sheet.cf.valueType.${r.CFValueType.num}`),value:r.CFValueType.num},{label:l.t(`sheet.cf.valueType.${r.CFValueType.percent}`),value:r.CFValueType.percent},{label:l.t(`sheet.cf.valueType.${r.CFValueType.percentile}`),value:r.CFValueType.percentile},{label:l.t(`sheet.cf.valueType.${r.CFValueType.formula}`),value:r.CFValueType.formula}],v=(p,h)=>{e([String(h),"value","value"],p)},d=(p,h)=>{e([String(h),"operator"],p);const b=r.createDefaultValue(r.CFSubRuleType.number,p);v(b,h)},f=(p,h)=>{e([String(h),"value","type"],p);const b=t[h],S=r.createDefaultValue(r.CFSubRuleType.number,b.operator);v(S,h)};return C.useMemo(()=>t.map((p,h)=>{const b=n[h],S=yr(p.iconType,p.iconId),m=h===t.length-1,N=h===0,w=t[h-1],E=(w==null?void 0:w.value.type)===r.CFValueType.formula?l.t("sheet.cf.valueType.formula"):w==null?void 0:w.value.value,M=(R,g)=>{const T={...p,iconId:g,iconType:R};e([String(h)],T)};return c.jsxs("div",{className:h?"univer-mt-6":"univer-mt-3",children:[c.jsxs("div",{className:"univer-mt-3 univer-flex univer-items-center univer-justify-between univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:[c.jsxs("div",{className:"univer-w-[45%]",children:[l.t("sheet.cf.iconSet.icon"),h+1]}),c.jsx("div",{className:"univer-w-[45%]",children:c.jsxs(c.Fragment,{children:[!N&&!m&&l.t("sheet.cf.iconSet.rule"),!N&&!m&&c.jsxs("span",{className:"univer-font-medium univer-text-gray-600 dark:!univer-text-gray-200",children:[l.t("sheet.cf.iconSet.when"),l.t(`sheet.cf.symbol.${r.getOppositeOperator(w.operator)}`),E,m?"":` ${l.t("sheet.cf.iconSet.and")} `]})]})})]}),c.jsxs("div",{className:"univer-mt-3 univer-grid univer-grid-cols-2 univer-gap-4",children:[c.jsx("div",{className:"univer-flex univer-items-center",children:c.jsx(V.Dropdown,{overlay:c.jsx("div",{className:"univer-rounded-lg univer-p-4",children:c.jsx(Gr,{onClick:M,iconId:p.iconId,iconType:p.iconType})}),children:c.jsxs("div",{className:V.clsx("univer-box-border univer-flex univer-h-8 univer-w-full univer-items-center univer-justify-between univer-rounded-md univer-bg-white univer-px-4 univer-py-2 univer-text-xs univer-text-gray-600 univer-transition-all hover:univer-border-primary-600 dark:!univer-text-gray-200",V.borderClassName),children:[S?c.jsx("img",{src:S,className:"univer-size-4",draggable:!1}):c.jsx(ce,{className:"univer-size-4"}),c.jsx(Ye,{})]})})}),m?c.jsxs("div",{className:"univer-mt-0 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:[l.t("sheet.cf.iconSet.rule"),c.jsxs("span",{className:"univer-font-medium",children:[l.t("sheet.cf.iconSet.when"),l.t(`sheet.cf.symbol.${r.getOppositeOperator(w.operator)}`),E,m?"":` ${l.t("sheet.cf.iconSet.and")} `]})]}):c.jsx(V.Select,{options:u,value:p.operator,onChange:R=>{d(R,h)}})]}),m?c.jsx("div",{}):c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"univer-mt-3 univer-grid univer-grid-cols-2 univer-gap-4 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:[c.jsx("div",{children:l.t("sheet.cf.iconSet.type")}),c.jsx("div",{children:l.t("sheet.cf.iconSet.value")})]}),c.jsxs("div",{className:"univer-mt-3 univer-grid univer-grid-cols-2 univer-gap-4",children:[c.jsx(V.Select,{options:i,value:p.value.type,onChange:R=>{f(R,h)}}),c.jsx(Wr,{id:h,type:p.value.type,error:b,value:p.value.value||"",onChange:R=>{v(R,h)}})]})]})]},h)}),[t,n])},Yr=a=>{var R;const{interceptorManager:e}=a,t=((R=a.rule)==null?void 0:R.type)===r.CFRuleType.iconSet?a.rule:void 0,n=A.useDependency(s.LocaleService),[l,u]=C.useState({}),[i,v]=C.useState(()=>{const g=Object.keys(r.iconMap)[0];if(t&&t.config.length){const T=t.config[0].iconType;if(!t.config.some(I=>I.iconType!==T))return T}return g}),[d,f]=C.useState(()=>{if(t&&t.config.length)return s.Tools.deepClone(t==null?void 0:t.config);const g=r.iconMap[i]||[];return new Array(g.length).fill("").map((T,_,I)=>_===I.length-1?{operator:r.CFNumberOperator.lessThanOrEqual,value:{type:r.CFValueType.num,value:Number.MAX_SAFE_INTEGER},iconType:i,iconId:String(_)}:Cr(i,_,I))}),[o,p]=C.useState(()=>t?!!t.isShowValue:!0),h=C.useMemo(()=>{const g=d.map(T=>yr(T.iconType,T.iconId));return c.jsx("div",{className:"univer-flex univer-items-center",children:g.map((T,_)=>T?c.jsx("img",{className:"univer-size-5",src:T},_):c.jsx(ce,{className:"univer-size-5"},_))})},[d]),b=g=>{if(g.reduce((_,I,k)=>_.preType&&!_.result||g.length-1===k?_:I.value.type===r.CFValueType.formula?{preType:r.CFValueType.formula,result:!1}:_.preType?{result:_.preType===I.value.type,preType:I.value.type}:{result:!0,preType:I.value.type},{result:!0,preType:""}).result&&[r.CFValueType.num,r.CFValueType.percent,r.CFValueType.percentile].includes(g[0].value.type)){const _={};return g.forEach((I,k,U)=>{if(k-1<0||k===U.length-1)return;const j=g[k-1],y=r.getOppositeOperator(j.operator);r.compareWithNumber({operator:y,value:j.value.value},I.value.value)||(_[k]=`${n.t(`sheet.cf.form.${y}`,String(j.value.value))} `)}),_}return{}},S=(g,T)=>{s.get(d,g)!==T&&(s.set(d,g,T),f([...d]),u(b(d)))},m=g=>{v(g);const T=r.iconMap[g]||[],_=new Array(T.length).fill("").map((I,k,U)=>Cr(g,k,U));f(_),u(b(_))};C.useEffect(()=>{const g=e.intercept(e.getInterceptPoints().submit,{handler(){return{type:r.CFRuleType.iconSet,isShowValue:o,config:d}}});return()=>{g()}},[o,d,e]),C.useEffect(()=>{const g=e.intercept(e.getInterceptPoints().beforeSubmit,{handler(){return Object.keys(l).length===0}});return()=>{g()}},[o,d,e,l]);const N=()=>{const g=d.map(T=>({...T}));d.forEach((T,_)=>{const I=d.length-1-_,k=g[I];T.iconId=k.iconId,T.iconType=k.iconType}),f([...d])},w=A.useDependency(A.ILayoutService),[E,M]=C.useState();return A.useScrollYOverContainer(E,w.rootContainerElement),c.jsxs("div",{children:[c.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-600",children:n.t("sheet.cf.panel.styleRule")}),c.jsx("div",{className:"univer-mt-3",children:c.jsx(V.Dropdown,{overlay:c.jsx("div",{className:"univer-rounded-lg univer-p-4",children:c.jsx(qr,{ref:g=>{!E&&g&&M(g)},iconType:i,onClick:m})}),children:c.jsxs("div",{className:V.clsx("univer-box-border univer-flex univer-h-8 univer-w-full univer-items-center univer-justify-between univer-rounded-md univer-bg-white univer-px-4 univer-py-2 univer-text-xs univer-text-gray-600 univer-transition-all hover:univer-border-primary-600",V.borderClassName),children:[h,c.jsx(Ye,{})]})})}),c.jsxs("div",{className:"univer-mt-3 univer-flex univer-items-center univer-text-xs",children:[c.jsxs("div",{className:"univer-flex univer-items-center univer-text-xs",children:[c.jsx(V.Checkbox,{onChange:N}),n.t("sheet.cf.iconSet.reverseIconOrder")]}),c.jsxs("div",{className:"univer-ml-6 univer-flex univer-items-center univer-text-xs",children:[c.jsx(V.Checkbox,{checked:!o,onChange:g=>{p(!g)}}),n.t("sheet.cf.iconSet.onlyShowIcon")]})]}),c.jsx(Zr,{errorMap:l,onChange:S,configList:d})]})},zr=a=>{var N;const{onChange:e,interceptorManager:t}=a,n=A.useDependency(s.LocaleService),l=((N=a.rule)==null?void 0:N.type)===r.CFRuleType.highlightCell?a.rule:void 0,u=[{label:n.t("sheet.cf.panel.isNotBottom"),value:"isNotBottom"},{label:n.t("sheet.cf.panel.isBottom"),value:"isBottom"},{label:n.t("sheet.cf.panel.greaterThanAverage"),value:"greaterThanAverage"},{label:n.t("sheet.cf.panel.lessThanAverage"),value:"lessThanAverage"}],[i,v]=C.useState(()=>{const w=u[0].value,E=l==null?void 0:l.type;if(!l)return w;switch(E){case r.CFRuleType.highlightCell:switch(l.subType){case r.CFSubRuleType.average:return[r.CFNumberOperator.greaterThan,r.CFNumberOperator.greaterThanOrEqual].includes(l.operator)?"greaterThanAverage":[r.CFNumberOperator.lessThan,r.CFNumberOperator.lessThanOrEqual].includes(l.operator)?"lessThanAverage":w;case r.CFSubRuleType.rank:return l.isBottom?"isBottom":"isNotBottom"}}return w}),[d,f]=C.useState(()=>{const E=l==null?void 0:l.type;if(!l)return 10;switch(E){case r.CFRuleType.highlightCell:if(l.subType===r.CFSubRuleType.rank)return l.value||10}return 10}),[o,p]=C.useState(()=>{const E=l==null?void 0:l.type;if(!l)return!1;switch(E){case r.CFRuleType.highlightCell:if(l.subType===r.CFSubRuleType.rank)return l.isPercent||!1}return!1}),[h,b]=C.useState({}),S=w=>{const{type:E,isPercent:M,value:R,style:g}=w;if(E==="isNotBottom")return{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.rank,isPercent:M,isBottom:!1,value:R,style:g};if(E==="isBottom")return{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.rank,isPercent:M,isBottom:!0,value:R,style:g};if(E==="greaterThanAverage")return{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.average,operator:r.CFNumberOperator.greaterThan,style:g};if(E==="lessThanAverage")return{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.average,operator:r.CFNumberOperator.lessThan,style:g}};C.useEffect(()=>t.intercept(t.getInterceptPoints().submit,{handler(){return S({type:i,isPercent:o,value:d,style:h})}}),[i,o,d,h,t]);const m=w=>{e(S(w))};return c.jsxs("div",{children:[c.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:n.t("sheet.cf.panel.styleRule")}),c.jsx(V.Select,{className:"univer-mt-3 univer-w-full",value:i,options:u,onChange:w=>{v(w),m({type:w,isPercent:o,value:d,style:h})}}),["isNotBottom","isBottom"].includes(i)&&c.jsxs("div",{className:"univer-mt-3 univer-flex univer-items-center",children:[c.jsx(V.InputNumber,{min:1,max:1e3,value:d,onChange:w=>{const E=w||0;f(E),m({type:i,isPercent:o,value:E,style:h})}}),c.jsxs("div",{className:"univer-ml-3 univer-flex univer-items-center univer-text-xs",children:[c.jsx(V.Checkbox,{checked:o,onChange:w=>{p(!!w),m({type:i,isPercent:!!w,value:d,style:h})}}),n.t("sheet.cf.valueType.percent")]})]}),c.jsx("div",{className:oe,children:c.jsx(te,{rule:S({type:i,isPercent:o,value:d,style:h})})}),c.jsx(Ke,{style:l==null?void 0:l.style,className:"univer-mt-3",onChange:w=>{b(w),m({type:i,isPercent:o,value:d,style:w})}})]})},Kr=s.createInterceptorKey("beforeSubmit"),Xr=s.createInterceptorKey("submit"),mr=a=>a.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET).getUnitId(),br=a=>{var e;return(e=a.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:e.getSheetId()},Jr=a=>{var _,I,k;const e=A.useDependency(s.LocaleService),t=A.useDependency(s.ICommandService),n=A.useDependency(s.IUniverInstanceService),l=A.useDependency(r.ConditionalFormattingRuleModel),u=A.useDependency(O.SheetsSelectionsService),i=mr(n),v=br(n),[d,f]=C.useState(void 0),o=C.useRef((I=(_=a.rule)==null?void 0:_.ranges)!=null?I:[]),p=C.useMemo(()=>{var L,j,y;let U=(L=a.rule)==null?void 0:L.ranges;return U!=null&&U.length||(U=(y=(j=u.getCurrentSelections())==null?void 0:j.map(x=>x.range))!=null?y:[]),o.current=U,U!=null&&U.length?U.map(x=>{const $=je.serializeRange(x);return $==="NaN"?"":$}).filter(x=>!!x).join(","):""},[a.rule]),h=[{label:e.t("sheet.cf.ruleType.highlightCell"),value:"1"},{label:e.t("sheet.cf.panel.rankAndAverage"),value:"2"},{label:e.t("sheet.cf.ruleType.dataBar"),value:"3"},{label:e.t("sheet.cf.ruleType.colorScale"),value:"4"},{label:e.t("sheet.cf.ruleType.formula"),value:"5"},{label:e.t("sheet.cf.ruleType.iconSet"),value:"6"}],[b,S]=C.useState(()=>{var j,y;const U=(j=a.rule)==null?void 0:j.rule.type,L=h[0].value;if(!U)return L;switch(U){case r.CFRuleType.highlightCell:{switch((y=a.rule)==null?void 0:y.rule.subType){case r.CFSubRuleType.number:case r.CFSubRuleType.text:case r.CFSubRuleType.duplicateValues:case r.CFSubRuleType.uniqueValues:case r.CFSubRuleType.timePeriod:return"1";case r.CFSubRuleType.average:case r.CFSubRuleType.rank:return"2";case r.CFSubRuleType.formula:return"5"}break}case r.CFRuleType.dataBar:return"3";case r.CFRuleType.colorScale:return"4";case r.CFRuleType.iconSet:return"6"}return L}),m=C.useRef(void 0),N=C.useMemo(()=>new s.InterceptorManager({beforeSubmit:Kr,submit:Xr}),[]),w=C.useMemo(()=>{switch(b){case"1":return gr;case"2":return zr;case"3":return $r;case"4":return Fr;case"5":return Br;case"6":return Yr;default:return gr}},[b]);C.useEffect(()=>{const U=t.onCommandExecuted(L=>{if(L.id===O.RemoveSheetMutation.id){const j=L.params;j.subUnitId===v&&j.unitId===i&&a.onCancel()}L.id===O.SetWorksheetActiveOperation.id&&a.onCancel()});return()=>U.dispose()},[]);const E=U=>{m.current=U},M=U=>{const L=U.split(",").filter(j=>!!j).map(je.deserializeRangeWithSheet).map(j=>j.range);o.current=L},R=()=>{if(d)return;const L=(()=>{const y=n.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET).getActiveSheet();if(!y)throw new Error("No active sheet found");return o.current.map(D=>O.setEndForRange(D,y.getRowCount(),y.getColumnCount())).filter(D=>!(Number.isNaN(D.startRow)||Number.isNaN(D.startColumn)))})();if(N.fetchThroughInterceptors(N.getInterceptPoints().beforeSubmit)(!0,null)){const y=N.fetchThroughInterceptors(N.getInterceptPoints().submit)(null,null);if(y){const x=mr(n),$=br(n);if(!x||!$)throw new Error("No active sheet found");let D={};a.rule&&a.rule.cfId?(D={...a.rule,ranges:L,rule:y},t.executeCommand(r.SetCfCommand.id,{unitId:x,subUnitId:$,rule:D}),a.onCancel()):(D={cfId:l.createCfId(x,$),ranges:L,rule:y,stopIfTrue:!1},t.executeCommand(r.AddCfCommand.id,{unitId:x,subUnitId:$,rule:D}),a.onCancel())}}},g=()=>{a.onCancel()},T=(U,L)=>{U?L.length<1?f(e.t("sheet.cf.errorMessage.rangeError")):f(void 0):f(e.t("sheet.cf.errorMessage.rangeError"))};return c.jsxs("div",{children:[c.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:e.t("sheet.cf.panel.range")}),c.jsxs("div",{className:"univer-mt-4",children:[c.jsx(ie.RangeSelector,{unitId:i,subUnitId:v,initialValue:p,onChange:(U,L)=>M(L),onVerify:T}),d&&c.jsx("div",{className:"univer-mt-1 univer-text-xs univer-text-red-500",children:d})]}),c.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:e.t("sheet.cf.panel.styleType")}),c.jsx(V.Select,{className:"univer-mt-4 univer-w-full",value:b,options:h,onChange:U=>S(U)}),c.jsx(w,{interceptorManager:N,rule:(k=a.rule)==null?void 0:k.rule,onChange:E}),c.jsxs("div",{className:"univer-mt-4 univer-flex univer-justify-end",children:[c.jsx(V.Button,{onClick:g,children:e.t("sheet.cf.panel.cancel")}),c.jsx(V.Button,{className:"univer-ml-3",variant:"primary",onClick:R,children:e.t("sheet.cf.panel.submit")})]})]})};var Qr=Object.getOwnPropertyDescriptor,et=(a,e,t,n)=>{for(var l=n>1?void 0:n?Qr(e,t):e,u=a.length-1,i;u>=0;u--)(i=a[u])&&(l=i(l)||l);return l},rt=(a,e)=>(t,n)=>e(t,n,a);let le=class extends s.Disposable{constructor(e){super();X(this,"_initLocal",()=>{});X(this,"_findReplaceIndex",e=>{const t=/\{([^}]+)?\}/g,n=[];let l=t.exec(e);for(;l;)n.push({startIndex:l.index,key:Number(l[1]),endIndex:l.index+l[0].length-1}),l=t.exec(e);return n});this._localeService=e,this._initLocal()}tWithReactNode(e,...t){const n=this._localeService.getLocales(),l=e.split("."),u=n&&this._localeService.resolveKeyPath(n,l);if(typeof u=="string"){const i=[];return this._findReplaceIndex(u).forEach((v,d,f)=>{const o=f[d-1]||{endIndex:-1};if(o.endIndex+1<v.startIndex){const p=u.slice(o.endIndex+1,v.startIndex);p&&i.push(p)}if(t[v.key]&&i.push(t[v.key]),d===f.length-1){const p=u.slice(v.endIndex+1);p&&i.push(p)}}),i}return[]}};le=et([rt(0,s.Inject(s.LocaleService))],le);const tt=(a,e)=>{const t=a.rule;switch(t.type){case r.CFRuleType.colorScale:return e.t("sheet.cf.ruleType.colorScale");case r.CFRuleType.dataBar:return e.t("sheet.cf.ruleType.dataBar");case r.CFRuleType.iconSet:return e.t("sheet.cf.ruleType.iconSet");case r.CFRuleType.highlightCell:switch(t.subType){case r.CFSubRuleType.average:{const n=t.operator;return e.t(`sheet.cf.preview.describe.${n}`,e.t("sheet.cf.subRuleType.average"))}case r.CFSubRuleType.duplicateValues:return e.t("sheet.cf.subRuleType.duplicateValues");case r.CFSubRuleType.uniqueValues:return e.t("sheet.cf.subRuleType.uniqueValues");case r.CFSubRuleType.number:{const n=t.operator;return e.t(`sheet.cf.preview.describe.${n}`,...Array.isArray(t.value)?t.value.map(l=>String(l)):[String(t.value||"")])}case r.CFSubRuleType.text:{const n=t.operator;return e.t(`sheet.cf.preview.describe.${n}`,t.value||"")}case r.CFSubRuleType.timePeriod:{const n=t.operator;return e.t(`sheet.cf.preview.describe.${n}`)}case r.CFSubRuleType.rank:return t.isPercent?t.isBottom?e.t("sheet.cf.preview.describe.bottomNPercent",String(t.value)):e.t("sheet.cf.preview.describe.topNPercent",String(t.value)):t.isBottom?e.t("sheet.cf.preview.describe.bottomN",String(t.value)):e.t("sheet.cf.preview.describe.topN",String(t.value));case r.CFSubRuleType.formula:return e.t("sheet.cf.ruleType.formula")}}},nt=a=>{const{onClick:e}=a,t=A.useDependency(r.ConditionalFormattingRuleModel),n=A.useDependency(s.IUniverInstanceService),l=A.useDependency(O.SheetsSelectionsService),u=A.useDependency(s.ICommandService),i=A.useDependency(s.LocaleService),v=A.useDependency(s.Injector),d=A.useDependency(le),f=A.useObservable(()=>n.getCurrentTypeOfUnit$(s.UniverInstanceType.UNIVER_SHEET),void 0,void 0,[]),o=f.getUnitId(),p=f.getActiveSheet();if(!p)throw new Error("No active sheet found");const h=p.getSheetId(),[b,S]=C.useState([]),[m,N]=C.useState("2"),[w,E]=C.useState(0),[M,R]=C.useState(""),g=[{label:i.t("sheet.cf.panel.workSheet"),value:"2"},{label:i.t("sheet.cf.panel.selectedRange"),value:"1"}],T=()=>{const D=t.getSubunitRules(o,h);if(!D||!D.length)return[];if(m==="1"){const F=l.getCurrentLastSelection();if(!F)return[];const H=F.range;return D.filter(Z=>Z.ranges.some(J=>s.Rectangle.intersects(J,H)))}else if(m==="2")return[...D];return[]},[_,I]=C.useState(T);q.useHighlightRange(b),C.useEffect(()=>{const D=u.onCommandExecuted(F=>{F.id===O.SetWorksheetActiveOperation.id&&E(Math.random())});return()=>D.dispose()}),C.useEffect(()=>{I(T)},[m,w,o,h]),C.useEffect(()=>{if(m==="2")return;const D=new K.Observable(F=>{const H=[O.SetSelectionsOperation.id,r.AddConditionalRuleMutation.id,r.SetConditionalRuleMutation.id,r.DeleteConditionalRuleMutation.id,r.MoveConditionalRuleMutation.id],W=u.onCommandExecuted(Z=>{const{id:J,params:re}=Z,z=n.getCurrentUnitOfType(s.UniverInstanceType.UNIVER_SHEET).getUnitId();H.includes(J)&&re.unitId===z&&F.next(null)});return()=>W.dispose()}).pipe(K.debounceTime(16)).subscribe(()=>{I(T)});return()=>{D.unsubscribe()}},[n,m,o,h]),C.useEffect(()=>{const D=t.$ruleChange.subscribe(()=>{E(Math.random())});return()=>D.unsubscribe()},[t]);const k=D=>{var W;const F=n.getCurrentUnitOfType(s.UniverInstanceType.UNIVER_SHEET).getUnitId(),H=(W=n.getCurrentUnitOfType(s.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:W.getSheetId();if(!F||!H)throw new Error("No active sheet found");u.executeCommand(r.DeleteCfCommand.id,{unitId:F,subUnitId:H,cfId:D.cfId})},U=(D,F)=>{var W;const H=x[F.y];R((W=H==null?void 0:H.cfId)!=null?W:"")},L=(D,F,H)=>{var tr,De,Le;R("");const W=n.getCurrentUnitOfType(s.UniverInstanceType.UNIVER_SHEET).getUnitId(),Z=(tr=n.getCurrentUnitOfType(s.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:tr.getSheetId();if(!W||!Z)throw new Error("No active sheet found");const J=jt=>{const At=x.length;return Math.min(At-1,Math.max(0,jt))},re=(De=x[J(F.y)])==null?void 0:De.cfId,z=(Le=x[J(H.y)])==null?void 0:Le.cfId;!re||!z||re!==z&&u.executeCommand(r.MoveCfCommand.id,{unitId:W,subUnitId:Z,start:{id:re,type:"self"},end:{id:z,type:H.y>F.y?"after":"before"}})},j=()=>{a.onCreate()},y=()=>{m==="2"?u.executeCommand(r.ClearWorksheetCfCommand.id):m==="1"&&_.map(F=>({unitId:o,subUnitId:h,cfId:F.cfId})).forEach(F=>{u.executeCommand(r.DeleteCfCommand.id,F)})},x=C.useMemo(()=>{const D=n.getCurrentUnitOfType(s.UniverInstanceType.UNIVER_SHEET),F=D.getActiveSheet();return _.filter(H=>{const W=H.ranges;return O.checkRangesEditablePermission(v,D.getUnitId(),F.getSheetId(),W)})},[_]),$=C.useMemo(()=>{const D=n.getCurrentUnitOfType(s.UniverInstanceType.UNIVER_SHEET),F=D.getActiveSheet();return _.every(H=>{const W=H.ranges;return O.checkRangesEditablePermission(v,D.getUnitId(),F.getSheetId(),W)})},[_]);return c.jsxs("div",{children:[c.jsxs("div",{className:`
2
2
  univer-mb-2 univer-flex univer-items-center univer-justify-between univer-gap-2 univer-text-sm
3
- `,children:[c.jsx("div",{className:"univer-flex univer-items-center univer-gap-2",children:d.tWithReactNode("sheet.cf.panel.managerRuleSelect",c.jsx(V.Select,{className:"univer-w-36",options:g,value:m,onChange:D=>{N(D)}})).map((D,F)=>c.jsx("span",{children:D},F))}),c.jsxs("div",{className:"univer-flex univer-justify-end univer-space-x-2",children:[c.jsx(V.Tooltip,{title:i.t("sheet.cf.panel.createRule"),placement:"bottom",children:c.jsx("a",{className:"univer-size-5 univer-cursor-pointer",onClick:j,children:c.jsx(ir,{})})}),_.length&&$?c.jsx(V.Tooltip,{title:i.t("sheet.cf.panel.clear"),placement:"bottom",children:c.jsx("a",{className:"univer-size-5 univer-cursor-pointer",onClick:y,children:c.jsx(Se,{className:"univer-text-red-500"})})}):c.jsx("div",{children:c.jsx(Se,{className:"univer-text-gray-300"})})]})]}),c.jsx("div",{children:c.jsx(V.DraggableList,{className:"univer-w-full",draggableHandle:".draggableHandle",list:x,onListChange:()=>{},idKey:"cfId",rowHeight:60,margin:[0,10],onDragStop:L,onDragStart:U,itemRender:D=>c.jsxs("div",{className:V.clsx("univer-group univer-relative univer-flex univer-items-center univer-justify-between univer-rounded univer-py-2 univer-pl-5 univer-pr-8 hover:univer-bg-gray-100 dark:hover:!univer-bg-gray-700",{"univer-bg-gray-100 dark:!univer-bg-gray-700":M===D.cfId}),onMouseMove:()=>{D.ranges!==b&&S(D.ranges)},onMouseLeave:()=>S([]),onClick:()=>{e(D)},children:[c.jsx("div",{className:V.clsx("univer-absolute univer-left-0 univer-hidden univer-size-5 univer-cursor-grab univer-items-center univer-justify-center univer-rounded group-hover:univer-flex","draggableHandle"),onClick:F=>F.stopPropagation(),children:c.jsx(cr,{})}),c.jsxs("div",{className:"univer-min-w-0 univer-max-w-full univer-flex-shrink univer-overflow-hidden",children:[c.jsx("div",{className:"univer-text-sm univer-text-gray-900 dark:!univer-text-white",children:tt(D,i)}),c.jsx("div",{className:"univer-text-xs univer-text-gray-400",children:D.ranges.map(F=>je.serializeRange(F)).join(",")})]}),c.jsx("div",{children:c.jsx(te,{rule:D.rule})}),c.jsx("div",{className:V.clsx("univer-absolute univer-right-1 univer-hidden univer-size-6 univer-cursor-pointer univer-items-center univer-justify-center univer-rounded univer-text-red-500 group-hover:univer-flex hover:univer-bg-gray-200",{"univer-flex univer-items-center univer-justify-center":M===D.cfId}),onClick:F=>{F.stopPropagation(),k(D),S([])},children:c.jsx(Se,{})})]})})})]})},lt=a=>{const[e,t]=C.useState(a.rule),[n,l]=C.useState(!!a.rule),u=()=>{l(!0)},i=()=>{l(!1),t(void 0)},v=d=>{t(d),l(!0)};return c.jsx("div",{className:"univer-flex univer-h-full univer-flex-col univer-justify-between univer-py-4",children:n?c.jsx(Jr,{onCancel:i,rule:e}):c.jsx(nt,{onClick:v,onCreate:u})})};var at=Object.getOwnPropertyDescriptor,ut=(a,e,t,n)=>{for(var l=n>1?void 0:n?at(e,t):e,u=a.length-1,i;u>=0;u--)(i=a[u])&&(l=i(l)||l);return l},de=(a,e)=>(t,n)=>e(t,n,a);const xe="sheet.conditional.formatting.panel";let ve=class extends s.Disposable{constructor(e,t,n,l,u){super();X(this,"_sidebarDisposable",null);this._univerInstanceService=e,this._injector=t,this._componentManager=n,this._sidebarService=l,this._localeService=u,this._initPanel(),this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(s.UniverInstanceType.UNIVER_SHEET).subscribe(i=>{var v;i||(v=this._sidebarDisposable)==null||v.dispose()})),this.disposeWithMe(this._sidebarService.sidebarOptions$.subscribe(i=>{i.id===xe&&(i.visible||setTimeout(()=>{this._sidebarService.sidebarOptions$.next({visible:!1})}))}))}openPanel(e){const t={id:xe,header:{title:this._localeService.t("sheet.cf.title")},children:{label:xe,rule:e,key:s.generateRandomId(4)},onClose:()=>this._sidebarDisposable=null};this._sidebarDisposable=this._sidebarService.open(t)}_initPanel(){this.disposeWithMe(this._componentManager.register(xe,lt))}};ve=ut([de(0,s.IUniverInstanceService),de(1,s.Inject(s.Injector)),de(2,s.Inject(A.ComponentManager)),de(3,s.Inject(A.ISidebarService)),de(4,s.Inject(s.LocaleService))],ve);var G=(a=>(a[a.createRule=1]="createRule",a[a.viewRule=2]="viewRule",a[a.highlightCell=3]="highlightCell",a[a.rank=4]="rank",a[a.formula=5]="formula",a[a.colorScale=6]="colorScale",a[a.dataBar=7]="dataBar",a[a.icon=8]="icon",a[a.clearRangeRules=9]="clearRangeRules",a[a.clearWorkSheetRules=10]="clearWorkSheetRules",a))(G||{});const pe={id:"sheet.operation.open.conditional.formatting.panel",type:s.CommandType.OPERATION,handler:(a,e)=>{var v;const t=a.get(ve),n=a.get(O.SheetsSelectionsService),l=a.get(s.ICommandService),u=((v=n.getCurrentSelections())==null?void 0:v.map(d=>d.range))||[];switch(e.value){case 3:{t.openPanel({...r.createDefaultRule(),ranges:u});break}case 4:{const d={...r.createDefaultRule,ranges:u,rule:{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.rank}};t.openPanel(d);break}case 5:{const d={...r.createDefaultRule,ranges:u,rule:{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.formula,value:"="}};t.openPanel(d);break}case 6:{const d={...r.createDefaultRule,ranges:u,rule:{type:r.CFRuleType.colorScale,config:[]}};t.openPanel(d);break}case 7:{const d={...r.createDefaultRule,ranges:u,rule:{type:r.CFRuleType.dataBar,isShowValue:!0}};t.openPanel(d);break}case 8:{const d={...r.createDefaultRule,ranges:u,rule:{type:r.CFRuleType.iconSet,config:[],isShowValue:!0}};t.openPanel(d);break}case 2:{t.openPanel();break}case 1:{t.openPanel({...r.createDefaultRule(),ranges:u});break}case 9:{l.executeCommand(r.ClearRangeCfCommand.id,{ranges:u});break}case 10:{l.executeCommand(r.ClearWorksheetCfCommand.id);break}}return!0}};var it=Object.getOwnPropertyDescriptor,st=(a,e,t,n)=>{for(var l=n>1?void 0:n?it(e,t):e,u=a.length-1,i;u>=0;u--)(i=a[u])&&(l=i(l)||l);return l},fe=(a,e)=>(t,n)=>e(t,n,a);P.ConditionalFormattingClearController=class extends s.Disposable{constructor(e,t,n,l,u){super(),this._injector=e,this._univerInstanceService=t,this._sheetInterceptorService=n,this._selectionManagerService=l,this._conditionalFormattingRuleModel=u,this._init()}_init(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:e=>{var u;const t=[],n=[],l={redos:t,undos:n};if([O.ClearSelectionFormatCommand.id,O.ClearSelectionAllCommand.id].includes(e.id)){const i=(u=this._selectionManagerService.getCurrentSelections())==null?void 0:u.map(S=>S.range);if(!i)return l;const v=this._univerInstanceService.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET),d=v.getActiveSheet();if(!d)return l;const f=v.getUnitId(),o=d.getSheetId(),p=this._conditionalFormattingRuleModel.getSubunitRules(f,o);if(!p||!p.length)return l;const{redos:h,undos:b}=Ir(this._injector,p,i,f,o);t.push(...h),n.push(...b)}return l}})),this.disposeWithMe(this._sheetInterceptorService.interceptRanges({getMutations:({unitId:e,subUnitId:t,ranges:n})=>{const l=[],u=[],i={redos:l,undos:u};if(!n||!n.length)return i;const v=this._conditionalFormattingRuleModel.getSubunitRules(e,t);if(!v||!v.length)return i;const{redos:d,undos:f}=Ir(this._injector,v,n,e,t);return l.push(...d),u.push(...f),i}}))}},P.ConditionalFormattingClearController=st([fe(0,s.Inject(s.Injector)),fe(1,s.Inject(s.IUniverInstanceService)),fe(2,s.Inject(O.SheetInterceptorService)),fe(3,s.Inject(O.SheetsSelectionsService)),fe(4,s.Inject(r.ConditionalFormattingRuleModel))],P.ConditionalFormattingClearController);function Ir(a,e,t,n,l){const u=[],i=[];return e.filter(v=>t.some(d=>v.ranges.some(f=>s.Rectangle.getIntersects(f,d)))).forEach(v=>{const f=new O.RangeMergeUtil().add(...v.ranges).subtract(...t).merge();if(f.length){const o={id:r.SetConditionalRuleMutation.id,params:{unitId:n,subUnitId:l,rule:{...v,ranges:f}}},p=r.setConditionalRuleMutationUndoFactory(a,o.params);u.push(o),i.push(...p)}else{const o={id:r.DeleteConditionalRuleMutation.id,params:{unitId:n,subUnitId:l,cfId:v.cfId}},p=r.DeleteConditionalRuleMutationUndoFactory(a,o.params);u.push(o),i.push(...p)}}),{redos:u,undos:i}}const Ne={name:"@univerjs/sheets-conditional-formatting-ui",version:"0.16.1-insiders.20260311-074e8ca"},Sr="sheets-conditional-formatting-ui.config",Ee={};var ct=Object.getOwnPropertyDescriptor,ot=(a,e,t,n)=>{for(var l=n>1?void 0:n?ct(e,t):e,u=a.length-1,i;u>=0;u--)(i=a[u])&&(l=i(l)||l);return l},Xe=(a,e)=>(t,n)=>e(t,n,a);let he=class extends s.Disposable{constructor(e,t,n){super();X(this,"_disposableMap",new Map);this._conditionalFormattingRuleModel=e,this._formulaRefRangeService=t,this._injector=n,this._initRefRange()}_getIdWithUnitId(e,t,n){return`${e}_${t}_${n}`}_getRuleFormulas(e){const t=[],n=e.rule;switch(n.type){case r.CFRuleType.highlightCell:n.subType===r.CFSubRuleType.formula&&t.push(n.value);break;case r.CFRuleType.dataBar:{const l=n;l.config.min.type===r.CFValueType.formula&&t.push(l.config.min.value),l.config.max.type===r.CFValueType.formula&&t.push(l.config.max.value);break}case r.CFRuleType.colorScale:{n.config.forEach(u=>{u.value.type===r.CFValueType.formula&&t.push(u.value.value)});break}case r.CFRuleType.iconSet:{n.config.forEach(u=>{u.value.type===r.CFValueType.formula&&t.push(u.value.value)});break}}return t}_updateRuleFormulas(e,t){const n=s.Tools.deepClone(e),l=n.rule;let u=0;switch(l.type){case r.CFRuleType.highlightCell:l.subType===r.CFSubRuleType.formula&&(l.value=t[u++]);break;case r.CFRuleType.dataBar:{const i=l;i.config.min.type===r.CFValueType.formula&&(i.config.min.value=t[u++]),i.config.max.type===r.CFValueType.formula&&(i.config.max.value=t[u++]);break}case r.CFRuleType.colorScale:{l.config.forEach(v=>{v.value.type===r.CFValueType.formula&&(v.value.value=t[u++])});break}case r.CFRuleType.iconSet:{l.config.forEach(v=>{v.value.type===r.CFValueType.formula&&(v.value.value=t[u++])});break}}return n}register(e,t,n){const l=n.ranges,u=this._getRuleFormulas(n),i=this._formulaRefRangeService.registerRangeFormula(e,t,l,u,d=>{if(d.length===0)return{undos:[{id:r.AddConditionalRuleMutation.id,params:{unitId:e,subUnitId:t,rule:n}}],redos:[{id:r.DeleteConditionalRuleMutation.id,params:{unitId:e,subUnitId:t,cfId:n.cfId}}]};const f=[],o=[],p=d[0],h=this._updateRuleFormulas(n,p.formulas);h.ranges=p.ranges,f.push({id:r.SetConditionalRuleMutation.id,params:{unitId:e,subUnitId:t,cfId:n.cfId,rule:h}}),o.push(...r.setConditionalRuleMutationUndoFactory(this._injector,{unitId:e,subUnitId:t,cfId:n.cfId,rule:h}));for(let b=1;b<d.length;b++){const S=d[b],m=r.createCfId(),N=this._updateRuleFormulas(n,S.formulas);N.cfId=m,N.ranges=S.ranges,f.push({id:r.AddConditionalRuleMutation.id,params:{unitId:e,subUnitId:t,rule:N}}),o.push(r.AddConditionalRuleMutationUndoFactory(this._injector,{unitId:e,subUnitId:t,rule:N}))}return{undos:o,redos:f}}),v=this._getIdWithUnitId(e,t,n.cfId);this._disposableMap.set(v,i)}_initRefRange(){const e=this._conditionalFormattingRuleModel.getAll();for(const[t,n]of e)for(const[l,u]of n)for(const i of u)this.register(t,l,i);this.disposeWithMe(this._conditionalFormattingRuleModel.$ruleChange.subscribe(t=>{const{unitId:n,subUnitId:l,rule:u}=t;switch(t.type){case"add":{this.register(n,l,u);break}case"delete":{const i=this._getIdWithUnitId(n,l,u.cfId),v=this._disposableMap.get(i);v&&(v.dispose(),this._disposableMap.delete(i));break}case"set":{const i=this._getIdWithUnitId(n,l,u.cfId),v=this._disposableMap.get(i);v&&(v.dispose(),this._disposableMap.delete(i)),this.register(n,l,u);break}}})),this.disposeWithMe(s.toDisposable(()=>{this._disposableMap.forEach(t=>{t.dispose()}),this._disposableMap.clear()}))}};he=ot([Xe(0,s.Inject(r.ConditionalFormattingRuleModel)),Xe(1,s.Inject(nr.FormulaRefRangeService)),Xe(2,s.Inject(s.Injector))],he);var dt=Object.getOwnPropertyDescriptor,vt=(a,e,t,n)=>{for(var l=n>1?void 0:n?dt(e,t):e,u=a.length-1,i;u>=0;u--)(i=a[u])&&(l=i(l)||l);return l},ge=(a,e)=>(t,n)=>e(t,n,a);let ye=class extends s.Disposable{constructor(e,t,n,l,u){super();X(this,"_copyInfo");this._sheetClipboardService=e,this._conditionalFormattingRuleModel=t,this._injector=n,this._conditionalFormattingViewModel=l,this._univerInstanceService=u,this._initClipboardHook()}_initClipboardHook(){this.disposeWithMe(this._sheetClipboardService.addClipboardHook({id:r.SHEET_CONDITIONAL_FORMATTING_PLUGIN,onBeforeCopy:(e,t,n)=>this._collectConditionalRule(e,t,n),onPasteCells:(e,t,n,l)=>{const{copyType:u=q.COPY_TYPE.COPY,pasteType:i}=l,{range:v}=e||{},{range:d}=t;return this._generateConditionalFormattingMutations(d,{copyType:u,pasteType:i,copyRange:v})}}))}_collectConditionalRule(e,t,n){const l=new s.ObjectMatrix,u={};this._copyInfo={matrix:l,info:{unitId:e,subUnitId:t,cfMap:u}};const i=this._injector.invoke(o=>O.rangeToDiscreteRange(n,o,e,t));if(!i)return;const{rows:v,cols:d}=i,f=new Set;v.forEach((o,p)=>{d.forEach((h,b)=>{const S=this._conditionalFormattingViewModel.getCellCfs(e,t,o,h);S&&(S.forEach(m=>f.add(m.cfId)),l.setValue(p,b,S.map(m=>m.cfId)))})}),f.forEach(o=>{const p=this._conditionalFormattingRuleModel.getRule(e,t,o);p&&(u[o]=p.rule)})}_generateConditionalFormattingMutations(e,t){const n=this._univerInstanceService.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET),l=n.getActiveSheet(),u=n.getUnitId();if(!l)return{redos:[],undos:[]};const i=l.getSheetId();if(t.copyType===q.COPY_TYPE.CUT)return this._copyInfo=null,{redos:[],undos:[]};if(!this._copyInfo||!t.copyRange)return{redos:[],undos:[]};if(![q.PREDEFINED_HOOK_NAME_PASTE.SPECIAL_PASTE_FORMAT,q.PREDEFINED_HOOK_NAME_PASTE.DEFAULT_PASTE,q.PREDEFINED_HOOK_NAME_PASTE.SPECIAL_PASTE_BESIDES_BORDER].includes(t.pasteType))return{redos:[],undos:[]};const{ranges:[d,f],mapFunc:o}=q.virtualizeDiscreteRanges([t.copyRange,e]),p=q.getRepeatRange(d,f,!0),h={};s.Range.foreach(f,(g,T)=>{const{row:_,col:I}=o(g,T),k=this._conditionalFormattingViewModel.getCellCfs(u,i,_,I);k&&k.forEach(U=>{if(!h[U.cfId]){const L=new s.ObjectMatrix;h[U.cfId]=L;const j=this._conditionalFormattingRuleModel.getRule(u,i,U.cfId);j==null||j.ranges.forEach(y=>{s.Range.foreach(y,(x,$)=>{L.setValue(x,$,1)})})}h[U.cfId].realDeleteValue(_,I)})});const{matrix:b,info:S}=this._copyInfo,m=[];let N=this._conditionalFormattingRuleModel.createCfId(u,i);const w={},E=g=>{if(w[g])return w[g];const T=S==null?void 0:S.cfMap[g],_=[...this._conditionalFormattingRuleModel.getSubunitRules(u,i)||[],...m].find(I=>s.Tools.diffValue(I.rule,T));if(_)return w[g]=_,_;{const I={rule:T,cfId:N,ranges:[],stopIfTrue:!1};return w[g]=I,m.push(I),N=`${Number(N)+1}`,I}};p.forEach(g=>{b&&b.forValue((T,_,I)=>{const k=s.Rectangle.getPositionRange({startRow:T,endRow:T,startColumn:_,endColumn:_},g.startRange),{row:U,col:L}=o(k.startRow,k.startColumn);I.forEach(j=>{if(!h[j]){const y=E(j),x=new s.ObjectMatrix;h[j]=x,y.ranges.forEach($=>{s.Range.foreach($,(D,F)=>{x.setValue(D,F,1)})})}h[j].setValue(U,L,1)})})});const M=[],R=[];for(const g in h){const T=h[g],_=O.findAllRectangle(O.createTopMatrixFromMatrix(T));if(!_.length){const I={unitId:u,subUnitId:i,cfId:g};M.push({id:r.DeleteConditionalRuleMutation.id,params:I}),R.push(...r.DeleteConditionalRuleMutationUndoFactory(this._injector,I))}if(m.some(I=>I.cfId===g)){const I=E(g),k={unitId:u,subUnitId:i,rule:{...I,ranges:_}};M.push({id:r.AddConditionalRuleMutation.id,params:k}),R.push(r.AddConditionalRuleMutationUndoFactory(this._injector,k))}else{const I=this._conditionalFormattingRuleModel.getRule(u,i,g);if(!I)continue;const k={unitId:u,subUnitId:i,rule:{...I,ranges:_}};M.push({id:r.SetConditionalRuleMutation.id,params:k}),R.push(...r.setConditionalRuleMutationUndoFactory(this._injector,k))}}return{redos:M,undos:R}}};ye=vt([ge(0,s.Inject(q.ISheetClipboardService)),ge(1,s.Inject(r.ConditionalFormattingRuleModel)),ge(2,s.Inject(s.Injector)),ge(3,s.Inject(r.ConditionalFormattingViewModel)),ge(4,s.Inject(s.IUniverInstanceService))],ye);var pt=Object.getOwnPropertyDescriptor,ft=(a,e,t,n)=>{for(var l=n>1?void 0:n?pt(e,t):e,u=a.length-1,i;u>=0;u--)(i=a[u])&&(l=i(l)||l);return l},Je=(a,e)=>(t,n)=>e(t,n,a);let Ce=class extends s.Disposable{constructor(a,e,t){super(),this._localeService=a,this._commandService=e,this._sheetPermissionCheckController=t,this._commandExecutedListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.beforeCommandExecuted(a=>{if(a.id===r.AddCfCommand.id){const{unitId:e,subUnitId:t,rule:{ranges:n}}=a.params;this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[O.WorkbookEditablePermission],rangeTypes:[O.RangeProtectionPermissionEditPoint],worksheetTypes:[O.WorksheetEditPermission,O.WorksheetSetCellStylePermission]},n,e,t)||this._sheetPermissionCheckController.blockExecuteWithoutPermission(this._localeService.t("permission.dialog.setStyleErr"))}}))}};Ce=ft([Je(0,s.Inject(s.LocaleService)),Je(1,s.ICommandService),Je(2,s.Inject(O.SheetPermissionCheckController))],Ce);var ht=Object.getOwnPropertyDescriptor,gt=(a,e,t,n)=>{for(var l=n>1?void 0:n?ht(e,t):e,u=a.length-1,i;u>=0;u--)(i=a[u])&&(l=i(l)||l);return l},ae=(a,e)=>(t,n)=>e(t,n,a);let me=class extends s.Disposable{constructor(e,t,n,l,u,i){super();X(this,"_ruleChangeCacheMap",new Map);this._sheetInterceptorService=e,this._conditionalFormattingService=t,this._univerInstanceService=n,this._renderManagerService=l,this._conditionalFormattingViewModel=u,this._conditionalFormattingRuleModel=i,this._initViewModelInterceptor(),this._initSkeleton(),this.disposeWithMe(()=>{this._ruleChangeCacheMap.clear()})}_markDirtySkeleton(){var t,n,l;const e=this._univerInstanceService.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET).getUnitId();(t=this._renderManagerService.getRenderById(e))==null||t.with(q.SheetSkeletonManagerService).reCalculate(),(l=(n=this._renderManagerService.getRenderById(e))==null?void 0:n.mainComponent)==null||l.makeDirty()}_initSkeleton(){this.disposeWithMe(K.merge(this._conditionalFormattingRuleModel.$ruleChange,this._conditionalFormattingViewModel.markDirty$).pipe(se.bufferTime(16),se.filter(e=>!!e.length),se.filter(e=>{const t=this._univerInstanceService.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET);if(!t)return!1;const n=t.getActiveSheet();return n?e.filter(l=>l.unitId===t.getUnitId()&&l.subUnitId===n.getSheetId()).length>0:!1})).subscribe(()=>this._markDirtySkeleton()))}_initViewModelInterceptor(){this.disposeWithMe(this._sheetInterceptorService.intercept(O.INTERCEPTOR_POINT.CELL_CONTENT,{effect:s.InterceptorEffectEnum.Style,handler:(e,t,n)=>{const l=this._conditionalFormattingService.composeStyle(t.unitId,t.subUnitId,t.row,t.col);if(!l)return n(e);const u=t.workbook.getStyles(),i=(typeof(e==null?void 0:e.s)=="string"?u.get(e==null?void 0:e.s):e==null?void 0:e.s)||{},v=e===t.rawData?{...t.rawData}:e;if(l.style){const d={...i,...l.style};Object.assign(v,{s:d})}return v.fontRenderExtension||(v.fontRenderExtension={},l.isShowValue!==void 0&&(v.fontRenderExtension.isSkip=!l.isShowValue)),l.dataBar&&(v.dataBar=l.dataBar),l.iconSet&&(v.iconSet=l.iconSet,v.fontRenderExtension.leftOffset=r.DEFAULT_PADDING+r.DEFAULT_WIDTH),n(v)},priority:10}))}};me=gt([ae(0,s.Inject(O.SheetInterceptorService)),ae(1,s.Inject(r.ConditionalFormattingService)),ae(2,s.Inject(s.IUniverInstanceService)),ae(3,s.Inject(lr.IRenderManagerService)),ae(4,s.Inject(r.ConditionalFormattingViewModel)),ae(5,s.Inject(r.ConditionalFormattingRuleModel))],me);var yt=Object.defineProperty,Ct=Object.getOwnPropertyDescriptor,mt=(a,e,t)=>e in a?yt(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t,bt=(a,e,t,n)=>{for(var l=n>1?void 0:n?Ct(e,t):e,u=a.length-1,i;u>=0;u--)(i=a[u])&&(l=i(l)||l);return l},Qe=(a,e)=>(t,n)=>e(t,n,a),Re=(a,e,t)=>mt(a,typeof e!="symbol"?e+"":e,t);P.UniverSheetsConditionalFormattingMobileUIPlugin=class extends s.Plugin{constructor(e=Ee,t,n,l){super(),this._config=e,this._injector=t,this._commandService=n,this._configService=l;const{menu:u,...i}=s.merge({},Ee,this._config);u&&this._configService.setConfig("menu",u,{merge:!0}),this._configService.setConfig(Sr,i),this._initCommand(),this._injector.add([me]),this._injector.add([ye]),this._injector.add([Ce]),this._injector.add([le]),this._injector.add([he])}_initCommand(){[Ae,Fe,$e,Be,He,We,qe,Ge,Ze,pe].forEach(e=>{this._commandService.registerCommand(e)})}},Re(P.UniverSheetsConditionalFormattingMobileUIPlugin,"pluginName",`${r.SHEET_CONDITIONAL_FORMATTING_PLUGIN}_MOBILE_UI_PLUGIN`),Re(P.UniverSheetsConditionalFormattingMobileUIPlugin,"packageName",Ne.name),Re(P.UniverSheetsConditionalFormattingMobileUIPlugin,"version",Ne.version),Re(P.UniverSheetsConditionalFormattingMobileUIPlugin,"type",s.UniverInstanceType.UNIVER_SHEET),P.UniverSheetsConditionalFormattingMobileUIPlugin=bt([s.DependentOn(r.UniverSheetsConditionalFormattingPlugin),Qe(1,s.Inject(s.Injector)),Qe(2,s.Inject(s.ICommandService)),Qe(3,s.IConfigService)],P.UniverSheetsConditionalFormattingMobileUIPlugin);var It=Object.getOwnPropertyDescriptor,St=(a,e,t,n)=>{for(var l=n>1?void 0:n?It(e,t):e,u=a.length-1,i;u>=0;u--)(i=a[u])&&(l=i(l)||l);return l},be=(a,e)=>(t,n)=>e(t,n,a);let Me=class extends s.Disposable{constructor(a,e,t,n,l){super(),this._injector=a,this._univerInstanceService=e,this._autoFillService=t,this._conditionalFormattingRuleModel=n,this._conditionalFormattingViewModel=l,this._initAutoFill()}_initAutoFill(){const a=()=>({redos:[],undos:[]}),e=(l,u,i,v,d)=>{var b;const f=this._univerInstanceService.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET).getUnitId(),o=(b=this._univerInstanceService.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:b.getSheetId();if(!f||!o)return;const p={startRow:l.row,startColumn:l.col,endColumn:l.col,endRow:l.row},h={startRow:u.row,startColumn:u.col,endColumn:u.col,endRow:u.row};s.Range.foreach(i,(S,m)=>{const N=s.Rectangle.getPositionRange({startRow:S,startColumn:m,endColumn:m,endRow:S},p),w=s.Rectangle.getPositionRange({startRow:S,startColumn:m,endColumn:m,endRow:S},h),{row:E,col:M}=d(N.startRow,N.startColumn),R=this._conditionalFormattingViewModel.getCellCfs(f,o,E,M),{row:g,col:T}=d(w.startRow,w.startColumn),_=this._conditionalFormattingViewModel.getCellCfs(f,o,g,T);_&&_.forEach(I=>{let k=v.get(I.cfId);if(!v.get(I.cfId)){const U=this._conditionalFormattingRuleModel.getRule(f,o,I.cfId);if(!U)return;k=new s.ObjectMatrix,U.ranges.forEach(L=>{s.Range.foreach(L,(j,y)=>{k.setValue(j,y,1)})}),v.set(I.cfId,k)}k.realDeleteValue(g,T)}),R&&R.forEach(I=>{let k=v.get(I.cfId);if(!v.get(I.cfId)){const U=this._conditionalFormattingRuleModel.getRule(f,o,I.cfId);if(!U)return;k=new s.ObjectMatrix,U.ranges.forEach(L=>{s.Range.foreach(L,(j,y)=>{k.setValue(j,y,1)})}),v.set(I.cfId,k)}k.setValue(g,T,1)})})},t=(l,u)=>{var w,E,M;const i=(w=this._univerInstanceService.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET))==null?void 0:w.getUnitId(),v=(M=(E=this._univerInstanceService.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET))==null?void 0:E.getActiveSheet())==null?void 0:M.getSheetId(),d=new Map,f=[],o=[];if(!i||!v)return a();const p=q.virtualizeDiscreteRanges([l,u]),[h,b]=p.ranges,{mapFunc:S}=p,m={row:h.startRow,col:h.startColumn};return O.AutoFillTools.getAutoFillRepeatRange(h,b).forEach(R=>{e(m,R.repeatStartCell,R.relativeRange,d,S)}),d.forEach((R,g)=>{const T=this._conditionalFormattingRuleModel.getRule(i,v,g);if(!T)return;const _=O.findAllRectangle(O.createTopMatrixFromMatrix(R));if(_.length){const I={unitId:i,subUnitId:v,rule:{...T,ranges:_}};f.push({id:r.SetConditionalRuleMutation.id,params:I}),o.push(...r.setConditionalRuleMutationUndoFactory(this._injector,I))}else{const I={unitId:i,subUnitId:v,cfId:T.cfId};f.push({id:r.DeleteConditionalRuleMutation.id,params:I}),o.push(...r.DeleteConditionalRuleMutationUndoFactory(this._injector,I))}}),{undos:o,redos:f}},n={id:r.SHEET_CONDITIONAL_FORMATTING_PLUGIN,onFillData:(l,u,i)=>{if(i===O.AUTO_FILL_APPLY_TYPE.COPY||i===O.AUTO_FILL_APPLY_TYPE.ONLY_FORMAT||i===O.AUTO_FILL_APPLY_TYPE.SERIES){const{source:v,target:d}=l;return t(v,d)}return a()}};this.disposeWithMe(this._autoFillService.addHook(n))}};Me=St([be(0,s.Inject(s.Injector)),be(1,s.Inject(s.IUniverInstanceService)),be(2,s.Inject(O.IAutoFillService)),be(3,s.Inject(r.ConditionalFormattingRuleModel)),be(4,s.Inject(r.ConditionalFormattingViewModel))],Me);var Tt=Object.getOwnPropertyDescriptor,_t=(a,e,t,n)=>{for(var l=n>1?void 0:n?Tt(e,t):e,u=a.length-1,i;u>=0;u--)(i=a[u])&&(l=i(l)||l);return l},Tr=(a,e)=>(t,n)=>e(t,n,a);let Ve=class extends s.Disposable{constructor(a,e){super(),this._sheetInterceptorService=a,this._conditionalFormattingService=e,this._initInterceptorEditorEnd()}_initInterceptorEditorEnd(){this.disposeWithMe(s.toDisposable(this._sheetInterceptorService.writeCellInterceptor.intercept(O.AFTER_CELL_EDIT,{handler:(a,e,t)=>{var i,v,d;a||t(a);const n=this._conditionalFormattingService.composeStyle(e.unitId,e.subUnitId,e.row,e.col),l=(i=n==null?void 0:n.style)!=null?i:{},u=Object.keys(l);if(a!=null&&a.p)return(d=(v=a.p.body)==null?void 0:v.textRuns)==null||d.forEach(f=>{f.ts&&u.forEach(o=>{var p;(p=f.ts)==null||delete p[o]})}),t(a);{const f={...(typeof(a==null?void 0:a.s)=="string"?e.workbook.getStyles().get(a.s):a==null?void 0:a.s)||{}};u.forEach(p=>{delete f[p]});const o={...a,s:{...f}};return t(o)}}})))}};Ve=_t([Tr(0,s.Inject(O.SheetInterceptorService)),Tr(1,s.Inject(r.ConditionalFormattingService))],Ve);var wt=Object.getOwnPropertyDescriptor,xt=(a,e,t,n)=>{for(var l=n>1?void 0:n?wt(e,t):e,u=a.length-1,i;u>=0;u--)(i=a[u])&&(l=i(l)||l);return l},ue=(a,e)=>(t,n)=>e(t,n,a);const Nt=(a,e)=>{const t=o=>o.endRow-o.startRow+1,n=o=>o.endColumn-o.startColumn+1,l=t(e)%t(a),u=n(e)%n(a),i=Math.floor(t(e)/t(a)),v=Math.floor(n(e)/n(a)),d=[],f={startRow:0,endRow:t(a)-1,startColumn:0,endColumn:n(a)-1};if(t(e)===1&&n(e)===1){const o={startRow:e.startRow,endRow:e.startRow,startColumn:e.startColumn,endColumn:e.startColumn};return d.push({repeatRelativeRange:f,startRange:o}),d}for(let o=0;o<i+(l?.1:0);o++)for(let p=0;p<v+(u?.1:0);p++){const h=t(a)*o,b=n(a)*p,S={startRow:h+e.startRow,endRow:h+e.startRow,startColumn:b+e.startColumn,endColumn:b+e.startColumn};let m=f;o===i&&l&&(m={...m},m.endRow=m.endRow-(t(a)-l)),p===v&&u&&(m={...m},m.endColumn=m.endColumn-(n(a)-u)),d.push({repeatRelativeRange:m,startRange:S})}return d};let Oe=class extends s.Disposable{constructor(e,t,n,l,u,i){super();X(this,"_painterConfig",null);this._injector=e,this._univerInstanceService=t,this._formatPainterService=n,this._sheetsSelectionsService=l,this._conditionalFormattingRuleModel=u,this._conditionalFormattingViewModel=i,this._initFormattingPainter()}_initFormattingPainter(){const e=()=>({redos:[],undos:[]}),t=(u,i,v,d,f)=>{const{unitId:o,subUnitId:p}=this._painterConfig,{targetUnitId:h,targetSubUnitId:b}=f,S={startRow:u.row,startColumn:u.col,endColumn:u.col,endRow:u.row},m={startRow:i.row,startColumn:i.col,endColumn:i.col,endRow:i.row};s.Range.foreach(v,(N,w)=>{const E=s.Rectangle.getPositionRange({startRow:N,startColumn:w,endColumn:w,endRow:N},S),M=s.Rectangle.getPositionRange({startRow:N,startColumn:w,endColumn:w,endRow:N},m),R=this._conditionalFormattingViewModel.getCellCfs(o,p,E.startRow,E.startColumn),g=this._conditionalFormattingViewModel.getCellCfs(h,b,M.startRow,M.startColumn);g&&g.forEach(T=>{let _=d.get(T.cfId);if(!d.get(T.cfId)){const I=this._conditionalFormattingRuleModel.getRule(h,b,T.cfId);if(!I)return;_=new s.ObjectMatrix,I.ranges.forEach(k=>{s.Range.foreach(k,(U,L)=>{_.setValue(U,L,1)})}),d.set(T.cfId,_)}_.realDeleteValue(M.startRow,M.startColumn)}),R&&R.forEach(T=>{const _=d.get(T.cfId);_&&_.setValue(M.startRow,M.startColumn,1)})})},n=(u,i,v)=>{var E;const{range:d,unitId:f,subUnitId:o}=this._painterConfig,p=u!==f||o!==i,h=new Map,b=[],S=[];if(!u||!i||!f||!o)return e();const m=(E=this._conditionalFormattingRuleModel.getSubunitRules(f,o))!=null?E:[];m==null||m.forEach(M=>{const{ranges:R,cfId:g}=M;if(R.some(T=>s.Rectangle.intersects(d,T))){const T=new s.ObjectMatrix;p||R.forEach(_=>{s.Range.foreach(_,(I,k)=>{T.setValue(I,k,1)})}),h.set(g,T)}});const N={row:d.startRow,col:d.startColumn};return Nt(d,v).forEach(M=>{t(N,{row:M.startRange.startRow,col:M.startRange.startColumn},M.repeatRelativeRange,h,{targetUnitId:u,targetSubUnitId:i})}),h.forEach((M,R)=>{if(p){const g=this._conditionalFormattingRuleModel.getRule(u,i,R),T=O.findAllRectangle(O.createTopMatrixFromMatrix(M));if(g)if(T.length){const _={unitId:u,subUnitId:i,rule:{...g,ranges:T}};b.push({id:r.SetConditionalRuleMutation.id,params:_}),S.push(...r.setConditionalRuleMutationUndoFactory(this._injector,_))}else{const _={unitId:u,subUnitId:i,cfId:g.cfId};b.push({id:r.DeleteConditionalRuleMutation.id,params:_}),S.push(...r.DeleteConditionalRuleMutationUndoFactory(this._injector,_))}else if(T.length){const _=this._conditionalFormattingRuleModel.getRule(f,o,R);if(_){const I={unitId:u,subUnitId:i,rule:{...s.Tools.deepClone(_),cfId:this._conditionalFormattingRuleModel.createCfId(u,i),ranges:T}};b.push({id:r.AddConditionalRuleMutation.id,params:I}),S.push(r.AddConditionalRuleMutationUndoFactory(this._injector,I))}}}else{const g=this._conditionalFormattingRuleModel.getRule(f,o,R);if(!g)return;const T=O.findAllRectangle(O.createTopMatrixFromMatrix(M));if(T.length){const _={unitId:f,subUnitId:o,rule:{...g,ranges:T}};b.push({id:r.SetConditionalRuleMutation.id,params:_}),S.push(...r.setConditionalRuleMutationUndoFactory(this._injector,_))}else{const _={unitId:f,subUnitId:o,cfId:g.cfId};b.push({id:r.DeleteConditionalRuleMutation.id,params:_}),S.push(...r.DeleteConditionalRuleMutationUndoFactory(this._injector,_))}}}),{undos:S,redos:b}},l={id:r.SHEET_CONDITIONAL_FORMATTING_PLUGIN,onStatusChange:u=>{var i,v,d;switch(u){case q.FormatPainterStatus.INFINITE:case q.FormatPainterStatus.ONCE:{const f=(i=this._univerInstanceService.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET))==null?void 0:i.getUnitId(),o=(d=(v=this._univerInstanceService.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET))==null?void 0:v.getActiveSheet())==null?void 0:d.getSheetId(),p=this._sheetsSelectionsService.getCurrentLastSelection(),h=p==null?void 0:p.range;f&&o&&h&&(this._painterConfig={unitId:f,subUnitId:o,range:h});break}case q.FormatPainterStatus.OFF:{this._painterConfig=null;break}}},onApply:(u,i,v)=>this._painterConfig?n(u,i,v):{redos:[],undos:[]}};this._formatPainterService.addHook(l)}};Oe=xt([ue(0,s.Inject(s.Injector)),ue(1,s.Inject(s.IUniverInstanceService)),ue(2,s.Inject(q.IFormatPainterService)),ue(3,s.Inject(O.SheetsSelectionsService)),ue(4,s.Inject(r.ConditionalFormattingRuleModel)),ue(5,s.Inject(r.ConditionalFormattingViewModel))],Oe);var Et=Object.getOwnPropertyDescriptor,Rt=(a,e,t,n)=>{for(var l=n>1?void 0:n?Et(e,t):e,u=a.length-1,i;u>=0;u--)(i=a[u])&&(l=i(l)||l);return l},er=(a,e)=>(t,n)=>e(t,n,a);let Ue=class extends s.Disposable{constructor(a,e,t){super(),this._conditionalFormattingViewModel=a,this._univerInstanceService=e,this._renderManagerService=t,this._init()}_init(){const a=this._univerInstanceService.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET),e=t=>{const n=t.getUnitId(),l=this._renderManagerService.getRenderById(n);if(!l)return;const u=l.with(q.SheetSkeletonManagerService);this.disposeWithMe(u.currentSkeleton$.subscribe(i=>{if(i){const v=i.skeleton.rowColumnSegment,d=v.endColumn-v.startColumn+1,o=(v.endRow-v.startRow+1)*d*9,p=Math.max(r.CONDITIONAL_FORMATTING_VIEWPORT_CACHE_LENGTH,o);this._conditionalFormattingViewModel.setCacheLength(p)}}))};a&&e(a),this._univerInstanceService.getCurrentTypeOfUnit$(s.UniverInstanceType.UNIVER_SHEET).subscribe(t=>{t&&e(t)})}};Ue=Rt([er(0,s.Inject(r.ConditionalFormattingViewModel)),er(1,s.IUniverInstanceService),er(2,lr.IRenderManagerService)],Ue);const _r=[O.SetWorksheetActiveOperation.id,r.AddConditionalRuleMutation.id,r.SetConditionalRuleMutation.id,r.DeleteConditionalRuleMutation.id,r.MoveConditionalRuleMutation.id],Ie=[{label:{name:"sheet.cf.ruleType.highlightCell",selectable:!1},value:G.highlightCell},{label:{name:"sheet.cf.panel.rankAndAverage",selectable:!1},value:G.rank},{label:{name:"sheet.cf.ruleType.formula",selectable:!1},value:G.formula},{label:{name:"sheet.cf.ruleType.colorScale",selectable:!1},value:G.colorScale},{label:{name:"sheet.cf.ruleType.dataBar",selectable:!1},value:G.dataBar},{label:{name:"sheet.cf.ruleType.iconSet",selectable:!1},value:G.icon},{label:{name:"sheet.cf.menu.manageConditionalFormatting",selectable:!1},value:G.viewRule},{label:{name:"sheet.cf.menu.createConditionalFormatting",selectable:!1},value:G.createRule},{label:{name:"sheet.cf.menu.clearRangeRules",selectable:!1},value:G.clearRangeRules,disabled:!1},{label:{name:"sheet.cf.menu.clearWorkSheetRules",selectable:!1},value:G.clearWorkSheetRules}],Mt=a=>{const e=a.get(O.SheetsSelectionsService),t=a.get(s.ICommandService),n=a.get(s.IUniverInstanceService),l=a.get(r.ConditionalFormattingRuleModel),u=new K.Observable(d=>K.merge(e.selectionMoveEnd$,e.selectionSet$,new K.Observable(f=>{const o=t.onCommandExecuted(p=>{var m;const{id:h,params:b}=p,S=(m=n.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET))==null?void 0:m.getUnitId();_r.includes(h)&&b.unitId===S&&f.next(null)});return()=>o.dispose()})).pipe(se.debounceTime(16)).subscribe(()=>{var m;const f=((m=e.getCurrentSelections())==null?void 0:m.map(N=>N.range))||[],o=n.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET);if(!o)return;const p=o.getActiveSheet();if(!p)return;const S=(l.getSubunitRules(o.getUnitId(),p.getSheetId())||[]).filter(N=>N.ranges.some(w=>f.some(E=>s.Rectangle.intersects(E,w)))).map(N=>N.ranges).every(N=>O.checkRangesEditablePermission(a,o.getUnitId(),p.getSheetId(),N));d.next(S)})),i=new K.Observable(d=>new K.Observable(f=>{const o=t.onCommandExecuted(p=>{var m;const{id:h,params:b}=p,S=(m=n.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET))==null?void 0:m.getUnitId();_r.includes(h)&&b.unitId===S&&f.next(null)});return()=>o.dispose()}).pipe(se.debounceTime(16)).subscribe(()=>{const f=n.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET);if(!f)return;const o=f.getActiveSheet();if(!o)return;const p=l.getSubunitRules(f.getUnitId(),o.getSheetId())||[];if(!p.length)return d.next(!1),!1;const h=p.map(b=>b.ranges).every(b=>O.checkRangesEditablePermission(a,f.getUnitId(),o.getSheetId(),b));d.next(h)})),v=new K.Observable(d=>{u.subscribe(f=>{const o=Ie.find(p=>p.value===G.clearRangeRules);o&&(o.disabled=!f,d.next(Ie))}),i.subscribe(f=>{const o=Ie.find(p=>p.value===G.clearWorkSheetRules);o&&(o.disabled=!f,d.next(Ie))}),d.next(Ie)});return{id:pe.id,type:A.MenuItemType.SELECTOR,icon:"ConditionsDoubleIcon",tooltip:"sheet.cf.title",selections:v,hidden$:A.getMenuHiddenObservable(a,s.UniverInstanceType.UNIVER_SHEET),disabled$:q.getCurrentRangeDisable$(a,{workbookTypes:[O.WorkbookEditablePermission],worksheetTypes:[O.WorksheetSetCellStylePermission,O.WorksheetEditPermission],rangeTypes:[O.RangeProtectionPermissionEditPoint]})}},Vt={[A.RibbonDataGroup.RULES]:{[pe.id]:{order:1,menuItemFactory:Mt}}};var Ot=Object.getOwnPropertyDescriptor,Ut=(a,e,t,n)=>{for(var l=n>1?void 0:n?Ot(e,t):e,u=a.length-1,i;u>=0;u--)(i=a[u])&&(l=i(l)||l);return l},wr=(a,e)=>(t,n)=>e(t,n,a);let ke=class extends s.Disposable{constructor(e,t){super();X(this,"_sidebarDisposable",null);this._injector=e,this._menuManagerService=t,this._menuManagerService.mergeMenu(Vt)}};ke=Ut([wr(0,s.Inject(s.Injector)),wr(1,A.IMenuManagerService)],ke);var kt=Object.defineProperty,Pt=Object.getOwnPropertyDescriptor,Dt=(a,e,t)=>e in a?kt(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t,Lt=(a,e,t,n)=>{for(var l=n>1?void 0:n?Pt(e,t):e,u=a.length-1,i;u>=0;u--)(i=a[u])&&(l=i(l)||l);return l},rr=(a,e)=>(t,n)=>e(t,n,a),Pe=(a,e,t)=>Dt(a,typeof e!="symbol"?e+"":e,t);P.UniverSheetsConditionalFormattingUIPlugin=class extends s.Plugin{constructor(e=Ee,t,n,l){super(),this._config=e,this._injector=t,this._commandService=n,this._configService=l;const{menu:u,...i}=s.merge({},Ee,this._config);u&&this._configService.setConfig("menu",u,{merge:!0}),this._configService.setConfig(Sr,i),this._initCommand()}onStarting(){s.registerDependencies(this._injector,[[me],[ye],[Me],[Ce],[ve],[ke],[le],[Ve],[P.ConditionalFormattingClearController],[Oe],[Ue],[he]]),s.touchDependencies(this._injector,[[me],[he]])}onReady(){s.touchDependencies(this._injector,[[ke],[ve]])}onRendered(){s.touchDependencies(this._injector,[[Me],[P.ConditionalFormattingClearController],[ye],[Ve],[le],[Oe],[Ce],[Ue]])}_initCommand(){[Ae,Fe,$e,Be,He,We,qe,Ge,Ze,pe].forEach(e=>{this._commandService.registerCommand(e)})}},Pe(P.UniverSheetsConditionalFormattingUIPlugin,"pluginName",`${r.SHEET_CONDITIONAL_FORMATTING_PLUGIN}_UI_PLUGIN`),Pe(P.UniverSheetsConditionalFormattingUIPlugin,"packageName",Ne.name),Pe(P.UniverSheetsConditionalFormattingUIPlugin,"version",Ne.version),Pe(P.UniverSheetsConditionalFormattingUIPlugin,"type",s.UniverInstanceType.UNIVER_SHEET),P.UniverSheetsConditionalFormattingUIPlugin=Lt([s.DependentOn(r.UniverSheetsConditionalFormattingPlugin,nr.UniverSheetsFormulaPlugin),rr(1,s.Inject(s.Injector)),rr(2,s.Inject(s.ICommandService)),rr(3,s.IConfigService)],P.UniverSheetsConditionalFormattingUIPlugin),P.AddAverageCfCommand=Ae,P.AddColorScaleConditionalRuleCommand=Fe,P.AddDataBarConditionalRuleCommand=$e,P.AddDuplicateValuesCfCommand=Be,P.AddNumberCfCommand=He,P.AddRankCfCommand=We,P.AddTextCfCommand=qe,P.AddTimePeriodCfCommand=Ge,P.AddUniqueValuesCfCommand=Ze,P.OpenConditionalFormattingOperator=pe,Object.defineProperty(P,Symbol.toStringTag,{value:"Module"})}));
3
+ `,children:[c.jsx("div",{className:"univer-flex univer-items-center univer-gap-2",children:d.tWithReactNode("sheet.cf.panel.managerRuleSelect",c.jsx(V.Select,{className:"univer-w-36",options:g,value:m,onChange:D=>{N(D)}})).map((D,F)=>c.jsx("span",{children:D},F))}),c.jsxs("div",{className:"univer-flex univer-justify-end univer-space-x-2",children:[c.jsx(V.Tooltip,{title:i.t("sheet.cf.panel.createRule"),placement:"bottom",children:c.jsx("a",{className:"univer-size-5 univer-cursor-pointer",onClick:j,children:c.jsx(ir,{})})}),_.length&&$?c.jsx(V.Tooltip,{title:i.t("sheet.cf.panel.clear"),placement:"bottom",children:c.jsx("a",{className:"univer-size-5 univer-cursor-pointer",onClick:y,children:c.jsx(Se,{className:"univer-text-red-500"})})}):c.jsx("div",{children:c.jsx(Se,{className:"univer-text-gray-300"})})]})]}),c.jsx("div",{children:c.jsx(V.DraggableList,{className:"univer-w-full",draggableHandle:".draggableHandle",list:x,onListChange:()=>{},idKey:"cfId",rowHeight:60,margin:[0,10],onDragStop:L,onDragStart:U,itemRender:D=>c.jsxs("div",{className:V.clsx("univer-group univer-relative univer-flex univer-items-center univer-justify-between univer-rounded univer-py-2 univer-pl-5 univer-pr-8 hover:univer-bg-gray-100 dark:hover:!univer-bg-gray-700",{"univer-bg-gray-100 dark:!univer-bg-gray-700":M===D.cfId}),onMouseMove:()=>{D.ranges!==b&&S(D.ranges)},onMouseLeave:()=>S([]),onClick:()=>{e(D)},children:[c.jsx("div",{className:V.clsx("univer-absolute univer-left-0 univer-hidden univer-size-5 univer-cursor-grab univer-items-center univer-justify-center univer-rounded group-hover:univer-flex","draggableHandle"),onClick:F=>F.stopPropagation(),children:c.jsx(cr,{})}),c.jsxs("div",{className:"univer-min-w-0 univer-max-w-full univer-flex-shrink univer-overflow-hidden",children:[c.jsx("div",{className:"univer-text-sm univer-text-gray-900 dark:!univer-text-white",children:tt(D,i)}),c.jsx("div",{className:"univer-text-xs univer-text-gray-400",children:D.ranges.map(F=>je.serializeRange(F)).join(",")})]}),c.jsx("div",{children:c.jsx(te,{rule:D.rule})}),c.jsx("div",{className:V.clsx("univer-absolute univer-right-1 univer-hidden univer-size-6 univer-cursor-pointer univer-items-center univer-justify-center univer-rounded univer-text-red-500 group-hover:univer-flex hover:univer-bg-gray-200",{"univer-flex univer-items-center univer-justify-center":M===D.cfId}),onClick:F=>{F.stopPropagation(),k(D),S([])},children:c.jsx(Se,{})})]})})})]})},lt=a=>{const[e,t]=C.useState(a.rule),[n,l]=C.useState(!!a.rule),u=()=>{l(!0)},i=()=>{l(!1),t(void 0)},v=d=>{t(d),l(!0)};return c.jsx("div",{className:"univer-flex univer-h-full univer-flex-col univer-justify-between univer-py-4",children:n?c.jsx(Jr,{onCancel:i,rule:e}):c.jsx(nt,{onClick:v,onCreate:u})})};var at=Object.getOwnPropertyDescriptor,ut=(a,e,t,n)=>{for(var l=n>1?void 0:n?at(e,t):e,u=a.length-1,i;u>=0;u--)(i=a[u])&&(l=i(l)||l);return l},de=(a,e)=>(t,n)=>e(t,n,a);const xe="sheet.conditional.formatting.panel";let ve=class extends s.Disposable{constructor(e,t,n,l,u){super();X(this,"_sidebarDisposable",null);this._univerInstanceService=e,this._injector=t,this._componentManager=n,this._sidebarService=l,this._localeService=u,this._initPanel(),this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(s.UniverInstanceType.UNIVER_SHEET).subscribe(i=>{var v;i||(v=this._sidebarDisposable)==null||v.dispose()})),this.disposeWithMe(this._sidebarService.sidebarOptions$.subscribe(i=>{i.id===xe&&(i.visible||setTimeout(()=>{this._sidebarService.sidebarOptions$.next({visible:!1})}))}))}openPanel(e){const t={id:xe,header:{title:this._localeService.t("sheet.cf.title")},children:{label:xe,rule:e,key:s.generateRandomId(4)},onClose:()=>this._sidebarDisposable=null};this._sidebarDisposable=this._sidebarService.open(t)}_initPanel(){this.disposeWithMe(this._componentManager.register(xe,lt))}};ve=ut([de(0,s.IUniverInstanceService),de(1,s.Inject(s.Injector)),de(2,s.Inject(A.ComponentManager)),de(3,s.Inject(A.ISidebarService)),de(4,s.Inject(s.LocaleService))],ve);var G=(a=>(a[a.createRule=1]="createRule",a[a.viewRule=2]="viewRule",a[a.highlightCell=3]="highlightCell",a[a.rank=4]="rank",a[a.formula=5]="formula",a[a.colorScale=6]="colorScale",a[a.dataBar=7]="dataBar",a[a.icon=8]="icon",a[a.clearRangeRules=9]="clearRangeRules",a[a.clearWorkSheetRules=10]="clearWorkSheetRules",a))(G||{});const pe={id:"sheet.operation.open.conditional.formatting.panel",type:s.CommandType.OPERATION,handler:(a,e)=>{var v;const t=a.get(ve),n=a.get(O.SheetsSelectionsService),l=a.get(s.ICommandService),u=((v=n.getCurrentSelections())==null?void 0:v.map(d=>d.range))||[];switch(e.value){case 3:{t.openPanel({...r.createDefaultRule(),ranges:u});break}case 4:{const d={...r.createDefaultRule,ranges:u,rule:{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.rank}};t.openPanel(d);break}case 5:{const d={...r.createDefaultRule,ranges:u,rule:{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.formula,value:"="}};t.openPanel(d);break}case 6:{const d={...r.createDefaultRule,ranges:u,rule:{type:r.CFRuleType.colorScale,config:[]}};t.openPanel(d);break}case 7:{const d={...r.createDefaultRule,ranges:u,rule:{type:r.CFRuleType.dataBar,isShowValue:!0}};t.openPanel(d);break}case 8:{const d={...r.createDefaultRule,ranges:u,rule:{type:r.CFRuleType.iconSet,config:[],isShowValue:!0}};t.openPanel(d);break}case 2:{t.openPanel();break}case 1:{t.openPanel({...r.createDefaultRule(),ranges:u});break}case 9:{l.executeCommand(r.ClearRangeCfCommand.id,{ranges:u});break}case 10:{l.executeCommand(r.ClearWorksheetCfCommand.id);break}}return!0}};var it=Object.getOwnPropertyDescriptor,st=(a,e,t,n)=>{for(var l=n>1?void 0:n?it(e,t):e,u=a.length-1,i;u>=0;u--)(i=a[u])&&(l=i(l)||l);return l},fe=(a,e)=>(t,n)=>e(t,n,a);P.ConditionalFormattingClearController=class extends s.Disposable{constructor(e,t,n,l,u){super(),this._injector=e,this._univerInstanceService=t,this._sheetInterceptorService=n,this._selectionManagerService=l,this._conditionalFormattingRuleModel=u,this._init()}_init(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:e=>{var u;const t=[],n=[],l={redos:t,undos:n};if([O.ClearSelectionFormatCommand.id,O.ClearSelectionAllCommand.id].includes(e.id)){const i=(u=this._selectionManagerService.getCurrentSelections())==null?void 0:u.map(S=>S.range);if(!i)return l;const v=this._univerInstanceService.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET),d=v.getActiveSheet();if(!d)return l;const f=v.getUnitId(),o=d.getSheetId(),p=this._conditionalFormattingRuleModel.getSubunitRules(f,o);if(!p||!p.length)return l;const{redos:h,undos:b}=Ir(this._injector,p,i,f,o);t.push(...h),n.push(...b)}return l}})),this.disposeWithMe(this._sheetInterceptorService.interceptRanges({getMutations:({unitId:e,subUnitId:t,ranges:n})=>{const l=[],u=[],i={redos:l,undos:u};if(!n||!n.length)return i;const v=this._conditionalFormattingRuleModel.getSubunitRules(e,t);if(!v||!v.length)return i;const{redos:d,undos:f}=Ir(this._injector,v,n,e,t);return l.push(...d),u.push(...f),i}}))}},P.ConditionalFormattingClearController=st([fe(0,s.Inject(s.Injector)),fe(1,s.Inject(s.IUniverInstanceService)),fe(2,s.Inject(O.SheetInterceptorService)),fe(3,s.Inject(O.SheetsSelectionsService)),fe(4,s.Inject(r.ConditionalFormattingRuleModel))],P.ConditionalFormattingClearController);function Ir(a,e,t,n,l){const u=[],i=[];return e.filter(v=>t.some(d=>v.ranges.some(f=>s.Rectangle.getIntersects(f,d)))).forEach(v=>{const f=new O.RangeMergeUtil().add(...v.ranges).subtract(...t).merge();if(f.length){const o={id:r.SetConditionalRuleMutation.id,params:{unitId:n,subUnitId:l,rule:{...v,ranges:f}}},p=r.setConditionalRuleMutationUndoFactory(a,o.params);u.push(o),i.push(...p)}else{const o={id:r.DeleteConditionalRuleMutation.id,params:{unitId:n,subUnitId:l,cfId:v.cfId}},p=r.DeleteConditionalRuleMutationUndoFactory(a,o.params);u.push(o),i.push(...p)}}),{redos:u,undos:i}}const Ne={name:"@univerjs/sheets-conditional-formatting-ui",version:"0.17.0"},Sr="sheets-conditional-formatting-ui.config",Ee={};var ct=Object.getOwnPropertyDescriptor,ot=(a,e,t,n)=>{for(var l=n>1?void 0:n?ct(e,t):e,u=a.length-1,i;u>=0;u--)(i=a[u])&&(l=i(l)||l);return l},Xe=(a,e)=>(t,n)=>e(t,n,a);let he=class extends s.Disposable{constructor(e,t,n){super();X(this,"_disposableMap",new Map);this._conditionalFormattingRuleModel=e,this._formulaRefRangeService=t,this._injector=n,this._initRefRange()}_getIdWithUnitId(e,t,n){return`${e}_${t}_${n}`}_getRuleFormulas(e){const t=[],n=e.rule;switch(n.type){case r.CFRuleType.highlightCell:n.subType===r.CFSubRuleType.formula&&t.push(n.value);break;case r.CFRuleType.dataBar:{const l=n;l.config.min.type===r.CFValueType.formula&&t.push(l.config.min.value),l.config.max.type===r.CFValueType.formula&&t.push(l.config.max.value);break}case r.CFRuleType.colorScale:{n.config.forEach(u=>{u.value.type===r.CFValueType.formula&&t.push(u.value.value)});break}case r.CFRuleType.iconSet:{n.config.forEach(u=>{u.value.type===r.CFValueType.formula&&t.push(u.value.value)});break}}return t}_updateRuleFormulas(e,t){const n=s.Tools.deepClone(e),l=n.rule;let u=0;switch(l.type){case r.CFRuleType.highlightCell:l.subType===r.CFSubRuleType.formula&&(l.value=t[u++]);break;case r.CFRuleType.dataBar:{const i=l;i.config.min.type===r.CFValueType.formula&&(i.config.min.value=t[u++]),i.config.max.type===r.CFValueType.formula&&(i.config.max.value=t[u++]);break}case r.CFRuleType.colorScale:{l.config.forEach(v=>{v.value.type===r.CFValueType.formula&&(v.value.value=t[u++])});break}case r.CFRuleType.iconSet:{l.config.forEach(v=>{v.value.type===r.CFValueType.formula&&(v.value.value=t[u++])});break}}return n}register(e,t,n){const l=n.ranges,u=this._getRuleFormulas(n),i=this._formulaRefRangeService.registerRangeFormula(e,t,l,u,d=>{if(d.length===0)return{undos:[{id:r.AddConditionalRuleMutation.id,params:{unitId:e,subUnitId:t,rule:n}}],redos:[{id:r.DeleteConditionalRuleMutation.id,params:{unitId:e,subUnitId:t,cfId:n.cfId}}]};const f=[],o=[],p=d[0],h=this._updateRuleFormulas(n,p.formulas);h.ranges=p.ranges,f.push({id:r.SetConditionalRuleMutation.id,params:{unitId:e,subUnitId:t,cfId:n.cfId,rule:h}}),o.push(...r.setConditionalRuleMutationUndoFactory(this._injector,{unitId:e,subUnitId:t,cfId:n.cfId,rule:h}));for(let b=1;b<d.length;b++){const S=d[b],m=r.createCfId(),N=this._updateRuleFormulas(n,S.formulas);N.cfId=m,N.ranges=S.ranges,f.push({id:r.AddConditionalRuleMutation.id,params:{unitId:e,subUnitId:t,rule:N}}),o.push(r.AddConditionalRuleMutationUndoFactory(this._injector,{unitId:e,subUnitId:t,rule:N}))}return{undos:o,redos:f}}),v=this._getIdWithUnitId(e,t,n.cfId);this._disposableMap.set(v,i)}_initRefRange(){const e=this._conditionalFormattingRuleModel.getAll();for(const[t,n]of e)for(const[l,u]of n)for(const i of u)this.register(t,l,i);this.disposeWithMe(this._conditionalFormattingRuleModel.$ruleChange.subscribe(t=>{const{unitId:n,subUnitId:l,rule:u}=t;switch(t.type){case"add":{this.register(n,l,u);break}case"delete":{const i=this._getIdWithUnitId(n,l,u.cfId),v=this._disposableMap.get(i);v&&(v.dispose(),this._disposableMap.delete(i));break}case"set":{const i=this._getIdWithUnitId(n,l,u.cfId),v=this._disposableMap.get(i);v&&(v.dispose(),this._disposableMap.delete(i)),this.register(n,l,u);break}}})),this.disposeWithMe(s.toDisposable(()=>{this._disposableMap.forEach(t=>{t.dispose()}),this._disposableMap.clear()}))}};he=ot([Xe(0,s.Inject(r.ConditionalFormattingRuleModel)),Xe(1,s.Inject(nr.FormulaRefRangeService)),Xe(2,s.Inject(s.Injector))],he);var dt=Object.getOwnPropertyDescriptor,vt=(a,e,t,n)=>{for(var l=n>1?void 0:n?dt(e,t):e,u=a.length-1,i;u>=0;u--)(i=a[u])&&(l=i(l)||l);return l},ge=(a,e)=>(t,n)=>e(t,n,a);let ye=class extends s.Disposable{constructor(e,t,n,l,u){super();X(this,"_copyInfo");this._sheetClipboardService=e,this._conditionalFormattingRuleModel=t,this._injector=n,this._conditionalFormattingViewModel=l,this._univerInstanceService=u,this._initClipboardHook()}_initClipboardHook(){this.disposeWithMe(this._sheetClipboardService.addClipboardHook({id:r.SHEET_CONDITIONAL_FORMATTING_PLUGIN,onBeforeCopy:(e,t,n)=>this._collectConditionalRule(e,t,n),onPasteCells:(e,t,n,l)=>{const{copyType:u=q.COPY_TYPE.COPY,pasteType:i}=l,{range:v}=e||{},{range:d}=t;return this._generateConditionalFormattingMutations(d,{copyType:u,pasteType:i,copyRange:v})}}))}_collectConditionalRule(e,t,n){const l=new s.ObjectMatrix,u={};this._copyInfo={matrix:l,info:{unitId:e,subUnitId:t,cfMap:u}};const i=this._injector.invoke(o=>O.rangeToDiscreteRange(n,o,e,t));if(!i)return;const{rows:v,cols:d}=i,f=new Set;v.forEach((o,p)=>{d.forEach((h,b)=>{const S=this._conditionalFormattingViewModel.getCellCfs(e,t,o,h);S&&(S.forEach(m=>f.add(m.cfId)),l.setValue(p,b,S.map(m=>m.cfId)))})}),f.forEach(o=>{const p=this._conditionalFormattingRuleModel.getRule(e,t,o);p&&(u[o]=p.rule)})}_generateConditionalFormattingMutations(e,t){const n=this._univerInstanceService.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET),l=n.getActiveSheet(),u=n.getUnitId();if(!l)return{redos:[],undos:[]};const i=l.getSheetId();if(t.copyType===q.COPY_TYPE.CUT)return this._copyInfo=null,{redos:[],undos:[]};if(!this._copyInfo||!t.copyRange)return{redos:[],undos:[]};if(![q.PREDEFINED_HOOK_NAME_PASTE.SPECIAL_PASTE_FORMAT,q.PREDEFINED_HOOK_NAME_PASTE.DEFAULT_PASTE,q.PREDEFINED_HOOK_NAME_PASTE.SPECIAL_PASTE_BESIDES_BORDER].includes(t.pasteType))return{redos:[],undos:[]};const{ranges:[d,f],mapFunc:o}=q.virtualizeDiscreteRanges([t.copyRange,e]),p=q.getRepeatRange(d,f,!0),h={};s.Range.foreach(f,(g,T)=>{const{row:_,col:I}=o(g,T),k=this._conditionalFormattingViewModel.getCellCfs(u,i,_,I);k&&k.forEach(U=>{if(!h[U.cfId]){const L=new s.ObjectMatrix;h[U.cfId]=L;const j=this._conditionalFormattingRuleModel.getRule(u,i,U.cfId);j==null||j.ranges.forEach(y=>{s.Range.foreach(y,(x,$)=>{L.setValue(x,$,1)})})}h[U.cfId].realDeleteValue(_,I)})});const{matrix:b,info:S}=this._copyInfo,m=[];let N=this._conditionalFormattingRuleModel.createCfId(u,i);const w={},E=g=>{if(w[g])return w[g];const T=S==null?void 0:S.cfMap[g],_=[...this._conditionalFormattingRuleModel.getSubunitRules(u,i)||[],...m].find(I=>s.Tools.diffValue(I.rule,T));if(_)return w[g]=_,_;{const I={rule:T,cfId:N,ranges:[],stopIfTrue:!1};return w[g]=I,m.push(I),N=`${Number(N)+1}`,I}};p.forEach(g=>{b&&b.forValue((T,_,I)=>{const k=s.Rectangle.getPositionRange({startRow:T,endRow:T,startColumn:_,endColumn:_},g.startRange),{row:U,col:L}=o(k.startRow,k.startColumn);I.forEach(j=>{if(!h[j]){const y=E(j),x=new s.ObjectMatrix;h[j]=x,y.ranges.forEach($=>{s.Range.foreach($,(D,F)=>{x.setValue(D,F,1)})})}h[j].setValue(U,L,1)})})});const M=[],R=[];for(const g in h){const T=h[g],_=O.findAllRectangle(O.createTopMatrixFromMatrix(T));if(!_.length){const I={unitId:u,subUnitId:i,cfId:g};M.push({id:r.DeleteConditionalRuleMutation.id,params:I}),R.push(...r.DeleteConditionalRuleMutationUndoFactory(this._injector,I))}if(m.some(I=>I.cfId===g)){const I=E(g),k={unitId:u,subUnitId:i,rule:{...I,ranges:_}};M.push({id:r.AddConditionalRuleMutation.id,params:k}),R.push(r.AddConditionalRuleMutationUndoFactory(this._injector,k))}else{const I=this._conditionalFormattingRuleModel.getRule(u,i,g);if(!I)continue;const k={unitId:u,subUnitId:i,rule:{...I,ranges:_}};M.push({id:r.SetConditionalRuleMutation.id,params:k}),R.push(...r.setConditionalRuleMutationUndoFactory(this._injector,k))}}return{redos:M,undos:R}}};ye=vt([ge(0,s.Inject(q.ISheetClipboardService)),ge(1,s.Inject(r.ConditionalFormattingRuleModel)),ge(2,s.Inject(s.Injector)),ge(3,s.Inject(r.ConditionalFormattingViewModel)),ge(4,s.Inject(s.IUniverInstanceService))],ye);var pt=Object.getOwnPropertyDescriptor,ft=(a,e,t,n)=>{for(var l=n>1?void 0:n?pt(e,t):e,u=a.length-1,i;u>=0;u--)(i=a[u])&&(l=i(l)||l);return l},Je=(a,e)=>(t,n)=>e(t,n,a);let Ce=class extends s.Disposable{constructor(a,e,t){super(),this._localeService=a,this._commandService=e,this._sheetPermissionCheckController=t,this._commandExecutedListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.beforeCommandExecuted(a=>{if(a.id===r.AddCfCommand.id){const{unitId:e,subUnitId:t,rule:{ranges:n}}=a.params;this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[O.WorkbookEditablePermission],rangeTypes:[O.RangeProtectionPermissionEditPoint],worksheetTypes:[O.WorksheetEditPermission,O.WorksheetSetCellStylePermission]},n,e,t)||this._sheetPermissionCheckController.blockExecuteWithoutPermission(this._localeService.t("permission.dialog.setStyleErr"))}}))}};Ce=ft([Je(0,s.Inject(s.LocaleService)),Je(1,s.ICommandService),Je(2,s.Inject(O.SheetPermissionCheckController))],Ce);var ht=Object.getOwnPropertyDescriptor,gt=(a,e,t,n)=>{for(var l=n>1?void 0:n?ht(e,t):e,u=a.length-1,i;u>=0;u--)(i=a[u])&&(l=i(l)||l);return l},ae=(a,e)=>(t,n)=>e(t,n,a);let me=class extends s.Disposable{constructor(e,t,n,l,u,i){super();X(this,"_ruleChangeCacheMap",new Map);this._sheetInterceptorService=e,this._conditionalFormattingService=t,this._univerInstanceService=n,this._renderManagerService=l,this._conditionalFormattingViewModel=u,this._conditionalFormattingRuleModel=i,this._initViewModelInterceptor(),this._initSkeleton(),this.disposeWithMe(()=>{this._ruleChangeCacheMap.clear()})}_markDirtySkeleton(){var t,n,l;const e=this._univerInstanceService.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET).getUnitId();(t=this._renderManagerService.getRenderById(e))==null||t.with(q.SheetSkeletonManagerService).reCalculate(),(l=(n=this._renderManagerService.getRenderById(e))==null?void 0:n.mainComponent)==null||l.makeDirty()}_initSkeleton(){this.disposeWithMe(K.merge(this._conditionalFormattingRuleModel.$ruleChange,this._conditionalFormattingViewModel.markDirty$).pipe(se.bufferTime(16),se.filter(e=>!!e.length),se.filter(e=>{const t=this._univerInstanceService.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET);if(!t)return!1;const n=t.getActiveSheet();return n?e.filter(l=>l.unitId===t.getUnitId()&&l.subUnitId===n.getSheetId()).length>0:!1})).subscribe(()=>this._markDirtySkeleton()))}_initViewModelInterceptor(){this.disposeWithMe(this._sheetInterceptorService.intercept(O.INTERCEPTOR_POINT.CELL_CONTENT,{effect:s.InterceptorEffectEnum.Style,handler:(e,t,n)=>{const l=this._conditionalFormattingService.composeStyle(t.unitId,t.subUnitId,t.row,t.col);if(!l)return n(e);const u=t.workbook.getStyles(),i=(typeof(e==null?void 0:e.s)=="string"?u.get(e==null?void 0:e.s):e==null?void 0:e.s)||{},v=e===t.rawData?{...t.rawData}:e;if(l.style){const d={...i,...l.style};Object.assign(v,{s:d})}return v.fontRenderExtension||(v.fontRenderExtension={},l.isShowValue!==void 0&&(v.fontRenderExtension.isSkip=!l.isShowValue)),l.dataBar&&(v.dataBar=l.dataBar),l.iconSet&&(v.iconSet=l.iconSet,v.fontRenderExtension.leftOffset=r.DEFAULT_PADDING+r.DEFAULT_WIDTH),n(v)},priority:10}))}};me=gt([ae(0,s.Inject(O.SheetInterceptorService)),ae(1,s.Inject(r.ConditionalFormattingService)),ae(2,s.Inject(s.IUniverInstanceService)),ae(3,s.Inject(lr.IRenderManagerService)),ae(4,s.Inject(r.ConditionalFormattingViewModel)),ae(5,s.Inject(r.ConditionalFormattingRuleModel))],me);var yt=Object.defineProperty,Ct=Object.getOwnPropertyDescriptor,mt=(a,e,t)=>e in a?yt(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t,bt=(a,e,t,n)=>{for(var l=n>1?void 0:n?Ct(e,t):e,u=a.length-1,i;u>=0;u--)(i=a[u])&&(l=i(l)||l);return l},Qe=(a,e)=>(t,n)=>e(t,n,a),Re=(a,e,t)=>mt(a,typeof e!="symbol"?e+"":e,t);P.UniverSheetsConditionalFormattingMobileUIPlugin=class extends s.Plugin{constructor(e=Ee,t,n,l){super(),this._config=e,this._injector=t,this._commandService=n,this._configService=l;const{menu:u,...i}=s.merge({},Ee,this._config);u&&this._configService.setConfig("menu",u,{merge:!0}),this._configService.setConfig(Sr,i),this._initCommand(),this._injector.add([me]),this._injector.add([ye]),this._injector.add([Ce]),this._injector.add([le]),this._injector.add([he])}_initCommand(){[Ae,Fe,$e,Be,He,We,qe,Ge,Ze,pe].forEach(e=>{this._commandService.registerCommand(e)})}},Re(P.UniverSheetsConditionalFormattingMobileUIPlugin,"pluginName",`${r.SHEET_CONDITIONAL_FORMATTING_PLUGIN}_MOBILE_UI_PLUGIN`),Re(P.UniverSheetsConditionalFormattingMobileUIPlugin,"packageName",Ne.name),Re(P.UniverSheetsConditionalFormattingMobileUIPlugin,"version",Ne.version),Re(P.UniverSheetsConditionalFormattingMobileUIPlugin,"type",s.UniverInstanceType.UNIVER_SHEET),P.UniverSheetsConditionalFormattingMobileUIPlugin=bt([s.DependentOn(r.UniverSheetsConditionalFormattingPlugin),Qe(1,s.Inject(s.Injector)),Qe(2,s.Inject(s.ICommandService)),Qe(3,s.IConfigService)],P.UniverSheetsConditionalFormattingMobileUIPlugin);var It=Object.getOwnPropertyDescriptor,St=(a,e,t,n)=>{for(var l=n>1?void 0:n?It(e,t):e,u=a.length-1,i;u>=0;u--)(i=a[u])&&(l=i(l)||l);return l},be=(a,e)=>(t,n)=>e(t,n,a);let Me=class extends s.Disposable{constructor(a,e,t,n,l){super(),this._injector=a,this._univerInstanceService=e,this._autoFillService=t,this._conditionalFormattingRuleModel=n,this._conditionalFormattingViewModel=l,this._initAutoFill()}_initAutoFill(){const a=()=>({redos:[],undos:[]}),e=(l,u,i,v,d)=>{var b;const f=this._univerInstanceService.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET).getUnitId(),o=(b=this._univerInstanceService.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:b.getSheetId();if(!f||!o)return;const p={startRow:l.row,startColumn:l.col,endColumn:l.col,endRow:l.row},h={startRow:u.row,startColumn:u.col,endColumn:u.col,endRow:u.row};s.Range.foreach(i,(S,m)=>{const N=s.Rectangle.getPositionRange({startRow:S,startColumn:m,endColumn:m,endRow:S},p),w=s.Rectangle.getPositionRange({startRow:S,startColumn:m,endColumn:m,endRow:S},h),{row:E,col:M}=d(N.startRow,N.startColumn),R=this._conditionalFormattingViewModel.getCellCfs(f,o,E,M),{row:g,col:T}=d(w.startRow,w.startColumn),_=this._conditionalFormattingViewModel.getCellCfs(f,o,g,T);_&&_.forEach(I=>{let k=v.get(I.cfId);if(!v.get(I.cfId)){const U=this._conditionalFormattingRuleModel.getRule(f,o,I.cfId);if(!U)return;k=new s.ObjectMatrix,U.ranges.forEach(L=>{s.Range.foreach(L,(j,y)=>{k.setValue(j,y,1)})}),v.set(I.cfId,k)}k.realDeleteValue(g,T)}),R&&R.forEach(I=>{let k=v.get(I.cfId);if(!v.get(I.cfId)){const U=this._conditionalFormattingRuleModel.getRule(f,o,I.cfId);if(!U)return;k=new s.ObjectMatrix,U.ranges.forEach(L=>{s.Range.foreach(L,(j,y)=>{k.setValue(j,y,1)})}),v.set(I.cfId,k)}k.setValue(g,T,1)})})},t=(l,u)=>{var w,E,M;const i=(w=this._univerInstanceService.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET))==null?void 0:w.getUnitId(),v=(M=(E=this._univerInstanceService.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET))==null?void 0:E.getActiveSheet())==null?void 0:M.getSheetId(),d=new Map,f=[],o=[];if(!i||!v)return a();const p=q.virtualizeDiscreteRanges([l,u]),[h,b]=p.ranges,{mapFunc:S}=p,m={row:h.startRow,col:h.startColumn};return O.AutoFillTools.getAutoFillRepeatRange(h,b).forEach(R=>{e(m,R.repeatStartCell,R.relativeRange,d,S)}),d.forEach((R,g)=>{const T=this._conditionalFormattingRuleModel.getRule(i,v,g);if(!T)return;const _=O.findAllRectangle(O.createTopMatrixFromMatrix(R));if(_.length){const I={unitId:i,subUnitId:v,rule:{...T,ranges:_}};f.push({id:r.SetConditionalRuleMutation.id,params:I}),o.push(...r.setConditionalRuleMutationUndoFactory(this._injector,I))}else{const I={unitId:i,subUnitId:v,cfId:T.cfId};f.push({id:r.DeleteConditionalRuleMutation.id,params:I}),o.push(...r.DeleteConditionalRuleMutationUndoFactory(this._injector,I))}}),{undos:o,redos:f}},n={id:r.SHEET_CONDITIONAL_FORMATTING_PLUGIN,onFillData:(l,u,i)=>{if(i===O.AUTO_FILL_APPLY_TYPE.COPY||i===O.AUTO_FILL_APPLY_TYPE.ONLY_FORMAT||i===O.AUTO_FILL_APPLY_TYPE.SERIES){const{source:v,target:d}=l;return t(v,d)}return a()}};this.disposeWithMe(this._autoFillService.addHook(n))}};Me=St([be(0,s.Inject(s.Injector)),be(1,s.Inject(s.IUniverInstanceService)),be(2,s.Inject(O.IAutoFillService)),be(3,s.Inject(r.ConditionalFormattingRuleModel)),be(4,s.Inject(r.ConditionalFormattingViewModel))],Me);var Tt=Object.getOwnPropertyDescriptor,_t=(a,e,t,n)=>{for(var l=n>1?void 0:n?Tt(e,t):e,u=a.length-1,i;u>=0;u--)(i=a[u])&&(l=i(l)||l);return l},Tr=(a,e)=>(t,n)=>e(t,n,a);let Ve=class extends s.Disposable{constructor(a,e){super(),this._sheetInterceptorService=a,this._conditionalFormattingService=e,this._initInterceptorEditorEnd()}_initInterceptorEditorEnd(){this.disposeWithMe(s.toDisposable(this._sheetInterceptorService.writeCellInterceptor.intercept(O.AFTER_CELL_EDIT,{handler:(a,e,t)=>{var i,v,d;a||t(a);const n=this._conditionalFormattingService.composeStyle(e.unitId,e.subUnitId,e.row,e.col),l=(i=n==null?void 0:n.style)!=null?i:{},u=Object.keys(l);if(a!=null&&a.p)return(d=(v=a.p.body)==null?void 0:v.textRuns)==null||d.forEach(f=>{f.ts&&u.forEach(o=>{var p;(p=f.ts)==null||delete p[o]})}),t(a);{const f={...(typeof(a==null?void 0:a.s)=="string"?e.workbook.getStyles().get(a.s):a==null?void 0:a.s)||{}};u.forEach(p=>{delete f[p]});const o={...a,s:{...f}};return t(o)}}})))}};Ve=_t([Tr(0,s.Inject(O.SheetInterceptorService)),Tr(1,s.Inject(r.ConditionalFormattingService))],Ve);var wt=Object.getOwnPropertyDescriptor,xt=(a,e,t,n)=>{for(var l=n>1?void 0:n?wt(e,t):e,u=a.length-1,i;u>=0;u--)(i=a[u])&&(l=i(l)||l);return l},ue=(a,e)=>(t,n)=>e(t,n,a);const Nt=(a,e)=>{const t=o=>o.endRow-o.startRow+1,n=o=>o.endColumn-o.startColumn+1,l=t(e)%t(a),u=n(e)%n(a),i=Math.floor(t(e)/t(a)),v=Math.floor(n(e)/n(a)),d=[],f={startRow:0,endRow:t(a)-1,startColumn:0,endColumn:n(a)-1};if(t(e)===1&&n(e)===1){const o={startRow:e.startRow,endRow:e.startRow,startColumn:e.startColumn,endColumn:e.startColumn};return d.push({repeatRelativeRange:f,startRange:o}),d}for(let o=0;o<i+(l?.1:0);o++)for(let p=0;p<v+(u?.1:0);p++){const h=t(a)*o,b=n(a)*p,S={startRow:h+e.startRow,endRow:h+e.startRow,startColumn:b+e.startColumn,endColumn:b+e.startColumn};let m=f;o===i&&l&&(m={...m},m.endRow=m.endRow-(t(a)-l)),p===v&&u&&(m={...m},m.endColumn=m.endColumn-(n(a)-u)),d.push({repeatRelativeRange:m,startRange:S})}return d};let Oe=class extends s.Disposable{constructor(e,t,n,l,u,i){super();X(this,"_painterConfig",null);this._injector=e,this._univerInstanceService=t,this._formatPainterService=n,this._sheetsSelectionsService=l,this._conditionalFormattingRuleModel=u,this._conditionalFormattingViewModel=i,this._initFormattingPainter()}_initFormattingPainter(){const e=()=>({redos:[],undos:[]}),t=(u,i,v,d,f)=>{const{unitId:o,subUnitId:p}=this._painterConfig,{targetUnitId:h,targetSubUnitId:b}=f,S={startRow:u.row,startColumn:u.col,endColumn:u.col,endRow:u.row},m={startRow:i.row,startColumn:i.col,endColumn:i.col,endRow:i.row};s.Range.foreach(v,(N,w)=>{const E=s.Rectangle.getPositionRange({startRow:N,startColumn:w,endColumn:w,endRow:N},S),M=s.Rectangle.getPositionRange({startRow:N,startColumn:w,endColumn:w,endRow:N},m),R=this._conditionalFormattingViewModel.getCellCfs(o,p,E.startRow,E.startColumn),g=this._conditionalFormattingViewModel.getCellCfs(h,b,M.startRow,M.startColumn);g&&g.forEach(T=>{let _=d.get(T.cfId);if(!d.get(T.cfId)){const I=this._conditionalFormattingRuleModel.getRule(h,b,T.cfId);if(!I)return;_=new s.ObjectMatrix,I.ranges.forEach(k=>{s.Range.foreach(k,(U,L)=>{_.setValue(U,L,1)})}),d.set(T.cfId,_)}_.realDeleteValue(M.startRow,M.startColumn)}),R&&R.forEach(T=>{const _=d.get(T.cfId);_&&_.setValue(M.startRow,M.startColumn,1)})})},n=(u,i,v)=>{var E;const{range:d,unitId:f,subUnitId:o}=this._painterConfig,p=u!==f||o!==i,h=new Map,b=[],S=[];if(!u||!i||!f||!o)return e();const m=(E=this._conditionalFormattingRuleModel.getSubunitRules(f,o))!=null?E:[];m==null||m.forEach(M=>{const{ranges:R,cfId:g}=M;if(R.some(T=>s.Rectangle.intersects(d,T))){const T=new s.ObjectMatrix;p||R.forEach(_=>{s.Range.foreach(_,(I,k)=>{T.setValue(I,k,1)})}),h.set(g,T)}});const N={row:d.startRow,col:d.startColumn};return Nt(d,v).forEach(M=>{t(N,{row:M.startRange.startRow,col:M.startRange.startColumn},M.repeatRelativeRange,h,{targetUnitId:u,targetSubUnitId:i})}),h.forEach((M,R)=>{if(p){const g=this._conditionalFormattingRuleModel.getRule(u,i,R),T=O.findAllRectangle(O.createTopMatrixFromMatrix(M));if(g)if(T.length){const _={unitId:u,subUnitId:i,rule:{...g,ranges:T}};b.push({id:r.SetConditionalRuleMutation.id,params:_}),S.push(...r.setConditionalRuleMutationUndoFactory(this._injector,_))}else{const _={unitId:u,subUnitId:i,cfId:g.cfId};b.push({id:r.DeleteConditionalRuleMutation.id,params:_}),S.push(...r.DeleteConditionalRuleMutationUndoFactory(this._injector,_))}else if(T.length){const _=this._conditionalFormattingRuleModel.getRule(f,o,R);if(_){const I={unitId:u,subUnitId:i,rule:{...s.Tools.deepClone(_),cfId:this._conditionalFormattingRuleModel.createCfId(u,i),ranges:T}};b.push({id:r.AddConditionalRuleMutation.id,params:I}),S.push(r.AddConditionalRuleMutationUndoFactory(this._injector,I))}}}else{const g=this._conditionalFormattingRuleModel.getRule(f,o,R);if(!g)return;const T=O.findAllRectangle(O.createTopMatrixFromMatrix(M));if(T.length){const _={unitId:f,subUnitId:o,rule:{...g,ranges:T}};b.push({id:r.SetConditionalRuleMutation.id,params:_}),S.push(...r.setConditionalRuleMutationUndoFactory(this._injector,_))}else{const _={unitId:f,subUnitId:o,cfId:g.cfId};b.push({id:r.DeleteConditionalRuleMutation.id,params:_}),S.push(...r.DeleteConditionalRuleMutationUndoFactory(this._injector,_))}}}),{undos:S,redos:b}},l={id:r.SHEET_CONDITIONAL_FORMATTING_PLUGIN,onStatusChange:u=>{var i,v,d;switch(u){case q.FormatPainterStatus.INFINITE:case q.FormatPainterStatus.ONCE:{const f=(i=this._univerInstanceService.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET))==null?void 0:i.getUnitId(),o=(d=(v=this._univerInstanceService.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET))==null?void 0:v.getActiveSheet())==null?void 0:d.getSheetId(),p=this._sheetsSelectionsService.getCurrentLastSelection(),h=p==null?void 0:p.range;f&&o&&h&&(this._painterConfig={unitId:f,subUnitId:o,range:h});break}case q.FormatPainterStatus.OFF:{this._painterConfig=null;break}}},onApply:(u,i,v)=>this._painterConfig?n(u,i,v):{redos:[],undos:[]}};this._formatPainterService.addHook(l)}};Oe=xt([ue(0,s.Inject(s.Injector)),ue(1,s.Inject(s.IUniverInstanceService)),ue(2,s.Inject(q.IFormatPainterService)),ue(3,s.Inject(O.SheetsSelectionsService)),ue(4,s.Inject(r.ConditionalFormattingRuleModel)),ue(5,s.Inject(r.ConditionalFormattingViewModel))],Oe);var Et=Object.getOwnPropertyDescriptor,Rt=(a,e,t,n)=>{for(var l=n>1?void 0:n?Et(e,t):e,u=a.length-1,i;u>=0;u--)(i=a[u])&&(l=i(l)||l);return l},er=(a,e)=>(t,n)=>e(t,n,a);let Ue=class extends s.Disposable{constructor(a,e,t){super(),this._conditionalFormattingViewModel=a,this._univerInstanceService=e,this._renderManagerService=t,this._init()}_init(){const a=this._univerInstanceService.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET),e=t=>{const n=t.getUnitId(),l=this._renderManagerService.getRenderById(n);if(!l)return;const u=l.with(q.SheetSkeletonManagerService);this.disposeWithMe(u.currentSkeleton$.subscribe(i=>{if(i){const v=i.skeleton.rowColumnSegment,d=v.endColumn-v.startColumn+1,o=(v.endRow-v.startRow+1)*d*9,p=Math.max(r.CONDITIONAL_FORMATTING_VIEWPORT_CACHE_LENGTH,o);this._conditionalFormattingViewModel.setCacheLength(p)}}))};a&&e(a),this._univerInstanceService.getCurrentTypeOfUnit$(s.UniverInstanceType.UNIVER_SHEET).subscribe(t=>{t&&e(t)})}};Ue=Rt([er(0,s.Inject(r.ConditionalFormattingViewModel)),er(1,s.IUniverInstanceService),er(2,lr.IRenderManagerService)],Ue);const _r=[O.SetWorksheetActiveOperation.id,r.AddConditionalRuleMutation.id,r.SetConditionalRuleMutation.id,r.DeleteConditionalRuleMutation.id,r.MoveConditionalRuleMutation.id],Ie=[{label:{name:"sheet.cf.ruleType.highlightCell",selectable:!1},value:G.highlightCell},{label:{name:"sheet.cf.panel.rankAndAverage",selectable:!1},value:G.rank},{label:{name:"sheet.cf.ruleType.formula",selectable:!1},value:G.formula},{label:{name:"sheet.cf.ruleType.colorScale",selectable:!1},value:G.colorScale},{label:{name:"sheet.cf.ruleType.dataBar",selectable:!1},value:G.dataBar},{label:{name:"sheet.cf.ruleType.iconSet",selectable:!1},value:G.icon},{label:{name:"sheet.cf.menu.manageConditionalFormatting",selectable:!1},value:G.viewRule},{label:{name:"sheet.cf.menu.createConditionalFormatting",selectable:!1},value:G.createRule},{label:{name:"sheet.cf.menu.clearRangeRules",selectable:!1},value:G.clearRangeRules,disabled:!1},{label:{name:"sheet.cf.menu.clearWorkSheetRules",selectable:!1},value:G.clearWorkSheetRules}],Mt=a=>{const e=a.get(O.SheetsSelectionsService),t=a.get(s.ICommandService),n=a.get(s.IUniverInstanceService),l=a.get(r.ConditionalFormattingRuleModel),u=new K.Observable(d=>K.merge(e.selectionMoveEnd$,e.selectionSet$,new K.Observable(f=>{const o=t.onCommandExecuted(p=>{var m;const{id:h,params:b}=p,S=(m=n.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET))==null?void 0:m.getUnitId();_r.includes(h)&&b.unitId===S&&f.next(null)});return()=>o.dispose()})).pipe(se.debounceTime(16)).subscribe(()=>{var m;const f=((m=e.getCurrentSelections())==null?void 0:m.map(N=>N.range))||[],o=n.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET);if(!o)return;const p=o.getActiveSheet();if(!p)return;const S=(l.getSubunitRules(o.getUnitId(),p.getSheetId())||[]).filter(N=>N.ranges.some(w=>f.some(E=>s.Rectangle.intersects(E,w)))).map(N=>N.ranges).every(N=>O.checkRangesEditablePermission(a,o.getUnitId(),p.getSheetId(),N));d.next(S)})),i=new K.Observable(d=>new K.Observable(f=>{const o=t.onCommandExecuted(p=>{var m;const{id:h,params:b}=p,S=(m=n.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET))==null?void 0:m.getUnitId();_r.includes(h)&&b.unitId===S&&f.next(null)});return()=>o.dispose()}).pipe(se.debounceTime(16)).subscribe(()=>{const f=n.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET);if(!f)return;const o=f.getActiveSheet();if(!o)return;const p=l.getSubunitRules(f.getUnitId(),o.getSheetId())||[];if(!p.length)return d.next(!1),!1;const h=p.map(b=>b.ranges).every(b=>O.checkRangesEditablePermission(a,f.getUnitId(),o.getSheetId(),b));d.next(h)})),v=new K.Observable(d=>{u.subscribe(f=>{const o=Ie.find(p=>p.value===G.clearRangeRules);o&&(o.disabled=!f,d.next(Ie))}),i.subscribe(f=>{const o=Ie.find(p=>p.value===G.clearWorkSheetRules);o&&(o.disabled=!f,d.next(Ie))}),d.next(Ie)});return{id:pe.id,type:A.MenuItemType.SELECTOR,icon:"ConditionsDoubleIcon",tooltip:"sheet.cf.title",selections:v,hidden$:A.getMenuHiddenObservable(a,s.UniverInstanceType.UNIVER_SHEET),disabled$:q.getCurrentRangeDisable$(a,{workbookTypes:[O.WorkbookEditablePermission],worksheetTypes:[O.WorksheetSetCellStylePermission,O.WorksheetEditPermission],rangeTypes:[O.RangeProtectionPermissionEditPoint]})}},Vt={[A.RibbonDataGroup.RULES]:{[pe.id]:{order:1,menuItemFactory:Mt}}};var Ot=Object.getOwnPropertyDescriptor,Ut=(a,e,t,n)=>{for(var l=n>1?void 0:n?Ot(e,t):e,u=a.length-1,i;u>=0;u--)(i=a[u])&&(l=i(l)||l);return l},wr=(a,e)=>(t,n)=>e(t,n,a);let ke=class extends s.Disposable{constructor(e,t){super();X(this,"_sidebarDisposable",null);this._injector=e,this._menuManagerService=t,this._menuManagerService.mergeMenu(Vt)}};ke=Ut([wr(0,s.Inject(s.Injector)),wr(1,A.IMenuManagerService)],ke);var kt=Object.defineProperty,Pt=Object.getOwnPropertyDescriptor,Dt=(a,e,t)=>e in a?kt(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t,Lt=(a,e,t,n)=>{for(var l=n>1?void 0:n?Pt(e,t):e,u=a.length-1,i;u>=0;u--)(i=a[u])&&(l=i(l)||l);return l},rr=(a,e)=>(t,n)=>e(t,n,a),Pe=(a,e,t)=>Dt(a,typeof e!="symbol"?e+"":e,t);P.UniverSheetsConditionalFormattingUIPlugin=class extends s.Plugin{constructor(e=Ee,t,n,l){super(),this._config=e,this._injector=t,this._commandService=n,this._configService=l;const{menu:u,...i}=s.merge({},Ee,this._config);u&&this._configService.setConfig("menu",u,{merge:!0}),this._configService.setConfig(Sr,i),this._initCommand()}onStarting(){s.registerDependencies(this._injector,[[me],[ye],[Me],[Ce],[ve],[ke],[le],[Ve],[P.ConditionalFormattingClearController],[Oe],[Ue],[he]]),s.touchDependencies(this._injector,[[me],[he]])}onReady(){s.touchDependencies(this._injector,[[ke],[ve]])}onRendered(){s.touchDependencies(this._injector,[[Me],[P.ConditionalFormattingClearController],[ye],[Ve],[le],[Oe],[Ce],[Ue]])}_initCommand(){[Ae,Fe,$e,Be,He,We,qe,Ge,Ze,pe].forEach(e=>{this._commandService.registerCommand(e)})}},Pe(P.UniverSheetsConditionalFormattingUIPlugin,"pluginName",`${r.SHEET_CONDITIONAL_FORMATTING_PLUGIN}_UI_PLUGIN`),Pe(P.UniverSheetsConditionalFormattingUIPlugin,"packageName",Ne.name),Pe(P.UniverSheetsConditionalFormattingUIPlugin,"version",Ne.version),Pe(P.UniverSheetsConditionalFormattingUIPlugin,"type",s.UniverInstanceType.UNIVER_SHEET),P.UniverSheetsConditionalFormattingUIPlugin=Lt([s.DependentOn(r.UniverSheetsConditionalFormattingPlugin,nr.UniverSheetsFormulaPlugin),rr(1,s.Inject(s.Injector)),rr(2,s.Inject(s.ICommandService)),rr(3,s.IConfigService)],P.UniverSheetsConditionalFormattingUIPlugin),P.AddAverageCfCommand=Ae,P.AddColorScaleConditionalRuleCommand=Fe,P.AddDataBarConditionalRuleCommand=$e,P.AddDuplicateValuesCfCommand=Be,P.AddNumberCfCommand=He,P.AddRankCfCommand=We,P.AddTextCfCommand=qe,P.AddTimePeriodCfCommand=Ge,P.AddUniqueValuesCfCommand=Ze,P.OpenConditionalFormattingOperator=pe,Object.defineProperty(P,Symbol.toStringTag,{value:"Module"})}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@univerjs/sheets-conditional-formatting-ui",
3
- "version": "0.16.1-insiders.20260311-074e8ca",
3
+ "version": "0.17.0",
4
4
  "private": false,
5
5
  "description": "Conditional formatting plugin for Univer Sheets",
6
6
  "author": "DreamNum <developer@univer.ai>",
@@ -55,16 +55,16 @@
55
55
  },
56
56
  "dependencies": {
57
57
  "@univerjs/icons": "^1.1.1",
58
- "@univerjs/core": "0.16.1-insiders.20260311-074e8ca",
59
- "@univerjs/design": "0.16.1-insiders.20260311-074e8ca",
60
- "@univerjs/engine-formula": "0.16.1-insiders.20260311-074e8ca",
61
- "@univerjs/engine-render": "0.16.1-insiders.20260311-074e8ca",
62
- "@univerjs/sheets": "0.16.1-insiders.20260311-074e8ca",
63
- "@univerjs/sheets-conditional-formatting": "0.16.1-insiders.20260311-074e8ca",
64
- "@univerjs/sheets-formula": "0.16.1-insiders.20260311-074e8ca",
65
- "@univerjs/sheets-formula-ui": "0.16.1-insiders.20260311-074e8ca",
66
- "@univerjs/sheets-ui": "0.16.1-insiders.20260311-074e8ca",
67
- "@univerjs/ui": "0.16.1-insiders.20260311-074e8ca"
58
+ "@univerjs/design": "0.17.0",
59
+ "@univerjs/core": "0.17.0",
60
+ "@univerjs/engine-formula": "0.17.0",
61
+ "@univerjs/engine-render": "0.17.0",
62
+ "@univerjs/sheets": "0.17.0",
63
+ "@univerjs/sheets-conditional-formatting": "0.17.0",
64
+ "@univerjs/sheets-formula": "0.17.0",
65
+ "@univerjs/sheets-formula-ui": "0.17.0",
66
+ "@univerjs/ui": "0.17.0",
67
+ "@univerjs/sheets-ui": "0.17.0"
68
68
  },
69
69
  "devDependencies": {
70
70
  "postcss": "^8.5.8",
@@ -74,7 +74,7 @@
74
74
  "typescript": "^5.9.3",
75
75
  "vite": "^7.3.1",
76
76
  "vitest": "^4.0.18",
77
- "@univerjs-infra/shared": "0.16.1"
77
+ "@univerjs-infra/shared": "0.17.0"
78
78
  },
79
79
  "scripts": {
80
80
  "test": "vitest run",