@univerjs/drawing-ui 0.1.13

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.
Files changed (36) hide show
  1. package/LICENSE +176 -0
  2. package/README.md +16 -0
  3. package/lib/cjs/index.js +1 -0
  4. package/lib/es/index.js +1778 -0
  5. package/lib/index.css +1 -0
  6. package/lib/locale/en-US.json +54 -0
  7. package/lib/locale/ru-RU.json +54 -0
  8. package/lib/locale/zh-CN.json +54 -0
  9. package/lib/types/commands/operations/drawing-align.operation.d.ts +17 -0
  10. package/lib/types/commands/operations/image-crop.operation.d.ts +22 -0
  11. package/lib/types/commands/operations/image-reset-size.operation.d.ts +3 -0
  12. package/lib/types/controllers/drawing-ui.controller.d.ts +16 -0
  13. package/lib/types/controllers/drawing-update.controller.d.ts +35 -0
  14. package/lib/types/controllers/image-cropper.controller.d.ts +27 -0
  15. package/lib/types/controllers/image-update.controller.d.ts +26 -0
  16. package/lib/types/controllers/utils.d.ts +9 -0
  17. package/lib/types/index.d.ts +23 -0
  18. package/lib/types/locale/en-US.d.ts +4 -0
  19. package/lib/types/locale/ru-RU.d.ts +4 -0
  20. package/lib/types/locale/zh-CN.d.ts +70 -0
  21. package/lib/types/plugin.d.ts +11 -0
  22. package/lib/types/utils/config.d.ts +18 -0
  23. package/lib/types/utils/get-update-params.d.ts +5 -0
  24. package/lib/types/views/crop/image-cropper-object.d.ts +34 -0
  25. package/lib/types/views/image-popup-menu/ImagePopupMenu.d.ts +19 -0
  26. package/lib/types/views/image-popup-menu/component-name.d.ts +16 -0
  27. package/lib/types/views/image-viewer/ImageViewer.d.ts +7 -0
  28. package/lib/types/views/image-viewer/component-name.d.ts +16 -0
  29. package/lib/types/views/panel/DrawingAlign.d.ts +8 -0
  30. package/lib/types/views/panel/DrawingArrange.d.ts +8 -0
  31. package/lib/types/views/panel/DrawingCommonPanel.d.ts +12 -0
  32. package/lib/types/views/panel/DrawingGroup.d.ts +8 -0
  33. package/lib/types/views/panel/DrawingTransform.d.ts +8 -0
  34. package/lib/types/views/panel/ImageCropper.d.ts +8 -0
  35. package/lib/umd/index.js +1 -0
  36. package/package.json +86 -0
