@univerjs/sheets-drawing-ui 0.2.3 → 0.2.4-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/index.js +1 -1
- package/lib/es/index.js +565 -549
- package/lib/types/controllers/drawing-popup-menu.controller.d.ts +1 -2
- package/lib/types/controllers/sheet-drawing.controller.d.ts +1 -2
- package/lib/types/plugin.d.ts +1 -2
- package/lib/types/services/canvas-float-dom-manager.service.d.ts +8 -4
- package/lib/types/views/menu/image.menu.d.ts +1 -1
- package/lib/umd/index.js +1 -1
- package/package.json +23 -25
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { IContextService, IUniverInstanceService, RxDisposable } from '@univerjs/core';
|
|
2
|
-
import { Injector } from '@wendellhu/redi';
|
|
1
|
+
import { IContextService, Injector, IUniverInstanceService, RxDisposable } from '@univerjs/core';
|
|
3
2
|
import { IRenderManagerService } from '@univerjs/engine-render';
|
|
4
3
|
import { SheetCanvasPopManagerService } from '@univerjs/sheets-ui';
|
|
5
4
|
import { IDrawingManagerService } from '@univerjs/drawing';
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { DependencyOverride, Disposable, ICommandService } from '@univerjs/core';
|
|
1
|
+
import { DependencyOverride, Disposable, ICommandService, Injector } from '@univerjs/core';
|
|
2
2
|
import { MenuConfig, ComponentManager, IMenuService, IShortcutService } from '@univerjs/ui';
|
|
3
|
-
import { Injector } from '@wendellhu/redi';
|
|
4
3
|
|
|
5
4
|
export interface IUniverSheetsDrawingConfig {
|
|
6
5
|
menu?: MenuConfig;
|
package/lib/types/plugin.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { LocaleService, Plugin, UniverInstanceType } from '@univerjs/core';
|
|
2
|
-
import { Injector } from '@wendellhu/redi';
|
|
1
|
+
import { Injector, LocaleService, Plugin, UniverInstanceType } from '@univerjs/core';
|
|
3
2
|
import { IRenderManagerService } from '@univerjs/engine-render';
|
|
4
3
|
import { IUniverSheetsDrawingConfig } from './controllers/sheet-drawing.controller';
|
|
5
4
|
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { IPosition, ITransformState, Worksheet, Disposable, ICommandService, IUniverInstanceService } from '@univerjs/core';
|
|
1
|
+
import { IDisposable, IPosition, ITransformState, Worksheet, Disposable, ICommandService, IUniverInstanceService } from '@univerjs/core';
|
|
2
2
|
import { IDrawingManagerService } from '@univerjs/drawing';
|
|
3
3
|
import { IBoundRectNoAngle, Scene, SpreadsheetSkeleton, IRenderManagerService } from '@univerjs/engine-render';
|
|
4
4
|
import { ISheetDrawingService } from '@univerjs/sheets-drawing';
|
|
5
|
-
import { ISheetSelectionRenderService } from '@univerjs/sheets-ui';
|
|
6
5
|
import { CanvasFloatDomService } from '@univerjs/ui';
|
|
7
6
|
|
|
8
7
|
export interface ICanvasFloatDom {
|
|
@@ -23,12 +22,14 @@ export declare function transformBound2DOMBound(originBound: IBoundRectNoAngle,
|
|
|
23
22
|
right: number;
|
|
24
23
|
bottom: number;
|
|
25
24
|
};
|
|
25
|
+
export interface ISheetCanvasFloatDomHook {
|
|
26
|
+
onGetFloatDomProps: (id: string) => Record<string, any>;
|
|
27
|
+
}
|
|
26
28
|
export declare class SheetCanvasFloatDomManagerService extends Disposable {
|
|
27
29
|
private _renderManagerService;
|
|
28
30
|
private _univerInstanceService;
|
|
29
31
|
private _commandService;
|
|
30
32
|
private _drawingManagerService;
|
|
31
|
-
private readonly _selectionRenderService;
|
|
32
33
|
private readonly _canvasFloatDomService;
|
|
33
34
|
private readonly _sheetDrawingService;
|
|
34
35
|
private _domLayerMap;
|
|
@@ -44,9 +45,11 @@ export declare class SheetCanvasFloatDomManagerService extends Disposable {
|
|
|
44
45
|
subUnitId: string;
|
|
45
46
|
id: string;
|
|
46
47
|
}>;
|
|
47
|
-
|
|
48
|
+
private _hooks;
|
|
49
|
+
constructor(_renderManagerService: IRenderManagerService, _univerInstanceService: IUniverInstanceService, _commandService: ICommandService, _drawingManagerService: IDrawingManagerService, _canvasFloatDomService: CanvasFloatDomService, _sheetDrawingService: ISheetDrawingService);
|
|
48
50
|
private _ensureMap;
|
|
49
51
|
private _getSceneAndTransformerByDrawingSearch;
|
|
52
|
+
private _getFloatDomProps;
|
|
50
53
|
private _drawingAddListener;
|
|
51
54
|
private _scrollUpdateListener;
|
|
52
55
|
private _getPosition;
|
|
@@ -57,4 +60,5 @@ export declare class SheetCanvasFloatDomManagerService extends Disposable {
|
|
|
57
60
|
dispose: () => void;
|
|
58
61
|
} | undefined;
|
|
59
62
|
private _removeDom;
|
|
63
|
+
addHook(hook: ISheetCanvasFloatDomHook): IDisposable;
|
|
60
64
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { IMenuItem } from '@univerjs/ui';
|
|
2
|
-
import { IAccessor } from '@
|
|
2
|
+
import { IAccessor } from '@univerjs/core';
|
|
3
3
|
|
|
4
4
|
export declare const IMAGE_UPLOAD_ICON = "addition-and-subtraction-single";
|
|
5
5
|
export declare function ImageMenuFactory(accessor: IAccessor): IMenuItem;
|
package/lib/umd/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(T,p){typeof exports=="object"&&typeof module<"u"?p(exports,require("@univerjs/core"),require("@wendellhu/redi"),require("@univerjs/drawing-ui"),require("@univerjs/sheets-drawing"),require("@univerjs/drawing"),require("@univerjs/engine-render"),require("@univerjs/sheets-ui"),require("rxjs"),require("@univerjs/ui"),require("@wendellhu/redi/react-bindings"),require("@univerjs/sheets"),require("react"),require("@univerjs/design"),require("clsx")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@wendellhu/redi","@univerjs/drawing-ui","@univerjs/sheets-drawing","@univerjs/drawing","@univerjs/engine-render","@univerjs/sheets-ui","rxjs","@univerjs/ui","@wendellhu/redi/react-bindings","@univerjs/sheets","react","@univerjs/design","clsx"],p):(T=typeof globalThis<"u"?globalThis:T||self,p(T.UniverSheetsDrawingUi={},T.UniverCore,T["@wendellhu/redi"],T.UniverDrawingUi,T.UniverSheetsDrawing,T.UniverDrawing,T.UniverEngineRender,T.UniverSheetsUi,T.rxjs,T.UniverUi,T["@wendellhu/redi/react-bindings"],T.UniverSheets,T.React,T.UniverDesign,T.clsx))})(this,function(T,p,B,Q,h,A,L,$,k,F,q,_,N,J,me){"use strict";var Ft=Object.defineProperty;var kt=(T,p,B)=>p in T?Ft(T,p,{enumerable:!0,configurable:!0,writable:!0,value:B}):T[p]=B;var z=(T,p,B)=>kt(T,typeof p!="symbol"?p+"":p,B);const G={id:"sheet.operation.clear-drawing-transformer",type:p.CommandType.MUTATION,handler:(i,t)=>{const n=i.get(L.IRenderManagerService);return t.forEach(e=>{var r,o;(o=(r=n.getRenderById(e))==null?void 0:r.scene.getTransformer())==null||o.debounceRefreshControls()}),!0}},ge={id:"sheet.command.remove-sheet-image",type:p.CommandType.COMMAND,handler:(i,t)=>{const n=i.get(p.ICommandService),e=i.get(p.IUndoRedoService),r=i.get(h.ISheetDrawingService);if(!t)return!1;const{drawings:o}=t,a=[];o.forEach(S=>{const{unitId:f}=S;a.push(f)});const s=r.getBatchRemoveOp(o),{unitId:l,subUnitId:u,undo:d,redo:c,objects:m}=s;return n.syncExecuteCommand(h.SetDrawingApplyMutation.id,{unitId:l,subUnitId:u,op:c,objects:m,type:h.DrawingApplyType.REMOVE})?(e.pushUndoRedo({unitID:l,undoMutations:[{id:h.SetDrawingApplyMutation.id,params:{unitId:l,subUnitId:u,op:d,objects:m,type:h.DrawingApplyType.INSERT}},{id:G.id,params:a}],redoMutations:[{id:h.SetDrawingApplyMutation.id,params:{unitId:l,subUnitId:u,op:c,objects:m,type:h.DrawingApplyType.REMOVE}},{id:G.id,params:a}]}),!0):!1}},Ue="COMPONENT_SHEET_DRAWING_PANEL",Me={id:"sidebar.operation.sheet-image",type:p.CommandType.COMMAND,handler:async(i,t)=>{const n=i.get(F.ISidebarService),e=i.get(p.LocaleService),r=i.get(p.IUniverInstanceService),o=i.get(A.IDrawingManagerService);if(!_.getSheetCommandTarget(r))return!1;switch(t.value){case"open":n.open({header:{title:e.t("sheetImage.panel.title")},children:{label:Ue},onClose:()=>{o.focusDrawing(null)},width:360});break;case"close":default:n.close();break}return!0}},De={id:"sheet.operation.edit-sheet-image",type:p.CommandType.OPERATION,handler:(i,t)=>{const n=i.get(A.IDrawingManagerService),e=i.get(p.ICommandService);return t==null?!1:(n.focusDrawing([t]),e.executeCommand(Me.id,{value:"open"}),!0)}},pe={uploadLoading:"univer-upload-loading",uploadLoadingBody:"univer-upload-loading-body",uploadLoadingBodyAnimation:"univer-upload-loading-body-animation",univerCircleAnimation:"univer-UniverCircleAnimation",uploadLoadingBodyText:"univer-upload-loading-body-text"},Xe=()=>{const i=q.useDependency(A.IImageIoService),t=q.useDependency(p.LocaleService),[n,e]=N.useState(0);return N.useEffect(()=>{const r=i.change$.subscribe(o=>{e(o)});return()=>{r.unsubscribe()}},[i]),N.createElement("div",{style:{display:n>0?"block":"none"},className:pe.uploadLoading},N.createElement("div",{className:pe.uploadLoadingBody},N.createElement("div",{className:pe.uploadLoadingBodyAnimation}),N.createElement("div",{className:pe.uploadLoadingBodyText},`${t.t("uploadLoading.loading")}: ${n}`)))};var xe=Object.defineProperty,Ke=Object.getOwnPropertyDescriptor,ze=(i,t,n,e)=>{for(var r=e>1?void 0:e?Ke(t,n):t,o=i.length-1,a;o>=0;o--)(a=i[o])&&(r=(e?a(t,n,r):a(r))||r);return e&&r&&xe(t,n,r),r},ee=(i,t)=>(n,e)=>t(n,e,i);let he=class extends p.RxDisposable{constructor(t,n,e,r,o,a,s){super();z(this,"_initImagePopupMenu",new Set);this._injector=t,this._drawingManagerService=n,this._canvasPopManagerService=e,this._renderManagerService=r,this._univerInstanceService=o,this._contextService=a,this._uiPartsService=s,this._init()}_init(){this._univerInstanceService.getCurrentTypeOfUnit$(p.UniverInstanceType.UNIVER_SHEET).pipe(k.takeUntil(this.dispose$)).subscribe(t=>this._create(t)),this._univerInstanceService.getTypeOfUnitDisposed$(p.UniverInstanceType.UNIVER_SHEET).pipe(k.takeUntil(this.dispose$)).subscribe(t=>this._dispose(t)),this._univerInstanceService.getAllUnitsForType(p.UniverInstanceType.UNIVER_SHEET).forEach(t=>this._create(t)),this._uiPartsService.registerComponent(F.BuiltInUIPart.CONTENT,()=>q.connectInjector(Xe,this._injector))}_dispose(t){const n=t.getUnitId();this._renderManagerService.removeRender(n)}_create(t){if(!t)return;const n=t.getUnitId();this._renderManagerService.has(n)&&!this._initImagePopupMenu.has(n)&&(this._popupMenuListener(n),this._initImagePopupMenu.add(n))}_hasCropObject(t){const n=t.getAllObjects();for(const e of n)if(e instanceof Q.ImageCropperObject)return!0;return!1}_popupMenuListener(t){var o;const n=(o=this._renderManagerService.getRenderById(t))==null?void 0:o.scene;if(!n)return;const e=n.getTransformerByCreate();if(!e)return;let r;this.disposeWithMe(p.toDisposable(e.createControl$.subscribe(()=>{if(this._contextService.setContextValue(p.FOCUSING_COMMON_DRAWINGS,!0),this._hasCropObject(n))return;const a=e.getSelectedObjectMap();if(a.size>1){r==null||r.dispose();return}const s=a.values().next().value;if(!s)return;const l=s.oKey,u=this._drawingManagerService.getDrawingOKey(l);if(!u)return;const{unitId:d,subUnitId:c,drawingId:m}=u;r==null||r.dispose(),r=this.disposeWithMe(this._canvasPopManagerService.attachPopupToObject(s,{componentKey:Q.COMPONENT_IMAGE_POPUP_MENU,direction:"horizontal",offset:[2,0],extraProps:{menuItems:this._getImageMenuItems(d,c,m)}})),this._drawingManagerService.focusDrawing([{unitId:d,subUnitId:c,drawingId:m}])}))),this.disposeWithMe(e.clearControl$.subscribe(()=>{r==null||r.dispose(),this._contextService.setContextValue(p.FOCUSING_COMMON_DRAWINGS,!1),this._drawingManagerService.focusDrawing(null)})),this.disposeWithMe(e.changing$.subscribe(()=>{r==null||r.dispose()}))}_getImageMenuItems(t,n,e){return[{label:"image-popup.edit",index:0,commandId:De.id,commandParams:{unitId:t,subUnitId:n,drawingId:e},disable:!1},{label:"image-popup.delete",index:1,commandId:ge.id,commandParams:{unitId:t,drawings:[{unitId:t,subUnitId:n,drawingId:e}]},disable:!1},{label:"image-popup.crop",index:2,commandId:Q.OpenImageCropOperation.id,commandParams:{unitId:t,subUnitId:n,drawingId:e},disable:!1},{label:"image-popup.reset",index:3,commandId:Q.ImageResetSizeOperation.id,commandParams:[{unitId:t,subUnitId:n,drawingId:e}],disable:!1}]}};he=ze([p.OnLifecycle(p.LifecycleStages.Steady,he),ee(0,B.Inject(B.Injector)),ee(1,A.IDrawingManagerService),ee(2,B.Inject($.SheetCanvasPopManagerService)),ee(3,L.IRenderManagerService),ee(4,p.IUniverInstanceService),ee(5,p.IContextService),ee(6,B.Inject(F.IUIPartsService))],he);const oe={id:"sheet.operation.insert-float-image",type:p.CommandType.OPERATION,handler:(i,t)=>!0},ae={id:"sheet.operation.insert-cell-image",type:p.CommandType.OPERATION,handler:(i,t)=>!0},fe={id:"sheet.command.insert-sheet-image",type:p.CommandType.COMMAND,handler:(i,t)=>{const n=i.get(p.ICommandService),e=i.get(p.IUndoRedoService),r=i.get(h.ISheetDrawingService);if(!t)return!1;const o=t.drawings,a=o.map(S=>S.unitId),s=r.getBatchAddOp(o),{unitId:l,subUnitId:u,undo:d,redo:c,objects:m}=s;return n.syncExecuteCommand(h.SetDrawingApplyMutation.id,{op:c,unitId:l,subUnitId:u,objects:m,type:h.DrawingApplyType.INSERT})?(e.pushUndoRedo({unitID:l,undoMutations:[{id:h.SetDrawingApplyMutation.id,params:{op:d,unitId:l,subUnitId:u,objects:m,type:h.DrawingApplyType.REMOVE}},{id:G.id,params:a}],redoMutations:[{id:h.SetDrawingApplyMutation.id,params:{op:c,unitId:l,subUnitId:u,objects:m,type:h.DrawingApplyType.INSERT}},{id:G.id,params:a}]}),!0):!1}},se={id:"sheet.command.set-sheet-image",type:p.CommandType.COMMAND,handler:(i,t)=>{const n=i.get(p.ICommandService),e=i.get(p.IUndoRedoService),r=i.get(h.ISheetDrawingService);if(!t)return!1;const{drawings:o}=t,a=r.getBatchUpdateOp(o),{unitId:s,subUnitId:l,undo:u,redo:d,objects:c}=a;return n.syncExecuteCommand(h.SetDrawingApplyMutation.id,{unitId:s,subUnitId:l,op:d,objects:c,type:h.DrawingApplyType.UPDATE})?(e.pushUndoRedo({unitID:s,undoMutations:[{id:h.SetDrawingApplyMutation.id,params:{unitId:s,subUnitId:l,op:u,objects:c,type:h.DrawingApplyType.UPDATE}},{id:G.id,params:[s]}],redoMutations:[{id:h.SetDrawingApplyMutation.id,params:{unitId:s,subUnitId:l,op:d,objects:c,type:h.DrawingApplyType.UPDATE}},{id:G.id,params:[s]}]}),!0):!1}},Te={id:"sheet.command.set-drawing-arrange",type:p.CommandType.COMMAND,handler:(i,t)=>{const n=i.get(p.ICommandService),e=i.get(p.IUndoRedoService);if(!t)return!1;const r=i.get(h.ISheetDrawingService),{unitId:o,subUnitId:a,drawingIds:s,arrangeType:l}=t,u={unitId:o,subUnitId:a,drawingIds:s};let d;if(l===A.ArrangeTypeEnum.forward?d=r.getForwardDrawingsOp(u):l===A.ArrangeTypeEnum.backward?d=r.getBackwardDrawingOp(u):l===A.ArrangeTypeEnum.front?d=r.getFrontDrawingsOp(u):l===A.ArrangeTypeEnum.back&&(d=r.getBackDrawingsOp(u)),d==null)return!1;const{objects:c,redo:m,undo:g}=d;return n.syncExecuteCommand(h.SetDrawingApplyMutation.id,{op:m,unitId:o,subUnitId:a,objects:c,type:h.DrawingApplyType.ARRANGE})?(e.pushUndoRedo({unitID:o,undoMutations:[{id:h.SetDrawingApplyMutation.id,params:{op:g,unitId:o,subUnitId:a,objects:c,type:h.DrawingApplyType.ARRANGE}}],redoMutations:[{id:h.SetDrawingApplyMutation.id,params:{op:m,unitId:o,subUnitId:a,objects:c,type:h.DrawingApplyType.ARRANGE}}]}),!0):!1}};function qe(i){const t=[];return i.forEach(n=>{const{parent:e,children:r}=n,{unitId:o,subUnitId:a,drawingId:s}=e,l=L.getGroupState(0,0,r.map(c=>c.transform||{})),u=r.map(c=>{const m=c.transform||{left:0,top:0},{unitId:g,subUnitId:S,drawingId:f}=c;return{unitId:g,subUnitId:S,drawingId:f,transform:{...m,left:m.left-l.left,top:m.top-l.top},groupId:s}}),d={unitId:o,subUnitId:a,drawingId:s,drawingType:A.DrawingTypeEnum.DRAWING_GROUP,transform:l};t.push({parent:d,children:u})}),t}function Je(i){const t=[];return i.forEach(n=>{const{parent:e,children:r}=n,{unitId:o,subUnitId:a,drawingId:s,transform:l={width:0,height:0}}=e;if(l==null)return;const u=r.map(c=>{const{transform:m}=c,{unitId:g,subUnitId:S,drawingId:f}=c,v=L.transformObjectOutOfGroup(m||{},l,l.width||0,l.height||0);return{unitId:g,subUnitId:S,drawingId:f,transform:v,groupId:void 0}}),d={unitId:o,subUnitId:a,drawingId:s,drawingType:A.DrawingTypeEnum.DRAWING_GROUP,transform:{left:0,top:0}};t.push({parent:d,children:u})}),t}const Re={id:"sheet.command.group-sheet-image",type:p.CommandType.COMMAND,handler:(i,t)=>{const n=i.get(p.ICommandService),e=i.get(p.IUndoRedoService),r=i.get(h.ISheetDrawingService);if(!t)return!1;const o=[];t.forEach(({parent:g,children:S})=>{o.push(g.unitId),S.forEach(f=>{o.push(f.unitId)})});const a=r.getGroupDrawingOp(t),{unitId:s,subUnitId:l,undo:u,redo:d,objects:c}=a;return n.syncExecuteCommand(h.SetDrawingApplyMutation.id,{op:d,unitId:s,subUnitId:l,objects:c,type:h.DrawingApplyType.GROUP})?(e.pushUndoRedo({unitID:s,undoMutations:[{id:h.SetDrawingApplyMutation.id,params:{op:u,unitId:s,subUnitId:l,objects:Je(c),type:h.DrawingApplyType.UNGROUP}},{id:G.id,params:o}],redoMutations:[{id:h.SetDrawingApplyMutation.id,params:{op:d,unitId:s,subUnitId:l,objects:c,type:h.DrawingApplyType.GROUP}},{id:G.id,params:o}]}),!0):!1}},Ee={id:"sheet.command.ungroup-sheet-image",type:p.CommandType.COMMAND,handler:(i,t)=>{const n=i.get(p.ICommandService),e=i.get(p.IUndoRedoService),r=i.get(h.ISheetDrawingService);if(!t)return!1;const o=[];t.forEach(({parent:g,children:S})=>{o.push(g.unitId),S.forEach(f=>{o.push(f.unitId)})});const a=r.getUngroupDrawingOp(t),{unitId:s,subUnitId:l,undo:u,redo:d,objects:c}=a;return n.syncExecuteCommand(h.SetDrawingApplyMutation.id,{op:d,unitId:s,subUnitId:l,objects:c,type:h.DrawingApplyType.UNGROUP})?(e.pushUndoRedo({unitID:s,undoMutations:[{id:h.SetDrawingApplyMutation.id,params:{op:u,unitId:s,subUnitId:l,objects:qe(c),type:h.DrawingApplyType.GROUP}},{id:G.id,params:o}],redoMutations:[{id:h.SetDrawingApplyMutation.id,params:{op:d,unitId:s,subUnitId:l,objects:c,type:h.DrawingApplyType.UNGROUP}},{id:G.id,params:o}]}),!0):!1}};function H(i,t,n){const{from:e,to:r,flipY:o=!1,flipX:a=!1,angle:s=0,skewX:l=0,skewY:u=0}=i,{column:d,columnOffset:c,row:m,rowOffset:g}=e,{column:S,columnOffset:f,row:v,rowOffset:y}=r,M=n.attachRangeWithCoord({startColumn:d,endColumn:d,startRow:m,endRow:m});if(M==null)return;const C=n.attachRangeWithCoord({startColumn:S,endColumn:S,startRow:v,endRow:v});if(C==null)return;const{startX:R,startY:I}=M,{startX:O,startY:w}=C;let U=L.precisionTo(R+c,1),E=L.precisionTo(I+g,1),j=L.precisionTo(O+f-U,1),P=L.precisionTo(w+y-E,1);M.startX===C.endX&&(j=0),M.startY===C.endY&&(P=0);const b=n.getCurrentSkeleton(),D=b.rowHeaderWidth+b.columnTotalWidth,W=b.columnHeaderHeight+b.rowTotalHeight;return U+j>D&&(U=D-j),E+P>W&&(E=W-P),{flipY:o,flipX:a,angle:s,skewX:l,skewY:u,left:U,top:E,width:j,height:P}}function V(i,t){const{left:n=0,top:e=0,width:r=0,height:o=0,flipY:a=!1,flipX:s=!1,angle:l=0,skewX:u=0,skewY:d=0}=i,c=t.getSelectionCellByPosition(n,e);if(c==null)return;const m={column:c.actualColumn,columnOffset:L.precisionTo(n-c.startX,1),row:c.actualRow,rowOffset:L.precisionTo(e-c.startY,1)},g=t.getSelectionCellByPosition(n+r,e+o);if(g==null)return;const S={column:g.actualColumn,columnOffset:L.precisionTo(n+r-g.startX,1),row:g.actualRow,rowOffset:L.precisionTo(e+o-g.startY,1)};return{flipY:a,flipX:s,angle:l,skewX:u,skewY:d,from:m,to:S}}var Ze=Object.defineProperty,Qe=Object.getOwnPropertyDescriptor,et=(i,t,n,e)=>{for(var r=e>1?void 0:e?Qe(t,n):t,o=i.length-1,a;o>=0;o--)(a=i[o])&&(r=(e?a(t,n,r):a(r))||r);return e&&r&&Ze(t,n,r),r},K=(i,t)=>(n,e)=>t(n,e,i);let Se=class extends p.Disposable{constructor(i,t,n,e,r,o,a,s,l,u){super(),this._commandService=i,this._univerInstanceService=t,this._selectionManagerService=n,this._imageIoService=e,this._sheetDrawingService=r,this._drawingManagerService=o,this._contextService=a,this._messageService=s,this._localeService=l,this._renderManagerService=u,this._init()}get _selectionRenderService(){return this._renderManagerService.getRenderById(this._univerInstanceService.getCurrentUnitForType(p.UniverInstanceType.UNIVER_SHEET).getUnitId()).with($.ISheetSelectionRenderService)}get _skeletonManagerService(){return this._renderManagerService.getRenderById(this._univerInstanceService.getCurrentUnitForType(p.UniverInstanceType.UNIVER_SHEET).getUnitId()).with($.SheetSkeletonManagerService)}_init(){this._initCommandListeners(),this._updateImageListener(),this._updateOrderListener(),this._groupDrawingListener(),this._focusDrawingListener(),this._drawingAddListener()}_initCommandListeners(){this.disposeWithMe(this._commandService.onCommandExecuted(async i=>{if(i.id===ae.id||i.id===oe.id){const t=i.params;if(t.files==null)return;const n=t.files.length;if(n>A.DRAWING_IMAGE_COUNT_LIMIT){this._messageService.show({type:J.MessageType.Error,content:this._localeService.t("update-status.exceedMaxCount",String(A.DRAWING_IMAGE_COUNT_LIMIT))});return}this._imageIoService.setWaitCount(n),i.id===ae.id?t.files.forEach(async e=>{await this._insertCellImage(e)}):t.files.forEach(async e=>{await this._insertFloatImage(e)})}}))}async _insertCellImage(i){}async _insertFloatImage(i){let t;try{t=await this._imageIoService.saveImage(i)}catch(M){const C=M.message;C===A.ImageUploadStatusType.ERROR_EXCEED_SIZE?this._messageService.show({type:J.MessageType.Error,content:this._localeService.t("update-status.exceedMaxSize",String(A.DRAWING_IMAGE_ALLOW_SIZE/(1024*1024)))}):C===A.ImageUploadStatusType.ERROR_IMAGE_TYPE?this._messageService.show({type:J.MessageType.Error,content:this._localeService.t("update-status.invalidImageType")}):C===A.ImageUploadStatusType.ERROR_IMAGE&&this._messageService.show({type:J.MessageType.Error,content:this._localeService.t("update-status.invalidImage")})}if(t==null)return;const n=this._getUnitInfo();if(n==null)return;const{unitId:e,subUnitId:r}=n,{imageId:o,imageSourceType:a,source:s,base64Cache:l}=t,{width:u,height:d,image:c}=await A.getImageSize(l||""),m=this._renderManagerService.getRenderById(e);if(m==null)return;const{width:g,height:S}=m.scene;this._imageIoService.addImageSourceCache(s,a,c);let f=1;if(u>A.DRAWING_IMAGE_WIDTH_LIMIT||d>A.DRAWING_IMAGE_HEIGHT_LIMIT){const M=A.DRAWING_IMAGE_WIDTH_LIMIT/u,C=A.DRAWING_IMAGE_HEIGHT_LIMIT/d;f=Math.max(M,C)}const v=this._getImagePosition(u*f,d*f,g,S);if(v==null)return;const y={unitId:e,subUnitId:r,drawingId:o,drawingType:A.DrawingTypeEnum.DRAWING_IMAGE,imageSourceType:a,source:s,transform:H(v,this._selectionRenderService,this._skeletonManagerService),sheetTransform:v};this._commandService.executeCommand(fe.id,{unitId:e,drawings:[y]})}_getUnitInfo(){const i=this._univerInstanceService.getCurrentUnitForType(p.UniverInstanceType.UNIVER_SHEET);if(i==null)return;const t=i.getActiveSheet();if(t==null)return;const n=i.getUnitId(),e=t.getSheetId();return{unitId:n,subUnitId:e}}_getImagePosition(i,t,n,e){const r=this._selectionManagerService.getCurrentSelections();let o={startRow:0,endRow:0,startColumn:0,endColumn:0};r&&r.length>0&&(o=r[r.length-1].range);const a=$.attachRangeWithCoord(this._skeletonManagerService.getCurrent().skeleton,o);if(a==null)return;let{startColumn:s,startRow:l,startX:u,startY:d}=a,c=!1;if(u+i>n&&(u=n-i,u<0&&(u=0,i=n),c=!0),d+t>e&&(d=e-t,d<0&&(d=0,t=e),c=!0),c){const f=this._selectionRenderService.getSelectionCellByPosition(u,d);if(f==null)return;u=f.startX,d=f.startY,s=f.actualColumn,l=f.actualRow}const m={column:s,columnOffset:0,row:l,rowOffset:0},g=this._selectionRenderService.getSelectionCellByPosition(u+i,d+t);if(g==null)return;const S={column:g.actualColumn,columnOffset:u+i-g.startX,row:g.actualRow,rowOffset:d+t-g.startY};return{from:m,to:S}}_updateOrderListener(){this._drawingManagerService.featurePluginOrderUpdate$.subscribe(i=>{const{unitId:t,subUnitId:n,drawingIds:e,arrangeType:r}=i;this._commandService.executeCommand(Te.id,{unitId:t,subUnitId:n,drawingIds:e,arrangeType:r})})}_updateImageListener(){this._drawingManagerService.featurePluginUpdate$.subscribe(i=>{const t=[];i.length!==0&&(i.forEach(n=>{const{unitId:e,subUnitId:r,drawingId:o,drawingType:a,transform:s}=n;if(s==null)return;const l=this._sheetDrawingService.getDrawingByParam({unitId:e,subUnitId:r,drawingId:o});if(l==null)return;const u=V({...l.transform,...s},this._selectionRenderService);if(u==null)return;const d={...n,transform:{...l.transform,...s,...H(u,this._selectionRenderService,this._skeletonManagerService)},sheetTransform:{...u}};t.push(d)}),t.length>0&&this._commandService.executeCommand(se.id,{unitId:i[0].unitId,drawings:t}))})}_groupDrawingListener(){this._drawingManagerService.featurePluginGroupUpdate$.subscribe(i=>{this._commandService.executeCommand(Re.id,i);const{unitId:t,subUnitId:n,drawingId:e}=i[0].parent;this._drawingManagerService.focusDrawing([{unitId:t,subUnitId:n,drawingId:e}])}),this._drawingManagerService.featurePluginUngroupUpdate$.subscribe(i=>{this._commandService.executeCommand(Ee.id,i)})}_focusDrawingListener(){this.disposeWithMe(this._drawingManagerService.focus$.subscribe(i=>{i==null||i.length===0?(this._contextService.setContextValue(p.FOCUSING_COMMON_DRAWINGS,!1),this._sheetDrawingService.focusDrawing([])):(this._contextService.setContextValue(p.FOCUSING_COMMON_DRAWINGS,!0),this._sheetDrawingService.focusDrawing(i))}))}_drawingAddListener(){this.disposeWithMe(this._sheetDrawingService.add$.subscribe(i=>{this._registerDrawing(i)}))}_registerDrawing(i){i.forEach(n=>{const e=this._sheetDrawingService.getDrawingByParam(n);if(e==null)return;const{sheetTransform:r}=e;e.transform=H(r,this._selectionRenderService,this._skeletonManagerService)});const t=i[0].unitId;this._drawingManagerService.registerDrawingData(t,this._sheetDrawingService.getDrawingDataForUnit(t)),this._drawingManagerService.initializeNotification(t)}};Se=et([p.OnLifecycle(p.LifecycleStages.Rendered,Se),K(0,p.ICommandService),K(1,p.IUniverInstanceService),K(2,B.Inject(_.SheetsSelectionsService)),K(3,A.IImageIoService),K(4,h.ISheetDrawingService),K(5,A.IDrawingManagerService),K(6,p.IContextService),K(7,F.IMessageService),K(8,B.Inject(p.LocaleService)),K(9,L.IRenderManagerService)],Se);var x=function(){return x=Object.assign||function(i){for(var t,n=1,e=arguments.length;n<e;n++){t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(i[r]=t[r])}return i},x.apply(this,arguments)},tt=function(i,t){var n={};for(var e in i)Object.prototype.hasOwnProperty.call(i,e)&&t.indexOf(e)<0&&(n[e]=i[e]);if(i!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,e=Object.getOwnPropertySymbols(i);r<e.length;r++)t.indexOf(e[r])<0&&Object.prototype.propertyIsEnumerable.call(i,e[r])&&(n[e[r]]=i[e[r]]);return n},Ne=N.forwardRef(function(i,t){var n=i.icon,e=i.id,r=i.className,o=i.extend,a=tt(i,["icon","id","className","extend"]),s="univerjs-icon univerjs-icon-".concat(e," ").concat(r||"").trim(),l=N.useRef("_".concat(it()));return Le(n,"".concat(e),{defIds:n.defIds,idSuffix:l.current},x({ref:t,className:s},a),o)});function Le(i,t,n,e,r){return N.createElement(i.tag,x(x({key:t},nt(i,n,r)),e),(rt(i,n).children||[]).map(function(o,a){return Le(o,"".concat(t,"-").concat(i.tag,"-").concat(a),n,void 0,r)}))}function nt(i,t,n){var e=x({},i.attrs);n!=null&&n.colorChannel1&&e.fill==="colorChannel1"&&(e.fill=n.colorChannel1);var r=t.defIds;return!r||r.length===0||(i.tag==="use"&&e["xlink:href"]&&(e["xlink:href"]=e["xlink:href"]+t.idSuffix),Object.entries(e).forEach(function(o){var a=o[0],s=o[1];typeof s=="string"&&(e[a]=s.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))})),e}function rt(i,t){var n,e=t.defIds;return!e||e.length===0?i:i.tag==="defs"&&(!((n=i.children)===null||n===void 0)&&n.length)?x(x({},i),{children:i.children.map(function(r){return typeof r.attrs.id=="string"&&e&&e.indexOf(r.attrs.id)>-1?x(x({},r),{attrs:x(x({},r.attrs),{id:r.attrs.id+t.idSuffix})}):r})}):i}function it(){return Math.random().toString(36).substring(2,8)}Ne.displayName="UniverIcon";var ot={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"}}]},je=N.forwardRef(function(i,t){return N.createElement(Ne,Object.assign({},i,{id:"add-image-single",ref:t,icon:ot}))});je.displayName="AddImageSingle";const We={uploadFileMenu:"univer-upload-file-menu",uploadFileMenuInput:"univer-upload-file-menu-input"},$e="COMPONENT_UPLOAD_FILE_MENU";var ve=(i=>(i[i.cellImage=0]="cellImage",i[i.floatImage=1]="floatImage",i))(ve||{});const at=i=>{const{type:t}=i,n=q.useDependency(p.ICommandService),e=N.useRef(null),r=()=>{var s;(s=e.current)==null||s.click()},o=A.DRAWING_IMAGE_ALLOW_IMAGE_LIST.map(s=>`.${s.replace("image/","")}`).join(","),a=s=>{const l=s.target.files;if(l==null)return;const u=Array.from(l);t===ve.floatImage?n.executeCommand(oe.id,{files:u}):t===ve.cellImage&&n.executeCommand(ae.id,{files:u}),e.current&&(e.current.value="")};return N.createElement("div",{onClick:r,className:We.uploadFileMenu},N.createElement("input",{type:"file",className:We.uploadFileMenuInput,ref:e,onChange:a,accept:o,multiple:!0}))},Be="addition-and-subtraction-single",Ge="sheet.menu.image";function st(i){return{id:Ge,type:F.MenuItemType.SUBITEMS,positions:[F.MenuPosition.TOOLBAR_START],group:F.MenuGroup.TOOLBAR_FORMULAS_INSERT,icon:Be,tooltip:"sheetImage.title",hidden$:F.getMenuHiddenObservable(i,p.UniverInstanceType.UNIVER_SHEET),disabled$:$.getCurrentRangeDisable$(i,{workbookTypes:[_.WorkbookEditablePermission],worksheetTypes:[_.WorksheetEditPermission],rangeTypes:[_.RangeProtectionPermissionEditPoint]})}}function ct(i){return{id:oe.id,title:"sheetImage.upload.float",type:F.MenuItemType.SELECTOR,label:{name:$e,props:{type:ve.floatImage}},positions:[Ge],hidden$:F.getMenuHiddenObservable(i,p.UniverInstanceType.UNIVER_SHEET)}}const Z={imageCommonPanel:"univer-image-common-panel",imageCommonPanelGrid:"univer-image-common-panel-grid",imageCommonPanelBorder:"univer-image-common-panel-border",imageCommonPanelTitle:"univer-image-common-panel-title",imageCommonPanelSubtitle:"univer-image-common-panel-subtitle",imageCommonPanelRow:"univer-image-common-panel-row",imageCommonPanelRowVertical:"univer-image-common-panel-row-vertical",imageCommonPanelColumn:"univer-image-common-panel-column",imageCommonPanelColumnCenter:"univer-image-common-panel-column-center",imageCommonPanelInline:"univer-image-common-panel-inline",imageCommonPanelSpan2:"univer-image-common-panel-span2",imageCommonPanelSpan3:"univer-image-common-panel-span3",imageCommonPanelInput:"univer-image-common-panel-input",sheetImageMenu:"univer-sheet-image-menu",sheetImageMenuInput:"univer-sheet-image-menu-input"},lt=i=>{var C;const t=q.useDependency(p.ICommandService),n=q.useDependency(p.LocaleService),e=q.useDependency(A.IDrawingManagerService),r=q.useDependency(L.IRenderManagerService),{drawings:o}=i,a=o[0];if(a==null)return;const{unitId:s}=a,l=r.getRenderById(s),u=l==null?void 0:l.scene;if(u==null)return;const d=u.getTransformerByCreate(),[c,m]=N.useState(!0),g=(C=a.anchorType)!=null?C:h.SheetDrawingAnchorType.Position,[S,f]=N.useState(g);function v(R,I){const O=[];return R.forEach(w=>{const{oKey:U}=w,E=I.getDrawingOKey(U);if(E==null)return O.push(null),!0;const{unitId:j,subUnitId:P,drawingId:b,drawingType:D,anchorType:W,sheetTransform:Y}=E;O.push({unitId:j,subUnitId:P,drawingId:b,anchorType:W,sheetTransform:Y,drawingType:D})}),O}N.useEffect(()=>{const R=d.clearControl$.subscribe(O=>{O===!0&&m(!1)}),I=d.changeStart$.subscribe(O=>{var E;const{objects:w}=O,U=v(w,e);if(U.length===0)m(!1);else if(U.length>=1){m(!0);const j=((E=U[0])==null?void 0:E.anchorType)||h.SheetDrawingAnchorType.Position;f(j)}});return()=>{I.unsubscribe(),R.unsubscribe()}},[]);function y(R){f(R);const I=e.getFocusDrawings();if(I.length===0)return;const O=I.map(w=>({unitId:w.unitId,subUnitId:w.subUnitId,drawingId:w.drawingId,anchorType:R}));t.executeCommand(se.id,{unitId:I[0].unitId,drawings:O})}const M=R=>R?"block":"none";return N.createElement("div",{className:me(Z.imageCommonPanelGrid,Z.imageCommonPanelBorder),style:{display:M(c)}},N.createElement("div",{className:Z.imageCommonPanelRow},N.createElement("div",{className:me(Z.imageCommonPanelColumn,Z.imageCommonPanelTitle)},N.createElement("div",null,n.t("drawing-anchor.title")))),N.createElement("div",{className:me(Z.imageCommonPanelRow)},N.createElement("div",{className:me(Z.imageCommonPanelColumn)},N.createElement(J.RadioGroup,{value:S,onChange:y,direction:"vertical"},N.createElement(J.Radio,{value:h.SheetDrawingAnchorType.Both},n.t("drawing-anchor.both")),N.createElement(J.Radio,{value:h.SheetDrawingAnchorType.Position},n.t("drawing-anchor.position")),N.createElement(J.Radio,{value:h.SheetDrawingAnchorType.None},n.t("drawing-anchor.none"))))))},dt=()=>{const i=q.useDependency(A.IDrawingManagerService),t=i.getFocusDrawings(),[n,e]=N.useState(t);return N.useEffect(()=>{const r=i.focus$.subscribe(o=>{e(o)});return()=>{r.unsubscribe()}},[]),!!(n!=null&&n.length)&&N.createElement("div",{className:Z.imageCommonPanel},N.createElement(Q.DrawingCommonPanel,{drawings:n}),N.createElement(lt,{drawings:n}))},re={id:"sheet.command.move-drawing",type:p.CommandType.COMMAND,handler:(i,t)=>{const n=i.get(p.ICommandService),e=i.get(h.ISheetDrawingService),r=i.get($.ISheetSelectionRenderService),{direction:o}=t,a=e.getFocusDrawings();if(a.length===0)return!1;const s=a[0].unitId,l=a.map(d=>{const{transform:c}=d;if(c==null)return null;const m={...c},{left:g=0,top:S=0}=c;return o===p.Direction.UP?m.top=S-1:o===p.Direction.DOWN?m.top=S+1:o===p.Direction.LEFT?m.left=g-1:o===p.Direction.RIGHT&&(m.left=g+1),{...d,transform:m,sheetTransform:V(m,r)}}).filter(d=>d!=null);return n.syncExecuteCommand(se.id,{unitId:s,drawings:l})?(n.syncExecuteCommand(G.id,[s]),!0):!1}},be={id:"sheet.command.delete-drawing",type:p.CommandType.COMMAND,handler:i=>{const t=i.get(p.ICommandService),e=i.get(h.ISheetDrawingService).getFocusDrawings();if(e.length===0)return!1;const r=e[0].unitId,o=e.map(a=>{const{unitId:s,subUnitId:l,drawingId:u,drawingType:d}=a;return{unitId:s,subUnitId:l,drawingId:u,drawingType:d}});return t.executeCommand(ge.id,{unitId:r,drawings:o})}};function ce(i){return!i.getContextValue(p.FOCUSING_FORMULA_EDITOR)&&!i.getContextValue(p.EDITOR_ACTIVATED)&&i.getContextValue(p.FOCUSING_COMMON_DRAWINGS)}const ut={id:re.id,description:"shortcut.sheet.drawing-move-down",group:"4_sheet-drawing-view",binding:F.KeyCode.ARROW_DOWN,priority:100,preconditions:ce,staticParameters:{direction:p.Direction.DOWN}},mt={id:re.id,description:"shortcut.sheet.drawing-move-up",group:"4_sheet-drawing-view",binding:F.KeyCode.ARROW_UP,priority:100,preconditions:ce,staticParameters:{direction:p.Direction.UP}},gt={id:re.id,description:"shortcut.sheet.drawing-move-left",group:"4_sheet-drawing-view",binding:F.KeyCode.ARROW_LEFT,priority:100,preconditions:ce,staticParameters:{direction:p.Direction.LEFT}},pt={id:re.id,description:"shortcut.sheet.drawing-move-right",group:"4_sheet-drawing-view",binding:F.KeyCode.ARROW_RIGHT,priority:100,preconditions:ce,staticParameters:{direction:p.Direction.RIGHT}},ht={id:be.id,description:"shortcut.sheet.drawing-delete",group:"4_sheet-drawing-view",preconditions:ce,binding:F.KeyCode.DELETE,mac:F.KeyCode.BACKSPACE};var ft=Object.defineProperty,St=Object.getOwnPropertyDescriptor,vt=(i,t,n,e)=>{for(var r=e>1?void 0:e?St(t,n):t,o=i.length-1,a;o>=0;o--)(a=i[o])&&(r=(e?a(t,n,r):a(r))||r);return e&&r&&ft(t,n,r),r},le=(i,t)=>(n,e)=>t(n,e,i);const wt={};let de=class extends p.Disposable{constructor(i,t,n,e,r,o){super(),this._config=i,this._injector=t,this._componentManager=n,this._menuService=e,this._commandService=r,this._shortcutService=o,this._init()}_initCustomComponents(){const i=this._componentManager;this.disposeWithMe(i.register(Be,je)),this.disposeWithMe(i.register($e,at)),this.disposeWithMe(i.register(Ue,dt))}_initMenus(){const{menu:i={}}=this._config;[st,ct].forEach(t=>{this._menuService.addMenuItem(t(this._injector),i)})}_initCommands(){[oe,ae,fe,ge,se,Me,G,De,Re,Ee,re,be,Te].forEach(i=>this.disposeWithMe(this._commandService.registerCommand(i)))}_initShortcuts(){[ut,mt,gt,pt,ht].forEach(i=>{this.disposeWithMe(this._shortcutService.registerShortcut(i))})}_init(){this._initCommands(),this._initCustomComponents(),this._initMenus(),this._initShortcuts()}};de=vt([p.OnLifecycle(p.LifecycleStages.Rendered,de),le(1,B.Inject(B.Injector)),le(2,B.Inject(F.ComponentManager)),le(3,F.IMenuService),le(4,p.ICommandService),le(5,F.IShortcutService)],de);var _t=Object.defineProperty,It=Object.getOwnPropertyDescriptor,Ct=(i,t,n,e)=>{for(var r=e>1?void 0:e?It(t,n):t,o=i.length-1,a;o>=0;o--)(a=i[o])&&(r=(e?a(t,n,r):a(r))||r);return e&&r&&_t(t,n,r),r},ie=(i,t)=>(n,e)=>t(n,e,i);const yt=[_.InsertRowCommand.id,_.InsertColCommand.id,_.RemoveRowCommand.id,_.RemoveColCommand.id,_.DeleteRangeMoveLeftCommand.id,_.DeleteRangeMoveUpCommand.id,_.InsertRangeMoveDownCommand.id,_.InsertRangeMoveRightCommand.id,_.DeltaRowHeightCommand.id,_.SetRowHeightCommand.id,_.DeltaColumnWidthCommand.id,_.SetColWidthCommand.id,_.SetRowHiddenCommand.id,_.SetSpecificRowsVisibleCommand.id,_.SetSpecificColsVisibleCommand.id,_.SetColHiddenCommand.id],Mt=[_.SetRowVisibleMutation.id,_.SetRowHiddenMutation.id,_.SetColVisibleMutation.id,_.SetColHiddenMutation.id,_.SetWorksheetRowHeightMutation.id,_.SetWorksheetColWidthMutation.id];let we=class extends p.Disposable{constructor(i,t,n,e,r,o){super(),this._commandService=i,this._sheetInterceptorService=t,this._renderManagerService=n,this._sheetDrawingService=e,this._drawingManagerService=r,this._univerInstanceService=o,this._init()}get _selectionRenderService(){return this._renderManagerService.getRenderById(this._univerInstanceService.getCurrentUnitForType(p.UniverInstanceType.UNIVER_SHEET).getUnitId()).with($.ISheetSelectionRenderService)}get _skeletonManagerService(){return this._renderManagerService.getRenderById(this._univerInstanceService.getCurrentUnitForType(p.UniverInstanceType.UNIVER_SHEET).getUnitId()).with($.SheetSkeletonManagerService)}_init(){this._sheetInterceptorListener(),this._commandListener(),this._sheetRefreshListener()}_sheetInterceptorListener(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:i=>{if(!yt.includes(i.id))return{redos:[],undos:[]};if(i.params==null)return{redos:[],undos:[]};const t=i.id;if(t===_.InsertRowCommand.id)return this._moveRowInterceptor(i.params,"insert");if(t===_.InsertColCommand.id)return this._moveColInterceptor(i.params,"insert");if(t===_.RemoveRowCommand.id)return this._moveRowInterceptor(i.params,"remove");if(t===_.RemoveColCommand.id)return this._moveColInterceptor(i.params,"remove");if(t===_.DeleteRangeMoveLeftCommand.id){const{range:n}=i.params;return this._getRangeMoveUndo(n,0)}else if(t===_.DeleteRangeMoveUpCommand.id){const{range:n}=i.params;return this._getRangeMoveUndo(n,1)}else if(t===_.InsertRangeMoveDownCommand.id){const{range:n}=i.params;return this._getRangeMoveUndo(n,2)}else if(t===_.InsertRangeMoveRightCommand.id){const{range:n}=i.params;return this._getRangeMoveUndo(n,3)}else if(t===_.SetRowHiddenCommand.id||t===_.SetSpecificRowsVisibleCommand.id){const n=i.params,{unitId:e,subUnitId:r,ranges:o}=n;return this._getDrawingUndoForRowVisible(e,r,o)}else if(t===_.SetSpecificColsVisibleCommand.id||t===_.SetColHiddenCommand.id){const n=i.params,{unitId:e,subUnitId:r,ranges:o}=n;return this._getDrawingUndoForColVisible(e,r,o)}else if(t===_.DeltaRowHeightCommand.id||t===_.SetRowHeightCommand.id||t===_.DeltaColumnWidthCommand.id||t===_.SetColWidthCommand.id){const n=i.params,{unitId:e,subUnitId:r,ranges:o}=n,a=t===_.DeltaRowHeightCommand.id||t===_.SetRowHeightCommand.id;return this._getDrawingUndoForRowAndColSize(e,r,o,a)}return{redos:[],undos:[]}}}))}_getRangeMoveUndo(i,t){const n=_.getSheetCommandTarget(this._univerInstanceService);if(n==null)return{redos:[],undos:[]};const e=n.unitId,r=n.subUnitId,o=[],a=[],s=this._sheetDrawingService.getDrawingData(e,r),l=[],u=[];if(Object.keys(s).forEach(d=>{const c=s[d],{updateDrawings:m,deleteDrawings:g}=this._getUpdateOrDeleteDrawings(i,t,c);l.push(...m),u.push(...g)}),l.length===0&&u.length===0)return{redos:[],undos:[]};if(l.length>0){const d=this._sheetDrawingService.getBatchUpdateOp(l),{undo:c,redo:m,objects:g}=d;o.push({id:h.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:r,op:m,objects:g,type:h.DrawingApplyType.UPDATE}}),a.push({id:h.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:r,op:c,objects:g,type:h.DrawingApplyType.UPDATE}})}if(u.length>0){const d=this._sheetDrawingService.getBatchRemoveOp(u),c=d.undo,m=d.redo,g=d.objects;o.push({id:h.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:r,op:m,objects:g,type:h.DrawingApplyType.REMOVE}}),a.push({id:h.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:r,op:c,objects:g,type:h.DrawingApplyType.INSERT}})}return o.push({id:G.id,params:[e]}),a.push({id:G.id,params:[e]}),{redos:o,undos:a}}_getUpdateOrDeleteDrawings(i,t,n){const e=[],r=[],{sheetTransform:o,anchorType:a=h.SheetDrawingAnchorType.Position,transform:s,unitId:l,subUnitId:u,drawingId:d}=n,{from:c,to:m}=o,{row:g,column:S}=c,{row:f,column:v}=m;if(o==null||s==null)return{updateDrawings:e,deleteDrawings:r};const{startRow:y,endRow:M,startColumn:C,endColumn:R}=i;let I=null,O=null;if(t===0&&g>=y&&f<=M)if(S>=C&&v<=R)r.push({unitId:l,subUnitId:u,drawingId:d});else{const w=this._shrinkCol(o,s,C,R,a);I=w==null?void 0:w.newSheetTransform,O=w==null?void 0:w.newTransform}else if(t===1&&S>=C&&v<=R)if(g>=y&&f<=M)r.push({unitId:l,subUnitId:u,drawingId:d});else{const w=this._shrinkRow(o,s,y,M,a);I=w==null?void 0:w.newSheetTransform,O=w==null?void 0:w.newTransform}else if(t===2){const w=this._expandRow(o,s,y,M,a);I=w==null?void 0:w.newSheetTransform,O=w==null?void 0:w.newTransform}else if(t===3){const w=this._expandCol(o,s,C,R,a);I=w==null?void 0:w.newSheetTransform,O=w==null?void 0:w.newTransform}if(I!=null&&O!=null){const w=H(I,this._selectionRenderService,this._skeletonManagerService);e.push({...n,sheetTransform:I,transform:w})}return{updateDrawings:e,deleteDrawings:r}}_remainDrawingSize(i,t,n){const e=V({...i},this._selectionRenderService);e!=null&&t.push({...n,sheetTransform:e})}_getDrawingUndoForColVisible(i,t,n){const e=this._drawingManagerService.getDrawingData(i,t),r=[],o=[];if(Object.keys(e).forEach(d=>{const c=e[d],{sheetTransform:m,transform:g,anchorType:S=h.SheetDrawingAnchorType.Position}=c;if(S===h.SheetDrawingAnchorType.None)this._remainDrawingSize(g,r,c);else{const{from:f,to:v}=m,{row:y,column:M}=f,{row:C,column:R}=v;for(let I=0;I<n.length;I++){const O=n[I],{startRow:w,endRow:U,startColumn:E,endColumn:j}=O;if(R<E)continue;if(S===h.SheetDrawingAnchorType.Position){let D=null,W=null;if(M>=E&&M<=j){const Y=this._skeletonManagerService.attachRangeWithCoord({startColumn:M,endColumn:j,startRow:f.row,endRow:v.row});if(Y==null)return;W={...g,left:Y.startX}}if(W!=null&&(D=V(W,this._selectionRenderService),D!=null&&W!=null)){r.push({...c,sheetTransform:D,transform:W});break}this._remainDrawingSize(g,r,c);continue}if(M>=E&&R<=j)continue;let P=null,b=null;if(M>=E&&M<=j){const D=this._skeletonManagerService.attachRangeWithCoord({startColumn:M,endColumn:j,startRow:f.row,endRow:v.row});if(D==null)return;b={...g,left:(D==null?void 0:D.startX)||0,width:((g==null?void 0:g.width)||0)-D.endX+D.startX}}else if(R>=E&&R<=j){const D=this._skeletonManagerService.attachRangeWithCoord({startColumn:E,endColumn:R,startRow:f.row,endRow:v.row});if(D==null)return;b={...g,left:D.startX-((g==null?void 0:g.width)||0)}}else{const D=this._skeletonManagerService.attachRangeWithCoord({startColumn:E,endColumn:j,startRow:f.row,endRow:v.row});if(D==null)return;if(b={...g,width:((g==null?void 0:g.width)||0)-D.endX+D.startX},P=V(b,this._selectionRenderService),P!=null&&b!=null){o.push({...c,sheetTransform:P,transform:b});break}}if(b!=null&&(P=V(b,this._selectionRenderService)),b!=null&&P!=null){r.push({...c,sheetTransform:P,transform:b});break}else this._remainDrawingSize(g,r,c)}}}),r.length===0&&o.length===0)return{redos:[],undos:[]};const{redos:a,undos:s}=this._createUndoAndRedoMutation(i,t,r),l=[],u=[];if(o.length>0){const{redos:d,undos:c}=this._createUndoAndRedoMutation(i,t,o);l.push(...d),u.push(...c)}return{redos:a,undos:s,preRedos:l,preUndos:u}}_createUndoAndRedoMutation(i,t,n){const e=this._sheetDrawingService.getBatchUpdateOp(n),{undo:r,redo:o,objects:a}=e,s=[{id:h.SetDrawingApplyMutation.id,params:{unitId:i,subUnitId:t,op:o,objects:a,type:h.DrawingApplyType.UPDATE}},{id:G.id,params:[i]}],l=[{id:h.SetDrawingApplyMutation.id,params:{unitId:i,subUnitId:t,op:r,objects:a,type:h.DrawingApplyType.UPDATE}},{id:G.id,params:[i]}];return{redos:s,undos:l}}_getDrawingUndoForRowVisible(i,t,n){const e=this._drawingManagerService.getDrawingData(i,t),r=[],o=[];if(Object.keys(e).forEach(d=>{const c=e[d],{sheetTransform:m,transform:g,anchorType:S=h.SheetDrawingAnchorType.Position}=c;if(S===h.SheetDrawingAnchorType.None)this._remainDrawingSize(g,r,c);else{const{from:f,to:v}=m,{row:y,column:M}=f,{row:C,column:R}=v;for(let I=0;I<n.length;I++){const O=n[I],{startRow:w,endRow:U,startColumn:E,endColumn:j}=O;if(C<w)continue;if(S===h.SheetDrawingAnchorType.Position){let D=null,W=null;if(y>=w&&y<=U){const Y=this._skeletonManagerService.attachRangeWithCoord({startColumn:f.column,endColumn:v.column,startRow:y,endRow:U});if(Y==null)return;W={...g,top:Y.startY}}if(W!=null&&(D=V(W,this._selectionRenderService),D!=null&&W!=null)){r.push({...c,sheetTransform:D,transform:W});break}this._remainDrawingSize(g,r,c);continue}if(y>=w&&C<=U)continue;let P=null,b=null;if(y>=w&&y<=U){const D=this._skeletonManagerService.attachRangeWithCoord({startColumn:f.column,endColumn:v.column,startRow:y,endRow:U});if(D==null)return;b={...g,top:(D==null?void 0:D.startY)||0,height:((g==null?void 0:g.height)||0)-D.endY+D.startY}}else if(C>=w&&C<=U){const D=this._skeletonManagerService.attachRangeWithCoord({startColumn:f.column,endColumn:v.column,startRow:w,endRow:C});if(D==null)return;b={...g,top:D.startY-((g==null?void 0:g.height)||0)}}else{const D=this._skeletonManagerService.attachRangeWithCoord({startColumn:f.column,endColumn:v.column,startRow:w,endRow:U});if(D==null)return;if(b={...g,height:((g==null?void 0:g.height)||0)-D.endY+D.startY},P=V(b,this._selectionRenderService),P!=null&&b!=null){o.push({...c,sheetTransform:P,transform:b});break}}if(b!=null&&(P=V(b,this._selectionRenderService)),b!=null&&P!=null){r.push({...c,sheetTransform:P,transform:b});break}else this._remainDrawingSize(g,r,c)}}}),r.length===0&&o.length===0)return{redos:[],undos:[]};const{redos:a,undos:s}=this._createUndoAndRedoMutation(i,t,r),l=[],u=[];if(o.length>0){const{redos:d,undos:c}=this._createUndoAndRedoMutation(i,t,o);l.push(...d),u.push(...c)}return{redos:a,undos:s,preRedos:l,preUndos:u}}_getDrawingUndoForRowAndColSize(i,t,n,e){const r=this._drawingManagerService.getDrawingData(i,t),o=[];return Object.keys(r).forEach(a=>{const s=r[a],{sheetTransform:l,transform:u,anchorType:d=h.SheetDrawingAnchorType.Position}=s;if(d===h.SheetDrawingAnchorType.None)this._remainDrawingSize(u,o,s);else{const{from:c,to:m}=l,{row:g,column:S}=c,{row:f,column:v}=m;for(let y=0;y<n.length;y++){const M=n[y],{startRow:C,endRow:R,startColumn:I,endColumn:O}=M;if(f<C||v<I)continue;if(d===h.SheetDrawingAnchorType.Position&&(g<=C&&f>=R||S<=I&&v>=O)){this._remainDrawingSize(u,o,s);continue}const w=H({...l},this._selectionRenderService,this._skeletonManagerService);if(w!=null){o.push({...s,transform:w});break}}}}),o.length===0?{redos:[],undos:[]}:this._createUndoAndRedoMutation(i,t,o)}_getUnitIdAndSubUnitId(i,t){let n,e;if(t==="insert")n=i.unitId,e=i.subUnitId;else{const r=_.getSheetCommandTarget(this._univerInstanceService);if(r==null)return;n=r.unitId,e=r.subUnitId}return{unitId:n,subUnitId:e}}_moveRowInterceptor(i,t){const n=this._getUnitIdAndSubUnitId(i,t);if(n==null)return{redos:[],undos:[]};const{unitId:e,subUnitId:r}=n,{range:o}=i,a=o.startRow,s=o.endRow,l=[],u=[],d=this._sheetDrawingService.getDrawingData(e,r),c=[],m=[];if(Object.keys(d).forEach(g=>{const S=d[g],{sheetTransform:f,transform:v,anchorType:y=h.SheetDrawingAnchorType.Position}=S;if(f==null||v==null)return;let M,C;if(t==="insert"){const I=this._expandRow(f,v,a,s,y);M=I==null?void 0:I.newSheetTransform,C=I==null?void 0:I.newTransform}else{const{from:I,to:O}=f,{row:w}=I,{row:U}=O;if(w>=a&&U<=s)m.push({unitId:e,subUnitId:r,drawingId:g});else{const E=this._shrinkRow(f,v,a,s,y);M=E==null?void 0:E.newSheetTransform,C=E==null?void 0:E.newTransform}}if(!M||!C)return;const R={unitId:e,subUnitId:r,drawingId:g,transform:C,sheetTransform:M};c.push(R)}),c.length===0&&m.length===0)return{redos:[],undos:[]};if(c.length>0){const g=this._sheetDrawingService.getBatchUpdateOp(c),{undo:S,redo:f,objects:v}=g;l.push({id:h.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:r,op:f,objects:v,type:h.DrawingApplyType.UPDATE}}),u.push({id:h.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:r,op:S,objects:v,type:h.DrawingApplyType.UPDATE}})}if(m.length>0){const g=this._sheetDrawingService.getBatchRemoveOp(m),S=g.undo,f=g.redo,v=g.objects;l.push({id:h.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:r,op:f,objects:v,type:h.DrawingApplyType.REMOVE}}),u.push({id:h.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:r,op:S,objects:v,type:h.DrawingApplyType.INSERT}})}return l.push({id:G.id,params:[e]}),u.push({id:G.id,params:[e]}),{redos:l,undos:u}}_moveColInterceptor(i,t){const n=this._getUnitIdAndSubUnitId(i,t);if(n==null)return{redos:[],undos:[]};const{unitId:e,subUnitId:r}=n,{range:o}=i,a=o.startColumn,s=o.endColumn,l=[],u=[],d=this._sheetDrawingService.getDrawingData(e,r),c=[],m=[];if(Object.keys(d).forEach(g=>{const S=d[g],{sheetTransform:f,transform:v,anchorType:y=h.SheetDrawingAnchorType.Position}=S;if(f==null||v==null)return;let M,C;if(t==="insert"){const I=this._expandCol(f,v,a,s,y);M=I==null?void 0:I.newSheetTransform,C=I==null?void 0:I.newTransform}else{const{from:I,to:O}=f,{column:w}=I,{column:U}=O;if(w>=a&&U<=s)m.push({unitId:e,subUnitId:r,drawingId:g});else{const E=this._shrinkCol(f,v,a,s,y);M=E==null?void 0:E.newSheetTransform,C=E==null?void 0:E.newTransform}}if(!M||!C)return;const R={unitId:e,subUnitId:r,drawingId:g,transform:C,sheetTransform:M};c.push(R)}),c.length===0&&m.length===0)return{redos:[],undos:[]};if(c.length>0){const g=this._sheetDrawingService.getBatchUpdateOp(c),{undo:S,redo:f,objects:v}=g;l.push({id:h.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:r,op:f,objects:v,type:h.DrawingApplyType.UPDATE}}),u.push({id:h.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:r,op:S,objects:v,type:h.DrawingApplyType.UPDATE}})}if(m.length>0){const g=this._sheetDrawingService.getBatchRemoveOp(m),S=g.undo,f=g.redo,v=g.objects;l.push({id:h.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:r,op:f,objects:v,type:h.DrawingApplyType.REMOVE}}),u.push({id:h.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:r,op:S,objects:v,type:h.DrawingApplyType.INSERT}})}return l.push({id:G.id,params:[e]}),u.push({id:G.id,params:[e]}),{redos:l,undos:u}}_expandCol(i,t,n,e,r=h.SheetDrawingAnchorType.Position){const o=e-n+1,{from:a,to:s}=i,{column:l}=a,{column:u}=s;if(r===h.SheetDrawingAnchorType.None)return{newSheetTransform:V({...t},this._selectionRenderService),newTransform:t};let d=null,c=null;if(l>=n){const m=this._skeletonManagerService.attachRangeWithCoord({startColumn:n,endColumn:e,startRow:a.row,endRow:s.row});if(m==null)return;c={...t,left:(t.left||0)+m.endX-m.startX},d=V(c,this._selectionRenderService)}else if(u>=e)if(r===h.SheetDrawingAnchorType.Both)d={from:{...a},to:{...s,column:u+o}},c=H(d,this._selectionRenderService,this._skeletonManagerService);else return{newSheetTransform:V({...t},this._selectionRenderService),newTransform:t};return d!=null&&c!=null?{newSheetTransform:d,newTransform:c}:null}_shrinkCol(i,t,n,e,r=h.SheetDrawingAnchorType.Position){const o=e-n+1,{from:a,to:s}=i,{column:l}=a,{column:u}=s;if(r===h.SheetDrawingAnchorType.None)return{newSheetTransform:V({...t},this._selectionRenderService),newTransform:t};let d=null,c=null;if(l>e)d={from:{...a,column:l-o},to:{...s,column:u-o}},c=H(d,this._selectionRenderService,this._skeletonManagerService);else{if(l>=n&&u<=e)return null;if(l<n&&u>e)if(r===h.SheetDrawingAnchorType.Both)d={from:{...a},to:{...s,column:u-o}},c=H(d,this._selectionRenderService,this._skeletonManagerService);else return{newSheetTransform:V({...t},this._selectionRenderService),newTransform:t};else if(l>=n&&l<=e){if(l===n)c={...t,left:(t.left||0)-i.from.columnOffset};else{const m=this._skeletonManagerService.attachRangeWithCoord({startColumn:n,endColumn:l-1,startRow:a.row,endRow:s.row});if(m==null)return;c={...t,left:(t.left||0)-m.endX+m.startX-i.from.columnOffset}}d=V(c,this._selectionRenderService)}else if(u>=n&&u<=e&&r===h.SheetDrawingAnchorType.Both){const m=this._skeletonManagerService.attachRangeWithCoord({startColumn:n-1,endColumn:n-1,startRow:a.row,endRow:s.row});if(m==null)return;d={from:{...a},to:{...s,column:n-1,columnOffset:m.endX-m.startX}},c=H(d,this._selectionRenderService,this._skeletonManagerService)}}return d!=null&&c!=null?{newSheetTransform:d,newTransform:c}:null}_expandRow(i,t,n,e,r=h.SheetDrawingAnchorType.Position){const o=e-n+1,{from:a,to:s}=i,{row:l}=a,{row:u}=s;if(r===h.SheetDrawingAnchorType.None)return{newSheetTransform:V({...t},this._selectionRenderService),newTransform:t};let d=null,c=null;if(l>=n){const m=this._skeletonManagerService.attachRangeWithCoord({startRow:n,endRow:e,startColumn:a.column,endColumn:s.column});if(m==null)return;c={...t,top:(t.top||0)+m.endY-m.startY},d=V(c,this._selectionRenderService)}else if(u>=e)if(r===h.SheetDrawingAnchorType.Both)d={from:{...a},to:{...s,row:u+o}},c=H(d,this._selectionRenderService,this._skeletonManagerService);else return{newSheetTransform:V({...t},this._selectionRenderService),newTransform:t};return d!=null&&c!=null?{newSheetTransform:d,newTransform:c}:null}_shrinkRow(i,t,n,e,r=h.SheetDrawingAnchorType.Position){const o=e-n+1,{from:a,to:s}=i,{row:l}=a,{row:u}=s;if(r===h.SheetDrawingAnchorType.None)return{newSheetTransform:V({...t},this._selectionRenderService),newTransform:t};let d=null,c=null;if(l>e)d={from:{...a,row:l-o},to:{...s,row:u-o}},c=H(d,this._selectionRenderService,this._skeletonManagerService);else{if(l>=n&&u<=e)return null;if(l<n&&u>e)if(r===h.SheetDrawingAnchorType.Both)d={from:{...a},to:{...s,row:u-o}},c=H(d,this._selectionRenderService,this._skeletonManagerService);else return{newSheetTransform:V({...t},this._selectionRenderService),newTransform:t};else if(l>=n&&l<=e){if(l===n)c={...t,top:(t.top||0)-i.from.rowOffset};else{const m=this._skeletonManagerService.attachRangeWithCoord({startRow:n,endRow:l-1,startColumn:a.column,endColumn:s.column});if(m==null)return;c={...t,top:(t.top||0)-m.endY+m.startY-i.from.rowOffset}}d=V(c,this._selectionRenderService)}else if(u>=n&&u<=e&&r===h.SheetDrawingAnchorType.Both){const m=this._skeletonManagerService.attachRangeWithCoord({startColumn:a.column,endColumn:a.column,startRow:n-1,endRow:n-1});if(m==null)return;d={from:{...a},to:{...s,row:n-1,rowOffset:m.endY-m.startY}},c=H(d,this._selectionRenderService,this._skeletonManagerService)}}return d!=null&&c!=null?{newSheetTransform:d,newTransform:c}:null}_commandListener(){this.disposeWithMe(this._commandService.onCommandExecuted(i=>{i.id===_.SetWorksheetActiveOperation.id&&setTimeout(()=>{const t=i.params,{unitId:n,subUnitId:e}=t,r=this._drawingManagerService.drawingManagerData,o=[],a=[];Object.keys(r).forEach(s=>{const l=r[s];Object.keys(l).forEach(u=>{const d=l[u].data;d!=null&&Object.keys(d).forEach(c=>{if(s===n&&u===e){const m=d[c];m.transform=H(m.sheetTransform,this._selectionRenderService,this._skeletonManagerService),o.push(d[c])}else a.push(d[c])})})}),this._drawingManagerService.removeNotification(a),this._drawingManagerService.addNotification(o)},0)}))}_sheetRefreshListener(){this.disposeWithMe(this._commandService.onCommandExecuted(i=>{Mt.includes(i.id)&&requestIdleCallback(()=>{const t=i.params,{unitId:n,subUnitId:e,ranges:r}=t;this._refreshDrawingTransform(n,e,r)})}))}_refreshDrawingTransform(i,t,n){const e=this._drawingManagerService.getDrawingData(i,t),r=[];Object.keys(e).forEach(o=>{const a=e[o],{sheetTransform:s,anchorType:l=h.SheetDrawingAnchorType.Position}=a;if(l===h.SheetDrawingAnchorType.None)return!0;const{from:u,to:d}=s,{row:c,column:m}=u,{row:g,column:S}=d;for(let f=0;f<n.length;f++){const v=n[f],{startRow:y,endRow:M,startColumn:C,endColumn:R}=v;if(p.Rectangle.intersects({startRow:y,endRow:M,startColumn:C,endColumn:R},{startRow:c,endRow:g,startColumn:m,endColumn:S})||c>M||m>R){r.push({...a,transform:H(s,this._selectionRenderService,this._skeletonManagerService)});break}}}),r.length!==0&&(this._drawingManagerService.refreshTransform(r),this._commandService.syncExecuteCommand(G.id,[i]))}};we=Ct([p.OnLifecycle(p.LifecycleStages.Rendered,we),ie(0,p.ICommandService),ie(1,B.Inject(_.SheetInterceptorService)),ie(2,L.IRenderManagerService),ie(3,h.ISheetDrawingService),ie(4,A.IDrawingManagerService),ie(5,p.IUniverInstanceService)],we);var Dt=Object.defineProperty,Tt=Object.getOwnPropertyDescriptor,Rt=(i,t,n,e)=>{for(var r=e>1?void 0:e?Tt(t,n):t,o=i.length-1,a;o>=0;o--)(a=i[o])&&(r=(e?a(t,n,r):a(r))||r);return e&&r&&Dt(t,n,r),r},te=(i,t)=>(n,e)=>t(n,e,i);function Et(i,t,n,e){const{scaleX:r,scaleY:o}=t.getAncestorScale(),a=t.getViewport(L.SHEET_VIEWPORT_KEY.VIEW_MAIN),s={left:!0,top:!0};if(!a)return{...i,absolute:s};const{left:l,right:u,top:d,bottom:c}=i,m=e.getFreeze(),{startColumn:g,startRow:S,xSplit:f,ySplit:v}=m,y=n.getNoMergeCellPositionByIndexWithNoHeader(S-v,g-f),M=n.getNoMergeCellPositionByIndexWithNoHeader(S,g),{rowHeaderWidth:C,columnHeaderHeight:R}=n,I=M.startX-y.startX,O=M.startY-y.startY,{top:w,left:U,viewportScrollX:E,viewportScrollY:j}=a;let P,b;l<U?(s.left=!0,P=(I+C+(l-U))*r,b=Math.max(Math.min((I+C+(u-U))*r,(I+C)*r),(u-E)*r)):(s.left=!1,P=Math.max((l-E)*r,(I+C)*r),b=Math.max((u-E)*r,(I+C)*r));let D,W;return d<w?(s.top=!0,D=(O+R+(d-w))*o,W=Math.max(Math.min((O+R+(u-w))*o,(O+R)*o),(c-j)*o)):(s.top=!1,D=Math.max((d-j)*o,(O+R)*o),W=Math.max((c-j)*o,(O+R)*o)),{left:P,right:b,top:D,bottom:W,absolute:s}}const Oe=(i,t,n,e)=>{const{scene:r}=t,{left:o,top:a,width:s,height:l,angle:u}=i,d={left:o,right:o+s,top:a,bottom:a+l},c=Et(d,r,n,e);return{startX:c.left,endX:c.right,startY:c.top,endY:c.bottom,rotate:u,width:s,height:l,absolute:c.absolute}};T.SheetCanvasFloatDomManagerService=class extends p.Disposable{constructor(n,e,r,o,a,s,l){super();z(this,"_domLayerMap",new Map);z(this,"_domLayerInfoMap",new Map);z(this,"_transformChange$",new k.Subject);z(this,"transformChange$",this._transformChange$.asObservable());z(this,"_remove$",new k.Subject);z(this,"remove$",this._remove$.asObservable());this._renderManagerService=n,this._univerInstanceService=e,this._commandService=r,this._drawingManagerService=o,this._selectionRenderService=a,this._canvasFloatDomService=s,this._sheetDrawingService=l,this._drawingAddListener(),this._scrollUpdateListener(),this._featureUpdateListener(),this._deleteListener()}_ensureMap(n,e){let r=this._domLayerMap.get(n);r||(r=new Map,this._domLayerMap.set(n,r));let o=r.get(e);return o||(o=new Map,r.set(e,o)),o}_getSceneAndTransformerByDrawingSearch(n){if(n==null)return;const e=this._renderManagerService.getRenderById(n),r=e==null?void 0:e.scene;if(e==null||r==null)return null;const o=r.getTransformerByCreate(),a=e.engine.getCanvasElement();return{scene:r,transformer:o,renderObject:e,canvas:a}}_drawingAddListener(){this.disposeWithMe(this._drawingManagerService.add$.subscribe(n=>{n.forEach(e=>{var He,Ye;const{unitId:r,subUnitId:o,drawingId:a}=e,s=_.getSheetCommandTarget(this._univerInstanceService,{unitId:r,subUnitId:o}),l=this._drawingManagerService.getDrawingByParam(e),u=(He=this._renderManagerService.getRenderById(r))==null?void 0:He.with($.SheetSkeletonManagerService).getWorksheetSkeleton(o);if(l==null||s==null||u==null)return;const{transform:d,drawingType:c}=l;if(c!==p.DrawingTypeEnum.DRAWING_DOM)return;const m=this._getSceneAndTransformerByDrawingSearch(r);if(m==null)return;const{scene:g,canvas:S}=m;if(d==null)return!0;const{left:f,top:v,width:y,height:M,angle:C,flipX:R,flipY:I,skewX:O,skewY:w}=d,U=A.getDrawingShapeKeyByDrawingSearch({unitId:r,subUnitId:o,drawingId:a}),E=g.getObject(U);if(E!=null){E.transformByState({left:f,top:v,width:y,height:M,angle:C,flipX:R,flipY:I,skewX:O,skewY:w});return}const j={left:f,top:v,width:y,height:M,zIndex:this._drawingManagerService.getDrawingOrder(r,o).length-1},P=new L.Rect(U,j);g.addObject(P,L.DRAWING_OBJECT_LAYER_INDEX).attachTransformerTo(P);const b=this._ensureMap(r,o),D=new p.DisposableCollection,W=Oe(P,m.renderObject,u.skeleton,s.worksheet),Y=new k.BehaviorSubject(W),ne={dispose:D,rect:P,position$:Y,unitId:r,subUnitId:o};this._canvasFloatDomService.addFloatDom({position$:Y,id:a,componentKey:l.componentKey,onPointerDown:X=>{S.dispatchEvent(new PointerEvent(X.type,X))},onPointerMove:X=>{S.dispatchEvent(new PointerEvent(X.type,X))},onPointerUp:X=>{S.dispatchEvent(new PointerEvent(X.type,X))},onWheel:X=>{S.dispatchEvent(new WheelEvent(X.type,X))},props:(Ye=b.get(a))==null?void 0:Ye.props});const ke=P.onTransformChange$.subscribeEvent(()=>{const X=Oe(P,m.renderObject,u.skeleton,s.worksheet);Y.next(X)});D.add(()=>{this._canvasFloatDomService.removeFloatDom(a)}),ke&&D.add(ke),this._domLayerInfoMap.set(a,ne)})}))}_scrollUpdateListener(){this.disposeWithMe(this._commandService.onCommandExecuted(n=>{var r,o;const e=(a,s)=>{var g;const l=this._getSceneAndTransformerByDrawingSearch(a),u=this._ensureMap(a,s),d=Array.from(u.keys()),c=_.getSheetCommandTarget(this._univerInstanceService,{unitId:a,subUnitId:s}),m=(g=this._renderManagerService.getRenderById(a))==null?void 0:g.with($.SheetSkeletonManagerService).getWorksheetSkeleton(s);!l||!c||!m||d.forEach(S=>{const f=this._domLayerInfoMap.get(S);if(f){const v=Oe(f.rect,l.renderObject,m.skeleton,c.worksheet);f.position$.next(v)}})};if(n.id===$.SetScrollOperation.id){const a=n.params,{unitId:s,sheetId:l}=a;e(s,l)}else if(n.id===$.SetZoomRatioOperation.id){const a=n.params,{unitId:s}=a;Array.from((o=(r=this._domLayerMap.get(s))==null?void 0:r.keys())!=null?o:[]).forEach(u=>{e(s,u)})}else if(n.id===_.SetFrozenMutation.id){const{unitId:a,subUnitId:s}=n.params;e(a,s)}}))}_getPosition(n){const{startX:e,endX:r,startY:o,endY:a}=n,s=this._selectionRenderService.getSelectionCellByPosition(e,o);if(s==null)return;const l={column:s.actualColumn,columnOffset:e-s.startX,row:s.actualRow,rowOffset:o-s.startY},u=this._selectionRenderService.getSelectionCellByPosition(r,a);if(u==null)return;const d={column:u.actualColumn,columnOffset:r-u.startX,row:u.actualRow,rowOffset:a-u.startY};return{from:l,to:d}}_featureUpdateListener(){this.disposeWithMe(this._drawingManagerService.update$.subscribe(n=>{n.forEach(e=>{const r=this._drawingManagerService.getDrawingByParam(e);if(!r||r.drawingType!==p.DrawingTypeEnum.DRAWING_DOM)return;const o={...r.transform};this._transformChange$.next({id:e.drawingId,value:o})})}))}_deleteListener(){this.disposeWithMe(this._drawingManagerService.remove$.subscribe(n=>{n.forEach(e=>{this._removeDom(e.drawingId)})}))}addFloatDomToPosition(n){const e=_.getSheetCommandTarget(this._univerInstanceService,{unitId:n.unitId,subUnitId:n.subUnitId});if(!e)throw new Error("cannot find current target!");const{unitId:r,subUnitId:o}=e,{initPosition:a,componentKey:s}=n,l=p.Tools.generateRandomId(),u=this._getPosition(a);if(u==null)return;this._ensureMap(r,o).set(l,n);const c={unitId:r,subUnitId:o,drawingId:l,drawingType:p.DrawingTypeEnum.DRAWING_DOM,componentKey:s,sheetTransform:u,transform:{left:a.startX,top:a.startY,width:a.endX-a.startX,height:a.endY-a.startY}};return this._commandService.executeCommand(fe.id,{unitId:r,drawings:[c]}),{id:l,dispose:()=>{this._removeDom(l,!0)}}}_removeDom(n,e=!1){const r=this._domLayerInfoMap.get(n);if(!r)return;const{unitId:o,subUnitId:a}=r;this._domLayerInfoMap.delete(n),r.dispose.dispose();const s=this._getSceneAndTransformerByDrawingSearch(o);if(s&&s.scene.removeObject(r.rect),e){this._ensureMap(o,a).delete(n);const u=this._drawingManagerService.getDrawingByParam({unitId:o,subUnitId:a,drawingId:n});if(!u)return;const d=this._sheetDrawingService.getBatchRemoveOp([u]),{redo:c,objects:m}=d;this._commandService.syncExecuteCommand(h.SetDrawingApplyMutation.id,{unitId:o,subUnitId:a,op:c,objects:m,type:h.DrawingApplyType.REMOVE})}}},T.SheetCanvasFloatDomManagerService=Rt([te(0,B.Inject(L.IRenderManagerService)),te(1,p.IUniverInstanceService),te(2,B.Inject(p.ICommandService)),te(3,A.IDrawingManagerService),te(4,$.ISheetSelectionRenderService),te(5,B.Inject(F.CanvasFloatDomService)),te(6,h.ISheetDrawingService)],T.SheetCanvasFloatDomManagerService);var bt=Object.defineProperty,Ot=Object.getOwnPropertyDescriptor,Pt=(i,t,n,e)=>{for(var r=e>1?void 0:e?Ot(t,n):t,o=i.length-1,a;o>=0;o--)(a=i[o])&&(r=(e?a(t,n,r):a(r))||r);return e&&r&&bt(t,n,r),r},_e=(i,t)=>(n,e)=>t(n,e,i);let Ie=class extends p.Disposable{constructor(i,t,n,e){super(),this._sheetPrintInterceptorService=i,this._drawingRenderService=t,this._drawingManagerService=n,this._renderManagerService=e,this._initPrinting()}_initPrinting(){this.disposeWithMe(this._sheetPrintInterceptorService.interceptor.intercept(this._sheetPrintInterceptorService.interceptor.getInterceptPoints().PRINTING_COMPONENT_COLLECT,{handler:(i,t,n)=>{const{unitId:e,scene:r,subUnitId:o}=t,a=this._drawingManagerService.getDrawingDataForUnit(e),s=a==null?void 0:a[o];return s&&s.order.forEach(l=>{this._drawingRenderService.renderDrawing(s.data[l],r)}),n()}})),this.disposeWithMe(this._sheetPrintInterceptorService.interceptor.intercept(this._sheetPrintInterceptorService.interceptor.getInterceptPoints().PRINTING_RANGE,{handler:(i,t,n)=>{const{unitId:e,subUnitId:r}=t,o=this._renderManagerService.getRenderById(e);if(!o)return n(i);const a=o.with($.SheetSkeletonManagerService).getWorksheetSkeleton(r);if(!a)return n(i);const s=this._drawingManagerService.getDrawingDataForUnit(e),l=s==null?void 0:s[t.subUnitId];if(!l)return n(i);const{scaleX:u,scaleY:d}=o.scene,c=i?{...i}:{startColumn:0,endColumn:0,endRow:0,startRow:0},m=l.order.map(g=>l.data[g]).filter(g=>g.drawingType!==A.DrawingTypeEnum.DRAWING_DOM);return m.length?(m.forEach(g=>{if(!g.groupId&&g.transform&&p.Tools.isDefine(g.transform.left)&&p.Tools.isDefine(g.transform.top)&&p.Tools.isDefine(g.transform.width)&&p.Tools.isDefine(g.transform.height)){const S=a.skeleton.getCellPositionByOffset(g.transform.left,g.transform.top,u,d,{x:0,y:0}),f=a.skeleton.getCellPositionByOffset(g.transform.left+g.transform.width,g.transform.top+g.transform.height,u,d,{x:0,y:0});S.column<c.startColumn&&(c.startColumn=S.column),S.row<c.startRow&&(c.startRow=S.row),c.endRow<f.row&&(c.endRow=f.row),c.endColumn<f.column&&(c.endColumn=f.column)}}),n(c)):n(i)}}))}};Ie=Pt([p.OnLifecycle(p.LifecycleStages.Rendered,Ie),_e(0,B.Inject($.SheetPrintInterceptorService)),_e(1,B.Inject(Q.DrawingRenderService)),_e(2,A.IDrawingManagerService),_e(3,L.IRenderManagerService)],Ie);var At=Object.defineProperty,Ut=Object.getOwnPropertyDescriptor,Nt=(i,t,n,e)=>{for(var r=e>1?void 0:e?Ut(t,n):t,o=i.length-1,a;o>=0;o--)(a=i[o])&&(r=(e?a(t,n,r):a(r))||r);return e&&r&&At(t,n,r),r},ue=(i,t)=>(n,e)=>t(n,e,i);let Ce=class extends p.Disposable{constructor(i,t,n,e,r){super(),this._drawingManagerService=i,this._renderManagerService=t,this._permissionService=n,this._univerInstanceService=e,this._userManagerService=r,this._initDrawingVisible(),this._initDrawingEditable(),this._initViewPermissionChange(),this._initEditPermissionChange()}_initDrawingVisible(){const i=this._univerInstanceService.getCurrentTypeOfUnit$(p.UniverInstanceType.UNIVER_SHEET);this.disposeWithMe(k.combineLatest([i,this._userManagerService.currentUser$]).subscribe(([t,n])=>{if(!t){this._drawingManagerService.setDrawingVisible(!1);return}t.activeSheet$.subscribe(e=>{if(!e){this._drawingManagerService.setDrawingVisible(!1);return}const r=t.getUnitId(),o=e.getSheetId();if(this._permissionService.composePermission([new _.WorkbookViewPermission(r).id,new _.WorksheetViewPermission(r,o).id]).every(s=>s.value))this._drawingManagerService.setDrawingVisible(!0);else{this._drawingManagerService.setDrawingVisible(!1);const s=t.getUnitId(),l=e.getSheetId(),u=this._drawingManagerService.getDrawingData(s,l),d=Object.values(u),c=this._renderManagerService.getRenderById(s),m=c==null?void 0:c.scene;if(m==null)return;m.getAllObjects().forEach(S=>{S.classType===L.RENDER_CLASS_TYPE.IMAGE&&d.some(f=>S.oKey.includes(f.drawingId))&&m.removeObject(S)})}})}))}_initDrawingEditable(){const i=this._univerInstanceService.getCurrentTypeOfUnit$(p.UniverInstanceType.UNIVER_SHEET);this.disposeWithMe(k.combineLatest([i,this._userManagerService.currentUser$]).subscribe(([t,n])=>{if(!t){this._drawingManagerService.setDrawingEditable(!1);return}t.activeSheet$.subscribe(e=>{if(!e){this._drawingManagerService.setDrawingEditable(!1);return}const r=t.getUnitId(),o=e.getSheetId();if(this._permissionService.composePermission([new _.WorkbookEditablePermission(r).id,new _.WorksheetEditPermission(r,o).id]).every(s=>s.value))this._drawingManagerService.setDrawingEditable(!0);else{this._drawingManagerService.setDrawingEditable(!1);const s=t.getUnitId(),l=e.getSheetId(),u=this._drawingManagerService.getDrawingData(s,l),d=Object.values(u),c=this._renderManagerService.getRenderById(s),m=c==null?void 0:c.scene;if(m==null)return;m.getAllObjects().forEach(S=>{S.classType===L.RENDER_CLASS_TYPE.IMAGE&&d.some(f=>S.oKey.includes(f.drawingId))&&m.detachTransformerFrom(S)})}})}))}_initViewPermissionChange(){const i=this._univerInstanceService.getCurrentTypeOfUnit$(p.UniverInstanceType.UNIVER_SHEET);this.disposeWithMe(k.combineLatest([i,this._userManagerService.currentUser$]).subscribe(([t,n])=>{t&&t.activeSheet$.subscribe(e=>{var c;if(!e)return;const r=t.getUnitId(),o=e.getSheetId();let a=!0;const s=this._renderManagerService.getRenderById(r),l=s==null?void 0:s.scene;if(l==null)return;const u=l.getTransformerByCreate(),d=this._permissionService.composePermission$([new _.WorkbookViewPermission(r).id,new _.WorksheetViewPermission(r,o).id]).pipe(k.map(m=>m.every(g=>g.value)));d==null||d.pipe(k.filter(m=>m!==a),k.distinctUntilChanged()).subscribe({next:m=>{a=m,this._drawingManagerService.setDrawingVisible(m);const g=l.getAllObjects(),S=this._drawingManagerService.getDrawingData(r,o),f=Object.values(S);m?this._drawingManagerService.addNotification(f):(g.forEach(v=>{v.classType===L.RENDER_CLASS_TYPE.IMAGE&&f.some(y=>v.oKey.includes(y.drawingId))&&l.removeObject(v)}),u.clearSelectedObjects())}}),(c=this._permissionService.getPermissionPoint$(new _.WorksheetViewPermission(r,o).id))==null||c.pipe(k.filter(m=>m.value!==a),k.distinctUntilChanged()).subscribe({complete:()=>{a=!0,this._drawingManagerService.setDrawingVisible(!0);const m=this._drawingManagerService.getDrawingData(r,o),g=Object.values(m);this._drawingManagerService.addNotification(g)}})})}))}_initEditPermissionChange(){const i=this._univerInstanceService.getCurrentTypeOfUnit$(p.UniverInstanceType.UNIVER_SHEET);this.disposeWithMe(k.combineLatest([i,this._userManagerService.currentUser$]).subscribe(([t,n])=>{t&&t.activeSheet$.subscribe(e=>{var c;if(!e)return;const r=t.getUnitId(),o=e.getSheetId();let a=!0;const s=this._renderManagerService.getRenderById(r),l=s==null?void 0:s.scene;if(l==null)return;const u=l.getTransformerByCreate(),d=this._permissionService.composePermission$([new _.WorkbookEditablePermission(r).id,new _.WorksheetEditPermission(r,o).id]).pipe(k.map(m=>m.every(g=>g.value)));d==null||d.pipe(k.filter(m=>m!==a),k.distinctUntilChanged()).subscribe({next:m=>{a=m,this._drawingManagerService.setDrawingEditable(m);const g=l.getAllObjects(),S=this._drawingManagerService.getDrawingData(r,o),f=Object.values(S);m?(g.forEach(v=>{v.classType===L.RENDER_CLASS_TYPE.IMAGE&&f.some(y=>v.oKey.includes(y.drawingId))&&l.attachTransformerTo(v)}),this._drawingManagerService.addNotification(f)):(g.forEach(v=>{v.classType===L.RENDER_CLASS_TYPE.IMAGE&&f.some(y=>v.oKey.includes(y.drawingId))&&l.detachTransformerFrom(v)}),u.clearSelectedObjects())}}),(c=this._permissionService.getPermissionPoint$(new _.WorksheetEditPermission(r,o).id))==null||c.pipe(k.filter(m=>m.value!==a),k.distinctUntilChanged()).subscribe({complete:()=>{a=!0;const m=t.getUnitId(),g=e.getSheetId(),S=this._drawingManagerService.getDrawingData(m,g),f=Object.values(S),v=this._renderManagerService.getRenderById(m),y=v==null?void 0:v.scene;if(y==null)return;this._drawingManagerService.setDrawingEditable(!0),y.getAllObjects().forEach(C=>{C.classType===L.RENDER_CLASS_TYPE.IMAGE&&f.some(R=>C.oKey.includes(R.drawingId))&&y.detachTransformerFrom(C)})}})})}))}};Ce=Nt([p.OnLifecycle(p.LifecycleStages.Rendered,Ce),ue(0,A.IDrawingManagerService),ue(1,L.IRenderManagerService),ue(2,p.IPermissionService),ue(3,p.IUniverInstanceService),ue(4,B.Inject(p.UserManagerService))],Ce);var Lt=Object.defineProperty,jt=Object.getOwnPropertyDescriptor,Wt=(i,t,n,e)=>{for(var r=e>1?void 0:e?jt(t,n):t,o=i.length-1,a;o>=0;o--)(a=i[o])&&(r=(e?a(t,n,r):a(r))||r);return e&&r&&Lt(t,n,r),r},Pe=(i,t)=>(n,e)=>t(n,e,i);let ye=class extends p.Disposable{constructor(t,n,e){super();z(this,"_copyInfo");this._sheetClipboardService=t,this._renderManagerService=n,this._sheetDrawingService=e,this._initCopyPaste()}_initCopyPaste(){this._sheetClipboardService.addClipboardHook({id:"SHEET_IMAGE_UI_PLUGIN",onBeforeCopy:(t,n,e)=>this._collect(t,n,e),onPasteCells:(t,n,e,r)=>{const{copyType:o=$.COPY_TYPE.COPY,pasteType:a}=r,{range:s}=t||{},{range:l,unitId:u,subUnitId:d}=n;return this._generateMutations(l,{copyType:o,pasteType:a,copyRange:s,unitId:u,subUnitId:d})},onPastePlainText:(t,n)=>({undos:[],redos:[]})})}_collect(t,n,e){var m;const r=(m=this._renderManagerService.getRenderById(t))==null?void 0:m.with($.SheetSkeletonManagerService);if(!r)return;const o=r.attachRangeWithCoord(e);if(!o)return;const{startX:a,endX:s,startY:l,endY:u}=o,d=this._sheetDrawingService.getDrawingData(t,n),c=[];Object.keys(d).forEach(g=>{const S=d[g],{transform:f}=S;if(S.anchorType!==h.SheetDrawingAnchorType.Both||!f)return;const{left:v=0,top:y=0,width:M=0,height:C=0}=f,{drawingStartX:R,drawingEndX:I,drawingStartY:O,drawingEndY:w}={drawingStartX:v,drawingEndX:v+M,drawingStartY:y,drawingEndY:y+C};a<=R&&I<=s&&l<=O&&w<=u&&c.push(S)}),c.length&&(this._copyInfo={drawings:c,unitId:t,subUnitId:n})}_generateMutations(t,n){var E;if(!this._copyInfo)return{redos:[],undos:[]};if([$.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_COL_WIDTH,$.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_VALUE,$.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMAT,$.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMULA].includes(n.pasteType))return{redos:[],undos:[]};const{copyRange:e}=n;if(!e)return{redos:[],undos:[]};const{drawings:r,unitId:o,subUnitId:a}=this._copyInfo,{ranges:[s,l],mapFunc:u}=$.virtualizeDiscreteRanges([e,t]),{row:d,col:c}=u(s.startRow,s.startColumn),{row:m,col:g}=u(l.startRow,l.startColumn),S=(E=this._renderManagerService.getRenderById(o))==null?void 0:E.with($.SheetSkeletonManagerService);if(!S)return{redos:[],undos:[]};const f=S.attachRangeWithCoord({startRow:d,endRow:d,startColumn:c,endColumn:c}),v=S.attachRangeWithCoord({startRow:m,endRow:m,startColumn:g,endColumn:g});if(!f||!v)return{redos:[],undos:[]};const y=[],M=[],C=v.startX-f.startX,R=v.startY-f.startY,I=m-d,O=g-c,w=n.copyType===$.COPY_TYPE.CUT,{_sheetDrawingService:U}=this;return r.forEach(j=>{const{transform:P,sheetTransform:b}=j;if(!P)return;const D={...j,unitId:o,subUnitId:a,drawingId:w?j.drawingId:p.Tools.generateRandomId(),transform:{...P,left:P.left+C,top:P.top+R},sheetTransform:{to:{...b.to,row:b.to.row+I,column:b.to.column+O},from:{...b.from,row:b.from.row+I,column:b.from.column+O}}};if(w){const{undo:W,redo:Y,objects:ne}=U.getBatchUpdateOp([D]);y.push({id:h.SetDrawingApplyMutation.id,params:{unitId:o,subUnitId:a,type:h.DrawingApplyType.UPDATE,op:Y,objects:ne}}),M.push({id:h.SetDrawingApplyMutation.id,params:{unitId:o,subUnitId:a,type:h.DrawingApplyType.UPDATE,op:W,objects:ne}})}else{const{undo:W,redo:Y,objects:ne}=U.getBatchAddOp([D]);y.push({id:h.SetDrawingApplyMutation.id,params:{op:Y,unitId:o,subUnitId:a,objects:ne,type:h.DrawingApplyType.INSERT}}),M.push({id:h.SetDrawingApplyMutation.id,params:{op:W,unitId:o,subUnitId:a,objects:ne,type:h.DrawingApplyType.REMOVE}})}}),{redos:y,undos:M}}};ye=Wt([p.OnLifecycle(p.LifecycleStages.Ready,ye),Pe(0,$.ISheetClipboardService),Pe(1,L.IRenderManagerService),Pe(2,h.ISheetDrawingService)],ye);var Ve=Object.defineProperty,$t=Object.getOwnPropertyDescriptor,Bt=(i,t,n)=>t in i?Ve(i,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):i[t]=n,Gt=(i,t,n,e)=>{for(var r=e>1?void 0:e?$t(t,n):t,o=i.length-1,a;o>=0;o--)(a=i[o])&&(r=(e?a(t,n,r):a(r))||r);return e&&r&&Ve(t,n,r),r},Ae=(i,t)=>(n,e)=>t(n,e,i),Fe=(i,t,n)=>Bt(i,typeof t!="symbol"?t+"":t,n);const Vt="SHEET_IMAGE_UI_PLUGIN";T.UniverSheetsDrawingUIPlugin=class extends p.Plugin{constructor(n={},e,r,o){super();z(this,"_pluginConfig");this._injector=e,this._localeService=r,this._renderManagerService=o,this._pluginConfig=p.Tools.deepMerge({},wt,n)}onStarting(n){super.onStarting(n),this._initDependencies(n)}onRendered(){this._registerRenderModules()}_initDependencies(n){const e=[[T.SheetCanvasFloatDomManagerService],[de,{useFactory:()=>this._injector.createInstance(de,this._pluginConfig)}],[he],[Ie],[Ce]],r=[Se,we];e.forEach(o=>n.add(o)),r.forEach(o=>this._renderManagerService.registerRenderModule(p.UniverInstanceType.UNIVER_SHEET,o))}_registerRenderModules(){[[ye]].forEach(n=>{this.disposeWithMe(this._renderManagerService.registerRenderModule(p.UniverInstanceType.UNIVER_SHEET,n))})}},Fe(T.UniverSheetsDrawingUIPlugin,"type",p.UniverInstanceType.UNIVER_SHEET),Fe(T.UniverSheetsDrawingUIPlugin,"pluginName",Vt),T.UniverSheetsDrawingUIPlugin=Gt([p.DependentOn(A.UniverDrawingPlugin,Q.UniverDrawingUIPlugin,h.UniverSheetsDrawingPlugin),Ae(1,B.Inject(B.Injector)),Ae(2,B.Inject(p.LocaleService)),Ae(3,L.IRenderManagerService)],T.UniverSheetsDrawingUIPlugin),T.ClearSheetDrawingTransformerOperation=G,T.DeleteDrawingsCommand=be,T.EditSheetDrawingOperation=De,T.GroupSheetDrawingCommand=Re,T.InsertCellImageOperation=ae,T.InsertFloatImageOperation=oe,T.InsertSheetDrawingCommand=fe,T.MoveDrawingsCommand=re,T.RemoveSheetDrawingCommand=ge,T.SetDrawingArrangeCommand=Te,T.SetSheetDrawingCommand=se,T.SidebarSheetDrawingOperation=Me,T.UngroupSheetDrawingCommand=Ee,Object.defineProperty(T,Symbol.toStringTag,{value:"Module"})});
|
|
1
|
+
(function(T,u){typeof exports=="object"&&typeof module<"u"?u(exports,require("@univerjs/core"),require("@univerjs/drawing-ui"),require("@univerjs/sheets-drawing"),require("@univerjs/drawing"),require("@univerjs/engine-render"),require("@univerjs/sheets-ui"),require("rxjs"),require("@univerjs/ui"),require("@univerjs/sheets"),require("react"),require("@univerjs/design"),require("clsx")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/drawing-ui","@univerjs/sheets-drawing","@univerjs/drawing","@univerjs/engine-render","@univerjs/sheets-ui","rxjs","@univerjs/ui","@univerjs/sheets","react","@univerjs/design","clsx"],u):(T=typeof globalThis<"u"?globalThis:T||self,u(T.UniverSheetsDrawingUi={},T.UniverCore,T.UniverDrawingUi,T.UniverSheetsDrawing,T.UniverDrawing,T.UniverEngineRender,T.UniverSheetsUi,T.rxjs,T.UniverUi,T.UniverSheets,T.React,T.UniverDesign,T.clsx))})(this,function(T,u,X,h,A,L,B,F,V,_,N,q,de){"use strict";var Vt=Object.defineProperty;var Ft=(T,u,X)=>u in T?Vt(T,u,{enumerable:!0,configurable:!0,writable:!0,value:X}):T[u]=X;var K=(T,u,X)=>Ft(T,typeof u!="symbol"?u+"":u,X);const $={id:"sheet.operation.clear-drawing-transformer",type:u.CommandType.MUTATION,handler:(i,r)=>{const t=i.get(L.IRenderManagerService);return r.forEach(e=>{var n,o;(o=(n=t.getRenderById(e))==null?void 0:n.scene.getTransformer())==null||o.debounceRefreshControls()}),!0}},ue={id:"sheet.command.remove-sheet-image",type:u.CommandType.COMMAND,handler:(i,r)=>{const t=i.get(u.ICommandService),e=i.get(u.IUndoRedoService),n=i.get(h.ISheetDrawingService);if(!r)return!1;const{drawings:o}=r,a=[];o.forEach(S=>{const{unitId:f}=S;a.push(f)});const s=n.getBatchRemoveOp(o),{unitId:l,subUnitId:m,undo:d,redo:c,objects:g}=s;return t.syncExecuteCommand(h.SetDrawingApplyMutation.id,{unitId:l,subUnitId:m,op:c,objects:g,type:h.DrawingApplyType.REMOVE})?(e.pushUndoRedo({unitID:l,undoMutations:[{id:h.SetDrawingApplyMutation.id,params:{unitId:l,subUnitId:m,op:d,objects:g,type:h.DrawingApplyType.INSERT}},{id:$.id,params:a}],redoMutations:[{id:h.SetDrawingApplyMutation.id,params:{unitId:l,subUnitId:m,op:c,objects:g,type:h.DrawingApplyType.REMOVE}},{id:$.id,params:a}]}),!0):!1}},Oe="COMPONENT_SHEET_DRAWING_PANEL",Ce={id:"sidebar.operation.sheet-image",type:u.CommandType.COMMAND,handler:async(i,r)=>{const t=i.get(V.ISidebarService),e=i.get(u.LocaleService),n=i.get(u.IUniverInstanceService),o=i.get(A.IDrawingManagerService);if(!_.getSheetCommandTarget(n))return!1;switch(r.value){case"open":t.open({header:{title:e.t("sheetImage.panel.title")},children:{label:Oe},onClose:()=>{o.focusDrawing(null)},width:360});break;case"close":default:t.close();break}return!0}},ye={id:"sheet.operation.edit-sheet-image",type:u.CommandType.OPERATION,handler:(i,r)=>{const t=i.get(A.IDrawingManagerService),e=i.get(u.ICommandService);return r==null?!1:(t.focusDrawing([r]),e.executeCommand(Ce.id,{value:"open"}),!0)}},me={uploadLoading:"univer-upload-loading",uploadLoadingBody:"univer-upload-loading-body",uploadLoadingBodyAnimation:"univer-upload-loading-body-animation",univerCircleAnimation:"univer-UniverCircleAnimation",uploadLoadingBodyText:"univer-upload-loading-body-text"},Ye=()=>{const i=u.useDependency(A.IImageIoService),r=u.useDependency(u.LocaleService),[t,e]=N.useState(0);return N.useEffect(()=>{const n=i.change$.subscribe(o=>{e(o)});return()=>{n.unsubscribe()}},[i]),N.createElement("div",{style:{display:t>0?"block":"none"},className:me.uploadLoading},N.createElement("div",{className:me.uploadLoadingBody},N.createElement("div",{className:me.uploadLoadingBodyAnimation}),N.createElement("div",{className:me.uploadLoadingBodyText},`${r.t("uploadLoading.loading")}: ${t}`)))};var Xe=Object.defineProperty,xe=Object.getOwnPropertyDescriptor,Ke=(i,r,t,e)=>{for(var n=e>1?void 0:e?xe(r,t):r,o=i.length-1,a;o>=0;o--)(a=i[o])&&(n=(e?a(r,t,n):a(n))||n);return e&&n&&Xe(r,t,n),n},Z=(i,r)=>(t,e)=>r(t,e,i);let ge=class extends u.RxDisposable{constructor(r,t,e,n,o,a,s){super();K(this,"_initImagePopupMenu",new Set);this._injector=r,this._drawingManagerService=t,this._canvasPopManagerService=e,this._renderManagerService=n,this._univerInstanceService=o,this._contextService=a,this._uiPartsService=s,this._init()}_init(){this._univerInstanceService.getCurrentTypeOfUnit$(u.UniverInstanceType.UNIVER_SHEET).pipe(F.takeUntil(this.dispose$)).subscribe(r=>this._create(r)),this._univerInstanceService.getTypeOfUnitDisposed$(u.UniverInstanceType.UNIVER_SHEET).pipe(F.takeUntil(this.dispose$)).subscribe(r=>this._dispose(r)),this._univerInstanceService.getAllUnitsForType(u.UniverInstanceType.UNIVER_SHEET).forEach(r=>this._create(r)),this._uiPartsService.registerComponent(V.BuiltInUIPart.CONTENT,()=>u.connectInjector(Ye,this._injector))}_dispose(r){const t=r.getUnitId();this._renderManagerService.removeRender(t)}_create(r){if(!r)return;const t=r.getUnitId();this._renderManagerService.has(t)&&!this._initImagePopupMenu.has(t)&&(this._popupMenuListener(t),this._initImagePopupMenu.add(t))}_hasCropObject(r){const t=r.getAllObjects();for(const e of t)if(e instanceof X.ImageCropperObject)return!0;return!1}_popupMenuListener(r){var o;const t=(o=this._renderManagerService.getRenderById(r))==null?void 0:o.scene;if(!t)return;const e=t.getTransformerByCreate();if(!e)return;let n;this.disposeWithMe(u.toDisposable(e.createControl$.subscribe(()=>{if(this._contextService.setContextValue(u.FOCUSING_COMMON_DRAWINGS,!0),this._hasCropObject(t))return;const a=e.getSelectedObjectMap();if(a.size>1){n==null||n.dispose();return}const s=a.values().next().value;if(!s)return;const l=s.oKey,m=this._drawingManagerService.getDrawingOKey(l);if(!m)return;const{unitId:d,subUnitId:c,drawingId:g}=m;n==null||n.dispose(),n=this.disposeWithMe(this._canvasPopManagerService.attachPopupToObject(s,{componentKey:X.COMPONENT_IMAGE_POPUP_MENU,direction:"horizontal",offset:[2,0],extraProps:{menuItems:this._getImageMenuItems(d,c,g)}})),this._drawingManagerService.focusDrawing([{unitId:d,subUnitId:c,drawingId:g}])}))),this.disposeWithMe(e.clearControl$.subscribe(()=>{n==null||n.dispose(),this._contextService.setContextValue(u.FOCUSING_COMMON_DRAWINGS,!1),this._drawingManagerService.focusDrawing(null)})),this.disposeWithMe(e.changing$.subscribe(()=>{n==null||n.dispose()}))}_getImageMenuItems(r,t,e){return[{label:"image-popup.edit",index:0,commandId:ye.id,commandParams:{unitId:r,subUnitId:t,drawingId:e},disable:!1},{label:"image-popup.delete",index:1,commandId:ue.id,commandParams:{unitId:r,drawings:[{unitId:r,subUnitId:t,drawingId:e}]},disable:!1},{label:"image-popup.crop",index:2,commandId:X.OpenImageCropOperation.id,commandParams:{unitId:r,subUnitId:t,drawingId:e},disable:!1},{label:"image-popup.reset",index:3,commandId:X.ImageResetSizeOperation.id,commandParams:[{unitId:r,subUnitId:t,drawingId:e}],disable:!1}]}};ge=Ke([u.OnLifecycle(u.LifecycleStages.Steady,ge),Z(0,u.Inject(u.Injector)),Z(1,A.IDrawingManagerService),Z(2,u.Inject(B.SheetCanvasPopManagerService)),Z(3,L.IRenderManagerService),Z(4,u.IUniverInstanceService),Z(5,u.IContextService),Z(6,u.Inject(V.IUIPartsService))],ge);const re={id:"sheet.operation.insert-float-image",type:u.CommandType.OPERATION,handler:(i,r)=>!0},ie={id:"sheet.operation.insert-cell-image",type:u.CommandType.OPERATION,handler:(i,r)=>!0},pe={id:"sheet.command.insert-sheet-image",type:u.CommandType.COMMAND,handler:(i,r)=>{const t=i.get(u.ICommandService),e=i.get(u.IUndoRedoService),n=i.get(h.ISheetDrawingService);if(!r)return!1;const o=r.drawings,a=o.map(S=>S.unitId),s=n.getBatchAddOp(o),{unitId:l,subUnitId:m,undo:d,redo:c,objects:g}=s;return t.syncExecuteCommand(h.SetDrawingApplyMutation.id,{op:c,unitId:l,subUnitId:m,objects:g,type:h.DrawingApplyType.INSERT})?(e.pushUndoRedo({unitID:l,undoMutations:[{id:h.SetDrawingApplyMutation.id,params:{op:d,unitId:l,subUnitId:m,objects:g,type:h.DrawingApplyType.REMOVE}},{id:$.id,params:a}],redoMutations:[{id:h.SetDrawingApplyMutation.id,params:{op:c,unitId:l,subUnitId:m,objects:g,type:h.DrawingApplyType.INSERT}},{id:$.id,params:a}]}),!0):!1}},oe={id:"sheet.command.set-sheet-image",type:u.CommandType.COMMAND,handler:(i,r)=>{const t=i.get(u.ICommandService),e=i.get(u.IUndoRedoService),n=i.get(h.ISheetDrawingService);if(!r)return!1;const{drawings:o}=r,a=n.getBatchUpdateOp(o),{unitId:s,subUnitId:l,undo:m,redo:d,objects:c}=a;return t.syncExecuteCommand(h.SetDrawingApplyMutation.id,{unitId:s,subUnitId:l,op:d,objects:c,type:h.DrawingApplyType.UPDATE})?(e.pushUndoRedo({unitID:s,undoMutations:[{id:h.SetDrawingApplyMutation.id,params:{unitId:s,subUnitId:l,op:m,objects:c,type:h.DrawingApplyType.UPDATE}},{id:$.id,params:[s]}],redoMutations:[{id:h.SetDrawingApplyMutation.id,params:{unitId:s,subUnitId:l,op:d,objects:c,type:h.DrawingApplyType.UPDATE}},{id:$.id,params:[s]}]}),!0):!1}},Me={id:"sheet.command.set-drawing-arrange",type:u.CommandType.COMMAND,handler:(i,r)=>{const t=i.get(u.ICommandService),e=i.get(u.IUndoRedoService);if(!r)return!1;const n=i.get(h.ISheetDrawingService),{unitId:o,subUnitId:a,drawingIds:s,arrangeType:l}=r,m={unitId:o,subUnitId:a,drawingIds:s};let d;if(l===A.ArrangeTypeEnum.forward?d=n.getForwardDrawingsOp(m):l===A.ArrangeTypeEnum.backward?d=n.getBackwardDrawingOp(m):l===A.ArrangeTypeEnum.front?d=n.getFrontDrawingsOp(m):l===A.ArrangeTypeEnum.back&&(d=n.getBackDrawingsOp(m)),d==null)return!1;const{objects:c,redo:g,undo:p}=d;return t.syncExecuteCommand(h.SetDrawingApplyMutation.id,{op:g,unitId:o,subUnitId:a,objects:c,type:h.DrawingApplyType.ARRANGE})?(e.pushUndoRedo({unitID:o,undoMutations:[{id:h.SetDrawingApplyMutation.id,params:{op:p,unitId:o,subUnitId:a,objects:c,type:h.DrawingApplyType.ARRANGE}}],redoMutations:[{id:h.SetDrawingApplyMutation.id,params:{op:g,unitId:o,subUnitId:a,objects:c,type:h.DrawingApplyType.ARRANGE}}]}),!0):!1}};function ze(i){const r=[];return i.forEach(t=>{const{parent:e,children:n}=t,{unitId:o,subUnitId:a,drawingId:s}=e,l=L.getGroupState(0,0,n.map(c=>c.transform||{})),m=n.map(c=>{const g=c.transform||{left:0,top:0},{unitId:p,subUnitId:S,drawingId:f}=c;return{unitId:p,subUnitId:S,drawingId:f,transform:{...g,left:g.left-l.left,top:g.top-l.top},groupId:s}}),d={unitId:o,subUnitId:a,drawingId:s,drawingType:A.DrawingTypeEnum.DRAWING_GROUP,transform:l};r.push({parent:d,children:m})}),r}function qe(i){const r=[];return i.forEach(t=>{const{parent:e,children:n}=t,{unitId:o,subUnitId:a,drawingId:s,transform:l={width:0,height:0}}=e;if(l==null)return;const m=n.map(c=>{const{transform:g}=c,{unitId:p,subUnitId:S,drawingId:f}=c,v=L.transformObjectOutOfGroup(g||{},l,l.width||0,l.height||0);return{unitId:p,subUnitId:S,drawingId:f,transform:v,groupId:void 0}}),d={unitId:o,subUnitId:a,drawingId:s,drawingType:A.DrawingTypeEnum.DRAWING_GROUP,transform:{left:0,top:0}};r.push({parent:d,children:m})}),r}const De={id:"sheet.command.group-sheet-image",type:u.CommandType.COMMAND,handler:(i,r)=>{const t=i.get(u.ICommandService),e=i.get(u.IUndoRedoService),n=i.get(h.ISheetDrawingService);if(!r)return!1;const o=[];r.forEach(({parent:p,children:S})=>{o.push(p.unitId),S.forEach(f=>{o.push(f.unitId)})});const a=n.getGroupDrawingOp(r),{unitId:s,subUnitId:l,undo:m,redo:d,objects:c}=a;return t.syncExecuteCommand(h.SetDrawingApplyMutation.id,{op:d,unitId:s,subUnitId:l,objects:c,type:h.DrawingApplyType.GROUP})?(e.pushUndoRedo({unitID:s,undoMutations:[{id:h.SetDrawingApplyMutation.id,params:{op:m,unitId:s,subUnitId:l,objects:qe(c),type:h.DrawingApplyType.UNGROUP}},{id:$.id,params:o}],redoMutations:[{id:h.SetDrawingApplyMutation.id,params:{op:d,unitId:s,subUnitId:l,objects:c,type:h.DrawingApplyType.GROUP}},{id:$.id,params:o}]}),!0):!1}},Te={id:"sheet.command.ungroup-sheet-image",type:u.CommandType.COMMAND,handler:(i,r)=>{const t=i.get(u.ICommandService),e=i.get(u.IUndoRedoService),n=i.get(h.ISheetDrawingService);if(!r)return!1;const o=[];r.forEach(({parent:p,children:S})=>{o.push(p.unitId),S.forEach(f=>{o.push(f.unitId)})});const a=n.getUngroupDrawingOp(r),{unitId:s,subUnitId:l,undo:m,redo:d,objects:c}=a;return t.syncExecuteCommand(h.SetDrawingApplyMutation.id,{op:d,unitId:s,subUnitId:l,objects:c,type:h.DrawingApplyType.UNGROUP})?(e.pushUndoRedo({unitID:s,undoMutations:[{id:h.SetDrawingApplyMutation.id,params:{op:m,unitId:s,subUnitId:l,objects:ze(c),type:h.DrawingApplyType.GROUP}},{id:$.id,params:o}],redoMutations:[{id:h.SetDrawingApplyMutation.id,params:{op:d,unitId:s,subUnitId:l,objects:c,type:h.DrawingApplyType.UNGROUP}},{id:$.id,params:o}]}),!0):!1}};function k(i,r,t){const{from:e,to:n,flipY:o=!1,flipX:a=!1,angle:s=0,skewX:l=0,skewY:m=0}=i,{column:d,columnOffset:c,row:g,rowOffset:p}=e,{column:S,columnOffset:f,row:v,rowOffset:y}=n,M=t.attachRangeWithCoord({startColumn:d,endColumn:d,startRow:g,endRow:g});if(M==null)return;const C=t.attachRangeWithCoord({startColumn:S,endColumn:S,startRow:v,endRow:v});if(C==null)return;const{startX:R,startY:I}=M,{startX:P,startY:w}=C;let U=L.precisionTo(R+c,1),E=L.precisionTo(I+p,1),j=L.precisionTo(P+f-U,1),O=L.precisionTo(w+y-E,1);M.startX===C.endX&&(j=0),M.startY===C.endY&&(O=0);const b=t.getCurrentSkeleton(),D=b.rowHeaderWidth+b.columnTotalWidth,W=b.columnHeaderHeight+b.rowTotalHeight;return U+j>D&&(U=D-j),E+O>W&&(E=W-O),{flipY:o,flipX:a,angle:s,skewX:l,skewY:m,left:U,top:E,width:j,height:O}}function G(i,r){const{left:t=0,top:e=0,width:n=0,height:o=0,flipY:a=!1,flipX:s=!1,angle:l=0,skewX:m=0,skewY:d=0}=i,c=r.getSelectionCellByPosition(t,e);if(c==null)return;const g={column:c.actualColumn,columnOffset:L.precisionTo(t-c.startX,1),row:c.actualRow,rowOffset:L.precisionTo(e-c.startY,1)},p=r.getSelectionCellByPosition(t+n,e+o);if(p==null)return;const S={column:p.actualColumn,columnOffset:L.precisionTo(t+n-p.startX,1),row:p.actualRow,rowOffset:L.precisionTo(e+o-p.startY,1)};return{flipY:a,flipX:s,angle:l,skewX:m,skewY:d,from:g,to:S}}var Je=Object.defineProperty,Ze=Object.getOwnPropertyDescriptor,Qe=(i,r,t,e)=>{for(var n=e>1?void 0:e?Ze(r,t):r,o=i.length-1,a;o>=0;o--)(a=i[o])&&(n=(e?a(r,t,n):a(n))||n);return e&&n&&Je(r,t,n),n},z=(i,r)=>(t,e)=>r(t,e,i);let he=class extends u.Disposable{constructor(i,r,t,e,n,o,a,s,l,m){super(),this._commandService=i,this._univerInstanceService=r,this._selectionManagerService=t,this._imageIoService=e,this._sheetDrawingService=n,this._drawingManagerService=o,this._contextService=a,this._messageService=s,this._localeService=l,this._renderManagerService=m,this._init()}get _selectionRenderService(){return this._renderManagerService.getRenderById(this._univerInstanceService.getCurrentUnitForType(u.UniverInstanceType.UNIVER_SHEET).getUnitId()).with(B.ISheetSelectionRenderService)}get _skeletonManagerService(){return this._renderManagerService.getRenderById(this._univerInstanceService.getCurrentUnitForType(u.UniverInstanceType.UNIVER_SHEET).getUnitId()).with(B.SheetSkeletonManagerService)}_init(){this._initCommandListeners(),this._updateImageListener(),this._updateOrderListener(),this._groupDrawingListener(),this._focusDrawingListener(),this._drawingAddListener()}_initCommandListeners(){this.disposeWithMe(this._commandService.onCommandExecuted(async i=>{if(i.id===ie.id||i.id===re.id){const r=i.params;if(r.files==null)return;const t=r.files.length;if(t>A.DRAWING_IMAGE_COUNT_LIMIT){this._messageService.show({type:q.MessageType.Error,content:this._localeService.t("update-status.exceedMaxCount",String(A.DRAWING_IMAGE_COUNT_LIMIT))});return}this._imageIoService.setWaitCount(t),i.id===ie.id?r.files.forEach(async e=>{await this._insertCellImage(e)}):r.files.forEach(async e=>{await this._insertFloatImage(e)})}}))}async _insertCellImage(i){}async _insertFloatImage(i){let r;try{r=await this._imageIoService.saveImage(i)}catch(M){const C=M.message;C===A.ImageUploadStatusType.ERROR_EXCEED_SIZE?this._messageService.show({type:q.MessageType.Error,content:this._localeService.t("update-status.exceedMaxSize",String(A.DRAWING_IMAGE_ALLOW_SIZE/(1024*1024)))}):C===A.ImageUploadStatusType.ERROR_IMAGE_TYPE?this._messageService.show({type:q.MessageType.Error,content:this._localeService.t("update-status.invalidImageType")}):C===A.ImageUploadStatusType.ERROR_IMAGE&&this._messageService.show({type:q.MessageType.Error,content:this._localeService.t("update-status.invalidImage")})}if(r==null)return;const t=this._getUnitInfo();if(t==null)return;const{unitId:e,subUnitId:n}=t,{imageId:o,imageSourceType:a,source:s,base64Cache:l}=r,{width:m,height:d,image:c}=await A.getImageSize(l||""),g=this._renderManagerService.getRenderById(e);if(g==null)return;const{width:p,height:S}=g.scene;this._imageIoService.addImageSourceCache(s,a,c);let f=1;if(m>A.DRAWING_IMAGE_WIDTH_LIMIT||d>A.DRAWING_IMAGE_HEIGHT_LIMIT){const M=A.DRAWING_IMAGE_WIDTH_LIMIT/m,C=A.DRAWING_IMAGE_HEIGHT_LIMIT/d;f=Math.max(M,C)}const v=this._getImagePosition(m*f,d*f,p,S);if(v==null)return;const y={unitId:e,subUnitId:n,drawingId:o,drawingType:A.DrawingTypeEnum.DRAWING_IMAGE,imageSourceType:a,source:s,transform:k(v,this._selectionRenderService,this._skeletonManagerService),sheetTransform:v};this._commandService.executeCommand(pe.id,{unitId:e,drawings:[y]})}_getUnitInfo(){const i=this._univerInstanceService.getCurrentUnitForType(u.UniverInstanceType.UNIVER_SHEET);if(i==null)return;const r=i.getActiveSheet();if(r==null)return;const t=i.getUnitId(),e=r.getSheetId();return{unitId:t,subUnitId:e}}_getImagePosition(i,r,t,e){const n=this._selectionManagerService.getCurrentSelections();let o={startRow:0,endRow:0,startColumn:0,endColumn:0};n&&n.length>0&&(o=n[n.length-1].range);const a=B.attachRangeWithCoord(this._skeletonManagerService.getCurrent().skeleton,o);if(a==null)return;let{startColumn:s,startRow:l,startX:m,startY:d}=a,c=!1;if(m+i>t&&(m=t-i,m<0&&(m=0,i=t),c=!0),d+r>e&&(d=e-r,d<0&&(d=0,r=e),c=!0),c){const f=this._selectionRenderService.getSelectionCellByPosition(m,d);if(f==null)return;m=f.startX,d=f.startY,s=f.actualColumn,l=f.actualRow}const g={column:s,columnOffset:0,row:l,rowOffset:0},p=this._selectionRenderService.getSelectionCellByPosition(m+i,d+r);if(p==null)return;const S={column:p.actualColumn,columnOffset:m+i-p.startX,row:p.actualRow,rowOffset:d+r-p.startY};return{from:g,to:S}}_updateOrderListener(){this._drawingManagerService.featurePluginOrderUpdate$.subscribe(i=>{const{unitId:r,subUnitId:t,drawingIds:e,arrangeType:n}=i;this._commandService.executeCommand(Me.id,{unitId:r,subUnitId:t,drawingIds:e,arrangeType:n})})}_updateImageListener(){this._drawingManagerService.featurePluginUpdate$.subscribe(i=>{const r=[];i.length!==0&&(i.forEach(t=>{const{unitId:e,subUnitId:n,drawingId:o,drawingType:a,transform:s}=t;if(s==null)return;const l=this._sheetDrawingService.getDrawingByParam({unitId:e,subUnitId:n,drawingId:o});if(l==null)return;const m=G({...l.transform,...s},this._selectionRenderService);if(m==null)return;const d={...t,transform:{...l.transform,...s,...k(m,this._selectionRenderService,this._skeletonManagerService)},sheetTransform:{...m}};r.push(d)}),r.length>0&&this._commandService.executeCommand(oe.id,{unitId:i[0].unitId,drawings:r}))})}_groupDrawingListener(){this._drawingManagerService.featurePluginGroupUpdate$.subscribe(i=>{this._commandService.executeCommand(De.id,i);const{unitId:r,subUnitId:t,drawingId:e}=i[0].parent;this._drawingManagerService.focusDrawing([{unitId:r,subUnitId:t,drawingId:e}])}),this._drawingManagerService.featurePluginUngroupUpdate$.subscribe(i=>{this._commandService.executeCommand(Te.id,i)})}_focusDrawingListener(){this.disposeWithMe(this._drawingManagerService.focus$.subscribe(i=>{i==null||i.length===0?(this._contextService.setContextValue(u.FOCUSING_COMMON_DRAWINGS,!1),this._sheetDrawingService.focusDrawing([])):(this._contextService.setContextValue(u.FOCUSING_COMMON_DRAWINGS,!0),this._sheetDrawingService.focusDrawing(i))}))}_drawingAddListener(){this.disposeWithMe(this._sheetDrawingService.add$.subscribe(i=>{this._registerDrawing(i)}))}_registerDrawing(i){i.forEach(t=>{const e=this._sheetDrawingService.getDrawingByParam(t);if(e==null)return;const{sheetTransform:n}=e;e.transform=k(n,this._selectionRenderService,this._skeletonManagerService)});const r=i[0].unitId;this._drawingManagerService.registerDrawingData(r,this._sheetDrawingService.getDrawingDataForUnit(r)),this._drawingManagerService.initializeNotification(r)}};he=Qe([u.OnLifecycle(u.LifecycleStages.Rendered,he),z(0,u.ICommandService),z(1,u.IUniverInstanceService),z(2,u.Inject(_.SheetsSelectionsService)),z(3,A.IImageIoService),z(4,h.ISheetDrawingService),z(5,A.IDrawingManagerService),z(6,u.IContextService),z(7,V.IMessageService),z(8,u.Inject(u.LocaleService)),z(9,L.IRenderManagerService)],he);var x=function(){return x=Object.assign||function(i){for(var r,t=1,e=arguments.length;t<e;t++){r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(i[n]=r[n])}return i},x.apply(this,arguments)},et=function(i,r){var t={};for(var e in i)Object.prototype.hasOwnProperty.call(i,e)&&r.indexOf(e)<0&&(t[e]=i[e]);if(i!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,e=Object.getOwnPropertySymbols(i);n<e.length;n++)r.indexOf(e[n])<0&&Object.prototype.propertyIsEnumerable.call(i,e[n])&&(t[e[n]]=i[e[n]]);return t},Ae=N.forwardRef(function(i,r){var t=i.icon,e=i.id,n=i.className,o=i.extend,a=et(i,["icon","id","className","extend"]),s="univerjs-icon univerjs-icon-".concat(e," ").concat(n||"").trim(),l=N.useRef("_".concat(rt()));return Ue(t,"".concat(e),{defIds:t.defIds,idSuffix:l.current},x({ref:r,className:s},a),o)});function Ue(i,r,t,e,n){return N.createElement(i.tag,x(x({key:r},tt(i,t,n)),e),(nt(i,t).children||[]).map(function(o,a){return Ue(o,"".concat(r,"-").concat(i.tag,"-").concat(a),t,void 0,n)}))}function tt(i,r,t){var e=x({},i.attrs);t!=null&&t.colorChannel1&&e.fill==="colorChannel1"&&(e.fill=t.colorChannel1);var n=r.defIds;return!n||n.length===0||(i.tag==="use"&&e["xlink:href"]&&(e["xlink:href"]=e["xlink:href"]+r.idSuffix),Object.entries(e).forEach(function(o){var a=o[0],s=o[1];typeof s=="string"&&(e[a]=s.replace(/url\(#(.*)\)/,"url(#$1".concat(r.idSuffix,")")))})),e}function nt(i,r){var t,e=r.defIds;return!e||e.length===0?i:i.tag==="defs"&&(!((t=i.children)===null||t===void 0)&&t.length)?x(x({},i),{children:i.children.map(function(n){return typeof n.attrs.id=="string"&&e&&e.indexOf(n.attrs.id)>-1?x(x({},n),{attrs:x(x({},n.attrs),{id:n.attrs.id+r.idSuffix})}):n})}):i}function rt(){return Math.random().toString(36).substring(2,8)}Ae.displayName="UniverIcon";var it={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"}}]},Ne=N.forwardRef(function(i,r){return N.createElement(Ae,Object.assign({},i,{id:"add-image-single",ref:r,icon:it}))});Ne.displayName="AddImageSingle";const Le={uploadFileMenu:"univer-upload-file-menu",uploadFileMenuInput:"univer-upload-file-menu-input"},je="COMPONENT_UPLOAD_FILE_MENU";var fe=(i=>(i[i.cellImage=0]="cellImage",i[i.floatImage=1]="floatImage",i))(fe||{});const ot=i=>{const{type:r}=i,t=u.useDependency(u.ICommandService),e=N.useRef(null),n=()=>{var s;(s=e.current)==null||s.click()},o=A.DRAWING_IMAGE_ALLOW_IMAGE_LIST.map(s=>`.${s.replace("image/","")}`).join(","),a=s=>{const l=s.target.files;if(l==null)return;const m=Array.from(l);r===fe.floatImage?t.executeCommand(re.id,{files:m}):r===fe.cellImage&&t.executeCommand(ie.id,{files:m}),e.current&&(e.current.value="")};return N.createElement("div",{onClick:n,className:Le.uploadFileMenu},N.createElement("input",{type:"file",className:Le.uploadFileMenuInput,ref:e,onChange:a,accept:o,multiple:!0}))},We="addition-and-subtraction-single",Be="sheet.menu.image";function at(i){return{id:Be,type:V.MenuItemType.SUBITEMS,positions:[V.MenuPosition.TOOLBAR_START],group:V.MenuGroup.TOOLBAR_FORMULAS_INSERT,icon:We,tooltip:"sheetImage.title",hidden$:V.getMenuHiddenObservable(i,u.UniverInstanceType.UNIVER_SHEET),disabled$:B.getCurrentRangeDisable$(i,{workbookTypes:[_.WorkbookEditablePermission],worksheetTypes:[_.WorksheetEditPermission],rangeTypes:[_.RangeProtectionPermissionEditPoint]})}}function st(i){return{id:re.id,title:"sheetImage.upload.float",type:V.MenuItemType.SELECTOR,label:{name:je,props:{type:fe.floatImage}},positions:[Be],hidden$:V.getMenuHiddenObservable(i,u.UniverInstanceType.UNIVER_SHEET)}}const J={imageCommonPanel:"univer-image-common-panel",imageCommonPanelGrid:"univer-image-common-panel-grid",imageCommonPanelBorder:"univer-image-common-panel-border",imageCommonPanelTitle:"univer-image-common-panel-title",imageCommonPanelSubtitle:"univer-image-common-panel-subtitle",imageCommonPanelRow:"univer-image-common-panel-row",imageCommonPanelRowVertical:"univer-image-common-panel-row-vertical",imageCommonPanelColumn:"univer-image-common-panel-column",imageCommonPanelColumnCenter:"univer-image-common-panel-column-center",imageCommonPanelInline:"univer-image-common-panel-inline",imageCommonPanelSpan2:"univer-image-common-panel-span2",imageCommonPanelSpan3:"univer-image-common-panel-span3",imageCommonPanelInput:"univer-image-common-panel-input",sheetImageMenu:"univer-sheet-image-menu",sheetImageMenuInput:"univer-sheet-image-menu-input"},ct=i=>{var C;const r=u.useDependency(u.ICommandService),t=u.useDependency(u.LocaleService),e=u.useDependency(A.IDrawingManagerService),n=u.useDependency(L.IRenderManagerService),{drawings:o}=i,a=o[0];if(a==null)return;const{unitId:s}=a,l=n.getRenderById(s),m=l==null?void 0:l.scene;if(m==null)return;const d=m.getTransformerByCreate(),[c,g]=N.useState(!0),p=(C=a.anchorType)!=null?C:h.SheetDrawingAnchorType.Position,[S,f]=N.useState(p);function v(R,I){const P=[];return R.forEach(w=>{const{oKey:U}=w,E=I.getDrawingOKey(U);if(E==null)return P.push(null),!0;const{unitId:j,subUnitId:O,drawingId:b,drawingType:D,anchorType:W,sheetTransform:H}=E;P.push({unitId:j,subUnitId:O,drawingId:b,anchorType:W,sheetTransform:H,drawingType:D})}),P}N.useEffect(()=>{const R=d.clearControl$.subscribe(P=>{P===!0&&g(!1)}),I=d.changeStart$.subscribe(P=>{var E;const{objects:w}=P,U=v(w,e);if(U.length===0)g(!1);else if(U.length>=1){g(!0);const j=((E=U[0])==null?void 0:E.anchorType)||h.SheetDrawingAnchorType.Position;f(j)}});return()=>{I.unsubscribe(),R.unsubscribe()}},[]);function y(R){f(R);const I=e.getFocusDrawings();if(I.length===0)return;const P=I.map(w=>({unitId:w.unitId,subUnitId:w.subUnitId,drawingId:w.drawingId,anchorType:R}));r.executeCommand(oe.id,{unitId:I[0].unitId,drawings:P})}const M=R=>R?"block":"none";return N.createElement("div",{className:de(J.imageCommonPanelGrid,J.imageCommonPanelBorder),style:{display:M(c)}},N.createElement("div",{className:J.imageCommonPanelRow},N.createElement("div",{className:de(J.imageCommonPanelColumn,J.imageCommonPanelTitle)},N.createElement("div",null,t.t("drawing-anchor.title")))),N.createElement("div",{className:de(J.imageCommonPanelRow)},N.createElement("div",{className:de(J.imageCommonPanelColumn)},N.createElement(q.RadioGroup,{value:S,onChange:y,direction:"vertical"},N.createElement(q.Radio,{value:h.SheetDrawingAnchorType.Both},t.t("drawing-anchor.both")),N.createElement(q.Radio,{value:h.SheetDrawingAnchorType.Position},t.t("drawing-anchor.position")),N.createElement(q.Radio,{value:h.SheetDrawingAnchorType.None},t.t("drawing-anchor.none"))))))},lt=()=>{const i=u.useDependency(A.IDrawingManagerService),r=i.getFocusDrawings(),[t,e]=N.useState(r);return N.useEffect(()=>{const n=i.focus$.subscribe(o=>{e(o)});return()=>{n.unsubscribe()}},[]),!!(t!=null&&t.length)&&N.createElement("div",{className:J.imageCommonPanel},N.createElement(X.DrawingCommonPanel,{drawings:t}),N.createElement(ct,{drawings:t}))},ee={id:"sheet.command.move-drawing",type:u.CommandType.COMMAND,handler:(i,r)=>{const t=i.get(u.ICommandService),e=i.get(h.ISheetDrawingService),n=i.get(B.ISheetSelectionRenderService),{direction:o}=r,a=e.getFocusDrawings();if(a.length===0)return!1;const s=a[0].unitId,l=a.map(d=>{const{transform:c}=d;if(c==null)return null;const g={...c},{left:p=0,top:S=0}=c;return o===u.Direction.UP?g.top=S-1:o===u.Direction.DOWN?g.top=S+1:o===u.Direction.LEFT?g.left=p-1:o===u.Direction.RIGHT&&(g.left=p+1),{...d,transform:g,sheetTransform:G(g,n)}}).filter(d=>d!=null);return t.syncExecuteCommand(oe.id,{unitId:s,drawings:l})?(t.syncExecuteCommand($.id,[s]),!0):!1}},Re={id:"sheet.command.delete-drawing",type:u.CommandType.COMMAND,handler:i=>{const r=i.get(u.ICommandService),e=i.get(h.ISheetDrawingService).getFocusDrawings();if(e.length===0)return!1;const n=e[0].unitId,o=e.map(a=>{const{unitId:s,subUnitId:l,drawingId:m,drawingType:d}=a;return{unitId:s,subUnitId:l,drawingId:m,drawingType:d}});return r.executeCommand(ue.id,{unitId:n,drawings:o})}};function ae(i){return!i.getContextValue(u.FOCUSING_FORMULA_EDITOR)&&!i.getContextValue(u.EDITOR_ACTIVATED)&&i.getContextValue(u.FOCUSING_COMMON_DRAWINGS)}const dt={id:ee.id,description:"shortcut.sheet.drawing-move-down",group:"4_sheet-drawing-view",binding:V.KeyCode.ARROW_DOWN,priority:100,preconditions:ae,staticParameters:{direction:u.Direction.DOWN}},ut={id:ee.id,description:"shortcut.sheet.drawing-move-up",group:"4_sheet-drawing-view",binding:V.KeyCode.ARROW_UP,priority:100,preconditions:ae,staticParameters:{direction:u.Direction.UP}},mt={id:ee.id,description:"shortcut.sheet.drawing-move-left",group:"4_sheet-drawing-view",binding:V.KeyCode.ARROW_LEFT,priority:100,preconditions:ae,staticParameters:{direction:u.Direction.LEFT}},gt={id:ee.id,description:"shortcut.sheet.drawing-move-right",group:"4_sheet-drawing-view",binding:V.KeyCode.ARROW_RIGHT,priority:100,preconditions:ae,staticParameters:{direction:u.Direction.RIGHT}},pt={id:Re.id,description:"shortcut.sheet.drawing-delete",group:"4_sheet-drawing-view",preconditions:ae,binding:V.KeyCode.DELETE,mac:V.KeyCode.BACKSPACE};var ht=Object.defineProperty,ft=Object.getOwnPropertyDescriptor,St=(i,r,t,e)=>{for(var n=e>1?void 0:e?ft(r,t):r,o=i.length-1,a;o>=0;o--)(a=i[o])&&(n=(e?a(r,t,n):a(n))||n);return e&&n&&ht(r,t,n),n},se=(i,r)=>(t,e)=>r(t,e,i);const vt={};let ce=class extends u.Disposable{constructor(i,r,t,e,n,o){super(),this._config=i,this._injector=r,this._componentManager=t,this._menuService=e,this._commandService=n,this._shortcutService=o,this._init()}_initCustomComponents(){const i=this._componentManager;this.disposeWithMe(i.register(We,Ne)),this.disposeWithMe(i.register(je,ot)),this.disposeWithMe(i.register(Oe,lt))}_initMenus(){const{menu:i={}}=this._config;[at,st].forEach(r=>{this._menuService.addMenuItem(r(this._injector),i)})}_initCommands(){[re,ie,pe,ue,oe,Ce,$,ye,De,Te,ee,Re,Me].forEach(i=>this.disposeWithMe(this._commandService.registerCommand(i)))}_initShortcuts(){[dt,ut,mt,gt,pt].forEach(i=>{this.disposeWithMe(this._shortcutService.registerShortcut(i))})}_init(){this._initCommands(),this._initCustomComponents(),this._initMenus(),this._initShortcuts()}};ce=St([u.OnLifecycle(u.LifecycleStages.Rendered,ce),se(1,u.Inject(u.Injector)),se(2,u.Inject(V.ComponentManager)),se(3,V.IMenuService),se(4,u.ICommandService),se(5,V.IShortcutService)],ce);var wt=Object.defineProperty,_t=Object.getOwnPropertyDescriptor,It=(i,r,t,e)=>{for(var n=e>1?void 0:e?_t(r,t):r,o=i.length-1,a;o>=0;o--)(a=i[o])&&(n=(e?a(r,t,n):a(n))||n);return e&&n&&wt(r,t,n),n},te=(i,r)=>(t,e)=>r(t,e,i);const Ct=[_.InsertRowCommand.id,_.InsertColCommand.id,_.RemoveRowCommand.id,_.RemoveColCommand.id,_.DeleteRangeMoveLeftCommand.id,_.DeleteRangeMoveUpCommand.id,_.InsertRangeMoveDownCommand.id,_.InsertRangeMoveRightCommand.id,_.DeltaRowHeightCommand.id,_.SetRowHeightCommand.id,_.DeltaColumnWidthCommand.id,_.SetColWidthCommand.id,_.SetRowHiddenCommand.id,_.SetSpecificRowsVisibleCommand.id,_.SetSpecificColsVisibleCommand.id,_.SetColHiddenCommand.id],yt=[_.SetRowVisibleMutation.id,_.SetRowHiddenMutation.id,_.SetColVisibleMutation.id,_.SetColHiddenMutation.id,_.SetWorksheetRowHeightMutation.id,_.SetWorksheetColWidthMutation.id];let Se=class extends u.Disposable{constructor(i,r,t,e,n,o){super(),this._commandService=i,this._sheetInterceptorService=r,this._renderManagerService=t,this._sheetDrawingService=e,this._drawingManagerService=n,this._univerInstanceService=o,this._init()}get _selectionRenderService(){return this._renderManagerService.getRenderById(this._univerInstanceService.getCurrentUnitForType(u.UniverInstanceType.UNIVER_SHEET).getUnitId()).with(B.ISheetSelectionRenderService)}get _skeletonManagerService(){return this._renderManagerService.getRenderById(this._univerInstanceService.getCurrentUnitForType(u.UniverInstanceType.UNIVER_SHEET).getUnitId()).with(B.SheetSkeletonManagerService)}_init(){this._sheetInterceptorListener(),this._commandListener(),this._sheetRefreshListener()}_sheetInterceptorListener(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:i=>{if(!Ct.includes(i.id))return{redos:[],undos:[]};if(i.params==null)return{redos:[],undos:[]};const r=i.id;if(r===_.InsertRowCommand.id)return this._moveRowInterceptor(i.params,"insert");if(r===_.InsertColCommand.id)return this._moveColInterceptor(i.params,"insert");if(r===_.RemoveRowCommand.id)return this._moveRowInterceptor(i.params,"remove");if(r===_.RemoveColCommand.id)return this._moveColInterceptor(i.params,"remove");if(r===_.DeleteRangeMoveLeftCommand.id){const{range:t}=i.params;return this._getRangeMoveUndo(t,0)}else if(r===_.DeleteRangeMoveUpCommand.id){const{range:t}=i.params;return this._getRangeMoveUndo(t,1)}else if(r===_.InsertRangeMoveDownCommand.id){const{range:t}=i.params;return this._getRangeMoveUndo(t,2)}else if(r===_.InsertRangeMoveRightCommand.id){const{range:t}=i.params;return this._getRangeMoveUndo(t,3)}else if(r===_.SetRowHiddenCommand.id||r===_.SetSpecificRowsVisibleCommand.id){const t=i.params,{unitId:e,subUnitId:n,ranges:o}=t;return this._getDrawingUndoForRowVisible(e,n,o)}else if(r===_.SetSpecificColsVisibleCommand.id||r===_.SetColHiddenCommand.id){const t=i.params,{unitId:e,subUnitId:n,ranges:o}=t;return this._getDrawingUndoForColVisible(e,n,o)}else if(r===_.DeltaRowHeightCommand.id||r===_.SetRowHeightCommand.id||r===_.DeltaColumnWidthCommand.id||r===_.SetColWidthCommand.id){const t=i.params,{unitId:e,subUnitId:n,ranges:o}=t,a=r===_.DeltaRowHeightCommand.id||r===_.SetRowHeightCommand.id;return this._getDrawingUndoForRowAndColSize(e,n,o,a)}return{redos:[],undos:[]}}}))}_getRangeMoveUndo(i,r){const t=_.getSheetCommandTarget(this._univerInstanceService);if(t==null)return{redos:[],undos:[]};const e=t.unitId,n=t.subUnitId,o=[],a=[],s=this._sheetDrawingService.getDrawingData(e,n),l=[],m=[];if(Object.keys(s).forEach(d=>{const c=s[d],{updateDrawings:g,deleteDrawings:p}=this._getUpdateOrDeleteDrawings(i,r,c);l.push(...g),m.push(...p)}),l.length===0&&m.length===0)return{redos:[],undos:[]};if(l.length>0){const d=this._sheetDrawingService.getBatchUpdateOp(l),{undo:c,redo:g,objects:p}=d;o.push({id:h.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:n,op:g,objects:p,type:h.DrawingApplyType.UPDATE}}),a.push({id:h.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:n,op:c,objects:p,type:h.DrawingApplyType.UPDATE}})}if(m.length>0){const d=this._sheetDrawingService.getBatchRemoveOp(m),c=d.undo,g=d.redo,p=d.objects;o.push({id:h.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:n,op:g,objects:p,type:h.DrawingApplyType.REMOVE}}),a.push({id:h.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:n,op:c,objects:p,type:h.DrawingApplyType.INSERT}})}return o.push({id:$.id,params:[e]}),a.push({id:$.id,params:[e]}),{redos:o,undos:a}}_getUpdateOrDeleteDrawings(i,r,t){const e=[],n=[],{sheetTransform:o,anchorType:a=h.SheetDrawingAnchorType.Position,transform:s,unitId:l,subUnitId:m,drawingId:d}=t,{from:c,to:g}=o,{row:p,column:S}=c,{row:f,column:v}=g;if(o==null||s==null)return{updateDrawings:e,deleteDrawings:n};const{startRow:y,endRow:M,startColumn:C,endColumn:R}=i;let I=null,P=null;if(r===0&&p>=y&&f<=M)if(S>=C&&v<=R)n.push({unitId:l,subUnitId:m,drawingId:d});else{const w=this._shrinkCol(o,s,C,R,a);I=w==null?void 0:w.newSheetTransform,P=w==null?void 0:w.newTransform}else if(r===1&&S>=C&&v<=R)if(p>=y&&f<=M)n.push({unitId:l,subUnitId:m,drawingId:d});else{const w=this._shrinkRow(o,s,y,M,a);I=w==null?void 0:w.newSheetTransform,P=w==null?void 0:w.newTransform}else if(r===2){const w=this._expandRow(o,s,y,M,a);I=w==null?void 0:w.newSheetTransform,P=w==null?void 0:w.newTransform}else if(r===3){const w=this._expandCol(o,s,C,R,a);I=w==null?void 0:w.newSheetTransform,P=w==null?void 0:w.newTransform}if(I!=null&&P!=null){const w=k(I,this._selectionRenderService,this._skeletonManagerService);e.push({...t,sheetTransform:I,transform:w})}return{updateDrawings:e,deleteDrawings:n}}_remainDrawingSize(i,r,t){const e=G({...i},this._selectionRenderService);e!=null&&r.push({...t,sheetTransform:e})}_getDrawingUndoForColVisible(i,r,t){const e=this._drawingManagerService.getDrawingData(i,r),n=[],o=[];if(Object.keys(e).forEach(d=>{const c=e[d],{sheetTransform:g,transform:p,anchorType:S=h.SheetDrawingAnchorType.Position}=c;if(S===h.SheetDrawingAnchorType.None)this._remainDrawingSize(p,n,c);else{const{from:f,to:v}=g,{row:y,column:M}=f,{row:C,column:R}=v;for(let I=0;I<t.length;I++){const P=t[I],{startRow:w,endRow:U,startColumn:E,endColumn:j}=P;if(R<E)continue;if(S===h.SheetDrawingAnchorType.Position){let D=null,W=null;if(M>=E&&M<=j){const H=this._skeletonManagerService.attachRangeWithCoord({startColumn:M,endColumn:j,startRow:f.row,endRow:v.row});if(H==null)return;W={...p,left:H.startX}}if(W!=null&&(D=G(W,this._selectionRenderService),D!=null&&W!=null)){n.push({...c,sheetTransform:D,transform:W});break}this._remainDrawingSize(p,n,c);continue}if(M>=E&&R<=j)continue;let O=null,b=null;if(M>=E&&M<=j){const D=this._skeletonManagerService.attachRangeWithCoord({startColumn:M,endColumn:j,startRow:f.row,endRow:v.row});if(D==null)return;b={...p,left:(D==null?void 0:D.startX)||0,width:((p==null?void 0:p.width)||0)-D.endX+D.startX}}else if(R>=E&&R<=j){const D=this._skeletonManagerService.attachRangeWithCoord({startColumn:E,endColumn:R,startRow:f.row,endRow:v.row});if(D==null)return;b={...p,left:D.startX-((p==null?void 0:p.width)||0)}}else{const D=this._skeletonManagerService.attachRangeWithCoord({startColumn:E,endColumn:j,startRow:f.row,endRow:v.row});if(D==null)return;if(b={...p,width:((p==null?void 0:p.width)||0)-D.endX+D.startX},O=G(b,this._selectionRenderService),O!=null&&b!=null){o.push({...c,sheetTransform:O,transform:b});break}}if(b!=null&&(O=G(b,this._selectionRenderService)),b!=null&&O!=null){n.push({...c,sheetTransform:O,transform:b});break}else this._remainDrawingSize(p,n,c)}}}),n.length===0&&o.length===0)return{redos:[],undos:[]};const{redos:a,undos:s}=this._createUndoAndRedoMutation(i,r,n),l=[],m=[];if(o.length>0){const{redos:d,undos:c}=this._createUndoAndRedoMutation(i,r,o);l.push(...d),m.push(...c)}return{redos:a,undos:s,preRedos:l,preUndos:m}}_createUndoAndRedoMutation(i,r,t){const e=this._sheetDrawingService.getBatchUpdateOp(t),{undo:n,redo:o,objects:a}=e,s=[{id:h.SetDrawingApplyMutation.id,params:{unitId:i,subUnitId:r,op:o,objects:a,type:h.DrawingApplyType.UPDATE}},{id:$.id,params:[i]}],l=[{id:h.SetDrawingApplyMutation.id,params:{unitId:i,subUnitId:r,op:n,objects:a,type:h.DrawingApplyType.UPDATE}},{id:$.id,params:[i]}];return{redos:s,undos:l}}_getDrawingUndoForRowVisible(i,r,t){const e=this._drawingManagerService.getDrawingData(i,r),n=[],o=[];if(Object.keys(e).forEach(d=>{const c=e[d],{sheetTransform:g,transform:p,anchorType:S=h.SheetDrawingAnchorType.Position}=c;if(S===h.SheetDrawingAnchorType.None)this._remainDrawingSize(p,n,c);else{const{from:f,to:v}=g,{row:y,column:M}=f,{row:C,column:R}=v;for(let I=0;I<t.length;I++){const P=t[I],{startRow:w,endRow:U,startColumn:E,endColumn:j}=P;if(C<w)continue;if(S===h.SheetDrawingAnchorType.Position){let D=null,W=null;if(y>=w&&y<=U){const H=this._skeletonManagerService.attachRangeWithCoord({startColumn:f.column,endColumn:v.column,startRow:y,endRow:U});if(H==null)return;W={...p,top:H.startY}}if(W!=null&&(D=G(W,this._selectionRenderService),D!=null&&W!=null)){n.push({...c,sheetTransform:D,transform:W});break}this._remainDrawingSize(p,n,c);continue}if(y>=w&&C<=U)continue;let O=null,b=null;if(y>=w&&y<=U){const D=this._skeletonManagerService.attachRangeWithCoord({startColumn:f.column,endColumn:v.column,startRow:y,endRow:U});if(D==null)return;b={...p,top:(D==null?void 0:D.startY)||0,height:((p==null?void 0:p.height)||0)-D.endY+D.startY}}else if(C>=w&&C<=U){const D=this._skeletonManagerService.attachRangeWithCoord({startColumn:f.column,endColumn:v.column,startRow:w,endRow:C});if(D==null)return;b={...p,top:D.startY-((p==null?void 0:p.height)||0)}}else{const D=this._skeletonManagerService.attachRangeWithCoord({startColumn:f.column,endColumn:v.column,startRow:w,endRow:U});if(D==null)return;if(b={...p,height:((p==null?void 0:p.height)||0)-D.endY+D.startY},O=G(b,this._selectionRenderService),O!=null&&b!=null){o.push({...c,sheetTransform:O,transform:b});break}}if(b!=null&&(O=G(b,this._selectionRenderService)),b!=null&&O!=null){n.push({...c,sheetTransform:O,transform:b});break}else this._remainDrawingSize(p,n,c)}}}),n.length===0&&o.length===0)return{redos:[],undos:[]};const{redos:a,undos:s}=this._createUndoAndRedoMutation(i,r,n),l=[],m=[];if(o.length>0){const{redos:d,undos:c}=this._createUndoAndRedoMutation(i,r,o);l.push(...d),m.push(...c)}return{redos:a,undos:s,preRedos:l,preUndos:m}}_getDrawingUndoForRowAndColSize(i,r,t,e){const n=this._drawingManagerService.getDrawingData(i,r),o=[];return Object.keys(n).forEach(a=>{const s=n[a],{sheetTransform:l,transform:m,anchorType:d=h.SheetDrawingAnchorType.Position}=s;if(d===h.SheetDrawingAnchorType.None)this._remainDrawingSize(m,o,s);else{const{from:c,to:g}=l,{row:p,column:S}=c,{row:f,column:v}=g;for(let y=0;y<t.length;y++){const M=t[y],{startRow:C,endRow:R,startColumn:I,endColumn:P}=M;if(f<C||v<I)continue;if(d===h.SheetDrawingAnchorType.Position&&(p<=C&&f>=R||S<=I&&v>=P)){this._remainDrawingSize(m,o,s);continue}const w=k({...l},this._selectionRenderService,this._skeletonManagerService);if(w!=null){o.push({...s,transform:w});break}}}}),o.length===0?{redos:[],undos:[]}:this._createUndoAndRedoMutation(i,r,o)}_getUnitIdAndSubUnitId(i,r){let t,e;if(r==="insert")t=i.unitId,e=i.subUnitId;else{const n=_.getSheetCommandTarget(this._univerInstanceService);if(n==null)return;t=n.unitId,e=n.subUnitId}return{unitId:t,subUnitId:e}}_moveRowInterceptor(i,r){const t=this._getUnitIdAndSubUnitId(i,r);if(t==null)return{redos:[],undos:[]};const{unitId:e,subUnitId:n}=t,{range:o}=i,a=o.startRow,s=o.endRow,l=[],m=[],d=this._sheetDrawingService.getDrawingData(e,n),c=[],g=[];if(Object.keys(d).forEach(p=>{const S=d[p],{sheetTransform:f,transform:v,anchorType:y=h.SheetDrawingAnchorType.Position}=S;if(f==null||v==null)return;let M,C;if(r==="insert"){const I=this._expandRow(f,v,a,s,y);M=I==null?void 0:I.newSheetTransform,C=I==null?void 0:I.newTransform}else{const{from:I,to:P}=f,{row:w}=I,{row:U}=P;if(w>=a&&U<=s)g.push({unitId:e,subUnitId:n,drawingId:p});else{const E=this._shrinkRow(f,v,a,s,y);M=E==null?void 0:E.newSheetTransform,C=E==null?void 0:E.newTransform}}if(!M||!C)return;const R={unitId:e,subUnitId:n,drawingId:p,transform:C,sheetTransform:M};c.push(R)}),c.length===0&&g.length===0)return{redos:[],undos:[]};if(c.length>0){const p=this._sheetDrawingService.getBatchUpdateOp(c),{undo:S,redo:f,objects:v}=p;l.push({id:h.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:n,op:f,objects:v,type:h.DrawingApplyType.UPDATE}}),m.push({id:h.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:n,op:S,objects:v,type:h.DrawingApplyType.UPDATE}})}if(g.length>0){const p=this._sheetDrawingService.getBatchRemoveOp(g),S=p.undo,f=p.redo,v=p.objects;l.push({id:h.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:n,op:f,objects:v,type:h.DrawingApplyType.REMOVE}}),m.push({id:h.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:n,op:S,objects:v,type:h.DrawingApplyType.INSERT}})}return l.push({id:$.id,params:[e]}),m.push({id:$.id,params:[e]}),{redos:l,undos:m}}_moveColInterceptor(i,r){const t=this._getUnitIdAndSubUnitId(i,r);if(t==null)return{redos:[],undos:[]};const{unitId:e,subUnitId:n}=t,{range:o}=i,a=o.startColumn,s=o.endColumn,l=[],m=[],d=this._sheetDrawingService.getDrawingData(e,n),c=[],g=[];if(Object.keys(d).forEach(p=>{const S=d[p],{sheetTransform:f,transform:v,anchorType:y=h.SheetDrawingAnchorType.Position}=S;if(f==null||v==null)return;let M,C;if(r==="insert"){const I=this._expandCol(f,v,a,s,y);M=I==null?void 0:I.newSheetTransform,C=I==null?void 0:I.newTransform}else{const{from:I,to:P}=f,{column:w}=I,{column:U}=P;if(w>=a&&U<=s)g.push({unitId:e,subUnitId:n,drawingId:p});else{const E=this._shrinkCol(f,v,a,s,y);M=E==null?void 0:E.newSheetTransform,C=E==null?void 0:E.newTransform}}if(!M||!C)return;const R={unitId:e,subUnitId:n,drawingId:p,transform:C,sheetTransform:M};c.push(R)}),c.length===0&&g.length===0)return{redos:[],undos:[]};if(c.length>0){const p=this._sheetDrawingService.getBatchUpdateOp(c),{undo:S,redo:f,objects:v}=p;l.push({id:h.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:n,op:f,objects:v,type:h.DrawingApplyType.UPDATE}}),m.push({id:h.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:n,op:S,objects:v,type:h.DrawingApplyType.UPDATE}})}if(g.length>0){const p=this._sheetDrawingService.getBatchRemoveOp(g),S=p.undo,f=p.redo,v=p.objects;l.push({id:h.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:n,op:f,objects:v,type:h.DrawingApplyType.REMOVE}}),m.push({id:h.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:n,op:S,objects:v,type:h.DrawingApplyType.INSERT}})}return l.push({id:$.id,params:[e]}),m.push({id:$.id,params:[e]}),{redos:l,undos:m}}_expandCol(i,r,t,e,n=h.SheetDrawingAnchorType.Position){const o=e-t+1,{from:a,to:s}=i,{column:l}=a,{column:m}=s;if(n===h.SheetDrawingAnchorType.None)return{newSheetTransform:G({...r},this._selectionRenderService),newTransform:r};let d=null,c=null;if(l>=t){const g=this._skeletonManagerService.attachRangeWithCoord({startColumn:t,endColumn:e,startRow:a.row,endRow:s.row});if(g==null)return;c={...r,left:(r.left||0)+g.endX-g.startX},d=G(c,this._selectionRenderService)}else if(m>=e)if(n===h.SheetDrawingAnchorType.Both)d={from:{...a},to:{...s,column:m+o}},c=k(d,this._selectionRenderService,this._skeletonManagerService);else return{newSheetTransform:G({...r},this._selectionRenderService),newTransform:r};return d!=null&&c!=null?{newSheetTransform:d,newTransform:c}:null}_shrinkCol(i,r,t,e,n=h.SheetDrawingAnchorType.Position){const o=e-t+1,{from:a,to:s}=i,{column:l}=a,{column:m}=s;if(n===h.SheetDrawingAnchorType.None)return{newSheetTransform:G({...r},this._selectionRenderService),newTransform:r};let d=null,c=null;if(l>e)d={from:{...a,column:l-o},to:{...s,column:m-o}},c=k(d,this._selectionRenderService,this._skeletonManagerService);else{if(l>=t&&m<=e)return null;if(l<t&&m>e)if(n===h.SheetDrawingAnchorType.Both)d={from:{...a},to:{...s,column:m-o}},c=k(d,this._selectionRenderService,this._skeletonManagerService);else return{newSheetTransform:G({...r},this._selectionRenderService),newTransform:r};else if(l>=t&&l<=e){if(l===t)c={...r,left:(r.left||0)-i.from.columnOffset};else{const g=this._skeletonManagerService.attachRangeWithCoord({startColumn:t,endColumn:l-1,startRow:a.row,endRow:s.row});if(g==null)return;c={...r,left:(r.left||0)-g.endX+g.startX-i.from.columnOffset}}d=G(c,this._selectionRenderService)}else if(m>=t&&m<=e&&n===h.SheetDrawingAnchorType.Both){const g=this._skeletonManagerService.attachRangeWithCoord({startColumn:t-1,endColumn:t-1,startRow:a.row,endRow:s.row});if(g==null)return;d={from:{...a},to:{...s,column:t-1,columnOffset:g.endX-g.startX}},c=k(d,this._selectionRenderService,this._skeletonManagerService)}}return d!=null&&c!=null?{newSheetTransform:d,newTransform:c}:null}_expandRow(i,r,t,e,n=h.SheetDrawingAnchorType.Position){const o=e-t+1,{from:a,to:s}=i,{row:l}=a,{row:m}=s;if(n===h.SheetDrawingAnchorType.None)return{newSheetTransform:G({...r},this._selectionRenderService),newTransform:r};let d=null,c=null;if(l>=t){const g=this._skeletonManagerService.attachRangeWithCoord({startRow:t,endRow:e,startColumn:a.column,endColumn:s.column});if(g==null)return;c={...r,top:(r.top||0)+g.endY-g.startY},d=G(c,this._selectionRenderService)}else if(m>=e)if(n===h.SheetDrawingAnchorType.Both)d={from:{...a},to:{...s,row:m+o}},c=k(d,this._selectionRenderService,this._skeletonManagerService);else return{newSheetTransform:G({...r},this._selectionRenderService),newTransform:r};return d!=null&&c!=null?{newSheetTransform:d,newTransform:c}:null}_shrinkRow(i,r,t,e,n=h.SheetDrawingAnchorType.Position){const o=e-t+1,{from:a,to:s}=i,{row:l}=a,{row:m}=s;if(n===h.SheetDrawingAnchorType.None)return{newSheetTransform:G({...r},this._selectionRenderService),newTransform:r};let d=null,c=null;if(l>e)d={from:{...a,row:l-o},to:{...s,row:m-o}},c=k(d,this._selectionRenderService,this._skeletonManagerService);else{if(l>=t&&m<=e)return null;if(l<t&&m>e)if(n===h.SheetDrawingAnchorType.Both)d={from:{...a},to:{...s,row:m-o}},c=k(d,this._selectionRenderService,this._skeletonManagerService);else return{newSheetTransform:G({...r},this._selectionRenderService),newTransform:r};else if(l>=t&&l<=e){if(l===t)c={...r,top:(r.top||0)-i.from.rowOffset};else{const g=this._skeletonManagerService.attachRangeWithCoord({startRow:t,endRow:l-1,startColumn:a.column,endColumn:s.column});if(g==null)return;c={...r,top:(r.top||0)-g.endY+g.startY-i.from.rowOffset}}d=G(c,this._selectionRenderService)}else if(m>=t&&m<=e&&n===h.SheetDrawingAnchorType.Both){const g=this._skeletonManagerService.attachRangeWithCoord({startColumn:a.column,endColumn:a.column,startRow:t-1,endRow:t-1});if(g==null)return;d={from:{...a},to:{...s,row:t-1,rowOffset:g.endY-g.startY}},c=k(d,this._selectionRenderService,this._skeletonManagerService)}}return d!=null&&c!=null?{newSheetTransform:d,newTransform:c}:null}_commandListener(){this.disposeWithMe(this._commandService.onCommandExecuted(i=>{i.id===_.SetWorksheetActiveOperation.id&&setTimeout(()=>{const r=i.params,{unitId:t,subUnitId:e}=r,n=this._drawingManagerService.drawingManagerData,o=[],a=[];Object.keys(n).forEach(s=>{const l=n[s];Object.keys(l).forEach(m=>{const d=l[m].data;d!=null&&Object.keys(d).forEach(c=>{if(s===t&&m===e){const g=d[c];g.transform=k(g.sheetTransform,this._selectionRenderService,this._skeletonManagerService),o.push(d[c])}else a.push(d[c])})})}),this._drawingManagerService.removeNotification(a),this._drawingManagerService.addNotification(o)},0)}))}_sheetRefreshListener(){this.disposeWithMe(this._commandService.onCommandExecuted(i=>{yt.includes(i.id)&&requestIdleCallback(()=>{const r=i.params,{unitId:t,subUnitId:e,ranges:n}=r;this._refreshDrawingTransform(t,e,n)})}))}_refreshDrawingTransform(i,r,t){const e=this._drawingManagerService.getDrawingData(i,r),n=[];Object.keys(e).forEach(o=>{const a=e[o],{sheetTransform:s,anchorType:l=h.SheetDrawingAnchorType.Position}=a;if(l===h.SheetDrawingAnchorType.None)return!0;const{from:m,to:d}=s,{row:c,column:g}=m,{row:p,column:S}=d;for(let f=0;f<t.length;f++){const v=t[f],{startRow:y,endRow:M,startColumn:C,endColumn:R}=v;if(u.Rectangle.intersects({startRow:y,endRow:M,startColumn:C,endColumn:R},{startRow:c,endRow:p,startColumn:g,endColumn:S})||c>M||g>R){n.push({...a,transform:k(s,this._selectionRenderService,this._skeletonManagerService)});break}}}),n.length!==0&&(this._drawingManagerService.refreshTransform(n),this._commandService.syncExecuteCommand($.id,[i]))}};Se=It([u.OnLifecycle(u.LifecycleStages.Rendered,Se),te(0,u.ICommandService),te(1,u.Inject(_.SheetInterceptorService)),te(2,L.IRenderManagerService),te(3,h.ISheetDrawingService),te(4,A.IDrawingManagerService),te(5,u.IUniverInstanceService)],Se);var Mt=Object.defineProperty,Dt=Object.getOwnPropertyDescriptor,Tt=(i,r,t,e)=>{for(var n=e>1?void 0:e?Dt(r,t):r,o=i.length-1,a;o>=0;o--)(a=i[o])&&(n=(e?a(r,t,n):a(n))||n);return e&&n&&Mt(r,t,n),n},ne=(i,r)=>(t,e)=>r(t,e,i);function Rt(i,r,t,e){const{scaleX:n,scaleY:o}=r.getAncestorScale(),a=r.getViewport(L.SHEET_VIEWPORT_KEY.VIEW_MAIN),s={left:!0,top:!0};if(!a)return{...i,absolute:s};const{left:l,right:m,top:d,bottom:c}=i,g=e.getFreeze(),{startColumn:p,startRow:S,xSplit:f,ySplit:v}=g,y=t.getNoMergeCellPositionByIndexWithNoHeader(S-v,p-f),M=t.getNoMergeCellPositionByIndexWithNoHeader(S,p),{rowHeaderWidth:C,columnHeaderHeight:R}=t,I=M.startX-y.startX,P=M.startY-y.startY,{top:w,left:U,viewportScrollX:E,viewportScrollY:j}=a;let O,b;l<U?(s.left=!0,O=(I+C+(l-U))*n,b=Math.max(Math.min((I+C+(m-U))*n,(I+C)*n),(m-E)*n)):(s.left=!1,O=Math.max((l-E)*n,(I+C)*n),b=Math.max((m-E)*n,(I+C)*n));let D,W;return d<w?(s.top=!0,D=(P+R+(d-w))*o,W=Math.max(Math.min((P+R+(m-w))*o,(P+R)*o),(c-j)*o)):(s.top=!1,D=Math.max((d-j)*o,(P+R)*o),W=Math.max((c-j)*o,(P+R)*o)),{left:O,right:b,top:D,bottom:W,absolute:s}}const Ee=(i,r,t,e)=>{const{scene:n}=r,{left:o,top:a,width:s,height:l,angle:m}=i,d={left:o,right:o+s,top:a,bottom:a+l},c=Rt(d,n,t,e);return{startX:c.left,endX:c.right,startY:c.top,endY:c.bottom,rotate:m,width:s,height:l,absolute:c.absolute}};T.SheetCanvasFloatDomManagerService=class extends u.Disposable{constructor(t,e,n,o,a,s){super();K(this,"_domLayerMap",new Map);K(this,"_domLayerInfoMap",new Map);K(this,"_transformChange$",new F.Subject);K(this,"transformChange$",this._transformChange$.asObservable());K(this,"_remove$",new F.Subject);K(this,"remove$",this._remove$.asObservable());K(this,"_hooks",[]);this._renderManagerService=t,this._univerInstanceService=e,this._commandService=n,this._drawingManagerService=o,this._canvasFloatDomService=a,this._sheetDrawingService=s,this._drawingAddListener(),this._scrollUpdateListener(),this._featureUpdateListener(),this._deleteListener()}_ensureMap(t,e){let n=this._domLayerMap.get(t);n||(n=new Map,this._domLayerMap.set(t,n));let o=n.get(e);return o||(o=new Map,n.set(e,o)),o}_getSceneAndTransformerByDrawingSearch(t){if(t==null)return;const e=this._renderManagerService.getRenderById(t),n=e==null?void 0:e.scene;if(e==null||n==null)return null;const o=n.getTransformerByCreate(),a=e.engine.getCanvasElement();return{scene:n,transformer:o,renderObject:e,canvas:a}}_getFloatDomProps(t){let e;return this._hooks.forEach(n=>{e=n.onGetFloatDomProps(t)}),e}_drawingAddListener(){this.disposeWithMe(this._drawingManagerService.add$.subscribe(t=>{t.forEach(e=>{var Fe,ke,He;const{unitId:n,subUnitId:o,drawingId:a}=e,s=_.getSheetCommandTarget(this._univerInstanceService,{unitId:n,subUnitId:o}),l=this._drawingManagerService.getDrawingByParam(e),m=(Fe=this._renderManagerService.getRenderById(n))==null?void 0:Fe.with(B.SheetSkeletonManagerService).getWorksheetSkeleton(o);if(l==null||s==null||m==null)return;const{transform:d,drawingType:c}=l;if(c!==u.DrawingTypeEnum.DRAWING_DOM)return;const g=this._getSceneAndTransformerByDrawingSearch(n);if(g==null)return;const{scene:p,canvas:S}=g;if(d==null)return!0;const{left:f,top:v,width:y,height:M,angle:C,flipX:R,flipY:I,skewX:P,skewY:w}=d,U=A.getDrawingShapeKeyByDrawingSearch({unitId:n,subUnitId:o,drawingId:a}),E=p.getObject(U);if(E!=null){E.transformByState({left:f,top:v,width:y,height:M,angle:C,flipX:R,flipY:I,skewX:P,skewY:w});return}const j={left:f,top:v,width:y,height:M,zIndex:this._drawingManagerService.getDrawingOrder(n,o).length-1},O=new L.Rect(U,j);p.addObject(O,L.DRAWING_OBJECT_LAYER_INDEX).attachTransformerTo(O);const b=this._ensureMap(n,o),D=new u.DisposableCollection,W=Ee(O,g.renderObject,m.skeleton,s.worksheet),H=new F.BehaviorSubject(W),Q={dispose:D,rect:O,position$:H,unitId:n,subUnitId:o};this._canvasFloatDomService.addFloatDom({position$:H,id:a,componentKey:l.componentKey,onPointerDown:Y=>{S.dispatchEvent(new PointerEvent(Y.type,Y))},onPointerMove:Y=>{S.dispatchEvent(new PointerEvent(Y.type,Y))},onPointerUp:Y=>{S.dispatchEvent(new PointerEvent(Y.type,Y))},onWheel:Y=>{S.dispatchEvent(new WheelEvent(Y.type,Y))},props:(He=(ke=b.get(a))==null?void 0:ke.props)!=null?He:this._getFloatDomProps(a)});const Ve=O.onTransformChange$.subscribeEvent(()=>{const Y=Ee(O,g.renderObject,m.skeleton,s.worksheet);H.next(Y)});D.add(()=>{this._canvasFloatDomService.removeFloatDom(a)}),Ve&&D.add(Ve),this._domLayerInfoMap.set(a,Q)})}))}_scrollUpdateListener(){this.disposeWithMe(this._commandService.onCommandExecuted(t=>{var n,o;const e=(a,s)=>{var p;const l=this._getSceneAndTransformerByDrawingSearch(a),m=this._ensureMap(a,s),d=Array.from(m.keys()),c=_.getSheetCommandTarget(this._univerInstanceService,{unitId:a,subUnitId:s}),g=(p=this._renderManagerService.getRenderById(a))==null?void 0:p.with(B.SheetSkeletonManagerService).getWorksheetSkeleton(s);!l||!c||!g||d.forEach(S=>{const f=this._domLayerInfoMap.get(S);if(f){const v=Ee(f.rect,l.renderObject,g.skeleton,c.worksheet);f.position$.next(v)}})};if(t.id===B.SetScrollOperation.id){const a=t.params,{unitId:s,sheetId:l}=a;e(s,l)}else if(t.id===B.SetZoomRatioOperation.id){const a=t.params,{unitId:s}=a;Array.from((o=(n=this._domLayerMap.get(s))==null?void 0:n.keys())!=null?o:[]).forEach(m=>{e(s,m)})}else if(t.id===_.SetFrozenMutation.id){const{unitId:a,subUnitId:s}=t.params;e(a,s)}}))}_getPosition(t,e){var p;const{startX:n,endX:o,startY:a,endY:s}=t,l=(p=this._renderManagerService.getRenderById(e))==null?void 0:p.with(B.ISheetSelectionRenderService);if(l==null)return;const m=l.getSelectionCellByPosition(n,a);if(m==null)return;const d={column:m.actualColumn,columnOffset:n-m.startX,row:m.actualRow,rowOffset:a-m.startY},c=l.getSelectionCellByPosition(o,s);if(c==null)return;const g={column:c.actualColumn,columnOffset:o-c.startX,row:c.actualRow,rowOffset:s-c.startY};return{from:d,to:g}}_featureUpdateListener(){this.disposeWithMe(this._drawingManagerService.update$.subscribe(t=>{t.forEach(e=>{const n=this._drawingManagerService.getDrawingByParam(e);if(!n||n.drawingType!==u.DrawingTypeEnum.DRAWING_DOM)return;const o={...n.transform};this._transformChange$.next({id:e.drawingId,value:o})})}))}_deleteListener(){this.disposeWithMe(this._drawingManagerService.remove$.subscribe(t=>{t.forEach(e=>{this._removeDom(e.drawingId)})}))}addFloatDomToPosition(t){const e=_.getSheetCommandTarget(this._univerInstanceService,{unitId:t.unitId,subUnitId:t.subUnitId});if(!e)throw new Error("cannot find current target!");const{unitId:n,subUnitId:o}=e,{initPosition:a,componentKey:s}=t,l=u.Tools.generateRandomId(),m=this._getPosition(a,n);if(m==null)return;this._ensureMap(n,o).set(l,t);const c={unitId:n,subUnitId:o,drawingId:l,drawingType:u.DrawingTypeEnum.DRAWING_DOM,componentKey:s,sheetTransform:m,transform:{left:a.startX,top:a.startY,width:a.endX-a.startX,height:a.endY-a.startY}};return this._commandService.executeCommand(pe.id,{unitId:n,drawings:[c]}),{id:l,dispose:()=>{this._removeDom(l,!0)}}}_removeDom(t,e=!1){const n=this._domLayerInfoMap.get(t);if(!n)return;const{unitId:o,subUnitId:a}=n;this._domLayerInfoMap.delete(t),n.dispose.dispose();const s=this._getSceneAndTransformerByDrawingSearch(o);if(s&&s.scene.removeObject(n.rect),e){this._ensureMap(o,a).delete(t);const m=this._drawingManagerService.getDrawingByParam({unitId:o,subUnitId:a,drawingId:t});if(!m)return;const d=this._sheetDrawingService.getBatchRemoveOp([m]),{redo:c,objects:g}=d;this._commandService.syncExecuteCommand(h.SetDrawingApplyMutation.id,{unitId:o,subUnitId:a,op:c,objects:g,type:h.DrawingApplyType.REMOVE})}}addHook(t){return this._hooks.push(t),{dispose:()=>{const e=this._hooks.findIndex(n=>n===t);this._hooks.splice(e,1)}}}},T.SheetCanvasFloatDomManagerService=Tt([ne(0,u.Inject(L.IRenderManagerService)),ne(1,u.IUniverInstanceService),ne(2,u.Inject(u.ICommandService)),ne(3,A.IDrawingManagerService),ne(4,u.Inject(V.CanvasFloatDomService)),ne(5,h.ISheetDrawingService)],T.SheetCanvasFloatDomManagerService);var Et=Object.defineProperty,bt=Object.getOwnPropertyDescriptor,Pt=(i,r,t,e)=>{for(var n=e>1?void 0:e?bt(r,t):r,o=i.length-1,a;o>=0;o--)(a=i[o])&&(n=(e?a(r,t,n):a(n))||n);return e&&n&&Et(r,t,n),n},ve=(i,r)=>(t,e)=>r(t,e,i);let we=class extends u.Disposable{constructor(i,r,t,e){super(),this._sheetPrintInterceptorService=i,this._drawingRenderService=r,this._drawingManagerService=t,this._renderManagerService=e,this._initPrinting()}_initPrinting(){this.disposeWithMe(this._sheetPrintInterceptorService.interceptor.intercept(this._sheetPrintInterceptorService.interceptor.getInterceptPoints().PRINTING_COMPONENT_COLLECT,{handler:(i,r,t)=>{const{unitId:e,scene:n,subUnitId:o}=r,a=this._drawingManagerService.getDrawingDataForUnit(e),s=a==null?void 0:a[o];return s&&s.order.forEach(l=>{this._drawingRenderService.renderDrawing(s.data[l],n)}),t()}})),this.disposeWithMe(this._sheetPrintInterceptorService.interceptor.intercept(this._sheetPrintInterceptorService.interceptor.getInterceptPoints().PRINTING_RANGE,{handler:(i,r,t)=>{const{unitId:e,subUnitId:n}=r,o=this._renderManagerService.getRenderById(e);if(!o)return t(i);const a=o.with(B.SheetSkeletonManagerService).getWorksheetSkeleton(n);if(!a)return t(i);const s=this._drawingManagerService.getDrawingDataForUnit(e),l=s==null?void 0:s[r.subUnitId];if(!l)return t(i);const{scaleX:m,scaleY:d}=o.scene,c=i?{...i}:{startColumn:0,endColumn:0,endRow:0,startRow:0},g=l.order.map(p=>l.data[p]).filter(p=>p.drawingType!==A.DrawingTypeEnum.DRAWING_DOM);return g.length?(g.forEach(p=>{if(!p.groupId&&p.transform&&u.Tools.isDefine(p.transform.left)&&u.Tools.isDefine(p.transform.top)&&u.Tools.isDefine(p.transform.width)&&u.Tools.isDefine(p.transform.height)){const S=a.skeleton.getCellPositionByOffset(p.transform.left,p.transform.top,m,d,{x:0,y:0}),f=a.skeleton.getCellPositionByOffset(p.transform.left+p.transform.width,p.transform.top+p.transform.height,m,d,{x:0,y:0});S.column<c.startColumn&&(c.startColumn=S.column),S.row<c.startRow&&(c.startRow=S.row),c.endRow<f.row&&(c.endRow=f.row),c.endColumn<f.column&&(c.endColumn=f.column)}}),t(c)):t(i)}}))}};we=Pt([u.OnLifecycle(u.LifecycleStages.Rendered,we),ve(0,u.Inject(B.SheetPrintInterceptorService)),ve(1,u.Inject(X.DrawingRenderService)),ve(2,A.IDrawingManagerService),ve(3,L.IRenderManagerService)],we);var Ot=Object.defineProperty,At=Object.getOwnPropertyDescriptor,Ut=(i,r,t,e)=>{for(var n=e>1?void 0:e?At(r,t):r,o=i.length-1,a;o>=0;o--)(a=i[o])&&(n=(e?a(r,t,n):a(n))||n);return e&&n&&Ot(r,t,n),n},le=(i,r)=>(t,e)=>r(t,e,i);let _e=class extends u.Disposable{constructor(i,r,t,e,n){super(),this._drawingManagerService=i,this._renderManagerService=r,this._permissionService=t,this._univerInstanceService=e,this._userManagerService=n,this._initDrawingVisible(),this._initDrawingEditable(),this._initViewPermissionChange(),this._initEditPermissionChange()}_initDrawingVisible(){const i=this._univerInstanceService.getCurrentTypeOfUnit$(u.UniverInstanceType.UNIVER_SHEET);this.disposeWithMe(F.combineLatest([i,this._userManagerService.currentUser$]).subscribe(([r,t])=>{if(!r){this._drawingManagerService.setDrawingVisible(!1);return}r.activeSheet$.subscribe(e=>{if(!e){this._drawingManagerService.setDrawingVisible(!1);return}const n=r.getUnitId(),o=e.getSheetId();if(this._permissionService.composePermission([new _.WorkbookViewPermission(n).id,new _.WorksheetViewPermission(n,o).id]).every(s=>s.value))this._drawingManagerService.setDrawingVisible(!0);else{this._drawingManagerService.setDrawingVisible(!1);const s=r.getUnitId(),l=e.getSheetId(),m=this._drawingManagerService.getDrawingData(s,l),d=Object.values(m),c=this._renderManagerService.getRenderById(s),g=c==null?void 0:c.scene;if(g==null)return;g.getAllObjects().forEach(S=>{S.classType===L.RENDER_CLASS_TYPE.IMAGE&&d.some(f=>S.oKey.includes(f.drawingId))&&g.removeObject(S)})}})}))}_initDrawingEditable(){const i=this._univerInstanceService.getCurrentTypeOfUnit$(u.UniverInstanceType.UNIVER_SHEET);this.disposeWithMe(F.combineLatest([i,this._userManagerService.currentUser$]).subscribe(([r,t])=>{if(!r){this._drawingManagerService.setDrawingEditable(!1);return}r.activeSheet$.subscribe(e=>{if(!e){this._drawingManagerService.setDrawingEditable(!1);return}const n=r.getUnitId(),o=e.getSheetId();if(this._permissionService.composePermission([new _.WorkbookEditablePermission(n).id,new _.WorksheetEditPermission(n,o).id]).every(s=>s.value))this._drawingManagerService.setDrawingEditable(!0);else{this._drawingManagerService.setDrawingEditable(!1);const s=r.getUnitId(),l=e.getSheetId(),m=this._drawingManagerService.getDrawingData(s,l),d=Object.values(m),c=this._renderManagerService.getRenderById(s),g=c==null?void 0:c.scene;if(g==null)return;g.getAllObjects().forEach(S=>{S.classType===L.RENDER_CLASS_TYPE.IMAGE&&d.some(f=>S.oKey.includes(f.drawingId))&&g.detachTransformerFrom(S)})}})}))}_initViewPermissionChange(){const i=this._univerInstanceService.getCurrentTypeOfUnit$(u.UniverInstanceType.UNIVER_SHEET);this.disposeWithMe(F.combineLatest([i,this._userManagerService.currentUser$]).subscribe(([r,t])=>{r&&r.activeSheet$.subscribe(e=>{var c;if(!e)return;const n=r.getUnitId(),o=e.getSheetId();let a=!0;const s=this._renderManagerService.getRenderById(n),l=s==null?void 0:s.scene;if(l==null)return;const m=l.getTransformerByCreate(),d=this._permissionService.composePermission$([new _.WorkbookViewPermission(n).id,new _.WorksheetViewPermission(n,o).id]).pipe(F.map(g=>g.every(p=>p.value)));d==null||d.pipe(F.filter(g=>g!==a),F.distinctUntilChanged()).subscribe({next:g=>{a=g,this._drawingManagerService.setDrawingVisible(g);const p=l.getAllObjects(),S=this._drawingManagerService.getDrawingData(n,o),f=Object.values(S);g?this._drawingManagerService.addNotification(f):(p.forEach(v=>{v.classType===L.RENDER_CLASS_TYPE.IMAGE&&f.some(y=>v.oKey.includes(y.drawingId))&&l.removeObject(v)}),m.clearSelectedObjects())}}),(c=this._permissionService.getPermissionPoint$(new _.WorksheetViewPermission(n,o).id))==null||c.pipe(F.filter(g=>g.value!==a),F.distinctUntilChanged()).subscribe({complete:()=>{a=!0,this._drawingManagerService.setDrawingVisible(!0);const g=this._drawingManagerService.getDrawingData(n,o),p=Object.values(g);this._drawingManagerService.addNotification(p)}})})}))}_initEditPermissionChange(){const i=this._univerInstanceService.getCurrentTypeOfUnit$(u.UniverInstanceType.UNIVER_SHEET);this.disposeWithMe(F.combineLatest([i,this._userManagerService.currentUser$]).subscribe(([r,t])=>{r&&r.activeSheet$.subscribe(e=>{var c;if(!e)return;const n=r.getUnitId(),o=e.getSheetId();let a=!0;const s=this._renderManagerService.getRenderById(n),l=s==null?void 0:s.scene;if(l==null)return;const m=l.getTransformerByCreate(),d=this._permissionService.composePermission$([new _.WorkbookEditablePermission(n).id,new _.WorksheetEditPermission(n,o).id]).pipe(F.map(g=>g.every(p=>p.value)));d==null||d.pipe(F.filter(g=>g!==a),F.distinctUntilChanged()).subscribe({next:g=>{a=g,this._drawingManagerService.setDrawingEditable(g);const p=l.getAllObjects(),S=this._drawingManagerService.getDrawingData(n,o),f=Object.values(S);g?(p.forEach(v=>{v.classType===L.RENDER_CLASS_TYPE.IMAGE&&f.some(y=>v.oKey.includes(y.drawingId))&&l.attachTransformerTo(v)}),this._drawingManagerService.addNotification(f)):(p.forEach(v=>{v.classType===L.RENDER_CLASS_TYPE.IMAGE&&f.some(y=>v.oKey.includes(y.drawingId))&&l.detachTransformerFrom(v)}),m.clearSelectedObjects())}}),(c=this._permissionService.getPermissionPoint$(new _.WorksheetEditPermission(n,o).id))==null||c.pipe(F.filter(g=>g.value!==a),F.distinctUntilChanged()).subscribe({complete:()=>{a=!0;const g=r.getUnitId(),p=e.getSheetId(),S=this._drawingManagerService.getDrawingData(g,p),f=Object.values(S),v=this._renderManagerService.getRenderById(g),y=v==null?void 0:v.scene;if(y==null)return;this._drawingManagerService.setDrawingEditable(!0),y.getAllObjects().forEach(C=>{C.classType===L.RENDER_CLASS_TYPE.IMAGE&&f.some(R=>C.oKey.includes(R.drawingId))&&y.detachTransformerFrom(C)})}})})}))}};_e=Ut([u.OnLifecycle(u.LifecycleStages.Rendered,_e),le(0,A.IDrawingManagerService),le(1,L.IRenderManagerService),le(2,u.IPermissionService),le(3,u.IUniverInstanceService),le(4,u.Inject(u.UserManagerService))],_e);var Nt=Object.defineProperty,Lt=Object.getOwnPropertyDescriptor,jt=(i,r,t,e)=>{for(var n=e>1?void 0:e?Lt(r,t):r,o=i.length-1,a;o>=0;o--)(a=i[o])&&(n=(e?a(r,t,n):a(n))||n);return e&&n&&Nt(r,t,n),n},be=(i,r)=>(t,e)=>r(t,e,i);let Ie=class extends u.Disposable{constructor(r,t,e){super();K(this,"_copyInfo");this._sheetClipboardService=r,this._renderManagerService=t,this._sheetDrawingService=e,this._initCopyPaste()}_initCopyPaste(){this._sheetClipboardService.addClipboardHook({id:"SHEET_IMAGE_UI_PLUGIN",onBeforeCopy:(r,t,e)=>this._collect(r,t,e),onPasteCells:(r,t,e,n)=>{const{copyType:o=B.COPY_TYPE.COPY,pasteType:a}=n,{range:s}=r||{},{range:l,unitId:m,subUnitId:d}=t;return this._generateMutations(l,{copyType:o,pasteType:a,copyRange:s,unitId:m,subUnitId:d})},onPastePlainText:(r,t)=>({undos:[],redos:[]})})}_collect(r,t,e){var g;const n=(g=this._renderManagerService.getRenderById(r))==null?void 0:g.with(B.SheetSkeletonManagerService);if(!n)return;const o=n.attachRangeWithCoord(e);if(!o)return;const{startX:a,endX:s,startY:l,endY:m}=o,d=this._sheetDrawingService.getDrawingData(r,t),c=[];Object.keys(d).forEach(p=>{const S=d[p],{transform:f}=S;if(S.anchorType!==h.SheetDrawingAnchorType.Both||!f)return;const{left:v=0,top:y=0,width:M=0,height:C=0}=f,{drawingStartX:R,drawingEndX:I,drawingStartY:P,drawingEndY:w}={drawingStartX:v,drawingEndX:v+M,drawingStartY:y,drawingEndY:y+C};a<=R&&I<=s&&l<=P&&w<=m&&c.push(S)}),c.length&&(this._copyInfo={drawings:c,unitId:r,subUnitId:t})}_generateMutations(r,t){var E;if(!this._copyInfo)return{redos:[],undos:[]};if([B.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_COL_WIDTH,B.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_VALUE,B.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMAT,B.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMULA].includes(t.pasteType))return{redos:[],undos:[]};const{copyRange:e}=t;if(!e)return{redos:[],undos:[]};const{drawings:n,unitId:o,subUnitId:a}=this._copyInfo,{ranges:[s,l],mapFunc:m}=B.virtualizeDiscreteRanges([e,r]),{row:d,col:c}=m(s.startRow,s.startColumn),{row:g,col:p}=m(l.startRow,l.startColumn),S=(E=this._renderManagerService.getRenderById(o))==null?void 0:E.with(B.SheetSkeletonManagerService);if(!S)return{redos:[],undos:[]};const f=S.attachRangeWithCoord({startRow:d,endRow:d,startColumn:c,endColumn:c}),v=S.attachRangeWithCoord({startRow:g,endRow:g,startColumn:p,endColumn:p});if(!f||!v)return{redos:[],undos:[]};const y=[],M=[],C=v.startX-f.startX,R=v.startY-f.startY,I=g-d,P=p-c,w=t.copyType===B.COPY_TYPE.CUT,{_sheetDrawingService:U}=this;return n.forEach(j=>{const{transform:O,sheetTransform:b}=j;if(!O)return;const D={...j,unitId:o,subUnitId:a,drawingId:w?j.drawingId:u.Tools.generateRandomId(),transform:{...O,left:O.left+C,top:O.top+R},sheetTransform:{to:{...b.to,row:b.to.row+I,column:b.to.column+P},from:{...b.from,row:b.from.row+I,column:b.from.column+P}}};if(w){const{undo:W,redo:H,objects:Q}=U.getBatchUpdateOp([D]);y.push({id:h.SetDrawingApplyMutation.id,params:{unitId:o,subUnitId:a,type:h.DrawingApplyType.UPDATE,op:H,objects:Q}}),M.push({id:h.SetDrawingApplyMutation.id,params:{unitId:o,subUnitId:a,type:h.DrawingApplyType.UPDATE,op:W,objects:Q}})}else{const{undo:W,redo:H,objects:Q}=U.getBatchAddOp([D]);y.push({id:h.SetDrawingApplyMutation.id,params:{op:H,unitId:o,subUnitId:a,objects:Q,type:h.DrawingApplyType.INSERT}}),M.push({id:h.SetDrawingApplyMutation.id,params:{op:W,unitId:o,subUnitId:a,objects:Q,type:h.DrawingApplyType.REMOVE}})}}),{redos:y,undos:M}}};Ie=jt([u.OnLifecycle(u.LifecycleStages.Ready,Ie),be(0,B.ISheetClipboardService),be(1,L.IRenderManagerService),be(2,h.ISheetDrawingService)],Ie);var $e=Object.defineProperty,Wt=Object.getOwnPropertyDescriptor,Bt=(i,r,t)=>r in i?$e(i,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[r]=t,$t=(i,r,t,e)=>{for(var n=e>1?void 0:e?Wt(r,t):r,o=i.length-1,a;o>=0;o--)(a=i[o])&&(n=(e?a(r,t,n):a(n))||n);return e&&n&&$e(r,t,n),n},Pe=(i,r)=>(t,e)=>r(t,e,i),Ge=(i,r,t)=>Bt(i,typeof r!="symbol"?r+"":r,t);const Gt="SHEET_IMAGE_UI_PLUGIN";T.UniverSheetsDrawingUIPlugin=class extends u.Plugin{constructor(t={},e,n,o){super();K(this,"_pluginConfig");this._injector=e,this._localeService=n,this._renderManagerService=o,this._pluginConfig=u.Tools.deepMerge({},vt,t)}onStarting(t){super.onStarting(t),this._initDependencies(t)}onRendered(){this._registerRenderModules()}_initDependencies(t){const e=[[T.SheetCanvasFloatDomManagerService],[ce,{useFactory:()=>this._injector.createInstance(ce,this._pluginConfig)}],[ge],[we],[_e]],n=[he,Se];e.forEach(o=>t.add(o)),n.forEach(o=>this._renderManagerService.registerRenderModule(u.UniverInstanceType.UNIVER_SHEET,o))}_registerRenderModules(){[[Ie]].forEach(t=>{this.disposeWithMe(this._renderManagerService.registerRenderModule(u.UniverInstanceType.UNIVER_SHEET,t))})}},Ge(T.UniverSheetsDrawingUIPlugin,"type",u.UniverInstanceType.UNIVER_SHEET),Ge(T.UniverSheetsDrawingUIPlugin,"pluginName",Gt),T.UniverSheetsDrawingUIPlugin=$t([u.DependentOn(A.UniverDrawingPlugin,X.UniverDrawingUIPlugin,h.UniverSheetsDrawingPlugin),Pe(1,u.Inject(u.Injector)),Pe(2,u.Inject(u.LocaleService)),Pe(3,L.IRenderManagerService)],T.UniverSheetsDrawingUIPlugin),T.ClearSheetDrawingTransformerOperation=$,T.DeleteDrawingsCommand=Re,T.EditSheetDrawingOperation=ye,T.GroupSheetDrawingCommand=De,T.InsertCellImageOperation=ie,T.InsertFloatImageOperation=re,T.InsertSheetDrawingCommand=pe,T.MoveDrawingsCommand=ee,T.RemoveSheetDrawingCommand=ue,T.SetDrawingArrangeCommand=Me,T.SetSheetDrawingCommand=oe,T.SidebarSheetDrawingOperation=Ce,T.UngroupSheetDrawingCommand=Te,Object.defineProperty(T,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@univerjs/sheets-drawing-ui",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.4-alpha.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "",
|
|
6
6
|
"author": "DreamNum <developer@univer.ai>",
|
|
@@ -48,42 +48,40 @@
|
|
|
48
48
|
"lib"
|
|
49
49
|
],
|
|
50
50
|
"peerDependencies": {
|
|
51
|
-
"@wendellhu/redi": "0.15.5",
|
|
52
51
|
"clsx": ">=2.0.0",
|
|
53
52
|
"react": "^16.9.0 || ^17.0.0 || ^18.0.0",
|
|
54
53
|
"rxjs": ">=7.0.0",
|
|
55
|
-
"@univerjs/core": "0.2.
|
|
56
|
-
"@univerjs/
|
|
57
|
-
"@univerjs/
|
|
58
|
-
"@univerjs/
|
|
59
|
-
"@univerjs/
|
|
60
|
-
"@univerjs/
|
|
61
|
-
"@univerjs/sheets-drawing": "0.2.
|
|
62
|
-
"@univerjs/sheets-ui": "0.2.
|
|
63
|
-
"@univerjs/ui": "0.2.
|
|
54
|
+
"@univerjs/core": "0.2.4-alpha.0",
|
|
55
|
+
"@univerjs/drawing-ui": "0.2.4-alpha.0",
|
|
56
|
+
"@univerjs/design": "0.2.4-alpha.0",
|
|
57
|
+
"@univerjs/sheets": "0.2.4-alpha.0",
|
|
58
|
+
"@univerjs/drawing": "0.2.4-alpha.0",
|
|
59
|
+
"@univerjs/engine-render": "0.2.4-alpha.0",
|
|
60
|
+
"@univerjs/sheets-drawing": "0.2.4-alpha.0",
|
|
61
|
+
"@univerjs/sheets-ui": "0.2.4-alpha.0",
|
|
62
|
+
"@univerjs/ui": "0.2.4-alpha.0"
|
|
64
63
|
},
|
|
65
64
|
"dependencies": {
|
|
66
|
-
"@univerjs/icons": "^0.1.
|
|
65
|
+
"@univerjs/icons": "^0.1.64"
|
|
67
66
|
},
|
|
68
67
|
"devDependencies": {
|
|
69
|
-
"@wendellhu/redi": "0.15.5",
|
|
70
68
|
"clsx": "^2.1.1",
|
|
71
69
|
"less": "^4.2.0",
|
|
72
70
|
"react": "18.3.1",
|
|
73
71
|
"rxjs": "^7.8.1",
|
|
74
72
|
"typescript": "^5.5.3",
|
|
75
|
-
"vite": "^5.3.
|
|
76
|
-
"vitest": "^
|
|
77
|
-
"@univerjs/
|
|
78
|
-
"@univerjs/
|
|
79
|
-
"@univerjs/drawing": "0.2.
|
|
80
|
-
"@univerjs/drawing
|
|
81
|
-
"@univerjs/
|
|
82
|
-
"@univerjs/
|
|
83
|
-
"@univerjs/sheets": "0.2.
|
|
84
|
-
"@univerjs/sheets-
|
|
85
|
-
"@univerjs/sheets-
|
|
86
|
-
"@univerjs/ui": "0.2.
|
|
73
|
+
"vite": "^5.3.4",
|
|
74
|
+
"vitest": "^2.0.3",
|
|
75
|
+
"@univerjs/core": "0.2.4-alpha.0",
|
|
76
|
+
"@univerjs/design": "0.2.4-alpha.0",
|
|
77
|
+
"@univerjs/drawing-ui": "0.2.4-alpha.0",
|
|
78
|
+
"@univerjs/drawing": "0.2.4-alpha.0",
|
|
79
|
+
"@univerjs/engine-render": "0.2.4-alpha.0",
|
|
80
|
+
"@univerjs/shared": "0.2.4-alpha.0",
|
|
81
|
+
"@univerjs/sheets": "0.2.4-alpha.0",
|
|
82
|
+
"@univerjs/sheets-drawing": "0.2.4-alpha.0",
|
|
83
|
+
"@univerjs/sheets-ui": "0.2.4-alpha.0",
|
|
84
|
+
"@univerjs/ui": "0.2.4-alpha.0"
|
|
87
85
|
},
|
|
88
86
|
"univerSpace": {
|
|
89
87
|
".": {
|