@univerjs/sheets-data-validation-ui 0.6.10-nightly.202504171607 → 0.6.10

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 +1 @@
1
- "use strict";var xt=Object.defineProperty;var Bt=(e,t,n)=>t in e?xt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var A=(e,t,n)=>Bt(e,typeof t!="symbol"?t+"":t,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("@univerjs/core"),S=require("@univerjs/sheets-data-validation"),m=require("react/jsx-runtime"),b=require("@univerjs/design"),y=require("@univerjs/ui"),E=require("react"),gt=require("@univerjs/sheets-formula-ui"),z=require("@univerjs/data-validation"),ie=require("rxjs"),P=require("@univerjs/engine-render"),H=require("@univerjs/sheets"),Ht=require("@univerjs/sheets-numfmt"),N=require("@univerjs/sheets-ui"),lt=require("@univerjs/engine-formula"),Wt="univer-data-validation-formula",$t="univer-data-validation-formula-and",Yt="univer-data-validation-formula-list-item",Xt="univer-data-validation-formula-list-item-icon",zt="univer-data-validation-formula-list-item-drag",Kt="univer-data-validation-formula-list-add",Gt="univer-data-validation-formula-color-select",qt="univer-data-validation-formula-color-select-panel",Zt="univer-data-validation-formula-color-item",ee={dataValidationFormula:Wt,dataValidationFormulaAnd:$t,dataValidationFormulaListItem:Yt,dataValidationFormulaListItemIcon:Xt,dataValidationFormulaListItemDrag:zt,dataValidationFormulaListAdd:Kt,dataValidationFormulaColorSelect:Gt,dataValidationFormulaColorSelectPanel:qt,dataValidationFormulaColorItem:Zt},Jt=e=>{const{isTwoFormula:t=!1,value:n,onChange:a,showError:i,validResult:o}=e,s=y.useDependency(r.LocaleService),d=i?o==null?void 0:o.formula1:"",l=i?o==null?void 0:o.formula2:"";return t?m.jsxs(m.Fragment,{children:[m.jsx(b.FormLayout,{error:d,children:m.jsx(b.Input,{className:ee.dataValidationFormula,placeholder:s.t("dataValidation.panel.formulaPlaceholder"),value:n==null?void 0:n.formula1,onChange:c=>{a==null||a({...n,formula1:c})}})}),m.jsx("div",{className:ee.dataValidationFormulaAnd,children:s.t("dataValidation.panel.formulaAnd")}),m.jsx(b.FormLayout,{error:l,children:m.jsx(b.Input,{className:ee.dataValidationFormula,placeholder:s.t("dataValidation.panel.formulaPlaceholder"),value:n==null?void 0:n.formula2,onChange:c=>{a==null||a({...n,formula2:c})}})})]}):m.jsx(b.FormLayout,{error:d,children:m.jsx(b.Input,{className:ee.dataValidationFormula,placeholder:s.t("dataValidation.panel.formulaPlaceholder"),value:n==null?void 0:n.formula1,onChange:c=>{a==null||a({formula1:c})}})})};function Qt(e){const{value:t,onChange:n,showError:a,validResult:i}=e,o=y.useDependency(r.LocaleService),s=a?i==null?void 0:i.formula1:"",d=a?i==null?void 0:i.formula2:"",[l,c]=E.useState(!((t==null?void 0:t.formula1)===void 0&&(t==null?void 0:t.formula2)===void 0));return m.jsxs(m.Fragment,{children:[m.jsx(b.FormLayout,{children:m.jsx(b.Checkbox,{checked:l,onChange:h=>{h?c(!0):(c(!1),n==null||n({...t,formula1:void 0,formula2:void 0}))},children:o.t("dataValidation.checkbox.tips")})}),l?m.jsx(b.FormLayout,{label:o.t("dataValidation.checkbox.checked"),error:s,children:m.jsx(b.Input,{className:ee.dataValidationFormula,placeholder:o.t("dataValidation.panel.valuePlaceholder"),value:t==null?void 0:t.formula1,onChange:h=>{n==null||n({...t,formula1:h||void 0})}})}):null,l?m.jsx(b.FormLayout,{label:o.t("dataValidation.checkbox.unchecked"),error:d,children:m.jsx(b.Input,{className:ee.dataValidationFormula,placeholder:o.t("dataValidation.panel.valuePlaceholder"),value:t==null?void 0:t.formula2,onChange:h=>{n==null||n({...t,formula2:h||void 0})}})}):null]})}function ea(e){var g;const{unitId:t,subUnitId:n,value:a,onChange:i,showError:o,validResult:s}=e,d=o?s==null?void 0:s.formula1:void 0,l=E.useRef(null),[c,h]=E.useState(!1);return y.useSidebarClick(u=>{var v;((v=l.current)==null?void 0:v.isClickOutSide(u))&&h(!1)}),m.jsx(gt.FormulaEditor,{initValue:(g=a==null?void 0:a.formula1)!=null?g:"=",unitId:t,subUnitId:n,isFocus:c,onChange:u=>{const I=(u!=null?u:"").trim();I!==(a==null?void 0:a.formula1)&&(i==null||i({...a,formula1:I}))},errorText:d,onFocus:()=>h(!0),isSupportAcrossSheet:!0,ref:l})}var ne=function(){return ne=Object.assign||function(e){for(var t,n=1,a=arguments.length;n<a;n++){t=arguments[n];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])}return e},ne.apply(this,arguments)},ta=function(e,t){var n={};for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&t.indexOf(a)<0&&(n[a]=e[a]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,a=Object.getOwnPropertySymbols(e);i<a.length;i++)t.indexOf(a[i])<0&&Object.prototype.propertyIsEnumerable.call(e,a[i])&&(n[a[i]]=e[a[i]]);return n},Se=E.forwardRef(function(e,t){var n=e.icon,a=e.id,i=e.className,o=e.extend,s=ta(e,["icon","id","className","extend"]),d="univerjs-icon univerjs-icon-".concat(a," ").concat(i||"").trim(),l=E.useRef("_".concat(ia()));return Dt(n,"".concat(a),{defIds:n.defIds,idSuffix:l.current},ne({ref:t,className:d},s),o)});function Dt(e,t,n,a,i){return E.createElement(e.tag,ne(ne({key:t},aa(e,n,i)),a),(na(e,n).children||[]).map(function(o,s){return Dt(o,"".concat(t,"-").concat(e.tag,"-").concat(s),n,void 0,i)}))}function aa(e,t,n){var a=ne({},e.attrs);n!=null&&n.colorChannel1&&a.fill==="colorChannel1"&&(a.fill=n.colorChannel1),e.tag==="mask"&&a.id&&(a.id=a.id+t.idSuffix),Object.entries(a).forEach(function(o){var s=o[0],d=o[1];s==="mask"&&typeof d=="string"&&(a[s]=d.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))});var i=t.defIds;return!i||i.length===0||(e.tag==="use"&&a["xlink:href"]&&(a["xlink:href"]=a["xlink:href"]+t.idSuffix),Object.entries(a).forEach(function(o){var s=o[0],d=o[1];typeof d=="string"&&(a[s]=d.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))})),a}function na(e,t){var n,a=t.defIds;return!a||a.length===0?e:e.tag==="defs"&&(!((n=e.children)===null||n===void 0)&&n.length)?ne(ne({},e),{children:e.children.map(function(i){return typeof i.attrs.id=="string"&&a&&a.indexOf(i.attrs.id)>-1?ne(ne({},i),{attrs:ne(ne({},i.attrs),{id:i.attrs.id+t.idSuffix})}):i})}):e}function ia(){return Math.random().toString(36).substring(2,8)}Se.displayName="UniverIcon";var oa={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M1.4917 3.07803C1.4917 2.19437 2.20804 1.47803 3.0917 1.47803H5.6917C6.57536 1.47803 7.2917 2.19437 7.2917 3.07803V5.67803C7.2917 6.56168 6.57535 7.27803 5.6917 7.27803H3.0917C2.20804 7.27803 1.4917 6.56168 1.4917 5.67803V3.07803ZM3.0917 2.67803C2.87078 2.67803 2.6917 2.85711 2.6917 3.07803V5.67803C2.6917 5.89894 2.87079 6.07803 3.0917 6.07803H5.6917C5.91261 6.07803 6.0917 5.89894 6.0917 5.67803V3.07803C6.0917 2.85711 5.91261 2.67803 5.6917 2.67803H3.0917Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M14.6175 2.45279C14.8518 2.68711 14.8518 3.06701 14.6175 3.30132L11.6151 6.30365C11.3957 6.52307 11.0451 6.53897 10.8067 6.34031L8.80915 4.67566C8.55458 4.46352 8.52019 4.08518 8.73233 3.83062 8.94447 3.57605 9.32281 3.54166 9.57737 3.7538L11.154 5.06767 13.769 2.45278C14.0033 2.21847 14.3832 2.21848 14.6175 2.45279zM14.1175 9.19746C14.3518 9.43178 14.3518 9.81168 14.1175 10.046L12.5418 11.6217 14.1175 13.1975C14.3518 13.4318 14.3518 13.8117 14.1175 14.046 13.8832 14.2803 13.5033 14.2803 13.269 14.046L11.6933 12.4703 10.1175 14.046C9.88321 14.2803 9.50331 14.2803 9.269 14.046 9.03468 13.8117 9.03468 13.4318 9.269 13.1975L10.8447 11.6217 9.269 10.046C9.03468 9.81168 9.03468 9.43178 9.269 9.19746 9.50331 8.96315 9.88321 8.96315 10.1175 9.19746L11.6933 10.7732 13.269 9.19746C13.5033 8.96315 13.8832 8.96315 14.1175 9.19746z"}},{tag:"path",attrs:{fill:"currentColor",d:"M3.0917 8.72168C2.20804 8.72168 1.4917 9.43802 1.4917 10.3217V12.9217C1.4917 13.8053 2.20804 14.5217 3.0917 14.5217H5.6917C6.57535 14.5217 7.2917 13.8053 7.2917 12.9217V10.3217C7.2917 9.43802 6.57536 8.72168 5.6917 8.72168H3.0917ZM2.6917 10.3217C2.6917 10.1008 2.87078 9.92168 3.0917 9.92168H5.6917C5.91261 9.92168 6.0917 10.1008 6.0917 10.3217V12.9217C6.0917 13.1426 5.91261 13.3217 5.6917 13.3217H3.0917C2.87079 13.3217 2.6917 13.1426 2.6917 12.9217V10.3217Z",fillRule:"evenodd",clipRule:"evenodd"}}]},yt=E.forwardRef(function(e,t){return E.createElement(Se,Object.assign({},e,{id:"data-validation-single",ref:t,icon:oa}))});yt.displayName="DataValidationSingle";var ra={tag:"svg",attrs:{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.866699 5.9313.866699H10.069C10.4004.866699 10.669 1.13533 10.669 1.4667 10.669 1.79807 10.4004 2.0667 10.069 2.0667H5.9313C5.59993 2.0667 5.3313 1.79807 5.3313 1.4667zM1.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.64443 14.8999 3.9758 14.6312 4.24443 14.2999 4.24443H1.69985C1.36848 4.24443 1.09985 3.9758 1.09985 3.64443zM6.12398 8.30171C6.35829 8.0674 6.73819 8.0674 6.97251 8.30171L8.00007 9.32928 9.02764 8.30171C9.26195 8.0674 9.64185 8.0674 9.87617 8.30171 10.1105 8.53603 10.1105 8.91593 9.87617 9.15024L8.8486 10.1778 9.87617 11.2054C10.1105 11.4397 10.1105 11.8196 9.87617 12.0539 9.64185 12.2882 9.26195 12.2882 9.02764 12.0539L8.00007 11.0263 6.97251 12.0539C6.73819 12.2882 6.35829 12.2882 6.12398 12.0539 5.88966 11.8196 5.88966 11.4397 6.12398 11.2054L7.15154 10.1778 6.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"}}]},pt=E.forwardRef(function(e,t){return E.createElement(Se,Object.assign({},e,{id:"delete-single",ref:t,icon:ra}))});pt.displayName="DeleteSingle";var sa={tag:"svg",attrs:{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"}}]},Rt=E.forwardRef(function(e,t){return E.createElement(Se,Object.assign({},e,{id:"increase-single",ref:t,icon:sa}))});Rt.displayName="IncreaseSingle";var la={tag:"svg",attrs:{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"}}]},wt=E.forwardRef(function(e,t){return E.createElement(Se,Object.assign({},e,{id:"more-down-single",ref:t,icon:la}))});wt.displayName="MoreDownSingle";var da={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M4.64645 9.85355C4.45118 9.65829 4.45118 9.34171 4.64645 9.14645L7.64645 6.14645C7.84171 5.95118 8.15829 5.95118 8.35355 6.14645L11.3536 9.14645C11.5488 9.34171 11.5488 9.65829 11.3536 9.85355C11.1583 10.0488 10.8417 10.0488 10.6464 9.85355L8 7.20711L5.35355 9.85355C5.15829 10.0488 4.84171 10.0488 4.64645 9.85355Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Et=E.forwardRef(function(e,t){return E.createElement(Se,Object.assign({},e,{id:"more-up-single",ref:t,icon:da}))});Et.displayName="MoreUpSingle";var ca={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"mask",attrs:{id:"mask0_622_8",style:{maskType:"alpha"},width:16,height:16,x:0,y:0,maskUnits:"userSpaceOnUse"},children:[{tag:"path",attrs:{fill:"#D9D9D9",d:"M0 0H16V16H0z"}}]},{tag:"g",attrs:{fill:"currentColor",mask:"url(#mask0_622_8)"},children:[{tag:"path",attrs:{d:"M6 5C6.55228 5 7 4.55228 7 4 7 3.44772 6.55228 3 6 3 5.44772 3 5 3.44772 5 4 5 4.55228 5.44772 5 6 5zM6 9C6.55228 9 7 8.55229 7 8 7 7.44772 6.55228 7 6 7 5.44772 7 5 7.44772 5 8 5 8.55229 5.44772 9 6 9zM7 12C7 12.5523 6.55228 13 6 13 5.44772 13 5 12.5523 5 12 5 11.4477 5.44772 11 6 11 6.55228 11 7 11.4477 7 12zM10 5C10.5523 5 11 4.55228 11 4 11 3.44772 10.5523 3 10 3 9.44771 3 9 3.44772 9 4 9 4.55228 9.44771 5 10 5zM11 8C11 8.55229 10.5523 9 10 9 9.44771 9 9 8.55229 9 8 9 7.44772 9.44771 7 10 7 10.5523 7 11 7.44772 11 8zM10 13C10.5523 13 11 12.5523 11 12 11 11.4477 10.5523 11 10 11 9.44771 11 9 11.4477 9 12 9 12.5523 9.44771 13 10 13z"}}]}]},Mt=E.forwardRef(function(e,t){return E.createElement(Se,Object.assign({},e,{id:"sequence-single",ref:t,icon:ca}))});Mt.displayName="SequenceSingle";const ye="#ECECEC",ua=["#FFFFFF","#FEE7E7","#FEF0E6","#EFFBD0","#E4F4FE","#E8ECFD","#F1EAFA","#FDE8F3","#E5E5E5","#FDCECE","#FDC49B","#DEF6A2","#9FDAFF","#D0D9FB","#E3D5F6","#FBD0E8","#656565","#FE4B4B","#FF8C51","#8BBB11","#0B9EFB","#3A60F7","#9E6DE3","#F248A6"],ha=e=>{const{value:t,onChange:n,disabled:a}=e,[i,o]=E.useState(!1);return m.jsx(b.Select,{disabled:a,open:i,onDropdownVisibleChange:o,dropdownStyle:{width:112},style:{width:96,cursor:"pointer"},className:ee.dataValidationFormulaColorSelect,value:t,onChange:n,labelRender:s=>m.jsx("div",{className:ee.dataValidationFormulaColorItem,style:{background:s.value,marginTop:5}}),dropdownRender:()=>m.jsx("div",{className:ee.dataValidationFormulaColorSelectPanel,children:ua.map(s=>m.jsx("div",{onClick:()=>{n(s),o(!1)},className:ee.dataValidationFormulaColorItem,style:{background:s}},s))})})},ft=e=>{const{item:t,commonProps:n,style:a}=e,{onItemChange:i,onItemDelete:o}=n;return m.jsxs("div",{className:ee.dataValidationFormulaListItem,style:a,children:[t.isRef?null:m.jsx("div",{className:b.clsx(ee.dataValidationFormulaListItemDrag,"draggableHandle"),children:m.jsx(Mt,{})}),m.jsx(ha,{value:t.color,onChange:s=>{i(t.id,t.label,s)}}),m.jsx(b.Input,{disabled:t.isRef,value:t.label,onChange:s=>{i(t.id,s,t.color)}}),t.isRef?null:m.jsx("div",{className:ee.dataValidationFormulaListItemIcon,children:m.jsx(pt,{onClick:()=>o(t.id)})})]})};function ga(e){const{value:t,onChange:n=()=>{},unitId:a,subUnitId:i,validResult:o,showError:s,ruleId:d}=e,{formula1:l="",formula2:c=""}=t||{},h=E.useRef(null),[g,u]=E.useState(()=>r.isFormulaString(l)?"1":"0"),[I,v]=E.useState(g==="1"?l:"="),[M,R]=E.useState(g==="1"?l:"="),p=y.useDependency(r.LocaleService),f=y.useDependency(z.DataValidatorRegistryService),_=y.useDependency(z.DataValidationModel),O=y.useDependency(S.DataValidationFormulaController),[w,V]=E.useState(()=>c.split(",")),D=f.getValidatorItem(r.DataValidationType.LIST),[T,k]=E.useState([]),[B,U]=E.useState(""),F=s?o==null?void 0:o.formula1:"",x=E.useMemo(()=>_.ruleChange$.pipe(ie.debounceTime(16)),[]),X=y.useObservable(x),W=y.useEvent(n);E.useEffect(()=>{(async()=>{await new Promise(L=>{setTimeout(()=>L(!0),100)});const j=_.getRuleById(a,i,d),C=j==null?void 0:j.formula1;if(r.isFormulaString(C)&&D&&j){const L=await D.getListAsync(j,a,i);k(L)}})()},[_,X,D,d,i,a]),E.useEffect(()=>{r.isFormulaString(l)&&l!==M&&(v(l),R(M))},[M,l]);const[Y,K]=E.useState(()=>{const j=g!=="1"?S.deserializeListOptions(l):[],C=c.split(",");return j.map((L,$)=>({label:L,color:C[$]||ye,isRef:!1,id:r.Tools.generateRandomId(4)}))}),Z=(j,C,L)=>{const $=Y.find(J=>J.id===j);$&&($.label=C,$.color=L,K([...Y]))},q=j=>{const C=Y.findIndex(L=>L.id===j);C!==-1&&(Y.splice(C,1),K([...Y]))},te=c.split(","),se=E.useMemo(()=>T.map((j,C)=>({label:j,color:te[C]||ye,id:`${C}`,isRef:!0})),[te,T]),oe=(j,C,L)=>{const $=[...w];$[+j]=L,V($),W({formula1:l,formula2:$.join(",")})},ae=()=>{K([...Y,{label:"",color:ye,isRef:!1,id:r.Tools.generateRandomId(4)}])};E.useEffect(()=>{if(g==="1")return;const j=new Set,C=[];Y.map(L=>({labelList:L.label.split(","),item:L})).forEach(({item:L,labelList:$})=>{$.forEach(J=>{j.has(J)||(j.add(J),C.push({label:J,color:L.color}))})}),W({formula1:S.serializeListOptions(C.map(L=>L.label)),formula2:C.map(L=>L.color===ye?"":L.color).join(",")})},[Y,W,g,M,w]);const le=y.useEvent(async j=>{if(!r.isFormulaString(j)){W==null||W({formula1:"",formula2:c});return}O.getFormulaRefCheck(j)?(W==null||W({formula1:r.isFormulaString(j)?j:"",formula2:c}),U("")):(W==null||W({formula1:"",formula2:c}),v("="),U(p.t("dataValidation.validFail.formulaError")))}),de=E.useRef(null),[ge,Le]=E.useState(!1);return y.useSidebarClick(j=>{var L;((L=de.current)==null?void 0:L.isClickOutSide(j))&&Le(!1)}),m.jsxs(m.Fragment,{children:[m.jsx(b.FormLayout,{label:p.t("dataValidation.list.options"),children:m.jsxs(b.RadioGroup,{value:g,onChange:j=>{u(j),v(M),j==="1"&&W({formula1:M==="="?"":M,formula2:w.join(",")})},children:[m.jsx(b.Radio,{value:"0",children:p.t("dataValidation.list.customOptions")}),m.jsx(b.Radio,{value:"1",children:p.t("dataValidation.list.refOptions")})]})}),g==="1"?m.jsxs(m.Fragment,{children:[m.jsx(gt.FormulaEditor,{initValue:I,unitId:a,subUnitId:i,isFocus:ge,onChange:(j="")=>{const C=(j!=null?j:"").trim();R(C),le(C)},errorText:F||B||void 0,onFocus:()=>Le(!0),isSupportAcrossSheet:!0,ref:de}),m.jsx("div",{ref:h,style:{marginTop:"12px"},children:se.map(j=>m.jsx(ft,{item:j,commonProps:{onItemChange:oe},style:{marginBottom:12}},j.id))})]}):m.jsx(b.FormLayout,{error:F,children:m.jsxs("div",{ref:h,style:{marginTop:"-12px"},children:[m.jsx(b.DraggableList,{list:Y,onListChange:K,rowHeight:32,margin:[0,12],draggableHandle:".draggableHandle",itemRender:j=>m.jsx(ft,{item:j,commonProps:{onItemChange:Z,onItemDelete:q}},j.id),idKey:"id"}),m.jsxs("a",{className:ee.dataValidationFormulaListAdd,onClick:ae,children:[m.jsx(Rt,{}),p.t("dataValidation.list.add")]})]})})]})}const pa=[[S.CUSTOM_FORMULA_INPUT_NAME,ea],[S.BASE_FORMULA_INPUT_NAME,Jt],[S.LIST_FORMULA_INPUT_NAME,ga],[S.CHECKBOX_FORMULA_INPUT_NAME,Qt]];var ma=Object.getOwnPropertyDescriptor,va=(e,t,n,a)=>{for(var i=a>1?void 0:a?ma(t,n):t,o=e.length-1,s;o>=0;o--)(s=e[o])&&(i=s(i)||i);return i},fa=(e,t)=>(n,a)=>t(n,a,e);exports.BaseSheetDataValidatorView=class{constructor(t){A(this,"canvasRender",null);A(this,"dropdownType");A(this,"optionsInput");A(this,"formulaInput",S.LIST_FORMULA_INPUT_NAME);this.injector=t}};exports.BaseSheetDataValidatorView=va([fa(0,r.Inject(r.Injector))],exports.BaseSheetDataValidatorView);var Sa=Object.getOwnPropertyDescriptor,_a=(e,t,n,a)=>{for(var i=a>1?void 0:a?Sa(t,n):t,o=e.length-1,s;o>=0;o--)(s=e[o])&&(i=s(i)||i);return i},St=(e,t)=>(n,a)=>t(n,a,e);let he=class extends r.Disposable{constructor(t,n){super();A(this,"_open$",new ie.BehaviorSubject(!1));A(this,"open$",this._open$.pipe(ie.distinctUntilChanged()));A(this,"_activeRule");A(this,"_activeRule$",new ie.BehaviorSubject(void 0));A(this,"activeRule$",this._activeRule$.asObservable());A(this,"_closeDisposable",null);this._univerInstanceService=t,this._sidebarService=n,this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(r.UniverInstanceType.UNIVER_SHEET).pipe(ie.filter(a=>!a)).subscribe(()=>{this.close()})),this.disposeWithMe(this._sidebarService.sidebarOptions$.subscribe(a=>{a.id===We&&(a.visible||setTimeout(()=>{this._sidebarService.sidebarOptions$.next({visible:!1})}))}))}get activeRule(){return this._activeRule}get isOpen(){return this._open$.getValue()}dispose(){var t;super.dispose(),this._open$.next(!1),this._open$.complete(),this._activeRule$.complete(),(t=this._closeDisposable)==null||t.dispose()}open(){this._open$.next(!0)}close(){var t;this._open$.next(!1),(t=this._closeDisposable)==null||t.dispose()}setCloseDisposable(t){this._closeDisposable=r.toDisposable(()=>{t.dispose(),this._closeDisposable=null})}setActiveRule(t){this._activeRule=t,this._activeRule$.next(t)}};he=_a([St(0,r.IUniverInstanceService),St(1,y.ISidebarService)],he);var Ia=Object.getOwnPropertyDescriptor,Ca=(e,t,n,a)=>{for(var i=a>1?void 0:a?Ia(t,n):t,o=e.length-1,s;o>=0;o--)(s=e[o])&&(i=s(i)||i);return i},Ie=(e,t)=>(n,a)=>t(n,a,e);let we=class extends r.Disposable{constructor(e,t,n,a,i,o){super(),this._sheetInterceptorService=e,this._dataValidationModel=t,this._dataValidatorRegistryService=n,this._dialogService=a,this._localeService=i,this._sheetsDataValidationValidatorService=o,this._initEditorBridgeInterceptor()}_initEditorBridgeInterceptor(){this._sheetInterceptorService.writeCellInterceptor.intercept(H.VALIDATE_CELL,{handler:async(e,t,n)=>{const a=await e,{row:i,col:o,unitId:s,subUnitId:d}=t,l=this._dataValidationModel.getRuleIdByLocation(s,d,i,o),c=l?this._dataValidationModel.getRuleById(s,d,l):void 0;if(a===!1)return n(Promise.resolve(!1));if(!c||c.errorStyle!==r.DataValidationErrorStyle.STOP)return n(Promise.resolve(!0));const h=this._dataValidatorRegistryService.getValidatorItem(c.type);return!h||await this._sheetsDataValidationValidatorService.validatorCell(s,d,i,o)===r.DataValidationStatus.VALID?n(Promise.resolve(!0)):(this._dialogService.open({width:368,title:{title:this._localeService.t("dataValidation.alert.title")},id:"reject-input-dialog",children:{title:h.getRuleFinalError(c,{row:i,col:o,unitId:s,subUnitId:d})},footer:{title:E.createElement(b.Button,{variant:"primary",onClick:()=>this._dialogService.close("reject-input-dialog")},this._localeService.t("dataValidation.alert.ok"))},onClose:()=>{this._dialogService.close("reject-input-dialog")}}),n(Promise.resolve(!1)))}})}showReject(e){this._dialogService.open({width:368,title:{title:this._localeService.t("dataValidation.alert.title")},id:"reject-input-dialog",children:{title:e},footer:{title:E.createElement(b.Button,{variant:"primary",onClick:()=>this._dialogService.close("reject-input-dialog")},this._localeService.t("dataValidation.alert.ok"))},onClose:()=>{this._dialogService.close("reject-input-dialog")}})}};we=Ca([Ie(0,r.Inject(H.SheetInterceptorService)),Ie(1,r.Inject(S.SheetDataValidationModel)),Ie(2,r.Inject(z.DataValidatorRegistryService)),Ie(3,y.IDialogService),Ie(4,r.Inject(r.LocaleService)),Ie(5,r.Inject(S.SheetsDataValidationValidatorService))],we);var Va=Object.getOwnPropertyDescriptor,Da=(e,t,n,a)=>{for(var i=a>1?void 0:a?Va(t,n):t,o=e.length-1,s;o>=0;o--)(s=e[o])&&(i=s(i)||i);return i},ce=(e,t)=>(n,a)=>t(n,a,e);const Ze=e=>{if(e==null||typeof e=="boolean")return;if(typeof e=="number"||!Number.isNaN(+e))return r.dayjs(r.numfmt.format("yyyy-MM-dd HH:mm:ss",Number(e)));const t=r.dayjs(e);if(t.isValid())return t};function ya(e,t){const n=Ht.getPatternType(t);if(e===n)return t;switch(e){case"datetime":return"yyyy-MM-dd hh:mm:ss";case"date":return"yyyy-MM-dd";case"time":return"HH:mm:ss"}}let fe=class extends r.Disposable{constructor(t,n,a,i,o,s,d,l,c,h){super();A(this,"_activeDropdown");A(this,"_activeDropdown$",new ie.Subject);A(this,"_currentPopup",null);A(this,"activeDropdown$",this._activeDropdown$.asObservable());A(this,"_zenVisible",!1);this._univerInstanceService=t,this._dataValidatorRegistryService=n,this._zenZoneService=a,this._dataValidationModel=i,this._sheetsSelectionsService=o,this._cellDropdownManagerService=s,this._sheetDataValidationModel=d,this._commandService=l,this._editorBridgeService=c,this._injector=h,this._init(),this._initSelectionChange(),this.disposeWithMe(()=>{this._activeDropdown$.complete()})}get activeDropdown(){return this._activeDropdown}_init(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(t=>{this._zenVisible=t,t&&this.hideDropdown()}))}_getDropdownByCell(t,n,a,i){const o=t?this._univerInstanceService.getUnit(t,r.UniverInstanceType.UNIVER_SHEET):this._univerInstanceService.getCurrentUnitForType(r.UniverInstanceType.UNIVER_SHEET);if(!o)return;const s=n?o.getSheetBySheetId(n):o.getActiveSheet();if(!s)return;const d=this._dataValidationModel.getRuleByLocation(o.getUnitId(),s.getSheetId(),a,i);if(!d)return;const l=this._dataValidatorRegistryService.getValidatorItem(d.type);return l==null?void 0:l.dropdownType}_initSelectionChange(){this.disposeWithMe(this._sheetsSelectionsService.selectionMoveEnd$.subscribe(t=>{t&&t.every(n=>!(n.primary&&this._getDropdownByCell(n.primary.unitId,n.primary.sheetId,n.primary.actualRow,n.primary.actualColumn)))&&this.hideDropdown()}))}showDropdown(t){var M,R;const{location:n}=t,{row:a,col:i,unitId:o,subUnitId:s,workbook:d,worksheet:l}=n;if(this._currentPopup&&this._currentPopup.dispose(),this._zenVisible)return;this._activeDropdown=t,this._activeDropdown$.next(this._activeDropdown);const c=this._sheetDataValidationModel.getRuleByLocation(o,s,a,i);if(!c)return;const h=this._dataValidatorRegistryService.getValidatorItem(c.type);if(!(h!=null&&h.dropdownType))return;let g;const u=async(p,f)=>{var B,U,F;if(!p)return!0;const _=p,O=l.getCell(a,i),w=_.format(f==="date"?"YYYY-MM-DD 00:00:00":"YYYY-MM-DD HH:mm:ss"),V=(B=r.numfmt.parseDate(w))==null?void 0:B.v,D=f==="time"?V%1:V,T=d.getStyles().getStyleByCell(O),k=(F=(U=T==null?void 0:T.n)==null?void 0:U.pattern)!=null?F:"";return c.errorStyle!==r.DataValidationErrorStyle.STOP||await h.validator({value:D,unitId:o,subUnitId:s,row:a,column:i,worksheet:l,workbook:d,interceptValue:w.replace("Z","").replace("T"," "),t:r.CellValueType.NUMBER},c)?(await this._commandService.executeCommand(N.SetCellEditVisibleOperation.id,{visible:!1,eventType:P.DeviceInputEventType.Keyboard,unitId:o,keycode:y.KeyCode.ESC}),await this._commandService.executeCommand(H.SetRangeValuesCommand.id,{unitId:o,subUnitId:s,range:{startColumn:i,endColumn:i,startRow:a,endRow:a},value:{v:D,t:2,p:null,f:null,si:null,s:{n:{pattern:ya(f,k)}}}}),!0):(this._injector.has(we)&&this._injector.get(we).showReject(h.getRuleFinalError(c,{row:a,col:i,unitId:o,subUnitId:s})),!1)};let I;switch(h.dropdownType){case z.DataValidatorDropdownType.DATE:{const p=S.getCellValueOrigin(l.getCellRaw(a,i)),f=Ze(p),_=!!((M=c.bizInfo)!=null&&M.showTime);I={location:n,type:"datepicker",props:{showTime:_,onChange:O=>u(O,_?"datetime":"date"),defaultValue:f,patternType:"date"}};break}case z.DataValidatorDropdownType.TIME:{const p=S.getCellValueOrigin(l.getCellRaw(a,i)),f=Ze(p);I={location:n,type:"datepicker",props:{onChange:_=>u(_,"time"),defaultValue:f,patternType:"time"}};break}case z.DataValidatorDropdownType.DATETIME:{const p=S.getCellValueOrigin(l.getCellRaw(a,i)),f=Ze(p);I={location:n,type:"datepicker",props:{onChange:_=>u(_,"datetime"),defaultValue:f,patternType:"datetime"}};break}case z.DataValidatorDropdownType.LIST:case z.DataValidatorDropdownType.MULTIPLE_LIST:{const p=h.dropdownType===z.DataValidatorDropdownType.MULTIPLE_LIST,f=async T=>{const k=S.serializeListOptions(T),B={unitId:o,subUnitId:s,range:{startColumn:i,endColumn:i,startRow:a,endRow:a},value:{v:k,p:null,f:null,si:null}};return this._editorBridgeService.isVisible().visible&&await this._commandService.executeCommand(N.SetCellEditVisibleOperation.id,{visible:!1,eventType:P.DeviceInputEventType.Keyboard,unitId:o,keycode:y.KeyCode.ESC}),this._commandService.executeCommand(H.SetRangeValuesCommand.id,B),!p},_=(c==null?void 0:c.renderMode)===r.DataValidationRenderMode.CUSTOM||(c==null?void 0:c.renderMode)===void 0,O=h.getListWithColor(c,o,s),w=S.getDataValidationCellValue(l.getCellRaw(a,i)),V=()=>{this._commandService.executeCommand(_e.id,{ruleId:c.uid}),g==null||g.dispose()},D=O.map(T=>({label:T.label,value:T.label,color:_||T.color?T.color:"transparent"}));I={location:n,type:"list",props:{onChange:T=>f(T),options:D,onEdit:V,defaultValue:w,multiple:p}};break}case z.DataValidatorDropdownType.CASCADE:{I={type:"cascader",props:{onChange:f=>{const _={unitId:o,subUnitId:s,range:{startColumn:i,endColumn:i,startRow:a,endRow:a},value:{v:f.join("/"),p:null,f:null,si:null}};return this._editorBridgeService.isVisible().visible&&this._commandService.syncExecuteCommand(N.SetCellEditVisibleOperation.id,{visible:!1,eventType:P.DeviceInputEventType.Keyboard,unitId:o,keycode:y.KeyCode.ESC}),this._commandService.syncExecuteCommand(H.SetRangeValuesCommand.id,_),!0},defaultValue:S.getDataValidationCellValue(l.getCellRaw(a,i)).split("/"),options:JSON.parse((R=c.formula1)!=null?R:"[]")},location:n};break}case z.DataValidatorDropdownType.COLOR:{I={type:"color",props:{onChange:f=>{const _={unitId:o,subUnitId:s,range:{startColumn:i,endColumn:i,startRow:a,endRow:a},value:{v:f,p:null,f:null,si:null}};return this._editorBridgeService.isVisible().visible&&this._commandService.syncExecuteCommand(N.SetCellEditVisibleOperation.id,{visible:!1,eventType:P.DeviceInputEventType.Keyboard,unitId:o,keycode:y.KeyCode.ESC}),this._commandService.syncExecuteCommand(H.SetRangeValuesCommand.id,_),!0},defaultValue:S.getDataValidationCellValue(l.getCellRaw(a,i))},location:n};break}default:throw new Error("[DataValidationDropdownManagerService]: unknown type!")}if(g=this._cellDropdownManagerService.showDropdown(I),!g)throw new Error("[DataValidationDropdownManagerService]: cannot show dropdown!");const v=new r.DisposableCollection;v.add(g),v.add({dispose:()=>{var p,f;(f=(p=this._activeDropdown)==null?void 0:p.onHide)==null||f.call(p)}}),this._currentPopup=v}hideDropdown(){this._activeDropdown&&(this._currentPopup&&this._currentPopup.dispose(),this._currentPopup=null,this._activeDropdown=null,this._activeDropdown$.next(null))}showDataValidationDropdown(t,n,a,i,o){const s=this._univerInstanceService.getUnit(t,r.UniverInstanceType.UNIVER_SHEET);if(!s)return;const d=s.getSheetBySheetId(n);if(!d)return;const l=this._dataValidationModel.getRuleByLocation(s.getUnitId(),d.getSheetId(),a,i);if(!l)return;const c=this._dataValidatorRegistryService.getValidatorItem(l.type);if(!c||!c.dropdownType){this.hideDropdown();return}this.showDropdown({location:{workbook:s,worksheet:d,row:a,col:i,unitId:t,subUnitId:n},onHide:o})}};fe=Da([ce(0,r.IUniverInstanceService),ce(1,r.Inject(z.DataValidatorRegistryService)),ce(2,y.IZenZoneService),ce(3,r.Inject(S.SheetDataValidationModel)),ce(4,r.Inject(H.SheetsSelectionsService)),ce(5,r.Inject(N.ISheetCellDropdownManagerService)),ce(6,r.Inject(S.SheetDataValidationModel)),ce(7,r.ICommandService),ce(8,N.IEditorBridgeService),ce(9,r.Inject(r.Injector))],fe);const We="DataValidationPanel",_e={id:"data-validation.operation.open-validation-panel",type:r.CommandType.OPERATION,handler(e,t){if(!t)return!1;const{ruleId:n,isAdd:a}=t,i=e.get(he),o=e.get(z.DataValidationModel),s=e.get(r.IUniverInstanceService),d=e.get(y.ISidebarService),l=H.getSheetCommandTarget(s);if(!l)return!1;const{unitId:c,subUnitId:h}=l,g=n?o.getRuleById(c,h,n):void 0;i.open(),i.setActiveRule(g&&{unitId:c,subUnitId:h,rule:g});const u=d.open({id:We,header:{title:a?"dataValidation.panel.addTitle":"dataValidation.panel.title"},children:{label:We},width:312,onClose:()=>i.close()});return i.setCloseDisposable(u),!0}},mt={id:"data-validation.operation.close-validation-panel",type:r.CommandType.OPERATION,handler(e){return e.get(he).close(),!0}},Tt={id:"data-validation.operation.toggle-validation-panel",type:r.CommandType.OPERATION,handler(e){const t=e.get(r.ICommandService),n=e.get(he);return n.open(),n.isOpen?t.executeCommand(mt.id):t.executeCommand(_e.id),!0}},Ge={type:r.CommandType.OPERATION,id:"sheet.operation.show-data-validation-dropdown",handler(e,t){if(!t)return!1;const n=e.get(fe),{unitId:a,subUnitId:i,row:o,column:s}=t,d=n.activeDropdown,l=d==null?void 0:d.location;return l&&l.unitId===a&&l.subUnitId===i&&l.row===o&&l.col===s||n.showDataValidationDropdown(a,i,o,s),!0}},bt={type:r.CommandType.OPERATION,id:"sheet.operation.hide-data-validation-dropdown",handler(e,t){return t?(e.get(fe).hideDropdown(),!0):!1}},qe={type:r.CommandType.COMMAND,id:"data-validation.command.addRuleAndOpen",handler(e){const t=e.get(r.IUniverInstanceService),n=H.getSheetCommandTarget(t);if(!n)return!1;const{workbook:a,worksheet:i}=n,o=S.createDefaultNewRule(e),s=e.get(r.ICommandService),d=a.getUnitId(),l=i.getSheetId(),c={rule:o,unitId:d,subUnitId:l};return s.syncExecuteCommand(S.AddSheetDataValidationCommand.id,c)?(s.syncExecuteCommand(_e.id,{ruleId:o.uid,isAdd:!0}),!0):!1}},Ot="sheets-data-validation-ui.config",$e={};var Ra=Object.getOwnPropertyDescriptor,wa=(e,t,n,a)=>{for(var i=a>1?void 0:a?Ra(t,n):t,o=e.length-1,s;o>=0;o--)(s=e[o])&&(i=s(i)||i);return i},Ce=(e,t)=>(n,a)=>t(n,a,e);const pe="SHEET_DATA_VALIDATION_ALERT";let Pe=class extends r.Disposable{constructor(e,t,n,a,i,o){super(),this._hoverManagerService=e,this._cellAlertManagerService=t,this._univerInstanceService=n,this._localeService=a,this._zenZoneService=i,this._dataValidationModel=o,this._init()}_init(){this._initCellAlertPopup(),this._initZenService()}_initCellAlertPopup(){this.disposeWithMe(this._hoverManagerService.currentCell$.pipe(ie.debounceTime(100)).subscribe(e=>{var t;if(e){const n=this._univerInstanceService.getUnit(e.location.unitId,r.UniverInstanceType.UNIVER_SHEET),a=n.getSheetBySheetId(e.location.subUnitId);if(!a)return;const i=this._dataValidationModel.getRuleByLocation(e.location.unitId,e.location.subUnitId,e.location.row,e.location.col);if(!i){this._cellAlertManagerService.removeAlert(pe);return}if(this._dataValidationModel.validator(i,{...e.location,workbook:n,worksheet:a})===r.DataValidationStatus.INVALID){const s=this._cellAlertManagerService.currentAlert.get(pe),d=(t=s==null?void 0:s.alert)==null?void 0:t.location;if(d&&d.row===e.location.row&&d.col===e.location.col&&d.subUnitId===e.location.subUnitId&&d.unitId===e.location.unitId){this._cellAlertManagerService.removeAlert(pe);return}const l=this._dataValidationModel.getValidator(i.type);if(!l){this._cellAlertManagerService.removeAlert(pe);return}this._cellAlertManagerService.showAlert({type:N.CellAlertType.ERROR,title:this._localeService.t("dataValidation.error.title"),message:l==null?void 0:l.getRuleFinalError(i,e.location),location:e.location,width:200,height:74,key:pe});return}}this._cellAlertManagerService.removeAlert(pe)}))}_initZenService(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(e=>{e&&this._cellAlertManagerService.removeAlert(pe)}))}};Pe=wa([Ce(0,r.Inject(N.HoverManagerService)),Ce(1,r.Inject(N.CellAlertManagerService)),Ce(2,r.IUniverInstanceService),Ce(3,r.Inject(r.LocaleService)),Ce(4,y.IZenZoneService),Ce(5,r.Inject(S.SheetDataValidationModel))],Pe);var Ea=Object.getOwnPropertyDescriptor,Ma=(e,t,n,a)=>{for(var i=a>1?void 0:a?Ea(t,n):t,o=e.length-1,s;o>=0;o--)(s=e[o])&&(i=s(i)||i);return i},Je=(e,t)=>(n,a)=>t(n,a,e);let Ee=class extends r.Disposable{constructor(e,t,n){super(),this._autoFillService=e,this._sheetDataValidationModel=t,this._injector=n,this._initAutoFill()}_initAutoFill(){const e=()=>({redos:[],undos:[]}),t=(a,i)=>{const{source:o,target:s,unitId:d,subUnitId:l}=a,c=this._sheetDataValidationModel.getRuleObjectMatrix(d,l).clone(),h=N.virtualizeDiscreteRanges([o,s]),[g,u]=h.ranges,{mapFunc:I}=h,v={row:g.startRow,col:g.startColumn},M=N.getAutoFillRepeatRange(g,u),R=new r.ObjectMatrix,p=new Set;M.forEach(V=>{const D=V.repeatStartCell,T=V.relativeRange,k={startRow:v.row,startColumn:v.col,endColumn:v.col,endRow:v.row},B={startRow:D.row,startColumn:D.col,endColumn:D.col,endRow:D.row};r.Range.foreach(T,(U,F)=>{const x=r.Rectangle.getPositionRange({startRow:U,startColumn:F,endColumn:F,endRow:U},k),{row:X,col:W}=I(x.startRow,x.startColumn),Y=this._sheetDataValidationModel.getRuleIdByLocation(d,l,X,W)||"",K=r.Rectangle.getPositionRange({startRow:U,startColumn:F,endColumn:F,endRow:U},B),{row:Z,col:q}=I(K.startRow,K.startColumn);R.setValue(Z,q,Y),p.add(Y)})});const f=Array.from(p).map(V=>({id:V,ranges:r.queryObjectMatrix(R,D=>D===V)}));c.addRangeRules(f);const _=c.diff(this._sheetDataValidationModel.getRules(d,l)),{redoMutations:O,undoMutations:w}=S.getDataValidationDiffMutations(d,l,_,this._injector,"patched",i===N.APPLY_TYPE.ONLY_FORMAT);return{undos:w,redos:O}},n={id:S.DATA_VALIDATION_PLUGIN_NAME,onBeforeFillData:a=>{const{source:i,unitId:o,subUnitId:s}=a;for(const d of i.rows)for(const l of i.cols){const c=this._sheetDataValidationModel.getRuleByLocation(o,s,d,l);if(c&&c.type===r.DataValidationType.CHECKBOX){this._autoFillService.setDisableApplyType(N.APPLY_TYPE.SERIES,!0);return}}},onFillData:(a,i,o)=>o===N.APPLY_TYPE.COPY||o===N.APPLY_TYPE.ONLY_FORMAT||o===N.APPLY_TYPE.SERIES?t(a,o):e(),onAfterFillData:()=>{}};this.disposeWithMe(this._autoFillService.addHook(n))}};Ee=Ma([Je(0,N.IAutoFillService),Je(1,r.Inject(S.SheetDataValidationModel)),Je(2,r.Inject(r.Injector))],Ee);var Ta=Object.getOwnPropertyDescriptor,ba=(e,t,n,a)=>{for(var i=a>1?void 0:a?Ta(t,n):t,o=e.length-1,s;o>=0;o--)(s=e[o])&&(i=s(i)||i);return i},Qe=(e,t)=>(n,a)=>t(n,a,e);let Me=class extends r.Disposable{constructor(t,n,a){super();A(this,"_copyInfo");this._sheetClipboardService=t,this._sheetDataValidationModel=n,this._injector=a,this._initCopyPaste()}_initCopyPaste(){this._sheetClipboardService.addClipboardHook({id:S.DATA_VALIDATION_PLUGIN_NAME,onBeforeCopy:(t,n,a)=>this._collect(t,n,a),onPasteCells:(t,n,a,i)=>{const{copyType:o=N.COPY_TYPE.COPY,pasteType:s}=i,{range:d}=t||{},{range:l,unitId:c,subUnitId:h}=n;return this._generateMutations(l,{copyType:o,pasteType:s,copyRange:d,unitId:c,subUnitId:h})}})}_collect(t,n,a){const i=new r.ObjectMatrix;this._copyInfo={unitId:t,subUnitId:n,matrix:i};const o=this._injector.invoke(l=>H.rangeToDiscreteRange(a,l,t,n));if(!o)return;const{rows:s,cols:d}=o;s.forEach((l,c)=>{d.forEach((h,g)=>{const u=this._sheetDataValidationModel.getRuleIdByLocation(t,n,l,h);i.setValue(c,g,u!=null?u:"")})})}_generateMutations(t,n){if(!this._copyInfo)return{redos:[],undos:[]};if(n.copyType===N.COPY_TYPE.CUT)return this._copyInfo=null,{redos:[],undos:[]};if(!this._copyInfo||!this._copyInfo.matrix.getSizeOf()||!n.copyRange)return{redos:[],undos:[]};if([N.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_COL_WIDTH,N.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_VALUE,N.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMAT,N.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMULA].includes(n.pasteType))return{redos:[],undos:[]};const{unitId:i,subUnitId:o}=this._copyInfo;if(n.unitId!==i||o!==n.subUnitId){const s=this._sheetDataValidationModel.getRuleObjectMatrix(n.unitId,n.subUnitId).clone(),d=new r.ObjectMatrix,l=new Set,{ranges:[c,h],mapFunc:g}=N.virtualizeDiscreteRanges([n.copyRange,t]),u=N.getRepeatRange(c,h,!0),I=new Map;u.forEach(({startRange:p})=>{var f;(f=this._copyInfo)==null||f.matrix.forValue((_,O,w)=>{const V=r.Rectangle.getPositionRange({startRow:_,endRow:_,startColumn:O,endColumn:O},p),D=`${o}-${w}`,T=this._sheetDataValidationModel.getRuleById(i,o,w);!this._sheetDataValidationModel.getRuleById(n.unitId,n.subUnitId,D)&&T&&I.set(D,{...T,uid:D});const{row:k,col:B}=g(V.startRow,V.startColumn);l.add(D),d.setValue(k,B,D)})});const v=Array.from(l).map(p=>({id:p,ranges:r.queryObjectMatrix(d,f=>f===p)}));s.addRangeRules(v);const{redoMutations:M,undoMutations:R}=S.getDataValidationDiffMutations(n.unitId,n.subUnitId,s.diffWithAddition(this._sheetDataValidationModel.getRules(n.unitId,n.subUnitId),I.values()),this._injector,"patched",!1);return{redos:M,undos:R}}else{const s=this._sheetDataValidationModel.getRuleObjectMatrix(i,o).clone(),d=new r.ObjectMatrix,l=new Set,{ranges:[c,h],mapFunc:g}=N.virtualizeDiscreteRanges([n.copyRange,t]);N.getRepeatRange(c,h,!0).forEach(({startRange:R})=>{var p;(p=this._copyInfo)==null||p.matrix.forValue((f,_,O)=>{const w=r.Rectangle.getPositionRange({startRow:f,endRow:f,startColumn:_,endColumn:_},R),{row:V,col:D}=g(w.startRow,w.startColumn);d.setValue(V,D,O),l.add(O)})});const I=Array.from(l).map(R=>({id:R,ranges:r.queryObjectMatrix(d,p=>p===R)}));s.addRangeRules(I);const{redoMutations:v,undoMutations:M}=S.getDataValidationDiffMutations(i,o,s.diff(this._sheetDataValidationModel.getRules(i,o)),this._injector,"patched",!1);return{redos:v,undos:M}}}};Me=ba([Qe(0,N.ISheetClipboardService),Qe(1,r.Inject(S.SheetDataValidationModel)),Qe(2,r.Inject(r.Injector))],Me);var Oa=Object.getOwnPropertyDescriptor,La=(e,t,n,a)=>{for(var i=a>1?void 0:a?Oa(t,n):t,o=e.length-1,s;o>=0;o--)(s=e[o])&&(i=s(i)||i);return i},et=(e,t)=>(n,a)=>t(n,a,e);let Te=class extends r.Disposable{constructor(e,t,n){super(),this._localeService=e,this._commandService=t,this._sheetPermissionCheckController=n,this._commandExecutedListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.beforeCommandExecuted(e=>{e.id===S.AddSheetDataValidationCommand.id&&(this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[H.WorkbookEditablePermission],rangeTypes:[H.RangeProtectionPermissionEditPoint],worksheetTypes:[H.WorksheetEditPermission,H.WorksheetSetCellStylePermission]})||this._sheetPermissionCheckController.blockExecuteWithoutPermission(this._localeService.t("permission.dialog.setStyleErr"))),e.id===S.UpdateSheetDataValidationRangeCommand.id&&(this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[H.WorkbookEditablePermission],rangeTypes:[H.RangeProtectionPermissionEditPoint],worksheetTypes:[H.WorksheetEditPermission,H.WorksheetSetCellStylePermission]},e.params.ranges)||this._sheetPermissionCheckController.blockExecuteWithoutPermission(this._localeService.t("permission.dialog.setStyleErr")))}))}};Te=La([et(0,r.Inject(r.LocaleService)),et(1,r.ICommandService),et(2,r.Inject(H.SheetPermissionCheckController))],Te);const Lt="data-validation-single",At="sheet.menu.data-validation";function Aa(e){return{id:At,type:y.MenuItemType.SUBITEMS,icon:Lt,tooltip:"dataValidation.title",hidden$:y.getMenuHiddenObservable(e,r.UniverInstanceType.UNIVER_SHEET),disabled$:N.getCurrentRangeDisable$(e,{workbookTypes:[H.WorkbookEditablePermission],worksheetTypes:[H.WorksheetSetCellStylePermission,H.WorksheetEditPermission],rangeTypes:[H.RangeProtectionPermissionEditPoint]})}}function Pa(e){return{id:_e.id,title:"dataValidation.panel.title",type:y.MenuItemType.BUTTON}}function ja(e){return{id:qe.id,title:"dataValidation.panel.add",type:y.MenuItemType.BUTTON}}const Fa={[y.RibbonStartGroup.FORMULAS_INSERT]:{[At]:{order:9,menuItemFactory:Aa,[_e.id]:{order:0,menuItemFactory:Pa},[qe.id]:{order:1,menuItemFactory:ja}}}};var Ua=Object.getOwnPropertyDescriptor,Pt=(e,t,n,a)=>{for(var i=a>1?void 0:a?Ua(t,n):t,o=e.length-1,s;o>=0;o--)(s=e[o])&&(i=s(i)||i);return i},G=(e,t)=>(n,a)=>t(n,a,e);const jt={tr:{size:6,color:"#fe4b4b"}};let be=class extends r.RxDisposable{constructor(e,t,n,a,i,o,s,d,l,c,h){super(),this._commandService=e,this._menuManagerService=t,this._renderManagerService=n,this._univerInstanceService=a,this._autoHeightController=i,this._dropdownManagerService=o,this._sheetDataValidationModel=s,this._dataValidatorRegistryService=d,this._sheetInterceptorService=l,this._dataValidationCacheService=c,this._editorBridgeService=h,this._initMenu(),this._initDropdown(),this._initViewModelIntercept(),this._initAutoHeight()}_initMenu(){this._menuManagerService.mergeMenu(Fa)}_initDropdown(){this._editorBridgeService&&this.disposeWithMe(this._editorBridgeService.visible$.subscribe(e=>{var n;if(!e.visible){((n=this._dropdownManagerService.activeDropdown)==null?void 0:n.trigger)==="editor-bridge"&&this._dropdownManagerService.hideDropdown();return}const t=this._editorBridgeService.getEditCellState();if(t){const{unitId:a,sheetId:i,row:o,column:s}=t,d=this._univerInstanceService.getUniverSheetInstance(a);if(!d)return;const l=this._sheetDataValidationModel.getRuleByLocation(a,i,o,s);if(!l)return;const c=this._dataValidatorRegistryService.getValidatorItem(l.type);if(!(c!=null&&c.dropdownType))return;const h=d.getActiveSheet();if(!h)return;const g=this._dropdownManagerService.activeDropdown,u=g==null?void 0:g.location;if(u&&u.unitId===a&&u.subUnitId===i&&u.row===o&&u.col===s)return;this._dropdownManagerService.showDropdown({location:{unitId:a,subUnitId:i,row:o,col:s,workbook:d,worksheet:h},trigger:"editor-bridge",closeOnOutSide:!1})}}))}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(H.INTERCEPTOR_POINT.CELL_CONTENT,{effect:r.InterceptorEffectEnum.Style,priority:H.InterceptCellContentPriority.DATA_VALIDATION,handler:(e,t,n)=>{var p,f,_,O,w;const{row:a,col:i,unitId:o,subUnitId:s,workbook:d,worksheet:l}=t,c=this._sheetDataValidationModel.getRuleIdByLocation(o,s,a,i);if(!c)return n(e);const h=this._sheetDataValidationModel.getRuleById(o,s,c);if(!h)return n(e);const g=(p=this._dataValidationCacheService.getValue(o,s,a,i))!=null?p:r.DataValidationStatus.VALID,u=this._dataValidatorRegistryService.getValidatorItem(h.type),I=t.rawData;let v;const M={get value(){var V;return v!==void 0||(v=(V=S.getCellValueOrigin(I))!=null?V:null),v}},R={get value(){var V;return`${(V=M.value)!=null?V:""}`}};return n({...e,markers:{...e==null?void 0:e.markers,...g===r.DataValidationStatus.INVALID?jt:null},customRender:[...(f=e==null?void 0:e.customRender)!=null?f:[],...u!=null&&u.canvasRender?[u.canvasRender]:[]],fontRenderExtension:{...e==null?void 0:e.fontRenderExtension,isSkip:((_=e==null?void 0:e.fontRenderExtension)==null?void 0:_.isSkip)||((O=u==null?void 0:u.skipDefaultFontRender)==null?void 0:O.call(u,h,M.value,t))},interceptorStyle:{...e==null?void 0:e.interceptorStyle,...u==null?void 0:u.getExtraStyle(h,R.value,{get style(){const V=d.getStyles();return(typeof(e==null?void 0:e.s)=="string"?V.get(e==null?void 0:e.s):e==null?void 0:e.s)||{}}},a,i)},interceptorAutoHeight:()=>{var k,B,U,F,x,X;const V=(B=(k=this._renderManagerService.getRenderById(o))==null?void 0:k.with(N.SheetSkeletonManagerService).getSkeletonParam(s))==null?void 0:B.skeleton;if(!V)return;const D=V.worksheet.getMergedCell(a,i),T={data:e,style:V.getStyles().getStyleByCell(e),primaryWithCoord:V.getCellWithCoordByIndex((U=D==null?void 0:D.startRow)!=null?U:a,(F=D==null?void 0:D.startColumn)!=null?F:i),unitId:o,subUnitId:s,row:a,col:i,workbook:d,worksheet:l};return(X=(x=u==null?void 0:u.canvasRender)==null?void 0:x.calcCellAutoHeight)==null?void 0:X.call(x,T)},interceptorAutoWidth:()=>{var k,B,U,F,x,X;const V=(B=(k=this._renderManagerService.getRenderById(o))==null?void 0:k.with(N.SheetSkeletonManagerService).getSkeletonParam(s))==null?void 0:B.skeleton;if(!V)return;const D=V.worksheet.getMergedCell(a,i),T={data:e,style:V.getStyles().getStyleByCell(e),primaryWithCoord:V.getCellWithCoordByIndex((U=D==null?void 0:D.startRow)!=null?U:a,(F=D==null?void 0:D.startColumn)!=null?F:i),unitId:o,subUnitId:s,row:a,col:i,workbook:d,worksheet:l};return(X=(x=u==null?void 0:u.canvasRender)==null?void 0:x.calcCellAutoWidth)==null?void 0:X.call(x,T)},coverable:((w=e==null?void 0:e.coverable)!=null?w:!0)&&!(h.type===r.DataValidationType.LIST||h.type===r.DataValidationType.LIST_MULTIPLE)})}}))}_initAutoHeight(){this._sheetDataValidationModel.ruleChange$.pipe(ie.filter(e=>e.source==="command"),ie.bufferTime(100)).subscribe(e=>{if(e.length===0)return;const t=[];if(e.forEach(n=>{var a;(n.rule.type===r.DataValidationType.LIST_MULTIPLE||n.rule.type===r.DataValidationType.LIST)&&(a=n.rule)!=null&&a.ranges&&t.push(...n.rule.ranges)}),t.length){const n=this._autoHeightController.getUndoRedoParamsOfAutoHeight(t);r.sequenceExecute(n.redos,this._commandService)}})}};be=Pt([G(0,r.ICommandService),G(1,y.IMenuManagerService),G(2,P.IRenderManagerService),G(3,r.IUniverInstanceService),G(4,r.Inject(N.AutoHeightController)),G(5,r.Inject(fe)),G(6,r.Inject(S.SheetDataValidationModel)),G(7,r.Inject(z.DataValidatorRegistryService)),G(8,r.Inject(H.SheetInterceptorService)),G(9,r.Inject(S.DataValidationCacheService)),G(10,r.Optional(N.IEditorBridgeService))],be);let _t=class extends r.RxDisposable{constructor(e,t,n,a,i,o,s){super(),this._commandService=e,this._renderManagerService=t,this._autoHeightController=n,this._dataValidatorRegistryService=a,this._sheetInterceptorService=i,this._sheetDataValidationModel=o,this._dataValidationCacheService=s,this._initViewModelIntercept(),this._initAutoHeight()}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(H.INTERCEPTOR_POINT.CELL_CONTENT,{effect:r.InterceptorEffectEnum.Style,priority:H.InterceptCellContentPriority.DATA_VALIDATION,handler:(e,t,n)=>{var R,p,f,_,O;const{row:a,col:i,unitId:o,subUnitId:s,workbook:d,worksheet:l}=t,c=this._sheetDataValidationModel.getRuleIdByLocation(o,s,a,i);if(!c)return n(e);const h=this._sheetDataValidationModel.getRuleById(o,s,c);if(!h)return n(e);const g=(R=this._dataValidationCacheService.getValue(o,s,a,i))!=null?R:r.DataValidationStatus.VALID,u=this._dataValidatorRegistryService.getValidatorItem(h.type),I=l.getCellRaw(a,i),v=S.getCellValueOrigin(I),M=`${v!=null?v:""}`;return n({...e,markers:{...e==null?void 0:e.markers,...g===r.DataValidationStatus.INVALID?jt:null},customRender:[...(p=e==null?void 0:e.customRender)!=null?p:[],...u!=null&&u.canvasRender?[u.canvasRender]:[]],fontRenderExtension:{...e==null?void 0:e.fontRenderExtension,isSkip:((f=e==null?void 0:e.fontRenderExtension)==null?void 0:f.isSkip)||((_=u==null?void 0:u.skipDefaultFontRender)==null?void 0:_.call(u,h,v,t))},interceptorStyle:{...e==null?void 0:e.interceptorStyle,...u==null?void 0:u.getExtraStyle(h,M,{get style(){const w=d.getStyles();return(typeof(e==null?void 0:e.s)=="string"?w.get(e==null?void 0:e.s):e==null?void 0:e.s)||{}}},a,i)},interceptorAutoHeight:()=>{var T,k,B,U,F,x;const w=(k=(T=this._renderManagerService.getRenderById(o))==null?void 0:T.with(N.SheetSkeletonManagerService).getSkeletonParam(s))==null?void 0:k.skeleton;if(!w)return;const V=w.worksheet.getMergedCell(a,i),D={data:e,style:w.getStyles().getStyleByCell(e),primaryWithCoord:w.getCellWithCoordByIndex((B=V==null?void 0:V.startRow)!=null?B:a,(U=V==null?void 0:V.startColumn)!=null?U:i),unitId:o,subUnitId:s,row:a,col:i,workbook:d,worksheet:l};return(x=(F=u==null?void 0:u.canvasRender)==null?void 0:F.calcCellAutoHeight)==null?void 0:x.call(F,D)},coverable:((O=e==null?void 0:e.coverable)!=null?O:!0)&&!(h.type===r.DataValidationType.LIST||h.type===r.DataValidationType.LIST_MULTIPLE)})}}))}_initAutoHeight(){this._sheetDataValidationModel.ruleChange$.pipe(ie.filter(e=>e.source==="command"),ie.bufferTime(16)).subscribe(e=>{const t=[];if(e.forEach(n=>{var a;(a=n.rule)!=null&&a.ranges&&t.push(...n.rule.ranges)}),t.length){const n=this._autoHeightController.getUndoRedoParamsOfAutoHeight(t);r.sequenceExecute(n.redos,this._commandService)}})}};_t=Pt([G(0,r.ICommandService),G(1,P.IRenderManagerService),G(2,r.Inject(N.AutoHeightController)),G(3,r.Inject(z.DataValidatorRegistryService)),G(4,r.Inject(H.SheetInterceptorService)),G(5,r.Inject(S.SheetDataValidationModel)),G(6,r.Inject(S.DataValidationCacheService))],_t);var Na=Object.getOwnPropertyDescriptor,ka=(e,t,n,a)=>{for(var i=a>1?void 0:a?Na(t,n):t,o=e.length-1,s;o>=0;o--)(s=e[o])&&(i=s(i)||i);return i},It=(e,t)=>(n,a)=>t(n,a,e);let Ye=class extends r.Disposable{constructor(e,t,n){super(),this._context=e,this._sheetDataValidationModel=t,this._sheetSkeletonManagerService=n,this._initSkeletonChange()}_initSkeletonChange(){const e=t=>{var a;if(!t.length)return;const n=new Set;t.forEach(i=>{n.add(i.subUnitId)}),n.forEach(i=>{var o;(o=this._sheetSkeletonManagerService.getSkeletonParam(i))==null||o.skeleton.makeDirty(!0)}),(a=this._context.mainComponent)==null||a.makeForceDirty()};this.disposeWithMe(this._sheetDataValidationModel.validStatusChange$.pipe(r.bufferDebounceTime(16)).subscribe(e))}};Ye=ka([It(1,r.Inject(S.SheetDataValidationModel)),It(2,r.Inject(N.SheetSkeletonManagerService))],Ye);const xa="univer-data-validation-options-button",Ba="univer-data-validation-options-button-icon",tt={dataValidationOptionsButton:xa,dataValidationOptionsButtonIcon:Ba};function Ha(e){var c;const t=y.useDependency(r.LocaleService),n=y.useDependency(y.ComponentManager),{value:a,onChange:i,extraComponent:o}=e,[s,d]=E.useState(!1),l=o?n.get(o):null;return m.jsxs(m.Fragment,{children:[m.jsxs("div",{className:tt.dataValidationOptionsButton,onClick:()=>d(!s),children:[t.t("dataValidation.panel.options"),s?m.jsx(Et,{className:tt.dataValidationOptionsButtonIcon}):m.jsx(wt,{className:tt.dataValidationOptionsButtonIcon})]}),s&&m.jsxs(m.Fragment,{children:[l?m.jsx(l,{value:a,onChange:i}):null,m.jsx(b.FormLayout,{label:t.t("dataValidation.panel.invalid"),children:m.jsxs(b.RadioGroup,{value:`${(c=a.errorStyle)!=null?c:r.DataValidationErrorStyle.WARNING}`,onChange:h=>i({...a,errorStyle:+h}),children:[m.jsx(b.Radio,{value:`${r.DataValidationErrorStyle.WARNING}`,children:t.t("dataValidation.panel.showWarning")}),m.jsx(b.Radio,{value:`${r.DataValidationErrorStyle.STOP}`,children:t.t("dataValidation.panel.rejectInput")})]})}),m.jsx(b.FormLayout,{label:t.t("dataValidation.panel.messageInfo"),children:m.jsx(b.Checkbox,{checked:a.showErrorMessage,onChange:()=>i({...a,showErrorMessage:!a.showErrorMessage}),children:t.t("dataValidation.panel.showInfo")})}),a.showErrorMessage?m.jsx(b.FormLayout,{children:m.jsx(b.Input,{value:a.error,onChange:h=>i({...a,error:h})})}):null]})]})}const Wa="univer-data-validation-detail",$a="univer-data-validation-detail-form-item",Ya="univer-data-validation-detail-buttons",Xa="univer-data-validation-detail-button",Ve={dataValidationDetail:Wa,dataValidationDetailFormItem:$a,dataValidationDetailButtons:Ya,dataValidationDetailButton:Xa},za=e=>r.debounce(async(t,n,a,i)=>{const o=await e.executeCommand(t,n,a);i==null||i(o)},1e3);function Ka(e,t,n){var a,i,o,s;return t?((i=(a=e.getUnit(t))==null?void 0:a.getSheetBySheetName(n))==null?void 0:i.getSheetId())||"":((s=(o=e.getCurrentUnitForType(r.UniverInstanceType.UNIVER_SHEET))==null?void 0:o.getSheetBySheetName(n))==null?void 0:s.getSheetId())||""}function Ga(){var Le,j;const[e,t]=E.useState(0),n=y.useDependency(he),a=y.useObservable(n.activeRule$,n.activeRule),{unitId:i,subUnitId:o,rule:s}=a||{},d=s.uid,l=y.useDependency(z.DataValidatorRegistryService),c=y.useDependency(r.IUniverInstanceService),h=y.useDependency(y.ComponentManager),g=y.useDependency(r.ICommandService),u=y.useDependency(z.DataValidationModel),I=y.useDependency(r.LocaleService),[v,M]=E.useState(s),R=l.getValidatorItem(v.type),[p,f]=E.useState(!1),_=l.getValidatorsByScope(z.DataValidatorRegistryScope.SHEET),[O,w]=E.useState(()=>v.ranges.map(C=>({unitId:"",sheetId:"",range:C}))),V=E.useMemo(()=>za(g),[g]),[D,T]=E.useState(!1),[k,B]=E.useState(!1),U=E.useRef(null),F=y.useDependency(H.SheetsSelectionsService);if(E.useEffect(()=>()=>{const C=F.getCurrentLastSelection();C&&F.setSelections([C])},[F]),E.useEffect(()=>{g.onCommandExecuted(C=>{(C.id===r.UndoCommand.id||C.id===r.RedoCommand.id)&&setTimeout(()=>{const L=u.getRuleById(i,o,d);t($=>$+1),L&&(M(L),w(L.ranges.map($=>({unitId:"",sheetId:"",range:$}))))},20)})},[g,u,d,o,i]),!R)return null;const x=R.operators,X=R.operatorNames,W=v.operator?z.TWO_FORMULA_OPERATOR_COUNT.includes(v.operator):!1,Y=()=>{var C,L,$;(L=(C=U.current)==null?void 0:C.editor)!=null&&L.isFocus()&&K(($=U.current)==null?void 0:$.getValue()),!(!v.ranges.length||D)&&(R.validatorFormula(v,i,o).success?n.setActiveRule(null):f(!0))},K=y.useEvent(C=>{const L=C.split(",").filter(Boolean).map(lt.deserializeRangeWithSheet).map(Q=>{const vt=Q.sheetName;if(vt){const kt=Ka(c,Q.unitId,vt);return{...Q,sheetId:kt}}return{...Q,sheetId:""}});if(r.isUnitRangesEqual(L,O))return;w(L);const $=L.filter(Q=>(!Q.unitId||Q.unitId===i)&&(!Q.sheetId||Q.sheetId===o)).map(Q=>Q.range);if(M({...v,ranges:$}),$.length===0)return;const J={unitId:i,subUnitId:o,ruleId:d,ranges:$};V(S.UpdateSheetDataValidationRangeCommand.id,J)}),Z=C=>{if(r.shallowEqual(C,z.getRuleSetting(v)))return;M({...v,...C});const L={unitId:i,subUnitId:o,ruleId:d,setting:C};V(S.UpdateSheetDataValidationSettingCommand.id,L,void 0)},q=async()=>{await g.executeCommand(S.RemoveSheetDataValidationCommand.id,{ruleId:d,unitId:i,subUnitId:o}),n.setActiveRule(null)},te={type:v.type,operator:v.operator,formula1:v.formula1,formula2:v.formula2,allowBlank:v.allowBlank},se=C=>{const L=l.getValidatorItem(C);if(!L)return;const $=L.operators,J=u.getRuleById(i,o,d),Q=C===(J==null?void 0:J.type)||C.includes("list")&&(J!=null&&J.type.includes("list"))?{...J,type:C}:{...v,type:C,operator:$[0],formula1:void 0,formula2:void 0};M(Q),g.executeCommand(S.UpdateSheetDataValidationSettingCommand.id,{unitId:i,subUnitId:o,ruleId:v.uid,setting:z.getRuleSetting(Q)})},oe=h.get(R.formulaInput),ae=E.useMemo(()=>O.map(C=>lt.serializeRange(C.range)).join(","),[]),le=z.getRuleOptions(v),de=C=>{r.shallowEqual(C,z.getRuleOptions(v))||(M({...v,...C}),V(S.UpdateSheetDataValidationOptionsCommand.id,{unitId:i,subUnitId:o,ruleId:d,options:C}))},ge=!v.operator;return m.jsxs("div",{className:Ve.dataValidationDetail,children:[m.jsx(b.FormLayout,{label:I.t("dataValidation.panel.range"),error:!v.ranges.length||D?I.t("dataValidation.panel.rangeError"):"",children:m.jsx(gt.RangeSelector,{selectorRef:U,unitId:i,subUnitId:o,initialValue:ae,onChange:(C,L)=>{var $;!k&&(($=U.current)!=null&&$.verify())&&K(L)},onFocusChange:(C,L)=>{var $;B(C),!C&&L&&(($=U.current)!=null&&$.verify())&&K(L)},onVerify:C=>T(!C)})}),m.jsx(b.FormLayout,{label:I.t("dataValidation.panel.type"),children:m.jsx(b.Select,{options:(Le=_==null?void 0:_.sort((C,L)=>C.order-L.order))==null?void 0:Le.map(C=>({label:I.t(C.title),value:C.id})),value:v.type,onChange:se,className:Ve.dataValidationDetailFormItem})}),x!=null&&x.length?m.jsx(b.FormLayout,{label:I.t("dataValidation.panel.operator"),children:m.jsx(b.Select,{options:[{value:"",label:I.t("dataValidation.operators.legal")},...x.map((C,L)=>({value:`${C}`,label:X[L]}))],value:`${v.operator}`,onChange:C=>{Z({...te,operator:C})},className:Ve.dataValidationDetailFormItem})}):null,oe&&!ge?m.jsx(b.FormLayout,{children:m.jsx(oe,{isTwoFormula:W,value:{formula1:v.formula1,formula2:v.formula2},onChange:C=>{Z({...te,...C})},showError:p,validResult:R.validatorFormula(v,i,o),unitId:i,subUnitId:o,ruleId:d},e+v.type)}):null,m.jsx(b.FormLayout,{children:m.jsx(b.Checkbox,{checked:(j=v.allowBlank)!=null?j:!0,onChange:()=>{var C;return Z({...te,allowBlank:!((C=v.allowBlank)==null||C)})},children:I.t("dataValidation.panel.allowBlank")})}),m.jsx(Ha,{value:le,onChange:de,extraComponent:R.optionsInput}),m.jsxs("div",{className:Ve.dataValidationDetailButtons,children:[m.jsx(b.Button,{className:Ve.dataValidationDetailButton,onClick:q,children:I.t("dataValidation.panel.removeRule")}),m.jsx(b.Button,{className:Ve.dataValidationDetailButton,variant:"primary",onClick:Y,children:I.t("dataValidation.panel.done")})]})]})}const qa="univer-data-validation-item-container",Za="univer-data-validation-item-title",Ja="univer-data-validation-item-content",Qa="univer-data-validation-item-icon",je={dataValidationItemContainer:qa,dataValidationItemTitle:Za,dataValidationItemContent:Ja,dataValidationItemIcon:Qa},en=e=>{const{rule:t,onClick:n,unitId:a,subUnitId:i,disable:o}=e,s=y.useDependency(z.DataValidatorRegistryService),d=y.useDependency(r.ICommandService),l=y.useDependency(N.IMarkSelectionService),c=s.getValidatorItem(t.type),h=E.useRef(void 0),[g,u]=E.useState(!1),I=y.useDependency(r.ThemeService),v=y.useObservable(I.currentTheme$),M=E.useMemo(()=>{var _;const p=(_=v==null?void 0:v.loopColor2)!=null?_:"#49B811",f=new r.ColorKit(p).toRgb();return{fill:`rgba(${f.r}, ${f.g}, ${f.b}, 0.1)`,stroke:p}},[v]),R=p=>{d.executeCommand(S.RemoveSheetDataValidationCommand.id,{ruleId:t.uid,unitId:a,subUnitId:i}),p.stopPropagation()};return E.useEffect(()=>()=>{var p;h.current&&((p=h.current)==null||p.forEach(f=>{f&&l.removeShape(f)}))},[l]),m.jsxs("div",{className:je.dataValidationItemContainer,onClick:n,onMouseEnter:()=>{o||(u(!0),h.current=t.ranges.map(p=>l.addShape({range:p,style:M,primary:null})))},onMouseLeave:()=>{var p;u(!1),(p=h.current)==null||p.forEach(f=>{f&&l.removeShape(f)}),h.current=void 0},children:[m.jsx("div",{className:je.dataValidationItemTitle,children:c==null?void 0:c.generateRuleName(t)}),m.jsx("div",{className:je.dataValidationItemContent,children:t.ranges.map(p=>lt.serializeRange(p)).join(",")}),g?m.jsx("div",{className:je.dataValidationItemIcon,onClick:R,children:m.jsx(pt,{})}):null]})},tn="univer-data-validation-list",an="univer-data-validation-list-buttons",nn="univer-data-validation-list-button",Fe={dataValidationList:tn,dataValidationListButtons:an,dataValidationListButton:nn};function on(e){const t=y.useDependency(S.SheetDataValidationModel),n=y.useDependency(r.IUniverInstanceService),a=y.useDependency(r.ICommandService),i=y.useDependency(r.Injector),o=y.useDependency(he),s=y.useDependency(r.LocaleService),[d,l]=E.useState([]),{workbook:c}=e,h=y.useObservable(c.activeSheet$,void 0,!0),g=c.getUnitId(),u=h==null?void 0:h.getSheetId();E.useEffect(()=>{l(t.getRules(g,u));const f=t.ruleChange$.subscribe(_=>{_.unitId===g&&_.subUnitId===u&&l(t.getRules(g,u))});return()=>{f.unsubscribe()}},[g,u,t]);const I=async()=>{const f=S.createDefaultNewRule(i),_={unitId:g,subUnitId:u,rule:f};await a.executeCommand(S.AddSheetDataValidationCommand.id,_),o.setActiveRule({unitId:g,subUnitId:u,rule:f})},v=()=>{a.executeCommand(S.RemoveSheetAllDataValidationCommand.id,{unitId:g,subUnitId:u})},R=(f=>{const _=n.getCurrentUnitForType(r.UniverInstanceType.UNIVER_SHEET),O=_.getActiveSheet(),w=_.getUnitId(),V=O.getSheetId();return f.map(T=>H.checkRangesEditablePermission(i,w,V,T.ranges)?{...T}:{...T,disable:!0})})(d),p=R==null?void 0:R.some(f=>f.disable);return m.jsxs("div",{className:Fe.dataValidationList,children:[R==null?void 0:R.map(f=>{var _;return m.jsx(en,{unitId:g,subUnitId:u,onClick:()=>{f.disable||o.setActiveRule({unitId:g,subUnitId:u,rule:f})},rule:f,disable:(_=f.disable)!=null?_:!1},f.uid)}),m.jsxs("div",{className:Fe.dataValidationListButtons,children:[d.length&&!p?m.jsx(b.Button,{className:Fe.dataValidationListButton,onClick:v,children:s.t("dataValidation.panel.removeAll")}):null,m.jsx(b.Button,{className:Fe.dataValidationListButton,variant:"primary",onClick:I,children:s.t("dataValidation.panel.add")})]})]})}const rn=()=>{const e=y.useDependency(he),t=y.useObservable(e.activeRule$,e.activeRule),n=y.useDependency(r.IUniverInstanceService),a=y.useObservable(()=>n.getCurrentTypeOfUnit$(r.UniverInstanceType.UNIVER_SHEET),void 0,void 0,[]),i=y.useObservable(()=>{var o;return(o=a==null?void 0:a.activeSheet$)!=null?o:ie.of(null)},void 0,void 0,[]);return!a||!i?null:t&&t.subUnitId===i.getSheetId()?m.jsx(Ga,{},t.rule.uid):m.jsx(on,{workbook:a})},sn="LIST_RENDER_MODE_OPTION_INPUT";function Xe(e){var i;const{value:t,onChange:n}=e,a=y.useDependency(r.LocaleService);return m.jsx(b.FormLayout,{label:a.t("dataValidation.renderMode.label"),children:m.jsxs(b.RadioGroup,{value:`${(i=t.renderMode)!=null?i:r.DataValidationRenderMode.CUSTOM}`,onChange:o=>n({...t,renderMode:+o}),children:[m.jsx(b.Radio,{value:`${r.DataValidationRenderMode.CUSTOM}`,children:a.t("dataValidation.renderMode.chip")}),m.jsx(b.Radio,{value:`${r.DataValidationRenderMode.ARROW}`,children:a.t("dataValidation.renderMode.arrow")}),m.jsx(b.Radio,{value:`${r.DataValidationRenderMode.TEXT}`,children:a.t("dataValidation.renderMode.text")})]})})}Xe.componentKey=sn;const ln="DATE_SHOW_TIME_OPTION";function ze(e){var i;const{value:t,onChange:n}=e,a=y.useDependency(r.LocaleService);return m.jsx(b.FormLayout,{children:m.jsx(b.Checkbox,{checked:(i=t.bizInfo)==null?void 0:i.showTime,onChange:o=>{n({...t,bizInfo:{...t.bizInfo,showTime:o}})},children:a.t("dataValidation.showTime.label")})})}ze.componentKey=ln;var dn=Object.getOwnPropertyDescriptor,cn=(e,t,n,a)=>{for(var i=a>1?void 0:a?dn(t,n):t,o=e.length-1,s;o>=0;o--)(s=e[o])&&(i=s(i)||i);return i},De=(e,t)=>(n,a)=>t(n,a,e);const Ue=6;let dt=class{constructor(e,t,n,a,i,o){this._commandService=e,this._univerInstanceService=t,this._formulaService=n,this._themeService=a,this._renderManagerService=i,this._dataValidationModel=o}_calc(e,t){var c,h,g;const{vt:n,ht:a}=t||{},i=e.endX-e.startX-Ue*2,o=e.endY-e.startY,s=((c=t==null?void 0:t.fs)!=null?c:10)*1.6;let d=0,l=0;switch(n){case r.VerticalAlign.TOP:l=0;break;case r.VerticalAlign.BOTTOM:l=0+(o-s);break;default:l=0+(o-s)/2;break}switch(a){case r.HorizontalAlign.LEFT:d=Ue;break;case r.HorizontalAlign.RIGHT:d=Ue+(i-s);break;default:d=Ue+(i-s)/2;break}return{left:e.startX+d,top:e.startY+l,width:((h=t==null?void 0:t.fs)!=null?h:10)*1.6,height:((g=t==null?void 0:t.fs)!=null?g:10)*1.6}}calcCellAutoHeight(e){var n;const{style:t}=e;return((n=t==null?void 0:t.fs)!=null?n:10)*1.6}calcCellAutoWidth(e){var n;const{style:t}=e;return((n=t==null?void 0:t.fs)!=null?n:10)*1.6}async _parseFormula(e,t,n){var c,h,g,u,I,v,M,R,p;const{formula1:a=S.CHECKBOX_FORMULA_1,formula2:i=S.CHECKBOX_FORMULA_2}=e,o=await this._formulaService.getRuleFormulaResult(t,n,e.uid),s=S.getFormulaResult((g=(h=(c=o==null?void 0:o[0])==null?void 0:c.result)==null?void 0:h[0])==null?void 0:g[0]),d=S.getFormulaResult((v=(I=(u=o==null?void 0:o[1])==null?void 0:u.result)==null?void 0:I[0])==null?void 0:v[0]),l=S.isLegalFormulaResult(String(s))&&S.isLegalFormulaResult(String(d));return{formula1:r.isFormulaString(a)?S.getFormulaResult((p=(R=(M=o==null?void 0:o[0])==null?void 0:M.result)==null?void 0:R[0])==null?void 0:p[0]):a,formula2:r.isFormulaString(i)?d:i,isFormulaValid:l}}drawWith(e,t){var F,x,X,W;const{style:n,primaryWithCoord:a,unitId:i,subUnitId:o,worksheet:s,row:d,col:l}=t,c=a.isMergedMainCell?a.mergeInfo:a,h=S.getCellValueOrigin(s.getCellRaw(d,l)),g=this._dataValidationModel.getRuleByLocation(i,o,d,l);if(!g)return;const u=this._dataValidationModel.getValidator(g.type);if(!u)return;const I=this._themeService.getCurrentTheme();if(!((F=u.skipDefaultFontRender)!=null&&F.call(u,g,h,{unitId:i,subUnitId:o,row:d,column:l})))return;const v=u.parseFormulaSync(g,i,o),{formula1:M}=v,R=this._calc(c,n),{a:p,d:f}=e.getTransform(),_=P.fixLineWidthByScale(R.left,p),O=P.fixLineWidthByScale(R.top,f),w=P.Transform.create().composeMatrix({left:_,top:O,scaleX:1,scaleY:1,angle:0,skewX:0,skewY:0,flipX:!1,flipY:!1}),V=c.endX-c.startX,D=c.endY-c.startY;e.save(),e.beginPath(),e.rect(c.startX,c.startY,V,D),e.clip();const T=w.getMatrix();e.transform(T[0],T[1],T[2],T[3],T[4],T[5]);const k=((x=n==null?void 0:n.fs)!=null?x:10)*1.6,B=String(h)===String(M),U=I.hyacinth500;P.CheckboxShape.drawWith(e,{checked:B,width:k,height:k,fill:(W=(X=n==null?void 0:n.cl)==null?void 0:X.rgb)!=null?W:U}),e.restore()}isHit(e,t){const n=t.primaryWithCoord.isMergedMainCell?t.primaryWithCoord.mergeInfo:t.primaryWithCoord,a=this._calc(n,t.style),i=a.top,o=a.top+a.height,s=a.left,d=a.left+a.width,{x:l,y:c}=e;return l<=d&&l>=s&&c<=o&&c>=i}async onPointerDown(e,t){var v;if(t.button===2)return;const{primaryWithCoord:n,unitId:a,subUnitId:i,worksheet:o,row:s,col:d}=e,l=S.getCellValueOrigin(o.getCellRaw(s,d)),c=this._dataValidationModel.getRuleByLocation(a,i,s,d);if(!c)return;const h=this._dataValidationModel.getValidator(c.type);if(!h||!((v=h.skipDefaultFontRender)!=null&&v.call(h,c,l,{unitId:a,subUnitId:i,row:s,column:d})))return;const{formula1:g,formula2:u}=await this._parseFormula(c,a,i),I={range:{startColumn:n.actualColumn,endColumn:n.actualColumn,startRow:n.actualRow,endRow:n.actualRow},value:{v:String(l)===S.transformCheckboxValue(String(g))?u:g,p:null}};this._commandService.executeCommand(H.SetRangeValuesCommand.id,I)}onPointerEnter(e,t){var n,a;(a=(n=P.getCurrentTypeOfRenderer(r.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null?void 0:n.mainComponent)==null||a.setCursor(P.CURSOR_TYPE.POINTER)}onPointerLeave(e,t){var n,a;(a=(n=P.getCurrentTypeOfRenderer(r.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null?void 0:n.mainComponent)==null||a.setCursor(P.CURSOR_TYPE.DEFAULT)}};dt=cn([De(0,r.ICommandService),De(1,r.IUniverInstanceService),De(2,r.Inject(S.DataValidationFormulaService)),De(3,r.Inject(r.ThemeService)),De(4,r.Inject(P.IRenderManagerService)),De(5,r.Inject(S.SheetDataValidationModel))],dt);class un extends exports.BaseSheetDataValidatorView{constructor(){super(...arguments);A(this,"id",r.DataValidationType.CHECKBOX);A(this,"canvasRender",this.injector.createInstance(dt));A(this,"formulaInput",S.CHECKBOX_FORMULA_INPUT_NAME)}}class hn extends exports.BaseSheetDataValidatorView{constructor(){super(...arguments);A(this,"id",r.DataValidationType.CUSTOM);A(this,"formulaInput",S.CUSTOM_FORMULA_INPUT_NAME)}}const gn="data-validation.formula-input";class pn extends exports.BaseSheetDataValidatorView{constructor(){super(...arguments);A(this,"id",r.DataValidationType.DATE);A(this,"formulaInput",gn);A(this,"optionsInput",ze.componentKey);A(this,"dropdownType",z.DataValidatorDropdownType.DATE)}}class mn extends exports.BaseSheetDataValidatorView{constructor(){super(...arguments);A(this,"id",r.DataValidationType.DECIMAL);A(this,"formulaInput",S.BASE_FORMULA_INPUT_NAME)}}const Ft=4,vn=0,at=4,Ut=4,ct=6,Ke=6,ve=14;function fn(e,t){const n=P.FontCache.getTextSize(e,t),a=n.width+Ft*2,{ba:i,bd:o}=n,s=i+o;return{width:a,height:s+vn*2,ba:i}}function nt(e,t,n,a){const i=ve+ct*2,o=n-i,s=a-Ke*2,d=e.map(u=>({layout:fn(u,t),text:u}));let l;const c=[];d.forEach(u=>{const{layout:I}=u,{width:v,height:M}=I;!l||l.width+v+at>o?(l={width:v,height:M,items:[{...u,left:0}]},c.push(l)):(l.items.push({...u,left:l.width+at}),l.width=l.width+v+at)});let h=0,g=0;return c.forEach((u,I)=>{g=Math.max(g,u.width),I===c.length-1?h+=u.height:h+=u.height+Ut}),{lines:c,totalHeight:h,contentWidth:o,contentHeight:s,cellAutoHeight:h+Ke*2,calcAutoWidth:g+i}}const Sn=8;class _n extends P.Shape{static drawWith(t,n){const{fontString:a,info:i,fill:o,color:s}=n,{layout:d,text:l}=i;t.save(),P.Rect.drawWith(t,{width:d.width,height:d.height,radius:Sn,fill:o||ye}),t.translateWithPrecision(Ft,d.ba),t.font=a,t.fillStyle=s,t.fillText(l,0,0),t.restore()}}var In=Object.getOwnPropertyDescriptor,Cn=(e,t,n,a)=>{for(var i=a>1?void 0:a?In(t,n):t,o=e.length-1,s;o>=0;o--)(s=e[o])&&(i=s(i)||i);return i},Ne=(e,t)=>(n,a)=>t(n,a,e);const Vn=new Path2D("M3.32201 4.84556C3.14417 5.05148 2.85583 5.05148 2.67799 4.84556L0.134292 1.90016C-0.152586 1.56798 0.0505937 1 0.456301 1L5.5437 1C5.94941 1 6.15259 1.56798 5.86571 1.90016L3.32201 4.84556Z");let ut=class{constructor(e,t,n,a){A(this,"zIndex");A(this,"_dropdownInfoMap",new Map);this._commandService=e,this._univerInstanceService=t,this._renderManagerService=n,this._dataValidationModel=a}_ensureMap(e){let t=this._dropdownInfoMap.get(e);return t||(t=new Map,this._dropdownInfoMap.set(e,t)),t}_generateKey(e,t){return`${e}.${t}`}_drawDownIcon(e,t,n,a,i){const o=n-ve+4;let s=4;switch(i){case r.VerticalAlign.MIDDLE:s=(a-ve)/2+4;break;case r.VerticalAlign.BOTTOM:s=a-ve+4;break}e.save(),e.translateWithPrecision(t.startX+o,t.startY+s),e.fillStyle="#565656",e.fill(Vn),e.restore()}drawWith(e,t,n,a){var Z,q;const{primaryWithCoord:i,row:o,col:s,style:d,data:l,subUnitId:c}=t,h=i.isMergedMainCell?i.mergeInfo:i,g=l==null?void 0:l.fontRenderExtension,{leftOffset:u=0,rightOffset:I=0,topOffset:v=0,downOffset:M=0}=g||{},R=this._ensureMap(c),p=this._generateKey(o,s),f=this._dataValidationModel.getRuleByLocation(t.unitId,t.subUnitId,o,s);if(!f)return;const _=this._dataValidationModel.getValidator(f.type);if(!_)return;const O={startX:h.startX+u,endX:h.endX-I,startY:h.startY+v,endY:h.endY-M},w=O.endX-O.startX,V=O.endY-O.startY,{cl:D}=d||{},T=(Z=typeof D=="object"?D==null?void 0:D.rgb:D)!=null?Z:"#000",k=P.getFontStyleString(d!=null?d:void 0),{vt:B,ht:U}=d||{},F=B!=null?B:r.VerticalAlign.MIDDLE,x=(q=S.getCellValueOrigin(l))!=null?q:"",X=_.parseCellValue(x),W=_.getListWithColorMap(f),Y=nt(X,k,w,V);this._drawDownIcon(e,O,w,V,F),e.save(),e.translateWithPrecision(O.startX,O.startY),e.beginPath(),e.rect(0,0,w-ve,V),e.clip(),e.translateWithPrecision(ct,Ke);let K=0;switch(F){case r.VerticalAlign.MIDDLE:K=(Y.contentHeight-Y.totalHeight)/2;break;case r.VerticalAlign.BOTTOM:K=Y.contentHeight-Y.totalHeight;break}e.translateWithPrecision(0,K),Y.lines.forEach((te,se)=>{e.save();const{width:oe,height:ae,items:le}=te;let de=0;switch(U){case r.HorizontalAlign.RIGHT:de=Y.contentWidth-oe;break;case r.HorizontalAlign.CENTER:de=(Y.contentWidth-oe)/2;break}e.translate(de,se*(ae+Ut)),le.forEach(ge=>{e.save(),e.translateWithPrecision(ge.left,0),_n.drawWith(e,{...k,info:ge,color:T,fill:W[ge.text]}),e.restore()}),e.restore()}),e.restore(),R.set(p,{left:O.startX,top:O.startY,width:Y.contentWidth+ct+ve,height:Y.contentHeight+Ke*2})}calcCellAutoHeight(e){var w;const{primaryWithCoord:t,style:n,data:a,row:i,col:o}=e,s=a==null?void 0:a.fontRenderExtension,{leftOffset:d=0,rightOffset:l=0,topOffset:c=0,downOffset:h=0}=s||{},g=t.isMergedMainCell?t.mergeInfo:t,u={startX:g.startX+d,endX:g.endX-l,startY:g.startY+c,endY:g.endY-h},I=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,i,o);if(!I)return;const v=this._dataValidationModel.getValidator(I.type);if(!v)return;const M=u.endX-u.startX,R=u.endY-u.startY,p=(w=S.getCellValueOrigin(a))!=null?w:"",f=v.parseCellValue(p),_=P.getFontStyleString(n!=null?n:void 0);return nt(f,_,M,R).cellAutoHeight}calcCellAutoWidth(e){var w;const{primaryWithCoord:t,style:n,data:a,row:i,col:o}=e,s=a==null?void 0:a.fontRenderExtension,{leftOffset:d=0,rightOffset:l=0,topOffset:c=0,downOffset:h=0}=s||{},g=t.isMergedMainCell?t.mergeInfo:t,u={startX:g.startX+d,endX:g.endX-l,startY:g.startY+c,endY:g.endY-h},I=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,i,o);if(!I)return;const v=this._dataValidationModel.getValidator(I.type);if(!v)return;const M=u.endX-u.startX,R=u.endY-u.startY,p=(w=S.getCellValueOrigin(a))!=null?w:"",f=v.parseCellValue(p),_=P.getFontStyleString(n!=null?n:void 0);return nt(f,_,M,R).calcAutoWidth}isHit(e,t){const{primaryWithCoord:n}=t,a=n.isMergedMainCell?n.mergeInfo:n,{endX:i}=a,{x:o}=e;return o>=i-ve&&o<=i}onPointerDown(e,t){if(t.button===2)return;const{unitId:n,subUnitId:a,row:i,col:o}=e,s={unitId:n,subUnitId:a,row:i,column:o};this._commandService.executeCommand(Ge.id,s)}onPointerEnter(e,t){var n,a;return(a=(n=P.getCurrentTypeOfRenderer(r.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null?void 0:n.mainComponent)==null?void 0:a.setCursor(P.CURSOR_TYPE.POINTER)}onPointerLeave(e,t){var n,a;return(a=(n=P.getCurrentTypeOfRenderer(r.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null?void 0:n.mainComponent)==null?void 0:a.setCursor(P.CURSOR_TYPE.DEFAULT)}};ut=Cn([Ne(0,r.ICommandService),Ne(1,r.IUniverInstanceService),Ne(2,r.Inject(P.IRenderManagerService)),Ne(3,r.Inject(S.SheetDataValidationModel))],ut);class Dn extends exports.BaseSheetDataValidatorView{constructor(){super(...arguments);A(this,"id",r.DataValidationType.LIST_MULTIPLE);A(this,"canvasRender",this.injector.createInstance(ut));A(this,"dropdownType",z.DataValidatorDropdownType.MULTIPLE_LIST)}}var yn=Object.getOwnPropertyDescriptor,Rn=(e,t,n,a)=>{for(var i=a>1?void 0:a?yn(t,n):t,o=e.length-1,s;o>=0;o--)(s=e[o])&&(i=s(i)||i);return i},Ae=(e,t)=>(n,a)=>t(n,a,e);const me=4,ke=4,re=14,ue=6,Re=4,it=8,wn="#565656",Ct=new Path2D("M3.32201 4.84556C3.14417 5.05148 2.85583 5.05148 2.67799 4.84556L0.134292 1.90016C-0.152586 1.56798 0.0505937 1 0.456301 1L5.5437 1C5.94941 1 6.15259 1.56798 5.86571 1.90016L3.32201 4.84556Z");function En(e,t){const n=e.length;return{id:"d",body:{dataStream:`${e}${r.DEFAULT_EMPTY_DOCUMENT_VALUE}`,textRuns:[{ts:{fs:11,ff:void 0,it:r.BooleanNumber.FALSE,bl:r.BooleanNumber.FALSE,ul:{s:r.BooleanNumber.FALSE},st:{s:r.BooleanNumber.FALSE},ol:{s:r.BooleanNumber.FALSE},cl:void 0,...t,bg:void 0,bd:void 0},st:0,ed:n}]},documentStyle:{pageSize:{width:Number.POSITIVE_INFINITY,height:Number.POSITIVE_INFINITY}}}}function Nt(e,t,n){const a=En(e,n),i=new r.DocumentDataModel(a),o=new P.DocumentViewModel(i);return{documentSkeleton:P.DocumentSkeleton.create(o,t),docModel:i,docViewModel:o}}function xe(e,t,n){const{documentSkeleton:a,docModel:i,docViewModel:o}=Nt(e,t,n);return{documents:new P.Documents(`DOCUMENTS_${r.Tools.generateRandomId()}`,a,{pageMarginLeft:0,pageMarginTop:0}),documentSkeleton:a,docModel:i,docViewModel:o}}function Vt(e,t,n,a,i,o,s=!0){let d=0;const l=s?Re:0;switch(i){case r.VerticalAlign.BOTTOM:d=t-a-l;break;case r.VerticalAlign.MIDDLE:d=(t-a)/2;break;default:d=l;break}d=Math.max(Re,d);let c=0;switch(o){case r.HorizontalAlign.CENTER:c=(e-n)/2;break;case r.HorizontalAlign.RIGHT:c=e-n;break}return c=Math.max(ue,c),{paddingLeft:c,paddingTop:d}}let ht=class{constructor(e,t,n,a,i){A(this,"_dropdownInfoMap",new Map);A(this,"zIndex");this._univerInstanceService=e,this._localeService=t,this._commandService=n,this._renderManagerService=a,this._dataValidationModel=i}_ensureMap(e){let t=this._dropdownInfoMap.get(e);return t||(t=new Map,this._dropdownInfoMap.set(e,t)),t}_generateKey(e,t){return`${e}.${t}`}_drawDownIcon(e,t,n,a,i,o,s){const{t:d=r.DEFAULT_STYLES.pd.t,b:l=r.DEFAULT_STYLES.pd.b}=s,c=n-re;let h;switch(o){case r.VerticalAlign.MIDDLE:h=(a-ke)/2;break;case r.VerticalAlign.BOTTOM:h=a-l-i-Re+(i/2-ke/2);break;default:h=d+Re+(i/2-ke/2);break}e.save(),e.translateWithPrecision(t.startX+c,t.startY+h),e.fillStyle="#565656",e.fill(Ct),e.restore()}drawWith(e,t,n){const{primaryWithCoord:a,row:i,col:o,style:s,data:d,subUnitId:l}=t,c=a.isMergedMainCell?a.mergeInfo:a,h=this._dataValidationModel.getRuleByLocation(t.unitId,t.subUnitId,i,o);if(!h)return;const g=this._dataValidationModel.getValidator(h.type);if(!g)return;const u=d==null?void 0:d.fontRenderExtension,{leftOffset:I=0,rightOffset:v=0,topOffset:M=0,downOffset:R=0}=u||{};if(!h||!g||!g||g.id.indexOf(r.DataValidationType.LIST)!==0||!g.skipDefaultFontRender(h))return;const p={startX:c.startX+I,endX:c.endX-v,startY:c.startY+M,endY:c.endY-R},f=p.endX-p.startX,_=p.endY-p.startY,O=this._ensureMap(l),w=this._generateKey(i,o),V=g.getListWithColor(h),D=S.getCellValueOrigin(d),T=`${D!=null?D:""}`,k=V.find(X=>X.label===T);let{tb:B,vt:U,ht:F,pd:x}=s||{};if(B=B!=null?B:r.WrapStrategy.WRAP,U=U!=null?U:r.VerticalAlign.BOTTOM,F=F!=null?F:r.DEFAULT_STYLES.ht,x=x!=null?x:r.DEFAULT_STYLES.pd,h.renderMode===r.DataValidationRenderMode.ARROW){const{l:X=r.DEFAULT_STYLES.pd.l,t:W=r.DEFAULT_STYLES.pd.t,r:Y=r.DEFAULT_STYLES.pd.r,b:K=r.DEFAULT_STYLES.pd.b}=x,Z=f-X-Y-re-4,{documentSkeleton:q,documents:te,docModel:se}=xe(T,this._localeService,s);B===r.WrapStrategy.WRAP&&se.updateDocumentDataPageSize(Math.max(Z,1)),q.calculate(),q.getActualSize();const oe=P.getDocsSkeletonPageSize(q),{height:ae,width:le}=oe,{paddingTop:de,paddingLeft:ge}=Vt(Z,_-W-K,le,ae,U,F,!0);this._drawDownIcon(e,p,f,_,ae,U,x),e.save(),e.translateWithPrecision(p.startX+X,p.startY+W),e.beginPath(),e.rect(0,0,f-X-Y,_-W-K),e.clip(),e.translateWithPrecision(0,de),e.save(),e.translateWithPrecision(me,0),e.beginPath(),e.rect(0,0,Z,ae),e.clip(),te.render(e),e.translateWithPrecision(ge,0),e.restore(),e.restore(),O.set(w,{left:p.endX+X+n.rowHeaderWidth-re,top:p.startY+W+n.columnHeaderHeight,width:re,height:_-W-K})}else{e.save(),e.translateWithPrecision(p.startX,p.startY),e.beginPath(),e.rect(0,0,f,_),e.clip();const X=f-ue*2-me-re-4,{documentSkeleton:W,documents:Y,docModel:K}=xe(T,this._localeService,s);B===r.WrapStrategy.WRAP&&K.updateDocumentDataPageSize(Math.max(X,1)),W.calculate();const Z=P.getDocsSkeletonPageSize(W),{height:q,width:te}=Z,{paddingTop:se,paddingLeft:oe}=Vt(X,_,te,q,U,F);e.translateWithPrecision(ue,se);const ae=Math.max(f-ue*2,1),le=q;P.Rect.drawWith(e,{width:ae,height:le,fill:(k==null?void 0:k.color)||ye,radius:it}),e.save(),e.translateWithPrecision(me,0),e.beginPath(),e.rect(0,0,X,q),e.clip(),e.translateWithPrecision(oe,0),Y.render(e),e.restore(),e.translateWithPrecision(X+me+4,(q-ke)/2),e.fillStyle=wn,e.fill(Ct),e.restore(),O.set(w,{left:p.startX+ue+n.rowHeaderWidth,top:p.startY+se+n.columnHeaderHeight,width:ae,height:le})}}calcCellAutoHeight(e){const{primaryWithCoord:t,style:n,data:a,row:i,col:o}=e,s=t.isMergedMainCell?t.mergeInfo:t,d=a==null?void 0:a.fontRenderExtension,{leftOffset:l=0,rightOffset:c=0,topOffset:h=0,downOffset:g=0}=d||{},u=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,i,o);if(!u||u.renderMode===r.DataValidationRenderMode.TEXT)return;const I={startX:s.startX+l,endX:s.endX-c,startY:s.startY+h,endY:s.endY-g},v=I.endX-I.startX,M=S.getCellValueOrigin(a),R=`${M!=null?M:""}`;let{tb:p,pd:f}=n||{};const{t:_=r.DEFAULT_STYLES.pd.t,b:O=r.DEFAULT_STYLES.pd.b}=f!=null?f:{};if(p=p!=null?p:r.WrapStrategy.WRAP,u.renderMode===r.DataValidationRenderMode.ARROW){const w=v-re,{documentSkeleton:V,docModel:D}=xe(R,this._localeService,n);p===r.WrapStrategy.WRAP&&D.updateDocumentDataPageSize(Math.max(w,1)),V.calculate(),V.getActualSize();const T=P.getDocsSkeletonPageSize(V),{height:k}=T;return k+_+O+Re*2}else{const w=v-ue*2-me-re,{documentSkeleton:V,docModel:D}=Nt(R,this._localeService,n);p===r.WrapStrategy.WRAP&&D.updateDocumentDataPageSize(Math.max(w,1)),V.calculate();const T=P.getDocsSkeletonPageSize(V),{height:k}=T;return k+Re*2}}calcCellAutoWidth(e){const{primaryWithCoord:t,style:n,data:a,row:i,col:o}=e,s=t.isMergedMainCell?t.mergeInfo:t,d=a==null?void 0:a.fontRenderExtension,{leftOffset:l=0,rightOffset:c=0,topOffset:h=0,downOffset:g=0}=d||{},u=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,i,o);if(!u||u.renderMode===r.DataValidationRenderMode.TEXT)return;const I={startX:s.startX+l,endX:s.endX-c,startY:s.startY+h,endY:s.endY-g},v=I.endX-I.startX,M=S.getCellValueOrigin(a),R=`${M!=null?M:""}`;let{tb:p,pd:f}=n||{};const{l:_=r.DEFAULT_STYLES.pd.l,r:O=r.DEFAULT_STYLES.pd.r}=f!=null?f:{};p=p!=null?p:r.WrapStrategy.WRAP;let w=ue*2+re;switch(u.renderMode){case r.DataValidationRenderMode.ARROW:w=re+ue*2+O+_;break;case r.DataValidationRenderMode.CUSTOM:w=re+ue*2+me*2+O+_+it/2+1;break;default:w=re+ue*2+me*2+O+_+it/2+1}const V=v-w,{documentSkeleton:D,docModel:T}=xe(R,this._localeService,n);return p===r.WrapStrategy.WRAP&&T.updateDocumentDataPageSize(Math.max(V,1)),D.calculate(),D.getActualSize(),P.getDocsSkeletonPageSize(D).width+w}isHit(e,t){const{subUnitId:n,row:a,col:i}=t,s=this._ensureMap(n).get(this._generateKey(a,i)),d=this._dataValidationModel.getRuleByLocation(t.unitId,t.subUnitId,a,i);if(!d||!s||d.renderMode===r.DataValidationRenderMode.TEXT)return!1;const{top:l,left:c,width:h,height:g}=s,{x:u,y:I}=e;return u>=c&&u<=c+h&&I>=l&&I<=l+g}onPointerDown(e,t){if(t.button===2)return;const{unitId:n,subUnitId:a,row:i,col:o}=e,s={unitId:n,subUnitId:a,row:i,column:o};this._commandService.executeCommand(Ge.id,s)}onPointerEnter(e,t){var n,a;(a=(n=P.getCurrentTypeOfRenderer(r.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null?void 0:n.mainComponent)==null||a.setCursor(P.CURSOR_TYPE.POINTER)}onPointerLeave(e,t){var n,a;(a=(n=P.getCurrentTypeOfRenderer(r.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null?void 0:n.mainComponent)==null||a.setCursor(P.CURSOR_TYPE.DEFAULT)}};ht=Rn([Ae(0,r.IUniverInstanceService),Ae(1,r.Inject(r.LocaleService)),Ae(2,r.ICommandService),Ae(3,r.Inject(P.IRenderManagerService)),Ae(4,r.Inject(S.SheetDataValidationModel))],ht);class Mn extends exports.BaseSheetDataValidatorView{constructor(){super(...arguments);A(this,"id",r.DataValidationType.LIST);A(this,"canvasRender",this.injector.createInstance(ht));A(this,"dropdownType",z.DataValidatorDropdownType.LIST);A(this,"optionsInput",Xe.componentKey);A(this,"formulaInput",S.LIST_FORMULA_INPUT_NAME)}}class Tn extends exports.BaseSheetDataValidatorView{constructor(){super(...arguments);A(this,"id",r.DataValidationType.TEXT_LENGTH);A(this,"formulaInput",S.BASE_FORMULA_INPUT_NAME)}}class bn extends exports.BaseSheetDataValidatorView{constructor(){super(...arguments);A(this,"id",r.DataValidationType.WHOLE);A(this,"formulaInput",S.BASE_FORMULA_INPUT_NAME)}}var On=Object.getOwnPropertyDescriptor,Ln=(e,t,n,a)=>{for(var i=a>1?void 0:a?On(t,n):t,o=e.length-1,s;o>=0;o--)(s=e[o])&&(i=s(i)||i);return i},ot=(e,t)=>(n,a)=>t(n,a,e);let Oe=class extends r.RxDisposable{constructor(e,t,n){super(),this._injector=e,this._componentManger=t,this._dataValidatorRegistryService=n,this._initComponents(),this._registerValidatorViews()}_initComponents(){[[Lt,yt],[We,rn],[Xe.componentKey,Xe],[ze.componentKey,ze],...pa].forEach(([e,t])=>{this.disposeWithMe(this._componentManger.register(e,t))})}_registerValidatorViews(){[mn,bn,Tn,pn,un,Mn,Dn,hn].forEach(e=>{const t=this._injector.createInstance(e),n=this._dataValidatorRegistryService.getValidatorItem(t.id);n&&(n.formulaInput=t.formulaInput,n.canvasRender=t.canvasRender,n.dropdownType=t.dropdownType,n.optionsInput=t.optionsInput)})}};Oe=Ln([ot(0,r.Inject(r.Injector)),ot(1,r.Inject(y.ComponentManager)),ot(2,r.Inject(z.DataValidatorRegistryService))],Oe);var An=Object.getOwnPropertyDescriptor,Pn=(e,t,n,a)=>{for(var i=a>1?void 0:a?An(t,n):t,o=e.length-1,s;o>=0;o--)(s=e[o])&&(i=s(i)||i);return i},rt=(e,t)=>(n,a)=>t(n,a,e);const jn="SHEET_DATA_VALIDATION_UI_PLUGIN";var Be;exports.UniverSheetsDataValidationUIPlugin=(Be=class extends r.Plugin{constructor(t=$e,n,a,i){super(),this._config=t,this._injector=n,this._commandService=a,this._configService=i;const{menu:o,...s}=r.merge({},$e,this._config);o&&this._configService.setConfig("menu",o,{merge:!0}),this._configService.setConfig(Ot,s)}onStarting(){[[he],[fe],[Pe],[Ee],[be],[Te],[Me],[we],[Oe]].forEach(t=>{this._injector.add(t)}),[qe,Ge,bt,mt,_e,Tt].forEach(t=>{this._commandService.registerCommand(t)})}onReady(){this._injector.get(Me),this._injector.get(Te),this._injector.get(we),this._injector.get(Pe),this._injector.get(P.IRenderManagerService).registerRenderModule(r.UniverInstanceType.UNIVER_SHEET,[Ye])}onRendered(){this._injector.get(Oe),this._injector.get(be)}onSteady(){this._injector.get(Ee)}},A(Be,"pluginName",jn),A(Be,"type",r.UniverInstanceType.UNIVER_SHEET),Be);exports.UniverSheetsDataValidationUIPlugin=Pn([rt(1,r.Inject(r.Injector)),rt(2,r.ICommandService),rt(3,r.IConfigService)],exports.UniverSheetsDataValidationUIPlugin);var Fn=Object.getOwnPropertyDescriptor,Un=(e,t,n,a)=>{for(var i=a>1?void 0:a?Fn(t,n):t,o=e.length-1,s;o>=0;o--)(s=e[o])&&(i=s(i)||i);return i},st=(e,t)=>(n,a)=>t(n,a,e);const Nn="SHEET_DATA_VALIDATION_UI_PLUGIN";var He;exports.UniverSheetsDataValidationMobileUIPlugin=(He=class extends r.Plugin{constructor(t=$e,n,a,i){super(),this._config=t,this._injector=n,this._commandService=a,this._configService=i;const{menu:o,...s}=r.merge({},$e,this._config);o&&this._configService.setConfig("menu",o,{merge:!0}),this._configService.setConfig(Ot,s)}onStarting(){[[he],[fe],[Pe],[Ee],[be],[Te],[Me],[Oe]].forEach(t=>{this._injector.add(t)}),[qe,Ge,bt,mt,_e,Tt].forEach(t=>{this._commandService.registerCommand(t)})}onReady(){this._injector.get(Me),this._injector.get(Te),this._injector.get(P.IRenderManagerService).registerRenderModule(r.UniverInstanceType.UNIVER_SHEET,[Ye])}onRendered(){this._injector.get(Oe),this._injector.get(be)}onSteady(){this._injector.get(Ee)}},A(He,"pluginName",Nn),A(He,"type",r.UniverInstanceType.UNIVER_SHEET),He);exports.UniverSheetsDataValidationMobileUIPlugin=Un([st(1,r.Inject(r.Injector)),st(2,r.ICommandService),st(3,r.IConfigService)],exports.UniverSheetsDataValidationMobileUIPlugin);
1
+ "use strict";var xt=Object.defineProperty;var Bt=(e,t,n)=>t in e?xt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var L=(e,t,n)=>Bt(e,typeof t!="symbol"?t+"":t,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("@univerjs/core"),S=require("@univerjs/sheets-data-validation"),m=require("react/jsx-runtime"),b=require("@univerjs/design"),y=require("@univerjs/ui"),E=require("react"),gt=require("@univerjs/sheets-formula-ui"),$=require("@univerjs/data-validation"),ie=require("rxjs"),A=require("@univerjs/engine-render"),W=require("@univerjs/sheets"),Ht=require("@univerjs/sheets-numfmt"),k=require("@univerjs/sheets-ui"),lt=require("@univerjs/engine-formula"),Wt="univer-data-validation-formula",$t="univer-data-validation-formula-and",Yt="univer-data-validation-formula-list-item",Xt="univer-data-validation-formula-list-item-icon",zt="univer-data-validation-formula-list-item-drag",Kt="univer-data-validation-formula-list-add",Gt="univer-data-validation-formula-color-select",qt="univer-data-validation-formula-color-select-panel",Zt="univer-data-validation-formula-color-item",ee={dataValidationFormula:Wt,dataValidationFormulaAnd:$t,dataValidationFormulaListItem:Yt,dataValidationFormulaListItemIcon:Xt,dataValidationFormulaListItemDrag:zt,dataValidationFormulaListAdd:Kt,dataValidationFormulaColorSelect:Gt,dataValidationFormulaColorSelectPanel:qt,dataValidationFormulaColorItem:Zt},Jt=e=>{const{isTwoFormula:t=!1,value:n,onChange:a,showError:i,validResult:o}=e,s=y.useDependency(r.LocaleService),d=i?o==null?void 0:o.formula1:"",l=i?o==null?void 0:o.formula2:"";return t?m.jsxs(m.Fragment,{children:[m.jsx(b.FormLayout,{error:d,children:m.jsx(b.Input,{className:ee.dataValidationFormula,placeholder:s.t("dataValidation.panel.formulaPlaceholder"),value:n==null?void 0:n.formula1,onChange:c=>{a==null||a({...n,formula1:c})}})}),m.jsx("div",{className:ee.dataValidationFormulaAnd,children:s.t("dataValidation.panel.formulaAnd")}),m.jsx(b.FormLayout,{error:l,children:m.jsx(b.Input,{className:ee.dataValidationFormula,placeholder:s.t("dataValidation.panel.formulaPlaceholder"),value:n==null?void 0:n.formula2,onChange:c=>{a==null||a({...n,formula2:c})}})})]}):m.jsx(b.FormLayout,{error:d,children:m.jsx(b.Input,{className:ee.dataValidationFormula,placeholder:s.t("dataValidation.panel.formulaPlaceholder"),value:n==null?void 0:n.formula1,onChange:c=>{a==null||a({formula1:c})}})})};function Qt(e){const{value:t,onChange:n,showError:a,validResult:i}=e,o=y.useDependency(r.LocaleService),s=a?i==null?void 0:i.formula1:"",d=a?i==null?void 0:i.formula2:"",[l,c]=E.useState(!((t==null?void 0:t.formula1)===void 0&&(t==null?void 0:t.formula2)===void 0));return m.jsxs(m.Fragment,{children:[m.jsx(b.FormLayout,{children:m.jsx(b.Checkbox,{checked:l,onChange:h=>{h?c(!0):(c(!1),n==null||n({...t,formula1:void 0,formula2:void 0}))},children:o.t("dataValidation.checkbox.tips")})}),l?m.jsx(b.FormLayout,{label:o.t("dataValidation.checkbox.checked"),error:s,children:m.jsx(b.Input,{className:ee.dataValidationFormula,placeholder:o.t("dataValidation.panel.valuePlaceholder"),value:t==null?void 0:t.formula1,onChange:h=>{n==null||n({...t,formula1:h||void 0})}})}):null,l?m.jsx(b.FormLayout,{label:o.t("dataValidation.checkbox.unchecked"),error:d,children:m.jsx(b.Input,{className:ee.dataValidationFormula,placeholder:o.t("dataValidation.panel.valuePlaceholder"),value:t==null?void 0:t.formula2,onChange:h=>{n==null||n({...t,formula2:h||void 0})}})}):null]})}function ea(e){var v;const{unitId:t,subUnitId:n,value:a,onChange:i,showError:o,validResult:s}=e,d=o?s==null?void 0:s.formula1:void 0,l=E.useRef(null),[c,h]=E.useState(!1);return y.useSidebarClick(u=>{var g;((g=l.current)==null?void 0:g.isClickOutSide(u))&&h(!1)}),m.jsx(gt.FormulaEditor,{initValue:(v=a==null?void 0:a.formula1)!=null?v:"=",unitId:t,subUnitId:n,isFocus:c,onChange:u=>{const I=(u!=null?u:"").trim();I!==(a==null?void 0:a.formula1)&&(i==null||i({...a,formula1:I}))},errorText:d,onFocus:()=>h(!0),isSupportAcrossSheet:!0,ref:l})}var ne=function(){return ne=Object.assign||function(e){for(var t,n=1,a=arguments.length;n<a;n++){t=arguments[n];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])}return e},ne.apply(this,arguments)},ta=function(e,t){var n={};for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&t.indexOf(a)<0&&(n[a]=e[a]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,a=Object.getOwnPropertySymbols(e);i<a.length;i++)t.indexOf(a[i])<0&&Object.prototype.propertyIsEnumerable.call(e,a[i])&&(n[a[i]]=e[a[i]]);return n},_e=E.forwardRef(function(e,t){var n=e.icon,a=e.id,i=e.className,o=e.extend,s=ta(e,["icon","id","className","extend"]),d="univerjs-icon univerjs-icon-".concat(a," ").concat(i||"").trim(),l=E.useRef("_".concat(ia()));return Dt(n,"".concat(a),{defIds:n.defIds,idSuffix:l.current},ne({ref:t,className:d},s),o)});function Dt(e,t,n,a,i){return E.createElement(e.tag,ne(ne({key:t},aa(e,n,i)),a),(na(e,n).children||[]).map(function(o,s){return Dt(o,"".concat(t,"-").concat(e.tag,"-").concat(s),n,void 0,i)}))}function aa(e,t,n){var a=ne({},e.attrs);n!=null&&n.colorChannel1&&a.fill==="colorChannel1"&&(a.fill=n.colorChannel1),e.tag==="mask"&&a.id&&(a.id=a.id+t.idSuffix),Object.entries(a).forEach(function(o){var s=o[0],d=o[1];s==="mask"&&typeof d=="string"&&(a[s]=d.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))});var i=t.defIds;return!i||i.length===0||(e.tag==="use"&&a["xlink:href"]&&(a["xlink:href"]=a["xlink:href"]+t.idSuffix),Object.entries(a).forEach(function(o){var s=o[0],d=o[1];typeof d=="string"&&(a[s]=d.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))})),a}function na(e,t){var n,a=t.defIds;return!a||a.length===0?e:e.tag==="defs"&&(!((n=e.children)===null||n===void 0)&&n.length)?ne(ne({},e),{children:e.children.map(function(i){return typeof i.attrs.id=="string"&&a&&a.indexOf(i.attrs.id)>-1?ne(ne({},i),{attrs:ne(ne({},i.attrs),{id:i.attrs.id+t.idSuffix})}):i})}):e}function ia(){return Math.random().toString(36).substring(2,8)}_e.displayName="UniverIcon";var oa={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M1.4917 3.07803C1.4917 2.19437 2.20804 1.47803 3.0917 1.47803H5.6917C6.57536 1.47803 7.2917 2.19437 7.2917 3.07803V5.67803C7.2917 6.56168 6.57535 7.27803 5.6917 7.27803H3.0917C2.20804 7.27803 1.4917 6.56168 1.4917 5.67803V3.07803ZM3.0917 2.67803C2.87078 2.67803 2.6917 2.85711 2.6917 3.07803V5.67803C2.6917 5.89894 2.87079 6.07803 3.0917 6.07803H5.6917C5.91261 6.07803 6.0917 5.89894 6.0917 5.67803V3.07803C6.0917 2.85711 5.91261 2.67803 5.6917 2.67803H3.0917Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M14.6175 2.45279C14.8518 2.68711 14.8518 3.06701 14.6175 3.30132L11.6151 6.30365C11.3957 6.52307 11.0451 6.53897 10.8067 6.34031L8.80915 4.67566C8.55458 4.46352 8.52019 4.08518 8.73233 3.83062 8.94447 3.57605 9.32281 3.54166 9.57737 3.7538L11.154 5.06767 13.769 2.45278C14.0033 2.21847 14.3832 2.21848 14.6175 2.45279zM14.1175 9.19746C14.3518 9.43178 14.3518 9.81168 14.1175 10.046L12.5418 11.6217 14.1175 13.1975C14.3518 13.4318 14.3518 13.8117 14.1175 14.046 13.8832 14.2803 13.5033 14.2803 13.269 14.046L11.6933 12.4703 10.1175 14.046C9.88321 14.2803 9.50331 14.2803 9.269 14.046 9.03468 13.8117 9.03468 13.4318 9.269 13.1975L10.8447 11.6217 9.269 10.046C9.03468 9.81168 9.03468 9.43178 9.269 9.19746 9.50331 8.96315 9.88321 8.96315 10.1175 9.19746L11.6933 10.7732 13.269 9.19746C13.5033 8.96315 13.8832 8.96315 14.1175 9.19746z"}},{tag:"path",attrs:{fill:"currentColor",d:"M3.0917 8.72168C2.20804 8.72168 1.4917 9.43802 1.4917 10.3217V12.9217C1.4917 13.8053 2.20804 14.5217 3.0917 14.5217H5.6917C6.57535 14.5217 7.2917 13.8053 7.2917 12.9217V10.3217C7.2917 9.43802 6.57536 8.72168 5.6917 8.72168H3.0917ZM2.6917 10.3217C2.6917 10.1008 2.87078 9.92168 3.0917 9.92168H5.6917C5.91261 9.92168 6.0917 10.1008 6.0917 10.3217V12.9217C6.0917 13.1426 5.91261 13.3217 5.6917 13.3217H3.0917C2.87079 13.3217 2.6917 13.1426 2.6917 12.9217V10.3217Z",fillRule:"evenodd",clipRule:"evenodd"}}]},yt=E.forwardRef(function(e,t){return E.createElement(_e,Object.assign({},e,{id:"data-validation-single",ref:t,icon:oa}))});yt.displayName="DataValidationSingle";var ra={tag:"svg",attrs:{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.866699 5.9313.866699H10.069C10.4004.866699 10.669 1.13533 10.669 1.4667 10.669 1.79807 10.4004 2.0667 10.069 2.0667H5.9313C5.59993 2.0667 5.3313 1.79807 5.3313 1.4667zM1.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.64443 14.8999 3.9758 14.6312 4.24443 14.2999 4.24443H1.69985C1.36848 4.24443 1.09985 3.9758 1.09985 3.64443zM6.12398 8.30171C6.35829 8.0674 6.73819 8.0674 6.97251 8.30171L8.00007 9.32928 9.02764 8.30171C9.26195 8.0674 9.64185 8.0674 9.87617 8.30171 10.1105 8.53603 10.1105 8.91593 9.87617 9.15024L8.8486 10.1778 9.87617 11.2054C10.1105 11.4397 10.1105 11.8196 9.87617 12.0539 9.64185 12.2882 9.26195 12.2882 9.02764 12.0539L8.00007 11.0263 6.97251 12.0539C6.73819 12.2882 6.35829 12.2882 6.12398 12.0539 5.88966 11.8196 5.88966 11.4397 6.12398 11.2054L7.15154 10.1778 6.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"}}]},pt=E.forwardRef(function(e,t){return E.createElement(_e,Object.assign({},e,{id:"delete-single",ref:t,icon:ra}))});pt.displayName="DeleteSingle";var sa={tag:"svg",attrs:{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"}}]},Rt=E.forwardRef(function(e,t){return E.createElement(_e,Object.assign({},e,{id:"increase-single",ref:t,icon:sa}))});Rt.displayName="IncreaseSingle";var la={tag:"svg",attrs:{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"}}]},wt=E.forwardRef(function(e,t){return E.createElement(_e,Object.assign({},e,{id:"more-down-single",ref:t,icon:la}))});wt.displayName="MoreDownSingle";var da={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M4.64645 9.85355C4.45118 9.65829 4.45118 9.34171 4.64645 9.14645L7.64645 6.14645C7.84171 5.95118 8.15829 5.95118 8.35355 6.14645L11.3536 9.14645C11.5488 9.34171 11.5488 9.65829 11.3536 9.85355C11.1583 10.0488 10.8417 10.0488 10.6464 9.85355L8 7.20711L5.35355 9.85355C5.15829 10.0488 4.84171 10.0488 4.64645 9.85355Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Et=E.forwardRef(function(e,t){return E.createElement(_e,Object.assign({},e,{id:"more-up-single",ref:t,icon:da}))});Et.displayName="MoreUpSingle";var ca={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"mask",attrs:{id:"mask0_622_8",style:{maskType:"alpha"},width:16,height:16,x:0,y:0,maskUnits:"userSpaceOnUse"},children:[{tag:"path",attrs:{fill:"#D9D9D9",d:"M0 0H16V16H0z"}}]},{tag:"g",attrs:{fill:"currentColor",mask:"url(#mask0_622_8)"},children:[{tag:"path",attrs:{d:"M6 5C6.55228 5 7 4.55228 7 4 7 3.44772 6.55228 3 6 3 5.44772 3 5 3.44772 5 4 5 4.55228 5.44772 5 6 5zM6 9C6.55228 9 7 8.55229 7 8 7 7.44772 6.55228 7 6 7 5.44772 7 5 7.44772 5 8 5 8.55229 5.44772 9 6 9zM7 12C7 12.5523 6.55228 13 6 13 5.44772 13 5 12.5523 5 12 5 11.4477 5.44772 11 6 11 6.55228 11 7 11.4477 7 12zM10 5C10.5523 5 11 4.55228 11 4 11 3.44772 10.5523 3 10 3 9.44771 3 9 3.44772 9 4 9 4.55228 9.44771 5 10 5zM11 8C11 8.55229 10.5523 9 10 9 9.44771 9 9 8.55229 9 8 9 7.44772 9.44771 7 10 7 10.5523 7 11 7.44772 11 8zM10 13C10.5523 13 11 12.5523 11 12 11 11.4477 10.5523 11 10 11 9.44771 11 9 11.4477 9 12 9 12.5523 9.44771 13 10 13z"}}]}]},Mt=E.forwardRef(function(e,t){return E.createElement(_e,Object.assign({},e,{id:"sequence-single",ref:t,icon:ca}))});Mt.displayName="SequenceSingle";const Re="#ECECEC",ua=["#FFFFFF","#FEE7E7","#FEF0E6","#EFFBD0","#E4F4FE","#E8ECFD","#F1EAFA","#FDE8F3","#E5E5E5","#FDCECE","#FDC49B","#DEF6A2","#9FDAFF","#D0D9FB","#E3D5F6","#FBD0E8","#656565","#FE4B4B","#FF8C51","#8BBB11","#0B9EFB","#3A60F7","#9E6DE3","#F248A6"],ha=e=>{const{value:t,onChange:n,disabled:a}=e,[i,o]=E.useState(!1);return m.jsx(b.Select,{disabled:a,open:i,onDropdownVisibleChange:o,dropdownStyle:{width:112},style:{width:96,cursor:"pointer"},className:ee.dataValidationFormulaColorSelect,value:t,onChange:n,labelRender:s=>m.jsx("div",{className:ee.dataValidationFormulaColorItem,style:{background:s.value,marginTop:5}}),dropdownRender:()=>m.jsx("div",{className:ee.dataValidationFormulaColorSelectPanel,children:ua.map(s=>m.jsx("div",{onClick:()=>{n(s),o(!1)},className:ee.dataValidationFormulaColorItem,style:{background:s}},s))})})},ft=e=>{const{item:t,commonProps:n,style:a}=e,{onItemChange:i,onItemDelete:o}=n;return m.jsxs("div",{className:ee.dataValidationFormulaListItem,style:a,children:[t.isRef?null:m.jsx("div",{className:b.clsx(ee.dataValidationFormulaListItemDrag,"draggableHandle"),children:m.jsx(Mt,{})}),m.jsx(ha,{value:t.color,onChange:s=>{i(t.id,t.label,s)}}),m.jsx(b.Input,{disabled:t.isRef,value:t.label,onChange:s=>{i(t.id,s,t.color)},inputStyle:{height:28}}),t.isRef?null:m.jsx("div",{className:ee.dataValidationFormulaListItemIcon,children:m.jsx(pt,{onClick:()=>o(t.id)})})]})};function ga(e){const{value:t,onChange:n=()=>{},unitId:a,subUnitId:i,validResult:o,showError:s,ruleId:d}=e,{formula1:l="",formula2:c=""}=t||{},[h,v]=E.useState(()=>r.isFormulaString(l)?"1":"0"),[u,I]=E.useState(h==="1"?l:"="),[g,O]=E.useState(h==="1"?l:"="),R=y.useDependency(r.LocaleService),p=y.useDependency($.DataValidatorRegistryService),f=y.useDependency($.DataValidationModel),C=y.useDependency(S.DataValidationFormulaController),[M,w]=E.useState(()=>c.split(",")),V=p.getValidatorItem(r.DataValidationType.LIST),[D,T]=E.useState([]),[x,H]=E.useState(""),F=s?o==null?void 0:o.formula1:"",U=E.useMemo(()=>f.ruleChange$.pipe(ie.debounceTime(16)),[]),B=y.useObservable(U),j=y.useEvent(n);E.useEffect(()=>{(async()=>{await new Promise(_=>{setTimeout(()=>_(!0),100)});const P=f.getRuleById(a,i,d),K=P==null?void 0:P.formula1;if(r.isFormulaString(K)&&V&&P){const _=await V.getListAsync(P,a,i);T(_)}})()},[f,B,V,d,i,a]),E.useEffect(()=>{r.isFormulaString(l)&&l!==g&&(I(l),O(g))},[g,l]);const[Y,X]=E.useState(()=>{const P=h!=="1"?S.deserializeListOptions(l):[],K=c.split(",");return P.map((_,N)=>({label:_,color:K[N]||Re,isRef:!1,id:r.Tools.generateRandomId(4)}))}),G=(P,K,_)=>{const N=Y.find(z=>z.id===P);N&&(N.label=K,N.color=_,X([...Y]))},J=P=>{const K=Y.findIndex(_=>_.id===P);K!==-1&&(Y.splice(K,1),X([...Y]))},q=c.split(","),te=E.useMemo(()=>D.map((P,K)=>({label:P,color:q[K]||Re,id:`${K}`,isRef:!0})),[q,D]),le=(P,K,_)=>{const N=[...M];N[+P]=_,w(N),j({formula1:l,formula2:N.join(",")})},oe=()=>{X([...Y,{label:"",color:Re,isRef:!1,id:r.Tools.generateRandomId(4)}])};E.useEffect(()=>{if(h==="1")return;const P=new Set,K=[];Y.map(_=>({labelList:_.label.split(","),item:_})).forEach(({item:_,labelList:N})=>{N.forEach(z=>{P.has(z)||(P.add(z),K.push({label:z,color:_.color}))})}),j({formula1:S.serializeListOptions(K.map(_=>_.label)),formula2:K.map(_=>_.color===Re?"":_.color).join(",")})},[Y,j,h,g,M]);const ae=y.useEvent(async P=>{if(!r.isFormulaString(P)){j==null||j({formula1:"",formula2:c});return}C.getFormulaRefCheck(P)?(j==null||j({formula1:r.isFormulaString(P)?P:"",formula2:c}),H("")):(j==null||j({formula1:"",formula2:c}),I("="),H(R.t("dataValidation.validFail.formulaError")))}),re=E.useRef(null),[ge,de]=E.useState(!1);return y.useSidebarClick(P=>{var _;((_=re.current)==null?void 0:_.isClickOutSide(P))&&de(!1)}),m.jsxs(m.Fragment,{children:[m.jsx(b.FormLayout,{label:R.t("dataValidation.list.options"),children:m.jsxs(b.RadioGroup,{value:h,onChange:P=>{v(P),I(g),P==="1"&&j({formula1:g==="="?"":g,formula2:M.join(",")})},children:[m.jsx(b.Radio,{value:"0",children:R.t("dataValidation.list.customOptions")}),m.jsx(b.Radio,{value:"1",children:R.t("dataValidation.list.refOptions")})]})}),h==="1"?m.jsxs(m.Fragment,{children:[m.jsx(gt.FormulaEditor,{initValue:u,unitId:a,subUnitId:i,isFocus:ge,onChange:(P="")=>{const K=(P!=null?P:"").trim();O(K),ae(K)},errorText:F||x||void 0,onFocus:()=>de(!0),isSupportAcrossSheet:!0,ref:re}),te.length>0&&m.jsx("div",{style:{marginTop:"12px"},children:te.map(P=>m.jsx(ft,{item:P,commonProps:{onItemChange:le},style:{marginBottom:12}},P.id))})]}):m.jsx(b.FormLayout,{error:F,children:m.jsxs("div",{style:{marginTop:"-12px"},children:[m.jsx(b.DraggableList,{list:Y,onListChange:X,rowHeight:28,margin:[0,12],draggableHandle:".draggableHandle",itemRender:P=>m.jsx(ft,{item:P,commonProps:{onItemChange:G,onItemDelete:J}},P.id),idKey:"id"}),m.jsxs("a",{className:ee.dataValidationFormulaListAdd,onClick:oe,children:[m.jsx(Rt,{}),R.t("dataValidation.list.add")]})]})})]})}const pa=[[S.CUSTOM_FORMULA_INPUT_NAME,ea],[S.BASE_FORMULA_INPUT_NAME,Jt],[S.LIST_FORMULA_INPUT_NAME,ga],[S.CHECKBOX_FORMULA_INPUT_NAME,Qt]];var ma=Object.getOwnPropertyDescriptor,va=(e,t,n,a)=>{for(var i=a>1?void 0:a?ma(t,n):t,o=e.length-1,s;o>=0;o--)(s=e[o])&&(i=s(i)||i);return i},fa=(e,t)=>(n,a)=>t(n,a,e);exports.BaseSheetDataValidatorView=class{constructor(t){L(this,"canvasRender",null);L(this,"dropdownType");L(this,"optionsInput");L(this,"formulaInput",S.LIST_FORMULA_INPUT_NAME);this.injector=t}};exports.BaseSheetDataValidatorView=va([fa(0,r.Inject(r.Injector))],exports.BaseSheetDataValidatorView);var Sa=Object.getOwnPropertyDescriptor,_a=(e,t,n,a)=>{for(var i=a>1?void 0:a?Sa(t,n):t,o=e.length-1,s;o>=0;o--)(s=e[o])&&(i=s(i)||i);return i},St=(e,t)=>(n,a)=>t(n,a,e);let he=class extends r.Disposable{constructor(t,n){super();L(this,"_open$",new ie.BehaviorSubject(!1));L(this,"open$",this._open$.pipe(ie.distinctUntilChanged()));L(this,"_activeRule");L(this,"_activeRule$",new ie.BehaviorSubject(void 0));L(this,"activeRule$",this._activeRule$.asObservable());L(this,"_closeDisposable",null);this._univerInstanceService=t,this._sidebarService=n,this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(r.UniverInstanceType.UNIVER_SHEET).pipe(ie.filter(a=>!a)).subscribe(()=>{this.close()})),this.disposeWithMe(this._sidebarService.sidebarOptions$.subscribe(a=>{a.id===We&&(a.visible||setTimeout(()=>{this._sidebarService.sidebarOptions$.next({visible:!1})}))}))}get activeRule(){return this._activeRule}get isOpen(){return this._open$.getValue()}dispose(){var t;super.dispose(),this._open$.next(!1),this._open$.complete(),this._activeRule$.complete(),(t=this._closeDisposable)==null||t.dispose()}open(){this._open$.next(!0)}close(){var t;this._open$.next(!1),(t=this._closeDisposable)==null||t.dispose()}setCloseDisposable(t){this._closeDisposable=r.toDisposable(()=>{t.dispose(),this._closeDisposable=null})}setActiveRule(t){this._activeRule=t,this._activeRule$.next(t)}};he=_a([St(0,r.IUniverInstanceService),St(1,y.ISidebarService)],he);var Ia=Object.getOwnPropertyDescriptor,Ca=(e,t,n,a)=>{for(var i=a>1?void 0:a?Ia(t,n):t,o=e.length-1,s;o>=0;o--)(s=e[o])&&(i=s(i)||i);return i},Ce=(e,t)=>(n,a)=>t(n,a,e);let Ee=class extends r.Disposable{constructor(e,t,n,a,i,o){super(),this._sheetInterceptorService=e,this._dataValidationModel=t,this._dataValidatorRegistryService=n,this._dialogService=a,this._localeService=i,this._sheetsDataValidationValidatorService=o,this._initEditorBridgeInterceptor()}_initEditorBridgeInterceptor(){this._sheetInterceptorService.writeCellInterceptor.intercept(W.VALIDATE_CELL,{handler:async(e,t,n)=>{const a=await e,{row:i,col:o,unitId:s,subUnitId:d}=t,l=this._dataValidationModel.getRuleIdByLocation(s,d,i,o),c=l?this._dataValidationModel.getRuleById(s,d,l):void 0;if(a===!1)return n(Promise.resolve(!1));if(!c||c.errorStyle!==r.DataValidationErrorStyle.STOP)return n(Promise.resolve(!0));const h=this._dataValidatorRegistryService.getValidatorItem(c.type);return!h||await this._sheetsDataValidationValidatorService.validatorCell(s,d,i,o)===r.DataValidationStatus.VALID?n(Promise.resolve(!0)):(this._dialogService.open({width:368,title:{title:this._localeService.t("dataValidation.alert.title")},id:"reject-input-dialog",children:{title:h.getRuleFinalError(c,{row:i,col:o,unitId:s,subUnitId:d})},footer:{title:E.createElement(b.Button,{variant:"primary",onClick:()=>this._dialogService.close("reject-input-dialog")},this._localeService.t("dataValidation.alert.ok"))},onClose:()=>{this._dialogService.close("reject-input-dialog")}}),n(Promise.resolve(!1)))}})}showReject(e){this._dialogService.open({width:368,title:{title:this._localeService.t("dataValidation.alert.title")},id:"reject-input-dialog",children:{title:e},footer:{title:E.createElement(b.Button,{variant:"primary",onClick:()=>this._dialogService.close("reject-input-dialog")},this._localeService.t("dataValidation.alert.ok"))},onClose:()=>{this._dialogService.close("reject-input-dialog")}})}};Ee=Ca([Ce(0,r.Inject(W.SheetInterceptorService)),Ce(1,r.Inject(S.SheetDataValidationModel)),Ce(2,r.Inject($.DataValidatorRegistryService)),Ce(3,y.IDialogService),Ce(4,r.Inject(r.LocaleService)),Ce(5,r.Inject(S.SheetsDataValidationValidatorService))],Ee);var Va=Object.getOwnPropertyDescriptor,Da=(e,t,n,a)=>{for(var i=a>1?void 0:a?Va(t,n):t,o=e.length-1,s;o>=0;o--)(s=e[o])&&(i=s(i)||i);return i},ce=(e,t)=>(n,a)=>t(n,a,e);const Ze=e=>{if(e==null||typeof e=="boolean")return;if(typeof e=="number"||!Number.isNaN(+e))return r.dayjs(r.numfmt.format("yyyy-MM-dd HH:mm:ss",Number(e)));const t=r.dayjs(e);if(t.isValid())return t};function ya(e,t){const n=Ht.getPatternType(t);if(e===n)return t;switch(e){case"datetime":return"yyyy-MM-dd hh:mm:ss";case"date":return"yyyy-MM-dd";case"time":return"HH:mm:ss"}}let Se=class extends r.Disposable{constructor(t,n,a,i,o,s,d,l,c,h){super();L(this,"_activeDropdown");L(this,"_activeDropdown$",new ie.Subject);L(this,"_currentPopup",null);L(this,"activeDropdown$",this._activeDropdown$.asObservable());L(this,"_zenVisible",!1);this._univerInstanceService=t,this._dataValidatorRegistryService=n,this._zenZoneService=a,this._dataValidationModel=i,this._sheetsSelectionsService=o,this._cellDropdownManagerService=s,this._sheetDataValidationModel=d,this._commandService=l,this._editorBridgeService=c,this._injector=h,this._init(),this._initSelectionChange(),this.disposeWithMe(()=>{this._activeDropdown$.complete()})}get activeDropdown(){return this._activeDropdown}_init(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(t=>{this._zenVisible=t,t&&this.hideDropdown()}))}_getDropdownByCell(t,n,a,i){const o=t?this._univerInstanceService.getUnit(t,r.UniverInstanceType.UNIVER_SHEET):this._univerInstanceService.getCurrentUnitForType(r.UniverInstanceType.UNIVER_SHEET);if(!o)return;const s=n?o.getSheetBySheetId(n):o.getActiveSheet();if(!s)return;const d=this._dataValidationModel.getRuleByLocation(o.getUnitId(),s.getSheetId(),a,i);if(!d)return;const l=this._dataValidatorRegistryService.getValidatorItem(d.type);return l==null?void 0:l.dropdownType}_initSelectionChange(){this.disposeWithMe(this._sheetsSelectionsService.selectionMoveEnd$.subscribe(t=>{t&&t.every(n=>!(n.primary&&this._getDropdownByCell(n.primary.unitId,n.primary.sheetId,n.primary.actualRow,n.primary.actualColumn)))&&this.hideDropdown()}))}showDropdown(t){var O,R;const{location:n}=t,{row:a,col:i,unitId:o,subUnitId:s,workbook:d,worksheet:l}=n;if(this._currentPopup&&this._currentPopup.dispose(),this._zenVisible)return;this._activeDropdown=t,this._activeDropdown$.next(this._activeDropdown);const c=this._sheetDataValidationModel.getRuleByLocation(o,s,a,i);if(!c)return;const h=this._dataValidatorRegistryService.getValidatorItem(c.type);if(!(h!=null&&h.dropdownType))return;let v;const u=async(p,f)=>{var H,F,U;if(!p)return!0;const C=p,M=l.getCell(a,i),w=C.format(f==="date"?"YYYY-MM-DD 00:00:00":"YYYY-MM-DD HH:mm:ss"),V=(H=r.numfmt.parseDate(w))==null?void 0:H.v,D=f==="time"?V%1:V,T=d.getStyles().getStyleByCell(M),x=(U=(F=T==null?void 0:T.n)==null?void 0:F.pattern)!=null?U:"";return c.errorStyle!==r.DataValidationErrorStyle.STOP||await h.validator({value:D,unitId:o,subUnitId:s,row:a,column:i,worksheet:l,workbook:d,interceptValue:w.replace("Z","").replace("T"," "),t:r.CellValueType.NUMBER},c)?(await this._commandService.executeCommand(k.SetCellEditVisibleOperation.id,{visible:!1,eventType:A.DeviceInputEventType.Keyboard,unitId:o,keycode:y.KeyCode.ESC}),await this._commandService.executeCommand(W.SetRangeValuesCommand.id,{unitId:o,subUnitId:s,range:{startColumn:i,endColumn:i,startRow:a,endRow:a},value:{v:D,t:2,p:null,f:null,si:null,s:{n:{pattern:ya(f,x)}}}}),!0):(this._injector.has(Ee)&&this._injector.get(Ee).showReject(h.getRuleFinalError(c,{row:a,col:i,unitId:o,subUnitId:s})),!1)};let I;switch(h.dropdownType){case $.DataValidatorDropdownType.DATE:{const p=S.getCellValueOrigin(l.getCellRaw(a,i)),f=Ze(p),C=!!((O=c.bizInfo)!=null&&O.showTime);I={location:n,type:"datepicker",props:{showTime:C,onChange:M=>u(M,C?"datetime":"date"),defaultValue:f,patternType:"date"}};break}case $.DataValidatorDropdownType.TIME:{const p=S.getCellValueOrigin(l.getCellRaw(a,i)),f=Ze(p);I={location:n,type:"datepicker",props:{onChange:C=>u(C,"time"),defaultValue:f,patternType:"time"}};break}case $.DataValidatorDropdownType.DATETIME:{const p=S.getCellValueOrigin(l.getCellRaw(a,i)),f=Ze(p);I={location:n,type:"datepicker",props:{onChange:C=>u(C,"datetime"),defaultValue:f,patternType:"datetime"}};break}case $.DataValidatorDropdownType.LIST:case $.DataValidatorDropdownType.MULTIPLE_LIST:{const p=h.dropdownType===$.DataValidatorDropdownType.MULTIPLE_LIST,f=async T=>{const x=S.serializeListOptions(T),H={unitId:o,subUnitId:s,range:{startColumn:i,endColumn:i,startRow:a,endRow:a},value:{v:x,p:null,f:null,si:null}};return this._editorBridgeService.isVisible().visible&&await this._commandService.executeCommand(k.SetCellEditVisibleOperation.id,{visible:!1,eventType:A.DeviceInputEventType.Keyboard,unitId:o,keycode:y.KeyCode.ESC}),this._commandService.executeCommand(W.SetRangeValuesCommand.id,H),!p},C=(c==null?void 0:c.renderMode)===r.DataValidationRenderMode.CUSTOM||(c==null?void 0:c.renderMode)===void 0,M=h.getListWithColor(c,o,s),w=S.getDataValidationCellValue(l.getCellRaw(a,i)),V=()=>{this._commandService.executeCommand(Ie.id,{ruleId:c.uid}),v==null||v.dispose()},D=M.map(T=>({label:T.label,value:T.label,color:C||T.color?T.color:"transparent"}));I={location:n,type:"list",props:{onChange:T=>f(T),options:D,onEdit:V,defaultValue:w,multiple:p}};break}case $.DataValidatorDropdownType.CASCADE:{I={type:"cascader",props:{onChange:f=>{const C={unitId:o,subUnitId:s,range:{startColumn:i,endColumn:i,startRow:a,endRow:a},value:{v:f.join("/"),p:null,f:null,si:null}};return this._editorBridgeService.isVisible().visible&&this._commandService.syncExecuteCommand(k.SetCellEditVisibleOperation.id,{visible:!1,eventType:A.DeviceInputEventType.Keyboard,unitId:o,keycode:y.KeyCode.ESC}),this._commandService.syncExecuteCommand(W.SetRangeValuesCommand.id,C),!0},defaultValue:S.getDataValidationCellValue(l.getCellRaw(a,i)).split("/"),options:JSON.parse((R=c.formula1)!=null?R:"[]")},location:n};break}case $.DataValidatorDropdownType.COLOR:{I={type:"color",props:{onChange:f=>{const C={unitId:o,subUnitId:s,range:{startColumn:i,endColumn:i,startRow:a,endRow:a},value:{v:f,p:null,f:null,si:null}};return this._editorBridgeService.isVisible().visible&&this._commandService.syncExecuteCommand(k.SetCellEditVisibleOperation.id,{visible:!1,eventType:A.DeviceInputEventType.Keyboard,unitId:o,keycode:y.KeyCode.ESC}),this._commandService.syncExecuteCommand(W.SetRangeValuesCommand.id,C),!0},defaultValue:S.getDataValidationCellValue(l.getCellRaw(a,i))},location:n};break}default:throw new Error("[DataValidationDropdownManagerService]: unknown type!")}if(v=this._cellDropdownManagerService.showDropdown(I),!v)throw new Error("[DataValidationDropdownManagerService]: cannot show dropdown!");const g=new r.DisposableCollection;g.add(v),g.add({dispose:()=>{var p,f;(f=(p=this._activeDropdown)==null?void 0:p.onHide)==null||f.call(p)}}),this._currentPopup=g}hideDropdown(){this._activeDropdown&&(this._currentPopup&&this._currentPopup.dispose(),this._currentPopup=null,this._activeDropdown=null,this._activeDropdown$.next(null))}showDataValidationDropdown(t,n,a,i,o){const s=this._univerInstanceService.getUnit(t,r.UniverInstanceType.UNIVER_SHEET);if(!s)return;const d=s.getSheetBySheetId(n);if(!d)return;const l=this._dataValidationModel.getRuleByLocation(s.getUnitId(),d.getSheetId(),a,i);if(!l)return;const c=this._dataValidatorRegistryService.getValidatorItem(l.type);if(!c||!c.dropdownType){this.hideDropdown();return}this.showDropdown({location:{workbook:s,worksheet:d,row:a,col:i,unitId:t,subUnitId:n},onHide:o})}};Se=Da([ce(0,r.IUniverInstanceService),ce(1,r.Inject($.DataValidatorRegistryService)),ce(2,y.IZenZoneService),ce(3,r.Inject(S.SheetDataValidationModel)),ce(4,r.Inject(W.SheetsSelectionsService)),ce(5,r.Inject(k.ISheetCellDropdownManagerService)),ce(6,r.Inject(S.SheetDataValidationModel)),ce(7,r.ICommandService),ce(8,k.IEditorBridgeService),ce(9,r.Inject(r.Injector))],Se);const We="DataValidationPanel",Ie={id:"data-validation.operation.open-validation-panel",type:r.CommandType.OPERATION,handler(e,t){if(!t)return!1;const{ruleId:n,isAdd:a}=t,i=e.get(he),o=e.get($.DataValidationModel),s=e.get(r.IUniverInstanceService),d=e.get(y.ISidebarService),l=W.getSheetCommandTarget(s);if(!l)return!1;const{unitId:c,subUnitId:h}=l,v=n?o.getRuleById(c,h,n):void 0;i.open(),i.setActiveRule(v&&{unitId:c,subUnitId:h,rule:v});const u=d.open({id:We,header:{title:a?"dataValidation.panel.addTitle":"dataValidation.panel.title"},children:{label:We},width:312,onClose:()=>i.close()});return i.setCloseDisposable(u),!0}},mt={id:"data-validation.operation.close-validation-panel",type:r.CommandType.OPERATION,handler(e){return e.get(he).close(),!0}},Tt={id:"data-validation.operation.toggle-validation-panel",type:r.CommandType.OPERATION,handler(e){const t=e.get(r.ICommandService),n=e.get(he);return n.open(),n.isOpen?t.executeCommand(mt.id):t.executeCommand(Ie.id),!0}},Ge={type:r.CommandType.OPERATION,id:"sheet.operation.show-data-validation-dropdown",handler(e,t){if(!t)return!1;const n=e.get(Se),{unitId:a,subUnitId:i,row:o,column:s}=t,d=n.activeDropdown,l=d==null?void 0:d.location;return l&&l.unitId===a&&l.subUnitId===i&&l.row===o&&l.col===s||n.showDataValidationDropdown(a,i,o,s),!0}},bt={type:r.CommandType.OPERATION,id:"sheet.operation.hide-data-validation-dropdown",handler(e,t){return t?(e.get(Se).hideDropdown(),!0):!1}},qe={type:r.CommandType.COMMAND,id:"data-validation.command.addRuleAndOpen",handler(e){const t=e.get(r.IUniverInstanceService),n=W.getSheetCommandTarget(t);if(!n)return!1;const{workbook:a,worksheet:i}=n,o=S.createDefaultNewRule(e),s=e.get(r.ICommandService),d=a.getUnitId(),l=i.getSheetId(),c={rule:o,unitId:d,subUnitId:l};return s.syncExecuteCommand(S.AddSheetDataValidationCommand.id,c)?(s.syncExecuteCommand(Ie.id,{ruleId:o.uid,isAdd:!0}),!0):!1}},Ot="sheets-data-validation-ui.config",$e={};var Ra=Object.getOwnPropertyDescriptor,wa=(e,t,n,a)=>{for(var i=a>1?void 0:a?Ra(t,n):t,o=e.length-1,s;o>=0;o--)(s=e[o])&&(i=s(i)||i);return i},Ve=(e,t)=>(n,a)=>t(n,a,e);const me="SHEET_DATA_VALIDATION_ALERT";let Pe=class extends r.Disposable{constructor(e,t,n,a,i,o){super(),this._hoverManagerService=e,this._cellAlertManagerService=t,this._univerInstanceService=n,this._localeService=a,this._zenZoneService=i,this._dataValidationModel=o,this._init()}_init(){this._initCellAlertPopup(),this._initZenService()}_initCellAlertPopup(){this.disposeWithMe(this._hoverManagerService.currentCell$.pipe(ie.debounceTime(100)).subscribe(e=>{var t;if(e){const n=this._univerInstanceService.getUnit(e.location.unitId,r.UniverInstanceType.UNIVER_SHEET),a=n.getSheetBySheetId(e.location.subUnitId);if(!a)return;const i=this._dataValidationModel.getRuleByLocation(e.location.unitId,e.location.subUnitId,e.location.row,e.location.col);if(!i){this._cellAlertManagerService.removeAlert(me);return}if(this._dataValidationModel.validator(i,{...e.location,workbook:n,worksheet:a})===r.DataValidationStatus.INVALID){const s=this._cellAlertManagerService.currentAlert.get(me),d=(t=s==null?void 0:s.alert)==null?void 0:t.location;if(d&&d.row===e.location.row&&d.col===e.location.col&&d.subUnitId===e.location.subUnitId&&d.unitId===e.location.unitId){this._cellAlertManagerService.removeAlert(me);return}const l=this._dataValidationModel.getValidator(i.type);if(!l){this._cellAlertManagerService.removeAlert(me);return}this._cellAlertManagerService.showAlert({type:k.CellAlertType.ERROR,title:this._localeService.t("dataValidation.error.title"),message:l==null?void 0:l.getRuleFinalError(i,e.location),location:e.location,width:200,height:74,key:me});return}}this._cellAlertManagerService.removeAlert(me)}))}_initZenService(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(e=>{e&&this._cellAlertManagerService.removeAlert(me)}))}};Pe=wa([Ve(0,r.Inject(k.HoverManagerService)),Ve(1,r.Inject(k.CellAlertManagerService)),Ve(2,r.IUniverInstanceService),Ve(3,r.Inject(r.LocaleService)),Ve(4,y.IZenZoneService),Ve(5,r.Inject(S.SheetDataValidationModel))],Pe);var Ea=Object.getOwnPropertyDescriptor,Ma=(e,t,n,a)=>{for(var i=a>1?void 0:a?Ea(t,n):t,o=e.length-1,s;o>=0;o--)(s=e[o])&&(i=s(i)||i);return i},Je=(e,t)=>(n,a)=>t(n,a,e);let Me=class extends r.Disposable{constructor(e,t,n){super(),this._autoFillService=e,this._sheetDataValidationModel=t,this._injector=n,this._initAutoFill()}_initAutoFill(){const e=()=>({redos:[],undos:[]}),t=(a,i)=>{const{source:o,target:s,unitId:d,subUnitId:l}=a,c=this._sheetDataValidationModel.getRuleObjectMatrix(d,l).clone(),h=k.virtualizeDiscreteRanges([o,s]),[v,u]=h.ranges,{mapFunc:I}=h,g={row:v.startRow,col:v.startColumn},O=k.getAutoFillRepeatRange(v,u),R=new r.ObjectMatrix,p=new Set;O.forEach(V=>{const D=V.repeatStartCell,T=V.relativeRange,x={startRow:g.row,startColumn:g.col,endColumn:g.col,endRow:g.row},H={startRow:D.row,startColumn:D.col,endColumn:D.col,endRow:D.row};r.Range.foreach(T,(F,U)=>{const B=r.Rectangle.getPositionRange({startRow:F,startColumn:U,endColumn:U,endRow:F},x),{row:j,col:Y}=I(B.startRow,B.startColumn),X=this._sheetDataValidationModel.getRuleIdByLocation(d,l,j,Y)||"",G=r.Rectangle.getPositionRange({startRow:F,startColumn:U,endColumn:U,endRow:F},H),{row:J,col:q}=I(G.startRow,G.startColumn);R.setValue(J,q,X),p.add(X)})});const f=Array.from(p).map(V=>({id:V,ranges:r.queryObjectMatrix(R,D=>D===V)}));c.addRangeRules(f);const C=c.diff(this._sheetDataValidationModel.getRules(d,l)),{redoMutations:M,undoMutations:w}=S.getDataValidationDiffMutations(d,l,C,this._injector,"patched",i===k.APPLY_TYPE.ONLY_FORMAT);return{undos:w,redos:M}},n={id:S.DATA_VALIDATION_PLUGIN_NAME,onBeforeFillData:a=>{const{source:i,unitId:o,subUnitId:s}=a;for(const d of i.rows)for(const l of i.cols){const c=this._sheetDataValidationModel.getRuleByLocation(o,s,d,l);if(c&&c.type===r.DataValidationType.CHECKBOX){this._autoFillService.setDisableApplyType(k.APPLY_TYPE.SERIES,!0);return}}},onFillData:(a,i,o)=>o===k.APPLY_TYPE.COPY||o===k.APPLY_TYPE.ONLY_FORMAT||o===k.APPLY_TYPE.SERIES?t(a,o):e(),onAfterFillData:()=>{}};this.disposeWithMe(this._autoFillService.addHook(n))}};Me=Ma([Je(0,k.IAutoFillService),Je(1,r.Inject(S.SheetDataValidationModel)),Je(2,r.Inject(r.Injector))],Me);var Ta=Object.getOwnPropertyDescriptor,ba=(e,t,n,a)=>{for(var i=a>1?void 0:a?Ta(t,n):t,o=e.length-1,s;o>=0;o--)(s=e[o])&&(i=s(i)||i);return i},Qe=(e,t)=>(n,a)=>t(n,a,e);let Te=class extends r.Disposable{constructor(t,n,a){super();L(this,"_copyInfo");this._sheetClipboardService=t,this._sheetDataValidationModel=n,this._injector=a,this._initCopyPaste()}_initCopyPaste(){this._sheetClipboardService.addClipboardHook({id:S.DATA_VALIDATION_PLUGIN_NAME,onBeforeCopy:(t,n,a)=>this._collect(t,n,a),onPasteCells:(t,n,a,i)=>{const{copyType:o=k.COPY_TYPE.COPY,pasteType:s}=i,{range:d}=t||{},{range:l,unitId:c,subUnitId:h}=n;return this._generateMutations(l,{copyType:o,pasteType:s,copyRange:d,unitId:c,subUnitId:h})}})}_collect(t,n,a){const i=new r.ObjectMatrix;this._copyInfo={unitId:t,subUnitId:n,matrix:i};const o=this._injector.invoke(l=>W.rangeToDiscreteRange(a,l,t,n));if(!o)return;const{rows:s,cols:d}=o;s.forEach((l,c)=>{d.forEach((h,v)=>{const u=this._sheetDataValidationModel.getRuleIdByLocation(t,n,l,h);i.setValue(c,v,u!=null?u:"")})})}_generateMutations(t,n){if(!this._copyInfo)return{redos:[],undos:[]};if(n.copyType===k.COPY_TYPE.CUT)return this._copyInfo=null,{redos:[],undos:[]};if(!this._copyInfo||!this._copyInfo.matrix.getSizeOf()||!n.copyRange)return{redos:[],undos:[]};if([k.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_COL_WIDTH,k.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_VALUE,k.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMAT,k.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMULA].includes(n.pasteType))return{redos:[],undos:[]};const{unitId:i,subUnitId:o}=this._copyInfo;if(n.unitId!==i||o!==n.subUnitId){const s=this._sheetDataValidationModel.getRuleObjectMatrix(n.unitId,n.subUnitId).clone(),d=new r.ObjectMatrix,l=new Set,{ranges:[c,h],mapFunc:v}=k.virtualizeDiscreteRanges([n.copyRange,t]),u=k.getRepeatRange(c,h,!0),I=new Map;u.forEach(({startRange:p})=>{var f;(f=this._copyInfo)==null||f.matrix.forValue((C,M,w)=>{const V=r.Rectangle.getPositionRange({startRow:C,endRow:C,startColumn:M,endColumn:M},p),D=`${o}-${w}`,T=this._sheetDataValidationModel.getRuleById(i,o,w);!this._sheetDataValidationModel.getRuleById(n.unitId,n.subUnitId,D)&&T&&I.set(D,{...T,uid:D});const{row:x,col:H}=v(V.startRow,V.startColumn);l.add(D),d.setValue(x,H,D)})});const g=Array.from(l).map(p=>({id:p,ranges:r.queryObjectMatrix(d,f=>f===p)}));s.addRangeRules(g);const{redoMutations:O,undoMutations:R}=S.getDataValidationDiffMutations(n.unitId,n.subUnitId,s.diffWithAddition(this._sheetDataValidationModel.getRules(n.unitId,n.subUnitId),I.values()),this._injector,"patched",!1);return{redos:O,undos:R}}else{const s=this._sheetDataValidationModel.getRuleObjectMatrix(i,o).clone(),d=new r.ObjectMatrix,l=new Set,{ranges:[c,h],mapFunc:v}=k.virtualizeDiscreteRanges([n.copyRange,t]);k.getRepeatRange(c,h,!0).forEach(({startRange:R})=>{var p;(p=this._copyInfo)==null||p.matrix.forValue((f,C,M)=>{const w=r.Rectangle.getPositionRange({startRow:f,endRow:f,startColumn:C,endColumn:C},R),{row:V,col:D}=v(w.startRow,w.startColumn);d.setValue(V,D,M),l.add(M)})});const I=Array.from(l).map(R=>({id:R,ranges:r.queryObjectMatrix(d,p=>p===R)}));s.addRangeRules(I);const{redoMutations:g,undoMutations:O}=S.getDataValidationDiffMutations(i,o,s.diff(this._sheetDataValidationModel.getRules(i,o)),this._injector,"patched",!1);return{redos:g,undos:O}}}};Te=ba([Qe(0,k.ISheetClipboardService),Qe(1,r.Inject(S.SheetDataValidationModel)),Qe(2,r.Inject(r.Injector))],Te);var Oa=Object.getOwnPropertyDescriptor,La=(e,t,n,a)=>{for(var i=a>1?void 0:a?Oa(t,n):t,o=e.length-1,s;o>=0;o--)(s=e[o])&&(i=s(i)||i);return i},et=(e,t)=>(n,a)=>t(n,a,e);let be=class extends r.Disposable{constructor(e,t,n){super(),this._localeService=e,this._commandService=t,this._sheetPermissionCheckController=n,this._commandExecutedListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.beforeCommandExecuted(e=>{e.id===S.AddSheetDataValidationCommand.id&&(this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[W.WorkbookEditablePermission],rangeTypes:[W.RangeProtectionPermissionEditPoint],worksheetTypes:[W.WorksheetEditPermission,W.WorksheetSetCellStylePermission]})||this._sheetPermissionCheckController.blockExecuteWithoutPermission(this._localeService.t("permission.dialog.setStyleErr"))),e.id===S.UpdateSheetDataValidationRangeCommand.id&&(this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[W.WorkbookEditablePermission],rangeTypes:[W.RangeProtectionPermissionEditPoint],worksheetTypes:[W.WorksheetEditPermission,W.WorksheetSetCellStylePermission]},e.params.ranges)||this._sheetPermissionCheckController.blockExecuteWithoutPermission(this._localeService.t("permission.dialog.setStyleErr")))}))}};be=La([et(0,r.Inject(r.LocaleService)),et(1,r.ICommandService),et(2,r.Inject(W.SheetPermissionCheckController))],be);const Lt="data-validation-single",At="sheet.menu.data-validation";function Aa(e){return{id:At,type:y.MenuItemType.SUBITEMS,icon:Lt,tooltip:"dataValidation.title",hidden$:y.getMenuHiddenObservable(e,r.UniverInstanceType.UNIVER_SHEET),disabled$:k.getCurrentRangeDisable$(e,{workbookTypes:[W.WorkbookEditablePermission],worksheetTypes:[W.WorksheetSetCellStylePermission,W.WorksheetEditPermission],rangeTypes:[W.RangeProtectionPermissionEditPoint]})}}function Pa(e){return{id:Ie.id,title:"dataValidation.panel.title",type:y.MenuItemType.BUTTON}}function ja(e){return{id:qe.id,title:"dataValidation.panel.add",type:y.MenuItemType.BUTTON}}const Fa={[y.RibbonStartGroup.FORMULAS_INSERT]:{[At]:{order:9,menuItemFactory:Aa,[Ie.id]:{order:0,menuItemFactory:Pa},[qe.id]:{order:1,menuItemFactory:ja}}}};var Ua=Object.getOwnPropertyDescriptor,Pt=(e,t,n,a)=>{for(var i=a>1?void 0:a?Ua(t,n):t,o=e.length-1,s;o>=0;o--)(s=e[o])&&(i=s(i)||i);return i},Z=(e,t)=>(n,a)=>t(n,a,e);const jt={tr:{size:6,color:"#fe4b4b"}};let Oe=class extends r.RxDisposable{constructor(e,t,n,a,i,o,s,d,l,c,h){super(),this._commandService=e,this._menuManagerService=t,this._renderManagerService=n,this._univerInstanceService=a,this._autoHeightController=i,this._dropdownManagerService=o,this._sheetDataValidationModel=s,this._dataValidatorRegistryService=d,this._sheetInterceptorService=l,this._dataValidationCacheService=c,this._editorBridgeService=h,this._initMenu(),this._initDropdown(),this._initViewModelIntercept(),this._initAutoHeight()}_initMenu(){this._menuManagerService.mergeMenu(Fa)}_initDropdown(){this._editorBridgeService&&this.disposeWithMe(this._editorBridgeService.visible$.subscribe(e=>{var n;if(!e.visible){((n=this._dropdownManagerService.activeDropdown)==null?void 0:n.trigger)==="editor-bridge"&&this._dropdownManagerService.hideDropdown();return}const t=this._editorBridgeService.getEditCellState();if(t){const{unitId:a,sheetId:i,row:o,column:s}=t,d=this._univerInstanceService.getUniverSheetInstance(a);if(!d)return;const l=this._sheetDataValidationModel.getRuleByLocation(a,i,o,s);if(!l)return;const c=this._dataValidatorRegistryService.getValidatorItem(l.type);if(!(c!=null&&c.dropdownType))return;const h=d.getActiveSheet();if(!h)return;const v=this._dropdownManagerService.activeDropdown,u=v==null?void 0:v.location;if(u&&u.unitId===a&&u.subUnitId===i&&u.row===o&&u.col===s)return;this._dropdownManagerService.showDropdown({location:{unitId:a,subUnitId:i,row:o,col:s,workbook:d,worksheet:h},trigger:"editor-bridge",closeOnOutSide:!1})}}))}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(W.INTERCEPTOR_POINT.CELL_CONTENT,{effect:r.InterceptorEffectEnum.Style,priority:W.InterceptCellContentPriority.DATA_VALIDATION,handler:(e,t,n)=>{var p,f,C,M,w;const{row:a,col:i,unitId:o,subUnitId:s,workbook:d,worksheet:l}=t,c=this._sheetDataValidationModel.getRuleIdByLocation(o,s,a,i);if(!c)return n(e);const h=this._sheetDataValidationModel.getRuleById(o,s,c);if(!h)return n(e);const v=(p=this._dataValidationCacheService.getValue(o,s,a,i))!=null?p:r.DataValidationStatus.VALID,u=this._dataValidatorRegistryService.getValidatorItem(h.type),I=t.rawData;let g;const O={get value(){var V;return g!==void 0||(g=(V=S.getCellValueOrigin(I))!=null?V:null),g}},R={get value(){var V;return`${(V=O.value)!=null?V:""}`}};return n({...e,markers:{...e==null?void 0:e.markers,...v===r.DataValidationStatus.INVALID?jt:null},customRender:[...(f=e==null?void 0:e.customRender)!=null?f:[],...u!=null&&u.canvasRender?[u.canvasRender]:[]],fontRenderExtension:{...e==null?void 0:e.fontRenderExtension,isSkip:((C=e==null?void 0:e.fontRenderExtension)==null?void 0:C.isSkip)||((M=u==null?void 0:u.skipDefaultFontRender)==null?void 0:M.call(u,h,O.value,t))},interceptorStyle:{...e==null?void 0:e.interceptorStyle,...u==null?void 0:u.getExtraStyle(h,R.value,{get style(){const V=d.getStyles();return(typeof(e==null?void 0:e.s)=="string"?V.get(e==null?void 0:e.s):e==null?void 0:e.s)||{}}},a,i)},interceptorAutoHeight:()=>{var x,H,F,U,B,j;const V=(H=(x=this._renderManagerService.getRenderById(o))==null?void 0:x.with(k.SheetSkeletonManagerService).getSkeletonParam(s))==null?void 0:H.skeleton;if(!V)return;const D=V.worksheet.getMergedCell(a,i),T={data:e,style:V.getStyles().getStyleByCell(e),primaryWithCoord:V.getCellWithCoordByIndex((F=D==null?void 0:D.startRow)!=null?F:a,(U=D==null?void 0:D.startColumn)!=null?U:i),unitId:o,subUnitId:s,row:a,col:i,workbook:d,worksheet:l};return(j=(B=u==null?void 0:u.canvasRender)==null?void 0:B.calcCellAutoHeight)==null?void 0:j.call(B,T)},interceptorAutoWidth:()=>{var x,H,F,U,B,j;const V=(H=(x=this._renderManagerService.getRenderById(o))==null?void 0:x.with(k.SheetSkeletonManagerService).getSkeletonParam(s))==null?void 0:H.skeleton;if(!V)return;const D=V.worksheet.getMergedCell(a,i),T={data:e,style:V.getStyles().getStyleByCell(e),primaryWithCoord:V.getCellWithCoordByIndex((F=D==null?void 0:D.startRow)!=null?F:a,(U=D==null?void 0:D.startColumn)!=null?U:i),unitId:o,subUnitId:s,row:a,col:i,workbook:d,worksheet:l};return(j=(B=u==null?void 0:u.canvasRender)==null?void 0:B.calcCellAutoWidth)==null?void 0:j.call(B,T)},coverable:((w=e==null?void 0:e.coverable)!=null?w:!0)&&!(h.type===r.DataValidationType.LIST||h.type===r.DataValidationType.LIST_MULTIPLE)})}}))}_initAutoHeight(){this._sheetDataValidationModel.ruleChange$.pipe(ie.filter(e=>e.source==="command"),ie.bufferTime(100)).subscribe(e=>{if(e.length===0)return;const t=[];if(e.forEach(n=>{var a;(n.rule.type===r.DataValidationType.LIST_MULTIPLE||n.rule.type===r.DataValidationType.LIST)&&(a=n.rule)!=null&&a.ranges&&t.push(...n.rule.ranges)}),t.length){const n=this._autoHeightController.getUndoRedoParamsOfAutoHeight(t);r.sequenceExecute(n.redos,this._commandService)}})}};Oe=Pt([Z(0,r.ICommandService),Z(1,y.IMenuManagerService),Z(2,A.IRenderManagerService),Z(3,r.IUniverInstanceService),Z(4,r.Inject(k.AutoHeightController)),Z(5,r.Inject(Se)),Z(6,r.Inject(S.SheetDataValidationModel)),Z(7,r.Inject($.DataValidatorRegistryService)),Z(8,r.Inject(W.SheetInterceptorService)),Z(9,r.Inject(S.DataValidationCacheService)),Z(10,r.Optional(k.IEditorBridgeService))],Oe);let _t=class extends r.RxDisposable{constructor(e,t,n,a,i,o,s){super(),this._commandService=e,this._renderManagerService=t,this._autoHeightController=n,this._dataValidatorRegistryService=a,this._sheetInterceptorService=i,this._sheetDataValidationModel=o,this._dataValidationCacheService=s,this._initViewModelIntercept(),this._initAutoHeight()}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(W.INTERCEPTOR_POINT.CELL_CONTENT,{effect:r.InterceptorEffectEnum.Style,priority:W.InterceptCellContentPriority.DATA_VALIDATION,handler:(e,t,n)=>{var R,p,f,C,M;const{row:a,col:i,unitId:o,subUnitId:s,workbook:d,worksheet:l}=t,c=this._sheetDataValidationModel.getRuleIdByLocation(o,s,a,i);if(!c)return n(e);const h=this._sheetDataValidationModel.getRuleById(o,s,c);if(!h)return n(e);const v=(R=this._dataValidationCacheService.getValue(o,s,a,i))!=null?R:r.DataValidationStatus.VALID,u=this._dataValidatorRegistryService.getValidatorItem(h.type),I=l.getCellRaw(a,i),g=S.getCellValueOrigin(I),O=`${g!=null?g:""}`;return n({...e,markers:{...e==null?void 0:e.markers,...v===r.DataValidationStatus.INVALID?jt:null},customRender:[...(p=e==null?void 0:e.customRender)!=null?p:[],...u!=null&&u.canvasRender?[u.canvasRender]:[]],fontRenderExtension:{...e==null?void 0:e.fontRenderExtension,isSkip:((f=e==null?void 0:e.fontRenderExtension)==null?void 0:f.isSkip)||((C=u==null?void 0:u.skipDefaultFontRender)==null?void 0:C.call(u,h,g,t))},interceptorStyle:{...e==null?void 0:e.interceptorStyle,...u==null?void 0:u.getExtraStyle(h,O,{get style(){const w=d.getStyles();return(typeof(e==null?void 0:e.s)=="string"?w.get(e==null?void 0:e.s):e==null?void 0:e.s)||{}}},a,i)},interceptorAutoHeight:()=>{var T,x,H,F,U,B;const w=(x=(T=this._renderManagerService.getRenderById(o))==null?void 0:T.with(k.SheetSkeletonManagerService).getSkeletonParam(s))==null?void 0:x.skeleton;if(!w)return;const V=w.worksheet.getMergedCell(a,i),D={data:e,style:w.getStyles().getStyleByCell(e),primaryWithCoord:w.getCellWithCoordByIndex((H=V==null?void 0:V.startRow)!=null?H:a,(F=V==null?void 0:V.startColumn)!=null?F:i),unitId:o,subUnitId:s,row:a,col:i,workbook:d,worksheet:l};return(B=(U=u==null?void 0:u.canvasRender)==null?void 0:U.calcCellAutoHeight)==null?void 0:B.call(U,D)},coverable:((M=e==null?void 0:e.coverable)!=null?M:!0)&&!(h.type===r.DataValidationType.LIST||h.type===r.DataValidationType.LIST_MULTIPLE)})}}))}_initAutoHeight(){this._sheetDataValidationModel.ruleChange$.pipe(ie.filter(e=>e.source==="command"),ie.bufferTime(16)).subscribe(e=>{const t=[];if(e.forEach(n=>{var a;(a=n.rule)!=null&&a.ranges&&t.push(...n.rule.ranges)}),t.length){const n=this._autoHeightController.getUndoRedoParamsOfAutoHeight(t);r.sequenceExecute(n.redos,this._commandService)}})}};_t=Pt([Z(0,r.ICommandService),Z(1,A.IRenderManagerService),Z(2,r.Inject(k.AutoHeightController)),Z(3,r.Inject($.DataValidatorRegistryService)),Z(4,r.Inject(W.SheetInterceptorService)),Z(5,r.Inject(S.SheetDataValidationModel)),Z(6,r.Inject(S.DataValidationCacheService))],_t);var Na=Object.getOwnPropertyDescriptor,ka=(e,t,n,a)=>{for(var i=a>1?void 0:a?Na(t,n):t,o=e.length-1,s;o>=0;o--)(s=e[o])&&(i=s(i)||i);return i},It=(e,t)=>(n,a)=>t(n,a,e);let Ye=class extends r.Disposable{constructor(e,t,n){super(),this._context=e,this._sheetDataValidationModel=t,this._sheetSkeletonManagerService=n,this._initSkeletonChange()}_initSkeletonChange(){const e=t=>{var a;if(!t.length)return;const n=new Set;t.forEach(i=>{n.add(i.subUnitId)}),n.forEach(i=>{var o;(o=this._sheetSkeletonManagerService.getSkeletonParam(i))==null||o.skeleton.makeDirty(!0)}),(a=this._context.mainComponent)==null||a.makeForceDirty()};this.disposeWithMe(this._sheetDataValidationModel.validStatusChange$.pipe(r.bufferDebounceTime(16)).subscribe(e))}};Ye=ka([It(1,r.Inject(S.SheetDataValidationModel)),It(2,r.Inject(k.SheetSkeletonManagerService))],Ye);const xa="univer-data-validation-options-button",Ba="univer-data-validation-options-button-icon",tt={dataValidationOptionsButton:xa,dataValidationOptionsButtonIcon:Ba};function Ha(e){var c;const t=y.useDependency(r.LocaleService),n=y.useDependency(y.ComponentManager),{value:a,onChange:i,extraComponent:o}=e,[s,d]=E.useState(!1),l=o?n.get(o):null;return m.jsxs(m.Fragment,{children:[m.jsxs("div",{className:tt.dataValidationOptionsButton,onClick:()=>d(!s),children:[t.t("dataValidation.panel.options"),s?m.jsx(Et,{className:tt.dataValidationOptionsButtonIcon}):m.jsx(wt,{className:tt.dataValidationOptionsButtonIcon})]}),s&&m.jsxs(m.Fragment,{children:[l?m.jsx(l,{value:a,onChange:i}):null,m.jsx(b.FormLayout,{label:t.t("dataValidation.panel.invalid"),children:m.jsxs(b.RadioGroup,{value:`${(c=a.errorStyle)!=null?c:r.DataValidationErrorStyle.WARNING}`,onChange:h=>i({...a,errorStyle:+h}),children:[m.jsx(b.Radio,{value:`${r.DataValidationErrorStyle.WARNING}`,children:t.t("dataValidation.panel.showWarning")}),m.jsx(b.Radio,{value:`${r.DataValidationErrorStyle.STOP}`,children:t.t("dataValidation.panel.rejectInput")})]})}),m.jsx(b.FormLayout,{label:t.t("dataValidation.panel.messageInfo"),children:m.jsx(b.Checkbox,{checked:a.showErrorMessage,onChange:()=>i({...a,showErrorMessage:!a.showErrorMessage}),children:t.t("dataValidation.panel.showInfo")})}),a.showErrorMessage?m.jsx(b.FormLayout,{children:m.jsx(b.Input,{value:a.error,onChange:h=>i({...a,error:h})})}):null]})]})}const Wa="univer-data-validation-detail",$a="univer-data-validation-detail-form-item",Ya="univer-data-validation-detail-buttons",Xa="univer-data-validation-detail-button",De={dataValidationDetail:Wa,dataValidationDetailFormItem:$a,dataValidationDetailButtons:Ya,dataValidationDetailButton:Xa},za=e=>r.debounce(async(t,n,a,i)=>{const o=await e.executeCommand(t,n,a);i==null||i(o)},1e3);function Ka(e,t,n){var a,i,o,s;return t?((i=(a=e.getUnit(t))==null?void 0:a.getSheetBySheetName(n))==null?void 0:i.getSheetId())||"":((s=(o=e.getCurrentUnitForType(r.UniverInstanceType.UNIVER_SHEET))==null?void 0:o.getSheetBySheetName(n))==null?void 0:s.getSheetId())||""}function Ga(){var P,K;const[e,t]=E.useState(0),n=y.useDependency(he),a=y.useObservable(n.activeRule$,n.activeRule),{unitId:i,subUnitId:o,rule:s}=a||{},d=s.uid,l=y.useDependency($.DataValidatorRegistryService),c=y.useDependency(r.IUniverInstanceService),h=y.useDependency(y.ComponentManager),v=y.useDependency(r.ICommandService),u=y.useDependency($.DataValidationModel),I=y.useDependency(r.LocaleService),[g,O]=E.useState(s),R=l.getValidatorItem(g.type),[p,f]=E.useState(!1),C=l.getValidatorsByScope($.DataValidatorRegistryScope.SHEET),[M,w]=E.useState(()=>g.ranges.map(_=>({unitId:"",sheetId:"",range:_}))),V=E.useMemo(()=>za(v),[v]),[D,T]=E.useState(!1),[x,H]=E.useState(!1),F=E.useRef(null),U=y.useDependency(W.SheetsSelectionsService);if(E.useEffect(()=>()=>{const _=U.getCurrentLastSelection();_&&U.setSelections([_])},[U]),E.useEffect(()=>{v.onCommandExecuted(_=>{(_.id===r.UndoCommand.id||_.id===r.RedoCommand.id)&&setTimeout(()=>{const N=u.getRuleById(i,o,d);t(z=>z+1),N&&(O(N),w(N.ranges.map(z=>({unitId:"",sheetId:"",range:z}))))},20)})},[v,u,d,o,i]),!R)return null;const B=R.operators,j=R.operatorNames,Y=g.operator?$.TWO_FORMULA_OPERATOR_COUNT.includes(g.operator):!1,X=()=>{var _,N,z;(N=(_=F.current)==null?void 0:_.editor)!=null&&N.isFocus()&&G((z=F.current)==null?void 0:z.getValue()),!(!g.ranges.length||D)&&(R.validatorFormula(g,i,o).success?n.setActiveRule(null):f(!0))},G=y.useEvent(_=>{const N=_.split(",").filter(Boolean).map(lt.deserializeRangeWithSheet).map(Q=>{const vt=Q.sheetName;if(vt){const kt=Ka(c,Q.unitId,vt);return{...Q,sheetId:kt}}return{...Q,sheetId:""}});if(r.isUnitRangesEqual(N,M))return;w(N);const z=N.filter(Q=>(!Q.unitId||Q.unitId===i)&&(!Q.sheetId||Q.sheetId===o)).map(Q=>Q.range);if(O({...g,ranges:z}),z.length===0)return;const pe={unitId:i,subUnitId:o,ruleId:d,ranges:z};V(S.UpdateSheetDataValidationRangeCommand.id,pe)}),J=_=>{if(r.shallowEqual(_,$.getRuleSetting(g)))return;O({...g,..._});const N={unitId:i,subUnitId:o,ruleId:d,setting:_};V(S.UpdateSheetDataValidationSettingCommand.id,N,void 0)},q=async()=>{await v.executeCommand(S.RemoveSheetDataValidationCommand.id,{ruleId:d,unitId:i,subUnitId:o}),n.setActiveRule(null)},te={type:g.type,operator:g.operator,formula1:g.formula1,formula2:g.formula2,allowBlank:g.allowBlank},le=_=>{const N=l.getValidatorItem(_);if(!N)return;const z=N.operators,pe=u.getRuleById(i,o,d),Q=_===(pe==null?void 0:pe.type)||_.includes("list")&&(pe!=null&&pe.type.includes("list"))?{...pe,type:_}:{...g,type:_,operator:z[0],formula1:void 0,formula2:void 0};O(Q),v.executeCommand(S.UpdateSheetDataValidationSettingCommand.id,{unitId:i,subUnitId:o,ruleId:g.uid,setting:$.getRuleSetting(Q)})},oe=h.get(R.formulaInput),ae=E.useMemo(()=>M.map(_=>lt.serializeRange(_.range)).join(","),[]),re=$.getRuleOptions(g),ge=_=>{r.shallowEqual(_,$.getRuleOptions(g))||(O({...g,..._}),V(S.UpdateSheetDataValidationOptionsCommand.id,{unitId:i,subUnitId:o,ruleId:d,options:_}))},de=B.length&&!g.operator;return m.jsxs("div",{className:De.dataValidationDetail,children:[m.jsx(b.FormLayout,{label:I.t("dataValidation.panel.range"),error:!g.ranges.length||D?I.t("dataValidation.panel.rangeError"):"",children:m.jsx(gt.RangeSelector,{selectorRef:F,unitId:i,subUnitId:o,initialValue:ae,onChange:(_,N)=>{var z;!x&&((z=F.current)!=null&&z.verify())&&G(N)},onFocusChange:(_,N)=>{var z;H(_),!_&&N&&((z=F.current)!=null&&z.verify())&&G(N)},onVerify:_=>T(!_)})}),m.jsx(b.FormLayout,{label:I.t("dataValidation.panel.type"),children:m.jsx(b.Select,{options:(P=C==null?void 0:C.sort((_,N)=>_.order-N.order))==null?void 0:P.map(_=>({label:I.t(_.title),value:_.id})),value:g.type,onChange:le,className:De.dataValidationDetailFormItem})}),B!=null&&B.length?m.jsx(b.FormLayout,{label:I.t("dataValidation.panel.operator"),children:m.jsx(b.Select,{options:[{value:"",label:I.t("dataValidation.operators.legal")},...B.map((_,N)=>({value:`${_}`,label:j[N]}))],value:`${g.operator}`,onChange:_=>{J({...te,operator:_})},className:De.dataValidationDetailFormItem})}):null,oe&&!de?m.jsx(b.FormLayout,{children:m.jsx(oe,{isTwoFormula:Y,value:{formula1:g.formula1,formula2:g.formula2},onChange:_=>{J({...te,..._})},showError:p,validResult:R.validatorFormula(g,i,o),unitId:i,subUnitId:o,ruleId:d},e+g.type)}):null,m.jsx(b.FormLayout,{children:m.jsx(b.Checkbox,{checked:(K=g.allowBlank)!=null?K:!0,onChange:()=>{var _;return J({...te,allowBlank:!((_=g.allowBlank)==null||_)})},children:I.t("dataValidation.panel.allowBlank")})}),m.jsx(Ha,{value:re,onChange:ge,extraComponent:R.optionsInput}),m.jsxs("div",{className:De.dataValidationDetailButtons,children:[m.jsx(b.Button,{className:De.dataValidationDetailButton,onClick:q,children:I.t("dataValidation.panel.removeRule")}),m.jsx(b.Button,{className:De.dataValidationDetailButton,variant:"primary",onClick:X,children:I.t("dataValidation.panel.done")})]})]})}const qa="univer-data-validation-item-container",Za="univer-data-validation-item-title",Ja="univer-data-validation-item-content",Qa="univer-data-validation-item-icon",je={dataValidationItemContainer:qa,dataValidationItemTitle:Za,dataValidationItemContent:Ja,dataValidationItemIcon:Qa},en=e=>{const{rule:t,onClick:n,unitId:a,subUnitId:i,disable:o}=e,s=y.useDependency($.DataValidatorRegistryService),d=y.useDependency(r.ICommandService),l=y.useDependency(k.IMarkSelectionService),c=s.getValidatorItem(t.type),h=E.useRef(void 0),[v,u]=E.useState(!1),I=y.useDependency(r.ThemeService),g=y.useObservable(I.currentTheme$),O=E.useMemo(()=>{var C;const p=(C=g==null?void 0:g.loopColor2)!=null?C:"#49B811",f=new r.ColorKit(p).toRgb();return{fill:`rgba(${f.r}, ${f.g}, ${f.b}, 0.1)`,stroke:p}},[g]),R=p=>{d.executeCommand(S.RemoveSheetDataValidationCommand.id,{ruleId:t.uid,unitId:a,subUnitId:i}),p.stopPropagation()};return E.useEffect(()=>()=>{var p;h.current&&((p=h.current)==null||p.forEach(f=>{f&&l.removeShape(f)}))},[l]),m.jsxs("div",{className:je.dataValidationItemContainer,onClick:n,onMouseEnter:()=>{o||(u(!0),h.current=t.ranges.map(p=>l.addShape({range:p,style:O,primary:null})))},onMouseLeave:()=>{var p;u(!1),(p=h.current)==null||p.forEach(f=>{f&&l.removeShape(f)}),h.current=void 0},children:[m.jsx("div",{className:je.dataValidationItemTitle,children:c==null?void 0:c.generateRuleName(t)}),m.jsx("div",{className:je.dataValidationItemContent,children:t.ranges.map(p=>lt.serializeRange(p)).join(",")}),v?m.jsx("div",{className:je.dataValidationItemIcon,onClick:R,children:m.jsx(pt,{})}):null]})},tn="univer-data-validation-list",an="univer-data-validation-list-buttons",nn="univer-data-validation-list-button",Fe={dataValidationList:tn,dataValidationListButtons:an,dataValidationListButton:nn};function on(e){const t=y.useDependency(S.SheetDataValidationModel),n=y.useDependency(r.IUniverInstanceService),a=y.useDependency(r.ICommandService),i=y.useDependency(r.Injector),o=y.useDependency(he),s=y.useDependency(r.LocaleService),[d,l]=E.useState([]),{workbook:c}=e,h=y.useObservable(c.activeSheet$,void 0,!0),v=c.getUnitId(),u=h==null?void 0:h.getSheetId();E.useEffect(()=>{l(t.getRules(v,u));const f=t.ruleChange$.subscribe(C=>{C.unitId===v&&C.subUnitId===u&&l(t.getRules(v,u))});return()=>{f.unsubscribe()}},[v,u,t]);const I=async()=>{const f=S.createDefaultNewRule(i),C={unitId:v,subUnitId:u,rule:f};await a.executeCommand(S.AddSheetDataValidationCommand.id,C),o.setActiveRule({unitId:v,subUnitId:u,rule:f})},g=()=>{a.executeCommand(S.RemoveSheetAllDataValidationCommand.id,{unitId:v,subUnitId:u})},R=(f=>{const C=n.getCurrentUnitForType(r.UniverInstanceType.UNIVER_SHEET),M=C.getActiveSheet(),w=C.getUnitId(),V=M.getSheetId();return f.map(T=>W.checkRangesEditablePermission(i,w,V,T.ranges)?{...T}:{...T,disable:!0})})(d),p=R==null?void 0:R.some(f=>f.disable);return m.jsxs("div",{className:Fe.dataValidationList,children:[R==null?void 0:R.map(f=>{var C;return m.jsx(en,{unitId:v,subUnitId:u,onClick:()=>{f.disable||o.setActiveRule({unitId:v,subUnitId:u,rule:f})},rule:f,disable:(C=f.disable)!=null?C:!1},f.uid)}),m.jsxs("div",{className:Fe.dataValidationListButtons,children:[d.length&&!p?m.jsx(b.Button,{className:Fe.dataValidationListButton,onClick:g,children:s.t("dataValidation.panel.removeAll")}):null,m.jsx(b.Button,{className:Fe.dataValidationListButton,variant:"primary",onClick:I,children:s.t("dataValidation.panel.add")})]})]})}const rn=()=>{const e=y.useDependency(he),t=y.useObservable(e.activeRule$,e.activeRule),n=y.useDependency(r.IUniverInstanceService),a=y.useObservable(()=>n.getCurrentTypeOfUnit$(r.UniverInstanceType.UNIVER_SHEET),void 0,void 0,[]),i=y.useObservable(()=>{var o;return(o=a==null?void 0:a.activeSheet$)!=null?o:ie.of(null)},void 0,void 0,[]);return!a||!i?null:t&&t.subUnitId===i.getSheetId()?m.jsx(Ga,{},t.rule.uid):m.jsx(on,{workbook:a})},sn="LIST_RENDER_MODE_OPTION_INPUT";function Xe(e){var i;const{value:t,onChange:n}=e,a=y.useDependency(r.LocaleService);return m.jsx(b.FormLayout,{label:a.t("dataValidation.renderMode.label"),children:m.jsxs(b.RadioGroup,{value:`${(i=t.renderMode)!=null?i:r.DataValidationRenderMode.CUSTOM}`,onChange:o=>n({...t,renderMode:+o}),children:[m.jsx(b.Radio,{value:`${r.DataValidationRenderMode.CUSTOM}`,children:a.t("dataValidation.renderMode.chip")}),m.jsx(b.Radio,{value:`${r.DataValidationRenderMode.ARROW}`,children:a.t("dataValidation.renderMode.arrow")}),m.jsx(b.Radio,{value:`${r.DataValidationRenderMode.TEXT}`,children:a.t("dataValidation.renderMode.text")})]})})}Xe.componentKey=sn;const ln="DATE_SHOW_TIME_OPTION";function ze(e){var i;const{value:t,onChange:n}=e,a=y.useDependency(r.LocaleService);return m.jsx(b.FormLayout,{children:m.jsx(b.Checkbox,{checked:(i=t.bizInfo)==null?void 0:i.showTime,onChange:o=>{n({...t,bizInfo:{...t.bizInfo,showTime:o}})},children:a.t("dataValidation.showTime.label")})})}ze.componentKey=ln;var dn=Object.getOwnPropertyDescriptor,cn=(e,t,n,a)=>{for(var i=a>1?void 0:a?dn(t,n):t,o=e.length-1,s;o>=0;o--)(s=e[o])&&(i=s(i)||i);return i},ye=(e,t)=>(n,a)=>t(n,a,e);const Ue=6;let dt=class{constructor(e,t,n,a,i,o){this._commandService=e,this._univerInstanceService=t,this._formulaService=n,this._themeService=a,this._renderManagerService=i,this._dataValidationModel=o}_calc(e,t){var c,h,v;const{vt:n,ht:a}=t||{},i=e.endX-e.startX-Ue*2,o=e.endY-e.startY,s=((c=t==null?void 0:t.fs)!=null?c:10)*1.6;let d=0,l=0;switch(n){case r.VerticalAlign.TOP:l=0;break;case r.VerticalAlign.BOTTOM:l=0+(o-s);break;default:l=0+(o-s)/2;break}switch(a){case r.HorizontalAlign.LEFT:d=Ue;break;case r.HorizontalAlign.RIGHT:d=Ue+(i-s);break;default:d=Ue+(i-s)/2;break}return{left:e.startX+d,top:e.startY+l,width:((h=t==null?void 0:t.fs)!=null?h:10)*1.6,height:((v=t==null?void 0:t.fs)!=null?v:10)*1.6}}calcCellAutoHeight(e){var n;const{style:t}=e;return((n=t==null?void 0:t.fs)!=null?n:10)*1.6}calcCellAutoWidth(e){var n;const{style:t}=e;return((n=t==null?void 0:t.fs)!=null?n:10)*1.6}async _parseFormula(e,t,n){var c,h,v,u,I,g,O,R,p;const{formula1:a=S.CHECKBOX_FORMULA_1,formula2:i=S.CHECKBOX_FORMULA_2}=e,o=await this._formulaService.getRuleFormulaResult(t,n,e.uid),s=S.getFormulaResult((v=(h=(c=o==null?void 0:o[0])==null?void 0:c.result)==null?void 0:h[0])==null?void 0:v[0]),d=S.getFormulaResult((g=(I=(u=o==null?void 0:o[1])==null?void 0:u.result)==null?void 0:I[0])==null?void 0:g[0]),l=S.isLegalFormulaResult(String(s))&&S.isLegalFormulaResult(String(d));return{formula1:r.isFormulaString(a)?S.getFormulaResult((p=(R=(O=o==null?void 0:o[0])==null?void 0:O.result)==null?void 0:R[0])==null?void 0:p[0]):a,formula2:r.isFormulaString(i)?d:i,isFormulaValid:l}}drawWith(e,t){var U,B,j,Y;const{style:n,primaryWithCoord:a,unitId:i,subUnitId:o,worksheet:s,row:d,col:l}=t,c=a.isMergedMainCell?a.mergeInfo:a,h=S.getCellValueOrigin(s.getCellRaw(d,l)),v=this._dataValidationModel.getRuleByLocation(i,o,d,l);if(!v)return;const u=this._dataValidationModel.getValidator(v.type);if(!u)return;const I=this._themeService.getCurrentTheme();if(!((U=u.skipDefaultFontRender)!=null&&U.call(u,v,h,{unitId:i,subUnitId:o,row:d,column:l})))return;const g=u.parseFormulaSync(v,i,o),{formula1:O}=g,R=this._calc(c,n),{a:p,d:f}=e.getTransform(),C=A.fixLineWidthByScale(R.left,p),M=A.fixLineWidthByScale(R.top,f),w=A.Transform.create().composeMatrix({left:C,top:M,scaleX:1,scaleY:1,angle:0,skewX:0,skewY:0,flipX:!1,flipY:!1}),V=c.endX-c.startX,D=c.endY-c.startY;e.save(),e.beginPath(),e.rect(c.startX,c.startY,V,D),e.clip();const T=w.getMatrix();e.transform(T[0],T[1],T[2],T[3],T[4],T[5]);const x=((B=n==null?void 0:n.fs)!=null?B:10)*1.6,H=String(h)===String(O),F=I.hyacinth500;A.CheckboxShape.drawWith(e,{checked:H,width:x,height:x,fill:(Y=(j=n==null?void 0:n.cl)==null?void 0:j.rgb)!=null?Y:F}),e.restore()}isHit(e,t){const n=t.primaryWithCoord.isMergedMainCell?t.primaryWithCoord.mergeInfo:t.primaryWithCoord,a=this._calc(n,t.style),i=a.top,o=a.top+a.height,s=a.left,d=a.left+a.width,{x:l,y:c}=e;return l<=d&&l>=s&&c<=o&&c>=i}async onPointerDown(e,t){var g;if(t.button===2)return;const{primaryWithCoord:n,unitId:a,subUnitId:i,worksheet:o,row:s,col:d}=e,l=S.getCellValueOrigin(o.getCellRaw(s,d)),c=this._dataValidationModel.getRuleByLocation(a,i,s,d);if(!c)return;const h=this._dataValidationModel.getValidator(c.type);if(!h||!((g=h.skipDefaultFontRender)!=null&&g.call(h,c,l,{unitId:a,subUnitId:i,row:s,column:d})))return;const{formula1:v,formula2:u}=await this._parseFormula(c,a,i),I={range:{startColumn:n.actualColumn,endColumn:n.actualColumn,startRow:n.actualRow,endRow:n.actualRow},value:{v:String(l)===S.transformCheckboxValue(String(v))?u:v,p:null}};this._commandService.executeCommand(W.SetRangeValuesCommand.id,I)}onPointerEnter(e,t){var n,a;(a=(n=A.getCurrentTypeOfRenderer(r.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null?void 0:n.mainComponent)==null||a.setCursor(A.CURSOR_TYPE.POINTER)}onPointerLeave(e,t){var n,a;(a=(n=A.getCurrentTypeOfRenderer(r.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null?void 0:n.mainComponent)==null||a.setCursor(A.CURSOR_TYPE.DEFAULT)}};dt=cn([ye(0,r.ICommandService),ye(1,r.IUniverInstanceService),ye(2,r.Inject(S.DataValidationFormulaService)),ye(3,r.Inject(r.ThemeService)),ye(4,r.Inject(A.IRenderManagerService)),ye(5,r.Inject(S.SheetDataValidationModel))],dt);class un extends exports.BaseSheetDataValidatorView{constructor(){super(...arguments);L(this,"id",r.DataValidationType.CHECKBOX);L(this,"canvasRender",this.injector.createInstance(dt));L(this,"formulaInput",S.CHECKBOX_FORMULA_INPUT_NAME)}}class hn extends exports.BaseSheetDataValidatorView{constructor(){super(...arguments);L(this,"id",r.DataValidationType.CUSTOM);L(this,"formulaInput",S.CUSTOM_FORMULA_INPUT_NAME)}}const gn="data-validation.formula-input";class pn extends exports.BaseSheetDataValidatorView{constructor(){super(...arguments);L(this,"id",r.DataValidationType.DATE);L(this,"formulaInput",gn);L(this,"optionsInput",ze.componentKey);L(this,"dropdownType",$.DataValidatorDropdownType.DATE)}}class mn extends exports.BaseSheetDataValidatorView{constructor(){super(...arguments);L(this,"id",r.DataValidationType.DECIMAL);L(this,"formulaInput",S.BASE_FORMULA_INPUT_NAME)}}const Ft=4,vn=0,at=4,Ut=4,ct=6,Ke=6,fe=14;function fn(e,t){const n=A.FontCache.getTextSize(e,t),a=n.width+Ft*2,{ba:i,bd:o}=n,s=i+o;return{width:a,height:s+vn*2,ba:i}}function nt(e,t,n,a){const i=fe+ct*2,o=n-i,s=a-Ke*2,d=e.map(u=>({layout:fn(u,t),text:u}));let l;const c=[];d.forEach(u=>{const{layout:I}=u,{width:g,height:O}=I;!l||l.width+g+at>o?(l={width:g,height:O,items:[{...u,left:0}]},c.push(l)):(l.items.push({...u,left:l.width+at}),l.width=l.width+g+at)});let h=0,v=0;return c.forEach((u,I)=>{v=Math.max(v,u.width),I===c.length-1?h+=u.height:h+=u.height+Ut}),{lines:c,totalHeight:h,contentWidth:o,contentHeight:s,cellAutoHeight:h+Ke*2,calcAutoWidth:v+i}}const Sn=8;class _n extends A.Shape{static drawWith(t,n){const{fontString:a,info:i,fill:o,color:s}=n,{layout:d,text:l}=i;t.save(),A.Rect.drawWith(t,{width:d.width,height:d.height,radius:Sn,fill:o||Re}),t.translateWithPrecision(Ft,d.ba),t.font=a,t.fillStyle=s,t.fillText(l,0,0),t.restore()}}var In=Object.getOwnPropertyDescriptor,Cn=(e,t,n,a)=>{for(var i=a>1?void 0:a?In(t,n):t,o=e.length-1,s;o>=0;o--)(s=e[o])&&(i=s(i)||i);return i},Ne=(e,t)=>(n,a)=>t(n,a,e);const Vn=new Path2D("M3.32201 4.84556C3.14417 5.05148 2.85583 5.05148 2.67799 4.84556L0.134292 1.90016C-0.152586 1.56798 0.0505937 1 0.456301 1L5.5437 1C5.94941 1 6.15259 1.56798 5.86571 1.90016L3.32201 4.84556Z");let ut=class{constructor(e,t,n,a){L(this,"zIndex");L(this,"_dropdownInfoMap",new Map);this._commandService=e,this._univerInstanceService=t,this._renderManagerService=n,this._dataValidationModel=a}_ensureMap(e){let t=this._dropdownInfoMap.get(e);return t||(t=new Map,this._dropdownInfoMap.set(e,t)),t}_generateKey(e,t){return`${e}.${t}`}_drawDownIcon(e,t,n,a,i){const o=n-fe+4;let s=4;switch(i){case r.VerticalAlign.MIDDLE:s=(a-fe)/2+4;break;case r.VerticalAlign.BOTTOM:s=a-fe+4;break}e.save(),e.translateWithPrecision(t.startX+o,t.startY+s),e.fillStyle="#565656",e.fill(Vn),e.restore()}drawWith(e,t,n,a){var J,q;const{primaryWithCoord:i,row:o,col:s,style:d,data:l,subUnitId:c}=t,h=i.isMergedMainCell?i.mergeInfo:i,v=l==null?void 0:l.fontRenderExtension,{leftOffset:u=0,rightOffset:I=0,topOffset:g=0,downOffset:O=0}=v||{},R=this._ensureMap(c),p=this._generateKey(o,s),f=this._dataValidationModel.getRuleByLocation(t.unitId,t.subUnitId,o,s);if(!f)return;const C=this._dataValidationModel.getValidator(f.type);if(!C)return;const M={startX:h.startX+u,endX:h.endX-I,startY:h.startY+g,endY:h.endY-O},w=M.endX-M.startX,V=M.endY-M.startY,{cl:D}=d||{},T=(J=typeof D=="object"?D==null?void 0:D.rgb:D)!=null?J:"#000",x=A.getFontStyleString(d!=null?d:void 0),{vt:H,ht:F}=d||{},U=H!=null?H:r.VerticalAlign.MIDDLE,B=(q=S.getCellValueOrigin(l))!=null?q:"",j=C.parseCellValue(B),Y=C.getListWithColorMap(f),X=nt(j,x,w,V);this._drawDownIcon(e,M,w,V,U),e.save(),e.translateWithPrecision(M.startX,M.startY),e.beginPath(),e.rect(0,0,w-fe,V),e.clip(),e.translateWithPrecision(ct,Ke);let G=0;switch(U){case r.VerticalAlign.MIDDLE:G=(X.contentHeight-X.totalHeight)/2;break;case r.VerticalAlign.BOTTOM:G=X.contentHeight-X.totalHeight;break}e.translateWithPrecision(0,G),X.lines.forEach((te,le)=>{e.save();const{width:oe,height:ae,items:re}=te;let ge=0;switch(F){case r.HorizontalAlign.RIGHT:ge=X.contentWidth-oe;break;case r.HorizontalAlign.CENTER:ge=(X.contentWidth-oe)/2;break}e.translate(ge,le*(ae+Ut)),re.forEach(de=>{e.save(),e.translateWithPrecision(de.left,0),_n.drawWith(e,{...x,info:de,color:T,fill:Y[de.text]}),e.restore()}),e.restore()}),e.restore(),R.set(p,{left:M.startX,top:M.startY,width:X.contentWidth+ct+fe,height:X.contentHeight+Ke*2})}calcCellAutoHeight(e){var w;const{primaryWithCoord:t,style:n,data:a,row:i,col:o}=e,s=a==null?void 0:a.fontRenderExtension,{leftOffset:d=0,rightOffset:l=0,topOffset:c=0,downOffset:h=0}=s||{},v=t.isMergedMainCell?t.mergeInfo:t,u={startX:v.startX+d,endX:v.endX-l,startY:v.startY+c,endY:v.endY-h},I=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,i,o);if(!I)return;const g=this._dataValidationModel.getValidator(I.type);if(!g)return;const O=u.endX-u.startX,R=u.endY-u.startY,p=(w=S.getCellValueOrigin(a))!=null?w:"",f=g.parseCellValue(p),C=A.getFontStyleString(n!=null?n:void 0);return nt(f,C,O,R).cellAutoHeight}calcCellAutoWidth(e){var w;const{primaryWithCoord:t,style:n,data:a,row:i,col:o}=e,s=a==null?void 0:a.fontRenderExtension,{leftOffset:d=0,rightOffset:l=0,topOffset:c=0,downOffset:h=0}=s||{},v=t.isMergedMainCell?t.mergeInfo:t,u={startX:v.startX+d,endX:v.endX-l,startY:v.startY+c,endY:v.endY-h},I=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,i,o);if(!I)return;const g=this._dataValidationModel.getValidator(I.type);if(!g)return;const O=u.endX-u.startX,R=u.endY-u.startY,p=(w=S.getCellValueOrigin(a))!=null?w:"",f=g.parseCellValue(p),C=A.getFontStyleString(n!=null?n:void 0);return nt(f,C,O,R).calcAutoWidth}isHit(e,t){const{primaryWithCoord:n}=t,a=n.isMergedMainCell?n.mergeInfo:n,{endX:i}=a,{x:o}=e;return o>=i-fe&&o<=i}onPointerDown(e,t){if(t.button===2)return;const{unitId:n,subUnitId:a,row:i,col:o}=e,s={unitId:n,subUnitId:a,row:i,column:o};this._commandService.executeCommand(Ge.id,s)}onPointerEnter(e,t){var n,a;return(a=(n=A.getCurrentTypeOfRenderer(r.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null?void 0:n.mainComponent)==null?void 0:a.setCursor(A.CURSOR_TYPE.POINTER)}onPointerLeave(e,t){var n,a;return(a=(n=A.getCurrentTypeOfRenderer(r.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null?void 0:n.mainComponent)==null?void 0:a.setCursor(A.CURSOR_TYPE.DEFAULT)}};ut=Cn([Ne(0,r.ICommandService),Ne(1,r.IUniverInstanceService),Ne(2,r.Inject(A.IRenderManagerService)),Ne(3,r.Inject(S.SheetDataValidationModel))],ut);class Dn extends exports.BaseSheetDataValidatorView{constructor(){super(...arguments);L(this,"id",r.DataValidationType.LIST_MULTIPLE);L(this,"canvasRender",this.injector.createInstance(ut));L(this,"dropdownType",$.DataValidatorDropdownType.MULTIPLE_LIST)}}var yn=Object.getOwnPropertyDescriptor,Rn=(e,t,n,a)=>{for(var i=a>1?void 0:a?yn(t,n):t,o=e.length-1,s;o>=0;o--)(s=e[o])&&(i=s(i)||i);return i},Ae=(e,t)=>(n,a)=>t(n,a,e);const ve=4,ke=4,se=14,ue=6,we=4,it=8,wn="#565656",Ct=new Path2D("M3.32201 4.84556C3.14417 5.05148 2.85583 5.05148 2.67799 4.84556L0.134292 1.90016C-0.152586 1.56798 0.0505937 1 0.456301 1L5.5437 1C5.94941 1 6.15259 1.56798 5.86571 1.90016L3.32201 4.84556Z");function En(e,t){const n=e.length;return{id:"d",body:{dataStream:`${e}${r.DEFAULT_EMPTY_DOCUMENT_VALUE}`,textRuns:[{ts:{fs:11,ff:void 0,it:r.BooleanNumber.FALSE,bl:r.BooleanNumber.FALSE,ul:{s:r.BooleanNumber.FALSE},st:{s:r.BooleanNumber.FALSE},ol:{s:r.BooleanNumber.FALSE},cl:void 0,...t,bg:void 0,bd:void 0},st:0,ed:n}]},documentStyle:{pageSize:{width:Number.POSITIVE_INFINITY,height:Number.POSITIVE_INFINITY}}}}function Nt(e,t,n){const a=En(e,n),i=new r.DocumentDataModel(a),o=new A.DocumentViewModel(i);return{documentSkeleton:A.DocumentSkeleton.create(o,t),docModel:i,docViewModel:o}}function xe(e,t,n){const{documentSkeleton:a,docModel:i,docViewModel:o}=Nt(e,t,n);return{documents:new A.Documents(`DOCUMENTS_${r.Tools.generateRandomId()}`,a,{pageMarginLeft:0,pageMarginTop:0}),documentSkeleton:a,docModel:i,docViewModel:o}}function Vt(e,t,n,a,i,o,s=!0){let d=0;const l=s?we:0;switch(i){case r.VerticalAlign.BOTTOM:d=t-a-l;break;case r.VerticalAlign.MIDDLE:d=(t-a)/2;break;default:d=l;break}d=Math.max(we,d);let c=0;switch(o){case r.HorizontalAlign.CENTER:c=(e-n)/2;break;case r.HorizontalAlign.RIGHT:c=e-n;break}return c=Math.max(ue,c),{paddingLeft:c,paddingTop:d}}let ht=class{constructor(e,t,n,a,i){L(this,"_dropdownInfoMap",new Map);L(this,"zIndex");this._univerInstanceService=e,this._localeService=t,this._commandService=n,this._renderManagerService=a,this._dataValidationModel=i}_ensureMap(e){let t=this._dropdownInfoMap.get(e);return t||(t=new Map,this._dropdownInfoMap.set(e,t)),t}_generateKey(e,t){return`${e}.${t}`}_drawDownIcon(e,t,n,a,i,o,s){const{t:d=r.DEFAULT_STYLES.pd.t,b:l=r.DEFAULT_STYLES.pd.b}=s,c=n-se;let h;switch(o){case r.VerticalAlign.MIDDLE:h=(a-ke)/2;break;case r.VerticalAlign.BOTTOM:h=a-l-i-we+(i/2-ke/2);break;default:h=d+we+(i/2-ke/2);break}e.save(),e.translateWithPrecision(t.startX+c,t.startY+h),e.fillStyle="#565656",e.fill(Ct),e.restore()}drawWith(e,t,n){const{primaryWithCoord:a,row:i,col:o,style:s,data:d,subUnitId:l}=t,c=a.isMergedMainCell?a.mergeInfo:a,h=this._dataValidationModel.getRuleByLocation(t.unitId,t.subUnitId,i,o);if(!h)return;const v=this._dataValidationModel.getValidator(h.type);if(!v)return;const u=d==null?void 0:d.fontRenderExtension,{leftOffset:I=0,rightOffset:g=0,topOffset:O=0,downOffset:R=0}=u||{};if(!h||!v||!v||v.id.indexOf(r.DataValidationType.LIST)!==0||!v.skipDefaultFontRender(h))return;const p={startX:c.startX+I,endX:c.endX-g,startY:c.startY+O,endY:c.endY-R},f=p.endX-p.startX,C=p.endY-p.startY,M=this._ensureMap(l),w=this._generateKey(i,o),V=v.getListWithColor(h),D=S.getCellValueOrigin(d),T=`${D!=null?D:""}`,x=V.find(j=>j.label===T);let{tb:H,vt:F,ht:U,pd:B}=s||{};if(H=H!=null?H:r.WrapStrategy.WRAP,F=F!=null?F:r.VerticalAlign.BOTTOM,U=U!=null?U:r.DEFAULT_STYLES.ht,B=B!=null?B:r.DEFAULT_STYLES.pd,h.renderMode===r.DataValidationRenderMode.ARROW){const{l:j=r.DEFAULT_STYLES.pd.l,t:Y=r.DEFAULT_STYLES.pd.t,r:X=r.DEFAULT_STYLES.pd.r,b:G=r.DEFAULT_STYLES.pd.b}=B,J=f-j-X-se-4,{documentSkeleton:q,documents:te,docModel:le}=xe(T,this._localeService,s);H===r.WrapStrategy.WRAP&&le.updateDocumentDataPageSize(Math.max(J,1)),q.calculate(),q.getActualSize();const oe=A.getDocsSkeletonPageSize(q),{height:ae,width:re}=oe,{paddingTop:ge,paddingLeft:de}=Vt(J,C-Y-G,re,ae,F,U,!0);this._drawDownIcon(e,p,f,C,ae,F,B),e.save(),e.translateWithPrecision(p.startX+j,p.startY+Y),e.beginPath(),e.rect(0,0,f-j-X,C-Y-G),e.clip(),e.translateWithPrecision(0,ge),e.save(),e.translateWithPrecision(ve,0),e.beginPath(),e.rect(0,0,J,ae),e.clip(),te.render(e),e.translateWithPrecision(de,0),e.restore(),e.restore(),M.set(w,{left:p.endX+j+n.rowHeaderWidth-se,top:p.startY+Y+n.columnHeaderHeight,width:se,height:C-Y-G})}else{e.save(),e.translateWithPrecision(p.startX,p.startY),e.beginPath(),e.rect(0,0,f,C),e.clip();const j=f-ue*2-ve-se-4,{documentSkeleton:Y,documents:X,docModel:G}=xe(T,this._localeService,s);H===r.WrapStrategy.WRAP&&G.updateDocumentDataPageSize(Math.max(j,1)),Y.calculate();const J=A.getDocsSkeletonPageSize(Y),{height:q,width:te}=J,{paddingTop:le,paddingLeft:oe}=Vt(j,C,te,q,F,U);e.translateWithPrecision(ue,le);const ae=Math.max(f-ue*2,1),re=q;A.Rect.drawWith(e,{width:ae,height:re,fill:(x==null?void 0:x.color)||Re,radius:it}),e.save(),e.translateWithPrecision(ve,0),e.beginPath(),e.rect(0,0,j,q),e.clip(),e.translateWithPrecision(oe,0),X.render(e),e.restore(),e.translateWithPrecision(j+ve+4,(q-ke)/2),e.fillStyle=wn,e.fill(Ct),e.restore(),M.set(w,{left:p.startX+ue+n.rowHeaderWidth,top:p.startY+le+n.columnHeaderHeight,width:ae,height:re})}}calcCellAutoHeight(e){const{primaryWithCoord:t,style:n,data:a,row:i,col:o}=e,s=t.isMergedMainCell?t.mergeInfo:t,d=a==null?void 0:a.fontRenderExtension,{leftOffset:l=0,rightOffset:c=0,topOffset:h=0,downOffset:v=0}=d||{},u=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,i,o);if(!u||u.renderMode===r.DataValidationRenderMode.TEXT)return;const I={startX:s.startX+l,endX:s.endX-c,startY:s.startY+h,endY:s.endY-v},g=I.endX-I.startX,O=S.getCellValueOrigin(a),R=`${O!=null?O:""}`;let{tb:p,pd:f}=n||{};const{t:C=r.DEFAULT_STYLES.pd.t,b:M=r.DEFAULT_STYLES.pd.b}=f!=null?f:{};if(p=p!=null?p:r.WrapStrategy.WRAP,u.renderMode===r.DataValidationRenderMode.ARROW){const w=g-se,{documentSkeleton:V,docModel:D}=xe(R,this._localeService,n);p===r.WrapStrategy.WRAP&&D.updateDocumentDataPageSize(Math.max(w,1)),V.calculate(),V.getActualSize();const T=A.getDocsSkeletonPageSize(V),{height:x}=T;return x+C+M+we*2}else{const w=g-ue*2-ve-se,{documentSkeleton:V,docModel:D}=Nt(R,this._localeService,n);p===r.WrapStrategy.WRAP&&D.updateDocumentDataPageSize(Math.max(w,1)),V.calculate();const T=A.getDocsSkeletonPageSize(V),{height:x}=T;return x+we*2}}calcCellAutoWidth(e){const{primaryWithCoord:t,style:n,data:a,row:i,col:o}=e,s=t.isMergedMainCell?t.mergeInfo:t,d=a==null?void 0:a.fontRenderExtension,{leftOffset:l=0,rightOffset:c=0,topOffset:h=0,downOffset:v=0}=d||{},u=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,i,o);if(!u||u.renderMode===r.DataValidationRenderMode.TEXT)return;const I={startX:s.startX+l,endX:s.endX-c,startY:s.startY+h,endY:s.endY-v},g=I.endX-I.startX,O=S.getCellValueOrigin(a),R=`${O!=null?O:""}`;let{tb:p,pd:f}=n||{};const{l:C=r.DEFAULT_STYLES.pd.l,r:M=r.DEFAULT_STYLES.pd.r}=f!=null?f:{};p=p!=null?p:r.WrapStrategy.WRAP;let w=ue*2+se;switch(u.renderMode){case r.DataValidationRenderMode.ARROW:w=se+ue*2+M+C;break;case r.DataValidationRenderMode.CUSTOM:w=se+ue*2+ve*2+M+C+it/2+1;break;default:w=se+ue*2+ve*2+M+C+it/2+1}const V=g-w,{documentSkeleton:D,docModel:T}=xe(R,this._localeService,n);return p===r.WrapStrategy.WRAP&&T.updateDocumentDataPageSize(Math.max(V,1)),D.calculate(),D.getActualSize(),A.getDocsSkeletonPageSize(D).width+w}isHit(e,t){const{subUnitId:n,row:a,col:i}=t,s=this._ensureMap(n).get(this._generateKey(a,i)),d=this._dataValidationModel.getRuleByLocation(t.unitId,t.subUnitId,a,i);if(!d||!s||d.renderMode===r.DataValidationRenderMode.TEXT)return!1;const{top:l,left:c,width:h,height:v}=s,{x:u,y:I}=e;return u>=c&&u<=c+h&&I>=l&&I<=l+v}onPointerDown(e,t){if(t.button===2)return;const{unitId:n,subUnitId:a,row:i,col:o}=e,s={unitId:n,subUnitId:a,row:i,column:o};this._commandService.executeCommand(Ge.id,s)}onPointerEnter(e,t){var n,a;(a=(n=A.getCurrentTypeOfRenderer(r.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null?void 0:n.mainComponent)==null||a.setCursor(A.CURSOR_TYPE.POINTER)}onPointerLeave(e,t){var n,a;(a=(n=A.getCurrentTypeOfRenderer(r.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null?void 0:n.mainComponent)==null||a.setCursor(A.CURSOR_TYPE.DEFAULT)}};ht=Rn([Ae(0,r.IUniverInstanceService),Ae(1,r.Inject(r.LocaleService)),Ae(2,r.ICommandService),Ae(3,r.Inject(A.IRenderManagerService)),Ae(4,r.Inject(S.SheetDataValidationModel))],ht);class Mn extends exports.BaseSheetDataValidatorView{constructor(){super(...arguments);L(this,"id",r.DataValidationType.LIST);L(this,"canvasRender",this.injector.createInstance(ht));L(this,"dropdownType",$.DataValidatorDropdownType.LIST);L(this,"optionsInput",Xe.componentKey);L(this,"formulaInput",S.LIST_FORMULA_INPUT_NAME)}}class Tn extends exports.BaseSheetDataValidatorView{constructor(){super(...arguments);L(this,"id",r.DataValidationType.TEXT_LENGTH);L(this,"formulaInput",S.BASE_FORMULA_INPUT_NAME)}}class bn extends exports.BaseSheetDataValidatorView{constructor(){super(...arguments);L(this,"id",r.DataValidationType.WHOLE);L(this,"formulaInput",S.BASE_FORMULA_INPUT_NAME)}}var On=Object.getOwnPropertyDescriptor,Ln=(e,t,n,a)=>{for(var i=a>1?void 0:a?On(t,n):t,o=e.length-1,s;o>=0;o--)(s=e[o])&&(i=s(i)||i);return i},ot=(e,t)=>(n,a)=>t(n,a,e);let Le=class extends r.RxDisposable{constructor(e,t,n){super(),this._injector=e,this._componentManger=t,this._dataValidatorRegistryService=n,this._initComponents(),this._registerValidatorViews()}_initComponents(){[[Lt,yt],[We,rn],[Xe.componentKey,Xe],[ze.componentKey,ze],...pa].forEach(([e,t])=>{this.disposeWithMe(this._componentManger.register(e,t))})}_registerValidatorViews(){[mn,bn,Tn,pn,un,Mn,Dn,hn].forEach(e=>{const t=this._injector.createInstance(e),n=this._dataValidatorRegistryService.getValidatorItem(t.id);n&&(n.formulaInput=t.formulaInput,n.canvasRender=t.canvasRender,n.dropdownType=t.dropdownType,n.optionsInput=t.optionsInput)})}};Le=Ln([ot(0,r.Inject(r.Injector)),ot(1,r.Inject(y.ComponentManager)),ot(2,r.Inject($.DataValidatorRegistryService))],Le);var An=Object.getOwnPropertyDescriptor,Pn=(e,t,n,a)=>{for(var i=a>1?void 0:a?An(t,n):t,o=e.length-1,s;o>=0;o--)(s=e[o])&&(i=s(i)||i);return i},rt=(e,t)=>(n,a)=>t(n,a,e);const jn="SHEET_DATA_VALIDATION_UI_PLUGIN";var Be;exports.UniverSheetsDataValidationUIPlugin=(Be=class extends r.Plugin{constructor(t=$e,n,a,i){super(),this._config=t,this._injector=n,this._commandService=a,this._configService=i;const{menu:o,...s}=r.merge({},$e,this._config);o&&this._configService.setConfig("menu",o,{merge:!0}),this._configService.setConfig(Ot,s)}onStarting(){[[he],[Se],[Pe],[Me],[Oe],[be],[Te],[Ee],[Le]].forEach(t=>{this._injector.add(t)}),[qe,Ge,bt,mt,Ie,Tt].forEach(t=>{this._commandService.registerCommand(t)})}onReady(){this._injector.get(Te),this._injector.get(be),this._injector.get(Ee),this._injector.get(Pe),this._injector.get(A.IRenderManagerService).registerRenderModule(r.UniverInstanceType.UNIVER_SHEET,[Ye])}onRendered(){this._injector.get(Le),this._injector.get(Oe)}onSteady(){this._injector.get(Me)}},L(Be,"pluginName",jn),L(Be,"type",r.UniverInstanceType.UNIVER_SHEET),Be);exports.UniverSheetsDataValidationUIPlugin=Pn([rt(1,r.Inject(r.Injector)),rt(2,r.ICommandService),rt(3,r.IConfigService)],exports.UniverSheetsDataValidationUIPlugin);var Fn=Object.getOwnPropertyDescriptor,Un=(e,t,n,a)=>{for(var i=a>1?void 0:a?Fn(t,n):t,o=e.length-1,s;o>=0;o--)(s=e[o])&&(i=s(i)||i);return i},st=(e,t)=>(n,a)=>t(n,a,e);const Nn="SHEET_DATA_VALIDATION_UI_PLUGIN";var He;exports.UniverSheetsDataValidationMobileUIPlugin=(He=class extends r.Plugin{constructor(t=$e,n,a,i){super(),this._config=t,this._injector=n,this._commandService=a,this._configService=i;const{menu:o,...s}=r.merge({},$e,this._config);o&&this._configService.setConfig("menu",o,{merge:!0}),this._configService.setConfig(Ot,s)}onStarting(){[[he],[Se],[Pe],[Me],[Oe],[be],[Te],[Le]].forEach(t=>{this._injector.add(t)}),[qe,Ge,bt,mt,Ie,Tt].forEach(t=>{this._commandService.registerCommand(t)})}onReady(){this._injector.get(Te),this._injector.get(be),this._injector.get(A.IRenderManagerService).registerRenderModule(r.UniverInstanceType.UNIVER_SHEET,[Ye])}onRendered(){this._injector.get(Le),this._injector.get(Oe)}onSteady(){this._injector.get(Me)}},L(He,"pluginName",Nn),L(He,"type",r.UniverInstanceType.UNIVER_SHEET),He);exports.UniverSheetsDataValidationMobileUIPlugin=Un([st(1,r.Inject(r.Injector)),st(2,r.ICommandService),st(3,r.IConfigService)],exports.UniverSheetsDataValidationMobileUIPlugin);