@univerjs/core 0.7.0 → 0.8.0-beta.1

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.
@@ -15,3 +15,9 @@
15
15
  */
16
16
  export declare function isNumeric(str: string): boolean;
17
17
  export declare function isSafeNumeric(str: string): boolean;
18
+ /**
19
+ * Whether the numeric string will lose precision when converted to a number.
20
+ * e.g. '123456789123456789' -> 123456789123456780
21
+ * e.g. '1212121212121212.2345' -> 1212121212121212.2
22
+ */
23
+ export declare function willLoseNumericPrecision(str: string): boolean;
@@ -1,4 +1,4 @@
1
- import { CommandListener, IDisposable, IDocumentData, IExecutionOptions, IParagraphStyle, ITextDecoration, ITextStyle, LifecycleStages, ColorBuilder, Disposable, ICommandService, Injector, IUniverInstanceService, LifecycleService, ParagraphStyleBuilder, ParagraphStyleValue, RichTextBuilder, RichTextValue, TextDecorationBuilder, TextStyleBuilder, TextStyleValue, Univer } from '@univerjs/core';
1
+ import { CommandListener, IDisposable, IDocumentData, IExecutionOptions, ILanguagePack, IParagraphStyle, ITextDecoration, ITextStyle, LifecycleStages, ColorBuilder, Disposable, ICommandService, Injector, IUniverInstanceService, LifecycleService, ParagraphStyleBuilder, ParagraphStyleValue, RichTextBuilder, RichTextValue, TextDecorationBuilder, TextStyleBuilder, TextStyleValue, Univer } from '@univerjs/core';
2
2
  import { Subscription } from 'rxjs';
3
3
  import { IEventParamConfig, FEventName } from './f-event';
4
4
  import { FBlob } from './f-blob';
