@univerjs/sheets-data-validation-ui 0.16.1 → 0.17.0

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