@univerjs/sheets-drawing-ui 0.4.2 → 0.5.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/es/index.js CHANGED
@@ -1,1185 +1,1217 @@
1
- var __defProp = Object.defineProperty;
2
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value;
3
- var __name = (target, value) => __defProp(target, "name", { value, configurable: !0 });
4
- var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key != "symbol" ? key + "" : key, value);
5
- import { CommandType, ICommandService, IUndoRedoService, LocaleService, IUniverInstanceService, useDependency, Inject, Injector, IContextService, RxDisposable, UniverInstanceType, connectInjector, toDisposable, FOCUSING_COMMON_DRAWINGS, Disposable, Direction, FOCUSING_FX_BAR_EDITOR, EDITOR_ACTIVATED, Tools, UserManagerService, IPermissionService, Rectangle, LifecycleService, LifecycleStages, DisposableCollection, fromEventSubject, generateRandomId, DependentOn, Plugin, registerDependencies, touchDependencies, IConfigService } from "@univerjs/core";
6
- import { IDrawingManagerService, IImageIoService, DrawingTypeEnum, ArrangeTypeEnum, DRAWING_IMAGE_ALLOW_IMAGE_LIST, DRAWING_IMAGE_COUNT_LIMIT, ImageUploadStatusType, DRAWING_IMAGE_ALLOW_SIZE, getImageSize, DRAWING_IMAGE_WIDTH_LIMIT, DRAWING_IMAGE_HEIGHT_LIMIT, getDrawingShapeKeyByDrawingSearch, UniverDrawingPlugin } from "@univerjs/drawing";
7
- import { ImageCropperObject, COMPONENT_IMAGE_POPUP_MENU, OpenImageCropOperation, ImageResetSizeOperation, DrawingCommonPanel, DrawingRenderService, UniverDrawingUIPlugin } from "@univerjs/drawing-ui";
8
- import { IRenderManagerService, precisionTo, getGroupState, transformObjectOutOfGroup, RENDER_CLASS_TYPE, Rect, ObjectType, DRAWING_OBJECT_LAYER_INDEX, SHEET_VIEWPORT_KEY } from "@univerjs/engine-render";
9
- import { ISheetDrawingService, SetDrawingApplyMutation, DrawingApplyType, SheetDrawingAnchorType, UniverSheetsDrawingPlugin } from "@univerjs/sheets-drawing";
10
- import { SheetCanvasPopManagerService, attachRangeWithCoord, ISheetSelectionRenderService, SheetSkeletonManagerService, getCurrentRangeDisable$, COPY_TYPE, PREDEFINED_HOOK_NAME, virtualizeDiscreteRanges, ISheetClipboardService, SheetPrintInterceptorService, VIEWPORT_KEY, SetZoomRatioOperation } from "@univerjs/sheets-ui";
11
- import { ISidebarService, IUIPartsService, BuiltInUIPart, ILocalFileService, IMessageService, MenuItemType, getMenuHiddenObservable, RibbonStartGroup, KeyCode, ComponentManager, IMenuManagerService, IShortcutService, CanvasFloatDomService } from "@univerjs/ui";
12
- import { takeUntil, combineLatest, map, filter, distinctUntilChanged, Subject, take, BehaviorSubject, switchMap } from "rxjs";
13
- import { getSheetCommandTarget, SheetsSelectionsService, WorkbookEditablePermission, WorksheetEditPermission, RangeProtectionPermissionEditPoint, WorkbookViewPermission, WorksheetViewPermission, InsertRowCommand, InsertColCommand, RemoveRowCommand, RemoveColCommand, DeleteRangeMoveLeftCommand, DeleteRangeMoveUpCommand, InsertRangeMoveDownCommand, InsertRangeMoveRightCommand, DeltaRowHeightCommand, SetRowHeightCommand, DeltaColumnWidthCommand, SetColWidthCommand, SetRowHiddenCommand, SetSpecificRowsVisibleCommand, SetSpecificColsVisibleCommand, SetColHiddenCommand, MoveColsCommand, MoveRowsCommand, MoveRangeCommand, SetRowVisibleMutation, SetRowHiddenMutation, SetColVisibleMutation, SetColHiddenMutation, SetWorksheetRowHeightMutation, SetWorksheetColWidthMutation, SheetInterceptorService, SetWorksheetActiveOperation, SetFrozenMutation } from "@univerjs/sheets";
14
- import React, { useEffect, forwardRef, useRef, createElement, useState } from "react";
15
- import { MessageType, RadioGroup, Radio } from "@univerjs/design";
16
- const PLUGIN_CONFIG_KEY = "sheets-drawing-ui.config", defaultPluginConfig = {}, ClearSheetDrawingTransformerOperation = {
1
+ var mn = Object.defineProperty;
2
+ var fn = (i, e, n) => e in i ? mn(i, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : i[e] = n;
3
+ var V = (i, e, n) => fn(i, typeof e != "symbol" ? e + "" : e, n);
4
+ import { CommandType as H, ICommandService as B, IUndoRedoService as ue, sequenceExecute as It, LocaleService as Be, IUniverInstanceService as fe, useDependency as ae, Inject as W, Injector as Rt, IContextService as Dt, RxDisposable as pn, UniverInstanceType as Y, connectInjector as wn, toDisposable as _n, FOCUSING_COMMON_DRAWINGS as me, Disposable as ie, Direction as te, FOCUSING_FX_BAR_EDITOR as vn, EDITOR_ACTIVATED as Sn, FOCUSING_PANEL_EDITOR as Cn, Tools as ge, UserManagerService as In, IPermissionService as Rn, Rectangle as Dn, LifecycleService as Mn, LifecycleStages as bn, DisposableCollection as yn, fromEventSubject as On, generateRandomId as Tn, DependentOn as Pn, Plugin as En, registerDependencies as Un, touchDependencies as Xe, IConfigService as An } from "@univerjs/core";
5
+ import { IDrawingManagerService as K, IImageIoService as Mt, DrawingTypeEnum as k, ArrangeTypeEnum as ve, DRAWING_IMAGE_ALLOW_IMAGE_LIST as Nn, DRAWING_IMAGE_COUNT_LIMIT as mt, ImageUploadStatusType as He, DRAWING_IMAGE_ALLOW_SIZE as jn, getImageSize as Wn, DRAWING_IMAGE_WIDTH_LIMIT as ft, DRAWING_IMAGE_HEIGHT_LIMIT as pt, getDrawingShapeKeyByDrawingSearch as ze, UniverDrawingPlugin as xn } from "@univerjs/drawing";
6
+ import { ImageCropperObject as $n, COMPONENT_IMAGE_POPUP_MENU as Ln, OpenImageCropOperation as Bn, ImageResetSizeOperation as Gn, DrawingCommonPanel as Vn, DrawingRenderService as kn, UniverDrawingUIPlugin as Yn } from "@univerjs/drawing-ui";
7
+ import { IRenderManagerService as J, precisionTo as ne, getGroupState as Fn, transformObjectOutOfGroup as Xn, RENDER_CLASS_TYPE as de, Rect as wt, ObjectType as Hn, DRAWING_OBJECT_LAYER_INDEX as zn, SHEET_VIEWPORT_KEY as Kn } from "@univerjs/engine-render";
8
+ import { ISheetDrawingService as F, SetDrawingApplyMutation as T, DrawingApplyType as P, SheetDrawingAnchorType as y, UniverSheetsDrawingPlugin as Jn } from "@univerjs/sheets-drawing";
9
+ import { SheetCanvasPopManagerService as Zn, attachRangeWithCoord as Pe, ISheetSelectionRenderService as pe, SheetSkeletonManagerService as q, getCurrentRangeDisable$ as qn, COPY_TYPE as _t, PREDEFINED_HOOK_NAME as Se, virtualizeDiscreteRanges as Qn, ISheetClipboardService as er, SheetPrintInterceptorService as tr, VIEWPORT_KEY as nr, SetZoomRatioOperation as rr } from "@univerjs/sheets-ui";
10
+ import { ISidebarService as ir, IUIPartsService as sr, BuiltInUIPart as or, ILocalFileService as ar, IMessageService as cr, MenuItemType as bt, getMenuHiddenObservable as yt, RibbonStartGroup as dr, KeyCode as le, ComponentManager as lr, IMenuManagerService as ur, IShortcutService as hr, CanvasFloatDomService as gr } from "@univerjs/ui";
11
+ import { takeUntil as vt, combineLatest as Ce, map as Ee, filter as re, distinctUntilChanged as Ie, Subject as Ke, take as mr, BehaviorSubject as fr, switchMap as St } from "rxjs";
12
+ import { SheetInterceptorService as at, getSheetCommandTarget as ce, SheetsSelectionsService as pr, WorkbookEditablePermission as tt, WorksheetEditPermission as Te, RangeProtectionPermissionEditPoint as wr, WorkbookViewPermission as Ct, WorksheetViewPermission as Je, InsertRowCommand as Ot, InsertColCommand as Tt, RemoveRowCommand as Pt, RemoveColCommand as Et, DeleteRangeMoveLeftCommand as Ut, DeleteRangeMoveUpCommand as At, InsertRangeMoveDownCommand as Nt, InsertRangeMoveRightCommand as jt, DeltaRowHeightCommand as nt, SetRowHeightCommand as rt, DeltaColumnWidthCommand as Wt, SetColWidthCommand as xt, SetRowHiddenCommand as $t, SetSpecificRowsVisibleCommand as Lt, SetSpecificColsVisibleCommand as Bt, SetColHiddenCommand as Gt, MoveColsCommand as Vt, MoveRowsCommand as kt, MoveRangeCommand as Yt, SetRowVisibleMutation as _r, SetRowHiddenMutation as vr, SetColVisibleMutation as Sr, SetColHiddenMutation as Cr, SetWorksheetRowHeightMutation as Ir, SetWorksheetColWidthMutation as Rr, SetWorksheetActiveOperation as Dr, SetFrozenMutation as Mr } from "@univerjs/sheets";
13
+ import Ft, { useEffect as ct, forwardRef as Xt, useRef as br, createElement as Ht, useState as it } from "react";
14
+ import { MessageType as Re, RadioGroup as yr, Radio as Ze } from "@univerjs/design";
15
+ const Or = "sheets-drawing-ui.config", Tr = {}, j = {
17
16
  id: "sheet.operation.clear-drawing-transformer",
18
- type: CommandType.MUTATION,
19
- handler: /* @__PURE__ */ __name((accessor, params) => {
20
- const renderManagerService = accessor.get(IRenderManagerService);
21
- return params.forEach((unitId) => {
22
- var _a11, _b;
23
- (_b = (_a11 = renderManagerService.getRenderById(unitId)) == null ? void 0 : _a11.scene.getTransformer()) == null || _b.debounceRefreshControls();
17
+ type: H.MUTATION,
18
+ handler: (i, e) => {
19
+ const n = i.get(J);
20
+ return e.forEach((t) => {
21
+ var r, s;
22
+ (s = (r = n.getRenderById(t)) == null ? void 0 : r.scene.getTransformer()) == null || s.debounceRefreshControls();
24
23
  }), !0;
25
- }, "handler")
26
- }, RemoveSheetDrawingCommand = {
24
+ }
25
+ }, Ge = {
27
26
  id: "sheet.command.remove-sheet-image",
28
- type: CommandType.COMMAND,
29
- handler: /* @__PURE__ */ __name((accessor, params) => {
30
- const commandService = accessor.get(ICommandService), undoRedoService = accessor.get(IUndoRedoService), sheetDrawingService = accessor.get(ISheetDrawingService);
31
- if (!params) return !1;
32
- const { drawings } = params, unitIds = [];
33
- drawings.forEach((param) => {
34
- const { unitId: unitId2 } = param;
35
- unitIds.push(unitId2);
27
+ type: H.COMMAND,
28
+ handler: (i, e) => {
29
+ var S, v, R;
30
+ const n = i.get(B), t = i.get(ue), r = i.get(at), s = i.get(F);
31
+ if (!e) return !1;
32
+ const { drawings: o } = e, d = [];
33
+ o.forEach((_) => {
34
+ const { unitId: I } = _;
35
+ d.push(I);
36
36
  });
37
- const jsonOp = sheetDrawingService.getBatchRemoveOp(drawings), { unitId, subUnitId, undo, redo, objects } = jsonOp;
38
- return commandService.syncExecuteCommand(SetDrawingApplyMutation.id, { unitId, subUnitId, op: redo, objects, type: DrawingApplyType.REMOVE }) ? (undoRedoService.pushUndoRedo({
39
- unitID: unitId,
37
+ const l = s.getBatchRemoveOp(o), { unitId: g, subUnitId: c, undo: a, redo: h, objects: u } = l, m = r.onCommandExecute({ id: Ge.id, params: e }), f = { id: T.id, params: { unitId: g, subUnitId: c, op: h, objects: u, type: P.REMOVE } }, p = { id: T.id, params: { unitId: g, subUnitId: c, op: a, objects: u, type: P.INSERT } };
38
+ return It([...(S = m.preRedos) != null ? S : [], f, ...m.redos], n) ? (t.pushUndoRedo({
39
+ unitID: g,
40
40
  undoMutations: [
41
- { id: SetDrawingApplyMutation.id, params: { unitId, subUnitId, op: undo, objects, type: DrawingApplyType.INSERT } },
42
- { id: ClearSheetDrawingTransformerOperation.id, params: unitIds }
41
+ ...(v = m.preUndos) != null ? v : [],
42
+ p,
43
+ ...m.undos,
44
+ { id: j.id, params: d }
43
45
  ],
44
46
  redoMutations: [
45
- { id: SetDrawingApplyMutation.id, params: { unitId, subUnitId, op: redo, objects, type: DrawingApplyType.REMOVE } },
46
- { id: ClearSheetDrawingTransformerOperation.id, params: unitIds }
47
+ ...(R = m.preRedos) != null ? R : [],
48
+ f,
49
+ ...m.redos,
50
+ { id: j.id, params: d }
47
51
  ]
48
52
  }), !0) : !1;
49
- }, "handler")
50
- }, COMPONENT_SHEET_DRAWING_PANEL = "COMPONENT_SHEET_DRAWING_PANEL", SidebarSheetDrawingOperation = {
53
+ }
54
+ }, zt = "COMPONENT_SHEET_DRAWING_PANEL", Kt = {
51
55
  id: "sidebar.operation.sheet-image",
52
- type: CommandType.COMMAND,
53
- handler: /* @__PURE__ */ __name(async (accessor, params) => {
54
- const sidebarService = accessor.get(ISidebarService), localeService = accessor.get(LocaleService), univerInstanceService = accessor.get(IUniverInstanceService), drawingManagerService = accessor.get(IDrawingManagerService);
55
- if (!getSheetCommandTarget(univerInstanceService)) return !1;
56
- switch (params.value) {
56
+ type: H.COMMAND,
57
+ handler: async (i, e) => {
58
+ const n = i.get(ir), t = i.get(Be), r = i.get(fe), s = i.get(K);
59
+ if (!ce(r)) return !1;
60
+ switch (e.value) {
57
61
  case "open":
58
- sidebarService.open({
59
- header: { title: localeService.t("sheetImage.panel.title") },
60
- children: { label: COMPONENT_SHEET_DRAWING_PANEL },
61
- onClose: /* @__PURE__ */ __name(() => {
62
- drawingManagerService.focusDrawing(null);
63
- }, "onClose"),
62
+ n.open({
63
+ header: { title: t.t("sheetImage.panel.title") },
64
+ children: { label: zt },
65
+ onClose: () => {
66
+ s.focusDrawing(null);
67
+ },
64
68
  width: 360
65
69
  });
66
70
  break;
67
71
  case "close":
68
72
  default:
69
- sidebarService.close();
73
+ n.close();
70
74
  break;
71
75
  }
72
76
  return !0;
73
- }, "handler")
74
- }, EditSheetDrawingOperation = {
77
+ }
78
+ }, Jt = {
75
79
  id: "sheet.operation.edit-sheet-image",
76
- type: CommandType.OPERATION,
77
- handler: /* @__PURE__ */ __name((accessor, params) => {
78
- const drawingManagerService = accessor.get(IDrawingManagerService), commandService = accessor.get(ICommandService);
79
- return params == null ? !1 : (drawingManagerService.focusDrawing([params]), commandService.executeCommand(SidebarSheetDrawingOperation.id, { value: "open" }), !0);
80
- }, "handler")
81
- }, uploadLoading = "univer-upload-loading", uploadLoadingBody = "univer-upload-loading-body", uploadLoadingBodyAnimation = "univer-upload-loading-body-animation", univerCircleAnimation = "univer-UniverCircleAnimation", uploadLoadingBodyText = "univer-upload-loading-body-text", styles$1 = {
82
- uploadLoading,
83
- uploadLoadingBody,
84
- uploadLoadingBodyAnimation,
85
- univerCircleAnimation,
86
- uploadLoadingBodyText
87
- }, UploadLoading = /* @__PURE__ */ __name(() => {
88
- const imageIoService = useDependency(IImageIoService), localeService = useDependency(LocaleService), [remain, setRemain] = React.useState(0);
89
- return useEffect(() => {
90
- const sub = imageIoService.change$.subscribe((count) => {
91
- setRemain(count);
80
+ type: H.OPERATION,
81
+ handler: (i, e) => {
82
+ const n = i.get(K), t = i.get(B);
83
+ return e == null ? !1 : (n.focusDrawing([e]), t.executeCommand(Kt.id, { value: "open" }), !0);
84
+ }
85
+ };
86
+ var Zt = { exports: {} }, Ve = {};
87
+ /**
88
+ * @license React
89
+ * react-jsx-runtime.production.min.js
90
+ *
91
+ * Copyright (c) Facebook, Inc. and its affiliates.
92
+ *
93
+ * This source code is licensed under the MIT license found in the
94
+ * LICENSE file in the root directory of this source tree.
95
+ */
96
+ var Pr = Ft, Er = Symbol.for("react.element"), Ur = Symbol.for("react.fragment"), Ar = Object.prototype.hasOwnProperty, Nr = Pr.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, jr = { key: !0, ref: !0, __self: !0, __source: !0 };
97
+ function qt(i, e, n) {
98
+ var t, r = {}, s = null, o = null;
99
+ n !== void 0 && (s = "" + n), e.key !== void 0 && (s = "" + e.key), e.ref !== void 0 && (o = e.ref);
100
+ for (t in e) Ar.call(e, t) && !jr.hasOwnProperty(t) && (r[t] = e[t]);
101
+ if (i && i.defaultProps) for (t in e = i.defaultProps, e) r[t] === void 0 && (r[t] = e[t]);
102
+ return { $$typeof: Er, type: i, key: s, ref: o, props: r, _owner: Nr.current };
103
+ }
104
+ Ve.Fragment = Ur;
105
+ Ve.jsx = qt;
106
+ Ve.jsxs = qt;
107
+ Zt.exports = Ve;
108
+ var $ = Zt.exports;
109
+ const Wr = "univer-upload-loading", xr = "univer-upload-loading-body", $r = "univer-upload-loading-body-animation", Lr = "univer-UniverCircleAnimation", Br = "univer-upload-loading-body-text", De = {
110
+ uploadLoading: Wr,
111
+ uploadLoadingBody: xr,
112
+ uploadLoadingBodyAnimation: $r,
113
+ univerCircleAnimation: Lr,
114
+ uploadLoadingBodyText: Br
115
+ }, Gr = () => {
116
+ const i = ae(Mt), e = ae(Be), [n, t] = Ft.useState(0);
117
+ return ct(() => {
118
+ const r = i.change$.subscribe((s) => {
119
+ t(s);
92
120
  });
93
121
  return () => {
94
- sub.unsubscribe();
122
+ r.unsubscribe();
95
123
  };
96
- }, [imageIoService]), /* @__PURE__ */ React.createElement("div", { style: { display: remain > 0 ? "block" : "none" }, className: styles$1.uploadLoading }, /* @__PURE__ */ React.createElement("div", { className: styles$1.uploadLoadingBody }, /* @__PURE__ */ React.createElement("div", { className: styles$1.uploadLoadingBodyAnimation }), /* @__PURE__ */ React.createElement("div", { className: styles$1.uploadLoadingBodyText }, `${localeService.t("uploadLoading.loading")}: ${remain}`)));
97
- }, "UploadLoading");
98
- var __defProp$9 = Object.defineProperty, __getOwnPropDesc$9 = Object.getOwnPropertyDescriptor, __decorateClass$9 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
99
- for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$9(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
100
- (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
101
- return kind && result && __defProp$9(target, key, result), result;
102
- }, "__decorateClass$9"), __decorateParam$9 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$9"), _a;
103
- let DrawingPopupMenuController = (_a = class extends RxDisposable {
104
- constructor(_injector, _drawingManagerService, _canvasPopManagerService, _renderManagerService, _univerInstanceService, _contextService, _uiPartsService) {
124
+ }, [i]), /* @__PURE__ */ $.jsx("div", { style: { display: n > 0 ? "block" : "none" }, className: De.uploadLoading, children: /* @__PURE__ */ $.jsxs("div", { className: De.uploadLoadingBody, children: [
125
+ /* @__PURE__ */ $.jsx("div", { className: De.uploadLoadingBodyAnimation }),
126
+ /* @__PURE__ */ $.jsx("div", { className: De.uploadLoadingBodyText, children: `${e.t("uploadLoading.loading")}: ${n}` })
127
+ ] }) });
128
+ };
129
+ var Vr = Object.defineProperty, kr = Object.getOwnPropertyDescriptor, Yr = (i, e, n, t) => {
130
+ for (var r = t > 1 ? void 0 : t ? kr(e, n) : e, s = i.length - 1, o; s >= 0; s--)
131
+ (o = i[s]) && (r = (t ? o(e, n, r) : o(r)) || r);
132
+ return t && r && Vr(e, n, r), r;
133
+ }, se = (i, e) => (n, t) => e(n, t, i);
134
+ let Ue = class extends pn {
135
+ constructor(e, n, t, r, s, o, d) {
105
136
  super();
106
- __publicField(this, "_initImagePopupMenu", /* @__PURE__ */ new Set());
107
- this._injector = _injector, this._drawingManagerService = _drawingManagerService, this._canvasPopManagerService = _canvasPopManagerService, this._renderManagerService = _renderManagerService, this._univerInstanceService = _univerInstanceService, this._contextService = _contextService, this._uiPartsService = _uiPartsService, this._init();
137
+ V(this, "_initImagePopupMenu", /* @__PURE__ */ new Set());
138
+ this._injector = e, this._drawingManagerService = n, this._canvasPopManagerService = t, this._renderManagerService = r, this._univerInstanceService = s, this._contextService = o, this._uiPartsService = d, this._init();
108
139
  }
109
140
  _init() {
110
- this._univerInstanceService.getCurrentTypeOfUnit$(UniverInstanceType.UNIVER_SHEET).pipe(takeUntil(this.dispose$)).subscribe((workbook) => this._create(workbook)), this._univerInstanceService.getTypeOfUnitDisposed$(UniverInstanceType.UNIVER_SHEET).pipe(takeUntil(this.dispose$)).subscribe((workbook) => this._dispose(workbook)), this._univerInstanceService.getAllUnitsForType(UniverInstanceType.UNIVER_SHEET).forEach((workbook) => this._create(workbook)), this._uiPartsService.registerComponent(BuiltInUIPart.CONTENT, () => connectInjector(UploadLoading, this._injector));
141
+ this._univerInstanceService.getCurrentTypeOfUnit$(Y.UNIVER_SHEET).pipe(vt(this.dispose$)).subscribe((e) => this._create(e)), this._univerInstanceService.getTypeOfUnitDisposed$(Y.UNIVER_SHEET).pipe(vt(this.dispose$)).subscribe((e) => this._dispose(e)), this._univerInstanceService.getAllUnitsForType(Y.UNIVER_SHEET).forEach((e) => this._create(e)), this._uiPartsService.registerComponent(or.CONTENT, () => wn(Gr, this._injector));
111
142
  }
112
- _dispose(workbook) {
113
- const unitId = workbook.getUnitId();
114
- this._renderManagerService.removeRender(unitId);
143
+ _dispose(e) {
144
+ const n = e.getUnitId();
145
+ this._renderManagerService.removeRender(n);
115
146
  }
116
- _create(workbook) {
117
- if (!workbook)
147
+ _create(e) {
148
+ if (!e)
118
149
  return;
119
- const unitId = workbook.getUnitId();
120
- this._renderManagerService.has(unitId) && !this._initImagePopupMenu.has(unitId) && (this._popupMenuListener(unitId), this._initImagePopupMenu.add(unitId));
150
+ const n = e.getUnitId();
151
+ this._renderManagerService.has(n) && !this._initImagePopupMenu.has(n) && (this._popupMenuListener(n), this._initImagePopupMenu.add(n));
121
152
  }
122
- _hasCropObject(scene) {
123
- const objects = scene.getAllObjectsByOrder();
124
- for (const object of objects)
125
- if (object instanceof ImageCropperObject)
153
+ _hasCropObject(e) {
154
+ const n = e.getAllObjectsByOrder();
155
+ for (const t of n)
156
+ if (t instanceof $n)
126
157
  return !0;
127
158
  return !1;
128
159
  }
129
- _popupMenuListener(unitId) {
130
- var _a11;
131
- const scene = (_a11 = this._renderManagerService.getRenderById(unitId)) == null ? void 0 : _a11.scene;
132
- if (!scene)
160
+ _popupMenuListener(e) {
161
+ var s;
162
+ const n = (s = this._renderManagerService.getRenderById(e)) == null ? void 0 : s.scene;
163
+ if (!n)
133
164
  return;
134
- const transformer = scene.getTransformerByCreate();
135
- if (!transformer)
165
+ const t = n.getTransformerByCreate();
166
+ if (!t)
136
167
  return;
137
- let singletonPopupDisposer;
168
+ let r;
138
169
  this.disposeWithMe(
139
- toDisposable(
140
- transformer.createControl$.subscribe(() => {
141
- if (this._contextService.setContextValue(FOCUSING_COMMON_DRAWINGS, !0), this._hasCropObject(scene))
170
+ _n(
171
+ t.createControl$.subscribe(() => {
172
+ if (this._contextService.setContextValue(me, !0), this._hasCropObject(n))
142
173
  return;
143
- const selectedObjects = transformer.getSelectedObjectMap();
144
- if (selectedObjects.size > 1) {
145
- singletonPopupDisposer == null || singletonPopupDisposer.dispose();
174
+ const o = t.getSelectedObjectMap();
175
+ if (o.size > 1) {
176
+ r == null || r.dispose();
146
177
  return;
147
178
  }
148
- const object = selectedObjects.values().next().value;
149
- if (!object)
179
+ const d = o.values().next().value;
180
+ if (!d)
150
181
  return;
151
- const oKey = object.oKey, drawingParam = this._drawingManagerService.getDrawingOKey(oKey);
152
- if (!drawingParam)
182
+ const l = d.oKey, g = this._drawingManagerService.getDrawingOKey(l);
183
+ if (!g)
153
184
  return;
154
- const { unitId: unitId2, subUnitId, drawingId, drawingType } = drawingParam;
155
- singletonPopupDisposer == null || singletonPopupDisposer.dispose(), singletonPopupDisposer = this.disposeWithMe(this._canvasPopManagerService.attachPopupToObject(object, {
156
- componentKey: COMPONENT_IMAGE_POPUP_MENU,
185
+ const { unitId: c, subUnitId: a, drawingId: h, drawingType: u } = g, m = g.data;
186
+ m && m.disablePopup || (r == null || r.dispose(), r = this.disposeWithMe(this._canvasPopManagerService.attachPopupToObject(d, {
187
+ componentKey: Ln,
157
188
  direction: "horizontal",
158
189
  offset: [2, 0],
159
190
  extraProps: {
160
- menuItems: this._getImageMenuItems(unitId2, subUnitId, drawingId, drawingType)
191
+ menuItems: this._getImageMenuItems(c, a, h, u)
161
192
  }
162
193
  })), this._drawingManagerService.focusDrawing([{
163
- unitId: unitId2,
164
- subUnitId,
165
- drawingId
166
- }]);
194
+ unitId: c,
195
+ subUnitId: a,
196
+ drawingId: h
197
+ }]));
167
198
  })
168
199
  )
169
200
  ), this.disposeWithMe(
170
- transformer.clearControl$.subscribe(() => {
171
- singletonPopupDisposer == null || singletonPopupDisposer.dispose(), this._contextService.setContextValue(FOCUSING_COMMON_DRAWINGS, !1), this._drawingManagerService.focusDrawing(null);
201
+ t.clearControl$.subscribe(() => {
202
+ r == null || r.dispose(), this._contextService.setContextValue(me, !1), this._drawingManagerService.focusDrawing(null);
172
203
  })
173
204
  ), this.disposeWithMe(
174
- transformer.changing$.subscribe(() => {
175
- singletonPopupDisposer == null || singletonPopupDisposer.dispose();
205
+ t.changing$.subscribe(() => {
206
+ r == null || r.dispose();
176
207
  })
177
208
  );
178
209
  }
179
- _getImageMenuItems(unitId, subUnitId, drawingId, drawingType) {
210
+ _getImageMenuItems(e, n, t, r) {
180
211
  return [
181
212
  {
182
213
  label: "image-popup.edit",
183
214
  index: 0,
184
- commandId: EditSheetDrawingOperation.id,
185
- commandParams: { unitId, subUnitId, drawingId },
186
- disable: drawingType === DrawingTypeEnum.DRAWING_DOM
215
+ commandId: Jt.id,
216
+ commandParams: { unitId: e, subUnitId: n, drawingId: t },
217
+ disable: r === k.DRAWING_DOM
187
218
  },
188
219
  {
189
220
  label: "image-popup.delete",
190
221
  index: 1,
191
- commandId: RemoveSheetDrawingCommand.id,
192
- commandParams: { unitId, drawings: [{ unitId, subUnitId, drawingId }] },
222
+ commandId: Ge.id,
223
+ commandParams: { unitId: e, drawings: [{ unitId: e, subUnitId: n, drawingId: t }] },
193
224
  disable: !1
194
225
  },
195
226
  {
196
227
  label: "image-popup.crop",
197
228
  index: 2,
198
- commandId: OpenImageCropOperation.id,
199
- commandParams: { unitId, subUnitId, drawingId },
200
- disable: drawingType === DrawingTypeEnum.DRAWING_DOM
229
+ commandId: Bn.id,
230
+ commandParams: { unitId: e, subUnitId: n, drawingId: t },
231
+ disable: r === k.DRAWING_DOM
201
232
  },
202
233
  {
203
234
  label: "image-popup.reset",
204
235
  index: 3,
205
- commandId: ImageResetSizeOperation.id,
206
- commandParams: [{ unitId, subUnitId, drawingId }],
207
- disable: drawingType === DrawingTypeEnum.DRAWING_DOM
236
+ commandId: Gn.id,
237
+ commandParams: [{ unitId: e, subUnitId: n, drawingId: t }],
238
+ disable: r === k.DRAWING_DOM
208
239
  }
209
240
  ];
210
241
  }
211
- }, __name(_a, "DrawingPopupMenuController"), _a);
212
- DrawingPopupMenuController = __decorateClass$9([
213
- __decorateParam$9(0, Inject(Injector)),
214
- __decorateParam$9(1, IDrawingManagerService),
215
- __decorateParam$9(2, Inject(SheetCanvasPopManagerService)),
216
- __decorateParam$9(3, IRenderManagerService),
217
- __decorateParam$9(4, IUniverInstanceService),
218
- __decorateParam$9(5, IContextService),
219
- __decorateParam$9(6, Inject(IUIPartsService))
220
- ], DrawingPopupMenuController);
221
- function drawingPositionToTransform(position, selectionRenderService, sheetSkeletonManagerService) {
222
- const { from, to, flipY = !1, flipX = !1, angle = 0, skewX = 0, skewY = 0 } = position, { column: fromColumn, columnOffset: fromColumnOffset, row: fromRow, rowOffset: fromRowOffset } = from, { column: toColumn, columnOffset: toColumnOffset, row: toRow, rowOffset: toRowOffset } = to, skeleton = sheetSkeletonManagerService.getCurrentSkeleton(), startSelectionCell = attachRangeWithCoord(skeleton, {
223
- startColumn: fromColumn,
224
- endColumn: fromColumn,
225
- startRow: fromRow,
226
- endRow: fromRow
242
+ };
243
+ Ue = Yr([
244
+ se(0, W(Rt)),
245
+ se(1, K),
246
+ se(2, W(Zn)),
247
+ se(3, J),
248
+ se(4, fe),
249
+ se(5, Dt),
250
+ se(6, W(sr))
251
+ ], Ue);
252
+ function L(i, e, n) {
253
+ const { from: t, to: r, flipY: s = !1, flipX: o = !1, angle: d = 0, skewX: l = 0, skewY: g = 0 } = i, { column: c, columnOffset: a, row: h, rowOffset: u } = t, { column: m, columnOffset: f, row: p, rowOffset: C } = r, S = n.getCurrentSkeleton(), v = Pe(S, {
254
+ startColumn: c,
255
+ endColumn: c,
256
+ startRow: h,
257
+ endRow: h
227
258
  });
228
- if (startSelectionCell == null)
259
+ if (v == null)
229
260
  return;
230
- const endSelectionCell = attachRangeWithCoord(skeleton, {
231
- startColumn: toColumn,
232
- endColumn: toColumn,
233
- startRow: toRow,
234
- endRow: toRow
261
+ const R = Pe(S, {
262
+ startColumn: m,
263
+ endColumn: m,
264
+ startRow: p,
265
+ endRow: p
235
266
  });
236
- if (endSelectionCell == null)
267
+ if (R == null)
237
268
  return;
238
- const { startX: startSelectionX, startY: startSelectionY } = startSelectionCell, { startX: endSelectionX, startY: endSelectionY } = endSelectionCell;
239
- let left = precisionTo(startSelectionX + fromColumnOffset, 1), top = precisionTo(startSelectionY + fromRowOffset, 1), width = precisionTo(endSelectionX + toColumnOffset - left, 1), height = precisionTo(endSelectionY + toRowOffset - top, 1);
240
- startSelectionCell.startX === endSelectionCell.endX && (width = 0), startSelectionCell.startY === endSelectionCell.endY && (height = 0);
241
- const sheetWidth = skeleton.rowHeaderWidth + skeleton.columnTotalWidth, sheetHeight = skeleton.columnHeaderHeight + skeleton.rowTotalHeight;
242
- return left + width > sheetWidth && (left = sheetWidth - width), top + height > sheetHeight && (top = sheetHeight - height), {
243
- flipY,
244
- flipX,
245
- angle,
246
- skewX,
247
- skewY,
248
- left,
249
- top,
250
- width,
251
- height
269
+ const { startX: _, startY: I } = v, { startX: w, startY: O } = R;
270
+ let b = ne(_ + a, 1), A = ne(I + u, 1), E = ne(w + f - b, 1), M = ne(O + C - A, 1);
271
+ v.startX === R.endX && (E = 0), v.startY === R.endY && (M = 0);
272
+ const D = S.rowHeaderWidth + S.columnTotalWidth, U = S.columnHeaderHeight + S.rowTotalHeight;
273
+ return b + E > D && (b = D - E), A + M > U && (A = U - M), {
274
+ flipY: s,
275
+ flipX: o,
276
+ angle: d,
277
+ skewX: l,
278
+ skewY: g,
279
+ left: b,
280
+ top: A,
281
+ width: E,
282
+ height: M
252
283
  };
253
284
  }
254
- __name(drawingPositionToTransform, "drawingPositionToTransform");
255
- function transformToDrawingPosition(transform, selectionRenderService) {
256
- const { left = 0, top = 0, width = 0, height = 0, flipY = !1, flipX = !1, angle = 0, skewX = 0, skewY = 0 } = transform, startSelectionCell = selectionRenderService.getSelectionCellByPosition(left, top);
257
- if (startSelectionCell == null)
285
+ function N(i, e) {
286
+ const { left: n = 0, top: t = 0, width: r = 0, height: s = 0, flipY: o = !1, flipX: d = !1, angle: l = 0, skewX: g = 0, skewY: c = 0 } = i, a = e.getCellWithCoordByOffset(n, t);
287
+ if (a == null)
258
288
  return;
259
- const from = {
260
- column: startSelectionCell.actualColumn,
261
- columnOffset: precisionTo(left - startSelectionCell.startX, 1),
262
- row: startSelectionCell.actualRow,
263
- rowOffset: precisionTo(top - startSelectionCell.startY, 1)
264
- }, endSelectionCell = selectionRenderService.getSelectionCellByPosition(left + width, top + height);
265
- if (endSelectionCell == null)
289
+ const h = {
290
+ column: a.actualColumn,
291
+ columnOffset: ne(n - a.startX, 1),
292
+ row: a.actualRow,
293
+ rowOffset: ne(t - a.startY, 1)
294
+ }, u = e.getCellWithCoordByOffset(n + r, t + s);
295
+ if (u == null)
266
296
  return;
267
- const to = {
268
- column: endSelectionCell.actualColumn,
269
- columnOffset: precisionTo(left + width - endSelectionCell.startX, 1),
270
- row: endSelectionCell.actualRow,
271
- rowOffset: precisionTo(top + height - endSelectionCell.startY, 1)
297
+ const m = {
298
+ column: u.actualColumn,
299
+ columnOffset: ne(n + r - u.startX, 1),
300
+ row: u.actualRow,
301
+ rowOffset: ne(t + s - u.startY, 1)
272
302
  };
273
303
  return {
274
- flipY,
275
- flipX,
276
- angle,
277
- skewX,
278
- skewY,
279
- from,
280
- to
304
+ flipY: o,
305
+ flipX: d,
306
+ angle: l,
307
+ skewX: g,
308
+ skewY: c,
309
+ from: h,
310
+ to: m
281
311
  };
282
312
  }
283
- __name(transformToDrawingPosition, "transformToDrawingPosition");
284
- var __defProp$8 = Object.defineProperty, __getOwnPropDesc$8 = Object.getOwnPropertyDescriptor, __decorateClass$8 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
285
- for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$8(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
286
- (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
287
- return kind && result && __defProp$8(target, key, result), result;
288
- }, "__decorateClass$8"), __decorateParam$8 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$8"), _a2;
289
- let SheetsDrawingRenderController = (_a2 = class extends Disposable {
290
- constructor(_context, _sheetDrawingService, _drawingManagerService, _sheetSelectionRenderService, _sheetSkeletonManagerService) {
291
- super(), this._context = _context, this._sheetDrawingService = _sheetDrawingService, this._drawingManagerService = _drawingManagerService, this._sheetSelectionRenderService = _sheetSelectionRenderService, this._sheetSkeletonManagerService = _sheetSkeletonManagerService, this._init();
313
+ var Fr = Object.defineProperty, Xr = Object.getOwnPropertyDescriptor, Hr = (i, e, n, t) => {
314
+ for (var r = t > 1 ? void 0 : t ? Xr(e, n) : e, s = i.length - 1, o; s >= 0; s--)
315
+ (o = i[s]) && (r = (t ? o(e, n, r) : o(r)) || r);
316
+ return t && r && Fr(e, n, r), r;
317
+ }, Me = (i, e) => (n, t) => e(n, t, i);
318
+ let st = class extends ie {
319
+ constructor(i, e, n, t, r) {
320
+ super(), this._context = i, this._sheetDrawingService = e, this._drawingManagerService = n, this._sheetSelectionRenderService = t, this._sheetSkeletonManagerService = r, this._init();
292
321
  }
293
322
  _init() {
294
323
  this._drawingInitializeListener();
295
324
  }
296
325
  _drawingInitializeListener() {
297
326
  this._sheetDrawingService.initializeNotification(this._context.unitId);
298
- const data = this._sheetDrawingService.getDrawingDataForUnit(this._context.unitId);
299
- for (const subUnit in data) {
300
- const subUnitData = data[subUnit];
301
- for (const drawingId in subUnitData.data) {
302
- const drawingData = subUnitData.data[drawingId];
303
- drawingData.transform = drawingPositionToTransform(drawingData.sheetTransform, this._sheetSelectionRenderService, this._sheetSkeletonManagerService);
327
+ const i = this._sheetDrawingService.getDrawingDataForUnit(this._context.unitId);
328
+ for (const e in i) {
329
+ const n = i[e];
330
+ for (const t in n.data) {
331
+ const r = n.data[t];
332
+ r.transform = L(r.sheetTransform, this._sheetSelectionRenderService, this._sheetSkeletonManagerService);
304
333
  }
305
334
  }
306
335
  this._drawingManagerService.registerDrawingData(this._context.unitId, this._sheetDrawingService.getDrawingDataForUnit(this._context.unitId)), this._drawingManagerService.initializeNotification(this._context.unitId);
307
336
  }
308
- }, __name(_a2, "SheetsDrawingRenderController"), _a2);
309
- SheetsDrawingRenderController = __decorateClass$8([
310
- __decorateParam$8(1, ISheetDrawingService),
311
- __decorateParam$8(2, IDrawingManagerService),
312
- __decorateParam$8(3, Inject(ISheetSelectionRenderService)),
313
- __decorateParam$8(4, Inject(SheetSkeletonManagerService))
314
- ], SheetsDrawingRenderController);
315
- var __assign = function() {
316
- return __assign = Object.assign || function(t) {
317
- for (var s, i = 1, n = arguments.length; i < n; i++) {
318
- s = arguments[i];
319
- for (var p in s) Object.prototype.hasOwnProperty.call(s, p) && (t[p] = s[p]);
337
+ };
338
+ st = Hr([
339
+ Me(1, F),
340
+ Me(2, K),
341
+ Me(3, W(pe)),
342
+ Me(4, W(q))
343
+ ], st);
344
+ var X = function() {
345
+ return X = Object.assign || function(i) {
346
+ for (var e, n = 1, t = arguments.length; n < t; n++) {
347
+ e = arguments[n];
348
+ for (var r in e) Object.prototype.hasOwnProperty.call(e, r) && (i[r] = e[r]);
320
349
  }
321
- return t;
322
- }, __assign.apply(this, arguments);
323
- }, __rest = function(s, e) {
324
- var t = {};
325
- for (var p in s) Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0 && (t[p] = s[p]);
326
- if (s != null && typeof Object.getOwnPropertySymbols == "function")
327
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++)
328
- e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]) && (t[p[i]] = s[p[i]]);
329
- return t;
330
- }, IconBase = forwardRef(function(props, ref) {
331
- var icon = props.icon, id = props.id, className = props.className, extend = props.extend, restProps = __rest(props, ["icon", "id", "className", "extend"]), cls = "univerjs-icon univerjs-icon-".concat(id, " ").concat(className || "").trim(), idSuffix = useRef("_".concat(generateShortUuid()));
332
- return render(icon, "".concat(id), { defIds: icon.defIds, idSuffix: idSuffix.current }, __assign({ ref, className: cls }, restProps), extend);
350
+ return i;
351
+ }, X.apply(this, arguments);
352
+ }, zr = function(i, e) {
353
+ var n = {};
354
+ for (var t in i) Object.prototype.hasOwnProperty.call(i, t) && e.indexOf(t) < 0 && (n[t] = i[t]);
355
+ if (i != null && typeof Object.getOwnPropertySymbols == "function")
356
+ for (var r = 0, t = Object.getOwnPropertySymbols(i); r < t.length; r++)
357
+ e.indexOf(t[r]) < 0 && Object.prototype.propertyIsEnumerable.call(i, t[r]) && (n[t[r]] = i[t[r]]);
358
+ return n;
359
+ }, Qt = Xt(function(i, e) {
360
+ var n = i.icon, t = i.id, r = i.className, s = i.extend, o = zr(i, ["icon", "id", "className", "extend"]), d = "univerjs-icon univerjs-icon-".concat(t, " ").concat(r || "").trim(), l = br("_".concat(Zr()));
361
+ return en(n, "".concat(t), { defIds: n.defIds, idSuffix: l.current }, X({ ref: e, className: d }, o), s);
333
362
  });
334
- function render(node, id, runtimeProps, rootProps, extend) {
335
- return createElement(node.tag, __assign(__assign({ key: id }, replaceRuntimeIdsAndExtInAttrs(node, runtimeProps, extend)), rootProps), (replaceRuntimeIdsInDefs(node, runtimeProps).children || []).map(function(child, index) {
336
- return render(child, "".concat(id, "-").concat(node.tag, "-").concat(index), runtimeProps, void 0, extend);
363
+ function en(i, e, n, t, r) {
364
+ return Ht(i.tag, X(X({ key: e }, Kr(i, n, r)), t), (Jr(i, n).children || []).map(function(s, o) {
365
+ return en(s, "".concat(e, "-").concat(i.tag, "-").concat(o), n, void 0, r);
337
366
  }));
338
367
  }
339
- __name(render, "render");
340
- function replaceRuntimeIdsAndExtInAttrs(node, runtimeProps, extend) {
341
- var attrs = __assign({}, node.attrs);
342
- extend != null && extend.colorChannel1 && attrs.fill === "colorChannel1" && (attrs.fill = extend.colorChannel1);
343
- var defIds = runtimeProps.defIds;
344
- return !defIds || defIds.length === 0 || (node.tag === "use" && attrs["xlink:href"] && (attrs["xlink:href"] = attrs["xlink:href"] + runtimeProps.idSuffix), Object.entries(attrs).forEach(function(_a11) {
345
- var key = _a11[0], value = _a11[1];
346
- typeof value == "string" && (attrs[key] = value.replace(/url\(#(.*)\)/, "url(#$1".concat(runtimeProps.idSuffix, ")")));
347
- })), attrs;
368
+ function Kr(i, e, n) {
369
+ var t = X({}, i.attrs);
370
+ n != null && n.colorChannel1 && t.fill === "colorChannel1" && (t.fill = n.colorChannel1);
371
+ var r = e.defIds;
372
+ return !r || r.length === 0 || (i.tag === "use" && t["xlink:href"] && (t["xlink:href"] = t["xlink:href"] + e.idSuffix), Object.entries(t).forEach(function(s) {
373
+ var o = s[0], d = s[1];
374
+ typeof d == "string" && (t[o] = d.replace(/url\(#(.*)\)/, "url(#$1".concat(e.idSuffix, ")")));
375
+ })), t;
348
376
  }
349
- __name(replaceRuntimeIdsAndExtInAttrs, "replaceRuntimeIdsAndExtInAttrs");
350
- function replaceRuntimeIdsInDefs(node, runtimeProps) {
351
- var _a11, defIds = runtimeProps.defIds;
352
- return !defIds || defIds.length === 0 ? node : node.tag === "defs" && (!((_a11 = node.children) === null || _a11 === void 0) && _a11.length) ? __assign(__assign({}, node), { children: node.children.map(function(child) {
353
- return typeof child.attrs.id == "string" && defIds && defIds.indexOf(child.attrs.id) > -1 ? __assign(__assign({}, child), { attrs: __assign(__assign({}, child.attrs), { id: child.attrs.id + runtimeProps.idSuffix }) }) : child;
354
- }) }) : node;
377
+ function Jr(i, e) {
378
+ var n, t = e.defIds;
379
+ return !t || t.length === 0 ? i : i.tag === "defs" && (!((n = i.children) === null || n === void 0) && n.length) ? X(X({}, i), { children: i.children.map(function(r) {
380
+ return typeof r.attrs.id == "string" && t && t.indexOf(r.attrs.id) > -1 ? X(X({}, r), { attrs: X(X({}, r.attrs), { id: r.attrs.id + e.idSuffix }) }) : r;
381
+ }) }) : i;
355
382
  }
356
- __name(replaceRuntimeIdsInDefs, "replaceRuntimeIdsInDefs");
357
- function generateShortUuid() {
383
+ function Zr() {
358
384
  return Math.random().toString(36).substring(2, 8);
359
385
  }
360
- __name(generateShortUuid, "generateShortUuid");
361
- IconBase.displayName = "UniverIcon";
362
- var element = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M2.2498 3.65005C2.2498 2.87685 2.87661 2.25005 3.64981 2.25005H7.9998C8.33118 2.25005 8.5998 1.98142 8.5998 1.65005C8.5998 1.31868 8.33118 1.05005 7.9998 1.05005H3.64981C2.21387 1.05005 1.0498 2.21411 1.0498 3.65005V12.35C1.0498 13.786 2.21386 14.95 3.6498 14.95H12.3498C13.7857 14.95 14.9498 13.786 14.9498 12.3501V8.00005C14.9498 7.66868 14.6812 7.40005 14.3498 7.40005C14.0184 7.40005 13.7498 7.66868 13.7498 8.00005V9.23974L12.2385 8.1063C11.7252 7.72129 11.0068 7.7723 10.5531 8.22605L9.00869 9.77041L6.73916 7.8251C6.24387 7.40055 5.5095 7.41278 5.02864 7.85359L2.2498 10.4009V3.65005ZM2.2498 12.0287V12.35C2.2498 13.1232 2.87661 13.75 3.6498 13.75H12.3498C13.123 13.75 13.7498 13.1232 13.7498 12.3501V10.7397L11.5186 9.06631C11.4829 9.03956 11.433 9.04314 11.4016 9.07458L9.92249 10.5537L11.1015 11.5642C11.3531 11.7799 11.3822 12.1587 11.1666 12.4103C10.9509 12.6619 10.5721 12.691 10.3205 12.4753L5.9582 8.7362C5.92384 8.70674 5.87288 8.70758 5.83952 8.73816L2.2498 12.0287Z", fillRule: "evenodd", clipRule: "evenodd" } }, { tag: "path", attrs: { fill: "currentColor", d: "M11.8097 1.14783C12.1411 1.14783 12.4097 1.41646 12.4097 1.74783V3.297H14.1541C14.4855 3.297 14.7541 3.56563 14.7541 3.897C14.7541 4.22837 14.4855 4.497 14.1541 4.497H12.4097V6.24167C12.4097 6.57304 12.1411 6.84167 11.8097 6.84167C11.4783 6.84167 11.2097 6.57304 11.2097 6.24167V4.497H9.6603C9.32893 4.497 9.0603 4.22837 9.0603 3.897C9.0603 3.56563 9.32893 3.297 9.6603 3.297H11.2097V1.74783C11.2097 1.41646 11.4783 1.14783 11.8097 1.14783Z" } }] }, AddImageSingle = forwardRef(function(props, ref) {
363
- return createElement(IconBase, Object.assign({}, props, {
386
+ Qt.displayName = "UniverIcon";
387
+ var qr = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M2.2498 3.65005C2.2498 2.87685 2.87661 2.25005 3.64981 2.25005H7.9998C8.33118 2.25005 8.5998 1.98142 8.5998 1.65005C8.5998 1.31868 8.33118 1.05005 7.9998 1.05005H3.64981C2.21387 1.05005 1.0498 2.21411 1.0498 3.65005V12.35C1.0498 13.786 2.21386 14.95 3.6498 14.95H12.3498C13.7857 14.95 14.9498 13.786 14.9498 12.3501V8.00005C14.9498 7.66868 14.6812 7.40005 14.3498 7.40005C14.0184 7.40005 13.7498 7.66868 13.7498 8.00005V9.23974L12.2385 8.1063C11.7252 7.72129 11.0068 7.7723 10.5531 8.22605L9.00869 9.77041L6.73916 7.8251C6.24387 7.40055 5.5095 7.41278 5.02864 7.85359L2.2498 10.4009V3.65005ZM2.2498 12.0287V12.35C2.2498 13.1232 2.87661 13.75 3.6498 13.75H12.3498C13.123 13.75 13.7498 13.1232 13.7498 12.3501V10.7397L11.5186 9.06631C11.4829 9.03956 11.433 9.04314 11.4016 9.07458L9.92249 10.5537L11.1015 11.5642C11.3531 11.7799 11.3822 12.1587 11.1666 12.4103C10.9509 12.6619 10.5721 12.691 10.3205 12.4753L5.9582 8.7362C5.92384 8.70674 5.87288 8.70758 5.83952 8.73816L2.2498 12.0287Z", fillRule: "evenodd", clipRule: "evenodd" } }, { tag: "path", attrs: { fill: "currentColor", d: "M11.8097 1.14783C12.1411 1.14783 12.4097 1.41646 12.4097 1.74783V3.297H14.1541C14.4855 3.297 14.7541 3.56563 14.7541 3.897C14.7541 4.22837 14.4855 4.497 14.1541 4.497H12.4097V6.24167C12.4097 6.57304 12.1411 6.84167 11.8097 6.84167C11.4783 6.84167 11.2097 6.57304 11.2097 6.24167V4.497H9.6603C9.32893 4.497 9.0603 4.22837 9.0603 3.897C9.0603 3.56563 9.32893 3.297 9.6603 3.297H11.2097V1.74783C11.2097 1.41646 11.4783 1.14783 11.8097 1.14783Z" } }] }, tn = Xt(function(i, e) {
388
+ return Ht(Qt, Object.assign({}, i, {
364
389
  id: "add-image-single",
365
- ref,
366
- icon: element
390
+ ref: e,
391
+ icon: qr
367
392
  }));
368
393
  });
369
- AddImageSingle.displayName = "AddImageSingle";
370
- const DeleteDrawingsCommand = {
394
+ tn.displayName = "AddImageSingle";
395
+ const nn = {
371
396
  id: "sheet.command.delete-drawing",
372
- type: CommandType.COMMAND,
373
- handler: /* @__PURE__ */ __name((accessor) => {
374
- const commandService = accessor.get(ICommandService), drawings = accessor.get(ISheetDrawingService).getFocusDrawings();
375
- if (drawings.length === 0)
397
+ type: H.COMMAND,
398
+ handler: (i) => {
399
+ const e = i.get(B), t = i.get(F).getFocusDrawings();
400
+ if (t.length === 0)
376
401
  return !1;
377
- const unitId = drawings[0].unitId, newDrawings = drawings.map((drawing) => {
378
- const { unitId: unitId2, subUnitId, drawingId, drawingType } = drawing;
402
+ const r = t[0].unitId, s = t.map((o) => {
403
+ const { unitId: d, subUnitId: l, drawingId: g, drawingType: c } = o;
379
404
  return {
380
- unitId: unitId2,
381
- subUnitId,
382
- drawingId,
383
- drawingType
405
+ unitId: d,
406
+ subUnitId: l,
407
+ drawingId: g,
408
+ drawingType: c
384
409
  };
385
410
  });
386
- return commandService.executeCommand(RemoveSheetDrawingCommand.id, {
387
- unitId,
388
- drawings: newDrawings
411
+ return e.executeCommand(Ge.id, {
412
+ unitId: r,
413
+ drawings: s
389
414
  });
390
- }, "handler")
415
+ }
391
416
  };
392
- function ungroupToGroup(ungroupParams) {
393
- const newGroupParams = [];
394
- return ungroupParams.forEach((ungroupParam) => {
395
- const { parent, children } = ungroupParam, { unitId, subUnitId, drawingId: groupId } = parent, groupTransform = getGroupState(0, 0, children.map((o) => o.transform || {})), newChildren = children.map((drawing) => {
396
- const transform = drawing.transform || { left: 0, top: 0 }, { unitId: unitId2, subUnitId: subUnitId2, drawingId } = drawing;
417
+ function Qr(i) {
418
+ const e = [];
419
+ return i.forEach((n) => {
420
+ const { parent: t, children: r } = n, { unitId: s, subUnitId: o, drawingId: d } = t, l = Fn(0, 0, r.map((a) => a.transform || {})), g = r.map((a) => {
421
+ const h = a.transform || { left: 0, top: 0 }, { unitId: u, subUnitId: m, drawingId: f } = a;
397
422
  return {
398
- unitId: unitId2,
399
- subUnitId: subUnitId2,
400
- drawingId,
423
+ unitId: u,
424
+ subUnitId: m,
425
+ drawingId: f,
401
426
  transform: {
402
- ...transform,
403
- left: transform.left - groupTransform.left,
404
- top: transform.top - groupTransform.top
427
+ ...h,
428
+ left: h.left - l.left,
429
+ top: h.top - l.top
405
430
  },
406
- groupId
431
+ groupId: d
407
432
  };
408
- }), groupParam = {
409
- unitId,
410
- subUnitId,
411
- drawingId: groupId,
412
- drawingType: DrawingTypeEnum.DRAWING_GROUP,
413
- transform: groupTransform
433
+ }), c = {
434
+ unitId: s,
435
+ subUnitId: o,
436
+ drawingId: d,
437
+ drawingType: k.DRAWING_GROUP,
438
+ transform: l
414
439
  };
415
- newGroupParams.push({
416
- parent: groupParam,
417
- children: newChildren
440
+ e.push({
441
+ parent: c,
442
+ children: g
418
443
  });
419
- }), newGroupParams;
444
+ }), e;
420
445
  }
421
- __name(ungroupToGroup, "ungroupToGroup");
422
- function groupToUngroup(groupParams) {
423
- const newGroupParams = [];
424
- return groupParams.forEach((groupParam) => {
425
- const { parent, children } = groupParam, { unitId, subUnitId, drawingId: groupId, transform: groupTransform = { width: 0, height: 0 } } = parent;
426
- if (groupTransform == null)
446
+ function ei(i) {
447
+ const e = [];
448
+ return i.forEach((n) => {
449
+ const { parent: t, children: r } = n, { unitId: s, subUnitId: o, drawingId: d, transform: l = { width: 0, height: 0 } } = t;
450
+ if (l == null)
427
451
  return;
428
- const newChildren = children.map((object) => {
429
- const { transform } = object, { unitId: unitId2, subUnitId: subUnitId2, drawingId } = object, newTransform = transformObjectOutOfGroup(transform || {}, groupTransform, groupTransform.width || 0, groupTransform.height || 0);
452
+ const g = r.map((a) => {
453
+ const { transform: h } = a, { unitId: u, subUnitId: m, drawingId: f } = a, p = Xn(h || {}, l, l.width || 0, l.height || 0);
430
454
  return {
431
- unitId: unitId2,
432
- subUnitId: subUnitId2,
433
- drawingId,
434
- transform: newTransform,
455
+ unitId: u,
456
+ subUnitId: m,
457
+ drawingId: f,
458
+ transform: p,
435
459
  groupId: void 0
436
460
  };
437
- }), ungroupParam = {
438
- unitId,
439
- subUnitId,
440
- drawingId: groupId,
441
- drawingType: DrawingTypeEnum.DRAWING_GROUP,
461
+ }), c = {
462
+ unitId: s,
463
+ subUnitId: o,
464
+ drawingId: d,
465
+ drawingType: k.DRAWING_GROUP,
442
466
  transform: {
443
467
  left: 0,
444
468
  top: 0
445
469
  }
446
470
  };
447
- newGroupParams.push({
448
- parent: ungroupParam,
449
- children: newChildren
471
+ e.push({
472
+ parent: c,
473
+ children: g
450
474
  });
451
- }), newGroupParams;
475
+ }), e;
452
476
  }
453
- __name(groupToUngroup, "groupToUngroup");
454
- const GroupSheetDrawingCommand = {
477
+ const rn = {
455
478
  id: "sheet.command.group-sheet-image",
456
- type: CommandType.COMMAND,
457
- handler: /* @__PURE__ */ __name((accessor, params) => {
458
- const commandService = accessor.get(ICommandService), undoRedoService = accessor.get(IUndoRedoService), sheetDrawingService = accessor.get(ISheetDrawingService);
459
- if (!params) return !1;
460
- const unitIds = [];
461
- params.forEach(({ parent, children }) => {
462
- unitIds.push(parent.unitId), children.forEach((child) => {
463
- unitIds.push(child.unitId);
479
+ type: H.COMMAND,
480
+ handler: (i, e) => {
481
+ const n = i.get(B), t = i.get(ue), r = i.get(F);
482
+ if (!e) return !1;
483
+ const s = [];
484
+ e.forEach(({ parent: u, children: m }) => {
485
+ s.push(u.unitId), m.forEach((f) => {
486
+ s.push(f.unitId);
464
487
  });
465
488
  });
466
- const jsonOp = sheetDrawingService.getGroupDrawingOp(params), { unitId, subUnitId, undo, redo, objects } = jsonOp;
467
- return commandService.syncExecuteCommand(SetDrawingApplyMutation.id, { op: redo, unitId, subUnitId, objects, type: DrawingApplyType.GROUP }) ? (undoRedoService.pushUndoRedo({
468
- unitID: unitId,
489
+ const o = r.getGroupDrawingOp(e), { unitId: d, subUnitId: l, undo: g, redo: c, objects: a } = o;
490
+ return n.syncExecuteCommand(T.id, { op: c, unitId: d, subUnitId: l, objects: a, type: P.GROUP }) ? (t.pushUndoRedo({
491
+ unitID: d,
469
492
  undoMutations: [
470
- { id: SetDrawingApplyMutation.id, params: { op: undo, unitId, subUnitId, objects: groupToUngroup(objects), type: DrawingApplyType.UNGROUP } },
471
- { id: ClearSheetDrawingTransformerOperation.id, params: unitIds }
493
+ { id: T.id, params: { op: g, unitId: d, subUnitId: l, objects: ei(a), type: P.UNGROUP } },
494
+ { id: j.id, params: s }
472
495
  ],
473
496
  redoMutations: [
474
- { id: SetDrawingApplyMutation.id, params: { op: redo, unitId, subUnitId, objects, type: DrawingApplyType.GROUP } },
475
- { id: ClearSheetDrawingTransformerOperation.id, params: unitIds }
497
+ { id: T.id, params: { op: c, unitId: d, subUnitId: l, objects: a, type: P.GROUP } },
498
+ { id: j.id, params: s }
476
499
  ]
477
500
  }), !0) : !1;
478
- }, "handler")
479
- }, InsertSheetDrawingCommand = {
501
+ }
502
+ }, ke = {
480
503
  id: "sheet.command.insert-sheet-image",
481
- type: CommandType.COMMAND,
482
- handler: /* @__PURE__ */ __name((accessor, params) => {
483
- const commandService = accessor.get(ICommandService), undoRedoService = accessor.get(IUndoRedoService), sheetDrawingService = accessor.get(ISheetDrawingService);
484
- if (!params) return !1;
485
- const drawings = params.drawings, unitIds = drawings.map((param) => param.unitId), jsonOp = sheetDrawingService.getBatchAddOp(drawings), { unitId, subUnitId, undo, redo, objects } = jsonOp;
486
- return commandService.syncExecuteCommand(SetDrawingApplyMutation.id, { op: redo, unitId, subUnitId, objects, type: DrawingApplyType.INSERT }) ? (undoRedoService.pushUndoRedo({
487
- unitID: unitId,
504
+ type: H.COMMAND,
505
+ handler: (i, e) => {
506
+ var S, v, R;
507
+ const n = i.get(B), t = i.get(ue), r = i.get(F), s = i.get(at);
508
+ if (!e) return !1;
509
+ const o = e.drawings, d = o.map((_) => _.unitId), l = r.getBatchAddOp(o), { unitId: g, subUnitId: c, undo: a, redo: h, objects: u } = l, m = s.onCommandExecute({ id: ke.id, params: e }), f = { id: T.id, params: { op: h, unitId: g, subUnitId: c, objects: u, type: P.INSERT } }, p = { id: T.id, params: { op: a, unitId: g, subUnitId: c, objects: u, type: P.REMOVE } };
510
+ return It([...(S = m.preRedos) != null ? S : [], f, ...m.redos], n) ? (t.pushUndoRedo({
511
+ unitID: g,
488
512
  undoMutations: [
489
- { id: SetDrawingApplyMutation.id, params: { op: undo, unitId, subUnitId, objects, type: DrawingApplyType.REMOVE } },
490
- { id: ClearSheetDrawingTransformerOperation.id, params: unitIds }
513
+ ...(v = m.preUndos) != null ? v : [],
514
+ p,
515
+ ...m.undos,
516
+ { id: j.id, params: d }
491
517
  ],
492
518
  redoMutations: [
493
- { id: SetDrawingApplyMutation.id, params: { op: redo, unitId, subUnitId, objects, type: DrawingApplyType.INSERT } },
494
- { id: ClearSheetDrawingTransformerOperation.id, params: unitIds }
519
+ ...(R = m.preRedos) != null ? R : [],
520
+ f,
521
+ ...m.redos,
522
+ { id: j.id, params: d }
495
523
  ]
496
524
  }), !0) : !1;
497
- }, "handler")
498
- }, SetDrawingArrangeCommand = {
525
+ }
526
+ }, sn = {
499
527
  id: "sheet.command.set-drawing-arrange",
500
- type: CommandType.COMMAND,
501
- handler: /* @__PURE__ */ __name((accessor, params) => {
502
- const commandService = accessor.get(ICommandService), undoRedoService = accessor.get(IUndoRedoService);
503
- if (!params) return !1;
504
- const sheetDrawingService = accessor.get(ISheetDrawingService), { unitId, subUnitId, drawingIds, arrangeType } = params, drawingOrderMapParam = { unitId, subUnitId, drawingIds };
505
- let jsonOp;
506
- if (arrangeType === ArrangeTypeEnum.forward ? jsonOp = sheetDrawingService.getForwardDrawingsOp(drawingOrderMapParam) : arrangeType === ArrangeTypeEnum.backward ? jsonOp = sheetDrawingService.getBackwardDrawingOp(drawingOrderMapParam) : arrangeType === ArrangeTypeEnum.front ? jsonOp = sheetDrawingService.getFrontDrawingsOp(drawingOrderMapParam) : arrangeType === ArrangeTypeEnum.back && (jsonOp = sheetDrawingService.getBackDrawingsOp(drawingOrderMapParam)), jsonOp == null)
528
+ type: H.COMMAND,
529
+ handler: (i, e) => {
530
+ const n = i.get(B), t = i.get(ue);
531
+ if (!e) return !1;
532
+ const r = i.get(F), { unitId: s, subUnitId: o, drawingIds: d, arrangeType: l } = e, g = { unitId: s, subUnitId: o, drawingIds: d };
533
+ let c;
534
+ if (l === ve.forward ? c = r.getForwardDrawingsOp(g) : l === ve.backward ? c = r.getBackwardDrawingOp(g) : l === ve.front ? c = r.getFrontDrawingsOp(g) : l === ve.back && (c = r.getBackDrawingsOp(g)), c == null)
507
535
  return !1;
508
- const { objects, redo, undo } = jsonOp;
509
- return commandService.syncExecuteCommand(SetDrawingApplyMutation.id, { op: redo, unitId, subUnitId, objects, type: DrawingApplyType.ARRANGE }) ? (undoRedoService.pushUndoRedo({
510
- unitID: unitId,
536
+ const { objects: a, redo: h, undo: u } = c;
537
+ return n.syncExecuteCommand(T.id, { op: h, unitId: s, subUnitId: o, objects: a, type: P.ARRANGE }) ? (t.pushUndoRedo({
538
+ unitID: s,
511
539
  undoMutations: [
512
- { id: SetDrawingApplyMutation.id, params: { op: undo, unitId, subUnitId, objects, type: DrawingApplyType.ARRANGE } }
540
+ { id: T.id, params: { op: u, unitId: s, subUnitId: o, objects: a, type: P.ARRANGE } }
513
541
  ],
514
542
  redoMutations: [
515
- { id: SetDrawingApplyMutation.id, params: { op: redo, unitId, subUnitId, objects, type: DrawingApplyType.ARRANGE } }
543
+ { id: T.id, params: { op: h, unitId: s, subUnitId: o, objects: a, type: P.ARRANGE } }
516
544
  ]
517
545
  }), !0) : !1;
518
- }, "handler")
519
- }, SetSheetDrawingCommand = {
546
+ }
547
+ }, Ye = {
520
548
  id: "sheet.command.set-sheet-image",
521
- type: CommandType.COMMAND,
522
- handler: /* @__PURE__ */ __name((accessor, params) => {
523
- const commandService = accessor.get(ICommandService), undoRedoService = accessor.get(IUndoRedoService), sheetDrawingService = accessor.get(ISheetDrawingService);
524
- if (!params) return !1;
525
- const { drawings } = params, jsonOp = sheetDrawingService.getBatchUpdateOp(drawings), { unitId, subUnitId, undo, redo, objects } = jsonOp;
526
- return commandService.syncExecuteCommand(SetDrawingApplyMutation.id, { unitId, subUnitId, op: redo, objects, type: DrawingApplyType.UPDATE }) ? (undoRedoService.pushUndoRedo({
527
- unitID: unitId,
549
+ type: H.COMMAND,
550
+ handler: (i, e) => {
551
+ const n = i.get(B), t = i.get(ue), r = i.get(F);
552
+ if (!e) return !1;
553
+ const { drawings: s } = e, o = r.getBatchUpdateOp(s), { unitId: d, subUnitId: l, undo: g, redo: c, objects: a } = o;
554
+ return n.syncExecuteCommand(T.id, { unitId: d, subUnitId: l, op: c, objects: a, type: P.UPDATE }) ? (t.pushUndoRedo({
555
+ unitID: d,
528
556
  undoMutations: [
529
- { id: SetDrawingApplyMutation.id, params: { unitId, subUnitId, op: undo, objects, type: DrawingApplyType.UPDATE } },
530
- { id: ClearSheetDrawingTransformerOperation.id, params: [unitId] }
557
+ { id: T.id, params: { unitId: d, subUnitId: l, op: g, objects: a, type: P.UPDATE } },
558
+ { id: j.id, params: [d] }
531
559
  ],
532
560
  redoMutations: [
533
- { id: SetDrawingApplyMutation.id, params: { unitId, subUnitId, op: redo, objects, type: DrawingApplyType.UPDATE } },
534
- { id: ClearSheetDrawingTransformerOperation.id, params: [unitId] }
561
+ { id: T.id, params: { unitId: d, subUnitId: l, op: c, objects: a, type: P.UPDATE } },
562
+ { id: j.id, params: [d] }
535
563
  ]
536
564
  }), !0) : !1;
537
- }, "handler")
538
- }, UngroupSheetDrawingCommand = {
565
+ }
566
+ }, on = {
539
567
  id: "sheet.command.ungroup-sheet-image",
540
- type: CommandType.COMMAND,
541
- handler: /* @__PURE__ */ __name((accessor, params) => {
542
- const commandService = accessor.get(ICommandService), undoRedoService = accessor.get(IUndoRedoService), sheetDrawingService = accessor.get(ISheetDrawingService);
543
- if (!params) return !1;
544
- const unitIds = [];
545
- params.forEach(({ parent, children }) => {
546
- unitIds.push(parent.unitId), children.forEach((child) => {
547
- unitIds.push(child.unitId);
568
+ type: H.COMMAND,
569
+ handler: (i, e) => {
570
+ const n = i.get(B), t = i.get(ue), r = i.get(F);
571
+ if (!e) return !1;
572
+ const s = [];
573
+ e.forEach(({ parent: u, children: m }) => {
574
+ s.push(u.unitId), m.forEach((f) => {
575
+ s.push(f.unitId);
548
576
  });
549
577
  });
550
- const jsonOp = sheetDrawingService.getUngroupDrawingOp(params), { unitId, subUnitId, undo, redo, objects } = jsonOp;
551
- return commandService.syncExecuteCommand(SetDrawingApplyMutation.id, { op: redo, unitId, subUnitId, objects, type: DrawingApplyType.UNGROUP }) ? (undoRedoService.pushUndoRedo({
552
- unitID: unitId,
578
+ const o = r.getUngroupDrawingOp(e), { unitId: d, subUnitId: l, undo: g, redo: c, objects: a } = o;
579
+ return n.syncExecuteCommand(T.id, { op: c, unitId: d, subUnitId: l, objects: a, type: P.UNGROUP }) ? (t.pushUndoRedo({
580
+ unitID: d,
553
581
  undoMutations: [
554
- { id: SetDrawingApplyMutation.id, params: { op: undo, unitId, subUnitId, objects: ungroupToGroup(objects), type: DrawingApplyType.GROUP } },
555
- { id: ClearSheetDrawingTransformerOperation.id, params: unitIds }
582
+ { id: T.id, params: { op: g, unitId: d, subUnitId: l, objects: Qr(a), type: P.GROUP } },
583
+ { id: j.id, params: s }
556
584
  ],
557
585
  redoMutations: [
558
- { id: SetDrawingApplyMutation.id, params: { op: redo, unitId, subUnitId, objects, type: DrawingApplyType.UNGROUP } },
559
- { id: ClearSheetDrawingTransformerOperation.id, params: unitIds }
586
+ { id: T.id, params: { op: c, unitId: d, subUnitId: l, objects: a, type: P.UNGROUP } },
587
+ { id: j.id, params: s }
560
588
  ]
561
589
  }), !0) : !1;
562
- }, "handler")
590
+ }
563
591
  };
564
- var __defProp$7 = Object.defineProperty, __getOwnPropDesc$7 = Object.getOwnPropertyDescriptor, __decorateClass$7 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
565
- for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$7(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
566
- (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
567
- return kind && result && __defProp$7(target, key, result), result;
568
- }, "__decorateClass$7"), __decorateParam$7 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$7"), _a3;
569
- let SheetDrawingUpdateController = (_a3 = class extends Disposable {
570
- constructor(_context, _skeletonManagerService, _commandService, _selectionRenderService, _imageIoService, _fileOpenerService, _sheetDrawingService, _drawingManagerService, _contextService, _messageService, _localeService, selectionManagerService) {
592
+ var ti = Object.defineProperty, ni = Object.getOwnPropertyDescriptor, ri = (i, e, n, t) => {
593
+ for (var r = t > 1 ? void 0 : t ? ni(e, n) : e, s = i.length - 1, o; s >= 0; s--)
594
+ (o = i[s]) && (r = (t ? o(e, n, r) : o(r)) || r);
595
+ return t && r && ti(e, n, r), r;
596
+ }, z = (i, e) => (n, t) => e(n, t, i);
597
+ let Ae = class extends ie {
598
+ constructor(e, n, t, r, s, o, d, l, g, c, a, h) {
571
599
  super();
572
- __publicField(this, "_workbookSelections");
573
- this._context = _context, this._skeletonManagerService = _skeletonManagerService, this._commandService = _commandService, this._selectionRenderService = _selectionRenderService, this._imageIoService = _imageIoService, this._fileOpenerService = _fileOpenerService, this._sheetDrawingService = _sheetDrawingService, this._drawingManagerService = _drawingManagerService, this._contextService = _contextService, this._messageService = _messageService, this._localeService = _localeService, this._workbookSelections = selectionManagerService.getWorkbookSelections(this._context.unitId), this._updateImageListener(), this._updateOrderListener(), this._groupDrawingListener(), this._focusDrawingListener();
600
+ V(this, "_workbookSelections");
601
+ this._context = e, this._skeletonManagerService = n, this._commandService = t, this._selectionRenderService = r, this._imageIoService = s, this._fileOpenerService = o, this._sheetDrawingService = d, this._drawingManagerService = l, this._contextService = g, this._messageService = c, this._localeService = a, this._workbookSelections = h.getWorkbookSelections(this._context.unitId), this._updateImageListener(), this._updateOrderListener(), this._groupDrawingListener(), this._focusDrawingListener();
574
602
  }
575
603
  async insertFloatImage() {
576
- const files = await this._fileOpenerService.openFile({
604
+ const e = await this._fileOpenerService.openFile({
577
605
  multiple: !0,
578
- accept: DRAWING_IMAGE_ALLOW_IMAGE_LIST.map((image) => `.${image.replace("image/", "")}`).join(",")
579
- }), fileLength = files.length;
580
- return fileLength > DRAWING_IMAGE_COUNT_LIMIT ? (this._messageService.show({
581
- type: MessageType.Error,
582
- content: this._localeService.t("update-status.exceedMaxCount", String(DRAWING_IMAGE_COUNT_LIMIT))
583
- }), !1) : fileLength === 0 ? !1 : (files.forEach(async (file) => await this._insertFloatImage(file)), !0);
584
- }
585
- async _insertFloatImage(file) {
586
- let imageParam;
606
+ accept: Nn.map((t) => `.${t.replace("image/", "")}`).join(",")
607
+ }), n = e.length;
608
+ return n > mt ? (this._messageService.show({
609
+ type: Re.Error,
610
+ content: this._localeService.t("update-status.exceedMaxCount", String(mt))
611
+ }), !1) : n === 0 ? !1 : (e.forEach(async (t) => await this._insertFloatImage(t)), !0);
612
+ }
613
+ async _insertFloatImage(e) {
614
+ let n;
587
615
  try {
588
- imageParam = await this._imageIoService.saveImage(file);
589
- } catch (error) {
590
- const type = error.message;
591
- type === ImageUploadStatusType.ERROR_EXCEED_SIZE ? this._messageService.show({
592
- type: MessageType.Error,
593
- content: this._localeService.t("update-status.exceedMaxSize", String(DRAWING_IMAGE_ALLOW_SIZE / (1024 * 1024)))
594
- }) : type === ImageUploadStatusType.ERROR_IMAGE_TYPE ? this._messageService.show({
595
- type: MessageType.Error,
616
+ n = await this._imageIoService.saveImage(e);
617
+ } catch (S) {
618
+ const v = S.message;
619
+ v === He.ERROR_EXCEED_SIZE ? this._messageService.show({
620
+ type: Re.Error,
621
+ content: this._localeService.t("update-status.exceedMaxSize", String(jn / (1024 * 1024)))
622
+ }) : v === He.ERROR_IMAGE_TYPE ? this._messageService.show({
623
+ type: Re.Error,
596
624
  content: this._localeService.t("update-status.invalidImageType")
597
- }) : type === ImageUploadStatusType.ERROR_IMAGE && this._messageService.show({
598
- type: MessageType.Error,
625
+ }) : v === He.ERROR_IMAGE && this._messageService.show({
626
+ type: Re.Error,
599
627
  content: this._localeService.t("update-status.invalidImage")
600
628
  });
601
629
  }
602
- if (imageParam == null)
630
+ if (n == null)
603
631
  return;
604
- const info = this._getUnitInfo(), { unitId, subUnitId } = info, { imageId, imageSourceType, source, base64Cache } = imageParam, { width, height, image } = await getImageSize(base64Cache || ""), { width: sceneWidth, height: sceneHeight } = this._context.scene;
605
- this._imageIoService.addImageSourceCache(source, imageSourceType, image);
606
- let scale = 1;
607
- if (width > DRAWING_IMAGE_WIDTH_LIMIT || height > DRAWING_IMAGE_HEIGHT_LIMIT) {
608
- const scaleWidth = DRAWING_IMAGE_WIDTH_LIMIT / width, scaleHeight = DRAWING_IMAGE_HEIGHT_LIMIT / height;
609
- scale = Math.max(scaleWidth, scaleHeight);
632
+ const t = this._getUnitInfo(), { unitId: r, subUnitId: s } = t, { imageId: o, imageSourceType: d, source: l, base64Cache: g } = n, { width: c, height: a, image: h } = await Wn(g || ""), { width: u, height: m } = this._context.scene;
633
+ this._imageIoService.addImageSourceCache(l, d, h);
634
+ let f = 1;
635
+ if (c > ft || a > pt) {
636
+ const S = ft / c, v = pt / a;
637
+ f = Math.max(S, v);
610
638
  }
611
- const sheetTransform = this._getImagePosition(width * scale, height * scale, sceneWidth, sceneHeight);
612
- if (sheetTransform == null)
639
+ const p = this._getImagePosition(c * f, a * f, u, m);
640
+ if (p == null)
613
641
  return;
614
- const sheetDrawingParam = {
615
- unitId,
616
- subUnitId,
617
- drawingId: imageId,
618
- drawingType: DrawingTypeEnum.DRAWING_IMAGE,
619
- imageSourceType,
620
- source,
621
- transform: drawingPositionToTransform(sheetTransform, this._selectionRenderService, this._skeletonManagerService),
622
- sheetTransform
642
+ const C = {
643
+ unitId: r,
644
+ subUnitId: s,
645
+ drawingId: o,
646
+ drawingType: k.DRAWING_IMAGE,
647
+ imageSourceType: d,
648
+ source: l,
649
+ transform: L(p, this._selectionRenderService, this._skeletonManagerService),
650
+ sheetTransform: p
623
651
  };
624
- this._commandService.executeCommand(InsertSheetDrawingCommand.id, {
625
- unitId,
626
- drawings: [sheetDrawingParam]
652
+ this._commandService.executeCommand(ke.id, {
653
+ unitId: r,
654
+ drawings: [C]
627
655
  });
628
656
  }
629
657
  _getUnitInfo() {
630
- const workbook = this._context.unit, worksheet = workbook.getActiveSheet(), unitId = workbook.getUnitId(), subUnitId = worksheet.getSheetId();
658
+ const e = this._context.unit, n = e.getActiveSheet(), t = e.getUnitId(), r = n.getSheetId();
631
659
  return {
632
- unitId,
633
- subUnitId
660
+ unitId: t,
661
+ subUnitId: r
634
662
  };
635
663
  }
636
- _getImagePosition(imageWidth, imageHeight, sceneWidth, sceneHeight) {
637
- const selections = this._workbookSelections.getCurrentSelections();
638
- let range = {
664
+ _getImagePosition(e, n, t, r) {
665
+ const s = this._workbookSelections.getCurrentSelections();
666
+ let o = {
639
667
  startRow: 0,
640
668
  endRow: 0,
641
669
  startColumn: 0,
642
670
  endColumn: 0
643
671
  };
644
- selections && selections.length > 0 && (range = selections[selections.length - 1].range);
645
- const rangeWithCoord = attachRangeWithCoord(this._skeletonManagerService.getCurrent().skeleton, range);
646
- if (rangeWithCoord == null)
672
+ s && s.length > 0 && (o = s[s.length - 1].range);
673
+ const d = Pe(this._skeletonManagerService.getCurrent().skeleton, o);
674
+ if (d == null)
647
675
  return;
648
- let { startColumn, startRow, startX, startY } = rangeWithCoord, isChangeStart = !1;
649
- if (startX + imageWidth > sceneWidth && (startX = sceneWidth - imageWidth, startX < 0 && (startX = 0, imageWidth = sceneWidth), isChangeStart = !0), startY + imageHeight > sceneHeight && (startY = sceneHeight - imageHeight, startY < 0 && (startY = 0, imageHeight = sceneHeight), isChangeStart = !0), isChangeStart) {
650
- const newCoord = this._selectionRenderService.getSelectionCellByPosition(startX, startY);
651
- if (newCoord == null)
676
+ let { startColumn: l, startRow: g, startX: c, startY: a } = d, h = !1;
677
+ if (c + e > t && (c = t - e, c < 0 && (c = 0, e = t), h = !0), a + n > r && (a = r - n, a < 0 && (a = 0, n = r), h = !0), h) {
678
+ const p = this._selectionRenderService.getCellWithCoordByOffset(c, a);
679
+ if (p == null)
652
680
  return;
653
- startX = newCoord.startX, startY = newCoord.startY, startColumn = newCoord.actualColumn, startRow = newCoord.actualRow;
681
+ c = p.startX, a = p.startY, l = p.actualColumn, g = p.actualRow;
654
682
  }
655
- const from = {
656
- column: startColumn,
683
+ const u = {
684
+ column: l,
657
685
  columnOffset: 0,
658
- row: startRow,
686
+ row: g,
659
687
  rowOffset: 0
660
- }, endSelectionCell = this._selectionRenderService.getSelectionCellByPosition(startX + imageWidth, startY + imageHeight);
661
- if (endSelectionCell == null)
688
+ }, m = this._selectionRenderService.getCellWithCoordByOffset(c + e, a + n);
689
+ if (m == null)
662
690
  return;
663
- const to = {
664
- column: endSelectionCell.actualColumn,
665
- columnOffset: startX + imageWidth - endSelectionCell.startX,
666
- row: endSelectionCell.actualRow,
667
- rowOffset: startY + imageHeight - endSelectionCell.startY
691
+ const f = {
692
+ column: m.actualColumn,
693
+ columnOffset: c + e - m.startX,
694
+ row: m.actualRow,
695
+ rowOffset: a + n - m.startY
668
696
  };
669
697
  return {
670
- from,
671
- to
698
+ from: u,
699
+ to: f
672
700
  };
673
701
  }
674
702
  _updateOrderListener() {
675
- this._drawingManagerService.featurePluginOrderUpdate$.subscribe((params) => {
676
- const { unitId, subUnitId, drawingIds, arrangeType } = params;
677
- this._commandService.executeCommand(SetDrawingArrangeCommand.id, {
678
- unitId,
679
- subUnitId,
680
- drawingIds,
681
- arrangeType
703
+ this.disposeWithMe(this._drawingManagerService.featurePluginOrderUpdate$.subscribe((e) => {
704
+ const { unitId: n, subUnitId: t, drawingIds: r, arrangeType: s } = e;
705
+ this._commandService.executeCommand(sn.id, {
706
+ unitId: n,
707
+ subUnitId: t,
708
+ drawingIds: r,
709
+ arrangeType: s
682
710
  });
683
- });
711
+ }));
684
712
  }
685
713
  _updateImageListener() {
686
- this._drawingManagerService.featurePluginUpdate$.subscribe((params) => {
687
- const drawings = [];
688
- params.length !== 0 && (params.forEach((param) => {
689
- const { unitId, subUnitId, drawingId, drawingType, transform } = param;
690
- if (transform == null)
714
+ this.disposeWithMe(this._drawingManagerService.featurePluginUpdate$.subscribe((e) => {
715
+ const n = [];
716
+ e.length !== 0 && (e.forEach((t) => {
717
+ const { unitId: r, subUnitId: s, drawingId: o, drawingType: d, transform: l } = t;
718
+ if (l == null)
691
719
  return;
692
- const sheetDrawing = this._sheetDrawingService.getDrawingByParam({ unitId, subUnitId, drawingId });
693
- if (sheetDrawing == null || sheetDrawing.unitId !== this._context.unitId)
720
+ const g = this._sheetDrawingService.getDrawingByParam({ unitId: r, subUnitId: s, drawingId: o });
721
+ if (g == null || g.unitId !== this._context.unitId)
694
722
  return;
695
- const sheetTransform = transformToDrawingPosition({ ...sheetDrawing.transform, ...transform }, this._selectionRenderService);
696
- if (sheetTransform == null)
723
+ const c = N({ ...g.transform, ...l }, this._selectionRenderService);
724
+ if (c == null)
697
725
  return;
698
- const newDrawing = {
699
- ...param,
700
- transform: { ...sheetDrawing.transform, ...transform, ...drawingPositionToTransform(sheetTransform, this._selectionRenderService, this._skeletonManagerService) },
701
- sheetTransform: { ...sheetTransform }
726
+ const a = {
727
+ ...t,
728
+ transform: { ...g.transform, ...l, ...L(c, this._selectionRenderService, this._skeletonManagerService) },
729
+ sheetTransform: { ...c }
702
730
  };
703
- drawings.push(newDrawing);
704
- }), drawings.length > 0 && this._commandService.executeCommand(SetSheetDrawingCommand.id, {
705
- unitId: params[0].unitId,
706
- drawings
731
+ n.push(a);
732
+ }), n.length > 0 && this._commandService.executeCommand(Ye.id, {
733
+ unitId: e[0].unitId,
734
+ drawings: n
707
735
  }));
708
- });
736
+ }));
709
737
  }
710
738
  _groupDrawingListener() {
711
- this._drawingManagerService.featurePluginGroupUpdate$.subscribe((params) => {
712
- this._commandService.executeCommand(GroupSheetDrawingCommand.id, params);
713
- const { unitId, subUnitId, drawingId } = params[0].parent;
714
- this._drawingManagerService.focusDrawing([{ unitId, subUnitId, drawingId }]);
715
- }), this._drawingManagerService.featurePluginUngroupUpdate$.subscribe((params) => {
716
- this._commandService.executeCommand(UngroupSheetDrawingCommand.id, params);
717
- });
739
+ this.disposeWithMe(this._drawingManagerService.featurePluginGroupUpdate$.subscribe((e) => {
740
+ this._commandService.executeCommand(rn.id, e);
741
+ const { unitId: n, subUnitId: t, drawingId: r } = e[0].parent;
742
+ this._drawingManagerService.focusDrawing([{ unitId: n, subUnitId: t, drawingId: r }]);
743
+ })), this.disposeWithMe(this._drawingManagerService.featurePluginUngroupUpdate$.subscribe((e) => {
744
+ this._commandService.executeCommand(on.id, e);
745
+ }));
718
746
  }
719
747
  _focusDrawingListener() {
720
748
  this.disposeWithMe(
721
- this._drawingManagerService.focus$.subscribe((params) => {
722
- params == null || params.length === 0 ? (this._contextService.setContextValue(FOCUSING_COMMON_DRAWINGS, !1), this._sheetDrawingService.focusDrawing([])) : (this._contextService.setContextValue(FOCUSING_COMMON_DRAWINGS, !0), this._sheetDrawingService.focusDrawing(params));
749
+ this._drawingManagerService.focus$.subscribe((e) => {
750
+ e == null || e.length === 0 ? (this._contextService.setContextValue(me, !1), this._sheetDrawingService.focusDrawing([])) : (this._contextService.setContextValue(me, !0), this._sheetDrawingService.focusDrawing(e));
723
751
  })
724
752
  );
725
753
  }
726
- }, __name(_a3, "SheetDrawingUpdateController"), _a3);
727
- SheetDrawingUpdateController = __decorateClass$7([
728
- __decorateParam$7(1, Inject(SheetSkeletonManagerService)),
729
- __decorateParam$7(2, ICommandService),
730
- __decorateParam$7(3, ISheetSelectionRenderService),
731
- __decorateParam$7(4, IImageIoService),
732
- __decorateParam$7(5, ILocalFileService),
733
- __decorateParam$7(6, ISheetDrawingService),
734
- __decorateParam$7(7, IDrawingManagerService),
735
- __decorateParam$7(8, IContextService),
736
- __decorateParam$7(9, IMessageService),
737
- __decorateParam$7(10, Inject(LocaleService)),
738
- __decorateParam$7(11, Inject(SheetsSelectionsService))
739
- ], SheetDrawingUpdateController);
740
- const InsertFloatImageCommand = {
754
+ };
755
+ Ae = ri([
756
+ z(1, W(q)),
757
+ z(2, B),
758
+ z(3, pe),
759
+ z(4, Mt),
760
+ z(5, ar),
761
+ z(6, F),
762
+ z(7, K),
763
+ z(8, Dt),
764
+ z(9, cr),
765
+ z(10, W(Be)),
766
+ z(11, W(pr))
767
+ ], Ae);
768
+ const dt = {
741
769
  id: "sheet.command.insert-float-image",
742
- type: CommandType.COMMAND,
743
- handler: /* @__PURE__ */ __name((accessor) => {
744
- var _a11, _b;
745
- return (_b = (_a11 = accessor.get(IRenderManagerService).getCurrentTypeOfRenderer(UniverInstanceType.UNIVER_SHEET)) == null ? void 0 : _a11.with(SheetDrawingUpdateController).insertFloatImage()) != null ? _b : !1;
746
- }, "handler")
747
- }, MoveDrawingsCommand = {
770
+ type: H.COMMAND,
771
+ handler: (i) => {
772
+ var n, t;
773
+ return (t = (n = i.get(J).getCurrentTypeOfRenderer(Y.UNIVER_SHEET)) == null ? void 0 : n.with(Ae).insertFloatImage()) != null ? t : !1;
774
+ }
775
+ }, we = {
748
776
  id: "sheet.command.move-drawing",
749
- type: CommandType.COMMAND,
750
- handler: /* @__PURE__ */ __name((accessor, params) => {
751
- const commandService = accessor.get(ICommandService), drawingManagerService = accessor.get(ISheetDrawingService), selectionRenderService = accessor.get(ISheetSelectionRenderService), { direction } = params, drawings = drawingManagerService.getFocusDrawings();
752
- if (drawings.length === 0)
777
+ type: H.COMMAND,
778
+ handler: (i, e) => {
779
+ const n = i.get(B), t = i.get(F), r = i.get(pe), { direction: s } = e, o = t.getFocusDrawings();
780
+ if (o.length === 0)
753
781
  return !1;
754
- const unitId = drawings[0].unitId, newDrawings = drawings.map((drawing) => {
755
- const { transform } = drawing;
756
- if (transform == null)
782
+ const d = o[0].unitId, l = o.map((c) => {
783
+ const { transform: a } = c;
784
+ if (a == null)
757
785
  return null;
758
- const newTransform = { ...transform }, { left = 0, top = 0 } = transform;
759
- return direction === Direction.UP ? newTransform.top = top - 1 : direction === Direction.DOWN ? newTransform.top = top + 1 : direction === Direction.LEFT ? newTransform.left = left - 1 : direction === Direction.RIGHT && (newTransform.left = left + 1), {
760
- ...drawing,
761
- transform: newTransform,
762
- sheetTransform: transformToDrawingPosition(newTransform, selectionRenderService)
786
+ const h = { ...a }, { left: u = 0, top: m = 0 } = a;
787
+ return s === te.UP ? h.top = m - 1 : s === te.DOWN ? h.top = m + 1 : s === te.LEFT ? h.left = u - 1 : s === te.RIGHT && (h.left = u + 1), {
788
+ ...c,
789
+ transform: h,
790
+ sheetTransform: N(h, r)
763
791
  };
764
- }).filter((drawing) => drawing != null);
765
- return commandService.syncExecuteCommand(SetSheetDrawingCommand.id, {
766
- unitId,
767
- drawings: newDrawings
768
- }) ? (commandService.syncExecuteCommand(ClearSheetDrawingTransformerOperation.id, [unitId]), !0) : !1;
769
- }, "handler")
770
- }, IMAGE_UPLOAD_ICON = "addition-and-subtraction-single", IMAGE_MENU_ID = "sheet.menu.image";
771
- function ImageMenuFactory(accessor) {
792
+ }).filter((c) => c != null);
793
+ return n.syncExecuteCommand(Ye.id, {
794
+ unitId: d,
795
+ drawings: l
796
+ }) ? (n.syncExecuteCommand(j.id, [d]), !0) : !1;
797
+ }
798
+ }, an = "addition-and-subtraction-single", cn = "sheet.menu.image";
799
+ function ii(i) {
772
800
  return {
773
- id: IMAGE_MENU_ID,
774
- type: MenuItemType.SUBITEMS,
775
- icon: IMAGE_UPLOAD_ICON,
801
+ id: cn,
802
+ type: bt.SUBITEMS,
803
+ icon: an,
776
804
  tooltip: "sheetImage.title",
777
- hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_SHEET),
778
- disabled$: getCurrentRangeDisable$(accessor, { workbookTypes: [WorkbookEditablePermission], worksheetTypes: [WorksheetEditPermission], rangeTypes: [RangeProtectionPermissionEditPoint] })
805
+ hidden$: yt(i, Y.UNIVER_SHEET),
806
+ disabled$: qn(i, { workbookTypes: [tt], worksheetTypes: [Te], rangeTypes: [wr] })
779
807
  };
780
808
  }
781
- __name(ImageMenuFactory, "ImageMenuFactory");
782
- function UploadFloatImageMenuFactory(_accessor) {
809
+ function si(i) {
783
810
  return {
784
- id: InsertFloatImageCommand.id,
811
+ id: dt.id,
785
812
  title: "sheetImage.upload.float",
786
- type: MenuItemType.BUTTON,
787
- hidden$: getMenuHiddenObservable(_accessor, UniverInstanceType.UNIVER_SHEET)
813
+ type: bt.BUTTON,
814
+ hidden$: yt(i, Y.UNIVER_SHEET)
788
815
  };
789
816
  }
790
- __name(UploadFloatImageMenuFactory, "UploadFloatImageMenuFactory");
791
- const imageCommonPanel = "univer-image-common-panel", imageCommonPanelGrid = "univer-image-common-panel-grid", imageCommonPanelBorder = "univer-image-common-panel-border", imageCommonPanelTitle = "univer-image-common-panel-title", imageCommonPanelSubtitle = "univer-image-common-panel-subtitle", imageCommonPanelRow = "univer-image-common-panel-row", imageCommonPanelRowVertical = "univer-image-common-panel-row-vertical", imageCommonPanelColumn = "univer-image-common-panel-column", imageCommonPanelColumnCenter = "univer-image-common-panel-column-center", imageCommonPanelInline = "univer-image-common-panel-inline", imageCommonPanelSpan2 = "univer-image-common-panel-span2", imageCommonPanelSpan3 = "univer-image-common-panel-span3", imageCommonPanelInput = "univer-image-common-panel-input", sheetImageMenu = "univer-sheet-image-menu", sheetImageMenuInput = "univer-sheet-image-menu-input", styles = {
792
- imageCommonPanel,
793
- imageCommonPanelGrid,
794
- imageCommonPanelBorder,
795
- imageCommonPanelTitle,
796
- imageCommonPanelSubtitle,
797
- imageCommonPanelRow,
798
- imageCommonPanelRowVertical,
799
- imageCommonPanelColumn,
800
- imageCommonPanelColumnCenter,
801
- imageCommonPanelInline,
802
- imageCommonPanelSpan2,
803
- imageCommonPanelSpan3,
804
- imageCommonPanelInput,
805
- sheetImageMenu,
806
- sheetImageMenuInput
817
+ const oi = "univer-image-common-panel", ai = "univer-image-common-panel-grid", ci = "univer-image-common-panel-border", di = "univer-image-common-panel-title", li = "univer-image-common-panel-subtitle", ui = "univer-image-common-panel-row", hi = "univer-image-common-panel-row-vertical", gi = "univer-image-common-panel-column", mi = "univer-image-common-panel-column-center", fi = "univer-image-common-panel-inline", pi = "univer-image-common-panel-span2", wi = "univer-image-common-panel-span3", _i = "univer-image-common-panel-input", vi = "univer-sheet-image-menu", Si = "univer-sheet-image-menu-input", ee = {
818
+ imageCommonPanel: oi,
819
+ imageCommonPanelGrid: ai,
820
+ imageCommonPanelBorder: ci,
821
+ imageCommonPanelTitle: di,
822
+ imageCommonPanelSubtitle: li,
823
+ imageCommonPanelRow: ui,
824
+ imageCommonPanelRowVertical: hi,
825
+ imageCommonPanelColumn: gi,
826
+ imageCommonPanelColumnCenter: mi,
827
+ imageCommonPanelInline: fi,
828
+ imageCommonPanelSpan2: pi,
829
+ imageCommonPanelSpan3: wi,
830
+ imageCommonPanelInput: _i,
831
+ sheetImageMenu: vi,
832
+ sheetImageMenuInput: Si
807
833
  };
808
- function r(e) {
809
- var t, f, n = "";
810
- if (typeof e == "string" || typeof e == "number") n += e;
811
- else if (typeof e == "object") if (Array.isArray(e)) {
812
- var o = e.length;
813
- for (t = 0; t < o; t++) e[t] && (f = r(e[t])) && (n && (n += " "), n += f);
814
- } else for (f in e) e[f] && (n && (n += " "), n += f);
815
- return n;
834
+ function dn(i) {
835
+ var e, n, t = "";
836
+ if (typeof i == "string" || typeof i == "number") t += i;
837
+ else if (typeof i == "object") if (Array.isArray(i)) {
838
+ var r = i.length;
839
+ for (e = 0; e < r; e++) i[e] && (n = dn(i[e])) && (t && (t += " "), t += n);
840
+ } else for (n in i) i[n] && (t && (t += " "), t += n);
841
+ return t;
816
842
  }
817
- __name(r, "r");
818
- function clsx() {
819
- for (var e, t, f = 0, n = "", o = arguments.length; f < o; f++) (e = arguments[f]) && (t = r(e)) && (n && (n += " "), n += t);
820
- return n;
843
+ function be() {
844
+ for (var i, e, n = 0, t = "", r = arguments.length; n < r; n++) (i = arguments[n]) && (e = dn(i)) && (t && (t += " "), t += e);
845
+ return t;
821
846
  }
822
- __name(clsx, "clsx");
823
- const SheetDrawingAnchor = /* @__PURE__ */ __name((props) => {
824
- var _a11;
825
- const commandService = useDependency(ICommandService), localeService = useDependency(LocaleService), drawingManagerService = useDependency(IDrawingManagerService), renderManagerService = useDependency(IRenderManagerService), { drawings } = props, drawingParam = drawings[0];
826
- if (drawingParam == null)
847
+ const Ci = (i) => {
848
+ var v;
849
+ const e = ae(B), n = ae(Be), t = ae(K), r = ae(J), { drawings: s } = i, o = s[0];
850
+ if (o == null)
827
851
  return;
828
- const { unitId } = drawingParam, renderObject = renderManagerService.getRenderById(unitId), scene = renderObject == null ? void 0 : renderObject.scene;
829
- if (scene == null)
852
+ const { unitId: d } = o, l = r.getRenderById(d), g = l == null ? void 0 : l.scene;
853
+ if (g == null)
830
854
  return;
831
- const transformer = scene.getTransformerByCreate(), [anchorShow, setAnchorShow] = useState(!0), type = (_a11 = drawingParam.anchorType) != null ? _a11 : SheetDrawingAnchorType.Position, [value, setValue] = useState(type);
832
- function getUpdateParams(objects, drawingManagerService2) {
833
- const params = [];
834
- return objects.forEach((object) => {
835
- const { oKey } = object, searchParam = drawingManagerService2.getDrawingOKey(oKey);
836
- if (searchParam == null)
837
- return params.push(null), !0;
838
- const { unitId: unitId2, subUnitId, drawingId, drawingType, anchorType, sheetTransform } = searchParam;
839
- params.push({
840
- unitId: unitId2,
841
- subUnitId,
842
- drawingId,
843
- anchorType,
844
- sheetTransform,
845
- drawingType
855
+ const c = g.getTransformerByCreate(), [a, h] = it(!0), u = (v = o.anchorType) != null ? v : y.Position, [m, f] = it(u);
856
+ function p(R, _) {
857
+ const I = [];
858
+ return R.forEach((w) => {
859
+ const { oKey: O } = w, b = _.getDrawingOKey(O);
860
+ if (b == null)
861
+ return I.push(null), !0;
862
+ const { unitId: A, subUnitId: E, drawingId: M, drawingType: D, anchorType: U, sheetTransform: x } = b;
863
+ I.push({
864
+ unitId: A,
865
+ subUnitId: E,
866
+ drawingId: M,
867
+ anchorType: U,
868
+ sheetTransform: x,
869
+ drawingType: D
846
870
  });
847
- }), params;
848
- }
849
- __name(getUpdateParams, "getUpdateParams"), useEffect(() => {
850
- const onClearControlObserver = transformer.clearControl$.subscribe((changeSelf) => {
851
- changeSelf === !0 && setAnchorShow(!1);
852
- }), onChangeStartObserver = transformer.changeStart$.subscribe((state) => {
853
- var _a12;
854
- const { objects } = state, params = getUpdateParams(objects, drawingManagerService);
855
- if (params.length === 0)
856
- setAnchorShow(!1);
857
- else if (params.length >= 1) {
858
- setAnchorShow(!0);
859
- const anchorType = ((_a12 = params[0]) == null ? void 0 : _a12.anchorType) || SheetDrawingAnchorType.Position;
860
- setValue(anchorType);
871
+ }), I;
872
+ }
873
+ ct(() => {
874
+ const R = c.clearControl$.subscribe((I) => {
875
+ I === !0 && h(!1);
876
+ }), _ = c.changeStart$.subscribe((I) => {
877
+ var b;
878
+ const { objects: w } = I, O = p(w, t);
879
+ if (O.length === 0)
880
+ h(!1);
881
+ else if (O.length >= 1) {
882
+ h(!0);
883
+ const A = ((b = O[0]) == null ? void 0 : b.anchorType) || y.Position;
884
+ f(A);
861
885
  }
862
886
  });
863
887
  return () => {
864
- onChangeStartObserver.unsubscribe(), onClearControlObserver.unsubscribe();
888
+ _.unsubscribe(), R.unsubscribe();
865
889
  };
866
890
  }, []);
867
- function handleChange(value2) {
868
- setValue(value2);
869
- const focusDrawings = drawingManagerService.getFocusDrawings();
870
- if (focusDrawings.length === 0)
891
+ function C(R) {
892
+ f(R);
893
+ const _ = t.getFocusDrawings();
894
+ if (_.length === 0)
871
895
  return;
872
- const updateParams = focusDrawings.map((drawing) => ({
873
- unitId: drawing.unitId,
874
- subUnitId: drawing.subUnitId,
875
- drawingId: drawing.drawingId,
876
- anchorType: value2
896
+ const I = _.map((w) => ({
897
+ unitId: w.unitId,
898
+ subUnitId: w.subUnitId,
899
+ drawingId: w.drawingId,
900
+ anchorType: R
877
901
  }));
878
- commandService.executeCommand(SetSheetDrawingCommand.id, {
879
- unitId: focusDrawings[0].unitId,
880
- drawings: updateParams
902
+ e.executeCommand(Ye.id, {
903
+ unitId: _[0].unitId,
904
+ drawings: I
881
905
  });
882
906
  }
883
- __name(handleChange, "handleChange");
884
- const gridDisplay = /* @__PURE__ */ __name((isShow) => isShow ? "block" : "none", "gridDisplay");
885
- return /* @__PURE__ */ React.createElement("div", { className: clsx(styles.imageCommonPanelGrid, styles.imageCommonPanelBorder), style: { display: gridDisplay(anchorShow) } }, /* @__PURE__ */ React.createElement("div", { className: styles.imageCommonPanelRow }, /* @__PURE__ */ React.createElement("div", { className: clsx(styles.imageCommonPanelColumn, styles.imageCommonPanelTitle) }, /* @__PURE__ */ React.createElement("div", null, localeService.t("drawing-anchor.title")))), /* @__PURE__ */ React.createElement("div", { className: clsx(styles.imageCommonPanelRow) }, /* @__PURE__ */ React.createElement("div", { className: clsx(styles.imageCommonPanelColumn) }, /* @__PURE__ */ React.createElement(RadioGroup, { value, onChange: handleChange, direction: "vertical" }, /* @__PURE__ */ React.createElement(Radio, { value: SheetDrawingAnchorType.Both }, localeService.t("drawing-anchor.both")), /* @__PURE__ */ React.createElement(Radio, { value: SheetDrawingAnchorType.Position }, localeService.t("drawing-anchor.position")), /* @__PURE__ */ React.createElement(Radio, { value: SheetDrawingAnchorType.None }, localeService.t("drawing-anchor.none"))))));
886
- }, "SheetDrawingAnchor"), SheetDrawingPanel = /* @__PURE__ */ __name(() => {
887
- const drawingManagerService = useDependency(IDrawingManagerService), focusDrawings = drawingManagerService.getFocusDrawings(), [drawings, setDrawings] = useState(focusDrawings);
888
- return useEffect(() => {
889
- const focusDispose = drawingManagerService.focus$.subscribe((drawings2) => {
890
- setDrawings(drawings2);
907
+ const S = (R) => R ? "block" : "none";
908
+ return /* @__PURE__ */ $.jsxs("div", { className: be(ee.imageCommonPanelGrid, ee.imageCommonPanelBorder), style: { display: S(a) }, children: [
909
+ /* @__PURE__ */ $.jsx("div", { className: ee.imageCommonPanelRow, children: /* @__PURE__ */ $.jsx("div", { className: be(ee.imageCommonPanelColumn, ee.imageCommonPanelTitle), children: /* @__PURE__ */ $.jsx("div", { children: n.t("drawing-anchor.title") }) }) }),
910
+ /* @__PURE__ */ $.jsx("div", { className: be(ee.imageCommonPanelRow), children: /* @__PURE__ */ $.jsx("div", { className: be(ee.imageCommonPanelColumn), children: /* @__PURE__ */ $.jsxs(yr, { value: m, onChange: C, direction: "vertical", children: [
911
+ /* @__PURE__ */ $.jsx(Ze, { value: y.Both, children: n.t("drawing-anchor.both") }),
912
+ /* @__PURE__ */ $.jsx(Ze, { value: y.Position, children: n.t("drawing-anchor.position") }),
913
+ /* @__PURE__ */ $.jsx(Ze, { value: y.None, children: n.t("drawing-anchor.none") })
914
+ ] }) }) })
915
+ ] });
916
+ }, Ii = () => {
917
+ const i = ae(K), e = i.getFocusDrawings(), [n, t] = it(e);
918
+ return ct(() => {
919
+ const r = i.focus$.subscribe((s) => {
920
+ t(s);
891
921
  });
892
922
  return () => {
893
- focusDispose.unsubscribe();
923
+ r.unsubscribe();
894
924
  };
895
- }, []), !!(drawings != null && drawings.length) && /* @__PURE__ */ React.createElement("div", { className: styles.imageCommonPanel }, /* @__PURE__ */ React.createElement(DrawingCommonPanel, { drawings }), /* @__PURE__ */ React.createElement(SheetDrawingAnchor, { drawings }));
896
- }, "SheetDrawingPanel"), menuSchema = {
897
- [RibbonStartGroup.FORMULAS_INSERT]: {
898
- [IMAGE_MENU_ID]: {
925
+ }, []), !!(n != null && n.length) && /* @__PURE__ */ $.jsxs("div", { className: ee.imageCommonPanel, children: [
926
+ /* @__PURE__ */ $.jsx(Vn, { drawings: n }),
927
+ /* @__PURE__ */ $.jsx(Ci, { drawings: n })
928
+ ] });
929
+ }, Ri = {
930
+ [dr.FORMULAS_INSERT]: {
931
+ [cn]: {
899
932
  order: 3,
900
- menuItemFactory: ImageMenuFactory,
901
- [InsertFloatImageCommand.id]: {
933
+ menuItemFactory: ii,
934
+ [dt.id]: {
902
935
  order: 0,
903
- menuItemFactory: UploadFloatImageMenuFactory
936
+ menuItemFactory: si
904
937
  }
905
938
  }
906
939
  }
907
940
  };
908
- function whenSheetDrawingFocused(contextService) {
909
- return !contextService.getContextValue(FOCUSING_FX_BAR_EDITOR) && !contextService.getContextValue(EDITOR_ACTIVATED) && contextService.getContextValue(FOCUSING_COMMON_DRAWINGS);
941
+ function _e(i) {
942
+ return !i.getContextValue(vn) && !i.getContextValue(Sn) && !i.getContextValue(Cn) && i.getContextValue(me);
910
943
  }
911
- __name(whenSheetDrawingFocused, "whenSheetDrawingFocused");
912
- const MoveDrawingDownShortcutItem = {
913
- id: MoveDrawingsCommand.id,
944
+ const Di = {
945
+ id: we.id,
914
946
  description: "shortcut.sheet.drawing-move-down",
915
947
  group: "4_sheet-drawing-view",
916
- binding: KeyCode.ARROW_DOWN,
948
+ binding: le.ARROW_DOWN,
917
949
  priority: 100,
918
- preconditions: whenSheetDrawingFocused,
950
+ preconditions: _e,
919
951
  staticParameters: {
920
- direction: Direction.DOWN
952
+ direction: te.DOWN
921
953
  }
922
- }, MoveDrawingUpShortcutItem = {
923
- id: MoveDrawingsCommand.id,
954
+ }, Mi = {
955
+ id: we.id,
924
956
  description: "shortcut.sheet.drawing-move-up",
925
957
  group: "4_sheet-drawing-view",
926
- binding: KeyCode.ARROW_UP,
958
+ binding: le.ARROW_UP,
927
959
  priority: 100,
928
- preconditions: whenSheetDrawingFocused,
960
+ preconditions: _e,
929
961
  staticParameters: {
930
- direction: Direction.UP
962
+ direction: te.UP
931
963
  }
932
- }, MoveDrawingLeftShortcutItem = {
933
- id: MoveDrawingsCommand.id,
964
+ }, bi = {
965
+ id: we.id,
934
966
  description: "shortcut.sheet.drawing-move-left",
935
967
  group: "4_sheet-drawing-view",
936
- binding: KeyCode.ARROW_LEFT,
968
+ binding: le.ARROW_LEFT,
937
969
  priority: 100,
938
- preconditions: whenSheetDrawingFocused,
970
+ preconditions: _e,
939
971
  staticParameters: {
940
- direction: Direction.LEFT
972
+ direction: te.LEFT
941
973
  }
942
- }, MoveDrawingRightShortcutItem = {
943
- id: MoveDrawingsCommand.id,
974
+ }, yi = {
975
+ id: we.id,
944
976
  description: "shortcut.sheet.drawing-move-right",
945
977
  group: "4_sheet-drawing-view",
946
- binding: KeyCode.ARROW_RIGHT,
978
+ binding: le.ARROW_RIGHT,
947
979
  priority: 100,
948
- preconditions: whenSheetDrawingFocused,
980
+ preconditions: _e,
949
981
  staticParameters: {
950
- direction: Direction.RIGHT
982
+ direction: te.RIGHT
951
983
  }
952
- }, DeleteDrawingsShortcutItem = {
953
- id: DeleteDrawingsCommand.id,
984
+ }, Oi = {
985
+ id: nn.id,
954
986
  description: "shortcut.sheet.drawing-delete",
955
987
  group: "4_sheet-drawing-view",
956
988
  // when focusing on any other input tag do not trigger this shortcut
957
- preconditions: whenSheetDrawingFocused,
958
- binding: KeyCode.DELETE,
959
- mac: KeyCode.BACKSPACE
989
+ preconditions: _e,
990
+ binding: le.DELETE,
991
+ mac: le.BACKSPACE
960
992
  };
961
- var __defProp$6 = Object.defineProperty, __getOwnPropDesc$6 = Object.getOwnPropertyDescriptor, __decorateClass$6 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
962
- for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$6(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
963
- (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
964
- return kind && result && __defProp$6(target, key, result), result;
965
- }, "__decorateClass$6"), __decorateParam$6 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$6"), _a4;
966
- let SheetDrawingUIController = (_a4 = class extends Disposable {
967
- constructor(_componentManager, _menuManagerService, _commandService, _shortcutService) {
968
- super(), this._componentManager = _componentManager, this._menuManagerService = _menuManagerService, this._commandService = _commandService, this._shortcutService = _shortcutService, this._init();
993
+ var Ti = Object.defineProperty, Pi = Object.getOwnPropertyDescriptor, Ei = (i, e, n, t) => {
994
+ for (var r = t > 1 ? void 0 : t ? Pi(e, n) : e, s = i.length - 1, o; s >= 0; s--)
995
+ (o = i[s]) && (r = (t ? o(e, n, r) : o(r)) || r);
996
+ return t && r && Ti(e, n, r), r;
997
+ }, ye = (i, e) => (n, t) => e(n, t, i);
998
+ let Ne = class extends ie {
999
+ constructor(i, e, n, t) {
1000
+ super(), this._componentManager = i, this._menuManagerService = e, this._commandService = n, this._shortcutService = t, this._init();
969
1001
  }
970
1002
  _initCustomComponents() {
971
- const componentManager = this._componentManager;
972
- this.disposeWithMe(componentManager.register(IMAGE_UPLOAD_ICON, AddImageSingle)), this.disposeWithMe(componentManager.register(COMPONENT_SHEET_DRAWING_PANEL, SheetDrawingPanel));
1003
+ const i = this._componentManager;
1004
+ this.disposeWithMe(i.register(an, tn)), this.disposeWithMe(i.register(zt, Ii));
973
1005
  }
974
1006
  _initMenus() {
975
- this._menuManagerService.mergeMenu(menuSchema);
1007
+ this._menuManagerService.mergeMenu(Ri);
976
1008
  }
977
1009
  _initCommands() {
978
1010
  [
979
- InsertFloatImageCommand,
980
- InsertSheetDrawingCommand,
981
- RemoveSheetDrawingCommand,
982
- SetSheetDrawingCommand,
983
- SidebarSheetDrawingOperation,
984
- ClearSheetDrawingTransformerOperation,
985
- EditSheetDrawingOperation,
986
- GroupSheetDrawingCommand,
987
- UngroupSheetDrawingCommand,
988
- MoveDrawingsCommand,
989
- DeleteDrawingsCommand,
990
- SetDrawingArrangeCommand
991
- ].forEach((command) => this.disposeWithMe(this._commandService.registerCommand(command)));
1011
+ dt,
1012
+ ke,
1013
+ Ge,
1014
+ Ye,
1015
+ Kt,
1016
+ j,
1017
+ Jt,
1018
+ rn,
1019
+ on,
1020
+ we,
1021
+ nn,
1022
+ sn
1023
+ ].forEach((i) => this.disposeWithMe(this._commandService.registerCommand(i)));
992
1024
  }
993
1025
  _initShortcuts() {
994
1026
  [
995
1027
  // sheet drawing shortcuts
996
- MoveDrawingDownShortcutItem,
997
- MoveDrawingUpShortcutItem,
998
- MoveDrawingLeftShortcutItem,
999
- MoveDrawingRightShortcutItem,
1000
- DeleteDrawingsShortcutItem
1001
- ].forEach((item) => {
1002
- this.disposeWithMe(this._shortcutService.registerShortcut(item));
1028
+ Di,
1029
+ Mi,
1030
+ bi,
1031
+ yi,
1032
+ Oi
1033
+ ].forEach((i) => {
1034
+ this.disposeWithMe(this._shortcutService.registerShortcut(i));
1003
1035
  });
1004
1036
  }
1005
1037
  _init() {
1006
1038
  this._initCommands(), this._initCustomComponents(), this._initMenus(), this._initShortcuts();
1007
1039
  }
1008
- }, __name(_a4, "SheetDrawingUIController"), _a4);
1009
- SheetDrawingUIController = __decorateClass$6([
1010
- __decorateParam$6(0, Inject(ComponentManager)),
1011
- __decorateParam$6(1, IMenuManagerService),
1012
- __decorateParam$6(2, ICommandService),
1013
- __decorateParam$6(3, IShortcutService)
1014
- ], SheetDrawingUIController);
1015
- var __defProp$5 = Object.defineProperty, __getOwnPropDesc$5 = Object.getOwnPropertyDescriptor, __decorateClass$5 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
1016
- for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$5(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
1017
- (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
1018
- return kind && result && __defProp$5(target, key, result), result;
1019
- }, "__decorateClass$5"), __decorateParam$5 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$5"), _a5;
1020
- let SheetsDrawingCopyPasteController = (_a5 = class extends Disposable {
1021
- constructor(_sheetClipboardService, _renderManagerService, _sheetDrawingService) {
1040
+ };
1041
+ Ne = Ei([
1042
+ ye(0, W(lr)),
1043
+ ye(1, ur),
1044
+ ye(2, B),
1045
+ ye(3, hr)
1046
+ ], Ne);
1047
+ var Ui = Object.defineProperty, Ai = Object.getOwnPropertyDescriptor, Ni = (i, e, n, t) => {
1048
+ for (var r = t > 1 ? void 0 : t ? Ai(e, n) : e, s = i.length - 1, o; s >= 0; s--)
1049
+ (o = i[s]) && (r = (t ? o(e, n, r) : o(r)) || r);
1050
+ return t && r && Ui(e, n, r), r;
1051
+ }, qe = (i, e) => (n, t) => e(n, t, i);
1052
+ let je = class extends ie {
1053
+ constructor(e, n, t) {
1022
1054
  super();
1023
- __publicField(this, "_copyInfo");
1024
- this._sheetClipboardService = _sheetClipboardService, this._renderManagerService = _renderManagerService, this._sheetDrawingService = _sheetDrawingService, this._initCopyPaste();
1055
+ V(this, "_copyInfo");
1056
+ this._sheetClipboardService = e, this._renderManagerService = n, this._sheetDrawingService = t, this._initCopyPaste();
1025
1057
  }
1026
1058
  _initCopyPaste() {
1027
1059
  this._sheetClipboardService.addClipboardHook({
1028
1060
  id: "SHEET_IMAGE_UI_PLUGIN",
1029
- onBeforeCopy: /* @__PURE__ */ __name((unitId, subUnitId, range) => this._collect(unitId, subUnitId, range), "onBeforeCopy"),
1030
- onPasteCells: /* @__PURE__ */ __name((pasteFrom, pasteTo, data, payload) => {
1031
- const { copyType = COPY_TYPE.COPY, pasteType } = payload, { range: copyRange } = pasteFrom || {}, { range: pastedRange, unitId, subUnitId } = pasteTo;
1032
- return this._generateMutations(pastedRange, { copyType, pasteType, copyRange, unitId, subUnitId });
1033
- }, "onPasteCells"),
1034
- onPastePlainText: /* @__PURE__ */ __name((pasteTo, clipText) => ({ undos: [], redos: [] }), "onPastePlainText")
1061
+ onBeforeCopy: (e, n, t) => this._collect(e, n, t),
1062
+ onPasteCells: (e, n, t, r) => {
1063
+ const { copyType: s = _t.COPY, pasteType: o } = r, { range: d } = e || {}, { range: l, unitId: g, subUnitId: c } = n;
1064
+ return this._generateMutations(l, { copyType: s, pasteType: o, copyRange: d, unitId: g, subUnitId: c });
1065
+ },
1066
+ onPastePlainText: (e, n) => ({ undos: [], redos: [] })
1035
1067
  });
1036
1068
  }
1037
- _collect(unitId, subUnitId, range) {
1038
- var _a11;
1039
- const skeletonManagerService = (_a11 = this._renderManagerService.getRenderById(unitId)) == null ? void 0 : _a11.with(SheetSkeletonManagerService);
1040
- if (!skeletonManagerService) return;
1041
- const selectionRect = skeletonManagerService.attachRangeWithCoord(range);
1042
- if (!selectionRect)
1069
+ _collect(e, n, t) {
1070
+ var h;
1071
+ const r = (h = this._renderManagerService.getRenderById(e)) == null ? void 0 : h.with(q);
1072
+ if (!r) return;
1073
+ const s = r.attachRangeWithCoord(t);
1074
+ if (!s)
1043
1075
  return;
1044
- const { startX, endX, startY, endY } = selectionRect, drawings = this._sheetDrawingService.getDrawingData(unitId, subUnitId), containedDrawings = [];
1045
- Object.keys(drawings).forEach((drawingId) => {
1046
- const drawing = drawings[drawingId], { transform } = drawing;
1047
- if (drawing.anchorType !== SheetDrawingAnchorType.Both || !transform)
1076
+ const { startX: o, endX: d, startY: l, endY: g } = s, c = this._sheetDrawingService.getDrawingData(e, n), a = [];
1077
+ Object.keys(c).forEach((u) => {
1078
+ const m = c[u], { transform: f } = m;
1079
+ if (m.anchorType !== y.Both || !f)
1048
1080
  return;
1049
- const { left = 0, top = 0, width = 0, height = 0 } = transform, { drawingStartX, drawingEndX, drawingStartY, drawingEndY } = {
1050
- drawingStartX: left,
1051
- drawingEndX: left + width,
1052
- drawingStartY: top,
1053
- drawingEndY: top + height
1081
+ const { left: p = 0, top: C = 0, width: S = 0, height: v = 0 } = f, { drawingStartX: R, drawingEndX: _, drawingStartY: I, drawingEndY: w } = {
1082
+ drawingStartX: p,
1083
+ drawingEndX: p + S,
1084
+ drawingStartY: C,
1085
+ drawingEndY: C + v
1054
1086
  };
1055
- startX <= drawingStartX && drawingEndX <= endX && startY <= drawingStartY && drawingEndY <= endY && containedDrawings.push(drawing);
1056
- }), containedDrawings.length && (this._copyInfo = {
1057
- drawings: containedDrawings,
1058
- unitId,
1059
- subUnitId
1087
+ o <= R && _ <= d && l <= I && w <= g && a.push(m);
1088
+ }), a.length && (this._copyInfo = {
1089
+ drawings: a,
1090
+ unitId: e,
1091
+ subUnitId: n
1060
1092
  });
1061
1093
  }
1062
1094
  // eslint-disable-next-line max-lines-per-function
1063
- _generateMutations(pastedRange, copyInfo) {
1064
- var _a11;
1095
+ _generateMutations(e, n) {
1096
+ var b;
1065
1097
  if (!this._copyInfo)
1066
1098
  return { redos: [], undos: [] };
1067
1099
  if ([
1068
- PREDEFINED_HOOK_NAME.SPECIAL_PASTE_COL_WIDTH,
1069
- PREDEFINED_HOOK_NAME.SPECIAL_PASTE_VALUE,
1070
- PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMAT,
1071
- PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMULA
1100
+ Se.SPECIAL_PASTE_COL_WIDTH,
1101
+ Se.SPECIAL_PASTE_VALUE,
1102
+ Se.SPECIAL_PASTE_FORMAT,
1103
+ Se.SPECIAL_PASTE_FORMULA
1072
1104
  ].includes(
1073
- copyInfo.pasteType
1105
+ n.pasteType
1074
1106
  ))
1075
1107
  return { redos: [], undos: [] };
1076
- const { copyRange } = copyInfo;
1077
- if (!copyRange)
1108
+ const { copyRange: t } = n;
1109
+ if (!t)
1078
1110
  return { redos: [], undos: [] };
1079
- const { drawings, unitId, subUnitId } = this._copyInfo, { ranges: [vCopyRange, vPastedRange], mapFunc } = virtualizeDiscreteRanges([copyRange, pastedRange]), { row: copyRow, col: copyCol } = mapFunc(vCopyRange.startRow, vCopyRange.startColumn), { row: pasteRow, col: pasteCol } = mapFunc(vPastedRange.startRow, vPastedRange.startColumn), skeletonManagerService = (_a11 = this._renderManagerService.getRenderById(unitId)) == null ? void 0 : _a11.with(SheetSkeletonManagerService);
1080
- if (!skeletonManagerService)
1111
+ const { drawings: r, unitId: s, subUnitId: o } = this._copyInfo, { ranges: [d, l], mapFunc: g } = Qn([t, e]), { row: c, col: a } = g(d.startRow, d.startColumn), { row: h, col: u } = g(l.startRow, l.startColumn), m = (b = this._renderManagerService.getRenderById(s)) == null ? void 0 : b.with(q);
1112
+ if (!m)
1081
1113
  return { redos: [], undos: [] };
1082
- const copyRect = skeletonManagerService.attachRangeWithCoord({
1083
- startRow: copyRow,
1084
- endRow: copyRow,
1085
- startColumn: copyCol,
1086
- endColumn: copyCol
1087
- }), pasteRect = skeletonManagerService.attachRangeWithCoord({
1088
- startRow: pasteRow,
1089
- endRow: pasteRow,
1090
- startColumn: pasteCol,
1091
- endColumn: pasteCol
1114
+ const f = m.attachRangeWithCoord({
1115
+ startRow: c,
1116
+ endRow: c,
1117
+ startColumn: a,
1118
+ endColumn: a
1119
+ }), p = m.attachRangeWithCoord({
1120
+ startRow: h,
1121
+ endRow: h,
1122
+ startColumn: u,
1123
+ endColumn: u
1092
1124
  });
1093
- if (!copyRect || !pasteRect)
1125
+ if (!f || !p)
1094
1126
  return { redos: [], undos: [] };
1095
- const redos = [], undos = [], leftOffset = pasteRect.startX - copyRect.startX, topOffset = pasteRect.startY - copyRect.startY, rowOffset = pasteRow - copyRow, columnOffset = pasteCol - copyCol, isCut = copyInfo.copyType === COPY_TYPE.CUT, { _sheetDrawingService } = this;
1096
- return drawings.forEach((drawing) => {
1097
- const { transform, sheetTransform } = drawing;
1098
- if (!transform)
1127
+ const C = [], S = [], v = p.startX - f.startX, R = p.startY - f.startY, _ = h - c, I = u - a, w = n.copyType === _t.CUT, { _sheetDrawingService: O } = this;
1128
+ return r.forEach((A) => {
1129
+ const { transform: E, sheetTransform: M } = A;
1130
+ if (!E)
1099
1131
  return;
1100
- const drawingObject = {
1101
- ...drawing,
1102
- unitId,
1103
- subUnitId,
1104
- drawingId: isCut ? drawing.drawingId : Tools.generateRandomId(),
1132
+ const D = {
1133
+ ...A,
1134
+ unitId: s,
1135
+ subUnitId: o,
1136
+ drawingId: w ? A.drawingId : ge.generateRandomId(),
1105
1137
  transform: {
1106
- ...transform,
1107
- left: transform.left + leftOffset,
1108
- top: transform.top + topOffset
1138
+ ...E,
1139
+ left: E.left + v,
1140
+ top: E.top + R
1109
1141
  },
1110
1142
  sheetTransform: {
1111
- to: { ...sheetTransform.to, row: sheetTransform.to.row + rowOffset, column: sheetTransform.to.column + columnOffset },
1112
- from: { ...sheetTransform.from, row: sheetTransform.from.row + rowOffset, column: sheetTransform.from.column + columnOffset }
1143
+ to: { ...M.to, row: M.to.row + _, column: M.to.column + I },
1144
+ from: { ...M.from, row: M.from.row + _, column: M.from.column + I }
1113
1145
  }
1114
1146
  };
1115
- if (isCut) {
1116
- const { undo, redo, objects } = _sheetDrawingService.getBatchUpdateOp([drawingObject]);
1117
- redos.push({
1118
- id: SetDrawingApplyMutation.id,
1147
+ if (w) {
1148
+ const { undo: U, redo: x, objects: Z } = O.getBatchUpdateOp([D]);
1149
+ C.push({
1150
+ id: T.id,
1119
1151
  params: {
1120
- unitId,
1121
- subUnitId,
1122
- type: DrawingApplyType.UPDATE,
1123
- op: redo,
1124
- objects
1152
+ unitId: s,
1153
+ subUnitId: o,
1154
+ type: P.UPDATE,
1155
+ op: x,
1156
+ objects: Z
1125
1157
  }
1126
- }), undos.push({
1127
- id: SetDrawingApplyMutation.id,
1158
+ }), S.push({
1159
+ id: T.id,
1128
1160
  params: {
1129
- unitId,
1130
- subUnitId,
1131
- type: DrawingApplyType.UPDATE,
1132
- op: undo,
1133
- objects
1161
+ unitId: s,
1162
+ subUnitId: o,
1163
+ type: P.UPDATE,
1164
+ op: U,
1165
+ objects: Z
1134
1166
  }
1135
1167
  });
1136
1168
  } else {
1137
- const { undo, redo, objects } = _sheetDrawingService.getBatchAddOp([drawingObject]);
1138
- redos.push({ id: SetDrawingApplyMutation.id, params: { op: redo, unitId, subUnitId, objects, type: DrawingApplyType.INSERT } }), undos.push({ id: SetDrawingApplyMutation.id, params: { op: undo, unitId, subUnitId, objects, type: DrawingApplyType.REMOVE } });
1169
+ const { undo: U, redo: x, objects: Z } = O.getBatchAddOp([D]);
1170
+ C.push({ id: T.id, params: { op: x, unitId: s, subUnitId: o, objects: Z, type: P.INSERT } }), S.push({ id: T.id, params: { op: U, unitId: s, subUnitId: o, objects: Z, type: P.REMOVE } });
1139
1171
  }
1140
1172
  }), {
1141
- redos,
1142
- undos
1173
+ redos: C,
1174
+ undos: S
1143
1175
  };
1144
1176
  }
1145
- }, __name(_a5, "SheetsDrawingCopyPasteController"), _a5);
1146
- SheetsDrawingCopyPasteController = __decorateClass$5([
1147
- __decorateParam$5(0, ISheetClipboardService),
1148
- __decorateParam$5(1, IRenderManagerService),
1149
- __decorateParam$5(2, ISheetDrawingService)
1150
- ], SheetsDrawingCopyPasteController);
1151
- var __defProp$4 = Object.defineProperty, __getOwnPropDesc$4 = Object.getOwnPropertyDescriptor, __decorateClass$4 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
1152
- for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$4(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
1153
- (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
1154
- return kind && result && __defProp$4(target, key, result), result;
1155
- }, "__decorateClass$4"), __decorateParam$4 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$4"), _a6;
1156
- let SheetDrawingPermissionController = (_a6 = class extends Disposable {
1157
- constructor(_drawingManagerService, _renderManagerService, _permissionService, _univerInstanceService, _userManagerService) {
1158
- super(), this._drawingManagerService = _drawingManagerService, this._renderManagerService = _renderManagerService, this._permissionService = _permissionService, this._univerInstanceService = _univerInstanceService, this._userManagerService = _userManagerService, this._initDrawingVisible(), this._initDrawingEditable(), this._initViewPermissionChange(), this._initEditPermissionChange();
1177
+ };
1178
+ je = Ni([
1179
+ qe(0, er),
1180
+ qe(1, J),
1181
+ qe(2, F)
1182
+ ], je);
1183
+ var ji = Object.defineProperty, Wi = Object.getOwnPropertyDescriptor, xi = (i, e, n, t) => {
1184
+ for (var r = t > 1 ? void 0 : t ? Wi(e, n) : e, s = i.length - 1, o; s >= 0; s--)
1185
+ (o = i[s]) && (r = (t ? o(e, n, r) : o(r)) || r);
1186
+ return t && r && ji(e, n, r), r;
1187
+ }, he = (i, e) => (n, t) => e(n, t, i);
1188
+ let We = class extends ie {
1189
+ constructor(i, e, n, t, r) {
1190
+ super(), this._drawingManagerService = i, this._renderManagerService = e, this._permissionService = n, this._univerInstanceService = t, this._userManagerService = r, this._initDrawingVisible(), this._initDrawingEditable(), this._initViewPermissionChange(), this._initEditPermissionChange();
1159
1191
  }
1160
1192
  _initDrawingVisible() {
1161
- const workbook$ = this._univerInstanceService.getCurrentTypeOfUnit$(UniverInstanceType.UNIVER_SHEET);
1193
+ const i = this._univerInstanceService.getCurrentTypeOfUnit$(Y.UNIVER_SHEET);
1162
1194
  this.disposeWithMe(
1163
- combineLatest([workbook$, this._userManagerService.currentUser$]).subscribe(([workbook, _]) => {
1164
- if (!workbook) {
1195
+ Ce([i, this._userManagerService.currentUser$]).subscribe(([e, n]) => {
1196
+ if (!e) {
1165
1197
  this._drawingManagerService.setDrawingVisible(!1);
1166
1198
  return;
1167
1199
  }
1168
- workbook.activeSheet$.subscribe((sheet) => {
1169
- if (!sheet) {
1200
+ e.activeSheet$.subscribe((t) => {
1201
+ if (!t) {
1170
1202
  this._drawingManagerService.setDrawingVisible(!1);
1171
1203
  return;
1172
1204
  }
1173
- const unitId = workbook.getUnitId(), subUnitId = sheet.getSheetId();
1174
- if (this._permissionService.composePermission([new WorkbookViewPermission(unitId).id, new WorksheetViewPermission(unitId, subUnitId).id]).every((permission) => permission.value))
1205
+ const r = e.getUnitId(), s = t.getSheetId();
1206
+ if (this._permissionService.composePermission([new Ct(r).id, new Je(r, s).id]).every((d) => d.value))
1175
1207
  this._drawingManagerService.setDrawingVisible(!0);
1176
1208
  else {
1177
1209
  this._drawingManagerService.setDrawingVisible(!1);
1178
- const unitId2 = workbook.getUnitId(), subUnitId2 = sheet.getSheetId(), drawingData = this._drawingManagerService.getDrawingData(unitId2, subUnitId2), drawingDataValues = Object.values(drawingData), renderObject = this._renderManagerService.getRenderById(unitId2), scene = renderObject == null ? void 0 : renderObject.scene;
1179
- if (scene == null)
1210
+ const d = e.getUnitId(), l = t.getSheetId(), g = this._drawingManagerService.getDrawingData(d, l), c = Object.values(g), a = this._renderManagerService.getRenderById(d), h = a == null ? void 0 : a.scene;
1211
+ if (h == null)
1180
1212
  return;
1181
- scene.getAllObjectsByOrder().forEach((object) => {
1182
- object.classType === RENDER_CLASS_TYPE.IMAGE && drawingDataValues.some((item) => object.oKey.includes(item.drawingId)) && scene.removeObject(object);
1213
+ h.getAllObjectsByOrder().forEach((m) => {
1214
+ m.classType === de.IMAGE && c.some((f) => m.oKey.includes(f.drawingId)) && h.removeObject(m);
1183
1215
  });
1184
1216
  }
1185
1217
  });
@@ -1187,28 +1219,28 @@ let SheetDrawingPermissionController = (_a6 = class extends Disposable {
1187
1219
  );
1188
1220
  }
1189
1221
  _initDrawingEditable() {
1190
- const workbook$ = this._univerInstanceService.getCurrentTypeOfUnit$(UniverInstanceType.UNIVER_SHEET);
1222
+ const i = this._univerInstanceService.getCurrentTypeOfUnit$(Y.UNIVER_SHEET);
1191
1223
  this.disposeWithMe(
1192
- combineLatest([workbook$, this._userManagerService.currentUser$]).subscribe(([workbook, _]) => {
1193
- if (!workbook) {
1224
+ Ce([i, this._userManagerService.currentUser$]).subscribe(([e, n]) => {
1225
+ if (!e) {
1194
1226
  this._drawingManagerService.setDrawingEditable(!1);
1195
1227
  return;
1196
1228
  }
1197
- workbook.activeSheet$.subscribe((sheet) => {
1198
- if (!sheet) {
1229
+ e.activeSheet$.subscribe((t) => {
1230
+ if (!t) {
1199
1231
  this._drawingManagerService.setDrawingEditable(!1);
1200
1232
  return;
1201
1233
  }
1202
- const unitId = workbook.getUnitId(), subUnitId = sheet.getSheetId();
1203
- if (this._permissionService.composePermission([new WorkbookEditablePermission(unitId).id, new WorksheetEditPermission(unitId, subUnitId).id]).every((permission) => permission.value))
1234
+ const r = e.getUnitId(), s = t.getSheetId();
1235
+ if (this._permissionService.composePermission([new tt(r).id, new Te(r, s).id]).every((d) => d.value))
1204
1236
  this._drawingManagerService.setDrawingEditable(!0);
1205
1237
  else {
1206
1238
  this._drawingManagerService.setDrawingEditable(!1);
1207
- const unitId2 = workbook.getUnitId(), subUnitId2 = sheet.getSheetId(), drawingData = this._drawingManagerService.getDrawingData(unitId2, subUnitId2), drawingDataValues = Object.values(drawingData), renderObject = this._renderManagerService.getRenderById(unitId2), scene = renderObject == null ? void 0 : renderObject.scene;
1208
- if (scene == null)
1239
+ const d = e.getUnitId(), l = t.getSheetId(), g = this._drawingManagerService.getDrawingData(d, l), c = Object.values(g), a = this._renderManagerService.getRenderById(d), h = a == null ? void 0 : a.scene;
1240
+ if (h == null)
1209
1241
  return;
1210
- scene.getAllObjectsByOrder().forEach((object) => {
1211
- object.classType === RENDER_CLASS_TYPE.IMAGE && drawingDataValues.some((item) => object.oKey.includes(item.drawingId)) && scene.detachTransformerFrom(object);
1242
+ h.getAllObjectsByOrder().forEach((m) => {
1243
+ m.classType === de.IMAGE && c.some((f) => m.oKey.includes(f.drawingId)) && h.detachTransformerFrom(m);
1212
1244
  });
1213
1245
  }
1214
1246
  });
@@ -1216,1344 +1248,1346 @@ let SheetDrawingPermissionController = (_a6 = class extends Disposable {
1216
1248
  );
1217
1249
  }
1218
1250
  _initViewPermissionChange() {
1219
- const workbook$ = this._univerInstanceService.getCurrentTypeOfUnit$(UniverInstanceType.UNIVER_SHEET);
1251
+ const i = this._univerInstanceService.getCurrentTypeOfUnit$(Y.UNIVER_SHEET);
1220
1252
  this.disposeWithMe(
1221
- combineLatest([workbook$, this._userManagerService.currentUser$]).subscribe(([workbook, _]) => {
1222
- workbook && workbook.activeSheet$.subscribe((sheet) => {
1223
- var _a11;
1224
- if (!sheet)
1253
+ Ce([i, this._userManagerService.currentUser$]).subscribe(([e, n]) => {
1254
+ e && e.activeSheet$.subscribe((t) => {
1255
+ var a;
1256
+ if (!t)
1225
1257
  return;
1226
- const unitId = workbook.getUnitId(), subUnitId = sheet.getSheetId();
1227
- let initialViewPermission = !0;
1228
- const renderObject = this._renderManagerService.getRenderById(unitId), scene = renderObject == null ? void 0 : renderObject.scene;
1229
- if (scene == null)
1258
+ const r = e.getUnitId(), s = t.getSheetId();
1259
+ let o = !0;
1260
+ const d = this._renderManagerService.getRenderById(r), l = d == null ? void 0 : d.scene;
1261
+ if (l == null)
1230
1262
  return;
1231
- const transformer = scene.getTransformerByCreate(), worksheetViewPermission$ = this._permissionService.composePermission$([new WorkbookViewPermission(unitId).id, new WorksheetViewPermission(unitId, subUnitId).id]).pipe(map((permissions) => permissions.every((item) => item.value)));
1232
- worksheetViewPermission$ == null || worksheetViewPermission$.pipe(
1233
- filter((permission) => permission !== initialViewPermission),
1234
- distinctUntilChanged()
1263
+ const g = l.getTransformerByCreate(), c = this._permissionService.composePermission$([new Ct(r).id, new Je(r, s).id]).pipe(Ee((h) => h.every((u) => u.value)));
1264
+ c == null || c.pipe(
1265
+ re((h) => h !== o),
1266
+ Ie()
1235
1267
  ).subscribe({
1236
- next: /* @__PURE__ */ __name((permission) => {
1237
- initialViewPermission = permission, this._drawingManagerService.setDrawingVisible(permission);
1238
- const objects = scene.getAllObjectsByOrder(), drawingData = this._drawingManagerService.getDrawingData(unitId, subUnitId), drawingDataValues = Object.values(drawingData);
1239
- permission ? this._drawingManagerService.addNotification(drawingDataValues) : (objects.forEach((object) => {
1240
- object.classType === RENDER_CLASS_TYPE.IMAGE && drawingDataValues.some((item) => object.oKey.includes(item.drawingId)) && scene.removeObject(object);
1241
- }), transformer.clearSelectedObjects());
1242
- }, "next")
1243
- }), (_a11 = this._permissionService.getPermissionPoint$(new WorksheetViewPermission(unitId, subUnitId).id)) == null || _a11.pipe(
1244
- filter((permission) => permission.value !== initialViewPermission),
1245
- distinctUntilChanged()
1268
+ next: (h) => {
1269
+ o = h, this._drawingManagerService.setDrawingVisible(h);
1270
+ const u = l.getAllObjectsByOrder(), m = this._drawingManagerService.getDrawingData(r, s), f = Object.values(m);
1271
+ h ? this._drawingManagerService.addNotification(f) : (u.forEach((p) => {
1272
+ p.classType === de.IMAGE && f.some((C) => p.oKey.includes(C.drawingId)) && l.removeObject(p);
1273
+ }), g.clearSelectedObjects());
1274
+ }
1275
+ }), (a = this._permissionService.getPermissionPoint$(new Je(r, s).id)) == null || a.pipe(
1276
+ re((h) => h.value !== o),
1277
+ Ie()
1246
1278
  ).subscribe({
1247
- complete: /* @__PURE__ */ __name(() => {
1248
- initialViewPermission = !0, this._drawingManagerService.setDrawingVisible(!0);
1249
- const drawingData = this._drawingManagerService.getDrawingData(unitId, subUnitId), drawingDataValues = Object.values(drawingData);
1250
- this._drawingManagerService.addNotification(drawingDataValues);
1251
- }, "complete")
1279
+ complete: () => {
1280
+ o = !0, this._drawingManagerService.setDrawingVisible(!0);
1281
+ const h = this._drawingManagerService.getDrawingData(r, s), u = Object.values(h);
1282
+ this._drawingManagerService.addNotification(u);
1283
+ }
1252
1284
  });
1253
1285
  });
1254
1286
  })
1255
1287
  );
1256
1288
  }
1257
1289
  _initEditPermissionChange() {
1258
- const workbook$ = this._univerInstanceService.getCurrentTypeOfUnit$(UniverInstanceType.UNIVER_SHEET);
1290
+ const i = this._univerInstanceService.getCurrentTypeOfUnit$(Y.UNIVER_SHEET);
1259
1291
  this.disposeWithMe(
1260
- combineLatest([workbook$, this._userManagerService.currentUser$]).subscribe(([workbook, _]) => {
1261
- workbook && workbook.activeSheet$.subscribe((sheet) => {
1262
- var _a11;
1263
- if (!sheet)
1292
+ Ce([i, this._userManagerService.currentUser$]).subscribe(([e, n]) => {
1293
+ e && e.activeSheet$.subscribe((t) => {
1294
+ var a;
1295
+ if (!t)
1264
1296
  return;
1265
- const unitId = workbook.getUnitId(), subUnitId = sheet.getSheetId();
1266
- let initialEditPermission = !0;
1267
- const renderObject = this._renderManagerService.getRenderById(unitId), scene = renderObject == null ? void 0 : renderObject.scene;
1268
- if (scene == null)
1297
+ const r = e.getUnitId(), s = t.getSheetId();
1298
+ let o = !0;
1299
+ const d = this._renderManagerService.getRenderById(r), l = d == null ? void 0 : d.scene;
1300
+ if (l == null)
1269
1301
  return;
1270
- const transformer = scene.getTransformerByCreate(), composeWorksheetEditPermission = this._permissionService.composePermission$([new WorkbookEditablePermission(unitId).id, new WorksheetEditPermission(unitId, subUnitId).id]).pipe(map((permissions) => permissions.every((item) => item.value)));
1271
- composeWorksheetEditPermission == null || composeWorksheetEditPermission.pipe(
1272
- filter((permission) => permission !== initialEditPermission),
1273
- distinctUntilChanged()
1302
+ const g = l.getTransformerByCreate(), c = this._permissionService.composePermission$([new tt(r).id, new Te(r, s).id]).pipe(Ee((h) => h.every((u) => u.value)));
1303
+ c == null || c.pipe(
1304
+ re((h) => h !== o),
1305
+ Ie()
1274
1306
  ).subscribe({
1275
- next: /* @__PURE__ */ __name((permission) => {
1276
- initialEditPermission = permission, this._drawingManagerService.setDrawingEditable(permission);
1277
- const objects = scene.getAllObjectsByOrder(), drawingData = this._drawingManagerService.getDrawingData(unitId, subUnitId), drawingDataValues = Object.values(drawingData);
1278
- permission ? (objects.forEach((object) => {
1279
- object.classType === RENDER_CLASS_TYPE.IMAGE && drawingDataValues.some((item) => object.oKey.includes(item.drawingId)) && scene.attachTransformerTo(object);
1280
- }), this._drawingManagerService.addNotification(drawingDataValues)) : (objects.forEach((object) => {
1281
- object.classType === RENDER_CLASS_TYPE.IMAGE && drawingDataValues.some((item) => object.oKey.includes(item.drawingId)) && scene.detachTransformerFrom(object);
1282
- }), transformer.clearSelectedObjects());
1283
- }, "next")
1284
- }), (_a11 = this._permissionService.getPermissionPoint$(new WorksheetEditPermission(unitId, subUnitId).id)) == null || _a11.pipe(
1285
- filter((permission) => permission.value !== initialEditPermission),
1286
- distinctUntilChanged()
1307
+ next: (h) => {
1308
+ o = h, this._drawingManagerService.setDrawingEditable(h);
1309
+ const u = l.getAllObjectsByOrder(), m = this._drawingManagerService.getDrawingData(r, s), f = Object.values(m);
1310
+ h ? (u.forEach((p) => {
1311
+ p.classType === de.IMAGE && f.some((C) => p.oKey.includes(C.drawingId)) && l.attachTransformerTo(p);
1312
+ }), this._drawingManagerService.addNotification(f)) : (u.forEach((p) => {
1313
+ p.classType === de.IMAGE && f.some((C) => p.oKey.includes(C.drawingId)) && l.detachTransformerFrom(p);
1314
+ }), g.clearSelectedObjects());
1315
+ }
1316
+ }), (a = this._permissionService.getPermissionPoint$(new Te(r, s).id)) == null || a.pipe(
1317
+ re((h) => h.value !== o),
1318
+ Ie()
1287
1319
  ).subscribe({
1288
- complete: /* @__PURE__ */ __name(() => {
1289
- initialEditPermission = !0;
1290
- const unitId2 = workbook.getUnitId(), subUnitId2 = sheet.getSheetId(), drawingData = this._drawingManagerService.getDrawingData(unitId2, subUnitId2), drawingDataValues = Object.values(drawingData), renderObject2 = this._renderManagerService.getRenderById(unitId2), scene2 = renderObject2 == null ? void 0 : renderObject2.scene;
1291
- if (scene2 == null)
1320
+ complete: () => {
1321
+ o = !0;
1322
+ const h = e.getUnitId(), u = t.getSheetId(), m = this._drawingManagerService.getDrawingData(h, u), f = Object.values(m), p = this._renderManagerService.getRenderById(h), C = p == null ? void 0 : p.scene;
1323
+ if (C == null)
1292
1324
  return;
1293
- this._drawingManagerService.setDrawingEditable(!0), scene2.getAllObjectsByOrder().forEach((object) => {
1294
- object.classType === RENDER_CLASS_TYPE.IMAGE && drawingDataValues.some((item) => object.oKey.includes(item.drawingId)) && scene2.detachTransformerFrom(object);
1325
+ this._drawingManagerService.setDrawingEditable(!0), C.getAllObjectsByOrder().forEach((v) => {
1326
+ v.classType === de.IMAGE && f.some((R) => v.oKey.includes(R.drawingId)) && C.detachTransformerFrom(v);
1295
1327
  });
1296
- }, "complete")
1328
+ }
1297
1329
  });
1298
1330
  });
1299
1331
  })
1300
1332
  );
1301
1333
  }
1302
- }, __name(_a6, "SheetDrawingPermissionController"), _a6);
1303
- SheetDrawingPermissionController = __decorateClass$4([
1304
- __decorateParam$4(0, IDrawingManagerService),
1305
- __decorateParam$4(1, IRenderManagerService),
1306
- __decorateParam$4(2, IPermissionService),
1307
- __decorateParam$4(3, IUniverInstanceService),
1308
- __decorateParam$4(4, Inject(UserManagerService))
1309
- ], SheetDrawingPermissionController);
1310
- var __defProp$3 = Object.defineProperty, __getOwnPropDesc$3 = Object.getOwnPropertyDescriptor, __decorateClass$3 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
1311
- for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$3(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
1312
- (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
1313
- return kind && result && __defProp$3(target, key, result), result;
1314
- }, "__decorateClass$3"), __decorateParam$3 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$3"), _a7;
1315
- let SheetDrawingPrintingController = (_a7 = class extends Disposable {
1316
- constructor(_sheetPrintInterceptorService, _drawingRenderService, _drawingManagerService, _renderManagerService) {
1317
- super(), this._sheetPrintInterceptorService = _sheetPrintInterceptorService, this._drawingRenderService = _drawingRenderService, this._drawingManagerService = _drawingManagerService, this._renderManagerService = _renderManagerService, this._initPrinting();
1334
+ };
1335
+ We = xi([
1336
+ he(0, K),
1337
+ he(1, J),
1338
+ he(2, Rn),
1339
+ he(3, fe),
1340
+ he(4, W(In))
1341
+ ], We);
1342
+ var $i = Object.defineProperty, Li = Object.getOwnPropertyDescriptor, Bi = (i, e, n, t) => {
1343
+ for (var r = t > 1 ? void 0 : t ? Li(e, n) : e, s = i.length - 1, o; s >= 0; s--)
1344
+ (o = i[s]) && (r = (t ? o(e, n, r) : o(r)) || r);
1345
+ return t && r && $i(e, n, r), r;
1346
+ }, Oe = (i, e) => (n, t) => e(n, t, i);
1347
+ let xe = class extends ie {
1348
+ constructor(i, e, n, t) {
1349
+ super(), this._sheetPrintInterceptorService = i, this._drawingRenderService = e, this._drawingManagerService = n, this._renderManagerService = t, this._initPrinting();
1318
1350
  }
1319
1351
  _initPrinting() {
1320
1352
  this.disposeWithMe(
1321
1353
  this._sheetPrintInterceptorService.interceptor.intercept(
1322
1354
  this._sheetPrintInterceptorService.interceptor.getInterceptPoints().PRINTING_COMPONENT_COLLECT,
1323
1355
  {
1324
- handler: /* @__PURE__ */ __name((_param, pos, next) => {
1325
- const { unitId, scene, subUnitId } = pos, unitData = this._drawingManagerService.getDrawingDataForUnit(unitId), subUnitData = unitData == null ? void 0 : unitData[subUnitId];
1326
- return subUnitData && subUnitData.order.forEach((id) => {
1327
- this._drawingRenderService.renderDrawing(subUnitData.data[id], scene);
1328
- }), next();
1329
- }, "handler")
1356
+ handler: (i, e, n) => {
1357
+ const { unitId: t, scene: r, subUnitId: s } = e, o = this._drawingManagerService.getDrawingDataForUnit(t), d = o == null ? void 0 : o[s];
1358
+ return d && d.order.forEach((l) => {
1359
+ this._drawingRenderService.renderDrawing(d.data[l], r);
1360
+ }), n();
1361
+ }
1330
1362
  }
1331
1363
  )
1332
1364
  ), this.disposeWithMe(
1333
1365
  this._sheetPrintInterceptorService.interceptor.intercept(
1334
1366
  this._sheetPrintInterceptorService.interceptor.getInterceptPoints().PRINTING_RANGE,
1335
1367
  {
1336
- handler: /* @__PURE__ */ __name((range, pos, next) => {
1337
- const { unitId, subUnitId } = pos, renderer = this._renderManagerService.getRenderById(unitId);
1338
- if (!renderer)
1339
- return next(range);
1340
- const skeleton = renderer.with(SheetSkeletonManagerService).getWorksheetSkeleton(subUnitId);
1341
- if (!skeleton)
1342
- return next(range);
1343
- const unitData = this._drawingManagerService.getDrawingDataForUnit(unitId), subUnitData = unitData == null ? void 0 : unitData[pos.subUnitId];
1344
- if (!subUnitData)
1345
- return next(range);
1346
- const { scaleX, scaleY } = renderer.scene, newRange = range ? { ...range } : { startColumn: 0, endColumn: 0, endRow: 0, startRow: 0 }, data = subUnitData.order.map((key) => subUnitData.data[key]).filter((item) => item.drawingType !== DrawingTypeEnum.DRAWING_DOM);
1347
- return data.length ? (data.forEach((param) => {
1348
- if (!param.groupId && param.transform && Tools.isDefine(param.transform.left) && Tools.isDefine(param.transform.top) && Tools.isDefine(param.transform.width) && Tools.isDefine(param.transform.height)) {
1349
- const start = skeleton.skeleton.getCellPositionByOffset(param.transform.left, param.transform.top, scaleX, scaleY, { x: 0, y: 0 }), end = skeleton.skeleton.getCellPositionByOffset(param.transform.left + param.transform.width, param.transform.top + param.transform.height, scaleX, scaleY, { x: 0, y: 0 });
1350
- start.column < newRange.startColumn && (newRange.startColumn = start.column), start.row < newRange.startRow && (newRange.startRow = start.row), newRange.endRow < end.row && (newRange.endRow = end.row), newRange.endColumn < end.column && (newRange.endColumn = end.column);
1368
+ handler: (i, e, n) => {
1369
+ const { unitId: t, subUnitId: r } = e, s = this._renderManagerService.getRenderById(t);
1370
+ if (!s)
1371
+ return n(i);
1372
+ const o = s.with(q).getWorksheetSkeleton(r);
1373
+ if (!o)
1374
+ return n(i);
1375
+ const d = this._drawingManagerService.getDrawingDataForUnit(t), l = d == null ? void 0 : d[e.subUnitId];
1376
+ if (!l)
1377
+ return n(i);
1378
+ const { scaleX: g, scaleY: c } = s.scene, a = i ? { ...i } : { startColumn: 0, endColumn: 0, endRow: 0, startRow: 0 }, h = l.order.map((u) => l.data[u]).filter((u) => u.drawingType !== k.DRAWING_DOM);
1379
+ return h.length ? (h.forEach((u) => {
1380
+ if (!u.groupId && u.transform && ge.isDefine(u.transform.left) && ge.isDefine(u.transform.top) && ge.isDefine(u.transform.width) && ge.isDefine(u.transform.height)) {
1381
+ const m = o.skeleton.getCellIndexByOffset(u.transform.left, u.transform.top, g, c, { x: 0, y: 0 }), f = o.skeleton.getCellIndexByOffset(u.transform.left + u.transform.width, u.transform.top + u.transform.height, g, c, { x: 0, y: 0 });
1382
+ m.column < a.startColumn && (a.startColumn = m.column), m.row < a.startRow && (a.startRow = m.row), a.endRow < f.row && (a.endRow = f.row), a.endColumn < f.column && (a.endColumn = f.column);
1351
1383
  }
1352
- }), next(newRange)) : next(range);
1353
- }, "handler")
1384
+ }), n(a)) : n(i);
1385
+ }
1354
1386
  }
1355
1387
  )
1356
1388
  );
1357
1389
  }
1358
- }, __name(_a7, "SheetDrawingPrintingController"), _a7);
1359
- SheetDrawingPrintingController = __decorateClass$3([
1360
- __decorateParam$3(0, Inject(SheetPrintInterceptorService)),
1361
- __decorateParam$3(1, Inject(DrawingRenderService)),
1362
- __decorateParam$3(2, IDrawingManagerService),
1363
- __decorateParam$3(3, IRenderManagerService)
1364
- ], SheetDrawingPrintingController);
1365
- var __defProp$2 = Object.defineProperty, __getOwnPropDesc$2 = Object.getOwnPropertyDescriptor, __decorateClass$2 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
1366
- for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$2(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
1367
- (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
1368
- return kind && result && __defProp$2(target, key, result), result;
1369
- }, "__decorateClass$2"), __decorateParam$2 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$2");
1370
- const UPDATE_COMMANDS = [
1371
- InsertRowCommand.id,
1372
- InsertColCommand.id,
1373
- RemoveRowCommand.id,
1374
- RemoveColCommand.id,
1375
- DeleteRangeMoveLeftCommand.id,
1376
- DeleteRangeMoveUpCommand.id,
1377
- InsertRangeMoveDownCommand.id,
1378
- InsertRangeMoveRightCommand.id,
1379
- DeltaRowHeightCommand.id,
1380
- SetRowHeightCommand.id,
1381
- DeltaColumnWidthCommand.id,
1382
- SetColWidthCommand.id,
1383
- SetRowHiddenCommand.id,
1384
- SetSpecificRowsVisibleCommand.id,
1385
- SetSpecificColsVisibleCommand.id,
1386
- SetColHiddenCommand.id,
1387
- MoveColsCommand.id,
1388
- MoveRowsCommand.id,
1389
- MoveRangeCommand.id
1390
- ], REFRESH_MUTATIONS = [
1391
- SetRowVisibleMutation.id,
1392
- SetRowHiddenMutation.id,
1393
- SetColVisibleMutation.id,
1394
- SetColHiddenMutation.id,
1395
- SetWorksheetRowHeightMutation.id,
1396
- SetWorksheetColWidthMutation.id
1390
+ };
1391
+ xe = Bi([
1392
+ Oe(0, W(tr)),
1393
+ Oe(1, W(kn)),
1394
+ Oe(2, K),
1395
+ Oe(3, J)
1396
+ ], xe);
1397
+ var Gi = Object.defineProperty, Vi = Object.getOwnPropertyDescriptor, ki = (i, e, n, t) => {
1398
+ for (var r = t > 1 ? void 0 : t ? Vi(e, n) : e, s = i.length - 1, o; s >= 0; s--)
1399
+ (o = i[s]) && (r = (t ? o(e, n, r) : o(r)) || r);
1400
+ return t && r && Gi(e, n, r), r;
1401
+ }, Q = (i, e) => (n, t) => e(n, t, i);
1402
+ const Yi = [
1403
+ Ot.id,
1404
+ Tt.id,
1405
+ Pt.id,
1406
+ Et.id,
1407
+ Ut.id,
1408
+ At.id,
1409
+ Nt.id,
1410
+ jt.id,
1411
+ nt.id,
1412
+ rt.id,
1413
+ Wt.id,
1414
+ xt.id,
1415
+ $t.id,
1416
+ Lt.id,
1417
+ Bt.id,
1418
+ Gt.id,
1419
+ Vt.id,
1420
+ kt.id,
1421
+ Yt.id
1422
+ ], Fi = [
1423
+ _r.id,
1424
+ vr.id,
1425
+ Sr.id,
1426
+ Cr.id,
1427
+ Ir.id,
1428
+ Rr.id
1397
1429
  ];
1398
- var _a8;
1399
- let SheetDrawingTransformAffectedController = (_a8 = class extends Disposable {
1400
- constructor(_context, _renderManagerService, _commandService, _selectionRenderService, _skeletonManagerService, _sheetInterceptorService, _sheetDrawingService, _drawingManagerService, _univerInstanceService) {
1401
- super(), this._context = _context, this._renderManagerService = _renderManagerService, this._commandService = _commandService, this._selectionRenderService = _selectionRenderService, this._skeletonManagerService = _skeletonManagerService, this._sheetInterceptorService = _sheetInterceptorService, this._sheetDrawingService = _sheetDrawingService, this._drawingManagerService = _drawingManagerService, this._univerInstanceService = _univerInstanceService, this._sheetInterceptorListener(), this._commandListener(), this._sheetRefreshListener();
1430
+ let ot = class extends ie {
1431
+ constructor(i, e, n, t, r, s, o, d, l) {
1432
+ super(), this._context = i, this._renderManagerService = e, this._commandService = n, this._selectionRenderService = t, this._skeletonManagerService = r, this._sheetInterceptorService = s, this._sheetDrawingService = o, this._drawingManagerService = d, this._univerInstanceService = l, this._sheetInterceptorListener(), this._commandListener(), this._sheetRefreshListener();
1402
1433
  }
1403
1434
  _sheetInterceptorListener() {
1404
1435
  this.disposeWithMe(
1405
1436
  this._sheetInterceptorService.interceptCommand({
1406
- getMutations: /* @__PURE__ */ __name((commandInfo) => {
1407
- if (!UPDATE_COMMANDS.includes(commandInfo.id))
1437
+ getMutations: (i) => {
1438
+ if (!Yi.includes(i.id))
1408
1439
  return { redos: [], undos: [] };
1409
- if (commandInfo.params == null)
1440
+ if (i.params == null)
1410
1441
  return { redos: [], undos: [] };
1411
- const cId = commandInfo.id;
1412
- if (cId === InsertRowCommand.id)
1413
- return this._moveRowInterceptor(commandInfo.params, "insert");
1414
- if ([MoveColsCommand.id, MoveRowsCommand.id, MoveRangeCommand.id].includes(cId))
1415
- return this._moveRangeInterceptor(commandInfo.params);
1416
- if (cId === InsertColCommand.id)
1417
- return this._moveColInterceptor(commandInfo.params, "insert");
1418
- if (cId === RemoveRowCommand.id)
1419
- return this._moveRowInterceptor(commandInfo.params, "remove");
1420
- if (cId === RemoveColCommand.id)
1421
- return this._moveColInterceptor(commandInfo.params, "remove");
1422
- if (cId === DeleteRangeMoveLeftCommand.id) {
1423
- const { range } = commandInfo.params;
1442
+ const e = i.id;
1443
+ if (e === Ot.id)
1444
+ return this._moveRowInterceptor(i.params, "insert");
1445
+ if ([Vt.id, kt.id, Yt.id].includes(e))
1446
+ return this._moveRangeInterceptor(i.params);
1447
+ if (e === Tt.id)
1448
+ return this._moveColInterceptor(i.params, "insert");
1449
+ if (e === Pt.id)
1450
+ return this._moveRowInterceptor(i.params, "remove");
1451
+ if (e === Et.id)
1452
+ return this._moveColInterceptor(i.params, "remove");
1453
+ if (e === Ut.id) {
1454
+ const { range: n } = i.params;
1424
1455
  return this._getRangeMoveUndo(
1425
- range,
1456
+ n,
1426
1457
  0
1427
1458
  /* deleteLeft */
1428
1459
  );
1429
- } else if (cId === DeleteRangeMoveUpCommand.id) {
1430
- const { range } = commandInfo.params;
1460
+ } else if (e === At.id) {
1461
+ const { range: n } = i.params;
1431
1462
  return this._getRangeMoveUndo(
1432
- range,
1463
+ n,
1433
1464
  1
1434
1465
  /* deleteUp */
1435
1466
  );
1436
- } else if (cId === InsertRangeMoveDownCommand.id) {
1437
- const { range } = commandInfo.params;
1467
+ } else if (e === Nt.id) {
1468
+ const { range: n } = i.params;
1438
1469
  return this._getRangeMoveUndo(
1439
- range,
1470
+ n,
1440
1471
  2
1441
1472
  /* insertDown */
1442
1473
  );
1443
- } else if (cId === InsertRangeMoveRightCommand.id) {
1444
- const { range } = commandInfo.params;
1474
+ } else if (e === jt.id) {
1475
+ const { range: n } = i.params;
1445
1476
  return this._getRangeMoveUndo(
1446
- range,
1477
+ n,
1447
1478
  3
1448
1479
  /* insertRight */
1449
1480
  );
1450
- } else if (cId === SetRowHiddenCommand.id || cId === SetSpecificRowsVisibleCommand.id) {
1451
- const params = commandInfo.params, { unitId, subUnitId, ranges } = params;
1452
- return this._getDrawingUndoForRowVisible(unitId, subUnitId, ranges);
1453
- } else if (cId === SetSpecificColsVisibleCommand.id || cId === SetColHiddenCommand.id) {
1454
- const params = commandInfo.params, { unitId, subUnitId, ranges } = params;
1455
- return this._getDrawingUndoForColVisible(unitId, subUnitId, ranges);
1456
- } else if (cId === DeltaRowHeightCommand.id || cId === SetRowHeightCommand.id || cId === DeltaColumnWidthCommand.id || cId === SetColWidthCommand.id) {
1457
- const params = commandInfo.params, { unitId, subUnitId, ranges } = params, isRow = cId === DeltaRowHeightCommand.id || cId === SetRowHeightCommand.id;
1458
- return this._getDrawingUndoForRowAndColSize(unitId, subUnitId, ranges, isRow);
1481
+ } else if (e === $t.id || e === Lt.id) {
1482
+ const n = i.params, { unitId: t, subUnitId: r, ranges: s } = n;
1483
+ return this._getDrawingUndoForRowVisible(t, r, s);
1484
+ } else if (e === Bt.id || e === Gt.id) {
1485
+ const n = i.params, { unitId: t, subUnitId: r, ranges: s } = n;
1486
+ return this._getDrawingUndoForColVisible(t, r, s);
1487
+ } else if (e === nt.id || e === rt.id || e === Wt.id || e === xt.id) {
1488
+ const n = i.params, { unitId: t, subUnitId: r, ranges: s } = n, o = e === nt.id || e === rt.id;
1489
+ return this._getDrawingUndoForRowAndColSize(t, r, s, o);
1459
1490
  }
1460
1491
  return { redos: [], undos: [] };
1461
- }, "getMutations")
1492
+ }
1462
1493
  })
1463
1494
  );
1464
1495
  }
1465
- _getRangeMoveUndo(range, type) {
1466
- const newParams = getSheetCommandTarget(this._univerInstanceService);
1467
- if (newParams == null)
1496
+ _getRangeMoveUndo(i, e) {
1497
+ const n = ce(this._univerInstanceService);
1498
+ if (n == null)
1468
1499
  return { redos: [], undos: [] };
1469
- const unitId = newParams.unitId, subUnitId = newParams.subUnitId, redos = [], undos = [], drawingData = this._sheetDrawingService.getDrawingData(unitId, subUnitId), updateDrawings = [], deleteDrawings = [];
1470
- if (Object.keys(drawingData).forEach((drawingId) => {
1471
- const drawing = drawingData[drawingId], { updateDrawings: updateDrawingsPart, deleteDrawings: deleteDrawingsPart } = this._getUpdateOrDeleteDrawings(range, type, drawing);
1472
- updateDrawings.push(...updateDrawingsPart), deleteDrawings.push(...deleteDrawingsPart);
1473
- }), updateDrawings.length === 0 && deleteDrawings.length === 0)
1500
+ const t = n.unitId, r = n.subUnitId, s = [], o = [], d = this._sheetDrawingService.getDrawingData(t, r), l = [], g = [];
1501
+ if (Object.keys(d).forEach((c) => {
1502
+ const a = d[c], { updateDrawings: h, deleteDrawings: u } = this._getUpdateOrDeleteDrawings(i, e, a);
1503
+ l.push(...h), g.push(...u);
1504
+ }), l.length === 0 && g.length === 0)
1474
1505
  return { redos: [], undos: [] };
1475
- if (updateDrawings.length > 0) {
1476
- const updateJsonOp = this._sheetDrawingService.getBatchUpdateOp(updateDrawings), { undo, redo, objects } = updateJsonOp;
1477
- redos.push({ id: SetDrawingApplyMutation.id, params: { unitId, subUnitId, op: redo, objects, type: DrawingApplyType.UPDATE } }), undos.push({ id: SetDrawingApplyMutation.id, params: { unitId, subUnitId, op: undo, objects, type: DrawingApplyType.UPDATE } });
1506
+ if (l.length > 0) {
1507
+ const c = this._sheetDrawingService.getBatchUpdateOp(l), { undo: a, redo: h, objects: u } = c;
1508
+ s.push({ id: T.id, params: { unitId: t, subUnitId: r, op: h, objects: u, type: P.UPDATE } }), o.push({ id: T.id, params: { unitId: t, subUnitId: r, op: a, objects: u, type: P.UPDATE } });
1478
1509
  }
1479
- if (deleteDrawings.length > 0) {
1480
- const deleteJsonOp = this._sheetDrawingService.getBatchRemoveOp(deleteDrawings), deleteUndo = deleteJsonOp.undo, deleteRedo = deleteJsonOp.redo, deleteObjects = deleteJsonOp.objects;
1481
- redos.push({ id: SetDrawingApplyMutation.id, params: { unitId, subUnitId, op: deleteRedo, objects: deleteObjects, type: DrawingApplyType.REMOVE } }), undos.push({ id: SetDrawingApplyMutation.id, params: { unitId, subUnitId, op: deleteUndo, objects: deleteObjects, type: DrawingApplyType.INSERT } });
1510
+ if (g.length > 0) {
1511
+ const c = this._sheetDrawingService.getBatchRemoveOp(g), a = c.undo, h = c.redo, u = c.objects;
1512
+ s.push({ id: T.id, params: { unitId: t, subUnitId: r, op: h, objects: u, type: P.REMOVE } }), o.push({ id: T.id, params: { unitId: t, subUnitId: r, op: a, objects: u, type: P.INSERT } });
1482
1513
  }
1483
- return redos.push({ id: ClearSheetDrawingTransformerOperation.id, params: [unitId] }), undos.push({ id: ClearSheetDrawingTransformerOperation.id, params: [unitId] }), {
1484
- redos,
1485
- undos
1514
+ return s.push({ id: j.id, params: [t] }), o.push({ id: j.id, params: [t] }), {
1515
+ redos: s,
1516
+ undos: o
1486
1517
  };
1487
1518
  }
1488
- _getUpdateOrDeleteDrawings(range, type, drawing) {
1489
- const updateDrawings = [], deleteDrawings = [], { sheetTransform, anchorType = SheetDrawingAnchorType.Position, transform, unitId, subUnitId, drawingId } = drawing, { from, to } = sheetTransform, { row: fromRow, column: fromColumn } = from, { row: toRow, column: toColumn } = to;
1490
- if (sheetTransform == null || transform == null)
1519
+ _getUpdateOrDeleteDrawings(i, e, n) {
1520
+ const t = [], r = [], { sheetTransform: s, anchorType: o = y.Position, transform: d, unitId: l, subUnitId: g, drawingId: c } = n, { from: a, to: h } = s, { row: u, column: m } = a, { row: f, column: p } = h;
1521
+ if (s == null || d == null)
1491
1522
  return {
1492
- updateDrawings,
1493
- deleteDrawings
1523
+ updateDrawings: t,
1524
+ deleteDrawings: r
1494
1525
  };
1495
- const { startRow, endRow, startColumn, endColumn } = range;
1496
- let newSheetTransform = null, newTransform = null;
1497
- if (type === 0 && fromRow >= startRow && toRow <= endRow)
1498
- if (fromColumn >= startColumn && toColumn <= endColumn)
1499
- deleteDrawings.push({ unitId, subUnitId, drawingId });
1526
+ const { startRow: C, endRow: S, startColumn: v, endColumn: R } = i;
1527
+ let _ = null, I = null;
1528
+ if (e === 0 && u >= C && f <= S)
1529
+ if (m >= v && p <= R)
1530
+ r.push({ unitId: l, subUnitId: g, drawingId: c });
1500
1531
  else {
1501
- const param = this._shrinkCol(sheetTransform, transform, startColumn, endColumn, anchorType);
1502
- newSheetTransform = param == null ? void 0 : param.newSheetTransform, newTransform = param == null ? void 0 : param.newTransform;
1532
+ const w = this._shrinkCol(s, d, v, R, o);
1533
+ _ = w == null ? void 0 : w.newSheetTransform, I = w == null ? void 0 : w.newTransform;
1503
1534
  }
1504
- else if (type === 1 && fromColumn >= startColumn && toColumn <= endColumn)
1505
- if (fromRow >= startRow && toRow <= endRow)
1506
- deleteDrawings.push({ unitId, subUnitId, drawingId });
1535
+ else if (e === 1 && m >= v && p <= R)
1536
+ if (u >= C && f <= S)
1537
+ r.push({ unitId: l, subUnitId: g, drawingId: c });
1507
1538
  else {
1508
- const param = this._shrinkRow(sheetTransform, transform, startRow, endRow, anchorType);
1509
- newSheetTransform = param == null ? void 0 : param.newSheetTransform, newTransform = param == null ? void 0 : param.newTransform;
1539
+ const w = this._shrinkRow(s, d, C, S, o);
1540
+ _ = w == null ? void 0 : w.newSheetTransform, I = w == null ? void 0 : w.newTransform;
1510
1541
  }
1511
- else if (type === 2) {
1512
- const param = this._expandRow(sheetTransform, transform, startRow, endRow, anchorType);
1513
- newSheetTransform = param == null ? void 0 : param.newSheetTransform, newTransform = param == null ? void 0 : param.newTransform;
1514
- } else if (type === 3) {
1515
- const param = this._expandCol(sheetTransform, transform, startColumn, endColumn, anchorType);
1516
- newSheetTransform = param == null ? void 0 : param.newSheetTransform, newTransform = param == null ? void 0 : param.newTransform;
1542
+ else if (e === 2) {
1543
+ const w = this._expandRow(s, d, C, S, o);
1544
+ _ = w == null ? void 0 : w.newSheetTransform, I = w == null ? void 0 : w.newTransform;
1545
+ } else if (e === 3) {
1546
+ const w = this._expandCol(s, d, v, R, o);
1547
+ _ = w == null ? void 0 : w.newSheetTransform, I = w == null ? void 0 : w.newTransform;
1517
1548
  }
1518
- if (newSheetTransform != null && newTransform != null) {
1519
- const newTransform2 = drawingPositionToTransform(newSheetTransform, this._selectionRenderService, this._skeletonManagerService);
1520
- updateDrawings.push({ ...drawing, sheetTransform: newSheetTransform, transform: newTransform2 });
1549
+ if (_ != null && I != null) {
1550
+ const w = L(_, this._selectionRenderService, this._skeletonManagerService);
1551
+ t.push({ ...n, sheetTransform: _, transform: w });
1521
1552
  }
1522
- return { updateDrawings, deleteDrawings };
1553
+ return { updateDrawings: t, deleteDrawings: r };
1523
1554
  }
1524
- _remainDrawingSize(transform, updateDrawings, drawing) {
1525
- const newSheetTransform = transformToDrawingPosition({ ...transform }, this._selectionRenderService);
1526
- newSheetTransform != null && updateDrawings.push({
1527
- ...drawing,
1528
- sheetTransform: newSheetTransform
1555
+ _remainDrawingSize(i, e, n) {
1556
+ const t = N({ ...i }, this._selectionRenderService);
1557
+ t != null && e.push({
1558
+ ...n,
1559
+ sheetTransform: t
1529
1560
  });
1530
1561
  }
1531
1562
  // eslint-disable-next-line max-lines-per-function
1532
- _getDrawingUndoForColVisible(unitId, subUnitId, ranges) {
1533
- const drawingData = this._drawingManagerService.getDrawingData(unitId, subUnitId), updateDrawings = [], preUpdateDrawings = [];
1534
- if (Object.keys(drawingData).forEach((drawingId) => {
1535
- const drawing = drawingData[drawingId], { sheetTransform, transform, anchorType = SheetDrawingAnchorType.Position } = drawing;
1536
- if (anchorType === SheetDrawingAnchorType.None)
1537
- this._remainDrawingSize(transform, updateDrawings, drawing);
1563
+ _getDrawingUndoForColVisible(i, e, n) {
1564
+ const t = this._drawingManagerService.getDrawingData(i, e), r = [], s = [];
1565
+ if (Object.keys(t).forEach((c) => {
1566
+ const a = t[c], { sheetTransform: h, transform: u, anchorType: m = y.Position } = a;
1567
+ if (m === y.None)
1568
+ this._remainDrawingSize(u, r, a);
1538
1569
  else {
1539
- const { from, to } = sheetTransform, { row: fromRow, column: fromColumn } = from, { row: toRow, column: toColumn } = to;
1540
- for (let i = 0; i < ranges.length; i++) {
1541
- const range = ranges[i], { startRow, endRow, startColumn, endColumn } = range;
1542
- if (toColumn < startColumn)
1570
+ const { from: f, to: p } = h, { row: C, column: S } = f, { row: v, column: R } = p;
1571
+ for (let _ = 0; _ < n.length; _++) {
1572
+ const I = n[_], { startRow: w, endRow: O, startColumn: b, endColumn: A } = I;
1573
+ if (R < b)
1543
1574
  continue;
1544
- if (anchorType === SheetDrawingAnchorType.Position) {
1545
- let newSheetTransform2 = null, newTransform2 = null;
1546
- if (fromColumn >= startColumn && fromColumn <= endColumn) {
1547
- const selectionCell = this._skeletonManagerService.attachRangeWithCoord({ startColumn: fromColumn, endColumn, startRow: from.row, endRow: to.row });
1548
- if (selectionCell == null)
1575
+ if (m === y.Position) {
1576
+ let D = null, U = null;
1577
+ if (S >= b && S <= A) {
1578
+ const x = this._skeletonManagerService.attachRangeWithCoord({ startColumn: S, endColumn: A, startRow: f.row, endRow: p.row });
1579
+ if (x == null)
1549
1580
  return;
1550
- newTransform2 = { ...transform, left: selectionCell.startX };
1581
+ U = { ...u, left: x.startX };
1551
1582
  }
1552
- if (newTransform2 != null && (newSheetTransform2 = transformToDrawingPosition(newTransform2, this._selectionRenderService), newSheetTransform2 != null && newTransform2 != null)) {
1553
- updateDrawings.push({ ...drawing, sheetTransform: newSheetTransform2, transform: newTransform2 });
1583
+ if (U != null && (D = N(U, this._selectionRenderService), D != null && U != null)) {
1584
+ r.push({ ...a, sheetTransform: D, transform: U });
1554
1585
  break;
1555
1586
  }
1556
- this._remainDrawingSize(transform, updateDrawings, drawing);
1587
+ this._remainDrawingSize(u, r, a);
1557
1588
  continue;
1558
1589
  }
1559
- if (fromColumn >= startColumn && toColumn <= endColumn)
1590
+ if (S >= b && R <= A)
1560
1591
  continue;
1561
- let newSheetTransform = null, newTransform = null;
1562
- if (fromColumn >= startColumn && fromColumn <= endColumn) {
1563
- const selectionCell = this._skeletonManagerService.attachRangeWithCoord({ startColumn: fromColumn, endColumn, startRow: from.row, endRow: to.row });
1564
- if (selectionCell == null)
1592
+ let E = null, M = null;
1593
+ if (S >= b && S <= A) {
1594
+ const D = this._skeletonManagerService.attachRangeWithCoord({ startColumn: S, endColumn: A, startRow: f.row, endRow: p.row });
1595
+ if (D == null)
1565
1596
  return;
1566
- newTransform = {
1567
- ...transform,
1568
- left: (selectionCell == null ? void 0 : selectionCell.startX) || 0,
1569
- width: ((transform == null ? void 0 : transform.width) || 0) - selectionCell.endX + selectionCell.startX
1597
+ M = {
1598
+ ...u,
1599
+ left: (D == null ? void 0 : D.startX) || 0,
1600
+ width: ((u == null ? void 0 : u.width) || 0) - D.endX + D.startX
1570
1601
  };
1571
- } else if (toColumn >= startColumn && toColumn <= endColumn) {
1572
- const selectionCell = this._skeletonManagerService.attachRangeWithCoord({ startColumn, endColumn: toColumn, startRow: from.row, endRow: to.row });
1573
- if (selectionCell == null)
1602
+ } else if (R >= b && R <= A) {
1603
+ const D = this._skeletonManagerService.attachRangeWithCoord({ startColumn: b, endColumn: R, startRow: f.row, endRow: p.row });
1604
+ if (D == null)
1574
1605
  return;
1575
- newTransform = {
1576
- ...transform,
1577
- left: selectionCell.startX - ((transform == null ? void 0 : transform.width) || 0)
1606
+ M = {
1607
+ ...u,
1608
+ left: D.startX - ((u == null ? void 0 : u.width) || 0)
1578
1609
  };
1579
1610
  } else {
1580
- const selectionCell = this._skeletonManagerService.attachRangeWithCoord({ startColumn, endColumn, startRow: from.row, endRow: to.row });
1581
- if (selectionCell == null)
1611
+ const D = this._skeletonManagerService.attachRangeWithCoord({ startColumn: b, endColumn: A, startRow: f.row, endRow: p.row });
1612
+ if (D == null)
1582
1613
  return;
1583
- if (newTransform = {
1584
- ...transform,
1585
- width: ((transform == null ? void 0 : transform.width) || 0) - selectionCell.endX + selectionCell.startX
1586
- }, newSheetTransform = transformToDrawingPosition(newTransform, this._selectionRenderService), newSheetTransform != null && newTransform != null) {
1587
- preUpdateDrawings.push({ ...drawing, sheetTransform: newSheetTransform, transform: newTransform });
1614
+ if (M = {
1615
+ ...u,
1616
+ width: ((u == null ? void 0 : u.width) || 0) - D.endX + D.startX
1617
+ }, E = N(M, this._selectionRenderService), E != null && M != null) {
1618
+ s.push({ ...a, sheetTransform: E, transform: M });
1588
1619
  break;
1589
1620
  }
1590
1621
  }
1591
- if (newTransform != null && (newSheetTransform = transformToDrawingPosition(newTransform, this._selectionRenderService)), newTransform != null && newSheetTransform != null) {
1592
- updateDrawings.push({ ...drawing, sheetTransform: newSheetTransform, transform: newTransform });
1622
+ if (M != null && (E = N(M, this._selectionRenderService)), M != null && E != null) {
1623
+ r.push({ ...a, sheetTransform: E, transform: M });
1593
1624
  break;
1594
1625
  } else
1595
- this._remainDrawingSize(transform, updateDrawings, drawing);
1626
+ this._remainDrawingSize(u, r, a);
1596
1627
  }
1597
1628
  }
1598
- }), updateDrawings.length === 0 && preUpdateDrawings.length === 0)
1629
+ }), r.length === 0 && s.length === 0)
1599
1630
  return { redos: [], undos: [] };
1600
- const { redos, undos } = this._createUndoAndRedoMutation(unitId, subUnitId, updateDrawings), preRedos = [], preUndos = [];
1601
- if (preUpdateDrawings.length > 0) {
1602
- const { redos: redos2, undos: undos2 } = this._createUndoAndRedoMutation(unitId, subUnitId, preUpdateDrawings);
1603
- preRedos.push(...redos2), preUndos.push(...undos2);
1631
+ const { redos: o, undos: d } = this._createUndoAndRedoMutation(i, e, r), l = [], g = [];
1632
+ if (s.length > 0) {
1633
+ const { redos: c, undos: a } = this._createUndoAndRedoMutation(i, e, s);
1634
+ l.push(...c), g.push(...a);
1604
1635
  }
1605
1636
  return {
1606
- redos,
1607
- undos,
1608
- preRedos,
1609
- preUndos
1637
+ redos: o,
1638
+ undos: d,
1639
+ preRedos: l,
1640
+ preUndos: g
1610
1641
  };
1611
1642
  }
1612
- _createUndoAndRedoMutation(unitId, subUnitId, updateDrawings) {
1613
- const updateJsonOp = this._sheetDrawingService.getBatchUpdateOp(updateDrawings), { undo, redo, objects } = updateJsonOp, redos = [
1614
- { id: SetDrawingApplyMutation.id, params: { unitId, subUnitId, op: redo, objects, type: DrawingApplyType.UPDATE } },
1615
- { id: ClearSheetDrawingTransformerOperation.id, params: [unitId] }
1616
- ], undos = [
1617
- { id: SetDrawingApplyMutation.id, params: { unitId, subUnitId, op: undo, objects, type: DrawingApplyType.UPDATE } },
1618
- { id: ClearSheetDrawingTransformerOperation.id, params: [unitId] }
1643
+ _createUndoAndRedoMutation(i, e, n) {
1644
+ const t = this._sheetDrawingService.getBatchUpdateOp(n), { undo: r, redo: s, objects: o } = t, d = [
1645
+ { id: T.id, params: { unitId: i, subUnitId: e, op: s, objects: o, type: P.UPDATE } },
1646
+ { id: j.id, params: [i] }
1647
+ ], l = [
1648
+ { id: T.id, params: { unitId: i, subUnitId: e, op: r, objects: o, type: P.UPDATE } },
1649
+ { id: j.id, params: [i] }
1619
1650
  ];
1620
1651
  return {
1621
- redos,
1622
- undos
1652
+ redos: d,
1653
+ undos: l
1623
1654
  };
1624
1655
  }
1625
1656
  // eslint-disable-next-line max-lines-per-function
1626
- _getDrawingUndoForRowVisible(unitId, subUnitId, ranges) {
1627
- const drawingData = this._drawingManagerService.getDrawingData(unitId, subUnitId), updateDrawings = [], preUpdateDrawings = [];
1628
- if (Object.keys(drawingData).forEach((drawingId) => {
1629
- const drawing = drawingData[drawingId], { sheetTransform, transform, anchorType = SheetDrawingAnchorType.Position } = drawing;
1630
- if (anchorType === SheetDrawingAnchorType.None)
1631
- this._remainDrawingSize(transform, updateDrawings, drawing);
1657
+ _getDrawingUndoForRowVisible(i, e, n) {
1658
+ const t = this._drawingManagerService.getDrawingData(i, e), r = [], s = [];
1659
+ if (Object.keys(t).forEach((c) => {
1660
+ const a = t[c], { sheetTransform: h, transform: u, anchorType: m = y.Position } = a;
1661
+ if (m === y.None)
1662
+ this._remainDrawingSize(u, r, a);
1632
1663
  else {
1633
- const { from, to } = sheetTransform, { row: fromRow, column: fromColumn } = from, { row: toRow, column: toColumn } = to;
1634
- for (let i = 0; i < ranges.length; i++) {
1635
- const range = ranges[i], { startRow, endRow, startColumn, endColumn } = range;
1636
- if (toRow < startRow)
1664
+ const { from: f, to: p } = h, { row: C, column: S } = f, { row: v, column: R } = p;
1665
+ for (let _ = 0; _ < n.length; _++) {
1666
+ const I = n[_], { startRow: w, endRow: O, startColumn: b, endColumn: A } = I;
1667
+ if (v < w)
1637
1668
  continue;
1638
- if (anchorType === SheetDrawingAnchorType.Position) {
1639
- let newSheetTransform2 = null, newTransform2 = null;
1640
- if (fromRow >= startRow && fromRow <= endRow) {
1641
- const selectionCell = this._skeletonManagerService.attachRangeWithCoord({ startColumn: from.column, endColumn: to.column, startRow: fromRow, endRow });
1642
- if (selectionCell == null)
1669
+ if (m === y.Position) {
1670
+ let D = null, U = null;
1671
+ if (C >= w && C <= O) {
1672
+ const x = this._skeletonManagerService.attachRangeWithCoord({ startColumn: f.column, endColumn: p.column, startRow: C, endRow: O });
1673
+ if (x == null)
1643
1674
  return;
1644
- newTransform2 = { ...transform, top: selectionCell.startY };
1675
+ U = { ...u, top: x.startY };
1645
1676
  }
1646
- if (newTransform2 != null && (newSheetTransform2 = transformToDrawingPosition(newTransform2, this._selectionRenderService), newSheetTransform2 != null && newTransform2 != null)) {
1647
- updateDrawings.push({ ...drawing, sheetTransform: newSheetTransform2, transform: newTransform2 });
1677
+ if (U != null && (D = N(U, this._selectionRenderService), D != null && U != null)) {
1678
+ r.push({ ...a, sheetTransform: D, transform: U });
1648
1679
  break;
1649
1680
  }
1650
- this._remainDrawingSize(transform, updateDrawings, drawing);
1681
+ this._remainDrawingSize(u, r, a);
1651
1682
  continue;
1652
1683
  }
1653
- if (fromRow >= startRow && toRow <= endRow)
1684
+ if (C >= w && v <= O)
1654
1685
  continue;
1655
- let newSheetTransform = null, newTransform = null;
1656
- if (fromRow >= startRow && fromRow <= endRow) {
1657
- const selectionCell = this._skeletonManagerService.attachRangeWithCoord({ startColumn: from.column, endColumn: to.column, startRow: fromRow, endRow });
1658
- if (selectionCell == null)
1686
+ let E = null, M = null;
1687
+ if (C >= w && C <= O) {
1688
+ const D = this._skeletonManagerService.attachRangeWithCoord({ startColumn: f.column, endColumn: p.column, startRow: C, endRow: O });
1689
+ if (D == null)
1659
1690
  return;
1660
- newTransform = {
1661
- ...transform,
1662
- top: (selectionCell == null ? void 0 : selectionCell.startY) || 0,
1663
- height: ((transform == null ? void 0 : transform.height) || 0) - selectionCell.endY + selectionCell.startY
1691
+ M = {
1692
+ ...u,
1693
+ top: (D == null ? void 0 : D.startY) || 0,
1694
+ height: ((u == null ? void 0 : u.height) || 0) - D.endY + D.startY
1664
1695
  };
1665
- } else if (toRow >= startRow && toRow <= endRow) {
1666
- const selectionCell = this._skeletonManagerService.attachRangeWithCoord({ startColumn: from.column, endColumn: to.column, startRow, endRow: toRow });
1667
- if (selectionCell == null)
1696
+ } else if (v >= w && v <= O) {
1697
+ const D = this._skeletonManagerService.attachRangeWithCoord({ startColumn: f.column, endColumn: p.column, startRow: w, endRow: v });
1698
+ if (D == null)
1668
1699
  return;
1669
- newTransform = {
1670
- ...transform,
1671
- top: selectionCell.startY - ((transform == null ? void 0 : transform.height) || 0)
1700
+ M = {
1701
+ ...u,
1702
+ top: D.startY - ((u == null ? void 0 : u.height) || 0)
1672
1703
  };
1673
1704
  } else {
1674
- const selectionCell = this._skeletonManagerService.attachRangeWithCoord({ startColumn: from.column, endColumn: to.column, startRow, endRow });
1675
- if (selectionCell == null)
1705
+ const D = this._skeletonManagerService.attachRangeWithCoord({ startColumn: f.column, endColumn: p.column, startRow: w, endRow: O });
1706
+ if (D == null)
1676
1707
  return;
1677
- if (newTransform = {
1678
- ...transform,
1679
- height: ((transform == null ? void 0 : transform.height) || 0) - selectionCell.endY + selectionCell.startY
1680
- }, newSheetTransform = transformToDrawingPosition(newTransform, this._selectionRenderService), newSheetTransform != null && newTransform != null) {
1681
- preUpdateDrawings.push({ ...drawing, sheetTransform: newSheetTransform, transform: newTransform });
1708
+ if (M = {
1709
+ ...u,
1710
+ height: ((u == null ? void 0 : u.height) || 0) - D.endY + D.startY
1711
+ }, E = N(M, this._selectionRenderService), E != null && M != null) {
1712
+ s.push({ ...a, sheetTransform: E, transform: M });
1682
1713
  break;
1683
1714
  }
1684
1715
  }
1685
- if (newTransform != null && (newSheetTransform = transformToDrawingPosition(newTransform, this._selectionRenderService)), newTransform != null && newSheetTransform != null) {
1686
- updateDrawings.push({ ...drawing, sheetTransform: newSheetTransform, transform: newTransform });
1716
+ if (M != null && (E = N(M, this._selectionRenderService)), M != null && E != null) {
1717
+ r.push({ ...a, sheetTransform: E, transform: M });
1687
1718
  break;
1688
1719
  } else
1689
- this._remainDrawingSize(transform, updateDrawings, drawing);
1720
+ this._remainDrawingSize(u, r, a);
1690
1721
  }
1691
1722
  }
1692
- }), updateDrawings.length === 0 && preUpdateDrawings.length === 0)
1723
+ }), r.length === 0 && s.length === 0)
1693
1724
  return { redos: [], undos: [] };
1694
- const { redos, undos } = this._createUndoAndRedoMutation(unitId, subUnitId, updateDrawings), preRedos = [], preUndos = [];
1695
- if (preUpdateDrawings.length > 0) {
1696
- const { redos: redos2, undos: undos2 } = this._createUndoAndRedoMutation(unitId, subUnitId, preUpdateDrawings);
1697
- preRedos.push(...redos2), preUndos.push(...undos2);
1725
+ const { redos: o, undos: d } = this._createUndoAndRedoMutation(i, e, r), l = [], g = [];
1726
+ if (s.length > 0) {
1727
+ const { redos: c, undos: a } = this._createUndoAndRedoMutation(i, e, s);
1728
+ l.push(...c), g.push(...a);
1698
1729
  }
1699
1730
  return {
1700
- redos,
1701
- undos,
1702
- preRedos,
1703
- preUndos
1731
+ redos: o,
1732
+ undos: d,
1733
+ preRedos: l,
1734
+ preUndos: g
1704
1735
  };
1705
1736
  }
1706
- _getDrawingUndoForRowAndColSize(unitId, subUnitId, ranges, isRow) {
1707
- const drawingData = this._drawingManagerService.getDrawingData(unitId, subUnitId), updateDrawings = [];
1708
- return Object.keys(drawingData).forEach((drawingId) => {
1709
- const drawing = drawingData[drawingId], { sheetTransform, transform, anchorType = SheetDrawingAnchorType.Position } = drawing;
1710
- if (anchorType === SheetDrawingAnchorType.None)
1711
- this._remainDrawingSize(transform, updateDrawings, drawing);
1737
+ _getDrawingUndoForRowAndColSize(i, e, n, t) {
1738
+ const r = this._drawingManagerService.getDrawingData(i, e), s = [];
1739
+ return Object.keys(r).forEach((o) => {
1740
+ const d = r[o], { sheetTransform: l, transform: g, anchorType: c = y.Position } = d;
1741
+ if (c === y.None)
1742
+ this._remainDrawingSize(g, s, d);
1712
1743
  else {
1713
- const { from, to } = sheetTransform, { row: fromRow, column: fromColumn } = from, { row: toRow, column: toColumn } = to;
1714
- for (let i = 0; i < ranges.length; i++) {
1715
- const range = ranges[i], { startRow, endRow, startColumn, endColumn } = range;
1716
- if (toRow < startRow || toColumn < startColumn)
1744
+ const { from: a, to: h } = l, { row: u, column: m } = a, { row: f, column: p } = h;
1745
+ for (let C = 0; C < n.length; C++) {
1746
+ const S = n[C], { startRow: v, endRow: R, startColumn: _, endColumn: I } = S;
1747
+ if (f < v || p < _)
1717
1748
  continue;
1718
- if (anchorType === SheetDrawingAnchorType.Position && (fromRow <= startRow && toRow >= endRow || fromColumn <= startColumn && toColumn >= endColumn)) {
1719
- this._remainDrawingSize(transform, updateDrawings, drawing);
1749
+ if (c === y.Position && (u <= v && f >= R || m <= _ && p >= I)) {
1750
+ this._remainDrawingSize(g, s, d);
1720
1751
  continue;
1721
1752
  }
1722
- const newTransform = drawingPositionToTransform(
1723
- { ...sheetTransform },
1753
+ const w = L(
1754
+ { ...l },
1724
1755
  this._selectionRenderService,
1725
1756
  this._skeletonManagerService
1726
1757
  );
1727
- if (newTransform != null) {
1728
- updateDrawings.push({
1729
- ...drawing,
1730
- transform: newTransform
1758
+ if (w != null) {
1759
+ s.push({
1760
+ ...d,
1761
+ transform: w
1731
1762
  });
1732
1763
  break;
1733
1764
  }
1734
1765
  }
1735
1766
  }
1736
- }), updateDrawings.length === 0 ? { redos: [], undos: [] } : this._createUndoAndRedoMutation(unitId, subUnitId, updateDrawings);
1767
+ }), s.length === 0 ? { redos: [], undos: [] } : this._createUndoAndRedoMutation(i, e, s);
1737
1768
  }
1738
- _getUnitIdAndSubUnitId(params, type) {
1739
- let unitId, subUnitId;
1740
- if (type === "insert")
1741
- unitId = params.unitId, subUnitId = params.subUnitId;
1769
+ _getUnitIdAndSubUnitId(i, e) {
1770
+ let n, t;
1771
+ if (e === "insert")
1772
+ n = i.unitId, t = i.subUnitId;
1742
1773
  else {
1743
- const newParams = getSheetCommandTarget(this._univerInstanceService);
1744
- if (newParams == null)
1774
+ const r = ce(this._univerInstanceService);
1775
+ if (r == null)
1745
1776
  return;
1746
- unitId = newParams.unitId, subUnitId = newParams.subUnitId;
1777
+ n = r.unitId, t = r.subUnitId;
1747
1778
  }
1748
- return { unitId, subUnitId };
1779
+ return { unitId: n, subUnitId: t };
1749
1780
  }
1750
- _moveRangeInterceptor(params) {
1751
- var _a11, _b;
1752
- const { toRange, fromRange } = params, target = getSheetCommandTarget(this._univerInstanceService);
1753
- if (!target)
1781
+ _moveRangeInterceptor(i) {
1782
+ var v, R;
1783
+ const { toRange: e, fromRange: n } = i, t = ce(this._univerInstanceService);
1784
+ if (!t)
1754
1785
  return { redos: [], undos: [] };
1755
- const { unitId, subUnitId } = target, skeleton = (_b = (_a11 = this._renderManagerService.getRenderById(unitId)) == null ? void 0 : _a11.with(SheetSkeletonManagerService)) == null ? void 0 : _b.getCurrentSkeleton();
1756
- if (!skeleton)
1786
+ const { unitId: r, subUnitId: s } = t, o = (R = (v = this._renderManagerService.getRenderById(r)) == null ? void 0 : v.with(q)) == null ? void 0 : R.getCurrentSkeleton();
1787
+ if (!o)
1757
1788
  return { redos: [], undos: [] };
1758
- const selectionRect = attachRangeWithCoord(skeleton, fromRange);
1759
- if (!selectionRect)
1789
+ const d = Pe(o, n);
1790
+ if (!d)
1760
1791
  return { redos: [], undos: [] };
1761
- const { startX, endX, startY, endY } = selectionRect, drawings = this._sheetDrawingService.getDrawingData(unitId, subUnitId), containedDrawings = [];
1762
- Object.keys(drawings).forEach((drawingId) => {
1763
- const drawing = drawings[drawingId];
1764
- if (drawing.anchorType !== SheetDrawingAnchorType.Both)
1792
+ const { startX: l, endX: g, startY: c, endY: a } = d, h = this._sheetDrawingService.getDrawingData(r, s), u = [];
1793
+ Object.keys(h).forEach((_) => {
1794
+ const I = h[_];
1795
+ if (I.anchorType !== y.Both)
1765
1796
  return;
1766
- const { transform } = drawing;
1767
- if (!transform)
1797
+ const { transform: w } = I;
1798
+ if (!w)
1768
1799
  return;
1769
- const { left = 0, top = 0, width = 0, height = 0 } = transform, { drawingStartX, drawingEndX, drawingStartY, drawingEndY } = {
1770
- drawingStartX: left,
1771
- drawingEndX: left + width,
1772
- drawingStartY: top,
1773
- drawingEndY: top + height
1800
+ const { left: O = 0, top: b = 0, width: A = 0, height: E = 0 } = w, { drawingStartX: M, drawingEndX: D, drawingStartY: U, drawingEndY: x } = {
1801
+ drawingStartX: O,
1802
+ drawingEndX: O + A,
1803
+ drawingStartY: b,
1804
+ drawingEndY: b + E
1774
1805
  };
1775
- startX <= drawingStartX && drawingEndX <= endX && startY <= drawingStartY && drawingEndY <= endY && containedDrawings.push(drawing);
1806
+ l <= M && D <= g && c <= U && x <= a && u.push(I);
1776
1807
  });
1777
- const redos = [], undos = [], rowOffset = toRange.startRow - fromRange.startRow, colOffset = toRange.startColumn - fromRange.startColumn, updateDrawings = containedDrawings.map((drawing) => {
1778
- const oldSheetTransform = drawing.sheetTransform, sheetTransform = {
1779
- to: { ...oldSheetTransform.to, row: oldSheetTransform.to.row + rowOffset, column: oldSheetTransform.to.column + colOffset },
1780
- from: { ...oldSheetTransform.from, row: oldSheetTransform.from.row + rowOffset, column: oldSheetTransform.from.column + colOffset }
1781
- }, transform = drawingPositionToTransform(sheetTransform, this._selectionRenderService, this._skeletonManagerService);
1808
+ const m = [], f = [], p = e.startRow - n.startRow, C = e.startColumn - n.startColumn, S = u.map((_) => {
1809
+ const I = _.sheetTransform, w = {
1810
+ to: { ...I.to, row: I.to.row + p, column: I.to.column + C },
1811
+ from: { ...I.from, row: I.from.row + p, column: I.from.column + C }
1812
+ }, O = L(w, this._selectionRenderService, this._skeletonManagerService);
1782
1813
  return {
1783
- unitId,
1784
- subUnitId,
1785
- drawingId: drawing.drawingId,
1786
- transform,
1787
- sheetTransform
1814
+ unitId: r,
1815
+ subUnitId: s,
1816
+ drawingId: _.drawingId,
1817
+ transform: O,
1818
+ sheetTransform: w
1788
1819
  };
1789
1820
  });
1790
- if (updateDrawings.length) {
1791
- const updateJsonOp = this._sheetDrawingService.getBatchUpdateOp(updateDrawings), { undo, redo, objects } = updateJsonOp;
1792
- redos.push({ id: SetDrawingApplyMutation.id, params: { unitId, subUnitId, op: redo, objects, type: DrawingApplyType.UPDATE } }), undos.push({ id: SetDrawingApplyMutation.id, params: { unitId, subUnitId, op: undo, objects, type: DrawingApplyType.UPDATE } });
1821
+ if (S.length) {
1822
+ const _ = this._sheetDrawingService.getBatchUpdateOp(S), { undo: I, redo: w, objects: O } = _;
1823
+ m.push({ id: T.id, params: { unitId: r, subUnitId: s, op: w, objects: O, type: P.UPDATE } }), f.push({ id: T.id, params: { unitId: r, subUnitId: s, op: I, objects: O, type: P.UPDATE } });
1793
1824
  }
1794
- return { redos, undos };
1825
+ return { redos: m, undos: f };
1795
1826
  }
1796
- _moveRowInterceptor(params, type) {
1797
- const ids = this._getUnitIdAndSubUnitId(params, type);
1798
- if (ids == null)
1827
+ _moveRowInterceptor(i, e) {
1828
+ const n = this._getUnitIdAndSubUnitId(i, e);
1829
+ if (n == null)
1799
1830
  return { redos: [], undos: [] };
1800
- const { unitId, subUnitId } = ids, { range } = params, rowStartIndex = range.startRow, rowEndIndex = range.endRow, redos = [], undos = [], data = this._sheetDrawingService.getDrawingData(unitId, subUnitId), updateDrawings = [], deleteDrawings = [];
1801
- if (Object.keys(data).forEach((drawingId) => {
1802
- const drawing = data[drawingId], { sheetTransform, transform, anchorType = SheetDrawingAnchorType.Position } = drawing;
1803
- if (sheetTransform == null || transform == null)
1831
+ const { unitId: t, subUnitId: r } = n, { range: s } = i, o = s.startRow, d = s.endRow, l = [], g = [], c = this._sheetDrawingService.getDrawingData(t, r), a = [], h = [];
1832
+ if (Object.keys(c).forEach((u) => {
1833
+ const m = c[u], { sheetTransform: f, transform: p, anchorType: C = y.Position } = m;
1834
+ if (f == null || p == null)
1804
1835
  return;
1805
- let newSheetTransform, newTransform;
1806
- if (type === "insert") {
1807
- const param = this._expandRow(sheetTransform, transform, rowStartIndex, rowEndIndex, anchorType);
1808
- newSheetTransform = param == null ? void 0 : param.newSheetTransform, newTransform = param == null ? void 0 : param.newTransform;
1836
+ let S, v;
1837
+ if (e === "insert") {
1838
+ const _ = this._expandRow(f, p, o, d, C);
1839
+ S = _ == null ? void 0 : _.newSheetTransform, v = _ == null ? void 0 : _.newTransform;
1809
1840
  } else {
1810
- const { from, to } = sheetTransform, { row: fromRow } = from, { row: toRow } = to;
1811
- if (anchorType === SheetDrawingAnchorType.Both && fromRow >= rowStartIndex && toRow <= rowEndIndex)
1812
- deleteDrawings.push({ unitId, subUnitId, drawingId });
1841
+ const { from: _, to: I } = f, { row: w } = _, { row: O } = I;
1842
+ if (C === y.Both && w >= o && O <= d)
1843
+ h.push({ unitId: t, subUnitId: r, drawingId: u });
1813
1844
  else {
1814
- const param = this._shrinkRow(sheetTransform, transform, rowStartIndex, rowEndIndex, anchorType);
1815
- newSheetTransform = param == null ? void 0 : param.newSheetTransform, newTransform = param == null ? void 0 : param.newTransform;
1845
+ const b = this._shrinkRow(f, p, o, d, C);
1846
+ S = b == null ? void 0 : b.newSheetTransform, v = b == null ? void 0 : b.newTransform;
1816
1847
  }
1817
1848
  }
1818
- if (!newSheetTransform || !newTransform)
1849
+ if (!S || !v)
1819
1850
  return;
1820
- const params2 = { unitId, subUnitId, drawingId, transform: newTransform, sheetTransform: newSheetTransform };
1821
- updateDrawings.push(params2);
1822
- }), updateDrawings.length === 0 && deleteDrawings.length === 0)
1851
+ const R = { unitId: t, subUnitId: r, drawingId: u, transform: v, sheetTransform: S };
1852
+ a.push(R);
1853
+ }), a.length === 0 && h.length === 0)
1823
1854
  return { redos: [], undos: [] };
1824
- if (updateDrawings.length > 0) {
1825
- const updateJsonOp = this._sheetDrawingService.getBatchUpdateOp(updateDrawings), { undo, redo, objects } = updateJsonOp;
1826
- redos.push({ id: SetDrawingApplyMutation.id, params: { unitId, subUnitId, op: redo, objects, type: DrawingApplyType.UPDATE } }), undos.push({ id: SetDrawingApplyMutation.id, params: { unitId, subUnitId, op: undo, objects, type: DrawingApplyType.UPDATE } });
1855
+ if (a.length > 0) {
1856
+ const u = this._sheetDrawingService.getBatchUpdateOp(a), { undo: m, redo: f, objects: p } = u;
1857
+ l.push({ id: T.id, params: { unitId: t, subUnitId: r, op: f, objects: p, type: P.UPDATE } }), g.push({ id: T.id, params: { unitId: t, subUnitId: r, op: m, objects: p, type: P.UPDATE } });
1827
1858
  }
1828
- if (deleteDrawings.length > 0) {
1829
- const deleteJsonOp = this._sheetDrawingService.getBatchRemoveOp(deleteDrawings), deleteUndo = deleteJsonOp.undo, deleteRedo = deleteJsonOp.redo, deleteObjects = deleteJsonOp.objects;
1830
- redos.push({ id: SetDrawingApplyMutation.id, params: { unitId, subUnitId, op: deleteRedo, objects: deleteObjects, type: DrawingApplyType.REMOVE } }), undos.push({ id: SetDrawingApplyMutation.id, params: { unitId, subUnitId, op: deleteUndo, objects: deleteObjects, type: DrawingApplyType.INSERT } });
1859
+ if (h.length > 0) {
1860
+ const u = this._sheetDrawingService.getBatchRemoveOp(h), m = u.undo, f = u.redo, p = u.objects;
1861
+ l.push({ id: T.id, params: { unitId: t, subUnitId: r, op: f, objects: p, type: P.REMOVE } }), g.push({ id: T.id, params: { unitId: t, subUnitId: r, op: m, objects: p, type: P.INSERT } });
1831
1862
  }
1832
- return redos.push({ id: ClearSheetDrawingTransformerOperation.id, params: [unitId] }), undos.push({ id: ClearSheetDrawingTransformerOperation.id, params: [unitId] }), {
1833
- redos,
1834
- undos
1863
+ return l.push({ id: j.id, params: [t] }), g.push({ id: j.id, params: [t] }), {
1864
+ redos: l,
1865
+ undos: g
1835
1866
  };
1836
1867
  }
1837
- _moveColInterceptor(params, type) {
1838
- const ids = this._getUnitIdAndSubUnitId(params, type);
1839
- if (ids == null)
1868
+ _moveColInterceptor(i, e) {
1869
+ const n = this._getUnitIdAndSubUnitId(i, e);
1870
+ if (n == null)
1840
1871
  return { redos: [], undos: [] };
1841
- const { unitId, subUnitId } = ids, { range } = params, colStartIndex = range.startColumn, colEndIndex = range.endColumn, redos = [], undos = [], data = this._sheetDrawingService.getDrawingData(unitId, subUnitId), updateDrawings = [], deleteDrawings = [];
1842
- if (Object.keys(data).forEach((drawingId) => {
1843
- const drawing = data[drawingId], { sheetTransform, transform, anchorType = SheetDrawingAnchorType.Position } = drawing;
1844
- if (sheetTransform == null || transform == null)
1872
+ const { unitId: t, subUnitId: r } = n, { range: s } = i, o = s.startColumn, d = s.endColumn, l = [], g = [], c = this._sheetDrawingService.getDrawingData(t, r), a = [], h = [];
1873
+ if (Object.keys(c).forEach((u) => {
1874
+ const m = c[u], { sheetTransform: f, transform: p, anchorType: C = y.Position } = m;
1875
+ if (f == null || p == null)
1845
1876
  return;
1846
- let newSheetTransform, newTransform;
1847
- if (type === "insert") {
1848
- const param = this._expandCol(sheetTransform, transform, colStartIndex, colEndIndex, anchorType);
1849
- newSheetTransform = param == null ? void 0 : param.newSheetTransform, newTransform = param == null ? void 0 : param.newTransform;
1877
+ let S, v;
1878
+ if (e === "insert") {
1879
+ const _ = this._expandCol(f, p, o, d, C);
1880
+ S = _ == null ? void 0 : _.newSheetTransform, v = _ == null ? void 0 : _.newTransform;
1850
1881
  } else {
1851
- const { from, to } = sheetTransform, { column: fromColumn } = from, { column: toColumn } = to;
1852
- if (anchorType === SheetDrawingAnchorType.Both && fromColumn >= colStartIndex && toColumn <= colEndIndex)
1853
- deleteDrawings.push({ unitId, subUnitId, drawingId });
1882
+ const { from: _, to: I } = f, { column: w } = _, { column: O } = I;
1883
+ if (C === y.Both && w >= o && O <= d)
1884
+ h.push({ unitId: t, subUnitId: r, drawingId: u });
1854
1885
  else {
1855
- const param = this._shrinkCol(sheetTransform, transform, colStartIndex, colEndIndex, anchorType);
1856
- newSheetTransform = param == null ? void 0 : param.newSheetTransform, newTransform = param == null ? void 0 : param.newTransform;
1886
+ const b = this._shrinkCol(f, p, o, d, C);
1887
+ S = b == null ? void 0 : b.newSheetTransform, v = b == null ? void 0 : b.newTransform;
1857
1888
  }
1858
1889
  }
1859
- if (!newSheetTransform || !newTransform)
1890
+ if (!S || !v)
1860
1891
  return;
1861
- const params2 = { unitId, subUnitId, drawingId, transform: newTransform, sheetTransform: newSheetTransform };
1862
- updateDrawings.push(params2);
1863
- }), updateDrawings.length === 0 && deleteDrawings.length === 0)
1892
+ const R = { unitId: t, subUnitId: r, drawingId: u, transform: v, sheetTransform: S };
1893
+ a.push(R);
1894
+ }), a.length === 0 && h.length === 0)
1864
1895
  return { redos: [], undos: [] };
1865
- if (updateDrawings.length > 0) {
1866
- const updateJsonOp = this._sheetDrawingService.getBatchUpdateOp(updateDrawings), { undo, redo, objects } = updateJsonOp;
1867
- redos.push({ id: SetDrawingApplyMutation.id, params: { unitId, subUnitId, op: redo, objects, type: DrawingApplyType.UPDATE } }), undos.push({ id: SetDrawingApplyMutation.id, params: { unitId, subUnitId, op: undo, objects, type: DrawingApplyType.UPDATE } });
1896
+ if (a.length > 0) {
1897
+ const u = this._sheetDrawingService.getBatchUpdateOp(a), { undo: m, redo: f, objects: p } = u;
1898
+ l.push({ id: T.id, params: { unitId: t, subUnitId: r, op: f, objects: p, type: P.UPDATE } }), g.push({ id: T.id, params: { unitId: t, subUnitId: r, op: m, objects: p, type: P.UPDATE } });
1868
1899
  }
1869
- if (deleteDrawings.length > 0) {
1870
- const deleteJsonOp = this._sheetDrawingService.getBatchRemoveOp(deleteDrawings), deleteUndo = deleteJsonOp.undo, deleteRedo = deleteJsonOp.redo, deleteObjects = deleteJsonOp.objects;
1871
- redos.push({ id: SetDrawingApplyMutation.id, params: { unitId, subUnitId, op: deleteRedo, objects: deleteObjects, type: DrawingApplyType.REMOVE } }), undos.push({ id: SetDrawingApplyMutation.id, params: { unitId, subUnitId, op: deleteUndo, objects: deleteObjects, type: DrawingApplyType.INSERT } });
1900
+ if (h.length > 0) {
1901
+ const u = this._sheetDrawingService.getBatchRemoveOp(h), m = u.undo, f = u.redo, p = u.objects;
1902
+ l.push({ id: T.id, params: { unitId: t, subUnitId: r, op: f, objects: p, type: P.REMOVE } }), g.push({ id: T.id, params: { unitId: t, subUnitId: r, op: m, objects: p, type: P.INSERT } });
1872
1903
  }
1873
- return redos.push({ id: ClearSheetDrawingTransformerOperation.id, params: [unitId] }), undos.push({ id: ClearSheetDrawingTransformerOperation.id, params: [unitId] }), { redos, undos };
1904
+ return l.push({ id: j.id, params: [t] }), g.push({ id: j.id, params: [t] }), { redos: l, undos: g };
1874
1905
  }
1875
- _expandCol(sheetTransform, transform, colStartIndex, colEndIndex, anchorType = SheetDrawingAnchorType.Position) {
1876
- const colCount = colEndIndex - colStartIndex + 1, { from, to } = sheetTransform, { column: fromColumn } = from, { column: toColumn } = to;
1877
- if (anchorType === SheetDrawingAnchorType.None)
1906
+ _expandCol(i, e, n, t, r = y.Position) {
1907
+ const s = t - n + 1, { from: o, to: d } = i, { column: l } = o, { column: g } = d;
1908
+ if (r === y.None)
1878
1909
  return {
1879
- newSheetTransform: transformToDrawingPosition({ ...transform }, this._selectionRenderService),
1880
- newTransform: transform
1910
+ newSheetTransform: N({ ...e }, this._selectionRenderService),
1911
+ newTransform: e
1881
1912
  };
1882
- let newSheetTransform = null, newTransform = null;
1883
- if (fromColumn >= colStartIndex) {
1884
- const selectionCell = this._skeletonManagerService.attachRangeWithCoord({ startColumn: colStartIndex, endColumn: colEndIndex, startRow: from.row, endRow: to.row });
1885
- if (selectionCell == null)
1913
+ let c = null, a = null;
1914
+ if (l >= n) {
1915
+ const h = this._skeletonManagerService.attachRangeWithCoord({ startColumn: n, endColumn: t, startRow: o.row, endRow: d.row });
1916
+ if (h == null)
1886
1917
  return;
1887
- newTransform = { ...transform, left: (transform.left || 0) + selectionCell.endX - selectionCell.startX }, newSheetTransform = transformToDrawingPosition(newTransform, this._selectionRenderService);
1888
- } else if (toColumn >= colEndIndex)
1889
- if (anchorType === SheetDrawingAnchorType.Both)
1890
- newSheetTransform = {
1891
- from: { ...from },
1892
- to: { ...to, column: toColumn + colCount }
1893
- }, newTransform = drawingPositionToTransform(newSheetTransform, this._selectionRenderService, this._skeletonManagerService);
1918
+ a = { ...e, left: (e.left || 0) + h.endX - h.startX }, c = N(a, this._selectionRenderService);
1919
+ } else if (g >= t)
1920
+ if (r === y.Both)
1921
+ c = {
1922
+ from: { ...o },
1923
+ to: { ...d, column: g + s }
1924
+ }, a = L(c, this._selectionRenderService, this._skeletonManagerService);
1894
1925
  else
1895
1926
  return {
1896
- newSheetTransform: transformToDrawingPosition({ ...transform }, this._selectionRenderService),
1897
- newTransform: transform
1927
+ newSheetTransform: N({ ...e }, this._selectionRenderService),
1928
+ newTransform: e
1898
1929
  };
1899
- return newSheetTransform != null && newTransform != null ? {
1900
- newSheetTransform,
1901
- newTransform
1930
+ return c != null && a != null ? {
1931
+ newSheetTransform: c,
1932
+ newTransform: a
1902
1933
  } : null;
1903
1934
  }
1904
- _shrinkCol(sheetTransform, transform, colStartIndex, colEndIndex, anchorType = SheetDrawingAnchorType.Position) {
1905
- const colCount = colEndIndex - colStartIndex + 1, { from, to } = sheetTransform, { column: fromColumn } = from, { column: toColumn } = to;
1906
- if (anchorType === SheetDrawingAnchorType.None)
1935
+ _shrinkCol(i, e, n, t, r = y.Position) {
1936
+ const s = t - n + 1, { from: o, to: d } = i, { column: l } = o, { column: g } = d;
1937
+ if (r === y.None)
1907
1938
  return {
1908
- newSheetTransform: transformToDrawingPosition({ ...transform }, this._selectionRenderService),
1909
- newTransform: transform
1939
+ newSheetTransform: N({ ...e }, this._selectionRenderService),
1940
+ newTransform: e
1910
1941
  };
1911
- let newSheetTransform = null, newTransform = null;
1912
- if (fromColumn > colEndIndex)
1913
- newSheetTransform = {
1914
- from: { ...from, column: fromColumn - colCount },
1915
- to: { ...to, column: toColumn - colCount }
1916
- }, newTransform = drawingPositionToTransform(newSheetTransform, this._selectionRenderService, this._skeletonManagerService);
1942
+ let c = null, a = null;
1943
+ if (l > t)
1944
+ c = {
1945
+ from: { ...o, column: l - s },
1946
+ to: { ...d, column: g - s }
1947
+ }, a = L(c, this._selectionRenderService, this._skeletonManagerService);
1917
1948
  else {
1918
- if (fromColumn >= colStartIndex && toColumn <= colEndIndex)
1949
+ if (l >= n && g <= t)
1919
1950
  return null;
1920
- if (fromColumn < colStartIndex && toColumn > colEndIndex)
1921
- if (anchorType === SheetDrawingAnchorType.Both)
1922
- newSheetTransform = {
1923
- from: { ...from },
1924
- to: { ...to, column: toColumn - colCount }
1925
- }, newTransform = drawingPositionToTransform(newSheetTransform, this._selectionRenderService, this._skeletonManagerService);
1951
+ if (l < n && g > t)
1952
+ if (r === y.Both)
1953
+ c = {
1954
+ from: { ...o },
1955
+ to: { ...d, column: g - s }
1956
+ }, a = L(c, this._selectionRenderService, this._skeletonManagerService);
1926
1957
  else
1927
1958
  return {
1928
- newSheetTransform: transformToDrawingPosition({ ...transform }, this._selectionRenderService),
1929
- newTransform: transform
1959
+ newSheetTransform: N({ ...e }, this._selectionRenderService),
1960
+ newTransform: e
1930
1961
  };
1931
- else if (fromColumn >= colStartIndex && fromColumn <= colEndIndex) {
1932
- if (fromColumn === colStartIndex)
1933
- newTransform = { ...transform, left: (transform.left || 0) - sheetTransform.from.columnOffset };
1962
+ else if (l >= n && l <= t) {
1963
+ if (l === n)
1964
+ a = { ...e, left: (e.left || 0) - i.from.columnOffset };
1934
1965
  else {
1935
- const selectionCell = this._skeletonManagerService.attachRangeWithCoord({ startColumn: colStartIndex, endColumn: fromColumn - 1, startRow: from.row, endRow: to.row });
1936
- if (selectionCell == null)
1966
+ const h = this._skeletonManagerService.attachRangeWithCoord({ startColumn: n, endColumn: l - 1, startRow: o.row, endRow: d.row });
1967
+ if (h == null)
1937
1968
  return;
1938
- newTransform = { ...transform, left: (transform.left || 0) - selectionCell.endX + selectionCell.startX - sheetTransform.from.columnOffset };
1969
+ a = { ...e, left: (e.left || 0) - h.endX + h.startX - i.from.columnOffset };
1939
1970
  }
1940
- newSheetTransform = transformToDrawingPosition(newTransform, this._selectionRenderService);
1941
- } else if (toColumn >= colStartIndex && toColumn <= colEndIndex && anchorType === SheetDrawingAnchorType.Both) {
1942
- const selectionCell = this._skeletonManagerService.attachRangeWithCoord({
1943
- startColumn: colStartIndex - 1,
1944
- endColumn: colStartIndex - 1,
1945
- startRow: from.row,
1946
- endRow: to.row
1971
+ c = N(a, this._selectionRenderService);
1972
+ } else if (g >= n && g <= t && r === y.Both) {
1973
+ const h = this._skeletonManagerService.attachRangeWithCoord({
1974
+ startColumn: n - 1,
1975
+ endColumn: n - 1,
1976
+ startRow: o.row,
1977
+ endRow: d.row
1947
1978
  });
1948
- if (selectionCell == null)
1979
+ if (h == null)
1949
1980
  return;
1950
- newSheetTransform = {
1951
- from: { ...from },
1952
- to: { ...to, column: colStartIndex - 1, columnOffset: selectionCell.endX - selectionCell.startX }
1953
- }, newTransform = drawingPositionToTransform(newSheetTransform, this._selectionRenderService, this._skeletonManagerService);
1981
+ c = {
1982
+ from: { ...o },
1983
+ to: { ...d, column: n - 1, columnOffset: h.endX - h.startX }
1984
+ }, a = L(c, this._selectionRenderService, this._skeletonManagerService);
1954
1985
  }
1955
1986
  }
1956
- return newSheetTransform != null && newTransform != null ? {
1957
- newSheetTransform,
1958
- newTransform
1987
+ return c != null && a != null ? {
1988
+ newSheetTransform: c,
1989
+ newTransform: a
1959
1990
  } : null;
1960
1991
  }
1961
- _expandRow(sheetTransform, transform, rowStartIndex, rowEndIndex, anchorType = SheetDrawingAnchorType.Position) {
1962
- const rowCount = rowEndIndex - rowStartIndex + 1, { from, to } = sheetTransform, { row: fromRow } = from, { row: toRow } = to;
1963
- if (anchorType === SheetDrawingAnchorType.None)
1992
+ _expandRow(i, e, n, t, r = y.Position) {
1993
+ const s = t - n + 1, { from: o, to: d } = i, { row: l } = o, { row: g } = d;
1994
+ if (r === y.None)
1964
1995
  return {
1965
- newSheetTransform: transformToDrawingPosition({ ...transform }, this._selectionRenderService),
1966
- newTransform: transform
1996
+ newSheetTransform: N({ ...e }, this._selectionRenderService),
1997
+ newTransform: e
1967
1998
  };
1968
- let newSheetTransform = null, newTransform = null;
1969
- if (fromRow >= rowStartIndex) {
1970
- const selectionCell = this._skeletonManagerService.attachRangeWithCoord({ startRow: rowStartIndex, endRow: rowEndIndex, startColumn: from.column, endColumn: to.column });
1971
- if (selectionCell == null)
1999
+ let c = null, a = null;
2000
+ if (l >= n) {
2001
+ const h = this._skeletonManagerService.attachRangeWithCoord({ startRow: n, endRow: t, startColumn: o.column, endColumn: d.column });
2002
+ if (h == null)
1972
2003
  return;
1973
- newTransform = { ...transform, top: (transform.top || 0) + selectionCell.endY - selectionCell.startY }, newSheetTransform = transformToDrawingPosition(newTransform, this._selectionRenderService);
1974
- } else if (toRow >= rowEndIndex)
1975
- if (anchorType === SheetDrawingAnchorType.Both)
1976
- newSheetTransform = {
1977
- from: { ...from },
2004
+ a = { ...e, top: (e.top || 0) + h.endY - h.startY }, c = N(a, this._selectionRenderService);
2005
+ } else if (g >= t)
2006
+ if (r === y.Both)
2007
+ c = {
2008
+ from: { ...o },
1978
2009
  to: {
1979
- ...to,
1980
- row: toRow + rowCount
2010
+ ...d,
2011
+ row: g + s
1981
2012
  }
1982
- }, newTransform = drawingPositionToTransform(newSheetTransform, this._selectionRenderService, this._skeletonManagerService);
2013
+ }, a = L(c, this._selectionRenderService, this._skeletonManagerService);
1983
2014
  else
1984
2015
  return {
1985
- newSheetTransform: transformToDrawingPosition({ ...transform }, this._selectionRenderService),
1986
- newTransform: transform
2016
+ newSheetTransform: N({ ...e }, this._selectionRenderService),
2017
+ newTransform: e
1987
2018
  };
1988
- return newSheetTransform != null && newTransform != null ? {
1989
- newSheetTransform,
1990
- newTransform
2019
+ return c != null && a != null ? {
2020
+ newSheetTransform: c,
2021
+ newTransform: a
1991
2022
  } : null;
1992
2023
  }
1993
- _shrinkRow(sheetTransform, transform, rowStartIndex, rowEndIndex, anchorType = SheetDrawingAnchorType.Position) {
1994
- const rowCount = rowEndIndex - rowStartIndex + 1, { from, to } = sheetTransform, { row: fromRow } = from, { row: toRow } = to;
1995
- if (anchorType === SheetDrawingAnchorType.None)
2024
+ _shrinkRow(i, e, n, t, r = y.Position) {
2025
+ const s = t - n + 1, { from: o, to: d } = i, { row: l } = o, { row: g } = d;
2026
+ if (r === y.None)
1996
2027
  return {
1997
- newSheetTransform: transformToDrawingPosition({ ...transform }, this._selectionRenderService),
1998
- newTransform: transform
2028
+ newSheetTransform: N({ ...e }, this._selectionRenderService),
2029
+ newTransform: e
1999
2030
  };
2000
- let newSheetTransform = null, newTransform = null;
2001
- if (fromRow > rowEndIndex)
2002
- newSheetTransform = {
2003
- from: { ...from, row: fromRow - rowCount },
2004
- to: { ...to, row: toRow - rowCount }
2005
- }, newTransform = drawingPositionToTransform(newSheetTransform, this._selectionRenderService, this._skeletonManagerService);
2031
+ let c = null, a = null;
2032
+ if (l > t)
2033
+ c = {
2034
+ from: { ...o, row: l - s },
2035
+ to: { ...d, row: g - s }
2036
+ }, a = L(c, this._selectionRenderService, this._skeletonManagerService);
2006
2037
  else {
2007
- if (fromRow >= rowStartIndex && toRow <= rowEndIndex)
2038
+ if (l >= n && g <= t)
2008
2039
  return null;
2009
- if (fromRow < rowStartIndex && toRow > rowEndIndex)
2010
- if (anchorType === SheetDrawingAnchorType.Both)
2011
- newSheetTransform = {
2012
- from: { ...from },
2013
- to: { ...to, row: toRow - rowCount }
2014
- }, newTransform = drawingPositionToTransform(newSheetTransform, this._selectionRenderService, this._skeletonManagerService);
2040
+ if (l < n && g > t)
2041
+ if (r === y.Both)
2042
+ c = {
2043
+ from: { ...o },
2044
+ to: { ...d, row: g - s }
2045
+ }, a = L(c, this._selectionRenderService, this._skeletonManagerService);
2015
2046
  else
2016
2047
  return {
2017
- newSheetTransform: transformToDrawingPosition({ ...transform }, this._selectionRenderService),
2018
- newTransform: transform
2048
+ newSheetTransform: N({ ...e }, this._selectionRenderService),
2049
+ newTransform: e
2019
2050
  };
2020
- else if (fromRow >= rowStartIndex && fromRow <= rowEndIndex) {
2021
- if (fromRow === rowStartIndex)
2022
- newTransform = { ...transform, top: (transform.top || 0) - sheetTransform.from.rowOffset };
2051
+ else if (l >= n && l <= t) {
2052
+ if (l === n)
2053
+ a = { ...e, top: (e.top || 0) - i.from.rowOffset };
2023
2054
  else {
2024
- const selectionCell = this._skeletonManagerService.attachRangeWithCoord({ startRow: rowStartIndex, endRow: fromRow - 1, startColumn: from.column, endColumn: to.column });
2025
- if (selectionCell == null)
2055
+ const h = this._skeletonManagerService.attachRangeWithCoord({ startRow: n, endRow: l - 1, startColumn: o.column, endColumn: d.column });
2056
+ if (h == null)
2026
2057
  return;
2027
- newTransform = { ...transform, top: (transform.top || 0) - selectionCell.endY + selectionCell.startY - sheetTransform.from.rowOffset };
2058
+ a = { ...e, top: (e.top || 0) - h.endY + h.startY - i.from.rowOffset };
2028
2059
  }
2029
- newSheetTransform = transformToDrawingPosition(newTransform, this._selectionRenderService);
2030
- } else if (toRow >= rowStartIndex && toRow <= rowEndIndex && anchorType === SheetDrawingAnchorType.Both) {
2031
- const selectionCell = this._skeletonManagerService.attachRangeWithCoord({ startColumn: from.column, endColumn: from.column, startRow: rowStartIndex - 1, endRow: rowStartIndex - 1 });
2032
- if (selectionCell == null)
2060
+ c = N(a, this._selectionRenderService);
2061
+ } else if (g >= n && g <= t && r === y.Both) {
2062
+ const h = this._skeletonManagerService.attachRangeWithCoord({ startColumn: o.column, endColumn: o.column, startRow: n - 1, endRow: n - 1 });
2063
+ if (h == null)
2033
2064
  return;
2034
- newSheetTransform = {
2035
- from: { ...from },
2036
- to: { ...to, row: rowStartIndex - 1, rowOffset: selectionCell.endY - selectionCell.startY }
2037
- }, newTransform = drawingPositionToTransform(newSheetTransform, this._selectionRenderService, this._skeletonManagerService);
2065
+ c = {
2066
+ from: { ...o },
2067
+ to: { ...d, row: n - 1, rowOffset: h.endY - h.startY }
2068
+ }, a = L(c, this._selectionRenderService, this._skeletonManagerService);
2038
2069
  }
2039
2070
  }
2040
- return newSheetTransform != null && newTransform != null ? {
2041
- newSheetTransform,
2042
- newTransform
2071
+ return c != null && a != null ? {
2072
+ newSheetTransform: c,
2073
+ newTransform: a
2043
2074
  } : null;
2044
2075
  }
2045
2076
  _commandListener() {
2046
2077
  this.disposeWithMe(
2047
- this._commandService.onCommandExecuted((command) => {
2048
- command.id === SetWorksheetActiveOperation.id && setTimeout(() => {
2049
- const params = command.params, { unitId: showUnitId, subUnitId: showSubunitId } = params, drawingMap = this._drawingManagerService.drawingManagerData, insertDrawings = [], removeDrawings = [];
2050
- Object.keys(drawingMap).forEach((unitId) => {
2051
- const subUnitMap = drawingMap[unitId];
2052
- subUnitMap != null && Object.keys(subUnitMap).forEach((subUnitId) => {
2053
- const drawingData = subUnitMap[subUnitId].data;
2054
- drawingData != null && Object.keys(drawingData).forEach((drawingId) => {
2055
- if (unitId === showUnitId && subUnitId === showSubunitId) {
2056
- const drawing = drawingData[drawingId];
2057
- drawing.transform = drawingPositionToTransform(drawing.sheetTransform, this._selectionRenderService, this._skeletonManagerService), insertDrawings.push(drawingData[drawingId]);
2078
+ this._commandService.onCommandExecuted((i) => {
2079
+ i.id === Dr.id && setTimeout(() => {
2080
+ const e = i.params, { unitId: n, subUnitId: t } = e, r = this._drawingManagerService.drawingManagerData, s = [], o = [];
2081
+ Object.keys(r).forEach((d) => {
2082
+ const l = r[d];
2083
+ l != null && Object.keys(l).forEach((g) => {
2084
+ const c = l[g].data;
2085
+ c != null && Object.keys(c).forEach((a) => {
2086
+ if (d === n && g === t) {
2087
+ const h = c[a];
2088
+ h.transform = L(h.sheetTransform, this._selectionRenderService, this._skeletonManagerService), s.push(c[a]);
2058
2089
  } else
2059
- removeDrawings.push(drawingData[drawingId]);
2090
+ o.push(c[a]);
2060
2091
  });
2061
2092
  });
2062
- }), this._drawingManagerService.removeNotification(removeDrawings), this._drawingManagerService.addNotification(insertDrawings);
2093
+ }), this._drawingManagerService.removeNotification(o), this._drawingManagerService.addNotification(s);
2063
2094
  }, 0);
2064
2095
  })
2065
2096
  );
2066
2097
  }
2067
2098
  _sheetRefreshListener() {
2068
2099
  this.disposeWithMe(
2069
- this._commandService.onCommandExecuted((command) => {
2070
- REFRESH_MUTATIONS.includes(command.id) && requestIdleCallback(() => {
2071
- const params = command.params, { unitId, subUnitId, ranges } = params;
2072
- this._refreshDrawingTransform(unitId, subUnitId, ranges);
2100
+ this._commandService.onCommandExecuted((i) => {
2101
+ Fi.includes(i.id) && requestIdleCallback(() => {
2102
+ const e = i.params, { unitId: n, subUnitId: t, ranges: r } = e;
2103
+ this._refreshDrawingTransform(n, t, r);
2073
2104
  });
2074
2105
  })
2075
2106
  );
2076
2107
  }
2077
- _refreshDrawingTransform(unitId, subUnitId, ranges) {
2078
- const drawingData = this._drawingManagerService.getDrawingData(unitId, subUnitId), updateDrawings = [];
2079
- Object.keys(drawingData).forEach((drawingId) => {
2080
- const drawing = drawingData[drawingId], { sheetTransform, transform, anchorType = SheetDrawingAnchorType.Position } = drawing;
2081
- if (anchorType === SheetDrawingAnchorType.None)
2108
+ _refreshDrawingTransform(i, e, n) {
2109
+ const t = this._drawingManagerService.getDrawingData(i, e), r = [];
2110
+ Object.keys(t).forEach((s) => {
2111
+ const o = t[s], { sheetTransform: d, transform: l, anchorType: g = y.Position } = o;
2112
+ if (g === y.None)
2082
2113
  return !0;
2083
- const { from, to } = sheetTransform, { row: fromRow, column: fromColumn } = from, { row: toRow, column: toColumn } = to;
2084
- for (let i = 0; i < ranges.length; i++) {
2085
- const range = ranges[i], { startRow, endRow, startColumn, endColumn } = range;
2086
- if (Rectangle.intersects(
2114
+ const { from: c, to: a } = d, { row: h, column: u } = c, { row: m, column: f } = a;
2115
+ for (let p = 0; p < n.length; p++) {
2116
+ const C = n[p], { startRow: S, endRow: v, startColumn: R, endColumn: _ } = C;
2117
+ if (Dn.intersects(
2087
2118
  {
2088
- startRow,
2089
- endRow,
2090
- startColumn,
2091
- endColumn
2119
+ startRow: S,
2120
+ endRow: v,
2121
+ startColumn: R,
2122
+ endColumn: _
2092
2123
  },
2093
2124
  {
2094
- startRow: fromRow,
2095
- endRow: toRow,
2096
- startColumn: fromColumn,
2097
- endColumn: toColumn
2125
+ startRow: h,
2126
+ endRow: m,
2127
+ startColumn: u,
2128
+ endColumn: f
2098
2129
  }
2099
- ) || fromRow > endRow || fromColumn > endColumn) {
2100
- const isPositionAnchor = anchorType === SheetDrawingAnchorType.Position, newTransform = drawingPositionToTransform(sheetTransform, this._selectionRenderService, this._skeletonManagerService);
2101
- updateDrawings.push({
2102
- ...drawing,
2130
+ ) || h > v || u > _) {
2131
+ const I = g === y.Position, w = L(d, this._selectionRenderService, this._skeletonManagerService);
2132
+ r.push({
2133
+ ...o,
2103
2134
  transform: {
2104
- ...newTransform,
2105
- width: isPositionAnchor ? transform == null ? void 0 : transform.width : newTransform == null ? void 0 : newTransform.width,
2106
- height: isPositionAnchor ? transform == null ? void 0 : transform.height : newTransform == null ? void 0 : newTransform.height
2135
+ ...w,
2136
+ width: I ? l == null ? void 0 : l.width : w == null ? void 0 : w.width,
2137
+ height: I ? l == null ? void 0 : l.height : w == null ? void 0 : w.height
2107
2138
  }
2108
2139
  });
2109
2140
  break;
2110
2141
  }
2111
2142
  }
2112
- }), updateDrawings.length !== 0 && (this._drawingManagerService.refreshTransform(updateDrawings), this._commandService.syncExecuteCommand(ClearSheetDrawingTransformerOperation.id, [unitId]));
2113
- }
2114
- }, __name(_a8, "SheetDrawingTransformAffectedController"), _a8);
2115
- SheetDrawingTransformAffectedController = __decorateClass$2([
2116
- __decorateParam$2(1, IRenderManagerService),
2117
- __decorateParam$2(2, ICommandService),
2118
- __decorateParam$2(3, ISheetSelectionRenderService),
2119
- __decorateParam$2(4, Inject(SheetSkeletonManagerService)),
2120
- __decorateParam$2(5, Inject(SheetInterceptorService)),
2121
- __decorateParam$2(6, ISheetDrawingService),
2122
- __decorateParam$2(7, IDrawingManagerService),
2123
- __decorateParam$2(8, IUniverInstanceService)
2124
- ], SheetDrawingTransformAffectedController);
2125
- var __defProp$1 = Object.defineProperty, __getOwnPropDesc$1 = Object.getOwnPropertyDescriptor, __decorateClass$1 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
2126
- for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$1(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
2127
- (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
2128
- return kind && result && __defProp$1(target, key, result), result;
2129
- }, "__decorateClass$1"), __decorateParam$1 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$1");
2130
- function transformBound2DOMBound(originBound, scene, skeleton, worksheet) {
2131
- const { scaleX, scaleY } = scene.getAncestorScale(), viewMain = scene.getViewport(SHEET_VIEWPORT_KEY.VIEW_MAIN), absolute = {
2143
+ }), r.length !== 0 && (this._drawingManagerService.refreshTransform(r), this._commandService.syncExecuteCommand(j.id, [i]));
2144
+ }
2145
+ };
2146
+ ot = ki([
2147
+ Q(1, J),
2148
+ Q(2, B),
2149
+ Q(3, pe),
2150
+ Q(4, W(q)),
2151
+ Q(5, W(at)),
2152
+ Q(6, F),
2153
+ Q(7, K),
2154
+ Q(8, fe)
2155
+ ], ot);
2156
+ var Xi = Object.defineProperty, Hi = Object.getOwnPropertyDescriptor, zi = (i, e, n, t) => {
2157
+ for (var r = t > 1 ? void 0 : t ? Hi(e, n) : e, s = i.length - 1, o; s >= 0; s--)
2158
+ (o = i[s]) && (r = (t ? o(e, n, r) : o(r)) || r);
2159
+ return t && r && Xi(e, n, r), r;
2160
+ }, oe = (i, e) => (n, t) => e(n, t, i);
2161
+ function Ki(i, e, n, t) {
2162
+ const { scaleX: r, scaleY: s } = e.getAncestorScale(), o = e.getViewport(Kn.VIEW_MAIN), d = {
2132
2163
  left: !0,
2133
2164
  top: !0
2134
2165
  };
2135
- if (!viewMain)
2166
+ if (!o)
2136
2167
  return {
2137
- ...originBound,
2138
- absolute
2168
+ ...i,
2169
+ absolute: d
2139
2170
  };
2140
- const { left, right, top, bottom } = originBound, freeze = worksheet.getFreeze(), { startColumn, startRow, xSplit, ySplit } = freeze, startSheetView = skeleton.getNoMergeCellPositionByIndexWithNoHeader(startRow - ySplit, startColumn - xSplit), endSheetView = skeleton.getNoMergeCellPositionByIndexWithNoHeader(startRow, startColumn), { rowHeaderWidth, columnHeaderHeight } = skeleton, freezeWidth = endSheetView.startX - startSheetView.startX, freezeHeight = endSheetView.startY - startSheetView.startY, { top: freezeTop, left: freezeLeft, viewportScrollX: actualScrollX, viewportScrollY: actualScrollY } = viewMain;
2141
- let offsetLeft, offsetRight;
2142
- left < freezeLeft ? (absolute.left = !0, offsetLeft = (freezeWidth + rowHeaderWidth + (left - freezeLeft)) * scaleX, offsetRight = Math.max(
2171
+ const { left: l, right: g, top: c, bottom: a } = i, h = t.getFreeze(), { startColumn: u, startRow: m, xSplit: f, ySplit: p } = h, C = n.getNoMergeCellPositionByIndexWithNoHeader(m - p, u - f), S = n.getNoMergeCellPositionByIndexWithNoHeader(m, u), { rowHeaderWidth: v, columnHeaderHeight: R } = n, _ = S.startX - C.startX, I = S.startY - C.startY, { top: w, left: O, viewportScrollX: b, viewportScrollY: A } = o;
2172
+ let E, M;
2173
+ l < O ? (d.left = !0, E = (_ + v + (l - O)) * r, M = Math.max(
2143
2174
  Math.min(
2144
- (freezeWidth + rowHeaderWidth + (right - freezeLeft)) * scaleX,
2145
- (freezeWidth + rowHeaderWidth) * scaleX
2175
+ (_ + v + (g - O)) * r,
2176
+ (_ + v) * r
2146
2177
  ),
2147
- (right - actualScrollX) * scaleX
2148
- )) : (absolute.left = !1, offsetLeft = Math.max((left - actualScrollX) * scaleX, (freezeWidth + rowHeaderWidth) * scaleX), offsetRight = Math.max((right - actualScrollX) * scaleX, (freezeWidth + rowHeaderWidth) * scaleX));
2149
- let offsetTop, offsetBottom;
2150
- return top < freezeTop ? (absolute.top = !0, offsetTop = (freezeHeight + columnHeaderHeight + (top - freezeTop)) * scaleY, offsetBottom = Math.max(
2178
+ (g - b) * r
2179
+ )) : (d.left = !1, E = Math.max((l - b) * r, (_ + v) * r), M = Math.max((g - b) * r, (_ + v) * r));
2180
+ let D, U;
2181
+ return c < w ? (d.top = !0, D = (I + R + (c - w)) * s, U = Math.max(
2151
2182
  Math.min(
2152
- (freezeHeight + columnHeaderHeight + (right - freezeTop)) * scaleY,
2153
- (freezeHeight + columnHeaderHeight) * scaleY
2183
+ (I + R + (g - w)) * s,
2184
+ (I + R) * s
2154
2185
  ),
2155
- (bottom - actualScrollY) * scaleY
2156
- )) : (absolute.top = !1, offsetTop = Math.max((top - actualScrollY) * scaleY, (freezeHeight + columnHeaderHeight) * scaleY), offsetBottom = Math.max((bottom - actualScrollY) * scaleY, (freezeHeight + columnHeaderHeight) * scaleY)), {
2157
- left: offsetLeft,
2158
- right: offsetRight,
2159
- top: offsetTop,
2160
- bottom: offsetBottom,
2161
- absolute
2186
+ (a - A) * s
2187
+ )) : (d.top = !1, D = Math.max((c - A) * s, (I + R) * s), U = Math.max((a - A) * s, (I + R) * s)), {
2188
+ left: E,
2189
+ right: M,
2190
+ top: D,
2191
+ bottom: U,
2192
+ absolute: d
2162
2193
  };
2163
2194
  }
2164
- __name(transformBound2DOMBound, "transformBound2DOMBound");
2165
- const calcPosition = /* @__PURE__ */ __name((targetObject, currentRender, skeleton, worksheet) => {
2166
- const { scene } = currentRender, { left, top, width, height, angle } = targetObject, bound = {
2167
- left,
2168
- right: left + width,
2169
- top,
2170
- bottom: top + height
2171
- }, offsetBound = transformBound2DOMBound(bound, scene, skeleton, worksheet), { scaleX, scaleY } = scene.getAncestorScale();
2195
+ const Qe = (i, e, n, t) => {
2196
+ const { scene: r } = e, { left: s, top: o, width: d, height: l, angle: g } = i, c = {
2197
+ left: s,
2198
+ right: s + d,
2199
+ top: o,
2200
+ bottom: o + l
2201
+ }, a = Ki(c, r, n, t), { scaleX: h, scaleY: u } = r.getAncestorScale();
2172
2202
  return {
2173
- startX: offsetBound.left,
2174
- endX: offsetBound.right,
2175
- startY: offsetBound.top,
2176
- endY: offsetBound.bottom,
2177
- rotate: angle,
2178
- width: width * scaleX,
2179
- height: height * scaleY,
2180
- absolute: offsetBound.absolute
2203
+ startX: a.left,
2204
+ endX: a.right,
2205
+ startY: a.top,
2206
+ endY: a.bottom,
2207
+ rotate: g,
2208
+ width: d * h,
2209
+ height: l * u,
2210
+ absolute: a.absolute
2181
2211
  };
2182
- }, "calcPosition");
2183
- var _a9;
2184
- let SheetCanvasFloatDomManagerService = (_a9 = class extends Disposable {
2185
- constructor(_renderManagerService, _univerInstanceService, _commandService, _drawingManagerService, _canvasFloatDomService, _sheetDrawingService, _lifecycleService) {
2212
+ };
2213
+ let $e = class extends ie {
2214
+ constructor(e, n, t, r, s, o, d) {
2186
2215
  super();
2187
- __publicField(this, "_domLayerMap", /* @__PURE__ */ new Map());
2188
- __publicField(this, "_domLayerInfoMap", /* @__PURE__ */ new Map());
2189
- __publicField(this, "_transformChange$", new Subject());
2190
- __publicField(this, "transformChange$", this._transformChange$.asObservable());
2191
- __publicField(this, "_add$", new Subject());
2192
- __publicField(this, "add$", this._add$.asObservable());
2193
- __publicField(this, "_remove$", new Subject());
2194
- __publicField(this, "remove$", this._remove$.asObservable());
2195
- __publicField(this, "_hooks", []);
2196
- this._renderManagerService = _renderManagerService, this._univerInstanceService = _univerInstanceService, this._commandService = _commandService, this._drawingManagerService = _drawingManagerService, this._canvasFloatDomService = _canvasFloatDomService, this._sheetDrawingService = _sheetDrawingService, this._lifecycleService = _lifecycleService, this._drawingAddListener(), this._featureUpdateListener(), this._deleteListener(), this._bindScrollEvent();
2216
+ V(this, "_domLayerMap", /* @__PURE__ */ new Map());
2217
+ V(this, "_domLayerInfoMap", /* @__PURE__ */ new Map());
2218
+ V(this, "_transformChange$", new Ke());
2219
+ V(this, "transformChange$", this._transformChange$.asObservable());
2220
+ V(this, "_add$", new Ke());
2221
+ V(this, "add$", this._add$.asObservable());
2222
+ V(this, "_remove$", new Ke());
2223
+ V(this, "remove$", this._remove$.asObservable());
2224
+ V(this, "_hooks", []);
2225
+ this._renderManagerService = e, this._univerInstanceService = n, this._commandService = t, this._drawingManagerService = r, this._canvasFloatDomService = s, this._sheetDrawingService = o, this._lifecycleService = d, this._drawingAddListener(), this._featureUpdateListener(), this._deleteListener(), this._bindScrollEvent();
2197
2226
  }
2198
2227
  _bindScrollEvent() {
2199
- this._lifecycleService.lifecycle$.pipe(filter((s) => s === LifecycleStages.Rendered), take(1)).subscribe(() => {
2228
+ this._lifecycleService.lifecycle$.pipe(re((e) => e === bn.Rendered), mr(1)).subscribe(() => {
2200
2229
  this._scrollUpdateListener();
2201
2230
  });
2202
2231
  }
2203
- _ensureMap(unitId, subUnitId) {
2204
- let unitMap = this._domLayerMap.get(unitId);
2205
- unitMap || (unitMap = /* @__PURE__ */ new Map(), this._domLayerMap.set(unitId, unitMap));
2206
- let subUnitMap = unitMap.get(subUnitId);
2207
- return subUnitMap || (subUnitMap = /* @__PURE__ */ new Map(), unitMap.set(subUnitId, subUnitMap)), subUnitMap;
2232
+ _ensureMap(e, n) {
2233
+ let t = this._domLayerMap.get(e);
2234
+ t || (t = /* @__PURE__ */ new Map(), this._domLayerMap.set(e, t));
2235
+ let r = t.get(n);
2236
+ return r || (r = /* @__PURE__ */ new Map(), t.set(n, r)), r;
2208
2237
  }
2209
- getFloatDomInfo(id) {
2210
- return this._domLayerInfoMap.get(id);
2238
+ getFloatDomInfo(e) {
2239
+ return this._domLayerInfoMap.get(e);
2211
2240
  }
2212
- _getSceneAndTransformerByDrawingSearch(unitId) {
2213
- if (unitId == null)
2241
+ _getSceneAndTransformerByDrawingSearch(e) {
2242
+ if (e == null)
2214
2243
  return;
2215
- const renderObject = this._renderManagerService.getRenderById(unitId), scene = renderObject == null ? void 0 : renderObject.scene;
2216
- if (renderObject == null || scene == null)
2244
+ const n = this._renderManagerService.getRenderById(e), t = n == null ? void 0 : n.scene;
2245
+ if (n == null || t == null)
2217
2246
  return null;
2218
- const transformer = scene.getTransformerByCreate(), canvas = renderObject.engine.getCanvasElement();
2219
- return { scene, transformer, renderObject, canvas };
2247
+ const r = t.getTransformerByCreate(), s = n.engine.getCanvasElement();
2248
+ return { scene: t, transformer: r, renderObject: n, canvas: s };
2220
2249
  }
2221
- _getFloatDomProps(id) {
2222
- let props;
2223
- return this._hooks.forEach((hook) => {
2224
- props = hook.onGetFloatDomProps(id);
2225
- }), props;
2250
+ _getFloatDomProps(e) {
2251
+ let n;
2252
+ return this._hooks.forEach((t) => {
2253
+ n = t.onGetFloatDomProps(e);
2254
+ }), n;
2226
2255
  }
2227
2256
  // eslint-disable-next-line max-lines-per-function
2228
2257
  _drawingAddListener() {
2229
2258
  this.disposeWithMe(
2230
2259
  // eslint-disable-next-line max-lines-per-function
2231
- this._drawingManagerService.add$.subscribe((params) => {
2232
- params.forEach((param) => {
2233
- var _a11, _b, _c;
2234
- const { unitId, subUnitId, drawingId } = param, target = getSheetCommandTarget(this._univerInstanceService, { unitId, subUnitId }), floatDomParam = this._drawingManagerService.getDrawingByParam(param);
2235
- if (!floatDomParam || !target)
2260
+ this._drawingManagerService.add$.subscribe((e) => {
2261
+ e.forEach((n) => {
2262
+ var ut, ht, gt;
2263
+ const { unitId: t, subUnitId: r, drawingId: s } = n, o = ce(this._univerInstanceService, { unitId: t, subUnitId: r }), d = this._drawingManagerService.getDrawingByParam(n), l = this._univerInstanceService.getUnit(t);
2264
+ if (!l)
2265
+ return;
2266
+ const g = l.getActiveSheet().getSheetId();
2267
+ if (!d || !o)
2236
2268
  return;
2237
- const skeleton = (_a11 = this._renderManagerService.getRenderById(unitId)) == null ? void 0 : _a11.with(SheetSkeletonManagerService).getWorksheetSkeleton(subUnitId);
2238
- if (!skeleton)
2269
+ const c = (ut = this._renderManagerService.getRenderById(t)) == null ? void 0 : ut.with(q).getWorksheetSkeleton(r);
2270
+ if (!c)
2239
2271
  return;
2240
- const { transform, drawingType, data } = floatDomParam;
2241
- if (drawingType !== DrawingTypeEnum.DRAWING_DOM && drawingType !== DrawingTypeEnum.DRAWING_CHART)
2272
+ const { transform: a, drawingType: h, data: u } = d;
2273
+ if (h !== k.DRAWING_DOM && h !== k.DRAWING_CHART)
2242
2274
  return;
2243
- const renderObject = this._getSceneAndTransformerByDrawingSearch(unitId);
2244
- if (renderObject == null)
2275
+ const m = this._getSceneAndTransformerByDrawingSearch(t);
2276
+ if (m == null)
2245
2277
  return;
2246
- const { scene, canvas } = renderObject;
2247
- if (transform == null)
2278
+ const { scene: f, canvas: p } = m;
2279
+ if (a == null)
2248
2280
  return !0;
2249
- const { left, top, width, height, angle, flipX, flipY, skewX, skewY } = transform, rectShapeKey = getDrawingShapeKeyByDrawingSearch({ unitId, subUnitId, drawingId }), rectShape = scene.getObject(rectShapeKey);
2250
- if (rectShape != null) {
2251
- rectShape.transformByState({ left, top, width, height, angle, flipX, flipY, skewX, skewY });
2281
+ if (g !== r)
2282
+ return;
2283
+ const { left: C, top: S, width: v, height: R, angle: _, flipX: I, flipY: w, skewX: O, skewY: b } = a, A = ze({ unitId: t, subUnitId: r, drawingId: s }), E = f.getObject(A);
2284
+ if (E != null) {
2285
+ E.transformByState({ left: C, top: S, width: v, height: R, angle: _, flipX: I, flipY: w, skewX: O, skewY: b });
2252
2286
  return;
2253
2287
  }
2254
- const imageConfig = {
2255
- left,
2256
- top,
2257
- width,
2258
- height,
2259
- zIndex: this._drawingManagerService.getDrawingOrder(unitId, subUnitId).length - 1
2260
- }, isChart = drawingType === DrawingTypeEnum.DRAWING_CHART;
2261
- isChart && (imageConfig.fill = "white", imageConfig.rotateEnabled = !1, data && data.border && (imageConfig.stroke = data.border), imageConfig.paintFirst = "stroke", imageConfig.strokeWidth = 1, imageConfig.borderEnabled = !1);
2262
- const rect = new Rect(rectShapeKey, imageConfig);
2263
- isChart && rect.setObjectType(ObjectType.CHART), scene.addObject(rect, DRAWING_OBJECT_LAYER_INDEX), floatDomParam.allowTransform !== !1 && scene.attachTransformerTo(rect);
2264
- const map2 = this._ensureMap(unitId, subUnitId), disposableCollection = new DisposableCollection(), initPosition = calcPosition(rect, renderObject.renderObject, skeleton.skeleton, target.worksheet), position$ = new BehaviorSubject(initPosition), info = {
2265
- dispose: disposableCollection,
2266
- rect,
2267
- position$,
2268
- unitId,
2269
- subUnitId
2288
+ const M = {
2289
+ left: C,
2290
+ top: S,
2291
+ width: v,
2292
+ height: R,
2293
+ zIndex: this._drawingManagerService.getDrawingOrder(t, r).length - 1
2294
+ }, D = h === k.DRAWING_CHART;
2295
+ D && (M.fill = "white", M.rotateEnabled = !1, u && u.border && (M.stroke = u.border), M.paintFirst = "stroke", M.strokeWidth = 1, M.borderEnabled = !1, M.radius = 8);
2296
+ const U = new wt(A, M);
2297
+ D && U.setObjectType(Hn.CHART), f.addObject(U, zn), d.allowTransform !== !1 && f.attachTransformerTo(U);
2298
+ const x = this._ensureMap(t, r), Z = new yn(), hn = Qe(U, m.renderObject, c.skeleton, o.worksheet), Fe = new fr(hn), gn = {
2299
+ dispose: Z,
2300
+ rect: U,
2301
+ position$: Fe,
2302
+ unitId: t,
2303
+ subUnitId: r
2270
2304
  };
2271
2305
  this._canvasFloatDomService.addFloatDom({
2272
- position$,
2273
- id: drawingId,
2274
- componentKey: floatDomParam.componentKey,
2275
- onPointerDown: /* @__PURE__ */ __name((evt) => {
2276
- canvas.dispatchEvent(new PointerEvent(evt.type, evt));
2277
- }, "onPointerDown"),
2278
- onPointerMove: /* @__PURE__ */ __name((evt) => {
2279
- canvas.dispatchEvent(new PointerEvent(evt.type, evt));
2280
- }, "onPointerMove"),
2281
- onPointerUp: /* @__PURE__ */ __name((evt) => {
2282
- canvas.dispatchEvent(new PointerEvent(evt.type, evt));
2283
- }, "onPointerUp"),
2284
- onWheel: /* @__PURE__ */ __name((evt) => {
2285
- canvas.dispatchEvent(new WheelEvent(evt.type, evt));
2286
- }, "onWheel"),
2287
- props: (_c = (_b = map2.get(drawingId)) == null ? void 0 : _b.props) != null ? _c : this._getFloatDomProps(drawingId),
2288
- data,
2289
- unitId
2306
+ position$: Fe,
2307
+ id: s,
2308
+ componentKey: d.componentKey,
2309
+ onPointerDown: (G) => {
2310
+ p.dispatchEvent(new PointerEvent(G.type, G));
2311
+ },
2312
+ onPointerMove: (G) => {
2313
+ p.dispatchEvent(new PointerEvent(G.type, G));
2314
+ },
2315
+ onPointerUp: (G) => {
2316
+ p.dispatchEvent(new PointerEvent(G.type, G));
2317
+ },
2318
+ onWheel: (G) => {
2319
+ p.dispatchEvent(new WheelEvent(G.type, G));
2320
+ },
2321
+ props: (gt = (ht = x.get(s)) == null ? void 0 : ht.props) != null ? gt : this._getFloatDomProps(s),
2322
+ data: u,
2323
+ unitId: t
2290
2324
  });
2291
- const listener = rect.onTransformChange$.subscribeEvent(() => {
2292
- const newPosition = calcPosition(rect, renderObject.renderObject, skeleton.skeleton, target.worksheet);
2293
- position$.next(
2294
- newPosition
2325
+ const lt = U.onTransformChange$.subscribeEvent(() => {
2326
+ const G = Qe(U, m.renderObject, c.skeleton, o.worksheet);
2327
+ Fe.next(
2328
+ G
2295
2329
  );
2296
2330
  });
2297
- disposableCollection.add(() => {
2298
- this._canvasFloatDomService.removeFloatDom(drawingId);
2299
- }), listener && disposableCollection.add(listener), this._domLayerInfoMap.set(drawingId, info), map2.set(drawingId, {
2300
- ...map2.get(drawingId)
2331
+ Z.add(() => {
2332
+ this._canvasFloatDomService.removeFloatDom(s);
2333
+ }), lt && Z.add(lt), this._domLayerInfoMap.set(s, gn), x.set(s, {
2334
+ ...x.get(s)
2301
2335
  });
2302
2336
  });
2303
2337
  })
2304
2338
  ), this.disposeWithMe(
2305
- this._drawingManagerService.remove$.subscribe((params) => {
2306
- params.forEach((param) => {
2307
- const { unitId, subUnitId, drawingId } = param, rectShapeKey = getDrawingShapeKeyByDrawingSearch({ unitId, subUnitId, drawingId }), renderObject = this._getSceneAndTransformerByDrawingSearch(unitId);
2308
- if (renderObject == null)
2339
+ this._drawingManagerService.remove$.subscribe((e) => {
2340
+ e.forEach((n) => {
2341
+ const { unitId: t, subUnitId: r, drawingId: s } = n, o = ze({ unitId: t, subUnitId: r, drawingId: s }), d = this._getSceneAndTransformerByDrawingSearch(t);
2342
+ if (d == null)
2309
2343
  return;
2310
- const { transformer, scene } = renderObject, rectShape = scene.getObject(rectShapeKey);
2311
- rectShape != null && rectShape.oKey && transformer.clearControlByIds([rectShape == null ? void 0 : rectShape.oKey]);
2344
+ const { transformer: l, scene: g } = d, c = g.getObject(o);
2345
+ c != null && c.oKey && l.clearControlByIds([c == null ? void 0 : c.oKey]);
2312
2346
  });
2313
2347
  })
2314
2348
  );
2315
2349
  }
2316
2350
  _scrollUpdateListener() {
2317
- const updateSheet = /* @__PURE__ */ __name((unitId, subUnitId) => {
2318
- var _a11;
2319
- const renderObject = this._getSceneAndTransformerByDrawingSearch(unitId), map2 = this._ensureMap(unitId, subUnitId), ids = Array.from(map2.keys()), target = getSheetCommandTarget(this._univerInstanceService, { unitId, subUnitId }), skeleton = (_a11 = this._renderManagerService.getRenderById(unitId)) == null ? void 0 : _a11.with(SheetSkeletonManagerService).getWorksheetSkeleton(subUnitId);
2320
- !renderObject || !target || !skeleton || ids.forEach((id) => {
2321
- const info = this._domLayerInfoMap.get(id);
2322
- if (info) {
2323
- const position = calcPosition(info.rect, renderObject.renderObject, skeleton.skeleton, target.worksheet);
2324
- info.position$.next(position);
2351
+ const e = (n, t) => {
2352
+ var g;
2353
+ const r = this._getSceneAndTransformerByDrawingSearch(n), s = this._ensureMap(n, t), o = Array.from(s.keys()), d = ce(this._univerInstanceService, { unitId: n, subUnitId: t }), l = (g = this._renderManagerService.getRenderById(n)) == null ? void 0 : g.with(q).getWorksheetSkeleton(t);
2354
+ !r || !d || !l || o.forEach((c) => {
2355
+ const a = this._domLayerInfoMap.get(c);
2356
+ if (a) {
2357
+ const h = Qe(a.rect, r.renderObject, l.skeleton, d.worksheet);
2358
+ a.position$.next(h);
2325
2359
  }
2326
2360
  });
2327
- }, "updateSheet");
2361
+ };
2328
2362
  this.disposeWithMe(
2329
- this._univerInstanceService.getCurrentTypeOfUnit$(UniverInstanceType.UNIVER_SHEET).pipe(
2330
- filter((sheet) => !!sheet),
2331
- map((sheet) => {
2332
- const render2 = this._renderManagerService.getRenderById(sheet.getUnitId());
2333
- return render2 ? { render: render2, unitId: sheet.getUnitId(), subUnitId: sheet.getActiveSheet().getSheetId() } : null;
2363
+ this._univerInstanceService.getCurrentTypeOfUnit$(Y.UNIVER_SHEET).pipe(
2364
+ re((n) => !!n),
2365
+ St((n) => n.activeSheet$),
2366
+ re((n) => !!n),
2367
+ Ee((n) => {
2368
+ const t = this._renderManagerService.getRenderById(n.getUnitId());
2369
+ return t ? { render: t, unitId: n.getUnitId(), subUnitId: n.getSheetId() } : null;
2334
2370
  }),
2335
- filter((render2) => !!render2),
2336
- switchMap(
2337
- (render2) => fromEventSubject(render2.render.scene.getViewport(VIEWPORT_KEY.VIEW_MAIN).onScrollAfter$).pipe(map(() => ({ unitId: render2.unitId, subUnitId: render2.subUnitId })))
2371
+ re((n) => !!n),
2372
+ St(
2373
+ (n) => On(n.render.scene.getViewport(nr.VIEW_MAIN).onScrollAfter$).pipe(Ee(() => ({ unitId: n.unitId, subUnitId: n.subUnitId })))
2338
2374
  )
2339
- ).subscribe(({ unitId, subUnitId }) => {
2340
- updateSheet(unitId, subUnitId);
2375
+ ).subscribe(({ unitId: n, subUnitId: t }) => {
2376
+ e(n, t);
2341
2377
  })
2342
- ), this.disposeWithMe(this._commandService.onCommandExecuted((commandInfo) => {
2343
- var _a11, _b;
2344
- if (commandInfo.id === SetZoomRatioOperation.id) {
2345
- const params = commandInfo.params, { unitId } = params;
2346
- Array.from((_b = (_a11 = this._domLayerMap.get(unitId)) == null ? void 0 : _a11.keys()) != null ? _b : []).forEach((subUnitId) => {
2347
- updateSheet(unitId, subUnitId);
2378
+ ), this.disposeWithMe(this._commandService.onCommandExecuted((n) => {
2379
+ var t, r;
2380
+ if (n.id === rr.id) {
2381
+ const s = n.params, { unitId: o } = s;
2382
+ Array.from((r = (t = this._domLayerMap.get(o)) == null ? void 0 : t.keys()) != null ? r : []).forEach((l) => {
2383
+ e(o, l);
2348
2384
  });
2349
- } else if (commandInfo.id === SetFrozenMutation.id) {
2350
- const { unitId, subUnitId } = commandInfo.params;
2351
- updateSheet(unitId, subUnitId);
2385
+ } else if (n.id === Mr.id) {
2386
+ const { unitId: s, subUnitId: o } = n.params;
2387
+ e(s, o);
2352
2388
  }
2353
2389
  }));
2354
2390
  }
2355
- _getPosition(position, unitId) {
2356
- var _a11;
2357
- const { startX, endX, startY, endY } = position, selectionRenderService = (_a11 = this._renderManagerService.getRenderById(unitId)) == null ? void 0 : _a11.with(ISheetSelectionRenderService);
2358
- if (selectionRenderService == null)
2391
+ _getPosition(e, n) {
2392
+ var h;
2393
+ const { startX: t, endX: r, startY: s, endY: o } = e, d = (h = this._renderManagerService.getRenderById(n)) == null ? void 0 : h.with(pe);
2394
+ if (d == null)
2359
2395
  return;
2360
- const start = selectionRenderService.getSelectionCellByPosition(startX, startY);
2361
- if (start == null)
2396
+ const l = d.getCellWithCoordByOffset(t, s);
2397
+ if (l == null)
2362
2398
  return;
2363
- const from = {
2364
- column: start.actualColumn,
2365
- columnOffset: startX - start.startX,
2366
- row: start.actualRow,
2367
- rowOffset: startY - start.startY
2368
- }, end = selectionRenderService.getSelectionCellByPosition(endX, endY);
2369
- if (end == null)
2399
+ const g = {
2400
+ column: l.actualColumn,
2401
+ columnOffset: t - l.startX,
2402
+ row: l.actualRow,
2403
+ rowOffset: s - l.startY
2404
+ }, c = d.getCellWithCoordByOffset(r, o);
2405
+ if (c == null)
2370
2406
  return;
2371
- const to = {
2372
- column: end.actualColumn,
2373
- columnOffset: endX - end.startX,
2374
- row: end.actualRow,
2375
- rowOffset: endY - end.startY
2407
+ const a = {
2408
+ column: c.actualColumn,
2409
+ columnOffset: r - c.startX,
2410
+ row: c.actualRow,
2411
+ rowOffset: o - c.startY
2376
2412
  };
2377
2413
  return {
2378
- from,
2379
- to
2414
+ from: g,
2415
+ to: a
2380
2416
  };
2381
2417
  }
2382
2418
  _featureUpdateListener() {
2383
2419
  this.disposeWithMe(
2384
- this._drawingManagerService.update$.subscribe((params) => {
2385
- params.forEach((data) => {
2386
- const sheetDrawing = this._drawingManagerService.getDrawingByParam(data);
2387
- if (!sheetDrawing || sheetDrawing.drawingType !== DrawingTypeEnum.DRAWING_DOM && sheetDrawing.drawingType !== DrawingTypeEnum.DRAWING_CHART)
2420
+ this._drawingManagerService.update$.subscribe((e) => {
2421
+ e.forEach((n) => {
2422
+ const t = this._drawingManagerService.getDrawingByParam(n);
2423
+ if (!t || t.drawingType !== k.DRAWING_DOM && t.drawingType !== k.DRAWING_CHART)
2388
2424
  return;
2389
- const newValue = {
2390
- ...sheetDrawing.transform
2425
+ const r = {
2426
+ ...t.transform
2391
2427
  };
2392
- this._transformChange$.next({ id: data.drawingId, value: newValue });
2428
+ this._transformChange$.next({ id: n.drawingId, value: r });
2393
2429
  });
2394
2430
  })
2395
2431
  );
2396
2432
  }
2397
2433
  _deleteListener() {
2398
2434
  this.disposeWithMe(
2399
- this._drawingManagerService.remove$.subscribe((params) => {
2400
- params.forEach((param) => {
2401
- this._removeDom(param.drawingId);
2435
+ this._drawingManagerService.remove$.subscribe((e) => {
2436
+ e.forEach((n) => {
2437
+ this._removeDom(n.drawingId);
2402
2438
  });
2403
2439
  })
2404
2440
  );
2405
2441
  }
2406
- updateFloatDomProps(unitId, subUnitId, id, props) {
2407
- const info = this._domLayerInfoMap.get(id), renderObject = this._getSceneAndTransformerByDrawingSearch(unitId);
2408
- if (info && renderObject) {
2409
- const { scene } = renderObject, rectShapeKey = getDrawingShapeKeyByDrawingSearch({ unitId, subUnitId, drawingId: id }), rectShape = scene.getObject(rectShapeKey);
2410
- rectShape && rectShape instanceof Rect && rectShape.setProps(props);
2442
+ updateFloatDomProps(e, n, t, r) {
2443
+ const s = this._domLayerInfoMap.get(t), o = this._getSceneAndTransformerByDrawingSearch(e);
2444
+ if (s && o) {
2445
+ const { scene: d } = o, l = ze({ unitId: e, subUnitId: n, drawingId: t }), g = d.getObject(l);
2446
+ g && g instanceof wt && g.setProps(r);
2411
2447
  }
2412
2448
  }
2413
- addFloatDomToPosition(layer, propId, executeCommand = !0) {
2414
- const target = getSheetCommandTarget(this._univerInstanceService, {
2415
- unitId: layer.unitId,
2416
- subUnitId: layer.subUnitId
2449
+ addFloatDomToPosition(e, n) {
2450
+ const t = ce(this._univerInstanceService, {
2451
+ unitId: e.unitId,
2452
+ subUnitId: e.subUnitId
2417
2453
  });
2418
- if (!target)
2454
+ if (!t)
2419
2455
  throw new Error("cannot find current target!");
2420
- const { unitId, subUnitId } = target, { initPosition, componentKey, data, allowTransform = !0 } = layer, id = propId != null ? propId : generateRandomId(), sheetTransform = this._getPosition(initPosition, unitId);
2421
- if (sheetTransform == null)
2456
+ const { unitId: r, subUnitId: s } = t, { initPosition: o, componentKey: d, data: l, allowTransform: g = !0 } = e, c = n != null ? n : Tn(), a = this._getPosition(o, r);
2457
+ if (a == null)
2422
2458
  return;
2423
- this._ensureMap(unitId, subUnitId).set(id, layer);
2424
- const sheetDrawingParam = {
2425
- unitId,
2426
- subUnitId,
2427
- drawingId: id,
2428
- drawingType: layer.type || DrawingTypeEnum.DRAWING_DOM,
2429
- componentKey,
2430
- sheetTransform,
2459
+ this._ensureMap(r, s).set(c, e);
2460
+ const u = {
2461
+ unitId: r,
2462
+ subUnitId: s,
2463
+ drawingId: c,
2464
+ drawingType: e.type || k.DRAWING_DOM,
2465
+ componentKey: d,
2466
+ sheetTransform: a,
2431
2467
  transform: {
2432
- left: initPosition.startX,
2433
- top: initPosition.startY,
2434
- width: initPosition.endX - initPosition.startX,
2435
- height: initPosition.endY - initPosition.startY
2468
+ left: o.startX,
2469
+ top: o.startY,
2470
+ width: o.endX - o.startX,
2471
+ height: o.endY - o.startY
2436
2472
  },
2437
- data,
2438
- allowTransform
2473
+ data: l,
2474
+ allowTransform: g
2439
2475
  };
2440
- return executeCommand && this._commandService.executeCommand(InsertSheetDrawingCommand.id, {
2441
- unitId,
2442
- drawings: [sheetDrawingParam]
2443
- }), this._add$.next({ unitId, subUnitId, id }), {
2444
- id,
2445
- dispose: /* @__PURE__ */ __name(() => {
2446
- this._removeDom(id, !0);
2447
- }, "dispose"),
2448
- sheetDrawingParam
2476
+ return this._commandService.executeCommand(ke.id, {
2477
+ unitId: r,
2478
+ drawings: [u]
2479
+ }), this._add$.next({ unitId: r, subUnitId: s, id: c }), {
2480
+ id: c,
2481
+ dispose: () => {
2482
+ this._removeDom(c, !0);
2483
+ }
2449
2484
  };
2450
2485
  }
2451
- _removeDom(id, removeDrawing = !1) {
2452
- const info = this._domLayerInfoMap.get(id);
2453
- if (!info)
2486
+ _removeDom(e, n = !1) {
2487
+ const t = this._domLayerInfoMap.get(e);
2488
+ if (!t)
2454
2489
  return;
2455
- const { unitId, subUnitId } = info;
2456
- this._domLayerInfoMap.delete(id), info.dispose.dispose();
2457
- const renderObject = this._getSceneAndTransformerByDrawingSearch(unitId);
2458
- if (renderObject && renderObject.scene.removeObject(info.rect), removeDrawing) {
2459
- this._ensureMap(unitId, subUnitId).delete(id);
2460
- const param = this._drawingManagerService.getDrawingByParam({ unitId, subUnitId, drawingId: id });
2461
- if (!param)
2490
+ const { unitId: r, subUnitId: s } = t;
2491
+ this._domLayerInfoMap.delete(e), t.dispose.dispose();
2492
+ const o = this._getSceneAndTransformerByDrawingSearch(r);
2493
+ if (o && o.scene.removeObject(t.rect), n) {
2494
+ this._ensureMap(r, s).delete(e);
2495
+ const l = this._drawingManagerService.getDrawingByParam({ unitId: r, subUnitId: s, drawingId: e });
2496
+ if (!l)
2462
2497
  return;
2463
- const jsonOp = this._sheetDrawingService.getBatchRemoveOp([param]), { redo, objects } = jsonOp;
2464
- this._commandService.syncExecuteCommand(SetDrawingApplyMutation.id, { unitId, subUnitId, op: redo, objects, type: DrawingApplyType.REMOVE });
2498
+ const g = this._sheetDrawingService.getBatchRemoveOp([l]), { redo: c, objects: a } = g;
2499
+ this._commandService.syncExecuteCommand(T.id, { unitId: r, subUnitId: s, op: c, objects: a, type: P.REMOVE });
2465
2500
  }
2466
2501
  }
2467
- addHook(hook) {
2468
- return this._hooks.push(hook), {
2469
- dispose: /* @__PURE__ */ __name(() => {
2470
- const index = this._hooks.findIndex((h) => h === hook);
2471
- this._hooks.splice(index, 1);
2472
- }, "dispose")
2502
+ addHook(e) {
2503
+ return this._hooks.push(e), {
2504
+ dispose: () => {
2505
+ const n = this._hooks.findIndex((t) => t === e);
2506
+ this._hooks.splice(n, 1);
2507
+ }
2473
2508
  };
2474
2509
  }
2475
- }, __name(_a9, "SheetCanvasFloatDomManagerService"), _a9);
2476
- SheetCanvasFloatDomManagerService = __decorateClass$1([
2477
- __decorateParam$1(0, Inject(IRenderManagerService)),
2478
- __decorateParam$1(1, IUniverInstanceService),
2479
- __decorateParam$1(2, Inject(ICommandService)),
2480
- __decorateParam$1(3, IDrawingManagerService),
2481
- __decorateParam$1(4, Inject(CanvasFloatDomService)),
2482
- __decorateParam$1(5, ISheetDrawingService),
2483
- __decorateParam$1(6, Inject(LifecycleService))
2484
- ], SheetCanvasFloatDomManagerService);
2485
- var __defProp2 = Object.defineProperty, __getOwnPropDesc = Object.getOwnPropertyDescriptor, __defNormalProp2 = /* @__PURE__ */ __name((obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value, "__defNormalProp"), __decorateClass = /* @__PURE__ */ __name((decorators, target, key, kind) => {
2486
- for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
2487
- (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
2488
- return kind && result && __defProp2(target, key, result), result;
2489
- }, "__decorateClass"), __decorateParam = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam"), __publicField2 = /* @__PURE__ */ __name((obj, key, value) => __defNormalProp2(obj, typeof key != "symbol" ? key + "" : key, value), "__publicField");
2490
- const PLUGIN_NAME = "SHEET_IMAGE_UI_PLUGIN";
2491
- var _a10;
2492
- let UniverSheetsDrawingUIPlugin = (_a10 = class extends Plugin {
2493
- constructor(_config = defaultPluginConfig, _injector, _renderManagerService, _configService) {
2494
- super(), this._config = _config, this._injector = _injector, this._renderManagerService = _renderManagerService, this._configService = _configService;
2495
- const { menu, ...rest } = this._config;
2496
- menu && this._configService.setConfig("menu", menu, { merge: !0 }), this._configService.setConfig(PLUGIN_CONFIG_KEY, rest);
2510
+ };
2511
+ $e = zi([
2512
+ oe(0, W(J)),
2513
+ oe(1, fe),
2514
+ oe(2, W(B)),
2515
+ oe(3, K),
2516
+ oe(4, W(gr)),
2517
+ oe(5, F),
2518
+ oe(6, W(Mn))
2519
+ ], $e);
2520
+ var ln = Object.defineProperty, Ji = Object.getOwnPropertyDescriptor, Zi = (i, e, n) => e in i ? ln(i, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : i[e] = n, qi = (i, e, n, t) => {
2521
+ for (var r = t > 1 ? void 0 : t ? Ji(e, n) : e, s = i.length - 1, o; s >= 0; s--)
2522
+ (o = i[s]) && (r = (t ? o(e, n, r) : o(r)) || r);
2523
+ return t && r && ln(e, n, r), r;
2524
+ }, et = (i, e) => (n, t) => e(n, t, i), un = (i, e, n) => Zi(i, typeof e != "symbol" ? e + "" : e, n);
2525
+ const Qi = "SHEET_IMAGE_UI_PLUGIN";
2526
+ let Le = class extends En {
2527
+ constructor(i = Tr, e, n, t) {
2528
+ super(), this._config = i, this._injector = e, this._renderManagerService = n, this._configService = t;
2529
+ const { menu: r, ...s } = this._config;
2530
+ r && this._configService.setConfig("menu", r, { merge: !0 }), this._configService.setConfig(Or, s);
2497
2531
  }
2498
2532
  onStarting() {
2499
- registerDependencies(this._injector, [
2500
- [SheetCanvasFloatDomManagerService],
2501
- [SheetDrawingUIController],
2502
- [DrawingPopupMenuController],
2503
- [SheetDrawingPrintingController],
2504
- [SheetDrawingPermissionController],
2505
- [SheetsDrawingCopyPasteController]
2506
- ]), touchDependencies(this._injector, [
2507
- [SheetCanvasFloatDomManagerService]
2533
+ Un(this._injector, [
2534
+ [$e],
2535
+ [Ne],
2536
+ [Ue],
2537
+ [xe],
2538
+ [We],
2539
+ [je]
2540
+ ]), Xe(this._injector, [
2541
+ [$e]
2508
2542
  ]);
2509
2543
  }
2510
2544
  onReady() {
2511
- touchDependencies(this._injector, [
2512
- [SheetsDrawingCopyPasteController]
2545
+ Xe(this._injector, [
2546
+ [je]
2513
2547
  ]);
2514
2548
  }
2515
2549
  onRendered() {
2516
- this._registerRenderModules(), touchDependencies(this._injector, [
2517
- [SheetDrawingPermissionController],
2518
- [SheetDrawingPrintingController],
2519
- [SheetDrawingUIController]
2550
+ this._registerRenderModules(), Xe(this._injector, [
2551
+ [We],
2552
+ [xe],
2553
+ [Ne]
2520
2554
  ]);
2521
2555
  }
2522
2556
  onSteady() {
2523
- this._injector.get(DrawingPopupMenuController);
2557
+ this._injector.get(Ue);
2524
2558
  }
2525
2559
  _registerRenderModules() {
2526
2560
  [
2527
- [SheetDrawingUpdateController],
2528
- [SheetDrawingTransformAffectedController],
2529
- [SheetsDrawingRenderController]
2530
- ].forEach((m) => {
2531
- this.disposeWithMe(this._renderManagerService.registerRenderModule(UniverInstanceType.UNIVER_SHEET, m));
2561
+ [Ae],
2562
+ [ot],
2563
+ [st]
2564
+ ].forEach((i) => {
2565
+ this.disposeWithMe(this._renderManagerService.registerRenderModule(Y.UNIVER_SHEET, i));
2532
2566
  });
2533
2567
  }
2534
- }, __name(_a10, "UniverSheetsDrawingUIPlugin"), _a10);
2535
- __publicField2(UniverSheetsDrawingUIPlugin, "type", UniverInstanceType.UNIVER_SHEET);
2536
- __publicField2(UniverSheetsDrawingUIPlugin, "pluginName", PLUGIN_NAME);
2537
- UniverSheetsDrawingUIPlugin = __decorateClass([
2538
- DependentOn(UniverDrawingPlugin, UniverDrawingUIPlugin, UniverSheetsDrawingPlugin),
2539
- __decorateParam(1, Inject(Injector)),
2540
- __decorateParam(2, IRenderManagerService),
2541
- __decorateParam(3, IConfigService)
2542
- ], UniverSheetsDrawingUIPlugin);
2568
+ };
2569
+ un(Le, "type", Y.UNIVER_SHEET);
2570
+ un(Le, "pluginName", Qi);
2571
+ Le = qi([
2572
+ Pn(xn, Yn, Jn),
2573
+ et(1, W(Rt)),
2574
+ et(2, J),
2575
+ et(3, An)
2576
+ ], Le);
2543
2577
  export {
2544
- ClearSheetDrawingTransformerOperation,
2545
- DeleteDrawingsCommand,
2546
- EditSheetDrawingOperation,
2547
- GroupSheetDrawingCommand,
2548
- IMAGE_MENU_ID,
2549
- InsertFloatImageCommand,
2550
- InsertSheetDrawingCommand,
2551
- MoveDrawingsCommand,
2552
- RemoveSheetDrawingCommand,
2553
- SetDrawingArrangeCommand,
2554
- SetSheetDrawingCommand,
2555
- SheetCanvasFloatDomManagerService,
2556
- SidebarSheetDrawingOperation,
2557
- UngroupSheetDrawingCommand,
2558
- UniverSheetsDrawingUIPlugin
2578
+ j as ClearSheetDrawingTransformerOperation,
2579
+ nn as DeleteDrawingsCommand,
2580
+ Jt as EditSheetDrawingOperation,
2581
+ rn as GroupSheetDrawingCommand,
2582
+ cn as IMAGE_MENU_ID,
2583
+ dt as InsertFloatImageCommand,
2584
+ ke as InsertSheetDrawingCommand,
2585
+ we as MoveDrawingsCommand,
2586
+ Ge as RemoveSheetDrawingCommand,
2587
+ sn as SetDrawingArrangeCommand,
2588
+ Ye as SetSheetDrawingCommand,
2589
+ $e as SheetCanvasFloatDomManagerService,
2590
+ Kt as SidebarSheetDrawingOperation,
2591
+ on as UngroupSheetDrawingCommand,
2592
+ Le as UniverSheetsDrawingUIPlugin
2559
2593
  };