@univerjs/sheets-drawing-ui 0.1.15 → 0.1.16

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.
@@ -0,0 +1,16 @@
1
+ import { Disposable, IPermissionService, IUniverInstanceService, UserManagerService } from '@univerjs/core';
2
+ import { IDrawingManagerService } from '@univerjs/drawing';
3
+ import { IRenderManagerService } from '@univerjs/engine-render';
4
+
5
+ export declare class SheetDrawingPermissionController extends Disposable {
6
+ private readonly _drawingManagerService;
7
+ private readonly _renderManagerService;
8
+ private readonly _permissionService;
9
+ private readonly _univerInstanceService;
10
+ private _userManagerService;
11
+ constructor(_drawingManagerService: IDrawingManagerService, _renderManagerService: IRenderManagerService, _permissionService: IPermissionService, _univerInstanceService: IUniverInstanceService, _userManagerService: UserManagerService);
12
+ private _initDrawingVisible;
13
+ private _initDrawingEditable;
14
+ private _initViewPermissionChange;
15
+ private _initEditPermissionChange;
16
+ }
package/lib/umd/index.js CHANGED
@@ -1 +1 @@
1
- (function(O,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):(O=typeof globalThis<"u"?globalThis:O||self,p(O.UniverSheetsDrawingUi={},O.UniverCore,O["@wendellhu/redi"],O.UniverDrawingUi,O.UniverSheetsDrawing,O.UniverDrawing,O.UniverEngineRender,O.UniverSheetsUi,O.rxjs,O.UniverUi,O["@wendellhu/redi/react-bindings"],O.UniverSheets,O.React,O.UniverDesign,O.clsx))})(this,function(O,p,j,Z,g,P,B,H,te,G,z,C,A,q,se){"use strict";var Un=Object.defineProperty;var Nn=(O,p,j)=>p in O?Un(O,p,{enumerable:!0,configurable:!0,writable:!0,value:j}):O[p]=j;var K=(O,p,j)=>(Nn(O,typeof p!="symbol"?p+"":p,j),j);const L={id:"sheet.operation.clear-drawing-transformer",type:p.CommandType.MUTATION,handler:(i,t)=>{const e=i.get(B.IRenderManagerService);return t.forEach(n=>{var r,o;(o=(r=e.getRenderById(n))==null?void 0:r.scene.getTransformer())==null||o.debounceRefreshControls()}),!0}},ve={id:"sheet.command.remove-sheet-image",type:p.CommandType.COMMAND,handler:(i,t)=>{const e=i.get(p.ICommandService),n=i.get(p.IUndoRedoService),r=i.get(g.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:c,subUnitId:u,undo:d,redo:l,objects:h}=s;return e.syncExecuteCommand(g.SetDrawingApplyMutation.id,{unitId:c,subUnitId:u,op:l,objects:h,type:g.DrawingApplyType.REMOVE})?(n.pushUndoRedo({unitID:c,undoMutations:[{id:g.SetDrawingApplyMutation.id,params:{unitId:c,subUnitId:u,op:d,objects:h,type:g.DrawingApplyType.INSERT}},{id:L.id,params:a}],redoMutations:[{id:g.SetDrawingApplyMutation.id,params:{unitId:c,subUnitId:u,op:l,objects:h,type:g.DrawingApplyType.REMOVE}},{id:L.id,params:a}]}),!0):!1}},Ce="COMPONENT_SHEET_DRAWING_PANEL",Ie={id:"sidebar.operation.sheet-image",type:p.CommandType.COMMAND,handler:async(i,t)=>{const e=i.get(G.ISidebarService),n=i.get(p.LocaleService),r=i.get(p.IUniverInstanceService),o=i.get(P.IDrawingManagerService);if(!C.getSheetCommandTarget(r))return!1;switch(t.value){case"open":e.open({header:{title:n.t("sheetImage.panel.title")},children:{label:Ce},onClose:()=>{o.focusDrawing(null)},width:360});break;case"close":default:e.close();break}return!0}},ye={id:"sheet.operation.edit-sheet-image",type:p.CommandType.OPERATION,handler:(i,t)=>{const e=i.get(P.IDrawingManagerService),n=i.get(p.ICommandService);return t==null?!1:(e.focusDrawing([t]),n.executeCommand(Ie.id,{value:"open"}),!0)}},ce={uploadLoading:"univer-upload-loading",uploadLoadingBody:"univer-upload-loading-body",uploadLoadingBodyAnimation:"univer-upload-loading-body-animation",univerCircleAnimation:"univer-UniverCircleAnimation",uploadLoadingBodyText:"univer-upload-loading-body-text"},$e=()=>{const i=z.useDependency(P.IImageIoService),t=z.useDependency(p.LocaleService),[e,n]=A.useState(0);return A.useEffect(()=>{const r=i.change$.subscribe(o=>{n(o)});return()=>{r.unsubscribe()}},[i]),A.createElement("div",{style:{display:e>0?"block":"none"},className:ce.uploadLoading},A.createElement("div",{className:ce.uploadLoadingBody},A.createElement("div",{className:ce.uploadLoadingBodyAnimation}),A.createElement("div",{className:ce.uploadLoadingBodyText},`${t.t("uploadLoading.loading")}: ${e}`)))};var xe=Object.defineProperty,Ve=Object.getOwnPropertyDescriptor,He=(i,t,e,n)=>{for(var r=n>1?void 0:n?Ve(t,e):t,o=i.length-1,a;o>=0;o--)(a=i[o])&&(r=(n?a(t,e,r):a(r))||r);return n&&r&&xe(t,e,r),r},Q=(i,t)=>(e,n)=>t(e,n,i);let le=class extends p.RxDisposable{constructor(t,e,n,r,o,a,s){super();K(this,"_initImagePopupMenu",new Set);this._injector=t,this._drawingManagerService=e,this._canvasPopManagerService=n,this._renderManagerService=r,this._univerInstanceService=o,this._contextService=a,this._uiPartsService=s,this._init()}_init(){this._univerInstanceService.getCurrentTypeOfUnit$(p.UniverInstanceType.UNIVER_SHEET).pipe(te.takeUntil(this.dispose$)).subscribe(t=>this._create(t)),this._univerInstanceService.getTypeOfUnitDisposed$(p.UniverInstanceType.UNIVER_SHEET).pipe(te.takeUntil(this.dispose$)).subscribe(t=>this._dispose(t)),this._univerInstanceService.getAllUnitsForType(p.UniverInstanceType.UNIVER_SHEET).forEach(t=>this._create(t)),this._uiPartsService.registerComponent(G.BuiltInUIPart.CONTENT,()=>z.connectInjector($e,this._injector))}_dispose(t){const e=t.getUnitId();this._renderManagerService.removeRender(e)}_create(t){if(!t)return;const e=t.getUnitId();this._renderManagerService.has(e)&&!this._initImagePopupMenu.has(e)&&(this._popupMenuListener(e),this._initImagePopupMenu.add(e))}_hasCropObject(t){const e=t.getAllObjects();for(const n of e)if(n instanceof Z.ImageCropperObject)return!0;return!1}_popupMenuListener(t){var o;const e=(o=this._renderManagerService.getRenderById(t))==null?void 0:o.scene;if(!e)return;const n=e.getTransformerByCreate();if(!n)return;const r=[];this.disposeWithMe(p.toDisposable(n.onCreateControlObservable.add(()=>{if(this._contextService.setContextValue(p.FOCUSING_COMMON_DRAWINGS,!0),this._hasCropObject(e))return;const a=n.getSelectedObjectMap();if(a.size>1){r.forEach(m=>m.dispose());return}const s=a.values().next().value;if(!s)return;const c=s.oKey,u=this._drawingManagerService.getDrawingOKey(c);if(!u)return;const{unitId:d,subUnitId:l,drawingId:h}=u;r.push(this.disposeWithMe(this._canvasPopManagerService.attachPopupToObject(s,{componentKey:Z.COMPONENT_IMAGE_POPUP_MENU,direction:"horizontal",offset:[2,0],extraProps:{menuItems:this._getImageMenuItems(d,l,h)}}))),this._drawingManagerService.focusDrawing([{unitId:d,subUnitId:l,drawingId:h}])}))),this.disposeWithMe(p.toDisposable(n.onClearControlObservable.add(()=>{r.forEach(a=>a.dispose()),this._contextService.setContextValue(p.FOCUSING_COMMON_DRAWINGS,!1),this._drawingManagerService.focusDrawing(null)}))),this.disposeWithMe(p.toDisposable(n.onChangingObservable.add(()=>{r.forEach(a=>a.dispose())})))}_getImageMenuItems(t,e,n){return[{label:"image-popup.edit",index:0,commandId:ye.id,commandParams:{unitId:t,subUnitId:e,drawingId:n},disable:!1},{label:"image-popup.delete",index:1,commandId:ve.id,commandParams:{unitId:t,drawings:[{unitId:t,subUnitId:e,drawingId:n}]},disable:!1},{label:"image-popup.crop",index:2,commandId:Z.OpenImageCropOperation.id,commandParams:{unitId:t,subUnitId:e,drawingId:n},disable:!1},{label:"image-popup.reset",index:3,commandId:Z.ImageResetSizeOperation.id,commandParams:[{unitId:t,subUnitId:e,drawingId:n}],disable:!1}]}};le=He([p.OnLifecycle(p.LifecycleStages.Steady,le),Q(0,j.Inject(j.Injector)),Q(1,P.IDrawingManagerService),Q(2,j.Inject(H.SheetCanvasPopManagerService)),Q(3,B.IRenderManagerService),Q(4,p.IUniverInstanceService),Q(5,p.IContextService),Q(6,j.Inject(G.IUIPartsService))],le);const de={id:"sheet.operation.insert-float-image",type:p.CommandType.OPERATION,handler:(i,t)=>!0},ue={id:"sheet.operation.insert-cell-image",type:p.CommandType.OPERATION,handler:(i,t)=>!0},we={id:"sheet.command.insert-sheet-image",type:p.CommandType.COMMAND,handler:(i,t)=>{const e=i.get(p.ICommandService),n=i.get(p.IUndoRedoService),r=i.get(g.ISheetDrawingService);if(!t)return!1;const o=t.drawings,a=o.map(S=>S.unitId),s=r.getBatchAddOp(o),{unitId:c,subUnitId:u,undo:d,redo:l,objects:h}=s;return e.syncExecuteCommand(g.SetDrawingApplyMutation.id,{op:l,unitId:c,subUnitId:u,objects:h,type:g.DrawingApplyType.INSERT})?(n.pushUndoRedo({unitID:c,undoMutations:[{id:g.SetDrawingApplyMutation.id,params:{op:d,unitId:c,subUnitId:u,objects:h,type:g.DrawingApplyType.REMOVE}},{id:L.id,params:a}],redoMutations:[{id:g.SetDrawingApplyMutation.id,params:{op:l,unitId:c,subUnitId:u,objects:h,type:g.DrawingApplyType.INSERT}},{id:L.id,params:a}]}),!0):!1}},me={id:"sheet.command.set-sheet-image",type:p.CommandType.COMMAND,handler:(i,t)=>{const e=i.get(p.ICommandService),n=i.get(p.IUndoRedoService),r=i.get(g.ISheetDrawingService);if(!t)return!1;const{drawings:o}=t,a=r.getBatchUpdateOp(o),{unitId:s,subUnitId:c,undo:u,redo:d,objects:l}=a;return e.syncExecuteCommand(g.SetDrawingApplyMutation.id,{unitId:s,subUnitId:c,op:d,objects:l,type:g.DrawingApplyType.UPDATE})?(n.pushUndoRedo({unitID:s,undoMutations:[{id:g.SetDrawingApplyMutation.id,params:{unitId:s,subUnitId:c,op:u,objects:l,type:g.DrawingApplyType.UPDATE}},{id:L.id,params:[s]}],redoMutations:[{id:g.SetDrawingApplyMutation.id,params:{unitId:s,subUnitId:c,op:d,objects:l,type:g.DrawingApplyType.UPDATE}},{id:L.id,params:[s]}]}),!0):!1}},Me={id:"sheet.command.set-drawing-arrange",type:p.CommandType.COMMAND,handler:(i,t)=>{const e=i.get(p.ICommandService),n=i.get(p.IUndoRedoService);if(!t)return!1;const r=i.get(g.ISheetDrawingService),{unitId:o,subUnitId:a,drawingIds:s,arrangeType:c}=t,u={unitId:o,subUnitId:a,drawingIds:s};let d;if(c===P.ArrangeTypeEnum.forward?d=r.getForwardDrawingsOp(u):c===P.ArrangeTypeEnum.backward?d=r.getBackwardDrawingOp(u):c===P.ArrangeTypeEnum.front?d=r.getFrontDrawingsOp(u):c===P.ArrangeTypeEnum.back&&(d=r.getBackDrawingsOp(u)),d==null)return!1;const{objects:l,redo:h,undo:m}=d;return e.syncExecuteCommand(g.SetDrawingApplyMutation.id,{op:h,unitId:o,subUnitId:a,objects:l,type:g.DrawingApplyType.ARRANGE})?(n.pushUndoRedo({unitID:o,undoMutations:[{id:g.SetDrawingApplyMutation.id,params:{op:m,unitId:o,subUnitId:a,objects:l,type:g.DrawingApplyType.ARRANGE}}],redoMutations:[{id:g.SetDrawingApplyMutation.id,params:{op:h,unitId:o,subUnitId:a,objects:l,type:g.DrawingApplyType.ARRANGE}}]}),!0):!1}};function Ye(i){const t=[];return i.forEach(e=>{const{parent:n,children:r}=e,{unitId:o,subUnitId:a,drawingId:s}=n,c=B.getGroupState(0,0,r.map(l=>l.transform||{})),u=r.map(l=>{const h=l.transform||{left:0,top:0},{unitId:m,subUnitId:S,drawingId:f}=l;return{unitId:m,subUnitId:S,drawingId:f,transform:{...h,left:h.left-c.left,top:h.top-c.top},groupId:s}}),d={unitId:o,subUnitId:a,drawingId:s,drawingType:P.DrawingTypeEnum.DRAWING_GROUP,transform:c};t.push({parent:d,children:u})}),t}function Xe(i){const t=[];return i.forEach(e=>{const{parent:n,children:r}=e,{unitId:o,subUnitId:a,drawingId:s,transform:c={width:0,height:0}}=n;if(c==null)return;const u=r.map(l=>{const{transform:h}=l,{unitId:m,subUnitId:S,drawingId:f}=l,_=B.transformObjectOutOfGroup(h||{},c,c.width||0,c.height||0);return{unitId:m,subUnitId:S,drawingId:f,transform:_,groupId:void 0}}),d={unitId:o,subUnitId:a,drawingId:s,drawingType:P.DrawingTypeEnum.DRAWING_GROUP,transform:{left:0,top:0}};t.push({parent:d,children:u})}),t}const De={id:"sheet.command.group-sheet-image",type:p.CommandType.COMMAND,handler:(i,t)=>{const e=i.get(p.ICommandService),n=i.get(p.IUndoRedoService),r=i.get(g.ISheetDrawingService);if(!t)return!1;const o=[];t.forEach(({parent:m,children:S})=>{o.push(m.unitId),S.forEach(f=>{o.push(f.unitId)})});const a=r.getGroupDrawingOp(t),{unitId:s,subUnitId:c,undo:u,redo:d,objects:l}=a;return e.syncExecuteCommand(g.SetDrawingApplyMutation.id,{op:d,unitId:s,subUnitId:c,objects:l,type:g.DrawingApplyType.GROUP})?(n.pushUndoRedo({unitID:s,undoMutations:[{id:g.SetDrawingApplyMutation.id,params:{op:u,unitId:s,subUnitId:c,objects:Xe(l),type:g.DrawingApplyType.UNGROUP}},{id:L.id,params:o}],redoMutations:[{id:g.SetDrawingApplyMutation.id,params:{op:d,unitId:s,subUnitId:c,objects:l,type:g.DrawingApplyType.GROUP}},{id:L.id,params:o}]}),!0):!1}},Te={id:"sheet.command.ungroup-sheet-image",type:p.CommandType.COMMAND,handler:(i,t)=>{const e=i.get(p.ICommandService),n=i.get(p.IUndoRedoService),r=i.get(g.ISheetDrawingService);if(!t)return!1;const o=[];t.forEach(({parent:m,children:S})=>{o.push(m.unitId),S.forEach(f=>{o.push(f.unitId)})});const a=r.getUngroupDrawingOp(t),{unitId:s,subUnitId:c,undo:u,redo:d,objects:l}=a;return e.syncExecuteCommand(g.SetDrawingApplyMutation.id,{op:d,unitId:s,subUnitId:c,objects:l,type:g.DrawingApplyType.UNGROUP})?(n.pushUndoRedo({unitID:s,undoMutations:[{id:g.SetDrawingApplyMutation.id,params:{op:u,unitId:s,subUnitId:c,objects:Ye(l),type:g.DrawingApplyType.GROUP}},{id:L.id,params:o}],redoMutations:[{id:g.SetDrawingApplyMutation.id,params:{op:d,unitId:s,subUnitId:c,objects:l,type:g.DrawingApplyType.UNGROUP}},{id:L.id,params:o}]}),!0):!1}};function x(i,t){const{from:e,to:n}=i,{column:r,columnOffset:o,row:a,rowOffset:s}=e,{column:c,columnOffset:u,row:d,rowOffset:l}=n,h=t.attachRangeWithCoord({startColumn:r,endColumn:r,startRow:a,endRow:a});if(h==null)return;const m=t.attachRangeWithCoord({startColumn:c,endColumn:c,startRow:d,endRow:d});if(m==null)return;const{startX:S,startY:f}=h,{startX:_,startY:T}=m,M=B.precisionTo(S+o,1),I=B.precisionTo(f+s,1);let D=B.precisionTo(_+u-M,1),w=B.precisionTo(T+l-I,1);return h.startX===m.endX&&(D=0),h.startY===m.endY&&(w=0),{left:M,top:I,width:D,height:w}}function W(i,t){const{left:e=0,top:n=0,width:r=0,height:o=0}=i,a=t.getSelectionCellByPosition(e,n);if(a==null)return;const s={column:a.actualColumn,columnOffset:B.precisionTo(e-a.startX,1),row:a.actualRow,rowOffset:B.precisionTo(n-a.startY,1)},c=t.getSelectionCellByPosition(e+r,n+o);if(c==null)return;const u={column:c.actualColumn,columnOffset:B.precisionTo(e+r-c.startX,1),row:c.actualRow,rowOffset:B.precisionTo(n+o-c.startY,1)};return{from:s,to:u}}var ke=Object.defineProperty,ze=Object.getOwnPropertyDescriptor,Ke=(i,t,e,n)=>{for(var r=n>1?void 0:n?ze(t,e):t,o=i.length-1,a;o>=0;o--)(a=i[o])&&(r=(n?a(t,e,r):a(r))||r);return n&&r&&ke(t,e,r),r},X=(i,t)=>(e,n)=>t(e,n,i);let pe=class extends p.Disposable{constructor(i,t,e,n,r,o,a,s,c,u,d){super(),this._commandService=i,this._univerInstanceService=t,this._selectionManagerService=e,this._selectionRenderService=n,this._imageIoService=r,this._sheetDrawingService=o,this._drawingManagerService=a,this._contextService=s,this._messageService=c,this._localeService=u,this._renderManagerService=d,this._init()}_init(){this._initCommandListeners(),this._updateImageListener(),this._updateOrderListener(),this._groupDrawingListener(),this._focusDrawingListener()}_initCommandListeners(){this.disposeWithMe(this._commandService.onCommandExecuted(async i=>{if(i.id===ue.id||i.id===de.id){const t=i.params;if(t.files==null)return;const e=t.files.length;if(e>P.DRAWING_IMAGE_COUNT_LIMIT){this._messageService.show({type:q.MessageType.Error,content:this._localeService.t("update-status.exceedMaxCount",String(P.DRAWING_IMAGE_COUNT_LIMIT))});return}this._imageIoService.setWaitCount(e),i.id===ue.id?t.files.forEach(async n=>{await this._insertCellImage(n)}):t.files.forEach(async n=>{await this._insertFloatImage(n)})}}))}async _insertCellImage(i){}async _insertFloatImage(i){let t;try{t=await this._imageIoService.saveImage(i)}catch(M){const I=M.message;I===P.ImageUploadStatusType.ERROR_EXCEED_SIZE?this._messageService.show({type:q.MessageType.Error,content:this._localeService.t("update-status.exceedMaxSize",String(P.DRAWING_IMAGE_ALLOW_SIZE/(1024*1024)))}):I===P.ImageUploadStatusType.ERROR_IMAGE_TYPE?this._messageService.show({type:q.MessageType.Error,content:this._localeService.t("update-status.invalidImageType")}):I===P.ImageUploadStatusType.ERROR_IMAGE&&this._messageService.show({type:q.MessageType.Error,content:this._localeService.t("update-status.invalidImage")})}if(t==null)return;const e=this._getUnitInfo();if(e==null)return;const{unitId:n,subUnitId:r}=e,{imageId:o,imageSourceType:a,source:s,base64Cache:c}=t,{width:u,height:d,image:l}=await P.getImageSize(c||""),h=this._renderManagerService.getRenderById(n);if(h==null)return;const{width:m,height:S}=h.scene;this._imageIoService.addImageSourceCache(s,a,l);let f=1;if(u>P.DRAWING_IMAGE_WIDTH_LIMIT||d>P.DRAWING_IMAGE_HEIGHT_LIMIT){const M=P.DRAWING_IMAGE_WIDTH_LIMIT/u,I=P.DRAWING_IMAGE_HEIGHT_LIMIT/d;f=Math.max(M,I)}const _=this._getImagePosition(u*f,d*f,m,S);if(_==null)return;const T={unitId:n,subUnitId:r,drawingId:o,drawingType:P.DrawingTypeEnum.DRAWING_IMAGE,imageSourceType:a,source:s,transform:x(_,this._selectionRenderService),sheetTransform:_};this._commandService.executeCommand(we.id,{unitId:n,drawings:[T]})}_getUnitInfo(){const i=this._univerInstanceService.getCurrentUnitForType(p.UniverInstanceType.UNIVER_SHEET);if(i==null)return;const t=i.getActiveSheet();if(t==null)return;const e=i.getUnitId(),n=t.getSheetId();return{unitId:e,subUnitId:n}}_getImagePosition(i,t,e,n){const r=this._selectionManagerService.getSelections();let o={startRow:0,endRow:0,startColumn:0,endColumn:0};r&&r.length>0&&(o=r[r.length-1].range);const a=this._selectionRenderService.attachRangeWithCoord(o);if(a==null)return;let{startColumn:s,startRow:c,startX:u,startY:d}=a,l=!1;if(u+i>e&&(u=e-i,u<0&&(u=0,i=e),l=!0),d+t>n&&(d=n-t,d<0&&(d=0,t=n),l=!0),l){const f=this._selectionRenderService.getSelectionCellByPosition(u,d);if(f==null)return;u=f.startX,d=f.startY,s=f.actualColumn,c=f.actualRow}const h={column:s,columnOffset:0,row:c,rowOffset:0},m=this._selectionRenderService.getSelectionCellByPosition(u+i,d+t);if(m==null)return;const S={column:m.actualColumn,columnOffset:u+i-m.startX,row:m.actualRow,rowOffset:d+t-m.startY};return{from:h,to:S}}_updateOrderListener(){this._drawingManagerService.featurePluginOrderUpdate$.subscribe(i=>{const{unitId:t,subUnitId:e,drawingIds:n,arrangeType:r}=i;this._commandService.executeCommand(Me.id,{unitId:t,subUnitId:e,drawingIds:n,arrangeType:r})})}_updateImageListener(){this._drawingManagerService.featurePluginUpdate$.subscribe(i=>{const t=[];i.length!==0&&(i.forEach(e=>{const{unitId:n,subUnitId:r,drawingId:o,drawingType:a,transform:s}=e;if(s==null)return;const c=this._sheetDrawingService.getDrawingByParam({unitId:n,subUnitId:r,drawingId:o});if(c==null)return;const u=W({...c.transform,...s},this._selectionRenderService);if(u==null)return;const d={...e,transform:{...c.transform,...s,...x(u,this._selectionRenderService)},sheetTransform:{...u}};t.push(d)}),t.length>0&&this._commandService.executeCommand(me.id,{unitId:i[0].unitId,drawings:t}))})}_groupDrawingListener(){this._drawingManagerService.featurePluginGroupUpdate$.subscribe(i=>{this._commandService.executeCommand(De.id,i);const{unitId:t,subUnitId:e,drawingId:n}=i[0].parent;this._drawingManagerService.focusDrawing([{unitId:t,subUnitId:e,drawingId:n}])}),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(p.FOCUSING_COMMON_DRAWINGS,!1),this._sheetDrawingService.focusDrawing([])):(this._contextService.setContextValue(p.FOCUSING_COMMON_DRAWINGS,!0),this._sheetDrawingService.focusDrawing(i))}))}};pe=Ke([p.OnLifecycle(p.LifecycleStages.Rendered,pe),X(0,p.ICommandService),X(1,p.IUniverInstanceService),X(2,j.Inject(C.SelectionManagerService)),X(3,H.ISelectionRenderService),X(4,P.IImageIoService),X(5,g.ISheetDrawingService),X(6,P.IDrawingManagerService),X(7,p.IContextService),X(8,G.IMessageService),X(9,j.Inject(p.LocaleService)),X(10,B.IRenderManagerService)],pe);var Y=function(){return Y=Object.assign||function(i){for(var t,e=1,n=arguments.length;e<n;e++){t=arguments[e];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(i[r]=t[r])}return i},Y.apply(this,arguments)},qe=function(i,t){var e={};for(var n in i)Object.prototype.hasOwnProperty.call(i,n)&&t.indexOf(n)<0&&(e[n]=i[n]);if(i!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,n=Object.getOwnPropertySymbols(i);r<n.length;r++)t.indexOf(n[r])<0&&Object.prototype.propertyIsEnumerable.call(i,n[r])&&(e[n[r]]=i[n[r]]);return e},Re=A.forwardRef(function(i,t){var e=i.icon,n=i.id,r=i.className,o=i.extend,a=qe(i,["icon","id","className","extend"]),s="univerjs-icon univerjs-icon-".concat(n," ").concat(r||"").trim(),c=A.useRef("_".concat(Qe()));return Oe(e,"".concat(n),{defIds:e.defIds,idSuffix:c.current},Y({ref:t,className:s},a),o)});function Oe(i,t,e,n,r){return A.createElement(i.tag,Y(Y({key:t},Je(i,e,r)),n),(Ze(i,e).children||[]).map(function(o,a){return Oe(o,"".concat(t,"-").concat(i.tag,"-").concat(a),e,void 0,r)}))}function Je(i,t,e){var n=Y({},i.attrs);e!=null&&e.colorChannel1&&n.fill==="colorChannel1"&&(n.fill=e.colorChannel1);var r=t.defIds;return!r||r.length===0||(i.tag==="use"&&n["xlink:href"]&&(n["xlink:href"]=n["xlink:href"]+t.idSuffix),Object.entries(n).forEach(function(o){var a=o[0],s=o[1];typeof s=="string"&&(n[a]=s.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))})),n}function Ze(i,t){var e,n=t.defIds;return!n||n.length===0?i:i.tag==="defs"&&(!((e=i.children)===null||e===void 0)&&e.length)?Y(Y({},i),{children:i.children.map(function(r){return typeof r.attrs.id=="string"&&n&&n.indexOf(r.attrs.id)>-1?Y(Y({},r),{attrs:Y(Y({},r.attrs),{id:r.attrs.id+t.idSuffix})}):r})}):i}function Qe(){return Math.random().toString(36).substring(2,8)}Re.displayName="UniverIcon";var en={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"}}]},Pe=A.forwardRef(function(i,t){return A.createElement(Re,Object.assign({},i,{id:"add-image-single",ref:t,icon:en}))});Pe.displayName="AddImageSingle";const be={uploadFileMenu:"univer-upload-file-menu",uploadFileMenuInput:"univer-upload-file-menu-input"},Ae="COMPONENT_UPLOAD_FILE_MENU";var ge=(i=>(i[i.cellImage=0]="cellImage",i[i.floatImage=1]="floatImage",i))(ge||{});const nn=i=>{const{type:t}=i,e=z.useDependency(p.ICommandService),n=A.useRef(null),r=()=>{var s;(s=n.current)==null||s.click()},o=P.DRAWING_IMAGE_ALLOW_IMAGE_LIST.map(s=>`.${s.replace("image/","")}`).join(","),a=s=>{const c=s.target.files;if(c==null)return;const u=Array.from(c);t===ge.floatImage?e.executeCommand(de.id,{files:u}):t===ge.cellImage&&e.executeCommand(ue.id,{files:u}),n.current&&(n.current.value="")};return A.createElement("div",{onClick:r,className:be.uploadFileMenu},A.createElement("input",{type:"file",className:be.uploadFileMenuInput,ref:n,onChange:a,accept:o,multiple:!0}))},Ee="addition-and-subtraction-single",Ue="sheet.menu.image";function tn(i){return{id:Ue,type:G.MenuItemType.SUBITEMS,positions:[G.MenuPosition.TOOLBAR_START],group:G.MenuGroup.TOOLBAR_FORMULAS_INSERT,icon:Ee,tooltip:"sheetImage.title",hidden$:G.getMenuHiddenObservable(i,p.UniverInstanceType.UNIVER_SHEET),disabled$:H.getCurrentRangeDisable$(i,{workbookTypes:[C.WorkbookEditablePermission],worksheetTypes:[C.WorksheetEditPermission],rangeTypes:[C.RangeProtectionPermissionEditPoint]})}}function rn(i){return{id:de.id,title:"sheetImage.upload.float",type:G.MenuItemType.SELECTOR,label:{name:Ae,props:{type:ge.floatImage}},positions:[Ue],hidden$:G.getMenuHiddenObservable(i,p.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",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"},on=i=>{var I;const t=z.useDependency(p.ICommandService),e=z.useDependency(p.LocaleService),n=z.useDependency(P.IDrawingManagerService),r=z.useDependency(B.IRenderManagerService),{drawings:o}=i,a=o[0];if(a==null)return;const{unitId:s}=a,c=r.getRenderById(s),u=c==null?void 0:c.scene;if(u==null)return;const d=u.getTransformerByCreate(),[l,h]=A.useState(!0),m=(I=a.anchorType)!=null?I:g.SheetDrawingAnchorType.Position,[S,f]=A.useState(m);function _(D,w){const b=[];return D.forEach(v=>{const{oKey:N}=v,R=w.getDrawingOKey(N);if(R==null)return b.push(null),!0;const{unitId:$,subUnitId:U,drawingId:E,drawingType:y,anchorType:F,sheetTransform:k}=R;b.push({unitId:$,subUnitId:U,drawingId:E,anchorType:F,sheetTransform:k,drawingType:y})}),b}A.useEffect(()=>{const D=d.onClearControlObservable.add(b=>{b===!0&&h(!1)}),w=d.onChangeStartObservable.add(b=>{var R;const{objects:v}=b,N=_(v,n);if(N.length===0)h(!1);else if(N.length>=1){h(!0);const $=((R=N[0])==null?void 0:R.anchorType)||g.SheetDrawingAnchorType.Position;f($)}});return()=>{w==null||w.dispose(),D==null||D.dispose()}},[]);function T(D){f(D);const w=n.getFocusDrawings();if(w.length===0)return;const b=w.map(v=>({unitId:v.unitId,subUnitId:v.subUnitId,drawingId:v.drawingId,anchorType:D}));t.executeCommand(me.id,{unitId:w[0].unitId,drawings:b})}const M=D=>D?"block":"none";return A.createElement("div",{className:se(J.imageCommonPanelGrid,J.imageCommonPanelBorder),style:{display:M(l)}},A.createElement("div",{className:J.imageCommonPanelRow},A.createElement("div",{className:se(J.imageCommonPanelColumn,J.imageCommonPanelTitle)},A.createElement("div",null,e.t("drawing-anchor.title")))),A.createElement("div",{className:se(J.imageCommonPanelRow)},A.createElement("div",{className:se(J.imageCommonPanelColumn)},A.createElement(q.RadioGroup,{value:S,onChange:T,direction:"vertical"},A.createElement(q.Radio,{value:g.SheetDrawingAnchorType.Both},e.t("drawing-anchor.both")),A.createElement(q.Radio,{value:g.SheetDrawingAnchorType.Position},e.t("drawing-anchor.position")),A.createElement(q.Radio,{value:g.SheetDrawingAnchorType.None},e.t("drawing-anchor.none"))))))},an=()=>{const i=z.useDependency(P.IDrawingManagerService),t=i.getFocusDrawings();if(t==null||t.length===0)return;const[e,n]=A.useState(t);return A.useEffect(()=>{const r=i.focus$.subscribe(o=>{n(o)});return()=>{r.unsubscribe()}},[]),A.createElement("div",{className:J.imageCommonPanel},A.createElement(Z.DrawingCommonPanel,{drawings:e}),A.createElement(on,{drawings:e}))},re={id:"sheet.command.move-drawing",type:p.CommandType.COMMAND,handler:(i,t)=>{const e=i.get(p.ICommandService),n=i.get(g.ISheetDrawingService),r=i.get(H.ISelectionRenderService),{direction:o}=t,a=n.getFocusDrawings();if(a.length===0)return!1;const s=a[0].unitId,c=a.map(d=>{const{transform:l}=d;if(l==null)return null;const h={...l},{left:m=0,top:S=0}=l;return o===p.Direction.UP?h.top=S-1:o===p.Direction.DOWN?h.top=S+1:o===p.Direction.LEFT?h.left=m-1:o===p.Direction.RIGHT&&(h.left=m+1),{...d,transform:h,sheetTransform:W(h,r)}}).filter(d=>d!=null);return e.syncExecuteCommand(me.id,{unitId:s,drawings:c})?(e.syncExecuteCommand(L.id,[s]),!0):!1}},Ne={id:"sheet.command.delete-drawing",type:p.CommandType.COMMAND,handler:i=>{const t=i.get(p.ICommandService),n=i.get(g.ISheetDrawingService).getFocusDrawings();if(n.length===0)return!1;const r=n[0].unitId,o=n.map(a=>{const{unitId:s,subUnitId:c,drawingId:u,drawingType:d}=a;return{unitId:s,subUnitId:c,drawingId:u,drawingType:d}});return t.executeCommand(ve.id,{unitId:r,drawings:o})}};function ie(i){return!i.getContextValue(p.FOCUSING_FORMULA_EDITOR)&&!i.getContextValue(p.EDITOR_ACTIVATED)&&i.getContextValue(p.FOCUSING_COMMON_DRAWINGS)}const sn={id:re.id,description:"shortcut.sheet.drawing-move-down",group:"4_sheet-drawing-view",binding:G.KeyCode.ARROW_DOWN,priority:100,preconditions:ie,staticParameters:{direction:p.Direction.DOWN}},cn={id:re.id,description:"shortcut.sheet.drawing-move-up",group:"4_sheet-drawing-view",binding:G.KeyCode.ARROW_UP,priority:100,preconditions:ie,staticParameters:{direction:p.Direction.UP}},ln={id:re.id,description:"shortcut.sheet.drawing-move-left",group:"4_sheet-drawing-view",binding:G.KeyCode.ARROW_LEFT,priority:100,preconditions:ie,staticParameters:{direction:p.Direction.LEFT}},dn={id:re.id,description:"shortcut.sheet.drawing-move-right",group:"4_sheet-drawing-view",binding:G.KeyCode.ARROW_RIGHT,priority:100,preconditions:ie,staticParameters:{direction:p.Direction.RIGHT}},un={id:Ne.id,description:"shortcut.sheet.drawing-delete",group:"4_sheet-drawing-view",preconditions:ie,binding:G.KeyCode.DELETE,mac:G.KeyCode.BACKSPACE};var mn=Object.defineProperty,pn=Object.getOwnPropertyDescriptor,gn=(i,t,e,n)=>{for(var r=n>1?void 0:n?pn(t,e):t,o=i.length-1,a;o>=0;o--)(a=i[o])&&(r=(n?a(t,e,r):a(r))||r);return n&&r&&mn(t,e,r),r},oe=(i,t)=>(e,n)=>t(e,n,i);const hn={};let ae=class extends p.Disposable{constructor(i,t,e,n,r,o){super(),this._config=i,this._injector=t,this._componentManager=e,this._menuService=n,this._commandService=r,this._shortcutService=o,this._init()}_initCustomComponents(){const i=this._componentManager;this.disposeWithMe(i.register(Ee,Pe)),this.disposeWithMe(i.register(Ae,nn)),this.disposeWithMe(i.register(Ce,an))}_initMenus(){const{menu:i={}}=this._config;[tn,rn].forEach(t=>{this._menuService.addMenuItem(t(this._injector),i)})}_initCommands(){[de,ue,we,ve,me,Ie,L,ye,De,Te,re,Ne,Me].forEach(i=>this.disposeWithMe(this._commandService.registerCommand(i)))}_initShortcuts(){[sn,cn,ln,dn,un].forEach(i=>{this.disposeWithMe(this._shortcutService.registerShortcut(i))})}_init(){this._initCommands(),this._initCustomComponents(),this._initMenus(),this._initShortcuts()}};ae=gn([p.OnLifecycle(p.LifecycleStages.Rendered,ae),oe(1,j.Inject(j.Injector)),oe(2,j.Inject(G.ComponentManager)),oe(3,G.IMenuService),oe(4,p.ICommandService),oe(5,G.IShortcutService)],ae);var fn=Object.defineProperty,Sn=Object.getOwnPropertyDescriptor,vn=(i,t,e,n)=>{for(var r=n>1?void 0:n?Sn(t,e):t,o=i.length-1,a;o>=0;o--)(a=i[o])&&(r=(n?a(t,e,r):a(r))||r);return n&&r&&fn(t,e,r),r},ne=(i,t)=>(e,n)=>t(e,n,i);const wn=[C.InsertRowCommand.id,C.InsertColCommand.id,C.RemoveRowCommand.id,C.RemoveColCommand.id,C.DeleteRangeMoveLeftCommand.id,C.DeleteRangeMoveUpCommand.id,C.InsertRangeMoveDownCommand.id,C.InsertRangeMoveRightCommand.id,C.DeltaRowHeightCommand.id,C.SetRowHeightCommand.id,C.DeltaColumnWidthCommand.id,C.SetColWidthCommand.id,C.SetRowHiddenCommand.id,C.SetSpecificRowsVisibleCommand.id,C.SetSpecificColsVisibleCommand.id,C.SetColHiddenCommand.id],_n=[C.SetRowVisibleMutation.id,C.SetRowHiddenMutation.id,C.SetColVisibleMutation.id,C.SetColHiddenMutation.id,C.SetWorksheetRowHeightMutation.id,C.SetWorksheetColWidthMutation.id];let he=class extends p.Disposable{constructor(i,t,e,n,r,o){super(),this._commandService=i,this._sheetInterceptorService=t,this._sheetDrawingService=e,this._drawingManagerService=n,this._selectionRenderService=r,this._univerInstanceService=o,this._init()}_init(){this._sheetInterceptorListener(),this._commandListener(),this._sheetRefreshListener()}_sheetInterceptorListener(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:i=>{if(!wn.includes(i.id))return{redos:[],undos:[]};if(i.params==null)return{redos:[],undos:[]};const t=i.id;if(t===C.InsertRowCommand.id)return this._moveRowInterceptor(i.params,"insert");if(t===C.InsertColCommand.id)return this._moveColInterceptor(i.params,"insert");if(t===C.RemoveRowCommand.id)return this._moveRowInterceptor(i.params,"remove");if(t===C.RemoveColCommand.id)return this._moveColInterceptor(i.params,"remove");if(t===C.DeleteRangeMoveLeftCommand.id){const{range:e}=i.params;return this._getRangeMoveUndo(e,0)}else if(t===C.DeleteRangeMoveUpCommand.id){const{range:e}=i.params;return this._getRangeMoveUndo(e,1)}else if(t===C.InsertRangeMoveDownCommand.id){const{range:e}=i.params;return this._getRangeMoveUndo(e,2)}else if(t===C.InsertRangeMoveRightCommand.id){const{range:e}=i.params;return this._getRangeMoveUndo(e,3)}else if(t===C.SetRowHiddenCommand.id||t===C.SetSpecificRowsVisibleCommand.id){const e=i.params,{unitId:n,subUnitId:r,ranges:o}=e;return this._getDrawingUndoForRowVisible(n,r,o)}else if(t===C.SetSpecificColsVisibleCommand.id||t===C.SetColHiddenCommand.id){const e=i.params,{unitId:n,subUnitId:r,ranges:o}=e;return this._getDrawingUndoForColVisible(n,r,o)}else if(t===C.DeltaRowHeightCommand.id||t===C.SetRowHeightCommand.id||t===C.DeltaColumnWidthCommand.id||t===C.SetColWidthCommand.id){const e=i.params,{unitId:n,subUnitId:r,ranges:o}=e,a=t===C.DeltaRowHeightCommand.id||t===C.SetRowHeightCommand.id;return this._getDrawingUndoForRowAndColSize(n,r,o,a)}return{redos:[],undos:[]}}}))}_getRangeMoveUndo(i,t){const e=C.getSheetCommandTarget(this._univerInstanceService);if(e==null)return{redos:[],undos:[]};const n=e.unitId,r=e.subUnitId,o=[],a=[],s=this._sheetDrawingService.getDrawingData(n,r),c=[],u=[];if(Object.keys(s).forEach(d=>{const l=s[d],{updateDrawings:h,deleteDrawings:m}=this._getUpdateOrDeleteDrawings(i,t,l);c.push(...h),u.push(...m)}),c.length===0&&u.length===0)return{redos:[],undos:[]};if(c.length>0){const d=this._sheetDrawingService.getBatchUpdateOp(c),{undo:l,redo:h,objects:m}=d;o.push({id:g.SetDrawingApplyMutation.id,params:{unitId:n,subUnitId:r,op:h,objects:m,type:g.DrawingApplyType.UPDATE}}),a.push({id:g.SetDrawingApplyMutation.id,params:{unitId:n,subUnitId:r,op:l,objects:m,type:g.DrawingApplyType.UPDATE}})}if(u.length>0){const d=this._sheetDrawingService.getBatchRemoveOp(u),l=d.undo,h=d.redo,m=d.objects;o.push({id:g.SetDrawingApplyMutation.id,params:{unitId:n,subUnitId:r,op:h,objects:m,type:g.DrawingApplyType.REMOVE}}),a.push({id:g.SetDrawingApplyMutation.id,params:{unitId:n,subUnitId:r,op:l,objects:m,type:g.DrawingApplyType.INSERT}})}return o.push({id:L.id,params:[n]}),a.push({id:L.id,params:[n]}),{redos:o,undos:a}}_getUpdateOrDeleteDrawings(i,t,e){const n=[],r=[],{sheetTransform:o,anchorType:a=g.SheetDrawingAnchorType.Position,transform:s,unitId:c,subUnitId:u,drawingId:d}=e,{from:l,to:h}=o,{row:m,column:S}=l,{row:f,column:_}=h;if(o==null||s==null)return{updateDrawings:n,deleteDrawings:r};const{startRow:T,endRow:M,startColumn:I,endColumn:D}=i;let w=null,b=null;if(t===0&&m>=T&&f<=M)if(S>=I&&_<=D)r.push({unitId:c,subUnitId:u,drawingId:d});else{const v=this._shrinkCol(o,s,I,D,a);w=v==null?void 0:v.newSheetTransform,b=v==null?void 0:v.newTransform}else if(t===1&&S>=I&&_<=D)if(m>=T&&f<=M)r.push({unitId:c,subUnitId:u,drawingId:d});else{const v=this._shrinkRow(o,s,T,M,a);w=v==null?void 0:v.newSheetTransform,b=v==null?void 0:v.newTransform}else if(t===2){const v=this._expandRow(o,s,T,M,a);w=v==null?void 0:v.newSheetTransform,b=v==null?void 0:v.newTransform}else if(t===3){const v=this._expandCol(o,s,I,D,a);w=v==null?void 0:v.newSheetTransform,b=v==null?void 0:v.newTransform}if(w!=null&&b!=null){const v=x(w,this._selectionRenderService);n.push({...e,sheetTransform:w,transform:v})}return{updateDrawings:n,deleteDrawings:r}}_remainDrawingSize(i,t,e){const n=W({...i},this._selectionRenderService);n!=null&&t.push({...e,sheetTransform:n})}_getDrawingUndoForColVisible(i,t,e){const n=this._drawingManagerService.getDrawingData(i,t),r=[],o=[];if(Object.keys(n).forEach(d=>{const l=n[d],{sheetTransform:h,transform:m,anchorType:S=g.SheetDrawingAnchorType.Position}=l;if(S===g.SheetDrawingAnchorType.None)this._remainDrawingSize(m,r,l);else{const{from:f,to:_}=h,{row:T,column:M}=f,{row:I,column:D}=_;for(let w=0;w<e.length;w++){const b=e[w],{startRow:v,endRow:N,startColumn:R,endColumn:$}=b;if(D<R)continue;if(S===g.SheetDrawingAnchorType.Position){let y=null,F=null;if(M>=R&&M<=$){const k=this._selectionRenderService.attachRangeWithCoord({startColumn:M,endColumn:$,startRow:f.row,endRow:_.row});if(k==null)return;F={...m,left:k.startX}}if(F!=null&&(y=W(F,this._selectionRenderService),y!=null&&F!=null)){r.push({...l,sheetTransform:y,transform:F});break}this._remainDrawingSize(m,r,l);continue}if(M>=R&&D<=$)continue;let U=null,E=null;if(M>=R&&M<=$){const y=this._selectionRenderService.attachRangeWithCoord({startColumn:M,endColumn:$,startRow:f.row,endRow:_.row});if(y==null)return;E={...m,left:(y==null?void 0:y.startX)||0,width:((m==null?void 0:m.width)||0)-y.endX+y.startX}}else if(D>=R&&D<=$){const y=this._selectionRenderService.attachRangeWithCoord({startColumn:R,endColumn:D,startRow:f.row,endRow:_.row});if(y==null)return;E={...m,left:y.startX-((m==null?void 0:m.width)||0)}}else{const y=this._selectionRenderService.attachRangeWithCoord({startColumn:R,endColumn:$,startRow:f.row,endRow:_.row});if(y==null)return;if(E={...m,width:((m==null?void 0:m.width)||0)-y.endX+y.startX},U=W(E,this._selectionRenderService),U!=null&&E!=null){o.push({...l,sheetTransform:U,transform:E});break}}if(E!=null&&(U=W(E,this._selectionRenderService)),E!=null&&U!=null){r.push({...l,sheetTransform:U,transform:E});break}else this._remainDrawingSize(m,r,l)}}}),r.length===0&&o.length===0)return{redos:[],undos:[]};const{redos:a,undos:s}=this._createUndoAndRedoMutation(i,t,r),c=[],u=[];if(o.length>0){const{redos:d,undos:l}=this._createUndoAndRedoMutation(i,t,o);c.push(...d),u.push(...l)}return{redos:a,undos:s,preRedos:c,preUndos:u}}_createUndoAndRedoMutation(i,t,e){const n=this._sheetDrawingService.getBatchUpdateOp(e),{undo:r,redo:o,objects:a}=n,s=[{id:g.SetDrawingApplyMutation.id,params:{unitId:i,subUnitId:t,op:o,objects:a,type:g.DrawingApplyType.UPDATE}},{id:L.id,params:[i]}],c=[{id:g.SetDrawingApplyMutation.id,params:{unitId:i,subUnitId:t,op:r,objects:a,type:g.DrawingApplyType.UPDATE}},{id:L.id,params:[i]}];return{redos:s,undos:c}}_getDrawingUndoForRowVisible(i,t,e){const n=this._drawingManagerService.getDrawingData(i,t),r=[],o=[];if(Object.keys(n).forEach(d=>{const l=n[d],{sheetTransform:h,transform:m,anchorType:S=g.SheetDrawingAnchorType.Position}=l;if(S===g.SheetDrawingAnchorType.None)this._remainDrawingSize(m,r,l);else{const{from:f,to:_}=h,{row:T,column:M}=f,{row:I,column:D}=_;for(let w=0;w<e.length;w++){const b=e[w],{startRow:v,endRow:N,startColumn:R,endColumn:$}=b;if(I<v)continue;if(S===g.SheetDrawingAnchorType.Position){let y=null,F=null;if(T>=v&&T<=N){const k=this._selectionRenderService.attachRangeWithCoord({startColumn:f.column,endColumn:_.column,startRow:T,endRow:N});if(k==null)return;F={...m,top:k.startY}}if(F!=null&&(y=W(F,this._selectionRenderService),y!=null&&F!=null)){r.push({...l,sheetTransform:y,transform:F});break}this._remainDrawingSize(m,r,l);continue}if(T>=v&&I<=N)continue;let U=null,E=null;if(T>=v&&T<=N){const y=this._selectionRenderService.attachRangeWithCoord({startColumn:f.column,endColumn:_.column,startRow:T,endRow:N});if(y==null)return;E={...m,top:(y==null?void 0:y.startY)||0,height:((m==null?void 0:m.height)||0)-y.endY+y.startY}}else if(I>=v&&I<=N){const y=this._selectionRenderService.attachRangeWithCoord({startColumn:f.column,endColumn:_.column,startRow:v,endRow:I});if(y==null)return;E={...m,top:y.startY-((m==null?void 0:m.height)||0)}}else{const y=this._selectionRenderService.attachRangeWithCoord({startColumn:f.column,endColumn:_.column,startRow:v,endRow:N});if(y==null)return;if(E={...m,height:((m==null?void 0:m.height)||0)-y.endY+y.startY},U=W(E,this._selectionRenderService),U!=null&&E!=null){o.push({...l,sheetTransform:U,transform:E});break}}if(E!=null&&(U=W(E,this._selectionRenderService)),E!=null&&U!=null){r.push({...l,sheetTransform:U,transform:E});break}else this._remainDrawingSize(m,r,l)}}}),r.length===0&&o.length===0)return{redos:[],undos:[]};const{redos:a,undos:s}=this._createUndoAndRedoMutation(i,t,r),c=[],u=[];if(o.length>0){const{redos:d,undos:l}=this._createUndoAndRedoMutation(i,t,o);c.push(...d),u.push(...l)}return{redos:a,undos:s,preRedos:c,preUndos:u}}_getDrawingUndoForRowAndColSize(i,t,e,n){const r=this._drawingManagerService.getDrawingData(i,t),o=[];return Object.keys(r).forEach(a=>{const s=r[a],{sheetTransform:c,transform:u,anchorType:d=g.SheetDrawingAnchorType.Position}=s;if(d===g.SheetDrawingAnchorType.None)this._remainDrawingSize(u,o,s);else{const{from:l,to:h}=c,{row:m,column:S}=l,{row:f,column:_}=h;for(let T=0;T<e.length;T++){const M=e[T],{startRow:I,endRow:D,startColumn:w,endColumn:b}=M;if(f<I||_<w)continue;if(d===g.SheetDrawingAnchorType.Position&&(m<=I&&f>=D||S<=w&&_>=b)){this._remainDrawingSize(u,o,s);continue}const v=x({...c},this._selectionRenderService);if(v!=null){o.push({...s,transform:v});break}}}}),o.length===0?{redos:[],undos:[]}:this._createUndoAndRedoMutation(i,t,o)}_getUnitIdAndSubUnitId(i,t){let e,n;if(t==="insert")e=i.unitId,n=i.subUnitId;else{const r=C.getSheetCommandTarget(this._univerInstanceService);if(r==null)return;e=r.unitId,n=r.subUnitId}return{unitId:e,subUnitId:n}}_moveRowInterceptor(i,t){const e=this._getUnitIdAndSubUnitId(i,t);if(e==null)return{redos:[],undos:[]};const{unitId:n,subUnitId:r}=e,{range:o}=i,a=o.startRow,s=o.endRow,c=[],u=[],d=this._sheetDrawingService.getDrawingData(n,r),l=[],h=[];if(Object.keys(d).forEach(m=>{const S=d[m],{sheetTransform:f,transform:_,anchorType:T=g.SheetDrawingAnchorType.Position}=S;if(f==null||_==null)return;let M,I;if(t==="insert"){const w=this._expandRow(f,_,a,s,T);M=w==null?void 0:w.newSheetTransform,I=w==null?void 0:w.newTransform}else{const{from:w,to:b}=f,{row:v}=w,{row:N}=b;if(v>=a&&N<=s)h.push({unitId:n,subUnitId:r,drawingId:m});else{const R=this._shrinkRow(f,_,a,s,T);M=R==null?void 0:R.newSheetTransform,I=R==null?void 0:R.newTransform}}if(!M||!I)return;const D={unitId:n,subUnitId:r,drawingId:m,transform:I,sheetTransform:M};l.push(D)}),l.length===0&&h.length===0)return{redos:[],undos:[]};if(l.length>0){const m=this._sheetDrawingService.getBatchUpdateOp(l),{undo:S,redo:f,objects:_}=m;c.push({id:g.SetDrawingApplyMutation.id,params:{unitId:n,subUnitId:r,op:f,objects:_,type:g.DrawingApplyType.UPDATE}}),u.push({id:g.SetDrawingApplyMutation.id,params:{unitId:n,subUnitId:r,op:S,objects:_,type:g.DrawingApplyType.UPDATE}})}if(h.length>0){const m=this._sheetDrawingService.getBatchRemoveOp(h),S=m.undo,f=m.redo,_=m.objects;c.push({id:g.SetDrawingApplyMutation.id,params:{unitId:n,subUnitId:r,op:f,objects:_,type:g.DrawingApplyType.REMOVE}}),u.push({id:g.SetDrawingApplyMutation.id,params:{unitId:n,subUnitId:r,op:S,objects:_,type:g.DrawingApplyType.INSERT}})}return c.push({id:L.id,params:[n]}),u.push({id:L.id,params:[n]}),{redos:c,undos:u}}_moveColInterceptor(i,t){const e=this._getUnitIdAndSubUnitId(i,t);if(e==null)return{redos:[],undos:[]};const{unitId:n,subUnitId:r}=e,{range:o}=i,a=o.startColumn,s=o.endColumn,c=[],u=[],d=this._sheetDrawingService.getDrawingData(n,r),l=[],h=[];if(Object.keys(d).forEach(m=>{const S=d[m],{sheetTransform:f,transform:_,anchorType:T=g.SheetDrawingAnchorType.Position}=S;if(f==null||_==null)return;let M,I;if(t==="insert"){const w=this._expandCol(f,_,a,s,T);M=w==null?void 0:w.newSheetTransform,I=w==null?void 0:w.newTransform}else{const{from:w,to:b}=f,{column:v}=w,{column:N}=b;if(v>=a&&N<=s)h.push({unitId:n,subUnitId:r,drawingId:m});else{const R=this._shrinkCol(f,_,a,s,T);M=R==null?void 0:R.newSheetTransform,I=R==null?void 0:R.newTransform}}if(!M||!I)return;const D={unitId:n,subUnitId:r,drawingId:m,transform:I,sheetTransform:M};l.push(D)}),l.length===0&&h.length===0)return{redos:[],undos:[]};if(l.length>0){const m=this._sheetDrawingService.getBatchUpdateOp(l),{undo:S,redo:f,objects:_}=m;c.push({id:g.SetDrawingApplyMutation.id,params:{unitId:n,subUnitId:r,op:f,objects:_,type:g.DrawingApplyType.UPDATE}}),u.push({id:g.SetDrawingApplyMutation.id,params:{unitId:n,subUnitId:r,op:S,objects:_,type:g.DrawingApplyType.UPDATE}})}if(h.length>0){const m=this._sheetDrawingService.getBatchRemoveOp(h),S=m.undo,f=m.redo,_=m.objects;c.push({id:g.SetDrawingApplyMutation.id,params:{unitId:n,subUnitId:r,op:f,objects:_,type:g.DrawingApplyType.REMOVE}}),u.push({id:g.SetDrawingApplyMutation.id,params:{unitId:n,subUnitId:r,op:S,objects:_,type:g.DrawingApplyType.INSERT}})}return c.push({id:L.id,params:[n]}),u.push({id:L.id,params:[n]}),{redos:c,undos:u}}_expandCol(i,t,e,n,r=g.SheetDrawingAnchorType.Position){const o=n-e+1,{from:a,to:s}=i,{column:c}=a,{column:u}=s;if(r===g.SheetDrawingAnchorType.None)return{newSheetTransform:W({...t},this._selectionRenderService),newTransform:t};let d=null,l=null;if(c>=e){const h=this._selectionRenderService.attachRangeWithCoord({startColumn:e,endColumn:n,startRow:a.row,endRow:s.row});if(h==null)return;l={...t,left:(t.left||0)+h.endX-h.startX},d=W(l,this._selectionRenderService)}else if(u>=n)if(r===g.SheetDrawingAnchorType.Both)d={from:{...a},to:{...s,column:u+o}},l=x(d,this._selectionRenderService);else return{newSheetTransform:W({...t},this._selectionRenderService),newTransform:t};return d!=null&&l!=null?{newSheetTransform:d,newTransform:l}:null}_shrinkCol(i,t,e,n,r=g.SheetDrawingAnchorType.Position){const o=n-e+1,{from:a,to:s}=i,{column:c}=a,{column:u}=s;if(r===g.SheetDrawingAnchorType.None)return{newSheetTransform:W({...t},this._selectionRenderService),newTransform:t};let d=null,l=null;if(c>n)d={from:{...a,column:c-o},to:{...s,column:u-o}},l=x(d,this._selectionRenderService);else{if(c>=e&&u<=n)return null;if(c<e&&u>n)if(r===g.SheetDrawingAnchorType.Both)d={from:{...a},to:{...s,column:u-o}},l=x(d,this._selectionRenderService);else return{newSheetTransform:W({...t},this._selectionRenderService),newTransform:t};else if(c>=e&&c<=n){if(c===e)l={...t,left:(t.left||0)-i.from.columnOffset};else{const h=this._selectionRenderService.attachRangeWithCoord({startColumn:e,endColumn:c-1,startRow:a.row,endRow:s.row});if(h==null)return;l={...t,left:(t.left||0)-h.endX+h.startX-i.from.columnOffset}}d=W(l,this._selectionRenderService)}else if(u>=e&&u<=n&&r===g.SheetDrawingAnchorType.Both){const h=this._selectionRenderService.attachRangeWithCoord({startColumn:e-1,endColumn:e-1,startRow:a.row,endRow:s.row});if(h==null)return;d={from:{...a},to:{...s,column:e-1,columnOffset:h.endX-h.startX}},l=x(d,this._selectionRenderService)}}return d!=null&&l!=null?{newSheetTransform:d,newTransform:l}:null}_expandRow(i,t,e,n,r=g.SheetDrawingAnchorType.Position){const o=n-e+1,{from:a,to:s}=i,{row:c}=a,{row:u}=s;if(r===g.SheetDrawingAnchorType.None)return{newSheetTransform:W({...t},this._selectionRenderService),newTransform:t};let d=null,l=null;if(c>=e){const h=this._selectionRenderService.attachRangeWithCoord({startRow:e,endRow:n,startColumn:a.column,endColumn:s.column});if(h==null)return;l={...t,top:(t.top||0)+h.endY-h.startY},d=W(l,this._selectionRenderService)}else if(u>=n)if(r===g.SheetDrawingAnchorType.Both)d={from:{...a},to:{...s,row:u+o}},l=x(d,this._selectionRenderService);else return{newSheetTransform:W({...t},this._selectionRenderService),newTransform:t};return d!=null&&l!=null?{newSheetTransform:d,newTransform:l}:null}_shrinkRow(i,t,e,n,r=g.SheetDrawingAnchorType.Position){const o=n-e+1,{from:a,to:s}=i,{row:c}=a,{row:u}=s;if(r===g.SheetDrawingAnchorType.None)return{newSheetTransform:W({...t},this._selectionRenderService),newTransform:t};let d=null,l=null;if(c>n)d={from:{...a,row:c-o},to:{...s,row:u-o}},l=x(d,this._selectionRenderService);else{if(c>=e&&u<=n)return null;if(c<e&&u>n)if(r===g.SheetDrawingAnchorType.Both)d={from:{...a},to:{...s,row:u-o}},l=x(d,this._selectionRenderService);else return{newSheetTransform:W({...t},this._selectionRenderService),newTransform:t};else if(c>=e&&c<=n){if(c===e)l={...t,top:(t.top||0)-i.from.rowOffset};else{const h=this._selectionRenderService.attachRangeWithCoord({startRow:e,endRow:c-1,startColumn:a.column,endColumn:s.column});if(h==null)return;l={...t,top:(t.top||0)-h.endY+h.startY-i.from.rowOffset}}d=W(l,this._selectionRenderService)}else if(u>=e&&u<=n&&r===g.SheetDrawingAnchorType.Both){const h=this._selectionRenderService.attachRangeWithCoord({startColumn:a.column,endColumn:a.column,startRow:e-1,endRow:e-1});if(h==null)return;d={from:{...a},to:{...s,row:e-1,rowOffset:h.endY-h.startY}},l=x(d,this._selectionRenderService)}}return d!=null&&l!=null?{newSheetTransform:d,newTransform:l}:null}_commandListener(){this.disposeWithMe(this._commandService.onCommandExecuted(i=>{if(i.id===C.SetWorksheetActiveOperation.id){const t=i.params,{unitId:e,subUnitId:n}=t,r=this._drawingManagerService.drawingManagerData,o=[],a=[];Object.keys(r).forEach(s=>{const c=r[s];Object.keys(c).forEach(u=>{const d=c[u].data;d!=null&&Object.keys(d).forEach(l=>{s===e&&u===n?o.push(d[l]):a.push(d[l])})})}),this._drawingManagerService.removeNotification(a),this._drawingManagerService.addNotification(o)}}))}_sheetRefreshListener(){this.disposeWithMe(this._commandService.onCommandExecuted(i=>{_n.includes(i.id)&&requestIdleCallback(()=>{const t=i.params,{unitId:e,subUnitId:n,ranges:r}=t;this._refreshDrawingTransform(e,n,r)})}))}_refreshDrawingTransform(i,t,e){const n=this._drawingManagerService.getDrawingData(i,t),r=[];Object.keys(n).forEach(o=>{const a=n[o],{sheetTransform:s,anchorType:c=g.SheetDrawingAnchorType.Position}=a;if(c===g.SheetDrawingAnchorType.None)return!0;const{from:u,to:d}=s,{row:l,column:h}=u,{row:m,column:S}=d;for(let f=0;f<e.length;f++){const _=e[f],{startRow:T,endRow:M,startColumn:I,endColumn:D}=_;if(p.Rectangle.intersects({startRow:T,endRow:M,startColumn:I,endColumn:D},{startRow:l,endRow:m,startColumn:h,endColumn:S})||l>M||h>D){r.push({...a,transform:x(s,this._selectionRenderService)});break}}}),r.length!==0&&(this._drawingManagerService.refreshTransform(r),this._commandService.syncExecuteCommand(L.id,[i]))}};he=vn([p.OnLifecycle(p.LifecycleStages.Rendered,he),ne(0,p.ICommandService),ne(1,j.Inject(C.SheetInterceptorService)),ne(2,g.ISheetDrawingService),ne(3,P.IDrawingManagerService),ne(4,H.ISelectionRenderService),ne(5,p.IUniverInstanceService)],he);var Cn=Object.defineProperty,In=Object.getOwnPropertyDescriptor,yn=(i,t,e,n)=>{for(var r=n>1?void 0:n?In(t,e):t,o=i.length-1,a;o>=0;o--)(a=i[o])&&(r=(n?a(t,e,r):a(r))||r);return n&&r&&Cn(t,e,r),r},ee=(i,t)=>(e,n)=>t(e,n,i);function Mn(i,t,e,n){const{scaleX:r,scaleY:o}=t.getAncestorScale(),a=t.getViewport(B.SHEET_VIEWPORT_KEY.VIEW_MAIN),s={left:!0,top:!0};if(!a)return{...i,absolute:s};const{left:c,right:u,top:d,bottom:l}=i,h=n.getFreeze(),{startColumn:m,startRow:S,xSplit:f,ySplit:_}=h,T=e.getNoMergeCellPositionByIndexWithNoHeader(S-_,m-f),M=e.getNoMergeCellPositionByIndexWithNoHeader(S,m),{rowHeaderWidth:I,columnHeaderHeight:D}=e,w=M.startX-T.startX,b=M.startY-T.startY,{top:v,left:N,viewportScrollX:R,viewportScrollY:$}=a;let U,E;c<N?(s.left=!0,U=(w+I+(c-N))*r,E=Math.max(Math.min((w+I+(u-N))*r,(w+I)*r),(u-R)*r)):(s.left=!1,U=Math.max((c-R)*r,(w+I)*r),E=Math.max((u-R)*r,(w+I)*r));let y,F;return d<v?(s.top=!0,y=(b+D+(d-v))*o,F=Math.max(Math.min((b+D+(u-v))*o,(b+D)*o),(l-$)*o)):(s.top=!1,y=Math.max((d-$)*o,(b+D)*o),F=Math.max((l-$)*o,(b+D)*o)),{left:U,right:E,top:y,bottom:F,absolute:s}}const _e=(i,t,e,n)=>{const{scene:r}=t,{left:o,top:a,width:s,height:c,angle:u}=i,d={left:o,right:o+s,top:a,bottom:a+c},l=Mn(d,r,e,n);return{startX:l.left,endX:l.right,startY:l.top,endY:l.bottom,rotate:u,width:s,height:c,absolute:l.absolute}};O.SheetCanvasFloatDomManagerService=class extends p.Disposable{constructor(e,n,r,o,a,s,c){super();K(this,"_domLayerMap",new Map);K(this,"_domLayerInfoMap",new Map);K(this,"_transformChange$",new te.Subject);K(this,"transformChange$",this._transformChange$.asObservable());K(this,"_remove$",new te.Subject);K(this,"remove$",this._remove$.asObservable());this._renderManagerService=e,this._univerInstanceService=n,this._commandService=r,this._drawingManagerService=o,this._selectionRenderService=a,this._canvasFloatDomService=s,this._sheetDrawingService=c,this._drawingAddListener(),this._scrollUpdateListener(),this._featureUpdateListener(),this._deleteListener()}_ensureMap(e,n){let r=this._domLayerMap.get(e);r||(r=new Map,this._domLayerMap.set(e,r));let o=r.get(n);return o||(o=new Map,r.set(n,o)),o}_getSceneAndTransformerByDrawingSearch(e){if(e==null)return;const n=this._renderManagerService.getRenderById(e),r=n==null?void 0:n.scene;if(n==null||r==null)return null;const o=r.getTransformerByCreate(),a=n.engine.getCanvasElement();return{scene:r,transformer:o,renderObject:n,canvas:a}}_drawingAddListener(){this.disposeWithMe(this._drawingManagerService.add$.subscribe(e=>{e.forEach(n=>{var Be,Fe;const{unitId:r,subUnitId:o,drawingId:a}=n,s=C.getSheetCommandTarget(this._univerInstanceService,{unitId:r,subUnitId:o}),c=this._drawingManagerService.getDrawingByParam(n),u=(Be=this._renderManagerService.getRenderById(r))==null?void 0:Be.with(H.SheetSkeletonManagerService).getUnitSkeleton(r,o);if(c==null||s==null||u==null)return;const{transform:d,drawingType:l}=c;if(l!==p.DrawingTypeEnum.DRAWING_DOM)return;const h=this._getSceneAndTransformerByDrawingSearch(r);if(h==null)return;const{scene:m,canvas:S}=h;if(d==null)return!0;const{left:f,top:_,width:T,height:M,angle:I,flipX:D,flipY:w,skewX:b,skewY:v}=d,N=P.getDrawingShapeKeyByDrawingSearch({unitId:r,subUnitId:o,drawingId:a}),R=m.getObject(N);if(R!=null){R.transformByState({left:f,top:_,width:T,height:M,angle:I,flipX:D,flipY:w,skewX:b,skewY:v});return}const $={left:f,top:_,width:T,height:M,zIndex:this._drawingManagerService.getDrawingOrder(r,o).length-1},U=new B.Rect(N,$);m.addObject(U,B.DRAWING_OBJECT_LAYER_INDEX).attachTransformerTo(U);const E=this._ensureMap(r,o),y=new p.DisposableCollection,F=_e(U,h.renderObject,u.skeleton,s.worksheet),k=new te.BehaviorSubject(F),En={dispose:y,rect:U,position$:k,unitId:r,subUnitId:o};this._canvasFloatDomService.addFloatDom({position$:k,id:a,componentKey:c.componentKey,onPointerDown:V=>{S.dispatchEvent(new PointerEvent(V.type,V))},onPointerMove:V=>{S.dispatchEvent(new PointerEvent(V.type,V))},onPointerUp:V=>{S.dispatchEvent(new PointerEvent(V.type,V))},onWheel:V=>{S.dispatchEvent(new WheelEvent(V.type,V))},props:(Fe=E.get(a))==null?void 0:Fe.props});const Ge=U.onTransformChangeObservable.add(()=>{const V=_e(U,h.renderObject,u.skeleton,s.worksheet);k.next(V)});y.add(()=>{this._canvasFloatDomService.removeFloatDom(a)}),Ge&&y.add(Ge),this._domLayerInfoMap.set(a,En)})}))}_scrollUpdateListener(){this.disposeWithMe(this._commandService.onCommandExecuted(e=>{var r,o;const n=(a,s)=>{var m;const c=this._getSceneAndTransformerByDrawingSearch(a),u=this._ensureMap(a,s),d=Array.from(u.keys()),l=C.getSheetCommandTarget(this._univerInstanceService,{unitId:a,subUnitId:s}),h=(m=this._renderManagerService.getRenderById(a))==null?void 0:m.with(H.SheetSkeletonManagerService).getUnitSkeleton(a,s);!c||!l||!h||d.forEach(S=>{const f=this._domLayerInfoMap.get(S);if(f){const _=_e(f.rect,c.renderObject,h.skeleton,l.worksheet);f.position$.next(_)}})};if(e.id===H.SetScrollOperation.id){const a=e.params,{unitId:s,sheetId:c}=a;n(s,c)}else if(e.id===H.SetZoomRatioOperation.id){const a=e.params,{unitId:s}=a;Array.from((o=(r=this._domLayerMap.get(s))==null?void 0:r.keys())!=null?o:[]).forEach(u=>{n(s,u)})}else if(e.id===C.SetFrozenMutation.id){const{unitId:a,subUnitId:s}=e.params;n(a,s)}}))}_getPosition(e){const{startX:n,endX:r,startY:o,endY:a}=e,s=this._selectionRenderService.getSelectionCellByPosition(n,o);if(s==null)return;const c={column:s.actualColumn,columnOffset:n-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:c,to:d}}_featureUpdateListener(){this.disposeWithMe(this._drawingManagerService.update$.subscribe(e=>{e.forEach(n=>{const r=this._drawingManagerService.getDrawingByParam(n);if(!r||r.drawingType!==p.DrawingTypeEnum.DRAWING_DOM)return;const o={...r.transform};this._transformChange$.next({id:n.drawingId,value:o})})}))}_deleteListener(){this.disposeWithMe(this._drawingManagerService.remove$.subscribe(e=>{e.forEach(n=>{this._removeDom(n.drawingId)})}))}addFloatDomToPosition(e){const n=C.getSheetCommandTarget(this._univerInstanceService,{unitId:e.unitId,subUnitId:e.subUnitId});if(!n)throw new Error("cannot find current target!");const{unitId:r,subUnitId:o}=n,{initPosition:a,componentKey:s}=e,c=p.Tools.generateRandomId(),u=this._getPosition(a);if(u==null)return;this._ensureMap(r,o).set(c,e);const l={unitId:r,subUnitId:o,drawingId:c,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(we.id,{unitId:r,drawings:[l]}),{id:c,dispose:()=>{this._removeDom(c,!0)}}}_removeDom(e,n=!1){const r=this._domLayerInfoMap.get(e);if(!r)return;const{unitId:o,subUnitId:a}=r,s=this._ensureMap(o,a);this._domLayerInfoMap.delete(e),s.delete(e),r.dispose.dispose();const c=this._getSceneAndTransformerByDrawingSearch(o);if(c&&c.scene.removeObject(r.rect),n){const u=this._drawingManagerService.getDrawingByParam({unitId:o,subUnitId:a,drawingId:e});if(!u)return;const d=this._sheetDrawingService.getBatchRemoveOp([u]),{redo:l,objects:h}=d;this._commandService.syncExecuteCommand(g.SetDrawingApplyMutation.id,{unitId:o,subUnitId:a,op:l,objects:h,type:g.DrawingApplyType.REMOVE})}}},O.SheetCanvasFloatDomManagerService=yn([ee(0,j.Inject(B.IRenderManagerService)),ee(1,p.IUniverInstanceService),ee(2,j.Inject(p.ICommandService)),ee(3,P.IDrawingManagerService),ee(4,H.ISelectionRenderService),ee(5,j.Inject(G.CanvasFloatDomService)),ee(6,g.ISheetDrawingService)],O.SheetCanvasFloatDomManagerService);var Dn=Object.defineProperty,Tn=Object.getOwnPropertyDescriptor,Rn=(i,t,e,n)=>{for(var r=n>1?void 0:n?Tn(t,e):t,o=i.length-1,a;o>=0;o--)(a=i[o])&&(r=(n?a(t,e,r):a(r))||r);return n&&r&&Dn(t,e,r),r},fe=(i,t)=>(e,n)=>t(e,n,i);let Se=class extends p.Disposable{constructor(i,t,e,n){super(),this._sheetPrintInterceptorService=i,this._drawingRenderService=t,this._drawingManagerService=e,this._renderManagerService=n,this._initPrinting()}_initPrinting(){this.disposeWithMe(this._sheetPrintInterceptorService.interceptor.intercept(this._sheetPrintInterceptorService.interceptor.getInterceptPoints().PRINTING_COMPONENT_COLLECT,{handler:(i,t,e)=>{const{unitId:n,scene:r,subUnitId:o}=t,a=this._drawingManagerService.getDrawingDataForUnit(n),s=a==null?void 0:a[o];return s&&s.order.forEach(c=>{this._drawingRenderService.renderDrawing(s.data[c],r)}),e()}})),this.disposeWithMe(this._sheetPrintInterceptorService.interceptor.intercept(this._sheetPrintInterceptorService.interceptor.getInterceptPoints().PRINTING_RANGE,{handler:(i,t,e)=>{const{unitId:n,subUnitId:r}=t,o=this._renderManagerService.getRenderById(n);if(!o)return e(i);const a=o.with(H.SheetSkeletonManagerService).getUnitSkeleton(n,r);if(!a)return e(i);const s=this._drawingManagerService.getDrawingDataForUnit(n),c=s==null?void 0:s[t.subUnitId];if(!c)return e(i);const{scaleX:u,scaleY:d}=o.scene,l=i?{...i}:{startColumn:0,endColumn:0,endRow:0,startRow:0},h=c.order.map(m=>c.data[m]).filter(m=>m.drawingType!==P.DrawingTypeEnum.DRAWING_DOM);return h.length?(h.forEach(m=>{if(!m.groupId&&m.transform&&p.Tools.isDefine(m.transform.left)&&p.Tools.isDefine(m.transform.top)&&p.Tools.isDefine(m.transform.width)&&p.Tools.isDefine(m.transform.height)){const S=a.skeleton.getCellPositionByOffset(m.transform.left,m.transform.top,u,d,{x:0,y:0}),f=a.skeleton.getCellPositionByOffset(m.transform.left+m.transform.width,m.transform.top+m.transform.height,u,d,{x:0,y:0});S.column<l.startColumn&&(l.startColumn=S.column),S.row<l.startRow&&(l.startRow=S.row),l.endRow<f.row&&(l.endRow=f.row),l.endColumn<f.column&&(l.endColumn=f.column)}}),e(l)):e(i)}}))}};Se=Rn([p.OnLifecycle(p.LifecycleStages.Rendered,Se),fe(0,j.Inject(H.SheetPrintInterceptorService)),fe(1,j.Inject(Z.DrawingRenderService)),fe(2,P.IDrawingManagerService),fe(3,B.IRenderManagerService)],Se);var je=Object.defineProperty,On=Object.getOwnPropertyDescriptor,Pn=(i,t,e)=>t in i?je(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e,bn=(i,t,e,n)=>{for(var r=n>1?void 0:n?On(t,e):t,o=i.length-1,a;o>=0;o--)(a=i[o])&&(r=(n?a(t,e,r):a(r))||r);return n&&r&&je(t,e,r),r},Le=(i,t)=>(e,n)=>t(e,n,i),We=(i,t,e)=>(Pn(i,typeof t!="symbol"?t+"":t,e),e);const An="SHEET_IMAGE_UI_PLUGIN";O.UniverSheetsDrawingUIPlugin=class extends p.Plugin{constructor(e={},n,r){super();K(this,"_pluginConfig");this._injector=n,this._localeService=r,this._pluginConfig=p.Tools.deepMerge({},hn,e)}onStarting(e){super.onStarting(e),this._initDependencies(e)}_initDependencies(e){[[O.SheetCanvasFloatDomManagerService],[ae,{useFactory:()=>this._injector.createInstance(ae,this._pluginConfig)}],[pe],[le],[he],[Se]].forEach(r=>e.add(r))}},We(O.UniverSheetsDrawingUIPlugin,"type",p.UniverInstanceType.UNIVER_SHEET),We(O.UniverSheetsDrawingUIPlugin,"pluginName",An),O.UniverSheetsDrawingUIPlugin=bn([p.DependentOn(P.UniverDrawingPlugin,Z.UniverDrawingUIPlugin,g.UniverSheetsDrawingPlugin),Le(1,j.Inject(j.Injector)),Le(2,j.Inject(p.LocaleService))],O.UniverSheetsDrawingUIPlugin),Object.defineProperty(O,Symbol.toStringTag,{value:"Module"})});
1
+ (function(b,g){typeof exports=="object"&&typeof module<"u"?g(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"],g):(b=typeof globalThis<"u"?globalThis:b||self,g(b.UniverSheetsDrawingUi={},b.UniverCore,b["@wendellhu/redi"],b.UniverDrawingUi,b.UniverSheetsDrawing,b.UniverDrawing,b.UniverEngineRender,b.UniverSheetsUi,b.rxjs,b.UniverUi,b["@wendellhu/redi/react-bindings"],b.UniverSheets,b.React,b.UniverDesign,b.clsx))})(this,function(b,g,j,Q,h,E,U,X,B,$,z,w,O,J,ce){"use strict";var Gn=Object.defineProperty;var $n=(b,g,j)=>g in b?Gn(b,g,{enumerable:!0,configurable:!0,writable:!0,value:j}):b[g]=j;var q=(b,g,j)=>$n(b,typeof g!="symbol"?g+"":g,j);const W={id:"sheet.operation.clear-drawing-transformer",type:g.CommandType.MUTATION,handler:(r,n)=>{const i=r.get(U.IRenderManagerService);return n.forEach(e=>{var t,o;(o=(t=i.getRenderById(e))==null?void 0:t.scene.getTransformer())==null||o.debounceRefreshControls()}),!0}},_e={id:"sheet.command.remove-sheet-image",type:g.CommandType.COMMAND,handler:(r,n)=>{const i=r.get(g.ICommandService),e=r.get(g.IUndoRedoService),t=r.get(h.ISheetDrawingService);if(!n)return!1;const{drawings:o}=n,s=[];o.forEach(S=>{const{unitId:f}=S;s.push(f)});const a=t.getBatchRemoveOp(o),{unitId:c,subUnitId:u,undo:d,redo:l,objects:m}=a;return i.syncExecuteCommand(h.SetDrawingApplyMutation.id,{unitId:c,subUnitId:u,op:l,objects:m,type:h.DrawingApplyType.REMOVE})?(e.pushUndoRedo({unitID:c,undoMutations:[{id:h.SetDrawingApplyMutation.id,params:{unitId:c,subUnitId:u,op:d,objects:m,type:h.DrawingApplyType.INSERT}},{id:W.id,params:s}],redoMutations:[{id:h.SetDrawingApplyMutation.id,params:{unitId:c,subUnitId:u,op:l,objects:m,type:h.DrawingApplyType.REMOVE}},{id:W.id,params:s}]}),!0):!1}},ye="COMPONENT_SHEET_DRAWING_PANEL",De={id:"sidebar.operation.sheet-image",type:g.CommandType.COMMAND,handler:async(r,n)=>{const i=r.get($.ISidebarService),e=r.get(g.LocaleService),t=r.get(g.IUniverInstanceService),o=r.get(E.IDrawingManagerService);if(!w.getSheetCommandTarget(t))return!1;switch(n.value){case"open":i.open({header:{title:e.t("sheetImage.panel.title")},children:{label:ye},onClose:()=>{o.focusDrawing(null)},width:360});break;case"close":default:i.close();break}return!0}},Me={id:"sheet.operation.edit-sheet-image",type:g.CommandType.OPERATION,handler:(r,n)=>{const i=r.get(E.IDrawingManagerService),e=r.get(g.ICommandService);return n==null?!1:(i.focusDrawing([n]),e.executeCommand(De.id,{value:"open"}),!0)}},le={uploadLoading:"univer-upload-loading",uploadLoadingBody:"univer-upload-loading-body",uploadLoadingBodyAnimation:"univer-upload-loading-body-animation",univerCircleAnimation:"univer-UniverCircleAnimation",uploadLoadingBodyText:"univer-upload-loading-body-text"},He=()=>{const r=z.useDependency(E.IImageIoService),n=z.useDependency(g.LocaleService),[i,e]=O.useState(0);return O.useEffect(()=>{const t=r.change$.subscribe(o=>{e(o)});return()=>{t.unsubscribe()}},[r]),O.createElement("div",{style:{display:i>0?"block":"none"},className:le.uploadLoading},O.createElement("div",{className:le.uploadLoadingBody},O.createElement("div",{className:le.uploadLoadingBodyAnimation}),O.createElement("div",{className:le.uploadLoadingBodyText},`${n.t("uploadLoading.loading")}: ${i}`)))};var Ye=Object.defineProperty,Xe=Object.getOwnPropertyDescriptor,xe=(r,n,i,e)=>{for(var t=e>1?void 0:e?Xe(n,i):n,o=r.length-1,s;o>=0;o--)(s=r[o])&&(t=(e?s(n,i,t):s(t))||t);return e&&t&&Ye(n,i,t),t},ee=(r,n)=>(i,e)=>n(i,e,r);let de=class extends g.RxDisposable{constructor(n,i,e,t,o,s,a){super();q(this,"_initImagePopupMenu",new Set);this._injector=n,this._drawingManagerService=i,this._canvasPopManagerService=e,this._renderManagerService=t,this._univerInstanceService=o,this._contextService=s,this._uiPartsService=a,this._init()}_init(){this._univerInstanceService.getCurrentTypeOfUnit$(g.UniverInstanceType.UNIVER_SHEET).pipe(B.takeUntil(this.dispose$)).subscribe(n=>this._create(n)),this._univerInstanceService.getTypeOfUnitDisposed$(g.UniverInstanceType.UNIVER_SHEET).pipe(B.takeUntil(this.dispose$)).subscribe(n=>this._dispose(n)),this._univerInstanceService.getAllUnitsForType(g.UniverInstanceType.UNIVER_SHEET).forEach(n=>this._create(n)),this._uiPartsService.registerComponent($.BuiltInUIPart.CONTENT,()=>z.connectInjector(He,this._injector))}_dispose(n){const i=n.getUnitId();this._renderManagerService.removeRender(i)}_create(n){if(!n)return;const i=n.getUnitId();this._renderManagerService.has(i)&&!this._initImagePopupMenu.has(i)&&(this._popupMenuListener(i),this._initImagePopupMenu.add(i))}_hasCropObject(n){const i=n.getAllObjects();for(const e of i)if(e instanceof Q.ImageCropperObject)return!0;return!1}_popupMenuListener(n){var o;const i=(o=this._renderManagerService.getRenderById(n))==null?void 0:o.scene;if(!i)return;const e=i.getTransformerByCreate();if(!e)return;const t=[];this.disposeWithMe(g.toDisposable(e.onCreateControlObservable.add(()=>{if(this._contextService.setContextValue(g.FOCUSING_COMMON_DRAWINGS,!0),this._hasCropObject(i))return;const s=e.getSelectedObjectMap();if(s.size>1){t.forEach(p=>p.dispose());return}const a=s.values().next().value;if(!a)return;const c=a.oKey,u=this._drawingManagerService.getDrawingOKey(c);if(!u)return;const{unitId:d,subUnitId:l,drawingId:m}=u;t.push(this.disposeWithMe(this._canvasPopManagerService.attachPopupToObject(a,{componentKey:Q.COMPONENT_IMAGE_POPUP_MENU,direction:"horizontal",offset:[2,0],extraProps:{menuItems:this._getImageMenuItems(d,l,m)}}))),this._drawingManagerService.focusDrawing([{unitId:d,subUnitId:l,drawingId:m}])}))),this.disposeWithMe(g.toDisposable(e.onClearControlObservable.add(()=>{t.forEach(s=>s.dispose()),this._contextService.setContextValue(g.FOCUSING_COMMON_DRAWINGS,!1),this._drawingManagerService.focusDrawing(null)}))),this.disposeWithMe(g.toDisposable(e.onChangingObservable.add(()=>{t.forEach(s=>s.dispose())})))}_getImageMenuItems(n,i,e){return[{label:"image-popup.edit",index:0,commandId:Me.id,commandParams:{unitId:n,subUnitId:i,drawingId:e},disable:!1},{label:"image-popup.delete",index:1,commandId:_e.id,commandParams:{unitId:n,drawings:[{unitId:n,subUnitId:i,drawingId:e}]},disable:!1},{label:"image-popup.crop",index:2,commandId:Q.OpenImageCropOperation.id,commandParams:{unitId:n,subUnitId:i,drawingId:e},disable:!1},{label:"image-popup.reset",index:3,commandId:Q.ImageResetSizeOperation.id,commandParams:[{unitId:n,subUnitId:i,drawingId:e}],disable:!1}]}};de=xe([g.OnLifecycle(g.LifecycleStages.Steady,de),ee(0,j.Inject(j.Injector)),ee(1,E.IDrawingManagerService),ee(2,j.Inject(X.SheetCanvasPopManagerService)),ee(3,U.IRenderManagerService),ee(4,g.IUniverInstanceService),ee(5,g.IContextService),ee(6,j.Inject($.IUIPartsService))],de);const ue={id:"sheet.operation.insert-float-image",type:g.CommandType.OPERATION,handler:(r,n)=>!0},me={id:"sheet.operation.insert-cell-image",type:g.CommandType.OPERATION,handler:(r,n)=>!0},Ie={id:"sheet.command.insert-sheet-image",type:g.CommandType.COMMAND,handler:(r,n)=>{const i=r.get(g.ICommandService),e=r.get(g.IUndoRedoService),t=r.get(h.ISheetDrawingService);if(!n)return!1;const o=n.drawings,s=o.map(S=>S.unitId),a=t.getBatchAddOp(o),{unitId:c,subUnitId:u,undo:d,redo:l,objects:m}=a;return i.syncExecuteCommand(h.SetDrawingApplyMutation.id,{op:l,unitId:c,subUnitId:u,objects:m,type:h.DrawingApplyType.INSERT})?(e.pushUndoRedo({unitID:c,undoMutations:[{id:h.SetDrawingApplyMutation.id,params:{op:d,unitId:c,subUnitId:u,objects:m,type:h.DrawingApplyType.REMOVE}},{id:W.id,params:s}],redoMutations:[{id:h.SetDrawingApplyMutation.id,params:{op:l,unitId:c,subUnitId:u,objects:m,type:h.DrawingApplyType.INSERT}},{id:W.id,params:s}]}),!0):!1}},pe={id:"sheet.command.set-sheet-image",type:g.CommandType.COMMAND,handler:(r,n)=>{const i=r.get(g.ICommandService),e=r.get(g.IUndoRedoService),t=r.get(h.ISheetDrawingService);if(!n)return!1;const{drawings:o}=n,s=t.getBatchUpdateOp(o),{unitId:a,subUnitId:c,undo:u,redo:d,objects:l}=s;return i.syncExecuteCommand(h.SetDrawingApplyMutation.id,{unitId:a,subUnitId:c,op:d,objects:l,type:h.DrawingApplyType.UPDATE})?(e.pushUndoRedo({unitID:a,undoMutations:[{id:h.SetDrawingApplyMutation.id,params:{unitId:a,subUnitId:c,op:u,objects:l,type:h.DrawingApplyType.UPDATE}},{id:W.id,params:[a]}],redoMutations:[{id:h.SetDrawingApplyMutation.id,params:{unitId:a,subUnitId:c,op:d,objects:l,type:h.DrawingApplyType.UPDATE}},{id:W.id,params:[a]}]}),!0):!1}},Te={id:"sheet.command.set-drawing-arrange",type:g.CommandType.COMMAND,handler:(r,n)=>{const i=r.get(g.ICommandService),e=r.get(g.IUndoRedoService);if(!n)return!1;const t=r.get(h.ISheetDrawingService),{unitId:o,subUnitId:s,drawingIds:a,arrangeType:c}=n,u={unitId:o,subUnitId:s,drawingIds:a};let d;if(c===E.ArrangeTypeEnum.forward?d=t.getForwardDrawingsOp(u):c===E.ArrangeTypeEnum.backward?d=t.getBackwardDrawingOp(u):c===E.ArrangeTypeEnum.front?d=t.getFrontDrawingsOp(u):c===E.ArrangeTypeEnum.back&&(d=t.getBackDrawingsOp(u)),d==null)return!1;const{objects:l,redo:m,undo:p}=d;return i.syncExecuteCommand(h.SetDrawingApplyMutation.id,{op:m,unitId:o,subUnitId:s,objects:l,type:h.DrawingApplyType.ARRANGE})?(e.pushUndoRedo({unitID:o,undoMutations:[{id:h.SetDrawingApplyMutation.id,params:{op:p,unitId:o,subUnitId:s,objects:l,type:h.DrawingApplyType.ARRANGE}}],redoMutations:[{id:h.SetDrawingApplyMutation.id,params:{op:m,unitId:o,subUnitId:s,objects:l,type:h.DrawingApplyType.ARRANGE}}]}),!0):!1}};function ke(r){const n=[];return r.forEach(i=>{const{parent:e,children:t}=i,{unitId:o,subUnitId:s,drawingId:a}=e,c=U.getGroupState(0,0,t.map(l=>l.transform||{})),u=t.map(l=>{const m=l.transform||{left:0,top:0},{unitId:p,subUnitId:S,drawingId:f}=l;return{unitId:p,subUnitId:S,drawingId:f,transform:{...m,left:m.left-c.left,top:m.top-c.top},groupId:a}}),d={unitId:o,subUnitId:s,drawingId:a,drawingType:E.DrawingTypeEnum.DRAWING_GROUP,transform:c};n.push({parent:d,children:u})}),n}function Ke(r){const n=[];return r.forEach(i=>{const{parent:e,children:t}=i,{unitId:o,subUnitId:s,drawingId:a,transform:c={width:0,height:0}}=e;if(c==null)return;const u=t.map(l=>{const{transform:m}=l,{unitId:p,subUnitId:S,drawingId:f}=l,v=U.transformObjectOutOfGroup(m||{},c,c.width||0,c.height||0);return{unitId:p,subUnitId:S,drawingId:f,transform:v,groupId:void 0}}),d={unitId:o,subUnitId:s,drawingId:a,drawingType:E.DrawingTypeEnum.DRAWING_GROUP,transform:{left:0,top:0}};n.push({parent:d,children:u})}),n}const Re={id:"sheet.command.group-sheet-image",type:g.CommandType.COMMAND,handler:(r,n)=>{const i=r.get(g.ICommandService),e=r.get(g.IUndoRedoService),t=r.get(h.ISheetDrawingService);if(!n)return!1;const o=[];n.forEach(({parent:p,children:S})=>{o.push(p.unitId),S.forEach(f=>{o.push(f.unitId)})});const s=t.getGroupDrawingOp(n),{unitId:a,subUnitId:c,undo:u,redo:d,objects:l}=s;return i.syncExecuteCommand(h.SetDrawingApplyMutation.id,{op:d,unitId:a,subUnitId:c,objects:l,type:h.DrawingApplyType.GROUP})?(e.pushUndoRedo({unitID:a,undoMutations:[{id:h.SetDrawingApplyMutation.id,params:{op:u,unitId:a,subUnitId:c,objects:Ke(l),type:h.DrawingApplyType.UNGROUP}},{id:W.id,params:o}],redoMutations:[{id:h.SetDrawingApplyMutation.id,params:{op:d,unitId:a,subUnitId:c,objects:l,type:h.DrawingApplyType.GROUP}},{id:W.id,params:o}]}),!0):!1}},be={id:"sheet.command.ungroup-sheet-image",type:g.CommandType.COMMAND,handler:(r,n)=>{const i=r.get(g.ICommandService),e=r.get(g.IUndoRedoService),t=r.get(h.ISheetDrawingService);if(!n)return!1;const o=[];n.forEach(({parent:p,children:S})=>{o.push(p.unitId),S.forEach(f=>{o.push(f.unitId)})});const s=t.getUngroupDrawingOp(n),{unitId:a,subUnitId:c,undo:u,redo:d,objects:l}=s;return i.syncExecuteCommand(h.SetDrawingApplyMutation.id,{op:d,unitId:a,subUnitId:c,objects:l,type:h.DrawingApplyType.UNGROUP})?(e.pushUndoRedo({unitID:a,undoMutations:[{id:h.SetDrawingApplyMutation.id,params:{op:u,unitId:a,subUnitId:c,objects:ke(l),type:h.DrawingApplyType.GROUP}},{id:W.id,params:o}],redoMutations:[{id:h.SetDrawingApplyMutation.id,params:{op:d,unitId:a,subUnitId:c,objects:l,type:h.DrawingApplyType.UNGROUP}},{id:W.id,params:o}]}),!0):!1}};function H(r,n){const{from:i,to:e}=r,{column:t,columnOffset:o,row:s,rowOffset:a}=i,{column:c,columnOffset:u,row:d,rowOffset:l}=e,m=n.attachRangeWithCoord({startColumn:t,endColumn:t,startRow:s,endRow:s});if(m==null)return;const p=n.attachRangeWithCoord({startColumn:c,endColumn:c,startRow:d,endRow:d});if(p==null)return;const{startX:S,startY:f}=m,{startX:v,startY:y}=p,M=U.precisionTo(S+o,1),C=U.precisionTo(f+a,1);let T=U.precisionTo(v+u-M,1),I=U.precisionTo(y+l-C,1);return m.startX===p.endX&&(T=0),m.startY===p.endY&&(I=0),{left:M,top:C,width:T,height:I}}function G(r,n){const{left:i=0,top:e=0,width:t=0,height:o=0}=r,s=n.getSelectionCellByPosition(i,e);if(s==null)return;const a={column:s.actualColumn,columnOffset:U.precisionTo(i-s.startX,1),row:s.actualRow,rowOffset:U.precisionTo(e-s.startY,1)},c=n.getSelectionCellByPosition(i+t,e+o);if(c==null)return;const u={column:c.actualColumn,columnOffset:U.precisionTo(i+t-c.startX,1),row:c.actualRow,rowOffset:U.precisionTo(e+o-c.startY,1)};return{from:a,to:u}}var ze=Object.defineProperty,qe=Object.getOwnPropertyDescriptor,Je=(r,n,i,e)=>{for(var t=e>1?void 0:e?qe(n,i):n,o=r.length-1,s;o>=0;o--)(s=r[o])&&(t=(e?s(n,i,t):s(t))||t);return e&&t&&ze(n,i,t),t},k=(r,n)=>(i,e)=>n(i,e,r);let ge=class extends g.Disposable{constructor(r,n,i,e,t,o,s,a,c,u,d){super(),this._commandService=r,this._univerInstanceService=n,this._selectionManagerService=i,this._selectionRenderService=e,this._imageIoService=t,this._sheetDrawingService=o,this._drawingManagerService=s,this._contextService=a,this._messageService=c,this._localeService=u,this._renderManagerService=d,this._init()}_init(){this._initCommandListeners(),this._updateImageListener(),this._updateOrderListener(),this._groupDrawingListener(),this._focusDrawingListener()}_initCommandListeners(){this.disposeWithMe(this._commandService.onCommandExecuted(async r=>{if(r.id===me.id||r.id===ue.id){const n=r.params;if(n.files==null)return;const i=n.files.length;if(i>E.DRAWING_IMAGE_COUNT_LIMIT){this._messageService.show({type:J.MessageType.Error,content:this._localeService.t("update-status.exceedMaxCount",String(E.DRAWING_IMAGE_COUNT_LIMIT))});return}this._imageIoService.setWaitCount(i),r.id===me.id?n.files.forEach(async e=>{await this._insertCellImage(e)}):n.files.forEach(async e=>{await this._insertFloatImage(e)})}}))}async _insertCellImage(r){}async _insertFloatImage(r){let n;try{n=await this._imageIoService.saveImage(r)}catch(M){const C=M.message;C===E.ImageUploadStatusType.ERROR_EXCEED_SIZE?this._messageService.show({type:J.MessageType.Error,content:this._localeService.t("update-status.exceedMaxSize",String(E.DRAWING_IMAGE_ALLOW_SIZE/(1024*1024)))}):C===E.ImageUploadStatusType.ERROR_IMAGE_TYPE?this._messageService.show({type:J.MessageType.Error,content:this._localeService.t("update-status.invalidImageType")}):C===E.ImageUploadStatusType.ERROR_IMAGE&&this._messageService.show({type:J.MessageType.Error,content:this._localeService.t("update-status.invalidImage")})}if(n==null)return;const i=this._getUnitInfo();if(i==null)return;const{unitId:e,subUnitId:t}=i,{imageId:o,imageSourceType:s,source:a,base64Cache:c}=n,{width:u,height:d,image:l}=await E.getImageSize(c||""),m=this._renderManagerService.getRenderById(e);if(m==null)return;const{width:p,height:S}=m.scene;this._imageIoService.addImageSourceCache(a,s,l);let f=1;if(u>E.DRAWING_IMAGE_WIDTH_LIMIT||d>E.DRAWING_IMAGE_HEIGHT_LIMIT){const M=E.DRAWING_IMAGE_WIDTH_LIMIT/u,C=E.DRAWING_IMAGE_HEIGHT_LIMIT/d;f=Math.max(M,C)}const v=this._getImagePosition(u*f,d*f,p,S);if(v==null)return;const y={unitId:e,subUnitId:t,drawingId:o,drawingType:E.DrawingTypeEnum.DRAWING_IMAGE,imageSourceType:s,source:a,transform:H(v,this._selectionRenderService),sheetTransform:v};this._commandService.executeCommand(Ie.id,{unitId:e,drawings:[y]})}_getUnitInfo(){const r=this._univerInstanceService.getCurrentUnitForType(g.UniverInstanceType.UNIVER_SHEET);if(r==null)return;const n=r.getActiveSheet();if(n==null)return;const i=r.getUnitId(),e=n.getSheetId();return{unitId:i,subUnitId:e}}_getImagePosition(r,n,i,e){const t=this._selectionManagerService.getSelections();let o={startRow:0,endRow:0,startColumn:0,endColumn:0};t&&t.length>0&&(o=t[t.length-1].range);const s=this._selectionRenderService.attachRangeWithCoord(o);if(s==null)return;let{startColumn:a,startRow:c,startX:u,startY:d}=s,l=!1;if(u+r>i&&(u=i-r,u<0&&(u=0,r=i),l=!0),d+n>e&&(d=e-n,d<0&&(d=0,n=e),l=!0),l){const f=this._selectionRenderService.getSelectionCellByPosition(u,d);if(f==null)return;u=f.startX,d=f.startY,a=f.actualColumn,c=f.actualRow}const m={column:a,columnOffset:0,row:c,rowOffset:0},p=this._selectionRenderService.getSelectionCellByPosition(u+r,d+n);if(p==null)return;const S={column:p.actualColumn,columnOffset:u+r-p.startX,row:p.actualRow,rowOffset:d+n-p.startY};return{from:m,to:S}}_updateOrderListener(){this._drawingManagerService.featurePluginOrderUpdate$.subscribe(r=>{const{unitId:n,subUnitId:i,drawingIds:e,arrangeType:t}=r;this._commandService.executeCommand(Te.id,{unitId:n,subUnitId:i,drawingIds:e,arrangeType:t})})}_updateImageListener(){this._drawingManagerService.featurePluginUpdate$.subscribe(r=>{const n=[];r.length!==0&&(r.forEach(i=>{const{unitId:e,subUnitId:t,drawingId:o,drawingType:s,transform:a}=i;if(a==null)return;const c=this._sheetDrawingService.getDrawingByParam({unitId:e,subUnitId:t,drawingId:o});if(c==null)return;const u=G({...c.transform,...a},this._selectionRenderService);if(u==null)return;const d={...i,transform:{...c.transform,...a,...H(u,this._selectionRenderService)},sheetTransform:{...u}};n.push(d)}),n.length>0&&this._commandService.executeCommand(pe.id,{unitId:r[0].unitId,drawings:n}))})}_groupDrawingListener(){this._drawingManagerService.featurePluginGroupUpdate$.subscribe(r=>{this._commandService.executeCommand(Re.id,r);const{unitId:n,subUnitId:i,drawingId:e}=r[0].parent;this._drawingManagerService.focusDrawing([{unitId:n,subUnitId:i,drawingId:e}])}),this._drawingManagerService.featurePluginUngroupUpdate$.subscribe(r=>{this._commandService.executeCommand(be.id,r)})}_focusDrawingListener(){this.disposeWithMe(this._drawingManagerService.focus$.subscribe(r=>{r==null||r.length===0?(this._contextService.setContextValue(g.FOCUSING_COMMON_DRAWINGS,!1),this._sheetDrawingService.focusDrawing([])):(this._contextService.setContextValue(g.FOCUSING_COMMON_DRAWINGS,!0),this._sheetDrawingService.focusDrawing(r))}))}};ge=Je([g.OnLifecycle(g.LifecycleStages.Rendered,ge),k(0,g.ICommandService),k(1,g.IUniverInstanceService),k(2,j.Inject(w.SelectionManagerService)),k(3,X.ISelectionRenderService),k(4,E.IImageIoService),k(5,h.ISheetDrawingService),k(6,E.IDrawingManagerService),k(7,g.IContextService),k(8,$.IMessageService),k(9,j.Inject(g.LocaleService)),k(10,U.IRenderManagerService)],ge);var x=function(){return x=Object.assign||function(r){for(var n,i=1,e=arguments.length;i<e;i++){n=arguments[i];for(var t in n)Object.prototype.hasOwnProperty.call(n,t)&&(r[t]=n[t])}return r},x.apply(this,arguments)},Ze=function(r,n){var i={};for(var e in r)Object.prototype.hasOwnProperty.call(r,e)&&n.indexOf(e)<0&&(i[e]=r[e]);if(r!=null&&typeof Object.getOwnPropertySymbols=="function")for(var t=0,e=Object.getOwnPropertySymbols(r);t<e.length;t++)n.indexOf(e[t])<0&&Object.prototype.propertyIsEnumerable.call(r,e[t])&&(i[e[t]]=r[e[t]]);return i},Ee=O.forwardRef(function(r,n){var i=r.icon,e=r.id,t=r.className,o=r.extend,s=Ze(r,["icon","id","className","extend"]),a="univerjs-icon univerjs-icon-".concat(e," ").concat(t||"").trim(),c=O.useRef("_".concat(nn()));return Pe(i,"".concat(e),{defIds:i.defIds,idSuffix:c.current},x({ref:n,className:a},s),o)});function Pe(r,n,i,e,t){return O.createElement(r.tag,x(x({key:n},Qe(r,i,t)),e),(en(r,i).children||[]).map(function(o,s){return Pe(o,"".concat(n,"-").concat(r.tag,"-").concat(s),i,void 0,t)}))}function Qe(r,n,i){var e=x({},r.attrs);i!=null&&i.colorChannel1&&e.fill==="colorChannel1"&&(e.fill=i.colorChannel1);var t=n.defIds;return!t||t.length===0||(r.tag==="use"&&e["xlink:href"]&&(e["xlink:href"]=e["xlink:href"]+n.idSuffix),Object.entries(e).forEach(function(o){var s=o[0],a=o[1];typeof a=="string"&&(e[s]=a.replace(/url\(#(.*)\)/,"url(#$1".concat(n.idSuffix,")")))})),e}function en(r,n){var i,e=n.defIds;return!e||e.length===0?r:r.tag==="defs"&&(!((i=r.children)===null||i===void 0)&&i.length)?x(x({},r),{children:r.children.map(function(t){return typeof t.attrs.id=="string"&&e&&e.indexOf(t.attrs.id)>-1?x(x({},t),{attrs:x(x({},t.attrs),{id:t.attrs.id+n.idSuffix})}):t})}):r}function nn(){return Math.random().toString(36).substring(2,8)}Ee.displayName="UniverIcon";var tn={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"}}]},Oe=O.forwardRef(function(r,n){return O.createElement(Ee,Object.assign({},r,{id:"add-image-single",ref:n,icon:tn}))});Oe.displayName="AddImageSingle";const Ae={uploadFileMenu:"univer-upload-file-menu",uploadFileMenuInput:"univer-upload-file-menu-input"},Ue="COMPONENT_UPLOAD_FILE_MENU";var he=(r=>(r[r.cellImage=0]="cellImage",r[r.floatImage=1]="floatImage",r))(he||{});const rn=r=>{const{type:n}=r,i=z.useDependency(g.ICommandService),e=O.useRef(null),t=()=>{var a;(a=e.current)==null||a.click()},o=E.DRAWING_IMAGE_ALLOW_IMAGE_LIST.map(a=>`.${a.replace("image/","")}`).join(","),s=a=>{const c=a.target.files;if(c==null)return;const u=Array.from(c);n===he.floatImage?i.executeCommand(ue.id,{files:u}):n===he.cellImage&&i.executeCommand(me.id,{files:u}),e.current&&(e.current.value="")};return O.createElement("div",{onClick:t,className:Ae.uploadFileMenu},O.createElement("input",{type:"file",className:Ae.uploadFileMenuInput,ref:e,onChange:s,accept:o,multiple:!0}))},Ne="addition-and-subtraction-single",Le="sheet.menu.image";function on(r){return{id:Le,type:$.MenuItemType.SUBITEMS,positions:[$.MenuPosition.TOOLBAR_START],group:$.MenuGroup.TOOLBAR_FORMULAS_INSERT,icon:Ne,tooltip:"sheetImage.title",hidden$:$.getMenuHiddenObservable(r,g.UniverInstanceType.UNIVER_SHEET),disabled$:X.getCurrentRangeDisable$(r,{workbookTypes:[w.WorkbookEditablePermission],worksheetTypes:[w.WorksheetEditPermission],rangeTypes:[w.RangeProtectionPermissionEditPoint]})}}function sn(r){return{id:ue.id,title:"sheetImage.upload.float",type:$.MenuItemType.SELECTOR,label:{name:Ue,props:{type:he.floatImage}},positions:[Le],hidden$:$.getMenuHiddenObservable(r,g.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",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"},an=r=>{var C;const n=z.useDependency(g.ICommandService),i=z.useDependency(g.LocaleService),e=z.useDependency(E.IDrawingManagerService),t=z.useDependency(U.IRenderManagerService),{drawings:o}=r,s=o[0];if(s==null)return;const{unitId:a}=s,c=t.getRenderById(a),u=c==null?void 0:c.scene;if(u==null)return;const d=u.getTransformerByCreate(),[l,m]=O.useState(!0),p=(C=s.anchorType)!=null?C:h.SheetDrawingAnchorType.Position,[S,f]=O.useState(p);function v(T,I){const P=[];return T.forEach(_=>{const{oKey:L}=_,R=I.getDrawingOKey(L);if(R==null)return P.push(null),!0;const{unitId:F,subUnitId:N,drawingId:A,drawingType:D,anchorType:V,sheetTransform:K}=R;P.push({unitId:F,subUnitId:N,drawingId:A,anchorType:V,sheetTransform:K,drawingType:D})}),P}O.useEffect(()=>{const T=d.onClearControlObservable.add(P=>{P===!0&&m(!1)}),I=d.onChangeStartObservable.add(P=>{var R;const{objects:_}=P,L=v(_,e);if(L.length===0)m(!1);else if(L.length>=1){m(!0);const F=((R=L[0])==null?void 0:R.anchorType)||h.SheetDrawingAnchorType.Position;f(F)}});return()=>{I==null||I.dispose(),T==null||T.dispose()}},[]);function y(T){f(T);const I=e.getFocusDrawings();if(I.length===0)return;const P=I.map(_=>({unitId:_.unitId,subUnitId:_.subUnitId,drawingId:_.drawingId,anchorType:T}));n.executeCommand(pe.id,{unitId:I[0].unitId,drawings:P})}const M=T=>T?"block":"none";return O.createElement("div",{className:ce(Z.imageCommonPanelGrid,Z.imageCommonPanelBorder),style:{display:M(l)}},O.createElement("div",{className:Z.imageCommonPanelRow},O.createElement("div",{className:ce(Z.imageCommonPanelColumn,Z.imageCommonPanelTitle)},O.createElement("div",null,i.t("drawing-anchor.title")))),O.createElement("div",{className:ce(Z.imageCommonPanelRow)},O.createElement("div",{className:ce(Z.imageCommonPanelColumn)},O.createElement(J.RadioGroup,{value:S,onChange:y,direction:"vertical"},O.createElement(J.Radio,{value:h.SheetDrawingAnchorType.Both},i.t("drawing-anchor.both")),O.createElement(J.Radio,{value:h.SheetDrawingAnchorType.Position},i.t("drawing-anchor.position")),O.createElement(J.Radio,{value:h.SheetDrawingAnchorType.None},i.t("drawing-anchor.none"))))))},cn=()=>{const r=z.useDependency(E.IDrawingManagerService),n=r.getFocusDrawings();if(n==null||n.length===0)return;const[i,e]=O.useState(n);return O.useEffect(()=>{const t=r.focus$.subscribe(o=>{e(o)});return()=>{t.unsubscribe()}},[]),O.createElement("div",{className:Z.imageCommonPanel},O.createElement(Q.DrawingCommonPanel,{drawings:i}),O.createElement(an,{drawings:i}))},ie={id:"sheet.command.move-drawing",type:g.CommandType.COMMAND,handler:(r,n)=>{const i=r.get(g.ICommandService),e=r.get(h.ISheetDrawingService),t=r.get(X.ISelectionRenderService),{direction:o}=n,s=e.getFocusDrawings();if(s.length===0)return!1;const a=s[0].unitId,c=s.map(d=>{const{transform:l}=d;if(l==null)return null;const m={...l},{left:p=0,top:S=0}=l;return o===g.Direction.UP?m.top=S-1:o===g.Direction.DOWN?m.top=S+1:o===g.Direction.LEFT?m.left=p-1:o===g.Direction.RIGHT&&(m.left=p+1),{...d,transform:m,sheetTransform:G(m,t)}}).filter(d=>d!=null);return i.syncExecuteCommand(pe.id,{unitId:a,drawings:c})?(i.syncExecuteCommand(W.id,[a]),!0):!1}},je={id:"sheet.command.delete-drawing",type:g.CommandType.COMMAND,handler:r=>{const n=r.get(g.ICommandService),e=r.get(h.ISheetDrawingService).getFocusDrawings();if(e.length===0)return!1;const t=e[0].unitId,o=e.map(s=>{const{unitId:a,subUnitId:c,drawingId:u,drawingType:d}=s;return{unitId:a,subUnitId:c,drawingId:u,drawingType:d}});return n.executeCommand(_e.id,{unitId:t,drawings:o})}};function re(r){return!r.getContextValue(g.FOCUSING_FORMULA_EDITOR)&&!r.getContextValue(g.EDITOR_ACTIVATED)&&r.getContextValue(g.FOCUSING_COMMON_DRAWINGS)}const ln={id:ie.id,description:"shortcut.sheet.drawing-move-down",group:"4_sheet-drawing-view",binding:$.KeyCode.ARROW_DOWN,priority:100,preconditions:re,staticParameters:{direction:g.Direction.DOWN}},dn={id:ie.id,description:"shortcut.sheet.drawing-move-up",group:"4_sheet-drawing-view",binding:$.KeyCode.ARROW_UP,priority:100,preconditions:re,staticParameters:{direction:g.Direction.UP}},un={id:ie.id,description:"shortcut.sheet.drawing-move-left",group:"4_sheet-drawing-view",binding:$.KeyCode.ARROW_LEFT,priority:100,preconditions:re,staticParameters:{direction:g.Direction.LEFT}},mn={id:ie.id,description:"shortcut.sheet.drawing-move-right",group:"4_sheet-drawing-view",binding:$.KeyCode.ARROW_RIGHT,priority:100,preconditions:re,staticParameters:{direction:g.Direction.RIGHT}},pn={id:je.id,description:"shortcut.sheet.drawing-delete",group:"4_sheet-drawing-view",preconditions:re,binding:$.KeyCode.DELETE,mac:$.KeyCode.BACKSPACE};var gn=Object.defineProperty,hn=Object.getOwnPropertyDescriptor,fn=(r,n,i,e)=>{for(var t=e>1?void 0:e?hn(n,i):n,o=r.length-1,s;o>=0;o--)(s=r[o])&&(t=(e?s(n,i,t):s(t))||t);return e&&t&&gn(n,i,t),t},oe=(r,n)=>(i,e)=>n(i,e,r);const Sn={};let se=class extends g.Disposable{constructor(r,n,i,e,t,o){super(),this._config=r,this._injector=n,this._componentManager=i,this._menuService=e,this._commandService=t,this._shortcutService=o,this._init()}_initCustomComponents(){const r=this._componentManager;this.disposeWithMe(r.register(Ne,Oe)),this.disposeWithMe(r.register(Ue,rn)),this.disposeWithMe(r.register(ye,cn))}_initMenus(){const{menu:r={}}=this._config;[on,sn].forEach(n=>{this._menuService.addMenuItem(n(this._injector),r)})}_initCommands(){[ue,me,Ie,_e,pe,De,W,Me,Re,be,ie,je,Te].forEach(r=>this.disposeWithMe(this._commandService.registerCommand(r)))}_initShortcuts(){[ln,dn,un,mn,pn].forEach(r=>{this.disposeWithMe(this._shortcutService.registerShortcut(r))})}_init(){this._initCommands(),this._initCustomComponents(),this._initMenus(),this._initShortcuts()}};se=fn([g.OnLifecycle(g.LifecycleStages.Rendered,se),oe(1,j.Inject(j.Injector)),oe(2,j.Inject($.ComponentManager)),oe(3,$.IMenuService),oe(4,g.ICommandService),oe(5,$.IShortcutService)],se);var vn=Object.defineProperty,wn=Object.getOwnPropertyDescriptor,_n=(r,n,i,e)=>{for(var t=e>1?void 0:e?wn(n,i):n,o=r.length-1,s;o>=0;o--)(s=r[o])&&(t=(e?s(n,i,t):s(t))||t);return e&&t&&vn(n,i,t),t},te=(r,n)=>(i,e)=>n(i,e,r);const In=[w.InsertRowCommand.id,w.InsertColCommand.id,w.RemoveRowCommand.id,w.RemoveColCommand.id,w.DeleteRangeMoveLeftCommand.id,w.DeleteRangeMoveUpCommand.id,w.InsertRangeMoveDownCommand.id,w.InsertRangeMoveRightCommand.id,w.DeltaRowHeightCommand.id,w.SetRowHeightCommand.id,w.DeltaColumnWidthCommand.id,w.SetColWidthCommand.id,w.SetRowHiddenCommand.id,w.SetSpecificRowsVisibleCommand.id,w.SetSpecificColsVisibleCommand.id,w.SetColHiddenCommand.id],Cn=[w.SetRowVisibleMutation.id,w.SetRowHiddenMutation.id,w.SetColVisibleMutation.id,w.SetColHiddenMutation.id,w.SetWorksheetRowHeightMutation.id,w.SetWorksheetColWidthMutation.id];let fe=class extends g.Disposable{constructor(r,n,i,e,t,o){super(),this._commandService=r,this._sheetInterceptorService=n,this._sheetDrawingService=i,this._drawingManagerService=e,this._selectionRenderService=t,this._univerInstanceService=o,this._init()}_init(){this._sheetInterceptorListener(),this._commandListener(),this._sheetRefreshListener()}_sheetInterceptorListener(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:r=>{if(!In.includes(r.id))return{redos:[],undos:[]};if(r.params==null)return{redos:[],undos:[]};const n=r.id;if(n===w.InsertRowCommand.id)return this._moveRowInterceptor(r.params,"insert");if(n===w.InsertColCommand.id)return this._moveColInterceptor(r.params,"insert");if(n===w.RemoveRowCommand.id)return this._moveRowInterceptor(r.params,"remove");if(n===w.RemoveColCommand.id)return this._moveColInterceptor(r.params,"remove");if(n===w.DeleteRangeMoveLeftCommand.id){const{range:i}=r.params;return this._getRangeMoveUndo(i,0)}else if(n===w.DeleteRangeMoveUpCommand.id){const{range:i}=r.params;return this._getRangeMoveUndo(i,1)}else if(n===w.InsertRangeMoveDownCommand.id){const{range:i}=r.params;return this._getRangeMoveUndo(i,2)}else if(n===w.InsertRangeMoveRightCommand.id){const{range:i}=r.params;return this._getRangeMoveUndo(i,3)}else if(n===w.SetRowHiddenCommand.id||n===w.SetSpecificRowsVisibleCommand.id){const i=r.params,{unitId:e,subUnitId:t,ranges:o}=i;return this._getDrawingUndoForRowVisible(e,t,o)}else if(n===w.SetSpecificColsVisibleCommand.id||n===w.SetColHiddenCommand.id){const i=r.params,{unitId:e,subUnitId:t,ranges:o}=i;return this._getDrawingUndoForColVisible(e,t,o)}else if(n===w.DeltaRowHeightCommand.id||n===w.SetRowHeightCommand.id||n===w.DeltaColumnWidthCommand.id||n===w.SetColWidthCommand.id){const i=r.params,{unitId:e,subUnitId:t,ranges:o}=i,s=n===w.DeltaRowHeightCommand.id||n===w.SetRowHeightCommand.id;return this._getDrawingUndoForRowAndColSize(e,t,o,s)}return{redos:[],undos:[]}}}))}_getRangeMoveUndo(r,n){const i=w.getSheetCommandTarget(this._univerInstanceService);if(i==null)return{redos:[],undos:[]};const e=i.unitId,t=i.subUnitId,o=[],s=[],a=this._sheetDrawingService.getDrawingData(e,t),c=[],u=[];if(Object.keys(a).forEach(d=>{const l=a[d],{updateDrawings:m,deleteDrawings:p}=this._getUpdateOrDeleteDrawings(r,n,l);c.push(...m),u.push(...p)}),c.length===0&&u.length===0)return{redos:[],undos:[]};if(c.length>0){const d=this._sheetDrawingService.getBatchUpdateOp(c),{undo:l,redo:m,objects:p}=d;o.push({id:h.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:m,objects:p,type:h.DrawingApplyType.UPDATE}}),s.push({id:h.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:l,objects:p,type:h.DrawingApplyType.UPDATE}})}if(u.length>0){const d=this._sheetDrawingService.getBatchRemoveOp(u),l=d.undo,m=d.redo,p=d.objects;o.push({id:h.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:m,objects:p,type:h.DrawingApplyType.REMOVE}}),s.push({id:h.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:l,objects:p,type:h.DrawingApplyType.INSERT}})}return o.push({id:W.id,params:[e]}),s.push({id:W.id,params:[e]}),{redos:o,undos:s}}_getUpdateOrDeleteDrawings(r,n,i){const e=[],t=[],{sheetTransform:o,anchorType:s=h.SheetDrawingAnchorType.Position,transform:a,unitId:c,subUnitId:u,drawingId:d}=i,{from:l,to:m}=o,{row:p,column:S}=l,{row:f,column:v}=m;if(o==null||a==null)return{updateDrawings:e,deleteDrawings:t};const{startRow:y,endRow:M,startColumn:C,endColumn:T}=r;let I=null,P=null;if(n===0&&p>=y&&f<=M)if(S>=C&&v<=T)t.push({unitId:c,subUnitId:u,drawingId:d});else{const _=this._shrinkCol(o,a,C,T,s);I=_==null?void 0:_.newSheetTransform,P=_==null?void 0:_.newTransform}else if(n===1&&S>=C&&v<=T)if(p>=y&&f<=M)t.push({unitId:c,subUnitId:u,drawingId:d});else{const _=this._shrinkRow(o,a,y,M,s);I=_==null?void 0:_.newSheetTransform,P=_==null?void 0:_.newTransform}else if(n===2){const _=this._expandRow(o,a,y,M,s);I=_==null?void 0:_.newSheetTransform,P=_==null?void 0:_.newTransform}else if(n===3){const _=this._expandCol(o,a,C,T,s);I=_==null?void 0:_.newSheetTransform,P=_==null?void 0:_.newTransform}if(I!=null&&P!=null){const _=H(I,this._selectionRenderService);e.push({...i,sheetTransform:I,transform:_})}return{updateDrawings:e,deleteDrawings:t}}_remainDrawingSize(r,n,i){const e=G({...r},this._selectionRenderService);e!=null&&n.push({...i,sheetTransform:e})}_getDrawingUndoForColVisible(r,n,i){const e=this._drawingManagerService.getDrawingData(r,n),t=[],o=[];if(Object.keys(e).forEach(d=>{const l=e[d],{sheetTransform:m,transform:p,anchorType:S=h.SheetDrawingAnchorType.Position}=l;if(S===h.SheetDrawingAnchorType.None)this._remainDrawingSize(p,t,l);else{const{from:f,to:v}=m,{row:y,column:M}=f,{row:C,column:T}=v;for(let I=0;I<i.length;I++){const P=i[I],{startRow:_,endRow:L,startColumn:R,endColumn:F}=P;if(T<R)continue;if(S===h.SheetDrawingAnchorType.Position){let D=null,V=null;if(M>=R&&M<=F){const K=this._selectionRenderService.attachRangeWithCoord({startColumn:M,endColumn:F,startRow:f.row,endRow:v.row});if(K==null)return;V={...p,left:K.startX}}if(V!=null&&(D=G(V,this._selectionRenderService),D!=null&&V!=null)){t.push({...l,sheetTransform:D,transform:V});break}this._remainDrawingSize(p,t,l);continue}if(M>=R&&T<=F)continue;let N=null,A=null;if(M>=R&&M<=F){const D=this._selectionRenderService.attachRangeWithCoord({startColumn:M,endColumn:F,startRow:f.row,endRow:v.row});if(D==null)return;A={...p,left:(D==null?void 0:D.startX)||0,width:((p==null?void 0:p.width)||0)-D.endX+D.startX}}else if(T>=R&&T<=F){const D=this._selectionRenderService.attachRangeWithCoord({startColumn:R,endColumn:T,startRow:f.row,endRow:v.row});if(D==null)return;A={...p,left:D.startX-((p==null?void 0:p.width)||0)}}else{const D=this._selectionRenderService.attachRangeWithCoord({startColumn:R,endColumn:F,startRow:f.row,endRow:v.row});if(D==null)return;if(A={...p,width:((p==null?void 0:p.width)||0)-D.endX+D.startX},N=G(A,this._selectionRenderService),N!=null&&A!=null){o.push({...l,sheetTransform:N,transform:A});break}}if(A!=null&&(N=G(A,this._selectionRenderService)),A!=null&&N!=null){t.push({...l,sheetTransform:N,transform:A});break}else this._remainDrawingSize(p,t,l)}}}),t.length===0&&o.length===0)return{redos:[],undos:[]};const{redos:s,undos:a}=this._createUndoAndRedoMutation(r,n,t),c=[],u=[];if(o.length>0){const{redos:d,undos:l}=this._createUndoAndRedoMutation(r,n,o);c.push(...d),u.push(...l)}return{redos:s,undos:a,preRedos:c,preUndos:u}}_createUndoAndRedoMutation(r,n,i){const e=this._sheetDrawingService.getBatchUpdateOp(i),{undo:t,redo:o,objects:s}=e,a=[{id:h.SetDrawingApplyMutation.id,params:{unitId:r,subUnitId:n,op:o,objects:s,type:h.DrawingApplyType.UPDATE}},{id:W.id,params:[r]}],c=[{id:h.SetDrawingApplyMutation.id,params:{unitId:r,subUnitId:n,op:t,objects:s,type:h.DrawingApplyType.UPDATE}},{id:W.id,params:[r]}];return{redos:a,undos:c}}_getDrawingUndoForRowVisible(r,n,i){const e=this._drawingManagerService.getDrawingData(r,n),t=[],o=[];if(Object.keys(e).forEach(d=>{const l=e[d],{sheetTransform:m,transform:p,anchorType:S=h.SheetDrawingAnchorType.Position}=l;if(S===h.SheetDrawingAnchorType.None)this._remainDrawingSize(p,t,l);else{const{from:f,to:v}=m,{row:y,column:M}=f,{row:C,column:T}=v;for(let I=0;I<i.length;I++){const P=i[I],{startRow:_,endRow:L,startColumn:R,endColumn:F}=P;if(C<_)continue;if(S===h.SheetDrawingAnchorType.Position){let D=null,V=null;if(y>=_&&y<=L){const K=this._selectionRenderService.attachRangeWithCoord({startColumn:f.column,endColumn:v.column,startRow:y,endRow:L});if(K==null)return;V={...p,top:K.startY}}if(V!=null&&(D=G(V,this._selectionRenderService),D!=null&&V!=null)){t.push({...l,sheetTransform:D,transform:V});break}this._remainDrawingSize(p,t,l);continue}if(y>=_&&C<=L)continue;let N=null,A=null;if(y>=_&&y<=L){const D=this._selectionRenderService.attachRangeWithCoord({startColumn:f.column,endColumn:v.column,startRow:y,endRow:L});if(D==null)return;A={...p,top:(D==null?void 0:D.startY)||0,height:((p==null?void 0:p.height)||0)-D.endY+D.startY}}else if(C>=_&&C<=L){const D=this._selectionRenderService.attachRangeWithCoord({startColumn:f.column,endColumn:v.column,startRow:_,endRow:C});if(D==null)return;A={...p,top:D.startY-((p==null?void 0:p.height)||0)}}else{const D=this._selectionRenderService.attachRangeWithCoord({startColumn:f.column,endColumn:v.column,startRow:_,endRow:L});if(D==null)return;if(A={...p,height:((p==null?void 0:p.height)||0)-D.endY+D.startY},N=G(A,this._selectionRenderService),N!=null&&A!=null){o.push({...l,sheetTransform:N,transform:A});break}}if(A!=null&&(N=G(A,this._selectionRenderService)),A!=null&&N!=null){t.push({...l,sheetTransform:N,transform:A});break}else this._remainDrawingSize(p,t,l)}}}),t.length===0&&o.length===0)return{redos:[],undos:[]};const{redos:s,undos:a}=this._createUndoAndRedoMutation(r,n,t),c=[],u=[];if(o.length>0){const{redos:d,undos:l}=this._createUndoAndRedoMutation(r,n,o);c.push(...d),u.push(...l)}return{redos:s,undos:a,preRedos:c,preUndos:u}}_getDrawingUndoForRowAndColSize(r,n,i,e){const t=this._drawingManagerService.getDrawingData(r,n),o=[];return Object.keys(t).forEach(s=>{const a=t[s],{sheetTransform:c,transform:u,anchorType:d=h.SheetDrawingAnchorType.Position}=a;if(d===h.SheetDrawingAnchorType.None)this._remainDrawingSize(u,o,a);else{const{from:l,to:m}=c,{row:p,column:S}=l,{row:f,column:v}=m;for(let y=0;y<i.length;y++){const M=i[y],{startRow:C,endRow:T,startColumn:I,endColumn:P}=M;if(f<C||v<I)continue;if(d===h.SheetDrawingAnchorType.Position&&(p<=C&&f>=T||S<=I&&v>=P)){this._remainDrawingSize(u,o,a);continue}const _=H({...c},this._selectionRenderService);if(_!=null){o.push({...a,transform:_});break}}}}),o.length===0?{redos:[],undos:[]}:this._createUndoAndRedoMutation(r,n,o)}_getUnitIdAndSubUnitId(r,n){let i,e;if(n==="insert")i=r.unitId,e=r.subUnitId;else{const t=w.getSheetCommandTarget(this._univerInstanceService);if(t==null)return;i=t.unitId,e=t.subUnitId}return{unitId:i,subUnitId:e}}_moveRowInterceptor(r,n){const i=this._getUnitIdAndSubUnitId(r,n);if(i==null)return{redos:[],undos:[]};const{unitId:e,subUnitId:t}=i,{range:o}=r,s=o.startRow,a=o.endRow,c=[],u=[],d=this._sheetDrawingService.getDrawingData(e,t),l=[],m=[];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(n==="insert"){const I=this._expandRow(f,v,s,a,y);M=I==null?void 0:I.newSheetTransform,C=I==null?void 0:I.newTransform}else{const{from:I,to:P}=f,{row:_}=I,{row:L}=P;if(_>=s&&L<=a)m.push({unitId:e,subUnitId:t,drawingId:p});else{const R=this._shrinkRow(f,v,s,a,y);M=R==null?void 0:R.newSheetTransform,C=R==null?void 0:R.newTransform}}if(!M||!C)return;const T={unitId:e,subUnitId:t,drawingId:p,transform:C,sheetTransform:M};l.push(T)}),l.length===0&&m.length===0)return{redos:[],undos:[]};if(l.length>0){const p=this._sheetDrawingService.getBatchUpdateOp(l),{undo:S,redo:f,objects:v}=p;c.push({id:h.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:f,objects:v,type:h.DrawingApplyType.UPDATE}}),u.push({id:h.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:S,objects:v,type:h.DrawingApplyType.UPDATE}})}if(m.length>0){const p=this._sheetDrawingService.getBatchRemoveOp(m),S=p.undo,f=p.redo,v=p.objects;c.push({id:h.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:f,objects:v,type:h.DrawingApplyType.REMOVE}}),u.push({id:h.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:S,objects:v,type:h.DrawingApplyType.INSERT}})}return c.push({id:W.id,params:[e]}),u.push({id:W.id,params:[e]}),{redos:c,undos:u}}_moveColInterceptor(r,n){const i=this._getUnitIdAndSubUnitId(r,n);if(i==null)return{redos:[],undos:[]};const{unitId:e,subUnitId:t}=i,{range:o}=r,s=o.startColumn,a=o.endColumn,c=[],u=[],d=this._sheetDrawingService.getDrawingData(e,t),l=[],m=[];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(n==="insert"){const I=this._expandCol(f,v,s,a,y);M=I==null?void 0:I.newSheetTransform,C=I==null?void 0:I.newTransform}else{const{from:I,to:P}=f,{column:_}=I,{column:L}=P;if(_>=s&&L<=a)m.push({unitId:e,subUnitId:t,drawingId:p});else{const R=this._shrinkCol(f,v,s,a,y);M=R==null?void 0:R.newSheetTransform,C=R==null?void 0:R.newTransform}}if(!M||!C)return;const T={unitId:e,subUnitId:t,drawingId:p,transform:C,sheetTransform:M};l.push(T)}),l.length===0&&m.length===0)return{redos:[],undos:[]};if(l.length>0){const p=this._sheetDrawingService.getBatchUpdateOp(l),{undo:S,redo:f,objects:v}=p;c.push({id:h.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:f,objects:v,type:h.DrawingApplyType.UPDATE}}),u.push({id:h.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:S,objects:v,type:h.DrawingApplyType.UPDATE}})}if(m.length>0){const p=this._sheetDrawingService.getBatchRemoveOp(m),S=p.undo,f=p.redo,v=p.objects;c.push({id:h.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:f,objects:v,type:h.DrawingApplyType.REMOVE}}),u.push({id:h.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:S,objects:v,type:h.DrawingApplyType.INSERT}})}return c.push({id:W.id,params:[e]}),u.push({id:W.id,params:[e]}),{redos:c,undos:u}}_expandCol(r,n,i,e,t=h.SheetDrawingAnchorType.Position){const o=e-i+1,{from:s,to:a}=r,{column:c}=s,{column:u}=a;if(t===h.SheetDrawingAnchorType.None)return{newSheetTransform:G({...n},this._selectionRenderService),newTransform:n};let d=null,l=null;if(c>=i){const m=this._selectionRenderService.attachRangeWithCoord({startColumn:i,endColumn:e,startRow:s.row,endRow:a.row});if(m==null)return;l={...n,left:(n.left||0)+m.endX-m.startX},d=G(l,this._selectionRenderService)}else if(u>=e)if(t===h.SheetDrawingAnchorType.Both)d={from:{...s},to:{...a,column:u+o}},l=H(d,this._selectionRenderService);else return{newSheetTransform:G({...n},this._selectionRenderService),newTransform:n};return d!=null&&l!=null?{newSheetTransform:d,newTransform:l}:null}_shrinkCol(r,n,i,e,t=h.SheetDrawingAnchorType.Position){const o=e-i+1,{from:s,to:a}=r,{column:c}=s,{column:u}=a;if(t===h.SheetDrawingAnchorType.None)return{newSheetTransform:G({...n},this._selectionRenderService),newTransform:n};let d=null,l=null;if(c>e)d={from:{...s,column:c-o},to:{...a,column:u-o}},l=H(d,this._selectionRenderService);else{if(c>=i&&u<=e)return null;if(c<i&&u>e)if(t===h.SheetDrawingAnchorType.Both)d={from:{...s},to:{...a,column:u-o}},l=H(d,this._selectionRenderService);else return{newSheetTransform:G({...n},this._selectionRenderService),newTransform:n};else if(c>=i&&c<=e){if(c===i)l={...n,left:(n.left||0)-r.from.columnOffset};else{const m=this._selectionRenderService.attachRangeWithCoord({startColumn:i,endColumn:c-1,startRow:s.row,endRow:a.row});if(m==null)return;l={...n,left:(n.left||0)-m.endX+m.startX-r.from.columnOffset}}d=G(l,this._selectionRenderService)}else if(u>=i&&u<=e&&t===h.SheetDrawingAnchorType.Both){const m=this._selectionRenderService.attachRangeWithCoord({startColumn:i-1,endColumn:i-1,startRow:s.row,endRow:a.row});if(m==null)return;d={from:{...s},to:{...a,column:i-1,columnOffset:m.endX-m.startX}},l=H(d,this._selectionRenderService)}}return d!=null&&l!=null?{newSheetTransform:d,newTransform:l}:null}_expandRow(r,n,i,e,t=h.SheetDrawingAnchorType.Position){const o=e-i+1,{from:s,to:a}=r,{row:c}=s,{row:u}=a;if(t===h.SheetDrawingAnchorType.None)return{newSheetTransform:G({...n},this._selectionRenderService),newTransform:n};let d=null,l=null;if(c>=i){const m=this._selectionRenderService.attachRangeWithCoord({startRow:i,endRow:e,startColumn:s.column,endColumn:a.column});if(m==null)return;l={...n,top:(n.top||0)+m.endY-m.startY},d=G(l,this._selectionRenderService)}else if(u>=e)if(t===h.SheetDrawingAnchorType.Both)d={from:{...s},to:{...a,row:u+o}},l=H(d,this._selectionRenderService);else return{newSheetTransform:G({...n},this._selectionRenderService),newTransform:n};return d!=null&&l!=null?{newSheetTransform:d,newTransform:l}:null}_shrinkRow(r,n,i,e,t=h.SheetDrawingAnchorType.Position){const o=e-i+1,{from:s,to:a}=r,{row:c}=s,{row:u}=a;if(t===h.SheetDrawingAnchorType.None)return{newSheetTransform:G({...n},this._selectionRenderService),newTransform:n};let d=null,l=null;if(c>e)d={from:{...s,row:c-o},to:{...a,row:u-o}},l=H(d,this._selectionRenderService);else{if(c>=i&&u<=e)return null;if(c<i&&u>e)if(t===h.SheetDrawingAnchorType.Both)d={from:{...s},to:{...a,row:u-o}},l=H(d,this._selectionRenderService);else return{newSheetTransform:G({...n},this._selectionRenderService),newTransform:n};else if(c>=i&&c<=e){if(c===i)l={...n,top:(n.top||0)-r.from.rowOffset};else{const m=this._selectionRenderService.attachRangeWithCoord({startRow:i,endRow:c-1,startColumn:s.column,endColumn:a.column});if(m==null)return;l={...n,top:(n.top||0)-m.endY+m.startY-r.from.rowOffset}}d=G(l,this._selectionRenderService)}else if(u>=i&&u<=e&&t===h.SheetDrawingAnchorType.Both){const m=this._selectionRenderService.attachRangeWithCoord({startColumn:s.column,endColumn:s.column,startRow:i-1,endRow:i-1});if(m==null)return;d={from:{...s},to:{...a,row:i-1,rowOffset:m.endY-m.startY}},l=H(d,this._selectionRenderService)}}return d!=null&&l!=null?{newSheetTransform:d,newTransform:l}:null}_commandListener(){this.disposeWithMe(this._commandService.onCommandExecuted(r=>{if(r.id===w.SetWorksheetActiveOperation.id){const n=r.params,{unitId:i,subUnitId:e}=n,t=this._drawingManagerService.drawingManagerData,o=[],s=[];Object.keys(t).forEach(a=>{const c=t[a];Object.keys(c).forEach(u=>{const d=c[u].data;d!=null&&Object.keys(d).forEach(l=>{a===i&&u===e?o.push(d[l]):s.push(d[l])})})}),this._drawingManagerService.removeNotification(s),this._drawingManagerService.addNotification(o)}}))}_sheetRefreshListener(){this.disposeWithMe(this._commandService.onCommandExecuted(r=>{Cn.includes(r.id)&&requestIdleCallback(()=>{const n=r.params,{unitId:i,subUnitId:e,ranges:t}=n;this._refreshDrawingTransform(i,e,t)})}))}_refreshDrawingTransform(r,n,i){const e=this._drawingManagerService.getDrawingData(r,n),t=[];Object.keys(e).forEach(o=>{const s=e[o],{sheetTransform:a,anchorType:c=h.SheetDrawingAnchorType.Position}=s;if(c===h.SheetDrawingAnchorType.None)return!0;const{from:u,to:d}=a,{row:l,column:m}=u,{row:p,column:S}=d;for(let f=0;f<i.length;f++){const v=i[f],{startRow:y,endRow:M,startColumn:C,endColumn:T}=v;if(g.Rectangle.intersects({startRow:y,endRow:M,startColumn:C,endColumn:T},{startRow:l,endRow:p,startColumn:m,endColumn:S})||l>M||m>T){t.push({...s,transform:H(a,this._selectionRenderService)});break}}}),t.length!==0&&(this._drawingManagerService.refreshTransform(t),this._commandService.syncExecuteCommand(W.id,[r]))}};fe=_n([g.OnLifecycle(g.LifecycleStages.Rendered,fe),te(0,g.ICommandService),te(1,j.Inject(w.SheetInterceptorService)),te(2,h.ISheetDrawingService),te(3,E.IDrawingManagerService),te(4,X.ISelectionRenderService),te(5,g.IUniverInstanceService)],fe);var yn=Object.defineProperty,Dn=Object.getOwnPropertyDescriptor,Mn=(r,n,i,e)=>{for(var t=e>1?void 0:e?Dn(n,i):n,o=r.length-1,s;o>=0;o--)(s=r[o])&&(t=(e?s(n,i,t):s(t))||t);return e&&t&&yn(n,i,t),t},ne=(r,n)=>(i,e)=>n(i,e,r);function Tn(r,n,i,e){const{scaleX:t,scaleY:o}=n.getAncestorScale(),s=n.getViewport(U.SHEET_VIEWPORT_KEY.VIEW_MAIN),a={left:!0,top:!0};if(!s)return{...r,absolute:a};const{left:c,right:u,top:d,bottom:l}=r,m=e.getFreeze(),{startColumn:p,startRow:S,xSplit:f,ySplit:v}=m,y=i.getNoMergeCellPositionByIndexWithNoHeader(S-v,p-f),M=i.getNoMergeCellPositionByIndexWithNoHeader(S,p),{rowHeaderWidth:C,columnHeaderHeight:T}=i,I=M.startX-y.startX,P=M.startY-y.startY,{top:_,left:L,viewportScrollX:R,viewportScrollY:F}=s;let N,A;c<L?(a.left=!0,N=(I+C+(c-L))*t,A=Math.max(Math.min((I+C+(u-L))*t,(I+C)*t),(u-R)*t)):(a.left=!1,N=Math.max((c-R)*t,(I+C)*t),A=Math.max((u-R)*t,(I+C)*t));let D,V;return d<_?(a.top=!0,D=(P+T+(d-_))*o,V=Math.max(Math.min((P+T+(u-_))*o,(P+T)*o),(l-F)*o)):(a.top=!1,D=Math.max((d-F)*o,(P+T)*o),V=Math.max((l-F)*o,(P+T)*o)),{left:N,right:A,top:D,bottom:V,absolute:a}}const Ce=(r,n,i,e)=>{const{scene:t}=n,{left:o,top:s,width:a,height:c,angle:u}=r,d={left:o,right:o+a,top:s,bottom:s+c},l=Tn(d,t,i,e);return{startX:l.left,endX:l.right,startY:l.top,endY:l.bottom,rotate:u,width:a,height:c,absolute:l.absolute}};b.SheetCanvasFloatDomManagerService=class extends g.Disposable{constructor(i,e,t,o,s,a,c){super();q(this,"_domLayerMap",new Map);q(this,"_domLayerInfoMap",new Map);q(this,"_transformChange$",new B.Subject);q(this,"transformChange$",this._transformChange$.asObservable());q(this,"_remove$",new B.Subject);q(this,"remove$",this._remove$.asObservable());this._renderManagerService=i,this._univerInstanceService=e,this._commandService=t,this._drawingManagerService=o,this._selectionRenderService=s,this._canvasFloatDomService=a,this._sheetDrawingService=c,this._drawingAddListener(),this._scrollUpdateListener(),this._featureUpdateListener(),this._deleteListener()}_ensureMap(i,e){let t=this._domLayerMap.get(i);t||(t=new Map,this._domLayerMap.set(i,t));let o=t.get(e);return o||(o=new Map,t.set(e,o)),o}_getSceneAndTransformerByDrawingSearch(i){if(i==null)return;const e=this._renderManagerService.getRenderById(i),t=e==null?void 0:e.scene;if(e==null||t==null)return null;const o=t.getTransformerByCreate(),s=e.engine.getCanvasElement();return{scene:t,transformer:o,renderObject:e,canvas:s}}_drawingAddListener(){this.disposeWithMe(this._drawingManagerService.add$.subscribe(i=>{i.forEach(e=>{var Ve,Fe;const{unitId:t,subUnitId:o,drawingId:s}=e,a=w.getSheetCommandTarget(this._univerInstanceService,{unitId:t,subUnitId:o}),c=this._drawingManagerService.getDrawingByParam(e),u=(Ve=this._renderManagerService.getRenderById(t))==null?void 0:Ve.with(X.SheetSkeletonManagerService).getUnitSkeleton(t,o);if(c==null||a==null||u==null)return;const{transform:d,drawingType:l}=c;if(l!==g.DrawingTypeEnum.DRAWING_DOM)return;const m=this._getSceneAndTransformerByDrawingSearch(t);if(m==null)return;const{scene:p,canvas:S}=m;if(d==null)return!0;const{left:f,top:v,width:y,height:M,angle:C,flipX:T,flipY:I,skewX:P,skewY:_}=d,L=E.getDrawingShapeKeyByDrawingSearch({unitId:t,subUnitId:o,drawingId:s}),R=p.getObject(L);if(R!=null){R.transformByState({left:f,top:v,width:y,height:M,angle:C,flipX:T,flipY:I,skewX:P,skewY:_});return}const F={left:f,top:v,width:y,height:M,zIndex:this._drawingManagerService.getDrawingOrder(t,o).length-1},N=new U.Rect(L,F);p.addObject(N,U.DRAWING_OBJECT_LAYER_INDEX).attachTransformerTo(N);const A=this._ensureMap(t,o),D=new g.DisposableCollection,V=Ce(N,m.renderObject,u.skeleton,a.worksheet),K=new B.BehaviorSubject(V),Wn={dispose:D,rect:N,position$:K,unitId:t,subUnitId:o};this._canvasFloatDomService.addFloatDom({position$:K,id:s,componentKey:c.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:(Fe=A.get(s))==null?void 0:Fe.props});const Be=N.onTransformChangeObservable.add(()=>{const Y=Ce(N,m.renderObject,u.skeleton,a.worksheet);K.next(Y)});D.add(()=>{this._canvasFloatDomService.removeFloatDom(s)}),Be&&D.add(Be),this._domLayerInfoMap.set(s,Wn)})}))}_scrollUpdateListener(){this.disposeWithMe(this._commandService.onCommandExecuted(i=>{var t,o;const e=(s,a)=>{var p;const c=this._getSceneAndTransformerByDrawingSearch(s),u=this._ensureMap(s,a),d=Array.from(u.keys()),l=w.getSheetCommandTarget(this._univerInstanceService,{unitId:s,subUnitId:a}),m=(p=this._renderManagerService.getRenderById(s))==null?void 0:p.with(X.SheetSkeletonManagerService).getUnitSkeleton(s,a);!c||!l||!m||d.forEach(S=>{const f=this._domLayerInfoMap.get(S);if(f){const v=Ce(f.rect,c.renderObject,m.skeleton,l.worksheet);f.position$.next(v)}})};if(i.id===X.SetScrollOperation.id){const s=i.params,{unitId:a,sheetId:c}=s;e(a,c)}else if(i.id===X.SetZoomRatioOperation.id){const s=i.params,{unitId:a}=s;Array.from((o=(t=this._domLayerMap.get(a))==null?void 0:t.keys())!=null?o:[]).forEach(u=>{e(a,u)})}else if(i.id===w.SetFrozenMutation.id){const{unitId:s,subUnitId:a}=i.params;e(s,a)}}))}_getPosition(i){const{startX:e,endX:t,startY:o,endY:s}=i,a=this._selectionRenderService.getSelectionCellByPosition(e,o);if(a==null)return;const c={column:a.actualColumn,columnOffset:e-a.startX,row:a.actualRow,rowOffset:o-a.startY},u=this._selectionRenderService.getSelectionCellByPosition(t,s);if(u==null)return;const d={column:u.actualColumn,columnOffset:t-u.startX,row:u.actualRow,rowOffset:s-u.startY};return{from:c,to:d}}_featureUpdateListener(){this.disposeWithMe(this._drawingManagerService.update$.subscribe(i=>{i.forEach(e=>{const t=this._drawingManagerService.getDrawingByParam(e);if(!t||t.drawingType!==g.DrawingTypeEnum.DRAWING_DOM)return;const o={...t.transform};this._transformChange$.next({id:e.drawingId,value:o})})}))}_deleteListener(){this.disposeWithMe(this._drawingManagerService.remove$.subscribe(i=>{i.forEach(e=>{this._removeDom(e.drawingId)})}))}addFloatDomToPosition(i){const e=w.getSheetCommandTarget(this._univerInstanceService,{unitId:i.unitId,subUnitId:i.subUnitId});if(!e)throw new Error("cannot find current target!");const{unitId:t,subUnitId:o}=e,{initPosition:s,componentKey:a}=i,c=g.Tools.generateRandomId(),u=this._getPosition(s);if(u==null)return;this._ensureMap(t,o).set(c,i);const l={unitId:t,subUnitId:o,drawingId:c,drawingType:g.DrawingTypeEnum.DRAWING_DOM,componentKey:a,sheetTransform:u,transform:{left:s.startX,top:s.startY,width:s.endX-s.startX,height:s.endY-s.startY}};return this._commandService.executeCommand(Ie.id,{unitId:t,drawings:[l]}),{id:c,dispose:()=>{this._removeDom(c,!0)}}}_removeDom(i,e=!1){const t=this._domLayerInfoMap.get(i);if(!t)return;const{unitId:o,subUnitId:s}=t;this._domLayerInfoMap.delete(i),t.dispose.dispose();const a=this._getSceneAndTransformerByDrawingSearch(o);if(a&&a.scene.removeObject(t.rect),e){this._ensureMap(o,s).delete(i);const u=this._drawingManagerService.getDrawingByParam({unitId:o,subUnitId:s,drawingId:i});if(!u)return;const d=this._sheetDrawingService.getBatchRemoveOp([u]),{redo:l,objects:m}=d;this._commandService.syncExecuteCommand(h.SetDrawingApplyMutation.id,{unitId:o,subUnitId:s,op:l,objects:m,type:h.DrawingApplyType.REMOVE})}}},b.SheetCanvasFloatDomManagerService=Mn([ne(0,j.Inject(U.IRenderManagerService)),ne(1,g.IUniverInstanceService),ne(2,j.Inject(g.ICommandService)),ne(3,E.IDrawingManagerService),ne(4,X.ISelectionRenderService),ne(5,j.Inject($.CanvasFloatDomService)),ne(6,h.ISheetDrawingService)],b.SheetCanvasFloatDomManagerService);var Rn=Object.defineProperty,bn=Object.getOwnPropertyDescriptor,En=(r,n,i,e)=>{for(var t=e>1?void 0:e?bn(n,i):n,o=r.length-1,s;o>=0;o--)(s=r[o])&&(t=(e?s(n,i,t):s(t))||t);return e&&t&&Rn(n,i,t),t},Se=(r,n)=>(i,e)=>n(i,e,r);let ve=class extends g.Disposable{constructor(r,n,i,e){super(),this._sheetPrintInterceptorService=r,this._drawingRenderService=n,this._drawingManagerService=i,this._renderManagerService=e,this._initPrinting()}_initPrinting(){this.disposeWithMe(this._sheetPrintInterceptorService.interceptor.intercept(this._sheetPrintInterceptorService.interceptor.getInterceptPoints().PRINTING_COMPONENT_COLLECT,{handler:(r,n,i)=>{const{unitId:e,scene:t,subUnitId:o}=n,s=this._drawingManagerService.getDrawingDataForUnit(e),a=s==null?void 0:s[o];return a&&a.order.forEach(c=>{this._drawingRenderService.renderDrawing(a.data[c],t)}),i()}})),this.disposeWithMe(this._sheetPrintInterceptorService.interceptor.intercept(this._sheetPrintInterceptorService.interceptor.getInterceptPoints().PRINTING_RANGE,{handler:(r,n,i)=>{const{unitId:e,subUnitId:t}=n,o=this._renderManagerService.getRenderById(e);if(!o)return i(r);const s=o.with(X.SheetSkeletonManagerService).getUnitSkeleton(e,t);if(!s)return i(r);const a=this._drawingManagerService.getDrawingDataForUnit(e),c=a==null?void 0:a[n.subUnitId];if(!c)return i(r);const{scaleX:u,scaleY:d}=o.scene,l=r?{...r}:{startColumn:0,endColumn:0,endRow:0,startRow:0},m=c.order.map(p=>c.data[p]).filter(p=>p.drawingType!==E.DrawingTypeEnum.DRAWING_DOM);return m.length?(m.forEach(p=>{if(!p.groupId&&p.transform&&g.Tools.isDefine(p.transform.left)&&g.Tools.isDefine(p.transform.top)&&g.Tools.isDefine(p.transform.width)&&g.Tools.isDefine(p.transform.height)){const S=s.skeleton.getCellPositionByOffset(p.transform.left,p.transform.top,u,d,{x:0,y:0}),f=s.skeleton.getCellPositionByOffset(p.transform.left+p.transform.width,p.transform.top+p.transform.height,u,d,{x:0,y:0});S.column<l.startColumn&&(l.startColumn=S.column),S.row<l.startRow&&(l.startRow=S.row),l.endRow<f.row&&(l.endRow=f.row),l.endColumn<f.column&&(l.endColumn=f.column)}}),i(l)):i(r)}}))}};ve=En([g.OnLifecycle(g.LifecycleStages.Rendered,ve),Se(0,j.Inject(X.SheetPrintInterceptorService)),Se(1,j.Inject(Q.DrawingRenderService)),Se(2,E.IDrawingManagerService),Se(3,U.IRenderManagerService)],ve);var Pn=Object.defineProperty,On=Object.getOwnPropertyDescriptor,An=(r,n,i,e)=>{for(var t=e>1?void 0:e?On(n,i):n,o=r.length-1,s;o>=0;o--)(s=r[o])&&(t=(e?s(n,i,t):s(t))||t);return e&&t&&Pn(n,i,t),t},ae=(r,n)=>(i,e)=>n(i,e,r);let we=class extends g.Disposable{constructor(r,n,i,e,t){super(),this._drawingManagerService=r,this._renderManagerService=n,this._permissionService=i,this._univerInstanceService=e,this._userManagerService=t,this._initDrawingVisible(),this._initDrawingEditable(),this._initViewPermissionChange(),this._initEditPermissionChange()}_initDrawingVisible(){const r=this._univerInstanceService.getCurrentTypeOfUnit$(g.UniverInstanceType.UNIVER_SHEET);this.disposeWithMe(B.combineLatest([r,this._userManagerService.currentUser$]).subscribe(([n,i])=>{if(!n){this._drawingManagerService.setDrawingVisible(!1);return}n.activeSheet$.subscribe(e=>{if(!e){this._drawingManagerService.setDrawingVisible(!1);return}const t=n.getUnitId(),o=e.getSheetId();if(this._permissionService.composePermission([new w.WorkbookViewPermission(t).id,new w.WorksheetViewPermission(t,o).id]).every(a=>a.value))this._drawingManagerService.setDrawingVisible(!0);else{this._drawingManagerService.setDrawingVisible(!1);const a=n.getUnitId(),c=e.getSheetId(),u=this._drawingManagerService.getDrawingData(a,c),d=Object.values(u),l=this._renderManagerService.getRenderById(a),m=l==null?void 0:l.scene;if(m==null)return;m.getAllObjects().forEach(S=>{S.classType===U.RENDER_CLASS_TYPE.IMAGE&&d.some(f=>S.oKey.includes(f.drawingId))&&m.removeObject(S)})}})}))}_initDrawingEditable(){const r=this._univerInstanceService.getCurrentTypeOfUnit$(g.UniverInstanceType.UNIVER_SHEET);this.disposeWithMe(B.combineLatest([r,this._userManagerService.currentUser$]).subscribe(([n,i])=>{if(!n){this._drawingManagerService.setDrawingEditable(!1);return}n.activeSheet$.subscribe(e=>{if(!e){this._drawingManagerService.setDrawingEditable(!1);return}const t=n.getUnitId(),o=e.getSheetId();if(this._permissionService.composePermission([new w.WorkbookEditablePermission(t).id,new w.WorksheetEditPermission(t,o).id]).every(a=>a.value))this._drawingManagerService.setDrawingEditable(!0);else{this._drawingManagerService.setDrawingEditable(!1);const a=n.getUnitId(),c=e.getSheetId(),u=this._drawingManagerService.getDrawingData(a,c),d=Object.values(u),l=this._renderManagerService.getRenderById(a),m=l==null?void 0:l.scene;if(m==null)return;m.getAllObjects().forEach(S=>{S.classType===U.RENDER_CLASS_TYPE.IMAGE&&d.some(f=>S.oKey.includes(f.drawingId))&&m.detachTransformerFrom(S)})}})}))}_initViewPermissionChange(){const r=this._univerInstanceService.getCurrentTypeOfUnit$(g.UniverInstanceType.UNIVER_SHEET);this.disposeWithMe(B.combineLatest([r,this._userManagerService.currentUser$]).subscribe(([n,i])=>{n&&n.activeSheet$.subscribe(e=>{var l;if(!e)return;const t=n.getUnitId(),o=e.getSheetId();let s=!0;const a=this._renderManagerService.getRenderById(t),c=a==null?void 0:a.scene;if(c==null)return;const u=c.getTransformerByCreate(),d=this._permissionService.composePermission$([new w.WorkbookViewPermission(t).id,new w.WorksheetViewPermission(t,o).id]).pipe(B.map(m=>m.every(p=>p.value)));d==null||d.pipe(B.filter(m=>m!==s),B.distinctUntilChanged()).subscribe({next:m=>{s=m,this._drawingManagerService.setDrawingVisible(m);const p=c.getAllObjects(),S=this._drawingManagerService.getDrawingData(t,o),f=Object.values(S);m?this._drawingManagerService.addNotification(f):(p.forEach(v=>{v.classType===U.RENDER_CLASS_TYPE.IMAGE&&f.some(y=>v.oKey.includes(y.drawingId))&&c.removeObject(v)}),u.clearSelectedObjects())}}),(l=this._permissionService.getPermissionPoint$(new w.WorksheetViewPermission(t,o).id))==null||l.pipe(B.filter(m=>m.value!==s),B.distinctUntilChanged()).subscribe({complete:()=>{s=!0,this._drawingManagerService.setDrawingVisible(!0);const m=this._drawingManagerService.getDrawingData(t,o),p=Object.values(m);this._drawingManagerService.addNotification(p)}})})}))}_initEditPermissionChange(){const r=this._univerInstanceService.getCurrentTypeOfUnit$(g.UniverInstanceType.UNIVER_SHEET);this.disposeWithMe(B.combineLatest([r,this._userManagerService.currentUser$]).subscribe(([n,i])=>{n&&n.activeSheet$.subscribe(e=>{var l;if(!e)return;const t=n.getUnitId(),o=e.getSheetId();let s=!0;const a=this._renderManagerService.getRenderById(t),c=a==null?void 0:a.scene;if(c==null)return;const u=c.getTransformerByCreate(),d=this._permissionService.composePermission$([new w.WorkbookEditablePermission(t).id,new w.WorksheetEditPermission(t,o).id]).pipe(B.map(m=>m.every(p=>p.value)));d==null||d.pipe(B.filter(m=>m!==s),B.distinctUntilChanged()).subscribe({next:m=>{s=m,this._drawingManagerService.setDrawingEditable(m);const p=c.getAllObjects(),S=this._drawingManagerService.getDrawingData(t,o),f=Object.values(S);m?(p.forEach(v=>{v.classType===U.RENDER_CLASS_TYPE.IMAGE&&f.some(y=>v.oKey.includes(y.drawingId))&&c.attachTransformerTo(v)}),this._drawingManagerService.addNotification(f)):(p.forEach(v=>{v.classType===U.RENDER_CLASS_TYPE.IMAGE&&f.some(y=>v.oKey.includes(y.drawingId))&&c.detachTransformerFrom(v)}),u.clearSelectedObjects())}}),(l=this._permissionService.getPermissionPoint$(new w.WorksheetEditPermission(t,o).id))==null||l.pipe(B.filter(m=>m.value!==s),B.distinctUntilChanged()).subscribe({complete:()=>{s=!0;const m=n.getUnitId(),p=e.getSheetId(),S=this._drawingManagerService.getDrawingData(m,p),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===U.RENDER_CLASS_TYPE.IMAGE&&f.some(T=>C.oKey.includes(T.drawingId))&&y.detachTransformerFrom(C)})}})})}))}};we=An([g.OnLifecycle(g.LifecycleStages.Rendered,we),ae(0,E.IDrawingManagerService),ae(1,U.IRenderManagerService),ae(2,g.IPermissionService),ae(3,g.IUniverInstanceService),ae(4,j.Inject(g.UserManagerService))],we);var We=Object.defineProperty,Un=Object.getOwnPropertyDescriptor,Nn=(r,n,i)=>n in r?We(r,n,{enumerable:!0,configurable:!0,writable:!0,value:i}):r[n]=i,Ln=(r,n,i,e)=>{for(var t=e>1?void 0:e?Un(n,i):n,o=r.length-1,s;o>=0;o--)(s=r[o])&&(t=(e?s(n,i,t):s(t))||t);return e&&t&&We(n,i,t),t},Ge=(r,n)=>(i,e)=>n(i,e,r),$e=(r,n,i)=>Nn(r,typeof n!="symbol"?n+"":n,i);const jn="SHEET_IMAGE_UI_PLUGIN";b.UniverSheetsDrawingUIPlugin=class extends g.Plugin{constructor(i={},e,t){super();q(this,"_pluginConfig");this._injector=e,this._localeService=t,this._pluginConfig=g.Tools.deepMerge({},Sn,i)}onStarting(i){super.onStarting(i),this._initDependencies(i)}_initDependencies(i){[[b.SheetCanvasFloatDomManagerService],[se,{useFactory:()=>this._injector.createInstance(se,this._pluginConfig)}],[ge],[de],[fe],[ve],[we]].forEach(t=>i.add(t))}},$e(b.UniverSheetsDrawingUIPlugin,"type",g.UniverInstanceType.UNIVER_SHEET),$e(b.UniverSheetsDrawingUIPlugin,"pluginName",jn),b.UniverSheetsDrawingUIPlugin=Ln([g.DependentOn(E.UniverDrawingPlugin,Q.UniverDrawingUIPlugin,h.UniverSheetsDrawingPlugin),Ge(1,j.Inject(j.Injector)),Ge(2,j.Inject(g.LocaleService))],b.UniverSheetsDrawingUIPlugin),Object.defineProperty(b,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@univerjs/sheets-drawing-ui",
3
- "version": "0.1.15",
3
+ "version": "0.1.16",
4
4
  "private": false,
5
5
  "description": "",
6
6
  "author": "DreamNum <developer@univer.ai>",
@@ -52,18 +52,18 @@
52
52
  "clsx": ">=2.0.0",
53
53
  "react": "^16.9.0 || ^17.0.0 || ^18.0.0",
54
54
  "rxjs": ">=7.0.0",
55
- "@univerjs/core": "0.1.15",
56
- "@univerjs/design": "0.1.15",
57
- "@univerjs/drawing": "0.1.15",
58
- "@univerjs/engine-render": "0.1.15",
59
- "@univerjs/drawing-ui": "0.1.15",
60
- "@univerjs/sheets": "0.1.15",
61
- "@univerjs/sheets-ui": "0.1.15",
62
- "@univerjs/ui": "0.1.15",
63
- "@univerjs/sheets-drawing": "0.1.15"
55
+ "@univerjs/core": "0.1.16",
56
+ "@univerjs/design": "0.1.16",
57
+ "@univerjs/drawing": "0.1.16",
58
+ "@univerjs/drawing-ui": "0.1.16",
59
+ "@univerjs/engine-render": "0.1.16",
60
+ "@univerjs/sheets": "0.1.16",
61
+ "@univerjs/sheets-ui": "0.1.16",
62
+ "@univerjs/ui": "0.1.16",
63
+ "@univerjs/sheets-drawing": "0.1.16"
64
64
  },
65
65
  "dependencies": {
66
- "@univerjs/icons": "^0.1.56"
66
+ "@univerjs/icons": "^0.1.57"
67
67
  },
68
68
  "devDependencies": {
69
69
  "@wendellhu/redi": "0.15.4",
@@ -72,18 +72,18 @@
72
72
  "react": "18.3.1",
73
73
  "rxjs": "^7.8.1",
74
74
  "typescript": "^5.4.5",
75
- "vite": "^5.2.13",
75
+ "vite": "^5.3.1",
76
76
  "vitest": "^1.6.0",
77
- "@univerjs/core": "0.1.15",
78
- "@univerjs/design": "0.1.15",
79
- "@univerjs/drawing-ui": "0.1.15",
80
- "@univerjs/engine-render": "0.1.15",
81
- "@univerjs/drawing": "0.1.15",
82
- "@univerjs/shared": "0.1.15",
83
- "@univerjs/sheets": "0.1.15",
84
- "@univerjs/sheets-drawing": "0.1.15",
85
- "@univerjs/sheets-ui": "0.1.15",
86
- "@univerjs/ui": "0.1.15"
77
+ "@univerjs/core": "0.1.16",
78
+ "@univerjs/design": "0.1.16",
79
+ "@univerjs/drawing": "0.1.16",
80
+ "@univerjs/engine-render": "0.1.16",
81
+ "@univerjs/shared": "0.1.16",
82
+ "@univerjs/sheets": "0.1.16",
83
+ "@univerjs/drawing-ui": "0.1.16",
84
+ "@univerjs/sheets-drawing": "0.1.16",
85
+ "@univerjs/sheets-ui": "0.1.16",
86
+ "@univerjs/ui": "0.1.16"
87
87
  },
88
88
  "univerSpace": {
89
89
  ".": {