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