@univerjs/drawing-ui 0.2.4 → 0.2.6

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,752 +1,760 @@
1
- var Mt = Object.defineProperty;
2
- var Ot = (a, n, e) => n in a ? Mt(a, n, { enumerable: !0, configurable: !0, writable: !0, value: e }) : a[n] = e;
3
- var te = (a, n, e) => Ot(a, typeof n != "symbol" ? n + "" : n, e);
4
- import { getDrawingShapeKeyByDrawingSearch as G, DrawingTypeEnum as re, ImageSourceType as Nt, IDrawingManagerService as ae, IImageIoService as ot, ArrangeTypeEnum as Pe } from "@univerjs/drawing";
5
- import { Group as ve, DRAWING_OBJECT_LAYER_INDEX as Ye, Image as Fe, IRenderManagerService as he, getGroupState as Dt, transformObjectOutOfGroup as Tt, RENDER_CLASS_TYPE as Qe, Shape as Bt, Rect as jt, Canvas as Ut, precisionTo as ye, CURSOR_TYPE as Ue, Vector2 as ke, degToRad as et } from "@univerjs/engine-render";
6
- import { UniverInstanceType as Ne, LocaleService as Y, debounce as Ee, CommandType as Se, ICommandService as ue, Tools as Ht, Disposable as Ae, checkIfMove as st, toDisposable as _e, OnLifecycle as xe, LifecycleStages as Ve, IUniverInstanceService as Xe, Plugin as Lt } from "@univerjs/core";
7
- import { useDependency as V } from "@wendellhu/redi/react-bindings";
8
- import c, { forwardRef as X, useRef as ct, createElement as J, useState as L, useEffect as be } from "react";
9
- import { Button as le, InputNumber as pe, Checkbox as At, Select as lt, Dropdown as xt, MessageType as tt } from "@univerjs/design";
10
- import O from "clsx";
11
- import { Inject as ge, Injector as mt } from "@wendellhu/redi";
12
- import { ComponentManager as Vt, IMenuService as Gt, IMessageService as Wt, IDialogService as $t } from "@univerjs/ui";
13
- import { filter as kt, switchMap as zt } from "rxjs";
14
- function Ft(a, n, e, t) {
15
- const r = t.getDrawingByParam(a);
16
- if (r == null)
1
+ var __defProp = Object.defineProperty;
2
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value;
3
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: !0 });
4
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key != "symbol" ? key + "" : key, value);
5
+ import { getDrawingShapeKeyByDrawingSearch, DrawingTypeEnum, ImageSourceType, IDrawingManagerService, IImageIoService, ArrangeTypeEnum } from "@univerjs/drawing";
6
+ import { Group, DRAWING_OBJECT_LAYER_INDEX, Image, IRenderManagerService, getGroupState, transformObjectOutOfGroup, RENDER_CLASS_TYPE, Shape, Rect, Canvas, precisionTo, CURSOR_TYPE, Vector2, degToRad } from "@univerjs/engine-render";
7
+ import { UniverInstanceType, useDependency, LocaleService, debounce, CommandType, ICommandService, Tools, Disposable, checkIfMove, toDisposable, OnLifecycle, LifecycleStages, IUniverInstanceService, Inject, Injector, Plugin } from "@univerjs/core";
8
+ import React, { forwardRef, useRef, createElement, useState, useEffect } from "react";
9
+ import { Button, InputNumber, Checkbox, Select, Dropdown, MessageType } from "@univerjs/design";
10
+ import clsx from "clsx";
11
+ import { ComponentManager, IMenuService, IMessageService, IDialogService } from "@univerjs/ui";
12
+ import { filter, switchMap } from "rxjs";
13
+ function insertGroupObject(objectParam, object, scene, drawingManagerService) {
14
+ const groupParam = drawingManagerService.getDrawingByParam(objectParam);
15
+ if (groupParam == null)
17
16
  return;
18
- const o = G(a), i = e.getObject(o);
19
- if (i && !(i instanceof ve))
17
+ const groupKey = getDrawingShapeKeyByDrawingSearch(objectParam), groupObject = scene.getObject(groupKey);
18
+ if (groupObject && !(groupObject instanceof Group))
20
19
  return;
21
- if (i != null) {
22
- i.addObject(n);
20
+ if (groupObject != null) {
21
+ groupObject.addObject(object);
23
22
  return;
24
23
  }
25
- const s = new ve(o);
26
- e.addObject(s, Ye).attachTransformerTo(s), s.addObject(n);
27
- const { transform: l } = r;
28
- l && s.transformByState(
24
+ const group = new Group(groupKey);
25
+ scene.addObject(group, DRAWING_OBJECT_LAYER_INDEX).attachTransformerTo(group), group.addObject(object);
26
+ const { transform } = groupParam;
27
+ transform && group.transformByState(
29
28
  {
30
- left: l.left,
31
- top: l.top,
32
- angle: l.angle
29
+ left: transform.left,
30
+ top: transform.top,
31
+ angle: transform.angle
33
32
  }
34
33
  );
35
34
  }
36
- function Ke(a) {
37
- var r;
38
- const n = a.getFocusedUnit();
39
- if (n == null)
35
+ __name(insertGroupObject, "insertGroupObject");
36
+ function getCurrentUnitInfo(currentUniverService) {
37
+ var _a7;
38
+ const current = currentUniverService.getFocusedUnit();
39
+ if (current == null)
40
40
  return;
41
- const e = n.getUnitId();
42
- let t;
43
- return n.type === Ne.UNIVER_SHEET ? t = (r = n.getActiveSheet()) == null ? void 0 : r.getSheetId() : (n.type === Ne.UNIVER_DOC || n.type === Ne.UNIVER_SLIDE) && (t = e), { unitId: e, subUnitId: t };
41
+ const unitId = current.getUnitId();
42
+ let subUnitId;
43
+ return current.type === UniverInstanceType.UNIVER_SHEET ? subUnitId = (_a7 = current.getActiveSheet()) == null ? void 0 : _a7.getSheetId() : (current.type === UniverInstanceType.UNIVER_DOC || current.type === UniverInstanceType.UNIVER_SLIDE) && (subUnitId = unitId), { unitId, subUnitId };
44
44
  }
45
- var Kt = Object.defineProperty, Zt = Object.getOwnPropertyDescriptor, Yt = (a, n, e, t) => {
46
- for (var r = t > 1 ? void 0 : t ? Zt(n, e) : n, o = a.length - 1, i; o >= 0; o--)
47
- (i = a[o]) && (r = (t ? i(n, e, r) : i(r)) || r);
48
- return t && r && Kt(n, e, r), r;
49
- }, nt = (a, n) => (e, t) => n(e, t, a);
50
- let He = class {
51
- constructor(a, n) {
52
- this._drawingManagerService = a, this._imageIoService = n;
45
+ __name(getCurrentUnitInfo, "getCurrentUnitInfo");
46
+ var __defProp$5 = Object.defineProperty, __getOwnPropDesc$5 = Object.getOwnPropertyDescriptor, __decorateClass$5 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
47
+ for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$5(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
48
+ (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
49
+ return kind && result && __defProp$5(target, key, result), result;
50
+ }, "__decorateClass$5"), __decorateParam$5 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$5"), _a;
51
+ let DrawingRenderService = (_a = class {
52
+ constructor(_drawingManagerService, _imageIoService) {
53
+ this._drawingManagerService = _drawingManagerService, this._imageIoService = _imageIoService;
53
54
  }
54
55
  // eslint-disable-next-line max-lines-per-function
55
- async renderImages(a, n) {
56
+ async renderImages(imageParam, scene) {
56
57
  const {
57
- transform: e,
58
- drawingType: t,
59
- source: r,
60
- imageSourceType: o,
61
- srcRect: i,
62
- prstGeom: s,
63
- groupId: l,
64
- unitId: m,
65
- subUnitId: u,
66
- drawingId: d,
67
- isMultiTransform: h,
68
- transforms: f
69
- } = a;
70
- if (t !== re.DRAWING_IMAGE || !this._drawingManagerService.getDrawingVisible() || e == null)
58
+ transform: singleTransform,
59
+ drawingType,
60
+ source,
61
+ imageSourceType,
62
+ srcRect,
63
+ prstGeom,
64
+ groupId,
65
+ unitId,
66
+ subUnitId,
67
+ drawingId,
68
+ isMultiTransform,
69
+ transforms: multiTransforms
70
+ } = imageParam;
71
+ if (drawingType !== DrawingTypeEnum.DRAWING_IMAGE || !this._drawingManagerService.getDrawingVisible() || singleTransform == null)
71
72
  return;
72
- const v = h && f ? f : [e], w = [];
73
- for (const p of v) {
74
- const { left: S, top: _, width: R, height: b, angle: N, flipX: I, flipY: y, skewX: P, skewY: M } = p, D = v.indexOf(p), U = G({ unitId: m, subUnitId: u, drawingId: d }, h ? D : void 0), T = n.getObject(U);
75
- if (T != null) {
76
- T.transformByState({ left: S, top: _, width: R, height: b, angle: N, flipX: I, flipY: y, skewX: P, skewY: M });
73
+ const transforms = isMultiTransform && multiTransforms ? multiTransforms : [singleTransform], images = [];
74
+ for (const transform of transforms) {
75
+ const { left, top, width, height, angle, flipX, flipY, skewX, skewY } = transform, index = transforms.indexOf(transform), imageShapeKey = getDrawingShapeKeyByDrawingSearch({ unitId, subUnitId, drawingId }, isMultiTransform ? index : void 0), imageShape = scene.getObject(imageShapeKey);
76
+ if (imageShape != null) {
77
+ imageShape.transformByState({ left, top, width, height, angle, flipX, flipY, skewX, skewY });
77
78
  continue;
78
79
  }
79
- const ie = this._drawingManagerService.getDrawingOrder(m, u), W = ie.indexOf(d), Q = { ...p, zIndex: W === -1 ? ie.length - 1 : W }, Ie = this._imageIoService.getImageSourceCache(r, o);
80
- let oe = !1;
81
- if (Ie != null)
82
- Q.image = Ie;
80
+ const orders = this._drawingManagerService.getDrawingOrder(unitId, subUnitId), zIndex = orders.indexOf(drawingId), imageConfig = { ...transform, zIndex: zIndex === -1 ? orders.length - 1 : zIndex }, imageNativeCache = this._imageIoService.getImageSourceCache(source, imageSourceType);
81
+ let shouldBeCache = !1;
82
+ if (imageNativeCache != null)
83
+ imageConfig.image = imageNativeCache;
83
84
  else {
84
- if (o === Nt.UUID)
85
+ if (imageSourceType === ImageSourceType.UUID)
85
86
  try {
86
- Q.url = await this._imageIoService.getImage(r);
87
- } catch ($e) {
88
- console.error($e);
87
+ imageConfig.url = await this._imageIoService.getImage(source);
88
+ } catch (error) {
89
+ console.error(error);
89
90
  continue;
90
91
  }
91
92
  else
92
- Q.url = r;
93
- oe = !0;
93
+ imageConfig.url = source;
94
+ shouldBeCache = !0;
94
95
  }
95
- Q.printable = !0;
96
- const F = new Fe(U, Q);
97
- if (oe && this._imageIoService.addImageSourceCache(r, o, F.getNative()), !this._drawingManagerService.getDrawingVisible())
96
+ imageConfig.printable = !0;
97
+ const image = new Image(imageShapeKey, imageConfig);
98
+ if (shouldBeCache && this._imageIoService.addImageSourceCache(source, imageSourceType, image.getNative()), !this._drawingManagerService.getDrawingVisible())
98
99
  continue;
99
- const We = n.addObject(F, Ye);
100
- this._drawingManagerService.getDrawingEditable() && We.attachTransformerTo(F), l && Ft({ drawingId: l, unitId: m, subUnitId: u }, F, n, this._drawingManagerService), s != null && F.setPrstGeom(s), i != null && F.setSrcRect(i), w.push(F);
100
+ const imageObject = scene.addObject(image, DRAWING_OBJECT_LAYER_INDEX);
101
+ this._drawingManagerService.getDrawingEditable() && imageObject.attachTransformerTo(image), groupId && insertGroupObject({ drawingId: groupId, unitId, subUnitId }, image, scene, this._drawingManagerService), prstGeom != null && image.setPrstGeom(prstGeom), srcRect != null && image.setSrcRect(srcRect), images.push(image);
101
102
  }
102
- return w;
103
- }
104
- renderDrawing(a, n) {
105
- const e = this._drawingManagerService.getDrawingByParam(a);
106
- if (e != null)
107
- switch (e.drawingType) {
108
- case re.DRAWING_IMAGE:
109
- return this.renderImages(e, n);
103
+ return images;
104
+ }
105
+ renderDrawing(param, scene) {
106
+ const drawingParam = this._drawingManagerService.getDrawingByParam(param);
107
+ if (drawingParam != null)
108
+ switch (drawingParam.drawingType) {
109
+ case DrawingTypeEnum.DRAWING_IMAGE:
110
+ return this.renderImages(drawingParam, scene);
110
111
  }
111
112
  }
112
- };
113
- He = Yt([
114
- nt(0, ae),
115
- nt(1, ot)
116
- ], He);
117
- function Ge(a, n) {
118
- const e = [];
119
- return a.forEach((t) => {
120
- const { oKey: r, left: o, top: i, height: s, width: l, angle: m } = t, u = n.getDrawingOKey(r);
121
- if (u == null)
122
- return e.push(null), !0;
123
- const { unitId: d, subUnitId: h, drawingId: f, drawingType: v } = u, w = {
124
- unitId: d,
125
- subUnitId: h,
126
- drawingId: f,
127
- drawingType: v,
113
+ }, __name(_a, "DrawingRenderService"), _a);
114
+ DrawingRenderService = __decorateClass$5([
115
+ __decorateParam$5(0, IDrawingManagerService),
116
+ __decorateParam$5(1, IImageIoService)
117
+ ], DrawingRenderService);
118
+ function getUpdateParams(objects, drawingManagerService) {
119
+ const params = [];
120
+ return objects.forEach((object) => {
121
+ const { oKey, left, top, height, width, angle } = object, searchParam = drawingManagerService.getDrawingOKey(oKey);
122
+ if (searchParam == null)
123
+ return params.push(null), !0;
124
+ const { unitId, subUnitId, drawingId, drawingType } = searchParam, param = {
125
+ unitId,
126
+ subUnitId,
127
+ drawingId,
128
+ drawingType,
128
129
  transform: {
129
- left: o,
130
- top: i,
131
- height: s,
132
- width: l,
133
- angle: m
130
+ left,
131
+ top,
132
+ height,
133
+ width,
134
+ angle
134
135
  }
135
136
  };
136
- v === re.DRAWING_IMAGE && (w.srcRect = t.srcRect), e.push(w);
137
- }), e;
137
+ drawingType === DrawingTypeEnum.DRAWING_IMAGE && (param.srcRect = object.srcRect), params.push(param);
138
+ }), params;
138
139
  }
139
- var $ = function() {
140
- return $ = Object.assign || function(a) {
141
- for (var n, e = 1, t = arguments.length; e < t; e++) {
142
- n = arguments[e];
143
- for (var r in n) Object.prototype.hasOwnProperty.call(n, r) && (a[r] = n[r]);
140
+ __name(getUpdateParams, "getUpdateParams");
141
+ var __assign = function() {
142
+ return __assign = Object.assign || function(t) {
143
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
144
+ s = arguments[i];
145
+ for (var p in s) Object.prototype.hasOwnProperty.call(s, p) && (t[p] = s[p]);
144
146
  }
145
- return a;
146
- }, $.apply(this, arguments);
147
- }, Xt = function(a, n) {
148
- var e = {};
149
- for (var t in a) Object.prototype.hasOwnProperty.call(a, t) && n.indexOf(t) < 0 && (e[t] = a[t]);
150
- if (a != null && typeof Object.getOwnPropertySymbols == "function")
151
- for (var r = 0, t = Object.getOwnPropertySymbols(a); r < t.length; r++)
152
- n.indexOf(t[r]) < 0 && Object.prototype.propertyIsEnumerable.call(a, t[r]) && (e[t[r]] = a[t[r]]);
153
- return e;
154
- }, q = X(function(a, n) {
155
- var e = a.icon, t = a.id, r = a.className, o = a.extend, i = Xt(a, ["icon", "id", "className", "extend"]), s = "univerjs-icon univerjs-icon-".concat(t, " ").concat(r || "").trim(), l = ct("_".concat(Qt()));
156
- return gt(e, "".concat(t), { defIds: e.defIds, idSuffix: l.current }, $({ ref: n, className: s }, i), o);
147
+ return t;
148
+ }, __assign.apply(this, arguments);
149
+ }, __rest = function(s, e) {
150
+ var t = {};
151
+ for (var p in s) Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0 && (t[p] = s[p]);
152
+ if (s != null && typeof Object.getOwnPropertySymbols == "function")
153
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++)
154
+ e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]) && (t[p[i]] = s[p[i]]);
155
+ return t;
156
+ }, IconBase = forwardRef(function(props, ref) {
157
+ var icon = props.icon, id = props.id, className = props.className, extend = props.extend, restProps = __rest(props, ["icon", "id", "className", "extend"]), cls = "univerjs-icon univerjs-icon-".concat(id, " ").concat(className || "").trim(), idSuffix = useRef("_".concat(generateShortUuid()));
158
+ return render(icon, "".concat(id), { defIds: icon.defIds, idSuffix: idSuffix.current }, __assign({ ref, className: cls }, restProps), extend);
157
159
  });
158
- function gt(a, n, e, t, r) {
159
- return J(a.tag, $($({ key: n }, Jt(a, e, r)), t), (qt(a, e).children || []).map(function(o, i) {
160
- return gt(o, "".concat(n, "-").concat(a.tag, "-").concat(i), e, void 0, r);
160
+ function render(node, id, runtimeProps, rootProps, extend) {
161
+ return createElement(node.tag, __assign(__assign({ key: id }, replaceRuntimeIdsAndExtInAttrs(node, runtimeProps, extend)), rootProps), (replaceRuntimeIdsInDefs(node, runtimeProps).children || []).map(function(child, index) {
162
+ return render(child, "".concat(id, "-").concat(node.tag, "-").concat(index), runtimeProps, void 0, extend);
161
163
  }));
162
164
  }
163
- function Jt(a, n, e) {
164
- var t = $({}, a.attrs);
165
- e != null && e.colorChannel1 && t.fill === "colorChannel1" && (t.fill = e.colorChannel1);
166
- var r = n.defIds;
167
- return !r || r.length === 0 || (a.tag === "use" && t["xlink:href"] && (t["xlink:href"] = t["xlink:href"] + n.idSuffix), Object.entries(t).forEach(function(o) {
168
- var i = o[0], s = o[1];
169
- typeof s == "string" && (t[i] = s.replace(/url\(#(.*)\)/, "url(#$1".concat(n.idSuffix, ")")));
170
- })), t;
165
+ __name(render, "render");
166
+ function replaceRuntimeIdsAndExtInAttrs(node, runtimeProps, extend) {
167
+ var attrs = __assign({}, node.attrs);
168
+ extend != null && extend.colorChannel1 && attrs.fill === "colorChannel1" && (attrs.fill = extend.colorChannel1);
169
+ var defIds = runtimeProps.defIds;
170
+ return !defIds || defIds.length === 0 || (node.tag === "use" && attrs["xlink:href"] && (attrs["xlink:href"] = attrs["xlink:href"] + runtimeProps.idSuffix), Object.entries(attrs).forEach(function(_a7) {
171
+ var key = _a7[0], value = _a7[1];
172
+ typeof value == "string" && (attrs[key] = value.replace(/url\(#(.*)\)/, "url(#$1".concat(runtimeProps.idSuffix, ")")));
173
+ })), attrs;
171
174
  }
172
- function qt(a, n) {
173
- var e, t = n.defIds;
174
- return !t || t.length === 0 ? a : a.tag === "defs" && (!((e = a.children) === null || e === void 0) && e.length) ? $($({}, a), { children: a.children.map(function(r) {
175
- return typeof r.attrs.id == "string" && t && t.indexOf(r.attrs.id) > -1 ? $($({}, r), { attrs: $($({}, r.attrs), { id: r.attrs.id + n.idSuffix }) }) : r;
176
- }) }) : a;
175
+ __name(replaceRuntimeIdsAndExtInAttrs, "replaceRuntimeIdsAndExtInAttrs");
176
+ function replaceRuntimeIdsInDefs(node, runtimeProps) {
177
+ var _a7, defIds = runtimeProps.defIds;
178
+ return !defIds || defIds.length === 0 ? node : node.tag === "defs" && (!((_a7 = node.children) === null || _a7 === void 0) && _a7.length) ? __assign(__assign({}, node), { children: node.children.map(function(child) {
179
+ return typeof child.attrs.id == "string" && defIds && defIds.indexOf(child.attrs.id) > -1 ? __assign(__assign({}, child), { attrs: __assign(__assign({}, child.attrs), { id: child.attrs.id + runtimeProps.idSuffix }) }) : child;
180
+ }) }) : node;
177
181
  }
178
- function Qt() {
182
+ __name(replaceRuntimeIdsInDefs, "replaceRuntimeIdsInDefs");
183
+ function generateShortUuid() {
179
184
  return Math.random().toString(36).substring(2, 8);
180
185
  }
181
- q.displayName = "UniverIcon";
182
- var en = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "colorChannel1", d: "M11.0363 12.2367V14.0367C11.0363 14.3681 11.3049 14.6367 11.6363 14.6367C11.9676 14.6367 12.2363 14.3681 12.2363 14.0367V12.2367H14.0364C14.3677 12.2367 14.6364 11.9681 14.6364 11.6367C14.6364 11.3054 14.3677 11.0367 14.0364 11.0367H12.2363V9.23672C12.2363 8.90535 11.9676 8.63672 11.6363 8.63672C11.3049 8.63672 11.0363 8.90535 11.0363 9.23672V11.0367H9.23635C8.90498 11.0367 8.63635 11.3054 8.63635 11.6367C8.63635 11.9681 8.90498 12.2367 9.23635 12.2367H11.0363Z" } }, { tag: "path", attrs: { fill: "currentColor", d: "M2.56365 1.36377C1.90091 1.36377 1.36365 1.90103 1.36365 2.56377V6.16377C1.36365 6.82651 1.90091 7.36377 2.56365 7.36377H6.16365C6.82639 7.36377 7.36365 6.82651 7.36365 6.16377V2.56377C7.36365 1.90103 6.82639 1.36377 6.16365 1.36377H2.56365zM6.16365 2.56377H2.56365L2.56365 6.16377H6.16365V2.56377zM2.56365 8.63647C1.90091 8.63647 1.36365 9.17373 1.36365 9.83647V13.4365C1.36365 14.0992 1.90091 14.6365 2.56365 14.6365H6.16365C6.82639 14.6365 7.36365 14.0992 7.36365 13.4365V9.83647C7.36365 9.17373 6.82639 8.63647 6.16365 8.63647H2.56365zM6.16365 9.83647H2.56365L2.56365 13.4365H6.16365V9.83647zM9.83635 7.36377C9.17361 7.36377 8.63635 6.82651 8.63635 6.16377V2.56377C8.63635 1.90103 9.17361 1.36377 9.83635 1.36377H13.4364C14.0991 1.36377 14.6364 1.90103 14.6364 2.56377V6.16377C14.6364 6.82651 14.0991 7.36377 13.4364 7.36377H9.83635zM9.83635 6.16377V2.56377L13.4364 2.56377V6.16377H9.83635z", fillRule: "evenodd", clipRule: "evenodd" } }] }, ut = X(function(a, n) {
183
- return J(q, Object.assign({}, a, {
186
+ __name(generateShortUuid, "generateShortUuid");
187
+ IconBase.displayName = "UniverIcon";
188
+ var element$8 = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "colorChannel1", d: "M11.0363 12.2367V14.0367C11.0363 14.3681 11.3049 14.6367 11.6363 14.6367C11.9676 14.6367 12.2363 14.3681 12.2363 14.0367V12.2367H14.0364C14.3677 12.2367 14.6364 11.9681 14.6364 11.6367C14.6364 11.3054 14.3677 11.0367 14.0364 11.0367H12.2363V9.23672C12.2363 8.90535 11.9676 8.63672 11.6363 8.63672C11.3049 8.63672 11.0363 8.90535 11.0363 9.23672V11.0367H9.23635C8.90498 11.0367 8.63635 11.3054 8.63635 11.6367C8.63635 11.9681 8.90498 12.2367 9.23635 12.2367H11.0363Z" } }, { tag: "path", attrs: { fill: "currentColor", d: "M2.56365 1.36377C1.90091 1.36377 1.36365 1.90103 1.36365 2.56377V6.16377C1.36365 6.82651 1.90091 7.36377 2.56365 7.36377H6.16365C6.82639 7.36377 7.36365 6.82651 7.36365 6.16377V2.56377C7.36365 1.90103 6.82639 1.36377 6.16365 1.36377H2.56365zM6.16365 2.56377H2.56365L2.56365 6.16377H6.16365V2.56377zM2.56365 8.63647C1.90091 8.63647 1.36365 9.17373 1.36365 9.83647V13.4365C1.36365 14.0992 1.90091 14.6365 2.56365 14.6365H6.16365C6.82639 14.6365 7.36365 14.0992 7.36365 13.4365V9.83647C7.36365 9.17373 6.82639 8.63647 6.16365 8.63647H2.56365zM6.16365 9.83647H2.56365L2.56365 13.4365H6.16365V9.83647zM9.83635 7.36377C9.17361 7.36377 8.63635 6.82651 8.63635 6.16377V2.56377C8.63635 1.90103 9.17361 1.36377 9.83635 1.36377H13.4364C14.0991 1.36377 14.6364 1.90103 14.6364 2.56377V6.16377C14.6364 6.82651 14.0991 7.36377 13.4364 7.36377H9.83635zM9.83635 6.16377V2.56377L13.4364 2.56377V6.16377H9.83635z", fillRule: "evenodd", clipRule: "evenodd" } }] }, Autofill = forwardRef(function(props, ref) {
189
+ return createElement(IconBase, Object.assign({}, props, {
184
190
  id: "autofill",
185
- ref: n,
186
- icon: en
191
+ ref,
192
+ icon: element$8
187
193
  }));
188
194
  });
189
- ut.displayName = "Autofill";
190
- var tn = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 17 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M14.0045 4.4334C14.8881 4.4334 15.6045 3.71705 15.6045 2.8334 15.6045 1.94974 14.8881 1.2334 14.0045 1.2334H3.70449C2.82084 1.2334 2.10449 1.94974 2.10449 2.8334 2.10449 3.71705 2.82084 4.4334 3.70449 4.4334H14.0045zM14.4045 2.8334C14.4045 3.05431 14.2254 3.2334 14.0045 3.2334H3.70449C3.48358 3.2334 3.30449 3.05431 3.30449 2.8334 3.30449 2.61248 3.48358 2.4334 3.70449 2.4334H14.0045C14.2254 2.4334 14.4045 2.61249 14.4045 2.8334zM14.1544 8.5999C15.038 8.5999 15.7544 7.88356 15.7544 6.9999 15.7544 6.11625 15.038 5.3999 14.1544 5.3999H3.85439C2.97074 5.3999 2.25439 6.11625 2.25439 6.9999 2.25439 7.88356 2.97074 8.5999 3.85439 8.5999H14.1544zM14.5544 6.9999C14.5544 7.22082 14.3753 7.3999 14.1544 7.3999H3.85439C3.63348 7.3999 3.45439 7.22082 3.45439 6.9999 3.45439 6.77899 3.63348 6.5999 3.85439 6.5999H14.1544C14.3753 6.5999 14.5544 6.77899 14.5544 6.9999z", fillRule: "evenodd", clipRule: "evenodd" } }, { tag: "path", attrs: { fill: "currentColor", d: "M8.57975 14.5902L6.58023 12.5907C6.34591 12.3564 6.34591 11.9765 6.58023 11.7421 6.81454 11.5078 7.19444 11.5078 7.42876 11.7421L8.40449 12.7179V10.1664C8.40449 9.83504 8.67312 9.56641 9.00449 9.56641 9.33586 9.56641 9.60449 9.83504 9.60449 10.1664V12.7179L10.5802 11.7421C10.8145 11.5078 11.1944 11.5078 11.4288 11.7421 11.6631 11.9765 11.6631 12.3564 11.4288 12.5907L9.42923 14.5902M8.57975 14.5902C8.58121 14.5917 8.58268 14.5931 8.58416 14.5946 8.64077 14.6502 8.70566 14.6923 8.77482 14.7209 8.84557 14.7502 8.92314 14.7664 9.00449 14.7664 9.08585 14.7664 9.16342 14.7502 9.23416 14.7209 9.30332 14.6923 9.36821 14.6502 9.42482 14.5946" } }] }, dt = X(function(a, n) {
191
- return J(q, Object.assign({}, a, {
195
+ Autofill.displayName = "Autofill";
196
+ var element$7 = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 17 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M14.0045 4.4334C14.8881 4.4334 15.6045 3.71705 15.6045 2.8334 15.6045 1.94974 14.8881 1.2334 14.0045 1.2334H3.70449C2.82084 1.2334 2.10449 1.94974 2.10449 2.8334 2.10449 3.71705 2.82084 4.4334 3.70449 4.4334H14.0045zM14.4045 2.8334C14.4045 3.05431 14.2254 3.2334 14.0045 3.2334H3.70449C3.48358 3.2334 3.30449 3.05431 3.30449 2.8334 3.30449 2.61248 3.48358 2.4334 3.70449 2.4334H14.0045C14.2254 2.4334 14.4045 2.61249 14.4045 2.8334zM14.1544 8.5999C15.038 8.5999 15.7544 7.88356 15.7544 6.9999 15.7544 6.11625 15.038 5.3999 14.1544 5.3999H3.85439C2.97074 5.3999 2.25439 6.11625 2.25439 6.9999 2.25439 7.88356 2.97074 8.5999 3.85439 8.5999H14.1544zM14.5544 6.9999C14.5544 7.22082 14.3753 7.3999 14.1544 7.3999H3.85439C3.63348 7.3999 3.45439 7.22082 3.45439 6.9999 3.45439 6.77899 3.63348 6.5999 3.85439 6.5999H14.1544C14.3753 6.5999 14.5544 6.77899 14.5544 6.9999z", fillRule: "evenodd", clipRule: "evenodd" } }, { tag: "path", attrs: { fill: "currentColor", d: "M8.57975 14.5902L6.58023 12.5907C6.34591 12.3564 6.34591 11.9765 6.58023 11.7421 6.81454 11.5078 7.19444 11.5078 7.42876 11.7421L8.40449 12.7179V10.1664C8.40449 9.83504 8.67312 9.56641 9.00449 9.56641 9.33586 9.56641 9.60449 9.83504 9.60449 10.1664V12.7179L10.5802 11.7421C10.8145 11.5078 11.1944 11.5078 11.4288 11.7421 11.6631 11.9765 11.6631 12.3564 11.4288 12.5907L9.42923 14.5902M8.57975 14.5902C8.58121 14.5917 8.58268 14.5931 8.58416 14.5946 8.64077 14.6502 8.70566 14.6923 8.77482 14.7209 8.84557 14.7502 8.92314 14.7664 9.00449 14.7664 9.08585 14.7664 9.16342 14.7502 9.23416 14.7209 9.30332 14.6923 9.36821 14.6502 9.42482 14.5946" } }] }, BottomSingle = forwardRef(function(props, ref) {
197
+ return createElement(IconBase, Object.assign({}, props, {
192
198
  id: "bottom-single",
193
- ref: n,
194
- icon: tn
199
+ ref,
200
+ icon: element$7
195
201
  }));
196
202
  });
197
- dt.displayName = "BottomSingle";
198
- var nn = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M5.97705 7.51296C5.97705 7.18159 6.24568 6.91296 6.57705 6.91296H8.48632C8.81769 6.91296 9.08632 7.18159 9.08632 7.51296 9.08632 7.84433 8.81769 8.11296 8.48632 8.11296H6.57705C6.24568 8.11296 5.97705 7.84433 5.97705 7.51296zM6.57705 9.41028C6.24568 9.41028 5.97705 9.67891 5.97705 10.0103 5.97705 10.3416 6.24568 10.6103 6.57705 10.6103H10.8199C11.1512 10.6103 11.4199 10.3416 11.4199 10.0103 11.4199 9.67891 11.1512 9.41028 10.8199 9.41028H6.57705z" } }, { tag: "path", attrs: { fill: "currentColor", d: "M3.51074 2.37063C3.51074 1.48697 4.22709 0.77063 5.11074 0.77063H9.80318L9.81294 0.770708C9.97168 0.768161 10.1311 0.82824 10.2511 0.95055L14.4317 5.21408C14.5165 5.30049 14.5697 5.406 14.5917 5.51645C14.6041 5.5644 14.6106 5.61467 14.6106 5.66648V11.6406C14.6106 12.5243 13.8943 13.2406 13.0106 13.2406H5.11074C4.22709 13.2406 3.51074 12.5243 3.51074 11.6406V2.37063ZM10.4032 4.66648V2.81964L12.6063 5.06648H10.8032C10.5823 5.06648 10.4032 4.88739 10.4032 4.66648ZM5.11074 1.97063C4.88983 1.97063 4.71074 2.14972 4.71074 2.37063V11.6406C4.71074 11.8615 4.88983 12.0406 5.11074 12.0406H13.0106C13.2316 12.0406 13.4106 11.8615 13.4106 11.6406V6.26648H10.8032C9.91953 6.26648 9.20318 5.55013 9.20318 4.66648V1.97063H5.11074Z", fillRule: "evenodd", clipRule: "evenodd" } }, { tag: "path", attrs: { fill: "currentColor", d: "M2.58916 6.6741C2.58916 6.34273 2.32053 6.0741 1.98916 6.0741C1.65779 6.0741 1.38916 6.34273 1.38916 6.6741V12.6294C1.38916 14.0653 2.55322 15.2294 3.98916 15.2294H9.41408C9.74545 15.2294 10.0141 14.9607 10.0141 14.6294C10.0141 14.298 9.74545 14.0294 9.41408 14.0294H3.98916C3.21596 14.0294 2.58916 13.4026 2.58916 12.6294V6.6741Z" } }] }, ht = X(function(a, n) {
199
- return J(q, Object.assign({}, a, {
203
+ BottomSingle.displayName = "BottomSingle";
204
+ var element$6 = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M5.97705 7.51296C5.97705 7.18159 6.24568 6.91296 6.57705 6.91296H8.48632C8.81769 6.91296 9.08632 7.18159 9.08632 7.51296 9.08632 7.84433 8.81769 8.11296 8.48632 8.11296H6.57705C6.24568 8.11296 5.97705 7.84433 5.97705 7.51296zM6.57705 9.41028C6.24568 9.41028 5.97705 9.67891 5.97705 10.0103 5.97705 10.3416 6.24568 10.6103 6.57705 10.6103H10.8199C11.1512 10.6103 11.4199 10.3416 11.4199 10.0103 11.4199 9.67891 11.1512 9.41028 10.8199 9.41028H6.57705z" } }, { tag: "path", attrs: { fill: "currentColor", d: "M3.51074 2.37063C3.51074 1.48697 4.22709 0.77063 5.11074 0.77063H9.80318L9.81294 0.770708C9.97168 0.768161 10.1311 0.82824 10.2511 0.95055L14.4317 5.21408C14.5165 5.30049 14.5697 5.406 14.5917 5.51645C14.6041 5.5644 14.6106 5.61467 14.6106 5.66648V11.6406C14.6106 12.5243 13.8943 13.2406 13.0106 13.2406H5.11074C4.22709 13.2406 3.51074 12.5243 3.51074 11.6406V2.37063ZM10.4032 4.66648V2.81964L12.6063 5.06648H10.8032C10.5823 5.06648 10.4032 4.88739 10.4032 4.66648ZM5.11074 1.97063C4.88983 1.97063 4.71074 2.14972 4.71074 2.37063V11.6406C4.71074 11.8615 4.88983 12.0406 5.11074 12.0406H13.0106C13.2316 12.0406 13.4106 11.8615 13.4106 11.6406V6.26648H10.8032C9.91953 6.26648 9.20318 5.55013 9.20318 4.66648V1.97063H5.11074Z", fillRule: "evenodd", clipRule: "evenodd" } }, { tag: "path", attrs: { fill: "currentColor", d: "M2.58916 6.6741C2.58916 6.34273 2.32053 6.0741 1.98916 6.0741C1.65779 6.0741 1.38916 6.34273 1.38916 6.6741V12.6294C1.38916 14.0653 2.55322 15.2294 3.98916 15.2294H9.41408C9.74545 15.2294 10.0141 14.9607 10.0141 14.6294C10.0141 14.298 9.74545 14.0294 9.41408 14.0294H3.98916C3.21596 14.0294 2.58916 13.4026 2.58916 12.6294V6.6741Z" } }] }, CreateCopySingle = forwardRef(function(props, ref) {
205
+ return createElement(IconBase, Object.assign({}, props, {
200
206
  id: "create-copy-single",
201
- ref: n,
202
- icon: nn
207
+ ref,
208
+ icon: element$6
203
209
  }));
204
210
  });
205
- ht.displayName = "CreateCopySingle";
206
- var rn = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 17 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M7.38125 1.16211C6.49759 1.16211 5.78125 1.87845 5.78125 2.76211V5.6377H2.87783C1.99418 5.6377 1.27783 6.35404 1.27783 7.2377V13.2377C1.27783 14.1214 1.99418 14.8377 2.87783 14.8377H8.87783C9.76149 14.8377 10.4778 14.1214 10.4778 13.2377V10.3621H13.3813C14.2649 10.3621 14.9813 9.64577 14.9813 8.76211V2.76211C14.9813 1.87845 14.2649 1.16211 13.3813 1.16211H7.38125ZM10.4778 9.16211H13.3813C13.6022 9.16211 13.7812 8.98302 13.7812 8.76211V2.76211C13.7812 2.5412 13.6022 2.36211 13.3813 2.36211H7.38125C7.16034 2.36211 6.98125 2.5412 6.98125 2.76211V5.6377H8.87783C9.76149 5.6377 10.4778 6.35404 10.4778 7.2377V9.16211ZM6.98125 6.8377H8.87783C9.09875 6.8377 9.27783 7.01678 9.27783 7.2377V9.16211H7.38125C7.16034 9.16211 6.98125 8.98302 6.98125 8.76211V6.8377ZM5.78125 6.8377V8.76211C5.78125 9.64577 6.49759 10.3621 7.38125 10.3621H9.27783V13.2377C9.27783 13.4586 9.09875 13.6377 8.87783 13.6377H2.87783C2.65692 13.6377 2.47783 13.4586 2.47783 13.2377V7.2377C2.47783 7.01678 2.65692 6.8377 2.87783 6.8377H5.78125Z", fillRule: "evenodd", clipRule: "evenodd" } }] }, ft = X(function(a, n) {
207
- return J(q, Object.assign({}, a, {
211
+ CreateCopySingle.displayName = "CreateCopySingle";
212
+ var element$5 = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 17 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M7.38125 1.16211C6.49759 1.16211 5.78125 1.87845 5.78125 2.76211V5.6377H2.87783C1.99418 5.6377 1.27783 6.35404 1.27783 7.2377V13.2377C1.27783 14.1214 1.99418 14.8377 2.87783 14.8377H8.87783C9.76149 14.8377 10.4778 14.1214 10.4778 13.2377V10.3621H13.3813C14.2649 10.3621 14.9813 9.64577 14.9813 8.76211V2.76211C14.9813 1.87845 14.2649 1.16211 13.3813 1.16211H7.38125ZM10.4778 9.16211H13.3813C13.6022 9.16211 13.7812 8.98302 13.7812 8.76211V2.76211C13.7812 2.5412 13.6022 2.36211 13.3813 2.36211H7.38125C7.16034 2.36211 6.98125 2.5412 6.98125 2.76211V5.6377H8.87783C9.76149 5.6377 10.4778 6.35404 10.4778 7.2377V9.16211ZM6.98125 6.8377H8.87783C9.09875 6.8377 9.27783 7.01678 9.27783 7.2377V9.16211H7.38125C7.16034 9.16211 6.98125 8.98302 6.98125 8.76211V6.8377ZM5.78125 6.8377V8.76211C5.78125 9.64577 6.49759 10.3621 7.38125 10.3621H9.27783V13.2377C9.27783 13.4586 9.09875 13.6377 8.87783 13.6377H2.87783C2.65692 13.6377 2.47783 13.4586 2.47783 13.2377V7.2377C2.47783 7.01678 2.65692 6.8377 2.87783 6.8377H5.78125Z", fillRule: "evenodd", clipRule: "evenodd" } }] }, GroupSingle = forwardRef(function(props, ref) {
213
+ return createElement(IconBase, Object.assign({}, props, {
208
214
  id: "group-single",
209
- ref: n,
210
- icon: rn
215
+ ref,
216
+ icon: element$5
211
217
  }));
212
218
  });
213
- ft.displayName = "GroupSingle";
214
- var an = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M11.3536 6.14645C11.5488 6.34171 11.5488 6.65829 11.3536 6.85355L8.35355 9.85355C8.15829 10.0488 7.84171 10.0488 7.64645 9.85355L4.64645 6.85355C4.45118 6.65829 4.45118 6.34171 4.64645 6.14645C4.84171 5.95118 5.15829 5.95118 5.35355 6.14645L8 8.79289L10.6464 6.14645C10.8417 5.95118 11.1583 5.95118 11.3536 6.14645Z", fillRule: "evenodd", clipRule: "evenodd" } }] }, pt = X(function(a, n) {
215
- return J(q, Object.assign({}, a, {
219
+ GroupSingle.displayName = "GroupSingle";
220
+ var element$4 = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M11.3536 6.14645C11.5488 6.34171 11.5488 6.65829 11.3536 6.85355L8.35355 9.85355C8.15829 10.0488 7.84171 10.0488 7.64645 9.85355L4.64645 6.85355C4.45118 6.65829 4.45118 6.34171 4.64645 6.14645C4.84171 5.95118 5.15829 5.95118 5.35355 6.14645L8 8.79289L10.6464 6.14645C10.8417 5.95118 11.1583 5.95118 11.3536 6.14645Z", fillRule: "evenodd", clipRule: "evenodd" } }] }, MoreDownSingle = forwardRef(function(props, ref) {
221
+ return createElement(IconBase, Object.assign({}, props, {
216
222
  id: "more-down-single",
217
- ref: n,
218
- icon: an
223
+ ref,
224
+ icon: element$4
219
225
  }));
220
226
  });
221
- pt.displayName = "MoreDownSingle";
222
- var on = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M1.25 2.96401C1.25 3.84767 1.96634 4.56401 2.85 4.56401H13.15C14.0337 4.56401 14.75 3.84767 14.75 2.96401C14.75 2.08036 14.0337 1.36401 13.15 1.36401H2.85C1.96635 1.36401 1.25 2.08036 1.25 2.96401ZM2.85 3.36401C2.62909 3.36401 2.45 3.18493 2.45 2.96401C2.45 2.7431 2.62909 2.56401 2.85 2.56401H13.15C13.3709 2.56401 13.55 2.7431 13.55 2.96401C13.55 3.18493 13.3709 3.36401 13.15 3.36401H2.85Z", fillRule: "evenodd", clipRule: "evenodd" } }, { tag: "path", attrs: { fill: "currentColor", d: "M5.57564 11.6118C5.80995 11.3774 6.18985 11.3774 6.42417 11.6118L7.3999 12.5875V6.36951C7.3999 6.03814 7.66853 5.76951 7.9999 5.76951C8.33127 5.76951 8.5999 6.03814 8.5999 6.36951V12.5875L9.57564 11.6118C9.80995 11.3774 10.1899 11.3774 10.4242 11.6118C10.6585 11.8461 10.6585 12.226 10.4242 12.4603L8.4324 14.452C8.32324 14.5655 8.16982 14.6362 7.9999 14.6362C7.82998 14.6362 7.67655 14.5655 7.56739 14.452L5.57564 12.4603C5.34132 12.226 5.34132 11.8461 5.57564 11.6118Z" } }] }, Ct = X(function(a, n) {
223
- return J(q, Object.assign({}, a, {
227
+ MoreDownSingle.displayName = "MoreDownSingle";
228
+ var element$3 = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M1.25 2.96401C1.25 3.84767 1.96634 4.56401 2.85 4.56401H13.15C14.0337 4.56401 14.75 3.84767 14.75 2.96401C14.75 2.08036 14.0337 1.36401 13.15 1.36401H2.85C1.96635 1.36401 1.25 2.08036 1.25 2.96401ZM2.85 3.36401C2.62909 3.36401 2.45 3.18493 2.45 2.96401C2.45 2.7431 2.62909 2.56401 2.85 2.56401H13.15C13.3709 2.56401 13.55 2.7431 13.55 2.96401C13.55 3.18493 13.3709 3.36401 13.15 3.36401H2.85Z", fillRule: "evenodd", clipRule: "evenodd" } }, { tag: "path", attrs: { fill: "currentColor", d: "M5.57564 11.6118C5.80995 11.3774 6.18985 11.3774 6.42417 11.6118L7.3999 12.5875V6.36951C7.3999 6.03814 7.66853 5.76951 7.9999 5.76951C8.33127 5.76951 8.5999 6.03814 8.5999 6.36951V12.5875L9.57564 11.6118C9.80995 11.3774 10.1899 11.3774 10.4242 11.6118C10.6585 11.8461 10.6585 12.226 10.4242 12.4603L8.4324 14.452C8.32324 14.5655 8.16982 14.6362 7.9999 14.6362C7.82998 14.6362 7.67655 14.5655 7.56739 14.452L5.57564 12.4603C5.34132 12.226 5.34132 11.8461 5.57564 11.6118Z" } }] }, MoveDownSingle = forwardRef(function(props, ref) {
229
+ return createElement(IconBase, Object.assign({}, props, {
224
230
  id: "move-down-single",
225
- ref: n,
226
- icon: on
231
+ ref,
232
+ icon: element$3
227
233
  }));
228
234
  });
229
- Ct.displayName = "MoveDownSingle";
230
- var sn = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M1.25 13.036C1.25 12.1523 1.96634 11.436 2.85 11.436H13.15C14.0337 11.436 14.75 12.1523 14.75 13.036C14.75 13.9196 14.0337 14.636 13.15 14.636H2.85C1.96635 14.636 1.25 13.9196 1.25 13.036ZM2.85 12.636C2.62909 12.636 2.45 12.8151 2.45 13.036C2.45 13.2569 2.62909 13.436 2.85 13.436H13.15C13.3709 13.436 13.55 13.2569 13.55 13.036C13.55 12.8151 13.3709 12.636 13.15 12.636H2.85Z", fillRule: "evenodd", clipRule: "evenodd" } }, { tag: "path", attrs: { fill: "currentColor", d: "M5.57564 4.38825C5.80995 4.62256 6.18985 4.62256 6.42417 4.38825L7.3999 3.41251V9.63049C7.3999 9.96186 7.66853 10.2305 7.9999 10.2305C8.33127 10.2305 8.5999 9.96186 8.5999 9.63049V3.41251L9.57564 4.38825C9.80995 4.62256 10.1899 4.62256 10.4242 4.38825C10.6585 4.15393 10.6585 3.77403 10.4242 3.53972L8.4324 1.54796C8.32324 1.43445 8.16982 1.36382 7.9999 1.36382C7.82998 1.36382 7.67655 1.43446 7.56739 1.54797L5.57564 3.53972C5.34132 3.77403 5.34132 4.15393 5.57564 4.38825Z" } }] }, wt = X(function(a, n) {
231
- return J(q, Object.assign({}, a, {
235
+ MoveDownSingle.displayName = "MoveDownSingle";
236
+ var element$2 = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M1.25 13.036C1.25 12.1523 1.96634 11.436 2.85 11.436H13.15C14.0337 11.436 14.75 12.1523 14.75 13.036C14.75 13.9196 14.0337 14.636 13.15 14.636H2.85C1.96635 14.636 1.25 13.9196 1.25 13.036ZM2.85 12.636C2.62909 12.636 2.45 12.8151 2.45 13.036C2.45 13.2569 2.62909 13.436 2.85 13.436H13.15C13.3709 13.436 13.55 13.2569 13.55 13.036C13.55 12.8151 13.3709 12.636 13.15 12.636H2.85Z", fillRule: "evenodd", clipRule: "evenodd" } }, { tag: "path", attrs: { fill: "currentColor", d: "M5.57564 4.38825C5.80995 4.62256 6.18985 4.62256 6.42417 4.38825L7.3999 3.41251V9.63049C7.3999 9.96186 7.66853 10.2305 7.9999 10.2305C8.33127 10.2305 8.5999 9.96186 8.5999 9.63049V3.41251L9.57564 4.38825C9.80995 4.62256 10.1899 4.62256 10.4242 4.38825C10.6585 4.15393 10.6585 3.77403 10.4242 3.53972L8.4324 1.54796C8.32324 1.43445 8.16982 1.36382 7.9999 1.36382C7.82998 1.36382 7.67655 1.43446 7.56739 1.54797L5.57564 3.53972C5.34132 3.77403 5.34132 4.15393 5.57564 4.38825Z" } }] }, MoveUpSingle = forwardRef(function(props, ref) {
237
+ return createElement(IconBase, Object.assign({}, props, {
232
238
  id: "move-up-single",
233
- ref: n,
234
- icon: sn
239
+ ref,
240
+ icon: element$2
235
241
  }));
236
242
  });
237
- wt.displayName = "MoveUpSingle";
238
- var cn = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 17 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M7.82994 1.40913C7.88746 1.35161 7.95376 1.30821 8.02453 1.27893C8.09527 1.24959 8.17285 1.2334 8.2542 1.2334C8.33555 1.2334 8.41313 1.24959 8.48387 1.27893C8.55464 1.30821 8.62094 1.35161 8.67846 1.40913L10.6785 3.40913C10.9128 3.64345 10.9128 4.02335 10.6785 4.25766C10.4441 4.49198 10.0642 4.49198 9.82994 4.25766L8.8542 3.28193V5.8334C8.8542 6.16477 8.58557 6.4334 8.2542 6.4334C7.92283 6.4334 7.6542 6.16477 7.6542 5.8334V3.28193L6.67846 4.25766C6.44415 4.49198 6.06425 4.49198 5.82994 4.25766C5.59562 4.02335 5.59562 3.64345 5.82994 3.40913L7.82994 1.40913Z" } }, { tag: "path", attrs: { fill: "currentColor", d: "M1.50439 9C1.50439 8.11634 2.22074 7.4 3.10439 7.4H13.4044C14.288 7.4 15.0044 8.11634 15.0044 9 15.0044 9.88366 14.2881 10.6 13.4044 10.6H3.1044C2.22074 10.6 1.50439 9.88366 1.50439 9zM3.10439 8.6C2.88348 8.6 2.70439 8.77909 2.70439 9 2.70439 9.22091 2.88348 9.4 3.1044 9.4H13.4044C13.6253 9.4 13.8044 9.22091 13.8044 9 13.8044 8.77909 13.6253 8.6 13.4044 8.6H3.10439zM1.6543 13.1665C1.6543 12.2828 2.37064 11.5665 3.2543 11.5665H13.5543C14.438 11.5665 15.1543 12.2828 15.1543 13.1665 15.1543 14.0502 14.438 14.7665 13.5543 14.7665H3.2543C2.37064 14.7665 1.6543 14.0502 1.6543 13.1665zM3.2543 12.7665C3.03338 12.7665 2.8543 12.9456 2.8543 13.1665 2.8543 13.3874 3.03338 13.5665 3.2543 13.5665H13.5543C13.7752 13.5665 13.9543 13.3874 13.9543 13.1665 13.9543 12.9456 13.7752 12.7665 13.5543 12.7665H3.2543z", fillRule: "evenodd", clipRule: "evenodd" } }] }, vt = X(function(a, n) {
239
- return J(q, Object.assign({}, a, {
243
+ MoveUpSingle.displayName = "MoveUpSingle";
244
+ var element$1 = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 17 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M7.82994 1.40913C7.88746 1.35161 7.95376 1.30821 8.02453 1.27893C8.09527 1.24959 8.17285 1.2334 8.2542 1.2334C8.33555 1.2334 8.41313 1.24959 8.48387 1.27893C8.55464 1.30821 8.62094 1.35161 8.67846 1.40913L10.6785 3.40913C10.9128 3.64345 10.9128 4.02335 10.6785 4.25766C10.4441 4.49198 10.0642 4.49198 9.82994 4.25766L8.8542 3.28193V5.8334C8.8542 6.16477 8.58557 6.4334 8.2542 6.4334C7.92283 6.4334 7.6542 6.16477 7.6542 5.8334V3.28193L6.67846 4.25766C6.44415 4.49198 6.06425 4.49198 5.82994 4.25766C5.59562 4.02335 5.59562 3.64345 5.82994 3.40913L7.82994 1.40913Z" } }, { tag: "path", attrs: { fill: "currentColor", d: "M1.50439 9C1.50439 8.11634 2.22074 7.4 3.10439 7.4H13.4044C14.288 7.4 15.0044 8.11634 15.0044 9 15.0044 9.88366 14.2881 10.6 13.4044 10.6H3.1044C2.22074 10.6 1.50439 9.88366 1.50439 9zM3.10439 8.6C2.88348 8.6 2.70439 8.77909 2.70439 9 2.70439 9.22091 2.88348 9.4 3.1044 9.4H13.4044C13.6253 9.4 13.8044 9.22091 13.8044 9 13.8044 8.77909 13.6253 8.6 13.4044 8.6H3.10439zM1.6543 13.1665C1.6543 12.2828 2.37064 11.5665 3.2543 11.5665H13.5543C14.438 11.5665 15.1543 12.2828 15.1543 13.1665 15.1543 14.0502 14.438 14.7665 13.5543 14.7665H3.2543C2.37064 14.7665 1.6543 14.0502 1.6543 13.1665zM3.2543 12.7665C3.03338 12.7665 2.8543 12.9456 2.8543 13.1665 2.8543 13.3874 3.03338 13.5665 3.2543 13.5665H13.5543C13.7752 13.5665 13.9543 13.3874 13.9543 13.1665 13.9543 12.9456 13.7752 12.7665 13.5543 12.7665H3.2543z", fillRule: "evenodd", clipRule: "evenodd" } }] }, TopmostSingle = forwardRef(function(props, ref) {
245
+ return createElement(IconBase, Object.assign({}, props, {
240
246
  id: "topmost-single",
241
- ref: n,
242
- icon: cn
247
+ ref,
248
+ icon: element$1
243
249
  }));
244
250
  });
245
- vt.displayName = "TopmostSingle";
246
- var ln = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 17 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M7.46855 2.83731C7.46855 2.61639 7.64764 2.4373 7.86855 2.4373H13.8603C14.0812 2.4373 14.2603 2.61639 14.2603 2.8373V9.5049C14.2603 9.72581 14.0812 9.90489 13.8603 9.90489H12.866C12.5346 9.90489 12.266 10.1735 12.266 10.5049C12.266 10.8363 12.5346 11.1049 12.866 11.1049H13.8603C14.7439 11.1049 15.4603 10.3886 15.4603 9.5049V2.8373C15.4603 1.95365 14.7439 1.2373 13.8603 1.2373H7.86855C6.9849 1.2373 6.26855 1.95365 6.26855 2.83731V3.48688C6.26855 3.81825 6.53718 4.08688 6.86855 4.08688C7.19993 4.08688 7.46855 3.81825 7.46855 3.48688V2.83731Z" } }, { tag: "path", attrs: { fill: "currentColor", d: "M3.19888 5.56299C2.31522 5.56299 1.59888 6.27933 1.59888 7.16299V13.163C1.59888 14.0466 2.31522 14.763 3.19888 14.763H9.19888C10.0825 14.763 10.7989 14.0466 10.7989 13.163V7.16299C10.7989 6.27933 10.0825 5.56299 9.19888 5.56299H3.19888ZM2.79888 7.16299C2.79888 6.94207 2.97796 6.76299 3.19888 6.76299H9.19888C9.41979 6.76299 9.59888 6.94207 9.59888 7.16299V13.163C9.59888 13.3839 9.41979 13.563 9.19888 13.563H3.19888C2.97796 13.563 2.79888 13.3839 2.79888 13.163V7.16299Z", fillRule: "evenodd", clipRule: "evenodd" } }] }, _t = X(function(a, n) {
247
- return J(q, Object.assign({}, a, {
251
+ TopmostSingle.displayName = "TopmostSingle";
252
+ var element = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 17 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M7.46855 2.83731C7.46855 2.61639 7.64764 2.4373 7.86855 2.4373H13.8603C14.0812 2.4373 14.2603 2.61639 14.2603 2.8373V9.5049C14.2603 9.72581 14.0812 9.90489 13.8603 9.90489H12.866C12.5346 9.90489 12.266 10.1735 12.266 10.5049C12.266 10.8363 12.5346 11.1049 12.866 11.1049H13.8603C14.7439 11.1049 15.4603 10.3886 15.4603 9.5049V2.8373C15.4603 1.95365 14.7439 1.2373 13.8603 1.2373H7.86855C6.9849 1.2373 6.26855 1.95365 6.26855 2.83731V3.48688C6.26855 3.81825 6.53718 4.08688 6.86855 4.08688C7.19993 4.08688 7.46855 3.81825 7.46855 3.48688V2.83731Z" } }, { tag: "path", attrs: { fill: "currentColor", d: "M3.19888 5.56299C2.31522 5.56299 1.59888 6.27933 1.59888 7.16299V13.163C1.59888 14.0466 2.31522 14.763 3.19888 14.763H9.19888C10.0825 14.763 10.7989 14.0466 10.7989 13.163V7.16299C10.7989 6.27933 10.0825 5.56299 9.19888 5.56299H3.19888ZM2.79888 7.16299C2.79888 6.94207 2.97796 6.76299 3.19888 6.76299H9.19888C9.41979 6.76299 9.59888 6.94207 9.59888 7.16299V13.163C9.59888 13.3839 9.41979 13.563 9.19888 13.563H3.19888C2.97796 13.563 2.79888 13.3839 2.79888 13.163V7.16299Z", fillRule: "evenodd", clipRule: "evenodd" } }] }, UngroupSingle = forwardRef(function(props, ref) {
253
+ return createElement(IconBase, Object.assign({}, props, {
248
254
  id: "ungroup-single",
249
- ref: n,
250
- icon: ln
255
+ ref,
256
+ icon: element
251
257
  }));
252
258
  });
253
- _t.displayName = "UngroupSingle";
254
- const mn = "univer-image-common-panel", gn = "univer-image-common-panel-grid", un = "univer-image-common-panel-border", dn = "univer-image-common-panel-title", hn = "univer-image-common-panel-subtitle", fn = "univer-image-common-panel-row", pn = "univer-image-common-panel-row-vertical", Cn = "univer-image-common-panel-column", wn = "univer-image-common-panel-column-center", vn = "univer-image-common-panel-inline", _n = "univer-image-common-panel-span2", Sn = "univer-image-common-panel-span3", bn = "univer-image-common-panel-input", g = {
255
- imageCommonPanel: mn,
256
- imageCommonPanelGrid: gn,
257
- imageCommonPanelBorder: un,
258
- imageCommonPanelTitle: dn,
259
- imageCommonPanelSubtitle: hn,
260
- imageCommonPanelRow: fn,
261
- imageCommonPanelRowVertical: pn,
262
- imageCommonPanelColumn: Cn,
263
- imageCommonPanelColumnCenter: wn,
264
- imageCommonPanelInline: vn,
265
- imageCommonPanelSpan2: _n,
266
- imageCommonPanelSpan3: Sn,
267
- imageCommonPanelInput: bn
268
- }, In = (a) => {
269
- const { arrangeShow: n, drawings: e } = a, t = V(Y), r = V(ae), o = (m) => m ? "block" : "none", [i, s] = L(e);
270
- be(() => {
271
- const m = r.focus$.subscribe((u) => {
272
- s(u);
259
+ UngroupSingle.displayName = "UngroupSingle";
260
+ const imageCommonPanel = "univer-image-common-panel", imageCommonPanelGrid = "univer-image-common-panel-grid", imageCommonPanelBorder = "univer-image-common-panel-border", imageCommonPanelTitle = "univer-image-common-panel-title", imageCommonPanelSubtitle = "univer-image-common-panel-subtitle", imageCommonPanelRow = "univer-image-common-panel-row", imageCommonPanelRowVertical = "univer-image-common-panel-row-vertical", imageCommonPanelColumn = "univer-image-common-panel-column", imageCommonPanelColumnCenter = "univer-image-common-panel-column-center", imageCommonPanelInline = "univer-image-common-panel-inline", imageCommonPanelSpan2 = "univer-image-common-panel-span2", imageCommonPanelSpan3 = "univer-image-common-panel-span3", imageCommonPanelInput = "univer-image-common-panel-input", styles$1 = {
261
+ imageCommonPanel,
262
+ imageCommonPanelGrid,
263
+ imageCommonPanelBorder,
264
+ imageCommonPanelTitle,
265
+ imageCommonPanelSubtitle,
266
+ imageCommonPanelRow,
267
+ imageCommonPanelRowVertical,
268
+ imageCommonPanelColumn,
269
+ imageCommonPanelColumnCenter,
270
+ imageCommonPanelInline,
271
+ imageCommonPanelSpan2,
272
+ imageCommonPanelSpan3,
273
+ imageCommonPanelInput
274
+ }, DrawingArrange = /* @__PURE__ */ __name((props) => {
275
+ const { arrangeShow, drawings: focusDrawings } = props, localeService = useDependency(LocaleService), drawingManagerService = useDependency(IDrawingManagerService), gridDisplay = /* @__PURE__ */ __name((isShow) => isShow ? "block" : "none", "gridDisplay"), [drawings, setDrawings] = useState(focusDrawings);
276
+ useEffect(() => {
277
+ const focusDispose = drawingManagerService.focus$.subscribe((drawings2) => {
278
+ setDrawings(drawings2);
273
279
  });
274
280
  return () => {
275
- m.unsubscribe();
281
+ focusDispose.unsubscribe();
276
282
  };
277
283
  }, []);
278
- const l = (m) => {
279
- const u = i[0].unitId, d = i[0].subUnitId, h = i.map((f) => f.drawingId);
280
- r.featurePluginOrderUpdateNotification({ unitId: u, subUnitId: d, drawingIds: h, arrangeType: m });
281
- };
282
- return /* @__PURE__ */ c.createElement("div", { className: g.imageCommonPanelGrid, style: { display: o(n) } }, /* @__PURE__ */ c.createElement("div", { className: g.imageCommonPanelRow }, /* @__PURE__ */ c.createElement("div", { className: O(g.imageCommonPanelColumn, g.imageCommonPanelTitle) }, /* @__PURE__ */ c.createElement("div", null, t.t("image-panel.arrange.title")))), /* @__PURE__ */ c.createElement("div", { className: g.imageCommonPanelRow }, /* @__PURE__ */ c.createElement("div", { className: O(g.imageCommonPanelColumn, g.imageCommonPanelSpan2) }, /* @__PURE__ */ c.createElement(le, { size: "small", onClick: () => {
283
- l(Pe.forward);
284
- } }, /* @__PURE__ */ c.createElement("span", { className: g.imageCommonPanelInline }, /* @__PURE__ */ c.createElement(wt, null), t.t("image-panel.arrange.forward")))), /* @__PURE__ */ c.createElement("div", { className: O(g.imageCommonPanelColumn, g.imageCommonPanelSpan2) }, /* @__PURE__ */ c.createElement(le, { size: "small", onClick: () => {
285
- l(Pe.backward);
286
- } }, /* @__PURE__ */ c.createElement("span", { className: g.imageCommonPanelInline }, /* @__PURE__ */ c.createElement(Ct, null), t.t("image-panel.arrange.backward"))))), /* @__PURE__ */ c.createElement("div", { className: g.imageCommonPanelRow }, /* @__PURE__ */ c.createElement("div", { className: O(g.imageCommonPanelColumn, g.imageCommonPanelSpan2) }, /* @__PURE__ */ c.createElement(le, { size: "small", onClick: () => {
287
- l(Pe.front);
288
- } }, /* @__PURE__ */ c.createElement("span", { className: g.imageCommonPanelInline }, /* @__PURE__ */ c.createElement(vt, null), t.t("image-panel.arrange.front")))), /* @__PURE__ */ c.createElement("div", { className: O(g.imageCommonPanelColumn, g.imageCommonPanelSpan2) }, /* @__PURE__ */ c.createElement(le, { size: "small", onClick: () => {
289
- l(Pe.back);
290
- } }, /* @__PURE__ */ c.createElement("span", { className: g.imageCommonPanelInline }, /* @__PURE__ */ c.createElement(dt, null), t.t("image-panel.arrange.back"))))));
291
- }, se = 20, Pn = 20, yn = [-3600, 3600], Re = 300, En = (a) => {
292
- var qe;
293
- const n = V(Y), e = V(ae), t = V(he), { drawings: r, transformShow: o } = a, i = r[0];
294
- if (i == null)
284
+ const onArrangeBtnClick = /* @__PURE__ */ __name((arrangeType) => {
285
+ const unitId = drawings[0].unitId, subUnitId = drawings[0].subUnitId, drawingIds = drawings.map((drawing) => drawing.drawingId);
286
+ drawingManagerService.featurePluginOrderUpdateNotification({ unitId, subUnitId, drawingIds, arrangeType });
287
+ }, "onArrangeBtnClick");
288
+ return /* @__PURE__ */ React.createElement("div", { className: styles$1.imageCommonPanelGrid, style: { display: gridDisplay(arrangeShow) } }, /* @__PURE__ */ React.createElement("div", { className: styles$1.imageCommonPanelRow }, /* @__PURE__ */ React.createElement("div", { className: clsx(styles$1.imageCommonPanelColumn, styles$1.imageCommonPanelTitle) }, /* @__PURE__ */ React.createElement("div", null, localeService.t("image-panel.arrange.title")))), /* @__PURE__ */ React.createElement("div", { className: styles$1.imageCommonPanelRow }, /* @__PURE__ */ React.createElement("div", { className: clsx(styles$1.imageCommonPanelColumn, styles$1.imageCommonPanelSpan2) }, /* @__PURE__ */ React.createElement(Button, { size: "small", onClick: /* @__PURE__ */ __name(() => {
289
+ onArrangeBtnClick(ArrangeTypeEnum.forward);
290
+ }, "onClick") }, /* @__PURE__ */ React.createElement("span", { className: styles$1.imageCommonPanelInline }, /* @__PURE__ */ React.createElement(MoveUpSingle, null), localeService.t("image-panel.arrange.forward")))), /* @__PURE__ */ React.createElement("div", { className: clsx(styles$1.imageCommonPanelColumn, styles$1.imageCommonPanelSpan2) }, /* @__PURE__ */ React.createElement(Button, { size: "small", onClick: /* @__PURE__ */ __name(() => {
291
+ onArrangeBtnClick(ArrangeTypeEnum.backward);
292
+ }, "onClick") }, /* @__PURE__ */ React.createElement("span", { className: styles$1.imageCommonPanelInline }, /* @__PURE__ */ React.createElement(MoveDownSingle, null), localeService.t("image-panel.arrange.backward"))))), /* @__PURE__ */ React.createElement("div", { className: styles$1.imageCommonPanelRow }, /* @__PURE__ */ React.createElement("div", { className: clsx(styles$1.imageCommonPanelColumn, styles$1.imageCommonPanelSpan2) }, /* @__PURE__ */ React.createElement(Button, { size: "small", onClick: /* @__PURE__ */ __name(() => {
293
+ onArrangeBtnClick(ArrangeTypeEnum.front);
294
+ }, "onClick") }, /* @__PURE__ */ React.createElement("span", { className: styles$1.imageCommonPanelInline }, /* @__PURE__ */ React.createElement(TopmostSingle, null), localeService.t("image-panel.arrange.front")))), /* @__PURE__ */ React.createElement("div", { className: clsx(styles$1.imageCommonPanelColumn, styles$1.imageCommonPanelSpan2) }, /* @__PURE__ */ React.createElement(Button, { size: "small", onClick: /* @__PURE__ */ __name(() => {
295
+ onArrangeBtnClick(ArrangeTypeEnum.back);
296
+ }, "onClick") }, /* @__PURE__ */ React.createElement("span", { className: styles$1.imageCommonPanelInline }, /* @__PURE__ */ React.createElement(BottomSingle, null), localeService.t("image-panel.arrange.back"))))));
297
+ }, "DrawingArrange"), MIN_DRAWING_WIDTH_LIMIT = 20, MIN_DRAWING_HEIGHT_LIMIT = 20, RANGE_DRAWING_ROTATION_LIMIT = [-3600, 3600], INPUT_DEBOUNCE_TIME = 300, DrawingTransform = /* @__PURE__ */ __name((props) => {
298
+ var _a7;
299
+ const localeService = useDependency(LocaleService), drawingManagerService = useDependency(IDrawingManagerService), renderManagerService = useDependency(IRenderManagerService), { drawings, transformShow } = props, drawingParam = drawings[0];
300
+ if (drawingParam == null)
295
301
  return;
296
- const s = i.transform;
297
- if (s == null)
302
+ const transform = drawingParam.transform;
303
+ if (transform == null)
298
304
  return;
299
- const { unitId: l, subUnitId: m, drawingId: u, drawingType: d } = i, h = t.getRenderById(l), f = h == null ? void 0 : h.scene;
300
- if (f == null)
305
+ const { unitId, subUnitId, drawingId, drawingType } = drawingParam, renderObject = renderManagerService.getRenderById(unitId), scene = renderObject == null ? void 0 : renderObject.scene;
306
+ if (scene == null)
301
307
  return;
302
- const v = (qe = f.getEngine()) == null ? void 0 : qe.activeScene;
303
- if (v == null)
308
+ const topScene = (_a7 = scene.getEngine()) == null ? void 0 : _a7.activeScene;
309
+ if (topScene == null)
304
310
  return;
305
- const w = f.getTransformerByCreate(), {
306
- width: p = 0,
307
- height: S = 0,
308
- left: _ = 0,
309
- top: R = 0,
310
- angle: b = 0
311
- } = s, [N, I] = L(p), [y, P] = L(S), [M, D] = L(_), [U, T] = L(R), [ie, W] = L(b), [Q, Ie] = L(w.keepRatio), oe = (C, A, x, H) => {
312
- const { width: j, height: ee } = v, { ancestorLeft: k, ancestorTop: z } = f;
313
- let K = C, Z = A, ne = x, fe = H;
314
- return C + k < 0 && (K = -k), A + z < 0 && (Z = -z), ne = j - K - k, ne < se && (ne = se), fe = ee - Z - z, fe < se && (fe = se), C + ne + k > j && (K = j - x - k), A + fe + z > ee && (Z = ee - H - z), {
315
- limitLeft: K,
316
- limitTop: Z,
317
- limitWidth: ne,
318
- limitHeight: fe
311
+ const transformer = scene.getTransformerByCreate(), {
312
+ width: originWidth = 0,
313
+ height: originHeight = 0,
314
+ left: originX = 0,
315
+ top: originY = 0,
316
+ angle: originRotation = 0
317
+ } = transform, [width, setWidth] = useState(originWidth), [height, setHeight] = useState(originHeight), [xPosition, setXPosition] = useState(originX), [yPosition, setYPosition] = useState(originY), [rotation, setRotation] = useState(originRotation), [lockRatio, setLockRatio] = useState(transformer.keepRatio), checkMoveBoundary = /* @__PURE__ */ __name((left, top, width2, height2) => {
318
+ const { width: topSceneWidth, height: topSceneHeight } = topScene, { ancestorLeft, ancestorTop } = scene;
319
+ let limitLeft = left, limitTop = top, limitWidth = width2, limitHeight = height2;
320
+ return left + ancestorLeft < 0 && (limitLeft = -ancestorLeft), top + ancestorTop < 0 && (limitTop = -ancestorTop), limitWidth = topSceneWidth - limitLeft - ancestorLeft, limitWidth < MIN_DRAWING_WIDTH_LIMIT && (limitWidth = MIN_DRAWING_WIDTH_LIMIT), limitHeight = topSceneHeight - limitTop - ancestorTop, limitHeight < MIN_DRAWING_WIDTH_LIMIT && (limitHeight = MIN_DRAWING_WIDTH_LIMIT), left + limitWidth + ancestorLeft > topSceneWidth && (limitLeft = topSceneWidth - width2 - ancestorLeft), top + limitHeight + ancestorTop > topSceneHeight && (limitTop = topSceneHeight - height2 - ancestorTop), {
321
+ limitLeft,
322
+ limitTop,
323
+ limitWidth,
324
+ limitHeight
319
325
  };
320
- }, F = (C) => {
321
- const { objects: A } = C, x = Ge(A, e);
322
- if (x.length !== 1)
326
+ }, "checkMoveBoundary"), changeObs = /* @__PURE__ */ __name((state) => {
327
+ const { objects } = state, params = getUpdateParams(objects, drawingManagerService);
328
+ if (params.length !== 1)
323
329
  return;
324
- const H = x[0];
325
- if (H == null)
330
+ const drawingParam2 = params[0];
331
+ if (drawingParam2 == null)
326
332
  return;
327
- const { transform: j } = H;
328
- if (j == null)
333
+ const { transform: transform2 } = drawingParam2;
334
+ if (transform2 == null)
329
335
  return;
330
336
  const {
331
- width: ee,
332
- height: k,
333
- left: z,
334
- top: K,
335
- angle: Z
336
- } = j;
337
- ee != null && I(ee), k != null && P(k), z != null && D(z), K != null && T(K), Z != null && W(Z);
338
- };
339
- be(() => {
340
- const C = w.changeStart$.subscribe((H) => {
341
- F(H);
342
- }), A = w.changing$.subscribe((H) => {
343
- F(H);
344
- }), x = e.focus$.subscribe((H) => {
345
- if (H.length !== 1)
337
+ width: originWidth2,
338
+ height: originHeight2,
339
+ left: originX2,
340
+ top: originY2,
341
+ angle: originRotation2
342
+ } = transform2;
343
+ originWidth2 != null && setWidth(originWidth2), originHeight2 != null && setHeight(originHeight2), originX2 != null && setXPosition(originX2), originY2 != null && setYPosition(originY2), originRotation2 != null && setRotation(originRotation2);
344
+ }, "changeObs");
345
+ useEffect(() => {
346
+ const changeStartSub = transformer.changeStart$.subscribe((state) => {
347
+ changeObs(state);
348
+ }), changingSub = transformer.changing$.subscribe((state) => {
349
+ changeObs(state);
350
+ }), focusSub = drawingManagerService.focus$.subscribe((drawings2) => {
351
+ if (drawings2.length !== 1)
346
352
  return;
347
- const j = e.getDrawingByParam(H[0]);
348
- if (j == null)
353
+ const drawingParam2 = drawingManagerService.getDrawingByParam(drawings2[0]);
354
+ if (drawingParam2 == null)
349
355
  return;
350
- const ee = j.transform;
351
- if (ee == null)
356
+ const transform2 = drawingParam2.transform;
357
+ if (transform2 == null)
352
358
  return;
353
359
  const {
354
- width: k,
355
- height: z,
356
- left: K,
357
- top: Z,
358
- angle: ne
359
- } = ee;
360
- k != null && I(k), z != null && P(z), K != null && D(K), Z != null && T(Z), ne != null && W(ne);
360
+ width: originWidth2,
361
+ height: originHeight2,
362
+ left: originX2,
363
+ top: originY2,
364
+ angle: originRotation2
365
+ } = transform2;
366
+ originWidth2 != null && setWidth(originWidth2), originHeight2 != null && setHeight(originHeight2), originX2 != null && setXPosition(originX2), originY2 != null && setYPosition(originY2), originRotation2 != null && setRotation(originRotation2);
361
367
  });
362
368
  return () => {
363
- A.unsubscribe(), C.unsubscribe(), x.unsubscribe();
369
+ changingSub.unsubscribe(), changeStartSub.unsubscribe(), focusSub.unsubscribe();
364
370
  };
365
371
  }, []);
366
- const We = Ee((C) => {
367
- if (C == null)
372
+ const handleWidthChange = debounce((val) => {
373
+ if (val == null)
368
374
  return;
369
- C = Math.max(C, se);
370
- const { limitWidth: A, limitHeight: x } = oe(M, U, C, y);
371
- C = Math.min(C, A);
372
- const H = { unitId: l, subUnitId: m, drawingId: u, drawingType: d, transform: { width: C } };
373
- if (Q) {
374
- let j = C / N * y;
375
- if (j = Math.max(j, Pn), j > x)
375
+ val = Math.max(val, MIN_DRAWING_WIDTH_LIMIT);
376
+ const { limitWidth, limitHeight } = checkMoveBoundary(xPosition, yPosition, val, height);
377
+ val = Math.min(val, limitWidth);
378
+ const updateParam = { unitId, subUnitId, drawingId, drawingType, transform: { width: val } };
379
+ if (lockRatio) {
380
+ let heightFix = val / width * height;
381
+ if (heightFix = Math.max(heightFix, MIN_DRAWING_HEIGHT_LIMIT), heightFix > limitHeight)
376
382
  return;
377
- P(j), H.transform.height = j;
383
+ setHeight(heightFix), updateParam.transform.height = heightFix;
378
384
  }
379
- I(C), e.featurePluginUpdateNotification([H]), w.refreshControls().changeNotification();
380
- }, Re), $e = Ee((C) => {
381
- if (C == null)
385
+ setWidth(val), drawingManagerService.featurePluginUpdateNotification([updateParam]), transformer.refreshControls().changeNotification();
386
+ }, INPUT_DEBOUNCE_TIME), handleHeightChange = debounce((val) => {
387
+ if (val == null)
382
388
  return;
383
- C = Math.max(C, se);
384
- const { limitHeight: A, limitWidth: x } = oe(M, U, N, C);
385
- C = Math.min(C, A);
386
- const H = { unitId: l, subUnitId: m, drawingId: u, drawingType: d, transform: { height: C } };
387
- if (Q) {
388
- let j = C / y * N;
389
- if (j = Math.max(j, se), j > x)
389
+ val = Math.max(val, MIN_DRAWING_WIDTH_LIMIT);
390
+ const { limitHeight, limitWidth } = checkMoveBoundary(xPosition, yPosition, width, val);
391
+ val = Math.min(val, limitHeight);
392
+ const updateParam = { unitId, subUnitId, drawingId, drawingType, transform: { height: val } };
393
+ if (lockRatio) {
394
+ let widthFix = val / height * width;
395
+ if (widthFix = Math.max(widthFix, MIN_DRAWING_WIDTH_LIMIT), widthFix > limitWidth)
390
396
  return;
391
- I(j), H.transform.width = j;
397
+ setWidth(widthFix), updateParam.transform.width = widthFix;
392
398
  }
393
- P(C), e.featurePluginUpdateNotification([H]), w.refreshControls().changeNotification();
394
- }, Re), It = Ee((C) => {
395
- if (C == null)
399
+ setHeight(val), drawingManagerService.featurePluginUpdateNotification([updateParam]), transformer.refreshControls().changeNotification();
400
+ }, INPUT_DEBOUNCE_TIME), handleXChange = debounce((val) => {
401
+ if (val == null)
396
402
  return;
397
- const { limitLeft: A } = oe(C, U, N, y);
398
- C = A;
399
- const x = { unitId: l, subUnitId: m, drawingId: u, drawingType: d, transform: { left: C } };
400
- D(C), e.featurePluginUpdateNotification([x]), w.refreshControls().changeNotification();
401
- }, Re), Pt = Ee((C) => {
402
- if (C == null)
403
+ const { limitLeft } = checkMoveBoundary(val, yPosition, width, height);
404
+ val = limitLeft;
405
+ const updateParam = { unitId, subUnitId, drawingId, drawingType, transform: { left: val } };
406
+ setXPosition(val), drawingManagerService.featurePluginUpdateNotification([updateParam]), transformer.refreshControls().changeNotification();
407
+ }, INPUT_DEBOUNCE_TIME), handleYChange = debounce((val) => {
408
+ if (val == null)
403
409
  return;
404
- const { limitTop: A } = oe(M, C, N, y);
405
- C = A;
406
- const x = { unitId: l, subUnitId: m, drawingId: u, drawingType: d, transform: { top: C } };
407
- T(C), e.featurePluginUpdateNotification([x]), w.refreshControls().changeNotification();
408
- }, Re), yt = (C) => {
409
- if (C == null)
410
+ const { limitTop } = checkMoveBoundary(xPosition, val, width, height);
411
+ val = limitTop;
412
+ const updateParam = { unitId, subUnitId, drawingId, drawingType, transform: { top: val } };
413
+ setYPosition(val), drawingManagerService.featurePluginUpdateNotification([updateParam]), transformer.refreshControls().changeNotification();
414
+ }, INPUT_DEBOUNCE_TIME), handleRotationChange = /* @__PURE__ */ __name((val) => {
415
+ if (val == null)
410
416
  return;
411
- const [A, x] = yn;
412
- C < A && (C = A), C > x && (C = x);
413
- const H = { unitId: l, subUnitId: m, drawingId: u, drawingType: d, transform: { angle: C } };
414
- W(C), e.featurePluginUpdateNotification([H]), w.refreshControls().changeNotification();
415
- }, Et = (C) => {
416
- Ie(C), w.keepRatio = C;
417
- }, Rt = (C) => C ? "block" : "none";
418
- return /* @__PURE__ */ c.createElement("div", { className: O(g.imageCommonPanelGrid, g.imageCommonPanelBorder), style: { display: Rt(o) } }, /* @__PURE__ */ c.createElement("div", { className: g.imageCommonPanelRow }, /* @__PURE__ */ c.createElement("div", { className: O(g.imageCommonPanelColumn, g.imageCommonPanelTitle) }, /* @__PURE__ */ c.createElement("div", null, n.t("image-panel.transform.title")))), /* @__PURE__ */ c.createElement("div", { className: g.imageCommonPanelRow }, /* @__PURE__ */ c.createElement("div", { className: O(g.imageCommonPanelColumn, g.imageCommonPanelSpan3) }, /* @__PURE__ */ c.createElement("label", null, /* @__PURE__ */ c.createElement("div", { className: g.imageCommonPanelRow }, /* @__PURE__ */ c.createElement("div", { className: g.imageCommonPanelColumn }, n.t("image-panel.transform.width"))), /* @__PURE__ */ c.createElement("div", { className: g.imageCommonPanelRow }, /* @__PURE__ */ c.createElement("div", { className: g.imageCommonPanelColumn }, /* @__PURE__ */ c.createElement(pe, { precision: 1, value: N, onChange: (C) => {
419
- We(C);
420
- }, className: g.imageCommonPanelInput }))))), /* @__PURE__ */ c.createElement("div", { className: O(g.imageCommonPanelColumn, g.imageCommonPanelSpan3) }, /* @__PURE__ */ c.createElement("label", null, /* @__PURE__ */ c.createElement("div", { className: g.imageCommonPanelRow }, /* @__PURE__ */ c.createElement("div", { className: g.imageCommonPanelColumn }, n.t("image-panel.transform.height"))), /* @__PURE__ */ c.createElement("div", { className: g.imageCommonPanelRow }, /* @__PURE__ */ c.createElement("div", { className: g.imageCommonPanelColumn }, /* @__PURE__ */ c.createElement(pe, { precision: 1, value: y, onChange: (C) => {
421
- $e(C);
422
- }, className: g.imageCommonPanelInput }))))), /* @__PURE__ */ c.createElement("div", { className: O(g.imageCommonPanelColumn, g.imageCommonPanelSpan3) }, /* @__PURE__ */ c.createElement("label", null, /* @__PURE__ */ c.createElement("div", { className: g.imageCommonPanelRow }, /* @__PURE__ */ c.createElement("div", { className: g.imageCommonPanelColumn }, n.t("image-panel.transform.lock"))), /* @__PURE__ */ c.createElement("div", { className: O(g.imageCommonPanelRow, g.imageCommonPanelRowVertical) }, /* @__PURE__ */ c.createElement("div", { className: g.imageCommonPanelColumn }, /* @__PURE__ */ c.createElement(At, { checked: Q, onChange: Et })))))), /* @__PURE__ */ c.createElement("div", { className: g.imageCommonPanelRow }, /* @__PURE__ */ c.createElement("div", { className: O(g.imageCommonPanelColumn, g.imageCommonPanelSpan3) }, /* @__PURE__ */ c.createElement("label", null, /* @__PURE__ */ c.createElement("div", { className: g.imageCommonPanelRow }, /* @__PURE__ */ c.createElement("div", { className: g.imageCommonPanelColumn }, n.t("image-panel.transform.x"))), /* @__PURE__ */ c.createElement("div", { className: g.imageCommonPanelRow }, /* @__PURE__ */ c.createElement("div", { className: g.imageCommonPanelColumn }, /* @__PURE__ */ c.createElement(pe, { precision: 1, value: M, onChange: (C) => {
423
- It(C);
424
- }, className: g.imageCommonPanelInput }))))), /* @__PURE__ */ c.createElement("div", { className: O(g.imageCommonPanelColumn, g.imageCommonPanelSpan3) }, /* @__PURE__ */ c.createElement("label", null, /* @__PURE__ */ c.createElement("div", { className: g.imageCommonPanelRow }, /* @__PURE__ */ c.createElement("div", { className: g.imageCommonPanelColumn }, n.t("image-panel.transform.y"))), /* @__PURE__ */ c.createElement("div", { className: g.imageCommonPanelRow }, /* @__PURE__ */ c.createElement("div", { className: g.imageCommonPanelColumn }, /* @__PURE__ */ c.createElement(pe, { precision: 1, value: U, onChange: (C) => {
425
- Pt(C);
426
- }, className: g.imageCommonPanelInput }))))), /* @__PURE__ */ c.createElement("div", { className: O(g.imageCommonPanelColumn, g.imageCommonPanelSpan3) }, /* @__PURE__ */ c.createElement("label", null, /* @__PURE__ */ c.createElement("div", { className: g.imageCommonPanelRow }, /* @__PURE__ */ c.createElement("div", { className: g.imageCommonPanelColumn }, n.t("image-panel.transform.rotate"))), /* @__PURE__ */ c.createElement("div", { className: g.imageCommonPanelRow }, /* @__PURE__ */ c.createElement("div", { className: g.imageCommonPanelColumn }, /* @__PURE__ */ c.createElement(pe, { precision: 1, value: ie, onChange: yt, className: g.imageCommonPanelInput })))))));
427
- };
428
- var E = /* @__PURE__ */ ((a) => (a.default = "0", a.left = "1", a.center = "2", a.right = "3", a.top = "4", a.middle = "5", a.bottom = "6", a.horizon = "7", a.vertical = "8", a))(E || {});
429
- const Je = {
417
+ const [min, max] = RANGE_DRAWING_ROTATION_LIMIT;
418
+ val < min && (val = min), val > max && (val = max);
419
+ const updateParam = { unitId, subUnitId, drawingId, drawingType, transform: { angle: val } };
420
+ setRotation(val), drawingManagerService.featurePluginUpdateNotification([updateParam]), transformer.refreshControls().changeNotification();
421
+ }, "handleRotationChange"), handleLockRatioChange = /* @__PURE__ */ __name((val) => {
422
+ setLockRatio(val), transformer.keepRatio = val;
423
+ }, "handleLockRatioChange"), gridDisplay = /* @__PURE__ */ __name((isShow) => isShow ? "block" : "none", "gridDisplay");
424
+ return /* @__PURE__ */ React.createElement("div", { className: clsx(styles$1.imageCommonPanelGrid, styles$1.imageCommonPanelBorder), style: { display: gridDisplay(transformShow) } }, /* @__PURE__ */ React.createElement("div", { className: styles$1.imageCommonPanelRow }, /* @__PURE__ */ React.createElement("div", { className: clsx(styles$1.imageCommonPanelColumn, styles$1.imageCommonPanelTitle) }, /* @__PURE__ */ React.createElement("div", null, localeService.t("image-panel.transform.title")))), /* @__PURE__ */ React.createElement("div", { className: styles$1.imageCommonPanelRow }, /* @__PURE__ */ React.createElement("div", { className: clsx(styles$1.imageCommonPanelColumn, styles$1.imageCommonPanelSpan3) }, /* @__PURE__ */ React.createElement("label", null, /* @__PURE__ */ React.createElement("div", { className: styles$1.imageCommonPanelRow }, /* @__PURE__ */ React.createElement("div", { className: styles$1.imageCommonPanelColumn }, localeService.t("image-panel.transform.width"))), /* @__PURE__ */ React.createElement("div", { className: styles$1.imageCommonPanelRow }, /* @__PURE__ */ React.createElement("div", { className: styles$1.imageCommonPanelColumn }, /* @__PURE__ */ React.createElement(InputNumber, { precision: 1, value: width, onChange: /* @__PURE__ */ __name((val) => {
425
+ handleWidthChange(val);
426
+ }, "onChange"), className: styles$1.imageCommonPanelInput }))))), /* @__PURE__ */ React.createElement("div", { className: clsx(styles$1.imageCommonPanelColumn, styles$1.imageCommonPanelSpan3) }, /* @__PURE__ */ React.createElement("label", null, /* @__PURE__ */ React.createElement("div", { className: styles$1.imageCommonPanelRow }, /* @__PURE__ */ React.createElement("div", { className: styles$1.imageCommonPanelColumn }, localeService.t("image-panel.transform.height"))), /* @__PURE__ */ React.createElement("div", { className: styles$1.imageCommonPanelRow }, /* @__PURE__ */ React.createElement("div", { className: styles$1.imageCommonPanelColumn }, /* @__PURE__ */ React.createElement(InputNumber, { precision: 1, value: height, onChange: /* @__PURE__ */ __name((val) => {
427
+ handleHeightChange(val);
428
+ }, "onChange"), className: styles$1.imageCommonPanelInput }))))), /* @__PURE__ */ React.createElement("div", { className: clsx(styles$1.imageCommonPanelColumn, styles$1.imageCommonPanelSpan3) }, /* @__PURE__ */ React.createElement("label", null, /* @__PURE__ */ React.createElement("div", { className: styles$1.imageCommonPanelRow }, /* @__PURE__ */ React.createElement("div", { className: styles$1.imageCommonPanelColumn }, localeService.t("image-panel.transform.lock"))), /* @__PURE__ */ React.createElement("div", { className: clsx(styles$1.imageCommonPanelRow, styles$1.imageCommonPanelRowVertical) }, /* @__PURE__ */ React.createElement("div", { className: styles$1.imageCommonPanelColumn }, /* @__PURE__ */ React.createElement(Checkbox, { checked: lockRatio, onChange: handleLockRatioChange })))))), /* @__PURE__ */ React.createElement("div", { className: styles$1.imageCommonPanelRow }, /* @__PURE__ */ React.createElement("div", { className: clsx(styles$1.imageCommonPanelColumn, styles$1.imageCommonPanelSpan3) }, /* @__PURE__ */ React.createElement("label", null, /* @__PURE__ */ React.createElement("div", { className: styles$1.imageCommonPanelRow }, /* @__PURE__ */ React.createElement("div", { className: styles$1.imageCommonPanelColumn }, localeService.t("image-panel.transform.x"))), /* @__PURE__ */ React.createElement("div", { className: styles$1.imageCommonPanelRow }, /* @__PURE__ */ React.createElement("div", { className: styles$1.imageCommonPanelColumn }, /* @__PURE__ */ React.createElement(InputNumber, { precision: 1, value: xPosition, onChange: /* @__PURE__ */ __name((val) => {
429
+ handleXChange(val);
430
+ }, "onChange"), className: styles$1.imageCommonPanelInput }))))), /* @__PURE__ */ React.createElement("div", { className: clsx(styles$1.imageCommonPanelColumn, styles$1.imageCommonPanelSpan3) }, /* @__PURE__ */ React.createElement("label", null, /* @__PURE__ */ React.createElement("div", { className: styles$1.imageCommonPanelRow }, /* @__PURE__ */ React.createElement("div", { className: styles$1.imageCommonPanelColumn }, localeService.t("image-panel.transform.y"))), /* @__PURE__ */ React.createElement("div", { className: styles$1.imageCommonPanelRow }, /* @__PURE__ */ React.createElement("div", { className: styles$1.imageCommonPanelColumn }, /* @__PURE__ */ React.createElement(InputNumber, { precision: 1, value: yPosition, onChange: /* @__PURE__ */ __name((val) => {
431
+ handleYChange(val);
432
+ }, "onChange"), className: styles$1.imageCommonPanelInput }))))), /* @__PURE__ */ React.createElement("div", { className: clsx(styles$1.imageCommonPanelColumn, styles$1.imageCommonPanelSpan3) }, /* @__PURE__ */ React.createElement("label", null, /* @__PURE__ */ React.createElement("div", { className: styles$1.imageCommonPanelRow }, /* @__PURE__ */ React.createElement("div", { className: styles$1.imageCommonPanelColumn }, localeService.t("image-panel.transform.rotate"))), /* @__PURE__ */ React.createElement("div", { className: styles$1.imageCommonPanelRow }, /* @__PURE__ */ React.createElement("div", { className: styles$1.imageCommonPanelColumn }, /* @__PURE__ */ React.createElement(InputNumber, { precision: 1, value: rotation, onChange: handleRotationChange, className: styles$1.imageCommonPanelInput })))))));
433
+ }, "DrawingTransform");
434
+ var AlignType = /* @__PURE__ */ ((AlignType2) => (AlignType2.default = "0", AlignType2.left = "1", AlignType2.center = "2", AlignType2.right = "3", AlignType2.top = "4", AlignType2.middle = "5", AlignType2.bottom = "6", AlignType2.horizon = "7", AlignType2.vertical = "8", AlignType2))(AlignType || {});
435
+ const SetDrawingAlignOperation = {
430
436
  id: "sheet.operation.set-image-align",
431
- type: Se.OPERATION,
432
- handler: (a, n) => !0
433
- }, Rn = (a) => {
434
- const n = V(ue), e = V(Y), { alignShow: t } = a, [r, o] = L(E.default), i = [
437
+ type: CommandType.OPERATION,
438
+ handler: /* @__PURE__ */ __name((accessor, params) => !0, "handler")
439
+ }, DrawingAlign = /* @__PURE__ */ __name((props) => {
440
+ const commandService = useDependency(ICommandService), localeService = useDependency(LocaleService), { alignShow } = props, [alignValue, setAlignValue] = useState(AlignType.default), alignOptions = [
435
441
  {
436
- label: e.t("image-panel.align.default"),
437
- value: E.default
442
+ label: localeService.t("image-panel.align.default"),
443
+ value: AlignType.default
438
444
  },
439
445
  {
440
446
  options: [
441
447
  {
442
- label: e.t("image-panel.align.left"),
443
- value: E.left
448
+ label: localeService.t("image-panel.align.left"),
449
+ value: AlignType.left
444
450
  },
445
451
  {
446
- label: e.t("image-panel.align.center"),
447
- value: E.center
452
+ label: localeService.t("image-panel.align.center"),
453
+ value: AlignType.center
448
454
  },
449
455
  {
450
- label: e.t("image-panel.align.right"),
451
- value: E.right
456
+ label: localeService.t("image-panel.align.right"),
457
+ value: AlignType.right
452
458
  }
453
459
  ]
454
460
  },
455
461
  {
456
462
  options: [
457
463
  {
458
- label: e.t("image-panel.align.top"),
459
- value: E.top
464
+ label: localeService.t("image-panel.align.top"),
465
+ value: AlignType.top
460
466
  },
461
467
  {
462
- label: e.t("image-panel.align.middle"),
463
- value: E.middle
468
+ label: localeService.t("image-panel.align.middle"),
469
+ value: AlignType.middle
464
470
  },
465
471
  {
466
- label: e.t("image-panel.align.bottom"),
467
- value: E.bottom
472
+ label: localeService.t("image-panel.align.bottom"),
473
+ value: AlignType.bottom
468
474
  }
469
475
  ]
470
476
  },
471
477
  {
472
478
  options: [
473
479
  {
474
- label: e.t("image-panel.align.horizon"),
475
- value: E.horizon
480
+ label: localeService.t("image-panel.align.horizon"),
481
+ value: AlignType.horizon
476
482
  },
477
483
  {
478
- label: e.t("image-panel.align.vertical"),
479
- value: E.vertical
484
+ label: localeService.t("image-panel.align.vertical"),
485
+ value: AlignType.vertical
480
486
  }
481
487
  ]
482
488
  }
483
489
  ];
484
- function s(m) {
485
- o(m), n.executeCommand(Je.id, {
486
- alignType: m
490
+ function handleAlignChange(value) {
491
+ setAlignValue(value), commandService.executeCommand(SetDrawingAlignOperation.id, {
492
+ alignType: value
487
493
  });
488
494
  }
489
- const l = (m) => m ? "block" : "none";
490
- return /* @__PURE__ */ c.createElement("div", { className: O(g.imageCommonPanelGrid, g.imageCommonPanelBorder), style: { display: l(t) } }, /* @__PURE__ */ c.createElement("div", { className: g.imageCommonPanelRow }, /* @__PURE__ */ c.createElement("div", { className: O(g.imageCommonPanelColumn, g.imageCommonPanelTitle) }, /* @__PURE__ */ c.createElement("div", null, e.t("image-panel.align.title")))), /* @__PURE__ */ c.createElement("div", { className: g.imageCommonPanelRow }, /* @__PURE__ */ c.createElement("div", { className: O(g.imageCommonPanelColumn) }, /* @__PURE__ */ c.createElement(lt, { value: r, options: i, onChange: s }))));
491
- }, Ze = {
495
+ __name(handleAlignChange, "handleAlignChange");
496
+ const gridDisplay = /* @__PURE__ */ __name((isShow) => isShow ? "block" : "none", "gridDisplay");
497
+ return /* @__PURE__ */ React.createElement("div", { className: clsx(styles$1.imageCommonPanelGrid, styles$1.imageCommonPanelBorder), style: { display: gridDisplay(alignShow) } }, /* @__PURE__ */ React.createElement("div", { className: styles$1.imageCommonPanelRow }, /* @__PURE__ */ React.createElement("div", { className: clsx(styles$1.imageCommonPanelColumn, styles$1.imageCommonPanelTitle) }, /* @__PURE__ */ React.createElement("div", null, localeService.t("image-panel.align.title")))), /* @__PURE__ */ React.createElement("div", { className: styles$1.imageCommonPanelRow }, /* @__PURE__ */ React.createElement("div", { className: clsx(styles$1.imageCommonPanelColumn) }, /* @__PURE__ */ React.createElement(Select, { value: alignValue, options: alignOptions, onChange: handleAlignChange }))));
498
+ }, "DrawingAlign"), OpenImageCropOperation = {
492
499
  id: "sheet.operation.open-image-crop",
493
- type: Se.OPERATION,
494
- handler: (a, n) => !0
495
- }, me = {
500
+ type: CommandType.OPERATION,
501
+ handler: /* @__PURE__ */ __name((accessor, params) => !0, "handler")
502
+ }, CloseImageCropOperation = {
496
503
  id: "sheet.operation.close-image-crop",
497
- type: Se.OPERATION,
498
- handler: (a, n) => !0
504
+ type: CommandType.OPERATION,
505
+ handler: /* @__PURE__ */ __name((accessor, params) => !0, "handler")
499
506
  };
500
- var B = /* @__PURE__ */ ((a) => (a.FREE = "0", a.R1_1 = "1", a.R16_9 = "2", a.R9_16 = "3", a.R5_4 = "4", a.R4_5 = "5", a.R4_3 = "6", a.R3_4 = "7", a.R3_2 = "8", a.R2_3 = "9", a))(B || {});
501
- const Le = {
507
+ var CropType = /* @__PURE__ */ ((CropType2) => (CropType2.FREE = "0", CropType2.R1_1 = "1", CropType2.R16_9 = "2", CropType2.R9_16 = "3", CropType2.R5_4 = "4", CropType2.R4_5 = "5", CropType2.R4_3 = "6", CropType2.R3_4 = "7", CropType2.R3_2 = "8", CropType2.R2_3 = "9", CropType2))(CropType || {});
508
+ const AutoImageCropOperation = {
502
509
  id: "sheet.operation.Auto-image-crop",
503
- type: Se.OPERATION,
504
- handler: (a, n) => !0
505
- }, Mn = (a) => {
506
- const n = V(ue), e = V(Y), { drawings: t, cropperShow: r } = a;
507
- if (t[0] == null)
510
+ type: CommandType.OPERATION,
511
+ handler: /* @__PURE__ */ __name((accessor, params) => !0, "handler")
512
+ }, ImageCropper = /* @__PURE__ */ __name((props) => {
513
+ const commandService = useDependency(ICommandService), localeService = useDependency(LocaleService), { drawings, cropperShow } = props;
514
+ if (drawings[0] == null)
508
515
  return;
509
- const [i, s] = L(B.FREE), l = ct(!1), m = [
516
+ const [cropValue, setCropValue] = useState(CropType.FREE), cropStateRef = useRef(!1), cropOptions = [
510
517
  {
511
- label: e.t("image-panel.crop.mode"),
512
- value: B.FREE
518
+ label: localeService.t("image-panel.crop.mode"),
519
+ value: CropType.FREE
513
520
  },
514
521
  {
515
522
  label: "1:1",
516
- value: B.R1_1
523
+ value: CropType.R1_1
517
524
  },
518
525
  {
519
526
  label: "16:9",
520
- value: B.R16_9
527
+ value: CropType.R16_9
521
528
  },
522
529
  {
523
530
  label: "9:16",
524
- value: B.R9_16
531
+ value: CropType.R9_16
525
532
  },
526
533
  {
527
534
  label: "5:4",
528
- value: B.R5_4
535
+ value: CropType.R5_4
529
536
  },
530
537
  {
531
538
  label: "4:5",
532
- value: B.R4_5
539
+ value: CropType.R4_5
533
540
  },
534
541
  {
535
542
  label: "4:3",
536
- value: B.R4_3
543
+ value: CropType.R4_3
537
544
  },
538
545
  {
539
546
  label: "3:4",
540
- value: B.R3_4
547
+ value: CropType.R3_4
541
548
  },
542
549
  {
543
550
  label: "3:2",
544
- value: B.R3_2
551
+ value: CropType.R3_2
545
552
  },
546
553
  {
547
554
  label: "2:3",
548
- value: B.R2_3
555
+ value: CropType.R2_3
549
556
  }
550
557
  ];
551
- be(() => {
552
- const f = n.onCommandExecuted((v) => {
553
- if (v.id === me.id) {
554
- const w = v.params;
555
- w != null && w.isAuto || (l.current = !1);
558
+ useEffect(() => {
559
+ const onChangeStartObserver = commandService.onCommandExecuted((command) => {
560
+ if (command.id === CloseImageCropOperation.id) {
561
+ const params = command.params;
562
+ params != null && params.isAuto || (cropStateRef.current = !1);
556
563
  }
557
564
  });
558
565
  return () => {
559
- f == null || f.dispose();
566
+ onChangeStartObserver == null || onChangeStartObserver.dispose();
560
567
  };
561
568
  }, []);
562
- function u(f) {
563
- s(f), l.current && n.executeCommand(Le.id, {
564
- cropType: f
569
+ function handleCropChange(value) {
570
+ setCropValue(value), cropStateRef.current && commandService.executeCommand(AutoImageCropOperation.id, {
571
+ cropType: value
565
572
  });
566
573
  }
567
- const d = (f) => f ? "block" : "none", h = (f) => {
568
- n.executeCommand(Le.id, {
569
- cropType: f
570
- }), l.current = !0;
571
- };
572
- return /* @__PURE__ */ c.createElement("div", { className: O(g.imageCommonPanelGrid, g.imageCommonPanelBorder), style: { display: d(r) } }, /* @__PURE__ */ c.createElement("div", { className: g.imageCommonPanelRow }, /* @__PURE__ */ c.createElement("div", { className: O(g.imageCommonPanelColumn, g.imageCommonPanelTitle) }, /* @__PURE__ */ c.createElement("div", null, e.t("image-panel.crop.title")))), /* @__PURE__ */ c.createElement("div", { className: O(g.imageCommonPanelRow, g.imageCommonPanelRowVertical) }, /* @__PURE__ */ c.createElement("div", { className: O(g.imageCommonPanelColumn, g.imageCommonPanelSpan2) }, /* @__PURE__ */ c.createElement(le, { size: "small", onClick: () => {
573
- h(i);
574
- } }, /* @__PURE__ */ c.createElement("span", { className: g.imageCommonPanelInline }, /* @__PURE__ */ c.createElement(ht, null), e.t("image-panel.crop.start")))), /* @__PURE__ */ c.createElement("div", { className: O(g.imageCommonPanelColumn, g.imageCommonPanelSpan2) }, /* @__PURE__ */ c.createElement(lt, { value: i, options: m, onChange: u }))));
575
- }, On = (a) => {
576
- const n = V(Y), e = V(he), t = V(ae), { hasGroup: r, drawings: o } = a, [i, s] = L(!1), [l, m] = L(!0), [u, d] = L(!0), h = (p) => p ? "block" : "none", f = () => {
577
- const p = t.getFocusDrawings(), { unitId: S, subUnitId: _ } = p[0], R = Ht.generateRandomId(10), b = Dt(0, 0, p.map((y) => y.transform || {})), N = {
578
- unitId: S,
579
- subUnitId: _,
580
- drawingId: R,
581
- drawingType: re.DRAWING_GROUP,
582
- transform: b
583
- }, I = p.map((y) => {
584
- const P = y.transform || { left: 0, top: 0 }, { unitId: M, subUnitId: D, drawingId: U } = y;
574
+ __name(handleCropChange, "handleCropChange");
575
+ const gridDisplay = /* @__PURE__ */ __name((isShow) => isShow ? "block" : "none", "gridDisplay"), onCropperBtnClick = /* @__PURE__ */ __name((val) => {
576
+ commandService.executeCommand(AutoImageCropOperation.id, {
577
+ cropType: val
578
+ }), cropStateRef.current = !0;
579
+ }, "onCropperBtnClick");
580
+ return /* @__PURE__ */ React.createElement("div", { className: clsx(styles$1.imageCommonPanelGrid, styles$1.imageCommonPanelBorder), style: { display: gridDisplay(cropperShow) } }, /* @__PURE__ */ React.createElement("div", { className: styles$1.imageCommonPanelRow }, /* @__PURE__ */ React.createElement("div", { className: clsx(styles$1.imageCommonPanelColumn, styles$1.imageCommonPanelTitle) }, /* @__PURE__ */ React.createElement("div", null, localeService.t("image-panel.crop.title")))), /* @__PURE__ */ React.createElement("div", { className: clsx(styles$1.imageCommonPanelRow, styles$1.imageCommonPanelRowVertical) }, /* @__PURE__ */ React.createElement("div", { className: clsx(styles$1.imageCommonPanelColumn, styles$1.imageCommonPanelSpan2) }, /* @__PURE__ */ React.createElement(Button, { size: "small", onClick: /* @__PURE__ */ __name(() => {
581
+ onCropperBtnClick(cropValue);
582
+ }, "onClick") }, /* @__PURE__ */ React.createElement("span", { className: styles$1.imageCommonPanelInline }, /* @__PURE__ */ React.createElement(CreateCopySingle, null), localeService.t("image-panel.crop.start")))), /* @__PURE__ */ React.createElement("div", { className: clsx(styles$1.imageCommonPanelColumn, styles$1.imageCommonPanelSpan2) }, /* @__PURE__ */ React.createElement(Select, { value: cropValue, options: cropOptions, onChange: handleCropChange }))));
583
+ }, "ImageCropper"), DrawingGroup = /* @__PURE__ */ __name((props) => {
584
+ const localeService = useDependency(LocaleService), renderManagerService = useDependency(IRenderManagerService), drawingManagerService = useDependency(IDrawingManagerService), { hasGroup, drawings } = props, [groupShow, setGroupShow] = useState(!1), [groupBtnShow, setGroupBtnShow] = useState(!0), [ungroupBtnShow, setUngroupBtnShow] = useState(!0), gridDisplay = /* @__PURE__ */ __name((isShow) => isShow ? "block" : "none", "gridDisplay"), onGroupBtnClick = /* @__PURE__ */ __name(() => {
585
+ const focusDrawings = drawingManagerService.getFocusDrawings(), { unitId, subUnitId } = focusDrawings[0], groupId = Tools.generateRandomId(10), groupTransform = getGroupState(0, 0, focusDrawings.map((o) => o.transform || {})), groupParam = {
586
+ unitId,
587
+ subUnitId,
588
+ drawingId: groupId,
589
+ drawingType: DrawingTypeEnum.DRAWING_GROUP,
590
+ transform: groupTransform
591
+ }, children = focusDrawings.map((drawing) => {
592
+ const transform = drawing.transform || { left: 0, top: 0 }, { unitId: unitId2, subUnitId: subUnitId2, drawingId } = drawing;
585
593
  return {
586
- unitId: M,
587
- subUnitId: D,
588
- drawingId: U,
594
+ unitId: unitId2,
595
+ subUnitId: subUnitId2,
596
+ drawingId,
589
597
  transform: {
590
- ...P,
591
- left: P.left - b.left,
592
- top: P.top - b.top
598
+ ...transform,
599
+ left: transform.left - groupTransform.left,
600
+ top: transform.top - groupTransform.top
593
601
  },
594
- groupId: R
602
+ groupId
595
603
  };
596
604
  });
597
- t.featurePluginGroupUpdateNotification([{
598
- parent: N,
599
- children: I
605
+ drawingManagerService.featurePluginGroupUpdateNotification([{
606
+ parent: groupParam,
607
+ children
600
608
  }]);
601
- }, v = (p) => {
602
- if (p.drawingType !== re.DRAWING_GROUP)
609
+ }, "onGroupBtnClick"), ungroup = /* @__PURE__ */ __name((param) => {
610
+ if (param.drawingType !== DrawingTypeEnum.DRAWING_GROUP)
603
611
  return;
604
- const { unitId: S, subUnitId: _, drawingId: R, transform: b = { width: 0, height: 0 } } = p;
605
- if (b == null)
612
+ const { unitId, subUnitId, drawingId, transform: groupTransform = { width: 0, height: 0 } } = param;
613
+ if (groupTransform == null)
606
614
  return;
607
- const N = t.getDrawingsByGroup({ unitId: S, subUnitId: _, drawingId: R });
608
- if (N.length === 0)
615
+ const objects = drawingManagerService.getDrawingsByGroup({ unitId, subUnitId, drawingId });
616
+ if (objects.length === 0)
609
617
  return;
610
- const I = N.map((y) => {
611
- const { transform: P } = y, { unitId: M, subUnitId: D, drawingId: U } = y, T = Tt(P || {}, b, b.width || 0, b.height || 0);
618
+ const children = objects.map((object) => {
619
+ const { transform } = object, { unitId: unitId2, subUnitId: subUnitId2, drawingId: drawingId2 } = object, newTransform = transformObjectOutOfGroup(transform || {}, groupTransform, groupTransform.width || 0, groupTransform.height || 0);
612
620
  return {
613
- unitId: M,
614
- subUnitId: D,
615
- drawingId: U,
621
+ unitId: unitId2,
622
+ subUnitId: subUnitId2,
623
+ drawingId: drawingId2,
616
624
  transform: {
617
- ...P,
618
- ...T
625
+ ...transform,
626
+ ...newTransform
619
627
  },
620
628
  groupId: void 0
621
629
  };
622
630
  });
623
631
  return {
624
- parent: p,
625
- children: I
632
+ parent: param,
633
+ children
626
634
  };
627
- }, w = () => {
628
- const S = t.getFocusDrawings().map(
629
- (_) => v(_)
630
- ).filter((_) => _ != null);
631
- S.length !== 0 && t.featurePluginUngroupUpdateNotification(S);
632
- };
633
- return be(() => {
634
- const p = o[0];
635
- if (p == null)
635
+ }, "ungroup"), onUngroupBtnClick = /* @__PURE__ */ __name(() => {
636
+ const params = drawingManagerService.getFocusDrawings().map(
637
+ (drawing) => ungroup(drawing)
638
+ ).filter((o) => o != null);
639
+ params.length !== 0 && drawingManagerService.featurePluginUngroupUpdateNotification(params);
640
+ }, "onUngroupBtnClick");
641
+ return useEffect(() => {
642
+ const drawingParam = drawings[0];
643
+ if (drawingParam == null)
636
644
  return;
637
- const { unitId: S } = p, _ = e.getRenderById(S), R = _ == null ? void 0 : _.scene;
638
- if (R == null)
645
+ const { unitId } = drawingParam, renderObject = renderManagerService.getRenderById(unitId), scene = renderObject == null ? void 0 : renderObject.scene;
646
+ if (scene == null)
639
647
  return;
640
- const b = R.getTransformerByCreate(), N = b.clearControl$.subscribe((y) => {
641
- y === !0 && s(!1);
642
- }), I = b.changeStart$.subscribe((y) => {
643
- const { objects: P } = y, M = Ge(P, t), D = M.filter((W) => (W == null ? void 0 : W.drawingType) === re.DRAWING_GROUP);
644
- let U = !1, T = !1;
645
- M.length > 1 && (U = !0), D.length > 0 && (T = !0), s(U || T), m(U), d(T);
648
+ const transformer = scene.getTransformerByCreate(), onClearControlObserver = transformer.clearControl$.subscribe((changeSelf) => {
649
+ changeSelf === !0 && setGroupShow(!1);
650
+ }), onChangeStartObserver = transformer.changeStart$.subscribe((state) => {
651
+ const { objects } = state, params = getUpdateParams(objects, drawingManagerService), groupParams = params.filter((o) => (o == null ? void 0 : o.drawingType) === DrawingTypeEnum.DRAWING_GROUP);
652
+ let groupBtnShow2 = !1, ungroupBtnShow2 = !1;
653
+ params.length > 1 && (groupBtnShow2 = !0), groupParams.length > 0 && (ungroupBtnShow2 = !0), setGroupShow(groupBtnShow2 || ungroupBtnShow2), setGroupBtnShow(groupBtnShow2), setUngroupBtnShow(ungroupBtnShow2);
646
654
  });
647
655
  return () => {
648
- I.unsubscribe(), N.unsubscribe();
656
+ onChangeStartObserver.unsubscribe(), onClearControlObserver.unsubscribe();
649
657
  };
650
- }, []), /* @__PURE__ */ c.createElement("div", { className: O(g.imageCommonPanelGrid, g.imageCommonPanelBorder), style: { display: h(r === !0 ? i : !1) } }, /* @__PURE__ */ c.createElement("div", { className: g.imageCommonPanelRow }, /* @__PURE__ */ c.createElement("div", { className: O(g.imageCommonPanelColumn, g.imageCommonPanelTitle) }, /* @__PURE__ */ c.createElement("div", null, n.t("image-panel.group.title")))), /* @__PURE__ */ c.createElement("div", { className: g.imageCommonPanelRow }, /* @__PURE__ */ c.createElement("div", { className: O(g.imageCommonPanelColumn, g.imageCommonPanelSpan2, g.imageCommonPanelColumnCenter) }, /* @__PURE__ */ c.createElement(le, { size: "small", onClick: () => {
651
- f();
652
- }, style: { display: h(l) } }, /* @__PURE__ */ c.createElement("span", { className: g.imageCommonPanelInline }, /* @__PURE__ */ c.createElement(ft, null), n.t("image-panel.group.group")))), /* @__PURE__ */ c.createElement("div", { className: O(g.imageCommonPanelColumn, g.imageCommonPanelSpan2, g.imageCommonPanelColumnCenter) }, /* @__PURE__ */ c.createElement(le, { size: "small", onClick: () => {
653
- w();
654
- }, style: { display: h(u) } }, /* @__PURE__ */ c.createElement("span", { className: g.imageCommonPanelInline }, /* @__PURE__ */ c.createElement(_t, null), n.t("image-panel.group.unGroup"))))));
655
- }, dr = (a) => {
656
- const n = V(ae), e = V(he), t = V(Y), { drawings: r, hasArrange: o = !0, hasTransform: i = !0, hasAlign: s = !0, hasCropper: l = !0, hasGroup: m = !0 } = a, u = r[0];
657
- if (u == null)
658
+ }, []), /* @__PURE__ */ React.createElement("div", { className: clsx(styles$1.imageCommonPanelGrid, styles$1.imageCommonPanelBorder), style: { display: gridDisplay(hasGroup === !0 ? groupShow : !1) } }, /* @__PURE__ */ React.createElement("div", { className: styles$1.imageCommonPanelRow }, /* @__PURE__ */ React.createElement("div", { className: clsx(styles$1.imageCommonPanelColumn, styles$1.imageCommonPanelTitle) }, /* @__PURE__ */ React.createElement("div", null, localeService.t("image-panel.group.title")))), /* @__PURE__ */ React.createElement("div", { className: styles$1.imageCommonPanelRow }, /* @__PURE__ */ React.createElement("div", { className: clsx(styles$1.imageCommonPanelColumn, styles$1.imageCommonPanelSpan2, styles$1.imageCommonPanelColumnCenter) }, /* @__PURE__ */ React.createElement(Button, { size: "small", onClick: /* @__PURE__ */ __name(() => {
659
+ onGroupBtnClick();
660
+ }, "onClick"), style: { display: gridDisplay(groupBtnShow) } }, /* @__PURE__ */ React.createElement("span", { className: styles$1.imageCommonPanelInline }, /* @__PURE__ */ React.createElement(GroupSingle, null), localeService.t("image-panel.group.group")))), /* @__PURE__ */ React.createElement("div", { className: clsx(styles$1.imageCommonPanelColumn, styles$1.imageCommonPanelSpan2, styles$1.imageCommonPanelColumnCenter) }, /* @__PURE__ */ React.createElement(Button, { size: "small", onClick: /* @__PURE__ */ __name(() => {
661
+ onUngroupBtnClick();
662
+ }, "onClick"), style: { display: gridDisplay(ungroupBtnShow) } }, /* @__PURE__ */ React.createElement("span", { className: styles$1.imageCommonPanelInline }, /* @__PURE__ */ React.createElement(UngroupSingle, null), localeService.t("image-panel.group.unGroup"))))));
663
+ }, "DrawingGroup"), DrawingCommonPanel = /* @__PURE__ */ __name((props) => {
664
+ const drawingManagerService = useDependency(IDrawingManagerService), renderManagerService = useDependency(IRenderManagerService), localeService = useDependency(LocaleService), { drawings, hasArrange = !0, hasTransform = !0, hasAlign = !0, hasCropper = !0, hasGroup = !0 } = props, drawingParam = drawings[0];
665
+ if (drawingParam == null)
658
666
  return;
659
- const { unitId: d } = u, h = e.getRenderById(d), f = h == null ? void 0 : h.scene;
660
- if (f == null)
667
+ const { unitId } = drawingParam, renderObject = renderManagerService.getRenderById(unitId), scene = renderObject == null ? void 0 : renderObject.scene;
668
+ if (scene == null)
661
669
  return;
662
- const v = f.getTransformerByCreate(), [w, p] = L(!0), [S, _] = L(!0), [R, b] = L(!1), [N, I] = L(!0), [y, P] = L(!1);
663
- return be(() => {
664
- const M = v.clearControl$.subscribe((T) => {
665
- T === !0 && (p(!1), _(!1), b(!1), I(!1), P(!0));
666
- }), D = v.changeStart$.subscribe((T) => {
667
- const { objects: ie } = T, W = Ge(ie, n);
668
- W.length === 0 ? (p(!1), _(!1), b(!1), I(!1), P(!0)) : W.length === 1 ? (p(!0), _(!0), b(!1), I(!0), P(!1)) : (p(!0), _(!1), b(!0), I(!1), P(!1));
669
- }), U = n.focus$.subscribe((T) => {
670
- T.length === 0 ? (p(!1), _(!1), b(!1), I(!1), P(!0)) : T.length === 1 ? (p(!0), _(!0), b(!1), I(!0), P(!1)) : (p(!0), _(!1), b(!0), I(!1), P(!1));
670
+ const transformer = scene.getTransformerByCreate(), [arrangeShow, setArrangeShow] = useState(!0), [transformShow, setTransformShow] = useState(!0), [alignShow, setAlignShow] = useState(!1), [cropperShow, setCropperShow] = useState(!0), [nullShow, setNullShow] = useState(!1);
671
+ return useEffect(() => {
672
+ const clearControlSub = transformer.clearControl$.subscribe((changeSelf) => {
673
+ changeSelf === !0 && (setArrangeShow(!1), setTransformShow(!1), setAlignShow(!1), setCropperShow(!1), setNullShow(!0));
674
+ }), changeStartSub = transformer.changeStart$.subscribe((state) => {
675
+ const { objects } = state, params = getUpdateParams(objects, drawingManagerService);
676
+ params.length === 0 ? (setArrangeShow(!1), setTransformShow(!1), setAlignShow(!1), setCropperShow(!1), setNullShow(!0)) : params.length === 1 ? (setArrangeShow(!0), setTransformShow(!0), setAlignShow(!1), setCropperShow(!0), setNullShow(!1)) : (setArrangeShow(!0), setTransformShow(!1), setAlignShow(!0), setCropperShow(!1), setNullShow(!1));
677
+ }), focusSub = drawingManagerService.focus$.subscribe((drawings2) => {
678
+ drawings2.length === 0 ? (setArrangeShow(!1), setTransformShow(!1), setAlignShow(!1), setCropperShow(!1), setNullShow(!0)) : drawings2.length === 1 ? (setArrangeShow(!0), setTransformShow(!0), setAlignShow(!1), setCropperShow(!0), setNullShow(!1)) : (setArrangeShow(!0), setTransformShow(!1), setAlignShow(!0), setCropperShow(!1), setNullShow(!1));
671
679
  });
672
680
  return () => {
673
- D.unsubscribe(), M.unsubscribe(), U.unsubscribe();
681
+ changeStartSub.unsubscribe(), clearControlSub.unsubscribe(), focusSub.unsubscribe();
674
682
  };
675
- }, []), /* @__PURE__ */ c.createElement(c.Fragment, null, /* @__PURE__ */ c.createElement("div", { style: { display: y === !0 ? "block" : "none", height: "100%" } }, /* @__PURE__ */ c.createElement("div", { style: { display: "flex", justifyContent: "center", alignItems: "center", height: "100%", top: "50%", marginTop: "-100px" } }, /* @__PURE__ */ c.createElement("span", null, t.t("image-panel.null")))), /* @__PURE__ */ c.createElement(In, { arrangeShow: o === !0 ? w : !1, drawings: r }), /* @__PURE__ */ c.createElement(En, { transformShow: i === !0 ? S : !1, drawings: r }), /* @__PURE__ */ c.createElement(Rn, { alignShow: s === !0 ? R : !1, drawings: r }), /* @__PURE__ */ c.createElement(Mn, { cropperShow: l === !0 ? N : !1, drawings: r }), /* @__PURE__ */ c.createElement(On, { hasGroup: m, drawings: r }));
676
- }, Nn = "univer-image-popup-menu", Dn = "univer-image-popup-menu-item", Tn = "univer-image-popup-menu-item-icon", Bn = "univer-image-popup-menu-item-title", jn = "univer-image-popup-menu-item-hide", Un = "univer-btn-container", Hn = "univer-btn-container-expand", Ce = {
677
- imagePopupMenu: Nn,
678
- imagePopupMenuItem: Dn,
679
- imagePopupMenuItemIcon: Tn,
680
- imagePopupMenuItemTitle: Bn,
681
- imagePopupMenuItemHide: jn,
682
- btnContainer: Un,
683
- btnContainerExpand: Hn
684
- }, Ln = (a) => {
685
- var v, w;
686
- const n = (w = (v = a.popup) == null ? void 0 : v.extraProps) == null ? void 0 : w.menuItems;
687
- if (!n)
683
+ }, []), /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("div", { style: { display: nullShow === !0 ? "block" : "none", height: "100%" } }, /* @__PURE__ */ React.createElement("div", { style: { display: "flex", justifyContent: "center", alignItems: "center", height: "100%", top: "50%", marginTop: "-100px" } }, /* @__PURE__ */ React.createElement("span", null, localeService.t("image-panel.null")))), /* @__PURE__ */ React.createElement(DrawingArrange, { arrangeShow: hasArrange === !0 ? arrangeShow : !1, drawings }), /* @__PURE__ */ React.createElement(DrawingTransform, { transformShow: hasTransform === !0 ? transformShow : !1, drawings }), /* @__PURE__ */ React.createElement(DrawingAlign, { alignShow: hasAlign === !0 ? alignShow : !1, drawings }), /* @__PURE__ */ React.createElement(ImageCropper, { cropperShow: hasCropper === !0 ? cropperShow : !1, drawings }), /* @__PURE__ */ React.createElement(DrawingGroup, { hasGroup, drawings }));
684
+ }, "DrawingCommonPanel"), imagePopupMenu = "univer-image-popup-menu", imagePopupMenuItem = "univer-image-popup-menu-item", imagePopupMenuItemIcon = "univer-image-popup-menu-item-icon", imagePopupMenuItemTitle = "univer-image-popup-menu-item-title", imagePopupMenuItemHide = "univer-image-popup-menu-item-hide", btnContainer = "univer-btn-container", btnContainerExpand = "univer-btn-container-expand", styles = {
685
+ imagePopupMenu,
686
+ imagePopupMenuItem,
687
+ imagePopupMenuItemIcon,
688
+ imagePopupMenuItemTitle,
689
+ imagePopupMenuItemHide,
690
+ btnContainer,
691
+ btnContainerExpand
692
+ }, ImagePopupMenu = /* @__PURE__ */ __name((props) => {
693
+ var _a7, _b;
694
+ const menuItems = (_b = (_a7 = props.popup) == null ? void 0 : _a7.extraProps) == null ? void 0 : _b.menuItems;
695
+ if (!menuItems)
688
696
  return null;
689
- const e = V(ue), t = V(Y), [r, o] = L(!1), [i, s] = L(!1), l = () => {
690
- s(!0);
691
- }, m = () => {
692
- s(!1);
693
- }, u = (p) => {
694
- o(p);
695
- }, d = (p) => {
696
- e.executeCommand(p.commandId, p.commandParams), o(!1);
697
- }, h = r || i, f = n.filter((p) => !p.disable);
698
- return /* @__PURE__ */ c.createElement(
697
+ const commandService = useDependency(ICommandService), localeService = useDependency(LocaleService), [visible, setVisible] = useState(!1), [isHovered, setHovered] = useState(!1), handleMouseEnter = /* @__PURE__ */ __name(() => {
698
+ setHovered(!0);
699
+ }, "handleMouseEnter"), handleMouseLeave = /* @__PURE__ */ __name(() => {
700
+ setHovered(!1);
701
+ }, "handleMouseLeave"), onVisibleChange = /* @__PURE__ */ __name((visible2) => {
702
+ setVisible(visible2);
703
+ }, "onVisibleChange"), handleClick = /* @__PURE__ */ __name((item) => {
704
+ commandService.executeCommand(item.commandId, item.commandParams), setVisible(!1);
705
+ }, "handleClick"), showMore = visible || isHovered, availableMenu = menuItems.filter((item) => !item.disable);
706
+ return /* @__PURE__ */ React.createElement(
699
707
  "div",
700
708
  {
701
- onMouseEnter: l,
702
- onMouseLeave: m
709
+ onMouseEnter: handleMouseEnter,
710
+ onMouseLeave: handleMouseLeave
703
711
  },
704
- /* @__PURE__ */ c.createElement(
705
- xt,
712
+ /* @__PURE__ */ React.createElement(
713
+ Dropdown,
706
714
  {
707
715
  placement: "bottomLeft",
708
716
  trigger: ["click"],
709
- overlay: /* @__PURE__ */ c.createElement("ul", { className: Ce.imagePopupMenu }, f.map((p) => /* @__PURE__ */ c.createElement(
717
+ overlay: /* @__PURE__ */ React.createElement("ul", { className: styles.imagePopupMenu }, availableMenu.map((item) => /* @__PURE__ */ React.createElement(
710
718
  "li",
711
719
  {
712
- key: p.index,
713
- onClick: () => d(p),
714
- className: Ce.imagePopupMenuItem
720
+ key: item.index,
721
+ onClick: /* @__PURE__ */ __name(() => handleClick(item), "onClick"),
722
+ className: styles.imagePopupMenuItem
715
723
  },
716
- /* @__PURE__ */ c.createElement("span", { className: Ce.imagePopupMenuItemTitle }, t.t(p.label))
724
+ /* @__PURE__ */ React.createElement("span", { className: styles.imagePopupMenuItemTitle }, localeService.t(item.label))
717
725
  ))),
718
- visible: r,
719
- onVisibleChange: u
726
+ visible,
727
+ onVisibleChange
720
728
  },
721
- /* @__PURE__ */ c.createElement(
729
+ /* @__PURE__ */ React.createElement(
722
730
  "div",
723
731
  {
724
- className: O(Ce.btnContainer, {
725
- [Ce.btnContainerExpand]: r
732
+ className: clsx(styles.btnContainer, {
733
+ [styles.btnContainerExpand]: visible
726
734
  })
727
735
  },
728
- /* @__PURE__ */ c.createElement(
729
- ut,
736
+ /* @__PURE__ */ React.createElement(
737
+ Autofill,
730
738
  {
731
739
  style: { color: "#35322B" },
732
740
  extend: { colorChannel1: "rgb(var(--green-700, #409f11))" }
733
741
  }
734
742
  ),
735
- h && /* @__PURE__ */ c.createElement(pt, { style: { color: "#CCCCCC", fontSize: "8px", marginLeft: "8px" } })
743
+ showMore && /* @__PURE__ */ React.createElement(MoreDownSingle, { style: { color: "#CCCCCC", fontSize: "8px", marginLeft: "8px" } })
736
744
  )
737
745
  )
738
746
  );
739
- }, An = "COMPONENT_IMAGE_POPUP_MENU";
740
- var xn = Object.defineProperty, Vn = Object.getOwnPropertyDescriptor, Gn = (a, n, e, t) => {
741
- for (var r = t > 1 ? void 0 : t ? Vn(n, e) : n, o = a.length - 1, i; o >= 0; o--)
742
- (i = a[o]) && (r = (t ? i(n, e, r) : i(r)) || r);
743
- return t && r && xn(n, e, r), r;
744
- }, Me = (a, n) => (e, t) => n(e, t, a);
745
- let De = class extends Ae {
746
- constructor(n, e, t, r) {
747
+ }, "ImagePopupMenu"), COMPONENT_IMAGE_POPUP_MENU = "COMPONENT_IMAGE_POPUP_MENU";
748
+ var __defProp$4 = Object.defineProperty, __getOwnPropDesc$4 = Object.getOwnPropertyDescriptor, __decorateClass$4 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
749
+ for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$4(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
750
+ (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
751
+ return kind && result && __defProp$4(target, key, result), result;
752
+ }, "__decorateClass$4"), __decorateParam$4 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$4"), _a2;
753
+ let DrawingUpdateController = (_a2 = class extends Disposable {
754
+ constructor(_currentUniverService, _commandService, _renderManagerService, _drawingManagerService) {
747
755
  super();
748
- te(this, "_sceneListenerOnDrawingMap", /* @__PURE__ */ new WeakSet());
749
- this._currentUniverService = n, this._commandService = e, this._renderManagerService = t, this._drawingManagerService = r, this._initialize();
756
+ __publicField(this, "_sceneListenerOnDrawingMap", /* @__PURE__ */ new WeakSet());
757
+ this._currentUniverService = _currentUniverService, this._commandService = _commandService, this._renderManagerService = _renderManagerService, this._drawingManagerService = _drawingManagerService, this._initialize();
750
758
  }
751
759
  dispose() {
752
760
  super.dispose();
@@ -755,39 +763,39 @@ let De = class extends Ae {
755
763
  this._recoveryImages(), this._drawingAddListener(), this._drawingRemoveListener(), this._drawingUpdateListener(), this._commandExecutedListener(), this._drawingArrangeListener(), this._drawingGroupListener(), this._drawingRefreshListener(), this._drawingVisibleListener();
756
764
  }
757
765
  _recoveryImages() {
758
- const n = this._drawingManagerService.drawingManagerData, e = Ke(this._currentUniverService);
759
- if (e == null)
766
+ const drawingList = this._drawingManagerService.drawingManagerData, info = getCurrentUnitInfo(this._currentUniverService);
767
+ if (info == null)
760
768
  return;
761
- const { unitId: t, subUnitId: r } = e;
762
- Object.keys(n).forEach((o) => {
763
- Object.keys(n[o]).forEach((i) => {
764
- const s = n[o][i].data;
765
- s == null || o !== t || i !== r || Object.keys(s).forEach((l) => {
766
- s[l] && this._insertDrawing([{ unitId: o, subUnitId: i, drawingId: l }]);
769
+ const { unitId: currentUnitId, subUnitId: currentSubUnitId } = info;
770
+ Object.keys(drawingList).forEach((unitId) => {
771
+ Object.keys(drawingList[unitId]).forEach((subUnitId) => {
772
+ const drawingMap = drawingList[unitId][subUnitId].data;
773
+ drawingMap == null || unitId !== currentUnitId || subUnitId !== currentSubUnitId || Object.keys(drawingMap).forEach((drawingId) => {
774
+ drawingMap[drawingId] && this._insertDrawing([{ unitId, subUnitId, drawingId }]);
767
775
  });
768
776
  });
769
777
  });
770
778
  }
771
779
  _commandExecutedListener() {
772
780
  this.disposeWithMe(
773
- this._commandService.onCommandExecuted((n) => {
774
- if (n.id === Je.id) {
775
- const e = n.params;
776
- if (e == null)
781
+ this._commandService.onCommandExecuted((command) => {
782
+ if (command.id === SetDrawingAlignOperation.id) {
783
+ const params = command.params;
784
+ if (params == null)
777
785
  return;
778
- this._drawingAlign(e);
786
+ this._drawingAlign(params);
779
787
  }
780
788
  })
781
789
  );
782
790
  }
783
791
  _drawingGroupListener() {
784
792
  this.disposeWithMe(
785
- this._drawingManagerService.group$.subscribe((n) => {
786
- this._groupDrawings(n);
793
+ this._drawingManagerService.group$.subscribe((params) => {
794
+ this._groupDrawings(params);
787
795
  })
788
796
  ), this.disposeWithMe(
789
- this._drawingManagerService.ungroup$.subscribe((n) => {
790
- this._ungroupDrawings(n);
797
+ this._drawingManagerService.ungroup$.subscribe((params) => {
798
+ this._ungroupDrawings(params);
791
799
  })
792
800
  );
793
801
  }
@@ -811,38 +819,38 @@ let De = class extends Ae {
811
819
  // break;
812
820
  // }
813
821
  // }
814
- _getSceneAndTransformerByDrawingSearch(n) {
815
- if (n == null)
822
+ _getSceneAndTransformerByDrawingSearch(unitId) {
823
+ if (unitId == null)
816
824
  return;
817
- const e = this._renderManagerService.getRenderById(n), t = e == null ? void 0 : e.scene;
818
- if (t == null)
825
+ const renderObject = this._renderManagerService.getRenderById(unitId), scene = renderObject == null ? void 0 : renderObject.scene;
826
+ if (scene == null)
819
827
  return null;
820
- const r = t.getTransformerByCreate();
821
- return { scene: t, transformer: r };
828
+ const transformer = scene.getTransformerByCreate();
829
+ return { scene, transformer };
822
830
  }
823
- _groupDrawings(n) {
824
- n.forEach((e) => {
825
- this._groupDrawing(e);
831
+ _groupDrawings(drawings) {
832
+ drawings.forEach((drawing) => {
833
+ this._groupDrawing(drawing);
826
834
  });
827
835
  }
828
- _groupDrawing(n) {
829
- const { parent: e, children: t } = n, { unitId: r, subUnitId: o, drawingId: i } = e, s = this._getSceneAndTransformerByDrawingSearch(e.unitId);
830
- if (s == null)
836
+ _groupDrawing(params) {
837
+ const { parent, children } = params, { unitId, subUnitId, drawingId } = parent, renderObject = this._getSceneAndTransformerByDrawingSearch(parent.unitId);
838
+ if (renderObject == null)
831
839
  return;
832
- const { scene: l, transformer: m } = s;
833
- this._commandService.syncExecuteCommand(me.id);
834
- const u = [];
835
- if (t.forEach((f) => {
836
- const v = G(f), w = l.getObjectIncludeInGroup(v);
837
- if (w == null || u.includes(w))
840
+ const { scene, transformer } = renderObject;
841
+ this._commandService.syncExecuteCommand(CloseImageCropOperation.id);
842
+ const objects = [];
843
+ if (children.forEach((drawing) => {
844
+ const drawingShapeKey = getDrawingShapeKeyByDrawingSearch(drawing), object = scene.getObjectIncludeInGroup(drawingShapeKey);
845
+ if (object == null || objects.includes(object))
838
846
  return;
839
- u.push(w);
840
- const { transform: p } = f;
841
- p != null && (w.classType === Qe.GROUP ? w.transformByState({ left: p.left, top: p.top }) : w.transformByState(p));
842
- }), u.length === 0)
847
+ objects.push(object);
848
+ const { transform } = drawing;
849
+ transform != null && (object.classType === RENDER_CLASS_TYPE.GROUP ? object.transformByState({ left: transform.left, top: transform.top }) : object.transformByState(transform));
850
+ }), objects.length === 0)
843
851
  return;
844
- const d = G({ unitId: r, subUnitId: o, drawingId: i }), h = new ve(d);
845
- l.addObject(h, Ye).attachTransformerTo(h), h.addObjects(...u), e.transform && h.transformByState({ left: e.transform.left, top: e.transform.top }), m.clearSelectedObjects(), m.setSelectedControl(h);
852
+ const groupKey = getDrawingShapeKeyByDrawingSearch({ unitId, subUnitId, drawingId }), group = new Group(groupKey);
853
+ scene.addObject(group, DRAWING_OBJECT_LAYER_INDEX).attachTransformerTo(group), group.addObjects(...objects), parent.transform && group.transformByState({ left: parent.transform.left, top: parent.transform.top }), transformer.clearSelectedObjects(), transformer.setSelectedControl(group);
846
854
  }
847
855
  // private _regroupDrawings(drawings: IDrawingSearch[]) {
848
856
  // const renderObject = this._getSceneAndTransformerByDrawingSearch(drawings[0].unitId);
@@ -878,127 +886,127 @@ let De = class extends Ae {
878
886
  // transformer.clearSelectedObjects();
879
887
  // transformer.setSelectedControl(firstGroup);
880
888
  // }
881
- _ungroupDrawings(n) {
882
- n.forEach((e) => {
883
- this._ungroupDrawing(e);
889
+ _ungroupDrawings(drawings) {
890
+ drawings.forEach((drawing) => {
891
+ this._ungroupDrawing(drawing);
884
892
  });
885
893
  }
886
- _ungroupDrawing(n) {
887
- const { parent: e, children: t } = n, r = this._getSceneAndTransformerByDrawingSearch(e.unitId);
888
- if (r == null)
894
+ _ungroupDrawing(drawing) {
895
+ const { parent, children } = drawing, renderObject = this._getSceneAndTransformerByDrawingSearch(parent.unitId);
896
+ if (renderObject == null)
889
897
  return;
890
- const { scene: o, transformer: i } = r;
891
- t.forEach((d) => {
892
- const h = G(d), f = o.getObjectIncludeInGroup(h);
893
- if (f == null)
898
+ const { scene, transformer } = renderObject;
899
+ children.forEach((drawing2) => {
900
+ const drawingKey = getDrawingShapeKeyByDrawingSearch(drawing2), object = scene.getObjectIncludeInGroup(drawingKey);
901
+ if (object == null)
894
902
  return !0;
895
- if (f == null)
903
+ if (object == null)
896
904
  return;
897
- const { transform: v } = d;
898
- v != null && (f.classType === Qe.GROUP ? f.transformByState({ left: v.left, top: v.top }) : f.transformByState(v));
905
+ const { transform } = drawing2;
906
+ transform != null && (object.classType === RENDER_CLASS_TYPE.GROUP ? object.transformByState({ left: transform.left, top: transform.top }) : object.transformByState(transform));
899
907
  });
900
- const s = G(e), l = o.getObject(s), { width: m, height: u } = l;
901
- l.getObjects().forEach((d) => {
902
- l.removeSelfObjectAndTransform(d.oKey, m, u);
903
- }), l.dispose(), i.clearSelectedObjects();
904
- }
905
- _drawingAlign(n) {
906
- const { alignType: e } = n, t = this._drawingManagerService.getFocusDrawings();
907
- if (e === E.default)
908
+ const groupKey = getDrawingShapeKeyByDrawingSearch(parent), group = scene.getObject(groupKey), { width, height } = group;
909
+ group.getObjects().forEach((object) => {
910
+ group.removeSelfObjectAndTransform(object.oKey, width, height);
911
+ }), group.dispose(), transformer.clearSelectedObjects();
912
+ }
913
+ _drawingAlign(params) {
914
+ const { alignType } = params, drawings = this._drawingManagerService.getFocusDrawings();
915
+ if (alignType === AlignType.default)
908
916
  return;
909
- const r = [];
910
- let o = Number.POSITIVE_INFINITY, i = Number.POSITIVE_INFINITY, s = Number.NEGATIVE_INFINITY, l = Number.NEGATIVE_INFINITY, m = 0;
911
- t.forEach((u) => {
912
- const { unitId: d, subUnitId: h, drawingId: f, drawingType: v } = u, w = this._drawingManagerService.getDrawingByParam({ unitId: d, subUnitId: h, drawingId: f });
913
- if (w == null || w.transform == null)
917
+ const drawingTransformCaches = [];
918
+ let minLeft = Number.POSITIVE_INFINITY, minTop = Number.POSITIVE_INFINITY, maxRight = Number.NEGATIVE_INFINITY, maxBottom = Number.NEGATIVE_INFINITY, drawingCount = 0;
919
+ drawings.forEach((drawing) => {
920
+ const { unitId, subUnitId, drawingId, drawingType } = drawing, drawingParam = this._drawingManagerService.getDrawingByParam({ unitId, subUnitId, drawingId });
921
+ if (drawingParam == null || drawingParam.transform == null)
914
922
  return;
915
- r.push({
916
- unitId: d,
917
- subUnitId: h,
918
- drawingId: f,
919
- drawingType: v,
920
- transform: w.transform
923
+ drawingTransformCaches.push({
924
+ unitId,
925
+ subUnitId,
926
+ drawingId,
927
+ drawingType,
928
+ transform: drawingParam.transform
921
929
  });
922
- const { left: p = 0, top: S = 0, width: _ = 0, height: R = 0 } = w.transform;
923
- o = Math.min(o, p), i = Math.min(i, S), s = Math.max(s, p + _), l = Math.max(l, S + R), m++;
924
- }), m !== 0 && (this._sortDrawingTransform(r, e), this._applyAlignType(r, e, o, i, s, l, m));
930
+ const { left = 0, top = 0, width = 0, height = 0 } = drawingParam.transform;
931
+ minLeft = Math.min(minLeft, left), minTop = Math.min(minTop, top), maxRight = Math.max(maxRight, left + width), maxBottom = Math.max(maxBottom, top + height), drawingCount++;
932
+ }), drawingCount !== 0 && (this._sortDrawingTransform(drawingTransformCaches, alignType), this._applyAlignType(drawingTransformCaches, alignType, minLeft, minTop, maxRight, maxBottom, drawingCount));
925
933
  }
926
- _applyAlignType(n, e, t, r, o, i, s) {
927
- const l = Math.round((o - t) / s * 10) / 10, m = Math.round((i - r) / s * 10) / 10, u = [], d = this._getSceneAndTransformerByDrawingSearch(n[0].unitId);
928
- if (d == null)
934
+ _applyAlignType(drawingTransformCaches, alignType, minLeft, minTop, maxRight, maxBottom, drawingCount) {
935
+ const averageHorizon = Math.round((maxRight - minLeft) / drawingCount * 10) / 10, averageVertical = Math.round((maxBottom - minTop) / drawingCount * 10) / 10, updateParams = [], renderObject = this._getSceneAndTransformerByDrawingSearch(drawingTransformCaches[0].unitId);
936
+ if (renderObject == null)
929
937
  return;
930
- const { scene: h, transformer: f } = d;
931
- n.forEach((v, w) => {
932
- const { unitId: p, subUnitId: S, drawingId: _, transform: R, drawingType: b } = v, { left: N = 0, top: I = 0, width: y = 0, height: P = 0 } = R;
933
- let M = N, D = I;
934
- switch (e) {
935
- case E.left:
936
- M = t;
938
+ const { scene, transformer } = renderObject;
939
+ drawingTransformCaches.forEach((drawingTransformCache, index) => {
940
+ const { unitId, subUnitId, drawingId, transform, drawingType } = drawingTransformCache, { left = 0, top = 0, width = 0, height = 0 } = transform;
941
+ let newLeft = left, newTop = top;
942
+ switch (alignType) {
943
+ case AlignType.left:
944
+ newLeft = minLeft;
937
945
  break;
938
- case E.center:
939
- M = t + (o - t) / 2 - y / 2;
946
+ case AlignType.center:
947
+ newLeft = minLeft + (maxRight - minLeft) / 2 - width / 2;
940
948
  break;
941
- case E.right:
942
- M = o - y;
949
+ case AlignType.right:
950
+ newLeft = maxRight - width;
943
951
  break;
944
- case E.top:
945
- D = r;
952
+ case AlignType.top:
953
+ newTop = minTop;
946
954
  break;
947
- case E.middle:
948
- D = r + (i - r) / 2 - P / 2;
955
+ case AlignType.middle:
956
+ newTop = minTop + (maxBottom - minTop) / 2 - height / 2;
949
957
  break;
950
- case E.bottom:
951
- D = i - P;
958
+ case AlignType.bottom:
959
+ newTop = maxBottom - height;
952
960
  break;
953
- case E.horizon:
954
- M = t + l * w;
961
+ case AlignType.horizon:
962
+ newLeft = minLeft + averageHorizon * index;
955
963
  break;
956
- case E.vertical:
957
- D = r + m * w;
964
+ case AlignType.vertical:
965
+ newTop = minTop + averageVertical * index;
958
966
  break;
959
967
  }
960
- (M !== N || D !== I) && u.push({
961
- unitId: p,
962
- subUnitId: S,
963
- drawingId: _,
964
- drawingType: b,
968
+ (newLeft !== left || newTop !== top) && updateParams.push({
969
+ unitId,
970
+ subUnitId,
971
+ drawingId,
972
+ drawingType,
965
973
  transform: {
966
- left: M,
967
- top: D
974
+ left: newLeft,
975
+ top: newTop
968
976
  }
969
977
  });
970
- }), this._drawingManagerService.featurePluginUpdateNotification(u), f.refreshControls().changeNotification();
971
- }
972
- _sortDrawingTransform(n, e) {
973
- n.sort((t, r) => {
974
- const o = t.transform, i = r.transform, {
975
- left: s = 0,
976
- top: l = 0,
977
- width: m = 0,
978
- height: u = 0
979
- } = o, {
980
- left: d = 0,
981
- top: h = 0,
982
- width: f = 0,
983
- height: v = 0
984
- } = i;
985
- switch (e) {
986
- case E.left:
987
- return s - d;
988
- case E.center:
989
- return s + m / 2 - (d + f / 2);
990
- case E.right:
991
- return s + m - (d + f);
992
- case E.top:
993
- return l - h;
994
- case E.middle:
995
- return l + u / 2 - (h + v / 2);
996
- case E.bottom:
997
- return l + u - (h + v);
998
- case E.horizon:
999
- return s + m / 2 - (d + f / 2);
1000
- case E.vertical:
1001
- return l + u / 2 - (h + v / 2);
978
+ }), this._drawingManagerService.featurePluginUpdateNotification(updateParams), transformer.refreshControls().changeNotification();
979
+ }
980
+ _sortDrawingTransform(drawingTransformCaches, alignType) {
981
+ drawingTransformCaches.sort((a, b) => {
982
+ const aTransform = a.transform, bTransform = b.transform, {
983
+ left: aLeft = 0,
984
+ top: aTop = 0,
985
+ width: aWidth = 0,
986
+ height: aHeight = 0
987
+ } = aTransform, {
988
+ left: bLeft = 0,
989
+ top: bTop = 0,
990
+ width: bWidth = 0,
991
+ height: bHeight = 0
992
+ } = bTransform;
993
+ switch (alignType) {
994
+ case AlignType.left:
995
+ return aLeft - bLeft;
996
+ case AlignType.center:
997
+ return aLeft + aWidth / 2 - (bLeft + bWidth / 2);
998
+ case AlignType.right:
999
+ return aLeft + aWidth - (bLeft + bWidth);
1000
+ case AlignType.top:
1001
+ return aTop - bTop;
1002
+ case AlignType.middle:
1003
+ return aTop + aHeight / 2 - (bTop + bHeight / 2);
1004
+ case AlignType.bottom:
1005
+ return aTop + aHeight - (bTop + bHeight);
1006
+ case AlignType.horizon:
1007
+ return aLeft + aWidth / 2 - (bLeft + bWidth / 2);
1008
+ case AlignType.vertical:
1009
+ return aTop + aHeight / 2 - (bTop + bHeight / 2);
1002
1010
  default:
1003
1011
  return 0;
1004
1012
  }
@@ -1006,60 +1014,60 @@ let De = class extends Ae {
1006
1014
  }
1007
1015
  _drawingArrangeListener() {
1008
1016
  this.disposeWithMe(
1009
- this._drawingManagerService.order$.subscribe((n) => {
1010
- this._drawingArrange(n);
1017
+ this._drawingManagerService.order$.subscribe((params) => {
1018
+ this._drawingArrange(params);
1011
1019
  })
1012
1020
  );
1013
1021
  }
1014
- _drawingArrange(n) {
1015
- const { unitId: e, subUnitId: t, drawingIds: r } = n, o = this._getSceneAndTransformerByDrawingSearch(e);
1016
- if (o == null)
1022
+ _drawingArrange(params) {
1023
+ const { unitId, subUnitId, drawingIds } = params, renderObject = this._getSceneAndTransformerByDrawingSearch(unitId);
1024
+ if (renderObject == null)
1017
1025
  return;
1018
- const { scene: i } = o;
1019
- r.forEach((s) => {
1020
- const l = G({ unitId: e, subUnitId: t, drawingId: s }), m = i.fuzzyMathObjects(l, !0);
1021
- if (m == null || m.length === 0)
1026
+ const { scene } = renderObject;
1027
+ drawingIds.forEach((drawingId) => {
1028
+ const oKey = getDrawingShapeKeyByDrawingSearch({ unitId, subUnitId, drawingId }), drawingShapes = scene.fuzzyMathObjects(oKey, !0);
1029
+ if (drawingShapes == null || drawingShapes.length === 0)
1022
1030
  return;
1023
- const u = this._drawingManagerService.getDrawingOrder(e, t).indexOf(s);
1024
- for (const d of m)
1025
- d.setProps({ zIndex: u }), d.makeDirty();
1031
+ const index = this._drawingManagerService.getDrawingOrder(unitId, subUnitId).indexOf(drawingId);
1032
+ for (const shape of drawingShapes)
1033
+ shape.setProps({ zIndex: index }), shape.makeDirty();
1026
1034
  });
1027
1035
  }
1028
1036
  _drawingAddListener() {
1029
1037
  this.disposeWithMe(
1030
- this._drawingManagerService.add$.subscribe((n) => {
1031
- this._insertDrawing(n);
1038
+ this._drawingManagerService.add$.subscribe((params) => {
1039
+ this._insertDrawing(params);
1032
1040
  })
1033
1041
  );
1034
1042
  }
1035
- _insertDrawing(n) {
1036
- const e = [];
1037
- n.forEach((t) => {
1038
- const { unitId: r, subUnitId: o, drawingId: i } = t;
1039
- if (this._drawingManagerService.getDrawingByParam(t) == null)
1043
+ _insertDrawing(params) {
1044
+ const sceneList = [];
1045
+ params.forEach((param) => {
1046
+ const { unitId, subUnitId, drawingId } = param;
1047
+ if (this._drawingManagerService.getDrawingByParam(param) == null)
1040
1048
  return;
1041
- const l = this._getSceneAndTransformerByDrawingSearch(r);
1042
- if (l == null)
1049
+ const renderObject = this._getSceneAndTransformerByDrawingSearch(unitId);
1050
+ if (renderObject == null)
1043
1051
  return;
1044
- const { scene: m, transformer: u } = l;
1045
- e.includes(m) || e.push(m);
1046
- }), e.forEach((t) => {
1047
- this._sceneListenerOnDrawingMap.has(t) || (this._addListenerOnDrawing(t), this._sceneListenerOnDrawingMap.add(t));
1052
+ const { scene, transformer } = renderObject;
1053
+ sceneList.includes(scene) || sceneList.push(scene);
1054
+ }), sceneList.forEach((scene) => {
1055
+ this._sceneListenerOnDrawingMap.has(scene) || (this._addListenerOnDrawing(scene), this._sceneListenerOnDrawingMap.add(scene));
1048
1056
  });
1049
1057
  }
1050
1058
  _drawingRemoveListener() {
1051
1059
  this.disposeWithMe(
1052
- this._drawingManagerService.remove$.subscribe((n) => {
1053
- n.forEach((e) => {
1054
- var u;
1055
- const { unitId: t, subUnitId: r, drawingId: o } = e, i = this._getSceneAndTransformerByDrawingSearch(t);
1056
- if (i == null)
1060
+ this._drawingManagerService.remove$.subscribe((params) => {
1061
+ params.forEach((param) => {
1062
+ var _a7;
1063
+ const { unitId, subUnitId, drawingId } = param, renderObject = this._getSceneAndTransformerByDrawingSearch(unitId);
1064
+ if (renderObject == null)
1057
1065
  return;
1058
- const { scene: s } = i, l = G({ unitId: t, subUnitId: r, drawingId: o }), m = s.fuzzyMathObjects(l, !0);
1059
- if (m.length > 0) {
1060
- for (const d of m)
1061
- d.dispose();
1062
- (u = s.getTransformer()) == null || u.clearSelectedObjects();
1066
+ const { scene } = renderObject, drawingShapeKey = getDrawingShapeKeyByDrawingSearch({ unitId, subUnitId, drawingId }), drawingShapes = scene.fuzzyMathObjects(drawingShapeKey, !0);
1067
+ if (drawingShapes.length > 0) {
1068
+ for (const drawingShape of drawingShapes)
1069
+ drawingShape.dispose();
1070
+ (_a7 = scene.getTransformer()) == null || _a7.clearSelectedObjects();
1063
1071
  }
1064
1072
  });
1065
1073
  })
@@ -1067,75 +1075,75 @@ let De = class extends Ae {
1067
1075
  }
1068
1076
  _drawingUpdateListener() {
1069
1077
  this.disposeWithMe(
1070
- this._drawingManagerService.update$.subscribe((n) => {
1071
- n.forEach((e) => {
1072
- const { unitId: t, subUnitId: r, drawingId: o } = e, i = this._drawingManagerService.getDrawingByParam(e);
1073
- if (i == null)
1078
+ this._drawingManagerService.update$.subscribe((params) => {
1079
+ params.forEach((param) => {
1080
+ const { unitId, subUnitId, drawingId } = param, drawingParam = this._drawingManagerService.getDrawingByParam(param);
1081
+ if (drawingParam == null)
1074
1082
  return;
1075
- const { transform: s, drawingType: l } = i, m = this._getSceneAndTransformerByDrawingSearch(t);
1076
- if (m == null)
1083
+ const { transform, drawingType } = drawingParam, renderObject = this._getSceneAndTransformerByDrawingSearch(unitId);
1084
+ if (renderObject == null)
1077
1085
  return;
1078
- const { scene: u, transformer: d } = m;
1079
- if (s == null)
1086
+ const { scene, transformer } = renderObject;
1087
+ if (transform == null)
1080
1088
  return !0;
1081
- const { left: h = 0, top: f = 0, width: v = 0, height: w = 0, angle: p = 0, flipX: S = !1, flipY: _ = !1, skewX: R = 0, skewY: b = 0 } = s, N = G({ unitId: t, subUnitId: r, drawingId: o }), I = u.getObject(N);
1082
- if (I == null)
1089
+ const { left = 0, top = 0, width = 0, height = 0, angle = 0, flipX = !1, flipY = !1, skewX = 0, skewY = 0 } = transform, drawingShapeKey = getDrawingShapeKeyByDrawingSearch({ unitId, subUnitId, drawingId }), drawingShape = scene.getObject(drawingShapeKey);
1090
+ if (drawingShape == null)
1083
1091
  return !0;
1084
- I.transformByState({ left: h, top: f, width: v, height: w, angle: p, flipX: S, flipY: _, skewX: R, skewY: b });
1092
+ drawingShape.transformByState({ left, top, width, height, angle, flipX, flipY, skewX, skewY });
1085
1093
  });
1086
1094
  })
1087
1095
  );
1088
1096
  }
1089
1097
  _drawingRefreshListener() {
1090
1098
  this.disposeWithMe(
1091
- this._drawingManagerService.refreshTransform$.subscribe((n) => {
1092
- n.forEach((e) => {
1093
- const { unitId: t, subUnitId: r, drawingId: o } = e, i = this._getSceneAndTransformerByDrawingSearch(t);
1094
- if (i == null)
1099
+ this._drawingManagerService.refreshTransform$.subscribe((params) => {
1100
+ params.forEach((param) => {
1101
+ const { unitId, subUnitId, drawingId } = param, renderObject = this._getSceneAndTransformerByDrawingSearch(unitId);
1102
+ if (renderObject == null)
1095
1103
  return;
1096
- const s = this._drawingManagerService.getDrawingByParam(e);
1097
- if (s == null)
1104
+ const drawingParam = this._drawingManagerService.getDrawingByParam(param);
1105
+ if (drawingParam == null)
1098
1106
  return;
1099
- const { transform: l } = s, { scene: m } = i, u = G({ unitId: t, subUnitId: r, drawingId: o }), d = m.getObject(u);
1100
- if (d == null || l == null)
1107
+ const { transform } = drawingParam, { scene } = renderObject, drawingShapeKey = getDrawingShapeKeyByDrawingSearch({ unitId, subUnitId, drawingId }), drawingShape = scene.getObject(drawingShapeKey);
1108
+ if (drawingShape == null || transform == null)
1101
1109
  return !0;
1102
1110
  const {
1103
- left: h = 0,
1104
- top: f = 0,
1105
- width: v = 0,
1106
- height: w = 0,
1107
- angle: p = 0,
1108
- flipX: S = !1,
1109
- flipY: _ = !1,
1110
- skewX: R = 0,
1111
- skewY: b = 0
1112
- } = l;
1113
- d.transformByState({ left: h, top: f, width: v, height: w, angle: p, flipX: S, flipY: _, skewX: R, skewY: b });
1111
+ left = 0,
1112
+ top = 0,
1113
+ width = 0,
1114
+ height = 0,
1115
+ angle = 0,
1116
+ flipX = !1,
1117
+ flipY = !1,
1118
+ skewX = 0,
1119
+ skewY = 0
1120
+ } = transform;
1121
+ drawingShape.transformByState({ left, top, width, height, angle, flipX, flipY, skewX, skewY });
1114
1122
  });
1115
1123
  })
1116
1124
  );
1117
1125
  }
1118
1126
  _drawingVisibleListener() {
1119
1127
  this.disposeWithMe(
1120
- this._drawingManagerService.visible$.subscribe((n) => {
1121
- n.forEach((e) => {
1122
- const { unitId: t, subUnitId: r, drawingId: o, visible: i } = e, s = this._getSceneAndTransformerByDrawingSearch(t);
1123
- if (s == null)
1128
+ this._drawingManagerService.visible$.subscribe((params) => {
1129
+ params.forEach((param) => {
1130
+ const { unitId, subUnitId, drawingId, visible } = param, renderObject = this._getSceneAndTransformerByDrawingSearch(unitId);
1131
+ if (renderObject == null)
1124
1132
  return;
1125
- const { scene: l } = s, m = G({ unitId: t, subUnitId: r, drawingId: o }), u = l.getObject(m);
1126
- if (u == null)
1133
+ const { scene } = renderObject, drawingShapeKey = getDrawingShapeKeyByDrawingSearch({ unitId, subUnitId, drawingId }), drawingShape = scene.getObject(drawingShapeKey);
1134
+ if (drawingShape == null)
1127
1135
  return !0;
1128
- i ? u.show() : u.hide();
1136
+ visible ? drawingShape.show() : drawingShape.hide();
1129
1137
  });
1130
1138
  })
1131
1139
  );
1132
1140
  }
1133
- _filterUpdateParams(n, e) {
1134
- return n.filter((t, r) => {
1135
- if (t == null)
1141
+ _filterUpdateParams(params, startTransforms) {
1142
+ return params.filter((param, index) => {
1143
+ if (param == null)
1136
1144
  return !1;
1137
- const { transform: o } = t;
1138
- return st(o, e == null ? void 0 : e[r]);
1145
+ const { transform } = param;
1146
+ return checkIfMove(transform, startTransforms == null ? void 0 : startTransforms[index]);
1139
1147
  });
1140
1148
  }
1141
1149
  // group?.getObjects().forEach((o) => {
@@ -1145,459 +1153,462 @@ let De = class extends Ae {
1145
1153
  // drawings.push({ unitId, subUnitId, drawingId });
1146
1154
  // }
1147
1155
  // });
1148
- _addListenerOnDrawing(n) {
1149
- const e = n.getTransformerByCreate();
1150
- let t = null;
1156
+ _addListenerOnDrawing(scene) {
1157
+ const transformer = scene.getTransformerByCreate();
1158
+ let startTransforms = null;
1151
1159
  this.disposeWithMe(
1152
- _e(
1153
- e.changeStart$.subscribe((r) => {
1154
- const { objects: o } = r, i = Array.from(o.values()), s = [];
1155
- t = i.map((l) => {
1156
- const { left: m, top: u, height: d, width: h, angle: f, oKey: v, isInGroup: w } = l, p = this._drawingManagerService.getDrawingOKey(v);
1157
- if (w || l instanceof ve) {
1158
- let S = l.ancestorGroup;
1159
- if (S == null && l instanceof ve && (S = l), S == null)
1160
+ toDisposable(
1161
+ transformer.changeStart$.subscribe((state) => {
1162
+ const { objects } = state, objectArray = Array.from(objects.values()), drawings = [];
1163
+ startTransforms = objectArray.map((object) => {
1164
+ const { left, top, height, width, angle, oKey, isInGroup } = object, drawing = this._drawingManagerService.getDrawingOKey(oKey);
1165
+ if (isInGroup || object instanceof Group) {
1166
+ let group = object.ancestorGroup;
1167
+ if (group == null && object instanceof Group && (group = object), group == null)
1160
1168
  return null;
1161
- const _ = this._drawingManagerService.getDrawingOKey(S.oKey);
1162
- if (_) {
1163
- const { unitId: R, subUnitId: b, drawingId: N } = _;
1164
- s.push({ unitId: R, subUnitId: b, drawingId: N });
1165
- const { left: I, top: y, height: P, width: M, angle: D } = S;
1166
- return { left: I, top: y, height: P, width: M, angle: D };
1169
+ const groupDrawing = this._drawingManagerService.getDrawingOKey(group.oKey);
1170
+ if (groupDrawing) {
1171
+ const { unitId, subUnitId, drawingId } = groupDrawing;
1172
+ drawings.push({ unitId, subUnitId, drawingId });
1173
+ const { left: left2, top: top2, height: height2, width: width2, angle: angle2 } = group;
1174
+ return { left: left2, top: top2, height: height2, width: width2, angle: angle2 };
1167
1175
  }
1168
- } else if (p != null) {
1169
- const { unitId: S, subUnitId: _, drawingId: R } = p;
1170
- return s.push({ unitId: S, subUnitId: _, drawingId: R }), { left: m, top: u, height: d, width: h, angle: f };
1176
+ } else if (drawing != null) {
1177
+ const { unitId, subUnitId, drawingId } = drawing;
1178
+ return drawings.push({ unitId, subUnitId, drawingId }), { left, top, height, width, angle };
1171
1179
  }
1172
1180
  return null;
1173
- }).filter((l) => l != null), s.length > 0 ? this._drawingManagerService.focusDrawing(s) : this._drawingManagerService.focusDrawing(null);
1181
+ }).filter((transform) => transform != null), drawings.length > 0 ? this._drawingManagerService.focusDrawing(drawings) : this._drawingManagerService.focusDrawing(null);
1174
1182
  })
1175
1183
  )
1176
1184
  ), this.disposeWithMe(
1177
- _e(
1178
- e.changeEnd$.subscribe((r) => {
1179
- const { objects: o } = r;
1180
- this._filterUpdateParams(Ge(o, this._drawingManagerService), t).length > 0;
1185
+ toDisposable(
1186
+ transformer.changeEnd$.subscribe((state) => {
1187
+ const { objects } = state, params = this._filterUpdateParams(getUpdateParams(objects, this._drawingManagerService), startTransforms);
1188
+ params.length > 0 && this._drawingManagerService.featurePluginUpdateNotification(params);
1181
1189
  })
1182
1190
  )
1183
1191
  );
1184
1192
  }
1185
- };
1186
- De = Gn([
1187
- xe(Ve.Rendered, De),
1188
- Me(0, Xe),
1189
- Me(1, ue),
1190
- Me(2, he),
1191
- Me(3, ae)
1192
- ], De);
1193
- const Wn = (a) => {
1194
- const { src: n } = a;
1195
- return n ? /* @__PURE__ */ c.createElement("div", null, /* @__PURE__ */ c.createElement("img", { src: n, alt: "Univer Image Viewer", style: { width: "100%", height: "100%", position: "relative" } })) : null;
1196
- }, St = "COMPONENT_IMAGE_VIEWER", bt = {
1193
+ }, __name(_a2, "DrawingUpdateController"), _a2);
1194
+ DrawingUpdateController = __decorateClass$4([
1195
+ OnLifecycle(LifecycleStages.Rendered, DrawingUpdateController),
1196
+ __decorateParam$4(0, IUniverInstanceService),
1197
+ __decorateParam$4(1, ICommandService),
1198
+ __decorateParam$4(2, IRenderManagerService),
1199
+ __decorateParam$4(3, IDrawingManagerService)
1200
+ ], DrawingUpdateController);
1201
+ const ImageViewer = /* @__PURE__ */ __name((props) => {
1202
+ const { src } = props;
1203
+ return src ? /* @__PURE__ */ React.createElement("div", null, /* @__PURE__ */ React.createElement("img", { src, alt: "Univer Image Viewer", style: { width: "100%", height: "100%", position: "relative" } })) : null;
1204
+ }, "ImageViewer"), COMPONENT_IMAGE_VIEWER = "COMPONENT_IMAGE_VIEWER", ImageResetSizeOperation = {
1197
1205
  id: "sheet.operation.image-reset-size",
1198
- type: Se.OPERATION,
1199
- handler: (a, n) => !0
1206
+ type: CommandType.OPERATION,
1207
+ handler: /* @__PURE__ */ __name((accessor, params) => !0, "handler")
1200
1208
  };
1201
- var $n = Object.defineProperty, kn = Object.getOwnPropertyDescriptor, zn = (a, n, e, t) => {
1202
- for (var r = t > 1 ? void 0 : t ? kn(n, e) : n, o = a.length - 1, i; o >= 0; o--)
1203
- (i = a[o]) && (r = (t ? i(n, e, r) : i(r)) || r);
1204
- return t && r && $n(n, e, r), r;
1205
- }, we = (a, n) => (e, t) => n(e, t, a);
1206
- let Te = class extends Ae {
1207
- constructor(a, n, e, t, r) {
1208
- super(), this._injector = a, this._componentManager = n, this._menuService = e, this._commandService = t, this._localeService = r, this._init();
1209
+ var __defProp$3 = Object.defineProperty, __getOwnPropDesc$3 = Object.getOwnPropertyDescriptor, __decorateClass$3 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
1210
+ for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$3(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
1211
+ (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
1212
+ return kind && result && __defProp$3(target, key, result), result;
1213
+ }, "__decorateClass$3"), __decorateParam$3 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$3"), _a3;
1214
+ let DrawingUIController = (_a3 = class extends Disposable {
1215
+ constructor(_injector, _componentManager, _menuService, _commandService, _localeService) {
1216
+ super(), this._injector = _injector, this._componentManager = _componentManager, this._menuService = _menuService, this._commandService = _commandService, this._localeService = _localeService, this._init();
1209
1217
  }
1210
1218
  _initCustomComponents() {
1211
- const a = this._componentManager;
1212
- this.disposeWithMe(a.register(An, Ln)), this.disposeWithMe(a.register(St, Wn));
1219
+ const componentManager = this._componentManager;
1220
+ this.disposeWithMe(componentManager.register(COMPONENT_IMAGE_POPUP_MENU, ImagePopupMenu)), this.disposeWithMe(componentManager.register(COMPONENT_IMAGE_VIEWER, ImageViewer));
1213
1221
  }
1214
1222
  _initMenus() {
1215
1223
  }
1216
1224
  _initCommands() {
1217
1225
  [
1218
- Ze,
1219
- me,
1220
- bt,
1221
- Je,
1222
- Le
1223
- ].forEach((a) => this.disposeWithMe(this._commandService.registerCommand(a)));
1226
+ OpenImageCropOperation,
1227
+ CloseImageCropOperation,
1228
+ ImageResetSizeOperation,
1229
+ SetDrawingAlignOperation,
1230
+ AutoImageCropOperation
1231
+ ].forEach((command) => this.disposeWithMe(this._commandService.registerCommand(command)));
1224
1232
  }
1225
1233
  _init() {
1226
1234
  this._initCommands(), this._initCustomComponents(), this._initMenus();
1227
1235
  }
1228
- };
1229
- Te = zn([
1230
- xe(Ve.Rendered, Te),
1231
- we(0, ge(mt)),
1232
- we(1, ge(Vt)),
1233
- we(2, Gt),
1234
- we(3, ue),
1235
- we(4, ge(Y))
1236
- ], Te);
1237
- class Oe extends Bt {
1238
- constructor(e, t) {
1239
- t == null && (t = {}), t.transformerConfig = {
1236
+ }, __name(_a3, "DrawingUIController"), _a3);
1237
+ DrawingUIController = __decorateClass$3([
1238
+ OnLifecycle(LifecycleStages.Rendered, DrawingUIController),
1239
+ __decorateParam$3(0, Inject(Injector)),
1240
+ __decorateParam$3(1, Inject(ComponentManager)),
1241
+ __decorateParam$3(2, IMenuService),
1242
+ __decorateParam$3(3, ICommandService),
1243
+ __decorateParam$3(4, Inject(LocaleService))
1244
+ ], DrawingUIController);
1245
+ const _ImageCropperObject = class _ImageCropperObject extends Shape {
1246
+ constructor(key, props) {
1247
+ props == null && (props = {}), props.transformerConfig = {
1240
1248
  keepRatio: !1,
1241
1249
  isCropper: !0,
1242
1250
  anchorFill: "rgb(0, 0, 0)",
1243
1251
  anchorStroke: "rgb(255, 255, 255)",
1244
1252
  anchorSize: 24
1245
1253
  };
1246
- super(e, t);
1247
- te(this, "_srcRect");
1248
- te(this, "_prstGeom");
1249
- te(this, "_applyTransform");
1250
- te(this, "_dragPadding", 8);
1251
- te(this, "_cacheCanvas");
1252
- t != null && t.srcRect && (this._srcRect = t.srcRect), t != null && t.prstGeom && (this._prstGeom = t.prstGeom), t != null && t.applyTransform && (this._applyTransform = t.applyTransform), t != null && t.dragPadding && (this._dragPadding = t.dragPadding), this._applyProps();
1254
+ super(key, props);
1255
+ __publicField(this, "_srcRect");
1256
+ __publicField(this, "_prstGeom");
1257
+ __publicField(this, "_applyTransform");
1258
+ __publicField(this, "_dragPadding", 8);
1259
+ __publicField(this, "_cacheCanvas");
1260
+ props != null && props.srcRect && (this._srcRect = props.srcRect), props != null && props.prstGeom && (this._prstGeom = props.prstGeom), props != null && props.applyTransform && (this._applyTransform = props.applyTransform), props != null && props.dragPadding && (this._dragPadding = props.dragPadding), this._applyProps();
1253
1261
  }
1254
- refreshSrcRect(e, t) {
1255
- this._srcRect = e, this._applyTransform = t, this._applyProps();
1262
+ refreshSrcRect(value, transform) {
1263
+ this._srcRect = value, this._applyTransform = transform, this._applyProps();
1256
1264
  }
1257
1265
  get srcRect() {
1258
1266
  return this._srcRect;
1259
1267
  }
1260
1268
  dispose() {
1261
- var e;
1262
- super.dispose(), (e = this._cacheCanvas) == null || e.dispose(), this._srcRect = null;
1263
- }
1264
- isHit(e) {
1265
- const t = this.getInverseCoord(e);
1266
- return t.x >= -this.strokeWidth / 2 && t.x <= this.width + this.strokeWidth / 2 && t.y >= -this.strokeWidth / 2 && t.y <= this.height + this.strokeWidth / 2 && !this._inSurround(t);
1267
- }
1268
- _inSurround(e) {
1269
- const t = this._dragPadding;
1270
- return e.x >= t - this.strokeWidth / 2 && e.x <= this.width + this.strokeWidth / 2 - t && e.y >= t - this.strokeWidth / 2 && e.y <= this.height + this.strokeWidth / 2 - t;
1271
- }
1272
- render(e, t) {
1273
- return this.visible ? (e.save(), this._draw(e), e.restore(), this.makeDirty(!1), this) : (this.makeDirty(!1), this);
1274
- }
1275
- _draw(e) {
1276
- var l, m;
1277
- const r = this.getScene().getEngine(), { width: o, height: i } = r;
1278
- this._initialCacheCanvas(), (l = this._cacheCanvas) == null || l.clear();
1279
- const s = (m = this._cacheCanvas) == null ? void 0 : m.getContext();
1280
- s != null && (s.save(), jt.drawWith(s, {
1269
+ var _a7;
1270
+ super.dispose(), (_a7 = this._cacheCanvas) == null || _a7.dispose(), this._srcRect = null;
1271
+ }
1272
+ isHit(coord) {
1273
+ const oCoord = this.getInverseCoord(coord);
1274
+ return oCoord.x >= -this.strokeWidth / 2 && oCoord.x <= this.width + this.strokeWidth / 2 && oCoord.y >= -this.strokeWidth / 2 && oCoord.y <= this.height + this.strokeWidth / 2 && !this._inSurround(oCoord);
1275
+ }
1276
+ _inSurround(oCoord) {
1277
+ const padding = this._dragPadding;
1278
+ return oCoord.x >= padding - this.strokeWidth / 2 && oCoord.x <= this.width + this.strokeWidth / 2 - padding && oCoord.y >= padding - this.strokeWidth / 2 && oCoord.y <= this.height + this.strokeWidth / 2 - padding;
1279
+ }
1280
+ render(mainCtx, bounds) {
1281
+ return this.visible ? (mainCtx.save(), this._draw(mainCtx), mainCtx.restore(), this.makeDirty(!1), this) : (this.makeDirty(!1), this);
1282
+ }
1283
+ _draw(ctx) {
1284
+ var _a7, _b;
1285
+ const engine = this.getScene().getEngine(), { width: engineWidth, height: engineHeight } = engine;
1286
+ this._initialCacheCanvas(), (_a7 = this._cacheCanvas) == null || _a7.clear();
1287
+ const cacheCtx = (_b = this._cacheCanvas) == null ? void 0 : _b.getContext();
1288
+ cacheCtx != null && (cacheCtx.save(), Rect.drawWith(cacheCtx, {
1281
1289
  left: 0,
1282
1290
  top: 0,
1283
- width: o,
1284
- height: i,
1291
+ width: engineWidth,
1292
+ height: engineHeight,
1285
1293
  fill: "rgba(0, 0, 0, 0.5)"
1286
- }), s.setTransform(e.getTransform()), this._clipForApplyObject(s), this._applyCache(e), s.restore());
1294
+ }), cacheCtx.setTransform(ctx.getTransform()), this._clipForApplyObject(cacheCtx), this._applyCache(ctx), cacheCtx.restore());
1287
1295
  }
1288
- _clipForApplyObject(e) {
1289
- let t = 0;
1290
- if (this._prstGeom != null && (t = 1), e.globalCompositeOperation = "destination-out", e.beginPath(), t === 0) {
1291
- const r = this.transform.getMatrix();
1292
- e.transform(r[0], r[1], r[2], r[3], r[4], r[5]), e.rect(0, 0, this.width, this.height), e.fill();
1296
+ _clipForApplyObject(cacheCtx) {
1297
+ let objectType = 0;
1298
+ if (this._prstGeom != null && (objectType = 1), cacheCtx.globalCompositeOperation = "destination-out", cacheCtx.beginPath(), objectType === 0) {
1299
+ const m = this.transform.getMatrix();
1300
+ cacheCtx.transform(m[0], m[1], m[2], m[3], m[4], m[5]), cacheCtx.rect(0, 0, this.width, this.height), cacheCtx.fill();
1293
1301
  }
1294
1302
  }
1295
1303
  _applyProps() {
1296
1304
  if (this._applyTransform == null)
1297
1305
  return;
1298
- let e = 0, t = 0, r = 0, o = 0;
1299
- const { left: i = 0, top: s = 0, width: l = 0, height: m = 0, angle: u } = this._applyTransform;
1306
+ let cropLeft = 0, cropTop = 0, cropRight = 0, cropBottom = 0;
1307
+ const { left: applyLeft = 0, top: applyTop = 0, width: applyWidth = 0, height: applyHeight = 0, angle } = this._applyTransform;
1300
1308
  if (this._srcRect != null) {
1301
- const { left: f = 0, top: v = 0, right: w = 0, bottom: p = 0 } = this._srcRect;
1302
- e = f, t = v, r = w, o = p;
1309
+ const { left: left2 = 0, top: top2 = 0, right = 0, bottom = 0 } = this._srcRect;
1310
+ cropLeft = left2, cropTop = top2, cropRight = right, cropBottom = bottom;
1303
1311
  }
1304
- const d = i + e, h = s + t;
1312
+ const left = applyLeft + cropLeft, top = applyTop + cropTop;
1305
1313
  this.transformByState({
1306
- left: d,
1307
- top: h,
1308
- width: i + l - r - d,
1309
- height: s + m - o - h,
1310
- angle: u
1314
+ left,
1315
+ top,
1316
+ width: applyLeft + applyWidth - cropRight - left,
1317
+ height: applyTop + applyHeight - cropBottom - top,
1318
+ angle
1311
1319
  });
1312
1320
  }
1313
- _applyCache(e) {
1314
- if (!e || this._cacheCanvas == null)
1321
+ _applyCache(ctx) {
1322
+ if (!ctx || this._cacheCanvas == null)
1315
1323
  return;
1316
- const t = this._cacheCanvas.getContext();
1317
- t.save(), e.save(), e.setTransform(1, 0, 0, 1, 0, 0), t.setTransform(1, 0, 0, 1, 0, 0), e.drawImage(this._cacheCanvas.getCanvasEle(), 0, 0), e.restore(), t.restore();
1324
+ const cacheCtx = this._cacheCanvas.getContext();
1325
+ cacheCtx.save(), ctx.save(), ctx.setTransform(1, 0, 0, 1, 0, 0), cacheCtx.setTransform(1, 0, 0, 1, 0, 0), ctx.drawImage(this._cacheCanvas.getCanvasEle(), 0, 0), ctx.restore(), cacheCtx.restore();
1318
1326
  }
1319
1327
  _initialCacheCanvas() {
1320
1328
  if (this._cacheCanvas != null)
1321
1329
  return;
1322
- this._cacheCanvas = new Ut();
1323
- const e = this.getScene().getEngine();
1324
- this._cacheCanvas.setSize(e.width, e.height), e.onTransformChange$.subscribeEvent(() => {
1325
- var t;
1326
- (t = this._cacheCanvas) == null || t.setSize(e.width, e.height), this.makeDirty(!0);
1330
+ this._cacheCanvas = new Canvas();
1331
+ const engine = this.getScene().getEngine();
1332
+ this._cacheCanvas.setSize(engine.width, engine.height), engine.onTransformChange$.subscribeEvent(() => {
1333
+ var _a7;
1334
+ (_a7 = this._cacheCanvas) == null || _a7.setSize(engine.width, engine.height), this.makeDirty(!0);
1327
1335
  });
1328
1336
  }
1329
- }
1330
- var Fn = Object.defineProperty, Kn = Object.getOwnPropertyDescriptor, Zn = (a, n, e, t) => {
1331
- for (var r = t > 1 ? void 0 : t ? Kn(n, e) : n, o = a.length - 1, i; o >= 0; o--)
1332
- (i = a[o]) && (r = (t ? i(n, e, r) : i(r)) || r);
1333
- return t && r && Fn(n, e, r), r;
1334
- }, de = (a, n) => (e, t) => n(e, t, a);
1335
- let Be = class extends Ae {
1336
- constructor(n, e, t, r, o, i) {
1337
+ };
1338
+ __name(_ImageCropperObject, "ImageCropperObject");
1339
+ let ImageCropperObject = _ImageCropperObject;
1340
+ var __defProp$2 = Object.defineProperty, __getOwnPropDesc$2 = Object.getOwnPropertyDescriptor, __decorateClass$2 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
1341
+ for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$2(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
1342
+ (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
1343
+ return kind && result && __defProp$2(target, key, result), result;
1344
+ }, "__decorateClass$2"), __decorateParam$2 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$2"), _a4;
1345
+ let ImageCropperController = (_a4 = class extends Disposable {
1346
+ constructor(_commandService, _drawingManagerService, _renderManagerService, _univerInstanceService, _messageService, _localeService) {
1337
1347
  super();
1338
- te(this, "_sceneListenerOnImageMap", /* @__PURE__ */ new WeakSet());
1339
- this._commandService = n, this._drawingManagerService = e, this._renderManagerService = t, this._univerInstanceService = r, this._messageService = o, this._localeService = i, this._init();
1348
+ __publicField(this, "_sceneListenerOnImageMap", /* @__PURE__ */ new WeakSet());
1349
+ this._commandService = _commandService, this._drawingManagerService = _drawingManagerService, this._renderManagerService = _renderManagerService, this._univerInstanceService = _univerInstanceService, this._messageService = _messageService, this._localeService = _localeService, this._init();
1340
1350
  }
1341
1351
  _init() {
1342
1352
  this._initOpenCrop(), this._initCloseCrop(), this._initAutoCrop();
1343
1353
  }
1344
1354
  _initAutoCrop() {
1345
1355
  this.disposeWithMe(
1346
- this._commandService.onCommandExecuted((n) => {
1347
- if (n.id !== Le.id)
1356
+ this._commandService.onCommandExecuted((command) => {
1357
+ if (command.id !== AutoImageCropOperation.id)
1348
1358
  return;
1349
- const e = n.params;
1350
- if (e == null)
1359
+ const params = command.params;
1360
+ if (params == null)
1351
1361
  return;
1352
- const { cropType: t } = e, r = this._drawingManagerService.getFocusDrawings();
1353
- if (r.length !== 1)
1362
+ const { cropType } = params, drawingParams = this._drawingManagerService.getFocusDrawings();
1363
+ if (drawingParams.length !== 1)
1354
1364
  return;
1355
- const o = r[0], { unitId: i, subUnitId: s, drawingId: l } = o, m = this._renderManagerService.getRenderById(i), u = m == null ? void 0 : m.scene;
1356
- if (u == null)
1365
+ const drawingParam = drawingParams[0], { unitId, subUnitId, drawingId } = drawingParam, renderObject = this._renderManagerService.getRenderById(unitId), scene = renderObject == null ? void 0 : renderObject.scene;
1366
+ if (scene == null)
1357
1367
  return !0;
1358
- this._searchCropObject(u) != null && this._commandService.syncExecuteCommand(me.id, { isAuto: !0 });
1359
- const h = G({ unitId: i, subUnitId: s, drawingId: l }), f = u.getObject(h);
1360
- if (!(f instanceof Fe)) {
1368
+ this._searchCropObject(scene) != null && this._commandService.syncExecuteCommand(CloseImageCropOperation.id, { isAuto: !0 });
1369
+ const imageShapeKey = getDrawingShapeKeyByDrawingSearch({ unitId, subUnitId, drawingId }), imageShape = scene.getObject(imageShapeKey);
1370
+ if (!(imageShape instanceof Image)) {
1361
1371
  this._messageService.show({
1362
- type: tt.Error,
1372
+ type: MessageType.Error,
1363
1373
  content: this._localeService.t("image-cropper.error")
1364
1374
  });
1365
1375
  return;
1366
1376
  }
1367
- f != null && (this._updateCropperObject(t, f), this._commandService.executeCommand(Ze.id, { unitId: i, subUnitId: s, drawingId: l }));
1377
+ imageShape != null && (this._updateCropperObject(cropType, imageShape), this._commandService.executeCommand(OpenImageCropOperation.id, { unitId, subUnitId, drawingId }));
1368
1378
  })
1369
1379
  );
1370
1380
  }
1371
- _calculateSrcRectByRatio(n, e, t, r, o, i) {
1372
- const s = t / r, l = o / i;
1373
- let m = t, u = r;
1374
- s > l ? m = r * l : u = t / l;
1375
- const d = (t - m) / 2, h = (r - u) / 2;
1381
+ _calculateSrcRectByRatio(left, top, width, height, numerator, denominator) {
1382
+ const srcRatio = width / height, ratio = numerator / denominator;
1383
+ let newWidth = width, newHeight = height;
1384
+ srcRatio > ratio ? newWidth = height * ratio : newHeight = width / ratio;
1385
+ const newLeft = (width - newWidth) / 2, newTop = (height - newHeight) / 2;
1376
1386
  return {
1377
- left: ye(d, 1),
1378
- top: ye(h, 1),
1379
- right: ye(t - (d + m), 1),
1380
- bottom: ye(r - (h + u), 1)
1387
+ left: precisionTo(newLeft, 1),
1388
+ top: precisionTo(newTop, 1),
1389
+ right: precisionTo(width - (newLeft + newWidth), 1),
1390
+ bottom: precisionTo(height - (newTop + newHeight), 1)
1381
1391
  };
1382
1392
  }
1383
- _updateCropperObject(n, e) {
1384
- const { left: t, top: r, width: o, height: i } = e.calculateTransformWithSrcRect();
1385
- let s;
1386
- switch (n) {
1387
- case B.R1_1:
1388
- s = this._calculateSrcRectByRatio(t, r, o, i, 1, 1);
1393
+ _updateCropperObject(cropType, imageShape) {
1394
+ const { left, top, width, height } = imageShape.calculateTransformWithSrcRect();
1395
+ let newSrcRect;
1396
+ switch (cropType) {
1397
+ case CropType.R1_1:
1398
+ newSrcRect = this._calculateSrcRectByRatio(left, top, width, height, 1, 1);
1389
1399
  break;
1390
- case B.R16_9:
1391
- s = this._calculateSrcRectByRatio(t, r, o, i, 16, 9);
1400
+ case CropType.R16_9:
1401
+ newSrcRect = this._calculateSrcRectByRatio(left, top, width, height, 16, 9);
1392
1402
  break;
1393
- case B.R9_16:
1394
- s = this._calculateSrcRectByRatio(t, r, o, i, 9, 16);
1403
+ case CropType.R9_16:
1404
+ newSrcRect = this._calculateSrcRectByRatio(left, top, width, height, 9, 16);
1395
1405
  break;
1396
- case B.R5_4:
1397
- s = this._calculateSrcRectByRatio(t, r, o, i, 5, 4);
1406
+ case CropType.R5_4:
1407
+ newSrcRect = this._calculateSrcRectByRatio(left, top, width, height, 5, 4);
1398
1408
  break;
1399
- case B.R4_5:
1400
- s = this._calculateSrcRectByRatio(t, r, o, i, 4, 5);
1409
+ case CropType.R4_5:
1410
+ newSrcRect = this._calculateSrcRectByRatio(left, top, width, height, 4, 5);
1401
1411
  break;
1402
- case B.R4_3:
1403
- s = this._calculateSrcRectByRatio(t, r, o, i, 4, 3);
1412
+ case CropType.R4_3:
1413
+ newSrcRect = this._calculateSrcRectByRatio(left, top, width, height, 4, 3);
1404
1414
  break;
1405
- case B.R3_4:
1406
- s = this._calculateSrcRectByRatio(t, r, o, i, 3, 4);
1415
+ case CropType.R3_4:
1416
+ newSrcRect = this._calculateSrcRectByRatio(left, top, width, height, 3, 4);
1407
1417
  break;
1408
- case B.R3_2:
1409
- s = this._calculateSrcRectByRatio(t, r, o, i, 3, 2);
1418
+ case CropType.R3_2:
1419
+ newSrcRect = this._calculateSrcRectByRatio(left, top, width, height, 3, 2);
1410
1420
  break;
1411
- case B.R2_3:
1412
- s = this._calculateSrcRectByRatio(t, r, o, i, 2, 3);
1421
+ case CropType.R2_3:
1422
+ newSrcRect = this._calculateSrcRectByRatio(left, top, width, height, 2, 3);
1413
1423
  break;
1414
- case B.FREE:
1424
+ case CropType.FREE:
1415
1425
  }
1416
- if (s == null)
1426
+ if (newSrcRect == null)
1417
1427
  return;
1418
- e.setSrcRect(s);
1419
- const { left: l = 0, top: m = 0, bottom: u = 0, right: d = 0 } = s;
1420
- e.transformByStateCloseCropper({
1421
- left: t + l,
1422
- top: r + m,
1423
- width: o - d - l,
1424
- height: i - u - m
1428
+ imageShape.setSrcRect(newSrcRect);
1429
+ const { left: newLeft = 0, top: newTop = 0, bottom: newBottom = 0, right: newRight = 0 } = newSrcRect;
1430
+ imageShape.transformByStateCloseCropper({
1431
+ left: left + newLeft,
1432
+ top: top + newTop,
1433
+ width: width - newRight - newLeft,
1434
+ height: height - newBottom - newTop
1425
1435
  });
1426
1436
  }
1427
1437
  _initOpenCrop() {
1428
1438
  this.disposeWithMe(
1429
- this._commandService.onCommandExecuted((n) => {
1430
- if (n.id !== Ze.id)
1439
+ this._commandService.onCommandExecuted((command) => {
1440
+ if (command.id !== OpenImageCropOperation.id)
1431
1441
  return;
1432
- const e = n.params;
1433
- if (e == null)
1442
+ const params = command.params;
1443
+ if (params == null)
1434
1444
  return;
1435
- const { unitId: t, subUnitId: r, drawingId: o } = e, i = this._renderManagerService.getRenderById(t), s = i == null ? void 0 : i.scene;
1436
- if (s == null)
1445
+ const { unitId, subUnitId, drawingId } = params, renderObject = this._renderManagerService.getRenderById(unitId), scene = renderObject == null ? void 0 : renderObject.scene;
1446
+ if (scene == null)
1437
1447
  return !0;
1438
- if (this._sceneListenerOnImageMap.has(s) || (this._addListenerOnImage(s), this._sceneListenerOnImageMap.add(s)), this._drawingManagerService.getDrawingByParam({ unitId: t, subUnitId: r, drawingId: o }) == null)
1448
+ if (this._sceneListenerOnImageMap.has(scene) || (this._addListenerOnImage(scene), this._sceneListenerOnImageMap.add(scene)), this._drawingManagerService.getDrawingByParam({ unitId, subUnitId, drawingId }) == null)
1439
1449
  return;
1440
- const m = G({ unitId: t, subUnitId: r, drawingId: o }), u = s.getObject(m);
1441
- if (u == null)
1450
+ const imageShapeKey = getDrawingShapeKeyByDrawingSearch({ unitId, subUnitId, drawingId }), imageShape = scene.getObject(imageShapeKey);
1451
+ if (imageShape == null)
1442
1452
  return;
1443
- if (!(u instanceof Fe)) {
1453
+ if (!(imageShape instanceof Image)) {
1444
1454
  this._messageService.show({
1445
- type: tt.Error,
1455
+ type: MessageType.Error,
1446
1456
  content: this._localeService.t("image-cropper.error")
1447
1457
  });
1448
1458
  return;
1449
1459
  }
1450
- const d = s.getTransformer();
1451
- d == null || d.clearControls();
1452
- const h = new Oe(`${m}-crop`, {
1453
- srcRect: u.srcRect,
1454
- prstGeom: u.prstGeom,
1455
- applyTransform: u.calculateTransformWithSrcRect()
1460
+ const transformer = scene.getTransformer();
1461
+ transformer == null || transformer.clearControls();
1462
+ const imageCropperObject = new ImageCropperObject(`${imageShapeKey}-crop`, {
1463
+ srcRect: imageShape.srcRect,
1464
+ prstGeom: imageShape.prstGeom,
1465
+ applyTransform: imageShape.calculateTransformWithSrcRect()
1456
1466
  });
1457
- s.addObject(h, u.getLayerIndex() + 1).attachTransformerTo(h), d == null || d.createControlForCopper(h), this._addHoverForImageCopper(h), u.openRenderByCropper(), d == null || d.refreshControls(), h.makeDirty(!0), this._drawingManagerService.focusDrawing([{ unitId: t, subUnitId: r, drawingId: o }]);
1467
+ scene.addObject(imageCropperObject, imageShape.getLayerIndex() + 1).attachTransformerTo(imageCropperObject), transformer == null || transformer.createControlForCopper(imageCropperObject), this._addHoverForImageCopper(imageCropperObject), imageShape.openRenderByCropper(), transformer == null || transformer.refreshControls(), imageCropperObject.makeDirty(!0), this._drawingManagerService.focusDrawing([{ unitId, subUnitId, drawingId }]);
1458
1468
  })
1459
1469
  );
1460
1470
  }
1461
- _searchCropObject(n) {
1462
- const e = n.getAllObjects();
1463
- for (const t of e)
1464
- if (t instanceof Oe)
1465
- return t;
1471
+ _searchCropObject(scene) {
1472
+ const objects = scene.getAllObjects();
1473
+ for (const object of objects)
1474
+ if (object instanceof ImageCropperObject)
1475
+ return object;
1466
1476
  }
1467
1477
  _initCloseCrop() {
1468
1478
  this.disposeWithMe(
1469
- this._commandService.onCommandExecuted((e) => {
1470
- if (e.id !== me.id)
1479
+ this._commandService.onCommandExecuted((command) => {
1480
+ if (command.id !== CloseImageCropOperation.id)
1471
1481
  return;
1472
- const t = this._univerInstanceService.getFocusedUnit();
1473
- if (t == null)
1482
+ const currentUnit = this._univerInstanceService.getFocusedUnit();
1483
+ if (currentUnit == null)
1474
1484
  return;
1475
- const r = t.getUnitId(), o = this._renderManagerService.getRenderById(r), i = o == null ? void 0 : o.scene;
1476
- if (i == null)
1485
+ const unitId = currentUnit.getUnitId(), renderObject = this._renderManagerService.getRenderById(unitId), scene = renderObject == null ? void 0 : renderObject.scene;
1486
+ if (scene == null)
1477
1487
  return !0;
1478
- const s = this._searchCropObject(i);
1479
- if (s == null)
1488
+ const imageCropperObject = this._searchCropObject(scene);
1489
+ if (imageCropperObject == null)
1480
1490
  return;
1481
- const l = this._getApplyObjectByCropObject(s);
1482
- if (l == null)
1491
+ const imageShape = this._getApplyObjectByCropObject(imageCropperObject);
1492
+ if (imageShape == null)
1483
1493
  return;
1484
- const m = i.getTransformerByCreate();
1485
- m.detachFrom(s), m.clearCopperControl();
1486
- const u = this._getSrcRectByTransformState(l, s), d = this._drawingManagerService.getDrawingOKey(l.oKey);
1487
- if (d != null) {
1488
- const { left: h, top: f, height: v, width: w } = s;
1494
+ const transformer = scene.getTransformerByCreate();
1495
+ transformer.detachFrom(imageCropperObject), transformer.clearCopperControl();
1496
+ const srcRect = this._getSrcRectByTransformState(imageShape, imageCropperObject), drawingParam = this._drawingManagerService.getDrawingOKey(imageShape.oKey);
1497
+ if (drawingParam != null) {
1498
+ const { left, top, height, width } = imageCropperObject;
1489
1499
  this._drawingManagerService.featurePluginUpdateNotification([{
1490
- ...d,
1500
+ ...drawingParam,
1491
1501
  transform: {
1492
- ...d.transform,
1493
- left: h,
1494
- top: f,
1495
- height: v,
1496
- width: w
1502
+ ...drawingParam.transform,
1503
+ left,
1504
+ top,
1505
+ height,
1506
+ width
1497
1507
  },
1498
- srcRect: u.srcRectAngle
1508
+ srcRect: srcRect.srcRectAngle
1499
1509
  }]);
1500
1510
  }
1501
- l.setSrcRect({ ...u.srcRectAngle }), l.closeRenderByCropper(), l.makeDirty(!0), s == null || s.dispose();
1511
+ imageShape.setSrcRect({ ...srcRect.srcRectAngle }), imageShape.closeRenderByCropper(), imageShape.makeDirty(!0), imageCropperObject == null || imageCropperObject.dispose();
1502
1512
  })
1503
1513
  );
1504
- const n = this._univerInstanceService.getCurrentTypeOfUnit$(Ne.UNIVER_SHEET).pipe(
1505
- kt((e) => !!e),
1506
- zt((e) => e.activeSheet$)
1514
+ const sheetUnit = this._univerInstanceService.getCurrentTypeOfUnit$(UniverInstanceType.UNIVER_SHEET).pipe(
1515
+ filter((workbook) => !!workbook),
1516
+ switchMap((workbook) => workbook.activeSheet$)
1507
1517
  );
1508
- this.disposeWithMe(n.subscribe(() => {
1509
- this._commandService.syncExecuteCommand(me.id);
1518
+ this.disposeWithMe(sheetUnit.subscribe(() => {
1519
+ this._commandService.syncExecuteCommand(CloseImageCropOperation.id);
1510
1520
  }));
1511
1521
  }
1512
- _getApplyObjectByCropObject(n) {
1513
- const e = n.oKey, t = e.slice(0, e.length - 5), r = n.getScene().getObject(t);
1514
- return r == null ? null : r;
1522
+ _getApplyObjectByCropObject(cropObject) {
1523
+ const cropOKey = cropObject.oKey, applyOKey = cropOKey.slice(0, cropOKey.length - 5), applyObject = cropObject.getScene().getObject(applyOKey);
1524
+ return applyObject == null ? null : applyObject;
1515
1525
  }
1516
- _addListenerOnImage(n) {
1517
- const e = n.getTransformerByCreate();
1518
- let t = null;
1526
+ _addListenerOnImage(scene) {
1527
+ const transformer = scene.getTransformerByCreate();
1528
+ let startTransform = null;
1519
1529
  this.disposeWithMe(
1520
- e.changeStart$.subscribe((r) => {
1521
- const { objects: o } = r, i = o.values().next().value;
1522
- if (i == null || !(i instanceof Oe))
1530
+ transformer.changeStart$.subscribe((state) => {
1531
+ const { objects } = state, cropObject = objects.values().next().value;
1532
+ if (cropObject == null || !(cropObject instanceof ImageCropperObject))
1523
1533
  return;
1524
- const { left: s, top: l, height: m, width: u, angle: d } = i;
1525
- t = { left: s, top: l, height: m, width: u, angle: d }, e.clearCopperControl();
1534
+ const { left, top, height, width, angle } = cropObject;
1535
+ startTransform = { left, top, height, width, angle }, transformer.clearCopperControl();
1526
1536
  })
1527
1537
  ), this.disposeWithMe(
1528
- e.changeEnd$.subscribe((r) => {
1529
- const { objects: o } = r, i = o.values().next().value;
1530
- if (i == null || !(i instanceof Oe))
1538
+ transformer.changeEnd$.subscribe((state) => {
1539
+ const { objects } = state, cropObject = objects.values().next().value;
1540
+ if (cropObject == null || !(cropObject instanceof ImageCropperObject))
1531
1541
  return;
1532
- const { left: s, top: l, height: m, width: u, angle: d } = i;
1533
- if (!st({ left: s, top: l, height: m, width: u, angle: d }, t))
1542
+ const { left, top, height, width, angle } = cropObject;
1543
+ if (!checkIfMove({ left, top, height, width, angle }, startTransform))
1534
1544
  return;
1535
- const h = this._getApplyObjectByCropObject(i);
1536
- if (h == null)
1545
+ const applyObject = this._getApplyObjectByCropObject(cropObject);
1546
+ if (applyObject == null)
1537
1547
  return;
1538
- const f = this._getSrcRectByTransformState(h, i);
1539
- i.refreshSrcRect(f.srcRect, h.getState()), e.createControlForCopper(i);
1548
+ const srcRect = this._getSrcRectByTransformState(applyObject, cropObject);
1549
+ cropObject.refreshSrcRect(srcRect.srcRect, applyObject.getState()), transformer.createControlForCopper(cropObject);
1540
1550
  })
1541
- ), this._endCropListener(n);
1551
+ ), this._endCropListener(scene);
1542
1552
  }
1543
- _addHoverForImageCopper(n) {
1553
+ _addHoverForImageCopper(o) {
1544
1554
  this.disposeWithMe(
1545
- n.onPointerEnter$.subscribeEvent(() => {
1546
- n.cursor = Ue.MOVE;
1555
+ o.onPointerEnter$.subscribeEvent(() => {
1556
+ o.cursor = CURSOR_TYPE.MOVE;
1547
1557
  })
1548
1558
  ), this.disposeWithMe(
1549
- n.onPointerLeave$.subscribeEvent(() => {
1550
- n.cursor = Ue.DEFAULT;
1559
+ o.onPointerLeave$.subscribeEvent(() => {
1560
+ o.cursor = CURSOR_TYPE.DEFAULT;
1551
1561
  })
1552
1562
  );
1553
1563
  }
1554
- _endCropListener(n) {
1555
- const e = n.getTransformerByCreate();
1564
+ _endCropListener(scene) {
1565
+ const transformer = scene.getTransformerByCreate();
1556
1566
  this.disposeWithMe(
1557
- e.clearControl$.subscribe((t) => {
1558
- t === !0 && this._commandService.syncExecuteCommand(me.id);
1567
+ transformer.clearControl$.subscribe((changeSelf) => {
1568
+ changeSelf === !0 && this._commandService.syncExecuteCommand(CloseImageCropOperation.id);
1559
1569
  })
1560
1570
  );
1561
1571
  }
1562
- _getSrcRectByTransformState(n, e) {
1563
- const { left: t, top: r, height: o, width: i, strokeWidth: s, angle: l } = e, { left: m, top: u, width: d, height: h, angle: f, strokeWidth: v } = n, w = t - m, p = r - u, S = {
1564
- left: w,
1565
- top: p,
1566
- right: d - w - i,
1567
- bottom: h - p - o
1568
- }, _ = { ...S };
1569
- if (f !== 0) {
1570
- const R = t + i / 2, b = r + o / 2, N = new ke(R, b), I = d / 2 + m, y = h / 2 + u, P = new ke(I, y), M = new ke(m, u);
1571
- M.rotateByPoint(et(f), P);
1572
- const D = M.clone();
1573
- D.rotateByPoint(et(-f), N);
1574
- const U = t - D.x, T = r - D.y;
1575
- _.left = U, _.top = T, _.right = d - U - i, _.bottom = h - T - o;
1572
+ _getSrcRectByTransformState(applyObject, imageCropperObject) {
1573
+ const { left, top, height, width, strokeWidth, angle: copperAngle } = imageCropperObject, { left: applyLeft, top: applyTop, width: applyWidth, height: applyHeight, angle: applyAngle, strokeWidth: applyStrokeWidth } = applyObject, newLeft = left - applyLeft, newTop = top - applyTop, srcRect = {
1574
+ left: newLeft,
1575
+ top: newTop,
1576
+ right: applyWidth - newLeft - width,
1577
+ bottom: applyHeight - newTop - height
1578
+ }, srcRectAngle = { ...srcRect };
1579
+ if (applyAngle !== 0) {
1580
+ const cx = left + width / 2, cy = top + height / 2, centerPoint = new Vector2(cx, cy), newCx = applyWidth / 2 + applyLeft, newCy = applyHeight / 2 + applyTop, newCenterPoint = new Vector2(newCx, newCy), vertexPoint = new Vector2(applyLeft, applyTop);
1581
+ vertexPoint.rotateByPoint(degToRad(applyAngle), newCenterPoint);
1582
+ const applyFinalPoint = vertexPoint.clone();
1583
+ applyFinalPoint.rotateByPoint(degToRad(-applyAngle), centerPoint);
1584
+ const newAngleLeft = left - applyFinalPoint.x, newAngleTop = top - applyFinalPoint.y;
1585
+ srcRectAngle.left = newAngleLeft, srcRectAngle.top = newAngleTop, srcRectAngle.right = applyWidth - newAngleLeft - width, srcRectAngle.bottom = applyHeight - newAngleTop - height;
1576
1586
  }
1577
1587
  return {
1578
- srcRect: S,
1579
- srcRectAngle: _
1588
+ srcRect,
1589
+ srcRectAngle
1580
1590
  };
1581
1591
  }
1582
- };
1583
- Be = Zn([
1584
- xe(Ve.Rendered, Be),
1585
- de(0, ue),
1586
- de(1, ae),
1587
- de(2, he),
1588
- de(3, Xe),
1589
- de(4, Wt),
1590
- de(5, ge(Y))
1591
- ], Be);
1592
- var Yn = Object.defineProperty, Xn = Object.getOwnPropertyDescriptor, Jn = (a, n, e, t) => {
1593
- for (var r = t > 1 ? void 0 : t ? Xn(n, e) : n, o = a.length - 1, i; o >= 0; o--)
1594
- (i = a[o]) && (r = (t ? i(n, e, r) : i(r)) || r);
1595
- return t && r && Yn(n, e, r), r;
1596
- }, ce = (a, n) => (e, t) => n(e, t, a);
1597
- const rt = 50;
1598
- let je = class extends Ae {
1599
- constructor(a, n, e, t, r, o, i) {
1600
- super(), this._commandService = a, this._renderManagerService = n, this._drawingManagerService = e, this._dialogService = t, this._imageIoService = r, this._currentUniverService = o, this._drawingRenderService = i, this._initialize();
1592
+ }, __name(_a4, "ImageCropperController"), _a4);
1593
+ ImageCropperController = __decorateClass$2([
1594
+ OnLifecycle(LifecycleStages.Rendered, ImageCropperController),
1595
+ __decorateParam$2(0, ICommandService),
1596
+ __decorateParam$2(1, IDrawingManagerService),
1597
+ __decorateParam$2(2, IRenderManagerService),
1598
+ __decorateParam$2(3, IUniverInstanceService),
1599
+ __decorateParam$2(4, IMessageService),
1600
+ __decorateParam$2(5, Inject(LocaleService))
1601
+ ], ImageCropperController);
1602
+ var __defProp$1 = Object.defineProperty, __getOwnPropDesc$1 = Object.getOwnPropertyDescriptor, __decorateClass$1 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
1603
+ for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$1(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
1604
+ (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
1605
+ return kind && result && __defProp$1(target, key, result), result;
1606
+ }, "__decorateClass$1"), __decorateParam$1 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$1");
1607
+ const IMAGE_VIEWER_DROPDOWN_PADDING = 50;
1608
+ var _a5;
1609
+ let ImageUpdateController = (_a5 = class extends Disposable {
1610
+ constructor(_commandService, _renderManagerService, _drawingManagerService, _dialogService, _imageIoService, _currentUniverService, _drawingRenderService) {
1611
+ super(), this._commandService = _commandService, this._renderManagerService = _renderManagerService, this._drawingManagerService = _drawingManagerService, this._dialogService = _dialogService, this._imageIoService = _imageIoService, this._currentUniverService = _currentUniverService, this._drawingRenderService = _drawingRenderService, this._initialize();
1601
1612
  }
1602
1613
  dispose() {
1603
1614
  super.dispose();
@@ -1606,225 +1617,225 @@ let je = class extends Ae {
1606
1617
  this._recoveryImages(), this._drawingAddListener(), this._commandExecutedListener(), this._imageUpdateListener();
1607
1618
  }
1608
1619
  _recoveryImages() {
1609
- const a = this._drawingManagerService.drawingManagerData, n = Ke(this._currentUniverService);
1610
- if (n == null)
1620
+ const drawingList = this._drawingManagerService.drawingManagerData, info = getCurrentUnitInfo(this._currentUniverService);
1621
+ if (info == null)
1611
1622
  return;
1612
- const { unitId: e, subUnitId: t } = n;
1613
- Object.keys(a).forEach((r) => {
1614
- Object.keys(a[r]).forEach((o) => {
1615
- const i = a[r][o].data;
1616
- i == null || r !== e || o !== t || Object.keys(i).forEach((s) => {
1617
- i[s] && this._insertImages([{ unitId: r, subUnitId: o, drawingId: s }]);
1623
+ const { unitId: currentUnitId, subUnitId: currentSubUnitId } = info;
1624
+ Object.keys(drawingList).forEach((unitId) => {
1625
+ Object.keys(drawingList[unitId]).forEach((subUnitId) => {
1626
+ const drawingMap = drawingList[unitId][subUnitId].data;
1627
+ drawingMap == null || unitId !== currentUnitId || subUnitId !== currentSubUnitId || Object.keys(drawingMap).forEach((drawingId) => {
1628
+ drawingMap[drawingId] && this._insertImages([{ unitId, subUnitId, drawingId }]);
1618
1629
  });
1619
1630
  });
1620
1631
  });
1621
1632
  }
1622
1633
  _commandExecutedListener() {
1623
1634
  this.disposeWithMe(
1624
- this._commandService.onCommandExecuted((a) => {
1625
- if (a.id === bt.id) {
1626
- const n = a.params;
1627
- if (n == null)
1635
+ this._commandService.onCommandExecuted((command) => {
1636
+ if (command.id === ImageResetSizeOperation.id) {
1637
+ const params = command.params;
1638
+ if (params == null)
1628
1639
  return;
1629
- this._resetImageSize(n);
1640
+ this._resetImageSize(params);
1630
1641
  }
1631
1642
  })
1632
1643
  );
1633
1644
  }
1634
- _getSceneAndTransformerByDrawingSearch(a) {
1635
- if (a == null)
1645
+ _getSceneAndTransformerByDrawingSearch(unitId) {
1646
+ if (unitId == null)
1636
1647
  return;
1637
- const n = this._renderManagerService.getRenderById(a), e = n == null ? void 0 : n.scene;
1638
- if (e == null)
1648
+ const renderObject = this._renderManagerService.getRenderById(unitId), scene = renderObject == null ? void 0 : renderObject.scene;
1649
+ if (scene == null)
1639
1650
  return null;
1640
- const t = e.getTransformerByCreate();
1641
- return { scene: e, transformer: t };
1642
- }
1643
- _resetImageSize(a) {
1644
- const n = [], e = [];
1645
- a.forEach((t) => {
1646
- const { unitId: r, subUnitId: o, drawingId: i } = t, s = this._getSceneAndTransformerByDrawingSearch(r);
1647
- if (s == null)
1651
+ const transformer = scene.getTransformerByCreate();
1652
+ return { scene, transformer };
1653
+ }
1654
+ _resetImageSize(params) {
1655
+ const updateParams = [], sceneList = [];
1656
+ params.forEach((param) => {
1657
+ const { unitId, subUnitId, drawingId } = param, renderObject = this._getSceneAndTransformerByDrawingSearch(unitId);
1658
+ if (renderObject == null)
1648
1659
  return;
1649
- const { scene: l } = s, m = G({ unitId: r, subUnitId: o, drawingId: i }), u = l.getObject(m);
1650
- if (u == null)
1660
+ const { scene } = renderObject, imageShapeKey = getDrawingShapeKeyByDrawingSearch({ unitId, subUnitId, drawingId }), imageShape = scene.getObject(imageShapeKey);
1661
+ if (imageShape == null)
1651
1662
  return !0;
1652
- const d = this._drawingManagerService.getDrawingByParam(t);
1653
- if (d == null)
1663
+ const imageData = this._drawingManagerService.getDrawingByParam(param);
1664
+ if (imageData == null)
1654
1665
  return !0;
1655
- if (d.drawingType !== re.DRAWING_IMAGE)
1666
+ if (imageData.drawingType !== DrawingTypeEnum.DRAWING_IMAGE)
1656
1667
  return;
1657
- u.resetSize();
1658
- const { width: h, height: f } = u.getNativeSize();
1659
- e.includes(l) === !1 && e.push(l), n.push({
1660
- ...d,
1668
+ imageShape.resetSize();
1669
+ const { width, height } = imageShape.getNativeSize();
1670
+ sceneList.includes(scene) === !1 && sceneList.push(scene), updateParams.push({
1671
+ ...imageData,
1661
1672
  transform: {
1662
- ...d.transform,
1663
- height: f,
1664
- width: h,
1673
+ ...imageData.transform,
1674
+ height,
1675
+ width,
1665
1676
  angle: 0
1666
1677
  },
1667
1678
  srcRect: null,
1668
1679
  prstGeom: null
1669
1680
  });
1670
- }), this._drawingManagerService.featurePluginUpdateNotification(n), e.forEach((t) => {
1671
- t.getTransformerByCreate().refreshControls().changeNotification();
1672
- }), this._drawingManagerService.focusDrawing(a);
1681
+ }), this._drawingManagerService.featurePluginUpdateNotification(updateParams), sceneList.forEach((scene) => {
1682
+ scene.getTransformerByCreate().refreshControls().changeNotification();
1683
+ }), this._drawingManagerService.focusDrawing(params);
1673
1684
  }
1674
1685
  _drawingAddListener() {
1675
1686
  this.disposeWithMe(
1676
- this._drawingManagerService.add$.subscribe((a) => {
1677
- this._insertImages(a);
1687
+ this._drawingManagerService.add$.subscribe((params) => {
1688
+ this._insertImages(params);
1678
1689
  })
1679
1690
  );
1680
1691
  }
1681
- _insertImages(a) {
1682
- a.forEach(async (n) => {
1683
- var l;
1684
- const { unitId: e, subUnitId: t } = n, r = this._getSceneAndTransformerByDrawingSearch(e), o = (l = Ke(this._currentUniverService)) == null ? void 0 : l.subUnitId;
1685
- if (r == null || o !== t)
1692
+ _insertImages(params) {
1693
+ params.forEach(async (param) => {
1694
+ var _a7;
1695
+ const { unitId, subUnitId } = param, renderObject = this._getSceneAndTransformerByDrawingSearch(unitId), currentSubUnitId = (_a7 = getCurrentUnitInfo(this._currentUniverService)) == null ? void 0 : _a7.subUnitId;
1696
+ if (renderObject == null || currentSubUnitId !== subUnitId)
1686
1697
  return;
1687
- const i = this._drawingManagerService.getDrawingByParam(n);
1688
- if (i == null)
1698
+ const imageParam = this._drawingManagerService.getDrawingByParam(param);
1699
+ if (imageParam == null)
1689
1700
  return;
1690
- const s = await this._drawingRenderService.renderImages(i, r.scene);
1691
- if (!(s == null || s.length === 0))
1692
- for (const m of s)
1693
- this._addHoverForImage(m), this._addDialogForImage(m);
1701
+ const images = await this._drawingRenderService.renderImages(imageParam, renderObject.scene);
1702
+ if (!(images == null || images.length === 0))
1703
+ for (const image of images)
1704
+ this._addHoverForImage(image), this._addDialogForImage(image);
1694
1705
  });
1695
1706
  }
1696
1707
  _imageUpdateListener() {
1697
1708
  this.disposeWithMe(
1698
- this._drawingManagerService.update$.subscribe((a) => {
1699
- a.forEach((n) => {
1700
- const { unitId: e, subUnitId: t, drawingId: r } = n, o = this._drawingManagerService.getDrawingByParam(n);
1701
- if (o == null)
1709
+ this._drawingManagerService.update$.subscribe((params) => {
1710
+ params.forEach((param) => {
1711
+ const { unitId, subUnitId, drawingId } = param, drawingParam = this._drawingManagerService.getDrawingByParam(param);
1712
+ if (drawingParam == null)
1702
1713
  return;
1703
- const { transform: i, drawingType: s, srcRect: l, prstGeom: m, source: u, imageSourceType: d } = o;
1704
- if (s !== re.DRAWING_IMAGE)
1714
+ const { transform, drawingType, srcRect, prstGeom, source, imageSourceType } = drawingParam;
1715
+ if (drawingType !== DrawingTypeEnum.DRAWING_IMAGE)
1705
1716
  return;
1706
- const h = this._getSceneAndTransformerByDrawingSearch(e);
1707
- if (h == null)
1717
+ const renderObject = this._getSceneAndTransformerByDrawingSearch(unitId);
1718
+ if (renderObject == null)
1708
1719
  return;
1709
- const { scene: f, transformer: v } = h;
1710
- if (i == null)
1720
+ const { scene, transformer } = renderObject;
1721
+ if (transform == null)
1711
1722
  return !0;
1712
- const w = G({ unitId: e, subUnitId: t, drawingId: r }), p = f.getObject(w);
1713
- if (p == null)
1723
+ const drawingShapeKey = getDrawingShapeKeyByDrawingSearch({ unitId, subUnitId, drawingId }), imageShape = scene.getObject(drawingShapeKey);
1724
+ if (imageShape == null)
1714
1725
  return !0;
1715
- p.setSrcRect(l), p.setPrstGeom(m);
1726
+ imageShape.setSrcRect(srcRect), imageShape.setPrstGeom(prstGeom);
1716
1727
  });
1717
1728
  })
1718
1729
  );
1719
1730
  }
1720
- _addHoverForImage(a) {
1731
+ _addHoverForImage(o) {
1721
1732
  this.disposeWithMe(
1722
- _e(
1723
- a.onPointerEnter$.subscribeEvent(() => {
1724
- a.cursor = Ue.GRAB;
1733
+ toDisposable(
1734
+ o.onPointerEnter$.subscribeEvent(() => {
1735
+ o.cursor = CURSOR_TYPE.GRAB;
1725
1736
  })
1726
1737
  )
1727
1738
  ), this.disposeWithMe(
1728
- _e(
1729
- a.onPointerLeave$.subscribeEvent(() => {
1730
- a.cursor = Ue.DEFAULT;
1739
+ toDisposable(
1740
+ o.onPointerLeave$.subscribeEvent(() => {
1741
+ o.cursor = CURSOR_TYPE.DEFAULT;
1731
1742
  })
1732
1743
  )
1733
1744
  );
1734
1745
  }
1735
- _addDialogForImage(a) {
1746
+ _addDialogForImage(o) {
1736
1747
  this.disposeWithMe(
1737
- _e(
1738
- a.onDblclick$.subscribeEvent(() => {
1739
- var s;
1740
- const n = `${a.oKey}-viewer-dialog`, e = a.getNativeSize(), t = window.innerWidth - rt, r = window.innerHeight - rt, o = this._adjustImageSize(e.width, e.height, t, r), i = this._dialogService.open({
1741
- width: o.width,
1742
- id: n,
1748
+ toDisposable(
1749
+ o.onDblclick$.subscribeEvent(() => {
1750
+ var _a7;
1751
+ const dialogId = `${o.oKey}-viewer-dialog`, nativeSize = o.getNativeSize(), screenWidth = window.innerWidth - IMAGE_VIEWER_DROPDOWN_PADDING, screenHeight = window.innerHeight - IMAGE_VIEWER_DROPDOWN_PADDING, adjustSize = this._adjustImageSize(nativeSize.width, nativeSize.height, screenWidth, screenHeight), dialog = this._dialogService.open({
1752
+ width: adjustSize.width,
1753
+ id: dialogId,
1743
1754
  style: { margin: "0", top: "50%", left: "50%", transform: "translate(-50%, -50%)" },
1744
1755
  children: {
1745
1756
  label: {
1746
- name: St,
1757
+ name: COMPONENT_IMAGE_VIEWER,
1747
1758
  props: {
1748
- src: (s = a.getNative()) == null ? void 0 : s.src,
1749
- width: o.width,
1750
- height: o.height
1759
+ src: (_a7 = o.getNative()) == null ? void 0 : _a7.src,
1760
+ width: adjustSize.width,
1761
+ height: adjustSize.height
1751
1762
  }
1752
1763
  }
1753
1764
  },
1754
1765
  destroyOnClose: !0,
1755
1766
  draggable: !1,
1756
- onClose: () => {
1757
- this._dialogService.close(n), i.dispose();
1758
- }
1767
+ onClose: /* @__PURE__ */ __name(() => {
1768
+ this._dialogService.close(dialogId), dialog.dispose();
1769
+ }, "onClose")
1759
1770
  });
1760
1771
  })
1761
1772
  )
1762
1773
  );
1763
1774
  }
1764
- _adjustImageSize(a, n, e, t) {
1765
- if (a <= e && n <= t)
1775
+ _adjustImageSize(nativeWidth, nativeHeight, screenWidth, screenHeight) {
1776
+ if (nativeWidth <= screenWidth && nativeHeight <= screenHeight)
1766
1777
  return {
1767
- width: a,
1768
- height: n
1778
+ width: nativeWidth,
1779
+ height: nativeHeight
1769
1780
  };
1770
- const r = e / a, o = t / n, i = Math.min(r, o);
1781
+ const widthRatio = screenWidth / nativeWidth, heightRatio = screenHeight / nativeHeight, scale = Math.min(widthRatio, heightRatio);
1771
1782
  return {
1772
- width: Math.floor(a * i),
1773
- height: Math.floor(n * i)
1783
+ width: Math.floor(nativeWidth * scale),
1784
+ height: Math.floor(nativeHeight * scale)
1774
1785
  };
1775
1786
  }
1776
- };
1777
- je = Jn([
1778
- xe(Ve.Rendered, je),
1779
- ce(0, ue),
1780
- ce(1, he),
1781
- ce(2, ae),
1782
- ce(3, $t),
1783
- ce(4, ot),
1784
- ce(5, Xe),
1785
- ce(6, ge(He))
1786
- ], je);
1787
- var qn = Object.defineProperty, Qn = Object.getOwnPropertyDescriptor, er = (a, n, e, t) => {
1788
- for (var r = t > 1 ? void 0 : t ? Qn(n, e) : n, o = a.length - 1, i; o >= 0; o--)
1789
- (i = a[o]) && (r = (t ? i(n, e, r) : i(r)) || r);
1790
- return t && r && qn(n, e, r), r;
1791
- }, at = (a, n) => (e, t) => n(e, t, a);
1792
- const tr = "DRAWING_UI_PLUGIN";
1793
- var ze;
1794
- let it = (ze = class extends Lt {
1795
- constructor(a, n, e) {
1796
- super(), this._injector = n, this._localeService = e;
1797
- }
1798
- onStarting(a) {
1799
- this._initDependencies(a);
1800
- }
1801
- _initDependencies(a) {
1787
+ }, __name(_a5, "ImageUpdateController"), _a5);
1788
+ ImageUpdateController = __decorateClass$1([
1789
+ OnLifecycle(LifecycleStages.Rendered, ImageUpdateController),
1790
+ __decorateParam$1(0, ICommandService),
1791
+ __decorateParam$1(1, IRenderManagerService),
1792
+ __decorateParam$1(2, IDrawingManagerService),
1793
+ __decorateParam$1(3, IDialogService),
1794
+ __decorateParam$1(4, IImageIoService),
1795
+ __decorateParam$1(5, IUniverInstanceService),
1796
+ __decorateParam$1(6, Inject(DrawingRenderService))
1797
+ ], ImageUpdateController);
1798
+ var __defProp2 = Object.defineProperty, __getOwnPropDesc = Object.getOwnPropertyDescriptor, __decorateClass = /* @__PURE__ */ __name((decorators, target, key, kind) => {
1799
+ for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
1800
+ (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
1801
+ return kind && result && __defProp2(target, key, result), result;
1802
+ }, "__decorateClass"), __decorateParam = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam");
1803
+ const PLUGIN_NAME = "DRAWING_UI_PLUGIN";
1804
+ var _a6;
1805
+ let UniverDrawingUIPlugin = (_a6 = class extends Plugin {
1806
+ constructor(config, _injector, _localeService) {
1807
+ super(), this._injector = _injector, this._localeService = _localeService;
1808
+ }
1809
+ onStarting() {
1810
+ this._initDependencies();
1811
+ }
1812
+ _initDependencies() {
1802
1813
  [
1803
1814
  // services
1804
- [He],
1815
+ [DrawingRenderService],
1805
1816
  // controllers
1806
- [De],
1807
- [Te],
1808
- [Be],
1809
- [je]
1810
- ].forEach((e) => a.add(e));
1811
- }
1812
- }, te(ze, "pluginName", tr), ze);
1813
- it = er([
1814
- at(1, ge(mt)),
1815
- at(2, ge(Y))
1816
- ], it);
1817
+ [DrawingUpdateController],
1818
+ [DrawingUIController],
1819
+ [ImageCropperController],
1820
+ [ImageUpdateController]
1821
+ ].forEach((dependency) => this._injector.add(dependency));
1822
+ }
1823
+ }, __name(_a6, "UniverDrawingUIPlugin"), __publicField(_a6, "pluginName", PLUGIN_NAME), _a6);
1824
+ UniverDrawingUIPlugin = __decorateClass([
1825
+ __decorateParam(1, Inject(Injector)),
1826
+ __decorateParam(2, Inject(LocaleService))
1827
+ ], UniverDrawingUIPlugin);
1817
1828
  export {
1818
- Le as AutoImageCropOperation,
1819
- An as COMPONENT_IMAGE_POPUP_MENU,
1820
- me as CloseImageCropOperation,
1821
- dr as DrawingCommonPanel,
1822
- He as DrawingRenderService,
1823
- Oe as ImageCropperObject,
1824
- Ln as ImagePopupMenu,
1825
- bt as ImageResetSizeOperation,
1826
- Ze as OpenImageCropOperation,
1827
- Je as SetDrawingAlignOperation,
1828
- it as UniverDrawingUIPlugin,
1829
- Ge as getUpdateParams
1829
+ AutoImageCropOperation,
1830
+ COMPONENT_IMAGE_POPUP_MENU,
1831
+ CloseImageCropOperation,
1832
+ DrawingCommonPanel,
1833
+ DrawingRenderService,
1834
+ ImageCropperObject,
1835
+ ImagePopupMenu,
1836
+ ImageResetSizeOperation,
1837
+ OpenImageCropOperation,
1838
+ SetDrawingAlignOperation,
1839
+ UniverDrawingUIPlugin,
1840
+ getUpdateParams
1830
1841
  };