@univerjs/docs-drawing-ui 0.2.3 → 0.2.4

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,144 +1,144 @@
1
- var dt = Object.defineProperty;
2
- var mt = (i, e, n) => e in i ? dt(i, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : i[e] = n;
3
- var Pe = (i, e, n) => mt(i, typeof e != "symbol" ? e + "" : e, n);
4
- import { CommandType as $, ICommandService as W, IUniverInstanceService as X, TextX as Je, JSONX as k, MemoryCursor as ut, TextXActionType as j, LocaleService as en, RxDisposable as gt, UniverInstanceType as Ce, toDisposable as Ee, FOCUSING_COMMON_DRAWINGS as Ze, OnLifecycle as nn, LifecycleStages as tn, IContextService as xn, PositionedObjectLayoutType as B, BooleanNumber as Me, ObjectRelativeFromH as Y, ObjectRelativeFromV as G, Tools as _e, WrapTextType as Ae, Direction as ae, IUndoRedoService as mn, FOCUSING_UNIVER_EDITOR as pt, Disposable as Ue, UndoCommand as ft, RedoCommand as ht, throttle as In, COLORS as wt, Plugin as vt, DependentOn as It } from "@univerjs/core";
5
- import { Inject as Se, Injector as Un } from "@wendellhu/redi";
6
- import { ImageCropperObject as _t, COMPONENT_IMAGE_POPUP_MENU as Ct, OpenImageCropOperation as St, ImageResetSizeOperation as Dt, DrawingCommonPanel as Pt, UniverDrawingUIPlugin as Et } from "@univerjs/drawing-ui";
7
- import { IDrawingManagerService as ge, DRAWING_IMAGE_ALLOW_IMAGE_LIST as Ot, ArrangeTypeEnum as He, DrawingTypeEnum as un, DRAWING_IMAGE_COUNT_LIMIT as _n, ImageUploadStatusType as an, DRAWING_IMAGE_ALLOW_SIZE as Tt, getImageSize as Mt, DRAWING_IMAGE_WIDTH_LIMIT as Cn, DRAWING_IMAGE_HEIGHT_LIMIT as Sn, IImageIoService as yt, UniverDrawingPlugin as bt } from "@univerjs/drawing";
8
- import { IDocDrawingService as De, SetDocDrawingApplyMutation as fe, DocDrawingApplyType as he, UniverDocsDrawingPlugin as Rt } from "@univerjs/docs-drawing";
9
- import { ITextSelectionRenderManager as Le, IRenderManagerService as Q, DocumentEditArea as sn, getGroupState as Nt, transformObjectOutOfGroup as At, Liquid as Ln, PageLayoutType as Dn, NodePositionConvertToCursor as Pn, getOneTextSelectionRange as En, Vector2 as xt, getAnchorBounding as Ut, Rect as Lt, getColor as Ft, TEXT_RANGE_LAYER_INDEX as Bt } from "@univerjs/engine-render";
10
- import { takeUntil as On, combineLatest as Gt, Observable as Wt } from "rxjs";
11
- import { DocCanvasPopManagerService as Ht, docDrawingPositionToTransform as Tn, transformToDocDrawingPosition as Vt } from "@univerjs/docs-ui";
12
- import { RichTextEditingMutation as Z, getRichTextEditPath as on, DocSkeletonManagerService as me, TextSelectionManagerService as cn, getRetainAndDeleteFromReplace as jt, SetDocZoomRatioOperation as kt, getDocObject as $t } from "@univerjs/docs";
13
- import { ISidebarService as zt, MenuItemType as Fn, MenuPosition as Xt, MenuGroup as qt, getMenuHiddenObservable as Bn, KeyCode as ye, ComponentManager as Kt, IMenuService as Yt, IShortcutService as Zt, IMessageService as Qt, IEditorService as Jt } from "@univerjs/ui";
14
- import { useDependency as ie } from "@wendellhu/redi/react-bindings";
15
- import d, { forwardRef as Gn, useRef as Wn, createElement as Hn, useState as te, useEffect as gn } from "react";
16
- import H from "clsx";
17
- import { RadioGroup as Mn, Radio as Ie, InputNumber as Te, Select as yn, Checkbox as ei, MessageType as Ve } from "@univerjs/design";
18
- const pn = {
1
+ var vn = Object.defineProperty;
2
+ var In = (i, e, t) => e in i ? vn(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t;
3
+ var _e = (i, e, t) => In(i, typeof e != "symbol" ? e + "" : e, t);
4
+ import { CommandType as Y, ICommandService as $, IUniverInstanceService as te, TextX as pt, JSONX as X, MemoryCursor as _n, TextXActionType as Z, LocaleService as ot, RxDisposable as Cn, UniverInstanceType as be, toDisposable as ye, FOCUSING_COMMON_DRAWINGS as it, OnLifecycle as at, LifecycleStages as st, IContextService as Bt, PositionedObjectLayoutType as k, BooleanNumber as oe, ObjectRelativeFromH as ee, ObjectRelativeFromV as V, Tools as Pe, WrapTextType as je, Direction as ge, IUndoRedoService as Ft, FOCUSING_UNIVER_EDITOR as Sn, Disposable as qe, UndoCommand as Dn, RedoCommand as En, throttle as Ct, COLORS as Pn, Plugin as On, DependentOn as Tn } from "@univerjs/core";
5
+ import { Inject as pe, Injector as kt } from "@wendellhu/redi";
6
+ import { ImageCropperObject as Mn, COMPONENT_IMAGE_POPUP_MENU as yn, OpenImageCropOperation as bn, ImageResetSizeOperation as Rn, DrawingCommonPanel as Nn, UniverDrawingUIPlugin as An } from "@univerjs/drawing-ui";
7
+ import { IDrawingManagerService as he, DRAWING_IMAGE_ALLOW_IMAGE_LIST as xn, ArrangeTypeEnum as Ye, DRAWING_IMAGE_COUNT_LIMIT as St, ImageUploadStatusType as mt, DRAWING_IMAGE_ALLOW_SIZE as Ln, getImageSize as Un, DrawingTypeEnum as Bn, getDrawingShapeKeyByDrawingSearch as Fn, DRAWING_IMAGE_WIDTH_LIMIT as Dt, DRAWING_IMAGE_HEIGHT_LIMIT as Et, IImageIoService as kn, UniverDrawingPlugin as Hn } from "@univerjs/drawing";
8
+ import { IDocDrawingService as Re, UniverDocsDrawingPlugin as Wn } from "@univerjs/docs-drawing";
9
+ import { ITextSelectionRenderManager as Ue, IRenderManagerService as se, DocumentEditArea as xe, Liquid as Ht, PageLayoutType as Pt, NodePositionConvertToCursor as Ot, getOneTextSelectionRange as Tt, DocumentSkeletonPageType as Mt, Vector2 as Gn, getAnchorBounding as Vn, Rect as jn, getColor as $n, TEXT_RANGE_LAYER_INDEX as zn } from "@univerjs/engine-render";
10
+ import { takeUntil as yt, BehaviorSubject as qn } from "rxjs";
11
+ import { DocCanvasPopManagerService as Xn, docDrawingPositionToTransform as Kn } from "@univerjs/docs-ui";
12
+ import { RichTextEditingMutation as Q, getRichTextEditPath as $e, DocSkeletonManagerService as ae, TextSelectionManagerService as gt, getRetainAndDeleteFromReplace as Yn, SetDocZoomRatioOperation as Zn, getDocObject as Qn } from "@univerjs/docs";
13
+ import { ISidebarService as Jn, MenuItemType as Wt, MenuPosition as ei, MenuGroup as ti, getMenuHiddenObservable as Gt, KeyCode as Le, ComponentManager as ni, IMenuService as ii, IShortcutService as ri, IMessageService as oi, IEditorService as ai } from "@univerjs/ui";
14
+ import { useDependency as re } from "@wendellhu/redi/react-bindings";
15
+ import d, { forwardRef as Vt, useRef as jt, createElement as $t, useState as ie, useEffect as ht } from "react";
16
+ import j from "clsx";
17
+ import { RadioGroup as bt, Radio as Ee, InputNumber as Ae, Select as Rt, Checkbox as si, MessageType as Nt } from "@univerjs/design";
18
+ const wt = {
19
19
  id: "doc.command.remove-doc-image",
20
- type: $.COMMAND,
20
+ type: Y.COMMAND,
21
21
  // eslint-disable-next-line max-lines-per-function
22
22
  handler: (i, e) => {
23
- var S, O, R, D;
24
- const n = i.get(W), t = i.get(X), o = i.get(Le), r = t.getCurrentUniverDocInstance();
25
- if (e == null || r == null)
23
+ var C, O, y, T;
24
+ const t = i.get($), n = i.get(te), r = i.get(Ue), o = n.getCurrentUniverDocInstance();
25
+ if (e == null || o == null)
26
26
  return !1;
27
- const { drawings: a } = e, s = (S = o.getSegment()) != null ? S : "", l = new Je(), c = k.getInstance(), m = (R = (O = r.getSelfOrHeaderFooterModel(s).getBody()) == null ? void 0 : O.customBlocks) != null ? R : [], u = a.map((b) => m.find((y) => y.blockId === b.drawingId)).filter((b) => !!b).sort((b, y) => b.startIndex > y.startIndex ? 1 : -1), p = a[0].unitId, f = new ut();
28
- f.reset();
29
- const g = u[0].startIndex, w = [
27
+ const { drawings: a } = e, s = (C = r.getSegment()) != null ? C : "", l = new pt(), c = X.getInstance(), m = (y = (O = o.getSelfOrHeaderFooterModel(s).getBody()) == null ? void 0 : O.customBlocks) != null ? y : [], u = a.map((N) => m.find((R) => R.blockId === N.drawingId)).filter((N) => !!N).sort((N, R) => N.startIndex > R.startIndex ? 1 : -1), f = a[0].unitId, h = new _n();
28
+ h.reset();
29
+ const p = u[0].startIndex, w = [
30
30
  {
31
- startOffset: g,
32
- endOffset: g
31
+ startOffset: p,
32
+ endOffset: p
33
33
  }
34
34
  ], v = {
35
- id: Z.id,
35
+ id: Q.id,
36
36
  params: {
37
- unitId: p,
37
+ unitId: f,
38
38
  actions: [],
39
39
  textRanges: w
40
40
  }
41
41
  }, I = [];
42
- for (const b of u) {
43
- const { startIndex: y } = b;
44
- y > f.cursor && l.push({
45
- t: j.RETAIN,
46
- len: y - f.cursor,
42
+ for (const N of u) {
43
+ const { startIndex: R } = N;
44
+ R > h.cursor && l.push({
45
+ t: Z.RETAIN,
46
+ len: R - h.cursor,
47
47
  segmentId: ""
48
48
  }), l.push({
49
- t: j.DELETE,
49
+ t: Z.DELETE,
50
50
  len: 1,
51
51
  line: 0,
52
52
  segmentId: ""
53
- }), f.moveCursorTo(y + 1);
53
+ }), h.moveCursorTo(R + 1);
54
54
  }
55
- const C = on(r, s);
56
- I.push(c.editOp(l.serialize(), C));
57
- for (const b of u) {
58
- const { blockId: y } = b, T = ((D = r.getDrawings()) != null ? D : {})[y], x = r.getDrawingsOrder().indexOf(y), L = c.removeOp(["drawings", y], T), z = c.removeOp(["drawingsOrder", x], y);
59
- I.push(L), I.push(z);
55
+ const D = $e(o, s);
56
+ I.push(c.editOp(l.serialize(), D));
57
+ for (const N of u) {
58
+ const { blockId: R } = N, E = ((T = o.getDrawings()) != null ? T : {})[R], z = o.getDrawingsOrder().indexOf(R), U = c.removeOp(["drawings", R], E), B = c.removeOp(["drawingsOrder", z], R);
59
+ I.push(U), I.push(B);
60
60
  }
61
- return v.params.actions = I.reduce((b, y) => k.compose(b, y), null), !!n.syncExecuteCommand(v.id, v.params);
61
+ return v.params.actions = I.reduce((N, R) => X.compose(N, R), null), !!t.syncExecuteCommand(v.id, v.params);
62
62
  }
63
- }, Vn = "COMPONENT_DOC_DRAWING_PANEL", jn = {
63
+ }, zt = "COMPONENT_DOC_DRAWING_PANEL", qt = {
64
64
  id: "sidebar.operation.doc-image",
65
- type: $.COMMAND,
65
+ type: Y.COMMAND,
66
66
  handler: async (i, e) => {
67
- const n = i.get(zt), t = i.get(en), o = i.get(ge);
67
+ const t = i.get(Jn), n = i.get(ot), r = i.get(he);
68
68
  switch (e.value) {
69
69
  case "open":
70
- n.open({
71
- header: { title: t.t("docImage.panel.title") },
72
- children: { label: Vn },
70
+ t.open({
71
+ header: { title: n.t("docImage.panel.title") },
72
+ children: { label: zt },
73
73
  onClose: () => {
74
- o.focusDrawing(null);
74
+ r.focusDrawing(null);
75
75
  },
76
76
  width: 360
77
77
  });
78
78
  break;
79
79
  case "close":
80
80
  default:
81
- n.close();
81
+ t.close();
82
82
  break;
83
83
  }
84
84
  return !0;
85
85
  }
86
- }, kn = {
86
+ }, Xt = {
87
87
  id: "doc.operation.edit-doc-image",
88
- type: $.OPERATION,
88
+ type: Y.OPERATION,
89
89
  handler: (i, e) => {
90
- const n = i.get(ge), t = i.get(W);
91
- return e == null ? !1 : (n.focusDrawing([e]), t.executeCommand(jn.id, { value: "open" }), !0);
90
+ const t = i.get(he), n = i.get($);
91
+ return e == null ? !1 : (t.focusDrawing([e]), n.executeCommand(qt.id, { value: "open" }), !0);
92
92
  }
93
93
  };
94
- var ni = Object.defineProperty, ti = Object.getOwnPropertyDescriptor, ii = (i, e, n, t) => {
95
- for (var o = t > 1 ? void 0 : t ? ti(e, n) : e, r = i.length - 1, a; r >= 0; r--)
96
- (a = i[r]) && (o = (t ? a(e, n, o) : a(o)) || o);
97
- return t && o && ni(e, n, o), o;
98
- }, be = (i, e) => (n, t) => e(n, t, i);
99
- let Xe = class extends gt {
100
- constructor(e, n, t, o, r) {
94
+ var ci = Object.defineProperty, li = Object.getOwnPropertyDescriptor, di = (i, e, t, n) => {
95
+ for (var r = n > 1 ? void 0 : n ? li(e, t) : e, o = i.length - 1, a; o >= 0; o--)
96
+ (a = i[o]) && (r = (n ? a(e, t, r) : a(r)) || r);
97
+ return n && r && ci(e, t, r), r;
98
+ }, ke = (i, e) => (t, n) => e(t, n, i);
99
+ let Je = class extends Cn {
100
+ constructor(e, t, n, r, o) {
101
101
  super();
102
- Pe(this, "_initImagePopupMenu", /* @__PURE__ */ new Set());
103
- this._drawingManagerService = e, this._canvasPopManagerService = n, this._renderManagerService = t, this._univerInstanceService = o, this._contextService = r, this._init();
102
+ _e(this, "_initImagePopupMenu", /* @__PURE__ */ new Set());
103
+ this._drawingManagerService = e, this._canvasPopManagerService = t, this._renderManagerService = n, this._univerInstanceService = r, this._contextService = o, this._init();
104
104
  }
105
105
  _init() {
106
- this._univerInstanceService.getCurrentTypeOfUnit$(Ce.UNIVER_DOC).pipe(On(this.dispose$)).subscribe((e) => this._create(e)), this._univerInstanceService.getTypeOfUnitDisposed$(Ce.UNIVER_DOC).pipe(On(this.dispose$)).subscribe((e) => this._dispose(e)), this._univerInstanceService.getAllUnitsForType(Ce.UNIVER_DOC).forEach((e) => this._create(e));
106
+ this._univerInstanceService.getCurrentTypeOfUnit$(be.UNIVER_DOC).pipe(yt(this.dispose$)).subscribe((e) => this._create(e)), this._univerInstanceService.getTypeOfUnitDisposed$(be.UNIVER_DOC).pipe(yt(this.dispose$)).subscribe((e) => this._dispose(e)), this._univerInstanceService.getAllUnitsForType(be.UNIVER_DOC).forEach((e) => this._create(e));
107
107
  }
108
108
  _dispose(e) {
109
- const n = e.getUnitId();
110
- this._renderManagerService.removeRender(n);
109
+ const t = e.getUnitId();
110
+ this._renderManagerService.removeRender(t);
111
111
  }
112
112
  _create(e) {
113
113
  if (!e)
114
114
  return;
115
- const n = e.getUnitId();
116
- this._renderManagerService.has(n) && !this._initImagePopupMenu.has(n) && (this._popupMenuListener(n), this._initImagePopupMenu.add(n));
115
+ const t = e.getUnitId();
116
+ this._renderManagerService.has(t) && !this._initImagePopupMenu.has(t) && (this._popupMenuListener(t), this._initImagePopupMenu.add(t));
117
117
  }
118
118
  _hasCropObject(e) {
119
- const n = e.getAllObjects();
120
- for (const t of n)
121
- if (t instanceof _t)
119
+ const t = e.getAllObjects();
120
+ for (const n of t)
121
+ if (n instanceof Mn)
122
122
  return !0;
123
123
  return !1;
124
124
  }
125
125
  // eslint-disable-next-line max-lines-per-function
126
126
  _popupMenuListener(e) {
127
- var r;
128
- const n = (r = this._renderManagerService.getRenderById(e)) == null ? void 0 : r.scene;
129
- if (!n)
130
- return;
131
- const t = n.getTransformerByCreate();
127
+ var o;
128
+ const t = (o = this._renderManagerService.getRenderById(e)) == null ? void 0 : o.scene;
132
129
  if (!t)
133
130
  return;
134
- const o = [];
131
+ const n = t.getTransformerByCreate();
132
+ if (!n)
133
+ return;
134
+ const r = [];
135
135
  this.disposeWithMe(
136
- Ee(
137
- t.createControl$.subscribe(() => {
138
- if (this._hasCropObject(n))
136
+ ye(
137
+ n.createControl$.subscribe(() => {
138
+ if (this._hasCropObject(t))
139
139
  return;
140
- const a = t.getSelectedObjectMap();
141
- if (o.forEach((w) => w.dispose()), o.length = 0, a.size > 1)
140
+ const a = n.getSelectedObjectMap();
141
+ if (r.forEach((w) => w.dispose()), r.length = 0, a.size > 1)
142
142
  return;
143
143
  const s = a.values().next().value;
144
144
  if (!s)
@@ -146,379 +146,482 @@ let Xe = class extends gt {
146
146
  const l = s.oKey, c = this._drawingManagerService.getDrawingOKey(l);
147
147
  if (!c)
148
148
  return;
149
- const { unitId: m, subUnitId: u, drawingId: p } = c;
150
- o.push(this.disposeWithMe(this._canvasPopManagerService.attachPopupToObject(s, {
151
- componentKey: Ct,
149
+ const { unitId: m, subUnitId: u, drawingId: f } = c;
150
+ r.push(this.disposeWithMe(this._canvasPopManagerService.attachPopupToObject(s, {
151
+ componentKey: yn,
152
152
  direction: "horizontal",
153
153
  offset: [2, 0],
154
154
  extraProps: {
155
- menuItems: this._getImageMenuItems(m, u, p)
155
+ menuItems: this._getImageMenuItems(m, u, f)
156
156
  }
157
- }))), !this._drawingManagerService.getFocusDrawings().find((w) => w.unitId === m && w.subUnitId === u && w.drawingId === p) && this._drawingManagerService.focusDrawing([{
157
+ }))), !this._drawingManagerService.getFocusDrawings().find((w) => w.unitId === m && w.subUnitId === u && w.drawingId === f) && this._drawingManagerService.focusDrawing([{
158
158
  unitId: m,
159
159
  subUnitId: u,
160
- drawingId: p
160
+ drawingId: f
161
161
  }]);
162
162
  })
163
163
  )
164
164
  ), this.disposeWithMe(
165
- Ee(
166
- t.clearControl$.subscribe(() => {
167
- o.forEach((a) => a.dispose()), o.length = 0, this._contextService.setContextValue(Ze, !1), this._drawingManagerService.focusDrawing(null);
165
+ ye(
166
+ n.clearControl$.subscribe(() => {
167
+ r.forEach((a) => a.dispose()), r.length = 0, this._contextService.setContextValue(it, !1), this._drawingManagerService.focusDrawing(null);
168
168
  })
169
169
  )
170
170
  ), this.disposeWithMe(
171
- Ee(
172
- t.changing$.subscribe(() => {
173
- o.forEach((a) => a.dispose()), o.length = 0;
171
+ ye(
172
+ n.changing$.subscribe(() => {
173
+ r.forEach((a) => a.dispose()), r.length = 0;
174
174
  })
175
175
  )
176
176
  ), this.disposeWithMe(
177
- Ee(
178
- t.changeStart$.subscribe(() => {
179
- o.forEach((a) => a.dispose()), o.length = 0;
177
+ ye(
178
+ n.changeStart$.subscribe(() => {
179
+ r.forEach((a) => a.dispose()), r.length = 0;
180
180
  })
181
181
  )
182
182
  );
183
183
  }
184
- _getImageMenuItems(e, n, t) {
184
+ _getImageMenuItems(e, t, n) {
185
185
  return [
186
186
  {
187
187
  label: "image-popup.edit",
188
188
  index: 0,
189
- commandId: kn.id,
190
- commandParams: { unitId: e, subUnitId: n, drawingId: t },
189
+ commandId: Xt.id,
190
+ commandParams: { unitId: e, subUnitId: t, drawingId: n },
191
191
  disable: !1
192
192
  },
193
193
  {
194
194
  label: "image-popup.delete",
195
195
  index: 1,
196
- commandId: pn.id,
197
- commandParams: { unitId: e, drawings: [{ unitId: e, subUnitId: n, drawingId: t }] },
196
+ commandId: wt.id,
197
+ commandParams: { unitId: e, drawings: [{ unitId: e, subUnitId: t, drawingId: n }] },
198
198
  disable: !1
199
199
  },
200
200
  {
201
201
  label: "image-popup.crop",
202
202
  index: 2,
203
- commandId: St.id,
204
- commandParams: { unitId: e, subUnitId: n, drawingId: t },
203
+ commandId: bn.id,
204
+ commandParams: { unitId: e, subUnitId: t, drawingId: n },
205
205
  disable: !0
206
206
  // TODO: @JOCS, feature is not ready.
207
207
  },
208
208
  {
209
209
  label: "image-popup.reset",
210
210
  index: 3,
211
- commandId: Dt.id,
212
- commandParams: [{ unitId: e, subUnitId: n, drawingId: t }],
211
+ commandId: Rn.id,
212
+ commandParams: [{ unitId: e, subUnitId: t, drawingId: n }],
213
213
  disable: !0
214
214
  // TODO: @JOCS, feature is not ready.
215
215
  }
216
216
  ];
217
217
  }
218
218
  };
219
- Xe = ii([
220
- nn(tn.Rendered, Xe),
221
- be(0, ge),
222
- be(1, Se(Ht)),
223
- be(2, Q),
224
- be(3, X),
225
- be(4, xn)
226
- ], Xe);
227
- var se = function() {
228
- return se = Object.assign || function(i) {
229
- for (var e, n = 1, t = arguments.length; n < t; n++) {
230
- e = arguments[n];
231
- for (var o in e) Object.prototype.hasOwnProperty.call(e, o) && (i[o] = e[o]);
219
+ Je = di([
220
+ at(st.Rendered, Je),
221
+ ke(0, he),
222
+ ke(1, pe(Xn)),
223
+ ke(2, se),
224
+ ke(3, te),
225
+ ke(4, Bt)
226
+ ], Je);
227
+ var ue = function() {
228
+ return ue = Object.assign || function(i) {
229
+ for (var e, t = 1, n = arguments.length; t < n; t++) {
230
+ e = arguments[t];
231
+ for (var r in e) Object.prototype.hasOwnProperty.call(e, r) && (i[r] = e[r]);
232
232
  }
233
233
  return i;
234
- }, se.apply(this, arguments);
235
- }, oi = function(i, e) {
236
- var n = {};
237
- for (var t in i) Object.prototype.hasOwnProperty.call(i, t) && e.indexOf(t) < 0 && (n[t] = i[t]);
234
+ }, ue.apply(this, arguments);
235
+ }, mi = function(i, e) {
236
+ var t = {};
237
+ for (var n in i) Object.prototype.hasOwnProperty.call(i, n) && e.indexOf(n) < 0 && (t[n] = i[n]);
238
238
  if (i != null && typeof Object.getOwnPropertySymbols == "function")
239
- for (var o = 0, t = Object.getOwnPropertySymbols(i); o < t.length; o++)
240
- e.indexOf(t[o]) < 0 && Object.prototype.propertyIsEnumerable.call(i, t[o]) && (n[t[o]] = i[t[o]]);
241
- return n;
242
- }, $n = Gn(function(i, e) {
243
- var n = i.icon, t = i.id, o = i.className, r = i.extend, a = oi(i, ["icon", "id", "className", "extend"]), s = "univerjs-icon univerjs-icon-".concat(t, " ").concat(o || "").trim(), l = Wn("_".concat(si()));
244
- return zn(n, "".concat(t), { defIds: n.defIds, idSuffix: l.current }, se({ ref: e, className: s }, a), r);
239
+ for (var r = 0, n = Object.getOwnPropertySymbols(i); r < n.length; r++)
240
+ e.indexOf(n[r]) < 0 && Object.prototype.propertyIsEnumerable.call(i, n[r]) && (t[n[r]] = i[n[r]]);
241
+ return t;
242
+ }, Kt = Vt(function(i, e) {
243
+ var t = i.icon, n = i.id, r = i.className, o = i.extend, a = mi(i, ["icon", "id", "className", "extend"]), s = "univerjs-icon univerjs-icon-".concat(n, " ").concat(r || "").trim(), l = jt("_".concat(fi()));
244
+ return Yt(t, "".concat(n), { defIds: t.defIds, idSuffix: l.current }, ue({ ref: e, className: s }, a), o);
245
245
  });
246
- function zn(i, e, n, t, o) {
247
- return Hn(i.tag, se(se({ key: e }, ri(i, n, o)), t), (ai(i, n).children || []).map(function(r, a) {
248
- return zn(r, "".concat(e, "-").concat(i.tag, "-").concat(a), n, void 0, o);
246
+ function Yt(i, e, t, n, r) {
247
+ return $t(i.tag, ue(ue({ key: e }, gi(i, t, r)), n), (ui(i, t).children || []).map(function(o, a) {
248
+ return Yt(o, "".concat(e, "-").concat(i.tag, "-").concat(a), t, void 0, r);
249
249
  }));
250
250
  }
251
- function ri(i, e, n) {
252
- var t = se({}, i.attrs);
253
- n != null && n.colorChannel1 && t.fill === "colorChannel1" && (t.fill = n.colorChannel1);
254
- var o = e.defIds;
255
- return !o || o.length === 0 || (i.tag === "use" && t["xlink:href"] && (t["xlink:href"] = t["xlink:href"] + e.idSuffix), Object.entries(t).forEach(function(r) {
256
- var a = r[0], s = r[1];
257
- typeof s == "string" && (t[a] = s.replace(/url\(#(.*)\)/, "url(#$1".concat(e.idSuffix, ")")));
258
- })), t;
251
+ function gi(i, e, t) {
252
+ var n = ue({}, i.attrs);
253
+ t != null && t.colorChannel1 && n.fill === "colorChannel1" && (n.fill = t.colorChannel1);
254
+ var r = e.defIds;
255
+ return !r || r.length === 0 || (i.tag === "use" && n["xlink:href"] && (n["xlink:href"] = n["xlink:href"] + e.idSuffix), Object.entries(n).forEach(function(o) {
256
+ var a = o[0], s = o[1];
257
+ typeof s == "string" && (n[a] = s.replace(/url\(#(.*)\)/, "url(#$1".concat(e.idSuffix, ")")));
258
+ })), n;
259
259
  }
260
- function ai(i, e) {
261
- var n, t = e.defIds;
262
- return !t || t.length === 0 ? i : i.tag === "defs" && (!((n = i.children) === null || n === void 0) && n.length) ? se(se({}, i), { children: i.children.map(function(o) {
263
- return typeof o.attrs.id == "string" && t && t.indexOf(o.attrs.id) > -1 ? se(se({}, o), { attrs: se(se({}, o.attrs), { id: o.attrs.id + e.idSuffix }) }) : o;
260
+ function ui(i, e) {
261
+ var t, n = e.defIds;
262
+ return !n || n.length === 0 ? i : i.tag === "defs" && (!((t = i.children) === null || t === void 0) && t.length) ? ue(ue({}, i), { children: i.children.map(function(r) {
263
+ return typeof r.attrs.id == "string" && n && n.indexOf(r.attrs.id) > -1 ? ue(ue({}, r), { attrs: ue(ue({}, r.attrs), { id: r.attrs.id + e.idSuffix }) }) : r;
264
264
  }) }) : i;
265
265
  }
266
- function si() {
266
+ function fi() {
267
267
  return Math.random().toString(36).substring(2, 8);
268
268
  }
269
- $n.displayName = "UniverIcon";
270
- var ci = { 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" } }] }, Xn = Gn(function(i, e) {
271
- return Hn($n, Object.assign({}, i, {
269
+ Kt.displayName = "UniverIcon";
270
+ var pi = { 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 = Vt(function(i, e) {
271
+ return $t(Kt, Object.assign({}, i, {
272
272
  id: "add-image-single",
273
273
  ref: e,
274
- icon: ci
274
+ icon: pi
275
275
  }));
276
276
  });
277
- Xn.displayName = "AddImageSingle";
278
- const rn = {
277
+ Zt.displayName = "AddImageSingle";
278
+ const vt = {
279
279
  id: "doc.operation.insert-float-image",
280
- type: $.OPERATION,
280
+ type: Y.OPERATION,
281
281
  handler: () => !0
282
- }, li = "univer-upload-file-menu", di = "univer-upload-file-menu-input", bn = {
283
- uploadFileMenu: li,
284
- uploadFileMenuInput: di
285
- }, mi = () => {
286
- const i = ie(W), e = Wn(null), n = () => {
287
- var r;
288
- (r = e.current) == null || r.click();
289
- }, t = Ot.map((r) => `.${r.replace("image/", "")}`).join(","), o = (r) => {
290
- const a = r.target.files;
282
+ }, hi = "univer-upload-file-menu", wi = "univer-upload-file-menu-input", At = {
283
+ uploadFileMenu: hi,
284
+ uploadFileMenuInput: wi
285
+ }, vi = () => {
286
+ const i = re($), e = jt(null), t = () => {
287
+ var o;
288
+ (o = e.current) == null || o.click();
289
+ }, n = xn.map((o) => `.${o.replace("image/", "")}`).join(","), r = (o) => {
290
+ const a = o.target.files;
291
291
  if (a == null)
292
292
  return;
293
293
  const s = Array.from(a);
294
- i.executeCommand(rn.id, { files: s }), e.current && (e.current.value = "");
294
+ i.executeCommand(vt.id, { files: s }), e.current && (e.current.value = "");
295
295
  };
296
- return /* @__PURE__ */ d.createElement("div", { onClick: n, className: bn.uploadFileMenu }, /* @__PURE__ */ d.createElement(
296
+ return /* @__PURE__ */ d.createElement("div", { onClick: t, className: At.uploadFileMenu }, /* @__PURE__ */ d.createElement(
297
297
  "input",
298
298
  {
299
299
  type: "file",
300
- className: bn.uploadFileMenuInput,
300
+ className: At.uploadFileMenuInput,
301
301
  ref: e,
302
- onChange: o,
303
- accept: t,
302
+ onChange: r,
303
+ accept: n,
304
304
  multiple: !0
305
305
  }
306
306
  ));
307
- }, qn = "COMPONENT_DOC_UPLOAD_FILE_MENU", Kn = "addition-and-subtraction-single", Yn = "doc.menu.image";
308
- function ui(i) {
309
- const e = i.get(X), n = i.get(Q);
310
- return new Wt((t) => {
311
- const o = e.focused$.subscribe((s) => {
312
- if (s == null)
313
- return t.next(!0);
314
- const l = n.getRenderById(s);
315
- if (l == null)
316
- return t.next(!0);
317
- l.with(me).getViewModel().editAreaChange$.subscribe((m) => {
318
- t.next(m === sn.HEADER || m === sn.FOOTER);
319
- });
320
- }), r = n.getCurrentTypeOfRenderer(Ce.UNIVER_DOC);
321
- if (r == null)
322
- return t.next(!0);
323
- const a = r.with(me).getViewModel();
324
- return t.next(a.getEditArea() !== sn.BODY), () => o.unsubscribe();
325
- });
326
- }
327
- function gi(i) {
307
+ }, Qt = "COMPONENT_DOC_UPLOAD_FILE_MENU", Jt = "addition-and-subtraction-single", en = "doc.menu.image", Ii = "doc.menu.image.upload.float";
308
+ function _i(i) {
328
309
  return {
329
- id: Yn,
330
- type: Fn.SUBITEMS,
331
- positions: [Xt.TOOLBAR_START],
332
- group: qt.TOOLBAR_LAYOUT,
333
- icon: Kn,
310
+ id: en,
311
+ type: Wt.SUBITEMS,
312
+ positions: [ei.TOOLBAR_START],
313
+ group: ti.TOOLBAR_LAYOUT,
314
+ icon: Jt,
334
315
  tooltip: "docImage.title",
335
- hidden$: Gt(Bn(i, Ce.UNIVER_DOC), ui(i), (e, n) => e || n)
316
+ hidden$: Gt(i, be.UNIVER_DOC)
336
317
  };
337
318
  }
338
- function pi(i) {
319
+ function Ci(i) {
339
320
  return {
340
- id: rn.id,
321
+ id: Ii,
341
322
  title: "docImage.upload.float",
342
- type: Fn.SELECTOR,
323
+ type: Wt.SELECTOR,
343
324
  label: {
344
- name: qn
325
+ name: Qt
345
326
  },
346
- positions: [Yn],
347
- hidden$: Bn(i, Ce.UNIVER_DOC)
327
+ positions: [en],
328
+ hidden$: Gt(i, be.UNIVER_DOC)
348
329
  };
349
330
  }
350
- const fi = "univer-image-common-panel", hi = "univer-image-common-panel-grid", wi = "univer-image-common-panel-border", vi = "univer-image-common-panel-title", Ii = "univer-image-common-panel-subtitle", _i = "univer-image-common-panel-row", Ci = "univer-image-common-panel-row-vertical", Si = "univer-image-common-panel-column", Di = "univer-image-common-panel-column-center", Pi = "univer-image-common-panel-inline", Ei = "univer-image-common-panel-span2", Oi = "univer-image-common-panel-span3", Ti = "univer-image-common-panel-input", Mi = "univer-sheet-image-menu", yi = "univer-sheet-image-menu-input", h = {
351
- imageCommonPanel: fi,
352
- imageCommonPanelGrid: hi,
353
- imageCommonPanelBorder: wi,
354
- imageCommonPanelTitle: vi,
355
- imageCommonPanelSubtitle: Ii,
356
- imageCommonPanelRow: _i,
357
- imageCommonPanelRowVertical: Ci,
358
- imageCommonPanelColumn: Si,
359
- imageCommonPanelColumnCenter: Di,
360
- imageCommonPanelInline: Pi,
361
- imageCommonPanelSpan2: Ei,
362
- imageCommonPanelSpan3: Oi,
363
- imageCommonPanelInput: Ti,
364
- sheetImageMenu: Mi,
365
- sheetImageMenuInput: yi
331
+ const Si = "univer-image-common-panel", Di = "univer-image-common-panel-grid", Ei = "univer-image-common-panel-border", Pi = "univer-image-common-panel-title", Oi = "univer-image-common-panel-subtitle", Ti = "univer-image-common-panel-row", Mi = "univer-image-common-panel-row-vertical", yi = "univer-image-common-panel-column", bi = "univer-image-common-panel-column-center", Ri = "univer-image-common-panel-inline", Ni = "univer-image-common-panel-span2", Ai = "univer-image-common-panel-span3", xi = "univer-image-common-panel-input", Li = "univer-sheet-image-menu", Ui = "univer-sheet-image-menu-input", g = {
332
+ imageCommonPanel: Si,
333
+ imageCommonPanelGrid: Di,
334
+ imageCommonPanelBorder: Ei,
335
+ imageCommonPanelTitle: Pi,
336
+ imageCommonPanelSubtitle: Oi,
337
+ imageCommonPanelRow: Ti,
338
+ imageCommonPanelRowVertical: Mi,
339
+ imageCommonPanelColumn: yi,
340
+ imageCommonPanelColumnCenter: bi,
341
+ imageCommonPanelInline: Ri,
342
+ imageCommonPanelSpan2: Ni,
343
+ imageCommonPanelSpan3: Ai,
344
+ imageCommonPanelInput: xi,
345
+ sheetImageMenu: Li,
346
+ sheetImageMenuInput: Ui
366
347
  };
367
- var re = /* @__PURE__ */ ((i) => (i.INLINE = "inline", i.BEHIND_TEXT = "behindText", i.IN_FRONT_OF_TEXT = "inFrontOfText", i.WRAP_SQUARE = "wrapSquare", i.WRAP_TOP_AND_BOTTOM = "wrapTopAndBottom", i))(re || {});
368
- const bi = {
369
- inline: B.INLINE,
370
- wrapSquare: B.WRAP_SQUARE,
371
- wrapTopAndBottom: B.WRAP_TOP_AND_BOTTOM,
372
- inFrontOfText: B.WRAP_NONE,
373
- behindText: B.WRAP_NONE
374
- }, Zn = {
348
+ class ct {
349
+ constructor() {
350
+ _e(this, "_refreshDrawings$", new qn(null));
351
+ _e(this, "refreshDrawings$", this._refreshDrawings$.asObservable());
352
+ }
353
+ refreshDrawings(e) {
354
+ this._refreshDrawings$.next(e);
355
+ }
356
+ }
357
+ var me = /* @__PURE__ */ ((i) => (i.INLINE = "inline", i.BEHIND_TEXT = "behindText", i.IN_FRONT_OF_TEXT = "inFrontOfText", i.WRAP_SQUARE = "wrapSquare", i.WRAP_TOP_AND_BOTTOM = "wrapTopAndBottom", i))(me || {});
358
+ const Bi = {
359
+ inline: k.INLINE,
360
+ wrapSquare: k.WRAP_SQUARE,
361
+ wrapTopAndBottom: k.WRAP_TOP_AND_BOTTOM,
362
+ inFrontOfText: k.WRAP_NONE,
363
+ behindText: k.WRAP_NONE
364
+ };
365
+ function tn(i, e, t, n, r, o, a) {
366
+ var h, p;
367
+ const s = new pt(), l = X.getInstance(), c = [], m = o.getSelfOrHeaderFooterModel(e).getBody(), u = o.getSelfOrHeaderFooterModel(i).getBody();
368
+ if (m == null || u == null)
369
+ return;
370
+ const f = (p = (h = m.customBlocks) == null ? void 0 : h.find((w) => w.blockId === r)) == null ? void 0 : p.startIndex;
371
+ if (f != null) {
372
+ if (n = Math.min(u.dataStream.length - 2, n), i === e) {
373
+ if (n < f ? (n > 0 && s.push({
374
+ t: Z.RETAIN,
375
+ len: n,
376
+ segmentId: e
377
+ }), s.push({
378
+ t: Z.INSERT,
379
+ body: {
380
+ dataStream: "\b",
381
+ customBlocks: [{
382
+ startIndex: 0,
383
+ blockId: r
384
+ }]
385
+ },
386
+ len: 1,
387
+ line: 0,
388
+ segmentId: e
389
+ }), s.push({
390
+ t: Z.RETAIN,
391
+ len: f - n,
392
+ segmentId: e
393
+ }), s.push({
394
+ t: Z.DELETE,
395
+ len: 1,
396
+ line: 0,
397
+ segmentId: ""
398
+ })) : (f > 0 && s.push({
399
+ t: Z.RETAIN,
400
+ len: f,
401
+ segmentId: e
402
+ }), s.push({
403
+ t: Z.DELETE,
404
+ len: 1,
405
+ line: 0,
406
+ segmentId: ""
407
+ }), n - f - 1 > 0 && s.push({
408
+ t: Z.RETAIN,
409
+ len: n - f - 1,
410
+ segmentId: e
411
+ }), s.push({
412
+ t: Z.INSERT,
413
+ body: {
414
+ dataStream: "\b",
415
+ customBlocks: [{
416
+ startIndex: 0,
417
+ blockId: r
418
+ }]
419
+ },
420
+ len: 1,
421
+ line: 0,
422
+ segmentId: e
423
+ })), n !== f) {
424
+ const w = $e(o, e), v = l.editOp(s.serialize(), w);
425
+ c.push(v);
426
+ }
427
+ } else {
428
+ f > 0 && s.push({
429
+ t: Z.RETAIN,
430
+ len: f,
431
+ segmentId: e
432
+ }), s.push({
433
+ t: Z.DELETE,
434
+ len: 1,
435
+ line: 0,
436
+ segmentId: ""
437
+ });
438
+ let w = $e(o, e), v = l.editOp(s.serialize(), w);
439
+ c.push(v), s.empty(), n > 0 && s.push({
440
+ t: Z.RETAIN,
441
+ len: n,
442
+ segmentId: i
443
+ }), s.push({
444
+ t: Z.INSERT,
445
+ body: {
446
+ dataStream: "\b",
447
+ customBlocks: [{
448
+ startIndex: 0,
449
+ blockId: r
450
+ }]
451
+ },
452
+ len: 1,
453
+ line: 0,
454
+ segmentId: i
455
+ }), w = $e(o, i), v = l.editOp(s.serialize(), w), c.push(v), a.setSegment(i), a.setSegmentPage(t);
456
+ }
457
+ return c;
458
+ }
459
+ }
460
+ const nn = {
375
461
  id: "doc.command.update-doc-drawing-wrapping-style",
376
- type: $.COMMAND,
462
+ type: Y.COMMAND,
377
463
  // eslint-disable-next-line max-lines-per-function, complexity
378
464
  handler: (i, e) => {
465
+ var T, N;
379
466
  if (e == null)
380
467
  return !1;
381
- const { drawings: n, wrappingStyle: t, unitId: o } = e, r = i.get(W), a = i.get(X), l = i.get(Q).getRenderById(o), c = l == null ? void 0 : l.with(me).getSkeleton().getSkeletonData(), m = l == null ? void 0 : l.scene, u = a.getCurrentUniverDocInstance();
382
- if (u == null || c == null || m == null)
468
+ const { drawings: t, wrappingStyle: n, unitId: r } = e, o = i.get($), a = i.get(te), l = i.get(se).getRenderById(r), c = l == null ? void 0 : l.with(ae).getSkeleton().getSkeletonData(), m = l == null ? void 0 : l.with(ae).getViewModel(), u = l == null ? void 0 : l.scene, f = a.getCurrentUniverDocInstance();
469
+ if (f == null || c == null || u == null || m == null)
383
470
  return !1;
384
- const p = m.getTransformerByCreate(), { pages: f } = c, g = k.getInstance(), w = [], { drawings: v = {} } = u.getSnapshot();
385
- for (const P of n) {
386
- const { drawingId: S } = P, O = v[S].layoutType, R = bi[t];
387
- if (O !== R) {
388
- const T = g.replaceOp(["drawings", S, "layoutType"], O, R);
389
- w.push(T);
471
+ const h = m.getEditArea(), p = u.getTransformerByCreate(), { pages: w, skeHeaders: v, skeFooters: I } = c, D = X.getInstance(), _ = [], { drawings: C = {} } = f.getSnapshot();
472
+ for (const R of t) {
473
+ const { drawingId: E } = R, H = C[E].layoutType, z = Bi[n];
474
+ if (H !== z) {
475
+ const S = D.replaceOp(["drawings", E, "layoutType"], H, z);
476
+ _.push(S);
390
477
  }
391
- if (t === "behindText" || t === "inFrontOfText") {
392
- const T = v[S].behindDoc, V = t === "behindText" ? Me.TRUE : Me.FALSE;
393
- if (T !== V) {
394
- const x = g.replaceOp(["drawings", S, "behindDoc"], T, V);
395
- w.push(x);
478
+ if (n === "behindText" || n === "inFrontOfText") {
479
+ const S = C[E].behindDoc, A = n === "behindText" ? oe.TRUE : oe.FALSE;
480
+ if (S !== A) {
481
+ const P = D.replaceOp(["drawings", E, "behindDoc"], S, A);
482
+ _.push(P);
396
483
  }
397
484
  }
398
- if (t === "inline")
485
+ if (n === "inline")
399
486
  continue;
400
- let D = null, b = 0, y = 0;
401
- for (const T of f)
402
- if (T.skeDrawings.has(S)) {
403
- D = T.skeDrawings.get(S), b = T.marginTop, y = T.marginLeft;
404
- break;
487
+ let U = null, B = 0, b = 0;
488
+ for (const S of w) {
489
+ const { headerId: A, footerId: P, marginTop: L, marginLeft: x, marginBottom: M, pageWidth: W, pageHeight: G } = S;
490
+ switch (h) {
491
+ case xe.HEADER: {
492
+ const F = (T = v.get(A)) == null ? void 0 : T.get(W);
493
+ F != null && F.skeDrawings.has(E) && (U = F.skeDrawings.get(E), B = F.marginTop, b = x);
494
+ break;
495
+ }
496
+ case xe.FOOTER: {
497
+ const F = (N = I.get(P)) == null ? void 0 : N.get(W);
498
+ F != null && F.skeDrawings.has(E) && (U = F.skeDrawings.get(E), B = G - M + F.marginTop, b = x);
499
+ break;
500
+ }
501
+ case xe.BODY: {
502
+ S.skeDrawings.has(E) && (U = S.skeDrawings.get(E), B = L, b = x);
503
+ break;
504
+ }
405
505
  }
406
- if (D != null) {
407
- const { aTop: T, aLeft: V } = D, x = v[S].docTransform.positionH;
408
- let L = V;
409
- x.relativeFrom === Y.MARGIN ? L -= y : x.relativeFrom === Y.COLUMN && (L -= D.columnLeft);
410
- const z = {
411
- relativeFrom: x.relativeFrom,
506
+ if (U != null)
507
+ break;
508
+ }
509
+ if (U != null) {
510
+ const { aTop: S, aLeft: A } = U, P = C[E].docTransform.positionH;
511
+ let L = A;
512
+ P.relativeFrom === ee.MARGIN ? L -= b : P.relativeFrom === ee.COLUMN && (L -= U.columnLeft);
513
+ const x = {
514
+ relativeFrom: P.relativeFrom,
412
515
  posOffset: L
413
516
  };
414
- if (x.posOffset !== z.posOffset) {
415
- const E = g.replaceOp(["drawings", S, "docTransform", "positionH"], x, z);
416
- w.push(E);
517
+ if (P.posOffset !== x.posOffset) {
518
+ const F = D.replaceOp(["drawings", E, "docTransform", "positionH"], P, x);
519
+ _.push(F);
417
520
  }
418
- const N = v[S].docTransform.positionV;
419
- let _ = T;
420
- N.relativeFrom === G.PAGE ? _ += b : N.relativeFrom === G.LINE ? _ -= D.lineTop : N.relativeFrom === G.PARAGRAPH && (_ -= D.blockAnchorTop);
421
- const M = {
422
- relativeFrom: N.relativeFrom,
423
- posOffset: _
521
+ const M = C[E].docTransform.positionV;
522
+ let W = S;
523
+ M.relativeFrom === V.PAGE ? W += B : M.relativeFrom === V.LINE ? W -= U.lineTop : M.relativeFrom === V.PARAGRAPH && (W -= U.blockAnchorTop);
524
+ const G = {
525
+ relativeFrom: M.relativeFrom,
526
+ posOffset: W
424
527
  };
425
- if (N.posOffset !== M.posOffset) {
426
- const E = g.replaceOp(["drawings", S, "docTransform", "positionV"], N, M);
427
- w.push(E);
528
+ if (M.posOffset !== G.posOffset) {
529
+ const F = D.replaceOp(["drawings", E, "docTransform", "positionV"], M, G);
530
+ _.push(F);
428
531
  }
429
532
  }
430
533
  }
431
- const I = {
432
- id: Z.id,
534
+ const O = {
535
+ id: Q.id,
433
536
  params: {
434
- unitId: o,
537
+ unitId: r,
435
538
  actions: [],
436
539
  textRanges: null
437
540
  }
438
541
  };
439
- I.params.actions = w.reduce((P, S) => k.compose(P, S), null);
440
- const C = r.syncExecuteCommand(I.id, I.params);
441
- return p.refreshControls(), !!C;
542
+ O.params.actions = _.reduce((R, E) => X.compose(R, E), null);
543
+ const y = o.syncExecuteCommand(O.id, O.params);
544
+ return p.refreshControls(), !!y;
442
545
  }
443
- }, Qn = {
546
+ }, rn = {
444
547
  id: "doc.command.update-doc-drawing-distance",
445
- type: $.COMMAND,
548
+ type: Y.COMMAND,
446
549
  handler: (i, e) => {
447
550
  if (e == null)
448
551
  return !1;
449
- const n = i.get(W), o = i.get(X).getCurrentUniverDocInstance();
450
- if (o == null)
552
+ const t = i.get($), r = i.get(te).getCurrentUniverDocInstance();
553
+ if (r == null)
451
554
  return !1;
452
- const { drawings: r, dist: a, unitId: s } = e, l = k.getInstance(), c = [], { drawings: m = {} } = o.getSnapshot();
453
- for (const f of r) {
454
- const { drawingId: g } = f;
555
+ const { drawings: o, dist: a, unitId: s } = e, l = X.getInstance(), c = [], { drawings: m = {} } = r.getSnapshot();
556
+ for (const h of o) {
557
+ const { drawingId: p } = h;
455
558
  for (const [w, v] of Object.entries(a)) {
456
- const I = m[g][w];
559
+ const I = m[p][w];
457
560
  if (I !== v) {
458
- const C = l.replaceOp(["drawings", g, w], I, v);
459
- c.push(C);
561
+ const D = l.replaceOp(["drawings", p, w], I, v);
562
+ c.push(D);
460
563
  }
461
564
  }
462
565
  }
463
566
  const u = {
464
- id: Z.id,
567
+ id: Q.id,
465
568
  params: {
466
569
  unitId: s,
467
570
  actions: [],
468
571
  textRanges: null
469
572
  }
470
573
  };
471
- return u.params.actions = c.reduce((f, g) => k.compose(f, g), null), !!n.syncExecuteCommand(u.id, u.params);
574
+ return u.params.actions = c.reduce((h, p) => X.compose(h, p), null), !!t.syncExecuteCommand(u.id, u.params);
472
575
  }
473
- }, Jn = {
576
+ }, on = {
474
577
  id: "doc.command.update-doc-drawing-wrap-text",
475
- type: $.COMMAND,
578
+ type: Y.COMMAND,
476
579
  handler: (i, e) => {
477
580
  if (e == null)
478
581
  return !1;
479
- const n = i.get(W), o = i.get(X).getCurrentUniverDocInstance();
480
- if (o == null)
582
+ const t = i.get($), r = i.get(te).getCurrentUniverDocInstance();
583
+ if (r == null)
481
584
  return !1;
482
- const { drawings: r, wrapText: a, unitId: s } = e, l = k.getInstance(), c = [], { drawings: m = {} } = o.getSnapshot();
483
- for (const f of r) {
484
- const { drawingId: g } = f, w = m[g].wrapText;
585
+ const { drawings: o, wrapText: a, unitId: s } = e, l = X.getInstance(), c = [], { drawings: m = {} } = r.getSnapshot();
586
+ for (const h of o) {
587
+ const { drawingId: p } = h, w = m[p].wrapText;
485
588
  if (w !== a) {
486
- const v = l.replaceOp(["drawings", g, "wrapText"], w, a);
589
+ const v = l.replaceOp(["drawings", p, "wrapText"], w, a);
487
590
  c.push(v);
488
591
  }
489
592
  }
490
593
  const u = {
491
- id: Z.id,
594
+ id: Q.id,
492
595
  params: {
493
596
  unitId: s,
494
597
  actions: [],
495
598
  textRanges: null
496
599
  }
497
600
  };
498
- return u.params.actions = c.reduce((f, g) => k.compose(f, g), null), !!n.syncExecuteCommand(u.id, u.params);
601
+ return u.params.actions = c.reduce((h, p) => X.compose(h, p), null), !!t.syncExecuteCommand(u.id, u.params);
499
602
  }
500
- }, xe = {
603
+ }, ze = {
501
604
  id: "doc.command.update-drawing-doc-transform",
502
- type: $.COMMAND,
605
+ type: Y.COMMAND,
503
606
  handler: (i, e) => {
504
607
  if (e == null)
505
608
  return !1;
506
- const n = i.get(W), t = i.get(X), r = i.get(Q).getRenderById(e.unitId), a = r == null ? void 0 : r.scene;
609
+ const t = i.get($), n = i.get(te), o = i.get(se).getRenderById(e.unitId), a = o == null ? void 0 : o.scene;
507
610
  if (a == null)
508
611
  return !1;
509
- const s = a.getTransformerByCreate(), l = t.getCurrentUniverDocInstance();
612
+ const s = a.getTransformerByCreate(), l = n.getCurrentUniverDocInstance();
510
613
  if (l == null)
511
614
  return !1;
512
- const { drawings: c, unitId: m } = e, u = k.getInstance(), p = [], { drawings: f = {} } = l.getSnapshot();
615
+ const { drawings: c, unitId: m } = e, u = X.getInstance(), f = [], { drawings: h = {} } = l.getSnapshot();
513
616
  for (const v of c) {
514
- const { drawingId: I, key: C, value: P } = v, S = f[I].docTransform[C];
515
- if (!_e.diffValue(S, P)) {
516
- const O = u.replaceOp(["drawings", I, "docTransform", C], S, P);
517
- p.push(O);
617
+ const { drawingId: I, key: D, value: _ } = v, C = h[I].docTransform[D];
618
+ if (!Pe.diffValue(C, _)) {
619
+ const O = u.replaceOp(["drawings", I, "docTransform", D], C, _);
620
+ f.push(O);
518
621
  }
519
622
  }
520
- const g = {
521
- id: Z.id,
623
+ const p = {
624
+ id: Q.id,
522
625
  params: {
523
626
  unitId: m,
524
627
  actions: [],
@@ -526,182 +629,92 @@ const bi = {
526
629
  debounce: !0
527
630
  }
528
631
  };
529
- g.params.actions = p.reduce((v, I) => k.compose(v, I), null);
530
- const w = n.syncExecuteCommand(g.id, g.params);
632
+ p.params.actions = f.reduce((v, I) => X.compose(v, I), null);
633
+ const w = t.syncExecuteCommand(p.id, p.params);
531
634
  return s.refreshControls(), !!w;
532
635
  }
533
- }, et = {
636
+ }, an = {
534
637
  id: "doc.command.move-inline-drawing",
535
- type: $.COMMAND,
536
- // eslint-disable-next-line max-lines-per-function
638
+ type: Y.COMMAND,
537
639
  handler: (i, e) => {
538
- var D, b, y, T;
640
+ var T;
539
641
  if (e == null)
540
642
  return !1;
541
- const n = i.get(Q), t = i.get(Le), o = n.getRenderById(e.unitId), r = o == null ? void 0 : o.scene;
542
- if (r == null)
543
- return !1;
544
- const a = r.getTransformerByCreate(), s = i.get(W), c = i.get(X).getCurrentUniverDocInstance();
545
- if (c == null)
643
+ const t = i.get(se), n = i.get(Ue), r = i.get(ct), o = t.getRenderById(e.unitId), a = o == null ? void 0 : o.scene, s = o == null ? void 0 : o.with(ae).getSkeleton();
644
+ if (a == null)
546
645
  return !1;
547
- const { drawing: m, unitId: u, offset: p } = e, f = new Je(), g = k.getInstance(), w = [], { drawingId: v } = m, I = (D = t.getSegment()) != null ? D : "", C = (T = (y = (b = c.getSelfOrHeaderFooterModel(I).getBody()) == null ? void 0 : b.customBlocks) == null ? void 0 : y.find((V) => V.blockId === v)) == null ? void 0 : T.startIndex;
548
- if (C == null)
646
+ const l = a.getTransformerByCreate(), c = i.get($), u = i.get(te).getCurrentUniverDocInstance();
647
+ if (u == null)
549
648
  return !1;
550
- p < C ? (p > 0 && f.push({
551
- t: j.RETAIN,
552
- len: p,
553
- segmentId: I
554
- }), f.push({
555
- t: j.INSERT,
556
- body: {
557
- dataStream: "\b",
558
- customBlocks: [{
559
- startIndex: 0,
560
- blockId: m.drawingId
561
- }]
562
- },
563
- len: 1,
564
- line: 0,
565
- segmentId: I
566
- }), f.push({
567
- t: j.RETAIN,
568
- len: C - p,
569
- segmentId: I
570
- }), f.push({
571
- t: j.DELETE,
572
- len: 1,
573
- line: 0,
574
- segmentId: ""
575
- })) : (C > 0 && f.push({
576
- t: j.RETAIN,
577
- len: C,
578
- segmentId: I
579
- }), f.push({
580
- t: j.DELETE,
581
- len: 1,
582
- line: 0,
583
- segmentId: ""
584
- }), p - C - 1 > 0 && f.push({
585
- t: j.RETAIN,
586
- len: p - C - 1,
587
- segmentId: I
588
- }), f.push({
589
- t: j.INSERT,
590
- body: {
591
- dataStream: "\b",
592
- customBlocks: [{
593
- startIndex: 0,
594
- blockId: m.drawingId
595
- }]
596
- },
597
- len: 1,
598
- line: 0,
599
- segmentId: I
600
- }));
601
- const P = on(c, I), S = g.editOp(f.serialize(), P);
602
- w.push(S);
649
+ const { drawing: f, unitId: h, offset: p, segmentId: w, segmentPage: v } = e, I = [], { drawingId: D } = f, _ = (T = n.getSegment()) != null ? T : "", C = tn(
650
+ w,
651
+ _,
652
+ v,
653
+ p,
654
+ D,
655
+ u,
656
+ n
657
+ );
658
+ if (C == null || C.length === 0)
659
+ return r.refreshDrawings(s), l.refreshControls(), !1;
660
+ I.push(...C);
603
661
  const O = {
604
- id: Z.id,
662
+ id: Q.id,
605
663
  params: {
606
- unitId: u,
664
+ unitId: h,
607
665
  actions: [],
608
666
  textRanges: null
609
667
  }
610
668
  };
611
- O.params.actions = w.reduce((V, x) => k.compose(V, x), null);
612
- const R = s.syncExecuteCommand(O.id, O.params);
613
- return a.refreshControls(), !!R;
669
+ O.params.actions = I.reduce((N, R) => X.compose(N, R), null);
670
+ const y = c.syncExecuteCommand(O.id, O.params);
671
+ return l.refreshControls(), !!y;
614
672
  }
615
- }, nt = {
673
+ }, sn = {
616
674
  id: "doc.command.transform-non-inline-drawing",
617
- type: $.COMMAND,
675
+ type: Y.COMMAND,
618
676
  // eslint-disable-next-line max-lines-per-function
619
677
  handler: (i, e) => {
620
- var x, L, z, N;
678
+ var U;
621
679
  if (e == null)
622
680
  return !1;
623
- const n = i.get(Le), o = i.get(Q).getRenderById(e.unitId), r = o == null ? void 0 : o.scene;
624
- if (r == null)
681
+ const t = i.get(Ue), r = i.get(se).getRenderById(e.unitId), o = r == null ? void 0 : r.scene;
682
+ if (o == null)
625
683
  return !1;
626
- const a = r.getTransformerByCreate(), s = i.get(W), c = i.get(X).getCurrentUniverDocInstance();
684
+ const a = o.getTransformerByCreate(), s = i.get($), c = i.get(te).getCurrentUniverDocInstance();
627
685
  if (c == null)
628
686
  return !1;
629
- const { drawing: m, unitId: u, offset: p, docTransform: f } = e, g = new Je(), w = k.getInstance(), v = [], { drawingId: I } = m, C = (x = n.getSegment()) != null ? x : "", P = (N = (z = (L = c.getSelfOrHeaderFooterModel(C).getBody()) == null ? void 0 : L.customBlocks) == null ? void 0 : z.find((_) => _.blockId === I)) == null ? void 0 : N.startIndex;
630
- if (P == null)
687
+ const { drawing: m, unitId: u, offset: f, docTransform: h, segmentId: p, segmentPage: w } = e, v = [], { drawingId: I } = m, D = (U = t.getSegment()) != null ? U : "", _ = tn(
688
+ p,
689
+ D,
690
+ w,
691
+ f,
692
+ I,
693
+ c,
694
+ t
695
+ );
696
+ if (_ == null)
631
697
  return !1;
632
- if (p < P ? (p > 0 && g.push({
633
- t: j.RETAIN,
634
- len: p,
635
- segmentId: C
636
- }), g.push({
637
- t: j.INSERT,
638
- body: {
639
- dataStream: "\b",
640
- customBlocks: [{
641
- startIndex: 0,
642
- blockId: m.drawingId
643
- }]
644
- },
645
- len: 1,
646
- line: 0,
647
- segmentId: C
648
- }), g.push({
649
- t: j.RETAIN,
650
- len: P - p,
651
- segmentId: C
652
- }), g.push({
653
- t: j.DELETE,
654
- len: 1,
655
- line: 0,
656
- segmentId: ""
657
- })) : p > P && (P > 0 && g.push({
658
- t: j.RETAIN,
659
- len: P,
660
- segmentId: C
661
- }), g.push({
662
- t: j.DELETE,
663
- len: 1,
664
- line: 0,
665
- segmentId: ""
666
- }), p - P - 1 > 0 && g.push({
667
- t: j.RETAIN,
668
- len: p - P - 1,
669
- segmentId: C
670
- }), g.push({
671
- t: j.INSERT,
672
- body: {
673
- dataStream: "\b",
674
- customBlocks: [{
675
- startIndex: 0,
676
- blockId: m.drawingId
677
- }]
678
- },
679
- len: 1,
680
- line: 0,
681
- segmentId: C
682
- })), p !== P) {
683
- const _ = on(c, C), M = w.editOp(g.serialize(), _);
684
- v.push(M);
685
- }
686
- const { drawings: S = {} } = c.getSnapshot(), O = S[I].docTransform, { positionH: R, positionV: D, size: b, angle: y } = O;
687
- if (!_e.diffValue(R, f.positionH)) {
688
- const _ = w.replaceOp(["drawings", I, "docTransform", "positionH"], R, f.positionH);
689
- v.push(_);
698
+ _.length > 0 && v.push(..._);
699
+ const C = X.getInstance(), { drawings: O = {} } = c.getSnapshot(), y = O[I].docTransform, { positionH: T, positionV: N, size: R, angle: E } = y;
700
+ if (!Pe.diffValue(T, h.positionH)) {
701
+ const B = C.replaceOp(["drawings", I, "docTransform", "positionH"], T, h.positionH);
702
+ v.push(B);
690
703
  }
691
- if (!_e.diffValue(D, f.positionV)) {
692
- const _ = w.replaceOp(["drawings", I, "docTransform", "positionV"], D, f.positionV);
693
- v.push(_);
704
+ if (!Pe.diffValue(N, h.positionV)) {
705
+ const B = C.replaceOp(["drawings", I, "docTransform", "positionV"], N, h.positionV);
706
+ v.push(B);
694
707
  }
695
- if (!_e.diffValue(b, f.size)) {
696
- const _ = w.replaceOp(["drawings", I, "docTransform", "size"], b, f.size);
697
- v.push(_);
708
+ if (!Pe.diffValue(R, h.size)) {
709
+ const B = C.replaceOp(["drawings", I, "docTransform", "size"], R, h.size);
710
+ v.push(B);
698
711
  }
699
- if (!_e.diffValue(y, f.angle)) {
700
- const _ = w.replaceOp(["drawings", I, "docTransform", "angle"], y, f.angle);
701
- v.push(_);
712
+ if (!Pe.diffValue(E, h.angle)) {
713
+ const B = C.replaceOp(["drawings", I, "docTransform", "angle"], E, h.angle);
714
+ v.push(B);
702
715
  }
703
- const T = {
704
- id: Z.id,
716
+ const H = {
717
+ id: Q.id,
705
718
  params: {
706
719
  unitId: u,
707
720
  actions: [],
@@ -709,433 +722,444 @@ const bi = {
709
722
  debounce: !0
710
723
  }
711
724
  };
712
- T.params.actions = v.reduce((_, M) => k.compose(_, M), null);
713
- const V = s.syncExecuteCommand(T.id, T.params);
714
- return a.refreshControls(), !!V;
725
+ H.params.actions = v.reduce((B, b) => X.compose(B, b), null);
726
+ const z = s.syncExecuteCommand(H.id, H.params);
727
+ return a.refreshControls(), !!z;
715
728
  }
716
- }, je = 0, ke = 100, Ri = (i) => {
717
- const e = ie(W), n = ie(en), t = ie(ge), o = ie(Q), r = ie(X), { drawings: a } = i, s = a[0];
729
+ }, Ze = 0, Qe = 100, Fi = (i) => {
730
+ const e = re($), t = re(ot), n = re(he), r = re(se), o = re(te), { drawings: a } = i, s = a[0];
718
731
  if (s == null)
719
732
  return null;
720
- const { unitId: l } = s, c = r.getUniverDocInstance(l), m = o.getRenderById(l);
733
+ const { unitId: l } = s, c = o.getUniverDocInstance(l), m = r.getRenderById(l);
721
734
  if ((m == null ? void 0 : m.scene) == null)
722
735
  return null;
723
- const [p, f] = te(!0), [g, w] = te(!0), [v, I] = te(!0), [C, P] = te(re.INLINE), [S, O] = te(""), [R, D] = te({
736
+ const [f, h] = ie(!0), [p, w] = ie(!0), [v, I] = ie(!0), [D, _] = ie(me.INLINE), [C, O] = ie(""), [y, T] = ie({
724
737
  distT: 0,
725
738
  distL: 0,
726
739
  distB: 0,
727
740
  distR: 0
728
- }), [b, y] = te(!0);
729
- function T(N) {
730
- P(N);
731
- const _ = t.getFocusDrawings();
732
- if (_.length === 0)
741
+ }), [N, R] = ie(!0);
742
+ function E(b) {
743
+ _(b);
744
+ const S = n.getFocusDrawings();
745
+ if (S.length === 0)
733
746
  return;
734
- const { unitId: M, subUnitId: E } = _[0], A = _.map(({ unitId: U, subUnitId: F, drawingId: q }) => ({
735
- unitId: U,
736
- subUnitId: F,
737
- drawingId: q
747
+ const { unitId: A, subUnitId: P } = S[0], L = S.map(({ unitId: x, subUnitId: M, drawingId: W }) => ({
748
+ unitId: x,
749
+ subUnitId: M,
750
+ drawingId: W
738
751
  }));
739
- e.executeCommand(Zn.id, {
740
- unitId: M,
741
- subUnitId: E,
742
- drawings: A,
743
- wrappingStyle: N
752
+ e.executeCommand(nn.id, {
753
+ unitId: A,
754
+ subUnitId: P,
755
+ drawings: L,
756
+ wrappingStyle: b
744
757
  });
745
758
  }
746
- function V(N) {
747
- O(N);
748
- const _ = t.getFocusDrawings();
749
- if (_.length === 0)
759
+ function H(b) {
760
+ O(b);
761
+ const S = n.getFocusDrawings();
762
+ if (S.length === 0)
750
763
  return;
751
- const M = _.map((E) => ({
752
- unitId: E.unitId,
753
- subUnitId: E.subUnitId,
754
- drawingId: E.drawingId
764
+ const A = S.map((P) => ({
765
+ unitId: P.unitId,
766
+ subUnitId: P.subUnitId,
767
+ drawingId: P.drawingId
755
768
  }));
756
- e.executeCommand(Jn.id, {
757
- unitId: _[0].unitId,
758
- subUnitId: _[0].unitId,
759
- drawings: M,
760
- wrapText: N
769
+ e.executeCommand(on.id, {
770
+ unitId: S[0].unitId,
771
+ subUnitId: S[0].unitId,
772
+ drawings: A,
773
+ wrapText: b
761
774
  });
762
775
  }
763
- function x(N, _) {
764
- if (N == null)
776
+ function z(b, S) {
777
+ if (b == null)
765
778
  return;
766
- const M = { ...R, [_]: N };
767
- D(M);
768
- const E = t.getFocusDrawings();
769
- if (E.length === 0)
779
+ const A = { ...y, [S]: b };
780
+ T(A);
781
+ const P = n.getFocusDrawings();
782
+ if (P.length === 0)
770
783
  return;
771
- const A = E.map((U) => ({
772
- unitId: U.unitId,
773
- subUnitId: U.subUnitId,
774
- drawingId: U.drawingId
784
+ const L = P.map((x) => ({
785
+ unitId: x.unitId,
786
+ subUnitId: x.subUnitId,
787
+ drawingId: x.drawingId
775
788
  }));
776
- e.executeCommand(Qn.id, {
777
- unitId: E[0].unitId,
778
- subUnitId: E[0].unitId,
779
- drawings: A,
789
+ e.executeCommand(rn.id, {
790
+ unitId: P[0].unitId,
791
+ subUnitId: P[0].unitId,
792
+ drawings: L,
780
793
  dist: {
781
- [_]: N
794
+ [S]: b
782
795
  }
783
796
  });
784
797
  }
785
- function L() {
786
- const N = t.getFocusDrawings();
787
- N.length !== 0 && z(N[0]);
798
+ function U() {
799
+ const b = n.getFocusDrawings();
800
+ b.length !== 0 && B(b[0]);
788
801
  }
789
- function z(N) {
790
- var ce, pe;
791
- const _ = (pe = (ce = c == null ? void 0 : c.getSnapshot()) == null ? void 0 : ce.drawings) == null ? void 0 : pe[N.drawingId];
792
- if (_ == null)
802
+ function B(b) {
803
+ var ce, fe;
804
+ const S = (fe = (ce = c == null ? void 0 : c.getSnapshot()) == null ? void 0 : ce.drawings) == null ? void 0 : fe[b.drawingId];
805
+ if (S == null)
793
806
  return;
794
807
  const {
795
- distT: M = 0,
796
- distL: E = 0,
797
- distB: A = 0,
798
- distR: U = 0,
799
- layoutType: F = B.INLINE,
800
- behindDoc: q = Me.FALSE,
801
- wrapText: J = Ae.BOTH_SIDES
802
- } = _;
803
- if (D({
804
- distT: M,
805
- distL: E,
806
- distB: A,
807
- distR: U
808
- }), O(J), f(F !== B.WRAP_SQUARE), F === B.WRAP_NONE || F === B.INLINE ? w(!0) : w(!1), F === B.WRAP_NONE || F === B.INLINE || F === B.WRAP_TOP_AND_BOTTOM ? I(!0) : I(!1), F === B.WRAP_NONE)
809
- q === Me.TRUE ? P(re.BEHIND_TEXT) : P(re.IN_FRONT_OF_TEXT);
808
+ distT: A = 0,
809
+ distL: P = 0,
810
+ distB: L = 0,
811
+ distR: x = 0,
812
+ layoutType: M = k.INLINE,
813
+ behindDoc: W = oe.FALSE,
814
+ wrapText: G = je.BOTH_SIDES
815
+ } = S;
816
+ if (T({
817
+ distT: A,
818
+ distL: P,
819
+ distB: L,
820
+ distR: x
821
+ }), O(G), h(M !== k.WRAP_SQUARE), M === k.WRAP_NONE || M === k.INLINE ? w(!0) : w(!1), M === k.WRAP_NONE || M === k.INLINE || M === k.WRAP_TOP_AND_BOTTOM ? I(!0) : I(!1), M === k.WRAP_NONE)
822
+ W === oe.TRUE ? _(me.BEHIND_TEXT) : _(me.IN_FRONT_OF_TEXT);
810
823
  else
811
- switch (F) {
812
- case B.INLINE:
813
- P(re.INLINE);
824
+ switch (M) {
825
+ case k.INLINE:
826
+ _(me.INLINE);
814
827
  break;
815
- case B.WRAP_SQUARE:
816
- P(re.WRAP_SQUARE);
828
+ case k.WRAP_SQUARE:
829
+ _(me.WRAP_SQUARE);
817
830
  break;
818
- case B.WRAP_TOP_AND_BOTTOM:
819
- P(re.WRAP_TOP_AND_BOTTOM);
831
+ case k.WRAP_TOP_AND_BOTTOM:
832
+ _(me.WRAP_TOP_AND_BOTTOM);
820
833
  break;
821
834
  default:
822
- throw new Error(`Unsupported layout type: ${F}`);
835
+ throw new Error(`Unsupported layout type: ${M}`);
823
836
  }
824
837
  }
825
- return gn(() => {
826
- L();
827
- const N = t.focus$.subscribe((M) => {
828
- if (M.length === 0) {
829
- y(!1);
838
+ return ht(() => {
839
+ U();
840
+ const b = n.focus$.subscribe((A) => {
841
+ if (A.length === 0) {
842
+ R(!1);
830
843
  return;
831
844
  }
832
- y(!0), z(M[0]);
833
- }), _ = e.onCommandExecuted(async (M) => {
834
- M.id === Z.id && L();
845
+ R(!0), B(A[0]);
846
+ }), S = e.onCommandExecuted(async (A) => {
847
+ A.id === Q.id && U();
835
848
  });
836
849
  return () => {
837
- N.unsubscribe(), _.dispose();
850
+ b.unsubscribe(), S.dispose();
838
851
  };
839
- }, []), /* @__PURE__ */ d.createElement("div", { className: H(h.imageCommonPanelGrid, h.imageCommonPanelBorder), style: { display: b ? "block" : "none" } }, /* @__PURE__ */ d.createElement("div", { className: h.imageCommonPanelRow }, /* @__PURE__ */ d.createElement("div", { className: H(h.imageCommonPanelColumn, h.imageCommonPanelTitle) }, /* @__PURE__ */ d.createElement("div", null, n.t("image-text-wrap.title")))), /* @__PURE__ */ d.createElement("div", { className: h.imageCommonPanelRow }, /* @__PURE__ */ d.createElement("div", { className: H(h.imageCommonPanelColumn, h.imageCommonPanelSubtitle) }, /* @__PURE__ */ d.createElement("div", null, n.t("image-text-wrap.wrappingStyle")))), /* @__PURE__ */ d.createElement("div", { className: H(h.imageCommonPanelRow) }, /* @__PURE__ */ d.createElement("div", { className: H(h.imageCommonPanelColumn) }, /* @__PURE__ */ d.createElement(Mn, { value: C, onChange: T, direction: "vertical" }, /* @__PURE__ */ d.createElement(Ie, { value: re.INLINE }, n.t("image-text-wrap.inline")), /* @__PURE__ */ d.createElement(Ie, { value: re.WRAP_SQUARE }, n.t("image-text-wrap.square")), /* @__PURE__ */ d.createElement(Ie, { value: re.WRAP_TOP_AND_BOTTOM }, n.t("image-text-wrap.topAndBottom")), /* @__PURE__ */ d.createElement(Ie, { value: re.BEHIND_TEXT }, n.t("image-text-wrap.behindText")), /* @__PURE__ */ d.createElement(Ie, { value: re.IN_FRONT_OF_TEXT }, n.t("image-text-wrap.inFrontText"))))), /* @__PURE__ */ d.createElement("div", { className: h.imageCommonPanelRow }, /* @__PURE__ */ d.createElement("div", { className: H(h.imageCommonPanelColumn, h.imageCommonPanelSubtitle) }, /* @__PURE__ */ d.createElement("div", null, n.t("image-text-wrap.wrapText")))), /* @__PURE__ */ d.createElement("div", { className: H(h.imageCommonPanelRow) }, /* @__PURE__ */ d.createElement("div", { className: H(h.imageCommonPanelColumn) }, /* @__PURE__ */ d.createElement(Mn, { disabled: p, value: S, onChange: V, direction: "horizontal" }, /* @__PURE__ */ d.createElement(Ie, { value: Ae.BOTH_SIDES }, n.t("image-text-wrap.bothSide")), /* @__PURE__ */ d.createElement(Ie, { value: Ae.LEFT }, n.t("image-text-wrap.leftOnly")), /* @__PURE__ */ d.createElement(Ie, { value: Ae.RIGHT }, n.t("image-text-wrap.rightOnly"))))), /* @__PURE__ */ d.createElement("div", { className: h.imageCommonPanelRow }, /* @__PURE__ */ d.createElement("div", { className: H(h.imageCommonPanelColumn, h.imageCommonPanelSubtitle) }, /* @__PURE__ */ d.createElement("div", null, n.t("image-text-wrap.distanceFromText")))), /* @__PURE__ */ d.createElement("div", { className: h.imageCommonPanelRow }, /* @__PURE__ */ d.createElement("div", { className: H(h.imageCommonPanelColumn, h.imageCommonPanelSpan2) }, /* @__PURE__ */ d.createElement("label", null, /* @__PURE__ */ d.createElement("div", { className: h.imageCommonPanelRow }, /* @__PURE__ */ d.createElement("div", { className: h.imageCommonPanelColumn }, n.t("image-text-wrap.top"))), /* @__PURE__ */ d.createElement("div", { className: h.imageCommonPanelRow }, /* @__PURE__ */ d.createElement("div", { className: h.imageCommonPanelColumn }, /* @__PURE__ */ d.createElement(
840
- Te,
852
+ }, []), /* @__PURE__ */ d.createElement("div", { className: j(g.imageCommonPanelGrid, g.imageCommonPanelBorder), style: { display: N ? "block" : "none" } }, /* @__PURE__ */ d.createElement("div", { className: g.imageCommonPanelRow }, /* @__PURE__ */ d.createElement("div", { className: j(g.imageCommonPanelColumn, g.imageCommonPanelTitle) }, /* @__PURE__ */ d.createElement("div", null, t.t("image-text-wrap.title")))), /* @__PURE__ */ d.createElement("div", { className: g.imageCommonPanelRow }, /* @__PURE__ */ d.createElement("div", { className: j(g.imageCommonPanelColumn, g.imageCommonPanelSubtitle) }, /* @__PURE__ */ d.createElement("div", null, t.t("image-text-wrap.wrappingStyle")))), /* @__PURE__ */ d.createElement("div", { className: j(g.imageCommonPanelRow) }, /* @__PURE__ */ d.createElement("div", { className: j(g.imageCommonPanelColumn) }, /* @__PURE__ */ d.createElement(bt, { value: D, onChange: E, direction: "vertical" }, /* @__PURE__ */ d.createElement(Ee, { value: me.INLINE }, t.t("image-text-wrap.inline")), /* @__PURE__ */ d.createElement(Ee, { value: me.WRAP_SQUARE }, t.t("image-text-wrap.square")), /* @__PURE__ */ d.createElement(Ee, { value: me.WRAP_TOP_AND_BOTTOM }, t.t("image-text-wrap.topAndBottom")), /* @__PURE__ */ d.createElement(Ee, { value: me.BEHIND_TEXT }, t.t("image-text-wrap.behindText")), /* @__PURE__ */ d.createElement(Ee, { value: me.IN_FRONT_OF_TEXT }, t.t("image-text-wrap.inFrontText"))))), /* @__PURE__ */ d.createElement("div", { className: g.imageCommonPanelRow }, /* @__PURE__ */ d.createElement("div", { className: j(g.imageCommonPanelColumn, g.imageCommonPanelSubtitle) }, /* @__PURE__ */ d.createElement("div", null, t.t("image-text-wrap.wrapText")))), /* @__PURE__ */ d.createElement("div", { className: j(g.imageCommonPanelRow) }, /* @__PURE__ */ d.createElement("div", { className: j(g.imageCommonPanelColumn) }, /* @__PURE__ */ d.createElement(bt, { disabled: f, value: C, onChange: H, direction: "horizontal" }, /* @__PURE__ */ d.createElement(Ee, { value: je.BOTH_SIDES }, t.t("image-text-wrap.bothSide")), /* @__PURE__ */ d.createElement(Ee, { value: je.LEFT }, t.t("image-text-wrap.leftOnly")), /* @__PURE__ */ d.createElement(Ee, { value: je.RIGHT }, t.t("image-text-wrap.rightOnly"))))), /* @__PURE__ */ d.createElement("div", { className: g.imageCommonPanelRow }, /* @__PURE__ */ d.createElement("div", { className: j(g.imageCommonPanelColumn, g.imageCommonPanelSubtitle) }, /* @__PURE__ */ d.createElement("div", null, t.t("image-text-wrap.distanceFromText")))), /* @__PURE__ */ d.createElement("div", { className: g.imageCommonPanelRow }, /* @__PURE__ */ d.createElement("div", { className: j(g.imageCommonPanelColumn, g.imageCommonPanelSpan2) }, /* @__PURE__ */ d.createElement("label", null, /* @__PURE__ */ d.createElement("div", { className: g.imageCommonPanelRow }, /* @__PURE__ */ d.createElement("div", { className: g.imageCommonPanelColumn }, t.t("image-text-wrap.top"))), /* @__PURE__ */ d.createElement("div", { className: g.imageCommonPanelRow }, /* @__PURE__ */ d.createElement("div", { className: g.imageCommonPanelColumn }, /* @__PURE__ */ d.createElement(
853
+ Ae,
841
854
  {
842
- min: je,
843
- max: ke,
844
- disabled: g,
855
+ min: Ze,
856
+ max: Qe,
857
+ disabled: p,
845
858
  precision: 1,
846
- value: R.distT,
847
- onChange: (N) => {
848
- x(N, "distT");
859
+ value: y.distT,
860
+ onChange: (b) => {
861
+ z(b, "distT");
849
862
  },
850
- className: h.imageCommonPanelInput
863
+ className: g.imageCommonPanelInput
851
864
  }
852
- ))))), /* @__PURE__ */ d.createElement("div", { className: H(h.imageCommonPanelColumn, h.imageCommonPanelSpan2) }, /* @__PURE__ */ d.createElement("label", null, /* @__PURE__ */ d.createElement("div", { className: h.imageCommonPanelRow }, /* @__PURE__ */ d.createElement("div", { className: h.imageCommonPanelColumn }, n.t("image-text-wrap.left"))), /* @__PURE__ */ d.createElement("div", { className: h.imageCommonPanelRow }, /* @__PURE__ */ d.createElement("div", { className: h.imageCommonPanelColumn }, /* @__PURE__ */ d.createElement(
853
- Te,
865
+ ))))), /* @__PURE__ */ d.createElement("div", { className: j(g.imageCommonPanelColumn, g.imageCommonPanelSpan2) }, /* @__PURE__ */ d.createElement("label", null, /* @__PURE__ */ d.createElement("div", { className: g.imageCommonPanelRow }, /* @__PURE__ */ d.createElement("div", { className: g.imageCommonPanelColumn }, t.t("image-text-wrap.left"))), /* @__PURE__ */ d.createElement("div", { className: g.imageCommonPanelRow }, /* @__PURE__ */ d.createElement("div", { className: g.imageCommonPanelColumn }, /* @__PURE__ */ d.createElement(
866
+ Ae,
854
867
  {
855
- min: je,
856
- max: ke,
868
+ min: Ze,
869
+ max: Qe,
857
870
  disabled: v,
858
871
  precision: 1,
859
- value: R.distL,
860
- onChange: (N) => {
861
- x(N, "distL");
872
+ value: y.distL,
873
+ onChange: (b) => {
874
+ z(b, "distL");
862
875
  },
863
- className: h.imageCommonPanelInput
876
+ className: g.imageCommonPanelInput
864
877
  }
865
- )))))), /* @__PURE__ */ d.createElement("div", { className: h.imageCommonPanelRow }, /* @__PURE__ */ d.createElement("div", { className: H(h.imageCommonPanelColumn, h.imageCommonPanelSpan2) }, /* @__PURE__ */ d.createElement("label", null, /* @__PURE__ */ d.createElement("div", { className: h.imageCommonPanelRow }, /* @__PURE__ */ d.createElement("div", { className: h.imageCommonPanelColumn }, n.t("image-text-wrap.bottom"))), /* @__PURE__ */ d.createElement("div", { className: h.imageCommonPanelRow }, /* @__PURE__ */ d.createElement("div", { className: h.imageCommonPanelColumn }, /* @__PURE__ */ d.createElement(
866
- Te,
878
+ )))))), /* @__PURE__ */ d.createElement("div", { className: g.imageCommonPanelRow }, /* @__PURE__ */ d.createElement("div", { className: j(g.imageCommonPanelColumn, g.imageCommonPanelSpan2) }, /* @__PURE__ */ d.createElement("label", null, /* @__PURE__ */ d.createElement("div", { className: g.imageCommonPanelRow }, /* @__PURE__ */ d.createElement("div", { className: g.imageCommonPanelColumn }, t.t("image-text-wrap.bottom"))), /* @__PURE__ */ d.createElement("div", { className: g.imageCommonPanelRow }, /* @__PURE__ */ d.createElement("div", { className: g.imageCommonPanelColumn }, /* @__PURE__ */ d.createElement(
879
+ Ae,
867
880
  {
868
- min: je,
869
- max: ke,
870
- disabled: g,
881
+ min: Ze,
882
+ max: Qe,
883
+ disabled: p,
871
884
  precision: 1,
872
- value: R.distB,
873
- onChange: (N) => {
874
- x(N, "distB");
885
+ value: y.distB,
886
+ onChange: (b) => {
887
+ z(b, "distB");
875
888
  },
876
- className: h.imageCommonPanelInput
889
+ className: g.imageCommonPanelInput
877
890
  }
878
- ))))), /* @__PURE__ */ d.createElement("div", { className: H(h.imageCommonPanelColumn, h.imageCommonPanelSpan2) }, /* @__PURE__ */ d.createElement("label", null, /* @__PURE__ */ d.createElement("div", { className: h.imageCommonPanelRow }, /* @__PURE__ */ d.createElement("div", { className: h.imageCommonPanelColumn }, n.t("image-text-wrap.right"))), /* @__PURE__ */ d.createElement("div", { className: h.imageCommonPanelRow }, /* @__PURE__ */ d.createElement("div", { className: h.imageCommonPanelColumn }, /* @__PURE__ */ d.createElement(
879
- Te,
891
+ ))))), /* @__PURE__ */ d.createElement("div", { className: j(g.imageCommonPanelColumn, g.imageCommonPanelSpan2) }, /* @__PURE__ */ d.createElement("label", null, /* @__PURE__ */ d.createElement("div", { className: g.imageCommonPanelRow }, /* @__PURE__ */ d.createElement("div", { className: g.imageCommonPanelColumn }, t.t("image-text-wrap.right"))), /* @__PURE__ */ d.createElement("div", { className: g.imageCommonPanelRow }, /* @__PURE__ */ d.createElement("div", { className: g.imageCommonPanelColumn }, /* @__PURE__ */ d.createElement(
892
+ Ae,
880
893
  {
881
- min: je,
882
- max: ke,
894
+ min: Ze,
895
+ max: Qe,
883
896
  disabled: v,
884
897
  precision: 1,
885
- value: R.distR,
886
- onChange: (N) => {
887
- x(N, "distR");
898
+ value: y.distR,
899
+ onChange: (b) => {
900
+ z(b, "distR");
888
901
  },
889
- className: h.imageCommonPanelInput
902
+ className: g.imageCommonPanelInput
890
903
  }
891
904
  )))))));
892
- }, Rn = -1e3, Nn = 1e3, Ni = (i) => {
893
- const e = ie(W), n = ie(en), t = ie(ge), o = ie(Q), r = ie(X), a = ie(Le), { drawings: s } = i, l = s[0];
905
+ }, xt = -1e3, Lt = 1e3, ki = (i) => {
906
+ const e = re($), t = re(ot), n = re(he), r = re(se), o = re(te), a = re(Ue), { drawings: s } = i, l = s[0];
894
907
  if (l == null)
895
908
  return;
896
- const { unitId: c } = l, m = r.getUniverDocInstance(c), u = o.getRenderById(c), p = u == null ? void 0 : u.scene;
897
- if (p == null)
909
+ const { unitId: c } = l, m = o.getUniverDocInstance(c), u = r.getRenderById(c), f = u == null ? void 0 : u.scene;
910
+ if (f == null)
898
911
  return;
899
- const f = p.getTransformerByCreate(), g = [{
900
- label: n.t("image-position.column"),
901
- value: String(Y.COLUMN)
912
+ const h = f.getTransformerByCreate(), p = [{
913
+ label: t.t("image-position.column"),
914
+ value: String(ee.COLUMN)
902
915
  }, {
903
- label: n.t("image-position.page"),
904
- value: String(Y.PAGE)
916
+ label: t.t("image-position.page"),
917
+ value: String(ee.PAGE)
905
918
  }, {
906
- label: n.t("image-position.margin"),
907
- value: String(Y.MARGIN)
919
+ label: t.t("image-position.margin"),
920
+ value: String(ee.MARGIN)
908
921
  }], w = [{
909
- label: n.t("image-position.line"),
910
- value: String(G.LINE)
922
+ label: t.t("image-position.line"),
923
+ value: String(V.LINE)
911
924
  }, {
912
- label: n.t("image-position.page"),
913
- value: String(G.PAGE)
925
+ label: t.t("image-position.page"),
926
+ value: String(V.PAGE)
914
927
  }, {
915
- label: n.t("image-position.margin"),
916
- value: String(G.MARGIN)
928
+ label: t.t("image-position.margin"),
929
+ value: String(V.MARGIN)
917
930
  }, {
918
- label: n.t("image-position.paragraph"),
919
- value: String(G.PARAGRAPH)
920
- }], [v, I] = te(!0), [C, P] = te({
921
- relativeFrom: Y.PAGE,
931
+ label: t.t("image-position.paragraph"),
932
+ value: String(V.PARAGRAPH)
933
+ }], [v, I] = ie(!0), [D, _] = ie({
934
+ relativeFrom: ee.PAGE,
922
935
  posOffset: 0
923
- }), [S, O] = te({
924
- relativeFrom: G.PAGE,
936
+ }), [C, O] = ie({
937
+ relativeFrom: V.PAGE,
925
938
  posOffset: 0
926
- }), [R, D] = te(!0), [b, y] = te(!0);
927
- function T(_, M) {
928
- _ === "positionH" ? P(M) : O(M);
929
- const E = t.getFocusDrawings();
930
- if (E.length === 0)
939
+ }), [y, T] = ie(!0), [N, R] = ie(!0);
940
+ function E(S, A) {
941
+ S === "positionH" ? _(A) : O(A);
942
+ const P = n.getFocusDrawings();
943
+ if (P.length === 0)
931
944
  return;
932
- const A = E.map((U) => ({
933
- unitId: U.unitId,
934
- subUnitId: U.subUnitId,
935
- drawingId: U.drawingId
945
+ const L = P.map((x) => ({
946
+ unitId: x.unitId,
947
+ subUnitId: x.subUnitId,
948
+ drawingId: x.drawingId
936
949
  }));
937
- e.executeCommand(xe.id, {
938
- unitId: E[0].unitId,
939
- subUnitId: E[0].unitId,
940
- drawings: A.map((U) => ({
941
- drawingId: U.drawingId,
942
- key: _,
943
- value: M
950
+ e.executeCommand(ze.id, {
951
+ unitId: P[0].unitId,
952
+ subUnitId: P[0].unitId,
953
+ drawings: L.map((x) => ({
954
+ drawingId: x.drawingId,
955
+ key: S,
956
+ value: A
944
957
  }))
945
- }), a.blur(), f.refreshControls();
958
+ }), a.blur(), h.refreshControls();
946
959
  }
947
- function V(_) {
948
- var ee;
949
- const M = C.relativeFrom, E = C.posOffset, A = Number(_);
950
- if (M === A)
960
+ function H(S) {
961
+ var we, ve, ne;
962
+ const A = D.relativeFrom, P = D.posOffset, L = Number(S);
963
+ if (A === L)
951
964
  return;
952
- const U = t.getFocusDrawings();
953
- if (U.length === 0)
965
+ const x = n.getFocusDrawings();
966
+ if (x.length === 0)
954
967
  return;
955
- const F = U[0].drawingId, q = U[0].unitId;
956
- let J = null, ue = 0;
957
- const ce = (ee = o.getRenderById(q)) == null ? void 0 : ee.with(me).getSkeleton(), pe = ce == null ? void 0 : ce.getSkeletonData();
958
- if (pe == null)
968
+ const M = x[0].drawingId, W = x[0].unitId;
969
+ let G = null, F = 0;
970
+ const ce = (we = r.getRenderById(W)) == null ? void 0 : we.with(ae).getSkeleton(), fe = ce == null ? void 0 : ce.getSkeletonData();
971
+ if (fe == null)
959
972
  return;
960
- for (const we of pe.pages) {
961
- const { marginLeft: ve, skeDrawings: ne } = we;
962
- if (ne.has(F)) {
963
- J = ne.get(F), ue = ve;
973
+ const { pages: Oe, skeHeaders: Be, skeFooters: Ce } = fe;
974
+ for (const Ne of Oe) {
975
+ const { marginLeft: Ie, skeDrawings: Se, headerId: Te, footerId: Me, pageWidth: De } = Ne;
976
+ if (Se.has(M)) {
977
+ G = Se.get(M), F = Ie;
978
+ break;
979
+ }
980
+ const J = (ve = Be.get(Te)) == null ? void 0 : ve.get(De);
981
+ if (J != null && J.skeDrawings.has(M)) {
982
+ G = J == null ? void 0 : J.skeDrawings.get(M), F = Ie;
983
+ break;
984
+ }
985
+ const q = (ne = Ce.get(Me)) == null ? void 0 : ne.get(De);
986
+ if (q != null && q.skeDrawings.has(M)) {
987
+ G = q == null ? void 0 : q.skeDrawings.get(M), F = Ie;
964
988
  break;
965
989
  }
966
990
  }
967
- if (J == null)
991
+ if (G == null)
968
992
  return;
969
- let oe = 0;
970
- M === Y.COLUMN ? oe -= J.columnLeft : M === Y.MARGIN && (oe -= ue), A === Y.COLUMN ? oe += J.columnLeft : A === Y.MARGIN ? oe += ue : Y.PAGE;
971
- const K = {
972
- relativeFrom: A,
973
- posOffset: (E != null ? E : 0) - oe
993
+ let K = 0;
994
+ A === ee.COLUMN ? K -= G.columnLeft : A === ee.MARGIN && (K -= F), L === ee.COLUMN ? K += G.columnLeft : L === ee.MARGIN ? K += F : ee.PAGE;
995
+ const le = {
996
+ relativeFrom: L,
997
+ posOffset: (P != null ? P : 0) - K
974
998
  };
975
- T("positionH", K);
999
+ E("positionH", le);
976
1000
  }
977
- function x(_) {
978
- var Ge, fn, hn, wn, vn;
979
- const M = S.relativeFrom, E = S.posOffset, A = Number(_);
980
- if (M === A)
1001
+ function z(S) {
1002
+ var Ie, Se, Te, Me, De;
1003
+ const A = C.relativeFrom, P = C.posOffset, L = Number(S);
1004
+ if (A === L)
981
1005
  return;
982
- const U = t.getFocusDrawings();
983
- if (U.length === 0)
1006
+ const x = n.getFocusDrawings();
1007
+ if (x.length === 0)
984
1008
  return;
985
- const { drawingId: F, unitId: q } = U[0], J = r.getUniverDocInstance(q), ue = (Ge = o.getRenderById(q)) == null ? void 0 : Ge.with(me).getSkeleton(), ce = (hn = (fn = J == null ? void 0 : J.getBody()) == null ? void 0 : fn.customBlocks) == null ? void 0 : hn.find((We) => We.blockId === F);
986
- if (ce == null || ue == null)
1009
+ const { drawingId: M, unitId: W } = x[0], G = o.getUniverDocInstance(W), F = (Ie = r.getRenderById(W)) == null ? void 0 : Ie.with(ae).getSkeleton(), ce = a.getSegment(), fe = a.getSegmentPage(), Oe = (Te = (Se = G == null ? void 0 : G.getSelfOrHeaderFooterModel(ce).getBody()) == null ? void 0 : Se.customBlocks) == null ? void 0 : Te.find((J) => J.blockId === M);
1010
+ if (Oe == null || F == null)
987
1011
  return;
988
- const { startIndex: pe } = ce, oe = ue.findNodeByCharIndex(pe), K = (wn = oe == null ? void 0 : oe.parent) == null ? void 0 : wn.parent, ee = K == null ? void 0 : K.parent, we = ee == null ? void 0 : ee.lines.find((We) => We.paragraphIndex === (K == null ? void 0 : K.paragraphIndex) && We.paragraphStart), ve = (vn = ee == null ? void 0 : ee.parent) == null ? void 0 : vn.parent;
989
- if (oe == null || K == null || we == null || ee == null || ve == null)
1012
+ const { startIndex: Be } = Oe, Ce = F.findNodeByCharIndex(Be, ce, fe), K = (Me = Ce == null ? void 0 : Ce.parent) == null ? void 0 : Me.parent, le = K == null ? void 0 : K.parent, we = le == null ? void 0 : le.lines.find((J) => J.paragraphIndex === (K == null ? void 0 : K.paragraphIndex) && J.paragraphStart), ve = (De = le == null ? void 0 : le.parent) == null ? void 0 : De.parent;
1013
+ if (Ce == null || K == null || we == null || le == null || ve == null)
990
1014
  return;
991
1015
  let ne = 0;
992
- M === G.PARAGRAPH ? ne -= we.top : M === G.LINE ? ne -= K.top : M === G.PAGE && (ne += ve.marginTop), A === G.PARAGRAPH ? ne += we.top : A === G.LINE ? ne += K.top : A === G.PAGE && (ne -= ve.marginTop);
993
- const le = {
994
- relativeFrom: A,
995
- posOffset: (E != null ? E : 0) - ne
1016
+ A === V.PARAGRAPH ? ne -= we.top : A === V.LINE ? ne -= K.top : A === V.PAGE && (ne += ve.marginTop), L === V.PARAGRAPH ? ne += we.top : L === V.LINE ? ne += K.top : L === V.PAGE && (ne -= ve.marginTop);
1017
+ const Ne = {
1018
+ relativeFrom: L,
1019
+ posOffset: (P != null ? P : 0) - ne
996
1020
  };
997
- T("positionV", le);
1021
+ E("positionV", Ne);
998
1022
  }
999
- function L(_) {
1000
- var q;
1001
- const M = m == null ? void 0 : m.getSnapshot(), E = (q = M == null ? void 0 : M.drawings) == null ? void 0 : q[_.drawingId];
1002
- if (E == null)
1023
+ function U(S) {
1024
+ var W;
1025
+ const A = m == null ? void 0 : m.getSnapshot(), P = (W = A == null ? void 0 : A.drawings) == null ? void 0 : W[S.drawingId];
1026
+ if (P == null)
1003
1027
  return;
1004
- const { layoutType: A } = E, {
1005
- positionH: U,
1006
- positionV: F
1007
- } = E.docTransform;
1008
- P(U), O(F), I(A === B.INLINE), D(F.relativeFrom === G.PARAGRAPH || F.relativeFrom === G.LINE);
1009
- }
1010
- function z() {
1011
- const _ = t.getFocusDrawings();
1012
- _.length !== 0 && L(_[0]);
1013
- }
1014
- function N(_) {
1015
- D(_), x(String(_ ? G.PARAGRAPH : G.PAGE));
1016
- }
1017
- return gn(() => {
1018
- z();
1019
- const _ = t.focus$.subscribe((E) => {
1020
- if (E.length === 0) {
1021
- y(!1);
1028
+ const { layoutType: L } = P, {
1029
+ positionH: x,
1030
+ positionV: M
1031
+ } = P.docTransform;
1032
+ _(x), O(M), I(L === k.INLINE), T(M.relativeFrom === V.PARAGRAPH || M.relativeFrom === V.LINE);
1033
+ }
1034
+ function B() {
1035
+ const S = n.getFocusDrawings();
1036
+ S.length !== 0 && U(S[0]);
1037
+ }
1038
+ function b(S) {
1039
+ T(S), z(String(S ? V.PARAGRAPH : V.PAGE));
1040
+ }
1041
+ return ht(() => {
1042
+ B();
1043
+ const S = n.focus$.subscribe((P) => {
1044
+ if (P.length === 0) {
1045
+ R(!1);
1022
1046
  return;
1023
1047
  }
1024
- y(!0), L(E[0]);
1025
- }), M = e.onCommandExecuted(async (E) => {
1026
- E.id === Z.id && z();
1048
+ R(!0), U(P[0]);
1049
+ }), A = e.onCommandExecuted(async (P) => {
1050
+ P.id === Q.id && B();
1027
1051
  });
1028
1052
  return () => {
1029
- _.unsubscribe(), M.dispose();
1053
+ S.unsubscribe(), A.dispose();
1030
1054
  };
1031
- }, []), /* @__PURE__ */ d.createElement("div", { className: H(h.imageCommonPanelGrid, h.imageCommonPanelBorder), style: { display: b ? "block" : "none" } }, /* @__PURE__ */ d.createElement("div", { className: h.imageCommonPanelRow }, /* @__PURE__ */ d.createElement("div", { className: H(h.imageCommonPanelColumn, h.imageCommonPanelTitle) }, /* @__PURE__ */ d.createElement("div", null, n.t("image-position.title")))), /* @__PURE__ */ d.createElement("div", { className: h.imageCommonPanelRow }, /* @__PURE__ */ d.createElement("div", { className: H(h.imageCommonPanelColumn, h.imageCommonPanelSubtitle) }, /* @__PURE__ */ d.createElement("div", null, n.t("image-position.horizontal")))), /* @__PURE__ */ d.createElement("div", { className: h.imageCommonPanelRow }, /* @__PURE__ */ d.createElement("div", { className: H(h.imageCommonPanelColumn, h.imageCommonPanelSpan2) }, /* @__PURE__ */ d.createElement("label", null, /* @__PURE__ */ d.createElement("div", { className: h.imageCommonPanelRow }, /* @__PURE__ */ d.createElement("div", { className: h.imageCommonPanelColumn }, n.t("image-position.absolutePosition"))), /* @__PURE__ */ d.createElement("div", { className: h.imageCommonPanelRow }, /* @__PURE__ */ d.createElement("div", { className: h.imageCommonPanelColumn }, /* @__PURE__ */ d.createElement(
1032
- Te,
1055
+ }, []), /* @__PURE__ */ d.createElement("div", { className: j(g.imageCommonPanelGrid, g.imageCommonPanelBorder), style: { display: N ? "block" : "none" } }, /* @__PURE__ */ d.createElement("div", { className: g.imageCommonPanelRow }, /* @__PURE__ */ d.createElement("div", { className: j(g.imageCommonPanelColumn, g.imageCommonPanelTitle) }, /* @__PURE__ */ d.createElement("div", null, t.t("image-position.title")))), /* @__PURE__ */ d.createElement("div", { className: g.imageCommonPanelRow }, /* @__PURE__ */ d.createElement("div", { className: j(g.imageCommonPanelColumn, g.imageCommonPanelSubtitle) }, /* @__PURE__ */ d.createElement("div", null, t.t("image-position.horizontal")))), /* @__PURE__ */ d.createElement("div", { className: g.imageCommonPanelRow }, /* @__PURE__ */ d.createElement("div", { className: j(g.imageCommonPanelColumn, g.imageCommonPanelSpan2) }, /* @__PURE__ */ d.createElement("label", null, /* @__PURE__ */ d.createElement("div", { className: g.imageCommonPanelRow }, /* @__PURE__ */ d.createElement("div", { className: g.imageCommonPanelColumn }, t.t("image-position.absolutePosition"))), /* @__PURE__ */ d.createElement("div", { className: g.imageCommonPanelRow }, /* @__PURE__ */ d.createElement("div", { className: g.imageCommonPanelColumn }, /* @__PURE__ */ d.createElement(
1056
+ Ae,
1033
1057
  {
1034
- min: Rn,
1035
- max: Nn,
1058
+ min: xt,
1059
+ max: Lt,
1036
1060
  precision: 1,
1037
1061
  disabled: v,
1038
- value: C.posOffset,
1039
- onChange: (_) => {
1040
- T("positionH", {
1041
- relativeFrom: C.relativeFrom,
1042
- posOffset: _
1062
+ value: D.posOffset,
1063
+ onChange: (S) => {
1064
+ E("positionH", {
1065
+ relativeFrom: D.relativeFrom,
1066
+ posOffset: S
1043
1067
  });
1044
1068
  },
1045
- className: h.imageCommonPanelInput
1069
+ className: g.imageCommonPanelInput
1046
1070
  }
1047
- ))))), /* @__PURE__ */ d.createElement("div", { className: H(h.imageCommonPanelColumn, h.imageCommonPanelSpan2) }, /* @__PURE__ */ d.createElement("label", null, /* @__PURE__ */ d.createElement("div", { className: h.imageCommonPanelRow }, /* @__PURE__ */ d.createElement("div", { className: h.imageCommonPanelColumn }, n.t("image-position.toTheRightOf"))), /* @__PURE__ */ d.createElement("div", { className: h.imageCommonPanelRow }, /* @__PURE__ */ d.createElement("div", { className: h.imageCommonPanelColumn }, /* @__PURE__ */ d.createElement(
1048
- yn,
1071
+ ))))), /* @__PURE__ */ d.createElement("div", { className: j(g.imageCommonPanelColumn, g.imageCommonPanelSpan2) }, /* @__PURE__ */ d.createElement("label", null, /* @__PURE__ */ d.createElement("div", { className: g.imageCommonPanelRow }, /* @__PURE__ */ d.createElement("div", { className: g.imageCommonPanelColumn }, t.t("image-position.toTheRightOf"))), /* @__PURE__ */ d.createElement("div", { className: g.imageCommonPanelRow }, /* @__PURE__ */ d.createElement("div", { className: g.imageCommonPanelColumn }, /* @__PURE__ */ d.createElement(
1072
+ Rt,
1049
1073
  {
1050
- value: String(C.relativeFrom),
1074
+ value: String(D.relativeFrom),
1051
1075
  disabled: v,
1052
- options: g,
1053
- onChange: V
1076
+ options: p,
1077
+ onChange: H
1054
1078
  }
1055
- )))))), /* @__PURE__ */ d.createElement("div", { className: h.imageCommonPanelRow }, /* @__PURE__ */ d.createElement("div", { className: H(h.imageCommonPanelColumn, h.imageCommonPanelSubtitle) }, /* @__PURE__ */ d.createElement("div", null, n.t("image-position.vertical")))), /* @__PURE__ */ d.createElement("div", { className: h.imageCommonPanelRow }, /* @__PURE__ */ d.createElement("div", { className: H(h.imageCommonPanelColumn, h.imageCommonPanelSpan2) }, /* @__PURE__ */ d.createElement("label", null, /* @__PURE__ */ d.createElement("div", { className: h.imageCommonPanelRow }, /* @__PURE__ */ d.createElement("div", { className: h.imageCommonPanelColumn }, n.t("image-position.absolutePosition"))), /* @__PURE__ */ d.createElement("div", { className: h.imageCommonPanelRow }, /* @__PURE__ */ d.createElement("div", { className: h.imageCommonPanelColumn }, /* @__PURE__ */ d.createElement(
1056
- Te,
1079
+ )))))), /* @__PURE__ */ d.createElement("div", { className: g.imageCommonPanelRow }, /* @__PURE__ */ d.createElement("div", { className: j(g.imageCommonPanelColumn, g.imageCommonPanelSubtitle) }, /* @__PURE__ */ d.createElement("div", null, t.t("image-position.vertical")))), /* @__PURE__ */ d.createElement("div", { className: g.imageCommonPanelRow }, /* @__PURE__ */ d.createElement("div", { className: j(g.imageCommonPanelColumn, g.imageCommonPanelSpan2) }, /* @__PURE__ */ d.createElement("label", null, /* @__PURE__ */ d.createElement("div", { className: g.imageCommonPanelRow }, /* @__PURE__ */ d.createElement("div", { className: g.imageCommonPanelColumn }, t.t("image-position.absolutePosition"))), /* @__PURE__ */ d.createElement("div", { className: g.imageCommonPanelRow }, /* @__PURE__ */ d.createElement("div", { className: g.imageCommonPanelColumn }, /* @__PURE__ */ d.createElement(
1080
+ Ae,
1057
1081
  {
1058
- min: Rn,
1059
- max: Nn,
1082
+ min: xt,
1083
+ max: Lt,
1060
1084
  precision: 1,
1061
1085
  disabled: v,
1062
- value: S.posOffset,
1063
- onChange: (_) => {
1064
- T("positionV", {
1065
- relativeFrom: S.relativeFrom,
1066
- posOffset: _
1086
+ value: C.posOffset,
1087
+ onChange: (S) => {
1088
+ E("positionV", {
1089
+ relativeFrom: C.relativeFrom,
1090
+ posOffset: S
1067
1091
  });
1068
1092
  },
1069
- className: h.imageCommonPanelInput
1093
+ className: g.imageCommonPanelInput
1070
1094
  }
1071
- ))))), /* @__PURE__ */ d.createElement("div", { className: H(h.imageCommonPanelColumn, h.imageCommonPanelSpan2) }, /* @__PURE__ */ d.createElement("label", null, /* @__PURE__ */ d.createElement("div", { className: h.imageCommonPanelRow }, /* @__PURE__ */ d.createElement("div", { className: h.imageCommonPanelColumn }, n.t("image-position.bellow"))), /* @__PURE__ */ d.createElement("div", { className: h.imageCommonPanelRow }, /* @__PURE__ */ d.createElement("div", { className: h.imageCommonPanelColumn }, /* @__PURE__ */ d.createElement(
1072
- yn,
1095
+ ))))), /* @__PURE__ */ d.createElement("div", { className: j(g.imageCommonPanelColumn, g.imageCommonPanelSpan2) }, /* @__PURE__ */ d.createElement("label", null, /* @__PURE__ */ d.createElement("div", { className: g.imageCommonPanelRow }, /* @__PURE__ */ d.createElement("div", { className: g.imageCommonPanelColumn }, t.t("image-position.bellow"))), /* @__PURE__ */ d.createElement("div", { className: g.imageCommonPanelRow }, /* @__PURE__ */ d.createElement("div", { className: g.imageCommonPanelColumn }, /* @__PURE__ */ d.createElement(
1096
+ Rt,
1073
1097
  {
1074
1098
  disabled: v,
1075
- value: String(S.relativeFrom),
1099
+ value: String(C.relativeFrom),
1076
1100
  options: w,
1077
- onChange: x
1101
+ onChange: z
1078
1102
  }
1079
- )))))), /* @__PURE__ */ d.createElement("div", { className: h.imageCommonPanelRow }, /* @__PURE__ */ d.createElement("div", { className: H(h.imageCommonPanelColumn, h.imageCommonPanelSubtitle) }, /* @__PURE__ */ d.createElement("div", null, n.t("image-position.options")))), /* @__PURE__ */ d.createElement("div", { className: h.imageCommonPanelRow, style: { marginBottom: "50px" } }, /* @__PURE__ */ d.createElement("div", { className: h.imageCommonPanelColumn }, /* @__PURE__ */ d.createElement(ei, { disabled: v, checked: R, onChange: N }, n.t("image-position.moveObjectWithText")))));
1080
- }, Ai = () => {
1081
- const i = ie(ge), e = i.getFocusDrawings(), [n, t] = te(e);
1082
- return gn(() => {
1083
- const o = i.focus$.subscribe((r) => {
1084
- t(r);
1103
+ )))))), /* @__PURE__ */ d.createElement("div", { className: g.imageCommonPanelRow }, /* @__PURE__ */ d.createElement("div", { className: j(g.imageCommonPanelColumn, g.imageCommonPanelSubtitle) }, /* @__PURE__ */ d.createElement("div", null, t.t("image-position.options")))), /* @__PURE__ */ d.createElement("div", { className: g.imageCommonPanelRow, style: { marginBottom: "50px" } }, /* @__PURE__ */ d.createElement("div", { className: g.imageCommonPanelColumn }, /* @__PURE__ */ d.createElement(si, { disabled: v, checked: y, onChange: b }, t.t("image-position.moveObjectWithText")))));
1104
+ }, Hi = () => {
1105
+ const i = re(he), e = i.getFocusDrawings(), [t, n] = ie(e);
1106
+ return ht(() => {
1107
+ const r = i.focus$.subscribe((o) => {
1108
+ n(o);
1085
1109
  });
1086
1110
  return () => {
1087
- o.unsubscribe();
1111
+ r.unsubscribe();
1088
1112
  };
1089
- }, []), !!(n != null && n.length) && /* @__PURE__ */ d.createElement("div", { className: h.imageCommonPanel }, /* @__PURE__ */ d.createElement(Pt, { drawings: n, hasAlign: !1, hasCropper: !1, hasGroup: !1, hasTransform: !1 }), /* @__PURE__ */ d.createElement(Ri, { drawings: n }), /* @__PURE__ */ d.createElement(Ni, { drawings: n }));
1090
- }, Oe = {
1113
+ }, []), !!(t != null && t.length) && /* @__PURE__ */ d.createElement("div", { className: g.imageCommonPanel }, /* @__PURE__ */ d.createElement(Nn, { drawings: t, hasAlign: !1, hasCropper: !1, hasGroup: !1, hasTransform: !1 }), /* @__PURE__ */ d.createElement(Fi, { drawings: t }), /* @__PURE__ */ d.createElement(ki, { drawings: t }));
1114
+ }, Wi = {
1091
1115
  id: "doc.operation.clear-drawing-transformer",
1092
- type: $.MUTATION,
1116
+ type: Y.MUTATION,
1093
1117
  handler: (i, e) => {
1094
- const n = i.get(Q);
1095
- return e.forEach((t) => {
1096
- var o, r;
1097
- (r = (o = n.getRenderById(t)) == null ? void 0 : o.scene.getTransformer()) == null || r.debounceRefreshControls();
1118
+ const t = i.get(se);
1119
+ return e.forEach((n) => {
1120
+ var r, o;
1121
+ (o = (r = t.getRenderById(n)) == null ? void 0 : r.scene.getTransformer()) == null || o.debounceRefreshControls();
1098
1122
  }), !0;
1099
1123
  }
1100
- }, Fe = {
1124
+ }, Xe = {
1101
1125
  id: "doc.command.move-drawing",
1102
- type: $.COMMAND,
1126
+ type: Y.COMMAND,
1103
1127
  handler: (i, e) => {
1104
- const n = i.get(W), t = i.get(De), o = i.get(X), r = i.get(Q), { direction: a } = e, s = t.getFocusDrawings();
1128
+ const t = i.get($), n = i.get(Re), r = i.get(te), o = i.get(se), { direction: a } = e, s = n.getFocusDrawings();
1105
1129
  if (s.length === 0)
1106
1130
  return !1;
1107
- const l = s[0].unitId, c = r.getRenderById(l), m = c == null ? void 0 : c.scene;
1131
+ const l = s[0].unitId, c = o.getRenderById(l), m = c == null ? void 0 : c.scene;
1108
1132
  if (m == null)
1109
1133
  return !1;
1110
- const u = m.getTransformerByCreate(), p = o.getUniverDocInstance(l), f = s.map((w) => {
1111
- var R, D, b, y, T;
1112
- const { drawingId: v } = w, I = (R = p == null ? void 0 : p.getSnapshot().drawings) == null ? void 0 : R[v];
1113
- if (I == null || I.layoutType === B.INLINE)
1134
+ const u = m.getTransformerByCreate(), f = r.getUniverDocInstance(l), h = s.map((w) => {
1135
+ var y, T, N, R, E;
1136
+ const { drawingId: v } = w, I = (y = f == null ? void 0 : f.getSnapshot().drawings) == null ? void 0 : y[v];
1137
+ if (I == null || I.layoutType === k.INLINE)
1114
1138
  return null;
1115
- const { positionH: C, positionV: P } = I.docTransform, S = { ...C }, O = { ...P };
1116
- return a === ae.UP ? O.posOffset = ((D = O.posOffset) != null ? D : 0) - 2 : a === ae.DOWN ? O.posOffset = ((b = O.posOffset) != null ? b : 0) + 2 : a === ae.LEFT ? S.posOffset = ((y = S.posOffset) != null ? y : 0) - 2 : a === ae.RIGHT && (S.posOffset = ((T = S.posOffset) != null ? T : 0) + 2), {
1139
+ const { positionH: D, positionV: _ } = I.docTransform, C = { ...D }, O = { ..._ };
1140
+ return a === ge.UP ? O.posOffset = ((T = O.posOffset) != null ? T : 0) - 2 : a === ge.DOWN ? O.posOffset = ((N = O.posOffset) != null ? N : 0) + 2 : a === ge.LEFT ? C.posOffset = ((R = C.posOffset) != null ? R : 0) - 2 : a === ge.RIGHT && (C.posOffset = ((E = C.posOffset) != null ? E : 0) + 2), {
1117
1141
  drawingId: v,
1118
- key: a === ae.UP || a === ae.DOWN ? "positionV" : "positionH",
1119
- value: a === ae.UP || a === ae.DOWN ? O : S
1142
+ key: a === ge.UP || a === ge.DOWN ? "positionV" : "positionH",
1143
+ value: a === ge.UP || a === ge.DOWN ? O : C
1120
1144
  };
1121
1145
  }).filter((w) => w != null);
1122
- if (f.length === 0)
1146
+ if (h.length === 0)
1123
1147
  return !1;
1124
- const g = n.syncExecuteCommand(xe.id, {
1148
+ const p = t.syncExecuteCommand(ze.id, {
1125
1149
  unitId: l,
1126
1150
  subUnitId: l,
1127
- drawings: f
1151
+ drawings: h
1128
1152
  });
1129
- return u.refreshControls(), !!g;
1153
+ return u.refreshControls(), !!p;
1130
1154
  }
1131
- }, tt = {
1155
+ }, cn = {
1132
1156
  id: "doc.command.delete-drawing",
1133
- type: $.COMMAND,
1157
+ type: Y.COMMAND,
1134
1158
  handler: (i) => {
1135
- const e = i.get(W), t = i.get(De).getFocusDrawings();
1136
- if (t.length === 0)
1159
+ const e = i.get($), n = i.get(Re).getFocusDrawings();
1160
+ if (n.length === 0)
1137
1161
  return !1;
1138
- const { unitId: o } = t[0], r = t.map((a) => {
1162
+ const { unitId: r } = n[0], o = n.map((a) => {
1139
1163
  const { unitId: s, subUnitId: l, drawingId: c, drawingType: m } = a;
1140
1164
  return {
1141
1165
  unitId: s,
@@ -1144,326 +1168,223 @@ const bi = {
1144
1168
  drawingType: m
1145
1169
  };
1146
1170
  });
1147
- return e.executeCommand(pn.id, {
1148
- unitId: o,
1149
- drawings: r
1171
+ return e.executeCommand(wt.id, {
1172
+ unitId: r,
1173
+ drawings: o
1150
1174
  });
1151
1175
  }
1152
- }, it = {
1176
+ }, ln = {
1153
1177
  id: "doc.command.set-drawing-arrange",
1154
- type: $.COMMAND,
1178
+ type: Y.COMMAND,
1155
1179
  handler: (i, e) => {
1156
- const n = i.get(W), t = i.get(De);
1180
+ const t = i.get($), n = i.get(Re);
1157
1181
  if (e == null)
1158
1182
  return !1;
1159
- const { unitId: o, subUnitId: r, drawingIds: a, arrangeType: s } = e, l = { unitId: o, subUnitId: r, drawingIds: a };
1183
+ const { unitId: r, subUnitId: o, drawingIds: a, arrangeType: s } = e, l = { unitId: r, subUnitId: o, drawingIds: a };
1160
1184
  let c;
1161
- if (s === He.forward ? c = t.getForwardDrawingsOp(l) : s === He.backward ? c = t.getBackwardDrawingOp(l) : s === He.front ? c = t.getFrontDrawingsOp(l) : s === He.back && (c = t.getBackDrawingsOp(l)), c == null)
1185
+ if (s === Ye.forward ? c = n.getForwardDrawingsOp(l) : s === Ye.backward ? c = n.getBackwardDrawingOp(l) : s === Ye.front ? c = n.getFrontDrawingsOp(l) : s === Ye.back && (c = n.getBackDrawingsOp(l)), c == null)
1162
1186
  return !1;
1163
1187
  const { redo: m } = c;
1164
1188
  if (m == null)
1165
1189
  return !1;
1166
1190
  const u = [];
1167
- let p = _e.deepClone(m);
1168
- p = p.slice(3), p.unshift("drawingsOrder"), u.push(p);
1169
- const f = {
1170
- id: Z.id,
1191
+ let f = Pe.deepClone(m);
1192
+ f = f.slice(3), f.unshift("drawingsOrder"), u.push(f);
1193
+ const h = {
1194
+ id: Q.id,
1171
1195
  params: {
1172
- unitId: o,
1196
+ unitId: r,
1173
1197
  actions: [],
1174
1198
  textRanges: null
1175
1199
  }
1176
1200
  };
1177
- return f.params.actions = u.reduce((w, v) => k.compose(w, v), null), !!n.syncExecuteCommand(f.id, f.params);
1178
- }
1179
- }, ot = {
1180
- id: "doc.command.set-doc-image",
1181
- type: $.COMMAND,
1182
- handler: (i, e) => {
1183
- const n = i.get(W), t = i.get(mn), o = i.get(De);
1184
- if (!e) return !1;
1185
- const { drawings: r } = e, a = o.getBatchUpdateOp(r), { unitId: s, subUnitId: l, undo: c, redo: m, objects: u } = a;
1186
- return n.syncExecuteCommand(fe.id, { unitId: s, subUnitId: l, op: m, objects: u, type: he.UPDATE }) ? (t.pushUndoRedo({
1187
- unitID: s,
1188
- undoMutations: [
1189
- { id: fe.id, params: { unitId: s, subUnitId: l, op: c, objects: u, type: he.UPDATE } },
1190
- { id: Oe.id, params: [s] }
1191
- ],
1192
- redoMutations: [
1193
- { id: fe.id, params: { unitId: s, subUnitId: l, op: m, objects: u, type: he.UPDATE } },
1194
- { id: Oe.id, params: [s] }
1195
- ]
1196
- }), !0) : !1;
1201
+ return h.params.actions = u.reduce((w, v) => X.compose(w, v), null), !!t.syncExecuteCommand(h.id, h.params);
1197
1202
  }
1198
- };
1199
- function xi(i) {
1200
- const e = [];
1201
- return i.forEach((n) => {
1202
- const { parent: t, children: o } = n, { unitId: r, subUnitId: a, drawingId: s } = t, l = Nt(0, 0, o.map((u) => u.transform || {})), c = o.map((u) => {
1203
- const p = u.transform || { left: 0, top: 0 }, { unitId: f, subUnitId: g, drawingId: w } = u;
1204
- return {
1205
- unitId: f,
1206
- subUnitId: g,
1207
- drawingId: w,
1208
- transform: {
1209
- ...p,
1210
- left: p.left - l.left,
1211
- top: p.top - l.top
1212
- },
1213
- groupId: s
1214
- };
1215
- }), m = {
1216
- unitId: r,
1217
- subUnitId: a,
1218
- drawingId: s,
1219
- drawingType: un.DRAWING_GROUP,
1220
- transform: l
1221
- };
1222
- e.push({
1223
- parent: m,
1224
- children: c
1225
- });
1226
- }), e;
1227
- }
1228
- function Ui(i) {
1229
- const e = [];
1230
- return i.forEach((n) => {
1231
- const { parent: t, children: o } = n, { unitId: r, subUnitId: a, drawingId: s, transform: l = { width: 0, height: 0 } } = t;
1232
- if (l == null)
1233
- return;
1234
- const c = o.map((u) => {
1235
- const { transform: p } = u, { unitId: f, subUnitId: g, drawingId: w } = u, v = At(p || {}, l, l.width || 0, l.height || 0);
1236
- return {
1237
- unitId: f,
1238
- subUnitId: g,
1239
- drawingId: w,
1240
- transform: v,
1241
- groupId: void 0
1242
- };
1243
- }), m = {
1244
- unitId: r,
1245
- subUnitId: a,
1246
- drawingId: s,
1247
- drawingType: un.DRAWING_GROUP,
1248
- transform: {
1249
- left: 0,
1250
- top: 0
1251
- }
1252
- };
1253
- e.push({
1254
- parent: m,
1255
- children: c
1256
- });
1257
- }), e;
1258
- }
1259
- const rt = {
1203
+ }, dn = {
1260
1204
  id: "doc.command.ungroup-doc-image",
1261
- type: $.COMMAND,
1205
+ type: Y.COMMAND,
1262
1206
  handler: (i, e) => {
1263
- const n = i.get(W), t = i.get(mn), o = i.get(De);
1207
+ i.get($), i.get(Ft);
1208
+ const t = i.get(Re);
1264
1209
  if (!e) return !1;
1265
- const r = [];
1266
- e.forEach(({ parent: f, children: g }) => {
1267
- r.push(f.unitId), g.forEach((w) => {
1268
- r.push(w.unitId);
1210
+ const n = [];
1211
+ return e.forEach(({ parent: r, children: o }) => {
1212
+ n.push(r.unitId), o.forEach((a) => {
1213
+ n.push(a.unitId);
1269
1214
  });
1270
- });
1271
- const a = o.getUngroupDrawingOp(e), { unitId: s, subUnitId: l, undo: c, redo: m, objects: u } = a;
1272
- return n.syncExecuteCommand(fe.id, { op: m, unitId: s, subUnitId: l, objects: u, type: he.UNGROUP }) ? (t.pushUndoRedo({
1273
- unitID: s,
1274
- undoMutations: [
1275
- { id: fe.id, params: { op: c, unitId: s, subUnitId: l, objects: xi(u), type: he.GROUP } },
1276
- { id: Oe.id, params: r }
1277
- ],
1278
- redoMutations: [
1279
- { id: fe.id, params: { op: m, unitId: s, subUnitId: l, objects: u, type: he.UNGROUP } },
1280
- { id: Oe.id, params: r }
1281
- ]
1282
- }), !0) : !1;
1283
- }
1284
- }, at = {
1215
+ }), t.getUngroupDrawingOp(e), !1;
1216
+ }
1217
+ }, mn = {
1285
1218
  id: "doc.command.group-doc-image",
1286
- type: $.COMMAND,
1219
+ type: Y.COMMAND,
1287
1220
  handler: (i, e) => {
1288
- const n = i.get(W), t = i.get(mn), o = i.get(De);
1221
+ i.get($), i.get(Ft);
1222
+ const t = i.get(Re);
1289
1223
  if (!e) return !1;
1290
- const r = [];
1291
- e.forEach(({ parent: f, children: g }) => {
1292
- r.push(f.unitId), g.forEach((w) => {
1293
- r.push(w.unitId);
1224
+ const n = [];
1225
+ return e.forEach(({ parent: r, children: o }) => {
1226
+ n.push(r.unitId), o.forEach((a) => {
1227
+ n.push(a.unitId);
1294
1228
  });
1295
- });
1296
- const a = o.getGroupDrawingOp(e), { unitId: s, subUnitId: l, undo: c, redo: m, objects: u } = a;
1297
- return n.syncExecuteCommand(fe.id, { op: m, unitId: s, subUnitId: l, objects: u, type: he.GROUP }) ? (t.pushUndoRedo({
1298
- unitID: s,
1299
- undoMutations: [
1300
- { id: fe.id, params: { op: c, unitId: s, subUnitId: l, objects: Ui(u), type: he.UNGROUP } },
1301
- { id: Oe.id, params: r }
1302
- ],
1303
- redoMutations: [
1304
- { id: fe.id, params: { op: m, unitId: s, subUnitId: l, objects: u, type: he.GROUP } },
1305
- { id: Oe.id, params: r }
1306
- ]
1307
- }), !0) : !1;
1308
- }
1309
- }, st = {
1229
+ }), t.getGroupDrawingOp(e), !1;
1230
+ }
1231
+ }, gn = {
1310
1232
  id: "doc.command.insert-doc-image",
1311
- type: $.COMMAND,
1233
+ type: Y.COMMAND,
1312
1234
  // eslint-disable-next-line max-lines-per-function
1313
1235
  handler: (i, e) => {
1314
- var O, R;
1236
+ var O, y;
1315
1237
  if (e == null)
1316
1238
  return !1;
1317
- const n = i.get(W), t = i.get(cn), o = i.get(X), r = t.getActiveRange(), a = o.getCurrentUniverDocInstance();
1318
- if (r == null || a == null)
1239
+ const t = i.get($), n = i.get(gt), r = i.get(te), o = n.getActiveRange(), a = r.getCurrentUniverDocInstance();
1240
+ if (o == null || a == null)
1319
1241
  return !1;
1320
- const s = a.getUnitId(), { drawings: l } = e, { collapsed: c, startOffset: m, segmentId: u } = r, p = a.getSelfOrHeaderFooterModel(u).getBody();
1321
- if (p == null)
1242
+ const s = a.getUnitId(), { drawings: l } = e, { collapsed: c, startOffset: m, segmentId: u } = o, f = a.getSelfOrHeaderFooterModel(u).getBody();
1243
+ if (f == null)
1322
1244
  return !1;
1323
- const f = new Je(), g = k.getInstance(), w = [], v = (R = (O = a.getSnapshot().drawingsOrder) == null ? void 0 : O.length) != null ? R : 0;
1245
+ const h = new pt(), p = X.getInstance(), w = [], v = (y = (O = a.getSnapshot().drawingsOrder) == null ? void 0 : O.length) != null ? y : 0;
1324
1246
  if (c)
1325
- m > 0 && f.push({
1326
- t: j.RETAIN,
1247
+ m > 0 && h.push({
1248
+ t: Z.RETAIN,
1327
1249
  len: m,
1328
1250
  segmentId: u
1329
1251
  });
1330
1252
  else {
1331
- const { dos: D } = jt(r, u, 0, p);
1332
- f.push(...D);
1253
+ const { dos: T } = Yn(o, u, 0, f);
1254
+ h.push(...T);
1333
1255
  }
1334
- f.push({
1335
- t: j.INSERT,
1256
+ h.push({
1257
+ t: Z.INSERT,
1336
1258
  body: {
1337
1259
  dataStream: "\b".repeat(l.length),
1338
- customBlocks: l.map((D, b) => ({
1339
- startIndex: b,
1340
- blockId: D.drawingId
1260
+ customBlocks: l.map((T, N) => ({
1261
+ startIndex: N,
1262
+ blockId: T.drawingId
1341
1263
  }))
1342
1264
  },
1343
1265
  len: l.length,
1344
1266
  line: 0,
1345
1267
  segmentId: u
1346
1268
  });
1347
- const I = on(a, u), C = g.editOp(f.serialize(), I);
1348
- w.push(C);
1349
- for (const D of l) {
1350
- const { drawingId: b } = D, y = g.insertOp(["drawings", b], D), T = g.insertOp(["drawingsOrder", v], b);
1351
- w.push(y), w.push(T);
1269
+ const I = $e(a, u), D = p.editOp(h.serialize(), I);
1270
+ w.push(D);
1271
+ for (const T of l) {
1272
+ const { drawingId: N } = T, R = p.insertOp(["drawings", N], T), E = p.insertOp(["drawingsOrder", v], N);
1273
+ w.push(R), w.push(E);
1352
1274
  }
1353
- const P = {
1354
- id: Z.id,
1275
+ const _ = {
1276
+ id: Q.id,
1355
1277
  params: {
1356
1278
  unitId: s,
1357
1279
  actions: [],
1358
1280
  textRanges: []
1359
1281
  }
1360
1282
  };
1361
- return P.params.actions = w.reduce((D, b) => k.compose(D, b), null), !!n.syncExecuteCommand(P.id, P.params);
1283
+ return _.params.actions = w.reduce((T, N) => X.compose(T, N), null), !!t.syncExecuteCommand(_.id, _.params);
1362
1284
  }
1363
1285
  };
1364
- function Be(i) {
1365
- return i.getContextValue(pt) && i.getContextValue(Ze);
1286
+ function Ke(i) {
1287
+ return i.getContextValue(Sn) && i.getContextValue(it);
1366
1288
  }
1367
- const Li = {
1368
- id: Fe.id,
1289
+ const Gi = {
1290
+ id: Xe.id,
1369
1291
  description: "shortcut.doc.drawing-move-down",
1370
1292
  group: "4_doc-drawing-view",
1371
- binding: ye.ARROW_DOWN,
1293
+ binding: Le.ARROW_DOWN,
1372
1294
  priority: 100,
1373
- preconditions: Be,
1295
+ preconditions: Ke,
1374
1296
  staticParameters: {
1375
- direction: ae.DOWN
1297
+ direction: ge.DOWN
1376
1298
  }
1377
- }, Fi = {
1378
- id: Fe.id,
1299
+ }, Vi = {
1300
+ id: Xe.id,
1379
1301
  description: "shortcut.doc.drawing-move-up",
1380
1302
  group: "4_doc-drawing-view",
1381
- binding: ye.ARROW_UP,
1303
+ binding: Le.ARROW_UP,
1382
1304
  priority: 100,
1383
- preconditions: Be,
1305
+ preconditions: Ke,
1384
1306
  staticParameters: {
1385
- direction: ae.UP
1307
+ direction: ge.UP
1386
1308
  }
1387
- }, Bi = {
1388
- id: Fe.id,
1309
+ }, ji = {
1310
+ id: Xe.id,
1389
1311
  description: "shortcut.doc.drawing-move-left",
1390
1312
  group: "4_doc-drawing-view",
1391
- binding: ye.ARROW_LEFT,
1313
+ binding: Le.ARROW_LEFT,
1392
1314
  priority: 100,
1393
- preconditions: Be,
1315
+ preconditions: Ke,
1394
1316
  staticParameters: {
1395
- direction: ae.LEFT
1317
+ direction: ge.LEFT
1396
1318
  }
1397
- }, Gi = {
1398
- id: Fe.id,
1319
+ }, $i = {
1320
+ id: Xe.id,
1399
1321
  description: "shortcut.doc.drawing-move-right",
1400
1322
  group: "4_doc-drawing-view",
1401
- binding: ye.ARROW_RIGHT,
1323
+ binding: Le.ARROW_RIGHT,
1402
1324
  priority: 100,
1403
- preconditions: Be,
1325
+ preconditions: Ke,
1404
1326
  staticParameters: {
1405
- direction: ae.RIGHT
1327
+ direction: ge.RIGHT
1406
1328
  }
1407
- }, Wi = {
1408
- id: tt.id,
1329
+ }, zi = {
1330
+ id: cn.id,
1409
1331
  description: "shortcut.doc.drawing-delete",
1410
1332
  group: "4_doc-drawing-view",
1411
1333
  // when focusing on any other input tag do not trigger this shortcut
1412
- preconditions: Be,
1413
- binding: ye.DELETE,
1414
- mac: ye.BACKSPACE
1334
+ preconditions: Ke,
1335
+ binding: Le.DELETE,
1336
+ mac: Le.BACKSPACE
1415
1337
  };
1416
- var Hi = Object.defineProperty, Vi = Object.getOwnPropertyDescriptor, ji = (i, e, n, t) => {
1417
- for (var o = t > 1 ? void 0 : t ? Vi(e, n) : e, r = i.length - 1, a; r >= 0; r--)
1418
- (a = i[r]) && (o = (t ? a(e, n, o) : a(o)) || o);
1419
- return t && o && Hi(e, n, o), o;
1420
- }, Re = (i, e) => (n, t) => e(n, t, i);
1421
- let qe = class extends Ue {
1422
- constructor(i, e, n, t, o) {
1423
- super(), this._injector = i, this._componentManager = e, this._menuService = n, this._commandService = t, this._shortcutService = o, this._init();
1338
+ var qi = Object.defineProperty, Xi = Object.getOwnPropertyDescriptor, Ki = (i, e, t, n) => {
1339
+ for (var r = n > 1 ? void 0 : n ? Xi(e, t) : e, o = i.length - 1, a; o >= 0; o--)
1340
+ (a = i[o]) && (r = (n ? a(e, t, r) : a(r)) || r);
1341
+ return n && r && qi(e, t, r), r;
1342
+ }, He = (i, e) => (t, n) => e(t, n, i);
1343
+ let et = class extends qe {
1344
+ constructor(i, e, t, n, r) {
1345
+ super(), this._injector = i, this._componentManager = e, this._menuService = t, this._commandService = n, this._shortcutService = r, this._init();
1424
1346
  }
1425
1347
  _initCustomComponents() {
1426
1348
  const i = this._componentManager;
1427
- this.disposeWithMe(i.register(Kn, Xn)), this.disposeWithMe(i.register(qn, mi)), this.disposeWithMe(i.register(Vn, Ai));
1349
+ this.disposeWithMe(i.register(Jt, Zt)), this.disposeWithMe(i.register(Qt, vi)), this.disposeWithMe(i.register(zt, Hi));
1428
1350
  }
1429
1351
  _initMenus() {
1430
1352
  [
1431
- gi,
1432
- pi
1353
+ _i,
1354
+ Ci
1433
1355
  ].forEach((i) => {
1434
1356
  this.disposeWithMe(this._menuService.addMenuItem(this._injector.invoke(i), {}));
1435
1357
  });
1436
1358
  }
1437
1359
  _initCommands() {
1438
1360
  [
1361
+ vt,
1362
+ gn,
1363
+ nn,
1439
1364
  rn,
1440
- st,
1441
- Zn,
1442
- Qn,
1443
- Jn,
1444
- xe,
1445
- et,
1446
- nt,
1447
- pn,
1448
- ot,
1449
- jn,
1450
- Oe,
1451
- kn,
1452
- at,
1453
- rt,
1454
- Fe,
1455
- tt,
1456
- it
1365
+ on,
1366
+ ze,
1367
+ an,
1368
+ sn,
1369
+ wt,
1370
+ qt,
1371
+ Wi,
1372
+ Xt,
1373
+ mn,
1374
+ dn,
1375
+ Xe,
1376
+ cn,
1377
+ ln
1457
1378
  ].forEach((i) => this.disposeWithMe(this._commandService.registerCommand(i)));
1458
1379
  }
1459
1380
  _initShortcuts() {
1460
1381
  [
1461
1382
  // sheet drawing shortcuts
1462
- Li,
1463
- Fi,
1464
- Bi,
1465
1383
  Gi,
1466
- Wi
1384
+ Vi,
1385
+ ji,
1386
+ $i,
1387
+ zi
1467
1388
  ].forEach((i) => {
1468
1389
  this.disposeWithMe(this._shortcutService.registerShortcut(i));
1469
1390
  });
@@ -1472,22 +1393,22 @@ let qe = class extends Ue {
1472
1393
  this._initCommands(), this._initCustomComponents(), this._initMenus(), this._initShortcuts();
1473
1394
  }
1474
1395
  };
1475
- qe = ji([
1476
- nn(tn.Ready, qe),
1477
- Re(0, Se(Un)),
1478
- Re(1, Se(Kt)),
1479
- Re(2, Yt),
1480
- Re(3, W),
1481
- Re(4, Zt)
1482
- ], qe);
1483
- var ki = Object.defineProperty, $i = Object.getOwnPropertyDescriptor, zi = (i, e, n, t) => {
1484
- for (var o = t > 1 ? void 0 : t ? $i(e, n) : e, r = i.length - 1, a; r >= 0; r--)
1485
- (a = i[r]) && (o = (t ? a(e, n, o) : a(o)) || o);
1486
- return t && o && ki(e, n, o), o;
1487
- }, de = (i, e) => (n, t) => e(n, t, i);
1488
- let ln = class extends Ue {
1489
- constructor(i, e, n, t, o, r, a, s, l, c, m, u) {
1490
- super(), this._context = i, this._commandService = e, this._textSelectionManagerService = n, this._renderManagerSrv = t, this._imageIoService = o, this._docDrawingService = r, this._drawingManagerService = a, this._contextService = s, this._messageService = l, this._localeService = c, this._textSelectionManager = m, this._textSelectionRenderManager = u, this._initCommandListeners(), this._updateDrawingListener(), this._updateOrderListener(), this._groupDrawingListener(), this._focusDrawingListener();
1396
+ et = Ki([
1397
+ at(st.Ready, et),
1398
+ He(0, pe(kt)),
1399
+ He(1, pe(ni)),
1400
+ He(2, ii),
1401
+ He(3, $),
1402
+ He(4, ri)
1403
+ ], et);
1404
+ var Yi = Object.defineProperty, Zi = Object.getOwnPropertyDescriptor, Qi = (i, e, t, n) => {
1405
+ for (var r = n > 1 ? void 0 : n ? Zi(e, t) : e, o = i.length - 1, a; o >= 0; o--)
1406
+ (a = i[o]) && (r = (n ? a(e, t, r) : a(r)) || r);
1407
+ return n && r && Yi(e, t, r), r;
1408
+ }, de = (i, e) => (t, n) => e(t, n, i);
1409
+ let ut = class extends qe {
1410
+ constructor(i, e, t, n, r, o, a, s, l, c, m, u, f) {
1411
+ super(), this._context = i, this._commandService = e, this._textSelectionManagerService = t, this._renderManagerSrv = n, this._imageIoService = r, this._docDrawingService = o, this._drawingManagerService = a, this._contextService = s, this._messageService = l, this._localeService = c, this._textSelectionManager = m, this._textSelectionRenderManager = u, this._docRefreshDrawingsService = f, this._initCommandListeners(), this._updateDrawingListener(), this._updateOrderListener(), this._groupDrawingListener(), this._focusDrawingListener(), this._editAreaChangeListener();
1491
1412
  }
1492
1413
  /**
1493
1414
  * Upload image to cell or float image
@@ -1495,19 +1416,19 @@ let ln = class extends Ue {
1495
1416
  _initCommandListeners() {
1496
1417
  this.disposeWithMe(
1497
1418
  this._commandService.onCommandExecuted(async (i) => {
1498
- if (i.id === rn.id) {
1419
+ if (i.id === vt.id) {
1499
1420
  const e = i.params;
1500
1421
  if (e.files == null)
1501
1422
  return;
1502
- const n = e.files.length;
1503
- if (n > _n) {
1423
+ const t = e.files.length;
1424
+ if (t > St) {
1504
1425
  this._messageService.show({
1505
- type: Ve.Error,
1506
- content: this._localeService.t("update-status.exceedMaxCount", String(_n))
1426
+ type: Nt.Error,
1427
+ content: this._localeService.t("update-status.exceedMaxCount", String(St))
1507
1428
  });
1508
1429
  return;
1509
1430
  }
1510
- this._imageIoService.setWaitCount(n), await this._insertFloatImages(e.files);
1431
+ this._imageIoService.setWaitCount(t), await this._insertFloatImages(e.files);
1511
1432
  }
1512
1433
  })
1513
1434
  );
@@ -1516,64 +1437,76 @@ let ln = class extends Ue {
1516
1437
  async _insertFloatImages(i) {
1517
1438
  let e = [];
1518
1439
  try {
1519
- e = await Promise.all(i.map((o) => this._imageIoService.saveImage(o)));
1520
- } catch (o) {
1521
- const r = o.message;
1522
- r === an.ERROR_EXCEED_SIZE ? this._messageService.show({
1523
- type: Ve.Error,
1524
- content: this._localeService.t("update-status.exceedMaxSize", String(Tt / (1024 * 1024)))
1525
- }) : r === an.ERROR_IMAGE_TYPE ? this._messageService.show({
1526
- type: Ve.Error,
1527
- content: this._localeService.t("update-status.invalidImageType")
1528
- }) : r === an.ERROR_IMAGE && this._messageService.show({
1529
- type: Ve.Error,
1530
- content: this._localeService.t("update-status.invalidImage")
1440
+ e = await Promise.all(i.map((r) => this._imageIoService.saveImage(r)));
1441
+ } catch (r) {
1442
+ const o = r.message;
1443
+ let a = "";
1444
+ switch (o) {
1445
+ case mt.ERROR_EXCEED_SIZE:
1446
+ a = this._localeService.t("update-status.exceedMaxSize", String(Ln / (1024 * 1024)));
1447
+ break;
1448
+ case mt.ERROR_IMAGE_TYPE:
1449
+ a = this._localeService.t("update-status.invalidImageType");
1450
+ break;
1451
+ case mt.ERROR_IMAGE:
1452
+ a = this._localeService.t("update-status.invalidImage");
1453
+ break;
1454
+ }
1455
+ this._messageService.show({
1456
+ type: Nt.Error,
1457
+ content: a
1531
1458
  });
1532
1459
  }
1533
1460
  if (e.length === 0)
1534
1461
  return;
1535
- const { unitId: n } = this._context, t = [];
1536
- for (const o of e) {
1537
- if (o == null)
1462
+ const { unitId: t } = this._context, n = [];
1463
+ for (const r of e) {
1464
+ if (r == null)
1538
1465
  continue;
1539
- const { imageId: r, imageSourceType: a, source: s, base64Cache: l } = o, { width: c, height: m, image: u } = await Mt(l || "");
1540
- this._imageIoService.addImageSourceCache(r, a, u);
1541
- let p = 1;
1542
- if (c > Cn || m > Sn) {
1543
- const w = Cn / c, v = Sn / m;
1544
- p = Math.min(w, v);
1466
+ const { imageId: o, imageSourceType: a, source: s, base64Cache: l } = r, { width: c, height: m, image: u } = await Un(l || "");
1467
+ this._imageIoService.addImageSourceCache(o, a, u);
1468
+ let f = 1;
1469
+ if (c > Dt || m > Et) {
1470
+ const v = Dt / c, I = Et / m;
1471
+ f = Math.min(v, I);
1545
1472
  }
1546
- const f = this._getImagePosition(c * p, m * p);
1547
- if (f == null)
1473
+ const h = this._getImagePosition(c * f, m * f);
1474
+ if (h == null)
1548
1475
  return;
1549
- const g = {
1550
- unitId: n,
1551
- subUnitId: n,
1552
- drawingId: r,
1553
- drawingType: un.DRAWING_IMAGE,
1476
+ const p = {
1477
+ unitId: t,
1478
+ subUnitId: t,
1479
+ drawingId: o,
1480
+ drawingType: Bn.DRAWING_IMAGE,
1554
1481
  imageSourceType: a,
1555
1482
  source: s,
1556
- transform: Tn(f),
1557
- docTransform: f,
1558
- behindDoc: Me.FALSE,
1483
+ transform: Kn(h),
1484
+ docTransform: h,
1485
+ behindDoc: oe.FALSE,
1559
1486
  title: "",
1560
1487
  description: "",
1561
- layoutType: B.INLINE,
1562
- wrapText: Ae.BOTH_SIDES,
1488
+ layoutType: k.INLINE,
1489
+ // Insert inline drawing by default.
1490
+ wrapText: je.BOTH_SIDES,
1563
1491
  distB: 0,
1564
1492
  distL: 0,
1565
1493
  distR: 0,
1566
1494
  distT: 0
1567
1495
  };
1568
- t.push(g);
1496
+ this._isInsertInHeaderFooter() && (p.isMultiTransform = oe.TRUE, p.transforms = p.transform ? [p.transform] : null), n.push(p);
1569
1497
  }
1570
- this._commandService.executeCommand(st.id, {
1571
- unitId: n,
1572
- drawings: t
1498
+ this._commandService.executeCommand(gn.id, {
1499
+ unitId: t,
1500
+ drawings: n
1573
1501
  });
1574
1502
  }
1503
+ _isInsertInHeaderFooter() {
1504
+ var n;
1505
+ const { unitId: i } = this._context, e = (n = this._renderManagerSrv.getRenderById(i)) == null ? void 0 : n.with(ae).getViewModel(), t = e == null ? void 0 : e.getEditArea();
1506
+ return t === xe.HEADER || t === xe.FOOTER;
1507
+ }
1575
1508
  _getImagePosition(i, e) {
1576
- const n = this._textSelectionManagerService.getActiveTextRange(), t = (n == null ? void 0 : n.getAbsolutePosition()) || {
1509
+ const t = this._textSelectionManagerService.getActiveTextRange(), n = (t == null ? void 0 : t.getAbsolutePosition()) || {
1577
1510
  left: 0,
1578
1511
  top: 0
1579
1512
  };
@@ -1583,139 +1516,160 @@ let ln = class extends Ue {
1583
1516
  height: e
1584
1517
  },
1585
1518
  positionH: {
1586
- relativeFrom: Y.PAGE,
1587
- posOffset: t.left
1519
+ relativeFrom: ee.PAGE,
1520
+ posOffset: n.left
1588
1521
  },
1589
1522
  positionV: {
1590
- relativeFrom: G.MARGIN,
1591
- posOffset: t.top
1523
+ relativeFrom: V.MARGIN,
1524
+ posOffset: n.top
1592
1525
  },
1593
1526
  angle: 0
1594
1527
  };
1595
1528
  }
1596
1529
  _updateOrderListener() {
1597
1530
  this._drawingManagerService.featurePluginOrderUpdate$.subscribe((i) => {
1598
- const { unitId: e, subUnitId: n, drawingIds: t, arrangeType: o } = i;
1599
- this._commandService.executeCommand(it.id, {
1531
+ const { unitId: e, subUnitId: t, drawingIds: n, arrangeType: r } = i;
1532
+ this._commandService.executeCommand(ln.id, {
1600
1533
  unitId: e,
1601
- subUnitId: n,
1602
- drawingIds: t,
1603
- arrangeType: o
1534
+ subUnitId: t,
1535
+ drawingIds: n,
1536
+ arrangeType: r
1604
1537
  });
1605
1538
  });
1606
1539
  }
1607
1540
  _updateDrawingListener() {
1608
1541
  this._drawingManagerService.featurePluginUpdate$.subscribe((i) => {
1609
- if (i.length === 0)
1610
- return;
1611
- const e = [];
1612
- if (i.forEach((n) => {
1613
- const { unitId: t, subUnitId: o, drawingId: r, transform: a } = n;
1614
- if (a == null)
1615
- return;
1616
- const s = this._docDrawingService.getDrawingByParam({ unitId: t, subUnitId: o, drawingId: r });
1617
- if (s == null)
1618
- return;
1619
- const l = Vt({ ...s.transform, ...a });
1620
- if (l == null)
1621
- return;
1622
- const c = {
1623
- ...n,
1624
- transform: { ...a, ...Tn(l) },
1625
- docTransform: { ...l }
1626
- };
1627
- e.push(c);
1628
- }), e.length > 0) {
1629
- const n = i[0].unitId;
1630
- this._commandService.syncExecuteCommand(ot.id, {
1631
- unitId: n,
1632
- drawings: e
1633
- }), this._refreshDocSkeleton();
1634
- }
1635
1542
  });
1636
1543
  }
1637
- _refreshDocSkeleton() {
1638
- var t;
1639
- const { mainComponent: i, unitId: e } = this._context, n = (t = this._renderManagerSrv.getRenderById(e)) == null ? void 0 : t.with(me).getSkeleton();
1640
- n == null || n.calculate(), i == null || i.makeDirty();
1641
- }
1642
1544
  _groupDrawingListener() {
1643
1545
  this._drawingManagerService.featurePluginGroupUpdate$.subscribe((i) => {
1644
- this._commandService.executeCommand(at.id, i);
1546
+ this._commandService.executeCommand(mn.id, i);
1645
1547
  }), this._drawingManagerService.featurePluginUngroupUpdate$.subscribe((i) => {
1646
- this._commandService.executeCommand(rt.id, i);
1548
+ this._commandService.executeCommand(dn.id, i);
1647
1549
  });
1648
1550
  }
1649
1551
  _getCurrentSceneAndTransformer() {
1650
1552
  const { scene: i, mainComponent: e } = this._context;
1651
1553
  if (i == null || e == null)
1652
1554
  return;
1653
- const n = i.getTransformerByCreate(), { docsLeft: t, docsTop: o } = e.getOffsetConfig();
1654
- return { scene: i, transformer: n, docsLeft: t, docsTop: o };
1555
+ const t = i.getTransformerByCreate(), { docsLeft: n, docsTop: r } = e.getOffsetConfig();
1556
+ return { scene: i, transformer: t, docsLeft: n, docsTop: r };
1655
1557
  }
1656
1558
  _focusDrawingListener() {
1657
1559
  this.disposeWithMe(
1658
1560
  this._drawingManagerService.focus$.subscribe((i) => {
1659
- var o;
1660
- const { transformer: e, docsLeft: n, docsTop: t } = (o = this._getCurrentSceneAndTransformer()) != null ? o : {};
1661
- i == null || i.length === 0 ? (this._contextService.setContextValue(Ze, !1), this._docDrawingService.focusDrawing([]), e && e.resetProps({
1662
- zeroTop: 0,
1663
- zeroLeft: 0
1664
- })) : (this._contextService.setContextValue(Ze, !0), this._docDrawingService.focusDrawing(i), this._textSelectionManager.replaceTextRanges([]), e && e.resetProps({
1665
- zeroTop: t,
1666
- zeroLeft: n
1667
- }));
1561
+ var r;
1562
+ const { transformer: e, docsLeft: t, docsTop: n } = (r = this._getCurrentSceneAndTransformer()) != null ? r : {};
1563
+ if (i == null || i.length === 0)
1564
+ this._contextService.setContextValue(it, !1), this._docDrawingService.focusDrawing([]), e && e.resetProps({
1565
+ zeroTop: 0,
1566
+ zeroLeft: 0
1567
+ });
1568
+ else {
1569
+ this._contextService.setContextValue(it, !0), this._docDrawingService.focusDrawing(i), this._textSelectionManager.getActiveTextRange() && this._textSelectionManager.replaceTextRanges([]);
1570
+ const a = this._textSelectionRenderManager.getSegment(), s = this._findSegmentIdByDrawingId(i[0].drawingId);
1571
+ a !== s && this._textSelectionRenderManager.setSegment(s), e && e.resetProps({
1572
+ zeroTop: n,
1573
+ zeroLeft: t
1574
+ });
1575
+ }
1668
1576
  })
1669
1577
  );
1670
1578
  }
1579
+ _findSegmentIdByDrawingId(i) {
1580
+ var a, s, l;
1581
+ const { unit: e } = this._context, { body: t, headers: n = {}, footers: r = {} } = e.getSnapshot();
1582
+ if (((a = t == null ? void 0 : t.customBlocks) != null ? a : []).some((c) => c.blockId === i))
1583
+ return "";
1584
+ for (const c of Object.keys(n))
1585
+ if ((s = n[c].body.customBlocks) != null && s.some((m) => m.blockId === i))
1586
+ return c;
1587
+ for (const c of Object.keys(r))
1588
+ if ((l = r[c].body.customBlocks) != null && l.some((m) => m.blockId === i))
1589
+ return c;
1590
+ return "";
1591
+ }
1592
+ // Update drawings edit status and opacity. You can not edit header footer images when you are editing body. and vice verse.
1593
+ _updateDrawingsEditStatus() {
1594
+ var s;
1595
+ const { unit: i, scene: e, unitId: t } = this._context, n = (s = this._renderManagerSrv.getRenderById(t)) == null ? void 0 : s.with(ae).getViewModel();
1596
+ if (n == null || i == null)
1597
+ return;
1598
+ const r = i.getSnapshot(), { drawings: o = {} } = r, a = n.getEditArea() === xe.BODY;
1599
+ for (const l of Object.keys(o)) {
1600
+ const c = o[l], m = Fn({ unitId: t, drawingId: c.drawingId, subUnitId: t }), u = e.fuzzyMathObjects(m, !0);
1601
+ if (u.length)
1602
+ for (const f of u)
1603
+ e.detachTransformerFrom(f), f.setOpacity(0.5), (a && c.isMultiTransform !== oe.TRUE || !a && c.isMultiTransform === oe.TRUE) && (e.attachTransformerTo(f), f.setOpacity(1));
1604
+ }
1605
+ }
1606
+ _editAreaChangeListener() {
1607
+ var t;
1608
+ const { unitId: i } = this._context, e = (t = this._renderManagerSrv.getRenderById(i)) == null ? void 0 : t.with(ae).getViewModel();
1609
+ e != null && (this._updateDrawingsEditStatus(), this.disposeWithMe(
1610
+ e.editAreaChange$.subscribe(() => {
1611
+ this._updateDrawingsEditStatus();
1612
+ })
1613
+ ), this._docRefreshDrawingsService.refreshDrawings$.subscribe((n) => {
1614
+ n != null && queueMicrotask(() => {
1615
+ this._updateDrawingsEditStatus();
1616
+ });
1617
+ }), this.disposeWithMe(
1618
+ this._commandService.onCommandExecuted(async (n) => {
1619
+ n.id === Q.id && queueMicrotask(() => {
1620
+ this._updateDrawingsEditStatus();
1621
+ });
1622
+ })
1623
+ ));
1624
+ }
1671
1625
  };
1672
- ln = zi([
1673
- de(1, W),
1674
- de(2, Se(cn)),
1675
- de(3, Q),
1676
- de(4, yt),
1677
- de(5, De),
1678
- de(6, ge),
1679
- de(7, xn),
1680
- de(8, Qt),
1681
- de(9, Se(en)),
1682
- de(10, Se(cn)),
1683
- de(11, Le)
1684
- ], ln);
1685
- var Xi = Object.defineProperty, qi = Object.getOwnPropertyDescriptor, Ki = (i, e, n, t) => {
1686
- for (var o = t > 1 ? void 0 : t ? qi(e, n) : e, r = i.length - 1, a; r >= 0; r--)
1687
- (a = i[r]) && (o = (t ? a(e, n, o) : a(o)) || o);
1688
- return t && o && Xi(e, n, o), o;
1689
- }, $e = (i, e) => (n, t) => e(n, t, i);
1690
- let dn = class extends Ue {
1691
- constructor(e, n, t, o, r) {
1626
+ ut = Qi([
1627
+ de(1, $),
1628
+ de(2, pe(gt)),
1629
+ de(3, se),
1630
+ de(4, kn),
1631
+ de(5, Re),
1632
+ de(6, he),
1633
+ de(7, Bt),
1634
+ de(8, oi),
1635
+ de(9, pe(ot)),
1636
+ de(10, pe(gt)),
1637
+ de(11, Ue),
1638
+ de(12, pe(ct))
1639
+ ], ut);
1640
+ var Ji = Object.defineProperty, er = Object.getOwnPropertyDescriptor, tr = (i, e, t, n) => {
1641
+ for (var r = n > 1 ? void 0 : n ? er(e, t) : e, o = i.length - 1, a; o >= 0; o--)
1642
+ (a = i[o]) && (r = (n ? a(e, t, r) : a(r)) || r);
1643
+ return n && r && Ji(e, t, r), r;
1644
+ }, We = (i, e) => (t, n) => e(t, n, i);
1645
+ let ft = class extends qe {
1646
+ constructor(e, t, n, r, o, a) {
1692
1647
  super();
1693
- Pe(this, "_liquid", new Ln());
1694
- this._context = e, this._docSkeletonManagerService = n, this._commandService = t, this._editorService = o, this._drawingManagerService = r, this._initialize(), this._commandExecutedListener();
1648
+ _e(this, "_liquid", new Ht());
1649
+ this._context = e, this._docSkeletonManagerService = t, this._commandService = n, this._editorService = r, this._drawingManagerService = o, this._docRefreshDrawingsService = a, this._initialize(), this._commandExecutedListener();
1695
1650
  }
1696
1651
  _initialize() {
1697
1652
  this._initialRenderRefresh();
1698
1653
  }
1699
1654
  _initialRenderRefresh() {
1700
- const { mainComponent: e } = this._context;
1701
- this._docSkeletonManagerService.currentSkeleton$.subscribe((n) => {
1702
- if (n == null)
1703
- return;
1704
- e.changeSkeleton(n), this._refreshDrawing(n);
1655
+ this._docSkeletonManagerService.currentSkeleton$.subscribe((e) => {
1656
+ e != null && this._refreshDrawing(e);
1657
+ }), this._docRefreshDrawingsService.refreshDrawings$.subscribe((e) => {
1658
+ e != null && this._refreshDrawing(e);
1705
1659
  });
1706
1660
  }
1707
1661
  _commandExecutedListener() {
1708
- const e = [Z.id, kt.id];
1662
+ const e = [Q.id, Zn.id];
1709
1663
  this.disposeWithMe(
1710
- this._commandService.onCommandExecuted((n) => {
1711
- if (e.includes(n.id)) {
1712
- const t = n.params, { unitId: o } = t, { unitId: r, mainComponent: a } = this._context;
1713
- if (o !== r)
1664
+ this._commandService.onCommandExecuted((t) => {
1665
+ if (e.includes(t.id)) {
1666
+ const n = t.params, { unitId: r } = n, { unitId: o, mainComponent: a } = this._context;
1667
+ if (r !== o)
1714
1668
  return;
1715
1669
  const s = this._docSkeletonManagerService.getSkeleton();
1716
1670
  if (s == null)
1717
1671
  return;
1718
- if (this._editorService.isEditor(r)) {
1672
+ if (this._editorService.isEditor(o)) {
1719
1673
  a == null || a.makeDirty();
1720
1674
  return;
1721
1675
  }
@@ -1725,88 +1679,127 @@ let dn = class extends Ue {
1725
1679
  );
1726
1680
  }
1727
1681
  _refreshDrawing(e) {
1728
- var w, v;
1729
- const n = e == null ? void 0 : e.getSkeletonData(), { mainComponent: t, unitId: o } = this._context, r = t;
1730
- if (!n)
1682
+ var D, _;
1683
+ const t = e == null ? void 0 : e.getSkeletonData(), { mainComponent: n, unitId: r } = this._context, o = n;
1684
+ if (!t)
1731
1685
  return;
1732
- const { left: a, top: s, pageLayoutType: l, pageMarginLeft: c, pageMarginTop: m } = r, { pages: u, skeHeaders: p, skeFooters: f } = n, g = [];
1686
+ const { left: a, top: s, pageLayoutType: l, pageMarginLeft: c, pageMarginTop: m } = o, { pages: u, skeHeaders: f, skeFooters: h } = t, p = {};
1733
1687
  this._liquid.reset();
1734
- for (let I = 0, C = u.length; I < C; I++) {
1735
- const P = u[I], { headerId: S, footerId: O, pageWidth: R } = P;
1736
- if (S) {
1737
- const D = (w = p.get(S)) == null ? void 0 : w.get(R);
1738
- D && this._calculateDrawingPosition(o, D, a, s, g);
1688
+ for (let C = 0, O = u.length; C < O; C++) {
1689
+ const y = u[C], { headerId: T, footerId: N, pageWidth: R } = y;
1690
+ if (T) {
1691
+ const E = (D = f.get(T)) == null ? void 0 : D.get(R);
1692
+ E && this._calculateDrawingPosition(
1693
+ r,
1694
+ E,
1695
+ a,
1696
+ s,
1697
+ p,
1698
+ E.marginTop,
1699
+ y.marginLeft
1700
+ );
1739
1701
  }
1740
- if (O) {
1741
- const D = (v = f.get(O)) == null ? void 0 : v.get(R);
1742
- D && this._calculateDrawingPosition(o, D, a, s, g);
1702
+ if (N) {
1703
+ const E = (_ = h.get(N)) == null ? void 0 : _.get(R);
1704
+ E && this._calculateDrawingPosition(
1705
+ r,
1706
+ E,
1707
+ a,
1708
+ s,
1709
+ p,
1710
+ y.pageHeight - y.marginBottom + E.marginTop,
1711
+ y.marginLeft
1712
+ );
1743
1713
  }
1744
- this._calculateDrawingPosition(o, P, a, s, g), this._liquid.translatePage(P, l, c, m);
1714
+ this._calculateDrawingPosition(r, y, a, s, p, y.marginTop, y.marginLeft), this._liquid.translatePage(y, l, c, m);
1715
+ }
1716
+ const w = Object.values(p), v = w.filter((C) => !C.isMultiTransform), I = w.filter((C) => C.isMultiTransform);
1717
+ v.length > 0 && this._drawingManagerService.refreshTransform(v), I.length > 0 && this._handleMultiDrawingsTransform(I);
1718
+ }
1719
+ _handleMultiDrawingsTransform(e) {
1720
+ const { scene: t, unitId: n } = this._context, r = t.getTransformerByCreate();
1721
+ e.forEach((l) => {
1722
+ const c = this._drawingManagerService.getDrawingByParam(l);
1723
+ c != null && (c.transform = l.transform, c.transforms = l.transforms, c.isMultiTransform = l.isMultiTransform);
1724
+ });
1725
+ const a = [...r.getSelectedObjectMap().keys()], s = Object.values(this._drawingManagerService.getDrawingData(n, n)).filter((l) => l.isMultiTransform === oe.TRUE);
1726
+ this._drawingManagerService.removeNotification(s), this._drawingManagerService.addNotification(e);
1727
+ for (const l of a) {
1728
+ const c = t.getObject(l);
1729
+ c && r.setSelectedControl(c);
1745
1730
  }
1746
- g.length > 0 && this._drawingManagerService.refreshTransform(g);
1747
1731
  }
1748
- _calculateDrawingPosition(e, n, t, o, r) {
1749
- const { skeDrawings: a } = n;
1750
- this._liquid.translatePagePadding(n), a.forEach((s) => {
1751
- const { aLeft: l, aTop: c, height: m, width: u, angle: p, drawingId: f, drawingOrigin: g } = s, w = g.layoutType === B.WRAP_NONE && g.behindDoc === Me.TRUE;
1752
- r.push({
1732
+ _calculateDrawingPosition(e, t, n, r, o, a, s) {
1733
+ const { skeDrawings: l } = t;
1734
+ this._liquid.translatePagePadding({
1735
+ marginTop: a,
1736
+ marginLeft: s
1737
+ }), l.forEach((c) => {
1738
+ const { aLeft: m, aTop: u, height: f, width: h, angle: p, drawingId: w, drawingOrigin: v } = c, I = v.layoutType === k.WRAP_NONE && v.behindDoc === oe.TRUE, { isMultiTransform: D = oe.FALSE } = v, _ = {
1739
+ left: m + n + this._liquid.x,
1740
+ top: u + r + this._liquid.y,
1741
+ width: h,
1742
+ height: f,
1743
+ angle: p
1744
+ };
1745
+ o[w] == null ? o[w] = {
1753
1746
  unitId: e,
1754
1747
  subUnitId: e,
1755
- drawingId: f,
1756
- behindText: w,
1757
- transform: {
1758
- left: l + t + this._liquid.x,
1759
- top: c + o + this._liquid.y,
1760
- width: u,
1761
- height: m,
1762
- angle: p
1763
- }
1764
- });
1765
- }), this._liquid.restorePagePadding(n);
1748
+ drawingId: w,
1749
+ behindText: I,
1750
+ transform: _,
1751
+ transforms: [_],
1752
+ isMultiTransform: D
1753
+ } : D === oe.TRUE && o[w].transforms.push(_);
1754
+ }), this._liquid.restorePagePadding({
1755
+ marginTop: a,
1756
+ marginLeft: s
1757
+ });
1766
1758
  }
1767
1759
  };
1768
- dn = Ki([
1769
- $e(1, Se(me)),
1770
- $e(2, W),
1771
- $e(3, Jt),
1772
- $e(4, ge)
1773
- ], dn);
1774
- var Yi = Object.defineProperty, Zi = Object.getOwnPropertyDescriptor, Qi = (i, e, n, t) => {
1775
- for (var o = t > 1 ? void 0 : t ? Zi(e, n) : e, r = i.length - 1, a; r >= 0; r--)
1776
- (a = i[r]) && (o = (t ? a(e, n, o) : a(o)) || o);
1777
- return t && o && Yi(e, n, o), o;
1778
- }, Ne = (i, e) => (n, t) => e(n, t, i);
1779
- function Ji(i) {
1780
- var t, o, r, a;
1781
- if (k.isNoop(i) || !Array.isArray(i))
1760
+ ft = tr([
1761
+ We(1, pe(ae)),
1762
+ We(2, $),
1763
+ We(3, ai),
1764
+ We(4, he),
1765
+ We(5, pe(ct))
1766
+ ], ft);
1767
+ var nr = Object.defineProperty, ir = Object.getOwnPropertyDescriptor, rr = (i, e, t, n) => {
1768
+ for (var r = n > 1 ? void 0 : n ? ir(e, t) : e, o = i.length - 1, a; o >= 0; o--)
1769
+ (a = i[o]) && (r = (n ? a(e, t, r) : a(r)) || r);
1770
+ return n && r && nr(e, t, r), r;
1771
+ }, Ge = (i, e) => (t, n) => e(t, n, i);
1772
+ function or(i) {
1773
+ var n, r, o, a;
1774
+ if (X.isNoop(i) || !Array.isArray(i))
1782
1775
  return null;
1783
1776
  const e = i.find((s) => Array.isArray(s) && (s == null ? void 0 : s[0]) === "drawings");
1784
1777
  if (e == null || !Array.isArray(e) || e.length < 3 || typeof e[1] == "string" && typeof e[2] != "object" || Array.isArray(e[1]) && typeof e[1][1] != "object")
1785
1778
  return null;
1786
- const n = [];
1779
+ const t = [];
1787
1780
  if (Array.isArray(e == null ? void 0 : e[1]))
1788
1781
  for (const s of e)
1789
- Array.isArray(s) && n.push({
1790
- type: (t = s == null ? void 0 : s[1]) != null && t.i ? "add" : "remove",
1782
+ Array.isArray(s) && t.push({
1783
+ type: (n = s == null ? void 0 : s[1]) != null && n.i ? "add" : "remove",
1791
1784
  drawingId: s == null ? void 0 : s[0],
1792
- drawing: (o = s == null ? void 0 : s[1]) == null ? void 0 : o.i
1785
+ drawing: (r = s == null ? void 0 : s[1]) == null ? void 0 : r.i
1793
1786
  });
1794
1787
  else
1795
- n.push({
1796
- type: (r = e[2]) != null && r.i ? "add" : "remove",
1788
+ t.push({
1789
+ type: (o = e[2]) != null && o.i ? "add" : "remove",
1797
1790
  drawingId: e[1],
1798
1791
  drawing: (a = e[2]) == null ? void 0 : a.i
1799
1792
  });
1800
- return n;
1793
+ return t;
1801
1794
  }
1802
- function eo(i) {
1795
+ function ar(i) {
1803
1796
  if (!Array.isArray(i) || i.length < 3 || i[0] !== "drawingsOrder")
1804
1797
  return [];
1805
1798
  const e = [];
1806
- for (let n = 1; n < i.length; n++) {
1807
- const t = i[n];
1808
- if (Array.isArray(t) && typeof t[0] == "number" && typeof t[1] == "object")
1809
- e.push(t[0]);
1799
+ for (let t = 1; t < i.length; t++) {
1800
+ const n = i[t];
1801
+ if (Array.isArray(n) && typeof n[0] == "number" && typeof n[1] == "object")
1802
+ e.push(n[0]);
1810
1803
  else {
1811
1804
  e.length = 0;
1812
1805
  break;
@@ -1814,9 +1807,9 @@ function eo(i) {
1814
1807
  }
1815
1808
  return e;
1816
1809
  }
1817
- let Ke = class extends Ue {
1818
- constructor(i, e, n, t, o) {
1819
- super(), this._univerInstanceService = i, this._commandService = e, this._drawingManagerService = n, this._docDrawingService = t, this._renderManagerService = o, this._initialize();
1810
+ let tt = class extends qe {
1811
+ constructor(i, e, t, n, r) {
1812
+ super(), this._univerInstanceService = i, this._commandService = e, this._drawingManagerService = t, this._docDrawingService = n, this._renderManagerService = r, this._initialize();
1820
1813
  }
1821
1814
  _initialize() {
1822
1815
  this._commandExecutedListener();
@@ -1824,87 +1817,87 @@ let Ke = class extends Ue {
1824
1817
  _commandExecutedListener() {
1825
1818
  this.disposeWithMe(
1826
1819
  this._commandService.beforeCommandExecuted((i) => {
1827
- if (i.id !== Z.id)
1820
+ if (i.id !== Q.id)
1828
1821
  return;
1829
- const e = i.params, { unitId: n, actions: t } = e, o = Ji(t);
1830
- if (o != null)
1831
- for (const { type: r, drawingId: a, drawing: s } of o)
1832
- r === "add" ? this._addDrawings(n, [s]) : this._removeDrawings(n, [a]);
1822
+ const e = i.params, { unitId: t, actions: n } = e, r = or(n);
1823
+ if (r != null)
1824
+ for (const { type: o, drawingId: a, drawing: s } of r)
1825
+ o === "add" ? this._addDrawings(t, [s]) : this._removeDrawings(t, [a]);
1833
1826
  })
1834
1827
  ), this.disposeWithMe(
1835
1828
  this._commandService.onCommandExecuted((i) => {
1836
- if (i.id !== Z.id)
1829
+ if (i.id !== Q.id)
1837
1830
  return;
1838
- const e = i.params, { unitId: n, actions: t } = e;
1839
- eo(t).length > 0 && this._updateDrawingsOrder(n);
1831
+ const e = i.params, { unitId: t, actions: n } = e;
1832
+ ar(n).length > 0 && this._updateDrawingsOrder(t);
1840
1833
  })
1841
1834
  ), this.disposeWithMe(
1842
1835
  this._commandService.onCommandExecuted((i) => {
1843
1836
  var a;
1844
- if (i.id !== ft.id && i.id !== ht.id)
1837
+ if (i.id !== Dn.id && i.id !== En.id)
1845
1838
  return;
1846
- const e = (a = this._univerInstanceService.getCurrentUniverDocInstance()) == null ? void 0 : a.getUnitId(), n = this._drawingManagerService.getFocusDrawings();
1847
- if (e == null || n.length === 0)
1839
+ const e = (a = this._univerInstanceService.getCurrentUniverDocInstance()) == null ? void 0 : a.getUnitId(), t = this._drawingManagerService.getFocusDrawings();
1840
+ if (e == null || t.length === 0)
1848
1841
  return;
1849
- const t = this._renderManagerService.getRenderById(e), o = t == null ? void 0 : t.scene;
1850
- if (o == null)
1842
+ const n = this._renderManagerService.getRenderById(e), r = n == null ? void 0 : n.scene;
1843
+ if (r == null)
1851
1844
  return !1;
1852
- o.getTransformerByCreate().refreshControls();
1845
+ r.getTransformerByCreate().refreshControls();
1853
1846
  })
1854
1847
  );
1855
1848
  }
1856
1849
  _addDrawings(i, e) {
1857
- const n = this._drawingManagerService, t = this._docDrawingService, o = this._docDrawingService.getBatchAddOp(e), { subUnitId: r, redo: a, objects: s } = o;
1858
- n.applyJson1(i, r, a), t.applyJson1(i, r, a), n.addNotification(s), t.addNotification(s);
1850
+ const t = this._drawingManagerService, n = this._docDrawingService, r = this._docDrawingService.getBatchAddOp(e), { subUnitId: o, redo: a, objects: s } = r;
1851
+ t.applyJson1(i, o, a), n.applyJson1(i, o, a), t.addNotification(s), n.addNotification(s);
1859
1852
  }
1860
1853
  _removeDrawings(i, e) {
1861
- const n = this._drawingManagerService, t = this._docDrawingService, o = this._docDrawingService.getBatchRemoveOp(e.map((l) => ({
1854
+ const t = this._drawingManagerService, n = this._docDrawingService, r = this._docDrawingService.getBatchRemoveOp(e.map((l) => ({
1862
1855
  unitId: i,
1863
1856
  subUnitId: i,
1864
1857
  drawingId: l
1865
- }))), { subUnitId: r, redo: a, objects: s } = o;
1866
- n.applyJson1(i, r, a), t.applyJson1(i, r, a), n.removeNotification(s), t.removeNotification(s);
1858
+ }))), { subUnitId: o, redo: a, objects: s } = r;
1859
+ t.applyJson1(i, o, a), n.applyJson1(i, o, a), t.removeNotification(s), n.removeNotification(s);
1867
1860
  }
1868
1861
  _updateDrawingsOrder(i) {
1869
1862
  const e = this._univerInstanceService.getUniverDocInstance(i);
1870
1863
  if (e == null)
1871
1864
  return;
1872
- const n = e.getSnapshot().drawingsOrder;
1873
- if (n == null)
1865
+ const t = e.getSnapshot().drawingsOrder;
1866
+ if (t == null)
1874
1867
  return;
1875
- const t = this._drawingManagerService, o = this._docDrawingService;
1876
- t.setDrawingOrder(i, i, n), o.setDrawingOrder(i, i, n);
1877
- const r = {
1868
+ const n = this._drawingManagerService, r = this._docDrawingService;
1869
+ n.setDrawingOrder(i, i, t), r.setDrawingOrder(i, i, t);
1870
+ const o = {
1878
1871
  unitId: i,
1879
1872
  subUnitId: i,
1880
- drawingIds: n
1873
+ drawingIds: t
1881
1874
  };
1882
- t.orderNotification(r), o.orderNotification(r);
1875
+ n.orderNotification(o), r.orderNotification(o);
1883
1876
  }
1884
1877
  };
1885
- Ke = Qi([
1886
- nn(tn.Steady, Ke),
1887
- Ne(0, X),
1888
- Ne(1, W),
1889
- Ne(2, ge),
1890
- Ne(3, De),
1891
- Ne(4, Q)
1892
- ], Ke);
1893
- var no = Object.defineProperty, to = Object.getOwnPropertyDescriptor, io = (i, e, n, t) => {
1894
- for (var o = t > 1 ? void 0 : t ? to(e, n) : e, r = i.length - 1, a; r >= 0; r--)
1895
- (a = i[r]) && (o = (t ? a(e, n, o) : a(o)) || o);
1896
- return t && o && no(e, n, o), o;
1897
- }, ze = (i, e) => (n, t) => e(n, t, i);
1898
- const oo = "__InlineDrawingAnchor__";
1899
- let Ye = class extends Ue {
1900
- constructor(e, n, t, o) {
1878
+ tt = rr([
1879
+ at(st.Steady, tt),
1880
+ Ge(0, te),
1881
+ Ge(1, $),
1882
+ Ge(2, he),
1883
+ Ge(3, Re),
1884
+ Ge(4, se)
1885
+ ], tt);
1886
+ var sr = Object.defineProperty, cr = Object.getOwnPropertyDescriptor, lr = (i, e, t, n) => {
1887
+ for (var r = n > 1 ? void 0 : n ? cr(e, t) : e, o = i.length - 1, a; o >= 0; o--)
1888
+ (a = i[o]) && (r = (n ? a(e, t, r) : a(r)) || r);
1889
+ return n && r && sr(e, t, r), r;
1890
+ }, Ve = (i, e) => (t, n) => e(t, n, i);
1891
+ const dr = "__InlineDrawingAnchor__";
1892
+ let nt = class extends qe {
1893
+ constructor(e, t, n, r, o) {
1901
1894
  super();
1902
- Pe(this, "_liquid", new Ln());
1903
- Pe(this, "_listenerOnImageMap", /* @__PURE__ */ new Set());
1895
+ _e(this, "_liquid", new Ht());
1896
+ _e(this, "_listenerOnImageMap", /* @__PURE__ */ new Set());
1904
1897
  // Use to cache the drawings is under transforming or scaling.
1905
- Pe(this, "_transformerCache", /* @__PURE__ */ new Map());
1906
- Pe(this, "_anchorShape");
1907
- this._commandService = e, this._univerInstanceService = n, this._drawingManagerService = t, this._renderManagerService = o, this._init();
1898
+ _e(this, "_transformerCache", /* @__PURE__ */ new Map());
1899
+ _e(this, "_anchorShape");
1900
+ this._commandService = e, this._univerInstanceService = t, this._drawingManagerService = n, this._renderManagerService = r, this._textSelectionRenderManager = o, this._init();
1908
1901
  }
1909
1902
  _init() {
1910
1903
  this._listenDrawingFocus();
@@ -1913,9 +1906,9 @@ let Ye = class extends Ue {
1913
1906
  this.disposeWithMe(
1914
1907
  this._drawingManagerService.add$.subscribe((e) => {
1915
1908
  if (e.length !== 0)
1916
- for (const n of e) {
1917
- const { unitId: t } = n;
1918
- this._listenerOnImageMap.has(t) || (this._listenTransformerChange(t), this._listenerOnImageMap.add(t));
1909
+ for (const t of e) {
1910
+ const { unitId: n } = t;
1911
+ this._listenerOnImageMap.has(n) || (this._listenTransformerChange(n), this._listenerOnImageMap.add(n));
1919
1912
  }
1920
1913
  })
1921
1914
  );
@@ -1923,66 +1916,66 @@ let Ye = class extends Ue {
1923
1916
  // Only handle one drawing transformer change.
1924
1917
  // eslint-disable-next-line max-lines-per-function
1925
1918
  _listenTransformerChange(e) {
1926
- var o;
1927
- const n = (o = this._getSceneAndTransformerByDrawingSearch(e)) == null ? void 0 : o.transformer;
1928
- if (n == null)
1919
+ var r;
1920
+ const t = (r = this._getSceneAndTransformerByDrawingSearch(e)) == null ? void 0 : r.transformer;
1921
+ if (t == null)
1929
1922
  return;
1930
1923
  this.disposeWithMe(
1931
- Ee(
1932
- n.changeStart$.subscribe((r) => {
1924
+ ye(
1925
+ t.changeStart$.subscribe((o) => {
1933
1926
  var s;
1934
1927
  this._transformerCache.clear();
1935
- const { objects: a } = r;
1928
+ const { objects: a } = o;
1936
1929
  for (const l of a.values()) {
1937
- const { oKey: c, width: m, height: u, left: p, top: f, angle: g } = l, w = this._drawingManagerService.getDrawingOKey(c);
1930
+ const { oKey: c, width: m, height: u, left: f, top: h, angle: p } = l, w = this._drawingManagerService.getDrawingOKey(c);
1938
1931
  if (w == null)
1939
1932
  continue;
1940
1933
  const v = this._univerInstanceService.getUniverDocInstance(w.unitId), I = (s = v == null ? void 0 : v.getSnapshot().drawings) == null ? void 0 : s[w.drawingId];
1941
- (I == null ? void 0 : I.layoutType) === B.INLINE && l.setOpacity(0.2), I != null && this._transformerCache.set(w.drawingId, {
1934
+ (I == null ? void 0 : I.layoutType) === k.INLINE && l.setOpacity(0.2), I != null && this._transformerCache.set(w.drawingId, {
1942
1935
  drawing: I,
1943
- top: f,
1944
- left: p,
1936
+ top: h,
1937
+ left: f,
1945
1938
  width: m,
1946
1939
  height: u,
1947
- angle: g
1940
+ angle: p
1948
1941
  });
1949
1942
  }
1950
1943
  })
1951
1944
  )
1952
1945
  );
1953
- const t = In(this._updateMultipleDrawingDocTransform.bind(this), 50);
1954
- In(this._nonInlineDrawingTransform.bind(this), 50), this.disposeWithMe(
1955
- Ee(
1956
- n.changing$.subscribe((r) => {
1957
- const { objects: a, offsetX: s, offsetY: l } = r;
1946
+ const n = Ct(this._updateMultipleDrawingDocTransform.bind(this), 50);
1947
+ Ct(this._nonInlineDrawingTransform.bind(this), 50), this.disposeWithMe(
1948
+ ye(
1949
+ t.changing$.subscribe((o) => {
1950
+ const { objects: a, offsetX: s, offsetY: l } = o;
1958
1951
  if (a.size > 1)
1959
- t(a);
1952
+ n(a);
1960
1953
  else if (a.size === 1) {
1961
- const c = this._transformerCache.values().next().value, m = a.values().next().value, { width: u, height: p, top: f, left: g, angle: w } = m;
1962
- if (u === c.width && p === c.height && f === c.top && g === c.left && w === c.angle)
1954
+ const c = this._transformerCache.values().next().value, m = a.values().next().value, { width: u, height: f, top: h, left: p, angle: w } = m;
1955
+ if (u === c.width && f === c.height && h === c.top && p === c.left && w === c.angle)
1963
1956
  return;
1964
- c && (c.drawing.layoutType, B.INLINE), c && c.drawing.layoutType === B.INLINE && s != null && l != null && this._updateInlineDrawingAnchor(c.drawing, s, l);
1957
+ c && (c.drawing.layoutType, k.INLINE), c && c.drawing.layoutType === k.INLINE && s != null && l != null && this._updateInlineDrawingAnchor(c.drawing, s, l);
1965
1958
  }
1966
1959
  })
1967
1960
  )
1968
1961
  ), this.disposeWithMe(
1969
- Ee(
1970
- n.changeEnd$.subscribe((r) => {
1971
- const { objects: a, offsetX: s, offsetY: l } = r;
1962
+ ye(
1963
+ t.changeEnd$.subscribe((o) => {
1964
+ const { objects: a, offsetX: s, offsetY: l } = o;
1972
1965
  for (const c of a.values()) {
1973
1966
  const m = this._drawingManagerService.getDrawingOKey(c.oKey);
1974
1967
  if (m == null)
1975
1968
  continue;
1976
1969
  const u = this._transformerCache.get(m == null ? void 0 : m.drawingId);
1977
- (u == null ? void 0 : u.drawing.layoutType) === B.INLINE && c.setOpacity(1);
1970
+ (u == null ? void 0 : u.drawing.layoutType) === k.INLINE && c.setOpacity(1);
1978
1971
  }
1979
1972
  if (this._anchorShape && this._anchorShape.hide(), a.size > 1)
1980
1973
  this._updateMultipleDrawingDocTransform(a);
1981
1974
  else if (a.size === 1) {
1982
- const c = this._transformerCache.values().next().value, m = a.values().next().value, { width: u, height: p, top: f, left: g, angle: w } = m;
1983
- if (u === c.width && p === c.height && f === c.top && g === c.left && w === c.angle)
1975
+ const c = this._transformerCache.values().next().value, m = a.values().next().value, { width: u, height: f, top: h, left: p, angle: w } = m;
1976
+ if (u === c.width && f === c.height && h === c.top && p === c.left && w === c.angle)
1984
1977
  return;
1985
- c && c.drawing.layoutType === B.INLINE ? u !== c.width || p !== c.height || w !== c.angle ? this._updateDrawingSize(c, m) : s != null && l != null && this._moveInlineDrawing(c.drawing, s, l) : c && this._nonInlineDrawingTransform(c.drawing, m);
1978
+ c && c.drawing.layoutType === k.INLINE ? u !== c.width || f !== c.height || w !== c.angle ? this._updateDrawingSize(c, m) : s != null && l != null && this._moveInlineDrawing(c.drawing, s, l) : c && this._nonInlineDrawingTransform(c.drawing, m);
1986
1979
  }
1987
1980
  this._transformerCache.clear();
1988
1981
  })
@@ -1993,308 +1986,355 @@ let Ye = class extends Ue {
1993
1986
  _updateMultipleDrawingDocTransform(e) {
1994
1987
  if (e.size < 1)
1995
1988
  return;
1996
- const n = [];
1997
- let t, o;
1998
- for (const r of e.values()) {
1999
- const { oKey: a, left: s, top: l, angle: c } = r;
2000
- let { width: m, height: u } = r;
2001
- const p = this._drawingManagerService.getDrawingOKey(a);
2002
- if (p == null)
2003
- continue;
2004
- t == null && (t = p.unitId), o == null && (o = p.subUnitId);
2005
- const f = this._transformerCache.get(p.drawingId);
1989
+ const t = [];
1990
+ let n, r;
1991
+ for (const o of e.values()) {
1992
+ const { oKey: a, left: s, top: l, angle: c } = o;
1993
+ let { width: m, height: u } = o;
1994
+ const f = this._drawingManagerService.getDrawingOKey(a);
2006
1995
  if (f == null)
2007
1996
  continue;
2008
- const { drawing: g, top: w, left: v, width: I, height: C, angle: P } = f, { width: S, height: O } = this._getPageContentSize(g);
2009
- if (m = Math.min(m, S), u = Math.min(u, O), (I !== m || C !== u) && n.push({
2010
- drawingId: p.drawingId,
1997
+ n == null && (n = f.unitId), r == null && (r = f.subUnitId);
1998
+ const h = this._transformerCache.get(f.drawingId);
1999
+ if (h == null)
2000
+ continue;
2001
+ const { drawing: p, top: w, left: v, width: I, height: D, angle: _ } = h, { width: C, height: O } = this._getPageContentSize(p);
2002
+ if (m = Math.min(m, C), u = Math.min(u, O), (I !== m || D !== u) && t.push({
2003
+ drawingId: f.drawingId,
2011
2004
  key: "size",
2012
2005
  value: {
2013
2006
  width: m,
2014
2007
  height: u
2015
2008
  }
2016
- }), P !== c && n.push({
2017
- drawingId: p.drawingId,
2009
+ }), _ !== c && t.push({
2010
+ drawingId: f.drawingId,
2018
2011
  key: "angle",
2019
2012
  value: c
2020
2013
  }), w !== l || v !== s) {
2021
- const R = l - w, D = s - v;
2022
- R !== 0 && n.push({
2023
- drawingId: p.drawingId,
2014
+ const y = l - w, T = s - v;
2015
+ y !== 0 && t.push({
2016
+ drawingId: f.drawingId,
2024
2017
  key: "positionV",
2025
2018
  value: {
2026
- relativeFrom: g.docTransform.positionV.relativeFrom,
2027
- posOffset: g.docTransform.positionV.posOffset + R
2019
+ relativeFrom: p.docTransform.positionV.relativeFrom,
2020
+ posOffset: p.docTransform.positionV.posOffset + y
2028
2021
  }
2029
- }), D !== 0 && n.push({
2030
- drawingId: p.drawingId,
2022
+ }), T !== 0 && t.push({
2023
+ drawingId: f.drawingId,
2031
2024
  key: "positionH",
2032
2025
  value: {
2033
- relativeFrom: g.docTransform.positionH.relativeFrom,
2034
- posOffset: g.docTransform.positionH.posOffset + D
2026
+ relativeFrom: p.docTransform.positionH.relativeFrom,
2027
+ posOffset: p.docTransform.positionH.posOffset + T
2035
2028
  }
2036
2029
  });
2037
2030
  }
2038
2031
  }
2039
- n.length > 0 && t && o && this._commandService.executeCommand(xe.id, {
2040
- unitId: t,
2041
- subUnitId: o,
2042
- drawings: n
2032
+ t.length > 0 && n && r && this._commandService.executeCommand(ze.id, {
2033
+ unitId: n,
2034
+ subUnitId: r,
2035
+ drawings: t
2043
2036
  });
2044
2037
  }
2045
2038
  // TODO: @JOCS, Use to draw and update the drawing anchor.
2046
2039
  _updateDrawingAnchor(e) {
2047
2040
  if (this._transformerCache.size !== 1)
2048
2041
  return;
2049
- const n = this._transformerCache.values().next().value, t = e.values().next().value;
2050
- this._getDrawingAnchor(n.drawing, t);
2042
+ const t = this._transformerCache.values().next().value, n = e.values().next().value;
2043
+ this._getDrawingAnchor(t.drawing, n);
2051
2044
  }
2052
- _updateInlineDrawingAnchor(e, n, t) {
2053
- var r;
2045
+ _updateInlineDrawingAnchor(e, t, n) {
2046
+ var o;
2054
2047
  if (this._transformerCache.size !== 1)
2055
2048
  return;
2056
- const { contentBoxPointGroup: o } = (r = this._getInlineDrawingAnchor(e, n, t)) != null ? r : {};
2057
- o != null && this._createOrUpdateInlineAnchor(e.unitId, o);
2049
+ const { contentBoxPointGroup: r } = (o = this._getInlineDrawingAnchor(e, t, n)) != null ? o : {};
2050
+ r != null && this._createOrUpdateInlineAnchor(e.unitId, r);
2058
2051
  }
2059
- _getInlineDrawingAnchor(e, n, t) {
2060
- var V;
2061
- const o = this._renderManagerService.getRenderById(e.unitId), r = o == null ? void 0 : o.with(me).getSkeleton();
2062
- if (o == null)
2052
+ _getInlineDrawingAnchor(e, t, n) {
2053
+ var z;
2054
+ const r = this._renderManagerService.getRenderById(e.unitId), o = r == null ? void 0 : r.with(ae).getSkeleton();
2055
+ if (r == null)
2063
2056
  return;
2064
- const { mainComponent: a, scene: s } = o, l = a, c = s.getViewports()[0], {
2065
- pageLayoutType: m = Dn.VERTICAL,
2057
+ const { mainComponent: a, scene: s } = r, l = a, c = s.getViewports()[0], {
2058
+ pageLayoutType: m = Pt.VERTICAL,
2066
2059
  pageMarginLeft: u,
2067
- pageMarginTop: p
2060
+ pageMarginTop: f
2068
2061
  } = l.getOffsetConfig();
2069
- let f = null, g = !1, w = -1;
2070
- const v = 0.5, I = this._getTransformCoordForDocumentOffset(l, c, n, t);
2071
- if (I == null)
2062
+ let h = null, p = !1, w = -1, v = "";
2063
+ const I = 0.5, D = this._getTransformCoordForDocumentOffset(l, c, t, n);
2064
+ if (D == null)
2072
2065
  return;
2073
- const C = r == null ? void 0 : r.findNodeByCoord(I, m, u, p);
2074
- if (C) {
2075
- const { node: x, ratioX: L, segmentPage: z } = C;
2076
- g = L < v, f = x, w = z;
2066
+ const _ = o == null ? void 0 : o.findNodeByCoord(
2067
+ D,
2068
+ m,
2069
+ u,
2070
+ f,
2071
+ {
2072
+ strict: !1,
2073
+ segmentId: this._textSelectionRenderManager.getSegment(),
2074
+ segmentPage: this._textSelectionRenderManager.getSegmentPage()
2075
+ }
2076
+ );
2077
+ if (_) {
2078
+ const { node: U, ratioX: B, segmentPage: b, segmentId: S } = _;
2079
+ p = B < I, h = U, w = b, v = S;
2077
2080
  }
2078
- if (f == null)
2081
+ if (h == null)
2079
2082
  return;
2080
- const P = r == null ? void 0 : r.findPositionByGlyph(f, w), S = this._getDocObject();
2081
- if (P == null || r == null || S == null)
2083
+ const C = o == null ? void 0 : o.findPositionByGlyph(h, w), O = this._getDocObject();
2084
+ if (C == null || o == null || O == null)
2082
2085
  return;
2083
- const O = {
2084
- ...P,
2085
- isBack: g
2086
- }, R = S.document.getOffsetConfig(), D = new Pn(R, r), { cursorList: b, contentBoxPointGroup: y } = D.getRangePointData(O, O), { startOffset: T } = (V = En(b)) != null ? V : {};
2087
- if (T != null)
2088
- return { offset: T, contentBoxPointGroup: y };
2086
+ const y = {
2087
+ ...C,
2088
+ isBack: p
2089
+ }, T = O.document.getOffsetConfig(), N = new Ot(T, o), { cursorList: R, contentBoxPointGroup: E } = N.getRangePointData(y, y), { startOffset: H } = (z = Tt(R)) != null ? z : {};
2090
+ if (H != null)
2091
+ return { offset: H, contentBoxPointGroup: E, segmentId: v, segmentPage: w };
2089
2092
  }
2090
2093
  // eslint-disable-next-line max-lines-per-function, complexity
2091
- _getDrawingAnchor(e, n) {
2092
- var ee, we, ve, ne;
2093
- const t = this._renderManagerService.getRenderById(e.unitId), o = t == null ? void 0 : t.with(me).getSkeleton(), r = o == null ? void 0 : o.getViewModel(), a = o == null ? void 0 : o.getSkeletonData();
2094
- if (a == null || t == null || r == null)
2094
+ _getDrawingAnchor(e, t) {
2095
+ var we, ve, ne, Ne, Ie, Se, Te, Me, De, J;
2096
+ const n = this._renderManagerService.getRenderById(e.unitId), r = n == null ? void 0 : n.with(ae).getSkeleton(), o = r == null ? void 0 : r.getSkeletonData();
2097
+ if (o == null || n == null)
2095
2098
  return;
2096
- const { pages: s } = a, { mainComponent: l, scene: c } = t, m = l, u = c.getViewports()[0], { pageLayoutType: p = Dn.VERTICAL, pageMarginLeft: f, pageMarginTop: g, docsLeft: w, docsTop: v } = m.getOffsetConfig(), { left: I, top: C, angle: P } = n;
2097
- let { width: S, height: O } = n;
2098
- const { positionV: R, positionH: D } = e.docTransform, { width: b, height: y } = this._getPageContentSize(e);
2099
- S = Math.min(S, b), O = Math.min(O, y);
2100
- let T = null, V = -1;
2101
- const x = !1, L = {
2099
+ const { pages: a, skeHeaders: s, skeFooters: l } = o, { mainComponent: c, scene: m } = n, u = c, f = m.getViewports()[0], { pageLayoutType: h = Pt.VERTICAL, pageMarginLeft: p, pageMarginTop: w, docsLeft: v, docsTop: I } = u.getOffsetConfig(), { left: D, top: _, angle: C } = t;
2100
+ let { width: O, height: y } = t;
2101
+ const { positionV: T, positionH: N } = e.docTransform, { width: R, height: E } = this._getPageContentSize(e);
2102
+ O = Math.min(O, R), y = Math.min(y, E);
2103
+ let H = null, z = "", U = -1;
2104
+ const B = !1, b = {
2102
2105
  ...e.docTransform,
2103
2106
  size: {
2104
- width: S,
2105
- height: O
2107
+ width: O,
2108
+ height: y
2106
2109
  },
2107
- angle: P
2108
- }, { x: z, y: N } = c.getViewportScrollXY(u), _ = this._getTransformCoordForDocumentOffset(m, u, I - z, C - N);
2109
- if (_ == null)
2110
+ angle: C
2111
+ }, { x: S, y: A } = m.getViewportScrollXY(f), P = this._getTransformCoordForDocumentOffset(u, f, D - S, _ - A);
2112
+ if (P == null)
2110
2113
  return;
2111
- const M = o == null ? void 0 : o.findNodeByCoord(_, p, f, g);
2112
- if (M) {
2113
- const { node: le, segmentPage: Ge } = M;
2114
- T = le, V = Ge;
2114
+ const L = r == null ? void 0 : r.findNodeByCoord(P, h, p, w, {
2115
+ strict: !1,
2116
+ segmentId: this._textSelectionRenderManager.getSegment(),
2117
+ segmentPage: this._textSelectionRenderManager.getSegmentPage()
2118
+ });
2119
+ if (L) {
2120
+ const { node: q, segmentPage: lt, segmentId: dt } = L;
2121
+ H = q, U = lt, z = dt;
2115
2122
  }
2116
- if (T == null)
2123
+ if (H == null)
2124
+ return;
2125
+ const x = (we = H.parent) == null ? void 0 : we.parent, M = x == null ? void 0 : x.parent, W = (ve = M == null ? void 0 : M.lines.find((q) => q.paragraphIndex === (x == null ? void 0 : x.paragraphIndex) && q.paragraphStart)) != null ? ve : M == null ? void 0 : M.lines[0], G = (ne = M == null ? void 0 : M.parent) == null ? void 0 : ne.parent;
2126
+ if (x == null || M == null || W == null || G == null)
2117
2127
  return;
2118
- const E = (ee = T.parent) == null ? void 0 : ee.parent, A = E == null ? void 0 : E.parent, U = (we = A == null ? void 0 : A.lines.find((le) => le.paragraphIndex === (E == null ? void 0 : E.paragraphIndex) && le.paragraphStart)) != null ? we : A == null ? void 0 : A.lines[0], F = (ve = A == null ? void 0 : A.parent) == null ? void 0 : ve.parent;
2119
2128
  this._liquid.reset();
2120
- for (const le of s) {
2121
- if (this._liquid.translatePagePadding(le), le === F)
2129
+ const F = G.type;
2130
+ for (const q of a) {
2131
+ const { headerId: lt, footerId: dt, pageHeight: pn, pageWidth: It, marginLeft: _t, marginBottom: hn } = q, wn = a.indexOf(q);
2132
+ if (U > -1 && wn === U) {
2133
+ switch (F) {
2134
+ case Mt.HEADER: {
2135
+ const Fe = (Ne = s.get(lt)) == null ? void 0 : Ne.get(It);
2136
+ if (Fe)
2137
+ this._liquid.translatePagePadding({
2138
+ marginTop: Fe.marginTop,
2139
+ marginLeft: _t
2140
+ });
2141
+ else
2142
+ throw new Error("header skeleton not found");
2143
+ break;
2144
+ }
2145
+ case Mt.FOOTER: {
2146
+ const Fe = (Ie = l.get(dt)) == null ? void 0 : Ie.get(It);
2147
+ if (Fe)
2148
+ this._liquid.translatePagePadding({
2149
+ marginTop: pn - hn + Fe.marginTop,
2150
+ marginLeft: _t
2151
+ });
2152
+ else
2153
+ throw new Error("footer skeleton not found");
2154
+ break;
2155
+ }
2156
+ }
2122
2157
  break;
2123
- this._liquid.restorePagePadding(le), this._liquid.translatePage(le, p, f, g);
2158
+ }
2159
+ if (this._liquid.translatePagePadding(q), q === G)
2160
+ break;
2161
+ this._liquid.restorePagePadding(q), this._liquid.translatePage(q, h, p, w);
2124
2162
  }
2125
- if (E == null || A == null || U == null || F == null)
2126
- return;
2127
- switch (R.relativeFrom === G.LINE ? T = E.divides[0].glyphGroup[0] : T = U.divides[0].glyphGroup[0], L.positionH = {
2128
- relativeFrom: D.relativeFrom,
2129
- posOffset: I - this._liquid.x - w
2130
- }, D.relativeFrom) {
2131
- case Y.MARGIN: {
2132
- L.positionH.posOffset = I - this._liquid.x - w - F.marginLeft;
2163
+ switch (T.relativeFrom === V.LINE ? H = x.divides[0].glyphGroup[0] : H = (De = (Me = (Te = (Se = W.divides) == null ? void 0 : Se[0]) == null ? void 0 : Te.glyphGroup) == null ? void 0 : Me[0]) != null ? De : H, b.positionH = {
2164
+ relativeFrom: N.relativeFrom,
2165
+ posOffset: D - this._liquid.x - v
2166
+ }, N.relativeFrom) {
2167
+ case ee.MARGIN: {
2168
+ b.positionH.posOffset = D - this._liquid.x - v - G.marginLeft;
2133
2169
  break;
2134
2170
  }
2135
- case Y.COLUMN: {
2136
- L.positionH.posOffset = I - this._liquid.x - w - A.left;
2171
+ case ee.COLUMN: {
2172
+ b.positionH.posOffset = D - this._liquid.x - v - M.left;
2137
2173
  break;
2138
2174
  }
2139
2175
  }
2140
- switch (L.positionV = {
2141
- relativeFrom: R.relativeFrom,
2142
- posOffset: C - this._liquid.y - v
2143
- }, R.relativeFrom) {
2144
- case G.PAGE: {
2145
- L.positionV.posOffset = C - this._liquid.y - v - F.marginTop;
2176
+ switch (b.positionV = {
2177
+ relativeFrom: T.relativeFrom,
2178
+ posOffset: _ - this._liquid.y - I
2179
+ }, T.relativeFrom) {
2180
+ case V.PAGE: {
2181
+ b.positionV.posOffset = _ - this._liquid.y - I - G.marginTop;
2146
2182
  break;
2147
2183
  }
2148
- case G.LINE: {
2149
- L.positionV.posOffset = C - this._liquid.y - v - E.top;
2184
+ case V.LINE: {
2185
+ b.positionV.posOffset = _ - this._liquid.y - I - x.top;
2150
2186
  break;
2151
2187
  }
2152
- case G.PARAGRAPH: {
2153
- L.positionV.posOffset = C - this._liquid.y - v - U.top;
2188
+ case V.PARAGRAPH: {
2189
+ b.positionV.posOffset = _ - this._liquid.y - I - W.top;
2154
2190
  break;
2155
2191
  }
2156
2192
  }
2157
- if (T == null)
2193
+ if (H == null)
2158
2194
  return;
2159
- const q = o == null ? void 0 : o.findPositionByGlyph(T, V), J = this._getDocObject();
2160
- if (q == null || o == null || J == null)
2195
+ const ce = r == null ? void 0 : r.findPositionByGlyph(H, U), fe = this._getDocObject();
2196
+ if (ce == null || r == null || fe == null)
2161
2197
  return;
2162
- const ue = {
2163
- ...q,
2164
- isBack: x
2165
- }, ce = J.document.getOffsetConfig(), pe = new Pn(ce, o), { cursorList: oe } = pe.getRangePointData(ue, ue), { startOffset: K } = (ne = En(oe)) != null ? ne : {};
2166
- if (K != null)
2167
- return { offset: K, docTransform: L };
2198
+ const Oe = {
2199
+ ...ce,
2200
+ isBack: B
2201
+ }, Be = fe.document.getOffsetConfig(), Ce = new Ot(Be, r), { cursorList: K } = Ce.getRangePointData(Oe, Oe), { startOffset: le } = (J = Tt(K)) != null ? J : {};
2202
+ if (le != null)
2203
+ return { offset: le, docTransform: b, segmentId: z, segmentPage: U };
2168
2204
  }
2169
2205
  // Update drawing when use transformer to resize it.
2170
- _updateDrawingSize(e, n) {
2171
- const t = [], { drawing: o, width: r, height: a, angle: s } = e, { unitId: l, subUnitId: c } = o;
2172
- let { width: m, height: u, angle: p } = n;
2173
- const { width: f, height: g } = this._getPageContentSize(o);
2174
- m = Math.min(f, m), u = Math.min(g, u), (m !== r || u !== a) && t.push({
2175
- drawingId: o.drawingId,
2206
+ _updateDrawingSize(e, t) {
2207
+ const n = [], { drawing: r, width: o, height: a, angle: s } = e, { unitId: l, subUnitId: c } = r;
2208
+ let { width: m, height: u, angle: f } = t;
2209
+ const { width: h, height: p } = this._getPageContentSize(r);
2210
+ m = Math.min(h, m), u = Math.min(p, u), (m !== o || u !== a) && n.push({
2211
+ drawingId: r.drawingId,
2176
2212
  key: "size",
2177
2213
  value: {
2178
2214
  width: m,
2179
2215
  height: u
2180
2216
  }
2181
- }), p !== s && t.push({
2182
- drawingId: o.drawingId,
2217
+ }), f !== s && n.push({
2218
+ drawingId: r.drawingId,
2183
2219
  key: "angle",
2184
- value: p
2185
- }), t.length > 0 && l && c && this._commandService.executeCommand(xe.id, {
2220
+ value: f
2221
+ }), n.length > 0 && l && c && this._commandService.executeCommand(ze.id, {
2186
2222
  unitId: l,
2187
2223
  subUnitId: c,
2188
- drawings: t
2224
+ drawings: n
2189
2225
  });
2190
2226
  }
2191
2227
  // Update inline drawing when use transformer to move it.
2192
- _moveInlineDrawing(e, n, t) {
2193
- const o = this._getInlineDrawingAnchor(e, n, t), { offset: r } = o != null ? o : {};
2194
- if (r != null)
2195
- return this._commandService.executeCommand(et.id, {
2228
+ _moveInlineDrawing(e, t, n) {
2229
+ const r = this._getInlineDrawingAnchor(e, t, n), { offset: o, segmentId: a, segmentPage: s } = r != null ? r : {};
2230
+ if (o != null)
2231
+ return this._commandService.executeCommand(an.id, {
2196
2232
  unitId: e.unitId,
2197
2233
  subUnitId: e.unitId,
2198
2234
  drawing: e,
2199
- offset: r
2235
+ offset: o,
2236
+ segmentId: a,
2237
+ segmentPage: s
2200
2238
  });
2201
2239
  }
2202
2240
  // Limit the drawing to the page area, mainly in the vertical direction,
2203
2241
  // and the upper and lower limits cannot exceed the page margin area.
2204
- _limitDrawingInPage(e, n) {
2205
- const t = this._renderManagerService.getRenderById(e.unitId), { left: o, top: r, width: a, height: s, angle: l } = n, c = t == null ? void 0 : t.with(me).getSkeleton(), m = c == null ? void 0 : c.getSkeletonData(), { pages: u } = m != null ? m : {};
2206
- if (m == null || t == null || u == null)
2242
+ _limitDrawingInPage(e, t) {
2243
+ const n = this._renderManagerService.getRenderById(e.unitId), { left: r, top: o, width: a, height: s, angle: l } = t, c = n == null ? void 0 : n.with(ae).getSkeleton(), m = c == null ? void 0 : c.getSkeletonData(), { pages: u } = m != null ? m : {};
2244
+ if (m == null || n == null || u == null)
2207
2245
  return {
2208
- left: o,
2209
- top: r,
2246
+ left: r,
2247
+ top: o,
2210
2248
  width: a,
2211
2249
  height: s,
2212
2250
  angle: l
2213
2251
  };
2214
- const { mainComponent: p } = t, f = p, { top: g, pageLayoutType: w, pageMarginLeft: v, pageMarginTop: I } = f;
2215
- let C = r;
2252
+ const { mainComponent: f } = n, h = f, { top: p, pageLayoutType: w, pageMarginLeft: v, pageMarginTop: I } = h;
2253
+ let D = o;
2216
2254
  this._liquid.reset();
2217
- for (const P of u) {
2218
- const { marginBottom: S, pageHeight: O } = P, R = u.indexOf(P), D = u[R + 1];
2219
- if (D == null)
2255
+ for (const _ of u) {
2256
+ const { marginBottom: C, pageHeight: O } = _, y = u.indexOf(_), T = u[y + 1];
2257
+ if (T == null)
2220
2258
  continue;
2221
- if (_e.hasIntersectionBetweenTwoRanges(
2222
- r,
2223
- r + s,
2224
- this._liquid.y + g + O - S,
2225
- this._liquid.y + g + O + I + D.marginTop
2259
+ if (Pe.hasIntersectionBetweenTwoRanges(
2260
+ o,
2261
+ o + s,
2262
+ this._liquid.y + p + O - C,
2263
+ this._liquid.y + p + O + I + T.marginTop
2226
2264
  )) {
2227
- const y = r + s / 2, T = this._liquid.y + g + O + I / 2;
2228
- y < T ? C = Math.min(r, this._liquid.y + g + O - S - s) : C = Math.max(r, this._liquid.y + g + O + I + D.marginTop);
2265
+ const R = o + s / 2, E = this._liquid.y + p + O + I / 2;
2266
+ R < E ? D = Math.min(o, this._liquid.y + p + O - C - s) : D = Math.max(o, this._liquid.y + p + O + I + T.marginTop);
2229
2267
  }
2230
- this._liquid.translatePage(P, w, v, I);
2268
+ this._liquid.translatePage(_, w, v, I);
2231
2269
  }
2232
2270
  return {
2233
- left: o,
2234
- top: C,
2271
+ left: r,
2272
+ top: D,
2235
2273
  width: a,
2236
2274
  height: s,
2237
2275
  angle: l
2238
2276
  };
2239
2277
  }
2240
- _nonInlineDrawingTransform(e, n, t = !1) {
2241
- const o = this._limitDrawingInPage(e, n);
2242
- if (t && o.top !== n.top)
2278
+ _nonInlineDrawingTransform(e, t, n = !1) {
2279
+ const r = e.isMultiTransform === oe.TRUE ? t : this._limitDrawingInPage(e, t);
2280
+ if (n && r.top !== t.top)
2243
2281
  return;
2244
- const r = this._getDrawingAnchor(e, o), { offset: a, docTransform: s } = r != null ? r : {};
2245
- return a == null || s == null ? this._updateMultipleDrawingDocTransform(/* @__PURE__ */ new Map([[e.drawingId, n]])) : this._commandService.executeCommand(nt.id, {
2282
+ const o = this._getDrawingAnchor(e, r), { offset: a, docTransform: s, segmentId: l, segmentPage: c } = o != null ? o : {};
2283
+ return a == null || s == null ? this._updateMultipleDrawingDocTransform(/* @__PURE__ */ new Map([[e.drawingId, t]])) : this._commandService.executeCommand(sn.id, {
2246
2284
  unitId: e.unitId,
2247
2285
  subUnitId: e.unitId,
2248
2286
  drawing: e,
2249
2287
  offset: a,
2250
- docTransform: s
2288
+ docTransform: s,
2289
+ segmentId: l,
2290
+ segmentPage: c
2251
2291
  });
2252
2292
  }
2253
2293
  _getSceneAndTransformerByDrawingSearch(e) {
2254
2294
  if (e == null)
2255
2295
  return;
2256
- const n = this._renderManagerService.getRenderById(e), t = n == null ? void 0 : n.scene;
2257
- if (t == null)
2296
+ const t = this._renderManagerService.getRenderById(e), n = t == null ? void 0 : t.scene;
2297
+ if (n == null)
2258
2298
  return;
2259
- const o = t.getTransformerByCreate();
2260
- return { scene: t, transformer: o };
2299
+ const r = n.getTransformerByCreate();
2300
+ return { scene: n, transformer: r };
2261
2301
  }
2262
- _getTransformCoordForDocumentOffset(e, n, t, o) {
2263
- const { documentTransform: r } = e.getOffsetConfig(), a = n.transformVector2SceneCoord(xt.FromArray([t, o]));
2302
+ _getTransformCoordForDocumentOffset(e, t, n, r) {
2303
+ const { documentTransform: o } = e.getOffsetConfig(), a = t.transformVector2SceneCoord(Gn.FromArray([n, r]));
2264
2304
  if (a)
2265
- return r.clone().invert().applyPoint(a);
2305
+ return o.clone().invert().applyPoint(a);
2266
2306
  }
2267
- _createOrUpdateInlineAnchor(e, n) {
2268
- const t = this._renderManagerService.getRenderById(e);
2269
- if (t == null)
2307
+ _createOrUpdateInlineAnchor(e, t) {
2308
+ const n = this._renderManagerService.getRenderById(e);
2309
+ if (n == null)
2270
2310
  return;
2271
- const { mainComponent: o, scene: r } = t, a = o, {
2311
+ const { mainComponent: r, scene: o } = n, a = r, {
2272
2312
  docsLeft: s,
2273
2313
  docsTop: l
2274
- } = a.getOffsetConfig(), c = Ut(n), { left: m, top: u, height: p } = c, f = m + s, g = u + l;
2314
+ } = a.getOffsetConfig(), c = Vn(t), { left: m, top: u, height: f } = c, h = m + s, p = u + l;
2275
2315
  if (this._anchorShape) {
2276
- this._anchorShape.transformByState({ left: f, top: g, height: p }), this._anchorShape.show();
2316
+ this._anchorShape.transformByState({ left: h, top: p, height: f }), this._anchorShape.show();
2277
2317
  return;
2278
2318
  }
2279
- const w = 6, v = new Lt(oo + _e.generateRandomId(w), {
2280
- left: f,
2281
- top: g,
2282
- height: p,
2319
+ const w = 6, v = new jn(dr + Pe.generateRandomId(w), {
2320
+ left: h,
2321
+ top: p,
2322
+ height: f,
2283
2323
  strokeWidth: 2,
2284
- stroke: Ft(wt.darkGray, 1),
2324
+ stroke: $n(Pn.darkGray, 1),
2285
2325
  evented: !1
2286
2326
  });
2287
- this._anchorShape = v, r.addObject(v, Bt);
2327
+ this._anchorShape = v, o.addObject(v, zn);
2288
2328
  }
2289
2329
  _getDocObject() {
2290
- return $t(this._univerInstanceService, this._renderManagerService);
2330
+ return Qn(this._univerInstanceService, this._renderManagerService);
2291
2331
  }
2292
2332
  _getPageContentSize(e) {
2293
- const n = this._renderManagerService.getRenderById(e.unitId), t = n == null ? void 0 : n.with(me).getSkeleton(), o = 500, r = 500, a = t == null ? void 0 : t.getSkeletonData();
2294
- if (a == null || n == null)
2333
+ const t = this._renderManagerService.getRenderById(e.unitId), n = t == null ? void 0 : t.with(ae).getSkeleton(), r = 500, o = 500, a = n == null ? void 0 : n.getSkeletonData();
2334
+ if (a == null || t == null)
2295
2335
  return {
2296
- width: o,
2297
- height: r
2336
+ width: r,
2337
+ height: o
2298
2338
  };
2299
2339
  const { pages: s } = a;
2300
2340
  let l = null;
@@ -2306,69 +2346,70 @@ let Ye = class extends Ue {
2306
2346
  }
2307
2347
  }
2308
2348
  if (l) {
2309
- const { pageWidth: c, pageHeight: m, marginLeft: u, marginBottom: p, marginRight: f, marginTop: g } = l;
2349
+ const { pageWidth: c, pageHeight: m, marginLeft: u, marginBottom: f, marginRight: h, marginTop: p } = l;
2310
2350
  return {
2311
- width: Math.max(o, c - u - f),
2312
- height: Math.max(r, m - g - p)
2351
+ width: Math.max(r, c - u - h),
2352
+ height: Math.max(o, m - p - f)
2313
2353
  };
2314
2354
  } else
2315
2355
  return {
2316
- width: o,
2317
- height: r
2356
+ width: r,
2357
+ height: o
2318
2358
  };
2319
2359
  }
2320
2360
  };
2321
- Ye = io([
2322
- nn(tn.Rendered, Ye),
2323
- ze(0, W),
2324
- ze(1, X),
2325
- ze(2, ge),
2326
- ze(3, Q)
2327
- ], Ye);
2328
- var ct = Object.defineProperty, ro = Object.getOwnPropertyDescriptor, ao = (i, e, n) => e in i ? ct(i, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : i[e] = n, so = (i, e, n, t) => {
2329
- for (var o = t > 1 ? void 0 : t ? ro(e, n) : e, r = i.length - 1, a; r >= 0; r--)
2330
- (a = i[r]) && (o = (t ? a(e, n, o) : a(o)) || o);
2331
- return t && o && ct(e, n, o), o;
2332
- }, An = (i, e) => (n, t) => e(n, t, i), lt = (i, e, n) => ao(i, typeof e != "symbol" ? e + "" : e, n);
2333
- const co = "DOCS_DRAWING_UI_PLUGIN";
2334
- let Qe = class extends vt {
2335
- constructor(i, e, n) {
2336
- super(), this._injector = e, this._renderManagerSrv = n;
2361
+ nt = lr([
2362
+ at(st.Rendered, nt),
2363
+ Ve(0, $),
2364
+ Ve(1, te),
2365
+ Ve(2, he),
2366
+ Ve(3, se),
2367
+ Ve(4, Ue)
2368
+ ], nt);
2369
+ var un = Object.defineProperty, mr = Object.getOwnPropertyDescriptor, gr = (i, e, t) => e in i ? un(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t, ur = (i, e, t, n) => {
2370
+ for (var r = n > 1 ? void 0 : n ? mr(e, t) : e, o = i.length - 1, a; o >= 0; o--)
2371
+ (a = i[o]) && (r = (n ? a(e, t, r) : a(r)) || r);
2372
+ return n && r && un(e, t, r), r;
2373
+ }, Ut = (i, e) => (t, n) => e(t, n, i), fn = (i, e, t) => gr(i, typeof e != "symbol" ? e + "" : e, t);
2374
+ const fr = "DOCS_DRAWING_UI_PLUGIN";
2375
+ let rt = class extends On {
2376
+ constructor(i, e, t) {
2377
+ super(), this._injector = e, this._renderManagerSrv = t;
2337
2378
  }
2338
2379
  onStarting(i) {
2339
2380
  [
2340
- [qe],
2341
- [Xe],
2342
- [Ye],
2343
- [Ke]
2344
- ].forEach((n) => i.add(n));
2381
+ [et],
2382
+ [Je],
2383
+ [nt],
2384
+ [tt],
2385
+ [ct]
2386
+ ].forEach((t) => i.add(t));
2345
2387
  }
2346
2388
  onReady() {
2347
2389
  [
2348
- [ln],
2349
- [dn]
2350
- ].forEach((i) => this._renderManagerSrv.registerRenderModule(Ce.UNIVER_DOC, i));
2390
+ [ut],
2391
+ [ft]
2392
+ ].forEach((i) => this._renderManagerSrv.registerRenderModule(be.UNIVER_DOC, i));
2351
2393
  }
2352
2394
  };
2353
- lt(Qe, "type", Ce.UNIVER_DOC);
2354
- lt(Qe, "pluginName", co);
2355
- Qe = so([
2356
- It(Et, bt, Rt),
2357
- An(1, Se(Un)),
2358
- An(2, Q)
2359
- ], Qe);
2395
+ fn(rt, "type", be.UNIVER_DOC);
2396
+ fn(rt, "pluginName", fr);
2397
+ rt = ur([
2398
+ Tn(An, Hn, Wn),
2399
+ Ut(1, pe(kt)),
2400
+ Ut(2, se)
2401
+ ], rt);
2360
2402
  export {
2361
- Oe as ClearDocDrawingTransformerOperation,
2362
- tt as DeleteDocDrawingsCommand,
2363
- kn as EditDocDrawingOperation,
2364
- at as GroupDocDrawingCommand,
2365
- st as InsertDocDrawingCommand,
2366
- rn as InsertDocImageOperation,
2367
- Fe as MoveDocDrawingsCommand,
2368
- pn as RemoveDocDrawingCommand,
2369
- it as SetDocDrawingArrangeCommand,
2370
- ot as SetDocDrawingCommand,
2371
- jn as SidebarDocDrawingOperation,
2372
- rt as UngroupDocDrawingCommand,
2373
- Qe as UniverDocsDrawingUIPlugin
2403
+ Wi as ClearDocDrawingTransformerOperation,
2404
+ cn as DeleteDocDrawingsCommand,
2405
+ Xt as EditDocDrawingOperation,
2406
+ mn as GroupDocDrawingCommand,
2407
+ gn as InsertDocDrawingCommand,
2408
+ vt as InsertDocImageOperation,
2409
+ Xe as MoveDocDrawingsCommand,
2410
+ wt as RemoveDocDrawingCommand,
2411
+ ln as SetDocDrawingArrangeCommand,
2412
+ qt as SidebarDocDrawingOperation,
2413
+ dn as UngroupDocDrawingCommand,
2414
+ rt as UniverDocsDrawingUIPlugin
2374
2415
  };