chunk-AGSU7DWG.js 83 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102
  1. import {
  2. h3,
  3. n1,
  4. o3
  5. } from "./chunk-POAJ2YNP.js";
  6. import {
  7. BO,
  8. Po,
  9. Xw,
  10. r_,
  11. sC,
  12. um
  13. } from "./chunk-GBYP4PB2.js";
  14. import {
  15. $,
  16. A1,
  17. Y,
  18. Y1,
  19. Yx,
  20. aS,
  21. aT,
  22. e7,
  23. ff,
  24. ie,
  25. p1,
  26. pe,
  27. pf,
  28. q3
  29. } from "./chunk-2MK3Q52E.js";
  30. import {
  31. Ut,
  32. bn,
  33. ln
  34. } from "./chunk-QG2HZMYH.js";
  35. import {
  36. Fe,
  37. Oa,
  38. Ot,
  39. Pt,
  40. Ra,
  41. S0,
  42. SE,
  43. Vr,
  44. W0,
  45. Ze,
  46. _n,
  47. ar,
  48. filter,
  49. fm,
  50. gm,
  51. iC,
  52. nt,
  53. nu,
  54. ot,
  55. re,
  56. switchMap,
  57. vl
  58. } from "./chunk-23V3HWTR.js";
  59. import {
  60. require_react
  61. } from "./chunk-GNR2UJZM.js";
  62. import {
  63. __toESM
  64. } from "./chunk-2LSFTFF7.js";
  65. // node_modules/.pnpm/@univerjs+drawing-ui@0.5.5_@grpc+grpc-js@1.13.4_react-dom@18.3.1_react@18.3.1_rxjs@7.8.1_typescript@5.4.5/node_modules/@univerjs/drawing-ui/lib/es/index.js
  66. var import_react = __toESM(require_react());
  67. var Tn = Object.defineProperty;
  68. var Bn = (i, t, n) => t in i ? Tn(i, t, { enumerable: true, configurable: true, writable: true, value: n }) : i[t] = n;
  69. var Q = (i, t, n) => Bn(i, typeof t != "symbol" ? t + "" : t, n);
  70. function et(i, t, n, e) {
  71. const r = e.getDrawingByParam(i);
  72. if (r == null)
  73. return;
  74. const s = bn(i), a = n.getObject(s);
  75. if (a && !(a instanceof e7))
  76. return;
  77. if (a != null) {
  78. a.addObject(t);
  79. return;
  80. }
  81. const o = new e7(s);
  82. n.addObject(o, aS).attachTransformerTo(o), o.addObject(t);
  83. const { transform: c } = r;
  84. c && o.transformByState(
  85. {
  86. left: c.left,
  87. top: c.top,
  88. angle: c.angle
  89. }
  90. );
  91. }
  92. function hn(i, t) {
  93. var s;
  94. const n = t ? i.getUnit(t) : i.getFocusedUnit();
  95. if (n == null)
  96. return;
  97. const e = n.getUnitId();
  98. let r;
  99. return n.type === Fe.UNIVER_SHEET ? r = (s = n.getActiveSheet()) == null ? void 0 : s.getSheetId() : (n.type === Fe.UNIVER_DOC || n.type === Fe.UNIVER_SLIDE) && (r = e), { unitId: e, subUnitId: r, current: n };
  100. }
  101. var fn = "COMPONENT_IMAGE_VIEWER";
  102. var nt2 = Object.defineProperty;
  103. var tt = Object.getOwnPropertyDescriptor;
  104. var rt = (i, t, n, e) => {
  105. for (var r = e > 1 ? void 0 : e ? tt(t, n) : t, s = i.length - 1, a; s >= 0; s--)
  106. (a = i[s]) && (r = (e ? a(t, n, r) : a(r)) || r);
  107. return e && r && nt2(t, n, r), r;
  108. };
  109. var $e = (i, t) => (n, e) => t(n, e, i);
  110. var nn = 50;
  111. var De = class {
  112. constructor(i, t, n) {
  113. this._drawingManagerService = i, this._imageIoService = t, this._dialogService = n;
  114. }
  115. // eslint-disable-next-line max-lines-per-function
  116. async renderImages(i, t) {
  117. const {
  118. transform: n,
  119. drawingType: e,
  120. source: r,
  121. imageSourceType: s,
  122. srcRect: a,
  123. prstGeom: o,
  124. groupId: c,
  125. unitId: g,
  126. subUnitId: m,
  127. drawingId: d,
  128. isMultiTransform: h,
  129. transforms: f
  130. } = i;
  131. if (e !== gm.DRAWING_IMAGE || !this._drawingManagerService.getDrawingVisible() || n == null)
  132. return;
  133. const _ = h && f ? f : [n], w = [];
  134. for (const p of _) {
  135. const { left: S, top: v, width: j, height: b, angle: N, flipX: P, flipY: I, skewX: y, skewY: x } = p, D = _.indexOf(p), B = bn({ unitId: g, subUnitId: m, drawingId: d }, h ? D : void 0), E = t.getObject(B);
  136. if (E != null) {
  137. E.transformByState({ left: S, top: v, width: j, height: b, angle: N, flipX: P, flipY: I, skewX: y, skewY: x });
  138. continue;
  139. }
  140. const re2 = this._drawingManagerService.getDrawingOrder(g, m), W = re2.indexOf(d), q = { ...p, zIndex: W === -1 ? re2.length - 1 : W }, be = this._imageIoService.getImageSourceCache(r, s);
  141. let ie2 = false;
  142. if (be != null)
  143. q.image = be;
  144. else {
  145. if (s === vl.UUID)
  146. try {
  147. q.url = await this._imageIoService.getImage(r);
  148. } catch (Ge) {
  149. console.error(Ge);
  150. continue;
  151. }
  152. else
  153. q.url = r;
  154. ie2 = true;
  155. }
  156. if (t.getObject(B))
  157. continue;
  158. q.printable = true;
  159. const k = new aT(B, q);
  160. ie2 && this._imageIoService.addImageSourceCache(r, s, k.getNative()), this._drawingManagerService.getDrawingVisible() && (t.addObject(k, aS), this._drawingManagerService.getDrawingEditable() && t.attachTransformerTo(k), c && et({ drawingId: c, unitId: g, subUnitId: m }, k, t, this._drawingManagerService), o != null && k.setPrstGeom(o), a != null && k.setSrcRect(a), w.push(k));
  161. }
  162. return w;
  163. }
  164. renderDrawing(i, t) {
  165. const n = this._drawingManagerService.getDrawingByParam(i);
  166. if (n != null)
  167. switch (n.drawingType) {
  168. case gm.DRAWING_IMAGE:
  169. return this.renderImages(n, t);
  170. }
  171. }
  172. previewImage(i, t, n, e) {
  173. const r = `${i}-viewer-dialog`, s = window.innerWidth - nn, a = window.innerHeight - nn, o = this._adjustImageSize(n, e, s, a), c = this._dialogService.open({
  174. width: Math.max(o.width, 200),
  175. id: r,
  176. style: { margin: "0", top: "50%", left: "50%", transform: "translate(-50%, -50%)" },
  177. children: {
  178. label: {
  179. name: fn,
  180. props: {
  181. src: t,
  182. width: o.width,
  183. height: o.height
  184. }
  185. }
  186. },
  187. destroyOnClose: true,
  188. draggable: false,
  189. onClose: () => {
  190. this._dialogService.close(r), c.dispose();
  191. }
  192. });
  193. }
  194. _adjustImageSize(i, t, n, e) {
  195. if (i <= n && t <= e)
  196. return {
  197. width: i,
  198. height: t
  199. };
  200. const r = n / i, s = e / t, a = Math.min(r, s);
  201. return {
  202. width: Math.floor(i * a),
  203. height: Math.floor(t * a)
  204. };
  205. }
  206. };
  207. De = rt([
  208. $e(0, Ut),
  209. $e(1, Oa),
  210. $e(2, h3)
  211. ], De);
  212. function Ve(i, t) {
  213. const n = [];
  214. return i.forEach((e) => {
  215. const { oKey: r, left: s, top: a, height: o, width: c, angle: g } = e, m = t.getDrawingOKey(r);
  216. if (m == null)
  217. return n.push(null), true;
  218. const { unitId: d, subUnitId: h, drawingId: f, drawingType: _ } = m, w = {
  219. unitId: d,
  220. subUnitId: h,
  221. drawingId: f,
  222. drawingType: _,
  223. transform: {
  224. left: s,
  225. top: a,
  226. height: o,
  227. width: c,
  228. angle: g
  229. }
  230. };
  231. _ === gm.DRAWING_IMAGE && (w.srcRect = e.srcRect), n.push(w);
  232. }), n;
  233. }
  234. var ke = { exports: {} };
  235. var pe2 = {};
  236. var tn;
  237. function it() {
  238. if (tn)
  239. return pe2;
  240. tn = 1;
  241. var i = import_react.default, t = Symbol.for("react.element"), n = Symbol.for("react.fragment"), e = Object.prototype.hasOwnProperty, r = i.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, s = { key: true, ref: true, __self: true, __source: true };
  242. function a(o, c, g) {
  243. var m, d = {}, h = null, f = null;
  244. g !== void 0 && (h = "" + g), c.key !== void 0 && (h = "" + c.key), c.ref !== void 0 && (f = c.ref);
  245. for (m in c)
  246. e.call(c, m) && !s.hasOwnProperty(m) && (d[m] = c[m]);
  247. if (o && o.defaultProps)
  248. for (m in c = o.defaultProps, c)
  249. d[m] === void 0 && (d[m] = c[m]);
  250. return { $$typeof: t, type: o, key: h, ref: f, props: d, _owner: r.current };
  251. }
  252. return pe2.Fragment = n, pe2.jsx = a, pe2.jsxs = a, pe2;
  253. }
  254. var rn;
  255. function at() {
  256. return rn || (rn = 1, ke.exports = it()), ke.exports;
  257. }
  258. var l = at();
  259. function pn(i) {
  260. var t, n, e = "";
  261. if (typeof i == "string" || typeof i == "number")
  262. e += i;
  263. else if (typeof i == "object")
  264. if (Array.isArray(i)) {
  265. var r = i.length;
  266. for (t = 0; t < r; t++)
  267. i[t] && (n = pn(i[t])) && (e && (e += " "), e += n);
  268. } else
  269. for (n in i)
  270. i[n] && (e && (e += " "), e += n);
  271. return e;
  272. }
  273. function O() {
  274. for (var i, t, n = 0, e = "", r = arguments.length; n < r; n++)
  275. (i = arguments[n]) && (t = pn(i)) && (e && (e += " "), e += t);
  276. return e;
  277. }
  278. var R = ((i) => (i.default = "0", i.left = "1", i.center = "2", i.right = "3", i.top = "4", i.middle = "5", i.bottom = "6", i.horizon = "7", i.vertical = "8", i))(R || {});
  279. var Xe = {
  280. id: "sheet.operation.set-image-align",
  281. type: ar.OPERATION,
  282. handler: (i, t) => true
  283. };
  284. var st = "univer-image-common-panel";
  285. var ot2 = "univer-image-common-panel-grid";
  286. var ct = "univer-image-common-panel-border";
  287. var lt = "univer-image-common-panel-title";
  288. var mt = "univer-image-common-panel-subtitle";
  289. var gt = "univer-image-common-panel-row";
  290. var ut = "univer-image-common-panel-row-vertical";
  291. var dt = "univer-image-common-panel-column";
  292. var ht = "univer-image-common-panel-column-center";
  293. var ft = "univer-image-common-panel-inline";
  294. var pt = "univer-image-common-panel-span2";
  295. var Ct = "univer-image-common-panel-span3";
  296. var wt = "univer-image-common-panel-input";
  297. var u = {
  298. imageCommonPanel: st,
  299. imageCommonPanelGrid: ot2,
  300. imageCommonPanelBorder: ct,
  301. imageCommonPanelTitle: lt,
  302. imageCommonPanelSubtitle: mt,
  303. imageCommonPanelRow: gt,
  304. imageCommonPanelRowVertical: ut,
  305. imageCommonPanelColumn: dt,
  306. imageCommonPanelColumnCenter: ht,
  307. imageCommonPanelInline: ft,
  308. imageCommonPanelSpan2: pt,
  309. imageCommonPanelSpan3: Ct,
  310. imageCommonPanelInput: wt
  311. };
  312. var _t = (i) => {
  313. const t = W0(Pt), n = W0(Vr), { alignShow: e } = i, [r, s] = (0, import_react.useState)(R.default), a = [
  314. {
  315. label: n.t("image-panel.align.default"),
  316. value: R.default
  317. },
  318. {
  319. options: [
  320. {
  321. label: n.t("image-panel.align.left"),
  322. value: R.left
  323. },
  324. {
  325. label: n.t("image-panel.align.center"),
  326. value: R.center
  327. },
  328. {
  329. label: n.t("image-panel.align.right"),
  330. value: R.right
  331. }
  332. ]
  333. },
  334. {
  335. options: [
  336. {
  337. label: n.t("image-panel.align.top"),
  338. value: R.top
  339. },
  340. {
  341. label: n.t("image-panel.align.middle"),
  342. value: R.middle
  343. },
  344. {
  345. label: n.t("image-panel.align.bottom"),
  346. value: R.bottom
  347. }
  348. ]
  349. },
  350. {
  351. options: [
  352. {
  353. label: n.t("image-panel.align.horizon"),
  354. value: R.horizon
  355. },
  356. {
  357. label: n.t("image-panel.align.vertical"),
  358. value: R.vertical
  359. }
  360. ]
  361. }
  362. ];
  363. function o(g) {
  364. s(g), t.executeCommand(Xe.id, {
  365. alignType: g
  366. });
  367. }
  368. const c = (g) => g ? "block" : "none";
  369. return l.jsxs("div", { className: O(u.imageCommonPanelGrid, u.imageCommonPanelBorder), style: { display: c(e) }, children: [
  370. l.jsx("div", { className: u.imageCommonPanelRow, children: l.jsx("div", { className: O(u.imageCommonPanelColumn, u.imageCommonPanelTitle), children: l.jsx("div", { children: n.t("image-panel.align.title") }) }) }),
  371. l.jsx("div", { className: u.imageCommonPanelRow, children: l.jsx("div", { className: O(u.imageCommonPanelColumn), children: l.jsx(r_, { value: r, options: a, onChange: o }) }) })
  372. ] });
  373. };
  374. var $2 = function() {
  375. return $2 = Object.assign || function(i) {
  376. for (var t, n = 1, e = arguments.length; n < e; n++) {
  377. t = arguments[n];
  378. for (var r in t)
  379. Object.prototype.hasOwnProperty.call(t, r) && (i[r] = t[r]);
  380. }
  381. return i;
  382. }, $2.apply(this, arguments);
  383. };
  384. var vt = function(i, t) {
  385. var n = {};
  386. for (var e in i)
  387. Object.prototype.hasOwnProperty.call(i, e) && t.indexOf(e) < 0 && (n[e] = i[e]);
  388. if (i != null && typeof Object.getOwnPropertySymbols == "function")
  389. for (var r = 0, e = Object.getOwnPropertySymbols(i); r < e.length; r++)
  390. t.indexOf(e[r]) < 0 && Object.prototype.propertyIsEnumerable.call(i, e[r]) && (n[e[r]] = i[e[r]]);
  391. return n;
  392. };
  393. var X = (0, import_react.forwardRef)(function(i, t) {
  394. var n = i.icon, e = i.id, r = i.className, s = i.extend, a = vt(i, ["icon", "id", "className", "extend"]), o = "univerjs-icon univerjs-icon-".concat(e, " ").concat(r || "").trim(), c = (0, import_react.useRef)("_".concat(It()));
  395. return Cn(n, "".concat(e), { defIds: n.defIds, idSuffix: c.current }, $2({ ref: t, className: o }, a), s);
  396. });
  397. function Cn(i, t, n, e, r) {
  398. return (0, import_react.createElement)(i.tag, $2($2({ key: t }, St(i, n, r)), e), (bt(i, n).children || []).map(function(s, a) {
  399. return Cn(s, "".concat(t, "-").concat(i.tag, "-").concat(a), n, void 0, r);
  400. }));
  401. }
  402. function St(i, t, n) {
  403. var e = $2({}, i.attrs);
  404. n != null && n.colorChannel1 && e.fill === "colorChannel1" && (e.fill = n.colorChannel1);
  405. var r = t.defIds;
  406. return !r || r.length === 0 || (i.tag === "use" && e["xlink:href"] && (e["xlink:href"] = e["xlink:href"] + t.idSuffix), Object.entries(e).forEach(function(s) {
  407. var a = s[0], o = s[1];
  408. typeof o == "string" && (e[a] = o.replace(/url\(#(.*)\)/, "url(#$1".concat(t.idSuffix, ")")));
  409. })), e;
  410. }
  411. function bt(i, t) {
  412. var n, e = t.defIds;
  413. return !e || e.length === 0 ? i : i.tag === "defs" && (!((n = i.children) === null || n === void 0) && n.length) ? $2($2({}, i), { children: i.children.map(function(r) {
  414. return typeof r.attrs.id == "string" && e && e.indexOf(r.attrs.id) > -1 ? $2($2({}, r), { attrs: $2($2({}, r.attrs), { id: r.attrs.id + t.idSuffix }) }) : r;
  415. }) }) : i;
  416. }
  417. function It() {
  418. return Math.random().toString(36).substring(2, 8);
  419. }
  420. X.displayName = "UniverIcon";
  421. var Pt2 = { 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" } }] };
  422. var wn = (0, import_react.forwardRef)(function(i, t) {
  423. return (0, import_react.createElement)(X, Object.assign({}, i, {
  424. id: "autofill",
  425. ref: t,
  426. icon: Pt2
  427. }));
  428. });
  429. wn.displayName = "Autofill";
  430. var yt = { 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" } }] };
  431. var _n2 = (0, import_react.forwardRef)(function(i, t) {
  432. return (0, import_react.createElement)(X, Object.assign({}, i, {
  433. id: "bottom-single",
  434. ref: t,
  435. icon: yt
  436. }));
  437. });
  438. _n2.displayName = "BottomSingle";
  439. var Rt = { 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" } }] };
  440. var vn = (0, import_react.forwardRef)(function(i, t) {
  441. return (0, import_react.createElement)(X, Object.assign({}, i, {
  442. id: "create-copy-single",
  443. ref: t,
  444. icon: Rt
  445. }));
  446. });
  447. vn.displayName = "CreateCopySingle";
  448. var jt = { 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" } }] };
  449. var Sn = (0, import_react.forwardRef)(function(i, t) {
  450. return (0, import_react.createElement)(X, Object.assign({}, i, {
  451. id: "group-single",
  452. ref: t,
  453. icon: jt
  454. }));
  455. });
  456. Sn.displayName = "GroupSingle";
  457. 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" } }] };
  458. var bn2 = (0, import_react.forwardRef)(function(i, t) {
  459. return (0, import_react.createElement)(X, Object.assign({}, i, {
  460. id: "more-down-single",
  461. ref: t,
  462. icon: xt
  463. }));
  464. });
  465. bn2.displayName = "MoreDownSingle";
  466. var Mt = { 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" } }] };
  467. var In = (0, import_react.forwardRef)(function(i, t) {
  468. return (0, import_react.createElement)(X, Object.assign({}, i, {
  469. id: "move-down-single",
  470. ref: t,
  471. icon: Mt
  472. }));
  473. });
  474. In.displayName = "MoveDownSingle";
  475. var Ot2 = { 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" } }] };
  476. var Pn = (0, import_react.forwardRef)(function(i, t) {
  477. return (0, import_react.createElement)(X, Object.assign({}, i, {
  478. id: "move-up-single",
  479. ref: t,
  480. icon: Ot2
  481. }));
  482. });
  483. Pn.displayName = "MoveUpSingle";
  484. var Nt = { 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" } }] };
  485. var yn = (0, import_react.forwardRef)(function(i, t) {
  486. return (0, import_react.createElement)(X, Object.assign({}, i, {
  487. id: "topmost-single",
  488. ref: t,
  489. icon: Nt
  490. }));
  491. });
  492. yn.displayName = "TopmostSingle";
  493. var Dt = { 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" } }] };
  494. var Rn = (0, import_react.forwardRef)(function(i, t) {
  495. return (0, import_react.createElement)(X, Object.assign({}, i, {
  496. id: "ungroup-single",
  497. ref: t,
  498. icon: Dt
  499. }));
  500. });
  501. Rn.displayName = "UngroupSingle";
  502. var Et = (i) => {
  503. const { arrangeShow: t, drawings: n } = i, e = W0(Vr), r = W0(Ut), s = (g) => g ? "block" : "none", [a, o] = (0, import_react.useState)(n);
  504. (0, import_react.useEffect)(() => {
  505. const g = r.focus$.subscribe((m) => {
  506. o(m);
  507. });
  508. return () => {
  509. g.unsubscribe();
  510. };
  511. }, []);
  512. const c = (g) => {
  513. const m = a[0].unitId, d = a[0].subUnitId, h = a.map((f) => f.drawingId);
  514. r.featurePluginOrderUpdateNotification({ unitId: m, subUnitId: d, drawingIds: h, arrangeType: g });
  515. };
  516. return l.jsxs("div", { className: u.imageCommonPanelGrid, style: { display: s(t) }, children: [
  517. l.jsx("div", { className: u.imageCommonPanelRow, children: l.jsx("div", { className: O(u.imageCommonPanelColumn, u.imageCommonPanelTitle), children: l.jsx("div", { children: e.t("image-panel.arrange.title") }) }) }),
  518. l.jsxs("div", { className: u.imageCommonPanelRow, children: [
  519. l.jsx("div", { className: O(u.imageCommonPanelColumn, u.imageCommonPanelSpan2), children: l.jsx(Po, { size: "small", onClick: () => {
  520. c(fm.forward);
  521. }, children: l.jsxs("span", { className: u.imageCommonPanelInline, children: [
  522. l.jsx(Pn, {}),
  523. e.t("image-panel.arrange.forward")
  524. ] }) }) }),
  525. l.jsx("div", { className: O(u.imageCommonPanelColumn, u.imageCommonPanelSpan2), children: l.jsx(Po, { size: "small", onClick: () => {
  526. c(fm.backward);
  527. }, children: l.jsxs("span", { className: u.imageCommonPanelInline, children: [
  528. l.jsx(In, {}),
  529. e.t("image-panel.arrange.backward")
  530. ] }) }) })
  531. ] }),
  532. l.jsxs("div", { className: u.imageCommonPanelRow, children: [
  533. l.jsx("div", { className: O(u.imageCommonPanelColumn, u.imageCommonPanelSpan2), children: l.jsx(Po, { size: "small", onClick: () => {
  534. c(fm.front);
  535. }, children: l.jsxs("span", { className: u.imageCommonPanelInline, children: [
  536. l.jsx(yn, {}),
  537. e.t("image-panel.arrange.front")
  538. ] }) }) }),
  539. l.jsx("div", { className: O(u.imageCommonPanelColumn, u.imageCommonPanelSpan2), children: l.jsx(Po, { size: "small", onClick: () => {
  540. c(fm.back);
  541. }, children: l.jsxs("span", { className: u.imageCommonPanelInline, children: [
  542. l.jsx(_n2, {}),
  543. e.t("image-panel.arrange.back")
  544. ] }) }) })
  545. ] })
  546. ] });
  547. };
  548. var Tt = (i) => {
  549. const t = W0(Vr), n = W0(Yx), e = W0(Ut), { hasGroup: r, drawings: s } = i, [a, o] = (0, import_react.useState)(false), [c, g] = (0, import_react.useState)(true), [m, d] = (0, import_react.useState)(true), h = (p) => p ? "block" : "none", f = () => {
  550. const p = e.getFocusDrawings(), { unitId: S, subUnitId: v } = p[0], j = re.generateRandomId(10), b = pf(0, 0, p.map((I) => I.transform || {})), N = {
  551. unitId: S,
  552. subUnitId: v,
  553. drawingId: j,
  554. drawingType: gm.DRAWING_GROUP,
  555. transform: b
  556. }, P = p.map((I) => {
  557. const y = I.transform || { left: 0, top: 0 }, { unitId: x, subUnitId: D, drawingId: B } = I;
  558. return {
  559. unitId: x,
  560. subUnitId: D,
  561. drawingId: B,
  562. transform: {
  563. ...y,
  564. left: y.left - b.left,
  565. top: y.top - b.top
  566. },
  567. groupId: j
  568. };
  569. });
  570. e.featurePluginGroupUpdateNotification([{
  571. parent: N,
  572. children: P
  573. }]);
  574. }, _ = (p) => {
  575. if (p.drawingType !== gm.DRAWING_GROUP)
  576. return;
  577. const { unitId: S, subUnitId: v, drawingId: j, transform: b = { width: 0, height: 0 } } = p;
  578. if (b == null)
  579. return;
  580. const N = e.getDrawingsByGroup({ unitId: S, subUnitId: v, drawingId: j });
  581. if (N.length === 0)
  582. return;
  583. const P = N.map((I) => {
  584. const { transform: y } = I, { unitId: x, subUnitId: D, drawingId: B } = I, E = ff(y || {}, b, b.width || 0, b.height || 0);
  585. return {
  586. unitId: x,
  587. subUnitId: D,
  588. drawingId: B,
  589. transform: {
  590. ...y,
  591. ...E
  592. },
  593. groupId: void 0
  594. };
  595. });
  596. return {
  597. parent: p,
  598. children: P
  599. };
  600. }, w = () => {
  601. const S = e.getFocusDrawings().map(
  602. (v) => _(v)
  603. ).filter((v) => v != null);
  604. S.length !== 0 && e.featurePluginUngroupUpdateNotification(S);
  605. };
  606. return (0, import_react.useEffect)(() => {
  607. const p = s[0];
  608. if (p == null)
  609. return;
  610. const { unitId: S } = p, v = n.getRenderById(S), j = v == null ? void 0 : v.scene;
  611. if (j == null)
  612. return;
  613. const b = j.getTransformerByCreate(), N = b.clearControl$.subscribe((I) => {
  614. I === true && o(false);
  615. }), P = b.changeStart$.subscribe((I) => {
  616. const { objects: y } = I, x = Ve(y, e), D = x.filter((W) => (W == null ? void 0 : W.drawingType) === gm.DRAWING_GROUP);
  617. let B = false, E = false;
  618. x.length > 1 && (B = true), D.length > 0 && (E = true), o(B || E), g(B), d(E);
  619. });
  620. return () => {
  621. P.unsubscribe(), N.unsubscribe();
  622. };
  623. }, []), l.jsxs("div", { className: O(u.imageCommonPanelGrid, u.imageCommonPanelBorder), style: { display: h(r === true ? a : false) }, children: [
  624. l.jsx("div", { className: u.imageCommonPanelRow, children: l.jsx("div", { className: O(u.imageCommonPanelColumn, u.imageCommonPanelTitle), children: l.jsx("div", { children: t.t("image-panel.group.title") }) }) }),
  625. l.jsxs("div", { className: u.imageCommonPanelRow, children: [
  626. l.jsx("div", { className: O(u.imageCommonPanelColumn, u.imageCommonPanelSpan2, u.imageCommonPanelColumnCenter), children: l.jsx(Po, { size: "small", onClick: () => {
  627. f();
  628. }, style: { display: h(c) }, children: l.jsxs("span", { className: u.imageCommonPanelInline, children: [
  629. l.jsx(Sn, {}),
  630. t.t("image-panel.group.group")
  631. ] }) }) }),
  632. l.jsx("div", { className: O(u.imageCommonPanelColumn, u.imageCommonPanelSpan2, u.imageCommonPanelColumnCenter), children: l.jsx(Po, { size: "small", onClick: () => {
  633. w();
  634. }, style: { display: h(m) }, children: l.jsxs("span", { className: u.imageCommonPanelInline, children: [
  635. l.jsx(Rn, {}),
  636. t.t("image-panel.group.unGroup")
  637. ] }) }) })
  638. ] })
  639. ] });
  640. };
  641. var se = 20;
  642. var Bt = 20;
  643. var Ut2 = [-3600, 3600];
  644. var Re = 300;
  645. var At = (i) => {
  646. var qe;
  647. const t = W0(Vr), n = W0(Ut), e = W0(Yx), { drawings: r, transformShow: s } = i, a = r[0];
  648. if (a == null)
  649. return;
  650. const o = a.transform;
  651. if (o == null)
  652. return;
  653. const { unitId: c, subUnitId: g, drawingId: m, drawingType: d } = a, h = e.getRenderById(c), f = h == null ? void 0 : h.scene;
  654. if (f == null)
  655. return;
  656. const _ = (qe = f.getEngine()) == null ? void 0 : qe.activeScene;
  657. if (_ == null)
  658. return;
  659. const w = f.getTransformerByCreate(), {
  660. width: p = 0,
  661. height: S = 0,
  662. left: v = 0,
  663. top: j = 0,
  664. angle: b = 0
  665. } = o, [N, P] = (0, import_react.useState)(p), [I, y] = (0, import_react.useState)(S), [x, D] = (0, import_react.useState)(v), [B, E] = (0, import_react.useState)(j), [re2, W] = (0, import_react.useState)(b), [q, be] = (0, import_react.useState)(w.keepRatio), ie2 = (C, M, A, V) => {
  666. const { width: U, height: J } = _, { ancestorLeft: z, ancestorTop: F } = f;
  667. let K = C, ae = M, de = A, he = V;
  668. return C + z < 0 && (K = -z), M + F < 0 && (ae = -F), de = U - K - z, de < se && (de = se), he = J - ae - F, he < se && (he = se), C + de + z > U && (K = U - A - z), M + he + F > J && (ae = J - V - F), {
  669. limitLeft: K,
  670. limitTop: ae,
  671. limitWidth: de,
  672. limitHeight: he
  673. };
  674. }, k = (C) => {
  675. const { objects: M } = C, A = Ve(M, n);
  676. if (A.length !== 1)
  677. return;
  678. const V = A[0];
  679. if (V == null)
  680. return;
  681. const { transform: U } = V;
  682. if (U == null)
  683. return;
  684. const {
  685. width: J,
  686. height: z,
  687. left: F,
  688. top: K,
  689. angle: ae
  690. } = U;
  691. J != null && P(J), z != null && y(z), F != null && D(F), K != null && E(K), ae != null && W(ae);
  692. };
  693. (0, import_react.useEffect)(() => {
  694. const C = [
  695. w.changeStart$.subscribe((M) => {
  696. k(M);
  697. }),
  698. w.changing$.subscribe((M) => {
  699. k(M);
  700. }),
  701. w.changeEnd$.subscribe((M) => {
  702. k(M);
  703. }),
  704. n.focus$.subscribe((M) => {
  705. if (M.length !== 1)
  706. return;
  707. const A = n.getDrawingByParam(M[0]);
  708. if (A == null)
  709. return;
  710. const V = A.transform;
  711. if (V == null)
  712. return;
  713. const {
  714. width: U,
  715. height: J,
  716. left: z,
  717. top: F,
  718. angle: K
  719. } = V;
  720. U != null && P(U), J != null && y(J), z != null && D(z), F != null && E(F), K != null && W(K);
  721. })
  722. ];
  723. return () => {
  724. C.forEach((M) => M.unsubscribe());
  725. };
  726. }, []);
  727. const Ge = S0((C) => {
  728. if (C == null)
  729. return;
  730. C = Math.max(C, se);
  731. const { limitWidth: M, limitHeight: A } = ie2(x, B, C, I);
  732. C = Math.min(C, M);
  733. const V = { unitId: c, subUnitId: g, drawingId: m, drawingType: d, transform: { width: C } };
  734. if (q) {
  735. let U = C / N * I;
  736. if (U = Math.max(U, Bt), U > A)
  737. return;
  738. y(U), V.transform.height = U;
  739. }
  740. P(C), n.featurePluginUpdateNotification([V]), w.refreshControls().changeNotification();
  741. }, Re), xn = S0((C) => {
  742. if (C == null)
  743. return;
  744. C = Math.max(C, se);
  745. const { limitHeight: M, limitWidth: A } = ie2(x, B, N, C);
  746. C = Math.min(C, M);
  747. const V = { unitId: c, subUnitId: g, drawingId: m, drawingType: d, transform: { height: C } };
  748. if (q) {
  749. let U = C / I * N;
  750. if (U = Math.max(U, se), U > A)
  751. return;
  752. P(U), V.transform.width = U;
  753. }
  754. y(C), n.featurePluginUpdateNotification([V]), w.refreshControls().changeNotification();
  755. }, Re), Mn = S0((C) => {
  756. if (C == null)
  757. return;
  758. const { limitLeft: M } = ie2(C, B, N, I);
  759. C = M;
  760. const A = { unitId: c, subUnitId: g, drawingId: m, drawingType: d, transform: { left: C } };
  761. D(C), n.featurePluginUpdateNotification([A]), w.refreshControls().changeNotification();
  762. }, Re), On = S0((C) => {
  763. if (C == null)
  764. return;
  765. const { limitTop: M } = ie2(x, C, N, I);
  766. C = M;
  767. const A = { unitId: c, subUnitId: g, drawingId: m, drawingType: d, transform: { top: C } };
  768. E(C), n.featurePluginUpdateNotification([A]), w.refreshControls().changeNotification();
  769. }, Re), Nn = (C) => {
  770. if (C == null)
  771. return;
  772. const [M, A] = Ut2;
  773. C < M && (C = M), C > A && (C = A);
  774. const V = { unitId: c, subUnitId: g, drawingId: m, drawingType: d, transform: { angle: C } };
  775. W(C), n.featurePluginUpdateNotification([V]), w.refreshControls().changeNotification();
  776. }, Dn = (C) => {
  777. be(C), w.keepRatio = C;
  778. }, En = (C) => C ? "block" : "none";
  779. return l.jsxs("div", { className: O(u.imageCommonPanelGrid, u.imageCommonPanelBorder), style: { display: En(s) }, children: [
  780. l.jsx("div", { className: u.imageCommonPanelRow, children: l.jsx("div", { className: O(u.imageCommonPanelColumn, u.imageCommonPanelTitle), children: l.jsx("div", { children: t.t("image-panel.transform.title") }) }) }),
  781. l.jsxs("div", { className: u.imageCommonPanelRow, children: [
  782. l.jsx("div", { className: O(u.imageCommonPanelColumn, u.imageCommonPanelSpan3), children: l.jsxs("label", { children: [
  783. l.jsx("div", { className: u.imageCommonPanelRow, children: l.jsx("div", { className: u.imageCommonPanelColumn, children: t.t("image-panel.transform.width") }) }),
  784. l.jsx("div", { className: u.imageCommonPanelRow, children: l.jsx("div", { className: u.imageCommonPanelColumn, children: l.jsx(BO, { precision: 1, value: N, onChange: (C) => {
  785. Ge(C);
  786. }, className: u.imageCommonPanelInput }) }) })
  787. ] }) }),
  788. l.jsx("div", { className: O(u.imageCommonPanelColumn, u.imageCommonPanelSpan3), children: l.jsxs("label", { children: [
  789. l.jsx("div", { className: u.imageCommonPanelRow, children: l.jsx("div", { className: u.imageCommonPanelColumn, children: t.t("image-panel.transform.height") }) }),
  790. l.jsx("div", { className: u.imageCommonPanelRow, children: l.jsx("div", { className: u.imageCommonPanelColumn, children: l.jsx(BO, { precision: 1, value: I, onChange: (C) => {
  791. xn(C);
  792. }, className: u.imageCommonPanelInput }) }) })
  793. ] }) }),
  794. l.jsx("div", { className: O(u.imageCommonPanelColumn, u.imageCommonPanelSpan3), children: l.jsxs("label", { children: [
  795. l.jsx("div", { className: u.imageCommonPanelRow, children: l.jsx("div", { className: u.imageCommonPanelColumn, children: t.t("image-panel.transform.lock") }) }),
  796. l.jsx("div", { className: O(u.imageCommonPanelRow, u.imageCommonPanelRowVertical), children: l.jsx("div", { className: u.imageCommonPanelColumn, children: l.jsx(um, { checked: q, onChange: Dn }) }) })
  797. ] }) })
  798. ] }),
  799. l.jsxs("div", { className: u.imageCommonPanelRow, children: [
  800. l.jsx("div", { className: O(u.imageCommonPanelColumn, u.imageCommonPanelSpan3), children: l.jsxs("label", { children: [
  801. l.jsx("div", { className: u.imageCommonPanelRow, children: l.jsx("div", { className: u.imageCommonPanelColumn, children: t.t("image-panel.transform.x") }) }),
  802. l.jsx("div", { className: u.imageCommonPanelRow, children: l.jsx("div", { className: u.imageCommonPanelColumn, children: l.jsx(BO, { precision: 1, value: x, onChange: (C) => {
  803. Mn(C);
  804. }, className: u.imageCommonPanelInput }) }) })
  805. ] }) }),
  806. l.jsx("div", { className: O(u.imageCommonPanelColumn, u.imageCommonPanelSpan3), children: l.jsxs("label", { children: [
  807. l.jsx("div", { className: u.imageCommonPanelRow, children: l.jsx("div", { className: u.imageCommonPanelColumn, children: t.t("image-panel.transform.y") }) }),
  808. l.jsx("div", { className: u.imageCommonPanelRow, children: l.jsx("div", { className: u.imageCommonPanelColumn, children: l.jsx(BO, { precision: 1, value: B, onChange: (C) => {
  809. On(C);
  810. }, className: u.imageCommonPanelInput }) }) })
  811. ] }) }),
  812. l.jsx("div", { className: O(u.imageCommonPanelColumn, u.imageCommonPanelSpan3), children: l.jsxs("label", { children: [
  813. l.jsx("div", { className: u.imageCommonPanelRow, children: l.jsx("div", { className: u.imageCommonPanelColumn, children: t.t("image-panel.transform.rotate") }) }),
  814. l.jsx("div", { className: u.imageCommonPanelRow, children: l.jsx("div", { className: u.imageCommonPanelColumn, children: l.jsx(BO, { precision: 1, value: re2, onChange: Nn, className: u.imageCommonPanelInput }) }) })
  815. ] }) })
  816. ] })
  817. ] });
  818. };
  819. var Ke = {
  820. id: "sheet.operation.open-image-crop",
  821. type: ar.OPERATION,
  822. handler: (i, t) => true
  823. };
  824. var le = {
  825. id: "sheet.operation.close-image-crop",
  826. type: ar.OPERATION,
  827. handler: (i, t) => true
  828. };
  829. var T = ((i) => (i.FREE = "0", i.R1_1 = "1", i.R16_9 = "2", i.R9_16 = "3", i.R5_4 = "4", i.R4_5 = "5", i.R4_3 = "6", i.R3_4 = "7", i.R3_2 = "8", i.R2_3 = "9", i))(T || {});
  830. var Ee = {
  831. id: "sheet.operation.Auto-image-crop",
  832. type: ar.OPERATION,
  833. handler: (i, t) => true
  834. };
  835. var Ht = (i) => {
  836. const t = W0(Pt), n = W0(Vr), { drawings: e, cropperShow: r } = i;
  837. if (e[0] == null)
  838. return;
  839. const [a, o] = (0, import_react.useState)(T.FREE), c = (0, import_react.useRef)(false), g = [
  840. {
  841. label: n.t("image-panel.crop.mode"),
  842. value: T.FREE
  843. },
  844. {
  845. label: "1:1",
  846. value: T.R1_1
  847. },
  848. {
  849. label: "16:9",
  850. value: T.R16_9
  851. },
  852. {
  853. label: "9:16",
  854. value: T.R9_16
  855. },
  856. {
  857. label: "5:4",
  858. value: T.R5_4
  859. },
  860. {
  861. label: "4:5",
  862. value: T.R4_5
  863. },
  864. {
  865. label: "4:3",
  866. value: T.R4_3
  867. },
  868. {
  869. label: "3:4",
  870. value: T.R3_4
  871. },
  872. {
  873. label: "3:2",
  874. value: T.R3_2
  875. },
  876. {
  877. label: "2:3",
  878. value: T.R2_3
  879. }
  880. ];
  881. (0, import_react.useEffect)(() => {
  882. const f = t.onCommandExecuted((_) => {
  883. if (_.id === le.id) {
  884. const w = _.params;
  885. w != null && w.isAuto || (c.current = false);
  886. }
  887. });
  888. return () => {
  889. f == null || f.dispose();
  890. };
  891. }, []);
  892. function m(f) {
  893. o(f), c.current && t.executeCommand(Ee.id, {
  894. cropType: f
  895. });
  896. }
  897. const d = (f) => f ? "block" : "none", h = (f) => {
  898. t.executeCommand(Ee.id, {
  899. cropType: f
  900. }), c.current = true;
  901. };
  902. return l.jsxs("div", { className: O(u.imageCommonPanelGrid, u.imageCommonPanelBorder), style: { display: d(r) }, children: [
  903. l.jsx("div", { className: u.imageCommonPanelRow, children: l.jsx("div", { className: O(u.imageCommonPanelColumn, u.imageCommonPanelTitle), children: l.jsx("div", { children: n.t("image-panel.crop.title") }) }) }),
  904. l.jsxs("div", { className: O(u.imageCommonPanelRow, u.imageCommonPanelRowVertical), children: [
  905. l.jsx("div", { className: O(u.imageCommonPanelColumn, u.imageCommonPanelSpan2), children: l.jsx(Po, { size: "small", onClick: () => {
  906. h(a);
  907. }, children: l.jsxs("span", { className: u.imageCommonPanelInline, children: [
  908. l.jsx(vn, {}),
  909. n.t("image-panel.crop.start")
  910. ] }) }) }),
  911. l.jsx("div", { className: O(u.imageCommonPanelColumn, u.imageCommonPanelSpan2), children: l.jsx(r_, { value: a, options: g, onChange: m }) })
  912. ] })
  913. ] });
  914. };
  915. var vr = (i) => {
  916. const t = W0(Ut), n = W0(Yx), e = W0(Vr), { drawings: r, hasArrange: s = true, hasTransform: a = true, hasAlign: o = true, hasCropper: c = true, hasGroup: g = true } = i, m = r[0];
  917. if (m == null)
  918. return;
  919. const { unitId: d } = m, h = n.getRenderById(d), f = h == null ? void 0 : h.scene;
  920. if (f == null)
  921. return;
  922. const _ = f.getTransformerByCreate(), [w, p] = (0, import_react.useState)(true), [S, v] = (0, import_react.useState)(true), [j, b] = (0, import_react.useState)(false), [N, P] = (0, import_react.useState)(true), [I, y] = (0, import_react.useState)(false);
  923. return (0, import_react.useEffect)(() => {
  924. const x = _.clearControl$.subscribe((E) => {
  925. E === true && (p(false), v(false), b(false), P(false), y(true));
  926. }), D = _.changeStart$.subscribe((E) => {
  927. const { objects: re2 } = E, W = Ve(re2, t);
  928. W.length === 0 ? (p(false), v(false), b(false), P(false), y(true)) : W.length === 1 ? (p(true), v(true), b(false), P(true), y(false)) : (p(true), v(false), b(true), P(false), y(false));
  929. }), B = t.focus$.subscribe((E) => {
  930. E.length === 0 ? (p(false), v(false), b(false), P(false), y(true)) : E.length === 1 ? (p(true), v(true), b(false), P(true), y(false)) : (p(true), v(false), b(true), P(false), y(false));
  931. });
  932. return () => {
  933. D.unsubscribe(), x.unsubscribe(), B.unsubscribe();
  934. };
  935. }, []), l.jsxs(l.Fragment, { children: [
  936. l.jsx("div", { style: { display: I === true ? "block" : "none", height: "100%" }, children: l.jsx("div", { style: { display: "flex", justifyContent: "center", alignItems: "center", height: "100%", top: "50%", marginTop: "-100px" }, children: l.jsx("span", { children: e.t("image-panel.null") }) }) }),
  937. l.jsx(Et, { arrangeShow: s === true ? w : false, drawings: r }),
  938. l.jsx(At, { transformShow: a === true ? S : false, drawings: r }),
  939. l.jsx(_t, { alignShow: o === true ? j : false, drawings: r }),
  940. l.jsx(Ht, { cropperShow: c === true ? N : false, drawings: r }),
  941. l.jsx(Tt, { hasGroup: g, drawings: r })
  942. ] });
  943. };
  944. var Lt = "univer-image-popup-menu";
  945. var Vt = "univer-image-popup-menu-item";
  946. var Gt = "univer-image-popup-menu-item-icon";
  947. var Wt = "univer-image-popup-menu-item-title";
  948. var $t = "univer-image-popup-menu-item-hide";
  949. var kt = "univer-btn-container";
  950. var zt = "univer-btn-container-expand";
  951. var Ce = {
  952. imagePopupMenu: Lt,
  953. imagePopupMenuItem: Vt,
  954. imagePopupMenuItemIcon: Gt,
  955. imagePopupMenuItemTitle: Wt,
  956. imagePopupMenuItemHide: $t,
  957. btnContainer: kt,
  958. btnContainerExpand: zt
  959. };
  960. var Ft = (i) => {
  961. var _, w;
  962. const t = (w = (_ = i.popup) == null ? void 0 : _.extraProps) == null ? void 0 : w.menuItems;
  963. if (!t)
  964. return null;
  965. const n = W0(Pt), e = W0(Vr), [r, s] = (0, import_react.useState)(false), [a, o] = (0, import_react.useState)(false), c = () => {
  966. o(true);
  967. }, g = () => {
  968. o(false);
  969. }, m = (p) => {
  970. s(p);
  971. }, d = (p) => {
  972. n.executeCommand(p.commandId, p.commandParams), s(false);
  973. }, h = r || a, f = t.filter((p) => !p.disable);
  974. return l.jsx(
  975. "div",
  976. {
  977. onMouseEnter: c,
  978. onMouseLeave: g,
  979. children: l.jsx(
  980. sC,
  981. {
  982. placement: "bottomLeft",
  983. trigger: ["click"],
  984. overlay: l.jsx("ul", { className: Ce.imagePopupMenu, children: f.map((p) => l.jsx(
  985. "li",
  986. {
  987. onClick: () => d(p),
  988. className: Ce.imagePopupMenuItem,
  989. children: l.jsx("span", { className: Ce.imagePopupMenuItemTitle, children: e.t(p.label) })
  990. },
  991. p.index
  992. )) }),
  993. visible: r,
  994. onVisibleChange: m,
  995. children: l.jsxs(
  996. "div",
  997. {
  998. className: O(Ce.btnContainer, {
  999. [Ce.btnContainerExpand]: r
  1000. }),
  1001. children: [
  1002. l.jsx(
  1003. wn,
  1004. {
  1005. style: { color: "#35322B" },
  1006. extend: { colorChannel1: "rgb(var(--green-700, #409f11))" }
  1007. }
  1008. ),
  1009. h && l.jsx(bn2, { style: { color: "#CCCCCC", fontSize: "8px", marginLeft: "8px" } })
  1010. ]
  1011. }
  1012. )
  1013. }
  1014. )
  1015. }
  1016. );
  1017. };
  1018. var Kt = "COMPONENT_IMAGE_POPUP_MENU";
  1019. var Yt = "drawing-ui.config";
  1020. var an = {};
  1021. var jn = {
  1022. id: "sheet.operation.image-reset-size",
  1023. type: ar.OPERATION,
  1024. handler: (i, t) => true
  1025. };
  1026. var Zt = (i) => {
  1027. const { src: t } = i;
  1028. return t ? l.jsx("div", { children: l.jsx("img", { src: t, alt: "Univer Image Viewer", style: { width: "100%", height: "100%", position: "relative" } }) }) : null;
  1029. };
  1030. var Xt = Object.defineProperty;
  1031. var qt = Object.getOwnPropertyDescriptor;
  1032. var Jt = (i, t, n, e) => {
  1033. for (var r = e > 1 ? void 0 : e ? qt(t, n) : t, s = i.length - 1, a; s >= 0; s--)
  1034. (a = i[s]) && (r = (e ? a(t, n, r) : a(r)) || r);
  1035. return e && r && Xt(t, n, r), r;
  1036. };
  1037. var sn = (i, t) => (n, e) => t(n, e, i);
  1038. var Te = class extends nt {
  1039. constructor(i, t) {
  1040. super(), this._componentManager = i, this._commandService = t, this._init();
  1041. }
  1042. _initCustomComponents() {
  1043. const i = this._componentManager;
  1044. this.disposeWithMe(i.register(Kt, Ft)), this.disposeWithMe(i.register(fn, Zt));
  1045. }
  1046. _initCommands() {
  1047. [
  1048. Ke,
  1049. le,
  1050. jn,
  1051. Xe,
  1052. Ee
  1053. ].forEach((i) => this.disposeWithMe(this._commandService.registerCommand(i)));
  1054. }
  1055. _init() {
  1056. this._initCommands(), this._initCustomComponents();
  1057. }
  1058. };
  1059. Te = Jt([
  1060. sn(0, ot(n1)),
  1061. sn(1, Pt)
  1062. ], Te);
  1063. var Qt = Object.defineProperty;
  1064. var er = Object.getOwnPropertyDescriptor;
  1065. var nr = (i, t, n, e) => {
  1066. for (var r = e > 1 ? void 0 : e ? er(t, n) : t, s = i.length - 1, a; s >= 0; s--)
  1067. (a = i[s]) && (r = (e ? a(t, n, r) : a(r)) || r);
  1068. return e && r && Qt(t, n, r), r;
  1069. };
  1070. var je = (i, t) => (n, e) => t(n, e, i);
  1071. var Be = class extends nt {
  1072. constructor(t, n, e, r) {
  1073. super();
  1074. Q(this, "_sceneListenerOnDrawingMap", /* @__PURE__ */ new WeakSet());
  1075. this._currentUniverService = t, this._commandService = n, this._renderManagerService = e, this._drawingManagerService = r, this._initialize();
  1076. }
  1077. dispose() {
  1078. super.dispose();
  1079. }
  1080. _initialize() {
  1081. this._recoveryImages(), this._drawingAddListener(), this._drawingRemoveListener(), this._drawingUpdateListener(), this._commandExecutedListener(), this._drawingArrangeListener(), this._drawingGroupListener(), this._drawingRefreshListener(), this._drawingVisibleListener();
  1082. }
  1083. _recoveryImages() {
  1084. const t = this._drawingManagerService.drawingManagerData, n = hn(this._currentUniverService);
  1085. if (n == null)
  1086. return;
  1087. const { unitId: e, subUnitId: r } = n;
  1088. Object.keys(t).forEach((s) => {
  1089. Object.keys(t[s]).forEach((a) => {
  1090. const o = t[s][a].data;
  1091. o == null || s !== e || a !== r || Object.keys(o).forEach((c) => {
  1092. o[c] && this._insertDrawing([{ unitId: s, subUnitId: a, drawingId: c }]);
  1093. });
  1094. });
  1095. });
  1096. }
  1097. _commandExecutedListener() {
  1098. this.disposeWithMe(
  1099. this._commandService.onCommandExecuted((t) => {
  1100. if (t.id === Xe.id) {
  1101. const n = t.params;
  1102. if (n == null)
  1103. return;
  1104. this._drawingAlign(n);
  1105. }
  1106. })
  1107. );
  1108. }
  1109. _drawingGroupListener() {
  1110. this.disposeWithMe(
  1111. this._drawingManagerService.group$.subscribe((t) => {
  1112. this._groupDrawings(t);
  1113. })
  1114. ), this.disposeWithMe(
  1115. this._drawingManagerService.ungroup$.subscribe((t) => {
  1116. this._ungroupDrawings(t);
  1117. })
  1118. );
  1119. }
  1120. // private _drawingGroup(params: ISetImageGroupOperationParams) {
  1121. // const { groupType } = params;
  1122. // const drawings = this._drawingManagerService.getFocusDrawings();
  1123. // if (drawings.length === 0) {
  1124. // return;
  1125. // }
  1126. // switch (groupType) {
  1127. // case GroupType.group:
  1128. // this._groupDrawings(drawings);
  1129. // break;
  1130. // case GroupType.regroup:
  1131. // this._regroupDrawings(drawings);
  1132. // break;
  1133. // case GroupType.ungroup:
  1134. // this._ungroupDrawings(drawings);
  1135. // break;
  1136. // default:
  1137. // break;
  1138. // }
  1139. // }
  1140. _getSceneAndTransformerByDrawingSearch(t) {
  1141. if (t == null)
  1142. return;
  1143. const n = this._renderManagerService.getRenderById(t), e = n == null ? void 0 : n.scene;
  1144. if (e == null)
  1145. return null;
  1146. const r = e.getTransformerByCreate();
  1147. return { scene: e, transformer: r };
  1148. }
  1149. _groupDrawings(t) {
  1150. t.forEach((n) => {
  1151. this._groupDrawing(n);
  1152. });
  1153. }
  1154. _groupDrawing(t) {
  1155. const { parent: n, children: e } = t, { unitId: r, subUnitId: s, drawingId: a } = n, o = this._getSceneAndTransformerByDrawingSearch(n.unitId);
  1156. if (o == null)
  1157. return;
  1158. const { scene: c, transformer: g } = o;
  1159. this._commandService.syncExecuteCommand(le.id);
  1160. const m = [];
  1161. if (e.forEach((f) => {
  1162. const _ = bn(f), w = c.getObjectIncludeInGroup(_);
  1163. if (w == null || m.includes(w))
  1164. return;
  1165. m.push(w);
  1166. const { transform: p } = f;
  1167. p != null && (w.classType === Y.GROUP ? w.transformByState({ left: p.left, top: p.top }) : w.transformByState(p));
  1168. }), m.length === 0)
  1169. return;
  1170. const d = bn({ unitId: r, subUnitId: s, drawingId: a }), h = new e7(d);
  1171. c.addObject(h, aS).attachTransformerTo(h), h.addObjects(...m), n.transform && h.transformByState({ left: n.transform.left, top: n.transform.top }), g.clearSelectedObjects(), g.setSelectedControl(h);
  1172. }
  1173. // private _regroupDrawings(drawings: IDrawingSearch[]) {
  1174. // const renderObject = this._getSceneAndTransformerByDrawingSearch(drawings[0].unitId);
  1175. // if (renderObject == null) {
  1176. // return;
  1177. // }
  1178. // const { scene, transformer } = renderObject;
  1179. // const objects: BaseObject[] = [];
  1180. // let firstGroup: Nullable<Group> = null;
  1181. // drawings.forEach((drawing) => {
  1182. // const imageShapeKey = getDrawingShapeKeyByDrawingSearch(drawing);
  1183. // const o = scene.getObject(imageShapeKey);
  1184. // if (o == null) {
  1185. // return true;
  1186. // }
  1187. // const group = o.ancestorGroup as Nullable<Group>;
  1188. // if (group != null && firstGroup == null) {
  1189. // firstGroup = group;
  1190. // } else if (group != null && !objects.includes(group)) {
  1191. // objects.push(group);
  1192. // } else if (!objects.includes(o)) {
  1193. // objects.push(o);
  1194. // }
  1195. // });
  1196. // if (firstGroup == null) {
  1197. // return;
  1198. // }
  1199. // if (objects.length === 0) {
  1200. // return;
  1201. // }
  1202. // (firstGroup as Group).addObjects(...objects);
  1203. // (firstGroup as Group).reCalculateObjects();
  1204. // transformer.clearSelectedObjects();
  1205. // transformer.setSelectedControl(firstGroup);
  1206. // }
  1207. _ungroupDrawings(t) {
  1208. t.forEach((n) => {
  1209. this._ungroupDrawing(n);
  1210. });
  1211. }
  1212. _ungroupDrawing(t) {
  1213. const { parent: n, children: e } = t, r = this._getSceneAndTransformerByDrawingSearch(n.unitId);
  1214. if (r == null)
  1215. return;
  1216. const { scene: s, transformer: a } = r;
  1217. e.forEach((d) => {
  1218. const h = bn(d), f = s.getObjectIncludeInGroup(h);
  1219. if (f == null)
  1220. return true;
  1221. if (f == null)
  1222. return;
  1223. const { transform: _ } = d;
  1224. _ != null && (f.classType === Y.GROUP ? f.transformByState({ left: _.left, top: _.top }) : f.transformByState(_));
  1225. });
  1226. const o = bn(n), c = s.getObject(o), { width: g, height: m } = c;
  1227. c.getObjects().forEach((d) => {
  1228. c.removeSelfObjectAndTransform(d.oKey, g, m);
  1229. }), c.dispose(), a.clearSelectedObjects();
  1230. }
  1231. _drawingAlign(t) {
  1232. const { alignType: n } = t, e = this._drawingManagerService.getFocusDrawings();
  1233. if (n === R.default)
  1234. return;
  1235. const r = [];
  1236. let s = Number.POSITIVE_INFINITY, a = Number.POSITIVE_INFINITY, o = Number.NEGATIVE_INFINITY, c = Number.NEGATIVE_INFINITY, g = 0;
  1237. e.forEach((m) => {
  1238. const { unitId: d, subUnitId: h, drawingId: f, drawingType: _ } = m, w = this._drawingManagerService.getDrawingByParam({ unitId: d, subUnitId: h, drawingId: f });
  1239. if (w == null || w.transform == null)
  1240. return;
  1241. r.push({
  1242. unitId: d,
  1243. subUnitId: h,
  1244. drawingId: f,
  1245. drawingType: _,
  1246. transform: w.transform
  1247. });
  1248. const { left: p = 0, top: S = 0, width: v = 0, height: j = 0 } = w.transform;
  1249. s = Math.min(s, p), a = Math.min(a, S), o = Math.max(o, p + v), c = Math.max(c, S + j), g++;
  1250. }), g !== 0 && (this._sortDrawingTransform(r, n), this._applyAlignType(r, n, s, a, o, c, g));
  1251. }
  1252. _applyAlignType(t, n, e, r, s, a, o) {
  1253. const c = Math.round((s - e) / o * 10) / 10, g = Math.round((a - r) / o * 10) / 10, m = [], d = this._getSceneAndTransformerByDrawingSearch(t[0].unitId);
  1254. if (d == null)
  1255. return;
  1256. const { scene: h, transformer: f } = d;
  1257. t.forEach((_, w) => {
  1258. const { unitId: p, subUnitId: S, drawingId: v, transform: j, drawingType: b } = _, { left: N = 0, top: P = 0, width: I = 0, height: y = 0 } = j;
  1259. let x = N, D = P;
  1260. switch (n) {
  1261. case R.left:
  1262. x = e;
  1263. break;
  1264. case R.center:
  1265. x = e + (s - e) / 2 - I / 2;
  1266. break;
  1267. case R.right:
  1268. x = s - I;
  1269. break;
  1270. case R.top:
  1271. D = r;
  1272. break;
  1273. case R.middle:
  1274. D = r + (a - r) / 2 - y / 2;
  1275. break;
  1276. case R.bottom:
  1277. D = a - y;
  1278. break;
  1279. case R.horizon:
  1280. x = e + c * w;
  1281. break;
  1282. case R.vertical:
  1283. D = r + g * w;
  1284. break;
  1285. }
  1286. (x !== N || D !== P) && m.push({
  1287. unitId: p,
  1288. subUnitId: S,
  1289. drawingId: v,
  1290. drawingType: b,
  1291. transform: {
  1292. left: x,
  1293. top: D
  1294. }
  1295. });
  1296. }), this._drawingManagerService.featurePluginUpdateNotification(m), f.refreshControls().changeNotification();
  1297. }
  1298. _sortDrawingTransform(t, n) {
  1299. t.sort((e, r) => {
  1300. const s = e.transform, a = r.transform, {
  1301. left: o = 0,
  1302. top: c = 0,
  1303. width: g = 0,
  1304. height: m = 0
  1305. } = s, {
  1306. left: d = 0,
  1307. top: h = 0,
  1308. width: f = 0,
  1309. height: _ = 0
  1310. } = a;
  1311. switch (n) {
  1312. case R.left:
  1313. return o - d;
  1314. case R.center:
  1315. return o + g / 2 - (d + f / 2);
  1316. case R.right:
  1317. return o + g - (d + f);
  1318. case R.top:
  1319. return c - h;
  1320. case R.middle:
  1321. return c + m / 2 - (h + _ / 2);
  1322. case R.bottom:
  1323. return c + m - (h + _);
  1324. case R.horizon:
  1325. return o + g / 2 - (d + f / 2);
  1326. case R.vertical:
  1327. return c + m / 2 - (h + _ / 2);
  1328. default:
  1329. return 0;
  1330. }
  1331. });
  1332. }
  1333. _drawingArrangeListener() {
  1334. this.disposeWithMe(
  1335. this._drawingManagerService.order$.subscribe((t) => {
  1336. this._drawingArrange(t);
  1337. })
  1338. );
  1339. }
  1340. _drawingArrange(t) {
  1341. const { unitId: n, subUnitId: e, drawingIds: r } = t, s = this._getSceneAndTransformerByDrawingSearch(n);
  1342. if (s == null)
  1343. return;
  1344. const { scene: a } = s;
  1345. r.forEach((o) => {
  1346. const c = bn({ unitId: n, subUnitId: e, drawingId: o }), g = a.fuzzyMathObjects(c, true);
  1347. if (g == null || g.length === 0)
  1348. return;
  1349. const m = this._drawingManagerService.getDrawingOrder(n, e).indexOf(o);
  1350. for (const d of g)
  1351. d.setProps({ zIndex: m }), d.makeDirty();
  1352. });
  1353. }
  1354. _drawingAddListener() {
  1355. this.disposeWithMe(
  1356. this._drawingManagerService.add$.subscribe((t) => {
  1357. this._insertDrawing(t);
  1358. })
  1359. );
  1360. }
  1361. _insertDrawing(t) {
  1362. const n = [];
  1363. t.forEach((e) => {
  1364. const { unitId: r } = e;
  1365. if (this._drawingManagerService.getDrawingByParam(e) == null)
  1366. return;
  1367. const a = this._getSceneAndTransformerByDrawingSearch(r);
  1368. if (a == null)
  1369. return;
  1370. const { scene: o } = a;
  1371. n.includes(o) || n.push(o);
  1372. }), n.forEach((e) => {
  1373. this._sceneListenerOnDrawingMap.has(e) || (this._addListenerOnDrawing(e), this._sceneListenerOnDrawingMap.add(e));
  1374. });
  1375. }
  1376. _drawingRemoveListener() {
  1377. this.disposeWithMe(
  1378. this._drawingManagerService.remove$.subscribe((t) => {
  1379. t.forEach((n) => {
  1380. var m;
  1381. const { unitId: e, subUnitId: r, drawingId: s } = n, a = this._getSceneAndTransformerByDrawingSearch(e);
  1382. if (a == null)
  1383. return;
  1384. const { scene: o } = a, c = bn({ unitId: e, subUnitId: r, drawingId: s }), g = o.fuzzyMathObjects(c, true);
  1385. if (g.length > 0) {
  1386. for (const d of g)
  1387. d.dispose();
  1388. (m = o.getTransformer()) == null || m.clearSelectedObjects();
  1389. }
  1390. });
  1391. })
  1392. );
  1393. }
  1394. _drawingUpdateListener() {
  1395. this.disposeWithMe(
  1396. this._drawingManagerService.update$.subscribe((t) => {
  1397. t.forEach((n) => {
  1398. var I;
  1399. const { unitId: e, subUnitId: r, drawingId: s } = n, a = this._drawingManagerService.getDrawingByParam(n);
  1400. if (a == null)
  1401. return;
  1402. const { transform: o, drawingType: c } = a, g = this._getSceneAndTransformerByDrawingSearch(e);
  1403. if (g == null)
  1404. return;
  1405. const { scene: m, transformer: d } = g;
  1406. if (o == null)
  1407. return true;
  1408. const { left: h = 0, top: f = 0, width: _ = 0, height: w = 0, angle: p = 0, flipX: S = false, flipY: v = false, skewX: j = 0, skewY: b = 0 } = o, N = bn({ unitId: e, subUnitId: r, drawingId: s }), P = m.getObject(N);
  1409. if (P == null)
  1410. return true;
  1411. P.transformByState({ left: h, top: f, width: _, height: w, angle: p, flipX: S, flipY: v, skewX: j, skewY: b }), (I = m.getTransformer()) == null || I.debounceRefreshControls();
  1412. });
  1413. })
  1414. );
  1415. }
  1416. _drawingRefreshListener() {
  1417. this.disposeWithMe(
  1418. this._drawingManagerService.refreshTransform$.subscribe((t) => {
  1419. t.forEach((n) => {
  1420. const { unitId: e, subUnitId: r, drawingId: s } = n, a = this._getSceneAndTransformerByDrawingSearch(e);
  1421. if (a == null)
  1422. return;
  1423. const o = this._drawingManagerService.getDrawingByParam(n);
  1424. if (o == null)
  1425. return;
  1426. const { transform: c } = o, { scene: g } = a, m = bn({ unitId: e, subUnitId: r, drawingId: s }), d = g.getObject(m);
  1427. if (d == null || c == null)
  1428. return true;
  1429. const {
  1430. left: h = 0,
  1431. top: f = 0,
  1432. width: _ = 0,
  1433. height: w = 0,
  1434. angle: p = 0,
  1435. flipX: S = false,
  1436. flipY: v = false,
  1437. skewX: j = 0,
  1438. skewY: b = 0
  1439. } = c;
  1440. d.transformByState({ left: h, top: f, width: _, height: w, angle: p, flipX: S, flipY: v, skewX: j, skewY: b });
  1441. });
  1442. })
  1443. );
  1444. }
  1445. _drawingVisibleListener() {
  1446. this.disposeWithMe(
  1447. this._drawingManagerService.visible$.subscribe((t) => {
  1448. t.forEach((n) => {
  1449. const { unitId: e, subUnitId: r, drawingId: s, visible: a } = n, o = this._getSceneAndTransformerByDrawingSearch(e);
  1450. if (o == null)
  1451. return;
  1452. const { scene: c } = o, g = bn({ unitId: e, subUnitId: r, drawingId: s }), m = c.getObject(g);
  1453. if (m == null)
  1454. return true;
  1455. a ? m.show() : m.hide();
  1456. });
  1457. })
  1458. );
  1459. }
  1460. _filterUpdateParams(t, n) {
  1461. return t.filter((e, r) => {
  1462. if (e == null)
  1463. return false;
  1464. const { transform: s } = e;
  1465. return iC(s, n == null ? void 0 : n[r]);
  1466. });
  1467. }
  1468. // group?.getObjects().forEach((o) => {
  1469. // const drawing = this._drawingManagerService.getDrawingOKey(o.oKey);
  1470. // if (drawing != null) {
  1471. // const { unitId, subUnitId, drawingId } = drawing;
  1472. // drawings.push({ unitId, subUnitId, drawingId });
  1473. // }
  1474. // });
  1475. _addListenerOnDrawing(t) {
  1476. const n = t.getTransformerByCreate();
  1477. let e = null;
  1478. this.disposeWithMe(
  1479. Ze(
  1480. n.changeStart$.subscribe((r) => {
  1481. const { objects: s } = r, a = Array.from(s.values()), o = [];
  1482. e = a.map((c) => {
  1483. const { left: g, top: m, height: d, width: h, angle: f, oKey: _, isInGroup: w } = c, p = this._drawingManagerService.getDrawingOKey(_);
  1484. if (w || c instanceof e7) {
  1485. let S = c.ancestorGroup;
  1486. if (S == null && c instanceof e7 && (S = c), S == null)
  1487. return null;
  1488. const v = this._drawingManagerService.getDrawingOKey(S.oKey);
  1489. if (v) {
  1490. const { unitId: j, subUnitId: b, drawingId: N } = v;
  1491. o.push({ unitId: j, subUnitId: b, drawingId: N });
  1492. const { left: P, top: I, height: y, width: x, angle: D } = S;
  1493. return { left: P, top: I, height: y, width: x, angle: D };
  1494. }
  1495. } else if (p != null) {
  1496. const { unitId: S, subUnitId: v, drawingId: j } = p;
  1497. return o.push({ unitId: S, subUnitId: v, drawingId: j }), { left: g, top: m, height: d, width: h, angle: f };
  1498. }
  1499. return null;
  1500. }).filter((c) => c != null), o.length > 0 ? this._commandService.syncExecuteCommand(ln.id, o) : this._commandService.syncExecuteCommand(ln.id, []);
  1501. })
  1502. )
  1503. ), this.disposeWithMe(
  1504. Ze(
  1505. n.changeEnd$.subscribe((r) => {
  1506. const { objects: s } = r, a = this._filterUpdateParams(Ve(s, this._drawingManagerService), e);
  1507. a.length > 0 && this._drawingManagerService.featurePluginUpdateNotification(a);
  1508. })
  1509. )
  1510. );
  1511. }
  1512. };
  1513. Be = nr([
  1514. je(0, _n),
  1515. je(1, Pt),
  1516. je(2, Yx),
  1517. je(3, Ut)
  1518. ], Be);
  1519. var xe = class extends q3 {
  1520. constructor(n, e) {
  1521. e == null && (e = {}), e.transformerConfig = {
  1522. keepRatio: false,
  1523. isCropper: true,
  1524. anchorFill: "rgb(0, 0, 0)",
  1525. anchorStroke: "rgb(255, 255, 255)",
  1526. anchorSize: 24
  1527. };
  1528. super(n, e);
  1529. Q(this, "_srcRect");
  1530. Q(this, "_prstGeom");
  1531. Q(this, "_applyTransform");
  1532. Q(this, "_dragPadding", 8);
  1533. Q(this, "_cacheCanvas");
  1534. 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();
  1535. }
  1536. refreshSrcRect(n, e) {
  1537. this._srcRect = n, this._applyTransform = e, this._applyProps();
  1538. }
  1539. get srcRect() {
  1540. return this._srcRect;
  1541. }
  1542. dispose() {
  1543. var n;
  1544. super.dispose(), (n = this._cacheCanvas) == null || n.dispose(), this._srcRect = null;
  1545. }
  1546. isHit(n) {
  1547. const e = this.getInverseCoord(n);
  1548. 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);
  1549. }
  1550. _inSurround(n) {
  1551. const e = this._dragPadding;
  1552. return n.x >= e - this.strokeWidth / 2 && n.x <= this.width + this.strokeWidth / 2 - e && n.y >= e - this.strokeWidth / 2 && n.y <= this.height + this.strokeWidth / 2 - e;
  1553. }
  1554. render(n, e) {
  1555. return this.visible ? (n.save(), this._draw(n), n.restore(), this.makeDirty(false), this) : (this.makeDirty(false), this);
  1556. }
  1557. _draw(n) {
  1558. var c, g;
  1559. const r = this.getScene().getEngine(), { width: s, height: a } = r;
  1560. this._initialCacheCanvas(), (c = this._cacheCanvas) == null || c.clear();
  1561. const o = (g = this._cacheCanvas) == null ? void 0 : g.getContext();
  1562. o != null && (o.save(), A1.drawWith(o, {
  1563. left: 0,
  1564. top: 0,
  1565. width: s,
  1566. height: a,
  1567. fill: "rgba(0, 0, 0, 0.5)"
  1568. }), o.setTransform(n.getTransform()), this._clipForApplyObject(o), this._applyCache(n), o.restore());
  1569. }
  1570. _clipForApplyObject(n) {
  1571. let e = 0;
  1572. if (this._prstGeom != null && (e = 1), n.globalCompositeOperation = "destination-out", n.beginPath(), e === 0) {
  1573. const r = this.transform.getMatrix();
  1574. n.transform(r[0], r[1], r[2], r[3], r[4], r[5]), n.rect(0, 0, this.width, this.height), n.fill();
  1575. }
  1576. }
  1577. _applyProps() {
  1578. if (this._applyTransform == null)
  1579. return;
  1580. let n = 0, e = 0, r = 0, s = 0;
  1581. const { left: a = 0, top: o = 0, width: c = 0, height: g = 0, angle: m } = this._applyTransform;
  1582. if (this._srcRect != null) {
  1583. const { left: f = 0, top: _ = 0, right: w = 0, bottom: p = 0 } = this._srcRect;
  1584. n = f, e = _, r = w, s = p;
  1585. }
  1586. const d = a + n, h = o + e;
  1587. this.transformByState({
  1588. left: d,
  1589. top: h,
  1590. width: a + c - r - d,
  1591. height: o + g - s - h,
  1592. angle: m
  1593. });
  1594. }
  1595. _applyCache(n) {
  1596. if (!n || this._cacheCanvas == null)
  1597. return;
  1598. const e = this._cacheCanvas.getContext();
  1599. e.save(), n.save(), n.setTransform(1, 0, 0, 1, 0, 0), e.setTransform(1, 0, 0, 1, 0, 0), n.drawImage(this._cacheCanvas.getCanvasEle(), 0, 0), n.restore(), e.restore();
  1600. }
  1601. _initialCacheCanvas() {
  1602. if (this._cacheCanvas != null)
  1603. return;
  1604. const n = this.getScene();
  1605. if (n == null)
  1606. return;
  1607. this._cacheCanvas = new pe();
  1608. const e = n.getEngine();
  1609. this._cacheCanvas.setSize(e.width, e.height), e.onTransformChange$.subscribeEvent(() => {
  1610. var r;
  1611. (r = this._cacheCanvas) == null || r.setSize(e.width, e.height), this.makeDirty(true);
  1612. });
  1613. }
  1614. };
  1615. var tr = Object.defineProperty;
  1616. var rr = Object.getOwnPropertyDescriptor;
  1617. var ir = (i, t, n, e) => {
  1618. for (var r = e > 1 ? void 0 : e ? rr(t, n) : t, s = i.length - 1, a; s >= 0; s--)
  1619. (a = i[s]) && (r = (e ? a(t, n, r) : a(r)) || r);
  1620. return e && r && tr(t, n, r), r;
  1621. };
  1622. var ge = (i, t) => (n, e) => t(n, e, i);
  1623. var Ue = class extends nt {
  1624. constructor(t, n, e, r, s, a) {
  1625. super();
  1626. Q(this, "_sceneListenerOnImageMap", /* @__PURE__ */ new WeakSet());
  1627. this._commandService = t, this._drawingManagerService = n, this._renderManagerService = e, this._univerInstanceService = r, this._messageService = s, this._localeService = a, this._init();
  1628. }
  1629. _init() {
  1630. this._initOpenCrop(), this._initCloseCrop(), this._initAutoCrop();
  1631. }
  1632. _initAutoCrop() {
  1633. this.disposeWithMe(
  1634. this._commandService.onCommandExecuted((t) => {
  1635. if (t.id !== Ee.id)
  1636. return;
  1637. const n = t.params;
  1638. if (n == null)
  1639. return;
  1640. const { cropType: e } = n, r = this._drawingManagerService.getFocusDrawings();
  1641. if (r.length !== 1)
  1642. return;
  1643. const s = r[0], { unitId: a, subUnitId: o, drawingId: c } = s, g = this._renderManagerService.getRenderById(a), m = g == null ? void 0 : g.scene;
  1644. if (m == null)
  1645. return true;
  1646. this._searchCropObject(m) != null && this._commandService.syncExecuteCommand(le.id, { isAuto: true });
  1647. const h = bn({ unitId: a, subUnitId: o, drawingId: c }), f = m.getObject(h);
  1648. if (!(f instanceof aT)) {
  1649. this._messageService.show({
  1650. type: Xw.Error,
  1651. content: this._localeService.t("image-cropper.error")
  1652. });
  1653. return;
  1654. }
  1655. f != null && (this._updateCropperObject(e, f), this._commandService.executeCommand(Ke.id, { unitId: a, subUnitId: o, drawingId: c }));
  1656. })
  1657. );
  1658. }
  1659. _calculateSrcRectByRatio(t, n, e, r, s, a) {
  1660. const o = e / r, c = s / a;
  1661. let g = e, m = r;
  1662. o > c ? g = r * c : m = e / c;
  1663. const d = (e - g) / 2, h = (r - m) / 2;
  1664. return {
  1665. left: ie(d, 1),
  1666. top: ie(h, 1),
  1667. right: ie(e - (d + g), 1),
  1668. bottom: ie(r - (h + m), 1)
  1669. };
  1670. }
  1671. _updateCropperObject(t, n) {
  1672. const { left: e, top: r, width: s, height: a } = n.calculateTransformWithSrcRect();
  1673. let o;
  1674. switch (t) {
  1675. case T.R1_1:
  1676. o = this._calculateSrcRectByRatio(e, r, s, a, 1, 1);
  1677. break;
  1678. case T.R16_9:
  1679. o = this._calculateSrcRectByRatio(e, r, s, a, 16, 9);
  1680. break;
  1681. case T.R9_16:
  1682. o = this._calculateSrcRectByRatio(e, r, s, a, 9, 16);
  1683. break;
  1684. case T.R5_4:
  1685. o = this._calculateSrcRectByRatio(e, r, s, a, 5, 4);
  1686. break;
  1687. case T.R4_5:
  1688. o = this._calculateSrcRectByRatio(e, r, s, a, 4, 5);
  1689. break;
  1690. case T.R4_3:
  1691. o = this._calculateSrcRectByRatio(e, r, s, a, 4, 3);
  1692. break;
  1693. case T.R3_4:
  1694. o = this._calculateSrcRectByRatio(e, r, s, a, 3, 4);
  1695. break;
  1696. case T.R3_2:
  1697. o = this._calculateSrcRectByRatio(e, r, s, a, 3, 2);
  1698. break;
  1699. case T.R2_3:
  1700. o = this._calculateSrcRectByRatio(e, r, s, a, 2, 3);
  1701. break;
  1702. case T.FREE:
  1703. }
  1704. if (o == null)
  1705. return;
  1706. n.setSrcRect(o);
  1707. const { left: c = 0, top: g = 0, bottom: m = 0, right: d = 0 } = o;
  1708. n.transformByStateCloseCropper({
  1709. left: e + c,
  1710. top: r + g,
  1711. width: s - d - c,
  1712. height: a - m - g
  1713. });
  1714. }
  1715. _initOpenCrop() {
  1716. this.disposeWithMe(
  1717. this._commandService.onCommandExecuted((t) => {
  1718. if (t.id !== Ke.id)
  1719. return;
  1720. const n = t.params;
  1721. if (n == null)
  1722. return;
  1723. const { unitId: e, subUnitId: r, drawingId: s } = n, a = this._renderManagerService.getRenderById(e), o = a == null ? void 0 : a.scene;
  1724. if (o == null)
  1725. return true;
  1726. if (this._sceneListenerOnImageMap.has(o) || (this._addListenerOnImage(o), this._sceneListenerOnImageMap.add(o)), this._drawingManagerService.getDrawingByParam({ unitId: e, subUnitId: r, drawingId: s }) == null)
  1727. return;
  1728. const g = bn({ unitId: e, subUnitId: r, drawingId: s }), m = o.getObject(g);
  1729. if (m == null)
  1730. return;
  1731. if (!(m instanceof aT)) {
  1732. this._messageService.show({
  1733. type: Xw.Error,
  1734. content: this._localeService.t("image-cropper.error")
  1735. });
  1736. return;
  1737. }
  1738. const d = o.getTransformer();
  1739. d == null || d.clearControls();
  1740. const h = new xe(`${g}-crop`, {
  1741. srcRect: m.srcRect,
  1742. prstGeom: m.prstGeom,
  1743. applyTransform: m.calculateTransformWithSrcRect()
  1744. });
  1745. o.addObject(h, m.getLayerIndex() + 1).attachTransformerTo(h), d == null || d.createControlForCopper(h), this._addHoverForImageCopper(h), m.openRenderByCropper(), d == null || d.refreshControls(), h.makeDirty(true), this._commandService.syncExecuteCommand(ln.id, [{ unitId: e, subUnitId: r, drawingId: s }]);
  1746. })
  1747. );
  1748. }
  1749. _searchCropObject(t) {
  1750. const n = t.getAllObjectsByOrder();
  1751. for (const e of n)
  1752. if (e instanceof xe)
  1753. return e;
  1754. }
  1755. _initCloseCrop() {
  1756. this.disposeWithMe(
  1757. this._commandService.onCommandExecuted((n) => {
  1758. if (n.id !== le.id)
  1759. return;
  1760. const e = this._univerInstanceService.getFocusedUnit();
  1761. if (e == null)
  1762. return;
  1763. const r = e.getUnitId(), s = this._renderManagerService.getRenderById(r), a = s == null ? void 0 : s.scene;
  1764. if (a == null)
  1765. return true;
  1766. const o = this._searchCropObject(a);
  1767. if (o == null)
  1768. return;
  1769. const c = this._getApplyObjectByCropObject(o);
  1770. if (c == null)
  1771. return;
  1772. const g = a.getTransformerByCreate();
  1773. g.detachFrom(o), g.clearCopperControl();
  1774. const m = this._getSrcRectByTransformState(c, o), d = this._drawingManagerService.getDrawingOKey(c.oKey);
  1775. if (d != null) {
  1776. const { left: h, top: f, height: _, width: w } = o;
  1777. this._drawingManagerService.featurePluginUpdateNotification([{
  1778. ...d,
  1779. transform: {
  1780. ...d.transform,
  1781. left: h,
  1782. top: f,
  1783. height: _,
  1784. width: w
  1785. },
  1786. srcRect: m.srcRectAngle
  1787. }]);
  1788. }
  1789. c.setSrcRect({ ...m.srcRectAngle }), c.closeRenderByCropper(), c.makeDirty(true), o == null || o.dispose();
  1790. })
  1791. );
  1792. const t = this._univerInstanceService.getCurrentTypeOfUnit$(Fe.UNIVER_SHEET).pipe(
  1793. filter((n) => !!n),
  1794. switchMap((n) => n.activeSheet$)
  1795. );
  1796. this.disposeWithMe(t.subscribe(() => {
  1797. this._commandService.syncExecuteCommand(le.id);
  1798. }));
  1799. }
  1800. _getApplyObjectByCropObject(t) {
  1801. const n = t.oKey, e = n.slice(0, n.length - 5), r = t.getScene();
  1802. if (!r)
  1803. return null;
  1804. const s = r.getObject(e);
  1805. return s == null ? null : s;
  1806. }
  1807. _addListenerOnImage(t) {
  1808. const n = t.getTransformerByCreate();
  1809. let e = null;
  1810. this.disposeWithMe(
  1811. n.changeStart$.subscribe((r) => {
  1812. const { objects: s } = r, a = s.values().next().value;
  1813. if (a == null || !(a instanceof xe))
  1814. return;
  1815. const { left: o, top: c, height: g, width: m, angle: d } = a;
  1816. e = { left: o, top: c, height: g, width: m, angle: d }, n.clearCopperControl();
  1817. })
  1818. ), this.disposeWithMe(
  1819. n.changeEnd$.subscribe((r) => {
  1820. const { objects: s } = r, a = s.values().next().value;
  1821. if (a == null || !(a instanceof xe))
  1822. return;
  1823. const { left: o, top: c, height: g, width: m, angle: d } = a;
  1824. if (!iC({ left: o, top: c, height: g, width: m, angle: d }, e))
  1825. return;
  1826. const h = this._getApplyObjectByCropObject(a);
  1827. if (h == null)
  1828. return;
  1829. const f = this._getSrcRectByTransformState(h, a);
  1830. a.refreshSrcRect(f.srcRect, h.getState()), n.createControlForCopper(a);
  1831. })
  1832. ), this._endCropListener(t);
  1833. }
  1834. _addHoverForImageCopper(t) {
  1835. this.disposeWithMe(
  1836. t.onPointerEnter$.subscribeEvent(() => {
  1837. t.cursor = p1.MOVE;
  1838. })
  1839. ), this.disposeWithMe(
  1840. t.onPointerLeave$.subscribeEvent(() => {
  1841. t.cursor = p1.DEFAULT;
  1842. })
  1843. );
  1844. }
  1845. _endCropListener(t) {
  1846. const n = t.getTransformerByCreate();
  1847. this.disposeWithMe(
  1848. n.clearControl$.subscribe((e) => {
  1849. e === true && this._commandService.syncExecuteCommand(le.id);
  1850. })
  1851. );
  1852. }
  1853. _getSrcRectByTransformState(t, n) {
  1854. const { left: e, top: r, height: s, width: a, strokeWidth: o, angle: c } = n, { left: g, top: m, width: d, height: h, angle: f, strokeWidth: _ } = t, w = e - g, p = r - m, S = {
  1855. left: w,
  1856. top: p,
  1857. right: d - w - a,
  1858. bottom: h - p - s
  1859. }, v = { ...S };
  1860. if (f !== 0) {
  1861. const j = e + a / 2, b = r + s / 2, N = new $(j, b), P = d / 2 + g, I = h / 2 + m, y = new $(P, I), x = new $(g, m);
  1862. x.rotateByPoint(Y1(f), y);
  1863. const D = x.clone();
  1864. D.rotateByPoint(Y1(-f), N);
  1865. const B = e - D.x, E = r - D.y;
  1866. v.left = B, v.top = E, v.right = d - B - a, v.bottom = h - E - s;
  1867. }
  1868. return {
  1869. srcRect: S,
  1870. srcRectAngle: v
  1871. };
  1872. }
  1873. };
  1874. Ue = ir([
  1875. ge(0, Pt),
  1876. ge(1, Ut),
  1877. ge(2, Yx),
  1878. ge(3, _n),
  1879. ge(4, o3),
  1880. ge(5, ot(Vr))
  1881. ], Ue);
  1882. var ar2 = Object.defineProperty;
  1883. var sr = Object.getOwnPropertyDescriptor;
  1884. var or = (i, t, n, e) => {
  1885. for (var r = e > 1 ? void 0 : e ? sr(t, n) : t, s = i.length - 1, a; s >= 0; s--)
  1886. (a = i[s]) && (r = (e ? a(t, n, r) : a(r)) || r);
  1887. return e && r && ar2(t, n, r), r;
  1888. };
  1889. var oe = (i, t) => (n, e) => t(n, e, i);
  1890. var Ae = class extends nt {
  1891. constructor(i, t, n, e, r, s, a) {
  1892. super(), this._commandService = i, this._renderManagerService = t, this._drawingManagerService = n, this._dialogService = e, this._imageIoService = r, this._currentUniverService = s, this._drawingRenderService = a, this._initialize();
  1893. }
  1894. dispose() {
  1895. super.dispose();
  1896. }
  1897. _initialize() {
  1898. this._drawingAddListener(), this._commandExecutedListener(), this._imageUpdateListener();
  1899. }
  1900. _commandExecutedListener() {
  1901. this.disposeWithMe(
  1902. this._commandService.onCommandExecuted((i) => {
  1903. if (i.id === jn.id) {
  1904. const t = i.params;
  1905. if (t == null)
  1906. return;
  1907. this._resetImageSize(t);
  1908. }
  1909. })
  1910. );
  1911. }
  1912. _getSceneAndTransformerByDrawingSearch(i) {
  1913. if (i == null)
  1914. return;
  1915. const t = this._renderManagerService.getRenderById(i), n = t == null ? void 0 : t.scene;
  1916. if (n == null)
  1917. return null;
  1918. const e = n.getTransformerByCreate();
  1919. return { scene: n, transformer: e };
  1920. }
  1921. _resetImageSize(i) {
  1922. const t = [], n = [];
  1923. i.forEach((e) => {
  1924. const { unitId: r, subUnitId: s, drawingId: a } = e, o = this._getSceneAndTransformerByDrawingSearch(r);
  1925. if (o == null)
  1926. return;
  1927. const { scene: c } = o, g = bn({ unitId: r, subUnitId: s, drawingId: a }), m = c.getObject(g);
  1928. if (m == null)
  1929. return true;
  1930. const d = this._drawingManagerService.getDrawingByParam(e);
  1931. if (d == null)
  1932. return true;
  1933. if (d.drawingType !== gm.DRAWING_IMAGE)
  1934. return;
  1935. m.resetSize();
  1936. const { width: h, height: f } = m.getNativeSize();
  1937. n.includes(c) === false && n.push(c), t.push({
  1938. ...d,
  1939. transform: {
  1940. ...d.transform,
  1941. height: f,
  1942. width: h,
  1943. angle: 0
  1944. },
  1945. srcRect: null,
  1946. prstGeom: null
  1947. });
  1948. }), this._drawingManagerService.featurePluginUpdateNotification(t), n.forEach((e) => {
  1949. e.getTransformerByCreate().refreshControls().changeNotification();
  1950. }), this._commandService.syncExecuteCommand(ln.id, i);
  1951. }
  1952. _drawingAddListener() {
  1953. this.disposeWithMe(
  1954. this._drawingManagerService.add$.subscribe((i) => {
  1955. this._insertImages(i);
  1956. })
  1957. );
  1958. }
  1959. _insertImages(i) {
  1960. i.forEach(async (t) => {
  1961. var g;
  1962. const { unitId: n, subUnitId: e, drawingId: r } = t, s = this._getSceneAndTransformerByDrawingSearch(n), a = (g = hn(this._currentUniverService, n)) == null ? void 0 : g.subUnitId;
  1963. if (s == null || a !== e)
  1964. return;
  1965. const o = this._drawingManagerService.getDrawingByParam(t);
  1966. if (o == null)
  1967. return;
  1968. const c = await this._drawingRenderService.renderImages(o, s.scene);
  1969. if (!(c == null || c.length === 0))
  1970. for (const m of c)
  1971. this._addHoverForImage(m), this._addDialogForImage(m);
  1972. });
  1973. }
  1974. _imageUpdateListener() {
  1975. this.disposeWithMe(
  1976. this._drawingManagerService.update$.subscribe((i) => {
  1977. i.forEach((t) => {
  1978. const { unitId: n, subUnitId: e, drawingId: r } = t, s = this._drawingManagerService.getDrawingByParam(t);
  1979. if (s == null)
  1980. return;
  1981. const { transform: a, drawingType: o, srcRect: c, prstGeom: g, source: m, imageSourceType: d } = s;
  1982. if (o !== gm.DRAWING_IMAGE)
  1983. return;
  1984. const h = this._getSceneAndTransformerByDrawingSearch(n);
  1985. if (h == null)
  1986. return;
  1987. const { scene: f, transformer: _ } = h;
  1988. if (a == null)
  1989. return true;
  1990. const w = bn({ unitId: n, subUnitId: e, drawingId: r }), p = f.getObject(w);
  1991. if (p == null)
  1992. return true;
  1993. p.setSrcRect(c), p.setPrstGeom(g);
  1994. });
  1995. })
  1996. );
  1997. }
  1998. _addHoverForImage(i) {
  1999. this.disposeWithMe(
  2000. Ze(
  2001. i.onPointerEnter$.subscribeEvent(() => {
  2002. i.cursor = p1.GRAB;
  2003. })
  2004. )
  2005. ), this.disposeWithMe(
  2006. Ze(
  2007. i.onPointerLeave$.subscribeEvent(() => {
  2008. i.cursor = p1.DEFAULT;
  2009. })
  2010. )
  2011. );
  2012. }
  2013. _addDialogForImage(i) {
  2014. this.disposeWithMe(
  2015. Ze(
  2016. i.onDblclick$.subscribeEvent(() => {
  2017. const t = `${i.oKey}-viewer-dialog`;
  2018. this._drawingRenderService.previewImage(t, i.getNative().src, i.getNativeSize().width, i.getNativeSize().height);
  2019. })
  2020. )
  2021. );
  2022. }
  2023. };
  2024. Ae = or([
  2025. oe(0, Pt),
  2026. oe(1, Yx),
  2027. oe(2, Ut),
  2028. oe(3, h3),
  2029. oe(4, Oa),
  2030. oe(5, _n),
  2031. oe(6, ot(De))
  2032. ], Ae);
  2033. var cr = Object.defineProperty;
  2034. var lr = Object.getOwnPropertyDescriptor;
  2035. var mr = (i, t, n, e) => {
  2036. for (var r = e > 1 ? void 0 : e ? lr(t, n) : t, s = i.length - 1, a; s >= 0; s--)
  2037. (a = i[s]) && (r = (e ? a(t, n, r) : a(r)) || r);
  2038. return e && r && cr(t, n, r), r;
  2039. };
  2040. var on = (i, t) => (n, e) => t(n, e, i);
  2041. var gr = "UNIVER_DRAWING_UI_PLUGIN";
  2042. var ze;
  2043. var cn = (ze = class extends Ra {
  2044. constructor(i = an, t, n) {
  2045. super(), this._config = i, this._injector = t, this._configService = n;
  2046. const { menu: e, ...r } = nu(
  2047. {},
  2048. an,
  2049. this._config
  2050. );
  2051. e && this._configService.setConfig("menu", e, { merge: true }), this._configService.setConfig(Yt, r);
  2052. }
  2053. onStarting() {
  2054. this._initDependencies();
  2055. }
  2056. onRendered() {
  2057. this._injector.get(Be), this._injector.get(Te), this._injector.get(Ue), this._injector.get(Ae);
  2058. }
  2059. _initDependencies() {
  2060. [
  2061. [De],
  2062. [Be],
  2063. [Te],
  2064. [Ue],
  2065. [Ae]
  2066. ].forEach((t) => this._injector.add(t));
  2067. }
  2068. }, Q(ze, "pluginName", gr), ze);
  2069. cn = mr([
  2070. on(1, ot(Ot)),
  2071. on(2, SE)
  2072. ], cn);
  2073. export {
  2074. De,
  2075. Ve,
  2076. Xe,
  2077. Ke,
  2078. le,
  2079. Ee,
  2080. vr,
  2081. Ft,
  2082. Kt,
  2083. jn,
  2084. xe,
  2085. cn
  2086. };
  2087. /*! Bundled license information:
  2088. @univerjs/drawing-ui/lib/es/index.js:
  2089. (**
  2090. * @license React
  2091. * react-jsx-runtime.production.min.js
  2092. *
  2093. * Copyright (c) Facebook, Inc. and its affiliates.
  2094. *
  2095. * This source code is licensed under the MIT license found in the
  2096. * LICENSE file in the root directory of this source tree.
  2097. *)
  2098. */
  2099. //# sourceMappingURL=chunk-AGSU7DWG.js.map