@univerjs/drawing-ui 0.1.13-nightly.202406041140

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