@univerjs/sheets-numfmt-ui 1.0.0-alpha.8 → 1.0.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/cjs/index.js CHANGED
@@ -172,7 +172,7 @@ let SheetNumfmtUIController = class SheetNumfmtUIController extends _univerjs_co
172
172
  }
173
173
  _forceUpdate(unitId) {
174
174
  var _this$_univerInstance, _renderUnit$mainCompo;
175
- const resolvedUnitId = unitId !== null && unitId !== void 0 ? unitId : (_this$_univerInstance = this._univerInstanceService.getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_SHEET)) === null || _this$_univerInstance === void 0 ? void 0 : _this$_univerInstance.getUnitId();
175
+ const resolvedUnitId = unitId ?? ((_this$_univerInstance = this._univerInstanceService.getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_SHEET)) === null || _this$_univerInstance === void 0 ? void 0 : _this$_univerInstance.getUnitId());
176
176
  if (!resolvedUnitId) return;
177
177
  const renderUnit = this._renderManagerService.getRenderUnitById(resolvedUnitId);
178
178
  renderUnit === null || renderUnit === void 0 || renderUnit.with(_univerjs_sheets_ui.SheetSkeletonManagerService).reCalculate();
@@ -221,8 +221,7 @@ let SheetNumfmtUIController = class SheetNumfmtUIController extends _univerjs_co
221
221
  if (value === void 0 || value === null || type !== _univerjs_core.CellValueType.NUMBER || this._previewPattern === null) return defaultValue;
222
222
  const info = (0, _univerjs_sheets_numfmt.getPatternPreviewIgnoreGeneral)(this._previewPattern, value, this._sheetsNumfmtCellContentController.locale);
223
223
  if (info.color) {
224
- var _this$_themeService$g;
225
- const color = (_this$_themeService$g = this._themeService.getColorFromTheme(`${info.color}.500`)) !== null && _this$_themeService$g !== void 0 ? _this$_themeService$g : info.color;
224
+ const color = this._themeService.getColorFromTheme(`${info.color}.500`) ?? info.color;
226
225
  return {
227
226
  ...defaultValue,
228
227
  v: info.result,
@@ -297,7 +296,7 @@ function MoreNumfmtType(props) {
297
296
  const localeService = (0, _univerjs_ui.useDependency)(_univerjs_core.LocaleService);
298
297
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
299
298
  className: "univer-text-sm",
300
- children: value !== null && value !== void 0 ? value : localeService.t("sheets-numfmt-ui.general")
299
+ children: value ?? localeService.t("sheets-numfmt-ui.general")
301
300
  });
302
301
  }
