@univerjs/sheets-data-validation-ui 0.5.0-nightly.202411221606 → 0.5.0-nightly.202411230627

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/cjs/index.js CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";var Jt=Object.defineProperty;var Qt=(t,e,a)=>e in t?Jt(t,e,{enumerable:!0,configurable:!0,writable:!0,value:a}):t[e]=a;var P=(t,e,a)=>Qt(t,typeof e!="symbol"?e+"":e,a);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const R=require("react"),i=require("@univerjs/core"),T=require("@univerjs/design"),B=require("@univerjs/engine-render"),Y=require("@univerjs/sheets"),E=require("@univerjs/sheets-data-validation"),en=require("@univerjs/sheets-numfmt"),N=require("@univerjs/sheets-ui"),X=require("@univerjs/ui"),ee=require("@univerjs/data-validation"),tn=require("@univerjs/docs"),le=require("rxjs"),lt=require("@univerjs/engine-formula"),pt=require("@univerjs/sheets-formula-ui");var bt={exports:{}},Xe={};/**
1
+ "use strict";var Jt=Object.defineProperty;var Qt=(e,t,a)=>t in e?Jt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a;var T=(e,t,a)=>Qt(e,typeof t!="symbol"?t+"":t,a);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const V=require("react"),i=require("@univerjs/core"),O=require("@univerjs/design"),B=require("@univerjs/engine-render"),Y=require("@univerjs/sheets"),w=require("@univerjs/sheets-data-validation"),en=require("@univerjs/sheets-numfmt"),N=require("@univerjs/sheets-ui"),X=require("@univerjs/ui"),Q=require("@univerjs/data-validation"),tn=require("@univerjs/docs"),le=require("rxjs"),dt=require("@univerjs/engine-formula"),mt=require("@univerjs/sheets-formula-ui");var Mt={exports:{}},ze={};/**
2
2
  * @license React
3
3
  * react-jsx-runtime.production.min.js
4
4
  *
@@ -6,4 +6,4 @@
6
6
  *
7
7
  * This source code is licensed under the MIT license found in the
8
8
  * LICENSE file in the root directory of this source tree.
9
- */var nn=R,an=Symbol.for("react.element"),on=Symbol.for("react.fragment"),rn=Object.prototype.hasOwnProperty,sn=nn.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,ln={key:!0,ref:!0,__self:!0,__source:!0};function Mt(t,e,a){var n,o={},r=null,s=null;a!==void 0&&(r=""+a),e.key!==void 0&&(r=""+e.key),e.ref!==void 0&&(s=e.ref);for(n in e)rn.call(e,n)&&!ln.hasOwnProperty(n)&&(o[n]=e[n]);if(t&&t.defaultProps)for(n in e=t.defaultProps,e)o[n]===void 0&&(o[n]=e[n]);return{$$typeof:an,type:t,key:r,ref:s,props:o,_owner:sn.current}}Xe.Fragment=on;Xe.jsx=Mt;Xe.jsxs=Mt;bt.exports=Xe;var m=bt.exports,dn=Object.defineProperty,cn=Object.getOwnPropertyDescriptor,un=(t,e,a,n)=>{for(var o=n>1?void 0:n?cn(e,a):e,r=t.length-1,s;r>=0;r--)(s=t[r])&&(o=(n?s(e,a,o):s(o))||o);return n&&o&&dn(e,a,o),o},Me=(t,e)=>(a,n)=>e(a,n,t);let Te=class extends i.Disposable{constructor(t,e,a,n,o){super(),this._sheetInterceptorService=t,this._dataValidationModel=e,this._dataValidatorRegistryService=a,this._dialogService=n,this._localeService=o,this._initEditorBridgeInterceptor()}_initEditorBridgeInterceptor(){this._sheetInterceptorService.writeCellInterceptor.intercept(Y.AFTER_CELL_EDIT_ASYNC,{handler:async(t,e,a)=>{var v;const n=await t,{worksheet:o,row:r,col:s,unitId:d,subUnitId:l,workbook:h}=e,u=this._dataValidationModel.getRuleIdByLocation(d,l,r,s),p=u?this._dataValidationModel.getRuleById(d,l,u):void 0;if(!p||p.errorStyle!==i.DataValidationErrorStyle.STOP)return a(Promise.resolve(n));const c=await this._dataValidatorRegistryService.getValidatorItem(p.type);if(!c||await c.validator({value:E.getCellValueOrigin(n),interceptValue:E.getCellValueOrigin((v=e==null?void 0:e.origin)!=null?v:n),row:r,column:s,unitId:d,subUnitId:l,worksheet:o,workbook:h,t:n==null?void 0:n.t},p))return a(Promise.resolve(n));const g=o.getCellRaw(r,s);return this._dialogService.open({width:368,title:{title:this._localeService.t("dataValidation.alert.title")},id:"reject-input-dialog",children:{title:c.getRuleFinalError(p,{row:r,col:s,unitId:d,subUnitId:l})},footer:{title:R.createElement(T.Button,{type:"primary",onClick:()=>this._dialogService.close("reject-input-dialog")},this._localeService.t("dataValidation.alert.ok"))},onClose:()=>{this._dialogService.close("reject-input-dialog")}}),a(Promise.resolve(g))}})}showReject(t){this._dialogService.open({width:368,title:{title:this._localeService.t("dataValidation.alert.title")},id:"reject-input-dialog",children:{title:t},footer:{title:R.createElement(T.Button,{type:"primary",onClick:()=>this._dialogService.close("reject-input-dialog")},this._localeService.t("dataValidation.alert.ok"))},onClose:()=>{this._dialogService.close("reject-input-dialog")}})}};Te=un([Me(0,i.Inject(Y.SheetInterceptorService)),Me(1,i.Inject(E.SheetDataValidationModel)),Me(2,i.Inject(ee.DataValidatorRegistryService)),Me(3,X.IDialogService),Me(4,i.Inject(i.LocaleService))],Te);const hn="univer-dv-date-dropdown",pn="univer-dv-date-dropdown-btns",It={dvDateDropdown:hn,dvDateDropdownBtns:pn},mn=t=>{if(t==null||typeof t=="boolean")return;if(typeof t=="number"||!Number.isNaN(+t))return i.dayjs(i.numfmt.format("yyyy-MM-dd HH:mm:ss",Number(t)));const e=i.dayjs(t);if(e.isValid())return e};function gn(t){var M,_,y;const{location:e,hideFn:a}=t,{worksheet:n,row:o,col:r,unitId:s,subUnitId:d,workbook:l}=e,h=i.useDependency(i.ICommandService),u=i.useDependency(Te),p=n.getCell(o,r),c=(M=p==null?void 0:p.dataValidation)==null?void 0:M.rule,f=(_=p==null?void 0:p.dataValidation)==null?void 0:_.validator,g=E.getCellValueOrigin(n.getCellRaw(o,r)),v=mn(g),[C,I]=R.useState(v),D=!!((y=c==null?void 0:c.bizInfo)!=null&&y.showTime),S=C&&C.isValid()?C:i.dayjs(),b=i.useDependency(i.LocaleService);if(!p||!c||!f)return;const w=async()=>{var U,k,z;if(!S)return;const H=S.format(D?"YYYY-MM-DD HH:mm:ss":"YYYY-MM-DD 00:00:00"),F=(U=i.numfmt.parseDate(H))==null?void 0:U.v,L=l.getStyles().getStyleByCell(p),j=(z=(k=L==null?void 0:L.n)==null?void 0:k.pattern)!=null?z:"",x=en.getPatternType(j);c.errorStyle!==i.DataValidationErrorStyle.STOP||await f.validator({value:F,unitId:s,subUnitId:d,row:o,column:r,worksheet:n,workbook:l,interceptValue:H.replace("Z","").replace("T"," "),t:i.CellValueType.NUMBER},c)?(a(),await h.executeCommand(N.SetCellEditVisibleOperation.id,{visible:!1,eventType:B.DeviceInputEventType.Keyboard,unitId:s,keycode:X.KeyCode.ESC}),await h.executeCommand(Y.SetRangeValuesCommand.id,{unitId:s,subUnitId:d,range:{startColumn:r,endColumn:r,startRow:o,endRow:o},value:{v:F,t:2,p:null,f:null,si:null,s:{n:{pattern:D?x==="datetime"?j:"yyyy-MM-dd hh:mm:ss":x==="date"?j:"yyyy-MM-dd"}}}})):u.showReject(f.getRuleFinalError(c,{row:o,col:r,unitId:s,subUnitId:d}))};return m.jsxs("div",{className:It.dvDateDropdown,children:[m.jsx(T.DatePanel,{defaultValue:S,pickerValue:S,showTime:D||void 0,onSelect:async A=>{I(A)},onPanelChange:A=>{I(A)},disabledDate:A=>!i.numfmt.parseDate(A.format("YYYY-MM-DD"))}),m.jsx("div",{className:It.dvDateDropdownBtns,children:m.jsx(T.Button,{size:"small",type:"primary",onClick:w,disabled:!S.isValid(),children:b.t("dataValidation.alert.ok")})})]})}var se=function(){return se=Object.assign||function(t){for(var e,a=1,n=arguments.length;a<n;a++){e=arguments[a];for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o])}return t},se.apply(this,arguments)},vn=function(t,e){var a={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(a[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,n=Object.getOwnPropertySymbols(t);o<n.length;o++)e.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(t,n[o])&&(a[n[o]]=t[n[o]]);return a},ve=R.forwardRef(function(t,e){var a=t.icon,n=t.id,o=t.className,r=t.extend,s=vn(t,["icon","id","className","extend"]),d="univerjs-icon univerjs-icon-".concat(n," ").concat(o||"").trim(),l=R.useRef("_".concat(_n()));return Ot(a,"".concat(n),{defIds:a.defIds,idSuffix:l.current},se({ref:e,className:d},s),r)});function Ot(t,e,a,n,o){return R.createElement(t.tag,se(se({key:e},fn(t,a,o)),n),(Sn(t,a).children||[]).map(function(r,s){return Ot(r,"".concat(e,"-").concat(t.tag,"-").concat(s),a,void 0,o)}))}function fn(t,e,a){var n=se({},t.attrs);a!=null&&a.colorChannel1&&n.fill==="colorChannel1"&&(n.fill=a.colorChannel1);var o=e.defIds;return!o||o.length===0||(t.tag==="use"&&n["xlink:href"]&&(n["xlink:href"]=n["xlink:href"]+e.idSuffix),Object.entries(n).forEach(function(r){var s=r[0],d=r[1];typeof d=="string"&&(n[s]=d.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))})),n}function Sn(t,e){var a,n=e.defIds;return!n||n.length===0?t:t.tag==="defs"&&(!((a=t.children)===null||a===void 0)&&a.length)?se(se({},t),{children:t.children.map(function(o){return typeof o.attrs.id=="string"&&n&&n.indexOf(o.attrs.id)>-1?se(se({},o),{attrs:se(se({},o.attrs),{id:o.attrs.id+e.idSuffix})}):o})}):t}function _n(){return Math.random().toString(36).substring(2,8)}ve.displayName="UniverIcon";var In={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M14.1544 3.75557C14.3887 3.98988 14.3887 4.36978 14.1544 4.6041L6.51409 12.2444C6.40157 12.3569 6.24896 12.4201 6.08983 12.4201C5.9307 12.4201 5.77808 12.3569 5.66556 12.2444L1.84541 8.42425C1.6111 8.18993 1.6111 7.81003 1.84541 7.57572C2.07973 7.34141 2.45963 7.34141 2.69394 7.57572L6.08983 10.9716L13.3059 3.75557C13.5402 3.52126 13.9201 3.52126 14.1544 3.75557Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Tt=R.forwardRef(function(t,e){return R.createElement(ve,Object.assign({},t,{id:"check-mark-single",ref:e,icon:In}))});Tt.displayName="CheckMarkSingle";var Cn={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"}}]},Pt=R.forwardRef(function(t,e){return R.createElement(ve,Object.assign({},t,{id:"data-validation-single",ref:e,icon:Cn}))});Pt.displayName="DataValidationSingle";var Dn={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"}}]},mt=R.forwardRef(function(t,e){return R.createElement(ve,Object.assign({},t,{id:"delete-single",ref:e,icon:Dn}))});mt.displayName="DeleteSingle";var Rn={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"}}]},Lt=R.forwardRef(function(t,e){return R.createElement(ve,Object.assign({},t,{id:"increase-single",ref:e,icon:Rn}))});Lt.displayName="IncreaseSingle";var Vn={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"}}]},jt=R.forwardRef(function(t,e){return R.createElement(ve,Object.assign({},t,{id:"more-down-single",ref:e,icon:Vn}))});jt.displayName="MoreDownSingle";var yn={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"}}]},At=R.forwardRef(function(t,e){return R.createElement(ve,Object.assign({},t,{id:"more-up-single",ref:e,icon:yn}))});At.displayName="MoreUpSingle";var wn={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"}}]}]},Ft=R.forwardRef(function(t,e){return R.createElement(ve,Object.assign({},t,{id:"sequence-single",ref:e,icon:wn}))});Ft.displayName="SequenceSingle";var En=Object.defineProperty,bn=Object.getOwnPropertyDescriptor,Mn=(t,e,a,n)=>{for(var o=n>1?void 0:n?bn(e,a):e,r=t.length-1,s;r>=0;r--)(s=t[r])&&(o=(n?s(e,a,o):s(o))||o);return n&&o&&En(e,a,o),o},Ct=(t,e)=>(a,n)=>e(a,n,t);let ue=class extends i.Disposable{constructor(e,a){super();P(this,"_open$",new le.BehaviorSubject(!1));P(this,"open$",this._open$.pipe(le.distinctUntilChanged()));P(this,"_activeRule");P(this,"_activeRule$",new le.BehaviorSubject(void 0));P(this,"activeRule$",this._activeRule$.asObservable());P(this,"_closeDisposable",null);this._univerInstanceService=e,this._sidebarService=a,this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(i.UniverInstanceType.UNIVER_SHEET).pipe(le.filter(n=>!n)).subscribe(()=>{this.close()})),this.disposeWithMe(this._sidebarService.sidebarOptions$.subscribe(n=>{n.id===gt&&(n.visible||setTimeout(()=>{this._sidebarService.sidebarOptions$.next({visible:!1})}))}))}get activeRule(){return this._activeRule}get isOpen(){return this._open$.getValue()}dispose(){var e;super.dispose(),this._open$.next(!1),this._open$.complete(),this._activeRule$.complete(),(e=this._closeDisposable)==null||e.dispose()}open(){this._open$.next(!0)}close(){var e;this._open$.next(!1),(e=this._closeDisposable)==null||e.dispose()}setCloseDisposable(e){this._closeDisposable=i.toDisposable(()=>{e.dispose(),this._closeDisposable=null})}setActiveRule(e){this._activeRule=e,this._activeRule$.next(e)}};ue=Mn([Ct(0,i.IUniverInstanceService),Ct(1,X.ISidebarService)],ue);function On(){const t=i.useDependency(ge),e=X.useObservable(t.activeDropdown$,t.activeDropdown),a=i.useDependency(X.ComponentManager);if(!e)return null;const{location:n,componentKey:o}=e,r=a.get(o),s=`${n.unitId}-${n.subUnitId}-${n.row}-${n.col}`;if(!r)return null;const d=()=>{t.hideDropdown()};return m.jsx(r,{location:n,hideFn:d},s)}const xt="sheet.ui.dropdown";var Tn=Object.defineProperty,Pn=Object.getOwnPropertyDescriptor,Ln=(t,e,a,n)=>{for(var o=n>1?void 0:n?Pn(e,a):e,r=t.length-1,s;r>=0;r--)(s=t[r])&&(o=(n?s(e,a,o):s(o))||o);return n&&o&&Tn(e,a,o),o},fe=(t,e)=>(a,n)=>e(a,n,t);let ge=class extends i.Disposable{constructor(e,a,n,o,r,s,d){super();P(this,"_activeDropdown");P(this,"_activeDropdown$",new le.Subject);P(this,"_currentPopup",null);P(this,"activeDropdown$",this._activeDropdown$.asObservable());P(this,"_zenVisible",!1);this._canvasPopupManagerService=e,this._univerInstanceService=a,this._dataValidatorRegistryService=n,this._zenZoneService=o,this._renderManagerService=r,this._dataValidationModel=s,this._sheetsSelectionsService=d,this._init(),this._initSelectionChange(),this.disposeWithMe(()=>{this._activeDropdown$.complete()})}get activeDropdown(){return this._activeDropdown}_init(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(e=>{this._zenVisible=e,e&&this.hideDropdown()}))}_getDropdownByCell(e,a,n,o){const r=e?this._univerInstanceService.getUnit(e,i.UniverInstanceType.UNIVER_SHEET):this._univerInstanceService.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET);if(!r)return;const s=a?r.getSheetBySheetId(a):r.getActiveSheet();if(!s)return;const d=this._dataValidationModel.getRuleByLocation(r.getUnitId(),s.getSheetId(),n,o);if(!d)return;const l=this._dataValidatorRegistryService.getValidatorItem(d.type);return l==null?void 0:l.dropdown}_initSelectionChange(){this.disposeWithMe(this._sheetsSelectionsService.selectionMoveEnd$.subscribe(e=>{e&&e.every(a=>!(a.primary&&this._getDropdownByCell(a.primary.unitId,a.primary.sheetId,a.primary.actualRow,a.primary.actualColumn)))&&this.hideDropdown()}))}showDropdown(e,a=!0){const{location:n}=e,{row:o,col:r,unitId:s,subUnitId:d}=n;if(this._currentPopup&&this._currentPopup.dispose(),this._zenVisible)return;this._activeDropdown=e,this._activeDropdown$.next(this._activeDropdown);const l=this._renderManagerService.getRenderById(i.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY),h=this._canvasPopupManagerService.attachPopupToCell(o,r,{componentKey:xt,onClickOutside:()=>{a&&this.hideDropdown()},offset:[0,3],excludeOutside:[l==null?void 0:l.engine.getCanvasElement()].filter(Boolean)},s,d);if(!h)throw new Error("[DataValidationDropdownManagerService]: cannot show dropdown!");const u=new i.DisposableCollection;u.add(h),u.add({dispose:()=>{var p,c;(c=(p=this._activeDropdown)==null?void 0:p.onHide)==null||c.call(p)}}),this._currentPopup=u}hideDropdown(){this._activeDropdown&&(this._currentPopup&&this._currentPopup.dispose(),this._currentPopup=null,this._activeDropdown=null,this._activeDropdown$.next(null))}showDataValidationDropdown(e,a,n,o,r){const s=this._univerInstanceService.getUnit(e,i.UniverInstanceType.UNIVER_SHEET);if(!s)return;const d=s.getSheetBySheetId(a);if(!d)return;const l=this._dataValidationModel.getRuleByLocation(s.getUnitId(),d.getSheetId(),n,o);if(!l)return;const h=this._dataValidatorRegistryService.getValidatorItem(l.type);if(!h||!h.dropdown){this.hideDropdown();return}this.showDropdown({location:{workbook:s,worksheet:d,row:n,col:o,unitId:e,subUnitId:a},componentKey:h.dropdown,onHide:r})}};ge=Ln([fe(0,i.Inject(N.SheetCanvasPopManagerService)),fe(1,i.IUniverInstanceService),fe(2,i.Inject(ee.DataValidatorRegistryService)),fe(3,X.IZenZoneService),fe(4,B.IRenderManagerService),fe(5,i.Inject(E.SheetDataValidationModel)),fe(6,i.Inject(Y.SheetsSelectionsService))],ge);const gt="DataValidationPanel",Ce={id:"data-validation.operation.open-validation-panel",type:i.CommandType.OPERATION,handler(t,e){if(!e)return!1;const{ruleId:a,isAdd:n}=e,o=t.get(ue),r=t.get(ee.DataValidationModel),s=t.get(i.IUniverInstanceService),d=t.get(X.ISidebarService),l=Y.getSheetCommandTarget(s);if(!l)return!1;const{unitId:h,subUnitId:u}=l,p=a?r.getRuleById(h,u,a):void 0;o.open(),o.setActiveRule(p&&{unitId:h,subUnitId:u,rule:p});const c=d.open({header:{title:n?"dataValidation.panel.addTitle":"dataValidation.panel.title"},children:{label:gt},width:312,onClose:()=>o.close()});return o.setCloseDisposable(c),!0}},vt={id:"data-validation.operation.close-validation-panel",type:i.CommandType.OPERATION,handler(t){return t.get(ue).close(),!0}},Ut={id:"data-validation.operation.toggle-validation-panel",type:i.CommandType.OPERATION,handler(t){const e=t.get(i.ICommandService),a=t.get(ue);return a.open(),a.isOpen?e.executeCommand(vt.id):e.executeCommand(Ce.id),!0}},ze={type:i.CommandType.OPERATION,id:"sheet.operation.show-data-validation-dropdown",handler(t,e){if(!e)return!1;const a=t.get(ge),{unitId:n,subUnitId:o,row:r,column:s}=e,d=a.activeDropdown,l=d==null?void 0:d.location;return l&&l.unitId===n&&l.subUnitId===o&&l.row===r&&l.col===s||a.showDataValidationDropdown(n,o,r,s),!0}},Nt={type:i.CommandType.OPERATION,id:"sheet.operation.hide-data-validation-dropdown",handler(t,e){return e?(t.get(ge).hideDropdown(),!0):!1}},Ie="#ECECEC",ft="sheets-data-validation-ui.config",kt={},jn="univer-dv-list-dropdown",An="univer-dv-list-dropdown-title",Fn="univer-dv-list-dropdown-list",xn="univer-dv-list-dropdown-list-container",Un="univer-dv-list-dropdown-selected-icon",Nn="univer-dv-list-dropdown-item-container",kn="univer-dv-list-dropdown-item",Bn="univer-dv-list-dropdown-split",Wn="univer-dv-list-dropdown-edit",pe={dvListDropdown:jn,dvListDropdownTitle:An,dvListDropdownList:Fn,dvListDropdownListContainer:xn,dvListDropdownSelectedIcon:Un,dvListDropdownItemContainer:Nn,dvListDropdownItem:kn,dvListDropdownSplit:Bn,dvListDropdownEdit:Wn},$n=t=>{var w,M;const{value:e,onChange:a,multiple:n,options:o,title:r,onEdit:s,style:d,filter:l,location:h}=t,u=i.useDependency(i.LocaleService),p=i.useDependency(i.IConfigService),c=l==null?void 0:l.toLowerCase(),{row:f,col:g,unitId:v,subUnitId:C}=h,I=o.filter(_=>c?_.label.toLowerCase().includes(c):!0),D=(M=(w=p.getConfig(ft))==null?void 0:w.showEditOnDropdown)!=null?M:!0,S=i.useDependency(N.SheetPermissionInterceptorBaseController),b=R.useMemo(()=>S.permissionCheckWithRanges({workbookTypes:[Y.WorkbookEditablePermission],rangeTypes:[Y.RangeProtectionPermissionEditPoint],worksheetTypes:[Y.WorksheetEditPermission]},[{startColumn:g,startRow:f,endColumn:g,endRow:f}],v,C),[S,g,f,v,C]);return m.jsxs("div",{className:pe.dvListDropdown,style:d,children:[m.jsx("div",{className:pe.dvListDropdownTitle,children:r}),m.jsx("div",{className:pe.dvListDropdownList,children:m.jsx(T.Scrollbar,{children:m.jsx("div",{className:pe.dvListDropdownListContainer,children:I.map((_,y)=>{const A=e.indexOf(_.value)>-1,H=()=>{let L;A?L=new Set(e.filter(x=>x!==_.value)):L=new Set(n?[...e,_.value]:[_.value]);const j=[];o.forEach(x=>{L.has(x.value)&&j.push(x.value)}),a(j)},F=_.label.toLocaleLowerCase().indexOf(c);return m.jsxs("div",{className:pe.dvListDropdownItemContainer,onClick:H,children:[m.jsx("div",{className:pe.dvListDropdownItem,style:{background:_.color||Ie},children:c&&_.label.toLowerCase().includes(c)?m.jsxs(m.Fragment,{children:[m.jsx("span",{children:_.label.substring(0,F)}),m.jsx("span",{style:{fontWeight:"bold"},children:_.label.substring(F,F+c.length)}),m.jsx("span",{children:_.label.substring(F+c.length)})]}):_.label}),m.jsx("div",{className:pe.dvListDropdownSelectedIcon,children:A?m.jsx(Tt,{}):null})]},y)})})},l)}),D&&b?m.jsxs(m.Fragment,{children:[m.jsx("div",{className:pe.dvListDropdownSplit}),m.jsx("div",{className:pe.dvListDropdownEdit,children:m.jsx("a",{onClick:s,children:u.t("dataValidation.list.edit")})})]}):null]})};function Hn(t){var x,U,k,z,K,J;const{location:e,hideFn:a}=t,{worksheet:n,row:o,col:r,unitId:s,subUnitId:d}=e,l=i.useDependency(ee.DataValidationModel),[h,u]=R.useState(""),p=i.useDependency(i.ICommandService),c=i.useDependency(i.LocaleService),[f,g]=R.useState(""),v=i.useDependency(N.IEditorBridgeService),C=i.useDependency(i.IUniverInstanceService),I=R.useMemo(()=>l.ruleChange$.pipe(le.debounceTime(16)),[]);X.useObservable(I);const D=X.RectPopup.useContext(),S=((U=(x=D.current)==null?void 0:x.right)!=null?U:0)-((z=(k=D.current)==null?void 0:k.left)!=null?z:0);if(R.useEffect(()=>{const q=p.onCommandExecuted(Z=>{var te,ie;if(Z.id===tn.RichTextEditingMutation.id){const re=Z.params,{unitId:ne}=re,ae=C.getUnit(ne,i.UniverInstanceType.UNIVER_DOC);if(!ae)return;const O=i.BuildTextUtils.transform.getPlainText((ie=(te=ae.getSnapshot().body)==null?void 0:te.dataStream)!=null?ie:"");u(O)}});return()=>{q.dispose()}},[p,C]),!n)return null;const b=n.getCell(o,r),w=(K=b==null?void 0:b.dataValidation)==null?void 0:K.rule,M=(J=b==null?void 0:b.dataValidation)==null?void 0:J.validator,_=(w==null?void 0:w.renderMode)===i.DataValidationRenderMode.CUSTOM||(w==null?void 0:w.renderMode)===void 0;if(!b||!w||!M||M.id.indexOf(i.DataValidationType.LIST)!==0)return;const y=w.type===i.DataValidationType.LIST_MULTIPLE,A=M.getListWithColor(w,s,d),H=f||E.getDataValidationCellValue(n.getCellRaw(o,r)),F=E.deserializeListOptions(H),L=()=>{p.executeCommand(Ce.id,{ruleId:w.uid}),a()},j=A.map(q=>({label:q.label,value:q.label,color:_||q.color?q.color:"transparent"}));return m.jsx($n,{style:{minWidth:S,maxWidth:Math.max(S,200)},title:y?c.t("dataValidation.listMultiple.dropdown"):c.t("dataValidation.list.dropdown"),value:F,multiple:y,onChange:async q=>{const Z=E.serializeListOptions(q),te={unitId:s,subUnitId:d,range:{startColumn:r,endColumn:r,startRow:o,endRow:o},value:{v:Z,p:null,f:null,si:null}};v.isVisible()&&v.changeVisible({visible:!1,keycode:X.KeyCode.ESC,eventType:B.DeviceInputEventType.Keyboard,unitId:s}),g(Z),y||a(),v.isVisible().visible&&await p.executeCommand(N.SetCellEditVisibleOperation.id,{visible:!1,eventType:B.DeviceInputEventType.Keyboard,unitId:s,keycode:X.KeyCode.ESC}),p.executeCommand(Y.SetRangeValuesCommand.id,te)},options:j,onEdit:L,filter:h,location:e})}const Yn="univer-data-validation-options-button",Xn="univer-data-validation-options-button-icon",Ze={dataValidationOptionsButton:Yn,dataValidationOptionsButtonIcon:Xn};function zn(t){var h;const e=i.useDependency(i.LocaleService),a=i.useDependency(X.ComponentManager),{value:n,onChange:o,extraComponent:r}=t,[s,d]=R.useState(!1),l=r?a.get(r):null;return m.jsxs(m.Fragment,{children:[m.jsxs("div",{className:Ze.dataValidationOptionsButton,onClick:()=>d(!s),children:[e.t("dataValidation.panel.options"),s?m.jsx(At,{className:Ze.dataValidationOptionsButtonIcon}):m.jsx(jt,{className:Ze.dataValidationOptionsButtonIcon})]}),s&&m.jsxs(m.Fragment,{children:[l?m.jsx(l,{value:n,onChange:o}):null,m.jsx(T.FormLayout,{label:e.t("dataValidation.panel.invalid"),children:m.jsxs(T.RadioGroup,{value:`${(h=n.errorStyle)!=null?h:i.DataValidationErrorStyle.WARNING}`,onChange:u=>o({...n,errorStyle:+u}),children:[m.jsx(T.Radio,{value:`${i.DataValidationErrorStyle.WARNING}`,children:e.t("dataValidation.panel.showWarning")}),m.jsx(T.Radio,{value:`${i.DataValidationErrorStyle.STOP}`,children:e.t("dataValidation.panel.rejectInput")})]})}),m.jsx(T.FormLayout,{label:e.t("dataValidation.panel.messageInfo"),children:m.jsx(T.Checkbox,{checked:n.showErrorMessage,onChange:()=>o({...n,showErrorMessage:!n.showErrorMessage}),children:e.t("dataValidation.panel.showInfo")})}),n.showErrorMessage?m.jsx(T.FormLayout,{children:m.jsx(T.Input,{value:n.error,onChange:u=>o({...n,error:u})})}):null]})]})}const Kn="univer-data-validation-detail",Gn="univer-data-validation-detail-form-item",qn="univer-data-validation-detail-buttons",Zn="univer-data-validation-detail-button",De={dataValidationDetail:Kn,dataValidationDetailFormItem:Gn,dataValidationDetailButtons:qn,dataValidationDetailButton:Zn},Jn=t=>i.debounce(async(e,a,n,o)=>{const r=await t.executeCommand(e,a,n);o==null||o(r)},1e3);function Qn(t,e,a){var n,o,r,s;return e?((o=(n=t.getUnit(e))==null?void 0:n.getSheetBySheetName(a))==null?void 0:o.getSheetId())||"":((s=(r=t.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET))==null?void 0:r.getSheetBySheetName(a))==null?void 0:s.getSheetId())||""}function ea(){var ae;const[t,e]=R.useState(0),a=i.useDependency(ue),n=X.useObservable(a.activeRule$,a.activeRule),{unitId:o,subUnitId:r,rule:s}=n||{},d=s.uid,l=i.useDependency(ee.DataValidatorRegistryService),h=i.useDependency(i.IUniverInstanceService),u=i.useDependency(X.ComponentManager),p=i.useDependency(i.ICommandService),c=i.useDependency(ee.DataValidationModel),f=i.useDependency(i.LocaleService),[g,v]=R.useState(s),C=l.getValidatorItem(g.type),[I,D]=R.useState(!1),S=l.getValidatorsByScope(ee.DataValidatorRegistryScope.SHEET),[b,w]=R.useState(()=>g.ranges.map(O=>({unitId:"",sheetId:"",range:O}))),M=R.useMemo(()=>Jn(p),[p]),[_,y]=R.useState(!1),A=R.useRef({}),[H,F]=R.useState(!1),L=i.useDependency(Y.SheetsSelectionsService);if(R.useEffect(()=>()=>{const O=L.getCurrentLastSelection();O&&L.setSelections([O])},[L]),R.useEffect(()=>{p.onCommandExecuted(O=>{(O.id===i.UndoCommand.id||O.id===i.RedoCommand.id)&&setTimeout(()=>{const V=c.getRuleById(o,r,d);e(W=>W+1),V&&(v(V),w(V.ranges.map(W=>({unitId:"",sheetId:"",range:W}))))},20)})},[p,c,d,r,o]),!C)return null;const j=C.operators,x=C.operatorNames,U=g.operator?ee.TWO_FORMULA_OPERATOR_COUNT.includes(g.operator):!1,k=()=>{!g.ranges.length||_||(C.validatorFormula(g,o,r).success?a.setActiveRule(null):D(!0))},z=X.useEvent(O=>{const V=O.split(",").map(lt.deserializeRangeWithSheet).map(G=>{const me=G.sheetName;if(me){const Zt=Qn(h,G.unitId,me);return{...G,sheetId:Zt}}return{...G,sheetId:""}});if(i.isUnitRangesEqual(V,b))return;w(V);const W=V.filter(G=>(!G.unitId||G.unitId===o)&&(!G.sheetId||G.sheetId===r)).map(G=>G.range);if(v({...g,ranges:W}),W.length===0)return;const $={unitId:o,subUnitId:r,ruleId:d,ranges:W};M(E.UpdateSheetDataValidationRangeCommand.id,$)}),K=O=>{if(i.shallowEqual(O,ee.getRuleSetting(g)))return;v({...g,...O});const V={unitId:o,subUnitId:r,ruleId:d,setting:O};M(E.UpdateSheetDataValidationSettingCommand.id,V,void 0)},J=async()=>{await p.executeCommand(E.RemoveSheetDataValidationCommand.id,{ruleId:d,unitId:o,subUnitId:r}),a.setActiveRule(null)},q={type:g.type,operator:g.operator,formula1:g.formula1,formula2:g.formula2,allowBlank:g.allowBlank},Z=O=>{const V=l.getValidatorItem(O);if(!V)return;const W=V.operators,$=c.getRuleById(o,r,d),G=O===($==null?void 0:$.type)||O.includes("list")&&($!=null&&$.type.includes("list"))?{...$,type:O}:{...g,type:O,operator:W[0],formula1:void 0,formula2:void 0};v(G),p.executeCommand(E.UpdateSheetDataValidationSettingCommand.id,{unitId:o,subUnitId:r,ruleId:g.uid,setting:ee.getRuleSetting(G)})},te=u.get(C.formulaInput),ie=R.useMemo(()=>b.map(O=>lt.serializeRange(O.range)).join(","),[]),re=ee.getRuleOptions(g),ne=O=>{i.shallowEqual(O,ee.getRuleOptions(g))||(v({...g,...O}),M(E.UpdateSheetDataValidationOptionsCommand.id,{unitId:o,subUnitId:r,ruleId:d,options:O}))};return X.useSidebarClick(O=>{var W;const V=(W=A.current)==null?void 0:W.handleOutClick;V&&V(O,()=>F(!1))}),m.jsxs("div",{className:De.dataValidationDetail,children:[m.jsx(T.FormLayout,{label:f.t("dataValidation.panel.range"),error:!g.ranges.length||_?f.t("dataValidation.panel.rangeError"):"",children:m.jsx(pt.RangeSelector,{unitId:o,subUnitId:r,initValue:ie,onChange:z,onFocus:()=>F(!0),isFocus:H,actions:A.current,onVerify:O=>y(!O)})}),m.jsx(T.FormLayout,{label:f.t("dataValidation.panel.type"),children:m.jsx(T.Select,{options:S==null?void 0:S.map(O=>({label:f.t(O.title),value:O.id})),value:g.type,onChange:Z,className:De.dataValidationDetailFormItem})}),j!=null&&j.length?m.jsx(T.FormLayout,{label:f.t("dataValidation.panel.operator"),children:m.jsx(T.Select,{options:j.map((O,V)=>({value:`${O}`,label:x[V]})),value:`${g.operator}`,onChange:O=>{K({...q,operator:O})},className:De.dataValidationDetailFormItem})}):null,te?m.jsx(te,{isTwoFormula:U,value:{formula1:g.formula1,formula2:g.formula2},onChange:O=>{K({...q,...O})},showError:I,validResult:C.validatorFormula(g,o,r),unitId:o,subUnitId:r,ruleId:d},t+g.type):null,m.jsx(T.FormLayout,{children:m.jsx(T.Checkbox,{checked:(ae=g.allowBlank)!=null?ae:!0,onChange:()=>{var O;return K({...q,allowBlank:!((O=g.allowBlank)==null||O)})},children:f.t("dataValidation.panel.allowBlank")})}),m.jsx(zn,{value:re,onChange:ne,extraComponent:C.optionsInput}),m.jsxs("div",{className:De.dataValidationDetailButtons,children:[m.jsx(T.Button,{className:De.dataValidationDetailButton,onClick:J,children:f.t("dataValidation.panel.removeRule")}),m.jsx(T.Button,{className:De.dataValidationDetailButton,type:"primary",onClick:k,children:f.t("dataValidation.panel.done")})]})]})}const ta="univer-data-validation-item-container",na="univer-data-validation-item-title",aa="univer-data-validation-item-content",oa="univer-data-validation-item-icon",Le={dataValidationItemContainer:ta,dataValidationItemTitle:na,dataValidationItemContent:aa,dataValidationItemIcon:oa},ia=t=>{const{rule:e,onClick:a,unitId:n,subUnitId:o,disable:r}=t,s=i.useDependency(ee.DataValidatorRegistryService),d=i.useDependency(i.ICommandService),l=i.useDependency(N.IMarkSelectionService),h=s.getValidatorItem(e.type),u=R.useRef(),[p,c]=R.useState(!1),f=g=>{d.executeCommand(E.RemoveSheetDataValidationCommand.id,{ruleId:e.uid,unitId:n,subUnitId:o}),g.stopPropagation()};return R.useEffect(()=>()=>{var g;u.current&&((g=u.current)==null||g.forEach(v=>{v&&l.removeShape(v)}))},[l]),m.jsxs("div",{className:Le.dataValidationItemContainer,onClick:a,onMouseEnter:()=>{r||(c(!0),u.current=e.ranges.map(g=>l.addShape({range:g,style:{fill:"rgba(73, 184, 17, 0.05)",strokeWidth:1,stroke:"#49B811",widgets:{}},primary:null})))},onMouseLeave:()=>{var g;c(!1),(g=u.current)==null||g.forEach(v=>{v&&l.removeShape(v)}),u.current=void 0},children:[m.jsx("div",{className:Le.dataValidationItemTitle,children:h==null?void 0:h.generateRuleName(e)}),m.jsx("div",{className:Le.dataValidationItemContent,children:e.ranges.map(g=>lt.serializeRange(g)).join(",")}),p?m.jsx("div",{className:Le.dataValidationItemIcon,onClick:f,children:m.jsx(mt,{})}):null]})},ra="univer-data-validation-list",sa="univer-data-validation-list-buttons",la="univer-data-validation-list-button",je={dataValidationList:ra,dataValidationListButtons:sa,dataValidationListButton:la};function da(){const t=i.useDependency(i.IUniverInstanceService),e=X.useObservable(()=>t.getCurrentTypeOfUnit$(i.UniverInstanceType.UNIVER_SHEET),void 0,void 0,[]);return e?m.jsx(ca,{workbook:e}):null}function ca(t){const e=i.useDependency(E.SheetDataValidationModel),a=i.useDependency(i.IUniverInstanceService),n=i.useDependency(i.ICommandService),o=i.useDependency(i.Injector),r=i.useDependency(ue),s=i.useDependency(i.LocaleService),[d,l]=R.useState([]),{workbook:h}=t,u=X.useObservable(h.activeSheet$,void 0,!0),p=h.getUnitId(),c=u==null?void 0:u.getSheetId();R.useEffect(()=>{l(e.getRules(p,c));const D=e.ruleChange$.subscribe(S=>{S.unitId===p&&S.subUnitId===c&&l(e.getRules(p,c))});return()=>{D.unsubscribe()}},[p,c,e]);const f=async()=>{const D=E.createDefaultNewRule(o),S={unitId:p,subUnitId:c,rule:D};await n.executeCommand(E.AddSheetDataValidationCommand.id,S),r.setActiveRule({unitId:p,subUnitId:c,rule:D})},g=()=>{n.executeCommand(E.RemoveSheetAllDataValidationCommand.id,{unitId:p,subUnitId:c})},C=(D=>{const S=a.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET),b=S.getActiveSheet(),w=S.getUnitId(),M=b.getSheetId();return D.map(y=>Y.checkRangesEditablePermission(o,w,M,y.ranges)?{...y}:{...y,disable:!0})})(d),I=C==null?void 0:C.some(D=>D.disable);return m.jsxs("div",{className:je.dataValidationList,children:[C==null?void 0:C.map(D=>{var S;return m.jsx(ia,{unitId:p,subUnitId:c,onClick:()=>{D.disable||r.setActiveRule({unitId:p,subUnitId:c,rule:D})},rule:D,disable:(S=D.disable)!=null?S:!1},D.uid)}),m.jsxs("div",{className:je.dataValidationListButtons,children:[d.length&&!I?m.jsx(T.Button,{className:je.dataValidationListButton,onClick:g,children:s.t("dataValidation.panel.removeAll")}):null,m.jsx(T.Button,{className:je.dataValidationListButton,type:"primary",onClick:f,children:s.t("dataValidation.panel.add")})]})]})}const ua=()=>{const t=i.useDependency(ue),e=X.useObservable(t.activeRule$,t.activeRule);return e?m.jsx(ea,{},e.rule.uid):m.jsx(da,{})},Ke="data-validation.list.dropdown",St="data-validation.date.dropdown",Ge={type:i.CommandType.COMMAND,id:"data-validation.command.addRuleAndOpen",handler(t){const e=t.get(i.IUniverInstanceService),a=Y.getSheetCommandTarget(e);if(!a)return!1;const{workbook:n,worksheet:o}=a,r=E.createDefaultNewRule(t),s=t.get(i.ICommandService),d=n.getUnitId(),l=o.getSheetId(),h={rule:r,unitId:d,subUnitId:l};return s.syncExecuteCommand(E.AddSheetDataValidationCommand.id,h)?(s.syncExecuteCommand(Ce.id,{ruleId:r.uid,isAdd:!0}),!0):!1}};var ha=Object.defineProperty,pa=Object.getOwnPropertyDescriptor,ma=(t,e,a,n)=>{for(var o=n>1?void 0:n?pa(e,a):e,r=t.length-1,s;r>=0;r--)(s=t[r])&&(o=(n?s(e,a,o):s(o))||o);return n&&o&&ha(e,a,o),o},Oe=(t,e)=>(a,n)=>e(a,n,t);const Ae="SHEET_DATA_VALIDATION_ALERT";let Pe=class extends i.Disposable{constructor(t,e,a,n,o){super(),this._hoverManagerService=t,this._cellAlertManagerService=e,this._univerInstanceService=a,this._localeService=n,this._zenZoneService=o,this._init()}_init(){this._initCellAlertPopup(),this._initZenService()}_initCellAlertPopup(){this.disposeWithMe(this._hoverManagerService.currentCell$.pipe(le.debounceTime(100)).subscribe(t=>{var e,a;if(t){const o=this._univerInstanceService.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET).getActiveSheet();if(!o)return;const r=o.getCell(t.location.row,t.location.col);if(((e=r==null?void 0:r.dataValidation)==null?void 0:e.validStatus)===i.DataValidationStatus.INVALID){const s=this._cellAlertManagerService.currentAlert.get(Ae),d=(a=s==null?void 0:s.alert)==null?void 0:a.location;if(d&&d.row===t.location.row&&d.col===t.location.col&&d.subUnitId===t.location.subUnitId&&d.unitId===t.location.unitId)return;const l=r.dataValidation.validator,h=r.dataValidation.rule;if(!l)return;this._cellAlertManagerService.showAlert({type:N.CellAlertType.ERROR,title:this._localeService.t("dataValidation.error.title"),message:l==null?void 0:l.getRuleFinalError(h,t.location),location:t.location,width:200,height:74,key:Ae});return}}this._cellAlertManagerService.removeAlert(Ae)}))}_initZenService(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(t=>{t&&this._cellAlertManagerService.removeAlert(Ae)}))}};Pe=ma([Oe(0,i.Inject(N.HoverManagerService)),Oe(1,i.Inject(N.CellAlertManagerService)),Oe(2,i.IUniverInstanceService),Oe(3,i.Inject(i.LocaleService)),Oe(4,X.IZenZoneService)],Pe);var ga=Object.defineProperty,va=Object.getOwnPropertyDescriptor,fa=(t,e,a,n)=>{for(var o=n>1?void 0:n?va(e,a):e,r=t.length-1,s;r>=0;r--)(s=t[r])&&(o=(n?s(e,a,o):s(o))||o);return n&&o&&ga(e,a,o),o},Je=(t,e)=>(a,n)=>e(a,n,t);let Ve=class extends i.Disposable{constructor(t,e,a){super(),this._autoFillService=t,this._dataValidationModel=e,this._injector=a,this._initAutoFill()}_initAutoFill(){const t=()=>({redos:[],undos:[]}),e=(o,r)=>{const{source:s,target:d,unitId:l,subUnitId:h}=o,u=this._dataValidationModel.getRuleObjectMatrix(l,h).clone(),p=N.virtualizeDiscreteRanges([s,d]),[c,f]=p.ranges,{mapFunc:g}=p,v={row:c.startRow,col:c.startColumn},C=N.getAutoFillRepeatRange(c,f),I=new i.ObjectMatrix,D=new Set;C.forEach(_=>{const y=_.repeatStartCell,A=_.relativeRange,H={startRow:v.row,startColumn:v.col,endColumn:v.col,endRow:v.row},F={startRow:y.row,startColumn:y.col,endColumn:y.col,endRow:y.row};i.Range.foreach(A,(L,j)=>{const x=i.Rectangle.getPositionRange({startRow:L,startColumn:j,endColumn:j,endRow:L},H),{row:U,col:k}=g(x.startRow,x.startColumn),z=this._dataValidationModel.getRuleIdByLocation(l,h,U,k);if(z){const K=i.Rectangle.getPositionRange({startRow:L,startColumn:j,endColumn:j,endRow:L},F),{row:J,col:q}=g(K.startRow,K.startColumn);I.setValue(J,q,z),D.add(z)}})});const S=Array.from(D).map(_=>({id:_,ranges:i.queryObjectMatrix(I,y=>y===_)}));u.addRangeRules(S);const b=u.diff(this._dataValidationModel.getRules(l,h)),{redoMutations:w,undoMutations:M}=E.getDataValidationDiffMutations(l,h,b,this._injector,"patched",r===N.APPLY_TYPE.ONLY_FORMAT);return{undos:M,redos:w}},a=[i.DataValidationType.CHECKBOX],n={id:E.DATA_VALIDATION_PLUGIN_NAME,onBeforeFillData:o=>{const{source:r,unitId:s,subUnitId:d}=o;for(const l of r.rows)for(const h of r.cols){const u=this._dataValidationModel.getRuleByLocation(s,d,l,h);if(u&&a.indexOf(u.type)>-1){this._autoFillService.setDisableApplyType(N.APPLY_TYPE.SERIES,!0);return}}},onFillData:(o,r,s)=>s===N.APPLY_TYPE.COPY||s===N.APPLY_TYPE.ONLY_FORMAT||s===N.APPLY_TYPE.SERIES?e(o,s):t(),onAfterFillData:()=>{}};this.disposeWithMe(this._autoFillService.addHook(n))}};Ve=fa([Je(0,N.IAutoFillService),Je(1,i.Inject(E.SheetDataValidationModel)),Je(2,i.Inject(i.Injector))],Ve);var Sa=Object.defineProperty,_a=Object.getOwnPropertyDescriptor,Ia=(t,e,a,n)=>{for(var o=n>1?void 0:n?_a(e,a):e,r=t.length-1,s;r>=0;r--)(s=t[r])&&(o=(n?s(e,a,o):s(o))||o);return n&&o&&Sa(e,a,o),o},Qe=(t,e)=>(a,n)=>e(a,n,t);let ye=class extends i.Disposable{constructor(e,a,n){super();P(this,"_copyInfo");this._sheetClipboardService=e,this._sheetDataValidationModel=a,this._injector=n,this._initCopyPaste()}_initCopyPaste(){this._sheetClipboardService.addClipboardHook({id:E.DATA_VALIDATION_PLUGIN_NAME,onBeforeCopy:(e,a,n)=>this._collect(e,a,n),onPasteCells:(e,a,n,o)=>{const{copyType:r=N.COPY_TYPE.COPY,pasteType:s}=o,{range:d}=e||{},{range:l,unitId:h,subUnitId:u}=a;return this._generateMutations(l,{copyType:r,pasteType:s,copyRange:d,unitId:h,subUnitId:u})}})}_collect(e,a,n){const o=new i.ObjectMatrix;this._copyInfo={unitId:e,subUnitId:a,matrix:o};const r=this._injector.invoke(l=>N.rangeToDiscreteRange(n,l,e,a));if(!r)return;const{rows:s,cols:d}=r;s.forEach((l,h)=>{d.forEach((u,p)=>{const c=this._sheetDataValidationModel.getRuleIdByLocation(e,a,l,u);o.setValue(h,p,c!=null?c:"")})})}_generateMutations(e,a){if(!this._copyInfo)return{redos:[],undos:[]};if(a.copyType===N.COPY_TYPE.CUT)return this._copyInfo=null,{redos:[],undos:[]};if(!this._copyInfo||!this._copyInfo.matrix.getSizeOf()||!a.copyRange)return{redos:[],undos:[]};if([N.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_COL_WIDTH,N.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_VALUE,N.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMAT,N.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMULA].includes(a.pasteType))return{redos:[],undos:[]};const{unitId:n,subUnitId:o}=this._copyInfo;if(a.unitId!==n||o!==a.subUnitId){const r=this._sheetDataValidationModel.getRuleObjectMatrix(a.unitId,a.subUnitId).clone(),s=new i.ObjectMatrix,d=new Set,{ranges:[l,h],mapFunc:u}=N.virtualizeDiscreteRanges([a.copyRange,e]),p=N.getRepeatRange(l,h,!0),c=new Map;p.forEach(({startRange:C})=>{var I;(I=this._copyInfo)==null||I.matrix.forValue((D,S,b)=>{const w=i.Rectangle.getPositionRange({startRow:D,endRow:D,startColumn:S,endColumn:S},C),M=`${o}-${b}`,_=this._sheetDataValidationModel.getRuleById(n,o,b);!this._sheetDataValidationModel.getRuleById(a.unitId,a.subUnitId,M)&&_&&c.set(M,{..._,uid:M});const{row:y,col:A}=u(w.startRow,w.startColumn);d.add(M),s.setValue(y,A,M)})});const f=Array.from(d).map(C=>({id:C,ranges:i.queryObjectMatrix(s,I=>I===C)}));r.addRangeRules(f);const{redoMutations:g,undoMutations:v}=E.getDataValidationDiffMutations(a.unitId,a.subUnitId,r.diffWithAddition(this._sheetDataValidationModel.getRules(a.unitId,a.subUnitId),c.values()),this._injector,"patched",!1);return{redos:g,undos:v}}else{const r=this._sheetDataValidationModel.getRuleObjectMatrix(n,o).clone(),s=new i.ObjectMatrix,d=new Set,{ranges:[l,h],mapFunc:u}=N.virtualizeDiscreteRanges([a.copyRange,e]);N.getRepeatRange(l,h,!0).forEach(({startRange:v})=>{var C;(C=this._copyInfo)==null||C.matrix.forValue((I,D,S)=>{const b=i.Rectangle.getPositionRange({startRow:I,endRow:I,startColumn:D,endColumn:D},v),{row:w,col:M}=u(b.startRow,b.startColumn);s.setValue(w,M,S),d.add(S)})});const c=Array.from(d).map(v=>({id:v,ranges:i.queryObjectMatrix(s,C=>C===v)}));r.addRangeRules(c);const{redoMutations:f,undoMutations:g}=E.getDataValidationDiffMutations(n,o,r.diff(this._sheetDataValidationModel.getRules(n,o)),this._injector,"patched",!1);return{redos:f,undos:g}}}};ye=Ia([Qe(0,N.ISheetClipboardService),Qe(1,i.Inject(E.SheetDataValidationModel)),Qe(2,i.Inject(i.Injector))],ye);var Ca=Object.defineProperty,Da=Object.getOwnPropertyDescriptor,Ra=(t,e,a,n)=>{for(var o=n>1?void 0:n?Da(e,a):e,r=t.length-1,s;r>=0;r--)(s=t[r])&&(o=(n?s(e,a,o):s(o))||o);return n&&o&&Ca(e,a,o),o},et=(t,e)=>(a,n)=>e(a,n,t);let we=class extends i.Disposable{constructor(t,e,a){super(),this._localeService=t,this._commandService=e,this._sheetPermissionInterceptorBaseController=a,this._commandExecutedListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.beforeCommandExecuted(t=>{t.id===E.AddSheetDataValidationCommand.id&&(this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[Y.WorkbookEditablePermission],rangeTypes:[Y.RangeProtectionPermissionEditPoint],worksheetTypes:[Y.WorksheetEditPermission,Y.WorksheetSetCellStylePermission]})||this._sheetPermissionInterceptorBaseController.haveNotPermissionHandle(this._localeService.t("permission.dialog.setStyleErr"))),t.id===E.UpdateSheetDataValidationRangeCommand.id&&(this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[Y.WorkbookEditablePermission],rangeTypes:[Y.RangeProtectionPermissionEditPoint],worksheetTypes:[Y.WorksheetEditPermission,Y.WorksheetSetCellStylePermission]},t.params.ranges)||this._sheetPermissionInterceptorBaseController.haveNotPermissionHandle(this._localeService.t("permission.dialog.setStyleErr")))}))}};we=Ra([et(0,i.Inject(i.LocaleService)),et(1,i.ICommandService),et(2,i.Inject(N.SheetPermissionInterceptorBaseController))],we);const Bt="data-validation-single",Wt="sheet.menu.data-validation";function Va(t){return{id:Wt,type:X.MenuItemType.SUBITEMS,icon:Bt,tooltip:"dataValidation.title",hidden$:X.getMenuHiddenObservable(t,i.UniverInstanceType.UNIVER_SHEET),disabled$:N.getCurrentRangeDisable$(t,{workbookTypes:[Y.WorkbookEditablePermission],worksheetTypes:[Y.WorksheetSetCellStylePermission,Y.WorksheetEditPermission],rangeTypes:[Y.RangeProtectionPermissionEditPoint]})}}function ya(t){return{id:Ce.id,title:"dataValidation.panel.title",type:X.MenuItemType.BUTTON}}function wa(t){return{id:Ge.id,title:"dataValidation.panel.add",type:X.MenuItemType.BUTTON}}const Ea={[X.RibbonStartGroup.FORMULAS_INSERT]:{[Wt]:{order:9,menuItemFactory:Va,[Ce.id]:{order:0,menuItemFactory:ya},[Ge.id]:{order:1,menuItemFactory:wa}}}};var ba=Object.defineProperty,Ma=Object.getOwnPropertyDescriptor,$t=(t,e,a,n)=>{for(var o=n>1?void 0:n?Ma(e,a):e,r=t.length-1,s;r>=0;r--)(s=t[r])&&(o=(n?s(e,a,o):s(o))||o);return n&&o&&ba(e,a,o),o},Q=(t,e)=>(a,n)=>e(a,n,t);const Ht={tr:{size:6,color:"#fe4b4b"}};let Ee=class extends i.RxDisposable{constructor(t,e,a,n,o,r,s,d,l,h,u){super(),this._commandService=t,this._menuManagerService=e,this._renderManagerService=a,this._univerInstanceService=n,this._autoHeightController=o,this._dropdownManagerService=r,this._sheetDataValidationModel=s,this._dataValidatorRegistryService=d,this._sheetInterceptorService=l,this._dataValidationCacheService=h,this._editorBridgeService=u,this._initMenu(),this._initDropdown(),this._initViewModelIntercept(),this._initAutoHeight()}_initMenu(){this._menuManagerService.mergeMenu(Ea)}_initDropdown(){this._editorBridgeService&&this.disposeWithMe(this._editorBridgeService.visible$.subscribe(t=>{var a;if(!t.visible){((a=this._dropdownManagerService.activeDropdown)==null?void 0:a.trigger)==="editor-bridge"&&this._dropdownManagerService.hideDropdown();return}const e=this._editorBridgeService.getEditCellState();if(e){const{unitId:n,sheetId:o,row:r,column:s}=e,d=this._univerInstanceService.getUniverSheetInstance(n);if(!d)return;const l=this._sheetDataValidationModel.getRuleByLocation(n,o,r,s);if(!l)return;const h=this._dataValidatorRegistryService.getValidatorItem(l.type);if(!(h!=null&&h.dropdown))return;const u=d.getActiveSheet();if(!u)return;const p=this._dropdownManagerService.activeDropdown,c=p==null?void 0:p.location;if(c&&c.unitId===n&&c.subUnitId===o&&c.row===r&&c.col===s)return;this._dropdownManagerService.showDropdown({location:{unitId:n,subUnitId:o,row:r,col:s,workbook:d,worksheet:u},componentKey:h.dropdown,onHide:()=>{},trigger:"editor-bridge"},!1)}}))}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(Y.INTERCEPTOR_POINT.CELL_CONTENT,{effect:i.InterceptorEffectEnum.Style,priority:Y.InterceptCellContentPriority.DATA_VALIDATION,handler:(t,e,a)=>{var I,D,S,b,w,M;const{row:n,col:o,unitId:r,subUnitId:s,workbook:d,worksheet:l}=e,h=this._sheetDataValidationModel.getRuleIdByLocation(r,s,n,o);if(!h)return a(t);const u=this._sheetDataValidationModel.getRuleById(r,s,h);if(!u)return a(t);const p=(D=(I=this._dataValidationCacheService.getValue(r,s,n,o))==null?void 0:I.status)!=null?D:i.DataValidationStatus.VALID,c=this._dataValidatorRegistryService.getValidatorItem(u.type),f=e.rawData;let g;const v={get value(){var _;return g!==void 0||(g=(_=E.getCellValueOrigin(f))!=null?_:null),g}},C={get value(){var _;return`${(_=v.value)!=null?_:""}`}};return a({...t,dataValidation:{ruleId:h,validStatus:p,rule:u,validator:c},markers:{...t==null?void 0:t.markers,...p===i.DataValidationStatus.INVALID?Ht:null},customRender:[...(S=t==null?void 0:t.customRender)!=null?S:[],...c!=null&&c.canvasRender?[c.canvasRender]:[]],fontRenderExtension:{...t==null?void 0:t.fontRenderExtension,isSkip:((b=t==null?void 0:t.fontRenderExtension)==null?void 0:b.isSkip)||((w=c==null?void 0:c.skipDefaultFontRender)==null?void 0:w.call(c,u,v.value,e))},interceptorStyle:{...t==null?void 0:t.interceptorStyle,...c==null?void 0:c.getExtraStyle(u,C.value,{get style(){const _=d.getStyles();return(typeof(t==null?void 0:t.s)=="string"?_.get(t==null?void 0:t.s):t==null?void 0:t.s)||{}}},n,o)},interceptorAutoHeight:()=>{var H,F,L,j,x,U;const _=(F=(H=this._renderManagerService.getRenderById(r))==null?void 0:H.with(N.SheetSkeletonManagerService).getWorksheetSkeleton(s))==null?void 0:F.skeleton;if(!_)return;const y=_.worksheet.getMergedCell(n,o),A={data:{...t,dataValidation:{ruleId:h,validStatus:p,rule:u,validator:c}},style:_.getsStyles().getStyleByCell(t),primaryWithCoord:_.getCellWithCoordByIndex((L=y==null?void 0:y.startRow)!=null?L:n,(j=y==null?void 0:y.startColumn)!=null?j:o),unitId:r,subUnitId:s,row:n,col:o,workbook:d,worksheet:l};return(U=(x=c==null?void 0:c.canvasRender)==null?void 0:x.calcCellAutoHeight)==null?void 0:U.call(x,A)},interceptorAutoWidth:()=>{var H,F,L,j,x,U;const _=(F=(H=this._renderManagerService.getRenderById(r))==null?void 0:H.with(N.SheetSkeletonManagerService).getWorksheetSkeleton(s))==null?void 0:F.skeleton;if(!_)return;const y=_.worksheet.getMergedCell(n,o),A={data:{...t,dataValidation:{ruleId:h,validStatus:p,rule:u,validator:c}},style:_.getsStyles().getStyleByCell(t),primaryWithCoord:_.getCellWithCoordByIndex((L=y==null?void 0:y.startRow)!=null?L:n,(j=y==null?void 0:y.startColumn)!=null?j:o),unitId:r,subUnitId:s,row:n,col:o,workbook:d,worksheet:l};return(U=(x=c==null?void 0:c.canvasRender)==null?void 0:x.calcCellAutoWidth)==null?void 0:U.call(x,A)},coverable:((M=t==null?void 0:t.coverable)!=null?M:!0)&&!(u.type===i.DataValidationType.LIST||u.type===i.DataValidationType.LIST_MULTIPLE)})}}))}_initAutoHeight(){this._sheetDataValidationModel.ruleChange$.pipe(le.filter(t=>t.source==="command"),le.bufferTime(16)).subscribe(t=>{const e=[];if(t.forEach(a=>{var n;(n=a.rule)!=null&&n.ranges&&e.push(...a.rule.ranges)}),e.length){const a=this._autoHeightController.getUndoRedoParamsOfAutoHeight(e);i.sequenceExecute(a.redos,this._commandService)}})}};Ee=$t([Q(0,i.ICommandService),Q(1,X.IMenuManagerService),Q(2,B.IRenderManagerService),Q(3,i.IUniverInstanceService),Q(4,i.Inject(N.AutoHeightController)),Q(5,i.Inject(ge)),Q(6,i.Inject(E.SheetDataValidationModel)),Q(7,i.Inject(ee.DataValidatorRegistryService)),Q(8,i.Inject(Y.SheetInterceptorService)),Q(9,i.Inject(E.DataValidationCacheService)),Q(10,i.Optional(N.IEditorBridgeService))],Ee);let Dt=class extends i.RxDisposable{constructor(t,e,a,n,o,r,s){super(),this._commandService=t,this._renderManagerService=e,this._autoHeightController=a,this._dataValidatorRegistryService=n,this._sheetInterceptorService=o,this._sheetDataValidationModel=r,this._dataValidationCacheService=s,this._initViewModelIntercept(),this._initAutoHeight()}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(Y.INTERCEPTOR_POINT.CELL_CONTENT,{effect:i.InterceptorEffectEnum.Style,priority:Y.InterceptCellContentPriority.DATA_VALIDATION,handler:(t,e,a)=>{var C,I,D,S,b,w;const{row:n,col:o,unitId:r,subUnitId:s,workbook:d,worksheet:l}=e,h=this._sheetDataValidationModel.getRuleIdByLocation(r,s,n,o);if(!h)return a(t);const u=this._sheetDataValidationModel.getRuleById(r,s,h);if(!u)return a(t);const p=(I=(C=this._dataValidationCacheService.getValue(r,s,n,o))==null?void 0:C.status)!=null?I:i.DataValidationStatus.VALID,c=this._dataValidatorRegistryService.getValidatorItem(u.type),f=l.getCellRaw(n,o),g=E.getCellValueOrigin(f),v=`${g!=null?g:""}`;return a({...t,dataValidation:{ruleId:h,validStatus:p,rule:u,validator:c},markers:{...t==null?void 0:t.markers,...p===i.DataValidationStatus.INVALID?Ht:null},customRender:[...(D=t==null?void 0:t.customRender)!=null?D:[],...c!=null&&c.canvasRender?[c.canvasRender]:[]],fontRenderExtension:{...t==null?void 0:t.fontRenderExtension,isSkip:((S=t==null?void 0:t.fontRenderExtension)==null?void 0:S.isSkip)||((b=c==null?void 0:c.skipDefaultFontRender)==null?void 0:b.call(c,u,g,e))},interceptorStyle:{...t==null?void 0:t.interceptorStyle,...c==null?void 0:c.getExtraStyle(u,v,{get style(){const M=d.getStyles();return(typeof(t==null?void 0:t.s)=="string"?M.get(t==null?void 0:t.s):t==null?void 0:t.s)||{}}},n,o)},interceptorAutoHeight:()=>{var A,H,F,L,j,x;const M=(H=(A=this._renderManagerService.getRenderById(r))==null?void 0:A.with(N.SheetSkeletonManagerService).getWorksheetSkeleton(s))==null?void 0:H.skeleton;if(!M)return;const _=M.worksheet.getMergedCell(n,o),y={data:{...t,dataValidation:{ruleId:h,validStatus:p,rule:u,validator:c}},style:M.getsStyles().getStyleByCell(t),primaryWithCoord:M.getCellWithCoordByIndex((F=_==null?void 0:_.startRow)!=null?F:n,(L=_==null?void 0:_.startColumn)!=null?L:o),unitId:r,subUnitId:s,row:n,col:o,workbook:d,worksheet:l};return(x=(j=c==null?void 0:c.canvasRender)==null?void 0:j.calcCellAutoHeight)==null?void 0:x.call(j,y)},coverable:((w=t==null?void 0:t.coverable)!=null?w:!0)&&!(u.type===i.DataValidationType.LIST||u.type===i.DataValidationType.LIST_MULTIPLE)})}}))}_initAutoHeight(){this._sheetDataValidationModel.ruleChange$.pipe(le.filter(t=>t.source==="command"),le.bufferTime(16)).subscribe(t=>{const e=[];if(t.forEach(a=>{var n;(n=a.rule)!=null&&n.ranges&&e.push(...a.rule.ranges)}),e.length){const a=this._autoHeightController.getUndoRedoParamsOfAutoHeight(e);i.sequenceExecute(a.redos,this._commandService)}})}};Dt=$t([Q(0,i.ICommandService),Q(1,B.IRenderManagerService),Q(2,i.Inject(N.AutoHeightController)),Q(3,i.Inject(ee.DataValidatorRegistryService)),Q(4,i.Inject(Y.SheetInterceptorService)),Q(5,i.Inject(E.SheetDataValidationModel)),Q(6,i.Inject(E.DataValidationCacheService))],Dt);var Oa=Object.defineProperty,Ta=Object.getOwnPropertyDescriptor,Pa=(t,e,a,n)=>{for(var o=n>1?void 0:n?Ta(e,a):e,r=t.length-1,s;r>=0;r--)(s=t[r])&&(o=(n?s(e,a,o):s(o))||o);return n&&o&&Oa(e,a,o),o},Rt=(t,e)=>(a,n)=>e(a,n,t);let We=class extends i.Disposable{constructor(t,e,a){super(),this._context=t,this._sheetDataValidationModel=e,this._sheetSkeletonManagerService=a,this._initSkeletonChange()}_initSkeletonChange(){const t=e=>{var n;if(!e.length)return;const a=new Set;e.forEach(o=>{a.add(o.subUnitId)}),a.forEach(o=>{var r;(r=this._sheetSkeletonManagerService.getWorksheetSkeleton(o))==null||r.skeleton.makeDirty(!0)}),(n=this._context.mainComponent)==null||n.makeForceDirty()};this.disposeWithMe(this._sheetDataValidationModel.validStatusChange$.pipe(i.bufferDebounceTime(16)).subscribe(t))}};We=Pa([Rt(1,i.Inject(E.SheetDataValidationModel)),Rt(2,i.Inject(N.SheetSkeletonManagerService))],We);const La="univer-data-validation-formula",ja="univer-data-validation-formula-and",Aa="univer-data-validation-formula-list-item",Fa="univer-data-validation-formula-list-item-icon",xa="univer-data-validation-formula-list-item-drag",Ua="univer-data-validation-formula-list-add",Na="univer-data-validation-formula-color-select",ka="univer-data-validation-formula-color-select-panel",Ba="univer-data-validation-formula-color-item",oe={dataValidationFormula:La,dataValidationFormulaAnd:ja,dataValidationFormulaListItem:Aa,dataValidationFormulaListItemIcon:Fa,dataValidationFormulaListItemDrag:xa,dataValidationFormulaListAdd:Ua,dataValidationFormulaColorSelect:Na,dataValidationFormulaColorSelectPanel:ka,dataValidationFormulaColorItem:Ba},Wa=t=>{const{isTwoFormula:e=!1,value:a,onChange:n,showError:o,validResult:r}=t,s=i.useDependency(i.LocaleService),d=o?r==null?void 0:r.formula1:"",l=o?r==null?void 0:r.formula2:"";return e?m.jsxs(m.Fragment,{children:[m.jsx(T.FormLayout,{error:d,children:m.jsx(T.Input,{className:oe.dataValidationFormula,placeholder:s.t("dataValidation.panel.formulaPlaceholder"),value:a==null?void 0:a.formula1,onChange:h=>{n==null||n({...a,formula1:h})}})}),m.jsx("div",{className:oe.dataValidationFormulaAnd,children:s.t("dataValidation.panel.formulaAnd")}),m.jsx(T.FormLayout,{error:l,children:m.jsx(T.Input,{className:oe.dataValidationFormula,placeholder:s.t("dataValidation.panel.formulaPlaceholder"),value:a==null?void 0:a.formula2,onChange:h=>{n==null||n({...a,formula2:h})}})})]}):m.jsx(T.FormLayout,{error:d,children:m.jsx(T.Input,{className:oe.dataValidationFormula,placeholder:s.t("dataValidation.panel.formulaPlaceholder"),value:a==null?void 0:a.formula1,onChange:h=>{n==null||n({formula1:h})}})})};function $a(t){const{value:e,onChange:a,showError:n,validResult:o}=t,r=i.useDependency(i.LocaleService),s=n?o==null?void 0:o.formula1:"",d=n?o==null?void 0:o.formula2:"",[l,h]=R.useState(!((e==null?void 0:e.formula1)===void 0&&(e==null?void 0:e.formula2)===void 0));return m.jsxs(m.Fragment,{children:[m.jsx(T.FormLayout,{children:m.jsx(T.Checkbox,{checked:l,onChange:u=>{u?h(!0):(h(!1),a==null||a({...e,formula1:void 0,formula2:void 0}))},children:r.t("dataValidation.checkbox.tips")})}),l?m.jsx(T.FormLayout,{label:r.t("dataValidation.checkbox.checked"),error:s,children:m.jsx(T.Input,{className:oe.dataValidationFormula,placeholder:r.t("dataValidation.panel.valuePlaceholder"),value:e==null?void 0:e.formula1,onChange:u=>{a==null||a({...e,formula1:u||void 0})}})}):null,l?m.jsx(T.FormLayout,{label:r.t("dataValidation.checkbox.unchecked"),error:d,children:m.jsx(T.Input,{className:oe.dataValidationFormula,placeholder:r.t("dataValidation.panel.valuePlaceholder"),value:e==null?void 0:e.formula2,onChange:u=>{a==null||a({...e,formula2:u||void 0})}})}):null]})}function Ha(t){var p;const{unitId:e,subUnitId:a,value:n,onChange:o,showError:r,validResult:s}=t,d=r?s==null?void 0:s.formula1:void 0,l=R.useRef({}),[h,u]=R.useState(!1);return X.useSidebarClick(c=>{var g;const f=(g=l.current)==null?void 0:g.handleOutClick;f&&f(c,()=>u(!1))}),m.jsx(pt.FormulaEditor,{initValue:(p=n==null?void 0:n.formula1)!=null?p:"",unitId:e,subUnitId:a,isFocus:h,onChange:c=>{const f=(c!=null?c:"").trim();f!==(n==null?void 0:n.formula1)&&(o==null||o({...n,formula1:f}))},errorText:d,onFocus:()=>u(!0),actions:l.current,isSupportAcrossSheet:!0})}function Yt(t){var e,a,n="";if(typeof t=="string"||typeof t=="number")n+=t;else if(typeof t=="object")if(Array.isArray(t)){var o=t.length;for(e=0;e<o;e++)t[e]&&(a=Yt(t[e]))&&(n&&(n+=" "),n+=a)}else for(a in t)t[a]&&(n&&(n+=" "),n+=a);return n}function Ya(){for(var t,e,a=0,n="",o=arguments.length;a<o;a++)(t=arguments[a])&&(e=Yt(t))&&(n&&(n+=" "),n+=e);return n}const Xa=["#FFFFFF","#FEE7E7","#FEF0E6","#EFFBD0","#E4F4FE","#E8ECFD","#F1EAFA","#FDE8F3","#E5E5E5","#FDCECE","#FDC49B","#DEF6A2","#9FDAFF","#D0D9FB","#E3D5F6","#FBD0E8","#656565","#FE4B4B","#FF8C51","#8BBB11","#0B9EFB","#3A60F7","#9E6DE3","#F248A6"],za=t=>{const{value:e,onChange:a,disabled:n}=t,[o,r]=R.useState(!1);return m.jsx(T.Select,{disabled:n,open:o,onDropdownVisibleChange:r,dropdownStyle:{width:112},style:{width:96,cursor:"pointer"},className:oe.dataValidationFormulaColorSelect,value:e,onChange:a,labelRender:s=>m.jsx("div",{className:oe.dataValidationFormulaColorItem,style:{background:s.value,marginTop:5}}),dropdownRender:()=>m.jsx("div",{className:oe.dataValidationFormulaColorSelectPanel,children:Xa.map(s=>m.jsx("div",{onClick:()=>{a(s),r(!1)},className:oe.dataValidationFormulaColorItem,style:{background:s}},s))})})},Vt=t=>{const{item:e,commonProps:a,style:n}=t,{onItemChange:o,onItemDelete:r}=a;return m.jsxs("div",{className:oe.dataValidationFormulaListItem,style:n,children:[e.isRef?null:m.jsx("div",{className:Ya(oe.dataValidationFormulaListItemDrag,"draggableHandle"),children:m.jsx(Ft,{})}),m.jsx(za,{value:e.color,onChange:s=>{o(e.id,e.label,s)}}),m.jsx(T.Input,{disabled:e.isRef,value:e.label,onChange:s=>{o(e.id,s,e.color)}}),e.isRef?null:m.jsx("div",{className:oe.dataValidationFormulaListItemIcon,children:m.jsx(mt,{onClick:()=>r(e.id)})})]})};function Ka(t){const{value:e,onChange:a=()=>{},unitId:n,subUnitId:o,validResult:r,showError:s,ruleId:d}=t,{formula1:l="",formula2:h=""}=e||{},u=R.useRef(null),[p,c]=R.useState(()=>i.isFormulaString(l)?"1":"0"),[f,g]=R.useState(p==="1"?l:"="),[v,C]=R.useState(p==="1"?l:"="),I=i.useDependency(i.LocaleService),D=i.useDependency(ee.DataValidatorRegistryService),S=i.useDependency(ee.DataValidationModel),b=i.useDependency(E.DataValidationFormulaController),[w,M]=R.useState(()=>h.split(",")),_=D.getValidatorItem(i.DataValidationType.LIST),[y,A]=R.useState([]),[H,F]=R.useState(""),L=s?r==null?void 0:r.formula1:"",j=R.useMemo(()=>S.ruleChange$.pipe(le.debounceTime(16)),[]),x=X.useObservable(j),U=X.useEvent(a);R.useEffect(()=>{(async()=>{await new Promise($=>{setTimeout(()=>$(!0),100)});const V=S.getRuleById(n,o,d),W=V==null?void 0:V.formula1;if(i.isFormulaString(W)&&_&&V){const $=await _.getListAsync(V,n,o);A($)}})()},[S,x,_,d,o,n]),R.useEffect(()=>{i.isFormulaString(l)&&l!==v&&(g(l),C(v))},[v,l]);const[k,z]=R.useState(()=>{const V=p!=="1"?E.deserializeListOptions(l):[],W=h.split(",");return V.map(($,G)=>({label:$,color:W[G]||Ie,isRef:!1,id:i.Tools.generateRandomId(4)}))}),K=(V,W,$)=>{const G=k.find(me=>me.id===V);G&&(G.label=W,G.color=$,z([...k]))},J=V=>{const W=k.findIndex($=>$.id===V);W!==-1&&(k.splice(W,1),z([...k]))},q=h.split(","),Z=R.useMemo(()=>y.map((V,W)=>({label:V,color:q[W]||Ie,id:`${W}`,isRef:!0})),[q,y]),te=(V,W,$)=>{const G=[...w];G[+V]=$,M(G),U({formula1:l,formula2:G.join(",")})},ie=()=>{z([...k,{label:"",color:Ie,isRef:!1,id:i.Tools.generateRandomId(4)}])};R.useEffect(()=>{if(p==="1")return;const V=new Set,W=[];k.map($=>({labelList:$.label.split(","),item:$})).forEach(({item:$,labelList:G})=>{G.forEach(me=>{V.has(me)||(V.add(me),W.push({label:me,color:$.color}))})}),U({formula1:E.serializeListOptions(W.map($=>$.label)),formula2:W.map($=>$.color===Ie?"":$.color).join(",")})},[k,U,p,v,w]);const re=R.useMemo(()=>async V=>{if(!i.isFormulaString(V)){U==null||U({formula1:"",formula2:h});return}b.getFormulaRefCheck(V)?(U==null||U({formula1:i.isFormulaString(V)?V:"",formula2:h}),F("")):(U==null||U({formula1:"",formula2:h}),g("="),F(I.t("dataValidation.validFail.formulaError")))},[h,U]),ne=R.useRef({}),[ae,O]=R.useState(!1);return X.useSidebarClick(V=>{var $;const W=($=ne.current)==null?void 0:$.handleOutClick;W&&W(V,()=>O(!1))}),m.jsxs(m.Fragment,{children:[m.jsx(T.FormLayout,{label:I.t("dataValidation.list.options"),children:m.jsxs(T.RadioGroup,{value:p,onChange:V=>{c(V),g(v),V==="1"&&U({formula1:v==="="?"":v,formula2:w.join(",")})},children:[m.jsx(T.Radio,{value:"0",children:I.t("dataValidation.list.customOptions")}),m.jsx(T.Radio,{value:"1",children:I.t("dataValidation.list.refOptions")})]})}),p==="1"?m.jsxs(m.Fragment,{children:[m.jsx(pt.FormulaEditor,{initValue:f,unitId:n,subUnitId:o,isFocus:ae,onChange:(V="")=>{const W=(V!=null?V:"").trim();C(W),re(W)},errorText:L||H||void 0,onFocus:()=>O(!0),actions:ne.current,isSupportAcrossSheet:!0}),m.jsx("div",{ref:u,style:{marginTop:"12px"},children:Z.map(V=>m.jsx(Vt,{item:V,commonProps:{onItemChange:te},style:{marginBottom:12}},V.id))})]}):m.jsx(T.FormLayout,{error:L,children:m.jsxs("div",{ref:u,style:{marginTop:"-12px"},children:[m.jsx(T.DraggableList,{list:k,onListChange:z,rowHeight:32,margin:[0,12],draggableHandle:".draggableHandle",itemRender:V=>m.jsx(Vt,{item:V,commonProps:{onItemChange:K,onItemDelete:J}},V.id),idKey:"id"}),m.jsxs("a",{className:oe.dataValidationFormulaListAdd,onClick:ie,children:[m.jsx(Lt,{}),I.t("dataValidation.list.add")]})]})})]})}const Xt="data-validation.custom-formula-input",qe="data-validation.formula-input",_t="data-validation.list-formula-input",zt="data-validation.checkbox-formula-input",Ga=[[Xt,Ha],[qe,Wa],[_t,Ka],[zt,$a]],qa="LIST_RENDER_MODE_OPTION_INPUT";function $e(t){var o;const{value:e,onChange:a}=t,n=i.useDependency(i.LocaleService);return m.jsx(T.FormLayout,{label:n.t("dataValidation.renderMode.label"),children:m.jsxs(T.RadioGroup,{value:`${(o=e.renderMode)!=null?o:i.DataValidationRenderMode.CUSTOM}`,onChange:r=>a({...e,renderMode:+r}),children:[m.jsx(T.Radio,{value:`${i.DataValidationRenderMode.CUSTOM}`,children:n.t("dataValidation.renderMode.chip")}),m.jsx(T.Radio,{value:`${i.DataValidationRenderMode.ARROW}`,children:n.t("dataValidation.renderMode.arrow")}),m.jsx(T.Radio,{value:`${i.DataValidationRenderMode.TEXT}`,children:n.t("dataValidation.renderMode.text")})]})})}$e.componentKey=qa;const Za="DATE_SHOW_TIME_OPTION";function He(t){var o;const{value:e,onChange:a}=t,n=i.useDependency(i.LocaleService);return m.jsx(T.FormLayout,{children:m.jsx(T.Checkbox,{checked:(o=e.bizInfo)==null?void 0:o.showTime,onChange:r=>{a({...e,bizInfo:{...e.bizInfo,showTime:r}})},children:n.t("dataValidation.showTime.label")})})}He.componentKey=Za;var Ja=Object.defineProperty,Qa=Object.getOwnPropertyDescriptor,eo=(t,e,a,n)=>{for(var o=n>1?void 0:n?Qa(e,a):e,r=t.length-1,s;r>=0;r--)(s=t[r])&&(o=(n?s(e,a,o):s(o))||o);return n&&o&&Ja(e,a,o),o},Fe=(t,e)=>(a,n)=>e(a,n,t);const xe=6;let dt=class{constructor(t,e,a,n){this._commandService=t,this._formulaService=e,this._themeService=a,this._renderManagerService=n}_calc(t,e){var h,u,p;const{vt:a,ht:n}=e||{},o=t.endX-t.startX-xe*2,r=t.endY-t.startY,s=((h=e==null?void 0:e.fs)!=null?h:10)*1.6;let d=0,l=0;switch(a){case i.VerticalAlign.TOP:l=0;break;case i.VerticalAlign.BOTTOM:l=0+(r-s);break;default:l=0+(r-s)/2;break}switch(n){case i.HorizontalAlign.LEFT:d=xe;break;case i.HorizontalAlign.RIGHT:d=xe+(o-s);break;default:d=xe+(o-s)/2;break}return{left:t.startX+d,top:t.startY+l,width:((u=e==null?void 0:e.fs)!=null?u:10)*1.6,height:((p=e==null?void 0:e.fs)!=null?p:10)*1.6}}calcCellAutoHeight(t){var a;const{style:e}=t;return((a=e==null?void 0:e.fs)!=null?a:10)*1.6}calcCellAutoWidth(t){var a;const{style:e}=t;return((a=e==null?void 0:e.fs)!=null?a:10)*1.6}async _parseFormula(t,e,a){var h,u,p,c,f,g,v,C,I;const{formula1:n=E.CHECKBOX_FORMULA_1,formula2:o=E.CHECKBOX_FORMULA_2}=t,r=await this._formulaService.getRuleFormulaResult(e,a,t.uid),s=E.getFormulaResult((p=(u=(h=r==null?void 0:r[0])==null?void 0:h.result)==null?void 0:u[0])==null?void 0:p[0]),d=E.getFormulaResult((g=(f=(c=r==null?void 0:r[1])==null?void 0:c.result)==null?void 0:f[0])==null?void 0:g[0]),l=E.isLegalFormulaResult(String(s))&&E.isLegalFormulaResult(String(d));return{formula1:i.isFormulaString(n)?E.getFormulaResult((I=(C=(v=r==null?void 0:r[0])==null?void 0:v.result)==null?void 0:C[0])==null?void 0:I[0]):n,formula2:i.isFormulaString(o)?d:o,isFormulaValid:l}}drawWith(t,e){var j,x,U,k,z,K;const{style:a,data:n,primaryWithCoord:o,unitId:r,subUnitId:s,worksheet:d,row:l,col:h}=e,u=o.isMergedMainCell?o.mergeInfo:o,p=E.getCellValueOrigin(d.getCellRaw(l,h)),c=(j=n.dataValidation)==null?void 0:j.rule,f=(x=n.dataValidation)==null?void 0:x.validator;if(!c||!f)return;const g=this._themeService.getCurrentTheme();if(!((U=f.skipDefaultFontRender)!=null&&U.call(f,c,p,{unitId:r,subUnitId:s,row:l,column:h})))return;const v=f.parseFormulaSync(c,r,s),{formula1:C}=v,I=this._calc(u,a),{a:D,d:S}=t.getTransform(),b=B.fixLineWidthByScale(I.left,D),w=B.fixLineWidthByScale(I.top,S),M=B.Transform.create().composeMatrix({left:b,top:w,scaleX:1,scaleY:1,angle:0,skewX:0,skewY:0,flipX:!1,flipY:!1}),_=u.endX-u.startX,y=u.endY-u.startY;t.save(),t.beginPath(),t.rect(u.startX,u.startY,_,y),t.clip();const A=M.getMatrix();t.transform(A[0],A[1],A[2],A[3],A[4],A[5]);const H=((k=a==null?void 0:a.fs)!=null?k:10)*1.6,F=String(p)===String(C),L=g.hyacinth500;B.Checkbox.drawWith(t,{checked:F,width:H,height:H,fill:(K=(z=a==null?void 0:a.cl)==null?void 0:z.rgb)!=null?K:L}),t.restore()}isHit(t,e){const a=e.primaryWithCoord.isMergedMainCell?e.primaryWithCoord.mergeInfo:e.primaryWithCoord,n=this._calc(a,e.style),o=n.top,r=n.top+n.height,s=n.left,d=n.left+n.width,{x:l,y:h}=t;return l<=d&&l>=s&&h<=r&&h>=o}async onPointerDown(t,e){var v,C,I;if(e.button===2)return;const{primaryWithCoord:a,unitId:n,subUnitId:o,data:r,worksheet:s,row:d,col:l}=t,h=E.getCellValueOrigin(s.getCellRaw(d,l)),u=(v=r.dataValidation)==null?void 0:v.rule,p=(C=r.dataValidation)==null?void 0:C.validator;if(!u||!p||!((I=p.skipDefaultFontRender)!=null&&I.call(p,u,h,{unitId:n,subUnitId:o,row:d,column:l})))return;const{formula1:c,formula2:f}=await this._parseFormula(u,n,o),g={range:{startColumn:a.actualColumn,endColumn:a.actualColumn,startRow:a.actualRow,endRow:a.actualRow},value:{v:String(h)===E.transformCheckboxValue(String(c))?f:c,p:null}};this._commandService.executeCommand(Y.SetRangeValuesCommand.id,g)}onPointerEnter(t,e){var a,n;(n=(a=this._renderManagerService.getCurrentTypeOfRenderer(i.UniverInstanceType.UNIVER_SHEET))==null?void 0:a.mainComponent)==null||n.setCursor(B.CURSOR_TYPE.POINTER)}onPointerLeave(t,e){var a,n;(n=(a=this._renderManagerService.getCurrentTypeOfRenderer(i.UniverInstanceType.UNIVER_SHEET))==null?void 0:a.mainComponent)==null||n.setCursor(B.CURSOR_TYPE.DEFAULT)}};dt=eo([Fe(0,i.ICommandService),Fe(1,i.Inject(E.DataValidationFormulaService)),Fe(2,i.Inject(i.ThemeService)),Fe(3,i.Inject(B.IRenderManagerService))],dt);var to=Object.defineProperty,no=Object.getOwnPropertyDescriptor,ao=(t,e,a,n)=>{for(var o=n>1?void 0:n?no(e,a):e,r=t.length-1,s;r>=0;r--)(s=t[r])&&(o=(n?s(e,a,o):s(o))||o);return n&&o&&to(e,a,o),o},oo=(t,e)=>(a,n)=>e(a,n,t);let he=class{constructor(t){P(this,"canvasRender",null);P(this,"dropdown");P(this,"optionsInput");P(this,"formulaInput",_t);this.injector=t}};he=ao([oo(0,i.Inject(i.Injector))],he);class io extends he{constructor(){super(...arguments);P(this,"id",i.DataValidationType.CHECKBOX);P(this,"canvasRender",this.injector.createInstance(dt));P(this,"formulaInput",zt)}}class ro extends he{constructor(){super(...arguments);P(this,"id",i.DataValidationType.CUSTOM);P(this,"formulaInput",Xt)}}const so="data-validation.formula-input";class lo extends he{constructor(){super(...arguments);P(this,"id",i.DataValidationType.DATE);P(this,"formulaInput",so);P(this,"optionsInput",He.componentKey);P(this,"dropdown",St)}}class co extends he{constructor(){super(...arguments);P(this,"id",i.DataValidationType.DECIMAL);P(this,"formulaInput",qe)}}const Kt=4,uo=0,tt=4,Gt=4,ct=6,Ye=6,_e=14;function ho(t,e){const a=B.FontCache.getTextSize(t,e),n=a.width+Kt*2,{ba:o,bd:r}=a,s=o+r;return{width:n,height:s+uo*2,ba:o}}function nt(t,e,a,n){const o=_e+ct*2,r=a-o,s=n-Ye*2,d=t.map(c=>({layout:ho(c,e),text:c}));let l;const h=[];d.forEach(c=>{const{layout:f}=c,{width:g,height:v}=f;!l||l.width+g+tt>r?(l={width:g,height:v,items:[{...c,left:0}]},h.push(l)):(l.items.push({...c,left:l.width+tt}),l.width=l.width+g+tt)});let u=0,p=0;return h.forEach((c,f)=>{p=Math.max(p,c.width),f===h.length-1?u+=c.height:u+=c.height+Gt}),{lines:h,totalHeight:u,contentWidth:r,contentHeight:s,cellAutoHeight:u+Ye*2,calcAutoWidth:p+o}}const po=8;class mo extends B.Shape{static drawWith(e,a){const{fontString:n,info:o,fill:r,color:s}=a,{layout:d,text:l}=o;e.save(),B.Rect.drawWith(e,{width:d.width,height:d.height,radius:po,fill:r||Ie}),e.translateWithPrecision(Kt,d.ba),e.font=n,e.fillStyle=s,e.fillText(l,0,0),e.restore()}}var go=Object.defineProperty,vo=Object.getOwnPropertyDescriptor,fo=(t,e,a,n)=>{for(var o=n>1?void 0:n?vo(e,a):e,r=t.length-1,s;r>=0;r--)(s=t[r])&&(o=(n?s(e,a,o):s(o))||o);return n&&o&&go(e,a,o),o},yt=(t,e)=>(a,n)=>e(a,n,t);const So=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(t,e){P(this,"zIndex");P(this,"_dropdownInfoMap",new Map);this._commandService=t,this._renderManagerService=e}_ensureMap(t){let e=this._dropdownInfoMap.get(t);return e||(e=new Map,this._dropdownInfoMap.set(t,e)),e}_generateKey(t,e){return`${t}.${e}`}_drawDownIcon(t,e,a,n,o){const r=a-_e+4;let s=4;switch(o){case i.VerticalAlign.MIDDLE:s=(n-_e)/2+4;break;case i.VerticalAlign.BOTTOM:s=n-_e+4;break}t.save(),t.translateWithPrecision(e.startX+r,e.startY+s),t.fillStyle="#565656",t.fill(So),t.restore()}drawWith(t,e,a,n){var q,Z;const{primaryWithCoord:o,row:r,col:s,style:d,data:l,subUnitId:h}=e,u=o.isMergedMainCell?o.mergeInfo:o,p=l.fontRenderExtension,{leftOffset:c=0,rightOffset:f=0,topOffset:g=0,downOffset:v=0}=p||{},C=l.dataValidation,I=this._ensureMap(h),D=this._generateKey(r,s);if(!C)return;const S={startX:u.startX+c,endX:u.endX-f,startY:u.startY+g,endY:u.endY-v},b=S.endX-S.startX,w=S.endY-S.startY,{cl:M}=d||{},_=(q=typeof M=="object"?M==null?void 0:M.rgb:M)!=null?q:"#000",y=B.getFontStyleString(d!=null?d:void 0),{rule:A,validator:H}=C,F=H,{vt:L,ht:j}=d||{},x=L!=null?L:i.VerticalAlign.MIDDLE,U=(Z=E.getCellValueOrigin(l))!=null?Z:"",k=F.parseCellValue(U),z=F.getListWithColorMap(A),K=nt(k,y,b,w);this._drawDownIcon(t,S,b,w,x),t.save(),t.translateWithPrecision(S.startX,S.startY),t.beginPath(),t.rect(0,0,b-_e,w),t.clip(),t.translateWithPrecision(ct,Ye);let J=0;switch(x){case i.VerticalAlign.MIDDLE:J=(K.contentHeight-K.totalHeight)/2;break;case i.VerticalAlign.BOTTOM:J=K.contentHeight-K.totalHeight;break}t.translateWithPrecision(0,J),K.lines.forEach((te,ie)=>{t.save();const{width:re,height:ne,items:ae}=te;let O=0;switch(j){case i.HorizontalAlign.RIGHT:O=K.contentWidth-re;break;case i.HorizontalAlign.CENTER:O=(K.contentWidth-re)/2;break}t.translate(O,ie*(ne+Gt)),ae.forEach(V=>{t.save(),t.translateWithPrecision(V.left,0),mo.drawWith(t,{...y,info:V,color:_,fill:z[V.text]}),t.restore()}),t.restore()}),t.restore(),I.set(D,{left:S.startX,top:S.startY,width:K.contentWidth+ct+_e,height:K.contentHeight+Ye*2})}calcCellAutoHeight(t){var b;const{primaryWithCoord:e,style:a,data:n}=t,o=n.fontRenderExtension,{leftOffset:r=0,rightOffset:s=0,topOffset:d=0,downOffset:l=0}=o||{},h=e.isMergedMainCell?e.mergeInfo:e,u={startX:h.startX+r,endX:h.endX-s,startY:h.startY+d,endY:h.endY-l},p=n.dataValidation;if(!p)return;const c=u.endX-u.startX,f=u.endY-u.startY,g=(b=E.getCellValueOrigin(n))!=null?b:"",{validator:v}=p,I=v.parseCellValue(g),D=B.getFontStyleString(a!=null?a:void 0);return nt(I,D,c,f).cellAutoHeight}calcCellAutoWidth(t){var b;const{primaryWithCoord:e,style:a,data:n}=t,o=n.fontRenderExtension,{leftOffset:r=0,rightOffset:s=0,topOffset:d=0,downOffset:l=0}=o||{},h=e.isMergedMainCell?e.mergeInfo:e,u={startX:h.startX+r,endX:h.endX-s,startY:h.startY+d,endY:h.endY-l},p=n.dataValidation;if(!p)return;const c=u.endX-u.startX,f=u.endY-u.startY,g=(b=E.getCellValueOrigin(n))!=null?b:"",{validator:v}=p,I=v.parseCellValue(g),D=B.getFontStyleString(a!=null?a:void 0);return nt(I,D,c,f).calcAutoWidth}isHit(t,e){const{primaryWithCoord:a}=e,n=a.isMergedMainCell?a.mergeInfo:a,{endX:o}=n,{x:r}=t;return r>=o-_e&&r<=o}onPointerDown(t,e){if(e.button===2)return;const{unitId:a,subUnitId:n,row:o,col:r}=t,s={unitId:a,subUnitId:n,row:o,column:r};this._commandService.executeCommand(ze.id,s)}onPointerEnter(t,e){var a,n;(n=(a=this._renderManagerService.getCurrentTypeOfRenderer(i.UniverInstanceType.UNIVER_SHEET))==null?void 0:a.mainComponent)==null||n.setCursor(B.CURSOR_TYPE.POINTER)}onPointerLeave(t,e){var a,n;(n=(a=this._renderManagerService.getCurrentTypeOfRenderer(i.UniverInstanceType.UNIVER_SHEET))==null?void 0:a.mainComponent)==null||n.setCursor(B.CURSOR_TYPE.DEFAULT)}};ut=fo([yt(0,i.ICommandService),yt(1,i.Inject(B.IRenderManagerService))],ut);class _o extends he{constructor(){super(...arguments);P(this,"id",i.DataValidationType.LIST_MULTIPLE);P(this,"canvasRender",this.injector.createInstance(ut));P(this,"dropdown",Ke)}}var Io=Object.defineProperty,Co=Object.getOwnPropertyDescriptor,Do=(t,e,a,n)=>{for(var o=n>1?void 0:n?Co(e,a):e,r=t.length-1,s;r>=0;r--)(s=t[r])&&(o=(n?s(e,a,o):s(o))||o);return n&&o&&Io(e,a,o),o},at=(t,e)=>(a,n)=>e(a,n,t);const Se=4,Ue=4,de=14,ce=6,Re=4,ot=8,Ro="#565656",wt=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 Vo(t,e){const a=t.length;return{id:"d",body:{dataStream:`${t}${i.DEFAULT_EMPTY_DOCUMENT_VALUE}`,textRuns:[{ts:{fs:11,ff:void 0,it:i.BooleanNumber.FALSE,bl:i.BooleanNumber.FALSE,ul:{s:i.BooleanNumber.FALSE},st:{s:i.BooleanNumber.FALSE},ol:{s:i.BooleanNumber.FALSE},cl:void 0,...e,bg:void 0,bd:void 0},st:0,ed:a}]},documentStyle:{pageSize:{width:Number.POSITIVE_INFINITY,height:Number.POSITIVE_INFINITY}}}}function qt(t,e,a){const n=Vo(t,a),o=new i.DocumentDataModel(n),r=new B.DocumentViewModel(o);return{documentSkeleton:B.DocumentSkeleton.create(r,e),docModel:o,docViewModel:r}}function Ne(t,e,a){const{documentSkeleton:n,docModel:o,docViewModel:r}=qt(t,e,a);return{documents:new B.Documents(`DOCUMENTS_${i.Tools.generateRandomId()}`,n,{pageMarginLeft:0,pageMarginTop:0}),documentSkeleton:n,docModel:o,docViewModel:r}}function Et(t,e,a,n,o,r,s=!0){let d=0;const l=s?Re:0;switch(o){case i.VerticalAlign.BOTTOM:d=e-n-l;break;case i.VerticalAlign.MIDDLE:d=(e-n)/2;break;default:d=l;break}d=Math.max(Re,d);let h=0;switch(r){case i.HorizontalAlign.CENTER:h=(t-a)/2;break;case i.HorizontalAlign.RIGHT:h=t-a;break}return h=Math.max(ce,h),{paddingLeft:h,paddingTop:d}}let ht=class{constructor(t,e,a){P(this,"_dropdownInfoMap",new Map);P(this,"zIndex");this._localeService=t,this._commandService=e,this._renderManagerService=a}_ensureMap(t){let e=this._dropdownInfoMap.get(t);return e||(e=new Map,this._dropdownInfoMap.set(t,e)),e}_generateKey(t,e){return`${t}.${e}`}_drawDownIcon(t,e,a,n,o,r,s){const{t:d=i.DEFAULT_STYLES.pd.t,b:l=i.DEFAULT_STYLES.pd.b}=s,h=a-de;let u;switch(r){case i.VerticalAlign.MIDDLE:u=(n-Ue)/2;break;case i.VerticalAlign.BOTTOM:u=n-l-o-Re+(o/2-Ue/2);break;default:u=d+Re+(o/2-Ue/2);break}t.save(),t.translateWithPrecision(e.startX+h,e.startY+u),t.fillStyle="#565656",t.fill(wt),t.restore()}drawWith(t,e,a){var x,U;const{primaryWithCoord:n,row:o,col:r,style:s,data:d,subUnitId:l}=e,h=n.isMergedMainCell?n.mergeInfo:n,u=(x=d.dataValidation)==null?void 0:x.rule,p=(U=d.dataValidation)==null?void 0:U.validator,c=d.fontRenderExtension,{leftOffset:f=0,rightOffset:g=0,topOffset:v=0,downOffset:C=0}=c||{};if(!u||!p||!p||p.id.indexOf(i.DataValidationType.LIST)!==0||!p.skipDefaultFontRender(u))return;const I={startX:h.startX+f,endX:h.endX-g,startY:h.startY+v,endY:h.endY-C},D=I.endX-I.startX,S=I.endY-I.startY,b=this._ensureMap(l),w=this._generateKey(o,r),M=p.getListWithColor(u),_=E.getCellValueOrigin(d),y=`${_!=null?_:""}`,A=M.find(k=>k.label===y);let{tb:H,vt:F,ht:L,pd:j}=s||{};if(H=H!=null?H:i.WrapStrategy.WRAP,F=F!=null?F:i.VerticalAlign.BOTTOM,L=L!=null?L:i.DEFAULT_STYLES.ht,j=j!=null?j:i.DEFAULT_STYLES.pd,u.renderMode===i.DataValidationRenderMode.ARROW){const{l:k=i.DEFAULT_STYLES.pd.l,t:z=i.DEFAULT_STYLES.pd.t,r:K=i.DEFAULT_STYLES.pd.r,b:J=i.DEFAULT_STYLES.pd.b}=j,q=D-k-K-de-4,{documentSkeleton:Z,documents:te,docModel:ie}=Ne(y,this._localeService,s);H===i.WrapStrategy.WRAP&&ie.updateDocumentDataPageSize(Math.max(q,1)),Z.calculate(),Z.getActualSize();const re=B.getDocsSkeletonPageSize(Z),{height:ne,width:ae}=re,{paddingTop:O,paddingLeft:V}=Et(q,S-z-J,ae,ne,F,L,!0);this._drawDownIcon(t,I,D,S,ne,F,j),t.save(),t.translateWithPrecision(I.startX+k,I.startY+z),t.beginPath(),t.rect(0,0,D-k-K,S-z-J),t.clip(),t.translateWithPrecision(0,O),t.save(),t.translateWithPrecision(Se,0),t.beginPath(),t.rect(0,0,q,ne),t.clip(),te.render(t),t.translateWithPrecision(V,0),t.restore(),t.restore(),b.set(w,{left:I.endX+k+a.rowHeaderWidth-de,top:I.startY+z+a.columnHeaderHeight,width:de,height:S-z-J})}else{t.save(),t.translateWithPrecision(I.startX,I.startY),t.beginPath(),t.rect(0,0,D,S),t.clip();const k=D-ce*2-Se-de-4,{documentSkeleton:z,documents:K,docModel:J}=Ne(y,this._localeService,s);H===i.WrapStrategy.WRAP&&J.updateDocumentDataPageSize(Math.max(k,1)),z.calculate();const q=B.getDocsSkeletonPageSize(z),{height:Z,width:te}=q,{paddingTop:ie,paddingLeft:re}=Et(k,S,te,Z,F,L);t.translateWithPrecision(ce,ie);const ne=Math.max(D-ce*2,1),ae=Z;B.Rect.drawWith(t,{width:ne,height:ae,fill:(A==null?void 0:A.color)||Ie,radius:ot}),t.save(),t.translateWithPrecision(Se,0),t.beginPath(),t.rect(0,0,k,Z),t.clip(),t.translateWithPrecision(re,0),K.render(t),t.restore(),t.translateWithPrecision(k+Se+4,(Z-Ue)/2),t.fillStyle=Ro,t.fill(wt),t.restore(),b.set(w,{left:I.startX+ce+a.rowHeaderWidth,top:I.startY+ie+a.columnHeaderHeight,width:ne,height:ae})}}calcCellAutoHeight(t){var S;const{primaryWithCoord:e,style:a,data:n}=t,o=e.isMergedMainCell?e.mergeInfo:e,r=n.fontRenderExtension,{leftOffset:s=0,rightOffset:d=0,topOffset:l=0,downOffset:h=0}=r||{},u=(S=n.dataValidation)==null?void 0:S.rule;if(!u||u.renderMode===i.DataValidationRenderMode.TEXT)return;const p={startX:o.startX+s,endX:o.endX-d,startY:o.startY+l,endY:o.endY-h},c=p.endX-p.startX,f=E.getCellValueOrigin(n),g=`${f!=null?f:""}`;let{tb:v,pd:C}=a||{};const{t:I=i.DEFAULT_STYLES.pd.t,b:D=i.DEFAULT_STYLES.pd.b}=C!=null?C:{};if(v=v!=null?v:i.WrapStrategy.WRAP,u.renderMode===i.DataValidationRenderMode.ARROW){const b=c-de,{documentSkeleton:w,docModel:M}=Ne(g,this._localeService,a);v===i.WrapStrategy.WRAP&&M.updateDocumentDataPageSize(Math.max(b,1)),w.calculate(),w.getActualSize();const _=B.getDocsSkeletonPageSize(w),{height:y}=_;return y+I+D+Re*2}else{const b=c-ce*2-Se-de,{documentSkeleton:w,docModel:M}=qt(g,this._localeService,a);v===i.WrapStrategy.WRAP&&M.updateDocumentDataPageSize(Math.max(b,1)),w.calculate();const _=B.getDocsSkeletonPageSize(w),{height:y}=_;return y+Re*2}}calcCellAutoWidth(t){var y;const{primaryWithCoord:e,style:a,data:n}=t,o=e.isMergedMainCell?e.mergeInfo:e,r=n.fontRenderExtension,{leftOffset:s=0,rightOffset:d=0,topOffset:l=0,downOffset:h=0}=r||{},u=(y=n.dataValidation)==null?void 0:y.rule;if(!u||u.renderMode===i.DataValidationRenderMode.TEXT)return;const p={startX:o.startX+s,endX:o.endX-d,startY:o.startY+l,endY:o.endY-h},c=p.endX-p.startX,f=E.getCellValueOrigin(n),g=`${f!=null?f:""}`;let{tb:v,pd:C}=a||{};const{l:I=i.DEFAULT_STYLES.pd.l,r:D=i.DEFAULT_STYLES.pd.r}=C!=null?C:{};v=v!=null?v:i.WrapStrategy.WRAP;let S=ce*2+de;switch(u.renderMode){case i.DataValidationRenderMode.ARROW:S=de+ce*2+D+I;break;case i.DataValidationRenderMode.CUSTOM:S=de+ce*2+Se*2+D+I+ot/2+1;break;default:S=de+ce*2+Se*2+D+I+ot/2+1}const b=c-S,{documentSkeleton:w,docModel:M}=Ne(g,this._localeService,a);return v===i.WrapStrategy.WRAP&&M.updateDocumentDataPageSize(Math.max(b,1)),w.calculate(),w.getActualSize(),B.getDocsSkeletonPageSize(w).width+S}isHit(t,e){const{data:a,subUnitId:n,row:o,col:r}=e,d=this._ensureMap(n).get(this._generateKey(o,r)),l=a.dataValidation;if(!l||!d||l.rule.renderMode===i.DataValidationRenderMode.TEXT)return!1;const{top:h,left:u,width:p,height:c}=d,{x:f,y:g}=t;return f>=u&&f<=u+p&&g>=h&&g<=h+c}onPointerDown(t,e){if(e.button===2)return;const{unitId:a,subUnitId:n,row:o,col:r}=t,s={unitId:a,subUnitId:n,row:o,column:r};this._commandService.executeCommand(ze.id,s)}onPointerEnter(t,e){var a,n;(n=(a=this._renderManagerService.getCurrentTypeOfRenderer(i.UniverInstanceType.UNIVER_SHEET))==null?void 0:a.mainComponent)==null||n.setCursor(B.CURSOR_TYPE.POINTER)}onPointerLeave(t,e){var a,n;(n=(a=this._renderManagerService.getCurrentTypeOfRenderer(i.UniverInstanceType.UNIVER_SHEET))==null?void 0:a.mainComponent)==null||n.setCursor(B.CURSOR_TYPE.DEFAULT)}};ht=Do([at(0,i.Inject(i.LocaleService)),at(1,i.ICommandService),at(2,i.Inject(B.IRenderManagerService))],ht);class yo extends he{constructor(){super(...arguments);P(this,"id",i.DataValidationType.LIST);P(this,"canvasRender",this.injector.createInstance(ht));P(this,"dropdown",Ke);P(this,"optionsInput",$e.componentKey);P(this,"formulaInput",_t)}}class wo extends he{constructor(){super(...arguments);P(this,"id",i.DataValidationType.TEXT_LENGTH);P(this,"formulaInput",qe)}}class Eo extends he{constructor(){super(...arguments);P(this,"id",i.DataValidationType.WHOLE);P(this,"formulaInput",qe)}}var bo=Object.defineProperty,Mo=Object.getOwnPropertyDescriptor,Oo=(t,e,a,n)=>{for(var o=n>1?void 0:n?Mo(e,a):e,r=t.length-1,s;r>=0;r--)(s=t[r])&&(o=(n?s(e,a,o):s(o))||o);return n&&o&&bo(e,a,o),o},it=(t,e)=>(a,n)=>e(a,n,t);let be=class extends i.RxDisposable{constructor(t,e,a){super(),this._injector=t,this._componentManger=e,this._dataValidatorRegistryService=a,this._initComponents(),this._registerValidatorViews()}_initComponents(){[[Bt,Pt],[gt,ua],[xt,On],[Ke,Hn],[St,gn],[$e.componentKey,$e],[He.componentKey,He],...Ga].forEach(([t,e])=>{this.disposeWithMe(this._componentManger.register(t,e))})}_registerValidatorViews(){[co,Eo,wo,lo,io,yo,_o,ro].forEach(t=>{const e=this._injector.createInstance(t),a=this._dataValidatorRegistryService.getValidatorItem(e.id);a&&(a.formulaInput=e.formulaInput,a.canvasRender=e.canvasRender,a.dropdown=e.dropdown,a.optionsInput=e.optionsInput)})}};be=Oo([it(0,i.Inject(i.Injector)),it(1,i.Inject(X.ComponentManager)),it(2,i.Inject(ee.DataValidatorRegistryService))],be);var To=Object.defineProperty,Po=Object.getOwnPropertyDescriptor,Lo=(t,e,a,n)=>{for(var o=n>1?void 0:n?Po(e,a):e,r=t.length-1,s;r>=0;r--)(s=t[r])&&(o=(n?s(e,a,o):s(o))||o);return n&&o&&To(e,a,o),o},rt=(t,e)=>(a,n)=>e(a,n,t);const jo="SHEET_DATA_VALIDATION_UI_PLUGIN";var ke;exports.UniverSheetsDataValidationUIPlugin=(ke=class extends i.Plugin{constructor(e=kt,a,n,o){super(),this._config=e,this._injector=a,this._commandService=n,this._configService=o;const{menu:r,...s}=this._config;r&&this._configService.setConfig("menu",r,{merge:!0}),this._configService.setConfig(ft,s)}onStarting(){[[ue],[ge],[Pe],[Ve],[Ee],[we],[ye],[Te],[be]].forEach(e=>{this._injector.add(e)}),[Ge,ze,Nt,vt,Ce,Ut].forEach(e=>{this._commandService.registerCommand(e)})}onReady(){this._injector.get(ye),this._injector.get(we),this._injector.get(Te),this._injector.get(Pe),this._injector.get(B.IRenderManagerService).registerRenderModule(i.UniverInstanceType.UNIVER_SHEET,[We])}onRendered(){this._injector.get(be),this._injector.get(Ee)}onSteady(){this._injector.get(Ve)}},P(ke,"pluginName",jo),P(ke,"type",i.UniverInstanceType.UNIVER_SHEET),ke);exports.UniverSheetsDataValidationUIPlugin=Lo([rt(1,i.Inject(i.Injector)),rt(2,i.ICommandService),rt(3,i.IConfigService)],exports.UniverSheetsDataValidationUIPlugin);var Ao=Object.defineProperty,Fo=Object.getOwnPropertyDescriptor,xo=(t,e,a,n)=>{for(var o=n>1?void 0:n?Fo(e,a):e,r=t.length-1,s;r>=0;r--)(s=t[r])&&(o=(n?s(e,a,o):s(o))||o);return n&&o&&Ao(e,a,o),o},st=(t,e)=>(a,n)=>e(a,n,t);const Uo="SHEET_DATA_VALIDATION_UI_PLUGIN";var Be;exports.UniverSheetsDataValidationMobileUIPlugin=(Be=class extends i.Plugin{constructor(e=kt,a,n,o){super(),this._config=e,this._injector=a,this._commandService=n,this._configService=o;const{menu:r,...s}=this._config;r&&this._configService.setConfig("menu",r,{merge:!0}),this._configService.setConfig(ft,s)}onStarting(){[[ue],[ge],[Pe],[Ve],[Ee],[we],[ye],[be]].forEach(e=>{this._injector.add(e)}),[Ge,ze,Nt,vt,Ce,Ut].forEach(e=>{this._commandService.registerCommand(e)})}onReady(){this._injector.get(ye),this._injector.get(we),this._injector.get(B.IRenderManagerService).registerRenderModule(i.UniverInstanceType.UNIVER_SHEET,[We])}onRendered(){this._injector.get(be),this._injector.get(Ee)}onSteady(){this._injector.get(Ve)}},P(Be,"pluginName",Uo),P(Be,"type",i.UniverInstanceType.UNIVER_SHEET),Be);exports.UniverSheetsDataValidationMobileUIPlugin=xo([st(1,i.Inject(i.Injector)),st(2,i.ICommandService),st(3,i.IConfigService)],exports.UniverSheetsDataValidationMobileUIPlugin);exports.DATE_DROPDOWN_KEY=St;exports.LIST_DROPDOWN_KEY=Ke;
9
+ */var nn=V,an=Symbol.for("react.element"),on=Symbol.for("react.fragment"),rn=Object.prototype.hasOwnProperty,sn=nn.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,ln={key:!0,ref:!0,__self:!0,__source:!0};function bt(e,t,a){var n,o={},r=null,s=null;a!==void 0&&(r=""+a),t.key!==void 0&&(r=""+t.key),t.ref!==void 0&&(s=t.ref);for(n in t)rn.call(t,n)&&!ln.hasOwnProperty(n)&&(o[n]=t[n]);if(e&&e.defaultProps)for(n in t=e.defaultProps,t)o[n]===void 0&&(o[n]=t[n]);return{$$typeof:an,type:e,key:r,ref:s,props:o,_owner:sn.current}}ze.Fragment=on;ze.jsx=bt;ze.jsxs=bt;Mt.exports=ze;var p=Mt.exports,dn=Object.defineProperty,cn=Object.getOwnPropertyDescriptor,un=(e,t,a,n)=>{for(var o=n>1?void 0:n?cn(t,a):t,r=e.length-1,s;r>=0;r--)(s=e[r])&&(o=(n?s(t,a,o):s(o))||o);return n&&o&&dn(t,a,o),o},Oe=(e,t)=>(a,n)=>t(a,n,e);let Le=class extends i.Disposable{constructor(e,t,a,n,o){super(),this._sheetInterceptorService=e,this._dataValidationModel=t,this._dataValidatorRegistryService=a,this._dialogService=n,this._localeService=o,this._initEditorBridgeInterceptor()}_initEditorBridgeInterceptor(){this._sheetInterceptorService.writeCellInterceptor.intercept(Y.AFTER_CELL_EDIT_ASYNC,{handler:async(e,t,a)=>{var f;const n=await e,{worksheet:o,row:r,col:s,unitId:d,subUnitId:l,workbook:u}=t,h=this._dataValidationModel.getRuleIdByLocation(d,l,r,s),m=h?this._dataValidationModel.getRuleById(d,l,h):void 0;if(!m||m.errorStyle!==i.DataValidationErrorStyle.STOP)return a(Promise.resolve(n));const c=await this._dataValidatorRegistryService.getValidatorItem(m.type);if(!c||await c.validator({value:w.getCellValueOrigin(n),interceptValue:w.getCellValueOrigin((f=t==null?void 0:t.origin)!=null?f:n),row:r,column:s,unitId:d,subUnitId:l,worksheet:o,workbook:u,t:n==null?void 0:n.t},m))return a(Promise.resolve(n));const g=o.getCellRaw(r,s);return this._dialogService.open({width:368,title:{title:this._localeService.t("dataValidation.alert.title")},id:"reject-input-dialog",children:{title:c.getRuleFinalError(m,{row:r,col:s,unitId:d,subUnitId:l})},footer:{title:V.createElement(O.Button,{type:"primary",onClick:()=>this._dialogService.close("reject-input-dialog")},this._localeService.t("dataValidation.alert.ok"))},onClose:()=>{this._dialogService.close("reject-input-dialog")}}),a(Promise.resolve(g))}})}showReject(e){this._dialogService.open({width:368,title:{title:this._localeService.t("dataValidation.alert.title")},id:"reject-input-dialog",children:{title:e},footer:{title:V.createElement(O.Button,{type:"primary",onClick:()=>this._dialogService.close("reject-input-dialog")},this._localeService.t("dataValidation.alert.ok"))},onClose:()=>{this._dialogService.close("reject-input-dialog")}})}};Le=un([Oe(0,i.Inject(Y.SheetInterceptorService)),Oe(1,i.Inject(w.SheetDataValidationModel)),Oe(2,i.Inject(Q.DataValidatorRegistryService)),Oe(3,X.IDialogService),Oe(4,i.Inject(i.LocaleService))],Le);const hn="univer-dv-date-dropdown",pn="univer-dv-date-dropdown-btns",Ct={dvDateDropdown:hn,dvDateDropdownBtns:pn},mn=e=>{if(e==null||typeof e=="boolean")return;if(typeof e=="number"||!Number.isNaN(+e))return i.dayjs(i.numfmt.format("yyyy-MM-dd HH:mm:ss",Number(e)));const t=i.dayjs(e);if(t.isValid())return t};function gn(e){var v;const{location:t,hideFn:a}=e,{worksheet:n,row:o,col:r,unitId:s,subUnitId:d,workbook:l}=t,u=i.useDependency(i.ICommandService),h=i.useDependency(Le),m=n.getCell(o,r),c=w.getCellValueOrigin(n.getCellRaw(o,r)),I=mn(c),[g,f]=V.useState(I),y=g&&g.isValid()?g:i.dayjs(),S=i.useDependency(i.LocaleService),R=i.useDependency(w.SheetDataValidationModel),D=R.getRuleByLocation(s,d,o,r);if(!D)return null;const b=R.getValidator(D.type);if(!m||!b)return;const _=!!((v=D.bizInfo)!=null&&v.showTime),C=async()=>{var x,U,$;if(!y)return;const A=y.format(_?"YYYY-MM-DD HH:mm:ss":"YYYY-MM-DD 00:00:00"),W=(x=i.numfmt.parseDate(A))==null?void 0:x.v,F=l.getStyles().getStyleByCell(m),L=($=(U=F==null?void 0:F.n)==null?void 0:U.pattern)!=null?$:"",P=en.getPatternType(L);D.errorStyle!==i.DataValidationErrorStyle.STOP||await b.validator({value:W,unitId:s,subUnitId:d,row:o,column:r,worksheet:n,workbook:l,interceptValue:A.replace("Z","").replace("T"," "),t:i.CellValueType.NUMBER},D)?(a(),await u.executeCommand(N.SetCellEditVisibleOperation.id,{visible:!1,eventType:B.DeviceInputEventType.Keyboard,unitId:s,keycode:X.KeyCode.ESC}),await u.executeCommand(Y.SetRangeValuesCommand.id,{unitId:s,subUnitId:d,range:{startColumn:r,endColumn:r,startRow:o,endRow:o},value:{v:W,t:2,p:null,f:null,si:null,s:{n:{pattern:_?P==="datetime"?L:"yyyy-MM-dd hh:mm:ss":P==="date"?L:"yyyy-MM-dd"}}}})):h.showReject(b.getRuleFinalError(D,{row:o,col:r,unitId:s,subUnitId:d}))};return p.jsxs("div",{className:Ct.dvDateDropdown,children:[p.jsx(O.DatePanel,{defaultValue:y,pickerValue:y,showTime:_||void 0,onSelect:async M=>{f(M)},onPanelChange:M=>{f(M)},disabledDate:M=>!i.numfmt.parseDate(M.format("YYYY-MM-DD"))}),p.jsx("div",{className:Ct.dvDateDropdownBtns,children:p.jsx(O.Button,{size:"small",type:"primary",onClick:C,disabled:!y.isValid(),children:S.t("dataValidation.alert.ok")})})]})}var se=function(){return se=Object.assign||function(e){for(var t,a=1,n=arguments.length;a<n;a++){t=arguments[a];for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o])}return e},se.apply(this,arguments)},fn=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 o=0,n=Object.getOwnPropertySymbols(e);o<n.length;o++)t.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(a[n[o]]=e[n[o]]);return a},fe=V.forwardRef(function(e,t){var a=e.icon,n=e.id,o=e.className,r=e.extend,s=fn(e,["icon","id","className","extend"]),d="univerjs-icon univerjs-icon-".concat(n," ").concat(o||"").trim(),l=V.useRef("_".concat(_n()));return Ot(a,"".concat(n),{defIds:a.defIds,idSuffix:l.current},se({ref:t,className:d},s),r)});function Ot(e,t,a,n,o){return V.createElement(e.tag,se(se({key:t},vn(e,a,o)),n),(Sn(e,a).children||[]).map(function(r,s){return Ot(r,"".concat(t,"-").concat(e.tag,"-").concat(s),a,void 0,o)}))}function vn(e,t,a){var n=se({},e.attrs);a!=null&&a.colorChannel1&&n.fill==="colorChannel1"&&(n.fill=a.colorChannel1);var o=t.defIds;return!o||o.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],d=r[1];typeof d=="string"&&(n[s]=d.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))})),n}function Sn(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)?se(se({},e),{children:e.children.map(function(o){return typeof o.attrs.id=="string"&&n&&n.indexOf(o.attrs.id)>-1?se(se({},o),{attrs:se(se({},o.attrs),{id:o.attrs.id+t.idSuffix})}):o})}):e}function _n(){return Math.random().toString(36).substring(2,8)}fe.displayName="UniverIcon";var In={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M14.1544 3.75557C14.3887 3.98988 14.3887 4.36978 14.1544 4.6041L6.51409 12.2444C6.40157 12.3569 6.24896 12.4201 6.08983 12.4201C5.9307 12.4201 5.77808 12.3569 5.66556 12.2444L1.84541 8.42425C1.6111 8.18993 1.6111 7.81003 1.84541 7.57572C2.07973 7.34141 2.45963 7.34141 2.69394 7.57572L6.08983 10.9716L13.3059 3.75557C13.5402 3.52126 13.9201 3.52126 14.1544 3.75557Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Tt=V.forwardRef(function(e,t){return V.createElement(fe,Object.assign({},e,{id:"check-mark-single",ref:t,icon:In}))});Tt.displayName="CheckMarkSingle";var Cn={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"}}]},Lt=V.forwardRef(function(e,t){return V.createElement(fe,Object.assign({},e,{id:"data-validation-single",ref:t,icon:Cn}))});Lt.displayName="DataValidationSingle";var Dn={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"}}]},gt=V.forwardRef(function(e,t){return V.createElement(fe,Object.assign({},e,{id:"delete-single",ref:t,icon:Dn}))});gt.displayName="DeleteSingle";var Rn={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"}}]},Pt=V.forwardRef(function(e,t){return V.createElement(fe,Object.assign({},e,{id:"increase-single",ref:t,icon:Rn}))});Pt.displayName="IncreaseSingle";var yn={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"}}]},jt=V.forwardRef(function(e,t){return V.createElement(fe,Object.assign({},e,{id:"more-down-single",ref:t,icon:yn}))});jt.displayName="MoreDownSingle";var Vn={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"}}]},At=V.forwardRef(function(e,t){return V.createElement(fe,Object.assign({},e,{id:"more-up-single",ref:t,icon:Vn}))});At.displayName="MoreUpSingle";var wn={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"}}]}]},Ft=V.forwardRef(function(e,t){return V.createElement(fe,Object.assign({},e,{id:"sequence-single",ref:t,icon:wn}))});Ft.displayName="SequenceSingle";var En=Object.defineProperty,Mn=Object.getOwnPropertyDescriptor,bn=(e,t,a,n)=>{for(var o=n>1?void 0:n?Mn(t,a):t,r=e.length-1,s;r>=0;r--)(s=e[r])&&(o=(n?s(t,a,o):s(o))||o);return n&&o&&En(t,a,o),o},Dt=(e,t)=>(a,n)=>t(a,n,e);let ue=class extends i.Disposable{constructor(t,a){super();T(this,"_open$",new le.BehaviorSubject(!1));T(this,"open$",this._open$.pipe(le.distinctUntilChanged()));T(this,"_activeRule");T(this,"_activeRule$",new le.BehaviorSubject(void 0));T(this,"activeRule$",this._activeRule$.asObservable());T(this,"_closeDisposable",null);this._univerInstanceService=t,this._sidebarService=a,this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(i.UniverInstanceType.UNIVER_SHEET).pipe(le.filter(n=>!n)).subscribe(()=>{this.close()})),this.disposeWithMe(this._sidebarService.sidebarOptions$.subscribe(n=>{n.id===ft&&(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=i.toDisposable(()=>{t.dispose(),this._closeDisposable=null})}setActiveRule(t){this._activeRule=t,this._activeRule$.next(t)}};ue=bn([Dt(0,i.IUniverInstanceService),Dt(1,X.ISidebarService)],ue);function On(){const e=i.useDependency(ge),t=X.useObservable(e.activeDropdown$,e.activeDropdown),a=i.useDependency(X.ComponentManager);if(!t)return null;const{location:n,componentKey:o}=t,r=a.get(o),s=`${n.unitId}-${n.subUnitId}-${n.row}-${n.col}`;if(!r)return null;const d=()=>{e.hideDropdown()};return p.jsx(r,{location:n,hideFn:d},s)}const xt="sheet.ui.dropdown";var Tn=Object.defineProperty,Ln=Object.getOwnPropertyDescriptor,Pn=(e,t,a,n)=>{for(var o=n>1?void 0:n?Ln(t,a):t,r=e.length-1,s;r>=0;r--)(s=e[r])&&(o=(n?s(t,a,o):s(o))||o);return n&&o&&Tn(t,a,o),o},ve=(e,t)=>(a,n)=>t(a,n,e);let ge=class extends i.Disposable{constructor(t,a,n,o,r,s,d){super();T(this,"_activeDropdown");T(this,"_activeDropdown$",new le.Subject);T(this,"_currentPopup",null);T(this,"activeDropdown$",this._activeDropdown$.asObservable());T(this,"_zenVisible",!1);this._canvasPopupManagerService=t,this._univerInstanceService=a,this._dataValidatorRegistryService=n,this._zenZoneService=o,this._renderManagerService=r,this._dataValidationModel=s,this._sheetsSelectionsService=d,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,o){const r=t?this._univerInstanceService.getUnit(t,i.UniverInstanceType.UNIVER_SHEET):this._univerInstanceService.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET);if(!r)return;const s=a?r.getSheetBySheetId(a):r.getActiveSheet();if(!s)return;const d=this._dataValidationModel.getRuleByLocation(r.getUnitId(),s.getSheetId(),n,o);if(!d)return;const l=this._dataValidatorRegistryService.getValidatorItem(d.type);return l==null?void 0:l.dropdown}_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,a=!0){const{location:n}=t,{row:o,col:r,unitId:s,subUnitId:d}=n;if(this._currentPopup&&this._currentPopup.dispose(),this._zenVisible)return;this._activeDropdown=t,this._activeDropdown$.next(this._activeDropdown);const l=this._renderManagerService.getRenderById(i.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY),u=this._canvasPopupManagerService.attachPopupToCell(o,r,{componentKey:xt,onClickOutside:()=>{a&&this.hideDropdown()},offset:[0,3],excludeOutside:[l==null?void 0:l.engine.getCanvasElement()].filter(Boolean)},s,d);if(!u)throw new Error("[DataValidationDropdownManagerService]: cannot show dropdown!");const h=new i.DisposableCollection;h.add(u),h.add({dispose:()=>{var m,c;(c=(m=this._activeDropdown)==null?void 0:m.onHide)==null||c.call(m)}}),this._currentPopup=h}hideDropdown(){this._activeDropdown&&(this._currentPopup&&this._currentPopup.dispose(),this._currentPopup=null,this._activeDropdown=null,this._activeDropdown$.next(null))}showDataValidationDropdown(t,a,n,o,r){const s=this._univerInstanceService.getUnit(t,i.UniverInstanceType.UNIVER_SHEET);if(!s)return;const d=s.getSheetBySheetId(a);if(!d)return;const l=this._dataValidationModel.getRuleByLocation(s.getUnitId(),d.getSheetId(),n,o);if(!l)return;const u=this._dataValidatorRegistryService.getValidatorItem(l.type);if(!u||!u.dropdown){this.hideDropdown();return}this.showDropdown({location:{workbook:s,worksheet:d,row:n,col:o,unitId:t,subUnitId:a},componentKey:u.dropdown,onHide:r})}};ge=Pn([ve(0,i.Inject(N.SheetCanvasPopManagerService)),ve(1,i.IUniverInstanceService),ve(2,i.Inject(Q.DataValidatorRegistryService)),ve(3,X.IZenZoneService),ve(4,B.IRenderManagerService),ve(5,i.Inject(w.SheetDataValidationModel)),ve(6,i.Inject(Y.SheetsSelectionsService))],ge);const ft="DataValidationPanel",Ce={id:"data-validation.operation.open-validation-panel",type:i.CommandType.OPERATION,handler(e,t){if(!t)return!1;const{ruleId:a,isAdd:n}=t,o=e.get(ue),r=e.get(Q.DataValidationModel),s=e.get(i.IUniverInstanceService),d=e.get(X.ISidebarService),l=Y.getSheetCommandTarget(s);if(!l)return!1;const{unitId:u,subUnitId:h}=l,m=a?r.getRuleById(u,h,a):void 0;o.open(),o.setActiveRule(m&&{unitId:u,subUnitId:h,rule:m});const c=d.open({header:{title:n?"dataValidation.panel.addTitle":"dataValidation.panel.title"},children:{label:ft},width:312,onClose:()=>o.close()});return o.setCloseDisposable(c),!0}},vt={id:"data-validation.operation.close-validation-panel",type:i.CommandType.OPERATION,handler(e){return e.get(ue).close(),!0}},Ut={id:"data-validation.operation.toggle-validation-panel",type:i.CommandType.OPERATION,handler(e){const t=e.get(i.ICommandService),a=e.get(ue);return a.open(),a.isOpen?t.executeCommand(vt.id):t.executeCommand(Ce.id),!0}},Ke={type:i.CommandType.OPERATION,id:"sheet.operation.show-data-validation-dropdown",handler(e,t){if(!t)return!1;const a=e.get(ge),{unitId:n,subUnitId:o,row:r,column:s}=t,d=a.activeDropdown,l=d==null?void 0:d.location;return l&&l.unitId===n&&l.subUnitId===o&&l.row===r&&l.col===s||a.showDataValidationDropdown(n,o,r,s),!0}},Nt={type:i.CommandType.OPERATION,id:"sheet.operation.hide-data-validation-dropdown",handler(e,t){return t?(e.get(ge).hideDropdown(),!0):!1}},Ie="#ECECEC",St="sheets-data-validation-ui.config",Bt={},jn="univer-dv-list-dropdown",An="univer-dv-list-dropdown-title",Fn="univer-dv-list-dropdown-list",xn="univer-dv-list-dropdown-list-container",Un="univer-dv-list-dropdown-selected-icon",Nn="univer-dv-list-dropdown-item-container",Bn="univer-dv-list-dropdown-item",kn="univer-dv-list-dropdown-split",Wn="univer-dv-list-dropdown-edit",pe={dvListDropdown:jn,dvListDropdownTitle:An,dvListDropdownList:Fn,dvListDropdownListContainer:xn,dvListDropdownSelectedIcon:Un,dvListDropdownItemContainer:Nn,dvListDropdownItem:Bn,dvListDropdownSplit:kn,dvListDropdownEdit:Wn},$n=e=>{var _,C;const{value:t,onChange:a,multiple:n,options:o,title:r,onEdit:s,style:d,filter:l,location:u}=e,h=i.useDependency(i.LocaleService),m=i.useDependency(i.IConfigService),c=l==null?void 0:l.toLowerCase(),{row:I,col:g,unitId:f,subUnitId:y}=u,S=o.filter(v=>c?v.label.toLowerCase().includes(c):!0),R=(C=(_=m.getConfig(St))==null?void 0:_.showEditOnDropdown)!=null?C:!0,D=i.useDependency(N.SheetPermissionInterceptorBaseController),b=V.useMemo(()=>D.permissionCheckWithRanges({workbookTypes:[Y.WorkbookEditablePermission],rangeTypes:[Y.RangeProtectionPermissionEditPoint],worksheetTypes:[Y.WorksheetEditPermission]},[{startColumn:g,startRow:I,endColumn:g,endRow:I}],f,y),[D,g,I,f,y]);return p.jsxs("div",{className:pe.dvListDropdown,style:d,children:[p.jsx("div",{className:pe.dvListDropdownTitle,children:r}),p.jsx("div",{className:pe.dvListDropdownList,children:p.jsx(O.Scrollbar,{children:p.jsx("div",{className:pe.dvListDropdownListContainer,children:S.map((v,M)=>{const A=t.indexOf(v.value)>-1,W=()=>{let L;A?L=new Set(t.filter(x=>x!==v.value)):L=new Set(n?[...t,v.value]:[v.value]);const P=[];o.forEach(x=>{L.has(x.value)&&P.push(x.value)}),a(P)},F=v.label.toLocaleLowerCase().indexOf(c);return p.jsxs("div",{className:pe.dvListDropdownItemContainer,onClick:W,children:[p.jsx("div",{className:pe.dvListDropdownItem,style:{background:v.color||Ie},children:c&&v.label.toLowerCase().includes(c)?p.jsxs(p.Fragment,{children:[p.jsx("span",{children:v.label.substring(0,F)}),p.jsx("span",{style:{fontWeight:"bold"},children:v.label.substring(F,F+c.length)}),p.jsx("span",{children:v.label.substring(F+c.length)})]}):v.label}),p.jsx("div",{className:pe.dvListDropdownSelectedIcon,children:A?p.jsx(Tt,{}):null})]},M)})})},l)}),R&&b?p.jsxs(p.Fragment,{children:[p.jsx("div",{className:pe.dvListDropdownSplit}),p.jsx("div",{className:pe.dvListDropdownEdit,children:p.jsx("a",{onClick:s,children:h.t("dataValidation.list.edit")})})]}):null]})};function Hn(e){var U,$,G,q;const{location:t,hideFn:a}=e,{worksheet:n,row:o,col:r,unitId:s,subUnitId:d}=t,l=i.useDependency(Q.DataValidationModel),[u,h]=V.useState(""),m=i.useDependency(i.ICommandService),c=i.useDependency(i.LocaleService),[I,g]=V.useState(""),f=i.useDependency(N.IEditorBridgeService),y=i.useDependency(i.IUniverInstanceService),S=V.useMemo(()=>l.ruleChange$.pipe(le.debounceTime(16)),[]),R=i.useDependency(w.SheetDataValidationModel);X.useObservable(S);const D=X.RectPopup.useContext(),b=(($=(U=D.current)==null?void 0:U.right)!=null?$:0)-((q=(G=D.current)==null?void 0:G.left)!=null?q:0);if(V.useEffect(()=>{const K=m.onCommandExecuted(Z=>{var ee,te;if(Z.id===tn.RichTextEditingMutation.id){const ne=Z.params,{unitId:ie}=ne,oe=y.getUnit(ie,i.UniverInstanceType.UNIVER_DOC);if(!oe)return;const re=i.BuildTextUtils.transform.getPlainText((te=(ee=oe.getSnapshot().body)==null?void 0:ee.dataStream)!=null?te:"");h(re)}});return()=>{K.dispose()}},[m,y]),!n)return null;const _=R.getRuleByLocation(s,d,o,r);if(!_)return null;const C=R.getValidator(_.type);if(!C)return null;const v=n.getCell(o,r),M=(_==null?void 0:_.renderMode)===i.DataValidationRenderMode.CUSTOM||(_==null?void 0:_.renderMode)===void 0;if(!v||!_||!C||C.id.indexOf(i.DataValidationType.LIST)!==0)return;const A=_.type===i.DataValidationType.LIST_MULTIPLE,W=C.getListWithColor(_,s,d),F=I||w.getDataValidationCellValue(n.getCellRaw(o,r)),L=w.deserializeListOptions(F),P=()=>{m.executeCommand(Ce.id,{ruleId:_.uid}),a()},x=W.map(K=>({label:K.label,value:K.label,color:M||K.color?K.color:"transparent"}));return p.jsx($n,{style:{minWidth:b,maxWidth:Math.max(b,200)},title:A?c.t("dataValidation.listMultiple.dropdown"):c.t("dataValidation.list.dropdown"),value:L,multiple:A,onChange:async K=>{const Z=w.serializeListOptions(K),ee={unitId:s,subUnitId:d,range:{startColumn:r,endColumn:r,startRow:o,endRow:o},value:{v:Z,p:null,f:null,si:null}};f.isVisible()&&f.changeVisible({visible:!1,keycode:X.KeyCode.ESC,eventType:B.DeviceInputEventType.Keyboard,unitId:s}),g(Z),A||a(),f.isVisible().visible&&await m.executeCommand(N.SetCellEditVisibleOperation.id,{visible:!1,eventType:B.DeviceInputEventType.Keyboard,unitId:s,keycode:X.KeyCode.ESC}),m.executeCommand(Y.SetRangeValuesCommand.id,ee)},options:x,onEdit:P,filter:u,location:t})}const Yn="univer-data-validation-options-button",Xn="univer-data-validation-options-button-icon",Je={dataValidationOptionsButton:Yn,dataValidationOptionsButtonIcon:Xn};function zn(e){var u;const t=i.useDependency(i.LocaleService),a=i.useDependency(X.ComponentManager),{value:n,onChange:o,extraComponent:r}=e,[s,d]=V.useState(!1),l=r?a.get(r):null;return p.jsxs(p.Fragment,{children:[p.jsxs("div",{className:Je.dataValidationOptionsButton,onClick:()=>d(!s),children:[t.t("dataValidation.panel.options"),s?p.jsx(At,{className:Je.dataValidationOptionsButtonIcon}):p.jsx(jt,{className:Je.dataValidationOptionsButtonIcon})]}),s&&p.jsxs(p.Fragment,{children:[l?p.jsx(l,{value:n,onChange:o}):null,p.jsx(O.FormLayout,{label:t.t("dataValidation.panel.invalid"),children:p.jsxs(O.RadioGroup,{value:`${(u=n.errorStyle)!=null?u:i.DataValidationErrorStyle.WARNING}`,onChange:h=>o({...n,errorStyle:+h}),children:[p.jsx(O.Radio,{value:`${i.DataValidationErrorStyle.WARNING}`,children:t.t("dataValidation.panel.showWarning")}),p.jsx(O.Radio,{value:`${i.DataValidationErrorStyle.STOP}`,children:t.t("dataValidation.panel.rejectInput")})]})}),p.jsx(O.FormLayout,{label:t.t("dataValidation.panel.messageInfo"),children:p.jsx(O.Checkbox,{checked:n.showErrorMessage,onChange:()=>o({...n,showErrorMessage:!n.showErrorMessage}),children:t.t("dataValidation.panel.showInfo")})}),n.showErrorMessage?p.jsx(O.FormLayout,{children:p.jsx(O.Input,{value:n.error,onChange:h=>o({...n,error:h})})}):null]})]})}const Kn="univer-data-validation-detail",Gn="univer-data-validation-detail-form-item",qn="univer-data-validation-detail-buttons",Zn="univer-data-validation-detail-button",De={dataValidationDetail:Kn,dataValidationDetailFormItem:Gn,dataValidationDetailButtons:qn,dataValidationDetailButton:Zn},Jn=e=>i.debounce(async(t,a,n,o)=>{const r=await e.executeCommand(t,a,n);o==null||o(r)},1e3);function Qn(e,t,a){var n,o,r,s;return t?((o=(n=e.getUnit(t))==null?void 0:n.getSheetBySheetName(a))==null?void 0:o.getSheetId())||"":((s=(r=e.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET))==null?void 0:r.getSheetBySheetName(a))==null?void 0:s.getSheetId())||""}function ea(){var re;const[e,t]=V.useState(0),a=i.useDependency(ue),n=X.useObservable(a.activeRule$,a.activeRule),{unitId:o,subUnitId:r,rule:s}=n||{},d=s.uid,l=i.useDependency(Q.DataValidatorRegistryService),u=i.useDependency(i.IUniverInstanceService),h=i.useDependency(X.ComponentManager),m=i.useDependency(i.ICommandService),c=i.useDependency(Q.DataValidationModel),I=i.useDependency(i.LocaleService),[g,f]=V.useState(s),y=l.getValidatorItem(g.type),[S,R]=V.useState(!1),D=l.getValidatorsByScope(Q.DataValidatorRegistryScope.SHEET),[b,_]=V.useState(()=>g.ranges.map(j=>({unitId:"",sheetId:"",range:j}))),C=V.useMemo(()=>Jn(m),[m]),[v,M]=V.useState(!1),A=V.useRef({}),[W,F]=V.useState(!1),L=i.useDependency(Y.SheetsSelectionsService);if(V.useEffect(()=>()=>{const j=L.getCurrentLastSelection();j&&L.setSelections([j])},[L]),V.useEffect(()=>{m.onCommandExecuted(j=>{(j.id===i.UndoCommand.id||j.id===i.RedoCommand.id)&&setTimeout(()=>{const E=c.getRuleById(o,r,d);t(k=>k+1),E&&(f(E),_(E.ranges.map(k=>({unitId:"",sheetId:"",range:k}))))},20)})},[m,c,d,r,o]),!y)return null;const P=y.operators,x=y.operatorNames,U=g.operator?Q.TWO_FORMULA_OPERATOR_COUNT.includes(g.operator):!1,$=()=>{!g.ranges.length||v||(y.validatorFormula(g,o,r).success?a.setActiveRule(null):R(!0))},G=X.useEvent(j=>{const E=j.split(",").map(dt.deserializeRangeWithSheet).map(z=>{const me=z.sheetName;if(me){const Zt=Qn(u,z.unitId,me);return{...z,sheetId:Zt}}return{...z,sheetId:""}});if(i.isUnitRangesEqual(E,b))return;_(E);const k=E.filter(z=>(!z.unitId||z.unitId===o)&&(!z.sheetId||z.sheetId===r)).map(z=>z.range);if(f({...g,ranges:k}),k.length===0)return;const H={unitId:o,subUnitId:r,ruleId:d,ranges:k};C(w.UpdateSheetDataValidationRangeCommand.id,H)}),q=j=>{if(i.shallowEqual(j,Q.getRuleSetting(g)))return;f({...g,...j});const E={unitId:o,subUnitId:r,ruleId:d,setting:j};C(w.UpdateSheetDataValidationSettingCommand.id,E,void 0)},K=async()=>{await m.executeCommand(w.RemoveSheetDataValidationCommand.id,{ruleId:d,unitId:o,subUnitId:r}),a.setActiveRule(null)},Z={type:g.type,operator:g.operator,formula1:g.formula1,formula2:g.formula2,allowBlank:g.allowBlank},ee=j=>{const E=l.getValidatorItem(j);if(!E)return;const k=E.operators,H=c.getRuleById(o,r,d),z=j===(H==null?void 0:H.type)||j.includes("list")&&(H!=null&&H.type.includes("list"))?{...H,type:j}:{...g,type:j,operator:k[0],formula1:void 0,formula2:void 0};f(z),m.executeCommand(w.UpdateSheetDataValidationSettingCommand.id,{unitId:o,subUnitId:r,ruleId:g.uid,setting:Q.getRuleSetting(z)})},te=h.get(y.formulaInput),ne=V.useMemo(()=>b.map(j=>dt.serializeRange(j.range)).join(","),[]),ie=Q.getRuleOptions(g),oe=j=>{i.shallowEqual(j,Q.getRuleOptions(g))||(f({...g,...j}),C(w.UpdateSheetDataValidationOptionsCommand.id,{unitId:o,subUnitId:r,ruleId:d,options:j}))};return X.useSidebarClick(j=>{var k;const E=(k=A.current)==null?void 0:k.handleOutClick;E&&E(j,()=>F(!1))}),p.jsxs("div",{className:De.dataValidationDetail,children:[p.jsx(O.FormLayout,{label:I.t("dataValidation.panel.range"),error:!g.ranges.length||v?I.t("dataValidation.panel.rangeError"):"",children:p.jsx(mt.RangeSelector,{unitId:o,subUnitId:r,initValue:ne,onChange:G,onFocus:()=>F(!0),isFocus:W,actions:A.current,onVerify:j=>M(!j)})}),p.jsx(O.FormLayout,{label:I.t("dataValidation.panel.type"),children:p.jsx(O.Select,{options:D==null?void 0:D.map(j=>({label:I.t(j.title),value:j.id})),value:g.type,onChange:ee,className:De.dataValidationDetailFormItem})}),P!=null&&P.length?p.jsx(O.FormLayout,{label:I.t("dataValidation.panel.operator"),children:p.jsx(O.Select,{options:P.map((j,E)=>({value:`${j}`,label:x[E]})),value:`${g.operator}`,onChange:j=>{q({...Z,operator:j})},className:De.dataValidationDetailFormItem})}):null,te?p.jsx(te,{isTwoFormula:U,value:{formula1:g.formula1,formula2:g.formula2},onChange:j=>{q({...Z,...j})},showError:S,validResult:y.validatorFormula(g,o,r),unitId:o,subUnitId:r,ruleId:d},e+g.type):null,p.jsx(O.FormLayout,{children:p.jsx(O.Checkbox,{checked:(re=g.allowBlank)!=null?re:!0,onChange:()=>{var j;return q({...Z,allowBlank:!((j=g.allowBlank)==null||j)})},children:I.t("dataValidation.panel.allowBlank")})}),p.jsx(zn,{value:ie,onChange:oe,extraComponent:y.optionsInput}),p.jsxs("div",{className:De.dataValidationDetailButtons,children:[p.jsx(O.Button,{className:De.dataValidationDetailButton,onClick:K,children:I.t("dataValidation.panel.removeRule")}),p.jsx(O.Button,{className:De.dataValidationDetailButton,type:"primary",onClick:$,children:I.t("dataValidation.panel.done")})]})]})}const ta="univer-data-validation-item-container",na="univer-data-validation-item-title",aa="univer-data-validation-item-content",oa="univer-data-validation-item-icon",je={dataValidationItemContainer:ta,dataValidationItemTitle:na,dataValidationItemContent:aa,dataValidationItemIcon:oa},ia=e=>{const{rule:t,onClick:a,unitId:n,subUnitId:o,disable:r}=e,s=i.useDependency(Q.DataValidatorRegistryService),d=i.useDependency(i.ICommandService),l=i.useDependency(N.IMarkSelectionService),u=s.getValidatorItem(t.type),h=V.useRef(),[m,c]=V.useState(!1),I=g=>{d.executeCommand(w.RemoveSheetDataValidationCommand.id,{ruleId:t.uid,unitId:n,subUnitId:o}),g.stopPropagation()};return V.useEffect(()=>()=>{var g;h.current&&((g=h.current)==null||g.forEach(f=>{f&&l.removeShape(f)}))},[l]),p.jsxs("div",{className:je.dataValidationItemContainer,onClick:a,onMouseEnter:()=>{r||(c(!0),h.current=t.ranges.map(g=>l.addShape({range:g,style:{fill:"rgba(73, 184, 17, 0.05)",strokeWidth:1,stroke:"#49B811",widgets:{}},primary:null})))},onMouseLeave:()=>{var g;c(!1),(g=h.current)==null||g.forEach(f=>{f&&l.removeShape(f)}),h.current=void 0},children:[p.jsx("div",{className:je.dataValidationItemTitle,children:u==null?void 0:u.generateRuleName(t)}),p.jsx("div",{className:je.dataValidationItemContent,children:t.ranges.map(g=>dt.serializeRange(g)).join(",")}),m?p.jsx("div",{className:je.dataValidationItemIcon,onClick:I,children:p.jsx(gt,{})}):null]})},ra="univer-data-validation-list",sa="univer-data-validation-list-buttons",la="univer-data-validation-list-button",Ae={dataValidationList:ra,dataValidationListButtons:sa,dataValidationListButton:la};function da(){const e=i.useDependency(i.IUniverInstanceService),t=X.useObservable(()=>e.getCurrentTypeOfUnit$(i.UniverInstanceType.UNIVER_SHEET),void 0,void 0,[]);return t?p.jsx(ca,{workbook:t}):null}function ca(e){const t=i.useDependency(w.SheetDataValidationModel),a=i.useDependency(i.IUniverInstanceService),n=i.useDependency(i.ICommandService),o=i.useDependency(i.Injector),r=i.useDependency(ue),s=i.useDependency(i.LocaleService),[d,l]=V.useState([]),{workbook:u}=e,h=X.useObservable(u.activeSheet$,void 0,!0),m=u.getUnitId(),c=h==null?void 0:h.getSheetId();V.useEffect(()=>{l(t.getRules(m,c));const R=t.ruleChange$.subscribe(D=>{D.unitId===m&&D.subUnitId===c&&l(t.getRules(m,c))});return()=>{R.unsubscribe()}},[m,c,t]);const I=async()=>{const R=w.createDefaultNewRule(o),D={unitId:m,subUnitId:c,rule:R};await n.executeCommand(w.AddSheetDataValidationCommand.id,D),r.setActiveRule({unitId:m,subUnitId:c,rule:R})},g=()=>{n.executeCommand(w.RemoveSheetAllDataValidationCommand.id,{unitId:m,subUnitId:c})},y=(R=>{const D=a.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET),b=D.getActiveSheet(),_=D.getUnitId(),C=b.getSheetId();return R.map(M=>Y.checkRangesEditablePermission(o,_,C,M.ranges)?{...M}:{...M,disable:!0})})(d),S=y==null?void 0:y.some(R=>R.disable);return p.jsxs("div",{className:Ae.dataValidationList,children:[y==null?void 0:y.map(R=>{var D;return p.jsx(ia,{unitId:m,subUnitId:c,onClick:()=>{R.disable||r.setActiveRule({unitId:m,subUnitId:c,rule:R})},rule:R,disable:(D=R.disable)!=null?D:!1},R.uid)}),p.jsxs("div",{className:Ae.dataValidationListButtons,children:[d.length&&!S?p.jsx(O.Button,{className:Ae.dataValidationListButton,onClick:g,children:s.t("dataValidation.panel.removeAll")}):null,p.jsx(O.Button,{className:Ae.dataValidationListButton,type:"primary",onClick:I,children:s.t("dataValidation.panel.add")})]})]})}const ua=()=>{const e=i.useDependency(ue),t=X.useObservable(e.activeRule$,e.activeRule);return t?p.jsx(ea,{},t.rule.uid):p.jsx(da,{})},Ge="data-validation.list.dropdown",_t="data-validation.date.dropdown",qe={type:i.CommandType.COMMAND,id:"data-validation.command.addRuleAndOpen",handler(e){const t=e.get(i.IUniverInstanceService),a=Y.getSheetCommandTarget(t);if(!a)return!1;const{workbook:n,worksheet:o}=a,r=w.createDefaultNewRule(e),s=e.get(i.ICommandService),d=n.getUnitId(),l=o.getSheetId(),u={rule:r,unitId:d,subUnitId:l};return s.syncExecuteCommand(w.AddSheetDataValidationCommand.id,u)?(s.syncExecuteCommand(Ce.id,{ruleId:r.uid,isAdd:!0}),!0):!1}};var ha=Object.defineProperty,pa=Object.getOwnPropertyDescriptor,ma=(e,t,a,n)=>{for(var o=n>1?void 0:n?pa(t,a):t,r=e.length-1,s;r>=0;r--)(s=e[r])&&(o=(n?s(t,a,o):s(o))||o);return n&&o&&ha(t,a,o),o},Re=(e,t)=>(a,n)=>t(a,n,e);const Fe="SHEET_DATA_VALIDATION_ALERT";let Pe=class extends i.Disposable{constructor(e,t,a,n,o,r){super(),this._hoverManagerService=e,this._cellAlertManagerService=t,this._univerInstanceService=a,this._localeService=n,this._zenZoneService=o,this._dataValidationModel=r,this._init()}_init(){this._initCellAlertPopup(),this._initZenService()}_initCellAlertPopup(){this.disposeWithMe(this._hoverManagerService.currentCell$.pipe(le.debounceTime(100)).subscribe(e=>{var t;if(e){if(!this._univerInstanceService.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET).getActiveSheet())return;const o=this._dataValidationModel.getRuleByLocation(e.location.unitId,e.location.subUnitId,e.location.row,e.location.col);if(!o)return;if(this._dataValidationModel.validator(o,e.location)===i.DataValidationStatus.INVALID){const s=this._cellAlertManagerService.currentAlert.get(Fe),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)return;const l=this._dataValidationModel.getValidator(o.type);if(!l)return;this._cellAlertManagerService.showAlert({type:N.CellAlertType.ERROR,title:this._localeService.t("dataValidation.error.title"),message:l==null?void 0:l.getRuleFinalError(o,e.location),location:e.location,width:200,height:74,key:Fe});return}}this._cellAlertManagerService.removeAlert(Fe)}))}_initZenService(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(e=>{e&&this._cellAlertManagerService.removeAlert(Fe)}))}};Pe=ma([Re(0,i.Inject(N.HoverManagerService)),Re(1,i.Inject(N.CellAlertManagerService)),Re(2,i.IUniverInstanceService),Re(3,i.Inject(i.LocaleService)),Re(4,X.IZenZoneService),Re(5,i.Inject(w.SheetDataValidationModel))],Pe);var ga=Object.defineProperty,fa=Object.getOwnPropertyDescriptor,va=(e,t,a,n)=>{for(var o=n>1?void 0:n?fa(t,a):t,r=e.length-1,s;r>=0;r--)(s=e[r])&&(o=(n?s(t,a,o):s(o))||o);return n&&o&&ga(t,a,o),o},Qe=(e,t)=>(a,n)=>t(a,n,e);let Ve=class extends i.Disposable{constructor(e,t,a){super(),this._autoFillService=e,this._dataValidationModel=t,this._injector=a,this._initAutoFill()}_initAutoFill(){const e=()=>({redos:[],undos:[]}),t=(o,r)=>{const{source:s,target:d,unitId:l,subUnitId:u}=o,h=this._dataValidationModel.getRuleObjectMatrix(l,u).clone(),m=N.virtualizeDiscreteRanges([s,d]),[c,I]=m.ranges,{mapFunc:g}=m,f={row:c.startRow,col:c.startColumn},y=N.getAutoFillRepeatRange(c,I),S=new i.ObjectMatrix,R=new Set;y.forEach(v=>{const M=v.repeatStartCell,A=v.relativeRange,W={startRow:f.row,startColumn:f.col,endColumn:f.col,endRow:f.row},F={startRow:M.row,startColumn:M.col,endColumn:M.col,endRow:M.row};i.Range.foreach(A,(L,P)=>{const x=i.Rectangle.getPositionRange({startRow:L,startColumn:P,endColumn:P,endRow:L},W),{row:U,col:$}=g(x.startRow,x.startColumn),G=this._dataValidationModel.getRuleIdByLocation(l,u,U,$);if(G){const q=i.Rectangle.getPositionRange({startRow:L,startColumn:P,endColumn:P,endRow:L},F),{row:K,col:Z}=g(q.startRow,q.startColumn);S.setValue(K,Z,G),R.add(G)}})});const D=Array.from(R).map(v=>({id:v,ranges:i.queryObjectMatrix(S,M=>M===v)}));h.addRangeRules(D);const b=h.diff(this._dataValidationModel.getRules(l,u)),{redoMutations:_,undoMutations:C}=w.getDataValidationDiffMutations(l,u,b,this._injector,"patched",r===N.APPLY_TYPE.ONLY_FORMAT);return{undos:C,redos:_}},a=[i.DataValidationType.CHECKBOX],n={id:w.DATA_VALIDATION_PLUGIN_NAME,onBeforeFillData:o=>{const{source:r,unitId:s,subUnitId:d}=o;for(const l of r.rows)for(const u of r.cols){const h=this._dataValidationModel.getRuleByLocation(s,d,l,u);if(h&&a.indexOf(h.type)>-1){this._autoFillService.setDisableApplyType(N.APPLY_TYPE.SERIES,!0);return}}},onFillData:(o,r,s)=>s===N.APPLY_TYPE.COPY||s===N.APPLY_TYPE.ONLY_FORMAT||s===N.APPLY_TYPE.SERIES?t(o,s):e(),onAfterFillData:()=>{}};this.disposeWithMe(this._autoFillService.addHook(n))}};Ve=va([Qe(0,N.IAutoFillService),Qe(1,i.Inject(w.SheetDataValidationModel)),Qe(2,i.Inject(i.Injector))],Ve);var Sa=Object.defineProperty,_a=Object.getOwnPropertyDescriptor,Ia=(e,t,a,n)=>{for(var o=n>1?void 0:n?_a(t,a):t,r=e.length-1,s;r>=0;r--)(s=e[r])&&(o=(n?s(t,a,o):s(o))||o);return n&&o&&Sa(t,a,o),o},et=(e,t)=>(a,n)=>t(a,n,e);let we=class extends i.Disposable{constructor(t,a,n){super();T(this,"_copyInfo");this._sheetClipboardService=t,this._sheetDataValidationModel=a,this._injector=n,this._initCopyPaste()}_initCopyPaste(){this._sheetClipboardService.addClipboardHook({id:w.DATA_VALIDATION_PLUGIN_NAME,onBeforeCopy:(t,a,n)=>this._collect(t,a,n),onPasteCells:(t,a,n,o)=>{const{copyType:r=N.COPY_TYPE.COPY,pasteType:s}=o,{range:d}=t||{},{range:l,unitId:u,subUnitId:h}=a;return this._generateMutations(l,{copyType:r,pasteType:s,copyRange:d,unitId:u,subUnitId:h})}})}_collect(t,a,n){const o=new i.ObjectMatrix;this._copyInfo={unitId:t,subUnitId:a,matrix:o};const r=this._injector.invoke(l=>N.rangeToDiscreteRange(n,l,t,a));if(!r)return;const{rows:s,cols:d}=r;s.forEach((l,u)=>{d.forEach((h,m)=>{const c=this._sheetDataValidationModel.getRuleIdByLocation(t,a,l,h);o.setValue(u,m,c!=null?c:"")})})}_generateMutations(t,a){if(!this._copyInfo)return{redos:[],undos:[]};if(a.copyType===N.COPY_TYPE.CUT)return this._copyInfo=null,{redos:[],undos:[]};if(!this._copyInfo||!this._copyInfo.matrix.getSizeOf()||!a.copyRange)return{redos:[],undos:[]};if([N.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_COL_WIDTH,N.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_VALUE,N.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMAT,N.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMULA].includes(a.pasteType))return{redos:[],undos:[]};const{unitId:n,subUnitId:o}=this._copyInfo;if(a.unitId!==n||o!==a.subUnitId){const r=this._sheetDataValidationModel.getRuleObjectMatrix(a.unitId,a.subUnitId).clone(),s=new i.ObjectMatrix,d=new Set,{ranges:[l,u],mapFunc:h}=N.virtualizeDiscreteRanges([a.copyRange,t]),m=N.getRepeatRange(l,u,!0),c=new Map;m.forEach(({startRange:y})=>{var S;(S=this._copyInfo)==null||S.matrix.forValue((R,D,b)=>{const _=i.Rectangle.getPositionRange({startRow:R,endRow:R,startColumn:D,endColumn:D},y),C=`${o}-${b}`,v=this._sheetDataValidationModel.getRuleById(n,o,b);!this._sheetDataValidationModel.getRuleById(a.unitId,a.subUnitId,C)&&v&&c.set(C,{...v,uid:C});const{row:M,col:A}=h(_.startRow,_.startColumn);d.add(C),s.setValue(M,A,C)})});const I=Array.from(d).map(y=>({id:y,ranges:i.queryObjectMatrix(s,S=>S===y)}));r.addRangeRules(I);const{redoMutations:g,undoMutations:f}=w.getDataValidationDiffMutations(a.unitId,a.subUnitId,r.diffWithAddition(this._sheetDataValidationModel.getRules(a.unitId,a.subUnitId),c.values()),this._injector,"patched",!1);return{redos:g,undos:f}}else{const r=this._sheetDataValidationModel.getRuleObjectMatrix(n,o).clone(),s=new i.ObjectMatrix,d=new Set,{ranges:[l,u],mapFunc:h}=N.virtualizeDiscreteRanges([a.copyRange,t]);N.getRepeatRange(l,u,!0).forEach(({startRange:f})=>{var y;(y=this._copyInfo)==null||y.matrix.forValue((S,R,D)=>{const b=i.Rectangle.getPositionRange({startRow:S,endRow:S,startColumn:R,endColumn:R},f),{row:_,col:C}=h(b.startRow,b.startColumn);s.setValue(_,C,D),d.add(D)})});const c=Array.from(d).map(f=>({id:f,ranges:i.queryObjectMatrix(s,y=>y===f)}));r.addRangeRules(c);const{redoMutations:I,undoMutations:g}=w.getDataValidationDiffMutations(n,o,r.diff(this._sheetDataValidationModel.getRules(n,o)),this._injector,"patched",!1);return{redos:I,undos:g}}}};we=Ia([et(0,N.ISheetClipboardService),et(1,i.Inject(w.SheetDataValidationModel)),et(2,i.Inject(i.Injector))],we);var Ca=Object.defineProperty,Da=Object.getOwnPropertyDescriptor,Ra=(e,t,a,n)=>{for(var o=n>1?void 0:n?Da(t,a):t,r=e.length-1,s;r>=0;r--)(s=e[r])&&(o=(n?s(t,a,o):s(o))||o);return n&&o&&Ca(t,a,o),o},tt=(e,t)=>(a,n)=>t(a,n,e);let Ee=class extends i.Disposable{constructor(e,t,a){super(),this._localeService=e,this._commandService=t,this._sheetPermissionInterceptorBaseController=a,this._commandExecutedListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.beforeCommandExecuted(e=>{e.id===w.AddSheetDataValidationCommand.id&&(this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[Y.WorkbookEditablePermission],rangeTypes:[Y.RangeProtectionPermissionEditPoint],worksheetTypes:[Y.WorksheetEditPermission,Y.WorksheetSetCellStylePermission]})||this._sheetPermissionInterceptorBaseController.haveNotPermissionHandle(this._localeService.t("permission.dialog.setStyleErr"))),e.id===w.UpdateSheetDataValidationRangeCommand.id&&(this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[Y.WorkbookEditablePermission],rangeTypes:[Y.RangeProtectionPermissionEditPoint],worksheetTypes:[Y.WorksheetEditPermission,Y.WorksheetSetCellStylePermission]},e.params.ranges)||this._sheetPermissionInterceptorBaseController.haveNotPermissionHandle(this._localeService.t("permission.dialog.setStyleErr")))}))}};Ee=Ra([tt(0,i.Inject(i.LocaleService)),tt(1,i.ICommandService),tt(2,i.Inject(N.SheetPermissionInterceptorBaseController))],Ee);const kt="data-validation-single",Wt="sheet.menu.data-validation";function ya(e){return{id:Wt,type:X.MenuItemType.SUBITEMS,icon:kt,tooltip:"dataValidation.title",hidden$:X.getMenuHiddenObservable(e,i.UniverInstanceType.UNIVER_SHEET),disabled$:N.getCurrentRangeDisable$(e,{workbookTypes:[Y.WorkbookEditablePermission],worksheetTypes:[Y.WorksheetSetCellStylePermission,Y.WorksheetEditPermission],rangeTypes:[Y.RangeProtectionPermissionEditPoint]})}}function Va(e){return{id:Ce.id,title:"dataValidation.panel.title",type:X.MenuItemType.BUTTON}}function wa(e){return{id:qe.id,title:"dataValidation.panel.add",type:X.MenuItemType.BUTTON}}const Ea={[X.RibbonStartGroup.FORMULAS_INSERT]:{[Wt]:{order:9,menuItemFactory:ya,[Ce.id]:{order:0,menuItemFactory:Va},[qe.id]:{order:1,menuItemFactory:wa}}}};var Ma=Object.defineProperty,ba=Object.getOwnPropertyDescriptor,$t=(e,t,a,n)=>{for(var o=n>1?void 0:n?ba(t,a):t,r=e.length-1,s;r>=0;r--)(s=e[r])&&(o=(n?s(t,a,o):s(o))||o);return n&&o&&Ma(t,a,o),o},J=(e,t)=>(a,n)=>t(a,n,e);const Ht={tr:{size:6,color:"#fe4b4b"}};let Me=class extends i.RxDisposable{constructor(e,t,a,n,o,r,s,d,l,u,h){super(),this._commandService=e,this._menuManagerService=t,this._renderManagerService=a,this._univerInstanceService=n,this._autoHeightController=o,this._dropdownManagerService=r,this._sheetDataValidationModel=s,this._dataValidatorRegistryService=d,this._sheetInterceptorService=l,this._dataValidationCacheService=u,this._editorBridgeService=h,this._initMenu(),this._initDropdown(),this._initViewModelIntercept(),this._initAutoHeight()}_initMenu(){this._menuManagerService.mergeMenu(Ea)}_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:o,row:r,column:s}=t,d=this._univerInstanceService.getUniverSheetInstance(n);if(!d)return;const l=this._sheetDataValidationModel.getRuleByLocation(n,o,r,s);if(!l)return;const u=this._dataValidatorRegistryService.getValidatorItem(l.type);if(!(u!=null&&u.dropdown))return;const h=d.getActiveSheet();if(!h)return;const m=this._dropdownManagerService.activeDropdown,c=m==null?void 0:m.location;if(c&&c.unitId===n&&c.subUnitId===o&&c.row===r&&c.col===s)return;this._dropdownManagerService.showDropdown({location:{unitId:n,subUnitId:o,row:r,col:s,workbook:d,worksheet:h},componentKey:u.dropdown,onHide:()=>{},trigger:"editor-bridge"},!1)}}))}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(Y.INTERCEPTOR_POINT.CELL_CONTENT,{effect:i.InterceptorEffectEnum.Style,priority:Y.InterceptCellContentPriority.DATA_VALIDATION,handler:(e,t,a)=>{var S,R,D,b,_;const{row:n,col:o,unitId:r,subUnitId:s,workbook:d,worksheet:l}=t,u=this._sheetDataValidationModel.getRuleIdByLocation(r,s,n,o);if(!u)return a(e);const h=this._sheetDataValidationModel.getRuleById(r,s,u);if(!h)return a(e);const m=(S=this._dataValidationCacheService.getValue(r,s,n,o))!=null?S:i.DataValidationStatus.VALID,c=this._dataValidatorRegistryService.getValidatorItem(h.type),I=t.rawData;let g;const f={get value(){var C;return g!==void 0||(g=(C=w.getCellValueOrigin(I))!=null?C:null),g}},y={get value(){var C;return`${(C=f.value)!=null?C:""}`}};return a({...e,markers:{...e==null?void 0:e.markers,...m===i.DataValidationStatus.INVALID?Ht:null},customRender:[...(R=e==null?void 0:e.customRender)!=null?R:[],...c!=null&&c.canvasRender?[c.canvasRender]:[]],fontRenderExtension:{...e==null?void 0:e.fontRenderExtension,isSkip:((D=e==null?void 0:e.fontRenderExtension)==null?void 0:D.isSkip)||((b=c==null?void 0:c.skipDefaultFontRender)==null?void 0:b.call(c,h,f.value,t))},interceptorStyle:{...e==null?void 0:e.interceptorStyle,...c==null?void 0:c.getExtraStyle(h,y.value,{get style(){const C=d.getStyles();return(typeof(e==null?void 0:e.s)=="string"?C.get(e==null?void 0:e.s):e==null?void 0:e.s)||{}}},n,o)},interceptorAutoHeight:()=>{var A,W,F,L,P,x;const C=(W=(A=this._renderManagerService.getRenderById(r))==null?void 0:A.with(N.SheetSkeletonManagerService).getWorksheetSkeleton(s))==null?void 0:W.skeleton;if(!C)return;const v=C.worksheet.getMergedCell(n,o),M={data:e,style:C.getsStyles().getStyleByCell(e),primaryWithCoord:C.getCellWithCoordByIndex((F=v==null?void 0:v.startRow)!=null?F:n,(L=v==null?void 0:v.startColumn)!=null?L:o),unitId:r,subUnitId:s,row:n,col:o,workbook:d,worksheet:l};return(x=(P=c==null?void 0:c.canvasRender)==null?void 0:P.calcCellAutoHeight)==null?void 0:x.call(P,M)},interceptorAutoWidth:()=>{var A,W,F,L,P,x;const C=(W=(A=this._renderManagerService.getRenderById(r))==null?void 0:A.with(N.SheetSkeletonManagerService).getWorksheetSkeleton(s))==null?void 0:W.skeleton;if(!C)return;const v=C.worksheet.getMergedCell(n,o),M={data:e,style:C.getsStyles().getStyleByCell(e),primaryWithCoord:C.getCellWithCoordByIndex((F=v==null?void 0:v.startRow)!=null?F:n,(L=v==null?void 0:v.startColumn)!=null?L:o),unitId:r,subUnitId:s,row:n,col:o,workbook:d,worksheet:l};return(x=(P=c==null?void 0:c.canvasRender)==null?void 0:P.calcCellAutoWidth)==null?void 0:x.call(P,M)},coverable:((_=e==null?void 0:e.coverable)!=null?_:!0)&&!(h.type===i.DataValidationType.LIST||h.type===i.DataValidationType.LIST_MULTIPLE)})}}))}_initAutoHeight(){this._sheetDataValidationModel.ruleChange$.pipe(le.filter(e=>e.source==="command"),le.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);i.sequenceExecute(a.redos,this._commandService)}})}};Me=$t([J(0,i.ICommandService),J(1,X.IMenuManagerService),J(2,B.IRenderManagerService),J(3,i.IUniverInstanceService),J(4,i.Inject(N.AutoHeightController)),J(5,i.Inject(ge)),J(6,i.Inject(w.SheetDataValidationModel)),J(7,i.Inject(Q.DataValidatorRegistryService)),J(8,i.Inject(Y.SheetInterceptorService)),J(9,i.Inject(w.DataValidationCacheService)),J(10,i.Optional(N.IEditorBridgeService))],Me);let Rt=class extends i.RxDisposable{constructor(e,t,a,n,o,r,s){super(),this._commandService=e,this._renderManagerService=t,this._autoHeightController=a,this._dataValidatorRegistryService=n,this._sheetInterceptorService=o,this._sheetDataValidationModel=r,this._dataValidationCacheService=s,this._initViewModelIntercept(),this._initAutoHeight()}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(Y.INTERCEPTOR_POINT.CELL_CONTENT,{effect:i.InterceptorEffectEnum.Style,priority:Y.InterceptCellContentPriority.DATA_VALIDATION,handler:(e,t,a)=>{var y,S,R,D,b;const{row:n,col:o,unitId:r,subUnitId:s,workbook:d,worksheet:l}=t,u=this._sheetDataValidationModel.getRuleIdByLocation(r,s,n,o);if(!u)return a(e);const h=this._sheetDataValidationModel.getRuleById(r,s,u);if(!h)return a(e);const m=(y=this._dataValidationCacheService.getValue(r,s,n,o))!=null?y:i.DataValidationStatus.VALID,c=this._dataValidatorRegistryService.getValidatorItem(h.type),I=l.getCellRaw(n,o),g=w.getCellValueOrigin(I),f=`${g!=null?g:""}`;return a({...e,markers:{...e==null?void 0:e.markers,...m===i.DataValidationStatus.INVALID?Ht:null},customRender:[...(S=e==null?void 0:e.customRender)!=null?S:[],...c!=null&&c.canvasRender?[c.canvasRender]:[]],fontRenderExtension:{...e==null?void 0:e.fontRenderExtension,isSkip:((R=e==null?void 0:e.fontRenderExtension)==null?void 0:R.isSkip)||((D=c==null?void 0:c.skipDefaultFontRender)==null?void 0:D.call(c,h,g,t))},interceptorStyle:{...e==null?void 0:e.interceptorStyle,...c==null?void 0:c.getExtraStyle(h,f,{get style(){const _=d.getStyles();return(typeof(e==null?void 0:e.s)=="string"?_.get(e==null?void 0:e.s):e==null?void 0:e.s)||{}}},n,o)},interceptorAutoHeight:()=>{var M,A,W,F,L,P;const _=(A=(M=this._renderManagerService.getRenderById(r))==null?void 0:M.with(N.SheetSkeletonManagerService).getWorksheetSkeleton(s))==null?void 0:A.skeleton;if(!_)return;const C=_.worksheet.getMergedCell(n,o),v={data:e,style:_.getsStyles().getStyleByCell(e),primaryWithCoord:_.getCellWithCoordByIndex((W=C==null?void 0:C.startRow)!=null?W:n,(F=C==null?void 0:C.startColumn)!=null?F:o),unitId:r,subUnitId:s,row:n,col:o,workbook:d,worksheet:l};return(P=(L=c==null?void 0:c.canvasRender)==null?void 0:L.calcCellAutoHeight)==null?void 0:P.call(L,v)},coverable:((b=e==null?void 0:e.coverable)!=null?b:!0)&&!(h.type===i.DataValidationType.LIST||h.type===i.DataValidationType.LIST_MULTIPLE)})}}))}_initAutoHeight(){this._sheetDataValidationModel.ruleChange$.pipe(le.filter(e=>e.source==="command"),le.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);i.sequenceExecute(a.redos,this._commandService)}})}};Rt=$t([J(0,i.ICommandService),J(1,B.IRenderManagerService),J(2,i.Inject(N.AutoHeightController)),J(3,i.Inject(Q.DataValidatorRegistryService)),J(4,i.Inject(Y.SheetInterceptorService)),J(5,i.Inject(w.SheetDataValidationModel)),J(6,i.Inject(w.DataValidationCacheService))],Rt);var Oa=Object.defineProperty,Ta=Object.getOwnPropertyDescriptor,La=(e,t,a,n)=>{for(var o=n>1?void 0:n?Ta(t,a):t,r=e.length-1,s;r>=0;r--)(s=e[r])&&(o=(n?s(t,a,o):s(o))||o);return n&&o&&Oa(t,a,o),o},yt=(e,t)=>(a,n)=>t(a,n,e);let $e=class extends i.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(o=>{a.add(o.subUnitId)}),a.forEach(o=>{var r;(r=this._sheetSkeletonManagerService.getWorksheetSkeleton(o))==null||r.skeleton.makeDirty(!0)}),(n=this._context.mainComponent)==null||n.makeForceDirty()};this.disposeWithMe(this._sheetDataValidationModel.validStatusChange$.pipe(i.bufferDebounceTime(16)).subscribe(e))}};$e=La([yt(1,i.Inject(w.SheetDataValidationModel)),yt(2,i.Inject(N.SheetSkeletonManagerService))],$e);const Pa="univer-data-validation-formula",ja="univer-data-validation-formula-and",Aa="univer-data-validation-formula-list-item",Fa="univer-data-validation-formula-list-item-icon",xa="univer-data-validation-formula-list-item-drag",Ua="univer-data-validation-formula-list-add",Na="univer-data-validation-formula-color-select",Ba="univer-data-validation-formula-color-select-panel",ka="univer-data-validation-formula-color-item",ae={dataValidationFormula:Pa,dataValidationFormulaAnd:ja,dataValidationFormulaListItem:Aa,dataValidationFormulaListItemIcon:Fa,dataValidationFormulaListItemDrag:xa,dataValidationFormulaListAdd:Ua,dataValidationFormulaColorSelect:Na,dataValidationFormulaColorSelectPanel:Ba,dataValidationFormulaColorItem:ka},Wa=e=>{const{isTwoFormula:t=!1,value:a,onChange:n,showError:o,validResult:r}=e,s=i.useDependency(i.LocaleService),d=o?r==null?void 0:r.formula1:"",l=o?r==null?void 0:r.formula2:"";return t?p.jsxs(p.Fragment,{children:[p.jsx(O.FormLayout,{error:d,children:p.jsx(O.Input,{className:ae.dataValidationFormula,placeholder:s.t("dataValidation.panel.formulaPlaceholder"),value:a==null?void 0:a.formula1,onChange:u=>{n==null||n({...a,formula1:u})}})}),p.jsx("div",{className:ae.dataValidationFormulaAnd,children:s.t("dataValidation.panel.formulaAnd")}),p.jsx(O.FormLayout,{error:l,children:p.jsx(O.Input,{className:ae.dataValidationFormula,placeholder:s.t("dataValidation.panel.formulaPlaceholder"),value:a==null?void 0:a.formula2,onChange:u=>{n==null||n({...a,formula2:u})}})})]}):p.jsx(O.FormLayout,{error:d,children:p.jsx(O.Input,{className:ae.dataValidationFormula,placeholder:s.t("dataValidation.panel.formulaPlaceholder"),value:a==null?void 0:a.formula1,onChange:u=>{n==null||n({formula1:u})}})})};function $a(e){const{value:t,onChange:a,showError:n,validResult:o}=e,r=i.useDependency(i.LocaleService),s=n?o==null?void 0:o.formula1:"",d=n?o==null?void 0:o.formula2:"",[l,u]=V.useState(!((t==null?void 0:t.formula1)===void 0&&(t==null?void 0:t.formula2)===void 0));return p.jsxs(p.Fragment,{children:[p.jsx(O.FormLayout,{children:p.jsx(O.Checkbox,{checked:l,onChange:h=>{h?u(!0):(u(!1),a==null||a({...t,formula1:void 0,formula2:void 0}))},children:r.t("dataValidation.checkbox.tips")})}),l?p.jsx(O.FormLayout,{label:r.t("dataValidation.checkbox.checked"),error:s,children:p.jsx(O.Input,{className:ae.dataValidationFormula,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?p.jsx(O.FormLayout,{label:r.t("dataValidation.checkbox.unchecked"),error:d,children:p.jsx(O.Input,{className:ae.dataValidationFormula,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 Ha(e){var m;const{unitId:t,subUnitId:a,value:n,onChange:o,showError:r,validResult:s}=e,d=r?s==null?void 0:s.formula1:void 0,l=V.useRef({}),[u,h]=V.useState(!1);return X.useSidebarClick(c=>{var g;const I=(g=l.current)==null?void 0:g.handleOutClick;I&&I(c,()=>h(!1))}),p.jsx(mt.FormulaEditor,{initValue:(m=n==null?void 0:n.formula1)!=null?m:"",unitId:t,subUnitId:a,isFocus:u,onChange:c=>{const I=(c!=null?c:"").trim();I!==(n==null?void 0:n.formula1)&&(o==null||o({...n,formula1:I}))},errorText:d,onFocus:()=>h(!0),actions:l.current,isSupportAcrossSheet:!0})}function Yt(e){var t,a,n="";if(typeof e=="string"||typeof e=="number")n+=e;else if(typeof e=="object")if(Array.isArray(e)){var o=e.length;for(t=0;t<o;t++)e[t]&&(a=Yt(e[t]))&&(n&&(n+=" "),n+=a)}else for(a in e)e[a]&&(n&&(n+=" "),n+=a);return n}function Ya(){for(var e,t,a=0,n="",o=arguments.length;a<o;a++)(e=arguments[a])&&(t=Yt(e))&&(n&&(n+=" "),n+=t);return n}const Xa=["#FFFFFF","#FEE7E7","#FEF0E6","#EFFBD0","#E4F4FE","#E8ECFD","#F1EAFA","#FDE8F3","#E5E5E5","#FDCECE","#FDC49B","#DEF6A2","#9FDAFF","#D0D9FB","#E3D5F6","#FBD0E8","#656565","#FE4B4B","#FF8C51","#8BBB11","#0B9EFB","#3A60F7","#9E6DE3","#F248A6"],za=e=>{const{value:t,onChange:a,disabled:n}=e,[o,r]=V.useState(!1);return p.jsx(O.Select,{disabled:n,open:o,onDropdownVisibleChange:r,dropdownStyle:{width:112},style:{width:96,cursor:"pointer"},className:ae.dataValidationFormulaColorSelect,value:t,onChange:a,labelRender:s=>p.jsx("div",{className:ae.dataValidationFormulaColorItem,style:{background:s.value,marginTop:5}}),dropdownRender:()=>p.jsx("div",{className:ae.dataValidationFormulaColorSelectPanel,children:Xa.map(s=>p.jsx("div",{onClick:()=>{a(s),r(!1)},className:ae.dataValidationFormulaColorItem,style:{background:s}},s))})})},Vt=e=>{const{item:t,commonProps:a,style:n}=e,{onItemChange:o,onItemDelete:r}=a;return p.jsxs("div",{className:ae.dataValidationFormulaListItem,style:n,children:[t.isRef?null:p.jsx("div",{className:Ya(ae.dataValidationFormulaListItemDrag,"draggableHandle"),children:p.jsx(Ft,{})}),p.jsx(za,{value:t.color,onChange:s=>{o(t.id,t.label,s)}}),p.jsx(O.Input,{disabled:t.isRef,value:t.label,onChange:s=>{o(t.id,s,t.color)}}),t.isRef?null:p.jsx("div",{className:ae.dataValidationFormulaListItemIcon,children:p.jsx(gt,{onClick:()=>r(t.id)})})]})};function Ka(e){const{value:t,onChange:a=()=>{},unitId:n,subUnitId:o,validResult:r,showError:s,ruleId:d}=e,{formula1:l="",formula2:u=""}=t||{},h=V.useRef(null),[m,c]=V.useState(()=>i.isFormulaString(l)?"1":"0"),[I,g]=V.useState(m==="1"?l:"="),[f,y]=V.useState(m==="1"?l:"="),S=i.useDependency(i.LocaleService),R=i.useDependency(Q.DataValidatorRegistryService),D=i.useDependency(Q.DataValidationModel),b=i.useDependency(w.DataValidationFormulaController),[_,C]=V.useState(()=>u.split(",")),v=R.getValidatorItem(i.DataValidationType.LIST),[M,A]=V.useState([]),[W,F]=V.useState(""),L=s?r==null?void 0:r.formula1:"",P=V.useMemo(()=>D.ruleChange$.pipe(le.debounceTime(16)),[]),x=X.useObservable(P),U=X.useEvent(a);V.useEffect(()=>{(async()=>{await new Promise(H=>{setTimeout(()=>H(!0),100)});const E=D.getRuleById(n,o,d),k=E==null?void 0:E.formula1;if(i.isFormulaString(k)&&v&&E){const H=await v.getListAsync(E,n,o);A(H)}})()},[D,x,v,d,o,n]),V.useEffect(()=>{i.isFormulaString(l)&&l!==f&&(g(l),y(f))},[f,l]);const[$,G]=V.useState(()=>{const E=m!=="1"?w.deserializeListOptions(l):[],k=u.split(",");return E.map((H,z)=>({label:H,color:k[z]||Ie,isRef:!1,id:i.Tools.generateRandomId(4)}))}),q=(E,k,H)=>{const z=$.find(me=>me.id===E);z&&(z.label=k,z.color=H,G([...$]))},K=E=>{const k=$.findIndex(H=>H.id===E);k!==-1&&($.splice(k,1),G([...$]))},Z=u.split(","),ee=V.useMemo(()=>M.map((E,k)=>({label:E,color:Z[k]||Ie,id:`${k}`,isRef:!0})),[Z,M]),te=(E,k,H)=>{const z=[..._];z[+E]=H,C(z),U({formula1:l,formula2:z.join(",")})},ne=()=>{G([...$,{label:"",color:Ie,isRef:!1,id:i.Tools.generateRandomId(4)}])};V.useEffect(()=>{if(m==="1")return;const E=new Set,k=[];$.map(H=>({labelList:H.label.split(","),item:H})).forEach(({item:H,labelList:z})=>{z.forEach(me=>{E.has(me)||(E.add(me),k.push({label:me,color:H.color}))})}),U({formula1:w.serializeListOptions(k.map(H=>H.label)),formula2:k.map(H=>H.color===Ie?"":H.color).join(",")})},[$,U,m,f,_]);const ie=V.useMemo(()=>async E=>{if(!i.isFormulaString(E)){U==null||U({formula1:"",formula2:u});return}b.getFormulaRefCheck(E)?(U==null||U({formula1:i.isFormulaString(E)?E:"",formula2:u}),F("")):(U==null||U({formula1:"",formula2:u}),g("="),F(S.t("dataValidation.validFail.formulaError")))},[u,U]),oe=V.useRef({}),[re,j]=V.useState(!1);return X.useSidebarClick(E=>{var H;const k=(H=oe.current)==null?void 0:H.handleOutClick;k&&k(E,()=>j(!1))}),p.jsxs(p.Fragment,{children:[p.jsx(O.FormLayout,{label:S.t("dataValidation.list.options"),children:p.jsxs(O.RadioGroup,{value:m,onChange:E=>{c(E),g(f),E==="1"&&U({formula1:f==="="?"":f,formula2:_.join(",")})},children:[p.jsx(O.Radio,{value:"0",children:S.t("dataValidation.list.customOptions")}),p.jsx(O.Radio,{value:"1",children:S.t("dataValidation.list.refOptions")})]})}),m==="1"?p.jsxs(p.Fragment,{children:[p.jsx(mt.FormulaEditor,{initValue:I,unitId:n,subUnitId:o,isFocus:re,onChange:(E="")=>{const k=(E!=null?E:"").trim();y(k),ie(k)},errorText:L||W||void 0,onFocus:()=>j(!0),actions:oe.current,isSupportAcrossSheet:!0}),p.jsx("div",{ref:h,style:{marginTop:"12px"},children:ee.map(E=>p.jsx(Vt,{item:E,commonProps:{onItemChange:te},style:{marginBottom:12}},E.id))})]}):p.jsx(O.FormLayout,{error:L,children:p.jsxs("div",{ref:h,style:{marginTop:"-12px"},children:[p.jsx(O.DraggableList,{list:$,onListChange:G,rowHeight:32,margin:[0,12],draggableHandle:".draggableHandle",itemRender:E=>p.jsx(Vt,{item:E,commonProps:{onItemChange:q,onItemDelete:K}},E.id),idKey:"id"}),p.jsxs("a",{className:ae.dataValidationFormulaListAdd,onClick:ne,children:[p.jsx(Pt,{}),S.t("dataValidation.list.add")]})]})})]})}const Xt="data-validation.custom-formula-input",Ze="data-validation.formula-input",It="data-validation.list-formula-input",zt="data-validation.checkbox-formula-input",Ga=[[Xt,Ha],[Ze,Wa],[It,Ka],[zt,$a]],qa="LIST_RENDER_MODE_OPTION_INPUT";function He(e){var o;const{value:t,onChange:a}=e,n=i.useDependency(i.LocaleService);return p.jsx(O.FormLayout,{label:n.t("dataValidation.renderMode.label"),children:p.jsxs(O.RadioGroup,{value:`${(o=t.renderMode)!=null?o:i.DataValidationRenderMode.CUSTOM}`,onChange:r=>a({...t,renderMode:+r}),children:[p.jsx(O.Radio,{value:`${i.DataValidationRenderMode.CUSTOM}`,children:n.t("dataValidation.renderMode.chip")}),p.jsx(O.Radio,{value:`${i.DataValidationRenderMode.ARROW}`,children:n.t("dataValidation.renderMode.arrow")}),p.jsx(O.Radio,{value:`${i.DataValidationRenderMode.TEXT}`,children:n.t("dataValidation.renderMode.text")})]})})}He.componentKey=qa;const Za="DATE_SHOW_TIME_OPTION";function Ye(e){var o;const{value:t,onChange:a}=e,n=i.useDependency(i.LocaleService);return p.jsx(O.FormLayout,{children:p.jsx(O.Checkbox,{checked:(o=t.bizInfo)==null?void 0:o.showTime,onChange:r=>{a({...t,bizInfo:{...t.bizInfo,showTime:r}})},children:n.t("dataValidation.showTime.label")})})}Ye.componentKey=Za;var Ja=Object.defineProperty,Qa=Object.getOwnPropertyDescriptor,eo=(e,t,a,n)=>{for(var o=n>1?void 0:n?Qa(t,a):t,r=e.length-1,s;r>=0;r--)(s=e[r])&&(o=(n?s(t,a,o):s(o))||o);return n&&o&&Ja(t,a,o),o},Te=(e,t)=>(a,n)=>t(a,n,e);const xe=6;let ct=class{constructor(e,t,a,n,o){this._commandService=e,this._formulaService=t,this._themeService=a,this._renderManagerService=n,this._dataValidationModel=o}_calc(e,t){var u,h,m;const{vt:a,ht:n}=t||{},o=e.endX-e.startX-xe*2,r=e.endY-e.startY,s=((u=t==null?void 0:t.fs)!=null?u:10)*1.6;let d=0,l=0;switch(a){case i.VerticalAlign.TOP:l=0;break;case i.VerticalAlign.BOTTOM:l=0+(r-s);break;default:l=0+(r-s)/2;break}switch(n){case i.HorizontalAlign.LEFT:d=xe;break;case i.HorizontalAlign.RIGHT:d=xe+(o-s);break;default:d=xe+(o-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:((m=t==null?void 0:t.fs)!=null?m: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 u,h,m,c,I,g,f,y,S;const{formula1:n=w.CHECKBOX_FORMULA_1,formula2:o=w.CHECKBOX_FORMULA_2}=e,r=await this._formulaService.getRuleFormulaResult(t,a,e.uid),s=w.getFormulaResult((m=(h=(u=r==null?void 0:r[0])==null?void 0:u.result)==null?void 0:h[0])==null?void 0:m[0]),d=w.getFormulaResult((g=(I=(c=r==null?void 0:r[1])==null?void 0:c.result)==null?void 0:I[0])==null?void 0:g[0]),l=w.isLegalFormulaResult(String(s))&&w.isLegalFormulaResult(String(d));return{formula1:i.isFormulaString(n)?w.getFormulaResult((S=(y=(f=r==null?void 0:r[0])==null?void 0:f.result)==null?void 0:y[0])==null?void 0:S[0]):n,formula2:i.isFormulaString(o)?d:o,isFormulaValid:l}}drawWith(e,t){var L,P,x,U;const{style:a,primaryWithCoord:n,unitId:o,subUnitId:r,worksheet:s,row:d,col:l}=t,u=n.isMergedMainCell?n.mergeInfo:n,h=w.getCellValueOrigin(s.getCellRaw(d,l)),m=this._dataValidationModel.getRuleByLocation(o,r,d,l);if(!m)return;const c=this._dataValidationModel.getValidator(m.type);if(!c)return;const I=this._themeService.getCurrentTheme();if(!((L=c.skipDefaultFontRender)!=null&&L.call(c,m,h,{unitId:o,subUnitId:r,row:d,column:l})))return;const g=c.parseFormulaSync(m,o,r),{formula1:f}=g,y=this._calc(u,a),{a:S,d:R}=e.getTransform(),D=B.fixLineWidthByScale(y.left,S),b=B.fixLineWidthByScale(y.top,R),_=B.Transform.create().composeMatrix({left:D,top:b,scaleX:1,scaleY:1,angle:0,skewX:0,skewY:0,flipX:!1,flipY:!1}),C=u.endX-u.startX,v=u.endY-u.startY;e.save(),e.beginPath(),e.rect(u.startX,u.startY,C,v),e.clip();const M=_.getMatrix();e.transform(M[0],M[1],M[2],M[3],M[4],M[5]);const A=((P=a==null?void 0:a.fs)!=null?P:10)*1.6,W=String(h)===String(f),F=I.hyacinth500;B.Checkbox.drawWith(e,{checked:W,width:A,height:A,fill:(U=(x=a==null?void 0:a.cl)==null?void 0:x.rgb)!=null?U:F}),e.restore()}isHit(e,t){const a=t.primaryWithCoord.isMergedMainCell?t.primaryWithCoord.mergeInfo:t.primaryWithCoord,n=this._calc(a,t.style),o=n.top,r=n.top+n.height,s=n.left,d=n.left+n.width,{x:l,y:u}=e;return l<=d&&l>=s&&u<=r&&u>=o}async onPointerDown(e,t){var g;if(t.button===2)return;const{primaryWithCoord:a,unitId:n,subUnitId:o,worksheet:r,row:s,col:d}=e,l=w.getCellValueOrigin(r.getCellRaw(s,d)),u=this._dataValidationModel.getRuleByLocation(n,o,s,d);if(!u)return;const h=this._dataValidationModel.getValidator(u.type);if(!h||!((g=h.skipDefaultFontRender)!=null&&g.call(h,u,l,{unitId:n,subUnitId:o,row:s,column:d})))return;const{formula1:m,formula2:c}=await this._parseFormula(u,n,o),I={range:{startColumn:a.actualColumn,endColumn:a.actualColumn,startRow:a.actualRow,endRow:a.actualRow},value:{v:String(l)===w.transformCheckboxValue(String(m))?c:m,p:null}};this._commandService.executeCommand(Y.SetRangeValuesCommand.id,I)}onPointerEnter(e,t){var a,n;(n=(a=this._renderManagerService.getCurrentTypeOfRenderer(i.UniverInstanceType.UNIVER_SHEET))==null?void 0:a.mainComponent)==null||n.setCursor(B.CURSOR_TYPE.POINTER)}onPointerLeave(e,t){var a,n;(n=(a=this._renderManagerService.getCurrentTypeOfRenderer(i.UniverInstanceType.UNIVER_SHEET))==null?void 0:a.mainComponent)==null||n.setCursor(B.CURSOR_TYPE.DEFAULT)}};ct=eo([Te(0,i.ICommandService),Te(1,i.Inject(w.DataValidationFormulaService)),Te(2,i.Inject(i.ThemeService)),Te(3,i.Inject(B.IRenderManagerService)),Te(4,i.Inject(w.SheetDataValidationModel))],ct);var to=Object.defineProperty,no=Object.getOwnPropertyDescriptor,ao=(e,t,a,n)=>{for(var o=n>1?void 0:n?no(t,a):t,r=e.length-1,s;r>=0;r--)(s=e[r])&&(o=(n?s(t,a,o):s(o))||o);return n&&o&&to(t,a,o),o},oo=(e,t)=>(a,n)=>t(a,n,e);let he=class{constructor(e){T(this,"canvasRender",null);T(this,"dropdown");T(this,"optionsInput");T(this,"formulaInput",It);this.injector=e}};he=ao([oo(0,i.Inject(i.Injector))],he);class io extends he{constructor(){super(...arguments);T(this,"id",i.DataValidationType.CHECKBOX);T(this,"canvasRender",this.injector.createInstance(ct));T(this,"formulaInput",zt)}}class ro extends he{constructor(){super(...arguments);T(this,"id",i.DataValidationType.CUSTOM);T(this,"formulaInput",Xt)}}const so="data-validation.formula-input";class lo extends he{constructor(){super(...arguments);T(this,"id",i.DataValidationType.DATE);T(this,"formulaInput",so);T(this,"optionsInput",Ye.componentKey);T(this,"dropdown",_t)}}class co extends he{constructor(){super(...arguments);T(this,"id",i.DataValidationType.DECIMAL);T(this,"formulaInput",Ze)}}const Kt=4,uo=0,nt=4,Gt=4,ut=6,Xe=6,_e=14;function ho(e,t){const a=B.FontCache.getTextSize(e,t),n=a.width+Kt*2,{ba:o,bd:r}=a,s=o+r;return{width:n,height:s+uo*2,ba:o}}function at(e,t,a,n){const o=_e+ut*2,r=a-o,s=n-Xe*2,d=e.map(c=>({layout:ho(c,t),text:c}));let l;const u=[];d.forEach(c=>{const{layout:I}=c,{width:g,height:f}=I;!l||l.width+g+nt>r?(l={width:g,height:f,items:[{...c,left:0}]},u.push(l)):(l.items.push({...c,left:l.width+nt}),l.width=l.width+g+nt)});let h=0,m=0;return u.forEach((c,I)=>{m=Math.max(m,c.width),I===u.length-1?h+=c.height:h+=c.height+Gt}),{lines:u,totalHeight:h,contentWidth:r,contentHeight:s,cellAutoHeight:h+Xe*2,calcAutoWidth:m+o}}const po=8;class mo extends B.Shape{static drawWith(t,a){const{fontString:n,info:o,fill:r,color:s}=a,{layout:d,text:l}=o;t.save(),B.Rect.drawWith(t,{width:d.width,height:d.height,radius:po,fill:r||Ie}),t.translateWithPrecision(Kt,d.ba),t.font=n,t.fillStyle=s,t.fillText(l,0,0),t.restore()}}var go=Object.defineProperty,fo=Object.getOwnPropertyDescriptor,vo=(e,t,a,n)=>{for(var o=n>1?void 0:n?fo(t,a):t,r=e.length-1,s;r>=0;r--)(s=e[r])&&(o=(n?s(t,a,o):s(o))||o);return n&&o&&go(t,a,o),o},ot=(e,t)=>(a,n)=>t(a,n,e);const So=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 ht=class{constructor(e,t,a){T(this,"zIndex");T(this,"_dropdownInfoMap",new Map);this._commandService=e,this._renderManagerService=t,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,a,n,o){const r=a-_e+4;let s=4;switch(o){case i.VerticalAlign.MIDDLE:s=(n-_e)/2+4;break;case i.VerticalAlign.BOTTOM:s=n-_e+4;break}e.save(),e.translateWithPrecision(t.startX+r,t.startY+s),e.fillStyle="#565656",e.fill(So),e.restore()}drawWith(e,t,a,n){var q,K;const{primaryWithCoord:o,row:r,col:s,style:d,data:l,subUnitId:u}=t,h=o.isMergedMainCell?o.mergeInfo:o,m=l==null?void 0:l.fontRenderExtension,{leftOffset:c=0,rightOffset:I=0,topOffset:g=0,downOffset:f=0}=m||{},y=this._ensureMap(u),S=this._generateKey(r,s),R=this._dataValidationModel.getRuleByLocation(t.unitId,t.subUnitId,r,s);if(!R)return;const D=this._dataValidationModel.getValidator(R.type);if(!D)return;const b={startX:h.startX+c,endX:h.endX-I,startY:h.startY+g,endY:h.endY-f},_=b.endX-b.startX,C=b.endY-b.startY,{cl:v}=d||{},M=(q=typeof v=="object"?v==null?void 0:v.rgb:v)!=null?q:"#000",A=B.getFontStyleString(d!=null?d:void 0),{vt:W,ht:F}=d||{},L=W!=null?W:i.VerticalAlign.MIDDLE,P=(K=w.getCellValueOrigin(l))!=null?K:"",x=D.parseCellValue(P),U=D.getListWithColorMap(R),$=at(x,A,_,C);this._drawDownIcon(e,b,_,C,L),e.save(),e.translateWithPrecision(b.startX,b.startY),e.beginPath(),e.rect(0,0,_-_e,C),e.clip(),e.translateWithPrecision(ut,Xe);let G=0;switch(L){case i.VerticalAlign.MIDDLE:G=($.contentHeight-$.totalHeight)/2;break;case i.VerticalAlign.BOTTOM:G=$.contentHeight-$.totalHeight;break}e.translateWithPrecision(0,G),$.lines.forEach((Z,ee)=>{e.save();const{width:te,height:ne,items:ie}=Z;let oe=0;switch(F){case i.HorizontalAlign.RIGHT:oe=$.contentWidth-te;break;case i.HorizontalAlign.CENTER:oe=($.contentWidth-te)/2;break}e.translate(oe,ee*(ne+Gt)),ie.forEach(re=>{e.save(),e.translateWithPrecision(re.left,0),mo.drawWith(e,{...A,info:re,color:M,fill:U[re.text]}),e.restore()}),e.restore()}),e.restore(),y.set(S,{left:b.startX,top:b.startY,width:$.contentWidth+ut+_e,height:$.contentHeight+Xe*2})}calcCellAutoHeight(e){var _;const{primaryWithCoord:t,style:a,data:n,row:o,col:r}=e,s=n==null?void 0:n.fontRenderExtension,{leftOffset:d=0,rightOffset:l=0,topOffset:u=0,downOffset:h=0}=s||{},m=t.isMergedMainCell?t.mergeInfo:t,c={startX:m.startX+d,endX:m.endX-l,startY:m.startY+u,endY:m.endY-h},I=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,o,r);if(!I)return;const g=this._dataValidationModel.getValidator(I.type);if(!g)return;const f=c.endX-c.startX,y=c.endY-c.startY,S=(_=w.getCellValueOrigin(n))!=null?_:"",R=g.parseCellValue(S),D=B.getFontStyleString(a!=null?a:void 0);return at(R,D,f,y).cellAutoHeight}calcCellAutoWidth(e){var _;const{primaryWithCoord:t,style:a,data:n,row:o,col:r}=e,s=n==null?void 0:n.fontRenderExtension,{leftOffset:d=0,rightOffset:l=0,topOffset:u=0,downOffset:h=0}=s||{},m=t.isMergedMainCell?t.mergeInfo:t,c={startX:m.startX+d,endX:m.endX-l,startY:m.startY+u,endY:m.endY-h},I=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,o,r);if(!I)return;const g=this._dataValidationModel.getValidator(I.type);if(!g)return;const f=c.endX-c.startX,y=c.endY-c.startY,S=(_=w.getCellValueOrigin(n))!=null?_:"",R=g.parseCellValue(S),D=B.getFontStyleString(a!=null?a:void 0);return at(R,D,f,y).calcAutoWidth}isHit(e,t){const{primaryWithCoord:a}=t,n=a.isMergedMainCell?a.mergeInfo:a,{endX:o}=n,{x:r}=e;return r>=o-_e&&r<=o}onPointerDown(e,t){if(t.button===2)return;const{unitId:a,subUnitId:n,row:o,col:r}=e,s={unitId:a,subUnitId:n,row:o,column:r};this._commandService.executeCommand(Ke.id,s)}onPointerEnter(e,t){var a,n;(n=(a=this._renderManagerService.getCurrentTypeOfRenderer(i.UniverInstanceType.UNIVER_SHEET))==null?void 0:a.mainComponent)==null||n.setCursor(B.CURSOR_TYPE.POINTER)}onPointerLeave(e,t){var a,n;(n=(a=this._renderManagerService.getCurrentTypeOfRenderer(i.UniverInstanceType.UNIVER_SHEET))==null?void 0:a.mainComponent)==null||n.setCursor(B.CURSOR_TYPE.DEFAULT)}};ht=vo([ot(0,i.ICommandService),ot(1,i.Inject(B.IRenderManagerService)),ot(2,i.Inject(w.SheetDataValidationModel))],ht);class _o extends he{constructor(){super(...arguments);T(this,"id",i.DataValidationType.LIST_MULTIPLE);T(this,"canvasRender",this.injector.createInstance(ht));T(this,"dropdown",Ge)}}var Io=Object.defineProperty,Co=Object.getOwnPropertyDescriptor,Do=(e,t,a,n)=>{for(var o=n>1?void 0:n?Co(t,a):t,r=e.length-1,s;r>=0;r--)(s=e[r])&&(o=(n?s(t,a,o):s(o))||o);return n&&o&&Io(t,a,o),o},Ue=(e,t)=>(a,n)=>t(a,n,e);const Se=4,Ne=4,de=14,ce=6,ye=4,it=8,Ro="#565656",wt=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 yo(e,t){const a=e.length;return{id:"d",body:{dataStream:`${e}${i.DEFAULT_EMPTY_DOCUMENT_VALUE}`,textRuns:[{ts:{fs:11,ff:void 0,it:i.BooleanNumber.FALSE,bl:i.BooleanNumber.FALSE,ul:{s:i.BooleanNumber.FALSE},st:{s:i.BooleanNumber.FALSE},ol:{s:i.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 qt(e,t,a){const n=yo(e,a),o=new i.DocumentDataModel(n),r=new B.DocumentViewModel(o);return{documentSkeleton:B.DocumentSkeleton.create(r,t),docModel:o,docViewModel:r}}function Be(e,t,a){const{documentSkeleton:n,docModel:o,docViewModel:r}=qt(e,t,a);return{documents:new B.Documents(`DOCUMENTS_${i.Tools.generateRandomId()}`,n,{pageMarginLeft:0,pageMarginTop:0}),documentSkeleton:n,docModel:o,docViewModel:r}}function Et(e,t,a,n,o,r,s=!0){let d=0;const l=s?ye:0;switch(o){case i.VerticalAlign.BOTTOM:d=t-n-l;break;case i.VerticalAlign.MIDDLE:d=(t-n)/2;break;default:d=l;break}d=Math.max(ye,d);let u=0;switch(r){case i.HorizontalAlign.CENTER:u=(e-a)/2;break;case i.HorizontalAlign.RIGHT:u=e-a;break}return u=Math.max(ce,u),{paddingLeft:u,paddingTop:d}}let pt=class{constructor(e,t,a,n){T(this,"_dropdownInfoMap",new Map);T(this,"zIndex");this._localeService=e,this._commandService=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,o,r,s){const{t:d=i.DEFAULT_STYLES.pd.t,b:l=i.DEFAULT_STYLES.pd.b}=s,u=a-de;let h;switch(r){case i.VerticalAlign.MIDDLE:h=(n-Ne)/2;break;case i.VerticalAlign.BOTTOM:h=n-l-o-ye+(o/2-Ne/2);break;default:h=d+ye+(o/2-Ne/2);break}e.save(),e.translateWithPrecision(t.startX+u,t.startY+h),e.fillStyle="#565656",e.fill(wt),e.restore()}drawWith(e,t,a){const{primaryWithCoord:n,row:o,col:r,style:s,data:d,subUnitId:l}=t,u=n.isMergedMainCell?n.mergeInfo:n,h=this._dataValidationModel.getRuleByLocation(t.unitId,t.subUnitId,o,r);if(!h)return;const m=this._dataValidationModel.getValidator(h.type);if(!m)return;const c=d==null?void 0:d.fontRenderExtension,{leftOffset:I=0,rightOffset:g=0,topOffset:f=0,downOffset:y=0}=c||{};if(!h||!m||!m||m.id.indexOf(i.DataValidationType.LIST)!==0||!m.skipDefaultFontRender(h))return;const S={startX:u.startX+I,endX:u.endX-g,startY:u.startY+f,endY:u.endY-y},R=S.endX-S.startX,D=S.endY-S.startY,b=this._ensureMap(l),_=this._generateKey(o,r),C=m.getListWithColor(h),v=w.getCellValueOrigin(d),M=`${v!=null?v:""}`,A=C.find(x=>x.label===M);let{tb:W,vt:F,ht:L,pd:P}=s||{};if(W=W!=null?W:i.WrapStrategy.WRAP,F=F!=null?F:i.VerticalAlign.BOTTOM,L=L!=null?L:i.DEFAULT_STYLES.ht,P=P!=null?P:i.DEFAULT_STYLES.pd,h.renderMode===i.DataValidationRenderMode.ARROW){const{l:x=i.DEFAULT_STYLES.pd.l,t:U=i.DEFAULT_STYLES.pd.t,r:$=i.DEFAULT_STYLES.pd.r,b:G=i.DEFAULT_STYLES.pd.b}=P,q=R-x-$-de-4,{documentSkeleton:K,documents:Z,docModel:ee}=Be(M,this._localeService,s);W===i.WrapStrategy.WRAP&&ee.updateDocumentDataPageSize(Math.max(q,1)),K.calculate(),K.getActualSize();const te=B.getDocsSkeletonPageSize(K),{height:ne,width:ie}=te,{paddingTop:oe,paddingLeft:re}=Et(q,D-U-G,ie,ne,F,L,!0);this._drawDownIcon(e,S,R,D,ne,F,P),e.save(),e.translateWithPrecision(S.startX+x,S.startY+U),e.beginPath(),e.rect(0,0,R-x-$,D-U-G),e.clip(),e.translateWithPrecision(0,oe),e.save(),e.translateWithPrecision(Se,0),e.beginPath(),e.rect(0,0,q,ne),e.clip(),Z.render(e),e.translateWithPrecision(re,0),e.restore(),e.restore(),b.set(_,{left:S.endX+x+a.rowHeaderWidth-de,top:S.startY+U+a.columnHeaderHeight,width:de,height:D-U-G})}else{e.save(),e.translateWithPrecision(S.startX,S.startY),e.beginPath(),e.rect(0,0,R,D),e.clip();const x=R-ce*2-Se-de-4,{documentSkeleton:U,documents:$,docModel:G}=Be(M,this._localeService,s);W===i.WrapStrategy.WRAP&&G.updateDocumentDataPageSize(Math.max(x,1)),U.calculate();const q=B.getDocsSkeletonPageSize(U),{height:K,width:Z}=q,{paddingTop:ee,paddingLeft:te}=Et(x,D,Z,K,F,L);e.translateWithPrecision(ce,ee);const ne=Math.max(R-ce*2,1),ie=K;B.Rect.drawWith(e,{width:ne,height:ie,fill:(A==null?void 0:A.color)||Ie,radius:it}),e.save(),e.translateWithPrecision(Se,0),e.beginPath(),e.rect(0,0,x,K),e.clip(),e.translateWithPrecision(te,0),$.render(e),e.restore(),e.translateWithPrecision(x+Se+4,(K-Ne)/2),e.fillStyle=Ro,e.fill(wt),e.restore(),b.set(_,{left:S.startX+ce+a.rowHeaderWidth,top:S.startY+ee+a.columnHeaderHeight,width:ne,height:ie})}}calcCellAutoHeight(e){const{primaryWithCoord:t,style:a,data:n,row:o,col:r}=e,s=t.isMergedMainCell?t.mergeInfo:t,d=n==null?void 0:n.fontRenderExtension,{leftOffset:l=0,rightOffset:u=0,topOffset:h=0,downOffset:m=0}=d||{},c=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,o,r);if(!c||c.renderMode===i.DataValidationRenderMode.TEXT)return;const I={startX:s.startX+l,endX:s.endX-u,startY:s.startY+h,endY:s.endY-m},g=I.endX-I.startX,f=w.getCellValueOrigin(n),y=`${f!=null?f:""}`;let{tb:S,pd:R}=a||{};const{t:D=i.DEFAULT_STYLES.pd.t,b=i.DEFAULT_STYLES.pd.b}=R!=null?R:{};if(S=S!=null?S:i.WrapStrategy.WRAP,c.renderMode===i.DataValidationRenderMode.ARROW){const _=g-de,{documentSkeleton:C,docModel:v}=Be(y,this._localeService,a);S===i.WrapStrategy.WRAP&&v.updateDocumentDataPageSize(Math.max(_,1)),C.calculate(),C.getActualSize();const M=B.getDocsSkeletonPageSize(C),{height:A}=M;return A+D+b+ye*2}else{const _=g-ce*2-Se-de,{documentSkeleton:C,docModel:v}=qt(y,this._localeService,a);S===i.WrapStrategy.WRAP&&v.updateDocumentDataPageSize(Math.max(_,1)),C.calculate();const M=B.getDocsSkeletonPageSize(C),{height:A}=M;return A+ye*2}}calcCellAutoWidth(e){const{primaryWithCoord:t,style:a,data:n,row:o,col:r}=e,s=t.isMergedMainCell?t.mergeInfo:t,d=n==null?void 0:n.fontRenderExtension,{leftOffset:l=0,rightOffset:u=0,topOffset:h=0,downOffset:m=0}=d||{},c=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,o,r);if(!c||c.renderMode===i.DataValidationRenderMode.TEXT)return;const I={startX:s.startX+l,endX:s.endX-u,startY:s.startY+h,endY:s.endY-m},g=I.endX-I.startX,f=w.getCellValueOrigin(n),y=`${f!=null?f:""}`;let{tb:S,pd:R}=a||{};const{l:D=i.DEFAULT_STYLES.pd.l,r:b=i.DEFAULT_STYLES.pd.r}=R!=null?R:{};S=S!=null?S:i.WrapStrategy.WRAP;let _=ce*2+de;switch(c.renderMode){case i.DataValidationRenderMode.ARROW:_=de+ce*2+b+D;break;case i.DataValidationRenderMode.CUSTOM:_=de+ce*2+Se*2+b+D+it/2+1;break;default:_=de+ce*2+Se*2+b+D+it/2+1}const C=g-_,{documentSkeleton:v,docModel:M}=Be(y,this._localeService,a);return S===i.WrapStrategy.WRAP&&M.updateDocumentDataPageSize(Math.max(C,1)),v.calculate(),v.getActualSize(),B.getDocsSkeletonPageSize(v).width+_}isHit(e,t){const{subUnitId:a,row:n,col:o}=t,s=this._ensureMap(a).get(this._generateKey(n,o)),d=this._dataValidationModel.getRuleByLocation(t.unitId,t.subUnitId,n,o);if(!d||!s||d.renderMode===i.DataValidationRenderMode.TEXT)return!1;const{top:l,left:u,width:h,height:m}=s,{x:c,y:I}=e;return c>=u&&c<=u+h&&I>=l&&I<=l+m}onPointerDown(e,t){if(t.button===2)return;const{unitId:a,subUnitId:n,row:o,col:r}=e,s={unitId:a,subUnitId:n,row:o,column:r};this._commandService.executeCommand(Ke.id,s)}onPointerEnter(e,t){var a,n;(n=(a=this._renderManagerService.getCurrentTypeOfRenderer(i.UniverInstanceType.UNIVER_SHEET))==null?void 0:a.mainComponent)==null||n.setCursor(B.CURSOR_TYPE.POINTER)}onPointerLeave(e,t){var a,n;(n=(a=this._renderManagerService.getCurrentTypeOfRenderer(i.UniverInstanceType.UNIVER_SHEET))==null?void 0:a.mainComponent)==null||n.setCursor(B.CURSOR_TYPE.DEFAULT)}};pt=Do([Ue(0,i.Inject(i.LocaleService)),Ue(1,i.ICommandService),Ue(2,i.Inject(B.IRenderManagerService)),Ue(3,i.Inject(w.SheetDataValidationModel))],pt);class Vo extends he{constructor(){super(...arguments);T(this,"id",i.DataValidationType.LIST);T(this,"canvasRender",this.injector.createInstance(pt));T(this,"dropdown",Ge);T(this,"optionsInput",He.componentKey);T(this,"formulaInput",It)}}class wo extends he{constructor(){super(...arguments);T(this,"id",i.DataValidationType.TEXT_LENGTH);T(this,"formulaInput",Ze)}}class Eo extends he{constructor(){super(...arguments);T(this,"id",i.DataValidationType.WHOLE);T(this,"formulaInput",Ze)}}var Mo=Object.defineProperty,bo=Object.getOwnPropertyDescriptor,Oo=(e,t,a,n)=>{for(var o=n>1?void 0:n?bo(t,a):t,r=e.length-1,s;r>=0;r--)(s=e[r])&&(o=(n?s(t,a,o):s(o))||o);return n&&o&&Mo(t,a,o),o},rt=(e,t)=>(a,n)=>t(a,n,e);let be=class extends i.RxDisposable{constructor(e,t,a){super(),this._injector=e,this._componentManger=t,this._dataValidatorRegistryService=a,this._initComponents(),this._registerValidatorViews()}_initComponents(){[[kt,Lt],[ft,ua],[xt,On],[Ge,Hn],[_t,gn],[He.componentKey,He],[Ye.componentKey,Ye],...Ga].forEach(([e,t])=>{this.disposeWithMe(this._componentManger.register(e,t))})}_registerValidatorViews(){[co,Eo,wo,lo,io,Vo,_o,ro].forEach(e=>{const t=this._injector.createInstance(e),a=this._dataValidatorRegistryService.getValidatorItem(t.id);a&&(a.formulaInput=t.formulaInput,a.canvasRender=t.canvasRender,a.dropdown=t.dropdown,a.optionsInput=t.optionsInput)})}};be=Oo([rt(0,i.Inject(i.Injector)),rt(1,i.Inject(X.ComponentManager)),rt(2,i.Inject(Q.DataValidatorRegistryService))],be);var To=Object.defineProperty,Lo=Object.getOwnPropertyDescriptor,Po=(e,t,a,n)=>{for(var o=n>1?void 0:n?Lo(t,a):t,r=e.length-1,s;r>=0;r--)(s=e[r])&&(o=(n?s(t,a,o):s(o))||o);return n&&o&&To(t,a,o),o},st=(e,t)=>(a,n)=>t(a,n,e);const jo="SHEET_DATA_VALIDATION_UI_PLUGIN";var ke;exports.UniverSheetsDataValidationUIPlugin=(ke=class extends i.Plugin{constructor(t=Bt,a,n,o){super(),this._config=t,this._injector=a,this._commandService=n,this._configService=o;const{menu:r,...s}=this._config;r&&this._configService.setConfig("menu",r,{merge:!0}),this._configService.setConfig(St,s)}onStarting(){[[ue],[ge],[Pe],[Ve],[Me],[Ee],[we],[Le],[be]].forEach(t=>{this._injector.add(t)}),[qe,Ke,Nt,vt,Ce,Ut].forEach(t=>{this._commandService.registerCommand(t)})}onReady(){this._injector.get(we),this._injector.get(Ee),this._injector.get(Le),this._injector.get(Pe),this._injector.get(B.IRenderManagerService).registerRenderModule(i.UniverInstanceType.UNIVER_SHEET,[$e])}onRendered(){this._injector.get(be),this._injector.get(Me)}onSteady(){this._injector.get(Ve)}},T(ke,"pluginName",jo),T(ke,"type",i.UniverInstanceType.UNIVER_SHEET),ke);exports.UniverSheetsDataValidationUIPlugin=Po([st(1,i.Inject(i.Injector)),st(2,i.ICommandService),st(3,i.IConfigService)],exports.UniverSheetsDataValidationUIPlugin);var Ao=Object.defineProperty,Fo=Object.getOwnPropertyDescriptor,xo=(e,t,a,n)=>{for(var o=n>1?void 0:n?Fo(t,a):t,r=e.length-1,s;r>=0;r--)(s=e[r])&&(o=(n?s(t,a,o):s(o))||o);return n&&o&&Ao(t,a,o),o},lt=(e,t)=>(a,n)=>t(a,n,e);const Uo="SHEET_DATA_VALIDATION_UI_PLUGIN";var We;exports.UniverSheetsDataValidationMobileUIPlugin=(We=class extends i.Plugin{constructor(t=Bt,a,n,o){super(),this._config=t,this._injector=a,this._commandService=n,this._configService=o;const{menu:r,...s}=this._config;r&&this._configService.setConfig("menu",r,{merge:!0}),this._configService.setConfig(St,s)}onStarting(){[[ue],[ge],[Pe],[Ve],[Me],[Ee],[we],[be]].forEach(t=>{this._injector.add(t)}),[qe,Ke,Nt,vt,Ce,Ut].forEach(t=>{this._commandService.registerCommand(t)})}onReady(){this._injector.get(we),this._injector.get(Ee),this._injector.get(B.IRenderManagerService).registerRenderModule(i.UniverInstanceType.UNIVER_SHEET,[$e])}onRendered(){this._injector.get(be),this._injector.get(Me)}onSteady(){this._injector.get(Ve)}},T(We,"pluginName",Uo),T(We,"type",i.UniverInstanceType.UNIVER_SHEET),We);exports.UniverSheetsDataValidationMobileUIPlugin=xo([lt(1,i.Inject(i.Injector)),lt(2,i.ICommandService),lt(3,i.IConfigService)],exports.UniverSheetsDataValidationMobileUIPlugin);exports.DATE_DROPDOWN_KEY=_t;exports.LIST_DROPDOWN_KEY=Ge;