@@ -96,6 +96,37 @@ export declare class FUniver extends Disposable {
96
96
  * ```
97
97
  */
98
98
  redo(): Promise<boolean>;
99
+ /**
100
+ * Toggle dark mode on or off.
101
+ * @param {boolean} isDarkMode - Whether the dark mode is enabled.
102
+ * @example
103
+ * ```ts
104
+ * univerAPI.toggleDarkMode(true);
105
+ * ```
106
+ */
107
+ toggleDarkMode(isDarkMode: boolean): void;
108
+ /**
109
+ * Load locales for the given locale.
110
+ * @description This method is utilized to load locales, which can be either built-in or custom-defined.
111
+ * @param {string} locale - A unique locale identifier.
112
+ * @param {ILanguagePack} locales - The locales object containing the translations.
113
+ * @example
114
+ * ```ts
115
+ * univerAPI.loadLocales('esES', {
116
+ * 'Hello World': 'Hola Mundo',
117
+ * });
118
+ * ```
119
+ */
120
+ loadLocales(locale: string, locales: ILanguagePack): void;
121
+ /**
122
+ * Set the current locale.
123
+ * @param {string} locale - A unique locale identifier.
124
+ * @example
125
+ * ```ts
126
+ * univerAPI.setLocale('esES');
127
+ * ```
128
+ */
129
+ setLocale(locale: string): void;
99
130
  /**
100
131
  * Register a callback that will be triggered before invoking a command.
101
132
  * @deprecated use `univerAPI.addEvent(univerAPI.Event.BeforeCommandExecute, (event) => {})` instead.
@@ -1,4 +1,4 @@
1
- import { INumfmt, Rectangle, Tools } from '@univerjs/core';
1
+ import { numfmt, Rectangle, Tools } from '@univerjs/core';
2
2
  /**
3
3
  * @ignore
4
4
  */
@@ -35,7 +35,7 @@ export declare class FUtil {
35
35
  * console.log(text);
36
36
  * ```
37
37
  */
38
- get numfmt(): INumfmt;
38
+ get numfmt(): typeof numfmt;
39
39
  /**
40
40
  * common tools
41
41
  *
@@ -14,7 +14,6 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  export { getPlainText } from './docs/data-model/text-x/build-utils/parse';
17
- export type { INumfmt } from './shared/types/numfmt.type';
18
17
  export { debounce, get, merge, mergeWith, set } from 'lodash-es';
19
18
  export { textDiff } from './shared/text-diff';
20
19
  export { dedupe, dedupeBy, groupBy, makeArray, remove, rotate } from './common/array';
@@ -31,7 +30,7 @@ export { AsyncInterceptorManager, composeInterceptors, createAsyncInterceptorKey
31
30
  export type { Serializable } from './common/json';
32
31
  export { MemoryCursor } from './common/memory-cursor';
33
32
  export { mixinClass } from './common/mixin';
34
- export { isNumeric, isSafeNumeric } from './common/number';
33
+ export { isNumeric, isSafeNumeric, willLoseNumericPrecision } from './common/number';
35
34
  export { Registry, RegistryAsMap } from './common/registry';
36
35
  export { requestImmediateMacroTask } from './common/request-immediate-macro-task';
37
36
  export { type ISequenceExecuteResult, sequence, sequenceAsync } from './common/sequence';
@@ -72,7 +71,7 @@ export { IPermissionService, PermissionStatus, } from './services/permission/typ
72
71
  export type { IPermissionParam } from './services/permission/type';
73
72
  export type { IPermissionPoint } from './services/permission/type';
74
73
  export type { IPermissionTypes, RangePermissionPointConstructor, WorkbookPermissionPointConstructor, WorkSheetPermissionPointConstructor } from './services/permission/type';
75
- export type { PluginCtor } from './services/plugin/plugin.service.ts';
74
+ export type { PluginCtor } from './services/plugin/plugin.service';
76
75
  export { DependentOn, Plugin, PluginService } from './services/plugin/plugin.service';
77
76
  export { type DependencyOverride, mergeOverrideWithDependencies } from './services/plugin/plugin-override';
78
77
  export { IResourceLoaderService } from './services/resource-loader/type';
@@ -120,7 +119,7 @@ export { type IUniverConfig, Univer } from './univer';
120
119
  export { isNodeEnv } from './shared/tools';
121
120
  export { Skeleton } from './skeleton';
122
121
  export type { IGetRowColByPosOptions } from './sheets/sheet-skeleton';
123
- export type { IPosition } from './sheets/typedef.ts';
122
+ export type { IPosition } from './sheets/typedef';
124
123
  export * from './sheets/sheet-skeleton';
125
124
  export { invertColorByMatrix } from './common/invert-color/invert-rgb';
126
125
  export { invertColorByHSL } from './common/invert-color/invert-hsl';
@@ -19,6 +19,7 @@ export declare const ILogService: import('@wendellhu/redi').IdentifierDecorator<
19
19
  export declare class DesktopLogService extends Disposable implements ILogService {
20
20
  private _logLevel;
21
21
  private _deduction;
22
+ dispose(): void;
22
23
  debug(...args: ArgsType): void;
23
24
  log(...args: ArgsType): void;
24
25
  warn(...args: ArgsType): void;
@@ -2,10 +2,13 @@ import { UniverInstanceType } from '../../common/unit';
2
2
  import { IResources } from '../resource-manager/type';
3
3
  import { IResourceHook, IResourceManagerService, IResourceName } from './type';
4
4
  import { Disposable } from '../../shared/lifecycle';
5
+ import { ILogService } from '../log/log.service';
5
6
  export declare class ResourceManagerService extends Disposable implements IResourceManagerService {
7
+ private readonly _logService;
6
8
  private _resourceMap;
7
- private _register$;
8
- register$: import('rxjs').Observable<IResourceHook<any>>;
9
+ private readonly _register$;
10
+ readonly register$: import('rxjs').Observable<IResourceHook<any>>;
11
+ constructor(_logService: ILogService);
9
12
  getAllResourceHooks(): IResourceHook<any>[];
10
13
  getResources(unitId: string): IResources;
11
14
  getResources(unitId: string, type: UniverInstanceType): IResources;
@@ -1,24 +1,10 @@
1
- /**
2
- * Copyright 2023-present DreamNum Co., Ltd.
3
- *
4
- * Licensed under the Apache License, Version 2.0 (the "License");
5
- * you may not use this file except in compliance with the License.
6
- * You may obtain a copy of the License at
7
- *
8
- * http://www.apache.org/licenses/LICENSE-2.0
9
- *
10
- * Unless required by applicable law or agreed to in writing, software
11
- * distributed under the License is distributed on an "AS IS" BASIS,
12
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- * See the License for the specific language governing permissions and
14
- * limitations under the License.
15
- */
1
+ import { Disposable } from '../../shared/lifecycle';
16
2
  export interface IUser {
17
3
  userID: string;
18
4
  name: string;
19
5
  avatar?: string;
20
6
  }
21
- export declare class UserManagerService {
7
+ export declare class UserManagerService extends Disposable {
22
8
  private _model;
23
9
  private _userChange$;
24
10
  userChange$: import('rxjs').Observable<{
@@ -33,6 +19,7 @@ export declare class UserManagerService {
33
19
  * @memberof UserManagerService
34
20
  */
35
21
  currentUser$: import('rxjs').Observable<IUser>;
22
+ dispose(): void;
36
23
  getCurrentUser<T extends IUser>(): T;
37
24
  setCurrentUser<T extends IUser>(user: T): void;
38
25
  addUser<T extends IUser>(user: T): void;
@@ -1,7 +1,8 @@
1
- import { ICellData, ICellDataForSheetInterceptor, ICellWithCoord, IRange, IRangeWithCoord, ISelectionCell } from '../sheets/typedef';
1
+ import { CellValue, ICellData, ICellDataForSheetInterceptor, ICellWithCoord, IRange, IRangeWithCoord, ISelectionCell } from '../sheets/typedef';
2
2
  import { Worksheet } from '../sheets/worksheet';
3
3
  import { IDocumentData } from '../types/interfaces/i-document-data';
4
4
  import { IColorStyle, IStyleData } from '../types/interfaces/i-style-data';
5
+ import { IObjectMatrixPrimitiveType } from './object-matrix';
5
6
  import { Nullable } from './types';
6
7
  /**
7
8
  * Data type convert, convert ICellWithCoord to IRangeWithCoord
@@ -46,3 +47,16 @@ export declare function isValidRange(range: IRange, worksheet?: Worksheet): bool
46
47
  * @returns
47
48
  */
48
49
  export declare function cellToRange(row: number, col: number): IRange;
50
+ /**
51
+ * Covert cell value to cell data.
52
+ * @param {CellValue | ICellData} value - The cell value.
53
+ * @returns {ICellData} The cell data.
54
+ */
55
+ export declare function covertCellValue(value: CellValue | ICellData): ICellData;
56
+ /**
57
+ * Covert cell value array or matrix to cell data.
58
+ * @param {CellValue[][] | IObjectMatrixPrimitiveType<CellValue> | ICellData[][] | IObjectMatrixPrimitiveType<ICellData>} value - The cell value array or matrix.
59
+ * @param {IRange} range - The range.
60
+ * @returns {IObjectMatrixPrimitiveType<ICellData>} The cell data matrix.
61
+ */
62
+ export declare function covertCellValues(value: CellValue[][] | IObjectMatrixPrimitiveType<CellValue> | ICellData[][] | IObjectMatrixPrimitiveType<ICellData>, range: IRange): IObjectMatrixPrimitiveType<ICellData>;
@@ -30,7 +30,7 @@ export * from './hash-algorithm';
30
30
  export * from './lifecycle';
31
31
  export * from './locale';
32
32
  export { LRUHelper, LRUMap } from './lru/lru-map';
33
- export { type INumfmtLocalTag, numfmt } from './numfmt';
33
+ export { type INumfmtLocalTag, isPatternEqualWithoutDecimal, numfmt } from './numfmt';
34
34
  export * from './object-matrix';
35
35
  export { queryObjectMatrix } from './object-matrix-query';
36
36
  export { moveRangeByOffset, splitIntoGrid } from './range';
@@ -1,3 +1,23 @@
1
- import { INumfmt, LocaleTag } from './types/numfmt.type';
2
- declare const numfmt: INumfmt;
3
- export { LocaleTag as INumfmtLocalTag, numfmt };
1
+ /**
2
+ * Copyright 2023-present DreamNum Co., Ltd.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ export * as numfmt from 'numfmt';
17
+ export type INumfmtLocalTag = 'zh-CN' | 'zh-TW' | 'cs' | 'da' | 'nl' | 'en' | 'fi' | 'fr' | 'de' | 'el' | 'hu' | 'is' | 'id' | 'it' | 'ja' | 'ko' | 'nb' | 'pl' | 'pt' | 'ru' | 'sk' | 'es' | 'sv' | 'th' | 'tr' | 'vi';
18
+ /**
19
+ * Determines whether two patterns are equal, excluding differences in decimal places.
20
+ * This function ignores the decimal part of the patterns and the positive color will be ignored but negative color will be considered.
21
+ * more info can check the test case.
22
+ */
23
+ export declare const isPatternEqualWithoutDecimal: (patternA: string, patternB: string) => boolean;
@@ -9,6 +9,7 @@ export interface IObjectMatrixPrimitiveType<T> {
9
9
  export interface IObjectArrayPrimitiveType<T> {
10
10
  [key: number]: T;
11
11
  }
12
+ export declare function mapObjectMatrix<T, R>(o: IObjectMatrixPrimitiveType<T>, callback: (row: number, col: number, value: T) => R): IObjectMatrixPrimitiveType<R>;
12
13
  export declare function getArrayLength<T>(o: IObjectArrayPrimitiveType<T> | IObjectMatrixPrimitiveType<T>): number;
13
14
  export declare function insertMatrixArray<T>(index: number, value: T, o: IObjectArrayPrimitiveType<T> | IObjectMatrixPrimitiveType<T>): void;
14
15
  export declare function spliceArray<T>(start: number, count: number, o: IObjectArrayPrimitiveType<T> | IObjectMatrixPrimitiveType<T>): void;
@@ -99,5 +100,6 @@ export declare class ObjectMatrix<T> {
99
100
  getStartEndScope(): IRange;
100
101
  getDataRange(): IRange;
101
102
  getDiscreteRanges(): IRange[];
103
+ merge(newObject: ObjectMatrix<Nullable<T>>): void;
102
104
  private _setOriginValue;
103
105
  }
@@ -34,10 +34,6 @@ export declare class SheetSkeleton extends Skeleton {
34
34
  protected _renderRawFormula: boolean;
35
35
  protected _cellData: ObjectMatrix<Nullable<ICellData>>;
36
36
  protected _imageCacheMap: ImageCacheMap;
37
- /**
38
- * Whether the row style precedes the column style.
39
- */
40
- protected _isRowStylePrecedeColumnStyle: boolean;
41
37
  /**
42
38
  * Whether auto height for merged cells
43
39
  */
@@ -1,8 +1,8 @@
1
1
  import { Nullable } from '../shared';
2
+ import { CellValueType, TextDirection, HorizontalAlign, VerticalAlign, WrapStrategy } from '../types/enum';
3
+ import { IPaddingData, IStyleBase, IStyleData, ITextRotation, ITextStyle } from '../types/interfaces';
2
4
  import { IRange, IUnitRange } from './typedef';
3
5
  import { DocumentDataModel } from '../docs';
4
- import { CellValueType, HorizontalAlign, TextDirection, VerticalAlign, WrapStrategy } from '../types/enum';
5
- import { IPaddingData, IStyleBase, IStyleData, ITextRotation, ITextStyle } from '../types/interfaces';
6
6
  export interface IFontLocale {
7
7
  fontList: string[];
8
8
  defaultFontSize: number;
@@ -42,19 +42,26 @@ export declare class Worksheet {
42
42
  private readonly _styles;
43
43
  protected _sheetId: string;
44
44
  protected _snapshot: IWorksheetData;
45
- protected _cellData: ObjectMatrix<ICellData>;
45
+ protected _cellData: ObjectMatrix<Nullable<ICellData>>;
46
46
  protected _rowManager: RowManager;
47
47
  protected _columnManager: ColumnManager;
48
48
  protected readonly _viewModel: SheetViewModel;
49
49
  protected _spanModel: SpanModel;
50
+ /**
51
+ * Whether the row style precedes the column style.
52
+ */
53
+ protected _isRowStylePrecedeColumnStyle: boolean;
54
+ private _getCellHeight;
50
55
  constructor(unitId: string, snapshot: Partial<IWorksheetData>, _styles: Styles);
51
56
  getSnapshot(): IWorksheetData;
57
+ getCellHeight(row: number, col: number): number;
52
58
  /**
53
59
  * Set the merge data of the sheet, all the merged cells will be rebuilt.
54
60
  * @param mergeData
55
61
  */
56
62
  setMergeData(mergeData: IRange[]): void;
57
63
  getSpanModel(): SpanModel;
64
+ setIsRowStylePrecedeColumnStyle(isRowStylePrecedeColumnStyle: boolean): void;
58
65
  getStyleDataByHash(hash: string): Nullable<IStyleData>;
59
66
  setStyleData(style: IStyleData): Nullable<string>;
60
67
  /**
@@ -383,13 +390,13 @@ export declare class Worksheet {
383
390
  * @param cell
384
391
  * @param options
385
392
  */
386
- private _getCellDocumentModel;
393
+ getCellDocumentModel(cell: Nullable<ICellDataForSheetInterceptor>, style: Nullable<IStyleData>, options?: ICellDocumentModelOption): Nullable<IDocumentLayoutObject>;
387
394
  private _updateConfigAndGetDocumentModel;
388
395
  /**
389
396
  * Only used for cell edit, and no need to rotate text when edit cell content!
390
397
  */
391
- getBlankCellDocumentModel(cell: Nullable<ICellData>): IDocumentLayoutObject;
392
- getCellDocumentModelWithFormula(cell: ICellData): Nullable<IDocumentLayoutObject>;
398
+ getBlankCellDocumentModel(cell: Nullable<ICellData>, row: number, column: number): IDocumentLayoutObject;
399
+ getCellDocumentModelWithFormula(cell: ICellData, row: number, column: number): Nullable<IDocumentLayoutObject>;
393
400
  /**
394
401
  * Get custom metadata of worksheet
395
402
  * @returns {CustomData | undefined} custom metadata
@@ -1,6 +1,6 @@
1
1
  import { Nullable } from '../../shared/types';
2
2
  import { BorderStyleTypes } from '../enum/border-style-types';
3
- import { BaselineOffset, BooleanNumber, HorizontalAlign, TextDecoration, TextDirection, VerticalAlign, WrapStrategy } from '../enum/text-style';
3
+ import { BaselineOffset, BooleanNumber, HorizontalAlign, TextDecoration, VerticalAlign, WrapStrategy } from '../enum/text-style';
4
4
  import { ThemeColorType } from '../enum/theme-color-type';
5
5
  /**
6
6
  * Properties of text decoration
@@ -166,10 +166,6 @@ export interface IStyleData extends IStyleBase {
166
166
  * textRotation
167
167
  */
168
168
  tr?: Nullable<ITextRotation>;
169
- /**
170
- * textDirection
171
- */
172
- td?: Nullable<TextDirection>;
173
169
  /**
174
170
  * horizontalAlignment
175
171
  */
@@ -182,8 +178,4 @@ export interface IStyleData extends IStyleBase {
182
178
  * wrapStrategy
183
179
  */
184
180
  tb?: Nullable<WrapStrategy>;
185
- /**
186
- * padding
187
- */
188
- pd?: Nullable<IPaddingData>;
189
181
  }
@@ -16,6 +16,11 @@ export interface IUniverConfig {
16
16
  * The theme of the Univer instance, default using the default theme.
17
17
  */
18
18
  theme?: Theme;
19
+ /**
20
+ * Whether to use dark mode.
21
+ * @default false
22
+ */
23
+ darkMode?: boolean;
19
24
  /**
20
25
  * The locale of the Univer instance.
21
26
  */
package/lib/umd/facade.js CHANGED
@@ -1 +1 @@
1
- (function(c,n){typeof exports=="object"&&typeof module<"u"?n(exports,require("@univerjs/core"),require("rxjs")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","rxjs"],n):(c=typeof globalThis<"u"?globalThis:c||self,n(c.UniverCoreFacade={},c.UniverCore,c.rxjs))})(this,function(c,n,p){"use strict";var A=Object.defineProperty;var k=(c,n,p)=>n in c?A(c,n,{enumerable:!0,configurable:!0,writable:!0,value:p}):c[n]=p;var u=(c,n,p)=>k(c,typeof n!="symbol"?n+"":n,p);class v extends n.Disposable{static extend(t){Object.getOwnPropertyNames(t.prototype).forEach(e=>{e!=="constructor"&&(this.prototype[e]=t.prototype[e])}),Object.getOwnPropertyNames(t).forEach(e=>{e!=="prototype"&&e!=="name"&&e!=="length"&&(this[e]=t[e])})}}const C=Symbol("initializers");class R extends n.Disposable{constructor(t){super(),this._injector=t;const e=this,i=Object.getPrototypeOf(this)[C];i&&i.forEach(function(r){r.apply(e,[t])})}_initialize(t){}static extend(t){Object.getOwnPropertyNames(t.prototype).forEach(e=>{if(e==="_initialize"){let i=this.prototype[C];i||(i=[],this.prototype[C]=i),i.push(t.prototype._initialize)}else e!=="constructor"&&(this.prototype[e]=t.prototype[e])}),Object.getOwnPropertyNames(t).forEach(e=>{e!=="prototype"&&e!=="name"&&e!=="length"&&(this[e]=t[e])})}}var U=Object.getOwnPropertyDescriptor,O=(a,t,e,i)=>{for(var r=i>1?void 0:i?U(t,e):t,s=a.length-1,o;s>=0;s--)(o=a[s])&&(r=o(r)||r);return r},P=(a,t)=>(e,i)=>t(e,i,a);c.FBlob=class extends v{constructor(t,e){super(),this._blob=t,this._injector=e}copyBlob(){return this._injector.createInstance(c.FBlob,this._blob)}getAs(t){const e=this.copyBlob();return e.setContentType(t),e}getDataAsString(t){return this._blob===null?Promise.resolve(""):t===void 0?this._blob.text():new Promise((e,i)=>{this._blob.arrayBuffer().then(r=>{const s=new TextDecoder(t).decode(r);e(s)}).catch(r=>{i(new Error(`Failed to read Blob as ArrayBuffer: ${r.message}`))})})}getBytes(){return this._blob?this._blob.arrayBuffer().then(t=>new Uint8Array(t)):Promise.reject(new Error("Blob is undefined or null."))}setBytes(t){return this._blob=new Blob([t]),this}setDataFromString(t,e){const i=e!=null?e:"text/plain",r=new Blob([t],{type:i});return this._blob=r,this}getContentType(){var t;return(t=this._blob)==null?void 0:t.type}setContentType(t){var e;return this._blob=(e=this._blob)==null?void 0:e.slice(0,this._blob.size,t),this}},c.FBlob=O([P(1,n.Inject(n.Injector))],c.FBlob);const y=class y{static get(){if(this._instance)return this._instance;const t=new y;return this._instance=t,t}static extend(t){Object.getOwnPropertyNames(t.prototype).forEach(e=>{e!=="constructor"&&(this.prototype[e]=t.prototype[e])}),Object.getOwnPropertyNames(t).forEach(e=>{e!=="prototype"&&e!=="name"&&e!=="length"&&(this[e]=t[e])})}constructor(){for(const t in y.prototype)this[t]=y.prototype[t]}get AbsoluteRefType(){return n.AbsoluteRefType}get UniverInstanceType(){return n.UniverInstanceType}get LifecycleStages(){return n.LifecycleStages}get DataValidationType(){return n.DataValidationType}get DataValidationErrorStyle(){return n.DataValidationErrorStyle}get DataValidationRenderMode(){return n.DataValidationRenderMode}get DataValidationOperator(){return n.DataValidationOperator}get DataValidationStatus(){return n.DataValidationStatus}get CommandType(){return n.CommandType}get BaselineOffset(){return n.BaselineOffset}get BooleanNumber(){return n.BooleanNumber}get HorizontalAlign(){return n.HorizontalAlign}get TextDecoration(){return n.TextDecoration}get TextDirection(){return n.TextDirection}get VerticalAlign(){return n.VerticalAlign}get WrapStrategy(){return n.WrapStrategy}get BorderType(){return n.BorderType}get BorderStyleTypes(){return n.BorderStyleTypes}get AutoFillSeries(){return n.AutoFillSeries}get ColorType(){return n.ColorType}get CommonHideTypes(){return n.CommonHideTypes}get CopyPasteType(){return n.CopyPasteType}get DeleteDirection(){return n.DeleteDirection}get DeveloperMetadataVisibility(){return n.DeveloperMetadataVisibility}get Dimension(){return n.Dimension}get Direction(){return n.Direction}get InterpolationPointType(){return n.InterpolationPointType}get LocaleType(){return n.LocaleType}get MentionType(){return n.MentionType}get ProtectionType(){return n.ProtectionType}get RelativeDate(){return n.RelativeDate}get SheetTypes(){return n.SheetTypes}get ThemeColorType(){return n.ThemeColorType}};u(y,"_instance");let f=y;const g=class g{static get(){if(this._instance)return this._instance;const t=new g;return this._instance=t,t}static extend(t){Object.getOwnPropertyNames(t.prototype).forEach(e=>{e!=="constructor"&&(this.prototype[e]=t.prototype[e])}),Object.getOwnPropertyNames(t).forEach(e=>{e!=="prototype"&&e!=="name"&&e!=="length"&&(this[e]=t[e])})}constructor(){for(const t in g.prototype)this[t]=g.prototype[t]}get DocCreated(){return"DocCreated"}get DocDisposed(){return"DocDisposed"}get LifeCycleChanged(){return"LifeCycleChanged"}get Redo(){return"Redo"}get Undo(){return"Undo"}get BeforeRedo(){return"BeforeRedo"}get BeforeUndo(){return"BeforeUndo"}get CommandExecuted(){return"CommandExecuted"}get BeforeCommandExecute(){return"BeforeCommandExecute"}};u(g,"_instance");let m=g;var I=Object.getOwnPropertyDescriptor,x=(a,t,e,i)=>{for(var r=i>1?void 0:i?I(t,e):t,s=a.length-1,o;s>=0;s--)(o=a[s])&&(r=o(r)||r);return r},w=(a,t)=>(e,i)=>t(e,i,a);c.FHooks=class extends v{constructor(t,e){super(),this._injector=t,this._lifecycleService=e}onStarting(t){return n.toDisposable(this._lifecycleService.lifecycle$.pipe(p.filter(e=>e===n.LifecycleStages.Starting)).subscribe(t))}onReady(t){return n.toDisposable(this._lifecycleService.lifecycle$.pipe(p.filter(e=>e===n.LifecycleStages.Ready)).subscribe(t))}onRendered(t){return n.toDisposable(this._lifecycleService.lifecycle$.pipe(p.filter(e=>e===n.LifecycleStages.Rendered)).subscribe(t))}onSteady(t){return n.toDisposable(this._lifecycleService.lifecycle$.pipe(p.filter(e=>e===n.LifecycleStages.Steady)).subscribe(t))}onBeforeUndo(t){return this._injector.get(n.ICommandService).beforeCommandExecuted(i=>{if(i.id===n.UndoCommand.id){const s=this._injector.get(n.IUndoRedoService).pitchTopUndoElement();s&&t(s)}})}onUndo(t){return this._injector.get(n.ICommandService).onCommandExecuted(i=>{if(i.id===n.UndoCommand.id){const s=this._injector.get(n.IUndoRedoService).pitchTopUndoElement();s&&t(s)}})}onBeforeRedo(t){return this._injector.get(n.ICommandService).beforeCommandExecuted(i=>{if(i.id===n.RedoCommand.id){const s=this._injector.get(n.IUndoRedoService).pitchTopRedoElement();s&&t(s)}})}onRedo(t){return this._injector.get(n.ICommandService).onCommandExecuted(i=>{if(i.id===n.RedoCommand.id){const s=this._injector.get(n.IUndoRedoService).pitchTopRedoElement();s&&t(s)}})}},c.FHooks=x([w(0,n.Inject(n.Injector)),w(1,n.Inject(n.LifecycleService))],c.FHooks);var H=Object.getOwnPropertyDescriptor,F=(a,t,e,i)=>{for(var r=i>1?void 0:i?H(t,e):t,s=a.length-1,o;s>=0;s--)(o=a[s])&&(r=o(r)||r);return r},M=(a,t)=>(e,i)=>t(e,i,a);let D=class extends R{constructor(a,t){super(t),this.doc=a}};D=F([M(1,n.Inject(n.Injector))],D);class V{constructor(){u(this,"_eventRegistry",new Map);u(this,"_eventHandlerMap",new Map);u(this,"_eventHandlerRegisted",new Map)}_ensureEventRegistry(t){return this._eventRegistry.has(t)||this._eventRegistry.set(t,new n.Registry),this._eventRegistry.get(t)}registerEventHandler(t,e){const i=this._eventHandlerMap.get(t);return i?i.add(e):this._eventHandlerMap.set(t,new Set([e])),this._ensureEventRegistry(t).getData().length&&this._initEventHandler(t),n.toDisposable(()=>{var r,s,o,d;(r=this._eventHandlerMap.get(t))==null||r.delete(e),(o=(s=this._eventHandlerRegisted.get(t))==null?void 0:s.get(e))==null||o.dispose(),(d=this._eventHandlerRegisted.get(t))==null||d.delete(e)})}removeEvent(t,e){const i=this._ensureEventRegistry(t);if(i.delete(e),i.getData().length===0){const r=this._eventHandlerRegisted.get(t);r==null||r.forEach(s=>s.dispose()),this._eventHandlerRegisted.delete(t)}}_initEventHandler(t){let e=this._eventHandlerRegisted.get(t);const i=this._eventHandlerMap.get(t);i&&(e||(e=new Map,this._eventHandlerRegisted.set(t,e),i==null||i.forEach(r=>{e==null||e.set(r,n.toDisposable(r()))})))}addEvent(t,e){return this._ensureEventRegistry(t).add(e),this._initEventHandler(t),n.toDisposable(()=>this.removeEvent(t,e))}fireEvent(t,e){var i;return(i=this._eventRegistry.get(t))==null||i.getData().forEach(r=>{r(e)}),e.cancel}}var $=Object.getOwnPropertyDescriptor,z=(a,t,e,i)=>{for(var r=i>1?void 0:i?$(t,e):t,s=a.length-1,o;s>=0;s--)(o=a[s])&&(r=o(r)||r);return r},B=(a,t)=>(e,i)=>t(e,i,a);let T=class extends v{constructor(a,t){super(),this._injector=a,this._userManagerService=t}getCurrentUser(){return this._userManagerService.getCurrentUser()}};T=z([B(0,n.Inject(n.Injector)),B(1,n.Inject(n.UserManagerService))],T);const b=class b{static get(){if(this._instance)return this._instance;const t=new b;return this._instance=t,t}static extend(t){Object.getOwnPropertyNames(t.prototype).forEach(e=>{e!=="constructor"&&(this.prototype[e]=t.prototype[e])}),Object.getOwnPropertyNames(t).forEach(e=>{e!=="prototype"&&e!=="name"&&e!=="length"&&(this[e]=t[e])})}get rectangle(){return n.Rectangle}get numfmt(){return n.numfmt}get tools(){return n.Tools}};u(b,"_instance");let _=b;var L=Object.getOwnPropertyDescriptor,N=(a,t,e,i)=>{for(var r=i>1?void 0:i?L(t,e):t,s=a.length-1,o;s>=0;s--)(o=a[s])&&(r=o(r)||r);return r},E=(a,t)=>(e,i)=>t(e,i,a);const j=Symbol("initializers");c.FUniver=class extends n.Disposable{constructor(e,i,r,s){super();u(this,"_eventRegistry",new V);u(this,"registerEventHandler",(e,i)=>this._eventRegistry.registerEventHandler(e,i));this._injector=e,this._commandService=i,this._univerInstanceService=r,this._lifecycleService=s,this.registerEventHandler(this.Event.LifeCycleChanged,()=>n.toDisposable(this._lifecycleService.lifecycle$.subscribe(d=>{this.fireEvent(this.Event.LifeCycleChanged,{stage:d})}))),this._initUnitEvent(this._injector),this._initBeforeCommandEvent(this._injector),this._initCommandEvent(this._injector),this._injector.onDispose(()=>{this.dispose()});const o=Object.getPrototypeOf(this)[j];if(o){const d=this;o.forEach(function(h){h.apply(d,[e])})}}static newAPI(e){return(e instanceof n.Univer?e.__getInjector():e).createInstance(c.FUniver)}_initialize(e){}static extend(e){Object.getOwnPropertyNames(e.prototype).forEach(i=>{if(i==="_initialize"){let r=this.prototype[j];r||(r=[],this.prototype[j]=r),r.push(e.prototype._initialize)}else i!=="constructor"&&(this.prototype[i]=e.prototype[i])}),Object.getOwnPropertyNames(e).forEach(i=>{i!=="prototype"&&i!=="name"&&i!=="length"&&(this[i]=e[i])})}_initCommandEvent(e){const i=e.get(n.ICommandService);this.registerEventHandler(this.Event.Redo,()=>i.onCommandExecuted(r=>{const{id:s,type:o,params:d}=r;if(r.id===n.RedoCommand.id){const l={id:s,type:o,params:d};this.fireEvent(this.Event.Redo,l)}})),this.registerEventHandler(this.Event.Undo,()=>i.onCommandExecuted(r=>{const{id:s,type:o,params:d}=r;if(r.id===n.UndoCommand.id){const l={id:s,type:o,params:d};this.fireEvent(this.Event.Undo,l)}})),this.registerEventHandler(this.Event.CommandExecuted,()=>i.onCommandExecuted((r,s)=>{const{id:o,type:d,params:h}=r;if(r.id!==n.RedoCommand.id&&r.id!==n.UndoCommand.id){const S={id:o,type:d,params:h,options:s};this.fireEvent(this.Event.CommandExecuted,S)}}))}_initBeforeCommandEvent(e){const i=e.get(n.ICommandService);this.registerEventHandler(this.Event.BeforeRedo,()=>i.beforeCommandExecuted(r=>{const{id:s,type:o,params:d}=r;if(r.id===n.RedoCommand.id){const l={id:s,type:o,params:d};if(this.fireEvent(this.Event.BeforeRedo,l),l.cancel)throw new n.CanceledError}})),this.registerEventHandler(this.Event.BeforeUndo,()=>i.beforeCommandExecuted(r=>{const{id:s,type:o,params:d}=r;if(r.id===n.UndoCommand.id){const l={id:s,type:o,params:d};if(this.fireEvent(this.Event.BeforeUndo,l),l.cancel)throw new n.CanceledError}})),this.registerEventHandler(this.Event.BeforeCommandExecute,()=>i.beforeCommandExecuted((r,s)=>{const{id:o,type:d,params:h}=r;if(r.id!==n.RedoCommand.id&&r.id!==n.UndoCommand.id){const S={id:o,type:d,params:h,options:s};if(this.fireEvent(this.Event.BeforeCommandExecute,S),S.cancel)throw new n.CanceledError}}))}_initUnitEvent(e){const i=e.get(n.IUniverInstanceService);this.registerEventHandler(this.Event.DocDisposed,()=>i.unitDisposed$.subscribe(r=>{r.type===n.UniverInstanceType.UNIVER_DOC&&this.fireEvent(this.Event.DocDisposed,{unitId:r.getUnitId(),unitType:r.type,snapshot:r.getSnapshot()})})),this.registerEventHandler(this.Event.DocCreated,()=>i.unitAdded$.subscribe(r=>{if(r.type===n.UniverInstanceType.UNIVER_DOC){const s=r,o=e.createInstance(D,s);this.fireEvent(this.Event.DocCreated,{unitId:r.getUnitId(),type:r.type,doc:o,unit:o})}}))}disposeUnit(e){return this._univerInstanceService.disposeUnit(e)}getCurrentLifecycleStage(){return this._injector.get(n.LifecycleService).stage}undo(){return this._commandService.executeCommand(n.UndoCommand.id)}redo(){return this._commandService.executeCommand(n.RedoCommand.id)}toggleDarkMode(e){this._injector.get(n.ThemeService).setDarkMode(e)}onBeforeCommandExecute(e){return this._commandService.beforeCommandExecuted((i,r)=>{e(i,r)})}onCommandExecuted(e){return this._commandService.onCommandExecuted((i,r)=>{e(i,r)})}executeCommand(e,i,r){return this._commandService.executeCommand(e,i,r)}syncExecuteCommand(e,i,r){return this._commandService.syncExecuteCommand(e,i,r)}getHooks(){return this._injector.createInstance(c.FHooks)}get Enum(){return f.get()}get Event(){return m.get()}get Util(){return _.get()}addEvent(e,i){if(!e||!i)throw new Error("Cannot add empty event");return this._eventRegistry.addEvent(e,i)}fireEvent(e,i){return this._eventRegistry.fireEvent(e,i)}getUserManager(){return this._injector.createInstance(T)}newBlob(){return this._injector.createInstance(c.FBlob)}newColor(){return new n.ColorBuilder}newRichText(e){return n.RichTextBuilder.create(e)}newRichTextValue(e){return n.RichTextValue.create(e)}newParagraphStyle(e){return n.ParagraphStyleBuilder.create(e)}newParagraphStyleValue(e){return n.ParagraphStyleValue.create(e)}newTextStyle(e){return n.TextStyleBuilder.create(e)}newTextStyleValue(e){return n.TextStyleValue.create(e)}newTextDecoration(e){return new n.TextDecorationBuilder(e)}},c.FUniver=N([E(0,n.Inject(n.Injector)),E(1,n.ICommandService),E(2,n.IUniverInstanceService),E(3,n.Inject(n.LifecycleService))],c.FUniver),c.FBase=v,c.FBaseInitialable=R,c.FEnum=f,c.FEventName=m,c.FUtil=_,Object.defineProperty(c,Symbol.toStringTag,{value:"Module"})});
1
+ (function(c,n){typeof exports=="object"&&typeof module<"u"?n(exports,require("@univerjs/core"),require("rxjs")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","rxjs"],n):(c=typeof globalThis<"u"?globalThis:c||self,n(c.UniverCoreFacade={},c.UniverCore,c.rxjs))})(this,function(c,n,p){"use strict";var A=Object.defineProperty;var k=(c,n,p)=>n in c?A(c,n,{enumerable:!0,configurable:!0,writable:!0,value:p}):c[n]=p;var u=(c,n,p)=>k(c,typeof n!="symbol"?n+"":n,p);class v extends n.Disposable{static extend(t){Object.getOwnPropertyNames(t.prototype).forEach(e=>{e!=="constructor"&&(this.prototype[e]=t.prototype[e])}),Object.getOwnPropertyNames(t).forEach(e=>{e!=="prototype"&&e!=="name"&&e!=="length"&&(this[e]=t[e])})}}const C=Symbol("initializers");class R extends n.Disposable{constructor(t){super(),this._injector=t;const e=this,i=Object.getPrototypeOf(this)[C];i&&i.forEach(function(r){r.apply(e,[t])})}_initialize(t){}static extend(t){Object.getOwnPropertyNames(t.prototype).forEach(e=>{if(e==="_initialize"){let i=this.prototype[C];i||(i=[],this.prototype[C]=i),i.push(t.prototype._initialize)}else e!=="constructor"&&(this.prototype[e]=t.prototype[e])}),Object.getOwnPropertyNames(t).forEach(e=>{e!=="prototype"&&e!=="name"&&e!=="length"&&(this[e]=t[e])})}}var U=Object.getOwnPropertyDescriptor,O=(a,t,e,i)=>{for(var r=i>1?void 0:i?U(t,e):t,s=a.length-1,o;s>=0;s--)(o=a[s])&&(r=o(r)||r);return r},P=(a,t)=>(e,i)=>t(e,i,a);c.FBlob=class extends v{constructor(t,e){super(),this._blob=t,this._injector=e}copyBlob(){return this._injector.createInstance(c.FBlob,this._blob)}getAs(t){const e=this.copyBlob();return e.setContentType(t),e}getDataAsString(t){return this._blob===null?Promise.resolve(""):t===void 0?this._blob.text():new Promise((e,i)=>{this._blob.arrayBuffer().then(r=>{const s=new TextDecoder(t).decode(r);e(s)}).catch(r=>{i(new Error(`Failed to read Blob as ArrayBuffer: ${r.message}`))})})}getBytes(){return this._blob?this._blob.arrayBuffer().then(t=>new Uint8Array(t)):Promise.reject(new Error("Blob is undefined or null."))}setBytes(t){return this._blob=new Blob([t]),this}setDataFromString(t,e){const i=e!=null?e:"text/plain",r=new Blob([t],{type:i});return this._blob=r,this}getContentType(){var t;return(t=this._blob)==null?void 0:t.type}setContentType(t){var e;return this._blob=(e=this._blob)==null?void 0:e.slice(0,this._blob.size,t),this}},c.FBlob=O([P(1,n.Inject(n.Injector))],c.FBlob);const y=class y{static get(){if(this._instance)return this._instance;const t=new y;return this._instance=t,t}static extend(t){Object.getOwnPropertyNames(t.prototype).forEach(e=>{e!=="constructor"&&(this.prototype[e]=t.prototype[e])}),Object.getOwnPropertyNames(t).forEach(e=>{e!=="prototype"&&e!=="name"&&e!=="length"&&(this[e]=t[e])})}constructor(){for(const t in y.prototype)this[t]=y.prototype[t]}get AbsoluteRefType(){return n.AbsoluteRefType}get UniverInstanceType(){return n.UniverInstanceType}get LifecycleStages(){return n.LifecycleStages}get DataValidationType(){return n.DataValidationType}get DataValidationErrorStyle(){return n.DataValidationErrorStyle}get DataValidationRenderMode(){return n.DataValidationRenderMode}get DataValidationOperator(){return n.DataValidationOperator}get DataValidationStatus(){return n.DataValidationStatus}get CommandType(){return n.CommandType}get BaselineOffset(){return n.BaselineOffset}get BooleanNumber(){return n.BooleanNumber}get HorizontalAlign(){return n.HorizontalAlign}get TextDecoration(){return n.TextDecoration}get TextDirection(){return n.TextDirection}get VerticalAlign(){return n.VerticalAlign}get WrapStrategy(){return n.WrapStrategy}get BorderType(){return n.BorderType}get BorderStyleTypes(){return n.BorderStyleTypes}get AutoFillSeries(){return n.AutoFillSeries}get ColorType(){return n.ColorType}get CommonHideTypes(){return n.CommonHideTypes}get CopyPasteType(){return n.CopyPasteType}get DeleteDirection(){return n.DeleteDirection}get DeveloperMetadataVisibility(){return n.DeveloperMetadataVisibility}get Dimension(){return n.Dimension}get Direction(){return n.Direction}get InterpolationPointType(){return n.InterpolationPointType}get LocaleType(){return n.LocaleType}get MentionType(){return n.MentionType}get ProtectionType(){return n.ProtectionType}get RelativeDate(){return n.RelativeDate}get SheetTypes(){return n.SheetTypes}get ThemeColorType(){return n.ThemeColorType}};u(y,"_instance");let f=y;const g=class g{static get(){if(this._instance)return this._instance;const t=new g;return this._instance=t,t}static extend(t){Object.getOwnPropertyNames(t.prototype).forEach(e=>{e!=="constructor"&&(this.prototype[e]=t.prototype[e])}),Object.getOwnPropertyNames(t).forEach(e=>{e!=="prototype"&&e!=="name"&&e!=="length"&&(this[e]=t[e])})}constructor(){for(const t in g.prototype)this[t]=g.prototype[t]}get DocCreated(){return"DocCreated"}get DocDisposed(){return"DocDisposed"}get LifeCycleChanged(){return"LifeCycleChanged"}get Redo(){return"Redo"}get Undo(){return"Undo"}get BeforeRedo(){return"BeforeRedo"}get BeforeUndo(){return"BeforeUndo"}get CommandExecuted(){return"CommandExecuted"}get BeforeCommandExecute(){return"BeforeCommandExecute"}};u(g,"_instance");let m=g;var I=Object.getOwnPropertyDescriptor,x=(a,t,e,i)=>{for(var r=i>1?void 0:i?I(t,e):t,s=a.length-1,o;s>=0;s--)(o=a[s])&&(r=o(r)||r);return r},w=(a,t)=>(e,i)=>t(e,i,a);c.FHooks=class extends v{constructor(t,e){super(),this._injector=t,this._lifecycleService=e}onStarting(t){return n.toDisposable(this._lifecycleService.lifecycle$.pipe(p.filter(e=>e===n.LifecycleStages.Starting)).subscribe(t))}onReady(t){return n.toDisposable(this._lifecycleService.lifecycle$.pipe(p.filter(e=>e===n.LifecycleStages.Ready)).subscribe(t))}onRendered(t){return n.toDisposable(this._lifecycleService.lifecycle$.pipe(p.filter(e=>e===n.LifecycleStages.Rendered)).subscribe(t))}onSteady(t){return n.toDisposable(this._lifecycleService.lifecycle$.pipe(p.filter(e=>e===n.LifecycleStages.Steady)).subscribe(t))}onBeforeUndo(t){return this._injector.get(n.ICommandService).beforeCommandExecuted(i=>{if(i.id===n.UndoCommand.id){const s=this._injector.get(n.IUndoRedoService).pitchTopUndoElement();s&&t(s)}})}onUndo(t){return this._injector.get(n.ICommandService).onCommandExecuted(i=>{if(i.id===n.UndoCommand.id){const s=this._injector.get(n.IUndoRedoService).pitchTopUndoElement();s&&t(s)}})}onBeforeRedo(t){return this._injector.get(n.ICommandService).beforeCommandExecuted(i=>{if(i.id===n.RedoCommand.id){const s=this._injector.get(n.IUndoRedoService).pitchTopRedoElement();s&&t(s)}})}onRedo(t){return this._injector.get(n.ICommandService).onCommandExecuted(i=>{if(i.id===n.RedoCommand.id){const s=this._injector.get(n.IUndoRedoService).pitchTopRedoElement();s&&t(s)}})}},c.FHooks=x([w(0,n.Inject(n.Injector)),w(1,n.Inject(n.LifecycleService))],c.FHooks);var H=Object.getOwnPropertyDescriptor,F=(a,t,e,i)=>{for(var r=i>1?void 0:i?H(t,e):t,s=a.length-1,o;s>=0;s--)(o=a[s])&&(r=o(r)||r);return r},M=(a,t)=>(e,i)=>t(e,i,a);let D=class extends R{constructor(a,t){super(t),this.doc=a}};D=F([M(1,n.Inject(n.Injector))],D);class V{constructor(){u(this,"_eventRegistry",new Map);u(this,"_eventHandlerMap",new Map);u(this,"_eventHandlerRegisted",new Map)}_ensureEventRegistry(t){return this._eventRegistry.has(t)||this._eventRegistry.set(t,new n.Registry),this._eventRegistry.get(t)}registerEventHandler(t,e){const i=this._eventHandlerMap.get(t);return i?i.add(e):this._eventHandlerMap.set(t,new Set([e])),this._ensureEventRegistry(t).getData().length&&this._initEventHandler(t),n.toDisposable(()=>{var r,s,o,d;(r=this._eventHandlerMap.get(t))==null||r.delete(e),(o=(s=this._eventHandlerRegisted.get(t))==null?void 0:s.get(e))==null||o.dispose(),(d=this._eventHandlerRegisted.get(t))==null||d.delete(e)})}removeEvent(t,e){const i=this._ensureEventRegistry(t);if(i.delete(e),i.getData().length===0){const r=this._eventHandlerRegisted.get(t);r==null||r.forEach(s=>s.dispose()),this._eventHandlerRegisted.delete(t)}}_initEventHandler(t){let e=this._eventHandlerRegisted.get(t);const i=this._eventHandlerMap.get(t);i&&(e||(e=new Map,this._eventHandlerRegisted.set(t,e),i==null||i.forEach(r=>{e==null||e.set(r,n.toDisposable(r()))})))}addEvent(t,e){return this._ensureEventRegistry(t).add(e),this._initEventHandler(t),n.toDisposable(()=>this.removeEvent(t,e))}fireEvent(t,e){var i;return(i=this._eventRegistry.get(t))==null||i.getData().forEach(r=>{r(e)}),e.cancel}}var L=Object.getOwnPropertyDescriptor,$=(a,t,e,i)=>{for(var r=i>1?void 0:i?L(t,e):t,s=a.length-1,o;s>=0;s--)(o=a[s])&&(r=o(r)||r);return r},B=(a,t)=>(e,i)=>t(e,i,a);let T=class extends v{constructor(a,t){super(),this._injector=a,this._userManagerService=t}getCurrentUser(){return this._userManagerService.getCurrentUser()}};T=$([B(0,n.Inject(n.Injector)),B(1,n.Inject(n.UserManagerService))],T);const S=class S{static get(){if(this._instance)return this._instance;const t=new S;return this._instance=t,t}static extend(t){Object.getOwnPropertyNames(t.prototype).forEach(e=>{e!=="constructor"&&(this.prototype[e]=t.prototype[e])}),Object.getOwnPropertyNames(t).forEach(e=>{e!=="prototype"&&e!=="name"&&e!=="length"&&(this[e]=t[e])})}get rectangle(){return n.Rectangle}get numfmt(){return n.numfmt}get tools(){return n.Tools}};u(S,"_instance");let _=S;var z=Object.getOwnPropertyDescriptor,N=(a,t,e,i)=>{for(var r=i>1?void 0:i?z(t,e):t,s=a.length-1,o;s>=0;s--)(o=a[s])&&(r=o(r)||r);return r},E=(a,t)=>(e,i)=>t(e,i,a);const j=Symbol("initializers");c.FUniver=class extends n.Disposable{constructor(e,i,r,s){super();u(this,"_eventRegistry",new V);u(this,"registerEventHandler",(e,i)=>this._eventRegistry.registerEventHandler(e,i));this._injector=e,this._commandService=i,this._univerInstanceService=r,this._lifecycleService=s,this.registerEventHandler(this.Event.LifeCycleChanged,()=>n.toDisposable(this._lifecycleService.lifecycle$.subscribe(d=>{this.fireEvent(this.Event.LifeCycleChanged,{stage:d})}))),this._initUnitEvent(this._injector),this._initBeforeCommandEvent(this._injector),this._initCommandEvent(this._injector),this._injector.onDispose(()=>{this.dispose()});const o=Object.getPrototypeOf(this)[j];if(o){const d=this;o.forEach(function(h){h.apply(d,[e])})}}static newAPI(e){return(e instanceof n.Univer?e.__getInjector():e).createInstance(c.FUniver)}_initialize(e){}static extend(e){Object.getOwnPropertyNames(e.prototype).forEach(i=>{if(i==="_initialize"){let r=this.prototype[j];r||(r=[],this.prototype[j]=r),r.push(e.prototype._initialize)}else i!=="constructor"&&(this.prototype[i]=e.prototype[i])}),Object.getOwnPropertyNames(e).forEach(i=>{i!=="prototype"&&i!=="name"&&i!=="length"&&(this[i]=e[i])})}_initCommandEvent(e){const i=e.get(n.ICommandService);this.registerEventHandler(this.Event.Redo,()=>i.onCommandExecuted(r=>{const{id:s,type:o,params:d}=r;if(r.id===n.RedoCommand.id){const l={id:s,type:o,params:d};this.fireEvent(this.Event.Redo,l)}})),this.registerEventHandler(this.Event.Undo,()=>i.onCommandExecuted(r=>{const{id:s,type:o,params:d}=r;if(r.id===n.UndoCommand.id){const l={id:s,type:o,params:d};this.fireEvent(this.Event.Undo,l)}})),this.registerEventHandler(this.Event.CommandExecuted,()=>i.onCommandExecuted((r,s)=>{const{id:o,type:d,params:h}=r;if(r.id!==n.RedoCommand.id&&r.id!==n.UndoCommand.id){const b={id:o,type:d,params:h,options:s};this.fireEvent(this.Event.CommandExecuted,b)}}))}_initBeforeCommandEvent(e){const i=e.get(n.ICommandService);this.registerEventHandler(this.Event.BeforeRedo,()=>i.beforeCommandExecuted(r=>{const{id:s,type:o,params:d}=r;if(r.id===n.RedoCommand.id){const l={id:s,type:o,params:d};if(this.fireEvent(this.Event.BeforeRedo,l),l.cancel)throw new n.CanceledError}})),this.registerEventHandler(this.Event.BeforeUndo,()=>i.beforeCommandExecuted(r=>{const{id:s,type:o,params:d}=r;if(r.id===n.UndoCommand.id){const l={id:s,type:o,params:d};if(this.fireEvent(this.Event.BeforeUndo,l),l.cancel)throw new n.CanceledError}})),this.registerEventHandler(this.Event.BeforeCommandExecute,()=>i.beforeCommandExecuted((r,s)=>{const{id:o,type:d,params:h}=r;if(r.id!==n.RedoCommand.id&&r.id!==n.UndoCommand.id){const b={id:o,type:d,params:h,options:s};if(this.fireEvent(this.Event.BeforeCommandExecute,b),b.cancel)throw new n.CanceledError}}))}_initUnitEvent(e){const i=e.get(n.IUniverInstanceService);this.registerEventHandler(this.Event.DocDisposed,()=>i.unitDisposed$.subscribe(r=>{r.type===n.UniverInstanceType.UNIVER_DOC&&this.fireEvent(this.Event.DocDisposed,{unitId:r.getUnitId(),unitType:r.type,snapshot:r.getSnapshot()})})),this.registerEventHandler(this.Event.DocCreated,()=>i.unitAdded$.subscribe(r=>{if(r.type===n.UniverInstanceType.UNIVER_DOC){const s=r,o=e.createInstance(D,s);this.fireEvent(this.Event.DocCreated,{unitId:r.getUnitId(),type:r.type,doc:o,unit:o})}}))}disposeUnit(e){return this._univerInstanceService.disposeUnit(e)}getCurrentLifecycleStage(){return this._injector.get(n.LifecycleService).stage}undo(){return this._commandService.executeCommand(n.UndoCommand.id)}redo(){return this._commandService.executeCommand(n.RedoCommand.id)}toggleDarkMode(e){this._injector.get(n.ThemeService).setDarkMode(e)}loadLocales(e,i){this._injector.get(n.LocaleService).load({[e]:i})}setLocale(e){this._injector.get(n.LocaleService).setLocale(e)}onBeforeCommandExecute(e){return this._commandService.beforeCommandExecuted((i,r)=>{e(i,r)})}onCommandExecuted(e){return this._commandService.onCommandExecuted((i,r)=>{e(i,r)})}executeCommand(e,i,r){return this._commandService.executeCommand(e,i,r)}syncExecuteCommand(e,i,r){return this._commandService.syncExecuteCommand(e,i,r)}getHooks(){return this._injector.createInstance(c.FHooks)}get Enum(){return f.get()}get Event(){return m.get()}get Util(){return _.get()}addEvent(e,i){if(!e||!i)throw new Error("Cannot add empty event");return this._eventRegistry.addEvent(e,i)}fireEvent(e,i){return this._eventRegistry.fireEvent(e,i)}getUserManager(){return this._injector.createInstance(T)}newBlob(){return this._injector.createInstance(c.FBlob)}newColor(){return new n.ColorBuilder}newRichText(e){return n.RichTextBuilder.create(e)}newRichTextValue(e){return n.RichTextValue.create(e)}newParagraphStyle(e){return n.ParagraphStyleBuilder.create(e)}newParagraphStyleValue(e){return n.ParagraphStyleValue.create(e)}newTextStyle(e){return n.TextStyleBuilder.create(e)}newTextStyleValue(e){return n.TextStyleValue.create(e)}newTextDecoration(e){return new n.TextDecorationBuilder(e)}},c.FUniver=N([E(0,n.Inject(n.Injector)),E(1,n.ICommandService),E(2,n.IUniverInstanceService),E(3,n.Inject(n.LifecycleService))],c.FUniver),c.FBase=v,c.FBaseInitialable=R,c.FEnum=f,c.FEventName=m,c.FUtil=_,Object.defineProperty(c,Symbol.toStringTag,{value:"Module"})});