@@ -0,0 +1,1778 @@
1
+ var yt = Object.defineProperty;
2
+ var Et = (a, n, t) => n in a ? yt(a, n, { enumerable: !0, configurable: !0, writable: !0, value: t }) : a[n] = t;
3
+ var ne = (a, n, t) => (Et(a, typeof n != "symbol" ? n + "" : n, t), t);
4
+ import { DrawingTypeEnum as oe, IDrawingManagerService as se, ArrangeTypeEnum as Pe, getDrawingShapeKeyByDrawingSearch as V, ImageSourceType as Rt, IImageIoService as Mt } from "@univerjs/drawing";
5
+ import { CommandType as be, LocaleService as J, debounce as ye, ICommandService as le, Tools as Ot, UniverInstanceType as xe, Disposable as He, checkIfMove as tt, toDisposable as K, OnLifecycle as Le, LifecycleStages as Ae, IUniverInstanceService as ze, Plugin as Nt } from "@univerjs/core";
6
+ import { useDependency as x } from "@wendellhu/redi/react-bindings";
7
+ import l, { forwardRef as q, useRef as nt, createElement as Q, useState as A, useEffect as Ie } from "react";
8
+ import { IRenderManagerService as fe, getGroupState as Dt, transformObjectOutOfGroup as Tt, Group as _e, DRAWING_OBJECT_LAYER_INDEX as $e, RENDER_CLASS_TYPE as Ye, Shape as Bt, Rect as jt, Canvas as Ut, Image as We, precisionTo as Ee, CURSOR_TYPE as je, Vector2 as Ve, degToRad as Xe } from "@univerjs/engine-render";
9
+ import { Button as ie, InputNumber as Ce, Checkbox as Ht, Select as rt, Dropdown as Lt, MessageType as Je } from "@univerjs/design";
10
+ import D from "clsx";
11
+ import { Inject as de, Injector as at } from "@wendellhu/redi";
12
+ import { ComponentManager as At, IMenuService as xt, IMessageService as Vt, IDialogService as Gt } from "@univerjs/ui";
13
+ function Se(a, n) {
14
+ const t = [];
15
+ return a.forEach((e) => {
16
+ const { oKey: r, left: o, top: i, height: s, width: c, angle: g } = e, u = n.getDrawingOKey(r);
17
+ if (u == null)
18
+ return t.push(null), !0;
19
+ const { unitId: d, subUnitId: h, drawingId: f, drawingType: v } = u, w = {
20
+ unitId: d,
21
+ subUnitId: h,
22
+ drawingId: f,
23
+ drawingType: v,
24
+ transform: {
25
+ left: o,
26
+ top: i,
27
+ height: s,
28
+ width: c,
29
+ angle: g
30
+ }
31
+ };
32
+ v === oe.DRAWING_IMAGE && (w.srcRect = e.srcRect), t.push(w);
33
+ }), t;
34
+ }
35
+ const it = {
36
+ id: "sheet.operation.image-reset-size",
37
+ type: be.OPERATION,
38
+ handler: (a, n) => !0
39
+ }, ke = {
40
+ id: "sheet.operation.open-image-crop",
41
+ type: be.OPERATION,
42
+ handler: (a, n) => !0
43
+ }, he = {
44
+ id: "sheet.operation.close-image-crop",
45
+ type: be.OPERATION,
46
+ handler: (a, n) => !0
47
+ };
48
+ var H = /* @__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))(H || {});
49
+ const Ue = {
50
+ id: "sheet.operation.Auto-image-crop",
51
+ type: be.OPERATION,
52
+ handler: (a, n) => !0
53
+ };
54
+ var z = function() {
55
+ return z = Object.assign || function(a) {
56
+ for (var n, t = 1, e = arguments.length; t < e; t++) {
57
+ n = arguments[t];
58
+ for (var r in n)
59
+ Object.prototype.hasOwnProperty.call(n, r) && (a[r] = n[r]);
60
+ }
61
+ return a;
62
+ }, z.apply(this, arguments);
63
+ }, Wt = function(a, n) {
64
+ var t = {};
65
+ for (var e in a)
66
+ Object.prototype.hasOwnProperty.call(a, e) && n.indexOf(e) < 0 && (t[e] = a[e]);
67
+ if (a != null && typeof Object.getOwnPropertySymbols == "function")
68
+ for (var r = 0, e = Object.getOwnPropertySymbols(a); r < e.length; r++)
69
+ n.indexOf(e[r]) < 0 && Object.prototype.propertyIsEnumerable.call(a, e[r]) && (t[e[r]] = a[e[r]]);
70
+ return t;
71
+ }, ee = q(function(a, n) {
72
+ var t = a.icon, e = a.id, r = a.className, o = a.extend, i = Wt(a, ["icon", "id", "className", "extend"]), s = "univerjs-icon univerjs-icon-".concat(e, " ").concat(r || "").trim(), c = nt("_".concat($t()));
73
+ return ot(t, "".concat(e), { defIds: t.defIds, idSuffix: c.current }, z({ ref: n, className: s }, i), o);
74
+ });
75
+ function ot(a, n, t, e, r) {
76
+ return Q(a.tag, z(z({ key: n }, kt(a, t, r)), e), (zt(a, t).children || []).map(function(o, i) {
77
+ return ot(o, "".concat(n, "-").concat(a.tag, "-").concat(i), t, void 0, r);
78
+ }));
79
+ }
80
+ function kt(a, n, t) {
81
+ var e = z({}, a.attrs);
82
+ t != null && t.colorChannel1 && e.fill === "colorChannel1" && (e.fill = t.colorChannel1);
83
+ var r = n.defIds;
84
+ return !r || r.length === 0 || (a.tag === "use" && e["xlink:href"] && (e["xlink:href"] = e["xlink:href"] + n.idSuffix), Object.entries(e).forEach(function(o) {
85
+ var i = o[0], s = o[1];
86
+ typeof s == "string" && (e[i] = s.replace(/url\(#(.*)\)/, "url(#$1".concat(n.idSuffix, ")")));
87
+ })), e;
88
+ }
89
+ function zt(a, n) {
90
+ var t, e = n.defIds;
91
+ return !e || e.length === 0 ? a : a.tag === "defs" && (!((t = a.children) === null || t === void 0) && t.length) ? z(z({}, a), { children: a.children.map(function(r) {
92
+ return typeof r.attrs.id == "string" && e && e.indexOf(r.attrs.id) > -1 ? z(z({}, r), { attrs: z(z({}, r.attrs), { id: r.attrs.id + n.idSuffix }) }) : r;
93
+ }) }) : a;
94
+ }
95
+ function $t() {
96
+ return Math.random().toString(36).substring(2, 8);
97
+ }
98
+ ee.displayName = "UniverIcon";
99
+ var Ft = { 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" } }] }, st = q(function(a, n) {
100
+ return Q(ee, Object.assign({}, a, {
101
+ id: "autofill",
102
+ ref: n,
103
+ icon: Ft
104
+ }));
105
+ });
106
+ st.displayName = "Autofill";
107
+ const Kt = st;
108
+ var Zt = { 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" } }] }, lt = q(function(a, n) {
109
+ return Q(ee, Object.assign({}, a, {
110
+ id: "bottom-single",
111
+ ref: n,
112
+ icon: Zt
113
+ }));
114
+ });
115
+ lt.displayName = "BottomSingle";
116
+ const Yt = lt;
117
+ var Xt = { 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" } }] }, ct = q(function(a, n) {
118
+ return Q(ee, Object.assign({}, a, {
119
+ id: "create-copy-single",
120
+ ref: n,
121
+ icon: Xt
122
+ }));
123
+ });
124
+ ct.displayName = "CreateCopySingle";
125
+ const Jt = ct;
126
+ var qt = { 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" } }] }, mt = q(function(a, n) {
127
+ return Q(ee, Object.assign({}, a, {
128
+ id: "group-single",
129
+ ref: n,
130
+ icon: qt
131
+ }));
132
+ });
133
+ mt.displayName = "GroupSingle";
134
+ const Qt = mt;
135
+ var en = { 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" } }] }, gt = q(function(a, n) {
136
+ return Q(ee, Object.assign({}, a, {
137
+ id: "more-down-single",
138
+ ref: n,
139
+ icon: en
140
+ }));
141
+ });
142
+ gt.displayName = "MoreDownSingle";
143
+ const tn = gt;
144
+ var nn = { 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" } }] }, ut = q(function(a, n) {
145
+ return Q(ee, Object.assign({}, a, {
146
+ id: "move-down-single",
147
+ ref: n,
148
+ icon: nn
149
+ }));
150
+ });
151
+ ut.displayName = "MoveDownSingle";
152
+ const rn = ut;
153
+ var an = { 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" } }] }, dt = q(function(a, n) {
154
+ return Q(ee, Object.assign({}, a, {
155
+ id: "move-up-single",
156
+ ref: n,
157
+ icon: an
158
+ }));
159
+ });
160
+ dt.displayName = "MoveUpSingle";
161
+ const on = dt;
162
+ var sn = { 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" } }] }, ht = q(function(a, n) {
163
+ return Q(ee, Object.assign({}, a, {
164
+ id: "topmost-single",
165
+ ref: n,
166
+ icon: sn
167
+ }));
168
+ });
169
+ ht.displayName = "TopmostSingle";
170
+ const ln = ht;
171
+ var cn = { 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" } }] }, ft = q(function(a, n) {
172
+ return Q(ee, Object.assign({}, a, {
173
+ id: "ungroup-single",
174
+ ref: n,
175
+ icon: cn
176
+ }));
177
+ });
178
+ ft.displayName = "UngroupSingle";
179
+ const mn = ft, gn = "univer-image-common-panel", un = "univer-image-common-panel-grid", dn = "univer-image-common-panel-border", hn = "univer-image-common-panel-title", 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", m = {
180
+ imageCommonPanel: gn,
181
+ imageCommonPanelGrid: un,
182
+ imageCommonPanelBorder: dn,
183
+ imageCommonPanelTitle: hn,
184
+ imageCommonPanelRow: fn,
185
+ imageCommonPanelRowVertical: pn,
186
+ imageCommonPanelColumn: Cn,
187
+ imageCommonPanelColumnCenter: wn,
188
+ imageCommonPanelInline: vn,
189
+ imageCommonPanelSpan2: _n,
190
+ imageCommonPanelSpan3: Sn,
191
+ imageCommonPanelInput: bn
192
+ }, In = (a) => {
193
+ const { arrangeShow: n, drawings: t } = a, e = x(J), r = x(se), o = (g) => g ? "block" : "none", [i, s] = A(t);
194
+ Ie(() => {
195
+ const g = r.focus$.subscribe((u) => {
196
+ s(u);
197
+ });
198
+ return () => {
199
+ g.unsubscribe();
200
+ };
201
+ }, []);
202
+ const c = (g) => {
203
+ const u = i[0].unitId, d = i[0].subUnitId, h = i.map((f) => f.drawingId);
204
+ r.featurePluginOrderUpdateNotification({ unitId: u, subUnitId: d, drawingIds: h, arrangeType: g });
205
+ };
206
+ return /* @__PURE__ */ l.createElement("div", { className: m.imageCommonPanelGrid, style: { display: o(n) } }, /* @__PURE__ */ l.createElement("div", { className: m.imageCommonPanelRow }, /* @__PURE__ */ l.createElement("div", { className: D(m.imageCommonPanelColumn, m.imageCommonPanelTitle) }, /* @__PURE__ */ l.createElement("div", null, e.t("image-panel.arrange.title")))), /* @__PURE__ */ l.createElement("div", { className: m.imageCommonPanelRow }, /* @__PURE__ */ l.createElement("div", { className: D(m.imageCommonPanelColumn, m.imageCommonPanelSpan2) }, /* @__PURE__ */ l.createElement(ie, { size: "small", onClick: () => {
207
+ c(Pe.forward);
208
+ } }, /* @__PURE__ */ l.createElement("span", { className: m.imageCommonPanelInline }, /* @__PURE__ */ l.createElement(on, null), e.t("image-panel.arrange.forward")))), /* @__PURE__ */ l.createElement("div", { className: D(m.imageCommonPanelColumn, m.imageCommonPanelSpan2) }, /* @__PURE__ */ l.createElement(ie, { size: "small", onClick: () => {
209
+ c(Pe.backward);
210
+ } }, /* @__PURE__ */ l.createElement("span", { className: m.imageCommonPanelInline }, /* @__PURE__ */ l.createElement(rn, null), e.t("image-panel.arrange.backward"))))), /* @__PURE__ */ l.createElement("div", { className: m.imageCommonPanelRow }, /* @__PURE__ */ l.createElement("div", { className: D(m.imageCommonPanelColumn, m.imageCommonPanelSpan2) }, /* @__PURE__ */ l.createElement(ie, { size: "small", onClick: () => {
211
+ c(Pe.front);
212
+ } }, /* @__PURE__ */ l.createElement("span", { className: m.imageCommonPanelInline }, /* @__PURE__ */ l.createElement(ln, null), e.t("image-panel.arrange.front")))), /* @__PURE__ */ l.createElement("div", { className: D(m.imageCommonPanelColumn, m.imageCommonPanelSpan2) }, /* @__PURE__ */ l.createElement(ie, { size: "small", onClick: () => {
213
+ c(Pe.back);
214
+ } }, /* @__PURE__ */ l.createElement("span", { className: m.imageCommonPanelInline }, /* @__PURE__ */ l.createElement(Yt, null), e.t("image-panel.arrange.back"))))));
215
+ }, ae = 20, Pn = 20, yn = [-3600, 3600], Re = 300, En = (a) => {
216
+ var Ze;
217
+ const n = x(J), t = x(se), e = x(fe), { drawings: r, transformShow: o } = a, i = r[0];
218
+ if (i == null)
219
+ return;
220
+ const s = i.transform;
221
+ if (s == null)
222
+ return;
223
+ const { unitId: c, subUnitId: g, drawingId: u, drawingType: d } = i, h = e.getRenderById(c), f = h == null ? void 0 : h.scene;
224
+ if (f == null)
225
+ return;
226
+ const v = (Ze = f.getEngine()) == null ? void 0 : Ze.activeScene;
227
+ if (v == null)
228
+ return;
229
+ const w = f.getTransformerByCreate(), {
230
+ width: p = 0,
231
+ height: E = 0,
232
+ left: _ = 0,
233
+ top: O = 0,
234
+ angle: S = 0
235
+ } = s, [I, b] = A(p), [R, P] = A(E), [y, M] = A(_), [B, U] = A(O), [te, G] = A(S), [ce, Z] = A(w.keepRatio), me = (C, L, j, T) => {
236
+ const { width: Y, height: X } = v, { ancestorLeft: W, ancestorTop: k } = f;
237
+ let $ = C, F = L, re = j, pe = T;
238
+ return C + W < 0 && ($ = -W), L + k < 0 && (F = -k), $ + j + W > Y && (re = Y - $ - W), re < ae && (re = ae), F + T + k > X && (pe = X - F - k), pe < ae && (pe = ae), C + re + W > Y && ($ = Y - j - W), L + pe + k > X && (F = X - T - k), {
239
+ limitLeft: $,
240
+ limitTop: F,
241
+ limitWidth: re,
242
+ limitHeight: pe
243
+ };
244
+ }, Ke = (C) => {
245
+ const { objects: L } = C, j = Se(L, t);
246
+ if (j.length !== 1)
247
+ return;
248
+ const T = j[0];
249
+ if (T == null)
250
+ return;
251
+ const Y = T.transform;
252
+ if (Y == null)
253
+ return;
254
+ const {
255
+ width: X,
256
+ height: W,
257
+ left: k,
258
+ top: $,
259
+ angle: F
260
+ } = Y;
261
+ X != null && b(X), W != null && P(W), k != null && M(k), $ != null && U($), F != null && G(F);
262
+ };
263
+ Ie(() => {
264
+ const C = w.onChangeStartObservable.add((T) => {
265
+ Ke(T);
266
+ }), L = w.onChangingObservable.add((T) => {
267
+ Ke(T);
268
+ }), j = t.focus$.subscribe((T) => {
269
+ if (T.length !== 1)
270
+ return;
271
+ const Y = t.getDrawingByParam(T[0]);
272
+ if (Y == null)
273
+ return;
274
+ const X = Y.transform;
275
+ if (X == null)
276
+ return;
277
+ const {
278
+ width: W,
279
+ height: k,
280
+ left: $,
281
+ top: F,
282
+ angle: re
283
+ } = X;
284
+ W != null && b(W), k != null && P(k), $ != null && M($), F != null && U(F), re != null && G(re);
285
+ });
286
+ return () => {
287
+ L == null || L.dispose(), C == null || C.dispose(), j == null || j.unsubscribe();
288
+ };
289
+ }, []);
290
+ const wt = ye((C) => {
291
+ if (C == null)
292
+ return;
293
+ C = Math.max(C, ae);
294
+ const { limitWidth: L } = me(y, B, C, R);
295
+ C = L;
296
+ const j = { unitId: c, subUnitId: g, drawingId: u, drawingType: d, transform: { width: C } };
297
+ if (ce) {
298
+ let T = C / I * R;
299
+ T = Math.max(T, Pn), P(T), j.transform.height = T;
300
+ }
301
+ b(C), t.featurePluginUpdateNotification([j]), w.refreshControls().changeNotification();
302
+ }, Re), vt = ye((C) => {
303
+ if (C == null)
304
+ return;
305
+ C = Math.max(C, ae);
306
+ const { limitHeight: L } = me(y, B, I, C);
307
+ C = L;
308
+ const j = { unitId: c, subUnitId: g, drawingId: u, drawingType: d, transform: { height: C } };
309
+ if (ce) {
310
+ let T = C / R * I;
311
+ T = Math.max(T, ae), b(T), j.transform.width = T;
312
+ }
313
+ P(C), t.featurePluginUpdateNotification([j]), w.refreshControls().changeNotification();
314
+ }, Re), _t = ye((C) => {
315
+ if (C == null)
316
+ return;
317
+ const { limitLeft: L } = me(C, B, I, R);
318
+ C = L;
319
+ const j = { unitId: c, subUnitId: g, drawingId: u, drawingType: d, transform: { left: C } };
320
+ M(C), t.featurePluginUpdateNotification([j]), w.refreshControls().changeNotification();
321
+ }, Re), St = ye((C) => {
322
+ if (C == null)
323
+ return;
324
+ const { limitTop: L } = me(y, C, I, R);
325
+ C = L;
326
+ const j = { unitId: c, subUnitId: g, drawingId: u, drawingType: d, transform: { top: C } };
327
+ U(C), t.featurePluginUpdateNotification([j]), w.refreshControls().changeNotification();
328
+ }, Re), bt = (C) => {
329
+ if (C == null)
330
+ return;
331
+ const [L, j] = yn;
332
+ C < L && (C = L), C > j && (C = j);
333
+ const T = { unitId: c, subUnitId: g, drawingId: u, drawingType: d, transform: { angle: C } };
334
+ G(C), t.featurePluginUpdateNotification([T]), w.refreshControls().changeNotification();
335
+ }, It = (C) => {
336
+ Z(C), w.keepRatio = C;
337
+ }, Pt = (C) => C ? "block" : "none";
338
+ return /* @__PURE__ */ l.createElement("div", { className: D(m.imageCommonPanelGrid, m.imageCommonPanelBorder), style: { display: Pt(o) } }, /* @__PURE__ */ l.createElement("div", { className: m.imageCommonPanelRow }, /* @__PURE__ */ l.createElement("div", { className: D(m.imageCommonPanelColumn, m.imageCommonPanelTitle) }, /* @__PURE__ */ l.createElement("div", null, n.t("image-panel.transform.title")))), /* @__PURE__ */ l.createElement("div", { className: m.imageCommonPanelRow }, /* @__PURE__ */ l.createElement("div", { className: D(m.imageCommonPanelColumn, m.imageCommonPanelSpan3) }, /* @__PURE__ */ l.createElement("label", null, /* @__PURE__ */ l.createElement("div", { className: m.imageCommonPanelRow }, /* @__PURE__ */ l.createElement("div", { className: m.imageCommonPanelColumn }, n.t("image-panel.transform.width"))), /* @__PURE__ */ l.createElement("div", { className: m.imageCommonPanelRow }, /* @__PURE__ */ l.createElement("div", { className: m.imageCommonPanelColumn }, /* @__PURE__ */ l.createElement(Ce, { precision: 1, value: I, onChange: (C) => {
339
+ wt(C);
340
+ }, className: m.imageCommonPanelInput }))))), /* @__PURE__ */ l.createElement("div", { className: D(m.imageCommonPanelColumn, m.imageCommonPanelSpan3) }, /* @__PURE__ */ l.createElement("label", null, /* @__PURE__ */ l.createElement("div", { className: m.imageCommonPanelRow }, /* @__PURE__ */ l.createElement("div", { className: m.imageCommonPanelColumn }, n.t("image-panel.transform.height"))), /* @__PURE__ */ l.createElement("div", { className: m.imageCommonPanelRow }, /* @__PURE__ */ l.createElement("div", { className: m.imageCommonPanelColumn }, /* @__PURE__ */ l.createElement(Ce, { precision: 1, value: R, onChange: (C) => {
341
+ vt(C);
342
+ }, className: m.imageCommonPanelInput }))))), /* @__PURE__ */ l.createElement("div", { className: D(m.imageCommonPanelColumn, m.imageCommonPanelSpan3) }, /* @__PURE__ */ l.createElement("label", null, /* @__PURE__ */ l.createElement("div", { className: m.imageCommonPanelRow }, /* @__PURE__ */ l.createElement("div", { className: m.imageCommonPanelColumn }, n.t("image-panel.transform.lock"))), /* @__PURE__ */ l.createElement("div", { className: D(m.imageCommonPanelRow, m.imageCommonPanelRowVertical) }, /* @__PURE__ */ l.createElement("div", { className: m.imageCommonPanelColumn }, /* @__PURE__ */ l.createElement(Ht, { checked: ce, onChange: It })))))), /* @__PURE__ */ l.createElement("div", { className: m.imageCommonPanelRow }, /* @__PURE__ */ l.createElement("div", { className: D(m.imageCommonPanelColumn, m.imageCommonPanelSpan3) }, /* @__PURE__ */ l.createElement("label", null, /* @__PURE__ */ l.createElement("div", { className: m.imageCommonPanelRow }, /* @__PURE__ */ l.createElement("div", { className: m.imageCommonPanelColumn }, n.t("image-panel.transform.x"))), /* @__PURE__ */ l.createElement("div", { className: m.imageCommonPanelRow }, /* @__PURE__ */ l.createElement("div", { className: m.imageCommonPanelColumn }, /* @__PURE__ */ l.createElement(Ce, { precision: 1, value: y, onChange: (C) => {
343
+ _t(C);
344
+ }, className: m.imageCommonPanelInput }))))), /* @__PURE__ */ l.createElement("div", { className: D(m.imageCommonPanelColumn, m.imageCommonPanelSpan3) }, /* @__PURE__ */ l.createElement("label", null, /* @__PURE__ */ l.createElement("div", { className: m.imageCommonPanelRow }, /* @__PURE__ */ l.createElement("div", { className: m.imageCommonPanelColumn }, n.t("image-panel.transform.y"))), /* @__PURE__ */ l.createElement("div", { className: m.imageCommonPanelRow }, /* @__PURE__ */ l.createElement("div", { className: m.imageCommonPanelColumn }, /* @__PURE__ */ l.createElement(Ce, { precision: 1, value: B, onChange: (C) => {
345
+ St(C);
346
+ }, className: m.imageCommonPanelInput }))))), /* @__PURE__ */ l.createElement("div", { className: D(m.imageCommonPanelColumn, m.imageCommonPanelSpan3) }, /* @__PURE__ */ l.createElement("label", null, /* @__PURE__ */ l.createElement("div", { className: m.imageCommonPanelRow }, /* @__PURE__ */ l.createElement("div", { className: m.imageCommonPanelColumn }, n.t("image-panel.transform.rotate"))), /* @__PURE__ */ l.createElement("div", { className: m.imageCommonPanelRow }, /* @__PURE__ */ l.createElement("div", { className: m.imageCommonPanelColumn }, /* @__PURE__ */ l.createElement(Ce, { precision: 1, value: te, onChange: bt, className: m.imageCommonPanelInput })))))));
347
+ };
348
+ var N = /* @__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))(N || {});
349
+ const Fe = {
350
+ id: "sheet.operation.set-image-align",
351
+ type: be.OPERATION,
352
+ handler: (a, n) => !0
353
+ }, Rn = (a) => {
354
+ const n = x(le), t = x(J), { alignShow: e } = a, [r, o] = A(N.default), i = [
355
+ {
356
+ label: t.t("image-panel.align.default"),
357
+ value: N.default
358
+ },
359
+ {
360
+ options: [
361
+ {
362
+ label: t.t("image-panel.align.left"),
363
+ value: N.left
364
+ },
365
+ {
366
+ label: t.t("image-panel.align.center"),
367
+ value: N.center
368
+ },
369
+ {
370
+ label: t.t("image-panel.align.right"),
371
+ value: N.right
372
+ }
373
+ ]
374
+ },
375
+ {
376
+ options: [
377
+ {
378
+ label: t.t("image-panel.align.top"),
379
+ value: N.top
380
+ },
381
+ {
382
+ label: t.t("image-panel.align.middle"),
383
+ value: N.middle
384
+ },
385
+ {
386
+ label: t.t("image-panel.align.bottom"),
387
+ value: N.bottom
388
+ }
389
+ ]
390
+ },
391
+ {
392
+ options: [
393
+ {
394
+ label: t.t("image-panel.align.horizon"),
395
+ value: N.horizon
396
+ },
397
+ {
398
+ label: t.t("image-panel.align.vertical"),
399
+ value: N.vertical
400
+ }
401
+ ]
402
+ }
403
+ ];
404
+ function s(g) {
405
+ o(g), n.executeCommand(Fe.id, {
406
+ alignType: g
407
+ });
408
+ }
409
+ const c = (g) => g ? "block" : "none";
410
+ return /* @__PURE__ */ l.createElement("div", { className: D(m.imageCommonPanelGrid, m.imageCommonPanelBorder), style: { display: c(e) } }, /* @__PURE__ */ l.createElement("div", { className: m.imageCommonPanelRow }, /* @__PURE__ */ l.createElement("div", { className: D(m.imageCommonPanelColumn, m.imageCommonPanelTitle) }, /* @__PURE__ */ l.createElement("div", null, t.t("image-panel.align.title")))), /* @__PURE__ */ l.createElement("div", { className: m.imageCommonPanelRow }, /* @__PURE__ */ l.createElement("div", { className: D(m.imageCommonPanelColumn) }, /* @__PURE__ */ l.createElement(rt, { value: r, options: i, onChange: s }))));
411
+ }, Mn = (a) => {
412
+ const n = x(le), t = x(J), { drawings: e, cropperShow: r } = a;
413
+ if (e[0] == null)
414
+ return;
415
+ const [i, s] = A(H.FREE), c = nt(!1), g = [
416
+ {
417
+ label: t.t("image-panel.crop.mode"),
418
+ value: H.FREE
419
+ },
420
+ {
421
+ label: "1:1",
422
+ value: H.R1_1
423
+ },
424
+ {
425
+ label: "16:9",
426
+ value: H.R16_9
427
+ },
428
+ {
429
+ label: "9:16",
430
+ value: H.R9_16
431
+ },
432
+ {
433
+ label: "5:4",
434
+ value: H.R5_4
435
+ },
436
+ {
437
+ label: "4:5",
438
+ value: H.R4_5
439
+ },
440
+ {
441
+ label: "4:3",
442
+ value: H.R4_3
443
+ },
444
+ {
445
+ label: "3:4",
446
+ value: H.R3_4
447
+ },
448
+ {
449
+ label: "3:2",
450
+ value: H.R3_2
451
+ },
452
+ {
453
+ label: "2:3",
454
+ value: H.R2_3
455
+ }
456
+ ];
457
+ Ie(() => {
458
+ const f = n.onCommandExecuted((v) => {
459
+ if (v.id === he.id) {
460
+ const w = v.params;
461
+ w != null && w.isAuto || (c.current = !1);
462
+ }
463
+ });
464
+ return () => {
465
+ f == null || f.dispose();
466
+ };
467
+ }, []);
468
+ function u(f) {
469
+ s(f), c.current && n.executeCommand(Ue.id, {
470
+ cropType: f
471
+ });
472
+ }
473
+ const d = (f) => f ? "block" : "none", h = (f) => {
474
+ n.executeCommand(Ue.id, {
475
+ cropType: f
476
+ }), c.current = !0;
477
+ };
478
+ return /* @__PURE__ */ l.createElement("div", { className: D(m.imageCommonPanelGrid, m.imageCommonPanelBorder), style: { display: d(r) } }, /* @__PURE__ */ l.createElement("div", { className: m.imageCommonPanelRow }, /* @__PURE__ */ l.createElement("div", { className: D(m.imageCommonPanelColumn, m.imageCommonPanelTitle) }, /* @__PURE__ */ l.createElement("div", null, t.t("image-panel.crop.title")))), /* @__PURE__ */ l.createElement("div", { className: D(m.imageCommonPanelRow, m.imageCommonPanelRowVertical) }, /* @__PURE__ */ l.createElement("div", { className: D(m.imageCommonPanelColumn, m.imageCommonPanelSpan2) }, /* @__PURE__ */ l.createElement(ie, { size: "small", onClick: () => {
479
+ h(i);
480
+ } }, /* @__PURE__ */ l.createElement("span", { className: m.imageCommonPanelInline }, /* @__PURE__ */ l.createElement(Jt, null), t.t("image-panel.crop.start")))), /* @__PURE__ */ l.createElement("div", { className: D(m.imageCommonPanelColumn, m.imageCommonPanelSpan2) }, /* @__PURE__ */ l.createElement(rt, { value: i, options: g, onChange: u }))));
481
+ }, On = (a) => {
482
+ const n = x(J), t = x(fe), e = x(se), { hasGroup: r, drawings: o } = a, [i, s] = A(!1), [c, g] = A(!0), [u, d] = A(!0), h = (p) => p ? "block" : "none", f = () => {
483
+ const p = e.getFocusDrawings(), { unitId: E, subUnitId: _ } = p[0], O = Ot.generateRandomId(10), S = Dt(0, 0, p.map((R) => R.transform || {})), I = {
484
+ unitId: E,
485
+ subUnitId: _,
486
+ drawingId: O,
487
+ drawingType: oe.DRAWING_GROUP,
488
+ transform: S
489
+ }, b = p.map((R) => {
490
+ const P = R.transform || { left: 0, top: 0 }, { unitId: y, subUnitId: M, drawingId: B } = R;
491
+ return {
492
+ unitId: y,
493
+ subUnitId: M,
494
+ drawingId: B,
495
+ transform: {
496
+ ...P,
497
+ left: P.left - S.left,
498
+ top: P.top - S.top
499
+ },
500
+ groupId: O
501
+ };
502
+ });
503
+ e.featurePluginGroupUpdateNotification([{
504
+ parent: I,
505
+ children: b
506
+ }]);
507
+ }, v = (p) => {
508
+ if (p.drawingType !== oe.DRAWING_GROUP)
509
+ return;
510
+ const { unitId: E, subUnitId: _, drawingId: O, transform: S = { width: 0, height: 0 } } = p;
511
+ if (S == null)
512
+ return;
513
+ const I = e.getDrawingsByGroup({ unitId: E, subUnitId: _, drawingId: O });
514
+ if (I.length === 0)
515
+ return;
516
+ const b = I.map((R) => {
517
+ const { transform: P } = R, { unitId: y, subUnitId: M, drawingId: B } = R, U = Tt(P || {}, S, S.width || 0, S.height || 0);
518
+ return {
519
+ unitId: y,
520
+ subUnitId: M,
521
+ drawingId: B,
522
+ transform: {
523
+ ...P,
524
+ ...U
525
+ },
526
+ groupId: void 0
527
+ };
528
+ });
529
+ return {
530
+ parent: p,
531
+ children: b
532
+ };
533
+ }, w = () => {
534
+ const E = e.getFocusDrawings().map(
535
+ (_) => v(_)
536
+ ).filter((_) => _ != null);
537
+ E.length !== 0 && e.featurePluginUngroupUpdateNotification(E);
538
+ };
539
+ return Ie(() => {
540
+ const p = o[0];
541
+ if (p == null)
542
+ return;
543
+ const { unitId: E } = p, _ = t.getRenderById(E), O = _ == null ? void 0 : _.scene;
544
+ if (O == null)
545
+ return;
546
+ const S = O.getTransformerByCreate(), I = S.onClearControlObservable.add((R) => {
547
+ R === !0 && s(!1);
548
+ }), b = S.onChangeStartObservable.add((R) => {
549
+ const { objects: P } = R, y = Se(P, e), M = y.filter((G) => (G == null ? void 0 : G.drawingType) === oe.DRAWING_GROUP);
550
+ let B = !1, U = !1;
551
+ y.length > 1 && (B = !0), M.length > 0 && (U = !0), s(B || U), g(B), d(U);
552
+ });
553
+ return () => {
554
+ b == null || b.dispose(), I == null || I.dispose();
555
+ };
556
+ }, []), /* @__PURE__ */ l.createElement("div", { className: D(m.imageCommonPanelGrid, m.imageCommonPanelBorder), style: { display: h(r === !0 ? i : !1) } }, /* @__PURE__ */ l.createElement("div", { className: m.imageCommonPanelRow }, /* @__PURE__ */ l.createElement("div", { className: D(m.imageCommonPanelColumn, m.imageCommonPanelTitle) }, /* @__PURE__ */ l.createElement("div", null, n.t("image-panel.group.title")))), /* @__PURE__ */ l.createElement("div", { className: m.imageCommonPanelRow }, /* @__PURE__ */ l.createElement("div", { className: D(m.imageCommonPanelColumn, m.imageCommonPanelSpan2, m.imageCommonPanelColumnCenter) }, /* @__PURE__ */ l.createElement(ie, { size: "small", onClick: () => {
557
+ f();
558
+ }, style: { display: h(c) } }, /* @__PURE__ */ l.createElement("span", { className: m.imageCommonPanelInline }, /* @__PURE__ */ l.createElement(Qt, null), n.t("image-panel.group.group")))), /* @__PURE__ */ l.createElement("div", { className: D(m.imageCommonPanelColumn, m.imageCommonPanelSpan2, m.imageCommonPanelColumnCenter) }, /* @__PURE__ */ l.createElement(ie, { size: "small", onClick: () => {
559
+ w();
560
+ }, style: { display: h(u) } }, /* @__PURE__ */ l.createElement("span", { className: m.imageCommonPanelInline }, /* @__PURE__ */ l.createElement(mn, null), n.t("image-panel.group.unGroup"))))));
561
+ }, dr = (a) => {
562
+ const n = x(se), t = x(fe), e = x(J), { drawings: r, hasArrange: o = !0, hasTransform: i = !0, hasAlign: s = !0, hasCropper: c = !0, hasGroup: g = !0 } = a, u = r[0];
563
+ if (u == null)
564
+ return;
565
+ const { unitId: d } = u, h = t.getRenderById(d), f = h == null ? void 0 : h.scene;
566
+ if (f == null)
567
+ return;
568
+ const v = f.getTransformerByCreate(), [w, p] = A(!0), [E, _] = A(!0), [O, S] = A(!1), [I, b] = A(!0), [R, P] = A(!1);
569
+ return Ie(() => {
570
+ const y = v.onClearControlObservable.add((U) => {
571
+ U === !0 && (p(!1), _(!1), S(!1), b(!1), P(!0));
572
+ }), M = v.onChangeStartObservable.add((U) => {
573
+ const { objects: te } = U, G = Se(te, n);
574
+ G.length === 0 ? (p(!1), _(!1), S(!1), b(!1), P(!0)) : G.length === 1 ? (p(!0), _(!0), S(!1), b(!0), P(!1)) : (p(!0), _(!1), S(!0), b(!1), P(!1));
575
+ }), B = n.focus$.subscribe((U) => {
576
+ U.length === 0 ? (p(!1), _(!1), S(!1), b(!1), P(!0)) : U.length === 1 ? (p(!0), _(!0), S(!1), b(!0), P(!1)) : (p(!0), _(!1), S(!0), b(!1), P(!1));
577
+ });
578
+ return () => {
579
+ M == null || M.dispose(), y == null || y.dispose(), B == null || B.unsubscribe();
580
+ };
581
+ }, []), /* @__PURE__ */ l.createElement(l.Fragment, null, /* @__PURE__ */ l.createElement("div", { style: { display: R === !0 ? "block" : "none", height: "100%" } }, /* @__PURE__ */ l.createElement("div", { style: { display: "flex", justifyContent: "center", alignItems: "center", height: "100%", top: "50%", marginTop: "-100px" } }, /* @__PURE__ */ l.createElement("span", null, e.t("image-panel.null")))), /* @__PURE__ */ l.createElement(In, { arrangeShow: o === !0 ? w : !1, drawings: r }), /* @__PURE__ */ l.createElement(En, { transformShow: i === !0 ? E : !1, drawings: r }), /* @__PURE__ */ l.createElement(Rn, { alignShow: s === !0 ? O : !1, drawings: r }), /* @__PURE__ */ l.createElement(Mn, { cropperShow: c === !0 ? I : !1, drawings: r }), /* @__PURE__ */ l.createElement(On, { hasGroup: g, drawings: r }));
582
+ }, 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", we = {
583
+ imagePopupMenu: Nn,
584
+ imagePopupMenuItem: Dn,
585
+ imagePopupMenuItemIcon: Tn,
586
+ imagePopupMenuItemTitle: Bn,
587
+ imagePopupMenuItemHide: jn,
588
+ btnContainer: Un,
589
+ btnContainerExpand: Hn
590
+ }, Ln = (a) => {
591
+ var v, w;
592
+ const n = (w = (v = a.popup) == null ? void 0 : v.extraProps) == null ? void 0 : w.menuItems;
593
+ if (!n)
594
+ return null;
595
+ const t = x(le), e = x(J), [r, o] = A(!1), [i, s] = A(!1), c = () => {
596
+ s(!0);
597
+ }, g = () => {
598
+ s(!1);
599
+ }, u = (p) => {
600
+ o(p);
601
+ }, d = (p) => {
602
+ t.executeCommand(p.commandId, p.commandParams), o(!1);
603
+ }, h = r || i, f = n.filter((p) => !p.disable);
604
+ return /* @__PURE__ */ l.createElement(
605
+ "div",
606
+ {
607
+ onMouseEnter: c,
608
+ onMouseLeave: g
609
+ },
610
+ /* @__PURE__ */ l.createElement(
611
+ Lt,
612
+ {
613
+ placement: "bottomLeft",
614
+ trigger: ["click"],
615
+ overlay: /* @__PURE__ */ l.createElement("ul", { className: we.imagePopupMenu }, f.map((p) => /* @__PURE__ */ l.createElement(
616
+ "li",
617
+ {
618
+ key: p.index,
619
+ onClick: () => d(p),
620
+ className: we.imagePopupMenuItem
621
+ },
622
+ /* @__PURE__ */ l.createElement("span", { className: we.imagePopupMenuItemTitle }, e.t(p.label))
623
+ ))),
624
+ visible: r,
625
+ onVisibleChange: u
626
+ },
627
+ /* @__PURE__ */ l.createElement(
628
+ "div",
629
+ {
630
+ className: D(we.btnContainer, {
631
+ [we.btnContainerExpand]: r
632
+ })
633
+ },
634
+ /* @__PURE__ */ l.createElement(
635
+ Kt,
636
+ {
637
+ style: { color: "#35322B" },
638
+ extend: { colorChannel1: "rgb(var(--green-700, #409f11))" }
639
+ }
640
+ ),
641
+ h && /* @__PURE__ */ l.createElement(tn, { style: { color: "#CCCCCC", fontSize: "8px", marginLeft: "8px" } })
642
+ )
643
+ )
644
+ );
645
+ }, An = "COMPONENT_IMAGE_POPUP_MENU";
646
+ function xn(a, n, t, e) {
647
+ const r = e.getDrawingByParam(a);
648
+ if (r == null)
649
+ return;
650
+ const o = V(a), i = t.getObject(o);
651
+ if (i && !(i instanceof _e))
652
+ return;
653
+ if (i != null) {
654
+ i.addObject(n);
655
+ return;
656
+ }
657
+ const s = new _e(o);
658
+ t.addObject(s, $e).attachTransformerTo(s), s.addObject(n);
659
+ const { transform: c } = r;
660
+ c && s.transformByState(
661
+ {
662
+ left: c.left,
663
+ top: c.top,
664
+ angle: c.angle
665
+ }
666
+ );
667
+ }
668
+ function pt(a) {
669
+ const n = a.getFocusedUnit();
670
+ if (n == null)
671
+ return;
672
+ const t = n.getUnitId();
673
+ let e;
674
+ return n.type === xe.UNIVER_SHEET ? e = n.getActiveSheet().getSheetId() : (n.type === xe.UNIVER_DOC || n.type === xe.UNIVER_SLIDE) && (e = t), { unitId: t, subUnitId: e };
675
+ }
676
+ var Vn = Object.defineProperty, Gn = Object.getOwnPropertyDescriptor, Wn = (a, n, t, e) => {
677
+ for (var r = e > 1 ? void 0 : e ? Gn(n, t) : n, o = a.length - 1, i; o >= 0; o--)
678
+ (i = a[o]) && (r = (e ? i(n, t, r) : i(r)) || r);
679
+ return e && r && Vn(n, t, r), r;
680
+ }, Me = (a, n) => (t, e) => n(t, e, a);
681
+ let Ne = class extends He {
682
+ constructor(n, t, e, r) {
683
+ super();
684
+ ne(this, "_sceneListenerOnDrawingMap", /* @__PURE__ */ new WeakSet());
685
+ this._currentUniverService = n, this._commandService = t, this._renderManagerService = e, this._drawingManagerService = r, this._initialize();
686
+ }
687
+ dispose() {
688
+ super.dispose();
689
+ }
690
+ _initialize() {
691
+ this._recoveryImages(), this._drawingAddListener(), this._drawingRemoveListener(), this._drawingUpdateListener(), this._commandExecutedListener(), this._drawingArrangeListener(), this._drawingGroupListener(), this._drawingRefreshListener(), this._drawingVisibleListener();
692
+ }
693
+ _recoveryImages() {
694
+ const n = this._drawingManagerService.drawingManagerData, t = pt(this._currentUniverService);
695
+ if (t == null)
696
+ return;
697
+ const { unitId: e, subUnitId: r } = t;
698
+ Object.keys(n).forEach((o) => {
699
+ Object.keys(n[o]).forEach((i) => {
700
+ const s = n[o][i].data;
701
+ s == null || o !== e || i !== r || Object.keys(s).forEach((c) => {
702
+ s[c] && this._insertDrawing([{ unitId: o, subUnitId: i, drawingId: c }]);
703
+ });
704
+ });
705
+ });
706
+ }
707
+ _commandExecutedListener() {
708
+ this.disposeWithMe(
709
+ this._commandService.onCommandExecuted((n) => {
710
+ if (n.id === Fe.id) {
711
+ const t = n.params;
712
+ if (t == null)
713
+ return;
714
+ this._drawingAlign(t);
715
+ }
716
+ })
717
+ );
718
+ }
719
+ _drawingGroupListener() {
720
+ this.disposeWithMe(
721
+ this._drawingManagerService.group$.subscribe((n) => {
722
+ this._groupDrawings(n);
723
+ })
724
+ ), this.disposeWithMe(
725
+ this._drawingManagerService.ungroup$.subscribe((n) => {
726
+ this._ungroupDrawings(n);
727
+ })
728
+ );
729
+ }
730
+ // private _drawingGroup(params: ISetImageGroupOperationParams) {
731
+ // const { groupType } = params;
732
+ // const drawings = this._drawingManagerService.getFocusDrawings();
733
+ // if (drawings.length === 0) {
734
+ // return;
735
+ // }
736
+ // switch (groupType) {
737
+ // case GroupType.group:
738
+ // this._groupDrawings(drawings);
739
+ // break;
740
+ // case GroupType.regroup:
741
+ // this._regroupDrawings(drawings);
742
+ // break;
743
+ // case GroupType.ungroup:
744
+ // this._ungroupDrawings(drawings);
745
+ // break;
746
+ // default:
747
+ // break;
748
+ // }
749
+ // }
750
+ _getSceneAndTransformerByDrawingSearch(n) {
751
+ if (n == null)
752
+ return;
753
+ const t = this._renderManagerService.getRenderById(n), e = t == null ? void 0 : t.scene;
754
+ if (e == null)
755
+ return null;
756
+ const r = e.getTransformerByCreate();
757
+ return { scene: e, transformer: r };
758
+ }
759
+ _groupDrawings(n) {
760
+ n.forEach((t) => {
761
+ this._groupDrawing(t);
762
+ });
763
+ }
764
+ _groupDrawing(n) {
765
+ const { parent: t, children: e } = n, { unitId: r, subUnitId: o, drawingId: i } = t, s = this._getSceneAndTransformerByDrawingSearch(t.unitId);
766
+ if (s == null)
767
+ return;
768
+ const { scene: c, transformer: g } = s;
769
+ this._commandService.syncExecuteCommand(he.id);
770
+ const u = [];
771
+ if (e.forEach((f) => {
772
+ const v = V(f), w = c.getObjectIncludeInGroup(v);
773
+ if (w == null || u.includes(w))
774
+ return;
775
+ u.push(w);
776
+ const { transform: p } = f;
777
+ p != null && (w.classType === Ye.GROUP ? w.transformByState({ left: p.left, top: p.top }) : w.transformByState(p));
778
+ }), u.length === 0)
779
+ return;
780
+ const d = V({ unitId: r, subUnitId: o, drawingId: i }), h = new _e(d);
781
+ c.addObject(h, $e).attachTransformerTo(h), h.addObjects(...u), t.transform && h.transformByState({ left: t.transform.left, top: t.transform.top }), g.clearSelectedObjects(), g.setSelectedControl(h);
782
+ }
783
+ // private _regroupDrawings(drawings: IDrawingSearch[]) {
784
+ // const renderObject = this._getSceneAndTransformerByDrawingSearch(drawings[0].unitId);
785
+ // if (renderObject == null) {
786
+ // return;
787
+ // }
788
+ // const { scene, transformer } = renderObject;
789
+ // const objects: BaseObject[] = [];
790
+ // let firstGroup: Nullable<Group> = null;
791
+ // drawings.forEach((drawing) => {
792
+ // const imageShapeKey = getDrawingShapeKeyByDrawingSearch(drawing);
793
+ // const o = scene.getObject(imageShapeKey);
794
+ // if (o == null) {
795
+ // return true;
796
+ // }
797
+ // const group = o.ancestorGroup as Nullable<Group>;
798
+ // if (group != null && firstGroup == null) {
799
+ // firstGroup = group;
800
+ // } else if (group != null && !objects.includes(group)) {
801
+ // objects.push(group);
802
+ // } else if (!objects.includes(o)) {
803
+ // objects.push(o);
804
+ // }
805
+ // });
806
+ // if (firstGroup == null) {
807
+ // return;
808
+ // }
809
+ // if (objects.length === 0) {
810
+ // return;
811
+ // }
812
+ // (firstGroup as Group).addObjects(...objects);
813
+ // (firstGroup as Group).reCalculateObjects();
814
+ // transformer.clearSelectedObjects();
815
+ // transformer.setSelectedControl(firstGroup);
816
+ // }
817
+ _ungroupDrawings(n) {
818
+ n.forEach((t) => {
819
+ this._ungroupDrawing(t);
820
+ });
821
+ }
822
+ _ungroupDrawing(n) {
823
+ const { parent: t, children: e } = n, r = this._getSceneAndTransformerByDrawingSearch(t.unitId);
824
+ if (r == null)
825
+ return;
826
+ const { scene: o, transformer: i } = r;
827
+ e.forEach((d) => {
828
+ const h = V(d), f = o.getObjectIncludeInGroup(h);
829
+ if (f == null)
830
+ return !0;
831
+ if (f == null)
832
+ return;
833
+ const { transform: v } = d;
834
+ v != null && (f.classType === Ye.GROUP ? f.transformByState({ left: v.left, top: v.top }) : f.transformByState(v));
835
+ });
836
+ const s = V(t), c = o.getObject(s), { width: g, height: u } = c;
837
+ c.getObjects().forEach((d) => {
838
+ c.removeSelfObjectAndTransform(d.oKey, g, u);
839
+ }), c.dispose(), i.clearSelectedObjects();
840
+ }
841
+ _drawingAlign(n) {
842
+ const { alignType: t } = n, e = this._drawingManagerService.getFocusDrawings();
843
+ if (t === N.default)
844
+ return;
845
+ const r = [];
846
+ let o = Number.POSITIVE_INFINITY, i = Number.POSITIVE_INFINITY, s = Number.NEGATIVE_INFINITY, c = Number.NEGATIVE_INFINITY, g = 0;
847
+ e.forEach((u) => {
848
+ const { unitId: d, subUnitId: h, drawingId: f, drawingType: v } = u, w = this._drawingManagerService.getDrawingByParam({ unitId: d, subUnitId: h, drawingId: f });
849
+ if (w == null || w.transform == null)
850
+ return;
851
+ r.push({
852
+ unitId: d,
853
+ subUnitId: h,
854
+ drawingId: f,
855
+ drawingType: v,
856
+ transform: w.transform
857
+ });
858
+ const { left: p = 0, top: E = 0, width: _ = 0, height: O = 0 } = w.transform;
859
+ o = Math.min(o, p), i = Math.min(i, E), s = Math.max(s, p + _), c = Math.max(c, E + O), g++;
860
+ }), g !== 0 && (this._sortDrawingTransform(r, t), this._applyAlignType(r, t, o, i, s, c, g));
861
+ }
862
+ _applyAlignType(n, t, e, r, o, i, s) {
863
+ const c = Math.round((o - e) / s * 10) / 10, g = Math.round((i - r) / s * 10) / 10, u = [], d = this._getSceneAndTransformerByDrawingSearch(n[0].unitId);
864
+ if (d == null)
865
+ return;
866
+ const { scene: h, transformer: f } = d;
867
+ n.forEach((v, w) => {
868
+ const { unitId: p, subUnitId: E, drawingId: _, transform: O, drawingType: S } = v, { left: I = 0, top: b = 0, width: R = 0, height: P = 0 } = O;
869
+ let y = I, M = b;
870
+ switch (t) {
871
+ case N.left:
872
+ y = e;
873
+ break;
874
+ case N.center:
875
+ y = e + (o - e) / 2 - R / 2;
876
+ break;
877
+ case N.right:
878
+ y = o - R;
879
+ break;
880
+ case N.top:
881
+ M = r;
882
+ break;
883
+ case N.middle:
884
+ M = r + (i - r) / 2 - P / 2;
885
+ break;
886
+ case N.bottom:
887
+ M = i - P;
888
+ break;
889
+ case N.horizon:
890
+ y = e + c * w;
891
+ break;
892
+ case N.vertical:
893
+ M = r + g * w;
894
+ break;
895
+ }
896
+ (y !== I || M !== b) && u.push({
897
+ unitId: p,
898
+ subUnitId: E,
899
+ drawingId: _,
900
+ drawingType: S,
901
+ transform: {
902
+ left: y,
903
+ top: M
904
+ }
905
+ });
906
+ }), this._drawingManagerService.featurePluginUpdateNotification(u), f.refreshControls().changeNotification();
907
+ }
908
+ _sortDrawingTransform(n, t) {
909
+ n.sort((e, r) => {
910
+ const o = e.transform, i = r.transform, {
911
+ left: s = 0,
912
+ top: c = 0,
913
+ width: g = 0,
914
+ height: u = 0
915
+ } = o, {
916
+ left: d = 0,
917
+ top: h = 0,
918
+ width: f = 0,
919
+ height: v = 0
920
+ } = i;
921
+ switch (t) {
922
+ case N.left:
923
+ return s - d;
924
+ case N.center:
925
+ return s + g / 2 - (d + f / 2);
926
+ case N.right:
927
+ return s + g - (d + f);
928
+ case N.top:
929
+ return c - h;
930
+ case N.middle:
931
+ return c + u / 2 - (h + v / 2);
932
+ case N.bottom:
933
+ return c + u - (h + v);
934
+ case N.horizon:
935
+ return s + g / 2 - (d + f / 2);
936
+ case N.vertical:
937
+ return c + u / 2 - (h + v / 2);
938
+ default:
939
+ return 0;
940
+ }
941
+ });
942
+ }
943
+ _drawingArrangeListener() {
944
+ this.disposeWithMe(
945
+ this._drawingManagerService.order$.subscribe((n) => {
946
+ this._drawingArrange(n);
947
+ })
948
+ );
949
+ }
950
+ _drawingArrange(n) {
951
+ const { unitId: t, subUnitId: e, drawingIds: r } = n, o = this._getSceneAndTransformerByDrawingSearch(t);
952
+ if (o == null)
953
+ return;
954
+ const { scene: i, transformer: s } = o;
955
+ r.forEach((c) => {
956
+ const g = V({ unitId: t, subUnitId: e, drawingId: c }), u = i.getObject(g);
957
+ if (u == null)
958
+ return;
959
+ const d = this._drawingManagerService.getDrawingOrder(t, e).indexOf(c);
960
+ u.setProps({ zIndex: d }), u.makeDirty();
961
+ });
962
+ }
963
+ _drawingAddListener() {
964
+ this.disposeWithMe(
965
+ this._drawingManagerService.add$.subscribe((n) => {
966
+ this._insertDrawing(n);
967
+ })
968
+ );
969
+ }
970
+ _insertDrawing(n) {
971
+ const t = [];
972
+ n.forEach((e) => {
973
+ const { unitId: r, subUnitId: o, drawingId: i } = e;
974
+ if (this._drawingManagerService.getDrawingByParam(e) == null)
975
+ return;
976
+ const c = this._getSceneAndTransformerByDrawingSearch(r);
977
+ if (c == null)
978
+ return;
979
+ const { scene: g, transformer: u } = c;
980
+ t.includes(g) || t.push(g);
981
+ }), t.forEach((e) => {
982
+ this._sceneListenerOnDrawingMap.has(e) || (this._addListenerOnDrawing(e), this._sceneListenerOnDrawingMap.add(e));
983
+ });
984
+ }
985
+ _drawingRemoveListener() {
986
+ this.disposeWithMe(
987
+ this._drawingManagerService.remove$.subscribe((n) => {
988
+ n.forEach((t) => {
989
+ var d;
990
+ const { unitId: e, subUnitId: r, drawingId: o } = t, i = this._getSceneAndTransformerByDrawingSearch(e);
991
+ if (i == null)
992
+ return;
993
+ const { scene: s, transformer: c } = i, g = V({ unitId: e, subUnitId: r, drawingId: o }), u = s.getObject(g);
994
+ u != null && (u.dispose(), (d = s.getTransformer()) == null || d.clearSelectedObjects());
995
+ });
996
+ })
997
+ );
998
+ }
999
+ _drawingUpdateListener() {
1000
+ this.disposeWithMe(
1001
+ this._drawingManagerService.update$.subscribe((n) => {
1002
+ n.forEach((t) => {
1003
+ const { unitId: e, subUnitId: r, drawingId: o } = t, i = this._drawingManagerService.getDrawingByParam(t);
1004
+ if (i == null)
1005
+ return;
1006
+ const { transform: s, drawingType: c } = i, g = this._getSceneAndTransformerByDrawingSearch(e);
1007
+ if (g == null)
1008
+ return;
1009
+ const { scene: u, transformer: d } = g;
1010
+ if (s == null)
1011
+ return !0;
1012
+ const { left: h = 0, top: f = 0, width: v = 0, height: w = 0, angle: p = 0, flipX: E = !1, flipY: _ = !1, skewX: O = 0, skewY: S = 0 } = s, I = V({ unitId: e, subUnitId: r, drawingId: o }), b = u.getObject(I);
1013
+ if (b == null)
1014
+ return !0;
1015
+ b.transformByState({ left: h, top: f, width: v, height: w, angle: p, flipX: E, flipY: _, skewX: O, skewY: S });
1016
+ });
1017
+ })
1018
+ );
1019
+ }
1020
+ _drawingRefreshListener() {
1021
+ this.disposeWithMe(
1022
+ this._drawingManagerService.refreshTransform$.subscribe((n) => {
1023
+ n.forEach((t) => {
1024
+ const { unitId: e, subUnitId: r, drawingId: o } = t, i = this._getSceneAndTransformerByDrawingSearch(e);
1025
+ if (i == null)
1026
+ return;
1027
+ const { scene: s, transformer: c } = i, g = V({ unitId: e, subUnitId: r, drawingId: o }), u = s.getObject(g), d = this._drawingManagerService.getDrawingByParam(t);
1028
+ if (d == null)
1029
+ return;
1030
+ const { transform: h } = d;
1031
+ if (h == null)
1032
+ return !0;
1033
+ const { left: f = 0, top: v = 0, width: w = 0, height: p = 0, angle: E = 0, flipX: _ = !1, flipY: O = !1, skewX: S = 0, skewY: I = 0 } = h;
1034
+ if (u == null)
1035
+ return !0;
1036
+ u.transformByState({ left: f, top: v, width: w, height: p, angle: E, flipX: _, flipY: O, skewX: S, skewY: I });
1037
+ });
1038
+ })
1039
+ );
1040
+ }
1041
+ _drawingVisibleListener() {
1042
+ this.disposeWithMe(
1043
+ this._drawingManagerService.visible$.subscribe((n) => {
1044
+ n.forEach((t) => {
1045
+ const { unitId: e, subUnitId: r, drawingId: o, visible: i } = t, s = this._getSceneAndTransformerByDrawingSearch(e);
1046
+ if (s == null)
1047
+ return;
1048
+ const { scene: c, transformer: g } = s, u = V({ unitId: e, subUnitId: r, drawingId: o }), d = c.getObject(u);
1049
+ if (d == null)
1050
+ return !0;
1051
+ i ? d.show() : d.hide();
1052
+ });
1053
+ })
1054
+ );
1055
+ }
1056
+ _filterUpdateParams(n, t) {
1057
+ return n.filter((e, r) => {
1058
+ if (e == null)
1059
+ return !1;
1060
+ const { transform: o } = e;
1061
+ return tt(o, t == null ? void 0 : t[r]);
1062
+ });
1063
+ }
1064
+ // group?.getObjects().forEach((o) => {
1065
+ // const drawing = this._drawingManagerService.getDrawingOKey(o.oKey);
1066
+ // if (drawing != null) {
1067
+ // const { unitId, subUnitId, drawingId } = drawing;
1068
+ // drawings.push({ unitId, subUnitId, drawingId });
1069
+ // }
1070
+ // });
1071
+ _addListenerOnDrawing(n) {
1072
+ const t = n.getTransformerByCreate();
1073
+ let e = null;
1074
+ this.disposeWithMe(
1075
+ K(
1076
+ t.onChangeStartObservable.add((r) => {
1077
+ const { objects: o } = r, i = Array.from(o.values()), s = [];
1078
+ e = i.map((c) => {
1079
+ const { left: g, top: u, height: d, width: h, angle: f, oKey: v, groupKey: w, isInGroup: p } = c, E = this._drawingManagerService.getDrawingOKey(v);
1080
+ if (p || c instanceof _e) {
1081
+ let _ = c.ancestorGroup;
1082
+ if (_ == null && c instanceof _e && (_ = c), _ == null)
1083
+ return null;
1084
+ const O = this._drawingManagerService.getDrawingOKey(_.oKey);
1085
+ if (O) {
1086
+ const { unitId: S, subUnitId: I, drawingId: b } = O;
1087
+ s.push({ unitId: S, subUnitId: I, drawingId: b });
1088
+ const { left: R, top: P, height: y, width: M, angle: B } = _;
1089
+ return { left: R, top: P, height: y, width: M, angle: B };
1090
+ }
1091
+ } else if (E != null) {
1092
+ const { unitId: _, subUnitId: O, drawingId: S } = E;
1093
+ return s.push({ unitId: _, subUnitId: O, drawingId: S }), { left: g, top: u, height: d, width: h, angle: f };
1094
+ }
1095
+ return null;
1096
+ }).filter((c) => c != null), s.length > 0 ? this._drawingManagerService.focusDrawing(s) : this._drawingManagerService.focusDrawing(null);
1097
+ })
1098
+ )
1099
+ ), this.disposeWithMe(
1100
+ K(
1101
+ t.onChangingObservable.add((r) => {
1102
+ const { objects: o } = r;
1103
+ Se(o, this._drawingManagerService).length > 0;
1104
+ })
1105
+ )
1106
+ ), this.disposeWithMe(
1107
+ K(
1108
+ t.onChangeEndObservable.add((r) => {
1109
+ const { objects: o } = r, i = this._filterUpdateParams(Se(o, this._drawingManagerService), e);
1110
+ i.length > 0 && this._drawingManagerService.featurePluginUpdateNotification(i);
1111
+ })
1112
+ )
1113
+ );
1114
+ }
1115
+ };
1116
+ Ne = Wn([
1117
+ Le(Ae.Rendered, Ne),
1118
+ Me(0, ze),
1119
+ Me(1, le),
1120
+ Me(2, fe),
1121
+ Me(3, se)
1122
+ ], Ne);
1123
+ const kn = (a) => {
1124
+ const { src: n } = a;
1125
+ return n ? /* @__PURE__ */ l.createElement("div", null, /* @__PURE__ */ l.createElement("img", { src: n, alt: "Univer Image Viewer", style: { width: "100%", height: "100%", position: "relative" } })) : null;
1126
+ }, Ct = "COMPONENT_IMAGE_VIEWER";
1127
+ var zn = Object.defineProperty, $n = Object.getOwnPropertyDescriptor, Fn = (a, n, t, e) => {
1128
+ for (var r = e > 1 ? void 0 : e ? $n(n, t) : n, o = a.length - 1, i; o >= 0; o--)
1129
+ (i = a[o]) && (r = (e ? i(n, t, r) : i(r)) || r);
1130
+ return e && r && zn(n, t, r), r;
1131
+ }, ve = (a, n) => (t, e) => n(t, e, a);
1132
+ let De = class extends He {
1133
+ constructor(a, n, t, e, r) {
1134
+ super(), this._injector = a, this._componentManager = n, this._menuService = t, this._commandService = e, this._localeService = r, this._init();
1135
+ }
1136
+ _initCustomComponents() {
1137
+ const a = this._componentManager;
1138
+ this.disposeWithMe(a.register(An, Ln)), this.disposeWithMe(a.register(Ct, kn));
1139
+ }
1140
+ _initMenus() {
1141
+ }
1142
+ _initCommands() {
1143
+ [
1144
+ ke,
1145
+ he,
1146
+ it,
1147
+ Fe,
1148
+ Ue
1149
+ ].forEach((a) => this.disposeWithMe(this._commandService.registerCommand(a)));
1150
+ }
1151
+ _init() {
1152
+ this._initCommands(), this._initCustomComponents(), this._initMenus();
1153
+ }
1154
+ };
1155
+ De = Fn([
1156
+ Le(Ae.Rendered, De),
1157
+ ve(0, de(at)),
1158
+ ve(1, de(At)),
1159
+ ve(2, xt),
1160
+ ve(3, le),
1161
+ ve(4, de(J))
1162
+ ], De);
1163
+ class Oe extends Bt {
1164
+ constructor(t, e) {
1165
+ e == null && (e = {}), e.transformerConfig = {
1166
+ keepRatio: !1,
1167
+ isCropper: !0,
1168
+ anchorFill: "rgb(0, 0, 0)",
1169
+ anchorStroke: "rgb(255, 255, 255)",
1170
+ anchorSize: 24
1171
+ };
1172
+ super(t, e);
1173
+ ne(this, "_srcRect");
1174
+ ne(this, "_prstGeom");
1175
+ ne(this, "_applyTransform");
1176
+ ne(this, "_dragPadding", 8);
1177
+ ne(this, "_cacheCanvas");
1178
+ e != null && e.srcRect && (this._srcRect = e.srcRect), e != null && e.prstGeom && (this._prstGeom = e.prstGeom), e != null && e.applyTransform && (this._applyTransform = e.applyTransform), e != null && e.dragPadding && (this._dragPadding = e.dragPadding), this._applyProps();
1179
+ }
1180
+ refreshSrcRect(t, e) {
1181
+ this._srcRect = t, this._applyTransform = e, this._applyProps();
1182
+ }
1183
+ get srcRect() {
1184
+ return this._srcRect;
1185
+ }
1186
+ dispose() {
1187
+ var t;
1188
+ super.dispose(), (t = this._cacheCanvas) == null || t.dispose(), this._srcRect = null;
1189
+ }
1190
+ isHit(t) {
1191
+ const e = this.getInverseCoord(t);
1192
+ return e.x >= -this.strokeWidth / 2 && e.x <= this.width + this.strokeWidth / 2 && e.y >= -this.strokeWidth / 2 && e.y <= this.height + this.strokeWidth / 2 && !this._inSurround(e);
1193
+ }
1194
+ _inSurround(t) {
1195
+ const e = this._dragPadding;
1196
+ return t.x >= e - this.strokeWidth / 2 && t.x <= this.width + this.strokeWidth / 2 - e && t.y >= e - this.strokeWidth / 2 && t.y <= this.height + this.strokeWidth / 2 - e;
1197
+ }
1198
+ render(t, e) {
1199
+ return this.visible ? (t.save(), this._draw(t), t.restore(), this.makeDirty(!1), this) : (this.makeDirty(!1), this);
1200
+ }
1201
+ _draw(t) {
1202
+ var c, g;
1203
+ const r = this.getScene().getEngine(), { width: o, height: i } = r;
1204
+ this._initialCacheCanvas(), (c = this._cacheCanvas) == null || c.clear();
1205
+ const s = (g = this._cacheCanvas) == null ? void 0 : g.getContext();
1206
+ s != null && (s.save(), jt.drawWith(s, {
1207
+ left: 0,
1208
+ top: 0,
1209
+ width: o,
1210
+ height: i,
1211
+ fill: "rgba(0, 0, 0, 0.5)"
1212
+ }), s.setTransform(t.getTransform()), this._clipForApplyObject(s), this._applyCache(t), s.restore());
1213
+ }
1214
+ _clipForApplyObject(t) {
1215
+ let e = 0;
1216
+ if (this._prstGeom != null && (e = 1), t.globalCompositeOperation = "destination-out", t.beginPath(), e === 0) {
1217
+ const r = this.transform.getMatrix();
1218
+ t.transform(r[0], r[1], r[2], r[3], r[4], r[5]), t.rect(0, 0, this.width, this.height), t.fill();
1219
+ }
1220
+ }
1221
+ _applyProps() {
1222
+ if (this._applyTransform == null)
1223
+ return;
1224
+ let t = 0, e = 0, r = 0, o = 0;
1225
+ const { left: i = 0, top: s = 0, width: c = 0, height: g = 0, angle: u } = this._applyTransform;
1226
+ if (this._srcRect != null) {
1227
+ const { left: f = 0, top: v = 0, right: w = 0, bottom: p = 0 } = this._srcRect;
1228
+ t = f, e = v, r = w, o = p;
1229
+ }
1230
+ const d = i + t, h = s + e;
1231
+ this.transformByState({
1232
+ left: d,
1233
+ top: h,
1234
+ width: i + c - r - d,
1235
+ height: s + g - o - h,
1236
+ angle: u
1237
+ });
1238
+ }
1239
+ _applyCache(t) {
1240
+ if (!t || this._cacheCanvas == null)
1241
+ return;
1242
+ const e = this._cacheCanvas.getContext();
1243
+ e.save(), t.save(), t.setTransform(1, 0, 0, 1, 0, 0), e.setTransform(1, 0, 0, 1, 0, 0), t.drawImage(this._cacheCanvas.getCanvasEle(), 0, 0), t.restore(), e.restore();
1244
+ }
1245
+ _initialCacheCanvas() {
1246
+ if (this._cacheCanvas != null)
1247
+ return;
1248
+ this._cacheCanvas = new Ut();
1249
+ const t = this.getScene().getEngine();
1250
+ this._cacheCanvas.setSize(t.width, t.height), this.getScene().getEngine().onTransformChangeObservable.add(() => {
1251
+ var e;
1252
+ (e = this._cacheCanvas) == null || e.setSize(t.width, t.height), this.makeDirty(!0);
1253
+ });
1254
+ }
1255
+ }
1256
+ var Kn = Object.defineProperty, Zn = Object.getOwnPropertyDescriptor, Yn = (a, n, t, e) => {
1257
+ for (var r = e > 1 ? void 0 : e ? Zn(n, t) : n, o = a.length - 1, i; o >= 0; o--)
1258
+ (i = a[o]) && (r = (e ? i(n, t, r) : i(r)) || r);
1259
+ return e && r && Kn(n, t, r), r;
1260
+ }, ge = (a, n) => (t, e) => n(t, e, a);
1261
+ let Te = class extends He {
1262
+ constructor(n, t, e, r, o, i) {
1263
+ super();
1264
+ ne(this, "_sceneListenerOnImageMap", /* @__PURE__ */ new WeakSet());
1265
+ this._commandService = n, this._drawingManagerService = t, this._renderManagerService = e, this._univerInstanceService = r, this._messageService = o, this._localeService = i, this._init();
1266
+ }
1267
+ _init() {
1268
+ this._initOpenCrop(), this._initCloseCrop(), this._initAutoCrop();
1269
+ }
1270
+ _initAutoCrop() {
1271
+ this.disposeWithMe(
1272
+ this._commandService.onCommandExecuted((n) => {
1273
+ if (n.id !== Ue.id)
1274
+ return;
1275
+ const t = n.params;
1276
+ if (t == null)
1277
+ return;
1278
+ const { cropType: e } = t, r = this._drawingManagerService.getFocusDrawings();
1279
+ if (r.length !== 1)
1280
+ return;
1281
+ const o = r[0], { unitId: i, subUnitId: s, drawingId: c } = o, g = this._renderManagerService.getRenderById(i), u = g == null ? void 0 : g.scene;
1282
+ if (u == null)
1283
+ return !0;
1284
+ this._searchCropObject(u) != null && this._commandService.syncExecuteCommand(he.id, { isAuto: !0 });
1285
+ const h = V({ unitId: i, subUnitId: s, drawingId: c }), f = u.getObject(h);
1286
+ if (!(f instanceof We)) {
1287
+ this._messageService.show({
1288
+ type: Je.Error,
1289
+ content: this._localeService.t("image-cropper.error")
1290
+ });
1291
+ return;
1292
+ }
1293
+ f != null && (this._updateCropperObject(e, f), this._commandService.executeCommand(ke.id, { unitId: i, subUnitId: s, drawingId: c }));
1294
+ })
1295
+ );
1296
+ }
1297
+ _calculateSrcRectByRatio(n, t, e, r, o, i) {
1298
+ const s = e / r, c = o / i;
1299
+ let g = e, u = r;
1300
+ s > c ? g = r * c : u = e / c;
1301
+ const d = (e - g) / 2, h = (r - u) / 2;
1302
+ return {
1303
+ left: Ee(d, 1),
1304
+ top: Ee(h, 1),
1305
+ right: Ee(e - (d + g), 1),
1306
+ bottom: Ee(r - (h + u), 1)
1307
+ };
1308
+ }
1309
+ _updateCropperObject(n, t) {
1310
+ const { left: e, top: r, width: o, height: i } = t.calculateTransformWithSrcRect();
1311
+ let s;
1312
+ switch (n) {
1313
+ case H.R1_1:
1314
+ s = this._calculateSrcRectByRatio(e, r, o, i, 1, 1);
1315
+ break;
1316
+ case H.R16_9:
1317
+ s = this._calculateSrcRectByRatio(e, r, o, i, 16, 9);
1318
+ break;
1319
+ case H.R9_16:
1320
+ s = this._calculateSrcRectByRatio(e, r, o, i, 9, 16);
1321
+ break;
1322
+ case H.R5_4:
1323
+ s = this._calculateSrcRectByRatio(e, r, o, i, 5, 4);
1324
+ break;
1325
+ case H.R4_5:
1326
+ s = this._calculateSrcRectByRatio(e, r, o, i, 4, 5);
1327
+ break;
1328
+ case H.R4_3:
1329
+ s = this._calculateSrcRectByRatio(e, r, o, i, 4, 3);
1330
+ break;
1331
+ case H.R3_4:
1332
+ s = this._calculateSrcRectByRatio(e, r, o, i, 3, 4);
1333
+ break;
1334
+ case H.R3_2:
1335
+ s = this._calculateSrcRectByRatio(e, r, o, i, 3, 2);
1336
+ break;
1337
+ case H.R2_3:
1338
+ s = this._calculateSrcRectByRatio(e, r, o, i, 2, 3);
1339
+ break;
1340
+ case H.FREE:
1341
+ }
1342
+ if (s == null)
1343
+ return;
1344
+ t.setSrcRect(s);
1345
+ const { left: c = 0, top: g = 0, bottom: u = 0, right: d = 0 } = s;
1346
+ t.transformByStateCloseCropper({
1347
+ left: e + c,
1348
+ top: r + g,
1349
+ width: o - d - c,
1350
+ height: i - u - g
1351
+ });
1352
+ }
1353
+ _initOpenCrop() {
1354
+ this.disposeWithMe(
1355
+ this._commandService.onCommandExecuted((n) => {
1356
+ if (n.id !== ke.id)
1357
+ return;
1358
+ const t = n.params;
1359
+ if (t == null)
1360
+ return;
1361
+ const { unitId: e, subUnitId: r, drawingId: o } = t, i = this._renderManagerService.getRenderById(e), s = i == null ? void 0 : i.scene;
1362
+ if (s == null)
1363
+ return !0;
1364
+ if (this._sceneListenerOnImageMap.has(s) || (this._addListenerOnImage(s), this._sceneListenerOnImageMap.add(s)), this._drawingManagerService.getDrawingByParam({ unitId: e, subUnitId: r, drawingId: o }) == null)
1365
+ return;
1366
+ const g = V({ unitId: e, subUnitId: r, drawingId: o }), u = s.getObject(g);
1367
+ if (u == null)
1368
+ return;
1369
+ if (!(u instanceof We)) {
1370
+ this._messageService.show({
1371
+ type: Je.Error,
1372
+ content: this._localeService.t("image-cropper.error")
1373
+ });
1374
+ return;
1375
+ }
1376
+ const d = s.getTransformer();
1377
+ d == null || d.clearControls();
1378
+ const h = new Oe(`${g}-crop`, {
1379
+ srcRect: u.srcRect,
1380
+ prstGeom: u.prstGeom,
1381
+ applyTransform: u.calculateTransformWithSrcRect()
1382
+ });
1383
+ 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: e, subUnitId: r, drawingId: o }]);
1384
+ })
1385
+ );
1386
+ }
1387
+ _searchCropObject(n) {
1388
+ const t = n.getAllObjects();
1389
+ for (const e of t)
1390
+ if (e instanceof Oe)
1391
+ return e;
1392
+ }
1393
+ _initCloseCrop() {
1394
+ this.disposeWithMe(
1395
+ this._commandService.onCommandExecuted((n) => {
1396
+ if (n.id !== he.id)
1397
+ return;
1398
+ const t = this._univerInstanceService.getFocusedUnit();
1399
+ if (t == null)
1400
+ return;
1401
+ const e = t.getUnitId(), r = this._renderManagerService.getRenderById(e), o = r == null ? void 0 : r.scene;
1402
+ if (o == null)
1403
+ return !0;
1404
+ const i = this._searchCropObject(o);
1405
+ if (i == null)
1406
+ return;
1407
+ const s = this._getApplyObjectByCropObject(i);
1408
+ if (s == null)
1409
+ return;
1410
+ const c = o.getTransformerByCreate();
1411
+ c.detachFrom(i), c.clearCopperControl();
1412
+ const g = this._getSrcRectByTransformState(s, i), u = this._drawingManagerService.getDrawingOKey(s.oKey);
1413
+ if (u != null) {
1414
+ const { left: d, top: h, height: f, width: v } = i;
1415
+ this._drawingManagerService.featurePluginUpdateNotification([{
1416
+ ...u,
1417
+ transform: {
1418
+ ...u.transform,
1419
+ left: d,
1420
+ top: h,
1421
+ height: f,
1422
+ width: v
1423
+ },
1424
+ srcRect: g.srcRectAngle
1425
+ }]);
1426
+ }
1427
+ s.setSrcRect({ ...g.srcRectAngle }), s.closeRenderByCropper(), s.makeDirty(!0), i == null || i.dispose();
1428
+ })
1429
+ );
1430
+ }
1431
+ _getApplyObjectByCropObject(n) {
1432
+ const t = n.oKey, e = t.slice(0, t.length - 5), r = n.getScene().getObject(e);
1433
+ return r == null ? null : r;
1434
+ }
1435
+ _addListenerOnImage(n) {
1436
+ const t = n.getTransformerByCreate();
1437
+ let e = null;
1438
+ this.disposeWithMe(
1439
+ K(
1440
+ t.onChangeStartObservable.add((r) => {
1441
+ const { objects: o } = r, i = o.values().next().value;
1442
+ if (i == null || !(i instanceof Oe))
1443
+ return;
1444
+ const { left: s, top: c, height: g, width: u, angle: d } = i;
1445
+ e = { left: s, top: c, height: g, width: u, angle: d }, t.clearCopperControl();
1446
+ })
1447
+ )
1448
+ ), this.disposeWithMe(
1449
+ K(
1450
+ t.onChangeEndObservable.add((r) => {
1451
+ const { objects: o } = r, i = o.values().next().value;
1452
+ if (i == null || !(i instanceof Oe))
1453
+ return;
1454
+ const { left: s, top: c, height: g, width: u, angle: d } = i;
1455
+ if (!tt({ left: s, top: c, height: g, width: u, angle: d }, e))
1456
+ return;
1457
+ const h = this._getApplyObjectByCropObject(i);
1458
+ if (h == null)
1459
+ return;
1460
+ const f = this._getSrcRectByTransformState(h, i);
1461
+ i.refreshSrcRect(f.srcRect, h.getState()), t.createControlForCopper(i);
1462
+ })
1463
+ )
1464
+ ), this._endCropListener(n);
1465
+ }
1466
+ _addHoverForImageCopper(n) {
1467
+ this.disposeWithMe(
1468
+ K(
1469
+ n.onPointerEnterObserver.add(() => {
1470
+ n.cursor = je.MOVE;
1471
+ })
1472
+ )
1473
+ ), this.disposeWithMe(
1474
+ K(
1475
+ n.onPointerLeaveObserver.add(() => {
1476
+ n.cursor = je.DEFAULT;
1477
+ })
1478
+ )
1479
+ );
1480
+ }
1481
+ _endCropListener(n) {
1482
+ const t = n.getTransformerByCreate();
1483
+ this.disposeWithMe(
1484
+ K(
1485
+ t.onClearControlObservable.add((e) => {
1486
+ e === !0 && this._commandService.syncExecuteCommand(he.id);
1487
+ })
1488
+ )
1489
+ );
1490
+ }
1491
+ _getSrcRectByTransformState(n, t) {
1492
+ const { left: e, top: r, height: o, width: i, strokeWidth: s, angle: c } = t, { left: g, top: u, width: d, height: h, angle: f, strokeWidth: v } = n, w = e - g, p = r - u, E = {
1493
+ left: w,
1494
+ top: p,
1495
+ right: d - w - i,
1496
+ bottom: h - p - o
1497
+ }, _ = { ...E };
1498
+ if (f !== 0) {
1499
+ const O = e + i / 2, S = r + o / 2, I = new Ve(O, S), b = d / 2 + g, R = h / 2 + u, P = new Ve(b, R), y = new Ve(g, u);
1500
+ y.rotateByPoint(Xe(f), P);
1501
+ const M = y.clone();
1502
+ M.rotateByPoint(Xe(-f), I);
1503
+ const B = e - M.x, U = r - M.y;
1504
+ _.left = B, _.top = U, _.right = d - B - i, _.bottom = h - U - o;
1505
+ }
1506
+ return {
1507
+ srcRect: E,
1508
+ srcRectAngle: _
1509
+ };
1510
+ }
1511
+ };
1512
+ Te = Yn([
1513
+ Le(Ae.Rendered, Te),
1514
+ ge(0, le),
1515
+ ge(1, se),
1516
+ ge(2, fe),
1517
+ ge(3, ze),
1518
+ ge(4, Vt),
1519
+ ge(5, de(J))
1520
+ ], Te);
1521
+ var Xn = Object.defineProperty, Jn = Object.getOwnPropertyDescriptor, qn = (a, n, t, e) => {
1522
+ for (var r = e > 1 ? void 0 : e ? Jn(n, t) : n, o = a.length - 1, i; o >= 0; o--)
1523
+ (i = a[o]) && (r = (e ? i(n, t, r) : i(r)) || r);
1524
+ return e && r && Xn(n, t, r), r;
1525
+ }, ue = (a, n) => (t, e) => n(t, e, a);
1526
+ const qe = 50;
1527
+ let Be = class extends He {
1528
+ constructor(a, n, t, e, r, o) {
1529
+ super(), this._commandService = a, this._renderManagerService = n, this._drawingManagerService = t, this._dialogService = e, this._imageIoService = r, this._currentUniverService = o, this._initialize();
1530
+ }
1531
+ dispose() {
1532
+ super.dispose();
1533
+ }
1534
+ _initialize() {
1535
+ this._recoveryImages(), this._drawingAddListener(), this._commandExecutedListener(), this._imageUpdateListener();
1536
+ }
1537
+ _recoveryImages() {
1538
+ const a = this._drawingManagerService.drawingManagerData, n = pt(this._currentUniverService);
1539
+ if (n == null)
1540
+ return;
1541
+ const { unitId: t, subUnitId: e } = n;
1542
+ Object.keys(a).forEach((r) => {
1543
+ Object.keys(a[r]).forEach((o) => {
1544
+ const i = a[r][o].data;
1545
+ i == null || r !== t || o !== e || Object.keys(i).forEach((s) => {
1546
+ i[s] && this._insertImages([{ unitId: r, subUnitId: o, drawingId: s }]);
1547
+ });
1548
+ });
1549
+ });
1550
+ }
1551
+ _commandExecutedListener() {
1552
+ this.disposeWithMe(
1553
+ this._commandService.onCommandExecuted((a) => {
1554
+ if (a.id === it.id) {
1555
+ const n = a.params;
1556
+ if (n == null)
1557
+ return;
1558
+ this._resetImageSize(n);
1559
+ }
1560
+ })
1561
+ );
1562
+ }
1563
+ _getSceneAndTransformerByDrawingSearch(a) {
1564
+ if (a == null)
1565
+ return;
1566
+ const n = this._renderManagerService.getRenderById(a), t = n == null ? void 0 : n.scene;
1567
+ if (t == null)
1568
+ return null;
1569
+ const e = t.getTransformerByCreate();
1570
+ return { scene: t, transformer: e };
1571
+ }
1572
+ _resetImageSize(a) {
1573
+ const n = [], t = [];
1574
+ a.forEach((e) => {
1575
+ const { unitId: r, subUnitId: o, drawingId: i } = e, s = this._getSceneAndTransformerByDrawingSearch(r);
1576
+ if (s == null)
1577
+ return;
1578
+ const { scene: c, transformer: g } = s, u = V({ unitId: r, subUnitId: o, drawingId: i }), d = c.getObject(u);
1579
+ if (d == null)
1580
+ return !0;
1581
+ const h = this._drawingManagerService.getDrawingByParam(e);
1582
+ if (h == null)
1583
+ return !0;
1584
+ if (h.drawingType !== oe.DRAWING_IMAGE)
1585
+ return;
1586
+ d.resetSize();
1587
+ const { width: f, height: v } = d.getNativeSize();
1588
+ t.includes(c) === !1 && t.push(c), n.push({
1589
+ ...h,
1590
+ transform: {
1591
+ ...h.transform,
1592
+ height: v,
1593
+ width: f,
1594
+ angle: 0
1595
+ },
1596
+ srcRect: null,
1597
+ prstGeom: null
1598
+ });
1599
+ }), this._drawingManagerService.featurePluginUpdateNotification(n), t.forEach((e) => {
1600
+ e.getTransformerByCreate().refreshControls().changeNotification();
1601
+ }), this._drawingManagerService.focusDrawing(a);
1602
+ }
1603
+ _drawingAddListener() {
1604
+ this.disposeWithMe(
1605
+ this._drawingManagerService.add$.subscribe((a) => {
1606
+ this._insertImages(a);
1607
+ })
1608
+ );
1609
+ }
1610
+ _insertImages(a) {
1611
+ a.forEach(async (n) => {
1612
+ const { unitId: t, subUnitId: e, drawingId: r } = n, o = this._drawingManagerService.getDrawingByParam(n);
1613
+ if (o == null)
1614
+ return;
1615
+ const { transform: i, drawingType: s, source: c, imageSourceType: g, srcRect: u, prstGeom: d, groupId: h } = o;
1616
+ if (s !== oe.DRAWING_IMAGE)
1617
+ return;
1618
+ const f = this._getSceneAndTransformerByDrawingSearch(t);
1619
+ if (f == null)
1620
+ return;
1621
+ const { scene: v, transformer: w } = f;
1622
+ if (i == null)
1623
+ return !0;
1624
+ const { left: p, top: E, width: _, height: O, angle: S, flipX: I, flipY: b, skewX: R, skewY: P } = i, y = V({ unitId: t, subUnitId: e, drawingId: r }), M = v.getObject(y);
1625
+ if (M != null) {
1626
+ M.transformByState({ left: p, top: E, width: _, height: O, angle: S, flipX: I, flipY: b, skewX: R, skewY: P });
1627
+ return;
1628
+ }
1629
+ const B = this._drawingManagerService.getDrawingOrder(t, e), U = B.indexOf(r), te = { ...i, zIndex: U === -1 ? B.length - 1 : U }, G = this._imageIoService.getImageSourceCache(c, g);
1630
+ let ce = !1;
1631
+ if (G != null)
1632
+ te.image = G;
1633
+ else {
1634
+ if (g === Rt.UUID)
1635
+ try {
1636
+ te.url = await this._imageIoService.getImage(c);
1637
+ } catch (me) {
1638
+ console.error(me);
1639
+ return;
1640
+ }
1641
+ else
1642
+ te.url = c;
1643
+ ce = !0;
1644
+ }
1645
+ const Z = new We(y, te);
1646
+ ce && this._imageIoService.addImageSourceCache(c, g, Z.getNative()), v.addObject(Z, $e).attachTransformerTo(Z), h && xn({ drawingId: h, unitId: t, subUnitId: e }, Z, v, this._drawingManagerService), d != null && Z.setPrstGeom(d), u != null && Z.setSrcRect(u), this._addHoverForImage(Z), this._addDialogForImage(Z);
1647
+ });
1648
+ }
1649
+ _imageUpdateListener() {
1650
+ this.disposeWithMe(
1651
+ this._drawingManagerService.update$.subscribe((a) => {
1652
+ a.forEach((n) => {
1653
+ const { unitId: t, subUnitId: e, drawingId: r } = n, o = this._drawingManagerService.getDrawingByParam(n);
1654
+ if (o == null)
1655
+ return;
1656
+ const { transform: i, drawingType: s, srcRect: c, prstGeom: g, source: u, imageSourceType: d } = o;
1657
+ if (s !== oe.DRAWING_IMAGE)
1658
+ return;
1659
+ const h = this._getSceneAndTransformerByDrawingSearch(t);
1660
+ if (h == null)
1661
+ return;
1662
+ const { scene: f, transformer: v } = h;
1663
+ if (i == null)
1664
+ return !0;
1665
+ const w = V({ unitId: t, subUnitId: e, drawingId: r }), p = f.getObject(w);
1666
+ if (p == null)
1667
+ return !0;
1668
+ p.setSrcRect(c), p.setPrstGeom(g);
1669
+ });
1670
+ })
1671
+ );
1672
+ }
1673
+ _addHoverForImage(a) {
1674
+ this.disposeWithMe(
1675
+ K(
1676
+ a.onPointerEnterObserver.add(() => {
1677
+ a.cursor = je.GRAB;
1678
+ })
1679
+ )
1680
+ ), this.disposeWithMe(
1681
+ K(
1682
+ a.onPointerLeaveObserver.add(() => {
1683
+ a.cursor = je.DEFAULT;
1684
+ })
1685
+ )
1686
+ );
1687
+ }
1688
+ _addDialogForImage(a) {
1689
+ this.disposeWithMe(
1690
+ K(
1691
+ a.onDblclickObserver.add(() => {
1692
+ var s;
1693
+ const n = `${a.oKey}-viewer-dialog`, t = a.getNativeSize(), e = window.innerWidth - qe, r = window.innerHeight - qe, o = this._adjustImageSize(t.width, t.height, e, r), i = this._dialogService.open({
1694
+ width: o.width,
1695
+ id: n,
1696
+ style: { margin: "0", top: "50%", left: "50%", transform: "translate(-50%, -50%)" },
1697
+ children: {
1698
+ label: {
1699
+ name: Ct,
1700
+ props: {
1701
+ src: (s = a.getNative()) == null ? void 0 : s.src,
1702
+ width: o.width,
1703
+ height: o.height
1704
+ }
1705
+ }
1706
+ },
1707
+ destroyOnClose: !0,
1708
+ draggable: !1,
1709
+ onClose: () => {
1710
+ this._dialogService.close(n), i.dispose();
1711
+ }
1712
+ });
1713
+ })
1714
+ )
1715
+ );
1716
+ }
1717
+ _adjustImageSize(a, n, t, e) {
1718
+ if (a <= t && n <= e)
1719
+ return {
1720
+ width: a,
1721
+ height: n
1722
+ };
1723
+ const r = t / a, o = e / n, i = Math.min(r, o);
1724
+ return {
1725
+ width: Math.floor(a * i),
1726
+ height: Math.floor(n * i)
1727
+ };
1728
+ }
1729
+ };
1730
+ Be = qn([
1731
+ Le(Ae.Rendered, Be),
1732
+ ue(0, le),
1733
+ ue(1, fe),
1734
+ ue(2, se),
1735
+ ue(3, Gt),
1736
+ ue(4, Mt),
1737
+ ue(5, ze)
1738
+ ], Be);
1739
+ var Qn = Object.defineProperty, er = Object.getOwnPropertyDescriptor, tr = (a, n, t, e) => {
1740
+ for (var r = e > 1 ? void 0 : e ? er(n, t) : n, o = a.length - 1, i; o >= 0; o--)
1741
+ (i = a[o]) && (r = (e ? i(n, t, r) : i(r)) || r);
1742
+ return e && r && Qn(n, t, r), r;
1743
+ }, Qe = (a, n) => (t, e) => n(t, e, a);
1744
+ const nr = "IMAGE_UI_PLUGIN";
1745
+ var Ge;
1746
+ let et = (Ge = class extends Nt {
1747
+ constructor(a, n, t) {
1748
+ super(), this._injector = n, this._localeService = t;
1749
+ }
1750
+ onStarting(a) {
1751
+ this._initDependencies(a);
1752
+ }
1753
+ _initDependencies(a) {
1754
+ [
1755
+ // services
1756
+ // controllers
1757
+ [Ne],
1758
+ [De],
1759
+ [Te],
1760
+ [Be]
1761
+ ].forEach((t) => a.add(t));
1762
+ }
1763
+ }, ne(Ge, "pluginName", nr), Ge);
1764
+ et = tr([
1765
+ Qe(1, de(at)),
1766
+ Qe(2, de(J))
1767
+ ], et);
1768
+ export {
1769
+ An as COMPONENT_IMAGE_POPUP_MENU,
1770
+ he as CloseImageCropOperation,
1771
+ dr as DrawingCommonPanel,
1772
+ Oe as ImageCropperObject,
1773
+ Ln as ImagePopupMenu,
1774
+ it as ImageResetSizeOperation,
1775
+ ke as OpenImageCropOperation,
1776
+ et as UniverDrawingUIPlugin,
1777
+ Se as getUpdateParams
1778
+ };