@univerjs/sheets-drawing-ui 0.5.4 → 0.5.5-nightly.202501201336

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/umd/index.js CHANGED
@@ -1,4 +1,4 @@
1
- (function(b,d){typeof exports=="object"&&typeof module<"u"?d(exports,require("@univerjs/core"),require("@univerjs/docs-drawing"),require("@univerjs/drawing"),require("@univerjs/drawing-ui"),require("@univerjs/engine-render"),require("@univerjs/sheets-drawing"),require("@univerjs/sheets-ui"),require("@univerjs/ui"),require("rxjs"),require("@univerjs/sheets"),require("react"),require("@univerjs/docs-ui"),require("@univerjs/design")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/docs-drawing","@univerjs/drawing","@univerjs/drawing-ui","@univerjs/engine-render","@univerjs/sheets-drawing","@univerjs/sheets-ui","@univerjs/ui","rxjs","@univerjs/sheets","react","@univerjs/docs-ui","@univerjs/design"],d):(b=typeof globalThis<"u"?globalThis:b||self,d(b.UniverSheetsDrawingUi={},b.UniverCore,b.UniverDocsDrawing,b.UniverDrawing,b.UniverDrawingUi,b.UniverEngineRender,b.UniverSheetsDrawing,b.UniverSheetsUi,b.UniverUi,b.rxjs,b.UniverSheets,b.React,b.UniverDocsUi,b.UniverDesign))})(this,function(b,d,ne,O,q,N,p,U,k,j,v,X,xe,J){"use strict";var Mn=Object.defineProperty;var Dn=(b,d,ne)=>d in b?Mn(b,d,{enumerable:!0,configurable:!0,writable:!0,value:ne}):b[d]=ne;var Y=(b,d,ne)=>Dn(b,typeof d!="symbol"?d+"":d,ne);const dt="sheets-drawing-ui.config",Ye={},G={id:"sheet.operation.clear-drawing-transformer",type:d.CommandType.MUTATION,handler:(i,r)=>{const n=i.get(N.IRenderManagerService);return r.forEach(e=>{var t,o;(o=(t=n.getRenderById(e))==null?void 0:t.scene.getTransformer())==null||o.debounceRefreshControls()}),!0}},se={id:"sheet.command.remove-sheet-image",type:d.CommandType.COMMAND,handler:(i,r)=>{var M,y,R;const n=i.get(d.ICommandService),e=i.get(d.IUndoRedoService),t=i.get(v.SheetInterceptorService),o=i.get(p.ISheetDrawingService);if(!r)return!1;const{drawings:a}=r,c=[];a.forEach(C=>{const{unitId:T}=C;c.push(T)});const l=o.getBatchRemoveOp(a),{unitId:h,subUnitId:u,undo:s,redo:g,objects:m}=l,f=t.onCommandExecute({id:se.id,params:r}),S={id:p.SetDrawingApplyMutation.id,params:{unitId:h,subUnitId:u,op:g,objects:m,type:p.DrawingApplyType.REMOVE}},_={id:p.SetDrawingApplyMutation.id,params:{unitId:h,subUnitId:u,op:s,objects:m,type:p.DrawingApplyType.INSERT}};return d.sequenceExecute([...(M=f.preRedos)!=null?M:[],S,...f.redos],n)?(e.pushUndoRedo({unitID:h,undoMutations:[...(y=f.preUndos)!=null?y:[],_,...f.undos,{id:G.id,params:c}],redoMutations:[...(R=f.preRedos)!=null?R:[],S,...f.redos,{id:G.id,params:c}]}),!0):!1}},Xe="COMPONENT_SHEET_DRAWING_PANEL",Ee={id:"sidebar.operation.sheet-image",type:d.CommandType.COMMAND,handler:async(i,r)=>{const n=i.get(k.ISidebarService),e=i.get(d.LocaleService),t=i.get(d.IUniverInstanceService),o=i.get(d.ICommandService);if(!v.getSheetCommandTarget(t))return!1;switch(r.value){case"open":n.open({header:{title:e.t("sheetImage.panel.title")},children:{label:Xe},onClose:()=>{o.syncExecuteCommand(O.SetDrawingSelectedOperation.id,[])},width:360});break;case"close":default:n.close();break}return!0}},Oe={id:"sheet.operation.edit-sheet-image",type:d.CommandType.OPERATION,handler:(i,r)=>{const n=i.get(d.ICommandService);return r==null?!1:(n.syncExecuteCommand(O.SetDrawingSelectedOperation.id,[r]),n.executeCommand(Ee.id,{value:"open"}),!0)}};var Pe={exports:{}},ce={};/**
1
+ (function(b,l){typeof exports=="object"&&typeof module<"u"?l(exports,require("@univerjs/core"),require("@univerjs/docs-drawing"),require("@univerjs/drawing"),require("@univerjs/drawing-ui"),require("@univerjs/engine-render"),require("@univerjs/sheets-drawing"),require("@univerjs/sheets-ui"),require("@univerjs/ui"),require("rxjs"),require("@univerjs/sheets"),require("react"),require("@univerjs/docs-ui"),require("@univerjs/design")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/docs-drawing","@univerjs/drawing","@univerjs/drawing-ui","@univerjs/engine-render","@univerjs/sheets-drawing","@univerjs/sheets-ui","@univerjs/ui","rxjs","@univerjs/sheets","react","@univerjs/docs-ui","@univerjs/design"],l):(b=typeof globalThis<"u"?globalThis:b||self,l(b.UniverSheetsDrawingUi={},b.UniverCore,b.UniverDocsDrawing,b.UniverDrawing,b.UniverDrawingUi,b.UniverEngineRender,b.UniverSheetsDrawing,b.UniverSheetsUi,b.UniverUi,b.rxjs,b.UniverSheets,b.React,b.UniverDocsUi,b.UniverDesign))})(this,function(b,l,Se,P,ge,N,f,A,V,k,v,q,bt,ne){"use strict";var cr=Object.defineProperty;var dr=(b,l,Se)=>l in b?cr(b,l,{enumerable:!0,configurable:!0,writable:!0,value:Se}):b[l]=Se;var Z=(b,l,Se)=>dr(b,typeof l!="symbol"?l+"":l,Se);const Xt="sheets-drawing-ui.config",Et={},$={id:"sheet.operation.clear-drawing-transformer",type:l.CommandType.MUTATION,handler:(i,r)=>{const n=i.get(N.IRenderManagerService);return r.forEach(e=>{var t,o;(o=(t=n.getRenderById(e))==null?void 0:t.scene.getTransformer())==null||o.debounceRefreshControls()}),!0}},Ee={id:"sheet.command.remove-sheet-image",type:l.CommandType.COMMAND,handler:(i,r)=>{var C,M,R;const n=i.get(l.ICommandService),e=i.get(l.IUndoRedoService),t=i.get(v.SheetInterceptorService),o=i.get(f.ISheetDrawingService);if(!r)return!1;const{drawings:a}=r,s=[];a.forEach(D=>{const{unitId:T}=D;s.push(T)});const d=o.getBatchRemoveOp(a),{unitId:m,subUnitId:u,undo:c,redo:h,objects:g}=d,p=t.onCommandExecute({id:Ee.id,params:r}),S={id:f.SetDrawingApplyMutation.id,params:{unitId:m,subUnitId:u,op:h,objects:g,type:f.DrawingApplyType.REMOVE}},w={id:f.SetDrawingApplyMutation.id,params:{unitId:m,subUnitId:u,op:c,objects:g,type:f.DrawingApplyType.INSERT}};return l.sequenceExecute([...(C=p.preRedos)!=null?C:[],S,...p.redos],n)?(e.pushUndoRedo({unitID:m,undoMutations:[...(M=p.preUndos)!=null?M:[],w,...p.undos,{id:$.id,params:s}],redoMutations:[...(R=p.preRedos)!=null?R:[],S,...p.redos,{id:$.id,params:s}]}),!0):!1}},Ot="COMPONENT_SHEET_DRAWING_PANEL",gt={id:"sidebar.operation.sheet-image",type:l.CommandType.COMMAND,handler:async(i,r)=>{const n=i.get(V.ISidebarService),e=i.get(l.LocaleService),t=i.get(l.IUniverInstanceService),o=i.get(l.ICommandService);if(!v.getSheetCommandTarget(t))return!1;switch(r.value){case"open":n.open({header:{title:e.t("sheetImage.panel.title")},children:{label:Ot},onClose:()=>{o.syncExecuteCommand(P.SetDrawingSelectedOperation.id,[])},width:360});break;case"close":default:n.close();break}return!0}},ht={id:"sheet.operation.edit-sheet-image",type:l.CommandType.OPERATION,handler:(i,r)=>{const n=i.get(l.ICommandService);return r==null?!1:(n.syncExecuteCommand(P.SetDrawingSelectedOperation.id,[r]),n.executeCommand(gt.id,{value:"open"}),!0)}};var mt={exports:{}},Oe={};/**
2
2
  * @license React
3
3
  * react-jsx-runtime.production.min.js
4
4
  *
@@ -6,4 +6,4 @@
6
6
  *
7
7
  * This source code is licensed under the MIT license found in the
8
8
  * LICENSE file in the root directory of this source tree.
9
- */var ze;function lt(){if(ze)return ce;ze=1;var i=X,r=Symbol.for("react.element"),n=Symbol.for("react.fragment"),e=Object.prototype.hasOwnProperty,t=i.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,o={key:!0,ref:!0,__self:!0,__source:!0};function a(c,l,h){var u,s={},g=null,m=null;h!==void 0&&(g=""+h),l.key!==void 0&&(g=""+l.key),l.ref!==void 0&&(m=l.ref);for(u in l)e.call(l,u)&&!o.hasOwnProperty(u)&&(s[u]=l[u]);if(c&&c.defaultProps)for(u in l=c.defaultProps,l)s[u]===void 0&&(s[u]=l[u]);return{$$typeof:r,type:c,key:g,ref:m,props:s,_owner:t.current}}return ce.Fragment=n,ce.jsx=a,ce.jsxs=a,ce}var Ke;function ut(){return Ke||(Ke=1,Pe.exports=lt()),Pe.exports}var H=ut();const he={uploadLoading:"univer-upload-loading",uploadLoadingBody:"univer-upload-loading-body",uploadLoadingBodyAnimation:"univer-upload-loading-body-animation",univerCircleAnimation:"univer-UniverCircleAnimation",uploadLoadingBodyText:"univer-upload-loading-body-text"},mt=()=>{const i=d.useDependency(O.IImageIoService),r=d.useDependency(d.LocaleService),[n,e]=X.useState(0);return X.useEffect(()=>{const t=i.change$.subscribe(o=>{e(o)});return()=>{t.unsubscribe()}},[i]),H.jsx("div",{style:{display:n>0?"block":"none"},className:he.uploadLoading,children:H.jsxs("div",{className:he.uploadLoadingBody,children:[H.jsx("div",{className:he.uploadLoadingBodyAnimation}),H.jsx("div",{className:he.uploadLoadingBodyText,children:`${r.t("uploadLoading.loading")}: ${n}`})]})})};var gt=Object.defineProperty,ht=Object.getOwnPropertyDescriptor,pt=(i,r,n,e)=>{for(var t=e>1?void 0:e?ht(r,n):r,o=i.length-1,a;o>=0;o--)(a=i[o])&&(t=(e?a(r,n,t):a(t))||t);return e&&t&&gt(r,n,t),t},Q=(i,r)=>(n,e)=>r(n,e,i);let pe=class extends d.RxDisposable{constructor(r,n,e,t,o,a,c,l){super();Y(this,"_initImagePopupMenu",new Set);this._injector=r,this._drawingManagerService=n,this._canvasPopManagerService=e,this._renderManagerService=t,this._univerInstanceService=o,this._contextService=a,this._uiPartsService=c,this._commandService=l,this._init()}_init(){this._univerInstanceService.getCurrentTypeOfUnit$(d.UniverInstanceType.UNIVER_SHEET).pipe(j.takeUntil(this.dispose$)).subscribe(r=>this._create(r)),this._univerInstanceService.getTypeOfUnitDisposed$(d.UniverInstanceType.UNIVER_SHEET).pipe(j.takeUntil(this.dispose$)).subscribe(r=>this._dispose(r)),this._univerInstanceService.getAllUnitsForType(d.UniverInstanceType.UNIVER_SHEET).forEach(r=>this._create(r)),this._uiPartsService.registerComponent(k.BuiltInUIPart.CONTENT,()=>d.connectInjector(mt,this._injector))}_dispose(r){const n=r.getUnitId();this._renderManagerService.removeRender(n)}_create(r){if(!r)return;const n=r.getUnitId();this._renderManagerService.has(n)&&!this._initImagePopupMenu.has(n)&&(this._popupMenuListener(n),this._initImagePopupMenu.add(n))}_hasCropObject(r){const n=r.getAllObjectsByOrder();for(const e of n)if(e instanceof q.ImageCropperObject)return!0;return!1}_popupMenuListener(r){var o;const n=(o=this._renderManagerService.getRenderById(r))==null?void 0:o.scene;if(!n)return;const e=n.getTransformerByCreate();if(!e)return;let t;this.disposeWithMe(d.toDisposable(e.createControl$.subscribe(()=>{if(this._contextService.setContextValue(d.FOCUSING_COMMON_DRAWINGS,!0),this._hasCropObject(n))return;const a=e.getSelectedObjectMap();if(a.size>1){t==null||t.dispose();return}const c=a.values().next().value;if(!c)return;const l=c.oKey,h=this._drawingManagerService.getDrawingOKey(l);if(!h)return;const{unitId:u,subUnitId:s,drawingId:g,drawingType:m}=h,f=h.data;if(f&&f.disablePopup)return;t==null||t.dispose();const S=this._canvasPopManagerService.getFeatureMenu(u,s,g,m);t=this.disposeWithMe(this._canvasPopManagerService.attachPopupToObject(c,{componentKey:q.COMPONENT_IMAGE_POPUP_MENU,direction:"horizontal",offset:[2,0],extraProps:{menuItems:S||this._getImageMenuItems(u,s,g,m)}}))}))),this.disposeWithMe(e.clearControl$.subscribe(()=>{t==null||t.dispose(),this._contextService.setContextValue(d.FOCUSING_COMMON_DRAWINGS,!1),this._commandService.syncExecuteCommand(O.SetDrawingSelectedOperation.id,[])})),this.disposeWithMe(this._contextService.contextChanged$.subscribe(a=>{a[d.FOCUSING_COMMON_DRAWINGS]===!1&&(t==null||t.dispose())})),this.disposeWithMe(e.changing$.subscribe(()=>{t==null||t.dispose()}))}_getImageMenuItems(r,n,e,t){return[{label:"image-popup.edit",index:0,commandId:Oe.id,commandParams:{unitId:r,subUnitId:n,drawingId:e},disable:t===d.DrawingTypeEnum.DRAWING_DOM},{label:"image-popup.delete",index:1,commandId:se.id,commandParams:{unitId:r,drawings:[{unitId:r,subUnitId:n,drawingId:e}]},disable:!1},{label:"image-popup.crop",index:2,commandId:q.OpenImageCropOperation.id,commandParams:{unitId:r,subUnitId:n,drawingId:e},disable:t===d.DrawingTypeEnum.DRAWING_DOM},{label:"image-popup.reset",index:3,commandId:q.ImageResetSizeOperation.id,commandParams:[{unitId:r,subUnitId:n,drawingId:e}],disable:t===d.DrawingTypeEnum.DRAWING_DOM}]}};pe=pt([Q(0,d.Inject(d.Injector)),Q(1,O.IDrawingManagerService),Q(2,d.Inject(U.SheetCanvasPopManagerService)),Q(3,N.IRenderManagerService),Q(4,d.IUniverInstanceService),Q(5,d.IContextService),Q(6,d.Inject(k.IUIPartsService)),Q(7,d.ICommandService)],pe);function V(i,r,n){const{from:e,to:t,flipY:o=!1,flipX:a=!1,angle:c=0,skewX:l=0,skewY:h=0}=i,u=n.getCurrent();if(u==null)return;const s=U.convertPositionSheetOverGridToAbsolute(u.unitId,u.sheetId,{from:e,to:t},n);let{left:g,top:m,width:f,height:S}=s;const _=n.getCurrentSkeleton(),I=_.rowHeaderWidth+_.columnTotalWidth,M=_.columnHeaderHeight+_.rowTotalHeight;return g+f>I&&(g=I-f),m+S>M&&(m=M-S),{flipY:o,flipX:a,angle:c,skewX:l,skewY:h,left:g,top:m,width:f,height:S}}function F(i,r){const{left:n=0,top:e=0,width:t=0,height:o=0,flipY:a=!1,flipX:c=!1,angle:l=0,skewX:h=0,skewY:u=0}=i,s=r.getCellWithCoordByOffset(n,e);if(s==null)return;const g={column:s.actualColumn,columnOffset:N.precisionTo(n-s.startX,1),row:s.actualRow,rowOffset:N.precisionTo(e-s.startY,1)},m=r.getCellWithCoordByOffset(n+t,e+o);if(m==null)return;const f={column:m.actualColumn,columnOffset:N.precisionTo(n+t-m.startX,1),row:m.actualRow,rowOffset:N.precisionTo(e+o-m.startY,1)};return{flipY:a,flipX:c,angle:l,skewX:h,skewY:u,from:g,to:f}}var ft=Object.defineProperty,St=Object.getOwnPropertyDescriptor,_t=(i,r,n,e)=>{for(var t=e>1?void 0:e?St(r,n):r,o=i.length-1,a;o>=0;o--)(a=i[o])&&(t=(e?a(r,n,t):a(t))||t);return e&&t&&ft(r,n,t),t},fe=(i,r)=>(n,e)=>r(n,e,i);let Ae=class extends d.Disposable{constructor(i,r,n,e,t){super(),this._context=i,this._sheetDrawingService=r,this._drawingManagerService=n,this._sheetSelectionRenderService=e,this._sheetSkeletonManagerService=t,this._init()}_init(){this._drawingInitializeListener()}_drawingInitializeListener(){this._sheetDrawingService.initializeNotification(this._context.unitId);const i=this._sheetDrawingService.getDrawingDataForUnit(this._context.unitId);for(const r in i){const n=i[r];for(const e in n.data){const t=n.data[e];t.transform=V(t.sheetTransform,this._sheetSelectionRenderService,this._sheetSkeletonManagerService)}}this._drawingManagerService.registerDrawingData(this._context.unitId,this._sheetDrawingService.getDrawingDataForUnit(this._context.unitId)),this._drawingManagerService.initializeNotification(this._context.unitId)}};Ae=_t([fe(1,p.ISheetDrawingService),fe(2,O.IDrawingManagerService),fe(3,d.Inject(U.ISheetSelectionRenderService)),fe(4,d.Inject(U.SheetSkeletonManagerService))],Ae);function vt(i){const r=[];return i.forEach(n=>{const{parent:e,children:t}=n,{unitId:o,subUnitId:a,drawingId:c}=e,l=N.getGroupState(0,0,t.map(s=>s.transform||{})),h=t.map(s=>{const g=s.transform||{left:0,top:0},{unitId:m,subUnitId:f,drawingId:S}=s;return{unitId:m,subUnitId:f,drawingId:S,transform:{...g,left:g.left-l.left,top:g.top-l.top},groupId:c}}),u={unitId:o,subUnitId:a,drawingId:c,drawingType:d.DrawingTypeEnum.DRAWING_GROUP,transform:l};r.push({parent:u,children:h})}),r}function wt(i){const r=[];return i.forEach(n=>{const{parent:e,children:t}=n,{unitId:o,subUnitId:a,drawingId:c,transform:l={width:0,height:0}}=e;if(l==null)return;const h=t.map(s=>{const{transform:g}=s,{unitId:m,subUnitId:f,drawingId:S}=s,_=N.transformObjectOutOfGroup(g||{},l,l.width||0,l.height||0);return{unitId:m,subUnitId:f,drawingId:S,transform:_,groupId:void 0}}),u={unitId:o,subUnitId:a,drawingId:c,drawingType:d.DrawingTypeEnum.DRAWING_GROUP,transform:{left:0,top:0}};r.push({parent:u,children:h})}),r}const Ue={id:"sheet.command.group-sheet-image",type:d.CommandType.COMMAND,handler:(i,r)=>{const n=i.get(d.ICommandService),e=i.get(d.IUndoRedoService),t=i.get(p.ISheetDrawingService);if(!r)return!1;const o=[];r.forEach(({parent:m,children:f})=>{o.push(m.unitId),f.forEach(S=>{o.push(S.unitId)})});const a=t.getGroupDrawingOp(r),{unitId:c,subUnitId:l,undo:h,redo:u,objects:s}=a;return n.syncExecuteCommand(p.SetDrawingApplyMutation.id,{op:u,unitId:c,subUnitId:l,objects:s,type:p.DrawingApplyType.GROUP})?(e.pushUndoRedo({unitID:c,undoMutations:[{id:p.SetDrawingApplyMutation.id,params:{op:h,unitId:c,subUnitId:l,objects:wt(s),type:p.DrawingApplyType.UNGROUP}},{id:G.id,params:o}],redoMutations:[{id:p.SetDrawingApplyMutation.id,params:{op:u,unitId:c,subUnitId:l,objects:s,type:p.DrawingApplyType.GROUP}},{id:G.id,params:o}]}),!0):!1}},de={id:"sheet.command.insert-sheet-image",type:d.CommandType.COMMAND,handler:(i,r)=>{var M,y,R;const n=i.get(d.ICommandService),e=i.get(d.IUndoRedoService),t=i.get(p.ISheetDrawingService),o=i.get(v.SheetInterceptorService);if(!r)return!1;const a=r.drawings,c=a.map(C=>C.unitId),l=t.getBatchAddOp(a),{unitId:h,subUnitId:u,undo:s,redo:g,objects:m}=l,f=o.onCommandExecute({id:de.id,params:r}),S={id:p.SetDrawingApplyMutation.id,params:{op:g,unitId:h,subUnitId:u,objects:m,type:p.DrawingApplyType.INSERT}},_={id:p.SetDrawingApplyMutation.id,params:{op:s,unitId:h,subUnitId:u,objects:m,type:p.DrawingApplyType.REMOVE}};return d.sequenceExecute([...(M=f.preRedos)!=null?M:[],S,...f.redos],n)?(e.pushUndoRedo({unitID:h,undoMutations:[...(y=f.preUndos)!=null?y:[],_,...f.undos,{id:G.id,params:c}],redoMutations:[...(R=f.preRedos)!=null?R:[],S,...f.redos,{id:G.id,params:c}]}),!0):!1}},Ne={id:"sheet.command.set-drawing-arrange",type:d.CommandType.COMMAND,handler:(i,r)=>{const n=i.get(d.ICommandService),e=i.get(d.IUndoRedoService);if(!r)return!1;const t=i.get(p.ISheetDrawingService),{unitId:o,subUnitId:a,drawingIds:c,arrangeType:l}=r,h={unitId:o,subUnitId:a,drawingIds:c};let u;if(l===d.ArrangeTypeEnum.forward?u=t.getForwardDrawingsOp(h):l===d.ArrangeTypeEnum.backward?u=t.getBackwardDrawingOp(h):l===d.ArrangeTypeEnum.front?u=t.getFrontDrawingsOp(h):l===d.ArrangeTypeEnum.back&&(u=t.getBackDrawingsOp(h)),u==null)return!1;const{objects:s,redo:g,undo:m}=u;return n.syncExecuteCommand(p.SetDrawingApplyMutation.id,{op:g,unitId:o,subUnitId:a,objects:s,type:p.DrawingApplyType.ARRANGE})?(e.pushUndoRedo({unitID:o,undoMutations:[{id:p.SetDrawingApplyMutation.id,params:{op:m,unitId:o,subUnitId:a,objects:s,type:p.DrawingApplyType.ARRANGE}}],redoMutations:[{id:p.SetDrawingApplyMutation.id,params:{op:g,unitId:o,subUnitId:a,objects:s,type:p.DrawingApplyType.ARRANGE}}]}),!0):!1}},le={id:"sheet.command.set-sheet-image",type:d.CommandType.COMMAND,handler:(i,r)=>{const n=i.get(d.ICommandService),e=i.get(d.IUndoRedoService),t=i.get(p.ISheetDrawingService);if(!r)return!1;const{drawings:o}=r,a=t.getBatchUpdateOp(o),{unitId:c,subUnitId:l,undo:h,redo:u,objects:s}=a;return n.syncExecuteCommand(p.SetDrawingApplyMutation.id,{unitId:c,subUnitId:l,op:u,objects:s,type:p.DrawingApplyType.UPDATE})?(e.pushUndoRedo({unitID:c,undoMutations:[{id:p.SetDrawingApplyMutation.id,params:{unitId:c,subUnitId:l,op:h,objects:s,type:p.DrawingApplyType.UPDATE}},{id:G.id,params:[c]}],redoMutations:[{id:p.SetDrawingApplyMutation.id,params:{unitId:c,subUnitId:l,op:u,objects:s,type:p.DrawingApplyType.UPDATE}},{id:G.id,params:[c]}]}),!0):!1}},je={id:"sheet.command.ungroup-sheet-image",type:d.CommandType.COMMAND,handler:(i,r)=>{const n=i.get(d.ICommandService),e=i.get(d.IUndoRedoService),t=i.get(p.ISheetDrawingService);if(!r)return!1;const o=[];r.forEach(({parent:m,children:f})=>{o.push(m.unitId),f.forEach(S=>{o.push(S.unitId)})});const a=t.getUngroupDrawingOp(r),{unitId:c,subUnitId:l,undo:h,redo:u,objects:s}=a;return n.syncExecuteCommand(p.SetDrawingApplyMutation.id,{op:u,unitId:c,subUnitId:l,objects:s,type:p.DrawingApplyType.UNGROUP})?(e.pushUndoRedo({unitID:c,undoMutations:[{id:p.SetDrawingApplyMutation.id,params:{op:h,unitId:c,subUnitId:l,objects:vt(s),type:p.DrawingApplyType.GROUP}},{id:G.id,params:o}],redoMutations:[{id:p.SetDrawingApplyMutation.id,params:{op:u,unitId:c,subUnitId:l,objects:s,type:p.DrawingApplyType.UNGROUP}},{id:G.id,params:o}]}),!0):!1}};var It=Object.defineProperty,Ct=Object.getOwnPropertyDescriptor,yt=(i,r,n,e)=>{for(var t=e>1?void 0:e?Ct(r,n):r,o=i.length-1,a;o>=0;o--)(a=i[o])&&(t=(e?a(r,n,t):a(t))||t);return e&&t&&It(r,n,t),t},z=(i,r)=>(n,e)=>r(n,e,i);function Mt(i,r,n){const e=n*Math.PI/180,t=Math.abs(i*Math.cos(e))+Math.abs(r*Math.sin(e)),o=Math.abs(i*Math.sin(e))+Math.abs(r*Math.cos(e));return{rotatedWidth:t,rotatedHeight:o}}function Je(i,r,n,e,t){var M;const{rotatedHeight:o,rotatedWidth:a}=Mt(n,e,t),l=i.get(N.IRenderManagerService).getRenderById(r.unitId);if(!l)return!1;const u=(M=l.with(U.SheetSkeletonManagerService).getWorksheetSkeleton(r.subUnitId))==null?void 0:M.skeleton;if(u==null)return!1;const s=u.getCellByIndex(r.row,r.col),g=s.mergeInfo.endX-s.mergeInfo.startX-2,m=s.mergeInfo.endY-s.mergeInfo.startY-2,f=a/o,_=Math.ceil(Math.min(g,m*f))/a,I=!_||Number.isNaN(_)?.001:_;return{width:n*I,height:e*I}}let ue=class extends d.Disposable{constructor(r,n,e,t,o,a,c,l,h,u,s,g,m){super();Y(this,"_workbookSelections");this._context=r,this._skeletonManagerService=n,this._commandService=e,this._selectionRenderService=t,this._imageIoService=o,this._fileOpenerService=a,this._sheetDrawingService=c,this._drawingManagerService=l,this._contextService=h,this._messageService=u,this._localeService=s,this._injector=m,this._workbookSelections=g.getWorkbookSelections(this._context.unitId),this._updateImageListener(),this._updateOrderListener(),this._groupDrawingListener(),this._focusDrawingListener()}async insertFloatImage(){const r=await this._fileOpenerService.openFile({multiple:!0,accept:O.DRAWING_IMAGE_ALLOW_IMAGE_LIST.map(e=>`.${e.replace("image/","")}`).join(",")}),n=r.length;return n>O.DRAWING_IMAGE_COUNT_LIMIT?(this._messageService.show({type:J.MessageType.Error,content:this._localeService.t("update-status.exceedMaxCount",String(O.DRAWING_IMAGE_COUNT_LIMIT))}),!1):n===0?!1:(r.forEach(async e=>await this._insertFloatImage(e)),!0)}async insertCellImage(){const n=(await this._fileOpenerService.openFile({multiple:!1,accept:O.DRAWING_IMAGE_ALLOW_IMAGE_LIST.map(e=>`.${e.replace("image/","")}`).join(",")}))[0];return n?(await this._insertCellImage(n),!0):!1}async _insertFloatImage(r){let n;try{n=await this._imageIoService.saveImage(r)}catch(M){const y=M.message;y===O.ImageUploadStatusType.ERROR_EXCEED_SIZE?this._messageService.show({type:J.MessageType.Error,content:this._localeService.t("update-status.exceedMaxSize",String(O.DRAWING_IMAGE_ALLOW_SIZE/(1024*1024)))}):y===O.ImageUploadStatusType.ERROR_IMAGE_TYPE?this._messageService.show({type:J.MessageType.Error,content:this._localeService.t("update-status.invalidImageType")}):y===O.ImageUploadStatusType.ERROR_IMAGE&&this._messageService.show({type:J.MessageType.Error,content:this._localeService.t("update-status.invalidImage")})}if(n==null)return;const e=this._getUnitInfo(),{unitId:t,subUnitId:o}=e,{imageId:a,imageSourceType:c,source:l,base64Cache:h}=n,{width:u,height:s,image:g}=await O.getImageSize(h||""),{width:m,height:f}=this._context.scene;this._imageIoService.addImageSourceCache(l,c,g);let S=1;if(u>O.DRAWING_IMAGE_WIDTH_LIMIT||s>O.DRAWING_IMAGE_HEIGHT_LIMIT){const M=O.DRAWING_IMAGE_WIDTH_LIMIT/u,y=O.DRAWING_IMAGE_HEIGHT_LIMIT/s;S=Math.max(M,y)}const _=this._getImagePosition(u*S,s*S,m,f);if(_==null)return;const I={unitId:t,subUnitId:o,drawingId:a,drawingType:d.DrawingTypeEnum.DRAWING_IMAGE,imageSourceType:c,source:l,transform:V(_,this._selectionRenderService,this._skeletonManagerService),sheetTransform:_};this._commandService.executeCommand(de.id,{unitId:t,drawings:[I]})}async _insertCellImage(r){let n;try{n=await this._imageIoService.saveImage(r)}catch(_){const I=_.message;I===O.ImageUploadStatusType.ERROR_EXCEED_SIZE?this._messageService.show({type:J.MessageType.Error,content:this._localeService.t("update-status.exceedMaxSize",String(O.DRAWING_IMAGE_ALLOW_SIZE/(1024*1024)))}):I===O.ImageUploadStatusType.ERROR_IMAGE_TYPE?this._messageService.show({type:J.MessageType.Error,content:this._localeService.t("update-status.invalidImageType")}):I===O.ImageUploadStatusType.ERROR_IMAGE&&this._messageService.show({type:J.MessageType.Error,content:this._localeService.t("update-status.invalidImage")})}if(n==null)return;const{imageId:e,imageSourceType:t,source:o,base64Cache:a}=n,{width:c,height:l,image:h}=await O.getImageSize(a||"");this._imageIoService.addImageSourceCache(o,t,h);const u=this._workbookSelections.getCurrentLastSelection();if(!u)return!1;const s=d.createDocumentModelWithStyle("",{}),g=Je(this._injector,{unitId:this._context.unitId,subUnitId:this._context.unit.getActiveSheet().getSheetId(),row:u.primary.actualRow,col:u.primary.actualColumn},c,l,0);if(!g)return!1;const m={size:{width:g.width,height:g.height},positionH:{relativeFrom:d.ObjectRelativeFromH.PAGE,posOffset:0},positionV:{relativeFrom:d.ObjectRelativeFromV.PARAGRAPH,posOffset:0},angle:0},f={unitId:s.getUnitId(),subUnitId:s.getUnitId(),drawingId:e,drawingType:d.DrawingTypeEnum.DRAWING_IMAGE,imageSourceType:t,source:o,transform:xe.docDrawingPositionToTransform(m),docTransform:m,behindDoc:d.BooleanNumber.FALSE,title:"",description:"",layoutType:d.PositionedObjectLayoutType.INLINE,wrapText:d.WrapTextType.BOTH_SIDES,distB:0,distL:0,distR:0,distT:0},S=d.BuildTextUtils.drawing.add({documentDataModel:s,drawings:[f],selection:{collapsed:!0,startOffset:0,endOffset:0}});return S?(s.apply(S),this._commandService.syncExecuteCommand(v.SetRangeValuesCommand.id,{value:{[u.primary.actualRow]:{[u.primary.actualColumn]:{p:s.getSnapshot(),t:1}}}})):!1}_getUnitInfo(){const r=this._context.unit,n=r.getActiveSheet(),e=r.getUnitId(),t=n.getSheetId();return{unitId:e,subUnitId:t}}_getImagePosition(r,n,e,t){const o=this._workbookSelections.getCurrentSelections();let a={startRow:0,endRow:0,startColumn:0,endColumn:0};o&&o.length>0&&(a=o[o.length-1].range);const c=U.attachRangeWithCoord(this._skeletonManagerService.getCurrent().skeleton,a);if(c==null)return;let{startColumn:l,startRow:h,startX:u,startY:s}=c,g=!1;if(u+r>e&&(u=e-r,u<0&&(u=0,r=e),g=!0),s+n>t&&(s=t-n,s<0&&(s=0,n=t),g=!0),g){const _=this._selectionRenderService.getCellWithCoordByOffset(u,s);if(_==null)return;u=_.startX,s=_.startY,l=_.actualColumn,h=_.actualRow}const m={column:l,columnOffset:0,row:h,rowOffset:0},f=this._selectionRenderService.getCellWithCoordByOffset(u+r,s+n);if(f==null)return;const S={column:f.actualColumn,columnOffset:u+r-f.startX,row:f.actualRow,rowOffset:s+n-f.startY};return{from:m,to:S}}_updateOrderListener(){this.disposeWithMe(this._drawingManagerService.featurePluginOrderUpdate$.subscribe(r=>{const{unitId:n,subUnitId:e,drawingIds:t,arrangeType:o}=r;this._commandService.executeCommand(Ne.id,{unitId:n,subUnitId:e,drawingIds:t,arrangeType:o})}))}_updateImageListener(){this.disposeWithMe(this._drawingManagerService.featurePluginUpdate$.subscribe(r=>{const n=[];r.length!==0&&(r.forEach(e=>{const{unitId:t,subUnitId:o,drawingId:a,drawingType:c,transform:l}=e;if(l==null)return;const h=this._sheetDrawingService.getDrawingByParam({unitId:t,subUnitId:o,drawingId:a});if(h==null||h.unitId!==this._context.unitId)return;const u=F({...h.transform,...l},this._selectionRenderService);if(u==null)return;const s={...e,transform:{...h.transform,...l,...V(u,this._selectionRenderService,this._skeletonManagerService)},sheetTransform:{...u}};n.push(s)}),n.length>0&&this._commandService.executeCommand(le.id,{unitId:r[0].unitId,drawings:n}))}))}_groupDrawingListener(){this.disposeWithMe(this._drawingManagerService.featurePluginGroupUpdate$.subscribe(r=>{this._commandService.executeCommand(Ue.id,r);const{unitId:n,subUnitId:e,drawingId:t}=r[0].parent;this._commandService.syncExecuteCommand(O.SetDrawingSelectedOperation.id,[{unitId:n,subUnitId:e,drawingId:t}])})),this.disposeWithMe(this._drawingManagerService.featurePluginUngroupUpdate$.subscribe(r=>{this._commandService.executeCommand(je.id,r)}))}_focusDrawingListener(){this.disposeWithMe(this._drawingManagerService.focus$.subscribe(r=>{r==null||r.length===0?(this._contextService.setContextValue(d.FOCUSING_COMMON_DRAWINGS,!1),this._sheetDrawingService.focusDrawing([])):(this._contextService.setContextValue(d.FOCUSING_COMMON_DRAWINGS,!0),this._sheetDrawingService.focusDrawing(r))}))}};ue=yt([z(1,d.Inject(U.SheetSkeletonManagerService)),z(2,d.ICommandService),z(3,U.ISheetSelectionRenderService),z(4,O.IImageIoService),z(5,k.ILocalFileService),z(6,p.ISheetDrawingService),z(7,O.IDrawingManagerService),z(8,d.IContextService),z(9,k.IMessageService),z(10,d.Inject(d.LocaleService)),z(11,d.Inject(v.SheetsSelectionsService)),z(12,d.Inject(d.Injector))],ue);var Dt=Object.defineProperty,Tt=Object.getOwnPropertyDescriptor,Rt=(i,r,n,e)=>{for(var t=e>1?void 0:e?Tt(r,n):r,o=i.length-1,a;o>=0;o--)(a=i[o])&&(t=(e?a(r,n,t):a(t))||t);return e&&t&&Dt(r,n,t),t},re=(i,r)=>(n,e)=>r(n,e,i);function We(i,r,n){var e,t,o,a;if(((t=(e=n==null?void 0:n.p)==null?void 0:e.body)==null?void 0:t.dataStream.length)===3&&((a=(o=n.p)==null?void 0:o.drawingsOrder)==null?void 0:a.length)===1){const c=n.p.drawings[n.p.drawingsOrder[0]],l=Je(i,{unitId:r.unitId,subUnitId:r.subUnitId,row:r.row,col:r.col},c.docTransform.size.width,c.docTransform.size.height,c.docTransform.angle);if(l)return c.transform.width=l.width,c.transform.height=l.height,c.docTransform.size.width=l.width,c.docTransform.size.height=l.height,c.transform.left=0,c.transform.top=0,c.docTransform.positionH.posOffset=0,c.docTransform.positionV.posOffset=0,n.p.documentStyle.pageSize.width=1/0,n.p.documentStyle.pageSize.height=1/0,!0}return!1}let Se=class extends d.Disposable{constructor(i,r,n,e,t,o,a){super(),this._commandService=i,this._sheetInterceptorService=r,this._univerInstanceService=n,this._injector=e,this._drawingManagerService=t,this._docDrawingController=o,this._editorBridgeService=a,this._initHandleResize(),this._handleInitEditor(),this._handleWriteCell(),this._initCellContentInterceptor()}_initHandleResize(){this.disposeWithMe(this._commandService.onCommandExecuted(i=>{let r,n=[];if(i.id===v.SetWorksheetRowHeightMutation.id){const e=i.params;n=e.ranges,r=v.getSheetCommandTarget(this._univerInstanceService,{unitId:e.unitId,subUnitId:e.subUnitId})}else if(i.id===v.SetWorksheetColWidthMutation.id){const e=i.params;n=e.ranges,r=v.getSheetCommandTarget(this._univerInstanceService,{unitId:e.unitId,subUnitId:e.subUnitId})}else if(i.id===v.SetWorksheetRowIsAutoHeightMutation.id){const e=i.params;n=e.ranges,r=v.getSheetCommandTarget(this._univerInstanceService,{unitId:e.unitId,subUnitId:e.subUnitId})}else if(i.id===v.SetWorksheetRowAutoHeightMutation.id){const e=i.params;r=v.getSheetCommandTarget(this._univerInstanceService,{unitId:e.unitId,subUnitId:e.subUnitId}),n=e.rowsAutoHeightInfo.map(t=>({startRow:t.row,endRow:t.row,startColumn:0,endColumn:9999}))}else if(i.id===v.AddWorksheetMergeMutation.id){const e=i.params;n=e.ranges,r=v.getSheetCommandTarget(this._univerInstanceService,{unitId:e.unitId,subUnitId:e.subUnitId})}else if(i.id===v.RemoveWorksheetMergeMutation.id){const e=i.params;n=e.ranges,r=v.getSheetCommandTarget(this._univerInstanceService,{unitId:e.unitId,subUnitId:e.subUnitId})}r&&n.length&&n.forEach(e=>{const t=d.Range.transformRange(e,r.worksheet);for(let o=t.startRow;o<=t.endRow;o++)for(let a=t.startColumn;a<=t.endColumn;a++)We(this._injector,{unitId:r.unitId,subUnitId:r.subUnitId,row:o,col:a},r.worksheet.getCellRaw(o,a))})}))}_handleInitEditor(){this.disposeWithMe(this._editorBridgeService.visible$.subscribe(i=>{i.visible?i.visible&&(this._drawingManagerService.removeDrawingDataForUnit(d.DOCS_NORMAL_EDITOR_UNIT_ID_KEY),this._docDrawingController.loadDrawingDataForUnit(d.DOCS_NORMAL_EDITOR_UNIT_ID_KEY),this._drawingManagerService.initializeNotification(d.DOCS_NORMAL_EDITOR_UNIT_ID_KEY)):this._drawingManagerService.removeDrawingDataForUnit(d.DOCS_NORMAL_EDITOR_UNIT_ID_KEY)})),this.disposeWithMe(this._commandService.onCommandExecuted(i=>{i.id===xe.ReplaceSnapshotCommand.id&&i.params.unitId===d.DOCS_ZEN_EDITOR_UNIT_ID_KEY&&(this._drawingManagerService.removeDrawingDataForUnit(d.DOCS_ZEN_EDITOR_UNIT_ID_KEY),this._docDrawingController.loadDrawingDataForUnit(d.DOCS_ZEN_EDITOR_UNIT_ID_KEY),this._drawingManagerService.initializeNotification(d.DOCS_ZEN_EDITOR_UNIT_ID_KEY))}))}_handleWriteCell(){this.disposeWithMe(this._sheetInterceptorService.writeCellInterceptor.intercept(v.AFTER_CELL_EDIT,{priority:9999,handler:(i,r,n)=>(We(this._injector,{unitId:r.unitId,subUnitId:r.subUnitId,row:r.row,col:r.col},i),n(i))}))}_initCellContentInterceptor(){this.disposeWithMe(this._sheetInterceptorService.intercept(v.INTERCEPTOR_POINT.CELL_CONTENT,{effect:d.InterceptorEffectEnum.Style,priority:v.InterceptCellContentPriority.CELL_IMAGE,handler:(i,r,n)=>{var e;return i!=null&&i.p&&((e=i.p.drawingsOrder)!=null&&e.length)&&(i.interceptorStyle||(i.interceptorStyle={}),i.interceptorStyle.tr={a:0}),n(i)}}))}};Se=Rt([re(0,d.ICommandService),re(1,d.Inject(v.SheetInterceptorService)),re(2,d.IUniverInstanceService),re(3,d.Inject(d.Injector)),re(4,O.IDrawingManagerService),re(5,d.Inject(ne.DocDrawingController)),re(6,d.Inject(U.IEditorBridgeService))],Se);var bt=Object.defineProperty,Et=Object.getOwnPropertyDescriptor,Ot=(i,r,n,e)=>{for(var t=e>1?void 0:e?Et(r,n):r,o=i.length-1,a;o>=0;o--)(a=i[o])&&(t=(e?a(r,n,t):a(t))||t);return e&&t&&bt(r,n,t),t},Ze=(i,r)=>(n,e)=>r(n,e,i);let _e=class extends d.Disposable{constructor(i,r){super(),this._autoFillService=i,this._injector=r,this._initAutoFillHooks()}_initAutoFillHooks(){this.disposeWithMe(this._autoFillService.addHook({id:"sheet-cell-image-autofill",onBeforeSubmit:(i,r,n,e)=>{new d.ObjectMatrix(e).forValue((t,o,a)=>{We(this._injector,{unitId:i.unitId,subUnitId:i.subUnitId,row:t,col:o},a)})}}))}};_e=Ot([Ze(0,d.Inject(U.IAutoFillService)),Ze(1,d.Inject(d.Injector))],_e);var Pt=Object.defineProperty,At=Object.getOwnPropertyDescriptor,Ut=(i,r,n,e)=>{for(var t=e>1?void 0:e?At(r,n):r,o=i.length-1,a;o>=0;o--)(a=i[o])&&(t=(e?a(r,n,t):a(t))||t);return e&&t&&Pt(r,n,t),t},ve=(i,r)=>(n,e)=>r(n,e,i);let we=class extends d.Disposable{constructor(r,n,e,t){super();Y(this,"_isSetCursor",!1);this._hoverManagerService=r,this._renderManagerService=n,this._selectionsService=e,this._drawingRenderService=t}_initHover(){}_initImageClick(){}};we=Ut([ve(0,d.Inject(U.HoverManagerService)),ve(1,d.Inject(N.IRenderManagerService)),ve(2,d.Inject(v.SheetsSelectionsService)),ve(3,d.Inject(q.DrawingRenderService))],we);var Nt=Object.defineProperty,jt=Object.getOwnPropertyDescriptor,Wt=(i,r,n,e)=>{for(var t=e>1?void 0:e?jt(r,n):r,o=i.length-1,a;o>=0;o--)(a=i[o])&&(t=(e?a(r,n,t):a(t))||t);return e&&t&&Nt(r,n,t),t},Le=(i,r)=>(n,e)=>r(n,e,i);let Ie=class extends d.Disposable{constructor(r,n,e){super();Y(this,"_copyInfo");this._sheetClipboardService=r,this._renderManagerService=n,this._sheetDrawingService=e,this._initCopyPaste()}_initCopyPaste(){this._sheetClipboardService.addClipboardHook({id:"SHEET_IMAGE_UI_PLUGIN",onBeforeCopy:(r,n,e)=>this._collect(r,n,e),onPasteCells:(r,n,e,t)=>{const{copyType:o=U.COPY_TYPE.COPY,pasteType:a}=t,{range:c}=r||{},{range:l,unitId:h,subUnitId:u}=n;return this._generateMutations(l,{copyType:o,pasteType:a,copyRange:c,unitId:h,subUnitId:u})},onPastePlainText:(r,n)=>({undos:[],redos:[]})})}_collect(r,n,e){var g;const t=(g=this._renderManagerService.getRenderById(r))==null?void 0:g.with(U.SheetSkeletonManagerService);if(!t)return;const o=t.attachRangeWithCoord(e);if(!o)return;const{startX:a,endX:c,startY:l,endY:h}=o,u=this._sheetDrawingService.getDrawingData(r,n),s=[];Object.keys(u).forEach(m=>{const f=u[m],{transform:S}=f;if(f.anchorType!==p.SheetDrawingAnchorType.Both||!S)return;const{left:_=0,top:I=0,width:M=0,height:y=0}=S,{drawingStartX:R,drawingEndX:C,drawingStartY:T,drawingEndY:w}={drawingStartX:_,drawingEndX:_+M,drawingStartY:I,drawingEndY:I+y};a<=R&&C<=c&&l<=T&&w<=h&&s.push(f)}),s.length&&(this._copyInfo={drawings:s,unitId:r,subUnitId:n})}_generateMutations(r,n){var B;if(!this._copyInfo)return{redos:[],undos:[]};if([U.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_COL_WIDTH,U.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_VALUE,U.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMAT,U.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMULA].includes(n.pasteType))return{redos:[],undos:[]};const{copyRange:t}=n;if(!t)return{redos:[],undos:[]};const{drawings:o,unitId:a,subUnitId:c}=this._copyInfo,{ranges:[l,h],mapFunc:u}=U.virtualizeDiscreteRanges([t,r]),{row:s,col:g}=u(l.startRow,l.startColumn),{row:m,col:f}=u(h.startRow,h.startColumn),S=(B=this._renderManagerService.getRenderById(a))==null?void 0:B.with(U.SheetSkeletonManagerService);if(!S)return{redos:[],undos:[]};const _=S.attachRangeWithCoord({startRow:s,endRow:s,startColumn:g,endColumn:g}),I=S.attachRangeWithCoord({startRow:m,endRow:m,startColumn:f,endColumn:f});if(!_||!I)return{redos:[],undos:[]};const M=[],y=[],R=I.startX-_.startX,C=I.startY-_.startY,T=m-s,w=f-g,A=n.copyType===U.COPY_TYPE.CUT,{_sheetDrawingService:E}=this;return o.forEach(W=>{const{transform:P,sheetTransform:D}=W;if(!P)return;const L={...W,unitId:a,subUnitId:c,drawingId:A?W.drawingId:d.Tools.generateRandomId(),transform:{...P,left:P.left+R,top:P.top+C},sheetTransform:{to:{...D.to,row:D.to.row+T,column:D.to.column+w},from:{...D.from,row:D.from.row+T,column:D.from.column+w}}};if(A){const{undo:$,redo:oe,objects:Z}=E.getBatchUpdateOp([L]);M.push({id:p.SetDrawingApplyMutation.id,params:{unitId:a,subUnitId:c,type:p.DrawingApplyType.UPDATE,op:oe,objects:Z}}),y.push({id:p.SetDrawingApplyMutation.id,params:{unitId:a,subUnitId:c,type:p.DrawingApplyType.UPDATE,op:$,objects:Z}})}else{const{undo:$,redo:oe,objects:Z}=E.getBatchAddOp([L]);M.push({id:p.SetDrawingApplyMutation.id,params:{op:oe,unitId:a,subUnitId:c,objects:Z,type:p.DrawingApplyType.INSERT}}),y.push({id:p.SetDrawingApplyMutation.id,params:{op:$,unitId:a,subUnitId:c,objects:Z,type:p.DrawingApplyType.REMOVE}})}}),{redos:M,undos:y}}};Ie=Wt([Le(0,U.ISheetClipboardService),Le(1,N.IRenderManagerService),Le(2,p.ISheetDrawingService)],Ie);var Lt=Object.defineProperty,Bt=Object.getOwnPropertyDescriptor,Gt=(i,r,n,e)=>{for(var t=e>1?void 0:e?Bt(r,n):r,o=i.length-1,a;o>=0;o--)(a=i[o])&&(t=(e?a(r,n,t):a(t))||t);return e&&t&&Lt(r,n,t),t},me=(i,r)=>(n,e)=>r(n,e,i);let Ce=class extends d.Disposable{constructor(i,r,n,e,t){super(),this._drawingManagerService=i,this._renderManagerService=r,this._permissionService=n,this._univerInstanceService=e,this._userManagerService=t,this._initDrawingVisible(),this._initDrawingEditable(),this._initViewPermissionChange(),this._initEditPermissionChange()}_initDrawingVisible(){const i=this._univerInstanceService.getCurrentTypeOfUnit$(d.UniverInstanceType.UNIVER_SHEET);this.disposeWithMe(j.combineLatest([i,this._userManagerService.currentUser$]).subscribe(([r,n])=>{if(!r){this._drawingManagerService.setDrawingVisible(!1);return}r.activeSheet$.subscribe(e=>{if(!e){this._drawingManagerService.setDrawingVisible(!1);return}const t=r.getUnitId(),o=e.getSheetId();if(this._permissionService.composePermission([new v.WorkbookViewPermission(t).id,new v.WorksheetViewPermission(t,o).id]).every(c=>c.value))this._drawingManagerService.setDrawingVisible(!0);else{this._drawingManagerService.setDrawingVisible(!1);const c=r.getUnitId(),l=e.getSheetId(),h=this._drawingManagerService.getDrawingData(c,l),u=Object.values(h),s=this._renderManagerService.getRenderById(c),g=s==null?void 0:s.scene;if(g==null)return;g.getAllObjectsByOrder().forEach(f=>{f.classType===N.RENDER_CLASS_TYPE.IMAGE&&u.some(S=>f.oKey.includes(S.drawingId))&&g.removeObject(f)})}})}))}_initDrawingEditable(){const i=this._univerInstanceService.getCurrentTypeOfUnit$(d.UniverInstanceType.UNIVER_SHEET);this.disposeWithMe(j.combineLatest([i,this._userManagerService.currentUser$]).subscribe(([r,n])=>{if(!r){this._drawingManagerService.setDrawingEditable(!1);return}r.activeSheet$.subscribe(e=>{if(!e){this._drawingManagerService.setDrawingEditable(!1);return}const t=r.getUnitId(),o=e.getSheetId();if(this._permissionService.composePermission([new v.WorkbookEditablePermission(t).id,new v.WorksheetEditPermission(t,o).id]).every(c=>c.value))this._drawingManagerService.setDrawingEditable(!0);else{this._drawingManagerService.setDrawingEditable(!1);const c=r.getUnitId(),l=e.getSheetId(),h=this._drawingManagerService.getDrawingData(c,l),u=Object.values(h),s=this._renderManagerService.getRenderById(c),g=s==null?void 0:s.scene;if(g==null)return;g.getAllObjectsByOrder().forEach(f=>{f.classType===N.RENDER_CLASS_TYPE.IMAGE&&u.some(S=>f.oKey.includes(S.drawingId))&&g.detachTransformerFrom(f)})}})}))}_initViewPermissionChange(){const i=this._univerInstanceService.getCurrentTypeOfUnit$(d.UniverInstanceType.UNIVER_SHEET);this.disposeWithMe(j.combineLatest([i,this._userManagerService.currentUser$]).subscribe(([r,n])=>{r&&r.activeSheet$.subscribe(e=>{var s;if(!e)return;const t=r.getUnitId(),o=e.getSheetId();let a=!0;const c=this._renderManagerService.getRenderById(t),l=c==null?void 0:c.scene;if(l==null)return;const h=l.getTransformerByCreate(),u=this._permissionService.composePermission$([new v.WorkbookViewPermission(t).id,new v.WorksheetViewPermission(t,o).id]).pipe(j.map(g=>g.every(m=>m.value)));u==null||u.pipe(j.filter(g=>g!==a),j.distinctUntilChanged()).subscribe({next:g=>{a=g,this._drawingManagerService.setDrawingVisible(g);const m=l.getAllObjectsByOrder(),f=this._drawingManagerService.getDrawingData(t,o),S=Object.values(f);g?this._drawingManagerService.addNotification(S):(m.forEach(_=>{_.classType===N.RENDER_CLASS_TYPE.IMAGE&&S.some(I=>_.oKey.includes(I.drawingId))&&l.removeObject(_)}),h.clearSelectedObjects())}}),(s=this._permissionService.getPermissionPoint$(new v.WorksheetViewPermission(t,o).id))==null||s.pipe(j.filter(g=>g.value!==a),j.distinctUntilChanged()).subscribe({complete:()=>{a=!0,this._drawingManagerService.setDrawingVisible(!0);const g=this._drawingManagerService.getDrawingData(t,o),m=Object.values(g);this._drawingManagerService.addNotification(m)}})})}))}_initEditPermissionChange(){const i=this._univerInstanceService.getCurrentTypeOfUnit$(d.UniverInstanceType.UNIVER_SHEET);this.disposeWithMe(j.combineLatest([i,this._userManagerService.currentUser$]).subscribe(([r,n])=>{r&&r.activeSheet$.subscribe(e=>{var s;if(!e)return;const t=r.getUnitId(),o=e.getSheetId();let a=!0;const c=this._renderManagerService.getRenderById(t),l=c==null?void 0:c.scene;if(l==null)return;const h=l.getTransformerByCreate(),u=this._permissionService.composePermission$([new v.WorkbookEditablePermission(t).id,new v.WorksheetEditPermission(t,o).id]).pipe(j.map(g=>g.every(m=>m.value)));u==null||u.pipe(j.filter(g=>g!==a),j.distinctUntilChanged()).subscribe({next:g=>{a=g,this._drawingManagerService.setDrawingEditable(g);const m=l.getAllObjectsByOrder(),f=this._drawingManagerService.getDrawingData(t,o),S=Object.values(f);g?(m.forEach(_=>{_.classType===N.RENDER_CLASS_TYPE.IMAGE&&S.some(I=>_.oKey.includes(I.drawingId))&&l.attachTransformerTo(_)}),this._drawingManagerService.addNotification(S)):(m.forEach(_=>{_.classType===N.RENDER_CLASS_TYPE.IMAGE&&S.some(I=>_.oKey.includes(I.drawingId))&&l.detachTransformerFrom(_)}),h.clearSelectedObjects())}}),(s=this._permissionService.getPermissionPoint$(new v.WorksheetEditPermission(t,o).id))==null||s.pipe(j.filter(g=>g.value!==a),j.distinctUntilChanged()).subscribe({complete:()=>{a=!0;const g=r.getUnitId(),m=e.getSheetId(),f=this._drawingManagerService.getDrawingData(g,m),S=Object.values(f),_=this._renderManagerService.getRenderById(g),I=_==null?void 0:_.scene;if(I==null)return;this._drawingManagerService.setDrawingEditable(!0),I.getAllObjectsByOrder().forEach(y=>{y.classType===N.RENDER_CLASS_TYPE.IMAGE&&S.some(R=>y.oKey.includes(R.drawingId))&&I.detachTransformerFrom(y)})}})})}))}};Ce=Gt([me(0,O.IDrawingManagerService),me(1,N.IRenderManagerService),me(2,d.IPermissionService),me(3,d.IUniverInstanceService),me(4,d.Inject(d.UserManagerService))],Ce);var kt=Object.defineProperty,Ft=Object.getOwnPropertyDescriptor,$t=(i,r,n,e)=>{for(var t=e>1?void 0:e?Ft(r,n):r,o=i.length-1,a;o>=0;o--)(a=i[o])&&(t=(e?a(r,n,t):a(t))||t);return e&&t&&kt(r,n,t),t},ye=(i,r)=>(n,e)=>r(n,e,i);let Me=class extends d.Disposable{constructor(i,r,n,e){super(),this._sheetPrintInterceptorService=i,this._drawingRenderService=r,this._drawingManagerService=n,this._renderManagerService=e,this._initPrinting()}_initPrinting(){this.disposeWithMe(this._sheetPrintInterceptorService.interceptor.intercept(this._sheetPrintInterceptorService.interceptor.getInterceptPoints().PRINTING_COMPONENT_COLLECT,{handler:(i,r,n)=>{const{unitId:e,scene:t,subUnitId:o}=r,a=this._drawingManagerService.getDrawingDataForUnit(e),c=a==null?void 0:a[o];return c&&c.order.forEach(l=>{this._drawingRenderService.renderDrawing(c.data[l],t)}),n()}})),this.disposeWithMe(this._sheetPrintInterceptorService.interceptor.intercept(this._sheetPrintInterceptorService.interceptor.getInterceptPoints().PRINTING_RANGE,{handler:(i,r,n)=>{const{unitId:e,subUnitId:t}=r,o=this._renderManagerService.getRenderById(e);if(!o)return n(i);const a=o.with(U.SheetSkeletonManagerService).getWorksheetSkeleton(t);if(!a)return n(i);const c=this._drawingManagerService.getDrawingDataForUnit(e),l=c==null?void 0:c[r.subUnitId];if(!l)return n(i);const{scaleX:h,scaleY:u}=o.scene,s=i?{...i}:{startColumn:0,endColumn:0,endRow:0,startRow:0},g=l.order.map(m=>l.data[m]).filter(m=>m.drawingType!==d.DrawingTypeEnum.DRAWING_DOM);return g.length?(g.forEach(m=>{if(!m.groupId&&m.transform&&d.Tools.isDefine(m.transform.left)&&d.Tools.isDefine(m.transform.top)&&d.Tools.isDefine(m.transform.width)&&d.Tools.isDefine(m.transform.height)){const f=a.skeleton.getCellIndexByOffset(m.transform.left,m.transform.top,h,u,{x:0,y:0}),S=a.skeleton.getCellIndexByOffset(m.transform.left+m.transform.width,m.transform.top+m.transform.height,h,u,{x:0,y:0});f.column<s.startColumn&&(s.startColumn=f.column),f.row<s.startRow&&(s.startRow=f.row),s.endRow<S.row&&(s.endRow=S.row),s.endColumn<S.column&&(s.endColumn=S.column)}}),n(s)):n(i)}}))}};Me=$t([ye(0,d.Inject(U.SheetPrintInterceptorService)),ye(1,d.Inject(q.DrawingRenderService)),ye(2,O.IDrawingManagerService),ye(3,N.IRenderManagerService)],Me);var Ht=Object.defineProperty,Vt=Object.getOwnPropertyDescriptor,xt=(i,r,n,e)=>{for(var t=e>1?void 0:e?Vt(r,n):r,o=i.length-1,a;o>=0;o--)(a=i[o])&&(t=(e?a(r,n,t):a(t))||t);return e&&t&&Ht(r,n,t),t},ee=(i,r)=>(n,e)=>r(n,e,i);const Yt=[v.InsertRowCommand.id,v.InsertColCommand.id,v.RemoveRowCommand.id,v.RemoveColCommand.id,v.DeleteRangeMoveLeftCommand.id,v.DeleteRangeMoveUpCommand.id,v.InsertRangeMoveDownCommand.id,v.InsertRangeMoveRightCommand.id,v.DeltaRowHeightCommand.id,v.SetRowHeightCommand.id,v.DeltaColumnWidthCommand.id,v.SetColWidthCommand.id,v.SetRowHiddenCommand.id,v.SetSpecificRowsVisibleCommand.id,v.SetSpecificColsVisibleCommand.id,v.SetColHiddenCommand.id,v.MoveColsCommand.id,v.MoveRowsCommand.id,v.MoveRangeCommand.id],Xt=[v.SetRowVisibleMutation.id,v.SetRowHiddenMutation.id,v.SetColVisibleMutation.id,v.SetColHiddenMutation.id,v.SetWorksheetRowHeightMutation.id,v.SetWorksheetColWidthMutation.id];let Be=class extends d.Disposable{constructor(i,r,n,e,t,o,a,c,l){super(),this._context=i,this._renderManagerService=r,this._commandService=n,this._selectionRenderService=e,this._skeletonManagerService=t,this._sheetInterceptorService=o,this._sheetDrawingService=a,this._drawingManagerService=c,this._univerInstanceService=l,this._sheetInterceptorListener(),this._commandListener(),this._sheetRefreshListener()}_sheetInterceptorListener(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:i=>{if(!Yt.includes(i.id))return{redos:[],undos:[]};if(i.params==null)return{redos:[],undos:[]};const r=i.id;if(r===v.InsertRowCommand.id)return this._moveRowInterceptor(i.params,"insert");if([v.MoveColsCommand.id,v.MoveRowsCommand.id,v.MoveRangeCommand.id].includes(r))return this._moveRangeInterceptor(i.params);if(r===v.InsertColCommand.id)return this._moveColInterceptor(i.params,"insert");if(r===v.RemoveRowCommand.id)return this._moveRowInterceptor(i.params,"remove");if(r===v.RemoveColCommand.id)return this._moveColInterceptor(i.params,"remove");if(r===v.DeleteRangeMoveLeftCommand.id){const{range:n}=i.params;return this._getRangeMoveUndo(n,0)}else if(r===v.DeleteRangeMoveUpCommand.id){const{range:n}=i.params;return this._getRangeMoveUndo(n,1)}else if(r===v.InsertRangeMoveDownCommand.id){const{range:n}=i.params;return this._getRangeMoveUndo(n,2)}else if(r===v.InsertRangeMoveRightCommand.id){const{range:n}=i.params;return this._getRangeMoveUndo(n,3)}else if(r===v.SetRowHiddenCommand.id||r===v.SetSpecificRowsVisibleCommand.id){const n=i.params,{unitId:e,subUnitId:t,ranges:o}=n;return this._getDrawingUndoForRowVisible(e,t,o)}else if(r===v.SetSpecificColsVisibleCommand.id||r===v.SetColHiddenCommand.id){const n=i.params,{unitId:e,subUnitId:t,ranges:o}=n;return this._getDrawingUndoForColVisible(e,t,o)}else if(r===v.DeltaRowHeightCommand.id||r===v.SetRowHeightCommand.id||r===v.DeltaColumnWidthCommand.id||r===v.SetColWidthCommand.id){const n=i.params,{unitId:e,subUnitId:t,ranges:o}=n,a=r===v.DeltaRowHeightCommand.id||r===v.SetRowHeightCommand.id;return this._getDrawingUndoForRowAndColSize(e,t,o,a)}return{redos:[],undos:[]}}}))}_getRangeMoveUndo(i,r){const n=v.getSheetCommandTarget(this._univerInstanceService);if(n==null)return{redos:[],undos:[]};const e=n.unitId,t=n.subUnitId,o=[],a=[],c=this._sheetDrawingService.getDrawingData(e,t),l=[],h=[];if(Object.keys(c).forEach(u=>{const s=c[u],{updateDrawings:g,deleteDrawings:m}=this._getUpdateOrDeleteDrawings(i,r,s);l.push(...g),h.push(...m)}),l.length===0&&h.length===0)return{redos:[],undos:[]};if(l.length>0){const u=this._sheetDrawingService.getBatchUpdateOp(l),{undo:s,redo:g,objects:m}=u;o.push({id:p.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:g,objects:m,type:p.DrawingApplyType.UPDATE}}),a.push({id:p.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:s,objects:m,type:p.DrawingApplyType.UPDATE}})}if(h.length>0){const u=this._sheetDrawingService.getBatchRemoveOp(h),s=u.undo,g=u.redo,m=u.objects;o.push({id:p.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:g,objects:m,type:p.DrawingApplyType.REMOVE}}),a.push({id:p.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:s,objects:m,type:p.DrawingApplyType.INSERT}})}return o.push({id:G.id,params:[e]}),a.push({id:G.id,params:[e]}),{redos:o,undos:a}}_getUpdateOrDeleteDrawings(i,r,n){const e=[],t=[],{sheetTransform:o,anchorType:a=p.SheetDrawingAnchorType.Position,transform:c,unitId:l,subUnitId:h,drawingId:u}=n,{from:s,to:g}=o,{row:m,column:f}=s,{row:S,column:_}=g;if(o==null||c==null)return{updateDrawings:e,deleteDrawings:t};const{startRow:I,endRow:M,startColumn:y,endColumn:R}=i;let C=null,T=null;if(r===0&&m>=I&&S<=M)if(f>=y&&_<=R)t.push({unitId:l,subUnitId:h,drawingId:u});else{const w=this._shrinkCol(o,c,y,R,a);C=w==null?void 0:w.newSheetTransform,T=w==null?void 0:w.newTransform}else if(r===1&&f>=y&&_<=R)if(m>=I&&S<=M)t.push({unitId:l,subUnitId:h,drawingId:u});else{const w=this._shrinkRow(o,c,I,M,a);C=w==null?void 0:w.newSheetTransform,T=w==null?void 0:w.newTransform}else if(r===2){const w=this._expandRow(o,c,I,M,a);C=w==null?void 0:w.newSheetTransform,T=w==null?void 0:w.newTransform}else if(r===3){const w=this._expandCol(o,c,y,R,a);C=w==null?void 0:w.newSheetTransform,T=w==null?void 0:w.newTransform}if(C!=null&&T!=null){const w=V(C,this._selectionRenderService,this._skeletonManagerService);e.push({...n,sheetTransform:C,transform:w})}return{updateDrawings:e,deleteDrawings:t}}_remainDrawingSize(i,r,n){const e=F({...i},this._selectionRenderService);e!=null&&r.push({...n,sheetTransform:e})}_getDrawingUndoForColVisible(i,r,n){const e=this._drawingManagerService.getDrawingData(i,r),t=[],o=[];if(Object.keys(e).forEach(u=>{const s=e[u],{sheetTransform:g,transform:m,anchorType:f=p.SheetDrawingAnchorType.Position}=s;if(f===p.SheetDrawingAnchorType.None)this._remainDrawingSize(m,t,s);else{const{from:S,to:_}=g,{row:I,column:M}=S,{row:y,column:R}=_;for(let C=0;C<n.length;C++){const T=n[C],{startRow:w,endRow:A,startColumn:E,endColumn:B}=T;if(R<E)continue;if(f===p.SheetDrawingAnchorType.Position){let D=null,L=null;if(M>=E&&M<=B){const $=this._skeletonManagerService.attachRangeWithCoord({startColumn:M,endColumn:B,startRow:S.row,endRow:_.row});if($==null)return;L={...m,left:$.startX}}if(L!=null&&(D=F(L,this._selectionRenderService),D!=null&&L!=null)){t.push({...s,sheetTransform:D,transform:L});break}this._remainDrawingSize(m,t,s);continue}if(M>=E&&R<=B)continue;let W=null,P=null;if(M>=E&&M<=B){const D=this._skeletonManagerService.attachRangeWithCoord({startColumn:M,endColumn:B,startRow:S.row,endRow:_.row});if(D==null)return;P={...m,left:(D==null?void 0:D.startX)||0,width:((m==null?void 0:m.width)||0)-D.endX+D.startX}}else if(R>=E&&R<=B){const D=this._skeletonManagerService.attachRangeWithCoord({startColumn:E,endColumn:R,startRow:S.row,endRow:_.row});if(D==null)return;P={...m,left:D.startX-((m==null?void 0:m.width)||0)}}else{const D=this._skeletonManagerService.attachRangeWithCoord({startColumn:E,endColumn:B,startRow:S.row,endRow:_.row});if(D==null)return;if(P={...m,width:((m==null?void 0:m.width)||0)-D.endX+D.startX},W=F(P,this._selectionRenderService),W!=null&&P!=null){o.push({...s,sheetTransform:W,transform:P});break}}if(P!=null&&(W=F(P,this._selectionRenderService)),P!=null&&W!=null){t.push({...s,sheetTransform:W,transform:P});break}else this._remainDrawingSize(m,t,s)}}}),t.length===0&&o.length===0)return{redos:[],undos:[]};const{redos:a,undos:c}=this._createUndoAndRedoMutation(i,r,t),l=[],h=[];if(o.length>0){const{redos:u,undos:s}=this._createUndoAndRedoMutation(i,r,o);l.push(...u),h.push(...s)}return{redos:a,undos:c,preRedos:l,preUndos:h}}_createUndoAndRedoMutation(i,r,n){const e=this._sheetDrawingService.getBatchUpdateOp(n),{undo:t,redo:o,objects:a}=e,c=[{id:p.SetDrawingApplyMutation.id,params:{unitId:i,subUnitId:r,op:o,objects:a,type:p.DrawingApplyType.UPDATE}},{id:G.id,params:[i]}],l=[{id:p.SetDrawingApplyMutation.id,params:{unitId:i,subUnitId:r,op:t,objects:a,type:p.DrawingApplyType.UPDATE}},{id:G.id,params:[i]}];return{redos:c,undos:l}}_getDrawingUndoForRowVisible(i,r,n){const e=this._drawingManagerService.getDrawingData(i,r),t=[],o=[];if(Object.keys(e).forEach(u=>{const s=e[u],{sheetTransform:g,transform:m,anchorType:f=p.SheetDrawingAnchorType.Position}=s;if(f===p.SheetDrawingAnchorType.None)this._remainDrawingSize(m,t,s);else{const{from:S,to:_}=g,{row:I,column:M}=S,{row:y,column:R}=_;for(let C=0;C<n.length;C++){const T=n[C],{startRow:w,endRow:A,startColumn:E,endColumn:B}=T;if(y<w)continue;if(f===p.SheetDrawingAnchorType.Position){let D=null,L=null;if(I>=w&&I<=A){const $=this._skeletonManagerService.attachRangeWithCoord({startColumn:S.column,endColumn:_.column,startRow:I,endRow:A});if($==null)return;L={...m,top:$.startY}}if(L!=null&&(D=F(L,this._selectionRenderService),D!=null&&L!=null)){t.push({...s,sheetTransform:D,transform:L});break}this._remainDrawingSize(m,t,s);continue}if(I>=w&&y<=A)continue;let W=null,P=null;if(I>=w&&I<=A){const D=this._skeletonManagerService.attachRangeWithCoord({startColumn:S.column,endColumn:_.column,startRow:I,endRow:A});if(D==null)return;P={...m,top:(D==null?void 0:D.startY)||0,height:((m==null?void 0:m.height)||0)-D.endY+D.startY}}else if(y>=w&&y<=A){const D=this._skeletonManagerService.attachRangeWithCoord({startColumn:S.column,endColumn:_.column,startRow:w,endRow:y});if(D==null)return;P={...m,top:D.startY-((m==null?void 0:m.height)||0)}}else{const D=this._skeletonManagerService.attachRangeWithCoord({startColumn:S.column,endColumn:_.column,startRow:w,endRow:A});if(D==null)return;if(P={...m,height:((m==null?void 0:m.height)||0)-D.endY+D.startY},W=F(P,this._selectionRenderService),W!=null&&P!=null){o.push({...s,sheetTransform:W,transform:P});break}}if(P!=null&&(W=F(P,this._selectionRenderService)),P!=null&&W!=null){t.push({...s,sheetTransform:W,transform:P});break}else this._remainDrawingSize(m,t,s)}}}),t.length===0&&o.length===0)return{redos:[],undos:[]};const{redos:a,undos:c}=this._createUndoAndRedoMutation(i,r,t),l=[],h=[];if(o.length>0){const{redos:u,undos:s}=this._createUndoAndRedoMutation(i,r,o);l.push(...u),h.push(...s)}return{redos:a,undos:c,preRedos:l,preUndos:h}}_getDrawingUndoForRowAndColSize(i,r,n,e){const t=this._drawingManagerService.getDrawingData(i,r),o=[];return Object.keys(t).forEach(a=>{const c=t[a],{sheetTransform:l,transform:h,anchorType:u=p.SheetDrawingAnchorType.Position}=c;if(u===p.SheetDrawingAnchorType.None)this._remainDrawingSize(h,o,c);else{const{from:s,to:g}=l,{row:m,column:f}=s,{row:S,column:_}=g;for(let I=0;I<n.length;I++){const M=n[I],{startRow:y,endRow:R,startColumn:C,endColumn:T}=M;if(S<y||_<C)continue;if(u===p.SheetDrawingAnchorType.Position&&(m<=y&&S>=R||f<=C&&_>=T)){this._remainDrawingSize(h,o,c);continue}const w=V({...l},this._selectionRenderService,this._skeletonManagerService);if(w!=null){o.push({...c,transform:w});break}}}}),o.length===0?{redos:[],undos:[]}:this._createUndoAndRedoMutation(i,r,o)}_getUnitIdAndSubUnitId(i,r){let n,e;if(r==="insert")n=i.unitId,e=i.subUnitId;else{const t=v.getSheetCommandTarget(this._univerInstanceService);if(t==null)return;n=t.unitId,e=t.subUnitId}return{unitId:n,subUnitId:e}}_moveRangeInterceptor(i){var y,R;const{toRange:r,fromRange:n}=i,e=v.getSheetCommandTarget(this._univerInstanceService);if(!e)return{redos:[],undos:[]};const{unitId:t,subUnitId:o}=e,a=(R=(y=this._renderManagerService.getRenderById(t))==null?void 0:y.with(U.SheetSkeletonManagerService))==null?void 0:R.getCurrentSkeleton();if(!a)return{redos:[],undos:[]};const c=U.attachRangeWithCoord(a,n);if(!c)return{redos:[],undos:[]};const{startX:l,endX:h,startY:u,endY:s}=c,g=this._sheetDrawingService.getDrawingData(t,o),m=[];Object.keys(g).forEach(C=>{const T=g[C];if(T.anchorType!==p.SheetDrawingAnchorType.Both)return;const{transform:w}=T;if(!w)return;const{left:A=0,top:E=0,width:B=0,height:W=0}=w,{drawingStartX:P,drawingEndX:D,drawingStartY:L,drawingEndY:$}={drawingStartX:A,drawingEndX:A+B,drawingStartY:E,drawingEndY:E+W};l<=P&&D<=h&&u<=L&&$<=s&&m.push(T)});const f=[],S=[],_=r.startRow-n.startRow,I=r.startColumn-n.startColumn,M=m.map(C=>{const T=C.sheetTransform,w={to:{...T.to,row:T.to.row+_,column:T.to.column+I},from:{...T.from,row:T.from.row+_,column:T.from.column+I}},A=V(w,this._selectionRenderService,this._skeletonManagerService);return{unitId:t,subUnitId:o,drawingId:C.drawingId,transform:A,sheetTransform:w}});if(M.length){const C=this._sheetDrawingService.getBatchUpdateOp(M),{undo:T,redo:w,objects:A}=C;f.push({id:p.SetDrawingApplyMutation.id,params:{unitId:t,subUnitId:o,op:w,objects:A,type:p.DrawingApplyType.UPDATE}}),S.push({id:p.SetDrawingApplyMutation.id,params:{unitId:t,subUnitId:o,op:T,objects:A,type:p.DrawingApplyType.UPDATE}})}return{redos:f,undos:S}}_moveRowInterceptor(i,r){const n=this._getUnitIdAndSubUnitId(i,r);if(n==null)return{redos:[],undos:[]};const{unitId:e,subUnitId:t}=n,{range:o}=i,a=o.startRow,c=o.endRow,l=[],h=[],u=this._sheetDrawingService.getDrawingData(e,t),s=[],g=[];if(Object.keys(u).forEach(m=>{const f=u[m],{sheetTransform:S,transform:_,anchorType:I=p.SheetDrawingAnchorType.Position}=f;if(S==null||_==null)return;let M,y;if(r==="insert"){const C=this._expandRow(S,_,a,c,I);M=C==null?void 0:C.newSheetTransform,y=C==null?void 0:C.newTransform}else{const{from:C,to:T}=S,{row:w}=C,{row:A}=T;if(I===p.SheetDrawingAnchorType.Both&&w>=a&&A<=c)g.push({unitId:e,subUnitId:t,drawingId:m});else{const E=this._shrinkRow(S,_,a,c,I);M=E==null?void 0:E.newSheetTransform,y=E==null?void 0:E.newTransform}}if(!M||!y)return;const R={unitId:e,subUnitId:t,drawingId:m,transform:y,sheetTransform:M};s.push(R)}),s.length===0&&g.length===0)return{redos:[],undos:[]};if(s.length>0){const m=this._sheetDrawingService.getBatchUpdateOp(s),{undo:f,redo:S,objects:_}=m;l.push({id:p.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:S,objects:_,type:p.DrawingApplyType.UPDATE}}),h.push({id:p.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:f,objects:_,type:p.DrawingApplyType.UPDATE}})}if(g.length>0){const m=this._sheetDrawingService.getBatchRemoveOp(g),f=m.undo,S=m.redo,_=m.objects;l.push({id:p.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:S,objects:_,type:p.DrawingApplyType.REMOVE}}),h.push({id:p.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:f,objects:_,type:p.DrawingApplyType.INSERT}})}return l.push({id:G.id,params:[e]}),h.push({id:G.id,params:[e]}),{redos:l,undos:h}}_moveColInterceptor(i,r){const n=this._getUnitIdAndSubUnitId(i,r);if(n==null)return{redos:[],undos:[]};const{unitId:e,subUnitId:t}=n,{range:o}=i,a=o.startColumn,c=o.endColumn,l=[],h=[],u=this._sheetDrawingService.getDrawingData(e,t),s=[],g=[];if(Object.keys(u).forEach(m=>{const f=u[m],{sheetTransform:S,transform:_,anchorType:I=p.SheetDrawingAnchorType.Position}=f;if(S==null||_==null)return;let M,y;if(r==="insert"){const C=this._expandCol(S,_,a,c,I);M=C==null?void 0:C.newSheetTransform,y=C==null?void 0:C.newTransform}else{const{from:C,to:T}=S,{column:w}=C,{column:A}=T;if(I===p.SheetDrawingAnchorType.Both&&w>=a&&A<=c)g.push({unitId:e,subUnitId:t,drawingId:m});else{const E=this._shrinkCol(S,_,a,c,I);M=E==null?void 0:E.newSheetTransform,y=E==null?void 0:E.newTransform}}if(!M||!y)return;const R={unitId:e,subUnitId:t,drawingId:m,transform:y,sheetTransform:M};s.push(R)}),s.length===0&&g.length===0)return{redos:[],undos:[]};if(s.length>0){const m=this._sheetDrawingService.getBatchUpdateOp(s),{undo:f,redo:S,objects:_}=m;l.push({id:p.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:S,objects:_,type:p.DrawingApplyType.UPDATE}}),h.push({id:p.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:f,objects:_,type:p.DrawingApplyType.UPDATE}})}if(g.length>0){const m=this._sheetDrawingService.getBatchRemoveOp(g),f=m.undo,S=m.redo,_=m.objects;l.push({id:p.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:S,objects:_,type:p.DrawingApplyType.REMOVE}}),h.push({id:p.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:f,objects:_,type:p.DrawingApplyType.INSERT}})}return l.push({id:G.id,params:[e]}),h.push({id:G.id,params:[e]}),{redos:l,undos:h}}_expandCol(i,r,n,e,t=p.SheetDrawingAnchorType.Position){const o=e-n+1,{from:a,to:c}=i,{column:l}=a,{column:h}=c;if(t===p.SheetDrawingAnchorType.None)return{newSheetTransform:F({...r},this._selectionRenderService),newTransform:r};let u=null,s=null;if(l>=n){const g=this._skeletonManagerService.attachRangeWithCoord({startColumn:n,endColumn:e,startRow:a.row,endRow:c.row});if(g==null)return;s={...r,left:(r.left||0)+g.endX-g.startX},u=F(s,this._selectionRenderService)}else if(h>=e)if(t===p.SheetDrawingAnchorType.Both)u={from:{...a},to:{...c,column:h+o}},s=V(u,this._selectionRenderService,this._skeletonManagerService);else return{newSheetTransform:F({...r},this._selectionRenderService),newTransform:r};return u!=null&&s!=null?{newSheetTransform:u,newTransform:s}:null}_shrinkCol(i,r,n,e,t=p.SheetDrawingAnchorType.Position){const o=e-n+1,{from:a,to:c}=i,{column:l}=a,{column:h}=c;if(t===p.SheetDrawingAnchorType.None)return{newSheetTransform:F({...r},this._selectionRenderService),newTransform:r};let u=null,s=null;if(l>e)u={from:{...a,column:l-o},to:{...c,column:h-o}},s=V(u,this._selectionRenderService,this._skeletonManagerService);else{if(l>=n&&h<=e)return null;if(l<n&&h>e)if(t===p.SheetDrawingAnchorType.Both)u={from:{...a},to:{...c,column:h-o}},s=V(u,this._selectionRenderService,this._skeletonManagerService);else return{newSheetTransform:F({...r},this._selectionRenderService),newTransform:r};else if(l>=n&&l<=e){if(l===n)s={...r,left:(r.left||0)-i.from.columnOffset};else{const g=this._skeletonManagerService.attachRangeWithCoord({startColumn:n,endColumn:l-1,startRow:a.row,endRow:c.row});if(g==null)return;s={...r,left:(r.left||0)-g.endX+g.startX-i.from.columnOffset}}u=F(s,this._selectionRenderService)}else if(h>=n&&h<=e&&t===p.SheetDrawingAnchorType.Both){const g=this._skeletonManagerService.attachRangeWithCoord({startColumn:n-1,endColumn:n-1,startRow:a.row,endRow:c.row});if(g==null)return;u={from:{...a},to:{...c,column:n-1,columnOffset:g.endX-g.startX}},s=V(u,this._selectionRenderService,this._skeletonManagerService)}}return u!=null&&s!=null?{newSheetTransform:u,newTransform:s}:null}_expandRow(i,r,n,e,t=p.SheetDrawingAnchorType.Position){const o=e-n+1,{from:a,to:c}=i,{row:l}=a,{row:h}=c;if(t===p.SheetDrawingAnchorType.None)return{newSheetTransform:F({...r},this._selectionRenderService),newTransform:r};let u=null,s=null;if(l>=n){const g=this._skeletonManagerService.attachRangeWithCoord({startRow:n,endRow:e,startColumn:a.column,endColumn:c.column});if(g==null)return;s={...r,top:(r.top||0)+g.endY-g.startY},u=F(s,this._selectionRenderService)}else if(h>=e)if(t===p.SheetDrawingAnchorType.Both)u={from:{...a},to:{...c,row:h+o}},s=V(u,this._selectionRenderService,this._skeletonManagerService);else return{newSheetTransform:F({...r},this._selectionRenderService),newTransform:r};return u!=null&&s!=null?{newSheetTransform:u,newTransform:s}:null}_shrinkRow(i,r,n,e,t=p.SheetDrawingAnchorType.Position){const o=e-n+1,{from:a,to:c}=i,{row:l}=a,{row:h}=c;if(t===p.SheetDrawingAnchorType.None)return{newSheetTransform:F({...r},this._selectionRenderService),newTransform:r};let u=null,s=null;if(l>e)u={from:{...a,row:l-o},to:{...c,row:h-o}},s=V(u,this._selectionRenderService,this._skeletonManagerService);else{if(l>=n&&h<=e)return null;if(l<n&&h>e)if(t===p.SheetDrawingAnchorType.Both)u={from:{...a},to:{...c,row:h-o}},s=V(u,this._selectionRenderService,this._skeletonManagerService);else return{newSheetTransform:F({...r},this._selectionRenderService),newTransform:r};else if(l>=n&&l<=e){if(l===n)s={...r,top:(r.top||0)-i.from.rowOffset};else{const g=this._skeletonManagerService.attachRangeWithCoord({startRow:n,endRow:l-1,startColumn:a.column,endColumn:c.column});if(g==null)return;s={...r,top:(r.top||0)-g.endY+g.startY-i.from.rowOffset}}u=F(s,this._selectionRenderService)}else if(h>=n&&h<=e&&t===p.SheetDrawingAnchorType.Both){const g=this._skeletonManagerService.attachRangeWithCoord({startColumn:a.column,endColumn:a.column,startRow:n-1,endRow:n-1});if(g==null)return;u={from:{...a},to:{...c,row:n-1,rowOffset:g.endY-g.startY}},s=V(u,this._selectionRenderService,this._skeletonManagerService)}}return u!=null&&s!=null?{newSheetTransform:u,newTransform:s}:null}_commandListener(){this.disposeWithMe(this._commandService.onCommandExecuted(i=>{i.id===v.SetWorksheetActiveOperation.id&&setTimeout(()=>{const r=i.params,{unitId:n,subUnitId:e}=r,t=this._drawingManagerService.drawingManagerData,o=[],a=[];Object.keys(t).forEach(c=>{const l=t[c];l!=null&&Object.keys(l).forEach(h=>{const u=l[h].data;u!=null&&Object.keys(u).forEach(s=>{if(c===n&&h===e){const g=u[s];g.transform=V(g.sheetTransform,this._selectionRenderService,this._skeletonManagerService),o.push(u[s])}else a.push(u[s])})})}),this._drawingManagerService.removeNotification(a),this._drawingManagerService.addNotification(o)},0)}))}_sheetRefreshListener(){this.disposeWithMe(this._commandService.onCommandExecuted(i=>{Xt.includes(i.id)&&requestIdleCallback(()=>{const r=i.params,{unitId:n,subUnitId:e,ranges:t}=r;this._refreshDrawingTransform(n,e,t)})}))}_refreshDrawingTransform(i,r,n){const e=this._drawingManagerService.getDrawingData(i,r),t=[];Object.keys(e).forEach(o=>{const a=e[o],{sheetTransform:c,transform:l,anchorType:h=p.SheetDrawingAnchorType.Position}=a;if(h===p.SheetDrawingAnchorType.None)return!0;const{from:u,to:s}=c,{row:g,column:m}=u,{row:f,column:S}=s;for(let _=0;_<n.length;_++){const I=n[_],{startRow:M,endRow:y,startColumn:R,endColumn:C}=I;if(d.Rectangle.intersects({startRow:M,endRow:y,startColumn:R,endColumn:C},{startRow:g,endRow:f,startColumn:m,endColumn:S})||g>y||m>C){const T=h===p.SheetDrawingAnchorType.Position,w=V(c,this._selectionRenderService,this._skeletonManagerService);t.push({...a,transform:{...w,width:T?l==null?void 0:l.width:w==null?void 0:w.width,height:T?l==null?void 0:l.height:w==null?void 0:w.height}});break}}}),t.length!==0&&(this._drawingManagerService.refreshTransform(t),this._commandService.syncExecuteCommand(G.id,[i]))}};Be=xt([ee(1,N.IRenderManagerService),ee(2,d.ICommandService),ee(3,U.ISheetSelectionRenderService),ee(4,d.Inject(U.SheetSkeletonManagerService)),ee(5,d.Inject(v.SheetInterceptorService)),ee(6,p.ISheetDrawingService),ee(7,O.IDrawingManagerService),ee(8,d.IUniverInstanceService)],Be);var K=function(){return K=Object.assign||function(i){for(var r,n=1,e=arguments.length;n<e;n++){r=arguments[n];for(var t in r)Object.prototype.hasOwnProperty.call(r,t)&&(i[t]=r[t])}return i},K.apply(this,arguments)},zt=function(i,r){var n={};for(var e in i)Object.prototype.hasOwnProperty.call(i,e)&&r.indexOf(e)<0&&(n[e]=i[e]);if(i!=null&&typeof Object.getOwnPropertySymbols=="function")for(var t=0,e=Object.getOwnPropertySymbols(i);t<e.length;t++)r.indexOf(e[t])<0&&Object.prototype.propertyIsEnumerable.call(i,e[t])&&(n[e[t]]=i[e[t]]);return n},qe=X.forwardRef(function(i,r){var n=i.icon,e=i.id,t=i.className,o=i.extend,a=zt(i,["icon","id","className","extend"]),c="univerjs-icon univerjs-icon-".concat(e," ").concat(t||"").trim(),l=X.useRef("_".concat(Zt()));return Qe(n,"".concat(e),{defIds:n.defIds,idSuffix:l.current},K({ref:r,className:c},a),o)});function Qe(i,r,n,e,t){return X.createElement(i.tag,K(K({key:r},Kt(i,n,t)),e),(Jt(i,n).children||[]).map(function(o,a){return Qe(o,"".concat(r,"-").concat(i.tag,"-").concat(a),n,void 0,t)}))}function Kt(i,r,n){var e=K({},i.attrs);n!=null&&n.colorChannel1&&e.fill==="colorChannel1"&&(e.fill=n.colorChannel1);var t=r.defIds;return!t||t.length===0||(i.tag==="use"&&e["xlink:href"]&&(e["xlink:href"]=e["xlink:href"]+r.idSuffix),Object.entries(e).forEach(function(o){var a=o[0],c=o[1];typeof c=="string"&&(e[a]=c.replace(/url\(#(.*)\)/,"url(#$1".concat(r.idSuffix,")")))})),e}function Jt(i,r){var n,e=r.defIds;return!e||e.length===0?i:i.tag==="defs"&&(!((n=i.children)===null||n===void 0)&&n.length)?K(K({},i),{children:i.children.map(function(t){return typeof t.attrs.id=="string"&&e&&e.indexOf(t.attrs.id)>-1?K(K({},t),{attrs:K(K({},t.attrs),{id:t.attrs.id+r.idSuffix})}):t})}):i}function Zt(){return Math.random().toString(36).substring(2,8)}qe.displayName="UniverIcon";var qt={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"}}]},et=X.forwardRef(function(i,r){return X.createElement(qe,Object.assign({},i,{id:"add-image-single",ref:r,icon:qt}))});et.displayName="AddImageSingle";const Ge={id:"sheet.command.delete-drawing",type:d.CommandType.COMMAND,handler:i=>{const r=i.get(d.ICommandService),e=i.get(p.ISheetDrawingService).getFocusDrawings();if(e.length===0)return!1;const t=e[0].unitId,o=e.map(a=>{const{unitId:c,subUnitId:l,drawingId:h,drawingType:u}=a;return{unitId:c,subUnitId:l,drawingId:h,drawingType:u}});return r.executeCommand(se.id,{unitId:t,drawings:o})}},De={id:"sheet.command.insert-float-image",type:d.CommandType.COMMAND,handler:i=>{var n,e;return(e=(n=i.get(N.IRenderManagerService).getCurrentTypeOfRenderer(d.UniverInstanceType.UNIVER_SHEET))==null?void 0:n.with(ue).insertFloatImage())!=null?e:!1}},ke={id:"sheet.command.insert-cell-image",type:d.CommandType.COMMAND,handler:i=>{var n,e;return(e=(n=i.get(N.IRenderManagerService).getCurrentTypeOfRenderer(d.UniverInstanceType.UNIVER_SHEET))==null?void 0:n.with(ue).insertCellImage())!=null?e:!1}},ae={id:"sheet.command.move-drawing",type:d.CommandType.COMMAND,handler:(i,r)=>{const n=i.get(d.ICommandService),e=i.get(p.ISheetDrawingService),t=i.get(U.ISheetSelectionRenderService),{direction:o}=r,a=e.getFocusDrawings();if(a.length===0)return!1;const c=a[0].unitId,l=a.map(u=>{const{transform:s}=u;if(s==null)return null;const g={...s},{left:m=0,top:f=0}=s;return o===d.Direction.UP?g.top=f-1:o===d.Direction.DOWN?g.top=f+1:o===d.Direction.LEFT?g.left=m-1:o===d.Direction.RIGHT&&(g.left=m+1),{...u,transform:g,sheetTransform:F(g,t)}}).filter(u=>u!=null);return n.syncExecuteCommand(le.id,{unitId:c,drawings:l})?(n.syncExecuteCommand(G.id,[c]),!0):!1}},tt="addition-and-subtraction-single",Fe="sheet.menu.image";function Qt(i){return{id:Fe,type:k.MenuItemType.SUBITEMS,icon:tt,tooltip:"sheetImage.title",hidden$:k.getMenuHiddenObservable(i,d.UniverInstanceType.UNIVER_SHEET),disabled$:U.getCurrentRangeDisable$(i,{workbookTypes:[v.WorkbookEditablePermission],worksheetTypes:[v.WorksheetEditPermission],rangeTypes:[v.RangeProtectionPermissionEditPoint]})}}function en(i){return{id:De.id,title:"sheetImage.upload.float",type:k.MenuItemType.BUTTON,hidden$:k.getMenuHiddenObservable(i,d.UniverInstanceType.UNIVER_SHEET)}}function tn(i){return{id:ke.id,title:"sheetImage.upload.cell",type:k.MenuItemType.BUTTON}}const te={imageCommonPanel:"univer-image-common-panel",imageCommonPanelGrid:"univer-image-common-panel-grid",imageCommonPanelBorder:"univer-image-common-panel-border",imageCommonPanelTitle:"univer-image-common-panel-title",imageCommonPanelSubtitle:"univer-image-common-panel-subtitle",imageCommonPanelRow:"univer-image-common-panel-row",imageCommonPanelRowVertical:"univer-image-common-panel-row-vertical",imageCommonPanelColumn:"univer-image-common-panel-column",imageCommonPanelColumnCenter:"univer-image-common-panel-column-center",imageCommonPanelInline:"univer-image-common-panel-inline",imageCommonPanelSpan2:"univer-image-common-panel-span2",imageCommonPanelSpan3:"univer-image-common-panel-span3",imageCommonPanelInput:"univer-image-common-panel-input",sheetImageMenu:"univer-sheet-image-menu",sheetImageMenuInput:"univer-sheet-image-menu-input"};function nt(i){var r,n,e="";if(typeof i=="string"||typeof i=="number")e+=i;else if(typeof i=="object")if(Array.isArray(i)){var t=i.length;for(r=0;r<t;r++)i[r]&&(n=nt(i[r]))&&(e&&(e+=" "),e+=n)}else for(n in i)i[n]&&(e&&(e+=" "),e+=n);return e}function Te(){for(var i,r,n=0,e="",t=arguments.length;n<t;n++)(i=arguments[n])&&(r=nt(i))&&(e&&(e+=" "),e+=r);return e}const nn=i=>{var y;const r=d.useDependency(d.ICommandService),n=d.useDependency(d.LocaleService),e=d.useDependency(O.IDrawingManagerService),t=d.useDependency(N.IRenderManagerService),{drawings:o}=i,a=o[0];if(a==null)return;const{unitId:c}=a,l=t.getRenderById(c),h=l==null?void 0:l.scene;if(h==null)return;const u=h.getTransformerByCreate(),[s,g]=X.useState(!0),m=(y=a.anchorType)!=null?y:p.SheetDrawingAnchorType.Position,[f,S]=X.useState(m);function _(R,C){const T=[];return R.forEach(w=>{const{oKey:A}=w,E=C.getDrawingOKey(A);if(E==null)return T.push(null),!0;const{unitId:B,subUnitId:W,drawingId:P,drawingType:D,anchorType:L,sheetTransform:$}=E;T.push({unitId:B,subUnitId:W,drawingId:P,anchorType:L,sheetTransform:$,drawingType:D})}),T}X.useEffect(()=>{const R=u.clearControl$.subscribe(T=>{T===!0&&g(!1)}),C=u.changeStart$.subscribe(T=>{var E;const{objects:w}=T,A=_(w,e);if(A.length===0)g(!1);else if(A.length>=1){g(!0);const B=((E=A[0])==null?void 0:E.anchorType)||p.SheetDrawingAnchorType.Position;S(B)}});return()=>{C.unsubscribe(),R.unsubscribe()}},[]);function I(R){S(R);const C=e.getFocusDrawings();if(C.length===0)return;const T=C.map(w=>({unitId:w.unitId,subUnitId:w.subUnitId,drawingId:w.drawingId,anchorType:R}));r.executeCommand(le.id,{unitId:C[0].unitId,drawings:T})}const M=R=>R?"block":"none";return H.jsxs("div",{className:Te(te.imageCommonPanelGrid,te.imageCommonPanelBorder),style:{display:M(s)},children:[H.jsx("div",{className:te.imageCommonPanelRow,children:H.jsx("div",{className:Te(te.imageCommonPanelColumn,te.imageCommonPanelTitle),children:H.jsx("div",{children:n.t("drawing-anchor.title")})})}),H.jsx("div",{className:Te(te.imageCommonPanelRow),children:H.jsx("div",{className:Te(te.imageCommonPanelColumn),children:H.jsxs(J.RadioGroup,{value:f,onChange:I,direction:"vertical",children:[H.jsx(J.Radio,{value:p.SheetDrawingAnchorType.Both,children:n.t("drawing-anchor.both")}),H.jsx(J.Radio,{value:p.SheetDrawingAnchorType.Position,children:n.t("drawing-anchor.position")}),H.jsx(J.Radio,{value:p.SheetDrawingAnchorType.None,children:n.t("drawing-anchor.none")})]})})})]})},rn=()=>{const i=d.useDependency(O.IDrawingManagerService),r=i.getFocusDrawings(),[n,e]=X.useState(r);return X.useEffect(()=>{const t=i.focus$.subscribe(o=>{e(o)});return()=>{t.unsubscribe()}},[]),!!(n!=null&&n.length)&&H.jsxs("div",{className:te.imageCommonPanel,children:[H.jsx(q.DrawingCommonPanel,{drawings:n}),H.jsx(nn,{drawings:n})]})},on={[k.RibbonStartGroup.FORMULAS_INSERT]:{[Fe]:{order:3,menuItemFactory:Qt,[De.id]:{order:0,menuItemFactory:en},[ke.id]:{order:1,menuItemFactory:tn}}}};function ge(i){return!i.getContextValue(d.FOCUSING_FX_BAR_EDITOR)&&!i.getContextValue(d.EDITOR_ACTIVATED)&&!i.getContextValue(d.FOCUSING_PANEL_EDITOR)&&i.getContextValue(d.FOCUSING_COMMON_DRAWINGS)}const an={id:ae.id,description:"shortcut.sheet.drawing-move-down",group:"4_sheet-drawing-view",binding:k.KeyCode.ARROW_DOWN,priority:100,preconditions:ge,staticParameters:{direction:d.Direction.DOWN}},sn={id:ae.id,description:"shortcut.sheet.drawing-move-up",group:"4_sheet-drawing-view",binding:k.KeyCode.ARROW_UP,priority:100,preconditions:ge,staticParameters:{direction:d.Direction.UP}},cn={id:ae.id,description:"shortcut.sheet.drawing-move-left",group:"4_sheet-drawing-view",binding:k.KeyCode.ARROW_LEFT,priority:100,preconditions:ge,staticParameters:{direction:d.Direction.LEFT}},dn={id:ae.id,description:"shortcut.sheet.drawing-move-right",group:"4_sheet-drawing-view",binding:k.KeyCode.ARROW_RIGHT,priority:100,preconditions:ge,staticParameters:{direction:d.Direction.RIGHT}},ln={id:Ge.id,description:"shortcut.sheet.drawing-delete",group:"4_sheet-drawing-view",preconditions:ge,binding:k.KeyCode.DELETE,mac:k.KeyCode.BACKSPACE};var un=Object.defineProperty,mn=Object.getOwnPropertyDescriptor,gn=(i,r,n,e)=>{for(var t=e>1?void 0:e?mn(r,n):r,o=i.length-1,a;o>=0;o--)(a=i[o])&&(t=(e?a(r,n,t):a(t))||t);return e&&t&&un(r,n,t),t},Re=(i,r)=>(n,e)=>r(n,e,i);let be=class extends d.Disposable{constructor(i,r,n,e){super(),this._componentManager=i,this._menuManagerService=r,this._commandService=n,this._shortcutService=e,this._init()}_initCustomComponents(){const i=this._componentManager;this.disposeWithMe(i.register(tt,et)),this.disposeWithMe(i.register(Xe,rn))}_initMenus(){this._menuManagerService.mergeMenu(on)}_initCommands(){[De,ke,de,se,le,Ee,G,Oe,Ue,je,ae,Ge,Ne].forEach(i=>this.disposeWithMe(this._commandService.registerCommand(i)))}_initShortcuts(){[an,sn,cn,dn,ln].forEach(i=>{this.disposeWithMe(this._shortcutService.registerShortcut(i))})}_init(){this._initCommands(),this._initCustomComponents(),this._initMenus(),this._initShortcuts()}};be=gn([Re(0,d.Inject(k.ComponentManager)),Re(1,k.IMenuManagerService),Re(2,d.ICommandService),Re(3,k.IShortcutService)],be);var hn=Object.defineProperty,pn=Object.getOwnPropertyDescriptor,fn=(i,r,n,e)=>{for(var t=e>1?void 0:e?pn(r,n):r,o=i.length-1,a;o>=0;o--)(a=i[o])&&(t=(e?a(r,n,t):a(t))||t);return e&&t&&hn(r,n,t),t},ie=(i,r)=>(n,e)=>r(n,e,i);function Sn(i,r,n,e){const{scaleX:t,scaleY:o}=r.getAncestorScale(),a=r.getViewport(N.SHEET_VIEWPORT_KEY.VIEW_MAIN),c={left:!0,top:!0};if(!a)return{...i,absolute:c};const{left:l,right:h,top:u,bottom:s}=i,g=e.getFreeze(),{startColumn:m,startRow:f,xSplit:S,ySplit:_}=g,I=n.getNoMergeCellPositionByIndexWithNoHeader(f-_,m-S),M=n.getNoMergeCellPositionByIndexWithNoHeader(f,m),{rowHeaderWidth:y,columnHeaderHeight:R}=n,C=M.startX-I.startX,T=M.startY-I.startY,{top:w,left:A,viewportScrollX:E,viewportScrollY:B}=a;let W,P;l<A?(c.left=!0,W=(C+y+(l-A))*t,P=Math.max(Math.min((C+y+(h-A))*t,(C+y)*t),(h-E)*t)):(c.left=!1,W=Math.max((l-E)*t,(C+y)*t),P=Math.max((h-E)*t,(C+y)*t));let D,L;return u<w?(c.top=!0,D=(T+R+(u-w))*o,L=Math.max(Math.min((T+R+(h-w))*o,(T+R)*o),(s-B)*o)):(c.top=!1,D=Math.max((u-B)*o,(T+R)*o),L=Math.max((s-B)*o,(T+R)*o)),{left:W,right:P,top:D,bottom:L,absolute:c}}const $e=(i,r,n,e)=>{const{scene:t}=r,{left:o,top:a,width:c,height:l,angle:h}=i,u={left:o,right:o+c,top:a,bottom:a+l},s=Sn(u,t,n,e),{scaleX:g,scaleY:m}=t.getAncestorScale();return{startX:s.left,endX:s.right,startY:s.top,endY:s.bottom,rotate:h,width:c*g,height:l*m,absolute:s.absolute}};b.SheetCanvasFloatDomManagerService=class extends d.Disposable{constructor(n,e,t,o,a,c,l){super();Y(this,"_domLayerMap",new Map);Y(this,"_domLayerInfoMap",new Map);Y(this,"_transformChange$",new j.Subject);Y(this,"transformChange$",this._transformChange$.asObservable());Y(this,"_add$",new j.Subject);Y(this,"add$",this._add$.asObservable());Y(this,"_remove$",new j.Subject);Y(this,"remove$",this._remove$.asObservable());Y(this,"_hooks",[]);this._renderManagerService=n,this._univerInstanceService=e,this._commandService=t,this._drawingManagerService=o,this._canvasFloatDomService=a,this._sheetDrawingService=c,this._lifecycleService=l,this._drawingAddListener(),this._featureUpdateListener(),this._deleteListener(),this._bindScrollEvent()}_bindScrollEvent(){this._lifecycleService.lifecycle$.pipe(j.filter(n=>n===d.LifecycleStages.Rendered),j.take(1)).subscribe(()=>{this._scrollUpdateListener()})}_ensureMap(n,e){let t=this._domLayerMap.get(n);t||(t=new Map,this._domLayerMap.set(n,t));let o=t.get(e);return o||(o=new Map,t.set(e,o)),o}getFloatDomInfo(n){return this._domLayerInfoMap.get(n)}_getSceneAndTransformerByDrawingSearch(n){if(n==null)return;const e=this._renderManagerService.getRenderById(n),t=e==null?void 0:e.scene;if(e==null||t==null)return null;const o=t.getTransformerByCreate(),a=e.engine.getCanvasElement();return{scene:t,transformer:o,renderObject:e,canvas:a}}_getFloatDomProps(n){let e;return this._hooks.forEach(t=>{e=t.onGetFloatDomProps(n)}),e}_drawingAddListener(){this.disposeWithMe(this._drawingManagerService.add$.subscribe(n=>{n.forEach(e=>{var at,st,ct;const{unitId:t,subUnitId:o,drawingId:a}=e,c=v.getSheetCommandTarget(this._univerInstanceService,{unitId:t,subUnitId:o}),l=this._drawingManagerService.getDrawingByParam(e),h=this._univerInstanceService.getUnit(t,d.UniverInstanceType.UNIVER_SHEET);if(!h)return;const u=h.getActiveSheet().getSheetId();if(!l||!c)return;const s=(at=this._renderManagerService.getRenderById(t))==null?void 0:at.with(U.SheetSkeletonManagerService).getWorksheetSkeleton(o);if(!s)return;const{transform:g,drawingType:m,data:f}=l;if(m!==d.DrawingTypeEnum.DRAWING_DOM&&m!==d.DrawingTypeEnum.DRAWING_CHART)return;const S=this._getSceneAndTransformerByDrawingSearch(t);if(S==null)return;const{scene:_,canvas:I}=S;if(g==null)return!0;if(u!==o)return;const{left:M,top:y,width:R,height:C,angle:T,flipX:w,flipY:A,skewX:E,skewY:B}=g,W=O.getDrawingShapeKeyByDrawingSearch({unitId:t,subUnitId:o,drawingId:a}),P=_.getObject(W);if(P!=null){P.transformByState({left:M,top:y,width:R,height:C,angle:T,flipX:w,flipY:A,skewX:E,skewY:B});return}const D={left:M,top:y,width:R,height:C,zIndex:this._drawingManagerService.getDrawingOrder(t,o).length-1},L=m===d.DrawingTypeEnum.DRAWING_CHART;if(L){const x=f?f.backgroundColor:"white";D.fill=x,D.rotateEnabled=!1,f&&f.border&&(D.stroke=f.border),D.paintFirst="stroke",D.strokeWidth=1,D.borderEnabled=!1,D.radius=8}const $=new N.Rect(W,D);L&&$.setObjectType(N.ObjectType.CHART),_.addObject($,N.DRAWING_OBJECT_LAYER_INDEX),l.allowTransform!==!1&&_.attachTransformerTo($);const oe=this._ensureMap(t,o),Z=new d.DisposableCollection,Cn=$e($,S.renderObject,s.skeleton,c.worksheet),Ve=new j.BehaviorSubject(Cn),yn={dispose:Z,rect:$,position$:Ve,unitId:t,subUnitId:o};this._canvasFloatDomService.addFloatDom({position$:Ve,id:a,componentKey:l.componentKey,onPointerDown:x=>{I.dispatchEvent(new PointerEvent(x.type,x))},onPointerMove:x=>{I.dispatchEvent(new PointerEvent(x.type,x))},onPointerUp:x=>{I.dispatchEvent(new PointerEvent(x.type,x))},onWheel:x=>{I.dispatchEvent(new WheelEvent(x.type,x))},props:(ct=(st=oe.get(a))==null?void 0:st.props)!=null?ct:this._getFloatDomProps(a),data:f,unitId:t});const ot=$.onTransformChange$.subscribeEvent(()=>{const x=$e($,S.renderObject,s.skeleton,c.worksheet);Ve.next(x)});Z.add(()=>{this._canvasFloatDomService.removeFloatDom(a)}),ot&&Z.add(ot),this._domLayerInfoMap.set(a,yn),oe.set(a,{...oe.get(a)})})})),this.disposeWithMe(this._drawingManagerService.remove$.subscribe(n=>{n.forEach(e=>{const{unitId:t,subUnitId:o,drawingId:a}=e,c=O.getDrawingShapeKeyByDrawingSearch({unitId:t,subUnitId:o,drawingId:a}),l=this._getSceneAndTransformerByDrawingSearch(t);if(l==null)return;const{transformer:h,scene:u}=l,s=u.getObject(c);s!=null&&s.oKey&&h.clearControlByIds([s==null?void 0:s.oKey])})}))}_scrollUpdateListener(){const n=(e,t)=>{var u;const o=this._getSceneAndTransformerByDrawingSearch(e),a=this._ensureMap(e,t),c=Array.from(a.keys()),l=v.getSheetCommandTarget(this._univerInstanceService,{unitId:e,subUnitId:t}),h=(u=this._renderManagerService.getRenderById(e))==null?void 0:u.with(U.SheetSkeletonManagerService).getWorksheetSkeleton(t);!o||!l||!h||c.forEach(s=>{const g=this._domLayerInfoMap.get(s);if(g){const m=$e(g.rect,o.renderObject,h.skeleton,l.worksheet);g.position$.next(m)}})};this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(d.UniverInstanceType.UNIVER_SHEET).pipe(j.filter(e=>!!e),j.switchMap(e=>e.activeSheet$),j.filter(e=>!!e),j.map(e=>{const t=this._renderManagerService.getRenderById(e.getUnitId());return t?{render:t,unitId:e.getUnitId(),subUnitId:e.getSheetId()}:null}),j.filter(e=>!!e),j.switchMap(e=>d.fromEventSubject(e.render.scene.getViewport(N.SHEET_VIEWPORT_KEY.VIEW_MAIN).onScrollAfter$).pipe(j.map(()=>({unitId:e.unitId,subUnitId:e.subUnitId}))))).subscribe(({unitId:e,subUnitId:t})=>{n(e,t)})),this.disposeWithMe(this._commandService.onCommandExecuted(e=>{var t,o;if(e.id===U.SetZoomRatioOperation.id){const a=e.params,{unitId:c}=a;Array.from((o=(t=this._domLayerMap.get(c))==null?void 0:t.keys())!=null?o:[]).forEach(h=>{n(c,h)})}else if(e.id===v.SetFrozenMutation.id){const{unitId:a,subUnitId:c}=e.params;n(a,c)}}))}_getPosition(n,e){var m;const{startX:t,endX:o,startY:a,endY:c}=n,l=(m=this._renderManagerService.getRenderById(e))==null?void 0:m.with(U.ISheetSelectionRenderService);if(l==null)return;const h=l.getCellWithCoordByOffset(t,a);if(h==null)return;const u={column:h.actualColumn,columnOffset:t-h.startX,row:h.actualRow,rowOffset:a-h.startY},s=l.getCellWithCoordByOffset(o,c);if(s==null)return;const g={column:s.actualColumn,columnOffset:o-s.startX,row:s.actualRow,rowOffset:c-s.startY};return{from:u,to:g}}_featureUpdateListener(){this.disposeWithMe(this._drawingManagerService.update$.subscribe(n=>{n.forEach(e=>{const t=this._drawingManagerService.getDrawingByParam(e);if(!t||t.drawingType!==d.DrawingTypeEnum.DRAWING_DOM&&t.drawingType!==d.DrawingTypeEnum.DRAWING_CHART)return;const o={...t.transform};this._transformChange$.next({id:e.drawingId,value:o})})}))}_deleteListener(){this.disposeWithMe(this._drawingManagerService.remove$.subscribe(n=>{n.forEach(e=>{this._removeDom(e.drawingId)})}))}updateFloatDomProps(n,e,t,o){const a=this._domLayerInfoMap.get(t),c=this._getSceneAndTransformerByDrawingSearch(n);if(a&&c){const{scene:l}=c,h=O.getDrawingShapeKeyByDrawingSearch({unitId:n,subUnitId:e,drawingId:t}),u=l.getObject(h);u&&u instanceof N.Rect&&u.setProps(o)}}addFloatDomToPosition(n,e){const t=v.getSheetCommandTarget(this._univerInstanceService,{unitId:n.unitId,subUnitId:n.subUnitId});if(!t)throw new Error("cannot find current target!");const{unitId:o,subUnitId:a}=t,{initPosition:c,componentKey:l,data:h,allowTransform:u=!0}=n,s=e!=null?e:d.generateRandomId(),g=this._getPosition(c,o);if(g==null)return;this._ensureMap(o,a).set(s,n);const f={unitId:o,subUnitId:a,drawingId:s,drawingType:n.type||d.DrawingTypeEnum.DRAWING_DOM,componentKey:l,sheetTransform:g,transform:{left:c.startX,top:c.startY,width:c.endX-c.startX,height:c.endY-c.startY},data:h,allowTransform:u};return this._commandService.executeCommand(de.id,{unitId:o,drawings:[f]}),this._add$.next({unitId:o,subUnitId:a,id:s}),{id:s,dispose:()=>{this._removeDom(s,!0)}}}_removeDom(n,e=!1){const t=this._domLayerInfoMap.get(n);if(!t)return;const{unitId:o,subUnitId:a}=t;this._domLayerInfoMap.delete(n),t.dispose.dispose();const c=this._getSceneAndTransformerByDrawingSearch(o);if(c&&c.scene.removeObject(t.rect),e){this._ensureMap(o,a).delete(n);const h=this._drawingManagerService.getDrawingByParam({unitId:o,subUnitId:a,drawingId:n});if(!h)return;const u=this._sheetDrawingService.getBatchRemoveOp([h]),{redo:s,objects:g}=u;this._commandService.syncExecuteCommand(p.SetDrawingApplyMutation.id,{unitId:o,subUnitId:a,op:s,objects:g,type:p.DrawingApplyType.REMOVE})}}addHook(n){return this._hooks.push(n),{dispose:()=>{const e=this._hooks.findIndex(t=>t===n);this._hooks.splice(e,1)}}}},b.SheetCanvasFloatDomManagerService=fn([ie(0,d.Inject(N.IRenderManagerService)),ie(1,d.IUniverInstanceService),ie(2,d.Inject(d.ICommandService)),ie(3,O.IDrawingManagerService),ie(4,d.Inject(k.CanvasFloatDomService)),ie(5,p.ISheetDrawingService),ie(6,d.Inject(d.LifecycleService))],b.SheetCanvasFloatDomManagerService);var rt=Object.defineProperty,_n=Object.getOwnPropertyDescriptor,vn=(i,r,n)=>r in i?rt(i,r,{enumerable:!0,configurable:!0,writable:!0,value:n}):i[r]=n,wn=(i,r,n,e)=>{for(var t=e>1?void 0:e?_n(r,n):r,o=i.length-1,a;o>=0;o--)(a=i[o])&&(t=(e?a(r,n,t):a(t))||t);return e&&t&&rt(r,n,t),t},He=(i,r)=>(n,e)=>r(n,e,i),it=(i,r,n)=>vn(i,typeof r!="symbol"?r+"":r,n);const In="SHEET_IMAGE_UI_PLUGIN";b.UniverSheetsDrawingUIPlugin=class extends d.Plugin{constructor(r=Ye,n,e,t){super(),this._config=r,this._injector=n,this._renderManagerService=e,this._configService=t;const{menu:o,...a}=d.merge({},Ye,this._config);o&&this._configService.setConfig("menu",o,{merge:!0}),this._configService.setConfig(dt,a)}onStarting(){d.registerDependencies(this._injector,[[b.SheetCanvasFloatDomManagerService],[be],[pe],[Me],[Ce],[Ie],[Se],[we],[_e]]),d.touchDependencies(this._injector,[[b.SheetCanvasFloatDomManagerService]])}onReady(){d.touchDependencies(this._injector,[[Ie]])}onRendered(){this._registerRenderModules(),d.touchDependencies(this._injector,[[Ce],[Me],[be],[Se],[we],[_e]])}onSteady(){this._injector.get(pe)}_registerRenderModules(){[[ue],[Be],[Ae]].forEach(r=>{this.disposeWithMe(this._renderManagerService.registerRenderModule(d.UniverInstanceType.UNIVER_SHEET,r))})}},it(b.UniverSheetsDrawingUIPlugin,"type",d.UniverInstanceType.UNIVER_SHEET),it(b.UniverSheetsDrawingUIPlugin,"pluginName",In),b.UniverSheetsDrawingUIPlugin=wn([d.DependentOn(O.UniverDrawingPlugin,ne.UniverDocsDrawingPlugin,q.UniverDrawingUIPlugin,p.UniverSheetsDrawingPlugin),He(1,d.Inject(d.Injector)),He(2,N.IRenderManagerService),He(3,d.IConfigService)],b.UniverSheetsDrawingUIPlugin),b.ClearSheetDrawingTransformerOperation=G,b.DeleteDrawingsCommand=Ge,b.EditSheetDrawingOperation=Oe,b.GroupSheetDrawingCommand=Ue,b.InsertFloatImageCommand=De,b.InsertSheetDrawingCommand=de,b.MoveDrawingsCommand=ae,b.RemoveSheetDrawingCommand=se,b.SHEETS_IMAGE_MENU_ID=Fe,b.SetDrawingArrangeCommand=Ne,b.SetSheetDrawingCommand=le,b.SidebarSheetDrawingOperation=Ee,b.UngroupSheetDrawingCommand=je,Object.defineProperty(b,Symbol.toStringTag,{value:"Module"})});
9
+ */var Pt;function xt(){if(Pt)return Oe;Pt=1;var i=q,r=Symbol.for("react.element"),n=Symbol.for("react.fragment"),e=Object.prototype.hasOwnProperty,t=i.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,o={key:!0,ref:!0,__self:!0,__source:!0};function a(s,d,m){var u,c={},h=null,g=null;m!==void 0&&(h=""+m),d.key!==void 0&&(h=""+d.key),d.ref!==void 0&&(g=d.ref);for(u in d)e.call(d,u)&&!o.hasOwnProperty(u)&&(c[u]=d[u]);if(s&&s.defaultProps)for(u in d=s.defaultProps,d)c[u]===void 0&&(c[u]=d[u]);return{$$typeof:r,type:s,key:h,ref:g,props:c,_owner:t.current}}return Oe.Fragment=n,Oe.jsx=a,Oe.jsxs=a,Oe}var At;function Kt(){return At||(At=1,mt.exports=xt()),mt.exports}var X=Kt();const 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"},zt=()=>{const i=l.useDependency(P.IImageIoService),r=l.useDependency(l.LocaleService),[n,e]=q.useState(0);return q.useEffect(()=>{const t=i.change$.subscribe(o=>{e(o)});return()=>{t.unsubscribe()}},[i]),X.jsx("div",{style:{display:n>0?"block":"none"},className:Le.uploadLoading,children:X.jsxs("div",{className:Le.uploadLoadingBody,children:[X.jsx("div",{className:Le.uploadLoadingBodyAnimation}),X.jsx("div",{className:Le.uploadLoadingBodyText,children:`${r.t("uploadLoading.loading")}: ${n}`})]})})};var Jt=Object.defineProperty,Zt=Object.getOwnPropertyDescriptor,qt=(i,r,n,e)=>{for(var t=e>1?void 0:e?Zt(r,n):r,o=i.length-1,a;o>=0;o--)(a=i[o])&&(t=(e?a(r,n,t):a(t))||t);return e&&t&&Jt(r,n,t),t},he=(i,r)=>(n,e)=>r(n,e,i);let Ge=class extends l.RxDisposable{constructor(r,n,e,t,o,a,s,d){super();Z(this,"_initImagePopupMenu",new Set);this._injector=r,this._drawingManagerService=n,this._canvasPopManagerService=e,this._renderManagerService=t,this._univerInstanceService=o,this._contextService=a,this._uiPartsService=s,this._commandService=d,this._init()}_init(){this._univerInstanceService.getCurrentTypeOfUnit$(l.UniverInstanceType.UNIVER_SHEET).pipe(k.takeUntil(this.dispose$)).subscribe(r=>this._create(r)),this._univerInstanceService.getTypeOfUnitDisposed$(l.UniverInstanceType.UNIVER_SHEET).pipe(k.takeUntil(this.dispose$)).subscribe(r=>this._dispose(r)),this._univerInstanceService.getAllUnitsForType(l.UniverInstanceType.UNIVER_SHEET).forEach(r=>this._create(r)),this._uiPartsService.registerComponent(V.BuiltInUIPart.CONTENT,()=>l.connectInjector(zt,this._injector))}_dispose(r){const n=r.getUnitId();this._renderManagerService.removeRender(n)}_create(r){if(!r)return;const n=r.getUnitId();this._renderManagerService.has(n)&&!this._initImagePopupMenu.has(n)&&(this._popupMenuListener(n),this._initImagePopupMenu.add(n))}_hasCropObject(r){const n=r.getAllObjectsByOrder();for(const e of n)if(e instanceof ge.ImageCropperObject)return!0;return!1}_popupMenuListener(r){var o;const n=(o=this._renderManagerService.getRenderById(r))==null?void 0:o.scene;if(!n)return;const e=n.getTransformerByCreate();if(!e)return;let t;this.disposeWithMe(l.toDisposable(e.createControl$.subscribe(()=>{if(this._contextService.setContextValue(l.FOCUSING_COMMON_DRAWINGS,!0),this._hasCropObject(n))return;const a=e.getSelectedObjectMap();if(a.size>1){t==null||t.dispose();return}const s=a.values().next().value;if(!s)return;const d=s.oKey,m=this._drawingManagerService.getDrawingOKey(d);if(!m)return;const{unitId:u,subUnitId:c,drawingId:h,drawingType:g}=m,p=m.data;if(p&&p.disablePopup)return;t==null||t.dispose();const S=this._canvasPopManagerService.getFeatureMenu(u,c,h,g);t=this.disposeWithMe(this._canvasPopManagerService.attachPopupToObject(s,{componentKey:ge.COMPONENT_IMAGE_POPUP_MENU,direction:"horizontal",offset:[2,0],extraProps:{menuItems:S||this._getImageMenuItems(u,c,h,g)}}))}))),this.disposeWithMe(e.clearControl$.subscribe(()=>{t==null||t.dispose(),this._contextService.setContextValue(l.FOCUSING_COMMON_DRAWINGS,!1),this._commandService.syncExecuteCommand(P.SetDrawingSelectedOperation.id,[])})),this.disposeWithMe(this._contextService.contextChanged$.subscribe(a=>{a[l.FOCUSING_COMMON_DRAWINGS]===!1&&(t==null||t.dispose())})),this.disposeWithMe(e.changing$.subscribe(()=>{t==null||t.dispose()}))}_getImageMenuItems(r,n,e,t){return[{label:"image-popup.edit",index:0,commandId:ht.id,commandParams:{unitId:r,subUnitId:n,drawingId:e},disable:t===l.DrawingTypeEnum.DRAWING_DOM},{label:"image-popup.delete",index:1,commandId:Ee.id,commandParams:{unitId:r,drawings:[{unitId:r,subUnitId:n,drawingId:e}]},disable:!1},{label:"image-popup.crop",index:2,commandId:ge.OpenImageCropOperation.id,commandParams:{unitId:r,subUnitId:n,drawingId:e},disable:t===l.DrawingTypeEnum.DRAWING_DOM},{label:"image-popup.reset",index:3,commandId:ge.ImageResetSizeOperation.id,commandParams:[{unitId:r,subUnitId:n,drawingId:e}],disable:t===l.DrawingTypeEnum.DRAWING_DOM}]}};Ge=qt([he(0,l.Inject(l.Injector)),he(1,P.IDrawingManagerService),he(2,l.Inject(A.SheetCanvasPopManagerService)),he(3,N.IRenderManagerService),he(4,l.IUniverInstanceService),he(5,l.IContextService),he(6,l.Inject(V.IUIPartsService)),he(7,l.ICommandService)],Ge);function x(i,r,n){const{from:e,to:t,flipY:o=!1,flipX:a=!1,angle:s=0,skewX:d=0,skewY:m=0}=i,u=n.getCurrent();if(u==null)return;const c=A.convertPositionSheetOverGridToAbsolute(u.unitId,u.sheetId,{from:e,to:t},n);let{left:h,top:g,width:p,height:S}=c;const w=n.getCurrentSkeleton(),_=w.rowHeaderWidth+w.columnTotalWidth,C=w.columnHeaderHeight+w.rowTotalHeight;return h+p>_&&(h=_-p),g+S>C&&(g=C-S),{flipY:o,flipX:a,angle:s,skewX:d,skewY:m,left:h,top:g,width:p,height:S}}function H(i,r){const{left:n=0,top:e=0,width:t=0,height:o=0,flipY:a=!1,flipX:s=!1,angle:d=0,skewX:m=0,skewY:u=0}=i,c=r.getCellWithCoordByOffset(n,e);if(c==null)return;const h={column:c.actualColumn,columnOffset:N.precisionTo(n-c.startX,1),row:c.actualRow,rowOffset:N.precisionTo(e-c.startY,1)},g=r.getCellWithCoordByOffset(n+t,e+o);if(g==null)return;const p={column:g.actualColumn,columnOffset:N.precisionTo(n+t-g.startX,1),row:g.actualRow,rowOffset:N.precisionTo(e+o-g.startY,1)};return{flipY:a,flipX:s,angle:d,skewX:m,skewY:u,from:h,to:p}}var Qt=Object.defineProperty,en=Object.getOwnPropertyDescriptor,tn=(i,r,n,e)=>{for(var t=e>1?void 0:e?en(r,n):r,o=i.length-1,a;o>=0;o--)(a=i[o])&&(t=(e?a(r,n,t):a(t))||t);return e&&t&&Qt(r,n,t),t},Ye=(i,r)=>(n,e)=>r(n,e,i);let pt=class extends l.Disposable{constructor(i,r,n,e,t){super(),this._context=i,this._sheetDrawingService=r,this._drawingManagerService=n,this._sheetSelectionRenderService=e,this._sheetSkeletonManagerService=t,this._init()}_init(){this._drawingInitializeListener()}_drawingInitializeListener(){this._sheetDrawingService.initializeNotification(this._context.unitId);const i=this._sheetDrawingService.getDrawingDataForUnit(this._context.unitId);for(const r in i){const n=i[r];for(const e in n.data){const t=n.data[e];t.transform=x(t.sheetTransform,this._sheetSelectionRenderService,this._sheetSkeletonManagerService)}}this._drawingManagerService.registerDrawingData(this._context.unitId,this._sheetDrawingService.getDrawingDataForUnit(this._context.unitId)),this._drawingManagerService.initializeNotification(this._context.unitId)}};pt=tn([Ye(1,f.ISheetDrawingService),Ye(2,P.IDrawingManagerService),Ye(3,l.Inject(A.ISheetSelectionRenderService)),Ye(4,l.Inject(A.SheetSkeletonManagerService))],pt);function nn(i){const r=[];return i.forEach(n=>{const{parent:e,children:t}=n,{unitId:o,subUnitId:a,drawingId:s}=e,d=N.getGroupState(0,0,t.map(c=>c.transform||{})),m=t.map(c=>{const h=c.transform||{left:0,top:0},{unitId:g,subUnitId:p,drawingId:S}=c;return{unitId:g,subUnitId:p,drawingId:S,transform:{...h,left:h.left-d.left,top:h.top-d.top},groupId:s}}),u={unitId:o,subUnitId:a,drawingId:s,drawingType:l.DrawingTypeEnum.DRAWING_GROUP,transform:d};r.push({parent:u,children:m})}),r}function rn(i){const r=[];return i.forEach(n=>{const{parent:e,children:t}=n,{unitId:o,subUnitId:a,drawingId:s,transform:d={width:0,height:0}}=e;if(d==null)return;const m=t.map(c=>{const{transform:h}=c,{unitId:g,subUnitId:p,drawingId:S}=c,w=N.transformObjectOutOfGroup(h||{},d,d.width||0,d.height||0);return{unitId:g,subUnitId:p,drawingId:S,transform:w,groupId:void 0}}),u={unitId:o,subUnitId:a,drawingId:s,drawingType:l.DrawingTypeEnum.DRAWING_GROUP,transform:{left:0,top:0}};r.push({parent:u,children:m})}),r}const ft={id:"sheet.command.group-sheet-image",type:l.CommandType.COMMAND,handler:(i,r)=>{const n=i.get(l.ICommandService),e=i.get(l.IUndoRedoService),t=i.get(f.ISheetDrawingService);if(!r)return!1;const o=[];r.forEach(({parent:g,children:p})=>{o.push(g.unitId),p.forEach(S=>{o.push(S.unitId)})});const a=t.getGroupDrawingOp(r),{unitId:s,subUnitId:d,undo:m,redo:u,objects:c}=a;return n.syncExecuteCommand(f.SetDrawingApplyMutation.id,{op:u,unitId:s,subUnitId:d,objects:c,type:f.DrawingApplyType.GROUP})?(e.pushUndoRedo({unitID:s,undoMutations:[{id:f.SetDrawingApplyMutation.id,params:{op:m,unitId:s,subUnitId:d,objects:rn(c),type:f.DrawingApplyType.UNGROUP}},{id:$.id,params:o}],redoMutations:[{id:f.SetDrawingApplyMutation.id,params:{op:u,unitId:s,subUnitId:d,objects:c,type:f.DrawingApplyType.GROUP}},{id:$.id,params:o}]}),!0):!1}},Pe={id:"sheet.command.insert-sheet-image",type:l.CommandType.COMMAND,handler:(i,r)=>{var C,M,R;const n=i.get(l.ICommandService),e=i.get(l.IUndoRedoService),t=i.get(f.ISheetDrawingService),o=i.get(v.SheetInterceptorService);if(!r)return!1;const a=r.drawings,s=a.map(D=>D.unitId),d=t.getBatchAddOp(a),{unitId:m,subUnitId:u,undo:c,redo:h,objects:g}=d,p=o.onCommandExecute({id:Pe.id,params:r}),S={id:f.SetDrawingApplyMutation.id,params:{op:h,unitId:m,subUnitId:u,objects:g,type:f.DrawingApplyType.INSERT}},w={id:f.SetDrawingApplyMutation.id,params:{op:c,unitId:m,subUnitId:u,objects:g,type:f.DrawingApplyType.REMOVE}};return l.sequenceExecute([...(C=p.preRedos)!=null?C:[],S,...p.redos],n)?(e.pushUndoRedo({unitID:m,undoMutations:[...(M=p.preUndos)!=null?M:[],w,...p.undos,{id:$.id,params:s}],redoMutations:[...(R=p.preRedos)!=null?R:[],S,...p.redos,{id:$.id,params:s}]}),!0):!1}},St={id:"sheet.command.set-drawing-arrange",type:l.CommandType.COMMAND,handler:(i,r)=>{const n=i.get(l.ICommandService),e=i.get(l.IUndoRedoService);if(!r)return!1;const t=i.get(f.ISheetDrawingService),{unitId:o,subUnitId:a,drawingIds:s,arrangeType:d}=r,m={unitId:o,subUnitId:a,drawingIds:s};let u;if(d===l.ArrangeTypeEnum.forward?u=t.getForwardDrawingsOp(m):d===l.ArrangeTypeEnum.backward?u=t.getBackwardDrawingOp(m):d===l.ArrangeTypeEnum.front?u=t.getFrontDrawingsOp(m):d===l.ArrangeTypeEnum.back&&(u=t.getBackDrawingsOp(m)),u==null)return!1;const{objects:c,redo:h,undo:g}=u;return n.syncExecuteCommand(f.SetDrawingApplyMutation.id,{op:h,unitId:o,subUnitId:a,objects:c,type:f.DrawingApplyType.ARRANGE})?(e.pushUndoRedo({unitID:o,undoMutations:[{id:f.SetDrawingApplyMutation.id,params:{op:g,unitId:o,subUnitId:a,objects:c,type:f.DrawingApplyType.ARRANGE}}],redoMutations:[{id:f.SetDrawingApplyMutation.id,params:{op:h,unitId:o,subUnitId:a,objects:c,type:f.DrawingApplyType.ARRANGE}}]}),!0):!1}},Ae={id:"sheet.command.set-sheet-image",type:l.CommandType.COMMAND,handler:(i,r)=>{const n=i.get(l.ICommandService),e=i.get(l.IUndoRedoService),t=i.get(f.ISheetDrawingService);if(!r)return!1;const{drawings:o}=r,a=t.getBatchUpdateOp(o),{unitId:s,subUnitId:d,undo:m,redo:u,objects:c}=a;return n.syncExecuteCommand(f.SetDrawingApplyMutation.id,{unitId:s,subUnitId:d,op:u,objects:c,type:f.DrawingApplyType.UPDATE})?(e.pushUndoRedo({unitID:s,undoMutations:[{id:f.SetDrawingApplyMutation.id,params:{unitId:s,subUnitId:d,op:m,objects:c,type:f.DrawingApplyType.UPDATE}},{id:$.id,params:[s]}],redoMutations:[{id:f.SetDrawingApplyMutation.id,params:{unitId:s,subUnitId:d,op:u,objects:c,type:f.DrawingApplyType.UPDATE}},{id:$.id,params:[s]}]}),!0):!1}},wt={id:"sheet.command.ungroup-sheet-image",type:l.CommandType.COMMAND,handler:(i,r)=>{const n=i.get(l.ICommandService),e=i.get(l.IUndoRedoService),t=i.get(f.ISheetDrawingService);if(!r)return!1;const o=[];r.forEach(({parent:g,children:p})=>{o.push(g.unitId),p.forEach(S=>{o.push(S.unitId)})});const a=t.getUngroupDrawingOp(r),{unitId:s,subUnitId:d,undo:m,redo:u,objects:c}=a;return n.syncExecuteCommand(f.SetDrawingApplyMutation.id,{op:u,unitId:s,subUnitId:d,objects:c,type:f.DrawingApplyType.UNGROUP})?(e.pushUndoRedo({unitID:s,undoMutations:[{id:f.SetDrawingApplyMutation.id,params:{op:m,unitId:s,subUnitId:d,objects:nn(c),type:f.DrawingApplyType.GROUP}},{id:$.id,params:o}],redoMutations:[{id:f.SetDrawingApplyMutation.id,params:{op:u,unitId:s,subUnitId:d,objects:c,type:f.DrawingApplyType.UNGROUP}},{id:$.id,params:o}]}),!0):!1}};var on=Object.defineProperty,an=Object.getOwnPropertyDescriptor,sn=(i,r,n,e)=>{for(var t=e>1?void 0:e?an(r,n):r,o=i.length-1,a;o>=0;o--)(a=i[o])&&(t=(e?a(r,n,t):a(t))||t);return e&&t&&on(r,n,t),t},Q=(i,r)=>(n,e)=>r(n,e,i);function cn(i,r,n){const e=n*Math.PI/180,t=Math.abs(i*Math.cos(e))+Math.abs(r*Math.sin(e)),o=Math.abs(i*Math.sin(e))+Math.abs(r*Math.cos(e));return{rotatedWidth:t,rotatedHeight:o}}function Ut(i,r,n,e,t){var C;const{rotatedHeight:o,rotatedWidth:a}=cn(n,e,t),d=i.get(N.IRenderManagerService).getRenderById(r.unitId);if(!d)return!1;const u=(C=d.with(A.SheetSkeletonManagerService).getWorksheetSkeleton(r.subUnitId))==null?void 0:C.skeleton;if(u==null)return!1;const c=u.getCellByIndex(r.row,r.col),h=c.mergeInfo.endX-c.mergeInfo.startX-2,g=c.mergeInfo.endY-c.mergeInfo.startY-2,p=a/o,w=Math.ceil(Math.min(h,g*p))/a,_=!w||Number.isNaN(w)?.001:w;return{width:n*_,height:e*_}}let Ue=class extends l.Disposable{constructor(r,n,e,t,o,a,s,d,m,u,c,h,g){super();Z(this,"_workbookSelections");this._context=r,this._skeletonManagerService=n,this._commandService=e,this._selectionRenderService=t,this._imageIoService=o,this._fileOpenerService=a,this._sheetDrawingService=s,this._drawingManagerService=d,this._contextService=m,this._messageService=u,this._localeService=c,this._injector=g,this._workbookSelections=h.getWorkbookSelections(this._context.unitId),this._updateImageListener(),this._updateOrderListener(),this._groupDrawingListener(),this._focusDrawingListener()}async insertFloatImage(){const r=await this._fileOpenerService.openFile({multiple:!0,accept:P.DRAWING_IMAGE_ALLOW_IMAGE_LIST.map(e=>`.${e.replace("image/","")}`).join(",")}),n=r.length;return n>P.DRAWING_IMAGE_COUNT_LIMIT?(this._messageService.show({type:ne.MessageType.Error,content:this._localeService.t("update-status.exceedMaxCount",String(P.DRAWING_IMAGE_COUNT_LIMIT))}),!1):n===0?!1:(r.forEach(async e=>await this._insertFloatImage(e)),!0)}async insertCellImage(){const n=(await this._fileOpenerService.openFile({multiple:!1,accept:P.DRAWING_IMAGE_ALLOW_IMAGE_LIST.map(e=>`.${e.replace("image/","")}`).join(",")}))[0];return n?(await this._insertCellImage(n),!0):!1}async _insertFloatImage(r){let n;try{n=await this._imageIoService.saveImage(r)}catch(C){const M=C.message;M===P.ImageUploadStatusType.ERROR_EXCEED_SIZE?this._messageService.show({type:ne.MessageType.Error,content:this._localeService.t("update-status.exceedMaxSize",String(P.DRAWING_IMAGE_ALLOW_SIZE/(1024*1024)))}):M===P.ImageUploadStatusType.ERROR_IMAGE_TYPE?this._messageService.show({type:ne.MessageType.Error,content:this._localeService.t("update-status.invalidImageType")}):M===P.ImageUploadStatusType.ERROR_IMAGE&&this._messageService.show({type:ne.MessageType.Error,content:this._localeService.t("update-status.invalidImage")})}if(n==null)return;const e=this._getUnitInfo(),{unitId:t,subUnitId:o}=e,{imageId:a,imageSourceType:s,source:d,base64Cache:m}=n,{width:u,height:c,image:h}=await P.getImageSize(m||""),{width:g,height:p}=this._context.scene;this._imageIoService.addImageSourceCache(d,s,h);let S=1;if(u>P.DRAWING_IMAGE_WIDTH_LIMIT||c>P.DRAWING_IMAGE_HEIGHT_LIMIT){const C=P.DRAWING_IMAGE_WIDTH_LIMIT/u,M=P.DRAWING_IMAGE_HEIGHT_LIMIT/c;S=Math.max(C,M)}const w=this._getImagePosition(u*S,c*S,g,p);if(w==null)return;const _={unitId:t,subUnitId:o,drawingId:a,drawingType:l.DrawingTypeEnum.DRAWING_IMAGE,imageSourceType:s,source:d,transform:x(w,this._selectionRenderService,this._skeletonManagerService),sheetTransform:w};this._commandService.executeCommand(Pe.id,{unitId:t,drawings:[_]})}async _insertCellImage(r){let n;try{n=await this._imageIoService.saveImage(r)}catch(w){const _=w.message;_===P.ImageUploadStatusType.ERROR_EXCEED_SIZE?this._messageService.show({type:ne.MessageType.Error,content:this._localeService.t("update-status.exceedMaxSize",String(P.DRAWING_IMAGE_ALLOW_SIZE/(1024*1024)))}):_===P.ImageUploadStatusType.ERROR_IMAGE_TYPE?this._messageService.show({type:ne.MessageType.Error,content:this._localeService.t("update-status.invalidImageType")}):_===P.ImageUploadStatusType.ERROR_IMAGE&&this._messageService.show({type:ne.MessageType.Error,content:this._localeService.t("update-status.invalidImage")})}if(n==null)return;const{imageId:e,imageSourceType:t,source:o,base64Cache:a}=n,{width:s,height:d,image:m}=await P.getImageSize(a||"");this._imageIoService.addImageSourceCache(o,t,m);const u=this._workbookSelections.getCurrentLastSelection();if(!u)return!1;const c=l.createDocumentModelWithStyle("",{}),h=Ut(this._injector,{unitId:this._context.unitId,subUnitId:this._context.unit.getActiveSheet().getSheetId(),row:u.primary.actualRow,col:u.primary.actualColumn},s,d,0);if(!h)return!1;const g={size:{width:h.width,height:h.height},positionH:{relativeFrom:l.ObjectRelativeFromH.PAGE,posOffset:0},positionV:{relativeFrom:l.ObjectRelativeFromV.PARAGRAPH,posOffset:0},angle:0},p={unitId:c.getUnitId(),subUnitId:c.getUnitId(),drawingId:e,drawingType:l.DrawingTypeEnum.DRAWING_IMAGE,imageSourceType:t,source:o,transform:bt.docDrawingPositionToTransform(g),docTransform:g,behindDoc:l.BooleanNumber.FALSE,title:"",description:"",layoutType:l.PositionedObjectLayoutType.INLINE,wrapText:l.WrapTextType.BOTH_SIDES,distB:0,distL:0,distR:0,distT:0},S=l.BuildTextUtils.drawing.add({documentDataModel:c,drawings:[p],selection:{collapsed:!0,startOffset:0,endOffset:0}});return S?(c.apply(S),this._commandService.syncExecuteCommand(v.SetRangeValuesCommand.id,{value:{[u.primary.actualRow]:{[u.primary.actualColumn]:{p:c.getSnapshot(),t:1}}}})):!1}_getUnitInfo(){const r=this._context.unit,n=r.getActiveSheet(),e=r.getUnitId(),t=n.getSheetId();return{unitId:e,subUnitId:t}}_getImagePosition(r,n,e,t){const o=this._workbookSelections.getCurrentSelections();let a={startRow:0,endRow:0,startColumn:0,endColumn:0};o&&o.length>0&&(a=o[o.length-1].range);const s=A.attachRangeWithCoord(this._skeletonManagerService.getCurrent().skeleton,a);if(s==null)return;let{startColumn:d,startRow:m,startX:u,startY:c}=s,h=!1;if(u+r>e&&(u=e-r,u<0&&(u=0,r=e),h=!0),c+n>t&&(c=t-n,c<0&&(c=0,n=t),h=!0),h){const w=this._selectionRenderService.getCellWithCoordByOffset(u,c);if(w==null)return;u=w.startX,c=w.startY,d=w.actualColumn,m=w.actualRow}const g={column:d,columnOffset:0,row:m,rowOffset:0},p=this._selectionRenderService.getCellWithCoordByOffset(u+r,c+n);if(p==null)return;const S={column:p.actualColumn,columnOffset:u+r-p.startX,row:p.actualRow,rowOffset:c+n-p.startY};return{from:g,to:S}}_updateOrderListener(){this.disposeWithMe(this._drawingManagerService.featurePluginOrderUpdate$.subscribe(r=>{const{unitId:n,subUnitId:e,drawingIds:t,arrangeType:o}=r;this._commandService.executeCommand(St.id,{unitId:n,subUnitId:e,drawingIds:t,arrangeType:o})}))}_updateImageListener(){this.disposeWithMe(this._drawingManagerService.featurePluginUpdate$.subscribe(r=>{const n=[];r.length!==0&&(r.forEach(e=>{const{unitId:t,subUnitId:o,drawingId:a,drawingType:s,transform:d}=e;if(d==null)return;const m=this._sheetDrawingService.getDrawingByParam({unitId:t,subUnitId:o,drawingId:a});if(m==null||m.unitId!==this._context.unitId)return;const u=H({...m.transform,...d},this._selectionRenderService);if(u==null)return;const c={...e,transform:{...m.transform,...d,...x(u,this._selectionRenderService,this._skeletonManagerService)},sheetTransform:{...u}};n.push(c)}),n.length>0&&this._commandService.executeCommand(Ae.id,{unitId:r[0].unitId,drawings:n}))}))}_groupDrawingListener(){this.disposeWithMe(this._drawingManagerService.featurePluginGroupUpdate$.subscribe(r=>{this._commandService.executeCommand(ft.id,r);const{unitId:n,subUnitId:e,drawingId:t}=r[0].parent;this._commandService.syncExecuteCommand(P.SetDrawingSelectedOperation.id,[{unitId:n,subUnitId:e,drawingId:t}])})),this.disposeWithMe(this._drawingManagerService.featurePluginUngroupUpdate$.subscribe(r=>{this._commandService.executeCommand(wt.id,r)}))}_focusDrawingListener(){this.disposeWithMe(this._drawingManagerService.focus$.subscribe(r=>{r==null||r.length===0?(this._contextService.setContextValue(l.FOCUSING_COMMON_DRAWINGS,!1),this._sheetDrawingService.focusDrawing([])):(this._contextService.setContextValue(l.FOCUSING_COMMON_DRAWINGS,!0),this._sheetDrawingService.focusDrawing(r))}))}};Ue=sn([Q(1,l.Inject(A.SheetSkeletonManagerService)),Q(2,l.ICommandService),Q(3,A.ISheetSelectionRenderService),Q(4,P.IImageIoService),Q(5,V.ILocalFileService),Q(6,f.ISheetDrawingService),Q(7,P.IDrawingManagerService),Q(8,l.IContextService),Q(9,V.IMessageService),Q(10,l.Inject(l.LocaleService)),Q(11,l.Inject(v.SheetsSelectionsService)),Q(12,l.Inject(l.Injector))],Ue);var dn=Object.defineProperty,ln=Object.getOwnPropertyDescriptor,un=(i,r,n,e)=>{for(var t=e>1?void 0:e?ln(r,n):r,o=i.length-1,a;o>=0;o--)(a=i[o])&&(t=(e?a(r,n,t):a(t))||t);return e&&t&&dn(r,n,t),t},we=(i,r)=>(n,e)=>r(n,e,i);function vt(i,r,n){var e,t,o,a;if(((t=(e=n==null?void 0:n.p)==null?void 0:e.body)==null?void 0:t.dataStream.length)===3&&((a=(o=n.p)==null?void 0:o.drawingsOrder)==null?void 0:a.length)===1){const s=n.p.drawings[n.p.drawingsOrder[0]],d=Ut(i,{unitId:r.unitId,subUnitId:r.subUnitId,row:r.row,col:r.col},s.docTransform.size.width,s.docTransform.size.height,s.docTransform.angle);if(d)return s.transform.width=d.width,s.transform.height=d.height,s.docTransform.size.width=d.width,s.docTransform.size.height=d.height,s.transform.left=0,s.transform.top=0,s.docTransform.positionH.posOffset=0,s.docTransform.positionV.posOffset=0,n.p.documentStyle.pageSize.width=1/0,n.p.documentStyle.pageSize.height=1/0,!0}return!1}let Fe=class extends l.Disposable{constructor(i,r,n,e,t,o,a){super(),this._commandService=i,this._sheetInterceptorService=r,this._univerInstanceService=n,this._injector=e,this._drawingManagerService=t,this._docDrawingController=o,this._editorBridgeService=a,this._initHandleResize(),this._handleInitEditor(),this._handleWriteCell(),this._initCellContentInterceptor()}_initHandleResize(){this.disposeWithMe(this._commandService.onCommandExecuted(i=>{let r,n=[];if(i.id===v.SetWorksheetRowHeightMutation.id){const e=i.params;n=e.ranges,r=v.getSheetCommandTarget(this._univerInstanceService,{unitId:e.unitId,subUnitId:e.subUnitId})}else if(i.id===v.SetWorksheetColWidthMutation.id){const e=i.params;n=e.ranges,r=v.getSheetCommandTarget(this._univerInstanceService,{unitId:e.unitId,subUnitId:e.subUnitId})}else if(i.id===v.SetWorksheetRowIsAutoHeightMutation.id){const e=i.params;n=e.ranges,r=v.getSheetCommandTarget(this._univerInstanceService,{unitId:e.unitId,subUnitId:e.subUnitId})}else if(i.id===v.SetWorksheetRowAutoHeightMutation.id){const e=i.params;r=v.getSheetCommandTarget(this._univerInstanceService,{unitId:e.unitId,subUnitId:e.subUnitId}),n=e.rowsAutoHeightInfo.map(t=>({startRow:t.row,endRow:t.row,startColumn:0,endColumn:9999}))}else if(i.id===v.AddWorksheetMergeMutation.id){const e=i.params;n=e.ranges,r=v.getSheetCommandTarget(this._univerInstanceService,{unitId:e.unitId,subUnitId:e.subUnitId})}else if(i.id===v.RemoveWorksheetMergeMutation.id){const e=i.params;n=e.ranges,r=v.getSheetCommandTarget(this._univerInstanceService,{unitId:e.unitId,subUnitId:e.subUnitId})}r&&n.length&&n.forEach(e=>{const t=l.Range.transformRange(e,r.worksheet);for(let o=t.startRow;o<=t.endRow;o++)for(let a=t.startColumn;a<=t.endColumn;a++)vt(this._injector,{unitId:r.unitId,subUnitId:r.subUnitId,row:o,col:a},r.worksheet.getCellRaw(o,a))})}))}_handleInitEditor(){this.disposeWithMe(this._editorBridgeService.visible$.subscribe(i=>{i.visible?i.visible&&(this._drawingManagerService.removeDrawingDataForUnit(l.DOCS_NORMAL_EDITOR_UNIT_ID_KEY),this._docDrawingController.loadDrawingDataForUnit(l.DOCS_NORMAL_EDITOR_UNIT_ID_KEY),this._drawingManagerService.initializeNotification(l.DOCS_NORMAL_EDITOR_UNIT_ID_KEY)):this._drawingManagerService.removeDrawingDataForUnit(l.DOCS_NORMAL_EDITOR_UNIT_ID_KEY)})),this.disposeWithMe(this._commandService.onCommandExecuted(i=>{i.id===bt.ReplaceSnapshotCommand.id&&i.params.unitId===l.DOCS_ZEN_EDITOR_UNIT_ID_KEY&&(this._drawingManagerService.removeDrawingDataForUnit(l.DOCS_ZEN_EDITOR_UNIT_ID_KEY),this._docDrawingController.loadDrawingDataForUnit(l.DOCS_ZEN_EDITOR_UNIT_ID_KEY),this._drawingManagerService.initializeNotification(l.DOCS_ZEN_EDITOR_UNIT_ID_KEY))}))}_handleWriteCell(){this.disposeWithMe(this._sheetInterceptorService.writeCellInterceptor.intercept(v.AFTER_CELL_EDIT,{priority:9999,handler:(i,r,n)=>(vt(this._injector,{unitId:r.unitId,subUnitId:r.subUnitId,row:r.row,col:r.col},i),n(i))}))}_initCellContentInterceptor(){this.disposeWithMe(this._sheetInterceptorService.intercept(v.INTERCEPTOR_POINT.CELL_CONTENT,{effect:l.InterceptorEffectEnum.Style,priority:v.InterceptCellContentPriority.CELL_IMAGE,handler:(i,r,n)=>{var e;return i!=null&&i.p&&((e=i.p.drawingsOrder)!=null&&e.length)&&(i.interceptorStyle||(i.interceptorStyle={}),i.interceptorStyle.tr={a:0}),n(i)}}))}};Fe=un([we(0,l.ICommandService),we(1,l.Inject(v.SheetInterceptorService)),we(2,l.IUniverInstanceService),we(3,l.Inject(l.Injector)),we(4,P.IDrawingManagerService),we(5,l.Inject(Se.DocDrawingController)),we(6,l.Inject(A.IEditorBridgeService))],Fe);var gn=Object.defineProperty,hn=Object.getOwnPropertyDescriptor,mn=(i,r,n,e)=>{for(var t=e>1?void 0:e?hn(r,n):r,o=i.length-1,a;o>=0;o--)(a=i[o])&&(t=(e?a(r,n,t):a(t))||t);return e&&t&&gn(r,n,t),t},Nt=(i,r)=>(n,e)=>r(n,e,i);let $e=class extends l.Disposable{constructor(i,r){super(),this._autoFillService=i,this._injector=r,this._initAutoFillHooks()}_initAutoFillHooks(){this.disposeWithMe(this._autoFillService.addHook({id:"sheet-cell-image-autofill",onBeforeSubmit:(i,r,n,e)=>{new l.ObjectMatrix(e).forValue((t,o,a)=>{vt(this._injector,{unitId:i.unitId,subUnitId:i.subUnitId,row:t,col:o},a)})}}))}};$e=mn([Nt(0,l.Inject(A.IAutoFillService)),Nt(1,l.Inject(l.Injector))],$e);var pn=Object.defineProperty,fn=Object.getOwnPropertyDescriptor,Sn=(i,r,n,e)=>{for(var t=e>1?void 0:e?fn(r,n):r,o=i.length-1,a;o>=0;o--)(a=i[o])&&(t=(e?a(r,n,t):a(t))||t);return e&&t&&pn(r,n,t),t},Ve=(i,r)=>(n,e)=>r(n,e,i);let He=class extends l.Disposable{constructor(r,n,e,t){super();Z(this,"_isSetCursor",!1);this._hoverManagerService=r,this._renderManagerService=n,this._selectionsService=e,this._drawingRenderService=t}_initHover(){}_initImageClick(){}};He=Sn([Ve(0,l.Inject(A.HoverManagerService)),Ve(1,l.Inject(N.IRenderManagerService)),Ve(2,l.Inject(v.SheetsSelectionsService)),Ve(3,l.Inject(ge.DrawingRenderService))],He);var wn=Object.defineProperty,vn=Object.getOwnPropertyDescriptor,_n=(i,r,n,e)=>{for(var t=e>1?void 0:e?vn(r,n):r,o=i.length-1,a;o>=0;o--)(a=i[o])&&(t=(e?a(r,n,t):a(t))||t);return e&&t&&wn(r,n,t),t},_t=(i,r)=>(n,e)=>r(n,e,i);let Xe=class extends l.Disposable{constructor(r,n,e){super();Z(this,"_copyInfo");this._sheetClipboardService=r,this._renderManagerService=n,this._sheetDrawingService=e,this._initCopyPaste()}_initCopyPaste(){this._sheetClipboardService.addClipboardHook({id:"SHEET_IMAGE_UI_PLUGIN",onBeforeCopy:(r,n,e)=>this._collect(r,n,e),onPasteCells:(r,n,e,t)=>{const{copyType:o=A.COPY_TYPE.COPY,pasteType:a}=t,{range:s}=r||{},{range:d,unitId:m,subUnitId:u}=n;return this._generateMutations(d,{copyType:o,pasteType:a,copyRange:s,unitId:m,subUnitId:u})},onPastePlainText:(r,n)=>({undos:[],redos:[]})})}_collect(r,n,e){var h;const t=(h=this._renderManagerService.getRenderById(r))==null?void 0:h.with(A.SheetSkeletonManagerService);if(!t)return;const o=t.attachRangeWithCoord(e);if(!o)return;const{startX:a,endX:s,startY:d,endY:m}=o,u=this._sheetDrawingService.getDrawingData(r,n),c=[];Object.keys(u).forEach(g=>{const p=u[g],{transform:S}=p;if(p.anchorType!==f.SheetDrawingAnchorType.Both||!S)return;const{left:w=0,top:_=0,width:C=0,height:M=0}=S,{drawingStartX:R,drawingEndX:D,drawingStartY:T,drawingEndY:I}={drawingStartX:w,drawingEndX:w+C,drawingStartY:_,drawingEndY:_+M};a<=R&&D<=s&&d<=T&&I<=m&&c.push(p)}),c.length&&(this._copyInfo={drawings:c,unitId:r,subUnitId:n})}_generateMutations(r,n){var G;if(!this._copyInfo)return{redos:[],undos:[]};if([A.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_COL_WIDTH,A.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_VALUE,A.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMAT,A.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMULA].includes(n.pasteType))return{redos:[],undos:[]};const{copyRange:t}=n;if(!t)return{redos:[],undos:[]};const{drawings:o,unitId:a,subUnitId:s}=this._copyInfo,{ranges:[d,m],mapFunc:u}=A.virtualizeDiscreteRanges([t,r]),{row:c,col:h}=u(d.startRow,d.startColumn),{row:g,col:p}=u(m.startRow,m.startColumn),S=(G=this._renderManagerService.getRenderById(a))==null?void 0:G.with(A.SheetSkeletonManagerService);if(!S)return{redos:[],undos:[]};const w=S.attachRangeWithCoord({startRow:c,endRow:c,startColumn:h,endColumn:h}),_=S.attachRangeWithCoord({startRow:g,endRow:g,startColumn:p,endColumn:p});if(!w||!_)return{redos:[],undos:[]};const C=[],M=[],R=_.startX-w.startX,D=_.startY-w.startY,T=g-c,I=p-h,j=n.copyType===A.COPY_TYPE.CUT,{_sheetDrawingService:O}=this;return o.forEach(U=>{const{transform:E,sheetTransform:y}=U;if(!E)return;const W={...U,unitId:a,subUnitId:s,drawingId:j?U.drawingId:l.Tools.generateRandomId(),transform:{...E,left:E.left+R,top:E.top+D},sheetTransform:{to:{...y.to,row:y.to.row+T,column:y.to.column+I},from:{...y.from,row:y.from.row+T,column:y.from.column+I}}};if(j){const{undo:B,redo:z,objects:K}=O.getBatchUpdateOp([W]);C.push({id:f.SetDrawingApplyMutation.id,params:{unitId:a,subUnitId:s,type:f.DrawingApplyType.UPDATE,op:z,objects:K}}),M.push({id:f.SetDrawingApplyMutation.id,params:{unitId:a,subUnitId:s,type:f.DrawingApplyType.UPDATE,op:B,objects:K}})}else{const{undo:B,redo:z,objects:K}=O.getBatchAddOp([W]);C.push({id:f.SetDrawingApplyMutation.id,params:{op:z,unitId:a,subUnitId:s,objects:K,type:f.DrawingApplyType.INSERT}}),M.push({id:f.SetDrawingApplyMutation.id,params:{op:B,unitId:a,subUnitId:s,objects:K,type:f.DrawingApplyType.REMOVE}})}}),{redos:C,undos:M}}};Xe=_n([_t(0,A.ISheetClipboardService),_t(1,N.IRenderManagerService),_t(2,f.ISheetDrawingService)],Xe);var In=Object.defineProperty,Cn=Object.getOwnPropertyDescriptor,yn=(i,r,n,e)=>{for(var t=e>1?void 0:e?Cn(r,n):r,o=i.length-1,a;o>=0;o--)(a=i[o])&&(t=(e?a(r,n,t):a(t))||t);return e&&t&&In(r,n,t),t},Ne=(i,r)=>(n,e)=>r(n,e,i);let xe=class extends l.Disposable{constructor(i,r,n,e,t){super(),this._drawingManagerService=i,this._renderManagerService=r,this._permissionService=n,this._univerInstanceService=e,this._userManagerService=t,this._initDrawingVisible(),this._initDrawingEditable(),this._initViewPermissionChange(),this._initEditPermissionChange()}_initDrawingVisible(){const i=this._univerInstanceService.getCurrentTypeOfUnit$(l.UniverInstanceType.UNIVER_SHEET);this.disposeWithMe(k.combineLatest([i,this._userManagerService.currentUser$]).subscribe(([r,n])=>{if(!r){this._drawingManagerService.setDrawingVisible(!1);return}r.activeSheet$.subscribe(e=>{if(!e){this._drawingManagerService.setDrawingVisible(!1);return}const t=r.getUnitId(),o=e.getSheetId();if(this._permissionService.composePermission([new v.WorkbookViewPermission(t).id,new v.WorksheetViewPermission(t,o).id]).every(s=>s.value))this._drawingManagerService.setDrawingVisible(!0);else{this._drawingManagerService.setDrawingVisible(!1);const s=r.getUnitId(),d=e.getSheetId(),m=this._drawingManagerService.getDrawingData(s,d),u=Object.values(m),c=this._renderManagerService.getRenderById(s),h=c==null?void 0:c.scene;if(h==null)return;h.getAllObjectsByOrder().forEach(p=>{p.classType===N.RENDER_CLASS_TYPE.IMAGE&&u.some(S=>p.oKey.includes(S.drawingId))&&h.removeObject(p)})}})}))}_initDrawingEditable(){const i=this._univerInstanceService.getCurrentTypeOfUnit$(l.UniverInstanceType.UNIVER_SHEET);this.disposeWithMe(k.combineLatest([i,this._userManagerService.currentUser$]).subscribe(([r,n])=>{if(!r){this._drawingManagerService.setDrawingEditable(!1);return}r.activeSheet$.subscribe(e=>{if(!e){this._drawingManagerService.setDrawingEditable(!1);return}const t=r.getUnitId(),o=e.getSheetId();if(this._permissionService.composePermission([new v.WorkbookEditablePermission(t).id,new v.WorksheetEditPermission(t,o).id]).every(s=>s.value))this._drawingManagerService.setDrawingEditable(!0);else{this._drawingManagerService.setDrawingEditable(!1);const s=r.getUnitId(),d=e.getSheetId(),m=this._drawingManagerService.getDrawingData(s,d),u=Object.values(m),c=this._renderManagerService.getRenderById(s),h=c==null?void 0:c.scene;if(h==null)return;h.getAllObjectsByOrder().forEach(p=>{p.classType===N.RENDER_CLASS_TYPE.IMAGE&&u.some(S=>p.oKey.includes(S.drawingId))&&h.detachTransformerFrom(p)})}})}))}_initViewPermissionChange(){const i=this._univerInstanceService.getCurrentTypeOfUnit$(l.UniverInstanceType.UNIVER_SHEET);this.disposeWithMe(k.combineLatest([i,this._userManagerService.currentUser$]).subscribe(([r,n])=>{r&&r.activeSheet$.subscribe(e=>{var c;if(!e)return;const t=r.getUnitId(),o=e.getSheetId();let a=!0;const s=this._renderManagerService.getRenderById(t),d=s==null?void 0:s.scene;if(d==null)return;const m=d.getTransformerByCreate(),u=this._permissionService.composePermission$([new v.WorkbookViewPermission(t).id,new v.WorksheetViewPermission(t,o).id]).pipe(k.map(h=>h.every(g=>g.value)));u==null||u.pipe(k.filter(h=>h!==a),k.distinctUntilChanged()).subscribe({next:h=>{a=h,this._drawingManagerService.setDrawingVisible(h);const g=d.getAllObjectsByOrder(),p=this._drawingManagerService.getDrawingData(t,o),S=Object.values(p);h?this._drawingManagerService.addNotification(S):(g.forEach(w=>{w.classType===N.RENDER_CLASS_TYPE.IMAGE&&S.some(_=>w.oKey.includes(_.drawingId))&&d.removeObject(w)}),m.clearSelectedObjects())}}),(c=this._permissionService.getPermissionPoint$(new v.WorksheetViewPermission(t,o).id))==null||c.pipe(k.filter(h=>h.value!==a),k.distinctUntilChanged()).subscribe({complete:()=>{a=!0,this._drawingManagerService.setDrawingVisible(!0);const h=this._drawingManagerService.getDrawingData(t,o),g=Object.values(h);this._drawingManagerService.addNotification(g)}})})}))}_initEditPermissionChange(){const i=this._univerInstanceService.getCurrentTypeOfUnit$(l.UniverInstanceType.UNIVER_SHEET);this.disposeWithMe(k.combineLatest([i,this._userManagerService.currentUser$]).subscribe(([r,n])=>{r&&r.activeSheet$.subscribe(e=>{var c;if(!e)return;const t=r.getUnitId(),o=e.getSheetId();let a=!0;const s=this._renderManagerService.getRenderById(t),d=s==null?void 0:s.scene;if(d==null)return;const m=d.getTransformerByCreate(),u=this._permissionService.composePermission$([new v.WorkbookEditablePermission(t).id,new v.WorksheetEditPermission(t,o).id]).pipe(k.map(h=>h.every(g=>g.value)));u==null||u.pipe(k.filter(h=>h!==a),k.distinctUntilChanged()).subscribe({next:h=>{a=h,this._drawingManagerService.setDrawingEditable(h);const g=d.getAllObjectsByOrder(),p=this._drawingManagerService.getDrawingData(t,o),S=Object.values(p);h?(g.forEach(w=>{w.classType===N.RENDER_CLASS_TYPE.IMAGE&&S.some(_=>w.oKey.includes(_.drawingId))&&d.attachTransformerTo(w)}),this._drawingManagerService.addNotification(S)):(g.forEach(w=>{w.classType===N.RENDER_CLASS_TYPE.IMAGE&&S.some(_=>w.oKey.includes(_.drawingId))&&d.detachTransformerFrom(w)}),m.clearSelectedObjects())}}),(c=this._permissionService.getPermissionPoint$(new v.WorksheetEditPermission(t,o).id))==null||c.pipe(k.filter(h=>h.value!==a),k.distinctUntilChanged()).subscribe({complete:()=>{a=!0;const h=r.getUnitId(),g=e.getSheetId(),p=this._drawingManagerService.getDrawingData(h,g),S=Object.values(p),w=this._renderManagerService.getRenderById(h),_=w==null?void 0:w.scene;if(_==null)return;this._drawingManagerService.setDrawingEditable(!0),_.getAllObjectsByOrder().forEach(M=>{M.classType===N.RENDER_CLASS_TYPE.IMAGE&&S.some(R=>M.oKey.includes(R.drawingId))&&_.detachTransformerFrom(M)})}})})}))}};xe=yn([Ne(0,P.IDrawingManagerService),Ne(1,N.IRenderManagerService),Ne(2,l.IPermissionService),Ne(3,l.IUniverInstanceService),Ne(4,l.Inject(l.UserManagerService))],xe);var Dn=Object.defineProperty,Mn=Object.getOwnPropertyDescriptor,Tn=(i,r,n,e)=>{for(var t=e>1?void 0:e?Mn(r,n):r,o=i.length-1,a;o>=0;o--)(a=i[o])&&(t=(e?a(r,n,t):a(t))||t);return e&&t&&Dn(r,n,t),t},Ke=(i,r)=>(n,e)=>r(n,e,i);let ze=class extends l.Disposable{constructor(i,r,n,e){super(),this._sheetPrintInterceptorService=i,this._drawingRenderService=r,this._drawingManagerService=n,this._renderManagerService=e,this._initPrinting()}_initPrinting(){this.disposeWithMe(this._sheetPrintInterceptorService.interceptor.intercept(this._sheetPrintInterceptorService.interceptor.getInterceptPoints().PRINTING_COMPONENT_COLLECT,{handler:(i,r,n)=>{const{unitId:e,scene:t,subUnitId:o}=r,a=this._drawingManagerService.getDrawingDataForUnit(e),s=a==null?void 0:a[o];return s&&s.order.forEach(d=>{this._drawingRenderService.renderDrawing(s.data[d],t)}),n()}})),this.disposeWithMe(this._sheetPrintInterceptorService.interceptor.intercept(this._sheetPrintInterceptorService.interceptor.getInterceptPoints().PRINTING_RANGE,{handler:(i,r,n)=>{const{unitId:e,subUnitId:t}=r,o=this._renderManagerService.getRenderById(e);if(!o)return n(i);const a=o.with(A.SheetSkeletonManagerService).getWorksheetSkeleton(t);if(!a)return n(i);const s=this._drawingManagerService.getDrawingDataForUnit(e),d=s==null?void 0:s[r.subUnitId];if(!d)return n(i);const{scaleX:m,scaleY:u}=o.scene,c=i?{...i}:{startColumn:0,endColumn:0,endRow:0,startRow:0},h=d.order.map(g=>d.data[g]).filter(g=>g.drawingType!==l.DrawingTypeEnum.DRAWING_DOM);return h.length?(h.forEach(g=>{if(!g.groupId&&g.transform&&l.Tools.isDefine(g.transform.left)&&l.Tools.isDefine(g.transform.top)&&l.Tools.isDefine(g.transform.width)&&l.Tools.isDefine(g.transform.height)){const p=a.skeleton.getCellIndexByOffset(g.transform.left,g.transform.top,m,u,{x:0,y:0}),S=a.skeleton.getCellIndexByOffset(g.transform.left+g.transform.width,g.transform.top+g.transform.height,m,u,{x:0,y:0});p.column<c.startColumn&&(c.startColumn=p.column),p.row<c.startRow&&(c.startRow=p.row),c.endRow<S.row&&(c.endRow=S.row),c.endColumn<S.column&&(c.endColumn=S.column)}}),n(c)):n(i)}}))}};ze=Tn([Ke(0,l.Inject(A.SheetPrintInterceptorService)),Ke(1,l.Inject(ge.DrawingRenderService)),Ke(2,P.IDrawingManagerService),Ke(3,N.IRenderManagerService)],ze);var Rn=Object.defineProperty,bn=Object.getOwnPropertyDescriptor,En=(i,r,n,e)=>{for(var t=e>1?void 0:e?bn(r,n):r,o=i.length-1,a;o>=0;o--)(a=i[o])&&(t=(e?a(r,n,t):a(t))||t);return e&&t&&Rn(r,n,t),t},me=(i,r)=>(n,e)=>r(n,e,i);const On=[v.InsertRowCommand.id,v.InsertColCommand.id,v.RemoveRowCommand.id,v.RemoveColCommand.id,v.DeleteRangeMoveLeftCommand.id,v.DeleteRangeMoveUpCommand.id,v.InsertRangeMoveDownCommand.id,v.InsertRangeMoveRightCommand.id,v.DeltaRowHeightCommand.id,v.SetRowHeightCommand.id,v.DeltaColumnWidthCommand.id,v.SetColWidthCommand.id,v.SetRowHiddenCommand.id,v.SetSpecificRowsVisibleCommand.id,v.SetSpecificColsVisibleCommand.id,v.SetColHiddenCommand.id,v.MoveColsCommand.id,v.MoveRowsCommand.id,v.MoveRangeCommand.id],Pn=[v.SetRowVisibleMutation.id,v.SetRowHiddenMutation.id,v.SetColVisibleMutation.id,v.SetColHiddenMutation.id,v.SetWorksheetRowHeightMutation.id,v.SetWorksheetColWidthMutation.id];let It=class extends l.Disposable{constructor(i,r,n,e,t,o,a,s,d){super(),this._context=i,this._renderManagerService=r,this._commandService=n,this._selectionRenderService=e,this._skeletonManagerService=t,this._sheetInterceptorService=o,this._sheetDrawingService=a,this._drawingManagerService=s,this._univerInstanceService=d,this._sheetInterceptorListener(),this._commandListener(),this._sheetRefreshListener()}_sheetInterceptorListener(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:i=>{if(!On.includes(i.id))return{redos:[],undos:[]};if(i.params==null)return{redos:[],undos:[]};const r=i.id;if(r===v.InsertRowCommand.id)return this._moveRowInterceptor(i.params,"insert");if([v.MoveColsCommand.id,v.MoveRowsCommand.id,v.MoveRangeCommand.id].includes(r))return this._moveRangeInterceptor(i.params);if(r===v.InsertColCommand.id)return this._moveColInterceptor(i.params,"insert");if(r===v.RemoveRowCommand.id)return this._moveRowInterceptor(i.params,"remove");if(r===v.RemoveColCommand.id)return this._moveColInterceptor(i.params,"remove");if(r===v.DeleteRangeMoveLeftCommand.id){const{range:n}=i.params;return this._getRangeMoveUndo(n,0)}else if(r===v.DeleteRangeMoveUpCommand.id){const{range:n}=i.params;return this._getRangeMoveUndo(n,1)}else if(r===v.InsertRangeMoveDownCommand.id){const{range:n}=i.params;return this._getRangeMoveUndo(n,2)}else if(r===v.InsertRangeMoveRightCommand.id){const{range:n}=i.params;return this._getRangeMoveUndo(n,3)}else if(r===v.SetRowHiddenCommand.id||r===v.SetSpecificRowsVisibleCommand.id){const n=i.params,{unitId:e,subUnitId:t,ranges:o}=n;return this._getDrawingUndoForRowVisible(e,t,o)}else if(r===v.SetSpecificColsVisibleCommand.id||r===v.SetColHiddenCommand.id){const n=i.params,{unitId:e,subUnitId:t,ranges:o}=n;return this._getDrawingUndoForColVisible(e,t,o)}else if(r===v.DeltaRowHeightCommand.id||r===v.SetRowHeightCommand.id||r===v.DeltaColumnWidthCommand.id||r===v.SetColWidthCommand.id){const n=i.params,{unitId:e,subUnitId:t,ranges:o}=n,a=r===v.DeltaRowHeightCommand.id||r===v.SetRowHeightCommand.id;return this._getDrawingUndoForRowAndColSize(e,t,o,a)}return{redos:[],undos:[]}}}))}_getRangeMoveUndo(i,r){const n=v.getSheetCommandTarget(this._univerInstanceService);if(n==null)return{redos:[],undos:[]};const e=n.unitId,t=n.subUnitId,o=[],a=[],s=this._sheetDrawingService.getDrawingData(e,t),d=[],m=[];if(Object.keys(s).forEach(u=>{const c=s[u],{updateDrawings:h,deleteDrawings:g}=this._getUpdateOrDeleteDrawings(i,r,c);d.push(...h),m.push(...g)}),d.length===0&&m.length===0)return{redos:[],undos:[]};if(d.length>0){const u=this._sheetDrawingService.getBatchUpdateOp(d),{undo:c,redo:h,objects:g}=u;o.push({id:f.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:h,objects:g,type:f.DrawingApplyType.UPDATE}}),a.push({id:f.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:c,objects:g,type:f.DrawingApplyType.UPDATE}})}if(m.length>0){const u=this._sheetDrawingService.getBatchRemoveOp(m),c=u.undo,h=u.redo,g=u.objects;o.push({id:f.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:h,objects:g,type:f.DrawingApplyType.REMOVE}}),a.push({id:f.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:c,objects:g,type:f.DrawingApplyType.INSERT}})}return o.push({id:$.id,params:[e]}),a.push({id:$.id,params:[e]}),{redos:o,undos:a}}_getUpdateOrDeleteDrawings(i,r,n){const e=[],t=[],{sheetTransform:o,anchorType:a=f.SheetDrawingAnchorType.Position,transform:s,unitId:d,subUnitId:m,drawingId:u}=n,{from:c,to:h}=o,{row:g,column:p}=c,{row:S,column:w}=h;if(o==null||s==null)return{updateDrawings:e,deleteDrawings:t};const{startRow:_,endRow:C,startColumn:M,endColumn:R}=i;let D=null,T=null;if(r===0&&g>=_&&S<=C)if(p>=M&&w<=R)t.push({unitId:d,subUnitId:m,drawingId:u});else{const I=this._shrinkCol(o,s,M,R,a);D=I==null?void 0:I.newSheetTransform,T=I==null?void 0:I.newTransform}else if(r===1&&p>=M&&w<=R)if(g>=_&&S<=C)t.push({unitId:d,subUnitId:m,drawingId:u});else{const I=this._shrinkRow(o,s,_,C,a);D=I==null?void 0:I.newSheetTransform,T=I==null?void 0:I.newTransform}else if(r===2){const I=this._expandRow(o,s,_,C,a);D=I==null?void 0:I.newSheetTransform,T=I==null?void 0:I.newTransform}else if(r===3){const I=this._expandCol(o,s,M,R,a);D=I==null?void 0:I.newSheetTransform,T=I==null?void 0:I.newTransform}if(D!=null&&T!=null){const I=x(D,this._selectionRenderService,this._skeletonManagerService);e.push({...n,sheetTransform:D,transform:I})}return{updateDrawings:e,deleteDrawings:t}}_remainDrawingSize(i,r,n){const e=H({...i},this._selectionRenderService);e!=null&&r.push({...n,sheetTransform:e})}_getDrawingUndoForColVisible(i,r,n){const e=this._drawingManagerService.getDrawingData(i,r),t=[],o=[];if(Object.keys(e).forEach(u=>{const c=e[u],{sheetTransform:h,transform:g,anchorType:p=f.SheetDrawingAnchorType.Position}=c;if(p===f.SheetDrawingAnchorType.None)this._remainDrawingSize(g,t,c);else{const{from:S,to:w}=h,{row:_,column:C}=S,{row:M,column:R}=w;for(let D=0;D<n.length;D++){const T=n[D],{startRow:I,endRow:j,startColumn:O,endColumn:G}=T;if(R<O)continue;if(p===f.SheetDrawingAnchorType.Position){let y=null,W=null;if(C>=O&&C<=G){const B=this._skeletonManagerService.attachRangeWithCoord({startColumn:C,endColumn:G,startRow:S.row,endRow:w.row});if(B==null)return;W={...g,left:B.startX}}if(W!=null&&(y=H(W,this._selectionRenderService),y!=null&&W!=null)){t.push({...c,sheetTransform:y,transform:W});break}this._remainDrawingSize(g,t,c);continue}if(C>=O&&R<=G)continue;let U=null,E=null;if(C>=O&&C<=G){const y=this._skeletonManagerService.attachRangeWithCoord({startColumn:C,endColumn:G,startRow:S.row,endRow:w.row});if(y==null)return;E={...g,left:(y==null?void 0:y.startX)||0,width:((g==null?void 0:g.width)||0)-y.endX+y.startX}}else if(R>=O&&R<=G){const y=this._skeletonManagerService.attachRangeWithCoord({startColumn:O,endColumn:R,startRow:S.row,endRow:w.row});if(y==null)return;E={...g,left:y.startX-((g==null?void 0:g.width)||0)}}else{const y=this._skeletonManagerService.attachRangeWithCoord({startColumn:O,endColumn:G,startRow:S.row,endRow:w.row});if(y==null)return;if(E={...g,width:((g==null?void 0:g.width)||0)-y.endX+y.startX},U=H(E,this._selectionRenderService),U!=null&&E!=null){o.push({...c,sheetTransform:U,transform:E});break}}if(E!=null&&(U=H(E,this._selectionRenderService)),E!=null&&U!=null){t.push({...c,sheetTransform:U,transform:E});break}else this._remainDrawingSize(g,t,c)}}}),t.length===0&&o.length===0)return{redos:[],undos:[]};const{redos:a,undos:s}=this._createUndoAndRedoMutation(i,r,t),d=[],m=[];if(o.length>0){const{redos:u,undos:c}=this._createUndoAndRedoMutation(i,r,o);d.push(...u),m.push(...c)}return{redos:a,undos:s,preRedos:d,preUndos:m}}_createUndoAndRedoMutation(i,r,n){const e=this._sheetDrawingService.getBatchUpdateOp(n),{undo:t,redo:o,objects:a}=e,s=[{id:f.SetDrawingApplyMutation.id,params:{unitId:i,subUnitId:r,op:o,objects:a,type:f.DrawingApplyType.UPDATE}},{id:$.id,params:[i]}],d=[{id:f.SetDrawingApplyMutation.id,params:{unitId:i,subUnitId:r,op:t,objects:a,type:f.DrawingApplyType.UPDATE}},{id:$.id,params:[i]}];return{redos:s,undos:d}}_getDrawingUndoForRowVisible(i,r,n){const e=this._drawingManagerService.getDrawingData(i,r),t=[],o=[];if(Object.keys(e).forEach(u=>{const c=e[u],{sheetTransform:h,transform:g,anchorType:p=f.SheetDrawingAnchorType.Position}=c;if(p===f.SheetDrawingAnchorType.None)this._remainDrawingSize(g,t,c);else{const{from:S,to:w}=h,{row:_,column:C}=S,{row:M,column:R}=w;for(let D=0;D<n.length;D++){const T=n[D],{startRow:I,endRow:j,startColumn:O,endColumn:G}=T;if(M<I)continue;if(p===f.SheetDrawingAnchorType.Position){let y=null,W=null;if(_>=I&&_<=j){const B=this._skeletonManagerService.attachRangeWithCoord({startColumn:S.column,endColumn:w.column,startRow:_,endRow:j});if(B==null)return;W={...g,top:B.startY}}if(W!=null&&(y=H(W,this._selectionRenderService),y!=null&&W!=null)){t.push({...c,sheetTransform:y,transform:W});break}this._remainDrawingSize(g,t,c);continue}if(_>=I&&M<=j)continue;let U=null,E=null;if(_>=I&&_<=j){const y=this._skeletonManagerService.attachRangeWithCoord({startColumn:S.column,endColumn:w.column,startRow:_,endRow:j});if(y==null)return;E={...g,top:(y==null?void 0:y.startY)||0,height:((g==null?void 0:g.height)||0)-y.endY+y.startY}}else if(M>=I&&M<=j){const y=this._skeletonManagerService.attachRangeWithCoord({startColumn:S.column,endColumn:w.column,startRow:I,endRow:M});if(y==null)return;E={...g,top:y.startY-((g==null?void 0:g.height)||0)}}else{const y=this._skeletonManagerService.attachRangeWithCoord({startColumn:S.column,endColumn:w.column,startRow:I,endRow:j});if(y==null)return;if(E={...g,height:((g==null?void 0:g.height)||0)-y.endY+y.startY},U=H(E,this._selectionRenderService),U!=null&&E!=null){o.push({...c,sheetTransform:U,transform:E});break}}if(E!=null&&(U=H(E,this._selectionRenderService)),E!=null&&U!=null){t.push({...c,sheetTransform:U,transform:E});break}else this._remainDrawingSize(g,t,c)}}}),t.length===0&&o.length===0)return{redos:[],undos:[]};const{redos:a,undos:s}=this._createUndoAndRedoMutation(i,r,t),d=[],m=[];if(o.length>0){const{redos:u,undos:c}=this._createUndoAndRedoMutation(i,r,o);d.push(...u),m.push(...c)}return{redos:a,undos:s,preRedos:d,preUndos:m}}_getDrawingUndoForRowAndColSize(i,r,n,e){const t=this._drawingManagerService.getDrawingData(i,r),o=[];return Object.keys(t).forEach(a=>{const s=t[a],{sheetTransform:d,transform:m,anchorType:u=f.SheetDrawingAnchorType.Position}=s;if(u===f.SheetDrawingAnchorType.None)this._remainDrawingSize(m,o,s);else{const{from:c,to:h}=d,{row:g,column:p}=c,{row:S,column:w}=h;for(let _=0;_<n.length;_++){const C=n[_],{startRow:M,endRow:R,startColumn:D,endColumn:T}=C;if(S<M||w<D)continue;if(u===f.SheetDrawingAnchorType.Position&&(g<=M&&S>=R||p<=D&&w>=T)){this._remainDrawingSize(m,o,s);continue}const I=x({...d},this._selectionRenderService,this._skeletonManagerService);if(I!=null){o.push({...s,transform:I});break}}}}),o.length===0?{redos:[],undos:[]}:this._createUndoAndRedoMutation(i,r,o)}_getUnitIdAndSubUnitId(i,r){let n,e;if(r==="insert")n=i.unitId,e=i.subUnitId;else{const t=v.getSheetCommandTarget(this._univerInstanceService);if(t==null)return;n=t.unitId,e=t.subUnitId}return{unitId:n,subUnitId:e}}_moveRangeInterceptor(i){var M,R;const{toRange:r,fromRange:n}=i,e=v.getSheetCommandTarget(this._univerInstanceService);if(!e)return{redos:[],undos:[]};const{unitId:t,subUnitId:o}=e,a=(R=(M=this._renderManagerService.getRenderById(t))==null?void 0:M.with(A.SheetSkeletonManagerService))==null?void 0:R.getCurrentSkeleton();if(!a)return{redos:[],undos:[]};const s=A.attachRangeWithCoord(a,n);if(!s)return{redos:[],undos:[]};const{startX:d,endX:m,startY:u,endY:c}=s,h=this._sheetDrawingService.getDrawingData(t,o),g=[];Object.keys(h).forEach(D=>{const T=h[D];if(T.anchorType!==f.SheetDrawingAnchorType.Both)return;const{transform:I}=T;if(!I)return;const{left:j=0,top:O=0,width:G=0,height:U=0}=I,{drawingStartX:E,drawingEndX:y,drawingStartY:W,drawingEndY:B}={drawingStartX:j,drawingEndX:j+G,drawingStartY:O,drawingEndY:O+U};d<=E&&y<=m&&u<=W&&B<=c&&g.push(T)});const p=[],S=[],w=r.startRow-n.startRow,_=r.startColumn-n.startColumn,C=g.map(D=>{const T=D.sheetTransform,I={to:{...T.to,row:T.to.row+w,column:T.to.column+_},from:{...T.from,row:T.from.row+w,column:T.from.column+_}},j=x(I,this._selectionRenderService,this._skeletonManagerService);return{unitId:t,subUnitId:o,drawingId:D.drawingId,transform:j,sheetTransform:I}});if(C.length){const D=this._sheetDrawingService.getBatchUpdateOp(C),{undo:T,redo:I,objects:j}=D;p.push({id:f.SetDrawingApplyMutation.id,params:{unitId:t,subUnitId:o,op:I,objects:j,type:f.DrawingApplyType.UPDATE}}),S.push({id:f.SetDrawingApplyMutation.id,params:{unitId:t,subUnitId:o,op:T,objects:j,type:f.DrawingApplyType.UPDATE}})}return{redos:p,undos:S}}_moveRowInterceptor(i,r){const n=this._getUnitIdAndSubUnitId(i,r);if(n==null)return{redos:[],undos:[]};const{unitId:e,subUnitId:t}=n,{range:o}=i,a=o.startRow,s=o.endRow,d=[],m=[],u=this._sheetDrawingService.getDrawingData(e,t),c=[],h=[];if(Object.keys(u).forEach(g=>{const p=u[g],{sheetTransform:S,transform:w,anchorType:_=f.SheetDrawingAnchorType.Position}=p;if(S==null||w==null)return;let C,M;if(r==="insert"){const D=this._expandRow(S,w,a,s,_);C=D==null?void 0:D.newSheetTransform,M=D==null?void 0:D.newTransform}else{const{from:D,to:T}=S,{row:I}=D,{row:j}=T;if(_===f.SheetDrawingAnchorType.Both&&I>=a&&j<=s)h.push({unitId:e,subUnitId:t,drawingId:g});else{const O=this._shrinkRow(S,w,a,s,_);C=O==null?void 0:O.newSheetTransform,M=O==null?void 0:O.newTransform}}if(!C||!M)return;const R={unitId:e,subUnitId:t,drawingId:g,transform:M,sheetTransform:C};c.push(R)}),c.length===0&&h.length===0)return{redos:[],undos:[]};if(c.length>0){const g=this._sheetDrawingService.getBatchUpdateOp(c),{undo:p,redo:S,objects:w}=g;d.push({id:f.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:S,objects:w,type:f.DrawingApplyType.UPDATE}}),m.push({id:f.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:p,objects:w,type:f.DrawingApplyType.UPDATE}})}if(h.length>0){const g=this._sheetDrawingService.getBatchRemoveOp(h),p=g.undo,S=g.redo,w=g.objects;d.push({id:f.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:S,objects:w,type:f.DrawingApplyType.REMOVE}}),m.push({id:f.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:p,objects:w,type:f.DrawingApplyType.INSERT}})}return d.push({id:$.id,params:[e]}),m.push({id:$.id,params:[e]}),{redos:d,undos:m}}_moveColInterceptor(i,r){const n=this._getUnitIdAndSubUnitId(i,r);if(n==null)return{redos:[],undos:[]};const{unitId:e,subUnitId:t}=n,{range:o}=i,a=o.startColumn,s=o.endColumn,d=[],m=[],u=this._sheetDrawingService.getDrawingData(e,t),c=[],h=[];if(Object.keys(u).forEach(g=>{const p=u[g],{sheetTransform:S,transform:w,anchorType:_=f.SheetDrawingAnchorType.Position}=p;if(S==null||w==null)return;let C,M;if(r==="insert"){const D=this._expandCol(S,w,a,s,_);C=D==null?void 0:D.newSheetTransform,M=D==null?void 0:D.newTransform}else{const{from:D,to:T}=S,{column:I}=D,{column:j}=T;if(_===f.SheetDrawingAnchorType.Both&&I>=a&&j<=s)h.push({unitId:e,subUnitId:t,drawingId:g});else{const O=this._shrinkCol(S,w,a,s,_);C=O==null?void 0:O.newSheetTransform,M=O==null?void 0:O.newTransform}}if(!C||!M)return;const R={unitId:e,subUnitId:t,drawingId:g,transform:M,sheetTransform:C};c.push(R)}),c.length===0&&h.length===0)return{redos:[],undos:[]};if(c.length>0){const g=this._sheetDrawingService.getBatchUpdateOp(c),{undo:p,redo:S,objects:w}=g;d.push({id:f.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:S,objects:w,type:f.DrawingApplyType.UPDATE}}),m.push({id:f.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:p,objects:w,type:f.DrawingApplyType.UPDATE}})}if(h.length>0){const g=this._sheetDrawingService.getBatchRemoveOp(h),p=g.undo,S=g.redo,w=g.objects;d.push({id:f.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:S,objects:w,type:f.DrawingApplyType.REMOVE}}),m.push({id:f.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:p,objects:w,type:f.DrawingApplyType.INSERT}})}return d.push({id:$.id,params:[e]}),m.push({id:$.id,params:[e]}),{redos:d,undos:m}}_expandCol(i,r,n,e,t=f.SheetDrawingAnchorType.Position){const o=e-n+1,{from:a,to:s}=i,{column:d}=a,{column:m}=s;if(t===f.SheetDrawingAnchorType.None)return{newSheetTransform:H({...r},this._selectionRenderService),newTransform:r};let u=null,c=null;if(d>=n){const h=this._skeletonManagerService.attachRangeWithCoord({startColumn:n,endColumn:e,startRow:a.row,endRow:s.row});if(h==null)return;c={...r,left:(r.left||0)+h.endX-h.startX},u=H(c,this._selectionRenderService)}else if(m>=e)if(t===f.SheetDrawingAnchorType.Both)u={from:{...a},to:{...s,column:m+o}},c=x(u,this._selectionRenderService,this._skeletonManagerService);else return{newSheetTransform:H({...r},this._selectionRenderService),newTransform:r};return u!=null&&c!=null?{newSheetTransform:u,newTransform:c}:null}_shrinkCol(i,r,n,e,t=f.SheetDrawingAnchorType.Position){const o=e-n+1,{from:a,to:s}=i,{column:d}=a,{column:m}=s;if(t===f.SheetDrawingAnchorType.None)return{newSheetTransform:H({...r},this._selectionRenderService),newTransform:r};let u=null,c=null;if(d>e)u={from:{...a,column:d-o},to:{...s,column:m-o}},c=x(u,this._selectionRenderService,this._skeletonManagerService);else{if(d>=n&&m<=e)return null;if(d<n&&m>e)if(t===f.SheetDrawingAnchorType.Both)u={from:{...a},to:{...s,column:m-o}},c=x(u,this._selectionRenderService,this._skeletonManagerService);else return{newSheetTransform:H({...r},this._selectionRenderService),newTransform:r};else if(d>=n&&d<=e){if(d===n)c={...r,left:(r.left||0)-i.from.columnOffset};else{const h=this._skeletonManagerService.attachRangeWithCoord({startColumn:n,endColumn:d-1,startRow:a.row,endRow:s.row});if(h==null)return;c={...r,left:(r.left||0)-h.endX+h.startX-i.from.columnOffset}}u=H(c,this._selectionRenderService)}else if(m>=n&&m<=e&&t===f.SheetDrawingAnchorType.Both){const h=this._skeletonManagerService.attachRangeWithCoord({startColumn:n-1,endColumn:n-1,startRow:a.row,endRow:s.row});if(h==null)return;u={from:{...a},to:{...s,column:n-1,columnOffset:h.endX-h.startX}},c=x(u,this._selectionRenderService,this._skeletonManagerService)}}return u!=null&&c!=null?{newSheetTransform:u,newTransform:c}:null}_expandRow(i,r,n,e,t=f.SheetDrawingAnchorType.Position){const o=e-n+1,{from:a,to:s}=i,{row:d}=a,{row:m}=s;if(t===f.SheetDrawingAnchorType.None)return{newSheetTransform:H({...r},this._selectionRenderService),newTransform:r};let u=null,c=null;if(d>=n){const h=this._skeletonManagerService.attachRangeWithCoord({startRow:n,endRow:e,startColumn:a.column,endColumn:s.column});if(h==null)return;c={...r,top:(r.top||0)+h.endY-h.startY},u=H(c,this._selectionRenderService)}else if(m>=e)if(t===f.SheetDrawingAnchorType.Both)u={from:{...a},to:{...s,row:m+o}},c=x(u,this._selectionRenderService,this._skeletonManagerService);else return{newSheetTransform:H({...r},this._selectionRenderService),newTransform:r};return u!=null&&c!=null?{newSheetTransform:u,newTransform:c}:null}_shrinkRow(i,r,n,e,t=f.SheetDrawingAnchorType.Position){const o=e-n+1,{from:a,to:s}=i,{row:d}=a,{row:m}=s;if(t===f.SheetDrawingAnchorType.None)return{newSheetTransform:H({...r},this._selectionRenderService),newTransform:r};let u=null,c=null;if(d>e)u={from:{...a,row:d-o},to:{...s,row:m-o}},c=x(u,this._selectionRenderService,this._skeletonManagerService);else{if(d>=n&&m<=e)return null;if(d<n&&m>e)if(t===f.SheetDrawingAnchorType.Both)u={from:{...a},to:{...s,row:m-o}},c=x(u,this._selectionRenderService,this._skeletonManagerService);else return{newSheetTransform:H({...r},this._selectionRenderService),newTransform:r};else if(d>=n&&d<=e){if(d===n)c={...r,top:(r.top||0)-i.from.rowOffset};else{const h=this._skeletonManagerService.attachRangeWithCoord({startRow:n,endRow:d-1,startColumn:a.column,endColumn:s.column});if(h==null)return;c={...r,top:(r.top||0)-h.endY+h.startY-i.from.rowOffset}}u=H(c,this._selectionRenderService)}else if(m>=n&&m<=e&&t===f.SheetDrawingAnchorType.Both){const h=this._skeletonManagerService.attachRangeWithCoord({startColumn:a.column,endColumn:a.column,startRow:n-1,endRow:n-1});if(h==null)return;u={from:{...a},to:{...s,row:n-1,rowOffset:h.endY-h.startY}},c=x(u,this._selectionRenderService,this._skeletonManagerService)}}return u!=null&&c!=null?{newSheetTransform:u,newTransform:c}:null}_commandListener(){this.disposeWithMe(this._commandService.onCommandExecuted(i=>{i.id===v.SetWorksheetActiveOperation.id&&setTimeout(()=>{const r=i.params,{unitId:n,subUnitId:e}=r,t=this._drawingManagerService.drawingManagerData,o=[],a=[];Object.keys(t).forEach(s=>{const d=t[s];d!=null&&Object.keys(d).forEach(m=>{const u=d[m].data;u!=null&&Object.keys(u).forEach(c=>{if(s===n&&m===e){const h=u[c];h.transform=x(h.sheetTransform,this._selectionRenderService,this._skeletonManagerService),o.push(u[c])}else a.push(u[c])})})}),this._drawingManagerService.removeNotification(a),this._drawingManagerService.addNotification(o)},0)}))}_sheetRefreshListener(){this.disposeWithMe(this._commandService.onCommandExecuted(i=>{Pn.includes(i.id)&&requestIdleCallback(()=>{const r=i.params,{unitId:n,subUnitId:e,ranges:t}=r;this._refreshDrawingTransform(n,e,t)})}))}_refreshDrawingTransform(i,r,n){const e=this._drawingManagerService.getDrawingData(i,r),t=[];Object.keys(e).forEach(o=>{const a=e[o],{sheetTransform:s,transform:d,anchorType:m=f.SheetDrawingAnchorType.Position}=a;if(m===f.SheetDrawingAnchorType.None)return!0;const{from:u,to:c}=s,{row:h,column:g}=u,{row:p,column:S}=c;for(let w=0;w<n.length;w++){const _=n[w],{startRow:C,endRow:M,startColumn:R,endColumn:D}=_;if(l.Rectangle.intersects({startRow:C,endRow:M,startColumn:R,endColumn:D},{startRow:h,endRow:p,startColumn:g,endColumn:S})||h>M||g>D){const T=m===f.SheetDrawingAnchorType.Position,I=x(s,this._selectionRenderService,this._skeletonManagerService);t.push({...a,transform:{...I,width:T?d==null?void 0:d.width:I==null?void 0:I.width,height:T?d==null?void 0:d.height:I==null?void 0:I.height}});break}}}),t.length!==0&&(this._drawingManagerService.refreshTransform(t),this._commandService.syncExecuteCommand($.id,[i]))}};It=En([me(1,N.IRenderManagerService),me(2,l.ICommandService),me(3,A.ISheetSelectionRenderService),me(4,l.Inject(A.SheetSkeletonManagerService)),me(5,l.Inject(v.SheetInterceptorService)),me(6,f.ISheetDrawingService),me(7,P.IDrawingManagerService),me(8,l.IUniverInstanceService)],It);var ee=function(){return ee=Object.assign||function(i){for(var r,n=1,e=arguments.length;n<e;n++){r=arguments[n];for(var t in r)Object.prototype.hasOwnProperty.call(r,t)&&(i[t]=r[t])}return i},ee.apply(this,arguments)},An=function(i,r){var n={};for(var e in i)Object.prototype.hasOwnProperty.call(i,e)&&r.indexOf(e)<0&&(n[e]=i[e]);if(i!=null&&typeof Object.getOwnPropertySymbols=="function")for(var t=0,e=Object.getOwnPropertySymbols(i);t<e.length;t++)r.indexOf(e[t])<0&&Object.prototype.propertyIsEnumerable.call(i,e[t])&&(n[e[t]]=i[e[t]]);return n},jt=q.forwardRef(function(i,r){var n=i.icon,e=i.id,t=i.className,o=i.extend,a=An(i,["icon","id","className","extend"]),s="univerjs-icon univerjs-icon-".concat(e," ").concat(t||"").trim(),d=q.useRef("_".concat(jn()));return Wt(n,"".concat(e),{defIds:n.defIds,idSuffix:d.current},ee({ref:r,className:s},a),o)});function Wt(i,r,n,e,t){return q.createElement(i.tag,ee(ee({key:r},Un(i,n,t)),e),(Nn(i,n).children||[]).map(function(o,a){return Wt(o,"".concat(r,"-").concat(i.tag,"-").concat(a),n,void 0,t)}))}function Un(i,r,n){var e=ee({},i.attrs);n!=null&&n.colorChannel1&&e.fill==="colorChannel1"&&(e.fill=n.colorChannel1);var t=r.defIds;return!t||t.length===0||(i.tag==="use"&&e["xlink:href"]&&(e["xlink:href"]=e["xlink:href"]+r.idSuffix),Object.entries(e).forEach(function(o){var a=o[0],s=o[1];typeof s=="string"&&(e[a]=s.replace(/url\(#(.*)\)/,"url(#$1".concat(r.idSuffix,")")))})),e}function Nn(i,r){var n,e=r.defIds;return!e||e.length===0?i:i.tag==="defs"&&(!((n=i.children)===null||n===void 0)&&n.length)?ee(ee({},i),{children:i.children.map(function(t){return typeof t.attrs.id=="string"&&e&&e.indexOf(t.attrs.id)>-1?ee(ee({},t),{attrs:ee(ee({},t.attrs),{id:t.attrs.id+r.idSuffix})}):t})}):i}function jn(){return Math.random().toString(36).substring(2,8)}jt.displayName="UniverIcon";var Wn={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"}}]},Bt=q.forwardRef(function(i,r){return q.createElement(jt,Object.assign({},i,{id:"add-image-single",ref:r,icon:Wn}))});Bt.displayName="AddImageSingle";const Ct={id:"sheet.command.delete-drawing",type:l.CommandType.COMMAND,handler:i=>{const r=i.get(l.ICommandService),e=i.get(f.ISheetDrawingService).getFocusDrawings();if(e.length===0)return!1;const t=e[0].unitId,o=e.map(a=>{const{unitId:s,subUnitId:d,drawingId:m,drawingType:u}=a;return{unitId:s,subUnitId:d,drawingId:m,drawingType:u}});return r.executeCommand(Ee.id,{unitId:t,drawings:o})}},Je={id:"sheet.command.insert-float-image",type:l.CommandType.COMMAND,handler:i=>{var n,e;return(e=(n=i.get(N.IRenderManagerService).getCurrentTypeOfRenderer(l.UniverInstanceType.UNIVER_SHEET))==null?void 0:n.with(Ue).insertFloatImage())!=null?e:!1}},yt={id:"sheet.command.insert-cell-image",type:l.CommandType.COMMAND,handler:i=>{var n,e;return(e=(n=i.get(N.IRenderManagerService).getCurrentTypeOfRenderer(l.UniverInstanceType.UNIVER_SHEET))==null?void 0:n.with(Ue).insertCellImage())!=null?e:!1}},Ce={id:"sheet.command.move-drawing",type:l.CommandType.COMMAND,handler:(i,r)=>{const n=i.get(l.ICommandService),e=i.get(f.ISheetDrawingService),t=i.get(A.ISheetSelectionRenderService),{direction:o}=r,a=e.getFocusDrawings();if(a.length===0)return!1;const s=a[0].unitId,d=a.map(u=>{const{transform:c}=u;if(c==null)return null;const h={...c},{left:g=0,top:p=0}=c;return o===l.Direction.UP?h.top=p-1:o===l.Direction.DOWN?h.top=p+1:o===l.Direction.LEFT?h.left=g-1:o===l.Direction.RIGHT&&(h.left=g+1),{...u,transform:h,sheetTransform:H(h,t)}}).filter(u=>u!=null);return n.syncExecuteCommand(Ae.id,{unitId:s,drawings:d})?(n.syncExecuteCommand($.id,[s]),!0):!1}},kt="addition-and-subtraction-single",Dt="sheet.menu.image";function Bn(i){return{id:Dt,type:V.MenuItemType.SUBITEMS,icon:kt,tooltip:"sheetImage.title",hidden$:V.getMenuHiddenObservable(i,l.UniverInstanceType.UNIVER_SHEET),disabled$:A.getCurrentRangeDisable$(i,{workbookTypes:[v.WorkbookEditablePermission],worksheetTypes:[v.WorksheetEditPermission],rangeTypes:[v.RangeProtectionPermissionEditPoint]})}}function kn(i){return{id:Je.id,title:"sheetImage.upload.float",type:V.MenuItemType.BUTTON,hidden$:V.getMenuHiddenObservable(i,l.UniverInstanceType.UNIVER_SHEET)}}function Ln(i){return{id:yt.id,title:"sheetImage.upload.cell",type:V.MenuItemType.BUTTON}}const pe={imageCommonPanel:"univer-image-common-panel",imageCommonPanelGrid:"univer-image-common-panel-grid",imageCommonPanelBorder:"univer-image-common-panel-border",imageCommonPanelTitle:"univer-image-common-panel-title",imageCommonPanelSubtitle:"univer-image-common-panel-subtitle",imageCommonPanelRow:"univer-image-common-panel-row",imageCommonPanelRowVertical:"univer-image-common-panel-row-vertical",imageCommonPanelColumn:"univer-image-common-panel-column",imageCommonPanelColumnCenter:"univer-image-common-panel-column-center",imageCommonPanelInline:"univer-image-common-panel-inline",imageCommonPanelSpan2:"univer-image-common-panel-span2",imageCommonPanelSpan3:"univer-image-common-panel-span3",imageCommonPanelInput:"univer-image-common-panel-input",sheetImageMenu:"univer-sheet-image-menu",sheetImageMenuInput:"univer-sheet-image-menu-input"};function Lt(i){var r,n,e="";if(typeof i=="string"||typeof i=="number")e+=i;else if(typeof i=="object")if(Array.isArray(i)){var t=i.length;for(r=0;r<t;r++)i[r]&&(n=Lt(i[r]))&&(e&&(e+=" "),e+=n)}else for(n in i)i[n]&&(e&&(e+=" "),e+=n);return e}function Ze(){for(var i,r,n=0,e="",t=arguments.length;n<t;n++)(i=arguments[n])&&(r=Lt(i))&&(e&&(e+=" "),e+=r);return e}const Gn=i=>{var M;const r=l.useDependency(l.ICommandService),n=l.useDependency(l.LocaleService),e=l.useDependency(P.IDrawingManagerService),t=l.useDependency(N.IRenderManagerService),{drawings:o}=i,a=o[0];if(a==null)return;const{unitId:s}=a,d=t.getRenderById(s),m=d==null?void 0:d.scene;if(m==null)return;const u=m.getTransformerByCreate(),[c,h]=q.useState(!0),g=(M=a.anchorType)!=null?M:f.SheetDrawingAnchorType.Position,[p,S]=q.useState(g);function w(R,D){const T=[];return R.forEach(I=>{const{oKey:j}=I,O=D.getDrawingOKey(j);if(O==null)return T.push(null),!0;const{unitId:G,subUnitId:U,drawingId:E,drawingType:y,anchorType:W,sheetTransform:B}=O;T.push({unitId:G,subUnitId:U,drawingId:E,anchorType:W,sheetTransform:B,drawingType:y})}),T}q.useEffect(()=>{const R=u.clearControl$.subscribe(T=>{T===!0&&h(!1)}),D=u.changeStart$.subscribe(T=>{var O;const{objects:I}=T,j=w(I,e);if(j.length===0)h(!1);else if(j.length>=1){h(!0);const G=((O=j[0])==null?void 0:O.anchorType)||f.SheetDrawingAnchorType.Position;S(G)}});return()=>{D.unsubscribe(),R.unsubscribe()}},[]);function _(R){S(R);const D=e.getFocusDrawings();if(D.length===0)return;const T=D.map(I=>({unitId:I.unitId,subUnitId:I.subUnitId,drawingId:I.drawingId,anchorType:R}));r.executeCommand(Ae.id,{unitId:D[0].unitId,drawings:T})}const C=R=>R?"block":"none";return X.jsxs("div",{className:Ze(pe.imageCommonPanelGrid,pe.imageCommonPanelBorder),style:{display:C(c)},children:[X.jsx("div",{className:pe.imageCommonPanelRow,children:X.jsx("div",{className:Ze(pe.imageCommonPanelColumn,pe.imageCommonPanelTitle),children:X.jsx("div",{children:n.t("drawing-anchor.title")})})}),X.jsx("div",{className:Ze(pe.imageCommonPanelRow),children:X.jsx("div",{className:Ze(pe.imageCommonPanelColumn),children:X.jsxs(ne.RadioGroup,{value:p,onChange:_,direction:"vertical",children:[X.jsx(ne.Radio,{value:f.SheetDrawingAnchorType.Both,children:n.t("drawing-anchor.both")}),X.jsx(ne.Radio,{value:f.SheetDrawingAnchorType.Position,children:n.t("drawing-anchor.position")}),X.jsx(ne.Radio,{value:f.SheetDrawingAnchorType.None,children:n.t("drawing-anchor.none")})]})})})]})},Yn=()=>{const i=l.useDependency(P.IDrawingManagerService),r=i.getFocusDrawings(),[n,e]=q.useState(r);return q.useEffect(()=>{const t=i.focus$.subscribe(o=>{e(o)});return()=>{t.unsubscribe()}},[]),!!(n!=null&&n.length)&&X.jsxs("div",{className:pe.imageCommonPanel,children:[X.jsx(ge.DrawingCommonPanel,{drawings:n}),X.jsx(Gn,{drawings:n})]})},Fn={[V.RibbonStartGroup.FORMULAS_INSERT]:{[Dt]:{order:3,menuItemFactory:Bn,[Je.id]:{order:0,menuItemFactory:kn},[yt.id]:{order:1,menuItemFactory:Ln}}}};function je(i){return!i.getContextValue(l.FOCUSING_FX_BAR_EDITOR)&&!i.getContextValue(l.EDITOR_ACTIVATED)&&!i.getContextValue(l.FOCUSING_PANEL_EDITOR)&&i.getContextValue(l.FOCUSING_COMMON_DRAWINGS)}const $n={id:Ce.id,description:"shortcut.sheet.drawing-move-down",group:"4_sheet-drawing-view",binding:V.KeyCode.ARROW_DOWN,priority:100,preconditions:je,staticParameters:{direction:l.Direction.DOWN}},Vn={id:Ce.id,description:"shortcut.sheet.drawing-move-up",group:"4_sheet-drawing-view",binding:V.KeyCode.ARROW_UP,priority:100,preconditions:je,staticParameters:{direction:l.Direction.UP}},Hn={id:Ce.id,description:"shortcut.sheet.drawing-move-left",group:"4_sheet-drawing-view",binding:V.KeyCode.ARROW_LEFT,priority:100,preconditions:je,staticParameters:{direction:l.Direction.LEFT}},Xn={id:Ce.id,description:"shortcut.sheet.drawing-move-right",group:"4_sheet-drawing-view",binding:V.KeyCode.ARROW_RIGHT,priority:100,preconditions:je,staticParameters:{direction:l.Direction.RIGHT}},xn={id:Ct.id,description:"shortcut.sheet.drawing-delete",group:"4_sheet-drawing-view",preconditions:je,binding:V.KeyCode.DELETE,mac:V.KeyCode.BACKSPACE};var Kn=Object.defineProperty,zn=Object.getOwnPropertyDescriptor,Jn=(i,r,n,e)=>{for(var t=e>1?void 0:e?zn(r,n):r,o=i.length-1,a;o>=0;o--)(a=i[o])&&(t=(e?a(r,n,t):a(t))||t);return e&&t&&Kn(r,n,t),t},qe=(i,r)=>(n,e)=>r(n,e,i);let Qe=class extends l.Disposable{constructor(i,r,n,e){super(),this._componentManager=i,this._menuManagerService=r,this._commandService=n,this._shortcutService=e,this._init()}_initCustomComponents(){const i=this._componentManager;this.disposeWithMe(i.register(kt,Bt)),this.disposeWithMe(i.register(Ot,Yn))}_initMenus(){this._menuManagerService.mergeMenu(Fn)}_initCommands(){[Je,yt,Pe,Ee,Ae,gt,$,ht,ft,wt,Ce,Ct,St].forEach(i=>this.disposeWithMe(this._commandService.registerCommand(i)))}_initShortcuts(){[$n,Vn,Hn,Xn,xn].forEach(i=>{this.disposeWithMe(this._shortcutService.registerShortcut(i))})}_init(){this._initCommands(),this._initCustomComponents(),this._initMenus(),this._initShortcuts()}};Qe=Jn([qe(0,l.Inject(V.ComponentManager)),qe(1,V.IMenuManagerService),qe(2,l.ICommandService),qe(3,V.IShortcutService)],Qe);var Zn=Object.defineProperty,qn=Object.getOwnPropertyDescriptor,Qn=(i,r,n,e)=>{for(var t=e>1?void 0:e?qn(r,n):r,o=i.length-1,a;o>=0;o--)(a=i[o])&&(t=(e?a(r,n,t):a(t))||t);return e&&t&&Zn(r,n,t),t},ve=(i,r)=>(n,e)=>r(n,e,i);function er(i,r,n,e,t){const{scaleX:o,scaleY:a}=r.getAncestorScale(),s=r.getViewport(N.SHEET_VIEWPORT_KEY.VIEW_MAIN),d={left:!0,top:!0};if(!s)return{...i,absolute:d};const{left:m,right:u,top:c,bottom:h}=i;let{top:g,left:p,viewportScrollX:S,viewportScrollY:w}=s;const{boundsOfViewArea:_,scrollDirectionResponse:C}=t||{};_&&(l.Tools.isDefine(_.top)&&(g=_.top),l.Tools.isDefine(_.left)&&(p=_.left)),C==="HORIZONTAL"&&(w=0),C==="VERTICAL"&&(S=0);let M,R;m<p?(d.left=!0,M=(p+(m-p))*o,R=Math.max(Math.min((p+(u-p))*o,p*o),(u-S)*o)):(d.left=!1,M=Math.max((m-S)*o,p*o),R=Math.max((u-S)*o,p*o));let D,T;return c<g?(d.top=!0,D=(g+(c-g))*a,T=Math.max(Math.min((g+(u-g))*a,g*a),(h-w)*a)):(d.top=!1,D=Math.max((c-w)*a,g*a),T=Math.max((h-w)*a,g*a)),{left:M,right:R,top:D,bottom:T,absolute:d}}const se=(i,r,n,e,t)=>{const{scene:o}=r,{left:a,top:s,width:d,height:m,angle:u}=i,c={left:a,right:a+d,top:s,bottom:s+m},h=er(c,o,n,e,t),{scaleX:g,scaleY:p}=o.getAncestorScale();return{startX:h.left,endX:h.right,startY:h.top,endY:h.bottom,rotate:u,width:d*g,height:m*p,absolute:h.absolute}};b.SheetCanvasFloatDomManagerService=class extends l.Disposable{constructor(n,e,t,o,a,s,d){super();Z(this,"_domLayerMap",new Map);Z(this,"_domLayerInfoMap",new Map);Z(this,"_transformChange$",new k.Subject);Z(this,"transformChange$",this._transformChange$.asObservable());Z(this,"_add$",new k.Subject);Z(this,"add$",this._add$.asObservable());Z(this,"_remove$",new k.Subject);Z(this,"remove$",this._remove$.asObservable());Z(this,"_hooks",[]);this._renderManagerService=n,this._univerInstanceService=e,this._commandService=t,this._drawingManagerService=o,this._canvasFloatDomService=a,this._sheetDrawingService=s,this._lifecycleService=d,this._drawingAddListener(),this._featureUpdateListener(),this._deleteListener(),this._bindScrollEvent()}_bindScrollEvent(){this._lifecycleService.lifecycle$.pipe(k.filter(n=>n===l.LifecycleStages.Rendered),k.take(1)).subscribe(()=>{this._scrollUpdateListener()})}_ensureMap(n,e){let t=this._domLayerMap.get(n);t||(t=new Map,this._domLayerMap.set(n,t));let o=t.get(e);return o||(o=new Map,t.set(e,o)),o}getFloatDomInfo(n){return this._domLayerInfoMap.get(n)}_getSceneAndTransformerByDrawingSearch(n){if(n==null)return;const e=this._renderManagerService.getRenderById(n),t=e==null?void 0:e.scene;if(e==null||t==null)return null;const o=t.getTransformerByCreate(),a=e.engine.getCanvasElement();return{scene:t,transformer:o,renderUnit:e,canvas:a}}_getFloatDomProps(n){let e;return this._hooks.forEach(t=>{e=t.onGetFloatDomProps(n)}),e}_drawingAddListener(){this.disposeWithMe(this._drawingManagerService.add$.subscribe(n=>{n.forEach(e=>{var re,ie,J;const{unitId:t,subUnitId:o,drawingId:a}=e,s=v.getSheetCommandTarget(this._univerInstanceService,{unitId:t,subUnitId:o}),d=this._drawingManagerService.getDrawingByParam(e),m=this._univerInstanceService.getUnit(t,l.UniverInstanceType.UNIVER_SHEET);if(!m)return;const u=m.getActiveSheet().getSheetId();if(!d||!s)return;const c=(re=this._renderManagerService.getRenderById(t))==null?void 0:re.with(A.SheetSkeletonManagerService).getWorksheetSkeleton(o);if(!c)return;const{transform:h,drawingType:g,data:p}=d;if(g!==l.DrawingTypeEnum.DRAWING_DOM&&g!==l.DrawingTypeEnum.DRAWING_CHART)return;const S=this._getSceneAndTransformerByDrawingSearch(t);if(S==null)return;const{scene:w,canvas:_}=S;if(h==null)return!0;if(u!==o)return;const{left:C,top:M,width:R,height:D,angle:T,flipX:I,flipY:j,skewX:O,skewY:G}=h,U=P.getDrawingShapeKeyByDrawingSearch({unitId:t,subUnitId:o,drawingId:a}),E=w.getObject(U);if(E!=null){E.transformByState({left:C,top:M,width:R,height:D,angle:T,flipX:I,flipY:j,skewX:O,skewY:G});return}const y={left:C,top:M,width:R,height:D,zIndex:this._drawingManagerService.getDrawingOrder(t,o).length-1},W=g===l.DrawingTypeEnum.DRAWING_CHART;if(W){const F=p?p.backgroundColor:"white";y.fill=F,y.rotateEnabled=!1,p&&p.border&&(y.stroke=p.border),y.paintFirst="stroke",y.strokeWidth=1,y.borderEnabled=!1,y.radius=8}const B=new N.Rect(U,y);W&&B.setObjectType(N.ObjectType.CHART),w.addObject(B,N.DRAWING_OBJECT_LAYER_INDEX),d.allowTransform!==!1&&w.attachTransformerTo(B);const z=this._ensureMap(t,o),K=new l.DisposableCollection,_e=se(B,S.renderUnit,c.skeleton,s.worksheet),ae=new k.BehaviorSubject(_e),Ie={dispose:K,rect:B,position$:ae,unitId:t,subUnitId:o};this._canvasFloatDomService.addFloatDom({position$:ae,id:a,componentKey:d.componentKey,onPointerDown:F=>{_.dispatchEvent(new PointerEvent(F.type,F))},onPointerMove:F=>{_.dispatchEvent(new PointerEvent(F.type,F))},onPointerUp:F=>{_.dispatchEvent(new PointerEvent(F.type,F))},onWheel:F=>{_.dispatchEvent(new WheelEvent(F.type,F))},props:(J=(ie=z.get(a))==null?void 0:ie.props)!=null?J:this._getFloatDomProps(a),data:p,unitId:t});const ce=B.onTransformChange$.subscribeEvent(()=>{const F=se(B,S.renderUnit,c.skeleton,s.worksheet);ae.next(F)});K.add(()=>{this._canvasFloatDomService.removeFloatDom(a)}),ce&&K.add(ce),this._domLayerInfoMap.set(a,Ie),z.set(a,{...z.get(a)})})})),this.disposeWithMe(this._drawingManagerService.remove$.subscribe(n=>{n.forEach(e=>{const{unitId:t,subUnitId:o,drawingId:a}=e,s=P.getDrawingShapeKeyByDrawingSearch({unitId:t,subUnitId:o,drawingId:a}),d=this._getSceneAndTransformerByDrawingSearch(t);if(d==null)return;const{transformer:m,scene:u}=d,c=u.getObject(s);c!=null&&c.oKey&&m.clearControlByIds([c==null?void 0:c.oKey])})}))}_scrollUpdateListener(){const n=(e,t)=>{var u;const o=this._getSceneAndTransformerByDrawingSearch(e),a=this._ensureMap(e,t),s=Array.from(a.keys()),d=v.getSheetCommandTarget(this._univerInstanceService,{unitId:e,subUnitId:t}),m=(u=this._renderManagerService.getRenderById(e))==null?void 0:u.with(A.SheetSkeletonManagerService).getWorksheetSkeleton(t);!o||!d||!m||s.forEach(c=>{const h=this._domLayerInfoMap.get(c);if(h){const g=se(h.rect,o.renderUnit,m.skeleton,d.worksheet,h);h.position$.next(g)}})};this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(l.UniverInstanceType.UNIVER_SHEET).pipe(k.filter(e=>!!e),k.switchMap(e=>e.activeSheet$),k.filter(e=>!!e),k.map(e=>{const t=this._renderManagerService.getRenderById(e.getUnitId());return t?{render:t,unitId:e.getUnitId(),subUnitId:e.getSheetId()}:null}),k.filter(e=>!!e),k.switchMap(e=>l.fromEventSubject(e.render.scene.getViewport(N.SHEET_VIEWPORT_KEY.VIEW_MAIN).onScrollAfter$).pipe(k.map(()=>({unitId:e.unitId,subUnitId:e.subUnitId}))))).subscribe(({unitId:e,subUnitId:t})=>{n(e,t)})),this.disposeWithMe(this._commandService.onCommandExecuted(e=>{var t,o;if(e.id===A.SetZoomRatioOperation.id){const a=e.params,{unitId:s}=a;Array.from((o=(t=this._domLayerMap.get(s))==null?void 0:t.keys())!=null?o:[]).forEach(m=>{n(s,m)})}else if(e.id===v.SetFrozenMutation.id){const{unitId:a,subUnitId:s}=e.params;n(a,s)}}))}_getPosition(n,e){var g;const{startX:t,endX:o,startY:a,endY:s}=n,d=(g=this._renderManagerService.getRenderById(e))==null?void 0:g.with(A.ISheetSelectionRenderService);if(d==null)return;const m=d.getCellWithCoordByOffset(t,a);if(m==null)return;const u={column:m.actualColumn,columnOffset:t-m.startX,row:m.actualRow,rowOffset:a-m.startY},c=d.getCellWithCoordByOffset(o,s);if(c==null)return;const h={column:c.actualColumn,columnOffset:o-c.startX,row:c.actualRow,rowOffset:s-c.startY};return{from:u,to:h}}_featureUpdateListener(){this.disposeWithMe(this._drawingManagerService.update$.subscribe(n=>{n.forEach(e=>{const t=this._drawingManagerService.getDrawingByParam(e);if(!t||t.drawingType!==l.DrawingTypeEnum.DRAWING_DOM&&t.drawingType!==l.DrawingTypeEnum.DRAWING_CHART)return;const o={...t.transform};this._transformChange$.next({id:e.drawingId,value:o})})}))}_deleteListener(){this.disposeWithMe(this._drawingManagerService.remove$.subscribe(n=>{n.forEach(e=>{this._removeDom(e.drawingId)})}))}updateFloatDomProps(n,e,t,o){const a=this._domLayerInfoMap.get(t),s=this._getSceneAndTransformerByDrawingSearch(n);if(a&&s){const{scene:d}=s,m=P.getDrawingShapeKeyByDrawingSearch({unitId:n,subUnitId:e,drawingId:t}),u=d.getObject(m);u&&u instanceof N.Rect&&u.setProps(o)}}addFloatDomToPosition(n,e){const t=v.getSheetCommandTarget(this._univerInstanceService,{unitId:n.unitId,subUnitId:n.subUnitId});if(!t)throw new Error("cannot find current target!");const{unitId:o,subUnitId:a}=t,{initPosition:s,componentKey:d,data:m,allowTransform:u=!0}=n,c=e!=null?e:l.generateRandomId(),h=this._getPosition(s,o);if(h==null)return;this._ensureMap(o,a).set(c,n);const p={unitId:o,subUnitId:a,drawingId:c,drawingType:n.type||l.DrawingTypeEnum.DRAWING_DOM,componentKey:d,sheetTransform:h,transform:{left:s.startX,top:s.startY,width:s.endX-s.startX,height:s.endY-s.startY},data:m,allowTransform:u};return this._commandService.executeCommand(Pe.id,{unitId:o,drawings:[p]}),this._add$.next({unitId:o,subUnitId:a,id:c}),{id:c,dispose:()=>{this._removeDom(c,!0)}}}_removeDom(n,e=!1){const t=this._domLayerInfoMap.get(n);if(!t)return;const{unitId:o,subUnitId:a}=t;this._domLayerInfoMap.delete(n),t.dispose.dispose();const s=this._getSceneAndTransformerByDrawingSearch(o);if(s&&s.scene.removeObject(t.rect),e){this._ensureMap(o,a).delete(n);const m=this._drawingManagerService.getDrawingByParam({unitId:o,subUnitId:a,drawingId:n});if(!m)return;const u=this._sheetDrawingService.getBatchRemoveOp([m]),{redo:c,objects:h}=u;this._commandService.syncExecuteCommand(f.SetDrawingApplyMutation.id,{unitId:o,subUnitId:a,op:c,objects:h,type:f.DrawingApplyType.REMOVE})}}addHook(n){return this._hooks.push(n),{dispose:()=>{const e=this._hooks.findIndex(t=>t===n);this._hooks.splice(e,1)}}}addFloatDomToRange(n,e,t,o){var j,O,G,U,E;const a=v.getSheetCommandTarget(this._univerInstanceService,{unitId:e.unitId,subUnitId:e.subUnitId});if(!a)throw new Error("cannot find current target!");const{unitId:s,subUnitId:d}=a,m=this._getSceneAndTransformerByDrawingSearch(s);if(!m)return;const u=this._renderManagerService.getRenderById(s);if(!u)return;const c=(j=this._renderManagerService.getRenderById(s))==null?void 0:j.with(A.SheetSkeletonManagerService).getWorksheetSkeleton(d);if(!c)return;const{componentKey:h,data:g,allowTransform:p=!0}=e,S=o!=null?o:l.generateRandomId(),{position:w,position$:_}=this._createRangePositionObserver(n,u,c.skeleton),C=this._getPosition(w,s);if(C==null)return;this._ensureMap(s,d).set(S,e);const R=m.scene,{scaleX:D}=R.getAncestorScale(),T=et(w,t,D),I={unitId:s,subUnitId:d,drawingId:S,drawingType:e.type||l.DrawingTypeEnum.DRAWING_DOM,componentKey:h,sheetTransform:C,transform:{left:T.startX,top:T.startY,width:T.width,height:T.height},data:g,allowTransform:p};{const{unitId:y,subUnitId:W,drawingId:B}=I,z=v.getSheetCommandTarget(this._univerInstanceService,{unitId:y,subUnitId:W}),K=I,_e=this._univerInstanceService.getUnit(y,l.UniverInstanceType.UNIVER_SHEET);if(!_e)return;const ae=_e.getActiveSheet().getSheetId();if(!K||!z)return;const Ie=(O=this._renderManagerService.getRenderById(y))==null?void 0:O.with(A.SheetSkeletonManagerService);if(!Ie)return;const ce=Ie.getWorksheetSkeleton(W);if(!ce)return;const{transform:re,drawingType:ie,data:J}=K;if(ie!==l.DrawingTypeEnum.DRAWING_DOM&&ie!==l.DrawingTypeEnum.DRAWING_CHART)return;const F=this._getSceneAndTransformerByDrawingSearch(y);if(F==null)return;const{scene:ye,canvas:De}=F;if(re==null||ae!==W)return;const{left:nt,top:rt,width:it,height:ot,angle:Tt,flipX:Rt,flipY:at,skewX:st,skewY:Me}=re,ct=P.getDrawingShapeKeyByDrawingSearch({unitId:y,subUnitId:W,drawingId:B}),de=ye.getObject(ct);if(de!=null){de.transformByState({left:nt,top:rt,width:it,height:ot,angle:Tt,flipX:Rt,flipY:at,skewX:st,skewY:Me});return}const te={left:nt,top:rt,width:it,height:ot,zIndex:this._drawingManagerService.getDrawingOrder(y,W).length-1},Te=ie===l.DrawingTypeEnum.DRAWING_CHART;if(Te){const L=J?J.backgroundColor:"white";te.fill=L,te.rotateEnabled=!1,J&&J.border&&(te.stroke=J.border),te.paintFirst="stroke",te.strokeWidth=1,te.borderEnabled=!1,te.radius=8}const oe=new N.Rect(ct,te);Te&&oe.setObjectType(N.ObjectType.CHART),ye.addObject(oe,N.DRAWING_OBJECT_LAYER_INDEX),K.allowTransform!==!1&&ye.attachTransformerTo(oe);const Be=this._ensureMap(y,W),le=new l.DisposableCollection,Re=ye.getMainViewport(),be={top:Re.top,left:Re.left,bottom:Re.bottom,right:Re.right},ue={dispose:le,rect:oe,boundsOfViewArea:be,domAnchor:t,unitId:y,subUnitId:W},dt=se(oe,F.renderUnit,ce.skeleton,z.worksheet,ue),fe=new k.BehaviorSubject(dt);ue.position$=fe;let Y={position$:fe,id:B,componentKey:K.componentKey,onPointerDown:()=>{},onPointerMove:()=>{},onPointerUp:()=>{},onWheel:L=>{De.dispatchEvent(new WheelEvent(L.type,L))},props:(U=(G=Be.get(B))==null?void 0:G.props)!=null?U:this._getFloatDomProps(B),data:J,unitId:y};e.eventPassThrough&&(Y={...Y,onPointerDown:L=>{De.dispatchEvent(new PointerEvent(L.type,L))},onPointerMove:L=>{De.dispatchEvent(new PointerEvent(L.type,L))},onPointerUp:L=>{De.dispatchEvent(new PointerEvent(L.type,L))}}),this._canvasFloatDomService.addFloatDom(Y),this.disposeWithMe(_.subscribe(L=>{var Ft,$t,Vt,Ht;const ut=et({rotate:0,startX:L.startX,startY:L.startY,endX:L.endX,endY:L.endY,width:(Ft=t.width)!=null?Ft:L.width,height:($t=t.height)!=null?$t:L.height,absolute:{left:w.absolute.left,top:w.absolute.top}},t),or=P.getDrawingShapeKeyByDrawingSearch({unitId:y,subUnitId:W,drawingId:B}),ar=new N.Rect(or,{left:ut.startX,top:ut.startY,width:(Vt=t.width)!=null?Vt:L.width,height:(Ht=t.height)!=null?Ht:L.height,zIndex:this._drawingManagerService.getDrawingOrder(y,W).length-1}),sr=se(ar,F.renderUnit,ce.skeleton,z.worksheet,ue);fe.next(sr)}));const ke=(E=this._renderManagerService.getRenderById(y))==null?void 0:E.with(A.SheetSkeletonManagerService);ke==null||ke.currentSkeleton$.subscribe(L=>{L&&c.sheetId!==L.sheetId&&this._removeDom(S,!0)});const lt=oe.onTransformChange$.subscribeEvent(()=>{const L=se(oe,F.renderUnit,ce.skeleton,z.worksheet,ue);fe.next(L)});le.add(()=>{this._canvasFloatDomService.removeFloatDom(B)}),lt&&le.add(lt),this._domLayerInfoMap.set(B,ue),Be.set(B,{...Be.get(B)})}return{id:S,dispose:()=>{this._removeDom(S,!0)}}}addFloatDomToColumnHeader(n,e,t,o){var T,I,j,O,G;const a=v.getSheetCommandTarget(this._univerInstanceService,{unitId:e.unitId,subUnitId:e.subUnitId});if(!a)throw new Error("cannot find current target!");const{unitId:s,subUnitId:d}=a;if(!this._getSceneAndTransformerByDrawingSearch(s))return;const u=this._renderManagerService.getRenderById(s);if(!u)return;const c=(T=this._renderManagerService.getRenderById(s))==null?void 0:T.with(A.SheetSkeletonManagerService).getWorksheetSkeleton(d);if(!c)return;const{componentKey:h,data:g,allowTransform:p=!0}=e,S=o!=null?o:l.generateRandomId(),{position:w,position$:_}=this._createRangePositionObserver({startRow:0,endRow:0,startColumn:n,endColumn:n},u,c.skeleton),C=w;C.startY=0;const M=this._getPosition(w,s);if(M==null)return;this._ensureMap(s,d).set(S,e);const D={unitId:s,subUnitId:d,drawingId:S,drawingType:e.type||l.DrawingTypeEnum.DRAWING_DOM,componentKey:h,sheetTransform:M,transform:{left:C.startX,top:C.startY,width:C.width,height:C.height},data:g,allowTransform:p};{const{unitId:U,subUnitId:E,drawingId:y}=D,W=v.getSheetCommandTarget(this._univerInstanceService,{unitId:U,subUnitId:E}),B=D,z=this._univerInstanceService.getUnit(U,l.UniverInstanceType.UNIVER_SHEET);if(!z)return;const K=z.getActiveSheet().getSheetId();if(!B||!W)return;const _e=(I=this._renderManagerService.getRenderById(U))==null?void 0:I.with(A.SheetSkeletonManagerService);if(!_e)return;const ae=_e.getWorksheetSkeleton(E);if(!ae)return;const{transform:Ie,data:ce}=B,re=this._getSceneAndTransformerByDrawingSearch(U);if(re==null)return;const{scene:ie,canvas:J}=re;if(Ie==null||K!==E)return;const{left:F,top:ye,width:De,height:nt,angle:rt,flipX:it,flipY:ot,skewX:Tt,skewY:Rt}=Ie,at=P.getDrawingShapeKeyByDrawingSearch({unitId:U,subUnitId:E,drawingId:y}),st=ie.getObject(at);if(st!=null){st.transformByState({left:F,top:ye,width:De,height:nt,angle:rt,flipX:it,flipY:ot,skewX:Tt,skewY:Rt});return}const Me=et({rotate:0,startX:C.startX,startY:0,endX:w.endX,endY:w.endY,width:t.width,height:t.height,absolute:{left:w.absolute.left,top:w.absolute.top}},t),ct={left:Me.startX,top:Me.startY,width:Me.width,height:Me.height,zIndex:this._drawingManagerService.getDrawingOrder(U,E).length-1},de=new N.Rect(at,ct);ie.addObject(de,N.DRAWING_OBJECT_LAYER_INDEX),B.allowTransform!==!1&&ie.attachTransformerTo(de);const te=this._ensureMap(U,E),Te=new l.DisposableCollection,oe=ie.getMainViewport(),Be={top:0,left:oe.left,bottom:oe.bottom,right:oe.right},le={dispose:Te,rect:de,unitId:U,subUnitId:E,boundsOfViewArea:Be,domAnchor:t,scrollDirectionResponse:"HORIZONTAL"},Re=se(de,re.renderUnit,ae.skeleton,W.worksheet,le),be=new k.BehaviorSubject(Re);le.position$=be;let ue={position$:be,id:y,componentKey:B.componentKey,onPointerDown:()=>{},onPointerMove:()=>{},onPointerUp:()=>{},onWheel:Y=>{J.dispatchEvent(new WheelEvent(Y.type,Y))},props:(O=(j=te.get(y))==null?void 0:j.props)!=null?O:this._getFloatDomProps(y),data:ce,unitId:U};e.eventPassThrough&&(ue={...ue,onPointerDown:Y=>{J.dispatchEvent(new PointerEvent(Y.type,Y))},onPointerMove:Y=>{J.dispatchEvent(new PointerEvent(Y.type,Y))},onPointerUp:Y=>{J.dispatchEvent(new PointerEvent(Y.type,Y))}}),this._canvasFloatDomService.addFloatDom(ue);const dt=de.onTransformChange$.subscribeEvent(()=>{const Y=se(de,re.renderUnit,ae.skeleton,W.worksheet,le);be.next(Y)});this.disposeWithMe(_.subscribe(Y=>{const ke=et({rotate:0,startX:Y.startX,startY:0,endX:Y.endX,endY:Y.endY,width:t.width,height:t.height,absolute:{left:w.absolute.left,top:w.absolute.top}},t),lt=P.getDrawingShapeKeyByDrawingSearch({unitId:U,subUnitId:E,drawingId:y}),L=new N.Rect(lt,{left:ke.startX,top:0,width:t.width,height:t.height,zIndex:this._drawingManagerService.getDrawingOrder(U,E).length-1}),ut=se(L,re.renderUnit,ae.skeleton,W.worksheet,le);be.next(ut)}));const fe=(G=this._renderManagerService.getRenderById(U))==null?void 0:G.with(A.SheetSkeletonManagerService);fe==null||fe.currentSkeleton$.subscribe(Y=>{Y&&c.sheetId!==Y.sheetId&&this._removeDom(S,!0)}),Te.add(()=>{this._canvasFloatDomService.removeFloatDom(y)}),dt&&Te.add(dt),this._domLayerInfoMap.set(y,le),te.set(y,{...te.get(y)})}return{id:S,dispose:()=>{this._removeDom(S,!0)}}}_createRangePositionObserver(n,e,t){let{startRow:o,startColumn:a}=n;const s=We(o,a,t),d=new k.BehaviorSubject(s),m=We(n.endRow,n.endColumn,t),u=new k.BehaviorSubject(m),c=()=>{const _=We(o,a,t),C=We(n.endRow,n.endColumn,t);d.next(_),u.next(C)},h=new l.DisposableCollection;h.add(e.engine.clientRect$.subscribe(()=>c())),h.add(this._commandService.onCommandExecuted(_=>{if(_.id===v.SetWorksheetRowAutoHeightMutation.id&&_.params.rowsAutoHeightInfo.findIndex(M=>M.row===o)>-1){c();return}(v.COMMAND_LISTENER_SKELETON_CHANGE.indexOf(_.id)>-1||_.id===A.SetScrollOperation.id||_.id===A.SetZoomRatioOperation.id)&&c()}));const g=(_,C)=>{o=_,a=C,c()},p=()=>({rotate:0,width:m.right-s.left,height:m.bottom-s.top,absolute:{left:!0,top:!0},startX:s.left,startY:s.top,endX:m.right,endY:m.bottom}),S=d.pipe(k.map(_=>{const C=We(n.endRow,n.endColumn,t);return{rotate:0,width:C.right-_.left,height:C.bottom-_.top,absolute:{left:!0,top:!0},startX:_.left,startY:_.top,endX:C.right,endY:C.bottom}})),w=p();return{position$:S,position:w,updateRowCol:g,topLeftPos$:d,rightBottomPos$:u,disposable:h}}},b.SheetCanvasFloatDomManagerService=Qn([ve(0,l.Inject(N.IRenderManagerService)),ve(1,l.IUniverInstanceService),ve(2,l.Inject(l.ICommandService)),ve(3,P.IDrawingManagerService),ve(4,l.Inject(V.CanvasFloatDomService)),ve(5,f.ISheetDrawingService),ve(6,l.Inject(l.LifecycleService))],b.SheetCanvasFloatDomManagerService);function We(i,r,n){const e=n.getCellWithCoordByIndex(i,r),t=e.isMergedMainCell?e.mergeInfo:e;return{left:t.startX,right:t.endX,top:t.startY,bottom:t.endY}}function et(i,r,n){var m,u;n=n!=null?n:1;const e=i.endX-i.startX,t=i.endY-i.startY,o=(m=r==null?void 0:r.width)!=null?m:e,a=(u=r==null?void 0:r.height)!=null?u:t;let s=0,d=0;if(r){if(r.horizonOffsetAlign==="right"){const c=tt(r.marginX,e*n);s=i.endX-c-o}else s=i.startX+tt(r.marginX,e);if(r.verticalOffsetAlign==="bottom"){const c=tt(r.marginY,t*n);d=i.endY-c-a}else d=i.startY+tt(r.marginY,t)}return{rotate:0,startX:s,startY:d,endX:i.endX,endY:i.endY,width:o,height:a,absolute:{left:i.absolute.left,top:i.absolute.top}}}function tt(i,r){if(i===void 0)return 0;if(typeof i=="number")return i;const n=Number.parseFloat(i);return r*n/100}var Gt=Object.defineProperty,tr=Object.getOwnPropertyDescriptor,nr=(i,r,n)=>r in i?Gt(i,r,{enumerable:!0,configurable:!0,writable:!0,value:n}):i[r]=n,rr=(i,r,n,e)=>{for(var t=e>1?void 0:e?tr(r,n):r,o=i.length-1,a;o>=0;o--)(a=i[o])&&(t=(e?a(r,n,t):a(t))||t);return e&&t&&Gt(r,n,t),t},Mt=(i,r)=>(n,e)=>r(n,e,i),Yt=(i,r,n)=>nr(i,typeof r!="symbol"?r+"":r,n);const ir="SHEET_IMAGE_UI_PLUGIN";b.UniverSheetsDrawingUIPlugin=class extends l.Plugin{constructor(r=Et,n,e,t){super(),this._config=r,this._injector=n,this._renderManagerService=e,this._configService=t;const{menu:o,...a}=l.merge({},Et,this._config);o&&this._configService.setConfig("menu",o,{merge:!0}),this._configService.setConfig(Xt,a)}onStarting(){l.registerDependencies(this._injector,[[b.SheetCanvasFloatDomManagerService],[Qe],[Ge],[ze],[xe],[Xe],[Fe],[He],[$e]]),l.touchDependencies(this._injector,[[b.SheetCanvasFloatDomManagerService]])}onReady(){l.touchDependencies(this._injector,[[Xe]])}onRendered(){this._registerRenderModules(),l.touchDependencies(this._injector,[[xe],[ze],[Qe],[Fe],[He],[$e]])}onSteady(){this._injector.get(Ge)}_registerRenderModules(){[[Ue],[It],[pt]].forEach(r=>{this.disposeWithMe(this._renderManagerService.registerRenderModule(l.UniverInstanceType.UNIVER_SHEET,r))})}},Yt(b.UniverSheetsDrawingUIPlugin,"type",l.UniverInstanceType.UNIVER_SHEET),Yt(b.UniverSheetsDrawingUIPlugin,"pluginName",ir),b.UniverSheetsDrawingUIPlugin=rr([l.DependentOn(P.UniverDrawingPlugin,Se.UniverDocsDrawingPlugin,ge.UniverDrawingUIPlugin,f.UniverSheetsDrawingPlugin),Mt(1,l.Inject(l.Injector)),Mt(2,N.IRenderManagerService),Mt(3,l.IConfigService)],b.UniverSheetsDrawingUIPlugin),b.ClearSheetDrawingTransformerOperation=$,b.DeleteDrawingsCommand=Ct,b.EditSheetDrawingOperation=ht,b.GroupSheetDrawingCommand=ft,b.InsertFloatImageCommand=Je,b.InsertSheetDrawingCommand=Pe,b.MoveDrawingsCommand=Ce,b.RemoveSheetDrawingCommand=Ee,b.SHEETS_IMAGE_MENU_ID=Dt,b.SetDrawingArrangeCommand=St,b.SetSheetDrawingCommand=Ae,b.SidebarSheetDrawingOperation=gt,b.UngroupSheetDrawingCommand=wt,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.5.4",
3
+ "version": "0.5.5-nightly.202501201336",
4
4
  "private": false,
5
5
  "description": "",
6
6
  "author": "DreamNum <developer@univer.ai>",
@@ -59,17 +59,17 @@
59
59
  "dependencies": {
60
60
  "@univerjs/icons": "^0.2.12",
61
61
  "clsx": "^2.1.1",
62
- "@univerjs/design": "0.5.4",
63
- "@univerjs/docs-drawing": "0.5.4",
64
- "@univerjs/docs-ui": "0.5.4",
65
- "@univerjs/drawing": "0.5.4",
66
- "@univerjs/drawing-ui": "0.5.4",
67
- "@univerjs/engine-render": "0.5.4",
68
- "@univerjs/sheets": "0.5.4",
69
- "@univerjs/sheets-ui": "0.5.4",
70
- "@univerjs/core": "0.5.4",
71
- "@univerjs/ui": "0.5.4",
72
- "@univerjs/sheets-drawing": "0.5.4"
62
+ "@univerjs/core": "0.5.5-nightly.202501201336",
63
+ "@univerjs/docs-drawing": "0.5.5-nightly.202501201336",
64
+ "@univerjs/design": "0.5.5-nightly.202501201336",
65
+ "@univerjs/docs-ui": "0.5.5-nightly.202501201336",
66
+ "@univerjs/drawing": "0.5.5-nightly.202501201336",
67
+ "@univerjs/drawing-ui": "0.5.5-nightly.202501201336",
68
+ "@univerjs/engine-render": "0.5.5-nightly.202501201336",
69
+ "@univerjs/sheets": "0.5.5-nightly.202501201336",
70
+ "@univerjs/sheets-drawing": "0.5.5-nightly.202501201336",
71
+ "@univerjs/sheets-ui": "0.5.5-nightly.202501201336",
72
+ "@univerjs/ui": "0.5.5-nightly.202501201336"
73
73
  },
74
74
  "devDependencies": {
75
75
  "less": "^4.2.1",
@@ -80,7 +80,7 @@
80
80
  "typescript": "^5.7.2",
81
81
  "vite": "^6.0.7",
82
82
  "vitest": "^2.1.8",
83
- "@univerjs-infra/shared": "0.5.4"
83
+ "@univerjs-infra/shared": "0.5.5"
84
84
  },
85
85
  "scripts": {
86
86
  "test": "vitest run",