@univerjs/sheets-data-validation-ui 0.8.0-nightly.202506041607 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +176 -0
- package/lib/cjs/index.js +1 -1
- package/lib/es/index.js +282 -277
- package/lib/index.js +282 -277
- package/lib/umd/index.js +1 -1
- package/package.json +13 -13
package/LICENSE
ADDED
@@ -0,0 +1,176 @@
|
|
1
|
+
Apache License
|
2
|
+
Version 2.0, January 2004
|
3
|
+
http://www.apache.org/licenses/
|
4
|
+
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
6
|
+
|
7
|
+
1. Definitions.
|
8
|
+
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
11
|
+
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
13
|
+
the copyright owner that is granting the License.
|
14
|
+
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
16
|
+
other entities that control, are controlled by, or are under common
|
17
|
+
control with that entity. For the purposes of this definition,
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
19
|
+
direction or management of such entity, whether by contract or
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
22
|
+
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
24
|
+
exercising permissions granted by this License.
|
25
|
+
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
27
|
+
including but not limited to software source code, documentation
|
28
|
+
source, and configuration files.
|
29
|
+
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
31
|
+
transformation or translation of a Source form, including but
|
32
|
+
not limited to compiled object code, generated documentation,
|
33
|
+
and conversions to other media types.
|
34
|
+
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
36
|
+
Object form, made available under the License, as indicated by a
|
37
|
+
copyright notice that is included in or attached to the work
|
38
|
+
(an example is provided in the Appendix below).
|
39
|
+
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
46
|
+
the Work and Derivative Works thereof.
|
47
|
+
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
49
|
+
the original version of the Work and any modifications or additions
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
61
|
+
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
64
|
+
subsequently incorporated within the Work.
|
65
|
+
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
72
|
+
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
78
|
+
where such license applies only to those patent claims licensable
|
79
|
+
by such Contributor that are necessarily infringed by their
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
82
|
+
institute patent litigation against any entity (including a
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
85
|
+
or contributory patent infringement, then any patent licenses
|
86
|
+
granted to You under this License for that Work shall terminate
|
87
|
+
as of the date such litigation is filed.
|
88
|
+
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
91
|
+
modifications, and in Source or Object form, provided that You
|
92
|
+
meet the following conditions:
|
93
|
+
|
94
|
+
(a) You must give any other recipients of the Work or
|
95
|
+
Derivative Works a copy of this License; and
|
96
|
+
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
98
|
+
stating that You changed the files; and
|
99
|
+
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
102
|
+
attribution notices from the Source form of the Work,
|
103
|
+
excluding those notices that do not pertain to any part of
|
104
|
+
the Derivative Works; and
|
105
|
+
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
108
|
+
include a readable copy of the attribution notices contained
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
111
|
+
of the following places: within a NOTICE text file distributed
|
112
|
+
as part of the Derivative Works; within the Source form or
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
114
|
+
within a display generated by the Derivative Works, if and
|
115
|
+
wherever such third-party notices normally appear. The contents
|
116
|
+
of the NOTICE file are for informational purposes only and
|
117
|
+
do not modify the License. You may add Your own attribution
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
120
|
+
that such additional attribution notices cannot be construed
|
121
|
+
as modifying the License.
|
122
|
+
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
124
|
+
may provide additional or different license terms and conditions
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
128
|
+
the conditions stated in this License.
|
129
|
+
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
133
|
+
this License, without any additional terms or conditions.
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
135
|
+
the terms of any separate license agreement you may have executed
|
136
|
+
with Licensor regarding such Contributions.
|
137
|
+
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
140
|
+
except as required for reasonable and customary use in describing the
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
142
|
+
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
152
|
+
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
158
|
+
incidental, or consequential damages of any character arising as a
|
159
|
+
result of this License or out of the use or inability to use the
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
162
|
+
other commercial damages or losses), even if such Contributor
|
163
|
+
has been advised of the possibility of such damages.
|
164
|
+
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
168
|
+
or other liability obligations and/or rights consistent with this
|
169
|
+
License. However, in accepting such obligations, You may act only
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
174
|
+
of your accepting any such warranty or additional liability.
|
175
|
+
|
176
|
+
END OF TERMS AND CONDITIONS
|
package/lib/cjs/index.js
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
"use strict";var Lt=Object.defineProperty;var Pt=(e,t,a)=>t in e?Lt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a;var A=(e,t,a)=>Pt(e,typeof t!="symbol"?t+"":t,a);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("@univerjs/core"),C=require("@univerjs/sheets-data-validation"),p=require("react/jsx-runtime"),V=require("@univerjs/design"),E=require("@univerjs/ui"),b=require("react"),st=require("@univerjs/sheets-formula-ui"),Y=require("@univerjs/data-validation"),oe=require("rxjs"),P=require("@univerjs/engine-render"),H=require("@univerjs/sheets"),jt=require("@univerjs/sheets-numfmt"),N=require("@univerjs/sheets-ui"),nt=require("@univerjs/engine-formula"),xt=e=>{const{isTwoFormula:t=!1,value:a,onChange:n,showError:r,validResult:i}=e,s=E.useDependency(o.LocaleService),d=r?i==null?void 0:i.formula1:"",l=r?i==null?void 0:i.formula2:"";return t?p.jsxs(p.Fragment,{children:[p.jsx(V.FormLayout,{error:d,children:p.jsx(V.Input,{className:"univer-w-full",placeholder:s.t("dataValidation.panel.formulaPlaceholder"),value:a==null?void 0:a.formula1,onChange:c=>{n==null||n({...a,formula1:c})}})}),p.jsx("div",{className:"-univer-mt-2 univer-mb-1 univer-text-sm univer-text-gray-400",children:s.t("dataValidation.panel.formulaAnd")}),p.jsx(V.FormLayout,{error:l,children:p.jsx(V.Input,{className:"univer-w-full",placeholder:s.t("dataValidation.panel.formulaPlaceholder"),value:a==null?void 0:a.formula2,onChange:c=>{n==null||n({...a,formula2:c})}})})]}):p.jsx(V.FormLayout,{error:d,children:p.jsx(V.Input,{className:"univer-w-full",placeholder:s.t("dataValidation.panel.formulaPlaceholder"),value:a==null?void 0:a.formula1,onChange:c=>{n==null||n({formula1:c})}})})};function Ut(e){const{value:t,onChange:a,showError:n,validResult:r}=e,i=E.useDependency(o.LocaleService),s=n?r==null?void 0:r.formula1:"",d=n?r==null?void 0:r.formula2:"",[l,c]=b.useState(!((t==null?void 0:t.formula1)===void 0&&(t==null?void 0:t.formula2)===void 0));return p.jsxs(p.Fragment,{children:[p.jsx(V.FormLayout,{children:p.jsx(V.Checkbox,{checked:l,onChange:h=>{h?c(!0):(c(!1),a==null||a({...t,formula1:void 0,formula2:void 0}))},children:i.t("dataValidation.checkbox.tips")})}),l?p.jsx(V.FormLayout,{label:i.t("dataValidation.checkbox.checked"),error:s,children:p.jsx(V.Input,{className:"univer-w-full",placeholder:i.t("dataValidation.panel.valuePlaceholder"),value:t==null?void 0:t.formula1,onChange:h=>{a==null||a({...t,formula1:h||void 0})}})}):null,l?p.jsx(V.FormLayout,{label:i.t("dataValidation.checkbox.unchecked"),error:d,children:p.jsx(V.Input,{className:"univer-w-full",placeholder:i.t("dataValidation.panel.valuePlaceholder"),value:t==null?void 0:t.formula2,onChange:h=>{a==null||a({...t,formula2:h||void 0})}})}):null]})}function kt(e){var g;const{unitId:t,subUnitId:a,value:n,onChange:r,showError:i,validResult:s}=e,d=i?s==null?void 0:s.formula1:void 0,l=b.useRef(null),[c,h]=b.useState(!1);return E.useSidebarClick(u=>{var v;((v=l.current)==null?void 0:v.isClickOutSide(u))&&h(!1)}),p.jsx(V.FormLayout,{error:d,children:p.jsx(st.FormulaEditor,{ref:l,className:V.clsx("univer-box-border univer-h-8 univer-w-full univer-cursor-pointer univer-items-center univer-rounded-lg univer-bg-white univer-pt-2 univer-transition-colors [&>div:first-child]:univer-px-2.5 [&>div]:univer-h-5 [&>div]:univer-ring-transparent dark:!univer-bg-gray-700 dark:!univer-text-white hover:univer-border-primary-600",V.borderClassName),initValue:(g=n==null?void 0:n.formula1)!=null?g:"=",unitId:t,subUnitId:a,isFocus:c,isSupportAcrossSheet:!0,onChange:u=>{const _=(u!=null?u:"").trim();_!==(n==null?void 0:n.formula1)&&(r==null||r({...n,formula1:_}))},onFocus:()=>h(!0)})})}var ie=function(){return ie=Object.assign||function(e){for(var t,a=1,n=arguments.length;a<n;a++){t=arguments[a];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])}return e},ie.apply(this,arguments)},Ft=function(e,t){var a={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(a[n]=e[n]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,n=Object.getOwnPropertySymbols(e);r<n.length;r++)t.indexOf(n[r])<0&&Object.prototype.propertyIsEnumerable.call(e,n[r])&&(a[n[r]]=e[n[r]]);return a},Se=b.forwardRef(function(e,t){var a=e.icon,n=e.id,r=e.className,i=e.extend,s=Ft(e,["icon","id","className","extend"]),d="univerjs-icon univerjs-icon-".concat(n," ").concat(r||"").trim(),l=b.useRef("_".concat(Wt()));return It(a,"".concat(n),{defIds:a.defIds,idSuffix:l.current},ie({ref:t,className:d},s),i)});function It(e,t,a,n,r){return b.createElement(e.tag,ie(ie({key:t},Nt(e,a,r)),n),(Bt(e,a).children||[]).map(function(i,s){return It(i,"".concat(t,"-").concat(e.tag,"-").concat(s),a,void 0,r)}))}function Nt(e,t,a){var n=ie({},e.attrs);a!=null&&a.colorChannel1&&n.fill==="colorChannel1"&&(n.fill=a.colorChannel1),e.tag==="mask"&&n.id&&(n.id=n.id+t.idSuffix),Object.entries(n).forEach(function(i){var s=i[0],d=i[1];s==="mask"&&typeof d=="string"&&(n[s]=d.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))});var r=t.defIds;return!r||r.length===0||(e.tag==="use"&&n["xlink:href"]&&(n["xlink:href"]=n["xlink:href"]+t.idSuffix),Object.entries(n).forEach(function(i){var s=i[0],d=i[1];typeof d=="string"&&(n[s]=d.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))})),n}function Bt(e,t){var a,n=t.defIds;return!n||n.length===0?e:e.tag==="defs"&&(!((a=e.children)===null||a===void 0)&&a.length)?ie(ie({},e),{children:e.children.map(function(r){return typeof r.attrs.id=="string"&&n&&n.includes(r.attrs.id)?ie(ie({},r),{attrs:ie(ie({},r.attrs),{id:r.attrs.id+t.idSuffix})}):r})}):e}function Wt(){return Math.random().toString(36).substring(2,8)}Se.displayName="UniverIcon";var Ht={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 17 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"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.83062C8.94447 3.57605 9.32281 3.54166 9.57737 3.7538L11.154 5.06767L13.769 2.45278C14.0033 2.21847 14.3832 2.21848 14.6175 2.45279Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M14.1175 9.19746C14.3518 9.43178 14.3518 9.81168 14.1175 10.046L12.5418 11.6217L14.1175 13.1975C14.3518 13.4318 14.3518 13.8117 14.1175 14.046C13.8832 14.2803 13.5033 14.2803 13.269 14.046L11.6933 12.4703L10.1175 14.046C9.88321 14.2803 9.50331 14.2803 9.269 14.046C9.03468 13.8117 9.03468 13.4318 9.269 13.1975L10.8447 11.6217L9.269 10.046C9.03468 9.81168 9.03468 9.43178 9.269 9.19746C9.50331 8.96315 9.88321 8.96315 10.1175 9.19746L11.6933 10.7732L13.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"}}]},Ct=b.forwardRef(function(e,t){return b.createElement(Se,Object.assign({},e,{id:"data-validation-icon",ref:t,icon:Ht}))});Ct.displayName="DataValidationIcon";var $t={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M5.3313 1.4667C5.3313 1.13533 5.59993 0.866699 5.9313 0.866699H10.069C10.4004 0.866699 10.669 1.13533 10.669 1.4667C10.669 1.79807 10.4004 2.0667 10.069 2.0667H5.9313C5.59993 2.0667 5.3313 1.79807 5.3313 1.4667Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M1.09985 3.64443C1.09985 3.31306 1.36848 3.04443 1.69985 3.04443H14.2999C14.6312 3.04443 14.8999 3.31306 14.8999 3.64443C14.8999 3.9758 14.6312 4.24443 14.2999 4.24443H1.69985C1.36848 4.24443 1.09985 3.9758 1.09985 3.64443Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M6.12398 8.30171C6.35829 8.0674 6.73819 8.0674 6.97251 8.30171L8.00007 9.32928L9.02764 8.30171C9.26195 8.0674 9.64185 8.0674 9.87617 8.30171C10.1105 8.53603 10.1105 8.91593 9.87617 9.15024L8.8486 10.1778L9.87617 11.2054C10.1105 11.4397 10.1105 11.8196 9.87617 12.0539C9.64185 12.2882 9.26195 12.2882 9.02764 12.0539L8.00007 11.0263L6.97251 12.0539C6.73819 12.2882 6.35829 12.2882 6.12398 12.0539C5.88966 11.8196 5.88966 11.4397 6.12398 11.2054L7.15154 10.1778L6.12398 9.15024C5.88966 8.91593 5.88966 8.53603 6.12398 8.30171Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M4.75332 5.22217C3.86966 5.22217 3.15332 5.93851 3.15332 6.82217V12.5331C3.15332 13.9691 4.31738 15.1332 5.75332 15.1332H10.2465C11.6825 15.1332 12.8465 13.9691 12.8465 12.5331V6.82217C12.8465 5.93851 12.1302 5.22217 11.2465 5.22217H4.75332ZM4.35332 6.82217C4.35332 6.60125 4.53241 6.42217 4.75332 6.42217H11.2465C11.4674 6.42217 11.6465 6.60125 11.6465 6.82217V12.5331C11.6465 13.3063 11.0197 13.9332 10.2465 13.9332H5.75332C4.98012 13.9332 4.35332 13.3063 4.35332 12.5331V6.82217Z",fillRule:"evenodd",clipRule:"evenodd"}}]},lt=b.forwardRef(function(e,t){return b.createElement(Se,Object.assign({},e,{id:"delete-icon",ref:t,icon:$t}))});lt.displayName="DeleteIcon";var Yt={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M8.6 1.99991C8.60001 1.66854 8.33138 1.39991 8.00001 1.3999C7.66864 1.3999 7.40001 1.66853 7.4 1.9999L7.39996 7.3999H1.9999C1.66853 7.3999 1.3999 7.66853 1.3999 7.9999C1.3999 8.33127 1.66853 8.5999 1.9999 8.5999H7.39995L7.3999 13.9999C7.3999 14.3313 7.66853 14.5999 7.9999 14.5999C8.33127 14.5999 8.5999 14.3313 8.5999 13.9999L8.59995 8.5999H13.9999C14.3313 8.5999 14.5999 8.33127 14.5999 7.9999C14.5999 7.66853 14.3313 7.3999 13.9999 7.3999H8.59996L8.6 1.99991Z"}}]},yt=b.forwardRef(function(e,t){return b.createElement(Se,Object.assign({},e,{id:"increase-icon",ref:t,icon:Yt}))});yt.displayName="IncreaseIcon";var Xt={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M11.3536 6.14645C11.5488 6.34171 11.5488 6.65829 11.3536 6.85355L8.35355 9.85355C8.15829 10.0488 7.84171 10.0488 7.64645 9.85355L4.64645 6.85355C4.45118 6.65829 4.45118 6.34171 4.64645 6.14645C4.84171 5.95118 5.15829 5.95118 5.35355 6.14645L8 8.79289L10.6464 6.14645C10.8417 5.95118 11.1583 5.95118 11.3536 6.14645Z",fillRule:"evenodd",clipRule:"evenodd"}}]},dt=b.forwardRef(function(e,t){return b.createElement(Se,Object.assign({},e,{id:"more-down-icon",ref:t,icon:Xt}))});dt.displayName="MoreDownIcon";var zt={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M4.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"}}]},Rt=b.forwardRef(function(e,t){return b.createElement(Se,Object.assign({},e,{id:"more-up-icon",ref:t,icon:zt}))});Rt.displayName="MoreUpIcon";var Kt={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"mask",attrs:{id:"mask0_622_8",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 4C7 3.44772 6.55228 3 6 3C5.44772 3 5 3.44772 5 4C5 4.55228 5.44772 5 6 5Z"}},{tag:"path",attrs:{d:"M6 9C6.55228 9 7 8.55229 7 8C7 7.44772 6.55228 7 6 7C5.44772 7 5 7.44772 5 8C5 8.55229 5.44772 9 6 9Z"}},{tag:"path",attrs:{d:"M7 12C7 12.5523 6.55228 13 6 13C5.44772 13 5 12.5523 5 12C5 11.4477 5.44772 11 6 11C6.55228 11 7 11.4477 7 12Z"}},{tag:"path",attrs:{d:"M10 5C10.5523 5 11 4.55228 11 4C11 3.44772 10.5523 3 10 3C9.44771 3 9 3.44772 9 4C9 4.55228 9.44771 5 10 5Z"}},{tag:"path",attrs:{d:"M11 8C11 8.55229 10.5523 9 10 9C9.44771 9 9 8.55229 9 8C9 7.44772 9.44771 7 10 7C10.5523 7 11 7.44772 11 8Z"}},{tag:"path",attrs:{d:"M10 13C10.5523 13 11 12.5523 11 12C11 11.4477 10.5523 11 10 11C9.44771 11 9 11.4477 9 12C9 12.5523 9.44771 13 10 13Z"}}]}]},Dt=b.forwardRef(function(e,t){return b.createElement(Se,Object.assign({},e,{id:"sequence-icon",ref:t,icon:Kt}))});Dt.displayName="SequenceIcon";const Re="#ECECEC",Zt=["#FFFFFF","#FEE7E7","#FEF0E6","#EFFBD0","#E4F4FE","#E8ECFD","#F1EAFA","#FDE8F3","#E5E5E5","#FDCECE","#FDC49B","#DEF6A2","#9FDAFF","#D0D9FB","#E3D5F6","#FBD0E8","#656565","#FE4B4B","#FF8C51","#8BBB11","#0B9EFB","#3A60F7","#9E6DE3","#F248A6"],Gt=e=>{const{value:t,onChange:a,disabled:n}=e,[r,i]=b.useState(!1);return p.jsx(V.Dropdown,{align:"start",disabled:n,open:r,onOpenChange:i,overlay:p.jsx("div",{className:"univer-box-border univer-grid univer-w-fit univer-grid-cols-6 univer-flex-wrap univer-gap-2 univer-p-1.5",children:Zt.map(s=>p.jsx("div",{className:V.clsx("univer-box-border univer-size-4 univer-cursor-pointer univer-rounded",V.borderClassName),style:{background:s},onClick:()=>{a(s),i(!1)}},s))}),children:p.jsxs("div",{className:V.clsx("univer-box-border univer-inline-flex univer-h-8 univer-w-16 univer-cursor-pointer univer-items-center univer-justify-between univer-gap-2 univer-rounded-lg univer-bg-white univer-px-2.5 univer-transition-colors univer-duration-200 dark:!univer-bg-gray-700 dark:!univer-text-white hover:univer-border-primary-600",V.borderClassName),children:[p.jsx("div",{className:"univer-box-border univer-h-4 univer-w-4 univer-rounded univer-text-base",style:{background:t}}),p.jsx(dt,{})]})})},gt=e=>{const{item:t,commonProps:a,className:n}=e,{onItemChange:r,onItemDelete:i}=a;return p.jsxs("div",{className:V.clsx("univer-flex univer-items-center univer-gap-2",n),children:[!t.isRef&&p.jsx("div",{className:V.clsx("univer-cursor-move","draggableHandle"),children:p.jsx(Dt,{})}),p.jsx(Gt,{value:t.color,onChange:s=>{r(t.id,t.label,s)}}),p.jsx(V.Input,{disabled:t.isRef,value:t.label,onChange:s=>{r(t.id,s,t.color)}}),t.isRef?null:p.jsx("div",{className:"univer-ml-1 univer-cursor-pointer univer-rounded univer-text-base hover:univer-bg-gray-200",children:p.jsx(lt,{onClick:()=>i(t.id)})})]})};function qt(e){const{value:t,onChange:a=()=>{},unitId:n,subUnitId:r,validResult:i,showError:s,ruleId:d}=e,{formula1:l="",formula2:c=""}=t||{},[h,g]=b.useState(()=>o.isFormulaString(l)?"1":"0"),[u,_]=b.useState(h==="1"?l:"="),[v,T]=b.useState(h==="1"?l:"="),M=E.useDependency(o.LocaleService),m=E.useDependency(Y.DataValidatorRegistryService),y=E.useDependency(Y.DataValidationModel),f=E.useDependency(C.DataValidationFormulaController),[D,R]=b.useState(()=>c.split(",")),I=m.getValidatorItem(o.DataValidationType.LIST),[w,F]=b.useState([]),[W,O]=b.useState(""),x=s?i==null?void 0:i.formula1:"",j=b.useMemo(()=>y.ruleChange$.pipe(oe.debounceTime(16)),[]),U=E.useObservable(j),B=E.useEvent(a);b.useEffect(()=>{(async()=>{await new Promise(S=>{setTimeout(()=>S(!0),100)});const L=y.getRuleById(n,r,d),$=L==null?void 0:L.formula1;if(o.isFormulaString($)&&I&&L){const S=await I.getListAsync(L,n,r);F(S)}})()},[y,U,I,d,r,n]),b.useEffect(()=>{o.isFormulaString(l)&&l!==v&&(_(l),T(v))},[v,l]);const[K,z]=b.useState(()=>{const L=h!=="1"?C.deserializeListOptions(l):[],$=c.split(",");return L.map((S,k)=>({label:S,color:$[k]||Re,isRef:!1,id:o.Tools.generateRandomId(4)}))}),ee=(L,$,S)=>{const k=K.find(X=>X.id===L);k&&(k.label=$,k.color=S,z([...K]))},ae=L=>{const $=K.findIndex(S=>S.id===L);$!==-1&&(K.splice($,1),z([...K]))},re=c.split(","),se=b.useMemo(()=>w.map((L,$)=>({label:L,color:re[$]||Re,id:`${$}`,isRef:!0})),[re,w]),q=(L,$,S)=>{const k=[...D];k[+L]=S,R(k),B({formula1:l,formula2:k.join(",")})},Z=()=>{z([...K,{label:"",color:Re,isRef:!1,id:o.Tools.generateRandomId(4)}])};b.useEffect(()=>{if(h==="1")return;const L=new Set,$=[];K.map(S=>({labelList:S.label.split(","),item:S})).forEach(({item:S,labelList:k})=>{k.forEach(X=>{L.has(X)||(L.add(X),$.push({label:X,color:S.color}))})}),B({formula1:C.serializeListOptions($.map(S=>S.label)),formula2:$.map(S=>S.color===Re?"":S.color).join(",")})},[K,B,h,v,D]);const ce=E.useEvent(async L=>{if(!o.isFormulaString(L)){B==null||B({formula1:"",formula2:c});return}f.getFormulaRefCheck(L)?(B==null||B({formula1:o.isFormulaString(L)?L:"",formula2:c}),O("")):(B==null||B({formula1:"",formula2:c}),_("="),O(M.t("dataValidation.validFail.formulaError")))}),te=b.useRef(null),[Q,J]=b.useState(!1);return E.useSidebarClick(L=>{var S;((S=te.current)==null?void 0:S.isClickOutSide(L))&&J(!1)}),p.jsxs(p.Fragment,{children:[p.jsx(V.FormLayout,{label:M.t("dataValidation.list.options"),children:p.jsxs(V.RadioGroup,{value:h,onChange:L=>{g(L),_(v),L==="1"&&B({formula1:v==="="?"":v,formula2:D.join(",")})},children:[p.jsx(V.Radio,{value:"0",children:M.t("dataValidation.list.customOptions")}),p.jsx(V.Radio,{value:"1",children:M.t("dataValidation.list.refOptions")})]})}),h==="1"?p.jsxs(V.FormLayout,{error:x||W||void 0,children:[p.jsx(st.FormulaEditor,{ref:te,className:V.clsx("univer-box-border univer-h-8 univer-w-full univer-cursor-pointer univer-items-center univer-rounded-lg univer-bg-white univer-pt-2 univer-transition-colors [&>div:first-child]:univer-px-2.5 [&>div]:univer-h-5 [&>div]:univer-ring-transparent dark:!univer-bg-gray-700 dark:!univer-text-white hover:univer-border-primary-600",V.borderClassName),initValue:u,unitId:n,subUnitId:r,isFocus:Q,isSupportAcrossSheet:!0,onFocus:()=>J(!0),onChange:(L="")=>{const $=(L!=null?L:"").trim();T($),ce($)}}),se.length>0&&p.jsx("div",{className:"univer-mt-3",children:se.map(L=>p.jsx(gt,{className:"univer-mb-3",item:L,commonProps:{onItemChange:q}},L.id))})]}):p.jsx(V.FormLayout,{error:x,children:p.jsxs("div",{className:"-univer-mt-3",children:[p.jsx(V.DraggableList,{list:K,onListChange:z,rowHeight:28,margin:[0,12],draggableHandle:".draggableHandle",itemRender:L=>p.jsx(gt,{item:L,commonProps:{onItemChange:ee,onItemDelete:ae}},L.id),idKey:"id"}),p.jsxs("a",{className:"univer-flex univer-w-fit univer-cursor-pointer univer-flex-row univer-items-center univer-rounded univer-p-1 univer-px-2 univer-text-sm univer-text-primary dark:hover:!univer-bg-gray-800 hover:univer-bg-primary-50",onClick:Z,children:[p.jsx(yt,{className:"univer-mr-1"}),M.t("dataValidation.list.add")]})]})})]})}const Jt=[[C.CUSTOM_FORMULA_INPUT_NAME,kt],[C.BASE_FORMULA_INPUT_NAME,xt],[C.LIST_FORMULA_INPUT_NAME,qt],[C.CHECKBOX_FORMULA_INPUT_NAME,Ut]];var Qt=Object.getOwnPropertyDescriptor,en=(e,t,a,n)=>{for(var r=n>1?void 0:n?Qt(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},tn=(e,t)=>(a,n)=>t(a,n,e);exports.BaseSheetDataValidatorView=class{constructor(t){A(this,"canvasRender",null);A(this,"dropdownType");A(this,"optionsInput");A(this,"formulaInput",C.LIST_FORMULA_INPUT_NAME);this.injector=t}};exports.BaseSheetDataValidatorView=en([tn(0,o.Inject(o.Injector))],exports.BaseSheetDataValidatorView);var nn=Object.getOwnPropertyDescriptor,an=(e,t,a,n)=>{for(var r=n>1?void 0:n?nn(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},pt=(e,t)=>(a,n)=>t(a,n,e);let he=class extends o.Disposable{constructor(t,a){super();A(this,"_open$",new oe.BehaviorSubject(!1));A(this,"open$",this._open$.pipe(oe.distinctUntilChanged()));A(this,"_activeRule");A(this,"_activeRule$",new oe.BehaviorSubject(void 0));A(this,"activeRule$",this._activeRule$.asObservable());A(this,"_closeDisposable",null);this._univerInstanceService=t,this._sidebarService=a,this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(o.UniverInstanceType.UNIVER_SHEET).pipe(oe.filter(n=>!n)).subscribe(()=>{this.close()})),this.disposeWithMe(this._sidebarService.sidebarOptions$.subscribe(n=>{n.id===Fe&&(n.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=o.toDisposable(()=>{t.dispose(),this._closeDisposable=null})}setActiveRule(t){this._activeRule=t,this._activeRule$.next(t)}};he=an([pt(0,o.IUniverInstanceService),pt(1,E.ISidebarService)],he);const ct="sheets-data-validation-ui.config",ke={};var rn=Object.getOwnPropertyDescriptor,on=(e,t,a,n)=>{for(var r=n>1?void 0:n?rn(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},Ie=(e,t)=>(a,n)=>t(a,n,e);let we=class extends o.Disposable{constructor(e,t,a,n,r,i){super(),this._sheetInterceptorService=e,this._dataValidationModel=t,this._dataValidatorRegistryService=a,this._dialogService=n,this._localeService=r,this._sheetsDataValidationValidatorService=i,this._initEditorBridgeInterceptor()}_initEditorBridgeInterceptor(){this._sheetInterceptorService.writeCellInterceptor.intercept(H.VALIDATE_CELL,{handler:async(e,t,a)=>{const n=await e,{row:r,col:i,unitId:s,subUnitId:d}=t,l=this._dataValidationModel.getRuleIdByLocation(s,d,r,i),c=l?this._dataValidationModel.getRuleById(s,d,l):void 0;if(n===!1)return a(Promise.resolve(!1));if(!c||c.errorStyle!==o.DataValidationErrorStyle.STOP)return a(Promise.resolve(!0));const h=this._dataValidatorRegistryService.getValidatorItem(c.type);return!h||await this._sheetsDataValidationValidatorService.validatorCell(s,d,r,i)===o.DataValidationStatus.VALID?a(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:r,col:i,unitId:s,subUnitId:d})},footer:{title:b.createElement(V.Button,{variant:"primary",onClick:()=>this._dialogService.close("reject-input-dialog")},this._localeService.t("dataValidation.alert.ok"))},onClose:()=>{this._dialogService.close("reject-input-dialog")}}),a(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:b.createElement(V.Button,{variant:"primary",onClick:()=>this._dialogService.close("reject-input-dialog")},this._localeService.t("dataValidation.alert.ok"))},onClose:()=>{this._dialogService.close("reject-input-dialog")}})}};we=on([Ie(0,o.Inject(H.SheetInterceptorService)),Ie(1,o.Inject(C.SheetDataValidationModel)),Ie(2,o.Inject(Y.DataValidatorRegistryService)),Ie(3,E.IDialogService),Ie(4,o.Inject(o.LocaleService)),Ie(5,o.Inject(C.SheetsDataValidationValidatorService))],we);var sn=Object.getOwnPropertyDescriptor,ln=(e,t,a,n)=>{for(var r=n>1?void 0:n?sn(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},le=(e,t)=>(a,n)=>t(a,n,e);const Xe=e=>{if(e==null||typeof e=="boolean")return;if(typeof e=="number"||!Number.isNaN(+e))return o.dayjs(o.numfmt.format("yyyy-MM-dd HH:mm:ss",Number(e)));const t=o.dayjs(e);if(t.isValid())return t};function dn(e,t){const a=jt.getPatternType(t);if(e===a)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 o.Disposable{constructor(t,a,n,r,i,s,d,l,c,h,g){super();A(this,"_activeDropdown");A(this,"_activeDropdown$",new oe.Subject);A(this,"_currentPopup",null);A(this,"activeDropdown$",this._activeDropdown$.asObservable());A(this,"_zenVisible",!1);this._univerInstanceService=t,this._dataValidatorRegistryService=a,this._zenZoneService=n,this._dataValidationModel=r,this._sheetsSelectionsService=i,this._cellDropdownManagerService=s,this._sheetDataValidationModel=d,this._commandService=l,this._editorBridgeService=c,this._injector=h,this._configService=g,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,a,n,r){const i=t?this._univerInstanceService.getUnit(t,o.UniverInstanceType.UNIVER_SHEET):this._univerInstanceService.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET);if(!i)return;const s=a?i.getSheetBySheetId(a):i.getActiveSheet();if(!s)return;const d=this._dataValidationModel.getRuleByLocation(i.getUnitId(),s.getSheetId(),n,r);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(a=>!(a.primary&&this._getDropdownByCell(a.primary.unitId,a.primary.sheetId,a.primary.actualRow,a.primary.actualColumn)))&&this.hideDropdown()}))}showDropdown(t){var T,M,m,y;const{location:a}=t,{row:n,col:r,unitId:i,subUnitId:s,workbook:d,worksheet:l}=a;if(this._currentPopup&&this._currentPopup.dispose(),this._zenVisible)return;this._activeDropdown=t,this._activeDropdown$.next(this._activeDropdown);const c=this._sheetDataValidationModel.getRuleByLocation(i,s,n,r);if(!c)return;const h=this._dataValidatorRegistryService.getValidatorItem(c.type);if(!(h!=null&&h.dropdownType))return;let g;const u=async(f,D)=>{var j,U,B;if(!f)return!0;const R=f,I=l.getCell(n,r),w=R.format(D==="date"?"YYYY-MM-DD 00:00:00":"YYYY-MM-DD HH:mm:ss"),F=(j=o.numfmt.parseDate(w))==null?void 0:j.v,W=D==="time"?F%1:F,O=d.getStyles().getStyleByCell(I),x=(B=(U=O==null?void 0:O.n)==null?void 0:U.pattern)!=null?B:"";return c.errorStyle!==o.DataValidationErrorStyle.STOP||await h.validator({value:W,unitId:i,subUnitId:s,row:n,column:r,worksheet:l,workbook:d,interceptValue:w.replace("Z","").replace("T"," "),t:o.CellValueType.NUMBER},c)?(await this._commandService.executeCommand(N.SetCellEditVisibleOperation.id,{visible:!1,eventType:P.DeviceInputEventType.Keyboard,unitId:i,keycode:E.KeyCode.ESC}),await this._commandService.executeCommand(H.SetRangeValuesCommand.id,{unitId:i,subUnitId:s,range:{startColumn:r,endColumn:r,startRow:n,endRow:n},value:{v:W,t:2,p:null,f:null,si:null,s:{n:{pattern:dn(D,x)}}}}),!0):(this._injector.has(we)&&this._injector.get(we).showReject(h.getRuleFinalError(c,{row:n,col:r,unitId:i,subUnitId:s})),!1)};let _;switch(h.dropdownType){case Y.DataValidatorDropdownType.DATE:{const f=C.getCellValueOrigin(l.getCellRaw(n,r)),D=Xe(f),R=!!((T=c.bizInfo)!=null&&T.showTime);_={location:a,type:"datepicker",props:{showTime:R,onChange:I=>u(I,R?"datetime":"date"),defaultValue:D,patternType:"date"}};break}case Y.DataValidatorDropdownType.TIME:{const f=C.getCellValueOrigin(l.getCellRaw(n,r)),D=Xe(f);_={location:a,type:"datepicker",props:{onChange:R=>u(R,"time"),defaultValue:D,patternType:"time"}};break}case Y.DataValidatorDropdownType.DATETIME:{const f=C.getCellValueOrigin(l.getCellRaw(n,r)),D=Xe(f);_={location:a,type:"datepicker",props:{onChange:R=>u(R,"datetime"),defaultValue:D,patternType:"datetime"}};break}case Y.DataValidatorDropdownType.LIST:case Y.DataValidatorDropdownType.MULTIPLE_LIST:{const f=h.dropdownType===Y.DataValidatorDropdownType.MULTIPLE_LIST,D=async O=>{const x=C.serializeListOptions(O),j={unitId:i,subUnitId:s,range:{startColumn:r,endColumn:r,startRow:n,endRow:n},value:{v:x,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:i,keycode:E.KeyCode.ESC}),this._commandService.executeCommand(H.SetRangeValuesCommand.id,j),!f},R=(c==null?void 0:c.renderMode)===o.DataValidationRenderMode.CUSTOM||(c==null?void 0:c.renderMode)===void 0,I=h.getListWithColor(c,i,s),w=C.getDataValidationCellValue(l.getCellRaw(n,r)),F=()=>{this._commandService.executeCommand(_e.id,{ruleId:c.uid}),g==null||g.dispose()},W=I.map(O=>({label:O.label,value:O.label,color:R||O.color?O.color:"transparent"}));_={location:a,type:"list",props:{onChange:O=>D(O),options:W,onEdit:F,defaultValue:w,multiple:f,showEdit:(m=(M=this._configService.getConfig(ct))==null?void 0:M.showEditOnDropdown)!=null?m:!0}};break}case Y.DataValidatorDropdownType.CASCADE:{_={type:"cascader",props:{onChange:D=>{const R={unitId:i,subUnitId:s,range:{startColumn:r,endColumn:r,startRow:n,endRow:n},value:{v:D.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:i,keycode:E.KeyCode.ESC}),this._commandService.syncExecuteCommand(H.SetRangeValuesCommand.id,R),!0},defaultValue:C.getDataValidationCellValue(l.getCellRaw(n,r)).split("/"),options:JSON.parse((y=c.formula1)!=null?y:"[]")},location:a};break}case Y.DataValidatorDropdownType.COLOR:{_={type:"color",props:{onChange:D=>{const R={unitId:i,subUnitId:s,range:{startColumn:r,endColumn:r,startRow:n,endRow:n},value:{v:D,p:null,f:null,si:null}};return this._editorBridgeService.isVisible().visible&&this._commandService.syncExecuteCommand(N.SetCellEditVisibleOperation.id,{visible:!1,eventType:P.DeviceInputEventType.Keyboard,unitId:i,keycode:E.KeyCode.ESC}),this._commandService.syncExecuteCommand(H.SetRangeValuesCommand.id,R),!0},defaultValue:C.getDataValidationCellValue(l.getCellRaw(n,r))},location:a};break}default:throw new Error("[DataValidationDropdownManagerService]: unknown type!")}if(g=this._cellDropdownManagerService.showDropdown(_),!g)throw new Error("[DataValidationDropdownManagerService]: cannot show dropdown!");const v=new o.DisposableCollection;v.add(g),v.add({dispose:()=>{var f,D;(D=(f=this._activeDropdown)==null?void 0:f.onHide)==null||D.call(f)}}),this._currentPopup=v}hideDropdown(){this._activeDropdown&&(this._currentPopup&&this._currentPopup.dispose(),this._currentPopup=null,this._activeDropdown=null,this._activeDropdown$.next(null))}showDataValidationDropdown(t,a,n,r,i){const s=this._univerInstanceService.getUnit(t,o.UniverInstanceType.UNIVER_SHEET);if(!s)return;const d=s.getSheetBySheetId(a);if(!d)return;const l=this._dataValidationModel.getRuleByLocation(s.getUnitId(),d.getSheetId(),n,r);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:n,col:r,unitId:t,subUnitId:a},onHide:i})}};fe=ln([le(0,o.IUniverInstanceService),le(1,o.Inject(Y.DataValidatorRegistryService)),le(2,E.IZenZoneService),le(3,o.Inject(C.SheetDataValidationModel)),le(4,o.Inject(H.SheetsSelectionsService)),le(5,o.Inject(N.ISheetCellDropdownManagerService)),le(6,o.Inject(C.SheetDataValidationModel)),le(7,o.ICommandService),le(8,N.IEditorBridgeService),le(9,o.Inject(o.Injector)),le(10,o.IConfigService)],fe);const Fe="DataValidationPanel",_e={id:"data-validation.operation.open-validation-panel",type:o.CommandType.OPERATION,handler(e,t){if(!t)return!1;const{ruleId:a,isAdd:n}=t,r=e.get(he),i=e.get(Y.DataValidationModel),s=e.get(o.IUniverInstanceService),d=e.get(E.ISidebarService),l=H.getSheetCommandTarget(s);if(!l)return!1;const{unitId:c,subUnitId:h}=l,g=a?i.getRuleById(c,h,a):void 0;r.open(),r.setActiveRule(g&&{unitId:c,subUnitId:h,rule:g});const u=d.open({id:Fe,header:{title:n?"dataValidation.panel.addTitle":"dataValidation.panel.title"},children:{label:Fe},width:312,onClose:()=>r.close()});return r.setCloseDisposable(u),!0}},ut={id:"data-validation.operation.close-validation-panel",type:o.CommandType.OPERATION,handler(e){return e.get(he).close(),!0}},wt={id:"data-validation.operation.toggle-validation-panel",type:o.CommandType.OPERATION,handler(e){const t=e.get(o.ICommandService),a=e.get(he);return a.open(),a.isOpen?t.executeCommand(ut.id):t.executeCommand(_e.id),!0}},$e={type:o.CommandType.OPERATION,id:"sheet.operation.show-data-validation-dropdown",handler(e,t){if(!t)return!1;const a=e.get(fe),{unitId:n,subUnitId:r,row:i,column:s}=t,d=a.activeDropdown,l=d==null?void 0:d.location;return l&&l.unitId===n&&l.subUnitId===r&&l.row===i&&l.col===s||a.showDataValidationDropdown(n,r,i,s),!0}},Vt={type:o.CommandType.OPERATION,id:"sheet.operation.hide-data-validation-dropdown",handler(e,t){return t?(e.get(fe).hideDropdown(),!0):!1}},Ye={type:o.CommandType.COMMAND,id:"data-validation.command.addRuleAndOpen",handler(e){const t=e.get(o.IUniverInstanceService),a=H.getSheetCommandTarget(t);if(!a)return!1;const{workbook:n,worksheet:r}=a,i=C.createDefaultNewRule(e),s=e.get(o.ICommandService),d=n.getUnitId(),l=r.getSheetId(),c={rule:i,unitId:d,subUnitId:l};return s.syncExecuteCommand(C.AddSheetDataValidationCommand.id,c)?(s.syncExecuteCommand(_e.id,{ruleId:i.uid,isAdd:!0}),!0):!1}};var cn=Object.getOwnPropertyDescriptor,un=(e,t,a,n)=>{for(var r=n>1?void 0:n?cn(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},Ce=(e,t)=>(a,n)=>t(a,n,e);const pe="SHEET_DATA_VALIDATION_ALERT";let Ae=class extends o.Disposable{constructor(e,t,a,n,r,i){super(),this._hoverManagerService=e,this._cellAlertManagerService=t,this._univerInstanceService=a,this._localeService=n,this._zenZoneService=r,this._dataValidationModel=i,this._init()}_init(){this._initCellAlertPopup(),this._initZenService()}_initCellAlertPopup(){this.disposeWithMe(this._hoverManagerService.currentCell$.pipe(oe.debounceTime(100)).subscribe(e=>{var t;if(e){const a=this._univerInstanceService.getUnit(e.location.unitId,o.UniverInstanceType.UNIVER_SHEET),n=a.getSheetBySheetId(e.location.subUnitId);if(!n)return;const r=this._dataValidationModel.getRuleByLocation(e.location.unitId,e.location.subUnitId,e.location.row,e.location.col);if(!r){this._cellAlertManagerService.removeAlert(pe);return}if(this._dataValidationModel.validator(r,{...e.location,workbook:a,worksheet:n})===o.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(r.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(r,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)}))}};Ae=un([Ce(0,o.Inject(N.HoverManagerService)),Ce(1,o.Inject(N.CellAlertManagerService)),Ce(2,o.IUniverInstanceService),Ce(3,o.Inject(o.LocaleService)),Ce(4,E.IZenZoneService),Ce(5,o.Inject(C.SheetDataValidationModel))],Ae);var hn=Object.getOwnPropertyDescriptor,gn=(e,t,a,n)=>{for(var r=n>1?void 0:n?hn(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},ze=(e,t)=>(a,n)=>t(a,n,e);let Ve=class extends o.Disposable{constructor(e,t,a){super(),this._autoFillService=e,this._sheetDataValidationModel=t,this._injector=a,this._initAutoFill()}_initAutoFill(){const e=()=>({redos:[],undos:[]}),t=(n,r)=>{const{source:i,target:s,unitId:d,subUnitId:l}=n,c=this._sheetDataValidationModel.getRuleObjectMatrix(d,l).clone(),h=N.virtualizeDiscreteRanges([i,s]),[g,u]=h.ranges,{mapFunc:_}=h,v={row:g.startRow,col:g.startColumn},T=N.getAutoFillRepeatRange(g,u),M=new o.ObjectMatrix,m=new Set;T.forEach(I=>{const w=I.repeatStartCell,F=I.relativeRange,W={startRow:v.row,startColumn:v.col,endColumn:v.col,endRow:v.row},O={startRow:w.row,startColumn:w.col,endColumn:w.col,endRow:w.row};o.Range.foreach(F,(x,j)=>{const U=o.Rectangle.getPositionRange({startRow:x,startColumn:j,endColumn:j,endRow:x},W),{row:B,col:K}=_(U.startRow,U.startColumn),z=this._sheetDataValidationModel.getRuleIdByLocation(d,l,B,K)||"",ee=o.Rectangle.getPositionRange({startRow:x,startColumn:j,endColumn:j,endRow:x},O),{row:ae,col:re}=_(ee.startRow,ee.startColumn);M.setValue(ae,re,z),m.add(z)})});const y=Array.from(m).map(I=>({id:I,ranges:o.queryObjectMatrix(M,w=>w===I)}));c.addRangeRules(y);const f=c.diff(this._sheetDataValidationModel.getRules(d,l)),{redoMutations:D,undoMutations:R}=C.getDataValidationDiffMutations(d,l,f,this._injector,"patched",r===N.APPLY_TYPE.ONLY_FORMAT);return{undos:R,redos:D}},a={id:C.DATA_VALIDATION_PLUGIN_NAME,onBeforeFillData:n=>{const{source:r,unitId:i,subUnitId:s}=n;for(const d of r.rows)for(const l of r.cols){const c=this._sheetDataValidationModel.getRuleByLocation(i,s,d,l);if(c&&c.type===o.DataValidationType.CHECKBOX){this._autoFillService.setDisableApplyType(N.APPLY_TYPE.SERIES,!0);return}}},onFillData:(n,r,i)=>i===N.APPLY_TYPE.COPY||i===N.APPLY_TYPE.ONLY_FORMAT||i===N.APPLY_TYPE.SERIES?t(n,i):e(),onAfterFillData:()=>{}};this.disposeWithMe(this._autoFillService.addHook(a))}};Ve=gn([ze(0,N.IAutoFillService),ze(1,o.Inject(C.SheetDataValidationModel)),ze(2,o.Inject(o.Injector))],Ve);var pn=Object.getOwnPropertyDescriptor,vn=(e,t,a,n)=>{for(var r=n>1?void 0:n?pn(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},Ke=(e,t)=>(a,n)=>t(a,n,e);let Ee=class extends o.Disposable{constructor(t,a,n){super();A(this,"_copyInfo");this._sheetClipboardService=t,this._sheetDataValidationModel=a,this._injector=n,this._initCopyPaste()}_initCopyPaste(){this._sheetClipboardService.addClipboardHook({id:C.DATA_VALIDATION_PLUGIN_NAME,onBeforeCopy:(t,a,n)=>this._collect(t,a,n),onPasteCells:(t,a,n,r)=>{const{copyType:i=N.COPY_TYPE.COPY,pasteType:s}=r,{range:d}=t||{},{range:l,unitId:c,subUnitId:h}=a;return this._generateMutations(l,{copyType:i,pasteType:s,copyRange:d,unitId:c,subUnitId:h})}})}_collect(t,a,n){const r=new o.ObjectMatrix;this._copyInfo={unitId:t,subUnitId:a,matrix:r};const i=this._injector.invoke(l=>H.rangeToDiscreteRange(n,l,t,a));if(!i)return;const{rows:s,cols:d}=i;s.forEach((l,c)=>{d.forEach((h,g)=>{const u=this._sheetDataValidationModel.getRuleIdByLocation(t,a,l,h);r.setValue(c,g,u!=null?u:"")})})}_generateMutations(t,a){if(!this._copyInfo)return{redos:[],undos:[]};if(a.copyType===N.COPY_TYPE.CUT)return this._copyInfo=null,{redos:[],undos:[]};if(!this._copyInfo||!this._copyInfo.matrix.getSizeOf()||!a.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(a.pasteType))return{redos:[],undos:[]};const{unitId:r,subUnitId:i}=this._copyInfo;if(a.unitId!==r||i!==a.subUnitId){const s=this._sheetDataValidationModel.getRuleObjectMatrix(a.unitId,a.subUnitId).clone(),d=new o.ObjectMatrix,l=new Set,{ranges:[c,h],mapFunc:g}=N.virtualizeDiscreteRanges([a.copyRange,t]),u=N.getRepeatRange(c,h,!0),_=new Map;u.forEach(({startRange:m})=>{var y;(y=this._copyInfo)==null||y.matrix.forValue((f,D,R)=>{const I=o.Rectangle.getPositionRange({startRow:f,endRow:f,startColumn:D,endColumn:D},m),w=`${i}-${R}`,F=this._sheetDataValidationModel.getRuleById(r,i,R);!this._sheetDataValidationModel.getRuleById(a.unitId,a.subUnitId,w)&&F&&_.set(w,{...F,uid:w});const{row:W,col:O}=g(I.startRow,I.startColumn);l.add(w),d.setValue(W,O,w)})});const v=Array.from(l).map(m=>({id:m,ranges:o.queryObjectMatrix(d,y=>y===m)}));s.addRangeRules(v);const{redoMutations:T,undoMutations:M}=C.getDataValidationDiffMutations(a.unitId,a.subUnitId,s.diffWithAddition(this._sheetDataValidationModel.getRules(a.unitId,a.subUnitId),_.values()),this._injector,"patched",!1);return{redos:T,undos:M}}else{const s=this._sheetDataValidationModel.getRuleObjectMatrix(r,i).clone(),d=new o.ObjectMatrix,l=new Set,{ranges:[c,h],mapFunc:g}=N.virtualizeDiscreteRanges([a.copyRange,t]);N.getRepeatRange(c,h,!0).forEach(({startRange:M})=>{var m;(m=this._copyInfo)==null||m.matrix.forValue((y,f,D)=>{const R=o.Rectangle.getPositionRange({startRow:y,endRow:y,startColumn:f,endColumn:f},M),{row:I,col:w}=g(R.startRow,R.startColumn);d.setValue(I,w,D),l.add(D)})});const _=Array.from(l).map(M=>({id:M,ranges:o.queryObjectMatrix(d,m=>m===M)}));s.addRangeRules(_);const{redoMutations:v,undoMutations:T}=C.getDataValidationDiffMutations(r,i,s.diff(this._sheetDataValidationModel.getRules(r,i)),this._injector,"patched",!1);return{redos:v,undos:T}}}};Ee=vn([Ke(0,N.ISheetClipboardService),Ke(1,o.Inject(C.SheetDataValidationModel)),Ke(2,o.Inject(o.Injector))],Ee);var mn=Object.getOwnPropertyDescriptor,fn=(e,t,a,n)=>{for(var r=n>1?void 0:n?mn(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},Ze=(e,t)=>(a,n)=>t(a,n,e);let Me=class extends o.Disposable{constructor(e,t,a){super(),this._localeService=e,this._commandService=t,this._sheetPermissionCheckController=a,this._commandExecutedListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.beforeCommandExecuted(e=>{e.id===C.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===C.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")))}))}};Me=fn([Ze(0,o.Inject(o.LocaleService)),Ze(1,o.ICommandService),Ze(2,o.Inject(H.SheetPermissionCheckController))],Me);const Et="sheet.menu.data-validation";function Sn(e){return{id:Et,type:E.MenuItemType.SUBITEMS,icon:"DataValidationIcon",tooltip:"dataValidation.title",hidden$:E.getMenuHiddenObservable(e,o.UniverInstanceType.UNIVER_SHEET),disabled$:N.getCurrentRangeDisable$(e,{workbookTypes:[H.WorkbookEditablePermission],worksheetTypes:[H.WorksheetSetCellStylePermission,H.WorksheetEditPermission],rangeTypes:[H.RangeProtectionPermissionEditPoint]})}}function _n(e){return{id:_e.id,title:"dataValidation.panel.title",type:E.MenuItemType.BUTTON}}function In(e){return{id:Ye.id,title:"dataValidation.panel.add",type:E.MenuItemType.BUTTON}}const Cn={[E.RibbonDataGroup.RULES]:{[Et]:{order:0,menuItemFactory:Sn,[_e.id]:{order:0,menuItemFactory:_n},[Ye.id]:{order:1,menuItemFactory:In}}}};var yn=Object.getOwnPropertyDescriptor,Mt=(e,t,a,n)=>{for(var r=n>1?void 0:n?yn(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},G=(e,t)=>(a,n)=>t(a,n,e);const bt={tr:{size:6,color:"#fe4b4b"}};let be=class extends o.RxDisposable{constructor(e,t,a,n,r,i,s,d,l,c,h){super(),this._commandService=e,this._menuManagerService=t,this._renderManagerService=a,this._univerInstanceService=n,this._autoHeightController=r,this._dropdownManagerService=i,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(Cn)}_initDropdown(){this._editorBridgeService&&this.disposeWithMe(this._editorBridgeService.visible$.subscribe(e=>{var a;if(!e.visible){((a=this._dropdownManagerService.activeDropdown)==null?void 0:a.trigger)==="editor-bridge"&&this._dropdownManagerService.hideDropdown();return}const t=this._editorBridgeService.getEditCellState();if(t){const{unitId:n,sheetId:r,row:i,column:s}=t,d=this._univerInstanceService.getUniverSheetInstance(n);if(!d)return;const l=this._sheetDataValidationModel.getRuleByLocation(n,r,i,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===n&&u.subUnitId===r&&u.row===i&&u.col===s)return;this._dropdownManagerService.showDropdown({location:{unitId:n,subUnitId:r,row:i,col:s,workbook:d,worksheet:h},trigger:"editor-bridge",closeOnOutSide:!1})}}))}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(H.INTERCEPTOR_POINT.CELL_CONTENT,{effect:o.InterceptorEffectEnum.Style,priority:H.InterceptCellContentPriority.DATA_VALIDATION,handler:(e,t,a)=>{var m,y,f,D,R;const{row:n,col:r,unitId:i,subUnitId:s,workbook:d,worksheet:l}=t,c=this._sheetDataValidationModel.getRuleIdByLocation(i,s,n,r);if(!c)return a(e);const h=this._sheetDataValidationModel.getRuleById(i,s,c);if(!h)return a(e);const g=(m=this._dataValidationCacheService.getValue(i,s,n,r))!=null?m:o.DataValidationStatus.VALID,u=this._dataValidatorRegistryService.getValidatorItem(h.type),_=t.rawData;let v;const T={get value(){var I;return v!==void 0||(v=(I=C.getCellValueOrigin(_))!=null?I:null),v}},M={get value(){var I;return`${(I=T.value)!=null?I:""}`}};return(!e||e===t.rawData)&&(e={...t.rawData}),e.markers={...e==null?void 0:e.markers,...g===o.DataValidationStatus.INVALID?bt:null},e.customRender=[...(y=e==null?void 0:e.customRender)!=null?y:[],...u!=null&&u.canvasRender?[u.canvasRender]:[]],e.fontRenderExtension={...e==null?void 0:e.fontRenderExtension,isSkip:((f=e==null?void 0:e.fontRenderExtension)==null?void 0:f.isSkip)||((D=u==null?void 0:u.skipDefaultFontRender)==null?void 0:D.call(u,h,T.value,t))},e.interceptorStyle={...e==null?void 0:e.interceptorStyle,...u==null?void 0:u.getExtraStyle(h,M.value,{get style(){const I=d.getStyles();return(typeof(e==null?void 0:e.s)=="string"?I.get(e==null?void 0:e.s):e==null?void 0:e.s)||{}}},n,r)},e.interceptorAutoHeight=()=>{var W,O,x,j,U,B;const I=(O=(W=this._renderManagerService.getRenderById(i))==null?void 0:W.with(N.SheetSkeletonManagerService).getSkeletonParam(s))==null?void 0:O.skeleton;if(!I)return;const w=I.worksheet.getMergedCell(n,r),F={data:e,style:I.getStyles().getStyleByCell(e),primaryWithCoord:I.getCellWithCoordByIndex((x=w==null?void 0:w.startRow)!=null?x:n,(j=w==null?void 0:w.startColumn)!=null?j:r),unitId:i,subUnitId:s,row:n,col:r,workbook:d,worksheet:l};return(B=(U=u==null?void 0:u.canvasRender)==null?void 0:U.calcCellAutoHeight)==null?void 0:B.call(U,F)},e.interceptorAutoWidth=()=>{var W,O,x,j,U,B;const I=(O=(W=this._renderManagerService.getRenderById(i))==null?void 0:W.with(N.SheetSkeletonManagerService).getSkeletonParam(s))==null?void 0:O.skeleton;if(!I)return;const w=I.worksheet.getMergedCell(n,r),F={data:e,style:I.getStyles().getStyleByCell(e),primaryWithCoord:I.getCellWithCoordByIndex((x=w==null?void 0:w.startRow)!=null?x:n,(j=w==null?void 0:w.startColumn)!=null?j:r),unitId:i,subUnitId:s,row:n,col:r,workbook:d,worksheet:l};return(B=(U=u==null?void 0:u.canvasRender)==null?void 0:U.calcCellAutoWidth)==null?void 0:B.call(U,F)},e.coverable=((R=e==null?void 0:e.coverable)!=null?R:!0)&&!(h.type===o.DataValidationType.LIST||h.type===o.DataValidationType.LIST_MULTIPLE),a(e)}}))}_initAutoHeight(){this._sheetDataValidationModel.ruleChange$.pipe(oe.filter(e=>e.source==="command"),oe.bufferTime(100)).subscribe(e=>{if(e.length===0)return;const t=[];if(e.forEach(a=>{var n;(a.rule.type===o.DataValidationType.LIST_MULTIPLE||a.rule.type===o.DataValidationType.LIST)&&(n=a.rule)!=null&&n.ranges&&t.push(...a.rule.ranges)}),t.length){const a=this._autoHeightController.getUndoRedoParamsOfAutoHeight(t);o.sequenceExecute(a.redos,this._commandService)}})}};be=Mt([G(0,o.ICommandService),G(1,E.IMenuManagerService),G(2,P.IRenderManagerService),G(3,o.IUniverInstanceService),G(4,o.Inject(N.AutoHeightController)),G(5,o.Inject(fe)),G(6,o.Inject(C.SheetDataValidationModel)),G(7,o.Inject(Y.DataValidatorRegistryService)),G(8,o.Inject(H.SheetInterceptorService)),G(9,o.Inject(C.DataValidationCacheService)),G(10,o.Optional(N.IEditorBridgeService))],be);let vt=class extends o.RxDisposable{constructor(e,t,a,n,r,i,s){super(),this._commandService=e,this._renderManagerService=t,this._autoHeightController=a,this._dataValidatorRegistryService=n,this._sheetInterceptorService=r,this._sheetDataValidationModel=i,this._dataValidationCacheService=s,this._initViewModelIntercept(),this._initAutoHeight()}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(H.INTERCEPTOR_POINT.CELL_CONTENT,{effect:o.InterceptorEffectEnum.Style,priority:H.InterceptCellContentPriority.DATA_VALIDATION,handler:(e,t,a)=>{var M,m,y,f,D;const{row:n,col:r,unitId:i,subUnitId:s,workbook:d,worksheet:l}=t,c=this._sheetDataValidationModel.getRuleIdByLocation(i,s,n,r);if(!c)return a(e);const h=this._sheetDataValidationModel.getRuleById(i,s,c);if(!h)return a(e);const g=(M=this._dataValidationCacheService.getValue(i,s,n,r))!=null?M:o.DataValidationStatus.VALID,u=this._dataValidatorRegistryService.getValidatorItem(h.type),_=l.getCellRaw(n,r),v=C.getCellValueOrigin(_),T=`${v!=null?v:""}`;return(!e||e===t.rawData)&&(e={...t.rawData}),e.markers={...e==null?void 0:e.markers,...g===o.DataValidationStatus.INVALID?bt:null},e.customRender=[...(m=e==null?void 0:e.customRender)!=null?m:[],...u!=null&&u.canvasRender?[u.canvasRender]:[]],e.fontRenderExtension={...e==null?void 0:e.fontRenderExtension,isSkip:((y=e==null?void 0:e.fontRenderExtension)==null?void 0:y.isSkip)||((f=u==null?void 0:u.skipDefaultFontRender)==null?void 0:f.call(u,h,v,t))},e.interceptorStyle={...e==null?void 0:e.interceptorStyle,...u==null?void 0:u.getExtraStyle(h,T,{get style(){const R=d.getStyles();return(typeof(e==null?void 0:e.s)=="string"?R.get(e==null?void 0:e.s):e==null?void 0:e.s)||{}}},n,r)},e.interceptorAutoHeight=()=>{var F,W,O,x,j,U;const R=(W=(F=this._renderManagerService.getRenderById(i))==null?void 0:F.with(N.SheetSkeletonManagerService).getSkeletonParam(s))==null?void 0:W.skeleton;if(!R)return;const I=R.worksheet.getMergedCell(n,r),w={data:e,style:R.getStyles().getStyleByCell(e),primaryWithCoord:R.getCellWithCoordByIndex((O=I==null?void 0:I.startRow)!=null?O:n,(x=I==null?void 0:I.startColumn)!=null?x:r),unitId:i,subUnitId:s,row:n,col:r,workbook:d,worksheet:l};return(U=(j=u==null?void 0:u.canvasRender)==null?void 0:j.calcCellAutoHeight)==null?void 0:U.call(j,w)},e.interceptorAutoWidth=()=>{var F,W,O,x,j,U;const R=(W=(F=this._renderManagerService.getRenderById(i))==null?void 0:F.with(N.SheetSkeletonManagerService).getSkeletonParam(s))==null?void 0:W.skeleton;if(!R)return;const I=R.worksheet.getMergedCell(n,r),w={data:e,style:R.getStyles().getStyleByCell(e),primaryWithCoord:R.getCellWithCoordByIndex((O=I==null?void 0:I.startRow)!=null?O:n,(x=I==null?void 0:I.startColumn)!=null?x:r),unitId:i,subUnitId:s,row:n,col:r,workbook:d,worksheet:l};return(U=(j=u==null?void 0:u.canvasRender)==null?void 0:j.calcCellAutoWidth)==null?void 0:U.call(j,w)},e.coverable=((D=e==null?void 0:e.coverable)!=null?D:!0)&&!(h.type===o.DataValidationType.LIST||h.type===o.DataValidationType.LIST_MULTIPLE),a(e)}}))}_initAutoHeight(){this._sheetDataValidationModel.ruleChange$.pipe(oe.filter(e=>e.source==="command"),oe.bufferTime(16)).subscribe(e=>{const t=[];if(e.forEach(a=>{var n;(a.rule.type===o.DataValidationType.LIST_MULTIPLE||a.rule.type===o.DataValidationType.LIST)&&(n=a.rule)!=null&&n.ranges&&t.push(...a.rule.ranges)}),t.length){const a=this._autoHeightController.getUndoRedoParamsOfAutoHeight(t);o.sequenceExecute(a.redos,this._commandService)}})}};vt=Mt([G(0,o.ICommandService),G(1,P.IRenderManagerService),G(2,o.Inject(N.AutoHeightController)),G(3,o.Inject(Y.DataValidatorRegistryService)),G(4,o.Inject(H.SheetInterceptorService)),G(5,o.Inject(C.SheetDataValidationModel)),G(6,o.Inject(C.DataValidationCacheService))],vt);var Rn=Object.getOwnPropertyDescriptor,Dn=(e,t,a,n)=>{for(var r=n>1?void 0:n?Rn(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},mt=(e,t)=>(a,n)=>t(a,n,e);let Ne=class extends o.Disposable{constructor(e,t,a){super(),this._context=e,this._sheetDataValidationModel=t,this._sheetSkeletonManagerService=a,this._initSkeletonChange()}_initSkeletonChange(){const e=t=>{var n;if(!t.length)return;const a=new Set;t.forEach(r=>{a.add(r.subUnitId)}),a.forEach(r=>{var i;(i=this._sheetSkeletonManagerService.getSkeletonParam(r))==null||i.skeleton.makeDirty(!0)}),(n=this._context.mainComponent)==null||n.makeForceDirty()};this.disposeWithMe(this._sheetDataValidationModel.validStatusChange$.pipe(o.bufferDebounceTime(16)).subscribe(e))}};Ne=Dn([mt(1,o.Inject(C.SheetDataValidationModel)),mt(2,o.Inject(N.SheetSkeletonManagerService))],Ne);function wn(e){var c;const t=E.useDependency(o.LocaleService),a=E.useDependency(E.ComponentManager),{value:n,onChange:r,extraComponent:i}=e,[s,d]=b.useState(!1),l=i?a.get(i):null;return p.jsxs(p.Fragment,{children:[p.jsxs("div",{className:"univer-mb-3 univer-flex univer-cursor-pointer univer-items-center univer-text-sm univer-text-gray-900 dark:!univer-text-white",onClick:()=>d(!s),children:[t.t("dataValidation.panel.options"),s?p.jsx(Rt,{className:"univer-ml-1"}):p.jsx(dt,{className:"univer-ml-1"})]}),s&&p.jsxs(p.Fragment,{children:[l?p.jsx(l,{value:n,onChange:r}):null,p.jsx(V.FormLayout,{label:t.t("dataValidation.panel.invalid"),children:p.jsxs(V.RadioGroup,{value:`${(c=n.errorStyle)!=null?c:o.DataValidationErrorStyle.WARNING}`,onChange:h=>r({...n,errorStyle:+h}),children:[p.jsx(V.Radio,{value:`${o.DataValidationErrorStyle.WARNING}`,children:t.t("dataValidation.panel.showWarning")}),p.jsx(V.Radio,{value:`${o.DataValidationErrorStyle.STOP}`,children:t.t("dataValidation.panel.rejectInput")})]})}),p.jsx(V.FormLayout,{label:t.t("dataValidation.panel.messageInfo"),children:p.jsx(V.Checkbox,{checked:n.showErrorMessage,onChange:()=>r({...n,showErrorMessage:!n.showErrorMessage}),children:t.t("dataValidation.panel.showInfo")})}),n.showErrorMessage?p.jsx(V.FormLayout,{children:p.jsx(V.Input,{value:n.error,onChange:h=>r({...n,error:h})})}):null]})]})}const Vn=e=>o.debounce(async(t,a,n,r)=>{const i=await e.executeCommand(t,a,n);r==null||r(i)},1e3);function En(e,t,a){var n,r,i,s;return t?((r=(n=e.getUnit(t))==null?void 0:n.getSheetBySheetName(a))==null?void 0:r.getSheetId())||"":((s=(i=e.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET))==null?void 0:i.getSheetBySheetName(a))==null?void 0:s.getSheetId())||""}function Mn(){var L,$;const[e,t]=b.useState(0),a=E.useDependency(he),n=E.useObservable(a.activeRule$,a.activeRule),{unitId:r,subUnitId:i,rule:s}=n||{},d=s.uid,l=E.useDependency(Y.DataValidatorRegistryService),c=E.useDependency(o.IUniverInstanceService),h=E.useDependency(E.ComponentManager),g=E.useDependency(o.ICommandService),u=E.useDependency(Y.DataValidationModel),_=E.useDependency(o.LocaleService),[v,T]=b.useState(s),M=l.getValidatorItem(v.type),[m,y]=b.useState(!1),f=l.getValidatorsByScope(Y.DataValidatorRegistryScope.SHEET),[D,R]=b.useState(()=>v.ranges.map(S=>({unitId:"",sheetId:"",range:S}))),I=b.useMemo(()=>Vn(g),[g]),[w,F]=b.useState(!1),[W,O]=b.useState(!1),x=b.useRef(null),j=E.useDependency(H.SheetsSelectionsService);if(b.useEffect(()=>()=>{const S=j.getCurrentLastSelection();S&&j.setSelections([S])},[j]),b.useEffect(()=>{g.onCommandExecuted(S=>{(S.id===o.UndoCommand.id||S.id===o.RedoCommand.id)&&setTimeout(()=>{const k=u.getRuleById(r,i,d);t(X=>X+1),k&&(T(k),R(k.ranges.map(X=>({unitId:"",sheetId:"",range:X}))))},20)})},[g,u,d,i,r]),!M)return null;const U=M.operators,B=M.operatorNames,K=v.operator?Y.TWO_FORMULA_OPERATOR_COUNT.includes(v.operator):!1,z=()=>{var S,k,X;(k=(S=x.current)==null?void 0:S.editor)!=null&&k.isFocus()&&ee((X=x.current)==null?void 0:X.getValue()),!(!v.ranges.length||w)&&(M.validatorFormula(v,r,i).success?a.setActiveRule(null):y(!0))},ee=E.useEvent(S=>{const k=S.split(",").filter(Boolean).map(nt.deserializeRangeWithSheet).map(ne=>{const ht=ne.sheetName;if(ht){const At=En(c,ne.unitId,ht);return{...ne,sheetId:At}}return{...ne,sheetId:""}});if(o.isUnitRangesEqual(k,D))return;R(k);const X=k.filter(ne=>(!ne.unitId||ne.unitId===r)&&(!ne.sheetId||ne.sheetId===i)).map(ne=>ne.range);if(T({...v,ranges:X}),X.length===0)return;const ge={unitId:r,subUnitId:i,ruleId:d,ranges:X};I(C.UpdateSheetDataValidationRangeCommand.id,ge)}),ae=S=>{if(o.shallowEqual(S,Y.getRuleSetting(v)))return;T({...v,...S});const k={unitId:r,subUnitId:i,ruleId:d,setting:S};I(C.UpdateSheetDataValidationSettingCommand.id,k,void 0)},re=async()=>{await g.executeCommand(C.RemoveSheetDataValidationCommand.id,{ruleId:d,unitId:r,subUnitId:i}),a.setActiveRule(null)},se={type:v.type,operator:v.operator,formula1:v.formula1,formula2:v.formula2,allowBlank:v.allowBlank},q=S=>{const k=l.getValidatorItem(S);if(!k)return;const X=k.operators,ge=u.getRuleById(r,i,d),ne=S===(ge==null?void 0:ge.type)||S.includes("list")&&(ge!=null&&ge.type.includes("list"))?{...ge,type:S}:{...v,type:S,operator:X[0],formula1:void 0,formula2:void 0};T(ne),g.executeCommand(C.UpdateSheetDataValidationSettingCommand.id,{unitId:r,subUnitId:i,ruleId:v.uid,setting:Y.getRuleSetting(ne)})},Z=h.get(M.formulaInput),ce=b.useMemo(()=>D.map(S=>nt.serializeRange(S.range)).join(","),[]),te=Y.getRuleOptions(v),Q=S=>{o.shallowEqual(S,Y.getRuleOptions(v))||(T({...v,...S}),I(C.UpdateSheetDataValidationOptionsCommand.id,{unitId:r,subUnitId:i,ruleId:d,options:S}))},J=U.length&&!v.operator;return p.jsxs("div",{"data-u-comp":"data-validation-detail",className:"univer-py-2",children:[p.jsx(V.FormLayout,{label:_.t("dataValidation.panel.range"),error:!v.ranges.length||w?_.t("dataValidation.panel.rangeError"):"",children:p.jsx(st.RangeSelector,{selectorRef:x,unitId:r,subUnitId:i,initialValue:ce,onChange:(S,k)=>{var X;!W&&((X=x.current)!=null&&X.verify())&&ee(k)},onFocusChange:(S,k)=>{var X;O(S),!S&&k&&((X=x.current)!=null&&X.verify())&&ee(k)},onVerify:S=>F(!S)})}),p.jsx(V.FormLayout,{label:_.t("dataValidation.panel.type"),children:p.jsx(V.Select,{className:"univer-w-full",value:v.type,options:(L=f==null?void 0:f.sort((S,k)=>S.order-k.order))==null?void 0:L.map(S=>({label:_.t(S.title),value:S.id})),onChange:q})}),U!=null&&U.length?p.jsx(V.FormLayout,{label:_.t("dataValidation.panel.operator"),children:p.jsx(V.Select,{className:"univer-w-full",value:`${v.operator}`,options:[{value:"",label:_.t("dataValidation.operators.legal")},...U.map((S,k)=>({value:`${S}`,label:B[k]}))],onChange:S=>{ae({...se,operator:S})}})}):null,Z&&!J?p.jsx(Z,{isTwoFormula:K,value:{formula1:v.formula1,formula2:v.formula2},onChange:S=>{ae({...se,...S})},showError:m,validResult:M.validatorFormula(v,r,i),unitId:r,subUnitId:i,ruleId:d},e+v.type):null,p.jsx(V.FormLayout,{children:p.jsx(V.Checkbox,{checked:($=v.allowBlank)!=null?$:!0,onChange:()=>{var S;return ae({...se,allowBlank:!((S=v.allowBlank)==null||S)})},children:_.t("dataValidation.panel.allowBlank")})}),p.jsx(wn,{value:te,onChange:Q,extraComponent:M.optionsInput}),p.jsxs("div",{className:"univer-mt-5 univer-flex univer-flex-row univer-justify-end",children:[p.jsx(V.Button,{className:"univer-ml-3",onClick:re,children:_.t("dataValidation.panel.removeRule")}),p.jsx(V.Button,{className:"univer-ml-3",variant:"primary",onClick:z,children:_.t("dataValidation.panel.done")})]})]})}const bn=e=>{const{rule:t,onClick:a,unitId:n,subUnitId:r,disable:i}=e,s=E.useDependency(Y.DataValidatorRegistryService),d=E.useDependency(o.ICommandService),l=E.useDependency(N.IMarkSelectionService),c=s.getValidatorItem(t.type),h=b.useRef(void 0),[g,u]=b.useState(!1),_=E.useDependency(o.ThemeService),v=E.useObservable(_.currentTheme$),T=b.useMemo(()=>{var R;const m=_.getColorFromTheme("primary.600"),y=_.getColorFromTheme("loop-color.2"),f=(R=_.getColorFromTheme(y))!=null?R:m,D=new o.ColorKit(f).toRgb();return{fill:`rgba(${D.r}, ${D.g}, ${D.b}, 0.1)`,stroke:f}},[v]),M=m=>{d.executeCommand(C.RemoveSheetDataValidationCommand.id,{ruleId:t.uid,unitId:n,subUnitId:r}),m.stopPropagation()};return b.useEffect(()=>()=>{var m;h.current&&((m=h.current)==null||m.forEach(y=>{y&&l.removeShape(y)}))},[l]),p.jsxs("div",{className:V.clsx(`
|
1
|
+
"use strict";var Lt=Object.defineProperty;var Pt=(e,t,a)=>t in e?Lt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a;var A=(e,t,a)=>Pt(e,typeof t!="symbol"?t+"":t,a);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("@univerjs/core"),C=require("@univerjs/sheets-data-validation"),p=require("react/jsx-runtime"),V=require("@univerjs/design"),E=require("@univerjs/ui"),b=require("react"),st=require("@univerjs/sheets-formula-ui"),Y=require("@univerjs/data-validation"),oe=require("rxjs"),P=require("@univerjs/engine-render"),H=require("@univerjs/sheets"),jt=require("@univerjs/sheets-numfmt"),N=require("@univerjs/sheets-ui"),nt=require("@univerjs/engine-formula"),xt=e=>{const{isTwoFormula:t=!1,value:a,onChange:n,showError:r,validResult:i}=e,s=E.useDependency(o.LocaleService),d=r?i==null?void 0:i.formula1:"",l=r?i==null?void 0:i.formula2:"";return t?p.jsxs(p.Fragment,{children:[p.jsx(V.FormLayout,{error:d,children:p.jsx(V.Input,{className:"univer-w-full",placeholder:s.t("dataValidation.panel.formulaPlaceholder"),value:a==null?void 0:a.formula1,onChange:c=>{n==null||n({...a,formula1:c})}})}),p.jsx("div",{className:"-univer-mt-2 univer-mb-1 univer-text-sm univer-text-gray-400",children:s.t("dataValidation.panel.formulaAnd")}),p.jsx(V.FormLayout,{error:l,children:p.jsx(V.Input,{className:"univer-w-full",placeholder:s.t("dataValidation.panel.formulaPlaceholder"),value:a==null?void 0:a.formula2,onChange:c=>{n==null||n({...a,formula2:c})}})})]}):p.jsx(V.FormLayout,{error:d,children:p.jsx(V.Input,{className:"univer-w-full",placeholder:s.t("dataValidation.panel.formulaPlaceholder"),value:a==null?void 0:a.formula1,onChange:c=>{n==null||n({formula1:c})}})})};function Ut(e){const{value:t,onChange:a,showError:n,validResult:r}=e,i=E.useDependency(o.LocaleService),s=n?r==null?void 0:r.formula1:"",d=n?r==null?void 0:r.formula2:"",[l,c]=b.useState(!((t==null?void 0:t.formula1)===void 0&&(t==null?void 0:t.formula2)===void 0));return p.jsxs(p.Fragment,{children:[p.jsx(V.FormLayout,{children:p.jsx(V.Checkbox,{checked:l,onChange:h=>{h?c(!0):(c(!1),a==null||a({...t,formula1:void 0,formula2:void 0}))},children:i.t("dataValidation.checkbox.tips")})}),l?p.jsx(V.FormLayout,{label:i.t("dataValidation.checkbox.checked"),error:s,children:p.jsx(V.Input,{className:"univer-w-full",placeholder:i.t("dataValidation.panel.valuePlaceholder"),value:t==null?void 0:t.formula1,onChange:h=>{a==null||a({...t,formula1:h||void 0})}})}):null,l?p.jsx(V.FormLayout,{label:i.t("dataValidation.checkbox.unchecked"),error:d,children:p.jsx(V.Input,{className:"univer-w-full",placeholder:i.t("dataValidation.panel.valuePlaceholder"),value:t==null?void 0:t.formula2,onChange:h=>{a==null||a({...t,formula2:h||void 0})}})}):null]})}function kt(e){var g;const{unitId:t,subUnitId:a,value:n,onChange:r,showError:i,validResult:s}=e,d=i?s==null?void 0:s.formula1:void 0,l=b.useRef(null),[c,h]=b.useState(!1);return E.useSidebarClick(u=>{var v;((v=l.current)==null?void 0:v.isClickOutSide(u))&&h(!1)}),p.jsx(V.FormLayout,{error:d,children:p.jsx(st.FormulaEditor,{ref:l,className:V.clsx("univer-box-border univer-h-8 univer-w-full univer-cursor-pointer univer-items-center univer-rounded-lg univer-bg-white univer-pt-2 univer-transition-colors [&>div:first-child]:univer-px-2.5 [&>div]:univer-h-5 [&>div]:univer-ring-transparent dark:!univer-bg-gray-700 dark:!univer-text-white hover:univer-border-primary-600",V.borderClassName),initValue:(g=n==null?void 0:n.formula1)!=null?g:"=",unitId:t,subUnitId:a,isFocus:c,isSupportAcrossSheet:!0,onChange:u=>{const _=(u!=null?u:"").trim();_!==(n==null?void 0:n.formula1)&&(r==null||r({...n,formula1:_}))},onFocus:()=>h(!0)})})}var ie=function(){return ie=Object.assign||function(e){for(var t,a=1,n=arguments.length;a<n;a++){t=arguments[a];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])}return e},ie.apply(this,arguments)},Ft=function(e,t){var a={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(a[n]=e[n]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,n=Object.getOwnPropertySymbols(e);r<n.length;r++)t.indexOf(n[r])<0&&Object.prototype.propertyIsEnumerable.call(e,n[r])&&(a[n[r]]=e[n[r]]);return a},Se=b.forwardRef(function(e,t){var a=e.icon,n=e.id,r=e.className,i=e.extend,s=Ft(e,["icon","id","className","extend"]),d="univerjs-icon univerjs-icon-".concat(n," ").concat(r||"").trim(),l=b.useRef("_".concat(Wt()));return It(a,"".concat(n),{defIds:a.defIds,idSuffix:l.current},ie({ref:t,className:d},s),i)});function It(e,t,a,n,r){return b.createElement(e.tag,ie(ie({key:t},Nt(e,a,r)),n),(Bt(e,a).children||[]).map(function(i,s){return It(i,"".concat(t,"-").concat(e.tag,"-").concat(s),a,void 0,r)}))}function Nt(e,t,a){var n=ie({},e.attrs);a!=null&&a.colorChannel1&&n.fill==="colorChannel1"&&(n.fill=a.colorChannel1),e.tag==="mask"&&n.id&&(n.id=n.id+t.idSuffix),Object.entries(n).forEach(function(i){var s=i[0],d=i[1];s==="mask"&&typeof d=="string"&&(n[s]=d.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))});var r=t.defIds;return!r||r.length===0||(e.tag==="use"&&n["xlink:href"]&&(n["xlink:href"]=n["xlink:href"]+t.idSuffix),Object.entries(n).forEach(function(i){var s=i[0],d=i[1];typeof d=="string"&&(n[s]=d.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))})),n}function Bt(e,t){var a,n=t.defIds;return!n||n.length===0?e:e.tag==="defs"&&(!((a=e.children)===null||a===void 0)&&a.length)?ie(ie({},e),{children:e.children.map(function(r){return typeof r.attrs.id=="string"&&n&&n.includes(r.attrs.id)?ie(ie({},r),{attrs:ie(ie({},r.attrs),{id:r.attrs.id+t.idSuffix})}):r})}):e}function Wt(){return Math.random().toString(36).substring(2,8)}Se.displayName="UniverIcon";var Ht={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 17 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"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.83062C8.94447 3.57605 9.32281 3.54166 9.57737 3.7538L11.154 5.06767L13.769 2.45278C14.0033 2.21847 14.3832 2.21848 14.6175 2.45279Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M14.1175 9.19746C14.3518 9.43178 14.3518 9.81168 14.1175 10.046L12.5418 11.6217L14.1175 13.1975C14.3518 13.4318 14.3518 13.8117 14.1175 14.046C13.8832 14.2803 13.5033 14.2803 13.269 14.046L11.6933 12.4703L10.1175 14.046C9.88321 14.2803 9.50331 14.2803 9.269 14.046C9.03468 13.8117 9.03468 13.4318 9.269 13.1975L10.8447 11.6217L9.269 10.046C9.03468 9.81168 9.03468 9.43178 9.269 9.19746C9.50331 8.96315 9.88321 8.96315 10.1175 9.19746L11.6933 10.7732L13.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"}}]},Ct=b.forwardRef(function(e,t){return b.createElement(Se,Object.assign({},e,{id:"data-validation-icon",ref:t,icon:Ht}))});Ct.displayName="DataValidationIcon";var $t={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M5.3313 1.4667C5.3313 1.13533 5.59993 0.866699 5.9313 0.866699H10.069C10.4004 0.866699 10.669 1.13533 10.669 1.4667C10.669 1.79807 10.4004 2.0667 10.069 2.0667H5.9313C5.59993 2.0667 5.3313 1.79807 5.3313 1.4667Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M1.09985 3.64443C1.09985 3.31306 1.36848 3.04443 1.69985 3.04443H14.2999C14.6312 3.04443 14.8999 3.31306 14.8999 3.64443C14.8999 3.9758 14.6312 4.24443 14.2999 4.24443H1.69985C1.36848 4.24443 1.09985 3.9758 1.09985 3.64443Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M6.12398 8.30171C6.35829 8.0674 6.73819 8.0674 6.97251 8.30171L8.00007 9.32928L9.02764 8.30171C9.26195 8.0674 9.64185 8.0674 9.87617 8.30171C10.1105 8.53603 10.1105 8.91593 9.87617 9.15024L8.8486 10.1778L9.87617 11.2054C10.1105 11.4397 10.1105 11.8196 9.87617 12.0539C9.64185 12.2882 9.26195 12.2882 9.02764 12.0539L8.00007 11.0263L6.97251 12.0539C6.73819 12.2882 6.35829 12.2882 6.12398 12.0539C5.88966 11.8196 5.88966 11.4397 6.12398 11.2054L7.15154 10.1778L6.12398 9.15024C5.88966 8.91593 5.88966 8.53603 6.12398 8.30171Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M4.75332 5.22217C3.86966 5.22217 3.15332 5.93851 3.15332 6.82217V12.5331C3.15332 13.9691 4.31738 15.1332 5.75332 15.1332H10.2465C11.6825 15.1332 12.8465 13.9691 12.8465 12.5331V6.82217C12.8465 5.93851 12.1302 5.22217 11.2465 5.22217H4.75332ZM4.35332 6.82217C4.35332 6.60125 4.53241 6.42217 4.75332 6.42217H11.2465C11.4674 6.42217 11.6465 6.60125 11.6465 6.82217V12.5331C11.6465 13.3063 11.0197 13.9332 10.2465 13.9332H5.75332C4.98012 13.9332 4.35332 13.3063 4.35332 12.5331V6.82217Z",fillRule:"evenodd",clipRule:"evenodd"}}]},lt=b.forwardRef(function(e,t){return b.createElement(Se,Object.assign({},e,{id:"delete-icon",ref:t,icon:$t}))});lt.displayName="DeleteIcon";var Yt={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M8.6 1.99991C8.60001 1.66854 8.33138 1.39991 8.00001 1.3999C7.66864 1.3999 7.40001 1.66853 7.4 1.9999L7.39996 7.3999H1.9999C1.66853 7.3999 1.3999 7.66853 1.3999 7.9999C1.3999 8.33127 1.66853 8.5999 1.9999 8.5999H7.39995L7.3999 13.9999C7.3999 14.3313 7.66853 14.5999 7.9999 14.5999C8.33127 14.5999 8.5999 14.3313 8.5999 13.9999L8.59995 8.5999H13.9999C14.3313 8.5999 14.5999 8.33127 14.5999 7.9999C14.5999 7.66853 14.3313 7.3999 13.9999 7.3999H8.59996L8.6 1.99991Z"}}]},yt=b.forwardRef(function(e,t){return b.createElement(Se,Object.assign({},e,{id:"increase-icon",ref:t,icon:Yt}))});yt.displayName="IncreaseIcon";var Xt={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M11.3536 6.14645C11.5488 6.34171 11.5488 6.65829 11.3536 6.85355L8.35355 9.85355C8.15829 10.0488 7.84171 10.0488 7.64645 9.85355L4.64645 6.85355C4.45118 6.65829 4.45118 6.34171 4.64645 6.14645C4.84171 5.95118 5.15829 5.95118 5.35355 6.14645L8 8.79289L10.6464 6.14645C10.8417 5.95118 11.1583 5.95118 11.3536 6.14645Z",fillRule:"evenodd",clipRule:"evenodd"}}]},dt=b.forwardRef(function(e,t){return b.createElement(Se,Object.assign({},e,{id:"more-down-icon",ref:t,icon:Xt}))});dt.displayName="MoreDownIcon";var zt={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M4.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"}}]},Rt=b.forwardRef(function(e,t){return b.createElement(Se,Object.assign({},e,{id:"more-up-icon",ref:t,icon:zt}))});Rt.displayName="MoreUpIcon";var Kt={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"mask",attrs:{id:"mask0_622_8",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 4C7 3.44772 6.55228 3 6 3C5.44772 3 5 3.44772 5 4C5 4.55228 5.44772 5 6 5Z"}},{tag:"path",attrs:{d:"M6 9C6.55228 9 7 8.55229 7 8C7 7.44772 6.55228 7 6 7C5.44772 7 5 7.44772 5 8C5 8.55229 5.44772 9 6 9Z"}},{tag:"path",attrs:{d:"M7 12C7 12.5523 6.55228 13 6 13C5.44772 13 5 12.5523 5 12C5 11.4477 5.44772 11 6 11C6.55228 11 7 11.4477 7 12Z"}},{tag:"path",attrs:{d:"M10 5C10.5523 5 11 4.55228 11 4C11 3.44772 10.5523 3 10 3C9.44771 3 9 3.44772 9 4C9 4.55228 9.44771 5 10 5Z"}},{tag:"path",attrs:{d:"M11 8C11 8.55229 10.5523 9 10 9C9.44771 9 9 8.55229 9 8C9 7.44772 9.44771 7 10 7C10.5523 7 11 7.44772 11 8Z"}},{tag:"path",attrs:{d:"M10 13C10.5523 13 11 12.5523 11 12C11 11.4477 10.5523 11 10 11C9.44771 11 9 11.4477 9 12C9 12.5523 9.44771 13 10 13Z"}}]}]},Dt=b.forwardRef(function(e,t){return b.createElement(Se,Object.assign({},e,{id:"sequence-icon",ref:t,icon:Kt}))});Dt.displayName="SequenceIcon";const Re="#ECECEC",Zt=["#FFFFFF","#FEE7E7","#FEF0E6","#EFFBD0","#E4F4FE","#E8ECFD","#F1EAFA","#FDE8F3","#E5E5E5","#FDCECE","#FDC49B","#DEF6A2","#9FDAFF","#D0D9FB","#E3D5F6","#FBD0E8","#656565","#FE4B4B","#FF8C51","#8BBB11","#0B9EFB","#3A60F7","#9E6DE3","#F248A6"],Gt=e=>{const{value:t,onChange:a,disabled:n}=e,[r,i]=b.useState(!1);return p.jsx(V.Dropdown,{align:"start",disabled:n,open:r,onOpenChange:i,overlay:p.jsx("div",{className:"univer-box-border univer-grid univer-w-fit univer-grid-cols-6 univer-flex-wrap univer-gap-2 univer-p-1.5",children:Zt.map(s=>p.jsx("div",{className:V.clsx("univer-box-border univer-size-4 univer-cursor-pointer univer-rounded",V.borderClassName),style:{background:s},onClick:()=>{a(s),i(!1)}},s))}),children:p.jsxs("div",{className:V.clsx("univer-box-border univer-inline-flex univer-h-8 univer-w-16 univer-cursor-pointer univer-items-center univer-justify-between univer-gap-2 univer-rounded-lg univer-bg-white univer-px-2.5 univer-transition-colors univer-duration-200 dark:!univer-bg-gray-700 dark:!univer-text-white hover:univer-border-primary-600",V.borderClassName),children:[p.jsx("div",{className:"univer-box-border univer-h-4 univer-w-4 univer-rounded univer-text-base",style:{background:t}}),p.jsx(dt,{})]})})},gt=e=>{const{item:t,commonProps:a,className:n}=e,{onItemChange:r,onItemDelete:i}=a;return p.jsxs("div",{className:V.clsx("univer-flex univer-items-center univer-gap-2",n),children:[!t.isRef&&p.jsx("div",{className:V.clsx("univer-cursor-move","draggableHandle"),children:p.jsx(Dt,{})}),p.jsx(Gt,{value:t.color,onChange:s=>{r(t.id,t.label,s)}}),p.jsx(V.Input,{disabled:t.isRef,value:t.label,onChange:s=>{r(t.id,s,t.color)}}),t.isRef?null:p.jsx("div",{className:"univer-ml-1 univer-cursor-pointer univer-rounded univer-text-base hover:univer-bg-gray-200",children:p.jsx(lt,{onClick:()=>i(t.id)})})]})};function qt(e){const{value:t,onChange:a=()=>{},unitId:n,subUnitId:r,validResult:i,showError:s,ruleId:d}=e,{formula1:l="",formula2:c=""}=t||{},[h,g]=b.useState(()=>o.isFormulaString(l)?"1":"0"),[u,_]=b.useState(h==="1"?l:"="),[v,T]=b.useState(h==="1"?l:"="),M=E.useDependency(o.LocaleService),m=E.useDependency(Y.DataValidatorRegistryService),y=E.useDependency(Y.DataValidationModel),f=E.useDependency(C.DataValidationFormulaController),[D,R]=b.useState(()=>c.split(",")),I=m.getValidatorItem(o.DataValidationType.LIST),[w,F]=b.useState([]),[W,O]=b.useState(""),x=s?i==null?void 0:i.formula1:"",j=b.useMemo(()=>y.ruleChange$.pipe(oe.debounceTime(16)),[]),U=E.useObservable(j),B=E.useEvent(a);b.useEffect(()=>{(async()=>{await new Promise(S=>{setTimeout(()=>S(!0),100)});const L=y.getRuleById(n,r,d),$=L==null?void 0:L.formula1;if(o.isFormulaString($)&&I&&L){const S=await I.getListAsync(L,n,r);F(S)}})()},[y,U,I,d,r,n]),b.useEffect(()=>{o.isFormulaString(l)&&l!==v&&(_(l),T(v))},[v,l]);const[K,z]=b.useState(()=>{const L=h!=="1"?C.deserializeListOptions(l):[],$=c.split(",");return L.map((S,k)=>({label:S,color:$[k]||Re,isRef:!1,id:o.Tools.generateRandomId(4)}))}),ee=(L,$,S)=>{const k=K.find(X=>X.id===L);k&&(k.label=$,k.color=S,z([...K]))},ae=L=>{const $=K.findIndex(S=>S.id===L);$!==-1&&(K.splice($,1),z([...K]))},re=c.split(","),se=b.useMemo(()=>w.map((L,$)=>({label:L,color:re[$]||Re,id:`${$}`,isRef:!0})),[re,w]),q=(L,$,S)=>{const k=[...D];k[+L]=S,R(k),B({formula1:l,formula2:k.join(",")})},Z=()=>{z([...K,{label:"",color:Re,isRef:!1,id:o.Tools.generateRandomId(4)}])};b.useEffect(()=>{if(h==="1")return;const L=new Set,$=[];K.map(S=>({labelList:S.label.split(","),item:S})).forEach(({item:S,labelList:k})=>{k.forEach(X=>{L.has(X)||(L.add(X),$.push({label:X,color:S.color}))})}),B({formula1:C.serializeListOptions($.map(S=>S.label)),formula2:$.map(S=>S.color===Re?"":S.color).join(",")})},[K,B,h,v,D]);const ce=E.useEvent(async L=>{if(!o.isFormulaString(L)){B==null||B({formula1:"",formula2:c});return}f.getFormulaRefCheck(L)?(B==null||B({formula1:o.isFormulaString(L)?L:"",formula2:c}),O("")):(B==null||B({formula1:"",formula2:c}),_("="),O(M.t("dataValidation.validFail.formulaError")))}),te=b.useRef(null),[Q,J]=b.useState(!1);return E.useSidebarClick(L=>{var S;((S=te.current)==null?void 0:S.isClickOutSide(L))&&J(!1)}),p.jsxs(p.Fragment,{children:[p.jsx(V.FormLayout,{label:M.t("dataValidation.list.options"),children:p.jsxs(V.RadioGroup,{value:h,onChange:L=>{g(L),_(v),L==="1"&&B({formula1:v==="="?"":v,formula2:D.join(",")})},children:[p.jsx(V.Radio,{value:"0",children:M.t("dataValidation.list.customOptions")}),p.jsx(V.Radio,{value:"1",children:M.t("dataValidation.list.refOptions")})]})}),h==="1"?p.jsxs(V.FormLayout,{error:x||W||void 0,children:[p.jsx(st.FormulaEditor,{ref:te,className:V.clsx("univer-box-border univer-h-8 univer-w-full univer-cursor-pointer univer-items-center univer-rounded-lg univer-bg-white univer-pt-2 univer-transition-colors [&>div:first-child]:univer-px-2.5 [&>div]:univer-h-5 [&>div]:univer-ring-transparent dark:!univer-bg-gray-700 dark:!univer-text-white hover:univer-border-primary-600",V.borderClassName),initValue:u,unitId:n,subUnitId:r,isFocus:Q,isSupportAcrossSheet:!0,onFocus:()=>J(!0),onChange:(L="")=>{const $=(L!=null?L:"").trim();T($),ce($)}}),se.length>0&&p.jsx("div",{className:"univer-mt-3",children:se.map(L=>p.jsx(gt,{className:"univer-mb-3",item:L,commonProps:{onItemChange:q}},L.id))})]}):p.jsx(V.FormLayout,{error:x,children:p.jsxs("div",{className:"-univer-mt-3",children:[p.jsx(V.DraggableList,{list:K,onListChange:z,rowHeight:28,margin:[0,12],draggableHandle:".draggableHandle",itemRender:L=>p.jsx(gt,{item:L,commonProps:{onItemChange:ee,onItemDelete:ae}},L.id),idKey:"id"}),p.jsxs("a",{className:"univer-flex univer-w-fit univer-cursor-pointer univer-flex-row univer-items-center univer-rounded univer-p-1 univer-px-2 univer-text-sm univer-text-primary dark:hover:!univer-bg-gray-800 hover:univer-bg-primary-50",onClick:Z,children:[p.jsx(yt,{className:"univer-mr-1"}),M.t("dataValidation.list.add")]})]})})]})}const Jt=[[C.CUSTOM_FORMULA_INPUT_NAME,kt],[C.BASE_FORMULA_INPUT_NAME,xt],[C.LIST_FORMULA_INPUT_NAME,qt],[C.CHECKBOX_FORMULA_INPUT_NAME,Ut]];var Qt=Object.getOwnPropertyDescriptor,en=(e,t,a,n)=>{for(var r=n>1?void 0:n?Qt(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},tn=(e,t)=>(a,n)=>t(a,n,e);exports.BaseSheetDataValidatorView=class{constructor(t){A(this,"canvasRender",null);A(this,"dropdownType");A(this,"optionsInput");A(this,"formulaInput",C.LIST_FORMULA_INPUT_NAME);this.injector=t}};exports.BaseSheetDataValidatorView=en([tn(0,o.Inject(o.Injector))],exports.BaseSheetDataValidatorView);var nn=Object.getOwnPropertyDescriptor,an=(e,t,a,n)=>{for(var r=n>1?void 0:n?nn(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},pt=(e,t)=>(a,n)=>t(a,n,e);let he=class extends o.Disposable{constructor(t,a){super();A(this,"_open$",new oe.BehaviorSubject(!1));A(this,"open$",this._open$.pipe(oe.distinctUntilChanged()));A(this,"_activeRule");A(this,"_activeRule$",new oe.BehaviorSubject(void 0));A(this,"activeRule$",this._activeRule$.asObservable());A(this,"_closeDisposable",null);this._univerInstanceService=t,this._sidebarService=a,this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(o.UniverInstanceType.UNIVER_SHEET).pipe(oe.filter(n=>!n)).subscribe(()=>{this.close()})),this.disposeWithMe(this._sidebarService.sidebarOptions$.subscribe(n=>{n.id===Fe&&(n.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=o.toDisposable(()=>{t.dispose(),this._closeDisposable=null})}setActiveRule(t){this._activeRule=t,this._activeRule$.next(t)}};he=an([pt(0,o.IUniverInstanceService),pt(1,E.ISidebarService)],he);const ct="sheets-data-validation-ui.config",ke={};var rn=Object.getOwnPropertyDescriptor,on=(e,t,a,n)=>{for(var r=n>1?void 0:n?rn(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},Ie=(e,t)=>(a,n)=>t(a,n,e);let we=class extends o.Disposable{constructor(e,t,a,n,r,i){super(),this._sheetInterceptorService=e,this._dataValidationModel=t,this._dataValidatorRegistryService=a,this._dialogService=n,this._localeService=r,this._sheetsDataValidationValidatorService=i,this._initEditorBridgeInterceptor()}_initEditorBridgeInterceptor(){this._sheetInterceptorService.writeCellInterceptor.intercept(H.VALIDATE_CELL,{handler:async(e,t,a)=>{const n=await e,{row:r,col:i,unitId:s,subUnitId:d}=t,l=this._dataValidationModel.getRuleIdByLocation(s,d,r,i),c=l?this._dataValidationModel.getRuleById(s,d,l):void 0;if(n===!1)return a(Promise.resolve(!1));if(!c||c.errorStyle!==o.DataValidationErrorStyle.STOP)return a(Promise.resolve(!0));const h=this._dataValidatorRegistryService.getValidatorItem(c.type);return!h||await this._sheetsDataValidationValidatorService.validatorCell(s,d,r,i)===o.DataValidationStatus.VALID?a(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:r,col:i,unitId:s,subUnitId:d})},footer:{title:b.createElement(V.Button,{variant:"primary",onClick:()=>this._dialogService.close("reject-input-dialog")},this._localeService.t("dataValidation.alert.ok"))},onClose:()=>{this._dialogService.close("reject-input-dialog")}}),a(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:b.createElement(V.Button,{variant:"primary",onClick:()=>this._dialogService.close("reject-input-dialog")},this._localeService.t("dataValidation.alert.ok"))},onClose:()=>{this._dialogService.close("reject-input-dialog")}})}};we=on([Ie(0,o.Inject(H.SheetInterceptorService)),Ie(1,o.Inject(C.SheetDataValidationModel)),Ie(2,o.Inject(Y.DataValidatorRegistryService)),Ie(3,E.IDialogService),Ie(4,o.Inject(o.LocaleService)),Ie(5,o.Inject(C.SheetsDataValidationValidatorService))],we);var sn=Object.getOwnPropertyDescriptor,ln=(e,t,a,n)=>{for(var r=n>1?void 0:n?sn(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},le=(e,t)=>(a,n)=>t(a,n,e);const Xe=e=>{if(e==null||typeof e=="boolean")return;if(typeof e=="number"||!Number.isNaN(+e))return o.dayjs(o.numfmt.format("yyyy-MM-dd HH:mm:ss",Number(e)));const t=o.dayjs(e);if(t.isValid())return t};function dn(e,t){const a=jt.getPatternType(t);if(e===a)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 o.Disposable{constructor(t,a,n,r,i,s,d,l,c,h,g){super();A(this,"_activeDropdown");A(this,"_activeDropdown$",new oe.Subject);A(this,"_currentPopup",null);A(this,"activeDropdown$",this._activeDropdown$.asObservable());A(this,"_zenVisible",!1);this._univerInstanceService=t,this._dataValidatorRegistryService=a,this._zenZoneService=n,this._dataValidationModel=r,this._sheetsSelectionsService=i,this._cellDropdownManagerService=s,this._sheetDataValidationModel=d,this._commandService=l,this._editorBridgeService=c,this._injector=h,this._configService=g,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,a,n,r){const i=t?this._univerInstanceService.getUnit(t,o.UniverInstanceType.UNIVER_SHEET):this._univerInstanceService.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET);if(!i)return;const s=a?i.getSheetBySheetId(a):i.getActiveSheet();if(!s)return;const d=this._dataValidationModel.getRuleByLocation(i.getUnitId(),s.getSheetId(),n,r);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(a=>!(a.primary&&this._getDropdownByCell(a.primary.unitId,a.primary.sheetId,a.primary.actualRow,a.primary.actualColumn)))&&this.hideDropdown()}))}showDropdown(t){var T,M,m,y;const{location:a}=t,{row:n,col:r,unitId:i,subUnitId:s,workbook:d,worksheet:l}=a;if(this._currentPopup&&this._currentPopup.dispose(),this._zenVisible)return;this._activeDropdown=t,this._activeDropdown$.next(this._activeDropdown);const c=this._sheetDataValidationModel.getRuleByLocation(i,s,n,r);if(!c)return;const h=this._dataValidatorRegistryService.getValidatorItem(c.type);if(!(h!=null&&h.dropdownType))return;let g;const u=async(f,D)=>{var j,U,B;if(!f)return!0;const R=f,I=l.getCell(n,r),w=R.format(D==="date"?"YYYY-MM-DD 00:00:00":"YYYY-MM-DD HH:mm:ss"),F=(j=o.numfmt.parseDate(w))==null?void 0:j.v,W=D==="time"?F%1:F,O=d.getStyles().getStyleByCell(I),x=(B=(U=O==null?void 0:O.n)==null?void 0:U.pattern)!=null?B:"";return c.errorStyle!==o.DataValidationErrorStyle.STOP||await h.validator({value:W,unitId:i,subUnitId:s,row:n,column:r,worksheet:l,workbook:d,interceptValue:w.replace("Z","").replace("T"," "),t:o.CellValueType.NUMBER},c)?(await this._commandService.executeCommand(N.SetCellEditVisibleOperation.id,{visible:!1,eventType:P.DeviceInputEventType.Keyboard,unitId:i,keycode:E.KeyCode.ESC}),await this._commandService.executeCommand(H.SetRangeValuesCommand.id,{unitId:i,subUnitId:s,range:{startColumn:r,endColumn:r,startRow:n,endRow:n},value:{v:W,t:2,p:null,f:null,si:null,s:{n:{pattern:dn(D,x)}}}}),!0):(this._injector.has(we)&&this._injector.get(we).showReject(h.getRuleFinalError(c,{row:n,col:r,unitId:i,subUnitId:s})),!1)};let _;switch(h.dropdownType){case Y.DataValidatorDropdownType.DATE:{const f=C.getCellValueOrigin(l.getCellRaw(n,r)),D=Xe(f),R=!!((T=c.bizInfo)!=null&&T.showTime);_={location:a,type:"datepicker",props:{showTime:R,onChange:I=>u(I,R?"datetime":"date"),defaultValue:D,patternType:"date"}};break}case Y.DataValidatorDropdownType.TIME:{const f=C.getCellValueOrigin(l.getCellRaw(n,r)),D=Xe(f);_={location:a,type:"datepicker",props:{onChange:R=>u(R,"time"),defaultValue:D,patternType:"time"}};break}case Y.DataValidatorDropdownType.DATETIME:{const f=C.getCellValueOrigin(l.getCellRaw(n,r)),D=Xe(f);_={location:a,type:"datepicker",props:{onChange:R=>u(R,"datetime"),defaultValue:D,patternType:"datetime"}};break}case Y.DataValidatorDropdownType.LIST:case Y.DataValidatorDropdownType.MULTIPLE_LIST:{const f=h.dropdownType===Y.DataValidatorDropdownType.MULTIPLE_LIST,D=async O=>{const x=C.serializeListOptions(O),j={unitId:i,subUnitId:s,range:{startColumn:r,endColumn:r,startRow:n,endRow:n},value:{v:x,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:i,keycode:E.KeyCode.ESC}),this._commandService.executeCommand(H.SetRangeValuesCommand.id,j),!f},R=(c==null?void 0:c.renderMode)===o.DataValidationRenderMode.CUSTOM||(c==null?void 0:c.renderMode)===void 0,I=h.getListWithColor(c,i,s),w=C.getDataValidationCellValue(l.getCellRaw(n,r)),F=()=>{this._commandService.executeCommand(_e.id,{ruleId:c.uid}),g==null||g.dispose()},W=I.map(O=>({label:O.label,value:O.label,color:R||O.color?O.color:"transparent"}));_={location:a,type:"list",props:{onChange:O=>D(O),options:W,onEdit:F,defaultValue:w,multiple:f,showEdit:(m=(M=this._configService.getConfig(ct))==null?void 0:M.showEditOnDropdown)!=null?m:!0}};break}case Y.DataValidatorDropdownType.CASCADE:{_={type:"cascader",props:{onChange:D=>{const R={unitId:i,subUnitId:s,range:{startColumn:r,endColumn:r,startRow:n,endRow:n},value:{v:D.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:i,keycode:E.KeyCode.ESC}),this._commandService.syncExecuteCommand(H.SetRangeValuesCommand.id,R),!0},defaultValue:C.getDataValidationCellValue(l.getCellRaw(n,r)).split("/"),options:JSON.parse((y=c.formula1)!=null?y:"[]")},location:a};break}case Y.DataValidatorDropdownType.COLOR:{_={type:"color",props:{onChange:D=>{const R={unitId:i,subUnitId:s,range:{startColumn:r,endColumn:r,startRow:n,endRow:n},value:{v:D,p:null,f:null,si:null}};return this._editorBridgeService.isVisible().visible&&this._commandService.syncExecuteCommand(N.SetCellEditVisibleOperation.id,{visible:!1,eventType:P.DeviceInputEventType.Keyboard,unitId:i,keycode:E.KeyCode.ESC}),this._commandService.syncExecuteCommand(H.SetRangeValuesCommand.id,R),!0},defaultValue:C.getDataValidationCellValue(l.getCellRaw(n,r))},location:a};break}default:throw new Error("[DataValidationDropdownManagerService]: unknown type!")}if(g=this._cellDropdownManagerService.showDropdown({..._,onHide:()=>{this._activeDropdown=null,this._activeDropdown$.next(null)}}),!g)throw new Error("[DataValidationDropdownManagerService]: cannot show dropdown!");const v=new o.DisposableCollection;v.add(g),v.add({dispose:()=>{var f,D;(D=(f=this._activeDropdown)==null?void 0:f.onHide)==null||D.call(f)}}),this._currentPopup=v}hideDropdown(){this._activeDropdown&&(this._currentPopup&&this._currentPopup.dispose(),this._currentPopup=null,this._activeDropdown=null,this._activeDropdown$.next(null))}showDataValidationDropdown(t,a,n,r,i){const s=this._univerInstanceService.getUnit(t,o.UniverInstanceType.UNIVER_SHEET);if(!s)return;const d=s.getSheetBySheetId(a);if(!d)return;const l=this._dataValidationModel.getRuleByLocation(s.getUnitId(),d.getSheetId(),n,r);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:n,col:r,unitId:t,subUnitId:a},onHide:i})}};fe=ln([le(0,o.IUniverInstanceService),le(1,o.Inject(Y.DataValidatorRegistryService)),le(2,E.IZenZoneService),le(3,o.Inject(C.SheetDataValidationModel)),le(4,o.Inject(H.SheetsSelectionsService)),le(5,o.Inject(N.ISheetCellDropdownManagerService)),le(6,o.Inject(C.SheetDataValidationModel)),le(7,o.ICommandService),le(8,N.IEditorBridgeService),le(9,o.Inject(o.Injector)),le(10,o.IConfigService)],fe);const Fe="DataValidationPanel",_e={id:"data-validation.operation.open-validation-panel",type:o.CommandType.OPERATION,handler(e,t){if(!t)return!1;const{ruleId:a,isAdd:n}=t,r=e.get(he),i=e.get(Y.DataValidationModel),s=e.get(o.IUniverInstanceService),d=e.get(E.ISidebarService),l=H.getSheetCommandTarget(s);if(!l)return!1;const{unitId:c,subUnitId:h}=l,g=a?i.getRuleById(c,h,a):void 0;r.open(),r.setActiveRule(g&&{unitId:c,subUnitId:h,rule:g});const u=d.open({id:Fe,header:{title:n?"dataValidation.panel.addTitle":"dataValidation.panel.title"},children:{label:Fe},width:312,onClose:()=>r.close()});return r.setCloseDisposable(u),!0}},ut={id:"data-validation.operation.close-validation-panel",type:o.CommandType.OPERATION,handler(e){return e.get(he).close(),!0}},wt={id:"data-validation.operation.toggle-validation-panel",type:o.CommandType.OPERATION,handler(e){const t=e.get(o.ICommandService),a=e.get(he);return a.open(),a.isOpen?t.executeCommand(ut.id):t.executeCommand(_e.id),!0}},$e={type:o.CommandType.OPERATION,id:"sheet.operation.show-data-validation-dropdown",handler(e,t){if(!t)return!1;const a=e.get(fe),{unitId:n,subUnitId:r,row:i,column:s}=t,d=a.activeDropdown,l=d==null?void 0:d.location;return l&&l.unitId===n&&l.subUnitId===r&&l.row===i&&l.col===s||a.showDataValidationDropdown(n,r,i,s),!0}},Vt={type:o.CommandType.OPERATION,id:"sheet.operation.hide-data-validation-dropdown",handler(e,t){return t?(e.get(fe).hideDropdown(),!0):!1}},Ye={type:o.CommandType.COMMAND,id:"data-validation.command.addRuleAndOpen",handler(e){const t=e.get(o.IUniverInstanceService),a=H.getSheetCommandTarget(t);if(!a)return!1;const{workbook:n,worksheet:r}=a,i=C.createDefaultNewRule(e),s=e.get(o.ICommandService),d=n.getUnitId(),l=r.getSheetId(),c={rule:i,unitId:d,subUnitId:l};return s.syncExecuteCommand(C.AddSheetDataValidationCommand.id,c)?(s.syncExecuteCommand(_e.id,{ruleId:i.uid,isAdd:!0}),!0):!1}};var cn=Object.getOwnPropertyDescriptor,un=(e,t,a,n)=>{for(var r=n>1?void 0:n?cn(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},Ce=(e,t)=>(a,n)=>t(a,n,e);const pe="SHEET_DATA_VALIDATION_ALERT";let Ae=class extends o.Disposable{constructor(e,t,a,n,r,i){super(),this._hoverManagerService=e,this._cellAlertManagerService=t,this._univerInstanceService=a,this._localeService=n,this._zenZoneService=r,this._dataValidationModel=i,this._init()}_init(){this._initCellAlertPopup(),this._initZenService()}_initCellAlertPopup(){this.disposeWithMe(this._hoverManagerService.currentCell$.pipe(oe.debounceTime(100)).subscribe(e=>{var t;if(e){const a=this._univerInstanceService.getUnit(e.location.unitId,o.UniverInstanceType.UNIVER_SHEET),n=a.getSheetBySheetId(e.location.subUnitId);if(!n)return;const r=this._dataValidationModel.getRuleByLocation(e.location.unitId,e.location.subUnitId,e.location.row,e.location.col);if(!r){this._cellAlertManagerService.removeAlert(pe);return}if(this._dataValidationModel.validator(r,{...e.location,workbook:a,worksheet:n})===o.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(r.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(r,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)}))}};Ae=un([Ce(0,o.Inject(N.HoverManagerService)),Ce(1,o.Inject(N.CellAlertManagerService)),Ce(2,o.IUniverInstanceService),Ce(3,o.Inject(o.LocaleService)),Ce(4,E.IZenZoneService),Ce(5,o.Inject(C.SheetDataValidationModel))],Ae);var hn=Object.getOwnPropertyDescriptor,gn=(e,t,a,n)=>{for(var r=n>1?void 0:n?hn(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},ze=(e,t)=>(a,n)=>t(a,n,e);let Ve=class extends o.Disposable{constructor(e,t,a){super(),this._autoFillService=e,this._sheetDataValidationModel=t,this._injector=a,this._initAutoFill()}_initAutoFill(){const e=()=>({redos:[],undos:[]}),t=(n,r)=>{const{source:i,target:s,unitId:d,subUnitId:l}=n,c=this._sheetDataValidationModel.getRuleObjectMatrix(d,l).clone(),h=N.virtualizeDiscreteRanges([i,s]),[g,u]=h.ranges,{mapFunc:_}=h,v={row:g.startRow,col:g.startColumn},T=N.getAutoFillRepeatRange(g,u),M=new o.ObjectMatrix,m=new Set;T.forEach(I=>{const w=I.repeatStartCell,F=I.relativeRange,W={startRow:v.row,startColumn:v.col,endColumn:v.col,endRow:v.row},O={startRow:w.row,startColumn:w.col,endColumn:w.col,endRow:w.row};o.Range.foreach(F,(x,j)=>{const U=o.Rectangle.getPositionRange({startRow:x,startColumn:j,endColumn:j,endRow:x},W),{row:B,col:K}=_(U.startRow,U.startColumn),z=this._sheetDataValidationModel.getRuleIdByLocation(d,l,B,K)||"",ee=o.Rectangle.getPositionRange({startRow:x,startColumn:j,endColumn:j,endRow:x},O),{row:ae,col:re}=_(ee.startRow,ee.startColumn);M.setValue(ae,re,z),m.add(z)})});const y=Array.from(m).map(I=>({id:I,ranges:o.queryObjectMatrix(M,w=>w===I)}));c.addRangeRules(y);const f=c.diff(this._sheetDataValidationModel.getRules(d,l)),{redoMutations:D,undoMutations:R}=C.getDataValidationDiffMutations(d,l,f,this._injector,"patched",r===N.APPLY_TYPE.ONLY_FORMAT);return{undos:R,redos:D}},a={id:C.DATA_VALIDATION_PLUGIN_NAME,onBeforeFillData:n=>{const{source:r,unitId:i,subUnitId:s}=n;for(const d of r.rows)for(const l of r.cols){const c=this._sheetDataValidationModel.getRuleByLocation(i,s,d,l);if(c&&c.type===o.DataValidationType.CHECKBOX){this._autoFillService.setDisableApplyType(N.APPLY_TYPE.SERIES,!0);return}}},onFillData:(n,r,i)=>i===N.APPLY_TYPE.COPY||i===N.APPLY_TYPE.ONLY_FORMAT||i===N.APPLY_TYPE.SERIES?t(n,i):e(),onAfterFillData:()=>{}};this.disposeWithMe(this._autoFillService.addHook(a))}};Ve=gn([ze(0,N.IAutoFillService),ze(1,o.Inject(C.SheetDataValidationModel)),ze(2,o.Inject(o.Injector))],Ve);var pn=Object.getOwnPropertyDescriptor,vn=(e,t,a,n)=>{for(var r=n>1?void 0:n?pn(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},Ke=(e,t)=>(a,n)=>t(a,n,e);let Ee=class extends o.Disposable{constructor(t,a,n){super();A(this,"_copyInfo");this._sheetClipboardService=t,this._sheetDataValidationModel=a,this._injector=n,this._initCopyPaste()}_initCopyPaste(){this._sheetClipboardService.addClipboardHook({id:C.DATA_VALIDATION_PLUGIN_NAME,onBeforeCopy:(t,a,n)=>this._collect(t,a,n),onPasteCells:(t,a,n,r)=>{const{copyType:i=N.COPY_TYPE.COPY,pasteType:s}=r,{range:d}=t||{},{range:l,unitId:c,subUnitId:h}=a;return this._generateMutations(l,{copyType:i,pasteType:s,copyRange:d,unitId:c,subUnitId:h})}})}_collect(t,a,n){const r=new o.ObjectMatrix;this._copyInfo={unitId:t,subUnitId:a,matrix:r};const i=this._injector.invoke(l=>H.rangeToDiscreteRange(n,l,t,a));if(!i)return;const{rows:s,cols:d}=i;s.forEach((l,c)=>{d.forEach((h,g)=>{const u=this._sheetDataValidationModel.getRuleIdByLocation(t,a,l,h);r.setValue(c,g,u!=null?u:"")})})}_generateMutations(t,a){if(!this._copyInfo)return{redos:[],undos:[]};if(a.copyType===N.COPY_TYPE.CUT)return this._copyInfo=null,{redos:[],undos:[]};if(!this._copyInfo||!this._copyInfo.matrix.getSizeOf()||!a.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(a.pasteType))return{redos:[],undos:[]};const{unitId:r,subUnitId:i}=this._copyInfo;if(a.unitId!==r||i!==a.subUnitId){const s=this._sheetDataValidationModel.getRuleObjectMatrix(a.unitId,a.subUnitId).clone(),d=new o.ObjectMatrix,l=new Set,{ranges:[c,h],mapFunc:g}=N.virtualizeDiscreteRanges([a.copyRange,t]),u=N.getRepeatRange(c,h,!0),_=new Map;u.forEach(({startRange:m})=>{var y;(y=this._copyInfo)==null||y.matrix.forValue((f,D,R)=>{const I=o.Rectangle.getPositionRange({startRow:f,endRow:f,startColumn:D,endColumn:D},m),w=`${i}-${R}`,F=this._sheetDataValidationModel.getRuleById(r,i,R);!this._sheetDataValidationModel.getRuleById(a.unitId,a.subUnitId,w)&&F&&_.set(w,{...F,uid:w});const{row:W,col:O}=g(I.startRow,I.startColumn);l.add(w),d.setValue(W,O,w)})});const v=Array.from(l).map(m=>({id:m,ranges:o.queryObjectMatrix(d,y=>y===m)}));s.addRangeRules(v);const{redoMutations:T,undoMutations:M}=C.getDataValidationDiffMutations(a.unitId,a.subUnitId,s.diffWithAddition(this._sheetDataValidationModel.getRules(a.unitId,a.subUnitId),_.values()),this._injector,"patched",!1);return{redos:T,undos:M}}else{const s=this._sheetDataValidationModel.getRuleObjectMatrix(r,i).clone(),d=new o.ObjectMatrix,l=new Set,{ranges:[c,h],mapFunc:g}=N.virtualizeDiscreteRanges([a.copyRange,t]);N.getRepeatRange(c,h,!0).forEach(({startRange:M})=>{var m;(m=this._copyInfo)==null||m.matrix.forValue((y,f,D)=>{const R=o.Rectangle.getPositionRange({startRow:y,endRow:y,startColumn:f,endColumn:f},M),{row:I,col:w}=g(R.startRow,R.startColumn);d.setValue(I,w,D),l.add(D)})});const _=Array.from(l).map(M=>({id:M,ranges:o.queryObjectMatrix(d,m=>m===M)}));s.addRangeRules(_);const{redoMutations:v,undoMutations:T}=C.getDataValidationDiffMutations(r,i,s.diff(this._sheetDataValidationModel.getRules(r,i)),this._injector,"patched",!1);return{redos:v,undos:T}}}};Ee=vn([Ke(0,N.ISheetClipboardService),Ke(1,o.Inject(C.SheetDataValidationModel)),Ke(2,o.Inject(o.Injector))],Ee);var mn=Object.getOwnPropertyDescriptor,fn=(e,t,a,n)=>{for(var r=n>1?void 0:n?mn(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},Ze=(e,t)=>(a,n)=>t(a,n,e);let Me=class extends o.Disposable{constructor(e,t,a){super(),this._localeService=e,this._commandService=t,this._sheetPermissionCheckController=a,this._commandExecutedListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.beforeCommandExecuted(e=>{e.id===C.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===C.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")))}))}};Me=fn([Ze(0,o.Inject(o.LocaleService)),Ze(1,o.ICommandService),Ze(2,o.Inject(H.SheetPermissionCheckController))],Me);const Et="sheet.menu.data-validation";function Sn(e){return{id:Et,type:E.MenuItemType.SUBITEMS,icon:"DataValidationIcon",tooltip:"dataValidation.title",hidden$:E.getMenuHiddenObservable(e,o.UniverInstanceType.UNIVER_SHEET),disabled$:N.getCurrentRangeDisable$(e,{workbookTypes:[H.WorkbookEditablePermission],worksheetTypes:[H.WorksheetSetCellStylePermission,H.WorksheetEditPermission],rangeTypes:[H.RangeProtectionPermissionEditPoint]})}}function _n(e){return{id:_e.id,title:"dataValidation.panel.title",type:E.MenuItemType.BUTTON}}function In(e){return{id:Ye.id,title:"dataValidation.panel.add",type:E.MenuItemType.BUTTON}}const Cn={[E.RibbonDataGroup.RULES]:{[Et]:{order:0,menuItemFactory:Sn,[_e.id]:{order:0,menuItemFactory:_n},[Ye.id]:{order:1,menuItemFactory:In}}}};var yn=Object.getOwnPropertyDescriptor,Mt=(e,t,a,n)=>{for(var r=n>1?void 0:n?yn(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},G=(e,t)=>(a,n)=>t(a,n,e);const bt={tr:{size:6,color:"#fe4b4b"}};let be=class extends o.RxDisposable{constructor(e,t,a,n,r,i,s,d,l,c,h){super(),this._commandService=e,this._menuManagerService=t,this._renderManagerService=a,this._univerInstanceService=n,this._autoHeightController=r,this._dropdownManagerService=i,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(Cn)}_initDropdown(){this._editorBridgeService&&this.disposeWithMe(this._editorBridgeService.visible$.subscribe(e=>{var a;if(!e.visible){((a=this._dropdownManagerService.activeDropdown)==null?void 0:a.trigger)==="editor-bridge"&&this._dropdownManagerService.hideDropdown();return}const t=this._editorBridgeService.getEditCellState();if(t){const{unitId:n,sheetId:r,row:i,column:s}=t,d=this._univerInstanceService.getUniverSheetInstance(n);if(!d)return;const l=this._sheetDataValidationModel.getRuleByLocation(n,r,i,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===n&&u.subUnitId===r&&u.row===i&&u.col===s)return;this._dropdownManagerService.showDropdown({location:{unitId:n,subUnitId:r,row:i,col:s,workbook:d,worksheet:h},trigger:"editor-bridge",closeOnOutSide:!1})}}))}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(H.INTERCEPTOR_POINT.CELL_CONTENT,{effect:o.InterceptorEffectEnum.Style,priority:H.InterceptCellContentPriority.DATA_VALIDATION,handler:(e,t,a)=>{var m,y,f,D,R;const{row:n,col:r,unitId:i,subUnitId:s,workbook:d,worksheet:l}=t,c=this._sheetDataValidationModel.getRuleIdByLocation(i,s,n,r);if(!c)return a(e);const h=this._sheetDataValidationModel.getRuleById(i,s,c);if(!h)return a(e);const g=(m=this._dataValidationCacheService.getValue(i,s,n,r))!=null?m:o.DataValidationStatus.VALID,u=this._dataValidatorRegistryService.getValidatorItem(h.type),_=t.rawData;let v;const T={get value(){var I;return v!==void 0||(v=(I=C.getCellValueOrigin(_))!=null?I:null),v}},M={get value(){var I;return`${(I=T.value)!=null?I:""}`}};return(!e||e===t.rawData)&&(e={...t.rawData}),e.markers={...e==null?void 0:e.markers,...g===o.DataValidationStatus.INVALID?bt:null},e.customRender=[...(y=e==null?void 0:e.customRender)!=null?y:[],...u!=null&&u.canvasRender?[u.canvasRender]:[]],e.fontRenderExtension={...e==null?void 0:e.fontRenderExtension,isSkip:((f=e==null?void 0:e.fontRenderExtension)==null?void 0:f.isSkip)||((D=u==null?void 0:u.skipDefaultFontRender)==null?void 0:D.call(u,h,T.value,t))},e.interceptorStyle={...e==null?void 0:e.interceptorStyle,...u==null?void 0:u.getExtraStyle(h,M.value,{get style(){const I=d.getStyles();return(typeof(e==null?void 0:e.s)=="string"?I.get(e==null?void 0:e.s):e==null?void 0:e.s)||{}}},n,r)},e.interceptorAutoHeight=()=>{var W,O,x,j,U,B;const I=(O=(W=this._renderManagerService.getRenderById(i))==null?void 0:W.with(N.SheetSkeletonManagerService).getSkeletonParam(s))==null?void 0:O.skeleton;if(!I)return;const w=I.worksheet.getMergedCell(n,r),F={data:e,style:I.getStyles().getStyleByCell(e),primaryWithCoord:I.getCellWithCoordByIndex((x=w==null?void 0:w.startRow)!=null?x:n,(j=w==null?void 0:w.startColumn)!=null?j:r),unitId:i,subUnitId:s,row:n,col:r,workbook:d,worksheet:l};return(B=(U=u==null?void 0:u.canvasRender)==null?void 0:U.calcCellAutoHeight)==null?void 0:B.call(U,F)},e.interceptorAutoWidth=()=>{var W,O,x,j,U,B;const I=(O=(W=this._renderManagerService.getRenderById(i))==null?void 0:W.with(N.SheetSkeletonManagerService).getSkeletonParam(s))==null?void 0:O.skeleton;if(!I)return;const w=I.worksheet.getMergedCell(n,r),F={data:e,style:I.getStyles().getStyleByCell(e),primaryWithCoord:I.getCellWithCoordByIndex((x=w==null?void 0:w.startRow)!=null?x:n,(j=w==null?void 0:w.startColumn)!=null?j:r),unitId:i,subUnitId:s,row:n,col:r,workbook:d,worksheet:l};return(B=(U=u==null?void 0:u.canvasRender)==null?void 0:U.calcCellAutoWidth)==null?void 0:B.call(U,F)},e.coverable=((R=e==null?void 0:e.coverable)!=null?R:!0)&&!(h.type===o.DataValidationType.LIST||h.type===o.DataValidationType.LIST_MULTIPLE),a(e)}}))}_initAutoHeight(){this._sheetDataValidationModel.ruleChange$.pipe(oe.filter(e=>e.source==="command"),oe.bufferTime(100)).subscribe(e=>{if(e.length===0)return;const t=[];if(e.forEach(a=>{var n;(a.rule.type===o.DataValidationType.LIST_MULTIPLE||a.rule.type===o.DataValidationType.LIST)&&(n=a.rule)!=null&&n.ranges&&t.push(...a.rule.ranges)}),t.length){const a=this._autoHeightController.getUndoRedoParamsOfAutoHeight(t);o.sequenceExecute(a.redos,this._commandService)}})}};be=Mt([G(0,o.ICommandService),G(1,E.IMenuManagerService),G(2,P.IRenderManagerService),G(3,o.IUniverInstanceService),G(4,o.Inject(N.AutoHeightController)),G(5,o.Inject(fe)),G(6,o.Inject(C.SheetDataValidationModel)),G(7,o.Inject(Y.DataValidatorRegistryService)),G(8,o.Inject(H.SheetInterceptorService)),G(9,o.Inject(C.DataValidationCacheService)),G(10,o.Optional(N.IEditorBridgeService))],be);let vt=class extends o.RxDisposable{constructor(e,t,a,n,r,i,s){super(),this._commandService=e,this._renderManagerService=t,this._autoHeightController=a,this._dataValidatorRegistryService=n,this._sheetInterceptorService=r,this._sheetDataValidationModel=i,this._dataValidationCacheService=s,this._initViewModelIntercept(),this._initAutoHeight()}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(H.INTERCEPTOR_POINT.CELL_CONTENT,{effect:o.InterceptorEffectEnum.Style,priority:H.InterceptCellContentPriority.DATA_VALIDATION,handler:(e,t,a)=>{var M,m,y,f,D;const{row:n,col:r,unitId:i,subUnitId:s,workbook:d,worksheet:l}=t,c=this._sheetDataValidationModel.getRuleIdByLocation(i,s,n,r);if(!c)return a(e);const h=this._sheetDataValidationModel.getRuleById(i,s,c);if(!h)return a(e);const g=(M=this._dataValidationCacheService.getValue(i,s,n,r))!=null?M:o.DataValidationStatus.VALID,u=this._dataValidatorRegistryService.getValidatorItem(h.type),_=l.getCellRaw(n,r),v=C.getCellValueOrigin(_),T=`${v!=null?v:""}`;return(!e||e===t.rawData)&&(e={...t.rawData}),e.markers={...e==null?void 0:e.markers,...g===o.DataValidationStatus.INVALID?bt:null},e.customRender=[...(m=e==null?void 0:e.customRender)!=null?m:[],...u!=null&&u.canvasRender?[u.canvasRender]:[]],e.fontRenderExtension={...e==null?void 0:e.fontRenderExtension,isSkip:((y=e==null?void 0:e.fontRenderExtension)==null?void 0:y.isSkip)||((f=u==null?void 0:u.skipDefaultFontRender)==null?void 0:f.call(u,h,v,t))},e.interceptorStyle={...e==null?void 0:e.interceptorStyle,...u==null?void 0:u.getExtraStyle(h,T,{get style(){const R=d.getStyles();return(typeof(e==null?void 0:e.s)=="string"?R.get(e==null?void 0:e.s):e==null?void 0:e.s)||{}}},n,r)},e.interceptorAutoHeight=()=>{var F,W,O,x,j,U;const R=(W=(F=this._renderManagerService.getRenderById(i))==null?void 0:F.with(N.SheetSkeletonManagerService).getSkeletonParam(s))==null?void 0:W.skeleton;if(!R)return;const I=R.worksheet.getMergedCell(n,r),w={data:e,style:R.getStyles().getStyleByCell(e),primaryWithCoord:R.getCellWithCoordByIndex((O=I==null?void 0:I.startRow)!=null?O:n,(x=I==null?void 0:I.startColumn)!=null?x:r),unitId:i,subUnitId:s,row:n,col:r,workbook:d,worksheet:l};return(U=(j=u==null?void 0:u.canvasRender)==null?void 0:j.calcCellAutoHeight)==null?void 0:U.call(j,w)},e.interceptorAutoWidth=()=>{var F,W,O,x,j,U;const R=(W=(F=this._renderManagerService.getRenderById(i))==null?void 0:F.with(N.SheetSkeletonManagerService).getSkeletonParam(s))==null?void 0:W.skeleton;if(!R)return;const I=R.worksheet.getMergedCell(n,r),w={data:e,style:R.getStyles().getStyleByCell(e),primaryWithCoord:R.getCellWithCoordByIndex((O=I==null?void 0:I.startRow)!=null?O:n,(x=I==null?void 0:I.startColumn)!=null?x:r),unitId:i,subUnitId:s,row:n,col:r,workbook:d,worksheet:l};return(U=(j=u==null?void 0:u.canvasRender)==null?void 0:j.calcCellAutoWidth)==null?void 0:U.call(j,w)},e.coverable=((D=e==null?void 0:e.coverable)!=null?D:!0)&&!(h.type===o.DataValidationType.LIST||h.type===o.DataValidationType.LIST_MULTIPLE),a(e)}}))}_initAutoHeight(){this._sheetDataValidationModel.ruleChange$.pipe(oe.filter(e=>e.source==="command"),oe.bufferTime(16)).subscribe(e=>{const t=[];if(e.forEach(a=>{var n;(a.rule.type===o.DataValidationType.LIST_MULTIPLE||a.rule.type===o.DataValidationType.LIST)&&(n=a.rule)!=null&&n.ranges&&t.push(...a.rule.ranges)}),t.length){const a=this._autoHeightController.getUndoRedoParamsOfAutoHeight(t);o.sequenceExecute(a.redos,this._commandService)}})}};vt=Mt([G(0,o.ICommandService),G(1,P.IRenderManagerService),G(2,o.Inject(N.AutoHeightController)),G(3,o.Inject(Y.DataValidatorRegistryService)),G(4,o.Inject(H.SheetInterceptorService)),G(5,o.Inject(C.SheetDataValidationModel)),G(6,o.Inject(C.DataValidationCacheService))],vt);var Rn=Object.getOwnPropertyDescriptor,Dn=(e,t,a,n)=>{for(var r=n>1?void 0:n?Rn(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},mt=(e,t)=>(a,n)=>t(a,n,e);let Ne=class extends o.Disposable{constructor(e,t,a){super(),this._context=e,this._sheetDataValidationModel=t,this._sheetSkeletonManagerService=a,this._initSkeletonChange()}_initSkeletonChange(){const e=t=>{var n;if(!t.length)return;const a=new Set;t.forEach(r=>{a.add(r.subUnitId)}),a.forEach(r=>{var i;(i=this._sheetSkeletonManagerService.getSkeletonParam(r))==null||i.skeleton.makeDirty(!0)}),(n=this._context.mainComponent)==null||n.makeForceDirty()};this.disposeWithMe(this._sheetDataValidationModel.validStatusChange$.pipe(o.bufferDebounceTime(16)).subscribe(e))}};Ne=Dn([mt(1,o.Inject(C.SheetDataValidationModel)),mt(2,o.Inject(N.SheetSkeletonManagerService))],Ne);function wn(e){var c;const t=E.useDependency(o.LocaleService),a=E.useDependency(E.ComponentManager),{value:n,onChange:r,extraComponent:i}=e,[s,d]=b.useState(!1),l=i?a.get(i):null;return p.jsxs(p.Fragment,{children:[p.jsxs("div",{className:"univer-mb-3 univer-flex univer-cursor-pointer univer-items-center univer-text-sm univer-text-gray-900 dark:!univer-text-white",onClick:()=>d(!s),children:[t.t("dataValidation.panel.options"),s?p.jsx(Rt,{className:"univer-ml-1"}):p.jsx(dt,{className:"univer-ml-1"})]}),s&&p.jsxs(p.Fragment,{children:[l?p.jsx(l,{value:n,onChange:r}):null,p.jsx(V.FormLayout,{label:t.t("dataValidation.panel.invalid"),children:p.jsxs(V.RadioGroup,{value:`${(c=n.errorStyle)!=null?c:o.DataValidationErrorStyle.WARNING}`,onChange:h=>r({...n,errorStyle:+h}),children:[p.jsx(V.Radio,{value:`${o.DataValidationErrorStyle.WARNING}`,children:t.t("dataValidation.panel.showWarning")}),p.jsx(V.Radio,{value:`${o.DataValidationErrorStyle.STOP}`,children:t.t("dataValidation.panel.rejectInput")})]})}),p.jsx(V.FormLayout,{label:t.t("dataValidation.panel.messageInfo"),children:p.jsx(V.Checkbox,{checked:n.showErrorMessage,onChange:()=>r({...n,showErrorMessage:!n.showErrorMessage}),children:t.t("dataValidation.panel.showInfo")})}),n.showErrorMessage?p.jsx(V.FormLayout,{children:p.jsx(V.Input,{value:n.error,onChange:h=>r({...n,error:h})})}):null]})]})}const Vn=e=>o.debounce(async(t,a,n,r)=>{const i=await e.executeCommand(t,a,n);r==null||r(i)},1e3);function En(e,t,a){var n,r,i,s;return t?((r=(n=e.getUnit(t))==null?void 0:n.getSheetBySheetName(a))==null?void 0:r.getSheetId())||"":((s=(i=e.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET))==null?void 0:i.getSheetBySheetName(a))==null?void 0:s.getSheetId())||""}function Mn(){var L,$;const[e,t]=b.useState(0),a=E.useDependency(he),n=E.useObservable(a.activeRule$,a.activeRule),{unitId:r,subUnitId:i,rule:s}=n||{},d=s.uid,l=E.useDependency(Y.DataValidatorRegistryService),c=E.useDependency(o.IUniverInstanceService),h=E.useDependency(E.ComponentManager),g=E.useDependency(o.ICommandService),u=E.useDependency(Y.DataValidationModel),_=E.useDependency(o.LocaleService),[v,T]=b.useState(s),M=l.getValidatorItem(v.type),[m,y]=b.useState(!1),f=l.getValidatorsByScope(Y.DataValidatorRegistryScope.SHEET),[D,R]=b.useState(()=>v.ranges.map(S=>({unitId:"",sheetId:"",range:S}))),I=b.useMemo(()=>Vn(g),[g]),[w,F]=b.useState(!1),[W,O]=b.useState(!1),x=b.useRef(null),j=E.useDependency(H.SheetsSelectionsService);if(b.useEffect(()=>()=>{const S=j.getCurrentLastSelection();S&&j.setSelections([S])},[j]),b.useEffect(()=>{g.onCommandExecuted(S=>{(S.id===o.UndoCommand.id||S.id===o.RedoCommand.id)&&setTimeout(()=>{const k=u.getRuleById(r,i,d);t(X=>X+1),k&&(T(k),R(k.ranges.map(X=>({unitId:"",sheetId:"",range:X}))))},20)})},[g,u,d,i,r]),!M)return null;const U=M.operators,B=M.operatorNames,K=v.operator?Y.TWO_FORMULA_OPERATOR_COUNT.includes(v.operator):!1,z=()=>{var S,k,X;(k=(S=x.current)==null?void 0:S.editor)!=null&&k.isFocus()&&ee((X=x.current)==null?void 0:X.getValue()),!(!v.ranges.length||w)&&(M.validatorFormula(v,r,i).success?a.setActiveRule(null):y(!0))},ee=E.useEvent(S=>{const k=S.split(",").filter(Boolean).map(nt.deserializeRangeWithSheet).map(ne=>{const ht=ne.sheetName;if(ht){const At=En(c,ne.unitId,ht);return{...ne,sheetId:At}}return{...ne,sheetId:""}});if(o.isUnitRangesEqual(k,D))return;R(k);const X=k.filter(ne=>(!ne.unitId||ne.unitId===r)&&(!ne.sheetId||ne.sheetId===i)).map(ne=>ne.range);if(T({...v,ranges:X}),X.length===0)return;const ge={unitId:r,subUnitId:i,ruleId:d,ranges:X};I(C.UpdateSheetDataValidationRangeCommand.id,ge)}),ae=S=>{if(o.shallowEqual(S,Y.getRuleSetting(v)))return;T({...v,...S});const k={unitId:r,subUnitId:i,ruleId:d,setting:S};I(C.UpdateSheetDataValidationSettingCommand.id,k,void 0)},re=async()=>{await g.executeCommand(C.RemoveSheetDataValidationCommand.id,{ruleId:d,unitId:r,subUnitId:i}),a.setActiveRule(null)},se={type:v.type,operator:v.operator,formula1:v.formula1,formula2:v.formula2,allowBlank:v.allowBlank},q=S=>{const k=l.getValidatorItem(S);if(!k)return;const X=k.operators,ge=u.getRuleById(r,i,d),ne=S===(ge==null?void 0:ge.type)||S.includes("list")&&(ge!=null&&ge.type.includes("list"))?{...ge,type:S}:{...v,type:S,operator:X[0],formula1:void 0,formula2:void 0};T(ne),g.executeCommand(C.UpdateSheetDataValidationSettingCommand.id,{unitId:r,subUnitId:i,ruleId:v.uid,setting:Y.getRuleSetting(ne)})},Z=h.get(M.formulaInput),ce=b.useMemo(()=>D.map(S=>nt.serializeRange(S.range)).join(","),[]),te=Y.getRuleOptions(v),Q=S=>{o.shallowEqual(S,Y.getRuleOptions(v))||(T({...v,...S}),I(C.UpdateSheetDataValidationOptionsCommand.id,{unitId:r,subUnitId:i,ruleId:d,options:S}))},J=U.length&&!v.operator;return p.jsxs("div",{"data-u-comp":"data-validation-detail",className:"univer-py-2",children:[p.jsx(V.FormLayout,{label:_.t("dataValidation.panel.range"),error:!v.ranges.length||w?_.t("dataValidation.panel.rangeError"):"",children:p.jsx(st.RangeSelector,{selectorRef:x,unitId:r,subUnitId:i,initialValue:ce,onChange:(S,k)=>{var X;!W&&((X=x.current)!=null&&X.verify())&&ee(k)},onFocusChange:(S,k)=>{var X;O(S),!S&&k&&((X=x.current)!=null&&X.verify())&&ee(k)},onVerify:S=>F(!S)})}),p.jsx(V.FormLayout,{label:_.t("dataValidation.panel.type"),children:p.jsx(V.Select,{className:"univer-w-full",value:v.type,options:(L=f==null?void 0:f.sort((S,k)=>S.order-k.order))==null?void 0:L.map(S=>({label:_.t(S.title),value:S.id})),onChange:q})}),U!=null&&U.length?p.jsx(V.FormLayout,{label:_.t("dataValidation.panel.operator"),children:p.jsx(V.Select,{className:"univer-w-full",value:`${v.operator}`,options:[{value:"",label:_.t("dataValidation.operators.legal")},...U.map((S,k)=>({value:`${S}`,label:B[k]}))],onChange:S=>{ae({...se,operator:S})}})}):null,Z&&!J?p.jsx(Z,{isTwoFormula:K,value:{formula1:v.formula1,formula2:v.formula2},onChange:S=>{ae({...se,...S})},showError:m,validResult:M.validatorFormula(v,r,i),unitId:r,subUnitId:i,ruleId:d},e+v.type):null,p.jsx(V.FormLayout,{children:p.jsx(V.Checkbox,{checked:($=v.allowBlank)!=null?$:!0,onChange:()=>{var S;return ae({...se,allowBlank:!((S=v.allowBlank)==null||S)})},children:_.t("dataValidation.panel.allowBlank")})}),p.jsx(wn,{value:te,onChange:Q,extraComponent:M.optionsInput}),p.jsxs("div",{className:"univer-mt-5 univer-flex univer-flex-row univer-justify-end",children:[p.jsx(V.Button,{className:"univer-ml-3",onClick:re,children:_.t("dataValidation.panel.removeRule")}),p.jsx(V.Button,{className:"univer-ml-3",variant:"primary",onClick:z,children:_.t("dataValidation.panel.done")})]})]})}const bn=e=>{const{rule:t,onClick:a,unitId:n,subUnitId:r,disable:i}=e,s=E.useDependency(Y.DataValidatorRegistryService),d=E.useDependency(o.ICommandService),l=E.useDependency(N.IMarkSelectionService),c=s.getValidatorItem(t.type),h=b.useRef(void 0),[g,u]=b.useState(!1),_=E.useDependency(o.ThemeService),v=E.useObservable(_.currentTheme$),T=b.useMemo(()=>{var R;const m=_.getColorFromTheme("primary.600"),y=_.getColorFromTheme("loop-color.2"),f=(R=_.getColorFromTheme(y))!=null?R:m,D=new o.ColorKit(f).toRgb();return{fill:`rgba(${D.r}, ${D.g}, ${D.b}, 0.1)`,stroke:f}},[v]),M=m=>{d.executeCommand(C.RemoveSheetDataValidationCommand.id,{ruleId:t.uid,unitId:n,subUnitId:r}),m.stopPropagation()};return b.useEffect(()=>()=>{var m;h.current&&((m=h.current)==null||m.forEach(y=>{y&&l.removeShape(y)}))},[l]),p.jsxs("div",{className:V.clsx(`
|
2
2
|
univer-rounded-md univer-bg-secondary univer-relative univer--ml-2 univer--mr-2 univer-box-border
|
3
3
|
univer-flex univer-w-[287px] univer-cursor-pointer univer-flex-col univer-justify-between
|
4
4
|
univer-overflow-hidden univer-p-2 univer-pr-9
|