303
302
  function Options() {
@@ -587,7 +586,7 @@ const menuSchema = { [_univerjs_ui.RibbonStartGroup.NUMBER]: {
587
586
  //#endregion
588
587
  //#region package.json
589
588
  var name = "@univerjs/sheets-numfmt-ui";
590
- var version = "1.0.0-alpha.8";
589
+ var version = "1.0.0-beta.0";
591
590
 
592
591
  //#endregion
593
592
  //#region src/config/config.ts
@@ -858,7 +857,7 @@ function CustomFormat(props) {
858
857
  ..._univerjs_sheets_numfmt.CURRENCYFORMAT.map((item) => item.suffix("$")),
859
858
  ..._univerjs_sheets_numfmt.DATEFMTLISG.map((item) => item.suffix),
860
859
  ..._univerjs_sheets_numfmt.NUMBERFORMAT.map((item) => item.suffix),
861
- ...historyList !== null && historyList !== void 0 ? historyList : []
860
+ ...historyList ?? []
862
861
  ];
863
862
  return userHabitController.addHabit(key$1, []).then(() => userHabitController.getHabit(key$1, list));
864
863
  }).then((list) => {
@@ -1687,7 +1686,7 @@ _defineProperty(UniverSheetsNumfmtUIPlugin, "packageName", name);
1687
1686
  _defineProperty(UniverSheetsNumfmtUIPlugin, "version", version);
1688
1687
  _defineProperty(UniverSheetsNumfmtUIPlugin, "type", _univerjs_core.UniverInstanceType.UNIVER_SHEET);
1689
1688
  UniverSheetsNumfmtUIPlugin = __decorate([
1690
- (0, _univerjs_core.DependentOn)(_univerjs_engine_render.UniverRenderEnginePlugin, _univerjs_sheets.UniverSheetsPlugin, _univerjs_ui.UniverUIPlugin, _univerjs_sheets_numfmt.UniverSheetsNumfmtPlugin, _univerjs_sheets_ui.UniverSheetsUIPlugin),
1689
+ (0, _univerjs_core.DependentOn)(_univerjs_engine_render.UniverRenderEnginePlugin, _univerjs_sheets.UniverSheetsPlugin, _univerjs_sheets_numfmt.UniverSheetsNumfmtPlugin, _univerjs_sheets_ui.UniverSheetsUIPlugin),
1691
1690
  __decorateParam(1, (0, _univerjs_core.Inject)(_univerjs_core.Injector)),
1692
1691
  __decorateParam(2, _univerjs_core.IConfigService),
1693
1692
  __decorateParam(3, _univerjs_engine_render.IRenderManagerService)
package/lib/es/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { AddDecimalCommand, CURRENCYFORMAT, DATEFMTLISG, NUMBERFORMAT, SHEETS_NUMFMT_PLUGIN_CONFIG_KEY, SetCurrencyCommand, SetNumfmtCommand, SetPercentCommand, SheetsNumfmtCellContentController, SubtractDecimalCommand, UniverSheetsNumfmtPlugin, getCurrencyFormatOptions, getCurrencySymbolByLocale, getCurrencySymbolIconByLocale, getCurrencyType, getDateFormatOptions, getDecimalFromPattern, getNumberFormatOptions, getPatternPreview, getPatternPreviewIgnoreGeneral, getPatternType, isPatternHasDecimal, setPatternDecimal } from "@univerjs/sheets-numfmt";
2
- import { ComponentManager, ILayoutService, IMenuManagerService, ISidebarService, IconManager, MenuItemType, RibbonStartGroup, UniverUIPlugin, getMenuHiddenObservable, useDependency, useObservable } from "@univerjs/ui";
2
+ import { ComponentManager, ILayoutService, IMenuManagerService, ISidebarService, IconManager, MenuItemType, RibbonStartGroup, getMenuHiddenObservable, useDependency, useObservable } from "@univerjs/ui";
3
3
  import { CellValueType, CommandType, DEFAULT_TEXT_FORMAT_EXCEL, DependentOn, Disposable, DisposableCollection, ICommandService, IConfigService, ILocalStorageService, IUniverInstanceService, Inject, Injector, InterceptorEffectEnum, LocaleService, Optional, Plugin, Range, RegionService, ThemeService, Tools, UniverInstanceType, currencySymbols, fromCallback, getNumfmtParseValueFilter, isDefaultFormat, isPatternEqualWithoutDecimal, isRealNum, isTextFormat, merge, numfmt, registerDependencies, toDisposable, touchDependencies, willLoseNumericPrecision } from "@univerjs/core";
4
4
  import { IRenderManagerService, UniverRenderEnginePlugin } from "@univerjs/engine-render";
5
5
  import { AFTER_CELL_EDIT, BEFORE_CELL_EDIT, INTERCEPTOR_POINT, INumfmtService, RangeProtectionPermissionEditPoint, RemoveNumfmtMutation, SetNumfmtMutation, SetRangeValuesCommand, SheetInterceptorService, SheetsSelectionsService, UniverSheetsPlugin, WorkbookEditablePermission, WorksheetEditPermission, WorksheetSetCellStylePermission, factoryRemoveNumfmtUndoMutation, factorySetNumfmtUndoMutation, transformCellsToRange } from "@univerjs/sheets";
@@ -171,7 +171,7 @@ let SheetNumfmtUIController = class SheetNumfmtUIController extends Disposable {
171
171
  }
172
172
  _forceUpdate(unitId) {
173
173
  var _this$_univerInstance, _renderUnit$mainCompo;
174
- const resolvedUnitId = unitId !== null && unitId !== void 0 ? unitId : (_this$_univerInstance = this._univerInstanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_SHEET)) === null || _this$_univerInstance === void 0 ? void 0 : _this$_univerInstance.getUnitId();
174
+ const resolvedUnitId = unitId ?? ((_this$_univerInstance = this._univerInstanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_SHEET)) === null || _this$_univerInstance === void 0 ? void 0 : _this$_univerInstance.getUnitId());
175
175
  if (!resolvedUnitId) return;
176
176
  const renderUnit = this._renderManagerService.getRenderUnitById(resolvedUnitId);
177
177
  renderUnit === null || renderUnit === void 0 || renderUnit.with(SheetSkeletonManagerService).reCalculate();
@@ -220,8 +220,7 @@ let SheetNumfmtUIController = class SheetNumfmtUIController extends Disposable {
220
220
  if (value === void 0 || value === null || type !== CellValueType.NUMBER || this._previewPattern === null) return defaultValue;
221
221
  const info = getPatternPreviewIgnoreGeneral(this._previewPattern, value, this._sheetsNumfmtCellContentController.locale);
222
222
  if (info.color) {
223
- var _this$_themeService$g;
224
- const color = (_this$_themeService$g = this._themeService.getColorFromTheme(`${info.color}.500`)) !== null && _this$_themeService$g !== void 0 ? _this$_themeService$g : info.color;
223
+ const color = this._themeService.getColorFromTheme(`${info.color}.500`) ?? info.color;
225
224
  return {
226
225
  ...defaultValue,
227
226
  v: info.result,
@@ -296,7 +295,7 @@ function MoreNumfmtType(props) {
296
295
  const localeService = useDependency(LocaleService);
297
296
  return /* @__PURE__ */ jsx("span", {
298
297
  className: "univer-text-sm",
299
- children: value !== null && value !== void 0 ? value : localeService.t("sheets-numfmt-ui.general")
298
+ children: value ?? localeService.t("sheets-numfmt-ui.general")
300
299
  });
301
300
  }
302
301
  function Options() {
@@ -586,7 +585,7 @@ const menuSchema = { [RibbonStartGroup.NUMBER]: {
586
585
  //#endregion
587
586
  //#region package.json
588
587
  var name = "@univerjs/sheets-numfmt-ui";
589
- var version = "1.0.0-alpha.8";
588
+ var version = "1.0.0-beta.0";
590
589
 
591
590
  //#endregion
592
591
  //#region src/config/config.ts
@@ -857,7 +856,7 @@ function CustomFormat(props) {
857
856
  ...CURRENCYFORMAT.map((item) => item.suffix("$")),
858
857
  ...DATEFMTLISG.map((item) => item.suffix),
859
858
  ...NUMBERFORMAT.map((item) => item.suffix),
860
- ...historyList !== null && historyList !== void 0 ? historyList : []
859
+ ...historyList ?? []
861
860
  ];
862
861
  return userHabitController.addHabit(key$1, []).then(() => userHabitController.getHabit(key$1, list));
863
862
  }).then((list) => {
@@ -1686,7 +1685,7 @@ _defineProperty(UniverSheetsNumfmtUIPlugin, "packageName", name);
1686
1685
  _defineProperty(UniverSheetsNumfmtUIPlugin, "version", version);
1687
1686
  _defineProperty(UniverSheetsNumfmtUIPlugin, "type", UniverInstanceType.UNIVER_SHEET);
1688
1687
  UniverSheetsNumfmtUIPlugin = __decorate([
1689
- DependentOn(UniverRenderEnginePlugin, UniverSheetsPlugin, UniverUIPlugin, UniverSheetsNumfmtPlugin, UniverSheetsUIPlugin),
1688
+ DependentOn(UniverRenderEnginePlugin, UniverSheetsPlugin, UniverSheetsNumfmtPlugin, UniverSheetsUIPlugin),
1690
1689
  __decorateParam(1, Inject(Injector)),
1691
1690
  __decorateParam(2, IConfigService),
1692
1691
  __decorateParam(3, IRenderManagerService)
package/lib/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { AddDecimalCommand, CURRENCYFORMAT, DATEFMTLISG, NUMBERFORMAT, SHEETS_NUMFMT_PLUGIN_CONFIG_KEY, SetCurrencyCommand, SetNumfmtCommand, SetPercentCommand, SheetsNumfmtCellContentController, SubtractDecimalCommand, UniverSheetsNumfmtPlugin, getCurrencyFormatOptions, getCurrencySymbolByLocale, getCurrencySymbolIconByLocale, getCurrencyType, getDateFormatOptions, getDecimalFromPattern, getNumberFormatOptions, getPatternPreview, getPatternPreviewIgnoreGeneral, getPatternType, isPatternHasDecimal, setPatternDecimal } from "@univerjs/sheets-numfmt";
2
- import { ComponentManager, ILayoutService, IMenuManagerService, ISidebarService, IconManager, MenuItemType, RibbonStartGroup, UniverUIPlugin, getMenuHiddenObservable, useDependency, useObservable } from "@univerjs/ui";
2
+ import { ComponentManager, ILayoutService, IMenuManagerService, ISidebarService, IconManager, MenuItemType, RibbonStartGroup, getMenuHiddenObservable, useDependency, useObservable } from "@univerjs/ui";
3
3
  import { CellValueType, CommandType, DEFAULT_TEXT_FORMAT_EXCEL, DependentOn, Disposable, DisposableCollection, ICommandService, IConfigService, ILocalStorageService, IUniverInstanceService, Inject, Injector, InterceptorEffectEnum, LocaleService, Optional, Plugin, Range, RegionService, ThemeService, Tools, UniverInstanceType, currencySymbols, fromCallback, getNumfmtParseValueFilter, isDefaultFormat, isPatternEqualWithoutDecimal, isRealNum, isTextFormat, merge, numfmt, registerDependencies, toDisposable, touchDependencies, willLoseNumericPrecision } from "@univerjs/core";
4
4
  import { IRenderManagerService, UniverRenderEnginePlugin } from "@univerjs/engine-render";
5
5
  import { AFTER_CELL_EDIT, BEFORE_CELL_EDIT, INTERCEPTOR_POINT, INumfmtService, RangeProtectionPermissionEditPoint, RemoveNumfmtMutation, SetNumfmtMutation, SetRangeValuesCommand, SheetInterceptorService, SheetsSelectionsService, UniverSheetsPlugin, WorkbookEditablePermission, WorksheetEditPermission, WorksheetSetCellStylePermission, factoryRemoveNumfmtUndoMutation, factorySetNumfmtUndoMutation, transformCellsToRange } from "@univerjs/sheets";
@@ -171,7 +171,7 @@ let SheetNumfmtUIController = class SheetNumfmtUIController extends Disposable {
171
171
  }
172
172
  _forceUpdate(unitId) {
173
173
  var _this$_univerInstance, _renderUnit$mainCompo;
174
- const resolvedUnitId = unitId !== null && unitId !== void 0 ? unitId : (_this$_univerInstance = this._univerInstanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_SHEET)) === null || _this$_univerInstance === void 0 ? void 0 : _this$_univerInstance.getUnitId();
174
+ const resolvedUnitId = unitId ?? ((_this$_univerInstance = this._univerInstanceService.getCurrentUnitOfType(UniverInstanceType.UNIVER_SHEET)) === null || _this$_univerInstance === void 0 ? void 0 : _this$_univerInstance.getUnitId());
175
175
  if (!resolvedUnitId) return;
176
176
  const renderUnit = this._renderManagerService.getRenderUnitById(resolvedUnitId);
177
177
  renderUnit === null || renderUnit === void 0 || renderUnit.with(SheetSkeletonManagerService).reCalculate();
@@ -220,8 +220,7 @@ let SheetNumfmtUIController = class SheetNumfmtUIController extends Disposable {
220
220
  if (value === void 0 || value === null || type !== CellValueType.NUMBER || this._previewPattern === null) return defaultValue;
221
221
  const info = getPatternPreviewIgnoreGeneral(this._previewPattern, value, this._sheetsNumfmtCellContentController.locale);
222
222
  if (info.color) {
223
- var _this$_themeService$g;
224
- const color = (_this$_themeService$g = this._themeService.getColorFromTheme(`${info.color}.500`)) !== null && _this$_themeService$g !== void 0 ? _this$_themeService$g : info.color;
223
+ const color = this._themeService.getColorFromTheme(`${info.color}.500`) ?? info.color;
225
224
  return {
226
225
  ...defaultValue,
227
226
  v: info.result,
@@ -296,7 +295,7 @@ function MoreNumfmtType(props) {
296
295
  const localeService = useDependency(LocaleService);
297
296
  return /* @__PURE__ */ jsx("span", {
298
297
  className: "univer-text-sm",
299
- children: value !== null && value !== void 0 ? value : localeService.t("sheets-numfmt-ui.general")
298
+ children: value ?? localeService.t("sheets-numfmt-ui.general")
300
299
  });
301
300
  }
302
301
  function Options() {
@@ -586,7 +585,7 @@ const menuSchema = { [RibbonStartGroup.NUMBER]: {
586
585
  //#endregion
587
586
  //#region package.json
588
587
  var name = "@univerjs/sheets-numfmt-ui";
589
- var version = "1.0.0-alpha.8";
588
+ var version = "1.0.0-beta.0";
590
589
 
591
590
  //#endregion
592
591
  //#region src/config/config.ts
@@ -857,7 +856,7 @@ function CustomFormat(props) {
857
856
  ...CURRENCYFORMAT.map((item) => item.suffix("$")),
858
857
  ...DATEFMTLISG.map((item) => item.suffix),
859
858
  ...NUMBERFORMAT.map((item) => item.suffix),
860
- ...historyList !== null && historyList !== void 0 ? historyList : []
859
+ ...historyList ?? []
861
860
  ];
862
861
  return userHabitController.addHabit(key$1, []).then(() => userHabitController.getHabit(key$1, list));
863
862
  }).then((list) => {
@@ -1686,7 +1685,7 @@ _defineProperty(UniverSheetsNumfmtUIPlugin, "packageName", name);
1686
1685
  _defineProperty(UniverSheetsNumfmtUIPlugin, "version", version);
1687
1686
  _defineProperty(UniverSheetsNumfmtUIPlugin, "type", UniverInstanceType.UNIVER_SHEET);
1688
1687
  UniverSheetsNumfmtUIPlugin = __decorate([
1689
- DependentOn(UniverRenderEnginePlugin, UniverSheetsPlugin, UniverUIPlugin, UniverSheetsNumfmtPlugin, UniverSheetsUIPlugin),
1688
+ DependentOn(UniverRenderEnginePlugin, UniverSheetsPlugin, UniverSheetsNumfmtPlugin, UniverSheetsUIPlugin),
1690
1689
  __decorateParam(1, Inject(Injector)),
1691
1690
  __decorateParam(2, IConfigService),
1692
1691
  __decorateParam(3, IRenderManagerService)
package/lib/umd/index.js CHANGED
@@ -1 +1 @@
1
- (function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("@univerjs/sheets-numfmt"),require("@univerjs/ui"),require("@univerjs/core"),require("@univerjs/engine-render"),require("@univerjs/sheets"),require("@univerjs/sheets-ui"),require("rxjs"),require("rxjs/operators"),require("@univerjs/design"),require("react"),require("react/jsx-runtime"),require("@univerjs/engine-formula")):typeof define==`function`&&define.amd?define([`exports`,`@univerjs/sheets-numfmt`,`@univerjs/ui`,`@univerjs/core`,`@univerjs/engine-render`,`@univerjs/sheets`,`@univerjs/sheets-ui`,`rxjs`,`rxjs/operators`,`@univerjs/design`,`react`,`react/jsx-runtime`,`@univerjs/engine-formula`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.UniverSheetsNumfmtUi={},e.UniverSheetsNumfmt,e.UniverUi,e.UniverCore,e.UniverEngineRender,e.UniverSheets,e.UniverSheetsUi,e.rxjs,e.rxjs.operators,e.UniverDesign,e.React,e.React,e.UniverEngineFormula))})(this,function(e,t,n,r,i,a,o,s,c,l,u,d,f){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});let p={id:`sheet.operation.close.numfmt.panel`,type:r.CommandType.OPERATION,handler:()=>!0};function m(e){"@babel/helpers - typeof";return m=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},m(e)}function h(e,t){if(m(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(m(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function g(e){var t=h(e,`string`);return m(t)==`symbol`?t:t+``}function _(e,t,n){return(t=g(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function v(e,t){return function(n,r){t(n,r,e)}}function y(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 b=class extends r.Disposable{constructor(e,t,n,r,i,a,o,s,c,l){super(),this._sheetInterceptorService=e,this._themeService=t,this._univerInstanceService=n,this._commandService=r,this._selectionManagerService=i,this._renderManagerService=a,this._numfmtService=o,this._sidebarService=s,this._localeService=c,this._sheetsNumfmtCellContentController=l,_(this,`_previewPattern`,``),_(this,`_sidebarDisposable`,null),this._initRealTimeRenderingInterceptor(),this._initCommands(),this._initCloseListener(),this._commandExecutedListener(),this._initNumfmtLocalChange()}_initNumfmtLocalChange(){this.disposeWithMe((0,s.merge)(this._sheetsNumfmtCellContentController.locale$,this._localeService.currentLocale$).subscribe(()=>{this._forceUpdate()}))}openPanel(){var e;let n=this._sidebarService,i=this._selectionManagerService,a=this._commandService,o=this._univerInstanceService,s=this._numfmtService,c=this._localeService,l=(((e=i.getCurrentSelections())==null?void 0:e.map(e=>e.range))||[])[0];if(!l)return!1;let u=o.getCurrentUnitOfType(r.UniverInstanceType.UNIVER_SHEET),d=u.getActiveSheet();if(!d)return!1;let f=d.getCellRaw(l.startRow,l.startColumn),m=s.getValue(u.getUnitId(),d.getSheetId(),l.startRow,l.startColumn),h=``;m&&(h=m.pattern);let g=(f==null?void 0:f.t)===r.CellValueType.NUMBER?f.v:12345678,_={onChange:e=>{if(e.type===`change`)this._previewPattern=e.value,this._forceUpdate();else if(e.type===`confirm`){var o;let s=((o=i.getCurrentSelections())==null?void 0:o.map(e=>e.range))||[],c={values:[]},l=(0,t.getPatternType)(e.value);s.forEach(t=>{r.Range.foreach(t,(t,n)=>{c.values.push({row:t,col:n,pattern:e.value,type:l})})}),a.executeCommand(t.SetNumfmtCommand.id,c),n.close()}else e.type===`cancel`&&n.close()},value:{defaultPattern:h,defaultValue:g,row:l.startRow,col:l.startColumn}};return this._sidebarDisposable=n.open({header:{title:c.t(`sheets-numfmt-ui.title`)},children:{label:`SHEET_NUMFMT_PANEL`,..._},onClose:()=>{this._forceUpdate(),a.executeCommand(p.id)}}),!0}_forceUpdate(e){var t,n;let i=e==null?(t=this._univerInstanceService.getCurrentUnitOfType(r.UniverInstanceType.UNIVER_SHEET))==null?void 0:t.getUnitId():e;if(!i)return;let a=this._renderManagerService.getRenderUnitById(i);a==null||a.with(o.SheetSkeletonManagerService).reCalculate(),a==null||(n=a.mainComponent)==null||n.makeDirty()}_initCommands(){[x,p].forEach(e=>{this.disposeWithMe(this._commandService.registerCommand(e))})}_initRealTimeRenderingInterceptor(){let e=(0,s.combineLatest)([new s.Observable(e=>{this._commandService.onCommandExecuted(t=>{t.id===x.id&&e.next(!0),t.id===p.id&&e.next(!1)})}),this._selectionManagerService.selectionMoveEnd$.pipe((0,c.map)(e=>e?e.map(e=>e.range):[]))]);this.disposeWithMe((0,r.toDisposable)(e.pipe((0,c.switchMap)(([e,t])=>new s.Observable(n=>{let i=new r.DisposableCollection;return e&&t.length&&n.next({selectionRanges:t,disposableCollection:i}),()=>{i.dispose()}})),(0,c.tap)(()=>{this._previewPattern=null})).subscribe(({disposableCollection:e,selectionRanges:n})=>{var i;let o=this._univerInstanceService.getCurrentUnitOfType(r.UniverInstanceType.UNIVER_SHEET);this.openPanel(),e.add(this._sheetInterceptorService.intercept(a.INTERCEPTOR_POINT.CELL_CONTENT,{priority:99,effect:r.InterceptorEffectEnum.Value|r.InterceptorEffectEnum.Style,handler:(e,i,a)=>{let{row:o,col:s}=i,c=a(e)||{};if(n.find(e=>e.startColumn<=s&&e.endColumn>=s&&e.startRow<=o&&e.endRow>=o)){let e=i.worksheet.getCellRaw(o,s),n=e==null?void 0:e.v,a=e==null?void 0:e.t;if(n==null||a!==r.CellValueType.NUMBER||this._previewPattern===null)return c;let u=(0,t.getPatternPreviewIgnoreGeneral)(this._previewPattern,n,this._sheetsNumfmtCellContentController.locale);if(u.color){var l;let e=(l=this._themeService.getColorFromTheme(`${u.color}.500`))==null?u.color:l;return{...c,v:u.result,t:r.CellValueType.STRING,s:{cl:{rgb:e}}}}return{...c,v:u.result,t:r.CellValueType.STRING}}return c}})),(i=this._renderManagerService.getRenderUnitById(o.getUnitId()))==null||(i=i.mainComponent)==null||i.makeDirty()})))}_commandExecutedListener(){let e=[a.RemoveNumfmtMutation.id,a.SetNumfmtMutation.id];this.disposeWithMe(new s.Observable(t=>{let n=this._commandService.onCommandExecuted(n=>{if(e.includes(n.id)){let e=n.params;t.next(e.unitId)}});return()=>n.dispose()}).pipe((0,c.debounceTime)(16)).subscribe(e=>this._forceUpdate(e)))}_initCloseListener(){this._univerInstanceService.getCurrentTypeOfUnit$(r.UniverInstanceType.UNIVER_SHEET).subscribe(e=>{if(!e){var t;(t=this._sidebarDisposable)==null||t.dispose(),this._sidebarDisposable=null}})}};b=y([v(0,(0,r.Inject)(a.SheetInterceptorService)),v(1,(0,r.Inject)(r.ThemeService)),v(2,r.IUniverInstanceService),v(3,r.ICommandService),v(4,(0,r.Inject)(a.SheetsSelectionsService)),v(5,i.IRenderManagerService),v(6,a.INumfmtService),v(7,n.ISidebarService),v(8,(0,r.Inject)(r.LocaleService)),v(9,(0,r.Inject)(t.SheetsNumfmtCellContentController))],b);let x={id:`sheet.operation.open.numfmt.panel`,type:r.CommandType.OPERATION,handler:e=>(e.get(b).openPanel(),!0)},S=`sheets-numfmt-ui.moreNumfmtType`,C=`sheets-numfmt-ui.moreNumfmtType.options`;function w(e){let{value:t}=e,i=(0,n.useDependency)(r.LocaleService);return(0,d.jsx)(`span`,{className:`univer-text-sm`,children:t==null?i.t(`sheets-numfmt-ui.general`):t})}function ee(){let e=(0,n.useDependency)(r.ICommandService),i=(0,n.useDependency)(r.LocaleService),o=(0,n.useDependency)(r.RegionService),s=(0,n.useDependency)(n.ILayoutService),c=(0,n.useDependency)(t.SheetsNumfmtCellContentController),f=(0,n.useObservable)(i.direction$,i.getDirection()),p=(0,n.useObservable)(o.currentRegion$,o.getCurrentRegion()),m=(0,n.useDependency)(a.SheetsSelectionsService),h=n=>{let i=m.getCurrentLastSelection();if(!i)return;let a=i.range,o=[];r.Range.foreach(a,(e,r)=>{n?o.push({row:e,col:r,pattern:n,type:(0,t.getPatternType)(n)}):o.push({row:e,col:r})}),e.executeCommand(t.SetNumfmtCommand.id,{values:o}),s.focus()},g=(0,u.useMemo)(()=>T((0,t.getCurrencySymbolByLocale)(p)),[p]),_=t=>{if(t===0)h(null);else if(t===g.length-1)e.executeCommand(x.id),s.focus();else{let e=g[t];e.pattern&&h(e.pattern)}};return(0,d.jsx)(`div`,{dir:f,className:`univer-grid univer-gap-1 univer-p-1.5`,children:g.map((e,n)=>e===`|`?(0,d.jsx)(l.Separator,{},n):(0,d.jsxs)(`div`,{className:`univer-flex univer-h-7 univer-cursor-default univer-items-center univer-justify-between univer-gap-6 univer-rounded univer-px-2 univer-text-sm hover:univer-bg-gray-100 dark:hover:!univer-bg-gray-700`,onClick:()=>_(n),children:[(0,d.jsx)(`span`,{children:i.t(e.label)}),(0,d.jsx)(`span`,{className:`univer-text-xs univer-text-gray-500 dark:!univer-text-gray-400`,children:e.pattern?(0,t.getPatternPreview)(e.pattern||``,1220,c.locale).result.trim():``})]},n))})}let T=e=>[{label:`sheets-numfmt-ui.general`,pattern:null},{label:`sheets-numfmt-ui.text`,pattern:r.DEFAULT_TEXT_FORMAT_EXCEL},`|`,{label:`sheets-numfmt-ui.number`,pattern:`0`},{label:`sheets-numfmt-ui.percent`,pattern:`0.00%`},{label:`sheets-numfmt-ui.scientific`,pattern:`0.00E+00`},`|`,{label:`sheets-numfmt-ui.accounting`,pattern:`"${e}" #,##0.00_);[Red]("${e}"#,##0.00)`},{label:`sheets-numfmt-ui.financialValue`,pattern:`#,##0.00;[Red]#,##0.00`},{label:`sheets-numfmt-ui.currency`,pattern:`"${e}"#,##0.00_);[Red]("${e}"#,##0.00)`},{label:`sheets-numfmt-ui.roundingCurrency`,pattern:`"${e}"#,##0;[Red]"${e}"#,##0`},`|`,{label:`sheets-numfmt-ui.date`,pattern:`yyyy-mm-dd;@`},{label:`sheets-numfmt-ui.time`,pattern:`am/pm h":"mm":"ss`},{label:`sheets-numfmt-ui.dateTime`,pattern:`yyyy-m-d am/pm h:mm`},{label:`sheets-numfmt-ui.timeDuration`,pattern:`h:mm:ss`},`|`,{label:`sheets-numfmt-ui.moreFmt`,pattern:``}];function E(e){return{icon:e.get(r.RegionService).currentRegion$.pipe((0,s.map)(e=>(0,t.getCurrencySymbolIconByLocale)(e).icon)),id:t.SetCurrencyCommand.id,title:`sheets-numfmt-ui.currency`,tooltip:`sheets-numfmt-ui.currency`,type:n.MenuItemType.BUTTON,hidden$:(0,n.getMenuHiddenObservable)(e,r.UniverInstanceType.UNIVER_SHEET),disabled$:(0,o.getCurrentRangeDisable$)(e,{workbookTypes:[a.WorkbookEditablePermission],worksheetTypes:[a.WorksheetEditPermission,a.WorksheetSetCellStylePermission],rangeTypes:[a.RangeProtectionPermissionEditPoint]})}}function D(e){return{icon:`AddDigitsIcon`,id:t.AddDecimalCommand.id,title:`sheets-numfmt-ui.addDecimal`,tooltip:`sheets-numfmt-ui.addDecimal`,type:n.MenuItemType.BUTTON,hidden$:(0,n.getMenuHiddenObservable)(e,r.UniverInstanceType.UNIVER_SHEET),disabled$:(0,o.getCurrentRangeDisable$)(e,{workbookTypes:[a.WorkbookEditablePermission],worksheetTypes:[a.WorksheetEditPermission,a.WorksheetSetCellStylePermission],rangeTypes:[a.RangeProtectionPermissionEditPoint]})}}function O(e){return{icon:`ReduceDigitsIcon`,id:t.SubtractDecimalCommand.id,title:`sheets-numfmt-ui.subtractDecimal`,tooltip:`sheets-numfmt-ui.subtractDecimal`,type:n.MenuItemType.BUTTON,hidden$:(0,n.getMenuHiddenObservable)(e,r.UniverInstanceType.UNIVER_SHEET),disabled$:(0,o.getCurrentRangeDisable$)(e,{workbookTypes:[a.WorkbookEditablePermission],worksheetTypes:[a.WorksheetEditPermission,a.WorksheetSetCellStylePermission],rangeTypes:[a.RangeProtectionPermissionEditPoint]})}}function te(e){return{icon:`PercentIcon`,id:t.SetPercentCommand.id,title:`sheets-numfmt-ui.percent`,tooltip:`sheets-numfmt-ui.percent`,type:n.MenuItemType.BUTTON,hidden$:(0,n.getMenuHiddenObservable)(e,r.UniverInstanceType.UNIVER_SHEET),disabled$:(0,o.getCurrentRangeDisable$)(e,{workbookTypes:[a.WorkbookEditablePermission],worksheetTypes:[a.WorksheetEditPermission,a.WorksheetSetCellStylePermission],rangeTypes:[a.RangeProtectionPermissionEditPoint]})}}function ne(e){let i=e.get(r.IUniverInstanceService),c=e.get(r.ICommandService),l=e.get(r.LocaleService),u=e.get(r.RegionService),d=e.get(a.SheetsSelectionsService),f=[a.RemoveNumfmtMutation.id,a.SetNumfmtMutation.id],p=(0,o.deriveStateFromActiveSheet$)(i,``,({workbook:e,worksheet:n})=>new s.Observable(i=>(0,s.merge)(d.selectionMoveEnd$,u.currentRegion$,(0,r.fromCallback)(c.onCommandExecuted.bind(c)).pipe((0,s.filter)(([e])=>f.includes(e.id)))).subscribe(()=>{let a=d.getCurrentSelections();if(a&&a[0]){var o,s;let c=a[0].range,d=c.startRow,f=c.startColumn,p=(o=e.getStyles().get((s=n.getCell(d,f))==null?void 0:s.s))==null?void 0:o.n,m=p==null?void 0:p.pattern,h=(0,t.getCurrencySymbolByLocale)(u.getCurrentRegion()),g=l.t(`sheets-numfmt-ui.general`);if((0,r.isDefaultFormat)(m)){i.next(g);return}if(m){let e=T(h).filter(e=>typeof e==`object`&&e.pattern).find(e=>(0,r.isPatternEqualWithoutDecimal)(m,e.pattern));g=e&&typeof e==`object`&&e.pattern?l.t(e.label):l.t(`sheets-numfmt-ui.moreFmt`)}i.next(g)}})));return{label:S,id:x.id,tooltip:`sheets-numfmt-ui.title`,type:n.MenuItemType.SELECTOR,slot:!0,selections:[{label:{name:C,hoverable:!1,selectable:!1}}],value$:p,hidden$:(0,n.getMenuHiddenObservable)(e,r.UniverInstanceType.UNIVER_SHEET),disabled$:(0,o.getCurrentRangeDisable$)(e,{workbookTypes:[a.WorkbookEditablePermission],worksheetTypes:[a.WorksheetSetCellStylePermission,a.WorksheetEditPermission],rangeTypes:[a.RangeProtectionPermissionEditPoint]})}}let re={[n.RibbonStartGroup.NUMBER]:{[x.id]:{order:9,gridLayout:{row:1,column:1,columnSpan:4,width:210},menuItemFactory:ne},[t.SetPercentCommand.id]:{order:9.1,gridLayout:{row:2,column:1},menuItemFactory:te},[t.SetCurrencyCommand.id]:{order:9.2,gridLayout:{row:2,column:2},menuItemFactory:E},[t.AddDecimalCommand.id]:{order:9.3,gridLayout:{row:2,column:3},menuItemFactory:D},[t.SubtractDecimalCommand.id]:{order:9.4,gridLayout:{row:2,column:4},menuItemFactory:O}}};var ie=`@univerjs/sheets-numfmt-ui`,ae=`1.0.0-alpha.8`;let oe={};function k({ref:e,...t}){let{icon:n,id:r,className:i,extend:a,...o}=t,s=`univerjs-icon univerjs-icon-${r} ${i||``}`.trim(),c=(0,u.useRef)(`_${le()}`);return A(n,`${r}`,{defIds:n.defIds,idSuffix:c.current},{ref:e,className:s,...o},a)}function A(e,t,n,r,i){return(0,u.createElement)(e.tag,{key:t,...se(e,n,i),...r},(ce(e,n).children||[]).map((r,a)=>A(r,`${t}-${e.tag}-${a}`,n,void 0,i)))}function se(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 ce(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 le(){return Math.random().toString(36).substring(2,8)}k.displayName=`UniverIcon`;let ue={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.06641 3.49366C4.06641 2.27555 5.14145 1.3916 6.33307 1.3916C7.52469 1.3916 8.59974 2.27555 8.59974 3.49366V6.49777C8.59974 7.71586 7.52469 8.59982 6.33307 8.59982C5.14145 8.59982 4.06641 7.71586 4.06641 6.49777V3.49366ZM6.33307 2.5916C5.68376 2.5916 5.26641 3.05264 5.26641 3.49366V6.49777C5.26641 6.93878 5.68376 7.39982 6.33307 7.39982C6.98239 7.39982 7.39974 6.93878 7.39974 6.49777V3.49366C7.39974 3.05264 6.98239 2.5916 6.33307 2.5916Z`,fillRule:`evenodd`,clipRule:`evenodd`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M10.0664 3.49366C10.0664 2.27555 11.1415 1.3916 12.3331 1.3916C13.5247 1.3916 14.5997 2.27555 14.5997 3.49366V6.49777C14.5997 7.71586 13.5247 8.59982 12.3331 8.59982C11.1415 8.59982 10.0664 7.71586 10.0664 6.49777V3.49366ZM12.3331 2.5916C11.6838 2.5916 11.2664 3.05264 11.2664 3.49366V6.49777C11.2664 6.93878 11.6838 7.39982 12.3331 7.39982C12.9824 7.39982 13.3997 6.93878 13.3997 6.49777V3.49366C13.3997 3.05264 12.9824 2.5916 12.3331 2.5916Z`,fillRule:`evenodd`,clipRule:`evenodd`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M12.4242 9.5417C12.1899 9.30739 11.81 9.30739 11.5756 9.5417C11.3413 9.77602 11.3413 10.1559 11.5756 10.3902L12.5514 11.366H6.3334C6.00203 11.366 5.7334 11.6346 5.7334 11.966C5.7334 12.2973 6.00203 12.566 6.3334 12.566H12.5514L11.5756 13.5417C11.3413 13.776 11.3413 14.1559 11.5756 14.3902C11.81 14.6245 12.1899 14.6245 12.4242 14.3902L14.4159 12.3985C14.5294 12.2893 14.6001 12.1359 14.6001 11.966C14.6001 11.796 14.5294 11.6426 14.4159 11.5334L12.4242 9.5417Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M1.3999 8.3002C1.3999 7.96882 1.66853 7.7002 1.9999 7.7002H2.33324C2.66461 7.7002 2.93324 7.96882 2.93324 8.3002C2.93324 8.63157 2.66461 8.9002 2.33324 8.9002H1.9999C1.66853 8.9002 1.3999 8.63157 1.3999 8.3002Z`}}]},j=(0,u.forwardRef)(function(e,t){return(0,u.createElement)(k,Object.assign({},e,{id:`add-digits-icon`,ref:t,icon:ue}))});j.displayName=`AddDigitsIcon`;let de={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:`M14.1544 3.75557C14.3887 3.98988 14.3887 4.36978 14.1544 4.6041L6.51409 12.2444C6.40157 12.3569 6.24896 12.4201 6.08983 12.4201C5.9307 12.4201 5.77808 12.3569 5.66556 12.2444L1.84541 8.42425C1.6111 8.18993 1.6111 7.81003 1.84541 7.57572C2.07973 7.34141 2.45963 7.34141 2.69394 7.57572L6.08983 10.9716L13.3059 3.75557C13.5402 3.52126 13.9201 3.52126 14.1544 3.75557Z`,fillRule:`evenodd`,clipRule:`evenodd`}}]},M=(0,u.forwardRef)(function(e,t){return(0,u.createElement)(k,Object.assign({},e,{id:`check-mark-icon`,ref:t,icon:de}))});M.displayName=`CheckMarkIcon`;let fe={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:`M7.3999 2.8999V1.6C7.3999 1.26863 7.66853 1 7.9999 1C8.33127 1 8.5999 1.26863 8.5999 1.6V2.8999H10.2044C11.6655 2.8999 12.8499 4.08431 12.8499 5.54536C12.8499 5.87673 12.5813 6.14536 12.2499 6.14536C11.9185 6.14536 11.6499 5.87673 11.6499 5.54536C11.6499 4.74705 11.0028 4.0999 10.2044 4.0999H5.7384C4.97155 4.0999 4.3499 4.72155 4.3499 5.4884C4.3499 6.14439 4.80899 6.71087 5.45074 6.84677L10.7977 7.97906C11.994 8.23242 12.8499 9.28849 12.8499 10.5114C12.8499 11.941 11.691 13.0999 10.2614 13.0999H8.5999V14.4C8.5999 14.7314 8.33127 15 7.9999 15C7.66853 15 7.3999 14.7314 7.3999 14.4V13.0999H5.79536C4.33431 13.0999 3.1499 11.9155 3.1499 10.4544C3.1499 10.1231 3.41853 9.85445 3.7499 9.85445C4.08127 9.85445 4.3499 10.1231 4.3499 10.4544C4.3499 11.2527 4.99705 11.8999 5.79536 11.8999H10.2614C11.0283 11.8999 11.6499 11.2782 11.6499 10.5114C11.6499 9.85542 11.1908 9.28893 10.5491 9.15303L5.20214 8.02074C4.00575 7.76739 3.1499 6.71132 3.1499 5.4884C3.1499 4.05881 4.30881 2.8999 5.7384 2.8999H7.3999Z`}}]},N=(0,u.forwardRef)(function(e,t){return(0,u.createElement)(k,Object.assign({},e,{id:`dollar-icon`,ref:t,icon:fe}))});N.displayName=`DollarIcon`;let pe={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:`M12.2058 3.459H11.2416V12.6604H9.6438V11.6962Q8.9091 12.844 7.4858 12.844Q5.8971 12.844 4.8456 11.6686Q3.7942 10.4932 3.7942 8.5739Q3.7942 6.5904 4.7814 5.4471Q5.7685 4.3038 7.4031 4.3038Q8.9183 4.3038 9.5887 5.3415V3.459H7.5041V2.1091H9.5887V1.2H11.2416V2.1091H12.2058V3.459ZM7.6143 11.4941Q8.5234 11.4941 9.0744 10.8008Q9.6254 10.1075 9.6254 8.7484Q9.6254 5.6629 7.5592 5.6629Q6.5491 5.6629 6.0211 6.4297Q5.493 7.1965 5.493 8.5923Q5.493 11.4941 7.6143 11.4941ZM11.2416 14.8H4.0421V13.4501H11.2416V14.8Z`}}]},P=(0,u.forwardRef)(function(e,t){return(0,u.createElement)(k,Object.assign({},e,{id:`dong-icon`,ref:t,icon:pe}))});P.displayName=`DongIcon`;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:`M5.84964 5.80918C6.71946 3.63548 8.84516 2.2 11.3295 2.2C11.8324 2.2 12.3198 2.26279 12.7846 2.38065C13.1058 2.46209 13.4322 2.26773 13.5137 1.94652C13.5951 1.62532 13.4008 1.2989 13.0795 1.21746C12.5191 1.07535 11.9327 1 11.3295 1C8.17278 1 5.49724 2.96009 4.57394 5.80918H3.06582C2.73445 5.80918 2.46582 6.07781 2.46582 6.40918C2.46582 6.74055 2.73445 7.00918 3.06582 7.00918H4.29808C4.25287 7.33297 4.22949 7.66376 4.22949 8C4.22949 8.33608 4.25284 8.6667 4.29801 8.99033H3.06582C2.73445 8.99033 2.46582 9.25896 2.46582 9.59033C2.46582 9.9217 2.73445 10.1903 3.06582 10.1903H4.57378C5.49693 13.0397 8.1726 15 11.3295 15C11.9336 15 12.5209 14.9244 13.0821 14.7819C13.4033 14.7003 13.5975 14.3738 13.5159 14.0527C13.4344 13.7315 13.1079 13.5373 12.7867 13.6188C12.3213 13.737 11.8332 13.8 11.3295 13.8C8.84497 13.8 6.71914 12.3643 5.84944 10.1903H11.4291C11.7605 10.1903 12.0291 9.9217 12.0291 9.59033C12.0291 9.25896 11.7605 8.99033 11.4291 8.99033H5.51225C5.45783 8.66834 5.42949 8.33748 5.42949 8C5.42949 7.66235 5.45786 7.33133 5.51233 7.00918H11.4291C11.7605 7.00918 12.0291 6.74055 12.0291 6.40918C12.0291 6.07781 11.7605 5.80918 11.4291 5.80918H5.84964Z`}}]},F=(0,u.forwardRef)(function(e,t){return(0,u.createElement)(k,Object.assign({},e,{id:`euro-icon`,ref:t,icon:me}))});F.displayName=`EuroIcon`;let he={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:`M1.85059 4.06725C1.85059 2.84302 2.84302 1.85059 4.06725 1.85059C5.29148 1.85059 6.28392 2.84302 6.28392 4.06725C6.28392 5.29148 5.29148 6.28392 4.06725 6.28392C2.84302 6.28392 1.85059 5.29148 1.85059 4.06725ZM4.06725 2.95059C3.45053 2.95059 2.95059 3.45053 2.95059 4.06725C2.95059 4.68397 3.45053 5.18392 4.06725 5.18392C4.68397 5.18392 5.18392 4.68397 5.18392 4.06725C5.18392 3.45053 4.68397 2.95059 4.06725 2.95059Z`,fillRule:`evenodd`,clipRule:`evenodd`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M9.7168 11.933C9.7168 10.7087 10.7092 9.71631 11.9335 9.71631C13.1577 9.71631 14.1501 10.7087 14.1501 11.933C14.1501 13.1572 13.1577 14.1496 11.9335 14.1496C10.7092 14.1496 9.7168 13.1572 9.7168 11.933ZM11.9335 10.8163C11.3167 10.8163 10.8168 11.3163 10.8168 11.933C10.8168 12.5497 11.3167 13.0496 11.9335 13.0496C12.5502 13.0496 13.0501 12.5497 13.0501 11.933C13.0501 11.3163 12.5502 10.8163 11.9335 10.8163Z`,fillRule:`evenodd`,clipRule:`evenodd`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M13.5241 3.32407C13.7584 3.08975 13.7584 2.70986 13.5241 2.47554C13.2898 2.24123 12.9099 2.24123 12.6755 2.47554L2.47554 12.6755C2.24123 12.9099 2.24123 13.2898 2.47554 13.5241C2.70986 13.7584 3.08975 13.7584 3.32407 13.5241L13.5241 3.32407Z`}}]},I=(0,u.forwardRef)(function(e,t){return(0,u.createElement)(k,Object.assign({},e,{id:`percent-icon`,ref:t,icon:he}))});I.displayName=`PercentIcon`;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:`path`,attrs:{fill:`currentColor`,d:`M6.33307 1.3916C5.14145 1.3916 4.06641 2.27555 4.06641 3.49366V6.49777C4.06641 7.71586 5.14145 8.59982 6.33307 8.59982C7.52469 8.59982 8.59974 7.71586 8.59974 6.49777V3.49366C8.59974 2.27555 7.52469 1.3916 6.33307 1.3916ZM5.26641 3.49366C5.26641 3.05264 5.68376 2.5916 6.33307 2.5916C6.98239 2.5916 7.39974 3.05264 7.39974 3.49366V6.49777C7.39974 6.93878 6.98239 7.39982 6.33307 7.39982C5.68376 7.39982 5.26641 6.93878 5.26641 6.49777V3.49366Z`,fillRule:`evenodd`,clipRule:`evenodd`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M7.90913 9.5417C8.14345 9.30739 8.52335 9.30739 8.75766 9.5417C8.99198 9.77602 8.99198 10.1559 8.75766 10.3902L7.78193 11.366H13.9999C14.3313 11.366 14.5999 11.6346 14.5999 11.966C14.5999 12.2973 14.3313 12.566 13.9999 12.566H7.78193L8.75766 13.5417C8.99198 13.776 8.99198 14.1559 8.75766 14.3902C8.52335 14.6245 8.14345 14.6245 7.90913 14.3902L5.91739 12.3985C5.80388 12.2893 5.73324 12.1359 5.73324 11.966C5.73324 11.796 5.80388 11.6426 5.91739 11.5334L7.90913 9.5417Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M1.3999 8.3002C1.3999 7.96882 1.66853 7.7002 1.9999 7.7002H2.33324C2.66461 7.7002 2.93324 7.96882 2.93324 8.3002C2.93324 8.63157 2.66461 8.9002 2.33324 8.9002H1.9999C1.66853 8.9002 1.3999 8.63157 1.3999 8.3002Z`}}]},L=(0,u.forwardRef)(function(e,t){return(0,u.createElement)(k,Object.assign({},e,{id:`reduce-digits-icon`,ref:t,icon:ge}))});L.displayName=`ReduceDigitsIcon`;let _e={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M6.7937 8.6977Q6.7937 9.5729 6.7228 9.9277Q6.6045 10.8264 5.7057 11.3704Q4.8543 11.8908 3.577 12.0327H3.4115Q2.6783 12.0327 2.2052 11.3468Q1.7795 10.7555 1.7795 9.9277Q1.7795 9.5965 1.945 8.887Q2.1343 8.0828 2.3944 7.8226Q2.4417 7.7517 2.5127 7.7517Q2.6546 7.7517 2.6546 7.9172Q2.6546 7.9882 2.489 8.4139Q2.3235 8.8397 2.3235 9.0762Q2.3235 9.904 2.7256 10.2588Q3.1277 10.6136 3.9791 10.6136Q4.9016 10.6136 5.6111 10.1878Q6.4863 9.6911 6.4153 8.8397Q6.2261 8.1774 5.8713 6.4271Q5.4456 4.2038 5.1617 3.0449Q4.9489 2.6191 4.807 2.4536Q4.9489 2.1934 5.0198 1.8859Q5.1617 1.2 5.28 1.2Q5.351 1.2 5.4456 1.4602Q5.5638 1.744 5.6821 1.8623Q6.1078 2.217 6.1551 2.288Q6.1551 2.3353 6.1788 2.3826Q6.2261 2.6191 5.9186 3.2577Q6.2024 4.535 6.4863 6.4271Q6.6991 7.8463 6.7937 8.6977ZM11.3586 8.9816Q11.3823 9.6911 11.0748 10.3061Q10.8856 10.7082 10.0577 10.7082Q9.3009 10.7082 8.8751 9.9277Q8.5677 9.4073 8.4021 7.8226Q8.1656 5.8122 7.9054 4.0146Q7.7398 3.0922 7.6452 2.6428L7.7871 1.9332Q7.8581 1.4602 7.929 1.4602Q7.9763 1.4602 8 1.5784Q8.2365 2.2407 8.4257 3.8963Q8.7096 6.167 8.8042 6.6637Q9.0643 8.5795 9.2299 8.9106Q9.3245 9.1235 9.5729 9.3127Q9.8212 9.5019 10.0577 9.5019Q10.72 9.5019 10.791 9.1471Q10.7437 8.9816 10.4835 8.6268Q10.2706 8.2957 10.247 8.0355L10.3889 7.657Q10.4598 7.4442 10.5781 7.2077Q10.6017 7.184 10.6254 7.184Q10.8383 7.184 11.0275 7.6334Q11.335 8.272 11.3586 8.9816ZM14.2205 10.7318Q14.2205 12.2219 13.511 13.3099Q13.1325 13.8776 12.2574 14.6108Q11.9736 14.8 11.4532 14.8Q10.9329 14.8 9.3245 14.4689Q9.2536 14.4689 9.1471 14.3624Q9.0407 14.256 9.0407 14.2087Q9.0643 14.185 9.0643 14.185L9.088 14.1614Q9.703 14.1141 10.0577 14.1141Q10.72 14.0904 11.0038 13.9722Q13.1089 13.1917 13.7475 11.2995Q13.6765 11.1339 13.2035 10.3061Q12.825 9.6438 12.825 9.3363Q12.825 9.289 12.9197 9.1471Q12.9433 9.1235 13.0379 8.7923Q13.1089 8.5558 13.1798 8.5558Q13.4637 8.5558 13.8657 9.3363Q14.2205 10.0459 14.2205 10.377V10.7318ZM10.6017 12.1273Q10.6254 12.1983 10.4243 12.6122Q10.2233 13.0261 10.105 13.0261Q9.9631 13.0261 9.6793 12.7777Q9.3955 12.5294 9.3245 12.3638Q9.632 11.536 9.7976 11.465Q9.8685 11.465 10.1997 11.7607Q10.5308 12.0563 10.6017 12.1273ZM9.1353 12.4584Q9.159 12.6003 8.9579 12.967Q8.7569 13.3336 8.6386 13.3336Q8.4967 13.3336 8.201 13.097Q7.9054 12.8605 7.9054 12.7423Q7.8344 12.553 8.3075 11.8198Q8.6386 11.9617 9.1353 12.4584Z`}}]},R=(0,u.forwardRef)(function(e,t){return(0,u.createElement)(k,Object.assign({},e,{id:`rial-icon`,ref:t,icon:_e}))});R.displayName=`RialIcon`;let ve={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.9445 1.55649C12.2184 1.744 12.2895 2.11755 12.1033 2.39085L9.24342 6.58659H12.8001C13.1315 6.58659 13.4001 6.85522 13.4001 7.18659C13.4001 7.51796 13.1315 7.78659 12.8001 7.78659H8.5999V9.91276H13.2221C13.5534 9.91276 13.8221 10.1814 13.8221 10.5128C13.8221 10.8441 13.5534 11.1128 13.2221 11.1128H8.5999V14.0877C8.5999 14.4191 8.33127 14.6877 7.9999 14.6877C7.66853 14.6877 7.3999 14.4191 7.3999 14.0877V11.1128H2.77773C2.44636 11.1128 2.17773 10.8441 2.17773 10.5128C2.17773 10.1814 2.44636 9.91276 2.77773 9.91276H7.3999V7.78659H3.2001C2.86873 7.78659 2.6001 7.51796 2.6001 7.18659C2.6001 6.85522 2.86873 6.58659 3.2001 6.58659H6.75736L3.89753 2.39085C3.71125 2.11755 3.78234 1.744 4.05631 1.55649C4.33029 1.36899 4.7034 1.43854 4.88968 1.71184L7.94595 6.19577C7.96752 6.22741 7.98564 6.2604 8.00039 6.29429C8.01514 6.2604 8.03326 6.22741 8.05483 6.19577L11.1111 1.71184C11.2974 1.43854 11.6705 1.36899 11.9445 1.55649Z`}}]},z=(0,u.forwardRef)(function(e,t){return(0,u.createElement)(k,Object.assign({},e,{id:`rmb-icon`,ref:t,icon:ve}))});z.displayName=`RmbIcon`;let ye={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:`M9.72502 1.02051H6.07803C4.97346 1.02051 4.07803 1.91594 4.07803 3.02051V7.57046H3.00039C2.66902 7.57046 2.40039 7.83909 2.40039 8.17046C2.40039 8.50183 2.66902 8.77046 3.00039 8.77046H4.07803V10.4854H3.00039C2.66902 10.4854 2.40039 10.754 2.40039 11.0854C2.40039 11.4167 2.66902 11.6854 3.00039 11.6854H4.07803V14.3795C4.07803 14.7108 4.34666 14.9795 4.67803 14.9795C5.0094 14.9795 5.27803 14.7108 5.27803 14.3795V11.6854H10.3637C10.695 11.6854 10.9637 11.4167 10.9637 11.0854C10.9637 10.754 10.695 10.4854 10.3637 10.4854H5.27803V8.77046H9.72503C11.8651 8.77046 13.6 7.03557 13.6 4.89548C13.6 2.75539 11.8651 1.02051 9.72502 1.02051ZM9.72503 7.57046H5.27803V3.12051C5.27803 2.62345 5.68097 2.22051 6.17803 2.22051H9.72502C11.2024 2.22051 12.4 3.41814 12.4 4.89548C12.4 6.37283 11.2024 7.57046 9.72503 7.57046Z`,fillRule:`evenodd`,clipRule:`evenodd`}}]},B=(0,u.forwardRef)(function(e,t){return(0,u.createElement)(k,Object.assign({},e,{id:`rouble-icon`,ref:t,icon:ye}))});B.displayName=`RoubleIcon`;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:`path`,attrs:{fill:`currentColor`,d:`M8.5953 11.0279H7.1987Q5.9451 9.0475 5.6418 8.5953Q5.3384 8.1431 5.0035 7.8197Q4.6687 7.4963 4.3739 7.4104Q4.0791 7.3246 3.5926 7.3246H2.3104V11.0279H1.2V2.6367H4.9148Q5.6761 2.6367 6.1912 2.734Q6.7064 2.8313 7.0956 3.1433Q7.4848 3.4552 7.6938 3.9303Q7.9027 4.4054 7.9027 4.932Q7.9027 5.8822 7.3017 6.4603Q6.7007 7.0384 5.5502 7.1929V7.2158Q6.3916 7.5879 7.13 8.7441L8.5953 11.0279ZM2.3104 6.3286H4.6916Q5.4128 6.3286 5.8335 6.2056Q6.2542 6.0825 6.5061 5.7276Q6.7579 5.3727 6.7579 4.932Q6.7579 4.3596 6.3401 3.9589Q5.9222 3.5582 4.9606 3.5582H2.3104V6.3286ZM10.4842 5.7391Q11.0623 4.8175 12.2185 4.8175Q13.4148 4.8175 14.1074 5.6847Q14.8 6.5519 14.8 7.9428Q14.8 9.4253 14.033 10.2981Q13.266 11.171 12.1498 11.171Q11.171 11.171 10.5815 10.3926H10.5529V13.3633H9.5226V4.9549H10.4613V5.7391H10.4842ZM12.0811 10.3239Q12.8024 10.3239 13.2746 9.7258Q13.7468 9.1276 13.7468 7.9428Q13.7468 6.8266 13.2918 6.2256Q12.8367 5.6246 12.1269 5.6246Q11.3943 5.6246 10.9221 6.2943Q10.4498 6.964 10.4498 8.0286Q10.4498 9.1562 10.902 9.7401Q11.3542 10.3239 12.0811 10.3239Z`}}]},V=(0,u.forwardRef)(function(e,t){return(0,u.createElement)(k,Object.assign({},e,{id:`rupiah-icon`,ref:t,icon:be}))});V.displayName=`RupiahIcon`;let xe={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:`M14.8 9.4486H12.955L11.8883 13.2829H10.5477L9.4811 9.4486H6.5189L5.4378 13.2829H4.0108L2.9874 9.4486H1.2V8.4685H2.7351L2.4541 7.409H1.2V6.436H2.1946L1.2 2.7171H2.6342L3.4919 6.436H6.1153L7.182 2.7171H8.8613L9.9135 6.436H12.4649L13.3802 2.7171H14.8L13.7622 6.436H14.8V7.409H13.5099L13.2144 8.4685H14.8V9.4486ZM8.645 6.436Q8.0757 4.3676 7.9892 4Q7.8667 4.6342 7.3261 6.436H8.645ZM12.2414 7.409H10.209L10.5045 8.4685H11.9748L12.2414 7.409ZM9.2144 8.4685L8.9189 7.409H7.0739L6.7856 8.4685H9.2144ZM5.8559 7.409H3.7297L3.9748 8.4685H5.5604L5.8559 7.409ZM11.7586 9.4486H10.7351Q11.0955 11.1063 11.1964 11.8054L11.7586 9.4486ZM5.2937 9.4486H4.1838Q4.573 11.1063 4.7027 11.8054Q4.955 10.7315 5.2937 9.4486Z`}}]},H=(0,u.forwardRef)(function(e,t){return(0,u.createElement)(k,Object.assign({},e,{id:`won-icon`,ref:t,icon:xe}))});H.displayName=`WonIcon`;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:`M10.092 14.8H1.3716V13.4548L7.6428 6.2652Q6.5389 6.3302 5.7596 6.3302H1.7334V4.9572H9.7858V6.0426L4.4516 12.2767Q4.2939 12.4715 3.6352 13.1858Q3.4775 13.3342 3.4218 13.4363Q4.3774 13.3528 5.5277 13.3528H10.092V14.8ZM14.6284 6.9888L13.376 8.0557V14.8H11.7247V9.4843L10.5094 10.4862V9.0205L11.7247 8.0186V1.2H13.376V6.5899L14.6284 5.5323V6.9888Z`}}]},Ce=(0,u.forwardRef)(function(e,t){return(0,u.createElement)(k,Object.assign({},e,{id:`zloty-icon`,ref:t,icon:Se}))});Ce.displayName=`ZlotyIcon`;let U=(0,u.createContext)([]),W=class{constructor(e){this._localStorageService=e}_getKey(e){return`userHabitController_${e}`}async addHabit(e,t){let n=this._getKey(e);return this._localStorageService.getItem(n).then(e=>{e||this._localStorageService.setItem(n,t)})}markHabit(e,t){let n=this._getKey(e);this._localStorageService.getItem(n).then(e=>{if(e){let r=e.findIndex(e=>e===t);r>-1&&e.splice(r,1),e.unshift(t),this._localStorageService.setItem(n,e)}})}async getHabit(e,t){let n=this._getKey(e),r=await this._localStorageService.getItem(n);if(t&&r){let e=r.map((e,t,n)=>({value:e,priority:n.length-t}));return t.sort((t,n)=>{var r,i;let a=((r=e.find(e=>e.value===t))==null?void 0:r.priority)||-1;return(((i=e.find(e=>e.value===n))==null?void 0:i.priority)||-1)-a})}return r||[]}deleteHabit(e){this._localStorageService.removeItem(e)}};W=y([v(0,(0,r.Inject)(r.ILocalStorageService))],W);let we=e=>!!(0,t.getCurrencyType)(e)&&e.startsWith(`_(`);function Te(e){let{defaultPattern:i,onActionChange:a,onChange:o}=e,[s,c]=(0,u.useState)(()=>(0,t.getDecimalFromPattern)(i||``,2)),f=(0,u.useContext)(U),[p,m]=(0,u.useState)(()=>(0,t.getCurrencyType)(i)||f[0]),h=(0,u.useMemo)(()=>f.map(e=>({label:e,value:e})),[]),g=(0,n.useDependency)(r.LocaleService);return(0,u.useLayoutEffect)(()=>{a(()=>(0,t.setPatternDecimal)(`_("${p}"* #,##0${s>0?`.0`:``}_)`,s))},[s,a,p]),(0,d.jsxs)(`div`,{children:[(0,d.jsxs)(`div`,{className:`univer-mt-4 univer-flex univer-justify-between`,children:[(0,d.jsxs)(`div`,{className:`option`,children:[(0,d.jsx)(`div`,{className:`univer-text-sm univer-text-gray-400`,children:g.t(`sheets-numfmt-ui.decimalLength`)}),(0,d.jsx)(`div`,{className:`univer-mt-2 univer-w-32`,children:(0,d.jsx)(l.InputNumber,{value:s,step:1,precision:0,max:20,min:0,onChange:e=>{let n=e||0;c(n),o((0,t.setPatternDecimal)(`_("${p}"* #,##0${n>0?`.0`:``}_)`,n))}})})]}),(0,d.jsxs)(`div`,{className:`option`,children:[(0,d.jsx)(`div`,{className:`univer-text-sm univer-text-gray-400`,children:g.t(`sheets-numfmt-ui.currencyType`)}),(0,d.jsx)(`div`,{className:`univer-mt-2 univer-w-36`,children:(0,d.jsx)(l.Select,{options:h,value:p,onChange:e=>{m(e),o((0,t.setPatternDecimal)(`_("${e}"* #,##0${s>0?`.0`:``}_)`,s))}})})]})]}),(0,d.jsx)(`div`,{className:`univer-mt-4 univer-text-sm univer-text-gray-400`,children:g.t(`sheets-numfmt-ui.accountingDes`)})]})}let Ee=e=>!!(0,t.getCurrencyType)(e)&&!e.startsWith(`_(`);function De(e){let{onActionChange:i,onChange:a}=e,o=(0,n.useDependency)(r.LocaleService),s=(0,u.useContext)(U),[c,f]=(0,u.useState)(()=>(0,t.getCurrencyType)(e.defaultPattern)||s[0]),[p,m]=(0,u.useState)(()=>(0,t.getDecimalFromPattern)(e.defaultPattern||``,2)),[h,g]=(0,u.useState)(()=>{var n;let i=(0,t.getCurrencyFormatOptions)(c);return((n=i.find(t=>(0,r.isPatternEqualWithoutDecimal)(t.value,e.defaultPattern)))==null?void 0:n.value)||i[0].value}),_=(0,u.useMemo)(()=>(0,t.getCurrencyFormatOptions)(c),[c]),v=(0,u.useMemo)(()=>s.map(e=>({label:e,value:e})),[s]);return(0,u.useLayoutEffect)(()=>{i(()=>(0,t.setPatternDecimal)(h,p))},[p,i,h]),(0,d.jsxs)(`div`,{children:[(0,d.jsxs)(`div`,{className:`univer-mt-4 univer-flex univer-justify-between`,children:[(0,d.jsxs)(`div`,{className:`option`,children:[(0,d.jsx)(`div`,{className:`univer-text-sm univer-text-gray-400`,children:o.t(`sheets-numfmt-ui.decimalLength`)}),(0,d.jsx)(`div`,{className:`univer-mt-2 univer-w-32`,children:(0,d.jsx)(l.InputNumber,{value:p,max:20,min:0,onChange:e=>{m(e||0),a((0,t.setPatternDecimal)(h,e||0))}})})]}),(0,d.jsxs)(`div`,{className:`option`,children:[(0,d.jsx)(`div`,{className:`univer-text-sm univer-text-gray-400`,children:o.t(`sheets-numfmt-ui.currencyType`)}),(0,d.jsx)(`div`,{className:`univer-mt-2 univer-w-36`,children:(0,d.jsx)(l.Select,{value:c,options:v,onChange:e=>{if(e===void 0)return;f(e);let n=(0,t.getCurrencyFormatOptions)(e)[0].value;g(n),a((0,t.setPatternDecimal)(n,p))}})})]})]}),(0,d.jsx)(`div`,{className:`label univer-mt-4`,children:o.t(`sheets-numfmt-ui.negType`)}),(0,d.jsx)(`div`,{className:`univer-mt-2`,children:(0,d.jsx)(l.SelectList,{value:h,options:_,onChange:e=>{e!==void 0&&(g(e),a((0,t.setPatternDecimal)(e,p)))}})}),(0,d.jsx)(`div`,{className:`univer-mt-4 univer-text-sm univer-text-gray-400`,children:o.t(`sheets-numfmt-ui.currencyDes`)})]})}let G=`customFormat`,K=`numfmt_custom_pattern`;function Oe(e){let{defaultPattern:i,onActionChange:a,onChange:o}=e,s=(0,n.useDependency)(W),c=(0,n.useDependency)(r.ILocalStorageService),f=(0,n.useDependency)(r.LocaleService),[p,m]=(0,u.useState)(i);(0,u.useLayoutEffect)(()=>{a(()=>(s.markHabit(G,p),c.getItem(K).then((e=[])=>{let t=[...new Set([p,...e||[]])].splice(0,10).filter(e=>!!e);c.setItem(K,t)}),p))},[c,a,p,s]);let[h,g]=(0,u.useState)([]);(0,u.useEffect)(()=>{let e=!1;return c.getItem(K).then(e=>{let n=[...t.CURRENCYFORMAT.map(e=>e.suffix(`$`)),...t.DATEFMTLISG.map(e=>e.suffix),...t.NUMBERFORMAT.map(e=>e.suffix),...e==null?[]:e];return s.addHabit(G,[]).then(()=>s.getHabit(G,n))}).then(t=>{e||g([...new Set(t)])}),()=>{e=!0}},[c,s]);let _=e=>{m(e),o(e)};return(0,d.jsxs)(`div`,{children:[(0,d.jsx)(`div`,{className:`univer-mt-4 univer-text-sm univer-text-gray-400`,children:f.t(`sheets-numfmt-ui.customFormat`)}),(0,d.jsx)(l.Input,{placeholder:f.t(`sheets-numfmt-ui.customFormat`),onBlur:()=>{o(p)},value:p,onChange:m,className:`univer-mt-2 univer-w-full`}),(0,d.jsx)(`div`,{className:(0,l.clsx)(`univer-mt-2 univer-max-h-[400px] univer-overflow-auto univer-rounded-lg univer-p-2`,l.borderClassName),children:h.map(e=>(0,d.jsxs)(`div`,{onClick:()=>_(e),className:`univer-flex univer-cursor-pointer univer-items-center univer-gap-1.5 univer-py-1.5 univer-text-sm`,children:[(0,d.jsx)(`div`,{className:`univer-flex univer-w-4 univer-items-center univer-text-primary-600`,children:p===e&&(0,d.jsx)(M,{})}),(0,d.jsx)(`div`,{children:e})]},e))}),(0,d.jsx)(`div`,{className:`univer-mt-3 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200`,children:f.t(`sheets-numfmt-ui.customFormatDes`)})]})}let ke=e=>{let n=r.numfmt.getFormatInfo(e);return(0,t.getDateFormatOptions)().map(e=>e.value).includes(e)||[`date`,`datetime`,`time`].includes(n.type)};function Ae(e){let{onActionChange:i,onChange:a,defaultPattern:o}=e,s=(0,u.useMemo)(t.getDateFormatOptions,[]),c=(0,n.useDependency)(r.LocaleService),[f,p]=(0,u.useState)(()=>{if(o){let e=s.find(e=>e.value===o);if(e)return e.value}return s[0].value});return(0,u.useLayoutEffect)(()=>{i(()=>f)},[i,f]),(0,d.jsxs)(`div`,{children:[(0,d.jsx)(`div`,{className:`univer-mt-4 univer-text-sm univer-text-gray-400`,children:c.t(`sheets-numfmt-ui.dateType`)}),(0,d.jsx)(`div`,{className:`univer-mt-2`,children:(0,d.jsx)(l.SelectList,{value:f,options:s,onChange:e=>{e!==void 0&&(p(e),a(e))}})}),(0,d.jsx)(`div`,{className:`univer-mt-3.5 univer-text-sm/5 univer-text-gray-600 dark:!univer-text-gray-200`,children:c.t(`sheets-numfmt-ui.dateDes`)})]})}let je=e=>!e;function Me(e){let t=(0,n.useDependency)(r.LocaleService),{onActionChange:i}=e;return(0,u.useLayoutEffect)(()=>{i(()=>``)},[i]),(0,d.jsx)(`div`,{children:(0,d.jsx)(`div`,{className:`univer-mt-3.5 univer-text-sm/5 univer-text-gray-600 dark:!univer-text-gray-200`,children:t.t(`sheets-numfmt-ui.generalDes`)})})}let Ne=e=>(0,t.getNumberFormatOptions)().some(t=>(0,r.isPatternEqualWithoutDecimal)(t.value,e));function Pe(e){let{onActionChange:i,onChange:a}=e,o=(0,n.useDependency)(r.LocaleService),s=(0,u.useMemo)(t.getNumberFormatOptions,[]),[c,f]=(0,u.useState)(()=>(0,t.getDecimalFromPattern)(e.defaultPattern||``,0)),[p,m]=(0,u.useState)(()=>{let t=s.find(t=>(0,r.isPatternEqualWithoutDecimal)(t.value,e.defaultPattern||``));return(t==null?void 0:t.value)||s[0].value}),h=(0,u.useMemo)(()=>(0,t.setPatternDecimal)(p,Number(c||0)),[p,c]),g=!(0,t.isPatternHasDecimal)(p);return(0,u.useLayoutEffect)(()=>{i(()=>h)},[i,h]),(0,d.jsxs)(`div`,{children:[(0,d.jsx)(`div`,{className:`univer-mt-4 univer-text-sm univer-text-gray-400`,children:o.t(`sheets-numfmt-ui.decimalLength`)}),(0,d.jsx)(`div`,{className:`univer-mt-2`,children:(0,d.jsx)(l.InputNumber,{disabled:g,value:c,max:20,min:0,onChange:e=>{f(e||0),a((0,t.setPatternDecimal)(p,Number(e||0)))}})}),(0,d.jsxs)(`div`,{className:`univer-mt-4 univer-text-sm univer-text-gray-400`,children:[` `,o.t(`sheets-numfmt-ui.negType`)]}),(0,d.jsx)(`div`,{className:`univer-mt-2`,children:(0,d.jsx)(l.SelectList,{onChange:e=>{e!==void 0&&(f((0,t.getDecimalFromPattern)(e,0)),m(e),a(e))},options:s,value:p})}),(0,d.jsx)(`div`,{className:`univer-mt-3.5 univer-text-sm/5 univer-text-gray-600 dark:!univer-text-gray-200`,children:o.t(`sheets-numfmt-ui.thousandthPercentileDes`)})]})}let Fe=`numfmtCurrency`,Ie=e=>{let t=(0,n.useDependency)(W),[i,a]=(0,u.useState)(r.currencySymbols);return(0,u.useEffect)(()=>{t.addHabit(`numfmtCurrency`,[]).then(()=>{t.getHabit(Fe,[...r.currencySymbols]).then(t=>{a(t),e&&e(t)})})},[]),{userHabitCurrency:i,mark:e=>{t.markHabit(Fe,e)}}},Le=()=>{let e=(0,u.useRef)([]),[t,n]=(0,u.useState)({});return(0,u.useEffect)(()=>{e.current.forEach(e=>{e()}),e.current=[]},[t]),t=>{e.current.push(t),n({})}};function Re(e){var i;let{defaultValue:a,defaultPattern:o,row:s,col:c}=e.value,f=(0,n.useDependency)(r.LocaleService),p=(0,u.useRef)(()=>``),m=Le(),h=(0,u.useMemo)(()=>[{label:`sheets-numfmt-ui.general`,component:Me},{label:`sheets-numfmt-ui.accounting`,component:Te},{label:`sheets-numfmt-ui.currency`,component:De},{label:`sheets-numfmt-ui.date`,component:Ae},{label:`sheets-numfmt-ui.thousandthPercentile`,component:Pe},{label:`sheets-numfmt-ui.customFormat`,component:Oe}].map(e=>({...e,label:f.t(e.label)})),[f]),[g,_]=(0,u.useState)(C),[v,y]=(0,u.useState)(()=>`${s}_${c}_${o}`),{mark:b,userHabitCurrency:x}=Ie(()=>y(`${s}_${c}_${o}_userCurrency`)),S=(i=h.find(e=>e.label===g))==null?void 0:i.component;function C(){return[je,we,Ee,ke,Ne].reduce((e,t,n)=>e||(t(o)?h[n].label:``),``)||h[0].label}let w=h.map(e=>({label:e.label,value:e.label})),ee=t=>{_(t),m(()=>e.onChange({type:`change`,value:p.current()||``}))},T=(0,u.useCallback)(t=>{e.onChange({type:`change`,value:t})},[]),E=(0,u.useCallback)(e=>{p.current=e},[]),D=()=>{let n=p.current()||``,r=(0,t.getCurrencyType)(n);r&&b(r),e.onChange({type:`confirm`,value:n})},O=()=>{e.onChange({type:`cancel`,value:``})},te={onChange:T,onActionChange:E,defaultValue:a,defaultPattern:o};return(0,u.useEffect)(()=>{_(C()),y(`${s}_${c}_${o}`)},[s,c,o]),(0,d.jsxs)(`div`,{className:(0,l.clsx)(`univer-flex univer-h-full univer-flex-col univer-justify-between univer-overflow-y-auto univer-pb-5`,l.scrollbarClassName),children:[(0,d.jsxs)(`div`,{children:[(0,d.jsx)(`div`,{className:`univer-mt-3.5 univer-text-sm univer-text-gray-400`,children:f.t(`sheets-numfmt-ui.numfmtType`)}),(0,d.jsx)(`div`,{className:`univer-mt-2`,children:(0,d.jsx)(l.Select,{className:`univer-w-full`,value:g,options:w,onChange:ee})}),(0,d.jsx)(`div`,{children:S&&(0,d.jsx)(U.Provider,{value:x,children:(0,u.createElement)(S,{...te,key:v})})})]}),(0,d.jsxs)(`div`,{className:`univer-mb-5 univer-mt-3.5 univer-flex univer-justify-end univer-gap-2 rtl:univer-flex-row-reverse`,children:[(0,d.jsx)(l.Button,{onClick:O,children:f.t(`sheets-numfmt-ui.cancel`)}),(0,d.jsx)(l.Button,{variant:`primary`,onClick:D,children:f.t(`sheets-numfmt-ui.confirm`)})]})]})}let q=class extends r.Disposable{constructor(e,t){super(),this._componentManager=e,this._iconManager=t,this._registerComponents(),this._registerIcons()}_registerIcons(){this.disposeWithMe(this._iconManager.register({AddDigitsIcon:j,DollarIcon:N,DongIcon:P,EuroIcon:F,PercentIcon:I,ReduceDigitsIcon:L,RialIcon:R,RmbIcon:z,RoubleIcon:B,RupiahIcon:V,WonIcon:H,ZlotyIcon:Ce}))}_registerComponents(){this.disposeWithMe(this._componentManager.register(`SHEET_NUMFMT_PANEL`,Re)),[[S,w],[C,ee]].forEach(([e,t])=>{this.disposeWithMe(this._componentManager.register(e,t))})}};q=y([v(0,(0,r.Inject)(n.ComponentManager)),v(1,(0,r.Inject)(n.IconManager))],q);let J=`SHEET_NUMFMT_ALERT`,Y=class extends r.Disposable{constructor(e,t,n,r,i,a){super(),this._context=e,this._hoverManagerService=t,this._cellAlertManagerService=n,this._localeService=r,this._numfmtService=i,this._configService=a,this._init()}_init(){this._initCellAlertPopup()}_initCellAlertPopup(){this.disposeWithMe(this._hoverManagerService.currentCell$.pipe((0,s.debounceTime)(100)).subscribe(e=>{if(e){let a=e.location,s=this._context.unit,c=s.getActiveSheet();if(!c)return this._hideAlert();let l=a.unitId,u=a.subUnitId,d,f=c.getCell(a.row,a.col);if(f!=null&&f.s){let e=s.getStyles().get(f.s);e!=null&&e.n&&(d=e.n)}if(d||(d=this._numfmtService.getValue(l,u,a.row,a.col)),!d){this._hideAlert();return}if((0,r.isTextFormat)(d.pattern)&&r.Tools.isDefine(f==null?void 0:f.v)&&(0,r.isRealNum)(f.v)){var n,i;if((n=this._configService.getConfig(t.SHEETS_NUMFMT_PLUGIN_CONFIG_KEY))!=null&&n.disableTextFormatAlert)return;let e=this._cellAlertManagerService.currentAlert.get(J),r=e==null||(i=e.alert)==null?void 0:i.location;if(r&&r.row===a.row&&r.col===a.col&&r.subUnitId===a.subUnitId&&r.unitId===a.unitId){this._hideAlert();return}this._cellAlertManagerService.showAlert({type:o.CellAlertType.ERROR,title:this._localeService.t(`sheets-numfmt-ui.info.error`),message:this._localeService.t(`sheets-numfmt-ui.info.forceStringInfo`),location:a,width:200,height:74,key:J});return}}this._hideAlert()}))}_hideAlert(){this._cellAlertManagerService.removeAlert(J)}};Y=y([v(1,(0,r.Inject)(o.HoverManagerService)),v(2,(0,r.Inject)(o.CellAlertManagerService)),v(3,(0,r.Inject)(r.LocaleService)),v(4,(0,r.Inject)(a.INumfmtService)),v(5,r.IConfigService)],Y);let X=class extends r.Disposable{constructor(e){super(),this._repeatLastActionService=e,this._initCommandRecording()}_initCommandRecording(){this._repeatLastActionService&&this.disposeWithMe(this._repeatLastActionService.registerRepeatableCommand(t.SetNumfmtCommand.id,(e,t)=>{if(!t)return;let{values:n}=t,r=n.find(e=>e.pattern);if(!r)return;let{pattern:i,type:a}=r,o=[],s=new Set;for(let t of e){let{startRow:e,startColumn:n,endRow:r,endColumn:c}=t;for(let t=e;t<=r;t++)for(let e=n;e<=c;e++){let n=`${t}-${e}`;s.has(n)||(s.add(n),o.push({row:t,col:e,pattern:i,type:a}))}}return{...t,values:o}},o.RepeatLastActionPermission.CellStyle))}};X=y([v(0,(0,r.Optional)(o.IRepeatLastActionService))],X);let ze=()=>{let e=[];return{add:(t,n,r,i,a)=>e.push({unitId:t,subUnitId:n,row:r,col:i,value:a}),getEffects:()=>e,clean:()=>{e=[]}}},Z=class extends r.Disposable{constructor(e,t,n,r,i){super(),this._sheetInterceptorService=e,this._numfmtService=t,this._univerInstanceService=n,this._injector=r,this._editorBridgeService=i,_(this,`_collectEffectMutation`,ze()),this._initInterceptorEditorStart(),this._initInterceptorEditorEnd(),this._initInterceptorCommands()}_initInterceptorEditorStart(){this._editorBridgeService&&this.disposeWithMe((0,r.toDisposable)(this._sheetInterceptorService.writeCellInterceptor.intercept(a.BEFORE_CELL_EDIT,{handler:(e,n,i)=>{let a=n.row,o=n.col,s=this._numfmtService.getValue(n.unitId,n.subUnitId,a,o);if(s)switch((0,t.getPatternType)(s.pattern)){case`scientific`:case`currency`:case`grouped`:case`number`:{let e={...n.worksheet.getCellRaw(a,o)};return(e==null?void 0:e.t)===r.CellValueType.NUMBER&&(0,r.isRealNum)(e.v)&&(e.v=(0,f.stripErrorMargin)(Number(e.v))),i&&i(e)}case`percent`:{let e={...n.worksheet.getCellRaw(a,o)};return(e==null?void 0:e.t)===r.CellValueType.NUMBER&&(0,r.isRealNum)(e.v)&&(e.v=`${(0,f.stripErrorMargin)(Number(e.v)*100)}%`),i&&i(e)}default:return i&&i(e)}return i(e)}})))}_initInterceptorEditorEnd(){this.disposeWithMe((0,r.toDisposable)(this._sheetInterceptorService.writeCellInterceptor.intercept(a.AFTER_CELL_EDIT,{handler:(e,n,i)=>{var a,o;if(!(e!=null&&e.v)&&!(e!=null&&e.p))return i(e);this._collectEffectMutation.clean();let s=this._numfmtService.getValue(n.unitId,n.subUnitId,n.row,n.col),c=n.worksheet.getCellRaw(n.row,n.col);if((0,r.isTextFormat)(s==null?void 0:s.pattern)||e.t===r.CellValueType.FORCE_STRING)return i(e);let l=(a=e.p)==null?void 0:a.body,u=e!=null&&(o=e.p)!=null&&(o=o.body)!=null&&o.dataStream?e.p.body.dataStream.replace(/\r\n$/,``):String(e.v),d=(0,r.getNumfmtParseValueFilter)(u);if(l)if(Be(l)){let{dataStream:t}=l,n=t.replace(/\r\n$/,``),r=Number(n);if(Number.isNaN(r)&&!d)return i(e)}else return i(e);if(d){if(!d.z&&!(s!=null&&s.pattern)&&(c==null?void 0:c.t)!==r.CellValueType.STRING&&(c==null?void 0:c.t)!==r.CellValueType.FORCE_STRING&&(0,r.willLoseNumericPrecision)(u))return i({...e,p:void 0,v:u,t:r.CellValueType.FORCE_STRING});d.z&&(!(s!=null&&s.pattern)||(0,t.getPatternType)(d.z)!==(0,t.getPatternType)(s.pattern))&&this._collectEffectMutation.add(n.unitId,n.subUnitId,n.row,n.col,{pattern:d.z});let a=(0,f.stripErrorMargin)(Number(d.v),16);return i({...e,p:void 0,v:a,t:r.CellValueType.NUMBER})}return i(e)}})))}_initInterceptorCommands(){let e=this;this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations(t){switch(t.id){case a.SetRangeValuesCommand.id:{var n;let t=e._univerInstanceService.getCurrentUnitOfType(r.UniverInstanceType.UNIVER_SHEET),i=t.getUnitId(),o=(n=t.getActiveSheet())==null?void 0:n.getSheetId();if(!o)return{redos:[],undos:[]};let s=e._collectEffectMutation.getEffects();if(e._collectEffectMutation.clean(),!s.length)return{redos:[],undos:[]};let c=s.filter(e=>{var t;return!!((t=e.value)!=null&&t.pattern)}).map(e=>({row:e.row,col:e.col,pattern:e.value.pattern})),l=s.filter(e=>{var t;return!((t=e.value)!=null&&t.pattern)}).map(e=>({startRow:e.row,endColumn:e.col,startColumn:e.col,endRow:e.row})),u=[],d=[];if(c.length){let t={id:a.SetNumfmtMutation.id,params:(0,a.transformCellsToRange)(i,o,c)};u.push(t),d.push(...(0,a.factorySetNumfmtUndoMutation)(e._injector,t.params))}if(l.length){let t={id:a.RemoveNumfmtMutation.id,params:{unitId:i,subUnitId:o,ranges:l}};u.push(t),d.push(...(0,a.factoryRemoveNumfmtUndoMutation)(e._injector,t.params))}return{redos:u,undos:d.reverse()}}}return{redos:[],undos:[]}}}))}dispose(){super.dispose(),this._collectEffectMutation.clean()}};Z=y([v(0,(0,r.Inject)(a.SheetInterceptorService)),v(1,(0,r.Inject)(a.INumfmtService)),v(2,(0,r.Inject)(r.IUniverInstanceService)),v(3,(0,r.Inject)(r.Injector)),v(4,(0,r.Optional)(o.IEditorBridgeService))],Z);function Be(e){let{textRuns:t=[],paragraphs:n=[],customRanges:r,customBlocks:i=[]}=e,a=[`va`];return!(t.some(e=>!!(e.ts&&Object.keys(e.ts).some(e=>a.includes(e))))||n.some(e=>e.bullet)||n.length>=2||r!=null&&r.length||i.length>0)}let Q=class extends r.Disposable{constructor(e){super(),this._menuManagerService=e,this._initMenu()}_initMenu(){this._menuManagerService.mergeMenu(re)}};Q=y([v(0,n.IMenuManagerService)],Q);let $=class extends r.Plugin{constructor(e=oe,t,n,i){super(),this._config=e,this._injector=t,this._configService=n,this._renderManagerService=i;let{menu:a,...o}=(0,r.merge)({},oe,this._config);a&&this._configService.setConfig(`menu`,a,{merge:!0}),this._configService.setConfig(`sheets-numfmt-ui.config`,o)}onStarting(){this._injector.add([q]),this._injector.get(q),(0,r.registerDependencies)(this._injector,[[b],[Z],[W],[Q],[X]])}onRendered(){this._registerRenderModules(),(0,r.touchDependencies)(this._injector,[[b],[Z],[Q],[X]])}_registerRenderModules(){[[Y]].forEach(e=>{this.disposeWithMe(this._renderManagerService.registerRenderModule(r.UniverInstanceType.UNIVER_SHEET,e))})}};_($,`pluginName`,`SHEET_NUMFMT_UI_PLUGIN`),_($,`packageName`,ie),_($,`version`,ae),_($,`type`,r.UniverInstanceType.UNIVER_SHEET),$=y([(0,r.DependentOn)(i.UniverRenderEnginePlugin,a.UniverSheetsPlugin,n.UniverUIPlugin,t.UniverSheetsNumfmtPlugin,o.UniverSheetsUIPlugin),v(1,(0,r.Inject)(r.Injector)),v(2,r.IConfigService),v(3,i.IRenderManagerService)],$),e.SheetsNumfmtUIMenuSchema=re,Object.defineProperty(e,"UniverSheetsNumfmtUIPlugin",{enumerable:!0,get:function(){return $}})});
1
+ (function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("@univerjs/sheets-numfmt"),require("@univerjs/ui"),require("@univerjs/core"),require("@univerjs/engine-render"),require("@univerjs/sheets"),require("@univerjs/sheets-ui"),require("rxjs"),require("rxjs/operators"),require("@univerjs/design"),require("react"),require("react/jsx-runtime"),require("@univerjs/engine-formula")):typeof define==`function`&&define.amd?define([`exports`,`@univerjs/sheets-numfmt`,`@univerjs/ui`,`@univerjs/core`,`@univerjs/engine-render`,`@univerjs/sheets`,`@univerjs/sheets-ui`,`rxjs`,`rxjs/operators`,`@univerjs/design`,`react`,`react/jsx-runtime`,`@univerjs/engine-formula`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.UniverSheetsNumfmtUi={},e.UniverSheetsNumfmt,e.UniverUi,e.UniverCore,e.UniverEngineRender,e.UniverSheets,e.UniverSheetsUi,e.rxjs,e.rxjs.operators,e.UniverDesign,e.React,e.React,e.UniverEngineFormula))})(this,function(e,t,n,r,i,a,o,s,c,l,u,d,f){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});let p={id:`sheet.operation.close.numfmt.panel`,type:r.CommandType.OPERATION,handler:()=>!0};function m(e){"@babel/helpers - typeof";return m=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},m(e)}function h(e,t){if(m(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(m(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function g(e){var t=h(e,`string`);return m(t)==`symbol`?t:t+``}function _(e,t,n){return(t=g(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function v(e,t){return function(n,r){t(n,r,e)}}function y(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 b=class extends r.Disposable{constructor(e,t,n,r,i,a,o,s,c,l){super(),this._sheetInterceptorService=e,this._themeService=t,this._univerInstanceService=n,this._commandService=r,this._selectionManagerService=i,this._renderManagerService=a,this._numfmtService=o,this._sidebarService=s,this._localeService=c,this._sheetsNumfmtCellContentController=l,_(this,`_previewPattern`,``),_(this,`_sidebarDisposable`,null),this._initRealTimeRenderingInterceptor(),this._initCommands(),this._initCloseListener(),this._commandExecutedListener(),this._initNumfmtLocalChange()}_initNumfmtLocalChange(){this.disposeWithMe((0,s.merge)(this._sheetsNumfmtCellContentController.locale$,this._localeService.currentLocale$).subscribe(()=>{this._forceUpdate()}))}openPanel(){var e;let n=this._sidebarService,i=this._selectionManagerService,a=this._commandService,o=this._univerInstanceService,s=this._numfmtService,c=this._localeService,l=(((e=i.getCurrentSelections())==null?void 0:e.map(e=>e.range))||[])[0];if(!l)return!1;let u=o.getCurrentUnitOfType(r.UniverInstanceType.UNIVER_SHEET),d=u.getActiveSheet();if(!d)return!1;let f=d.getCellRaw(l.startRow,l.startColumn),m=s.getValue(u.getUnitId(),d.getSheetId(),l.startRow,l.startColumn),h=``;m&&(h=m.pattern);let g=(f==null?void 0:f.t)===r.CellValueType.NUMBER?f.v:12345678,_={onChange:e=>{if(e.type===`change`)this._previewPattern=e.value,this._forceUpdate();else if(e.type===`confirm`){var o;let s=((o=i.getCurrentSelections())==null?void 0:o.map(e=>e.range))||[],c={values:[]},l=(0,t.getPatternType)(e.value);s.forEach(t=>{r.Range.foreach(t,(t,n)=>{c.values.push({row:t,col:n,pattern:e.value,type:l})})}),a.executeCommand(t.SetNumfmtCommand.id,c),n.close()}else e.type===`cancel`&&n.close()},value:{defaultPattern:h,defaultValue:g,row:l.startRow,col:l.startColumn}};return this._sidebarDisposable=n.open({header:{title:c.t(`sheets-numfmt-ui.title`)},children:{label:`SHEET_NUMFMT_PANEL`,..._},onClose:()=>{this._forceUpdate(),a.executeCommand(p.id)}}),!0}_forceUpdate(e){var t,n;let i=e??((t=this._univerInstanceService.getCurrentUnitOfType(r.UniverInstanceType.UNIVER_SHEET))==null?void 0:t.getUnitId());if(!i)return;let a=this._renderManagerService.getRenderUnitById(i);a==null||a.with(o.SheetSkeletonManagerService).reCalculate(),a==null||(n=a.mainComponent)==null||n.makeDirty()}_initCommands(){[x,p].forEach(e=>{this.disposeWithMe(this._commandService.registerCommand(e))})}_initRealTimeRenderingInterceptor(){let e=(0,s.combineLatest)([new s.Observable(e=>{this._commandService.onCommandExecuted(t=>{t.id===x.id&&e.next(!0),t.id===p.id&&e.next(!1)})}),this._selectionManagerService.selectionMoveEnd$.pipe((0,c.map)(e=>e?e.map(e=>e.range):[]))]);this.disposeWithMe((0,r.toDisposable)(e.pipe((0,c.switchMap)(([e,t])=>new s.Observable(n=>{let i=new r.DisposableCollection;return e&&t.length&&n.next({selectionRanges:t,disposableCollection:i}),()=>{i.dispose()}})),(0,c.tap)(()=>{this._previewPattern=null})).subscribe(({disposableCollection:e,selectionRanges:n})=>{var i;let o=this._univerInstanceService.getCurrentUnitOfType(r.UniverInstanceType.UNIVER_SHEET);this.openPanel(),e.add(this._sheetInterceptorService.intercept(a.INTERCEPTOR_POINT.CELL_CONTENT,{priority:99,effect:r.InterceptorEffectEnum.Value|r.InterceptorEffectEnum.Style,handler:(e,i,a)=>{let{row:o,col:s}=i,c=a(e)||{};if(n.find(e=>e.startColumn<=s&&e.endColumn>=s&&e.startRow<=o&&e.endRow>=o)){let e=i.worksheet.getCellRaw(o,s),n=e==null?void 0:e.v,a=e==null?void 0:e.t;if(n==null||a!==r.CellValueType.NUMBER||this._previewPattern===null)return c;let l=(0,t.getPatternPreviewIgnoreGeneral)(this._previewPattern,n,this._sheetsNumfmtCellContentController.locale);if(l.color){let e=this._themeService.getColorFromTheme(`${l.color}.500`)??l.color;return{...c,v:l.result,t:r.CellValueType.STRING,s:{cl:{rgb:e}}}}return{...c,v:l.result,t:r.CellValueType.STRING}}return c}})),(i=this._renderManagerService.getRenderUnitById(o.getUnitId()))==null||(i=i.mainComponent)==null||i.makeDirty()})))}_commandExecutedListener(){let e=[a.RemoveNumfmtMutation.id,a.SetNumfmtMutation.id];this.disposeWithMe(new s.Observable(t=>{let n=this._commandService.onCommandExecuted(n=>{if(e.includes(n.id)){let e=n.params;t.next(e.unitId)}});return()=>n.dispose()}).pipe((0,c.debounceTime)(16)).subscribe(e=>this._forceUpdate(e)))}_initCloseListener(){this._univerInstanceService.getCurrentTypeOfUnit$(r.UniverInstanceType.UNIVER_SHEET).subscribe(e=>{if(!e){var t;(t=this._sidebarDisposable)==null||t.dispose(),this._sidebarDisposable=null}})}};b=y([v(0,(0,r.Inject)(a.SheetInterceptorService)),v(1,(0,r.Inject)(r.ThemeService)),v(2,r.IUniverInstanceService),v(3,r.ICommandService),v(4,(0,r.Inject)(a.SheetsSelectionsService)),v(5,i.IRenderManagerService),v(6,a.INumfmtService),v(7,n.ISidebarService),v(8,(0,r.Inject)(r.LocaleService)),v(9,(0,r.Inject)(t.SheetsNumfmtCellContentController))],b);let x={id:`sheet.operation.open.numfmt.panel`,type:r.CommandType.OPERATION,handler:e=>(e.get(b).openPanel(),!0)},S=`sheets-numfmt-ui.moreNumfmtType`,C=`sheets-numfmt-ui.moreNumfmtType.options`;function w(e){let{value:t}=e,i=(0,n.useDependency)(r.LocaleService);return(0,d.jsx)(`span`,{className:`univer-text-sm`,children:t??i.t(`sheets-numfmt-ui.general`)})}function ee(){let e=(0,n.useDependency)(r.ICommandService),i=(0,n.useDependency)(r.LocaleService),o=(0,n.useDependency)(r.RegionService),s=(0,n.useDependency)(n.ILayoutService),c=(0,n.useDependency)(t.SheetsNumfmtCellContentController),f=(0,n.useObservable)(i.direction$,i.getDirection()),p=(0,n.useObservable)(o.currentRegion$,o.getCurrentRegion()),m=(0,n.useDependency)(a.SheetsSelectionsService),h=n=>{let i=m.getCurrentLastSelection();if(!i)return;let a=i.range,o=[];r.Range.foreach(a,(e,r)=>{n?o.push({row:e,col:r,pattern:n,type:(0,t.getPatternType)(n)}):o.push({row:e,col:r})}),e.executeCommand(t.SetNumfmtCommand.id,{values:o}),s.focus()},g=(0,u.useMemo)(()=>T((0,t.getCurrencySymbolByLocale)(p)),[p]),_=t=>{if(t===0)h(null);else if(t===g.length-1)e.executeCommand(x.id),s.focus();else{let e=g[t];e.pattern&&h(e.pattern)}};return(0,d.jsx)(`div`,{dir:f,className:`univer-grid univer-gap-1 univer-p-1.5`,children:g.map((e,n)=>e===`|`?(0,d.jsx)(l.Separator,{},n):(0,d.jsxs)(`div`,{className:`univer-flex univer-h-7 univer-cursor-default univer-items-center univer-justify-between univer-gap-6 univer-rounded univer-px-2 univer-text-sm hover:univer-bg-gray-100 dark:hover:!univer-bg-gray-700`,onClick:()=>_(n),children:[(0,d.jsx)(`span`,{children:i.t(e.label)}),(0,d.jsx)(`span`,{className:`univer-text-xs univer-text-gray-500 dark:!univer-text-gray-400`,children:e.pattern?(0,t.getPatternPreview)(e.pattern||``,1220,c.locale).result.trim():``})]},n))})}let T=e=>[{label:`sheets-numfmt-ui.general`,pattern:null},{label:`sheets-numfmt-ui.text`,pattern:r.DEFAULT_TEXT_FORMAT_EXCEL},`|`,{label:`sheets-numfmt-ui.number`,pattern:`0`},{label:`sheets-numfmt-ui.percent`,pattern:`0.00%`},{label:`sheets-numfmt-ui.scientific`,pattern:`0.00E+00`},`|`,{label:`sheets-numfmt-ui.accounting`,pattern:`"${e}" #,##0.00_);[Red]("${e}"#,##0.00)`},{label:`sheets-numfmt-ui.financialValue`,pattern:`#,##0.00;[Red]#,##0.00`},{label:`sheets-numfmt-ui.currency`,pattern:`"${e}"#,##0.00_);[Red]("${e}"#,##0.00)`},{label:`sheets-numfmt-ui.roundingCurrency`,pattern:`"${e}"#,##0;[Red]"${e}"#,##0`},`|`,{label:`sheets-numfmt-ui.date`,pattern:`yyyy-mm-dd;@`},{label:`sheets-numfmt-ui.time`,pattern:`am/pm h":"mm":"ss`},{label:`sheets-numfmt-ui.dateTime`,pattern:`yyyy-m-d am/pm h:mm`},{label:`sheets-numfmt-ui.timeDuration`,pattern:`h:mm:ss`},`|`,{label:`sheets-numfmt-ui.moreFmt`,pattern:``}];function E(e){return{icon:e.get(r.RegionService).currentRegion$.pipe((0,s.map)(e=>(0,t.getCurrencySymbolIconByLocale)(e).icon)),id:t.SetCurrencyCommand.id,title:`sheets-numfmt-ui.currency`,tooltip:`sheets-numfmt-ui.currency`,type:n.MenuItemType.BUTTON,hidden$:(0,n.getMenuHiddenObservable)(e,r.UniverInstanceType.UNIVER_SHEET),disabled$:(0,o.getCurrentRangeDisable$)(e,{workbookTypes:[a.WorkbookEditablePermission],worksheetTypes:[a.WorksheetEditPermission,a.WorksheetSetCellStylePermission],rangeTypes:[a.RangeProtectionPermissionEditPoint]})}}function D(e){return{icon:`AddDigitsIcon`,id:t.AddDecimalCommand.id,title:`sheets-numfmt-ui.addDecimal`,tooltip:`sheets-numfmt-ui.addDecimal`,type:n.MenuItemType.BUTTON,hidden$:(0,n.getMenuHiddenObservable)(e,r.UniverInstanceType.UNIVER_SHEET),disabled$:(0,o.getCurrentRangeDisable$)(e,{workbookTypes:[a.WorkbookEditablePermission],worksheetTypes:[a.WorksheetEditPermission,a.WorksheetSetCellStylePermission],rangeTypes:[a.RangeProtectionPermissionEditPoint]})}}function O(e){return{icon:`ReduceDigitsIcon`,id:t.SubtractDecimalCommand.id,title:`sheets-numfmt-ui.subtractDecimal`,tooltip:`sheets-numfmt-ui.subtractDecimal`,type:n.MenuItemType.BUTTON,hidden$:(0,n.getMenuHiddenObservable)(e,r.UniverInstanceType.UNIVER_SHEET),disabled$:(0,o.getCurrentRangeDisable$)(e,{workbookTypes:[a.WorkbookEditablePermission],worksheetTypes:[a.WorksheetEditPermission,a.WorksheetSetCellStylePermission],rangeTypes:[a.RangeProtectionPermissionEditPoint]})}}function te(e){return{icon:`PercentIcon`,id:t.SetPercentCommand.id,title:`sheets-numfmt-ui.percent`,tooltip:`sheets-numfmt-ui.percent`,type:n.MenuItemType.BUTTON,hidden$:(0,n.getMenuHiddenObservable)(e,r.UniverInstanceType.UNIVER_SHEET),disabled$:(0,o.getCurrentRangeDisable$)(e,{workbookTypes:[a.WorkbookEditablePermission],worksheetTypes:[a.WorksheetEditPermission,a.WorksheetSetCellStylePermission],rangeTypes:[a.RangeProtectionPermissionEditPoint]})}}function ne(e){let i=e.get(r.IUniverInstanceService),c=e.get(r.ICommandService),l=e.get(r.LocaleService),u=e.get(r.RegionService),d=e.get(a.SheetsSelectionsService),f=[a.RemoveNumfmtMutation.id,a.SetNumfmtMutation.id],p=(0,o.deriveStateFromActiveSheet$)(i,``,({workbook:e,worksheet:n})=>new s.Observable(i=>(0,s.merge)(d.selectionMoveEnd$,u.currentRegion$,(0,r.fromCallback)(c.onCommandExecuted.bind(c)).pipe((0,s.filter)(([e])=>f.includes(e.id)))).subscribe(()=>{let a=d.getCurrentSelections();if(a&&a[0]){var o,s;let c=a[0].range,d=c.startRow,f=c.startColumn,p=(o=e.getStyles().get((s=n.getCell(d,f))==null?void 0:s.s))==null?void 0:o.n,m=p==null?void 0:p.pattern,h=(0,t.getCurrencySymbolByLocale)(u.getCurrentRegion()),g=l.t(`sheets-numfmt-ui.general`);if((0,r.isDefaultFormat)(m)){i.next(g);return}if(m){let e=T(h).filter(e=>typeof e==`object`&&e.pattern).find(e=>(0,r.isPatternEqualWithoutDecimal)(m,e.pattern));g=e&&typeof e==`object`&&e.pattern?l.t(e.label):l.t(`sheets-numfmt-ui.moreFmt`)}i.next(g)}})));return{label:S,id:x.id,tooltip:`sheets-numfmt-ui.title`,type:n.MenuItemType.SELECTOR,slot:!0,selections:[{label:{name:C,hoverable:!1,selectable:!1}}],value$:p,hidden$:(0,n.getMenuHiddenObservable)(e,r.UniverInstanceType.UNIVER_SHEET),disabled$:(0,o.getCurrentRangeDisable$)(e,{workbookTypes:[a.WorkbookEditablePermission],worksheetTypes:[a.WorksheetSetCellStylePermission,a.WorksheetEditPermission],rangeTypes:[a.RangeProtectionPermissionEditPoint]})}}let re={[n.RibbonStartGroup.NUMBER]:{[x.id]:{order:9,gridLayout:{row:1,column:1,columnSpan:4,width:210},menuItemFactory:ne},[t.SetPercentCommand.id]:{order:9.1,gridLayout:{row:2,column:1},menuItemFactory:te},[t.SetCurrencyCommand.id]:{order:9.2,gridLayout:{row:2,column:2},menuItemFactory:E},[t.AddDecimalCommand.id]:{order:9.3,gridLayout:{row:2,column:3},menuItemFactory:D},[t.SubtractDecimalCommand.id]:{order:9.4,gridLayout:{row:2,column:4},menuItemFactory:O}}};var ie=`@univerjs/sheets-numfmt-ui`,ae=`1.0.0-beta.0`;let oe={};function k({ref:e,...t}){let{icon:n,id:r,className:i,extend:a,...o}=t,s=`univerjs-icon univerjs-icon-${r} ${i||``}`.trim(),c=(0,u.useRef)(`_${le()}`);return A(n,`${r}`,{defIds:n.defIds,idSuffix:c.current},{ref:e,className:s,...o},a)}function A(e,t,n,r,i){return(0,u.createElement)(e.tag,{key:t,...se(e,n,i),...r},(ce(e,n).children||[]).map((r,a)=>A(r,`${t}-${e.tag}-${a}`,n,void 0,i)))}function se(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 ce(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 le(){return Math.random().toString(36).substring(2,8)}k.displayName=`UniverIcon`;let ue={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.06641 3.49366C4.06641 2.27555 5.14145 1.3916 6.33307 1.3916C7.52469 1.3916 8.59974 2.27555 8.59974 3.49366V6.49777C8.59974 7.71586 7.52469 8.59982 6.33307 8.59982C5.14145 8.59982 4.06641 7.71586 4.06641 6.49777V3.49366ZM6.33307 2.5916C5.68376 2.5916 5.26641 3.05264 5.26641 3.49366V6.49777C5.26641 6.93878 5.68376 7.39982 6.33307 7.39982C6.98239 7.39982 7.39974 6.93878 7.39974 6.49777V3.49366C7.39974 3.05264 6.98239 2.5916 6.33307 2.5916Z`,fillRule:`evenodd`,clipRule:`evenodd`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M10.0664 3.49366C10.0664 2.27555 11.1415 1.3916 12.3331 1.3916C13.5247 1.3916 14.5997 2.27555 14.5997 3.49366V6.49777C14.5997 7.71586 13.5247 8.59982 12.3331 8.59982C11.1415 8.59982 10.0664 7.71586 10.0664 6.49777V3.49366ZM12.3331 2.5916C11.6838 2.5916 11.2664 3.05264 11.2664 3.49366V6.49777C11.2664 6.93878 11.6838 7.39982 12.3331 7.39982C12.9824 7.39982 13.3997 6.93878 13.3997 6.49777V3.49366C13.3997 3.05264 12.9824 2.5916 12.3331 2.5916Z`,fillRule:`evenodd`,clipRule:`evenodd`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M12.4242 9.5417C12.1899 9.30739 11.81 9.30739 11.5756 9.5417C11.3413 9.77602 11.3413 10.1559 11.5756 10.3902L12.5514 11.366H6.3334C6.00203 11.366 5.7334 11.6346 5.7334 11.966C5.7334 12.2973 6.00203 12.566 6.3334 12.566H12.5514L11.5756 13.5417C11.3413 13.776 11.3413 14.1559 11.5756 14.3902C11.81 14.6245 12.1899 14.6245 12.4242 14.3902L14.4159 12.3985C14.5294 12.2893 14.6001 12.1359 14.6001 11.966C14.6001 11.796 14.5294 11.6426 14.4159 11.5334L12.4242 9.5417Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M1.3999 8.3002C1.3999 7.96882 1.66853 7.7002 1.9999 7.7002H2.33324C2.66461 7.7002 2.93324 7.96882 2.93324 8.3002C2.93324 8.63157 2.66461 8.9002 2.33324 8.9002H1.9999C1.66853 8.9002 1.3999 8.63157 1.3999 8.3002Z`}}]},j=(0,u.forwardRef)(function(e,t){return(0,u.createElement)(k,Object.assign({},e,{id:`add-digits-icon`,ref:t,icon:ue}))});j.displayName=`AddDigitsIcon`;let de={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:`M14.1544 3.75557C14.3887 3.98988 14.3887 4.36978 14.1544 4.6041L6.51409 12.2444C6.40157 12.3569 6.24896 12.4201 6.08983 12.4201C5.9307 12.4201 5.77808 12.3569 5.66556 12.2444L1.84541 8.42425C1.6111 8.18993 1.6111 7.81003 1.84541 7.57572C2.07973 7.34141 2.45963 7.34141 2.69394 7.57572L6.08983 10.9716L13.3059 3.75557C13.5402 3.52126 13.9201 3.52126 14.1544 3.75557Z`,fillRule:`evenodd`,clipRule:`evenodd`}}]},M=(0,u.forwardRef)(function(e,t){return(0,u.createElement)(k,Object.assign({},e,{id:`check-mark-icon`,ref:t,icon:de}))});M.displayName=`CheckMarkIcon`;let fe={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:`M7.3999 2.8999V1.6C7.3999 1.26863 7.66853 1 7.9999 1C8.33127 1 8.5999 1.26863 8.5999 1.6V2.8999H10.2044C11.6655 2.8999 12.8499 4.08431 12.8499 5.54536C12.8499 5.87673 12.5813 6.14536 12.2499 6.14536C11.9185 6.14536 11.6499 5.87673 11.6499 5.54536C11.6499 4.74705 11.0028 4.0999 10.2044 4.0999H5.7384C4.97155 4.0999 4.3499 4.72155 4.3499 5.4884C4.3499 6.14439 4.80899 6.71087 5.45074 6.84677L10.7977 7.97906C11.994 8.23242 12.8499 9.28849 12.8499 10.5114C12.8499 11.941 11.691 13.0999 10.2614 13.0999H8.5999V14.4C8.5999 14.7314 8.33127 15 7.9999 15C7.66853 15 7.3999 14.7314 7.3999 14.4V13.0999H5.79536C4.33431 13.0999 3.1499 11.9155 3.1499 10.4544C3.1499 10.1231 3.41853 9.85445 3.7499 9.85445C4.08127 9.85445 4.3499 10.1231 4.3499 10.4544C4.3499 11.2527 4.99705 11.8999 5.79536 11.8999H10.2614C11.0283 11.8999 11.6499 11.2782 11.6499 10.5114C11.6499 9.85542 11.1908 9.28893 10.5491 9.15303L5.20214 8.02074C4.00575 7.76739 3.1499 6.71132 3.1499 5.4884C3.1499 4.05881 4.30881 2.8999 5.7384 2.8999H7.3999Z`}}]},N=(0,u.forwardRef)(function(e,t){return(0,u.createElement)(k,Object.assign({},e,{id:`dollar-icon`,ref:t,icon:fe}))});N.displayName=`DollarIcon`;let pe={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:`M12.2058 3.459H11.2416V12.6604H9.6438V11.6962Q8.9091 12.844 7.4858 12.844Q5.8971 12.844 4.8456 11.6686Q3.7942 10.4932 3.7942 8.5739Q3.7942 6.5904 4.7814 5.4471Q5.7685 4.3038 7.4031 4.3038Q8.9183 4.3038 9.5887 5.3415V3.459H7.5041V2.1091H9.5887V1.2H11.2416V2.1091H12.2058V3.459ZM7.6143 11.4941Q8.5234 11.4941 9.0744 10.8008Q9.6254 10.1075 9.6254 8.7484Q9.6254 5.6629 7.5592 5.6629Q6.5491 5.6629 6.0211 6.4297Q5.493 7.1965 5.493 8.5923Q5.493 11.4941 7.6143 11.4941ZM11.2416 14.8H4.0421V13.4501H11.2416V14.8Z`}}]},P=(0,u.forwardRef)(function(e,t){return(0,u.createElement)(k,Object.assign({},e,{id:`dong-icon`,ref:t,icon:pe}))});P.displayName=`DongIcon`;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:`M5.84964 5.80918C6.71946 3.63548 8.84516 2.2 11.3295 2.2C11.8324 2.2 12.3198 2.26279 12.7846 2.38065C13.1058 2.46209 13.4322 2.26773 13.5137 1.94652C13.5951 1.62532 13.4008 1.2989 13.0795 1.21746C12.5191 1.07535 11.9327 1 11.3295 1C8.17278 1 5.49724 2.96009 4.57394 5.80918H3.06582C2.73445 5.80918 2.46582 6.07781 2.46582 6.40918C2.46582 6.74055 2.73445 7.00918 3.06582 7.00918H4.29808C4.25287 7.33297 4.22949 7.66376 4.22949 8C4.22949 8.33608 4.25284 8.6667 4.29801 8.99033H3.06582C2.73445 8.99033 2.46582 9.25896 2.46582 9.59033C2.46582 9.9217 2.73445 10.1903 3.06582 10.1903H4.57378C5.49693 13.0397 8.1726 15 11.3295 15C11.9336 15 12.5209 14.9244 13.0821 14.7819C13.4033 14.7003 13.5975 14.3738 13.5159 14.0527C13.4344 13.7315 13.1079 13.5373 12.7867 13.6188C12.3213 13.737 11.8332 13.8 11.3295 13.8C8.84497 13.8 6.71914 12.3643 5.84944 10.1903H11.4291C11.7605 10.1903 12.0291 9.9217 12.0291 9.59033C12.0291 9.25896 11.7605 8.99033 11.4291 8.99033H5.51225C5.45783 8.66834 5.42949 8.33748 5.42949 8C5.42949 7.66235 5.45786 7.33133 5.51233 7.00918H11.4291C11.7605 7.00918 12.0291 6.74055 12.0291 6.40918C12.0291 6.07781 11.7605 5.80918 11.4291 5.80918H5.84964Z`}}]},F=(0,u.forwardRef)(function(e,t){return(0,u.createElement)(k,Object.assign({},e,{id:`euro-icon`,ref:t,icon:me}))});F.displayName=`EuroIcon`;let he={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:`M1.85059 4.06725C1.85059 2.84302 2.84302 1.85059 4.06725 1.85059C5.29148 1.85059 6.28392 2.84302 6.28392 4.06725C6.28392 5.29148 5.29148 6.28392 4.06725 6.28392C2.84302 6.28392 1.85059 5.29148 1.85059 4.06725ZM4.06725 2.95059C3.45053 2.95059 2.95059 3.45053 2.95059 4.06725C2.95059 4.68397 3.45053 5.18392 4.06725 5.18392C4.68397 5.18392 5.18392 4.68397 5.18392 4.06725C5.18392 3.45053 4.68397 2.95059 4.06725 2.95059Z`,fillRule:`evenodd`,clipRule:`evenodd`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M9.7168 11.933C9.7168 10.7087 10.7092 9.71631 11.9335 9.71631C13.1577 9.71631 14.1501 10.7087 14.1501 11.933C14.1501 13.1572 13.1577 14.1496 11.9335 14.1496C10.7092 14.1496 9.7168 13.1572 9.7168 11.933ZM11.9335 10.8163C11.3167 10.8163 10.8168 11.3163 10.8168 11.933C10.8168 12.5497 11.3167 13.0496 11.9335 13.0496C12.5502 13.0496 13.0501 12.5497 13.0501 11.933C13.0501 11.3163 12.5502 10.8163 11.9335 10.8163Z`,fillRule:`evenodd`,clipRule:`evenodd`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M13.5241 3.32407C13.7584 3.08975 13.7584 2.70986 13.5241 2.47554C13.2898 2.24123 12.9099 2.24123 12.6755 2.47554L2.47554 12.6755C2.24123 12.9099 2.24123 13.2898 2.47554 13.5241C2.70986 13.7584 3.08975 13.7584 3.32407 13.5241L13.5241 3.32407Z`}}]},I=(0,u.forwardRef)(function(e,t){return(0,u.createElement)(k,Object.assign({},e,{id:`percent-icon`,ref:t,icon:he}))});I.displayName=`PercentIcon`;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:`path`,attrs:{fill:`currentColor`,d:`M6.33307 1.3916C5.14145 1.3916 4.06641 2.27555 4.06641 3.49366V6.49777C4.06641 7.71586 5.14145 8.59982 6.33307 8.59982C7.52469 8.59982 8.59974 7.71586 8.59974 6.49777V3.49366C8.59974 2.27555 7.52469 1.3916 6.33307 1.3916ZM5.26641 3.49366C5.26641 3.05264 5.68376 2.5916 6.33307 2.5916C6.98239 2.5916 7.39974 3.05264 7.39974 3.49366V6.49777C7.39974 6.93878 6.98239 7.39982 6.33307 7.39982C5.68376 7.39982 5.26641 6.93878 5.26641 6.49777V3.49366Z`,fillRule:`evenodd`,clipRule:`evenodd`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M7.90913 9.5417C8.14345 9.30739 8.52335 9.30739 8.75766 9.5417C8.99198 9.77602 8.99198 10.1559 8.75766 10.3902L7.78193 11.366H13.9999C14.3313 11.366 14.5999 11.6346 14.5999 11.966C14.5999 12.2973 14.3313 12.566 13.9999 12.566H7.78193L8.75766 13.5417C8.99198 13.776 8.99198 14.1559 8.75766 14.3902C8.52335 14.6245 8.14345 14.6245 7.90913 14.3902L5.91739 12.3985C5.80388 12.2893 5.73324 12.1359 5.73324 11.966C5.73324 11.796 5.80388 11.6426 5.91739 11.5334L7.90913 9.5417Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M1.3999 8.3002C1.3999 7.96882 1.66853 7.7002 1.9999 7.7002H2.33324C2.66461 7.7002 2.93324 7.96882 2.93324 8.3002C2.93324 8.63157 2.66461 8.9002 2.33324 8.9002H1.9999C1.66853 8.9002 1.3999 8.63157 1.3999 8.3002Z`}}]},L=(0,u.forwardRef)(function(e,t){return(0,u.createElement)(k,Object.assign({},e,{id:`reduce-digits-icon`,ref:t,icon:ge}))});L.displayName=`ReduceDigitsIcon`;let _e={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M6.7937 8.6977Q6.7937 9.5729 6.7228 9.9277Q6.6045 10.8264 5.7057 11.3704Q4.8543 11.8908 3.577 12.0327H3.4115Q2.6783 12.0327 2.2052 11.3468Q1.7795 10.7555 1.7795 9.9277Q1.7795 9.5965 1.945 8.887Q2.1343 8.0828 2.3944 7.8226Q2.4417 7.7517 2.5127 7.7517Q2.6546 7.7517 2.6546 7.9172Q2.6546 7.9882 2.489 8.4139Q2.3235 8.8397 2.3235 9.0762Q2.3235 9.904 2.7256 10.2588Q3.1277 10.6136 3.9791 10.6136Q4.9016 10.6136 5.6111 10.1878Q6.4863 9.6911 6.4153 8.8397Q6.2261 8.1774 5.8713 6.4271Q5.4456 4.2038 5.1617 3.0449Q4.9489 2.6191 4.807 2.4536Q4.9489 2.1934 5.0198 1.8859Q5.1617 1.2 5.28 1.2Q5.351 1.2 5.4456 1.4602Q5.5638 1.744 5.6821 1.8623Q6.1078 2.217 6.1551 2.288Q6.1551 2.3353 6.1788 2.3826Q6.2261 2.6191 5.9186 3.2577Q6.2024 4.535 6.4863 6.4271Q6.6991 7.8463 6.7937 8.6977ZM11.3586 8.9816Q11.3823 9.6911 11.0748 10.3061Q10.8856 10.7082 10.0577 10.7082Q9.3009 10.7082 8.8751 9.9277Q8.5677 9.4073 8.4021 7.8226Q8.1656 5.8122 7.9054 4.0146Q7.7398 3.0922 7.6452 2.6428L7.7871 1.9332Q7.8581 1.4602 7.929 1.4602Q7.9763 1.4602 8 1.5784Q8.2365 2.2407 8.4257 3.8963Q8.7096 6.167 8.8042 6.6637Q9.0643 8.5795 9.2299 8.9106Q9.3245 9.1235 9.5729 9.3127Q9.8212 9.5019 10.0577 9.5019Q10.72 9.5019 10.791 9.1471Q10.7437 8.9816 10.4835 8.6268Q10.2706 8.2957 10.247 8.0355L10.3889 7.657Q10.4598 7.4442 10.5781 7.2077Q10.6017 7.184 10.6254 7.184Q10.8383 7.184 11.0275 7.6334Q11.335 8.272 11.3586 8.9816ZM14.2205 10.7318Q14.2205 12.2219 13.511 13.3099Q13.1325 13.8776 12.2574 14.6108Q11.9736 14.8 11.4532 14.8Q10.9329 14.8 9.3245 14.4689Q9.2536 14.4689 9.1471 14.3624Q9.0407 14.256 9.0407 14.2087Q9.0643 14.185 9.0643 14.185L9.088 14.1614Q9.703 14.1141 10.0577 14.1141Q10.72 14.0904 11.0038 13.9722Q13.1089 13.1917 13.7475 11.2995Q13.6765 11.1339 13.2035 10.3061Q12.825 9.6438 12.825 9.3363Q12.825 9.289 12.9197 9.1471Q12.9433 9.1235 13.0379 8.7923Q13.1089 8.5558 13.1798 8.5558Q13.4637 8.5558 13.8657 9.3363Q14.2205 10.0459 14.2205 10.377V10.7318ZM10.6017 12.1273Q10.6254 12.1983 10.4243 12.6122Q10.2233 13.0261 10.105 13.0261Q9.9631 13.0261 9.6793 12.7777Q9.3955 12.5294 9.3245 12.3638Q9.632 11.536 9.7976 11.465Q9.8685 11.465 10.1997 11.7607Q10.5308 12.0563 10.6017 12.1273ZM9.1353 12.4584Q9.159 12.6003 8.9579 12.967Q8.7569 13.3336 8.6386 13.3336Q8.4967 13.3336 8.201 13.097Q7.9054 12.8605 7.9054 12.7423Q7.8344 12.553 8.3075 11.8198Q8.6386 11.9617 9.1353 12.4584Z`}}]},R=(0,u.forwardRef)(function(e,t){return(0,u.createElement)(k,Object.assign({},e,{id:`rial-icon`,ref:t,icon:_e}))});R.displayName=`RialIcon`;let ve={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.9445 1.55649C12.2184 1.744 12.2895 2.11755 12.1033 2.39085L9.24342 6.58659H12.8001C13.1315 6.58659 13.4001 6.85522 13.4001 7.18659C13.4001 7.51796 13.1315 7.78659 12.8001 7.78659H8.5999V9.91276H13.2221C13.5534 9.91276 13.8221 10.1814 13.8221 10.5128C13.8221 10.8441 13.5534 11.1128 13.2221 11.1128H8.5999V14.0877C8.5999 14.4191 8.33127 14.6877 7.9999 14.6877C7.66853 14.6877 7.3999 14.4191 7.3999 14.0877V11.1128H2.77773C2.44636 11.1128 2.17773 10.8441 2.17773 10.5128C2.17773 10.1814 2.44636 9.91276 2.77773 9.91276H7.3999V7.78659H3.2001C2.86873 7.78659 2.6001 7.51796 2.6001 7.18659C2.6001 6.85522 2.86873 6.58659 3.2001 6.58659H6.75736L3.89753 2.39085C3.71125 2.11755 3.78234 1.744 4.05631 1.55649C4.33029 1.36899 4.7034 1.43854 4.88968 1.71184L7.94595 6.19577C7.96752 6.22741 7.98564 6.2604 8.00039 6.29429C8.01514 6.2604 8.03326 6.22741 8.05483 6.19577L11.1111 1.71184C11.2974 1.43854 11.6705 1.36899 11.9445 1.55649Z`}}]},z=(0,u.forwardRef)(function(e,t){return(0,u.createElement)(k,Object.assign({},e,{id:`rmb-icon`,ref:t,icon:ve}))});z.displayName=`RmbIcon`;let ye={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:`M9.72502 1.02051H6.07803C4.97346 1.02051 4.07803 1.91594 4.07803 3.02051V7.57046H3.00039C2.66902 7.57046 2.40039 7.83909 2.40039 8.17046C2.40039 8.50183 2.66902 8.77046 3.00039 8.77046H4.07803V10.4854H3.00039C2.66902 10.4854 2.40039 10.754 2.40039 11.0854C2.40039 11.4167 2.66902 11.6854 3.00039 11.6854H4.07803V14.3795C4.07803 14.7108 4.34666 14.9795 4.67803 14.9795C5.0094 14.9795 5.27803 14.7108 5.27803 14.3795V11.6854H10.3637C10.695 11.6854 10.9637 11.4167 10.9637 11.0854C10.9637 10.754 10.695 10.4854 10.3637 10.4854H5.27803V8.77046H9.72503C11.8651 8.77046 13.6 7.03557 13.6 4.89548C13.6 2.75539 11.8651 1.02051 9.72502 1.02051ZM9.72503 7.57046H5.27803V3.12051C5.27803 2.62345 5.68097 2.22051 6.17803 2.22051H9.72502C11.2024 2.22051 12.4 3.41814 12.4 4.89548C12.4 6.37283 11.2024 7.57046 9.72503 7.57046Z`,fillRule:`evenodd`,clipRule:`evenodd`}}]},B=(0,u.forwardRef)(function(e,t){return(0,u.createElement)(k,Object.assign({},e,{id:`rouble-icon`,ref:t,icon:ye}))});B.displayName=`RoubleIcon`;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:`path`,attrs:{fill:`currentColor`,d:`M8.5953 11.0279H7.1987Q5.9451 9.0475 5.6418 8.5953Q5.3384 8.1431 5.0035 7.8197Q4.6687 7.4963 4.3739 7.4104Q4.0791 7.3246 3.5926 7.3246H2.3104V11.0279H1.2V2.6367H4.9148Q5.6761 2.6367 6.1912 2.734Q6.7064 2.8313 7.0956 3.1433Q7.4848 3.4552 7.6938 3.9303Q7.9027 4.4054 7.9027 4.932Q7.9027 5.8822 7.3017 6.4603Q6.7007 7.0384 5.5502 7.1929V7.2158Q6.3916 7.5879 7.13 8.7441L8.5953 11.0279ZM2.3104 6.3286H4.6916Q5.4128 6.3286 5.8335 6.2056Q6.2542 6.0825 6.5061 5.7276Q6.7579 5.3727 6.7579 4.932Q6.7579 4.3596 6.3401 3.9589Q5.9222 3.5582 4.9606 3.5582H2.3104V6.3286ZM10.4842 5.7391Q11.0623 4.8175 12.2185 4.8175Q13.4148 4.8175 14.1074 5.6847Q14.8 6.5519 14.8 7.9428Q14.8 9.4253 14.033 10.2981Q13.266 11.171 12.1498 11.171Q11.171 11.171 10.5815 10.3926H10.5529V13.3633H9.5226V4.9549H10.4613V5.7391H10.4842ZM12.0811 10.3239Q12.8024 10.3239 13.2746 9.7258Q13.7468 9.1276 13.7468 7.9428Q13.7468 6.8266 13.2918 6.2256Q12.8367 5.6246 12.1269 5.6246Q11.3943 5.6246 10.9221 6.2943Q10.4498 6.964 10.4498 8.0286Q10.4498 9.1562 10.902 9.7401Q11.3542 10.3239 12.0811 10.3239Z`}}]},V=(0,u.forwardRef)(function(e,t){return(0,u.createElement)(k,Object.assign({},e,{id:`rupiah-icon`,ref:t,icon:be}))});V.displayName=`RupiahIcon`;let xe={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:`M14.8 9.4486H12.955L11.8883 13.2829H10.5477L9.4811 9.4486H6.5189L5.4378 13.2829H4.0108L2.9874 9.4486H1.2V8.4685H2.7351L2.4541 7.409H1.2V6.436H2.1946L1.2 2.7171H2.6342L3.4919 6.436H6.1153L7.182 2.7171H8.8613L9.9135 6.436H12.4649L13.3802 2.7171H14.8L13.7622 6.436H14.8V7.409H13.5099L13.2144 8.4685H14.8V9.4486ZM8.645 6.436Q8.0757 4.3676 7.9892 4Q7.8667 4.6342 7.3261 6.436H8.645ZM12.2414 7.409H10.209L10.5045 8.4685H11.9748L12.2414 7.409ZM9.2144 8.4685L8.9189 7.409H7.0739L6.7856 8.4685H9.2144ZM5.8559 7.409H3.7297L3.9748 8.4685H5.5604L5.8559 7.409ZM11.7586 9.4486H10.7351Q11.0955 11.1063 11.1964 11.8054L11.7586 9.4486ZM5.2937 9.4486H4.1838Q4.573 11.1063 4.7027 11.8054Q4.955 10.7315 5.2937 9.4486Z`}}]},H=(0,u.forwardRef)(function(e,t){return(0,u.createElement)(k,Object.assign({},e,{id:`won-icon`,ref:t,icon:xe}))});H.displayName=`WonIcon`;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:`M10.092 14.8H1.3716V13.4548L7.6428 6.2652Q6.5389 6.3302 5.7596 6.3302H1.7334V4.9572H9.7858V6.0426L4.4516 12.2767Q4.2939 12.4715 3.6352 13.1858Q3.4775 13.3342 3.4218 13.4363Q4.3774 13.3528 5.5277 13.3528H10.092V14.8ZM14.6284 6.9888L13.376 8.0557V14.8H11.7247V9.4843L10.5094 10.4862V9.0205L11.7247 8.0186V1.2H13.376V6.5899L14.6284 5.5323V6.9888Z`}}]},Ce=(0,u.forwardRef)(function(e,t){return(0,u.createElement)(k,Object.assign({},e,{id:`zloty-icon`,ref:t,icon:Se}))});Ce.displayName=`ZlotyIcon`;let U=(0,u.createContext)([]),W=class{constructor(e){this._localStorageService=e}_getKey(e){return`userHabitController_${e}`}async addHabit(e,t){let n=this._getKey(e);return this._localStorageService.getItem(n).then(e=>{e||this._localStorageService.setItem(n,t)})}markHabit(e,t){let n=this._getKey(e);this._localStorageService.getItem(n).then(e=>{if(e){let r=e.findIndex(e=>e===t);r>-1&&e.splice(r,1),e.unshift(t),this._localStorageService.setItem(n,e)}})}async getHabit(e,t){let n=this._getKey(e),r=await this._localStorageService.getItem(n);if(t&&r){let e=r.map((e,t,n)=>({value:e,priority:n.length-t}));return t.sort((t,n)=>{var r,i;let a=((r=e.find(e=>e.value===t))==null?void 0:r.priority)||-1;return(((i=e.find(e=>e.value===n))==null?void 0:i.priority)||-1)-a})}return r||[]}deleteHabit(e){this._localStorageService.removeItem(e)}};W=y([v(0,(0,r.Inject)(r.ILocalStorageService))],W);let we=e=>!!(0,t.getCurrencyType)(e)&&e.startsWith(`_(`);function Te(e){let{defaultPattern:i,onActionChange:a,onChange:o}=e,[s,c]=(0,u.useState)(()=>(0,t.getDecimalFromPattern)(i||``,2)),f=(0,u.useContext)(U),[p,m]=(0,u.useState)(()=>(0,t.getCurrencyType)(i)||f[0]),h=(0,u.useMemo)(()=>f.map(e=>({label:e,value:e})),[]),g=(0,n.useDependency)(r.LocaleService);return(0,u.useLayoutEffect)(()=>{a(()=>(0,t.setPatternDecimal)(`_("${p}"* #,##0${s>0?`.0`:``}_)`,s))},[s,a,p]),(0,d.jsxs)(`div`,{children:[(0,d.jsxs)(`div`,{className:`univer-mt-4 univer-flex univer-justify-between`,children:[(0,d.jsxs)(`div`,{className:`option`,children:[(0,d.jsx)(`div`,{className:`univer-text-sm univer-text-gray-400`,children:g.t(`sheets-numfmt-ui.decimalLength`)}),(0,d.jsx)(`div`,{className:`univer-mt-2 univer-w-32`,children:(0,d.jsx)(l.InputNumber,{value:s,step:1,precision:0,max:20,min:0,onChange:e=>{let n=e||0;c(n),o((0,t.setPatternDecimal)(`_("${p}"* #,##0${n>0?`.0`:``}_)`,n))}})})]}),(0,d.jsxs)(`div`,{className:`option`,children:[(0,d.jsx)(`div`,{className:`univer-text-sm univer-text-gray-400`,children:g.t(`sheets-numfmt-ui.currencyType`)}),(0,d.jsx)(`div`,{className:`univer-mt-2 univer-w-36`,children:(0,d.jsx)(l.Select,{options:h,value:p,onChange:e=>{m(e),o((0,t.setPatternDecimal)(`_("${e}"* #,##0${s>0?`.0`:``}_)`,s))}})})]})]}),(0,d.jsx)(`div`,{className:`univer-mt-4 univer-text-sm univer-text-gray-400`,children:g.t(`sheets-numfmt-ui.accountingDes`)})]})}let Ee=e=>!!(0,t.getCurrencyType)(e)&&!e.startsWith(`_(`);function De(e){let{onActionChange:i,onChange:a}=e,o=(0,n.useDependency)(r.LocaleService),s=(0,u.useContext)(U),[c,f]=(0,u.useState)(()=>(0,t.getCurrencyType)(e.defaultPattern)||s[0]),[p,m]=(0,u.useState)(()=>(0,t.getDecimalFromPattern)(e.defaultPattern||``,2)),[h,g]=(0,u.useState)(()=>{var n;let i=(0,t.getCurrencyFormatOptions)(c);return((n=i.find(t=>(0,r.isPatternEqualWithoutDecimal)(t.value,e.defaultPattern)))==null?void 0:n.value)||i[0].value}),_=(0,u.useMemo)(()=>(0,t.getCurrencyFormatOptions)(c),[c]),v=(0,u.useMemo)(()=>s.map(e=>({label:e,value:e})),[s]);return(0,u.useLayoutEffect)(()=>{i(()=>(0,t.setPatternDecimal)(h,p))},[p,i,h]),(0,d.jsxs)(`div`,{children:[(0,d.jsxs)(`div`,{className:`univer-mt-4 univer-flex univer-justify-between`,children:[(0,d.jsxs)(`div`,{className:`option`,children:[(0,d.jsx)(`div`,{className:`univer-text-sm univer-text-gray-400`,children:o.t(`sheets-numfmt-ui.decimalLength`)}),(0,d.jsx)(`div`,{className:`univer-mt-2 univer-w-32`,children:(0,d.jsx)(l.InputNumber,{value:p,max:20,min:0,onChange:e=>{m(e||0),a((0,t.setPatternDecimal)(h,e||0))}})})]}),(0,d.jsxs)(`div`,{className:`option`,children:[(0,d.jsx)(`div`,{className:`univer-text-sm univer-text-gray-400`,children:o.t(`sheets-numfmt-ui.currencyType`)}),(0,d.jsx)(`div`,{className:`univer-mt-2 univer-w-36`,children:(0,d.jsx)(l.Select,{value:c,options:v,onChange:e=>{if(e===void 0)return;f(e);let n=(0,t.getCurrencyFormatOptions)(e)[0].value;g(n),a((0,t.setPatternDecimal)(n,p))}})})]})]}),(0,d.jsx)(`div`,{className:`label univer-mt-4`,children:o.t(`sheets-numfmt-ui.negType`)}),(0,d.jsx)(`div`,{className:`univer-mt-2`,children:(0,d.jsx)(l.SelectList,{value:h,options:_,onChange:e=>{e!==void 0&&(g(e),a((0,t.setPatternDecimal)(e,p)))}})}),(0,d.jsx)(`div`,{className:`univer-mt-4 univer-text-sm univer-text-gray-400`,children:o.t(`sheets-numfmt-ui.currencyDes`)})]})}let G=`customFormat`,K=`numfmt_custom_pattern`;function Oe(e){let{defaultPattern:i,onActionChange:a,onChange:o}=e,s=(0,n.useDependency)(W),c=(0,n.useDependency)(r.ILocalStorageService),f=(0,n.useDependency)(r.LocaleService),[p,m]=(0,u.useState)(i);(0,u.useLayoutEffect)(()=>{a(()=>(s.markHabit(G,p),c.getItem(K).then((e=[])=>{let t=[...new Set([p,...e||[]])].splice(0,10).filter(e=>!!e);c.setItem(K,t)}),p))},[c,a,p,s]);let[h,g]=(0,u.useState)([]);(0,u.useEffect)(()=>{let e=!1;return c.getItem(K).then(e=>{let n=[...t.CURRENCYFORMAT.map(e=>e.suffix(`$`)),...t.DATEFMTLISG.map(e=>e.suffix),...t.NUMBERFORMAT.map(e=>e.suffix),...e??[]];return s.addHabit(G,[]).then(()=>s.getHabit(G,n))}).then(t=>{e||g([...new Set(t)])}),()=>{e=!0}},[c,s]);let _=e=>{m(e),o(e)};return(0,d.jsxs)(`div`,{children:[(0,d.jsx)(`div`,{className:`univer-mt-4 univer-text-sm univer-text-gray-400`,children:f.t(`sheets-numfmt-ui.customFormat`)}),(0,d.jsx)(l.Input,{placeholder:f.t(`sheets-numfmt-ui.customFormat`),onBlur:()=>{o(p)},value:p,onChange:m,className:`univer-mt-2 univer-w-full`}),(0,d.jsx)(`div`,{className:(0,l.clsx)(`univer-mt-2 univer-max-h-[400px] univer-overflow-auto univer-rounded-lg univer-p-2`,l.borderClassName),children:h.map(e=>(0,d.jsxs)(`div`,{onClick:()=>_(e),className:`univer-flex univer-cursor-pointer univer-items-center univer-gap-1.5 univer-py-1.5 univer-text-sm`,children:[(0,d.jsx)(`div`,{className:`univer-flex univer-w-4 univer-items-center univer-text-primary-600`,children:p===e&&(0,d.jsx)(M,{})}),(0,d.jsx)(`div`,{children:e})]},e))}),(0,d.jsx)(`div`,{className:`univer-mt-3 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200`,children:f.t(`sheets-numfmt-ui.customFormatDes`)})]})}let ke=e=>{let n=r.numfmt.getFormatInfo(e);return(0,t.getDateFormatOptions)().map(e=>e.value).includes(e)||[`date`,`datetime`,`time`].includes(n.type)};function Ae(e){let{onActionChange:i,onChange:a,defaultPattern:o}=e,s=(0,u.useMemo)(t.getDateFormatOptions,[]),c=(0,n.useDependency)(r.LocaleService),[f,p]=(0,u.useState)(()=>{if(o){let e=s.find(e=>e.value===o);if(e)return e.value}return s[0].value});return(0,u.useLayoutEffect)(()=>{i(()=>f)},[i,f]),(0,d.jsxs)(`div`,{children:[(0,d.jsx)(`div`,{className:`univer-mt-4 univer-text-sm univer-text-gray-400`,children:c.t(`sheets-numfmt-ui.dateType`)}),(0,d.jsx)(`div`,{className:`univer-mt-2`,children:(0,d.jsx)(l.SelectList,{value:f,options:s,onChange:e=>{e!==void 0&&(p(e),a(e))}})}),(0,d.jsx)(`div`,{className:`univer-mt-3.5 univer-text-sm/5 univer-text-gray-600 dark:!univer-text-gray-200`,children:c.t(`sheets-numfmt-ui.dateDes`)})]})}let je=e=>!e;function Me(e){let t=(0,n.useDependency)(r.LocaleService),{onActionChange:i}=e;return(0,u.useLayoutEffect)(()=>{i(()=>``)},[i]),(0,d.jsx)(`div`,{children:(0,d.jsx)(`div`,{className:`univer-mt-3.5 univer-text-sm/5 univer-text-gray-600 dark:!univer-text-gray-200`,children:t.t(`sheets-numfmt-ui.generalDes`)})})}let Ne=e=>(0,t.getNumberFormatOptions)().some(t=>(0,r.isPatternEqualWithoutDecimal)(t.value,e));function Pe(e){let{onActionChange:i,onChange:a}=e,o=(0,n.useDependency)(r.LocaleService),s=(0,u.useMemo)(t.getNumberFormatOptions,[]),[c,f]=(0,u.useState)(()=>(0,t.getDecimalFromPattern)(e.defaultPattern||``,0)),[p,m]=(0,u.useState)(()=>{let t=s.find(t=>(0,r.isPatternEqualWithoutDecimal)(t.value,e.defaultPattern||``));return(t==null?void 0:t.value)||s[0].value}),h=(0,u.useMemo)(()=>(0,t.setPatternDecimal)(p,Number(c||0)),[p,c]),g=!(0,t.isPatternHasDecimal)(p);return(0,u.useLayoutEffect)(()=>{i(()=>h)},[i,h]),(0,d.jsxs)(`div`,{children:[(0,d.jsx)(`div`,{className:`univer-mt-4 univer-text-sm univer-text-gray-400`,children:o.t(`sheets-numfmt-ui.decimalLength`)}),(0,d.jsx)(`div`,{className:`univer-mt-2`,children:(0,d.jsx)(l.InputNumber,{disabled:g,value:c,max:20,min:0,onChange:e=>{f(e||0),a((0,t.setPatternDecimal)(p,Number(e||0)))}})}),(0,d.jsxs)(`div`,{className:`univer-mt-4 univer-text-sm univer-text-gray-400`,children:[` `,o.t(`sheets-numfmt-ui.negType`)]}),(0,d.jsx)(`div`,{className:`univer-mt-2`,children:(0,d.jsx)(l.SelectList,{onChange:e=>{e!==void 0&&(f((0,t.getDecimalFromPattern)(e,0)),m(e),a(e))},options:s,value:p})}),(0,d.jsx)(`div`,{className:`univer-mt-3.5 univer-text-sm/5 univer-text-gray-600 dark:!univer-text-gray-200`,children:o.t(`sheets-numfmt-ui.thousandthPercentileDes`)})]})}let Fe=`numfmtCurrency`,Ie=e=>{let t=(0,n.useDependency)(W),[i,a]=(0,u.useState)(r.currencySymbols);return(0,u.useEffect)(()=>{t.addHabit(`numfmtCurrency`,[]).then(()=>{t.getHabit(Fe,[...r.currencySymbols]).then(t=>{a(t),e&&e(t)})})},[]),{userHabitCurrency:i,mark:e=>{t.markHabit(Fe,e)}}},Le=()=>{let e=(0,u.useRef)([]),[t,n]=(0,u.useState)({});return(0,u.useEffect)(()=>{e.current.forEach(e=>{e()}),e.current=[]},[t]),t=>{e.current.push(t),n({})}};function Re(e){var i;let{defaultValue:a,defaultPattern:o,row:s,col:c}=e.value,f=(0,n.useDependency)(r.LocaleService),p=(0,u.useRef)(()=>``),m=Le(),h=(0,u.useMemo)(()=>[{label:`sheets-numfmt-ui.general`,component:Me},{label:`sheets-numfmt-ui.accounting`,component:Te},{label:`sheets-numfmt-ui.currency`,component:De},{label:`sheets-numfmt-ui.date`,component:Ae},{label:`sheets-numfmt-ui.thousandthPercentile`,component:Pe},{label:`sheets-numfmt-ui.customFormat`,component:Oe}].map(e=>({...e,label:f.t(e.label)})),[f]),[g,_]=(0,u.useState)(C),[v,y]=(0,u.useState)(()=>`${s}_${c}_${o}`),{mark:b,userHabitCurrency:x}=Ie(()=>y(`${s}_${c}_${o}_userCurrency`)),S=(i=h.find(e=>e.label===g))==null?void 0:i.component;function C(){return[je,we,Ee,ke,Ne].reduce((e,t,n)=>e||(t(o)?h[n].label:``),``)||h[0].label}let w=h.map(e=>({label:e.label,value:e.label})),ee=t=>{_(t),m(()=>e.onChange({type:`change`,value:p.current()||``}))},T=(0,u.useCallback)(t=>{e.onChange({type:`change`,value:t})},[]),E=(0,u.useCallback)(e=>{p.current=e},[]),D=()=>{let n=p.current()||``,r=(0,t.getCurrencyType)(n);r&&b(r),e.onChange({type:`confirm`,value:n})},O=()=>{e.onChange({type:`cancel`,value:``})},te={onChange:T,onActionChange:E,defaultValue:a,defaultPattern:o};return(0,u.useEffect)(()=>{_(C()),y(`${s}_${c}_${o}`)},[s,c,o]),(0,d.jsxs)(`div`,{className:(0,l.clsx)(`univer-flex univer-h-full univer-flex-col univer-justify-between univer-overflow-y-auto univer-pb-5`,l.scrollbarClassName),children:[(0,d.jsxs)(`div`,{children:[(0,d.jsx)(`div`,{className:`univer-mt-3.5 univer-text-sm univer-text-gray-400`,children:f.t(`sheets-numfmt-ui.numfmtType`)}),(0,d.jsx)(`div`,{className:`univer-mt-2`,children:(0,d.jsx)(l.Select,{className:`univer-w-full`,value:g,options:w,onChange:ee})}),(0,d.jsx)(`div`,{children:S&&(0,d.jsx)(U.Provider,{value:x,children:(0,u.createElement)(S,{...te,key:v})})})]}),(0,d.jsxs)(`div`,{className:`univer-mb-5 univer-mt-3.5 univer-flex univer-justify-end univer-gap-2 rtl:univer-flex-row-reverse`,children:[(0,d.jsx)(l.Button,{onClick:O,children:f.t(`sheets-numfmt-ui.cancel`)}),(0,d.jsx)(l.Button,{variant:`primary`,onClick:D,children:f.t(`sheets-numfmt-ui.confirm`)})]})]})}let q=class extends r.Disposable{constructor(e,t){super(),this._componentManager=e,this._iconManager=t,this._registerComponents(),this._registerIcons()}_registerIcons(){this.disposeWithMe(this._iconManager.register({AddDigitsIcon:j,DollarIcon:N,DongIcon:P,EuroIcon:F,PercentIcon:I,ReduceDigitsIcon:L,RialIcon:R,RmbIcon:z,RoubleIcon:B,RupiahIcon:V,WonIcon:H,ZlotyIcon:Ce}))}_registerComponents(){this.disposeWithMe(this._componentManager.register(`SHEET_NUMFMT_PANEL`,Re)),[[S,w],[C,ee]].forEach(([e,t])=>{this.disposeWithMe(this._componentManager.register(e,t))})}};q=y([v(0,(0,r.Inject)(n.ComponentManager)),v(1,(0,r.Inject)(n.IconManager))],q);let J=`SHEET_NUMFMT_ALERT`,Y=class extends r.Disposable{constructor(e,t,n,r,i,a){super(),this._context=e,this._hoverManagerService=t,this._cellAlertManagerService=n,this._localeService=r,this._numfmtService=i,this._configService=a,this._init()}_init(){this._initCellAlertPopup()}_initCellAlertPopup(){this.disposeWithMe(this._hoverManagerService.currentCell$.pipe((0,s.debounceTime)(100)).subscribe(e=>{if(e){let a=e.location,s=this._context.unit,c=s.getActiveSheet();if(!c)return this._hideAlert();let l=a.unitId,u=a.subUnitId,d,f=c.getCell(a.row,a.col);if(f!=null&&f.s){let e=s.getStyles().get(f.s);e!=null&&e.n&&(d=e.n)}if(d||=this._numfmtService.getValue(l,u,a.row,a.col),!d){this._hideAlert();return}if((0,r.isTextFormat)(d.pattern)&&r.Tools.isDefine(f==null?void 0:f.v)&&(0,r.isRealNum)(f.v)){var n,i;if((n=this._configService.getConfig(t.SHEETS_NUMFMT_PLUGIN_CONFIG_KEY))!=null&&n.disableTextFormatAlert)return;let e=this._cellAlertManagerService.currentAlert.get(J),r=e==null||(i=e.alert)==null?void 0:i.location;if(r&&r.row===a.row&&r.col===a.col&&r.subUnitId===a.subUnitId&&r.unitId===a.unitId){this._hideAlert();return}this._cellAlertManagerService.showAlert({type:o.CellAlertType.ERROR,title:this._localeService.t(`sheets-numfmt-ui.info.error`),message:this._localeService.t(`sheets-numfmt-ui.info.forceStringInfo`),location:a,width:200,height:74,key:J});return}}this._hideAlert()}))}_hideAlert(){this._cellAlertManagerService.removeAlert(J)}};Y=y([v(1,(0,r.Inject)(o.HoverManagerService)),v(2,(0,r.Inject)(o.CellAlertManagerService)),v(3,(0,r.Inject)(r.LocaleService)),v(4,(0,r.Inject)(a.INumfmtService)),v(5,r.IConfigService)],Y);let X=class extends r.Disposable{constructor(e){super(),this._repeatLastActionService=e,this._initCommandRecording()}_initCommandRecording(){this._repeatLastActionService&&this.disposeWithMe(this._repeatLastActionService.registerRepeatableCommand(t.SetNumfmtCommand.id,(e,t)=>{if(!t)return;let{values:n}=t,r=n.find(e=>e.pattern);if(!r)return;let{pattern:i,type:a}=r,o=[],s=new Set;for(let t of e){let{startRow:e,startColumn:n,endRow:r,endColumn:c}=t;for(let t=e;t<=r;t++)for(let e=n;e<=c;e++){let n=`${t}-${e}`;s.has(n)||(s.add(n),o.push({row:t,col:e,pattern:i,type:a}))}}return{...t,values:o}},o.RepeatLastActionPermission.CellStyle))}};X=y([v(0,(0,r.Optional)(o.IRepeatLastActionService))],X);let ze=()=>{let e=[];return{add:(t,n,r,i,a)=>e.push({unitId:t,subUnitId:n,row:r,col:i,value:a}),getEffects:()=>e,clean:()=>{e=[]}}},Z=class extends r.Disposable{constructor(e,t,n,r,i){super(),this._sheetInterceptorService=e,this._numfmtService=t,this._univerInstanceService=n,this._injector=r,this._editorBridgeService=i,_(this,`_collectEffectMutation`,ze()),this._initInterceptorEditorStart(),this._initInterceptorEditorEnd(),this._initInterceptorCommands()}_initInterceptorEditorStart(){this._editorBridgeService&&this.disposeWithMe((0,r.toDisposable)(this._sheetInterceptorService.writeCellInterceptor.intercept(a.BEFORE_CELL_EDIT,{handler:(e,n,i)=>{let a=n.row,o=n.col,s=this._numfmtService.getValue(n.unitId,n.subUnitId,a,o);if(s)switch((0,t.getPatternType)(s.pattern)){case`scientific`:case`currency`:case`grouped`:case`number`:{let e={...n.worksheet.getCellRaw(a,o)};return(e==null?void 0:e.t)===r.CellValueType.NUMBER&&(0,r.isRealNum)(e.v)&&(e.v=(0,f.stripErrorMargin)(Number(e.v))),i&&i(e)}case`percent`:{let e={...n.worksheet.getCellRaw(a,o)};return(e==null?void 0:e.t)===r.CellValueType.NUMBER&&(0,r.isRealNum)(e.v)&&(e.v=`${(0,f.stripErrorMargin)(Number(e.v)*100)}%`),i&&i(e)}default:return i&&i(e)}return i(e)}})))}_initInterceptorEditorEnd(){this.disposeWithMe((0,r.toDisposable)(this._sheetInterceptorService.writeCellInterceptor.intercept(a.AFTER_CELL_EDIT,{handler:(e,n,i)=>{var a,o;if(!(e!=null&&e.v)&&!(e!=null&&e.p))return i(e);this._collectEffectMutation.clean();let s=this._numfmtService.getValue(n.unitId,n.subUnitId,n.row,n.col),c=n.worksheet.getCellRaw(n.row,n.col);if((0,r.isTextFormat)(s==null?void 0:s.pattern)||e.t===r.CellValueType.FORCE_STRING)return i(e);let l=(a=e.p)==null?void 0:a.body,u=e!=null&&(o=e.p)!=null&&(o=o.body)!=null&&o.dataStream?e.p.body.dataStream.replace(/\r\n$/,``):String(e.v),d=(0,r.getNumfmtParseValueFilter)(u);if(l)if(Be(l)){let{dataStream:t}=l,n=t.replace(/\r\n$/,``),r=Number(n);if(Number.isNaN(r)&&!d)return i(e)}else return i(e);if(d){if(!d.z&&!(s!=null&&s.pattern)&&(c==null?void 0:c.t)!==r.CellValueType.STRING&&(c==null?void 0:c.t)!==r.CellValueType.FORCE_STRING&&(0,r.willLoseNumericPrecision)(u))return i({...e,p:void 0,v:u,t:r.CellValueType.FORCE_STRING});d.z&&(!(s!=null&&s.pattern)||(0,t.getPatternType)(d.z)!==(0,t.getPatternType)(s.pattern))&&this._collectEffectMutation.add(n.unitId,n.subUnitId,n.row,n.col,{pattern:d.z});let a=(0,f.stripErrorMargin)(Number(d.v),16);return i({...e,p:void 0,v:a,t:r.CellValueType.NUMBER})}return i(e)}})))}_initInterceptorCommands(){let e=this;this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations(t){switch(t.id){case a.SetRangeValuesCommand.id:{var n;let t=e._univerInstanceService.getCurrentUnitOfType(r.UniverInstanceType.UNIVER_SHEET),i=t.getUnitId(),o=(n=t.getActiveSheet())==null?void 0:n.getSheetId();if(!o)return{redos:[],undos:[]};let s=e._collectEffectMutation.getEffects();if(e._collectEffectMutation.clean(),!s.length)return{redos:[],undos:[]};let c=s.filter(e=>{var t;return!!((t=e.value)!=null&&t.pattern)}).map(e=>({row:e.row,col:e.col,pattern:e.value.pattern})),l=s.filter(e=>{var t;return!((t=e.value)!=null&&t.pattern)}).map(e=>({startRow:e.row,endColumn:e.col,startColumn:e.col,endRow:e.row})),u=[],d=[];if(c.length){let t={id:a.SetNumfmtMutation.id,params:(0,a.transformCellsToRange)(i,o,c)};u.push(t),d.push(...(0,a.factorySetNumfmtUndoMutation)(e._injector,t.params))}if(l.length){let t={id:a.RemoveNumfmtMutation.id,params:{unitId:i,subUnitId:o,ranges:l}};u.push(t),d.push(...(0,a.factoryRemoveNumfmtUndoMutation)(e._injector,t.params))}return{redos:u,undos:d.reverse()}}}return{redos:[],undos:[]}}}))}dispose(){super.dispose(),this._collectEffectMutation.clean()}};Z=y([v(0,(0,r.Inject)(a.SheetInterceptorService)),v(1,(0,r.Inject)(a.INumfmtService)),v(2,(0,r.Inject)(r.IUniverInstanceService)),v(3,(0,r.Inject)(r.Injector)),v(4,(0,r.Optional)(o.IEditorBridgeService))],Z);function Be(e){let{textRuns:t=[],paragraphs:n=[],customRanges:r,customBlocks:i=[]}=e,a=[`va`];return!(t.some(e=>!!(e.ts&&Object.keys(e.ts).some(e=>a.includes(e))))||n.some(e=>e.bullet)||n.length>=2||r!=null&&r.length||i.length>0)}let Q=class extends r.Disposable{constructor(e){super(),this._menuManagerService=e,this._initMenu()}_initMenu(){this._menuManagerService.mergeMenu(re)}};Q=y([v(0,n.IMenuManagerService)],Q);let $=class extends r.Plugin{constructor(e=oe,t,n,i){super(),this._config=e,this._injector=t,this._configService=n,this._renderManagerService=i;let{menu:a,...o}=(0,r.merge)({},oe,this._config);a&&this._configService.setConfig(`menu`,a,{merge:!0}),this._configService.setConfig(`sheets-numfmt-ui.config`,o)}onStarting(){this._injector.add([q]),this._injector.get(q),(0,r.registerDependencies)(this._injector,[[b],[Z],[W],[Q],[X]])}onRendered(){this._registerRenderModules(),(0,r.touchDependencies)(this._injector,[[b],[Z],[Q],[X]])}_registerRenderModules(){[[Y]].forEach(e=>{this.disposeWithMe(this._renderManagerService.registerRenderModule(r.UniverInstanceType.UNIVER_SHEET,e))})}};_($,`pluginName`,`SHEET_NUMFMT_UI_PLUGIN`),_($,`packageName`,ie),_($,`version`,ae),_($,`type`,r.UniverInstanceType.UNIVER_SHEET),$=y([(0,r.DependentOn)(i.UniverRenderEnginePlugin,a.UniverSheetsPlugin,t.UniverSheetsNumfmtPlugin,o.UniverSheetsUIPlugin),v(1,(0,r.Inject)(r.Injector)),v(2,r.IConfigService),v(3,i.IRenderManagerService)],$),e.SheetsNumfmtUIMenuSchema=re,Object.defineProperty(e,"UniverSheetsNumfmtUIPlugin",{enumerable:!0,get:function(){return $}})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@univerjs/sheets-numfmt-ui",
3
- "version": "1.0.0-alpha.8",
3
+ "version": "1.0.0-beta.0",
4
4
  "private": false,
