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