@univerjs/sheets-data-validation-ui 0.7.0-nightly.202505071607 → 0.7.0-nightly.202505091607

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/lib/cjs/index.js CHANGED
@@ -1,54 +1,46 @@
1
- "use strict";var jt=Object.defineProperty;var xt=(e,t,a)=>t in e?jt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a;var O=(e,t,a)=>xt(e,typeof t!="symbol"?t+"":t,a);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("@univerjs/core"),_=require("@univerjs/sheets-data-validation"),g=require("react/jsx-runtime"),b=require("@univerjs/design"),w=require("@univerjs/ui"),M=require("react"),lt=require("@univerjs/sheets-formula-ui"),$=require("@univerjs/data-validation"),ae=require("rxjs"),L=require("@univerjs/engine-render"),W=require("@univerjs/sheets"),Ut=require("@univerjs/sheets-numfmt"),B=require("@univerjs/sheets-ui"),at=require("@univerjs/engine-formula"),Ft=e=>{const{isTwoFormula:t=!1,value:a,onChange:n,showError:r,validResult:i}=e,s=w.useDependency(o.LocaleService),d=r?i==null?void 0:i.formula1:"",l=r?i==null?void 0:i.formula2:"";return t?g.jsxs(g.Fragment,{children:[g.jsx(b.FormLayout,{error:d,children:g.jsx(b.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})}})}),g.jsx("div",{className:"-univer-mt-2 univer-mb-1 univer-text-sm univer-text-gray-400",children:s.t("dataValidation.panel.formulaAnd")}),g.jsx(b.FormLayout,{error:l,children:g.jsx(b.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})}})})]}):g.jsx(b.FormLayout,{error:d,children:g.jsx(b.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 kt(e){const{value:t,onChange:a,showError:n,validResult:r}=e,i=w.useDependency(o.LocaleService),s=n?r==null?void 0:r.formula1:"",d=n?r==null?void 0:r.formula2:"",[l,c]=M.useState(!((t==null?void 0:t.formula1)===void 0&&(t==null?void 0:t.formula2)===void 0));return g.jsxs(g.Fragment,{children:[g.jsx(b.FormLayout,{children:g.jsx(b.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?g.jsx(b.FormLayout,{label:i.t("dataValidation.checkbox.checked"),error:s,children:g.jsx(b.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?g.jsx(b.FormLayout,{label:i.t("dataValidation.checkbox.unchecked"),error:d,children:g.jsx(b.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 Nt(e){var p;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=M.useRef(null),[c,h]=M.useState(!1);return w.useSidebarClick(u=>{var v;((v=l.current)==null?void 0:v.isClickOutSide(u))&&h(!1)}),g.jsx(lt.FormulaEditor,{ref:l,className:`
2
- univer-box-border univer-h-8 univer-w-full univer-cursor-pointer univer-items-center univer-rounded-lg
3
- univer-border univer-border-solid univer-border-gray-200 univer-bg-white univer-pt-2
4
- univer-transition-colors
5
- [&>div:first-child]:univer-px-2.5
6
- [&>div]:univer-h-5 [&>div]:univer-ring-transparent
7
- dark:univer-border-gray-600 dark:univer-bg-gray-700 dark:univer-text-white
8
- hover:univer-border-primary-600
9
- `,initValue:(p=n==null?void 0:n.formula1)!=null?p:"=",unitId:t,subUnitId:a,isFocus:c,errorText:d,isSupportAcrossSheet:!0,onChange:u=>{const S=(u!=null?u:"").trim();S!==(n==null?void 0:n.formula1)&&(r==null||r({...n,formula1:S}))},onFocus:()=>h(!0)})}var ne=function(){return ne=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},ne.apply(this,arguments)},Bt=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=M.forwardRef(function(e,t){var a=e.icon,n=e.id,r=e.className,i=e.extend,s=Bt(e,["icon","id","className","extend"]),d="univerjs-icon univerjs-icon-".concat(n," ").concat(r||"").trim(),l=M.useRef("_".concat($t()));return It(a,"".concat(n),{defIds:a.defIds,idSuffix:l.current},ne({ref:t,className:d},s),i)});function It(e,t,a,n,r){return M.createElement(e.tag,ne(ne({key:t},Ht(e,a,r)),n),(Wt(e,a).children||[]).map(function(i,s){return It(i,"".concat(t,"-").concat(e.tag,"-").concat(s),a,void 0,r)}))}function Ht(e,t,a){var n=ne({},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 Wt(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)?ne(ne({},e),{children:e.children.map(function(r){return typeof r.attrs.id=="string"&&n&&n.indexOf(r.attrs.id)>-1?ne(ne({},r),{attrs:ne(ne({},r.attrs),{id:r.attrs.id+t.idSuffix})}):r})}):e}function $t(){return Math.random().toString(36).substring(2,8)}Se.displayName="UniverIcon";var Yt={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M1.4917 3.07803C1.4917 2.19437 2.20804 1.47803 3.0917 1.47803H5.6917C6.57536 1.47803 7.2917 2.19437 7.2917 3.07803V5.67803C7.2917 6.56168 6.57535 7.27803 5.6917 7.27803H3.0917C2.20804 7.27803 1.4917 6.56168 1.4917 5.67803V3.07803ZM3.0917 2.67803C2.87078 2.67803 2.6917 2.85711 2.6917 3.07803V5.67803C2.6917 5.89894 2.87079 6.07803 3.0917 6.07803H5.6917C5.91261 6.07803 6.0917 5.89894 6.0917 5.67803V3.07803C6.0917 2.85711 5.91261 2.67803 5.6917 2.67803H3.0917Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M14.6175 2.45279C14.8518 2.68711 14.8518 3.06701 14.6175 3.30132L11.6151 6.30365C11.3957 6.52307 11.0451 6.53897 10.8067 6.34031L8.80915 4.67566C8.55458 4.46352 8.52019 4.08518 8.73233 3.83062 8.94447 3.57605 9.32281 3.54166 9.57737 3.7538L11.154 5.06767 13.769 2.45278C14.0033 2.21847 14.3832 2.21848 14.6175 2.45279zM14.1175 9.19746C14.3518 9.43178 14.3518 9.81168 14.1175 10.046L12.5418 11.6217 14.1175 13.1975C14.3518 13.4318 14.3518 13.8117 14.1175 14.046 13.8832 14.2803 13.5033 14.2803 13.269 14.046L11.6933 12.4703 10.1175 14.046C9.88321 14.2803 9.50331 14.2803 9.269 14.046 9.03468 13.8117 9.03468 13.4318 9.269 13.1975L10.8447 11.6217 9.269 10.046C9.03468 9.81168 9.03468 9.43178 9.269 9.19746 9.50331 8.96315 9.88321 8.96315 10.1175 9.19746L11.6933 10.7732 13.269 9.19746C13.5033 8.96315 13.8832 8.96315 14.1175 9.19746z"}},{tag:"path",attrs:{fill:"currentColor",d:"M3.0917 8.72168C2.20804 8.72168 1.4917 9.43802 1.4917 10.3217V12.9217C1.4917 13.8053 2.20804 14.5217 3.0917 14.5217H5.6917C6.57535 14.5217 7.2917 13.8053 7.2917 12.9217V10.3217C7.2917 9.43802 6.57536 8.72168 5.6917 8.72168H3.0917ZM2.6917 10.3217C2.6917 10.1008 2.87078 9.92168 3.0917 9.92168H5.6917C5.91261 9.92168 6.0917 10.1008 6.0917 10.3217V12.9217C6.0917 13.1426 5.91261 13.3217 5.6917 13.3217H3.0917C2.87079 13.3217 2.6917 13.1426 2.6917 12.9217V10.3217Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Ct=M.forwardRef(function(e,t){return M.createElement(Se,Object.assign({},e,{id:"data-validation-single",ref:t,icon:Yt}))});Ct.displayName="DataValidationSingle";var Xt={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M5.3313 1.4667C5.3313 1.13533 5.59993.866699 5.9313.866699H10.069C10.4004.866699 10.669 1.13533 10.669 1.4667 10.669 1.79807 10.4004 2.0667 10.069 2.0667H5.9313C5.59993 2.0667 5.3313 1.79807 5.3313 1.4667zM1.09985 3.64443C1.09985 3.31306 1.36848 3.04443 1.69985 3.04443H14.2999C14.6312 3.04443 14.8999 3.31306 14.8999 3.64443 14.8999 3.9758 14.6312 4.24443 14.2999 4.24443H1.69985C1.36848 4.24443 1.09985 3.9758 1.09985 3.64443zM6.12398 8.30171C6.35829 8.0674 6.73819 8.0674 6.97251 8.30171L8.00007 9.32928 9.02764 8.30171C9.26195 8.0674 9.64185 8.0674 9.87617 8.30171 10.1105 8.53603 10.1105 8.91593 9.87617 9.15024L8.8486 10.1778 9.87617 11.2054C10.1105 11.4397 10.1105 11.8196 9.87617 12.0539 9.64185 12.2882 9.26195 12.2882 9.02764 12.0539L8.00007 11.0263 6.97251 12.0539C6.73819 12.2882 6.35829 12.2882 6.12398 12.0539 5.88966 11.8196 5.88966 11.4397 6.12398 11.2054L7.15154 10.1778 6.12398 9.15024C5.88966 8.91593 5.88966 8.53603 6.12398 8.30171z"}},{tag:"path",attrs:{fill:"currentColor",d:"M4.75332 5.22217C3.86966 5.22217 3.15332 5.93851 3.15332 6.82217V12.5331C3.15332 13.9691 4.31738 15.1332 5.75332 15.1332H10.2465C11.6825 15.1332 12.8465 13.9691 12.8465 12.5331V6.82217C12.8465 5.93851 12.1302 5.22217 11.2465 5.22217H4.75332ZM4.35332 6.82217C4.35332 6.60125 4.53241 6.42217 4.75332 6.42217H11.2465C11.4674 6.42217 11.6465 6.60125 11.6465 6.82217V12.5331C11.6465 13.3063 11.0197 13.9332 10.2465 13.9332H5.75332C4.98012 13.9332 4.35332 13.3063 4.35332 12.5331V6.82217Z",fillRule:"evenodd",clipRule:"evenodd"}}]},dt=M.forwardRef(function(e,t){return M.createElement(Se,Object.assign({},e,{id:"delete-single",ref:t,icon:Xt}))});dt.displayName="DeleteSingle";var zt={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M8.6 1.99991C8.60001 1.66854 8.33138 1.39991 8.00001 1.3999C7.66864 1.3999 7.40001 1.66853 7.4 1.9999L7.39996 7.3999H1.9999C1.66853 7.3999 1.3999 7.66853 1.3999 7.9999C1.3999 8.33127 1.66853 8.5999 1.9999 8.5999H7.39995L7.3999 13.9999C7.3999 14.3313 7.66853 14.5999 7.9999 14.5999C8.33127 14.5999 8.5999 14.3313 8.5999 13.9999L8.59995 8.5999H13.9999C14.3313 8.5999 14.5999 8.33127 14.5999 7.9999C14.5999 7.66853 14.3313 7.3999 13.9999 7.3999H8.59996L8.6 1.99991Z"}}]},yt=M.forwardRef(function(e,t){return M.createElement(Se,Object.assign({},e,{id:"increase-single",ref:t,icon:zt}))});yt.displayName="IncreaseSingle";var Kt={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M11.3536 6.14645C11.5488 6.34171 11.5488 6.65829 11.3536 6.85355L8.35355 9.85355C8.15829 10.0488 7.84171 10.0488 7.64645 9.85355L4.64645 6.85355C4.45118 6.65829 4.45118 6.34171 4.64645 6.14645C4.84171 5.95118 5.15829 5.95118 5.35355 6.14645L8 8.79289L10.6464 6.14645C10.8417 5.95118 11.1583 5.95118 11.3536 6.14645Z",fillRule:"evenodd",clipRule:"evenodd"}}]},ct=M.forwardRef(function(e,t){return M.createElement(Se,Object.assign({},e,{id:"more-down-single",ref:t,icon:Kt}))});ct.displayName="MoreDownSingle";var Gt={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M4.64645 9.85355C4.45118 9.65829 4.45118 9.34171 4.64645 9.14645L7.64645 6.14645C7.84171 5.95118 8.15829 5.95118 8.35355 6.14645L11.3536 9.14645C11.5488 9.34171 11.5488 9.65829 11.3536 9.85355C11.1583 10.0488 10.8417 10.0488 10.6464 9.85355L8 7.20711L5.35355 9.85355C5.15829 10.0488 4.84171 10.0488 4.64645 9.85355Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Dt=M.forwardRef(function(e,t){return M.createElement(Se,Object.assign({},e,{id:"more-up-single",ref:t,icon:Gt}))});Dt.displayName="MoreUpSingle";var qt={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"mask",attrs:{id:"mask0_622_8",style:{maskType:"alpha"},width:16,height:16,x:0,y:0,maskUnits:"userSpaceOnUse"},children:[{tag:"path",attrs:{fill:"#D9D9D9",d:"M0 0H16V16H0z"}}]},{tag:"g",attrs:{fill:"currentColor",mask:"url(#mask0_622_8)"},children:[{tag:"path",attrs:{d:"M6 5C6.55228 5 7 4.55228 7 4 7 3.44772 6.55228 3 6 3 5.44772 3 5 3.44772 5 4 5 4.55228 5.44772 5 6 5zM6 9C6.55228 9 7 8.55229 7 8 7 7.44772 6.55228 7 6 7 5.44772 7 5 7.44772 5 8 5 8.55229 5.44772 9 6 9zM7 12C7 12.5523 6.55228 13 6 13 5.44772 13 5 12.5523 5 12 5 11.4477 5.44772 11 6 11 6.55228 11 7 11.4477 7 12zM10 5C10.5523 5 11 4.55228 11 4 11 3.44772 10.5523 3 10 3 9.44771 3 9 3.44772 9 4 9 4.55228 9.44771 5 10 5zM11 8C11 8.55229 10.5523 9 10 9 9.44771 9 9 8.55229 9 8 9 7.44772 9.44771 7 10 7 10.5523 7 11 7.44772 11 8zM10 13C10.5523 13 11 12.5523 11 12 11 11.4477 10.5523 11 10 11 9.44771 11 9 11.4477 9 12 9 12.5523 9.44771 13 10 13z"}}]}]},Rt=M.forwardRef(function(e,t){return M.createElement(Se,Object.assign({},e,{id:"sequence-single",ref:t,icon:qt}))});Rt.displayName="SequenceSingle";const De="#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"],Jt=e=>{const{value:t,onChange:a,disabled:n}=e,[r,i]=M.useState(!1);return g.jsx(b.Dropdown,{align:"start",disabled:n,open:r,onOpenChange:i,overlay:g.jsx("div",{className:`
1
+ "use strict";var jt=Object.defineProperty;var xt=(e,t,a)=>t in e?jt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a;var O=(e,t,a)=>xt(e,typeof t!="symbol"?t+"":t,a);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("@univerjs/core"),_=require("@univerjs/sheets-data-validation"),p=require("react/jsx-runtime"),E=require("@univerjs/design"),w=require("@univerjs/ui"),b=require("react"),lt=require("@univerjs/sheets-formula-ui"),$=require("@univerjs/data-validation"),ae=require("rxjs"),L=require("@univerjs/engine-render"),W=require("@univerjs/sheets"),Ut=require("@univerjs/sheets-numfmt"),B=require("@univerjs/sheets-ui"),at=require("@univerjs/engine-formula"),Ft=e=>{const{isTwoFormula:t=!1,value:a,onChange:n,showError:r,validResult:i}=e,s=w.useDependency(o.LocaleService),c=r?i==null?void 0:i.formula1:"",l=r?i==null?void 0:i.formula2:"";return t?p.jsxs(p.Fragment,{children:[p.jsx(E.FormLayout,{error:c,children:p.jsx(E.Input,{className:"univer-w-full",placeholder:s.t("dataValidation.panel.formulaPlaceholder"),value:a==null?void 0:a.formula1,onChange:d=>{n==null||n({...a,formula1:d})}})}),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(E.FormLayout,{error:l,children:p.jsx(E.Input,{className:"univer-w-full",placeholder:s.t("dataValidation.panel.formulaPlaceholder"),value:a==null?void 0:a.formula2,onChange:d=>{n==null||n({...a,formula2:d})}})})]}):p.jsx(E.FormLayout,{error:c,children:p.jsx(E.Input,{className:"univer-w-full",placeholder:s.t("dataValidation.panel.formulaPlaceholder"),value:a==null?void 0:a.formula1,onChange:d=>{n==null||n({formula1:d})}})})};function Nt(e){const{value:t,onChange:a,showError:n,validResult:r}=e,i=w.useDependency(o.LocaleService),s=n?r==null?void 0:r.formula1:"",c=n?r==null?void 0:r.formula2:"",[l,d]=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(E.FormLayout,{children:p.jsx(E.Checkbox,{checked:l,onChange:h=>{h?d(!0):(d(!1),a==null||a({...t,formula1:void 0,formula2:void 0}))},children:i.t("dataValidation.checkbox.tips")})}),l?p.jsx(E.FormLayout,{label:i.t("dataValidation.checkbox.checked"),error:s,children:p.jsx(E.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(E.FormLayout,{label:i.t("dataValidation.checkbox.unchecked"),error:c,children:p.jsx(E.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,c=i?s==null?void 0:s.formula1:void 0,l=b.useRef(null),[d,h]=b.useState(!1);return w.useSidebarClick(u=>{var v;((v=l.current)==null?void 0:v.isClickOutSide(u))&&h(!1)}),p.jsx(E.FormLayout,{error:c,children:p.jsx(lt.FormulaEditor,{ref:l,className:E.clsx(`
2
+ univer-box-border univer-h-8 univer-w-full univer-cursor-pointer univer-items-center univer-rounded-lg
3
+ univer-bg-white univer-pt-2 univer-transition-colors
4
+ [&>div:first-child]:univer-px-2.5
5
+ [&>div]:univer-h-5 [&>div]:univer-ring-transparent
6
+ dark:univer-bg-gray-700 dark:univer-text-white
7
+ hover:univer-border-primary-600
8
+ `,E.borderClassName),initValue:(g=n==null?void 0:n.formula1)!=null?g:"=",unitId:t,subUnitId:a,isFocus:d,isSupportAcrossSheet:!0,onChange:u=>{const S=(u!=null?u:"").trim();S!==(n==null?void 0:n.formula1)&&(r==null||r({...n,formula1:S}))},onFocus:()=>h(!0)})})}var ne=function(){return ne=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},ne.apply(this,arguments)},Bt=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=Bt(e,["icon","id","className","extend"]),c="univerjs-icon univerjs-icon-".concat(n," ").concat(r||"").trim(),l=b.useRef("_".concat($t()));return It(a,"".concat(n),{defIds:a.defIds,idSuffix:l.current},ne({ref:t,className:c},s),i)});function It(e,t,a,n,r){return b.createElement(e.tag,ne(ne({key:t},Ht(e,a,r)),n),(Wt(e,a).children||[]).map(function(i,s){return It(i,"".concat(t,"-").concat(e.tag,"-").concat(s),a,void 0,r)}))}function Ht(e,t,a){var n=ne({},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],c=i[1];s==="mask"&&typeof c=="string"&&(n[s]=c.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],c=i[1];typeof c=="string"&&(n[s]=c.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))})),n}function Wt(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)?ne(ne({},e),{children:e.children.map(function(r){return typeof r.attrs.id=="string"&&n&&n.indexOf(r.attrs.id)>-1?ne(ne({},r),{attrs:ne(ne({},r.attrs),{id:r.attrs.id+t.idSuffix})}):r})}):e}function $t(){return Math.random().toString(36).substring(2,8)}Se.displayName="UniverIcon";var Yt={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M1.4917 3.07803C1.4917 2.19437 2.20804 1.47803 3.0917 1.47803H5.6917C6.57536 1.47803 7.2917 2.19437 7.2917 3.07803V5.67803C7.2917 6.56168 6.57535 7.27803 5.6917 7.27803H3.0917C2.20804 7.27803 1.4917 6.56168 1.4917 5.67803V3.07803ZM3.0917 2.67803C2.87078 2.67803 2.6917 2.85711 2.6917 3.07803V5.67803C2.6917 5.89894 2.87079 6.07803 3.0917 6.07803H5.6917C5.91261 6.07803 6.0917 5.89894 6.0917 5.67803V3.07803C6.0917 2.85711 5.91261 2.67803 5.6917 2.67803H3.0917Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M14.6175 2.45279C14.8518 2.68711 14.8518 3.06701 14.6175 3.30132L11.6151 6.30365C11.3957 6.52307 11.0451 6.53897 10.8067 6.34031L8.80915 4.67566C8.55458 4.46352 8.52019 4.08518 8.73233 3.83062 8.94447 3.57605 9.32281 3.54166 9.57737 3.7538L11.154 5.06767 13.769 2.45278C14.0033 2.21847 14.3832 2.21848 14.6175 2.45279zM14.1175 9.19746C14.3518 9.43178 14.3518 9.81168 14.1175 10.046L12.5418 11.6217 14.1175 13.1975C14.3518 13.4318 14.3518 13.8117 14.1175 14.046 13.8832 14.2803 13.5033 14.2803 13.269 14.046L11.6933 12.4703 10.1175 14.046C9.88321 14.2803 9.50331 14.2803 9.269 14.046 9.03468 13.8117 9.03468 13.4318 9.269 13.1975L10.8447 11.6217 9.269 10.046C9.03468 9.81168 9.03468 9.43178 9.269 9.19746 9.50331 8.96315 9.88321 8.96315 10.1175 9.19746L11.6933 10.7732 13.269 9.19746C13.5033 8.96315 13.8832 8.96315 14.1175 9.19746z"}},{tag:"path",attrs:{fill:"currentColor",d:"M3.0917 8.72168C2.20804 8.72168 1.4917 9.43802 1.4917 10.3217V12.9217C1.4917 13.8053 2.20804 14.5217 3.0917 14.5217H5.6917C6.57535 14.5217 7.2917 13.8053 7.2917 12.9217V10.3217C7.2917 9.43802 6.57536 8.72168 5.6917 8.72168H3.0917ZM2.6917 10.3217C2.6917 10.1008 2.87078 9.92168 3.0917 9.92168H5.6917C5.91261 9.92168 6.0917 10.1008 6.0917 10.3217V12.9217C6.0917 13.1426 5.91261 13.3217 5.6917 13.3217H3.0917C2.87079 13.3217 2.6917 13.1426 2.6917 12.9217V10.3217Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Ct=b.forwardRef(function(e,t){return b.createElement(Se,Object.assign({},e,{id:"data-validation-single",ref:t,icon:Yt}))});Ct.displayName="DataValidationSingle";var Xt={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M5.3313 1.4667C5.3313 1.13533 5.59993.866699 5.9313.866699H10.069C10.4004.866699 10.669 1.13533 10.669 1.4667 10.669 1.79807 10.4004 2.0667 10.069 2.0667H5.9313C5.59993 2.0667 5.3313 1.79807 5.3313 1.4667zM1.09985 3.64443C1.09985 3.31306 1.36848 3.04443 1.69985 3.04443H14.2999C14.6312 3.04443 14.8999 3.31306 14.8999 3.64443 14.8999 3.9758 14.6312 4.24443 14.2999 4.24443H1.69985C1.36848 4.24443 1.09985 3.9758 1.09985 3.64443zM6.12398 8.30171C6.35829 8.0674 6.73819 8.0674 6.97251 8.30171L8.00007 9.32928 9.02764 8.30171C9.26195 8.0674 9.64185 8.0674 9.87617 8.30171 10.1105 8.53603 10.1105 8.91593 9.87617 9.15024L8.8486 10.1778 9.87617 11.2054C10.1105 11.4397 10.1105 11.8196 9.87617 12.0539 9.64185 12.2882 9.26195 12.2882 9.02764 12.0539L8.00007 11.0263 6.97251 12.0539C6.73819 12.2882 6.35829 12.2882 6.12398 12.0539 5.88966 11.8196 5.88966 11.4397 6.12398 11.2054L7.15154 10.1778 6.12398 9.15024C5.88966 8.91593 5.88966 8.53603 6.12398 8.30171z"}},{tag:"path",attrs:{fill:"currentColor",d:"M4.75332 5.22217C3.86966 5.22217 3.15332 5.93851 3.15332 6.82217V12.5331C3.15332 13.9691 4.31738 15.1332 5.75332 15.1332H10.2465C11.6825 15.1332 12.8465 13.9691 12.8465 12.5331V6.82217C12.8465 5.93851 12.1302 5.22217 11.2465 5.22217H4.75332ZM4.35332 6.82217C4.35332 6.60125 4.53241 6.42217 4.75332 6.42217H11.2465C11.4674 6.42217 11.6465 6.60125 11.6465 6.82217V12.5331C11.6465 13.3063 11.0197 13.9332 10.2465 13.9332H5.75332C4.98012 13.9332 4.35332 13.3063 4.35332 12.5331V6.82217Z",fillRule:"evenodd",clipRule:"evenodd"}}]},ct=b.forwardRef(function(e,t){return b.createElement(Se,Object.assign({},e,{id:"delete-single",ref:t,icon:Xt}))});ct.displayName="DeleteSingle";var zt={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M8.6 1.99991C8.60001 1.66854 8.33138 1.39991 8.00001 1.3999C7.66864 1.3999 7.40001 1.66853 7.4 1.9999L7.39996 7.3999H1.9999C1.66853 7.3999 1.3999 7.66853 1.3999 7.9999C1.3999 8.33127 1.66853 8.5999 1.9999 8.5999H7.39995L7.3999 13.9999C7.3999 14.3313 7.66853 14.5999 7.9999 14.5999C8.33127 14.5999 8.5999 14.3313 8.5999 13.9999L8.59995 8.5999H13.9999C14.3313 8.5999 14.5999 8.33127 14.5999 7.9999C14.5999 7.66853 14.3313 7.3999 13.9999 7.3999H8.59996L8.6 1.99991Z"}}]},yt=b.forwardRef(function(e,t){return b.createElement(Se,Object.assign({},e,{id:"increase-single",ref:t,icon:zt}))});yt.displayName="IncreaseSingle";var Kt={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M11.3536 6.14645C11.5488 6.34171 11.5488 6.65829 11.3536 6.85355L8.35355 9.85355C8.15829 10.0488 7.84171 10.0488 7.64645 9.85355L4.64645 6.85355C4.45118 6.65829 4.45118 6.34171 4.64645 6.14645C4.84171 5.95118 5.15829 5.95118 5.35355 6.14645L8 8.79289L10.6464 6.14645C10.8417 5.95118 11.1583 5.95118 11.3536 6.14645Z",fillRule:"evenodd",clipRule:"evenodd"}}]},dt=b.forwardRef(function(e,t){return b.createElement(Se,Object.assign({},e,{id:"more-down-single",ref:t,icon:Kt}))});dt.displayName="MoreDownSingle";var Gt={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M4.64645 9.85355C4.45118 9.65829 4.45118 9.34171 4.64645 9.14645L7.64645 6.14645C7.84171 5.95118 8.15829 5.95118 8.35355 6.14645L11.3536 9.14645C11.5488 9.34171 11.5488 9.65829 11.3536 9.85355C11.1583 10.0488 10.8417 10.0488 10.6464 9.85355L8 7.20711L5.35355 9.85355C5.15829 10.0488 4.84171 10.0488 4.64645 9.85355Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Dt=b.forwardRef(function(e,t){return b.createElement(Se,Object.assign({},e,{id:"more-up-single",ref:t,icon:Gt}))});Dt.displayName="MoreUpSingle";var qt={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"mask",attrs:{id:"mask0_622_8",style:{maskType:"alpha"},width:16,height:16,x:0,y:0,maskUnits:"userSpaceOnUse"},children:[{tag:"path",attrs:{fill:"#D9D9D9",d:"M0 0H16V16H0z"}}]},{tag:"g",attrs:{fill:"currentColor",mask:"url(#mask0_622_8)"},children:[{tag:"path",attrs:{d:"M6 5C6.55228 5 7 4.55228 7 4 7 3.44772 6.55228 3 6 3 5.44772 3 5 3.44772 5 4 5 4.55228 5.44772 5 6 5zM6 9C6.55228 9 7 8.55229 7 8 7 7.44772 6.55228 7 6 7 5.44772 7 5 7.44772 5 8 5 8.55229 5.44772 9 6 9zM7 12C7 12.5523 6.55228 13 6 13 5.44772 13 5 12.5523 5 12 5 11.4477 5.44772 11 6 11 6.55228 11 7 11.4477 7 12zM10 5C10.5523 5 11 4.55228 11 4 11 3.44772 10.5523 3 10 3 9.44771 3 9 3.44772 9 4 9 4.55228 9.44771 5 10 5zM11 8C11 8.55229 10.5523 9 10 9 9.44771 9 9 8.55229 9 8 9 7.44772 9.44771 7 10 7 10.5523 7 11 7.44772 11 8zM10 13C10.5523 13 11 12.5523 11 12 11 11.4477 10.5523 11 10 11 9.44771 11 9 11.4477 9 12 9 12.5523 9.44771 13 10 13z"}}]}]},Rt=b.forwardRef(function(e,t){return b.createElement(Se,Object.assign({},e,{id:"sequence-single",ref:t,icon:qt}))});Rt.displayName="SequenceSingle";const De="#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"],Jt=e=>{const{value:t,onChange:a,disabled:n}=e,[r,i]=b.useState(!1);return p.jsx(E.Dropdown,{align:"start",disabled:n,open:r,onOpenChange:i,overlay:p.jsx("div",{className:`
10
9
  univer-box-border univer-grid univer-w-fit univer-grid-cols-6 univer-flex-wrap univer-gap-2
11
10
  univer-p-1.5
12
- `,children:Zt.map(s=>g.jsx("div",{className:`
13
- univer-box-border univer-size-4 univer-cursor-pointer univer-rounded univer-border
14
- univer-border-solid univer-border-gray-200
15
- `,style:{background:s},onClick:()=>{a(s),i(!1)}},s))}),children:g.jsxs("div",{className:`
11
+ `,children:Zt.map(s=>p.jsx("div",{className:E.clsx("univer-box-border univer-size-4 univer-cursor-pointer univer-rounded",E.borderClassName),style:{background:s},onClick:()=>{a(s),i(!1)}},s))}),children:p.jsxs("div",{className:E.clsx(`
16
12
  univer-box-border univer-inline-flex univer-h-8 univer-w-16 univer-cursor-pointer univer-items-center
17
- univer-justify-between univer-gap-2 univer-rounded-lg univer-border univer-border-solid
18
- univer-border-gray-200 univer-bg-white univer-px-2.5 univer-transition-colors univer-duration-200
19
- dark:univer-border-gray-600 dark:univer-bg-gray-700 dark:univer-text-white
13
+ univer-justify-between univer-gap-2 univer-rounded-lg univer-bg-white univer-px-2.5
14
+ univer-transition-colors univer-duration-200
15
+ dark:univer-bg-gray-700 dark:univer-text-white
20
16
  hover:univer-border-primary-600
21
- `,children:[g.jsx("div",{className:`
22
- univer-box-border univer-h-4 univer-w-4 univer-rounded univer-border univer-border-gray-200
23
- univer-text-base
24
- `,style:{background:t}}),g.jsx(ct,{className:"univer-text-gray-600"})]})})},pt=e=>{const{item:t,commonProps:a,style:n}=e,{onItemChange:r,onItemDelete:i}=a;return g.jsxs("div",{className:"univer-flex univer-items-center univer-gap-2",style:n,children:[t.isRef?null:g.jsx("div",{className:b.clsx("univer-cursor-move","draggableHandle"),children:g.jsx(Rt,{})}),g.jsx(Jt,{value:t.color,onChange:s=>{r(t.id,t.label,s)}}),g.jsx(b.Input,{disabled:t.isRef,value:t.label,onChange:s=>{r(t.id,s,t.color)}}),t.isRef?null:g.jsx("div",{className:`
17
+ `,E.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,{})]})})},pt=e=>{const{item:t,commonProps:a,style:n}=e,{onItemChange:r,onItemDelete:i}=a;return p.jsxs("div",{className:"univer-flex univer-items-center univer-gap-2",style:n,children:[t.isRef?null:p.jsx("div",{className:E.clsx("univer-cursor-move","draggableHandle"),children:p.jsx(Rt,{})}),p.jsx(Jt,{value:t.color,onChange:s=>{r(t.id,t.label,s)}}),p.jsx(E.Input,{disabled:t.isRef,value:t.label,onChange:s=>{r(t.id,s,t.color)}}),t.isRef?null:p.jsx("div",{className:`
25
18
  univer-ml-1 univer-cursor-pointer univer-rounded univer-text-base
26
19
  hover:univer-bg-gray-200
27
- `,children:g.jsx(dt,{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,p]=M.useState(()=>o.isFormulaString(l)?"1":"0"),[u,S]=M.useState(h==="1"?l:"="),[v,T]=M.useState(h==="1"?l:"="),E=w.useDependency(o.LocaleService),m=w.useDependency($.DataValidatorRegistryService),C=w.useDependency($.DataValidationModel),f=w.useDependency(_.DataValidationFormulaController),[y,R]=M.useState(()=>c.split(",")),D=m.getValidatorItem(o.DataValidationType.LIST),[V,x]=M.useState([]),[H,P]=M.useState(""),U=s?i==null?void 0:i.formula1:"",F=M.useMemo(()=>C.ruleChange$.pipe(ae.debounceTime(16)),[]),k=w.useObservable(F),A=w.useEvent(a);M.useEffect(()=>{(async()=>{await new Promise(I=>{setTimeout(()=>I(!0),100)});const j=C.getRuleById(n,r,d),K=j==null?void 0:j.formula1;if(o.isFormulaString(K)&&D&&j){const I=await D.getListAsync(j,n,r);x(I)}})()},[C,k,D,d,r,n]),M.useEffect(()=>{o.isFormulaString(l)&&l!==v&&(S(l),T(v))},[v,l]);const[Y,X]=M.useState(()=>{const j=h!=="1"?_.deserializeListOptions(l):[],K=c.split(",");return j.map((I,N)=>({label:I,color:K[N]||De,isRef:!1,id:o.Tools.generateRandomId(4)}))}),G=(j,K,I)=>{const N=Y.find(z=>z.id===j);N&&(N.label=K,N.color=I,X([...Y]))},J=j=>{const K=Y.findIndex(I=>I.id===j);K!==-1&&(Y.splice(K,1),X([...Y]))},q=c.split(","),ee=M.useMemo(()=>V.map((j,K)=>({label:j,color:q[K]||De,id:`${K}`,isRef:!0})),[q,V]),le=(j,K,I)=>{const N=[...y];N[+j]=I,R(N),A({formula1:l,formula2:N.join(",")})},re=()=>{X([...Y,{label:"",color:De,isRef:!1,id:o.Tools.generateRandomId(4)}])};M.useEffect(()=>{if(h==="1")return;const j=new Set,K=[];Y.map(I=>({labelList:I.label.split(","),item:I})).forEach(({item:I,labelList:N})=>{N.forEach(z=>{j.has(z)||(j.add(z),K.push({label:z,color:I.color}))})}),A({formula1:_.serializeListOptions(K.map(I=>I.label)),formula2:K.map(I=>I.color===De?"":I.color).join(",")})},[Y,A,h,v,y]);const te=w.useEvent(async j=>{if(!o.isFormulaString(j)){A==null||A({formula1:"",formula2:c});return}f.getFormulaRefCheck(j)?(A==null||A({formula1:o.isFormulaString(j)?j:"",formula2:c}),P("")):(A==null||A({formula1:"",formula2:c}),S("="),P(E.t("dataValidation.validFail.formulaError")))}),ie=M.useRef(null),[he,de]=M.useState(!1);return w.useSidebarClick(j=>{var I;((I=ie.current)==null?void 0:I.isClickOutSide(j))&&de(!1)}),g.jsxs(g.Fragment,{children:[g.jsx(b.FormLayout,{label:E.t("dataValidation.list.options"),children:g.jsxs(b.RadioGroup,{value:h,onChange:j=>{p(j),S(v),j==="1"&&A({formula1:v==="="?"":v,formula2:y.join(",")})},children:[g.jsx(b.Radio,{value:"0",children:E.t("dataValidation.list.customOptions")}),g.jsx(b.Radio,{value:"1",children:E.t("dataValidation.list.refOptions")})]})}),h==="1"?g.jsxs(g.Fragment,{children:[g.jsx(lt.FormulaEditor,{ref:ie,className:`
20
+ `,children:p.jsx(ct,{onClick:()=>i(t.id)})})]})};function Qt(e){const{value:t,onChange:a=()=>{},unitId:n,subUnitId:r,validResult:i,showError:s,ruleId:c}=e,{formula1:l="",formula2:d=""}=t||{},[h,g]=b.useState(()=>o.isFormulaString(l)?"1":"0"),[u,S]=b.useState(h==="1"?l:"="),[v,T]=b.useState(h==="1"?l:"="),M=w.useDependency(o.LocaleService),m=w.useDependency($.DataValidatorRegistryService),C=w.useDependency($.DataValidationModel),f=w.useDependency(_.DataValidationFormulaController),[y,R]=b.useState(()=>d.split(",")),D=m.getValidatorItem(o.DataValidationType.LIST),[V,x]=b.useState([]),[H,P]=b.useState(""),U=s?i==null?void 0:i.formula1:"",F=b.useMemo(()=>C.ruleChange$.pipe(ae.debounceTime(16)),[]),N=w.useObservable(F),A=w.useEvent(a);b.useEffect(()=>{(async()=>{await new Promise(I=>{setTimeout(()=>I(!0),100)});const j=C.getRuleById(n,r,c),K=j==null?void 0:j.formula1;if(o.isFormulaString(K)&&D&&j){const I=await D.getListAsync(j,n,r);x(I)}})()},[C,N,D,c,r,n]),b.useEffect(()=>{o.isFormulaString(l)&&l!==v&&(S(l),T(v))},[v,l]);const[Y,X]=b.useState(()=>{const j=h!=="1"?_.deserializeListOptions(l):[],K=d.split(",");return j.map((I,k)=>({label:I,color:K[k]||De,isRef:!1,id:o.Tools.generateRandomId(4)}))}),G=(j,K,I)=>{const k=Y.find(z=>z.id===j);k&&(k.label=K,k.color=I,X([...Y]))},J=j=>{const K=Y.findIndex(I=>I.id===j);K!==-1&&(Y.splice(K,1),X([...Y]))},q=d.split(","),ee=b.useMemo(()=>V.map((j,K)=>({label:j,color:q[K]||De,id:`${K}`,isRef:!0})),[q,V]),le=(j,K,I)=>{const k=[...y];k[+j]=I,R(k),A({formula1:l,formula2:k.join(",")})},re=()=>{X([...Y,{label:"",color:De,isRef:!1,id:o.Tools.generateRandomId(4)}])};b.useEffect(()=>{if(h==="1")return;const j=new Set,K=[];Y.map(I=>({labelList:I.label.split(","),item:I})).forEach(({item:I,labelList:k})=>{k.forEach(z=>{j.has(z)||(j.add(z),K.push({label:z,color:I.color}))})}),A({formula1:_.serializeListOptions(K.map(I=>I.label)),formula2:K.map(I=>I.color===De?"":I.color).join(",")})},[Y,A,h,v,y]);const te=w.useEvent(async j=>{if(!o.isFormulaString(j)){A==null||A({formula1:"",formula2:d});return}f.getFormulaRefCheck(j)?(A==null||A({formula1:o.isFormulaString(j)?j:"",formula2:d}),P("")):(A==null||A({formula1:"",formula2:d}),S("="),P(M.t("dataValidation.validFail.formulaError")))}),ie=b.useRef(null),[he,ce]=b.useState(!1);return w.useSidebarClick(j=>{var I;((I=ie.current)==null?void 0:I.isClickOutSide(j))&&ce(!1)}),p.jsxs(p.Fragment,{children:[p.jsx(E.FormLayout,{label:M.t("dataValidation.list.options"),children:p.jsxs(E.RadioGroup,{value:h,onChange:j=>{g(j),S(v),j==="1"&&A({formula1:v==="="?"":v,formula2:y.join(",")})},children:[p.jsx(E.Radio,{value:"0",children:M.t("dataValidation.list.customOptions")}),p.jsx(E.Radio,{value:"1",children:M.t("dataValidation.list.refOptions")})]})}),h==="1"?p.jsxs(E.FormLayout,{error:U||H||void 0,children:[p.jsx(lt.FormulaEditor,{ref:ie,className:E.clsx(`
28
21
  univer-box-border univer-h-8 univer-w-full univer-cursor-pointer univer-items-center
29
- univer-rounded-lg univer-border univer-border-solid univer-border-gray-200 univer-bg-white
30
- univer-pt-2 univer-transition-colors
22
+ univer-rounded-lg univer-bg-white univer-pt-2 univer-transition-colors
31
23
  [&>div:first-child]:univer-px-2.5
32
24
  [&>div]:univer-h-5 [&>div]:univer-ring-transparent
33
- dark:univer-border-gray-600 dark:univer-bg-gray-700 dark:univer-text-white
25
+ dark:univer-bg-gray-700 dark:univer-text-white
34
26
  hover:univer-border-primary-600
35
- `,initValue:u,unitId:n,subUnitId:r,isFocus:he,errorText:U||H||void 0,isSupportAcrossSheet:!0,onFocus:()=>de(!0),onChange:(j="")=>{const K=(j!=null?j:"").trim();T(K),te(K)}}),ee.length>0&&g.jsx("div",{style:{marginTop:"12px"},children:ee.map(j=>g.jsx(pt,{item:j,commonProps:{onItemChange:le},style:{marginBottom:12}},j.id))})]}):g.jsx(b.FormLayout,{error:U,children:g.jsxs("div",{style:{marginTop:"-12px"},children:[g.jsx(b.DraggableList,{list:Y,onListChange:X,rowHeight:28,margin:[0,12],draggableHandle:".draggableHandle",itemRender:j=>g.jsx(pt,{item:j,commonProps:{onItemChange:G,onItemDelete:J}},j.id),idKey:"id"}),g.jsxs("a",{className:`
27
+ `,E.borderClassName),initValue:u,unitId:n,subUnitId:r,isFocus:he,isSupportAcrossSheet:!0,onFocus:()=>ce(!0),onChange:(j="")=>{const K=(j!=null?j:"").trim();T(K),te(K)}}),ee.length>0&&p.jsx("div",{style:{marginTop:"12px"},children:ee.map(j=>p.jsx(pt,{item:j,commonProps:{onItemChange:le},style:{marginBottom:12}},j.id))})]}):p.jsx(E.FormLayout,{error:U,children:p.jsxs("div",{style:{marginTop:"-12px"},children:[p.jsx(E.DraggableList,{list:Y,onListChange:X,rowHeight:28,margin:[0,12],draggableHandle:".draggableHandle",itemRender:j=>p.jsx(pt,{item:j,commonProps:{onItemChange:G,onItemDelete:J}},j.id),idKey:"id"}),p.jsxs("a",{className:`
36
28
  univer-flex univer-w-fit univer-cursor-pointer univer-flex-row univer-items-center
37
29
  univer-rounded univer-p-1 univer-px-2 univer-text-sm univer-text-primary
38
30
  hover:univer-bg-primary-600/5
39
- `,onClick:re,children:[g.jsx(yt,{className:"univer-mr-1"}),E.t("dataValidation.list.add")]})]})})]})}const en=[[_.CUSTOM_FORMULA_INPUT_NAME,Nt],[_.BASE_FORMULA_INPUT_NAME,Ft],[_.LIST_FORMULA_INPUT_NAME,Qt],[_.CHECKBOX_FORMULA_INPUT_NAME,kt]];var tn=Object.getOwnPropertyDescriptor,nn=(e,t,a,n)=>{for(var r=n>1?void 0:n?tn(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},an=(e,t)=>(a,n)=>t(a,n,e);exports.BaseSheetDataValidatorView=class{constructor(t){O(this,"canvasRender",null);O(this,"dropdownType");O(this,"optionsInput");O(this,"formulaInput",_.LIST_FORMULA_INPUT_NAME);this.injector=t}};exports.BaseSheetDataValidatorView=nn([an(0,o.Inject(o.Injector))],exports.BaseSheetDataValidatorView);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},vt=(e,t)=>(a,n)=>t(a,n,e);let ue=class extends o.Disposable{constructor(t,a){super();O(this,"_open$",new ae.BehaviorSubject(!1));O(this,"open$",this._open$.pipe(ae.distinctUntilChanged()));O(this,"_activeRule");O(this,"_activeRule$",new ae.BehaviorSubject(void 0));O(this,"activeRule$",this._activeRule$.asObservable());O(this,"_closeDisposable",null);this._univerInstanceService=t,this._sidebarService=a,this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(o.UniverInstanceType.UNIVER_SHEET).pipe(ae.filter(n=>!n)).subscribe(()=>{this.close()})),this.disposeWithMe(this._sidebarService.sidebarOptions$.subscribe(n=>{n.id===Ne&&(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)}};ue=on([vt(0,o.IUniverInstanceService),vt(1,w.ISidebarService)],ue);const ut="sheets-data-validation-ui.config",ke={};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},Ie=(e,t)=>(a,n)=>t(a,n,e);let Ve=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(W.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:M.createElement(b.Button,{variant:"primary",onClick:()=>this._dialogService.close("reject-input-dialog")},this._localeService.t("dataValidation.alert.ok"))},onClose:()=>{this._dialogService.close("reject-input-dialog")}}),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:M.createElement(b.Button,{variant:"primary",onClick:()=>this._dialogService.close("reject-input-dialog")},this._localeService.t("dataValidation.alert.ok"))},onClose:()=>{this._dialogService.close("reject-input-dialog")}})}};Ve=ln([Ie(0,o.Inject(W.SheetInterceptorService)),Ie(1,o.Inject(_.SheetDataValidationModel)),Ie(2,o.Inject($.DataValidatorRegistryService)),Ie(3,w.IDialogService),Ie(4,o.Inject(o.LocaleService)),Ie(5,o.Inject(_.SheetsDataValidationValidatorService))],Ve);var dn=Object.getOwnPropertyDescriptor,cn=(e,t,a,n)=>{for(var r=n>1?void 0:n?dn(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},oe=(e,t)=>(a,n)=>t(a,n,e);const ze=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 un(e,t){const a=Ut.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,p){super();O(this,"_activeDropdown");O(this,"_activeDropdown$",new ae.Subject);O(this,"_currentPopup",null);O(this,"activeDropdown$",this._activeDropdown$.asObservable());O(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=p,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,E,m,C;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 p;const u=async(f,y)=>{var F,k,A;if(!f)return!0;const R=f,D=l.getCell(n,r),V=R.format(y==="date"?"YYYY-MM-DD 00:00:00":"YYYY-MM-DD HH:mm:ss"),x=(F=o.numfmt.parseDate(V))==null?void 0:F.v,H=y==="time"?x%1:x,P=d.getStyles().getStyleByCell(D),U=(A=(k=P==null?void 0:P.n)==null?void 0:k.pattern)!=null?A:"";return c.errorStyle!==o.DataValidationErrorStyle.STOP||await h.validator({value:H,unitId:i,subUnitId:s,row:n,column:r,worksheet:l,workbook:d,interceptValue:V.replace("Z","").replace("T"," "),t:o.CellValueType.NUMBER},c)?(await this._commandService.executeCommand(B.SetCellEditVisibleOperation.id,{visible:!1,eventType:L.DeviceInputEventType.Keyboard,unitId:i,keycode:w.KeyCode.ESC}),await this._commandService.executeCommand(W.SetRangeValuesCommand.id,{unitId:i,subUnitId:s,range:{startColumn:r,endColumn:r,startRow:n,endRow:n},value:{v:H,t:2,p:null,f:null,si:null,s:{n:{pattern:un(y,U)}}}}),!0):(this._injector.has(Ve)&&this._injector.get(Ve).showReject(h.getRuleFinalError(c,{row:n,col:r,unitId:i,subUnitId:s})),!1)};let S;switch(h.dropdownType){case $.DataValidatorDropdownType.DATE:{const f=_.getCellValueOrigin(l.getCellRaw(n,r)),y=ze(f),R=!!((T=c.bizInfo)!=null&&T.showTime);S={location:a,type:"datepicker",props:{showTime:R,onChange:D=>u(D,R?"datetime":"date"),defaultValue:y,patternType:"date"}};break}case $.DataValidatorDropdownType.TIME:{const f=_.getCellValueOrigin(l.getCellRaw(n,r)),y=ze(f);S={location:a,type:"datepicker",props:{onChange:R=>u(R,"time"),defaultValue:y,patternType:"time"}};break}case $.DataValidatorDropdownType.DATETIME:{const f=_.getCellValueOrigin(l.getCellRaw(n,r)),y=ze(f);S={location:a,type:"datepicker",props:{onChange:R=>u(R,"datetime"),defaultValue:y,patternType:"datetime"}};break}case $.DataValidatorDropdownType.LIST:case $.DataValidatorDropdownType.MULTIPLE_LIST:{const f=h.dropdownType===$.DataValidatorDropdownType.MULTIPLE_LIST,y=async P=>{const U=_.serializeListOptions(P),F={unitId:i,subUnitId:s,range:{startColumn:r,endColumn:r,startRow:n,endRow:n},value:{v:U,p:null,f:null,si:null}};return this._editorBridgeService.isVisible().visible&&await this._commandService.executeCommand(B.SetCellEditVisibleOperation.id,{visible:!1,eventType:L.DeviceInputEventType.Keyboard,unitId:i,keycode:w.KeyCode.ESC}),this._commandService.executeCommand(W.SetRangeValuesCommand.id,F),!f},R=(c==null?void 0:c.renderMode)===o.DataValidationRenderMode.CUSTOM||(c==null?void 0:c.renderMode)===void 0,D=h.getListWithColor(c,i,s),V=_.getDataValidationCellValue(l.getCellRaw(n,r)),x=()=>{this._commandService.executeCommand(_e.id,{ruleId:c.uid}),p==null||p.dispose()},H=D.map(P=>({label:P.label,value:P.label,color:R||P.color?P.color:"transparent"}));S={location:a,type:"list",props:{onChange:P=>y(P),options:H,onEdit:x,defaultValue:V,multiple:f,showEdit:(m=(E=this._configService.getConfig(ut))==null?void 0:E.showEditOnDropdown)!=null?m:!0}};break}case $.DataValidatorDropdownType.CASCADE:{S={type:"cascader",props:{onChange:y=>{const R={unitId:i,subUnitId:s,range:{startColumn:r,endColumn:r,startRow:n,endRow:n},value:{v:y.join("/"),p:null,f:null,si:null}};return this._editorBridgeService.isVisible().visible&&this._commandService.syncExecuteCommand(B.SetCellEditVisibleOperation.id,{visible:!1,eventType:L.DeviceInputEventType.Keyboard,unitId:i,keycode:w.KeyCode.ESC}),this._commandService.syncExecuteCommand(W.SetRangeValuesCommand.id,R),!0},defaultValue:_.getDataValidationCellValue(l.getCellRaw(n,r)).split("/"),options:JSON.parse((C=c.formula1)!=null?C:"[]")},location:a};break}case $.DataValidatorDropdownType.COLOR:{S={type:"color",props:{onChange:y=>{const R={unitId:i,subUnitId:s,range:{startColumn:r,endColumn:r,startRow:n,endRow:n},value:{v:y,p:null,f:null,si:null}};return this._editorBridgeService.isVisible().visible&&this._commandService.syncExecuteCommand(B.SetCellEditVisibleOperation.id,{visible:!1,eventType:L.DeviceInputEventType.Keyboard,unitId:i,keycode:w.KeyCode.ESC}),this._commandService.syncExecuteCommand(W.SetRangeValuesCommand.id,R),!0},defaultValue:_.getDataValidationCellValue(l.getCellRaw(n,r))},location:a};break}default:throw new Error("[DataValidationDropdownManagerService]: unknown type!")}if(p=this._cellDropdownManagerService.showDropdown(S),!p)throw new Error("[DataValidationDropdownManagerService]: cannot show dropdown!");const v=new o.DisposableCollection;v.add(p),v.add({dispose:()=>{var f,y;(y=(f=this._activeDropdown)==null?void 0:f.onHide)==null||y.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=cn([oe(0,o.IUniverInstanceService),oe(1,o.Inject($.DataValidatorRegistryService)),oe(2,w.IZenZoneService),oe(3,o.Inject(_.SheetDataValidationModel)),oe(4,o.Inject(W.SheetsSelectionsService)),oe(5,o.Inject(B.ISheetCellDropdownManagerService)),oe(6,o.Inject(_.SheetDataValidationModel)),oe(7,o.ICommandService),oe(8,B.IEditorBridgeService),oe(9,o.Inject(o.Injector)),oe(10,o.IConfigService)],fe);const Ne="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(ue),i=e.get($.DataValidationModel),s=e.get(o.IUniverInstanceService),d=e.get(w.ISidebarService),l=W.getSheetCommandTarget(s);if(!l)return!1;const{unitId:c,subUnitId:h}=l,p=a?i.getRuleById(c,h,a):void 0;r.open(),r.setActiveRule(p&&{unitId:c,subUnitId:h,rule:p});const u=d.open({id:Ne,header:{title:n?"dataValidation.panel.addTitle":"dataValidation.panel.title"},children:{label:Ne},width:312,onClose:()=>r.close()});return r.setCloseDisposable(u),!0}},ht={id:"data-validation.operation.close-validation-panel",type:o.CommandType.OPERATION,handler(e){return e.get(ue).close(),!0}},Vt={id:"data-validation.operation.toggle-validation-panel",type:o.CommandType.OPERATION,handler(e){const t=e.get(o.ICommandService),a=e.get(ue);return a.open(),a.isOpen?t.executeCommand(ht.id):t.executeCommand(_e.id),!0}},Ye={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}},wt={type:o.CommandType.OPERATION,id:"sheet.operation.hide-data-validation-dropdown",handler(e,t){return t?(e.get(fe).hideDropdown(),!0):!1}},Xe={type:o.CommandType.COMMAND,id:"data-validation.command.addRuleAndOpen",handler(e){const t=e.get(o.IUniverInstanceService),a=W.getSheetCommandTarget(t);if(!a)return!1;const{workbook:n,worksheet:r}=a,i=_.createDefaultNewRule(e),s=e.get(o.ICommandService),d=n.getUnitId(),l=r.getSheetId(),c={rule:i,unitId:d,subUnitId:l};return s.syncExecuteCommand(_.AddSheetDataValidationCommand.id,c)?(s.syncExecuteCommand(_e.id,{ruleId:i.uid,isAdd:!0}),!0):!1}};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},Ce=(e,t)=>(a,n)=>t(a,n,e);const pe="SHEET_DATA_VALIDATION_ALERT";let Pe=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(ae.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:B.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)}))}};Pe=gn([Ce(0,o.Inject(B.HoverManagerService)),Ce(1,o.Inject(B.CellAlertManagerService)),Ce(2,o.IUniverInstanceService),Ce(3,o.Inject(o.LocaleService)),Ce(4,w.IZenZoneService),Ce(5,o.Inject(_.SheetDataValidationModel))],Pe);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 we=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=B.virtualizeDiscreteRanges([i,s]),[p,u]=h.ranges,{mapFunc:S}=h,v={row:p.startRow,col:p.startColumn},T=B.getAutoFillRepeatRange(p,u),E=new o.ObjectMatrix,m=new Set;T.forEach(D=>{const V=D.repeatStartCell,x=D.relativeRange,H={startRow:v.row,startColumn:v.col,endColumn:v.col,endRow:v.row},P={startRow:V.row,startColumn:V.col,endColumn:V.col,endRow:V.row};o.Range.foreach(x,(U,F)=>{const k=o.Rectangle.getPositionRange({startRow:U,startColumn:F,endColumn:F,endRow:U},H),{row:A,col:Y}=S(k.startRow,k.startColumn),X=this._sheetDataValidationModel.getRuleIdByLocation(d,l,A,Y)||"",G=o.Rectangle.getPositionRange({startRow:U,startColumn:F,endColumn:F,endRow:U},P),{row:J,col:q}=S(G.startRow,G.startColumn);E.setValue(J,q,X),m.add(X)})});const C=Array.from(m).map(D=>({id:D,ranges:o.queryObjectMatrix(E,V=>V===D)}));c.addRangeRules(C);const f=c.diff(this._sheetDataValidationModel.getRules(d,l)),{redoMutations:y,undoMutations:R}=_.getDataValidationDiffMutations(d,l,f,this._injector,"patched",r===B.APPLY_TYPE.ONLY_FORMAT);return{undos:R,redos:y}},a={id:_.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(B.APPLY_TYPE.SERIES,!0);return}}},onFillData:(n,r,i)=>i===B.APPLY_TYPE.COPY||i===B.APPLY_TYPE.ONLY_FORMAT||i===B.APPLY_TYPE.SERIES?t(n,i):e(),onAfterFillData:()=>{}};this.disposeWithMe(this._autoFillService.addHook(a))}};we=vn([Ke(0,B.IAutoFillService),Ke(1,o.Inject(_.SheetDataValidationModel)),Ke(2,o.Inject(o.Injector))],we);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},Ge=(e,t)=>(a,n)=>t(a,n,e);let Ee=class extends o.Disposable{constructor(t,a,n){super();O(this,"_copyInfo");this._sheetClipboardService=t,this._sheetDataValidationModel=a,this._injector=n,this._initCopyPaste()}_initCopyPaste(){this._sheetClipboardService.addClipboardHook({id:_.DATA_VALIDATION_PLUGIN_NAME,onBeforeCopy:(t,a,n)=>this._collect(t,a,n),onPasteCells:(t,a,n,r)=>{const{copyType:i=B.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=>W.rangeToDiscreteRange(n,l,t,a));if(!i)return;const{rows:s,cols:d}=i;s.forEach((l,c)=>{d.forEach((h,p)=>{const u=this._sheetDataValidationModel.getRuleIdByLocation(t,a,l,h);r.setValue(c,p,u!=null?u:"")})})}_generateMutations(t,a){if(!this._copyInfo)return{redos:[],undos:[]};if(a.copyType===B.COPY_TYPE.CUT)return this._copyInfo=null,{redos:[],undos:[]};if(!this._copyInfo||!this._copyInfo.matrix.getSizeOf()||!a.copyRange)return{redos:[],undos:[]};if([B.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_COL_WIDTH,B.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_VALUE,B.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMAT,B.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:p}=B.virtualizeDiscreteRanges([a.copyRange,t]),u=B.getRepeatRange(c,h,!0),S=new Map;u.forEach(({startRange:m})=>{var C;(C=this._copyInfo)==null||C.matrix.forValue((f,y,R)=>{const D=o.Rectangle.getPositionRange({startRow:f,endRow:f,startColumn:y,endColumn:y},m),V=`${i}-${R}`,x=this._sheetDataValidationModel.getRuleById(r,i,R);!this._sheetDataValidationModel.getRuleById(a.unitId,a.subUnitId,V)&&x&&S.set(V,{...x,uid:V});const{row:H,col:P}=p(D.startRow,D.startColumn);l.add(V),d.setValue(H,P,V)})});const v=Array.from(l).map(m=>({id:m,ranges:o.queryObjectMatrix(d,C=>C===m)}));s.addRangeRules(v);const{redoMutations:T,undoMutations:E}=_.getDataValidationDiffMutations(a.unitId,a.subUnitId,s.diffWithAddition(this._sheetDataValidationModel.getRules(a.unitId,a.subUnitId),S.values()),this._injector,"patched",!1);return{redos:T,undos:E}}else{const s=this._sheetDataValidationModel.getRuleObjectMatrix(r,i).clone(),d=new o.ObjectMatrix,l=new Set,{ranges:[c,h],mapFunc:p}=B.virtualizeDiscreteRanges([a.copyRange,t]);B.getRepeatRange(c,h,!0).forEach(({startRange:E})=>{var m;(m=this._copyInfo)==null||m.matrix.forValue((C,f,y)=>{const R=o.Rectangle.getPositionRange({startRow:C,endRow:C,startColumn:f,endColumn:f},E),{row:D,col:V}=p(R.startRow,R.startColumn);d.setValue(D,V,y),l.add(y)})});const S=Array.from(l).map(E=>({id:E,ranges:o.queryObjectMatrix(d,m=>m===E)}));s.addRangeRules(S);const{redoMutations:v,undoMutations:T}=_.getDataValidationDiffMutations(r,i,s.diff(this._sheetDataValidationModel.getRules(r,i)),this._injector,"patched",!1);return{redos:v,undos:T}}}};Ee=fn([Ge(0,B.ISheetClipboardService),Ge(1,o.Inject(_.SheetDataValidationModel)),Ge(2,o.Inject(o.Injector))],Ee);var Sn=Object.getOwnPropertyDescriptor,_n=(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},qe=(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===_.AddSheetDataValidationCommand.id&&(this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[W.WorkbookEditablePermission],rangeTypes:[W.RangeProtectionPermissionEditPoint],worksheetTypes:[W.WorksheetEditPermission,W.WorksheetSetCellStylePermission]})||this._sheetPermissionCheckController.blockExecuteWithoutPermission(this._localeService.t("permission.dialog.setStyleErr"))),e.id===_.UpdateSheetDataValidationRangeCommand.id&&(this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[W.WorkbookEditablePermission],rangeTypes:[W.RangeProtectionPermissionEditPoint],worksheetTypes:[W.WorksheetEditPermission,W.WorksheetSetCellStylePermission]},e.params.ranges)||this._sheetPermissionCheckController.blockExecuteWithoutPermission(this._localeService.t("permission.dialog.setStyleErr")))}))}};Me=_n([qe(0,o.Inject(o.LocaleService)),qe(1,o.ICommandService),qe(2,o.Inject(W.SheetPermissionCheckController))],Me);const Et="data-validation-single",Mt="sheet.menu.data-validation";function In(e){return{id:Mt,type:w.MenuItemType.SUBITEMS,icon:Et,tooltip:"dataValidation.title",hidden$:w.getMenuHiddenObservable(e,o.UniverInstanceType.UNIVER_SHEET),disabled$:B.getCurrentRangeDisable$(e,{workbookTypes:[W.WorkbookEditablePermission],worksheetTypes:[W.WorksheetSetCellStylePermission,W.WorksheetEditPermission],rangeTypes:[W.RangeProtectionPermissionEditPoint]})}}function Cn(e){return{id:_e.id,title:"dataValidation.panel.title",type:w.MenuItemType.BUTTON}}function yn(e){return{id:Xe.id,title:"dataValidation.panel.add",type:w.MenuItemType.BUTTON}}const Dn={[w.RibbonStartGroup.FORMULAS_INSERT]:{[Mt]:{order:9,menuItemFactory:In,[_e.id]:{order:0,menuItemFactory:Cn},[Xe.id]:{order:1,menuItemFactory:yn}}}};var Rn=Object.getOwnPropertyDescriptor,bt=(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},Z=(e,t)=>(a,n)=>t(a,n,e);const Tt={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(Dn)}_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 p=this._dropdownManagerService.activeDropdown,u=p==null?void 0:p.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(W.INTERCEPTOR_POINT.CELL_CONTENT,{effect:o.InterceptorEffectEnum.Style,priority:W.InterceptCellContentPriority.DATA_VALIDATION,handler:(e,t,a)=>{var m,C,f,y,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 p=(m=this._dataValidationCacheService.getValue(i,s,n,r))!=null?m:o.DataValidationStatus.VALID,u=this._dataValidatorRegistryService.getValidatorItem(h.type),S=t.rawData;let v;const T={get value(){var D;return v!==void 0||(v=(D=_.getCellValueOrigin(S))!=null?D:null),v}},E={get value(){var D;return`${(D=T.value)!=null?D:""}`}};return a({...e,markers:{...e==null?void 0:e.markers,...p===o.DataValidationStatus.INVALID?Tt:null},customRender:[...(C=e==null?void 0:e.customRender)!=null?C:[],...u!=null&&u.canvasRender?[u.canvasRender]:[]],fontRenderExtension:{...e==null?void 0:e.fontRenderExtension,isSkip:((f=e==null?void 0:e.fontRenderExtension)==null?void 0:f.isSkip)||((y=u==null?void 0:u.skipDefaultFontRender)==null?void 0:y.call(u,h,T.value,t))},interceptorStyle:{...e==null?void 0:e.interceptorStyle,...u==null?void 0:u.getExtraStyle(h,E.value,{get style(){const D=d.getStyles();return(typeof(e==null?void 0:e.s)=="string"?D.get(e==null?void 0:e.s):e==null?void 0:e.s)||{}}},n,r)},interceptorAutoHeight:()=>{var H,P,U,F,k,A;const D=(P=(H=this._renderManagerService.getRenderById(i))==null?void 0:H.with(B.SheetSkeletonManagerService).getSkeletonParam(s))==null?void 0:P.skeleton;if(!D)return;const V=D.worksheet.getMergedCell(n,r),x={data:e,style:D.getStyles().getStyleByCell(e),primaryWithCoord:D.getCellWithCoordByIndex((U=V==null?void 0:V.startRow)!=null?U:n,(F=V==null?void 0:V.startColumn)!=null?F:r),unitId:i,subUnitId:s,row:n,col:r,workbook:d,worksheet:l};return(A=(k=u==null?void 0:u.canvasRender)==null?void 0:k.calcCellAutoHeight)==null?void 0:A.call(k,x)},interceptorAutoWidth:()=>{var H,P,U,F,k,A;const D=(P=(H=this._renderManagerService.getRenderById(i))==null?void 0:H.with(B.SheetSkeletonManagerService).getSkeletonParam(s))==null?void 0:P.skeleton;if(!D)return;const V=D.worksheet.getMergedCell(n,r),x={data:e,style:D.getStyles().getStyleByCell(e),primaryWithCoord:D.getCellWithCoordByIndex((U=V==null?void 0:V.startRow)!=null?U:n,(F=V==null?void 0:V.startColumn)!=null?F:r),unitId:i,subUnitId:s,row:n,col:r,workbook:d,worksheet:l};return(A=(k=u==null?void 0:u.canvasRender)==null?void 0:k.calcCellAutoWidth)==null?void 0:A.call(k,x)},coverable:((R=e==null?void 0:e.coverable)!=null?R:!0)&&!(h.type===o.DataValidationType.LIST||h.type===o.DataValidationType.LIST_MULTIPLE)})}}))}_initAutoHeight(){this._sheetDataValidationModel.ruleChange$.pipe(ae.filter(e=>e.source==="command"),ae.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=bt([Z(0,o.ICommandService),Z(1,w.IMenuManagerService),Z(2,L.IRenderManagerService),Z(3,o.IUniverInstanceService),Z(4,o.Inject(B.AutoHeightController)),Z(5,o.Inject(fe)),Z(6,o.Inject(_.SheetDataValidationModel)),Z(7,o.Inject($.DataValidatorRegistryService)),Z(8,o.Inject(W.SheetInterceptorService)),Z(9,o.Inject(_.DataValidationCacheService)),Z(10,o.Optional(B.IEditorBridgeService))],be);let mt=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(W.INTERCEPTOR_POINT.CELL_CONTENT,{effect:o.InterceptorEffectEnum.Style,priority:W.InterceptCellContentPriority.DATA_VALIDATION,handler:(e,t,a)=>{var E,m,C,f,y;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 p=(E=this._dataValidationCacheService.getValue(i,s,n,r))!=null?E:o.DataValidationStatus.VALID,u=this._dataValidatorRegistryService.getValidatorItem(h.type),S=l.getCellRaw(n,r),v=_.getCellValueOrigin(S),T=`${v!=null?v:""}`;return a({...e,markers:{...e==null?void 0:e.markers,...p===o.DataValidationStatus.INVALID?Tt:null},customRender:[...(m=e==null?void 0:e.customRender)!=null?m:[],...u!=null&&u.canvasRender?[u.canvasRender]:[]],fontRenderExtension:{...e==null?void 0:e.fontRenderExtension,isSkip:((C=e==null?void 0:e.fontRenderExtension)==null?void 0:C.isSkip)||((f=u==null?void 0:u.skipDefaultFontRender)==null?void 0:f.call(u,h,v,t))},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)},interceptorAutoHeight:()=>{var x,H,P,U,F,k;const R=(H=(x=this._renderManagerService.getRenderById(i))==null?void 0:x.with(B.SheetSkeletonManagerService).getSkeletonParam(s))==null?void 0:H.skeleton;if(!R)return;const D=R.worksheet.getMergedCell(n,r),V={data:e,style:R.getStyles().getStyleByCell(e),primaryWithCoord:R.getCellWithCoordByIndex((P=D==null?void 0:D.startRow)!=null?P:n,(U=D==null?void 0:D.startColumn)!=null?U:r),unitId:i,subUnitId:s,row:n,col:r,workbook:d,worksheet:l};return(k=(F=u==null?void 0:u.canvasRender)==null?void 0:F.calcCellAutoHeight)==null?void 0:k.call(F,V)},coverable:((y=e==null?void 0:e.coverable)!=null?y:!0)&&!(h.type===o.DataValidationType.LIST||h.type===o.DataValidationType.LIST_MULTIPLE)})}}))}_initAutoHeight(){this._sheetDataValidationModel.ruleChange$.pipe(ae.filter(e=>e.source==="command"),ae.bufferTime(16)).subscribe(e=>{const t=[];if(e.forEach(a=>{var n;(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)}})}};mt=bt([Z(0,o.ICommandService),Z(1,L.IRenderManagerService),Z(2,o.Inject(B.AutoHeightController)),Z(3,o.Inject($.DataValidatorRegistryService)),Z(4,o.Inject(W.SheetInterceptorService)),Z(5,o.Inject(_.SheetDataValidationModel)),Z(6,o.Inject(_.DataValidationCacheService))],mt);var Vn=Object.getOwnPropertyDescriptor,wn=(e,t,a,n)=>{for(var r=n>1?void 0:n?Vn(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},ft=(e,t)=>(a,n)=>t(a,n,e);let Be=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))}};Be=wn([ft(1,o.Inject(_.SheetDataValidationModel)),ft(2,o.Inject(B.SheetSkeletonManagerService))],Be);function En(e){var c;const t=w.useDependency(o.LocaleService),a=w.useDependency(w.ComponentManager),{value:n,onChange:r,extraComponent:i}=e,[s,d]=M.useState(!1),l=i?a.get(i):null;return g.jsxs(g.Fragment,{children:[g.jsxs("div",{className:`
40
- univer-mb-3 univer-flex univer-cursor-pointer univer-items-center univer-text-sm univer-text-black
41
- `,onClick:()=>d(!s),children:[t.t("dataValidation.panel.options"),s?g.jsx(Dt,{className:"univer-ml-1 univer-text-[8px]"}):g.jsx(ct,{className:"univer-ml-1 univer-text-[8px]"})]}),s&&g.jsxs(g.Fragment,{children:[l?g.jsx(l,{value:n,onChange:r}):null,g.jsx(b.FormLayout,{label:t.t("dataValidation.panel.invalid"),children:g.jsxs(b.RadioGroup,{value:`${(c=n.errorStyle)!=null?c:o.DataValidationErrorStyle.WARNING}`,onChange:h=>r({...n,errorStyle:+h}),children:[g.jsx(b.Radio,{value:`${o.DataValidationErrorStyle.WARNING}`,children:t.t("dataValidation.panel.showWarning")}),g.jsx(b.Radio,{value:`${o.DataValidationErrorStyle.STOP}`,children:t.t("dataValidation.panel.rejectInput")})]})}),g.jsx(b.FormLayout,{label:t.t("dataValidation.panel.messageInfo"),children:g.jsx(b.Checkbox,{checked:n.showErrorMessage,onChange:()=>r({...n,showErrorMessage:!n.showErrorMessage}),children:t.t("dataValidation.panel.showInfo")})}),n.showErrorMessage?g.jsx(b.FormLayout,{children:g.jsx(b.Input,{value:n.error,onChange:h=>r({...n,error:h})})}):null]})]})}const Mn=e=>o.debounce(async(t,a,n,r)=>{const i=await e.executeCommand(t,a,n);r==null||r(i)},1e3);function bn(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 Tn(){var j,K;const[e,t]=M.useState(0),a=w.useDependency(ue),n=w.useObservable(a.activeRule$,a.activeRule),{unitId:r,subUnitId:i,rule:s}=n||{},d=s.uid,l=w.useDependency($.DataValidatorRegistryService),c=w.useDependency(o.IUniverInstanceService),h=w.useDependency(w.ComponentManager),p=w.useDependency(o.ICommandService),u=w.useDependency($.DataValidationModel),S=w.useDependency(o.LocaleService),[v,T]=M.useState(s),E=l.getValidatorItem(v.type),[m,C]=M.useState(!1),f=l.getValidatorsByScope($.DataValidatorRegistryScope.SHEET),[y,R]=M.useState(()=>v.ranges.map(I=>({unitId:"",sheetId:"",range:I}))),D=M.useMemo(()=>Mn(p),[p]),[V,x]=M.useState(!1),[H,P]=M.useState(!1),U=M.useRef(null),F=w.useDependency(W.SheetsSelectionsService);if(M.useEffect(()=>()=>{const I=F.getCurrentLastSelection();I&&F.setSelections([I])},[F]),M.useEffect(()=>{p.onCommandExecuted(I=>{(I.id===o.UndoCommand.id||I.id===o.RedoCommand.id)&&setTimeout(()=>{const N=u.getRuleById(r,i,d);t(z=>z+1),N&&(T(N),R(N.ranges.map(z=>({unitId:"",sheetId:"",range:z}))))},20)})},[p,u,d,i,r]),!E)return null;const k=E.operators,A=E.operatorNames,Y=v.operator?$.TWO_FORMULA_OPERATOR_COUNT.includes(v.operator):!1,X=()=>{var I,N,z;(N=(I=U.current)==null?void 0:I.editor)!=null&&N.isFocus()&&G((z=U.current)==null?void 0:z.getValue()),!(!v.ranges.length||V)&&(E.validatorFormula(v,r,i).success?a.setActiveRule(null):C(!0))},G=w.useEvent(I=>{const N=I.split(",").filter(Boolean).map(at.deserializeRangeWithSheet).map(Q=>{const gt=Q.sheetName;if(gt){const Lt=bn(c,Q.unitId,gt);return{...Q,sheetId:Lt}}return{...Q,sheetId:""}});if(o.isUnitRangesEqual(N,y))return;R(N);const z=N.filter(Q=>(!Q.unitId||Q.unitId===r)&&(!Q.sheetId||Q.sheetId===i)).map(Q=>Q.range);if(T({...v,ranges:z}),z.length===0)return;const ge={unitId:r,subUnitId:i,ruleId:d,ranges:z};D(_.UpdateSheetDataValidationRangeCommand.id,ge)}),J=I=>{if(o.shallowEqual(I,$.getRuleSetting(v)))return;T({...v,...I});const N={unitId:r,subUnitId:i,ruleId:d,setting:I};D(_.UpdateSheetDataValidationSettingCommand.id,N,void 0)},q=async()=>{await p.executeCommand(_.RemoveSheetDataValidationCommand.id,{ruleId:d,unitId:r,subUnitId:i}),a.setActiveRule(null)},ee={type:v.type,operator:v.operator,formula1:v.formula1,formula2:v.formula2,allowBlank:v.allowBlank},le=I=>{const N=l.getValidatorItem(I);if(!N)return;const z=N.operators,ge=u.getRuleById(r,i,d),Q=I===(ge==null?void 0:ge.type)||I.includes("list")&&(ge!=null&&ge.type.includes("list"))?{...ge,type:I}:{...v,type:I,operator:z[0],formula1:void 0,formula2:void 0};T(Q),p.executeCommand(_.UpdateSheetDataValidationSettingCommand.id,{unitId:r,subUnitId:i,ruleId:v.uid,setting:$.getRuleSetting(Q)})},re=h.get(E.formulaInput),te=M.useMemo(()=>y.map(I=>at.serializeRange(I.range)).join(","),[]),ie=$.getRuleOptions(v),he=I=>{o.shallowEqual(I,$.getRuleOptions(v))||(T({...v,...I}),D(_.UpdateSheetDataValidationOptionsCommand.id,{unitId:r,subUnitId:i,ruleId:d,options:I}))},de=k.length&&!v.operator;return g.jsxs("div",{className:"univer-py-4",children:[g.jsx(b.FormLayout,{label:S.t("dataValidation.panel.range"),error:!v.ranges.length||V?S.t("dataValidation.panel.rangeError"):"",children:g.jsx(lt.RangeSelector,{selectorRef:U,unitId:r,subUnitId:i,initialValue:te,onChange:(I,N)=>{var z;!H&&((z=U.current)!=null&&z.verify())&&G(N)},onFocusChange:(I,N)=>{var z;P(I),!I&&N&&((z=U.current)!=null&&z.verify())&&G(N)},onVerify:I=>x(!I)})}),g.jsx(b.FormLayout,{label:S.t("dataValidation.panel.type"),children:g.jsx(b.Select,{className:"univer-w-full",value:v.type,options:(j=f==null?void 0:f.sort((I,N)=>I.order-N.order))==null?void 0:j.map(I=>({label:S.t(I.title),value:I.id})),onChange:le})}),k!=null&&k.length?g.jsx(b.FormLayout,{label:S.t("dataValidation.panel.operator"),children:g.jsx(b.Select,{className:"univer-w-full",value:`${v.operator}`,options:[{value:"",label:S.t("dataValidation.operators.legal")},...k.map((I,N)=>({value:`${I}`,label:A[N]}))],onChange:I=>{J({...ee,operator:I})}})}):null,re&&!de?g.jsx(b.FormLayout,{children:g.jsx(re,{isTwoFormula:Y,value:{formula1:v.formula1,formula2:v.formula2},onChange:I=>{J({...ee,...I})},showError:m,validResult:E.validatorFormula(v,r,i),unitId:r,subUnitId:i,ruleId:d},e+v.type)}):null,g.jsx(b.FormLayout,{children:g.jsx(b.Checkbox,{checked:(K=v.allowBlank)!=null?K:!0,onChange:()=>{var I;return J({...ee,allowBlank:!((I=v.allowBlank)==null||I)})},children:S.t("dataValidation.panel.allowBlank")})}),g.jsx(En,{value:ie,onChange:he,extraComponent:E.optionsInput}),g.jsxs("div",{className:"univer-mt-5 univer-flex univer-flex-row univer-justify-end",children:[g.jsx(b.Button,{className:"univer-ml-3",onClick:q,children:S.t("dataValidation.panel.removeRule")}),g.jsx(b.Button,{className:"univer-ml-3",variant:"primary",onClick:X,children:S.t("dataValidation.panel.done")})]})]})}const On=e=>{const{rule:t,onClick:a,unitId:n,subUnitId:r,disable:i}=e,s=w.useDependency($.DataValidatorRegistryService),d=w.useDependency(o.ICommandService),l=w.useDependency(B.IMarkSelectionService),c=s.getValidatorItem(t.type),h=M.useRef(void 0),[p,u]=M.useState(!1),S=w.useDependency(o.ThemeService),v=w.useObservable(S.currentTheme$),T=M.useMemo(()=>{var R;const m=S.getColorFromTheme("primary.600"),C=S.getColorFromTheme("loop-color.2"),f=(R=S.getColorFromTheme(C))!=null?R:m,y=new o.ColorKit(f).toRgb();return{fill:`rgba(${y.r}, ${y.g}, ${y.b}, 0.1)`,stroke:f}},[v]),E=m=>{d.executeCommand(_.RemoveSheetDataValidationCommand.id,{ruleId:t.uid,unitId:n,subUnitId:r}),m.stopPropagation()};return M.useEffect(()=>()=>{var m;h.current&&((m=h.current)==null||m.forEach(C=>{C&&l.removeShape(C)}))},[l]),g.jsxs("div",{className:b.clsx(`
31
+ `,onClick:re,children:[p.jsx(yt,{className:"univer-mr-1"}),M.t("dataValidation.list.add")]})]})})]})}const en=[[_.CUSTOM_FORMULA_INPUT_NAME,kt],[_.BASE_FORMULA_INPUT_NAME,Ft],[_.LIST_FORMULA_INPUT_NAME,Qt],[_.CHECKBOX_FORMULA_INPUT_NAME,Nt]];var tn=Object.getOwnPropertyDescriptor,nn=(e,t,a,n)=>{for(var r=n>1?void 0:n?tn(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},an=(e,t)=>(a,n)=>t(a,n,e);exports.BaseSheetDataValidatorView=class{constructor(t){O(this,"canvasRender",null);O(this,"dropdownType");O(this,"optionsInput");O(this,"formulaInput",_.LIST_FORMULA_INPUT_NAME);this.injector=t}};exports.BaseSheetDataValidatorView=nn([an(0,o.Inject(o.Injector))],exports.BaseSheetDataValidatorView);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},vt=(e,t)=>(a,n)=>t(a,n,e);let ue=class extends o.Disposable{constructor(t,a){super();O(this,"_open$",new ae.BehaviorSubject(!1));O(this,"open$",this._open$.pipe(ae.distinctUntilChanged()));O(this,"_activeRule");O(this,"_activeRule$",new ae.BehaviorSubject(void 0));O(this,"activeRule$",this._activeRule$.asObservable());O(this,"_closeDisposable",null);this._univerInstanceService=t,this._sidebarService=a,this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(o.UniverInstanceType.UNIVER_SHEET).pipe(ae.filter(n=>!n)).subscribe(()=>{this.close()})),this.disposeWithMe(this._sidebarService.sidebarOptions$.subscribe(n=>{n.id===ke&&(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)}};ue=on([vt(0,o.IUniverInstanceService),vt(1,w.ISidebarService)],ue);const ut="sheets-data-validation-ui.config",Ne={};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},Ie=(e,t)=>(a,n)=>t(a,n,e);let Ve=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(W.VALIDATE_CELL,{handler:async(e,t,a)=>{const n=await e,{row:r,col:i,unitId:s,subUnitId:c}=t,l=this._dataValidationModel.getRuleIdByLocation(s,c,r,i),d=l?this._dataValidationModel.getRuleById(s,c,l):void 0;if(n===!1)return a(Promise.resolve(!1));if(!d||d.errorStyle!==o.DataValidationErrorStyle.STOP)return a(Promise.resolve(!0));const h=this._dataValidatorRegistryService.getValidatorItem(d.type);return!h||await this._sheetsDataValidationValidatorService.validatorCell(s,c,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(d,{row:r,col:i,unitId:s,subUnitId:c})},footer:{title:b.createElement(E.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(E.Button,{variant:"primary",onClick:()=>this._dialogService.close("reject-input-dialog")},this._localeService.t("dataValidation.alert.ok"))},onClose:()=>{this._dialogService.close("reject-input-dialog")}})}};Ve=ln([Ie(0,o.Inject(W.SheetInterceptorService)),Ie(1,o.Inject(_.SheetDataValidationModel)),Ie(2,o.Inject($.DataValidatorRegistryService)),Ie(3,w.IDialogService),Ie(4,o.Inject(o.LocaleService)),Ie(5,o.Inject(_.SheetsDataValidationValidatorService))],Ve);var cn=Object.getOwnPropertyDescriptor,dn=(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},oe=(e,t)=>(a,n)=>t(a,n,e);const ze=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 un(e,t){const a=Ut.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,c,l,d,h,g){super();O(this,"_activeDropdown");O(this,"_activeDropdown$",new ae.Subject);O(this,"_currentPopup",null);O(this,"activeDropdown$",this._activeDropdown$.asObservable());O(this,"_zenVisible",!1);this._univerInstanceService=t,this._dataValidatorRegistryService=a,this._zenZoneService=n,this._dataValidationModel=r,this._sheetsSelectionsService=i,this._cellDropdownManagerService=s,this._sheetDataValidationModel=c,this._commandService=l,this._editorBridgeService=d,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 c=this._dataValidationModel.getRuleByLocation(i.getUnitId(),s.getSheetId(),n,r);if(!c)return;const l=this._dataValidatorRegistryService.getValidatorItem(c.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,C;const{location:a}=t,{row:n,col:r,unitId:i,subUnitId:s,workbook:c,worksheet:l}=a;if(this._currentPopup&&this._currentPopup.dispose(),this._zenVisible)return;this._activeDropdown=t,this._activeDropdown$.next(this._activeDropdown);const d=this._sheetDataValidationModel.getRuleByLocation(i,s,n,r);if(!d)return;const h=this._dataValidatorRegistryService.getValidatorItem(d.type);if(!(h!=null&&h.dropdownType))return;let g;const u=async(f,y)=>{var F,N,A;if(!f)return!0;const R=f,D=l.getCell(n,r),V=R.format(y==="date"?"YYYY-MM-DD 00:00:00":"YYYY-MM-DD HH:mm:ss"),x=(F=o.numfmt.parseDate(V))==null?void 0:F.v,H=y==="time"?x%1:x,P=c.getStyles().getStyleByCell(D),U=(A=(N=P==null?void 0:P.n)==null?void 0:N.pattern)!=null?A:"";return d.errorStyle!==o.DataValidationErrorStyle.STOP||await h.validator({value:H,unitId:i,subUnitId:s,row:n,column:r,worksheet:l,workbook:c,interceptValue:V.replace("Z","").replace("T"," "),t:o.CellValueType.NUMBER},d)?(await this._commandService.executeCommand(B.SetCellEditVisibleOperation.id,{visible:!1,eventType:L.DeviceInputEventType.Keyboard,unitId:i,keycode:w.KeyCode.ESC}),await this._commandService.executeCommand(W.SetRangeValuesCommand.id,{unitId:i,subUnitId:s,range:{startColumn:r,endColumn:r,startRow:n,endRow:n},value:{v:H,t:2,p:null,f:null,si:null,s:{n:{pattern:un(y,U)}}}}),!0):(this._injector.has(Ve)&&this._injector.get(Ve).showReject(h.getRuleFinalError(d,{row:n,col:r,unitId:i,subUnitId:s})),!1)};let S;switch(h.dropdownType){case $.DataValidatorDropdownType.DATE:{const f=_.getCellValueOrigin(l.getCellRaw(n,r)),y=ze(f),R=!!((T=d.bizInfo)!=null&&T.showTime);S={location:a,type:"datepicker",props:{showTime:R,onChange:D=>u(D,R?"datetime":"date"),defaultValue:y,patternType:"date"}};break}case $.DataValidatorDropdownType.TIME:{const f=_.getCellValueOrigin(l.getCellRaw(n,r)),y=ze(f);S={location:a,type:"datepicker",props:{onChange:R=>u(R,"time"),defaultValue:y,patternType:"time"}};break}case $.DataValidatorDropdownType.DATETIME:{const f=_.getCellValueOrigin(l.getCellRaw(n,r)),y=ze(f);S={location:a,type:"datepicker",props:{onChange:R=>u(R,"datetime"),defaultValue:y,patternType:"datetime"}};break}case $.DataValidatorDropdownType.LIST:case $.DataValidatorDropdownType.MULTIPLE_LIST:{const f=h.dropdownType===$.DataValidatorDropdownType.MULTIPLE_LIST,y=async P=>{const U=_.serializeListOptions(P),F={unitId:i,subUnitId:s,range:{startColumn:r,endColumn:r,startRow:n,endRow:n},value:{v:U,p:null,f:null,si:null}};return this._editorBridgeService.isVisible().visible&&await this._commandService.executeCommand(B.SetCellEditVisibleOperation.id,{visible:!1,eventType:L.DeviceInputEventType.Keyboard,unitId:i,keycode:w.KeyCode.ESC}),this._commandService.executeCommand(W.SetRangeValuesCommand.id,F),!f},R=(d==null?void 0:d.renderMode)===o.DataValidationRenderMode.CUSTOM||(d==null?void 0:d.renderMode)===void 0,D=h.getListWithColor(d,i,s),V=_.getDataValidationCellValue(l.getCellRaw(n,r)),x=()=>{this._commandService.executeCommand(_e.id,{ruleId:d.uid}),g==null||g.dispose()},H=D.map(P=>({label:P.label,value:P.label,color:R||P.color?P.color:"transparent"}));S={location:a,type:"list",props:{onChange:P=>y(P),options:H,onEdit:x,defaultValue:V,multiple:f,showEdit:(m=(M=this._configService.getConfig(ut))==null?void 0:M.showEditOnDropdown)!=null?m:!0}};break}case $.DataValidatorDropdownType.CASCADE:{S={type:"cascader",props:{onChange:y=>{const R={unitId:i,subUnitId:s,range:{startColumn:r,endColumn:r,startRow:n,endRow:n},value:{v:y.join("/"),p:null,f:null,si:null}};return this._editorBridgeService.isVisible().visible&&this._commandService.syncExecuteCommand(B.SetCellEditVisibleOperation.id,{visible:!1,eventType:L.DeviceInputEventType.Keyboard,unitId:i,keycode:w.KeyCode.ESC}),this._commandService.syncExecuteCommand(W.SetRangeValuesCommand.id,R),!0},defaultValue:_.getDataValidationCellValue(l.getCellRaw(n,r)).split("/"),options:JSON.parse((C=d.formula1)!=null?C:"[]")},location:a};break}case $.DataValidatorDropdownType.COLOR:{S={type:"color",props:{onChange:y=>{const R={unitId:i,subUnitId:s,range:{startColumn:r,endColumn:r,startRow:n,endRow:n},value:{v:y,p:null,f:null,si:null}};return this._editorBridgeService.isVisible().visible&&this._commandService.syncExecuteCommand(B.SetCellEditVisibleOperation.id,{visible:!1,eventType:L.DeviceInputEventType.Keyboard,unitId:i,keycode:w.KeyCode.ESC}),this._commandService.syncExecuteCommand(W.SetRangeValuesCommand.id,R),!0},defaultValue:_.getDataValidationCellValue(l.getCellRaw(n,r))},location:a};break}default:throw new Error("[DataValidationDropdownManagerService]: unknown type!")}if(g=this._cellDropdownManagerService.showDropdown(S),!g)throw new Error("[DataValidationDropdownManagerService]: cannot show dropdown!");const v=new o.DisposableCollection;v.add(g),v.add({dispose:()=>{var f,y;(y=(f=this._activeDropdown)==null?void 0:f.onHide)==null||y.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 c=s.getSheetBySheetId(a);if(!c)return;const l=this._dataValidationModel.getRuleByLocation(s.getUnitId(),c.getSheetId(),n,r);if(!l)return;const d=this._dataValidatorRegistryService.getValidatorItem(l.type);if(!d||!d.dropdownType){this.hideDropdown();return}this.showDropdown({location:{workbook:s,worksheet:c,row:n,col:r,unitId:t,subUnitId:a},onHide:i})}};fe=dn([oe(0,o.IUniverInstanceService),oe(1,o.Inject($.DataValidatorRegistryService)),oe(2,w.IZenZoneService),oe(3,o.Inject(_.SheetDataValidationModel)),oe(4,o.Inject(W.SheetsSelectionsService)),oe(5,o.Inject(B.ISheetCellDropdownManagerService)),oe(6,o.Inject(_.SheetDataValidationModel)),oe(7,o.ICommandService),oe(8,B.IEditorBridgeService),oe(9,o.Inject(o.Injector)),oe(10,o.IConfigService)],fe);const ke="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(ue),i=e.get($.DataValidationModel),s=e.get(o.IUniverInstanceService),c=e.get(w.ISidebarService),l=W.getSheetCommandTarget(s);if(!l)return!1;const{unitId:d,subUnitId:h}=l,g=a?i.getRuleById(d,h,a):void 0;r.open(),r.setActiveRule(g&&{unitId:d,subUnitId:h,rule:g});const u=c.open({id:ke,header:{title:n?"dataValidation.panel.addTitle":"dataValidation.panel.title"},children:{label:ke},width:312,onClose:()=>r.close()});return r.setCloseDisposable(u),!0}},ht={id:"data-validation.operation.close-validation-panel",type:o.CommandType.OPERATION,handler(e){return e.get(ue).close(),!0}},Vt={id:"data-validation.operation.toggle-validation-panel",type:o.CommandType.OPERATION,handler(e){const t=e.get(o.ICommandService),a=e.get(ue);return a.open(),a.isOpen?t.executeCommand(ht.id):t.executeCommand(_e.id),!0}},Ye={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,c=a.activeDropdown,l=c==null?void 0:c.location;return l&&l.unitId===n&&l.subUnitId===r&&l.row===i&&l.col===s||a.showDataValidationDropdown(n,r,i,s),!0}},wt={type:o.CommandType.OPERATION,id:"sheet.operation.hide-data-validation-dropdown",handler(e,t){return t?(e.get(fe).hideDropdown(),!0):!1}},Xe={type:o.CommandType.COMMAND,id:"data-validation.command.addRuleAndOpen",handler(e){const t=e.get(o.IUniverInstanceService),a=W.getSheetCommandTarget(t);if(!a)return!1;const{workbook:n,worksheet:r}=a,i=_.createDefaultNewRule(e),s=e.get(o.ICommandService),c=n.getUnitId(),l=r.getSheetId(),d={rule:i,unitId:c,subUnitId:l};return s.syncExecuteCommand(_.AddSheetDataValidationCommand.id,d)?(s.syncExecuteCommand(_e.id,{ruleId:i.uid,isAdd:!0}),!0):!1}};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},Ce=(e,t)=>(a,n)=>t(a,n,e);const pe="SHEET_DATA_VALIDATION_ALERT";let Pe=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(ae.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),c=(t=s==null?void 0:s.alert)==null?void 0:t.location;if(c&&c.row===e.location.row&&c.col===e.location.col&&c.subUnitId===e.location.subUnitId&&c.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:B.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)}))}};Pe=gn([Ce(0,o.Inject(B.HoverManagerService)),Ce(1,o.Inject(B.CellAlertManagerService)),Ce(2,o.IUniverInstanceService),Ce(3,o.Inject(o.LocaleService)),Ce(4,w.IZenZoneService),Ce(5,o.Inject(_.SheetDataValidationModel))],Pe);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 we=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:c,subUnitId:l}=n,d=this._sheetDataValidationModel.getRuleObjectMatrix(c,l).clone(),h=B.virtualizeDiscreteRanges([i,s]),[g,u]=h.ranges,{mapFunc:S}=h,v={row:g.startRow,col:g.startColumn},T=B.getAutoFillRepeatRange(g,u),M=new o.ObjectMatrix,m=new Set;T.forEach(D=>{const V=D.repeatStartCell,x=D.relativeRange,H={startRow:v.row,startColumn:v.col,endColumn:v.col,endRow:v.row},P={startRow:V.row,startColumn:V.col,endColumn:V.col,endRow:V.row};o.Range.foreach(x,(U,F)=>{const N=o.Rectangle.getPositionRange({startRow:U,startColumn:F,endColumn:F,endRow:U},H),{row:A,col:Y}=S(N.startRow,N.startColumn),X=this._sheetDataValidationModel.getRuleIdByLocation(c,l,A,Y)||"",G=o.Rectangle.getPositionRange({startRow:U,startColumn:F,endColumn:F,endRow:U},P),{row:J,col:q}=S(G.startRow,G.startColumn);M.setValue(J,q,X),m.add(X)})});const C=Array.from(m).map(D=>({id:D,ranges:o.queryObjectMatrix(M,V=>V===D)}));d.addRangeRules(C);const f=d.diff(this._sheetDataValidationModel.getRules(c,l)),{redoMutations:y,undoMutations:R}=_.getDataValidationDiffMutations(c,l,f,this._injector,"patched",r===B.APPLY_TYPE.ONLY_FORMAT);return{undos:R,redos:y}},a={id:_.DATA_VALIDATION_PLUGIN_NAME,onBeforeFillData:n=>{const{source:r,unitId:i,subUnitId:s}=n;for(const c of r.rows)for(const l of r.cols){const d=this._sheetDataValidationModel.getRuleByLocation(i,s,c,l);if(d&&d.type===o.DataValidationType.CHECKBOX){this._autoFillService.setDisableApplyType(B.APPLY_TYPE.SERIES,!0);return}}},onFillData:(n,r,i)=>i===B.APPLY_TYPE.COPY||i===B.APPLY_TYPE.ONLY_FORMAT||i===B.APPLY_TYPE.SERIES?t(n,i):e(),onAfterFillData:()=>{}};this.disposeWithMe(this._autoFillService.addHook(a))}};we=vn([Ke(0,B.IAutoFillService),Ke(1,o.Inject(_.SheetDataValidationModel)),Ke(2,o.Inject(o.Injector))],we);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},Ge=(e,t)=>(a,n)=>t(a,n,e);let Ee=class extends o.Disposable{constructor(t,a,n){super();O(this,"_copyInfo");this._sheetClipboardService=t,this._sheetDataValidationModel=a,this._injector=n,this._initCopyPaste()}_initCopyPaste(){this._sheetClipboardService.addClipboardHook({id:_.DATA_VALIDATION_PLUGIN_NAME,onBeforeCopy:(t,a,n)=>this._collect(t,a,n),onPasteCells:(t,a,n,r)=>{const{copyType:i=B.COPY_TYPE.COPY,pasteType:s}=r,{range:c}=t||{},{range:l,unitId:d,subUnitId:h}=a;return this._generateMutations(l,{copyType:i,pasteType:s,copyRange:c,unitId:d,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=>W.rangeToDiscreteRange(n,l,t,a));if(!i)return;const{rows:s,cols:c}=i;s.forEach((l,d)=>{c.forEach((h,g)=>{const u=this._sheetDataValidationModel.getRuleIdByLocation(t,a,l,h);r.setValue(d,g,u!=null?u:"")})})}_generateMutations(t,a){if(!this._copyInfo)return{redos:[],undos:[]};if(a.copyType===B.COPY_TYPE.CUT)return this._copyInfo=null,{redos:[],undos:[]};if(!this._copyInfo||!this._copyInfo.matrix.getSizeOf()||!a.copyRange)return{redos:[],undos:[]};if([B.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_COL_WIDTH,B.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_VALUE,B.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMAT,B.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(),c=new o.ObjectMatrix,l=new Set,{ranges:[d,h],mapFunc:g}=B.virtualizeDiscreteRanges([a.copyRange,t]),u=B.getRepeatRange(d,h,!0),S=new Map;u.forEach(({startRange:m})=>{var C;(C=this._copyInfo)==null||C.matrix.forValue((f,y,R)=>{const D=o.Rectangle.getPositionRange({startRow:f,endRow:f,startColumn:y,endColumn:y},m),V=`${i}-${R}`,x=this._sheetDataValidationModel.getRuleById(r,i,R);!this._sheetDataValidationModel.getRuleById(a.unitId,a.subUnitId,V)&&x&&S.set(V,{...x,uid:V});const{row:H,col:P}=g(D.startRow,D.startColumn);l.add(V),c.setValue(H,P,V)})});const v=Array.from(l).map(m=>({id:m,ranges:o.queryObjectMatrix(c,C=>C===m)}));s.addRangeRules(v);const{redoMutations:T,undoMutations:M}=_.getDataValidationDiffMutations(a.unitId,a.subUnitId,s.diffWithAddition(this._sheetDataValidationModel.getRules(a.unitId,a.subUnitId),S.values()),this._injector,"patched",!1);return{redos:T,undos:M}}else{const s=this._sheetDataValidationModel.getRuleObjectMatrix(r,i).clone(),c=new o.ObjectMatrix,l=new Set,{ranges:[d,h],mapFunc:g}=B.virtualizeDiscreteRanges([a.copyRange,t]);B.getRepeatRange(d,h,!0).forEach(({startRange:M})=>{var m;(m=this._copyInfo)==null||m.matrix.forValue((C,f,y)=>{const R=o.Rectangle.getPositionRange({startRow:C,endRow:C,startColumn:f,endColumn:f},M),{row:D,col:V}=g(R.startRow,R.startColumn);c.setValue(D,V,y),l.add(y)})});const S=Array.from(l).map(M=>({id:M,ranges:o.queryObjectMatrix(c,m=>m===M)}));s.addRangeRules(S);const{redoMutations:v,undoMutations:T}=_.getDataValidationDiffMutations(r,i,s.diff(this._sheetDataValidationModel.getRules(r,i)),this._injector,"patched",!1);return{redos:v,undos:T}}}};Ee=fn([Ge(0,B.ISheetClipboardService),Ge(1,o.Inject(_.SheetDataValidationModel)),Ge(2,o.Inject(o.Injector))],Ee);var Sn=Object.getOwnPropertyDescriptor,_n=(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},qe=(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===_.AddSheetDataValidationCommand.id&&(this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[W.WorkbookEditablePermission],rangeTypes:[W.RangeProtectionPermissionEditPoint],worksheetTypes:[W.WorksheetEditPermission,W.WorksheetSetCellStylePermission]})||this._sheetPermissionCheckController.blockExecuteWithoutPermission(this._localeService.t("permission.dialog.setStyleErr"))),e.id===_.UpdateSheetDataValidationRangeCommand.id&&(this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[W.WorkbookEditablePermission],rangeTypes:[W.RangeProtectionPermissionEditPoint],worksheetTypes:[W.WorksheetEditPermission,W.WorksheetSetCellStylePermission]},e.params.ranges)||this._sheetPermissionCheckController.blockExecuteWithoutPermission(this._localeService.t("permission.dialog.setStyleErr")))}))}};Me=_n([qe(0,o.Inject(o.LocaleService)),qe(1,o.ICommandService),qe(2,o.Inject(W.SheetPermissionCheckController))],Me);const Et="data-validation-single",Mt="sheet.menu.data-validation";function In(e){return{id:Mt,type:w.MenuItemType.SUBITEMS,icon:Et,tooltip:"dataValidation.title",hidden$:w.getMenuHiddenObservable(e,o.UniverInstanceType.UNIVER_SHEET),disabled$:B.getCurrentRangeDisable$(e,{workbookTypes:[W.WorkbookEditablePermission],worksheetTypes:[W.WorksheetSetCellStylePermission,W.WorksheetEditPermission],rangeTypes:[W.RangeProtectionPermissionEditPoint]})}}function Cn(e){return{id:_e.id,title:"dataValidation.panel.title",type:w.MenuItemType.BUTTON}}function yn(e){return{id:Xe.id,title:"dataValidation.panel.add",type:w.MenuItemType.BUTTON}}const Dn={[w.RibbonStartGroup.FORMULAS_INSERT]:{[Mt]:{order:9,menuItemFactory:In,[_e.id]:{order:0,menuItemFactory:Cn},[Xe.id]:{order:1,menuItemFactory:yn}}}};var Rn=Object.getOwnPropertyDescriptor,bt=(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},Z=(e,t)=>(a,n)=>t(a,n,e);const Tt={tr:{size:6,color:"#fe4b4b"}};let be=class extends o.RxDisposable{constructor(e,t,a,n,r,i,s,c,l,d,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=c,this._sheetInterceptorService=l,this._dataValidationCacheService=d,this._editorBridgeService=h,this._initMenu(),this._initDropdown(),this._initViewModelIntercept(),this._initAutoHeight()}_initMenu(){this._menuManagerService.mergeMenu(Dn)}_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,c=this._univerInstanceService.getUniverSheetInstance(n);if(!c)return;const l=this._sheetDataValidationModel.getRuleByLocation(n,r,i,s);if(!l)return;const d=this._dataValidatorRegistryService.getValidatorItem(l.type);if(!(d!=null&&d.dropdownType))return;const h=c.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:c,worksheet:h},trigger:"editor-bridge",closeOnOutSide:!1})}}))}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(W.INTERCEPTOR_POINT.CELL_CONTENT,{effect:o.InterceptorEffectEnum.Style,priority:W.InterceptCellContentPriority.DATA_VALIDATION,handler:(e,t,a)=>{var m,C,f,y,R;const{row:n,col:r,unitId:i,subUnitId:s,workbook:c,worksheet:l}=t,d=this._sheetDataValidationModel.getRuleIdByLocation(i,s,n,r);if(!d)return a(e);const h=this._sheetDataValidationModel.getRuleById(i,s,d);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),S=t.rawData;let v;const T={get value(){var D;return v!==void 0||(v=(D=_.getCellValueOrigin(S))!=null?D:null),v}},M={get value(){var D;return`${(D=T.value)!=null?D:""}`}};return a({...e,markers:{...e==null?void 0:e.markers,...g===o.DataValidationStatus.INVALID?Tt:null},customRender:[...(C=e==null?void 0:e.customRender)!=null?C:[],...u!=null&&u.canvasRender?[u.canvasRender]:[]],fontRenderExtension:{...e==null?void 0:e.fontRenderExtension,isSkip:((f=e==null?void 0:e.fontRenderExtension)==null?void 0:f.isSkip)||((y=u==null?void 0:u.skipDefaultFontRender)==null?void 0:y.call(u,h,T.value,t))},interceptorStyle:{...e==null?void 0:e.interceptorStyle,...u==null?void 0:u.getExtraStyle(h,M.value,{get style(){const D=c.getStyles();return(typeof(e==null?void 0:e.s)=="string"?D.get(e==null?void 0:e.s):e==null?void 0:e.s)||{}}},n,r)},interceptorAutoHeight:()=>{var H,P,U,F,N,A;const D=(P=(H=this._renderManagerService.getRenderById(i))==null?void 0:H.with(B.SheetSkeletonManagerService).getSkeletonParam(s))==null?void 0:P.skeleton;if(!D)return;const V=D.worksheet.getMergedCell(n,r),x={data:e,style:D.getStyles().getStyleByCell(e),primaryWithCoord:D.getCellWithCoordByIndex((U=V==null?void 0:V.startRow)!=null?U:n,(F=V==null?void 0:V.startColumn)!=null?F:r),unitId:i,subUnitId:s,row:n,col:r,workbook:c,worksheet:l};return(A=(N=u==null?void 0:u.canvasRender)==null?void 0:N.calcCellAutoHeight)==null?void 0:A.call(N,x)},interceptorAutoWidth:()=>{var H,P,U,F,N,A;const D=(P=(H=this._renderManagerService.getRenderById(i))==null?void 0:H.with(B.SheetSkeletonManagerService).getSkeletonParam(s))==null?void 0:P.skeleton;if(!D)return;const V=D.worksheet.getMergedCell(n,r),x={data:e,style:D.getStyles().getStyleByCell(e),primaryWithCoord:D.getCellWithCoordByIndex((U=V==null?void 0:V.startRow)!=null?U:n,(F=V==null?void 0:V.startColumn)!=null?F:r),unitId:i,subUnitId:s,row:n,col:r,workbook:c,worksheet:l};return(A=(N=u==null?void 0:u.canvasRender)==null?void 0:N.calcCellAutoWidth)==null?void 0:A.call(N,x)},coverable:((R=e==null?void 0:e.coverable)!=null?R:!0)&&!(h.type===o.DataValidationType.LIST||h.type===o.DataValidationType.LIST_MULTIPLE)})}}))}_initAutoHeight(){this._sheetDataValidationModel.ruleChange$.pipe(ae.filter(e=>e.source==="command"),ae.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=bt([Z(0,o.ICommandService),Z(1,w.IMenuManagerService),Z(2,L.IRenderManagerService),Z(3,o.IUniverInstanceService),Z(4,o.Inject(B.AutoHeightController)),Z(5,o.Inject(fe)),Z(6,o.Inject(_.SheetDataValidationModel)),Z(7,o.Inject($.DataValidatorRegistryService)),Z(8,o.Inject(W.SheetInterceptorService)),Z(9,o.Inject(_.DataValidationCacheService)),Z(10,o.Optional(B.IEditorBridgeService))],be);let mt=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(W.INTERCEPTOR_POINT.CELL_CONTENT,{effect:o.InterceptorEffectEnum.Style,priority:W.InterceptCellContentPriority.DATA_VALIDATION,handler:(e,t,a)=>{var M,m,C,f,y;const{row:n,col:r,unitId:i,subUnitId:s,workbook:c,worksheet:l}=t,d=this._sheetDataValidationModel.getRuleIdByLocation(i,s,n,r);if(!d)return a(e);const h=this._sheetDataValidationModel.getRuleById(i,s,d);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),S=l.getCellRaw(n,r),v=_.getCellValueOrigin(S),T=`${v!=null?v:""}`;return a({...e,markers:{...e==null?void 0:e.markers,...g===o.DataValidationStatus.INVALID?Tt:null},customRender:[...(m=e==null?void 0:e.customRender)!=null?m:[],...u!=null&&u.canvasRender?[u.canvasRender]:[]],fontRenderExtension:{...e==null?void 0:e.fontRenderExtension,isSkip:((C=e==null?void 0:e.fontRenderExtension)==null?void 0:C.isSkip)||((f=u==null?void 0:u.skipDefaultFontRender)==null?void 0:f.call(u,h,v,t))},interceptorStyle:{...e==null?void 0:e.interceptorStyle,...u==null?void 0:u.getExtraStyle(h,T,{get style(){const R=c.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)},interceptorAutoHeight:()=>{var x,H,P,U,F,N;const R=(H=(x=this._renderManagerService.getRenderById(i))==null?void 0:x.with(B.SheetSkeletonManagerService).getSkeletonParam(s))==null?void 0:H.skeleton;if(!R)return;const D=R.worksheet.getMergedCell(n,r),V={data:e,style:R.getStyles().getStyleByCell(e),primaryWithCoord:R.getCellWithCoordByIndex((P=D==null?void 0:D.startRow)!=null?P:n,(U=D==null?void 0:D.startColumn)!=null?U:r),unitId:i,subUnitId:s,row:n,col:r,workbook:c,worksheet:l};return(N=(F=u==null?void 0:u.canvasRender)==null?void 0:F.calcCellAutoHeight)==null?void 0:N.call(F,V)},coverable:((y=e==null?void 0:e.coverable)!=null?y:!0)&&!(h.type===o.DataValidationType.LIST||h.type===o.DataValidationType.LIST_MULTIPLE)})}}))}_initAutoHeight(){this._sheetDataValidationModel.ruleChange$.pipe(ae.filter(e=>e.source==="command"),ae.bufferTime(16)).subscribe(e=>{const t=[];if(e.forEach(a=>{var n;(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)}})}};mt=bt([Z(0,o.ICommandService),Z(1,L.IRenderManagerService),Z(2,o.Inject(B.AutoHeightController)),Z(3,o.Inject($.DataValidatorRegistryService)),Z(4,o.Inject(W.SheetInterceptorService)),Z(5,o.Inject(_.SheetDataValidationModel)),Z(6,o.Inject(_.DataValidationCacheService))],mt);var Vn=Object.getOwnPropertyDescriptor,wn=(e,t,a,n)=>{for(var r=n>1?void 0:n?Vn(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},ft=(e,t)=>(a,n)=>t(a,n,e);let Be=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))}};Be=wn([ft(1,o.Inject(_.SheetDataValidationModel)),ft(2,o.Inject(B.SheetSkeletonManagerService))],Be);function En(e){var d;const t=w.useDependency(o.LocaleService),a=w.useDependency(w.ComponentManager),{value:n,onChange:r,extraComponent:i}=e,[s,c]=b.useState(!1),l=i?a.get(i):null;return p.jsxs(p.Fragment,{children:[p.jsxs("div",{className:`
32
+ univer-mb-3 univer-flex univer-cursor-pointer univer-items-center univer-text-sm univer-text-gray-900
33
+ `,onClick:()=>c(!s),children:[t.t("dataValidation.panel.options"),s?p.jsx(Dt,{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(E.FormLayout,{label:t.t("dataValidation.panel.invalid"),children:p.jsxs(E.RadioGroup,{value:`${(d=n.errorStyle)!=null?d:o.DataValidationErrorStyle.WARNING}`,onChange:h=>r({...n,errorStyle:+h}),children:[p.jsx(E.Radio,{value:`${o.DataValidationErrorStyle.WARNING}`,children:t.t("dataValidation.panel.showWarning")}),p.jsx(E.Radio,{value:`${o.DataValidationErrorStyle.STOP}`,children:t.t("dataValidation.panel.rejectInput")})]})}),p.jsx(E.FormLayout,{label:t.t("dataValidation.panel.messageInfo"),children:p.jsx(E.Checkbox,{checked:n.showErrorMessage,onChange:()=>r({...n,showErrorMessage:!n.showErrorMessage}),children:t.t("dataValidation.panel.showInfo")})}),n.showErrorMessage?p.jsx(E.FormLayout,{children:p.jsx(E.Input,{value:n.error,onChange:h=>r({...n,error:h})})}):null]})]})}const Mn=e=>o.debounce(async(t,a,n,r)=>{const i=await e.executeCommand(t,a,n);r==null||r(i)},1e3);function bn(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 Tn(){var j,K;const[e,t]=b.useState(0),a=w.useDependency(ue),n=w.useObservable(a.activeRule$,a.activeRule),{unitId:r,subUnitId:i,rule:s}=n||{},c=s.uid,l=w.useDependency($.DataValidatorRegistryService),d=w.useDependency(o.IUniverInstanceService),h=w.useDependency(w.ComponentManager),g=w.useDependency(o.ICommandService),u=w.useDependency($.DataValidationModel),S=w.useDependency(o.LocaleService),[v,T]=b.useState(s),M=l.getValidatorItem(v.type),[m,C]=b.useState(!1),f=l.getValidatorsByScope($.DataValidatorRegistryScope.SHEET),[y,R]=b.useState(()=>v.ranges.map(I=>({unitId:"",sheetId:"",range:I}))),D=b.useMemo(()=>Mn(g),[g]),[V,x]=b.useState(!1),[H,P]=b.useState(!1),U=b.useRef(null),F=w.useDependency(W.SheetsSelectionsService);if(b.useEffect(()=>()=>{const I=F.getCurrentLastSelection();I&&F.setSelections([I])},[F]),b.useEffect(()=>{g.onCommandExecuted(I=>{(I.id===o.UndoCommand.id||I.id===o.RedoCommand.id)&&setTimeout(()=>{const k=u.getRuleById(r,i,c);t(z=>z+1),k&&(T(k),R(k.ranges.map(z=>({unitId:"",sheetId:"",range:z}))))},20)})},[g,u,c,i,r]),!M)return null;const N=M.operators,A=M.operatorNames,Y=v.operator?$.TWO_FORMULA_OPERATOR_COUNT.includes(v.operator):!1,X=()=>{var I,k,z;(k=(I=U.current)==null?void 0:I.editor)!=null&&k.isFocus()&&G((z=U.current)==null?void 0:z.getValue()),!(!v.ranges.length||V)&&(M.validatorFormula(v,r,i).success?a.setActiveRule(null):C(!0))},G=w.useEvent(I=>{const k=I.split(",").filter(Boolean).map(at.deserializeRangeWithSheet).map(Q=>{const gt=Q.sheetName;if(gt){const Lt=bn(d,Q.unitId,gt);return{...Q,sheetId:Lt}}return{...Q,sheetId:""}});if(o.isUnitRangesEqual(k,y))return;R(k);const z=k.filter(Q=>(!Q.unitId||Q.unitId===r)&&(!Q.sheetId||Q.sheetId===i)).map(Q=>Q.range);if(T({...v,ranges:z}),z.length===0)return;const ge={unitId:r,subUnitId:i,ruleId:c,ranges:z};D(_.UpdateSheetDataValidationRangeCommand.id,ge)}),J=I=>{if(o.shallowEqual(I,$.getRuleSetting(v)))return;T({...v,...I});const k={unitId:r,subUnitId:i,ruleId:c,setting:I};D(_.UpdateSheetDataValidationSettingCommand.id,k,void 0)},q=async()=>{await g.executeCommand(_.RemoveSheetDataValidationCommand.id,{ruleId:c,unitId:r,subUnitId:i}),a.setActiveRule(null)},ee={type:v.type,operator:v.operator,formula1:v.formula1,formula2:v.formula2,allowBlank:v.allowBlank},le=I=>{const k=l.getValidatorItem(I);if(!k)return;const z=k.operators,ge=u.getRuleById(r,i,c),Q=I===(ge==null?void 0:ge.type)||I.includes("list")&&(ge!=null&&ge.type.includes("list"))?{...ge,type:I}:{...v,type:I,operator:z[0],formula1:void 0,formula2:void 0};T(Q),g.executeCommand(_.UpdateSheetDataValidationSettingCommand.id,{unitId:r,subUnitId:i,ruleId:v.uid,setting:$.getRuleSetting(Q)})},re=h.get(M.formulaInput),te=b.useMemo(()=>y.map(I=>at.serializeRange(I.range)).join(","),[]),ie=$.getRuleOptions(v),he=I=>{o.shallowEqual(I,$.getRuleOptions(v))||(T({...v,...I}),D(_.UpdateSheetDataValidationOptionsCommand.id,{unitId:r,subUnitId:i,ruleId:c,options:I}))},ce=N.length&&!v.operator;return p.jsxs("div",{className:"univer-py-4",children:[p.jsx(E.FormLayout,{label:S.t("dataValidation.panel.range"),error:!v.ranges.length||V?S.t("dataValidation.panel.rangeError"):"",children:p.jsx(lt.RangeSelector,{selectorRef:U,unitId:r,subUnitId:i,initialValue:te,onChange:(I,k)=>{var z;!H&&((z=U.current)!=null&&z.verify())&&G(k)},onFocusChange:(I,k)=>{var z;P(I),!I&&k&&((z=U.current)!=null&&z.verify())&&G(k)},onVerify:I=>x(!I)})}),p.jsx(E.FormLayout,{label:S.t("dataValidation.panel.type"),children:p.jsx(E.Select,{className:"univer-w-full",value:v.type,options:(j=f==null?void 0:f.sort((I,k)=>I.order-k.order))==null?void 0:j.map(I=>({label:S.t(I.title),value:I.id})),onChange:le})}),N!=null&&N.length?p.jsx(E.FormLayout,{label:S.t("dataValidation.panel.operator"),children:p.jsx(E.Select,{className:"univer-w-full",value:`${v.operator}`,options:[{value:"",label:S.t("dataValidation.operators.legal")},...N.map((I,k)=>({value:`${I}`,label:A[k]}))],onChange:I=>{J({...ee,operator:I})}})}):null,re&&!ce?p.jsx(re,{isTwoFormula:Y,value:{formula1:v.formula1,formula2:v.formula2},onChange:I=>{J({...ee,...I})},showError:m,validResult:M.validatorFormula(v,r,i),unitId:r,subUnitId:i,ruleId:c},e+v.type):null,p.jsx(E.FormLayout,{children:p.jsx(E.Checkbox,{checked:(K=v.allowBlank)!=null?K:!0,onChange:()=>{var I;return J({...ee,allowBlank:!((I=v.allowBlank)==null||I)})},children:S.t("dataValidation.panel.allowBlank")})}),p.jsx(En,{value:ie,onChange:he,extraComponent:M.optionsInput}),p.jsxs("div",{className:"univer-mt-5 univer-flex univer-flex-row univer-justify-end",children:[p.jsx(E.Button,{className:"univer-ml-3",onClick:q,children:S.t("dataValidation.panel.removeRule")}),p.jsx(E.Button,{className:"univer-ml-3",variant:"primary",onClick:X,children:S.t("dataValidation.panel.done")})]})]})}const On=e=>{const{rule:t,onClick:a,unitId:n,subUnitId:r,disable:i}=e,s=w.useDependency($.DataValidatorRegistryService),c=w.useDependency(o.ICommandService),l=w.useDependency(B.IMarkSelectionService),d=s.getValidatorItem(t.type),h=b.useRef(void 0),[g,u]=b.useState(!1),S=w.useDependency(o.ThemeService),v=w.useObservable(S.currentTheme$),T=b.useMemo(()=>{var R;const m=S.getColorFromTheme("primary.600"),C=S.getColorFromTheme("loop-color.2"),f=(R=S.getColorFromTheme(C))!=null?R:m,y=new o.ColorKit(f).toRgb();return{fill:`rgba(${y.r}, ${y.g}, ${y.b}, 0.1)`,stroke:f}},[v]),M=m=>{c.executeCommand(_.RemoveSheetDataValidationCommand.id,{ruleId:t.uid,unitId:n,subUnitId:r}),m.stopPropagation()};return b.useEffect(()=>()=>{var m;h.current&&((m=h.current)==null||m.forEach(C=>{C&&l.removeShape(C)}))},[l]),p.jsxs("div",{className:E.clsx(`
42
34
  univer-rounded-md univer-bg-secondary univer-relative univer--ml-2 univer--mr-2 univer-box-border
43
35
  univer-flex univer-w-[287px] univer-cursor-pointer univer-flex-col univer-justify-between
44
36
  univer-overflow-hidden univer-p-2 univer-pr-9
45
- `,{"hover:univer-bg-gray-50":!i,"univer-opacity-50":i}),onClick:a,onMouseEnter:()=>{i||(u(!0),h.current=t.ranges.map(m=>l.addShape({range:m,style:T,primary:null})))},onMouseLeave:()=>{var m;u(!1),(m=h.current)==null||m.forEach(C=>{C&&l.removeShape(C)}),h.current=void 0},children:[g.jsx("div",{className:`
37
+ `,{"hover:univer-bg-gray-50":!i,"univer-opacity-50":i}),onClick:a,onMouseEnter:()=>{i||(u(!0),h.current=t.ranges.map(m=>l.addShape({range:m,style:T,primary:null})))},onMouseLeave:()=>{var m;u(!1),(m=h.current)==null||m.forEach(C=>{C&&l.removeShape(C)}),h.current=void 0},children:[p.jsx("div",{className:`
46
38
  univer-overflow-hidden univer-text-ellipsis univer-text-sm univer-font-medium univer-leading-[22px]
47
- univer-text-black
48
- `,children:c==null?void 0:c.generateRuleName(t)}),g.jsx("div",{className:`
39
+ univer-text-gray-900
40
+ `,children:d==null?void 0:d.generateRuleName(t)}),p.jsx("div",{className:`
49
41
  univer-text-secondary univer-overflow-hidden univer-text-ellipsis univer-text-xs univer-leading-[18px]
50
- `,children:t.ranges.map(m=>at.serializeRange(m)).join(",")}),p?g.jsx("div",{className:`
42
+ `,children:t.ranges.map(m=>at.serializeRange(m)).join(",")}),g?p.jsx("div",{className:`
51
43
  univer-absolute univer-right-2 univer-top-[19px] univer-flex univer-h-5 univer-w-5
52
44
  univer-items-center univer-justify-center univer-rounded
53
45
  hover:univer-bg-gray-200
54
- `,onClick:E,children:g.jsx(dt,{})}):null]})};function Pn(e){const t=w.useDependency(_.SheetDataValidationModel),a=w.useDependency(o.IUniverInstanceService),n=w.useDependency(o.ICommandService),r=w.useDependency(o.Injector),i=w.useDependency(ue),s=w.useDependency(o.LocaleService),[d,l]=M.useState([]),{workbook:c}=e,h=w.useObservable(c.activeSheet$,void 0,!0),p=c.getUnitId(),u=h==null?void 0:h.getSheetId();M.useEffect(()=>{l(t.getRules(p,u));const C=t.ruleChange$.subscribe(f=>{f.unitId===p&&f.subUnitId===u&&l(t.getRules(p,u))});return()=>{C.unsubscribe()}},[p,u,t]);const S=async()=>{const C=_.createDefaultNewRule(r),f={unitId:p,subUnitId:u,rule:C};await n.executeCommand(_.AddSheetDataValidationCommand.id,f),i.setActiveRule({unitId:p,subUnitId:u,rule:C})},v=()=>{n.executeCommand(_.RemoveSheetAllDataValidationCommand.id,{unitId:p,subUnitId:u})},E=(C=>{const f=a.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET),y=f.getActiveSheet(),R=f.getUnitId(),D=y.getSheetId();return C.map(x=>W.checkRangesEditablePermission(r,R,D,x.ranges)?{...x}:{...x,disable:!0})})(d),m=E==null?void 0:E.some(C=>C.disable);return g.jsxs("div",{className:"univer-pb-4",children:[E==null?void 0:E.map(C=>{var f;return g.jsx(On,{unitId:p,subUnitId:u,onClick:()=>{C.disable||i.setActiveRule({unitId:p,subUnitId:u,rule:C})},rule:C,disable:(f=C.disable)!=null?f:!1},C.uid)}),g.jsxs("div",{className:"univer-mt-4 univer-flex univer-flex-row univer-justify-end univer-gap-2",children:[d.length&&!m?g.jsx(b.Button,{onClick:v,children:s.t("dataValidation.panel.removeAll")}):null,g.jsx(b.Button,{variant:"primary",onClick:S,children:s.t("dataValidation.panel.add")})]})]})}const An=()=>{const e=w.useDependency(ue),t=w.useObservable(e.activeRule$,e.activeRule),a=w.useDependency(o.IUniverInstanceService),n=w.useObservable(()=>a.getCurrentTypeOfUnit$(o.UniverInstanceType.UNIVER_SHEET),void 0,void 0,[]),r=w.useObservable(()=>{var i;return(i=n==null?void 0:n.activeSheet$)!=null?i:ae.of(null)},void 0,void 0,[]);return!n||!r?null:t&&t.subUnitId===r.getSheetId()?g.jsx(Tn,{},t.rule.uid):g.jsx(Pn,{workbook:n})},Ln="LIST_RENDER_MODE_OPTION_INPUT";function He(e){var r;const{value:t,onChange:a}=e,n=w.useDependency(o.LocaleService);return g.jsx(b.FormLayout,{label:n.t("dataValidation.renderMode.label"),children:g.jsxs(b.RadioGroup,{value:`${(r=t.renderMode)!=null?r:o.DataValidationRenderMode.CUSTOM}`,onChange:i=>a({...t,renderMode:+i}),children:[g.jsx(b.Radio,{value:`${o.DataValidationRenderMode.CUSTOM}`,children:n.t("dataValidation.renderMode.chip")}),g.jsx(b.Radio,{value:`${o.DataValidationRenderMode.ARROW}`,children:n.t("dataValidation.renderMode.arrow")}),g.jsx(b.Radio,{value:`${o.DataValidationRenderMode.TEXT}`,children:n.t("dataValidation.renderMode.text")})]})})}He.componentKey=Ln;const jn="DATE_SHOW_TIME_OPTION";function We(e){var r;const{value:t,onChange:a}=e,n=w.useDependency(o.LocaleService);return g.jsx(b.FormLayout,{children:g.jsx(b.Checkbox,{checked:(r=t.bizInfo)==null?void 0:r.showTime,onChange:i=>{a({...t,bizInfo:{...t.bizInfo,showTime:i}})},children:n.t("dataValidation.showTime.label")})})}We.componentKey=jn;var xn=Object.getOwnPropertyDescriptor,Un=(e,t,a,n)=>{for(var r=n>1?void 0:n?xn(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},ye=(e,t)=>(a,n)=>t(a,n,e);const Ae=6;let rt=class{constructor(e,t,a,n,r,i){this._commandService=e,this._univerInstanceService=t,this._formulaService=a,this._themeService=n,this._renderManagerService=r,this._dataValidationModel=i}_calc(e,t){var c,h,p;const{vt:a,ht:n}=t||{},r=e.endX-e.startX-Ae*2,i=e.endY-e.startY,s=((c=t==null?void 0:t.fs)!=null?c:10)*1.6;let d=0,l=0;switch(a){case o.VerticalAlign.TOP:l=0;break;case o.VerticalAlign.BOTTOM:l=0+(i-s);break;default:l=0+(i-s)/2;break}switch(n){case o.HorizontalAlign.LEFT:d=Ae;break;case o.HorizontalAlign.RIGHT:d=Ae+(r-s);break;default:d=Ae+(r-s)/2;break}return{left:e.startX+d,top:e.startY+l,width:((h=t==null?void 0:t.fs)!=null?h:10)*1.6,height:((p=t==null?void 0:t.fs)!=null?p:10)*1.6}}calcCellAutoHeight(e){var a;const{style:t}=e;return((a=t==null?void 0:t.fs)!=null?a:10)*1.6}calcCellAutoWidth(e){var a;const{style:t}=e;return((a=t==null?void 0:t.fs)!=null?a:10)*1.6}async _parseFormula(e,t,a){var c,h,p,u,S,v,T,E,m;const{formula1:n=_.CHECKBOX_FORMULA_1,formula2:r=_.CHECKBOX_FORMULA_2}=e,i=await this._formulaService.getRuleFormulaResult(t,a,e.uid),s=_.getFormulaResult((p=(h=(c=i==null?void 0:i[0])==null?void 0:c.result)==null?void 0:h[0])==null?void 0:p[0]),d=_.getFormulaResult((v=(S=(u=i==null?void 0:i[1])==null?void 0:u.result)==null?void 0:S[0])==null?void 0:v[0]),l=_.isLegalFormulaResult(String(s))&&_.isLegalFormulaResult(String(d));return{formula1:o.isFormulaString(n)?_.getFormulaResult((m=(E=(T=i==null?void 0:i[0])==null?void 0:T.result)==null?void 0:E[0])==null?void 0:m[0]):n,formula2:o.isFormulaString(r)?d:r,isFormulaValid:l}}drawWith(e,t){var U,F,k,A;const{style:a,primaryWithCoord:n,unitId:r,subUnitId:i,worksheet:s,row:d,col:l}=t,c=n.isMergedMainCell?n.mergeInfo:n,h=_.getCellValueOrigin(s.getCellRaw(d,l)),p=this._dataValidationModel.getRuleByLocation(r,i,d,l);if(!p)return;const u=this._dataValidationModel.getValidator(p.type);if(!u||!((U=u.skipDefaultFontRender)!=null&&U.call(u,p,h,{unitId:r,subUnitId:i,row:d,column:l})))return;const S=u.parseFormulaSync(p,r,i),{formula1:v}=S,T=this._calc(c,a),{a:E,d:m}=e.getTransform(),C=L.fixLineWidthByScale(T.left,E),f=L.fixLineWidthByScale(T.top,m),y=L.Transform.create().composeMatrix({left:C,top:f,scaleX:1,scaleY:1,angle:0,skewX:0,skewY:0,flipX:!1,flipY:!1}),R=c.endX-c.startX,D=c.endY-c.startY;e.save(),e.beginPath(),e.rect(c.startX,c.startY,R,D),e.clip();const V=y.getMatrix();e.transform(V[0],V[1],V[2],V[3],V[4],V[5]);const x=((F=a==null?void 0:a.fs)!=null?F:10)*1.6,H=String(h)===String(v),P=this._themeService.getColorFromTheme("primary.600");L.CheckboxShape.drawWith(e,{checked:H,width:x,height:x,fill:(A=(k=a==null?void 0:a.cl)==null?void 0:k.rgb)!=null?A:P}),e.restore()}isHit(e,t){const a=t.primaryWithCoord.isMergedMainCell?t.primaryWithCoord.mergeInfo:t.primaryWithCoord,n=this._calc(a,t.style),r=n.top,i=n.top+n.height,s=n.left,d=n.left+n.width,{x:l,y:c}=e;return l<=d&&l>=s&&c<=i&&c>=r}async onPointerDown(e,t){var v;if(t.button===2)return;const{primaryWithCoord:a,unitId:n,subUnitId:r,worksheet:i,row:s,col:d}=e,l=_.getCellValueOrigin(i.getCellRaw(s,d)),c=this._dataValidationModel.getRuleByLocation(n,r,s,d);if(!c)return;const h=this._dataValidationModel.getValidator(c.type);if(!h||!((v=h.skipDefaultFontRender)!=null&&v.call(h,c,l,{unitId:n,subUnitId:r,row:s,column:d})))return;const{formula1:p,formula2:u}=await this._parseFormula(c,n,r),S={range:{startColumn:a.actualColumn,endColumn:a.actualColumn,startRow:a.actualRow,endRow:a.actualRow},value:{v:String(l)===_.transformCheckboxValue(String(p))?u:p,p:null}};this._commandService.executeCommand(W.SetRangeValuesCommand.id,S)}onPointerEnter(e,t){var a,n;(n=(a=L.getCurrentTypeOfRenderer(o.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null?void 0:a.mainComponent)==null||n.setCursor(L.CURSOR_TYPE.POINTER)}onPointerLeave(e,t){var a,n;(n=(a=L.getCurrentTypeOfRenderer(o.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null?void 0:a.mainComponent)==null||n.setCursor(L.CURSOR_TYPE.DEFAULT)}};rt=Un([ye(0,o.ICommandService),ye(1,o.IUniverInstanceService),ye(2,o.Inject(_.DataValidationFormulaService)),ye(3,o.Inject(o.ThemeService)),ye(4,o.Inject(L.IRenderManagerService)),ye(5,o.Inject(_.SheetDataValidationModel))],rt);class Fn extends exports.BaseSheetDataValidatorView{constructor(){super(...arguments);O(this,"id",o.DataValidationType.CHECKBOX);O(this,"canvasRender",this.injector.createInstance(rt));O(this,"formulaInput",_.CHECKBOX_FORMULA_INPUT_NAME)}}class kn extends exports.BaseSheetDataValidatorView{constructor(){super(...arguments);O(this,"id",o.DataValidationType.CUSTOM);O(this,"formulaInput",_.CUSTOM_FORMULA_INPUT_NAME)}}const Nn="data-validation.formula-input";class Bn extends exports.BaseSheetDataValidatorView{constructor(){super(...arguments);O(this,"id",o.DataValidationType.DATE);O(this,"formulaInput",Nn);O(this,"optionsInput",We.componentKey);O(this,"dropdownType",$.DataValidatorDropdownType.DATE)}}class Hn extends exports.BaseSheetDataValidatorView{constructor(){super(...arguments);O(this,"id",o.DataValidationType.DECIMAL);O(this,"formulaInput",_.BASE_FORMULA_INPUT_NAME)}}const Ot=4,Wn=0,Ze=4,Pt=4,it=6,$e=6,me=14;function $n(e,t){const a=L.FontCache.getTextSize(e,t),n=a.width+Ot*2,{ba:r,bd:i}=a,s=r+i;return{width:n,height:s+Wn*2,ba:r}}function Je(e,t,a,n){const r=me+it*2,i=a-r,s=n-$e*2,d=e.map(u=>({layout:$n(u,t),text:u}));let l;const c=[];d.forEach(u=>{const{layout:S}=u,{width:v,height:T}=S;!l||l.width+v+Ze>i?(l={width:v,height:T,items:[{...u,left:0}]},c.push(l)):(l.items.push({...u,left:l.width+Ze}),l.width=l.width+v+Ze)});let h=0,p=0;return c.forEach((u,S)=>{p=Math.max(p,u.width),S===c.length-1?h+=u.height:h+=u.height+Pt}),{lines:c,totalHeight:h,contentWidth:i,contentHeight:s,cellAutoHeight:h+$e*2,calcAutoWidth:p+r}}const Yn=8;class Xn extends L.Shape{static drawWith(t,a){const{fontString:n,info:r,fill:i,color:s}=a,{layout:d,text:l}=r;t.save(),L.Rect.drawWith(t,{width:d.width,height:d.height,radius:Yn,fill:i||De}),t.translateWithPrecision(Ot,d.ba),t.font=n,t.fillStyle=s,t.fillText(l,0,0),t.restore()}}var zn=Object.getOwnPropertyDescriptor,Kn=(e,t,a,n)=>{for(var r=n>1?void 0:n?zn(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 Gn=new Path2D("M3.32201 4.84556C3.14417 5.05148 2.85583 5.05148 2.67799 4.84556L0.134292 1.90016C-0.152586 1.56798 0.0505937 1 0.456301 1L5.5437 1C5.94941 1 6.15259 1.56798 5.86571 1.90016L3.32201 4.84556Z");let ot=class{constructor(e,t,a,n){O(this,"zIndex");O(this,"_dropdownInfoMap",new Map);this._commandService=e,this._univerInstanceService=t,this._renderManagerService=a,this._dataValidationModel=n}_ensureMap(e){let t=this._dropdownInfoMap.get(e);return t||(t=new Map,this._dropdownInfoMap.set(e,t)),t}_generateKey(e,t){return`${e}.${t}`}_drawDownIcon(e,t,a,n,r){const i=a-me+4;let s=4;switch(r){case o.VerticalAlign.MIDDLE:s=(n-me)/2+4;break;case o.VerticalAlign.BOTTOM:s=n-me+4;break}e.save(),e.translateWithPrecision(t.startX+i,t.startY+s),e.fillStyle="#565656",e.fill(Gn),e.restore()}drawWith(e,t,a,n){var J,q;const{primaryWithCoord:r,row:i,col:s,style:d,data:l,subUnitId:c}=t,h=r.isMergedMainCell?r.mergeInfo:r,p=l==null?void 0:l.fontRenderExtension,{leftOffset:u=0,rightOffset:S=0,topOffset:v=0,downOffset:T=0}=p||{},E=this._ensureMap(c),m=this._generateKey(i,s),C=this._dataValidationModel.getRuleByLocation(t.unitId,t.subUnitId,i,s);if(!C)return;const f=this._dataValidationModel.getValidator(C.type);if(!f)return;const y={startX:h.startX+u,endX:h.endX-S,startY:h.startY+v,endY:h.endY-T},R=y.endX-y.startX,D=y.endY-y.startY,{cl:V}=d||{},x=(J=typeof V=="object"?V==null?void 0:V.rgb:V)!=null?J:"#000",H=L.getFontStyleString(d!=null?d:void 0),{vt:P,ht:U}=d||{},F=P!=null?P:o.VerticalAlign.MIDDLE,k=(q=_.getCellValueOrigin(l))!=null?q:"",A=f.parseCellValue(k),Y=f.getListWithColorMap(C),X=Je(A,H,R,D);this._drawDownIcon(e,y,R,D,F),e.save(),e.translateWithPrecision(y.startX,y.startY),e.beginPath(),e.rect(0,0,R-me,D),e.clip(),e.translateWithPrecision(it,$e);let G=0;switch(F){case o.VerticalAlign.MIDDLE:G=(X.contentHeight-X.totalHeight)/2;break;case o.VerticalAlign.BOTTOM:G=X.contentHeight-X.totalHeight;break}e.translateWithPrecision(0,G),X.lines.forEach((ee,le)=>{e.save();const{width:re,height:te,items:ie}=ee;let he=0;switch(U){case o.HorizontalAlign.RIGHT:he=X.contentWidth-re;break;case o.HorizontalAlign.CENTER:he=(X.contentWidth-re)/2;break}e.translate(he,le*(te+Pt)),ie.forEach(de=>{e.save(),e.translateWithPrecision(de.left,0),Xn.drawWith(e,{...H,info:de,color:x,fill:Y[de.text]}),e.restore()}),e.restore()}),e.restore(),E.set(m,{left:y.startX,top:y.startY,width:X.contentWidth+it+me,height:X.contentHeight+$e*2})}calcCellAutoHeight(e){var R;const{primaryWithCoord:t,style:a,data:n,row:r,col:i}=e,s=n==null?void 0:n.fontRenderExtension,{leftOffset:d=0,rightOffset:l=0,topOffset:c=0,downOffset:h=0}=s||{},p=t.isMergedMainCell?t.mergeInfo:t,u={startX:p.startX+d,endX:p.endX-l,startY:p.startY+c,endY:p.endY-h},S=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,r,i);if(!S)return;const v=this._dataValidationModel.getValidator(S.type);if(!v)return;const T=u.endX-u.startX,E=u.endY-u.startY,m=(R=_.getCellValueOrigin(n))!=null?R:"",C=v.parseCellValue(m),f=L.getFontStyleString(a!=null?a:void 0);return Je(C,f,T,E).cellAutoHeight}calcCellAutoWidth(e){var R;const{primaryWithCoord:t,style:a,data:n,row:r,col:i}=e,s=n==null?void 0:n.fontRenderExtension,{leftOffset:d=0,rightOffset:l=0,topOffset:c=0,downOffset:h=0}=s||{},p=t.isMergedMainCell?t.mergeInfo:t,u={startX:p.startX+d,endX:p.endX-l,startY:p.startY+c,endY:p.endY-h},S=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,r,i);if(!S)return;const v=this._dataValidationModel.getValidator(S.type);if(!v)return;const T=u.endX-u.startX,E=u.endY-u.startY,m=(R=_.getCellValueOrigin(n))!=null?R:"",C=v.parseCellValue(m),f=L.getFontStyleString(a!=null?a:void 0);return Je(C,f,T,E).calcAutoWidth}isHit(e,t){const{primaryWithCoord:a}=t,n=a.isMergedMainCell?a.mergeInfo:a,{endX:r}=n,{x:i}=e;return i>=r-me&&i<=r}onPointerDown(e,t){if(t.button===2)return;const{unitId:a,subUnitId:n,row:r,col:i}=e,s={unitId:a,subUnitId:n,row:r,column:i};this._commandService.executeCommand(Ye.id,s)}onPointerEnter(e,t){var a,n;return(n=(a=L.getCurrentTypeOfRenderer(o.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null?void 0:a.mainComponent)==null?void 0:n.setCursor(L.CURSOR_TYPE.POINTER)}onPointerLeave(e,t){var a,n;return(n=(a=L.getCurrentTypeOfRenderer(o.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null?void 0:a.mainComponent)==null?void 0:n.setCursor(L.CURSOR_TYPE.DEFAULT)}};ot=Kn([Le(0,o.ICommandService),Le(1,o.IUniverInstanceService),Le(2,o.Inject(L.IRenderManagerService)),Le(3,o.Inject(_.SheetDataValidationModel))],ot);class qn extends exports.BaseSheetDataValidatorView{constructor(){super(...arguments);O(this,"id",o.DataValidationType.LIST_MULTIPLE);O(this,"canvasRender",this.injector.createInstance(ot));O(this,"dropdownType",$.DataValidatorDropdownType.MULTIPLE_LIST)}}var Zn=Object.getOwnPropertyDescriptor,Jn=(e,t,a,n)=>{for(var r=n>1?void 0:n?Zn(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},Oe=(e,t)=>(a,n)=>t(a,n,e);const ve=4,je=4,se=14,ce=6,Re=4,Qe=8,Qn="#565656",St=new Path2D("M3.32201 4.84556C3.14417 5.05148 2.85583 5.05148 2.67799 4.84556L0.134292 1.90016C-0.152586 1.56798 0.0505937 1 0.456301 1L5.5437 1C5.94941 1 6.15259 1.56798 5.86571 1.90016L3.32201 4.84556Z");function ea(e,t){const a=e.length;return{id:"d",body:{dataStream:`${e}${o.DEFAULT_EMPTY_DOCUMENT_VALUE}`,textRuns:[{ts:{fs:11,ff:void 0,it:o.BooleanNumber.FALSE,bl:o.BooleanNumber.FALSE,ul:{s:o.BooleanNumber.FALSE},st:{s:o.BooleanNumber.FALSE},ol:{s:o.BooleanNumber.FALSE},cl:void 0,...t,bg:void 0,bd:void 0},st:0,ed:a}]},documentStyle:{pageSize:{width:Number.POSITIVE_INFINITY,height:Number.POSITIVE_INFINITY}}}}function At(e,t,a){const n=ea(e,a),r=new o.DocumentDataModel(n),i=new L.DocumentViewModel(r);return{documentSkeleton:L.DocumentSkeleton.create(i,t),docModel:r,docViewModel:i}}function xe(e,t,a){const{documentSkeleton:n,docModel:r,docViewModel:i}=At(e,t,a);return{documents:new L.Documents(`DOCUMENTS_${o.Tools.generateRandomId()}`,n,{pageMarginLeft:0,pageMarginTop:0}),documentSkeleton:n,docModel:r,docViewModel:i}}function _t(e,t,a,n,r,i,s=!0){let d=0;const l=s?Re:0;switch(r){case o.VerticalAlign.BOTTOM:d=t-n-l;break;case o.VerticalAlign.MIDDLE:d=(t-n)/2;break;default:d=l;break}d=Math.max(Re,d);let c=0;switch(i){case o.HorizontalAlign.CENTER:c=(e-a)/2;break;case o.HorizontalAlign.RIGHT:c=e-a;break}return c=Math.max(ce,c),{paddingLeft:c,paddingTop:d}}let st=class{constructor(e,t,a,n,r){O(this,"_dropdownInfoMap",new Map);O(this,"zIndex");this._univerInstanceService=e,this._localeService=t,this._commandService=a,this._renderManagerService=n,this._dataValidationModel=r}_ensureMap(e){let t=this._dropdownInfoMap.get(e);return t||(t=new Map,this._dropdownInfoMap.set(e,t)),t}_generateKey(e,t){return`${e}.${t}`}_drawDownIcon(e,t,a,n,r,i,s){const{t:d=o.DEFAULT_STYLES.pd.t,b:l=o.DEFAULT_STYLES.pd.b}=s,c=a-se;let h;switch(i){case o.VerticalAlign.MIDDLE:h=(n-je)/2;break;case o.VerticalAlign.BOTTOM:h=n-l-r-Re+(r/2-je/2);break;default:h=d+Re+(r/2-je/2);break}e.save(),e.translateWithPrecision(t.startX+c,t.startY+h),e.fillStyle="#565656",e.fill(St),e.restore()}drawWith(e,t,a){const{primaryWithCoord:n,row:r,col:i,style:s,data:d,subUnitId:l}=t,c=n.isMergedMainCell?n.mergeInfo:n,h=this._dataValidationModel.getRuleByLocation(t.unitId,t.subUnitId,r,i);if(!h)return;const p=this._dataValidationModel.getValidator(h.type);if(!p)return;const u=d==null?void 0:d.fontRenderExtension,{leftOffset:S=0,rightOffset:v=0,topOffset:T=0,downOffset:E=0}=u||{};if(!h||!p||!p||p.id.indexOf(o.DataValidationType.LIST)!==0||!p.skipDefaultFontRender(h))return;const m={startX:c.startX+S,endX:c.endX-v,startY:c.startY+T,endY:c.endY-E},C=m.endX-m.startX,f=m.endY-m.startY,y=this._ensureMap(l),R=this._generateKey(r,i),D=p.getListWithColor(h),V=_.getCellValueOrigin(d),x=`${V!=null?V:""}`,H=D.find(A=>A.label===x);let{tb:P,vt:U,ht:F,pd:k}=s||{};if(P=P!=null?P:o.WrapStrategy.WRAP,U=U!=null?U:o.VerticalAlign.BOTTOM,F=F!=null?F:o.DEFAULT_STYLES.ht,k=k!=null?k:o.DEFAULT_STYLES.pd,h.renderMode===o.DataValidationRenderMode.ARROW){const{l:A=o.DEFAULT_STYLES.pd.l,t:Y=o.DEFAULT_STYLES.pd.t,r:X=o.DEFAULT_STYLES.pd.r,b:G=o.DEFAULT_STYLES.pd.b}=k,J=C-A-X-se-4,{documentSkeleton:q,documents:ee,docModel:le}=xe(x,this._localeService,s);P===o.WrapStrategy.WRAP&&le.updateDocumentDataPageSize(Math.max(J,1)),q.calculate(),q.getActualSize();const re=L.getDocsSkeletonPageSize(q),{height:te,width:ie}=re,{paddingTop:he,paddingLeft:de}=_t(J,f-Y-G,ie,te,U,F,!0);this._drawDownIcon(e,m,C,f,te,U,k),e.save(),e.translateWithPrecision(m.startX+A,m.startY+Y),e.beginPath(),e.rect(0,0,C-A-X,f-Y-G),e.clip(),e.translateWithPrecision(0,he),e.save(),e.translateWithPrecision(ve,0),e.beginPath(),e.rect(0,0,J,te),e.clip(),ee.render(e),e.translateWithPrecision(de,0),e.restore(),e.restore(),y.set(R,{left:m.endX+A+a.rowHeaderWidth-se,top:m.startY+Y+a.columnHeaderHeight,width:se,height:f-Y-G})}else{e.save(),e.translateWithPrecision(m.startX,m.startY),e.beginPath(),e.rect(0,0,C,f),e.clip();const A=C-ce*2-ve-se-4,{documentSkeleton:Y,documents:X,docModel:G}=xe(x,this._localeService,s);P===o.WrapStrategy.WRAP&&G.updateDocumentDataPageSize(Math.max(A,1)),Y.calculate();const J=L.getDocsSkeletonPageSize(Y),{height:q,width:ee}=J,{paddingTop:le,paddingLeft:re}=_t(A,f,ee,q,U,F);e.translateWithPrecision(ce,le);const te=Math.max(C-ce*2,1),ie=q;L.Rect.drawWith(e,{width:te,height:ie,fill:(H==null?void 0:H.color)||De,radius:Qe}),e.save(),e.translateWithPrecision(ve,0),e.beginPath(),e.rect(0,0,A,q),e.clip(),e.translateWithPrecision(re,0),X.render(e),e.restore(),e.translateWithPrecision(A+ve+4,(q-je)/2),e.fillStyle=Qn,e.fill(St),e.restore(),y.set(R,{left:m.startX+ce+a.rowHeaderWidth,top:m.startY+le+a.columnHeaderHeight,width:te,height:ie})}}calcCellAutoHeight(e){const{primaryWithCoord:t,style:a,data:n,row:r,col:i}=e,s=t.isMergedMainCell?t.mergeInfo:t,d=n==null?void 0:n.fontRenderExtension,{leftOffset:l=0,rightOffset:c=0,topOffset:h=0,downOffset:p=0}=d||{},u=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,r,i);if(!u||u.renderMode===o.DataValidationRenderMode.TEXT)return;const S={startX:s.startX+l,endX:s.endX-c,startY:s.startY+h,endY:s.endY-p},v=S.endX-S.startX,T=_.getCellValueOrigin(n),E=`${T!=null?T:""}`;let{tb:m,pd:C}=a||{};const{t:f=o.DEFAULT_STYLES.pd.t,b:y=o.DEFAULT_STYLES.pd.b}=C!=null?C:{};if(m=m!=null?m:o.WrapStrategy.WRAP,u.renderMode===o.DataValidationRenderMode.ARROW){const R=v-se,{documentSkeleton:D,docModel:V}=xe(E,this._localeService,a);m===o.WrapStrategy.WRAP&&V.updateDocumentDataPageSize(Math.max(R,1)),D.calculate(),D.getActualSize();const x=L.getDocsSkeletonPageSize(D),{height:H}=x;return H+f+y+Re*2}else{const R=v-ce*2-ve-se,{documentSkeleton:D,docModel:V}=At(E,this._localeService,a);m===o.WrapStrategy.WRAP&&V.updateDocumentDataPageSize(Math.max(R,1)),D.calculate();const x=L.getDocsSkeletonPageSize(D),{height:H}=x;return H+Re*2}}calcCellAutoWidth(e){const{primaryWithCoord:t,style:a,data:n,row:r,col:i}=e,s=t.isMergedMainCell?t.mergeInfo:t,d=n==null?void 0:n.fontRenderExtension,{leftOffset:l=0,rightOffset:c=0,topOffset:h=0,downOffset:p=0}=d||{},u=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,r,i);if(!u||u.renderMode===o.DataValidationRenderMode.TEXT)return;const S={startX:s.startX+l,endX:s.endX-c,startY:s.startY+h,endY:s.endY-p},v=S.endX-S.startX,T=_.getCellValueOrigin(n),E=`${T!=null?T:""}`;let{tb:m,pd:C}=a||{};const{l:f=o.DEFAULT_STYLES.pd.l,r:y=o.DEFAULT_STYLES.pd.r}=C!=null?C:{};m=m!=null?m:o.WrapStrategy.WRAP;let R=ce*2+se;switch(u.renderMode){case o.DataValidationRenderMode.ARROW:R=se+ce*2+y+f;break;case o.DataValidationRenderMode.CUSTOM:R=se+ce*2+ve*2+y+f+Qe/2+1;break;default:R=se+ce*2+ve*2+y+f+Qe/2+1}const D=v-R,{documentSkeleton:V,docModel:x}=xe(E,this._localeService,a);return m===o.WrapStrategy.WRAP&&x.updateDocumentDataPageSize(Math.max(D,1)),V.calculate(),V.getActualSize(),L.getDocsSkeletonPageSize(V).width+R}isHit(e,t){const{subUnitId:a,row:n,col:r}=t,s=this._ensureMap(a).get(this._generateKey(n,r)),d=this._dataValidationModel.getRuleByLocation(t.unitId,t.subUnitId,n,r);if(!d||!s||d.renderMode===o.DataValidationRenderMode.TEXT)return!1;const{top:l,left:c,width:h,height:p}=s,{x:u,y:S}=e;return u>=c&&u<=c+h&&S>=l&&S<=l+p}onPointerDown(e,t){if(t.button===2)return;const{unitId:a,subUnitId:n,row:r,col:i}=e,s={unitId:a,subUnitId:n,row:r,column:i};this._commandService.executeCommand(Ye.id,s)}onPointerEnter(e,t){var a,n;(n=(a=L.getCurrentTypeOfRenderer(o.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null?void 0:a.mainComponent)==null||n.setCursor(L.CURSOR_TYPE.POINTER)}onPointerLeave(e,t){var a,n;(n=(a=L.getCurrentTypeOfRenderer(o.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null?void 0:a.mainComponent)==null||n.setCursor(L.CURSOR_TYPE.DEFAULT)}};st=Jn([Oe(0,o.IUniverInstanceService),Oe(1,o.Inject(o.LocaleService)),Oe(2,o.ICommandService),Oe(3,o.Inject(L.IRenderManagerService)),Oe(4,o.Inject(_.SheetDataValidationModel))],st);class ta extends exports.BaseSheetDataValidatorView{constructor(){super(...arguments);O(this,"id",o.DataValidationType.LIST);O(this,"canvasRender",this.injector.createInstance(st));O(this,"dropdownType",$.DataValidatorDropdownType.LIST);O(this,"optionsInput",He.componentKey);O(this,"formulaInput",_.LIST_FORMULA_INPUT_NAME)}}class na extends exports.BaseSheetDataValidatorView{constructor(){super(...arguments);O(this,"id",o.DataValidationType.TEXT_LENGTH);O(this,"formulaInput",_.BASE_FORMULA_INPUT_NAME)}}class aa extends exports.BaseSheetDataValidatorView{constructor(){super(...arguments);O(this,"id",o.DataValidationType.WHOLE);O(this,"formulaInput",_.BASE_FORMULA_INPUT_NAME)}}var ra=Object.getOwnPropertyDescriptor,ia=(e,t,a,n)=>{for(var r=n>1?void 0:n?ra(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},et=(e,t)=>(a,n)=>t(a,n,e);let Te=class extends o.RxDisposable{constructor(e,t,a){super(),this._injector=e,this._componentManger=t,this._dataValidatorRegistryService=a,this._initComponents(),this._registerValidatorViews()}_initComponents(){[[Et,Ct],[Ne,An],[He.componentKey,He],[We.componentKey,We],...en].forEach(([e,t])=>{this.disposeWithMe(this._componentManger.register(e,t))})}_registerValidatorViews(){[Hn,aa,na,Bn,Fn,ta,qn,kn].forEach(e=>{const t=this._injector.createInstance(e),a=this._dataValidatorRegistryService.getValidatorItem(t.id);a&&(a.formulaInput=t.formulaInput,a.canvasRender=t.canvasRender,a.dropdownType=t.dropdownType,a.optionsInput=t.optionsInput)})}};Te=ia([et(0,o.Inject(o.Injector)),et(1,o.Inject(w.ComponentManager)),et(2,o.Inject($.DataValidatorRegistryService))],Te);var oa=Object.getOwnPropertyDescriptor,sa=(e,t,a,n)=>{for(var r=n>1?void 0:n?oa(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},tt=(e,t)=>(a,n)=>t(a,n,e);const la="SHEET_DATA_VALIDATION_UI_PLUGIN";var Ue;exports.UniverSheetsDataValidationUIPlugin=(Ue=class extends o.Plugin{constructor(t=ke,a,n,r){super(),this._config=t,this._injector=a,this._commandService=n,this._configService=r;const{menu:i,...s}=o.merge({},ke,this._config);i&&this._configService.setConfig("menu",i,{merge:!0}),this._configService.setConfig(ut,s)}onStarting(){[[ue],[fe],[Pe],[we],[be],[Me],[Ee],[Ve],[Te]].forEach(t=>{this._injector.add(t)}),[Xe,Ye,wt,ht,_e,Vt].forEach(t=>{this._commandService.registerCommand(t)})}onReady(){this._injector.get(Ee),this._injector.get(Me),this._injector.get(Ve),this._injector.get(Pe),this._injector.get(L.IRenderManagerService).registerRenderModule(o.UniverInstanceType.UNIVER_SHEET,[Be])}onRendered(){this._injector.get(Te),this._injector.get(be)}onSteady(){this._injector.get(we)}},O(Ue,"pluginName",la),O(Ue,"type",o.UniverInstanceType.UNIVER_SHEET),Ue);exports.UniverSheetsDataValidationUIPlugin=sa([tt(1,o.Inject(o.Injector)),tt(2,o.ICommandService),tt(3,o.IConfigService)],exports.UniverSheetsDataValidationUIPlugin);var da=Object.getOwnPropertyDescriptor,ca=(e,t,a,n)=>{for(var r=n>1?void 0:n?da(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},nt=(e,t)=>(a,n)=>t(a,n,e);const ua="SHEET_DATA_VALIDATION_UI_PLUGIN";var Fe;exports.UniverSheetsDataValidationMobileUIPlugin=(Fe=class extends o.Plugin{constructor(t=ke,a,n,r){super(),this._config=t,this._injector=a,this._commandService=n,this._configService=r;const{menu:i,...s}=o.merge({},ke,this._config);i&&this._configService.setConfig("menu",i,{merge:!0}),this._configService.setConfig(ut,s)}onStarting(){[[ue],[fe],[Pe],[we],[be],[Me],[Ee],[Te]].forEach(t=>{this._injector.add(t)}),[Xe,Ye,wt,ht,_e,Vt].forEach(t=>{this._commandService.registerCommand(t)})}onReady(){this._injector.get(Ee),this._injector.get(Me),this._injector.get(L.IRenderManagerService).registerRenderModule(o.UniverInstanceType.UNIVER_SHEET,[Be])}onRendered(){this._injector.get(Te),this._injector.get(be)}onSteady(){this._injector.get(we)}},O(Fe,"pluginName",ua),O(Fe,"type",o.UniverInstanceType.UNIVER_SHEET),Fe);exports.UniverSheetsDataValidationMobileUIPlugin=ca([nt(1,o.Inject(o.Injector)),nt(2,o.ICommandService),nt(3,o.IConfigService)],exports.UniverSheetsDataValidationMobileUIPlugin);
46
+ `,onClick:M,children:p.jsx(ct,{})}):null]})};function Pn(e){const t=w.useDependency(_.SheetDataValidationModel),a=w.useDependency(o.IUniverInstanceService),n=w.useDependency(o.ICommandService),r=w.useDependency(o.Injector),i=w.useDependency(ue),s=w.useDependency(o.LocaleService),[c,l]=b.useState([]),{workbook:d}=e,h=w.useObservable(d.activeSheet$,void 0,!0),g=d.getUnitId(),u=h==null?void 0:h.getSheetId();b.useEffect(()=>{l(t.getRules(g,u));const C=t.ruleChange$.subscribe(f=>{f.unitId===g&&f.subUnitId===u&&l(t.getRules(g,u))});return()=>{C.unsubscribe()}},[g,u,t]);const S=async()=>{const C=_.createDefaultNewRule(r),f={unitId:g,subUnitId:u,rule:C};await n.executeCommand(_.AddSheetDataValidationCommand.id,f),i.setActiveRule({unitId:g,subUnitId:u,rule:C})},v=()=>{n.executeCommand(_.RemoveSheetAllDataValidationCommand.id,{unitId:g,subUnitId:u})},M=(C=>{const f=a.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET),y=f.getActiveSheet(),R=f.getUnitId(),D=y.getSheetId();return C.map(x=>W.checkRangesEditablePermission(r,R,D,x.ranges)?{...x}:{...x,disable:!0})})(c),m=M==null?void 0:M.some(C=>C.disable);return p.jsxs("div",{className:"univer-pb-4",children:[M==null?void 0:M.map(C=>{var f;return p.jsx(On,{unitId:g,subUnitId:u,onClick:()=>{C.disable||i.setActiveRule({unitId:g,subUnitId:u,rule:C})},rule:C,disable:(f=C.disable)!=null?f:!1},C.uid)}),p.jsxs("div",{className:"univer-mt-4 univer-flex univer-flex-row univer-justify-end univer-gap-2",children:[c.length&&!m?p.jsx(E.Button,{onClick:v,children:s.t("dataValidation.panel.removeAll")}):null,p.jsx(E.Button,{variant:"primary",onClick:S,children:s.t("dataValidation.panel.add")})]})]})}const An=()=>{const e=w.useDependency(ue),t=w.useObservable(e.activeRule$,e.activeRule),a=w.useDependency(o.IUniverInstanceService),n=w.useObservable(()=>a.getCurrentTypeOfUnit$(o.UniverInstanceType.UNIVER_SHEET),void 0,void 0,[]),r=w.useObservable(()=>{var i;return(i=n==null?void 0:n.activeSheet$)!=null?i:ae.of(null)},void 0,void 0,[]);return!n||!r?null:t&&t.subUnitId===r.getSheetId()?p.jsx(Tn,{},t.rule.uid):p.jsx(Pn,{workbook:n})},Ln="LIST_RENDER_MODE_OPTION_INPUT";function He(e){var r;const{value:t,onChange:a}=e,n=w.useDependency(o.LocaleService);return p.jsx(E.FormLayout,{label:n.t("dataValidation.renderMode.label"),children:p.jsxs(E.RadioGroup,{value:`${(r=t.renderMode)!=null?r:o.DataValidationRenderMode.CUSTOM}`,onChange:i=>a({...t,renderMode:+i}),children:[p.jsx(E.Radio,{value:`${o.DataValidationRenderMode.CUSTOM}`,children:n.t("dataValidation.renderMode.chip")}),p.jsx(E.Radio,{value:`${o.DataValidationRenderMode.ARROW}`,children:n.t("dataValidation.renderMode.arrow")}),p.jsx(E.Radio,{value:`${o.DataValidationRenderMode.TEXT}`,children:n.t("dataValidation.renderMode.text")})]})})}He.componentKey=Ln;const jn="DATE_SHOW_TIME_OPTION";function We(e){var r;const{value:t,onChange:a}=e,n=w.useDependency(o.LocaleService);return p.jsx(E.FormLayout,{children:p.jsx(E.Checkbox,{checked:(r=t.bizInfo)==null?void 0:r.showTime,onChange:i=>{a({...t,bizInfo:{...t.bizInfo,showTime:i}})},children:n.t("dataValidation.showTime.label")})})}We.componentKey=jn;var xn=Object.getOwnPropertyDescriptor,Un=(e,t,a,n)=>{for(var r=n>1?void 0:n?xn(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},ye=(e,t)=>(a,n)=>t(a,n,e);const Ae=6;let rt=class{constructor(e,t,a,n,r,i){this._commandService=e,this._univerInstanceService=t,this._formulaService=a,this._themeService=n,this._renderManagerService=r,this._dataValidationModel=i}_calc(e,t){var d,h,g;const{vt:a,ht:n}=t||{},r=e.endX-e.startX-Ae*2,i=e.endY-e.startY,s=((d=t==null?void 0:t.fs)!=null?d:10)*1.6;let c=0,l=0;switch(a){case o.VerticalAlign.TOP:l=0;break;case o.VerticalAlign.BOTTOM:l=0+(i-s);break;default:l=0+(i-s)/2;break}switch(n){case o.HorizontalAlign.LEFT:c=Ae;break;case o.HorizontalAlign.RIGHT:c=Ae+(r-s);break;default:c=Ae+(r-s)/2;break}return{left:e.startX+c,top:e.startY+l,width:((h=t==null?void 0:t.fs)!=null?h:10)*1.6,height:((g=t==null?void 0:t.fs)!=null?g:10)*1.6}}calcCellAutoHeight(e){var a;const{style:t}=e;return((a=t==null?void 0:t.fs)!=null?a:10)*1.6}calcCellAutoWidth(e){var a;const{style:t}=e;return((a=t==null?void 0:t.fs)!=null?a:10)*1.6}async _parseFormula(e,t,a){var d,h,g,u,S,v,T,M,m;const{formula1:n=_.CHECKBOX_FORMULA_1,formula2:r=_.CHECKBOX_FORMULA_2}=e,i=await this._formulaService.getRuleFormulaResult(t,a,e.uid),s=_.getFormulaResult((g=(h=(d=i==null?void 0:i[0])==null?void 0:d.result)==null?void 0:h[0])==null?void 0:g[0]),c=_.getFormulaResult((v=(S=(u=i==null?void 0:i[1])==null?void 0:u.result)==null?void 0:S[0])==null?void 0:v[0]),l=_.isLegalFormulaResult(String(s))&&_.isLegalFormulaResult(String(c));return{formula1:o.isFormulaString(n)?_.getFormulaResult((m=(M=(T=i==null?void 0:i[0])==null?void 0:T.result)==null?void 0:M[0])==null?void 0:m[0]):n,formula2:o.isFormulaString(r)?c:r,isFormulaValid:l}}drawWith(e,t){var U,F,N,A;const{style:a,primaryWithCoord:n,unitId:r,subUnitId:i,worksheet:s,row:c,col:l}=t,d=n.isMergedMainCell?n.mergeInfo:n,h=_.getCellValueOrigin(s.getCellRaw(c,l)),g=this._dataValidationModel.getRuleByLocation(r,i,c,l);if(!g)return;const u=this._dataValidationModel.getValidator(g.type);if(!u||!((U=u.skipDefaultFontRender)!=null&&U.call(u,g,h,{unitId:r,subUnitId:i,row:c,column:l})))return;const S=u.parseFormulaSync(g,r,i),{formula1:v}=S,T=this._calc(d,a),{a:M,d:m}=e.getTransform(),C=L.fixLineWidthByScale(T.left,M),f=L.fixLineWidthByScale(T.top,m),y=L.Transform.create().composeMatrix({left:C,top:f,scaleX:1,scaleY:1,angle:0,skewX:0,skewY:0,flipX:!1,flipY:!1}),R=d.endX-d.startX,D=d.endY-d.startY;e.save(),e.beginPath(),e.rect(d.startX,d.startY,R,D),e.clip();const V=y.getMatrix();e.transform(V[0],V[1],V[2],V[3],V[4],V[5]);const x=((F=a==null?void 0:a.fs)!=null?F:10)*1.6,H=String(h)===String(v),P=this._themeService.getColorFromTheme("primary.600");L.CheckboxShape.drawWith(e,{checked:H,width:x,height:x,fill:(A=(N=a==null?void 0:a.cl)==null?void 0:N.rgb)!=null?A:P}),e.restore()}isHit(e,t){const a=t.primaryWithCoord.isMergedMainCell?t.primaryWithCoord.mergeInfo:t.primaryWithCoord,n=this._calc(a,t.style),r=n.top,i=n.top+n.height,s=n.left,c=n.left+n.width,{x:l,y:d}=e;return l<=c&&l>=s&&d<=i&&d>=r}async onPointerDown(e,t){var v;if(t.button===2)return;const{primaryWithCoord:a,unitId:n,subUnitId:r,worksheet:i,row:s,col:c}=e,l=_.getCellValueOrigin(i.getCellRaw(s,c)),d=this._dataValidationModel.getRuleByLocation(n,r,s,c);if(!d)return;const h=this._dataValidationModel.getValidator(d.type);if(!h||!((v=h.skipDefaultFontRender)!=null&&v.call(h,d,l,{unitId:n,subUnitId:r,row:s,column:c})))return;const{formula1:g,formula2:u}=await this._parseFormula(d,n,r),S={range:{startColumn:a.actualColumn,endColumn:a.actualColumn,startRow:a.actualRow,endRow:a.actualRow},value:{v:String(l)===_.transformCheckboxValue(String(g))?u:g,p:null}};this._commandService.executeCommand(W.SetRangeValuesCommand.id,S)}onPointerEnter(e,t){var a,n;(n=(a=L.getCurrentTypeOfRenderer(o.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null?void 0:a.mainComponent)==null||n.setCursor(L.CURSOR_TYPE.POINTER)}onPointerLeave(e,t){var a,n;(n=(a=L.getCurrentTypeOfRenderer(o.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null?void 0:a.mainComponent)==null||n.setCursor(L.CURSOR_TYPE.DEFAULT)}};rt=Un([ye(0,o.ICommandService),ye(1,o.IUniverInstanceService),ye(2,o.Inject(_.DataValidationFormulaService)),ye(3,o.Inject(o.ThemeService)),ye(4,o.Inject(L.IRenderManagerService)),ye(5,o.Inject(_.SheetDataValidationModel))],rt);class Fn extends exports.BaseSheetDataValidatorView{constructor(){super(...arguments);O(this,"id",o.DataValidationType.CHECKBOX);O(this,"canvasRender",this.injector.createInstance(rt));O(this,"formulaInput",_.CHECKBOX_FORMULA_INPUT_NAME)}}class Nn extends exports.BaseSheetDataValidatorView{constructor(){super(...arguments);O(this,"id",o.DataValidationType.CUSTOM);O(this,"formulaInput",_.CUSTOM_FORMULA_INPUT_NAME)}}const kn="data-validation.formula-input";class Bn extends exports.BaseSheetDataValidatorView{constructor(){super(...arguments);O(this,"id",o.DataValidationType.DATE);O(this,"formulaInput",kn);O(this,"optionsInput",We.componentKey);O(this,"dropdownType",$.DataValidatorDropdownType.DATE)}}class Hn extends exports.BaseSheetDataValidatorView{constructor(){super(...arguments);O(this,"id",o.DataValidationType.DECIMAL);O(this,"formulaInput",_.BASE_FORMULA_INPUT_NAME)}}const Ot=4,Wn=0,Ze=4,Pt=4,it=6,$e=6,me=14;function $n(e,t){const a=L.FontCache.getTextSize(e,t),n=a.width+Ot*2,{ba:r,bd:i}=a,s=r+i;return{width:n,height:s+Wn*2,ba:r}}function Je(e,t,a,n){const r=me+it*2,i=a-r,s=n-$e*2,c=e.map(u=>({layout:$n(u,t),text:u}));let l;const d=[];c.forEach(u=>{const{layout:S}=u,{width:v,height:T}=S;!l||l.width+v+Ze>i?(l={width:v,height:T,items:[{...u,left:0}]},d.push(l)):(l.items.push({...u,left:l.width+Ze}),l.width=l.width+v+Ze)});let h=0,g=0;return d.forEach((u,S)=>{g=Math.max(g,u.width),S===d.length-1?h+=u.height:h+=u.height+Pt}),{lines:d,totalHeight:h,contentWidth:i,contentHeight:s,cellAutoHeight:h+$e*2,calcAutoWidth:g+r}}const Yn=8;class Xn extends L.Shape{static drawWith(t,a){const{fontString:n,info:r,fill:i,color:s}=a,{layout:c,text:l}=r;t.save(),L.Rect.drawWith(t,{width:c.width,height:c.height,radius:Yn,fill:i||De}),t.translateWithPrecision(Ot,c.ba),t.font=n,t.fillStyle=s,t.fillText(l,0,0),t.restore()}}var zn=Object.getOwnPropertyDescriptor,Kn=(e,t,a,n)=>{for(var r=n>1?void 0:n?zn(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 Gn=new Path2D("M3.32201 4.84556C3.14417 5.05148 2.85583 5.05148 2.67799 4.84556L0.134292 1.90016C-0.152586 1.56798 0.0505937 1 0.456301 1L5.5437 1C5.94941 1 6.15259 1.56798 5.86571 1.90016L3.32201 4.84556Z");let ot=class{constructor(e,t,a,n){O(this,"zIndex");O(this,"_dropdownInfoMap",new Map);this._commandService=e,this._univerInstanceService=t,this._renderManagerService=a,this._dataValidationModel=n}_ensureMap(e){let t=this._dropdownInfoMap.get(e);return t||(t=new Map,this._dropdownInfoMap.set(e,t)),t}_generateKey(e,t){return`${e}.${t}`}_drawDownIcon(e,t,a,n,r){const i=a-me+4;let s=4;switch(r){case o.VerticalAlign.MIDDLE:s=(n-me)/2+4;break;case o.VerticalAlign.BOTTOM:s=n-me+4;break}e.save(),e.translateWithPrecision(t.startX+i,t.startY+s),e.fillStyle="#565656",e.fill(Gn),e.restore()}drawWith(e,t,a,n){var J,q;const{primaryWithCoord:r,row:i,col:s,style:c,data:l,subUnitId:d}=t,h=r.isMergedMainCell?r.mergeInfo:r,g=l==null?void 0:l.fontRenderExtension,{leftOffset:u=0,rightOffset:S=0,topOffset:v=0,downOffset:T=0}=g||{},M=this._ensureMap(d),m=this._generateKey(i,s),C=this._dataValidationModel.getRuleByLocation(t.unitId,t.subUnitId,i,s);if(!C)return;const f=this._dataValidationModel.getValidator(C.type);if(!f)return;const y={startX:h.startX+u,endX:h.endX-S,startY:h.startY+v,endY:h.endY-T},R=y.endX-y.startX,D=y.endY-y.startY,{cl:V}=c||{},x=(J=typeof V=="object"?V==null?void 0:V.rgb:V)!=null?J:"#000",H=L.getFontStyleString(c!=null?c:void 0),{vt:P,ht:U}=c||{},F=P!=null?P:o.VerticalAlign.MIDDLE,N=(q=_.getCellValueOrigin(l))!=null?q:"",A=f.parseCellValue(N),Y=f.getListWithColorMap(C),X=Je(A,H,R,D);this._drawDownIcon(e,y,R,D,F),e.save(),e.translateWithPrecision(y.startX,y.startY),e.beginPath(),e.rect(0,0,R-me,D),e.clip(),e.translateWithPrecision(it,$e);let G=0;switch(F){case o.VerticalAlign.MIDDLE:G=(X.contentHeight-X.totalHeight)/2;break;case o.VerticalAlign.BOTTOM:G=X.contentHeight-X.totalHeight;break}e.translateWithPrecision(0,G),X.lines.forEach((ee,le)=>{e.save();const{width:re,height:te,items:ie}=ee;let he=0;switch(U){case o.HorizontalAlign.RIGHT:he=X.contentWidth-re;break;case o.HorizontalAlign.CENTER:he=(X.contentWidth-re)/2;break}e.translate(he,le*(te+Pt)),ie.forEach(ce=>{e.save(),e.translateWithPrecision(ce.left,0),Xn.drawWith(e,{...H,info:ce,color:x,fill:Y[ce.text]}),e.restore()}),e.restore()}),e.restore(),M.set(m,{left:y.startX,top:y.startY,width:X.contentWidth+it+me,height:X.contentHeight+$e*2})}calcCellAutoHeight(e){var R;const{primaryWithCoord:t,style:a,data:n,row:r,col:i}=e,s=n==null?void 0:n.fontRenderExtension,{leftOffset:c=0,rightOffset:l=0,topOffset:d=0,downOffset:h=0}=s||{},g=t.isMergedMainCell?t.mergeInfo:t,u={startX:g.startX+c,endX:g.endX-l,startY:g.startY+d,endY:g.endY-h},S=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,r,i);if(!S)return;const v=this._dataValidationModel.getValidator(S.type);if(!v)return;const T=u.endX-u.startX,M=u.endY-u.startY,m=(R=_.getCellValueOrigin(n))!=null?R:"",C=v.parseCellValue(m),f=L.getFontStyleString(a!=null?a:void 0);return Je(C,f,T,M).cellAutoHeight}calcCellAutoWidth(e){var R;const{primaryWithCoord:t,style:a,data:n,row:r,col:i}=e,s=n==null?void 0:n.fontRenderExtension,{leftOffset:c=0,rightOffset:l=0,topOffset:d=0,downOffset:h=0}=s||{},g=t.isMergedMainCell?t.mergeInfo:t,u={startX:g.startX+c,endX:g.endX-l,startY:g.startY+d,endY:g.endY-h},S=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,r,i);if(!S)return;const v=this._dataValidationModel.getValidator(S.type);if(!v)return;const T=u.endX-u.startX,M=u.endY-u.startY,m=(R=_.getCellValueOrigin(n))!=null?R:"",C=v.parseCellValue(m),f=L.getFontStyleString(a!=null?a:void 0);return Je(C,f,T,M).calcAutoWidth}isHit(e,t){const{primaryWithCoord:a}=t,n=a.isMergedMainCell?a.mergeInfo:a,{endX:r}=n,{x:i}=e;return i>=r-me&&i<=r}onPointerDown(e,t){if(t.button===2)return;const{unitId:a,subUnitId:n,row:r,col:i}=e,s={unitId:a,subUnitId:n,row:r,column:i};this._commandService.executeCommand(Ye.id,s)}onPointerEnter(e,t){var a,n;return(n=(a=L.getCurrentTypeOfRenderer(o.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null?void 0:a.mainComponent)==null?void 0:n.setCursor(L.CURSOR_TYPE.POINTER)}onPointerLeave(e,t){var a,n;return(n=(a=L.getCurrentTypeOfRenderer(o.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null?void 0:a.mainComponent)==null?void 0:n.setCursor(L.CURSOR_TYPE.DEFAULT)}};ot=Kn([Le(0,o.ICommandService),Le(1,o.IUniverInstanceService),Le(2,o.Inject(L.IRenderManagerService)),Le(3,o.Inject(_.SheetDataValidationModel))],ot);class qn extends exports.BaseSheetDataValidatorView{constructor(){super(...arguments);O(this,"id",o.DataValidationType.LIST_MULTIPLE);O(this,"canvasRender",this.injector.createInstance(ot));O(this,"dropdownType",$.DataValidatorDropdownType.MULTIPLE_LIST)}}var Zn=Object.getOwnPropertyDescriptor,Jn=(e,t,a,n)=>{for(var r=n>1?void 0:n?Zn(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},Oe=(e,t)=>(a,n)=>t(a,n,e);const ve=4,je=4,se=14,de=6,Re=4,Qe=8,Qn="#565656",St=new Path2D("M3.32201 4.84556C3.14417 5.05148 2.85583 5.05148 2.67799 4.84556L0.134292 1.90016C-0.152586 1.56798 0.0505937 1 0.456301 1L5.5437 1C5.94941 1 6.15259 1.56798 5.86571 1.90016L3.32201 4.84556Z");function ea(e,t){const a=e.length;return{id:"d",body:{dataStream:`${e}${o.DEFAULT_EMPTY_DOCUMENT_VALUE}`,textRuns:[{ts:{fs:11,ff:void 0,it:o.BooleanNumber.FALSE,bl:o.BooleanNumber.FALSE,ul:{s:o.BooleanNumber.FALSE},st:{s:o.BooleanNumber.FALSE},ol:{s:o.BooleanNumber.FALSE},cl:void 0,...t,bg:void 0,bd:void 0},st:0,ed:a}]},documentStyle:{pageSize:{width:Number.POSITIVE_INFINITY,height:Number.POSITIVE_INFINITY}}}}function At(e,t,a){const n=ea(e,a),r=new o.DocumentDataModel(n),i=new L.DocumentViewModel(r);return{documentSkeleton:L.DocumentSkeleton.create(i,t),docModel:r,docViewModel:i}}function xe(e,t,a){const{documentSkeleton:n,docModel:r,docViewModel:i}=At(e,t,a);return{documents:new L.Documents(`DOCUMENTS_${o.Tools.generateRandomId()}`,n,{pageMarginLeft:0,pageMarginTop:0}),documentSkeleton:n,docModel:r,docViewModel:i}}function _t(e,t,a,n,r,i,s=!0){let c=0;const l=s?Re:0;switch(r){case o.VerticalAlign.BOTTOM:c=t-n-l;break;case o.VerticalAlign.MIDDLE:c=(t-n)/2;break;default:c=l;break}c=Math.max(Re,c);let d=0;switch(i){case o.HorizontalAlign.CENTER:d=(e-a)/2;break;case o.HorizontalAlign.RIGHT:d=e-a;break}return d=Math.max(de,d),{paddingLeft:d,paddingTop:c}}let st=class{constructor(e,t,a,n,r){O(this,"_dropdownInfoMap",new Map);O(this,"zIndex");this._univerInstanceService=e,this._localeService=t,this._commandService=a,this._renderManagerService=n,this._dataValidationModel=r}_ensureMap(e){let t=this._dropdownInfoMap.get(e);return t||(t=new Map,this._dropdownInfoMap.set(e,t)),t}_generateKey(e,t){return`${e}.${t}`}_drawDownIcon(e,t,a,n,r,i,s){const{t:c=o.DEFAULT_STYLES.pd.t,b:l=o.DEFAULT_STYLES.pd.b}=s,d=a-se;let h;switch(i){case o.VerticalAlign.MIDDLE:h=(n-je)/2;break;case o.VerticalAlign.BOTTOM:h=n-l-r-Re+(r/2-je/2);break;default:h=c+Re+(r/2-je/2);break}e.save(),e.translateWithPrecision(t.startX+d,t.startY+h),e.fillStyle="#565656",e.fill(St),e.restore()}drawWith(e,t,a){const{primaryWithCoord:n,row:r,col:i,style:s,data:c,subUnitId:l}=t,d=n.isMergedMainCell?n.mergeInfo:n,h=this._dataValidationModel.getRuleByLocation(t.unitId,t.subUnitId,r,i);if(!h)return;const g=this._dataValidationModel.getValidator(h.type);if(!g)return;const u=c==null?void 0:c.fontRenderExtension,{leftOffset:S=0,rightOffset:v=0,topOffset:T=0,downOffset:M=0}=u||{};if(!h||!g||!g||g.id.indexOf(o.DataValidationType.LIST)!==0||!g.skipDefaultFontRender(h))return;const m={startX:d.startX+S,endX:d.endX-v,startY:d.startY+T,endY:d.endY-M},C=m.endX-m.startX,f=m.endY-m.startY,y=this._ensureMap(l),R=this._generateKey(r,i),D=g.getListWithColor(h),V=_.getCellValueOrigin(c),x=`${V!=null?V:""}`,H=D.find(A=>A.label===x);let{tb:P,vt:U,ht:F,pd:N}=s||{};if(P=P!=null?P:o.WrapStrategy.WRAP,U=U!=null?U:o.VerticalAlign.BOTTOM,F=F!=null?F:o.DEFAULT_STYLES.ht,N=N!=null?N:o.DEFAULT_STYLES.pd,h.renderMode===o.DataValidationRenderMode.ARROW){const{l:A=o.DEFAULT_STYLES.pd.l,t:Y=o.DEFAULT_STYLES.pd.t,r:X=o.DEFAULT_STYLES.pd.r,b:G=o.DEFAULT_STYLES.pd.b}=N,J=C-A-X-se-4,{documentSkeleton:q,documents:ee,docModel:le}=xe(x,this._localeService,s);P===o.WrapStrategy.WRAP&&le.updateDocumentDataPageSize(Math.max(J,1)),q.calculate(),q.getActualSize();const re=L.getDocsSkeletonPageSize(q),{height:te,width:ie}=re,{paddingTop:he,paddingLeft:ce}=_t(J,f-Y-G,ie,te,U,F,!0);this._drawDownIcon(e,m,C,f,te,U,N),e.save(),e.translateWithPrecision(m.startX+A,m.startY+Y),e.beginPath(),e.rect(0,0,C-A-X,f-Y-G),e.clip(),e.translateWithPrecision(0,he),e.save(),e.translateWithPrecision(ve,0),e.beginPath(),e.rect(0,0,J,te),e.clip(),ee.render(e),e.translateWithPrecision(ce,0),e.restore(),e.restore(),y.set(R,{left:m.endX+A+a.rowHeaderWidth-se,top:m.startY+Y+a.columnHeaderHeight,width:se,height:f-Y-G})}else{e.save(),e.translateWithPrecision(m.startX,m.startY),e.beginPath(),e.rect(0,0,C,f),e.clip();const A=C-de*2-ve-se-4,{documentSkeleton:Y,documents:X,docModel:G}=xe(x,this._localeService,s);P===o.WrapStrategy.WRAP&&G.updateDocumentDataPageSize(Math.max(A,1)),Y.calculate();const J=L.getDocsSkeletonPageSize(Y),{height:q,width:ee}=J,{paddingTop:le,paddingLeft:re}=_t(A,f,ee,q,U,F);e.translateWithPrecision(de,le);const te=Math.max(C-de*2,1),ie=q;L.Rect.drawWith(e,{width:te,height:ie,fill:(H==null?void 0:H.color)||De,radius:Qe}),e.save(),e.translateWithPrecision(ve,0),e.beginPath(),e.rect(0,0,A,q),e.clip(),e.translateWithPrecision(re,0),X.render(e),e.restore(),e.translateWithPrecision(A+ve+4,(q-je)/2),e.fillStyle=Qn,e.fill(St),e.restore(),y.set(R,{left:m.startX+de+a.rowHeaderWidth,top:m.startY+le+a.columnHeaderHeight,width:te,height:ie})}}calcCellAutoHeight(e){const{primaryWithCoord:t,style:a,data:n,row:r,col:i}=e,s=t.isMergedMainCell?t.mergeInfo:t,c=n==null?void 0:n.fontRenderExtension,{leftOffset:l=0,rightOffset:d=0,topOffset:h=0,downOffset:g=0}=c||{},u=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,r,i);if(!u||u.renderMode===o.DataValidationRenderMode.TEXT)return;const S={startX:s.startX+l,endX:s.endX-d,startY:s.startY+h,endY:s.endY-g},v=S.endX-S.startX,T=_.getCellValueOrigin(n),M=`${T!=null?T:""}`;let{tb:m,pd:C}=a||{};const{t:f=o.DEFAULT_STYLES.pd.t,b:y=o.DEFAULT_STYLES.pd.b}=C!=null?C:{};if(m=m!=null?m:o.WrapStrategy.WRAP,u.renderMode===o.DataValidationRenderMode.ARROW){const R=v-se,{documentSkeleton:D,docModel:V}=xe(M,this._localeService,a);m===o.WrapStrategy.WRAP&&V.updateDocumentDataPageSize(Math.max(R,1)),D.calculate(),D.getActualSize();const x=L.getDocsSkeletonPageSize(D),{height:H}=x;return H+f+y+Re*2}else{const R=v-de*2-ve-se,{documentSkeleton:D,docModel:V}=At(M,this._localeService,a);m===o.WrapStrategy.WRAP&&V.updateDocumentDataPageSize(Math.max(R,1)),D.calculate();const x=L.getDocsSkeletonPageSize(D),{height:H}=x;return H+Re*2}}calcCellAutoWidth(e){const{primaryWithCoord:t,style:a,data:n,row:r,col:i}=e,s=t.isMergedMainCell?t.mergeInfo:t,c=n==null?void 0:n.fontRenderExtension,{leftOffset:l=0,rightOffset:d=0,topOffset:h=0,downOffset:g=0}=c||{},u=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,r,i);if(!u||u.renderMode===o.DataValidationRenderMode.TEXT)return;const S={startX:s.startX+l,endX:s.endX-d,startY:s.startY+h,endY:s.endY-g},v=S.endX-S.startX,T=_.getCellValueOrigin(n),M=`${T!=null?T:""}`;let{tb:m,pd:C}=a||{};const{l:f=o.DEFAULT_STYLES.pd.l,r:y=o.DEFAULT_STYLES.pd.r}=C!=null?C:{};m=m!=null?m:o.WrapStrategy.WRAP;let R=de*2+se;switch(u.renderMode){case o.DataValidationRenderMode.ARROW:R=se+de*2+y+f;break;case o.DataValidationRenderMode.CUSTOM:R=se+de*2+ve*2+y+f+Qe/2+1;break;default:R=se+de*2+ve*2+y+f+Qe/2+1}const D=v-R,{documentSkeleton:V,docModel:x}=xe(M,this._localeService,a);return m===o.WrapStrategy.WRAP&&x.updateDocumentDataPageSize(Math.max(D,1)),V.calculate(),V.getActualSize(),L.getDocsSkeletonPageSize(V).width+R}isHit(e,t){const{subUnitId:a,row:n,col:r}=t,s=this._ensureMap(a).get(this._generateKey(n,r)),c=this._dataValidationModel.getRuleByLocation(t.unitId,t.subUnitId,n,r);if(!c||!s||c.renderMode===o.DataValidationRenderMode.TEXT)return!1;const{top:l,left:d,width:h,height:g}=s,{x:u,y:S}=e;return u>=d&&u<=d+h&&S>=l&&S<=l+g}onPointerDown(e,t){if(t.button===2)return;const{unitId:a,subUnitId:n,row:r,col:i}=e,s={unitId:a,subUnitId:n,row:r,column:i};this._commandService.executeCommand(Ye.id,s)}onPointerEnter(e,t){var a,n;(n=(a=L.getCurrentTypeOfRenderer(o.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null?void 0:a.mainComponent)==null||n.setCursor(L.CURSOR_TYPE.POINTER)}onPointerLeave(e,t){var a,n;(n=(a=L.getCurrentTypeOfRenderer(o.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null?void 0:a.mainComponent)==null||n.setCursor(L.CURSOR_TYPE.DEFAULT)}};st=Jn([Oe(0,o.IUniverInstanceService),Oe(1,o.Inject(o.LocaleService)),Oe(2,o.ICommandService),Oe(3,o.Inject(L.IRenderManagerService)),Oe(4,o.Inject(_.SheetDataValidationModel))],st);class ta extends exports.BaseSheetDataValidatorView{constructor(){super(...arguments);O(this,"id",o.DataValidationType.LIST);O(this,"canvasRender",this.injector.createInstance(st));O(this,"dropdownType",$.DataValidatorDropdownType.LIST);O(this,"optionsInput",He.componentKey);O(this,"formulaInput",_.LIST_FORMULA_INPUT_NAME)}}class na extends exports.BaseSheetDataValidatorView{constructor(){super(...arguments);O(this,"id",o.DataValidationType.TEXT_LENGTH);O(this,"formulaInput",_.BASE_FORMULA_INPUT_NAME)}}class aa extends exports.BaseSheetDataValidatorView{constructor(){super(...arguments);O(this,"id",o.DataValidationType.WHOLE);O(this,"formulaInput",_.BASE_FORMULA_INPUT_NAME)}}var ra=Object.getOwnPropertyDescriptor,ia=(e,t,a,n)=>{for(var r=n>1?void 0:n?ra(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},et=(e,t)=>(a,n)=>t(a,n,e);let Te=class extends o.RxDisposable{constructor(e,t,a){super(),this._injector=e,this._componentManger=t,this._dataValidatorRegistryService=a,this._initComponents(),this._registerValidatorViews()}_initComponents(){[[Et,Ct],[ke,An],[He.componentKey,He],[We.componentKey,We],...en].forEach(([e,t])=>{this.disposeWithMe(this._componentManger.register(e,t))})}_registerValidatorViews(){[Hn,aa,na,Bn,Fn,ta,qn,Nn].forEach(e=>{const t=this._injector.createInstance(e),a=this._dataValidatorRegistryService.getValidatorItem(t.id);a&&(a.formulaInput=t.formulaInput,a.canvasRender=t.canvasRender,a.dropdownType=t.dropdownType,a.optionsInput=t.optionsInput)})}};Te=ia([et(0,o.Inject(o.Injector)),et(1,o.Inject(w.ComponentManager)),et(2,o.Inject($.DataValidatorRegistryService))],Te);var oa=Object.getOwnPropertyDescriptor,sa=(e,t,a,n)=>{for(var r=n>1?void 0:n?oa(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},tt=(e,t)=>(a,n)=>t(a,n,e);const la="SHEET_DATA_VALIDATION_UI_PLUGIN";var Ue;exports.UniverSheetsDataValidationUIPlugin=(Ue=class extends o.Plugin{constructor(t=Ne,a,n,r){super(),this._config=t,this._injector=a,this._commandService=n,this._configService=r;const{menu:i,...s}=o.merge({},Ne,this._config);i&&this._configService.setConfig("menu",i,{merge:!0}),this._configService.setConfig(ut,s)}onStarting(){[[ue],[fe],[Pe],[we],[be],[Me],[Ee],[Ve],[Te]].forEach(t=>{this._injector.add(t)}),[Xe,Ye,wt,ht,_e,Vt].forEach(t=>{this._commandService.registerCommand(t)})}onReady(){this._injector.get(Ee),this._injector.get(Me),this._injector.get(Ve),this._injector.get(Pe),this._injector.get(L.IRenderManagerService).registerRenderModule(o.UniverInstanceType.UNIVER_SHEET,[Be])}onRendered(){this._injector.get(Te),this._injector.get(be)}onSteady(){this._injector.get(we)}},O(Ue,"pluginName",la),O(Ue,"type",o.UniverInstanceType.UNIVER_SHEET),Ue);exports.UniverSheetsDataValidationUIPlugin=sa([tt(1,o.Inject(o.Injector)),tt(2,o.ICommandService),tt(3,o.IConfigService)],exports.UniverSheetsDataValidationUIPlugin);var ca=Object.getOwnPropertyDescriptor,da=(e,t,a,n)=>{for(var r=n>1?void 0:n?ca(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},nt=(e,t)=>(a,n)=>t(a,n,e);const ua="SHEET_DATA_VALIDATION_UI_PLUGIN";var Fe;exports.UniverSheetsDataValidationMobileUIPlugin=(Fe=class extends o.Plugin{constructor(t=Ne,a,n,r){super(),this._config=t,this._injector=a,this._commandService=n,this._configService=r;const{menu:i,...s}=o.merge({},Ne,this._config);i&&this._configService.setConfig("menu",i,{merge:!0}),this._configService.setConfig(ut,s)}onStarting(){[[ue],[fe],[Pe],[we],[be],[Me],[Ee],[Te]].forEach(t=>{this._injector.add(t)}),[Xe,Ye,wt,ht,_e,Vt].forEach(t=>{this._commandService.registerCommand(t)})}onReady(){this._injector.get(Ee),this._injector.get(Me),this._injector.get(L.IRenderManagerService).registerRenderModule(o.UniverInstanceType.UNIVER_SHEET,[Be])}onRendered(){this._injector.get(Te),this._injector.get(be)}onSteady(){this._injector.get(we)}},O(Fe,"pluginName",ua),O(Fe,"type",o.UniverInstanceType.UNIVER_SHEET),Fe);exports.UniverSheetsDataValidationMobileUIPlugin=da([nt(1,o.Inject(o.Injector)),nt(2,o.ICommandService),nt(3,o.IConfigService)],exports.UniverSheetsDataValidationMobileUIPlugin);