5
5
  "description": "Number format menus, editors, and previews for Univer Sheets.",
6
6
  "author": "DreamNum Co., Ltd. <developer@univer.ai>",
@@ -58,24 +58,24 @@
58
58
  "rxjs": ">=7.0.0"
59
59
  },
60
60
  "dependencies": {
61
- "@univerjs/icons": "1.34.0",
62
- "@univerjs/engine-formula": "1.0.0-alpha.8",
63
- "@univerjs/design": "1.0.0-alpha.8",
64
- "@univerjs/engine-render": "1.0.0-alpha.8",
65
- "@univerjs/sheets": "1.0.0-alpha.8",
66
- "@univerjs/sheets-numfmt": "1.0.0-alpha.8",
67
- "@univerjs/sheets-ui": "1.0.0-alpha.8",
68
- "@univerjs/ui": "1.0.0-alpha.8",
69
- "@univerjs/core": "1.0.0-alpha.8"
61
+ "@univerjs/icons": "1.35.0",
62
+ "@univerjs/core": "1.0.0-beta.0",
63
+ "@univerjs/design": "1.0.0-beta.0",
64
+ "@univerjs/engine-render": "1.0.0-beta.0",
65
+ "@univerjs/sheets-numfmt": "1.0.0-beta.0",
66
+ "@univerjs/sheets": "1.0.0-beta.0",
67
+ "@univerjs/sheets-ui": "1.0.0-beta.0",
68
+ "@univerjs/engine-formula": "1.0.0-beta.0",
69
+ "@univerjs/ui": "1.0.0-beta.0"
70
70
  },
71
71
  "devDependencies": {
72
- "postcss": "^8.5.23",
72
+ "postcss": "^8.5.25",
73
73
  "react": "18.3.1",
74
74
  "rxjs": "^7.8.2",
75
75
  "tailwindcss": "3.4.18",
76
76
  "typescript": "^6.0.3",
77
77
  "vitest": "^4.1.10",
78
- "@univerjs-infra/shared": "1.0.0-alpha.8"
78
+ "@univerjs-infra/shared": "1.0.0-beta.0"
79
79
  },
80
80
  "scripts": {
81
81
  "test": "vitest run",