@univerjs/sheets-data-validation-ui 0.15.0-insiders.20251227-c108ce3 → 0.15.0-insiders.20260106-79b11f9

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,n)=>t in e?At(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var L=(e,t,n)=>Lt(e,typeof t!="symbol"?t+"":t,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("@univerjs/core"),P=require("@univerjs/engine-render"),H=require("@univerjs/sheets"),C=require("@univerjs/sheets-data-validation"),Y=require("@univerjs/data-validation"),E=require("@univerjs/ui"),re=require("rxjs"),Pt=require("@univerjs/sheets-numfmt"),N=require("@univerjs/sheets-ui"),V=require("@univerjs/design"),T=require("react"),g=require("react/jsx-runtime"),tt=require("@univerjs/engine-formula"),ot=require("@univerjs/sheets-formula-ui");var jt=Object.getOwnPropertyDescriptor,xt=(e,t,n,a)=>{for(var r=a>1?void 0:a?jt(t,n):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},ht=(e,t)=>(n,a)=>t(n,a,e);let ce=class extends o.Disposable{constructor(t,n){super();L(this,"_open$",new re.BehaviorSubject(!1));L(this,"open$",this._open$.pipe(re.distinctUntilChanged()));L(this,"_activeRule");L(this,"_activeRule$",new re.BehaviorSubject(void 0));L(this,"activeRule$",this._activeRule$.asObservable());L(this,"_closeDisposable",null);this._univerInstanceService=t,this._sidebarService=n,this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(o.UniverInstanceType.UNIVER_SHEET).pipe(re.filter(a=>!a)).subscribe(()=>{this.close()})),this.disposeWithMe(this._sidebarService.sidebarOptions$.subscribe(a=>{a.id===Ue&&(a.visible||setTimeout(()=>{this._sidebarService.sidebarOptions$.next({visible:!1})}))}))}get activeRule(){return this._activeRule}get isOpen(){return this._open$.getValue()}dispose(){var t;super.dispose(),this._open$.next(!1),this._open$.complete(),this._activeRule$.complete(),(t=this._closeDisposable)==null||t.dispose()}open(){this._open$.next(!0)}close(){var t;this._open$.next(!1),(t=this._closeDisposable)==null||t.dispose()}setCloseDisposable(t){this._closeDisposable=o.toDisposable(()=>{t.dispose(),this._closeDisposable=null})}setActiveRule(t){this._activeRule=t,this._activeRule$.next(t)}};ce=xt([ht(0,o.IUniverInstanceService),ht(1,E.ISidebarService)],ce);const ve="#ECECEC",st="sheets-data-validation-ui.config",xe={};var Ut=Object.getOwnPropertyDescriptor,Ft=(e,t,n,a)=>{for(var r=a>1?void 0:a?Ut(t,n):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},_e=(e,t)=>(n,a)=>t(n,a,e);let De=class extends o.Disposable{constructor(e,t,n,a,r,i){super(),this._sheetInterceptorService=e,this._dataValidationModel=t,this._dataValidatorRegistryService=n,this._dialogService=a,this._localeService=r,this._sheetsDataValidationValidatorService=i,this._initEditorBridgeInterceptor()}_initEditorBridgeInterceptor(){this.disposeWithMe(this._sheetInterceptorService.writeCellInterceptor.intercept(H.VALIDATE_CELL,{handler:async(e,t,n)=>{const a=await e,{row:r,col:i,unitId:s,subUnitId:c}=t,l=this._dataValidationModel.getRuleIdByLocation(s,c,r,i),d=l?this._dataValidationModel.getRuleById(s,c,l):void 0;if(a===!1)return n(Promise.resolve(!1));if(!d||d.errorStyle!==o.DataValidationErrorStyle.STOP)return n(Promise.resolve(!0));const h=this._dataValidatorRegistryService.getValidatorItem(d.type);return!h||await this._sheetsDataValidationValidatorService.validatorCell(s,c,r,i)===o.DataValidationStatus.VALID?n(Promise.resolve(!0)):(this._dialogService.open({width:368,title:{title:this._localeService.t("dataValidation.alert.title")},id:"reject-input-dialog",children:{title:h.getRuleFinalError(d,{row:r,col:i,unitId:s,subUnitId:c})},footer:{title:T.createElement(V.Button,{variant:"primary",onClick:()=>this._dialogService.close("reject-input-dialog")},this._localeService.t("dataValidation.alert.ok"))},onClose:()=>{this._dialogService.close("reject-input-dialog")}}),n(Promise.resolve(!1)))}}))}showReject(e){this._dialogService.open({width:368,title:{title:this._localeService.t("dataValidation.alert.title")},id:"reject-input-dialog",children:{title:e},footer:{title:T.createElement(V.Button,{variant:"primary",onClick:()=>this._dialogService.close("reject-input-dialog")},this._localeService.t("dataValidation.alert.ok"))},onClose:()=>{this._dialogService.close("reject-input-dialog")}})}};De=Ft([_e(0,o.Inject(H.SheetInterceptorService)),_e(1,o.Inject(C.SheetDataValidationModel)),_e(2,o.Inject(Y.DataValidatorRegistryService)),_e(3,E.IDialogService),_e(4,o.Inject(o.LocaleService)),_e(5,o.Inject(C.SheetsDataValidationValidatorService))],De);var kt=Object.getOwnPropertyDescriptor,Nt=(e,t,n,a)=>{for(var r=a>1?void 0:a?kt(t,n):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},oe=(e,t)=>(n,a)=>t(n,a,e);const He=e=>{if(e==null||typeof e=="boolean")return;if(e==="")return o.dayjs();if(typeof e=="number"||!Number.isNaN(+e))return o.dayjs(o.numfmt.format("yyyy-MM-dd HH:mm:ss",Number(e)));const t=o.dayjs(e);if(t.isValid())return t};function Bt(e,t){const n=Pt.getPatternType(t);if(e===n)return t;switch(e){case"datetime":return"yyyy-MM-dd hh:mm:ss";case"date":return"yyyy-MM-dd";case"time":return"HH:mm:ss"}}let me=class extends o.Disposable{constructor(t,n,a,r,i,s,c,l,d,h,v){super();L(this,"_activeDropdown");L(this,"_activeDropdown$",new re.Subject);L(this,"_currentPopup",null);L(this,"activeDropdown$",this._activeDropdown$.asObservable());L(this,"_zenVisible",!1);this._univerInstanceService=t,this._dataValidatorRegistryService=n,this._zenZoneService=a,this._dataValidationModel=r,this._sheetsSelectionsService=i,this._cellDropdownManagerService=s,this._sheetDataValidationModel=c,this._commandService=l,this._editorBridgeService=d,this._injector=h,this._configService=v,this._init(),this._initSelectionChange(),this.disposeWithMe(()=>{this._activeDropdown$.complete()})}get activeDropdown(){return this._activeDropdown}_init(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(t=>{this._zenVisible=t,t&&this.hideDropdown()}))}_getDropdownByCell(t,n,a,r){const i=t?this._univerInstanceService.getUnit(t,o.UniverInstanceType.UNIVER_SHEET):this._univerInstanceService.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET);if(!i)return;const s=n?i.getSheetBySheetId(n):i.getActiveSheet();if(!s)return;const c=this._dataValidationModel.getRuleByLocation(i.getUnitId(),s.getSheetId(),a,r);if(!c)return;const l=this._dataValidatorRegistryService.getValidatorItem(c.type);return l==null?void 0:l.dropdownType}_initSelectionChange(){this.disposeWithMe(this._sheetsSelectionsService.selectionMoveEnd$.subscribe(t=>{t&&t.every(n=>!(n.primary&&this._getDropdownByCell(n.primary.unitId,n.primary.sheetId,n.primary.actualRow,n.primary.actualColumn)))&&this.hideDropdown()}))}showDropdown(t){var O,M,R,y;const{location:n}=t,{row:a,col:r,unitId:i,subUnitId:s,workbook:c,worksheet:l}=n;if(this._currentPopup&&this._currentPopup.dispose(),this._zenVisible)return;this._activeDropdown=t,this._activeDropdown$.next(this._activeDropdown);const d=this._sheetDataValidationModel.getRuleByLocation(i,s,a,r);if(!d)return;const h=this._dataValidatorRegistryService.getValidatorItem(d.type);if(!(h!=null&&h.dropdownType))return;let v;const u=async(m,D)=>{var A,x,k;if(!m)return!0;const I=m,f=l.getCell(a,r),w=I.format(D==="date"?"YYYY-MM-DD 00:00:00":"YYYY-MM-DD HH:mm:ss"),F=(A=o.numfmt.parseDate(w))==null?void 0:A.v,B=D==="time"?F%1:F,j=c.getStyles().getStyleByCell(f),W=(k=(x=j==null?void 0:j.n)==null?void 0:x.pattern)!=null?k:"";return d.errorStyle!==o.DataValidationErrorStyle.STOP||await h.validator({value:B,unitId:i,subUnitId:s,row:a,column:r,worksheet:l,workbook:c,interceptValue:w.replace("Z","").replace("T"," "),t:o.CellValueType.NUMBER},d)?(await this._commandService.executeCommand(H.SetRangeValuesCommand.id,{unitId:i,subUnitId:s,range:{startColumn:r,endColumn:r,startRow:a,endRow:a},value:{v:B,t:2,p:null,f:null,si:null,s:{n:{pattern:Bt(D,W)}}}}),await this._commandService.executeCommand(N.SetCellEditVisibleOperation.id,{visible:!1,eventType:P.DeviceInputEventType.Keyboard,unitId:i,keycode:E.KeyCode.ESC}),!0):(this._injector.has(De)&&this._injector.get(De).showReject(h.getRuleFinalError(d,{row:a,col:r,unitId:i,subUnitId:s})),!1)};let S;switch(h.dropdownType){case Y.DataValidatorDropdownType.DATE:{const m=C.getCellValueOrigin(l.getCellRaw(a,r)),D=He(m),I=!!((O=d.bizInfo)!=null&&O.showTime);S={location:n,type:"datepicker",props:{showTime:I,onChange:f=>u(f,I?"datetime":"date"),defaultValue:D,patternType:"date"}};break}case Y.DataValidatorDropdownType.TIME:{const m=C.getCellValueOrigin(l.getCellRaw(a,r)),D=He(m);S={location:n,type:"datepicker",props:{onChange:I=>u(I,"time"),defaultValue:D,patternType:"time"}};break}case Y.DataValidatorDropdownType.DATETIME:{const m=C.getCellValueOrigin(l.getCellRaw(a,r)),D=He(m);S={location:n,type:"datepicker",props:{onChange:I=>u(I,"datetime"),defaultValue:D,patternType:"datetime"}};break}case Y.DataValidatorDropdownType.LIST:case Y.DataValidatorDropdownType.MULTIPLE_LIST:{const m=h.dropdownType===Y.DataValidatorDropdownType.MULTIPLE_LIST,D=async j=>{const W=C.serializeListOptions(j),A={unitId:i,subUnitId:s,range:{startColumn:r,endColumn:r,startRow:a,endRow:a},value:{v:W,p:null,f:null,si:null}};return this._commandService.executeCommand(H.SetRangeValuesCommand.id,A),this._editorBridgeService.isVisible().visible&&await this._commandService.executeCommand(N.SetCellEditVisibleOperation.id,{visible:!1,eventType:P.DeviceInputEventType.Keyboard,unitId:i,keycode:E.KeyCode.ESC}),!m},I=(d==null?void 0:d.renderMode)===o.DataValidationRenderMode.CUSTOM||(d==null?void 0:d.renderMode)===void 0,f=h.getListWithColor(d,i,s),w=C.getDataValidationCellValue(l.getCellRaw(a,r)),F=()=>{this._commandService.executeCommand(fe.id,{ruleId:d.uid}),v==null||v.dispose()},B=f.map(j=>({label:j.label,value:j.label,color:I||j.color?j.color||ve:"transparent"}));S={location:n,type:"list",props:{onChange:j=>D(j),options:B,onEdit:F,defaultValue:w,multiple:m,showEdit:(R=(M=this._configService.getConfig(st))==null?void 0:M.showEditOnDropdown)!=null?R:!0}};break}case Y.DataValidatorDropdownType.CASCADE:{S={type:"cascader",props:{onChange:D=>{const I={unitId:i,subUnitId:s,range:{startColumn:r,endColumn:r,startRow:a,endRow:a},value:{v:D.join("/"),p:null,f:null,si:null}};return this._commandService.syncExecuteCommand(H.SetRangeValuesCommand.id,I),this._editorBridgeService.isVisible().visible&&this._commandService.syncExecuteCommand(N.SetCellEditVisibleOperation.id,{visible:!1,eventType:P.DeviceInputEventType.Keyboard,unitId:i,keycode:E.KeyCode.ESC}),!0},defaultValue:C.getDataValidationCellValue(l.getCellRaw(a,r)).split("/"),options:JSON.parse((y=d.formula1)!=null?y:"[]")},location:n};break}case Y.DataValidatorDropdownType.COLOR:{S={type:"color",props:{onChange:D=>{const I={unitId:i,subUnitId:s,range:{startColumn:r,endColumn:r,startRow:a,endRow:a},value:{v:D,p:null,f:null,si:null}};return this._commandService.syncExecuteCommand(H.SetRangeValuesCommand.id,I),this._editorBridgeService.isVisible().visible&&this._commandService.syncExecuteCommand(N.SetCellEditVisibleOperation.id,{visible:!1,eventType:P.DeviceInputEventType.Keyboard,unitId:i,keycode:E.KeyCode.ESC}),!0},defaultValue:C.getDataValidationCellValue(l.getCellRaw(a,r))},location:n};break}default:throw new Error("[DataValidationDropdownManagerService]: unknown type!")}if(v=this._cellDropdownManagerService.showDropdown({...S,onHide:()=>{this._activeDropdown=null,this._activeDropdown$.next(null)}}),!v)throw new Error("[DataValidationDropdownManagerService]: cannot show dropdown!");const p=new o.DisposableCollection;p.add(v),p.add({dispose:()=>{var m,D;(D=(m=this._activeDropdown)==null?void 0:m.onHide)==null||D.call(m)}}),this._currentPopup=p}hideDropdown(){this._activeDropdown&&(this._currentPopup&&this._currentPopup.dispose(),this._currentPopup=null,this._activeDropdown=null,this._activeDropdown$.next(null))}showDataValidationDropdown(t,n,a,r,i){const s=this._univerInstanceService.getUnit(t,o.UniverInstanceType.UNIVER_SHEET);if(!s)return;const c=s.getSheetBySheetId(n);if(!c)return;const l=this._dataValidationModel.getRuleByLocation(s.getUnitId(),c.getSheetId(),a,r);if(!l)return;const d=this._dataValidatorRegistryService.getValidatorItem(l.type);if(!d||!d.dropdownType){this.hideDropdown();return}this.showDropdown({location:{workbook:s,worksheet:c,row:a,col:r,unitId:t,subUnitId:n},onHide:i})}};me=Nt([oe(0,o.IUniverInstanceService),oe(1,o.Inject(Y.DataValidatorRegistryService)),oe(2,E.IZenZoneService),oe(3,o.Inject(C.SheetDataValidationModel)),oe(4,o.Inject(H.SheetsSelectionsService)),oe(5,o.Inject(N.ISheetCellDropdownManagerService)),oe(6,o.Inject(C.SheetDataValidationModel)),oe(7,o.ICommandService),oe(8,N.IEditorBridgeService),oe(9,o.Inject(o.Injector)),oe(10,o.IConfigService)],me);const Ue="DataValidationPanel",fe={id:"data-validation.operation.open-validation-panel",type:o.CommandType.OPERATION,handler(e,t){if(!t)return!1;const{ruleId:n,isAdd:a}=t,r=e.get(ce),i=e.get(Y.DataValidationModel),s=e.get(o.IUniverInstanceService),c=e.get(E.ISidebarService),l=H.getSheetCommandTarget(s);if(!l)return!1;const{unitId:d,subUnitId:h}=l,v=n?i.getRuleById(d,h,n):void 0;r.open(),r.setActiveRule(v&&{unitId:d,subUnitId:h,rule:v});const u=c.open({id:Ue,header:{title:a?"dataValidation.panel.addTitle":"dataValidation.panel.title"},children:{label:Ue},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(ce).close(),!0}},St={id:"data-validation.operation.toggle-validation-panel",type:o.CommandType.OPERATION,handler(e){const t=e.get(o.ICommandService),n=e.get(ce);return n.open(),n.isOpen?t.executeCommand(lt.id):t.executeCommand(fe.id),!0}},We={type:o.CommandType.OPERATION,id:"sheet.operation.show-data-validation-dropdown",handler(e,t){if(!t)return!1;const n=e.get(me),{unitId:a,subUnitId:r,row:i,column:s}=t,c=n.activeDropdown,l=c==null?void 0:c.location;return l&&l.unitId===a&&l.subUnitId===r&&l.row===i&&l.col===s||n.showDataValidationDropdown(a,r,i,s),!0}},_t={type:o.CommandType.OPERATION,id:"sheet.operation.hide-data-validation-dropdown",handler(e,t){return t?(e.get(me).hideDropdown(),!0):!1}},$e={type:o.CommandType.COMMAND,id:"data-validation.command.addRuleAndOpen",handler(e){const t=e.get(o.IUniverInstanceService),n=H.getSheetCommandTarget(t);if(!n)return!1;const{workbook:a,worksheet:r}=n,i=C.createDefaultNewRule(e),s=e.get(o.ICommandService),c=a.getUnitId(),l=r.getSheetId(),d={rule:i,unitId:c,subUnitId:l};return s.syncExecuteCommand(C.AddSheetDataValidationCommand.id,d)?(s.syncExecuteCommand(fe.id,{ruleId:i.uid,isAdd:!0}),!0):!1}};var Wt=Object.getOwnPropertyDescriptor,$t=(e,t,n,a)=>{for(var r=a>1?void 0:a?Wt(t,n):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},Ie=(e,t)=>(n,a)=>t(n,a,e);const ge="SHEET_DATA_VALIDATION_ALERT";let Oe=class extends o.Disposable{constructor(e,t,n,a,r,i){super(),this._hoverManagerService=e,this._cellAlertManagerService=t,this._univerInstanceService=n,this._localeService=a,this._zenZoneService=r,this._dataValidationModel=i,this._init()}_init(){this._initCellAlertPopup(),this._initZenService()}_initCellAlertPopup(){this.disposeWithMe(this._hoverManagerService.currentCell$.pipe(re.debounceTime(100)).subscribe(e=>{var t;if(e){const n=this._univerInstanceService.getUnit(e.location.unitId,o.UniverInstanceType.UNIVER_SHEET),a=n.getSheetBySheetId(e.location.subUnitId);if(!a)return;const r=this._dataValidationModel.getRuleByLocation(e.location.unitId,e.location.subUnitId,e.location.row,e.location.col);if(!r){this._cellAlertManagerService.removeAlert(ge);return}if(this._dataValidationModel.validator(r,{...e.location,workbook:n,worksheet:a})===o.DataValidationStatus.INVALID){const s=this._cellAlertManagerService.currentAlert.get(ge),c=(t=s==null?void 0:s.alert)==null?void 0:t.location;if(c&&c.row===e.location.row&&c.col===e.location.col&&c.subUnitId===e.location.subUnitId&&c.unitId===e.location.unitId){this._cellAlertManagerService.removeAlert(ge);return}const l=this._dataValidationModel.getValidator(r.type);if(!l){this._cellAlertManagerService.removeAlert(ge);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:ge});return}}this._cellAlertManagerService.removeAlert(ge)}))}_initZenService(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(e=>{e&&this._cellAlertManagerService.removeAlert(ge)}))}};Oe=$t([Ie(0,o.Inject(N.HoverManagerService)),Ie(1,o.Inject(N.CellAlertManagerService)),Ie(2,o.IUniverInstanceService),Ie(3,o.Inject(o.LocaleService)),Ie(4,E.IZenZoneService),Ie(5,o.Inject(C.SheetDataValidationModel))],Oe);var Ht=Object.getOwnPropertyDescriptor,Yt=(e,t,n,a)=>{for(var r=a>1?void 0:a?Ht(t,n):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},Ye=(e,t)=>(n,a)=>t(n,a,e);let we=class extends o.Disposable{constructor(e,t,n){super(),this._autoFillService=e,this._sheetDataValidationModel=t,this._injector=n,this._initAutoFill()}_initAutoFill(){const e=()=>({redos:[],undos:[]}),t=(a,r)=>{const{source:i,target:s,unitId:c,subUnitId:l}=a,d=this._sheetDataValidationModel.getRuleObjectMatrix(c,l).clone(),h=N.virtualizeDiscreteRanges([i,s]),[v,u]=h.ranges,{mapFunc:S}=h,p={row:v.startRow,col:v.startColumn},O=N.getAutoFillRepeatRange(v,u),M=new o.ObjectMatrix,R=new Set;O.forEach(f=>{const w=f.repeatStartCell,F=f.relativeRange,B={startRow:p.row,startColumn:p.col,endColumn:p.col,endRow:p.row},j={startRow:w.row,startColumn:w.col,endColumn:w.col,endRow:w.row};o.Range.foreach(F,(W,A)=>{const x=o.Rectangle.getPositionRange({startRow:W,startColumn:A,endColumn:A,endRow:W},B),{row:k,col:z}=S(x.startRow,x.startColumn),q=this._sheetDataValidationModel.getRuleIdByLocation(c,l,k,z)||"",te=o.Rectangle.getPositionRange({startRow:W,startColumn:A,endColumn:A,endRow:W},j),{row:K,col:ne}=S(te.startRow,te.startColumn);M.setValue(K,ne,q),R.add(q)})});const y=Array.from(R).map(f=>({id:f,ranges:o.queryObjectMatrix(M,w=>w===f)}));d.addRangeRules(y);const m=d.diff(this._sheetDataValidationModel.getRules(c,l)),{redoMutations:D,undoMutations:I}=C.getDataValidationDiffMutations(c,l,m,this._injector,"patched",r===N.APPLY_TYPE.ONLY_FORMAT);return{undos:I,redos:D}},n={id:C.DATA_VALIDATION_PLUGIN_NAME,onBeforeFillData:a=>{const{source:r,unitId:i,subUnitId:s}=a;for(const c of r.rows)for(const l of r.cols){const d=this._sheetDataValidationModel.getRuleByLocation(i,s,c,l);if(d&&d.type===o.DataValidationType.CHECKBOX){this._autoFillService.setDisableApplyType(N.APPLY_TYPE.SERIES,!0);return}}},onFillData:(a,r,i)=>i===N.APPLY_TYPE.COPY||i===N.APPLY_TYPE.ONLY_FORMAT||i===N.APPLY_TYPE.SERIES?t(a,i):e(),onAfterFillData:()=>{}};this.disposeWithMe(this._autoFillService.addHook(n))}};we=Yt([Ye(0,N.IAutoFillService),Ye(1,o.Inject(C.SheetDataValidationModel)),Ye(2,o.Inject(o.Injector))],we);var Xt=Object.getOwnPropertyDescriptor,zt=(e,t,n,a)=>{for(var r=a>1?void 0:a?Xt(t,n):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},Xe=(e,t)=>(n,a)=>t(n,a,e);let Ve=class extends o.Disposable{constructor(t,n,a){super();L(this,"_copyInfo");this._sheetClipboardService=t,this._sheetDataValidationModel=n,this._injector=a,this._initCopyPaste()}_initCopyPaste(){this._sheetClipboardService.addClipboardHook({id:C.DATA_VALIDATION_PLUGIN_NAME,onBeforeCopy:(t,n,a)=>this._collect(t,n,a),onPasteCells:(t,n,a,r)=>{const{copyType:i=N.COPY_TYPE.COPY,pasteType:s}=r,{range:c}=t||{},{range:l,unitId:d,subUnitId:h}=n;return this._generateMutations(l,{copyType:i,pasteType:s,copyRange:c,unitId:d,subUnitId:h})}})}_collect(t,n,a){const r=new o.ObjectMatrix;this._copyInfo={unitId:t,subUnitId:n,matrix:r};const i=this._injector.invoke(l=>H.rangeToDiscreteRange(a,l,t,n));if(!i)return;const{rows:s,cols:c}=i;s.forEach((l,d)=>{c.forEach((h,v)=>{const u=this._sheetDataValidationModel.getRuleIdByLocation(t,n,l,h);r.setValue(d,v,u!=null?u:"")})})}_generateMutations(t,n){if(!this._copyInfo)return{redos:[],undos:[]};if(n.copyType===N.COPY_TYPE.CUT)return this._copyInfo=null,{redos:[],undos:[]};if(!this._copyInfo||!this._copyInfo.matrix.getSizeOf()||!n.copyRange)return{redos:[],undos:[]};if([N.PREDEFINED_HOOK_NAME_PASTE.SPECIAL_PASTE_COL_WIDTH,N.PREDEFINED_HOOK_NAME_PASTE.SPECIAL_PASTE_VALUE,N.PREDEFINED_HOOK_NAME_PASTE.SPECIAL_PASTE_FORMAT,N.PREDEFINED_HOOK_NAME_PASTE.SPECIAL_PASTE_FORMULA].includes(n.pasteType))return{redos:[],undos:[]};const{unitId:r,subUnitId:i}=this._copyInfo;if(n.unitId!==r||i!==n.subUnitId){const s=this._sheetDataValidationModel.getRuleObjectMatrix(n.unitId,n.subUnitId).clone(),c=new o.ObjectMatrix,l=new Set,{ranges:[d,h],mapFunc:v}=N.virtualizeDiscreteRanges([n.copyRange,t]),u=N.getRepeatRange(d,h,!0),S=new Map;u.forEach(({startRange:R})=>{var y;(y=this._copyInfo)==null||y.matrix.forValue((m,D,I)=>{const f=o.Rectangle.getPositionRange({startRow:m,endRow:m,startColumn:D,endColumn:D},R),w=`${i}-${I}`,F=this._sheetDataValidationModel.getRuleById(r,i,I);!this._sheetDataValidationModel.getRuleById(n.unitId,n.subUnitId,w)&&F&&S.set(w,{...F,uid:w});const{row:B,col:j}=v(f.startRow,f.startColumn);l.add(w),c.setValue(B,j,w)})});const p=Array.from(l).map(R=>({id:R,ranges:o.queryObjectMatrix(c,y=>y===R)}));s.addRangeRules(p);const{redoMutations:O,undoMutations:M}=C.getDataValidationDiffMutations(n.unitId,n.subUnitId,s.diffWithAddition(this._sheetDataValidationModel.getRules(n.unitId,n.subUnitId),S.values()),this._injector,"patched",!1);return{redos:O,undos:M}}else{const s=this._sheetDataValidationModel.getRuleObjectMatrix(r,i).clone(),c=new o.ObjectMatrix,l=new Set,{ranges:[d,h],mapFunc:v}=N.virtualizeDiscreteRanges([n.copyRange,t]);N.getRepeatRange(d,h,!0).forEach(({startRange:M})=>{var R;(R=this._copyInfo)==null||R.matrix.forValue((y,m,D)=>{const I=o.Rectangle.getPositionRange({startRow:y,endRow:y,startColumn:m,endColumn:m},M),{row:f,col:w}=v(I.startRow,I.startColumn);c.setValue(f,w,D),l.add(D)})});const S=Array.from(l).map(M=>({id:M,ranges:o.queryObjectMatrix(c,R=>R===M)}));s.addRangeRules(S);const{redoMutations:p,undoMutations:O}=C.getDataValidationDiffMutations(r,i,s.diff(this._sheetDataValidationModel.getRules(r,i)),this._injector,"patched",!1);return{redos:p,undos:O}}}};Ve=zt([Xe(0,N.ISheetClipboardService),Xe(1,o.Inject(C.SheetDataValidationModel)),Xe(2,o.Inject(o.Injector))],Ve);var Kt=Object.getOwnPropertyDescriptor,Zt=(e,t,n,a)=>{for(var r=a>1?void 0:a?Kt(t,n):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},ze=(e,t)=>(n,a)=>t(n,a,e);let Ee=class extends o.Disposable{constructor(e,t,n){super(),this._localeService=e,this._commandService=t,this._sheetPermissionCheckController=n,this._commandExecutedListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.beforeCommandExecuted(e=>{if(e.id===C.AddSheetDataValidationCommand.id){const{unitId:t,subUnitId:n,rule:{ranges:a}}=e.params;this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[H.WorkbookEditablePermission],rangeTypes:[H.RangeProtectionPermissionEditPoint],worksheetTypes:[H.WorksheetEditPermission,H.WorksheetSetCellStylePermission]},a,t,n)||this._sheetPermissionCheckController.blockExecuteWithoutPermission(this._localeService.t("permission.dialog.setStyleErr"))}if(e.id===C.UpdateSheetDataValidationRangeCommand.id){const{unitId:t,subUnitId:n,ranges:a}=e.params;this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[H.WorkbookEditablePermission],rangeTypes:[H.RangeProtectionPermissionEditPoint],worksheetTypes:[H.WorksheetEditPermission,H.WorksheetSetCellStylePermission]},a,t,n)||this._sheetPermissionCheckController.blockExecuteWithoutPermission(this._localeService.t("permission.dialog.setStyleErr"))}}))}};Ee=Zt([ze(0,o.Inject(o.LocaleService)),ze(1,o.ICommandService),ze(2,o.Inject(H.SheetPermissionCheckController))],Ee);const It="sheet.menu.data-validation";function Gt(e){return{id:It,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 qt(e){return{id:fe.id,title:"dataValidation.panel.title",type:E.MenuItemType.BUTTON}}function Jt(e){return{id:$e.id,title:"dataValidation.panel.add",type:E.MenuItemType.BUTTON}}const Qt={[E.RibbonDataGroup.RULES]:{[It]:{order:0,menuItemFactory:Gt,[fe.id]:{order:0,menuItemFactory:qt},[$e.id]:{order:1,menuItemFactory:Jt}}}};var en=Object.getOwnPropertyDescriptor,Ct=(e,t,n,a)=>{for(var r=a>1?void 0:a?en(t,n):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},G=(e,t)=>(n,a)=>t(n,a,e);const yt={tr:{size:6,color:"#fe4b4b"}};let Me=class extends o.RxDisposable{constructor(e,t,n,a,r,i,s,c,l,d,h){super(),this._commandService=e,this._menuManagerService=t,this._renderManagerService=n,this._univerInstanceService=a,this._autoHeightController=r,this._dropdownManagerService=i,this._sheetDataValidationModel=s,this._dataValidatorRegistryService=c,this._sheetInterceptorService=l,this._dataValidationCacheService=d,this._editorBridgeService=h,this._initMenu(),this._initDropdown(),this._initViewModelIntercept(),this._initAutoHeight()}_initMenu(){this._menuManagerService.mergeMenu(Qt)}_initDropdown(){this._editorBridgeService&&this.disposeWithMe(this._editorBridgeService.visible$.subscribe(e=>{var n;if(!e.visible){((n=this._dropdownManagerService.activeDropdown)==null?void 0:n.trigger)==="editor-bridge"&&this._dropdownManagerService.hideDropdown();return}const t=this._editorBridgeService.getEditCellState();if(t){const{unitId:a,sheetId:r,row:i,column:s}=t,c=this._univerInstanceService.getUniverSheetInstance(a);if(!c)return;const l=this._sheetDataValidationModel.getRuleByLocation(a,r,i,s);if(!l)return;const d=this._dataValidatorRegistryService.getValidatorItem(l.type);if(!(d!=null&&d.dropdownType))return;const h=c.getActiveSheet();if(!h)return;const v=this._dropdownManagerService.activeDropdown,u=v==null?void 0:v.location;if(u&&u.unitId===a&&u.subUnitId===r&&u.row===i&&u.col===s)return;this._dropdownManagerService.showDropdown({location:{unitId:a,subUnitId:r,row:i,col:s,workbook:c,worksheet:h},trigger:"editor-bridge",closeOnOutSide:!1})}}))}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(H.INTERCEPTOR_POINT.CELL_CONTENT,{effect:o.InterceptorEffectEnum.Style,priority:H.InterceptCellContentPriority.DATA_VALIDATION,handler:(e,t,n)=>{var R,y,m,D,I;const{row:a,col:r,unitId:i,subUnitId:s,workbook:c,worksheet:l}=t,d=this._sheetDataValidationModel.getRuleIdByLocation(i,s,a,r);if(!d)return n(e);const h=this._sheetDataValidationModel.getRuleById(i,s,d);if(!h)return n(e);const v=(R=this._dataValidationCacheService.getValue(i,s,a,r))!=null?R:o.DataValidationStatus.VALID,u=this._dataValidatorRegistryService.getValidatorItem(h.type),S=t.rawData;let p;const O={get value(){var f;return p!==void 0||(p=(f=C.getCellValueOrigin(S))!=null?f:null),p}},M={get value(){var f;return`${(f=O.value)!=null?f:""}`}};return(!e||e===t.rawData)&&(e={...t.rawData}),e.markers={...e==null?void 0:e.markers,...v===o.DataValidationStatus.INVALID?yt: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:((m=e==null?void 0:e.fontRenderExtension)==null?void 0:m.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,M.value,{get style(){const f=c.getStyles();return(typeof(e==null?void 0:e.s)=="string"?f.get(e==null?void 0:e.s):e==null?void 0:e.s)||{}}},a,r)},e.interceptorAutoHeight=()=>{var B,j,W,A,x,k;const f=(j=(B=this._renderManagerService.getRenderById(i))==null?void 0:B.with(N.SheetSkeletonManagerService).getSkeletonParam(s))==null?void 0:j.skeleton;if(!f)return;const w=f.worksheet.getMergedCell(a,r),F={data:e,style:f.getStyles().getStyleByCell(e),primaryWithCoord:f.getCellWithCoordByIndex((W=w==null?void 0:w.startRow)!=null?W:a,(A=w==null?void 0:w.startColumn)!=null?A:r),unitId:i,subUnitId:s,row:a,col:r,workbook:c,worksheet:l};return(k=(x=u==null?void 0:u.canvasRender)==null?void 0:x.calcCellAutoHeight)==null?void 0:k.call(x,F)},e.interceptorAutoWidth=()=>{var B,j,W,A,x,k;const f=(j=(B=this._renderManagerService.getRenderById(i))==null?void 0:B.with(N.SheetSkeletonManagerService).getSkeletonParam(s))==null?void 0:j.skeleton;if(!f)return;const w=f.worksheet.getMergedCell(a,r),F={data:e,style:f.getStyles().getStyleByCell(e),primaryWithCoord:f.getCellWithCoordByIndex((W=w==null?void 0:w.startRow)!=null?W:a,(A=w==null?void 0:w.startColumn)!=null?A:r),unitId:i,subUnitId:s,row:a,col:r,workbook:c,worksheet:l};return(k=(x=u==null?void 0:u.canvasRender)==null?void 0:x.calcCellAutoWidth)==null?void 0:k.call(x,F)},e.coverable=((I=e==null?void 0:e.coverable)!=null?I:!0)&&!(h.type===o.DataValidationType.LIST||h.type===o.DataValidationType.LIST_MULTIPLE),n(e)}}))}_initAutoHeight(){this._sheetDataValidationModel.ruleChange$.pipe(re.filter(e=>e.source==="command"),re.bufferTime(100)).subscribe(e=>{if(e.length===0)return;const t=[];if(e.forEach(n=>{var a;(n.rule.type===o.DataValidationType.LIST_MULTIPLE||n.rule.type===o.DataValidationType.LIST)&&(a=n.rule)!=null&&a.ranges&&t.push(...n.rule.ranges)}),t.length){const n=this._autoHeightController.getUndoRedoParamsOfAutoHeight(t);o.sequenceExecute(n.redos,this._commandService)}})}};Me=Ct([G(0,o.ICommandService),G(1,E.IMenuManagerService),G(2,P.IRenderManagerService),G(3,o.IUniverInstanceService),G(4,o.Inject(N.AutoHeightController)),G(5,o.Inject(me)),G(6,o.Inject(C.SheetDataValidationModel)),G(7,o.Inject(Y.DataValidatorRegistryService)),G(8,o.Inject(H.SheetInterceptorService)),G(9,o.Inject(C.DataValidationCacheService)),G(10,o.Optional(N.IEditorBridgeService))],Me);let gt=class extends o.RxDisposable{constructor(e,t,n,a,r,i,s){super(),this._commandService=e,this._renderManagerService=t,this._autoHeightController=n,this._dataValidatorRegistryService=a,this._sheetInterceptorService=r,this._sheetDataValidationModel=i,this._dataValidationCacheService=s,this._initViewModelIntercept(),this._initAutoHeight()}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(H.INTERCEPTOR_POINT.CELL_CONTENT,{effect:o.InterceptorEffectEnum.Style,priority:H.InterceptCellContentPriority.DATA_VALIDATION,handler:(e,t,n)=>{var M,R,y,m,D;const{row:a,col:r,unitId:i,subUnitId:s,workbook:c,worksheet:l}=t,d=this._sheetDataValidationModel.getRuleIdByLocation(i,s,a,r);if(!d)return n(e);const h=this._sheetDataValidationModel.getRuleById(i,s,d);if(!h)return n(e);const v=(M=this._dataValidationCacheService.getValue(i,s,a,r))!=null?M:o.DataValidationStatus.VALID,u=this._dataValidatorRegistryService.getValidatorItem(h.type),S=l.getCellRaw(a,r),p=C.getCellValueOrigin(S),O=`${p!=null?p:""}`;return(!e||e===t.rawData)&&(e={...t.rawData}),e.markers={...e==null?void 0:e.markers,...v===o.DataValidationStatus.INVALID?yt:null},e.customRender=[...(R=e==null?void 0:e.customRender)!=null?R:[],...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)||((m=u==null?void 0:u.skipDefaultFontRender)==null?void 0:m.call(u,h,p,t))},e.interceptorStyle={...e==null?void 0:e.interceptorStyle,...u==null?void 0:u.getExtraStyle(h,O,{get style(){const I=c.getStyles();return(typeof(e==null?void 0:e.s)=="string"?I.get(e==null?void 0:e.s):e==null?void 0:e.s)||{}}},a,r)},e.interceptorAutoHeight=()=>{var F,B,j,W,A,x;const I=(B=(F=this._renderManagerService.getRenderById(i))==null?void 0:F.with(N.SheetSkeletonManagerService).getSkeletonParam(s))==null?void 0:B.skeleton;if(!I)return;const f=I.worksheet.getMergedCell(a,r),w={data:e,style:I.getStyles().getStyleByCell(e),primaryWithCoord:I.getCellWithCoordByIndex((j=f==null?void 0:f.startRow)!=null?j:a,(W=f==null?void 0:f.startColumn)!=null?W:r),unitId:i,subUnitId:s,row:a,col:r,workbook:c,worksheet:l};return(x=(A=u==null?void 0:u.canvasRender)==null?void 0:A.calcCellAutoHeight)==null?void 0:x.call(A,w)},e.interceptorAutoWidth=()=>{var F,B,j,W,A,x;const I=(B=(F=this._renderManagerService.getRenderById(i))==null?void 0:F.with(N.SheetSkeletonManagerService).getSkeletonParam(s))==null?void 0:B.skeleton;if(!I)return;const f=I.worksheet.getMergedCell(a,r),w={data:e,style:I.getStyles().getStyleByCell(e),primaryWithCoord:I.getCellWithCoordByIndex((j=f==null?void 0:f.startRow)!=null?j:a,(W=f==null?void 0:f.startColumn)!=null?W:r),unitId:i,subUnitId:s,row:a,col:r,workbook:c,worksheet:l};return(x=(A=u==null?void 0:u.canvasRender)==null?void 0:A.calcCellAutoWidth)==null?void 0:x.call(A,w)},e.coverable=((D=e==null?void 0:e.coverable)!=null?D:!0)&&!(h.type===o.DataValidationType.LIST||h.type===o.DataValidationType.LIST_MULTIPLE),n(e)}}))}_initAutoHeight(){this._sheetDataValidationModel.ruleChange$.pipe(re.filter(e=>e.source==="command"),re.bufferTime(16)).subscribe(e=>{const t=[];if(e.forEach(n=>{var a;(n.rule.type===o.DataValidationType.LIST_MULTIPLE||n.rule.type===o.DataValidationType.LIST)&&(a=n.rule)!=null&&a.ranges&&t.push(...n.rule.ranges)}),t.length){const n=this._autoHeightController.getUndoRedoParamsOfAutoHeight(t);o.sequenceExecute(n.redos,this._commandService)}})}};gt=Ct([G(0,o.ICommandService),G(1,P.IRenderManagerService),G(2,o.Inject(N.AutoHeightController)),G(3,o.Inject(Y.DataValidatorRegistryService)),G(4,o.Inject(H.SheetInterceptorService)),G(5,o.Inject(C.SheetDataValidationModel)),G(6,o.Inject(C.DataValidationCacheService))],gt);var tn=Object.getOwnPropertyDescriptor,nn=(e,t,n,a)=>{for(var r=a>1?void 0:a?tn(t,n):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},pt=(e,t)=>(n,a)=>t(n,a,e);let Fe=class extends o.Disposable{constructor(e,t,n){super(),this._context=e,this._sheetDataValidationModel=t,this._sheetSkeletonManagerService=n,this._initSkeletonChange()}_initSkeletonChange(){const e=t=>{var a;if(!t.length)return;const n=new Set;t.forEach(r=>{n.add(r.subUnitId)}),n.forEach(r=>{var i;(i=this._sheetSkeletonManagerService.getSkeletonParam(r))==null||i.skeleton.makeDirty(!0)}),(a=this._context.mainComponent)==null||a.makeForceDirty()};this.disposeWithMe(this._sheetDataValidationModel.validStatusChange$.pipe(o.bufferDebounceTime(16)).subscribe(e))}};Fe=nn([pt(1,o.Inject(C.SheetDataValidationModel)),pt(2,o.Inject(N.SheetSkeletonManagerService))],Fe);function Se({ref:e,...t}){const{icon:n,id:a,className:r,extend:i,...s}=t,c=`univerjs-icon univerjs-icon-${a} ${r||""}`.trim(),l=T.useRef(`_${on()}`);return Rt(n,`${a}`,{defIds:n.defIds,idSuffix:l.current},{ref:e,className:c,...s},i)}function Rt(e,t,n,a,r){return T.createElement(e.tag,{key:t,...an(e,n,r),...a},(rn(e,n).children||[]).map((i,s)=>Rt(i,`${t}-${e.tag}-${s}`,n,void 0,r)))}function an(e,t,n){const a={...e.attrs};n!=null&&n.colorChannel1&&a.fill==="colorChannel1"&&(a.fill=n.colorChannel1),e.tag==="mask"&&a.id&&(a.id=a.id+t.idSuffix),Object.entries(a).forEach(([i,s])=>{i==="mask"&&typeof s=="string"&&(a[i]=s.replace(/url\(#(.*)\)/,`url(#$1${t.idSuffix})`))});const{defIds:r}=t;return!r||r.length===0||(e.tag==="use"&&a["xlink:href"]&&(a["xlink:href"]=a["xlink:href"]+t.idSuffix),Object.entries(a).forEach(([i,s])=>{typeof s=="string"&&(a[i]=s.replace(/url\(#(.*)\)/,`url(#$1${t.idSuffix})`))})),a}function rn(e,t){var a;const{defIds:n}=t;return!n||n.length===0?e:e.tag==="defs"&&((a=e.children)!=null&&a.length)?{...e,children:e.children.map(r=>typeof r.attrs.id=="string"&&n&&n.includes(r.attrs.id)?{...r,attrs:{...r.attrs,id:r.attrs.id+t.idSuffix}}:r)}:e}function on(){return Math.random().toString(36).substring(2,8)}Se.displayName="UniverIcon";const 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"}}]},Dt=T.forwardRef(function(t,n){return T.createElement(Se,Object.assign({},t,{id:"data-validation-icon",ref:n,icon:sn}))});Dt.displayName="DataValidationIcon";const 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"}}]},ct=T.forwardRef(function(t,n){return T.createElement(Se,Object.assign({},t,{id:"delete-icon",ref:n,icon:ln}))});ct.displayName="DeleteIcon";const 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:"M8.6 1.99991C8.60001 1.66854 8.33138 1.39991 8.00001 1.3999C7.66864 1.3999 7.40001 1.66853 7.4 1.9999L7.39996 7.3999H1.9999C1.66853 7.3999 1.3999 7.66853 1.3999 7.9999C1.3999 8.33127 1.66853 8.5999 1.9999 8.5999H7.39995L7.3999 13.9999C7.3999 14.3313 7.66853 14.5999 7.9999 14.5999C8.33127 14.5999 8.5999 14.3313 8.5999 13.9999L8.59995 8.5999H13.9999C14.3313 8.5999 14.5999 8.33127 14.5999 7.9999C14.5999 7.66853 14.3313 7.3999 13.9999 7.3999H8.59996L8.6 1.99991Z"}}]},wt=T.forwardRef(function(t,n){return T.createElement(Se,Object.assign({},t,{id:"increase-icon",ref:n,icon:cn}))});wt.displayName="IncreaseIcon";const 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:"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"}}]},dt=T.forwardRef(function(t,n){return T.createElement(Se,Object.assign({},t,{id:"more-down-icon",ref:n,icon:dn}))});dt.displayName="MoreDownIcon";const un={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"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"}}]},Vt=T.forwardRef(function(t,n){return T.createElement(Se,Object.assign({},t,{id:"more-up-icon",ref:n,icon:un}))});Vt.displayName="MoreUpIcon";const hn={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M6 5C6.55228 5 7 4.55228 7 4C7 3.44772 6.55228 3 6 3C5.44772 3 5 3.44772 5 4C5 4.55228 5.44772 5 6 5Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M6 9C6.55228 9 7 8.55229 7 8C7 7.44772 6.55228 7 6 7C5.44772 7 5 7.44772 5 8C5 8.55229 5.44772 9 6 9Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M7 12C7 12.5523 6.55228 13 6 13C5.44772 13 5 12.5523 5 12C5 11.4477 5.44772 11 6 11C6.55228 11 7 11.4477 7 12Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M10 5C10.5523 5 11 4.55228 11 4C11 3.44772 10.5523 3 10 3C9.44771 3 9 3.44772 9 4C9 4.55228 9.44771 5 10 5Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M11 8C11 8.55229 10.5523 9 10 9C9.44771 9 9 8.55229 9 8C9 7.44772 9.44771 7 10 7C10.5523 7 11 7.44772 11 8Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M10 13C10.5523 13 11 12.5523 11 12C11 11.4477 10.5523 11 10 11C9.44771 11 9 11.4477 9 12C9 12.5523 9.44771 13 10 13Z"}}]},Et=T.forwardRef(function(t,n){return T.createElement(Se,Object.assign({},t,{id:"sequence-icon",ref:n,icon:hn}))});Et.displayName="SequenceIcon";function gn(e){var d;const t=E.useDependency(o.LocaleService),n=E.useDependency(E.ComponentManager),{value:a,onChange:r,extraComponent:i}=e,[s,c]=T.useState(!1),l=i?n.get(i):null;return g.jsxs(g.Fragment,{children:[g.jsxs("div",{className:"univer-mb-3 univer-flex univer-cursor-pointer univer-items-center univer-text-sm univer-text-gray-900 dark:!univer-text-white",onClick:()=>c(!s),children:[t.t("dataValidation.panel.options"),s?g.jsx(Vt,{className:"univer-ml-1"}):g.jsx(dt,{className:"univer-ml-1"})]}),s&&g.jsxs(g.Fragment,{children:[l?g.jsx(l,{value:a,onChange:r}):null,g.jsx(V.FormLayout,{label:t.t("dataValidation.panel.invalid"),children:g.jsxs(V.RadioGroup,{value:`${(d=a.errorStyle)!=null?d:o.DataValidationErrorStyle.WARNING}`,onChange:h=>r({...a,errorStyle:+h}),children:[g.jsx(V.Radio,{value:`${o.DataValidationErrorStyle.WARNING}`,children:t.t("dataValidation.panel.showWarning")}),g.jsx(V.Radio,{value:`${o.DataValidationErrorStyle.STOP}`,children:t.t("dataValidation.panel.rejectInput")})]})}),g.jsx(V.FormLayout,{label:t.t("dataValidation.panel.messageInfo"),children:g.jsx(V.Checkbox,{checked:a.showErrorMessage,onChange:()=>r({...a,showErrorMessage:!a.showErrorMessage}),children:t.t("dataValidation.panel.showInfo")})}),a.showErrorMessage?g.jsx(V.FormLayout,{children:g.jsx(V.Input,{value:a.error,onChange:h=>r({...a,error:h})})}):null]})]})}const pn=e=>o.debounce(async(t,n,a,r)=>{const i=await e.executeCommand(t,n,a);r==null||r(i)},1e3);function vn(e,t,n){var a,r,i,s;return t?((r=(a=e.getUnit(t))==null?void 0:a.getSheetBySheetName(n))==null?void 0:r.getSheetId())||"":((s=(i=e.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET))==null?void 0:i.getSheetBySheetName(n))==null?void 0:s.getSheetId())||""}function mn(){var b,$;const[e,t]=T.useState(0),n=E.useDependency(ce),a=E.useObservable(n.activeRule$,n.activeRule),{unitId:r,subUnitId:i,rule:s}=a||{},c=s.uid,l=E.useDependency(Y.DataValidatorRegistryService),d=E.useDependency(o.IUniverInstanceService),h=E.useDependency(E.ComponentManager),v=E.useDependency(o.ICommandService),u=E.useDependency(Y.DataValidationModel),S=E.useDependency(o.LocaleService),[p,O]=T.useState(s),M=l.getValidatorItem(p.type),[R,y]=T.useState(!1),m=l.getValidatorsByScope(Y.DataValidatorRegistryScope.SHEET),[D,I]=T.useState(()=>p.ranges.map(_=>({unitId:"",sheetId:"",range:_}))),f=T.useMemo(()=>pn(v),[v]),[w,F]=T.useState(!1),[B,j]=T.useState(!1),W=T.useRef(null),A=E.useDependency(H.SheetsSelectionsService);if(T.useEffect(()=>()=>{const _=A.getCurrentLastSelection();_&&A.setSelections([_])},[A]),T.useEffect(()=>{v.onCommandExecuted(_=>{(_.id===o.UndoCommand.id||_.id===o.RedoCommand.id)&&setTimeout(()=>{const U=u.getRuleById(r,i,c);t(X=>X+1),U&&(O(U),I(U.ranges.map(X=>({unitId:"",sheetId:"",range:X}))))},20)})},[v,u,c,i,r]),!M)return null;const x=M.operators,k=M.operatorNames,z=p.operator?Y.TWO_FORMULA_OPERATOR_COUNT.includes(p.operator):!1,q=()=>{var _,U,X;(U=(_=W.current)==null?void 0:_.editor)!=null&&U.isFocus()&&te((X=W.current)==null?void 0:X.getValue()),!(!p.ranges.length||w)&&(M.validatorFormula(p,r,i).success?n.setActiveRule(null):y(!0))},te=E.useEvent(_=>{const U=_.split(",").filter(Boolean).map(tt.deserializeRangeWithSheet).map(ee=>{const ut=ee.sheetName;if(ut){const Ot=vn(d,ee.unitId,ut);return{...ee,sheetId:Ot}}return{...ee,sheetId:""}});if(o.isUnitRangesEqual(U,D))return;I(U);const X=U.filter(ee=>(!ee.unitId||ee.unitId===r)&&(!ee.sheetId||ee.sheetId===i)).map(ee=>ee.range);if(O({...p,ranges:X}),X.length===0)return;const ie={unitId:r,subUnitId:i,ruleId:c,ranges:X};f(C.UpdateSheetDataValidationRangeCommand.id,ie)}),K=_=>{if(o.shallowEqual(_,Y.getRuleSetting(p)))return;O({...p,..._});const U={unitId:r,subUnitId:i,ruleId:c,setting:_};f(C.UpdateSheetDataValidationSettingCommand.id,U,void 0)},ne=async()=>{await v.executeCommand(C.RemoveSheetDataValidationCommand.id,{ruleId:c,unitId:r,subUnitId:i}),n.setActiveRule(null)},ae={type:p.type,operator:p.operator,formula1:p.formula1,formula2:p.formula2,allowBlank:p.allowBlank},de=_=>{const U=l.getValidatorItem(_);if(!U)return;const X=U.operators,ie=u.getRuleById(r,i,c),ee=_===(ie==null?void 0:ie.type)||_.includes("list")&&(ie!=null&&ie.type.includes("list"))?{...ie,type:_}:{...p,type:_,operator:X[0],formula1:void 0,formula2:void 0};O(ee),v.executeCommand(C.UpdateSheetDataValidationSettingCommand.id,{unitId:r,subUnitId:i,ruleId:p.uid,setting:Y.getRuleSetting(ee)})},ue=h.get(M.formulaInput),Q=T.useMemo(()=>D.map(_=>tt.serializeRange(_.range)).join(","),[]),Z=Y.getRuleOptions(p),le=_=>{o.shallowEqual(_,Y.getRuleOptions(p))||(O({...p,..._}),f(C.UpdateSheetDataValidationOptionsCommand.id,{unitId:r,subUnitId:i,ruleId:c,options:_}))},J=x.length&&!p.operator;return g.jsxs("div",{"data-u-comp":"data-validation-detail",className:"univer-py-2",children:[g.jsx(V.FormLayout,{label:S.t("dataValidation.panel.range"),error:!p.ranges.length||w?S.t("dataValidation.panel.rangeError"):"",children:g.jsx(ot.RangeSelector,{selectorRef:W,unitId:r,subUnitId:i,initialValue:Q,onChange:(_,U)=>{var X;!B&&((X=W.current)!=null&&X.verify())&&te(U)},onFocusChange:(_,U)=>{var X;j(_),!_&&U&&((X=W.current)!=null&&X.verify())&&te(U)},onVerify:_=>F(!_)})}),g.jsx(V.FormLayout,{label:S.t("dataValidation.panel.type"),children:g.jsx(V.Select,{className:"univer-w-full",value:p.type,options:(b=m==null?void 0:m.sort((_,U)=>_.order-U.order))==null?void 0:b.map(_=>({label:S.t(_.title),value:_.id})),onChange:de})}),x!=null&&x.length?g.jsx(V.FormLayout,{label:S.t("dataValidation.panel.operator"),children:g.jsx(V.Select,{className:"univer-w-full",value:`${p.operator}`,options:[{value:"",label:S.t("dataValidation.operators.legal")},...x.map((_,U)=>({value:`${_}`,label:k[U]}))],onChange:_=>{K({...ae,operator:_})}})}):null,ue&&!J?g.jsx(ue,{isTwoFormula:z,value:{formula1:p.formula1,formula2:p.formula2},onChange:_=>{K({...ae,..._})},showError:R,validResult:M.validatorFormula(p,r,i),unitId:r,subUnitId:i,ruleId:c},e+p.type):null,g.jsx(V.FormLayout,{children:g.jsx(V.Checkbox,{checked:($=p.allowBlank)!=null?$:!0,onChange:()=>{var _;return K({...ae,allowBlank:!((_=p.allowBlank)==null||_)})},children:S.t("dataValidation.panel.allowBlank")})}),g.jsx(gn,{value:Z,onChange:le,extraComponent:M.optionsInput}),g.jsxs("div",{className:"univer-mt-5 univer-flex univer-flex-row univer-justify-end",children:[g.jsx(V.Button,{className:"univer-ml-3",onClick:ne,children:S.t("dataValidation.panel.removeRule")}),g.jsx(V.Button,{className:"univer-ml-3",variant:"primary",onClick:q,children:S.t("dataValidation.panel.done")})]})]})}const fn=e=>{const{rule:t,onClick:n,unitId:a,subUnitId:r,disable:i}=e,s=E.useDependency(Y.DataValidatorRegistryService),c=E.useDependency(o.ICommandService),l=E.useDependency(N.IMarkSelectionService),d=s.getValidatorItem(t.type),h=T.useRef(void 0),[v,u]=T.useState(!1),S=E.useDependency(o.ThemeService),p=E.useObservable(S.currentTheme$),O=T.useMemo(()=>{var I;const R=S.getColorFromTheme("primary.600"),y=S.getColorFromTheme("loop-color.2"),m=(I=S.getColorFromTheme(y))!=null?I:R,D=new o.ColorKit(m).toRgb();return{fill:`rgba(${D.r}, ${D.g}, ${D.b}, 0.1)`,stroke:m}},[p]),M=R=>{c.executeCommand(C.RemoveSheetDataValidationCommand.id,{ruleId:t.uid,unitId:a,subUnitId:r}),R.stopPropagation()};return T.useEffect(()=>()=>{var R;h.current&&((R=h.current)==null||R.forEach(y=>{y&&l.removeShape(y)}))},[l]),g.jsxs("div",{className:V.clsx(`
1
+ "use strict";var At=Object.defineProperty;var Lt=(e,t,n)=>t in e?At(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var L=(e,t,n)=>Lt(e,typeof t!="symbol"?t+"":t,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("@univerjs/core"),P=require("@univerjs/engine-render"),H=require("@univerjs/sheets"),I=require("@univerjs/sheets-data-validation"),Y=require("@univerjs/data-validation"),V=require("@univerjs/ui"),re=require("rxjs"),Pt=require("@univerjs/sheets-numfmt"),N=require("@univerjs/sheets-ui"),w=require("@univerjs/design"),T=require("react"),g=require("react/jsx-runtime"),nt=require("@univerjs/engine-formula"),st=require("@univerjs/sheets-formula-ui");var jt=Object.getOwnPropertyDescriptor,xt=(e,t,n,a)=>{for(var r=a>1?void 0:a?jt(t,n):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},ht=(e,t)=>(n,a)=>t(n,a,e);let ce=class extends o.Disposable{constructor(t,n){super();L(this,"_open$",new re.BehaviorSubject(!1));L(this,"open$",this._open$.pipe(re.distinctUntilChanged()));L(this,"_activeRule");L(this,"_activeRule$",new re.BehaviorSubject(void 0));L(this,"activeRule$",this._activeRule$.asObservable());L(this,"_closeDisposable",null);this._univerInstanceService=t,this._sidebarService=n,this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(o.UniverInstanceType.UNIVER_SHEET).pipe(re.filter(a=>!a)).subscribe(()=>{this.close()})),this.disposeWithMe(this._sidebarService.sidebarOptions$.subscribe(a=>{a.id===Fe&&(a.visible||setTimeout(()=>{this._sidebarService.sidebarOptions$.next({visible:!1})}))}))}get activeRule(){return this._activeRule}get isOpen(){return this._open$.getValue()}dispose(){var t;super.dispose(),this._open$.next(!1),this._open$.complete(),this._activeRule$.complete(),(t=this._closeDisposable)==null||t.dispose()}open(){this._open$.next(!0)}close(){var t;this._open$.next(!1),(t=this._closeDisposable)==null||t.dispose()}setCloseDisposable(t){this._closeDisposable=o.toDisposable(()=>{t.dispose(),this._closeDisposable=null})}setActiveRule(t){this._activeRule=t,this._activeRule$.next(t)}};ce=xt([ht(0,o.IUniverInstanceService),ht(1,V.ISidebarService)],ce);const ve="#ECECEC",xe="sheets-data-validation-ui.config",Ue={};var Ut=Object.getOwnPropertyDescriptor,Ft=(e,t,n,a)=>{for(var r=a>1?void 0:a?Ut(t,n):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},_e=(e,t)=>(n,a)=>t(n,a,e);let De=class extends o.Disposable{constructor(e,t,n,a,r,i){super(),this._sheetInterceptorService=e,this._dataValidationModel=t,this._dataValidatorRegistryService=n,this._dialogService=a,this._localeService=r,this._sheetsDataValidationValidatorService=i,this._initEditorBridgeInterceptor()}_initEditorBridgeInterceptor(){this.disposeWithMe(this._sheetInterceptorService.writeCellInterceptor.intercept(H.VALIDATE_CELL,{handler:async(e,t,n)=>{const a=await e,{row:r,col:i,unitId:s,subUnitId:c}=t,l=this._dataValidationModel.getRuleIdByLocation(s,c,r,i),d=l?this._dataValidationModel.getRuleById(s,c,l):void 0;if(a===!1)return n(Promise.resolve(!1));if(!d||d.errorStyle!==o.DataValidationErrorStyle.STOP)return n(Promise.resolve(!0));const h=this._dataValidatorRegistryService.getValidatorItem(d.type);return!h||await this._sheetsDataValidationValidatorService.validatorCell(s,c,r,i)===o.DataValidationStatus.VALID?n(Promise.resolve(!0)):(this._dialogService.open({width:368,title:{title:this._localeService.t("dataValidation.alert.title")},id:"reject-input-dialog",children:{title:h.getRuleFinalError(d,{row:r,col:i,unitId:s,subUnitId:c})},footer:{title:T.createElement(w.Button,{variant:"primary",onClick:()=>this._dialogService.close("reject-input-dialog")},this._localeService.t("dataValidation.alert.ok"))},onClose:()=>{this._dialogService.close("reject-input-dialog")}}),n(Promise.resolve(!1)))}}))}showReject(e){this._dialogService.open({width:368,title:{title:this._localeService.t("dataValidation.alert.title")},id:"reject-input-dialog",children:{title:e},footer:{title:T.createElement(w.Button,{variant:"primary",onClick:()=>this._dialogService.close("reject-input-dialog")},this._localeService.t("dataValidation.alert.ok"))},onClose:()=>{this._dialogService.close("reject-input-dialog")}})}};De=Ft([_e(0,o.Inject(H.SheetInterceptorService)),_e(1,o.Inject(I.SheetDataValidationModel)),_e(2,o.Inject(Y.DataValidatorRegistryService)),_e(3,V.IDialogService),_e(4,o.Inject(o.LocaleService)),_e(5,o.Inject(I.SheetsDataValidationValidatorService))],De);var kt=Object.getOwnPropertyDescriptor,Nt=(e,t,n,a)=>{for(var r=a>1?void 0:a?kt(t,n):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},oe=(e,t)=>(n,a)=>t(n,a,e);const Ye=e=>{if(e==null||typeof e=="boolean")return;if(e==="")return o.dayjs();if(typeof e=="number"||!Number.isNaN(+e))return o.dayjs(o.numfmt.format("yyyy-MM-dd HH:mm:ss",Number(e)));const t=o.dayjs(e);if(t.isValid())return t};function Bt(e,t){const n=Pt.getPatternType(t);if(e===n)return t;switch(e){case"datetime":return"yyyy-MM-dd hh:mm:ss";case"date":return"yyyy-MM-dd";case"time":return"HH:mm:ss"}}let me=class extends o.Disposable{constructor(t,n,a,r,i,s,c,l,d,h,m){super();L(this,"_activeDropdown");L(this,"_activeDropdown$",new re.Subject);L(this,"_currentPopup",null);L(this,"activeDropdown$",this._activeDropdown$.asObservable());L(this,"_zenVisible",!1);this._univerInstanceService=t,this._dataValidatorRegistryService=n,this._zenZoneService=a,this._dataValidationModel=r,this._sheetsSelectionsService=i,this._cellDropdownManagerService=s,this._sheetDataValidationModel=c,this._commandService=l,this._editorBridgeService=d,this._injector=h,this._configService=m,this._init(),this._initSelectionChange(),this.disposeWithMe(()=>{this._activeDropdown$.complete()})}get activeDropdown(){return this._activeDropdown}_init(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(t=>{this._zenVisible=t,t&&this.hideDropdown()}))}_getDropdownByCell(t,n,a,r){const i=t?this._univerInstanceService.getUnit(t,o.UniverInstanceType.UNIVER_SHEET):this._univerInstanceService.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET);if(!i)return;const s=n?i.getSheetBySheetId(n):i.getActiveSheet();if(!s)return;const c=this._dataValidationModel.getRuleByLocation(i.getUnitId(),s.getSheetId(),a,r);if(!c)return;const l=this._dataValidatorRegistryService.getValidatorItem(c.type);return l==null?void 0:l.dropdownType}_initSelectionChange(){this.disposeWithMe(this._sheetsSelectionsService.selectionMoveEnd$.subscribe(t=>{t&&t.every(n=>!(n.primary&&this._getDropdownByCell(n.primary.unitId,n.primary.sheetId,n.primary.actualRow,n.primary.actualColumn)))&&this.hideDropdown()}))}showDropdown(t){var A,E,R,y,D,O;const{location:n}=t,{row:a,col:r,unitId:i,subUnitId:s,workbook:c,worksheet:l}=n;if(this._currentPopup&&this._currentPopup.dispose(),this._zenVisible)return;this._activeDropdown=t,this._activeDropdown$.next(this._activeDropdown);const d=this._sheetDataValidationModel.getRuleByLocation(i,s,a,r);if(!d)return;const h=this._dataValidatorRegistryService.getValidatorItem(d.type);if(!(h!=null&&h.dropdownType))return;let m;const u=async(f,v)=>{var U,z,Z;if(!f)return!0;const C=f,F=l.getCell(a,r),B=C.format(v==="date"?"YYYY-MM-DD 00:00:00":"YYYY-MM-DD HH:mm:ss"),$=(U=o.numfmt.parseDate(B))==null?void 0:U.v,k=v==="time"?$%1:$,M=c.getStyles().getStyleByCell(F),j=(Z=(z=M==null?void 0:M.n)==null?void 0:z.pattern)!=null?Z:"";return d.errorStyle!==o.DataValidationErrorStyle.STOP||await h.validator({value:k,unitId:i,subUnitId:s,row:a,column:r,worksheet:l,workbook:c,interceptValue:B.replace("Z","").replace("T"," "),t:o.CellValueType.NUMBER},d)?(await this._commandService.executeCommand(H.SetRangeValuesCommand.id,{unitId:i,subUnitId:s,range:{startColumn:r,endColumn:r,startRow:a,endRow:a},value:{v:k,t:2,p:null,f:null,si:null,s:{n:{pattern:Bt(v,j)}}}}),await this._commandService.executeCommand(N.SetCellEditVisibleOperation.id,{visible:!1,eventType:P.DeviceInputEventType.Keyboard,unitId:i,keycode:V.KeyCode.ESC}),!0):(this._injector.has(De)&&this._injector.get(De).showReject(h.getRuleFinalError(d,{row:a,col:r,unitId:i,subUnitId:s})),!1)};let S;switch(h.dropdownType){case Y.DataValidatorDropdownType.DATE:{const f=I.getCellValueOrigin(l.getCellRaw(a,r)),v=Ye(f),C=!!((A=d.bizInfo)!=null&&A.showTime);S={location:n,type:"datepicker",props:{showTime:C,onChange:F=>u(F,C?"datetime":"date"),defaultValue:v,patternType:"date"}};break}case Y.DataValidatorDropdownType.TIME:{const f=I.getCellValueOrigin(l.getCellRaw(a,r)),v=Ye(f);S={location:n,type:"datepicker",props:{onChange:C=>u(C,"time"),defaultValue:v,patternType:"time"}};break}case Y.DataValidatorDropdownType.DATETIME:{const f=I.getCellValueOrigin(l.getCellRaw(a,r)),v=Ye(f);S={location:n,type:"datepicker",props:{onChange:C=>u(C,"datetime"),defaultValue:v,patternType:"datetime"}};break}case Y.DataValidatorDropdownType.LIST:case Y.DataValidatorDropdownType.MULTIPLE_LIST:{const f=h.dropdownType===Y.DataValidatorDropdownType.MULTIPLE_LIST,v=async M=>{const j=I.serializeListOptions(M),U={unitId:i,subUnitId:s,range:{startColumn:r,endColumn:r,startRow:a,endRow:a},value:{v:j,p:null,f:null,si:null}};return this._commandService.executeCommand(H.SetRangeValuesCommand.id,U),this._editorBridgeService.isVisible().visible&&await this._commandService.executeCommand(N.SetCellEditVisibleOperation.id,{visible:!1,eventType:P.DeviceInputEventType.Keyboard,unitId:i,keycode:V.KeyCode.ESC}),!f},C=(d==null?void 0:d.renderMode)===o.DataValidationRenderMode.CUSTOM||(d==null?void 0:d.renderMode)===void 0,F=h.getListWithColor(d,i,s),B=I.getDataValidationCellValue(l.getCellRaw(a,r)),$=()=>{this._commandService.executeCommand(fe.id,{ruleId:d.uid}),m==null||m.dispose()},k=F.map(M=>({label:M.label,value:M.label,color:C||M.color?M.color||ve:"transparent"}));S={location:n,type:"list",props:{onChange:M=>v(M),options:k,onEdit:$,defaultValue:B,multiple:f,showEdit:(R=(E=this._configService.getConfig(xe))==null?void 0:E.showEditOnDropdown)!=null?R:!0,showSearch:(D=(y=this._configService.getConfig(xe))==null?void 0:y.showSearchOnDropdown)!=null?D:!0}};break}case Y.DataValidatorDropdownType.CASCADE:{S={type:"cascader",props:{onChange:v=>{const C={unitId:i,subUnitId:s,range:{startColumn:r,endColumn:r,startRow:a,endRow:a},value:{v:v.join("/"),p:null,f:null,si:null}};return this._commandService.syncExecuteCommand(H.SetRangeValuesCommand.id,C),this._editorBridgeService.isVisible().visible&&this._commandService.syncExecuteCommand(N.SetCellEditVisibleOperation.id,{visible:!1,eventType:P.DeviceInputEventType.Keyboard,unitId:i,keycode:V.KeyCode.ESC}),!0},defaultValue:I.getDataValidationCellValue(l.getCellRaw(a,r)).split("/"),options:JSON.parse((O=d.formula1)!=null?O:"[]")},location:n};break}case Y.DataValidatorDropdownType.COLOR:{S={type:"color",props:{onChange:v=>{const C={unitId:i,subUnitId:s,range:{startColumn:r,endColumn:r,startRow:a,endRow:a},value:{v,p:null,f:null,si:null}};return this._commandService.syncExecuteCommand(H.SetRangeValuesCommand.id,C),this._editorBridgeService.isVisible().visible&&this._commandService.syncExecuteCommand(N.SetCellEditVisibleOperation.id,{visible:!1,eventType:P.DeviceInputEventType.Keyboard,unitId:i,keycode:V.KeyCode.ESC}),!0},defaultValue:I.getDataValidationCellValue(l.getCellRaw(a,r))},location:n};break}default:throw new Error("[DataValidationDropdownManagerService]: unknown type!")}if(m=this._cellDropdownManagerService.showDropdown({...S,onHide:()=>{this._activeDropdown=null,this._activeDropdown$.next(null)}}),!m)throw new Error("[DataValidationDropdownManagerService]: cannot show dropdown!");const p=new o.DisposableCollection;p.add(m),p.add({dispose:()=>{var f,v;(v=(f=this._activeDropdown)==null?void 0:f.onHide)==null||v.call(f)}}),this._currentPopup=p}hideDropdown(){this._activeDropdown&&(this._currentPopup&&this._currentPopup.dispose(),this._currentPopup=null,this._activeDropdown=null,this._activeDropdown$.next(null))}showDataValidationDropdown(t,n,a,r,i){const s=this._univerInstanceService.getUnit(t,o.UniverInstanceType.UNIVER_SHEET);if(!s)return;const c=s.getSheetBySheetId(n);if(!c)return;const l=this._dataValidationModel.getRuleByLocation(s.getUnitId(),c.getSheetId(),a,r);if(!l)return;const d=this._dataValidatorRegistryService.getValidatorItem(l.type);if(!d||!d.dropdownType){this.hideDropdown();return}this.showDropdown({location:{workbook:s,worksheet:c,row:a,col:r,unitId:t,subUnitId:n},onHide:i})}};me=Nt([oe(0,o.IUniverInstanceService),oe(1,o.Inject(Y.DataValidatorRegistryService)),oe(2,V.IZenZoneService),oe(3,o.Inject(I.SheetDataValidationModel)),oe(4,o.Inject(H.SheetsSelectionsService)),oe(5,o.Inject(N.ISheetCellDropdownManagerService)),oe(6,o.Inject(I.SheetDataValidationModel)),oe(7,o.ICommandService),oe(8,N.IEditorBridgeService),oe(9,o.Inject(o.Injector)),oe(10,o.IConfigService)],me);const Fe="DataValidationPanel",fe={id:"data-validation.operation.open-validation-panel",type:o.CommandType.OPERATION,handler(e,t){if(!t)return!1;const{ruleId:n,isAdd:a}=t,r=e.get(ce),i=e.get(Y.DataValidationModel),s=e.get(o.IUniverInstanceService),c=e.get(V.ISidebarService),l=H.getSheetCommandTarget(s);if(!l)return!1;const{unitId:d,subUnitId:h}=l,m=n?i.getRuleById(d,h,n):void 0;r.open(),r.setActiveRule(m&&{unitId:d,subUnitId:h,rule:m});const u=c.open({id:Fe,header:{title:a?"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(ce).close(),!0}},St={id:"data-validation.operation.toggle-validation-panel",type:o.CommandType.OPERATION,handler(e){const t=e.get(o.ICommandService),n=e.get(ce);return n.open(),n.isOpen?t.executeCommand(lt.id):t.executeCommand(fe.id),!0}},$e={type:o.CommandType.OPERATION,id:"sheet.operation.show-data-validation-dropdown",handler(e,t){if(!t)return!1;const n=e.get(me),{unitId:a,subUnitId:r,row:i,column:s}=t,c=n.activeDropdown,l=c==null?void 0:c.location;return l&&l.unitId===a&&l.subUnitId===r&&l.row===i&&l.col===s||n.showDataValidationDropdown(a,r,i,s),!0}},_t={type:o.CommandType.OPERATION,id:"sheet.operation.hide-data-validation-dropdown",handler(e,t){return t?(e.get(me).hideDropdown(),!0):!1}},He={type:o.CommandType.COMMAND,id:"data-validation.command.addRuleAndOpen",handler(e){const t=e.get(o.IUniverInstanceService),n=H.getSheetCommandTarget(t);if(!n)return!1;const{workbook:a,worksheet:r}=n,i=I.createDefaultNewRule(e),s=e.get(o.ICommandService),c=a.getUnitId(),l=r.getSheetId(),d={rule:i,unitId:c,subUnitId:l};return s.syncExecuteCommand(I.AddSheetDataValidationCommand.id,d)?(s.syncExecuteCommand(fe.id,{ruleId:i.uid,isAdd:!0}),!0):!1}};var Wt=Object.getOwnPropertyDescriptor,$t=(e,t,n,a)=>{for(var r=a>1?void 0:a?Wt(t,n):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},Ie=(e,t)=>(n,a)=>t(n,a,e);const ge="SHEET_DATA_VALIDATION_ALERT";let Oe=class extends o.Disposable{constructor(e,t,n,a,r,i){super(),this._hoverManagerService=e,this._cellAlertManagerService=t,this._univerInstanceService=n,this._localeService=a,this._zenZoneService=r,this._dataValidationModel=i,this._init()}_init(){this._initCellAlertPopup(),this._initZenService()}_initCellAlertPopup(){this.disposeWithMe(this._hoverManagerService.currentCell$.pipe(re.debounceTime(100)).subscribe(e=>{var t;if(e){const n=this._univerInstanceService.getUnit(e.location.unitId,o.UniverInstanceType.UNIVER_SHEET),a=n.getSheetBySheetId(e.location.subUnitId);if(!a)return;const r=this._dataValidationModel.getRuleByLocation(e.location.unitId,e.location.subUnitId,e.location.row,e.location.col);if(!r){this._cellAlertManagerService.removeAlert(ge);return}if(this._dataValidationModel.validator(r,{...e.location,workbook:n,worksheet:a})===o.DataValidationStatus.INVALID){const s=this._cellAlertManagerService.currentAlert.get(ge),c=(t=s==null?void 0:s.alert)==null?void 0:t.location;if(c&&c.row===e.location.row&&c.col===e.location.col&&c.subUnitId===e.location.subUnitId&&c.unitId===e.location.unitId){this._cellAlertManagerService.removeAlert(ge);return}const l=this._dataValidationModel.getValidator(r.type);if(!l){this._cellAlertManagerService.removeAlert(ge);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:ge});return}}this._cellAlertManagerService.removeAlert(ge)}))}_initZenService(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(e=>{e&&this._cellAlertManagerService.removeAlert(ge)}))}};Oe=$t([Ie(0,o.Inject(N.HoverManagerService)),Ie(1,o.Inject(N.CellAlertManagerService)),Ie(2,o.IUniverInstanceService),Ie(3,o.Inject(o.LocaleService)),Ie(4,V.IZenZoneService),Ie(5,o.Inject(I.SheetDataValidationModel))],Oe);var Ht=Object.getOwnPropertyDescriptor,Yt=(e,t,n,a)=>{for(var r=a>1?void 0:a?Ht(t,n):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},Xe=(e,t)=>(n,a)=>t(n,a,e);let we=class extends o.Disposable{constructor(e,t,n){super(),this._autoFillService=e,this._sheetDataValidationModel=t,this._injector=n,this._initAutoFill()}_initAutoFill(){const e=()=>({redos:[],undos:[]}),t=(a,r)=>{const{source:i,target:s,unitId:c,subUnitId:l}=a,d=this._sheetDataValidationModel.getRuleObjectMatrix(c,l).clone(),h=N.virtualizeDiscreteRanges([i,s]),[m,u]=h.ranges,{mapFunc:S}=h,p={row:m.startRow,col:m.startColumn},A=N.getAutoFillRepeatRange(m,u),E=new o.ObjectMatrix,R=new Set;A.forEach(v=>{const C=v.repeatStartCell,F=v.relativeRange,B={startRow:p.row,startColumn:p.col,endColumn:p.col,endRow:p.row},$={startRow:C.row,startColumn:C.col,endColumn:C.col,endRow:C.row};o.Range.foreach(F,(k,M)=>{const j=o.Rectangle.getPositionRange({startRow:k,startColumn:M,endColumn:M,endRow:k},B),{row:U,col:z}=S(j.startRow,j.startColumn),Z=this._sheetDataValidationModel.getRuleIdByLocation(c,l,U,z)||"",Q=o.Rectangle.getPositionRange({startRow:k,startColumn:M,endColumn:M,endRow:k},$),{row:K,col:ne}=S(Q.startRow,Q.startColumn);E.setValue(K,ne,Z),R.add(Z)})});const y=Array.from(R).map(v=>({id:v,ranges:o.queryObjectMatrix(E,C=>C===v)}));d.addRangeRules(y);const D=d.diff(this._sheetDataValidationModel.getRules(c,l)),{redoMutations:O,undoMutations:f}=I.getDataValidationDiffMutations(c,l,D,this._injector,"patched",r===N.APPLY_TYPE.ONLY_FORMAT);return{undos:f,redos:O}},n={id:I.DATA_VALIDATION_PLUGIN_NAME,onBeforeFillData:a=>{const{source:r,unitId:i,subUnitId:s}=a;for(const c of r.rows)for(const l of r.cols){const d=this._sheetDataValidationModel.getRuleByLocation(i,s,c,l);if(d&&d.type===o.DataValidationType.CHECKBOX){this._autoFillService.setDisableApplyType(N.APPLY_TYPE.SERIES,!0);return}}},onFillData:(a,r,i)=>i===N.APPLY_TYPE.COPY||i===N.APPLY_TYPE.ONLY_FORMAT||i===N.APPLY_TYPE.SERIES?t(a,i):e(),onAfterFillData:()=>{}};this.disposeWithMe(this._autoFillService.addHook(n))}};we=Yt([Xe(0,N.IAutoFillService),Xe(1,o.Inject(I.SheetDataValidationModel)),Xe(2,o.Inject(o.Injector))],we);var Xt=Object.getOwnPropertyDescriptor,zt=(e,t,n,a)=>{for(var r=a>1?void 0:a?Xt(t,n):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},ze=(e,t)=>(n,a)=>t(n,a,e);let Ve=class extends o.Disposable{constructor(t,n,a){super();L(this,"_copyInfo");this._sheetClipboardService=t,this._sheetDataValidationModel=n,this._injector=a,this._initCopyPaste()}_initCopyPaste(){this._sheetClipboardService.addClipboardHook({id:I.DATA_VALIDATION_PLUGIN_NAME,onBeforeCopy:(t,n,a)=>this._collect(t,n,a),onPasteCells:(t,n,a,r)=>{const{copyType:i=N.COPY_TYPE.COPY,pasteType:s}=r,{range:c}=t||{},{range:l,unitId:d,subUnitId:h}=n;return this._generateMutations(l,{copyType:i,pasteType:s,copyRange:c,unitId:d,subUnitId:h})}})}_collect(t,n,a){const r=new o.ObjectMatrix;this._copyInfo={unitId:t,subUnitId:n,matrix:r};const i=this._injector.invoke(l=>H.rangeToDiscreteRange(a,l,t,n));if(!i)return;const{rows:s,cols:c}=i;s.forEach((l,d)=>{c.forEach((h,m)=>{const u=this._sheetDataValidationModel.getRuleIdByLocation(t,n,l,h);r.setValue(d,m,u!=null?u:"")})})}_generateMutations(t,n){if(!this._copyInfo)return{redos:[],undos:[]};if(n.copyType===N.COPY_TYPE.CUT)return this._copyInfo=null,{redos:[],undos:[]};if(!this._copyInfo||!this._copyInfo.matrix.getSizeOf()||!n.copyRange)return{redos:[],undos:[]};if([N.PREDEFINED_HOOK_NAME_PASTE.SPECIAL_PASTE_COL_WIDTH,N.PREDEFINED_HOOK_NAME_PASTE.SPECIAL_PASTE_VALUE,N.PREDEFINED_HOOK_NAME_PASTE.SPECIAL_PASTE_FORMAT,N.PREDEFINED_HOOK_NAME_PASTE.SPECIAL_PASTE_FORMULA].includes(n.pasteType))return{redos:[],undos:[]};const{unitId:r,subUnitId:i}=this._copyInfo;if(n.unitId!==r||i!==n.subUnitId){const s=this._sheetDataValidationModel.getRuleObjectMatrix(n.unitId,n.subUnitId).clone(),c=new o.ObjectMatrix,l=new Set,{ranges:[d,h],mapFunc:m}=N.virtualizeDiscreteRanges([n.copyRange,t]),u=N.getRepeatRange(d,h,!0),S=new Map;u.forEach(({startRange:R})=>{var y;(y=this._copyInfo)==null||y.matrix.forValue((D,O,f)=>{const v=o.Rectangle.getPositionRange({startRow:D,endRow:D,startColumn:O,endColumn:O},R),C=`${i}-${f}`,F=this._sheetDataValidationModel.getRuleById(r,i,f);!this._sheetDataValidationModel.getRuleById(n.unitId,n.subUnitId,C)&&F&&S.set(C,{...F,uid:C});const{row:B,col:$}=m(v.startRow,v.startColumn);l.add(C),c.setValue(B,$,C)})});const p=Array.from(l).map(R=>({id:R,ranges:o.queryObjectMatrix(c,y=>y===R)}));s.addRangeRules(p);const{redoMutations:A,undoMutations:E}=I.getDataValidationDiffMutations(n.unitId,n.subUnitId,s.diffWithAddition(this._sheetDataValidationModel.getRules(n.unitId,n.subUnitId),S.values()),this._injector,"patched",!1);return{redos:A,undos:E}}else{const s=this._sheetDataValidationModel.getRuleObjectMatrix(r,i).clone(),c=new o.ObjectMatrix,l=new Set,{ranges:[d,h],mapFunc:m}=N.virtualizeDiscreteRanges([n.copyRange,t]);N.getRepeatRange(d,h,!0).forEach(({startRange:E})=>{var R;(R=this._copyInfo)==null||R.matrix.forValue((y,D,O)=>{const f=o.Rectangle.getPositionRange({startRow:y,endRow:y,startColumn:D,endColumn:D},E),{row:v,col:C}=m(f.startRow,f.startColumn);c.setValue(v,C,O),l.add(O)})});const S=Array.from(l).map(E=>({id:E,ranges:o.queryObjectMatrix(c,R=>R===E)}));s.addRangeRules(S);const{redoMutations:p,undoMutations:A}=I.getDataValidationDiffMutations(r,i,s.diff(this._sheetDataValidationModel.getRules(r,i)),this._injector,"patched",!1);return{redos:p,undos:A}}}};Ve=zt([ze(0,N.ISheetClipboardService),ze(1,o.Inject(I.SheetDataValidationModel)),ze(2,o.Inject(o.Injector))],Ve);var Kt=Object.getOwnPropertyDescriptor,Zt=(e,t,n,a)=>{for(var r=a>1?void 0:a?Kt(t,n):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},Ke=(e,t)=>(n,a)=>t(n,a,e);let Ee=class extends o.Disposable{constructor(e,t,n){super(),this._localeService=e,this._commandService=t,this._sheetPermissionCheckController=n,this._commandExecutedListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.beforeCommandExecuted(e=>{if(e.id===I.AddSheetDataValidationCommand.id){const{unitId:t,subUnitId:n,rule:{ranges:a}}=e.params;this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[H.WorkbookEditablePermission],rangeTypes:[H.RangeProtectionPermissionEditPoint],worksheetTypes:[H.WorksheetEditPermission,H.WorksheetSetCellStylePermission]},a,t,n)||this._sheetPermissionCheckController.blockExecuteWithoutPermission(this._localeService.t("permission.dialog.setStyleErr"))}if(e.id===I.UpdateSheetDataValidationRangeCommand.id){const{unitId:t,subUnitId:n,ranges:a}=e.params;this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[H.WorkbookEditablePermission],rangeTypes:[H.RangeProtectionPermissionEditPoint],worksheetTypes:[H.WorksheetEditPermission,H.WorksheetSetCellStylePermission]},a,t,n)||this._sheetPermissionCheckController.blockExecuteWithoutPermission(this._localeService.t("permission.dialog.setStyleErr"))}}))}};Ee=Zt([Ke(0,o.Inject(o.LocaleService)),Ke(1,o.ICommandService),Ke(2,o.Inject(H.SheetPermissionCheckController))],Ee);const It="sheet.menu.data-validation";function Gt(e){return{id:It,type:V.MenuItemType.SUBITEMS,icon:"DataValidationIcon",tooltip:"dataValidation.title",hidden$:V.getMenuHiddenObservable(e,o.UniverInstanceType.UNIVER_SHEET),disabled$:N.getCurrentRangeDisable$(e,{workbookTypes:[H.WorkbookEditablePermission],worksheetTypes:[H.WorksheetSetCellStylePermission,H.WorksheetEditPermission],rangeTypes:[H.RangeProtectionPermissionEditPoint]})}}function qt(e){return{id:fe.id,title:"dataValidation.panel.title",type:V.MenuItemType.BUTTON}}function Jt(e){return{id:He.id,title:"dataValidation.panel.add",type:V.MenuItemType.BUTTON}}const Qt={[V.RibbonDataGroup.RULES]:{[It]:{order:0,menuItemFactory:Gt,[fe.id]:{order:0,menuItemFactory:qt},[He.id]:{order:1,menuItemFactory:Jt}}}};var en=Object.getOwnPropertyDescriptor,Ct=(e,t,n,a)=>{for(var r=a>1?void 0:a?en(t,n):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},q=(e,t)=>(n,a)=>t(n,a,e);const yt={tr:{size:6,color:"#fe4b4b"}};let Me=class extends o.RxDisposable{constructor(e,t,n,a,r,i,s,c,l,d,h){super(),this._commandService=e,this._menuManagerService=t,this._renderManagerService=n,this._univerInstanceService=a,this._autoHeightController=r,this._dropdownManagerService=i,this._sheetDataValidationModel=s,this._dataValidatorRegistryService=c,this._sheetInterceptorService=l,this._dataValidationCacheService=d,this._editorBridgeService=h,this._initMenu(),this._initDropdown(),this._initViewModelIntercept(),this._initAutoHeight()}_initMenu(){this._menuManagerService.mergeMenu(Qt)}_initDropdown(){this._editorBridgeService&&this.disposeWithMe(this._editorBridgeService.visible$.subscribe(e=>{var n;if(!e.visible){((n=this._dropdownManagerService.activeDropdown)==null?void 0:n.trigger)==="editor-bridge"&&this._dropdownManagerService.hideDropdown();return}const t=this._editorBridgeService.getEditCellState();if(t){const{unitId:a,sheetId:r,row:i,column:s}=t,c=this._univerInstanceService.getUniverSheetInstance(a);if(!c)return;const l=this._sheetDataValidationModel.getRuleByLocation(a,r,i,s);if(!l)return;const d=this._dataValidatorRegistryService.getValidatorItem(l.type);if(!(d!=null&&d.dropdownType))return;const h=c.getActiveSheet();if(!h)return;const m=this._dropdownManagerService.activeDropdown,u=m==null?void 0:m.location;if(u&&u.unitId===a&&u.subUnitId===r&&u.row===i&&u.col===s)return;this._dropdownManagerService.showDropdown({location:{unitId:a,subUnitId:r,row:i,col:s,workbook:c,worksheet:h},trigger:"editor-bridge",closeOnOutSide:!1})}}))}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(H.INTERCEPTOR_POINT.CELL_CONTENT,{effect:o.InterceptorEffectEnum.Style,priority:H.InterceptCellContentPriority.DATA_VALIDATION,handler:(e,t,n)=>{var R,y,D,O,f;const{row:a,col:r,unitId:i,subUnitId:s,workbook:c,worksheet:l}=t,d=this._sheetDataValidationModel.getRuleIdByLocation(i,s,a,r);if(!d)return n(e);const h=this._sheetDataValidationModel.getRuleById(i,s,d);if(!h)return n(e);const m=(R=this._dataValidationCacheService.getValue(i,s,a,r))!=null?R:o.DataValidationStatus.VALID,u=this._dataValidatorRegistryService.getValidatorItem(h.type),S=t.rawData;let p;const A={get value(){var v;return p!==void 0||(p=(v=I.getCellValueOrigin(S))!=null?v:null),p}},E={get value(){var v;return`${(v=A.value)!=null?v:""}`}};return(!e||e===t.rawData)&&(e={...t.rawData}),e.markers={...e==null?void 0:e.markers,...m===o.DataValidationStatus.INVALID?yt: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:((D=e==null?void 0:e.fontRenderExtension)==null?void 0:D.isSkip)||((O=u==null?void 0:u.skipDefaultFontRender)==null?void 0:O.call(u,h,A.value,t))},e.interceptorStyle={...e==null?void 0:e.interceptorStyle,...u==null?void 0:u.getExtraStyle(h,E.value,{get style(){const v=c.getStyles();return(typeof(e==null?void 0:e.s)=="string"?v.get(e==null?void 0:e.s):e==null?void 0:e.s)||{}}},a,r)},e.interceptorAutoHeight=()=>{var B,$,k,M,j,U;const v=($=(B=this._renderManagerService.getRenderById(i))==null?void 0:B.with(N.SheetSkeletonManagerService).getSkeletonParam(s))==null?void 0:$.skeleton;if(!v)return;const C=v.worksheet.getMergedCell(a,r),F={data:e,style:v.getStyles().getStyleByCell(e),primaryWithCoord:v.getCellWithCoordByIndex((k=C==null?void 0:C.startRow)!=null?k:a,(M=C==null?void 0:C.startColumn)!=null?M:r),unitId:i,subUnitId:s,row:a,col:r,workbook:c,worksheet:l};return(U=(j=u==null?void 0:u.canvasRender)==null?void 0:j.calcCellAutoHeight)==null?void 0:U.call(j,F)},e.interceptorAutoWidth=()=>{var B,$,k,M,j,U;const v=($=(B=this._renderManagerService.getRenderById(i))==null?void 0:B.with(N.SheetSkeletonManagerService).getSkeletonParam(s))==null?void 0:$.skeleton;if(!v)return;const C=v.worksheet.getMergedCell(a,r),F={data:e,style:v.getStyles().getStyleByCell(e),primaryWithCoord:v.getCellWithCoordByIndex((k=C==null?void 0:C.startRow)!=null?k:a,(M=C==null?void 0:C.startColumn)!=null?M:r),unitId:i,subUnitId:s,row:a,col:r,workbook:c,worksheet:l};return(U=(j=u==null?void 0:u.canvasRender)==null?void 0:j.calcCellAutoWidth)==null?void 0:U.call(j,F)},e.coverable=((f=e==null?void 0:e.coverable)!=null?f:!0)&&!(h.type===o.DataValidationType.LIST||h.type===o.DataValidationType.LIST_MULTIPLE),n(e)}}))}_initAutoHeight(){this._sheetDataValidationModel.ruleChange$.pipe(re.filter(e=>e.source==="command"),re.bufferTime(100)).subscribe(e=>{if(e.length===0)return;const t=[];if(e.forEach(n=>{var a;(n.rule.type===o.DataValidationType.LIST_MULTIPLE||n.rule.type===o.DataValidationType.LIST)&&(a=n.rule)!=null&&a.ranges&&t.push(...n.rule.ranges)}),t.length){const n=this._autoHeightController.getUndoRedoParamsOfAutoHeight(t);o.sequenceExecute(n.redos,this._commandService)}})}};Me=Ct([q(0,o.ICommandService),q(1,V.IMenuManagerService),q(2,P.IRenderManagerService),q(3,o.IUniverInstanceService),q(4,o.Inject(N.AutoHeightController)),q(5,o.Inject(me)),q(6,o.Inject(I.SheetDataValidationModel)),q(7,o.Inject(Y.DataValidatorRegistryService)),q(8,o.Inject(H.SheetInterceptorService)),q(9,o.Inject(I.DataValidationCacheService)),q(10,o.Optional(N.IEditorBridgeService))],Me);let gt=class extends o.RxDisposable{constructor(e,t,n,a,r,i,s){super(),this._commandService=e,this._renderManagerService=t,this._autoHeightController=n,this._dataValidatorRegistryService=a,this._sheetInterceptorService=r,this._sheetDataValidationModel=i,this._dataValidationCacheService=s,this._initViewModelIntercept(),this._initAutoHeight()}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(H.INTERCEPTOR_POINT.CELL_CONTENT,{effect:o.InterceptorEffectEnum.Style,priority:H.InterceptCellContentPriority.DATA_VALIDATION,handler:(e,t,n)=>{var E,R,y,D,O;const{row:a,col:r,unitId:i,subUnitId:s,workbook:c,worksheet:l}=t,d=this._sheetDataValidationModel.getRuleIdByLocation(i,s,a,r);if(!d)return n(e);const h=this._sheetDataValidationModel.getRuleById(i,s,d);if(!h)return n(e);const m=(E=this._dataValidationCacheService.getValue(i,s,a,r))!=null?E:o.DataValidationStatus.VALID,u=this._dataValidatorRegistryService.getValidatorItem(h.type),S=l.getCellRaw(a,r),p=I.getCellValueOrigin(S),A=`${p!=null?p:""}`;return(!e||e===t.rawData)&&(e={...t.rawData}),e.markers={...e==null?void 0:e.markers,...m===o.DataValidationStatus.INVALID?yt:null},e.customRender=[...(R=e==null?void 0:e.customRender)!=null?R:[],...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)||((D=u==null?void 0:u.skipDefaultFontRender)==null?void 0:D.call(u,h,p,t))},e.interceptorStyle={...e==null?void 0:e.interceptorStyle,...u==null?void 0:u.getExtraStyle(h,A,{get style(){const f=c.getStyles();return(typeof(e==null?void 0:e.s)=="string"?f.get(e==null?void 0:e.s):e==null?void 0:e.s)||{}}},a,r)},e.interceptorAutoHeight=()=>{var F,B,$,k,M,j;const f=(B=(F=this._renderManagerService.getRenderById(i))==null?void 0:F.with(N.SheetSkeletonManagerService).getSkeletonParam(s))==null?void 0:B.skeleton;if(!f)return;const v=f.worksheet.getMergedCell(a,r),C={data:e,style:f.getStyles().getStyleByCell(e),primaryWithCoord:f.getCellWithCoordByIndex(($=v==null?void 0:v.startRow)!=null?$:a,(k=v==null?void 0:v.startColumn)!=null?k:r),unitId:i,subUnitId:s,row:a,col:r,workbook:c,worksheet:l};return(j=(M=u==null?void 0:u.canvasRender)==null?void 0:M.calcCellAutoHeight)==null?void 0:j.call(M,C)},e.interceptorAutoWidth=()=>{var F,B,$,k,M,j;const f=(B=(F=this._renderManagerService.getRenderById(i))==null?void 0:F.with(N.SheetSkeletonManagerService).getSkeletonParam(s))==null?void 0:B.skeleton;if(!f)return;const v=f.worksheet.getMergedCell(a,r),C={data:e,style:f.getStyles().getStyleByCell(e),primaryWithCoord:f.getCellWithCoordByIndex(($=v==null?void 0:v.startRow)!=null?$:a,(k=v==null?void 0:v.startColumn)!=null?k:r),unitId:i,subUnitId:s,row:a,col:r,workbook:c,worksheet:l};return(j=(M=u==null?void 0:u.canvasRender)==null?void 0:M.calcCellAutoWidth)==null?void 0:j.call(M,C)},e.coverable=((O=e==null?void 0:e.coverable)!=null?O:!0)&&!(h.type===o.DataValidationType.LIST||h.type===o.DataValidationType.LIST_MULTIPLE),n(e)}}))}_initAutoHeight(){this._sheetDataValidationModel.ruleChange$.pipe(re.filter(e=>e.source==="command"),re.bufferTime(16)).subscribe(e=>{const t=[];if(e.forEach(n=>{var a;(n.rule.type===o.DataValidationType.LIST_MULTIPLE||n.rule.type===o.DataValidationType.LIST)&&(a=n.rule)!=null&&a.ranges&&t.push(...n.rule.ranges)}),t.length){const n=this._autoHeightController.getUndoRedoParamsOfAutoHeight(t);o.sequenceExecute(n.redos,this._commandService)}})}};gt=Ct([q(0,o.ICommandService),q(1,P.IRenderManagerService),q(2,o.Inject(N.AutoHeightController)),q(3,o.Inject(Y.DataValidatorRegistryService)),q(4,o.Inject(H.SheetInterceptorService)),q(5,o.Inject(I.SheetDataValidationModel)),q(6,o.Inject(I.DataValidationCacheService))],gt);var tn=Object.getOwnPropertyDescriptor,nn=(e,t,n,a)=>{for(var r=a>1?void 0:a?tn(t,n):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},pt=(e,t)=>(n,a)=>t(n,a,e);let ke=class extends o.Disposable{constructor(e,t,n){super(),this._context=e,this._sheetDataValidationModel=t,this._sheetSkeletonManagerService=n,this._initSkeletonChange()}_initSkeletonChange(){const e=t=>{var a;if(!t.length)return;const n=new Set;t.forEach(r=>{n.add(r.subUnitId)}),n.forEach(r=>{var i;(i=this._sheetSkeletonManagerService.getSkeletonParam(r))==null||i.skeleton.makeDirty(!0)}),(a=this._context.mainComponent)==null||a.makeForceDirty()};this.disposeWithMe(this._sheetDataValidationModel.validStatusChange$.pipe(o.bufferDebounceTime(16)).subscribe(e))}};ke=nn([pt(1,o.Inject(I.SheetDataValidationModel)),pt(2,o.Inject(N.SheetSkeletonManagerService))],ke);function Se({ref:e,...t}){const{icon:n,id:a,className:r,extend:i,...s}=t,c=`univerjs-icon univerjs-icon-${a} ${r||""}`.trim(),l=T.useRef(`_${on()}`);return Rt(n,`${a}`,{defIds:n.defIds,idSuffix:l.current},{ref:e,className:c,...s},i)}function Rt(e,t,n,a,r){return T.createElement(e.tag,{key:t,...an(e,n,r),...a},(rn(e,n).children||[]).map((i,s)=>Rt(i,`${t}-${e.tag}-${s}`,n,void 0,r)))}function an(e,t,n){const a={...e.attrs};n!=null&&n.colorChannel1&&a.fill==="colorChannel1"&&(a.fill=n.colorChannel1),e.tag==="mask"&&a.id&&(a.id=a.id+t.idSuffix),Object.entries(a).forEach(([i,s])=>{i==="mask"&&typeof s=="string"&&(a[i]=s.replace(/url\(#(.*)\)/,`url(#$1${t.idSuffix})`))});const{defIds:r}=t;return!r||r.length===0||(e.tag==="use"&&a["xlink:href"]&&(a["xlink:href"]=a["xlink:href"]+t.idSuffix),Object.entries(a).forEach(([i,s])=>{typeof s=="string"&&(a[i]=s.replace(/url\(#(.*)\)/,`url(#$1${t.idSuffix})`))})),a}function rn(e,t){var a;const{defIds:n}=t;return!n||n.length===0?e:e.tag==="defs"&&((a=e.children)!=null&&a.length)?{...e,children:e.children.map(r=>typeof r.attrs.id=="string"&&n&&n.includes(r.attrs.id)?{...r,attrs:{...r.attrs,id:r.attrs.id+t.idSuffix}}:r)}:e}function on(){return Math.random().toString(36).substring(2,8)}Se.displayName="UniverIcon";const 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"}}]},Dt=T.forwardRef(function(t,n){return T.createElement(Se,Object.assign({},t,{id:"data-validation-icon",ref:n,icon:sn}))});Dt.displayName="DataValidationIcon";const 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"}}]},ct=T.forwardRef(function(t,n){return T.createElement(Se,Object.assign({},t,{id:"delete-icon",ref:n,icon:ln}))});ct.displayName="DeleteIcon";const 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:"M8.6 1.99991C8.60001 1.66854 8.33138 1.39991 8.00001 1.3999C7.66864 1.3999 7.40001 1.66853 7.4 1.9999L7.39996 7.3999H1.9999C1.66853 7.3999 1.3999 7.66853 1.3999 7.9999C1.3999 8.33127 1.66853 8.5999 1.9999 8.5999H7.39995L7.3999 13.9999C7.3999 14.3313 7.66853 14.5999 7.9999 14.5999C8.33127 14.5999 8.5999 14.3313 8.5999 13.9999L8.59995 8.5999H13.9999C14.3313 8.5999 14.5999 8.33127 14.5999 7.9999C14.5999 7.66853 14.3313 7.3999 13.9999 7.3999H8.59996L8.6 1.99991Z"}}]},wt=T.forwardRef(function(t,n){return T.createElement(Se,Object.assign({},t,{id:"increase-icon",ref:n,icon:cn}))});wt.displayName="IncreaseIcon";const 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:"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"}}]},dt=T.forwardRef(function(t,n){return T.createElement(Se,Object.assign({},t,{id:"more-down-icon",ref:n,icon:dn}))});dt.displayName="MoreDownIcon";const un={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"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"}}]},Vt=T.forwardRef(function(t,n){return T.createElement(Se,Object.assign({},t,{id:"more-up-icon",ref:n,icon:un}))});Vt.displayName="MoreUpIcon";const hn={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M6 5C6.55228 5 7 4.55228 7 4C7 3.44772 6.55228 3 6 3C5.44772 3 5 3.44772 5 4C5 4.55228 5.44772 5 6 5Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M6 9C6.55228 9 7 8.55229 7 8C7 7.44772 6.55228 7 6 7C5.44772 7 5 7.44772 5 8C5 8.55229 5.44772 9 6 9Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M7 12C7 12.5523 6.55228 13 6 13C5.44772 13 5 12.5523 5 12C5 11.4477 5.44772 11 6 11C6.55228 11 7 11.4477 7 12Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M10 5C10.5523 5 11 4.55228 11 4C11 3.44772 10.5523 3 10 3C9.44771 3 9 3.44772 9 4C9 4.55228 9.44771 5 10 5Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M11 8C11 8.55229 10.5523 9 10 9C9.44771 9 9 8.55229 9 8C9 7.44772 9.44771 7 10 7C10.5523 7 11 7.44772 11 8Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M10 13C10.5523 13 11 12.5523 11 12C11 11.4477 10.5523 11 10 11C9.44771 11 9 11.4477 9 12C9 12.5523 9.44771 13 10 13Z"}}]},Et=T.forwardRef(function(t,n){return T.createElement(Se,Object.assign({},t,{id:"sequence-icon",ref:n,icon:hn}))});Et.displayName="SequenceIcon";function gn(e){var d;const t=V.useDependency(o.LocaleService),n=V.useDependency(V.ComponentManager),{value:a,onChange:r,extraComponent:i}=e,[s,c]=T.useState(!1),l=i?n.get(i):null;return g.jsxs(g.Fragment,{children:[g.jsxs("div",{className:"univer-mb-3 univer-flex univer-cursor-pointer univer-items-center univer-text-sm univer-text-gray-900 dark:!univer-text-white",onClick:()=>c(!s),children:[t.t("dataValidation.panel.options"),s?g.jsx(Vt,{className:"univer-ml-1"}):g.jsx(dt,{className:"univer-ml-1"})]}),s&&g.jsxs(g.Fragment,{children:[l?g.jsx(l,{value:a,onChange:r}):null,g.jsx(w.FormLayout,{label:t.t("dataValidation.panel.invalid"),children:g.jsxs(w.RadioGroup,{value:`${(d=a.errorStyle)!=null?d:o.DataValidationErrorStyle.WARNING}`,onChange:h=>r({...a,errorStyle:+h}),children:[g.jsx(w.Radio,{value:`${o.DataValidationErrorStyle.WARNING}`,children:t.t("dataValidation.panel.showWarning")}),g.jsx(w.Radio,{value:`${o.DataValidationErrorStyle.STOP}`,children:t.t("dataValidation.panel.rejectInput")})]})}),g.jsx(w.FormLayout,{label:t.t("dataValidation.panel.messageInfo"),children:g.jsx(w.Checkbox,{checked:a.showErrorMessage,onChange:()=>r({...a,showErrorMessage:!a.showErrorMessage}),children:t.t("dataValidation.panel.showInfo")})}),a.showErrorMessage?g.jsx(w.FormLayout,{children:g.jsx(w.Input,{value:a.error,onChange:h=>r({...a,error:h})})}):null]})]})}const pn=e=>o.debounce(async(t,n,a,r)=>{const i=await e.executeCommand(t,n,a);r==null||r(i)},1e3);function vn(e,t,n){var a,r,i,s;return t?((r=(a=e.getUnit(t))==null?void 0:a.getSheetBySheetName(n))==null?void 0:r.getSheetId())||"":((s=(i=e.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET))==null?void 0:i.getSheetBySheetName(n))==null?void 0:s.getSheetId())||""}function mn(){var b,W;const[e,t]=T.useState(0),n=V.useDependency(ce),a=V.useObservable(n.activeRule$,n.activeRule),{unitId:r,subUnitId:i,rule:s}=a||{},c=s.uid,l=V.useDependency(Y.DataValidatorRegistryService),d=V.useDependency(o.IUniverInstanceService),h=V.useDependency(V.ComponentManager),m=V.useDependency(o.ICommandService),u=V.useDependency(Y.DataValidationModel),S=V.useDependency(o.LocaleService),[p,A]=T.useState(s),E=l.getValidatorItem(p.type),[R,y]=T.useState(!1),D=l.getValidatorsByScope(Y.DataValidatorRegistryScope.SHEET),[O,f]=T.useState(()=>p.ranges.map(_=>({unitId:"",sheetId:"",range:_}))),v=T.useMemo(()=>pn(m),[m]),[C,F]=T.useState(!1),[B,$]=T.useState(!1),k=T.useRef(null),M=V.useDependency(H.SheetsSelectionsService);if(T.useEffect(()=>()=>{const _=M.getCurrentLastSelection();_&&M.setSelections([_])},[M]),T.useEffect(()=>{m.onCommandExecuted(_=>{(_.id===o.UndoCommand.id||_.id===o.RedoCommand.id)&&setTimeout(()=>{const x=u.getRuleById(r,i,c);t(X=>X+1),x&&(A(x),f(x.ranges.map(X=>({unitId:"",sheetId:"",range:X}))))},20)})},[m,u,c,i,r]),!E)return null;const j=E.operators,U=E.operatorNames,z=p.operator?Y.TWO_FORMULA_OPERATOR_COUNT.includes(p.operator):!1,Z=()=>{var _,x,X;(x=(_=k.current)==null?void 0:_.editor)!=null&&x.isFocus()&&Q((X=k.current)==null?void 0:X.getValue()),!(!p.ranges.length||C)&&(E.validatorFormula(p,r,i).success?n.setActiveRule(null):y(!0))},Q=V.useEvent(_=>{const x=_.split(",").filter(Boolean).map(nt.deserializeRangeWithSheet).map(te=>{const ut=te.sheetName;if(ut){const Ot=vn(d,te.unitId,ut);return{...te,sheetId:Ot}}return{...te,sheetId:""}});if(o.isUnitRangesEqual(x,O))return;f(x);const X=x.filter(te=>(!te.unitId||te.unitId===r)&&(!te.sheetId||te.sheetId===i)).map(te=>te.range);if(A({...p,ranges:X}),X.length===0)return;const ie={unitId:r,subUnitId:i,ruleId:c,ranges:X};v(I.UpdateSheetDataValidationRangeCommand.id,ie)}),K=_=>{if(o.shallowEqual(_,Y.getRuleSetting(p)))return;A({...p,..._});const x={unitId:r,subUnitId:i,ruleId:c,setting:_};v(I.UpdateSheetDataValidationSettingCommand.id,x,void 0)},ne=async()=>{await m.executeCommand(I.RemoveSheetDataValidationCommand.id,{ruleId:c,unitId:r,subUnitId:i}),n.setActiveRule(null)},ae={type:p.type,operator:p.operator,formula1:p.formula1,formula2:p.formula2,allowBlank:p.allowBlank},de=_=>{const x=l.getValidatorItem(_);if(!x)return;const X=x.operators,ie=u.getRuleById(r,i,c),te=_===(ie==null?void 0:ie.type)||_.includes("list")&&(ie!=null&&ie.type.includes("list"))?{...ie,type:_}:{...p,type:_,operator:X[0],formula1:void 0,formula2:void 0};A(te),m.executeCommand(I.UpdateSheetDataValidationSettingCommand.id,{unitId:r,subUnitId:i,ruleId:p.uid,setting:Y.getRuleSetting(te)})},ue=h.get(E.formulaInput),ee=T.useMemo(()=>O.map(_=>nt.serializeRange(_.range)).join(","),[]),G=Y.getRuleOptions(p),le=_=>{o.shallowEqual(_,Y.getRuleOptions(p))||(A({...p,..._}),v(I.UpdateSheetDataValidationOptionsCommand.id,{unitId:r,subUnitId:i,ruleId:c,options:_}))},J=j.length&&!p.operator;return g.jsxs("div",{"data-u-comp":"data-validation-detail",className:"univer-py-2",children:[g.jsx(w.FormLayout,{label:S.t("dataValidation.panel.range"),error:!p.ranges.length||C?S.t("dataValidation.panel.rangeError"):"",children:g.jsx(st.RangeSelector,{selectorRef:k,unitId:r,subUnitId:i,initialValue:ee,onChange:(_,x)=>{var X;!B&&((X=k.current)!=null&&X.verify())&&Q(x)},onFocusChange:(_,x)=>{var X;$(_),!_&&x&&((X=k.current)!=null&&X.verify())&&Q(x)},onVerify:_=>F(!_)})}),g.jsx(w.FormLayout,{label:S.t("dataValidation.panel.type"),children:g.jsx(w.Select,{className:"univer-w-full",value:p.type,options:(b=D==null?void 0:D.sort((_,x)=>_.order-x.order))==null?void 0:b.map(_=>({label:S.t(_.title),value:_.id})),onChange:de})}),j!=null&&j.length?g.jsx(w.FormLayout,{label:S.t("dataValidation.panel.operator"),children:g.jsx(w.Select,{className:"univer-w-full",value:`${p.operator}`,options:[{value:"",label:S.t("dataValidation.operators.legal")},...j.map((_,x)=>({value:`${_}`,label:U[x]}))],onChange:_=>{K({...ae,operator:_})}})}):null,ue&&!J?g.jsx(ue,{isTwoFormula:z,value:{formula1:p.formula1,formula2:p.formula2},onChange:_=>{K({...ae,..._})},showError:R,validResult:E.validatorFormula(p,r,i),unitId:r,subUnitId:i,ruleId:c},e+p.type):null,g.jsx(w.FormLayout,{children:g.jsx(w.Checkbox,{checked:(W=p.allowBlank)!=null?W:!0,onChange:()=>{var _;return K({...ae,allowBlank:!((_=p.allowBlank)==null||_)})},children:S.t("dataValidation.panel.allowBlank")})}),g.jsx(gn,{value:G,onChange:le,extraComponent:E.optionsInput}),g.jsxs("div",{className:"univer-mt-5 univer-flex univer-flex-row univer-justify-end",children:[g.jsx(w.Button,{className:"univer-ml-3",onClick:ne,children:S.t("dataValidation.panel.removeRule")}),g.jsx(w.Button,{className:"univer-ml-3",variant:"primary",onClick:Z,children:S.t("dataValidation.panel.done")})]})]})}const fn=e=>{const{rule:t,onClick:n,unitId:a,subUnitId:r,disable:i}=e,s=V.useDependency(Y.DataValidatorRegistryService),c=V.useDependency(o.ICommandService),l=V.useDependency(N.IMarkSelectionService),d=s.getValidatorItem(t.type),h=T.useRef(void 0),[m,u]=T.useState(!1),S=V.useDependency(o.ThemeService),p=V.useObservable(S.currentTheme$),A=T.useMemo(()=>{var f;const R=S.getColorFromTheme("primary.600"),y=S.getColorFromTheme("loop-color.2"),D=(f=S.getColorFromTheme(y))!=null?f:R,O=new o.ColorKit(D).toRgb();return{fill:`rgba(${O.r}, ${O.g}, ${O.b}, 0.1)`,stroke:D}},[p]),E=R=>{c.executeCommand(I.RemoveSheetDataValidationCommand.id,{ruleId:t.uid,unitId:a,subUnitId:r}),R.stopPropagation()};return T.useEffect(()=>()=>{var R;h.current&&((R=h.current)==null||R.forEach(y=>{y&&l.removeShape(y)}))},[l]),g.jsxs("div",{className:w.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:n,onMouseEnter:()=>{i||(u(!0),h.current=t.ranges.map(R=>l.addShape({range:R,style:O,primary:null})))},onMouseLeave:()=>{var R;u(!1),(R=h.current)==null||R.forEach(y=>{y&&l.removeShape(y)}),h.current=void 0},children:[g.jsx("div",{className:"univer-truncate univer-text-sm univer-font-medium univer-leading-[22px] univer-text-gray-900 dark:!univer-text-white",children:d==null?void 0:d.generateRuleName(t)}),g.jsx("div",{className:"univer-text-secondary univer-truncate univer-text-xs univer-leading-[18px] dark:!univer-text-gray-300",children:t.ranges.map(R=>tt.serializeRange(R)).join(",")}),v?g.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:g.jsx(ct,{})}):null]})};function Sn(e){const t=E.useDependency(C.SheetDataValidationModel),n=E.useDependency(o.IUniverInstanceService),a=E.useDependency(o.ICommandService),r=E.useDependency(o.Injector),i=E.useDependency(ce),s=E.useDependency(o.LocaleService),[c,l]=T.useState([]),{workbook:d}=e,h=E.useObservable(d.activeSheet$,void 0,!0),v=d.getUnitId(),u=h==null?void 0:h.getSheetId();T.useEffect(()=>{l(t.getRules(v,u));const y=t.ruleChange$.subscribe(m=>{m.unitId===v&&m.subUnitId===u&&l(t.getRules(v,u))});return()=>{y.unsubscribe()}},[v,u,t]);const S=async()=>{const y=C.createDefaultNewRule(r),m={unitId:v,subUnitId:u,rule:y};await a.executeCommand(C.AddSheetDataValidationCommand.id,m),i.setActiveRule({unitId:v,subUnitId:u,rule:y})},p=()=>{a.executeCommand(C.RemoveSheetAllDataValidationCommand.id,{unitId:v,subUnitId:u})},M=(y=>{const m=n.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET),D=m.getActiveSheet(),I=m.getUnitId(),f=D.getSheetId();return y.map(F=>H.checkRangesEditablePermission(r,I,f,F.ranges)?{...F}:{...F,disable:!0})})(c),R=M==null?void 0:M.some(y=>y.disable);return g.jsxs("div",{className:"univer-pb-4",children:[M==null?void 0:M.map(y=>{var m;return g.jsx(fn,{unitId:v,subUnitId:u,onClick:()=>{y.disable||i.setActiveRule({unitId:v,subUnitId:u,rule:y})},rule:y,disable:(m=y.disable)!=null?m:!1},y.uid)}),g.jsxs("div",{className:"univer-mt-4 univer-flex univer-flex-row univer-justify-end univer-gap-2",children:[c.length&&!R?g.jsx(V.Button,{onClick:p,children:s.t("dataValidation.panel.removeAll")}):null,g.jsx(V.Button,{variant:"primary",onClick:S,children:s.t("dataValidation.panel.add")})]})]})}const _n=()=>{const e=E.useDependency(ce),t=E.useObservable(e.activeRule$,e.activeRule),n=E.useDependency(o.IUniverInstanceService),a=E.useObservable(()=>n.getCurrentTypeOfUnit$(o.UniverInstanceType.UNIVER_SHEET),void 0,void 0,[]),r=E.useObservable(()=>{var i;return(i=a==null?void 0:a.activeSheet$)!=null?i:re.of(null)},void 0,void 0,[]);return!a||!r?null:t&&t.subUnitId===r.getSheetId()?g.jsx(mn,{},t.rule.uid):g.jsx(Sn,{workbook:a})},In=e=>{const{isTwoFormula:t=!1,value:n,onChange:a,showError:r,validResult:i}=e,s=E.useDependency(o.LocaleService),c=r?i==null?void 0:i.formula1:"",l=r?i==null?void 0:i.formula2:"";return t?g.jsxs(g.Fragment,{children:[g.jsx(V.FormLayout,{error:c,children:g.jsx(V.Input,{className:"univer-w-full",placeholder:s.t("dataValidation.panel.formulaPlaceholder"),value:n==null?void 0:n.formula1,onChange:d=>{a==null||a({...n,formula1:d})}})}),g.jsx("div",{className:"-univer-mt-2 univer-mb-1 univer-text-sm univer-text-gray-400",children:s.t("dataValidation.panel.formulaAnd")}),g.jsx(V.FormLayout,{error:l,children:g.jsx(V.Input,{className:"univer-w-full",placeholder:s.t("dataValidation.panel.formulaPlaceholder"),value:n==null?void 0:n.formula2,onChange:d=>{a==null||a({...n,formula2:d})}})})]}):g.jsx(V.FormLayout,{error:c,children:g.jsx(V.Input,{className:"univer-w-full",placeholder:s.t("dataValidation.panel.formulaPlaceholder"),value:n==null?void 0:n.formula1,onChange:d=>{a==null||a({formula1:d})}})})};function Cn(e){const{value:t,onChange:n,showError:a,validResult:r}=e,i=E.useDependency(o.LocaleService),s=a?r==null?void 0:r.formula1:"",c=a?r==null?void 0:r.formula2:"",[l,d]=T.useState(!((t==null?void 0:t.formula1)===void 0&&(t==null?void 0:t.formula2)===void 0));return g.jsxs(g.Fragment,{children:[g.jsx(V.FormLayout,{children:g.jsx(V.Checkbox,{checked:l,onChange:h=>{h?d(!0):(d(!1),n==null||n({...t,formula1:void 0,formula2:void 0}))},children:i.t("dataValidation.checkbox.tips")})}),l?g.jsx(V.FormLayout,{label:i.t("dataValidation.checkbox.checked"),error:s,children:g.jsx(V.Input,{className:"univer-w-full",placeholder:i.t("dataValidation.panel.valuePlaceholder"),value:t==null?void 0:t.formula1,onChange:h=>{n==null||n({...t,formula1:h||void 0})}})}):null,l?g.jsx(V.FormLayout,{label:i.t("dataValidation.checkbox.unchecked"),error:c,children:g.jsx(V.Input,{className:"univer-w-full",placeholder:i.t("dataValidation.panel.valuePlaceholder"),value:t==null?void 0:t.formula2,onChange:h=>{n==null||n({...t,formula2:h||void 0})}})}):null]})}function yn(e){var v;const{unitId:t,subUnitId:n,value:a,onChange:r,showError:i,validResult:s}=e,c=i?s==null?void 0:s.formula1:void 0,l=T.useRef(null),[d,h]=T.useState(!1);return E.useSidebarClick(u=>{var p;(p=l.current)!=null&&p.isClickOutSide(u)&&h(!1)}),g.jsx(V.FormLayout,{error:c,children:g.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:(v=a==null?void 0:a.formula1)!=null?v:"=",unitId:t,subUnitId:n,isFocus:d,isSupportAcrossSheet:!0,onChange:u=>{const S=(u!=null?u:"").trim();S!==(a==null?void 0:a.formula1)&&(r==null||r({...a,formula1:S}))},onFocus:()=>h(!0)})})}const Rn=["#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:n,disabled:a}=e,[r,i]=T.useState(!1);return g.jsx(V.Dropdown,{align:"start",disabled:a,open:r,onOpenChange:i,overlay:g.jsx("div",{className:"univer-box-border univer-grid univer-w-fit univer-grid-cols-6 univer-flex-wrap univer-gap-2 univer-p-1.5",children:Rn.map(s=>g.jsx("div",{className:V.clsx("univer-box-border univer-size-4 univer-cursor-pointer univer-rounded",V.borderClassName),style:{background:s},onClick:()=>{n(s),i(!1)}},s))}),children:g.jsxs("div",{className:V.clsx("univer-box-border univer-inline-flex univer-h-8 univer-w-16 univer-cursor-pointer univer-items-center univer-justify-between univer-gap-2 univer-rounded-lg univer-bg-white univer-px-2.5 univer-transition-colors univer-duration-200 hover:univer-border-primary-600 dark:!univer-bg-gray-700 dark:!univer-text-white",V.borderClassName),children:[g.jsx("div",{className:"univer-box-border univer-h-4 univer-w-4 univer-rounded univer-text-base",style:{background:t}}),g.jsx(dt,{})]})})},vt=e=>{const{item:t,commonProps:n,className:a}=e,{onItemChange:r,onItemDelete:i}=n;return g.jsxs("div",{className:V.clsx("univer-flex univer-items-center univer-gap-2",a),children:[!t.isRef&&g.jsx("div",{className:V.clsx("univer-cursor-move","draggableHandle"),children:g.jsx(Et,{})}),g.jsx(Dn,{value:t.color,onChange:s=>{r(t.id,t.label,s)}}),g.jsx(V.Input,{disabled:t.isRef,value:t.label,onChange:s=>{r(t.id,s,t.color)}}),t.isRef?null:g.jsx("div",{className:"univer-ml-1 univer-cursor-pointer univer-rounded univer-text-base hover:univer-bg-gray-200",children:g.jsx(ct,{onClick:()=>i(t.id)})})]})};function wn(e){const{value:t,onChange:n=()=>{},unitId:a,subUnitId:r,validResult:i,showError:s,ruleId:c}=e,{formula1:l="",formula2:d=""}=t||{},[h,v]=T.useState(()=>o.isFormulaString(l)?"1":"0"),[u,S]=T.useState(h==="1"?l:"="),[p,O]=T.useState(h==="1"?l:"="),M=E.useDependency(o.LocaleService),R=E.useDependency(Y.DataValidatorRegistryService),y=E.useDependency(Y.DataValidationModel),m=E.useDependency(C.DataValidationFormulaController),[D,I]=T.useState(()=>d.split(",")),f=R.getValidatorItem(o.DataValidationType.LIST),[w,F]=T.useState([]),[B,j]=T.useState(""),W=s?i==null?void 0:i.formula1:"",A=T.useMemo(()=>y.ruleChange$.pipe(re.debounceTime(16)),[]),x=E.useObservable(A),k=E.useEvent(n);T.useEffect(()=>{(async()=>{await new Promise(_=>{setTimeout(()=>_(!0),100)});const b=y.getRuleById(a,r,c),$=b==null?void 0:b.formula1;if(o.isFormulaString($)&&f&&b){const _=await f.getListAsync(b,a,r);F(_)}})()},[y,x,f,c,r,a]),T.useEffect(()=>{o.isFormulaString(l)&&l!==p&&(S(l),O(p))},[p,l]);const[z,q]=T.useState(()=>{const b=h!=="1"?C.deserializeListOptions(l):[],$=d.split(",");return b.map((_,U)=>({label:_,color:$[U]||ve,isRef:!1,id:o.generateRandomId(4)}))}),te=(b,$,_)=>{const U=z.find(X=>X.id===b);U&&(U.label=$,U.color=_,q([...z]))},K=b=>{const $=z.findIndex(_=>_.id===b);$!==-1&&(z.splice($,1),q([...z]))},ne=d.split(","),ae=T.useMemo(()=>w.map((b,$)=>({label:b,color:ne[$]||ve,id:`${$}`,isRef:!0})),[ne,w]),de=(b,$,_)=>{const U=[...D];U[+b]=_,I(U),k({formula1:l,formula2:U.join(",")})},ue=()=>{q([...z,{label:"",color:ve,isRef:!1,id:o.generateRandomId(4)}])};T.useEffect(()=>{if(h==="1")return;const b=new Set,$=[];z.map(_=>({labelList:_.label.split(","),item:_})).forEach(({item:_,labelList:U})=>{U.forEach(X=>{b.has(X)||(b.add(X),$.push({label:X,color:_.color}))})}),k({formula1:C.serializeListOptions($.map(_=>_.label)),formula2:$.map(_=>_.color===ve?"":_.color).join(",")})},[z,k,h,p,D]);const Q=E.useEvent(async b=>{if(!o.isFormulaString(b)){k==null||k({formula1:"",formula2:d});return}m.getFormulaRefCheck(b)?(k==null||k({formula1:o.isFormulaString(b)?b:"",formula2:d}),j("")):(k==null||k({formula1:"",formula2:d}),S("="),j(M.t("dataValidation.validFail.formulaError")))}),Z=T.useRef(null),[le,J]=T.useState(!1);return E.useSidebarClick(b=>{var _;(_=Z.current)!=null&&_.isClickOutSide(b)&&J(!1)}),g.jsxs(g.Fragment,{children:[g.jsx(V.FormLayout,{label:M.t("dataValidation.list.options"),children:g.jsxs(V.RadioGroup,{value:h,onChange:b=>{v(b),S(p),b==="1"&&k({formula1:p==="="?"":p,formula2:D.join(",")})},children:[g.jsx(V.Radio,{value:"0",children:M.t("dataValidation.list.customOptions")}),g.jsx(V.Radio,{value:"1",children:M.t("dataValidation.list.refOptions")})]})}),h==="1"?g.jsxs(V.FormLayout,{error:W||B||void 0,children:[g.jsx(ot.FormulaEditor,{ref:Z,className:V.clsx("univer-box-border univer-h-8 univer-w-full univer-cursor-pointer univer-items-center univer-rounded-lg univer-bg-white univer-pt-2 univer-transition-colors hover:univer-border-primary-600 dark:!univer-bg-gray-700 dark:!univer-text-white [&>div:first-child]:univer-px-2.5 [&>div]:univer-h-5 [&>div]:univer-ring-transparent",V.borderClassName),initValue:u,unitId:a,subUnitId:r,isFocus:le,isSupportAcrossSheet:!0,onFocus:()=>J(!0),onChange:(b="")=>{const $=(b!=null?b:"").trim();O($),Q($)}}),ae.length>0&&g.jsx("div",{className:"univer-mt-3",children:ae.map(b=>g.jsx(vt,{className:"univer-mb-3",item:b,commonProps:{onItemChange:de}},b.id))})]}):g.jsx(V.FormLayout,{error:W,children:g.jsxs("div",{className:"-univer-mt-3",children:[g.jsx(V.DraggableList,{list:z,onListChange:q,rowHeight:28,margin:[0,12],draggableHandle:".draggableHandle",itemRender:b=>g.jsx(vt,{item:b,commonProps:{onItemChange:te,onItemDelete:K}},b.id),idKey:"id"}),g.jsxs("a",{className:"univer-text-primary univer-flex univer-w-fit univer-cursor-pointer univer-flex-row univer-items-center univer-rounded univer-p-1 univer-px-2 univer-text-sm hover:univer-bg-primary-50 dark:hover:!univer-bg-gray-800",onClick:ue,children:[g.jsx(wt,{className:"univer-mr-1"}),M.t("dataValidation.list.add")]})]})})]})}const Vn=[[C.CUSTOM_FORMULA_INPUT_NAME,yn],[C.BASE_FORMULA_INPUT_NAME,In],[C.LIST_FORMULA_INPUT_NAME,wn],[C.CHECKBOX_FORMULA_INPUT_NAME,Cn]],En="LIST_RENDER_MODE_OPTION_INPUT";function ke(e){var r;const{value:t,onChange:n}=e,a=E.useDependency(o.LocaleService);return g.jsx(V.FormLayout,{label:a.t("dataValidation.renderMode.label"),children:g.jsxs(V.RadioGroup,{value:`${(r=t.renderMode)!=null?r:o.DataValidationRenderMode.CUSTOM}`,onChange:i=>n({...t,renderMode:+i}),children:[g.jsx(V.Radio,{value:`${o.DataValidationRenderMode.CUSTOM}`,children:a.t("dataValidation.renderMode.chip")}),g.jsx(V.Radio,{value:`${o.DataValidationRenderMode.ARROW}`,children:a.t("dataValidation.renderMode.arrow")}),g.jsx(V.Radio,{value:`${o.DataValidationRenderMode.TEXT}`,children:a.t("dataValidation.renderMode.text")})]})})}ke.componentKey=En;const Mn="DATE_SHOW_TIME_OPTION";function Ne(e){var r;const{value:t,onChange:n}=e,a=E.useDependency(o.LocaleService);return g.jsx(V.FormLayout,{children:g.jsx(V.Checkbox,{checked:(r=t.bizInfo)==null?void 0:r.showTime,onChange:i=>{n({...t,bizInfo:{...t.bizInfo,showTime:i}})},children:a.t("dataValidation.showTime.label")})})}Ne.componentKey=Mn;var bn=Object.getOwnPropertyDescriptor,Tn=(e,t,n,a)=>{for(var r=a>1?void 0:a?bn(t,n):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},Ce=(e,t)=>(n,a)=>t(n,a,e);const Ae=6;let nt=class{constructor(e,t,n,a,r,i){this._commandService=e,this._univerInstanceService=t,this._formulaService=n,this._themeService=a,this._renderManagerService=r,this._dataValidationModel=i}_calc(e,t){var d,h,v;const{vt:n,ht:a}=t||{},r=e.endX-e.startX-Ae*2,i=e.endY-e.startY,s=((d=t==null?void 0:t.fs)!=null?d:10)*1.6;let c=0,l=0;switch(n){case o.VerticalAlign.TOP:l=0;break;case o.VerticalAlign.BOTTOM:l=0+(i-s);break;default:l=0+(i-s)/2;break}switch(a){case o.HorizontalAlign.LEFT:c=Ae;break;case o.HorizontalAlign.RIGHT:c=Ae+(r-s);break;default:c=Ae+(r-s)/2;break}return{left:e.startX+c,top:e.startY+l,width:((h=t==null?void 0:t.fs)!=null?h:10)*1.6,height:((v=t==null?void 0:t.fs)!=null?v:10)*1.6}}calcCellAutoHeight(e){var n;const{style:t}=e;return((n=t==null?void 0:t.fs)!=null?n:10)*1.6}calcCellAutoWidth(e){var n;const{style:t}=e;return((n=t==null?void 0:t.fs)!=null?n:10)*1.6}async _parseFormula(e,t,n){var d,h,v,u,S,p,O,M,R;const{formula1:a=C.CHECKBOX_FORMULA_1,formula2:r=C.CHECKBOX_FORMULA_2}=e,i=await this._formulaService.getRuleFormulaResult(t,n,e.uid),s=C.getFormulaResult((v=(h=(d=i==null?void 0:i[0])==null?void 0:d.result)==null?void 0:h[0])==null?void 0:v[0]),c=C.getFormulaResult((p=(S=(u=i==null?void 0:i[1])==null?void 0:u.result)==null?void 0:S[0])==null?void 0:p[0]),l=C.isLegalFormulaResult(String(s))&&C.isLegalFormulaResult(String(c));return{formula1:o.isFormulaString(a)?C.getFormulaResult((R=(M=(O=i==null?void 0:i[0])==null?void 0:O.result)==null?void 0:M[0])==null?void 0:R[0]):a,formula2:o.isFormulaString(r)?c:r,isFormulaValid:l}}drawWith(e,t){var W,A,x,k;const{style:n,primaryWithCoord:a,unitId:r,subUnitId:i,worksheet:s,row:c,col:l}=t,d=a.isMergedMainCell?a.mergeInfo:a,h=C.getCellValueOrigin(s.getCellRaw(c,l)),v=this._dataValidationModel.getRuleByLocation(r,i,c,l);if(!v)return;const u=this._dataValidationModel.getValidator(v.type);if(!u||!((W=u.skipDefaultFontRender)!=null&&W.call(u,v,h,{unitId:r,subUnitId:i,row:c,column:l})))return;const S=u.parseFormulaSync(v,r,i),{formula1:p}=S,O=this._calc(d,n),{a:M,d:R}=e.getTransform(),y=P.fixLineWidthByScale(O.left,M),m=P.fixLineWidthByScale(O.top,R),D=P.Transform.create().composeMatrix({left:y,top:m,scaleX:1,scaleY:1,angle:0,skewX:0,skewY:0,flipX:!1,flipY:!1}),I=d.endX-d.startX,f=d.endY-d.startY;e.save(),e.beginPath(),e.rect(d.startX,d.startY,I,f),e.clip();const w=D.getMatrix();e.transform(w[0],w[1],w[2],w[3],w[4],w[5]);const F=((A=n==null?void 0:n.fs)!=null?A:10)*1.6,B=String(h)===String(p),j=this._themeService.getColorFromTheme("primary.600");P.CheckboxShape.drawWith(e,{checked:B,width:F,height:F,fill:(k=(x=n==null?void 0:n.cl)==null?void 0:x.rgb)!=null?k:j}),e.restore()}isHit(e,t){const n=t.primaryWithCoord.isMergedMainCell?t.primaryWithCoord.mergeInfo:t.primaryWithCoord,a=this._calc(n,t.style),r=a.top,i=a.top+a.height,s=a.left,c=a.left+a.width,{x:l,y:d}=e;return l<=c&&l>=s&&d<=i&&d>=r}async onPointerDown(e,t){var p;if(t.button===2)return;const{primaryWithCoord:n,unitId:a,subUnitId:r,worksheet:i,row:s,col:c}=e,l=C.getCellValueOrigin(i.getCellRaw(s,c)),d=this._dataValidationModel.getRuleByLocation(a,r,s,c);if(!d)return;const h=this._dataValidationModel.getValidator(d.type);if(!h||!((p=h.skipDefaultFontRender)!=null&&p.call(h,d,l,{unitId:a,subUnitId:r,row:s,column:c})))return;const{formula1:v,formula2:u}=await this._parseFormula(d,a,r),S={range:{startColumn:n.actualColumn,endColumn:n.actualColumn,startRow:n.actualRow,endRow:n.actualRow},value:{v:String(l)===C.transformCheckboxValue(String(v))?u:v,p:null}};this._commandService.executeCommand(H.SetRangeValuesCommand.id,S)}onPointerEnter(e,t){var n,a;(a=(n=P.getCurrentTypeOfRenderer(o.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null?void 0:n.mainComponent)==null||a.setCursor(P.CURSOR_TYPE.POINTER)}onPointerLeave(e,t){var n,a;(a=(n=P.getCurrentTypeOfRenderer(o.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null?void 0:n.mainComponent)==null||a.setCursor(P.CURSOR_TYPE.DEFAULT)}};nt=Tn([Ce(0,o.ICommandService),Ce(1,o.IUniverInstanceService),Ce(2,o.Inject(C.DataValidationFormulaService)),Ce(3,o.Inject(o.ThemeService)),Ce(4,o.Inject(P.IRenderManagerService)),Ce(5,o.Inject(C.SheetDataValidationModel))],nt);var On=Object.getOwnPropertyDescriptor,An=(e,t,n,a)=>{for(var r=a>1?void 0:a?On(t,n):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},Ln=(e,t)=>(n,a)=>t(n,a,e);exports.BaseSheetDataValidatorView=class{constructor(t){L(this,"canvasRender",null);L(this,"dropdownType");L(this,"optionsInput");L(this,"formulaInput",C.LIST_FORMULA_INPUT_NAME);this.injector=t}};exports.BaseSheetDataValidatorView=An([Ln(0,o.Inject(o.Injector))],exports.BaseSheetDataValidatorView);class Pn extends exports.BaseSheetDataValidatorView{constructor(){super(...arguments);L(this,"id",o.DataValidationType.CHECKBOX);L(this,"canvasRender",this.injector.createInstance(nt));L(this,"formulaInput",C.CHECKBOX_FORMULA_INPUT_NAME)}}class jn extends exports.BaseSheetDataValidatorView{constructor(){super(...arguments);L(this,"id",o.DataValidationType.CUSTOM);L(this,"formulaInput",C.CUSTOM_FORMULA_INPUT_NAME)}}const xn="data-validation.formula-input";class Un extends exports.BaseSheetDataValidatorView{constructor(){super(...arguments);L(this,"id",o.DataValidationType.DATE);L(this,"formulaInput",xn);L(this,"optionsInput",Ne.componentKey);L(this,"dropdownType",Y.DataValidatorDropdownType.DATE)}}class Fn extends exports.BaseSheetDataValidatorView{constructor(){super(...arguments);L(this,"id",o.DataValidationType.DECIMAL);L(this,"formulaInput",C.BASE_FORMULA_INPUT_NAME)}}const Mt=4,kn=0,Ke=4,bt=4,at=6,Be=6,pe=14;function Nn(e,t){const n=P.FontCache.getTextSize(e,t),a=n.width+Mt*2,{ba:r,bd:i}=n,s=r+i;return{width:a,height:s+kn*2,ba:r}}function Ze(e,t,n,a){const r=pe+at*2,i=n-r,s=a-Be*2,c=e.map(u=>({layout:Nn(u,t),text:u}));let l;const d=[];c.forEach(u=>{const{layout:S}=u,{width:p,height:O}=S;!l||l.width+p+Ke>i?(l={width:p,height:O,items:[{...u,left:0}]},d.push(l)):(l.items.push({...u,left:l.width+Ke}),l.width=l.width+p+Ke)});let h=0,v=0;return d.forEach((u,S)=>{v=Math.max(v,u.width),S===d.length-1?h+=u.height:h+=u.height+bt}),{lines:d,totalHeight:h,contentWidth:i,contentHeight:s,cellAutoHeight:h+Be*2,calcAutoWidth:v+r}}const Bn=8;class Wn extends P.Shape{static drawWith(t,n){const{fontString:a,info:r,fill:i,color:s}=n,{layout:c,text:l}=r;t.save(),P.Rect.drawWith(t,{width:c.width,height:c.height,radius:Bn,fill:i||ve}),t.translateWithPrecision(Mt,c.ba),t.font=a,t.fillStyle=s,t.fillText(l,0,0),t.restore()}}var $n=Object.getOwnPropertyDescriptor,Hn=(e,t,n,a)=>{for(var r=a>1?void 0:a?$n(t,n):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},Le=(e,t)=>(n,a)=>t(n,a,e);const 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 rt=class{constructor(e,t,n,a){L(this,"zIndex");L(this,"_dropdownInfoMap",new Map);this._commandService=e,this._univerInstanceService=t,this._renderManagerService=n,this._dataValidationModel=a}_ensureMap(e){let t=this._dropdownInfoMap.get(e);return t||(t=new Map,this._dropdownInfoMap.set(e,t)),t}_generateKey(e,t){return`${e}.${t}`}_drawDownIcon(e,t,n,a,r){const i=n-pe+4;let s=4;switch(r){case o.VerticalAlign.MIDDLE:s=(a-pe)/2+4;break;case o.VerticalAlign.BOTTOM:s=a-pe+4;break}e.save(),e.translateWithPrecision(t.startX+i,t.startY+s),e.fillStyle="#565656",e.fill(Yn),e.restore()}drawWith(e,t,n,a){var ae,de;const{primaryWithCoord:r,row:i,col:s,style:c,data:l,subUnitId:d}=t,h=r.isMergedMainCell?r.mergeInfo:r,v=l==null?void 0:l.fontRenderExtension,{leftOffset:u=0,rightOffset:S=0,topOffset:p=0,downOffset:O=0}=v||{},M=this._ensureMap(d),R=this._generateKey(i,s),y=r.isMergedMainCell?r.mergeInfo.startRow:i,m=r.isMergedMainCell?r.mergeInfo.startColumn:s,D=this._dataValidationModel.getRuleByLocation(t.unitId,t.subUnitId,y,m);if(!D)return;const I=this._dataValidationModel.getValidator(D.type);if(!I)return;const f={startX:h.startX+u,endX:h.endX-S,startY:h.startY+p,endY:h.endY-O},w=f.endX-f.startX,F=f.endY-f.startY,{cl:B}=c||{},j=(ae=typeof B=="object"?B==null?void 0:B.rgb:B)!=null?ae:"#000",W=P.getFontStyleString(c!=null?c:void 0),{vt:A,ht:x}=c||{},k=A!=null?A:o.VerticalAlign.MIDDLE,z=(de=C.getCellValueOrigin(l))!=null?de:"",q=I.parseCellValue(z),te=I.getListWithColorMap(D),K=Ze(q,W,w,F);this._drawDownIcon(e,f,w,F,k),e.save(),e.translateWithPrecision(f.startX,f.startY),e.beginPath(),e.rect(0,0,w-pe,F),e.clip(),e.translateWithPrecision(at,Be);let ne=0;switch(k){case o.VerticalAlign.MIDDLE:ne=(K.contentHeight-K.totalHeight)/2;break;case o.VerticalAlign.BOTTOM:ne=K.contentHeight-K.totalHeight;break}e.translateWithPrecision(0,ne),K.lines.forEach((ue,Q)=>{e.save();const{width:Z,height:le,items:J}=ue;let b=0;switch(x){case o.HorizontalAlign.RIGHT:b=K.contentWidth-Z;break;case o.HorizontalAlign.CENTER:b=(K.contentWidth-Z)/2;break}e.translate(b,Q*(le+bt)),J.forEach($=>{e.save(),e.translateWithPrecision($.left,0),Wn.drawWith(e,{...W,info:$,color:j,fill:te[$.text]}),e.restore()}),e.restore()}),e.restore(),M.set(R,{left:f.startX,top:f.startY,width:K.contentWidth+at+pe,height:K.contentHeight+Be*2})}calcCellAutoHeight(e){var I;const{primaryWithCoord:t,style:n,data:a,row:r,col:i}=e,s=a==null?void 0:a.fontRenderExtension,{leftOffset:c=0,rightOffset:l=0,topOffset:d=0,downOffset:h=0}=s||{},v=t.isMergedMainCell?t.mergeInfo:t,u={startX:v.startX+c,endX:v.endX-l,startY:v.startY+d,endY:v.endY-h},S=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,r,i);if(!S)return;const p=this._dataValidationModel.getValidator(S.type);if(!p)return;const O=u.endX-u.startX,M=u.endY-u.startY,R=(I=C.getCellValueOrigin(a))!=null?I:"",y=p.parseCellValue(R),m=P.getFontStyleString(n!=null?n:void 0);return Ze(y,m,O,M).cellAutoHeight}calcCellAutoWidth(e){var I;const{primaryWithCoord:t,style:n,data:a,row:r,col:i}=e,s=a==null?void 0:a.fontRenderExtension,{leftOffset:c=0,rightOffset:l=0,topOffset:d=0,downOffset:h=0}=s||{},v=t.isMergedMainCell?t.mergeInfo:t,u={startX:v.startX+c,endX:v.endX-l,startY:v.startY+d,endY:v.endY-h},S=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,r,i);if(!S)return;const p=this._dataValidationModel.getValidator(S.type);if(!p)return;const O=u.endX-u.startX,M=u.endY-u.startY,R=(I=C.getCellValueOrigin(a))!=null?I:"",y=p.parseCellValue(R),m=P.getFontStyleString(n!=null?n:void 0);return Ze(y,m,O,M).calcAutoWidth}isHit(e,t){const{primaryWithCoord:n}=t,a=n.isMergedMainCell?n.mergeInfo:n,{endX:r}=a,{x:i}=e;return i>=r-pe&&i<=r}onPointerDown(e,t){if(t.button===2)return;const{unitId:n,subUnitId:a,row:r,col:i}=e,s={unitId:n,subUnitId:a,row:r,column:i};this._commandService.executeCommand(We.id,s)}onPointerEnter(e,t){var n,a;return(a=(n=P.getCurrentTypeOfRenderer(o.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null?void 0:n.mainComponent)==null?void 0:a.setCursor(P.CURSOR_TYPE.POINTER)}onPointerLeave(e,t){var n,a;return(a=(n=P.getCurrentTypeOfRenderer(o.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null?void 0:n.mainComponent)==null?void 0:a.setCursor(P.CURSOR_TYPE.DEFAULT)}};rt=Hn([Le(0,o.ICommandService),Le(1,o.IUniverInstanceService),Le(2,o.Inject(P.IRenderManagerService)),Le(3,o.Inject(C.SheetDataValidationModel))],rt);class Xn extends exports.BaseSheetDataValidatorView{constructor(){super(...arguments);L(this,"id",o.DataValidationType.LIST_MULTIPLE);L(this,"canvasRender",this.injector.createInstance(rt));L(this,"dropdownType",Y.DataValidatorDropdownType.MULTIPLE_LIST)}}var zn=Object.getOwnPropertyDescriptor,Kn=(e,t,n,a)=>{for(var r=a>1?void 0:a?zn(t,n):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},Te=(e,t)=>(n,a)=>t(n,a,e);const ye=4,Pe=4,se=14,Ge=1,he=6,Re=3,qe=8,Zn="#565656",mt=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 ft(e,t,n,a,r,i,s=!0){let c=0;const l=s?Re:0;switch(r){case o.VerticalAlign.BOTTOM:c=t-a-l;break;case o.VerticalAlign.MIDDLE:c=(t-a)/2;break;default:c=l;break}c=Math.max(Re,c);let d=0;switch(i){case o.HorizontalAlign.CENTER:d=(e-n)/2;break;case o.HorizontalAlign.RIGHT:d=e-n;break}return d=Math.max(he,d),{paddingLeft:d,paddingTop:c}}let it=class{constructor(e,t,n,a,r){L(this,"_dropdownInfoMap",new Map);L(this,"zIndex");this._univerInstanceService=e,this._localeService=t,this._commandService=n,this._renderManagerService=a,this._dataValidationModel=r}_ensureMap(e){let t=this._dropdownInfoMap.get(e);return t||(t=new Map,this._dropdownInfoMap.set(e,t)),t}_generateKey(e,t){return`${e}.${t}`}_drawDownIcon(e,t,n,a,r,i,s){const{t:c=o.DEFAULT_STYLES.pd.t,b:l=o.DEFAULT_STYLES.pd.b}=s,d=n-se;let h;switch(i){case o.VerticalAlign.MIDDLE:h=(a-Pe)/2;break;case o.VerticalAlign.BOTTOM:h=a-l-r-Re+(r/2-Pe/2);break;default:h=c+Re+(r/2-Pe/2);break}e.save(),e.translateWithPrecision(t.startX+d,t.startY+h),e.fillStyle="#565656",e.fill(mt),e.restore()}drawWith(e,t,n){var te,K,ne,ae,de,ue;const{primaryWithCoord:a,row:r,col:i,style:s,data:c,subUnitId:l}=t,d=a.isMergedMainCell?a.mergeInfo:a,h=a.isMergedMainCell?a.mergeInfo.startRow:r,v=a.isMergedMainCell?a.mergeInfo.startColumn:i,u=this._dataValidationModel.getRuleByLocation(t.unitId,t.subUnitId,h,v);if(!u)return;const S=this._dataValidationModel.getValidator(u.type);if(!S)return;const p=c==null?void 0:c.fontRenderExtension,{leftOffset:O=0,rightOffset:M=0,topOffset:R=0,downOffset:y=0}=p||{};if(!u||!S||!S||S.id.indexOf(o.DataValidationType.LIST)!==0||!S.skipDefaultFontRender(u))return;const m={startX:d.startX+O,endX:d.endX-M,startY:d.startY+R,endY:d.endY-y},D=m.endX-m.startX,I=m.endY-m.startY,f=this._ensureMap(l),w=this._generateKey(r,i),F=S.getListWithColorMap(u),B=C.getCellValueOrigin(c),j=`${B!=null?B:""}`,W=F[j];let{tb:A,vt:x,ht:k,pd:z}=s||{};A=A!=null?A:o.WrapStrategy.WRAP,x=x!=null?x:o.VerticalAlign.BOTTOM,k=k!=null?k:o.DEFAULT_STYLES.ht,z=z!=null?z:o.DEFAULT_STYLES.pd;const q=P.getFontStyleString(s).fontCache;if(u.renderMode===o.DataValidationRenderMode.ARROW){const{l:Q=o.DEFAULT_STYLES.pd.l,t:Z=o.DEFAULT_STYLES.pd.t,r:le=o.DEFAULT_STYLES.pd.r,b:J=o.DEFAULT_STYLES.pd.b}=z,b=D-Q-le-se-4,$=new P.DocSimpleSkeleton(j,q,A===o.WrapStrategy.WRAP,b,1/0);$.calculate();const _=$.getTotalWidth(),U=$.getTotalHeight(),{paddingTop:X,paddingLeft:ie}=ft(b,I-Z-J,_,U,x,k,!0);this._drawDownIcon(e,m,D,I,U,x,z),e.save(),e.translateWithPrecision(m.startX+Q,m.startY+Z),e.beginPath(),e.rect(0,0,D-Q-le,I-Z-J),e.clip(),e.translateWithPrecision(0,X),e.save(),e.translateWithPrecision(ie,0),e.beginPath(),e.rect(0,0,b,U),e.clip(),P.Text.drawWith(e,{text:j,fontStyle:q,width:b,height:U,color:(te=s==null?void 0:s.cl)==null?void 0:te.rgb,strokeLine:!!((K=s==null?void 0:s.st)!=null&&K.s),underline:!!((ne=s==null?void 0:s.ul)!=null&&ne.s),warp:A===o.WrapStrategy.WRAP,hAlign:o.HorizontalAlign.LEFT},$),e.restore(),e.restore(),f.set(w,{left:m.endX-se+n.rowHeaderWidth,top:m.startY+Z+n.columnHeaderHeight,width:se,height:I-Z-J})}else{e.save(),e.translateWithPrecision(m.startX,m.startY),e.beginPath(),e.rect(0,0,D,I),e.clip();const Q=D-he*2-ye-se-4,Z=new P.DocSimpleSkeleton(j,q,A===o.WrapStrategy.WRAP,Q,1/0);Z.calculate();const le=Z.getTotalWidth(),J=Z.getTotalHeight(),b=J+Ge*2,$=Math.max(D-he*2,1),{paddingTop:_}=ft($,I,le,b,x,k);e.translateWithPrecision(he,_),P.Rect.drawWith(e,{width:$,height:b,fill:W||ve,radius:qe}),e.save(),e.translateWithPrecision(ye,Ge),e.beginPath(),e.rect(0,0,Q,J),e.clip(),P.Text.drawWith(e,{text:j,fontStyle:q,width:Q,height:J,color:(ae=s==null?void 0:s.cl)==null?void 0:ae.rgb,strokeLine:!!((de=s==null?void 0:s.st)!=null&&de.s),underline:!!((ue=s==null?void 0:s.ul)!=null&&ue.s),warp:A===o.WrapStrategy.WRAP,hAlign:o.HorizontalAlign.LEFT},Z),e.restore(),e.translateWithPrecision(Q+ye+4,(J-Pe)/2),e.fillStyle=Zn,e.fill(mt),e.restore(),f.set(w,{left:m.startX+he+n.rowHeaderWidth,top:m.startY+_+n.columnHeaderHeight,width:$,height:b})}}calcCellAutoHeight(e){const{primaryWithCoord:t,style:n,data:a,row:r,col:i}=e,s=t.isMergedMainCell?t.mergeInfo:t,c=a==null?void 0:a.fontRenderExtension,{leftOffset:l=0,rightOffset:d=0,topOffset:h=0,downOffset:v=0}=c||{},u=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,r,i);if(!u||u.renderMode===o.DataValidationRenderMode.TEXT)return;const S={startX:s.startX+l,endX:s.endX-d,startY:s.startY+h,endY:s.endY-v},p=S.endX-S.startX,O=C.getCellValueOrigin(a),M=`${O!=null?O:""}`;let{tb:R,pd:y}=n||{};const{t:m=o.DEFAULT_STYLES.pd.t,b:D=o.DEFAULT_STYLES.pd.b}=y!=null?y:{};if(R=R!=null?R:o.WrapStrategy.WRAP,u.renderMode===o.DataValidationRenderMode.ARROW){const{l:I=o.DEFAULT_STYLES.pd.l,r:f=o.DEFAULT_STYLES.pd.r}=y!=null?y:{},w=p-I-f-se-4,F=new P.DocSimpleSkeleton(M,P.getFontStyleString(n).fontCache,R===o.WrapStrategy.WRAP,w,1/0);return F.calculate(),F.getTotalHeight()+m+D+Re*2}else{const I=Math.max(p-he*2-ye-se-4,10),f=new P.DocSimpleSkeleton(M,P.getFontStyleString(n).fontCache,R===o.WrapStrategy.WRAP,I,1/0);return f.calculate(),f.getTotalHeight()+Re*2+Ge*2}}calcCellAutoWidth(e){const{primaryWithCoord:t,style:n,data:a,row:r,col:i}=e,s=t.isMergedMainCell?t.mergeInfo:t,c=a==null?void 0:a.fontRenderExtension,{leftOffset:l=0,rightOffset:d=0,topOffset:h=0,downOffset:v=0}=c||{},u=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,r,i);if(!u||u.renderMode===o.DataValidationRenderMode.TEXT)return;const S={startX:s.startX+l,endX:s.endX-d,startY:s.startY+h,endY:s.endY-v},p=S.endX-S.startX,O=C.getCellValueOrigin(a),M=`${O!=null?O:""}`;let{tb:R,pd:y}=n||{};const{l:m=o.DEFAULT_STYLES.pd.l,r:D=o.DEFAULT_STYLES.pd.r}=y!=null?y:{};R=R!=null?R:o.WrapStrategy.WRAP;let I=he*2+se;switch(u.renderMode){case o.DataValidationRenderMode.ARROW:I=se+4+D+m;break;case o.DataValidationRenderMode.CUSTOM:I=se+he*2+ye*2+D+m+qe/2+1;break;default:I=se+he*2+ye*2+D+m+qe/2+1}const f=p-I,w=new P.DocSimpleSkeleton(M,P.getFontStyleString(n).fontCache,R===o.WrapStrategy.WRAP,f,1/0);return w.calculate(),w.getTotalWidth()+I}isHit(e,t){const{subUnitId:n,row:a,col:r}=t,s=this._ensureMap(n).get(this._generateKey(a,r)),c=this._dataValidationModel.getRuleByLocation(t.unitId,t.subUnitId,a,r);if(!c||!s||c.renderMode===o.DataValidationRenderMode.TEXT)return!1;const{top:l,left:d,width:h,height:v}=s,{x:u,y:S}=e;return u>=d&&u<=d+h&&S>=l&&S<=l+v}onPointerDown(e,t){if(t.button===2)return;const{unitId:n,subUnitId:a,row:r,col:i}=e,s={unitId:n,subUnitId:a,row:r,column:i};this._commandService.executeCommand(We.id,s)}onPointerEnter(e,t){var n,a;(a=(n=P.getCurrentTypeOfRenderer(o.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null?void 0:n.mainComponent)==null||a.setCursor(P.CURSOR_TYPE.POINTER)}onPointerLeave(e,t){var n,a;(a=(n=P.getCurrentTypeOfRenderer(o.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null?void 0:n.mainComponent)==null||a.setCursor(P.CURSOR_TYPE.DEFAULT)}};it=Kn([Te(0,o.IUniverInstanceService),Te(1,o.Inject(o.LocaleService)),Te(2,o.ICommandService),Te(3,o.Inject(P.IRenderManagerService)),Te(4,o.Inject(C.SheetDataValidationModel))],it);class Gn extends exports.BaseSheetDataValidatorView{constructor(){super(...arguments);L(this,"id",o.DataValidationType.LIST);L(this,"canvasRender",this.injector.createInstance(it));L(this,"dropdownType",Y.DataValidatorDropdownType.LIST);L(this,"optionsInput",ke.componentKey);L(this,"formulaInput",C.LIST_FORMULA_INPUT_NAME)}}class qn extends exports.BaseSheetDataValidatorView{constructor(){super(...arguments);L(this,"id",o.DataValidationType.TEXT_LENGTH);L(this,"formulaInput",C.BASE_FORMULA_INPUT_NAME)}}class Jn extends exports.BaseSheetDataValidatorView{constructor(){super(...arguments);L(this,"id",o.DataValidationType.WHOLE);L(this,"formulaInput",C.BASE_FORMULA_INPUT_NAME)}}var Qn=Object.getOwnPropertyDescriptor,ea=(e,t,n,a)=>{for(var r=a>1?void 0:a?Qn(t,n):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},Je=(e,t)=>(n,a)=>t(n,a,e);let be=class extends o.RxDisposable{constructor(e,t,n){super(),this._injector=e,this._componentManger=t,this._dataValidatorRegistryService=n,this._initComponents(),this._registerValidatorViews()}_initComponents(){[["DataValidationIcon",Dt],[Ue,_n],[ke.componentKey,ke],[Ne.componentKey,Ne],...Vn].forEach(([e,t])=>{this.disposeWithMe(this._componentManger.register(e,t))})}_registerValidatorViews(){[Fn,Jn,qn,Un,Pn,Gn,Xn,jn].forEach(e=>{const t=this._injector.createInstance(e),n=this._dataValidatorRegistryService.getValidatorItem(t.id);n&&(n.formulaInput=t.formulaInput,n.canvasRender=t.canvasRender,n.dropdownType=t.dropdownType,n.optionsInput=t.optionsInput)})}};be=ea([Je(0,o.Inject(o.Injector)),Je(1,o.Inject(E.ComponentManager)),Je(2,o.Inject(Y.DataValidatorRegistryService))],be);var ta=Object.getOwnPropertyDescriptor,na=(e,t,n,a)=>{for(var r=a>1?void 0:a?ta(t,n):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},Qe=(e,t)=>(n,a)=>t(n,a,e);const aa="SHEET_DATA_VALIDATION_UI_PLUGIN";var je;exports.UniverSheetsDataValidationMobileUIPlugin=(je=class extends o.Plugin{constructor(t=xe,n,a,r){super(),this._config=t,this._injector=n,this._commandService=a,this._configService=r;const{menu:i,...s}=o.merge({},xe,this._config);i&&this._configService.setConfig("menu",i,{merge:!0}),this._configService.setConfig(st,s)}onStarting(){[[ce],[me],[Oe],[we],[Me],[Ee],[Ve],[be]].forEach(t=>{this._injector.add(t)}),[$e,We,_t,lt,fe,St].forEach(t=>{this._commandService.registerCommand(t)})}onReady(){this._injector.get(Ve),this._injector.get(Ee),this._injector.get(P.IRenderManagerService).registerRenderModule(o.UniverInstanceType.UNIVER_SHEET,[Fe])}onRendered(){this._injector.get(be),this._injector.get(Me)}onSteady(){this._injector.get(we)}},L(je,"pluginName",aa),L(je,"type",o.UniverInstanceType.UNIVER_SHEET),je);exports.UniverSheetsDataValidationMobileUIPlugin=na([Qe(1,o.Inject(o.Injector)),Qe(2,o.ICommandService),Qe(3,o.IConfigService)],exports.UniverSheetsDataValidationMobileUIPlugin);var ra=Object.defineProperty,ia=Object.getOwnPropertyDescriptor,oa=(e,t,n)=>t in e?ra(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,sa=(e,t,n,a)=>{for(var r=a>1?void 0:a?ia(t,n):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},et=(e,t)=>(n,a)=>t(n,a,e),Tt=(e,t,n)=>oa(e,typeof t!="symbol"?t+"":t,n);const la="SHEET_DATA_VALIDATION_UI_PLUGIN";exports.UniverSheetsDataValidationUIPlugin=class extends o.Plugin{constructor(t=xe,n,a,r){super(),this._config=t,this._injector=n,this._commandService=a,this._configService=r;const{menu:i,...s}=o.merge({},xe,this._config);i&&this._configService.setConfig("menu",i,{merge:!0}),this._configService.setConfig(st,s)}onStarting(){[[ce],[me],[Oe],[we],[Me],[Ee],[Ve],[De],[be]].forEach(t=>{this._injector.add(t)}),[$e,We,_t,lt,fe,St].forEach(t=>{this._commandService.registerCommand(t)})}onReady(){this._injector.get(Ve),this._injector.get(Ee),this._injector.get(De),this._injector.get(Oe),this._injector.get(P.IRenderManagerService).registerRenderModule(o.UniverInstanceType.UNIVER_SHEET,[Fe])}onRendered(){this._injector.get(be),this._injector.get(Me)}onSteady(){this._injector.get(we)}};Tt(exports.UniverSheetsDataValidationUIPlugin,"pluginName",la);Tt(exports.UniverSheetsDataValidationUIPlugin,"type",o.UniverInstanceType.UNIVER_SHEET);exports.UniverSheetsDataValidationUIPlugin=sa([o.DependentOn(C.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:n,onMouseEnter:()=>{i||(u(!0),h.current=t.ranges.map(R=>l.addShape({range:R,style:A,primary:null})))},onMouseLeave:()=>{var R;u(!1),(R=h.current)==null||R.forEach(y=>{y&&l.removeShape(y)}),h.current=void 0},children:[g.jsx("div",{className:"univer-truncate univer-text-sm univer-font-medium univer-leading-[22px] univer-text-gray-900 dark:!univer-text-white",children:d==null?void 0:d.generateRuleName(t)}),g.jsx("div",{className:"univer-text-secondary univer-truncate univer-text-xs univer-leading-[18px] dark:!univer-text-gray-300",children:t.ranges.map(R=>nt.serializeRange(R)).join(",")}),m?g.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:E,children:g.jsx(ct,{})}):null]})};function Sn(e){const t=V.useDependency(I.SheetDataValidationModel),n=V.useDependency(o.IUniverInstanceService),a=V.useDependency(o.ICommandService),r=V.useDependency(o.Injector),i=V.useDependency(ce),s=V.useDependency(o.LocaleService),[c,l]=T.useState([]),{workbook:d}=e,h=V.useObservable(d.activeSheet$,void 0,!0),m=d.getUnitId(),u=h==null?void 0:h.getSheetId();T.useEffect(()=>{l(t.getRules(m,u));const y=t.ruleChange$.subscribe(D=>{D.unitId===m&&D.subUnitId===u&&l(t.getRules(m,u))});return()=>{y.unsubscribe()}},[m,u,t]);const S=async()=>{const y=I.createDefaultNewRule(r),D={unitId:m,subUnitId:u,rule:y};await a.executeCommand(I.AddSheetDataValidationCommand.id,D),i.setActiveRule({unitId:m,subUnitId:u,rule:y})},p=()=>{a.executeCommand(I.RemoveSheetAllDataValidationCommand.id,{unitId:m,subUnitId:u})},E=(y=>{const D=n.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET),O=D.getActiveSheet(),f=D.getUnitId(),v=O.getSheetId();return y.map(F=>H.checkRangesEditablePermission(r,f,v,F.ranges)?{...F}:{...F,disable:!0})})(c),R=E==null?void 0:E.some(y=>y.disable);return g.jsxs("div",{className:"univer-pb-4",children:[E==null?void 0:E.map(y=>{var D;return g.jsx(fn,{unitId:m,subUnitId:u,onClick:()=>{y.disable||i.setActiveRule({unitId:m,subUnitId:u,rule:y})},rule:y,disable:(D=y.disable)!=null?D:!1},y.uid)}),g.jsxs("div",{className:"univer-mt-4 univer-flex univer-flex-row univer-justify-end univer-gap-2",children:[c.length&&!R?g.jsx(w.Button,{onClick:p,children:s.t("dataValidation.panel.removeAll")}):null,g.jsx(w.Button,{variant:"primary",onClick:S,children:s.t("dataValidation.panel.add")})]})]})}const _n=()=>{const e=V.useDependency(ce),t=V.useObservable(e.activeRule$,e.activeRule),n=V.useDependency(o.IUniverInstanceService),a=V.useObservable(()=>n.getCurrentTypeOfUnit$(o.UniverInstanceType.UNIVER_SHEET),void 0,void 0,[]),r=V.useObservable(()=>{var i;return(i=a==null?void 0:a.activeSheet$)!=null?i:re.of(null)},void 0,void 0,[]);return!a||!r?null:t&&t.subUnitId===r.getSheetId()?g.jsx(mn,{},t.rule.uid):g.jsx(Sn,{workbook:a})},In=e=>{const{isTwoFormula:t=!1,value:n,onChange:a,showError:r,validResult:i}=e,s=V.useDependency(o.LocaleService),c=r?i==null?void 0:i.formula1:"",l=r?i==null?void 0:i.formula2:"";return t?g.jsxs(g.Fragment,{children:[g.jsx(w.FormLayout,{error:c,children:g.jsx(w.Input,{className:"univer-w-full",placeholder:s.t("dataValidation.panel.formulaPlaceholder"),value:n==null?void 0:n.formula1,onChange:d=>{a==null||a({...n,formula1:d})}})}),g.jsx("div",{className:"-univer-mt-2 univer-mb-1 univer-text-sm univer-text-gray-400",children:s.t("dataValidation.panel.formulaAnd")}),g.jsx(w.FormLayout,{error:l,children:g.jsx(w.Input,{className:"univer-w-full",placeholder:s.t("dataValidation.panel.formulaPlaceholder"),value:n==null?void 0:n.formula2,onChange:d=>{a==null||a({...n,formula2:d})}})})]}):g.jsx(w.FormLayout,{error:c,children:g.jsx(w.Input,{className:"univer-w-full",placeholder:s.t("dataValidation.panel.formulaPlaceholder"),value:n==null?void 0:n.formula1,onChange:d=>{a==null||a({formula1:d})}})})};function Cn(e){const{value:t,onChange:n,showError:a,validResult:r}=e,i=V.useDependency(o.LocaleService),s=a?r==null?void 0:r.formula1:"",c=a?r==null?void 0:r.formula2:"",[l,d]=T.useState(!((t==null?void 0:t.formula1)===void 0&&(t==null?void 0:t.formula2)===void 0));return g.jsxs(g.Fragment,{children:[g.jsx(w.FormLayout,{children:g.jsx(w.Checkbox,{checked:l,onChange:h=>{h?d(!0):(d(!1),n==null||n({...t,formula1:void 0,formula2:void 0}))},children:i.t("dataValidation.checkbox.tips")})}),l?g.jsx(w.FormLayout,{label:i.t("dataValidation.checkbox.checked"),error:s,children:g.jsx(w.Input,{className:"univer-w-full",placeholder:i.t("dataValidation.panel.valuePlaceholder"),value:t==null?void 0:t.formula1,onChange:h=>{n==null||n({...t,formula1:h||void 0})}})}):null,l?g.jsx(w.FormLayout,{label:i.t("dataValidation.checkbox.unchecked"),error:c,children:g.jsx(w.Input,{className:"univer-w-full",placeholder:i.t("dataValidation.panel.valuePlaceholder"),value:t==null?void 0:t.formula2,onChange:h=>{n==null||n({...t,formula2:h||void 0})}})}):null]})}function yn(e){var m;const{unitId:t,subUnitId:n,value:a,onChange:r,showError:i,validResult:s}=e,c=i?s==null?void 0:s.formula1:void 0,l=T.useRef(null),[d,h]=T.useState(!1);return V.useSidebarClick(u=>{var p;(p=l.current)!=null&&p.isClickOutSide(u)&&h(!1)}),g.jsx(w.FormLayout,{error:c,children:g.jsx(st.FormulaEditor,{ref:l,className:w.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",w.borderClassName),initValue:(m=a==null?void 0:a.formula1)!=null?m:"=",unitId:t,subUnitId:n,isFocus:d,isSupportAcrossSheet:!0,onChange:u=>{const S=(u!=null?u:"").trim();S!==(a==null?void 0:a.formula1)&&(r==null||r({...a,formula1:S}))},onFocus:()=>h(!0)})})}const Rn=["#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:n,disabled:a}=e,[r,i]=T.useState(!1);return g.jsx(w.Dropdown,{align:"start",disabled:a,open:r,onOpenChange:i,overlay:g.jsx("div",{className:"univer-box-border univer-grid univer-w-fit univer-grid-cols-6 univer-flex-wrap univer-gap-2 univer-p-1.5",children:Rn.map(s=>g.jsx("div",{className:w.clsx("univer-box-border univer-size-4 univer-cursor-pointer univer-rounded",w.borderClassName),style:{background:s},onClick:()=>{n(s),i(!1)}},s))}),children:g.jsxs("div",{className:w.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",w.borderClassName),children:[g.jsx("div",{className:"univer-box-border univer-h-4 univer-w-4 univer-rounded univer-text-base",style:{background:t}}),g.jsx(dt,{})]})})},vt=e=>{const{item:t,commonProps:n,className:a}=e,{onItemChange:r,onItemDelete:i}=n;return g.jsxs("div",{className:w.clsx("univer-flex univer-items-center univer-gap-2",a),children:[!t.isRef&&g.jsx("div",{className:w.clsx("univer-cursor-move","draggableHandle"),children:g.jsx(Et,{})}),g.jsx(Dn,{value:t.color,onChange:s=>{r(t.id,t.label,s)}}),g.jsx(w.Input,{disabled:t.isRef,value:t.label,onChange:s=>{r(t.id,s,t.color)}}),t.isRef?null:g.jsx("div",{className:"univer-ml-1 univer-cursor-pointer univer-rounded univer-text-base hover:univer-bg-gray-200",children:g.jsx(ct,{onClick:()=>i(t.id)})})]})};function wn(e){const{value:t,onChange:n=()=>{},unitId:a,subUnitId:r,validResult:i,showError:s,ruleId:c}=e,{formula1:l="",formula2:d=""}=t||{},[h,m]=T.useState(()=>o.isFormulaString(l)?"1":"0"),[u,S]=T.useState(h==="1"?l:"="),[p,A]=T.useState(h==="1"?l:"="),E=V.useDependency(o.LocaleService),R=V.useDependency(Y.DataValidatorRegistryService),y=V.useDependency(Y.DataValidationModel),D=V.useDependency(I.DataValidationFormulaController),[O,f]=T.useState(()=>d.split(",")),v=R.getValidatorItem(o.DataValidationType.LIST),[C,F]=T.useState([]),[B,$]=T.useState(""),k=s?i==null?void 0:i.formula1:"",M=T.useMemo(()=>y.ruleChange$.pipe(re.debounceTime(16)),[]),j=V.useObservable(M),U=V.useEvent(n);T.useEffect(()=>{(async()=>{await new Promise(_=>{setTimeout(()=>_(!0),100)});const b=y.getRuleById(a,r,c),W=b==null?void 0:b.formula1;if(o.isFormulaString(W)&&v&&b){const _=await v.getListAsync(b,a,r);F(_)}})()},[y,j,v,c,r,a]),T.useEffect(()=>{o.isFormulaString(l)&&l!==p&&(S(l),A(p))},[p,l]);const[z,Z]=T.useState(()=>{const b=h!=="1"?I.deserializeListOptions(l):[],W=d.split(",");return b.map((_,x)=>({label:_,color:W[x]||ve,isRef:!1,id:o.generateRandomId(4)}))}),Q=(b,W,_)=>{const x=z.find(X=>X.id===b);x&&(x.label=W,x.color=_,Z([...z]))},K=b=>{const W=z.findIndex(_=>_.id===b);W!==-1&&(z.splice(W,1),Z([...z]))},ne=d.split(","),ae=T.useMemo(()=>C.map((b,W)=>({label:b,color:ne[W]||ve,id:`${W}`,isRef:!0})),[ne,C]),de=(b,W,_)=>{const x=[...O];x[+b]=_,f(x),U({formula1:l,formula2:x.join(",")})},ue=()=>{Z([...z,{label:"",color:ve,isRef:!1,id:o.generateRandomId(4)}])};T.useEffect(()=>{if(h==="1")return;const b=new Set,W=[];z.map(_=>({labelList:_.label.split(","),item:_})).forEach(({item:_,labelList:x})=>{x.forEach(X=>{b.has(X)||(b.add(X),W.push({label:X,color:_.color}))})}),U({formula1:I.serializeListOptions(W.map(_=>_.label)),formula2:W.map(_=>_.color===ve?"":_.color).join(",")})},[z,U,h,p,O]);const ee=V.useEvent(async b=>{if(!o.isFormulaString(b)){U==null||U({formula1:"",formula2:d});return}D.getFormulaRefCheck(b)?(U==null||U({formula1:o.isFormulaString(b)?b:"",formula2:d}),$("")):(U==null||U({formula1:"",formula2:d}),S("="),$(E.t("dataValidation.validFail.formulaError")))}),G=T.useRef(null),[le,J]=T.useState(!1);return V.useSidebarClick(b=>{var _;(_=G.current)!=null&&_.isClickOutSide(b)&&J(!1)}),g.jsxs(g.Fragment,{children:[g.jsx(w.FormLayout,{label:E.t("dataValidation.list.options"),children:g.jsxs(w.RadioGroup,{value:h,onChange:b=>{m(b),S(p),b==="1"&&U({formula1:p==="="?"":p,formula2:O.join(",")})},children:[g.jsx(w.Radio,{value:"0",children:E.t("dataValidation.list.customOptions")}),g.jsx(w.Radio,{value:"1",children:E.t("dataValidation.list.refOptions")})]})}),h==="1"?g.jsxs(w.FormLayout,{error:k||B||void 0,children:[g.jsx(st.FormulaEditor,{ref:G,className:w.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",w.borderClassName),initValue:u,unitId:a,subUnitId:r,isFocus:le,isSupportAcrossSheet:!0,onFocus:()=>J(!0),onChange:(b="")=>{const W=(b!=null?b:"").trim();A(W),ee(W)}}),ae.length>0&&g.jsx("div",{className:"univer-mt-3",children:ae.map(b=>g.jsx(vt,{className:"univer-mb-3",item:b,commonProps:{onItemChange:de}},b.id))})]}):g.jsx(w.FormLayout,{error:k,children:g.jsxs("div",{className:"-univer-mt-3",children:[g.jsx(w.DraggableList,{list:z,onListChange:Z,rowHeight:28,margin:[0,12],draggableHandle:".draggableHandle",itemRender:b=>g.jsx(vt,{item:b,commonProps:{onItemChange:Q,onItemDelete:K}},b.id),idKey:"id"}),g.jsxs("a",{className:"univer-text-primary univer-flex univer-w-fit univer-cursor-pointer univer-flex-row univer-items-center univer-rounded univer-p-1 univer-px-2 univer-text-sm hover:univer-bg-primary-50 dark:hover:!univer-bg-gray-800",onClick:ue,children:[g.jsx(wt,{className:"univer-mr-1"}),E.t("dataValidation.list.add")]})]})})]})}const Vn=[[I.CUSTOM_FORMULA_INPUT_NAME,yn],[I.BASE_FORMULA_INPUT_NAME,In],[I.LIST_FORMULA_INPUT_NAME,wn],[I.CHECKBOX_FORMULA_INPUT_NAME,Cn]],En="LIST_RENDER_MODE_OPTION_INPUT";function Ne(e){var r;const{value:t,onChange:n}=e,a=V.useDependency(o.LocaleService);return g.jsx(w.FormLayout,{label:a.t("dataValidation.renderMode.label"),children:g.jsxs(w.RadioGroup,{value:`${(r=t.renderMode)!=null?r:o.DataValidationRenderMode.CUSTOM}`,onChange:i=>n({...t,renderMode:+i}),children:[g.jsx(w.Radio,{value:`${o.DataValidationRenderMode.CUSTOM}`,children:a.t("dataValidation.renderMode.chip")}),g.jsx(w.Radio,{value:`${o.DataValidationRenderMode.ARROW}`,children:a.t("dataValidation.renderMode.arrow")}),g.jsx(w.Radio,{value:`${o.DataValidationRenderMode.TEXT}`,children:a.t("dataValidation.renderMode.text")})]})})}Ne.componentKey=En;const Mn="DATE_SHOW_TIME_OPTION";function Be(e){var r;const{value:t,onChange:n}=e,a=V.useDependency(o.LocaleService);return g.jsx(w.FormLayout,{children:g.jsx(w.Checkbox,{checked:(r=t.bizInfo)==null?void 0:r.showTime,onChange:i=>{n({...t,bizInfo:{...t.bizInfo,showTime:i}})},children:a.t("dataValidation.showTime.label")})})}Be.componentKey=Mn;var bn=Object.getOwnPropertyDescriptor,Tn=(e,t,n,a)=>{for(var r=a>1?void 0:a?bn(t,n):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},Ce=(e,t)=>(n,a)=>t(n,a,e);const Ae=6;let at=class{constructor(e,t,n,a,r,i){this._commandService=e,this._univerInstanceService=t,this._formulaService=n,this._themeService=a,this._renderManagerService=r,this._dataValidationModel=i}_calc(e,t){var d,h,m;const{vt:n,ht:a}=t||{},r=e.endX-e.startX-Ae*2,i=e.endY-e.startY,s=((d=t==null?void 0:t.fs)!=null?d:10)*1.6;let c=0,l=0;switch(n){case o.VerticalAlign.TOP:l=0;break;case o.VerticalAlign.BOTTOM:l=0+(i-s);break;default:l=0+(i-s)/2;break}switch(a){case o.HorizontalAlign.LEFT:c=Ae;break;case o.HorizontalAlign.RIGHT:c=Ae+(r-s);break;default:c=Ae+(r-s)/2;break}return{left:e.startX+c,top:e.startY+l,width:((h=t==null?void 0:t.fs)!=null?h:10)*1.6,height:((m=t==null?void 0:t.fs)!=null?m:10)*1.6}}calcCellAutoHeight(e){var n;const{style:t}=e;return((n=t==null?void 0:t.fs)!=null?n:10)*1.6}calcCellAutoWidth(e){var n;const{style:t}=e;return((n=t==null?void 0:t.fs)!=null?n:10)*1.6}async _parseFormula(e,t,n){var d,h,m,u,S,p,A,E,R;const{formula1:a=I.CHECKBOX_FORMULA_1,formula2:r=I.CHECKBOX_FORMULA_2}=e,i=await this._formulaService.getRuleFormulaResult(t,n,e.uid),s=I.getFormulaResult((m=(h=(d=i==null?void 0:i[0])==null?void 0:d.result)==null?void 0:h[0])==null?void 0:m[0]),c=I.getFormulaResult((p=(S=(u=i==null?void 0:i[1])==null?void 0:u.result)==null?void 0:S[0])==null?void 0:p[0]),l=I.isLegalFormulaResult(String(s))&&I.isLegalFormulaResult(String(c));return{formula1:o.isFormulaString(a)?I.getFormulaResult((R=(E=(A=i==null?void 0:i[0])==null?void 0:A.result)==null?void 0:E[0])==null?void 0:R[0]):a,formula2:o.isFormulaString(r)?c:r,isFormulaValid:l}}drawWith(e,t){var k,M,j,U;const{style:n,primaryWithCoord:a,unitId:r,subUnitId:i,worksheet:s,row:c,col:l}=t,d=a.isMergedMainCell?a.mergeInfo:a,h=I.getCellValueOrigin(s.getCellRaw(c,l)),m=this._dataValidationModel.getRuleByLocation(r,i,c,l);if(!m)return;const u=this._dataValidationModel.getValidator(m.type);if(!u||!((k=u.skipDefaultFontRender)!=null&&k.call(u,m,h,{unitId:r,subUnitId:i,row:c,column:l})))return;const S=u.parseFormulaSync(m,r,i),{formula1:p}=S,A=this._calc(d,n),{a:E,d:R}=e.getTransform(),y=P.fixLineWidthByScale(A.left,E),D=P.fixLineWidthByScale(A.top,R),O=P.Transform.create().composeMatrix({left:y,top:D,scaleX:1,scaleY:1,angle:0,skewX:0,skewY:0,flipX:!1,flipY:!1}),f=d.endX-d.startX,v=d.endY-d.startY;e.save(),e.beginPath(),e.rect(d.startX,d.startY,f,v),e.clip();const C=O.getMatrix();e.transform(C[0],C[1],C[2],C[3],C[4],C[5]);const F=((M=n==null?void 0:n.fs)!=null?M:10)*1.6,B=String(h)===String(p),$=this._themeService.getColorFromTheme("primary.600");P.CheckboxShape.drawWith(e,{checked:B,width:F,height:F,fill:(U=(j=n==null?void 0:n.cl)==null?void 0:j.rgb)!=null?U:$}),e.restore()}isHit(e,t){const n=t.primaryWithCoord.isMergedMainCell?t.primaryWithCoord.mergeInfo:t.primaryWithCoord,a=this._calc(n,t.style),r=a.top,i=a.top+a.height,s=a.left,c=a.left+a.width,{x:l,y:d}=e;return l<=c&&l>=s&&d<=i&&d>=r}async onPointerDown(e,t){var p;if(t.button===2)return;const{primaryWithCoord:n,unitId:a,subUnitId:r,worksheet:i,row:s,col:c}=e,l=I.getCellValueOrigin(i.getCellRaw(s,c)),d=this._dataValidationModel.getRuleByLocation(a,r,s,c);if(!d)return;const h=this._dataValidationModel.getValidator(d.type);if(!h||!((p=h.skipDefaultFontRender)!=null&&p.call(h,d,l,{unitId:a,subUnitId:r,row:s,column:c})))return;const{formula1:m,formula2:u}=await this._parseFormula(d,a,r),S={range:{startColumn:n.actualColumn,endColumn:n.actualColumn,startRow:n.actualRow,endRow:n.actualRow},value:{v:String(l)===I.transformCheckboxValue(String(m))?u:m,p:null}};this._commandService.executeCommand(H.SetRangeValuesCommand.id,S)}onPointerEnter(e,t){var n,a;(a=(n=P.getCurrentTypeOfRenderer(o.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null?void 0:n.mainComponent)==null||a.setCursor(P.CURSOR_TYPE.POINTER)}onPointerLeave(e,t){var n,a;(a=(n=P.getCurrentTypeOfRenderer(o.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null?void 0:n.mainComponent)==null||a.setCursor(P.CURSOR_TYPE.DEFAULT)}};at=Tn([Ce(0,o.ICommandService),Ce(1,o.IUniverInstanceService),Ce(2,o.Inject(I.DataValidationFormulaService)),Ce(3,o.Inject(o.ThemeService)),Ce(4,o.Inject(P.IRenderManagerService)),Ce(5,o.Inject(I.SheetDataValidationModel))],at);var On=Object.getOwnPropertyDescriptor,An=(e,t,n,a)=>{for(var r=a>1?void 0:a?On(t,n):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},Ln=(e,t)=>(n,a)=>t(n,a,e);exports.BaseSheetDataValidatorView=class{constructor(t){L(this,"canvasRender",null);L(this,"dropdownType");L(this,"optionsInput");L(this,"formulaInput",I.LIST_FORMULA_INPUT_NAME);this.injector=t}};exports.BaseSheetDataValidatorView=An([Ln(0,o.Inject(o.Injector))],exports.BaseSheetDataValidatorView);class Pn extends exports.BaseSheetDataValidatorView{constructor(){super(...arguments);L(this,"id",o.DataValidationType.CHECKBOX);L(this,"canvasRender",this.injector.createInstance(at));L(this,"formulaInput",I.CHECKBOX_FORMULA_INPUT_NAME)}}class jn extends exports.BaseSheetDataValidatorView{constructor(){super(...arguments);L(this,"id",o.DataValidationType.CUSTOM);L(this,"formulaInput",I.CUSTOM_FORMULA_INPUT_NAME)}}const xn="data-validation.formula-input";class Un extends exports.BaseSheetDataValidatorView{constructor(){super(...arguments);L(this,"id",o.DataValidationType.DATE);L(this,"formulaInput",xn);L(this,"optionsInput",Be.componentKey);L(this,"dropdownType",Y.DataValidatorDropdownType.DATE)}}class Fn extends exports.BaseSheetDataValidatorView{constructor(){super(...arguments);L(this,"id",o.DataValidationType.DECIMAL);L(this,"formulaInput",I.BASE_FORMULA_INPUT_NAME)}}const Mt=4,kn=0,Ze=4,bt=4,rt=6,We=6,pe=14;function Nn(e,t){const n=P.FontCache.getTextSize(e,t),a=n.width+Mt*2,{ba:r,bd:i}=n,s=r+i;return{width:a,height:s+kn*2,ba:r}}function Ge(e,t,n,a){const r=pe+rt*2,i=n-r,s=a-We*2,c=e.map(u=>({layout:Nn(u,t),text:u}));let l;const d=[];c.forEach(u=>{const{layout:S}=u,{width:p,height:A}=S;!l||l.width+p+Ze>i?(l={width:p,height:A,items:[{...u,left:0}]},d.push(l)):(l.items.push({...u,left:l.width+Ze}),l.width=l.width+p+Ze)});let h=0,m=0;return d.forEach((u,S)=>{m=Math.max(m,u.width),S===d.length-1?h+=u.height:h+=u.height+bt}),{lines:d,totalHeight:h,contentWidth:i,contentHeight:s,cellAutoHeight:h+We*2,calcAutoWidth:m+r}}const Bn=8;class Wn extends P.Shape{static drawWith(t,n){const{fontString:a,info:r,fill:i,color:s}=n,{layout:c,text:l}=r;t.save(),P.Rect.drawWith(t,{width:c.width,height:c.height,radius:Bn,fill:i||ve}),t.translateWithPrecision(Mt,c.ba),t.font=a,t.fillStyle=s,t.fillText(l,0,0),t.restore()}}var $n=Object.getOwnPropertyDescriptor,Hn=(e,t,n,a)=>{for(var r=a>1?void 0:a?$n(t,n):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},Le=(e,t)=>(n,a)=>t(n,a,e);const 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 it=class{constructor(e,t,n,a){L(this,"zIndex");L(this,"_dropdownInfoMap",new Map);this._commandService=e,this._univerInstanceService=t,this._renderManagerService=n,this._dataValidationModel=a}_ensureMap(e){let t=this._dropdownInfoMap.get(e);return t||(t=new Map,this._dropdownInfoMap.set(e,t)),t}_generateKey(e,t){return`${e}.${t}`}_drawDownIcon(e,t,n,a,r){const i=n-pe+4;let s=4;switch(r){case o.VerticalAlign.MIDDLE:s=(a-pe)/2+4;break;case o.VerticalAlign.BOTTOM:s=a-pe+4;break}e.save(),e.translateWithPrecision(t.startX+i,t.startY+s),e.fillStyle="#565656",e.fill(Yn),e.restore()}drawWith(e,t,n,a){var ae,de;const{primaryWithCoord:r,row:i,col:s,style:c,data:l,subUnitId:d}=t,h=r.isMergedMainCell?r.mergeInfo:r,m=l==null?void 0:l.fontRenderExtension,{leftOffset:u=0,rightOffset:S=0,topOffset:p=0,downOffset:A=0}=m||{},E=this._ensureMap(d),R=this._generateKey(i,s),y=r.isMergedMainCell?r.mergeInfo.startRow:i,D=r.isMergedMainCell?r.mergeInfo.startColumn:s,O=this._dataValidationModel.getRuleByLocation(t.unitId,t.subUnitId,y,D);if(!O)return;const f=this._dataValidationModel.getValidator(O.type);if(!f)return;const v={startX:h.startX+u,endX:h.endX-S,startY:h.startY+p,endY:h.endY-A},C=v.endX-v.startX,F=v.endY-v.startY,{cl:B}=c||{},$=(ae=typeof B=="object"?B==null?void 0:B.rgb:B)!=null?ae:"#000",k=P.getFontStyleString(c!=null?c:void 0),{vt:M,ht:j}=c||{},U=M!=null?M:o.VerticalAlign.MIDDLE,z=(de=I.getCellValueOrigin(l))!=null?de:"",Z=f.parseCellValue(z),Q=f.getListWithColorMap(O),K=Ge(Z,k,C,F);this._drawDownIcon(e,v,C,F,U),e.save(),e.translateWithPrecision(v.startX,v.startY),e.beginPath(),e.rect(0,0,C-pe,F),e.clip(),e.translateWithPrecision(rt,We);let ne=0;switch(U){case o.VerticalAlign.MIDDLE:ne=(K.contentHeight-K.totalHeight)/2;break;case o.VerticalAlign.BOTTOM:ne=K.contentHeight-K.totalHeight;break}e.translateWithPrecision(0,ne),K.lines.forEach((ue,ee)=>{e.save();const{width:G,height:le,items:J}=ue;let b=0;switch(j){case o.HorizontalAlign.RIGHT:b=K.contentWidth-G;break;case o.HorizontalAlign.CENTER:b=(K.contentWidth-G)/2;break}e.translate(b,ee*(le+bt)),J.forEach(W=>{e.save(),e.translateWithPrecision(W.left,0),Wn.drawWith(e,{...k,info:W,color:$,fill:Q[W.text]}),e.restore()}),e.restore()}),e.restore(),E.set(R,{left:v.startX,top:v.startY,width:K.contentWidth+rt+pe,height:K.contentHeight+We*2})}calcCellAutoHeight(e){var f;const{primaryWithCoord:t,style:n,data:a,row:r,col:i}=e,s=a==null?void 0:a.fontRenderExtension,{leftOffset:c=0,rightOffset:l=0,topOffset:d=0,downOffset:h=0}=s||{},m=t.isMergedMainCell?t.mergeInfo:t,u={startX:m.startX+c,endX:m.endX-l,startY:m.startY+d,endY:m.endY-h},S=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,r,i);if(!S)return;const p=this._dataValidationModel.getValidator(S.type);if(!p)return;const A=u.endX-u.startX,E=u.endY-u.startY,R=(f=I.getCellValueOrigin(a))!=null?f:"",y=p.parseCellValue(R),D=P.getFontStyleString(n!=null?n:void 0);return Ge(y,D,A,E).cellAutoHeight}calcCellAutoWidth(e){var f;const{primaryWithCoord:t,style:n,data:a,row:r,col:i}=e,s=a==null?void 0:a.fontRenderExtension,{leftOffset:c=0,rightOffset:l=0,topOffset:d=0,downOffset:h=0}=s||{},m=t.isMergedMainCell?t.mergeInfo:t,u={startX:m.startX+c,endX:m.endX-l,startY:m.startY+d,endY:m.endY-h},S=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,r,i);if(!S)return;const p=this._dataValidationModel.getValidator(S.type);if(!p)return;const A=u.endX-u.startX,E=u.endY-u.startY,R=(f=I.getCellValueOrigin(a))!=null?f:"",y=p.parseCellValue(R),D=P.getFontStyleString(n!=null?n:void 0);return Ge(y,D,A,E).calcAutoWidth}isHit(e,t){const{primaryWithCoord:n}=t,a=n.isMergedMainCell?n.mergeInfo:n,{endX:r}=a,{x:i}=e;return i>=r-pe&&i<=r}onPointerDown(e,t){if(t.button===2)return;const{unitId:n,subUnitId:a,row:r,col:i}=e,s={unitId:n,subUnitId:a,row:r,column:i};this._commandService.executeCommand($e.id,s)}onPointerEnter(e,t){var n,a;return(a=(n=P.getCurrentTypeOfRenderer(o.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null?void 0:n.mainComponent)==null?void 0:a.setCursor(P.CURSOR_TYPE.POINTER)}onPointerLeave(e,t){var n,a;return(a=(n=P.getCurrentTypeOfRenderer(o.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null?void 0:n.mainComponent)==null?void 0:a.setCursor(P.CURSOR_TYPE.DEFAULT)}};it=Hn([Le(0,o.ICommandService),Le(1,o.IUniverInstanceService),Le(2,o.Inject(P.IRenderManagerService)),Le(3,o.Inject(I.SheetDataValidationModel))],it);class Xn extends exports.BaseSheetDataValidatorView{constructor(){super(...arguments);L(this,"id",o.DataValidationType.LIST_MULTIPLE);L(this,"canvasRender",this.injector.createInstance(it));L(this,"dropdownType",Y.DataValidatorDropdownType.MULTIPLE_LIST)}}var zn=Object.getOwnPropertyDescriptor,Kn=(e,t,n,a)=>{for(var r=a>1?void 0:a?zn(t,n):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},Te=(e,t)=>(n,a)=>t(n,a,e);const ye=4,Pe=4,se=14,qe=1,he=6,Re=3,Je=8,Zn="#565656",mt=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 ft(e,t,n,a,r,i,s=!0){let c=0;const l=s?Re:0;switch(r){case o.VerticalAlign.BOTTOM:c=t-a-l;break;case o.VerticalAlign.MIDDLE:c=(t-a)/2;break;default:c=l;break}c=Math.max(Re,c);let d=0;switch(i){case o.HorizontalAlign.CENTER:d=(e-n)/2;break;case o.HorizontalAlign.RIGHT:d=e-n;break}return d=Math.max(he,d),{paddingLeft:d,paddingTop:c}}let ot=class{constructor(e,t,n,a,r){L(this,"_dropdownInfoMap",new Map);L(this,"zIndex");this._univerInstanceService=e,this._localeService=t,this._commandService=n,this._renderManagerService=a,this._dataValidationModel=r}_ensureMap(e){let t=this._dropdownInfoMap.get(e);return t||(t=new Map,this._dropdownInfoMap.set(e,t)),t}_generateKey(e,t){return`${e}.${t}`}_drawDownIcon(e,t,n,a,r,i,s){const{t:c=o.DEFAULT_STYLES.pd.t,b:l=o.DEFAULT_STYLES.pd.b}=s,d=n-se;let h;switch(i){case o.VerticalAlign.MIDDLE:h=(a-Pe)/2;break;case o.VerticalAlign.BOTTOM:h=a-l-r-Re+(r/2-Pe/2);break;default:h=c+Re+(r/2-Pe/2);break}e.save(),e.translateWithPrecision(t.startX+d,t.startY+h),e.fillStyle="#565656",e.fill(mt),e.restore()}drawWith(e,t,n){var Q,K,ne,ae,de,ue;const{primaryWithCoord:a,row:r,col:i,style:s,data:c,subUnitId:l}=t,d=a.isMergedMainCell?a.mergeInfo:a,h=a.isMergedMainCell?a.mergeInfo.startRow:r,m=a.isMergedMainCell?a.mergeInfo.startColumn:i,u=this._dataValidationModel.getRuleByLocation(t.unitId,t.subUnitId,h,m);if(!u)return;const S=this._dataValidationModel.getValidator(u.type);if(!S)return;const p=c==null?void 0:c.fontRenderExtension,{leftOffset:A=0,rightOffset:E=0,topOffset:R=0,downOffset:y=0}=p||{};if(!u||!S||!S||S.id.indexOf(o.DataValidationType.LIST)!==0||!S.skipDefaultFontRender(u))return;const D={startX:d.startX+A,endX:d.endX-E,startY:d.startY+R,endY:d.endY-y},O=D.endX-D.startX,f=D.endY-D.startY,v=this._ensureMap(l),C=this._generateKey(r,i),F=S.getListWithColorMap(u),B=I.getCellValueOrigin(c),$=`${B!=null?B:""}`,k=F[$];let{tb:M,vt:j,ht:U,pd:z}=s||{};M=M!=null?M:o.WrapStrategy.WRAP,j=j!=null?j:o.VerticalAlign.BOTTOM,U=U!=null?U:o.DEFAULT_STYLES.ht,z=z!=null?z:o.DEFAULT_STYLES.pd;const Z=P.getFontStyleString(s).fontCache;if(u.renderMode===o.DataValidationRenderMode.ARROW){const{l:ee=o.DEFAULT_STYLES.pd.l,t:G=o.DEFAULT_STYLES.pd.t,r:le=o.DEFAULT_STYLES.pd.r,b:J=o.DEFAULT_STYLES.pd.b}=z,b=O-ee-le-se-4,W=new P.DocSimpleSkeleton($,Z,M===o.WrapStrategy.WRAP,b,1/0);W.calculate();const _=W.getTotalWidth(),x=W.getTotalHeight(),{paddingTop:X,paddingLeft:ie}=ft(b,f-G-J,_,x,j,U,!0);this._drawDownIcon(e,D,O,f,x,j,z),e.save(),e.translateWithPrecision(D.startX+ee,D.startY+G),e.beginPath(),e.rect(0,0,O-ee-le,f-G-J),e.clip(),e.translateWithPrecision(0,X),e.save(),e.translateWithPrecision(ie,0),e.beginPath(),e.rect(0,0,b,x),e.clip(),P.Text.drawWith(e,{text:$,fontStyle:Z,width:b,height:x,color:(Q=s==null?void 0:s.cl)==null?void 0:Q.rgb,strokeLine:!!((K=s==null?void 0:s.st)!=null&&K.s),underline:!!((ne=s==null?void 0:s.ul)!=null&&ne.s),warp:M===o.WrapStrategy.WRAP,hAlign:o.HorizontalAlign.LEFT},W),e.restore(),e.restore(),v.set(C,{left:D.endX-se+n.rowHeaderWidth,top:D.startY+G+n.columnHeaderHeight,width:se,height:f-G-J})}else{e.save(),e.translateWithPrecision(D.startX,D.startY),e.beginPath(),e.rect(0,0,O,f),e.clip();const ee=O-he*2-ye-se-4,G=new P.DocSimpleSkeleton($,Z,M===o.WrapStrategy.WRAP,ee,1/0);G.calculate();const le=G.getTotalWidth(),J=G.getTotalHeight(),b=J+qe*2,W=Math.max(O-he*2,1),{paddingTop:_}=ft(W,f,le,b,j,U);e.translateWithPrecision(he,_),P.Rect.drawWith(e,{width:W,height:b,fill:k||ve,radius:Je}),e.save(),e.translateWithPrecision(ye,qe),e.beginPath(),e.rect(0,0,ee,J),e.clip(),P.Text.drawWith(e,{text:$,fontStyle:Z,width:ee,height:J,color:(ae=s==null?void 0:s.cl)==null?void 0:ae.rgb,strokeLine:!!((de=s==null?void 0:s.st)!=null&&de.s),underline:!!((ue=s==null?void 0:s.ul)!=null&&ue.s),warp:M===o.WrapStrategy.WRAP,hAlign:o.HorizontalAlign.LEFT},G),e.restore(),e.translateWithPrecision(ee+ye+4,(J-Pe)/2),e.fillStyle=Zn,e.fill(mt),e.restore(),v.set(C,{left:D.startX+he+n.rowHeaderWidth,top:D.startY+_+n.columnHeaderHeight,width:W,height:b})}}calcCellAutoHeight(e){const{primaryWithCoord:t,style:n,data:a,row:r,col:i}=e,s=t.isMergedMainCell?t.mergeInfo:t,c=a==null?void 0:a.fontRenderExtension,{leftOffset:l=0,rightOffset:d=0,topOffset:h=0,downOffset:m=0}=c||{},u=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,r,i);if(!u||u.renderMode===o.DataValidationRenderMode.TEXT)return;const S={startX:s.startX+l,endX:s.endX-d,startY:s.startY+h,endY:s.endY-m},p=S.endX-S.startX,A=I.getCellValueOrigin(a),E=`${A!=null?A:""}`;let{tb:R,pd:y}=n||{};const{t:D=o.DEFAULT_STYLES.pd.t,b:O=o.DEFAULT_STYLES.pd.b}=y!=null?y:{};if(R=R!=null?R:o.WrapStrategy.WRAP,u.renderMode===o.DataValidationRenderMode.ARROW){const{l:f=o.DEFAULT_STYLES.pd.l,r:v=o.DEFAULT_STYLES.pd.r}=y!=null?y:{},C=p-f-v-se-4,F=new P.DocSimpleSkeleton(E,P.getFontStyleString(n).fontCache,R===o.WrapStrategy.WRAP,C,1/0);return F.calculate(),F.getTotalHeight()+D+O+Re*2}else{const f=Math.max(p-he*2-ye-se-4,10),v=new P.DocSimpleSkeleton(E,P.getFontStyleString(n).fontCache,R===o.WrapStrategy.WRAP,f,1/0);return v.calculate(),v.getTotalHeight()+Re*2+qe*2}}calcCellAutoWidth(e){const{primaryWithCoord:t,style:n,data:a,row:r,col:i}=e,s=t.isMergedMainCell?t.mergeInfo:t,c=a==null?void 0:a.fontRenderExtension,{leftOffset:l=0,rightOffset:d=0,topOffset:h=0,downOffset:m=0}=c||{},u=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,r,i);if(!u||u.renderMode===o.DataValidationRenderMode.TEXT)return;const S={startX:s.startX+l,endX:s.endX-d,startY:s.startY+h,endY:s.endY-m},p=S.endX-S.startX,A=I.getCellValueOrigin(a),E=`${A!=null?A:""}`;let{tb:R,pd:y}=n||{};const{l:D=o.DEFAULT_STYLES.pd.l,r:O=o.DEFAULT_STYLES.pd.r}=y!=null?y:{};R=R!=null?R:o.WrapStrategy.WRAP;let f=he*2+se;switch(u.renderMode){case o.DataValidationRenderMode.ARROW:f=se+4+O+D;break;case o.DataValidationRenderMode.CUSTOM:f=se+he*2+ye*2+O+D+Je/2+1;break;default:f=se+he*2+ye*2+O+D+Je/2+1}const v=p-f,C=new P.DocSimpleSkeleton(E,P.getFontStyleString(n).fontCache,R===o.WrapStrategy.WRAP,v,1/0);return C.calculate(),C.getTotalWidth()+f}isHit(e,t){const{subUnitId:n,row:a,col:r}=t,s=this._ensureMap(n).get(this._generateKey(a,r)),c=this._dataValidationModel.getRuleByLocation(t.unitId,t.subUnitId,a,r);if(!c||!s||c.renderMode===o.DataValidationRenderMode.TEXT)return!1;const{top:l,left:d,width:h,height:m}=s,{x:u,y:S}=e;return u>=d&&u<=d+h&&S>=l&&S<=l+m}onPointerDown(e,t){if(t.button===2)return;const{unitId:n,subUnitId:a,row:r,col:i}=e,s={unitId:n,subUnitId:a,row:r,column:i};this._commandService.executeCommand($e.id,s)}onPointerEnter(e,t){var n,a;(a=(n=P.getCurrentTypeOfRenderer(o.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null?void 0:n.mainComponent)==null||a.setCursor(P.CURSOR_TYPE.POINTER)}onPointerLeave(e,t){var n,a;(a=(n=P.getCurrentTypeOfRenderer(o.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null?void 0:n.mainComponent)==null||a.setCursor(P.CURSOR_TYPE.DEFAULT)}};ot=Kn([Te(0,o.IUniverInstanceService),Te(1,o.Inject(o.LocaleService)),Te(2,o.ICommandService),Te(3,o.Inject(P.IRenderManagerService)),Te(4,o.Inject(I.SheetDataValidationModel))],ot);class Gn extends exports.BaseSheetDataValidatorView{constructor(){super(...arguments);L(this,"id",o.DataValidationType.LIST);L(this,"canvasRender",this.injector.createInstance(ot));L(this,"dropdownType",Y.DataValidatorDropdownType.LIST);L(this,"optionsInput",Ne.componentKey);L(this,"formulaInput",I.LIST_FORMULA_INPUT_NAME)}}class qn extends exports.BaseSheetDataValidatorView{constructor(){super(...arguments);L(this,"id",o.DataValidationType.TEXT_LENGTH);L(this,"formulaInput",I.BASE_FORMULA_INPUT_NAME)}}class Jn extends exports.BaseSheetDataValidatorView{constructor(){super(...arguments);L(this,"id",o.DataValidationType.WHOLE);L(this,"formulaInput",I.BASE_FORMULA_INPUT_NAME)}}var Qn=Object.getOwnPropertyDescriptor,ea=(e,t,n,a)=>{for(var r=a>1?void 0:a?Qn(t,n):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},Qe=(e,t)=>(n,a)=>t(n,a,e);let be=class extends o.RxDisposable{constructor(e,t,n){super(),this._injector=e,this._componentManger=t,this._dataValidatorRegistryService=n,this._initComponents(),this._registerValidatorViews()}_initComponents(){[["DataValidationIcon",Dt],[Fe,_n],[Ne.componentKey,Ne],[Be.componentKey,Be],...Vn].forEach(([e,t])=>{this.disposeWithMe(this._componentManger.register(e,t))})}_registerValidatorViews(){[Fn,Jn,qn,Un,Pn,Gn,Xn,jn].forEach(e=>{const t=this._injector.createInstance(e),n=this._dataValidatorRegistryService.getValidatorItem(t.id);n&&(n.formulaInput=t.formulaInput,n.canvasRender=t.canvasRender,n.dropdownType=t.dropdownType,n.optionsInput=t.optionsInput)})}};be=ea([Qe(0,o.Inject(o.Injector)),Qe(1,o.Inject(V.ComponentManager)),Qe(2,o.Inject(Y.DataValidatorRegistryService))],be);var ta=Object.getOwnPropertyDescriptor,na=(e,t,n,a)=>{for(var r=a>1?void 0:a?ta(t,n):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},et=(e,t)=>(n,a)=>t(n,a,e);const aa="SHEET_DATA_VALIDATION_UI_PLUGIN";var je;exports.UniverSheetsDataValidationMobileUIPlugin=(je=class extends o.Plugin{constructor(t=Ue,n,a,r){super(),this._config=t,this._injector=n,this._commandService=a,this._configService=r;const{menu:i,...s}=o.merge({},Ue,this._config);i&&this._configService.setConfig("menu",i,{merge:!0}),this._configService.setConfig(xe,s)}onStarting(){[[ce],[me],[Oe],[we],[Me],[Ee],[Ve],[be]].forEach(t=>{this._injector.add(t)}),[He,$e,_t,lt,fe,St].forEach(t=>{this._commandService.registerCommand(t)})}onReady(){this._injector.get(Ve),this._injector.get(Ee),this._injector.get(P.IRenderManagerService).registerRenderModule(o.UniverInstanceType.UNIVER_SHEET,[ke])}onRendered(){this._injector.get(be),this._injector.get(Me)}onSteady(){this._injector.get(we)}},L(je,"pluginName",aa),L(je,"type",o.UniverInstanceType.UNIVER_SHEET),je);exports.UniverSheetsDataValidationMobileUIPlugin=na([et(1,o.Inject(o.Injector)),et(2,o.ICommandService),et(3,o.IConfigService)],exports.UniverSheetsDataValidationMobileUIPlugin);var ra=Object.defineProperty,ia=Object.getOwnPropertyDescriptor,oa=(e,t,n)=>t in e?ra(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,sa=(e,t,n,a)=>{for(var r=a>1?void 0:a?ia(t,n):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},tt=(e,t)=>(n,a)=>t(n,a,e),Tt=(e,t,n)=>oa(e,typeof t!="symbol"?t+"":t,n);const la="SHEET_DATA_VALIDATION_UI_PLUGIN";exports.UniverSheetsDataValidationUIPlugin=class extends o.Plugin{constructor(t=Ue,n,a,r){super(),this._config=t,this._injector=n,this._commandService=a,this._configService=r;const{menu:i,...s}=o.merge({},Ue,this._config);i&&this._configService.setConfig("menu",i,{merge:!0}),this._configService.setConfig(xe,s)}onStarting(){[[ce],[me],[Oe],[we],[Me],[Ee],[Ve],[De],[be]].forEach(t=>{this._injector.add(t)}),[He,$e,_t,lt,fe,St].forEach(t=>{this._commandService.registerCommand(t)})}onReady(){this._injector.get(Ve),this._injector.get(Ee),this._injector.get(De),this._injector.get(Oe),this._injector.get(P.IRenderManagerService).registerRenderModule(o.UniverInstanceType.UNIVER_SHEET,[ke])}onRendered(){this._injector.get(be),this._injector.get(Me)}onSteady(){this._injector.get(we)}};Tt(exports.UniverSheetsDataValidationUIPlugin,"pluginName",la);Tt(exports.UniverSheetsDataValidationUIPlugin,"type",o.UniverInstanceType.UNIVER_SHEET);exports.UniverSheetsDataValidationUIPlugin=sa([o.DependentOn(I.UniverSheetsDataValidationPlugin),tt(1,o.Inject(o.Injector)),tt(2,o.ICommandService),tt(3,o.IConfigService)],exports.UniverSheetsDataValidationUIPlugin);