@univerjs/sheets-drawing-ui 0.4.2-nightly.202411071606 → 0.4.2-nightly.202411081606

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