@univerjs/sheets-data-validation-ui 1.0.0-alpha.5 → 1.0.0-alpha.7
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 +6 -1
- package/lib/es/index.js +6 -1
- package/lib/index.js +6 -1
- package/lib/umd/index.js +1 -1
- package/package.json +14 -14
package/lib/cjs/index.js
CHANGED
|
@@ -967,6 +967,11 @@ const menuSchema = {
|
|
|
967
967
|
},
|
|
968
968
|
[_univerjs_ui.RibbonDataGroup.RULES]: { [DATA_VALIDATION_MENU_ID]: {
|
|
969
969
|
order: 0,
|
|
970
|
+
gridLayout: {
|
|
971
|
+
row: 1,
|
|
972
|
+
column: 1,
|
|
973
|
+
showLabel: true
|
|
974
|
+
},
|
|
970
975
|
menuItemFactory: dataValidationMenuFactory,
|
|
971
976
|
[OpenValidationPanelOperation.id]: {
|
|
972
977
|
order: 0,
|
|
@@ -982,7 +987,7 @@ const menuSchema = {
|
|
|
982
987
|
//#endregion
|
|
983
988
|
//#region package.json
|
|
984
989
|
var name = "@univerjs/sheets-data-validation-ui";
|
|
985
|
-
var version = "1.0.0-alpha.
|
|
990
|
+
var version = "1.0.0-alpha.7";
|
|
986
991
|
|
|
987
992
|
//#endregion
|
|
988
993
|
//#region src/views/components/DataValidationOptions.tsx
|
package/lib/es/index.js
CHANGED
|
@@ -966,6 +966,11 @@ const menuSchema = {
|
|
|
966
966
|
},
|
|
967
967
|
[RibbonDataGroup.RULES]: { [DATA_VALIDATION_MENU_ID]: {
|
|
968
968
|
order: 0,
|
|
969
|
+
gridLayout: {
|
|
970
|
+
row: 1,
|
|
971
|
+
column: 1,
|
|
972
|
+
showLabel: true
|
|
973
|
+
},
|
|
969
974
|
menuItemFactory: dataValidationMenuFactory,
|
|
970
975
|
[OpenValidationPanelOperation.id]: {
|
|
971
976
|
order: 0,
|
|
@@ -981,7 +986,7 @@ const menuSchema = {
|
|
|
981
986
|
//#endregion
|
|
982
987
|
//#region package.json
|
|
983
988
|
var name = "@univerjs/sheets-data-validation-ui";
|
|
984
|
-
var version = "1.0.0-alpha.
|
|
989
|
+
var version = "1.0.0-alpha.7";
|
|
985
990
|
|
|
986
991
|
//#endregion
|
|
987
992
|
//#region src/views/components/DataValidationOptions.tsx
|
package/lib/index.js
CHANGED
|
@@ -966,6 +966,11 @@ const menuSchema = {
|
|
|
966
966
|
},
|
|
967
967
|
[RibbonDataGroup.RULES]: { [DATA_VALIDATION_MENU_ID]: {
|
|
968
968
|
order: 0,
|
|
969
|
+
gridLayout: {
|
|
970
|
+
row: 1,
|
|
971
|
+
column: 1,
|
|
972
|
+
showLabel: true
|
|
973
|
+
},
|
|
969
974
|
menuItemFactory: dataValidationMenuFactory,
|
|
970
975
|
[OpenValidationPanelOperation.id]: {
|
|
971
976
|
order: 0,
|
|
@@ -981,7 +986,7 @@ const menuSchema = {
|
|
|
981
986
|
//#endregion
|
|
982
987
|
//#region package.json
|
|
983
988
|
var name = "@univerjs/sheets-data-validation-ui";
|
|
984
|
-
var version = "1.0.0-alpha.
|
|
989
|
+
var version = "1.0.0-alpha.7";
|
|
985
990
|
|
|
986
991
|
//#endregion
|
|
987
992
|
//#region src/views/components/DataValidationOptions.tsx
|
package/lib/umd/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("@univerjs/ui"),require("@univerjs/core"),require("@univerjs/sheets"),require("@univerjs/sheets-data-validation"),require("@univerjs/data-validation"),require("rxjs"),require("@univerjs/engine-render"),require("@univerjs/sheets-numfmt"),require("@univerjs/sheets-ui"),require("@univerjs/design"),require("react"),require("react/jsx-runtime"),require("@univerjs/engine-formula"),require("@univerjs/sheets-formula-ui")):typeof define==`function`&&define.amd?define([`exports`,`@univerjs/ui`,`@univerjs/core`,`@univerjs/sheets`,`@univerjs/sheets-data-validation`,`@univerjs/data-validation`,`rxjs`,`@univerjs/engine-render`,`@univerjs/sheets-numfmt`,`@univerjs/sheets-ui`,`@univerjs/design`,`react`,`react/jsx-runtime`,`@univerjs/engine-formula`,`@univerjs/sheets-formula-ui`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.UniverSheetsDataValidationUi={},e.UniverUi,e.UniverCore,e.UniverSheets,e.UniverSheetsDataValidation,e.UniverDataValidation,e.rxjs,e.UniverEngineRender,e.UniverSheetsNumfmt,e.UniverSheetsUi,e.UniverDesign,e.React,e.React,e.UniverEngineFormula,e.UniverSheetsFormulaUi))})(this,function(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});function h(e){"@babel/helpers - typeof";return h=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},h(e)}function g(e,t){if(h(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(h(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function _(e){var t=g(e,`string`);return h(t)==`symbol`?t:t+``}function v(e,t,n){return(t=_(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function y(e,t){return function(n,r){t(n,r,e)}}function b(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}let x=class extends n.Disposable{get activeRule(){return this._activeRule}get isOpen(){return this._open$.getValue()}constructor(e,t){super(),this._univerInstanceService=e,this._sidebarService=t,v(this,`_open$`,new o.BehaviorSubject(!1)),v(this,`open$`,this._open$.pipe((0,o.distinctUntilChanged)())),v(this,`_activeRule`,void 0),v(this,`_activeRule$`,new o.BehaviorSubject(void 0)),v(this,`activeRule$`,this._activeRule$.asObservable()),v(this,`_closeDisposable`,null),v(this,`_focusFormulaEditorActiveRuleSubUnitId`,null),this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(n.UniverInstanceType.UNIVER_SHEET).pipe((0,o.filter)(e=>!e)).subscribe(()=>{this.close()})),this.disposeWithMe(this._sidebarService.sidebarOptions$.subscribe(e=>{e.id===`DataValidationPanel`&&(e.visible||setTimeout(()=>{this._sidebarService.sidebarOptions$.next({visible:!1})}))}))}dispose(){var e;super.dispose(),this._open$.next(!1),this._open$.complete(),this._activeRule$.complete(),(e=this._closeDisposable)==null||e.dispose()}open(){this._open$.next(!0)}close(){var e;this._open$.next(!1),(e=this._closeDisposable)==null||e.dispose()}setCloseDisposable(e){this._closeDisposable=(0,n.toDisposable)(()=>{e.dispose(),this._closeDisposable=null})}setActiveRule(e){this._activeRule=e,this._activeRule$.next(e)}setFocusFormulaEditorActiveRuleSubUnitId(e){this._focusFormulaEditorActiveRuleSubUnitId=e}getFocusFormulaEditorActiveRuleSubUnitId(){return this._focusFormulaEditorActiveRuleSubUnitId}};x=b([y(0,n.IUniverInstanceService),y(1,t.ISidebarService)],x);let S=`sheets-data-validation-ui.config`,C={},w=`#ECECEC`,T=class extends n.Disposable{constructor(e,t,n,r,i,a){super(),this._sheetInterceptorService=e,this._dataValidationModel=t,this._dataValidatorRegistryService=n,this._dialogService=r,this._localeService=i,this._sheetsDataValidationValidatorService=a,this._initEditorBridgeInterceptor()}_initEditorBridgeInterceptor(){this.disposeWithMe(this._sheetInterceptorService.writeCellInterceptor.intercept(r.VALIDATE_CELL,{handler:async(e,t,r)=>{let i=await e,{row:a,col:o,unitId:s,subUnitId:c}=t,l=this._dataValidationModel.getRuleIdByLocation(s,c,a,o),f=l?this._dataValidationModel.getRuleById(s,c,l):void 0;if(i===!1)return r(Promise.resolve(!1));if(!f||f.errorStyle!==n.DataValidationErrorStyle.STOP)return r(Promise.resolve(!0));let p=this._dataValidatorRegistryService.getValidatorItem(f.type);return!p||await this._sheetsDataValidationValidatorService.validatorCell(s,c,a,o)===n.DataValidationStatus.VALID?r(Promise.resolve(!0)):(this._dialogService.open({width:368,title:{title:this._localeService.t(`sheets-data-validation-ui.alert.title`)},id:`reject-input-dialog`,children:{title:p.getRuleFinalError(f,{row:a,col:o,unitId:s,subUnitId:c})},footer:{title:(0,d.createElement)(u.Button,{variant:`primary`,onClick:()=>this._dialogService.close(`reject-input-dialog`)},this._localeService.t(`sheets-data-validation-ui.alert.ok`))},onClose:()=>{this._dialogService.close(`reject-input-dialog`)}}),r(Promise.resolve(!1)))}}))}showReject(e){this._dialogService.open({width:368,title:{title:this._localeService.t(`sheets-data-validation-ui.alert.title`)},id:`reject-input-dialog`,children:{title:e},footer:{title:(0,d.createElement)(u.Button,{variant:`primary`,onClick:()=>this._dialogService.close(`reject-input-dialog`)},this._localeService.t(`sheets-data-validation-ui.alert.ok`))},onClose:()=>{this._dialogService.close(`reject-input-dialog`)}})}};T=b([y(0,(0,n.Inject)(r.SheetInterceptorService)),y(1,(0,n.Inject)(i.SheetDataValidationModel)),y(2,(0,n.Inject)(a.DataValidatorRegistryService)),y(3,t.IDialogService),y(4,(0,n.Inject)(n.LocaleService)),y(5,(0,n.Inject)(i.SheetsDataValidationValidatorService))],T);let E=e=>{if(e==null||typeof e==`boolean`)return;if(e===``)return(0,n.dateKit)();if(typeof e==`number`||!Number.isNaN(+e))return(0,n.dateKit)(n.numfmt.format(`yyyy-MM-dd HH:mm:ss`,Number(e)));let t=(0,n.dateKit)(e);if(t.isValid())return t};function D(e,t){if(e===(0,c.getPatternType)(t))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 O=class extends n.Disposable{get activeDropdown(){return this._activeDropdown}constructor(e,t,n,r,i,a,s,c,l,u){super(),this._univerInstanceService=e,this._dataValidatorRegistryService=t,this._dataValidationModel=n,this._sheetsSelectionsService=r,this._cellDropdownManagerService=i,this._sheetDataValidationModel=a,this._commandService=s,this._editorBridgeService=c,this._injector=l,this._configService=u,v(this,`_activeDropdown`,void 0),v(this,`_activeDropdown$`,new o.Subject),v(this,`_currentPopup`,null),v(this,`activeDropdown$`,this._activeDropdown$.asObservable()),this._initSelectionChange(),this.disposeWithMe(()=>{this._activeDropdown$.complete()})}_getDropdownByCell(e,t,r,i){let a=e?this._univerInstanceService.getUnit(e,n.UniverInstanceType.UNIVER_SHEET):this._univerInstanceService.getCurrentUnitOfType(n.UniverInstanceType.UNIVER_SHEET);if(!a)return;let o=t?a.getSheetBySheetId(t):a.getActiveSheet();if(!o)return;let s=this._dataValidationModel.getRuleByLocation(a.getUnitId(),o.getSheetId(),r,i);if(!s)return;let c=this._dataValidatorRegistryService.getValidatorItem(s.type);return c==null?void 0:c.dropdownType}_initSelectionChange(){this.disposeWithMe(this._sheetsSelectionsService.selectionMoveEnd$.subscribe(e=>{e&&e.every(e=>!(e.primary&&this._getDropdownByCell(e.primary.unitId,e.primary.sheetId,e.primary.actualRow,e.primary.actualColumn)))&&this.hideDropdown()}))}showDropdown(e){let{location:o}=e,{row:c,col:u,unitId:d,subUnitId:f,workbook:p,worksheet:m}=o;this._currentPopup&&this._currentPopup.dispose(),this._activeDropdown=e,this._activeDropdown$.next(this._activeDropdown);let h=this._sheetDataValidationModel.getRuleByLocation(d,f,c,u);if(!h)return;let g=this._dataValidatorRegistryService.getValidatorItem(h.type);if(!(g!=null&&g.dropdownType))return;let _,v=async(e,i)=>{var a,o,_;if(!e)return!0;let v=e,y=m.getCell(c,u),b=v.format(i===`date`?`YYYY-MM-DD 00:00:00`:`YYYY-MM-DD HH:mm:ss`),x=(a=n.numfmt.parseDate(b))==null?void 0:a.v,S=i===`time`?x%1:x,C=p.getStyles().getStyleByCell(y),w=(o=C==null||(_=C.n)==null?void 0:_.pattern)==null?``:o;return h.errorStyle!==n.DataValidationErrorStyle.STOP||await g.validator({value:S,unitId:d,subUnitId:f,row:c,column:u,worksheet:m,workbook:p,interceptValue:b.replace(`Z`,``).replace(`T`,` `),t:n.CellValueType.NUMBER},h)?(await this._commandService.executeCommand(r.SetRangeValuesCommand.id,{unitId:d,subUnitId:f,range:{startColumn:u,endColumn:u,startRow:c,endRow:c},value:{v:S,t:2,p:null,f:null,si:null,s:{n:{pattern:D(i,w)}}}}),await this._commandService.executeCommand(l.SetCellEditVisibleOperation.id,{visible:!1,eventType:s.DeviceInputEventType.Keyboard,unitId:d,keycode:t.KeyCode.ESC}),!0):(this._injector.has(T)&&this._injector.get(T).showReject(g.getRuleFinalError(h,{row:c,col:u,unitId:d,subUnitId:f})),!1)},y;switch(g.dropdownType){case a.DataValidatorDropdownType.DATE:{var b;let e=E((0,i.getCellValueOrigin)(m.getCellRaw(c,u))),t=!!((b=h.bizInfo)!=null&&b.showTime);y={location:o,type:`datepicker`,props:{showTime:t,onChange:e=>v(e,t?`datetime`:`date`),defaultValue:e,patternType:`date`}};break}case a.DataValidatorDropdownType.TIME:y={location:o,type:`datepicker`,props:{onChange:e=>v(e,`time`),defaultValue:E((0,i.getCellValueOrigin)(m.getCellRaw(c,u))),patternType:`time`}};break;case a.DataValidatorDropdownType.DATETIME:y={location:o,type:`datepicker`,props:{onChange:e=>v(e,`datetime`),defaultValue:E((0,i.getCellValueOrigin)(m.getCellRaw(c,u))),patternType:`datetime`}};break;case a.DataValidatorDropdownType.LIST:case a.DataValidatorDropdownType.MULTIPLE_LIST:{var x,S,C,w;let e=g.dropdownType===a.DataValidatorDropdownType.MULTIPLE_LIST,p=async n=>{var i;let a=e?(0,r.serializeListOptions)(n):(i=n[0])==null?``:i,o={unitId:d,subUnitId:f,range:{startColumn:u,endColumn:u,startRow:c,endRow:c},value:{v:a,p:null,f:null,si:null}};return this._commandService.executeCommand(r.SetRangeValuesCommand.id,o),this._editorBridgeService.isVisible().visible&&await this._commandService.executeCommand(l.SetCellEditVisibleOperation.id,{visible:!1,eventType:s.DeviceInputEventType.Keyboard,unitId:d,keycode:t.KeyCode.ESC}),!e},v=(h==null?void 0:h.renderMode)===n.DataValidationRenderMode.CUSTOM||(h==null?void 0:h.renderMode)===void 0,b=g.getListWithColor(h,d,f),T=(0,i.getDataValidationCellValue)(m.getCellRaw(c,u));y={location:o,type:`list`,props:{onChange:e=>p(e),options:b.map(e=>({label:e.label,value:e.label,color:v||e.color?e.color||`#ECECEC`:`transparent`})),onEdit:()=>{this._commandService.executeCommand(A.id,{ruleId:h.uid}),_==null||_.dispose()},defaultValue:T,multiple:e,showEdit:(x=(S=this._configService.getConfig(`sheets-data-validation-ui.config`))==null?void 0:S.showEditOnDropdown)==null?!0:x,showSearch:(C=(w=this._configService.getConfig(`sheets-data-validation-ui.config`))==null?void 0:w.showSearchOnDropdown)==null?!0:C}};break}case a.DataValidatorDropdownType.CASCADE:var O;y={type:`cascader`,props:{onChange:e=>{let n={unitId:d,subUnitId:f,range:{startColumn:u,endColumn:u,startRow:c,endRow:c},value:{v:e.join(`/`),p:null,f:null,si:null}};return this._commandService.syncExecuteCommand(r.SetRangeValuesCommand.id,n),this._editorBridgeService.isVisible().visible&&this._commandService.syncExecuteCommand(l.SetCellEditVisibleOperation.id,{visible:!1,eventType:s.DeviceInputEventType.Keyboard,unitId:d,keycode:t.KeyCode.ESC}),!0},defaultValue:(0,i.getDataValidationCellValue)(m.getCellRaw(c,u)).split(`/`),options:JSON.parse((O=h.formula1)==null?`[]`:O)},location:o};break;case a.DataValidatorDropdownType.COLOR:y={type:`color`,props:{onChange:e=>{let n={unitId:d,subUnitId:f,range:{startColumn:u,endColumn:u,startRow:c,endRow:c},value:{v:e,p:null,f:null,si:null}};return this._commandService.syncExecuteCommand(r.SetRangeValuesCommand.id,n),this._editorBridgeService.isVisible().visible&&this._commandService.syncExecuteCommand(l.SetCellEditVisibleOperation.id,{visible:!1,eventType:s.DeviceInputEventType.Keyboard,unitId:d,keycode:t.KeyCode.ESC}),!0},defaultValue:(0,i.getDataValidationCellValue)(m.getCellRaw(c,u))},location:o};break;default:throw Error(`[DataValidationDropdownManagerService]: unknown type!`)}if(_=this._cellDropdownManagerService.showDropdown({...y,onHide:()=>{this._activeDropdown=null,this._activeDropdown$.next(null)}}),!_)throw Error(`[DataValidationDropdownManagerService]: cannot show dropdown!`);let k=new n.DisposableCollection;k.add(_),k.add({dispose:()=>{var e,t;(e=this._activeDropdown)==null||(t=e.onHide)==null||t.call(e)}}),this._currentPopup=k}hideDropdown(){this._activeDropdown&&(this._currentPopup&&this._currentPopup.dispose(),this._currentPopup=null,this._activeDropdown=null,this._activeDropdown$.next(null))}showDataValidationDropdown(e,t,r,i,a){let o=this._univerInstanceService.getUnit(e,n.UniverInstanceType.UNIVER_SHEET);if(!o)return;let s=o.getSheetBySheetId(t);if(!s)return;let c=this._dataValidationModel.getRuleByLocation(o.getUnitId(),s.getSheetId(),r,i);if(!c)return;let l=this._dataValidatorRegistryService.getValidatorItem(c.type);if(!l||!l.dropdownType){this.hideDropdown();return}this.showDropdown({location:{workbook:o,worksheet:s,row:r,col:i,unitId:e,subUnitId:t},onHide:a})}};O=b([y(0,n.IUniverInstanceService),y(1,(0,n.Inject)(a.DataValidatorRegistryService)),y(2,(0,n.Inject)(i.SheetDataValidationModel)),y(3,(0,n.Inject)(r.SheetsSelectionsService)),y(4,(0,n.Inject)(l.ISheetCellDropdownManagerService)),y(5,(0,n.Inject)(i.SheetDataValidationModel)),y(6,n.ICommandService),y(7,l.IEditorBridgeService),y(8,(0,n.Inject)(n.Injector)),y(9,n.IConfigService)],O);let k=`DataValidationPanel`,A={id:`data-validation.operation.open-validation-panel`,type:n.CommandType.OPERATION,handler(e,i){if(!i)return!1;let{ruleId:o,isAdd:s}=i,c=e.get(x),l=e.get(a.DataValidationModel),u=e.get(n.IUniverInstanceService),d=e.get(t.ISidebarService),f=(0,r.getSheetCommandTarget)(u);if(!f)return!1;let{unitId:p,subUnitId:m}=f,h=o?l.getRuleById(p,m,o):void 0;c.open(),c.setActiveRule(h&&{unitId:p,subUnitId:m,rule:h});let g=d.open({id:k,header:{title:s?`sheets-data-validation-ui.panel.addTitle`:`sheets-data-validation-ui.panel.title`},children:{label:k},width:312,onClose:()=>c.close()});return c.setCloseDisposable(g),!0}},j={id:`data-validation.operation.close-validation-panel`,type:n.CommandType.OPERATION,handler(e){return e.get(x).close(),!0}},M={id:`data-validation.operation.toggle-validation-panel`,type:n.CommandType.OPERATION,handler(e){let t=e.get(n.ICommandService),r=e.get(x);return r.open(),r.isOpen?t.executeCommand(j.id):t.executeCommand(A.id),!0}},N={type:n.CommandType.OPERATION,id:`sheet.operation.show-data-validation-dropdown`,handler(e,t){if(!t)return!1;let n=e.get(O),{unitId:r,subUnitId:i,row:a,column:o}=t,s=n.activeDropdown,c=s==null?void 0:s.location;return c&&c.unitId===r&&c.subUnitId===i&&c.row===a&&c.col===o||n.showDataValidationDropdown(r,i,a,o),!0}},P={type:n.CommandType.OPERATION,id:`sheet.operation.hide-data-validation-dropdown`,handler(e,t){return t?(e.get(O).hideDropdown(),!0):!1}};function F(e,t){let n=(0,i.createDefaultNewRule)(e);return{...n,...t,uid:n.uid,ranges:n.ranges}}let I={type:n.CommandType.COMMAND,id:`data-validation.command.insert-quick-rule`,handler(e,t){let a=(0,r.getSheetCommandTarget)(e.get(n.IUniverInstanceService)),o=e.get(r.SheetsSelectionsService).getCurrentSelections().map(e=>e.range);if(!a||!o.length||!(t!=null&&t.rule))return!1;let s=F(e,t.rule);return e.get(n.ICommandService).syncExecuteCommand(i.AddSheetDataValidationCommand.id,{unitId:a.workbook.getUnitId(),subUnitId:a.worksheet.getSheetId(),rule:s})}},L={type:n.CommandType.COMMAND,id:`data-validation.command.clear-quick-rule`,handler(e,t){var a;let o=(0,r.getSheetCommandTarget)(e.get(n.IUniverInstanceService)),s=e.get(r.SheetsSelectionsService).getCurrentSelections().map(e=>e.range);return!o||!s.length||!(!(t==null||(a=t.types)==null)&&a.length)?!1:e.get(n.ICommandService).syncExecuteCommand(i.ClearRangeDataValidationCommand.id,{unitId:o.workbook.getUnitId(),subUnitId:o.worksheet.getSheetId(),ranges:s,types:t.types})}},R={type:n.CommandType.COMMAND,id:`data-validation.command.addRuleAndOpen`,handler(e,t){let a=(0,r.getSheetCommandTarget)(e.get(n.IUniverInstanceService));if(!a)return!1;let{workbook:o,worksheet:s}=a;if(!e.get(r.SheetsSelectionsService).getCurrentSelections().length)return!1;let c=F(e,t==null?void 0:t.rule),l=e.get(n.ICommandService),u={rule:c,unitId:o.getUnitId(),subUnitId:s.getSheetId()};return l.syncExecuteCommand(i.AddSheetDataValidationCommand.id,u)?(l.syncExecuteCommand(A.id,{ruleId:c.uid,isAdd:!0}),!0):!1}},z=`SHEETS_DATA_VALIDATION_DROPDOWN_PRESETS`;function B({onChange:e}){let i=(0,t.useDependency)(n.LocaleService),a=[[i.t(`sheets-data-validation-ui.ribbon.presets.yes`),i.t(`sheets-data-validation-ui.ribbon.presets.no`)],[i.t(`sheets-data-validation-ui.ribbon.presets.notStarted`),i.t(`sheets-data-validation-ui.ribbon.presets.inProgress`),i.t(`sheets-data-validation-ui.ribbon.presets.completed`)],[`A`,`B`,`C`]];return(0,f.jsxs)(`div`,{className:`univer-box-border univer-w-[360px]`,children:[(0,f.jsx)(`div`,{className:`univer-px-2 univer-text-sm univer-font-semibold`,children:i.t(`sheets-data-validation-ui.ribbon.dropdownPresetTitle`)}),(0,f.jsx)(`div`,{className:`univer-mt-2 univer-grid univer-grid-cols-3 univer-gap-1.5`,children:a.map(t=>(0,f.jsx)(`button`,{type:`button`,"aria-label":t.join(` / `),className:`univer-flex univer-min-h-20 univer-cursor-pointer univer-flex-col univer-items-start univer-gap-1.5 univer-rounded-md univer-border-0 univer-bg-gray-50 univer-p-3 univer-text-left univer-text-sm univer-leading-5 univer-text-gray-900 univer-transition-colors hover:univer-bg-gray-100 focus-visible:univer-outline-none focus-visible:univer-ring-2 focus-visible:univer-ring-primary-600 focus-visible:univer-ring-offset-0 dark:!univer-bg-gray-800 dark:!univer-text-white dark:hover:!univer-bg-gray-700`,onClick:()=>e((0,r.serializeListOptions)(t)),children:t.map(e=>(0,f.jsx)(`span`,{className:`univer-w-full univer-break-words`,children:e},e))},t.join(`\0`)))}),(0,f.jsx)(u.Separator,{className:`univer-mt-2`})]})}let ee=`sheet.menu.data-validation`,V=`sheet.menu.quick-dropdown`,H=`sheet.menu.quick-date`,U={type:n.DataValidationType.CHECKBOX,operator:void 0,formula1:void 0,formula2:void 0},W={type:n.DataValidationType.DATE,operator:void 0,formula1:void 0,formula2:void 0},te={...W,bizInfo:{showTime:!0}};function G(e){return{type:n.DataValidationType.LIST,operator:void 0,formula1:e,formula2:``,renderMode:n.DataValidationRenderMode.CUSTOM}}function ne(e){return e===void 0?{}:{rule:G(String(e))}}function re(e){return{hidden$:(0,t.getMenuHiddenObservable)(e,n.UniverInstanceType.UNIVER_SHEET),disabled$:(0,l.getCurrentRangeDisable$)(e,{workbookTypes:[r.WorkbookEditablePermission],worksheetTypes:[r.WorksheetSetCellStylePermission,r.WorksheetEditPermission],rangeTypes:[r.RangeProtectionPermissionEditPoint]})}}function ie(e){return{id:ee,type:t.MenuItemType.SUBITEMS,icon:`DataValidationIcon`,tooltip:`sheets-data-validation-ui.title`,hidden$:(0,t.getMenuHiddenObservable)(e,n.UniverInstanceType.UNIVER_SHEET),disabled$:(0,l.getCurrentRangeDisable$)(e,{workbookTypes:[r.WorkbookEditablePermission],worksheetTypes:[r.WorksheetSetCellStylePermission,r.WorksheetEditPermission],rangeTypes:[r.RangeProtectionPermissionEditPoint]})}}function ae(e){return{id:I.id,type:t.MenuItemType.BUTTON_SELECTOR,icon:`CheckboxIcon`,tooltip:`sheets-data-validation-ui.checkbox.title`,params:{rule:U},selectionsCommandId:I.id,selections:[{label:`sheets-data-validation-ui.ribbon.setCheckbox`,value:n.DataValidationType.CHECKBOX,params:{rule:U}},{label:`sheets-data-validation-ui.ribbon.clearCheckbox`,id:L.id,value:n.DataValidationType.CHECKBOX,params:{types:[n.DataValidationType.CHECKBOX]}}],...re(e)}}function K(e){let i=e.get(n.LocaleService),a=(0,r.serializeListOptions)([i.t(`sheets-data-validation-ui.ribbon.presets.option1`),i.t(`sheets-data-validation-ui.ribbon.presets.option2`)]);return{id:V,type:t.MenuItemType.SUBITEMS,icon:`DropdownListIcon`,tooltip:`sheets-data-validation-ui.list.title`,selectionsCommandId:I.id,selections:[{label:{name:z,hoverable:!1,selectable:!1},params:ne},{id:R.id,label:`sheets-data-validation-ui.ribbon.editDropdown`,value:a,params:{rule:G(a)}},{id:L.id,label:`sheets-data-validation-ui.ribbon.clearDropdown`,value:n.DataValidationType.LIST,params:{types:[n.DataValidationType.LIST,n.DataValidationType.LIST_MULTIPLE]}}],...re(e)}}function oe(e){return{id:H,commandId:I.id,type:t.MenuItemType.BUTTON_SELECTOR,icon:`DatePickerIcon`,tooltip:`sheets-data-validation-ui.date.title`,params:{rule:W},selectionsCommandId:I.id,selections:[{label:`sheets-data-validation-ui.date.title`,value:n.DataValidationType.DATE,params:{rule:W}},{label:`sheets-data-validation-ui.ribbon.dateTime`,value:n.DataValidationType.DATE,params:{rule:te}},{id:R.id,label:`sheets-data-validation-ui.list.edit`,value:n.DataValidationType.DATE,params:{rule:W}},{id:L.id,label:`sheets-data-validation-ui.panel.removeRule`,value:n.DataValidationType.DATE,params:{types:[n.DataValidationType.DATE]}}],...re(e)}}function se(){return{id:A.id,title:`sheets-data-validation-ui.panel.title`,type:t.MenuItemType.BUTTON}}function ce(){return{id:R.id,title:`sheets-data-validation-ui.panel.add`,type:t.MenuItemType.BUTTON}}let le={[t.RibbonInsertGroup.CELL]:{[I.id]:{order:0,menuItemFactory:ae},[V]:{order:1,menuItemFactory:K},[H]:{order:2,menuItemFactory:oe}},[t.RibbonDataGroup.RULES]:{[ee]:{order:0,menuItemFactory:ie,[A.id]:{order:0,menuItemFactory:se},[R.id]:{order:1,menuItemFactory:ce}}}};var ue=`@univerjs/sheets-data-validation-ui`,de=`1.0.0-alpha.5`;function q({ref:e,...t}){let{icon:n,id:r,className:i,extend:a,...o}=t,s=`univerjs-icon univerjs-icon-${r} ${i||``}`.trim(),c=(0,d.useRef)(`_${he()}`);return fe(n,`${r}`,{defIds:n.defIds,idSuffix:c.current},{ref:e,className:s,...o},a)}function fe(e,t,n,r,i){return(0,d.createElement)(e.tag,{key:t,...pe(e,n,i),...r},(me(e,n).children||[]).map((r,a)=>fe(r,`${t}-${e.tag}-${a}`,n,void 0,i)))}function pe(e,t,n){let r={...e.attrs};n!=null&&n.colorChannel1&&r.fill===`colorChannel1`&&(r.fill=n.colorChannel1),n!=null&&n.colorChannel1&&r.stroke===`colorChannel1`&&(r.stroke=n.colorChannel1),e.tag===`mask`&&r.id&&(r.id+=t.idSuffix),Object.entries(r).forEach(([e,n])=>{e===`mask`&&typeof n==`string`&&(r[e]=n.replace(/url\(#(.*)\)/,`url(#$1${t.idSuffix})`))});let{defIds:i}=t;return!i||i.length===0?r:(e.tag===`use`&&r[`xlink:href`]&&(r[`xlink:href`]+=t.idSuffix),Object.entries(r).forEach(([e,n])=>{typeof n==`string`&&(r[e]=n.replace(/url\(#(.*)\)/,`url(#$1${t.idSuffix})`))}),r)}function me(e,t){var n;let{defIds:r}=t;return!r||r.length===0?e:e.tag===`defs`&&(n=e.children)!=null&&n.length?{...e,children:e.children.map(e=>typeof e.attrs.id==`string`&&r&&r.includes(e.attrs.id)?{...e,attrs:{...e.attrs,id:e.attrs.id+t.idSuffix}}:e)}:e}function he(){return Math.random().toString(36).substring(2,8)}q.displayName=`UniverIcon`;let ge={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`rect`,attrs:{width:13,height:13,x:1.5,y:1.5,stroke:`currentColor`,rx:1.5,strokeWidth:1.2}},{tag:`path`,attrs:{stroke:`currentColor`,d:`M4.5 8L6.8 10.3L11.5 5.6`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:1.2}}]},_e=(0,d.forwardRef)(function(e,t){return(0,d.createElement)(q,Object.assign({},e,{id:`checkbox-icon`,ref:t,icon:ge}))});_e.displayName=`CheckboxIcon`;let ve={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`}}]},ye=(0,d.forwardRef)(function(e,t){return(0,d.createElement)(q,Object.assign({},e,{id:`data-validation-icon`,ref:t,icon:ve}))});ye.displayName=`DataValidationIcon`;let be={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`rect`,attrs:{width:13,height:12,x:1.5,y:2.5,stroke:`currentColor`,rx:1.5,strokeWidth:1.2}},{tag:`path`,attrs:{stroke:`currentColor`,d:`M1.5 6.5H14.5M5 1.5V4M11 1.5V4`,strokeLinecap:`round`,strokeWidth:1.2}},{tag:`path`,attrs:{stroke:`currentColor`,d:`M4.5 9H6M8 9H9.5M11.5 9H12M4.5 12H6M8 12H9.5`,strokeLinecap:`round`,strokeWidth:1.2}}]},xe=(0,d.forwardRef)(function(e,t){return(0,d.createElement)(q,Object.assign({},e,{id:`date-picker-icon`,ref:t,icon:be}))});xe.displayName=`DatePickerIcon`;let Se={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`}}]},Ce=(0,d.forwardRef)(function(e,t){return(0,d.createElement)(q,Object.assign({},e,{id:`delete-icon`,ref:t,icon:Se}))});Ce.displayName=`DeleteIcon`;let we={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:{stroke:`currentColor`,d:`M8 5.5H2C1.72386 5.5 1.5 5.27614 1.5 5V2C1.5 1.72386 1.72386 1.5 2 1.5H14C14.2761 1.5 14.5 1.72386 14.5 2V5C14.5 5.27614 14.2761 5.5 14 5.5H13`,strokeLinejoin:`round`,strokeWidth:1.2}},{tag:`path`,attrs:{stroke:`currentColor`,d:`M8.5 3.5L10.5 5.5L12.5 3.5`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:1.2}},{tag:`path`,attrs:{stroke:`currentColor`,d:`M2 7.5H14C14.2761 7.5 14.5 7.72386 14.5 8V14C14.5 14.2761 14.2761 14.5 14 14.5H2C1.72386 14.5 1.5 14.2761 1.5 14V8C1.5 7.72386 1.72386 7.5 2 7.5Z`,strokeLinejoin:`round`,strokeWidth:1.2}},{tag:`path`,attrs:{stroke:`currentColor`,d:`M3.5 9.5H9.5M3.5 12.5H7.5`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:1.2}}]},Te=(0,d.forwardRef)(function(e,t){return(0,d.createElement)(q,Object.assign({},e,{id:`dropdown-list-icon`,ref:t,icon:we}))});Te.displayName=`DropdownListIcon`;let Ee={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 20 20`,width:`1em`,height:`1em`},children:[{tag:`circle`,attrs:{cx:7,cy:5,r:1.1,fill:`currentColor`}},{tag:`circle`,attrs:{cx:13,cy:5,r:1.1,fill:`currentColor`}},{tag:`circle`,attrs:{cx:7,cy:10,r:1.1,fill:`currentColor`}},{tag:`circle`,attrs:{cx:13,cy:10,r:1.1,fill:`currentColor`}},{tag:`circle`,attrs:{cx:7,cy:15,r:1.1,fill:`currentColor`}},{tag:`circle`,attrs:{cx:13,cy:15,r:1.1,fill:`currentColor`}}]},De=(0,d.forwardRef)(function(e,t){return(0,d.createElement)(q,Object.assign({},e,{id:`grip-vertical-icon`,ref:t,icon:Ee}))});De.displayName=`GripVerticalIcon`;let Oe={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`}}]},ke=(0,d.forwardRef)(function(e,t){return(0,d.createElement)(q,Object.assign({},e,{id:`increase-icon`,ref:t,icon:Oe}))});ke.displayName=`IncreaseIcon`;let Ae={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`}}]},je=(0,d.forwardRef)(function(e,t){return(0,d.createElement)(q,Object.assign({},e,{id:`more-down-icon`,ref:t,icon:Ae}))});je.displayName=`MoreDownIcon`;let Me={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`}}]},Ne=(0,d.forwardRef)(function(e,t){return(0,d.createElement)(q,Object.assign({},e,{id:`more-up-icon`,ref:t,icon:Me}))});Ne.displayName=`MoreUpIcon`;function Pe(e){var r;let i=(0,t.useDependency)(n.LocaleService),a=(0,t.useDependency)(t.ComponentManager),{value:o,onChange:s,extraComponent:c}=e,[l,p]=(0,d.useState)(!1),m=c?a.get(c):null;return(0,f.jsxs)(f.Fragment,{children:[(0,f.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:()=>p(!l),children:[i.t(`sheets-data-validation-ui.panel.options`),l?(0,f.jsx)(Ne,{className:`univer-ml-1`}):(0,f.jsx)(je,{className:`univer-ml-1`})]}),l&&(0,f.jsxs)(f.Fragment,{children:[m?(0,f.jsx)(m,{value:o,onChange:s}):null,(0,f.jsx)(u.FormLayout,{label:i.t(`sheets-data-validation-ui.panel.invalid`),children:(0,f.jsxs)(u.RadioGroup,{value:`${(r=o.errorStyle)==null?n.DataValidationErrorStyle.WARNING:r}`,onChange:e=>s({...o,errorStyle:+e}),children:[(0,f.jsx)(u.Radio,{value:`${n.DataValidationErrorStyle.WARNING}`,children:i.t(`sheets-data-validation-ui.panel.showWarning`)}),(0,f.jsx)(u.Radio,{value:`${n.DataValidationErrorStyle.STOP}`,children:i.t(`sheets-data-validation-ui.panel.rejectInput`)})]})}),(0,f.jsx)(u.FormLayout,{label:i.t(`sheets-data-validation-ui.panel.messageInfo`),children:(0,f.jsx)(u.Checkbox,{checked:o.showErrorMessage,onChange:()=>s({...o,showErrorMessage:!o.showErrorMessage}),children:i.t(`sheets-data-validation-ui.panel.showInfo`)})}),o.showErrorMessage?(0,f.jsx)(u.FormLayout,{children:(0,f.jsx)(u.Input,{value:o.error,onChange:e=>s({...o,error:e})})}):null]})]})}let Fe=e=>(0,n.debounce)(async(t,n,r,i)=>{let a=await e.executeCommand(t,n,r);i==null||i(a)},1e3);function Ie(e,t,r){var i;if(t){var a;return((a=e.getUnit(t))==null||(a=a.getSheetBySheetName(r))==null?void 0:a.getSheetId())||``}return((i=e.getCurrentUnitOfType(n.UniverInstanceType.UNIVER_SHEET))==null||(i=i.getSheetBySheetName(r))==null?void 0:i.getSheetId())||``}function Le(){let e=(0,t.useDependency)(x),{unitId:n,subUnitId:r,rule:i}=(0,t.useObservable)(e.activeRule$,e.activeRule)||{};return!n||!r||!i?null:(0,f.jsx)(Re,{activeRuleInfo:{unitId:n,subUnitId:r,rule:i}})}function Re(e){var s,c;let[l,h]=(0,d.useState)(0),g=(0,t.useDependency)(x),{unitId:_,subUnitId:v,rule:y}=e.activeRuleInfo,b=y.uid,S=(0,t.useDependency)(a.DataValidatorRegistryService),C=(0,t.useDependency)(n.IUniverInstanceService),w=(0,t.useDependency)(t.ComponentManager),T=(0,t.useDependency)(n.ICommandService),E=(0,t.useDependency)(a.DataValidationModel),D=(0,t.useDependency)(n.LocaleService),O=(0,t.useObservable)(()=>C.getCurrentTypeOfUnit$(n.UniverInstanceType.UNIVER_SHEET),void 0,void 0,[]),k=(0,t.useObservable)(()=>{var e;return(e=O==null?void 0:O.activeSheet$)==null?(0,o.of)(null):e},void 0,void 0,[]),[A,j]=(0,d.useState)(y),M=S.getValidatorItem(A.type),[N,P]=(0,d.useState)(!1),F=S.getValidatorsByScope(a.DataValidatorRegistryScope.SHEET),[I,L]=(0,d.useState)(()=>A.ranges.map(e=>({unitId:``,sheetId:``,range:e}))),R=(0,d.useMemo)(()=>Fe(T),[T]),[z,B]=(0,d.useState)(!1),[ee,V]=(0,d.useState)(!1),H=(0,d.useRef)(null),U=(0,t.useDependency)(r.SheetsSelectionsService);(0,d.useEffect)(()=>()=>{let e=U.getCurrentLastSelection();e&&U.setSelections([e])},[U]),(0,d.useEffect)(()=>{let e,t=T.onCommandExecuted(t=>{(t.id===n.UndoCommand.id||t.id===n.RedoCommand.id)&&(e!==void 0&&clearTimeout(e),e=setTimeout(()=>{let e=E.getRuleById(_,v,b);h(e=>e+1),e&&(j(e),L(e.ranges.map(e=>({unitId:``,sheetId:``,range:e}))))},20))});return()=>{t.dispose(),e!==void 0&&clearTimeout(e)}},[T,E,b,v,_]);let W=(0,t.useEvent)(e=>{let t=e.split(`,`).filter(Boolean).map(p.deserializeRangeWithSheet).map(e=>{let t=e.sheetName;if(t){let n=Ie(C,e.unitId,t);return{...e,sheetId:n}}return{...e,sheetId:``}});if((0,n.isUnitRangesEqual)(t,I))return;L(t);let r=t.filter(e=>(!e.unitId||e.unitId===_)&&(!e.sheetId||e.sheetId===v)).map(e=>e.range);if(j({...A,ranges:r}),r.length===0)return;let a={unitId:_,subUnitId:v,ruleId:b,ranges:r};R(i.UpdateSheetDataValidationRangeCommand.id,a)}),te=(0,d.useMemo)(()=>I.map(e=>(0,p.serializeRange)(e.range)).join(`,`),[]);if(!M)return null;let G=M.operators,ne=M.operatorNames,re=A.operator?a.TWO_FORMULA_OPERATOR_COUNT.includes(A.operator):!1,ie=()=>{(k==null?void 0:k.getSheetId())!==v&&T.syncExecuteCommand(r.SetWorksheetActiveOperation.id,{unitId:_,subUnitId:v})},ae=()=>{var e;if(!((e=H.current)==null||(e=e.editor)==null)&&e.isFocus()){var t;W((t=H.current)==null?void 0:t.getValue())}!A.ranges.length||z||(M.validatorFormula(A,_,v).success?g.setActiveRule(null):P(!0),ie())},K=e=>{if((0,n.shallowEqual)(e,(0,a.getRuleSetting)(A)))return;j({...A,...e});let t={unitId:_,subUnitId:v,ruleId:b,setting:e};R(i.UpdateSheetDataValidationSettingCommand.id,t,void 0)},oe=async()=>{await T.executeCommand(i.RemoveSheetDataValidationCommand.id,{ruleId:b,unitId:_,subUnitId:v}),g.setActiveRule(null),ie()},se={type:A.type,operator:A.operator,formula1:A.formula1,formula2:A.formula2,allowBlank:A.allowBlank},ce=e=>{let t=S.getValidatorItem(e);if(!t)return;let n=t.operators,r=E.getRuleById(_,v,b),o=e===(r==null?void 0:r.type)||e.includes(`list`)&&r!=null&&r.type.includes(`list`)?{...r,type:e}:{...A,type:e,operator:n[0],formula1:void 0,formula2:void 0};j(o),T.executeCommand(i.UpdateSheetDataValidationSettingCommand.id,{unitId:_,subUnitId:v,ruleId:A.uid,setting:(0,a.getRuleSetting)(o)})},le=w.get(M.formulaInput),ue=(0,a.getRuleOptions)(A),de=e=>{(0,n.shallowEqual)(e,(0,a.getRuleOptions)(A))||(j({...A,...e}),R(i.UpdateSheetDataValidationOptionsCommand.id,{unitId:_,subUnitId:v,ruleId:b,options:e}))},q=G.length&&!A.operator;return(0,f.jsxs)(`div`,{"data-u-comp":`data-validation-detail`,className:`univer-py-2`,children:[(0,f.jsx)(u.FormLayout,{label:D.t(`sheets-data-validation-ui.panel.range`),error:!A.ranges.length||z?D.t(`sheets-data-validation-ui.panel.rangeError`):``,children:(0,f.jsx)(m.RangeSelector,{selectorRef:H,unitId:_,subUnitId:v,initialValue:te,onChange:(e,t)=>{var n;!ee&&(n=H.current)!=null&&n.verify()&&W(t)},onFocusChange:(e,t)=>{var n;V(e),!e&&t&&(n=H.current)!=null&&n.verify()&&W(t)},onVerify:e=>B(!e)})}),(0,f.jsx)(u.FormLayout,{label:D.t(`sheets-data-validation-ui.panel.type`),children:(0,f.jsx)(u.Select,{className:`univer-w-full`,value:A.type,options:F==null||(s=F.sort((e,t)=>e.order-t.order))==null?void 0:s.map(e=>({label:D.t(e.title),value:e.id})),onChange:ce})}),G!=null&&G.length?(0,f.jsx)(u.FormLayout,{label:D.t(`sheets-data-validation-ui.panel.operator`),children:(0,f.jsx)(u.Select,{className:`univer-w-full`,value:`${A.operator}`,options:[{value:``,label:D.t(`sheets-data-validation-ui.operators.legal`)},...G.map((e,t)=>({value:`${e}`,label:ne[t]}))],onChange:e=>{K({...se,operator:e})}})}):null,le&&!q?(0,f.jsx)(le,{isTwoFormula:re,value:{formula1:A.formula1,formula2:A.formula2},onChange:e=>{K({...se,...e})},showError:N,validResult:M.validatorFormula(A,_,v),unitId:_,subUnitId:v,ruleId:b},l+A.type):null,(0,f.jsx)(u.FormLayout,{children:(0,f.jsx)(u.Checkbox,{checked:(c=A.allowBlank)==null?!0:c,onChange:()=>{var e;return K({...se,allowBlank:!((e=A.allowBlank)==null||e)})},children:D.t(`sheets-data-validation-ui.panel.allowBlank`)})}),(0,f.jsx)(Pe,{value:ue,onChange:de,extraComponent:M.optionsInput}),(0,f.jsxs)(`div`,{className:`univer-mt-5 univer-flex univer-flex-row univer-justify-end`,children:[(0,f.jsx)(u.Button,{className:`univer-ml-3`,onClick:oe,children:D.t(`sheets-data-validation-ui.panel.removeRule`)}),(0,f.jsx)(u.Button,{className:`univer-ml-3`,variant:`primary`,onClick:ae,children:D.t(`sheets-data-validation-ui.panel.done`)})]})]})}let ze=e=>{let{rule:r,onClick:o,unitId:s,subUnitId:c,disable:m}=e,h=(0,t.useDependency)(a.DataValidatorRegistryService),g=(0,t.useDependency)(n.ICommandService),_=(0,t.useDependency)(l.IMarkSelectionService),v=h.getValidatorItem(r.type),y=(0,d.useRef)(void 0),[b,x]=(0,d.useState)(!1),S=(0,t.useDependency)(n.ThemeService),C=(0,d.useMemo)(()=>{var e;let t=S.getColorFromTheme(`primary.600`),r=S.getColorFromTheme(`loop-color.2`),i=(e=S.getColorFromTheme(r))==null?t:e,a=new n.ColorKit(i).toRgb();return{fill:`rgba(${a.r}, ${a.g}, ${a.b}, 0.1)`,stroke:i}},[(0,t.useObservable)(S.currentTheme$)]);return(0,d.useEffect)(()=>()=>{if(y.current){var e;(e=y.current)==null||e.forEach(e=>{e&&_.removeShape(e)})}},[_]),(0,f.jsxs)(`div`,{className:(0,u.clsx)(`univer-bg-secondary univer-relative univer--mx-2 univer-box-border univer-flex univer-w-[287px] univer-cursor-pointer univer-flex-col univer-justify-between univer-overflow-hidden univer-rounded-md univer-p-2 univer-pr-9`,{"hover:univer-bg-gray-50 dark:hover:!univer-bg-gray-700":!m,"univer-opacity-50":m}),onClick:o,onMouseEnter:()=>{m||(x(!0),y.current=r.ranges.map(e=>_.addShape({range:e,style:C,primary:null})))},onMouseLeave:()=>{var e;x(!1),(e=y.current)==null||e.forEach(e=>{e&&_.removeShape(e)}),y.current=void 0},children:[(0,f.jsx)(`div`,{className:`univer-truncate univer-text-sm univer-font-medium univer-leading-[22px] univer-text-gray-900 dark:!univer-text-white`,children:v==null?void 0:v.generateRuleName(r)}),(0,f.jsx)(`div`,{className:`univer-text-secondary univer-truncate univer-text-xs univer-leading-[18px] dark:!univer-text-gray-300`,children:r.ranges.map(e=>(0,p.serializeRange)(e)).join(`,`)}),b&&(0,f.jsx)(`div`,{className:`univer-absolute univer-right-2 univer-top-[19px] univer-flex univer-size-5 univer-items-center univer-justify-center univer-rounded hover:univer-bg-gray-200 dark:!univer-text-gray-300 dark:hover:!univer-bg-gray-700`,onClick:e=>{g.executeCommand(i.RemoveSheetDataValidationCommand.id,{ruleId:r.uid,unitId:s,subUnitId:c}),e.stopPropagation()},children:(0,f.jsx)(Ce,{})})]})};function Be(e){let a=(0,t.useDependency)(i.SheetDataValidationModel),s=(0,t.useDependency)(n.IUniverInstanceService),c=(0,t.useDependency)(n.ICommandService),l=(0,t.useDependency)(n.Injector),d=(0,t.useDependency)(x),p=(0,t.useDependency)(n.LocaleService),{workbook:m}=e,h=(0,t.useObservable)(m.activeSheet$,void 0,!0),g=m.getUnitId(),_=h==null?void 0:h.getSheetId(),v=(0,t.useObservable)(()=>a.ruleChange$.pipe((0,o.filter)(e=>e.unitId===g&&e.subUnitId===_),(0,o.map)(()=>a.getRules(g,_)),(0,o.startWith)(a.getRules(g,_))),[],!1,[a,_,g]),y=async()=>{let e=(0,i.createDefaultNewRule)(l),t={unitId:g,subUnitId:_,rule:e};await c.executeCommand(i.AddSheetDataValidationCommand.id,t),d.setActiveRule({unitId:g,subUnitId:_,rule:e})},b=()=>{c.executeCommand(i.RemoveSheetAllDataValidationCommand.id,{unitId:g,subUnitId:_})},S=(e=>{let t=s.getCurrentUnitOfType(n.UniverInstanceType.UNIVER_SHEET),i=t.getActiveSheet(),a=t.getUnitId(),o=i.getSheetId();return e.map(e=>(0,r.checkRangesEditablePermission)(l,a,o,e.ranges)?{...e}:{...e,disable:!0})})(v),C=S==null?void 0:S.some(e=>e.disable);return(0,f.jsxs)(`div`,{className:`univer-pb-4`,children:[S==null?void 0:S.map(e=>{var t;return(0,f.jsx)(ze,{unitId:g,subUnitId:_,onClick:()=>{e.disable||d.setActiveRule({unitId:g,subUnitId:_,rule:e})},rule:e,disable:(t=e.disable)==null?!1:t},e.uid)}),(0,f.jsxs)(`div`,{className:`univer-mt-4 univer-flex univer-flex-row univer-justify-end univer-gap-2`,children:[v.length&&!C?(0,f.jsx)(u.Button,{onClick:b,children:p.t(`sheets-data-validation-ui.panel.removeAll`)}):null,(0,f.jsx)(u.Button,{variant:`primary`,onClick:y,children:p.t(`sheets-data-validation-ui.panel.add`)})]})]})}let Ve=()=>{let e=(0,t.useDependency)(x),r=(0,t.useObservable)(e.activeRule$,e.activeRule),i=(0,t.useDependency)(n.IUniverInstanceService),a=(0,t.useObservable)(()=>i.getCurrentTypeOfUnit$(n.UniverInstanceType.UNIVER_SHEET),void 0,void 0,[]),s=(0,t.useObservable)(()=>{var e;return(e=a==null?void 0:a.activeSheet$)==null?(0,o.of)(null):e},void 0,void 0,[]);return!a||!s?null:r&&(r.subUnitId===s.getSheetId()||r.subUnitId===e.getFocusFormulaEditorActiveRuleSubUnitId())?(0,f.jsx)(Le,{},r.rule.uid):(0,f.jsx)(Be,{workbook:a})};function He(e){var r;let{value:i,onChange:a}=e,o=(0,t.useDependency)(n.LocaleService);return(0,f.jsx)(u.FormLayout,{children:(0,f.jsx)(u.Checkbox,{checked:(r=i.bizInfo)==null?void 0:r.showTime,onChange:e=>{a({...i,bizInfo:{...i.bizInfo,showTime:e}})},children:o.t(`sheets-data-validation-ui.showTime.label`)})})}He.componentKey=`DATE_SHOW_TIME_OPTION`;let Ue=e=>{let{isTwoFormula:r=!1,value:i,onChange:a,showError:o,validResult:s}=e,c=(0,t.useDependency)(n.LocaleService),l=o?s==null?void 0:s.formula1:``,d=o?s==null?void 0:s.formula2:``;return r?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(u.FormLayout,{error:l,children:(0,f.jsx)(u.Input,{className:`univer-w-full`,placeholder:c.t(`sheets-data-validation-ui.panel.formulaPlaceholder`),value:i==null?void 0:i.formula1,onChange:e=>{a==null||a({...i,formula1:e})}})}),(0,f.jsx)(`div`,{className:`-univer-mt-2 univer-mb-1 univer-text-sm univer-text-gray-400`,children:c.t(`sheets-data-validation-ui.panel.formulaAnd`)}),(0,f.jsx)(u.FormLayout,{error:d,children:(0,f.jsx)(u.Input,{className:`univer-w-full`,placeholder:c.t(`sheets-data-validation-ui.panel.formulaPlaceholder`),value:i==null?void 0:i.formula2,onChange:e=>{a==null||a({...i,formula2:e})}})})]}):(0,f.jsx)(u.FormLayout,{error:l,children:(0,f.jsx)(u.Input,{className:`univer-w-full`,placeholder:c.t(`sheets-data-validation-ui.panel.formulaPlaceholder`),value:i==null?void 0:i.formula1,onChange:e=>{a==null||a({formula1:e})}})})};function We(e){let{value:r,onChange:i,showError:a,validResult:o}=e,s=(0,t.useDependency)(n.LocaleService),c=a?o==null?void 0:o.formula1:``,l=a?o==null?void 0:o.formula2:``,[p,m]=(0,d.useState)(!((r==null?void 0:r.formula1)===void 0&&(r==null?void 0:r.formula2)===void 0));return(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(u.FormLayout,{children:(0,f.jsx)(u.Checkbox,{checked:p,onChange:e=>{e?m(!0):(m(!1),i==null||i({...r,formula1:void 0,formula2:void 0}))},children:s.t(`sheets-data-validation-ui.checkbox.tips`)})}),p?(0,f.jsx)(u.FormLayout,{label:s.t(`sheets-data-validation-ui.checkbox.checked`),error:c,children:(0,f.jsx)(u.Input,{className:`univer-w-full`,placeholder:s.t(`sheets-data-validation-ui.panel.valuePlaceholder`),value:r==null?void 0:r.formula1,onChange:e=>{i==null||i({...r,formula1:e||void 0})}})}):null,p?(0,f.jsx)(u.FormLayout,{label:s.t(`sheets-data-validation-ui.checkbox.unchecked`),error:l,children:(0,f.jsx)(u.Input,{className:`univer-w-full`,placeholder:s.t(`sheets-data-validation-ui.panel.valuePlaceholder`),value:r==null?void 0:r.formula2,onChange:e=>{i==null||i({...r,formula2:e||void 0})}})}):null]})}function Ge(e){var n;let{unitId:r,subUnitId:i,value:a,onChange:o,showError:s,validResult:c}=e,l=s?c==null?void 0:c.formula1:void 0,p=(0,d.useRef)(null),[h,g]=(0,d.useState)(!1);return(0,t.useSidebarClick)(e=>{var t;(t=p.current)!=null&&t.isClickOutSide(e)&&g(!1)}),(0,f.jsx)(u.FormLayout,{error:l,children:(0,f.jsx)(m.FormulaEditor,{ref:p,className:(0,u.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`,u.borderClassName),initValue:(n=a==null?void 0:a.formula1)==null?`=`:n,unitId:r,subUnitId:i,isFocus:h,isSupportAcrossSheet:!0,onChange:e=>{let t=(e==null?``:e).trim();t!==(a==null?void 0:a.formula1)&&(o==null||o({...a,formula1:t}))},onFocus:()=>g(!0)})})}function Ke(e,t){let n=new Set,i=[];return e.forEach(e=>{!e.label||n.has(e.label)||(n.add(e.label),i.push(e))}),{formula1:(0,r.serializeListOptions)(i.map(e=>e.label)),formula2:i.map(e=>e.color===t?``:e.color).join(`,`)}}let qe=[`#FFFFFF`,`#FEE7E7`,`#FEF0E6`,`#EFFBD0`,`#E4F4FE`,`#E8ECFD`,`#F1EAFA`,`#FDE8F3`,`#E5E5E5`,`#FDCECE`,`#FDC49B`,`#DEF6A2`,`#9FDAFF`,`#D0D9FB`,`#E3D5F6`,`#FBD0E8`,`#656565`,`#FE4B4B`,`#FF8C51`,`#8BBB11`,`#0B9EFB`,`#3A60F7`,`#9E6DE3`,`#F248A6`],Je=e=>{let{value:t,onChange:n,disabled:r}=e,[i,a]=(0,d.useState)(!1);return(0,f.jsx)(u.Dropdown,{align:`start`,disabled:r,open:i,onOpenChange:a,overlay:(0,f.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:qe.map(e=>(0,f.jsx)(`div`,{className:(0,u.clsx)(`univer-box-border univer-size-4 univer-cursor-pointer univer-rounded`,u.borderClassName),style:{background:e},onClick:()=>{n(e),a(!1)}},e))}),children:(0,f.jsxs)(`div`,{className:(0,u.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`,u.borderClassName),children:[(0,f.jsx)(`div`,{className:`univer-box-border univer-size-4 univer-rounded univer-text-base`,style:{background:t}}),(0,f.jsx)(je,{})]})})},Ye=e=>{let{item:t,commonProps:n,className:r}=e,{onItemChange:i,onItemDelete:a}=n;return(0,f.jsxs)(`div`,{className:(0,u.clsx)(`univer-flex univer-items-center univer-gap-2`,r),children:[!t.isRef&&(0,f.jsx)(`div`,{className:(0,u.clsx)(`univer-cursor-move`,`draggableHandle`),children:(0,f.jsx)(De,{})}),(0,f.jsx)(Je,{value:t.color,onChange:e=>{i(t.id,t.label,e)}}),(0,f.jsx)(u.Input,{disabled:t.isRef,value:t.label,onChange:e=>{i(t.id,e,t.color)}}),t.isRef?null:(0,f.jsx)(`div`,{className:`univer-ml-1 univer-cursor-pointer univer-rounded univer-text-base hover:univer-bg-gray-200`,children:(0,f.jsx)(Ce,{onClick:()=>a(t.id)})})]})},Xe=()=>{};function Ze(e){let{value:s,onChange:c=Xe,unitId:l,subUnitId:p,validResult:h,showError:g,ruleId:_}=e,{formula1:v=``,formula2:y=``}=s||{},[b,S]=(0,d.useState)(()=>(0,n.isFormulaString)(v)?`1`:`0`),[C,T]=(0,d.useState)(b===`1`?v:`=`),[E,D]=(0,d.useState)(b===`1`?v:`=`),O=(0,t.useDependency)(n.LocaleService),k=(0,t.useDependency)(a.DataValidatorRegistryService),A=(0,t.useDependency)(a.DataValidationModel),j=(0,t.useDependency)(i.DataValidationFormulaController),M=(0,t.useDependency)(x),[N,P]=(0,d.useState)(()=>y.split(`,`)),F=k.getValidatorItem(n.DataValidationType.LIST),[I,L]=(0,d.useState)([]),[R,z]=(0,d.useState)(``),B=g?h==null?void 0:h.formula1:``,ee=(0,t.useObservable)((0,d.useMemo)(()=>A.ruleChange$.pipe((0,o.debounceTime)(16)),[])),V=(0,t.useEvent)(c);(0,d.useEffect)(()=>{let e=!1,t=setTimeout(()=>{let t=A.getRuleById(l,p,_);(0,n.isFormulaString)(t==null?void 0:t.formula1)&&F&&t&&F.getListAsync(t,l,p).then(t=>{e||L(t)})},100);return()=>{e=!0,clearTimeout(t)}},[A,ee,F,_,p,l]),(0,d.useEffect)(()=>{(0,n.isFormulaString)(v)&&v!==E&&(T(v),D(v))},[E,v]);let[H,U]=(0,d.useState)(()=>{let e=b===`1`?[]:(0,r.deserializeListOptions)(v),t=y.split(`,`);return e.map((e,r)=>({label:e,color:t[r]||`#ECECEC`,isRef:!1,id:(0,n.generateRandomId)(4)}))}),W=(e,t,n)=>{let r=H.find(t=>t.id===e);r&&(r.label=t,r.color=n,U([...H]))},te=e=>{let t=H.findIndex(t=>t.id===e);t!==-1&&(H.splice(t,1),U([...H]))},G=(0,d.useMemo)(()=>I.map((e,t)=>({label:e,color:N[t]||`#ECECEC`,id:`${t}`,isRef:!0})),[N,I]),ne=(e,t,n)=>{let r=[...N];r[+e]=n,P(r),V({formula1:v,formula2:r.join(`,`)})},re=()=>{U([...H,{label:``,color:w,isRef:!1,id:(0,n.generateRandomId)(4)}])};(0,d.useEffect)(()=>{b!==`1`&&V(Ke(H,w))},[H,V,b]);let ie=(0,t.useEvent)(async e=>{if(!(0,n.isFormulaString)(e)){V==null||V({formula1:``,formula2:y});return}j.getFormulaRefCheck(e)?(V==null||V({formula1:(0,n.isFormulaString)(e)?e:``,formula2:y}),z(``)):(V==null||V({formula1:``,formula2:y}),T(`=`),z(O.t(`sheets-data-validation-ui.validFail.formulaError`)))}),ae=(0,d.useRef)(null),[K,oe]=(0,d.useState)(!1);return(0,t.useSidebarClick)(e=>{var t;(t=ae.current)!=null&&t.isClickOutSide(e)&&oe(!1)}),(0,d.useEffect)(()=>{K?M.setFocusFormulaEditorActiveRuleSubUnitId(p):M.setFocusFormulaEditorActiveRuleSubUnitId(null)},[K,p,M]),(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(u.FormLayout,{label:O.t(`sheets-data-validation-ui.list.options`),children:(0,f.jsxs)(u.RadioGroup,{value:b,onChange:e=>{S(e),T(E),e===`1`&&V({formula1:E===`=`?``:E,formula2:N.join(`,`)})},children:[(0,f.jsx)(u.Radio,{value:`0`,children:O.t(`sheets-data-validation-ui.list.customOptions`)}),(0,f.jsx)(u.Radio,{value:`1`,children:O.t(`sheets-data-validation-ui.list.refOptions`)})]})}),b===`1`?(0,f.jsxs)(u.FormLayout,{error:B||R||void 0,children:[(0,f.jsx)(m.FormulaEditor,{ref:ae,className:(0,u.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`,u.borderClassName),initValue:C,unitId:l,subUnitId:p,isFocus:K,isSupportAcrossSheet:!0,onFocus:()=>oe(!0),onChange:(e=``)=>{let t=(e==null?``:e).trim();D(t),ie(t)}}),G.length>0&&(0,f.jsx)(`div`,{className:`univer-mt-3`,children:G.map(e=>(0,f.jsx)(Ye,{className:`univer-mb-3`,item:e,commonProps:{onItemChange:ne}},e.id))})]}):(0,f.jsx)(u.FormLayout,{error:B,children:(0,f.jsxs)(`div`,{children:[(0,f.jsx)(u.DraggableList,{list:H,onListChange:U,rowHeight:28,margin:[0,12],draggableHandle:`.draggableHandle`,itemRender:e=>(0,f.jsx)(Ye,{item:e,commonProps:{onItemChange:W,onItemDelete:te}},e.id),idKey:`id`}),(0,f.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:re,children:[(0,f.jsx)(ke,{className:`univer-mr-1`}),O.t(`sheets-data-validation-ui.list.add`)]})]})})]})}let Qe=[[i.CUSTOM_FORMULA_INPUT_NAME,Ge],[i.BASE_FORMULA_INPUT_NAME,Ue],[i.LIST_FORMULA_INPUT_NAME,Ze],[i.CHECKBOX_FORMULA_INPUT_NAME,We]];function $e(e){var r;let{value:i,onChange:a}=e,o=(0,t.useDependency)(n.LocaleService);return(0,f.jsx)(u.FormLayout,{label:o.t(`sheets-data-validation-ui.renderMode.label`),children:(0,f.jsxs)(u.RadioGroup,{value:`${(r=i.renderMode)==null?n.DataValidationRenderMode.CUSTOM:r}`,onChange:e=>a({...i,renderMode:+e}),children:[(0,f.jsx)(u.Radio,{value:`${n.DataValidationRenderMode.CUSTOM}`,children:o.t(`sheets-data-validation-ui.renderMode.chip`)}),(0,f.jsx)(u.Radio,{value:`${n.DataValidationRenderMode.ARROW}`,children:o.t(`sheets-data-validation-ui.renderMode.arrow`)}),(0,f.jsx)(u.Radio,{value:`${n.DataValidationRenderMode.TEXT}`,children:o.t(`sheets-data-validation-ui.renderMode.text`)})]})})}$e.componentKey=`LIST_RENDER_MODE_OPTION_INPUT`;let J=class extends n.Disposable{constructor(e,t){super(),this._componentManager=e,this._iconManager=t,this._registerIcons(),this._registerComponents()}_registerIcons(){this.disposeWithMe(this._iconManager.register({CheckboxIcon:_e,DataValidationIcon:ye,DatePickerIcon:xe,DropdownListIcon:Te}))}_registerComponents(){[[k,Ve],[$e.componentKey,$e],[He.componentKey,He],[z,B],...Qe].forEach(([e,t])=>{this.disposeWithMe(this._componentManager.register(e,t))})}};J=b([y(0,(0,n.Inject)(t.ComponentManager)),y(1,(0,n.Inject)(t.IconManager))],J);let Y=`SHEET_DATA_VALIDATION_ALERT`,et=class extends n.Disposable{constructor(e,t,n,r,i){super(),this._hoverManagerService=e,this._cellAlertManagerService=t,this._univerInstanceService=n,this._localeService=r,this._dataValidationModel=i,this._init()}_init(){this._initCellAlertPopup()}_initCellAlertPopup(){this.disposeWithMe(this._hoverManagerService.currentCell$.pipe((0,o.debounceTime)(100)).subscribe(e=>{if(e){let r=this._univerInstanceService.getUnit(e.location.unitId,n.UniverInstanceType.UNIVER_SHEET),i=r.getSheetBySheetId(e.location.subUnitId);if(!i)return;let a=this._dataValidationModel.getRuleByLocation(e.location.unitId,e.location.subUnitId,e.location.row,e.location.col);if(!a){this._cellAlertManagerService.removeAlert(Y);return}if(this._dataValidationModel.validator(a,{...e.location,workbook:r,worksheet:i})===n.DataValidationStatus.INVALID){var t;let n=this._cellAlertManagerService.currentAlert.get(Y),r=n==null||(t=n.alert)==null?void 0:t.location;if(r&&r.row===e.location.row&&r.col===e.location.col&&r.subUnitId===e.location.subUnitId&&r.unitId===e.location.unitId){this._cellAlertManagerService.removeAlert(Y);return}let i=this._dataValidationModel.getValidator(a.type);if(!i){this._cellAlertManagerService.removeAlert(Y);return}this._cellAlertManagerService.showAlert({type:l.CellAlertType.ERROR,title:this._localeService.t(`sheets-data-validation-ui.error.title`),message:i==null?void 0:i.getRuleFinalError(a,e.location),location:e.location,width:200,height:74,key:Y});return}}this._cellAlertManagerService.removeAlert(Y)}))}};et=b([y(0,(0,n.Inject)(l.HoverManagerService)),y(1,(0,n.Inject)(l.CellAlertManagerService)),y(2,n.IUniverInstanceService),y(3,(0,n.Inject)(n.LocaleService)),y(4,(0,n.Inject)(i.SheetDataValidationModel))],et);let X=class extends n.Disposable{constructor(e,t,n){super(),this._autoFillService=e,this._sheetDataValidationModel=t,this._injector=n,this._initAutoFill()}_initAutoFill(){let e=()=>({redos:[],undos:[]}),t=(e,t)=>{let{source:a,target:o,unitId:s,subUnitId:c}=e,u=this._sheetDataValidationModel.getRuleObjectMatrix(s,c).clone(),d=(0,l.virtualizeDiscreteRanges)([a,o]),[f,p]=d.ranges,{mapFunc:m}=d,h={row:f.startRow,col:f.startColumn},g=r.AutoFillTools.getAutoFillRepeatRange(f,p),_=new n.ObjectMatrix,v=new Set;g.forEach(e=>{let t=e.repeatStartCell,r=e.relativeRange,i={startRow:h.row,startColumn:h.col,endColumn:h.col,endRow:h.row},a={startRow:t.row,startColumn:t.col,endColumn:t.col,endRow:t.row};n.Range.foreach(r,(e,t)=>{let r=n.Rectangle.getPositionRange({startRow:e,startColumn:t,endColumn:t,endRow:e},i),{row:o,col:l}=m(r.startRow,r.startColumn),u=this._sheetDataValidationModel.getRuleIdByLocation(s,c,o,l)||``,d=n.Rectangle.getPositionRange({startRow:e,startColumn:t,endColumn:t,endRow:e},a),{row:f,col:p}=m(d.startRow,d.startColumn);_.setValue(f,p,u),v.add(u)})});let y=Array.from(v).map(e=>({id:e,ranges:(0,n.queryObjectMatrix)(_,t=>t===e)}));u.addRangeRules(y);let{redoMutations:b,undoMutations:x}=(0,i.getDataValidationDiffMutations)(s,c,u.diff(this._sheetDataValidationModel.getRules(s,c)),this._injector,`patched`,t===r.AUTO_FILL_APPLY_TYPE.ONLY_FORMAT);return{undos:x,redos:b}},a={id:i.DATA_VALIDATION_PLUGIN_NAME,onBeforeFillData:e=>{let{source:t,unitId:i,subUnitId:a}=e;for(let e of t.rows)for(let o of t.cols){let t=this._sheetDataValidationModel.getRuleByLocation(i,a,e,o);if(t&&t.type===n.DataValidationType.CHECKBOX){this._autoFillService.setDisableApplyType(r.AUTO_FILL_APPLY_TYPE.SERIES,!0);return}}},onFillData:(n,i,a)=>a===r.AUTO_FILL_APPLY_TYPE.COPY||a===r.AUTO_FILL_APPLY_TYPE.ONLY_FORMAT||a===r.AUTO_FILL_APPLY_TYPE.SERIES?t(n,a):e(),onAfterFillData:()=>{}};this.disposeWithMe(this._autoFillService.addHook(a))}};X=b([y(0,r.IAutoFillService),y(1,(0,n.Inject)(i.SheetDataValidationModel)),y(2,(0,n.Inject)(n.Injector))],X);let tt=[l.PREDEFINED_HOOK_NAME_PASTE.SPECIAL_PASTE_COL_WIDTH,l.PREDEFINED_HOOK_NAME_PASTE.SPECIAL_PASTE_VALUE,l.PREDEFINED_HOOK_NAME_PASTE.SPECIAL_PASTE_FORMAT,l.PREDEFINED_HOOK_NAME_PASTE.SPECIAL_PASTE_FORMULA],nt=class extends n.Disposable{constructor(e,t,n,r){super(),this._sheetClipboardService=e,this._sheetDataValidationModel=t,this._injector=n,this._univerInstanceService=r,v(this,`_copyInfo`,void 0),this._initCopyPaste()}_initCopyPaste(){this._sheetClipboardService.addClipboardHook({id:i.DATA_VALIDATION_PLUGIN_NAME,onBeforeCopy:(e,t,n)=>this._collect(e,t,n),onPasteCells:(e,t,n,r)=>!e||!this._copyInfo||tt.includes(r.pasteType)?{redos:[],undos:[]}:this._generateMutations(e,t,r)})}_collect(e,t,i){let a=new n.ObjectMatrix;this._copyInfo={unitId:e,subUnitId:t,matrix:a};let o=this._injector.invoke(n=>(0,r.rangeToDiscreteRange)(i,n,e,t));if(!o)return;let{rows:s,cols:c}=o;s.forEach((n,r)=>{c.forEach((i,o)=>{let s=this._sheetDataValidationModel.getRuleIdByLocation(e,t,n,i);a.setValue(r,o,s==null?``:s)})})}_generateMutations(e,t,a){let{unitId:o,subUnitId:s,range:c}=e,{unitId:u,subUnitId:d,range:f}=t,{copyType:p=l.COPY_TYPE.COPY}=a;if(!(0,r.getSheetCommandTarget)(this._univerInstanceService,{unitId:u,subUnitId:d}))return{redos:[],undos:[]};if(p===l.COPY_TYPE.CUT&&u===o&&d===s)return this._copyInfo=null,{redos:[],undos:[]};if(u!==o||d!==s){let e=this._sheetDataValidationModel.getRuleObjectMatrix(u,d).clone(),t=new n.ObjectMatrix,r=new Set,{ranges:[a,m],mapFunc:h}=(0,l.virtualizeDiscreteRanges)([c,f]),g=(0,l.getRepeatRange)(a,m,!0),_=new Map;g.forEach(({startRange:e})=>{var i;(i=this._copyInfo)==null||i.matrix.forValue((i,a,c)=>{let l=n.Rectangle.getPositionRange({startRow:i,endRow:i,startColumn:a,endColumn:a},e),f=`${s}-${c}`,p=this._sheetDataValidationModel.getRuleById(o,s,c);!this._sheetDataValidationModel.getRuleById(u,d,f)&&p&&_.set(f,{...p,uid:f});let{row:m,col:g}=h(l.startRow,l.startColumn);r.add(f),t.setValue(m,g,f)})});let v=Array.from(r).map(e=>({id:e,ranges:(0,n.queryObjectMatrix)(t,t=>t===e)}));e.addRangeRules(v);let{redoMutations:y,undoMutations:b}=(0,i.getDataValidationDiffMutations)(u,d,e.diffWithAddition(this._sheetDataValidationModel.getRules(u,d),_.values()),this._injector,`patched`,!1);if(p===l.COPY_TYPE.CUT){let e=this._sheetDataValidationModel.getRuleObjectMatrix(o,s).clone(),t=h(a.startRow,a.startColumn),n=h(a.endRow,a.endColumn);e.addRangeRules([{id:``,ranges:[{startRow:t.row,endRow:n.row,startColumn:t.col,endColumn:n.col}]}]);let{redoMutations:r,undoMutations:c}=(0,i.getDataValidationDiffMutations)(o,s,e.diff(this._sheetDataValidationModel.getRules(o,s)),this._injector,`patched`,!1);y.push(...r),b.push(...c)}return{redos:y,undos:b}}else{let e=this._sheetDataValidationModel.getRuleObjectMatrix(o,s).clone(),t=new n.ObjectMatrix,r=new Set,{ranges:[a,p],mapFunc:m}=(0,l.virtualizeDiscreteRanges)([c,f]);(0,l.getRepeatRange)(a,p,!0).forEach(({startRange:e})=>{var i;(i=this._copyInfo)==null||i.matrix.forValue((i,a,o)=>{let s=n.Rectangle.getPositionRange({startRow:i,endRow:i,startColumn:a,endColumn:a},e),{row:c,col:l}=m(s.startRow,s.startColumn);t.setValue(c,l,o),r.add(o)})});let h=Array.from(r).map(e=>({id:e,ranges:(0,n.queryObjectMatrix)(t,t=>t===e)}));e.addRangeRules(h);let{redoMutations:g,undoMutations:_}=(0,i.getDataValidationDiffMutations)(u,d,e.diff(this._sheetDataValidationModel.getRules(o,s)),this._injector,`patched`,!1);return{redos:g,undos:_}}}};nt=b([y(0,l.ISheetClipboardService),y(1,(0,n.Inject)(i.SheetDataValidationModel)),y(2,(0,n.Inject)(n.Injector)),y(3,(0,n.Inject)(n.IUniverInstanceService))],nt);let rt=class extends n.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){let{unitId:t,subUnitId:n,rule:{ranges:i}}=e.params;this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[r.WorkbookEditablePermission],rangeTypes:[r.RangeProtectionPermissionEditPoint],worksheetTypes:[r.WorksheetEditPermission,r.WorksheetSetCellStylePermission]},i,t,n)||this._sheetPermissionCheckController.blockExecuteWithoutPermission(this._localeService.t(`sheets-data-validation-ui.permission.dialog.setStyleErr`))}if(e.id===i.UpdateSheetDataValidationRangeCommand.id){let{unitId:t,subUnitId:n,ranges:i}=e.params;this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[r.WorkbookEditablePermission],rangeTypes:[r.RangeProtectionPermissionEditPoint],worksheetTypes:[r.WorksheetEditPermission,r.WorksheetSetCellStylePermission]},i,t,n)||this._sheetPermissionCheckController.blockExecuteWithoutPermission(this._localeService.t(`sheets-data-validation-ui.permission.dialog.setStyleErr`))}}))}};rt=b([y(0,(0,n.Inject)(n.LocaleService)),y(1,n.ICommandService),y(2,(0,n.Inject)(r.SheetPermissionCheckController))],rt);let it={tr:{size:6,color:`#fe4b4b`}},at=class extends n.RxDisposable{constructor(e,t,n,r,i,a,o,s,c,l,u){super(),this._commandService=e,this._menuManagerService=t,this._renderManagerService=n,this._univerInstanceService=r,this._autoHeightController=i,this._dropdownManagerService=a,this._sheetDataValidationModel=o,this._dataValidatorRegistryService=s,this._sheetInterceptorService=c,this._dataValidationCacheService=l,this._editorBridgeService=u,this._initMenu(),this._initDropdown(),this._initViewModelIntercept(),this._initAutoHeight()}_initMenu(){this._menuManagerService.mergeMenu(le)}_initDropdown(){this._editorBridgeService&&this.disposeWithMe(this._editorBridgeService.visible$.subscribe(e=>{if(!e.visible){var t;((t=this._dropdownManagerService.activeDropdown)==null?void 0:t.trigger)===`editor-bridge`&&this._dropdownManagerService.hideDropdown();return}let n=this._editorBridgeService.getEditCellState();if(n){let{unitId:e,sheetId:t,row:r,column:i}=n,a=this._univerInstanceService.getUniverSheetInstance(e);if(!a)return;let o=this._sheetDataValidationModel.getRuleByLocation(e,t,r,i);if(!o)return;let s=this._dataValidatorRegistryService.getValidatorItem(o.type);if(!(s!=null&&s.dropdownType))return;let c=a.getActiveSheet();if(!c)return;let l=this._dropdownManagerService.activeDropdown,u=l==null?void 0:l.location;if(u&&u.unitId===e&&u.subUnitId===t&&u.row===r&&u.col===i)return;this._dropdownManagerService.showDropdown({location:{unitId:e,subUnitId:t,row:r,col:i,workbook:a,worksheet:c},trigger:`editor-bridge`,closeOnOutSide:!1})}}))}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(r.INTERCEPTOR_POINT.CELL_CONTENT,{effect:n.InterceptorEffectEnum.Style,priority:r.InterceptCellContentPriority.DATA_VALIDATION,handler:(e,t,r)=>{var a,o,s,c,u;let{row:d,col:f,unitId:p,subUnitId:m,workbook:h,worksheet:g}=t,_=this._sheetDataValidationModel.getRuleIdByLocation(p,m,d,f);if(!_)return r(e);let v=this._sheetDataValidationModel.getRuleById(p,m,_);if(!v)return r(e);let y=(a=this._dataValidationCacheService.getValue(p,m,d,f))==null?n.DataValidationStatus.VALID:a,b=this._dataValidatorRegistryService.getValidatorItem(v.type),x=t.rawData,S,C={get value(){var e;return S===void 0&&(S=(e=(0,i.getCellValueOrigin)(x))==null?null:e),S}},w={get value(){var e;return`${(e=C.value)==null?``:e}`}};return(!e||e===t.rawData)&&(e={...t.rawData}),e.markers={...e==null?void 0:e.markers,...y===n.DataValidationStatus.INVALID?it:null},e.customRender=[...(o=e==null?void 0:e.customRender)==null?[]:o,...b!=null&&b.canvasRender?[b.canvasRender]:[]],e.fontRenderExtension={...e==null?void 0:e.fontRenderExtension,isSkip:(e==null||(s=e.fontRenderExtension)==null?void 0:s.isSkip)||(b==null||(c=b.skipDefaultFontRender)==null?void 0:c.call(b,v,C.value,t))},e.interceptorStyle={...e==null?void 0:e.interceptorStyle,...b==null?void 0:b.getExtraStyle(v,w.value,{get style(){let t=h.getStyles();return(typeof(e==null?void 0:e.s)==`string`?t.get(e==null?void 0:e.s):e==null?void 0:e.s)||{}}},d,f)},e.interceptorAutoHeight=()=>{var t,n,r,i,a;let o=(t=this._renderManagerService.getRenderById(p))==null||(t=t.with(l.SheetSkeletonManagerService).getSkeletonParam(m))==null?void 0:t.skeleton;if(!o)return;let s=o.worksheet.getMergedCell(d,f),c={data:e,style:o.getStyles().getStyleByCell(e),primaryWithCoord:o.getCellWithCoordByIndex((n=s==null?void 0:s.startRow)==null?d:n,(r=s==null?void 0:s.startColumn)==null?f:r),unitId:p,subUnitId:m,row:d,col:f,workbook:h,worksheet:g};return b==null||(i=b.canvasRender)==null||(a=i.calcCellAutoHeight)==null?void 0:a.call(i,c)},e.interceptorAutoWidth=()=>{var t,n,r,i,a;let o=(t=this._renderManagerService.getRenderById(p))==null||(t=t.with(l.SheetSkeletonManagerService).getSkeletonParam(m))==null?void 0:t.skeleton;if(!o)return;let s=o.worksheet.getMergedCell(d,f),c={data:e,style:o.getStyles().getStyleByCell(e),primaryWithCoord:o.getCellWithCoordByIndex((n=s==null?void 0:s.startRow)==null?d:n,(r=s==null?void 0:s.startColumn)==null?f:r),unitId:p,subUnitId:m,row:d,col:f,workbook:h,worksheet:g};return b==null||(i=b.canvasRender)==null||(a=i.calcCellAutoWidth)==null?void 0:a.call(i,c)},e.coverable=((u=e==null?void 0:e.coverable)==null?!0:u)&&!(v.type===n.DataValidationType.LIST||v.type===n.DataValidationType.LIST_MULTIPLE),r(e)}}))}_initAutoHeight(){this._sheetDataValidationModel.ruleChange$.pipe((0,o.filter)(e=>e.source===`command`),(0,o.bufferTime)(100)).subscribe(e=>{if(e.length===0)return;let t=[];e.forEach(e=>{if(e.rule.type===n.DataValidationType.LIST_MULTIPLE||e.rule.type===n.DataValidationType.LIST){var r;(r=e.rule)!=null&&r.ranges&&t.push(...e.rule.ranges)}}),t.length&&(0,n.sequenceExecute)(this._autoHeightController.getUndoRedoParamsOfAutoHeight(t).redos,this._commandService)})}};at=b([y(0,n.ICommandService),y(1,t.IMenuManagerService),y(2,s.IRenderManagerService),y(3,n.IUniverInstanceService),y(4,(0,n.Inject)(l.AutoHeightController)),y(5,(0,n.Inject)(O)),y(6,(0,n.Inject)(i.SheetDataValidationModel)),y(7,(0,n.Inject)(a.DataValidatorRegistryService)),y(8,(0,n.Inject)(r.SheetInterceptorService)),y(9,(0,n.Inject)(i.DataValidationCacheService)),y(10,(0,n.Optional)(l.IEditorBridgeService))],at);let ot=class extends n.RxDisposable{constructor(e,t,n,r,i,a,o){super(),this._commandService=e,this._renderManagerService=t,this._autoHeightController=n,this._dataValidatorRegistryService=r,this._sheetInterceptorService=i,this._sheetDataValidationModel=a,this._dataValidationCacheService=o,this._initViewModelIntercept(),this._initAutoHeight()}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(r.INTERCEPTOR_POINT.CELL_CONTENT,{effect:n.InterceptorEffectEnum.Style,priority:r.InterceptCellContentPriority.DATA_VALIDATION,handler:(e,t,r)=>{var a,o,s,c,u;let{row:d,col:f,unitId:p,subUnitId:m,workbook:h,worksheet:g}=t,_=this._sheetDataValidationModel.getRuleIdByLocation(p,m,d,f);if(!_)return r(e);let v=this._sheetDataValidationModel.getRuleById(p,m,_);if(!v)return r(e);let y=(a=this._dataValidationCacheService.getValue(p,m,d,f))==null?n.DataValidationStatus.VALID:a,b=this._dataValidatorRegistryService.getValidatorItem(v.type),x=(0,i.getCellValueOrigin)(g.getCellRaw(d,f)),S=`${x==null?``:x}`;return(!e||e===t.rawData)&&(e={...t.rawData}),e.markers={...e==null?void 0:e.markers,...y===n.DataValidationStatus.INVALID?it:null},e.customRender=[...(o=e==null?void 0:e.customRender)==null?[]:o,...b!=null&&b.canvasRender?[b.canvasRender]:[]],e.fontRenderExtension={...e==null?void 0:e.fontRenderExtension,isSkip:(e==null||(s=e.fontRenderExtension)==null?void 0:s.isSkip)||(b==null||(c=b.skipDefaultFontRender)==null?void 0:c.call(b,v,x,t))},e.interceptorStyle={...e==null?void 0:e.interceptorStyle,...b==null?void 0:b.getExtraStyle(v,S,{get style(){let t=h.getStyles();return(typeof(e==null?void 0:e.s)==`string`?t.get(e==null?void 0:e.s):e==null?void 0:e.s)||{}}},d,f)},e.interceptorAutoHeight=()=>{var t,n,r,i,a;let o=(t=this._renderManagerService.getRenderById(p))==null||(t=t.with(l.SheetSkeletonManagerService).getSkeletonParam(m))==null?void 0:t.skeleton;if(!o)return;let s=o.worksheet.getMergedCell(d,f),c={data:e,style:o.getStyles().getStyleByCell(e),primaryWithCoord:o.getCellWithCoordByIndex((n=s==null?void 0:s.startRow)==null?d:n,(r=s==null?void 0:s.startColumn)==null?f:r),unitId:p,subUnitId:m,row:d,col:f,workbook:h,worksheet:g};return b==null||(i=b.canvasRender)==null||(a=i.calcCellAutoHeight)==null?void 0:a.call(i,c)},e.interceptorAutoWidth=()=>{var t,n,r,i,a;let o=(t=this._renderManagerService.getRenderById(p))==null||(t=t.with(l.SheetSkeletonManagerService).getSkeletonParam(m))==null?void 0:t.skeleton;if(!o)return;let s=o.worksheet.getMergedCell(d,f),c={data:e,style:o.getStyles().getStyleByCell(e),primaryWithCoord:o.getCellWithCoordByIndex((n=s==null?void 0:s.startRow)==null?d:n,(r=s==null?void 0:s.startColumn)==null?f:r),unitId:p,subUnitId:m,row:d,col:f,workbook:h,worksheet:g};return b==null||(i=b.canvasRender)==null||(a=i.calcCellAutoWidth)==null?void 0:a.call(i,c)},e.coverable=((u=e==null?void 0:e.coverable)==null?!0:u)&&!(v.type===n.DataValidationType.LIST||v.type===n.DataValidationType.LIST_MULTIPLE),r(e)}}))}_initAutoHeight(){this._sheetDataValidationModel.ruleChange$.pipe((0,o.filter)(e=>e.source===`command`),(0,o.bufferTime)(16)).subscribe(e=>{let t=[];e.forEach(e=>{if(e.rule.type===n.DataValidationType.LIST_MULTIPLE||e.rule.type===n.DataValidationType.LIST){var r;(r=e.rule)!=null&&r.ranges&&t.push(...e.rule.ranges)}}),t.length&&(0,n.sequenceExecute)(this._autoHeightController.getUndoRedoParamsOfAutoHeight(t).redos,this._commandService)})}};ot=b([y(0,n.ICommandService),y(1,s.IRenderManagerService),y(2,(0,n.Inject)(l.AutoHeightController)),y(3,(0,n.Inject)(a.DataValidatorRegistryService)),y(4,(0,n.Inject)(r.SheetInterceptorService)),y(5,(0,n.Inject)(i.SheetDataValidationModel)),y(6,(0,n.Inject)(i.DataValidationCacheService))],ot);let st=class extends n.Disposable{constructor(e,t,n){super(),this._context=e,this._sheetDataValidationModel=t,this._sheetSkeletonManagerService=n,this._initSkeletonChange()}_initSkeletonChange(){this.disposeWithMe(this._sheetDataValidationModel.validStatusChange$.pipe((0,n.bufferDebounceTime)(16)).subscribe(e=>{var t;if(!e.length)return;let n=new Set;e.forEach(e=>{n.add(e.subUnitId)}),n.forEach(e=>{var t;(t=this._sheetSkeletonManagerService.getSkeletonParam(e))==null||t.skeleton.makeDirty(!0)}),(t=this._context.mainComponent)==null||t.makeForceDirty()}))}};st=b([y(1,(0,n.Inject)(i.SheetDataValidationModel)),y(2,(0,n.Inject)(l.SheetSkeletonManagerService))],st);let ct=class{_calc(e,t){var r,i,a;let{vt:o,ht:s}=t||{},c=e.endX-e.startX-12,l=e.endY-e.startY,u=((r=t==null?void 0:t.fs)==null?10:r)*1.6,d=0,f=0;switch(o){case n.VerticalAlign.TOP:f=0;break;case n.VerticalAlign.BOTTOM:f=0+(l-u);break;default:f=0+(l-u)/2;break}switch(s){case n.HorizontalAlign.LEFT:d=6;break;case n.HorizontalAlign.RIGHT:d=6+(c-u);break;default:d=6+(c-u)/2;break}return{left:e.startX+d,top:e.startY+f,width:((i=t==null?void 0:t.fs)==null?10:i)*1.6,height:((a=t==null?void 0:t.fs)==null?10:a)*1.6}}constructor(e,t,n,r,i,a){this._commandService=e,this._univerInstanceService=t,this._formulaService=n,this._themeService=r,this._renderManagerService=i,this._dataValidationModel=a}calcCellAutoHeight(e){var t;let{style:n}=e;return((t=n==null?void 0:n.fs)==null?10:t)*1.6}calcCellAutoWidth(e){var t;let{style:n}=e;return((t=n==null?void 0:n.fs)==null?10:t)*1.6}async _parseFormula(e,t,r){var a,o,s;let{formula1:c=i.CHECKBOX_FORMULA_1,formula2:l=i.CHECKBOX_FORMULA_2}=e,u=await this._formulaService.getRuleFormulaResult(t,r,e.uid),d=(0,i.getFormulaResult)(u==null||(a=u[0])==null||(a=a.result)==null||(a=a[0])==null?void 0:a[0]),f=(0,i.getFormulaResult)(u==null||(o=u[1])==null||(o=o.result)==null||(o=o[0])==null?void 0:o[0]),p=(0,i.isLegalFormulaResult)(String(d))&&(0,i.isLegalFormulaResult)(String(f));return{formula1:(0,n.isFormulaString)(c)?(0,i.getFormulaResult)(u==null||(s=u[0])==null||(s=s.result)==null||(s=s[0])==null?void 0:s[0]):c,formula2:(0,n.isFormulaString)(l)?f:l,isFormulaValid:p}}drawWith(e,t){var n,r,a,o;let{style:c,primaryWithCoord:l,unitId:u,subUnitId:d,worksheet:f,row:p,col:m}=t,h=l.isMergedMainCell?l.mergeInfo:l,g=(0,i.getCellValueOrigin)(f.getCellRaw(p,m)),_=this._dataValidationModel.getRuleByLocation(u,d,p,m);if(!_)return;let v=this._dataValidationModel.getValidator(_.type);if(!v||!((n=v.skipDefaultFontRender)!=null&&n.call(v,_,g,{unitId:u,subUnitId:d,row:p,column:m})))return;let{formula1:y}=v.parseFormulaSync(_,u,d),b=this._calc(h,c),{a:x,d:S}=e.getTransform(),C=(0,s.fixLineWidthByScale)(b.left,x),w=(0,s.fixLineWidthByScale)(b.top,S),T=s.Transform.create().composeMatrix({left:C,top:w,scaleX:1,scaleY:1,angle:0,skewX:0,skewY:0,flipX:!1,flipY:!1}),E=h.endX-h.startX,D=h.endY-h.startY;e.save(),e.beginPath(),e.rect(h.startX,h.startY,E,D),e.clip();let O=T.getMatrix();e.transform(O[0],O[1],O[2],O[3],O[4],O[5]);let k=((r=c==null?void 0:c.fs)==null?10:r)*1.6,A=String(g)===String(y),j=this._themeService.getColorFromTheme(`primary.600`);s.CheckboxShape.drawWith(e,{checked:A,width:k,height:k,fill:(a=c==null||(o=c.cl)==null?void 0:o.rgb)==null?j:a}),e.restore()}isHit(e,t){let n=t.primaryWithCoord.isMergedMainCell?t.primaryWithCoord.mergeInfo:t.primaryWithCoord,r=this._calc(n,t.style),i=r.top,a=r.top+r.height,o=r.left,s=r.left+r.width,{x:c,y:l}=e;return c<=s&&c>=o&&l<=a&&l>=i}async onPointerDown(e,t){var n;if(t.button===2)return;let{primaryWithCoord:a,unitId:o,subUnitId:s,worksheet:c,row:l,col:u}=e,d=(0,i.getCellValueOrigin)(c.getCellRaw(l,u)),f=this._dataValidationModel.getRuleByLocation(o,s,l,u);if(!f)return;let p=this._dataValidationModel.getValidator(f.type);if(!p||!((n=p.skipDefaultFontRender)!=null&&n.call(p,f,d,{unitId:o,subUnitId:s,row:l,column:u})))return;let{formula1:m,formula2:h}=await this._parseFormula(f,o,s),g={range:{startColumn:a.actualColumn,endColumn:a.actualColumn,startRow:a.actualRow,endRow:a.actualRow},value:{v:String(d)===(0,i.transformCheckboxValue)(String(m))?h:m,p:null}};this._commandService.executeCommand(r.SetRangeValuesCommand.id,g)}onPointerEnter(e,t){var r;(r=(0,s.getCurrentTypeOfRenderer)(n.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null||(r=r.mainComponent)==null||r.setCursor(s.CURSOR_TYPE.POINTER)}onPointerLeave(e,t){var r;(r=(0,s.getCurrentTypeOfRenderer)(n.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null||(r=r.mainComponent)==null||r.setCursor(s.CURSOR_TYPE.DEFAULT)}};ct=b([y(0,n.ICommandService),y(1,n.IUniverInstanceService),y(2,(0,n.Inject)(i.DataValidationFormulaService)),y(3,(0,n.Inject)(n.ThemeService)),y(4,(0,n.Inject)(s.IRenderManagerService)),y(5,(0,n.Inject)(i.SheetDataValidationModel))],ct);let Z=class{constructor(e){this.injector=e,v(this,`canvasRender`,null),v(this,`dropdownType`,void 0),v(this,`optionsInput`,void 0),v(this,`formulaInput`,i.LIST_FORMULA_INPUT_NAME)}};Z=b([y(0,(0,n.Inject)(n.Injector))],Z);var lt=class extends Z{constructor(...e){super(...e),v(this,`id`,n.DataValidationType.CHECKBOX),v(this,`canvasRender`,this.injector.createInstance(ct)),v(this,`formulaInput`,i.CHECKBOX_FORMULA_INPUT_NAME)}},ut=class extends Z{constructor(...e){super(...e),v(this,`id`,n.DataValidationType.CUSTOM),v(this,`formulaInput`,i.CUSTOM_FORMULA_INPUT_NAME)}},dt=class extends Z{constructor(...e){super(...e),v(this,`id`,n.DataValidationType.DATE),v(this,`formulaInput`,i.BASE_FORMULA_INPUT_NAME),v(this,`optionsInput`,He.componentKey),v(this,`dropdownType`,a.DataValidatorDropdownType.DATE)}},ft=class extends Z{constructor(...e){super(...e),v(this,`id`,n.DataValidationType.DECIMAL),v(this,`formulaInput`,i.BASE_FORMULA_INPUT_NAME)}};function pt(e,t){let n=s.FontCache.getTextSize(e,t),r=n.width+8,{ba:i,bd:a}=n;return{width:r,height:i+a+0,ba:i}}function mt(e,t,n,r){let i=n-26,a=r-12,o=e.map(e=>({layout:pt(e,t),text:e})),s,c=[];o.forEach(e=>{let{layout:t}=e,{width:n,height:r}=t;!s||s.width+n+4>i?(s={width:n,height:r,items:[{...e,left:0}]},c.push(s)):(s.items.push({...e,left:s.width+4}),s.width=s.width+n+4)});let l=0,u=0;return c.forEach((e,t)=>{u=Math.max(u,e.width),t===c.length-1?l+=e.height:l+=e.height+4}),{lines:c,totalHeight:l,contentWidth:i,contentHeight:a,cellAutoHeight:l+12,calcAutoWidth:u+26}}var ht=class extends s.Shape{static drawWith(e,t){let{fontString:n,info:r,fill:i,color:a}=t,{layout:o,text:c}=r;e.save(),s.Rect.drawWith(e,{width:o.width,height:o.height,radius:8,fill:i||`#ECECEC`}),e.translateWithPrecision(4,o.ba),e.font=n,e.fillStyle=a,e.fillText(c,0,0),e.restore()}};let gt=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`),_t=class{constructor(e,t,n,r){this._commandService=e,this._univerInstanceService=t,this._renderManagerService=n,this._dataValidationModel=r,v(this,`zIndex`,void 0),v(this,`_dropdownInfoMap`,new Map)}_ensureMap(e){let t=this._dropdownInfoMap.get(e);return t||(t=new Map,this._dropdownInfoMap.set(e,t)),t}_generateKey(e,t){return`${e}.${t}`}_drawDownIcon(e,t,r,i,a){let o=r-14+4,s=4;switch(a){case n.VerticalAlign.MIDDLE:s=(i-14)/2+4;break;case n.VerticalAlign.BOTTOM:s=i-14+4;break;default:break}e.save(),e.translateWithPrecision(t.startX+o,t.startY+s),e.fillStyle=`#565656`,e.fill(gt),e.restore()}drawWith(e,t,r,a){var o,c;let{primaryWithCoord:l,row:u,col:d,style:f,data:p,subUnitId:m}=t,h=l.isMergedMainCell?l.mergeInfo:l,{leftOffset:g=0,rightOffset:_=0,topOffset:v=0,downOffset:y=0}=(p==null?void 0:p.fontRenderExtension)||{},b=this._ensureMap(m),x=this._generateKey(u,d),S=l.isMergedMainCell?l.mergeInfo.startRow:u,C=l.isMergedMainCell?l.mergeInfo.startColumn:d,w=this._dataValidationModel.getRuleByLocation(t.unitId,t.subUnitId,S,C);if(!w)return;let T=this._dataValidationModel.getValidator(w.type);if(!T)return;let E={startX:h.startX+g,endX:h.endX-_,startY:h.startY+v,endY:h.endY-y},D=E.endX-E.startX,O=E.endY-E.startY,{cl:k}=f||{},A=(o=typeof k==`object`?k==null?void 0:k.rgb:k)==null?`#000`:o,j=(0,s.getFontStyleString)(f==null?void 0:f),{vt:M,ht:N}=f||{},P=M==null?n.VerticalAlign.MIDDLE:M,F=(c=(0,i.getCellValueOrigin)(p))==null?``:c,I=T.parseCellValue(F),L=T.getListWithColorMap(w),R=mt(I,j,D,O);this._drawDownIcon(e,E,D,O,P),e.save(),e.translateWithPrecision(E.startX,E.startY),e.beginPath(),e.rect(0,0,D-14,O),e.clip(),e.translateWithPrecision(6,6);let z=0;switch(P){case n.VerticalAlign.MIDDLE:z=(R.contentHeight-R.totalHeight)/2;break;case n.VerticalAlign.BOTTOM:z=R.contentHeight-R.totalHeight;break;default:break}e.translateWithPrecision(0,z),R.lines.forEach((t,r)=>{e.save();let{width:i,height:a,items:o}=t,s=0;switch(N){case n.HorizontalAlign.RIGHT:s=R.contentWidth-i;break;case n.HorizontalAlign.CENTER:s=(R.contentWidth-i)/2;break;default:break}e.translate(s,r*(a+4)),o.forEach(t=>{e.save(),e.translateWithPrecision(t.left,0),ht.drawWith(e,{...j,info:t,color:A,fill:L[t.text]}),e.restore()}),e.restore()}),e.restore(),b.set(x,{left:E.startX,top:E.startY,width:R.contentWidth+6+14,height:R.contentHeight+12})}calcCellAutoHeight(e){var t;let{primaryWithCoord:n,style:r,data:a,row:o,col:c}=e,{leftOffset:l=0,rightOffset:u=0,topOffset:d=0,downOffset:f=0}=(a==null?void 0:a.fontRenderExtension)||{},p=n.isMergedMainCell?n.mergeInfo:n,m={startX:p.startX+l,endX:p.endX-u,startY:p.startY+d,endY:p.endY-f},h=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,o,c);if(!h)return;let g=this._dataValidationModel.getValidator(h.type);if(!g)return;let _=m.endX-m.startX,v=m.endY-m.startY,y=(t=(0,i.getCellValueOrigin)(a))==null?``:t;return mt(g.parseCellValue(y),(0,s.getFontStyleString)(r==null?void 0:r),_,v).cellAutoHeight}calcCellAutoWidth(e){var t;let{primaryWithCoord:n,style:r,data:a,row:o,col:c}=e,{leftOffset:l=0,rightOffset:u=0,topOffset:d=0,downOffset:f=0}=(a==null?void 0:a.fontRenderExtension)||{},p=n.isMergedMainCell?n.mergeInfo:n,m={startX:p.startX+l,endX:p.endX-u,startY:p.startY+d,endY:p.endY-f},h=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,o,c);if(!h)return;let g=this._dataValidationModel.getValidator(h.type);if(!g)return;let _=m.endX-m.startX,v=m.endY-m.startY,y=(t=(0,i.getCellValueOrigin)(a))==null?``:t;return mt(g.parseCellValue(y),(0,s.getFontStyleString)(r==null?void 0:r),_,v).calcAutoWidth}isHit(e,t){let{primaryWithCoord:n}=t,{endX:r}=n.isMergedMainCell?n.mergeInfo:n,{x:i}=e;return i>=r-14&&i<=r}onPointerDown(e,t){if(t.button===2)return;let{unitId:n,subUnitId:r,row:i,col:a}=e,o={unitId:n,subUnitId:r,row:i,column:a};this._commandService.executeCommand(N.id,o)}onPointerEnter(e,t){var r;return(r=(0,s.getCurrentTypeOfRenderer)(n.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null||(r=r.mainComponent)==null?void 0:r.setCursor(s.CURSOR_TYPE.POINTER)}onPointerLeave(e,t){var r;return(r=(0,s.getCurrentTypeOfRenderer)(n.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null||(r=r.mainComponent)==null?void 0:r.setCursor(s.CURSOR_TYPE.DEFAULT)}};_t=b([y(0,n.ICommandService),y(1,n.IUniverInstanceService),y(2,(0,n.Inject)(s.IRenderManagerService)),y(3,(0,n.Inject)(i.SheetDataValidationModel))],_t);var vt=class extends Z{constructor(...e){super(...e),v(this,`id`,n.DataValidationType.LIST_MULTIPLE),v(this,`canvasRender`,this.injector.createInstance(_t)),v(this,`dropdownType`,a.DataValidatorDropdownType.MULTIPLE_LIST)}};let yt=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 bt(e,t,r,i,a,o,s=!0){let c=0,l=s?3:0;switch(a){case n.VerticalAlign.BOTTOM:c=t-i-l;break;case n.VerticalAlign.MIDDLE:c=(t-i)/2;break;default:c=l;break}c=Math.max(3,c);let u=0;switch(o){case n.HorizontalAlign.CENTER:u=(e-r)/2;break;case n.HorizontalAlign.RIGHT:u=e-r;break;default:break}return u=Math.max(6,u),{paddingLeft:u,paddingTop:c}}let xt=class{constructor(e,t,n,r,i){this._univerInstanceService=e,this._localeService=t,this._commandService=n,this._renderManagerService=r,this._dataValidationModel=i,v(this,`_dropdownInfoMap`,new Map),v(this,`zIndex`,void 0)}_ensureMap(e){let t=this._dropdownInfoMap.get(e);return t||(t=new Map,this._dropdownInfoMap.set(e,t)),t}_generateKey(e,t){return`${e}.${t}`}_drawDownIcon(e,t,r,i,a,o,s){let{t:c=n.DEFAULT_STYLES.pd.t,b:l=n.DEFAULT_STYLES.pd.b}=s,u=r-14,d;switch(o){case n.VerticalAlign.MIDDLE:d=(i-4)/2;break;case n.VerticalAlign.BOTTOM:d=i-l-a-3+(a/2-4/2);break;default:d=c+3+(a/2-4/2);break}e.save(),e.translateWithPrecision(t.startX+u,t.startY+d),e.fillStyle=`#565656`,e.fill(yt),e.restore()}drawWith(e,t,r){var a,o,c,l;let{primaryWithCoord:u,row:d,col:f,style:p,data:m,subUnitId:h}=t,g=u.isMergedMainCell?u.mergeInfo:u,_=u.isMergedMainCell?u.mergeInfo.startRow:d,v=u.isMergedMainCell?u.mergeInfo.startColumn:f,y=this._dataValidationModel.getRuleByLocation(t.unitId,t.subUnitId,_,v);if(!y)return;let b=this._dataValidationModel.getValidator(y.type);if(!b)return;let{leftOffset:x=0,rightOffset:S=0,topOffset:C=0,downOffset:w=0}=(m==null?void 0:m.fontRenderExtension)||{};if(!y||!b||!b||b.id.indexOf(n.DataValidationType.LIST)!==0||!b.skipDefaultFontRender(y))return;let T={startX:g.startX+x,endX:g.endX-S,startY:g.startY+C,endY:g.endY-w},E=T.endX-T.startX,D=T.endY-T.startY,O=this._ensureMap(h),k=this._generateKey(d,f),A=b.getListWithColorMap(y),j=(0,i.getCellValueOrigin)(m),M=`${j==null?``:j}`,N=A[M],{tb:P,vt:F,ht:I,pd:L}=p||{};P=(a=P)==null?n.WrapStrategy.WRAP:a,F=(o=F)==null?n.VerticalAlign.BOTTOM:o,I=(c=I)==null?n.DEFAULT_STYLES.ht:c,L=(l=L)==null?n.DEFAULT_STYLES.pd:l;let R=(0,s.getFontStyleString)(p).fontCache;if(y.renderMode===n.DataValidationRenderMode.ARROW){var z,B,ee;let{l:t=n.DEFAULT_STYLES.pd.l,t:i=n.DEFAULT_STYLES.pd.t,r:a=n.DEFAULT_STYLES.pd.r,b:o=n.DEFAULT_STYLES.pd.b}=L,c=E-t-a-14-4,l=new s.DocSimpleSkeleton(M,R,P===n.WrapStrategy.WRAP,c,1/0);l.calculate();let u=l.getTotalWidth(),d=l.getTotalHeight(),{paddingTop:f,paddingLeft:m}=bt(c,D-i-o,u,d,F,I,!0);this._drawDownIcon(e,T,E,D,d,F,L),e.save(),e.translateWithPrecision(T.startX+t,T.startY+i),e.beginPath(),e.rect(0,0,E-t-a,D-i-o),e.clip(),e.translateWithPrecision(0,f),e.save(),e.translateWithPrecision(m,0),e.beginPath(),e.rect(0,0,c,d),e.clip(),s.Text.drawWith(e,{text:M,fontStyle:R,width:c,height:d,color:p==null||(z=p.cl)==null?void 0:z.rgb,strokeLine:!!(!(p==null||(B=p.st)==null)&&B.s),underline:!!(!(p==null||(ee=p.ul)==null)&&ee.s),warp:P===n.WrapStrategy.WRAP,hAlign:n.HorizontalAlign.LEFT},l),e.restore(),e.restore(),O.set(k,{left:T.endX-14+r.rowHeaderWidth,top:T.startY+i+r.columnHeaderHeight,width:14,height:D-i-o})}else{var V,H,U;e.save(),e.translateWithPrecision(T.startX,T.startY),e.beginPath(),e.rect(0,0,E,D),e.clip();let t=E-12-4-14-4,i=new s.DocSimpleSkeleton(M,R,P===n.WrapStrategy.WRAP,t,1/0);i.calculate();let a=i.getTotalWidth(),o=i.getTotalHeight(),c=o+2,l=Math.max(E-12,1),{paddingTop:u}=bt(l,D,a,c,F,I);e.translateWithPrecision(6,u),s.Rect.drawWith(e,{width:l,height:c,fill:N||`#ECECEC`,radius:8}),e.save(),e.translateWithPrecision(4,1),e.beginPath(),e.rect(0,0,t,o),e.clip(),s.Text.drawWith(e,{text:M,fontStyle:R,width:t,height:o,color:p==null||(V=p.cl)==null?void 0:V.rgb,strokeLine:!!(!(p==null||(H=p.st)==null)&&H.s),underline:!!(!(p==null||(U=p.ul)==null)&&U.s),warp:P===n.WrapStrategy.WRAP,hAlign:n.HorizontalAlign.LEFT},i),e.restore(),e.translateWithPrecision(t+4+4,(o-4)/2),e.fillStyle=`#565656`,e.fill(yt),e.restore(),O.set(k,{left:T.startX+6+r.rowHeaderWidth,top:T.startY+u+r.columnHeaderHeight,width:l,height:c})}}calcCellAutoHeight(e){var t;let{primaryWithCoord:r,style:a,data:o,row:c,col:l}=e,u=r.isMergedMainCell?r.mergeInfo:r,{leftOffset:d=0,rightOffset:f=0,topOffset:p=0,downOffset:m=0}=(o==null?void 0:o.fontRenderExtension)||{},h=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,c,l);if(!h||h.renderMode===n.DataValidationRenderMode.TEXT)return;let g={startX:u.startX+d,endX:u.endX-f,startY:u.startY+p,endY:u.endY-m},_=g.endX-g.startX,v=(0,i.getCellValueOrigin)(o),y=`${v==null?``:v}`,{tb:b,pd:x}=a||{},{t:S=n.DEFAULT_STYLES.pd.t,b:C=n.DEFAULT_STYLES.pd.b}=x==null?{}:x;if(b=(t=b)==null?n.WrapStrategy.WRAP:t,h.renderMode===n.DataValidationRenderMode.ARROW){let{l:e=n.DEFAULT_STYLES.pd.l,r:t=n.DEFAULT_STYLES.pd.r}=x==null?{}:x,r=_-e-t-14-4,i=new s.DocSimpleSkeleton(y,(0,s.getFontStyleString)(a).fontCache,b===n.WrapStrategy.WRAP,r,1/0);return i.calculate(),i.getTotalHeight()+S+C+6}else{let e=Math.max(_-12-4-14-4,10),t=new s.DocSimpleSkeleton(y,(0,s.getFontStyleString)(a).fontCache,b===n.WrapStrategy.WRAP,e,1/0);return t.calculate(),t.getTotalHeight()+6+2}}calcCellAutoWidth(e){var t;let{primaryWithCoord:r,style:a,data:o,row:c,col:l}=e,u=r.isMergedMainCell?r.mergeInfo:r,{leftOffset:d=0,rightOffset:f=0,topOffset:p=0,downOffset:m=0}=(o==null?void 0:o.fontRenderExtension)||{},h=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,c,l);if(!h||h.renderMode===n.DataValidationRenderMode.TEXT)return;let g={startX:u.startX+d,endX:u.endX-f,startY:u.startY+p,endY:u.endY-m},_=g.endX-g.startX,v=(0,i.getCellValueOrigin)(o),y=`${v==null?``:v}`,{tb:b,pd:x}=a||{},{l:S=n.DEFAULT_STYLES.pd.l,r:C=n.DEFAULT_STYLES.pd.r}=x==null?{}:x;b=(t=b)==null?n.WrapStrategy.WRAP:t;let w=26;switch(h.renderMode){case n.DataValidationRenderMode.ARROW:w=18+C+S;break;case n.DataValidationRenderMode.CUSTOM:w=34+C+S+8/2+1;break;default:w=34+C+S+8/2+1}let T=_-w,E=new s.DocSimpleSkeleton(y,(0,s.getFontStyleString)(a).fontCache,b===n.WrapStrategy.WRAP,T,1/0);return E.calculate(),E.getTotalWidth()+w}isHit(e,t){let{subUnitId:r,row:i,col:a}=t,o=this._ensureMap(r).get(this._generateKey(i,a)),s=this._dataValidationModel.getRuleByLocation(t.unitId,t.subUnitId,i,a);if(!s||!o||s.renderMode===n.DataValidationRenderMode.TEXT)return!1;let{top:c,left:l,width:u,height:d}=o,{x:f,y:p}=e;return f>=l&&f<=l+u&&p>=c&&p<=c+d}onPointerDown(e,t){if(t.button===2)return;let{unitId:n,subUnitId:r,row:i,col:a}=e,o={unitId:n,subUnitId:r,row:i,column:a};this._commandService.executeCommand(N.id,o)}onPointerEnter(e,t){var r;(r=(0,s.getCurrentTypeOfRenderer)(n.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null||(r=r.mainComponent)==null||r.setCursor(s.CURSOR_TYPE.POINTER)}onPointerLeave(e,t){var r;(r=(0,s.getCurrentTypeOfRenderer)(n.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null||(r=r.mainComponent)==null||r.setCursor(s.CURSOR_TYPE.DEFAULT)}};xt=b([y(0,n.IUniverInstanceService),y(1,(0,n.Inject)(n.LocaleService)),y(2,n.ICommandService),y(3,(0,n.Inject)(s.IRenderManagerService)),y(4,(0,n.Inject)(i.SheetDataValidationModel))],xt);var St=class extends Z{constructor(...e){super(...e),v(this,`id`,n.DataValidationType.LIST),v(this,`canvasRender`,this.injector.createInstance(xt)),v(this,`dropdownType`,a.DataValidatorDropdownType.LIST),v(this,`optionsInput`,$e.componentKey),v(this,`formulaInput`,i.LIST_FORMULA_INPUT_NAME)}},Ct=class extends Z{constructor(...e){super(...e),v(this,`id`,n.DataValidationType.TEXT_LENGTH),v(this,`formulaInput`,i.BASE_FORMULA_INPUT_NAME)}},wt=class extends Z{constructor(...e){super(...e),v(this,`id`,n.DataValidationType.WHOLE),v(this,`formulaInput`,i.BASE_FORMULA_INPUT_NAME)}};let Tt=class extends n.RxDisposable{constructor(e,t){super(),this._injector=e,this._dataValidatorRegistryService=t,this._registerValidatorViews()}_registerValidatorViews(){[ft,wt,Ct,dt,lt,St,vt,ut].forEach(e=>{let 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)})}};Tt=b([y(0,(0,n.Inject)(n.Injector)),y(1,(0,n.Inject)(a.DataValidatorRegistryService))],Tt);let Q=class extends n.Plugin{constructor(e=C,t,r,i){super(),this._config=e,this._injector=t,this._commandService=r,this._configService=i;let{menu:a,...o}=(0,n.merge)({},C,this._config);a&&this._configService.setConfig(`menu`,a,{merge:!0}),this._configService.setConfig(S,o)}onStarting(){this._injector.add([J]),this._injector.get(J),[[x],[O],[et],[X],[at],[rt],[nt],[Tt]].forEach(e=>{this._injector.add(e)}),[R,I,L,N,P,j,A,M].forEach(e=>{this._commandService.registerCommand(e)})}onReady(){this._injector.get(nt),this._injector.get(rt),this._injector.get(s.IRenderManagerService).registerRenderModule(n.UniverInstanceType.UNIVER_SHEET,[st])}onRendered(){this._injector.get(Tt),this._injector.get(at)}onSteady(){this._injector.get(X)}};v(Q,`pluginName`,`SHEET_DATA_VALIDATION_UI_PLUGIN`),v(Q,`packageName`,ue),v(Q,`version`,de),v(Q,`type`,n.UniverInstanceType.UNIVER_SHEET),Q=b([y(1,(0,n.Inject)(n.Injector)),y(2,n.ICommandService),y(3,n.IConfigService)],Q);let $=class extends n.Plugin{constructor(e=C,t,r,i){super(),this._config=e,this._injector=t,this._commandService=r,this._configService=i;let{menu:a,...o}=(0,n.merge)({},C,this._config);a&&this._configService.setConfig(`menu`,a,{merge:!0}),this._configService.setConfig(S,o)}onStarting(){this._injector.add([J]),this._injector.get(J),[[x],[O],[et],[X],[at],[rt],[nt],[T],[Tt]].forEach(e=>{this._injector.add(e)}),[R,I,L,N,P,j,A,M].forEach(e=>{this._commandService.registerCommand(e)})}onReady(){this._injector.get(nt),this._injector.get(rt),this._injector.get(T),this._injector.get(et),this._injector.get(s.IRenderManagerService).registerRenderModule(n.UniverInstanceType.UNIVER_SHEET,[st])}onRendered(){this._injector.get(Tt),this._injector.get(at)}onSteady(){this._injector.get(X)}};v($,`pluginName`,`SHEET_DATA_VALIDATION_UI_PLUGIN`),v($,`packageName`,ue),v($,`version`,de),v($,`type`,n.UniverInstanceType.UNIVER_SHEET),$=b([(0,n.DependentOn)(i.UniverSheetsDataValidationPlugin),y(1,(0,n.Inject)(n.Injector)),y(2,n.ICommandService),y(3,n.IConfigService)],$),e.SheetsDataValidationUIMenuSchema=le,Object.defineProperty(e,"UniverSheetsDataValidationMobileUIPlugin",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(e,"UniverSheetsDataValidationUIPlugin",{enumerable:!0,get:function(){return $}})});
|
|
1
|
+
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("@univerjs/ui"),require("@univerjs/core"),require("@univerjs/sheets"),require("@univerjs/sheets-data-validation"),require("@univerjs/data-validation"),require("rxjs"),require("@univerjs/engine-render"),require("@univerjs/sheets-numfmt"),require("@univerjs/sheets-ui"),require("@univerjs/design"),require("react"),require("react/jsx-runtime"),require("@univerjs/engine-formula"),require("@univerjs/sheets-formula-ui")):typeof define==`function`&&define.amd?define([`exports`,`@univerjs/ui`,`@univerjs/core`,`@univerjs/sheets`,`@univerjs/sheets-data-validation`,`@univerjs/data-validation`,`rxjs`,`@univerjs/engine-render`,`@univerjs/sheets-numfmt`,`@univerjs/sheets-ui`,`@univerjs/design`,`react`,`react/jsx-runtime`,`@univerjs/engine-formula`,`@univerjs/sheets-formula-ui`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.UniverSheetsDataValidationUi={},e.UniverUi,e.UniverCore,e.UniverSheets,e.UniverSheetsDataValidation,e.UniverDataValidation,e.rxjs,e.UniverEngineRender,e.UniverSheetsNumfmt,e.UniverSheetsUi,e.UniverDesign,e.React,e.React,e.UniverEngineFormula,e.UniverSheetsFormulaUi))})(this,function(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});function h(e){"@babel/helpers - typeof";return h=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},h(e)}function g(e,t){if(h(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(h(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function _(e){var t=g(e,`string`);return h(t)==`symbol`?t:t+``}function v(e,t,n){return(t=_(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function y(e,t){return function(n,r){t(n,r,e)}}function b(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}let x=class extends n.Disposable{get activeRule(){return this._activeRule}get isOpen(){return this._open$.getValue()}constructor(e,t){super(),this._univerInstanceService=e,this._sidebarService=t,v(this,`_open$`,new o.BehaviorSubject(!1)),v(this,`open$`,this._open$.pipe((0,o.distinctUntilChanged)())),v(this,`_activeRule`,void 0),v(this,`_activeRule$`,new o.BehaviorSubject(void 0)),v(this,`activeRule$`,this._activeRule$.asObservable()),v(this,`_closeDisposable`,null),v(this,`_focusFormulaEditorActiveRuleSubUnitId`,null),this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(n.UniverInstanceType.UNIVER_SHEET).pipe((0,o.filter)(e=>!e)).subscribe(()=>{this.close()})),this.disposeWithMe(this._sidebarService.sidebarOptions$.subscribe(e=>{e.id===`DataValidationPanel`&&(e.visible||setTimeout(()=>{this._sidebarService.sidebarOptions$.next({visible:!1})}))}))}dispose(){var e;super.dispose(),this._open$.next(!1),this._open$.complete(),this._activeRule$.complete(),(e=this._closeDisposable)==null||e.dispose()}open(){this._open$.next(!0)}close(){var e;this._open$.next(!1),(e=this._closeDisposable)==null||e.dispose()}setCloseDisposable(e){this._closeDisposable=(0,n.toDisposable)(()=>{e.dispose(),this._closeDisposable=null})}setActiveRule(e){this._activeRule=e,this._activeRule$.next(e)}setFocusFormulaEditorActiveRuleSubUnitId(e){this._focusFormulaEditorActiveRuleSubUnitId=e}getFocusFormulaEditorActiveRuleSubUnitId(){return this._focusFormulaEditorActiveRuleSubUnitId}};x=b([y(0,n.IUniverInstanceService),y(1,t.ISidebarService)],x);let S=`sheets-data-validation-ui.config`,C={},w=`#ECECEC`,T=class extends n.Disposable{constructor(e,t,n,r,i,a){super(),this._sheetInterceptorService=e,this._dataValidationModel=t,this._dataValidatorRegistryService=n,this._dialogService=r,this._localeService=i,this._sheetsDataValidationValidatorService=a,this._initEditorBridgeInterceptor()}_initEditorBridgeInterceptor(){this.disposeWithMe(this._sheetInterceptorService.writeCellInterceptor.intercept(r.VALIDATE_CELL,{handler:async(e,t,r)=>{let i=await e,{row:a,col:o,unitId:s,subUnitId:c}=t,l=this._dataValidationModel.getRuleIdByLocation(s,c,a,o),f=l?this._dataValidationModel.getRuleById(s,c,l):void 0;if(i===!1)return r(Promise.resolve(!1));if(!f||f.errorStyle!==n.DataValidationErrorStyle.STOP)return r(Promise.resolve(!0));let p=this._dataValidatorRegistryService.getValidatorItem(f.type);return!p||await this._sheetsDataValidationValidatorService.validatorCell(s,c,a,o)===n.DataValidationStatus.VALID?r(Promise.resolve(!0)):(this._dialogService.open({width:368,title:{title:this._localeService.t(`sheets-data-validation-ui.alert.title`)},id:`reject-input-dialog`,children:{title:p.getRuleFinalError(f,{row:a,col:o,unitId:s,subUnitId:c})},footer:{title:(0,d.createElement)(u.Button,{variant:`primary`,onClick:()=>this._dialogService.close(`reject-input-dialog`)},this._localeService.t(`sheets-data-validation-ui.alert.ok`))},onClose:()=>{this._dialogService.close(`reject-input-dialog`)}}),r(Promise.resolve(!1)))}}))}showReject(e){this._dialogService.open({width:368,title:{title:this._localeService.t(`sheets-data-validation-ui.alert.title`)},id:`reject-input-dialog`,children:{title:e},footer:{title:(0,d.createElement)(u.Button,{variant:`primary`,onClick:()=>this._dialogService.close(`reject-input-dialog`)},this._localeService.t(`sheets-data-validation-ui.alert.ok`))},onClose:()=>{this._dialogService.close(`reject-input-dialog`)}})}};T=b([y(0,(0,n.Inject)(r.SheetInterceptorService)),y(1,(0,n.Inject)(i.SheetDataValidationModel)),y(2,(0,n.Inject)(a.DataValidatorRegistryService)),y(3,t.IDialogService),y(4,(0,n.Inject)(n.LocaleService)),y(5,(0,n.Inject)(i.SheetsDataValidationValidatorService))],T);let E=e=>{if(e==null||typeof e==`boolean`)return;if(e===``)return(0,n.dateKit)();if(typeof e==`number`||!Number.isNaN(+e))return(0,n.dateKit)(n.numfmt.format(`yyyy-MM-dd HH:mm:ss`,Number(e)));let t=(0,n.dateKit)(e);if(t.isValid())return t};function D(e,t){if(e===(0,c.getPatternType)(t))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 O=class extends n.Disposable{get activeDropdown(){return this._activeDropdown}constructor(e,t,n,r,i,a,s,c,l,u){super(),this._univerInstanceService=e,this._dataValidatorRegistryService=t,this._dataValidationModel=n,this._sheetsSelectionsService=r,this._cellDropdownManagerService=i,this._sheetDataValidationModel=a,this._commandService=s,this._editorBridgeService=c,this._injector=l,this._configService=u,v(this,`_activeDropdown`,void 0),v(this,`_activeDropdown$`,new o.Subject),v(this,`_currentPopup`,null),v(this,`activeDropdown$`,this._activeDropdown$.asObservable()),this._initSelectionChange(),this.disposeWithMe(()=>{this._activeDropdown$.complete()})}_getDropdownByCell(e,t,r,i){let a=e?this._univerInstanceService.getUnit(e,n.UniverInstanceType.UNIVER_SHEET):this._univerInstanceService.getCurrentUnitOfType(n.UniverInstanceType.UNIVER_SHEET);if(!a)return;let o=t?a.getSheetBySheetId(t):a.getActiveSheet();if(!o)return;let s=this._dataValidationModel.getRuleByLocation(a.getUnitId(),o.getSheetId(),r,i);if(!s)return;let c=this._dataValidatorRegistryService.getValidatorItem(s.type);return c==null?void 0:c.dropdownType}_initSelectionChange(){this.disposeWithMe(this._sheetsSelectionsService.selectionMoveEnd$.subscribe(e=>{e&&e.every(e=>!(e.primary&&this._getDropdownByCell(e.primary.unitId,e.primary.sheetId,e.primary.actualRow,e.primary.actualColumn)))&&this.hideDropdown()}))}showDropdown(e){let{location:o}=e,{row:c,col:u,unitId:d,subUnitId:f,workbook:p,worksheet:m}=o;this._currentPopup&&this._currentPopup.dispose(),this._activeDropdown=e,this._activeDropdown$.next(this._activeDropdown);let h=this._sheetDataValidationModel.getRuleByLocation(d,f,c,u);if(!h)return;let g=this._dataValidatorRegistryService.getValidatorItem(h.type);if(!(g!=null&&g.dropdownType))return;let _,v=async(e,i)=>{var a,o,_;if(!e)return!0;let v=e,y=m.getCell(c,u),b=v.format(i===`date`?`YYYY-MM-DD 00:00:00`:`YYYY-MM-DD HH:mm:ss`),x=(a=n.numfmt.parseDate(b))==null?void 0:a.v,S=i===`time`?x%1:x,C=p.getStyles().getStyleByCell(y),w=(o=C==null||(_=C.n)==null?void 0:_.pattern)==null?``:o;return h.errorStyle!==n.DataValidationErrorStyle.STOP||await g.validator({value:S,unitId:d,subUnitId:f,row:c,column:u,worksheet:m,workbook:p,interceptValue:b.replace(`Z`,``).replace(`T`,` `),t:n.CellValueType.NUMBER},h)?(await this._commandService.executeCommand(r.SetRangeValuesCommand.id,{unitId:d,subUnitId:f,range:{startColumn:u,endColumn:u,startRow:c,endRow:c},value:{v:S,t:2,p:null,f:null,si:null,s:{n:{pattern:D(i,w)}}}}),await this._commandService.executeCommand(l.SetCellEditVisibleOperation.id,{visible:!1,eventType:s.DeviceInputEventType.Keyboard,unitId:d,keycode:t.KeyCode.ESC}),!0):(this._injector.has(T)&&this._injector.get(T).showReject(g.getRuleFinalError(h,{row:c,col:u,unitId:d,subUnitId:f})),!1)},y;switch(g.dropdownType){case a.DataValidatorDropdownType.DATE:{var b;let e=E((0,i.getCellValueOrigin)(m.getCellRaw(c,u))),t=!!((b=h.bizInfo)!=null&&b.showTime);y={location:o,type:`datepicker`,props:{showTime:t,onChange:e=>v(e,t?`datetime`:`date`),defaultValue:e,patternType:`date`}};break}case a.DataValidatorDropdownType.TIME:y={location:o,type:`datepicker`,props:{onChange:e=>v(e,`time`),defaultValue:E((0,i.getCellValueOrigin)(m.getCellRaw(c,u))),patternType:`time`}};break;case a.DataValidatorDropdownType.DATETIME:y={location:o,type:`datepicker`,props:{onChange:e=>v(e,`datetime`),defaultValue:E((0,i.getCellValueOrigin)(m.getCellRaw(c,u))),patternType:`datetime`}};break;case a.DataValidatorDropdownType.LIST:case a.DataValidatorDropdownType.MULTIPLE_LIST:{var x,S,C,w;let e=g.dropdownType===a.DataValidatorDropdownType.MULTIPLE_LIST,p=async n=>{var i;let a=e?(0,r.serializeListOptions)(n):(i=n[0])==null?``:i,o={unitId:d,subUnitId:f,range:{startColumn:u,endColumn:u,startRow:c,endRow:c},value:{v:a,p:null,f:null,si:null}};return this._commandService.executeCommand(r.SetRangeValuesCommand.id,o),this._editorBridgeService.isVisible().visible&&await this._commandService.executeCommand(l.SetCellEditVisibleOperation.id,{visible:!1,eventType:s.DeviceInputEventType.Keyboard,unitId:d,keycode:t.KeyCode.ESC}),!e},v=(h==null?void 0:h.renderMode)===n.DataValidationRenderMode.CUSTOM||(h==null?void 0:h.renderMode)===void 0,b=g.getListWithColor(h,d,f),T=(0,i.getDataValidationCellValue)(m.getCellRaw(c,u));y={location:o,type:`list`,props:{onChange:e=>p(e),options:b.map(e=>({label:e.label,value:e.label,color:v||e.color?e.color||`#ECECEC`:`transparent`})),onEdit:()=>{this._commandService.executeCommand(A.id,{ruleId:h.uid}),_==null||_.dispose()},defaultValue:T,multiple:e,showEdit:(x=(S=this._configService.getConfig(`sheets-data-validation-ui.config`))==null?void 0:S.showEditOnDropdown)==null?!0:x,showSearch:(C=(w=this._configService.getConfig(`sheets-data-validation-ui.config`))==null?void 0:w.showSearchOnDropdown)==null?!0:C}};break}case a.DataValidatorDropdownType.CASCADE:var O;y={type:`cascader`,props:{onChange:e=>{let n={unitId:d,subUnitId:f,range:{startColumn:u,endColumn:u,startRow:c,endRow:c},value:{v:e.join(`/`),p:null,f:null,si:null}};return this._commandService.syncExecuteCommand(r.SetRangeValuesCommand.id,n),this._editorBridgeService.isVisible().visible&&this._commandService.syncExecuteCommand(l.SetCellEditVisibleOperation.id,{visible:!1,eventType:s.DeviceInputEventType.Keyboard,unitId:d,keycode:t.KeyCode.ESC}),!0},defaultValue:(0,i.getDataValidationCellValue)(m.getCellRaw(c,u)).split(`/`),options:JSON.parse((O=h.formula1)==null?`[]`:O)},location:o};break;case a.DataValidatorDropdownType.COLOR:y={type:`color`,props:{onChange:e=>{let n={unitId:d,subUnitId:f,range:{startColumn:u,endColumn:u,startRow:c,endRow:c},value:{v:e,p:null,f:null,si:null}};return this._commandService.syncExecuteCommand(r.SetRangeValuesCommand.id,n),this._editorBridgeService.isVisible().visible&&this._commandService.syncExecuteCommand(l.SetCellEditVisibleOperation.id,{visible:!1,eventType:s.DeviceInputEventType.Keyboard,unitId:d,keycode:t.KeyCode.ESC}),!0},defaultValue:(0,i.getDataValidationCellValue)(m.getCellRaw(c,u))},location:o};break;default:throw Error(`[DataValidationDropdownManagerService]: unknown type!`)}if(_=this._cellDropdownManagerService.showDropdown({...y,onHide:()=>{this._activeDropdown=null,this._activeDropdown$.next(null)}}),!_)throw Error(`[DataValidationDropdownManagerService]: cannot show dropdown!`);let k=new n.DisposableCollection;k.add(_),k.add({dispose:()=>{var e,t;(e=this._activeDropdown)==null||(t=e.onHide)==null||t.call(e)}}),this._currentPopup=k}hideDropdown(){this._activeDropdown&&(this._currentPopup&&this._currentPopup.dispose(),this._currentPopup=null,this._activeDropdown=null,this._activeDropdown$.next(null))}showDataValidationDropdown(e,t,r,i,a){let o=this._univerInstanceService.getUnit(e,n.UniverInstanceType.UNIVER_SHEET);if(!o)return;let s=o.getSheetBySheetId(t);if(!s)return;let c=this._dataValidationModel.getRuleByLocation(o.getUnitId(),s.getSheetId(),r,i);if(!c)return;let l=this._dataValidatorRegistryService.getValidatorItem(c.type);if(!l||!l.dropdownType){this.hideDropdown();return}this.showDropdown({location:{workbook:o,worksheet:s,row:r,col:i,unitId:e,subUnitId:t},onHide:a})}};O=b([y(0,n.IUniverInstanceService),y(1,(0,n.Inject)(a.DataValidatorRegistryService)),y(2,(0,n.Inject)(i.SheetDataValidationModel)),y(3,(0,n.Inject)(r.SheetsSelectionsService)),y(4,(0,n.Inject)(l.ISheetCellDropdownManagerService)),y(5,(0,n.Inject)(i.SheetDataValidationModel)),y(6,n.ICommandService),y(7,l.IEditorBridgeService),y(8,(0,n.Inject)(n.Injector)),y(9,n.IConfigService)],O);let k=`DataValidationPanel`,A={id:`data-validation.operation.open-validation-panel`,type:n.CommandType.OPERATION,handler(e,i){if(!i)return!1;let{ruleId:o,isAdd:s}=i,c=e.get(x),l=e.get(a.DataValidationModel),u=e.get(n.IUniverInstanceService),d=e.get(t.ISidebarService),f=(0,r.getSheetCommandTarget)(u);if(!f)return!1;let{unitId:p,subUnitId:m}=f,h=o?l.getRuleById(p,m,o):void 0;c.open(),c.setActiveRule(h&&{unitId:p,subUnitId:m,rule:h});let g=d.open({id:k,header:{title:s?`sheets-data-validation-ui.panel.addTitle`:`sheets-data-validation-ui.panel.title`},children:{label:k},width:312,onClose:()=>c.close()});return c.setCloseDisposable(g),!0}},j={id:`data-validation.operation.close-validation-panel`,type:n.CommandType.OPERATION,handler(e){return e.get(x).close(),!0}},M={id:`data-validation.operation.toggle-validation-panel`,type:n.CommandType.OPERATION,handler(e){let t=e.get(n.ICommandService),r=e.get(x);return r.open(),r.isOpen?t.executeCommand(j.id):t.executeCommand(A.id),!0}},N={type:n.CommandType.OPERATION,id:`sheet.operation.show-data-validation-dropdown`,handler(e,t){if(!t)return!1;let n=e.get(O),{unitId:r,subUnitId:i,row:a,column:o}=t,s=n.activeDropdown,c=s==null?void 0:s.location;return c&&c.unitId===r&&c.subUnitId===i&&c.row===a&&c.col===o||n.showDataValidationDropdown(r,i,a,o),!0}},P={type:n.CommandType.OPERATION,id:`sheet.operation.hide-data-validation-dropdown`,handler(e,t){return t?(e.get(O).hideDropdown(),!0):!1}};function F(e,t){let n=(0,i.createDefaultNewRule)(e);return{...n,...t,uid:n.uid,ranges:n.ranges}}let I={type:n.CommandType.COMMAND,id:`data-validation.command.insert-quick-rule`,handler(e,t){let a=(0,r.getSheetCommandTarget)(e.get(n.IUniverInstanceService)),o=e.get(r.SheetsSelectionsService).getCurrentSelections().map(e=>e.range);if(!a||!o.length||!(t!=null&&t.rule))return!1;let s=F(e,t.rule);return e.get(n.ICommandService).syncExecuteCommand(i.AddSheetDataValidationCommand.id,{unitId:a.workbook.getUnitId(),subUnitId:a.worksheet.getSheetId(),rule:s})}},L={type:n.CommandType.COMMAND,id:`data-validation.command.clear-quick-rule`,handler(e,t){var a;let o=(0,r.getSheetCommandTarget)(e.get(n.IUniverInstanceService)),s=e.get(r.SheetsSelectionsService).getCurrentSelections().map(e=>e.range);return!o||!s.length||!(!(t==null||(a=t.types)==null)&&a.length)?!1:e.get(n.ICommandService).syncExecuteCommand(i.ClearRangeDataValidationCommand.id,{unitId:o.workbook.getUnitId(),subUnitId:o.worksheet.getSheetId(),ranges:s,types:t.types})}},R={type:n.CommandType.COMMAND,id:`data-validation.command.addRuleAndOpen`,handler(e,t){let a=(0,r.getSheetCommandTarget)(e.get(n.IUniverInstanceService));if(!a)return!1;let{workbook:o,worksheet:s}=a;if(!e.get(r.SheetsSelectionsService).getCurrentSelections().length)return!1;let c=F(e,t==null?void 0:t.rule),l=e.get(n.ICommandService),u={rule:c,unitId:o.getUnitId(),subUnitId:s.getSheetId()};return l.syncExecuteCommand(i.AddSheetDataValidationCommand.id,u)?(l.syncExecuteCommand(A.id,{ruleId:c.uid,isAdd:!0}),!0):!1}},z=`SHEETS_DATA_VALIDATION_DROPDOWN_PRESETS`;function B({onChange:e}){let i=(0,t.useDependency)(n.LocaleService),a=[[i.t(`sheets-data-validation-ui.ribbon.presets.yes`),i.t(`sheets-data-validation-ui.ribbon.presets.no`)],[i.t(`sheets-data-validation-ui.ribbon.presets.notStarted`),i.t(`sheets-data-validation-ui.ribbon.presets.inProgress`),i.t(`sheets-data-validation-ui.ribbon.presets.completed`)],[`A`,`B`,`C`]];return(0,f.jsxs)(`div`,{className:`univer-box-border univer-w-[360px]`,children:[(0,f.jsx)(`div`,{className:`univer-px-2 univer-text-sm univer-font-semibold`,children:i.t(`sheets-data-validation-ui.ribbon.dropdownPresetTitle`)}),(0,f.jsx)(`div`,{className:`univer-mt-2 univer-grid univer-grid-cols-3 univer-gap-1.5`,children:a.map(t=>(0,f.jsx)(`button`,{type:`button`,"aria-label":t.join(` / `),className:`univer-flex univer-min-h-20 univer-cursor-pointer univer-flex-col univer-items-start univer-gap-1.5 univer-rounded-md univer-border-0 univer-bg-gray-50 univer-p-3 univer-text-left univer-text-sm univer-leading-5 univer-text-gray-900 univer-transition-colors hover:univer-bg-gray-100 focus-visible:univer-outline-none focus-visible:univer-ring-2 focus-visible:univer-ring-primary-600 focus-visible:univer-ring-offset-0 dark:!univer-bg-gray-800 dark:!univer-text-white dark:hover:!univer-bg-gray-700`,onClick:()=>e((0,r.serializeListOptions)(t)),children:t.map(e=>(0,f.jsx)(`span`,{className:`univer-w-full univer-break-words`,children:e},e))},t.join(`\0`)))}),(0,f.jsx)(u.Separator,{className:`univer-mt-2`})]})}let ee=`sheet.menu.data-validation`,V=`sheet.menu.quick-dropdown`,H=`sheet.menu.quick-date`,U={type:n.DataValidationType.CHECKBOX,operator:void 0,formula1:void 0,formula2:void 0},W={type:n.DataValidationType.DATE,operator:void 0,formula1:void 0,formula2:void 0},te={...W,bizInfo:{showTime:!0}};function G(e){return{type:n.DataValidationType.LIST,operator:void 0,formula1:e,formula2:``,renderMode:n.DataValidationRenderMode.CUSTOM}}function ne(e){return e===void 0?{}:{rule:G(String(e))}}function re(e){return{hidden$:(0,t.getMenuHiddenObservable)(e,n.UniverInstanceType.UNIVER_SHEET),disabled$:(0,l.getCurrentRangeDisable$)(e,{workbookTypes:[r.WorkbookEditablePermission],worksheetTypes:[r.WorksheetSetCellStylePermission,r.WorksheetEditPermission],rangeTypes:[r.RangeProtectionPermissionEditPoint]})}}function ie(e){return{id:ee,type:t.MenuItemType.SUBITEMS,icon:`DataValidationIcon`,tooltip:`sheets-data-validation-ui.title`,hidden$:(0,t.getMenuHiddenObservable)(e,n.UniverInstanceType.UNIVER_SHEET),disabled$:(0,l.getCurrentRangeDisable$)(e,{workbookTypes:[r.WorkbookEditablePermission],worksheetTypes:[r.WorksheetSetCellStylePermission,r.WorksheetEditPermission],rangeTypes:[r.RangeProtectionPermissionEditPoint]})}}function ae(e){return{id:I.id,type:t.MenuItemType.BUTTON_SELECTOR,icon:`CheckboxIcon`,tooltip:`sheets-data-validation-ui.checkbox.title`,params:{rule:U},selectionsCommandId:I.id,selections:[{label:`sheets-data-validation-ui.ribbon.setCheckbox`,value:n.DataValidationType.CHECKBOX,params:{rule:U}},{label:`sheets-data-validation-ui.ribbon.clearCheckbox`,id:L.id,value:n.DataValidationType.CHECKBOX,params:{types:[n.DataValidationType.CHECKBOX]}}],...re(e)}}function K(e){let i=e.get(n.LocaleService),a=(0,r.serializeListOptions)([i.t(`sheets-data-validation-ui.ribbon.presets.option1`),i.t(`sheets-data-validation-ui.ribbon.presets.option2`)]);return{id:V,type:t.MenuItemType.SUBITEMS,icon:`DropdownListIcon`,tooltip:`sheets-data-validation-ui.list.title`,selectionsCommandId:I.id,selections:[{label:{name:z,hoverable:!1,selectable:!1},params:ne},{id:R.id,label:`sheets-data-validation-ui.ribbon.editDropdown`,value:a,params:{rule:G(a)}},{id:L.id,label:`sheets-data-validation-ui.ribbon.clearDropdown`,value:n.DataValidationType.LIST,params:{types:[n.DataValidationType.LIST,n.DataValidationType.LIST_MULTIPLE]}}],...re(e)}}function oe(e){return{id:H,commandId:I.id,type:t.MenuItemType.BUTTON_SELECTOR,icon:`DatePickerIcon`,tooltip:`sheets-data-validation-ui.date.title`,params:{rule:W},selectionsCommandId:I.id,selections:[{label:`sheets-data-validation-ui.date.title`,value:n.DataValidationType.DATE,params:{rule:W}},{label:`sheets-data-validation-ui.ribbon.dateTime`,value:n.DataValidationType.DATE,params:{rule:te}},{id:R.id,label:`sheets-data-validation-ui.list.edit`,value:n.DataValidationType.DATE,params:{rule:W}},{id:L.id,label:`sheets-data-validation-ui.panel.removeRule`,value:n.DataValidationType.DATE,params:{types:[n.DataValidationType.DATE]}}],...re(e)}}function se(){return{id:A.id,title:`sheets-data-validation-ui.panel.title`,type:t.MenuItemType.BUTTON}}function ce(){return{id:R.id,title:`sheets-data-validation-ui.panel.add`,type:t.MenuItemType.BUTTON}}let le={[t.RibbonInsertGroup.CELL]:{[I.id]:{order:0,menuItemFactory:ae},[V]:{order:1,menuItemFactory:K},[H]:{order:2,menuItemFactory:oe}},[t.RibbonDataGroup.RULES]:{[ee]:{order:0,gridLayout:{row:1,column:1,showLabel:!0},menuItemFactory:ie,[A.id]:{order:0,menuItemFactory:se},[R.id]:{order:1,menuItemFactory:ce}}}};var ue=`@univerjs/sheets-data-validation-ui`,de=`1.0.0-alpha.7`;function q({ref:e,...t}){let{icon:n,id:r,className:i,extend:a,...o}=t,s=`univerjs-icon univerjs-icon-${r} ${i||``}`.trim(),c=(0,d.useRef)(`_${he()}`);return fe(n,`${r}`,{defIds:n.defIds,idSuffix:c.current},{ref:e,className:s,...o},a)}function fe(e,t,n,r,i){return(0,d.createElement)(e.tag,{key:t,...pe(e,n,i),...r},(me(e,n).children||[]).map((r,a)=>fe(r,`${t}-${e.tag}-${a}`,n,void 0,i)))}function pe(e,t,n){let r={...e.attrs};n!=null&&n.colorChannel1&&r.fill===`colorChannel1`&&(r.fill=n.colorChannel1),n!=null&&n.colorChannel1&&r.stroke===`colorChannel1`&&(r.stroke=n.colorChannel1),e.tag===`mask`&&r.id&&(r.id+=t.idSuffix),Object.entries(r).forEach(([e,n])=>{e===`mask`&&typeof n==`string`&&(r[e]=n.replace(/url\(#(.*)\)/,`url(#$1${t.idSuffix})`))});let{defIds:i}=t;return!i||i.length===0?r:(e.tag===`use`&&r[`xlink:href`]&&(r[`xlink:href`]+=t.idSuffix),Object.entries(r).forEach(([e,n])=>{typeof n==`string`&&(r[e]=n.replace(/url\(#(.*)\)/,`url(#$1${t.idSuffix})`))}),r)}function me(e,t){var n;let{defIds:r}=t;return!r||r.length===0?e:e.tag===`defs`&&(n=e.children)!=null&&n.length?{...e,children:e.children.map(e=>typeof e.attrs.id==`string`&&r&&r.includes(e.attrs.id)?{...e,attrs:{...e.attrs,id:e.attrs.id+t.idSuffix}}:e)}:e}function he(){return Math.random().toString(36).substring(2,8)}q.displayName=`UniverIcon`;let ge={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`rect`,attrs:{width:13,height:13,x:1.5,y:1.5,stroke:`currentColor`,rx:1.5,strokeWidth:1.2}},{tag:`path`,attrs:{stroke:`currentColor`,d:`M4.5 8L6.8 10.3L11.5 5.6`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:1.2}}]},_e=(0,d.forwardRef)(function(e,t){return(0,d.createElement)(q,Object.assign({},e,{id:`checkbox-icon`,ref:t,icon:ge}))});_e.displayName=`CheckboxIcon`;let ve={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`}}]},ye=(0,d.forwardRef)(function(e,t){return(0,d.createElement)(q,Object.assign({},e,{id:`data-validation-icon`,ref:t,icon:ve}))});ye.displayName=`DataValidationIcon`;let be={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`rect`,attrs:{width:13,height:12,x:1.5,y:2.5,stroke:`currentColor`,rx:1.5,strokeWidth:1.2}},{tag:`path`,attrs:{stroke:`currentColor`,d:`M1.5 6.5H14.5M5 1.5V4M11 1.5V4`,strokeLinecap:`round`,strokeWidth:1.2}},{tag:`path`,attrs:{stroke:`currentColor`,d:`M4.5 9H6M8 9H9.5M11.5 9H12M4.5 12H6M8 12H9.5`,strokeLinecap:`round`,strokeWidth:1.2}}]},xe=(0,d.forwardRef)(function(e,t){return(0,d.createElement)(q,Object.assign({},e,{id:`date-picker-icon`,ref:t,icon:be}))});xe.displayName=`DatePickerIcon`;let Se={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`}}]},Ce=(0,d.forwardRef)(function(e,t){return(0,d.createElement)(q,Object.assign({},e,{id:`delete-icon`,ref:t,icon:Se}))});Ce.displayName=`DeleteIcon`;let we={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:{stroke:`currentColor`,d:`M8 5.5H2C1.72386 5.5 1.5 5.27614 1.5 5V2C1.5 1.72386 1.72386 1.5 2 1.5H14C14.2761 1.5 14.5 1.72386 14.5 2V5C14.5 5.27614 14.2761 5.5 14 5.5H13`,strokeLinejoin:`round`,strokeWidth:1.2}},{tag:`path`,attrs:{stroke:`currentColor`,d:`M8.5 3.5L10.5 5.5L12.5 3.5`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:1.2}},{tag:`path`,attrs:{stroke:`currentColor`,d:`M2 7.5H14C14.2761 7.5 14.5 7.72386 14.5 8V14C14.5 14.2761 14.2761 14.5 14 14.5H2C1.72386 14.5 1.5 14.2761 1.5 14V8C1.5 7.72386 1.72386 7.5 2 7.5Z`,strokeLinejoin:`round`,strokeWidth:1.2}},{tag:`path`,attrs:{stroke:`currentColor`,d:`M3.5 9.5H9.5M3.5 12.5H7.5`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:1.2}}]},Te=(0,d.forwardRef)(function(e,t){return(0,d.createElement)(q,Object.assign({},e,{id:`dropdown-list-icon`,ref:t,icon:we}))});Te.displayName=`DropdownListIcon`;let Ee={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 20 20`,width:`1em`,height:`1em`},children:[{tag:`circle`,attrs:{cx:7,cy:5,r:1.1,fill:`currentColor`}},{tag:`circle`,attrs:{cx:13,cy:5,r:1.1,fill:`currentColor`}},{tag:`circle`,attrs:{cx:7,cy:10,r:1.1,fill:`currentColor`}},{tag:`circle`,attrs:{cx:13,cy:10,r:1.1,fill:`currentColor`}},{tag:`circle`,attrs:{cx:7,cy:15,r:1.1,fill:`currentColor`}},{tag:`circle`,attrs:{cx:13,cy:15,r:1.1,fill:`currentColor`}}]},De=(0,d.forwardRef)(function(e,t){return(0,d.createElement)(q,Object.assign({},e,{id:`grip-vertical-icon`,ref:t,icon:Ee}))});De.displayName=`GripVerticalIcon`;let Oe={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`}}]},ke=(0,d.forwardRef)(function(e,t){return(0,d.createElement)(q,Object.assign({},e,{id:`increase-icon`,ref:t,icon:Oe}))});ke.displayName=`IncreaseIcon`;let Ae={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`}}]},je=(0,d.forwardRef)(function(e,t){return(0,d.createElement)(q,Object.assign({},e,{id:`more-down-icon`,ref:t,icon:Ae}))});je.displayName=`MoreDownIcon`;let Me={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`}}]},Ne=(0,d.forwardRef)(function(e,t){return(0,d.createElement)(q,Object.assign({},e,{id:`more-up-icon`,ref:t,icon:Me}))});Ne.displayName=`MoreUpIcon`;function Pe(e){var r;let i=(0,t.useDependency)(n.LocaleService),a=(0,t.useDependency)(t.ComponentManager),{value:o,onChange:s,extraComponent:c}=e,[l,p]=(0,d.useState)(!1),m=c?a.get(c):null;return(0,f.jsxs)(f.Fragment,{children:[(0,f.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:()=>p(!l),children:[i.t(`sheets-data-validation-ui.panel.options`),l?(0,f.jsx)(Ne,{className:`univer-ml-1`}):(0,f.jsx)(je,{className:`univer-ml-1`})]}),l&&(0,f.jsxs)(f.Fragment,{children:[m?(0,f.jsx)(m,{value:o,onChange:s}):null,(0,f.jsx)(u.FormLayout,{label:i.t(`sheets-data-validation-ui.panel.invalid`),children:(0,f.jsxs)(u.RadioGroup,{value:`${(r=o.errorStyle)==null?n.DataValidationErrorStyle.WARNING:r}`,onChange:e=>s({...o,errorStyle:+e}),children:[(0,f.jsx)(u.Radio,{value:`${n.DataValidationErrorStyle.WARNING}`,children:i.t(`sheets-data-validation-ui.panel.showWarning`)}),(0,f.jsx)(u.Radio,{value:`${n.DataValidationErrorStyle.STOP}`,children:i.t(`sheets-data-validation-ui.panel.rejectInput`)})]})}),(0,f.jsx)(u.FormLayout,{label:i.t(`sheets-data-validation-ui.panel.messageInfo`),children:(0,f.jsx)(u.Checkbox,{checked:o.showErrorMessage,onChange:()=>s({...o,showErrorMessage:!o.showErrorMessage}),children:i.t(`sheets-data-validation-ui.panel.showInfo`)})}),o.showErrorMessage?(0,f.jsx)(u.FormLayout,{children:(0,f.jsx)(u.Input,{value:o.error,onChange:e=>s({...o,error:e})})}):null]})]})}let Fe=e=>(0,n.debounce)(async(t,n,r,i)=>{let a=await e.executeCommand(t,n,r);i==null||i(a)},1e3);function Ie(e,t,r){var i;if(t){var a;return((a=e.getUnit(t))==null||(a=a.getSheetBySheetName(r))==null?void 0:a.getSheetId())||``}return((i=e.getCurrentUnitOfType(n.UniverInstanceType.UNIVER_SHEET))==null||(i=i.getSheetBySheetName(r))==null?void 0:i.getSheetId())||``}function Le(){let e=(0,t.useDependency)(x),{unitId:n,subUnitId:r,rule:i}=(0,t.useObservable)(e.activeRule$,e.activeRule)||{};return!n||!r||!i?null:(0,f.jsx)(Re,{activeRuleInfo:{unitId:n,subUnitId:r,rule:i}})}function Re(e){var s,c;let[l,h]=(0,d.useState)(0),g=(0,t.useDependency)(x),{unitId:_,subUnitId:v,rule:y}=e.activeRuleInfo,b=y.uid,S=(0,t.useDependency)(a.DataValidatorRegistryService),C=(0,t.useDependency)(n.IUniverInstanceService),w=(0,t.useDependency)(t.ComponentManager),T=(0,t.useDependency)(n.ICommandService),E=(0,t.useDependency)(a.DataValidationModel),D=(0,t.useDependency)(n.LocaleService),O=(0,t.useObservable)(()=>C.getCurrentTypeOfUnit$(n.UniverInstanceType.UNIVER_SHEET),void 0,void 0,[]),k=(0,t.useObservable)(()=>{var e;return(e=O==null?void 0:O.activeSheet$)==null?(0,o.of)(null):e},void 0,void 0,[]),[A,j]=(0,d.useState)(y),M=S.getValidatorItem(A.type),[N,P]=(0,d.useState)(!1),F=S.getValidatorsByScope(a.DataValidatorRegistryScope.SHEET),[I,L]=(0,d.useState)(()=>A.ranges.map(e=>({unitId:``,sheetId:``,range:e}))),R=(0,d.useMemo)(()=>Fe(T),[T]),[z,B]=(0,d.useState)(!1),[ee,V]=(0,d.useState)(!1),H=(0,d.useRef)(null),U=(0,t.useDependency)(r.SheetsSelectionsService);(0,d.useEffect)(()=>()=>{let e=U.getCurrentLastSelection();e&&U.setSelections([e])},[U]),(0,d.useEffect)(()=>{let e,t=T.onCommandExecuted(t=>{(t.id===n.UndoCommand.id||t.id===n.RedoCommand.id)&&(e!==void 0&&clearTimeout(e),e=setTimeout(()=>{let e=E.getRuleById(_,v,b);h(e=>e+1),e&&(j(e),L(e.ranges.map(e=>({unitId:``,sheetId:``,range:e}))))},20))});return()=>{t.dispose(),e!==void 0&&clearTimeout(e)}},[T,E,b,v,_]);let W=(0,t.useEvent)(e=>{let t=e.split(`,`).filter(Boolean).map(p.deserializeRangeWithSheet).map(e=>{let t=e.sheetName;if(t){let n=Ie(C,e.unitId,t);return{...e,sheetId:n}}return{...e,sheetId:``}});if((0,n.isUnitRangesEqual)(t,I))return;L(t);let r=t.filter(e=>(!e.unitId||e.unitId===_)&&(!e.sheetId||e.sheetId===v)).map(e=>e.range);if(j({...A,ranges:r}),r.length===0)return;let a={unitId:_,subUnitId:v,ruleId:b,ranges:r};R(i.UpdateSheetDataValidationRangeCommand.id,a)}),te=(0,d.useMemo)(()=>I.map(e=>(0,p.serializeRange)(e.range)).join(`,`),[]);if(!M)return null;let G=M.operators,ne=M.operatorNames,re=A.operator?a.TWO_FORMULA_OPERATOR_COUNT.includes(A.operator):!1,ie=()=>{(k==null?void 0:k.getSheetId())!==v&&T.syncExecuteCommand(r.SetWorksheetActiveOperation.id,{unitId:_,subUnitId:v})},ae=()=>{var e;if(!((e=H.current)==null||(e=e.editor)==null)&&e.isFocus()){var t;W((t=H.current)==null?void 0:t.getValue())}!A.ranges.length||z||(M.validatorFormula(A,_,v).success?g.setActiveRule(null):P(!0),ie())},K=e=>{if((0,n.shallowEqual)(e,(0,a.getRuleSetting)(A)))return;j({...A,...e});let t={unitId:_,subUnitId:v,ruleId:b,setting:e};R(i.UpdateSheetDataValidationSettingCommand.id,t,void 0)},oe=async()=>{await T.executeCommand(i.RemoveSheetDataValidationCommand.id,{ruleId:b,unitId:_,subUnitId:v}),g.setActiveRule(null),ie()},se={type:A.type,operator:A.operator,formula1:A.formula1,formula2:A.formula2,allowBlank:A.allowBlank},ce=e=>{let t=S.getValidatorItem(e);if(!t)return;let n=t.operators,r=E.getRuleById(_,v,b),o=e===(r==null?void 0:r.type)||e.includes(`list`)&&r!=null&&r.type.includes(`list`)?{...r,type:e}:{...A,type:e,operator:n[0],formula1:void 0,formula2:void 0};j(o),T.executeCommand(i.UpdateSheetDataValidationSettingCommand.id,{unitId:_,subUnitId:v,ruleId:A.uid,setting:(0,a.getRuleSetting)(o)})},le=w.get(M.formulaInput),ue=(0,a.getRuleOptions)(A),de=e=>{(0,n.shallowEqual)(e,(0,a.getRuleOptions)(A))||(j({...A,...e}),R(i.UpdateSheetDataValidationOptionsCommand.id,{unitId:_,subUnitId:v,ruleId:b,options:e}))},q=G.length&&!A.operator;return(0,f.jsxs)(`div`,{"data-u-comp":`data-validation-detail`,className:`univer-py-2`,children:[(0,f.jsx)(u.FormLayout,{label:D.t(`sheets-data-validation-ui.panel.range`),error:!A.ranges.length||z?D.t(`sheets-data-validation-ui.panel.rangeError`):``,children:(0,f.jsx)(m.RangeSelector,{selectorRef:H,unitId:_,subUnitId:v,initialValue:te,onChange:(e,t)=>{var n;!ee&&(n=H.current)!=null&&n.verify()&&W(t)},onFocusChange:(e,t)=>{var n;V(e),!e&&t&&(n=H.current)!=null&&n.verify()&&W(t)},onVerify:e=>B(!e)})}),(0,f.jsx)(u.FormLayout,{label:D.t(`sheets-data-validation-ui.panel.type`),children:(0,f.jsx)(u.Select,{className:`univer-w-full`,value:A.type,options:F==null||(s=F.sort((e,t)=>e.order-t.order))==null?void 0:s.map(e=>({label:D.t(e.title),value:e.id})),onChange:ce})}),G!=null&&G.length?(0,f.jsx)(u.FormLayout,{label:D.t(`sheets-data-validation-ui.panel.operator`),children:(0,f.jsx)(u.Select,{className:`univer-w-full`,value:`${A.operator}`,options:[{value:``,label:D.t(`sheets-data-validation-ui.operators.legal`)},...G.map((e,t)=>({value:`${e}`,label:ne[t]}))],onChange:e=>{K({...se,operator:e})}})}):null,le&&!q?(0,f.jsx)(le,{isTwoFormula:re,value:{formula1:A.formula1,formula2:A.formula2},onChange:e=>{K({...se,...e})},showError:N,validResult:M.validatorFormula(A,_,v),unitId:_,subUnitId:v,ruleId:b},l+A.type):null,(0,f.jsx)(u.FormLayout,{children:(0,f.jsx)(u.Checkbox,{checked:(c=A.allowBlank)==null?!0:c,onChange:()=>{var e;return K({...se,allowBlank:!((e=A.allowBlank)==null||e)})},children:D.t(`sheets-data-validation-ui.panel.allowBlank`)})}),(0,f.jsx)(Pe,{value:ue,onChange:de,extraComponent:M.optionsInput}),(0,f.jsxs)(`div`,{className:`univer-mt-5 univer-flex univer-flex-row univer-justify-end`,children:[(0,f.jsx)(u.Button,{className:`univer-ml-3`,onClick:oe,children:D.t(`sheets-data-validation-ui.panel.removeRule`)}),(0,f.jsx)(u.Button,{className:`univer-ml-3`,variant:`primary`,onClick:ae,children:D.t(`sheets-data-validation-ui.panel.done`)})]})]})}let ze=e=>{let{rule:r,onClick:o,unitId:s,subUnitId:c,disable:m}=e,h=(0,t.useDependency)(a.DataValidatorRegistryService),g=(0,t.useDependency)(n.ICommandService),_=(0,t.useDependency)(l.IMarkSelectionService),v=h.getValidatorItem(r.type),y=(0,d.useRef)(void 0),[b,x]=(0,d.useState)(!1),S=(0,t.useDependency)(n.ThemeService),C=(0,d.useMemo)(()=>{var e;let t=S.getColorFromTheme(`primary.600`),r=S.getColorFromTheme(`loop-color.2`),i=(e=S.getColorFromTheme(r))==null?t:e,a=new n.ColorKit(i).toRgb();return{fill:`rgba(${a.r}, ${a.g}, ${a.b}, 0.1)`,stroke:i}},[(0,t.useObservable)(S.currentTheme$)]);return(0,d.useEffect)(()=>()=>{if(y.current){var e;(e=y.current)==null||e.forEach(e=>{e&&_.removeShape(e)})}},[_]),(0,f.jsxs)(`div`,{className:(0,u.clsx)(`univer-bg-secondary univer-relative univer--mx-2 univer-box-border univer-flex univer-w-[287px] univer-cursor-pointer univer-flex-col univer-justify-between univer-overflow-hidden univer-rounded-md univer-p-2 univer-pr-9`,{"hover:univer-bg-gray-50 dark:hover:!univer-bg-gray-700":!m,"univer-opacity-50":m}),onClick:o,onMouseEnter:()=>{m||(x(!0),y.current=r.ranges.map(e=>_.addShape({range:e,style:C,primary:null})))},onMouseLeave:()=>{var e;x(!1),(e=y.current)==null||e.forEach(e=>{e&&_.removeShape(e)}),y.current=void 0},children:[(0,f.jsx)(`div`,{className:`univer-truncate univer-text-sm univer-font-medium univer-leading-[22px] univer-text-gray-900 dark:!univer-text-white`,children:v==null?void 0:v.generateRuleName(r)}),(0,f.jsx)(`div`,{className:`univer-text-secondary univer-truncate univer-text-xs univer-leading-[18px] dark:!univer-text-gray-300`,children:r.ranges.map(e=>(0,p.serializeRange)(e)).join(`,`)}),b&&(0,f.jsx)(`div`,{className:`univer-absolute univer-right-2 univer-top-[19px] univer-flex univer-size-5 univer-items-center univer-justify-center univer-rounded hover:univer-bg-gray-200 dark:!univer-text-gray-300 dark:hover:!univer-bg-gray-700`,onClick:e=>{g.executeCommand(i.RemoveSheetDataValidationCommand.id,{ruleId:r.uid,unitId:s,subUnitId:c}),e.stopPropagation()},children:(0,f.jsx)(Ce,{})})]})};function Be(e){let a=(0,t.useDependency)(i.SheetDataValidationModel),s=(0,t.useDependency)(n.IUniverInstanceService),c=(0,t.useDependency)(n.ICommandService),l=(0,t.useDependency)(n.Injector),d=(0,t.useDependency)(x),p=(0,t.useDependency)(n.LocaleService),{workbook:m}=e,h=(0,t.useObservable)(m.activeSheet$,void 0,!0),g=m.getUnitId(),_=h==null?void 0:h.getSheetId(),v=(0,t.useObservable)(()=>a.ruleChange$.pipe((0,o.filter)(e=>e.unitId===g&&e.subUnitId===_),(0,o.map)(()=>a.getRules(g,_)),(0,o.startWith)(a.getRules(g,_))),[],!1,[a,_,g]),y=async()=>{let e=(0,i.createDefaultNewRule)(l),t={unitId:g,subUnitId:_,rule:e};await c.executeCommand(i.AddSheetDataValidationCommand.id,t),d.setActiveRule({unitId:g,subUnitId:_,rule:e})},b=()=>{c.executeCommand(i.RemoveSheetAllDataValidationCommand.id,{unitId:g,subUnitId:_})},S=(e=>{let t=s.getCurrentUnitOfType(n.UniverInstanceType.UNIVER_SHEET),i=t.getActiveSheet(),a=t.getUnitId(),o=i.getSheetId();return e.map(e=>(0,r.checkRangesEditablePermission)(l,a,o,e.ranges)?{...e}:{...e,disable:!0})})(v),C=S==null?void 0:S.some(e=>e.disable);return(0,f.jsxs)(`div`,{className:`univer-pb-4`,children:[S==null?void 0:S.map(e=>{var t;return(0,f.jsx)(ze,{unitId:g,subUnitId:_,onClick:()=>{e.disable||d.setActiveRule({unitId:g,subUnitId:_,rule:e})},rule:e,disable:(t=e.disable)==null?!1:t},e.uid)}),(0,f.jsxs)(`div`,{className:`univer-mt-4 univer-flex univer-flex-row univer-justify-end univer-gap-2`,children:[v.length&&!C?(0,f.jsx)(u.Button,{onClick:b,children:p.t(`sheets-data-validation-ui.panel.removeAll`)}):null,(0,f.jsx)(u.Button,{variant:`primary`,onClick:y,children:p.t(`sheets-data-validation-ui.panel.add`)})]})]})}let Ve=()=>{let e=(0,t.useDependency)(x),r=(0,t.useObservable)(e.activeRule$,e.activeRule),i=(0,t.useDependency)(n.IUniverInstanceService),a=(0,t.useObservable)(()=>i.getCurrentTypeOfUnit$(n.UniverInstanceType.UNIVER_SHEET),void 0,void 0,[]),s=(0,t.useObservable)(()=>{var e;return(e=a==null?void 0:a.activeSheet$)==null?(0,o.of)(null):e},void 0,void 0,[]);return!a||!s?null:r&&(r.subUnitId===s.getSheetId()||r.subUnitId===e.getFocusFormulaEditorActiveRuleSubUnitId())?(0,f.jsx)(Le,{},r.rule.uid):(0,f.jsx)(Be,{workbook:a})};function He(e){var r;let{value:i,onChange:a}=e,o=(0,t.useDependency)(n.LocaleService);return(0,f.jsx)(u.FormLayout,{children:(0,f.jsx)(u.Checkbox,{checked:(r=i.bizInfo)==null?void 0:r.showTime,onChange:e=>{a({...i,bizInfo:{...i.bizInfo,showTime:e}})},children:o.t(`sheets-data-validation-ui.showTime.label`)})})}He.componentKey=`DATE_SHOW_TIME_OPTION`;let Ue=e=>{let{isTwoFormula:r=!1,value:i,onChange:a,showError:o,validResult:s}=e,c=(0,t.useDependency)(n.LocaleService),l=o?s==null?void 0:s.formula1:``,d=o?s==null?void 0:s.formula2:``;return r?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(u.FormLayout,{error:l,children:(0,f.jsx)(u.Input,{className:`univer-w-full`,placeholder:c.t(`sheets-data-validation-ui.panel.formulaPlaceholder`),value:i==null?void 0:i.formula1,onChange:e=>{a==null||a({...i,formula1:e})}})}),(0,f.jsx)(`div`,{className:`-univer-mt-2 univer-mb-1 univer-text-sm univer-text-gray-400`,children:c.t(`sheets-data-validation-ui.panel.formulaAnd`)}),(0,f.jsx)(u.FormLayout,{error:d,children:(0,f.jsx)(u.Input,{className:`univer-w-full`,placeholder:c.t(`sheets-data-validation-ui.panel.formulaPlaceholder`),value:i==null?void 0:i.formula2,onChange:e=>{a==null||a({...i,formula2:e})}})})]}):(0,f.jsx)(u.FormLayout,{error:l,children:(0,f.jsx)(u.Input,{className:`univer-w-full`,placeholder:c.t(`sheets-data-validation-ui.panel.formulaPlaceholder`),value:i==null?void 0:i.formula1,onChange:e=>{a==null||a({formula1:e})}})})};function We(e){let{value:r,onChange:i,showError:a,validResult:o}=e,s=(0,t.useDependency)(n.LocaleService),c=a?o==null?void 0:o.formula1:``,l=a?o==null?void 0:o.formula2:``,[p,m]=(0,d.useState)(!((r==null?void 0:r.formula1)===void 0&&(r==null?void 0:r.formula2)===void 0));return(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(u.FormLayout,{children:(0,f.jsx)(u.Checkbox,{checked:p,onChange:e=>{e?m(!0):(m(!1),i==null||i({...r,formula1:void 0,formula2:void 0}))},children:s.t(`sheets-data-validation-ui.checkbox.tips`)})}),p?(0,f.jsx)(u.FormLayout,{label:s.t(`sheets-data-validation-ui.checkbox.checked`),error:c,children:(0,f.jsx)(u.Input,{className:`univer-w-full`,placeholder:s.t(`sheets-data-validation-ui.panel.valuePlaceholder`),value:r==null?void 0:r.formula1,onChange:e=>{i==null||i({...r,formula1:e||void 0})}})}):null,p?(0,f.jsx)(u.FormLayout,{label:s.t(`sheets-data-validation-ui.checkbox.unchecked`),error:l,children:(0,f.jsx)(u.Input,{className:`univer-w-full`,placeholder:s.t(`sheets-data-validation-ui.panel.valuePlaceholder`),value:r==null?void 0:r.formula2,onChange:e=>{i==null||i({...r,formula2:e||void 0})}})}):null]})}function Ge(e){var n;let{unitId:r,subUnitId:i,value:a,onChange:o,showError:s,validResult:c}=e,l=s?c==null?void 0:c.formula1:void 0,p=(0,d.useRef)(null),[h,g]=(0,d.useState)(!1);return(0,t.useSidebarClick)(e=>{var t;(t=p.current)!=null&&t.isClickOutSide(e)&&g(!1)}),(0,f.jsx)(u.FormLayout,{error:l,children:(0,f.jsx)(m.FormulaEditor,{ref:p,className:(0,u.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`,u.borderClassName),initValue:(n=a==null?void 0:a.formula1)==null?`=`:n,unitId:r,subUnitId:i,isFocus:h,isSupportAcrossSheet:!0,onChange:e=>{let t=(e==null?``:e).trim();t!==(a==null?void 0:a.formula1)&&(o==null||o({...a,formula1:t}))},onFocus:()=>g(!0)})})}function Ke(e,t){let n=new Set,i=[];return e.forEach(e=>{!e.label||n.has(e.label)||(n.add(e.label),i.push(e))}),{formula1:(0,r.serializeListOptions)(i.map(e=>e.label)),formula2:i.map(e=>e.color===t?``:e.color).join(`,`)}}let qe=[`#FFFFFF`,`#FEE7E7`,`#FEF0E6`,`#EFFBD0`,`#E4F4FE`,`#E8ECFD`,`#F1EAFA`,`#FDE8F3`,`#E5E5E5`,`#FDCECE`,`#FDC49B`,`#DEF6A2`,`#9FDAFF`,`#D0D9FB`,`#E3D5F6`,`#FBD0E8`,`#656565`,`#FE4B4B`,`#FF8C51`,`#8BBB11`,`#0B9EFB`,`#3A60F7`,`#9E6DE3`,`#F248A6`],Je=e=>{let{value:t,onChange:n,disabled:r}=e,[i,a]=(0,d.useState)(!1);return(0,f.jsx)(u.Dropdown,{align:`start`,disabled:r,open:i,onOpenChange:a,overlay:(0,f.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:qe.map(e=>(0,f.jsx)(`div`,{className:(0,u.clsx)(`univer-box-border univer-size-4 univer-cursor-pointer univer-rounded`,u.borderClassName),style:{background:e},onClick:()=>{n(e),a(!1)}},e))}),children:(0,f.jsxs)(`div`,{className:(0,u.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`,u.borderClassName),children:[(0,f.jsx)(`div`,{className:`univer-box-border univer-size-4 univer-rounded univer-text-base`,style:{background:t}}),(0,f.jsx)(je,{})]})})},Ye=e=>{let{item:t,commonProps:n,className:r}=e,{onItemChange:i,onItemDelete:a}=n;return(0,f.jsxs)(`div`,{className:(0,u.clsx)(`univer-flex univer-items-center univer-gap-2`,r),children:[!t.isRef&&(0,f.jsx)(`div`,{className:(0,u.clsx)(`univer-cursor-move`,`draggableHandle`),children:(0,f.jsx)(De,{})}),(0,f.jsx)(Je,{value:t.color,onChange:e=>{i(t.id,t.label,e)}}),(0,f.jsx)(u.Input,{disabled:t.isRef,value:t.label,onChange:e=>{i(t.id,e,t.color)}}),t.isRef?null:(0,f.jsx)(`div`,{className:`univer-ml-1 univer-cursor-pointer univer-rounded univer-text-base hover:univer-bg-gray-200`,children:(0,f.jsx)(Ce,{onClick:()=>a(t.id)})})]})},Xe=()=>{};function Ze(e){let{value:s,onChange:c=Xe,unitId:l,subUnitId:p,validResult:h,showError:g,ruleId:_}=e,{formula1:v=``,formula2:y=``}=s||{},[b,S]=(0,d.useState)(()=>(0,n.isFormulaString)(v)?`1`:`0`),[C,T]=(0,d.useState)(b===`1`?v:`=`),[E,D]=(0,d.useState)(b===`1`?v:`=`),O=(0,t.useDependency)(n.LocaleService),k=(0,t.useDependency)(a.DataValidatorRegistryService),A=(0,t.useDependency)(a.DataValidationModel),j=(0,t.useDependency)(i.DataValidationFormulaController),M=(0,t.useDependency)(x),[N,P]=(0,d.useState)(()=>y.split(`,`)),F=k.getValidatorItem(n.DataValidationType.LIST),[I,L]=(0,d.useState)([]),[R,z]=(0,d.useState)(``),B=g?h==null?void 0:h.formula1:``,ee=(0,t.useObservable)((0,d.useMemo)(()=>A.ruleChange$.pipe((0,o.debounceTime)(16)),[])),V=(0,t.useEvent)(c);(0,d.useEffect)(()=>{let e=!1,t=setTimeout(()=>{let t=A.getRuleById(l,p,_);(0,n.isFormulaString)(t==null?void 0:t.formula1)&&F&&t&&F.getListAsync(t,l,p).then(t=>{e||L(t)})},100);return()=>{e=!0,clearTimeout(t)}},[A,ee,F,_,p,l]),(0,d.useEffect)(()=>{(0,n.isFormulaString)(v)&&v!==E&&(T(v),D(v))},[E,v]);let[H,U]=(0,d.useState)(()=>{let e=b===`1`?[]:(0,r.deserializeListOptions)(v),t=y.split(`,`);return e.map((e,r)=>({label:e,color:t[r]||`#ECECEC`,isRef:!1,id:(0,n.generateRandomId)(4)}))}),W=(e,t,n)=>{let r=H.find(t=>t.id===e);r&&(r.label=t,r.color=n,U([...H]))},te=e=>{let t=H.findIndex(t=>t.id===e);t!==-1&&(H.splice(t,1),U([...H]))},G=(0,d.useMemo)(()=>I.map((e,t)=>({label:e,color:N[t]||`#ECECEC`,id:`${t}`,isRef:!0})),[N,I]),ne=(e,t,n)=>{let r=[...N];r[+e]=n,P(r),V({formula1:v,formula2:r.join(`,`)})},re=()=>{U([...H,{label:``,color:w,isRef:!1,id:(0,n.generateRandomId)(4)}])};(0,d.useEffect)(()=>{b!==`1`&&V(Ke(H,w))},[H,V,b]);let ie=(0,t.useEvent)(async e=>{if(!(0,n.isFormulaString)(e)){V==null||V({formula1:``,formula2:y});return}j.getFormulaRefCheck(e)?(V==null||V({formula1:(0,n.isFormulaString)(e)?e:``,formula2:y}),z(``)):(V==null||V({formula1:``,formula2:y}),T(`=`),z(O.t(`sheets-data-validation-ui.validFail.formulaError`)))}),ae=(0,d.useRef)(null),[K,oe]=(0,d.useState)(!1);return(0,t.useSidebarClick)(e=>{var t;(t=ae.current)!=null&&t.isClickOutSide(e)&&oe(!1)}),(0,d.useEffect)(()=>{K?M.setFocusFormulaEditorActiveRuleSubUnitId(p):M.setFocusFormulaEditorActiveRuleSubUnitId(null)},[K,p,M]),(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(u.FormLayout,{label:O.t(`sheets-data-validation-ui.list.options`),children:(0,f.jsxs)(u.RadioGroup,{value:b,onChange:e=>{S(e),T(E),e===`1`&&V({formula1:E===`=`?``:E,formula2:N.join(`,`)})},children:[(0,f.jsx)(u.Radio,{value:`0`,children:O.t(`sheets-data-validation-ui.list.customOptions`)}),(0,f.jsx)(u.Radio,{value:`1`,children:O.t(`sheets-data-validation-ui.list.refOptions`)})]})}),b===`1`?(0,f.jsxs)(u.FormLayout,{error:B||R||void 0,children:[(0,f.jsx)(m.FormulaEditor,{ref:ae,className:(0,u.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`,u.borderClassName),initValue:C,unitId:l,subUnitId:p,isFocus:K,isSupportAcrossSheet:!0,onFocus:()=>oe(!0),onChange:(e=``)=>{let t=(e==null?``:e).trim();D(t),ie(t)}}),G.length>0&&(0,f.jsx)(`div`,{className:`univer-mt-3`,children:G.map(e=>(0,f.jsx)(Ye,{className:`univer-mb-3`,item:e,commonProps:{onItemChange:ne}},e.id))})]}):(0,f.jsx)(u.FormLayout,{error:B,children:(0,f.jsxs)(`div`,{children:[(0,f.jsx)(u.DraggableList,{list:H,onListChange:U,rowHeight:28,margin:[0,12],draggableHandle:`.draggableHandle`,itemRender:e=>(0,f.jsx)(Ye,{item:e,commonProps:{onItemChange:W,onItemDelete:te}},e.id),idKey:`id`}),(0,f.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:re,children:[(0,f.jsx)(ke,{className:`univer-mr-1`}),O.t(`sheets-data-validation-ui.list.add`)]})]})})]})}let Qe=[[i.CUSTOM_FORMULA_INPUT_NAME,Ge],[i.BASE_FORMULA_INPUT_NAME,Ue],[i.LIST_FORMULA_INPUT_NAME,Ze],[i.CHECKBOX_FORMULA_INPUT_NAME,We]];function $e(e){var r;let{value:i,onChange:a}=e,o=(0,t.useDependency)(n.LocaleService);return(0,f.jsx)(u.FormLayout,{label:o.t(`sheets-data-validation-ui.renderMode.label`),children:(0,f.jsxs)(u.RadioGroup,{value:`${(r=i.renderMode)==null?n.DataValidationRenderMode.CUSTOM:r}`,onChange:e=>a({...i,renderMode:+e}),children:[(0,f.jsx)(u.Radio,{value:`${n.DataValidationRenderMode.CUSTOM}`,children:o.t(`sheets-data-validation-ui.renderMode.chip`)}),(0,f.jsx)(u.Radio,{value:`${n.DataValidationRenderMode.ARROW}`,children:o.t(`sheets-data-validation-ui.renderMode.arrow`)}),(0,f.jsx)(u.Radio,{value:`${n.DataValidationRenderMode.TEXT}`,children:o.t(`sheets-data-validation-ui.renderMode.text`)})]})})}$e.componentKey=`LIST_RENDER_MODE_OPTION_INPUT`;let J=class extends n.Disposable{constructor(e,t){super(),this._componentManager=e,this._iconManager=t,this._registerIcons(),this._registerComponents()}_registerIcons(){this.disposeWithMe(this._iconManager.register({CheckboxIcon:_e,DataValidationIcon:ye,DatePickerIcon:xe,DropdownListIcon:Te}))}_registerComponents(){[[k,Ve],[$e.componentKey,$e],[He.componentKey,He],[z,B],...Qe].forEach(([e,t])=>{this.disposeWithMe(this._componentManager.register(e,t))})}};J=b([y(0,(0,n.Inject)(t.ComponentManager)),y(1,(0,n.Inject)(t.IconManager))],J);let Y=`SHEET_DATA_VALIDATION_ALERT`,et=class extends n.Disposable{constructor(e,t,n,r,i){super(),this._hoverManagerService=e,this._cellAlertManagerService=t,this._univerInstanceService=n,this._localeService=r,this._dataValidationModel=i,this._init()}_init(){this._initCellAlertPopup()}_initCellAlertPopup(){this.disposeWithMe(this._hoverManagerService.currentCell$.pipe((0,o.debounceTime)(100)).subscribe(e=>{if(e){let r=this._univerInstanceService.getUnit(e.location.unitId,n.UniverInstanceType.UNIVER_SHEET),i=r.getSheetBySheetId(e.location.subUnitId);if(!i)return;let a=this._dataValidationModel.getRuleByLocation(e.location.unitId,e.location.subUnitId,e.location.row,e.location.col);if(!a){this._cellAlertManagerService.removeAlert(Y);return}if(this._dataValidationModel.validator(a,{...e.location,workbook:r,worksheet:i})===n.DataValidationStatus.INVALID){var t;let n=this._cellAlertManagerService.currentAlert.get(Y),r=n==null||(t=n.alert)==null?void 0:t.location;if(r&&r.row===e.location.row&&r.col===e.location.col&&r.subUnitId===e.location.subUnitId&&r.unitId===e.location.unitId){this._cellAlertManagerService.removeAlert(Y);return}let i=this._dataValidationModel.getValidator(a.type);if(!i){this._cellAlertManagerService.removeAlert(Y);return}this._cellAlertManagerService.showAlert({type:l.CellAlertType.ERROR,title:this._localeService.t(`sheets-data-validation-ui.error.title`),message:i==null?void 0:i.getRuleFinalError(a,e.location),location:e.location,width:200,height:74,key:Y});return}}this._cellAlertManagerService.removeAlert(Y)}))}};et=b([y(0,(0,n.Inject)(l.HoverManagerService)),y(1,(0,n.Inject)(l.CellAlertManagerService)),y(2,n.IUniverInstanceService),y(3,(0,n.Inject)(n.LocaleService)),y(4,(0,n.Inject)(i.SheetDataValidationModel))],et);let X=class extends n.Disposable{constructor(e,t,n){super(),this._autoFillService=e,this._sheetDataValidationModel=t,this._injector=n,this._initAutoFill()}_initAutoFill(){let e=()=>({redos:[],undos:[]}),t=(e,t)=>{let{source:a,target:o,unitId:s,subUnitId:c}=e,u=this._sheetDataValidationModel.getRuleObjectMatrix(s,c).clone(),d=(0,l.virtualizeDiscreteRanges)([a,o]),[f,p]=d.ranges,{mapFunc:m}=d,h={row:f.startRow,col:f.startColumn},g=r.AutoFillTools.getAutoFillRepeatRange(f,p),_=new n.ObjectMatrix,v=new Set;g.forEach(e=>{let t=e.repeatStartCell,r=e.relativeRange,i={startRow:h.row,startColumn:h.col,endColumn:h.col,endRow:h.row},a={startRow:t.row,startColumn:t.col,endColumn:t.col,endRow:t.row};n.Range.foreach(r,(e,t)=>{let r=n.Rectangle.getPositionRange({startRow:e,startColumn:t,endColumn:t,endRow:e},i),{row:o,col:l}=m(r.startRow,r.startColumn),u=this._sheetDataValidationModel.getRuleIdByLocation(s,c,o,l)||``,d=n.Rectangle.getPositionRange({startRow:e,startColumn:t,endColumn:t,endRow:e},a),{row:f,col:p}=m(d.startRow,d.startColumn);_.setValue(f,p,u),v.add(u)})});let y=Array.from(v).map(e=>({id:e,ranges:(0,n.queryObjectMatrix)(_,t=>t===e)}));u.addRangeRules(y);let{redoMutations:b,undoMutations:x}=(0,i.getDataValidationDiffMutations)(s,c,u.diff(this._sheetDataValidationModel.getRules(s,c)),this._injector,`patched`,t===r.AUTO_FILL_APPLY_TYPE.ONLY_FORMAT);return{undos:x,redos:b}},a={id:i.DATA_VALIDATION_PLUGIN_NAME,onBeforeFillData:e=>{let{source:t,unitId:i,subUnitId:a}=e;for(let e of t.rows)for(let o of t.cols){let t=this._sheetDataValidationModel.getRuleByLocation(i,a,e,o);if(t&&t.type===n.DataValidationType.CHECKBOX){this._autoFillService.setDisableApplyType(r.AUTO_FILL_APPLY_TYPE.SERIES,!0);return}}},onFillData:(n,i,a)=>a===r.AUTO_FILL_APPLY_TYPE.COPY||a===r.AUTO_FILL_APPLY_TYPE.ONLY_FORMAT||a===r.AUTO_FILL_APPLY_TYPE.SERIES?t(n,a):e(),onAfterFillData:()=>{}};this.disposeWithMe(this._autoFillService.addHook(a))}};X=b([y(0,r.IAutoFillService),y(1,(0,n.Inject)(i.SheetDataValidationModel)),y(2,(0,n.Inject)(n.Injector))],X);let tt=[l.PREDEFINED_HOOK_NAME_PASTE.SPECIAL_PASTE_COL_WIDTH,l.PREDEFINED_HOOK_NAME_PASTE.SPECIAL_PASTE_VALUE,l.PREDEFINED_HOOK_NAME_PASTE.SPECIAL_PASTE_FORMAT,l.PREDEFINED_HOOK_NAME_PASTE.SPECIAL_PASTE_FORMULA],nt=class extends n.Disposable{constructor(e,t,n,r){super(),this._sheetClipboardService=e,this._sheetDataValidationModel=t,this._injector=n,this._univerInstanceService=r,v(this,`_copyInfo`,void 0),this._initCopyPaste()}_initCopyPaste(){this._sheetClipboardService.addClipboardHook({id:i.DATA_VALIDATION_PLUGIN_NAME,onBeforeCopy:(e,t,n)=>this._collect(e,t,n),onPasteCells:(e,t,n,r)=>!e||!this._copyInfo||tt.includes(r.pasteType)?{redos:[],undos:[]}:this._generateMutations(e,t,r)})}_collect(e,t,i){let a=new n.ObjectMatrix;this._copyInfo={unitId:e,subUnitId:t,matrix:a};let o=this._injector.invoke(n=>(0,r.rangeToDiscreteRange)(i,n,e,t));if(!o)return;let{rows:s,cols:c}=o;s.forEach((n,r)=>{c.forEach((i,o)=>{let s=this._sheetDataValidationModel.getRuleIdByLocation(e,t,n,i);a.setValue(r,o,s==null?``:s)})})}_generateMutations(e,t,a){let{unitId:o,subUnitId:s,range:c}=e,{unitId:u,subUnitId:d,range:f}=t,{copyType:p=l.COPY_TYPE.COPY}=a;if(!(0,r.getSheetCommandTarget)(this._univerInstanceService,{unitId:u,subUnitId:d}))return{redos:[],undos:[]};if(p===l.COPY_TYPE.CUT&&u===o&&d===s)return this._copyInfo=null,{redos:[],undos:[]};if(u!==o||d!==s){let e=this._sheetDataValidationModel.getRuleObjectMatrix(u,d).clone(),t=new n.ObjectMatrix,r=new Set,{ranges:[a,m],mapFunc:h}=(0,l.virtualizeDiscreteRanges)([c,f]),g=(0,l.getRepeatRange)(a,m,!0),_=new Map;g.forEach(({startRange:e})=>{var i;(i=this._copyInfo)==null||i.matrix.forValue((i,a,c)=>{let l=n.Rectangle.getPositionRange({startRow:i,endRow:i,startColumn:a,endColumn:a},e),f=`${s}-${c}`,p=this._sheetDataValidationModel.getRuleById(o,s,c);!this._sheetDataValidationModel.getRuleById(u,d,f)&&p&&_.set(f,{...p,uid:f});let{row:m,col:g}=h(l.startRow,l.startColumn);r.add(f),t.setValue(m,g,f)})});let v=Array.from(r).map(e=>({id:e,ranges:(0,n.queryObjectMatrix)(t,t=>t===e)}));e.addRangeRules(v);let{redoMutations:y,undoMutations:b}=(0,i.getDataValidationDiffMutations)(u,d,e.diffWithAddition(this._sheetDataValidationModel.getRules(u,d),_.values()),this._injector,`patched`,!1);if(p===l.COPY_TYPE.CUT){let e=this._sheetDataValidationModel.getRuleObjectMatrix(o,s).clone(),t=h(a.startRow,a.startColumn),n=h(a.endRow,a.endColumn);e.addRangeRules([{id:``,ranges:[{startRow:t.row,endRow:n.row,startColumn:t.col,endColumn:n.col}]}]);let{redoMutations:r,undoMutations:c}=(0,i.getDataValidationDiffMutations)(o,s,e.diff(this._sheetDataValidationModel.getRules(o,s)),this._injector,`patched`,!1);y.push(...r),b.push(...c)}return{redos:y,undos:b}}else{let e=this._sheetDataValidationModel.getRuleObjectMatrix(o,s).clone(),t=new n.ObjectMatrix,r=new Set,{ranges:[a,p],mapFunc:m}=(0,l.virtualizeDiscreteRanges)([c,f]);(0,l.getRepeatRange)(a,p,!0).forEach(({startRange:e})=>{var i;(i=this._copyInfo)==null||i.matrix.forValue((i,a,o)=>{let s=n.Rectangle.getPositionRange({startRow:i,endRow:i,startColumn:a,endColumn:a},e),{row:c,col:l}=m(s.startRow,s.startColumn);t.setValue(c,l,o),r.add(o)})});let h=Array.from(r).map(e=>({id:e,ranges:(0,n.queryObjectMatrix)(t,t=>t===e)}));e.addRangeRules(h);let{redoMutations:g,undoMutations:_}=(0,i.getDataValidationDiffMutations)(u,d,e.diff(this._sheetDataValidationModel.getRules(o,s)),this._injector,`patched`,!1);return{redos:g,undos:_}}}};nt=b([y(0,l.ISheetClipboardService),y(1,(0,n.Inject)(i.SheetDataValidationModel)),y(2,(0,n.Inject)(n.Injector)),y(3,(0,n.Inject)(n.IUniverInstanceService))],nt);let rt=class extends n.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){let{unitId:t,subUnitId:n,rule:{ranges:i}}=e.params;this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[r.WorkbookEditablePermission],rangeTypes:[r.RangeProtectionPermissionEditPoint],worksheetTypes:[r.WorksheetEditPermission,r.WorksheetSetCellStylePermission]},i,t,n)||this._sheetPermissionCheckController.blockExecuteWithoutPermission(this._localeService.t(`sheets-data-validation-ui.permission.dialog.setStyleErr`))}if(e.id===i.UpdateSheetDataValidationRangeCommand.id){let{unitId:t,subUnitId:n,ranges:i}=e.params;this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[r.WorkbookEditablePermission],rangeTypes:[r.RangeProtectionPermissionEditPoint],worksheetTypes:[r.WorksheetEditPermission,r.WorksheetSetCellStylePermission]},i,t,n)||this._sheetPermissionCheckController.blockExecuteWithoutPermission(this._localeService.t(`sheets-data-validation-ui.permission.dialog.setStyleErr`))}}))}};rt=b([y(0,(0,n.Inject)(n.LocaleService)),y(1,n.ICommandService),y(2,(0,n.Inject)(r.SheetPermissionCheckController))],rt);let it={tr:{size:6,color:`#fe4b4b`}},at=class extends n.RxDisposable{constructor(e,t,n,r,i,a,o,s,c,l,u){super(),this._commandService=e,this._menuManagerService=t,this._renderManagerService=n,this._univerInstanceService=r,this._autoHeightController=i,this._dropdownManagerService=a,this._sheetDataValidationModel=o,this._dataValidatorRegistryService=s,this._sheetInterceptorService=c,this._dataValidationCacheService=l,this._editorBridgeService=u,this._initMenu(),this._initDropdown(),this._initViewModelIntercept(),this._initAutoHeight()}_initMenu(){this._menuManagerService.mergeMenu(le)}_initDropdown(){this._editorBridgeService&&this.disposeWithMe(this._editorBridgeService.visible$.subscribe(e=>{if(!e.visible){var t;((t=this._dropdownManagerService.activeDropdown)==null?void 0:t.trigger)===`editor-bridge`&&this._dropdownManagerService.hideDropdown();return}let n=this._editorBridgeService.getEditCellState();if(n){let{unitId:e,sheetId:t,row:r,column:i}=n,a=this._univerInstanceService.getUniverSheetInstance(e);if(!a)return;let o=this._sheetDataValidationModel.getRuleByLocation(e,t,r,i);if(!o)return;let s=this._dataValidatorRegistryService.getValidatorItem(o.type);if(!(s!=null&&s.dropdownType))return;let c=a.getActiveSheet();if(!c)return;let l=this._dropdownManagerService.activeDropdown,u=l==null?void 0:l.location;if(u&&u.unitId===e&&u.subUnitId===t&&u.row===r&&u.col===i)return;this._dropdownManagerService.showDropdown({location:{unitId:e,subUnitId:t,row:r,col:i,workbook:a,worksheet:c},trigger:`editor-bridge`,closeOnOutSide:!1})}}))}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(r.INTERCEPTOR_POINT.CELL_CONTENT,{effect:n.InterceptorEffectEnum.Style,priority:r.InterceptCellContentPriority.DATA_VALIDATION,handler:(e,t,r)=>{var a,o,s,c,u;let{row:d,col:f,unitId:p,subUnitId:m,workbook:h,worksheet:g}=t,_=this._sheetDataValidationModel.getRuleIdByLocation(p,m,d,f);if(!_)return r(e);let v=this._sheetDataValidationModel.getRuleById(p,m,_);if(!v)return r(e);let y=(a=this._dataValidationCacheService.getValue(p,m,d,f))==null?n.DataValidationStatus.VALID:a,b=this._dataValidatorRegistryService.getValidatorItem(v.type),x=t.rawData,S,C={get value(){var e;return S===void 0&&(S=(e=(0,i.getCellValueOrigin)(x))==null?null:e),S}},w={get value(){var e;return`${(e=C.value)==null?``:e}`}};return(!e||e===t.rawData)&&(e={...t.rawData}),e.markers={...e==null?void 0:e.markers,...y===n.DataValidationStatus.INVALID?it:null},e.customRender=[...(o=e==null?void 0:e.customRender)==null?[]:o,...b!=null&&b.canvasRender?[b.canvasRender]:[]],e.fontRenderExtension={...e==null?void 0:e.fontRenderExtension,isSkip:(e==null||(s=e.fontRenderExtension)==null?void 0:s.isSkip)||(b==null||(c=b.skipDefaultFontRender)==null?void 0:c.call(b,v,C.value,t))},e.interceptorStyle={...e==null?void 0:e.interceptorStyle,...b==null?void 0:b.getExtraStyle(v,w.value,{get style(){let t=h.getStyles();return(typeof(e==null?void 0:e.s)==`string`?t.get(e==null?void 0:e.s):e==null?void 0:e.s)||{}}},d,f)},e.interceptorAutoHeight=()=>{var t,n,r,i,a;let o=(t=this._renderManagerService.getRenderById(p))==null||(t=t.with(l.SheetSkeletonManagerService).getSkeletonParam(m))==null?void 0:t.skeleton;if(!o)return;let s=o.worksheet.getMergedCell(d,f),c={data:e,style:o.getStyles().getStyleByCell(e),primaryWithCoord:o.getCellWithCoordByIndex((n=s==null?void 0:s.startRow)==null?d:n,(r=s==null?void 0:s.startColumn)==null?f:r),unitId:p,subUnitId:m,row:d,col:f,workbook:h,worksheet:g};return b==null||(i=b.canvasRender)==null||(a=i.calcCellAutoHeight)==null?void 0:a.call(i,c)},e.interceptorAutoWidth=()=>{var t,n,r,i,a;let o=(t=this._renderManagerService.getRenderById(p))==null||(t=t.with(l.SheetSkeletonManagerService).getSkeletonParam(m))==null?void 0:t.skeleton;if(!o)return;let s=o.worksheet.getMergedCell(d,f),c={data:e,style:o.getStyles().getStyleByCell(e),primaryWithCoord:o.getCellWithCoordByIndex((n=s==null?void 0:s.startRow)==null?d:n,(r=s==null?void 0:s.startColumn)==null?f:r),unitId:p,subUnitId:m,row:d,col:f,workbook:h,worksheet:g};return b==null||(i=b.canvasRender)==null||(a=i.calcCellAutoWidth)==null?void 0:a.call(i,c)},e.coverable=((u=e==null?void 0:e.coverable)==null?!0:u)&&!(v.type===n.DataValidationType.LIST||v.type===n.DataValidationType.LIST_MULTIPLE),r(e)}}))}_initAutoHeight(){this._sheetDataValidationModel.ruleChange$.pipe((0,o.filter)(e=>e.source===`command`),(0,o.bufferTime)(100)).subscribe(e=>{if(e.length===0)return;let t=[];e.forEach(e=>{if(e.rule.type===n.DataValidationType.LIST_MULTIPLE||e.rule.type===n.DataValidationType.LIST){var r;(r=e.rule)!=null&&r.ranges&&t.push(...e.rule.ranges)}}),t.length&&(0,n.sequenceExecute)(this._autoHeightController.getUndoRedoParamsOfAutoHeight(t).redos,this._commandService)})}};at=b([y(0,n.ICommandService),y(1,t.IMenuManagerService),y(2,s.IRenderManagerService),y(3,n.IUniverInstanceService),y(4,(0,n.Inject)(l.AutoHeightController)),y(5,(0,n.Inject)(O)),y(6,(0,n.Inject)(i.SheetDataValidationModel)),y(7,(0,n.Inject)(a.DataValidatorRegistryService)),y(8,(0,n.Inject)(r.SheetInterceptorService)),y(9,(0,n.Inject)(i.DataValidationCacheService)),y(10,(0,n.Optional)(l.IEditorBridgeService))],at);let ot=class extends n.RxDisposable{constructor(e,t,n,r,i,a,o){super(),this._commandService=e,this._renderManagerService=t,this._autoHeightController=n,this._dataValidatorRegistryService=r,this._sheetInterceptorService=i,this._sheetDataValidationModel=a,this._dataValidationCacheService=o,this._initViewModelIntercept(),this._initAutoHeight()}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(r.INTERCEPTOR_POINT.CELL_CONTENT,{effect:n.InterceptorEffectEnum.Style,priority:r.InterceptCellContentPriority.DATA_VALIDATION,handler:(e,t,r)=>{var a,o,s,c,u;let{row:d,col:f,unitId:p,subUnitId:m,workbook:h,worksheet:g}=t,_=this._sheetDataValidationModel.getRuleIdByLocation(p,m,d,f);if(!_)return r(e);let v=this._sheetDataValidationModel.getRuleById(p,m,_);if(!v)return r(e);let y=(a=this._dataValidationCacheService.getValue(p,m,d,f))==null?n.DataValidationStatus.VALID:a,b=this._dataValidatorRegistryService.getValidatorItem(v.type),x=(0,i.getCellValueOrigin)(g.getCellRaw(d,f)),S=`${x==null?``:x}`;return(!e||e===t.rawData)&&(e={...t.rawData}),e.markers={...e==null?void 0:e.markers,...y===n.DataValidationStatus.INVALID?it:null},e.customRender=[...(o=e==null?void 0:e.customRender)==null?[]:o,...b!=null&&b.canvasRender?[b.canvasRender]:[]],e.fontRenderExtension={...e==null?void 0:e.fontRenderExtension,isSkip:(e==null||(s=e.fontRenderExtension)==null?void 0:s.isSkip)||(b==null||(c=b.skipDefaultFontRender)==null?void 0:c.call(b,v,x,t))},e.interceptorStyle={...e==null?void 0:e.interceptorStyle,...b==null?void 0:b.getExtraStyle(v,S,{get style(){let t=h.getStyles();return(typeof(e==null?void 0:e.s)==`string`?t.get(e==null?void 0:e.s):e==null?void 0:e.s)||{}}},d,f)},e.interceptorAutoHeight=()=>{var t,n,r,i,a;let o=(t=this._renderManagerService.getRenderById(p))==null||(t=t.with(l.SheetSkeletonManagerService).getSkeletonParam(m))==null?void 0:t.skeleton;if(!o)return;let s=o.worksheet.getMergedCell(d,f),c={data:e,style:o.getStyles().getStyleByCell(e),primaryWithCoord:o.getCellWithCoordByIndex((n=s==null?void 0:s.startRow)==null?d:n,(r=s==null?void 0:s.startColumn)==null?f:r),unitId:p,subUnitId:m,row:d,col:f,workbook:h,worksheet:g};return b==null||(i=b.canvasRender)==null||(a=i.calcCellAutoHeight)==null?void 0:a.call(i,c)},e.interceptorAutoWidth=()=>{var t,n,r,i,a;let o=(t=this._renderManagerService.getRenderById(p))==null||(t=t.with(l.SheetSkeletonManagerService).getSkeletonParam(m))==null?void 0:t.skeleton;if(!o)return;let s=o.worksheet.getMergedCell(d,f),c={data:e,style:o.getStyles().getStyleByCell(e),primaryWithCoord:o.getCellWithCoordByIndex((n=s==null?void 0:s.startRow)==null?d:n,(r=s==null?void 0:s.startColumn)==null?f:r),unitId:p,subUnitId:m,row:d,col:f,workbook:h,worksheet:g};return b==null||(i=b.canvasRender)==null||(a=i.calcCellAutoWidth)==null?void 0:a.call(i,c)},e.coverable=((u=e==null?void 0:e.coverable)==null?!0:u)&&!(v.type===n.DataValidationType.LIST||v.type===n.DataValidationType.LIST_MULTIPLE),r(e)}}))}_initAutoHeight(){this._sheetDataValidationModel.ruleChange$.pipe((0,o.filter)(e=>e.source===`command`),(0,o.bufferTime)(16)).subscribe(e=>{let t=[];e.forEach(e=>{if(e.rule.type===n.DataValidationType.LIST_MULTIPLE||e.rule.type===n.DataValidationType.LIST){var r;(r=e.rule)!=null&&r.ranges&&t.push(...e.rule.ranges)}}),t.length&&(0,n.sequenceExecute)(this._autoHeightController.getUndoRedoParamsOfAutoHeight(t).redos,this._commandService)})}};ot=b([y(0,n.ICommandService),y(1,s.IRenderManagerService),y(2,(0,n.Inject)(l.AutoHeightController)),y(3,(0,n.Inject)(a.DataValidatorRegistryService)),y(4,(0,n.Inject)(r.SheetInterceptorService)),y(5,(0,n.Inject)(i.SheetDataValidationModel)),y(6,(0,n.Inject)(i.DataValidationCacheService))],ot);let st=class extends n.Disposable{constructor(e,t,n){super(),this._context=e,this._sheetDataValidationModel=t,this._sheetSkeletonManagerService=n,this._initSkeletonChange()}_initSkeletonChange(){this.disposeWithMe(this._sheetDataValidationModel.validStatusChange$.pipe((0,n.bufferDebounceTime)(16)).subscribe(e=>{var t;if(!e.length)return;let n=new Set;e.forEach(e=>{n.add(e.subUnitId)}),n.forEach(e=>{var t;(t=this._sheetSkeletonManagerService.getSkeletonParam(e))==null||t.skeleton.makeDirty(!0)}),(t=this._context.mainComponent)==null||t.makeForceDirty()}))}};st=b([y(1,(0,n.Inject)(i.SheetDataValidationModel)),y(2,(0,n.Inject)(l.SheetSkeletonManagerService))],st);let ct=class{_calc(e,t){var r,i,a;let{vt:o,ht:s}=t||{},c=e.endX-e.startX-12,l=e.endY-e.startY,u=((r=t==null?void 0:t.fs)==null?10:r)*1.6,d=0,f=0;switch(o){case n.VerticalAlign.TOP:f=0;break;case n.VerticalAlign.BOTTOM:f=0+(l-u);break;default:f=0+(l-u)/2;break}switch(s){case n.HorizontalAlign.LEFT:d=6;break;case n.HorizontalAlign.RIGHT:d=6+(c-u);break;default:d=6+(c-u)/2;break}return{left:e.startX+d,top:e.startY+f,width:((i=t==null?void 0:t.fs)==null?10:i)*1.6,height:((a=t==null?void 0:t.fs)==null?10:a)*1.6}}constructor(e,t,n,r,i,a){this._commandService=e,this._univerInstanceService=t,this._formulaService=n,this._themeService=r,this._renderManagerService=i,this._dataValidationModel=a}calcCellAutoHeight(e){var t;let{style:n}=e;return((t=n==null?void 0:n.fs)==null?10:t)*1.6}calcCellAutoWidth(e){var t;let{style:n}=e;return((t=n==null?void 0:n.fs)==null?10:t)*1.6}async _parseFormula(e,t,r){var a,o,s;let{formula1:c=i.CHECKBOX_FORMULA_1,formula2:l=i.CHECKBOX_FORMULA_2}=e,u=await this._formulaService.getRuleFormulaResult(t,r,e.uid),d=(0,i.getFormulaResult)(u==null||(a=u[0])==null||(a=a.result)==null||(a=a[0])==null?void 0:a[0]),f=(0,i.getFormulaResult)(u==null||(o=u[1])==null||(o=o.result)==null||(o=o[0])==null?void 0:o[0]),p=(0,i.isLegalFormulaResult)(String(d))&&(0,i.isLegalFormulaResult)(String(f));return{formula1:(0,n.isFormulaString)(c)?(0,i.getFormulaResult)(u==null||(s=u[0])==null||(s=s.result)==null||(s=s[0])==null?void 0:s[0]):c,formula2:(0,n.isFormulaString)(l)?f:l,isFormulaValid:p}}drawWith(e,t){var n,r,a,o;let{style:c,primaryWithCoord:l,unitId:u,subUnitId:d,worksheet:f,row:p,col:m}=t,h=l.isMergedMainCell?l.mergeInfo:l,g=(0,i.getCellValueOrigin)(f.getCellRaw(p,m)),_=this._dataValidationModel.getRuleByLocation(u,d,p,m);if(!_)return;let v=this._dataValidationModel.getValidator(_.type);if(!v||!((n=v.skipDefaultFontRender)!=null&&n.call(v,_,g,{unitId:u,subUnitId:d,row:p,column:m})))return;let{formula1:y}=v.parseFormulaSync(_,u,d),b=this._calc(h,c),{a:x,d:S}=e.getTransform(),C=(0,s.fixLineWidthByScale)(b.left,x),w=(0,s.fixLineWidthByScale)(b.top,S),T=s.Transform.create().composeMatrix({left:C,top:w,scaleX:1,scaleY:1,angle:0,skewX:0,skewY:0,flipX:!1,flipY:!1}),E=h.endX-h.startX,D=h.endY-h.startY;e.save(),e.beginPath(),e.rect(h.startX,h.startY,E,D),e.clip();let O=T.getMatrix();e.transform(O[0],O[1],O[2],O[3],O[4],O[5]);let k=((r=c==null?void 0:c.fs)==null?10:r)*1.6,A=String(g)===String(y),j=this._themeService.getColorFromTheme(`primary.600`);s.CheckboxShape.drawWith(e,{checked:A,width:k,height:k,fill:(a=c==null||(o=c.cl)==null?void 0:o.rgb)==null?j:a}),e.restore()}isHit(e,t){let n=t.primaryWithCoord.isMergedMainCell?t.primaryWithCoord.mergeInfo:t.primaryWithCoord,r=this._calc(n,t.style),i=r.top,a=r.top+r.height,o=r.left,s=r.left+r.width,{x:c,y:l}=e;return c<=s&&c>=o&&l<=a&&l>=i}async onPointerDown(e,t){var n;if(t.button===2)return;let{primaryWithCoord:a,unitId:o,subUnitId:s,worksheet:c,row:l,col:u}=e,d=(0,i.getCellValueOrigin)(c.getCellRaw(l,u)),f=this._dataValidationModel.getRuleByLocation(o,s,l,u);if(!f)return;let p=this._dataValidationModel.getValidator(f.type);if(!p||!((n=p.skipDefaultFontRender)!=null&&n.call(p,f,d,{unitId:o,subUnitId:s,row:l,column:u})))return;let{formula1:m,formula2:h}=await this._parseFormula(f,o,s),g={range:{startColumn:a.actualColumn,endColumn:a.actualColumn,startRow:a.actualRow,endRow:a.actualRow},value:{v:String(d)===(0,i.transformCheckboxValue)(String(m))?h:m,p:null}};this._commandService.executeCommand(r.SetRangeValuesCommand.id,g)}onPointerEnter(e,t){var r;(r=(0,s.getCurrentTypeOfRenderer)(n.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null||(r=r.mainComponent)==null||r.setCursor(s.CURSOR_TYPE.POINTER)}onPointerLeave(e,t){var r;(r=(0,s.getCurrentTypeOfRenderer)(n.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null||(r=r.mainComponent)==null||r.setCursor(s.CURSOR_TYPE.DEFAULT)}};ct=b([y(0,n.ICommandService),y(1,n.IUniverInstanceService),y(2,(0,n.Inject)(i.DataValidationFormulaService)),y(3,(0,n.Inject)(n.ThemeService)),y(4,(0,n.Inject)(s.IRenderManagerService)),y(5,(0,n.Inject)(i.SheetDataValidationModel))],ct);let Z=class{constructor(e){this.injector=e,v(this,`canvasRender`,null),v(this,`dropdownType`,void 0),v(this,`optionsInput`,void 0),v(this,`formulaInput`,i.LIST_FORMULA_INPUT_NAME)}};Z=b([y(0,(0,n.Inject)(n.Injector))],Z);var lt=class extends Z{constructor(...e){super(...e),v(this,`id`,n.DataValidationType.CHECKBOX),v(this,`canvasRender`,this.injector.createInstance(ct)),v(this,`formulaInput`,i.CHECKBOX_FORMULA_INPUT_NAME)}},ut=class extends Z{constructor(...e){super(...e),v(this,`id`,n.DataValidationType.CUSTOM),v(this,`formulaInput`,i.CUSTOM_FORMULA_INPUT_NAME)}},dt=class extends Z{constructor(...e){super(...e),v(this,`id`,n.DataValidationType.DATE),v(this,`formulaInput`,i.BASE_FORMULA_INPUT_NAME),v(this,`optionsInput`,He.componentKey),v(this,`dropdownType`,a.DataValidatorDropdownType.DATE)}},ft=class extends Z{constructor(...e){super(...e),v(this,`id`,n.DataValidationType.DECIMAL),v(this,`formulaInput`,i.BASE_FORMULA_INPUT_NAME)}};function pt(e,t){let n=s.FontCache.getTextSize(e,t),r=n.width+8,{ba:i,bd:a}=n;return{width:r,height:i+a+0,ba:i}}function mt(e,t,n,r){let i=n-26,a=r-12,o=e.map(e=>({layout:pt(e,t),text:e})),s,c=[];o.forEach(e=>{let{layout:t}=e,{width:n,height:r}=t;!s||s.width+n+4>i?(s={width:n,height:r,items:[{...e,left:0}]},c.push(s)):(s.items.push({...e,left:s.width+4}),s.width=s.width+n+4)});let l=0,u=0;return c.forEach((e,t)=>{u=Math.max(u,e.width),t===c.length-1?l+=e.height:l+=e.height+4}),{lines:c,totalHeight:l,contentWidth:i,contentHeight:a,cellAutoHeight:l+12,calcAutoWidth:u+26}}var ht=class extends s.Shape{static drawWith(e,t){let{fontString:n,info:r,fill:i,color:a}=t,{layout:o,text:c}=r;e.save(),s.Rect.drawWith(e,{width:o.width,height:o.height,radius:8,fill:i||`#ECECEC`}),e.translateWithPrecision(4,o.ba),e.font=n,e.fillStyle=a,e.fillText(c,0,0),e.restore()}};let gt=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`),_t=class{constructor(e,t,n,r){this._commandService=e,this._univerInstanceService=t,this._renderManagerService=n,this._dataValidationModel=r,v(this,`zIndex`,void 0),v(this,`_dropdownInfoMap`,new Map)}_ensureMap(e){let t=this._dropdownInfoMap.get(e);return t||(t=new Map,this._dropdownInfoMap.set(e,t)),t}_generateKey(e,t){return`${e}.${t}`}_drawDownIcon(e,t,r,i,a){let o=r-14+4,s=4;switch(a){case n.VerticalAlign.MIDDLE:s=(i-14)/2+4;break;case n.VerticalAlign.BOTTOM:s=i-14+4;break;default:break}e.save(),e.translateWithPrecision(t.startX+o,t.startY+s),e.fillStyle=`#565656`,e.fill(gt),e.restore()}drawWith(e,t,r,a){var o,c;let{primaryWithCoord:l,row:u,col:d,style:f,data:p,subUnitId:m}=t,h=l.isMergedMainCell?l.mergeInfo:l,{leftOffset:g=0,rightOffset:_=0,topOffset:v=0,downOffset:y=0}=(p==null?void 0:p.fontRenderExtension)||{},b=this._ensureMap(m),x=this._generateKey(u,d),S=l.isMergedMainCell?l.mergeInfo.startRow:u,C=l.isMergedMainCell?l.mergeInfo.startColumn:d,w=this._dataValidationModel.getRuleByLocation(t.unitId,t.subUnitId,S,C);if(!w)return;let T=this._dataValidationModel.getValidator(w.type);if(!T)return;let E={startX:h.startX+g,endX:h.endX-_,startY:h.startY+v,endY:h.endY-y},D=E.endX-E.startX,O=E.endY-E.startY,{cl:k}=f||{},A=(o=typeof k==`object`?k==null?void 0:k.rgb:k)==null?`#000`:o,j=(0,s.getFontStyleString)(f==null?void 0:f),{vt:M,ht:N}=f||{},P=M==null?n.VerticalAlign.MIDDLE:M,F=(c=(0,i.getCellValueOrigin)(p))==null?``:c,I=T.parseCellValue(F),L=T.getListWithColorMap(w),R=mt(I,j,D,O);this._drawDownIcon(e,E,D,O,P),e.save(),e.translateWithPrecision(E.startX,E.startY),e.beginPath(),e.rect(0,0,D-14,O),e.clip(),e.translateWithPrecision(6,6);let z=0;switch(P){case n.VerticalAlign.MIDDLE:z=(R.contentHeight-R.totalHeight)/2;break;case n.VerticalAlign.BOTTOM:z=R.contentHeight-R.totalHeight;break;default:break}e.translateWithPrecision(0,z),R.lines.forEach((t,r)=>{e.save();let{width:i,height:a,items:o}=t,s=0;switch(N){case n.HorizontalAlign.RIGHT:s=R.contentWidth-i;break;case n.HorizontalAlign.CENTER:s=(R.contentWidth-i)/2;break;default:break}e.translate(s,r*(a+4)),o.forEach(t=>{e.save(),e.translateWithPrecision(t.left,0),ht.drawWith(e,{...j,info:t,color:A,fill:L[t.text]}),e.restore()}),e.restore()}),e.restore(),b.set(x,{left:E.startX,top:E.startY,width:R.contentWidth+6+14,height:R.contentHeight+12})}calcCellAutoHeight(e){var t;let{primaryWithCoord:n,style:r,data:a,row:o,col:c}=e,{leftOffset:l=0,rightOffset:u=0,topOffset:d=0,downOffset:f=0}=(a==null?void 0:a.fontRenderExtension)||{},p=n.isMergedMainCell?n.mergeInfo:n,m={startX:p.startX+l,endX:p.endX-u,startY:p.startY+d,endY:p.endY-f},h=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,o,c);if(!h)return;let g=this._dataValidationModel.getValidator(h.type);if(!g)return;let _=m.endX-m.startX,v=m.endY-m.startY,y=(t=(0,i.getCellValueOrigin)(a))==null?``:t;return mt(g.parseCellValue(y),(0,s.getFontStyleString)(r==null?void 0:r),_,v).cellAutoHeight}calcCellAutoWidth(e){var t;let{primaryWithCoord:n,style:r,data:a,row:o,col:c}=e,{leftOffset:l=0,rightOffset:u=0,topOffset:d=0,downOffset:f=0}=(a==null?void 0:a.fontRenderExtension)||{},p=n.isMergedMainCell?n.mergeInfo:n,m={startX:p.startX+l,endX:p.endX-u,startY:p.startY+d,endY:p.endY-f},h=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,o,c);if(!h)return;let g=this._dataValidationModel.getValidator(h.type);if(!g)return;let _=m.endX-m.startX,v=m.endY-m.startY,y=(t=(0,i.getCellValueOrigin)(a))==null?``:t;return mt(g.parseCellValue(y),(0,s.getFontStyleString)(r==null?void 0:r),_,v).calcAutoWidth}isHit(e,t){let{primaryWithCoord:n}=t,{endX:r}=n.isMergedMainCell?n.mergeInfo:n,{x:i}=e;return i>=r-14&&i<=r}onPointerDown(e,t){if(t.button===2)return;let{unitId:n,subUnitId:r,row:i,col:a}=e,o={unitId:n,subUnitId:r,row:i,column:a};this._commandService.executeCommand(N.id,o)}onPointerEnter(e,t){var r;return(r=(0,s.getCurrentTypeOfRenderer)(n.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null||(r=r.mainComponent)==null?void 0:r.setCursor(s.CURSOR_TYPE.POINTER)}onPointerLeave(e,t){var r;return(r=(0,s.getCurrentTypeOfRenderer)(n.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null||(r=r.mainComponent)==null?void 0:r.setCursor(s.CURSOR_TYPE.DEFAULT)}};_t=b([y(0,n.ICommandService),y(1,n.IUniverInstanceService),y(2,(0,n.Inject)(s.IRenderManagerService)),y(3,(0,n.Inject)(i.SheetDataValidationModel))],_t);var vt=class extends Z{constructor(...e){super(...e),v(this,`id`,n.DataValidationType.LIST_MULTIPLE),v(this,`canvasRender`,this.injector.createInstance(_t)),v(this,`dropdownType`,a.DataValidatorDropdownType.MULTIPLE_LIST)}};let yt=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 bt(e,t,r,i,a,o,s=!0){let c=0,l=s?3:0;switch(a){case n.VerticalAlign.BOTTOM:c=t-i-l;break;case n.VerticalAlign.MIDDLE:c=(t-i)/2;break;default:c=l;break}c=Math.max(3,c);let u=0;switch(o){case n.HorizontalAlign.CENTER:u=(e-r)/2;break;case n.HorizontalAlign.RIGHT:u=e-r;break;default:break}return u=Math.max(6,u),{paddingLeft:u,paddingTop:c}}let xt=class{constructor(e,t,n,r,i){this._univerInstanceService=e,this._localeService=t,this._commandService=n,this._renderManagerService=r,this._dataValidationModel=i,v(this,`_dropdownInfoMap`,new Map),v(this,`zIndex`,void 0)}_ensureMap(e){let t=this._dropdownInfoMap.get(e);return t||(t=new Map,this._dropdownInfoMap.set(e,t)),t}_generateKey(e,t){return`${e}.${t}`}_drawDownIcon(e,t,r,i,a,o,s){let{t:c=n.DEFAULT_STYLES.pd.t,b:l=n.DEFAULT_STYLES.pd.b}=s,u=r-14,d;switch(o){case n.VerticalAlign.MIDDLE:d=(i-4)/2;break;case n.VerticalAlign.BOTTOM:d=i-l-a-3+(a/2-4/2);break;default:d=c+3+(a/2-4/2);break}e.save(),e.translateWithPrecision(t.startX+u,t.startY+d),e.fillStyle=`#565656`,e.fill(yt),e.restore()}drawWith(e,t,r){var a,o,c,l;let{primaryWithCoord:u,row:d,col:f,style:p,data:m,subUnitId:h}=t,g=u.isMergedMainCell?u.mergeInfo:u,_=u.isMergedMainCell?u.mergeInfo.startRow:d,v=u.isMergedMainCell?u.mergeInfo.startColumn:f,y=this._dataValidationModel.getRuleByLocation(t.unitId,t.subUnitId,_,v);if(!y)return;let b=this._dataValidationModel.getValidator(y.type);if(!b)return;let{leftOffset:x=0,rightOffset:S=0,topOffset:C=0,downOffset:w=0}=(m==null?void 0:m.fontRenderExtension)||{};if(!y||!b||!b||b.id.indexOf(n.DataValidationType.LIST)!==0||!b.skipDefaultFontRender(y))return;let T={startX:g.startX+x,endX:g.endX-S,startY:g.startY+C,endY:g.endY-w},E=T.endX-T.startX,D=T.endY-T.startY,O=this._ensureMap(h),k=this._generateKey(d,f),A=b.getListWithColorMap(y),j=(0,i.getCellValueOrigin)(m),M=`${j==null?``:j}`,N=A[M],{tb:P,vt:F,ht:I,pd:L}=p||{};P=(a=P)==null?n.WrapStrategy.WRAP:a,F=(o=F)==null?n.VerticalAlign.BOTTOM:o,I=(c=I)==null?n.DEFAULT_STYLES.ht:c,L=(l=L)==null?n.DEFAULT_STYLES.pd:l;let R=(0,s.getFontStyleString)(p).fontCache;if(y.renderMode===n.DataValidationRenderMode.ARROW){var z,B,ee;let{l:t=n.DEFAULT_STYLES.pd.l,t:i=n.DEFAULT_STYLES.pd.t,r:a=n.DEFAULT_STYLES.pd.r,b:o=n.DEFAULT_STYLES.pd.b}=L,c=E-t-a-14-4,l=new s.DocSimpleSkeleton(M,R,P===n.WrapStrategy.WRAP,c,1/0);l.calculate();let u=l.getTotalWidth(),d=l.getTotalHeight(),{paddingTop:f,paddingLeft:m}=bt(c,D-i-o,u,d,F,I,!0);this._drawDownIcon(e,T,E,D,d,F,L),e.save(),e.translateWithPrecision(T.startX+t,T.startY+i),e.beginPath(),e.rect(0,0,E-t-a,D-i-o),e.clip(),e.translateWithPrecision(0,f),e.save(),e.translateWithPrecision(m,0),e.beginPath(),e.rect(0,0,c,d),e.clip(),s.Text.drawWith(e,{text:M,fontStyle:R,width:c,height:d,color:p==null||(z=p.cl)==null?void 0:z.rgb,strokeLine:!!(!(p==null||(B=p.st)==null)&&B.s),underline:!!(!(p==null||(ee=p.ul)==null)&&ee.s),warp:P===n.WrapStrategy.WRAP,hAlign:n.HorizontalAlign.LEFT},l),e.restore(),e.restore(),O.set(k,{left:T.endX-14+r.rowHeaderWidth,top:T.startY+i+r.columnHeaderHeight,width:14,height:D-i-o})}else{var V,H,U;e.save(),e.translateWithPrecision(T.startX,T.startY),e.beginPath(),e.rect(0,0,E,D),e.clip();let t=E-12-4-14-4,i=new s.DocSimpleSkeleton(M,R,P===n.WrapStrategy.WRAP,t,1/0);i.calculate();let a=i.getTotalWidth(),o=i.getTotalHeight(),c=o+2,l=Math.max(E-12,1),{paddingTop:u}=bt(l,D,a,c,F,I);e.translateWithPrecision(6,u),s.Rect.drawWith(e,{width:l,height:c,fill:N||`#ECECEC`,radius:8}),e.save(),e.translateWithPrecision(4,1),e.beginPath(),e.rect(0,0,t,o),e.clip(),s.Text.drawWith(e,{text:M,fontStyle:R,width:t,height:o,color:p==null||(V=p.cl)==null?void 0:V.rgb,strokeLine:!!(!(p==null||(H=p.st)==null)&&H.s),underline:!!(!(p==null||(U=p.ul)==null)&&U.s),warp:P===n.WrapStrategy.WRAP,hAlign:n.HorizontalAlign.LEFT},i),e.restore(),e.translateWithPrecision(t+4+4,(o-4)/2),e.fillStyle=`#565656`,e.fill(yt),e.restore(),O.set(k,{left:T.startX+6+r.rowHeaderWidth,top:T.startY+u+r.columnHeaderHeight,width:l,height:c})}}calcCellAutoHeight(e){var t;let{primaryWithCoord:r,style:a,data:o,row:c,col:l}=e,u=r.isMergedMainCell?r.mergeInfo:r,{leftOffset:d=0,rightOffset:f=0,topOffset:p=0,downOffset:m=0}=(o==null?void 0:o.fontRenderExtension)||{},h=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,c,l);if(!h||h.renderMode===n.DataValidationRenderMode.TEXT)return;let g={startX:u.startX+d,endX:u.endX-f,startY:u.startY+p,endY:u.endY-m},_=g.endX-g.startX,v=(0,i.getCellValueOrigin)(o),y=`${v==null?``:v}`,{tb:b,pd:x}=a||{},{t:S=n.DEFAULT_STYLES.pd.t,b:C=n.DEFAULT_STYLES.pd.b}=x==null?{}:x;if(b=(t=b)==null?n.WrapStrategy.WRAP:t,h.renderMode===n.DataValidationRenderMode.ARROW){let{l:e=n.DEFAULT_STYLES.pd.l,r:t=n.DEFAULT_STYLES.pd.r}=x==null?{}:x,r=_-e-t-14-4,i=new s.DocSimpleSkeleton(y,(0,s.getFontStyleString)(a).fontCache,b===n.WrapStrategy.WRAP,r,1/0);return i.calculate(),i.getTotalHeight()+S+C+6}else{let e=Math.max(_-12-4-14-4,10),t=new s.DocSimpleSkeleton(y,(0,s.getFontStyleString)(a).fontCache,b===n.WrapStrategy.WRAP,e,1/0);return t.calculate(),t.getTotalHeight()+6+2}}calcCellAutoWidth(e){var t;let{primaryWithCoord:r,style:a,data:o,row:c,col:l}=e,u=r.isMergedMainCell?r.mergeInfo:r,{leftOffset:d=0,rightOffset:f=0,topOffset:p=0,downOffset:m=0}=(o==null?void 0:o.fontRenderExtension)||{},h=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,c,l);if(!h||h.renderMode===n.DataValidationRenderMode.TEXT)return;let g={startX:u.startX+d,endX:u.endX-f,startY:u.startY+p,endY:u.endY-m},_=g.endX-g.startX,v=(0,i.getCellValueOrigin)(o),y=`${v==null?``:v}`,{tb:b,pd:x}=a||{},{l:S=n.DEFAULT_STYLES.pd.l,r:C=n.DEFAULT_STYLES.pd.r}=x==null?{}:x;b=(t=b)==null?n.WrapStrategy.WRAP:t;let w=26;switch(h.renderMode){case n.DataValidationRenderMode.ARROW:w=18+C+S;break;case n.DataValidationRenderMode.CUSTOM:w=34+C+S+8/2+1;break;default:w=34+C+S+8/2+1}let T=_-w,E=new s.DocSimpleSkeleton(y,(0,s.getFontStyleString)(a).fontCache,b===n.WrapStrategy.WRAP,T,1/0);return E.calculate(),E.getTotalWidth()+w}isHit(e,t){let{subUnitId:r,row:i,col:a}=t,o=this._ensureMap(r).get(this._generateKey(i,a)),s=this._dataValidationModel.getRuleByLocation(t.unitId,t.subUnitId,i,a);if(!s||!o||s.renderMode===n.DataValidationRenderMode.TEXT)return!1;let{top:c,left:l,width:u,height:d}=o,{x:f,y:p}=e;return f>=l&&f<=l+u&&p>=c&&p<=c+d}onPointerDown(e,t){if(t.button===2)return;let{unitId:n,subUnitId:r,row:i,col:a}=e,o={unitId:n,subUnitId:r,row:i,column:a};this._commandService.executeCommand(N.id,o)}onPointerEnter(e,t){var r;(r=(0,s.getCurrentTypeOfRenderer)(n.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null||(r=r.mainComponent)==null||r.setCursor(s.CURSOR_TYPE.POINTER)}onPointerLeave(e,t){var r;(r=(0,s.getCurrentTypeOfRenderer)(n.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null||(r=r.mainComponent)==null||r.setCursor(s.CURSOR_TYPE.DEFAULT)}};xt=b([y(0,n.IUniverInstanceService),y(1,(0,n.Inject)(n.LocaleService)),y(2,n.ICommandService),y(3,(0,n.Inject)(s.IRenderManagerService)),y(4,(0,n.Inject)(i.SheetDataValidationModel))],xt);var St=class extends Z{constructor(...e){super(...e),v(this,`id`,n.DataValidationType.LIST),v(this,`canvasRender`,this.injector.createInstance(xt)),v(this,`dropdownType`,a.DataValidatorDropdownType.LIST),v(this,`optionsInput`,$e.componentKey),v(this,`formulaInput`,i.LIST_FORMULA_INPUT_NAME)}},Ct=class extends Z{constructor(...e){super(...e),v(this,`id`,n.DataValidationType.TEXT_LENGTH),v(this,`formulaInput`,i.BASE_FORMULA_INPUT_NAME)}},wt=class extends Z{constructor(...e){super(...e),v(this,`id`,n.DataValidationType.WHOLE),v(this,`formulaInput`,i.BASE_FORMULA_INPUT_NAME)}};let Tt=class extends n.RxDisposable{constructor(e,t){super(),this._injector=e,this._dataValidatorRegistryService=t,this._registerValidatorViews()}_registerValidatorViews(){[ft,wt,Ct,dt,lt,St,vt,ut].forEach(e=>{let 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)})}};Tt=b([y(0,(0,n.Inject)(n.Injector)),y(1,(0,n.Inject)(a.DataValidatorRegistryService))],Tt);let Q=class extends n.Plugin{constructor(e=C,t,r,i){super(),this._config=e,this._injector=t,this._commandService=r,this._configService=i;let{menu:a,...o}=(0,n.merge)({},C,this._config);a&&this._configService.setConfig(`menu`,a,{merge:!0}),this._configService.setConfig(S,o)}onStarting(){this._injector.add([J]),this._injector.get(J),[[x],[O],[et],[X],[at],[rt],[nt],[Tt]].forEach(e=>{this._injector.add(e)}),[R,I,L,N,P,j,A,M].forEach(e=>{this._commandService.registerCommand(e)})}onReady(){this._injector.get(nt),this._injector.get(rt),this._injector.get(s.IRenderManagerService).registerRenderModule(n.UniverInstanceType.UNIVER_SHEET,[st])}onRendered(){this._injector.get(Tt),this._injector.get(at)}onSteady(){this._injector.get(X)}};v(Q,`pluginName`,`SHEET_DATA_VALIDATION_UI_PLUGIN`),v(Q,`packageName`,ue),v(Q,`version`,de),v(Q,`type`,n.UniverInstanceType.UNIVER_SHEET),Q=b([y(1,(0,n.Inject)(n.Injector)),y(2,n.ICommandService),y(3,n.IConfigService)],Q);let $=class extends n.Plugin{constructor(e=C,t,r,i){super(),this._config=e,this._injector=t,this._commandService=r,this._configService=i;let{menu:a,...o}=(0,n.merge)({},C,this._config);a&&this._configService.setConfig(`menu`,a,{merge:!0}),this._configService.setConfig(S,o)}onStarting(){this._injector.add([J]),this._injector.get(J),[[x],[O],[et],[X],[at],[rt],[nt],[T],[Tt]].forEach(e=>{this._injector.add(e)}),[R,I,L,N,P,j,A,M].forEach(e=>{this._commandService.registerCommand(e)})}onReady(){this._injector.get(nt),this._injector.get(rt),this._injector.get(T),this._injector.get(et),this._injector.get(s.IRenderManagerService).registerRenderModule(n.UniverInstanceType.UNIVER_SHEET,[st])}onRendered(){this._injector.get(Tt),this._injector.get(at)}onSteady(){this._injector.get(X)}};v($,`pluginName`,`SHEET_DATA_VALIDATION_UI_PLUGIN`),v($,`packageName`,ue),v($,`version`,de),v($,`type`,n.UniverInstanceType.UNIVER_SHEET),$=b([(0,n.DependentOn)(i.UniverSheetsDataValidationPlugin),y(1,(0,n.Inject)(n.Injector)),y(2,n.ICommandService),y(3,n.IConfigService)],$),e.SheetsDataValidationUIMenuSchema=le,Object.defineProperty(e,"UniverSheetsDataValidationMobileUIPlugin",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(e,"UniverSheetsDataValidationUIPlugin",{enumerable:!0,get:function(){return $}})});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@univerjs/sheets-data-validation-ui",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.7",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Data validation UI for Univer Sheets.",
|
|
6
6
|
"author": "DreamNum Co., Ltd. <developer@univer.ai>",
|
|
@@ -58,18 +58,18 @@
|
|
|
58
58
|
"rxjs": ">=7.0.0"
|
|
59
59
|
},
|
|
60
60
|
"dependencies": {
|
|
61
|
-
"@univerjs/icons": "1.
|
|
62
|
-
"@univerjs/core": "1.0.0-alpha.
|
|
63
|
-
"@univerjs/data-validation": "1.0.0-alpha.
|
|
64
|
-
"@univerjs/design": "1.0.0-alpha.
|
|
65
|
-
"@univerjs/engine-formula": "1.0.0-alpha.
|
|
66
|
-
"@univerjs/
|
|
67
|
-
"@univerjs/sheets
|
|
68
|
-
"@univerjs/sheets-
|
|
69
|
-
"@univerjs/
|
|
70
|
-
"@univerjs/sheets-
|
|
71
|
-
"@univerjs/ui": "1.0.0-alpha.
|
|
72
|
-
"@univerjs/
|
|
61
|
+
"@univerjs/icons": "1.34.0",
|
|
62
|
+
"@univerjs/core": "1.0.0-alpha.7",
|
|
63
|
+
"@univerjs/data-validation": "1.0.0-alpha.7",
|
|
64
|
+
"@univerjs/design": "1.0.0-alpha.7",
|
|
65
|
+
"@univerjs/engine-formula": "1.0.0-alpha.7",
|
|
66
|
+
"@univerjs/engine-render": "1.0.0-alpha.7",
|
|
67
|
+
"@univerjs/sheets": "1.0.0-alpha.7",
|
|
68
|
+
"@univerjs/sheets-data-validation": "1.0.0-alpha.7",
|
|
69
|
+
"@univerjs/sheets-numfmt": "1.0.0-alpha.7",
|
|
70
|
+
"@univerjs/sheets-formula-ui": "1.0.0-alpha.7",
|
|
71
|
+
"@univerjs/sheets-ui": "1.0.0-alpha.7",
|
|
72
|
+
"@univerjs/ui": "1.0.0-alpha.7"
|
|
73
73
|
},
|
|
74
74
|
"devDependencies": {
|
|
75
75
|
"postcss": "^8.5.19",
|
|
@@ -78,7 +78,7 @@
|
|
|
78
78
|
"tailwindcss": "3.4.18",
|
|
79
79
|
"typescript": "^6.0.3",
|
|
80
80
|
"vitest": "^4.1.10",
|
|
81
|
-
"@univerjs-infra/shared": "1.0.0-alpha.
|
|
81
|
+
"@univerjs-infra/shared": "1.0.0-alpha.7"
|
|
82
82
|
},
|
|
83
83
|
"scripts": {
|
|
84
84
|
"dev": "vite",
|