var vr = Object.defineProperty; var Sr = (i, e, n) => e in i ? vr(i, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : i[e] = n; var J = (i, e, n) => Sr(i, typeof e != "symbol" ? e + "" : e, n); import { CommandType as q, ICommandService as H, IUndoRedoService as Be, sequenceExecute as Mn, LocaleService as Pt, IUniverInstanceService as $e, useDependency as Ee, Inject as N, Injector as qe, IContextService as yn, RxDisposable as Ir, UniverInstanceType as Y, connectInjector as Cr, toDisposable as Rr, FOCUSING_COMMON_DRAWINGS as We, DrawingTypeEnum as L, Disposable as ie, ArrangeTypeEnum as st, createDocumentModelWithStyle as br, ObjectRelativeFromH as Dr, ObjectRelativeFromV as Mr, BooleanNumber as yr, PositionedObjectLayoutType as Or, WrapTextType as Tr, BuildTextUtils as Er, Range as Pr, DOCS_NORMAL_EDITOR_UNIT_ID_KEY as ot, DOCS_ZEN_EDITOR_UNIT_ID_KEY as at, InterceptorEffectEnum as Ur, ObjectMatrix as Ar, Tools as Pe, UserManagerService as Nr, IPermissionService as jr, Rectangle as Wr, Direction as _e, FOCUSING_FX_BAR_EDITOR as xr, EDITOR_ACTIVATED as Br, FOCUSING_PANEL_EDITOR as $r, LifecycleService as kr, LifecycleStages as Lr, DisposableCollection as ct, fromEventSubject as Fr, generateRandomId as Gt, DependentOn as Gr, Plugin as Vr, merge as Yr, registerDependencies as Hr, touchDependencies as Vt, IConfigService as Xr } from "@univerjs/core"; import { DocDrawingController as zr, UniverDocsDrawingPlugin as Kr } from "@univerjs/docs-drawing"; import { SetDrawingSelectedOperation as Ut, IImageIoService as On, IDrawingManagerService as ae, DRAWING_IMAGE_ALLOW_IMAGE_LIST as ln, DRAWING_IMAGE_COUNT_LIMIT as un, ImageUploadStatusType as Ae, DRAWING_IMAGE_ALLOW_SIZE as hn, getImageSize as gn, DRAWING_IMAGE_WIDTH_LIMIT as mn, DRAWING_IMAGE_HEIGHT_LIMIT as fn, getDrawingShapeKeyByDrawingSearch as Ye, UniverDrawingPlugin as Jr } from "@univerjs/drawing"; import { ImageCropperObject as Zr, COMPONENT_IMAGE_POPUP_MENU as qr, OpenImageCropOperation as Qr, ImageResetSizeOperation as ei, DrawingRenderService as Tn, DrawingCommonPanel as ti, UniverDrawingUIPlugin as ni } from "@univerjs/drawing-ui"; import { IRenderManagerService as Q, precisionTo as dt, getGroupState as ri, transformObjectOutOfGroup as ii, RENDER_CLASS_TYPE as Ne, Rect as lt, ObjectType as pn, DRAWING_OBJECT_LAYER_INDEX as Yt, SHEET_VIEWPORT_KEY as En } from "@univerjs/engine-render"; import { ISheetDrawingService as ee, SetDrawingApplyMutation as T, DrawingApplyType as E, SheetDrawingAnchorType as O, UniverSheetsDrawingPlugin as si } from "@univerjs/sheets-drawing"; import { SheetCanvasPopManagerService as oi, convertPositionSheetOverGridToAbsolute as ai, ISheetSelectionRenderService as Qe, SheetSkeletonManagerService as Z, attachRangeWithCoord as Pn, IEditorBridgeService as ci, IAutoFillService as di, HoverManagerService as li, COPY_TYPE as wn, PREDEFINED_HOOK_NAME as ut, virtualizeDiscreteRanges as ui, ISheetClipboardService as hi, SheetPrintInterceptorService as gi, getCurrentRangeDisable$ as mi, SetZoomRatioOperation as _n, SetScrollOperation as fi } from "@univerjs/sheets-ui"; import { ISidebarService as pi, IUIPartsService as wi, BuiltInUIPart as _i, ILocalFileService as vi, IMessageService as Si, MenuItemType as on, getMenuHiddenObservable as Un, RibbonStartGroup as Ii, KeyCode as xe, ComponentManager as Ci, IMenuManagerService as Ri, IShortcutService as bi, CanvasFloatDomService as Di } from "@univerjs/ui"; import { takeUntil as vn, combineLatest as ht, map as Je, filter as ve, distinctUntilChanged as gt, Subject as Ht, take as Mi, BehaviorSubject as He, switchMap as Sn } from "rxjs"; import { SheetInterceptorService as At, getSheetCommandTarget as V, SheetsSelectionsService as An, SetRangeValuesCommand as yi, SetWorksheetRowHeightMutation as Nn, SetWorksheetColWidthMutation as jn, SetWorksheetRowIsAutoHeightMutation as Oi, SetWorksheetRowAutoHeightMutation as Wn, AddWorksheetMergeMutation as Ti, RemoveWorksheetMergeMutation as Ei, AFTER_CELL_EDIT as Pi, INTERCEPTOR_POINT as Ui, InterceptCellContentPriority as Ai, WorkbookViewPermission as In, WorksheetViewPermission as Xt, WorkbookEditablePermission as qt, WorksheetEditPermission as St, InsertRowCommand as xn, InsertColCommand as Bn, RemoveRowCommand as $n, RemoveColCommand as kn, DeleteRangeMoveLeftCommand as Ln, DeleteRangeMoveUpCommand as Fn, InsertRangeMoveDownCommand as Gn, InsertRangeMoveRightCommand as Vn, DeltaRowHeightCommand as Qt, SetRowHeightCommand as en, DeltaColumnWidthCommand as Yn, SetColWidthCommand as Hn, SetRowHiddenCommand as Xn, SetSpecificRowsVisibleCommand as zn, SetSpecificColsVisibleCommand as Kn, SetColHiddenCommand as Jn, MoveColsCommand as Zn, MoveRowsCommand as qn, MoveRangeCommand as Qn, SetRowVisibleMutation as Ni, SetRowHiddenMutation as ji, SetColVisibleMutation as Wi, SetColHiddenMutation as xi, SetWorksheetActiveOperation as Bi, RangeProtectionPermissionEditPoint as $i, SetFrozenMutation as ki, COMMAND_LISTENER_SKELETON_CHANGE as Li } from "@univerjs/sheets"; import er, { useEffect as an, forwardRef as tr, useRef as Fi, createElement as nr, useState as tn } from "react"; import { docDrawingPositionToTransform as Gi, ReplaceSnapshotCommand as Vi } from "@univerjs/docs-ui"; import { MessageType as Me, RadioGroup as Yi, Radio as zt } from "@univerjs/design"; const Hi = "sheets-drawing-ui.config", Cn = {}, F = { id: "sheet.operation.clear-drawing-transformer", type: q.MUTATION, handler: (i, e) => { const n = i.get(Q); return e.forEach((t) => { var r, s; (s = (r = n.getRenderById(t)) == null ? void 0 : r.scene.getTransformer()) == null || s.debounceRefreshControls(); }), !0; } }, Nt = { id: "sheet.command.remove-sheet-image", type: q.COMMAND, handler: (i, e) => { var I, S, R; const n = i.get(H), t = i.get(Be), r = i.get(At), s = i.get(ee); if (!e) return !1; const { drawings: o } = e, c = []; o.forEach((v) => { const { unitId: C } = v; c.push(C); }); const d = s.getBatchRemoveOp(o), { unitId: g, subUnitId: a, undo: l, redo: h, objects: u } = d, m = r.onCommandExecute({ id: Nt.id, params: e }), p = { id: T.id, params: { unitId: g, subUnitId: a, op: h, objects: u, type: E.REMOVE } }, f = { id: T.id, params: { unitId: g, subUnitId: a, op: l, objects: u, type: E.INSERT } }; return Mn([...(I = m.preRedos) != null ? I : [], p, ...m.redos], n) ? (t.pushUndoRedo({ unitID: g, undoMutations: [ ...(S = m.preUndos) != null ? S : [], f, ...m.undos, { id: F.id, params: c } ], redoMutations: [ ...(R = m.preRedos) != null ? R : [], p, ...m.redos, { id: F.id, params: c } ] }), !0) : !1; } }, rr = "COMPONENT_SHEET_DRAWING_PANEL", ir = { id: "sidebar.operation.sheet-image", type: q.COMMAND, handler: async (i, e) => { const n = i.get(pi), t = i.get(Pt), r = i.get($e), s = i.get(H); if (!V(r)) return !1; switch (e.value) { case "open": n.open({ header: { title: t.t("sheetImage.panel.title") }, children: { label: rr }, onClose: () => { s.syncExecuteCommand(Ut.id, []); }, width: 360 }); break; case "close": default: n.close(); break; } return !0; } }, sr = { id: "sheet.operation.edit-sheet-image", type: q.OPERATION, handler: (i, e) => { const n = i.get(H); return e == null ? !1 : (n.syncExecuteCommand(Ut.id, [e]), n.executeCommand(ir.id, { value: "open" }), !0); } }; var Kt = { exports: {} }, Xe = {}; /** * @license React * react-jsx-runtime.production.min.js * * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ var Rn; function Xi() { if (Rn) return Xe; Rn = 1; var i = er, e = Symbol.for("react.element"), n = Symbol.for("react.fragment"), t = Object.prototype.hasOwnProperty, r = i.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, s = { key: !0, ref: !0, __self: !0, __source: !0 }; function o(c, d, g) { var a, l = {}, h = null, u = null; g !== void 0 && (h = "" + g), d.key !== void 0 && (h = "" + d.key), d.ref !== void 0 && (u = d.ref); for (a in d) t.call(d, a) && !s.hasOwnProperty(a) && (l[a] = d[a]); if (c && c.defaultProps) for (a in d = c.defaultProps, d) l[a] === void 0 && (l[a] = d[a]); return { $$typeof: e, type: c, key: h, ref: u, props: l, _owner: r.current }; } return Xe.Fragment = n, Xe.jsx = o, Xe.jsxs = o, Xe; } var bn; function zi() { return bn || (bn = 1, Kt.exports = Xi()), Kt.exports; } var G = zi(); const Ki = "univer-upload-loading", Ji = "univer-upload-loading-body", Zi = "univer-upload-loading-body-animation", qi = "univer-UniverCircleAnimation", Qi = "univer-upload-loading-body-text", mt = { uploadLoading: Ki, uploadLoadingBody: Ji, uploadLoadingBodyAnimation: Zi, univerCircleAnimation: qi, uploadLoadingBodyText: Qi }, es = () => { const i = Ee(On), e = Ee(Pt), [n, t] = er.useState(0); return an(() => { const r = i.change$.subscribe((s) => { t(s); }); return () => { r.unsubscribe(); }; }, [i]), /* @__PURE__ */ G.jsx("div", { style: { display: n > 0 ? "block" : "none" }, className: mt.uploadLoading, children: /* @__PURE__ */ G.jsxs("div", { className: mt.uploadLoadingBody, children: [ /* @__PURE__ */ G.jsx("div", { className: mt.uploadLoadingBodyAnimation }), /* @__PURE__ */ G.jsx("div", { className: mt.uploadLoadingBodyText, children: `${e.t("uploadLoading.loading")}: ${n}` }) ] }) }); }; var ts = Object.defineProperty, ns = Object.getOwnPropertyDescriptor, rs = (i, e, n, t) => { for (var r = t > 1 ? void 0 : t ? ns(e, n) : e, s = i.length - 1, o; s >= 0; s--) (o = i[s]) && (r = (t ? o(e, n, r) : o(r)) || r); return t && r && ts(e, n, r), r; }, fe = (i, e) => (n, t) => e(n, t, i); let It = class extends Ir { constructor(e, n, t, r, s, o, c, d) { super(); J(this, "_initImagePopupMenu", /* @__PURE__ */ new Set()); this._injector = e, this._drawingManagerService = n, this._canvasPopManagerService = t, this._renderManagerService = r, this._univerInstanceService = s, this._contextService = o, this._uiPartsService = c, this._commandService = d, this._init(); } _init() { this._univerInstanceService.getCurrentTypeOfUnit$(Y.UNIVER_SHEET).pipe(vn(this.dispose$)).subscribe((e) => this._create(e)), this._univerInstanceService.getTypeOfUnitDisposed$(Y.UNIVER_SHEET).pipe(vn(this.dispose$)).subscribe((e) => this._dispose(e)), this._univerInstanceService.getAllUnitsForType(Y.UNIVER_SHEET).forEach((e) => this._create(e)), this._uiPartsService.registerComponent(_i.CONTENT, () => Cr(es, this._injector)); } _dispose(e) { const n = e.getUnitId(); this._renderManagerService.removeRender(n); } _create(e) { if (!e) return; const n = e.getUnitId(); this._renderManagerService.has(n) && !this._initImagePopupMenu.has(n) && (this._popupMenuListener(n), this._initImagePopupMenu.add(n)); } _hasCropObject(e) { const n = e.getAllObjectsByOrder(); for (const t of n) if (t instanceof Zr) return !0; return !1; } _popupMenuListener(e) { var s; const n = (s = this._renderManagerService.getRenderById(e)) == null ? void 0 : s.scene; if (!n) return; const t = n.getTransformerByCreate(); if (!t) return; let r; this.disposeWithMe( Rr( t.createControl$.subscribe(() => { if (this._contextService.setContextValue(We, !0), this._hasCropObject(n)) return; const o = t.getSelectedObjectMap(); if (o.size > 1) { r == null || r.dispose(); return; } const c = o.values().next().value; if (!c) return; const d = c.oKey, g = this._drawingManagerService.getDrawingOKey(d); if (!g) return; const { unitId: a, subUnitId: l, drawingId: h, drawingType: u } = g, m = g.data; if (m && m.disablePopup) return; r == null || r.dispose(); const p = this._canvasPopManagerService.getFeatureMenu(a, l, h, u); r = this.disposeWithMe(this._canvasPopManagerService.attachPopupToObject(c, { componentKey: qr, direction: "horizontal", offset: [2, 0], extraProps: { menuItems: p || this._getImageMenuItems(a, l, h, u) } })); }) ) ), this.disposeWithMe( t.clearControl$.subscribe(() => { r == null || r.dispose(), this._contextService.setContextValue(We, !1), this._commandService.syncExecuteCommand(Ut.id, []); }) ), this.disposeWithMe( this._contextService.contextChanged$.subscribe((o) => { o[We] === !1 && (r == null || r.dispose()); }) ), this.disposeWithMe( t.changing$.subscribe(() => { r == null || r.dispose(); }) ); } _getImageMenuItems(e, n, t, r) { return [ { label: "image-popup.edit", index: 0, commandId: sr.id, commandParams: { unitId: e, subUnitId: n, drawingId: t }, disable: r === L.DRAWING_DOM }, { label: "image-popup.delete", index: 1, commandId: Nt.id, commandParams: { unitId: e, drawings: [{ unitId: e, subUnitId: n, drawingId: t }] }, disable: !1 }, { label: "image-popup.crop", index: 2, commandId: Qr.id, commandParams: { unitId: e, subUnitId: n, drawingId: t }, disable: r === L.DRAWING_DOM }, { label: "image-popup.reset", index: 3, commandId: ei.id, commandParams: [{ unitId: e, subUnitId: n, drawingId: t }], disable: r === L.DRAWING_DOM } ]; } }; It = rs([ fe(0, N(qe)), fe(1, ae), fe(2, N(oi)), fe(3, Q), fe(4, $e), fe(5, yn), fe(6, N(wi)), fe(7, H) ], It); function z(i, e, n) { const { from: t, to: r, flipY: s = !1, flipX: o = !1, angle: c = 0, skewX: d = 0, skewY: g = 0 } = i, a = n.getCurrent(); if (a == null) return; const l = ai( a.unitId, a.sheetId, { from: t, to: r }, n ); let { left: h, top: u, width: m, height: p } = l; const f = n.getCurrentSkeleton(), w = f.rowHeaderWidth + f.columnTotalWidth, I = f.columnHeaderHeight + f.rowTotalHeight; return h + m > w && (h = w - m), u + p > I && (u = I - p), { flipY: s, flipX: o, angle: c, skewX: d, skewY: g, left: h, top: u, width: m, height: p }; } function k(i, e) { const { left: n = 0, top: t = 0, width: r = 0, height: s = 0, flipY: o = !1, flipX: c = !1, angle: d = 0, skewX: g = 0, skewY: a = 0 } = i, l = e.getCellWithCoordByOffset(n, t); if (l == null) return; const h = { column: l.actualColumn, columnOffset: dt(n - l.startX, 1), row: l.actualRow, rowOffset: dt(t - l.startY, 1) }, u = e.getCellWithCoordByOffset(n + r, t + s); if (u == null) return; const m = { column: u.actualColumn, columnOffset: dt(n + r - u.startX, 1), row: u.actualRow, rowOffset: dt(t + s - u.startY, 1) }; return { flipY: o, flipX: c, angle: d, skewX: g, skewY: a, from: h, to: m }; } var is = Object.defineProperty, ss = Object.getOwnPropertyDescriptor, os = (i, e, n, t) => { for (var r = t > 1 ? void 0 : t ? ss(e, n) : e, s = i.length - 1, o; s >= 0; s--) (o = i[s]) && (r = (t ? o(e, n, r) : o(r)) || r); return t && r && is(e, n, r), r; }, ft = (i, e) => (n, t) => e(n, t, i); let nn = class extends ie { constructor(i, e, n, t, r) { super(), this._context = i, this._sheetDrawingService = e, this._drawingManagerService = n, this._sheetSelectionRenderService = t, this._sheetSkeletonManagerService = r, this._init(); } _init() { this._drawingInitializeListener(); } _drawingInitializeListener() { this._sheetDrawingService.initializeNotification(this._context.unitId); const i = this._sheetDrawingService.getDrawingDataForUnit(this._context.unitId); for (const e in i) { const n = i[e]; for (const t in n.data) { const r = n.data[t]; r.transform = z(r.sheetTransform, this._sheetSelectionRenderService, this._sheetSkeletonManagerService); } } this._drawingManagerService.registerDrawingData(this._context.unitId, this._sheetDrawingService.getDrawingDataForUnit(this._context.unitId)), this._drawingManagerService.initializeNotification(this._context.unitId); } }; nn = os([ ft(1, ee), ft(2, ae), ft(3, N(Qe)), ft(4, N(Z)) ], nn); function as(i) { const e = []; return i.forEach((n) => { const { parent: t, children: r } = n, { unitId: s, subUnitId: o, drawingId: c } = t, d = ri(0, 0, r.map((l) => l.transform || {})), g = r.map((l) => { const h = l.transform || { left: 0, top: 0 }, { unitId: u, subUnitId: m, drawingId: p } = l; return { unitId: u, subUnitId: m, drawingId: p, transform: { ...h, left: h.left - d.left, top: h.top - d.top }, groupId: c }; }), a = { unitId: s, subUnitId: o, drawingId: c, drawingType: L.DRAWING_GROUP, transform: d }; e.push({ parent: a, children: g }); }), e; } function cs(i) { const e = []; return i.forEach((n) => { const { parent: t, children: r } = n, { unitId: s, subUnitId: o, drawingId: c, transform: d = { width: 0, height: 0 } } = t; if (d == null) return; const g = r.map((l) => { const { transform: h } = l, { unitId: u, subUnitId: m, drawingId: p } = l, f = ii(h || {}, d, d.width || 0, d.height || 0); return { unitId: u, subUnitId: m, drawingId: p, transform: f, groupId: void 0 }; }), a = { unitId: s, subUnitId: o, drawingId: c, drawingType: L.DRAWING_GROUP, transform: { left: 0, top: 0 } }; e.push({ parent: a, children: g }); }), e; } const or = { id: "sheet.command.group-sheet-image", type: q.COMMAND, handler: (i, e) => { const n = i.get(H), t = i.get(Be), r = i.get(ee); if (!e) return !1; const s = []; e.forEach(({ parent: u, children: m }) => { s.push(u.unitId), m.forEach((p) => { s.push(p.unitId); }); }); const o = r.getGroupDrawingOp(e), { unitId: c, subUnitId: d, undo: g, redo: a, objects: l } = o; return n.syncExecuteCommand(T.id, { op: a, unitId: c, subUnitId: d, objects: l, type: E.GROUP }) ? (t.pushUndoRedo({ unitID: c, undoMutations: [ { id: T.id, params: { op: g, unitId: c, subUnitId: d, objects: cs(l), type: E.UNGROUP } }, { id: F.id, params: s } ], redoMutations: [ { id: T.id, params: { op: a, unitId: c, subUnitId: d, objects: l, type: E.GROUP } }, { id: F.id, params: s } ] }), !0) : !1; } }, jt = { id: "sheet.command.insert-sheet-image", type: q.COMMAND, handler: (i, e) => { var I, S, R; const n = i.get(H), t = i.get(Be), r = i.get(ee), s = i.get(At); if (!e) return !1; const o = e.drawings, c = o.map((v) => v.unitId), d = r.getBatchAddOp(o), { unitId: g, subUnitId: a, undo: l, redo: h, objects: u } = d, m = s.onCommandExecute({ id: jt.id, params: e }), p = { id: T.id, params: { op: h, unitId: g, subUnitId: a, objects: u, type: E.INSERT } }, f = { id: T.id, params: { op: l, unitId: g, subUnitId: a, objects: u, type: E.REMOVE } }; return Mn([...(I = m.preRedos) != null ? I : [], p, ...m.redos], n) ? (t.pushUndoRedo({ unitID: g, undoMutations: [ ...(S = m.preUndos) != null ? S : [], f, ...m.undos, { id: F.id, params: c } ], redoMutations: [ ...(R = m.preRedos) != null ? R : [], p, ...m.redos, { id: F.id, params: c } ] }), !0) : !1; } }, ar = { id: "sheet.command.set-drawing-arrange", type: q.COMMAND, handler: (i, e) => { const n = i.get(H), t = i.get(Be); if (!e) return !1; const r = i.get(ee), { unitId: s, subUnitId: o, drawingIds: c, arrangeType: d } = e, g = { unitId: s, subUnitId: o, drawingIds: c }; let a; if (d === st.forward ? a = r.getForwardDrawingsOp(g) : d === st.backward ? a = r.getBackwardDrawingOp(g) : d === st.front ? a = r.getFrontDrawingsOp(g) : d === st.back && (a = r.getBackDrawingsOp(g)), a == null) return !1; const { objects: l, redo: h, undo: u } = a; return n.syncExecuteCommand(T.id, { op: h, unitId: s, subUnitId: o, objects: l, type: E.ARRANGE }) ? (t.pushUndoRedo({ unitID: s, undoMutations: [ { id: T.id, params: { op: u, unitId: s, subUnitId: o, objects: l, type: E.ARRANGE } } ], redoMutations: [ { id: T.id, params: { op: h, unitId: s, subUnitId: o, objects: l, type: E.ARRANGE } } ] }), !0) : !1; } }, Wt = { id: "sheet.command.set-sheet-image", type: q.COMMAND, handler: (i, e) => { const n = i.get(H), t = i.get(Be), r = i.get(ee); if (!e) return !1; const { drawings: s } = e, o = r.getBatchUpdateOp(s), { unitId: c, subUnitId: d, undo: g, redo: a, objects: l } = o; return n.syncExecuteCommand(T.id, { unitId: c, subUnitId: d, op: a, objects: l, type: E.UPDATE }) ? (t.pushUndoRedo({ unitID: c, undoMutations: [ { id: T.id, params: { unitId: c, subUnitId: d, op: g, objects: l, type: E.UPDATE } }, { id: F.id, params: [c] } ], redoMutations: [ { id: T.id, params: { unitId: c, subUnitId: d, op: a, objects: l, type: E.UPDATE } }, { id: F.id, params: [c] } ] }), !0) : !1; } }, cr = { id: "sheet.command.ungroup-sheet-image", type: q.COMMAND, handler: (i, e) => { const n = i.get(H), t = i.get(Be), r = i.get(ee); if (!e) return !1; const s = []; e.forEach(({ parent: u, children: m }) => { s.push(u.unitId), m.forEach((p) => { s.push(p.unitId); }); }); const o = r.getUngroupDrawingOp(e), { unitId: c, subUnitId: d, undo: g, redo: a, objects: l } = o; return n.syncExecuteCommand(T.id, { op: a, unitId: c, subUnitId: d, objects: l, type: E.UNGROUP }) ? (t.pushUndoRedo({ unitID: c, undoMutations: [ { id: T.id, params: { op: g, unitId: c, subUnitId: d, objects: as(l), type: E.GROUP } }, { id: F.id, params: s } ], redoMutations: [ { id: T.id, params: { op: a, unitId: c, subUnitId: d, objects: l, type: E.UNGROUP } }, { id: F.id, params: s } ] }), !0) : !1; } }; var ds = Object.defineProperty, ls = Object.getOwnPropertyDescriptor, us = (i, e, n, t) => { for (var r = t > 1 ? void 0 : t ? ls(e, n) : e, s = i.length - 1, o; s >= 0; s--) (o = i[s]) && (r = (t ? o(e, n, r) : o(r)) || r); return t && r && ds(e, n, r), r; }, te = (i, e) => (n, t) => e(n, t, i); function hs(i, e, n) { const t = n * Math.PI / 180, r = Math.abs(i * Math.cos(t)) + Math.abs(e * Math.sin(t)), s = Math.abs(i * Math.sin(t)) + Math.abs(e * Math.cos(t)); return { rotatedWidth: r, rotatedHeight: s }; } function dr(i, e, n, t, r) { var I; const { rotatedHeight: s, rotatedWidth: o } = hs(n, t, r), d = i.get(Q).getRenderById(e.unitId); if (!d) return !1; const a = (I = d.with(Z).getWorksheetSkeleton(e.subUnitId)) == null ? void 0 : I.skeleton; if (a == null) return !1; const l = a.getCellByIndex(e.row, e.col), h = l.mergeInfo.endX - l.mergeInfo.startX - 2, u = l.mergeInfo.endY - l.mergeInfo.startY - 2, m = o / s, f = Math.ceil(Math.min(h, u * m)) / o, w = !f || Number.isNaN(f) ? 1e-3 : f; return { width: n * w, height: t * w }; } let Ze = class extends ie { constructor(e, n, t, r, s, o, c, d, g, a, l, h, u) { super(); J(this, "_workbookSelections"); this._context = e, this._skeletonManagerService = n, this._commandService = t, this._selectionRenderService = r, this._imageIoService = s, this._fileOpenerService = o, this._sheetDrawingService = c, this._drawingManagerService = d, this._contextService = g, this._messageService = a, this._localeService = l, this._injector = u, this._workbookSelections = h.getWorkbookSelections(this._context.unitId), this._updateImageListener(), this._updateOrderListener(), this._groupDrawingListener(), this._focusDrawingListener(); } async insertFloatImage() { const e = await this._fileOpenerService.openFile({ multiple: !0, accept: ln.map((t) => `.${t.replace("image/", "")}`).join(",") }), n = e.length; return n > un ? (this._messageService.show({ type: Me.Error, content: this._localeService.t("update-status.exceedMaxCount", String(un)) }), !1) : n === 0 ? !1 : (e.forEach(async (t) => await this._insertFloatImage(t)), !0); } async insertCellImage() { const n = (await this._fileOpenerService.openFile({ multiple: !1, accept: ln.map((t) => `.${t.replace("image/", "")}`).join(",") }))[0]; return n ? (await this._insertCellImage(n), !0) : !1; } async _insertFloatImage(e) { let n; try { n = await this._imageIoService.saveImage(e); } catch (I) { const S = I.message; S === Ae.ERROR_EXCEED_SIZE ? this._messageService.show({ type: Me.Error, content: this._localeService.t("update-status.exceedMaxSize", String(hn / (1024 * 1024))) }) : S === Ae.ERROR_IMAGE_TYPE ? this._messageService.show({ type: Me.Error, content: this._localeService.t("update-status.invalidImageType") }) : S === Ae.ERROR_IMAGE && this._messageService.show({ type: Me.Error, content: this._localeService.t("update-status.invalidImage") }); } if (n == null) return; const t = this._getUnitInfo(), { unitId: r, subUnitId: s } = t, { imageId: o, imageSourceType: c, source: d, base64Cache: g } = n, { width: a, height: l, image: h } = await gn(g || ""), { width: u, height: m } = this._context.scene; this._imageIoService.addImageSourceCache(d, c, h); let p = 1; if (a > mn || l > fn) { const I = mn / a, S = fn / l; p = Math.max(I, S); } const f = this._getImagePosition(a * p, l * p, u, m); if (f == null) return; const w = { unitId: r, subUnitId: s, drawingId: o, drawingType: L.DRAWING_IMAGE, imageSourceType: c, source: d, transform: z(f, this._selectionRenderService, this._skeletonManagerService), sheetTransform: f }; this._commandService.executeCommand(jt.id, { unitId: r, drawings: [w] }); } // eslint-disable-next-line max-lines-per-function async _insertCellImage(e) { let n; try { n = await this._imageIoService.saveImage(e); } catch (f) { const w = f.message; w === Ae.ERROR_EXCEED_SIZE ? this._messageService.show({ type: Me.Error, content: this._localeService.t("update-status.exceedMaxSize", String(hn / (1024 * 1024))) }) : w === Ae.ERROR_IMAGE_TYPE ? this._messageService.show({ type: Me.Error, content: this._localeService.t("update-status.invalidImageType") }) : w === Ae.ERROR_IMAGE && this._messageService.show({ type: Me.Error, content: this._localeService.t("update-status.invalidImage") }); } if (n == null) return; const { imageId: t, imageSourceType: r, source: s, base64Cache: o } = n, { width: c, height: d, image: g } = await gn(o || ""); this._imageIoService.addImageSourceCache(s, r, g); const a = this._workbookSelections.getCurrentLastSelection(); if (!a) return !1; const l = br("", {}), h = dr( this._injector, { unitId: this._context.unitId, subUnitId: this._context.unit.getActiveSheet().getSheetId(), row: a.primary.actualRow, col: a.primary.actualColumn }, c, d, 0 ); if (!h) return !1; const u = { size: { width: h.width, height: h.height }, positionH: { relativeFrom: Dr.PAGE, posOffset: 0 }, positionV: { relativeFrom: Mr.PARAGRAPH, posOffset: 0 }, angle: 0 }, m = { unitId: l.getUnitId(), subUnitId: l.getUnitId(), drawingId: t, drawingType: L.DRAWING_IMAGE, imageSourceType: r, source: s, transform: Gi(u), docTransform: u, behindDoc: yr.FALSE, title: "", description: "", layoutType: Or.INLINE, // Insert inline drawing by default. wrapText: Tr.BOTH_SIDES, distB: 0, distL: 0, distR: 0, distT: 0 }, p = Er.drawing.add({ documentDataModel: l, drawings: [m], selection: { collapsed: !0, startOffset: 0, endOffset: 0 } }); return p ? (l.apply(p), this._commandService.syncExecuteCommand(yi.id, { value: { [a.primary.actualRow]: { [a.primary.actualColumn]: { p: l.getSnapshot(), t: 1 } } } })) : !1; } _getUnitInfo() { const e = this._context.unit, n = e.getActiveSheet(), t = e.getUnitId(), r = n.getSheetId(); return { unitId: t, subUnitId: r }; } _getImagePosition(e, n, t, r) { const s = this._workbookSelections.getCurrentSelections(); let o = { startRow: 0, endRow: 0, startColumn: 0, endColumn: 0 }; s && s.length > 0 && (o = s[s.length - 1].range); const c = Pn(this._skeletonManagerService.getCurrent().skeleton, o); if (c == null) return; let { startColumn: d, startRow: g, startX: a, startY: l } = c, h = !1; if (a + e > t && (a = t - e, a < 0 && (a = 0, e = t), h = !0), l + n > r && (l = r - n, l < 0 && (l = 0, n = r), h = !0), h) { const f = this._selectionRenderService.getCellWithCoordByOffset(a, l); if (f == null) return; a = f.startX, l = f.startY, d = f.actualColumn, g = f.actualRow; } const u = { column: d, columnOffset: 0, row: g, rowOffset: 0 }, m = this._selectionRenderService.getCellWithCoordByOffset(a + e, l + n); if (m == null) return; const p = { column: m.actualColumn, columnOffset: a + e - m.startX, row: m.actualRow, rowOffset: l + n - m.startY }; return { from: u, to: p }; } _updateOrderListener() { this.disposeWithMe(this._drawingManagerService.featurePluginOrderUpdate$.subscribe((e) => { const { unitId: n, subUnitId: t, drawingIds: r, arrangeType: s } = e; this._commandService.executeCommand(ar.id, { unitId: n, subUnitId: t, drawingIds: r, arrangeType: s }); })); } _updateImageListener() { this.disposeWithMe(this._drawingManagerService.featurePluginUpdate$.subscribe((e) => { const n = []; e.length !== 0 && (e.forEach((t) => { const { unitId: r, subUnitId: s, drawingId: o, drawingType: c, transform: d } = t; if (d == null) return; const g = this._sheetDrawingService.getDrawingByParam({ unitId: r, subUnitId: s, drawingId: o }); if (g == null || g.unitId !== this._context.unitId) return; const a = k({ ...g.transform, ...d }, this._selectionRenderService); if (a == null) return; const l = { ...t, transform: { ...g.transform, ...d, ...z(a, this._selectionRenderService, this._skeletonManagerService) }, sheetTransform: { ...a } }; n.push(l); }), n.length > 0 && this._commandService.executeCommand(Wt.id, { unitId: e[0].unitId, drawings: n })); })); } _groupDrawingListener() { this.disposeWithMe(this._drawingManagerService.featurePluginGroupUpdate$.subscribe((e) => { this._commandService.executeCommand(or.id, e); const { unitId: n, subUnitId: t, drawingId: r } = e[0].parent; this._commandService.syncExecuteCommand(Ut.id, [{ unitId: n, subUnitId: t, drawingId: r }]); })), this.disposeWithMe(this._drawingManagerService.featurePluginUngroupUpdate$.subscribe((e) => { this._commandService.executeCommand(cr.id, e); })); } _focusDrawingListener() { this.disposeWithMe( this._drawingManagerService.focus$.subscribe((e) => { e == null || e.length === 0 ? (this._contextService.setContextValue(We, !1), this._sheetDrawingService.focusDrawing([])) : (this._contextService.setContextValue(We, !0), this._sheetDrawingService.focusDrawing(e)); }) ); } }; Ze = us([ te(1, N(Z)), te(2, H), te(3, Qe), te(4, On), te(5, vi), te(6, ee), te(7, ae), te(8, yn), te(9, Si), te(10, N(Pt)), te(11, N(An)), te(12, N(qe)) ], Ze); var gs = Object.defineProperty, ms = Object.getOwnPropertyDescriptor, fs = (i, e, n, t) => { for (var r = t > 1 ? void 0 : t ? ms(e, n) : e, s = i.length - 1, o; s >= 0; s--) (o = i[s]) && (r = (t ? o(e, n, r) : o(r)) || r); return t && r && gs(e, n, r), r; }, ye = (i, e) => (n, t) => e(n, t, i); function rn(i, e, n) { var t, r, s, o; if (((r = (t = n == null ? void 0 : n.p) == null ? void 0 : t.body) == null ? void 0 : r.dataStream.length) === 3 && ((o = (s = n.p) == null ? void 0 : s.drawingsOrder) == null ? void 0 : o.length) === 1) { const c = n.p.drawings[n.p.drawingsOrder[0]], d = dr( i, { unitId: e.unitId, subUnitId: e.subUnitId, row: e.row, col: e.col }, c.docTransform.size.width, c.docTransform.size.height, c.docTransform.angle ); if (d) return c.transform.width = d.width, c.transform.height = d.height, c.docTransform.size.width = d.width, c.docTransform.size.height = d.height, c.transform.left = 0, c.transform.top = 0, c.docTransform.positionH.posOffset = 0, c.docTransform.positionV.posOffset = 0, n.p.documentStyle.pageSize.width = 1 / 0, n.p.documentStyle.pageSize.height = 1 / 0, !0; } return !1; } let Ct = class extends ie { constructor(i, e, n, t, r, s, o) { super(), this._commandService = i, this._sheetInterceptorService = e, this._univerInstanceService = n, this._injector = t, this._drawingManagerService = r, this._docDrawingController = s, this._editorBridgeService = o, this._initHandleResize(), this._handleInitEditor(), this._handleWriteCell(), this._initCellContentInterceptor(); } _initHandleResize() { this.disposeWithMe(this._commandService.onCommandExecuted((i) => { let e, n = []; if (i.id === Nn.id) { const t = i.params; n = t.ranges, e = V(this._univerInstanceService, { unitId: t.unitId, subUnitId: t.subUnitId }); } else if (i.id === jn.id) { const t = i.params; n = t.ranges, e = V(this._univerInstanceService, { unitId: t.unitId, subUnitId: t.subUnitId }); } else if (i.id === Oi.id) { const t = i.params; n = t.ranges, e = V(this._univerInstanceService, { unitId: t.unitId, subUnitId: t.subUnitId }); } else if (i.id === Wn.id) { const t = i.params; e = V(this._univerInstanceService, { unitId: t.unitId, subUnitId: t.subUnitId }), n = t.rowsAutoHeightInfo.map((r) => ({ startRow: r.row, endRow: r.row, startColumn: 0, endColumn: 9999 })); } else if (i.id === Ti.id) { const t = i.params; n = t.ranges, e = V(this._univerInstanceService, { unitId: t.unitId, subUnitId: t.subUnitId }); } else if (i.id === Ei.id) { const t = i.params; n = t.ranges, e = V(this._univerInstanceService, { unitId: t.unitId, subUnitId: t.subUnitId }); } e && n.length && n.forEach((t) => { const r = Pr.transformRange(t, e.worksheet); for (let s = r.startRow; s <= r.endRow; s++) for (let o = r.startColumn; o <= r.endColumn; o++) rn(this._injector, { unitId: e.unitId, subUnitId: e.subUnitId, row: s, col: o }, e.worksheet.getCellRaw(s, o)); }); })); } _handleInitEditor() { this.disposeWithMe(this._editorBridgeService.visible$.subscribe((i) => { i.visible ? i.visible && (this._drawingManagerService.removeDrawingDataForUnit(ot), this._docDrawingController.loadDrawingDataForUnit(ot), this._drawingManagerService.initializeNotification(ot)) : this._drawingManagerService.removeDrawingDataForUnit(ot); })), this.disposeWithMe(this._commandService.onCommandExecuted((i) => { i.id === Vi.id && i.params.unitId === at && (this._drawingManagerService.removeDrawingDataForUnit(at), this._docDrawingController.loadDrawingDataForUnit(at), this._drawingManagerService.initializeNotification(at)); })); } _handleWriteCell() { this.disposeWithMe(this._sheetInterceptorService.writeCellInterceptor.intercept(Pi, { priority: 9999, handler: (i, e, n) => (rn(this._injector, { unitId: e.unitId, subUnitId: e.subUnitId, row: e.row, col: e.col }, i), n(i)) })); } _initCellContentInterceptor() { this.disposeWithMe( this._sheetInterceptorService.intercept( Ui.CELL_CONTENT, { effect: Ur.Style, priority: Ai.CELL_IMAGE, handler: (i, e, n) => { var t; return i != null && i.p && ((t = i.p.drawingsOrder) != null && t.length) && (i.interceptorStyle || (i.interceptorStyle = {}), i.interceptorStyle.tr = { a: 0 }), n(i); } } ) ); } }; Ct = fs([ ye(0, H), ye(1, N(At)), ye(2, $e), ye(3, N(qe)), ye(4, ae), ye(5, N(zr)), ye(6, N(ci)) ], Ct); var ps = Object.defineProperty, ws = Object.getOwnPropertyDescriptor, _s = (i, e, n, t) => { for (var r = t > 1 ? void 0 : t ? ws(e, n) : e, s = i.length - 1, o; s >= 0; s--) (o = i[s]) && (r = (t ? o(e, n, r) : o(r)) || r); return t && r && ps(e, n, r), r; }, Dn = (i, e) => (n, t) => e(n, t, i); let Rt = class extends ie { constructor(i, e) { super(), this._autoFillService = i, this._injector = e, this._initAutoFillHooks(); } _initAutoFillHooks() { this.disposeWithMe( this._autoFillService.addHook({ id: "sheet-cell-image-autofill", onBeforeSubmit: (i, e, n, t) => { new Ar(t).forValue((r, s, o) => { rn(this._injector, { unitId: i.unitId, subUnitId: i.subUnitId, row: r, col: s }, o); }); } }) ); } }; Rt = _s([ Dn(0, N(di)), Dn(1, N(qe)) ], Rt); var vs = Object.defineProperty, Ss = Object.getOwnPropertyDescriptor, Is = (i, e, n, t) => { for (var r = t > 1 ? void 0 : t ? Ss(e, n) : e, s = i.length - 1, o; s >= 0; s--) (o = i[s]) && (r = (t ? o(e, n, r) : o(r)) || r); return t && r && vs(e, n, r), r; }, pt = (i, e) => (n, t) => e(n, t, i); let bt = class extends ie { constructor(e, n, t, r) { super(); J(this, "_isSetCursor", !1); this._hoverManagerService = e, this._renderManagerService = n, this._selectionsService = t, this._drawingRenderService = r; } _initHover() { } _initImageClick() { } }; bt = Is([ pt(0, N(li)), pt(1, N(Q)), pt(2, N(An)), pt(3, N(Tn)) ], bt); var Cs = Object.defineProperty, Rs = Object.getOwnPropertyDescriptor, bs = (i, e, n, t) => { for (var r = t > 1 ? void 0 : t ? Rs(e, n) : e, s = i.length - 1, o; s >= 0; s--) (o = i[s]) && (r = (t ? o(e, n, r) : o(r)) || r); return t && r && Cs(e, n, r), r; }, Jt = (i, e) => (n, t) => e(n, t, i); let Dt = class extends ie { constructor(e, n, t) { super(); J(this, "_copyInfo"); this._sheetClipboardService = e, this._renderManagerService = n, this._sheetDrawingService = t, this._initCopyPaste(); } _initCopyPaste() { this._sheetClipboardService.addClipboardHook({ id: "SHEET_IMAGE_UI_PLUGIN", onBeforeCopy: (e, n, t) => this._collect(e, n, t), onPasteCells: (e, n, t, r) => { const { copyType: s = wn.COPY, pasteType: o } = r, { range: c } = e || {}, { range: d, unitId: g, subUnitId: a } = n; return this._generateMutations(d, { copyType: s, pasteType: o, copyRange: c, unitId: g, subUnitId: a }); }, onPastePlainText: (e, n) => ({ undos: [], redos: [] }) }); } _collect(e, n, t) { var h; const r = (h = this._renderManagerService.getRenderById(e)) == null ? void 0 : h.with(Z); if (!r) return; const s = r.attachRangeWithCoord(t); if (!s) return; const { startX: o, endX: c, startY: d, endY: g } = s, a = this._sheetDrawingService.getDrawingData(e, n), l = []; Object.keys(a).forEach((u) => { const m = a[u], { transform: p } = m; if (m.anchorType !== O.Both || !p) return; const { left: f = 0, top: w = 0, width: I = 0, height: S = 0 } = p, { drawingStartX: R, drawingEndX: v, drawingStartY: C, drawingEndY: _ } = { drawingStartX: f, drawingEndX: f + I, drawingStartY: w, drawingEndY: w + S }; o <= R && v <= c && d <= C && _ <= g && l.push(m); }), l.length && (this._copyInfo = { drawings: l, unitId: e, subUnitId: n }); } // eslint-disable-next-line max-lines-per-function _generateMutations(e, n) { var x; if (!this._copyInfo) return { redos: [], undos: [] }; if ([ ut.SPECIAL_PASTE_COL_WIDTH, ut.SPECIAL_PASTE_VALUE, ut.SPECIAL_PASTE_FORMAT, ut.SPECIAL_PASTE_FORMULA ].includes(n.pasteType)) return { redos: [], undos: [] }; const { copyRange: r } = n; if (!r) return { redos: [], undos: [] }; const { drawings: s, unitId: o, subUnitId: c } = this._copyInfo, { ranges: [d, g], mapFunc: a } = ui([r, e]), { row: l, col: h } = a(d.startRow, d.startColumn), { row: u, col: m } = a(g.startRow, g.startColumn), p = (x = this._renderManagerService.getRenderById(o)) == null ? void 0 : x.with(Z); if (!p) return { redos: [], undos: [] }; const f = p.attachRangeWithCoord({ startRow: l, endRow: l, startColumn: h, endColumn: h }), w = p.attachRangeWithCoord({ startRow: u, endRow: u, startColumn: m, endColumn: m }); if (!f || !w) return { redos: [], undos: [] }; const I = [], S = [], R = w.startX - f.startX, v = w.startY - f.startY, C = u - l, _ = m - h, y = n.copyType === wn.CUT, { _sheetDrawingService: M } = this; return s.forEach((U) => { const { transform: D, sheetTransform: b } = U; if (!D) return; const P = { ...U, unitId: o, subUnitId: c, drawingId: y ? U.drawingId : Pe.generateRandomId(), transform: { ...D, left: D.left + R, top: D.top + v }, sheetTransform: { to: { ...b.to, row: b.to.row + C, column: b.to.column + _ }, from: { ...b.from, row: b.from.row + C, column: b.from.column + _ } } }; if (y) { const { undo: A, redo: j, objects: B } = M.getBatchUpdateOp([P]); I.push({ id: T.id, params: { unitId: o, subUnitId: c, type: E.UPDATE, op: j, objects: B } }), S.push({ id: T.id, params: { unitId: o, subUnitId: c, type: E.UPDATE, op: A, objects: B } }); } else { const { undo: A, redo: j, objects: B } = M.getBatchAddOp([P]); I.push({ id: T.id, params: { op: j, unitId: o, subUnitId: c, objects: B, type: E.INSERT } }), S.push({ id: T.id, params: { op: A, unitId: o, subUnitId: c, objects: B, type: E.REMOVE } }); } }), { redos: I, undos: S }; } }; Dt = bs([ Jt(0, hi), Jt(1, Q), Jt(2, ee) ], Dt); var Ds = Object.defineProperty, Ms = Object.getOwnPropertyDescriptor, ys = (i, e, n, t) => { for (var r = t > 1 ? void 0 : t ? Ms(e, n) : e, s = i.length - 1, o; s >= 0; s--) (o = i[s]) && (r = (t ? o(e, n, r) : o(r)) || r); return t && r && Ds(e, n, r), r; }, ze = (i, e) => (n, t) => e(n, t, i); let Mt = class extends ie { constructor(i, e, n, t, r) { super(), this._drawingManagerService = i, this._renderManagerService = e, this._permissionService = n, this._univerInstanceService = t, this._userManagerService = r, this._initDrawingVisible(), this._initDrawingEditable(), this._initViewPermissionChange(), this._initEditPermissionChange(); } _initDrawingVisible() { const i = this._univerInstanceService.getCurrentTypeOfUnit$(Y.UNIVER_SHEET); this.disposeWithMe( ht([i, this._userManagerService.currentUser$]).subscribe(([e, n]) => { if (!e) { this._drawingManagerService.setDrawingVisible(!1); return; } e.activeSheet$.subscribe((t) => { if (!t) { this._drawingManagerService.setDrawingVisible(!1); return; } const r = e.getUnitId(), s = t.getSheetId(); if (this._permissionService.composePermission([new In(r).id, new Xt(r, s).id]).every((c) => c.value)) this._drawingManagerService.setDrawingVisible(!0); else { this._drawingManagerService.setDrawingVisible(!1); const c = e.getUnitId(), d = t.getSheetId(), g = this._drawingManagerService.getDrawingData(c, d), a = Object.values(g), l = this._renderManagerService.getRenderById(c), h = l == null ? void 0 : l.scene; if (h == null) return; h.getAllObjectsByOrder().forEach((m) => { m.classType === Ne.IMAGE && a.some((p) => m.oKey.includes(p.drawingId)) && h.removeObject(m); }); } }); }) ); } _initDrawingEditable() { const i = this._univerInstanceService.getCurrentTypeOfUnit$(Y.UNIVER_SHEET); this.disposeWithMe( ht([i, this._userManagerService.currentUser$]).subscribe(([e, n]) => { if (!e) { this._drawingManagerService.setDrawingEditable(!1); return; } e.activeSheet$.subscribe((t) => { if (!t) { this._drawingManagerService.setDrawingEditable(!1); return; } const r = e.getUnitId(), s = t.getSheetId(); if (this._permissionService.composePermission([new qt(r).id, new St(r, s).id]).every((c) => c.value)) this._drawingManagerService.setDrawingEditable(!0); else { this._drawingManagerService.setDrawingEditable(!1); const c = e.getUnitId(), d = t.getSheetId(), g = this._drawingManagerService.getDrawingData(c, d), a = Object.values(g), l = this._renderManagerService.getRenderById(c), h = l == null ? void 0 : l.scene; if (h == null) return; h.getAllObjectsByOrder().forEach((m) => { m.classType === Ne.IMAGE && a.some((p) => m.oKey.includes(p.drawingId)) && h.detachTransformerFrom(m); }); } }); }) ); } _initViewPermissionChange() { const i = this._univerInstanceService.getCurrentTypeOfUnit$(Y.UNIVER_SHEET); this.disposeWithMe( ht([i, this._userManagerService.currentUser$]).subscribe(([e, n]) => { e && e.activeSheet$.subscribe((t) => { var l; if (!t) return; const r = e.getUnitId(), s = t.getSheetId(); let o = !0; const c = this._renderManagerService.getRenderById(r), d = c == null ? void 0 : c.scene; if (d == null) return; const g = d.getTransformerByCreate(), a = this._permissionService.composePermission$([new In(r).id, new Xt(r, s).id]).pipe(Je((h) => h.every((u) => u.value))); a == null || a.pipe( ve((h) => h !== o), gt() ).subscribe({ next: (h) => { o = h, this._drawingManagerService.setDrawingVisible(h); const u = d.getAllObjectsByOrder(), m = this._drawingManagerService.getDrawingData(r, s), p = Object.values(m); h ? this._drawingManagerService.addNotification(p) : (u.forEach((f) => { f.classType === Ne.IMAGE && p.some((w) => f.oKey.includes(w.drawingId)) && d.removeObject(f); }), g.clearSelectedObjects()); } }), (l = this._permissionService.getPermissionPoint$(new Xt(r, s).id)) == null || l.pipe( ve((h) => h.value !== o), gt() ).subscribe({ complete: () => { o = !0, this._drawingManagerService.setDrawingVisible(!0); const h = this._drawingManagerService.getDrawingData(r, s), u = Object.values(h); this._drawingManagerService.addNotification(u); } }); }); }) ); } _initEditPermissionChange() { const i = this._univerInstanceService.getCurrentTypeOfUnit$(Y.UNIVER_SHEET); this.disposeWithMe( ht([i, this._userManagerService.currentUser$]).subscribe(([e, n]) => { e && e.activeSheet$.subscribe((t) => { var l; if (!t) return; const r = e.getUnitId(), s = t.getSheetId(); let o = !0; const c = this._renderManagerService.getRenderById(r), d = c == null ? void 0 : c.scene; if (d == null) return; const g = d.getTransformerByCreate(), a = this._permissionService.composePermission$([new qt(r).id, new St(r, s).id]).pipe(Je((h) => h.every((u) => u.value))); a == null || a.pipe( ve((h) => h !== o), gt() ).subscribe({ next: (h) => { o = h, this._drawingManagerService.setDrawingEditable(h); const u = d.getAllObjectsByOrder(), m = this._drawingManagerService.getDrawingData(r, s), p = Object.values(m); h ? (u.forEach((f) => { f.classType === Ne.IMAGE && p.some((w) => f.oKey.includes(w.drawingId)) && d.attachTransformerTo(f); }), this._drawingManagerService.addNotification(p)) : (u.forEach((f) => { f.classType === Ne.IMAGE && p.some((w) => f.oKey.includes(w.drawingId)) && d.detachTransformerFrom(f); }), g.clearSelectedObjects()); } }), (l = this._permissionService.getPermissionPoint$(new St(r, s).id)) == null || l.pipe( ve((h) => h.value !== o), gt() ).subscribe({ complete: () => { o = !0; const h = e.getUnitId(), u = t.getSheetId(), m = this._drawingManagerService.getDrawingData(h, u), p = Object.values(m), f = this._renderManagerService.getRenderById(h), w = f == null ? void 0 : f.scene; if (w == null) return; this._drawingManagerService.setDrawingEditable(!0), w.getAllObjectsByOrder().forEach((S) => { S.classType === Ne.IMAGE && p.some((R) => S.oKey.includes(R.drawingId)) && w.detachTransformerFrom(S); }); } }); }); }) ); } }; Mt = ys([ ze(0, ae), ze(1, Q), ze(2, jr), ze(3, $e), ze(4, N(Nr)) ], Mt); var Os = Object.defineProperty, Ts = Object.getOwnPropertyDescriptor, Es = (i, e, n, t) => { for (var r = t > 1 ? void 0 : t ? Ts(e, n) : e, s = i.length - 1, o; s >= 0; s--) (o = i[s]) && (r = (t ? o(e, n, r) : o(r)) || r); return t && r && Os(e, n, r), r; }, wt = (i, e) => (n, t) => e(n, t, i); let yt = class extends ie { constructor(i, e, n, t) { super(), this._sheetPrintInterceptorService = i, this._drawingRenderService = e, this._drawingManagerService = n, this._renderManagerService = t, this._initPrinting(); } _initPrinting() { this.disposeWithMe( this._sheetPrintInterceptorService.interceptor.intercept( this._sheetPrintInterceptorService.interceptor.getInterceptPoints().PRINTING_COMPONENT_COLLECT, { handler: (i, e, n) => { const { unitId: t, scene: r, subUnitId: s } = e, o = this._drawingManagerService.getDrawingDataForUnit(t), c = o == null ? void 0 : o[s]; return c && c.order.forEach((d) => { this._drawingRenderService.renderDrawing(c.data[d], r); }), n(); } } ) ), this.disposeWithMe( this._sheetPrintInterceptorService.interceptor.intercept( this._sheetPrintInterceptorService.interceptor.getInterceptPoints().PRINTING_RANGE, { handler: (i, e, n) => { const { unitId: t, subUnitId: r } = e, s = this._renderManagerService.getRenderById(t); if (!s) return n(i); const o = s.with(Z).getWorksheetSkeleton(r); if (!o) return n(i); const c = this._drawingManagerService.getDrawingDataForUnit(t), d = c == null ? void 0 : c[e.subUnitId]; if (!d) return n(i); const { scaleX: g, scaleY: a } = s.scene, l = i ? { ...i } : { startColumn: 0, endColumn: 0, endRow: 0, startRow: 0 }, h = d.order.map((u) => d.data[u]).filter((u) => u.drawingType !== L.DRAWING_DOM); return h.length ? (h.forEach((u) => { if (!u.groupId && u.transform && Pe.isDefine(u.transform.left) && Pe.isDefine(u.transform.top) && Pe.isDefine(u.transform.width) && Pe.isDefine(u.transform.height)) { const m = o.skeleton.getCellIndexByOffset(u.transform.left, u.transform.top, g, a, { x: 0, y: 0 }), p = o.skeleton.getCellIndexByOffset(u.transform.left + u.transform.width, u.transform.top + u.transform.height, g, a, { x: 0, y: 0 }); m.column < l.startColumn && (l.startColumn = m.column), m.row < l.startRow && (l.startRow = m.row), l.endRow < p.row && (l.endRow = p.row), l.endColumn < p.column && (l.endColumn = p.column); } }), n(l)) : n(i); } } ) ); } }; yt = Es([ wt(0, N(gi)), wt(1, N(Tn)), wt(2, ae), wt(3, Q) ], yt); var Ps = Object.defineProperty, Us = Object.getOwnPropertyDescriptor, As = (i, e, n, t) => { for (var r = t > 1 ? void 0 : t ? Us(e, n) : e, s = i.length - 1, o; s >= 0; s--) (o = i[s]) && (r = (t ? o(e, n, r) : o(r)) || r); return t && r && Ps(e, n, r), r; }, pe = (i, e) => (n, t) => e(n, t, i); const Ns = [ xn.id, Bn.id, $n.id, kn.id, Ln.id, Fn.id, Gn.id, Vn.id, Qt.id, en.id, Yn.id, Hn.id, Xn.id, zn.id, Kn.id, Jn.id, Zn.id, qn.id, Qn.id ], js = [ Ni.id, ji.id, Wi.id, xi.id, Nn.id, jn.id ]; let sn = class extends ie { constructor(i, e, n, t, r, s, o, c, d) { super(), this._context = i, this._renderManagerService = e, this._commandService = n, this._selectionRenderService = t, this._skeletonManagerService = r, this._sheetInterceptorService = s, this._sheetDrawingService = o, this._drawingManagerService = c, this._univerInstanceService = d, this._sheetInterceptorListener(), this._commandListener(), this._sheetRefreshListener(); } _sheetInterceptorListener() { this.disposeWithMe( this._sheetInterceptorService.interceptCommand({ getMutations: (i) => { if (!Ns.includes(i.id)) return { redos: [], undos: [] }; if (i.params == null) return { redos: [], undos: [] }; const e = i.id; if (e === xn.id) return this._moveRowInterceptor(i.params, "insert"); if ([Zn.id, qn.id, Qn.id].includes(e)) return this._moveRangeInterceptor(i.params); if (e === Bn.id) return this._moveColInterceptor(i.params, "insert"); if (e === $n.id) return this._moveRowInterceptor(i.params, "remove"); if (e === kn.id) return this._moveColInterceptor(i.params, "remove"); if (e === Ln.id) { const { range: n } = i.params; return this._getRangeMoveUndo( n, 0 /* deleteLeft */ ); } else if (e === Fn.id) { const { range: n } = i.params; return this._getRangeMoveUndo( n, 1 /* deleteUp */ ); } else if (e === Gn.id) { const { range: n } = i.params; return this._getRangeMoveUndo( n, 2 /* insertDown */ ); } else if (e === Vn.id) { const { range: n } = i.params; return this._getRangeMoveUndo( n, 3 /* insertRight */ ); } else if (e === Xn.id || e === zn.id) { const n = i.params, { unitId: t, subUnitId: r, ranges: s } = n; return this._getDrawingUndoForRowVisible(t, r, s); } else if (e === Kn.id || e === Jn.id) { const n = i.params, { unitId: t, subUnitId: r, ranges: s } = n; return this._getDrawingUndoForColVisible(t, r, s); } else if (e === Qt.id || e === en.id || e === Yn.id || e === Hn.id) { const n = i.params, { unitId: t, subUnitId: r, ranges: s } = n, o = e === Qt.id || e === en.id; return this._getDrawingUndoForRowAndColSize(t, r, s, o); } return { redos: [], undos: [] }; } }) ); } _getRangeMoveUndo(i, e) { const n = V(this._univerInstanceService); if (n == null) return { redos: [], undos: [] }; const t = n.unitId, r = n.subUnitId, s = [], o = [], c = this._sheetDrawingService.getDrawingData(t, r), d = [], g = []; if (Object.keys(c).forEach((a) => { const l = c[a], { updateDrawings: h, deleteDrawings: u } = this._getUpdateOrDeleteDrawings(i, e, l); d.push(...h), g.push(...u); }), d.length === 0 && g.length === 0) return { redos: [], undos: [] }; if (d.length > 0) { const a = this._sheetDrawingService.getBatchUpdateOp(d), { undo: l, redo: h, objects: u } = a; s.push({ id: T.id, params: { unitId: t, subUnitId: r, op: h, objects: u, type: E.UPDATE } }), o.push({ id: T.id, params: { unitId: t, subUnitId: r, op: l, objects: u, type: E.UPDATE } }); } if (g.length > 0) { const a = this._sheetDrawingService.getBatchRemoveOp(g), l = a.undo, h = a.redo, u = a.objects; s.push({ id: T.id, params: { unitId: t, subUnitId: r, op: h, objects: u, type: E.REMOVE } }), o.push({ id: T.id, params: { unitId: t, subUnitId: r, op: l, objects: u, type: E.INSERT } }); } return s.push({ id: F.id, params: [t] }), o.push({ id: F.id, params: [t] }), { redos: s, undos: o }; } _getUpdateOrDeleteDrawings(i, e, n) { const t = [], r = [], { sheetTransform: s, anchorType: o = O.Position, transform: c, unitId: d, subUnitId: g, drawingId: a } = n, { from: l, to: h } = s, { row: u, column: m } = l, { row: p, column: f } = h; if (s == null || c == null) return { updateDrawings: t, deleteDrawings: r }; const { startRow: w, endRow: I, startColumn: S, endColumn: R } = i; let v = null, C = null; if (e === 0 && u >= w && p <= I) if (m >= S && f <= R) r.push({ unitId: d, subUnitId: g, drawingId: a }); else { const _ = this._shrinkCol(s, c, S, R, o); v = _ == null ? void 0 : _.newSheetTransform, C = _ == null ? void 0 : _.newTransform; } else if (e === 1 && m >= S && f <= R) if (u >= w && p <= I) r.push({ unitId: d, subUnitId: g, drawingId: a }); else { const _ = this._shrinkRow(s, c, w, I, o); v = _ == null ? void 0 : _.newSheetTransform, C = _ == null ? void 0 : _.newTransform; } else if (e === 2) { const _ = this._expandRow(s, c, w, I, o); v = _ == null ? void 0 : _.newSheetTransform, C = _ == null ? void 0 : _.newTransform; } else if (e === 3) { const _ = this._expandCol(s, c, S, R, o); v = _ == null ? void 0 : _.newSheetTransform, C = _ == null ? void 0 : _.newTransform; } if (v != null && C != null) { const _ = z(v, this._selectionRenderService, this._skeletonManagerService); t.push({ ...n, sheetTransform: v, transform: _ }); } return { updateDrawings: t, deleteDrawings: r }; } _remainDrawingSize(i, e, n) { const t = k({ ...i }, this._selectionRenderService); t != null && e.push({ ...n, sheetTransform: t }); } // eslint-disable-next-line max-lines-per-function _getDrawingUndoForColVisible(i, e, n) { const t = this._drawingManagerService.getDrawingData(i, e), r = [], s = []; if (Object.keys(t).forEach((a) => { const l = t[a], { sheetTransform: h, transform: u, anchorType: m = O.Position } = l; if (m === O.None) this._remainDrawingSize(u, r, l); else { const { from: p, to: f } = h, { row: w, column: I } = p, { row: S, column: R } = f; for (let v = 0; v < n.length; v++) { const C = n[v], { startRow: _, endRow: y, startColumn: M, endColumn: x } = C; if (R < M) continue; if (m === O.Position) { let b = null, P = null; if (I >= M && I <= x) { const A = this._skeletonManagerService.attachRangeWithCoord({ startColumn: I, endColumn: x, startRow: p.row, endRow: f.row }); if (A == null) return; P = { ...u, left: A.startX }; } if (P != null && (b = k(P, this._selectionRenderService), b != null && P != null)) { r.push({ ...l, sheetTransform: b, transform: P }); break; } this._remainDrawingSize(u, r, l); continue; } if (I >= M && R <= x) continue; let U = null, D = null; if (I >= M && I <= x) { const b = this._skeletonManagerService.attachRangeWithCoord({ startColumn: I, endColumn: x, startRow: p.row, endRow: f.row }); if (b == null) return; D = { ...u, left: (b == null ? void 0 : b.startX) || 0, width: ((u == null ? void 0 : u.width) || 0) - b.endX + b.startX }; } else if (R >= M && R <= x) { const b = this._skeletonManagerService.attachRangeWithCoord({ startColumn: M, endColumn: R, startRow: p.row, endRow: f.row }); if (b == null) return; D = { ...u, left: b.startX - ((u == null ? void 0 : u.width) || 0) }; } else { const b = this._skeletonManagerService.attachRangeWithCoord({ startColumn: M, endColumn: x, startRow: p.row, endRow: f.row }); if (b == null) return; if (D = { ...u, width: ((u == null ? void 0 : u.width) || 0) - b.endX + b.startX }, U = k(D, this._selectionRenderService), U != null && D != null) { s.push({ ...l, sheetTransform: U, transform: D }); break; } } if (D != null && (U = k(D, this._selectionRenderService)), D != null && U != null) { r.push({ ...l, sheetTransform: U, transform: D }); break; } else this._remainDrawingSize(u, r, l); } } }), r.length === 0 && s.length === 0) return { redos: [], undos: [] }; const { redos: o, undos: c } = this._createUndoAndRedoMutation(i, e, r), d = [], g = []; if (s.length > 0) { const { redos: a, undos: l } = this._createUndoAndRedoMutation(i, e, s); d.push(...a), g.push(...l); } return { redos: o, undos: c, preRedos: d, preUndos: g }; } _createUndoAndRedoMutation(i, e, n) { const t = this._sheetDrawingService.getBatchUpdateOp(n), { undo: r, redo: s, objects: o } = t, c = [ { id: T.id, params: { unitId: i, subUnitId: e, op: s, objects: o, type: E.UPDATE } }, { id: F.id, params: [i] } ], d = [ { id: T.id, params: { unitId: i, subUnitId: e, op: r, objects: o, type: E.UPDATE } }, { id: F.id, params: [i] } ]; return { redos: c, undos: d }; } // eslint-disable-next-line max-lines-per-function _getDrawingUndoForRowVisible(i, e, n) { const t = this._drawingManagerService.getDrawingData(i, e), r = [], s = []; if (Object.keys(t).forEach((a) => { const l = t[a], { sheetTransform: h, transform: u, anchorType: m = O.Position } = l; if (m === O.None) this._remainDrawingSize(u, r, l); else { const { from: p, to: f } = h, { row: w, column: I } = p, { row: S, column: R } = f; for (let v = 0; v < n.length; v++) { const C = n[v], { startRow: _, endRow: y, startColumn: M, endColumn: x } = C; if (S < _) continue; if (m === O.Position) { let b = null, P = null; if (w >= _ && w <= y) { const A = this._skeletonManagerService.attachRangeWithCoord({ startColumn: p.column, endColumn: f.column, startRow: w, endRow: y }); if (A == null) return; P = { ...u, top: A.startY }; } if (P != null && (b = k(P, this._selectionRenderService), b != null && P != null)) { r.push({ ...l, sheetTransform: b, transform: P }); break; } this._remainDrawingSize(u, r, l); continue; } if (w >= _ && S <= y) continue; let U = null, D = null; if (w >= _ && w <= y) { const b = this._skeletonManagerService.attachRangeWithCoord({ startColumn: p.column, endColumn: f.column, startRow: w, endRow: y }); if (b == null) return; D = { ...u, top: (b == null ? void 0 : b.startY) || 0, height: ((u == null ? void 0 : u.height) || 0) - b.endY + b.startY }; } else if (S >= _ && S <= y) { const b = this._skeletonManagerService.attachRangeWithCoord({ startColumn: p.column, endColumn: f.column, startRow: _, endRow: S }); if (b == null) return; D = { ...u, top: b.startY - ((u == null ? void 0 : u.height) || 0) }; } else { const b = this._skeletonManagerService.attachRangeWithCoord({ startColumn: p.column, endColumn: f.column, startRow: _, endRow: y }); if (b == null) return; if (D = { ...u, height: ((u == null ? void 0 : u.height) || 0) - b.endY + b.startY }, U = k(D, this._selectionRenderService), U != null && D != null) { s.push({ ...l, sheetTransform: U, transform: D }); break; } } if (D != null && (U = k(D, this._selectionRenderService)), D != null && U != null) { r.push({ ...l, sheetTransform: U, transform: D }); break; } else this._remainDrawingSize(u, r, l); } } }), r.length === 0 && s.length === 0) return { redos: [], undos: [] }; const { redos: o, undos: c } = this._createUndoAndRedoMutation(i, e, r), d = [], g = []; if (s.length > 0) { const { redos: a, undos: l } = this._createUndoAndRedoMutation(i, e, s); d.push(...a), g.push(...l); } return { redos: o, undos: c, preRedos: d, preUndos: g }; } _getDrawingUndoForRowAndColSize(i, e, n, t) { const r = this._drawingManagerService.getDrawingData(i, e), s = []; return Object.keys(r).forEach((o) => { const c = r[o], { sheetTransform: d, transform: g, anchorType: a = O.Position } = c; if (a === O.None) this._remainDrawingSize(g, s, c); else { const { from: l, to: h } = d, { row: u, column: m } = l, { row: p, column: f } = h; for (let w = 0; w < n.length; w++) { const I = n[w], { startRow: S, endRow: R, startColumn: v, endColumn: C } = I; if (p < S || f < v) continue; if (a === O.Position && (u <= S && p >= R || m <= v && f >= C)) { this._remainDrawingSize(g, s, c); continue; } const _ = z( { ...d }, this._selectionRenderService, this._skeletonManagerService ); if (_ != null) { s.push({ ...c, transform: _ }); break; } } } }), s.length === 0 ? { redos: [], undos: [] } : this._createUndoAndRedoMutation(i, e, s); } _getUnitIdAndSubUnitId(i, e) { let n, t; if (e === "insert") n = i.unitId, t = i.subUnitId; else { const r = V(this._univerInstanceService); if (r == null) return; n = r.unitId, t = r.subUnitId; } return { unitId: n, subUnitId: t }; } _moveRangeInterceptor(i) { var S, R; const { toRange: e, fromRange: n } = i, t = V(this._univerInstanceService); if (!t) return { redos: [], undos: [] }; const { unitId: r, subUnitId: s } = t, o = (R = (S = this._renderManagerService.getRenderById(r)) == null ? void 0 : S.with(Z)) == null ? void 0 : R.getCurrentSkeleton(); if (!o) return { redos: [], undos: [] }; const c = Pn(o, n); if (!c) return { redos: [], undos: [] }; const { startX: d, endX: g, startY: a, endY: l } = c, h = this._sheetDrawingService.getDrawingData(r, s), u = []; Object.keys(h).forEach((v) => { const C = h[v]; if (C.anchorType !== O.Both) return; const { transform: _ } = C; if (!_) return; const { left: y = 0, top: M = 0, width: x = 0, height: U = 0 } = _, { drawingStartX: D, drawingEndX: b, drawingStartY: P, drawingEndY: A } = { drawingStartX: y, drawingEndX: y + x, drawingStartY: M, drawingEndY: M + U }; d <= D && b <= g && a <= P && A <= l && u.push(C); }); const m = [], p = [], f = e.startRow - n.startRow, w = e.startColumn - n.startColumn, I = u.map((v) => { const C = v.sheetTransform, _ = { to: { ...C.to, row: C.to.row + f, column: C.to.column + w }, from: { ...C.from, row: C.from.row + f, column: C.from.column + w } }, y = z(_, this._selectionRenderService, this._skeletonManagerService); return { unitId: r, subUnitId: s, drawingId: v.drawingId, transform: y, sheetTransform: _ }; }); if (I.length) { const v = this._sheetDrawingService.getBatchUpdateOp(I), { undo: C, redo: _, objects: y } = v; m.push({ id: T.id, params: { unitId: r, subUnitId: s, op: _, objects: y, type: E.UPDATE } }), p.push({ id: T.id, params: { unitId: r, subUnitId: s, op: C, objects: y, type: E.UPDATE } }); } return { redos: m, undos: p }; } _moveRowInterceptor(i, e) { const n = this._getUnitIdAndSubUnitId(i, e); if (n == null) return { redos: [], undos: [] }; const { unitId: t, subUnitId: r } = n, { range: s } = i, o = s.startRow, c = s.endRow, d = [], g = [], a = this._sheetDrawingService.getDrawingData(t, r), l = [], h = []; if (Object.keys(a).forEach((u) => { const m = a[u], { sheetTransform: p, transform: f, anchorType: w = O.Position } = m; if (p == null || f == null) return; let I, S; if (e === "insert") { const v = this._expandRow(p, f, o, c, w); I = v == null ? void 0 : v.newSheetTransform, S = v == null ? void 0 : v.newTransform; } else { const { from: v, to: C } = p, { row: _ } = v, { row: y } = C; if (w === O.Both && _ >= o && y <= c) h.push({ unitId: t, subUnitId: r, drawingId: u }); else { const M = this._shrinkRow(p, f, o, c, w); I = M == null ? void 0 : M.newSheetTransform, S = M == null ? void 0 : M.newTransform; } } if (!I || !S) return; const R = { unitId: t, subUnitId: r, drawingId: u, transform: S, sheetTransform: I }; l.push(R); }), l.length === 0 && h.length === 0) return { redos: [], undos: [] }; if (l.length > 0) { const u = this._sheetDrawingService.getBatchUpdateOp(l), { undo: m, redo: p, objects: f } = u; d.push({ id: T.id, params: { unitId: t, subUnitId: r, op: p, objects: f, type: E.UPDATE } }), g.push({ id: T.id, params: { unitId: t, subUnitId: r, op: m, objects: f, type: E.UPDATE } }); } if (h.length > 0) { const u = this._sheetDrawingService.getBatchRemoveOp(h), m = u.undo, p = u.redo, f = u.objects; d.push({ id: T.id, params: { unitId: t, subUnitId: r, op: p, objects: f, type: E.REMOVE } }), g.push({ id: T.id, params: { unitId: t, subUnitId: r, op: m, objects: f, type: E.INSERT } }); } return d.push({ id: F.id, params: [t] }), g.push({ id: F.id, params: [t] }), { redos: d, undos: g }; } _moveColInterceptor(i, e) { const n = this._getUnitIdAndSubUnitId(i, e); if (n == null) return { redos: [], undos: [] }; const { unitId: t, subUnitId: r } = n, { range: s } = i, o = s.startColumn, c = s.endColumn, d = [], g = [], a = this._sheetDrawingService.getDrawingData(t, r), l = [], h = []; if (Object.keys(a).forEach((u) => { const m = a[u], { sheetTransform: p, transform: f, anchorType: w = O.Position } = m; if (p == null || f == null) return; let I, S; if (e === "insert") { const v = this._expandCol(p, f, o, c, w); I = v == null ? void 0 : v.newSheetTransform, S = v == null ? void 0 : v.newTransform; } else { const { from: v, to: C } = p, { column: _ } = v, { column: y } = C; if (w === O.Both && _ >= o && y <= c) h.push({ unitId: t, subUnitId: r, drawingId: u }); else { const M = this._shrinkCol(p, f, o, c, w); I = M == null ? void 0 : M.newSheetTransform, S = M == null ? void 0 : M.newTransform; } } if (!I || !S) return; const R = { unitId: t, subUnitId: r, drawingId: u, transform: S, sheetTransform: I }; l.push(R); }), l.length === 0 && h.length === 0) return { redos: [], undos: [] }; if (l.length > 0) { const u = this._sheetDrawingService.getBatchUpdateOp(l), { undo: m, redo: p, objects: f } = u; d.push({ id: T.id, params: { unitId: t, subUnitId: r, op: p, objects: f, type: E.UPDATE } }), g.push({ id: T.id, params: { unitId: t, subUnitId: r, op: m, objects: f, type: E.UPDATE } }); } if (h.length > 0) { const u = this._sheetDrawingService.getBatchRemoveOp(h), m = u.undo, p = u.redo, f = u.objects; d.push({ id: T.id, params: { unitId: t, subUnitId: r, op: p, objects: f, type: E.REMOVE } }), g.push({ id: T.id, params: { unitId: t, subUnitId: r, op: m, objects: f, type: E.INSERT } }); } return d.push({ id: F.id, params: [t] }), g.push({ id: F.id, params: [t] }), { redos: d, undos: g }; } _expandCol(i, e, n, t, r = O.Position) { const s = t - n + 1, { from: o, to: c } = i, { column: d } = o, { column: g } = c; if (r === O.None) return { newSheetTransform: k({ ...e }, this._selectionRenderService), newTransform: e }; let a = null, l = null; if (d >= n) { const h = this._skeletonManagerService.attachRangeWithCoord({ startColumn: n, endColumn: t, startRow: o.row, endRow: c.row }); if (h == null) return; l = { ...e, left: (e.left || 0) + h.endX - h.startX }, a = k(l, this._selectionRenderService); } else if (g >= t) if (r === O.Both) a = { from: { ...o }, to: { ...c, column: g + s } }, l = z(a, this._selectionRenderService, this._skeletonManagerService); else return { newSheetTransform: k({ ...e }, this._selectionRenderService), newTransform: e }; return a != null && l != null ? { newSheetTransform: a, newTransform: l } : null; } _shrinkCol(i, e, n, t, r = O.Position) { const s = t - n + 1, { from: o, to: c } = i, { column: d } = o, { column: g } = c; if (r === O.None) return { newSheetTransform: k({ ...e }, this._selectionRenderService), newTransform: e }; let a = null, l = null; if (d > t) a = { from: { ...o, column: d - s }, to: { ...c, column: g - s } }, l = z(a, this._selectionRenderService, this._skeletonManagerService); else { if (d >= n && g <= t) return null; if (d < n && g > t) if (r === O.Both) a = { from: { ...o }, to: { ...c, column: g - s } }, l = z(a, this._selectionRenderService, this._skeletonManagerService); else return { newSheetTransform: k({ ...e }, this._selectionRenderService), newTransform: e }; else if (d >= n && d <= t) { if (d === n) l = { ...e, left: (e.left || 0) - i.from.columnOffset }; else { const h = this._skeletonManagerService.attachRangeWithCoord({ startColumn: n, endColumn: d - 1, startRow: o.row, endRow: c.row }); if (h == null) return; l = { ...e, left: (e.left || 0) - h.endX + h.startX - i.from.columnOffset }; } a = k(l, this._selectionRenderService); } else if (g >= n && g <= t && r === O.Both) { const h = this._skeletonManagerService.attachRangeWithCoord({ startColumn: n - 1, endColumn: n - 1, startRow: o.row, endRow: c.row }); if (h == null) return; a = { from: { ...o }, to: { ...c, column: n - 1, columnOffset: h.endX - h.startX } }, l = z(a, this._selectionRenderService, this._skeletonManagerService); } } return a != null && l != null ? { newSheetTransform: a, newTransform: l } : null; } _expandRow(i, e, n, t, r = O.Position) { const s = t - n + 1, { from: o, to: c } = i, { row: d } = o, { row: g } = c; if (r === O.None) return { newSheetTransform: k({ ...e }, this._selectionRenderService), newTransform: e }; let a = null, l = null; if (d >= n) { const h = this._skeletonManagerService.attachRangeWithCoord({ startRow: n, endRow: t, startColumn: o.column, endColumn: c.column }); if (h == null) return; l = { ...e, top: (e.top || 0) + h.endY - h.startY }, a = k(l, this._selectionRenderService); } else if (g >= t) if (r === O.Both) a = { from: { ...o }, to: { ...c, row: g + s } }, l = z(a, this._selectionRenderService, this._skeletonManagerService); else return { newSheetTransform: k({ ...e }, this._selectionRenderService), newTransform: e }; return a != null && l != null ? { newSheetTransform: a, newTransform: l } : null; } _shrinkRow(i, e, n, t, r = O.Position) { const s = t - n + 1, { from: o, to: c } = i, { row: d } = o, { row: g } = c; if (r === O.None) return { newSheetTransform: k({ ...e }, this._selectionRenderService), newTransform: e }; let a = null, l = null; if (d > t) a = { from: { ...o, row: d - s }, to: { ...c, row: g - s } }, l = z(a, this._selectionRenderService, this._skeletonManagerService); else { if (d >= n && g <= t) return null; if (d < n && g > t) if (r === O.Both) a = { from: { ...o }, to: { ...c, row: g - s } }, l = z(a, this._selectionRenderService, this._skeletonManagerService); else return { newSheetTransform: k({ ...e }, this._selectionRenderService), newTransform: e }; else if (d >= n && d <= t) { if (d === n) l = { ...e, top: (e.top || 0) - i.from.rowOffset }; else { const h = this._skeletonManagerService.attachRangeWithCoord({ startRow: n, endRow: d - 1, startColumn: o.column, endColumn: c.column }); if (h == null) return; l = { ...e, top: (e.top || 0) - h.endY + h.startY - i.from.rowOffset }; } a = k(l, this._selectionRenderService); } else if (g >= n && g <= t && r === O.Both) { const h = this._skeletonManagerService.attachRangeWithCoord({ startColumn: o.column, endColumn: o.column, startRow: n - 1, endRow: n - 1 }); if (h == null) return; a = { from: { ...o }, to: { ...c, row: n - 1, rowOffset: h.endY - h.startY } }, l = z(a, this._selectionRenderService, this._skeletonManagerService); } } return a != null && l != null ? { newSheetTransform: a, newTransform: l } : null; } _commandListener() { this.disposeWithMe( this._commandService.onCommandExecuted((i) => { i.id === Bi.id && setTimeout(() => { const e = i.params, { unitId: n, subUnitId: t } = e, r = this._drawingManagerService.drawingManagerData, s = [], o = []; Object.keys(r).forEach((c) => { const d = r[c]; d != null && Object.keys(d).forEach((g) => { const a = d[g].data; a != null && Object.keys(a).forEach((l) => { if (c === n && g === t) { const h = a[l]; h.transform = z(h.sheetTransform, this._selectionRenderService, this._skeletonManagerService), s.push(a[l]); } else o.push(a[l]); }); }); }), this._drawingManagerService.removeNotification(o), this._drawingManagerService.addNotification(s); }, 0); }) ); } _sheetRefreshListener() { this.disposeWithMe( this._commandService.onCommandExecuted((i) => { js.includes(i.id) && requestIdleCallback(() => { const e = i.params, { unitId: n, subUnitId: t, ranges: r } = e; this._refreshDrawingTransform(n, t, r); }); }) ); } _refreshDrawingTransform(i, e, n) { const t = this._drawingManagerService.getDrawingData(i, e), r = []; Object.keys(t).forEach((s) => { const o = t[s], { sheetTransform: c, transform: d, anchorType: g = O.Position } = o; if (g === O.None) return !0; const { from: a, to: l } = c, { row: h, column: u } = a, { row: m, column: p } = l; for (let f = 0; f < n.length; f++) { const w = n[f], { startRow: I, endRow: S, startColumn: R, endColumn: v } = w; if (Wr.intersects( { startRow: I, endRow: S, startColumn: R, endColumn: v }, { startRow: h, endRow: m, startColumn: u, endColumn: p } ) || h > S || u > v) { const C = g === O.Position, _ = z(c, this._selectionRenderService, this._skeletonManagerService); r.push({ ...o, transform: { ..._, width: C ? d == null ? void 0 : d.width : _ == null ? void 0 : _.width, height: C ? d == null ? void 0 : d.height : _ == null ? void 0 : _.height } }); break; } } }), r.length !== 0 && (this._drawingManagerService.refreshTransform(r), this._commandService.syncExecuteCommand(F.id, [i])); } }; sn = As([ pe(1, Q), pe(2, H), pe(3, Qe), pe(4, N(Z)), pe(5, N(At)), pe(6, ee), pe(7, ae), pe(8, $e) ], sn); var ne = function() { return ne = Object.assign || function(i) { for (var e, n = 1, t = arguments.length; n < t; n++) { e = arguments[n]; for (var r in e) Object.prototype.hasOwnProperty.call(e, r) && (i[r] = e[r]); } return i; }, ne.apply(this, arguments); }, Ws = function(i, e) { var n = {}; for (var t in i) Object.prototype.hasOwnProperty.call(i, t) && e.indexOf(t) < 0 && (n[t] = i[t]); if (i != null && typeof Object.getOwnPropertySymbols == "function") for (var r = 0, t = Object.getOwnPropertySymbols(i); r < t.length; r++) e.indexOf(t[r]) < 0 && Object.prototype.propertyIsEnumerable.call(i, t[r]) && (n[t[r]] = i[t[r]]); return n; }, lr = tr(function(i, e) { var n = i.icon, t = i.id, r = i.className, s = i.extend, o = Ws(i, ["icon", "id", "className", "extend"]), c = "univerjs-icon univerjs-icon-".concat(t, " ").concat(r || "").trim(), d = Fi("_".concat($s())); return ur(n, "".concat(t), { defIds: n.defIds, idSuffix: d.current }, ne({ ref: e, className: c }, o), s); }); function ur(i, e, n, t, r) { return nr(i.tag, ne(ne({ key: e }, xs(i, n, r)), t), (Bs(i, n).children || []).map(function(s, o) { return ur(s, "".concat(e, "-").concat(i.tag, "-").concat(o), n, void 0, r); })); } function xs(i, e, n) { var t = ne({}, i.attrs); n != null && n.colorChannel1 && t.fill === "colorChannel1" && (t.fill = n.colorChannel1); var r = e.defIds; return !r || r.length === 0 || (i.tag === "use" && t["xlink:href"] && (t["xlink:href"] = t["xlink:href"] + e.idSuffix), Object.entries(t).forEach(function(s) { var o = s[0], c = s[1]; typeof c == "string" && (t[o] = c.replace(/url\(#(.*)\)/, "url(#$1".concat(e.idSuffix, ")"))); })), t; } function Bs(i, e) { var n, t = e.defIds; return !t || t.length === 0 ? i : i.tag === "defs" && (!((n = i.children) === null || n === void 0) && n.length) ? ne(ne({}, i), { children: i.children.map(function(r) { return typeof r.attrs.id == "string" && t && t.indexOf(r.attrs.id) > -1 ? ne(ne({}, r), { attrs: ne(ne({}, r.attrs), { id: r.attrs.id + e.idSuffix }) }) : r; }) }) : i; } function $s() { return Math.random().toString(36).substring(2, 8); } lr.displayName = "UniverIcon"; var ks = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M2.2498 3.65005C2.2498 2.87685 2.87661 2.25005 3.64981 2.25005H7.9998C8.33118 2.25005 8.5998 1.98142 8.5998 1.65005C8.5998 1.31868 8.33118 1.05005 7.9998 1.05005H3.64981C2.21387 1.05005 1.0498 2.21411 1.0498 3.65005V12.35C1.0498 13.786 2.21386 14.95 3.6498 14.95H12.3498C13.7857 14.95 14.9498 13.786 14.9498 12.3501V8.00005C14.9498 7.66868 14.6812 7.40005 14.3498 7.40005C14.0184 7.40005 13.7498 7.66868 13.7498 8.00005V9.23974L12.2385 8.1063C11.7252 7.72129 11.0068 7.7723 10.5531 8.22605L9.00869 9.77041L6.73916 7.8251C6.24387 7.40055 5.5095 7.41278 5.02864 7.85359L2.2498 10.4009V3.65005ZM2.2498 12.0287V12.35C2.2498 13.1232 2.87661 13.75 3.6498 13.75H12.3498C13.123 13.75 13.7498 13.1232 13.7498 12.3501V10.7397L11.5186 9.06631C11.4829 9.03956 11.433 9.04314 11.4016 9.07458L9.92249 10.5537L11.1015 11.5642C11.3531 11.7799 11.3822 12.1587 11.1666 12.4103C10.9509 12.6619 10.5721 12.691 10.3205 12.4753L5.9582 8.7362C5.92384 8.70674 5.87288 8.70758 5.83952 8.73816L2.2498 12.0287Z", fillRule: "evenodd", clipRule: "evenodd" } }, { tag: "path", attrs: { fill: "currentColor", d: "M11.8097 1.14783C12.1411 1.14783 12.4097 1.41646 12.4097 1.74783V3.297H14.1541C14.4855 3.297 14.7541 3.56563 14.7541 3.897C14.7541 4.22837 14.4855 4.497 14.1541 4.497H12.4097V6.24167C12.4097 6.57304 12.1411 6.84167 11.8097 6.84167C11.4783 6.84167 11.2097 6.57304 11.2097 6.24167V4.497H9.6603C9.32893 4.497 9.0603 4.22837 9.0603 3.897C9.0603 3.56563 9.32893 3.297 9.6603 3.297H11.2097V1.74783C11.2097 1.41646 11.4783 1.14783 11.8097 1.14783Z" } }] }, hr = tr(function(i, e) { return nr(lr, Object.assign({}, i, { id: "add-image-single", ref: e, icon: ks })); }); hr.displayName = "AddImageSingle"; const gr = { id: "sheet.command.delete-drawing", type: q.COMMAND, handler: (i) => { const e = i.get(H), t = i.get(ee).getFocusDrawings(); if (t.length === 0) return !1; const r = t[0].unitId, s = t.map((o) => { const { unitId: c, subUnitId: d, drawingId: g, drawingType: a } = o; return { unitId: c, subUnitId: d, drawingId: g, drawingType: a }; }); return e.executeCommand(Nt.id, { unitId: r, drawings: s }); } }, cn = { id: "sheet.command.insert-float-image", type: q.COMMAND, handler: (i) => { var n, t; return (t = (n = i.get(Q).getCurrentTypeOfRenderer(Y.UNIVER_SHEET)) == null ? void 0 : n.with(Ze).insertFloatImage()) != null ? t : !1; } }, dn = { id: "sheet.command.insert-cell-image", type: q.COMMAND, handler: (i) => { var n, t; return (t = (n = i.get(Q).getCurrentTypeOfRenderer(Y.UNIVER_SHEET)) == null ? void 0 : n.with(Ze).insertCellImage()) != null ? t : !1; } }, et = { id: "sheet.command.move-drawing", type: q.COMMAND, handler: (i, e) => { const n = i.get(H), t = i.get(ee), r = i.get(Qe), { direction: s } = e, o = t.getFocusDrawings(); if (o.length === 0) return !1; const c = o[0].unitId, d = o.map((a) => { const { transform: l } = a; if (l == null) return null; const h = { ...l }, { left: u = 0, top: m = 0 } = l; return s === _e.UP ? h.top = m - 1 : s === _e.DOWN ? h.top = m + 1 : s === _e.LEFT ? h.left = u - 1 : s === _e.RIGHT && (h.left = u + 1), { ...a, transform: h, sheetTransform: k(h, r) }; }).filter((a) => a != null); return n.syncExecuteCommand(Wt.id, { unitId: c, drawings: d }) ? (n.syncExecuteCommand(F.id, [c]), !0) : !1; } }, mr = "addition-and-subtraction-single", fr = "sheet.menu.image"; function Ls(i) { return { id: fr, type: on.SUBITEMS, icon: mr, tooltip: "sheetImage.title", hidden$: Un(i, Y.UNIVER_SHEET), disabled$: mi(i, { workbookTypes: [qt], worksheetTypes: [St], rangeTypes: [$i] }) }; } function Fs(i) { return { id: cn.id, title: "sheetImage.upload.float", type: on.BUTTON, hidden$: Un(i, Y.UNIVER_SHEET) }; } function Gs(i) { return { id: dn.id, title: "sheetImage.upload.cell", type: on.BUTTON }; } const Vs = "univer-image-common-panel", Ys = "univer-image-common-panel-grid", Hs = "univer-image-common-panel-border", Xs = "univer-image-common-panel-title", zs = "univer-image-common-panel-subtitle", Ks = "univer-image-common-panel-row", Js = "univer-image-common-panel-row-vertical", Zs = "univer-image-common-panel-column", qs = "univer-image-common-panel-column-center", Qs = "univer-image-common-panel-inline", eo = "univer-image-common-panel-span2", to = "univer-image-common-panel-span3", no = "univer-image-common-panel-input", ro = "univer-sheet-image-menu", io = "univer-sheet-image-menu-input", we = { imageCommonPanel: Vs, imageCommonPanelGrid: Ys, imageCommonPanelBorder: Hs, imageCommonPanelTitle: Xs, imageCommonPanelSubtitle: zs, imageCommonPanelRow: Ks, imageCommonPanelRowVertical: Js, imageCommonPanelColumn: Zs, imageCommonPanelColumnCenter: qs, imageCommonPanelInline: Qs, imageCommonPanelSpan2: eo, imageCommonPanelSpan3: to, imageCommonPanelInput: no, sheetImageMenu: ro, sheetImageMenuInput: io }; function pr(i) { var e, n, t = ""; if (typeof i == "string" || typeof i == "number") t += i; else if (typeof i == "object") if (Array.isArray(i)) { var r = i.length; for (e = 0; e < r; e++) i[e] && (n = pr(i[e])) && (t && (t += " "), t += n); } else for (n in i) i[n] && (t && (t += " "), t += n); return t; } function _t() { for (var i, e, n = 0, t = "", r = arguments.length; n < r; n++) (i = arguments[n]) && (e = pr(i)) && (t && (t += " "), t += e); return t; } const so = (i) => { var S; const e = Ee(H), n = Ee(Pt), t = Ee(ae), r = Ee(Q), { drawings: s } = i, o = s[0]; if (o == null) return; const { unitId: c } = o, d = r.getRenderById(c), g = d == null ? void 0 : d.scene; if (g == null) return; const a = g.getTransformerByCreate(), [l, h] = tn(!0), u = (S = o.anchorType) != null ? S : O.Position, [m, p] = tn(u); function f(R, v) { const C = []; return R.forEach((_) => { const { oKey: y } = _, M = v.getDrawingOKey(y); if (M == null) return C.push(null), !0; const { unitId: x, subUnitId: U, drawingId: D, drawingType: b, anchorType: P, sheetTransform: A } = M; C.push({ unitId: x, subUnitId: U, drawingId: D, anchorType: P, sheetTransform: A, drawingType: b }); }), C; } an(() => { const R = a.clearControl$.subscribe((C) => { C === !0 && h(!1); }), v = a.changeStart$.subscribe((C) => { var M; const { objects: _ } = C, y = f(_, t); if (y.length === 0) h(!1); else if (y.length >= 1) { h(!0); const x = ((M = y[0]) == null ? void 0 : M.anchorType) || O.Position; p(x); } }); return () => { v.unsubscribe(), R.unsubscribe(); }; }, []); function w(R) { p(R); const v = t.getFocusDrawings(); if (v.length === 0) return; const C = v.map((_) => ({ unitId: _.unitId, subUnitId: _.subUnitId, drawingId: _.drawingId, anchorType: R })); e.executeCommand(Wt.id, { unitId: v[0].unitId, drawings: C }); } const I = (R) => R ? "block" : "none"; return /* @__PURE__ */ G.jsxs("div", { className: _t(we.imageCommonPanelGrid, we.imageCommonPanelBorder), style: { display: I(l) }, children: [ /* @__PURE__ */ G.jsx("div", { className: we.imageCommonPanelRow, children: /* @__PURE__ */ G.jsx("div", { className: _t(we.imageCommonPanelColumn, we.imageCommonPanelTitle), children: /* @__PURE__ */ G.jsx("div", { children: n.t("drawing-anchor.title") }) }) }), /* @__PURE__ */ G.jsx("div", { className: _t(we.imageCommonPanelRow), children: /* @__PURE__ */ G.jsx("div", { className: _t(we.imageCommonPanelColumn), children: /* @__PURE__ */ G.jsxs(Yi, { value: m, onChange: w, direction: "vertical", children: [ /* @__PURE__ */ G.jsx(zt, { value: O.Both, children: n.t("drawing-anchor.both") }), /* @__PURE__ */ G.jsx(zt, { value: O.Position, children: n.t("drawing-anchor.position") }), /* @__PURE__ */ G.jsx(zt, { value: O.None, children: n.t("drawing-anchor.none") }) ] }) }) }) ] }); }, oo = () => { const i = Ee(ae), e = i.getFocusDrawings(), [n, t] = tn(e); return an(() => { const r = i.focus$.subscribe((s) => { t(s); }); return () => { r.unsubscribe(); }; }, []), !!(n != null && n.length) && /* @__PURE__ */ G.jsxs("div", { className: we.imageCommonPanel, children: [ /* @__PURE__ */ G.jsx(ti, { drawings: n }), /* @__PURE__ */ G.jsx(so, { drawings: n }) ] }); }, ao = { [Ii.FORMULAS_INSERT]: { [fr]: { order: 3, menuItemFactory: Ls, [cn.id]: { order: 0, menuItemFactory: Fs }, [dn.id]: { order: 1, menuItemFactory: Gs } } } }; function tt(i) { return !i.getContextValue(xr) && !i.getContextValue(Br) && !i.getContextValue($r) && i.getContextValue(We); } const co = { id: et.id, description: "shortcut.sheet.drawing-move-down", group: "4_sheet-drawing-view", binding: xe.ARROW_DOWN, priority: 100, preconditions: tt, staticParameters: { direction: _e.DOWN } }, lo = { id: et.id, description: "shortcut.sheet.drawing-move-up", group: "4_sheet-drawing-view", binding: xe.ARROW_UP, priority: 100, preconditions: tt, staticParameters: { direction: _e.UP } }, uo = { id: et.id, description: "shortcut.sheet.drawing-move-left", group: "4_sheet-drawing-view", binding: xe.ARROW_LEFT, priority: 100, preconditions: tt, staticParameters: { direction: _e.LEFT } }, ho = { id: et.id, description: "shortcut.sheet.drawing-move-right", group: "4_sheet-drawing-view", binding: xe.ARROW_RIGHT, priority: 100, preconditions: tt, staticParameters: { direction: _e.RIGHT } }, go = { id: gr.id, description: "shortcut.sheet.drawing-delete", group: "4_sheet-drawing-view", // when focusing on any other input tag do not trigger this shortcut preconditions: tt, binding: xe.DELETE, mac: xe.BACKSPACE }; var mo = Object.defineProperty, fo = Object.getOwnPropertyDescriptor, po = (i, e, n, t) => { for (var r = t > 1 ? void 0 : t ? fo(e, n) : e, s = i.length - 1, o; s >= 0; s--) (o = i[s]) && (r = (t ? o(e, n, r) : o(r)) || r); return t && r && mo(e, n, r), r; }, vt = (i, e) => (n, t) => e(n, t, i); let Ot = class extends ie { constructor(i, e, n, t) { super(), this._componentManager = i, this._menuManagerService = e, this._commandService = n, this._shortcutService = t, this._init(); } _initCustomComponents() { const i = this._componentManager; this.disposeWithMe(i.register(mr, hr)), this.disposeWithMe(i.register(rr, oo)); } _initMenus() { this._menuManagerService.mergeMenu(ao); } _initCommands() { [ cn, dn, jt, Nt, Wt, ir, F, sr, or, cr, et, gr, ar ].forEach((i) => this.disposeWithMe(this._commandService.registerCommand(i))); } _initShortcuts() { [ // sheet drawing shortcuts co, lo, uo, ho, go ].forEach((i) => { this.disposeWithMe(this._shortcutService.registerShortcut(i)); }); } _init() { this._initCommands(), this._initCustomComponents(), this._initMenus(), this._initShortcuts(); } }; Ot = po([ vt(0, N(Ci)), vt(1, Ri), vt(2, H), vt(3, bi) ], Ot); var wo = Object.defineProperty, _o = Object.getOwnPropertyDescriptor, vo = (i, e, n, t) => { for (var r = t > 1 ? void 0 : t ? _o(e, n) : e, s = i.length - 1, o; s >= 0; s--) (o = i[s]) && (r = (t ? o(e, n, r) : o(r)) || r); return t && r && wo(e, n, r), r; }, Oe = (i, e) => (n, t) => e(n, t, i); function So(i, e, n, t, r) { const { scaleX: s, scaleY: o } = e.getAncestorScale(), c = e.getViewport(En.VIEW_MAIN), d = { left: !0, top: !0 }; if (!c) return { ...i, absolute: d }; const { left: g, right: a, top: l, bottom: h } = i; let { top: u, left: m, viewportScrollX: p, viewportScrollY: f } = c; const { boundsOfViewArea: w, scrollDirectionResponse: I } = r || {}; w && (Pe.isDefine(w.top) && (u = w.top), Pe.isDefine(w.left) && (m = w.left)), I === "HORIZONTAL" && (f = 0), I === "VERTICAL" && (p = 0); let S, R; g < m ? (d.left = !0, S = (m + (g - m)) * s, R = Math.max( Math.min( (m + (a - m)) * s, m * s ), (a - p) * s )) : (d.left = !1, S = Math.max((g - p) * s, m * s), R = Math.max((a - p) * s, m * s)); let v, C; return l < u ? (d.top = !0, v = (u + (l - u)) * o, C = Math.max( Math.min( (u + (a - u)) * o, u * o ), (h - f) * o )) : (d.top = !1, v = Math.max((l - f) * o, u * o), C = Math.max((h - f) * o, u * o)), { left: S, right: R, top: v, bottom: C, absolute: d }; } const Te = (i, e, n, t, r) => { const { scene: s } = e, { left: o, top: c, width: d, height: g, angle: a } = i, l = { left: o, right: o + d, top: c, bottom: c + g }, h = So(l, s, n, t, r), { scaleX: u, scaleY: m } = s.getAncestorScale(); return { startX: h.left, endX: h.right, startY: h.top, endY: h.bottom, rotate: a, width: d * u, height: g * m, absolute: h.absolute }; }; let Tt = class extends ie { constructor(e, n, t, r, s, o, c) { super(); /** * for update dom container position when scrolling */ J(this, "_domLayerMap", /* @__PURE__ */ new Map()); J(this, "_domLayerInfoMap", /* @__PURE__ */ new Map()); J(this, "_transformChange$", new Ht()); J(this, "transformChange$", this._transformChange$.asObservable()); J(this, "_add$", new Ht()); J(this, "add$", this._add$.asObservable()); J(this, "_remove$", new Ht()); J(this, "remove$", this._remove$.asObservable()); J(this, "_hooks", []); this._renderManagerService = e, this._univerInstanceService = n, this._commandService = t, this._drawingManagerService = r, this._canvasFloatDomService = s, this._sheetDrawingService = o, this._lifecycleService = c, this._drawingAddListener(), this._featureUpdateListener(), this._deleteListener(), this._bindScrollEvent(); } _bindScrollEvent() { this._lifecycleService.lifecycle$.pipe(ve((e) => e === Lr.Rendered), Mi(1)).subscribe(() => { this._scrollUpdateListener(); }); } _ensureMap(e, n) { let t = this._domLayerMap.get(e); t || (t = /* @__PURE__ */ new Map(), this._domLayerMap.set(e, t)); let r = t.get(n); return r || (r = /* @__PURE__ */ new Map(), t.set(n, r)), r; } getFloatDomInfo(e) { return this._domLayerInfoMap.get(e); } _getSceneAndTransformerByDrawingSearch(e) { if (e == null) return; const n = this._renderManagerService.getRenderById(e), t = n == null ? void 0 : n.scene; if (n == null || t == null) return null; const r = t.getTransformerByCreate(), s = n.engine.getCanvasElement(); return { scene: t, transformer: r, renderUnit: n, canvas: s }; } _getFloatDomProps(e) { let n; return this._hooks.forEach((t) => { n = t.onGetFloatDomProps(e); }), n; } _drawingAddListener() { this.disposeWithMe( this._drawingManagerService.add$.subscribe((e) => { e.forEach((n) => { var Se, ge, ce; const { unitId: t, subUnitId: r, drawingId: s } = n, o = V(this._univerInstanceService, { unitId: t, subUnitId: r }), c = this._drawingManagerService.getDrawingByParam(n), d = this._univerInstanceService.getUnit(t, Y.UNIVER_SHEET); if (!d) return; const g = d.getActiveSheet().getSheetId(); if (!c || !o) return; const a = (Se = this._renderManagerService.getRenderById(t)) == null ? void 0 : Se.with(Z).getWorksheetSkeleton(r); if (!a) return; const { transform: l, drawingType: h, data: u } = c; if (h !== L.DRAWING_DOM && h !== L.DRAWING_CHART) return; const m = this._getSceneAndTransformerByDrawingSearch(t); if (m == null) return; const { scene: p, canvas: f } = m; if (l == null) return !0; if (g !== r) return; const { left: w, top: I, width: S, height: R, angle: v, flipX: C, flipY: _, skewX: y, skewY: M } = l, x = Ye({ unitId: t, subUnitId: r, drawingId: s }), U = p.getObject(x); if (U != null) { U.transformByState({ left: w, top: I, width: S, height: R, angle: v, flipX: C, flipY: _, skewX: y, skewY: M }); return; } const D = { left: w, top: I, width: S, height: R, zIndex: this._drawingManagerService.getDrawingOrder(t, r).length - 1 }, b = h === L.DRAWING_CHART; if (b) { const $ = u ? u.backgroundColor : "white"; D.fill = $, D.rotateEnabled = !1, u && u.border && (D.stroke = u.border), D.paintFirst = "stroke", D.strokeWidth = 1, D.borderEnabled = !1, D.radius = 8; } const P = new lt(x, D); b && P.setObjectType(pn.CHART), p.addObject(P, Yt), c.allowTransform !== !1 && p.attachTransformerTo(P); const A = this._ensureMap(t, r), j = new ct(), B = Te(P, m.renderUnit, a.skeleton, o.worksheet), X = new He(B), se = { dispose: j, rect: P, position$: X, unitId: t, subUnitId: r }; this._canvasFloatDomService.addFloatDom({ position$: X, id: s, componentKey: c.componentKey, onPointerDown: ($) => { f.dispatchEvent(new PointerEvent($.type, $)); }, onPointerMove: ($) => { f.dispatchEvent(new PointerEvent($.type, $)); }, onPointerUp: ($) => { f.dispatchEvent(new PointerEvent($.type, $)); }, onWheel: ($) => { f.dispatchEvent(new WheelEvent($.type, $)); }, props: (ce = (ge = A.get(s)) == null ? void 0 : ge.props) != null ? ce : this._getFloatDomProps(s), data: u, unitId: t }); const oe = P.onTransformChange$.subscribeEvent(() => { const $ = Te(P, m.renderUnit, a.skeleton, o.worksheet); X.next( $ ); }); j.add(() => { this._canvasFloatDomService.removeFloatDom(s); }), oe && j.add(oe), this._domLayerInfoMap.set(s, se), A.set(s, { ...A.get(s) }); }); }) ), this.disposeWithMe( this._drawingManagerService.remove$.subscribe((e) => { e.forEach((n) => { const { unitId: t, subUnitId: r, drawingId: s } = n, o = Ye({ unitId: t, subUnitId: r, drawingId: s }), c = this._getSceneAndTransformerByDrawingSearch(t); if (c == null) return; const { transformer: d, scene: g } = c, a = g.getObject(o); a != null && a.oKey && d.clearControlByIds([a == null ? void 0 : a.oKey]); }); }) ); } _scrollUpdateListener() { const e = (n, t) => { var g; const r = this._getSceneAndTransformerByDrawingSearch(n), s = this._ensureMap(n, t), o = Array.from(s.keys()), c = V(this._univerInstanceService, { unitId: n, subUnitId: t }), d = (g = this._renderManagerService.getRenderById(n)) == null ? void 0 : g.with(Z).getWorksheetSkeleton(t); !r || !c || !d || o.forEach((a) => { const l = this._domLayerInfoMap.get(a); if (l) { const h = Te(l.rect, r.renderUnit, d.skeleton, c.worksheet, l); l.position$.next(h); } }); }; this.disposeWithMe( this._univerInstanceService.getCurrentTypeOfUnit$(Y.UNIVER_SHEET).pipe( ve((n) => !!n), Sn((n) => n.activeSheet$), ve((n) => !!n), Je((n) => { const t = this._renderManagerService.getRenderById(n.getUnitId()); return t ? { render: t, unitId: n.getUnitId(), subUnitId: n.getSheetId() } : null; }), ve((n) => !!n), Sn( (n) => Fr(n.render.scene.getViewport(En.VIEW_MAIN).onScrollAfter$).pipe(Je(() => ({ unitId: n.unitId, subUnitId: n.subUnitId }))) ) ).subscribe(({ unitId: n, subUnitId: t }) => { e(n, t); }) ), this.disposeWithMe(this._commandService.onCommandExecuted((n) => { var t, r; if (n.id === _n.id) { const s = n.params, { unitId: o } = s; Array.from((r = (t = this._domLayerMap.get(o)) == null ? void 0 : t.keys()) != null ? r : []).forEach((d) => { e(o, d); }); } else if (n.id === ki.id) { const { unitId: s, subUnitId: o } = n.params; e(s, o); } })); } _getPosition(e, n) { var h; const { startX: t, endX: r, startY: s, endY: o } = e, c = (h = this._renderManagerService.getRenderById(n)) == null ? void 0 : h.with(Qe); if (c == null) return; const d = c.getCellWithCoordByOffset(t, s); if (d == null) return; const g = { column: d.actualColumn, columnOffset: t - d.startX, row: d.actualRow, rowOffset: s - d.startY }, a = c.getCellWithCoordByOffset(r, o); if (a == null) return; const l = { column: a.actualColumn, columnOffset: r - a.startX, row: a.actualRow, rowOffset: o - a.startY }; return { from: g, to: l }; } _featureUpdateListener() { this.disposeWithMe( this._drawingManagerService.update$.subscribe((e) => { e.forEach((n) => { const t = this._drawingManagerService.getDrawingByParam(n); if (!t || t.drawingType !== L.DRAWING_DOM && t.drawingType !== L.DRAWING_CHART) return; const r = { ...t.transform }; this._transformChange$.next({ id: n.drawingId, value: r }); }); }) ); } _deleteListener() { this.disposeWithMe( this._drawingManagerService.remove$.subscribe((e) => { e.forEach((n) => { this._removeDom(n.drawingId); }); }) ); } updateFloatDomProps(e, n, t, r) { const s = this._domLayerInfoMap.get(t), o = this._getSceneAndTransformerByDrawingSearch(e); if (s && o) { const { scene: c } = o, d = Ye({ unitId: e, subUnitId: n, drawingId: t }), g = c.getObject(d); g && g instanceof lt && g.setProps(r); } } // CreateFloatDomCommand --> floatDomService.addFloatDomToPosition addFloatDomToPosition(e, n) { const t = V(this._univerInstanceService, { unitId: e.unitId, subUnitId: e.subUnitId }); if (!t) throw new Error("cannot find current target!"); const { unitId: r, subUnitId: s } = t, { initPosition: o, componentKey: c, data: d, allowTransform: g = !0 } = e, a = n != null ? n : Gt(), l = this._getPosition(o, r); if (l == null) return; this._ensureMap(r, s).set(a, e); const u = { unitId: r, subUnitId: s, drawingId: a, drawingType: e.type || L.DRAWING_DOM, componentKey: c, sheetTransform: l, transform: { left: o.startX, top: o.startY, width: o.endX - o.startX, height: o.endY - o.startY }, data: d, allowTransform: g }; return this._commandService.executeCommand(jt.id, { unitId: r, drawings: [u] }), this._add$.next({ unitId: r, subUnitId: s, id: a }), { id: a, dispose: () => { this._removeDom(a, !0); } }; } _removeDom(e, n = !1) { const t = this._domLayerInfoMap.get(e); if (!t) return; const { unitId: r, subUnitId: s } = t; this._domLayerInfoMap.delete(e), t.dispose.dispose(); const o = this._getSceneAndTransformerByDrawingSearch(r); if (o && o.scene.removeObject(t.rect), n) { this._ensureMap(r, s).delete(e); const d = this._drawingManagerService.getDrawingByParam({ unitId: r, subUnitId: s, drawingId: e }); if (!d) return; const g = this._sheetDrawingService.getBatchRemoveOp([d]), { redo: a, objects: l } = g; this._commandService.syncExecuteCommand(T.id, { unitId: r, subUnitId: s, op: a, objects: l, type: E.REMOVE }); } } addHook(e) { return this._hooks.push(e), { dispose: () => { const n = this._hooks.findIndex((t) => t === e); this._hooks.splice(n, 1); } }; } addFloatDomToRange(e, n, t, r) { var M, x, U, D, b, P; const s = V(this._univerInstanceService, { unitId: n.unitId, subUnitId: n.subUnitId }); if (!s) throw new Error("cannot find current target!"); const { unitId: o, subUnitId: c } = s; if (!this._getSceneAndTransformerByDrawingSearch(o)) return; const g = this._renderManagerService.getRenderById(o); if (!g) return; const a = (M = this._renderManagerService.getRenderById(o)) == null ? void 0 : M.with(Z).getWorksheetSkeleton(c); if (!a) return; const { componentKey: l, data: h, allowTransform: u = !0 } = n, m = r != null ? r : Gt(), { position: p } = this._createRangePositionObserver(e, g, a.skeleton), f = this._getPosition(p, o); if (f == null) return; this._ensureMap(o, c).set(m, n); const I = p.endX - p.startX, S = p.endY - p.startY, R = (x = t.width) != null ? x : I, v = (U = t.height) != null ? U : S, C = p.startX + je(t.marginX, I), _ = p.startY + je(t.marginY, S), y = { unitId: o, subUnitId: c, drawingId: m, drawingType: n.type || L.DRAWING_DOM, componentKey: l, sheetTransform: f, transform: { left: C, top: _, width: R, height: v }, data: h, allowTransform: u }; { const { unitId: A, subUnitId: j, drawingId: B } = y, X = V(this._univerInstanceService, { unitId: A, subUnitId: j }), se = y, oe = this._univerInstanceService.getUnit(A, Y.UNIVER_SHEET); if (!oe) return; const Se = oe.getActiveSheet().getSheetId(); if (!se || !X) return; const ge = (D = this._renderManagerService.getRenderById(A)) == null ? void 0 : D.with(Z).getWorksheetSkeleton(j); if (!ge) return; const { transform: ce, drawingType: $, data: de } = se; if ($ !== L.DRAWING_DOM && $ !== L.DRAWING_CHART) return; const Ue = this._getSceneAndTransformerByDrawingSearch(A); if (Ue == null) return; const { scene: le, canvas: ue } = Ue; if (ce == null || Se !== j) return; const { left: Ie, top: ke, width: Le, height: Fe, angle: nt, flipX: xt, flipY: Bt, skewX: $t, skewY: kt } = ce, rt = Ye({ unitId: A, subUnitId: j, drawingId: B }), Ge = le.getObject(rt); if (Ge != null) { Ge.transformByState({ left: Ie, top: ke, width: Le, height: Fe, angle: nt, flipX: xt, flipY: Bt, skewX: $t, skewY: kt }); return; } const re = { left: Ie, top: ke, width: Le, height: Fe, zIndex: this._drawingManagerService.getDrawingOrder(A, j).length - 1 }, it = $ === L.DRAWING_CHART; if (it) { const W = de ? de.backgroundColor : "white"; re.fill = W, re.rotateEnabled = !1, de && de.border && (re.stroke = de.border), re.paintFirst = "stroke", re.strokeWidth = 1, re.borderEnabled = !1, re.radius = 8; } const K = new lt(rt, re); it && K.setObjectType(pn.CHART), le.addObject(K, Yt), se.allowTransform !== !1 && le.attachTransformerTo(K); const Ce = this._ensureMap(A, j), Re = new ct(), me = le.getMainViewport(), Lt = { top: me.top, left: me.left, bottom: me.bottom, right: me.right }, he = { dispose: Re, rect: K, boundsOfViewArea: Lt, // position$, unitId: A, subUnitId: j }, Ft = Te(K, Ue.renderUnit, ge.skeleton, X.worksheet, he), be = new He(Ft); he.position$ = be; let De = { position$: be, id: B, componentKey: se.componentKey, onPointerDown: () => { }, onPointerMove: () => { }, onPointerUp: () => { }, onWheel: (W) => { ue.dispatchEvent(new WheelEvent(W.type, W)); }, props: (P = (b = Ce.get(B)) == null ? void 0 : b.props) != null ? P : this._getFloatDomProps(B), data: de, unitId: A }; n.eventPassThrough && (De = { ...De, onPointerDown: (W) => { ue.dispatchEvent(new PointerEvent(W.type, W)); }, onPointerMove: (W) => { ue.dispatchEvent(new PointerEvent(W.type, W)); }, onPointerUp: (W) => { ue.dispatchEvent(new PointerEvent(W.type, W)); } }), this._canvasFloatDomService.addFloatDom(De); const Ve = K.onTransformChange$.subscribeEvent(() => { const W = Te(K, Ue.renderUnit, ge.skeleton, X.worksheet, he); be.next( W ); }); Re.add(() => { this._canvasFloatDomService.removeFloatDom(B); }), Ve && Re.add(Ve), this._domLayerInfoMap.set(B, he), Ce.set(B, { ...Ce.get(B) }); } return { id: m, dispose: () => { this._removeDom(m, !0); } }; } addFloatDomToColumnHeader(e, n, t, r) { var x, U, D, b, P, A; const s = V(this._univerInstanceService, { unitId: n.unitId, subUnitId: n.subUnitId }); if (!s) throw new Error("cannot find current target!"); const { unitId: o, subUnitId: c } = s; if (!this._getSceneAndTransformerByDrawingSearch(o)) return; const g = this._renderManagerService.getRenderById(o); if (!g) return; const a = (x = this._renderManagerService.getRenderById(o)) == null ? void 0 : x.with(Z).getWorksheetSkeleton(c); if (!a) return; const { componentKey: l, data: h, allowTransform: u = !0 } = n, m = r != null ? r : Gt(), { position: p } = this._createRangePositionObserver({ startRow: 0, endRow: 0, startColumn: e, endColumn: e }, g, a.skeleton), f = p; f.startY = 0; const w = this._getPosition(p, o); if (w == null) return; this._ensureMap(o, c).set(m, n); const S = p.endX - p.startX, R = p.endY - p.startY, v = (U = t.width) != null ? U : S, C = (D = t.height) != null ? D : R; let _ = 0, y = 0; if (t.horizonOffsetAlign === "right") { const j = je(t.marginX, S); _ = f.endX - j - v; } else _ = f.startX + je(t.marginX, S); if (t.verticalOffsetAlign === "bottom") { const j = je(t.marginY, R); y = f.endY - j - C; } else y = f.startY + je(t.marginY, R); const M = { unitId: o, subUnitId: c, drawingId: m, drawingType: n.type || L.DRAWING_DOM, componentKey: l, sheetTransform: w, transform: { left: _, top: y, width: v, height: C }, data: h, allowTransform: u }; { const { unitId: j, subUnitId: B, drawingId: X } = M, se = V(this._univerInstanceService, { unitId: j, subUnitId: B }), oe = M, Se = this._univerInstanceService.getUnit(j, Y.UNIVER_SHEET); if (!Se) return; const ge = Se.getActiveSheet().getSheetId(); if (!oe || !se) return; const ce = (b = this._renderManagerService.getRenderById(j)) == null ? void 0 : b.with(Z).getWorksheetSkeleton(B); if (!ce) return; const { transform: $, drawingType: de, data: Ue } = oe; if (de !== L.DRAWING_DOM && de !== L.DRAWING_CHART) return; const le = this._getSceneAndTransformerByDrawingSearch(j); if (le == null) return; const { scene: ue, canvas: Ie } = le; if ($ == null || ge !== B) return; const { left: ke, top: Le, width: Fe, height: nt, angle: xt, flipX: Bt, flipY: $t, skewX: kt, skewY: rt } = $, Ge = Ye({ unitId: j, subUnitId: B, drawingId: X }), re = ue.getObject(Ge); if (re != null) { re.transformByState({ left: ke, top: Le, width: Fe, height: nt, angle: xt, flipX: Bt, flipY: $t, skewX: kt, skewY: rt }); return; } const it = { left: ke, top: Le, width: Fe, height: nt, zIndex: this._drawingManagerService.getDrawingOrder(j, B).length - 1 }, K = new lt(Ge, it); ue.addObject(K, Yt), oe.allowTransform !== !1 && ue.attachTransformerTo(K); const Ce = this._ensureMap(j, B), Re = new ct(), me = ue.getMainViewport(), Lt = { top: 0, //viewMain.top, left: me.left, bottom: me.bottom, right: me.right }, he = { dispose: Re, rect: K, // position$, unitId: j, subUnitId: B, boundsOfViewArea: Lt, scrollDirectionResponse: "HORIZONTAL" /* HORIZONTAL */ }, Ft = Te(K, le.renderUnit, ce.skeleton, se.worksheet, he), be = new He(Ft); he.position$ = be; let De = { position$: be, id: X, componentKey: oe.componentKey, onPointerDown: () => { }, onPointerMove: () => { }, onPointerUp: () => { }, onWheel: (W) => { Ie.dispatchEvent(new WheelEvent(W.type, W)); }, props: (A = (P = Ce.get(X)) == null ? void 0 : P.props) != null ? A : this._getFloatDomProps(X), data: Ue, unitId: j }; n.eventPassThrough && (De = { ...De, onPointerDown: (W) => { Ie.dispatchEvent(new PointerEvent(W.type, W)); }, onPointerMove: (W) => { Ie.dispatchEvent(new PointerEvent(W.type, W)); }, onPointerUp: (W) => { Ie.dispatchEvent(new PointerEvent(W.type, W)); } }), this._canvasFloatDomService.addFloatDom(De); const Ve = K.onTransformChange$.subscribeEvent(() => { const W = Te(K, le.renderUnit, ce.skeleton, se.worksheet, he); be.next( W ); }); Re.add(() => { this._canvasFloatDomService.removeFloatDom(X); }), Ve && Re.add(Ve), this._domLayerInfoMap.set(X, he), Ce.set(X, { ...Ce.get(X) }); } return { id: m, dispose: () => { this._removeDom(m, !0); } }; } /** * Unlike _createCellPositionObserver, this accept a range not a single cell. * * @param initialRow * @param initialCol * @param currentRender * @param skeleton * @param activeViewport * @returns position of cell to canvas. */ _createRangePositionObserver(e, n, t) { let { startRow: r, startColumn: s } = e; const o = Ke(r, s, t), c = new He(o), d = Ke(e.endRow, e.endColumn, t), g = new He(d), a = () => { const f = Ke(r, s, t), w = Ke(e.endRow, e.endColumn, t); c.next(f), g.next(w); }, l = new ct(); l.add(n.engine.clientRect$.subscribe(() => a())), l.add(this._commandService.onCommandExecuted((f) => { if (f.id === Wn.id && f.params.rowsAutoHeightInfo.findIndex((I) => I.row === r) > -1) { a(); return; } (Li.indexOf(f.id) > -1 || f.id === fi.id || f.id === _n.id) && a(); })); const h = (f, w) => { r = f, s = w, a(); }, u = () => ({ rotate: 0, width: d.right - o.left, height: d.bottom - o.top, absolute: { left: !0, top: !0 }, startX: o.left, startY: o.top, endX: d.right, endY: d.bottom }), m = c.pipe( Je((f) => { const w = Ke(e.endRow, e.endColumn, t); return console.log("service", f.left, f.top), { rotate: 0, width: w.right - f.left, height: w.bottom - f.top, absolute: { left: !0, top: !0 }, startX: f.left, startY: f.top, endX: w.right, endY: w.bottom }; }) ), p = u(); return console.log("init position", p), { position$: m, position: p, updateRowCol: h, topLeftPos$: c, rightBottomPos$: g, disposable: l }; } }; Tt = vo([ Oe(0, N(Q)), Oe(1, $e), Oe(2, N(H)), Oe(3, ae), Oe(4, N(Di)), Oe(5, ee), Oe(6, N(kr)) ], Tt); function Ke(i, e, n) { const t = n.getCellWithCoordByIndex(i, e), r = t.isMergedMainCell ? t.mergeInfo : t; return { left: r.startX, right: r.endX, top: r.startY, bottom: r.endY }; } function je(i, e) { if (i === void 0) return 0; if (typeof i == "number") return i; const n = Number.parseFloat(i); return e * n / 100; } var wr = Object.defineProperty, Io = Object.getOwnPropertyDescriptor, Co = (i, e, n) => e in i ? wr(i, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : i[e] = n, Ro = (i, e, n, t) => { for (var r = t > 1 ? void 0 : t ? Io(e, n) : e, s = i.length - 1, o; s >= 0; s--) (o = i[s]) && (r = (t ? o(e, n, r) : o(r)) || r); return t && r && wr(e, n, r), r; }, Zt = (i, e) => (n, t) => e(n, t, i), _r = (i, e, n) => Co(i, typeof e != "symbol" ? e + "" : e, n); const bo = "SHEET_IMAGE_UI_PLUGIN"; let Et = class extends Vr { constructor(i = Cn, e, n, t) { super(), this._config = i, this._injector = e, this._renderManagerService = n, this._configService = t; const { menu: r, ...s } = Yr( {}, Cn, this._config ); r && this._configService.setConfig("menu", r, { merge: !0 }), this._configService.setConfig(Hi, s); } onStarting() { Hr(this._injector, [ [Tt], [Ot], [It], [yt], [Mt], [Dt], [Ct], [bt], [Rt] ]), Vt(this._injector, [ [Tt] ]); } onReady() { Vt(this._injector, [ [Dt] ]); } onRendered() { this._registerRenderModules(), Vt(this._injector, [ [Mt], [yt], [Ot], [Ct], [bt], [Rt] ]); } onSteady() { this._injector.get(It); } _registerRenderModules() { [ [Ze], [sn], [nn] ].forEach((i) => { this.disposeWithMe(this._renderManagerService.registerRenderModule(Y.UNIVER_SHEET, i)); }); } }; _r(Et, "type", Y.UNIVER_SHEET); _r(Et, "pluginName", bo); Et = Ro([ Gr(Jr, Kr, ni, si), Zt(1, N(qe)), Zt(2, Q), Zt(3, Xr) ], Et); export { F as ClearSheetDrawingTransformerOperation, gr as DeleteDrawingsCommand, sr as EditSheetDrawingOperation, or as GroupSheetDrawingCommand, cn as InsertFloatImageCommand, jt as InsertSheetDrawingCommand, et as MoveDrawingsCommand, Nt as RemoveSheetDrawingCommand, fr as SHEETS_IMAGE_MENU_ID, ar as SetDrawingArrangeCommand, Wt as SetSheetDrawingCommand, Tt as SheetCanvasFloatDomManagerService, ir as SidebarSheetDrawingOperation, cr as UngroupSheetDrawingCommand, Et as UniverSheetsDrawingUIPlugin };