@univerjs/sheets-data-validation-ui 0.9.2-nightly.202507151607 → 0.9.2-nightly.202507171607

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 At=Object.defineProperty;var Lt=(e,t,a)=>t in e?At(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a;var A=(e,t,a)=>Lt(e,typeof t!="symbol"?t+"":t,a);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("@univerjs/core"),L=require("@univerjs/engine-render"),H=require("@univerjs/sheets"),_=require("@univerjs/sheets-data-validation"),Y=require("@univerjs/data-validation"),E=require("@univerjs/ui"),oe=require("rxjs"),jt=require("@univerjs/sheets-numfmt"),N=require("@univerjs/sheets-ui"),V=require("@univerjs/design"),b=require("react"),p=require("react/jsx-runtime"),tt=require("@univerjs/engine-formula"),ot=require("@univerjs/sheets-formula-ui");var xt=Object.getOwnPropertyDescriptor,Ut=(e,t,a,n)=>{for(var r=n>1?void 0:n?xt(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},ht=(e,t)=>(a,n)=>t(a,n,e);let he=class extends o.Disposable{constructor(t,a){super();A(this,"_open$",new oe.BehaviorSubject(!1));A(this,"open$",this._open$.pipe(oe.distinctUntilChanged()));A(this,"_activeRule");A(this,"_activeRule$",new oe.BehaviorSubject(void 0));A(this,"activeRule$",this._activeRule$.asObservable());A(this,"_closeDisposable",null);this._univerInstanceService=t,this._sidebarService=a,this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(o.UniverInstanceType.UNIVER_SHEET).pipe(oe.filter(n=>!n)).subscribe(()=>{this.close()})),this.disposeWithMe(this._sidebarService.sidebarOptions$.subscribe(n=>{n.id===Fe&&(n.visible||setTimeout(()=>{this._sidebarService.sidebarOptions$.next({visible:!1})}))}))}get activeRule(){return this._activeRule}get isOpen(){return this._open$.getValue()}dispose(){var t;super.dispose(),this._open$.next(!1),this._open$.complete(),this._activeRule$.complete(),(t=this._closeDisposable)==null||t.dispose()}open(){this._open$.next(!0)}close(){var t;this._open$.next(!1),(t=this._closeDisposable)==null||t.dispose()}setCloseDisposable(t){this._closeDisposable=o.toDisposable(()=>{t.dispose(),this._closeDisposable=null})}setActiveRule(t){this._activeRule=t,this._activeRule$.next(t)}};he=Ut([ht(0,o.IUniverInstanceService),ht(1,E.ISidebarService)],he);const st="sheets-data-validation-ui.config",Ue={};var Ft=Object.getOwnPropertyDescriptor,kt=(e,t,a,n)=>{for(var r=n>1?void 0:n?Ft(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},Ie=(e,t)=>(a,n)=>t(a,n,e);let we=class extends o.Disposable{constructor(e,t,a,n,r,i){super(),this._sheetInterceptorService=e,this._dataValidationModel=t,this._dataValidatorRegistryService=a,this._dialogService=n,this._localeService=r,this._sheetsDataValidationValidatorService=i,this._initEditorBridgeInterceptor()}_initEditorBridgeInterceptor(){this._sheetInterceptorService.writeCellInterceptor.intercept(H.VALIDATE_CELL,{handler:async(e,t,a)=>{const n=await e,{row:r,col:i,unitId:s,subUnitId:d}=t,l=this._dataValidationModel.getRuleIdByLocation(s,d,r,i),c=l?this._dataValidationModel.getRuleById(s,d,l):void 0;if(n===!1)return a(Promise.resolve(!1));if(!c||c.errorStyle!==o.DataValidationErrorStyle.STOP)return a(Promise.resolve(!0));const h=this._dataValidatorRegistryService.getValidatorItem(c.type);return!h||await this._sheetsDataValidationValidatorService.validatorCell(s,d,r,i)===o.DataValidationStatus.VALID?a(Promise.resolve(!0)):(this._dialogService.open({width:368,title:{title:this._localeService.t("dataValidation.alert.title")},id:"reject-input-dialog",children:{title:h.getRuleFinalError(c,{row:r,col:i,unitId:s,subUnitId:d})},footer:{title:b.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")}}),a(Promise.resolve(!1)))}})}showReject(e){this._dialogService.open({width:368,title:{title:this._localeService.t("dataValidation.alert.title")},id:"reject-input-dialog",children:{title:e},footer:{title:b.createElement(V.Button,{variant:"primary",onClick:()=>this._dialogService.close("reject-input-dialog")},this._localeService.t("dataValidation.alert.ok"))},onClose:()=>{this._dialogService.close("reject-input-dialog")}})}};we=kt([Ie(0,o.Inject(H.SheetInterceptorService)),Ie(1,o.Inject(_.SheetDataValidationModel)),Ie(2,o.Inject(Y.DataValidatorRegistryService)),Ie(3,E.IDialogService),Ie(4,o.Inject(o.LocaleService)),Ie(5,o.Inject(_.SheetsDataValidationValidatorService))],we);var Nt=Object.getOwnPropertyDescriptor,Bt=(e,t,a,n)=>{for(var r=n>1?void 0:n?Nt(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},le=(e,t)=>(a,n)=>t(a,n,e);const Ye=e=>{if(e==null||typeof e=="boolean")return;if(typeof e=="number"||!Number.isNaN(+e))return o.dayjs(o.numfmt.format("yyyy-MM-dd HH:mm:ss",Number(e)));const t=o.dayjs(e);if(t.isValid())return t};function Wt(e,t){const a=jt.getPatternType(t);if(e===a)return t;switch(e){case"datetime":return"yyyy-MM-dd hh:mm:ss";case"date":return"yyyy-MM-dd";case"time":return"HH:mm:ss"}}let fe=class extends o.Disposable{constructor(t,a,n,r,i,s,d,l,c,h,g){super();A(this,"_activeDropdown");A(this,"_activeDropdown$",new oe.Subject);A(this,"_currentPopup",null);A(this,"activeDropdown$",this._activeDropdown$.asObservable());A(this,"_zenVisible",!1);this._univerInstanceService=t,this._dataValidatorRegistryService=a,this._zenZoneService=n,this._dataValidationModel=r,this._sheetsSelectionsService=i,this._cellDropdownManagerService=s,this._sheetDataValidationModel=d,this._commandService=l,this._editorBridgeService=c,this._injector=h,this._configService=g,this._init(),this._initSelectionChange(),this.disposeWithMe(()=>{this._activeDropdown$.complete()})}get activeDropdown(){return this._activeDropdown}_init(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(t=>{this._zenVisible=t,t&&this.hideDropdown()}))}_getDropdownByCell(t,a,n,r){const i=t?this._univerInstanceService.getUnit(t,o.UniverInstanceType.UNIVER_SHEET):this._univerInstanceService.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET);if(!i)return;const s=a?i.getSheetBySheetId(a):i.getActiveSheet();if(!s)return;const d=this._dataValidationModel.getRuleByLocation(i.getUnitId(),s.getSheetId(),n,r);if(!d)return;const l=this._dataValidatorRegistryService.getValidatorItem(d.type);return l==null?void 0:l.dropdownType}_initSelectionChange(){this.disposeWithMe(this._sheetsSelectionsService.selectionMoveEnd$.subscribe(t=>{t&&t.every(a=>!(a.primary&&this._getDropdownByCell(a.primary.unitId,a.primary.sheetId,a.primary.actualRow,a.primary.actualColumn)))&&this.hideDropdown()}))}showDropdown(t){var T,M,m,y;const{location:a}=t,{row:n,col:r,unitId:i,subUnitId:s,workbook:d,worksheet:l}=a;if(this._currentPopup&&this._currentPopup.dispose(),this._zenVisible)return;this._activeDropdown=t,this._activeDropdown$.next(this._activeDropdown);const c=this._sheetDataValidationModel.getRuleByLocation(i,s,n,r);if(!c)return;const h=this._dataValidatorRegistryService.getValidatorItem(c.type);if(!(h!=null&&h.dropdownType))return;let g;const u=async(f,D)=>{var j,U,B;if(!f)return!0;const R=f,C=l.getCell(n,r),w=R.format(D==="date"?"YYYY-MM-DD 00:00:00":"YYYY-MM-DD HH:mm:ss"),k=(j=o.numfmt.parseDate(w))==null?void 0:j.v,W=D==="time"?k%1:k,O=d.getStyles().getStyleByCell(C),x=(B=(U=O==null?void 0:O.n)==null?void 0:U.pattern)!=null?B:"";return c.errorStyle!==o.DataValidationErrorStyle.STOP||await h.validator({value:W,unitId:i,subUnitId:s,row:n,column:r,worksheet:l,workbook:d,interceptValue:w.replace("Z","").replace("T"," "),t:o.CellValueType.NUMBER},c)?(await this._commandService.executeCommand(N.SetCellEditVisibleOperation.id,{visible:!1,eventType:L.DeviceInputEventType.Keyboard,unitId:i,keycode:E.KeyCode.ESC}),await this._commandService.executeCommand(H.SetRangeValuesCommand.id,{unitId:i,subUnitId:s,range:{startColumn:r,endColumn:r,startRow:n,endRow:n},value:{v:W,t:2,p:null,f:null,si:null,s:{n:{pattern:Wt(D,x)}}}}),!0):(this._injector.has(we)&&this._injector.get(we).showReject(h.getRuleFinalError(c,{row:n,col:r,unitId:i,subUnitId:s})),!1)};let I;switch(h.dropdownType){case Y.DataValidatorDropdownType.DATE:{const f=_.getCellValueOrigin(l.getCellRaw(n,r)),D=Ye(f),R=!!((T=c.bizInfo)!=null&&T.showTime);I={location:a,type:"datepicker",props:{showTime:R,onChange:C=>u(C,R?"datetime":"date"),defaultValue:D,patternType:"date"}};break}case Y.DataValidatorDropdownType.TIME:{const f=_.getCellValueOrigin(l.getCellRaw(n,r)),D=Ye(f);I={location:a,type:"datepicker",props:{onChange:R=>u(R,"time"),defaultValue:D,patternType:"time"}};break}case Y.DataValidatorDropdownType.DATETIME:{const f=_.getCellValueOrigin(l.getCellRaw(n,r)),D=Ye(f);I={location:a,type:"datepicker",props:{onChange:R=>u(R,"datetime"),defaultValue:D,patternType:"datetime"}};break}case Y.DataValidatorDropdownType.LIST:case Y.DataValidatorDropdownType.MULTIPLE_LIST:{const f=h.dropdownType===Y.DataValidatorDropdownType.MULTIPLE_LIST,D=async O=>{const x=_.serializeListOptions(O),j={unitId:i,subUnitId:s,range:{startColumn:r,endColumn:r,startRow:n,endRow:n},value:{v:x,p:null,f:null,si:null}};return this._editorBridgeService.isVisible().visible&&await this._commandService.executeCommand(N.SetCellEditVisibleOperation.id,{visible:!1,eventType:L.DeviceInputEventType.Keyboard,unitId:i,keycode:E.KeyCode.ESC}),this._commandService.executeCommand(H.SetRangeValuesCommand.id,j),!f},R=(c==null?void 0:c.renderMode)===o.DataValidationRenderMode.CUSTOM||(c==null?void 0:c.renderMode)===void 0,C=h.getListWithColor(c,i,s),w=_.getDataValidationCellValue(l.getCellRaw(n,r)),k=()=>{this._commandService.executeCommand(Se.id,{ruleId:c.uid}),g==null||g.dispose()},W=C.map(O=>({label:O.label,value:O.label,color:R||O.color?O.color:"transparent"}));I={location:a,type:"list",props:{onChange:O=>D(O),options:W,onEdit:k,defaultValue:w,multiple:f,showEdit:(m=(M=this._configService.getConfig(st))==null?void 0:M.showEditOnDropdown)!=null?m:!0}};break}case Y.DataValidatorDropdownType.CASCADE:{I={type:"cascader",props:{onChange:D=>{const R={unitId:i,subUnitId:s,range:{startColumn:r,endColumn:r,startRow:n,endRow:n},value:{v:D.join("/"),p:null,f:null,si:null}};return this._editorBridgeService.isVisible().visible&&this._commandService.syncExecuteCommand(N.SetCellEditVisibleOperation.id,{visible:!1,eventType:L.DeviceInputEventType.Keyboard,unitId:i,keycode:E.KeyCode.ESC}),this._commandService.syncExecuteCommand(H.SetRangeValuesCommand.id,R),!0},defaultValue:_.getDataValidationCellValue(l.getCellRaw(n,r)).split("/"),options:JSON.parse((y=c.formula1)!=null?y:"[]")},location:a};break}case Y.DataValidatorDropdownType.COLOR:{I={type:"color",props:{onChange:D=>{const R={unitId:i,subUnitId:s,range:{startColumn:r,endColumn:r,startRow:n,endRow:n},value:{v:D,p:null,f:null,si:null}};return this._editorBridgeService.isVisible().visible&&this._commandService.syncExecuteCommand(N.SetCellEditVisibleOperation.id,{visible:!1,eventType:L.DeviceInputEventType.Keyboard,unitId:i,keycode:E.KeyCode.ESC}),this._commandService.syncExecuteCommand(H.SetRangeValuesCommand.id,R),!0},defaultValue:_.getDataValidationCellValue(l.getCellRaw(n,r))},location:a};break}default:throw new Error("[DataValidationDropdownManagerService]: unknown type!")}if(g=this._cellDropdownManagerService.showDropdown({...I,onHide:()=>{this._activeDropdown=null,this._activeDropdown$.next(null)}}),!g)throw new Error("[DataValidationDropdownManagerService]: cannot show dropdown!");const v=new o.DisposableCollection;v.add(g),v.add({dispose:()=>{var f,D;(D=(f=this._activeDropdown)==null?void 0:f.onHide)==null||D.call(f)}}),this._currentPopup=v}hideDropdown(){this._activeDropdown&&(this._currentPopup&&this._currentPopup.dispose(),this._currentPopup=null,this._activeDropdown=null,this._activeDropdown$.next(null))}showDataValidationDropdown(t,a,n,r,i){const s=this._univerInstanceService.getUnit(t,o.UniverInstanceType.UNIVER_SHEET);if(!s)return;const d=s.getSheetBySheetId(a);if(!d)return;const l=this._dataValidationModel.getRuleByLocation(s.getUnitId(),d.getSheetId(),n,r);if(!l)return;const c=this._dataValidatorRegistryService.getValidatorItem(l.type);if(!c||!c.dropdownType){this.hideDropdown();return}this.showDropdown({location:{workbook:s,worksheet:d,row:n,col:r,unitId:t,subUnitId:a},onHide:i})}};fe=Bt([le(0,o.IUniverInstanceService),le(1,o.Inject(Y.DataValidatorRegistryService)),le(2,E.IZenZoneService),le(3,o.Inject(_.SheetDataValidationModel)),le(4,o.Inject(H.SheetsSelectionsService)),le(5,o.Inject(N.ISheetCellDropdownManagerService)),le(6,o.Inject(_.SheetDataValidationModel)),le(7,o.ICommandService),le(8,N.IEditorBridgeService),le(9,o.Inject(o.Injector)),le(10,o.IConfigService)],fe);const Fe="DataValidationPanel",Se={id:"data-validation.operation.open-validation-panel",type:o.CommandType.OPERATION,handler(e,t){if(!t)return!1;const{ruleId:a,isAdd:n}=t,r=e.get(he),i=e.get(Y.DataValidationModel),s=e.get(o.IUniverInstanceService),d=e.get(E.ISidebarService),l=H.getSheetCommandTarget(s);if(!l)return!1;const{unitId:c,subUnitId:h}=l,g=a?i.getRuleById(c,h,a):void 0;r.open(),r.setActiveRule(g&&{unitId:c,subUnitId:h,rule:g});const u=d.open({id:Fe,header:{title:n?"dataValidation.panel.addTitle":"dataValidation.panel.title"},children:{label:Fe},width:312,onClose:()=>r.close()});return r.setCloseDisposable(u),!0}},lt={id:"data-validation.operation.close-validation-panel",type:o.CommandType.OPERATION,handler(e){return e.get(he).close(),!0}},_t={id:"data-validation.operation.toggle-validation-panel",type:o.CommandType.OPERATION,handler(e){const t=e.get(o.ICommandService),a=e.get(he);return a.open(),a.isOpen?t.executeCommand(lt.id):t.executeCommand(Se.id),!0}},He={type:o.CommandType.OPERATION,id:"sheet.operation.show-data-validation-dropdown",handler(e,t){if(!t)return!1;const a=e.get(fe),{unitId:n,subUnitId:r,row:i,column:s}=t,d=a.activeDropdown,l=d==null?void 0:d.location;return l&&l.unitId===n&&l.subUnitId===r&&l.row===i&&l.col===s||a.showDataValidationDropdown(n,r,i,s),!0}},It={type:o.CommandType.OPERATION,id:"sheet.operation.hide-data-validation-dropdown",handler(e,t){return t?(e.get(fe).hideDropdown(),!0):!1}},$e={type:o.CommandType.COMMAND,id:"data-validation.command.addRuleAndOpen",handler(e){const t=e.get(o.IUniverInstanceService),a=H.getSheetCommandTarget(t);if(!a)return!1;const{workbook:n,worksheet:r}=a,i=_.createDefaultNewRule(e),s=e.get(o.ICommandService),d=n.getUnitId(),l=r.getSheetId(),c={rule:i,unitId:d,subUnitId:l};return s.syncExecuteCommand(_.AddSheetDataValidationCommand.id,c)?(s.syncExecuteCommand(Se.id,{ruleId:i.uid,isAdd:!0}),!0):!1}};var Ht=Object.getOwnPropertyDescriptor,$t=(e,t,a,n)=>{for(var r=n>1?void 0:n?Ht(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},Ce=(e,t)=>(a,n)=>t(a,n,e);const pe="SHEET_DATA_VALIDATION_ALERT";let Pe=class extends o.Disposable{constructor(e,t,a,n,r,i){super(),this._hoverManagerService=e,this._cellAlertManagerService=t,this._univerInstanceService=a,this._localeService=n,this._zenZoneService=r,this._dataValidationModel=i,this._init()}_init(){this._initCellAlertPopup(),this._initZenService()}_initCellAlertPopup(){this.disposeWithMe(this._hoverManagerService.currentCell$.pipe(oe.debounceTime(100)).subscribe(e=>{var t;if(e){const a=this._univerInstanceService.getUnit(e.location.unitId,o.UniverInstanceType.UNIVER_SHEET),n=a.getSheetBySheetId(e.location.subUnitId);if(!n)return;const r=this._dataValidationModel.getRuleByLocation(e.location.unitId,e.location.subUnitId,e.location.row,e.location.col);if(!r){this._cellAlertManagerService.removeAlert(pe);return}if(this._dataValidationModel.validator(r,{...e.location,workbook:a,worksheet:n})===o.DataValidationStatus.INVALID){const s=this._cellAlertManagerService.currentAlert.get(pe),d=(t=s==null?void 0:s.alert)==null?void 0:t.location;if(d&&d.row===e.location.row&&d.col===e.location.col&&d.subUnitId===e.location.subUnitId&&d.unitId===e.location.unitId){this._cellAlertManagerService.removeAlert(pe);return}const l=this._dataValidationModel.getValidator(r.type);if(!l){this._cellAlertManagerService.removeAlert(pe);return}this._cellAlertManagerService.showAlert({type:N.CellAlertType.ERROR,title:this._localeService.t("dataValidation.error.title"),message:l==null?void 0:l.getRuleFinalError(r,e.location),location:e.location,width:200,height:74,key:pe});return}}this._cellAlertManagerService.removeAlert(pe)}))}_initZenService(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(e=>{e&&this._cellAlertManagerService.removeAlert(pe)}))}};Pe=$t([Ce(0,o.Inject(N.HoverManagerService)),Ce(1,o.Inject(N.CellAlertManagerService)),Ce(2,o.IUniverInstanceService),Ce(3,o.Inject(o.LocaleService)),Ce(4,E.IZenZoneService),Ce(5,o.Inject(_.SheetDataValidationModel))],Pe);var Yt=Object.getOwnPropertyDescriptor,Xt=(e,t,a,n)=>{for(var r=n>1?void 0:n?Yt(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},Xe=(e,t)=>(a,n)=>t(a,n,e);let Ve=class extends o.Disposable{constructor(e,t,a){super(),this._autoFillService=e,this._sheetDataValidationModel=t,this._injector=a,this._initAutoFill()}_initAutoFill(){const e=()=>({redos:[],undos:[]}),t=(n,r)=>{const{source:i,target:s,unitId:d,subUnitId:l}=n,c=this._sheetDataValidationModel.getRuleObjectMatrix(d,l).clone(),h=N.virtualizeDiscreteRanges([i,s]),[g,u]=h.ranges,{mapFunc:I}=h,v={row:g.startRow,col:g.startColumn},T=N.getAutoFillRepeatRange(g,u),M=new o.ObjectMatrix,m=new Set;T.forEach(C=>{const w=C.repeatStartCell,k=C.relativeRange,W={startRow:v.row,startColumn:v.col,endColumn:v.col,endRow:v.row},O={startRow:w.row,startColumn:w.col,endColumn:w.col,endRow:w.row};o.Range.foreach(k,(x,j)=>{const U=o.Rectangle.getPositionRange({startRow:x,startColumn:j,endColumn:j,endRow:x},W),{row:B,col:K}=I(U.startRow,U.startColumn),z=this._sheetDataValidationModel.getRuleIdByLocation(d,l,B,K)||"",ee=o.Rectangle.getPositionRange({startRow:x,startColumn:j,endColumn:j,endRow:x},O),{row:ae,col:re}=I(ee.startRow,ee.startColumn);M.setValue(ae,re,z),m.add(z)})});const y=Array.from(m).map(C=>({id:C,ranges:o.queryObjectMatrix(M,w=>w===C)}));c.addRangeRules(y);const f=c.diff(this._sheetDataValidationModel.getRules(d,l)),{redoMutations:D,undoMutations:R}=_.getDataValidationDiffMutations(d,l,f,this._injector,"patched",r===N.APPLY_TYPE.ONLY_FORMAT);return{undos:R,redos:D}},a={id:_.DATA_VALIDATION_PLUGIN_NAME,onBeforeFillData:n=>{const{source:r,unitId:i,subUnitId:s}=n;for(const d of r.rows)for(const l of r.cols){const c=this._sheetDataValidationModel.getRuleByLocation(i,s,d,l);if(c&&c.type===o.DataValidationType.CHECKBOX){this._autoFillService.setDisableApplyType(N.APPLY_TYPE.SERIES,!0);return}}},onFillData:(n,r,i)=>i===N.APPLY_TYPE.COPY||i===N.APPLY_TYPE.ONLY_FORMAT||i===N.APPLY_TYPE.SERIES?t(n,i):e(),onAfterFillData:()=>{}};this.disposeWithMe(this._autoFillService.addHook(a))}};Ve=Xt([Xe(0,N.IAutoFillService),Xe(1,o.Inject(_.SheetDataValidationModel)),Xe(2,o.Inject(o.Injector))],Ve);var zt=Object.getOwnPropertyDescriptor,Kt=(e,t,a,n)=>{for(var r=n>1?void 0:n?zt(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},ze=(e,t)=>(a,n)=>t(a,n,e);let Ee=class extends o.Disposable{constructor(t,a,n){super();A(this,"_copyInfo");this._sheetClipboardService=t,this._sheetDataValidationModel=a,this._injector=n,this._initCopyPaste()}_initCopyPaste(){this._sheetClipboardService.addClipboardHook({id:_.DATA_VALIDATION_PLUGIN_NAME,onBeforeCopy:(t,a,n)=>this._collect(t,a,n),onPasteCells:(t,a,n,r)=>{const{copyType:i=N.COPY_TYPE.COPY,pasteType:s}=r,{range:d}=t||{},{range:l,unitId:c,subUnitId:h}=a;return this._generateMutations(l,{copyType:i,pasteType:s,copyRange:d,unitId:c,subUnitId:h})}})}_collect(t,a,n){const r=new o.ObjectMatrix;this._copyInfo={unitId:t,subUnitId:a,matrix:r};const i=this._injector.invoke(l=>H.rangeToDiscreteRange(n,l,t,a));if(!i)return;const{rows:s,cols:d}=i;s.forEach((l,c)=>{d.forEach((h,g)=>{const u=this._sheetDataValidationModel.getRuleIdByLocation(t,a,l,h);r.setValue(c,g,u!=null?u:"")})})}_generateMutations(t,a){if(!this._copyInfo)return{redos:[],undos:[]};if(a.copyType===N.COPY_TYPE.CUT)return this._copyInfo=null,{redos:[],undos:[]};if(!this._copyInfo||!this._copyInfo.matrix.getSizeOf()||!a.copyRange)return{redos:[],undos:[]};if([N.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_COL_WIDTH,N.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_VALUE,N.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMAT,N.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMULA].includes(a.pasteType))return{redos:[],undos:[]};const{unitId:r,subUnitId:i}=this._copyInfo;if(a.unitId!==r||i!==a.subUnitId){const s=this._sheetDataValidationModel.getRuleObjectMatrix(a.unitId,a.subUnitId).clone(),d=new o.ObjectMatrix,l=new Set,{ranges:[c,h],mapFunc:g}=N.virtualizeDiscreteRanges([a.copyRange,t]),u=N.getRepeatRange(c,h,!0),I=new Map;u.forEach(({startRange:m})=>{var y;(y=this._copyInfo)==null||y.matrix.forValue((f,D,R)=>{const C=o.Rectangle.getPositionRange({startRow:f,endRow:f,startColumn:D,endColumn:D},m),w=`${i}-${R}`,k=this._sheetDataValidationModel.getRuleById(r,i,R);!this._sheetDataValidationModel.getRuleById(a.unitId,a.subUnitId,w)&&k&&I.set(w,{...k,uid:w});const{row:W,col:O}=g(C.startRow,C.startColumn);l.add(w),d.setValue(W,O,w)})});const v=Array.from(l).map(m=>({id:m,ranges:o.queryObjectMatrix(d,y=>y===m)}));s.addRangeRules(v);const{redoMutations:T,undoMutations:M}=_.getDataValidationDiffMutations(a.unitId,a.subUnitId,s.diffWithAddition(this._sheetDataValidationModel.getRules(a.unitId,a.subUnitId),I.values()),this._injector,"patched",!1);return{redos:T,undos:M}}else{const s=this._sheetDataValidationModel.getRuleObjectMatrix(r,i).clone(),d=new o.ObjectMatrix,l=new Set,{ranges:[c,h],mapFunc:g}=N.virtualizeDiscreteRanges([a.copyRange,t]);N.getRepeatRange(c,h,!0).forEach(({startRange:M})=>{var m;(m=this._copyInfo)==null||m.matrix.forValue((y,f,D)=>{const R=o.Rectangle.getPositionRange({startRow:y,endRow:y,startColumn:f,endColumn:f},M),{row:C,col:w}=g(R.startRow,R.startColumn);d.setValue(C,w,D),l.add(D)})});const I=Array.from(l).map(M=>({id:M,ranges:o.queryObjectMatrix(d,m=>m===M)}));s.addRangeRules(I);const{redoMutations:v,undoMutations:T}=_.getDataValidationDiffMutations(r,i,s.diff(this._sheetDataValidationModel.getRules(r,i)),this._injector,"patched",!1);return{redos:v,undos:T}}}};Ee=Kt([ze(0,N.ISheetClipboardService),ze(1,o.Inject(_.SheetDataValidationModel)),ze(2,o.Inject(o.Injector))],Ee);var Zt=Object.getOwnPropertyDescriptor,Gt=(e,t,a,n)=>{for(var r=n>1?void 0:n?Zt(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},Ke=(e,t)=>(a,n)=>t(a,n,e);let Me=class extends o.Disposable{constructor(e,t,a){super(),this._localeService=e,this._commandService=t,this._sheetPermissionCheckController=a,this._commandExecutedListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.beforeCommandExecuted(e=>{e.id===_.AddSheetDataValidationCommand.id&&(this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[H.WorkbookEditablePermission],rangeTypes:[H.RangeProtectionPermissionEditPoint],worksheetTypes:[H.WorksheetEditPermission,H.WorksheetSetCellStylePermission]})||this._sheetPermissionCheckController.blockExecuteWithoutPermission(this._localeService.t("permission.dialog.setStyleErr"))),e.id===_.UpdateSheetDataValidationRangeCommand.id&&(this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[H.WorkbookEditablePermission],rangeTypes:[H.RangeProtectionPermissionEditPoint],worksheetTypes:[H.WorksheetEditPermission,H.WorksheetSetCellStylePermission]},e.params.ranges)||this._sheetPermissionCheckController.blockExecuteWithoutPermission(this._localeService.t("permission.dialog.setStyleErr")))}))}};Me=Gt([Ke(0,o.Inject(o.LocaleService)),Ke(1,o.ICommandService),Ke(2,o.Inject(H.SheetPermissionCheckController))],Me);const Ct="sheet.menu.data-validation";function qt(e){return{id:Ct,type:E.MenuItemType.SUBITEMS,icon:"DataValidationIcon",tooltip:"dataValidation.title",hidden$:E.getMenuHiddenObservable(e,o.UniverInstanceType.UNIVER_SHEET),disabled$:N.getCurrentRangeDisable$(e,{workbookTypes:[H.WorkbookEditablePermission],worksheetTypes:[H.WorksheetSetCellStylePermission,H.WorksheetEditPermission],rangeTypes:[H.RangeProtectionPermissionEditPoint]})}}function Jt(e){return{id:Se.id,title:"dataValidation.panel.title",type:E.MenuItemType.BUTTON}}function Qt(e){return{id:$e.id,title:"dataValidation.panel.add",type:E.MenuItemType.BUTTON}}const en={[E.RibbonDataGroup.RULES]:{[Ct]:{order:0,menuItemFactory:qt,[Se.id]:{order:0,menuItemFactory:Jt},[$e.id]:{order:1,menuItemFactory:Qt}}}};var tn=Object.getOwnPropertyDescriptor,yt=(e,t,a,n)=>{for(var r=n>1?void 0:n?tn(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},G=(e,t)=>(a,n)=>t(a,n,e);const Rt={tr:{size:6,color:"#fe4b4b"}};let be=class extends o.RxDisposable{constructor(e,t,a,n,r,i,s,d,l,c,h){super(),this._commandService=e,this._menuManagerService=t,this._renderManagerService=a,this._univerInstanceService=n,this._autoHeightController=r,this._dropdownManagerService=i,this._sheetDataValidationModel=s,this._dataValidatorRegistryService=d,this._sheetInterceptorService=l,this._dataValidationCacheService=c,this._editorBridgeService=h,this._initMenu(),this._initDropdown(),this._initViewModelIntercept(),this._initAutoHeight()}_initMenu(){this._menuManagerService.mergeMenu(en)}_initDropdown(){this._editorBridgeService&&this.disposeWithMe(this._editorBridgeService.visible$.subscribe(e=>{var a;if(!e.visible){((a=this._dropdownManagerService.activeDropdown)==null?void 0:a.trigger)==="editor-bridge"&&this._dropdownManagerService.hideDropdown();return}const t=this._editorBridgeService.getEditCellState();if(t){const{unitId:n,sheetId:r,row:i,column:s}=t,d=this._univerInstanceService.getUniverSheetInstance(n);if(!d)return;const l=this._sheetDataValidationModel.getRuleByLocation(n,r,i,s);if(!l)return;const c=this._dataValidatorRegistryService.getValidatorItem(l.type);if(!(c!=null&&c.dropdownType))return;const h=d.getActiveSheet();if(!h)return;const g=this._dropdownManagerService.activeDropdown,u=g==null?void 0:g.location;if(u&&u.unitId===n&&u.subUnitId===r&&u.row===i&&u.col===s)return;this._dropdownManagerService.showDropdown({location:{unitId:n,subUnitId:r,row:i,col:s,workbook:d,worksheet:h},trigger:"editor-bridge",closeOnOutSide:!1})}}))}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(H.INTERCEPTOR_POINT.CELL_CONTENT,{effect:o.InterceptorEffectEnum.Style,priority:H.InterceptCellContentPriority.DATA_VALIDATION,handler:(e,t,a)=>{var m,y,f,D,R;const{row:n,col:r,unitId:i,subUnitId:s,workbook:d,worksheet:l}=t,c=this._sheetDataValidationModel.getRuleIdByLocation(i,s,n,r);if(!c)return a(e);const h=this._sheetDataValidationModel.getRuleById(i,s,c);if(!h)return a(e);const g=(m=this._dataValidationCacheService.getValue(i,s,n,r))!=null?m:o.DataValidationStatus.VALID,u=this._dataValidatorRegistryService.getValidatorItem(h.type),I=t.rawData;let v;const T={get value(){var C;return v!==void 0||(v=(C=_.getCellValueOrigin(I))!=null?C:null),v}},M={get value(){var C;return`${(C=T.value)!=null?C:""}`}};return(!e||e===t.rawData)&&(e={...t.rawData}),e.markers={...e==null?void 0:e.markers,...g===o.DataValidationStatus.INVALID?Rt: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:((f=e==null?void 0:e.fontRenderExtension)==null?void 0:f.isSkip)||((D=u==null?void 0:u.skipDefaultFontRender)==null?void 0:D.call(u,h,T.value,t))},e.interceptorStyle={...e==null?void 0:e.interceptorStyle,...u==null?void 0:u.getExtraStyle(h,M.value,{get style(){const C=d.getStyles();return(typeof(e==null?void 0:e.s)=="string"?C.get(e==null?void 0:e.s):e==null?void 0:e.s)||{}}},n,r)},e.interceptorAutoHeight=()=>{var W,O,x,j,U,B;const C=(O=(W=this._renderManagerService.getRenderById(i))==null?void 0:W.with(N.SheetSkeletonManagerService).getSkeletonParam(s))==null?void 0:O.skeleton;if(!C)return;const w=C.worksheet.getMergedCell(n,r),k={data:e,style:C.getStyles().getStyleByCell(e),primaryWithCoord:C.getCellWithCoordByIndex((x=w==null?void 0:w.startRow)!=null?x:n,(j=w==null?void 0:w.startColumn)!=null?j:r),unitId:i,subUnitId:s,row:n,col:r,workbook:d,worksheet:l};return(B=(U=u==null?void 0:u.canvasRender)==null?void 0:U.calcCellAutoHeight)==null?void 0:B.call(U,k)},e.interceptorAutoWidth=()=>{var W,O,x,j,U,B;const C=(O=(W=this._renderManagerService.getRenderById(i))==null?void 0:W.with(N.SheetSkeletonManagerService).getSkeletonParam(s))==null?void 0:O.skeleton;if(!C)return;const w=C.worksheet.getMergedCell(n,r),k={data:e,style:C.getStyles().getStyleByCell(e),primaryWithCoord:C.getCellWithCoordByIndex((x=w==null?void 0:w.startRow)!=null?x:n,(j=w==null?void 0:w.startColumn)!=null?j:r),unitId:i,subUnitId:s,row:n,col:r,workbook:d,worksheet:l};return(B=(U=u==null?void 0:u.canvasRender)==null?void 0:U.calcCellAutoWidth)==null?void 0:B.call(U,k)},e.coverable=((R=e==null?void 0:e.coverable)!=null?R:!0)&&!(h.type===o.DataValidationType.LIST||h.type===o.DataValidationType.LIST_MULTIPLE),a(e)}}))}_initAutoHeight(){this._sheetDataValidationModel.ruleChange$.pipe(oe.filter(e=>e.source==="command"),oe.bufferTime(100)).subscribe(e=>{if(e.length===0)return;const t=[];if(e.forEach(a=>{var n;(a.rule.type===o.DataValidationType.LIST_MULTIPLE||a.rule.type===o.DataValidationType.LIST)&&(n=a.rule)!=null&&n.ranges&&t.push(...a.rule.ranges)}),t.length){const a=this._autoHeightController.getUndoRedoParamsOfAutoHeight(t);o.sequenceExecute(a.redos,this._commandService)}})}};be=yt([G(0,o.ICommandService),G(1,E.IMenuManagerService),G(2,L.IRenderManagerService),G(3,o.IUniverInstanceService),G(4,o.Inject(N.AutoHeightController)),G(5,o.Inject(fe)),G(6,o.Inject(_.SheetDataValidationModel)),G(7,o.Inject(Y.DataValidatorRegistryService)),G(8,o.Inject(H.SheetInterceptorService)),G(9,o.Inject(_.DataValidationCacheService)),G(10,o.Optional(N.IEditorBridgeService))],be);let gt=class extends o.RxDisposable{constructor(e,t,a,n,r,i,s){super(),this._commandService=e,this._renderManagerService=t,this._autoHeightController=a,this._dataValidatorRegistryService=n,this._sheetInterceptorService=r,this._sheetDataValidationModel=i,this._dataValidationCacheService=s,this._initViewModelIntercept(),this._initAutoHeight()}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(H.INTERCEPTOR_POINT.CELL_CONTENT,{effect:o.InterceptorEffectEnum.Style,priority:H.InterceptCellContentPriority.DATA_VALIDATION,handler:(e,t,a)=>{var M,m,y,f,D;const{row:n,col:r,unitId:i,subUnitId:s,workbook:d,worksheet:l}=t,c=this._sheetDataValidationModel.getRuleIdByLocation(i,s,n,r);if(!c)return a(e);const h=this._sheetDataValidationModel.getRuleById(i,s,c);if(!h)return a(e);const g=(M=this._dataValidationCacheService.getValue(i,s,n,r))!=null?M:o.DataValidationStatus.VALID,u=this._dataValidatorRegistryService.getValidatorItem(h.type),I=l.getCellRaw(n,r),v=_.getCellValueOrigin(I),T=`${v!=null?v:""}`;return(!e||e===t.rawData)&&(e={...t.rawData}),e.markers={...e==null?void 0:e.markers,...g===o.DataValidationStatus.INVALID?Rt:null},e.customRender=[...(m=e==null?void 0:e.customRender)!=null?m:[],...u!=null&&u.canvasRender?[u.canvasRender]:[]],e.fontRenderExtension={...e==null?void 0:e.fontRenderExtension,isSkip:((y=e==null?void 0:e.fontRenderExtension)==null?void 0:y.isSkip)||((f=u==null?void 0:u.skipDefaultFontRender)==null?void 0:f.call(u,h,v,t))},e.interceptorStyle={...e==null?void 0:e.interceptorStyle,...u==null?void 0:u.getExtraStyle(h,T,{get style(){const R=d.getStyles();return(typeof(e==null?void 0:e.s)=="string"?R.get(e==null?void 0:e.s):e==null?void 0:e.s)||{}}},n,r)},e.interceptorAutoHeight=()=>{var k,W,O,x,j,U;const R=(W=(k=this._renderManagerService.getRenderById(i))==null?void 0:k.with(N.SheetSkeletonManagerService).getSkeletonParam(s))==null?void 0:W.skeleton;if(!R)return;const C=R.worksheet.getMergedCell(n,r),w={data:e,style:R.getStyles().getStyleByCell(e),primaryWithCoord:R.getCellWithCoordByIndex((O=C==null?void 0:C.startRow)!=null?O:n,(x=C==null?void 0:C.startColumn)!=null?x:r),unitId:i,subUnitId:s,row:n,col:r,workbook:d,worksheet:l};return(U=(j=u==null?void 0:u.canvasRender)==null?void 0:j.calcCellAutoHeight)==null?void 0:U.call(j,w)},e.interceptorAutoWidth=()=>{var k,W,O,x,j,U;const R=(W=(k=this._renderManagerService.getRenderById(i))==null?void 0:k.with(N.SheetSkeletonManagerService).getSkeletonParam(s))==null?void 0:W.skeleton;if(!R)return;const C=R.worksheet.getMergedCell(n,r),w={data:e,style:R.getStyles().getStyleByCell(e),primaryWithCoord:R.getCellWithCoordByIndex((O=C==null?void 0:C.startRow)!=null?O:n,(x=C==null?void 0:C.startColumn)!=null?x:r),unitId:i,subUnitId:s,row:n,col:r,workbook:d,worksheet:l};return(U=(j=u==null?void 0:u.canvasRender)==null?void 0:j.calcCellAutoWidth)==null?void 0:U.call(j,w)},e.coverable=((D=e==null?void 0:e.coverable)!=null?D:!0)&&!(h.type===o.DataValidationType.LIST||h.type===o.DataValidationType.LIST_MULTIPLE),a(e)}}))}_initAutoHeight(){this._sheetDataValidationModel.ruleChange$.pipe(oe.filter(e=>e.source==="command"),oe.bufferTime(16)).subscribe(e=>{const t=[];if(e.forEach(a=>{var n;(a.rule.type===o.DataValidationType.LIST_MULTIPLE||a.rule.type===o.DataValidationType.LIST)&&(n=a.rule)!=null&&n.ranges&&t.push(...a.rule.ranges)}),t.length){const a=this._autoHeightController.getUndoRedoParamsOfAutoHeight(t);o.sequenceExecute(a.redos,this._commandService)}})}};gt=yt([G(0,o.ICommandService),G(1,L.IRenderManagerService),G(2,o.Inject(N.AutoHeightController)),G(3,o.Inject(Y.DataValidatorRegistryService)),G(4,o.Inject(H.SheetInterceptorService)),G(5,o.Inject(_.SheetDataValidationModel)),G(6,o.Inject(_.DataValidationCacheService))],gt);var nn=Object.getOwnPropertyDescriptor,an=(e,t,a,n)=>{for(var r=n>1?void 0:n?nn(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},pt=(e,t)=>(a,n)=>t(a,n,e);let ke=class extends o.Disposable{constructor(e,t,a){super(),this._context=e,this._sheetDataValidationModel=t,this._sheetSkeletonManagerService=a,this._initSkeletonChange()}_initSkeletonChange(){const e=t=>{var n;if(!t.length)return;const a=new Set;t.forEach(r=>{a.add(r.subUnitId)}),a.forEach(r=>{var i;(i=this._sheetSkeletonManagerService.getSkeletonParam(r))==null||i.skeleton.makeDirty(!0)}),(n=this._context.mainComponent)==null||n.makeForceDirty()};this.disposeWithMe(this._sheetDataValidationModel.validStatusChange$.pipe(o.bufferDebounceTime(16)).subscribe(e))}};ke=an([pt(1,o.Inject(_.SheetDataValidationModel)),pt(2,o.Inject(N.SheetSkeletonManagerService))],ke);var ie=function(){return ie=Object.assign||function(e){for(var t,a=1,n=arguments.length;a<n;a++){t=arguments[a];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])}return e},ie.apply(this,arguments)},rn=function(e,t){var a={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(a[n]=e[n]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,n=Object.getOwnPropertySymbols(e);r<n.length;r++)t.indexOf(n[r])<0&&Object.prototype.propertyIsEnumerable.call(e,n[r])&&(a[n[r]]=e[n[r]]);return a},_e=b.forwardRef(function(e,t){var a=e.icon,n=e.id,r=e.className,i=e.extend,s=rn(e,["icon","id","className","extend"]),d="univerjs-icon univerjs-icon-".concat(n," ").concat(r||"").trim(),l=b.useRef("_".concat(ln()));return Dt(a,"".concat(n),{defIds:a.defIds,idSuffix:l.current},ie({ref:t,className:d},s),i)});function Dt(e,t,a,n,r){return b.createElement(e.tag,ie(ie({key:t},on(e,a,r)),n),(sn(e,a).children||[]).map(function(i,s){return Dt(i,"".concat(t,"-").concat(e.tag,"-").concat(s),a,void 0,r)}))}function on(e,t,a){var n=ie({},e.attrs);a!=null&&a.colorChannel1&&n.fill==="colorChannel1"&&(n.fill=a.colorChannel1),e.tag==="mask"&&n.id&&(n.id=n.id+t.idSuffix),Object.entries(n).forEach(function(i){var s=i[0],d=i[1];s==="mask"&&typeof d=="string"&&(n[s]=d.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))});var r=t.defIds;return!r||r.length===0||(e.tag==="use"&&n["xlink:href"]&&(n["xlink:href"]=n["xlink:href"]+t.idSuffix),Object.entries(n).forEach(function(i){var s=i[0],d=i[1];typeof d=="string"&&(n[s]=d.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))})),n}function sn(e,t){var a,n=t.defIds;return!n||n.length===0?e:e.tag==="defs"&&(!((a=e.children)===null||a===void 0)&&a.length)?ie(ie({},e),{children:e.children.map(function(r){return typeof r.attrs.id=="string"&&n&&n.includes(r.attrs.id)?ie(ie({},r),{attrs:ie(ie({},r.attrs),{id:r.attrs.id+t.idSuffix})}):r})}):e}function ln(){return Math.random().toString(36).substring(2,8)}_e.displayName="UniverIcon";var 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"}}]},wt=b.forwardRef(function(e,t){return b.createElement(_e,Object.assign({},e,{id:"data-validation-icon",ref:t,icon:dn}))});wt.displayName="DataValidationIcon";var cn={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"}}]},dt=b.forwardRef(function(e,t){return b.createElement(_e,Object.assign({},e,{id:"delete-icon",ref:t,icon:cn}))});dt.displayName="DeleteIcon";var 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:"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"}}]},Vt=b.forwardRef(function(e,t){return b.createElement(_e,Object.assign({},e,{id:"increase-icon",ref:t,icon:un}))});Vt.displayName="IncreaseIcon";var 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:"M11.3536 6.14645C11.5488 6.34171 11.5488 6.65829 11.3536 6.85355L8.35355 9.85355C8.15829 10.0488 7.84171 10.0488 7.64645 9.85355L4.64645 6.85355C4.45118 6.65829 4.45118 6.34171 4.64645 6.14645C4.84171 5.95118 5.15829 5.95118 5.35355 6.14645L8 8.79289L10.6464 6.14645C10.8417 5.95118 11.1583 5.95118 11.3536 6.14645Z",fillRule:"evenodd",clipRule:"evenodd"}}]},ct=b.forwardRef(function(e,t){return b.createElement(_e,Object.assign({},e,{id:"more-down-icon",ref:t,icon:hn}))});ct.displayName="MoreDownIcon";var 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:"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"}}]},Et=b.forwardRef(function(e,t){return b.createElement(_e,Object.assign({},e,{id:"more-up-icon",ref:t,icon:gn}))});Et.displayName="MoreUpIcon";var pn={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"mask",attrs:{id:"mask0_622_8",width:16,height:16,x:0,y:0,maskUnits:"userSpaceOnUse"},children:[{tag:"path",attrs:{fill:"#D9D9D9",d:"M0 0H16V16H0z"}}]},{tag:"g",attrs:{fill:"currentColor",mask:"url(#mask0_622_8)"},children:[{tag:"path",attrs:{d:"M6 5C6.55228 5 7 4.55228 7 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:{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:{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:{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:{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:{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"}}]}]},Mt=b.forwardRef(function(e,t){return b.createElement(_e,Object.assign({},e,{id:"sequence-icon",ref:t,icon:pn}))});Mt.displayName="SequenceIcon";function vn(e){var c;const t=E.useDependency(o.LocaleService),a=E.useDependency(E.ComponentManager),{value:n,onChange:r,extraComponent:i}=e,[s,d]=b.useState(!1),l=i?a.get(i):null;return p.jsxs(p.Fragment,{children:[p.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:()=>d(!s),children:[t.t("dataValidation.panel.options"),s?p.jsx(Et,{className:"univer-ml-1"}):p.jsx(ct,{className:"univer-ml-1"})]}),s&&p.jsxs(p.Fragment,{children:[l?p.jsx(l,{value:n,onChange:r}):null,p.jsx(V.FormLayout,{label:t.t("dataValidation.panel.invalid"),children:p.jsxs(V.RadioGroup,{value:`${(c=n.errorStyle)!=null?c:o.DataValidationErrorStyle.WARNING}`,onChange:h=>r({...n,errorStyle:+h}),children:[p.jsx(V.Radio,{value:`${o.DataValidationErrorStyle.WARNING}`,children:t.t("dataValidation.panel.showWarning")}),p.jsx(V.Radio,{value:`${o.DataValidationErrorStyle.STOP}`,children:t.t("dataValidation.panel.rejectInput")})]})}),p.jsx(V.FormLayout,{label:t.t("dataValidation.panel.messageInfo"),children:p.jsx(V.Checkbox,{checked:n.showErrorMessage,onChange:()=>r({...n,showErrorMessage:!n.showErrorMessage}),children:t.t("dataValidation.panel.showInfo")})}),n.showErrorMessage?p.jsx(V.FormLayout,{children:p.jsx(V.Input,{value:n.error,onChange:h=>r({...n,error:h})})}):null]})]})}const mn=e=>o.debounce(async(t,a,n,r)=>{const i=await e.executeCommand(t,a,n);r==null||r(i)},1e3);function fn(e,t,a){var n,r,i,s;return t?((r=(n=e.getUnit(t))==null?void 0:n.getSheetBySheetName(a))==null?void 0:r.getSheetId())||"":((s=(i=e.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET))==null?void 0:i.getSheetBySheetName(a))==null?void 0:s.getSheetId())||""}function Sn(){var P,$;const[e,t]=b.useState(0),a=E.useDependency(he),n=E.useObservable(a.activeRule$,a.activeRule),{unitId:r,subUnitId:i,rule:s}=n||{},d=s.uid,l=E.useDependency(Y.DataValidatorRegistryService),c=E.useDependency(o.IUniverInstanceService),h=E.useDependency(E.ComponentManager),g=E.useDependency(o.ICommandService),u=E.useDependency(Y.DataValidationModel),I=E.useDependency(o.LocaleService),[v,T]=b.useState(s),M=l.getValidatorItem(v.type),[m,y]=b.useState(!1),f=l.getValidatorsByScope(Y.DataValidatorRegistryScope.SHEET),[D,R]=b.useState(()=>v.ranges.map(S=>({unitId:"",sheetId:"",range:S}))),C=b.useMemo(()=>mn(g),[g]),[w,k]=b.useState(!1),[W,O]=b.useState(!1),x=b.useRef(null),j=E.useDependency(H.SheetsSelectionsService);if(b.useEffect(()=>()=>{const S=j.getCurrentLastSelection();S&&j.setSelections([S])},[j]),b.useEffect(()=>{g.onCommandExecuted(S=>{(S.id===o.UndoCommand.id||S.id===o.RedoCommand.id)&&setTimeout(()=>{const F=u.getRuleById(r,i,d);t(X=>X+1),F&&(T(F),R(F.ranges.map(X=>({unitId:"",sheetId:"",range:X}))))},20)})},[g,u,d,i,r]),!M)return null;const U=M.operators,B=M.operatorNames,K=v.operator?Y.TWO_FORMULA_OPERATOR_COUNT.includes(v.operator):!1,z=()=>{var S,F,X;(F=(S=x.current)==null?void 0:S.editor)!=null&&F.isFocus()&&ee((X=x.current)==null?void 0:X.getValue()),!(!v.ranges.length||w)&&(M.validatorFormula(v,r,i).success?a.setActiveRule(null):y(!0))},ee=E.useEvent(S=>{const F=S.split(",").filter(Boolean).map(tt.deserializeRangeWithSheet).map(ne=>{const ut=ne.sheetName;if(ut){const Pt=fn(c,ne.unitId,ut);return{...ne,sheetId:Pt}}return{...ne,sheetId:""}});if(o.isUnitRangesEqual(F,D))return;R(F);const X=F.filter(ne=>(!ne.unitId||ne.unitId===r)&&(!ne.sheetId||ne.sheetId===i)).map(ne=>ne.range);if(T({...v,ranges:X}),X.length===0)return;const ge={unitId:r,subUnitId:i,ruleId:d,ranges:X};C(_.UpdateSheetDataValidationRangeCommand.id,ge)}),ae=S=>{if(o.shallowEqual(S,Y.getRuleSetting(v)))return;T({...v,...S});const F={unitId:r,subUnitId:i,ruleId:d,setting:S};C(_.UpdateSheetDataValidationSettingCommand.id,F,void 0)},re=async()=>{await g.executeCommand(_.RemoveSheetDataValidationCommand.id,{ruleId:d,unitId:r,subUnitId:i}),a.setActiveRule(null)},se={type:v.type,operator:v.operator,formula1:v.formula1,formula2:v.formula2,allowBlank:v.allowBlank},q=S=>{const F=l.getValidatorItem(S);if(!F)return;const X=F.operators,ge=u.getRuleById(r,i,d),ne=S===(ge==null?void 0:ge.type)||S.includes("list")&&(ge!=null&&ge.type.includes("list"))?{...ge,type:S}:{...v,type:S,operator:X[0],formula1:void 0,formula2:void 0};T(ne),g.executeCommand(_.UpdateSheetDataValidationSettingCommand.id,{unitId:r,subUnitId:i,ruleId:v.uid,setting:Y.getRuleSetting(ne)})},Z=h.get(M.formulaInput),ce=b.useMemo(()=>D.map(S=>tt.serializeRange(S.range)).join(","),[]),te=Y.getRuleOptions(v),Q=S=>{o.shallowEqual(S,Y.getRuleOptions(v))||(T({...v,...S}),C(_.UpdateSheetDataValidationOptionsCommand.id,{unitId:r,subUnitId:i,ruleId:d,options:S}))},J=U.length&&!v.operator;return p.jsxs("div",{"data-u-comp":"data-validation-detail",className:"univer-py-2",children:[p.jsx(V.FormLayout,{label:I.t("dataValidation.panel.range"),error:!v.ranges.length||w?I.t("dataValidation.panel.rangeError"):"",children:p.jsx(ot.RangeSelector,{selectorRef:x,unitId:r,subUnitId:i,initialValue:ce,onChange:(S,F)=>{var X;!W&&((X=x.current)!=null&&X.verify())&&ee(F)},onFocusChange:(S,F)=>{var X;O(S),!S&&F&&((X=x.current)!=null&&X.verify())&&ee(F)},onVerify:S=>k(!S)})}),p.jsx(V.FormLayout,{label:I.t("dataValidation.panel.type"),children:p.jsx(V.Select,{className:"univer-w-full",value:v.type,options:(P=f==null?void 0:f.sort((S,F)=>S.order-F.order))==null?void 0:P.map(S=>({label:I.t(S.title),value:S.id})),onChange:q})}),U!=null&&U.length?p.jsx(V.FormLayout,{label:I.t("dataValidation.panel.operator"),children:p.jsx(V.Select,{className:"univer-w-full",value:`${v.operator}`,options:[{value:"",label:I.t("dataValidation.operators.legal")},...U.map((S,F)=>({value:`${S}`,label:B[F]}))],onChange:S=>{ae({...se,operator:S})}})}):null,Z&&!J?p.jsx(Z,{isTwoFormula:K,value:{formula1:v.formula1,formula2:v.formula2},onChange:S=>{ae({...se,...S})},showError:m,validResult:M.validatorFormula(v,r,i),unitId:r,subUnitId:i,ruleId:d},e+v.type):null,p.jsx(V.FormLayout,{children:p.jsx(V.Checkbox,{checked:($=v.allowBlank)!=null?$:!0,onChange:()=>{var S;return ae({...se,allowBlank:!((S=v.allowBlank)==null||S)})},children:I.t("dataValidation.panel.allowBlank")})}),p.jsx(vn,{value:te,onChange:Q,extraComponent:M.optionsInput}),p.jsxs("div",{className:"univer-mt-5 univer-flex univer-flex-row univer-justify-end",children:[p.jsx(V.Button,{className:"univer-ml-3",onClick:re,children:I.t("dataValidation.panel.removeRule")}),p.jsx(V.Button,{className:"univer-ml-3",variant:"primary",onClick:z,children:I.t("dataValidation.panel.done")})]})]})}const _n=e=>{const{rule:t,onClick:a,unitId:n,subUnitId:r,disable:i}=e,s=E.useDependency(Y.DataValidatorRegistryService),d=E.useDependency(o.ICommandService),l=E.useDependency(N.IMarkSelectionService),c=s.getValidatorItem(t.type),h=b.useRef(void 0),[g,u]=b.useState(!1),I=E.useDependency(o.ThemeService),v=E.useObservable(I.currentTheme$),T=b.useMemo(()=>{var R;const m=I.getColorFromTheme("primary.600"),y=I.getColorFromTheme("loop-color.2"),f=(R=I.getColorFromTheme(y))!=null?R:m,D=new o.ColorKit(f).toRgb();return{fill:`rgba(${D.r}, ${D.g}, ${D.b}, 0.1)`,stroke:f}},[v]),M=m=>{d.executeCommand(_.RemoveSheetDataValidationCommand.id,{ruleId:t.uid,unitId:n,subUnitId:r}),m.stopPropagation()};return b.useEffect(()=>()=>{var m;h.current&&((m=h.current)==null||m.forEach(y=>{y&&l.removeShape(y)}))},[l]),p.jsxs("div",{className:V.clsx(`
1
+ "use strict";var At=Object.defineProperty;var Lt=(e,t,a)=>t in e?At(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a;var A=(e,t,a)=>Lt(e,typeof t!="symbol"?t+"":t,a);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("@univerjs/core"),L=require("@univerjs/engine-render"),H=require("@univerjs/sheets"),_=require("@univerjs/sheets-data-validation"),Y=require("@univerjs/data-validation"),E=require("@univerjs/ui"),oe=require("rxjs"),jt=require("@univerjs/sheets-numfmt"),N=require("@univerjs/sheets-ui"),V=require("@univerjs/design"),b=require("react"),p=require("react/jsx-runtime"),tt=require("@univerjs/engine-formula"),ot=require("@univerjs/sheets-formula-ui");var xt=Object.getOwnPropertyDescriptor,Ut=(e,t,a,n)=>{for(var r=n>1?void 0:n?xt(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},ht=(e,t)=>(a,n)=>t(a,n,e);let he=class extends o.Disposable{constructor(t,a){super();A(this,"_open$",new oe.BehaviorSubject(!1));A(this,"open$",this._open$.pipe(oe.distinctUntilChanged()));A(this,"_activeRule");A(this,"_activeRule$",new oe.BehaviorSubject(void 0));A(this,"activeRule$",this._activeRule$.asObservable());A(this,"_closeDisposable",null);this._univerInstanceService=t,this._sidebarService=a,this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(o.UniverInstanceType.UNIVER_SHEET).pipe(oe.filter(n=>!n)).subscribe(()=>{this.close()})),this.disposeWithMe(this._sidebarService.sidebarOptions$.subscribe(n=>{n.id===Fe&&(n.visible||setTimeout(()=>{this._sidebarService.sidebarOptions$.next({visible:!1})}))}))}get activeRule(){return this._activeRule}get isOpen(){return this._open$.getValue()}dispose(){var t;super.dispose(),this._open$.next(!1),this._open$.complete(),this._activeRule$.complete(),(t=this._closeDisposable)==null||t.dispose()}open(){this._open$.next(!0)}close(){var t;this._open$.next(!1),(t=this._closeDisposable)==null||t.dispose()}setCloseDisposable(t){this._closeDisposable=o.toDisposable(()=>{t.dispose(),this._closeDisposable=null})}setActiveRule(t){this._activeRule=t,this._activeRule$.next(t)}};he=Ut([ht(0,o.IUniverInstanceService),ht(1,E.ISidebarService)],he);const st="sheets-data-validation-ui.config",Ue={};var Ft=Object.getOwnPropertyDescriptor,kt=(e,t,a,n)=>{for(var r=n>1?void 0:n?Ft(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},Ie=(e,t)=>(a,n)=>t(a,n,e);let we=class extends o.Disposable{constructor(e,t,a,n,r,i){super(),this._sheetInterceptorService=e,this._dataValidationModel=t,this._dataValidatorRegistryService=a,this._dialogService=n,this._localeService=r,this._sheetsDataValidationValidatorService=i,this._initEditorBridgeInterceptor()}_initEditorBridgeInterceptor(){this._sheetInterceptorService.writeCellInterceptor.intercept(H.VALIDATE_CELL,{handler:async(e,t,a)=>{const n=await e,{row:r,col:i,unitId:s,subUnitId:d}=t,l=this._dataValidationModel.getRuleIdByLocation(s,d,r,i),c=l?this._dataValidationModel.getRuleById(s,d,l):void 0;if(n===!1)return a(Promise.resolve(!1));if(!c||c.errorStyle!==o.DataValidationErrorStyle.STOP)return a(Promise.resolve(!0));const h=this._dataValidatorRegistryService.getValidatorItem(c.type);return!h||await this._sheetsDataValidationValidatorService.validatorCell(s,d,r,i)===o.DataValidationStatus.VALID?a(Promise.resolve(!0)):(this._dialogService.open({width:368,title:{title:this._localeService.t("dataValidation.alert.title")},id:"reject-input-dialog",children:{title:h.getRuleFinalError(c,{row:r,col:i,unitId:s,subUnitId:d})},footer:{title:b.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")}}),a(Promise.resolve(!1)))}})}showReject(e){this._dialogService.open({width:368,title:{title:this._localeService.t("dataValidation.alert.title")},id:"reject-input-dialog",children:{title:e},footer:{title:b.createElement(V.Button,{variant:"primary",onClick:()=>this._dialogService.close("reject-input-dialog")},this._localeService.t("dataValidation.alert.ok"))},onClose:()=>{this._dialogService.close("reject-input-dialog")}})}};we=kt([Ie(0,o.Inject(H.SheetInterceptorService)),Ie(1,o.Inject(_.SheetDataValidationModel)),Ie(2,o.Inject(Y.DataValidatorRegistryService)),Ie(3,E.IDialogService),Ie(4,o.Inject(o.LocaleService)),Ie(5,o.Inject(_.SheetsDataValidationValidatorService))],we);var Nt=Object.getOwnPropertyDescriptor,Bt=(e,t,a,n)=>{for(var r=n>1?void 0:n?Nt(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},le=(e,t)=>(a,n)=>t(a,n,e);const Ye=e=>{if(e==null||typeof e=="boolean")return;if(typeof e=="number"||!Number.isNaN(+e))return o.dayjs(o.numfmt.format("yyyy-MM-dd HH:mm:ss",Number(e)));const t=o.dayjs(e);if(t.isValid())return t};function Wt(e,t){const a=jt.getPatternType(t);if(e===a)return t;switch(e){case"datetime":return"yyyy-MM-dd hh:mm:ss";case"date":return"yyyy-MM-dd";case"time":return"HH:mm:ss"}}let fe=class extends o.Disposable{constructor(t,a,n,r,i,s,d,l,c,h,g){super();A(this,"_activeDropdown");A(this,"_activeDropdown$",new oe.Subject);A(this,"_currentPopup",null);A(this,"activeDropdown$",this._activeDropdown$.asObservable());A(this,"_zenVisible",!1);this._univerInstanceService=t,this._dataValidatorRegistryService=a,this._zenZoneService=n,this._dataValidationModel=r,this._sheetsSelectionsService=i,this._cellDropdownManagerService=s,this._sheetDataValidationModel=d,this._commandService=l,this._editorBridgeService=c,this._injector=h,this._configService=g,this._init(),this._initSelectionChange(),this.disposeWithMe(()=>{this._activeDropdown$.complete()})}get activeDropdown(){return this._activeDropdown}_init(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(t=>{this._zenVisible=t,t&&this.hideDropdown()}))}_getDropdownByCell(t,a,n,r){const i=t?this._univerInstanceService.getUnit(t,o.UniverInstanceType.UNIVER_SHEET):this._univerInstanceService.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET);if(!i)return;const s=a?i.getSheetBySheetId(a):i.getActiveSheet();if(!s)return;const d=this._dataValidationModel.getRuleByLocation(i.getUnitId(),s.getSheetId(),n,r);if(!d)return;const l=this._dataValidatorRegistryService.getValidatorItem(d.type);return l==null?void 0:l.dropdownType}_initSelectionChange(){this.disposeWithMe(this._sheetsSelectionsService.selectionMoveEnd$.subscribe(t=>{t&&t.every(a=>!(a.primary&&this._getDropdownByCell(a.primary.unitId,a.primary.sheetId,a.primary.actualRow,a.primary.actualColumn)))&&this.hideDropdown()}))}showDropdown(t){var T,M,m,y;const{location:a}=t,{row:n,col:r,unitId:i,subUnitId:s,workbook:d,worksheet:l}=a;if(this._currentPopup&&this._currentPopup.dispose(),this._zenVisible)return;this._activeDropdown=t,this._activeDropdown$.next(this._activeDropdown);const c=this._sheetDataValidationModel.getRuleByLocation(i,s,n,r);if(!c)return;const h=this._dataValidatorRegistryService.getValidatorItem(c.type);if(!(h!=null&&h.dropdownType))return;let g;const u=async(f,D)=>{var j,U,B;if(!f)return!0;const R=f,C=l.getCell(n,r),w=R.format(D==="date"?"YYYY-MM-DD 00:00:00":"YYYY-MM-DD HH:mm:ss"),k=(j=o.numfmt.parseDate(w))==null?void 0:j.v,W=D==="time"?k%1:k,O=d.getStyles().getStyleByCell(C),x=(B=(U=O==null?void 0:O.n)==null?void 0:U.pattern)!=null?B:"";return c.errorStyle!==o.DataValidationErrorStyle.STOP||await h.validator({value:W,unitId:i,subUnitId:s,row:n,column:r,worksheet:l,workbook:d,interceptValue:w.replace("Z","").replace("T"," "),t:o.CellValueType.NUMBER},c)?(await this._commandService.executeCommand(H.SetRangeValuesCommand.id,{unitId:i,subUnitId:s,range:{startColumn:r,endColumn:r,startRow:n,endRow:n},value:{v:W,t:2,p:null,f:null,si:null,s:{n:{pattern:Wt(D,x)}}}}),await this._commandService.executeCommand(N.SetCellEditVisibleOperation.id,{visible:!1,eventType:L.DeviceInputEventType.Keyboard,unitId:i,keycode:E.KeyCode.ESC}),!0):(this._injector.has(we)&&this._injector.get(we).showReject(h.getRuleFinalError(c,{row:n,col:r,unitId:i,subUnitId:s})),!1)};let I;switch(h.dropdownType){case Y.DataValidatorDropdownType.DATE:{const f=_.getCellValueOrigin(l.getCellRaw(n,r)),D=Ye(f),R=!!((T=c.bizInfo)!=null&&T.showTime);I={location:a,type:"datepicker",props:{showTime:R,onChange:C=>u(C,R?"datetime":"date"),defaultValue:D,patternType:"date"}};break}case Y.DataValidatorDropdownType.TIME:{const f=_.getCellValueOrigin(l.getCellRaw(n,r)),D=Ye(f);I={location:a,type:"datepicker",props:{onChange:R=>u(R,"time"),defaultValue:D,patternType:"time"}};break}case Y.DataValidatorDropdownType.DATETIME:{const f=_.getCellValueOrigin(l.getCellRaw(n,r)),D=Ye(f);I={location:a,type:"datepicker",props:{onChange:R=>u(R,"datetime"),defaultValue:D,patternType:"datetime"}};break}case Y.DataValidatorDropdownType.LIST:case Y.DataValidatorDropdownType.MULTIPLE_LIST:{const f=h.dropdownType===Y.DataValidatorDropdownType.MULTIPLE_LIST,D=async O=>{const x=_.serializeListOptions(O),j={unitId:i,subUnitId:s,range:{startColumn:r,endColumn:r,startRow:n,endRow:n},value:{v:x,p:null,f:null,si:null}};return this._commandService.executeCommand(H.SetRangeValuesCommand.id,j),this._editorBridgeService.isVisible().visible&&await this._commandService.executeCommand(N.SetCellEditVisibleOperation.id,{visible:!1,eventType:L.DeviceInputEventType.Keyboard,unitId:i,keycode:E.KeyCode.ESC}),!f},R=(c==null?void 0:c.renderMode)===o.DataValidationRenderMode.CUSTOM||(c==null?void 0:c.renderMode)===void 0,C=h.getListWithColor(c,i,s),w=_.getDataValidationCellValue(l.getCellRaw(n,r)),k=()=>{this._commandService.executeCommand(Se.id,{ruleId:c.uid}),g==null||g.dispose()},W=C.map(O=>({label:O.label,value:O.label,color:R||O.color?O.color:"transparent"}));I={location:a,type:"list",props:{onChange:O=>D(O),options:W,onEdit:k,defaultValue:w,multiple:f,showEdit:(m=(M=this._configService.getConfig(st))==null?void 0:M.showEditOnDropdown)!=null?m:!0}};break}case Y.DataValidatorDropdownType.CASCADE:{I={type:"cascader",props:{onChange:D=>{const R={unitId:i,subUnitId:s,range:{startColumn:r,endColumn:r,startRow:n,endRow:n},value:{v:D.join("/"),p:null,f:null,si:null}};return this._commandService.syncExecuteCommand(H.SetRangeValuesCommand.id,R),this._editorBridgeService.isVisible().visible&&this._commandService.syncExecuteCommand(N.SetCellEditVisibleOperation.id,{visible:!1,eventType:L.DeviceInputEventType.Keyboard,unitId:i,keycode:E.KeyCode.ESC}),!0},defaultValue:_.getDataValidationCellValue(l.getCellRaw(n,r)).split("/"),options:JSON.parse((y=c.formula1)!=null?y:"[]")},location:a};break}case Y.DataValidatorDropdownType.COLOR:{I={type:"color",props:{onChange:D=>{const R={unitId:i,subUnitId:s,range:{startColumn:r,endColumn:r,startRow:n,endRow:n},value:{v:D,p:null,f:null,si:null}};return this._commandService.syncExecuteCommand(H.SetRangeValuesCommand.id,R),this._editorBridgeService.isVisible().visible&&this._commandService.syncExecuteCommand(N.SetCellEditVisibleOperation.id,{visible:!1,eventType:L.DeviceInputEventType.Keyboard,unitId:i,keycode:E.KeyCode.ESC}),!0},defaultValue:_.getDataValidationCellValue(l.getCellRaw(n,r))},location:a};break}default:throw new Error("[DataValidationDropdownManagerService]: unknown type!")}if(g=this._cellDropdownManagerService.showDropdown({...I,onHide:()=>{this._activeDropdown=null,this._activeDropdown$.next(null)}}),!g)throw new Error("[DataValidationDropdownManagerService]: cannot show dropdown!");const v=new o.DisposableCollection;v.add(g),v.add({dispose:()=>{var f,D;(D=(f=this._activeDropdown)==null?void 0:f.onHide)==null||D.call(f)}}),this._currentPopup=v}hideDropdown(){this._activeDropdown&&(this._currentPopup&&this._currentPopup.dispose(),this._currentPopup=null,this._activeDropdown=null,this._activeDropdown$.next(null))}showDataValidationDropdown(t,a,n,r,i){const s=this._univerInstanceService.getUnit(t,o.UniverInstanceType.UNIVER_SHEET);if(!s)return;const d=s.getSheetBySheetId(a);if(!d)return;const l=this._dataValidationModel.getRuleByLocation(s.getUnitId(),d.getSheetId(),n,r);if(!l)return;const c=this._dataValidatorRegistryService.getValidatorItem(l.type);if(!c||!c.dropdownType){this.hideDropdown();return}this.showDropdown({location:{workbook:s,worksheet:d,row:n,col:r,unitId:t,subUnitId:a},onHide:i})}};fe=Bt([le(0,o.IUniverInstanceService),le(1,o.Inject(Y.DataValidatorRegistryService)),le(2,E.IZenZoneService),le(3,o.Inject(_.SheetDataValidationModel)),le(4,o.Inject(H.SheetsSelectionsService)),le(5,o.Inject(N.ISheetCellDropdownManagerService)),le(6,o.Inject(_.SheetDataValidationModel)),le(7,o.ICommandService),le(8,N.IEditorBridgeService),le(9,o.Inject(o.Injector)),le(10,o.IConfigService)],fe);const Fe="DataValidationPanel",Se={id:"data-validation.operation.open-validation-panel",type:o.CommandType.OPERATION,handler(e,t){if(!t)return!1;const{ruleId:a,isAdd:n}=t,r=e.get(he),i=e.get(Y.DataValidationModel),s=e.get(o.IUniverInstanceService),d=e.get(E.ISidebarService),l=H.getSheetCommandTarget(s);if(!l)return!1;const{unitId:c,subUnitId:h}=l,g=a?i.getRuleById(c,h,a):void 0;r.open(),r.setActiveRule(g&&{unitId:c,subUnitId:h,rule:g});const u=d.open({id:Fe,header:{title:n?"dataValidation.panel.addTitle":"dataValidation.panel.title"},children:{label:Fe},width:312,onClose:()=>r.close()});return r.setCloseDisposable(u),!0}},lt={id:"data-validation.operation.close-validation-panel",type:o.CommandType.OPERATION,handler(e){return e.get(he).close(),!0}},_t={id:"data-validation.operation.toggle-validation-panel",type:o.CommandType.OPERATION,handler(e){const t=e.get(o.ICommandService),a=e.get(he);return a.open(),a.isOpen?t.executeCommand(lt.id):t.executeCommand(Se.id),!0}},He={type:o.CommandType.OPERATION,id:"sheet.operation.show-data-validation-dropdown",handler(e,t){if(!t)return!1;const a=e.get(fe),{unitId:n,subUnitId:r,row:i,column:s}=t,d=a.activeDropdown,l=d==null?void 0:d.location;return l&&l.unitId===n&&l.subUnitId===r&&l.row===i&&l.col===s||a.showDataValidationDropdown(n,r,i,s),!0}},It={type:o.CommandType.OPERATION,id:"sheet.operation.hide-data-validation-dropdown",handler(e,t){return t?(e.get(fe).hideDropdown(),!0):!1}},$e={type:o.CommandType.COMMAND,id:"data-validation.command.addRuleAndOpen",handler(e){const t=e.get(o.IUniverInstanceService),a=H.getSheetCommandTarget(t);if(!a)return!1;const{workbook:n,worksheet:r}=a,i=_.createDefaultNewRule(e),s=e.get(o.ICommandService),d=n.getUnitId(),l=r.getSheetId(),c={rule:i,unitId:d,subUnitId:l};return s.syncExecuteCommand(_.AddSheetDataValidationCommand.id,c)?(s.syncExecuteCommand(Se.id,{ruleId:i.uid,isAdd:!0}),!0):!1}};var Ht=Object.getOwnPropertyDescriptor,$t=(e,t,a,n)=>{for(var r=n>1?void 0:n?Ht(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},Ce=(e,t)=>(a,n)=>t(a,n,e);const pe="SHEET_DATA_VALIDATION_ALERT";let Pe=class extends o.Disposable{constructor(e,t,a,n,r,i){super(),this._hoverManagerService=e,this._cellAlertManagerService=t,this._univerInstanceService=a,this._localeService=n,this._zenZoneService=r,this._dataValidationModel=i,this._init()}_init(){this._initCellAlertPopup(),this._initZenService()}_initCellAlertPopup(){this.disposeWithMe(this._hoverManagerService.currentCell$.pipe(oe.debounceTime(100)).subscribe(e=>{var t;if(e){const a=this._univerInstanceService.getUnit(e.location.unitId,o.UniverInstanceType.UNIVER_SHEET),n=a.getSheetBySheetId(e.location.subUnitId);if(!n)return;const r=this._dataValidationModel.getRuleByLocation(e.location.unitId,e.location.subUnitId,e.location.row,e.location.col);if(!r){this._cellAlertManagerService.removeAlert(pe);return}if(this._dataValidationModel.validator(r,{...e.location,workbook:a,worksheet:n})===o.DataValidationStatus.INVALID){const s=this._cellAlertManagerService.currentAlert.get(pe),d=(t=s==null?void 0:s.alert)==null?void 0:t.location;if(d&&d.row===e.location.row&&d.col===e.location.col&&d.subUnitId===e.location.subUnitId&&d.unitId===e.location.unitId){this._cellAlertManagerService.removeAlert(pe);return}const l=this._dataValidationModel.getValidator(r.type);if(!l){this._cellAlertManagerService.removeAlert(pe);return}this._cellAlertManagerService.showAlert({type:N.CellAlertType.ERROR,title:this._localeService.t("dataValidation.error.title"),message:l==null?void 0:l.getRuleFinalError(r,e.location),location:e.location,width:200,height:74,key:pe});return}}this._cellAlertManagerService.removeAlert(pe)}))}_initZenService(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(e=>{e&&this._cellAlertManagerService.removeAlert(pe)}))}};Pe=$t([Ce(0,o.Inject(N.HoverManagerService)),Ce(1,o.Inject(N.CellAlertManagerService)),Ce(2,o.IUniverInstanceService),Ce(3,o.Inject(o.LocaleService)),Ce(4,E.IZenZoneService),Ce(5,o.Inject(_.SheetDataValidationModel))],Pe);var Yt=Object.getOwnPropertyDescriptor,Xt=(e,t,a,n)=>{for(var r=n>1?void 0:n?Yt(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},Xe=(e,t)=>(a,n)=>t(a,n,e);let Ve=class extends o.Disposable{constructor(e,t,a){super(),this._autoFillService=e,this._sheetDataValidationModel=t,this._injector=a,this._initAutoFill()}_initAutoFill(){const e=()=>({redos:[],undos:[]}),t=(n,r)=>{const{source:i,target:s,unitId:d,subUnitId:l}=n,c=this._sheetDataValidationModel.getRuleObjectMatrix(d,l).clone(),h=N.virtualizeDiscreteRanges([i,s]),[g,u]=h.ranges,{mapFunc:I}=h,v={row:g.startRow,col:g.startColumn},T=N.getAutoFillRepeatRange(g,u),M=new o.ObjectMatrix,m=new Set;T.forEach(C=>{const w=C.repeatStartCell,k=C.relativeRange,W={startRow:v.row,startColumn:v.col,endColumn:v.col,endRow:v.row},O={startRow:w.row,startColumn:w.col,endColumn:w.col,endRow:w.row};o.Range.foreach(k,(x,j)=>{const U=o.Rectangle.getPositionRange({startRow:x,startColumn:j,endColumn:j,endRow:x},W),{row:B,col:K}=I(U.startRow,U.startColumn),z=this._sheetDataValidationModel.getRuleIdByLocation(d,l,B,K)||"",ee=o.Rectangle.getPositionRange({startRow:x,startColumn:j,endColumn:j,endRow:x},O),{row:ae,col:re}=I(ee.startRow,ee.startColumn);M.setValue(ae,re,z),m.add(z)})});const y=Array.from(m).map(C=>({id:C,ranges:o.queryObjectMatrix(M,w=>w===C)}));c.addRangeRules(y);const f=c.diff(this._sheetDataValidationModel.getRules(d,l)),{redoMutations:D,undoMutations:R}=_.getDataValidationDiffMutations(d,l,f,this._injector,"patched",r===N.APPLY_TYPE.ONLY_FORMAT);return{undos:R,redos:D}},a={id:_.DATA_VALIDATION_PLUGIN_NAME,onBeforeFillData:n=>{const{source:r,unitId:i,subUnitId:s}=n;for(const d of r.rows)for(const l of r.cols){const c=this._sheetDataValidationModel.getRuleByLocation(i,s,d,l);if(c&&c.type===o.DataValidationType.CHECKBOX){this._autoFillService.setDisableApplyType(N.APPLY_TYPE.SERIES,!0);return}}},onFillData:(n,r,i)=>i===N.APPLY_TYPE.COPY||i===N.APPLY_TYPE.ONLY_FORMAT||i===N.APPLY_TYPE.SERIES?t(n,i):e(),onAfterFillData:()=>{}};this.disposeWithMe(this._autoFillService.addHook(a))}};Ve=Xt([Xe(0,N.IAutoFillService),Xe(1,o.Inject(_.SheetDataValidationModel)),Xe(2,o.Inject(o.Injector))],Ve);var zt=Object.getOwnPropertyDescriptor,Kt=(e,t,a,n)=>{for(var r=n>1?void 0:n?zt(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},ze=(e,t)=>(a,n)=>t(a,n,e);let Ee=class extends o.Disposable{constructor(t,a,n){super();A(this,"_copyInfo");this._sheetClipboardService=t,this._sheetDataValidationModel=a,this._injector=n,this._initCopyPaste()}_initCopyPaste(){this._sheetClipboardService.addClipboardHook({id:_.DATA_VALIDATION_PLUGIN_NAME,onBeforeCopy:(t,a,n)=>this._collect(t,a,n),onPasteCells:(t,a,n,r)=>{const{copyType:i=N.COPY_TYPE.COPY,pasteType:s}=r,{range:d}=t||{},{range:l,unitId:c,subUnitId:h}=a;return this._generateMutations(l,{copyType:i,pasteType:s,copyRange:d,unitId:c,subUnitId:h})}})}_collect(t,a,n){const r=new o.ObjectMatrix;this._copyInfo={unitId:t,subUnitId:a,matrix:r};const i=this._injector.invoke(l=>H.rangeToDiscreteRange(n,l,t,a));if(!i)return;const{rows:s,cols:d}=i;s.forEach((l,c)=>{d.forEach((h,g)=>{const u=this._sheetDataValidationModel.getRuleIdByLocation(t,a,l,h);r.setValue(c,g,u!=null?u:"")})})}_generateMutations(t,a){if(!this._copyInfo)return{redos:[],undos:[]};if(a.copyType===N.COPY_TYPE.CUT)return this._copyInfo=null,{redos:[],undos:[]};if(!this._copyInfo||!this._copyInfo.matrix.getSizeOf()||!a.copyRange)return{redos:[],undos:[]};if([N.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_COL_WIDTH,N.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_VALUE,N.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMAT,N.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMULA].includes(a.pasteType))return{redos:[],undos:[]};const{unitId:r,subUnitId:i}=this._copyInfo;if(a.unitId!==r||i!==a.subUnitId){const s=this._sheetDataValidationModel.getRuleObjectMatrix(a.unitId,a.subUnitId).clone(),d=new o.ObjectMatrix,l=new Set,{ranges:[c,h],mapFunc:g}=N.virtualizeDiscreteRanges([a.copyRange,t]),u=N.getRepeatRange(c,h,!0),I=new Map;u.forEach(({startRange:m})=>{var y;(y=this._copyInfo)==null||y.matrix.forValue((f,D,R)=>{const C=o.Rectangle.getPositionRange({startRow:f,endRow:f,startColumn:D,endColumn:D},m),w=`${i}-${R}`,k=this._sheetDataValidationModel.getRuleById(r,i,R);!this._sheetDataValidationModel.getRuleById(a.unitId,a.subUnitId,w)&&k&&I.set(w,{...k,uid:w});const{row:W,col:O}=g(C.startRow,C.startColumn);l.add(w),d.setValue(W,O,w)})});const v=Array.from(l).map(m=>({id:m,ranges:o.queryObjectMatrix(d,y=>y===m)}));s.addRangeRules(v);const{redoMutations:T,undoMutations:M}=_.getDataValidationDiffMutations(a.unitId,a.subUnitId,s.diffWithAddition(this._sheetDataValidationModel.getRules(a.unitId,a.subUnitId),I.values()),this._injector,"patched",!1);return{redos:T,undos:M}}else{const s=this._sheetDataValidationModel.getRuleObjectMatrix(r,i).clone(),d=new o.ObjectMatrix,l=new Set,{ranges:[c,h],mapFunc:g}=N.virtualizeDiscreteRanges([a.copyRange,t]);N.getRepeatRange(c,h,!0).forEach(({startRange:M})=>{var m;(m=this._copyInfo)==null||m.matrix.forValue((y,f,D)=>{const R=o.Rectangle.getPositionRange({startRow:y,endRow:y,startColumn:f,endColumn:f},M),{row:C,col:w}=g(R.startRow,R.startColumn);d.setValue(C,w,D),l.add(D)})});const I=Array.from(l).map(M=>({id:M,ranges:o.queryObjectMatrix(d,m=>m===M)}));s.addRangeRules(I);const{redoMutations:v,undoMutations:T}=_.getDataValidationDiffMutations(r,i,s.diff(this._sheetDataValidationModel.getRules(r,i)),this._injector,"patched",!1);return{redos:v,undos:T}}}};Ee=Kt([ze(0,N.ISheetClipboardService),ze(1,o.Inject(_.SheetDataValidationModel)),ze(2,o.Inject(o.Injector))],Ee);var Zt=Object.getOwnPropertyDescriptor,Gt=(e,t,a,n)=>{for(var r=n>1?void 0:n?Zt(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},Ke=(e,t)=>(a,n)=>t(a,n,e);let Me=class extends o.Disposable{constructor(e,t,a){super(),this._localeService=e,this._commandService=t,this._sheetPermissionCheckController=a,this._commandExecutedListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.beforeCommandExecuted(e=>{e.id===_.AddSheetDataValidationCommand.id&&(this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[H.WorkbookEditablePermission],rangeTypes:[H.RangeProtectionPermissionEditPoint],worksheetTypes:[H.WorksheetEditPermission,H.WorksheetSetCellStylePermission]})||this._sheetPermissionCheckController.blockExecuteWithoutPermission(this._localeService.t("permission.dialog.setStyleErr"))),e.id===_.UpdateSheetDataValidationRangeCommand.id&&(this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[H.WorkbookEditablePermission],rangeTypes:[H.RangeProtectionPermissionEditPoint],worksheetTypes:[H.WorksheetEditPermission,H.WorksheetSetCellStylePermission]},e.params.ranges)||this._sheetPermissionCheckController.blockExecuteWithoutPermission(this._localeService.t("permission.dialog.setStyleErr")))}))}};Me=Gt([Ke(0,o.Inject(o.LocaleService)),Ke(1,o.ICommandService),Ke(2,o.Inject(H.SheetPermissionCheckController))],Me);const Ct="sheet.menu.data-validation";function qt(e){return{id:Ct,type:E.MenuItemType.SUBITEMS,icon:"DataValidationIcon",tooltip:"dataValidation.title",hidden$:E.getMenuHiddenObservable(e,o.UniverInstanceType.UNIVER_SHEET),disabled$:N.getCurrentRangeDisable$(e,{workbookTypes:[H.WorkbookEditablePermission],worksheetTypes:[H.WorksheetSetCellStylePermission,H.WorksheetEditPermission],rangeTypes:[H.RangeProtectionPermissionEditPoint]})}}function Jt(e){return{id:Se.id,title:"dataValidation.panel.title",type:E.MenuItemType.BUTTON}}function Qt(e){return{id:$e.id,title:"dataValidation.panel.add",type:E.MenuItemType.BUTTON}}const en={[E.RibbonDataGroup.RULES]:{[Ct]:{order:0,menuItemFactory:qt,[Se.id]:{order:0,menuItemFactory:Jt},[$e.id]:{order:1,menuItemFactory:Qt}}}};var tn=Object.getOwnPropertyDescriptor,yt=(e,t,a,n)=>{for(var r=n>1?void 0:n?tn(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},G=(e,t)=>(a,n)=>t(a,n,e);const Rt={tr:{size:6,color:"#fe4b4b"}};let be=class extends o.RxDisposable{constructor(e,t,a,n,r,i,s,d,l,c,h){super(),this._commandService=e,this._menuManagerService=t,this._renderManagerService=a,this._univerInstanceService=n,this._autoHeightController=r,this._dropdownManagerService=i,this._sheetDataValidationModel=s,this._dataValidatorRegistryService=d,this._sheetInterceptorService=l,this._dataValidationCacheService=c,this._editorBridgeService=h,this._initMenu(),this._initDropdown(),this._initViewModelIntercept(),this._initAutoHeight()}_initMenu(){this._menuManagerService.mergeMenu(en)}_initDropdown(){this._editorBridgeService&&this.disposeWithMe(this._editorBridgeService.visible$.subscribe(e=>{var a;if(!e.visible){((a=this._dropdownManagerService.activeDropdown)==null?void 0:a.trigger)==="editor-bridge"&&this._dropdownManagerService.hideDropdown();return}const t=this._editorBridgeService.getEditCellState();if(t){const{unitId:n,sheetId:r,row:i,column:s}=t,d=this._univerInstanceService.getUniverSheetInstance(n);if(!d)return;const l=this._sheetDataValidationModel.getRuleByLocation(n,r,i,s);if(!l)return;const c=this._dataValidatorRegistryService.getValidatorItem(l.type);if(!(c!=null&&c.dropdownType))return;const h=d.getActiveSheet();if(!h)return;const g=this._dropdownManagerService.activeDropdown,u=g==null?void 0:g.location;if(u&&u.unitId===n&&u.subUnitId===r&&u.row===i&&u.col===s)return;this._dropdownManagerService.showDropdown({location:{unitId:n,subUnitId:r,row:i,col:s,workbook:d,worksheet:h},trigger:"editor-bridge",closeOnOutSide:!1})}}))}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(H.INTERCEPTOR_POINT.CELL_CONTENT,{effect:o.InterceptorEffectEnum.Style,priority:H.InterceptCellContentPriority.DATA_VALIDATION,handler:(e,t,a)=>{var m,y,f,D,R;const{row:n,col:r,unitId:i,subUnitId:s,workbook:d,worksheet:l}=t,c=this._sheetDataValidationModel.getRuleIdByLocation(i,s,n,r);if(!c)return a(e);const h=this._sheetDataValidationModel.getRuleById(i,s,c);if(!h)return a(e);const g=(m=this._dataValidationCacheService.getValue(i,s,n,r))!=null?m:o.DataValidationStatus.VALID,u=this._dataValidatorRegistryService.getValidatorItem(h.type),I=t.rawData;let v;const T={get value(){var C;return v!==void 0||(v=(C=_.getCellValueOrigin(I))!=null?C:null),v}},M={get value(){var C;return`${(C=T.value)!=null?C:""}`}};return(!e||e===t.rawData)&&(e={...t.rawData}),e.markers={...e==null?void 0:e.markers,...g===o.DataValidationStatus.INVALID?Rt: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:((f=e==null?void 0:e.fontRenderExtension)==null?void 0:f.isSkip)||((D=u==null?void 0:u.skipDefaultFontRender)==null?void 0:D.call(u,h,T.value,t))},e.interceptorStyle={...e==null?void 0:e.interceptorStyle,...u==null?void 0:u.getExtraStyle(h,M.value,{get style(){const C=d.getStyles();return(typeof(e==null?void 0:e.s)=="string"?C.get(e==null?void 0:e.s):e==null?void 0:e.s)||{}}},n,r)},e.interceptorAutoHeight=()=>{var W,O,x,j,U,B;const C=(O=(W=this._renderManagerService.getRenderById(i))==null?void 0:W.with(N.SheetSkeletonManagerService).getSkeletonParam(s))==null?void 0:O.skeleton;if(!C)return;const w=C.worksheet.getMergedCell(n,r),k={data:e,style:C.getStyles().getStyleByCell(e),primaryWithCoord:C.getCellWithCoordByIndex((x=w==null?void 0:w.startRow)!=null?x:n,(j=w==null?void 0:w.startColumn)!=null?j:r),unitId:i,subUnitId:s,row:n,col:r,workbook:d,worksheet:l};return(B=(U=u==null?void 0:u.canvasRender)==null?void 0:U.calcCellAutoHeight)==null?void 0:B.call(U,k)},e.interceptorAutoWidth=()=>{var W,O,x,j,U,B;const C=(O=(W=this._renderManagerService.getRenderById(i))==null?void 0:W.with(N.SheetSkeletonManagerService).getSkeletonParam(s))==null?void 0:O.skeleton;if(!C)return;const w=C.worksheet.getMergedCell(n,r),k={data:e,style:C.getStyles().getStyleByCell(e),primaryWithCoord:C.getCellWithCoordByIndex((x=w==null?void 0:w.startRow)!=null?x:n,(j=w==null?void 0:w.startColumn)!=null?j:r),unitId:i,subUnitId:s,row:n,col:r,workbook:d,worksheet:l};return(B=(U=u==null?void 0:u.canvasRender)==null?void 0:U.calcCellAutoWidth)==null?void 0:B.call(U,k)},e.coverable=((R=e==null?void 0:e.coverable)!=null?R:!0)&&!(h.type===o.DataValidationType.LIST||h.type===o.DataValidationType.LIST_MULTIPLE),a(e)}}))}_initAutoHeight(){this._sheetDataValidationModel.ruleChange$.pipe(oe.filter(e=>e.source==="command"),oe.bufferTime(100)).subscribe(e=>{if(e.length===0)return;const t=[];if(e.forEach(a=>{var n;(a.rule.type===o.DataValidationType.LIST_MULTIPLE||a.rule.type===o.DataValidationType.LIST)&&(n=a.rule)!=null&&n.ranges&&t.push(...a.rule.ranges)}),t.length){const a=this._autoHeightController.getUndoRedoParamsOfAutoHeight(t);o.sequenceExecute(a.redos,this._commandService)}})}};be=yt([G(0,o.ICommandService),G(1,E.IMenuManagerService),G(2,L.IRenderManagerService),G(3,o.IUniverInstanceService),G(4,o.Inject(N.AutoHeightController)),G(5,o.Inject(fe)),G(6,o.Inject(_.SheetDataValidationModel)),G(7,o.Inject(Y.DataValidatorRegistryService)),G(8,o.Inject(H.SheetInterceptorService)),G(9,o.Inject(_.DataValidationCacheService)),G(10,o.Optional(N.IEditorBridgeService))],be);let gt=class extends o.RxDisposable{constructor(e,t,a,n,r,i,s){super(),this._commandService=e,this._renderManagerService=t,this._autoHeightController=a,this._dataValidatorRegistryService=n,this._sheetInterceptorService=r,this._sheetDataValidationModel=i,this._dataValidationCacheService=s,this._initViewModelIntercept(),this._initAutoHeight()}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(H.INTERCEPTOR_POINT.CELL_CONTENT,{effect:o.InterceptorEffectEnum.Style,priority:H.InterceptCellContentPriority.DATA_VALIDATION,handler:(e,t,a)=>{var M,m,y,f,D;const{row:n,col:r,unitId:i,subUnitId:s,workbook:d,worksheet:l}=t,c=this._sheetDataValidationModel.getRuleIdByLocation(i,s,n,r);if(!c)return a(e);const h=this._sheetDataValidationModel.getRuleById(i,s,c);if(!h)return a(e);const g=(M=this._dataValidationCacheService.getValue(i,s,n,r))!=null?M:o.DataValidationStatus.VALID,u=this._dataValidatorRegistryService.getValidatorItem(h.type),I=l.getCellRaw(n,r),v=_.getCellValueOrigin(I),T=`${v!=null?v:""}`;return(!e||e===t.rawData)&&(e={...t.rawData}),e.markers={...e==null?void 0:e.markers,...g===o.DataValidationStatus.INVALID?Rt:null},e.customRender=[...(m=e==null?void 0:e.customRender)!=null?m:[],...u!=null&&u.canvasRender?[u.canvasRender]:[]],e.fontRenderExtension={...e==null?void 0:e.fontRenderExtension,isSkip:((y=e==null?void 0:e.fontRenderExtension)==null?void 0:y.isSkip)||((f=u==null?void 0:u.skipDefaultFontRender)==null?void 0:f.call(u,h,v,t))},e.interceptorStyle={...e==null?void 0:e.interceptorStyle,...u==null?void 0:u.getExtraStyle(h,T,{get style(){const R=d.getStyles();return(typeof(e==null?void 0:e.s)=="string"?R.get(e==null?void 0:e.s):e==null?void 0:e.s)||{}}},n,r)},e.interceptorAutoHeight=()=>{var k,W,O,x,j,U;const R=(W=(k=this._renderManagerService.getRenderById(i))==null?void 0:k.with(N.SheetSkeletonManagerService).getSkeletonParam(s))==null?void 0:W.skeleton;if(!R)return;const C=R.worksheet.getMergedCell(n,r),w={data:e,style:R.getStyles().getStyleByCell(e),primaryWithCoord:R.getCellWithCoordByIndex((O=C==null?void 0:C.startRow)!=null?O:n,(x=C==null?void 0:C.startColumn)!=null?x:r),unitId:i,subUnitId:s,row:n,col:r,workbook:d,worksheet:l};return(U=(j=u==null?void 0:u.canvasRender)==null?void 0:j.calcCellAutoHeight)==null?void 0:U.call(j,w)},e.interceptorAutoWidth=()=>{var k,W,O,x,j,U;const R=(W=(k=this._renderManagerService.getRenderById(i))==null?void 0:k.with(N.SheetSkeletonManagerService).getSkeletonParam(s))==null?void 0:W.skeleton;if(!R)return;const C=R.worksheet.getMergedCell(n,r),w={data:e,style:R.getStyles().getStyleByCell(e),primaryWithCoord:R.getCellWithCoordByIndex((O=C==null?void 0:C.startRow)!=null?O:n,(x=C==null?void 0:C.startColumn)!=null?x:r),unitId:i,subUnitId:s,row:n,col:r,workbook:d,worksheet:l};return(U=(j=u==null?void 0:u.canvasRender)==null?void 0:j.calcCellAutoWidth)==null?void 0:U.call(j,w)},e.coverable=((D=e==null?void 0:e.coverable)!=null?D:!0)&&!(h.type===o.DataValidationType.LIST||h.type===o.DataValidationType.LIST_MULTIPLE),a(e)}}))}_initAutoHeight(){this._sheetDataValidationModel.ruleChange$.pipe(oe.filter(e=>e.source==="command"),oe.bufferTime(16)).subscribe(e=>{const t=[];if(e.forEach(a=>{var n;(a.rule.type===o.DataValidationType.LIST_MULTIPLE||a.rule.type===o.DataValidationType.LIST)&&(n=a.rule)!=null&&n.ranges&&t.push(...a.rule.ranges)}),t.length){const a=this._autoHeightController.getUndoRedoParamsOfAutoHeight(t);o.sequenceExecute(a.redos,this._commandService)}})}};gt=yt([G(0,o.ICommandService),G(1,L.IRenderManagerService),G(2,o.Inject(N.AutoHeightController)),G(3,o.Inject(Y.DataValidatorRegistryService)),G(4,o.Inject(H.SheetInterceptorService)),G(5,o.Inject(_.SheetDataValidationModel)),G(6,o.Inject(_.DataValidationCacheService))],gt);var nn=Object.getOwnPropertyDescriptor,an=(e,t,a,n)=>{for(var r=n>1?void 0:n?nn(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},pt=(e,t)=>(a,n)=>t(a,n,e);let ke=class extends o.Disposable{constructor(e,t,a){super(),this._context=e,this._sheetDataValidationModel=t,this._sheetSkeletonManagerService=a,this._initSkeletonChange()}_initSkeletonChange(){const e=t=>{var n;if(!t.length)return;const a=new Set;t.forEach(r=>{a.add(r.subUnitId)}),a.forEach(r=>{var i;(i=this._sheetSkeletonManagerService.getSkeletonParam(r))==null||i.skeleton.makeDirty(!0)}),(n=this._context.mainComponent)==null||n.makeForceDirty()};this.disposeWithMe(this._sheetDataValidationModel.validStatusChange$.pipe(o.bufferDebounceTime(16)).subscribe(e))}};ke=an([pt(1,o.Inject(_.SheetDataValidationModel)),pt(2,o.Inject(N.SheetSkeletonManagerService))],ke);var ie=function(){return ie=Object.assign||function(e){for(var t,a=1,n=arguments.length;a<n;a++){t=arguments[a];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])}return e},ie.apply(this,arguments)},rn=function(e,t){var a={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(a[n]=e[n]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,n=Object.getOwnPropertySymbols(e);r<n.length;r++)t.indexOf(n[r])<0&&Object.prototype.propertyIsEnumerable.call(e,n[r])&&(a[n[r]]=e[n[r]]);return a},_e=b.forwardRef(function(e,t){var a=e.icon,n=e.id,r=e.className,i=e.extend,s=rn(e,["icon","id","className","extend"]),d="univerjs-icon univerjs-icon-".concat(n," ").concat(r||"").trim(),l=b.useRef("_".concat(ln()));return Dt(a,"".concat(n),{defIds:a.defIds,idSuffix:l.current},ie({ref:t,className:d},s),i)});function Dt(e,t,a,n,r){return b.createElement(e.tag,ie(ie({key:t},on(e,a,r)),n),(sn(e,a).children||[]).map(function(i,s){return Dt(i,"".concat(t,"-").concat(e.tag,"-").concat(s),a,void 0,r)}))}function on(e,t,a){var n=ie({},e.attrs);a!=null&&a.colorChannel1&&n.fill==="colorChannel1"&&(n.fill=a.colorChannel1),e.tag==="mask"&&n.id&&(n.id=n.id+t.idSuffix),Object.entries(n).forEach(function(i){var s=i[0],d=i[1];s==="mask"&&typeof d=="string"&&(n[s]=d.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))});var r=t.defIds;return!r||r.length===0||(e.tag==="use"&&n["xlink:href"]&&(n["xlink:href"]=n["xlink:href"]+t.idSuffix),Object.entries(n).forEach(function(i){var s=i[0],d=i[1];typeof d=="string"&&(n[s]=d.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))})),n}function sn(e,t){var a,n=t.defIds;return!n||n.length===0?e:e.tag==="defs"&&(!((a=e.children)===null||a===void 0)&&a.length)?ie(ie({},e),{children:e.children.map(function(r){return typeof r.attrs.id=="string"&&n&&n.includes(r.attrs.id)?ie(ie({},r),{attrs:ie(ie({},r.attrs),{id:r.attrs.id+t.idSuffix})}):r})}):e}function ln(){return Math.random().toString(36).substring(2,8)}_e.displayName="UniverIcon";var 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"}}]},wt=b.forwardRef(function(e,t){return b.createElement(_e,Object.assign({},e,{id:"data-validation-icon",ref:t,icon:dn}))});wt.displayName="DataValidationIcon";var cn={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"}}]},dt=b.forwardRef(function(e,t){return b.createElement(_e,Object.assign({},e,{id:"delete-icon",ref:t,icon:cn}))});dt.displayName="DeleteIcon";var 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:"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"}}]},Vt=b.forwardRef(function(e,t){return b.createElement(_e,Object.assign({},e,{id:"increase-icon",ref:t,icon:un}))});Vt.displayName="IncreaseIcon";var 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:"M11.3536 6.14645C11.5488 6.34171 11.5488 6.65829 11.3536 6.85355L8.35355 9.85355C8.15829 10.0488 7.84171 10.0488 7.64645 9.85355L4.64645 6.85355C4.45118 6.65829 4.45118 6.34171 4.64645 6.14645C4.84171 5.95118 5.15829 5.95118 5.35355 6.14645L8 8.79289L10.6464 6.14645C10.8417 5.95118 11.1583 5.95118 11.3536 6.14645Z",fillRule:"evenodd",clipRule:"evenodd"}}]},ct=b.forwardRef(function(e,t){return b.createElement(_e,Object.assign({},e,{id:"more-down-icon",ref:t,icon:hn}))});ct.displayName="MoreDownIcon";var 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:"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"}}]},Et=b.forwardRef(function(e,t){return b.createElement(_e,Object.assign({},e,{id:"more-up-icon",ref:t,icon:gn}))});Et.displayName="MoreUpIcon";var pn={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"mask",attrs:{id:"mask0_622_8",width:16,height:16,x:0,y:0,maskUnits:"userSpaceOnUse"},children:[{tag:"path",attrs:{fill:"#D9D9D9",d:"M0 0H16V16H0z"}}]},{tag:"g",attrs:{fill:"currentColor",mask:"url(#mask0_622_8)"},children:[{tag:"path",attrs:{d:"M6 5C6.55228 5 7 4.55228 7 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:{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:{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:{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:{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:{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"}}]}]},Mt=b.forwardRef(function(e,t){return b.createElement(_e,Object.assign({},e,{id:"sequence-icon",ref:t,icon:pn}))});Mt.displayName="SequenceIcon";function vn(e){var c;const t=E.useDependency(o.LocaleService),a=E.useDependency(E.ComponentManager),{value:n,onChange:r,extraComponent:i}=e,[s,d]=b.useState(!1),l=i?a.get(i):null;return p.jsxs(p.Fragment,{children:[p.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:()=>d(!s),children:[t.t("dataValidation.panel.options"),s?p.jsx(Et,{className:"univer-ml-1"}):p.jsx(ct,{className:"univer-ml-1"})]}),s&&p.jsxs(p.Fragment,{children:[l?p.jsx(l,{value:n,onChange:r}):null,p.jsx(V.FormLayout,{label:t.t("dataValidation.panel.invalid"),children:p.jsxs(V.RadioGroup,{value:`${(c=n.errorStyle)!=null?c:o.DataValidationErrorStyle.WARNING}`,onChange:h=>r({...n,errorStyle:+h}),children:[p.jsx(V.Radio,{value:`${o.DataValidationErrorStyle.WARNING}`,children:t.t("dataValidation.panel.showWarning")}),p.jsx(V.Radio,{value:`${o.DataValidationErrorStyle.STOP}`,children:t.t("dataValidation.panel.rejectInput")})]})}),p.jsx(V.FormLayout,{label:t.t("dataValidation.panel.messageInfo"),children:p.jsx(V.Checkbox,{checked:n.showErrorMessage,onChange:()=>r({...n,showErrorMessage:!n.showErrorMessage}),children:t.t("dataValidation.panel.showInfo")})}),n.showErrorMessage?p.jsx(V.FormLayout,{children:p.jsx(V.Input,{value:n.error,onChange:h=>r({...n,error:h})})}):null]})]})}const mn=e=>o.debounce(async(t,a,n,r)=>{const i=await e.executeCommand(t,a,n);r==null||r(i)},1e3);function fn(e,t,a){var n,r,i,s;return t?((r=(n=e.getUnit(t))==null?void 0:n.getSheetBySheetName(a))==null?void 0:r.getSheetId())||"":((s=(i=e.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET))==null?void 0:i.getSheetBySheetName(a))==null?void 0:s.getSheetId())||""}function Sn(){var P,$;const[e,t]=b.useState(0),a=E.useDependency(he),n=E.useObservable(a.activeRule$,a.activeRule),{unitId:r,subUnitId:i,rule:s}=n||{},d=s.uid,l=E.useDependency(Y.DataValidatorRegistryService),c=E.useDependency(o.IUniverInstanceService),h=E.useDependency(E.ComponentManager),g=E.useDependency(o.ICommandService),u=E.useDependency(Y.DataValidationModel),I=E.useDependency(o.LocaleService),[v,T]=b.useState(s),M=l.getValidatorItem(v.type),[m,y]=b.useState(!1),f=l.getValidatorsByScope(Y.DataValidatorRegistryScope.SHEET),[D,R]=b.useState(()=>v.ranges.map(S=>({unitId:"",sheetId:"",range:S}))),C=b.useMemo(()=>mn(g),[g]),[w,k]=b.useState(!1),[W,O]=b.useState(!1),x=b.useRef(null),j=E.useDependency(H.SheetsSelectionsService);if(b.useEffect(()=>()=>{const S=j.getCurrentLastSelection();S&&j.setSelections([S])},[j]),b.useEffect(()=>{g.onCommandExecuted(S=>{(S.id===o.UndoCommand.id||S.id===o.RedoCommand.id)&&setTimeout(()=>{const F=u.getRuleById(r,i,d);t(X=>X+1),F&&(T(F),R(F.ranges.map(X=>({unitId:"",sheetId:"",range:X}))))},20)})},[g,u,d,i,r]),!M)return null;const U=M.operators,B=M.operatorNames,K=v.operator?Y.TWO_FORMULA_OPERATOR_COUNT.includes(v.operator):!1,z=()=>{var S,F,X;(F=(S=x.current)==null?void 0:S.editor)!=null&&F.isFocus()&&ee((X=x.current)==null?void 0:X.getValue()),!(!v.ranges.length||w)&&(M.validatorFormula(v,r,i).success?a.setActiveRule(null):y(!0))},ee=E.useEvent(S=>{const F=S.split(",").filter(Boolean).map(tt.deserializeRangeWithSheet).map(ne=>{const ut=ne.sheetName;if(ut){const Pt=fn(c,ne.unitId,ut);return{...ne,sheetId:Pt}}return{...ne,sheetId:""}});if(o.isUnitRangesEqual(F,D))return;R(F);const X=F.filter(ne=>(!ne.unitId||ne.unitId===r)&&(!ne.sheetId||ne.sheetId===i)).map(ne=>ne.range);if(T({...v,ranges:X}),X.length===0)return;const ge={unitId:r,subUnitId:i,ruleId:d,ranges:X};C(_.UpdateSheetDataValidationRangeCommand.id,ge)}),ae=S=>{if(o.shallowEqual(S,Y.getRuleSetting(v)))return;T({...v,...S});const F={unitId:r,subUnitId:i,ruleId:d,setting:S};C(_.UpdateSheetDataValidationSettingCommand.id,F,void 0)},re=async()=>{await g.executeCommand(_.RemoveSheetDataValidationCommand.id,{ruleId:d,unitId:r,subUnitId:i}),a.setActiveRule(null)},se={type:v.type,operator:v.operator,formula1:v.formula1,formula2:v.formula2,allowBlank:v.allowBlank},q=S=>{const F=l.getValidatorItem(S);if(!F)return;const X=F.operators,ge=u.getRuleById(r,i,d),ne=S===(ge==null?void 0:ge.type)||S.includes("list")&&(ge!=null&&ge.type.includes("list"))?{...ge,type:S}:{...v,type:S,operator:X[0],formula1:void 0,formula2:void 0};T(ne),g.executeCommand(_.UpdateSheetDataValidationSettingCommand.id,{unitId:r,subUnitId:i,ruleId:v.uid,setting:Y.getRuleSetting(ne)})},Z=h.get(M.formulaInput),ce=b.useMemo(()=>D.map(S=>tt.serializeRange(S.range)).join(","),[]),te=Y.getRuleOptions(v),Q=S=>{o.shallowEqual(S,Y.getRuleOptions(v))||(T({...v,...S}),C(_.UpdateSheetDataValidationOptionsCommand.id,{unitId:r,subUnitId:i,ruleId:d,options:S}))},J=U.length&&!v.operator;return p.jsxs("div",{"data-u-comp":"data-validation-detail",className:"univer-py-2",children:[p.jsx(V.FormLayout,{label:I.t("dataValidation.panel.range"),error:!v.ranges.length||w?I.t("dataValidation.panel.rangeError"):"",children:p.jsx(ot.RangeSelector,{selectorRef:x,unitId:r,subUnitId:i,initialValue:ce,onChange:(S,F)=>{var X;!W&&((X=x.current)!=null&&X.verify())&&ee(F)},onFocusChange:(S,F)=>{var X;O(S),!S&&F&&((X=x.current)!=null&&X.verify())&&ee(F)},onVerify:S=>k(!S)})}),p.jsx(V.FormLayout,{label:I.t("dataValidation.panel.type"),children:p.jsx(V.Select,{className:"univer-w-full",value:v.type,options:(P=f==null?void 0:f.sort((S,F)=>S.order-F.order))==null?void 0:P.map(S=>({label:I.t(S.title),value:S.id})),onChange:q})}),U!=null&&U.length?p.jsx(V.FormLayout,{label:I.t("dataValidation.panel.operator"),children:p.jsx(V.Select,{className:"univer-w-full",value:`${v.operator}`,options:[{value:"",label:I.t("dataValidation.operators.legal")},...U.map((S,F)=>({value:`${S}`,label:B[F]}))],onChange:S=>{ae({...se,operator:S})}})}):null,Z&&!J?p.jsx(Z,{isTwoFormula:K,value:{formula1:v.formula1,formula2:v.formula2},onChange:S=>{ae({...se,...S})},showError:m,validResult:M.validatorFormula(v,r,i),unitId:r,subUnitId:i,ruleId:d},e+v.type):null,p.jsx(V.FormLayout,{children:p.jsx(V.Checkbox,{checked:($=v.allowBlank)!=null?$:!0,onChange:()=>{var S;return ae({...se,allowBlank:!((S=v.allowBlank)==null||S)})},children:I.t("dataValidation.panel.allowBlank")})}),p.jsx(vn,{value:te,onChange:Q,extraComponent:M.optionsInput}),p.jsxs("div",{className:"univer-mt-5 univer-flex univer-flex-row univer-justify-end",children:[p.jsx(V.Button,{className:"univer-ml-3",onClick:re,children:I.t("dataValidation.panel.removeRule")}),p.jsx(V.Button,{className:"univer-ml-3",variant:"primary",onClick:z,children:I.t("dataValidation.panel.done")})]})]})}const _n=e=>{const{rule:t,onClick:a,unitId:n,subUnitId:r,disable:i}=e,s=E.useDependency(Y.DataValidatorRegistryService),d=E.useDependency(o.ICommandService),l=E.useDependency(N.IMarkSelectionService),c=s.getValidatorItem(t.type),h=b.useRef(void 0),[g,u]=b.useState(!1),I=E.useDependency(o.ThemeService),v=E.useObservable(I.currentTheme$),T=b.useMemo(()=>{var R;const m=I.getColorFromTheme("primary.600"),y=I.getColorFromTheme("loop-color.2"),f=(R=I.getColorFromTheme(y))!=null?R:m,D=new o.ColorKit(f).toRgb();return{fill:`rgba(${D.r}, ${D.g}, ${D.b}, 0.1)`,stroke:f}},[v]),M=m=>{d.executeCommand(_.RemoveSheetDataValidationCommand.id,{ruleId:t.uid,unitId:n,subUnitId:r}),m.stopPropagation()};return b.useEffect(()=>()=>{var m;h.current&&((m=h.current)==null||m.forEach(y=>{y&&l.removeShape(y)}))},[l]),p.jsxs("div",{className:V.clsx(`
2
2
  univer-bg-secondary univer-relative univer--ml-2 univer--mr-2 univer-box-border univer-flex
3
3
  univer-w-[287px] univer-cursor-pointer univer-flex-col univer-justify-between univer-overflow-hidden
4
4
  univer-rounded-md univer-p-2 univer-pr-9
5
- `,{"hover:univer-bg-gray-50 dark:hover:!univer-bg-gray-700":!i,"univer-opacity-50":i}),onClick:a,onMouseEnter:()=>{i||(u(!0),h.current=t.ranges.map(m=>l.addShape({range:m,style:T,primary:null})))},onMouseLeave:()=>{var m;u(!1),(m=h.current)==null||m.forEach(y=>{y&&l.removeShape(y)}),h.current=void 0},children:[p.jsx("div",{className:"univer-truncate univer-text-sm univer-font-medium univer-leading-[22px] univer-text-gray-900 dark:!univer-text-white",children:c==null?void 0:c.generateRuleName(t)}),p.jsx("div",{className:"univer-text-secondary univer-truncate univer-text-xs univer-leading-[18px] dark:!univer-text-gray-300",children:t.ranges.map(m=>tt.serializeRange(m)).join(",")}),g?p.jsx("div",{className:"univer-absolute univer-right-2 univer-top-[19px] univer-flex univer-h-5 univer-w-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:M,children:p.jsx(dt,{})}):null]})};function In(e){const t=E.useDependency(_.SheetDataValidationModel),a=E.useDependency(o.IUniverInstanceService),n=E.useDependency(o.ICommandService),r=E.useDependency(o.Injector),i=E.useDependency(he),s=E.useDependency(o.LocaleService),[d,l]=b.useState([]),{workbook:c}=e,h=E.useObservable(c.activeSheet$,void 0,!0),g=c.getUnitId(),u=h==null?void 0:h.getSheetId();b.useEffect(()=>{l(t.getRules(g,u));const y=t.ruleChange$.subscribe(f=>{f.unitId===g&&f.subUnitId===u&&l(t.getRules(g,u))});return()=>{y.unsubscribe()}},[g,u,t]);const I=async()=>{const y=_.createDefaultNewRule(r),f={unitId:g,subUnitId:u,rule:y};await n.executeCommand(_.AddSheetDataValidationCommand.id,f),i.setActiveRule({unitId:g,subUnitId:u,rule:y})},v=()=>{n.executeCommand(_.RemoveSheetAllDataValidationCommand.id,{unitId:g,subUnitId:u})},M=(y=>{const f=a.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET),D=f.getActiveSheet(),R=f.getUnitId(),C=D.getSheetId();return y.map(k=>H.checkRangesEditablePermission(r,R,C,k.ranges)?{...k}:{...k,disable:!0})})(d),m=M==null?void 0:M.some(y=>y.disable);return p.jsxs("div",{className:"univer-pb-4",children:[M==null?void 0:M.map(y=>{var f;return p.jsx(_n,{unitId:g,subUnitId:u,onClick:()=>{y.disable||i.setActiveRule({unitId:g,subUnitId:u,rule:y})},rule:y,disable:(f=y.disable)!=null?f:!1},y.uid)}),p.jsxs("div",{className:"univer-mt-4 univer-flex univer-flex-row univer-justify-end univer-gap-2",children:[d.length&&!m?p.jsx(V.Button,{onClick:v,children:s.t("dataValidation.panel.removeAll")}):null,p.jsx(V.Button,{variant:"primary",onClick:I,children:s.t("dataValidation.panel.add")})]})]})}const Cn=()=>{const e=E.useDependency(he),t=E.useObservable(e.activeRule$,e.activeRule),a=E.useDependency(o.IUniverInstanceService),n=E.useObservable(()=>a.getCurrentTypeOfUnit$(o.UniverInstanceType.UNIVER_SHEET),void 0,void 0,[]),r=E.useObservable(()=>{var i;return(i=n==null?void 0:n.activeSheet$)!=null?i:oe.of(null)},void 0,void 0,[]);return!n||!r?null:t&&t.subUnitId===r.getSheetId()?p.jsx(Sn,{},t.rule.uid):p.jsx(In,{workbook:n})},yn=e=>{const{isTwoFormula:t=!1,value:a,onChange:n,showError:r,validResult:i}=e,s=E.useDependency(o.LocaleService),d=r?i==null?void 0:i.formula1:"",l=r?i==null?void 0:i.formula2:"";return t?p.jsxs(p.Fragment,{children:[p.jsx(V.FormLayout,{error:d,children:p.jsx(V.Input,{className:"univer-w-full",placeholder:s.t("dataValidation.panel.formulaPlaceholder"),value:a==null?void 0:a.formula1,onChange:c=>{n==null||n({...a,formula1:c})}})}),p.jsx("div",{className:"-univer-mt-2 univer-mb-1 univer-text-sm univer-text-gray-400",children:s.t("dataValidation.panel.formulaAnd")}),p.jsx(V.FormLayout,{error:l,children:p.jsx(V.Input,{className:"univer-w-full",placeholder:s.t("dataValidation.panel.formulaPlaceholder"),value:a==null?void 0:a.formula2,onChange:c=>{n==null||n({...a,formula2:c})}})})]}):p.jsx(V.FormLayout,{error:d,children:p.jsx(V.Input,{className:"univer-w-full",placeholder:s.t("dataValidation.panel.formulaPlaceholder"),value:a==null?void 0:a.formula1,onChange:c=>{n==null||n({formula1:c})}})})};function Rn(e){const{value:t,onChange:a,showError:n,validResult:r}=e,i=E.useDependency(o.LocaleService),s=n?r==null?void 0:r.formula1:"",d=n?r==null?void 0:r.formula2:"",[l,c]=b.useState(!((t==null?void 0:t.formula1)===void 0&&(t==null?void 0:t.formula2)===void 0));return p.jsxs(p.Fragment,{children:[p.jsx(V.FormLayout,{children:p.jsx(V.Checkbox,{checked:l,onChange:h=>{h?c(!0):(c(!1),a==null||a({...t,formula1:void 0,formula2:void 0}))},children:i.t("dataValidation.checkbox.tips")})}),l?p.jsx(V.FormLayout,{label:i.t("dataValidation.checkbox.checked"),error:s,children:p.jsx(V.Input,{className:"univer-w-full",placeholder:i.t("dataValidation.panel.valuePlaceholder"),value:t==null?void 0:t.formula1,onChange:h=>{a==null||a({...t,formula1:h||void 0})}})}):null,l?p.jsx(V.FormLayout,{label:i.t("dataValidation.checkbox.unchecked"),error:d,children:p.jsx(V.Input,{className:"univer-w-full",placeholder:i.t("dataValidation.panel.valuePlaceholder"),value:t==null?void 0:t.formula2,onChange:h=>{a==null||a({...t,formula2:h||void 0})}})}):null]})}function Dn(e){var g;const{unitId:t,subUnitId:a,value:n,onChange:r,showError:i,validResult:s}=e,d=i?s==null?void 0:s.formula1:void 0,l=b.useRef(null),[c,h]=b.useState(!1);return E.useSidebarClick(u=>{var v;((v=l.current)==null?void 0:v.isClickOutSide(u))&&h(!1)}),p.jsx(V.FormLayout,{error:d,children:p.jsx(ot.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:(g=n==null?void 0:n.formula1)!=null?g:"=",unitId:t,subUnitId:a,isFocus:c,isSupportAcrossSheet:!0,onChange:u=>{const I=(u!=null?u:"").trim();I!==(n==null?void 0:n.formula1)&&(r==null||r({...n,formula1:I}))},onFocus:()=>h(!0)})})}const Re="#ECECEC",wn=["#FFFFFF","#FEE7E7","#FEF0E6","#EFFBD0","#E4F4FE","#E8ECFD","#F1EAFA","#FDE8F3","#E5E5E5","#FDCECE","#FDC49B","#DEF6A2","#9FDAFF","#D0D9FB","#E3D5F6","#FBD0E8","#656565","#FE4B4B","#FF8C51","#8BBB11","#0B9EFB","#3A60F7","#9E6DE3","#F248A6"],Vn=e=>{const{value:t,onChange:a,disabled:n}=e,[r,i]=b.useState(!1);return p.jsx(V.Dropdown,{align:"start",disabled:n,open:r,onOpenChange:i,overlay:p.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:wn.map(s=>p.jsx("div",{className:V.clsx("univer-box-border univer-size-4 univer-cursor-pointer univer-rounded",V.borderClassName),style:{background:s},onClick:()=>{a(s),i(!1)}},s))}),children:p.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:[p.jsx("div",{className:"univer-box-border univer-h-4 univer-w-4 univer-rounded univer-text-base",style:{background:t}}),p.jsx(ct,{})]})})},vt=e=>{const{item:t,commonProps:a,className:n}=e,{onItemChange:r,onItemDelete:i}=a;return p.jsxs("div",{className:V.clsx("univer-flex univer-items-center univer-gap-2",n),children:[!t.isRef&&p.jsx("div",{className:V.clsx("univer-cursor-move","draggableHandle"),children:p.jsx(Mt,{})}),p.jsx(Vn,{value:t.color,onChange:s=>{r(t.id,t.label,s)}}),p.jsx(V.Input,{disabled:t.isRef,value:t.label,onChange:s=>{r(t.id,s,t.color)}}),t.isRef?null:p.jsx("div",{className:"univer-ml-1 univer-cursor-pointer univer-rounded univer-text-base hover:univer-bg-gray-200",children:p.jsx(dt,{onClick:()=>i(t.id)})})]})};function En(e){const{value:t,onChange:a=()=>{},unitId:n,subUnitId:r,validResult:i,showError:s,ruleId:d}=e,{formula1:l="",formula2:c=""}=t||{},[h,g]=b.useState(()=>o.isFormulaString(l)?"1":"0"),[u,I]=b.useState(h==="1"?l:"="),[v,T]=b.useState(h==="1"?l:"="),M=E.useDependency(o.LocaleService),m=E.useDependency(Y.DataValidatorRegistryService),y=E.useDependency(Y.DataValidationModel),f=E.useDependency(_.DataValidationFormulaController),[D,R]=b.useState(()=>c.split(",")),C=m.getValidatorItem(o.DataValidationType.LIST),[w,k]=b.useState([]),[W,O]=b.useState(""),x=s?i==null?void 0:i.formula1:"",j=b.useMemo(()=>y.ruleChange$.pipe(oe.debounceTime(16)),[]),U=E.useObservable(j),B=E.useEvent(a);b.useEffect(()=>{(async()=>{await new Promise(S=>{setTimeout(()=>S(!0),100)});const P=y.getRuleById(n,r,d),$=P==null?void 0:P.formula1;if(o.isFormulaString($)&&C&&P){const S=await C.getListAsync(P,n,r);k(S)}})()},[y,U,C,d,r,n]),b.useEffect(()=>{o.isFormulaString(l)&&l!==v&&(I(l),T(v))},[v,l]);const[K,z]=b.useState(()=>{const P=h!=="1"?_.deserializeListOptions(l):[],$=c.split(",");return P.map((S,F)=>({label:S,color:$[F]||Re,isRef:!1,id:o.Tools.generateRandomId(4)}))}),ee=(P,$,S)=>{const F=K.find(X=>X.id===P);F&&(F.label=$,F.color=S,z([...K]))},ae=P=>{const $=K.findIndex(S=>S.id===P);$!==-1&&(K.splice($,1),z([...K]))},re=c.split(","),se=b.useMemo(()=>w.map((P,$)=>({label:P,color:re[$]||Re,id:`${$}`,isRef:!0})),[re,w]),q=(P,$,S)=>{const F=[...D];F[+P]=S,R(F),B({formula1:l,formula2:F.join(",")})},Z=()=>{z([...K,{label:"",color:Re,isRef:!1,id:o.Tools.generateRandomId(4)}])};b.useEffect(()=>{if(h==="1")return;const P=new Set,$=[];K.map(S=>({labelList:S.label.split(","),item:S})).forEach(({item:S,labelList:F})=>{F.forEach(X=>{P.has(X)||(P.add(X),$.push({label:X,color:S.color}))})}),B({formula1:_.serializeListOptions($.map(S=>S.label)),formula2:$.map(S=>S.color===Re?"":S.color).join(",")})},[K,B,h,v,D]);const ce=E.useEvent(async P=>{if(!o.isFormulaString(P)){B==null||B({formula1:"",formula2:c});return}f.getFormulaRefCheck(P)?(B==null||B({formula1:o.isFormulaString(P)?P:"",formula2:c}),O("")):(B==null||B({formula1:"",formula2:c}),I("="),O(M.t("dataValidation.validFail.formulaError")))}),te=b.useRef(null),[Q,J]=b.useState(!1);return E.useSidebarClick(P=>{var S;((S=te.current)==null?void 0:S.isClickOutSide(P))&&J(!1)}),p.jsxs(p.Fragment,{children:[p.jsx(V.FormLayout,{label:M.t("dataValidation.list.options"),children:p.jsxs(V.RadioGroup,{value:h,onChange:P=>{g(P),I(v),P==="1"&&B({formula1:v==="="?"":v,formula2:D.join(",")})},children:[p.jsx(V.Radio,{value:"0",children:M.t("dataValidation.list.customOptions")}),p.jsx(V.Radio,{value:"1",children:M.t("dataValidation.list.refOptions")})]})}),h==="1"?p.jsxs(V.FormLayout,{error:x||W||void 0,children:[p.jsx(ot.FormulaEditor,{ref:te,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:n,subUnitId:r,isFocus:Q,isSupportAcrossSheet:!0,onFocus:()=>J(!0),onChange:(P="")=>{const $=(P!=null?P:"").trim();T($),ce($)}}),se.length>0&&p.jsx("div",{className:"univer-mt-3",children:se.map(P=>p.jsx(vt,{className:"univer-mb-3",item:P,commonProps:{onItemChange:q}},P.id))})]}):p.jsx(V.FormLayout,{error:x,children:p.jsxs("div",{className:"-univer-mt-3",children:[p.jsx(V.DraggableList,{list:K,onListChange:z,rowHeight:28,margin:[0,12],draggableHandle:".draggableHandle",itemRender:P=>p.jsx(vt,{item:P,commonProps:{onItemChange:ee,onItemDelete:ae}},P.id),idKey:"id"}),p.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:Z,children:[p.jsx(Vt,{className:"univer-mr-1"}),M.t("dataValidation.list.add")]})]})})]})}const Mn=[[_.CUSTOM_FORMULA_INPUT_NAME,Dn],[_.BASE_FORMULA_INPUT_NAME,yn],[_.LIST_FORMULA_INPUT_NAME,En],[_.CHECKBOX_FORMULA_INPUT_NAME,Rn]],bn="LIST_RENDER_MODE_OPTION_INPUT";function Ne(e){var r;const{value:t,onChange:a}=e,n=E.useDependency(o.LocaleService);return p.jsx(V.FormLayout,{label:n.t("dataValidation.renderMode.label"),children:p.jsxs(V.RadioGroup,{value:`${(r=t.renderMode)!=null?r:o.DataValidationRenderMode.CUSTOM}`,onChange:i=>a({...t,renderMode:+i}),children:[p.jsx(V.Radio,{value:`${o.DataValidationRenderMode.CUSTOM}`,children:n.t("dataValidation.renderMode.chip")}),p.jsx(V.Radio,{value:`${o.DataValidationRenderMode.ARROW}`,children:n.t("dataValidation.renderMode.arrow")}),p.jsx(V.Radio,{value:`${o.DataValidationRenderMode.TEXT}`,children:n.t("dataValidation.renderMode.text")})]})})}Ne.componentKey=bn;const Tn="DATE_SHOW_TIME_OPTION";function Be(e){var r;const{value:t,onChange:a}=e,n=E.useDependency(o.LocaleService);return p.jsx(V.FormLayout,{children:p.jsx(V.Checkbox,{checked:(r=t.bizInfo)==null?void 0:r.showTime,onChange:i=>{a({...t,bizInfo:{...t.bizInfo,showTime:i}})},children:n.t("dataValidation.showTime.label")})})}Be.componentKey=Tn;var On=Object.getOwnPropertyDescriptor,Pn=(e,t,a,n)=>{for(var r=n>1?void 0:n?On(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},ye=(e,t)=>(a,n)=>t(a,n,e);const Ae=6;let nt=class{constructor(e,t,a,n,r,i){this._commandService=e,this._univerInstanceService=t,this._formulaService=a,this._themeService=n,this._renderManagerService=r,this._dataValidationModel=i}_calc(e,t){var c,h,g;const{vt:a,ht:n}=t||{},r=e.endX-e.startX-Ae*2,i=e.endY-e.startY,s=((c=t==null?void 0:t.fs)!=null?c:10)*1.6;let d=0,l=0;switch(a){case o.VerticalAlign.TOP:l=0;break;case o.VerticalAlign.BOTTOM:l=0+(i-s);break;default:l=0+(i-s)/2;break}switch(n){case o.HorizontalAlign.LEFT:d=Ae;break;case o.HorizontalAlign.RIGHT:d=Ae+(r-s);break;default:d=Ae+(r-s)/2;break}return{left:e.startX+d,top:e.startY+l,width:((h=t==null?void 0:t.fs)!=null?h:10)*1.6,height:((g=t==null?void 0:t.fs)!=null?g:10)*1.6}}calcCellAutoHeight(e){var a;const{style:t}=e;return((a=t==null?void 0:t.fs)!=null?a:10)*1.6}calcCellAutoWidth(e){var a;const{style:t}=e;return((a=t==null?void 0:t.fs)!=null?a:10)*1.6}async _parseFormula(e,t,a){var c,h,g,u,I,v,T,M,m;const{formula1:n=_.CHECKBOX_FORMULA_1,formula2:r=_.CHECKBOX_FORMULA_2}=e,i=await this._formulaService.getRuleFormulaResult(t,a,e.uid),s=_.getFormulaResult((g=(h=(c=i==null?void 0:i[0])==null?void 0:c.result)==null?void 0:h[0])==null?void 0:g[0]),d=_.getFormulaResult((v=(I=(u=i==null?void 0:i[1])==null?void 0:u.result)==null?void 0:I[0])==null?void 0:v[0]),l=_.isLegalFormulaResult(String(s))&&_.isLegalFormulaResult(String(d));return{formula1:o.isFormulaString(n)?_.getFormulaResult((m=(M=(T=i==null?void 0:i[0])==null?void 0:T.result)==null?void 0:M[0])==null?void 0:m[0]):n,formula2:o.isFormulaString(r)?d:r,isFormulaValid:l}}drawWith(e,t){var x,j,U,B;const{style:a,primaryWithCoord:n,unitId:r,subUnitId:i,worksheet:s,row:d,col:l}=t,c=n.isMergedMainCell?n.mergeInfo:n,h=_.getCellValueOrigin(s.getCellRaw(d,l)),g=this._dataValidationModel.getRuleByLocation(r,i,d,l);if(!g)return;const u=this._dataValidationModel.getValidator(g.type);if(!u||!((x=u.skipDefaultFontRender)!=null&&x.call(u,g,h,{unitId:r,subUnitId:i,row:d,column:l})))return;const I=u.parseFormulaSync(g,r,i),{formula1:v}=I,T=this._calc(c,a),{a:M,d:m}=e.getTransform(),y=L.fixLineWidthByScale(T.left,M),f=L.fixLineWidthByScale(T.top,m),D=L.Transform.create().composeMatrix({left:y,top:f,scaleX:1,scaleY:1,angle:0,skewX:0,skewY:0,flipX:!1,flipY:!1}),R=c.endX-c.startX,C=c.endY-c.startY;e.save(),e.beginPath(),e.rect(c.startX,c.startY,R,C),e.clip();const w=D.getMatrix();e.transform(w[0],w[1],w[2],w[3],w[4],w[5]);const k=((j=a==null?void 0:a.fs)!=null?j:10)*1.6,W=String(h)===String(v),O=this._themeService.getColorFromTheme("primary.600");L.CheckboxShape.drawWith(e,{checked:W,width:k,height:k,fill:(B=(U=a==null?void 0:a.cl)==null?void 0:U.rgb)!=null?B:O}),e.restore()}isHit(e,t){const a=t.primaryWithCoord.isMergedMainCell?t.primaryWithCoord.mergeInfo:t.primaryWithCoord,n=this._calc(a,t.style),r=n.top,i=n.top+n.height,s=n.left,d=n.left+n.width,{x:l,y:c}=e;return l<=d&&l>=s&&c<=i&&c>=r}async onPointerDown(e,t){var v;if(t.button===2)return;const{primaryWithCoord:a,unitId:n,subUnitId:r,worksheet:i,row:s,col:d}=e,l=_.getCellValueOrigin(i.getCellRaw(s,d)),c=this._dataValidationModel.getRuleByLocation(n,r,s,d);if(!c)return;const h=this._dataValidationModel.getValidator(c.type);if(!h||!((v=h.skipDefaultFontRender)!=null&&v.call(h,c,l,{unitId:n,subUnitId:r,row:s,column:d})))return;const{formula1:g,formula2:u}=await this._parseFormula(c,n,r),I={range:{startColumn:a.actualColumn,endColumn:a.actualColumn,startRow:a.actualRow,endRow:a.actualRow},value:{v:String(l)===_.transformCheckboxValue(String(g))?u:g,p:null}};this._commandService.executeCommand(H.SetRangeValuesCommand.id,I)}onPointerEnter(e,t){var a,n;(n=(a=L.getCurrentTypeOfRenderer(o.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null?void 0:a.mainComponent)==null||n.setCursor(L.CURSOR_TYPE.POINTER)}onPointerLeave(e,t){var a,n;(n=(a=L.getCurrentTypeOfRenderer(o.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null?void 0:a.mainComponent)==null||n.setCursor(L.CURSOR_TYPE.DEFAULT)}};nt=Pn([ye(0,o.ICommandService),ye(1,o.IUniverInstanceService),ye(2,o.Inject(_.DataValidationFormulaService)),ye(3,o.Inject(o.ThemeService)),ye(4,o.Inject(L.IRenderManagerService)),ye(5,o.Inject(_.SheetDataValidationModel))],nt);var An=Object.getOwnPropertyDescriptor,Ln=(e,t,a,n)=>{for(var r=n>1?void 0:n?An(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},jn=(e,t)=>(a,n)=>t(a,n,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=Ln([jn(0,o.Inject(o.Injector))],exports.BaseSheetDataValidatorView);class xn extends exports.BaseSheetDataValidatorView{constructor(){super(...arguments);A(this,"id",o.DataValidationType.CHECKBOX);A(this,"canvasRender",this.injector.createInstance(nt));A(this,"formulaInput",_.CHECKBOX_FORMULA_INPUT_NAME)}}class Un extends exports.BaseSheetDataValidatorView{constructor(){super(...arguments);A(this,"id",o.DataValidationType.CUSTOM);A(this,"formulaInput",_.CUSTOM_FORMULA_INPUT_NAME)}}const Fn="data-validation.formula-input";class kn extends exports.BaseSheetDataValidatorView{constructor(){super(...arguments);A(this,"id",o.DataValidationType.DATE);A(this,"formulaInput",Fn);A(this,"optionsInput",Be.componentKey);A(this,"dropdownType",Y.DataValidatorDropdownType.DATE)}}class Nn extends exports.BaseSheetDataValidatorView{constructor(){super(...arguments);A(this,"id",o.DataValidationType.DECIMAL);A(this,"formulaInput",_.BASE_FORMULA_INPUT_NAME)}}const bt=4,Bn=0,Ze=4,Tt=4,at=6,We=6,me=14;function Wn(e,t){const a=L.FontCache.getTextSize(e,t),n=a.width+bt*2,{ba:r,bd:i}=a,s=r+i;return{width:n,height:s+Bn*2,ba:r}}function Ge(e,t,a,n){const r=me+at*2,i=a-r,s=n-We*2,d=e.map(u=>({layout:Wn(u,t),text:u}));let l;const c=[];d.forEach(u=>{const{layout:I}=u,{width:v,height:T}=I;!l||l.width+v+Ze>i?(l={width:v,height:T,items:[{...u,left:0}]},c.push(l)):(l.items.push({...u,left:l.width+Ze}),l.width=l.width+v+Ze)});let h=0,g=0;return c.forEach((u,I)=>{g=Math.max(g,u.width),I===c.length-1?h+=u.height:h+=u.height+Tt}),{lines:c,totalHeight:h,contentWidth:i,contentHeight:s,cellAutoHeight:h+We*2,calcAutoWidth:g+r}}const Hn=8;class $n extends L.Shape{static drawWith(t,a){const{fontString:n,info:r,fill:i,color:s}=a,{layout:d,text:l}=r;t.save(),L.Rect.drawWith(t,{width:d.width,height:d.height,radius:Hn,fill:i||Re}),t.translateWithPrecision(bt,d.ba),t.font=n,t.fillStyle=s,t.fillText(l,0,0),t.restore()}}var Yn=Object.getOwnPropertyDescriptor,Xn=(e,t,a,n)=>{for(var r=n>1?void 0:n?Yn(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},Le=(e,t)=>(a,n)=>t(a,n,e);const zn=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 rt=class{constructor(e,t,a,n){A(this,"zIndex");A(this,"_dropdownInfoMap",new Map);this._commandService=e,this._univerInstanceService=t,this._renderManagerService=a,this._dataValidationModel=n}_ensureMap(e){let t=this._dropdownInfoMap.get(e);return t||(t=new Map,this._dropdownInfoMap.set(e,t)),t}_generateKey(e,t){return`${e}.${t}`}_drawDownIcon(e,t,a,n,r){const i=a-me+4;let s=4;switch(r){case o.VerticalAlign.MIDDLE:s=(n-me)/2+4;break;case o.VerticalAlign.BOTTOM:s=n-me+4;break}e.save(),e.translateWithPrecision(t.startX+i,t.startY+s),e.fillStyle="#565656",e.fill(zn),e.restore()}drawWith(e,t,a,n){var ae,re;const{primaryWithCoord:r,row:i,col:s,style:d,data:l,subUnitId:c}=t,h=r.isMergedMainCell?r.mergeInfo:r,g=l==null?void 0:l.fontRenderExtension,{leftOffset:u=0,rightOffset:I=0,topOffset:v=0,downOffset:T=0}=g||{},M=this._ensureMap(c),m=this._generateKey(i,s),y=this._dataValidationModel.getRuleByLocation(t.unitId,t.subUnitId,i,s);if(!y)return;const f=this._dataValidationModel.getValidator(y.type);if(!f)return;const D={startX:h.startX+u,endX:h.endX-I,startY:h.startY+v,endY:h.endY-T},R=D.endX-D.startX,C=D.endY-D.startY,{cl:w}=d||{},k=(ae=typeof w=="object"?w==null?void 0:w.rgb:w)!=null?ae:"#000",W=L.getFontStyleString(d!=null?d:void 0),{vt:O,ht:x}=d||{},j=O!=null?O:o.VerticalAlign.MIDDLE,U=(re=_.getCellValueOrigin(l))!=null?re:"",B=f.parseCellValue(U),K=f.getListWithColorMap(y),z=Ge(B,W,R,C);this._drawDownIcon(e,D,R,C,j),e.save(),e.translateWithPrecision(D.startX,D.startY),e.beginPath(),e.rect(0,0,R-me,C),e.clip(),e.translateWithPrecision(at,We);let ee=0;switch(j){case o.VerticalAlign.MIDDLE:ee=(z.contentHeight-z.totalHeight)/2;break;case o.VerticalAlign.BOTTOM:ee=z.contentHeight-z.totalHeight;break}e.translateWithPrecision(0,ee),z.lines.forEach((se,q)=>{e.save();const{width:Z,height:ce,items:te}=se;let Q=0;switch(x){case o.HorizontalAlign.RIGHT:Q=z.contentWidth-Z;break;case o.HorizontalAlign.CENTER:Q=(z.contentWidth-Z)/2;break}e.translate(Q,q*(ce+Tt)),te.forEach(J=>{e.save(),e.translateWithPrecision(J.left,0),$n.drawWith(e,{...W,info:J,color:k,fill:K[J.text]}),e.restore()}),e.restore()}),e.restore(),M.set(m,{left:D.startX,top:D.startY,width:z.contentWidth+at+me,height:z.contentHeight+We*2})}calcCellAutoHeight(e){var R;const{primaryWithCoord:t,style:a,data:n,row:r,col:i}=e,s=n==null?void 0:n.fontRenderExtension,{leftOffset:d=0,rightOffset:l=0,topOffset:c=0,downOffset:h=0}=s||{},g=t.isMergedMainCell?t.mergeInfo:t,u={startX:g.startX+d,endX:g.endX-l,startY:g.startY+c,endY:g.endY-h},I=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,r,i);if(!I)return;const v=this._dataValidationModel.getValidator(I.type);if(!v)return;const T=u.endX-u.startX,M=u.endY-u.startY,m=(R=_.getCellValueOrigin(n))!=null?R:"",y=v.parseCellValue(m),f=L.getFontStyleString(a!=null?a:void 0);return Ge(y,f,T,M).cellAutoHeight}calcCellAutoWidth(e){var R;const{primaryWithCoord:t,style:a,data:n,row:r,col:i}=e,s=n==null?void 0:n.fontRenderExtension,{leftOffset:d=0,rightOffset:l=0,topOffset:c=0,downOffset:h=0}=s||{},g=t.isMergedMainCell?t.mergeInfo:t,u={startX:g.startX+d,endX:g.endX-l,startY:g.startY+c,endY:g.endY-h},I=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,r,i);if(!I)return;const v=this._dataValidationModel.getValidator(I.type);if(!v)return;const T=u.endX-u.startX,M=u.endY-u.startY,m=(R=_.getCellValueOrigin(n))!=null?R:"",y=v.parseCellValue(m),f=L.getFontStyleString(a!=null?a:void 0);return Ge(y,f,T,M).calcAutoWidth}isHit(e,t){const{primaryWithCoord:a}=t,n=a.isMergedMainCell?a.mergeInfo:a,{endX:r}=n,{x:i}=e;return i>=r-me&&i<=r}onPointerDown(e,t){if(t.button===2)return;const{unitId:a,subUnitId:n,row:r,col:i}=e,s={unitId:a,subUnitId:n,row:r,column:i};this._commandService.executeCommand(He.id,s)}onPointerEnter(e,t){var a,n;return(n=(a=L.getCurrentTypeOfRenderer(o.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null?void 0:a.mainComponent)==null?void 0:n.setCursor(L.CURSOR_TYPE.POINTER)}onPointerLeave(e,t){var a,n;return(n=(a=L.getCurrentTypeOfRenderer(o.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null?void 0:a.mainComponent)==null?void 0:n.setCursor(L.CURSOR_TYPE.DEFAULT)}};rt=Xn([Le(0,o.ICommandService),Le(1,o.IUniverInstanceService),Le(2,o.Inject(L.IRenderManagerService)),Le(3,o.Inject(_.SheetDataValidationModel))],rt);class Kn extends exports.BaseSheetDataValidatorView{constructor(){super(...arguments);A(this,"id",o.DataValidationType.LIST_MULTIPLE);A(this,"canvasRender",this.injector.createInstance(rt));A(this,"dropdownType",Y.DataValidatorDropdownType.MULTIPLE_LIST)}}var Zn=Object.getOwnPropertyDescriptor,Gn=(e,t,a,n)=>{for(var r=n>1?void 0:n?Zn(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},Oe=(e,t)=>(a,n)=>t(a,n,e);const ve=4,je=4,de=14,mt=1,ue=6,De=3,qe=8,qn="#565656",ft=new Path2D("M3.32201 4.84556C3.14417 5.05148 2.85583 5.05148 2.67799 4.84556L0.134292 1.90016C-0.152586 1.56798 0.0505937 1 0.456301 1L5.5437 1C5.94941 1 6.15259 1.56798 5.86571 1.90016L3.32201 4.84556Z");function St(e,t,a,n,r,i,s=!0){let d=0;const l=s?De:0;switch(r){case o.VerticalAlign.BOTTOM:d=t-n-l;break;case o.VerticalAlign.MIDDLE:d=(t-n)/2;break;default:d=l;break}d=Math.max(De,d);let c=0;switch(i){case o.HorizontalAlign.CENTER:c=(e-a)/2;break;case o.HorizontalAlign.RIGHT:c=e-a;break}return c=Math.max(ue,c),{paddingLeft:c,paddingTop:d}}let it=class{constructor(e,t,a,n,r){A(this,"_dropdownInfoMap",new Map);A(this,"zIndex");this._univerInstanceService=e,this._localeService=t,this._commandService=a,this._renderManagerService=n,this._dataValidationModel=r}_ensureMap(e){let t=this._dropdownInfoMap.get(e);return t||(t=new Map,this._dropdownInfoMap.set(e,t)),t}_generateKey(e,t){return`${e}.${t}`}_drawDownIcon(e,t,a,n,r,i,s){const{t:d=o.DEFAULT_STYLES.pd.t,b:l=o.DEFAULT_STYLES.pd.b}=s,c=a-de;let h;switch(i){case o.VerticalAlign.MIDDLE:h=(n-je)/2;break;case o.VerticalAlign.BOTTOM:h=n-l-r-De+(r/2-je/2);break;default:h=d+De+(r/2-je/2);break}e.save(),e.translateWithPrecision(t.startX+c,t.startY+h),e.fillStyle="#565656",e.fill(ft),e.restore()}drawWith(e,t,a){var K,z,ee,ae,re,se;const{primaryWithCoord:n,row:r,col:i,style:s,data:d,subUnitId:l}=t,c=n.isMergedMainCell?n.mergeInfo:n,h=this._dataValidationModel.getRuleByLocation(t.unitId,t.subUnitId,r,i);if(!h)return;const g=this._dataValidationModel.getValidator(h.type);if(!g)return;const u=d==null?void 0:d.fontRenderExtension,{leftOffset:I=0,rightOffset:v=0,topOffset:T=0,downOffset:M=0}=u||{};if(!h||!g||!g||g.id.indexOf(o.DataValidationType.LIST)!==0||!g.skipDefaultFontRender(h))return;const m={startX:c.startX+I,endX:c.endX-v,startY:c.startY+T,endY:c.endY-M},y=m.endX-m.startX,f=m.endY-m.startY,D=this._ensureMap(l),R=this._generateKey(r,i),C=g.getListWithColor(h),w=_.getCellValueOrigin(d),k=`${w!=null?w:""}`,W=C.find(q=>q.label===k);let{tb:O,vt:x,ht:j,pd:U}=s||{};O=O!=null?O:o.WrapStrategy.WRAP,x=x!=null?x:o.VerticalAlign.BOTTOM,j=j!=null?j:o.DEFAULT_STYLES.ht,U=U!=null?U:o.DEFAULT_STYLES.pd;const B=L.getFontStyleString(s).fontCache;if(h.renderMode===o.DataValidationRenderMode.ARROW){const{l:q=o.DEFAULT_STYLES.pd.l,t:Z=o.DEFAULT_STYLES.pd.t,r:ce=o.DEFAULT_STYLES.pd.r,b:te=o.DEFAULT_STYLES.pd.b}=U,Q=y-q-ce-de-4,J=new L.DocSimpleSkeleton(k,B,O===o.WrapStrategy.WRAP,Q,1/0);J.calculate();const P=J.getTotalWidth(),$=J.getTotalHeight(),{paddingTop:S,paddingLeft:F}=St(Q,f-Z-te,P,$,x,j,!0);this._drawDownIcon(e,m,y,f,$,x,U),e.save(),e.translateWithPrecision(m.startX+q,m.startY+Z),e.beginPath(),e.rect(0,0,y-q-ce,f-Z-te),e.clip(),e.translateWithPrecision(0,S),e.save(),e.translateWithPrecision(ve,0),e.beginPath(),e.rect(0,0,Q,$),e.clip(),L.Text.drawWith(e,{text:k,fontStyle:B,width:Q,height:$,color:(K=s==null?void 0:s.cl)==null?void 0:K.rgb,strokeLine:!!((z=s==null?void 0:s.st)!=null&&z.s),underline:!!((ee=s==null?void 0:s.ul)!=null&&ee.s),warp:O===o.WrapStrategy.WRAP,hAlign:o.HorizontalAlign.LEFT},J),e.translateWithPrecision(F,0),e.restore(),e.restore(),D.set(R,{left:m.endX+q+a.rowHeaderWidth-de,top:m.startY+Z+a.columnHeaderHeight,width:de,height:f-Z-te})}else{e.save(),e.translateWithPrecision(m.startX,m.startY),e.beginPath(),e.rect(0,0,y,f),e.clip();const q=y-ue*2-ve-de-4,Z=new L.DocSimpleSkeleton(k,B,O===o.WrapStrategy.WRAP,q,1/0);Z.calculate();const ce=Z.getTotalWidth(),te=Z.getTotalHeight(),Q=te+mt*2,J=Math.max(y-ue*2,1),{paddingTop:P,paddingLeft:$}=St(J,f,ce,Q,x,j);e.translateWithPrecision(ue,P),L.Rect.drawWith(e,{width:J,height:Q,fill:(W==null?void 0:W.color)||Re,radius:qe}),e.save(),e.translateWithPrecision(ve,mt),e.beginPath(),e.rect(0,0,q,te),e.clip(),e.translateWithPrecision($,0),L.Text.drawWith(e,{text:k,fontStyle:B,width:q,height:te,color:(ae=s==null?void 0:s.cl)==null?void 0:ae.rgb,strokeLine:!!((re=s==null?void 0:s.st)!=null&&re.s),underline:!!((se=s==null?void 0:s.ul)!=null&&se.s),warp:O===o.WrapStrategy.WRAP,hAlign:o.HorizontalAlign.LEFT},Z),e.restore(),e.translateWithPrecision(q+ve+4,(te-je)/2),e.fillStyle=qn,e.fill(ft),e.restore(),D.set(R,{left:m.startX+ue+a.rowHeaderWidth,top:m.startY+P+a.columnHeaderHeight,width:J,height:Q})}}calcCellAutoHeight(e){const{primaryWithCoord:t,style:a,data:n,row:r,col:i}=e,s=t.isMergedMainCell?t.mergeInfo:t,d=n==null?void 0:n.fontRenderExtension,{leftOffset:l=0,rightOffset:c=0,topOffset:h=0,downOffset:g=0}=d||{},u=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,r,i);if(!u||u.renderMode===o.DataValidationRenderMode.TEXT)return;const I={startX:s.startX+l,endX:s.endX-c,startY:s.startY+h,endY:s.endY-g},v=I.endX-I.startX,T=_.getCellValueOrigin(n),M=`${T!=null?T:""}`;let{tb:m,pd:y}=a||{};const{t:f=o.DEFAULT_STYLES.pd.t,b:D=o.DEFAULT_STYLES.pd.b}=y!=null?y:{};if(m=m!=null?m:o.WrapStrategy.WRAP,u.renderMode===o.DataValidationRenderMode.ARROW){const R=v-de,C=new L.DocSimpleSkeleton(M,L.getFontStyleString(a).fontCache,m===o.WrapStrategy.WRAP,R,1/0);return C.calculate(),C.getTotalHeight()+f+D+De*2}else{const R=Math.max(v-ue*2-ve-de,10),C=new L.DocSimpleSkeleton(M,L.getFontStyleString(a).fontCache,m===o.WrapStrategy.WRAP,R,1/0);return C.calculate(),C.getTotalHeight()+De*2+2}}calcCellAutoWidth(e){const{primaryWithCoord:t,style:a,data:n,row:r,col:i}=e,s=t.isMergedMainCell?t.mergeInfo:t,d=n==null?void 0:n.fontRenderExtension,{leftOffset:l=0,rightOffset:c=0,topOffset:h=0,downOffset:g=0}=d||{},u=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,r,i);if(!u||u.renderMode===o.DataValidationRenderMode.TEXT)return;const I={startX:s.startX+l,endX:s.endX-c,startY:s.startY+h,endY:s.endY-g},v=I.endX-I.startX,T=_.getCellValueOrigin(n),M=`${T!=null?T:""}`;let{tb:m,pd:y}=a||{};const{l:f=o.DEFAULT_STYLES.pd.l,r:D=o.DEFAULT_STYLES.pd.r}=y!=null?y:{};m=m!=null?m:o.WrapStrategy.WRAP;let R=ue*2+de;switch(u.renderMode){case o.DataValidationRenderMode.ARROW:R=de+ue*2+D+f;break;case o.DataValidationRenderMode.CUSTOM:R=de+ue*2+ve*2+D+f+qe/2+1;break;default:R=de+ue*2+ve*2+D+f+qe/2+1}const C=v-R,w=new L.DocSimpleSkeleton(M,L.getFontStyleString(a).fontCache,m===o.WrapStrategy.WRAP,C,1/0);return w.calculate(),w.getTotalWidth()+R}isHit(e,t){const{subUnitId:a,row:n,col:r}=t,s=this._ensureMap(a).get(this._generateKey(n,r)),d=this._dataValidationModel.getRuleByLocation(t.unitId,t.subUnitId,n,r);if(!d||!s||d.renderMode===o.DataValidationRenderMode.TEXT)return!1;const{top:l,left:c,width:h,height:g}=s,{x:u,y:I}=e;return u>=c&&u<=c+h&&I>=l&&I<=l+g}onPointerDown(e,t){if(t.button===2)return;const{unitId:a,subUnitId:n,row:r,col:i}=e,s={unitId:a,subUnitId:n,row:r,column:i};this._commandService.executeCommand(He.id,s)}onPointerEnter(e,t){var a,n;(n=(a=L.getCurrentTypeOfRenderer(o.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null?void 0:a.mainComponent)==null||n.setCursor(L.CURSOR_TYPE.POINTER)}onPointerLeave(e,t){var a,n;(n=(a=L.getCurrentTypeOfRenderer(o.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null?void 0:a.mainComponent)==null||n.setCursor(L.CURSOR_TYPE.DEFAULT)}};it=Gn([Oe(0,o.IUniverInstanceService),Oe(1,o.Inject(o.LocaleService)),Oe(2,o.ICommandService),Oe(3,o.Inject(L.IRenderManagerService)),Oe(4,o.Inject(_.SheetDataValidationModel))],it);class Jn extends exports.BaseSheetDataValidatorView{constructor(){super(...arguments);A(this,"id",o.DataValidationType.LIST);A(this,"canvasRender",this.injector.createInstance(it));A(this,"dropdownType",Y.DataValidatorDropdownType.LIST);A(this,"optionsInput",Ne.componentKey);A(this,"formulaInput",_.LIST_FORMULA_INPUT_NAME)}}class Qn extends exports.BaseSheetDataValidatorView{constructor(){super(...arguments);A(this,"id",o.DataValidationType.TEXT_LENGTH);A(this,"formulaInput",_.BASE_FORMULA_INPUT_NAME)}}class ea extends exports.BaseSheetDataValidatorView{constructor(){super(...arguments);A(this,"id",o.DataValidationType.WHOLE);A(this,"formulaInput",_.BASE_FORMULA_INPUT_NAME)}}var ta=Object.getOwnPropertyDescriptor,na=(e,t,a,n)=>{for(var r=n>1?void 0:n?ta(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},Je=(e,t)=>(a,n)=>t(a,n,e);let Te=class extends o.RxDisposable{constructor(e,t,a){super(),this._injector=e,this._componentManger=t,this._dataValidatorRegistryService=a,this._initComponents(),this._registerValidatorViews()}_initComponents(){[["DataValidationIcon",wt],[Fe,Cn],[Ne.componentKey,Ne],[Be.componentKey,Be],...Mn].forEach(([e,t])=>{this.disposeWithMe(this._componentManger.register(e,t))})}_registerValidatorViews(){[Nn,ea,Qn,kn,xn,Jn,Kn,Un].forEach(e=>{const t=this._injector.createInstance(e),a=this._dataValidatorRegistryService.getValidatorItem(t.id);a&&(a.formulaInput=t.formulaInput,a.canvasRender=t.canvasRender,a.dropdownType=t.dropdownType,a.optionsInput=t.optionsInput)})}};Te=na([Je(0,o.Inject(o.Injector)),Je(1,o.Inject(E.ComponentManager)),Je(2,o.Inject(Y.DataValidatorRegistryService))],Te);var aa=Object.getOwnPropertyDescriptor,ra=(e,t,a,n)=>{for(var r=n>1?void 0:n?aa(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},Qe=(e,t)=>(a,n)=>t(a,n,e);const ia="SHEET_DATA_VALIDATION_UI_PLUGIN";var xe;exports.UniverSheetsDataValidationMobileUIPlugin=(xe=class extends o.Plugin{constructor(t=Ue,a,n,r){super(),this._config=t,this._injector=a,this._commandService=n,this._configService=r;const{menu:i,...s}=o.merge({},Ue,this._config);i&&this._configService.setConfig("menu",i,{merge:!0}),this._configService.setConfig(st,s)}onStarting(){[[he],[fe],[Pe],[Ve],[be],[Me],[Ee],[Te]].forEach(t=>{this._injector.add(t)}),[$e,He,It,lt,Se,_t].forEach(t=>{this._commandService.registerCommand(t)})}onReady(){this._injector.get(Ee),this._injector.get(Me),this._injector.get(L.IRenderManagerService).registerRenderModule(o.UniverInstanceType.UNIVER_SHEET,[ke])}onRendered(){this._injector.get(Te),this._injector.get(be)}onSteady(){this._injector.get(Ve)}},A(xe,"pluginName",ia),A(xe,"type",o.UniverInstanceType.UNIVER_SHEET),xe);exports.UniverSheetsDataValidationMobileUIPlugin=ra([Qe(1,o.Inject(o.Injector)),Qe(2,o.ICommandService),Qe(3,o.IConfigService)],exports.UniverSheetsDataValidationMobileUIPlugin);var oa=Object.defineProperty,sa=Object.getOwnPropertyDescriptor,la=(e,t,a)=>t in e?oa(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a,da=(e,t,a,n)=>{for(var r=n>1?void 0:n?sa(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},et=(e,t)=>(a,n)=>t(a,n,e),Ot=(e,t,a)=>la(e,typeof t!="symbol"?t+"":t,a);const ca="SHEET_DATA_VALIDATION_UI_PLUGIN";exports.UniverSheetsDataValidationUIPlugin=class extends o.Plugin{constructor(t=Ue,a,n,r){super(),this._config=t,this._injector=a,this._commandService=n,this._configService=r;const{menu:i,...s}=o.merge({},Ue,this._config);i&&this._configService.setConfig("menu",i,{merge:!0}),this._configService.setConfig(st,s)}onStarting(){[[he],[fe],[Pe],[Ve],[be],[Me],[Ee],[we],[Te]].forEach(t=>{this._injector.add(t)}),[$e,He,It,lt,Se,_t].forEach(t=>{this._commandService.registerCommand(t)})}onReady(){this._injector.get(Ee),this._injector.get(Me),this._injector.get(we),this._injector.get(Pe),this._injector.get(L.IRenderManagerService).registerRenderModule(o.UniverInstanceType.UNIVER_SHEET,[ke])}onRendered(){this._injector.get(Te),this._injector.get(be)}onSteady(){this._injector.get(Ve)}};Ot(exports.UniverSheetsDataValidationUIPlugin,"pluginName",ca);Ot(exports.UniverSheetsDataValidationUIPlugin,"type",o.UniverInstanceType.UNIVER_SHEET);exports.UniverSheetsDataValidationUIPlugin=da([o.DependentOn(_.UniverSheetsDataValidationPlugin),et(1,o.Inject(o.Injector)),et(2,o.ICommandService),et(3,o.IConfigService)],exports.UniverSheetsDataValidationUIPlugin);
5
+ `,{"hover:univer-bg-gray-50 dark:hover:!univer-bg-gray-700":!i,"univer-opacity-50":i}),onClick:a,onMouseEnter:()=>{i||(u(!0),h.current=t.ranges.map(m=>l.addShape({range:m,style:T,primary:null})))},onMouseLeave:()=>{var m;u(!1),(m=h.current)==null||m.forEach(y=>{y&&l.removeShape(y)}),h.current=void 0},children:[p.jsx("div",{className:"univer-truncate univer-text-sm univer-font-medium univer-leading-[22px] univer-text-gray-900 dark:!univer-text-white",children:c==null?void 0:c.generateRuleName(t)}),p.jsx("div",{className:"univer-text-secondary univer-truncate univer-text-xs univer-leading-[18px] dark:!univer-text-gray-300",children:t.ranges.map(m=>tt.serializeRange(m)).join(",")}),g?p.jsx("div",{className:"univer-absolute univer-right-2 univer-top-[19px] univer-flex univer-h-5 univer-w-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:M,children:p.jsx(dt,{})}):null]})};function In(e){const t=E.useDependency(_.SheetDataValidationModel),a=E.useDependency(o.IUniverInstanceService),n=E.useDependency(o.ICommandService),r=E.useDependency(o.Injector),i=E.useDependency(he),s=E.useDependency(o.LocaleService),[d,l]=b.useState([]),{workbook:c}=e,h=E.useObservable(c.activeSheet$,void 0,!0),g=c.getUnitId(),u=h==null?void 0:h.getSheetId();b.useEffect(()=>{l(t.getRules(g,u));const y=t.ruleChange$.subscribe(f=>{f.unitId===g&&f.subUnitId===u&&l(t.getRules(g,u))});return()=>{y.unsubscribe()}},[g,u,t]);const I=async()=>{const y=_.createDefaultNewRule(r),f={unitId:g,subUnitId:u,rule:y};await n.executeCommand(_.AddSheetDataValidationCommand.id,f),i.setActiveRule({unitId:g,subUnitId:u,rule:y})},v=()=>{n.executeCommand(_.RemoveSheetAllDataValidationCommand.id,{unitId:g,subUnitId:u})},M=(y=>{const f=a.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET),D=f.getActiveSheet(),R=f.getUnitId(),C=D.getSheetId();return y.map(k=>H.checkRangesEditablePermission(r,R,C,k.ranges)?{...k}:{...k,disable:!0})})(d),m=M==null?void 0:M.some(y=>y.disable);return p.jsxs("div",{className:"univer-pb-4",children:[M==null?void 0:M.map(y=>{var f;return p.jsx(_n,{unitId:g,subUnitId:u,onClick:()=>{y.disable||i.setActiveRule({unitId:g,subUnitId:u,rule:y})},rule:y,disable:(f=y.disable)!=null?f:!1},y.uid)}),p.jsxs("div",{className:"univer-mt-4 univer-flex univer-flex-row univer-justify-end univer-gap-2",children:[d.length&&!m?p.jsx(V.Button,{onClick:v,children:s.t("dataValidation.panel.removeAll")}):null,p.jsx(V.Button,{variant:"primary",onClick:I,children:s.t("dataValidation.panel.add")})]})]})}const Cn=()=>{const e=E.useDependency(he),t=E.useObservable(e.activeRule$,e.activeRule),a=E.useDependency(o.IUniverInstanceService),n=E.useObservable(()=>a.getCurrentTypeOfUnit$(o.UniverInstanceType.UNIVER_SHEET),void 0,void 0,[]),r=E.useObservable(()=>{var i;return(i=n==null?void 0:n.activeSheet$)!=null?i:oe.of(null)},void 0,void 0,[]);return!n||!r?null:t&&t.subUnitId===r.getSheetId()?p.jsx(Sn,{},t.rule.uid):p.jsx(In,{workbook:n})},yn=e=>{const{isTwoFormula:t=!1,value:a,onChange:n,showError:r,validResult:i}=e,s=E.useDependency(o.LocaleService),d=r?i==null?void 0:i.formula1:"",l=r?i==null?void 0:i.formula2:"";return t?p.jsxs(p.Fragment,{children:[p.jsx(V.FormLayout,{error:d,children:p.jsx(V.Input,{className:"univer-w-full",placeholder:s.t("dataValidation.panel.formulaPlaceholder"),value:a==null?void 0:a.formula1,onChange:c=>{n==null||n({...a,formula1:c})}})}),p.jsx("div",{className:"-univer-mt-2 univer-mb-1 univer-text-sm univer-text-gray-400",children:s.t("dataValidation.panel.formulaAnd")}),p.jsx(V.FormLayout,{error:l,children:p.jsx(V.Input,{className:"univer-w-full",placeholder:s.t("dataValidation.panel.formulaPlaceholder"),value:a==null?void 0:a.formula2,onChange:c=>{n==null||n({...a,formula2:c})}})})]}):p.jsx(V.FormLayout,{error:d,children:p.jsx(V.Input,{className:"univer-w-full",placeholder:s.t("dataValidation.panel.formulaPlaceholder"),value:a==null?void 0:a.formula1,onChange:c=>{n==null||n({formula1:c})}})})};function Rn(e){const{value:t,onChange:a,showError:n,validResult:r}=e,i=E.useDependency(o.LocaleService),s=n?r==null?void 0:r.formula1:"",d=n?r==null?void 0:r.formula2:"",[l,c]=b.useState(!((t==null?void 0:t.formula1)===void 0&&(t==null?void 0:t.formula2)===void 0));return p.jsxs(p.Fragment,{children:[p.jsx(V.FormLayout,{children:p.jsx(V.Checkbox,{checked:l,onChange:h=>{h?c(!0):(c(!1),a==null||a({...t,formula1:void 0,formula2:void 0}))},children:i.t("dataValidation.checkbox.tips")})}),l?p.jsx(V.FormLayout,{label:i.t("dataValidation.checkbox.checked"),error:s,children:p.jsx(V.Input,{className:"univer-w-full",placeholder:i.t("dataValidation.panel.valuePlaceholder"),value:t==null?void 0:t.formula1,onChange:h=>{a==null||a({...t,formula1:h||void 0})}})}):null,l?p.jsx(V.FormLayout,{label:i.t("dataValidation.checkbox.unchecked"),error:d,children:p.jsx(V.Input,{className:"univer-w-full",placeholder:i.t("dataValidation.panel.valuePlaceholder"),value:t==null?void 0:t.formula2,onChange:h=>{a==null||a({...t,formula2:h||void 0})}})}):null]})}function Dn(e){var g;const{unitId:t,subUnitId:a,value:n,onChange:r,showError:i,validResult:s}=e,d=i?s==null?void 0:s.formula1:void 0,l=b.useRef(null),[c,h]=b.useState(!1);return E.useSidebarClick(u=>{var v;((v=l.current)==null?void 0:v.isClickOutSide(u))&&h(!1)}),p.jsx(V.FormLayout,{error:d,children:p.jsx(ot.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:(g=n==null?void 0:n.formula1)!=null?g:"=",unitId:t,subUnitId:a,isFocus:c,isSupportAcrossSheet:!0,onChange:u=>{const I=(u!=null?u:"").trim();I!==(n==null?void 0:n.formula1)&&(r==null||r({...n,formula1:I}))},onFocus:()=>h(!0)})})}const Re="#ECECEC",wn=["#FFFFFF","#FEE7E7","#FEF0E6","#EFFBD0","#E4F4FE","#E8ECFD","#F1EAFA","#FDE8F3","#E5E5E5","#FDCECE","#FDC49B","#DEF6A2","#9FDAFF","#D0D9FB","#E3D5F6","#FBD0E8","#656565","#FE4B4B","#FF8C51","#8BBB11","#0B9EFB","#3A60F7","#9E6DE3","#F248A6"],Vn=e=>{const{value:t,onChange:a,disabled:n}=e,[r,i]=b.useState(!1);return p.jsx(V.Dropdown,{align:"start",disabled:n,open:r,onOpenChange:i,overlay:p.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:wn.map(s=>p.jsx("div",{className:V.clsx("univer-box-border univer-size-4 univer-cursor-pointer univer-rounded",V.borderClassName),style:{background:s},onClick:()=>{a(s),i(!1)}},s))}),children:p.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:[p.jsx("div",{className:"univer-box-border univer-h-4 univer-w-4 univer-rounded univer-text-base",style:{background:t}}),p.jsx(ct,{})]})})},vt=e=>{const{item:t,commonProps:a,className:n}=e,{onItemChange:r,onItemDelete:i}=a;return p.jsxs("div",{className:V.clsx("univer-flex univer-items-center univer-gap-2",n),children:[!t.isRef&&p.jsx("div",{className:V.clsx("univer-cursor-move","draggableHandle"),children:p.jsx(Mt,{})}),p.jsx(Vn,{value:t.color,onChange:s=>{r(t.id,t.label,s)}}),p.jsx(V.Input,{disabled:t.isRef,value:t.label,onChange:s=>{r(t.id,s,t.color)}}),t.isRef?null:p.jsx("div",{className:"univer-ml-1 univer-cursor-pointer univer-rounded univer-text-base hover:univer-bg-gray-200",children:p.jsx(dt,{onClick:()=>i(t.id)})})]})};function En(e){const{value:t,onChange:a=()=>{},unitId:n,subUnitId:r,validResult:i,showError:s,ruleId:d}=e,{formula1:l="",formula2:c=""}=t||{},[h,g]=b.useState(()=>o.isFormulaString(l)?"1":"0"),[u,I]=b.useState(h==="1"?l:"="),[v,T]=b.useState(h==="1"?l:"="),M=E.useDependency(o.LocaleService),m=E.useDependency(Y.DataValidatorRegistryService),y=E.useDependency(Y.DataValidationModel),f=E.useDependency(_.DataValidationFormulaController),[D,R]=b.useState(()=>c.split(",")),C=m.getValidatorItem(o.DataValidationType.LIST),[w,k]=b.useState([]),[W,O]=b.useState(""),x=s?i==null?void 0:i.formula1:"",j=b.useMemo(()=>y.ruleChange$.pipe(oe.debounceTime(16)),[]),U=E.useObservable(j),B=E.useEvent(a);b.useEffect(()=>{(async()=>{await new Promise(S=>{setTimeout(()=>S(!0),100)});const P=y.getRuleById(n,r,d),$=P==null?void 0:P.formula1;if(o.isFormulaString($)&&C&&P){const S=await C.getListAsync(P,n,r);k(S)}})()},[y,U,C,d,r,n]),b.useEffect(()=>{o.isFormulaString(l)&&l!==v&&(I(l),T(v))},[v,l]);const[K,z]=b.useState(()=>{const P=h!=="1"?_.deserializeListOptions(l):[],$=c.split(",");return P.map((S,F)=>({label:S,color:$[F]||Re,isRef:!1,id:o.generateRandomId(4)}))}),ee=(P,$,S)=>{const F=K.find(X=>X.id===P);F&&(F.label=$,F.color=S,z([...K]))},ae=P=>{const $=K.findIndex(S=>S.id===P);$!==-1&&(K.splice($,1),z([...K]))},re=c.split(","),se=b.useMemo(()=>w.map((P,$)=>({label:P,color:re[$]||Re,id:`${$}`,isRef:!0})),[re,w]),q=(P,$,S)=>{const F=[...D];F[+P]=S,R(F),B({formula1:l,formula2:F.join(",")})},Z=()=>{z([...K,{label:"",color:Re,isRef:!1,id:o.generateRandomId(4)}])};b.useEffect(()=>{if(h==="1")return;const P=new Set,$=[];K.map(S=>({labelList:S.label.split(","),item:S})).forEach(({item:S,labelList:F})=>{F.forEach(X=>{P.has(X)||(P.add(X),$.push({label:X,color:S.color}))})}),B({formula1:_.serializeListOptions($.map(S=>S.label)),formula2:$.map(S=>S.color===Re?"":S.color).join(",")})},[K,B,h,v,D]);const ce=E.useEvent(async P=>{if(!o.isFormulaString(P)){B==null||B({formula1:"",formula2:c});return}f.getFormulaRefCheck(P)?(B==null||B({formula1:o.isFormulaString(P)?P:"",formula2:c}),O("")):(B==null||B({formula1:"",formula2:c}),I("="),O(M.t("dataValidation.validFail.formulaError")))}),te=b.useRef(null),[Q,J]=b.useState(!1);return E.useSidebarClick(P=>{var S;((S=te.current)==null?void 0:S.isClickOutSide(P))&&J(!1)}),p.jsxs(p.Fragment,{children:[p.jsx(V.FormLayout,{label:M.t("dataValidation.list.options"),children:p.jsxs(V.RadioGroup,{value:h,onChange:P=>{g(P),I(v),P==="1"&&B({formula1:v==="="?"":v,formula2:D.join(",")})},children:[p.jsx(V.Radio,{value:"0",children:M.t("dataValidation.list.customOptions")}),p.jsx(V.Radio,{value:"1",children:M.t("dataValidation.list.refOptions")})]})}),h==="1"?p.jsxs(V.FormLayout,{error:x||W||void 0,children:[p.jsx(ot.FormulaEditor,{ref:te,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:n,subUnitId:r,isFocus:Q,isSupportAcrossSheet:!0,onFocus:()=>J(!0),onChange:(P="")=>{const $=(P!=null?P:"").trim();T($),ce($)}}),se.length>0&&p.jsx("div",{className:"univer-mt-3",children:se.map(P=>p.jsx(vt,{className:"univer-mb-3",item:P,commonProps:{onItemChange:q}},P.id))})]}):p.jsx(V.FormLayout,{error:x,children:p.jsxs("div",{className:"-univer-mt-3",children:[p.jsx(V.DraggableList,{list:K,onListChange:z,rowHeight:28,margin:[0,12],draggableHandle:".draggableHandle",itemRender:P=>p.jsx(vt,{item:P,commonProps:{onItemChange:ee,onItemDelete:ae}},P.id),idKey:"id"}),p.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:Z,children:[p.jsx(Vt,{className:"univer-mr-1"}),M.t("dataValidation.list.add")]})]})})]})}const Mn=[[_.CUSTOM_FORMULA_INPUT_NAME,Dn],[_.BASE_FORMULA_INPUT_NAME,yn],[_.LIST_FORMULA_INPUT_NAME,En],[_.CHECKBOX_FORMULA_INPUT_NAME,Rn]],bn="LIST_RENDER_MODE_OPTION_INPUT";function Ne(e){var r;const{value:t,onChange:a}=e,n=E.useDependency(o.LocaleService);return p.jsx(V.FormLayout,{label:n.t("dataValidation.renderMode.label"),children:p.jsxs(V.RadioGroup,{value:`${(r=t.renderMode)!=null?r:o.DataValidationRenderMode.CUSTOM}`,onChange:i=>a({...t,renderMode:+i}),children:[p.jsx(V.Radio,{value:`${o.DataValidationRenderMode.CUSTOM}`,children:n.t("dataValidation.renderMode.chip")}),p.jsx(V.Radio,{value:`${o.DataValidationRenderMode.ARROW}`,children:n.t("dataValidation.renderMode.arrow")}),p.jsx(V.Radio,{value:`${o.DataValidationRenderMode.TEXT}`,children:n.t("dataValidation.renderMode.text")})]})})}Ne.componentKey=bn;const Tn="DATE_SHOW_TIME_OPTION";function Be(e){var r;const{value:t,onChange:a}=e,n=E.useDependency(o.LocaleService);return p.jsx(V.FormLayout,{children:p.jsx(V.Checkbox,{checked:(r=t.bizInfo)==null?void 0:r.showTime,onChange:i=>{a({...t,bizInfo:{...t.bizInfo,showTime:i}})},children:n.t("dataValidation.showTime.label")})})}Be.componentKey=Tn;var On=Object.getOwnPropertyDescriptor,Pn=(e,t,a,n)=>{for(var r=n>1?void 0:n?On(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},ye=(e,t)=>(a,n)=>t(a,n,e);const Ae=6;let nt=class{constructor(e,t,a,n,r,i){this._commandService=e,this._univerInstanceService=t,this._formulaService=a,this._themeService=n,this._renderManagerService=r,this._dataValidationModel=i}_calc(e,t){var c,h,g;const{vt:a,ht:n}=t||{},r=e.endX-e.startX-Ae*2,i=e.endY-e.startY,s=((c=t==null?void 0:t.fs)!=null?c:10)*1.6;let d=0,l=0;switch(a){case o.VerticalAlign.TOP:l=0;break;case o.VerticalAlign.BOTTOM:l=0+(i-s);break;default:l=0+(i-s)/2;break}switch(n){case o.HorizontalAlign.LEFT:d=Ae;break;case o.HorizontalAlign.RIGHT:d=Ae+(r-s);break;default:d=Ae+(r-s)/2;break}return{left:e.startX+d,top:e.startY+l,width:((h=t==null?void 0:t.fs)!=null?h:10)*1.6,height:((g=t==null?void 0:t.fs)!=null?g:10)*1.6}}calcCellAutoHeight(e){var a;const{style:t}=e;return((a=t==null?void 0:t.fs)!=null?a:10)*1.6}calcCellAutoWidth(e){var a;const{style:t}=e;return((a=t==null?void 0:t.fs)!=null?a:10)*1.6}async _parseFormula(e,t,a){var c,h,g,u,I,v,T,M,m;const{formula1:n=_.CHECKBOX_FORMULA_1,formula2:r=_.CHECKBOX_FORMULA_2}=e,i=await this._formulaService.getRuleFormulaResult(t,a,e.uid),s=_.getFormulaResult((g=(h=(c=i==null?void 0:i[0])==null?void 0:c.result)==null?void 0:h[0])==null?void 0:g[0]),d=_.getFormulaResult((v=(I=(u=i==null?void 0:i[1])==null?void 0:u.result)==null?void 0:I[0])==null?void 0:v[0]),l=_.isLegalFormulaResult(String(s))&&_.isLegalFormulaResult(String(d));return{formula1:o.isFormulaString(n)?_.getFormulaResult((m=(M=(T=i==null?void 0:i[0])==null?void 0:T.result)==null?void 0:M[0])==null?void 0:m[0]):n,formula2:o.isFormulaString(r)?d:r,isFormulaValid:l}}drawWith(e,t){var x,j,U,B;const{style:a,primaryWithCoord:n,unitId:r,subUnitId:i,worksheet:s,row:d,col:l}=t,c=n.isMergedMainCell?n.mergeInfo:n,h=_.getCellValueOrigin(s.getCellRaw(d,l)),g=this._dataValidationModel.getRuleByLocation(r,i,d,l);if(!g)return;const u=this._dataValidationModel.getValidator(g.type);if(!u||!((x=u.skipDefaultFontRender)!=null&&x.call(u,g,h,{unitId:r,subUnitId:i,row:d,column:l})))return;const I=u.parseFormulaSync(g,r,i),{formula1:v}=I,T=this._calc(c,a),{a:M,d:m}=e.getTransform(),y=L.fixLineWidthByScale(T.left,M),f=L.fixLineWidthByScale(T.top,m),D=L.Transform.create().composeMatrix({left:y,top:f,scaleX:1,scaleY:1,angle:0,skewX:0,skewY:0,flipX:!1,flipY:!1}),R=c.endX-c.startX,C=c.endY-c.startY;e.save(),e.beginPath(),e.rect(c.startX,c.startY,R,C),e.clip();const w=D.getMatrix();e.transform(w[0],w[1],w[2],w[3],w[4],w[5]);const k=((j=a==null?void 0:a.fs)!=null?j:10)*1.6,W=String(h)===String(v),O=this._themeService.getColorFromTheme("primary.600");L.CheckboxShape.drawWith(e,{checked:W,width:k,height:k,fill:(B=(U=a==null?void 0:a.cl)==null?void 0:U.rgb)!=null?B:O}),e.restore()}isHit(e,t){const a=t.primaryWithCoord.isMergedMainCell?t.primaryWithCoord.mergeInfo:t.primaryWithCoord,n=this._calc(a,t.style),r=n.top,i=n.top+n.height,s=n.left,d=n.left+n.width,{x:l,y:c}=e;return l<=d&&l>=s&&c<=i&&c>=r}async onPointerDown(e,t){var v;if(t.button===2)return;const{primaryWithCoord:a,unitId:n,subUnitId:r,worksheet:i,row:s,col:d}=e,l=_.getCellValueOrigin(i.getCellRaw(s,d)),c=this._dataValidationModel.getRuleByLocation(n,r,s,d);if(!c)return;const h=this._dataValidationModel.getValidator(c.type);if(!h||!((v=h.skipDefaultFontRender)!=null&&v.call(h,c,l,{unitId:n,subUnitId:r,row:s,column:d})))return;const{formula1:g,formula2:u}=await this._parseFormula(c,n,r),I={range:{startColumn:a.actualColumn,endColumn:a.actualColumn,startRow:a.actualRow,endRow:a.actualRow},value:{v:String(l)===_.transformCheckboxValue(String(g))?u:g,p:null}};this._commandService.executeCommand(H.SetRangeValuesCommand.id,I)}onPointerEnter(e,t){var a,n;(n=(a=L.getCurrentTypeOfRenderer(o.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null?void 0:a.mainComponent)==null||n.setCursor(L.CURSOR_TYPE.POINTER)}onPointerLeave(e,t){var a,n;(n=(a=L.getCurrentTypeOfRenderer(o.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null?void 0:a.mainComponent)==null||n.setCursor(L.CURSOR_TYPE.DEFAULT)}};nt=Pn([ye(0,o.ICommandService),ye(1,o.IUniverInstanceService),ye(2,o.Inject(_.DataValidationFormulaService)),ye(3,o.Inject(o.ThemeService)),ye(4,o.Inject(L.IRenderManagerService)),ye(5,o.Inject(_.SheetDataValidationModel))],nt);var An=Object.getOwnPropertyDescriptor,Ln=(e,t,a,n)=>{for(var r=n>1?void 0:n?An(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},jn=(e,t)=>(a,n)=>t(a,n,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=Ln([jn(0,o.Inject(o.Injector))],exports.BaseSheetDataValidatorView);class xn extends exports.BaseSheetDataValidatorView{constructor(){super(...arguments);A(this,"id",o.DataValidationType.CHECKBOX);A(this,"canvasRender",this.injector.createInstance(nt));A(this,"formulaInput",_.CHECKBOX_FORMULA_INPUT_NAME)}}class Un extends exports.BaseSheetDataValidatorView{constructor(){super(...arguments);A(this,"id",o.DataValidationType.CUSTOM);A(this,"formulaInput",_.CUSTOM_FORMULA_INPUT_NAME)}}const Fn="data-validation.formula-input";class kn extends exports.BaseSheetDataValidatorView{constructor(){super(...arguments);A(this,"id",o.DataValidationType.DATE);A(this,"formulaInput",Fn);A(this,"optionsInput",Be.componentKey);A(this,"dropdownType",Y.DataValidatorDropdownType.DATE)}}class Nn extends exports.BaseSheetDataValidatorView{constructor(){super(...arguments);A(this,"id",o.DataValidationType.DECIMAL);A(this,"formulaInput",_.BASE_FORMULA_INPUT_NAME)}}const bt=4,Bn=0,Ze=4,Tt=4,at=6,We=6,me=14;function Wn(e,t){const a=L.FontCache.getTextSize(e,t),n=a.width+bt*2,{ba:r,bd:i}=a,s=r+i;return{width:n,height:s+Bn*2,ba:r}}function Ge(e,t,a,n){const r=me+at*2,i=a-r,s=n-We*2,d=e.map(u=>({layout:Wn(u,t),text:u}));let l;const c=[];d.forEach(u=>{const{layout:I}=u,{width:v,height:T}=I;!l||l.width+v+Ze>i?(l={width:v,height:T,items:[{...u,left:0}]},c.push(l)):(l.items.push({...u,left:l.width+Ze}),l.width=l.width+v+Ze)});let h=0,g=0;return c.forEach((u,I)=>{g=Math.max(g,u.width),I===c.length-1?h+=u.height:h+=u.height+Tt}),{lines:c,totalHeight:h,contentWidth:i,contentHeight:s,cellAutoHeight:h+We*2,calcAutoWidth:g+r}}const Hn=8;class $n extends L.Shape{static drawWith(t,a){const{fontString:n,info:r,fill:i,color:s}=a,{layout:d,text:l}=r;t.save(),L.Rect.drawWith(t,{width:d.width,height:d.height,radius:Hn,fill:i||Re}),t.translateWithPrecision(bt,d.ba),t.font=n,t.fillStyle=s,t.fillText(l,0,0),t.restore()}}var Yn=Object.getOwnPropertyDescriptor,Xn=(e,t,a,n)=>{for(var r=n>1?void 0:n?Yn(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},Le=(e,t)=>(a,n)=>t(a,n,e);const zn=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 rt=class{constructor(e,t,a,n){A(this,"zIndex");A(this,"_dropdownInfoMap",new Map);this._commandService=e,this._univerInstanceService=t,this._renderManagerService=a,this._dataValidationModel=n}_ensureMap(e){let t=this._dropdownInfoMap.get(e);return t||(t=new Map,this._dropdownInfoMap.set(e,t)),t}_generateKey(e,t){return`${e}.${t}`}_drawDownIcon(e,t,a,n,r){const i=a-me+4;let s=4;switch(r){case o.VerticalAlign.MIDDLE:s=(n-me)/2+4;break;case o.VerticalAlign.BOTTOM:s=n-me+4;break}e.save(),e.translateWithPrecision(t.startX+i,t.startY+s),e.fillStyle="#565656",e.fill(zn),e.restore()}drawWith(e,t,a,n){var ae,re;const{primaryWithCoord:r,row:i,col:s,style:d,data:l,subUnitId:c}=t,h=r.isMergedMainCell?r.mergeInfo:r,g=l==null?void 0:l.fontRenderExtension,{leftOffset:u=0,rightOffset:I=0,topOffset:v=0,downOffset:T=0}=g||{},M=this._ensureMap(c),m=this._generateKey(i,s),y=this._dataValidationModel.getRuleByLocation(t.unitId,t.subUnitId,i,s);if(!y)return;const f=this._dataValidationModel.getValidator(y.type);if(!f)return;const D={startX:h.startX+u,endX:h.endX-I,startY:h.startY+v,endY:h.endY-T},R=D.endX-D.startX,C=D.endY-D.startY,{cl:w}=d||{},k=(ae=typeof w=="object"?w==null?void 0:w.rgb:w)!=null?ae:"#000",W=L.getFontStyleString(d!=null?d:void 0),{vt:O,ht:x}=d||{},j=O!=null?O:o.VerticalAlign.MIDDLE,U=(re=_.getCellValueOrigin(l))!=null?re:"",B=f.parseCellValue(U),K=f.getListWithColorMap(y),z=Ge(B,W,R,C);this._drawDownIcon(e,D,R,C,j),e.save(),e.translateWithPrecision(D.startX,D.startY),e.beginPath(),e.rect(0,0,R-me,C),e.clip(),e.translateWithPrecision(at,We);let ee=0;switch(j){case o.VerticalAlign.MIDDLE:ee=(z.contentHeight-z.totalHeight)/2;break;case o.VerticalAlign.BOTTOM:ee=z.contentHeight-z.totalHeight;break}e.translateWithPrecision(0,ee),z.lines.forEach((se,q)=>{e.save();const{width:Z,height:ce,items:te}=se;let Q=0;switch(x){case o.HorizontalAlign.RIGHT:Q=z.contentWidth-Z;break;case o.HorizontalAlign.CENTER:Q=(z.contentWidth-Z)/2;break}e.translate(Q,q*(ce+Tt)),te.forEach(J=>{e.save(),e.translateWithPrecision(J.left,0),$n.drawWith(e,{...W,info:J,color:k,fill:K[J.text]}),e.restore()}),e.restore()}),e.restore(),M.set(m,{left:D.startX,top:D.startY,width:z.contentWidth+at+me,height:z.contentHeight+We*2})}calcCellAutoHeight(e){var R;const{primaryWithCoord:t,style:a,data:n,row:r,col:i}=e,s=n==null?void 0:n.fontRenderExtension,{leftOffset:d=0,rightOffset:l=0,topOffset:c=0,downOffset:h=0}=s||{},g=t.isMergedMainCell?t.mergeInfo:t,u={startX:g.startX+d,endX:g.endX-l,startY:g.startY+c,endY:g.endY-h},I=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,r,i);if(!I)return;const v=this._dataValidationModel.getValidator(I.type);if(!v)return;const T=u.endX-u.startX,M=u.endY-u.startY,m=(R=_.getCellValueOrigin(n))!=null?R:"",y=v.parseCellValue(m),f=L.getFontStyleString(a!=null?a:void 0);return Ge(y,f,T,M).cellAutoHeight}calcCellAutoWidth(e){var R;const{primaryWithCoord:t,style:a,data:n,row:r,col:i}=e,s=n==null?void 0:n.fontRenderExtension,{leftOffset:d=0,rightOffset:l=0,topOffset:c=0,downOffset:h=0}=s||{},g=t.isMergedMainCell?t.mergeInfo:t,u={startX:g.startX+d,endX:g.endX-l,startY:g.startY+c,endY:g.endY-h},I=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,r,i);if(!I)return;const v=this._dataValidationModel.getValidator(I.type);if(!v)return;const T=u.endX-u.startX,M=u.endY-u.startY,m=(R=_.getCellValueOrigin(n))!=null?R:"",y=v.parseCellValue(m),f=L.getFontStyleString(a!=null?a:void 0);return Ge(y,f,T,M).calcAutoWidth}isHit(e,t){const{primaryWithCoord:a}=t,n=a.isMergedMainCell?a.mergeInfo:a,{endX:r}=n,{x:i}=e;return i>=r-me&&i<=r}onPointerDown(e,t){if(t.button===2)return;const{unitId:a,subUnitId:n,row:r,col:i}=e,s={unitId:a,subUnitId:n,row:r,column:i};this._commandService.executeCommand(He.id,s)}onPointerEnter(e,t){var a,n;return(n=(a=L.getCurrentTypeOfRenderer(o.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null?void 0:a.mainComponent)==null?void 0:n.setCursor(L.CURSOR_TYPE.POINTER)}onPointerLeave(e,t){var a,n;return(n=(a=L.getCurrentTypeOfRenderer(o.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null?void 0:a.mainComponent)==null?void 0:n.setCursor(L.CURSOR_TYPE.DEFAULT)}};rt=Xn([Le(0,o.ICommandService),Le(1,o.IUniverInstanceService),Le(2,o.Inject(L.IRenderManagerService)),Le(3,o.Inject(_.SheetDataValidationModel))],rt);class Kn extends exports.BaseSheetDataValidatorView{constructor(){super(...arguments);A(this,"id",o.DataValidationType.LIST_MULTIPLE);A(this,"canvasRender",this.injector.createInstance(rt));A(this,"dropdownType",Y.DataValidatorDropdownType.MULTIPLE_LIST)}}var Zn=Object.getOwnPropertyDescriptor,Gn=(e,t,a,n)=>{for(var r=n>1?void 0:n?Zn(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},Oe=(e,t)=>(a,n)=>t(a,n,e);const ve=4,je=4,de=14,mt=1,ue=6,De=3,qe=8,qn="#565656",ft=new Path2D("M3.32201 4.84556C3.14417 5.05148 2.85583 5.05148 2.67799 4.84556L0.134292 1.90016C-0.152586 1.56798 0.0505937 1 0.456301 1L5.5437 1C5.94941 1 6.15259 1.56798 5.86571 1.90016L3.32201 4.84556Z");function St(e,t,a,n,r,i,s=!0){let d=0;const l=s?De:0;switch(r){case o.VerticalAlign.BOTTOM:d=t-n-l;break;case o.VerticalAlign.MIDDLE:d=(t-n)/2;break;default:d=l;break}d=Math.max(De,d);let c=0;switch(i){case o.HorizontalAlign.CENTER:c=(e-a)/2;break;case o.HorizontalAlign.RIGHT:c=e-a;break}return c=Math.max(ue,c),{paddingLeft:c,paddingTop:d}}let it=class{constructor(e,t,a,n,r){A(this,"_dropdownInfoMap",new Map);A(this,"zIndex");this._univerInstanceService=e,this._localeService=t,this._commandService=a,this._renderManagerService=n,this._dataValidationModel=r}_ensureMap(e){let t=this._dropdownInfoMap.get(e);return t||(t=new Map,this._dropdownInfoMap.set(e,t)),t}_generateKey(e,t){return`${e}.${t}`}_drawDownIcon(e,t,a,n,r,i,s){const{t:d=o.DEFAULT_STYLES.pd.t,b:l=o.DEFAULT_STYLES.pd.b}=s,c=a-de;let h;switch(i){case o.VerticalAlign.MIDDLE:h=(n-je)/2;break;case o.VerticalAlign.BOTTOM:h=n-l-r-De+(r/2-je/2);break;default:h=d+De+(r/2-je/2);break}e.save(),e.translateWithPrecision(t.startX+c,t.startY+h),e.fillStyle="#565656",e.fill(ft),e.restore()}drawWith(e,t,a){var K,z,ee,ae,re,se;const{primaryWithCoord:n,row:r,col:i,style:s,data:d,subUnitId:l}=t,c=n.isMergedMainCell?n.mergeInfo:n,h=this._dataValidationModel.getRuleByLocation(t.unitId,t.subUnitId,r,i);if(!h)return;const g=this._dataValidationModel.getValidator(h.type);if(!g)return;const u=d==null?void 0:d.fontRenderExtension,{leftOffset:I=0,rightOffset:v=0,topOffset:T=0,downOffset:M=0}=u||{};if(!h||!g||!g||g.id.indexOf(o.DataValidationType.LIST)!==0||!g.skipDefaultFontRender(h))return;const m={startX:c.startX+I,endX:c.endX-v,startY:c.startY+T,endY:c.endY-M},y=m.endX-m.startX,f=m.endY-m.startY,D=this._ensureMap(l),R=this._generateKey(r,i),C=g.getListWithColor(h),w=_.getCellValueOrigin(d),k=`${w!=null?w:""}`,W=C.find(q=>q.label===k);let{tb:O,vt:x,ht:j,pd:U}=s||{};O=O!=null?O:o.WrapStrategy.WRAP,x=x!=null?x:o.VerticalAlign.BOTTOM,j=j!=null?j:o.DEFAULT_STYLES.ht,U=U!=null?U:o.DEFAULT_STYLES.pd;const B=L.getFontStyleString(s).fontCache;if(h.renderMode===o.DataValidationRenderMode.ARROW){const{l:q=o.DEFAULT_STYLES.pd.l,t:Z=o.DEFAULT_STYLES.pd.t,r:ce=o.DEFAULT_STYLES.pd.r,b:te=o.DEFAULT_STYLES.pd.b}=U,Q=y-q-ce-de-4,J=new L.DocSimpleSkeleton(k,B,O===o.WrapStrategy.WRAP,Q,1/0);J.calculate();const P=J.getTotalWidth(),$=J.getTotalHeight(),{paddingTop:S,paddingLeft:F}=St(Q,f-Z-te,P,$,x,j,!0);this._drawDownIcon(e,m,y,f,$,x,U),e.save(),e.translateWithPrecision(m.startX+q,m.startY+Z),e.beginPath(),e.rect(0,0,y-q-ce,f-Z-te),e.clip(),e.translateWithPrecision(0,S),e.save(),e.translateWithPrecision(ve,0),e.beginPath(),e.rect(0,0,Q,$),e.clip(),L.Text.drawWith(e,{text:k,fontStyle:B,width:Q,height:$,color:(K=s==null?void 0:s.cl)==null?void 0:K.rgb,strokeLine:!!((z=s==null?void 0:s.st)!=null&&z.s),underline:!!((ee=s==null?void 0:s.ul)!=null&&ee.s),warp:O===o.WrapStrategy.WRAP,hAlign:o.HorizontalAlign.LEFT},J),e.translateWithPrecision(F,0),e.restore(),e.restore(),D.set(R,{left:m.endX+q+a.rowHeaderWidth-de,top:m.startY+Z+a.columnHeaderHeight,width:de,height:f-Z-te})}else{e.save(),e.translateWithPrecision(m.startX,m.startY),e.beginPath(),e.rect(0,0,y,f),e.clip();const q=y-ue*2-ve-de-4,Z=new L.DocSimpleSkeleton(k,B,O===o.WrapStrategy.WRAP,q,1/0);Z.calculate();const ce=Z.getTotalWidth(),te=Z.getTotalHeight(),Q=te+mt*2,J=Math.max(y-ue*2,1),{paddingTop:P,paddingLeft:$}=St(J,f,ce,Q,x,j);e.translateWithPrecision(ue,P),L.Rect.drawWith(e,{width:J,height:Q,fill:(W==null?void 0:W.color)||Re,radius:qe}),e.save(),e.translateWithPrecision(ve,mt),e.beginPath(),e.rect(0,0,q,te),e.clip(),e.translateWithPrecision($,0),L.Text.drawWith(e,{text:k,fontStyle:B,width:q,height:te,color:(ae=s==null?void 0:s.cl)==null?void 0:ae.rgb,strokeLine:!!((re=s==null?void 0:s.st)!=null&&re.s),underline:!!((se=s==null?void 0:s.ul)!=null&&se.s),warp:O===o.WrapStrategy.WRAP,hAlign:o.HorizontalAlign.LEFT},Z),e.restore(),e.translateWithPrecision(q+ve+4,(te-je)/2),e.fillStyle=qn,e.fill(ft),e.restore(),D.set(R,{left:m.startX+ue+a.rowHeaderWidth,top:m.startY+P+a.columnHeaderHeight,width:J,height:Q})}}calcCellAutoHeight(e){const{primaryWithCoord:t,style:a,data:n,row:r,col:i}=e,s=t.isMergedMainCell?t.mergeInfo:t,d=n==null?void 0:n.fontRenderExtension,{leftOffset:l=0,rightOffset:c=0,topOffset:h=0,downOffset:g=0}=d||{},u=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,r,i);if(!u||u.renderMode===o.DataValidationRenderMode.TEXT)return;const I={startX:s.startX+l,endX:s.endX-c,startY:s.startY+h,endY:s.endY-g},v=I.endX-I.startX,T=_.getCellValueOrigin(n),M=`${T!=null?T:""}`;let{tb:m,pd:y}=a||{};const{t:f=o.DEFAULT_STYLES.pd.t,b:D=o.DEFAULT_STYLES.pd.b}=y!=null?y:{};if(m=m!=null?m:o.WrapStrategy.WRAP,u.renderMode===o.DataValidationRenderMode.ARROW){const R=v-de,C=new L.DocSimpleSkeleton(M,L.getFontStyleString(a).fontCache,m===o.WrapStrategy.WRAP,R,1/0);return C.calculate(),C.getTotalHeight()+f+D+De*2}else{const R=Math.max(v-ue*2-ve-de,10),C=new L.DocSimpleSkeleton(M,L.getFontStyleString(a).fontCache,m===o.WrapStrategy.WRAP,R,1/0);return C.calculate(),C.getTotalHeight()+De*2+2}}calcCellAutoWidth(e){const{primaryWithCoord:t,style:a,data:n,row:r,col:i}=e,s=t.isMergedMainCell?t.mergeInfo:t,d=n==null?void 0:n.fontRenderExtension,{leftOffset:l=0,rightOffset:c=0,topOffset:h=0,downOffset:g=0}=d||{},u=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,r,i);if(!u||u.renderMode===o.DataValidationRenderMode.TEXT)return;const I={startX:s.startX+l,endX:s.endX-c,startY:s.startY+h,endY:s.endY-g},v=I.endX-I.startX,T=_.getCellValueOrigin(n),M=`${T!=null?T:""}`;let{tb:m,pd:y}=a||{};const{l:f=o.DEFAULT_STYLES.pd.l,r:D=o.DEFAULT_STYLES.pd.r}=y!=null?y:{};m=m!=null?m:o.WrapStrategy.WRAP;let R=ue*2+de;switch(u.renderMode){case o.DataValidationRenderMode.ARROW:R=de+ue*2+D+f;break;case o.DataValidationRenderMode.CUSTOM:R=de+ue*2+ve*2+D+f+qe/2+1;break;default:R=de+ue*2+ve*2+D+f+qe/2+1}const C=v-R,w=new L.DocSimpleSkeleton(M,L.getFontStyleString(a).fontCache,m===o.WrapStrategy.WRAP,C,1/0);return w.calculate(),w.getTotalWidth()+R}isHit(e,t){const{subUnitId:a,row:n,col:r}=t,s=this._ensureMap(a).get(this._generateKey(n,r)),d=this._dataValidationModel.getRuleByLocation(t.unitId,t.subUnitId,n,r);if(!d||!s||d.renderMode===o.DataValidationRenderMode.TEXT)return!1;const{top:l,left:c,width:h,height:g}=s,{x:u,y:I}=e;return u>=c&&u<=c+h&&I>=l&&I<=l+g}onPointerDown(e,t){if(t.button===2)return;const{unitId:a,subUnitId:n,row:r,col:i}=e,s={unitId:a,subUnitId:n,row:r,column:i};this._commandService.executeCommand(He.id,s)}onPointerEnter(e,t){var a,n;(n=(a=L.getCurrentTypeOfRenderer(o.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null?void 0:a.mainComponent)==null||n.setCursor(L.CURSOR_TYPE.POINTER)}onPointerLeave(e,t){var a,n;(n=(a=L.getCurrentTypeOfRenderer(o.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null?void 0:a.mainComponent)==null||n.setCursor(L.CURSOR_TYPE.DEFAULT)}};it=Gn([Oe(0,o.IUniverInstanceService),Oe(1,o.Inject(o.LocaleService)),Oe(2,o.ICommandService),Oe(3,o.Inject(L.IRenderManagerService)),Oe(4,o.Inject(_.SheetDataValidationModel))],it);class Jn extends exports.BaseSheetDataValidatorView{constructor(){super(...arguments);A(this,"id",o.DataValidationType.LIST);A(this,"canvasRender",this.injector.createInstance(it));A(this,"dropdownType",Y.DataValidatorDropdownType.LIST);A(this,"optionsInput",Ne.componentKey);A(this,"formulaInput",_.LIST_FORMULA_INPUT_NAME)}}class Qn extends exports.BaseSheetDataValidatorView{constructor(){super(...arguments);A(this,"id",o.DataValidationType.TEXT_LENGTH);A(this,"formulaInput",_.BASE_FORMULA_INPUT_NAME)}}class ea extends exports.BaseSheetDataValidatorView{constructor(){super(...arguments);A(this,"id",o.DataValidationType.WHOLE);A(this,"formulaInput",_.BASE_FORMULA_INPUT_NAME)}}var ta=Object.getOwnPropertyDescriptor,na=(e,t,a,n)=>{for(var r=n>1?void 0:n?ta(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},Je=(e,t)=>(a,n)=>t(a,n,e);let Te=class extends o.RxDisposable{constructor(e,t,a){super(),this._injector=e,this._componentManger=t,this._dataValidatorRegistryService=a,this._initComponents(),this._registerValidatorViews()}_initComponents(){[["DataValidationIcon",wt],[Fe,Cn],[Ne.componentKey,Ne],[Be.componentKey,Be],...Mn].forEach(([e,t])=>{this.disposeWithMe(this._componentManger.register(e,t))})}_registerValidatorViews(){[Nn,ea,Qn,kn,xn,Jn,Kn,Un].forEach(e=>{const t=this._injector.createInstance(e),a=this._dataValidatorRegistryService.getValidatorItem(t.id);a&&(a.formulaInput=t.formulaInput,a.canvasRender=t.canvasRender,a.dropdownType=t.dropdownType,a.optionsInput=t.optionsInput)})}};Te=na([Je(0,o.Inject(o.Injector)),Je(1,o.Inject(E.ComponentManager)),Je(2,o.Inject(Y.DataValidatorRegistryService))],Te);var aa=Object.getOwnPropertyDescriptor,ra=(e,t,a,n)=>{for(var r=n>1?void 0:n?aa(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},Qe=(e,t)=>(a,n)=>t(a,n,e);const ia="SHEET_DATA_VALIDATION_UI_PLUGIN";var xe;exports.UniverSheetsDataValidationMobileUIPlugin=(xe=class extends o.Plugin{constructor(t=Ue,a,n,r){super(),this._config=t,this._injector=a,this._commandService=n,this._configService=r;const{menu:i,...s}=o.merge({},Ue,this._config);i&&this._configService.setConfig("menu",i,{merge:!0}),this._configService.setConfig(st,s)}onStarting(){[[he],[fe],[Pe],[Ve],[be],[Me],[Ee],[Te]].forEach(t=>{this._injector.add(t)}),[$e,He,It,lt,Se,_t].forEach(t=>{this._commandService.registerCommand(t)})}onReady(){this._injector.get(Ee),this._injector.get(Me),this._injector.get(L.IRenderManagerService).registerRenderModule(o.UniverInstanceType.UNIVER_SHEET,[ke])}onRendered(){this._injector.get(Te),this._injector.get(be)}onSteady(){this._injector.get(Ve)}},A(xe,"pluginName",ia),A(xe,"type",o.UniverInstanceType.UNIVER_SHEET),xe);exports.UniverSheetsDataValidationMobileUIPlugin=ra([Qe(1,o.Inject(o.Injector)),Qe(2,o.ICommandService),Qe(3,o.IConfigService)],exports.UniverSheetsDataValidationMobileUIPlugin);var oa=Object.defineProperty,sa=Object.getOwnPropertyDescriptor,la=(e,t,a)=>t in e?oa(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a,da=(e,t,a,n)=>{for(var r=n>1?void 0:n?sa(t,a):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},et=(e,t)=>(a,n)=>t(a,n,e),Ot=(e,t,a)=>la(e,typeof t!="symbol"?t+"":t,a);const ca="SHEET_DATA_VALIDATION_UI_PLUGIN";exports.UniverSheetsDataValidationUIPlugin=class extends o.Plugin{constructor(t=Ue,a,n,r){super(),this._config=t,this._injector=a,this._commandService=n,this._configService=r;const{menu:i,...s}=o.merge({},Ue,this._config);i&&this._configService.setConfig("menu",i,{merge:!0}),this._configService.setConfig(st,s)}onStarting(){[[he],[fe],[Pe],[Ve],[be],[Me],[Ee],[we],[Te]].forEach(t=>{this._injector.add(t)}),[$e,He,It,lt,Se,_t].forEach(t=>{this._commandService.registerCommand(t)})}onReady(){this._injector.get(Ee),this._injector.get(Me),this._injector.get(we),this._injector.get(Pe),this._injector.get(L.IRenderManagerService).registerRenderModule(o.UniverInstanceType.UNIVER_SHEET,[ke])}onRendered(){this._injector.get(Te),this._injector.get(be)}onSteady(){this._injector.get(Ve)}};Ot(exports.UniverSheetsDataValidationUIPlugin,"pluginName",ca);Ot(exports.UniverSheetsDataValidationUIPlugin,"type",o.UniverInstanceType.UNIVER_SHEET);exports.UniverSheetsDataValidationUIPlugin=da([o.DependentOn(_.UniverSheetsDataValidationPlugin),et(1,o.Inject(o.Injector)),et(2,o.ICommandService),et(3,o.IConfigService)],exports.UniverSheetsDataValidationUIPlugin);
package/lib/es/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  var Tr = Object.defineProperty;
2
2
  var Pr = (e, t, r) => t in e ? Tr(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
3
3
  var V = (e, t, r) => Pr(e, typeof t != "symbol" ? t + "" : t, r);
4
- import { Disposable as ye, UniverInstanceType as X, toDisposable as Ar, IUniverInstanceService as ce, Inject as M, LocaleService as ue, DataValidationErrorStyle as lt, DataValidationStatus as Ze, ICommandService as te, Injector as be, IConfigService as sn, DataValidationRenderMode as se, DisposableCollection as Lr, dayjs as In, numfmt as $n, CellValueType as kr, CommandType as rt, DataValidationType as j, ObjectMatrix as It, Range as Nr, Rectangle as Rt, queryObjectMatrix as Kt, Optional as Ur, RxDisposable as ln, InterceptorEffectEnum as jn, sequenceExecute as Yn, bufferDebounceTime as Fr, debounce as xr, UndoCommand as Br, RedoCommand as Wr, isUnitRangesEqual as Hr, shallowEqual as Rn, ThemeService as Xn, ColorKit as $r, isFormulaString as Oe, Tools as yn, VerticalAlign as de, HorizontalAlign as Re, DEFAULT_STYLES as ae, WrapStrategy as me, Plugin as Zn, merge as Kn, DependentOn as jr } from "@univerjs/core";
4
+ import { Disposable as ye, UniverInstanceType as X, toDisposable as Ar, IUniverInstanceService as ce, Inject as M, LocaleService as ue, DataValidationErrorStyle as lt, DataValidationStatus as Ze, ICommandService as te, Injector as be, IConfigService as sn, DataValidationRenderMode as se, DisposableCollection as Lr, dayjs as In, numfmt as $n, CellValueType as kr, CommandType as rt, DataValidationType as j, ObjectMatrix as It, Range as Nr, Rectangle as Rt, queryObjectMatrix as Kt, Optional as Ur, RxDisposable as ln, InterceptorEffectEnum as jn, sequenceExecute as Yn, bufferDebounceTime as Fr, debounce as xr, UndoCommand as Br, RedoCommand as Wr, isUnitRangesEqual as Hr, shallowEqual as Rn, ThemeService as Xn, ColorKit as $r, isFormulaString as Oe, generateRandomId as yn, VerticalAlign as de, HorizontalAlign as Re, DEFAULT_STYLES as ae, WrapStrategy as me, Plugin as Zn, merge as Kn, DependentOn as jr } from "@univerjs/core";
5
5
  import { DeviceInputEventType as gt, IRenderManagerService as Fe, fixLineWidthByScale as bn, Transform as Yr, CheckboxShape as Xr, getCurrentTypeOfRenderer as Ke, CURSOR_TYPE as ze, FontCache as Zr, Shape as Kr, Rect as zn, getFontStyleString as Te, DocSimpleSkeleton as it, Text as Mn } from "@univerjs/engine-render";
6
6
  import { SheetInterceptorService as dn, VALIDATE_CELL as zr, SheetsSelectionsService as Gn, SetRangeValuesCommand as st, getSheetCommandTarget as qn, rangeToDiscreteRange as Gr, SheetPermissionCheckController as qr, WorksheetEditPermission as zt, WorksheetSetCellStylePermission as Gt, RangeProtectionPermissionEditPoint as qt, WorkbookEditablePermission as Jt, INTERCEPTOR_POINT as Jn, InterceptCellContentPriority as Qn, checkRangesEditablePermission as Jr } from "@univerjs/sheets";
7
7
  import { SheetDataValidationModel as ie, SheetsDataValidationValidatorService as Qr, getDataValidationCellValue as Nt, getCellValueOrigin as re, serializeListOptions as er, createDefaultNewRule as tr, AddSheetDataValidationCommand as cn, DATA_VALIDATION_PLUGIN_NAME as nr, getDataValidationDiffMutations as Qt, UpdateSheetDataValidationRangeCommand as rr, DataValidationCacheService as ir, UpdateSheetDataValidationSettingCommand as En, UpdateSheetDataValidationOptionsCommand as ei, RemoveSheetDataValidationCommand as or, RemoveSheetAllDataValidationCommand as ti, DataValidationFormulaController as ni, deserializeListOptions as ri, CUSTOM_FORMULA_INPUT_NAME as ar, BASE_FORMULA_INPUT_NAME as Pt, LIST_FORMULA_INPUT_NAME as un, CHECKBOX_FORMULA_INPUT_NAME as sr, DataValidationFormulaService as ii, CHECKBOX_FORMULA_2 as oi, CHECKBOX_FORMULA_1 as ai, getFormulaResult as Ut, isLegalFormulaResult as Dn, transformCheckboxValue as si, UniverSheetsDataValidationPlugin as li } from "@univerjs/sheets-data-validation";
@@ -245,12 +245,7 @@ let Ue = class extends ye {
245
245
  workbook: l,
246
246
  interceptValue: R.replace("Z", "").replace("T", " "),
247
247
  t: kr.NUMBER
248
- }, d) ? (await this._commandService.executeCommand(ft.id, {
249
- visible: !1,
250
- eventType: gt.Keyboard,
251
- unitId: o,
252
- keycode: vt.ESC
253
- }), await this._commandService.executeCommand(st.id, {
248
+ }, d) ? (await this._commandService.executeCommand(st.id, {
254
249
  unitId: o,
255
250
  subUnitId: a,
256
251
  range: {
@@ -271,6 +266,11 @@ let Ue = class extends ye {
271
266
  }
272
267
  }
273
268
  }
269
+ }), await this._commandService.executeCommand(ft.id, {
270
+ visible: !1,
271
+ eventType: gt.Keyboard,
272
+ unitId: o,
273
+ keycode: vt.ESC
274
274
  }), !0) : (this._injector.has(qe) && this._injector.get(qe).showReject(u.getRuleFinalError(d, { row: n, col: i, unitId: o, subUnitId: a })), !1);
275
275
  };
276
276
  let m;
@@ -334,12 +334,12 @@ let Ue = class extends ye {
334
334
  si: null
335
335
  }
336
336
  };
337
- return this._editorBridgeService.isVisible().visible && await this._commandService.executeCommand(ft.id, {
337
+ return this._commandService.executeCommand(st.id, O), this._editorBridgeService.isVisible().visible && await this._commandService.executeCommand(ft.id, {
338
338
  visible: !1,
339
339
  eventType: gt.Keyboard,
340
340
  unitId: o,
341
341
  keycode: vt.ESC
342
- }), this._commandService.executeCommand(st.id, O), !v;
342
+ }), !v;
343
343
  }, w = (d == null ? void 0 : d.renderMode) === se.CUSTOM || (d == null ? void 0 : d.renderMode) === void 0, _ = u.getListWithColor(d, o, a), R = Nt(s.getCellRaw(n, i)), L = () => {
344
344
  this._commandService.executeCommand(Be.id, {
345
345
  ruleId: d.uid
@@ -384,12 +384,12 @@ let Ue = class extends ye {
384
384
  si: null
385
385
  }
386
386
  };
387
- return this._editorBridgeService.isVisible().visible && this._commandService.syncExecuteCommand(ft.id, {
387
+ return this._commandService.syncExecuteCommand(st.id, w), this._editorBridgeService.isVisible().visible && this._commandService.syncExecuteCommand(ft.id, {
388
388
  visible: !1,
389
389
  eventType: gt.Keyboard,
390
390
  unitId: o,
391
391
  keycode: vt.ESC
392
- }), this._commandService.syncExecuteCommand(st.id, w), !0;
392
+ }), !0;
393
393
  },
394
394
  defaultValue: Nt(s.getCellRaw(n, i)).split("/"),
395
395
  options: JSON.parse((C = d.formula1) != null ? C : "[]")
@@ -419,12 +419,12 @@ let Ue = class extends ye {
419
419
  si: null
420
420
  }
421
421
  };
422
- return this._editorBridgeService.isVisible().visible && this._commandService.syncExecuteCommand(ft.id, {
422
+ return this._commandService.syncExecuteCommand(st.id, w), this._editorBridgeService.isVisible().visible && this._commandService.syncExecuteCommand(ft.id, {
423
423
  visible: !1,
424
424
  eventType: gt.Keyboard,
425
425
  unitId: o,
426
426
  keycode: vt.ESC
427
- }), this._commandService.syncExecuteCommand(st.id, w), !0;
427
+ }), !0;
428
428
  },
429
429
  defaultValue: Nt(s.getCellRaw(n, i))
430
430
  },
@@ -1985,7 +1985,7 @@ function Ro(e) {
1985
1985
  label: f,
1986
1986
  color: U[A] || Ye,
1987
1987
  isRef: !1,
1988
- id: yn.generateRandomId(4)
1988
+ id: yn(4)
1989
1989
  }));
1990
1990
  }), J = (D, U, f) => {
1991
1991
  const A = H.find((x) => x.id === D);
@@ -2011,7 +2011,7 @@ function Ro(e) {
2011
2011
  label: "",
2012
2012
  color: Ye,
2013
2013
  isRef: !1,
2014
- id: yn.generateRandomId(4)
2014
+ id: yn(4)
2015
2015
  }
2016
2016
  ]);
2017
2017
  };
package/lib/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  var Tr = Object.defineProperty;
2
2
  var Pr = (e, t, r) => t in e ? Tr(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
3
3
  var V = (e, t, r) => Pr(e, typeof t != "symbol" ? t + "" : t, r);
4
- import { Disposable as ye, UniverInstanceType as X, toDisposable as Ar, IUniverInstanceService as ce, Inject as M, LocaleService as ue, DataValidationErrorStyle as lt, DataValidationStatus as Ze, ICommandService as te, Injector as be, IConfigService as sn, DataValidationRenderMode as se, DisposableCollection as Lr, dayjs as In, numfmt as $n, CellValueType as kr, CommandType as rt, DataValidationType as j, ObjectMatrix as It, Range as Nr, Rectangle as Rt, queryObjectMatrix as Kt, Optional as Ur, RxDisposable as ln, InterceptorEffectEnum as jn, sequenceExecute as Yn, bufferDebounceTime as Fr, debounce as xr, UndoCommand as Br, RedoCommand as Wr, isUnitRangesEqual as Hr, shallowEqual as Rn, ThemeService as Xn, ColorKit as $r, isFormulaString as Oe, Tools as yn, VerticalAlign as de, HorizontalAlign as Re, DEFAULT_STYLES as ae, WrapStrategy as me, Plugin as Zn, merge as Kn, DependentOn as jr } from "@univerjs/core";
4
+ import { Disposable as ye, UniverInstanceType as X, toDisposable as Ar, IUniverInstanceService as ce, Inject as M, LocaleService as ue, DataValidationErrorStyle as lt, DataValidationStatus as Ze, ICommandService as te, Injector as be, IConfigService as sn, DataValidationRenderMode as se, DisposableCollection as Lr, dayjs as In, numfmt as $n, CellValueType as kr, CommandType as rt, DataValidationType as j, ObjectMatrix as It, Range as Nr, Rectangle as Rt, queryObjectMatrix as Kt, Optional as Ur, RxDisposable as ln, InterceptorEffectEnum as jn, sequenceExecute as Yn, bufferDebounceTime as Fr, debounce as xr, UndoCommand as Br, RedoCommand as Wr, isUnitRangesEqual as Hr, shallowEqual as Rn, ThemeService as Xn, ColorKit as $r, isFormulaString as Oe, generateRandomId as yn, VerticalAlign as de, HorizontalAlign as Re, DEFAULT_STYLES as ae, WrapStrategy as me, Plugin as Zn, merge as Kn, DependentOn as jr } from "@univerjs/core";
5
5
  import { DeviceInputEventType as gt, IRenderManagerService as Fe, fixLineWidthByScale as bn, Transform as Yr, CheckboxShape as Xr, getCurrentTypeOfRenderer as Ke, CURSOR_TYPE as ze, FontCache as Zr, Shape as Kr, Rect as zn, getFontStyleString as Te, DocSimpleSkeleton as it, Text as Mn } from "@univerjs/engine-render";
6
6
  import { SheetInterceptorService as dn, VALIDATE_CELL as zr, SheetsSelectionsService as Gn, SetRangeValuesCommand as st, getSheetCommandTarget as qn, rangeToDiscreteRange as Gr, SheetPermissionCheckController as qr, WorksheetEditPermission as zt, WorksheetSetCellStylePermission as Gt, RangeProtectionPermissionEditPoint as qt, WorkbookEditablePermission as Jt, INTERCEPTOR_POINT as Jn, InterceptCellContentPriority as Qn, checkRangesEditablePermission as Jr } from "@univerjs/sheets";
7
7
  import { SheetDataValidationModel as ie, SheetsDataValidationValidatorService as Qr, getDataValidationCellValue as Nt, getCellValueOrigin as re, serializeListOptions as er, createDefaultNewRule as tr, AddSheetDataValidationCommand as cn, DATA_VALIDATION_PLUGIN_NAME as nr, getDataValidationDiffMutations as Qt, UpdateSheetDataValidationRangeCommand as rr, DataValidationCacheService as ir, UpdateSheetDataValidationSettingCommand as En, UpdateSheetDataValidationOptionsCommand as ei, RemoveSheetDataValidationCommand as or, RemoveSheetAllDataValidationCommand as ti, DataValidationFormulaController as ni, deserializeListOptions as ri, CUSTOM_FORMULA_INPUT_NAME as ar, BASE_FORMULA_INPUT_NAME as Pt, LIST_FORMULA_INPUT_NAME as un, CHECKBOX_FORMULA_INPUT_NAME as sr, DataValidationFormulaService as ii, CHECKBOX_FORMULA_2 as oi, CHECKBOX_FORMULA_1 as ai, getFormulaResult as Ut, isLegalFormulaResult as Dn, transformCheckboxValue as si, UniverSheetsDataValidationPlugin as li } from "@univerjs/sheets-data-validation";
@@ -245,12 +245,7 @@ let Ue = class extends ye {
245
245
  workbook: l,
246
246
  interceptValue: R.replace("Z", "").replace("T", " "),
247
247
  t: kr.NUMBER
248
- }, d) ? (await this._commandService.executeCommand(ft.id, {
249
- visible: !1,
250
- eventType: gt.Keyboard,
251
- unitId: o,
252
- keycode: vt.ESC
253
- }), await this._commandService.executeCommand(st.id, {
248
+ }, d) ? (await this._commandService.executeCommand(st.id, {
254
249
  unitId: o,
255
250
  subUnitId: a,
256
251
  range: {
@@ -271,6 +266,11 @@ let Ue = class extends ye {
271
266
  }
272
267
  }
273
268
  }
269
+ }), await this._commandService.executeCommand(ft.id, {
270
+ visible: !1,
271
+ eventType: gt.Keyboard,
272
+ unitId: o,
273
+ keycode: vt.ESC
274
274
  }), !0) : (this._injector.has(qe) && this._injector.get(qe).showReject(u.getRuleFinalError(d, { row: n, col: i, unitId: o, subUnitId: a })), !1);
275
275
  };
276
276
  let m;
@@ -334,12 +334,12 @@ let Ue = class extends ye {
334
334
  si: null
335
335
  }
336
336
  };
337
- return this._editorBridgeService.isVisible().visible && await this._commandService.executeCommand(ft.id, {
337
+ return this._commandService.executeCommand(st.id, O), this._editorBridgeService.isVisible().visible && await this._commandService.executeCommand(ft.id, {
338
338
  visible: !1,
339
339
  eventType: gt.Keyboard,
340
340
  unitId: o,
341
341
  keycode: vt.ESC
342
- }), this._commandService.executeCommand(st.id, O), !v;
342
+ }), !v;
343
343
  }, w = (d == null ? void 0 : d.renderMode) === se.CUSTOM || (d == null ? void 0 : d.renderMode) === void 0, _ = u.getListWithColor(d, o, a), R = Nt(s.getCellRaw(n, i)), L = () => {
344
344
  this._commandService.executeCommand(Be.id, {
345
345
  ruleId: d.uid
@@ -384,12 +384,12 @@ let Ue = class extends ye {
384
384
  si: null
385
385
  }
386
386
  };
387
- return this._editorBridgeService.isVisible().visible && this._commandService.syncExecuteCommand(ft.id, {
387
+ return this._commandService.syncExecuteCommand(st.id, w), this._editorBridgeService.isVisible().visible && this._commandService.syncExecuteCommand(ft.id, {
388
388
  visible: !1,
389
389
  eventType: gt.Keyboard,
390
390
  unitId: o,
391
391
  keycode: vt.ESC
392
- }), this._commandService.syncExecuteCommand(st.id, w), !0;
392
+ }), !0;
393
393
  },
394
394
  defaultValue: Nt(s.getCellRaw(n, i)).split("/"),
395
395
  options: JSON.parse((C = d.formula1) != null ? C : "[]")
@@ -419,12 +419,12 @@ let Ue = class extends ye {
419
419
  si: null
420
420
  }
421
421
  };
422
- return this._editorBridgeService.isVisible().visible && this._commandService.syncExecuteCommand(ft.id, {
422
+ return this._commandService.syncExecuteCommand(st.id, w), this._editorBridgeService.isVisible().visible && this._commandService.syncExecuteCommand(ft.id, {
423
423
  visible: !1,
424
424
  eventType: gt.Keyboard,
425
425
  unitId: o,
426
426
  keycode: vt.ESC
427
- }), this._commandService.syncExecuteCommand(st.id, w), !0;
427
+ }), !0;
428
428
  },
429
429
  defaultValue: Nt(s.getCellRaw(n, i))
430
430
  },
@@ -1985,7 +1985,7 @@ function Ro(e) {
1985
1985
  label: f,
1986
1986
  color: U[A] || Ye,
1987
1987
  isRef: !1,
1988
- id: yn.generateRandomId(4)
1988
+ id: yn(4)
1989
1989
  }));
1990
1990
  }), J = (D, U, f) => {
1991
1991
  const A = H.find((x) => x.id === D);
@@ -2011,7 +2011,7 @@ function Ro(e) {
2011
2011
  label: "",
2012
2012
  color: Ye,
2013
2013
  isRef: !1,
2014
- id: yn.generateRandomId(4)
2014
+ id: yn(4)
2015
2015
  }
2016
2016
  ]);
2017
2017
  };
package/lib/umd/index.js CHANGED
@@ -1,5 +1,5 @@
1
- (function(U,o){typeof exports=="object"&&typeof module<"u"?o(exports,require("@univerjs/core"),require("@univerjs/engine-render"),require("@univerjs/sheets"),require("@univerjs/sheets-data-validation"),require("@univerjs/data-validation"),require("@univerjs/ui"),require("rxjs"),require("@univerjs/sheets-numfmt"),require("@univerjs/sheets-ui"),require("@univerjs/design"),require("react"),require("react/jsx-runtime"),require("@univerjs/engine-formula"),require("@univerjs/sheets-formula-ui")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/engine-render","@univerjs/sheets","@univerjs/sheets-data-validation","@univerjs/data-validation","@univerjs/ui","rxjs","@univerjs/sheets-numfmt","@univerjs/sheets-ui","@univerjs/design","react","react/jsx-runtime","@univerjs/engine-formula","@univerjs/sheets-formula-ui"],o):(U=typeof globalThis<"u"?globalThis:U||self,o(U.UniverSheetsDataValidationUi={},U.UniverCore,U.UniverEngineRender,U.UniverSheets,U.UniverSheetsDataValidation,U.UniverDataValidation,U.UniverUi,U.rxjs,U.UniverSheetsNumfmt,U.UniverSheetsUi,U.UniverDesign,U.React,U.React,U.UniverEngineFormula,U.UniverSheetsFormulaUi))})(this,function(U,o,R,$,m,X,b,ie,At,B,M,V,v,Xe,ze){"use strict";var cr=Object.defineProperty;var ur=(U,o,R)=>o in U?cr(U,o,{enumerable:!0,configurable:!0,writable:!0,value:R}):U[o]=R;var L=(U,o,R)=>ur(U,typeof o!="symbol"?o+"":o,R);var Ye;var Lt=Object.getOwnPropertyDescriptor,Ut=(e,t,r,n)=>{for(var a=n>1?void 0:n?Lt(t,r):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(a=s(a)||a);return a},ht=(e,t)=>(r,n)=>t(r,n,e);let ue=class extends o.Disposable{constructor(t,r){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);this._univerInstanceService=t,this._sidebarService=r,this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(o.UniverInstanceType.UNIVER_SHEET).pipe(ie.filter(n=>!n)).subscribe(()=>{this.close()})),this.disposeWithMe(this._sidebarService.sidebarOptions$.subscribe(n=>{n.id===Ue&&(n.visible||setTimeout(()=>{this._sidebarService.sidebarOptions$.next({visible:!1})}))}))}get activeRule(){return this._activeRule}get isOpen(){return this._open$.getValue()}dispose(){var t;super.dispose(),this._open$.next(!1),this._open$.complete(),this._activeRule$.complete(),(t=this._closeDisposable)==null||t.dispose()}open(){this._open$.next(!0)}close(){var t;this._open$.next(!1),(t=this._closeDisposable)==null||t.dispose()}setCloseDisposable(t){this._closeDisposable=o.toDisposable(()=>{t.dispose(),this._closeDisposable=null})}setActiveRule(t){this._activeRule=t,this._activeRule$.next(t)}};ue=Ut([ht(0,o.IUniverInstanceService),ht(1,b.ISidebarService)],ue);const Ke="sheets-data-validation-ui.config",Le={};var kt=Object.getOwnPropertyDescriptor,Ft=(e,t,r,n)=>{for(var a=n>1?void 0:n?kt(t,r):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(a=s(a)||a);return a},Ce=(e,t)=>(r,n)=>t(r,n,e);let ye=class extends o.Disposable{constructor(e,t,r,n,a,i){super(),this._sheetInterceptorService=e,this._dataValidationModel=t,this._dataValidatorRegistryService=r,this._dialogService=n,this._localeService=a,this._sheetsDataValidationValidatorService=i,this._initEditorBridgeInterceptor()}_initEditorBridgeInterceptor(){this._sheetInterceptorService.writeCellInterceptor.intercept($.VALIDATE_CELL,{handler:async(e,t,r)=>{const n=await e,{row:a,col:i,unitId:s,subUnitId:d}=t,l=this._dataValidationModel.getRuleIdByLocation(s,d,a,i),c=l?this._dataValidationModel.getRuleById(s,d,l):void 0;if(n===!1)return r(Promise.resolve(!1));if(!c||c.errorStyle!==o.DataValidationErrorStyle.STOP)return r(Promise.resolve(!0));const h=this._dataValidatorRegistryService.getValidatorItem(c.type);return!h||await this._sheetsDataValidationValidatorService.validatorCell(s,d,a,i)===o.DataValidationStatus.VALID?r(Promise.resolve(!0)):(this._dialogService.open({width:368,title:{title:this._localeService.t("dataValidation.alert.title")},id:"reject-input-dialog",children:{title:h.getRuleFinalError(c,{row:a,col:i,unitId:s,subUnitId:d})},footer:{title:V.createElement(M.Button,{variant:"primary",onClick:()=>this._dialogService.close("reject-input-dialog")},this._localeService.t("dataValidation.alert.ok"))},onClose:()=>{this._dialogService.close("reject-input-dialog")}}),r(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:V.createElement(M.Button,{variant:"primary",onClick:()=>this._dialogService.close("reject-input-dialog")},this._localeService.t("dataValidation.alert.ok"))},onClose:()=>{this._dialogService.close("reject-input-dialog")}})}};ye=Ft([Ce(0,o.Inject($.SheetInterceptorService)),Ce(1,o.Inject(m.SheetDataValidationModel)),Ce(2,o.Inject(X.DataValidatorRegistryService)),Ce(3,b.IDialogService),Ce(4,o.Inject(o.LocaleService)),Ce(5,o.Inject(m.SheetsDataValidationValidatorService))],ye);var Nt=Object.getOwnPropertyDescriptor,jt=(e,t,r,n)=>{for(var a=n>1?void 0:n?Nt(t,r):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(a=s(a)||a);return a},le=(e,t)=>(r,n)=>t(r,n,e);const Ze=e=>{if(e==null||typeof e=="boolean")return;if(typeof e=="number"||!Number.isNaN(+e))return o.dayjs(o.numfmt.format("yyyy-MM-dd HH:mm:ss",Number(e)));const t=o.dayjs(e);if(t.isValid())return t};function Bt(e,t){const r=At.getPatternType(t);if(e===r)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 ge=class extends o.Disposable{constructor(t,r,n,a,i,s,d,l,c,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=r,this._zenZoneService=n,this._dataValidationModel=a,this._sheetsSelectionsService=i,this._cellDropdownManagerService=s,this._sheetDataValidationModel=d,this._commandService=l,this._editorBridgeService=c,this._injector=h,this._configService=p,this._init(),this._initSelectionChange(),this.disposeWithMe(()=>{this._activeDropdown$.complete()})}get activeDropdown(){return this._activeDropdown}_init(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(t=>{this._zenVisible=t,t&&this.hideDropdown()}))}_getDropdownByCell(t,r,n,a){const i=t?this._univerInstanceService.getUnit(t,o.UniverInstanceType.UNIVER_SHEET):this._univerInstanceService.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET);if(!i)return;const s=r?i.getSheetBySheetId(r):i.getActiveSheet();if(!s)return;const d=this._dataValidationModel.getRuleByLocation(i.getUnitId(),s.getSheetId(),n,a);if(!d)return;const l=this._dataValidatorRegistryService.getValidatorItem(d.type);return l==null?void 0:l.dropdownType}_initSelectionChange(){this.disposeWithMe(this._sheetsSelectionsService.selectionMoveEnd$.subscribe(t=>{t&&t.every(r=>!(r.primary&&this._getDropdownByCell(r.primary.unitId,r.primary.sheetId,r.primary.actualRow,r.primary.actualColumn)))&&this.hideDropdown()}))}showDropdown(t){var O,T,f,y;const{location:r}=t,{row:n,col:a,unitId:i,subUnitId:s,workbook:d,worksheet:l}=r;if(this._currentPopup&&this._currentPopup.dispose(),this._zenVisible)return;this._activeDropdown=t,this._activeDropdown$.next(this._activeDropdown);const c=this._sheetDataValidationModel.getRuleByLocation(i,s,n,a);if(!c)return;const h=this._dataValidatorRegistryService.getValidatorItem(c.type);if(!(h!=null&&h.dropdownType))return;let p;const u=async(S,D)=>{var k,N,H;if(!S)return!0;const w=S,C=l.getCell(n,a),E=w.format(D==="date"?"YYYY-MM-DD 00:00:00":"YYYY-MM-DD HH:mm:ss"),W=(k=o.numfmt.parseDate(E))==null?void 0:k.v,x=D==="time"?W%1:W,P=d.getStyles().getStyleByCell(C),F=(H=(N=P==null?void 0:P.n)==null?void 0:N.pattern)!=null?H:"";return c.errorStyle!==o.DataValidationErrorStyle.STOP||await h.validator({value:x,unitId:i,subUnitId:s,row:n,column:a,worksheet:l,workbook:d,interceptValue:E.replace("Z","").replace("T"," "),t:o.CellValueType.NUMBER},c)?(await this._commandService.executeCommand(B.SetCellEditVisibleOperation.id,{visible:!1,eventType:R.DeviceInputEventType.Keyboard,unitId:i,keycode:b.KeyCode.ESC}),await this._commandService.executeCommand($.SetRangeValuesCommand.id,{unitId:i,subUnitId:s,range:{startColumn:a,endColumn:a,startRow:n,endRow:n},value:{v:x,t:2,p:null,f:null,si:null,s:{n:{pattern:Bt(D,F)}}}}),!0):(this._injector.has(ye)&&this._injector.get(ye).showReject(h.getRuleFinalError(c,{row:n,col:a,unitId:i,subUnitId:s})),!1)};let I;switch(h.dropdownType){case X.DataValidatorDropdownType.DATE:{const S=m.getCellValueOrigin(l.getCellRaw(n,a)),D=Ze(S),w=!!((O=c.bizInfo)!=null&&O.showTime);I={location:r,type:"datepicker",props:{showTime:w,onChange:C=>u(C,w?"datetime":"date"),defaultValue:D,patternType:"date"}};break}case X.DataValidatorDropdownType.TIME:{const S=m.getCellValueOrigin(l.getCellRaw(n,a)),D=Ze(S);I={location:r,type:"datepicker",props:{onChange:w=>u(w,"time"),defaultValue:D,patternType:"time"}};break}case X.DataValidatorDropdownType.DATETIME:{const S=m.getCellValueOrigin(l.getCellRaw(n,a)),D=Ze(S);I={location:r,type:"datepicker",props:{onChange:w=>u(w,"datetime"),defaultValue:D,patternType:"datetime"}};break}case X.DataValidatorDropdownType.LIST:case X.DataValidatorDropdownType.MULTIPLE_LIST:{const S=h.dropdownType===X.DataValidatorDropdownType.MULTIPLE_LIST,D=async P=>{const F=m.serializeListOptions(P),k={unitId:i,subUnitId:s,range:{startColumn:a,endColumn:a,startRow:n,endRow:n},value:{v:F,p:null,f:null,si:null}};return this._editorBridgeService.isVisible().visible&&await this._commandService.executeCommand(B.SetCellEditVisibleOperation.id,{visible:!1,eventType:R.DeviceInputEventType.Keyboard,unitId:i,keycode:b.KeyCode.ESC}),this._commandService.executeCommand($.SetRangeValuesCommand.id,k),!S},w=(c==null?void 0:c.renderMode)===o.DataValidationRenderMode.CUSTOM||(c==null?void 0:c.renderMode)===void 0,C=h.getListWithColor(c,i,s),E=m.getDataValidationCellValue(l.getCellRaw(n,a)),W=()=>{this._commandService.executeCommand(fe.id,{ruleId:c.uid}),p==null||p.dispose()},x=C.map(P=>({label:P.label,value:P.label,color:w||P.color?P.color:"transparent"}));I={location:r,type:"list",props:{onChange:P=>D(P),options:x,onEdit:W,defaultValue:E,multiple:S,showEdit:(f=(T=this._configService.getConfig(Ke))==null?void 0:T.showEditOnDropdown)!=null?f:!0}};break}case X.DataValidatorDropdownType.CASCADE:{I={type:"cascader",props:{onChange:D=>{const w={unitId:i,subUnitId:s,range:{startColumn:a,endColumn:a,startRow:n,endRow:n},value:{v:D.join("/"),p:null,f:null,si:null}};return this._editorBridgeService.isVisible().visible&&this._commandService.syncExecuteCommand(B.SetCellEditVisibleOperation.id,{visible:!1,eventType:R.DeviceInputEventType.Keyboard,unitId:i,keycode:b.KeyCode.ESC}),this._commandService.syncExecuteCommand($.SetRangeValuesCommand.id,w),!0},defaultValue:m.getDataValidationCellValue(l.getCellRaw(n,a)).split("/"),options:JSON.parse((y=c.formula1)!=null?y:"[]")},location:r};break}case X.DataValidatorDropdownType.COLOR:{I={type:"color",props:{onChange:D=>{const w={unitId:i,subUnitId:s,range:{startColumn:a,endColumn:a,startRow:n,endRow:n},value:{v:D,p:null,f:null,si:null}};return this._editorBridgeService.isVisible().visible&&this._commandService.syncExecuteCommand(B.SetCellEditVisibleOperation.id,{visible:!1,eventType:R.DeviceInputEventType.Keyboard,unitId:i,keycode:b.KeyCode.ESC}),this._commandService.syncExecuteCommand($.SetRangeValuesCommand.id,w),!0},defaultValue:m.getDataValidationCellValue(l.getCellRaw(n,a))},location:r};break}default:throw new Error("[DataValidationDropdownManagerService]: unknown type!")}if(p=this._cellDropdownManagerService.showDropdown({...I,onHide:()=>{this._activeDropdown=null,this._activeDropdown$.next(null)}}),!p)throw new Error("[DataValidationDropdownManagerService]: cannot show dropdown!");const g=new o.DisposableCollection;g.add(p),g.add({dispose:()=>{var S,D;(D=(S=this._activeDropdown)==null?void 0:S.onHide)==null||D.call(S)}}),this._currentPopup=g}hideDropdown(){this._activeDropdown&&(this._currentPopup&&this._currentPopup.dispose(),this._currentPopup=null,this._activeDropdown=null,this._activeDropdown$.next(null))}showDataValidationDropdown(t,r,n,a,i){const s=this._univerInstanceService.getUnit(t,o.UniverInstanceType.UNIVER_SHEET);if(!s)return;const d=s.getSheetBySheetId(r);if(!d)return;const l=this._dataValidationModel.getRuleByLocation(s.getUnitId(),d.getSheetId(),n,a);if(!l)return;const c=this._dataValidatorRegistryService.getValidatorItem(l.type);if(!c||!c.dropdownType){this.hideDropdown();return}this.showDropdown({location:{workbook:s,worksheet:d,row:n,col:a,unitId:t,subUnitId:r},onHide:i})}};ge=jt([le(0,o.IUniverInstanceService),le(1,o.Inject(X.DataValidatorRegistryService)),le(2,b.IZenZoneService),le(3,o.Inject(m.SheetDataValidationModel)),le(4,o.Inject($.SheetsSelectionsService)),le(5,o.Inject(B.ISheetCellDropdownManagerService)),le(6,o.Inject(m.SheetDataValidationModel)),le(7,o.ICommandService),le(8,B.IEditorBridgeService),le(9,o.Inject(o.Injector)),le(10,o.IConfigService)],ge);const Ue="DataValidationPanel",fe={id:"data-validation.operation.open-validation-panel",type:o.CommandType.OPERATION,handler(e,t){if(!t)return!1;const{ruleId:r,isAdd:n}=t,a=e.get(ue),i=e.get(X.DataValidationModel),s=e.get(o.IUniverInstanceService),d=e.get(b.ISidebarService),l=$.getSheetCommandTarget(s);if(!l)return!1;const{unitId:c,subUnitId:h}=l,p=r?i.getRuleById(c,h,r):void 0;a.open(),a.setActiveRule(p&&{unitId:c,subUnitId:h,rule:p});const u=d.open({id:Ue,header:{title:n?"dataValidation.panel.addTitle":"dataValidation.panel.title"},children:{label:Ue},width:312,onClose:()=>a.close()});return a.setCloseDisposable(u),!0}},Ge={id:"data-validation.operation.close-validation-panel",type:o.CommandType.OPERATION,handler(e){return e.get(ue).close(),!0}},vt={id:"data-validation.operation.toggle-validation-panel",type:o.CommandType.OPERATION,handler(e){const t=e.get(o.ICommandService),r=e.get(ue);return r.open(),r.isOpen?t.executeCommand(Ge.id):t.executeCommand(fe.id),!0}},ke={type:o.CommandType.OPERATION,id:"sheet.operation.show-data-validation-dropdown",handler(e,t){if(!t)return!1;const r=e.get(ge),{unitId:n,subUnitId:a,row:i,column:s}=t,d=r.activeDropdown,l=d==null?void 0:d.location;return l&&l.unitId===n&&l.subUnitId===a&&l.row===i&&l.col===s||r.showDataValidationDropdown(n,a,i,s),!0}},pt={type:o.CommandType.OPERATION,id:"sheet.operation.hide-data-validation-dropdown",handler(e,t){return t?(e.get(ge).hideDropdown(),!0):!1}},Fe={type:o.CommandType.COMMAND,id:"data-validation.command.addRuleAndOpen",handler(e){const t=e.get(o.IUniverInstanceService),r=$.getSheetCommandTarget(t);if(!r)return!1;const{workbook:n,worksheet:a}=r,i=m.createDefaultNewRule(e),s=e.get(o.ICommandService),d=n.getUnitId(),l=a.getSheetId(),c={rule:i,unitId:d,subUnitId:l};return s.syncExecuteCommand(m.AddSheetDataValidationCommand.id,c)?(s.syncExecuteCommand(fe.id,{ruleId:i.uid,isAdd:!0}),!0):!1}};var Wt=Object.getOwnPropertyDescriptor,Ht=(e,t,r,n)=>{for(var a=n>1?void 0:n?Wt(t,r):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(a=s(a)||a);return a},we=(e,t)=>(r,n)=>t(r,n,e);const me="SHEET_DATA_VALIDATION_ALERT";let Pe=class extends o.Disposable{constructor(e,t,r,n,a,i){super(),this._hoverManagerService=e,this._cellAlertManagerService=t,this._univerInstanceService=r,this._localeService=n,this._zenZoneService=a,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 r=this._univerInstanceService.getUnit(e.location.unitId,o.UniverInstanceType.UNIVER_SHEET),n=r.getSheetBySheetId(e.location.subUnitId);if(!n)return;const a=this._dataValidationModel.getRuleByLocation(e.location.unitId,e.location.subUnitId,e.location.row,e.location.col);if(!a){this._cellAlertManagerService.removeAlert(me);return}if(this._dataValidationModel.validator(a,{...e.location,workbook:r,worksheet:n})===o.DataValidationStatus.INVALID){const s=this._cellAlertManagerService.currentAlert.get(me),d=(t=s==null?void 0:s.alert)==null?void 0:t.location;if(d&&d.row===e.location.row&&d.col===e.location.col&&d.subUnitId===e.location.subUnitId&&d.unitId===e.location.unitId){this._cellAlertManagerService.removeAlert(me);return}const l=this._dataValidationModel.getValidator(a.type);if(!l){this._cellAlertManagerService.removeAlert(me);return}this._cellAlertManagerService.showAlert({type:B.CellAlertType.ERROR,title:this._localeService.t("dataValidation.error.title"),message:l==null?void 0:l.getRuleFinalError(a,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=Ht([we(0,o.Inject(B.HoverManagerService)),we(1,o.Inject(B.CellAlertManagerService)),we(2,o.IUniverInstanceService),we(3,o.Inject(o.LocaleService)),we(4,b.IZenZoneService),we(5,o.Inject(m.SheetDataValidationModel))],Pe);var xt=Object.getOwnPropertyDescriptor,$t=(e,t,r,n)=>{for(var a=n>1?void 0:n?xt(t,r):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(a=s(a)||a);return a},qe=(e,t)=>(r,n)=>t(r,n,e);let De=class extends o.Disposable{constructor(e,t,r){super(),this._autoFillService=e,this._sheetDataValidationModel=t,this._injector=r,this._initAutoFill()}_initAutoFill(){const e=()=>({redos:[],undos:[]}),t=(n,a)=>{const{source:i,target:s,unitId:d,subUnitId:l}=n,c=this._sheetDataValidationModel.getRuleObjectMatrix(d,l).clone(),h=B.virtualizeDiscreteRanges([i,s]),[p,u]=h.ranges,{mapFunc:I}=h,g={row:p.startRow,col:p.startColumn},O=B.getAutoFillRepeatRange(p,u),T=new o.ObjectMatrix,f=new Set;O.forEach(C=>{const E=C.repeatStartCell,W=C.relativeRange,x={startRow:g.row,startColumn:g.col,endColumn:g.col,endRow:g.row},P={startRow:E.row,startColumn:E.col,endColumn:E.col,endRow:E.row};o.Range.foreach(W,(F,k)=>{const N=o.Rectangle.getPositionRange({startRow:F,startColumn:k,endColumn:k,endRow:F},x),{row:H,col:Z}=I(N.startRow,N.startColumn),K=this._sheetDataValidationModel.getRuleIdByLocation(d,l,H,Z)||"",te=o.Rectangle.getPositionRange({startRow:F,startColumn:k,endColumn:k,endRow:F},P),{row:ae,col:se}=I(te.startRow,te.startColumn);T.setValue(ae,se,K),f.add(K)})});const y=Array.from(f).map(C=>({id:C,ranges:o.queryObjectMatrix(T,E=>E===C)}));c.addRangeRules(y);const S=c.diff(this._sheetDataValidationModel.getRules(d,l)),{redoMutations:D,undoMutations:w}=m.getDataValidationDiffMutations(d,l,S,this._injector,"patched",a===B.APPLY_TYPE.ONLY_FORMAT);return{undos:w,redos:D}},r={id:m.DATA_VALIDATION_PLUGIN_NAME,onBeforeFillData:n=>{const{source:a,unitId:i,subUnitId:s}=n;for(const d of a.rows)for(const l of a.cols){const c=this._sheetDataValidationModel.getRuleByLocation(i,s,d,l);if(c&&c.type===o.DataValidationType.CHECKBOX){this._autoFillService.setDisableApplyType(B.APPLY_TYPE.SERIES,!0);return}}},onFillData:(n,a,i)=>i===B.APPLY_TYPE.COPY||i===B.APPLY_TYPE.ONLY_FORMAT||i===B.APPLY_TYPE.SERIES?t(n,i):e(),onAfterFillData:()=>{}};this.disposeWithMe(this._autoFillService.addHook(r))}};De=$t([qe(0,B.IAutoFillService),qe(1,o.Inject(m.SheetDataValidationModel)),qe(2,o.Inject(o.Injector))],De);var Yt=Object.getOwnPropertyDescriptor,Xt=(e,t,r,n)=>{for(var a=n>1?void 0:n?Yt(t,r):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(a=s(a)||a);return a},Je=(e,t)=>(r,n)=>t(r,n,e);let Ee=class extends o.Disposable{constructor(t,r,n){super();L(this,"_copyInfo");this._sheetClipboardService=t,this._sheetDataValidationModel=r,this._injector=n,this._initCopyPaste()}_initCopyPaste(){this._sheetClipboardService.addClipboardHook({id:m.DATA_VALIDATION_PLUGIN_NAME,onBeforeCopy:(t,r,n)=>this._collect(t,r,n),onPasteCells:(t,r,n,a)=>{const{copyType:i=B.COPY_TYPE.COPY,pasteType:s}=a,{range:d}=t||{},{range:l,unitId:c,subUnitId:h}=r;return this._generateMutations(l,{copyType:i,pasteType:s,copyRange:d,unitId:c,subUnitId:h})}})}_collect(t,r,n){const a=new o.ObjectMatrix;this._copyInfo={unitId:t,subUnitId:r,matrix:a};const i=this._injector.invoke(l=>$.rangeToDiscreteRange(n,l,t,r));if(!i)return;const{rows:s,cols:d}=i;s.forEach((l,c)=>{d.forEach((h,p)=>{const u=this._sheetDataValidationModel.getRuleIdByLocation(t,r,l,h);a.setValue(c,p,u!=null?u:"")})})}_generateMutations(t,r){if(!this._copyInfo)return{redos:[],undos:[]};if(r.copyType===B.COPY_TYPE.CUT)return this._copyInfo=null,{redos:[],undos:[]};if(!this._copyInfo||!this._copyInfo.matrix.getSizeOf()||!r.copyRange)return{redos:[],undos:[]};if([B.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_COL_WIDTH,B.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_VALUE,B.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMAT,B.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMULA].includes(r.pasteType))return{redos:[],undos:[]};const{unitId:a,subUnitId:i}=this._copyInfo;if(r.unitId!==a||i!==r.subUnitId){const s=this._sheetDataValidationModel.getRuleObjectMatrix(r.unitId,r.subUnitId).clone(),d=new o.ObjectMatrix,l=new Set,{ranges:[c,h],mapFunc:p}=B.virtualizeDiscreteRanges([r.copyRange,t]),u=B.getRepeatRange(c,h,!0),I=new Map;u.forEach(({startRange:f})=>{var y;(y=this._copyInfo)==null||y.matrix.forValue((S,D,w)=>{const C=o.Rectangle.getPositionRange({startRow:S,endRow:S,startColumn:D,endColumn:D},f),E=`${i}-${w}`,W=this._sheetDataValidationModel.getRuleById(a,i,w);!this._sheetDataValidationModel.getRuleById(r.unitId,r.subUnitId,E)&&W&&I.set(E,{...W,uid:E});const{row:x,col:P}=p(C.startRow,C.startColumn);l.add(E),d.setValue(x,P,E)})});const g=Array.from(l).map(f=>({id:f,ranges:o.queryObjectMatrix(d,y=>y===f)}));s.addRangeRules(g);const{redoMutations:O,undoMutations:T}=m.getDataValidationDiffMutations(r.unitId,r.subUnitId,s.diffWithAddition(this._sheetDataValidationModel.getRules(r.unitId,r.subUnitId),I.values()),this._injector,"patched",!1);return{redos:O,undos:T}}else{const s=this._sheetDataValidationModel.getRuleObjectMatrix(a,i).clone(),d=new o.ObjectMatrix,l=new Set,{ranges:[c,h],mapFunc:p}=B.virtualizeDiscreteRanges([r.copyRange,t]);B.getRepeatRange(c,h,!0).forEach(({startRange:T})=>{var f;(f=this._copyInfo)==null||f.matrix.forValue((y,S,D)=>{const w=o.Rectangle.getPositionRange({startRow:y,endRow:y,startColumn:S,endColumn:S},T),{row:C,col:E}=p(w.startRow,w.startColumn);d.setValue(C,E,D),l.add(D)})});const I=Array.from(l).map(T=>({id:T,ranges:o.queryObjectMatrix(d,f=>f===T)}));s.addRangeRules(I);const{redoMutations:g,undoMutations:O}=m.getDataValidationDiffMutations(a,i,s.diff(this._sheetDataValidationModel.getRules(a,i)),this._injector,"patched",!1);return{redos:g,undos:O}}}};Ee=Xt([Je(0,B.ISheetClipboardService),Je(1,o.Inject(m.SheetDataValidationModel)),Je(2,o.Inject(o.Injector))],Ee);var zt=Object.getOwnPropertyDescriptor,Kt=(e,t,r,n)=>{for(var a=n>1?void 0:n?zt(t,r):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(a=s(a)||a);return a},Qe=(e,t)=>(r,n)=>t(r,n,e);let Me=class extends o.Disposable{constructor(e,t,r){super(),this._localeService=e,this._commandService=t,this._sheetPermissionCheckController=r,this._commandExecutedListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.beforeCommandExecuted(e=>{e.id===m.AddSheetDataValidationCommand.id&&(this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[$.WorkbookEditablePermission],rangeTypes:[$.RangeProtectionPermissionEditPoint],worksheetTypes:[$.WorksheetEditPermission,$.WorksheetSetCellStylePermission]})||this._sheetPermissionCheckController.blockExecuteWithoutPermission(this._localeService.t("permission.dialog.setStyleErr"))),e.id===m.UpdateSheetDataValidationRangeCommand.id&&(this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[$.WorkbookEditablePermission],rangeTypes:[$.RangeProtectionPermissionEditPoint],worksheetTypes:[$.WorksheetEditPermission,$.WorksheetSetCellStylePermission]},e.params.ranges)||this._sheetPermissionCheckController.blockExecuteWithoutPermission(this._localeService.t("permission.dialog.setStyleErr")))}))}};Me=Kt([Qe(0,o.Inject(o.LocaleService)),Qe(1,o.ICommandService),Qe(2,o.Inject($.SheetPermissionCheckController))],Me);const gt="sheet.menu.data-validation";function Zt(e){return{id:gt,type:b.MenuItemType.SUBITEMS,icon:"DataValidationIcon",tooltip:"dataValidation.title",hidden$:b.getMenuHiddenObservable(e,o.UniverInstanceType.UNIVER_SHEET),disabled$:B.getCurrentRangeDisable$(e,{workbookTypes:[$.WorkbookEditablePermission],worksheetTypes:[$.WorksheetSetCellStylePermission,$.WorksheetEditPermission],rangeTypes:[$.RangeProtectionPermissionEditPoint]})}}function Gt(e){return{id:fe.id,title:"dataValidation.panel.title",type:b.MenuItemType.BUTTON}}function qt(e){return{id:Fe.id,title:"dataValidation.panel.add",type:b.MenuItemType.BUTTON}}const Jt={[b.RibbonDataGroup.RULES]:{[gt]:{order:0,menuItemFactory:Zt,[fe.id]:{order:0,menuItemFactory:Gt},[Fe.id]:{order:1,menuItemFactory:qt}}}};var Qt=Object.getOwnPropertyDescriptor,ft=(e,t,r,n)=>{for(var a=n>1?void 0:n?Qt(t,r):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(a=s(a)||a);return a},G=(e,t)=>(r,n)=>t(r,n,e);const mt={tr:{size:6,color:"#fe4b4b"}};let be=class extends o.RxDisposable{constructor(e,t,r,n,a,i,s,d,l,c,h){super(),this._commandService=e,this._menuManagerService=t,this._renderManagerService=r,this._univerInstanceService=n,this._autoHeightController=a,this._dropdownManagerService=i,this._sheetDataValidationModel=s,this._dataValidatorRegistryService=d,this._sheetInterceptorService=l,this._dataValidationCacheService=c,this._editorBridgeService=h,this._initMenu(),this._initDropdown(),this._initViewModelIntercept(),this._initAutoHeight()}_initMenu(){this._menuManagerService.mergeMenu(Jt)}_initDropdown(){this._editorBridgeService&&this.disposeWithMe(this._editorBridgeService.visible$.subscribe(e=>{var r;if(!e.visible){((r=this._dropdownManagerService.activeDropdown)==null?void 0:r.trigger)==="editor-bridge"&&this._dropdownManagerService.hideDropdown();return}const t=this._editorBridgeService.getEditCellState();if(t){const{unitId:n,sheetId:a,row:i,column:s}=t,d=this._univerInstanceService.getUniverSheetInstance(n);if(!d)return;const l=this._sheetDataValidationModel.getRuleByLocation(n,a,i,s);if(!l)return;const c=this._dataValidatorRegistryService.getValidatorItem(l.type);if(!(c!=null&&c.dropdownType))return;const h=d.getActiveSheet();if(!h)return;const p=this._dropdownManagerService.activeDropdown,u=p==null?void 0:p.location;if(u&&u.unitId===n&&u.subUnitId===a&&u.row===i&&u.col===s)return;this._dropdownManagerService.showDropdown({location:{unitId:n,subUnitId:a,row:i,col:s,workbook:d,worksheet:h},trigger:"editor-bridge",closeOnOutSide:!1})}}))}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept($.INTERCEPTOR_POINT.CELL_CONTENT,{effect:o.InterceptorEffectEnum.Style,priority:$.InterceptCellContentPriority.DATA_VALIDATION,handler:(e,t,r)=>{var f,y,S,D,w;const{row:n,col:a,unitId:i,subUnitId:s,workbook:d,worksheet:l}=t,c=this._sheetDataValidationModel.getRuleIdByLocation(i,s,n,a);if(!c)return r(e);const h=this._sheetDataValidationModel.getRuleById(i,s,c);if(!h)return r(e);const p=(f=this._dataValidationCacheService.getValue(i,s,n,a))!=null?f:o.DataValidationStatus.VALID,u=this._dataValidatorRegistryService.getValidatorItem(h.type),I=t.rawData;let g;const O={get value(){var C;return g!==void 0||(g=(C=m.getCellValueOrigin(I))!=null?C:null),g}},T={get value(){var C;return`${(C=O.value)!=null?C:""}`}};return(!e||e===t.rawData)&&(e={...t.rawData}),e.markers={...e==null?void 0:e.markers,...p===o.DataValidationStatus.INVALID?mt: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:((S=e==null?void 0:e.fontRenderExtension)==null?void 0:S.isSkip)||((D=u==null?void 0:u.skipDefaultFontRender)==null?void 0:D.call(u,h,O.value,t))},e.interceptorStyle={...e==null?void 0:e.interceptorStyle,...u==null?void 0:u.getExtraStyle(h,T.value,{get style(){const C=d.getStyles();return(typeof(e==null?void 0:e.s)=="string"?C.get(e==null?void 0:e.s):e==null?void 0:e.s)||{}}},n,a)},e.interceptorAutoHeight=()=>{var x,P,F,k,N,H;const C=(P=(x=this._renderManagerService.getRenderById(i))==null?void 0:x.with(B.SheetSkeletonManagerService).getSkeletonParam(s))==null?void 0:P.skeleton;if(!C)return;const E=C.worksheet.getMergedCell(n,a),W={data:e,style:C.getStyles().getStyleByCell(e),primaryWithCoord:C.getCellWithCoordByIndex((F=E==null?void 0:E.startRow)!=null?F:n,(k=E==null?void 0:E.startColumn)!=null?k:a),unitId:i,subUnitId:s,row:n,col:a,workbook:d,worksheet:l};return(H=(N=u==null?void 0:u.canvasRender)==null?void 0:N.calcCellAutoHeight)==null?void 0:H.call(N,W)},e.interceptorAutoWidth=()=>{var x,P,F,k,N,H;const C=(P=(x=this._renderManagerService.getRenderById(i))==null?void 0:x.with(B.SheetSkeletonManagerService).getSkeletonParam(s))==null?void 0:P.skeleton;if(!C)return;const E=C.worksheet.getMergedCell(n,a),W={data:e,style:C.getStyles().getStyleByCell(e),primaryWithCoord:C.getCellWithCoordByIndex((F=E==null?void 0:E.startRow)!=null?F:n,(k=E==null?void 0:E.startColumn)!=null?k:a),unitId:i,subUnitId:s,row:n,col:a,workbook:d,worksheet:l};return(H=(N=u==null?void 0:u.canvasRender)==null?void 0:N.calcCellAutoWidth)==null?void 0:H.call(N,W)},e.coverable=((w=e==null?void 0:e.coverable)!=null?w:!0)&&!(h.type===o.DataValidationType.LIST||h.type===o.DataValidationType.LIST_MULTIPLE),r(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(r=>{var n;(r.rule.type===o.DataValidationType.LIST_MULTIPLE||r.rule.type===o.DataValidationType.LIST)&&(n=r.rule)!=null&&n.ranges&&t.push(...r.rule.ranges)}),t.length){const r=this._autoHeightController.getUndoRedoParamsOfAutoHeight(t);o.sequenceExecute(r.redos,this._commandService)}})}};be=ft([G(0,o.ICommandService),G(1,b.IMenuManagerService),G(2,R.IRenderManagerService),G(3,o.IUniverInstanceService),G(4,o.Inject(B.AutoHeightController)),G(5,o.Inject(ge)),G(6,o.Inject(m.SheetDataValidationModel)),G(7,o.Inject(X.DataValidatorRegistryService)),G(8,o.Inject($.SheetInterceptorService)),G(9,o.Inject(m.DataValidationCacheService)),G(10,o.Optional(B.IEditorBridgeService))],be);let St=class extends o.RxDisposable{constructor(e,t,r,n,a,i,s){super(),this._commandService=e,this._renderManagerService=t,this._autoHeightController=r,this._dataValidatorRegistryService=n,this._sheetInterceptorService=a,this._sheetDataValidationModel=i,this._dataValidationCacheService=s,this._initViewModelIntercept(),this._initAutoHeight()}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept($.INTERCEPTOR_POINT.CELL_CONTENT,{effect:o.InterceptorEffectEnum.Style,priority:$.InterceptCellContentPriority.DATA_VALIDATION,handler:(e,t,r)=>{var T,f,y,S,D;const{row:n,col:a,unitId:i,subUnitId:s,workbook:d,worksheet:l}=t,c=this._sheetDataValidationModel.getRuleIdByLocation(i,s,n,a);if(!c)return r(e);const h=this._sheetDataValidationModel.getRuleById(i,s,c);if(!h)return r(e);const p=(T=this._dataValidationCacheService.getValue(i,s,n,a))!=null?T:o.DataValidationStatus.VALID,u=this._dataValidatorRegistryService.getValidatorItem(h.type),I=l.getCellRaw(n,a),g=m.getCellValueOrigin(I),O=`${g!=null?g:""}`;return(!e||e===t.rawData)&&(e={...t.rawData}),e.markers={...e==null?void 0:e.markers,...p===o.DataValidationStatus.INVALID?mt:null},e.customRender=[...(f=e==null?void 0:e.customRender)!=null?f:[],...u!=null&&u.canvasRender?[u.canvasRender]:[]],e.fontRenderExtension={...e==null?void 0:e.fontRenderExtension,isSkip:((y=e==null?void 0:e.fontRenderExtension)==null?void 0:y.isSkip)||((S=u==null?void 0:u.skipDefaultFontRender)==null?void 0:S.call(u,h,g,t))},e.interceptorStyle={...e==null?void 0:e.interceptorStyle,...u==null?void 0:u.getExtraStyle(h,O,{get style(){const w=d.getStyles();return(typeof(e==null?void 0:e.s)=="string"?w.get(e==null?void 0:e.s):e==null?void 0:e.s)||{}}},n,a)},e.interceptorAutoHeight=()=>{var W,x,P,F,k,N;const w=(x=(W=this._renderManagerService.getRenderById(i))==null?void 0:W.with(B.SheetSkeletonManagerService).getSkeletonParam(s))==null?void 0:x.skeleton;if(!w)return;const C=w.worksheet.getMergedCell(n,a),E={data:e,style:w.getStyles().getStyleByCell(e),primaryWithCoord:w.getCellWithCoordByIndex((P=C==null?void 0:C.startRow)!=null?P:n,(F=C==null?void 0:C.startColumn)!=null?F:a),unitId:i,subUnitId:s,row:n,col:a,workbook:d,worksheet:l};return(N=(k=u==null?void 0:u.canvasRender)==null?void 0:k.calcCellAutoHeight)==null?void 0:N.call(k,E)},e.interceptorAutoWidth=()=>{var W,x,P,F,k,N;const w=(x=(W=this._renderManagerService.getRenderById(i))==null?void 0:W.with(B.SheetSkeletonManagerService).getSkeletonParam(s))==null?void 0:x.skeleton;if(!w)return;const C=w.worksheet.getMergedCell(n,a),E={data:e,style:w.getStyles().getStyleByCell(e),primaryWithCoord:w.getCellWithCoordByIndex((P=C==null?void 0:C.startRow)!=null?P:n,(F=C==null?void 0:C.startColumn)!=null?F:a),unitId:i,subUnitId:s,row:n,col:a,workbook:d,worksheet:l};return(N=(k=u==null?void 0:u.canvasRender)==null?void 0:k.calcCellAutoWidth)==null?void 0:N.call(k,E)},e.coverable=((D=e==null?void 0:e.coverable)!=null?D:!0)&&!(h.type===o.DataValidationType.LIST||h.type===o.DataValidationType.LIST_MULTIPLE),r(e)}}))}_initAutoHeight(){this._sheetDataValidationModel.ruleChange$.pipe(ie.filter(e=>e.source==="command"),ie.bufferTime(16)).subscribe(e=>{const t=[];if(e.forEach(r=>{var n;(r.rule.type===o.DataValidationType.LIST_MULTIPLE||r.rule.type===o.DataValidationType.LIST)&&(n=r.rule)!=null&&n.ranges&&t.push(...r.rule.ranges)}),t.length){const r=this._autoHeightController.getUndoRedoParamsOfAutoHeight(t);o.sequenceExecute(r.redos,this._commandService)}})}};St=ft([G(0,o.ICommandService),G(1,R.IRenderManagerService),G(2,o.Inject(B.AutoHeightController)),G(3,o.Inject(X.DataValidatorRegistryService)),G(4,o.Inject($.SheetInterceptorService)),G(5,o.Inject(m.SheetDataValidationModel)),G(6,o.Inject(m.DataValidationCacheService))],St);var en=Object.getOwnPropertyDescriptor,tn=(e,t,r,n)=>{for(var a=n>1?void 0:n?en(t,r):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(a=s(a)||a);return a},_t=(e,t)=>(r,n)=>t(r,n,e);let Ne=class extends o.Disposable{constructor(e,t,r){super(),this._context=e,this._sheetDataValidationModel=t,this._sheetSkeletonManagerService=r,this._initSkeletonChange()}_initSkeletonChange(){const e=t=>{var n;if(!t.length)return;const r=new Set;t.forEach(a=>{r.add(a.subUnitId)}),r.forEach(a=>{var i;(i=this._sheetSkeletonManagerService.getSkeletonParam(a))==null||i.skeleton.makeDirty(!0)}),(n=this._context.mainComponent)==null||n.makeForceDirty()};this.disposeWithMe(this._sheetDataValidationModel.validStatusChange$.pipe(o.bufferDebounceTime(16)).subscribe(e))}};Ne=tn([_t(1,o.Inject(m.SheetDataValidationModel)),_t(2,o.Inject(B.SheetSkeletonManagerService))],Ne);var oe=function(){return oe=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++){t=arguments[r];for(var a in t)Object.prototype.hasOwnProperty.call(t,a)&&(e[a]=t[a])}return e},oe.apply(this,arguments)},nn=function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var a=0,n=Object.getOwnPropertySymbols(e);a<n.length;a++)t.indexOf(n[a])<0&&Object.prototype.propertyIsEnumerable.call(e,n[a])&&(r[n[a]]=e[n[a]]);return r},Se=V.forwardRef(function(e,t){var r=e.icon,n=e.id,a=e.className,i=e.extend,s=nn(e,["icon","id","className","extend"]),d="univerjs-icon univerjs-icon-".concat(n," ").concat(a||"").trim(),l=V.useRef("_".concat(on()));return It(r,"".concat(n),{defIds:r.defIds,idSuffix:l.current},oe({ref:t,className:d},s),i)});function It(e,t,r,n,a){return V.createElement(e.tag,oe(oe({key:t},rn(e,r,a)),n),(an(e,r).children||[]).map(function(i,s){return It(i,"".concat(t,"-").concat(e.tag,"-").concat(s),r,void 0,a)}))}function rn(e,t,r){var n=oe({},e.attrs);r!=null&&r.colorChannel1&&n.fill==="colorChannel1"&&(n.fill=r.colorChannel1),e.tag==="mask"&&n.id&&(n.id=n.id+t.idSuffix),Object.entries(n).forEach(function(i){var s=i[0],d=i[1];s==="mask"&&typeof d=="string"&&(n[s]=d.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))});var a=t.defIds;return!a||a.length===0||(e.tag==="use"&&n["xlink:href"]&&(n["xlink:href"]=n["xlink:href"]+t.idSuffix),Object.entries(n).forEach(function(i){var s=i[0],d=i[1];typeof d=="string"&&(n[s]=d.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))})),n}function an(e,t){var r,n=t.defIds;return!n||n.length===0?e:e.tag==="defs"&&(!((r=e.children)===null||r===void 0)&&r.length)?oe(oe({},e),{children:e.children.map(function(a){return typeof a.attrs.id=="string"&&n&&n.includes(a.attrs.id)?oe(oe({},a),{attrs:oe(oe({},a.attrs),{id:a.attrs.id+t.idSuffix})}):a})}):e}function on(){return Math.random().toString(36).substring(2,8)}Se.displayName="UniverIcon";var sn={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"}}]},Ct=V.forwardRef(function(e,t){return V.createElement(Se,Object.assign({},e,{id:"data-validation-icon",ref:t,icon:sn}))});Ct.displayName="DataValidationIcon";var ln={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"}}]},et=V.forwardRef(function(e,t){return V.createElement(Se,Object.assign({},e,{id:"delete-icon",ref:t,icon:ln}))});et.displayName="DeleteIcon";var dn={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"}}]},yt=V.forwardRef(function(e,t){return V.createElement(Se,Object.assign({},e,{id:"increase-icon",ref:t,icon:dn}))});yt.displayName="IncreaseIcon";var cn={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"}}]},tt=V.forwardRef(function(e,t){return V.createElement(Se,Object.assign({},e,{id:"more-down-icon",ref:t,icon:cn}))});tt.displayName="MoreDownIcon";var 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:"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"}}]},wt=V.forwardRef(function(e,t){return V.createElement(Se,Object.assign({},e,{id:"more-up-icon",ref:t,icon:un}))});wt.displayName="MoreUpIcon";var hn={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"mask",attrs:{id:"mask0_622_8",width:16,height:16,x:0,y:0,maskUnits:"userSpaceOnUse"},children:[{tag:"path",attrs:{fill:"#D9D9D9",d:"M0 0H16V16H0z"}}]},{tag:"g",attrs:{fill:"currentColor",mask:"url(#mask0_622_8)"},children:[{tag:"path",attrs:{d:"M6 5C6.55228 5 7 4.55228 7 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:{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:{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:{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:{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:{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"}}]}]},Dt=V.forwardRef(function(e,t){return V.createElement(Se,Object.assign({},e,{id:"sequence-icon",ref:t,icon:hn}))});Dt.displayName="SequenceIcon";function vn(e){var c;const t=b.useDependency(o.LocaleService),r=b.useDependency(b.ComponentManager),{value:n,onChange:a,extraComponent:i}=e,[s,d]=V.useState(!1),l=i?r.get(i):null;return v.jsxs(v.Fragment,{children:[v.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:()=>d(!s),children:[t.t("dataValidation.panel.options"),s?v.jsx(wt,{className:"univer-ml-1"}):v.jsx(tt,{className:"univer-ml-1"})]}),s&&v.jsxs(v.Fragment,{children:[l?v.jsx(l,{value:n,onChange:a}):null,v.jsx(M.FormLayout,{label:t.t("dataValidation.panel.invalid"),children:v.jsxs(M.RadioGroup,{value:`${(c=n.errorStyle)!=null?c:o.DataValidationErrorStyle.WARNING}`,onChange:h=>a({...n,errorStyle:+h}),children:[v.jsx(M.Radio,{value:`${o.DataValidationErrorStyle.WARNING}`,children:t.t("dataValidation.panel.showWarning")}),v.jsx(M.Radio,{value:`${o.DataValidationErrorStyle.STOP}`,children:t.t("dataValidation.panel.rejectInput")})]})}),v.jsx(M.FormLayout,{label:t.t("dataValidation.panel.messageInfo"),children:v.jsx(M.Checkbox,{checked:n.showErrorMessage,onChange:()=>a({...n,showErrorMessage:!n.showErrorMessage}),children:t.t("dataValidation.panel.showInfo")})}),n.showErrorMessage?v.jsx(M.FormLayout,{children:v.jsx(M.Input,{value:n.error,onChange:h=>a({...n,error:h})})}):null]})]})}const pn=e=>o.debounce(async(t,r,n,a)=>{const i=await e.executeCommand(t,r,n);a==null||a(i)},1e3);function gn(e,t,r){var n,a,i,s;return t?((a=(n=e.getUnit(t))==null?void 0:n.getSheetBySheetName(r))==null?void 0:a.getSheetId())||"":((s=(i=e.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET))==null?void 0:i.getSheetBySheetName(r))==null?void 0:s.getSheetId())||""}function fn(){var A,Y;const[e,t]=V.useState(0),r=b.useDependency(ue),n=b.useObservable(r.activeRule$,r.activeRule),{unitId:a,subUnitId:i,rule:s}=n||{},d=s.uid,l=b.useDependency(X.DataValidatorRegistryService),c=b.useDependency(o.IUniverInstanceService),h=b.useDependency(b.ComponentManager),p=b.useDependency(o.ICommandService),u=b.useDependency(X.DataValidationModel),I=b.useDependency(o.LocaleService),[g,O]=V.useState(s),T=l.getValidatorItem(g.type),[f,y]=V.useState(!1),S=l.getValidatorsByScope(X.DataValidatorRegistryScope.SHEET),[D,w]=V.useState(()=>g.ranges.map(_=>({unitId:"",sheetId:"",range:_}))),C=V.useMemo(()=>pn(p),[p]),[E,W]=V.useState(!1),[x,P]=V.useState(!1),F=V.useRef(null),k=b.useDependency($.SheetsSelectionsService);if(V.useEffect(()=>()=>{const _=k.getCurrentLastSelection();_&&k.setSelections([_])},[k]),V.useEffect(()=>{p.onCommandExecuted(_=>{(_.id===o.UndoCommand.id||_.id===o.RedoCommand.id)&&setTimeout(()=>{const j=u.getRuleById(a,i,d);t(z=>z+1),j&&(O(j),w(j.ranges.map(z=>({unitId:"",sheetId:"",range:z}))))},20)})},[p,u,d,i,a]),!T)return null;const N=T.operators,H=T.operatorNames,Z=g.operator?X.TWO_FORMULA_OPERATOR_COUNT.includes(g.operator):!1,K=()=>{var _,j,z;(j=(_=F.current)==null?void 0:_.editor)!=null&&j.isFocus()&&te((z=F.current)==null?void 0:z.getValue()),!(!g.ranges.length||E)&&(T.validatorFormula(g,a,i).success?r.setActiveRule(null):y(!0))},te=b.useEvent(_=>{const j=_.split(",").filter(Boolean).map(Xe.deserializeRangeWithSheet).map(re=>{const Pt=re.sheetName;if(Pt){const dr=gn(c,re.unitId,Pt);return{...re,sheetId:dr}}return{...re,sheetId:""}});if(o.isUnitRangesEqual(j,D))return;w(j);const z=j.filter(re=>(!re.unitId||re.unitId===a)&&(!re.sheetId||re.sheetId===i)).map(re=>re.range);if(O({...g,ranges:z}),z.length===0)return;const pe={unitId:a,subUnitId:i,ruleId:d,ranges:z};C(m.UpdateSheetDataValidationRangeCommand.id,pe)}),ae=_=>{if(o.shallowEqual(_,X.getRuleSetting(g)))return;O({...g,..._});const j={unitId:a,subUnitId:i,ruleId:d,setting:_};C(m.UpdateSheetDataValidationSettingCommand.id,j,void 0)},se=async()=>{await p.executeCommand(m.RemoveSheetDataValidationCommand.id,{ruleId:d,unitId:a,subUnitId:i}),r.setActiveRule(null)},ce={type:g.type,operator:g.operator,formula1:g.formula1,formula2:g.formula2,allowBlank:g.allowBlank},J=_=>{const j=l.getValidatorItem(_);if(!j)return;const z=j.operators,pe=u.getRuleById(a,i,d),re=_===(pe==null?void 0:pe.type)||_.includes("list")&&(pe!=null&&pe.type.includes("list"))?{...pe,type:_}:{...g,type:_,operator:z[0],formula1:void 0,formula2:void 0};O(re),p.executeCommand(m.UpdateSheetDataValidationSettingCommand.id,{unitId:a,subUnitId:i,ruleId:g.uid,setting:X.getRuleSetting(re)})},q=h.get(T.formulaInput),ve=V.useMemo(()=>D.map(_=>Xe.serializeRange(_.range)).join(","),[]),ne=X.getRuleOptions(g),ee=_=>{o.shallowEqual(_,X.getRuleOptions(g))||(O({...g,..._}),C(m.UpdateSheetDataValidationOptionsCommand.id,{unitId:a,subUnitId:i,ruleId:d,options:_}))},Q=N.length&&!g.operator;return v.jsxs("div",{"data-u-comp":"data-validation-detail",className:"univer-py-2",children:[v.jsx(M.FormLayout,{label:I.t("dataValidation.panel.range"),error:!g.ranges.length||E?I.t("dataValidation.panel.rangeError"):"",children:v.jsx(ze.RangeSelector,{selectorRef:F,unitId:a,subUnitId:i,initialValue:ve,onChange:(_,j)=>{var z;!x&&((z=F.current)!=null&&z.verify())&&te(j)},onFocusChange:(_,j)=>{var z;P(_),!_&&j&&((z=F.current)!=null&&z.verify())&&te(j)},onVerify:_=>W(!_)})}),v.jsx(M.FormLayout,{label:I.t("dataValidation.panel.type"),children:v.jsx(M.Select,{className:"univer-w-full",value:g.type,options:(A=S==null?void 0:S.sort((_,j)=>_.order-j.order))==null?void 0:A.map(_=>({label:I.t(_.title),value:_.id})),onChange:J})}),N!=null&&N.length?v.jsx(M.FormLayout,{label:I.t("dataValidation.panel.operator"),children:v.jsx(M.Select,{className:"univer-w-full",value:`${g.operator}`,options:[{value:"",label:I.t("dataValidation.operators.legal")},...N.map((_,j)=>({value:`${_}`,label:H[j]}))],onChange:_=>{ae({...ce,operator:_})}})}):null,q&&!Q?v.jsx(q,{isTwoFormula:Z,value:{formula1:g.formula1,formula2:g.formula2},onChange:_=>{ae({...ce,..._})},showError:f,validResult:T.validatorFormula(g,a,i),unitId:a,subUnitId:i,ruleId:d},e+g.type):null,v.jsx(M.FormLayout,{children:v.jsx(M.Checkbox,{checked:(Y=g.allowBlank)!=null?Y:!0,onChange:()=>{var _;return ae({...ce,allowBlank:!((_=g.allowBlank)==null||_)})},children:I.t("dataValidation.panel.allowBlank")})}),v.jsx(vn,{value:ne,onChange:ee,extraComponent:T.optionsInput}),v.jsxs("div",{className:"univer-mt-5 univer-flex univer-flex-row univer-justify-end",children:[v.jsx(M.Button,{className:"univer-ml-3",onClick:se,children:I.t("dataValidation.panel.removeRule")}),v.jsx(M.Button,{className:"univer-ml-3",variant:"primary",onClick:K,children:I.t("dataValidation.panel.done")})]})]})}const mn=e=>{const{rule:t,onClick:r,unitId:n,subUnitId:a,disable:i}=e,s=b.useDependency(X.DataValidatorRegistryService),d=b.useDependency(o.ICommandService),l=b.useDependency(B.IMarkSelectionService),c=s.getValidatorItem(t.type),h=V.useRef(void 0),[p,u]=V.useState(!1),I=b.useDependency(o.ThemeService),g=b.useObservable(I.currentTheme$),O=V.useMemo(()=>{var w;const f=I.getColorFromTheme("primary.600"),y=I.getColorFromTheme("loop-color.2"),S=(w=I.getColorFromTheme(y))!=null?w:f,D=new o.ColorKit(S).toRgb();return{fill:`rgba(${D.r}, ${D.g}, ${D.b}, 0.1)`,stroke:S}},[g]),T=f=>{d.executeCommand(m.RemoveSheetDataValidationCommand.id,{ruleId:t.uid,unitId:n,subUnitId:a}),f.stopPropagation()};return V.useEffect(()=>()=>{var f;h.current&&((f=h.current)==null||f.forEach(y=>{y&&l.removeShape(y)}))},[l]),v.jsxs("div",{className:M.clsx(`
1
+ (function(U,o){typeof exports=="object"&&typeof module<"u"?o(exports,require("@univerjs/core"),require("@univerjs/engine-render"),require("@univerjs/sheets"),require("@univerjs/sheets-data-validation"),require("@univerjs/data-validation"),require("@univerjs/ui"),require("rxjs"),require("@univerjs/sheets-numfmt"),require("@univerjs/sheets-ui"),require("@univerjs/design"),require("react"),require("react/jsx-runtime"),require("@univerjs/engine-formula"),require("@univerjs/sheets-formula-ui")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/engine-render","@univerjs/sheets","@univerjs/sheets-data-validation","@univerjs/data-validation","@univerjs/ui","rxjs","@univerjs/sheets-numfmt","@univerjs/sheets-ui","@univerjs/design","react","react/jsx-runtime","@univerjs/engine-formula","@univerjs/sheets-formula-ui"],o):(U=typeof globalThis<"u"?globalThis:U||self,o(U.UniverSheetsDataValidationUi={},U.UniverCore,U.UniverEngineRender,U.UniverSheets,U.UniverSheetsDataValidation,U.UniverDataValidation,U.UniverUi,U.rxjs,U.UniverSheetsNumfmt,U.UniverSheetsUi,U.UniverDesign,U.React,U.React,U.UniverEngineFormula,U.UniverSheetsFormulaUi))})(this,function(U,o,R,$,m,X,b,ie,At,B,M,V,v,Xe,ze){"use strict";var cr=Object.defineProperty;var ur=(U,o,R)=>o in U?cr(U,o,{enumerable:!0,configurable:!0,writable:!0,value:R}):U[o]=R;var L=(U,o,R)=>ur(U,typeof o!="symbol"?o+"":o,R);var Ye;var Lt=Object.getOwnPropertyDescriptor,Ut=(e,t,r,n)=>{for(var a=n>1?void 0:n?Lt(t,r):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(a=s(a)||a);return a},ht=(e,t)=>(r,n)=>t(r,n,e);let ue=class extends o.Disposable{constructor(t,r){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);this._univerInstanceService=t,this._sidebarService=r,this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(o.UniverInstanceType.UNIVER_SHEET).pipe(ie.filter(n=>!n)).subscribe(()=>{this.close()})),this.disposeWithMe(this._sidebarService.sidebarOptions$.subscribe(n=>{n.id===Ue&&(n.visible||setTimeout(()=>{this._sidebarService.sidebarOptions$.next({visible:!1})}))}))}get activeRule(){return this._activeRule}get isOpen(){return this._open$.getValue()}dispose(){var t;super.dispose(),this._open$.next(!1),this._open$.complete(),this._activeRule$.complete(),(t=this._closeDisposable)==null||t.dispose()}open(){this._open$.next(!0)}close(){var t;this._open$.next(!1),(t=this._closeDisposable)==null||t.dispose()}setCloseDisposable(t){this._closeDisposable=o.toDisposable(()=>{t.dispose(),this._closeDisposable=null})}setActiveRule(t){this._activeRule=t,this._activeRule$.next(t)}};ue=Ut([ht(0,o.IUniverInstanceService),ht(1,b.ISidebarService)],ue);const Ke="sheets-data-validation-ui.config",Le={};var kt=Object.getOwnPropertyDescriptor,Ft=(e,t,r,n)=>{for(var a=n>1?void 0:n?kt(t,r):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(a=s(a)||a);return a},Ce=(e,t)=>(r,n)=>t(r,n,e);let ye=class extends o.Disposable{constructor(e,t,r,n,a,i){super(),this._sheetInterceptorService=e,this._dataValidationModel=t,this._dataValidatorRegistryService=r,this._dialogService=n,this._localeService=a,this._sheetsDataValidationValidatorService=i,this._initEditorBridgeInterceptor()}_initEditorBridgeInterceptor(){this._sheetInterceptorService.writeCellInterceptor.intercept($.VALIDATE_CELL,{handler:async(e,t,r)=>{const n=await e,{row:a,col:i,unitId:s,subUnitId:d}=t,l=this._dataValidationModel.getRuleIdByLocation(s,d,a,i),c=l?this._dataValidationModel.getRuleById(s,d,l):void 0;if(n===!1)return r(Promise.resolve(!1));if(!c||c.errorStyle!==o.DataValidationErrorStyle.STOP)return r(Promise.resolve(!0));const h=this._dataValidatorRegistryService.getValidatorItem(c.type);return!h||await this._sheetsDataValidationValidatorService.validatorCell(s,d,a,i)===o.DataValidationStatus.VALID?r(Promise.resolve(!0)):(this._dialogService.open({width:368,title:{title:this._localeService.t("dataValidation.alert.title")},id:"reject-input-dialog",children:{title:h.getRuleFinalError(c,{row:a,col:i,unitId:s,subUnitId:d})},footer:{title:V.createElement(M.Button,{variant:"primary",onClick:()=>this._dialogService.close("reject-input-dialog")},this._localeService.t("dataValidation.alert.ok"))},onClose:()=>{this._dialogService.close("reject-input-dialog")}}),r(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:V.createElement(M.Button,{variant:"primary",onClick:()=>this._dialogService.close("reject-input-dialog")},this._localeService.t("dataValidation.alert.ok"))},onClose:()=>{this._dialogService.close("reject-input-dialog")}})}};ye=Ft([Ce(0,o.Inject($.SheetInterceptorService)),Ce(1,o.Inject(m.SheetDataValidationModel)),Ce(2,o.Inject(X.DataValidatorRegistryService)),Ce(3,b.IDialogService),Ce(4,o.Inject(o.LocaleService)),Ce(5,o.Inject(m.SheetsDataValidationValidatorService))],ye);var Nt=Object.getOwnPropertyDescriptor,jt=(e,t,r,n)=>{for(var a=n>1?void 0:n?Nt(t,r):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(a=s(a)||a);return a},le=(e,t)=>(r,n)=>t(r,n,e);const Ze=e=>{if(e==null||typeof e=="boolean")return;if(typeof e=="number"||!Number.isNaN(+e))return o.dayjs(o.numfmt.format("yyyy-MM-dd HH:mm:ss",Number(e)));const t=o.dayjs(e);if(t.isValid())return t};function Bt(e,t){const r=At.getPatternType(t);if(e===r)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 ge=class extends o.Disposable{constructor(t,r,n,a,i,s,d,l,c,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=r,this._zenZoneService=n,this._dataValidationModel=a,this._sheetsSelectionsService=i,this._cellDropdownManagerService=s,this._sheetDataValidationModel=d,this._commandService=l,this._editorBridgeService=c,this._injector=h,this._configService=p,this._init(),this._initSelectionChange(),this.disposeWithMe(()=>{this._activeDropdown$.complete()})}get activeDropdown(){return this._activeDropdown}_init(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(t=>{this._zenVisible=t,t&&this.hideDropdown()}))}_getDropdownByCell(t,r,n,a){const i=t?this._univerInstanceService.getUnit(t,o.UniverInstanceType.UNIVER_SHEET):this._univerInstanceService.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET);if(!i)return;const s=r?i.getSheetBySheetId(r):i.getActiveSheet();if(!s)return;const d=this._dataValidationModel.getRuleByLocation(i.getUnitId(),s.getSheetId(),n,a);if(!d)return;const l=this._dataValidatorRegistryService.getValidatorItem(d.type);return l==null?void 0:l.dropdownType}_initSelectionChange(){this.disposeWithMe(this._sheetsSelectionsService.selectionMoveEnd$.subscribe(t=>{t&&t.every(r=>!(r.primary&&this._getDropdownByCell(r.primary.unitId,r.primary.sheetId,r.primary.actualRow,r.primary.actualColumn)))&&this.hideDropdown()}))}showDropdown(t){var O,T,f,y;const{location:r}=t,{row:n,col:a,unitId:i,subUnitId:s,workbook:d,worksheet:l}=r;if(this._currentPopup&&this._currentPopup.dispose(),this._zenVisible)return;this._activeDropdown=t,this._activeDropdown$.next(this._activeDropdown);const c=this._sheetDataValidationModel.getRuleByLocation(i,s,n,a);if(!c)return;const h=this._dataValidatorRegistryService.getValidatorItem(c.type);if(!(h!=null&&h.dropdownType))return;let p;const u=async(S,D)=>{var k,N,H;if(!S)return!0;const w=S,C=l.getCell(n,a),E=w.format(D==="date"?"YYYY-MM-DD 00:00:00":"YYYY-MM-DD HH:mm:ss"),W=(k=o.numfmt.parseDate(E))==null?void 0:k.v,x=D==="time"?W%1:W,P=d.getStyles().getStyleByCell(C),F=(H=(N=P==null?void 0:P.n)==null?void 0:N.pattern)!=null?H:"";return c.errorStyle!==o.DataValidationErrorStyle.STOP||await h.validator({value:x,unitId:i,subUnitId:s,row:n,column:a,worksheet:l,workbook:d,interceptValue:E.replace("Z","").replace("T"," "),t:o.CellValueType.NUMBER},c)?(await this._commandService.executeCommand($.SetRangeValuesCommand.id,{unitId:i,subUnitId:s,range:{startColumn:a,endColumn:a,startRow:n,endRow:n},value:{v:x,t:2,p:null,f:null,si:null,s:{n:{pattern:Bt(D,F)}}}}),await this._commandService.executeCommand(B.SetCellEditVisibleOperation.id,{visible:!1,eventType:R.DeviceInputEventType.Keyboard,unitId:i,keycode:b.KeyCode.ESC}),!0):(this._injector.has(ye)&&this._injector.get(ye).showReject(h.getRuleFinalError(c,{row:n,col:a,unitId:i,subUnitId:s})),!1)};let I;switch(h.dropdownType){case X.DataValidatorDropdownType.DATE:{const S=m.getCellValueOrigin(l.getCellRaw(n,a)),D=Ze(S),w=!!((O=c.bizInfo)!=null&&O.showTime);I={location:r,type:"datepicker",props:{showTime:w,onChange:C=>u(C,w?"datetime":"date"),defaultValue:D,patternType:"date"}};break}case X.DataValidatorDropdownType.TIME:{const S=m.getCellValueOrigin(l.getCellRaw(n,a)),D=Ze(S);I={location:r,type:"datepicker",props:{onChange:w=>u(w,"time"),defaultValue:D,patternType:"time"}};break}case X.DataValidatorDropdownType.DATETIME:{const S=m.getCellValueOrigin(l.getCellRaw(n,a)),D=Ze(S);I={location:r,type:"datepicker",props:{onChange:w=>u(w,"datetime"),defaultValue:D,patternType:"datetime"}};break}case X.DataValidatorDropdownType.LIST:case X.DataValidatorDropdownType.MULTIPLE_LIST:{const S=h.dropdownType===X.DataValidatorDropdownType.MULTIPLE_LIST,D=async P=>{const F=m.serializeListOptions(P),k={unitId:i,subUnitId:s,range:{startColumn:a,endColumn:a,startRow:n,endRow:n},value:{v:F,p:null,f:null,si:null}};return this._commandService.executeCommand($.SetRangeValuesCommand.id,k),this._editorBridgeService.isVisible().visible&&await this._commandService.executeCommand(B.SetCellEditVisibleOperation.id,{visible:!1,eventType:R.DeviceInputEventType.Keyboard,unitId:i,keycode:b.KeyCode.ESC}),!S},w=(c==null?void 0:c.renderMode)===o.DataValidationRenderMode.CUSTOM||(c==null?void 0:c.renderMode)===void 0,C=h.getListWithColor(c,i,s),E=m.getDataValidationCellValue(l.getCellRaw(n,a)),W=()=>{this._commandService.executeCommand(fe.id,{ruleId:c.uid}),p==null||p.dispose()},x=C.map(P=>({label:P.label,value:P.label,color:w||P.color?P.color:"transparent"}));I={location:r,type:"list",props:{onChange:P=>D(P),options:x,onEdit:W,defaultValue:E,multiple:S,showEdit:(f=(T=this._configService.getConfig(Ke))==null?void 0:T.showEditOnDropdown)!=null?f:!0}};break}case X.DataValidatorDropdownType.CASCADE:{I={type:"cascader",props:{onChange:D=>{const w={unitId:i,subUnitId:s,range:{startColumn:a,endColumn:a,startRow:n,endRow:n},value:{v:D.join("/"),p:null,f:null,si:null}};return this._commandService.syncExecuteCommand($.SetRangeValuesCommand.id,w),this._editorBridgeService.isVisible().visible&&this._commandService.syncExecuteCommand(B.SetCellEditVisibleOperation.id,{visible:!1,eventType:R.DeviceInputEventType.Keyboard,unitId:i,keycode:b.KeyCode.ESC}),!0},defaultValue:m.getDataValidationCellValue(l.getCellRaw(n,a)).split("/"),options:JSON.parse((y=c.formula1)!=null?y:"[]")},location:r};break}case X.DataValidatorDropdownType.COLOR:{I={type:"color",props:{onChange:D=>{const w={unitId:i,subUnitId:s,range:{startColumn:a,endColumn:a,startRow:n,endRow:n},value:{v:D,p:null,f:null,si:null}};return this._commandService.syncExecuteCommand($.SetRangeValuesCommand.id,w),this._editorBridgeService.isVisible().visible&&this._commandService.syncExecuteCommand(B.SetCellEditVisibleOperation.id,{visible:!1,eventType:R.DeviceInputEventType.Keyboard,unitId:i,keycode:b.KeyCode.ESC}),!0},defaultValue:m.getDataValidationCellValue(l.getCellRaw(n,a))},location:r};break}default:throw new Error("[DataValidationDropdownManagerService]: unknown type!")}if(p=this._cellDropdownManagerService.showDropdown({...I,onHide:()=>{this._activeDropdown=null,this._activeDropdown$.next(null)}}),!p)throw new Error("[DataValidationDropdownManagerService]: cannot show dropdown!");const g=new o.DisposableCollection;g.add(p),g.add({dispose:()=>{var S,D;(D=(S=this._activeDropdown)==null?void 0:S.onHide)==null||D.call(S)}}),this._currentPopup=g}hideDropdown(){this._activeDropdown&&(this._currentPopup&&this._currentPopup.dispose(),this._currentPopup=null,this._activeDropdown=null,this._activeDropdown$.next(null))}showDataValidationDropdown(t,r,n,a,i){const s=this._univerInstanceService.getUnit(t,o.UniverInstanceType.UNIVER_SHEET);if(!s)return;const d=s.getSheetBySheetId(r);if(!d)return;const l=this._dataValidationModel.getRuleByLocation(s.getUnitId(),d.getSheetId(),n,a);if(!l)return;const c=this._dataValidatorRegistryService.getValidatorItem(l.type);if(!c||!c.dropdownType){this.hideDropdown();return}this.showDropdown({location:{workbook:s,worksheet:d,row:n,col:a,unitId:t,subUnitId:r},onHide:i})}};ge=jt([le(0,o.IUniverInstanceService),le(1,o.Inject(X.DataValidatorRegistryService)),le(2,b.IZenZoneService),le(3,o.Inject(m.SheetDataValidationModel)),le(4,o.Inject($.SheetsSelectionsService)),le(5,o.Inject(B.ISheetCellDropdownManagerService)),le(6,o.Inject(m.SheetDataValidationModel)),le(7,o.ICommandService),le(8,B.IEditorBridgeService),le(9,o.Inject(o.Injector)),le(10,o.IConfigService)],ge);const Ue="DataValidationPanel",fe={id:"data-validation.operation.open-validation-panel",type:o.CommandType.OPERATION,handler(e,t){if(!t)return!1;const{ruleId:r,isAdd:n}=t,a=e.get(ue),i=e.get(X.DataValidationModel),s=e.get(o.IUniverInstanceService),d=e.get(b.ISidebarService),l=$.getSheetCommandTarget(s);if(!l)return!1;const{unitId:c,subUnitId:h}=l,p=r?i.getRuleById(c,h,r):void 0;a.open(),a.setActiveRule(p&&{unitId:c,subUnitId:h,rule:p});const u=d.open({id:Ue,header:{title:n?"dataValidation.panel.addTitle":"dataValidation.panel.title"},children:{label:Ue},width:312,onClose:()=>a.close()});return a.setCloseDisposable(u),!0}},Ge={id:"data-validation.operation.close-validation-panel",type:o.CommandType.OPERATION,handler(e){return e.get(ue).close(),!0}},vt={id:"data-validation.operation.toggle-validation-panel",type:o.CommandType.OPERATION,handler(e){const t=e.get(o.ICommandService),r=e.get(ue);return r.open(),r.isOpen?t.executeCommand(Ge.id):t.executeCommand(fe.id),!0}},ke={type:o.CommandType.OPERATION,id:"sheet.operation.show-data-validation-dropdown",handler(e,t){if(!t)return!1;const r=e.get(ge),{unitId:n,subUnitId:a,row:i,column:s}=t,d=r.activeDropdown,l=d==null?void 0:d.location;return l&&l.unitId===n&&l.subUnitId===a&&l.row===i&&l.col===s||r.showDataValidationDropdown(n,a,i,s),!0}},pt={type:o.CommandType.OPERATION,id:"sheet.operation.hide-data-validation-dropdown",handler(e,t){return t?(e.get(ge).hideDropdown(),!0):!1}},Fe={type:o.CommandType.COMMAND,id:"data-validation.command.addRuleAndOpen",handler(e){const t=e.get(o.IUniverInstanceService),r=$.getSheetCommandTarget(t);if(!r)return!1;const{workbook:n,worksheet:a}=r,i=m.createDefaultNewRule(e),s=e.get(o.ICommandService),d=n.getUnitId(),l=a.getSheetId(),c={rule:i,unitId:d,subUnitId:l};return s.syncExecuteCommand(m.AddSheetDataValidationCommand.id,c)?(s.syncExecuteCommand(fe.id,{ruleId:i.uid,isAdd:!0}),!0):!1}};var Wt=Object.getOwnPropertyDescriptor,Ht=(e,t,r,n)=>{for(var a=n>1?void 0:n?Wt(t,r):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(a=s(a)||a);return a},we=(e,t)=>(r,n)=>t(r,n,e);const me="SHEET_DATA_VALIDATION_ALERT";let Pe=class extends o.Disposable{constructor(e,t,r,n,a,i){super(),this._hoverManagerService=e,this._cellAlertManagerService=t,this._univerInstanceService=r,this._localeService=n,this._zenZoneService=a,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 r=this._univerInstanceService.getUnit(e.location.unitId,o.UniverInstanceType.UNIVER_SHEET),n=r.getSheetBySheetId(e.location.subUnitId);if(!n)return;const a=this._dataValidationModel.getRuleByLocation(e.location.unitId,e.location.subUnitId,e.location.row,e.location.col);if(!a){this._cellAlertManagerService.removeAlert(me);return}if(this._dataValidationModel.validator(a,{...e.location,workbook:r,worksheet:n})===o.DataValidationStatus.INVALID){const s=this._cellAlertManagerService.currentAlert.get(me),d=(t=s==null?void 0:s.alert)==null?void 0:t.location;if(d&&d.row===e.location.row&&d.col===e.location.col&&d.subUnitId===e.location.subUnitId&&d.unitId===e.location.unitId){this._cellAlertManagerService.removeAlert(me);return}const l=this._dataValidationModel.getValidator(a.type);if(!l){this._cellAlertManagerService.removeAlert(me);return}this._cellAlertManagerService.showAlert({type:B.CellAlertType.ERROR,title:this._localeService.t("dataValidation.error.title"),message:l==null?void 0:l.getRuleFinalError(a,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=Ht([we(0,o.Inject(B.HoverManagerService)),we(1,o.Inject(B.CellAlertManagerService)),we(2,o.IUniverInstanceService),we(3,o.Inject(o.LocaleService)),we(4,b.IZenZoneService),we(5,o.Inject(m.SheetDataValidationModel))],Pe);var xt=Object.getOwnPropertyDescriptor,$t=(e,t,r,n)=>{for(var a=n>1?void 0:n?xt(t,r):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(a=s(a)||a);return a},qe=(e,t)=>(r,n)=>t(r,n,e);let De=class extends o.Disposable{constructor(e,t,r){super(),this._autoFillService=e,this._sheetDataValidationModel=t,this._injector=r,this._initAutoFill()}_initAutoFill(){const e=()=>({redos:[],undos:[]}),t=(n,a)=>{const{source:i,target:s,unitId:d,subUnitId:l}=n,c=this._sheetDataValidationModel.getRuleObjectMatrix(d,l).clone(),h=B.virtualizeDiscreteRanges([i,s]),[p,u]=h.ranges,{mapFunc:I}=h,g={row:p.startRow,col:p.startColumn},O=B.getAutoFillRepeatRange(p,u),T=new o.ObjectMatrix,f=new Set;O.forEach(C=>{const E=C.repeatStartCell,W=C.relativeRange,x={startRow:g.row,startColumn:g.col,endColumn:g.col,endRow:g.row},P={startRow:E.row,startColumn:E.col,endColumn:E.col,endRow:E.row};o.Range.foreach(W,(F,k)=>{const N=o.Rectangle.getPositionRange({startRow:F,startColumn:k,endColumn:k,endRow:F},x),{row:H,col:Z}=I(N.startRow,N.startColumn),K=this._sheetDataValidationModel.getRuleIdByLocation(d,l,H,Z)||"",te=o.Rectangle.getPositionRange({startRow:F,startColumn:k,endColumn:k,endRow:F},P),{row:ae,col:se}=I(te.startRow,te.startColumn);T.setValue(ae,se,K),f.add(K)})});const y=Array.from(f).map(C=>({id:C,ranges:o.queryObjectMatrix(T,E=>E===C)}));c.addRangeRules(y);const S=c.diff(this._sheetDataValidationModel.getRules(d,l)),{redoMutations:D,undoMutations:w}=m.getDataValidationDiffMutations(d,l,S,this._injector,"patched",a===B.APPLY_TYPE.ONLY_FORMAT);return{undos:w,redos:D}},r={id:m.DATA_VALIDATION_PLUGIN_NAME,onBeforeFillData:n=>{const{source:a,unitId:i,subUnitId:s}=n;for(const d of a.rows)for(const l of a.cols){const c=this._sheetDataValidationModel.getRuleByLocation(i,s,d,l);if(c&&c.type===o.DataValidationType.CHECKBOX){this._autoFillService.setDisableApplyType(B.APPLY_TYPE.SERIES,!0);return}}},onFillData:(n,a,i)=>i===B.APPLY_TYPE.COPY||i===B.APPLY_TYPE.ONLY_FORMAT||i===B.APPLY_TYPE.SERIES?t(n,i):e(),onAfterFillData:()=>{}};this.disposeWithMe(this._autoFillService.addHook(r))}};De=$t([qe(0,B.IAutoFillService),qe(1,o.Inject(m.SheetDataValidationModel)),qe(2,o.Inject(o.Injector))],De);var Yt=Object.getOwnPropertyDescriptor,Xt=(e,t,r,n)=>{for(var a=n>1?void 0:n?Yt(t,r):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(a=s(a)||a);return a},Je=(e,t)=>(r,n)=>t(r,n,e);let Ee=class extends o.Disposable{constructor(t,r,n){super();L(this,"_copyInfo");this._sheetClipboardService=t,this._sheetDataValidationModel=r,this._injector=n,this._initCopyPaste()}_initCopyPaste(){this._sheetClipboardService.addClipboardHook({id:m.DATA_VALIDATION_PLUGIN_NAME,onBeforeCopy:(t,r,n)=>this._collect(t,r,n),onPasteCells:(t,r,n,a)=>{const{copyType:i=B.COPY_TYPE.COPY,pasteType:s}=a,{range:d}=t||{},{range:l,unitId:c,subUnitId:h}=r;return this._generateMutations(l,{copyType:i,pasteType:s,copyRange:d,unitId:c,subUnitId:h})}})}_collect(t,r,n){const a=new o.ObjectMatrix;this._copyInfo={unitId:t,subUnitId:r,matrix:a};const i=this._injector.invoke(l=>$.rangeToDiscreteRange(n,l,t,r));if(!i)return;const{rows:s,cols:d}=i;s.forEach((l,c)=>{d.forEach((h,p)=>{const u=this._sheetDataValidationModel.getRuleIdByLocation(t,r,l,h);a.setValue(c,p,u!=null?u:"")})})}_generateMutations(t,r){if(!this._copyInfo)return{redos:[],undos:[]};if(r.copyType===B.COPY_TYPE.CUT)return this._copyInfo=null,{redos:[],undos:[]};if(!this._copyInfo||!this._copyInfo.matrix.getSizeOf()||!r.copyRange)return{redos:[],undos:[]};if([B.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_COL_WIDTH,B.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_VALUE,B.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMAT,B.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMULA].includes(r.pasteType))return{redos:[],undos:[]};const{unitId:a,subUnitId:i}=this._copyInfo;if(r.unitId!==a||i!==r.subUnitId){const s=this._sheetDataValidationModel.getRuleObjectMatrix(r.unitId,r.subUnitId).clone(),d=new o.ObjectMatrix,l=new Set,{ranges:[c,h],mapFunc:p}=B.virtualizeDiscreteRanges([r.copyRange,t]),u=B.getRepeatRange(c,h,!0),I=new Map;u.forEach(({startRange:f})=>{var y;(y=this._copyInfo)==null||y.matrix.forValue((S,D,w)=>{const C=o.Rectangle.getPositionRange({startRow:S,endRow:S,startColumn:D,endColumn:D},f),E=`${i}-${w}`,W=this._sheetDataValidationModel.getRuleById(a,i,w);!this._sheetDataValidationModel.getRuleById(r.unitId,r.subUnitId,E)&&W&&I.set(E,{...W,uid:E});const{row:x,col:P}=p(C.startRow,C.startColumn);l.add(E),d.setValue(x,P,E)})});const g=Array.from(l).map(f=>({id:f,ranges:o.queryObjectMatrix(d,y=>y===f)}));s.addRangeRules(g);const{redoMutations:O,undoMutations:T}=m.getDataValidationDiffMutations(r.unitId,r.subUnitId,s.diffWithAddition(this._sheetDataValidationModel.getRules(r.unitId,r.subUnitId),I.values()),this._injector,"patched",!1);return{redos:O,undos:T}}else{const s=this._sheetDataValidationModel.getRuleObjectMatrix(a,i).clone(),d=new o.ObjectMatrix,l=new Set,{ranges:[c,h],mapFunc:p}=B.virtualizeDiscreteRanges([r.copyRange,t]);B.getRepeatRange(c,h,!0).forEach(({startRange:T})=>{var f;(f=this._copyInfo)==null||f.matrix.forValue((y,S,D)=>{const w=o.Rectangle.getPositionRange({startRow:y,endRow:y,startColumn:S,endColumn:S},T),{row:C,col:E}=p(w.startRow,w.startColumn);d.setValue(C,E,D),l.add(D)})});const I=Array.from(l).map(T=>({id:T,ranges:o.queryObjectMatrix(d,f=>f===T)}));s.addRangeRules(I);const{redoMutations:g,undoMutations:O}=m.getDataValidationDiffMutations(a,i,s.diff(this._sheetDataValidationModel.getRules(a,i)),this._injector,"patched",!1);return{redos:g,undos:O}}}};Ee=Xt([Je(0,B.ISheetClipboardService),Je(1,o.Inject(m.SheetDataValidationModel)),Je(2,o.Inject(o.Injector))],Ee);var zt=Object.getOwnPropertyDescriptor,Kt=(e,t,r,n)=>{for(var a=n>1?void 0:n?zt(t,r):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(a=s(a)||a);return a},Qe=(e,t)=>(r,n)=>t(r,n,e);let Me=class extends o.Disposable{constructor(e,t,r){super(),this._localeService=e,this._commandService=t,this._sheetPermissionCheckController=r,this._commandExecutedListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.beforeCommandExecuted(e=>{e.id===m.AddSheetDataValidationCommand.id&&(this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[$.WorkbookEditablePermission],rangeTypes:[$.RangeProtectionPermissionEditPoint],worksheetTypes:[$.WorksheetEditPermission,$.WorksheetSetCellStylePermission]})||this._sheetPermissionCheckController.blockExecuteWithoutPermission(this._localeService.t("permission.dialog.setStyleErr"))),e.id===m.UpdateSheetDataValidationRangeCommand.id&&(this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[$.WorkbookEditablePermission],rangeTypes:[$.RangeProtectionPermissionEditPoint],worksheetTypes:[$.WorksheetEditPermission,$.WorksheetSetCellStylePermission]},e.params.ranges)||this._sheetPermissionCheckController.blockExecuteWithoutPermission(this._localeService.t("permission.dialog.setStyleErr")))}))}};Me=Kt([Qe(0,o.Inject(o.LocaleService)),Qe(1,o.ICommandService),Qe(2,o.Inject($.SheetPermissionCheckController))],Me);const gt="sheet.menu.data-validation";function Zt(e){return{id:gt,type:b.MenuItemType.SUBITEMS,icon:"DataValidationIcon",tooltip:"dataValidation.title",hidden$:b.getMenuHiddenObservable(e,o.UniverInstanceType.UNIVER_SHEET),disabled$:B.getCurrentRangeDisable$(e,{workbookTypes:[$.WorkbookEditablePermission],worksheetTypes:[$.WorksheetSetCellStylePermission,$.WorksheetEditPermission],rangeTypes:[$.RangeProtectionPermissionEditPoint]})}}function Gt(e){return{id:fe.id,title:"dataValidation.panel.title",type:b.MenuItemType.BUTTON}}function qt(e){return{id:Fe.id,title:"dataValidation.panel.add",type:b.MenuItemType.BUTTON}}const Jt={[b.RibbonDataGroup.RULES]:{[gt]:{order:0,menuItemFactory:Zt,[fe.id]:{order:0,menuItemFactory:Gt},[Fe.id]:{order:1,menuItemFactory:qt}}}};var Qt=Object.getOwnPropertyDescriptor,ft=(e,t,r,n)=>{for(var a=n>1?void 0:n?Qt(t,r):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(a=s(a)||a);return a},G=(e,t)=>(r,n)=>t(r,n,e);const mt={tr:{size:6,color:"#fe4b4b"}};let be=class extends o.RxDisposable{constructor(e,t,r,n,a,i,s,d,l,c,h){super(),this._commandService=e,this._menuManagerService=t,this._renderManagerService=r,this._univerInstanceService=n,this._autoHeightController=a,this._dropdownManagerService=i,this._sheetDataValidationModel=s,this._dataValidatorRegistryService=d,this._sheetInterceptorService=l,this._dataValidationCacheService=c,this._editorBridgeService=h,this._initMenu(),this._initDropdown(),this._initViewModelIntercept(),this._initAutoHeight()}_initMenu(){this._menuManagerService.mergeMenu(Jt)}_initDropdown(){this._editorBridgeService&&this.disposeWithMe(this._editorBridgeService.visible$.subscribe(e=>{var r;if(!e.visible){((r=this._dropdownManagerService.activeDropdown)==null?void 0:r.trigger)==="editor-bridge"&&this._dropdownManagerService.hideDropdown();return}const t=this._editorBridgeService.getEditCellState();if(t){const{unitId:n,sheetId:a,row:i,column:s}=t,d=this._univerInstanceService.getUniverSheetInstance(n);if(!d)return;const l=this._sheetDataValidationModel.getRuleByLocation(n,a,i,s);if(!l)return;const c=this._dataValidatorRegistryService.getValidatorItem(l.type);if(!(c!=null&&c.dropdownType))return;const h=d.getActiveSheet();if(!h)return;const p=this._dropdownManagerService.activeDropdown,u=p==null?void 0:p.location;if(u&&u.unitId===n&&u.subUnitId===a&&u.row===i&&u.col===s)return;this._dropdownManagerService.showDropdown({location:{unitId:n,subUnitId:a,row:i,col:s,workbook:d,worksheet:h},trigger:"editor-bridge",closeOnOutSide:!1})}}))}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept($.INTERCEPTOR_POINT.CELL_CONTENT,{effect:o.InterceptorEffectEnum.Style,priority:$.InterceptCellContentPriority.DATA_VALIDATION,handler:(e,t,r)=>{var f,y,S,D,w;const{row:n,col:a,unitId:i,subUnitId:s,workbook:d,worksheet:l}=t,c=this._sheetDataValidationModel.getRuleIdByLocation(i,s,n,a);if(!c)return r(e);const h=this._sheetDataValidationModel.getRuleById(i,s,c);if(!h)return r(e);const p=(f=this._dataValidationCacheService.getValue(i,s,n,a))!=null?f:o.DataValidationStatus.VALID,u=this._dataValidatorRegistryService.getValidatorItem(h.type),I=t.rawData;let g;const O={get value(){var C;return g!==void 0||(g=(C=m.getCellValueOrigin(I))!=null?C:null),g}},T={get value(){var C;return`${(C=O.value)!=null?C:""}`}};return(!e||e===t.rawData)&&(e={...t.rawData}),e.markers={...e==null?void 0:e.markers,...p===o.DataValidationStatus.INVALID?mt: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:((S=e==null?void 0:e.fontRenderExtension)==null?void 0:S.isSkip)||((D=u==null?void 0:u.skipDefaultFontRender)==null?void 0:D.call(u,h,O.value,t))},e.interceptorStyle={...e==null?void 0:e.interceptorStyle,...u==null?void 0:u.getExtraStyle(h,T.value,{get style(){const C=d.getStyles();return(typeof(e==null?void 0:e.s)=="string"?C.get(e==null?void 0:e.s):e==null?void 0:e.s)||{}}},n,a)},e.interceptorAutoHeight=()=>{var x,P,F,k,N,H;const C=(P=(x=this._renderManagerService.getRenderById(i))==null?void 0:x.with(B.SheetSkeletonManagerService).getSkeletonParam(s))==null?void 0:P.skeleton;if(!C)return;const E=C.worksheet.getMergedCell(n,a),W={data:e,style:C.getStyles().getStyleByCell(e),primaryWithCoord:C.getCellWithCoordByIndex((F=E==null?void 0:E.startRow)!=null?F:n,(k=E==null?void 0:E.startColumn)!=null?k:a),unitId:i,subUnitId:s,row:n,col:a,workbook:d,worksheet:l};return(H=(N=u==null?void 0:u.canvasRender)==null?void 0:N.calcCellAutoHeight)==null?void 0:H.call(N,W)},e.interceptorAutoWidth=()=>{var x,P,F,k,N,H;const C=(P=(x=this._renderManagerService.getRenderById(i))==null?void 0:x.with(B.SheetSkeletonManagerService).getSkeletonParam(s))==null?void 0:P.skeleton;if(!C)return;const E=C.worksheet.getMergedCell(n,a),W={data:e,style:C.getStyles().getStyleByCell(e),primaryWithCoord:C.getCellWithCoordByIndex((F=E==null?void 0:E.startRow)!=null?F:n,(k=E==null?void 0:E.startColumn)!=null?k:a),unitId:i,subUnitId:s,row:n,col:a,workbook:d,worksheet:l};return(H=(N=u==null?void 0:u.canvasRender)==null?void 0:N.calcCellAutoWidth)==null?void 0:H.call(N,W)},e.coverable=((w=e==null?void 0:e.coverable)!=null?w:!0)&&!(h.type===o.DataValidationType.LIST||h.type===o.DataValidationType.LIST_MULTIPLE),r(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(r=>{var n;(r.rule.type===o.DataValidationType.LIST_MULTIPLE||r.rule.type===o.DataValidationType.LIST)&&(n=r.rule)!=null&&n.ranges&&t.push(...r.rule.ranges)}),t.length){const r=this._autoHeightController.getUndoRedoParamsOfAutoHeight(t);o.sequenceExecute(r.redos,this._commandService)}})}};be=ft([G(0,o.ICommandService),G(1,b.IMenuManagerService),G(2,R.IRenderManagerService),G(3,o.IUniverInstanceService),G(4,o.Inject(B.AutoHeightController)),G(5,o.Inject(ge)),G(6,o.Inject(m.SheetDataValidationModel)),G(7,o.Inject(X.DataValidatorRegistryService)),G(8,o.Inject($.SheetInterceptorService)),G(9,o.Inject(m.DataValidationCacheService)),G(10,o.Optional(B.IEditorBridgeService))],be);let St=class extends o.RxDisposable{constructor(e,t,r,n,a,i,s){super(),this._commandService=e,this._renderManagerService=t,this._autoHeightController=r,this._dataValidatorRegistryService=n,this._sheetInterceptorService=a,this._sheetDataValidationModel=i,this._dataValidationCacheService=s,this._initViewModelIntercept(),this._initAutoHeight()}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept($.INTERCEPTOR_POINT.CELL_CONTENT,{effect:o.InterceptorEffectEnum.Style,priority:$.InterceptCellContentPriority.DATA_VALIDATION,handler:(e,t,r)=>{var T,f,y,S,D;const{row:n,col:a,unitId:i,subUnitId:s,workbook:d,worksheet:l}=t,c=this._sheetDataValidationModel.getRuleIdByLocation(i,s,n,a);if(!c)return r(e);const h=this._sheetDataValidationModel.getRuleById(i,s,c);if(!h)return r(e);const p=(T=this._dataValidationCacheService.getValue(i,s,n,a))!=null?T:o.DataValidationStatus.VALID,u=this._dataValidatorRegistryService.getValidatorItem(h.type),I=l.getCellRaw(n,a),g=m.getCellValueOrigin(I),O=`${g!=null?g:""}`;return(!e||e===t.rawData)&&(e={...t.rawData}),e.markers={...e==null?void 0:e.markers,...p===o.DataValidationStatus.INVALID?mt:null},e.customRender=[...(f=e==null?void 0:e.customRender)!=null?f:[],...u!=null&&u.canvasRender?[u.canvasRender]:[]],e.fontRenderExtension={...e==null?void 0:e.fontRenderExtension,isSkip:((y=e==null?void 0:e.fontRenderExtension)==null?void 0:y.isSkip)||((S=u==null?void 0:u.skipDefaultFontRender)==null?void 0:S.call(u,h,g,t))},e.interceptorStyle={...e==null?void 0:e.interceptorStyle,...u==null?void 0:u.getExtraStyle(h,O,{get style(){const w=d.getStyles();return(typeof(e==null?void 0:e.s)=="string"?w.get(e==null?void 0:e.s):e==null?void 0:e.s)||{}}},n,a)},e.interceptorAutoHeight=()=>{var W,x,P,F,k,N;const w=(x=(W=this._renderManagerService.getRenderById(i))==null?void 0:W.with(B.SheetSkeletonManagerService).getSkeletonParam(s))==null?void 0:x.skeleton;if(!w)return;const C=w.worksheet.getMergedCell(n,a),E={data:e,style:w.getStyles().getStyleByCell(e),primaryWithCoord:w.getCellWithCoordByIndex((P=C==null?void 0:C.startRow)!=null?P:n,(F=C==null?void 0:C.startColumn)!=null?F:a),unitId:i,subUnitId:s,row:n,col:a,workbook:d,worksheet:l};return(N=(k=u==null?void 0:u.canvasRender)==null?void 0:k.calcCellAutoHeight)==null?void 0:N.call(k,E)},e.interceptorAutoWidth=()=>{var W,x,P,F,k,N;const w=(x=(W=this._renderManagerService.getRenderById(i))==null?void 0:W.with(B.SheetSkeletonManagerService).getSkeletonParam(s))==null?void 0:x.skeleton;if(!w)return;const C=w.worksheet.getMergedCell(n,a),E={data:e,style:w.getStyles().getStyleByCell(e),primaryWithCoord:w.getCellWithCoordByIndex((P=C==null?void 0:C.startRow)!=null?P:n,(F=C==null?void 0:C.startColumn)!=null?F:a),unitId:i,subUnitId:s,row:n,col:a,workbook:d,worksheet:l};return(N=(k=u==null?void 0:u.canvasRender)==null?void 0:k.calcCellAutoWidth)==null?void 0:N.call(k,E)},e.coverable=((D=e==null?void 0:e.coverable)!=null?D:!0)&&!(h.type===o.DataValidationType.LIST||h.type===o.DataValidationType.LIST_MULTIPLE),r(e)}}))}_initAutoHeight(){this._sheetDataValidationModel.ruleChange$.pipe(ie.filter(e=>e.source==="command"),ie.bufferTime(16)).subscribe(e=>{const t=[];if(e.forEach(r=>{var n;(r.rule.type===o.DataValidationType.LIST_MULTIPLE||r.rule.type===o.DataValidationType.LIST)&&(n=r.rule)!=null&&n.ranges&&t.push(...r.rule.ranges)}),t.length){const r=this._autoHeightController.getUndoRedoParamsOfAutoHeight(t);o.sequenceExecute(r.redos,this._commandService)}})}};St=ft([G(0,o.ICommandService),G(1,R.IRenderManagerService),G(2,o.Inject(B.AutoHeightController)),G(3,o.Inject(X.DataValidatorRegistryService)),G(4,o.Inject($.SheetInterceptorService)),G(5,o.Inject(m.SheetDataValidationModel)),G(6,o.Inject(m.DataValidationCacheService))],St);var en=Object.getOwnPropertyDescriptor,tn=(e,t,r,n)=>{for(var a=n>1?void 0:n?en(t,r):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(a=s(a)||a);return a},_t=(e,t)=>(r,n)=>t(r,n,e);let Ne=class extends o.Disposable{constructor(e,t,r){super(),this._context=e,this._sheetDataValidationModel=t,this._sheetSkeletonManagerService=r,this._initSkeletonChange()}_initSkeletonChange(){const e=t=>{var n;if(!t.length)return;const r=new Set;t.forEach(a=>{r.add(a.subUnitId)}),r.forEach(a=>{var i;(i=this._sheetSkeletonManagerService.getSkeletonParam(a))==null||i.skeleton.makeDirty(!0)}),(n=this._context.mainComponent)==null||n.makeForceDirty()};this.disposeWithMe(this._sheetDataValidationModel.validStatusChange$.pipe(o.bufferDebounceTime(16)).subscribe(e))}};Ne=tn([_t(1,o.Inject(m.SheetDataValidationModel)),_t(2,o.Inject(B.SheetSkeletonManagerService))],Ne);var oe=function(){return oe=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++){t=arguments[r];for(var a in t)Object.prototype.hasOwnProperty.call(t,a)&&(e[a]=t[a])}return e},oe.apply(this,arguments)},nn=function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var a=0,n=Object.getOwnPropertySymbols(e);a<n.length;a++)t.indexOf(n[a])<0&&Object.prototype.propertyIsEnumerable.call(e,n[a])&&(r[n[a]]=e[n[a]]);return r},Se=V.forwardRef(function(e,t){var r=e.icon,n=e.id,a=e.className,i=e.extend,s=nn(e,["icon","id","className","extend"]),d="univerjs-icon univerjs-icon-".concat(n," ").concat(a||"").trim(),l=V.useRef("_".concat(on()));return It(r,"".concat(n),{defIds:r.defIds,idSuffix:l.current},oe({ref:t,className:d},s),i)});function It(e,t,r,n,a){return V.createElement(e.tag,oe(oe({key:t},rn(e,r,a)),n),(an(e,r).children||[]).map(function(i,s){return It(i,"".concat(t,"-").concat(e.tag,"-").concat(s),r,void 0,a)}))}function rn(e,t,r){var n=oe({},e.attrs);r!=null&&r.colorChannel1&&n.fill==="colorChannel1"&&(n.fill=r.colorChannel1),e.tag==="mask"&&n.id&&(n.id=n.id+t.idSuffix),Object.entries(n).forEach(function(i){var s=i[0],d=i[1];s==="mask"&&typeof d=="string"&&(n[s]=d.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))});var a=t.defIds;return!a||a.length===0||(e.tag==="use"&&n["xlink:href"]&&(n["xlink:href"]=n["xlink:href"]+t.idSuffix),Object.entries(n).forEach(function(i){var s=i[0],d=i[1];typeof d=="string"&&(n[s]=d.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))})),n}function an(e,t){var r,n=t.defIds;return!n||n.length===0?e:e.tag==="defs"&&(!((r=e.children)===null||r===void 0)&&r.length)?oe(oe({},e),{children:e.children.map(function(a){return typeof a.attrs.id=="string"&&n&&n.includes(a.attrs.id)?oe(oe({},a),{attrs:oe(oe({},a.attrs),{id:a.attrs.id+t.idSuffix})}):a})}):e}function on(){return Math.random().toString(36).substring(2,8)}Se.displayName="UniverIcon";var sn={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"}}]},Ct=V.forwardRef(function(e,t){return V.createElement(Se,Object.assign({},e,{id:"data-validation-icon",ref:t,icon:sn}))});Ct.displayName="DataValidationIcon";var ln={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"}}]},et=V.forwardRef(function(e,t){return V.createElement(Se,Object.assign({},e,{id:"delete-icon",ref:t,icon:ln}))});et.displayName="DeleteIcon";var dn={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"}}]},yt=V.forwardRef(function(e,t){return V.createElement(Se,Object.assign({},e,{id:"increase-icon",ref:t,icon:dn}))});yt.displayName="IncreaseIcon";var cn={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"}}]},tt=V.forwardRef(function(e,t){return V.createElement(Se,Object.assign({},e,{id:"more-down-icon",ref:t,icon:cn}))});tt.displayName="MoreDownIcon";var 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:"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"}}]},wt=V.forwardRef(function(e,t){return V.createElement(Se,Object.assign({},e,{id:"more-up-icon",ref:t,icon:un}))});wt.displayName="MoreUpIcon";var hn={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"mask",attrs:{id:"mask0_622_8",width:16,height:16,x:0,y:0,maskUnits:"userSpaceOnUse"},children:[{tag:"path",attrs:{fill:"#D9D9D9",d:"M0 0H16V16H0z"}}]},{tag:"g",attrs:{fill:"currentColor",mask:"url(#mask0_622_8)"},children:[{tag:"path",attrs:{d:"M6 5C6.55228 5 7 4.55228 7 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:{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:{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:{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:{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:{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"}}]}]},Dt=V.forwardRef(function(e,t){return V.createElement(Se,Object.assign({},e,{id:"sequence-icon",ref:t,icon:hn}))});Dt.displayName="SequenceIcon";function vn(e){var c;const t=b.useDependency(o.LocaleService),r=b.useDependency(b.ComponentManager),{value:n,onChange:a,extraComponent:i}=e,[s,d]=V.useState(!1),l=i?r.get(i):null;return v.jsxs(v.Fragment,{children:[v.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:()=>d(!s),children:[t.t("dataValidation.panel.options"),s?v.jsx(wt,{className:"univer-ml-1"}):v.jsx(tt,{className:"univer-ml-1"})]}),s&&v.jsxs(v.Fragment,{children:[l?v.jsx(l,{value:n,onChange:a}):null,v.jsx(M.FormLayout,{label:t.t("dataValidation.panel.invalid"),children:v.jsxs(M.RadioGroup,{value:`${(c=n.errorStyle)!=null?c:o.DataValidationErrorStyle.WARNING}`,onChange:h=>a({...n,errorStyle:+h}),children:[v.jsx(M.Radio,{value:`${o.DataValidationErrorStyle.WARNING}`,children:t.t("dataValidation.panel.showWarning")}),v.jsx(M.Radio,{value:`${o.DataValidationErrorStyle.STOP}`,children:t.t("dataValidation.panel.rejectInput")})]})}),v.jsx(M.FormLayout,{label:t.t("dataValidation.panel.messageInfo"),children:v.jsx(M.Checkbox,{checked:n.showErrorMessage,onChange:()=>a({...n,showErrorMessage:!n.showErrorMessage}),children:t.t("dataValidation.panel.showInfo")})}),n.showErrorMessage?v.jsx(M.FormLayout,{children:v.jsx(M.Input,{value:n.error,onChange:h=>a({...n,error:h})})}):null]})]})}const pn=e=>o.debounce(async(t,r,n,a)=>{const i=await e.executeCommand(t,r,n);a==null||a(i)},1e3);function gn(e,t,r){var n,a,i,s;return t?((a=(n=e.getUnit(t))==null?void 0:n.getSheetBySheetName(r))==null?void 0:a.getSheetId())||"":((s=(i=e.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET))==null?void 0:i.getSheetBySheetName(r))==null?void 0:s.getSheetId())||""}function fn(){var A,Y;const[e,t]=V.useState(0),r=b.useDependency(ue),n=b.useObservable(r.activeRule$,r.activeRule),{unitId:a,subUnitId:i,rule:s}=n||{},d=s.uid,l=b.useDependency(X.DataValidatorRegistryService),c=b.useDependency(o.IUniverInstanceService),h=b.useDependency(b.ComponentManager),p=b.useDependency(o.ICommandService),u=b.useDependency(X.DataValidationModel),I=b.useDependency(o.LocaleService),[g,O]=V.useState(s),T=l.getValidatorItem(g.type),[f,y]=V.useState(!1),S=l.getValidatorsByScope(X.DataValidatorRegistryScope.SHEET),[D,w]=V.useState(()=>g.ranges.map(_=>({unitId:"",sheetId:"",range:_}))),C=V.useMemo(()=>pn(p),[p]),[E,W]=V.useState(!1),[x,P]=V.useState(!1),F=V.useRef(null),k=b.useDependency($.SheetsSelectionsService);if(V.useEffect(()=>()=>{const _=k.getCurrentLastSelection();_&&k.setSelections([_])},[k]),V.useEffect(()=>{p.onCommandExecuted(_=>{(_.id===o.UndoCommand.id||_.id===o.RedoCommand.id)&&setTimeout(()=>{const j=u.getRuleById(a,i,d);t(z=>z+1),j&&(O(j),w(j.ranges.map(z=>({unitId:"",sheetId:"",range:z}))))},20)})},[p,u,d,i,a]),!T)return null;const N=T.operators,H=T.operatorNames,Z=g.operator?X.TWO_FORMULA_OPERATOR_COUNT.includes(g.operator):!1,K=()=>{var _,j,z;(j=(_=F.current)==null?void 0:_.editor)!=null&&j.isFocus()&&te((z=F.current)==null?void 0:z.getValue()),!(!g.ranges.length||E)&&(T.validatorFormula(g,a,i).success?r.setActiveRule(null):y(!0))},te=b.useEvent(_=>{const j=_.split(",").filter(Boolean).map(Xe.deserializeRangeWithSheet).map(re=>{const Pt=re.sheetName;if(Pt){const dr=gn(c,re.unitId,Pt);return{...re,sheetId:dr}}return{...re,sheetId:""}});if(o.isUnitRangesEqual(j,D))return;w(j);const z=j.filter(re=>(!re.unitId||re.unitId===a)&&(!re.sheetId||re.sheetId===i)).map(re=>re.range);if(O({...g,ranges:z}),z.length===0)return;const pe={unitId:a,subUnitId:i,ruleId:d,ranges:z};C(m.UpdateSheetDataValidationRangeCommand.id,pe)}),ae=_=>{if(o.shallowEqual(_,X.getRuleSetting(g)))return;O({...g,..._});const j={unitId:a,subUnitId:i,ruleId:d,setting:_};C(m.UpdateSheetDataValidationSettingCommand.id,j,void 0)},se=async()=>{await p.executeCommand(m.RemoveSheetDataValidationCommand.id,{ruleId:d,unitId:a,subUnitId:i}),r.setActiveRule(null)},ce={type:g.type,operator:g.operator,formula1:g.formula1,formula2:g.formula2,allowBlank:g.allowBlank},J=_=>{const j=l.getValidatorItem(_);if(!j)return;const z=j.operators,pe=u.getRuleById(a,i,d),re=_===(pe==null?void 0:pe.type)||_.includes("list")&&(pe!=null&&pe.type.includes("list"))?{...pe,type:_}:{...g,type:_,operator:z[0],formula1:void 0,formula2:void 0};O(re),p.executeCommand(m.UpdateSheetDataValidationSettingCommand.id,{unitId:a,subUnitId:i,ruleId:g.uid,setting:X.getRuleSetting(re)})},q=h.get(T.formulaInput),ve=V.useMemo(()=>D.map(_=>Xe.serializeRange(_.range)).join(","),[]),ne=X.getRuleOptions(g),ee=_=>{o.shallowEqual(_,X.getRuleOptions(g))||(O({...g,..._}),C(m.UpdateSheetDataValidationOptionsCommand.id,{unitId:a,subUnitId:i,ruleId:d,options:_}))},Q=N.length&&!g.operator;return v.jsxs("div",{"data-u-comp":"data-validation-detail",className:"univer-py-2",children:[v.jsx(M.FormLayout,{label:I.t("dataValidation.panel.range"),error:!g.ranges.length||E?I.t("dataValidation.panel.rangeError"):"",children:v.jsx(ze.RangeSelector,{selectorRef:F,unitId:a,subUnitId:i,initialValue:ve,onChange:(_,j)=>{var z;!x&&((z=F.current)!=null&&z.verify())&&te(j)},onFocusChange:(_,j)=>{var z;P(_),!_&&j&&((z=F.current)!=null&&z.verify())&&te(j)},onVerify:_=>W(!_)})}),v.jsx(M.FormLayout,{label:I.t("dataValidation.panel.type"),children:v.jsx(M.Select,{className:"univer-w-full",value:g.type,options:(A=S==null?void 0:S.sort((_,j)=>_.order-j.order))==null?void 0:A.map(_=>({label:I.t(_.title),value:_.id})),onChange:J})}),N!=null&&N.length?v.jsx(M.FormLayout,{label:I.t("dataValidation.panel.operator"),children:v.jsx(M.Select,{className:"univer-w-full",value:`${g.operator}`,options:[{value:"",label:I.t("dataValidation.operators.legal")},...N.map((_,j)=>({value:`${_}`,label:H[j]}))],onChange:_=>{ae({...ce,operator:_})}})}):null,q&&!Q?v.jsx(q,{isTwoFormula:Z,value:{formula1:g.formula1,formula2:g.formula2},onChange:_=>{ae({...ce,..._})},showError:f,validResult:T.validatorFormula(g,a,i),unitId:a,subUnitId:i,ruleId:d},e+g.type):null,v.jsx(M.FormLayout,{children:v.jsx(M.Checkbox,{checked:(Y=g.allowBlank)!=null?Y:!0,onChange:()=>{var _;return ae({...ce,allowBlank:!((_=g.allowBlank)==null||_)})},children:I.t("dataValidation.panel.allowBlank")})}),v.jsx(vn,{value:ne,onChange:ee,extraComponent:T.optionsInput}),v.jsxs("div",{className:"univer-mt-5 univer-flex univer-flex-row univer-justify-end",children:[v.jsx(M.Button,{className:"univer-ml-3",onClick:se,children:I.t("dataValidation.panel.removeRule")}),v.jsx(M.Button,{className:"univer-ml-3",variant:"primary",onClick:K,children:I.t("dataValidation.panel.done")})]})]})}const mn=e=>{const{rule:t,onClick:r,unitId:n,subUnitId:a,disable:i}=e,s=b.useDependency(X.DataValidatorRegistryService),d=b.useDependency(o.ICommandService),l=b.useDependency(B.IMarkSelectionService),c=s.getValidatorItem(t.type),h=V.useRef(void 0),[p,u]=V.useState(!1),I=b.useDependency(o.ThemeService),g=b.useObservable(I.currentTheme$),O=V.useMemo(()=>{var w;const f=I.getColorFromTheme("primary.600"),y=I.getColorFromTheme("loop-color.2"),S=(w=I.getColorFromTheme(y))!=null?w:f,D=new o.ColorKit(S).toRgb();return{fill:`rgba(${D.r}, ${D.g}, ${D.b}, 0.1)`,stroke:S}},[g]),T=f=>{d.executeCommand(m.RemoveSheetDataValidationCommand.id,{ruleId:t.uid,unitId:n,subUnitId:a}),f.stopPropagation()};return V.useEffect(()=>()=>{var f;h.current&&((f=h.current)==null||f.forEach(y=>{y&&l.removeShape(y)}))},[l]),v.jsxs("div",{className:M.clsx(`
2
2
  univer-bg-secondary univer-relative univer--ml-2 univer--mr-2 univer-box-border univer-flex
3
3
  univer-w-[287px] univer-cursor-pointer univer-flex-col univer-justify-between univer-overflow-hidden
4
4
  univer-rounded-md univer-p-2 univer-pr-9
5
- `,{"hover:univer-bg-gray-50 dark:hover:!univer-bg-gray-700":!i,"univer-opacity-50":i}),onClick:r,onMouseEnter:()=>{i||(u(!0),h.current=t.ranges.map(f=>l.addShape({range:f,style:O,primary:null})))},onMouseLeave:()=>{var f;u(!1),(f=h.current)==null||f.forEach(y=>{y&&l.removeShape(y)}),h.current=void 0},children:[v.jsx("div",{className:"univer-truncate univer-text-sm univer-font-medium univer-leading-[22px] univer-text-gray-900 dark:!univer-text-white",children:c==null?void 0:c.generateRuleName(t)}),v.jsx("div",{className:"univer-text-secondary univer-truncate univer-text-xs univer-leading-[18px] dark:!univer-text-gray-300",children:t.ranges.map(f=>Xe.serializeRange(f)).join(",")}),p?v.jsx("div",{className:"univer-absolute univer-right-2 univer-top-[19px] univer-flex univer-h-5 univer-w-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:T,children:v.jsx(et,{})}):null]})};function Sn(e){const t=b.useDependency(m.SheetDataValidationModel),r=b.useDependency(o.IUniverInstanceService),n=b.useDependency(o.ICommandService),a=b.useDependency(o.Injector),i=b.useDependency(ue),s=b.useDependency(o.LocaleService),[d,l]=V.useState([]),{workbook:c}=e,h=b.useObservable(c.activeSheet$,void 0,!0),p=c.getUnitId(),u=h==null?void 0:h.getSheetId();V.useEffect(()=>{l(t.getRules(p,u));const y=t.ruleChange$.subscribe(S=>{S.unitId===p&&S.subUnitId===u&&l(t.getRules(p,u))});return()=>{y.unsubscribe()}},[p,u,t]);const I=async()=>{const y=m.createDefaultNewRule(a),S={unitId:p,subUnitId:u,rule:y};await n.executeCommand(m.AddSheetDataValidationCommand.id,S),i.setActiveRule({unitId:p,subUnitId:u,rule:y})},g=()=>{n.executeCommand(m.RemoveSheetAllDataValidationCommand.id,{unitId:p,subUnitId:u})},T=(y=>{const S=r.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET),D=S.getActiveSheet(),w=S.getUnitId(),C=D.getSheetId();return y.map(W=>$.checkRangesEditablePermission(a,w,C,W.ranges)?{...W}:{...W,disable:!0})})(d),f=T==null?void 0:T.some(y=>y.disable);return v.jsxs("div",{className:"univer-pb-4",children:[T==null?void 0:T.map(y=>{var S;return v.jsx(mn,{unitId:p,subUnitId:u,onClick:()=>{y.disable||i.setActiveRule({unitId:p,subUnitId:u,rule:y})},rule:y,disable:(S=y.disable)!=null?S:!1},y.uid)}),v.jsxs("div",{className:"univer-mt-4 univer-flex univer-flex-row univer-justify-end univer-gap-2",children:[d.length&&!f?v.jsx(M.Button,{onClick:g,children:s.t("dataValidation.panel.removeAll")}):null,v.jsx(M.Button,{variant:"primary",onClick:I,children:s.t("dataValidation.panel.add")})]})]})}const _n=()=>{const e=b.useDependency(ue),t=b.useObservable(e.activeRule$,e.activeRule),r=b.useDependency(o.IUniverInstanceService),n=b.useObservable(()=>r.getCurrentTypeOfUnit$(o.UniverInstanceType.UNIVER_SHEET),void 0,void 0,[]),a=b.useObservable(()=>{var i;return(i=n==null?void 0:n.activeSheet$)!=null?i:ie.of(null)},void 0,void 0,[]);return!n||!a?null:t&&t.subUnitId===a.getSheetId()?v.jsx(fn,{},t.rule.uid):v.jsx(Sn,{workbook:n})},In=e=>{const{isTwoFormula:t=!1,value:r,onChange:n,showError:a,validResult:i}=e,s=b.useDependency(o.LocaleService),d=a?i==null?void 0:i.formula1:"",l=a?i==null?void 0:i.formula2:"";return t?v.jsxs(v.Fragment,{children:[v.jsx(M.FormLayout,{error:d,children:v.jsx(M.Input,{className:"univer-w-full",placeholder:s.t("dataValidation.panel.formulaPlaceholder"),value:r==null?void 0:r.formula1,onChange:c=>{n==null||n({...r,formula1:c})}})}),v.jsx("div",{className:"-univer-mt-2 univer-mb-1 univer-text-sm univer-text-gray-400",children:s.t("dataValidation.panel.formulaAnd")}),v.jsx(M.FormLayout,{error:l,children:v.jsx(M.Input,{className:"univer-w-full",placeholder:s.t("dataValidation.panel.formulaPlaceholder"),value:r==null?void 0:r.formula2,onChange:c=>{n==null||n({...r,formula2:c})}})})]}):v.jsx(M.FormLayout,{error:d,children:v.jsx(M.Input,{className:"univer-w-full",placeholder:s.t("dataValidation.panel.formulaPlaceholder"),value:r==null?void 0:r.formula1,onChange:c=>{n==null||n({formula1:c})}})})};function Cn(e){const{value:t,onChange:r,showError:n,validResult:a}=e,i=b.useDependency(o.LocaleService),s=n?a==null?void 0:a.formula1:"",d=n?a==null?void 0:a.formula2:"",[l,c]=V.useState(!((t==null?void 0:t.formula1)===void 0&&(t==null?void 0:t.formula2)===void 0));return v.jsxs(v.Fragment,{children:[v.jsx(M.FormLayout,{children:v.jsx(M.Checkbox,{checked:l,onChange:h=>{h?c(!0):(c(!1),r==null||r({...t,formula1:void 0,formula2:void 0}))},children:i.t("dataValidation.checkbox.tips")})}),l?v.jsx(M.FormLayout,{label:i.t("dataValidation.checkbox.checked"),error:s,children:v.jsx(M.Input,{className:"univer-w-full",placeholder:i.t("dataValidation.panel.valuePlaceholder"),value:t==null?void 0:t.formula1,onChange:h=>{r==null||r({...t,formula1:h||void 0})}})}):null,l?v.jsx(M.FormLayout,{label:i.t("dataValidation.checkbox.unchecked"),error:d,children:v.jsx(M.Input,{className:"univer-w-full",placeholder:i.t("dataValidation.panel.valuePlaceholder"),value:t==null?void 0:t.formula2,onChange:h=>{r==null||r({...t,formula2:h||void 0})}})}):null]})}function yn(e){var p;const{unitId:t,subUnitId:r,value:n,onChange:a,showError:i,validResult:s}=e,d=i?s==null?void 0:s.formula1:void 0,l=V.useRef(null),[c,h]=V.useState(!1);return b.useSidebarClick(u=>{var g;((g=l.current)==null?void 0:g.isClickOutSide(u))&&h(!1)}),v.jsx(M.FormLayout,{error:d,children:v.jsx(ze.FormulaEditor,{ref:l,className:M.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",M.borderClassName),initValue:(p=n==null?void 0:n.formula1)!=null?p:"=",unitId:t,subUnitId:r,isFocus:c,isSupportAcrossSheet:!0,onChange:u=>{const I=(u!=null?u:"").trim();I!==(n==null?void 0:n.formula1)&&(a==null||a({...n,formula1:I}))},onFocus:()=>h(!0)})})}const Te="#ECECEC",wn=["#FFFFFF","#FEE7E7","#FEF0E6","#EFFBD0","#E4F4FE","#E8ECFD","#F1EAFA","#FDE8F3","#E5E5E5","#FDCECE","#FDC49B","#DEF6A2","#9FDAFF","#D0D9FB","#E3D5F6","#FBD0E8","#656565","#FE4B4B","#FF8C51","#8BBB11","#0B9EFB","#3A60F7","#9E6DE3","#F248A6"],Dn=e=>{const{value:t,onChange:r,disabled:n}=e,[a,i]=V.useState(!1);return v.jsx(M.Dropdown,{align:"start",disabled:n,open:a,onOpenChange:i,overlay:v.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:wn.map(s=>v.jsx("div",{className:M.clsx("univer-box-border univer-size-4 univer-cursor-pointer univer-rounded",M.borderClassName),style:{background:s},onClick:()=>{r(s),i(!1)}},s))}),children:v.jsxs("div",{className:M.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",M.borderClassName),children:[v.jsx("div",{className:"univer-box-border univer-h-4 univer-w-4 univer-rounded univer-text-base",style:{background:t}}),v.jsx(tt,{})]})})},Et=e=>{const{item:t,commonProps:r,className:n}=e,{onItemChange:a,onItemDelete:i}=r;return v.jsxs("div",{className:M.clsx("univer-flex univer-items-center univer-gap-2",n),children:[!t.isRef&&v.jsx("div",{className:M.clsx("univer-cursor-move","draggableHandle"),children:v.jsx(Dt,{})}),v.jsx(Dn,{value:t.color,onChange:s=>{a(t.id,t.label,s)}}),v.jsx(M.Input,{disabled:t.isRef,value:t.label,onChange:s=>{a(t.id,s,t.color)}}),t.isRef?null:v.jsx("div",{className:"univer-ml-1 univer-cursor-pointer univer-rounded univer-text-base hover:univer-bg-gray-200",children:v.jsx(et,{onClick:()=>i(t.id)})})]})};function En(e){const{value:t,onChange:r=()=>{},unitId:n,subUnitId:a,validResult:i,showError:s,ruleId:d}=e,{formula1:l="",formula2:c=""}=t||{},[h,p]=V.useState(()=>o.isFormulaString(l)?"1":"0"),[u,I]=V.useState(h==="1"?l:"="),[g,O]=V.useState(h==="1"?l:"="),T=b.useDependency(o.LocaleService),f=b.useDependency(X.DataValidatorRegistryService),y=b.useDependency(X.DataValidationModel),S=b.useDependency(m.DataValidationFormulaController),[D,w]=V.useState(()=>c.split(",")),C=f.getValidatorItem(o.DataValidationType.LIST),[E,W]=V.useState([]),[x,P]=V.useState(""),F=s?i==null?void 0:i.formula1:"",k=V.useMemo(()=>y.ruleChange$.pipe(ie.debounceTime(16)),[]),N=b.useObservable(k),H=b.useEvent(r);V.useEffect(()=>{(async()=>{await new Promise(_=>{setTimeout(()=>_(!0),100)});const A=y.getRuleById(n,a,d),Y=A==null?void 0:A.formula1;if(o.isFormulaString(Y)&&C&&A){const _=await C.getListAsync(A,n,a);W(_)}})()},[y,N,C,d,a,n]),V.useEffect(()=>{o.isFormulaString(l)&&l!==g&&(I(l),O(g))},[g,l]);const[Z,K]=V.useState(()=>{const A=h!=="1"?m.deserializeListOptions(l):[],Y=c.split(",");return A.map((_,j)=>({label:_,color:Y[j]||Te,isRef:!1,id:o.Tools.generateRandomId(4)}))}),te=(A,Y,_)=>{const j=Z.find(z=>z.id===A);j&&(j.label=Y,j.color=_,K([...Z]))},ae=A=>{const Y=Z.findIndex(_=>_.id===A);Y!==-1&&(Z.splice(Y,1),K([...Z]))},se=c.split(","),ce=V.useMemo(()=>E.map((A,Y)=>({label:A,color:se[Y]||Te,id:`${Y}`,isRef:!0})),[se,E]),J=(A,Y,_)=>{const j=[...D];j[+A]=_,w(j),H({formula1:l,formula2:j.join(",")})},q=()=>{K([...Z,{label:"",color:Te,isRef:!1,id:o.Tools.generateRandomId(4)}])};V.useEffect(()=>{if(h==="1")return;const A=new Set,Y=[];Z.map(_=>({labelList:_.label.split(","),item:_})).forEach(({item:_,labelList:j})=>{j.forEach(z=>{A.has(z)||(A.add(z),Y.push({label:z,color:_.color}))})}),H({formula1:m.serializeListOptions(Y.map(_=>_.label)),formula2:Y.map(_=>_.color===Te?"":_.color).join(",")})},[Z,H,h,g,D]);const ve=b.useEvent(async A=>{if(!o.isFormulaString(A)){H==null||H({formula1:"",formula2:c});return}S.getFormulaRefCheck(A)?(H==null||H({formula1:o.isFormulaString(A)?A:"",formula2:c}),P("")):(H==null||H({formula1:"",formula2:c}),I("="),P(T.t("dataValidation.validFail.formulaError")))}),ne=V.useRef(null),[ee,Q]=V.useState(!1);return b.useSidebarClick(A=>{var _;((_=ne.current)==null?void 0:_.isClickOutSide(A))&&Q(!1)}),v.jsxs(v.Fragment,{children:[v.jsx(M.FormLayout,{label:T.t("dataValidation.list.options"),children:v.jsxs(M.RadioGroup,{value:h,onChange:A=>{p(A),I(g),A==="1"&&H({formula1:g==="="?"":g,formula2:D.join(",")})},children:[v.jsx(M.Radio,{value:"0",children:T.t("dataValidation.list.customOptions")}),v.jsx(M.Radio,{value:"1",children:T.t("dataValidation.list.refOptions")})]})}),h==="1"?v.jsxs(M.FormLayout,{error:F||x||void 0,children:[v.jsx(ze.FormulaEditor,{ref:ne,className:M.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",M.borderClassName),initValue:u,unitId:n,subUnitId:a,isFocus:ee,isSupportAcrossSheet:!0,onFocus:()=>Q(!0),onChange:(A="")=>{const Y=(A!=null?A:"").trim();O(Y),ve(Y)}}),ce.length>0&&v.jsx("div",{className:"univer-mt-3",children:ce.map(A=>v.jsx(Et,{className:"univer-mb-3",item:A,commonProps:{onItemChange:J}},A.id))})]}):v.jsx(M.FormLayout,{error:F,children:v.jsxs("div",{className:"-univer-mt-3",children:[v.jsx(M.DraggableList,{list:Z,onListChange:K,rowHeight:28,margin:[0,12],draggableHandle:".draggableHandle",itemRender:A=>v.jsx(Et,{item:A,commonProps:{onItemChange:te,onItemDelete:ae}},A.id),idKey:"id"}),v.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:q,children:[v.jsx(yt,{className:"univer-mr-1"}),T.t("dataValidation.list.add")]})]})})]})}const Mn=[[m.CUSTOM_FORMULA_INPUT_NAME,yn],[m.BASE_FORMULA_INPUT_NAME,In],[m.LIST_FORMULA_INPUT_NAME,En],[m.CHECKBOX_FORMULA_INPUT_NAME,Cn]],bn="LIST_RENDER_MODE_OPTION_INPUT";function je(e){var a;const{value:t,onChange:r}=e,n=b.useDependency(o.LocaleService);return v.jsx(M.FormLayout,{label:n.t("dataValidation.renderMode.label"),children:v.jsxs(M.RadioGroup,{value:`${(a=t.renderMode)!=null?a:o.DataValidationRenderMode.CUSTOM}`,onChange:i=>r({...t,renderMode:+i}),children:[v.jsx(M.Radio,{value:`${o.DataValidationRenderMode.CUSTOM}`,children:n.t("dataValidation.renderMode.chip")}),v.jsx(M.Radio,{value:`${o.DataValidationRenderMode.ARROW}`,children:n.t("dataValidation.renderMode.arrow")}),v.jsx(M.Radio,{value:`${o.DataValidationRenderMode.TEXT}`,children:n.t("dataValidation.renderMode.text")})]})})}je.componentKey=bn;const Tn="DATE_SHOW_TIME_OPTION";function Be(e){var a;const{value:t,onChange:r}=e,n=b.useDependency(o.LocaleService);return v.jsx(M.FormLayout,{children:v.jsx(M.Checkbox,{checked:(a=t.bizInfo)==null?void 0:a.showTime,onChange:i=>{r({...t,bizInfo:{...t.bizInfo,showTime:i}})},children:n.t("dataValidation.showTime.label")})})}Be.componentKey=Tn;var Vn=Object.getOwnPropertyDescriptor,Rn=(e,t,r,n)=>{for(var a=n>1?void 0:n?Vn(t,r):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(a=s(a)||a);return a},Ve=(e,t)=>(r,n)=>t(r,n,e);const We=6;let nt=class{constructor(e,t,r,n,a,i){this._commandService=e,this._univerInstanceService=t,this._formulaService=r,this._themeService=n,this._renderManagerService=a,this._dataValidationModel=i}_calc(e,t){var c,h,p;const{vt:r,ht:n}=t||{},a=e.endX-e.startX-We*2,i=e.endY-e.startY,s=((c=t==null?void 0:t.fs)!=null?c:10)*1.6;let d=0,l=0;switch(r){case o.VerticalAlign.TOP:l=0;break;case o.VerticalAlign.BOTTOM:l=0+(i-s);break;default:l=0+(i-s)/2;break}switch(n){case o.HorizontalAlign.LEFT:d=We;break;case o.HorizontalAlign.RIGHT:d=We+(a-s);break;default:d=We+(a-s)/2;break}return{left:e.startX+d,top:e.startY+l,width:((h=t==null?void 0:t.fs)!=null?h:10)*1.6,height:((p=t==null?void 0:t.fs)!=null?p:10)*1.6}}calcCellAutoHeight(e){var r;const{style:t}=e;return((r=t==null?void 0:t.fs)!=null?r:10)*1.6}calcCellAutoWidth(e){var r;const{style:t}=e;return((r=t==null?void 0:t.fs)!=null?r:10)*1.6}async _parseFormula(e,t,r){var c,h,p,u,I,g,O,T,f;const{formula1:n=m.CHECKBOX_FORMULA_1,formula2:a=m.CHECKBOX_FORMULA_2}=e,i=await this._formulaService.getRuleFormulaResult(t,r,e.uid),s=m.getFormulaResult((p=(h=(c=i==null?void 0:i[0])==null?void 0:c.result)==null?void 0:h[0])==null?void 0:p[0]),d=m.getFormulaResult((g=(I=(u=i==null?void 0:i[1])==null?void 0:u.result)==null?void 0:I[0])==null?void 0:g[0]),l=m.isLegalFormulaResult(String(s))&&m.isLegalFormulaResult(String(d));return{formula1:o.isFormulaString(n)?m.getFormulaResult((f=(T=(O=i==null?void 0:i[0])==null?void 0:O.result)==null?void 0:T[0])==null?void 0:f[0]):n,formula2:o.isFormulaString(a)?d:a,isFormulaValid:l}}drawWith(e,t){var F,k,N,H;const{style:r,primaryWithCoord:n,unitId:a,subUnitId:i,worksheet:s,row:d,col:l}=t,c=n.isMergedMainCell?n.mergeInfo:n,h=m.getCellValueOrigin(s.getCellRaw(d,l)),p=this._dataValidationModel.getRuleByLocation(a,i,d,l);if(!p)return;const u=this._dataValidationModel.getValidator(p.type);if(!u||!((F=u.skipDefaultFontRender)!=null&&F.call(u,p,h,{unitId:a,subUnitId:i,row:d,column:l})))return;const I=u.parseFormulaSync(p,a,i),{formula1:g}=I,O=this._calc(c,r),{a:T,d:f}=e.getTransform(),y=R.fixLineWidthByScale(O.left,T),S=R.fixLineWidthByScale(O.top,f),D=R.Transform.create().composeMatrix({left:y,top:S,scaleX:1,scaleY:1,angle:0,skewX:0,skewY:0,flipX:!1,flipY:!1}),w=c.endX-c.startX,C=c.endY-c.startY;e.save(),e.beginPath(),e.rect(c.startX,c.startY,w,C),e.clip();const E=D.getMatrix();e.transform(E[0],E[1],E[2],E[3],E[4],E[5]);const W=((k=r==null?void 0:r.fs)!=null?k:10)*1.6,x=String(h)===String(g),P=this._themeService.getColorFromTheme("primary.600");R.CheckboxShape.drawWith(e,{checked:x,width:W,height:W,fill:(H=(N=r==null?void 0:r.cl)==null?void 0:N.rgb)!=null?H:P}),e.restore()}isHit(e,t){const r=t.primaryWithCoord.isMergedMainCell?t.primaryWithCoord.mergeInfo:t.primaryWithCoord,n=this._calc(r,t.style),a=n.top,i=n.top+n.height,s=n.left,d=n.left+n.width,{x:l,y:c}=e;return l<=d&&l>=s&&c<=i&&c>=a}async onPointerDown(e,t){var g;if(t.button===2)return;const{primaryWithCoord:r,unitId:n,subUnitId:a,worksheet:i,row:s,col:d}=e,l=m.getCellValueOrigin(i.getCellRaw(s,d)),c=this._dataValidationModel.getRuleByLocation(n,a,s,d);if(!c)return;const h=this._dataValidationModel.getValidator(c.type);if(!h||!((g=h.skipDefaultFontRender)!=null&&g.call(h,c,l,{unitId:n,subUnitId:a,row:s,column:d})))return;const{formula1:p,formula2:u}=await this._parseFormula(c,n,a),I={range:{startColumn:r.actualColumn,endColumn:r.actualColumn,startRow:r.actualRow,endRow:r.actualRow},value:{v:String(l)===m.transformCheckboxValue(String(p))?u:p,p:null}};this._commandService.executeCommand($.SetRangeValuesCommand.id,I)}onPointerEnter(e,t){var r,n;(n=(r=R.getCurrentTypeOfRenderer(o.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null?void 0:r.mainComponent)==null||n.setCursor(R.CURSOR_TYPE.POINTER)}onPointerLeave(e,t){var r,n;(n=(r=R.getCurrentTypeOfRenderer(o.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null?void 0:r.mainComponent)==null||n.setCursor(R.CURSOR_TYPE.DEFAULT)}};nt=Rn([Ve(0,o.ICommandService),Ve(1,o.IUniverInstanceService),Ve(2,o.Inject(m.DataValidationFormulaService)),Ve(3,o.Inject(o.ThemeService)),Ve(4,o.Inject(R.IRenderManagerService)),Ve(5,o.Inject(m.SheetDataValidationModel))],nt);var On=Object.getOwnPropertyDescriptor,Pn=(e,t,r,n)=>{for(var a=n>1?void 0:n?On(t,r):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(a=s(a)||a);return a},An=(e,t)=>(r,n)=>t(r,n,e);U.BaseSheetDataValidatorView=class{constructor(t){L(this,"canvasRender",null);L(this,"dropdownType");L(this,"optionsInput");L(this,"formulaInput",m.LIST_FORMULA_INPUT_NAME);this.injector=t}},U.BaseSheetDataValidatorView=Pn([An(0,o.Inject(o.Injector))],U.BaseSheetDataValidatorView);class Ln extends U.BaseSheetDataValidatorView{constructor(){super(...arguments);L(this,"id",o.DataValidationType.CHECKBOX);L(this,"canvasRender",this.injector.createInstance(nt));L(this,"formulaInput",m.CHECKBOX_FORMULA_INPUT_NAME)}}class Un extends U.BaseSheetDataValidatorView{constructor(){super(...arguments);L(this,"id",o.DataValidationType.CUSTOM);L(this,"formulaInput",m.CUSTOM_FORMULA_INPUT_NAME)}}const kn="data-validation.formula-input";class Fn extends U.BaseSheetDataValidatorView{constructor(){super(...arguments);L(this,"id",o.DataValidationType.DATE);L(this,"formulaInput",kn);L(this,"optionsInput",Be.componentKey);L(this,"dropdownType",X.DataValidatorDropdownType.DATE)}}class Nn extends U.BaseSheetDataValidatorView{constructor(){super(...arguments);L(this,"id",o.DataValidationType.DECIMAL);L(this,"formulaInput",m.BASE_FORMULA_INPUT_NAME)}}const Mt=4,jn=0,rt=4,bt=4,at=6,He=6,_e=14;function Bn(e,t){const r=R.FontCache.getTextSize(e,t),n=r.width+Mt*2,{ba:a,bd:i}=r,s=a+i;return{width:n,height:s+jn*2,ba:a}}function it(e,t,r,n){const a=_e+at*2,i=r-a,s=n-He*2,d=e.map(u=>({layout:Bn(u,t),text:u}));let l;const c=[];d.forEach(u=>{const{layout:I}=u,{width:g,height:O}=I;!l||l.width+g+rt>i?(l={width:g,height:O,items:[{...u,left:0}]},c.push(l)):(l.items.push({...u,left:l.width+rt}),l.width=l.width+g+rt)});let h=0,p=0;return c.forEach((u,I)=>{p=Math.max(p,u.width),I===c.length-1?h+=u.height:h+=u.height+bt}),{lines:c,totalHeight:h,contentWidth:i,contentHeight:s,cellAutoHeight:h+He*2,calcAutoWidth:p+a}}const Wn=8;class Hn extends R.Shape{static drawWith(t,r){const{fontString:n,info:a,fill:i,color:s}=r,{layout:d,text:l}=a;t.save(),R.Rect.drawWith(t,{width:d.width,height:d.height,radius:Wn,fill:i||Te}),t.translateWithPrecision(Mt,d.ba),t.font=n,t.fillStyle=s,t.fillText(l,0,0),t.restore()}}var xn=Object.getOwnPropertyDescriptor,$n=(e,t,r,n)=>{for(var a=n>1?void 0:n?xn(t,r):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(a=s(a)||a);return a},xe=(e,t)=>(r,n)=>t(r,n,e);const Yn=new Path2D("M3.32201 4.84556C3.14417 5.05148 2.85583 5.05148 2.67799 4.84556L0.134292 1.90016C-0.152586 1.56798 0.0505937 1 0.456301 1L5.5437 1C5.94941 1 6.15259 1.56798 5.86571 1.90016L3.32201 4.84556Z");let ot=class{constructor(e,t,r,n){L(this,"zIndex");L(this,"_dropdownInfoMap",new Map);this._commandService=e,this._univerInstanceService=t,this._renderManagerService=r,this._dataValidationModel=n}_ensureMap(e){let t=this._dropdownInfoMap.get(e);return t||(t=new Map,this._dropdownInfoMap.set(e,t)),t}_generateKey(e,t){return`${e}.${t}`}_drawDownIcon(e,t,r,n,a){const i=r-_e+4;let s=4;switch(a){case o.VerticalAlign.MIDDLE:s=(n-_e)/2+4;break;case o.VerticalAlign.BOTTOM:s=n-_e+4;break}e.save(),e.translateWithPrecision(t.startX+i,t.startY+s),e.fillStyle="#565656",e.fill(Yn),e.restore()}drawWith(e,t,r,n){var ae,se;const{primaryWithCoord:a,row:i,col:s,style:d,data:l,subUnitId:c}=t,h=a.isMergedMainCell?a.mergeInfo:a,p=l==null?void 0:l.fontRenderExtension,{leftOffset:u=0,rightOffset:I=0,topOffset:g=0,downOffset:O=0}=p||{},T=this._ensureMap(c),f=this._generateKey(i,s),y=this._dataValidationModel.getRuleByLocation(t.unitId,t.subUnitId,i,s);if(!y)return;const S=this._dataValidationModel.getValidator(y.type);if(!S)return;const D={startX:h.startX+u,endX:h.endX-I,startY:h.startY+g,endY:h.endY-O},w=D.endX-D.startX,C=D.endY-D.startY,{cl:E}=d||{},W=(ae=typeof E=="object"?E==null?void 0:E.rgb:E)!=null?ae:"#000",x=R.getFontStyleString(d!=null?d:void 0),{vt:P,ht:F}=d||{},k=P!=null?P:o.VerticalAlign.MIDDLE,N=(se=m.getCellValueOrigin(l))!=null?se:"",H=S.parseCellValue(N),Z=S.getListWithColorMap(y),K=it(H,x,w,C);this._drawDownIcon(e,D,w,C,k),e.save(),e.translateWithPrecision(D.startX,D.startY),e.beginPath(),e.rect(0,0,w-_e,C),e.clip(),e.translateWithPrecision(at,He);let te=0;switch(k){case o.VerticalAlign.MIDDLE:te=(K.contentHeight-K.totalHeight)/2;break;case o.VerticalAlign.BOTTOM:te=K.contentHeight-K.totalHeight;break}e.translateWithPrecision(0,te),K.lines.forEach((ce,J)=>{e.save();const{width:q,height:ve,items:ne}=ce;let ee=0;switch(F){case o.HorizontalAlign.RIGHT:ee=K.contentWidth-q;break;case o.HorizontalAlign.CENTER:ee=(K.contentWidth-q)/2;break}e.translate(ee,J*(ve+bt)),ne.forEach(Q=>{e.save(),e.translateWithPrecision(Q.left,0),Hn.drawWith(e,{...x,info:Q,color:W,fill:Z[Q.text]}),e.restore()}),e.restore()}),e.restore(),T.set(f,{left:D.startX,top:D.startY,width:K.contentWidth+at+_e,height:K.contentHeight+He*2})}calcCellAutoHeight(e){var w;const{primaryWithCoord:t,style:r,data:n,row:a,col:i}=e,s=n==null?void 0:n.fontRenderExtension,{leftOffset:d=0,rightOffset:l=0,topOffset:c=0,downOffset:h=0}=s||{},p=t.isMergedMainCell?t.mergeInfo:t,u={startX:p.startX+d,endX:p.endX-l,startY:p.startY+c,endY:p.endY-h},I=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,a,i);if(!I)return;const g=this._dataValidationModel.getValidator(I.type);if(!g)return;const O=u.endX-u.startX,T=u.endY-u.startY,f=(w=m.getCellValueOrigin(n))!=null?w:"",y=g.parseCellValue(f),S=R.getFontStyleString(r!=null?r:void 0);return it(y,S,O,T).cellAutoHeight}calcCellAutoWidth(e){var w;const{primaryWithCoord:t,style:r,data:n,row:a,col:i}=e,s=n==null?void 0:n.fontRenderExtension,{leftOffset:d=0,rightOffset:l=0,topOffset:c=0,downOffset:h=0}=s||{},p=t.isMergedMainCell?t.mergeInfo:t,u={startX:p.startX+d,endX:p.endX-l,startY:p.startY+c,endY:p.endY-h},I=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,a,i);if(!I)return;const g=this._dataValidationModel.getValidator(I.type);if(!g)return;const O=u.endX-u.startX,T=u.endY-u.startY,f=(w=m.getCellValueOrigin(n))!=null?w:"",y=g.parseCellValue(f),S=R.getFontStyleString(r!=null?r:void 0);return it(y,S,O,T).calcAutoWidth}isHit(e,t){const{primaryWithCoord:r}=t,n=r.isMergedMainCell?r.mergeInfo:r,{endX:a}=n,{x:i}=e;return i>=a-_e&&i<=a}onPointerDown(e,t){if(t.button===2)return;const{unitId:r,subUnitId:n,row:a,col:i}=e,s={unitId:r,subUnitId:n,row:a,column:i};this._commandService.executeCommand(ke.id,s)}onPointerEnter(e,t){var r,n;return(n=(r=R.getCurrentTypeOfRenderer(o.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null?void 0:r.mainComponent)==null?void 0:n.setCursor(R.CURSOR_TYPE.POINTER)}onPointerLeave(e,t){var r,n;return(n=(r=R.getCurrentTypeOfRenderer(o.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null?void 0:r.mainComponent)==null?void 0:n.setCursor(R.CURSOR_TYPE.DEFAULT)}};ot=$n([xe(0,o.ICommandService),xe(1,o.IUniverInstanceService),xe(2,o.Inject(R.IRenderManagerService)),xe(3,o.Inject(m.SheetDataValidationModel))],ot);class Xn extends U.BaseSheetDataValidatorView{constructor(){super(...arguments);L(this,"id",o.DataValidationType.LIST_MULTIPLE);L(this,"canvasRender",this.injector.createInstance(ot));L(this,"dropdownType",X.DataValidatorDropdownType.MULTIPLE_LIST)}}var zn=Object.getOwnPropertyDescriptor,Kn=(e,t,r,n)=>{for(var a=n>1?void 0:n?zn(t,r):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(a=s(a)||a);return a},Ae=(e,t)=>(r,n)=>t(r,n,e);const Ie=4,$e=4,de=14,Tt=1,he=6,Re=3,st=8,Zn="#565656",Vt=new Path2D("M3.32201 4.84556C3.14417 5.05148 2.85583 5.05148 2.67799 4.84556L0.134292 1.90016C-0.152586 1.56798 0.0505937 1 0.456301 1L5.5437 1C5.94941 1 6.15259 1.56798 5.86571 1.90016L3.32201 4.84556Z");function Rt(e,t,r,n,a,i,s=!0){let d=0;const l=s?Re:0;switch(a){case o.VerticalAlign.BOTTOM:d=t-n-l;break;case o.VerticalAlign.MIDDLE:d=(t-n)/2;break;default:d=l;break}d=Math.max(Re,d);let c=0;switch(i){case o.HorizontalAlign.CENTER:c=(e-r)/2;break;case o.HorizontalAlign.RIGHT:c=e-r;break}return c=Math.max(he,c),{paddingLeft:c,paddingTop:d}}let lt=class{constructor(e,t,r,n,a){L(this,"_dropdownInfoMap",new Map);L(this,"zIndex");this._univerInstanceService=e,this._localeService=t,this._commandService=r,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,r,n,a,i,s){const{t:d=o.DEFAULT_STYLES.pd.t,b:l=o.DEFAULT_STYLES.pd.b}=s,c=r-de;let h;switch(i){case o.VerticalAlign.MIDDLE:h=(n-$e)/2;break;case o.VerticalAlign.BOTTOM:h=n-l-a-Re+(a/2-$e/2);break;default:h=d+Re+(a/2-$e/2);break}e.save(),e.translateWithPrecision(t.startX+c,t.startY+h),e.fillStyle="#565656",e.fill(Vt),e.restore()}drawWith(e,t,r){var Z,K,te,ae,se,ce;const{primaryWithCoord:n,row:a,col:i,style:s,data:d,subUnitId:l}=t,c=n.isMergedMainCell?n.mergeInfo:n,h=this._dataValidationModel.getRuleByLocation(t.unitId,t.subUnitId,a,i);if(!h)return;const p=this._dataValidationModel.getValidator(h.type);if(!p)return;const u=d==null?void 0:d.fontRenderExtension,{leftOffset:I=0,rightOffset:g=0,topOffset:O=0,downOffset:T=0}=u||{};if(!h||!p||!p||p.id.indexOf(o.DataValidationType.LIST)!==0||!p.skipDefaultFontRender(h))return;const f={startX:c.startX+I,endX:c.endX-g,startY:c.startY+O,endY:c.endY-T},y=f.endX-f.startX,S=f.endY-f.startY,D=this._ensureMap(l),w=this._generateKey(a,i),C=p.getListWithColor(h),E=m.getCellValueOrigin(d),W=`${E!=null?E:""}`,x=C.find(J=>J.label===W);let{tb:P,vt:F,ht:k,pd:N}=s||{};P=P!=null?P:o.WrapStrategy.WRAP,F=F!=null?F:o.VerticalAlign.BOTTOM,k=k!=null?k:o.DEFAULT_STYLES.ht,N=N!=null?N:o.DEFAULT_STYLES.pd;const H=R.getFontStyleString(s).fontCache;if(h.renderMode===o.DataValidationRenderMode.ARROW){const{l:J=o.DEFAULT_STYLES.pd.l,t:q=o.DEFAULT_STYLES.pd.t,r:ve=o.DEFAULT_STYLES.pd.r,b:ne=o.DEFAULT_STYLES.pd.b}=N,ee=y-J-ve-de-4,Q=new R.DocSimpleSkeleton(W,H,P===o.WrapStrategy.WRAP,ee,1/0);Q.calculate();const A=Q.getTotalWidth(),Y=Q.getTotalHeight(),{paddingTop:_,paddingLeft:j}=Rt(ee,S-q-ne,A,Y,F,k,!0);this._drawDownIcon(e,f,y,S,Y,F,N),e.save(),e.translateWithPrecision(f.startX+J,f.startY+q),e.beginPath(),e.rect(0,0,y-J-ve,S-q-ne),e.clip(),e.translateWithPrecision(0,_),e.save(),e.translateWithPrecision(Ie,0),e.beginPath(),e.rect(0,0,ee,Y),e.clip(),R.Text.drawWith(e,{text:W,fontStyle:H,width:ee,height:Y,color:(Z=s==null?void 0:s.cl)==null?void 0:Z.rgb,strokeLine:!!((K=s==null?void 0:s.st)!=null&&K.s),underline:!!((te=s==null?void 0:s.ul)!=null&&te.s),warp:P===o.WrapStrategy.WRAP,hAlign:o.HorizontalAlign.LEFT},Q),e.translateWithPrecision(j,0),e.restore(),e.restore(),D.set(w,{left:f.endX+J+r.rowHeaderWidth-de,top:f.startY+q+r.columnHeaderHeight,width:de,height:S-q-ne})}else{e.save(),e.translateWithPrecision(f.startX,f.startY),e.beginPath(),e.rect(0,0,y,S),e.clip();const J=y-he*2-Ie-de-4,q=new R.DocSimpleSkeleton(W,H,P===o.WrapStrategy.WRAP,J,1/0);q.calculate();const ve=q.getTotalWidth(),ne=q.getTotalHeight(),ee=ne+Tt*2,Q=Math.max(y-he*2,1),{paddingTop:A,paddingLeft:Y}=Rt(Q,S,ve,ee,F,k);e.translateWithPrecision(he,A),R.Rect.drawWith(e,{width:Q,height:ee,fill:(x==null?void 0:x.color)||Te,radius:st}),e.save(),e.translateWithPrecision(Ie,Tt),e.beginPath(),e.rect(0,0,J,ne),e.clip(),e.translateWithPrecision(Y,0),R.Text.drawWith(e,{text:W,fontStyle:H,width:J,height:ne,color:(ae=s==null?void 0:s.cl)==null?void 0:ae.rgb,strokeLine:!!((se=s==null?void 0:s.st)!=null&&se.s),underline:!!((ce=s==null?void 0:s.ul)!=null&&ce.s),warp:P===o.WrapStrategy.WRAP,hAlign:o.HorizontalAlign.LEFT},q),e.restore(),e.translateWithPrecision(J+Ie+4,(ne-$e)/2),e.fillStyle=Zn,e.fill(Vt),e.restore(),D.set(w,{left:f.startX+he+r.rowHeaderWidth,top:f.startY+A+r.columnHeaderHeight,width:Q,height:ee})}}calcCellAutoHeight(e){const{primaryWithCoord:t,style:r,data:n,row:a,col:i}=e,s=t.isMergedMainCell?t.mergeInfo:t,d=n==null?void 0:n.fontRenderExtension,{leftOffset:l=0,rightOffset:c=0,topOffset:h=0,downOffset:p=0}=d||{},u=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,a,i);if(!u||u.renderMode===o.DataValidationRenderMode.TEXT)return;const I={startX:s.startX+l,endX:s.endX-c,startY:s.startY+h,endY:s.endY-p},g=I.endX-I.startX,O=m.getCellValueOrigin(n),T=`${O!=null?O:""}`;let{tb:f,pd:y}=r||{};const{t:S=o.DEFAULT_STYLES.pd.t,b:D=o.DEFAULT_STYLES.pd.b}=y!=null?y:{};if(f=f!=null?f:o.WrapStrategy.WRAP,u.renderMode===o.DataValidationRenderMode.ARROW){const w=g-de,C=new R.DocSimpleSkeleton(T,R.getFontStyleString(r).fontCache,f===o.WrapStrategy.WRAP,w,1/0);return C.calculate(),C.getTotalHeight()+S+D+Re*2}else{const w=Math.max(g-he*2-Ie-de,10),C=new R.DocSimpleSkeleton(T,R.getFontStyleString(r).fontCache,f===o.WrapStrategy.WRAP,w,1/0);return C.calculate(),C.getTotalHeight()+Re*2+2}}calcCellAutoWidth(e){const{primaryWithCoord:t,style:r,data:n,row:a,col:i}=e,s=t.isMergedMainCell?t.mergeInfo:t,d=n==null?void 0:n.fontRenderExtension,{leftOffset:l=0,rightOffset:c=0,topOffset:h=0,downOffset:p=0}=d||{},u=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,a,i);if(!u||u.renderMode===o.DataValidationRenderMode.TEXT)return;const I={startX:s.startX+l,endX:s.endX-c,startY:s.startY+h,endY:s.endY-p},g=I.endX-I.startX,O=m.getCellValueOrigin(n),T=`${O!=null?O:""}`;let{tb:f,pd:y}=r||{};const{l:S=o.DEFAULT_STYLES.pd.l,r:D=o.DEFAULT_STYLES.pd.r}=y!=null?y:{};f=f!=null?f:o.WrapStrategy.WRAP;let w=he*2+de;switch(u.renderMode){case o.DataValidationRenderMode.ARROW:w=de+he*2+D+S;break;case o.DataValidationRenderMode.CUSTOM:w=de+he*2+Ie*2+D+S+st/2+1;break;default:w=de+he*2+Ie*2+D+S+st/2+1}const C=g-w,E=new R.DocSimpleSkeleton(T,R.getFontStyleString(r).fontCache,f===o.WrapStrategy.WRAP,C,1/0);return E.calculate(),E.getTotalWidth()+w}isHit(e,t){const{subUnitId:r,row:n,col:a}=t,s=this._ensureMap(r).get(this._generateKey(n,a)),d=this._dataValidationModel.getRuleByLocation(t.unitId,t.subUnitId,n,a);if(!d||!s||d.renderMode===o.DataValidationRenderMode.TEXT)return!1;const{top:l,left:c,width:h,height:p}=s,{x:u,y:I}=e;return u>=c&&u<=c+h&&I>=l&&I<=l+p}onPointerDown(e,t){if(t.button===2)return;const{unitId:r,subUnitId:n,row:a,col:i}=e,s={unitId:r,subUnitId:n,row:a,column:i};this._commandService.executeCommand(ke.id,s)}onPointerEnter(e,t){var r,n;(n=(r=R.getCurrentTypeOfRenderer(o.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null?void 0:r.mainComponent)==null||n.setCursor(R.CURSOR_TYPE.POINTER)}onPointerLeave(e,t){var r,n;(n=(r=R.getCurrentTypeOfRenderer(o.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null?void 0:r.mainComponent)==null||n.setCursor(R.CURSOR_TYPE.DEFAULT)}};lt=Kn([Ae(0,o.IUniverInstanceService),Ae(1,o.Inject(o.LocaleService)),Ae(2,o.ICommandService),Ae(3,o.Inject(R.IRenderManagerService)),Ae(4,o.Inject(m.SheetDataValidationModel))],lt);class Gn extends U.BaseSheetDataValidatorView{constructor(){super(...arguments);L(this,"id",o.DataValidationType.LIST);L(this,"canvasRender",this.injector.createInstance(lt));L(this,"dropdownType",X.DataValidatorDropdownType.LIST);L(this,"optionsInput",je.componentKey);L(this,"formulaInput",m.LIST_FORMULA_INPUT_NAME)}}class qn extends U.BaseSheetDataValidatorView{constructor(){super(...arguments);L(this,"id",o.DataValidationType.TEXT_LENGTH);L(this,"formulaInput",m.BASE_FORMULA_INPUT_NAME)}}class Jn extends U.BaseSheetDataValidatorView{constructor(){super(...arguments);L(this,"id",o.DataValidationType.WHOLE);L(this,"formulaInput",m.BASE_FORMULA_INPUT_NAME)}}var Qn=Object.getOwnPropertyDescriptor,er=(e,t,r,n)=>{for(var a=n>1?void 0:n?Qn(t,r):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(a=s(a)||a);return a},dt=(e,t)=>(r,n)=>t(r,n,e);let Oe=class extends o.RxDisposable{constructor(e,t,r){super(),this._injector=e,this._componentManger=t,this._dataValidatorRegistryService=r,this._initComponents(),this._registerValidatorViews()}_initComponents(){[["DataValidationIcon",Ct],[Ue,_n],[je.componentKey,je],[Be.componentKey,Be],...Mn].forEach(([e,t])=>{this.disposeWithMe(this._componentManger.register(e,t))})}_registerValidatorViews(){[Nn,Jn,qn,Fn,Ln,Gn,Xn,Un].forEach(e=>{const t=this._injector.createInstance(e),r=this._dataValidatorRegistryService.getValidatorItem(t.id);r&&(r.formulaInput=t.formulaInput,r.canvasRender=t.canvasRender,r.dropdownType=t.dropdownType,r.optionsInput=t.optionsInput)})}};Oe=er([dt(0,o.Inject(o.Injector)),dt(1,o.Inject(b.ComponentManager)),dt(2,o.Inject(X.DataValidatorRegistryService))],Oe);var tr=Object.getOwnPropertyDescriptor,nr=(e,t,r,n)=>{for(var a=n>1?void 0:n?tr(t,r):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(a=s(a)||a);return a},ct=(e,t)=>(r,n)=>t(r,n,e);const rr="SHEET_DATA_VALIDATION_UI_PLUGIN";U.UniverSheetsDataValidationMobileUIPlugin=(Ye=class extends o.Plugin{constructor(t=Le,r,n,a){super(),this._config=t,this._injector=r,this._commandService=n,this._configService=a;const{menu:i,...s}=o.merge({},Le,this._config);i&&this._configService.setConfig("menu",i,{merge:!0}),this._configService.setConfig(Ke,s)}onStarting(){[[ue],[ge],[Pe],[De],[be],[Me],[Ee],[Oe]].forEach(t=>{this._injector.add(t)}),[Fe,ke,pt,Ge,fe,vt].forEach(t=>{this._commandService.registerCommand(t)})}onReady(){this._injector.get(Ee),this._injector.get(Me),this._injector.get(R.IRenderManagerService).registerRenderModule(o.UniverInstanceType.UNIVER_SHEET,[Ne])}onRendered(){this._injector.get(Oe),this._injector.get(be)}onSteady(){this._injector.get(De)}},L(Ye,"pluginName",rr),L(Ye,"type",o.UniverInstanceType.UNIVER_SHEET),Ye),U.UniverSheetsDataValidationMobileUIPlugin=nr([ct(1,o.Inject(o.Injector)),ct(2,o.ICommandService),ct(3,o.IConfigService)],U.UniverSheetsDataValidationMobileUIPlugin);var ar=Object.defineProperty,ir=Object.getOwnPropertyDescriptor,or=(e,t,r)=>t in e?ar(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,sr=(e,t,r,n)=>{for(var a=n>1?void 0:n?ir(t,r):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(a=s(a)||a);return a},ut=(e,t)=>(r,n)=>t(r,n,e),Ot=(e,t,r)=>or(e,typeof t!="symbol"?t+"":t,r);const lr="SHEET_DATA_VALIDATION_UI_PLUGIN";U.UniverSheetsDataValidationUIPlugin=class extends o.Plugin{constructor(t=Le,r,n,a){super(),this._config=t,this._injector=r,this._commandService=n,this._configService=a;const{menu:i,...s}=o.merge({},Le,this._config);i&&this._configService.setConfig("menu",i,{merge:!0}),this._configService.setConfig(Ke,s)}onStarting(){[[ue],[ge],[Pe],[De],[be],[Me],[Ee],[ye],[Oe]].forEach(t=>{this._injector.add(t)}),[Fe,ke,pt,Ge,fe,vt].forEach(t=>{this._commandService.registerCommand(t)})}onReady(){this._injector.get(Ee),this._injector.get(Me),this._injector.get(ye),this._injector.get(Pe),this._injector.get(R.IRenderManagerService).registerRenderModule(o.UniverInstanceType.UNIVER_SHEET,[Ne])}onRendered(){this._injector.get(Oe),this._injector.get(be)}onSteady(){this._injector.get(De)}},Ot(U.UniverSheetsDataValidationUIPlugin,"pluginName",lr),Ot(U.UniverSheetsDataValidationUIPlugin,"type",o.UniverInstanceType.UNIVER_SHEET),U.UniverSheetsDataValidationUIPlugin=sr([o.DependentOn(m.UniverSheetsDataValidationPlugin),ut(1,o.Inject(o.Injector)),ut(2,o.ICommandService),ut(3,o.IConfigService)],U.UniverSheetsDataValidationUIPlugin),Object.defineProperty(U,Symbol.toStringTag,{value:"Module"})});
5
+ `,{"hover:univer-bg-gray-50 dark:hover:!univer-bg-gray-700":!i,"univer-opacity-50":i}),onClick:r,onMouseEnter:()=>{i||(u(!0),h.current=t.ranges.map(f=>l.addShape({range:f,style:O,primary:null})))},onMouseLeave:()=>{var f;u(!1),(f=h.current)==null||f.forEach(y=>{y&&l.removeShape(y)}),h.current=void 0},children:[v.jsx("div",{className:"univer-truncate univer-text-sm univer-font-medium univer-leading-[22px] univer-text-gray-900 dark:!univer-text-white",children:c==null?void 0:c.generateRuleName(t)}),v.jsx("div",{className:"univer-text-secondary univer-truncate univer-text-xs univer-leading-[18px] dark:!univer-text-gray-300",children:t.ranges.map(f=>Xe.serializeRange(f)).join(",")}),p?v.jsx("div",{className:"univer-absolute univer-right-2 univer-top-[19px] univer-flex univer-h-5 univer-w-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:T,children:v.jsx(et,{})}):null]})};function Sn(e){const t=b.useDependency(m.SheetDataValidationModel),r=b.useDependency(o.IUniverInstanceService),n=b.useDependency(o.ICommandService),a=b.useDependency(o.Injector),i=b.useDependency(ue),s=b.useDependency(o.LocaleService),[d,l]=V.useState([]),{workbook:c}=e,h=b.useObservable(c.activeSheet$,void 0,!0),p=c.getUnitId(),u=h==null?void 0:h.getSheetId();V.useEffect(()=>{l(t.getRules(p,u));const y=t.ruleChange$.subscribe(S=>{S.unitId===p&&S.subUnitId===u&&l(t.getRules(p,u))});return()=>{y.unsubscribe()}},[p,u,t]);const I=async()=>{const y=m.createDefaultNewRule(a),S={unitId:p,subUnitId:u,rule:y};await n.executeCommand(m.AddSheetDataValidationCommand.id,S),i.setActiveRule({unitId:p,subUnitId:u,rule:y})},g=()=>{n.executeCommand(m.RemoveSheetAllDataValidationCommand.id,{unitId:p,subUnitId:u})},T=(y=>{const S=r.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET),D=S.getActiveSheet(),w=S.getUnitId(),C=D.getSheetId();return y.map(W=>$.checkRangesEditablePermission(a,w,C,W.ranges)?{...W}:{...W,disable:!0})})(d),f=T==null?void 0:T.some(y=>y.disable);return v.jsxs("div",{className:"univer-pb-4",children:[T==null?void 0:T.map(y=>{var S;return v.jsx(mn,{unitId:p,subUnitId:u,onClick:()=>{y.disable||i.setActiveRule({unitId:p,subUnitId:u,rule:y})},rule:y,disable:(S=y.disable)!=null?S:!1},y.uid)}),v.jsxs("div",{className:"univer-mt-4 univer-flex univer-flex-row univer-justify-end univer-gap-2",children:[d.length&&!f?v.jsx(M.Button,{onClick:g,children:s.t("dataValidation.panel.removeAll")}):null,v.jsx(M.Button,{variant:"primary",onClick:I,children:s.t("dataValidation.panel.add")})]})]})}const _n=()=>{const e=b.useDependency(ue),t=b.useObservable(e.activeRule$,e.activeRule),r=b.useDependency(o.IUniverInstanceService),n=b.useObservable(()=>r.getCurrentTypeOfUnit$(o.UniverInstanceType.UNIVER_SHEET),void 0,void 0,[]),a=b.useObservable(()=>{var i;return(i=n==null?void 0:n.activeSheet$)!=null?i:ie.of(null)},void 0,void 0,[]);return!n||!a?null:t&&t.subUnitId===a.getSheetId()?v.jsx(fn,{},t.rule.uid):v.jsx(Sn,{workbook:n})},In=e=>{const{isTwoFormula:t=!1,value:r,onChange:n,showError:a,validResult:i}=e,s=b.useDependency(o.LocaleService),d=a?i==null?void 0:i.formula1:"",l=a?i==null?void 0:i.formula2:"";return t?v.jsxs(v.Fragment,{children:[v.jsx(M.FormLayout,{error:d,children:v.jsx(M.Input,{className:"univer-w-full",placeholder:s.t("dataValidation.panel.formulaPlaceholder"),value:r==null?void 0:r.formula1,onChange:c=>{n==null||n({...r,formula1:c})}})}),v.jsx("div",{className:"-univer-mt-2 univer-mb-1 univer-text-sm univer-text-gray-400",children:s.t("dataValidation.panel.formulaAnd")}),v.jsx(M.FormLayout,{error:l,children:v.jsx(M.Input,{className:"univer-w-full",placeholder:s.t("dataValidation.panel.formulaPlaceholder"),value:r==null?void 0:r.formula2,onChange:c=>{n==null||n({...r,formula2:c})}})})]}):v.jsx(M.FormLayout,{error:d,children:v.jsx(M.Input,{className:"univer-w-full",placeholder:s.t("dataValidation.panel.formulaPlaceholder"),value:r==null?void 0:r.formula1,onChange:c=>{n==null||n({formula1:c})}})})};function Cn(e){const{value:t,onChange:r,showError:n,validResult:a}=e,i=b.useDependency(o.LocaleService),s=n?a==null?void 0:a.formula1:"",d=n?a==null?void 0:a.formula2:"",[l,c]=V.useState(!((t==null?void 0:t.formula1)===void 0&&(t==null?void 0:t.formula2)===void 0));return v.jsxs(v.Fragment,{children:[v.jsx(M.FormLayout,{children:v.jsx(M.Checkbox,{checked:l,onChange:h=>{h?c(!0):(c(!1),r==null||r({...t,formula1:void 0,formula2:void 0}))},children:i.t("dataValidation.checkbox.tips")})}),l?v.jsx(M.FormLayout,{label:i.t("dataValidation.checkbox.checked"),error:s,children:v.jsx(M.Input,{className:"univer-w-full",placeholder:i.t("dataValidation.panel.valuePlaceholder"),value:t==null?void 0:t.formula1,onChange:h=>{r==null||r({...t,formula1:h||void 0})}})}):null,l?v.jsx(M.FormLayout,{label:i.t("dataValidation.checkbox.unchecked"),error:d,children:v.jsx(M.Input,{className:"univer-w-full",placeholder:i.t("dataValidation.panel.valuePlaceholder"),value:t==null?void 0:t.formula2,onChange:h=>{r==null||r({...t,formula2:h||void 0})}})}):null]})}function yn(e){var p;const{unitId:t,subUnitId:r,value:n,onChange:a,showError:i,validResult:s}=e,d=i?s==null?void 0:s.formula1:void 0,l=V.useRef(null),[c,h]=V.useState(!1);return b.useSidebarClick(u=>{var g;((g=l.current)==null?void 0:g.isClickOutSide(u))&&h(!1)}),v.jsx(M.FormLayout,{error:d,children:v.jsx(ze.FormulaEditor,{ref:l,className:M.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",M.borderClassName),initValue:(p=n==null?void 0:n.formula1)!=null?p:"=",unitId:t,subUnitId:r,isFocus:c,isSupportAcrossSheet:!0,onChange:u=>{const I=(u!=null?u:"").trim();I!==(n==null?void 0:n.formula1)&&(a==null||a({...n,formula1:I}))},onFocus:()=>h(!0)})})}const Te="#ECECEC",wn=["#FFFFFF","#FEE7E7","#FEF0E6","#EFFBD0","#E4F4FE","#E8ECFD","#F1EAFA","#FDE8F3","#E5E5E5","#FDCECE","#FDC49B","#DEF6A2","#9FDAFF","#D0D9FB","#E3D5F6","#FBD0E8","#656565","#FE4B4B","#FF8C51","#8BBB11","#0B9EFB","#3A60F7","#9E6DE3","#F248A6"],Dn=e=>{const{value:t,onChange:r,disabled:n}=e,[a,i]=V.useState(!1);return v.jsx(M.Dropdown,{align:"start",disabled:n,open:a,onOpenChange:i,overlay:v.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:wn.map(s=>v.jsx("div",{className:M.clsx("univer-box-border univer-size-4 univer-cursor-pointer univer-rounded",M.borderClassName),style:{background:s},onClick:()=>{r(s),i(!1)}},s))}),children:v.jsxs("div",{className:M.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",M.borderClassName),children:[v.jsx("div",{className:"univer-box-border univer-h-4 univer-w-4 univer-rounded univer-text-base",style:{background:t}}),v.jsx(tt,{})]})})},Et=e=>{const{item:t,commonProps:r,className:n}=e,{onItemChange:a,onItemDelete:i}=r;return v.jsxs("div",{className:M.clsx("univer-flex univer-items-center univer-gap-2",n),children:[!t.isRef&&v.jsx("div",{className:M.clsx("univer-cursor-move","draggableHandle"),children:v.jsx(Dt,{})}),v.jsx(Dn,{value:t.color,onChange:s=>{a(t.id,t.label,s)}}),v.jsx(M.Input,{disabled:t.isRef,value:t.label,onChange:s=>{a(t.id,s,t.color)}}),t.isRef?null:v.jsx("div",{className:"univer-ml-1 univer-cursor-pointer univer-rounded univer-text-base hover:univer-bg-gray-200",children:v.jsx(et,{onClick:()=>i(t.id)})})]})};function En(e){const{value:t,onChange:r=()=>{},unitId:n,subUnitId:a,validResult:i,showError:s,ruleId:d}=e,{formula1:l="",formula2:c=""}=t||{},[h,p]=V.useState(()=>o.isFormulaString(l)?"1":"0"),[u,I]=V.useState(h==="1"?l:"="),[g,O]=V.useState(h==="1"?l:"="),T=b.useDependency(o.LocaleService),f=b.useDependency(X.DataValidatorRegistryService),y=b.useDependency(X.DataValidationModel),S=b.useDependency(m.DataValidationFormulaController),[D,w]=V.useState(()=>c.split(",")),C=f.getValidatorItem(o.DataValidationType.LIST),[E,W]=V.useState([]),[x,P]=V.useState(""),F=s?i==null?void 0:i.formula1:"",k=V.useMemo(()=>y.ruleChange$.pipe(ie.debounceTime(16)),[]),N=b.useObservable(k),H=b.useEvent(r);V.useEffect(()=>{(async()=>{await new Promise(_=>{setTimeout(()=>_(!0),100)});const A=y.getRuleById(n,a,d),Y=A==null?void 0:A.formula1;if(o.isFormulaString(Y)&&C&&A){const _=await C.getListAsync(A,n,a);W(_)}})()},[y,N,C,d,a,n]),V.useEffect(()=>{o.isFormulaString(l)&&l!==g&&(I(l),O(g))},[g,l]);const[Z,K]=V.useState(()=>{const A=h!=="1"?m.deserializeListOptions(l):[],Y=c.split(",");return A.map((_,j)=>({label:_,color:Y[j]||Te,isRef:!1,id:o.generateRandomId(4)}))}),te=(A,Y,_)=>{const j=Z.find(z=>z.id===A);j&&(j.label=Y,j.color=_,K([...Z]))},ae=A=>{const Y=Z.findIndex(_=>_.id===A);Y!==-1&&(Z.splice(Y,1),K([...Z]))},se=c.split(","),ce=V.useMemo(()=>E.map((A,Y)=>({label:A,color:se[Y]||Te,id:`${Y}`,isRef:!0})),[se,E]),J=(A,Y,_)=>{const j=[...D];j[+A]=_,w(j),H({formula1:l,formula2:j.join(",")})},q=()=>{K([...Z,{label:"",color:Te,isRef:!1,id:o.generateRandomId(4)}])};V.useEffect(()=>{if(h==="1")return;const A=new Set,Y=[];Z.map(_=>({labelList:_.label.split(","),item:_})).forEach(({item:_,labelList:j})=>{j.forEach(z=>{A.has(z)||(A.add(z),Y.push({label:z,color:_.color}))})}),H({formula1:m.serializeListOptions(Y.map(_=>_.label)),formula2:Y.map(_=>_.color===Te?"":_.color).join(",")})},[Z,H,h,g,D]);const ve=b.useEvent(async A=>{if(!o.isFormulaString(A)){H==null||H({formula1:"",formula2:c});return}S.getFormulaRefCheck(A)?(H==null||H({formula1:o.isFormulaString(A)?A:"",formula2:c}),P("")):(H==null||H({formula1:"",formula2:c}),I("="),P(T.t("dataValidation.validFail.formulaError")))}),ne=V.useRef(null),[ee,Q]=V.useState(!1);return b.useSidebarClick(A=>{var _;((_=ne.current)==null?void 0:_.isClickOutSide(A))&&Q(!1)}),v.jsxs(v.Fragment,{children:[v.jsx(M.FormLayout,{label:T.t("dataValidation.list.options"),children:v.jsxs(M.RadioGroup,{value:h,onChange:A=>{p(A),I(g),A==="1"&&H({formula1:g==="="?"":g,formula2:D.join(",")})},children:[v.jsx(M.Radio,{value:"0",children:T.t("dataValidation.list.customOptions")}),v.jsx(M.Radio,{value:"1",children:T.t("dataValidation.list.refOptions")})]})}),h==="1"?v.jsxs(M.FormLayout,{error:F||x||void 0,children:[v.jsx(ze.FormulaEditor,{ref:ne,className:M.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",M.borderClassName),initValue:u,unitId:n,subUnitId:a,isFocus:ee,isSupportAcrossSheet:!0,onFocus:()=>Q(!0),onChange:(A="")=>{const Y=(A!=null?A:"").trim();O(Y),ve(Y)}}),ce.length>0&&v.jsx("div",{className:"univer-mt-3",children:ce.map(A=>v.jsx(Et,{className:"univer-mb-3",item:A,commonProps:{onItemChange:J}},A.id))})]}):v.jsx(M.FormLayout,{error:F,children:v.jsxs("div",{className:"-univer-mt-3",children:[v.jsx(M.DraggableList,{list:Z,onListChange:K,rowHeight:28,margin:[0,12],draggableHandle:".draggableHandle",itemRender:A=>v.jsx(Et,{item:A,commonProps:{onItemChange:te,onItemDelete:ae}},A.id),idKey:"id"}),v.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:q,children:[v.jsx(yt,{className:"univer-mr-1"}),T.t("dataValidation.list.add")]})]})})]})}const Mn=[[m.CUSTOM_FORMULA_INPUT_NAME,yn],[m.BASE_FORMULA_INPUT_NAME,In],[m.LIST_FORMULA_INPUT_NAME,En],[m.CHECKBOX_FORMULA_INPUT_NAME,Cn]],bn="LIST_RENDER_MODE_OPTION_INPUT";function je(e){var a;const{value:t,onChange:r}=e,n=b.useDependency(o.LocaleService);return v.jsx(M.FormLayout,{label:n.t("dataValidation.renderMode.label"),children:v.jsxs(M.RadioGroup,{value:`${(a=t.renderMode)!=null?a:o.DataValidationRenderMode.CUSTOM}`,onChange:i=>r({...t,renderMode:+i}),children:[v.jsx(M.Radio,{value:`${o.DataValidationRenderMode.CUSTOM}`,children:n.t("dataValidation.renderMode.chip")}),v.jsx(M.Radio,{value:`${o.DataValidationRenderMode.ARROW}`,children:n.t("dataValidation.renderMode.arrow")}),v.jsx(M.Radio,{value:`${o.DataValidationRenderMode.TEXT}`,children:n.t("dataValidation.renderMode.text")})]})})}je.componentKey=bn;const Tn="DATE_SHOW_TIME_OPTION";function Be(e){var a;const{value:t,onChange:r}=e,n=b.useDependency(o.LocaleService);return v.jsx(M.FormLayout,{children:v.jsx(M.Checkbox,{checked:(a=t.bizInfo)==null?void 0:a.showTime,onChange:i=>{r({...t,bizInfo:{...t.bizInfo,showTime:i}})},children:n.t("dataValidation.showTime.label")})})}Be.componentKey=Tn;var Vn=Object.getOwnPropertyDescriptor,Rn=(e,t,r,n)=>{for(var a=n>1?void 0:n?Vn(t,r):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(a=s(a)||a);return a},Ve=(e,t)=>(r,n)=>t(r,n,e);const We=6;let nt=class{constructor(e,t,r,n,a,i){this._commandService=e,this._univerInstanceService=t,this._formulaService=r,this._themeService=n,this._renderManagerService=a,this._dataValidationModel=i}_calc(e,t){var c,h,p;const{vt:r,ht:n}=t||{},a=e.endX-e.startX-We*2,i=e.endY-e.startY,s=((c=t==null?void 0:t.fs)!=null?c:10)*1.6;let d=0,l=0;switch(r){case o.VerticalAlign.TOP:l=0;break;case o.VerticalAlign.BOTTOM:l=0+(i-s);break;default:l=0+(i-s)/2;break}switch(n){case o.HorizontalAlign.LEFT:d=We;break;case o.HorizontalAlign.RIGHT:d=We+(a-s);break;default:d=We+(a-s)/2;break}return{left:e.startX+d,top:e.startY+l,width:((h=t==null?void 0:t.fs)!=null?h:10)*1.6,height:((p=t==null?void 0:t.fs)!=null?p:10)*1.6}}calcCellAutoHeight(e){var r;const{style:t}=e;return((r=t==null?void 0:t.fs)!=null?r:10)*1.6}calcCellAutoWidth(e){var r;const{style:t}=e;return((r=t==null?void 0:t.fs)!=null?r:10)*1.6}async _parseFormula(e,t,r){var c,h,p,u,I,g,O,T,f;const{formula1:n=m.CHECKBOX_FORMULA_1,formula2:a=m.CHECKBOX_FORMULA_2}=e,i=await this._formulaService.getRuleFormulaResult(t,r,e.uid),s=m.getFormulaResult((p=(h=(c=i==null?void 0:i[0])==null?void 0:c.result)==null?void 0:h[0])==null?void 0:p[0]),d=m.getFormulaResult((g=(I=(u=i==null?void 0:i[1])==null?void 0:u.result)==null?void 0:I[0])==null?void 0:g[0]),l=m.isLegalFormulaResult(String(s))&&m.isLegalFormulaResult(String(d));return{formula1:o.isFormulaString(n)?m.getFormulaResult((f=(T=(O=i==null?void 0:i[0])==null?void 0:O.result)==null?void 0:T[0])==null?void 0:f[0]):n,formula2:o.isFormulaString(a)?d:a,isFormulaValid:l}}drawWith(e,t){var F,k,N,H;const{style:r,primaryWithCoord:n,unitId:a,subUnitId:i,worksheet:s,row:d,col:l}=t,c=n.isMergedMainCell?n.mergeInfo:n,h=m.getCellValueOrigin(s.getCellRaw(d,l)),p=this._dataValidationModel.getRuleByLocation(a,i,d,l);if(!p)return;const u=this._dataValidationModel.getValidator(p.type);if(!u||!((F=u.skipDefaultFontRender)!=null&&F.call(u,p,h,{unitId:a,subUnitId:i,row:d,column:l})))return;const I=u.parseFormulaSync(p,a,i),{formula1:g}=I,O=this._calc(c,r),{a:T,d:f}=e.getTransform(),y=R.fixLineWidthByScale(O.left,T),S=R.fixLineWidthByScale(O.top,f),D=R.Transform.create().composeMatrix({left:y,top:S,scaleX:1,scaleY:1,angle:0,skewX:0,skewY:0,flipX:!1,flipY:!1}),w=c.endX-c.startX,C=c.endY-c.startY;e.save(),e.beginPath(),e.rect(c.startX,c.startY,w,C),e.clip();const E=D.getMatrix();e.transform(E[0],E[1],E[2],E[3],E[4],E[5]);const W=((k=r==null?void 0:r.fs)!=null?k:10)*1.6,x=String(h)===String(g),P=this._themeService.getColorFromTheme("primary.600");R.CheckboxShape.drawWith(e,{checked:x,width:W,height:W,fill:(H=(N=r==null?void 0:r.cl)==null?void 0:N.rgb)!=null?H:P}),e.restore()}isHit(e,t){const r=t.primaryWithCoord.isMergedMainCell?t.primaryWithCoord.mergeInfo:t.primaryWithCoord,n=this._calc(r,t.style),a=n.top,i=n.top+n.height,s=n.left,d=n.left+n.width,{x:l,y:c}=e;return l<=d&&l>=s&&c<=i&&c>=a}async onPointerDown(e,t){var g;if(t.button===2)return;const{primaryWithCoord:r,unitId:n,subUnitId:a,worksheet:i,row:s,col:d}=e,l=m.getCellValueOrigin(i.getCellRaw(s,d)),c=this._dataValidationModel.getRuleByLocation(n,a,s,d);if(!c)return;const h=this._dataValidationModel.getValidator(c.type);if(!h||!((g=h.skipDefaultFontRender)!=null&&g.call(h,c,l,{unitId:n,subUnitId:a,row:s,column:d})))return;const{formula1:p,formula2:u}=await this._parseFormula(c,n,a),I={range:{startColumn:r.actualColumn,endColumn:r.actualColumn,startRow:r.actualRow,endRow:r.actualRow},value:{v:String(l)===m.transformCheckboxValue(String(p))?u:p,p:null}};this._commandService.executeCommand($.SetRangeValuesCommand.id,I)}onPointerEnter(e,t){var r,n;(n=(r=R.getCurrentTypeOfRenderer(o.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null?void 0:r.mainComponent)==null||n.setCursor(R.CURSOR_TYPE.POINTER)}onPointerLeave(e,t){var r,n;(n=(r=R.getCurrentTypeOfRenderer(o.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null?void 0:r.mainComponent)==null||n.setCursor(R.CURSOR_TYPE.DEFAULT)}};nt=Rn([Ve(0,o.ICommandService),Ve(1,o.IUniverInstanceService),Ve(2,o.Inject(m.DataValidationFormulaService)),Ve(3,o.Inject(o.ThemeService)),Ve(4,o.Inject(R.IRenderManagerService)),Ve(5,o.Inject(m.SheetDataValidationModel))],nt);var On=Object.getOwnPropertyDescriptor,Pn=(e,t,r,n)=>{for(var a=n>1?void 0:n?On(t,r):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(a=s(a)||a);return a},An=(e,t)=>(r,n)=>t(r,n,e);U.BaseSheetDataValidatorView=class{constructor(t){L(this,"canvasRender",null);L(this,"dropdownType");L(this,"optionsInput");L(this,"formulaInput",m.LIST_FORMULA_INPUT_NAME);this.injector=t}},U.BaseSheetDataValidatorView=Pn([An(0,o.Inject(o.Injector))],U.BaseSheetDataValidatorView);class Ln extends U.BaseSheetDataValidatorView{constructor(){super(...arguments);L(this,"id",o.DataValidationType.CHECKBOX);L(this,"canvasRender",this.injector.createInstance(nt));L(this,"formulaInput",m.CHECKBOX_FORMULA_INPUT_NAME)}}class Un extends U.BaseSheetDataValidatorView{constructor(){super(...arguments);L(this,"id",o.DataValidationType.CUSTOM);L(this,"formulaInput",m.CUSTOM_FORMULA_INPUT_NAME)}}const kn="data-validation.formula-input";class Fn extends U.BaseSheetDataValidatorView{constructor(){super(...arguments);L(this,"id",o.DataValidationType.DATE);L(this,"formulaInput",kn);L(this,"optionsInput",Be.componentKey);L(this,"dropdownType",X.DataValidatorDropdownType.DATE)}}class Nn extends U.BaseSheetDataValidatorView{constructor(){super(...arguments);L(this,"id",o.DataValidationType.DECIMAL);L(this,"formulaInput",m.BASE_FORMULA_INPUT_NAME)}}const Mt=4,jn=0,rt=4,bt=4,at=6,He=6,_e=14;function Bn(e,t){const r=R.FontCache.getTextSize(e,t),n=r.width+Mt*2,{ba:a,bd:i}=r,s=a+i;return{width:n,height:s+jn*2,ba:a}}function it(e,t,r,n){const a=_e+at*2,i=r-a,s=n-He*2,d=e.map(u=>({layout:Bn(u,t),text:u}));let l;const c=[];d.forEach(u=>{const{layout:I}=u,{width:g,height:O}=I;!l||l.width+g+rt>i?(l={width:g,height:O,items:[{...u,left:0}]},c.push(l)):(l.items.push({...u,left:l.width+rt}),l.width=l.width+g+rt)});let h=0,p=0;return c.forEach((u,I)=>{p=Math.max(p,u.width),I===c.length-1?h+=u.height:h+=u.height+bt}),{lines:c,totalHeight:h,contentWidth:i,contentHeight:s,cellAutoHeight:h+He*2,calcAutoWidth:p+a}}const Wn=8;class Hn extends R.Shape{static drawWith(t,r){const{fontString:n,info:a,fill:i,color:s}=r,{layout:d,text:l}=a;t.save(),R.Rect.drawWith(t,{width:d.width,height:d.height,radius:Wn,fill:i||Te}),t.translateWithPrecision(Mt,d.ba),t.font=n,t.fillStyle=s,t.fillText(l,0,0),t.restore()}}var xn=Object.getOwnPropertyDescriptor,$n=(e,t,r,n)=>{for(var a=n>1?void 0:n?xn(t,r):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(a=s(a)||a);return a},xe=(e,t)=>(r,n)=>t(r,n,e);const Yn=new Path2D("M3.32201 4.84556C3.14417 5.05148 2.85583 5.05148 2.67799 4.84556L0.134292 1.90016C-0.152586 1.56798 0.0505937 1 0.456301 1L5.5437 1C5.94941 1 6.15259 1.56798 5.86571 1.90016L3.32201 4.84556Z");let ot=class{constructor(e,t,r,n){L(this,"zIndex");L(this,"_dropdownInfoMap",new Map);this._commandService=e,this._univerInstanceService=t,this._renderManagerService=r,this._dataValidationModel=n}_ensureMap(e){let t=this._dropdownInfoMap.get(e);return t||(t=new Map,this._dropdownInfoMap.set(e,t)),t}_generateKey(e,t){return`${e}.${t}`}_drawDownIcon(e,t,r,n,a){const i=r-_e+4;let s=4;switch(a){case o.VerticalAlign.MIDDLE:s=(n-_e)/2+4;break;case o.VerticalAlign.BOTTOM:s=n-_e+4;break}e.save(),e.translateWithPrecision(t.startX+i,t.startY+s),e.fillStyle="#565656",e.fill(Yn),e.restore()}drawWith(e,t,r,n){var ae,se;const{primaryWithCoord:a,row:i,col:s,style:d,data:l,subUnitId:c}=t,h=a.isMergedMainCell?a.mergeInfo:a,p=l==null?void 0:l.fontRenderExtension,{leftOffset:u=0,rightOffset:I=0,topOffset:g=0,downOffset:O=0}=p||{},T=this._ensureMap(c),f=this._generateKey(i,s),y=this._dataValidationModel.getRuleByLocation(t.unitId,t.subUnitId,i,s);if(!y)return;const S=this._dataValidationModel.getValidator(y.type);if(!S)return;const D={startX:h.startX+u,endX:h.endX-I,startY:h.startY+g,endY:h.endY-O},w=D.endX-D.startX,C=D.endY-D.startY,{cl:E}=d||{},W=(ae=typeof E=="object"?E==null?void 0:E.rgb:E)!=null?ae:"#000",x=R.getFontStyleString(d!=null?d:void 0),{vt:P,ht:F}=d||{},k=P!=null?P:o.VerticalAlign.MIDDLE,N=(se=m.getCellValueOrigin(l))!=null?se:"",H=S.parseCellValue(N),Z=S.getListWithColorMap(y),K=it(H,x,w,C);this._drawDownIcon(e,D,w,C,k),e.save(),e.translateWithPrecision(D.startX,D.startY),e.beginPath(),e.rect(0,0,w-_e,C),e.clip(),e.translateWithPrecision(at,He);let te=0;switch(k){case o.VerticalAlign.MIDDLE:te=(K.contentHeight-K.totalHeight)/2;break;case o.VerticalAlign.BOTTOM:te=K.contentHeight-K.totalHeight;break}e.translateWithPrecision(0,te),K.lines.forEach((ce,J)=>{e.save();const{width:q,height:ve,items:ne}=ce;let ee=0;switch(F){case o.HorizontalAlign.RIGHT:ee=K.contentWidth-q;break;case o.HorizontalAlign.CENTER:ee=(K.contentWidth-q)/2;break}e.translate(ee,J*(ve+bt)),ne.forEach(Q=>{e.save(),e.translateWithPrecision(Q.left,0),Hn.drawWith(e,{...x,info:Q,color:W,fill:Z[Q.text]}),e.restore()}),e.restore()}),e.restore(),T.set(f,{left:D.startX,top:D.startY,width:K.contentWidth+at+_e,height:K.contentHeight+He*2})}calcCellAutoHeight(e){var w;const{primaryWithCoord:t,style:r,data:n,row:a,col:i}=e,s=n==null?void 0:n.fontRenderExtension,{leftOffset:d=0,rightOffset:l=0,topOffset:c=0,downOffset:h=0}=s||{},p=t.isMergedMainCell?t.mergeInfo:t,u={startX:p.startX+d,endX:p.endX-l,startY:p.startY+c,endY:p.endY-h},I=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,a,i);if(!I)return;const g=this._dataValidationModel.getValidator(I.type);if(!g)return;const O=u.endX-u.startX,T=u.endY-u.startY,f=(w=m.getCellValueOrigin(n))!=null?w:"",y=g.parseCellValue(f),S=R.getFontStyleString(r!=null?r:void 0);return it(y,S,O,T).cellAutoHeight}calcCellAutoWidth(e){var w;const{primaryWithCoord:t,style:r,data:n,row:a,col:i}=e,s=n==null?void 0:n.fontRenderExtension,{leftOffset:d=0,rightOffset:l=0,topOffset:c=0,downOffset:h=0}=s||{},p=t.isMergedMainCell?t.mergeInfo:t,u={startX:p.startX+d,endX:p.endX-l,startY:p.startY+c,endY:p.endY-h},I=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,a,i);if(!I)return;const g=this._dataValidationModel.getValidator(I.type);if(!g)return;const O=u.endX-u.startX,T=u.endY-u.startY,f=(w=m.getCellValueOrigin(n))!=null?w:"",y=g.parseCellValue(f),S=R.getFontStyleString(r!=null?r:void 0);return it(y,S,O,T).calcAutoWidth}isHit(e,t){const{primaryWithCoord:r}=t,n=r.isMergedMainCell?r.mergeInfo:r,{endX:a}=n,{x:i}=e;return i>=a-_e&&i<=a}onPointerDown(e,t){if(t.button===2)return;const{unitId:r,subUnitId:n,row:a,col:i}=e,s={unitId:r,subUnitId:n,row:a,column:i};this._commandService.executeCommand(ke.id,s)}onPointerEnter(e,t){var r,n;return(n=(r=R.getCurrentTypeOfRenderer(o.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null?void 0:r.mainComponent)==null?void 0:n.setCursor(R.CURSOR_TYPE.POINTER)}onPointerLeave(e,t){var r,n;return(n=(r=R.getCurrentTypeOfRenderer(o.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null?void 0:r.mainComponent)==null?void 0:n.setCursor(R.CURSOR_TYPE.DEFAULT)}};ot=$n([xe(0,o.ICommandService),xe(1,o.IUniverInstanceService),xe(2,o.Inject(R.IRenderManagerService)),xe(3,o.Inject(m.SheetDataValidationModel))],ot);class Xn extends U.BaseSheetDataValidatorView{constructor(){super(...arguments);L(this,"id",o.DataValidationType.LIST_MULTIPLE);L(this,"canvasRender",this.injector.createInstance(ot));L(this,"dropdownType",X.DataValidatorDropdownType.MULTIPLE_LIST)}}var zn=Object.getOwnPropertyDescriptor,Kn=(e,t,r,n)=>{for(var a=n>1?void 0:n?zn(t,r):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(a=s(a)||a);return a},Ae=(e,t)=>(r,n)=>t(r,n,e);const Ie=4,$e=4,de=14,Tt=1,he=6,Re=3,st=8,Zn="#565656",Vt=new Path2D("M3.32201 4.84556C3.14417 5.05148 2.85583 5.05148 2.67799 4.84556L0.134292 1.90016C-0.152586 1.56798 0.0505937 1 0.456301 1L5.5437 1C5.94941 1 6.15259 1.56798 5.86571 1.90016L3.32201 4.84556Z");function Rt(e,t,r,n,a,i,s=!0){let d=0;const l=s?Re:0;switch(a){case o.VerticalAlign.BOTTOM:d=t-n-l;break;case o.VerticalAlign.MIDDLE:d=(t-n)/2;break;default:d=l;break}d=Math.max(Re,d);let c=0;switch(i){case o.HorizontalAlign.CENTER:c=(e-r)/2;break;case o.HorizontalAlign.RIGHT:c=e-r;break}return c=Math.max(he,c),{paddingLeft:c,paddingTop:d}}let lt=class{constructor(e,t,r,n,a){L(this,"_dropdownInfoMap",new Map);L(this,"zIndex");this._univerInstanceService=e,this._localeService=t,this._commandService=r,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,r,n,a,i,s){const{t:d=o.DEFAULT_STYLES.pd.t,b:l=o.DEFAULT_STYLES.pd.b}=s,c=r-de;let h;switch(i){case o.VerticalAlign.MIDDLE:h=(n-$e)/2;break;case o.VerticalAlign.BOTTOM:h=n-l-a-Re+(a/2-$e/2);break;default:h=d+Re+(a/2-$e/2);break}e.save(),e.translateWithPrecision(t.startX+c,t.startY+h),e.fillStyle="#565656",e.fill(Vt),e.restore()}drawWith(e,t,r){var Z,K,te,ae,se,ce;const{primaryWithCoord:n,row:a,col:i,style:s,data:d,subUnitId:l}=t,c=n.isMergedMainCell?n.mergeInfo:n,h=this._dataValidationModel.getRuleByLocation(t.unitId,t.subUnitId,a,i);if(!h)return;const p=this._dataValidationModel.getValidator(h.type);if(!p)return;const u=d==null?void 0:d.fontRenderExtension,{leftOffset:I=0,rightOffset:g=0,topOffset:O=0,downOffset:T=0}=u||{};if(!h||!p||!p||p.id.indexOf(o.DataValidationType.LIST)!==0||!p.skipDefaultFontRender(h))return;const f={startX:c.startX+I,endX:c.endX-g,startY:c.startY+O,endY:c.endY-T},y=f.endX-f.startX,S=f.endY-f.startY,D=this._ensureMap(l),w=this._generateKey(a,i),C=p.getListWithColor(h),E=m.getCellValueOrigin(d),W=`${E!=null?E:""}`,x=C.find(J=>J.label===W);let{tb:P,vt:F,ht:k,pd:N}=s||{};P=P!=null?P:o.WrapStrategy.WRAP,F=F!=null?F:o.VerticalAlign.BOTTOM,k=k!=null?k:o.DEFAULT_STYLES.ht,N=N!=null?N:o.DEFAULT_STYLES.pd;const H=R.getFontStyleString(s).fontCache;if(h.renderMode===o.DataValidationRenderMode.ARROW){const{l:J=o.DEFAULT_STYLES.pd.l,t:q=o.DEFAULT_STYLES.pd.t,r:ve=o.DEFAULT_STYLES.pd.r,b:ne=o.DEFAULT_STYLES.pd.b}=N,ee=y-J-ve-de-4,Q=new R.DocSimpleSkeleton(W,H,P===o.WrapStrategy.WRAP,ee,1/0);Q.calculate();const A=Q.getTotalWidth(),Y=Q.getTotalHeight(),{paddingTop:_,paddingLeft:j}=Rt(ee,S-q-ne,A,Y,F,k,!0);this._drawDownIcon(e,f,y,S,Y,F,N),e.save(),e.translateWithPrecision(f.startX+J,f.startY+q),e.beginPath(),e.rect(0,0,y-J-ve,S-q-ne),e.clip(),e.translateWithPrecision(0,_),e.save(),e.translateWithPrecision(Ie,0),e.beginPath(),e.rect(0,0,ee,Y),e.clip(),R.Text.drawWith(e,{text:W,fontStyle:H,width:ee,height:Y,color:(Z=s==null?void 0:s.cl)==null?void 0:Z.rgb,strokeLine:!!((K=s==null?void 0:s.st)!=null&&K.s),underline:!!((te=s==null?void 0:s.ul)!=null&&te.s),warp:P===o.WrapStrategy.WRAP,hAlign:o.HorizontalAlign.LEFT},Q),e.translateWithPrecision(j,0),e.restore(),e.restore(),D.set(w,{left:f.endX+J+r.rowHeaderWidth-de,top:f.startY+q+r.columnHeaderHeight,width:de,height:S-q-ne})}else{e.save(),e.translateWithPrecision(f.startX,f.startY),e.beginPath(),e.rect(0,0,y,S),e.clip();const J=y-he*2-Ie-de-4,q=new R.DocSimpleSkeleton(W,H,P===o.WrapStrategy.WRAP,J,1/0);q.calculate();const ve=q.getTotalWidth(),ne=q.getTotalHeight(),ee=ne+Tt*2,Q=Math.max(y-he*2,1),{paddingTop:A,paddingLeft:Y}=Rt(Q,S,ve,ee,F,k);e.translateWithPrecision(he,A),R.Rect.drawWith(e,{width:Q,height:ee,fill:(x==null?void 0:x.color)||Te,radius:st}),e.save(),e.translateWithPrecision(Ie,Tt),e.beginPath(),e.rect(0,0,J,ne),e.clip(),e.translateWithPrecision(Y,0),R.Text.drawWith(e,{text:W,fontStyle:H,width:J,height:ne,color:(ae=s==null?void 0:s.cl)==null?void 0:ae.rgb,strokeLine:!!((se=s==null?void 0:s.st)!=null&&se.s),underline:!!((ce=s==null?void 0:s.ul)!=null&&ce.s),warp:P===o.WrapStrategy.WRAP,hAlign:o.HorizontalAlign.LEFT},q),e.restore(),e.translateWithPrecision(J+Ie+4,(ne-$e)/2),e.fillStyle=Zn,e.fill(Vt),e.restore(),D.set(w,{left:f.startX+he+r.rowHeaderWidth,top:f.startY+A+r.columnHeaderHeight,width:Q,height:ee})}}calcCellAutoHeight(e){const{primaryWithCoord:t,style:r,data:n,row:a,col:i}=e,s=t.isMergedMainCell?t.mergeInfo:t,d=n==null?void 0:n.fontRenderExtension,{leftOffset:l=0,rightOffset:c=0,topOffset:h=0,downOffset:p=0}=d||{},u=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,a,i);if(!u||u.renderMode===o.DataValidationRenderMode.TEXT)return;const I={startX:s.startX+l,endX:s.endX-c,startY:s.startY+h,endY:s.endY-p},g=I.endX-I.startX,O=m.getCellValueOrigin(n),T=`${O!=null?O:""}`;let{tb:f,pd:y}=r||{};const{t:S=o.DEFAULT_STYLES.pd.t,b:D=o.DEFAULT_STYLES.pd.b}=y!=null?y:{};if(f=f!=null?f:o.WrapStrategy.WRAP,u.renderMode===o.DataValidationRenderMode.ARROW){const w=g-de,C=new R.DocSimpleSkeleton(T,R.getFontStyleString(r).fontCache,f===o.WrapStrategy.WRAP,w,1/0);return C.calculate(),C.getTotalHeight()+S+D+Re*2}else{const w=Math.max(g-he*2-Ie-de,10),C=new R.DocSimpleSkeleton(T,R.getFontStyleString(r).fontCache,f===o.WrapStrategy.WRAP,w,1/0);return C.calculate(),C.getTotalHeight()+Re*2+2}}calcCellAutoWidth(e){const{primaryWithCoord:t,style:r,data:n,row:a,col:i}=e,s=t.isMergedMainCell?t.mergeInfo:t,d=n==null?void 0:n.fontRenderExtension,{leftOffset:l=0,rightOffset:c=0,topOffset:h=0,downOffset:p=0}=d||{},u=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,a,i);if(!u||u.renderMode===o.DataValidationRenderMode.TEXT)return;const I={startX:s.startX+l,endX:s.endX-c,startY:s.startY+h,endY:s.endY-p},g=I.endX-I.startX,O=m.getCellValueOrigin(n),T=`${O!=null?O:""}`;let{tb:f,pd:y}=r||{};const{l:S=o.DEFAULT_STYLES.pd.l,r:D=o.DEFAULT_STYLES.pd.r}=y!=null?y:{};f=f!=null?f:o.WrapStrategy.WRAP;let w=he*2+de;switch(u.renderMode){case o.DataValidationRenderMode.ARROW:w=de+he*2+D+S;break;case o.DataValidationRenderMode.CUSTOM:w=de+he*2+Ie*2+D+S+st/2+1;break;default:w=de+he*2+Ie*2+D+S+st/2+1}const C=g-w,E=new R.DocSimpleSkeleton(T,R.getFontStyleString(r).fontCache,f===o.WrapStrategy.WRAP,C,1/0);return E.calculate(),E.getTotalWidth()+w}isHit(e,t){const{subUnitId:r,row:n,col:a}=t,s=this._ensureMap(r).get(this._generateKey(n,a)),d=this._dataValidationModel.getRuleByLocation(t.unitId,t.subUnitId,n,a);if(!d||!s||d.renderMode===o.DataValidationRenderMode.TEXT)return!1;const{top:l,left:c,width:h,height:p}=s,{x:u,y:I}=e;return u>=c&&u<=c+h&&I>=l&&I<=l+p}onPointerDown(e,t){if(t.button===2)return;const{unitId:r,subUnitId:n,row:a,col:i}=e,s={unitId:r,subUnitId:n,row:a,column:i};this._commandService.executeCommand(ke.id,s)}onPointerEnter(e,t){var r,n;(n=(r=R.getCurrentTypeOfRenderer(o.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null?void 0:r.mainComponent)==null||n.setCursor(R.CURSOR_TYPE.POINTER)}onPointerLeave(e,t){var r,n;(n=(r=R.getCurrentTypeOfRenderer(o.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null?void 0:r.mainComponent)==null||n.setCursor(R.CURSOR_TYPE.DEFAULT)}};lt=Kn([Ae(0,o.IUniverInstanceService),Ae(1,o.Inject(o.LocaleService)),Ae(2,o.ICommandService),Ae(3,o.Inject(R.IRenderManagerService)),Ae(4,o.Inject(m.SheetDataValidationModel))],lt);class Gn extends U.BaseSheetDataValidatorView{constructor(){super(...arguments);L(this,"id",o.DataValidationType.LIST);L(this,"canvasRender",this.injector.createInstance(lt));L(this,"dropdownType",X.DataValidatorDropdownType.LIST);L(this,"optionsInput",je.componentKey);L(this,"formulaInput",m.LIST_FORMULA_INPUT_NAME)}}class qn extends U.BaseSheetDataValidatorView{constructor(){super(...arguments);L(this,"id",o.DataValidationType.TEXT_LENGTH);L(this,"formulaInput",m.BASE_FORMULA_INPUT_NAME)}}class Jn extends U.BaseSheetDataValidatorView{constructor(){super(...arguments);L(this,"id",o.DataValidationType.WHOLE);L(this,"formulaInput",m.BASE_FORMULA_INPUT_NAME)}}var Qn=Object.getOwnPropertyDescriptor,er=(e,t,r,n)=>{for(var a=n>1?void 0:n?Qn(t,r):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(a=s(a)||a);return a},dt=(e,t)=>(r,n)=>t(r,n,e);let Oe=class extends o.RxDisposable{constructor(e,t,r){super(),this._injector=e,this._componentManger=t,this._dataValidatorRegistryService=r,this._initComponents(),this._registerValidatorViews()}_initComponents(){[["DataValidationIcon",Ct],[Ue,_n],[je.componentKey,je],[Be.componentKey,Be],...Mn].forEach(([e,t])=>{this.disposeWithMe(this._componentManger.register(e,t))})}_registerValidatorViews(){[Nn,Jn,qn,Fn,Ln,Gn,Xn,Un].forEach(e=>{const t=this._injector.createInstance(e),r=this._dataValidatorRegistryService.getValidatorItem(t.id);r&&(r.formulaInput=t.formulaInput,r.canvasRender=t.canvasRender,r.dropdownType=t.dropdownType,r.optionsInput=t.optionsInput)})}};Oe=er([dt(0,o.Inject(o.Injector)),dt(1,o.Inject(b.ComponentManager)),dt(2,o.Inject(X.DataValidatorRegistryService))],Oe);var tr=Object.getOwnPropertyDescriptor,nr=(e,t,r,n)=>{for(var a=n>1?void 0:n?tr(t,r):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(a=s(a)||a);return a},ct=(e,t)=>(r,n)=>t(r,n,e);const rr="SHEET_DATA_VALIDATION_UI_PLUGIN";U.UniverSheetsDataValidationMobileUIPlugin=(Ye=class extends o.Plugin{constructor(t=Le,r,n,a){super(),this._config=t,this._injector=r,this._commandService=n,this._configService=a;const{menu:i,...s}=o.merge({},Le,this._config);i&&this._configService.setConfig("menu",i,{merge:!0}),this._configService.setConfig(Ke,s)}onStarting(){[[ue],[ge],[Pe],[De],[be],[Me],[Ee],[Oe]].forEach(t=>{this._injector.add(t)}),[Fe,ke,pt,Ge,fe,vt].forEach(t=>{this._commandService.registerCommand(t)})}onReady(){this._injector.get(Ee),this._injector.get(Me),this._injector.get(R.IRenderManagerService).registerRenderModule(o.UniverInstanceType.UNIVER_SHEET,[Ne])}onRendered(){this._injector.get(Oe),this._injector.get(be)}onSteady(){this._injector.get(De)}},L(Ye,"pluginName",rr),L(Ye,"type",o.UniverInstanceType.UNIVER_SHEET),Ye),U.UniverSheetsDataValidationMobileUIPlugin=nr([ct(1,o.Inject(o.Injector)),ct(2,o.ICommandService),ct(3,o.IConfigService)],U.UniverSheetsDataValidationMobileUIPlugin);var ar=Object.defineProperty,ir=Object.getOwnPropertyDescriptor,or=(e,t,r)=>t in e?ar(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,sr=(e,t,r,n)=>{for(var a=n>1?void 0:n?ir(t,r):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(a=s(a)||a);return a},ut=(e,t)=>(r,n)=>t(r,n,e),Ot=(e,t,r)=>or(e,typeof t!="symbol"?t+"":t,r);const lr="SHEET_DATA_VALIDATION_UI_PLUGIN";U.UniverSheetsDataValidationUIPlugin=class extends o.Plugin{constructor(t=Le,r,n,a){super(),this._config=t,this._injector=r,this._commandService=n,this._configService=a;const{menu:i,...s}=o.merge({},Le,this._config);i&&this._configService.setConfig("menu",i,{merge:!0}),this._configService.setConfig(Ke,s)}onStarting(){[[ue],[ge],[Pe],[De],[be],[Me],[Ee],[ye],[Oe]].forEach(t=>{this._injector.add(t)}),[Fe,ke,pt,Ge,fe,vt].forEach(t=>{this._commandService.registerCommand(t)})}onReady(){this._injector.get(Ee),this._injector.get(Me),this._injector.get(ye),this._injector.get(Pe),this._injector.get(R.IRenderManagerService).registerRenderModule(o.UniverInstanceType.UNIVER_SHEET,[Ne])}onRendered(){this._injector.get(Oe),this._injector.get(be)}onSteady(){this._injector.get(De)}},Ot(U.UniverSheetsDataValidationUIPlugin,"pluginName",lr),Ot(U.UniverSheetsDataValidationUIPlugin,"type",o.UniverInstanceType.UNIVER_SHEET),U.UniverSheetsDataValidationUIPlugin=sr([o.DependentOn(m.UniverSheetsDataValidationPlugin),ut(1,o.Inject(o.Injector)),ut(2,o.ICommandService),ut(3,o.IConfigService)],U.UniverSheetsDataValidationUIPlugin),Object.defineProperty(U,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@univerjs/sheets-data-validation-ui",
3
- "version": "0.9.2-nightly.202507151607",
3
+ "version": "0.9.2-nightly.202507171607",
4
4
  "private": false,
5
5
  "description": "Data validation UI for Univer Sheets",
6
6
  "author": "DreamNum <developer@univer.ai>",
@@ -56,17 +56,17 @@
56
56
  "dependencies": {
57
57
  "@flatten-js/interval-tree": "^1.1.3",
58
58
  "@univerjs/icons": "^0.4.6",
59
- "@univerjs/core": "0.9.2-nightly.202507151607",
60
- "@univerjs/data-validation": "0.9.2-nightly.202507151607",
61
- "@univerjs/design": "0.9.2-nightly.202507151607",
62
- "@univerjs/engine-formula": "0.9.2-nightly.202507151607",
63
- "@univerjs/engine-render": "0.9.2-nightly.202507151607",
64
- "@univerjs/sheets": "0.9.2-nightly.202507151607",
65
- "@univerjs/sheets-formula-ui": "0.9.2-nightly.202507151607",
66
- "@univerjs/sheets-data-validation": "0.9.2-nightly.202507151607",
67
- "@univerjs/sheets-numfmt": "0.9.2-nightly.202507151607",
68
- "@univerjs/sheets-ui": "0.9.2-nightly.202507151607",
69
- "@univerjs/ui": "0.9.2-nightly.202507151607"
59
+ "@univerjs/core": "0.9.2-nightly.202507171607",
60
+ "@univerjs/data-validation": "0.9.2-nightly.202507171607",
61
+ "@univerjs/design": "0.9.2-nightly.202507171607",
62
+ "@univerjs/engine-formula": "0.9.2-nightly.202507171607",
63
+ "@univerjs/sheets-data-validation": "0.9.2-nightly.202507171607",
64
+ "@univerjs/sheets": "0.9.2-nightly.202507171607",
65
+ "@univerjs/engine-render": "0.9.2-nightly.202507171607",
66
+ "@univerjs/sheets-formula-ui": "0.9.2-nightly.202507171607",
67
+ "@univerjs/sheets-numfmt": "0.9.2-nightly.202507171607",
68
+ "@univerjs/sheets-ui": "0.9.2-nightly.202507171607",
69
+ "@univerjs/ui": "0.9.2-nightly.202507171607"
70
70
  },
71
71
  "devDependencies": {
72
72
  "postcss": "^8.5.6",
@@ -74,7 +74,7 @@
74
74
  "rxjs": "^7.8.2",
75
75
  "tailwindcss": "3.4.17",
76
76
  "typescript": "^5.8.3",
77
- "vite": "^6.3.5",
77
+ "vite": "^7.0.5",
78
78
  "vitest": "^3.2.4",
79
79
  "@univerjs-infra/shared": "0.9.2"
80
80
  },