@univerjs/sheets-drawing-ui 0.5.0-nightly.202411201606 → 0.5.0-nightly.202411211606
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/index.js +1 -1
- package/lib/es/index.js +59 -55
- package/lib/umd/index.js +2 -2
- package/package.json +10 -10
package/lib/cjs/index.js
CHANGED
|
@@ -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 tt=H,nt=Symbol.for("react.element"),rt=Symbol.for("react.fragment"),it=Object.prototype.hasOwnProperty,ot=tt.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,st={key:!0,ref:!0,__self:!0,__source:!0};function Ge(i,n,r){var e,t={},o=null,s=null;r!==void 0&&(o=""+r),n.key!==void 0&&(o=""+n.key),n.ref!==void 0&&(s=n.ref);for(e in n)it.call(n,e)&&!st.hasOwnProperty(e)&&(t[e]=n[e]);if(i&&i.defaultProps)for(e in n=i.defaultProps,n)t[e]===void 0&&(t[e]=n[e]);return{$$typeof:nt,type:i,key:o,ref:s,props:t,_owner:ot.current}}ve.Fragment=rt;ve.jsx=Ge;ve.jsxs=Ge;$e.exports=ve;var k=$e.exports;const at="univer-upload-loading",ct="univer-upload-loading-body",dt="univer-upload-loading-body-animation",lt="univer-UniverCircleAnimation",ut="univer-upload-loading-body-text",ce={uploadLoading:at,uploadLoadingBody:ct,uploadLoadingBodyAnimation:dt,univerCircleAnimation:lt,uploadLoadingBodyText:ut},gt=()=>{const i=m.useDependency(O.IImageIoService),n=m.useDependency(m.LocaleService),[r,e]=H.useState(0);return H.useEffect(()=>{const t=i.change$.subscribe(o=>{e(o)});return()=>{t.unsubscribe()}},[i]),k.jsx("div",{style:{display:r>0?"block":"none"},className:ce.uploadLoading,children:k.jsxs("div",{className:ce.uploadLoadingBody,children:[k.jsx("div",{className:ce.uploadLoadingBodyAnimation}),k.jsx("div",{className:ce.uploadLoadingBodyText,children:`${n.t("uploadLoading.loading")}: ${r}`})]})})};var ht=Object.defineProperty,mt=Object.getOwnPropertyDescriptor,pt=(i,n,r,e)=>{for(var t=e>1?void 0:e?mt(n,r):n,o=i.length-1,s;o>=0;o--)(s=i[o])&&(t=(e?s(n,r,t):s(t))||t);return e&&t&&ht(n,r,t),t},Q=(i,n)=>(r,e)=>n(r,e,i);let he=class extends m.RxDisposable{constructor(n,r,e,t,o,s,c){super();Y(this,"_initImagePopupMenu",new Set);this._injector=n,this._drawingManagerService=r,this._canvasPopManagerService=e,this._renderManagerService=t,this._univerInstanceService=o,this._contextService=s,this._uiPartsService=c,this._init()}_init(){this._univerInstanceService.getCurrentTypeOfUnit$(m.UniverInstanceType.UNIVER_SHEET).pipe(L.takeUntil(this.dispose$)).subscribe(n=>this._create(n)),this._univerInstanceService.getTypeOfUnitDisposed$(m.UniverInstanceType.UNIVER_SHEET).pipe(L.takeUntil(this.dispose$)).subscribe(n=>this._dispose(n)),this._univerInstanceService.getAllUnitsForType(m.UniverInstanceType.UNIVER_SHEET).forEach(n=>this._create(n)),this._uiPartsService.registerComponent(G.BuiltInUIPart.CONTENT,()=>m.connectInjector(gt,this._injector))}_dispose(n){const r=n.getUnitId();this._renderManagerService.removeRender(r)}_create(n){if(!n)return;const r=n.getUnitId();this._renderManagerService.has(r)&&!this._initImagePopupMenu.has(r)&&(this._popupMenuListener(r),this._initImagePopupMenu.add(r))}_hasCropObject(n){const r=n.getAllObjectsByOrder();for(const e of r)if(e instanceof te.ImageCropperObject)return!0;return!1}_popupMenuListener(n){var o;const r=(o=this._renderManagerService.getRenderById(n))==null?void 0:o.scene;if(!r)return;const e=r.getTransformerByCreate();if(!e)return;let t;this.disposeWithMe(m.toDisposable(e.createControl$.subscribe(()=>{if(this._contextService.setContextValue(m.FOCUSING_COMMON_DRAWINGS,!0),this._hasCropObject(r))return;const s=e.getSelectedObjectMap();if(s.size>1){t==null||t.dispose();return}const c=s.values().next().value;if(!c)return;const d=c.oKey,h=this._drawingManagerService.getDrawingOKey(d);if(!h)return;const{unitId:l,subUnitId:a,drawingId:u,drawingType:g}=h,f=h.data;f&&f.disablePopup||(t==null||t.dispose(),t=this.disposeWithMe(this._canvasPopManagerService.attachPopupToObject(c,{componentKey:te.COMPONENT_IMAGE_POPUP_MENU,direction:"horizontal",offset:[2,0],extraProps:{menuItems:this._getImageMenuItems(l,a,u,g)}})),this._drawingManagerService.focusDrawing([{unitId:l,subUnitId:a,drawingId:u}]))}))),this.disposeWithMe(e.clearControl$.subscribe(()=>{t==null||t.dispose(),this._contextService.setContextValue(m.FOCUSING_COMMON_DRAWINGS,!1),this._drawingManagerService.focusDrawing(null)})),this.disposeWithMe(e.changing$.subscribe(()=>{t==null||t.dispose()}))}_getImageMenuItems(n,r,e,t){return[{label:"image-popup.edit",index:0,commandId:Oe.id,commandParams:{unitId:n,subUnitId:r,drawingId:e},disable:t===O.DrawingTypeEnum.DRAWING_DOM},{label:"image-popup.delete",index:1,commandId:ie.id,commandParams:{unitId:n,drawings:[{unitId:n,subUnitId:r,drawingId:e}]},disable:!1},{label:"image-popup.crop",index:2,commandId:te.OpenImageCropOperation.id,commandParams:{unitId:n,subUnitId:r,drawingId:e},disable:t===O.DrawingTypeEnum.DRAWING_DOM},{label:"image-popup.reset",index:3,commandId:te.ImageResetSizeOperation.id,commandParams:[{unitId:n,subUnitId:r,drawingId:e}],disable:t===O.DrawingTypeEnum.DRAWING_DOM}]}};he=pt([Q(0,m.Inject(m.Injector)),Q(1,O.IDrawingManagerService),Q(2,m.Inject(U.SheetCanvasPopManagerService)),Q(3,N.IRenderManagerService),Q(4,m.IUniverInstanceService),Q(5,m.IContextService),Q(6,m.Inject(G.IUIPartsService))],he);function V(i,n,r){const{from:e,to:t,flipY:o=!1,flipX:s=!1,angle:c=0,skewX:d=0,skewY:h=0}=i,{column:l,columnOffset:a,row:u,rowOffset:g}=e,{column:f,columnOffset:w,row:S,rowOffset:C}=t,y=r.getCurrentSkeleton(),I=U.attachRangeWithCoord(y,{startColumn:l,endColumn:l,startRow:u,endRow:u});if(I==null)return;const T=U.attachRangeWithCoord(y,{startColumn:f,endColumn:f,startRow:S,endRow:S});if(T==null)return;const{startX:_,startY:M}=I,{startX:v,startY:P}=T;let b=N.precisionTo(_+a,1),j=N.precisionTo(M+g,1),A=N.precisionTo(v+w-b,1),E=N.precisionTo(P+C-j,1);I.startX===T.endX&&(A=0),I.startY===T.endY&&(E=0);const R=y.rowHeaderWidth+y.columnTotalWidth,W=y.columnHeaderHeight+y.rowTotalHeight;return b+A>R&&(b=R-A),j+E>W&&(j=W-E),{flipY:o,flipX:s,angle:c,skewX:d,skewY:h,left:b,top:j,width:A,height:E}}function $(i,n){const{left:r=0,top:e=0,width:t=0,height:o=0,flipY:s=!1,flipX:c=!1,angle:d=0,skewX:h=0,skewY:l=0}=i,a=n.getCellWithCoordByOffset(r,e);if(a==null)return;const u={column:a.actualColumn,columnOffset:N.precisionTo(r-a.startX,1),row:a.actualRow,rowOffset:N.precisionTo(e-a.startY,1)},g=n.getCellWithCoordByOffset(r+t,e+o);if(g==null)return;const f={column:g.actualColumn,columnOffset:N.precisionTo(r+t-g.startX,1),row:g.actualRow,rowOffset:N.precisionTo(e+o-g.startY,1)};return{flipY:s,flipX:c,angle:d,skewX:h,skewY:l,from:u,to:f}}var ft=Object.defineProperty,wt=Object.getOwnPropertyDescriptor,St=(i,n,r,e)=>{for(var t=e>1?void 0:e?wt(n,r):n,o=i.length-1,s;o>=0;o--)(s=i[o])&&(t=(e?s(n,r,t):s(t))||t);return e&&t&&ft(n,r,t),t},de=(i,n)=>(r,e)=>n(r,e,i);let Re=class extends m.Disposable{constructor(i,n,r,e,t){super(),this._context=i,this._sheetDrawingService=n,this._drawingManagerService=r,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 n in i){const r=i[n];for(const e in r.data){const t=r.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)}};Re=St([de(1,p.ISheetDrawingService),de(2,O.IDrawingManagerService),de(3,m.Inject(U.ISheetSelectionRenderService)),de(4,m.Inject(U.SheetSkeletonManagerService))],Re);var X=function(){return X=Object.assign||function(i){for(var n,r=1,e=arguments.length;r<e;r++){n=arguments[r];for(var t in n)Object.prototype.hasOwnProperty.call(n,t)&&(i[t]=n[t])}return i},X.apply(this,arguments)},vt=function(i,n){var r={};for(var e in i)Object.prototype.hasOwnProperty.call(i,e)&&n.indexOf(e)<0&&(r[e]=i[e]);if(i!=null&&typeof Object.getOwnPropertySymbols=="function")for(var t=0,e=Object.getOwnPropertySymbols(i);t<e.length;t++)n.indexOf(e[t])<0&&Object.prototype.propertyIsEnumerable.call(i,e[t])&&(r[e[t]]=i[e[t]]);return r},ke=H.forwardRef(function(i,n){var r=i.icon,e=i.id,t=i.className,o=i.extend,s=vt(i,["icon","id","className","extend"]),c="univerjs-icon univerjs-icon-".concat(e," ").concat(t||"").trim(),d=H.useRef("_".concat(It()));return Ve(r,"".concat(e),{defIds:r.defIds,idSuffix:d.current},X({ref:n,className:c},s),o)});function Ve(i,n,r,e,t){return H.createElement(i.tag,X(X({key:n},_t(i,r,t)),e),(Dt(i,r).children||[]).map(function(o,s){return Ve(o,"".concat(n,"-").concat(i.tag,"-").concat(s),r,void 0,t)}))}function _t(i,n,r){var e=X({},i.attrs);r!=null&&r.colorChannel1&&e.fill==="colorChannel1"&&(e.fill=r.colorChannel1);var t=n.defIds;return!t||t.length===0||(i.tag==="use"&&e["xlink:href"]&&(e["xlink:href"]=e["xlink:href"]+n.idSuffix),Object.entries(e).forEach(function(o){var s=o[0],c=o[1];typeof c=="string"&&(e[s]=c.replace(/url\(#(.*)\)/,"url(#$1".concat(n.idSuffix,")")))})),e}function Dt(i,n){var r,e=n.defIds;return!e||e.length===0?i:i.tag==="defs"&&(!((r=i.children)===null||r===void 0)&&r.length)?X(X({},i),{children:i.children.map(function(t){return typeof t.attrs.id=="string"&&e&&e.indexOf(t.attrs.id)>-1?X(X({},t),{attrs:X(X({},t.attrs),{id:t.attrs.id+n.idSuffix})}):t})}):i}function It(){return Math.random().toString(36).substring(2,8)}ke.displayName="UniverIcon";var Ct={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"}}]},Fe=H.forwardRef(function(i,n){return H.createElement(ke,Object.assign({},i,{id:"add-image-single",ref:n,icon:Ct}))});Fe.displayName="AddImageSingle";const Ee={id:"sheet.command.delete-drawing",type:m.CommandType.COMMAND,handler:i=>{const n=i.get(m.ICommandService),e=i.get(p.ISheetDrawingService).getFocusDrawings();if(e.length===0)return!1;const t=e[0].unitId,o=e.map(s=>{const{unitId:c,subUnitId:d,drawingId:h,drawingType:l}=s;return{unitId:c,subUnitId:d,drawingId:h,drawingType:l}});return n.executeCommand(ie.id,{unitId:t,drawings:o})}};function yt(i){const n=[];return i.forEach(r=>{const{parent:e,children:t}=r,{unitId:o,subUnitId:s,drawingId:c}=e,d=N.getGroupState(0,0,t.map(a=>a.transform||{})),h=t.map(a=>{const u=a.transform||{left:0,top:0},{unitId:g,subUnitId:f,drawingId:w}=a;return{unitId:g,subUnitId:f,drawingId:w,transform:{...u,left:u.left-d.left,top:u.top-d.top},groupId:c}}),l={unitId:o,subUnitId:s,drawingId:c,drawingType:O.DrawingTypeEnum.DRAWING_GROUP,transform:d};n.push({parent:l,children:h})}),n}function Mt(i){const n=[];return i.forEach(r=>{const{parent:e,children:t}=r,{unitId:o,subUnitId:s,drawingId:c,transform:d={width:0,height:0}}=e;if(d==null)return;const h=t.map(a=>{const{transform:u}=a,{unitId:g,subUnitId:f,drawingId:w}=a,S=N.transformObjectOutOfGroup(u||{},d,d.width||0,d.height||0);return{unitId:g,subUnitId:f,drawingId:w,transform:S,groupId:void 0}}),l={unitId:o,subUnitId:s,drawingId:c,drawingType:O.DrawingTypeEnum.DRAWING_GROUP,transform:{left:0,top:0}};n.push({parent:l,children:h})}),n}const Pe={id:"sheet.command.group-sheet-image",type:m.CommandType.COMMAND,handler:(i,n)=>{const r=i.get(m.ICommandService),e=i.get(m.IUndoRedoService),t=i.get(p.ISheetDrawingService);if(!n)return!1;const o=[];n.forEach(({parent:g,children:f})=>{o.push(g.unitId),f.forEach(w=>{o.push(w.unitId)})});const s=t.getGroupDrawingOp(n),{unitId:c,subUnitId:d,undo:h,redo:l,objects:a}=s;return r.syncExecuteCommand(p.SetDrawingApplyMutation.id,{op:l,unitId:c,subUnitId:d,objects:a,type:p.DrawingApplyType.GROUP})?(e.pushUndoRedo({unitID:c,undoMutations:[{id:p.SetDrawingApplyMutation.id,params:{op:h,unitId:c,subUnitId:d,objects:Mt(a),type:p.DrawingApplyType.UNGROUP}},{id:x.id,params:o}],redoMutations:[{id:p.SetDrawingApplyMutation.id,params:{op:l,unitId:c,subUnitId:d,objects:a,type:p.DrawingApplyType.GROUP}},{id:x.id,params:o}]}),!0):!1}},oe={id:"sheet.command.insert-sheet-image",type:m.CommandType.COMMAND,handler:(i,n)=>{var y,I,T;const r=i.get(m.ICommandService),e=i.get(m.IUndoRedoService),t=i.get(p.ISheetDrawingService),o=i.get(D.SheetInterceptorService);if(!n)return!1;const s=n.drawings,c=s.map(_=>_.unitId),d=t.getBatchAddOp(s),{unitId:h,subUnitId:l,undo:a,redo:u,objects:g}=d,f=o.onCommandExecute({id:oe.id,params:n}),w={id:p.SetDrawingApplyMutation.id,params:{op:u,unitId:h,subUnitId:l,objects:g,type:p.DrawingApplyType.INSERT}},S={id:p.SetDrawingApplyMutation.id,params:{op:a,unitId:h,subUnitId:l,objects:g,type:p.DrawingApplyType.REMOVE}};return m.sequenceExecute([...(y=f.preRedos)!=null?y:[],w,...f.redos],r)?(e.pushUndoRedo({unitID:h,undoMutations:[...(I=f.preUndos)!=null?I:[],S,...f.undos,{id:x.id,params:c}],redoMutations:[...(T=f.preRedos)!=null?T:[],w,...f.redos,{id:x.id,params:c}]}),!0):!1}},Ae={id:"sheet.command.set-drawing-arrange",type:m.CommandType.COMMAND,handler:(i,n)=>{const r=i.get(m.ICommandService),e=i.get(m.IUndoRedoService);if(!n)return!1;const t=i.get(p.ISheetDrawingService),{unitId:o,subUnitId:s,drawingIds:c,arrangeType:d}=n,h={unitId:o,subUnitId:s,drawingIds:c};let l;if(d===O.ArrangeTypeEnum.forward?l=t.getForwardDrawingsOp(h):d===O.ArrangeTypeEnum.backward?l=t.getBackwardDrawingOp(h):d===O.ArrangeTypeEnum.front?l=t.getFrontDrawingsOp(h):d===O.ArrangeTypeEnum.back&&(l=t.getBackDrawingsOp(h)),l==null)return!1;const{objects:a,redo:u,undo:g}=l;return r.syncExecuteCommand(p.SetDrawingApplyMutation.id,{op:u,unitId:o,subUnitId:s,objects:a,type:p.DrawingApplyType.ARRANGE})?(e.pushUndoRedo({unitID:o,undoMutations:[{id:p.SetDrawingApplyMutation.id,params:{op:g,unitId:o,subUnitId:s,objects:a,type:p.DrawingApplyType.ARRANGE}}],redoMutations:[{id:p.SetDrawingApplyMutation.id,params:{op:u,unitId:o,subUnitId:s,objects:a,type:p.DrawingApplyType.ARRANGE}}]}),!0):!1}},se={id:"sheet.command.set-sheet-image",type:m.CommandType.COMMAND,handler:(i,n)=>{const r=i.get(m.ICommandService),e=i.get(m.IUndoRedoService),t=i.get(p.ISheetDrawingService);if(!n)return!1;const{drawings:o}=n,s=t.getBatchUpdateOp(o),{unitId:c,subUnitId:d,undo:h,redo:l,objects:a}=s;return r.syncExecuteCommand(p.SetDrawingApplyMutation.id,{unitId:c,subUnitId:d,op:l,objects:a,type:p.DrawingApplyType.UPDATE})?(e.pushUndoRedo({unitID:c,undoMutations:[{id:p.SetDrawingApplyMutation.id,params:{unitId:c,subUnitId:d,op:h,objects:a,type:p.DrawingApplyType.UPDATE}},{id:x.id,params:[c]}],redoMutations:[{id:p.SetDrawingApplyMutation.id,params:{unitId:c,subUnitId:d,op:l,objects:a,type:p.DrawingApplyType.UPDATE}},{id:x.id,params:[c]}]}),!0):!1}},Ue={id:"sheet.command.ungroup-sheet-image",type:m.CommandType.COMMAND,handler:(i,n)=>{const r=i.get(m.ICommandService),e=i.get(m.IUndoRedoService),t=i.get(p.ISheetDrawingService);if(!n)return!1;const o=[];n.forEach(({parent:g,children:f})=>{o.push(g.unitId),f.forEach(w=>{o.push(w.unitId)})});const s=t.getUngroupDrawingOp(n),{unitId:c,subUnitId:d,undo:h,redo:l,objects:a}=s;return r.syncExecuteCommand(p.SetDrawingApplyMutation.id,{op:l,unitId:c,subUnitId:d,objects:a,type:p.DrawingApplyType.UNGROUP})?(e.pushUndoRedo({unitID:c,undoMutations:[{id:p.SetDrawingApplyMutation.id,params:{op:h,unitId:c,subUnitId:d,objects:yt(a),type:p.DrawingApplyType.GROUP}},{id:x.id,params:o}],redoMutations:[{id:p.SetDrawingApplyMutation.id,params:{op:l,unitId:c,subUnitId:d,objects:a,type:p.DrawingApplyType.UNGROUP}},{id:x.id,params:o}]}),!0):!1}};var Rt=Object.defineProperty,Tt=Object.getOwnPropertyDescriptor,bt=(i,n,r,e)=>{for(var t=e>1?void 0:e?Tt(n,r):n,o=i.length-1,s;o>=0;o--)(s=i[o])&&(t=(e?s(n,r,t):s(t))||t);return e&&t&&Rt(n,r,t),t},K=(i,n)=>(r,e)=>n(r,e,i);let me=class extends m.Disposable{constructor(n,r,e,t,o,s,c,d,h,l,a,u){super();Y(this,"_workbookSelections");this._context=n,this._skeletonManagerService=r,this._commandService=e,this._selectionRenderService=t,this._imageIoService=o,this._fileOpenerService=s,this._sheetDrawingService=c,this._drawingManagerService=d,this._contextService=h,this._messageService=l,this._localeService=a,this._workbookSelections=u.getWorkbookSelections(this._context.unitId),this._updateImageListener(),this._updateOrderListener(),this._groupDrawingListener(),this._focusDrawingListener()}async insertFloatImage(){const n=await this._fileOpenerService.openFile({multiple:!0,accept:O.DRAWING_IMAGE_ALLOW_IMAGE_LIST.map(e=>`.${e.replace("image/","")}`).join(",")}),r=n.length;return r>O.DRAWING_IMAGE_COUNT_LIMIT?(this._messageService.show({type:Z.MessageType.Error,content:this._localeService.t("update-status.exceedMaxCount",String(O.DRAWING_IMAGE_COUNT_LIMIT))}),!1):r===0?!1:(n.forEach(async e=>await this._insertFloatImage(e)),!0)}async _insertFloatImage(n){let r;try{r=await this._imageIoService.saveImage(n)}catch(y){const I=y.message;I===O.ImageUploadStatusType.ERROR_EXCEED_SIZE?this._messageService.show({type:Z.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:Z.MessageType.Error,content:this._localeService.t("update-status.invalidImageType")}):I===O.ImageUploadStatusType.ERROR_IMAGE&&this._messageService.show({type:Z.MessageType.Error,content:this._localeService.t("update-status.invalidImage")})}if(r==null)return;const e=this._getUnitInfo(),{unitId:t,subUnitId:o}=e,{imageId:s,imageSourceType:c,source:d,base64Cache:h}=r,{width:l,height:a,image:u}=await O.getImageSize(h||""),{width:g,height:f}=this._context.scene;this._imageIoService.addImageSourceCache(d,c,u);let w=1;if(l>O.DRAWING_IMAGE_WIDTH_LIMIT||a>O.DRAWING_IMAGE_HEIGHT_LIMIT){const y=O.DRAWING_IMAGE_WIDTH_LIMIT/l,I=O.DRAWING_IMAGE_HEIGHT_LIMIT/a;w=Math.max(y,I)}const S=this._getImagePosition(l*w,a*w,g,f);if(S==null)return;const C={unitId:t,subUnitId:o,drawingId:s,drawingType:O.DrawingTypeEnum.DRAWING_IMAGE,imageSourceType:c,source:d,transform:V(S,this._selectionRenderService,this._skeletonManagerService),sheetTransform:S};this._commandService.executeCommand(oe.id,{unitId:t,drawings:[C]})}_getUnitInfo(){const n=this._context.unit,r=n.getActiveSheet(),e=n.getUnitId(),t=r.getSheetId();return{unitId:e,subUnitId:t}}_getImagePosition(n,r,e,t){const o=this._workbookSelections.getCurrentSelections();let s={startRow:0,endRow:0,startColumn:0,endColumn:0};o&&o.length>0&&(s=o[o.length-1].range);const c=U.attachRangeWithCoord(this._skeletonManagerService.getCurrent().skeleton,s);if(c==null)return;let{startColumn:d,startRow:h,startX:l,startY:a}=c,u=!1;if(l+n>e&&(l=e-n,l<0&&(l=0,n=e),u=!0),a+r>t&&(a=t-r,a<0&&(a=0,r=t),u=!0),u){const S=this._selectionRenderService.getCellWithCoordByOffset(l,a);if(S==null)return;l=S.startX,a=S.startY,d=S.actualColumn,h=S.actualRow}const g={column:d,columnOffset:0,row:h,rowOffset:0},f=this._selectionRenderService.getCellWithCoordByOffset(l+n,a+r);if(f==null)return;const w={column:f.actualColumn,columnOffset:l+n-f.startX,row:f.actualRow,rowOffset:a+r-f.startY};return{from:g,to:w}}_updateOrderListener(){this.disposeWithMe(this._drawingManagerService.featurePluginOrderUpdate$.subscribe(n=>{const{unitId:r,subUnitId:e,drawingIds:t,arrangeType:o}=n;this._commandService.executeCommand(Ae.id,{unitId:r,subUnitId:e,drawingIds:t,arrangeType:o})}))}_updateImageListener(){this.disposeWithMe(this._drawingManagerService.featurePluginUpdate$.subscribe(n=>{const r=[];n.length!==0&&(n.forEach(e=>{const{unitId:t,subUnitId:o,drawingId:s,drawingType:c,transform:d}=e;if(d==null)return;const h=this._sheetDrawingService.getDrawingByParam({unitId:t,subUnitId:o,drawingId:s});if(h==null||h.unitId!==this._context.unitId)return;const l=$({...h.transform,...d},this._selectionRenderService);if(l==null)return;const a={...e,transform:{...h.transform,...d,...V(l,this._selectionRenderService,this._skeletonManagerService)},sheetTransform:{...l}};r.push(a)}),r.length>0&&this._commandService.executeCommand(se.id,{unitId:n[0].unitId,drawings:r}))}))}_groupDrawingListener(){this.disposeWithMe(this._drawingManagerService.featurePluginGroupUpdate$.subscribe(n=>{this._commandService.executeCommand(Pe.id,n);const{unitId:r,subUnitId:e,drawingId:t}=n[0].parent;this._drawingManagerService.focusDrawing([{unitId:r,subUnitId:e,drawingId:t}])})),this.disposeWithMe(this._drawingManagerService.featurePluginUngroupUpdate$.subscribe(n=>{this._commandService.executeCommand(Ue.id,n)}))}_focusDrawingListener(){this.disposeWithMe(this._drawingManagerService.focus$.subscribe(n=>{n==null||n.length===0?(this._contextService.setContextValue(m.FOCUSING_COMMON_DRAWINGS,!1),this._sheetDrawingService.focusDrawing([])):(this._contextService.setContextValue(m.FOCUSING_COMMON_DRAWINGS,!0),this._sheetDrawingService.focusDrawing(n))}))}};me=bt([K(1,m.Inject(U.SheetSkeletonManagerService)),K(2,m.ICommandService),K(3,U.ISheetSelectionRenderService),K(4,O.IImageIoService),K(5,G.ILocalFileService),K(6,p.ISheetDrawingService),K(7,O.IDrawingManagerService),K(8,m.IContextService),K(9,G.IMessageService),K(10,m.Inject(m.LocaleService)),K(11,m.Inject(D.SheetsSelectionsService))],me);const _e={id:"sheet.command.insert-float-image",type:m.CommandType.COMMAND,handler:i=>{var r,e;return(e=(r=i.get(N.IRenderManagerService).getCurrentTypeOfRenderer(m.UniverInstanceType.UNIVER_SHEET))==null?void 0:r.with(me).insertFloatImage())!=null?e:!1}},ne={id:"sheet.command.move-drawing",type:m.CommandType.COMMAND,handler:(i,n)=>{const r=i.get(m.ICommandService),e=i.get(p.ISheetDrawingService),t=i.get(U.ISheetSelectionRenderService),{direction:o}=n,s=e.getFocusDrawings();if(s.length===0)return!1;const c=s[0].unitId,d=s.map(l=>{const{transform:a}=l;if(a==null)return null;const u={...a},{left:g=0,top:f=0}=a;return o===m.Direction.UP?u.top=f-1:o===m.Direction.DOWN?u.top=f+1:o===m.Direction.LEFT?u.left=g-1:o===m.Direction.RIGHT&&(u.left=g+1),{...l,transform:u,sheetTransform:$(u,t)}}).filter(l=>l!=null);return r.syncExecuteCommand(se.id,{unitId:c,drawings:d})?(r.syncExecuteCommand(x.id,[c]),!0):!1}},Ye="addition-and-subtraction-single",Ne="sheet.menu.image";function Ot(i){return{id:Ne,type:G.MenuItemType.SUBITEMS,icon:Ye,tooltip:"sheetImage.title",hidden$:G.getMenuHiddenObservable(i,m.UniverInstanceType.UNIVER_SHEET),disabled$:U.getCurrentRangeDisable$(i,{workbookTypes:[D.WorkbookEditablePermission],worksheetTypes:[D.WorksheetEditPermission],rangeTypes:[D.RangeProtectionPermissionEditPoint]})}}function Et(i){return{id:_e.id,title:"sheetImage.upload.float",type:G.MenuItemType.BUTTON,hidden$:G.getMenuHiddenObservable(i,m.UniverInstanceType.UNIVER_SHEET)}}const Pt="univer-image-common-panel",At="univer-image-common-panel-grid",Ut="univer-image-common-panel-border",Nt="univer-image-common-panel-title",jt="univer-image-common-panel-subtitle",Wt="univer-image-common-panel-row",Lt="univer-image-common-panel-row-vertical",xt="univer-image-common-panel-column",Bt="univer-image-common-panel-column-center",$t="univer-image-common-panel-inline",Gt="univer-image-common-panel-span2",kt="univer-image-common-panel-span3",Vt="univer-image-common-panel-input",Ft="univer-sheet-image-menu",Yt="univer-sheet-image-menu-input",J={imageCommonPanel:Pt,imageCommonPanelGrid:At,imageCommonPanelBorder:Ut,imageCommonPanelTitle:Nt,imageCommonPanelSubtitle:jt,imageCommonPanelRow:Wt,imageCommonPanelRowVertical:Lt,imageCommonPanelColumn:xt,imageCommonPanelColumnCenter:Bt,imageCommonPanelInline:$t,imageCommonPanelSpan2:Gt,imageCommonPanelSpan3:kt,imageCommonPanelInput:Vt,sheetImageMenu:Ft,sheetImageMenuInput:Yt};function He(i){var n,r,e="";if(typeof i=="string"||typeof i=="number")e+=i;else if(typeof i=="object")if(Array.isArray(i)){var t=i.length;for(n=0;n<t;n++)i[n]&&(r=He(i[n]))&&(e&&(e+=" "),e+=r)}else for(r in i)i[r]&&(e&&(e+=" "),e+=r);return e}function le(){for(var i,n,r=0,e="",t=arguments.length;r<t;r++)(i=arguments[r])&&(n=He(i))&&(e&&(e+=" "),e+=n);return e}const Ht=i=>{var I;const n=m.useDependency(m.ICommandService),r=m.useDependency(m.LocaleService),e=m.useDependency(O.IDrawingManagerService),t=m.useDependency(N.IRenderManagerService),{drawings:o}=i,s=o[0];if(s==null)return;const{unitId:c}=s,d=t.getRenderById(c),h=d==null?void 0:d.scene;if(h==null)return;const l=h.getTransformerByCreate(),[a,u]=H.useState(!0),g=(I=s.anchorType)!=null?I:p.SheetDrawingAnchorType.Position,[f,w]=H.useState(g);function S(T,_){const M=[];return T.forEach(v=>{const{oKey:P}=v,b=_.getDrawingOKey(P);if(b==null)return M.push(null),!0;const{unitId:j,subUnitId:A,drawingId:E,drawingType:R,anchorType:W,sheetTransform:B}=b;M.push({unitId:j,subUnitId:A,drawingId:E,anchorType:W,sheetTransform:B,drawingType:R})}),M}H.useEffect(()=>{const T=l.clearControl$.subscribe(M=>{M===!0&&u(!1)}),_=l.changeStart$.subscribe(M=>{var b;const{objects:v}=M,P=S(v,e);if(P.length===0)u(!1);else if(P.length>=1){u(!0);const j=((b=P[0])==null?void 0:b.anchorType)||p.SheetDrawingAnchorType.Position;w(j)}});return()=>{_.unsubscribe(),T.unsubscribe()}},[]);function C(T){w(T);const _=e.getFocusDrawings();if(_.length===0)return;const M=_.map(v=>({unitId:v.unitId,subUnitId:v.subUnitId,drawingId:v.drawingId,anchorType:T}));n.executeCommand(se.id,{unitId:_[0].unitId,drawings:M})}const y=T=>T?"block":"none";return k.jsxs("div",{className:le(J.imageCommonPanelGrid,J.imageCommonPanelBorder),style:{display:y(a)},children:[k.jsx("div",{className:J.imageCommonPanelRow,children:k.jsx("div",{className:le(J.imageCommonPanelColumn,J.imageCommonPanelTitle),children:k.jsx("div",{children:r.t("drawing-anchor.title")})})}),k.jsx("div",{className:le(J.imageCommonPanelRow),children:k.jsx("div",{className:le(J.imageCommonPanelColumn),children:k.jsxs(Z.RadioGroup,{value:f,onChange:C,direction:"vertical",children:[k.jsx(Z.Radio,{value:p.SheetDrawingAnchorType.Both,children:r.t("drawing-anchor.both")}),k.jsx(Z.Radio,{value:p.SheetDrawingAnchorType.Position,children:r.t("drawing-anchor.position")}),k.jsx(Z.Radio,{value:p.SheetDrawingAnchorType.None,children:r.t("drawing-anchor.none")})]})})})]})},Xt=()=>{const i=m.useDependency(O.IDrawingManagerService),n=i.getFocusDrawings(),[r,e]=H.useState(n);return H.useEffect(()=>{const t=i.focus$.subscribe(o=>{e(o)});return()=>{t.unsubscribe()}},[]),!!(r!=null&&r.length)&&k.jsxs("div",{className:J.imageCommonPanel,children:[k.jsx(te.DrawingCommonPanel,{drawings:r}),k.jsx(Ht,{drawings:r})]})},Kt={[G.RibbonStartGroup.FORMULAS_INSERT]:{[Ne]:{order:3,menuItemFactory:Ot,[_e.id]:{order:0,menuItemFactory:Et}}}};function ae(i){return!i.getContextValue(m.FOCUSING_FX_BAR_EDITOR)&&!i.getContextValue(m.EDITOR_ACTIVATED)&&!i.getContextValue(m.FOCUSING_PANEL_EDITOR)&&i.getContextValue(m.FOCUSING_COMMON_DRAWINGS)}const zt={id:ne.id,description:"shortcut.sheet.drawing-move-down",group:"4_sheet-drawing-view",binding:G.KeyCode.ARROW_DOWN,priority:100,preconditions:ae,staticParameters:{direction:m.Direction.DOWN}},qt={id:ne.id,description:"shortcut.sheet.drawing-move-up",group:"4_sheet-drawing-view",binding:G.KeyCode.ARROW_UP,priority:100,preconditions:ae,staticParameters:{direction:m.Direction.UP}},Jt={id:ne.id,description:"shortcut.sheet.drawing-move-left",group:"4_sheet-drawing-view",binding:G.KeyCode.ARROW_LEFT,priority:100,preconditions:ae,staticParameters:{direction:m.Direction.LEFT}},Zt={id:ne.id,description:"shortcut.sheet.drawing-move-right",group:"4_sheet-drawing-view",binding:G.KeyCode.ARROW_RIGHT,priority:100,preconditions:ae,staticParameters:{direction:m.Direction.RIGHT}},Qt={id:Ee.id,description:"shortcut.sheet.drawing-delete",group:"4_sheet-drawing-view",preconditions:ae,binding:G.KeyCode.DELETE,mac:G.KeyCode.BACKSPACE};var en=Object.defineProperty,tn=Object.getOwnPropertyDescriptor,nn=(i,n,r,e)=>{for(var t=e>1?void 0:e?tn(n,r):n,o=i.length-1,s;o>=0;o--)(s=i[o])&&(t=(e?s(n,r,t):s(t))||t);return e&&t&&en(n,r,t),t},ue=(i,n)=>(r,e)=>n(r,e,i);let pe=class extends m.Disposable{constructor(i,n,r,e){super(),this._componentManager=i,this._menuManagerService=n,this._commandService=r,this._shortcutService=e,this._init()}_initCustomComponents(){const i=this._componentManager;this.disposeWithMe(i.register(Ye,Fe)),this.disposeWithMe(i.register(Be,Xt))}_initMenus(){this._menuManagerService.mergeMenu(Kt)}_initCommands(){[_e,oe,ie,se,be,x,Oe,Pe,Ue,ne,Ee,Ae].forEach(i=>this.disposeWithMe(this._commandService.registerCommand(i)))}_initShortcuts(){[zt,qt,Jt,Zt,Qt].forEach(i=>{this.disposeWithMe(this._shortcutService.registerShortcut(i))})}_init(){this._initCommands(),this._initCustomComponents(),this._initMenus(),this._initShortcuts()}};pe=nn([ue(0,m.Inject(G.ComponentManager)),ue(1,G.IMenuManagerService),ue(2,m.ICommandService),ue(3,G.IShortcutService)],pe);var rn=Object.defineProperty,on=Object.getOwnPropertyDescriptor,sn=(i,n,r,e)=>{for(var t=e>1?void 0:e?on(n,r):n,o=i.length-1,s;o>=0;o--)(s=i[o])&&(t=(e?s(n,r,t):s(t))||t);return e&&t&&rn(n,r,t),t},Ce=(i,n)=>(r,e)=>n(r,e,i);let fe=class extends m.Disposable{constructor(n,r,e){super();Y(this,"_copyInfo");this._sheetClipboardService=n,this._renderManagerService=r,this._sheetDrawingService=e,this._initCopyPaste()}_initCopyPaste(){this._sheetClipboardService.addClipboardHook({id:"SHEET_IMAGE_UI_PLUGIN",onBeforeCopy:(n,r,e)=>this._collect(n,r,e),onPasteCells:(n,r,e,t)=>{const{copyType:o=U.COPY_TYPE.COPY,pasteType:s}=t,{range:c}=n||{},{range:d,unitId:h,subUnitId:l}=r;return this._generateMutations(d,{copyType:o,pasteType:s,copyRange:c,unitId:h,subUnitId:l})},onPastePlainText:(n,r)=>({undos:[],redos:[]})})}_collect(n,r,e){var u;const t=(u=this._renderManagerService.getRenderById(n))==null?void 0:u.with(U.SheetSkeletonManagerService);if(!t)return;const o=t.attachRangeWithCoord(e);if(!o)return;const{startX:s,endX:c,startY:d,endY:h}=o,l=this._sheetDrawingService.getDrawingData(n,r),a=[];Object.keys(l).forEach(g=>{const f=l[g],{transform:w}=f;if(f.anchorType!==p.SheetDrawingAnchorType.Both||!w)return;const{left:S=0,top:C=0,width:y=0,height:I=0}=w,{drawingStartX:T,drawingEndX:_,drawingStartY:M,drawingEndY:v}={drawingStartX:S,drawingEndX:S+y,drawingStartY:C,drawingEndY:C+I};s<=T&&_<=c&&d<=M&&v<=h&&a.push(f)}),a.length&&(this._copyInfo={drawings:a,unitId:n,subUnitId:r})}_generateMutations(n,r){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(r.pasteType))return{redos:[],undos:[]};const{copyRange:e}=r;if(!e)return{redos:[],undos:[]};const{drawings:t,unitId:o,subUnitId:s}=this._copyInfo,{ranges:[c,d],mapFunc:h}=U.virtualizeDiscreteRanges([e,n]),{row:l,col:a}=h(c.startRow,c.startColumn),{row:u,col:g}=h(d.startRow,d.startColumn),f=(b=this._renderManagerService.getRenderById(o))==null?void 0:b.with(U.SheetSkeletonManagerService);if(!f)return{redos:[],undos:[]};const w=f.attachRangeWithCoord({startRow:l,endRow:l,startColumn:a,endColumn:a}),S=f.attachRangeWithCoord({startRow:u,endRow:u,startColumn:g,endColumn:g});if(!w||!S)return{redos:[],undos:[]};const C=[],y=[],I=S.startX-w.startX,T=S.startY-w.startY,_=u-l,M=g-a,v=r.copyType===U.COPY_TYPE.CUT,{_sheetDrawingService:P}=this;return t.forEach(j=>{const{transform:A,sheetTransform:E}=j;if(!A)return;const R={...j,unitId:o,subUnitId:s,drawingId:v?j.drawingId:m.Tools.generateRandomId(),transform:{...A,left:A.left+I,top:A.top+T},sheetTransform:{to:{...E.to,row:E.to.row+_,column:E.to.column+M},from:{...E.from,row:E.from.row+_,column:E.from.column+M}}};if(v){const{undo:W,redo:B,objects:z}=P.getBatchUpdateOp([R]);C.push({id:p.SetDrawingApplyMutation.id,params:{unitId:o,subUnitId:s,type:p.DrawingApplyType.UPDATE,op:B,objects:z}}),y.push({id:p.SetDrawingApplyMutation.id,params:{unitId:o,subUnitId:s,type:p.DrawingApplyType.UPDATE,op:W,objects:z}})}else{const{undo:W,redo:B,objects:z}=P.getBatchAddOp([R]);C.push({id:p.SetDrawingApplyMutation.id,params:{op:B,unitId:o,subUnitId:s,objects:z,type:p.DrawingApplyType.INSERT}}),y.push({id:p.SetDrawingApplyMutation.id,params:{op:W,unitId:o,subUnitId:s,objects:z,type:p.DrawingApplyType.REMOVE}})}}),{redos:C,undos:y}}};fe=sn([Ce(0,U.ISheetClipboardService),Ce(1,N.IRenderManagerService),Ce(2,p.ISheetDrawingService)],fe);var an=Object.defineProperty,cn=Object.getOwnPropertyDescriptor,dn=(i,n,r,e)=>{for(var t=e>1?void 0:e?cn(n,r):n,o=i.length-1,s;o>=0;o--)(s=i[o])&&(t=(e?s(n,r,t):s(t))||t);return e&&t&&an(n,r,t),t},re=(i,n)=>(r,e)=>n(r,e,i);let we=class extends m.Disposable{constructor(i,n,r,e,t){super(),this._drawingManagerService=i,this._renderManagerService=n,this._permissionService=r,this._univerInstanceService=e,this._userManagerService=t,this._initDrawingVisible(),this._initDrawingEditable(),this._initViewPermissionChange(),this._initEditPermissionChange()}_initDrawingVisible(){const i=this._univerInstanceService.getCurrentTypeOfUnit$(m.UniverInstanceType.UNIVER_SHEET);this.disposeWithMe(L.combineLatest([i,this._userManagerService.currentUser$]).subscribe(([n,r])=>{if(!n){this._drawingManagerService.setDrawingVisible(!1);return}n.activeSheet$.subscribe(e=>{if(!e){this._drawingManagerService.setDrawingVisible(!1);return}const t=n.getUnitId(),o=e.getSheetId();if(this._permissionService.composePermission([new D.WorkbookViewPermission(t).id,new D.WorksheetViewPermission(t,o).id]).every(c=>c.value))this._drawingManagerService.setDrawingVisible(!0);else{this._drawingManagerService.setDrawingVisible(!1);const c=n.getUnitId(),d=e.getSheetId(),h=this._drawingManagerService.getDrawingData(c,d),l=Object.values(h),a=this._renderManagerService.getRenderById(c),u=a==null?void 0:a.scene;if(u==null)return;u.getAllObjectsByOrder().forEach(f=>{f.classType===N.RENDER_CLASS_TYPE.IMAGE&&l.some(w=>f.oKey.includes(w.drawingId))&&u.removeObject(f)})}})}))}_initDrawingEditable(){const i=this._univerInstanceService.getCurrentTypeOfUnit$(m.UniverInstanceType.UNIVER_SHEET);this.disposeWithMe(L.combineLatest([i,this._userManagerService.currentUser$]).subscribe(([n,r])=>{if(!n){this._drawingManagerService.setDrawingEditable(!1);return}n.activeSheet$.subscribe(e=>{if(!e){this._drawingManagerService.setDrawingEditable(!1);return}const t=n.getUnitId(),o=e.getSheetId();if(this._permissionService.composePermission([new D.WorkbookEditablePermission(t).id,new D.WorksheetEditPermission(t,o).id]).every(c=>c.value))this._drawingManagerService.setDrawingEditable(!0);else{this._drawingManagerService.setDrawingEditable(!1);const c=n.getUnitId(),d=e.getSheetId(),h=this._drawingManagerService.getDrawingData(c,d),l=Object.values(h),a=this._renderManagerService.getRenderById(c),u=a==null?void 0:a.scene;if(u==null)return;u.getAllObjectsByOrder().forEach(f=>{f.classType===N.RENDER_CLASS_TYPE.IMAGE&&l.some(w=>f.oKey.includes(w.drawingId))&&u.detachTransformerFrom(f)})}})}))}_initViewPermissionChange(){const i=this._univerInstanceService.getCurrentTypeOfUnit$(m.UniverInstanceType.UNIVER_SHEET);this.disposeWithMe(L.combineLatest([i,this._userManagerService.currentUser$]).subscribe(([n,r])=>{n&&n.activeSheet$.subscribe(e=>{var a;if(!e)return;const t=n.getUnitId(),o=e.getSheetId();let s=!0;const c=this._renderManagerService.getRenderById(t),d=c==null?void 0:c.scene;if(d==null)return;const h=d.getTransformerByCreate(),l=this._permissionService.composePermission$([new D.WorkbookViewPermission(t).id,new D.WorksheetViewPermission(t,o).id]).pipe(L.map(u=>u.every(g=>g.value)));l==null||l.pipe(L.filter(u=>u!==s),L.distinctUntilChanged()).subscribe({next:u=>{s=u,this._drawingManagerService.setDrawingVisible(u);const g=d.getAllObjectsByOrder(),f=this._drawingManagerService.getDrawingData(t,o),w=Object.values(f);u?this._drawingManagerService.addNotification(w):(g.forEach(S=>{S.classType===N.RENDER_CLASS_TYPE.IMAGE&&w.some(C=>S.oKey.includes(C.drawingId))&&d.removeObject(S)}),h.clearSelectedObjects())}}),(a=this._permissionService.getPermissionPoint$(new D.WorksheetViewPermission(t,o).id))==null||a.pipe(L.filter(u=>u.value!==s),L.distinctUntilChanged()).subscribe({complete:()=>{s=!0,this._drawingManagerService.setDrawingVisible(!0);const u=this._drawingManagerService.getDrawingData(t,o),g=Object.values(u);this._drawingManagerService.addNotification(g)}})})}))}_initEditPermissionChange(){const i=this._univerInstanceService.getCurrentTypeOfUnit$(m.UniverInstanceType.UNIVER_SHEET);this.disposeWithMe(L.combineLatest([i,this._userManagerService.currentUser$]).subscribe(([n,r])=>{n&&n.activeSheet$.subscribe(e=>{var a;if(!e)return;const t=n.getUnitId(),o=e.getSheetId();let s=!0;const c=this._renderManagerService.getRenderById(t),d=c==null?void 0:c.scene;if(d==null)return;const h=d.getTransformerByCreate(),l=this._permissionService.composePermission$([new D.WorkbookEditablePermission(t).id,new D.WorksheetEditPermission(t,o).id]).pipe(L.map(u=>u.every(g=>g.value)));l==null||l.pipe(L.filter(u=>u!==s),L.distinctUntilChanged()).subscribe({next:u=>{s=u,this._drawingManagerService.setDrawingEditable(u);const g=d.getAllObjectsByOrder(),f=this._drawingManagerService.getDrawingData(t,o),w=Object.values(f);u?(g.forEach(S=>{S.classType===N.RENDER_CLASS_TYPE.IMAGE&&w.some(C=>S.oKey.includes(C.drawingId))&&d.attachTransformerTo(S)}),this._drawingManagerService.addNotification(w)):(g.forEach(S=>{S.classType===N.RENDER_CLASS_TYPE.IMAGE&&w.some(C=>S.oKey.includes(C.drawingId))&&d.detachTransformerFrom(S)}),h.clearSelectedObjects())}}),(a=this._permissionService.getPermissionPoint$(new D.WorksheetEditPermission(t,o).id))==null||a.pipe(L.filter(u=>u.value!==s),L.distinctUntilChanged()).subscribe({complete:()=>{s=!0;const u=n.getUnitId(),g=e.getSheetId(),f=this._drawingManagerService.getDrawingData(u,g),w=Object.values(f),S=this._renderManagerService.getRenderById(u),C=S==null?void 0:S.scene;if(C==null)return;this._drawingManagerService.setDrawingEditable(!0),C.getAllObjectsByOrder().forEach(I=>{I.classType===N.RENDER_CLASS_TYPE.IMAGE&&w.some(T=>I.oKey.includes(T.drawingId))&&C.detachTransformerFrom(I)})}})})}))}};we=dn([re(0,O.IDrawingManagerService),re(1,N.IRenderManagerService),re(2,m.IPermissionService),re(3,m.IUniverInstanceService),re(4,m.Inject(m.UserManagerService))],we);var ln=Object.defineProperty,un=Object.getOwnPropertyDescriptor,gn=(i,n,r,e)=>{for(var t=e>1?void 0:e?un(n,r):n,o=i.length-1,s;o>=0;o--)(s=i[o])&&(t=(e?s(n,r,t):s(t))||t);return e&&t&&ln(n,r,t),t},ge=(i,n)=>(r,e)=>n(r,e,i);let Se=class extends m.Disposable{constructor(i,n,r,e){super(),this._sheetPrintInterceptorService=i,this._drawingRenderService=n,this._drawingManagerService=r,this._renderManagerService=e,this._initPrinting()}_initPrinting(){this.disposeWithMe(this._sheetPrintInterceptorService.interceptor.intercept(this._sheetPrintInterceptorService.interceptor.getInterceptPoints().PRINTING_COMPONENT_COLLECT,{handler:(i,n,r)=>{const{unitId:e,scene:t,subUnitId:o}=n,s=this._drawingManagerService.getDrawingDataForUnit(e),c=s==null?void 0:s[o];return c&&c.order.forEach(d=>{this._drawingRenderService.renderDrawing(c.data[d],t)}),r()}})),this.disposeWithMe(this._sheetPrintInterceptorService.interceptor.intercept(this._sheetPrintInterceptorService.interceptor.getInterceptPoints().PRINTING_RANGE,{handler:(i,n,r)=>{const{unitId:e,subUnitId:t}=n,o=this._renderManagerService.getRenderById(e);if(!o)return r(i);const s=o.with(U.SheetSkeletonManagerService).getWorksheetSkeleton(t);if(!s)return r(i);const c=this._drawingManagerService.getDrawingDataForUnit(e),d=c==null?void 0:c[n.subUnitId];if(!d)return r(i);const{scaleX:h,scaleY:l}=o.scene,a=i?{...i}:{startColumn:0,endColumn:0,endRow:0,startRow:0},u=d.order.map(g=>d.data[g]).filter(g=>g.drawingType!==O.DrawingTypeEnum.DRAWING_DOM);return u.length?(u.forEach(g=>{if(!g.groupId&&g.transform&&m.Tools.isDefine(g.transform.left)&&m.Tools.isDefine(g.transform.top)&&m.Tools.isDefine(g.transform.width)&&m.Tools.isDefine(g.transform.height)){const f=s.skeleton.getCellIndexByOffset(g.transform.left,g.transform.top,h,l,{x:0,y:0}),w=s.skeleton.getCellIndexByOffset(g.transform.left+g.transform.width,g.transform.top+g.transform.height,h,l,{x:0,y:0});f.column<a.startColumn&&(a.startColumn=f.column),f.row<a.startRow&&(a.startRow=f.row),a.endRow<w.row&&(a.endRow=w.row),a.endColumn<w.column&&(a.endColumn=w.column)}}),r(a)):r(i)}}))}};Se=gn([ge(0,m.Inject(U.SheetPrintInterceptorService)),ge(1,m.Inject(te.DrawingRenderService)),ge(2,O.IDrawingManagerService),ge(3,N.IRenderManagerService)],Se);var hn=Object.defineProperty,mn=Object.getOwnPropertyDescriptor,pn=(i,n,r,e)=>{for(var t=e>1?void 0:e?mn(n,r):n,o=i.length-1,s;o>=0;o--)(s=i[o])&&(t=(e?s(n,r,t):s(t))||t);return e&&t&&hn(n,r,t),t},q=(i,n)=>(r,e)=>n(r,e,i);const fn=[D.InsertRowCommand.id,D.InsertColCommand.id,D.RemoveRowCommand.id,D.RemoveColCommand.id,D.DeleteRangeMoveLeftCommand.id,D.DeleteRangeMoveUpCommand.id,D.InsertRangeMoveDownCommand.id,D.InsertRangeMoveRightCommand.id,D.DeltaRowHeightCommand.id,D.SetRowHeightCommand.id,D.DeltaColumnWidthCommand.id,D.SetColWidthCommand.id,D.SetRowHiddenCommand.id,D.SetSpecificRowsVisibleCommand.id,D.SetSpecificColsVisibleCommand.id,D.SetColHiddenCommand.id,D.MoveColsCommand.id,D.MoveRowsCommand.id,D.MoveRangeCommand.id],wn=[D.SetRowVisibleMutation.id,D.SetRowHiddenMutation.id,D.SetColVisibleMutation.id,D.SetColHiddenMutation.id,D.SetWorksheetRowHeightMutation.id,D.SetWorksheetColWidthMutation.id];let Te=class extends m.Disposable{constructor(i,n,r,e,t,o,s,c,d){super(),this._context=i,this._renderManagerService=n,this._commandService=r,this._selectionRenderService=e,this._skeletonManagerService=t,this._sheetInterceptorService=o,this._sheetDrawingService=s,this._drawingManagerService=c,this._univerInstanceService=d,this._sheetInterceptorListener(),this._commandListener(),this._sheetRefreshListener()}_sheetInterceptorListener(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:i=>{if(!fn.includes(i.id))return{redos:[],undos:[]};if(i.params==null)return{redos:[],undos:[]};const n=i.id;if(n===D.InsertRowCommand.id)return this._moveRowInterceptor(i.params,"insert");if([D.MoveColsCommand.id,D.MoveRowsCommand.id,D.MoveRangeCommand.id].includes(n))return this._moveRangeInterceptor(i.params);if(n===D.InsertColCommand.id)return this._moveColInterceptor(i.params,"insert");if(n===D.RemoveRowCommand.id)return this._moveRowInterceptor(i.params,"remove");if(n===D.RemoveColCommand.id)return this._moveColInterceptor(i.params,"remove");if(n===D.DeleteRangeMoveLeftCommand.id){const{range:r}=i.params;return this._getRangeMoveUndo(r,0)}else if(n===D.DeleteRangeMoveUpCommand.id){const{range:r}=i.params;return this._getRangeMoveUndo(r,1)}else if(n===D.InsertRangeMoveDownCommand.id){const{range:r}=i.params;return this._getRangeMoveUndo(r,2)}else if(n===D.InsertRangeMoveRightCommand.id){const{range:r}=i.params;return this._getRangeMoveUndo(r,3)}else if(n===D.SetRowHiddenCommand.id||n===D.SetSpecificRowsVisibleCommand.id){const r=i.params,{unitId:e,subUnitId:t,ranges:o}=r;return this._getDrawingUndoForRowVisible(e,t,o)}else if(n===D.SetSpecificColsVisibleCommand.id||n===D.SetColHiddenCommand.id){const r=i.params,{unitId:e,subUnitId:t,ranges:o}=r;return this._getDrawingUndoForColVisible(e,t,o)}else if(n===D.DeltaRowHeightCommand.id||n===D.SetRowHeightCommand.id||n===D.DeltaColumnWidthCommand.id||n===D.SetColWidthCommand.id){const r=i.params,{unitId:e,subUnitId:t,ranges:o}=r,s=n===D.DeltaRowHeightCommand.id||n===D.SetRowHeightCommand.id;return this._getDrawingUndoForRowAndColSize(e,t,o,s)}return{redos:[],undos:[]}}}))}_getRangeMoveUndo(i,n){const r=D.getSheetCommandTarget(this._univerInstanceService);if(r==null)return{redos:[],undos:[]};const e=r.unitId,t=r.subUnitId,o=[],s=[],c=this._sheetDrawingService.getDrawingData(e,t),d=[],h=[];if(Object.keys(c).forEach(l=>{const a=c[l],{updateDrawings:u,deleteDrawings:g}=this._getUpdateOrDeleteDrawings(i,n,a);d.push(...u),h.push(...g)}),d.length===0&&h.length===0)return{redos:[],undos:[]};if(d.length>0){const l=this._sheetDrawingService.getBatchUpdateOp(d),{undo:a,redo:u,objects:g}=l;o.push({id:p.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:u,objects:g,type:p.DrawingApplyType.UPDATE}}),s.push({id:p.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:a,objects:g,type:p.DrawingApplyType.UPDATE}})}if(h.length>0){const l=this._sheetDrawingService.getBatchRemoveOp(h),a=l.undo,u=l.redo,g=l.objects;o.push({id:p.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:u,objects:g,type:p.DrawingApplyType.REMOVE}}),s.push({id:p.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:a,objects:g,type:p.DrawingApplyType.INSERT}})}return o.push({id:x.id,params:[e]}),s.push({id:x.id,params:[e]}),{redos:o,undos:s}}_getUpdateOrDeleteDrawings(i,n,r){const e=[],t=[],{sheetTransform:o,anchorType:s=p.SheetDrawingAnchorType.Position,transform:c,unitId:d,subUnitId:h,drawingId:l}=r,{from:a,to:u}=o,{row:g,column:f}=a,{row:w,column:S}=u;if(o==null||c==null)return{updateDrawings:e,deleteDrawings:t};const{startRow:C,endRow:y,startColumn:I,endColumn:T}=i;let _=null,M=null;if(n===0&&g>=C&&w<=y)if(f>=I&&S<=T)t.push({unitId:d,subUnitId:h,drawingId:l});else{const v=this._shrinkCol(o,c,I,T,s);_=v==null?void 0:v.newSheetTransform,M=v==null?void 0:v.newTransform}else if(n===1&&f>=I&&S<=T)if(g>=C&&w<=y)t.push({unitId:d,subUnitId:h,drawingId:l});else{const v=this._shrinkRow(o,c,C,y,s);_=v==null?void 0:v.newSheetTransform,M=v==null?void 0:v.newTransform}else if(n===2){const v=this._expandRow(o,c,C,y,s);_=v==null?void 0:v.newSheetTransform,M=v==null?void 0:v.newTransform}else if(n===3){const v=this._expandCol(o,c,I,T,s);_=v==null?void 0:v.newSheetTransform,M=v==null?void 0:v.newTransform}if(_!=null&&M!=null){const v=V(_,this._selectionRenderService,this._skeletonManagerService);e.push({...r,sheetTransform:_,transform:v})}return{updateDrawings:e,deleteDrawings:t}}_remainDrawingSize(i,n,r){const e=$({...i},this._selectionRenderService);e!=null&&n.push({...r,sheetTransform:e})}_getDrawingUndoForColVisible(i,n,r){const e=this._drawingManagerService.getDrawingData(i,n),t=[],o=[];if(Object.keys(e).forEach(l=>{const a=e[l],{sheetTransform:u,transform:g,anchorType:f=p.SheetDrawingAnchorType.Position}=a;if(f===p.SheetDrawingAnchorType.None)this._remainDrawingSize(g,t,a);else{const{from:w,to:S}=u,{row:C,column:y}=w,{row:I,column:T}=S;for(let _=0;_<r.length;_++){const M=r[_],{startRow:v,endRow:P,startColumn:b,endColumn:j}=M;if(T<b)continue;if(f===p.SheetDrawingAnchorType.Position){let R=null,W=null;if(y>=b&&y<=j){const B=this._skeletonManagerService.attachRangeWithCoord({startColumn:y,endColumn:j,startRow:w.row,endRow:S.row});if(B==null)return;W={...g,left:B.startX}}if(W!=null&&(R=$(W,this._selectionRenderService),R!=null&&W!=null)){t.push({...a,sheetTransform:R,transform:W});break}this._remainDrawingSize(g,t,a);continue}if(y>=b&&T<=j)continue;let A=null,E=null;if(y>=b&&y<=j){const R=this._skeletonManagerService.attachRangeWithCoord({startColumn:y,endColumn:j,startRow:w.row,endRow:S.row});if(R==null)return;E={...g,left:(R==null?void 0:R.startX)||0,width:((g==null?void 0:g.width)||0)-R.endX+R.startX}}else if(T>=b&&T<=j){const R=this._skeletonManagerService.attachRangeWithCoord({startColumn:b,endColumn:T,startRow:w.row,endRow:S.row});if(R==null)return;E={...g,left:R.startX-((g==null?void 0:g.width)||0)}}else{const R=this._skeletonManagerService.attachRangeWithCoord({startColumn:b,endColumn:j,startRow:w.row,endRow:S.row});if(R==null)return;if(E={...g,width:((g==null?void 0:g.width)||0)-R.endX+R.startX},A=$(E,this._selectionRenderService),A!=null&&E!=null){o.push({...a,sheetTransform:A,transform:E});break}}if(E!=null&&(A=$(E,this._selectionRenderService)),E!=null&&A!=null){t.push({...a,sheetTransform:A,transform:E});break}else this._remainDrawingSize(g,t,a)}}}),t.length===0&&o.length===0)return{redos:[],undos:[]};const{redos:s,undos:c}=this._createUndoAndRedoMutation(i,n,t),d=[],h=[];if(o.length>0){const{redos:l,undos:a}=this._createUndoAndRedoMutation(i,n,o);d.push(...l),h.push(...a)}return{redos:s,undos:c,preRedos:d,preUndos:h}}_createUndoAndRedoMutation(i,n,r){const e=this._sheetDrawingService.getBatchUpdateOp(r),{undo:t,redo:o,objects:s}=e,c=[{id:p.SetDrawingApplyMutation.id,params:{unitId:i,subUnitId:n,op:o,objects:s,type:p.DrawingApplyType.UPDATE}},{id:x.id,params:[i]}],d=[{id:p.SetDrawingApplyMutation.id,params:{unitId:i,subUnitId:n,op:t,objects:s,type:p.DrawingApplyType.UPDATE}},{id:x.id,params:[i]}];return{redos:c,undos:d}}_getDrawingUndoForRowVisible(i,n,r){const e=this._drawingManagerService.getDrawingData(i,n),t=[],o=[];if(Object.keys(e).forEach(l=>{const a=e[l],{sheetTransform:u,transform:g,anchorType:f=p.SheetDrawingAnchorType.Position}=a;if(f===p.SheetDrawingAnchorType.None)this._remainDrawingSize(g,t,a);else{const{from:w,to:S}=u,{row:C,column:y}=w,{row:I,column:T}=S;for(let _=0;_<r.length;_++){const M=r[_],{startRow:v,endRow:P,startColumn:b,endColumn:j}=M;if(I<v)continue;if(f===p.SheetDrawingAnchorType.Position){let R=null,W=null;if(C>=v&&C<=P){const B=this._skeletonManagerService.attachRangeWithCoord({startColumn:w.column,endColumn:S.column,startRow:C,endRow:P});if(B==null)return;W={...g,top:B.startY}}if(W!=null&&(R=$(W,this._selectionRenderService),R!=null&&W!=null)){t.push({...a,sheetTransform:R,transform:W});break}this._remainDrawingSize(g,t,a);continue}if(C>=v&&I<=P)continue;let A=null,E=null;if(C>=v&&C<=P){const R=this._skeletonManagerService.attachRangeWithCoord({startColumn:w.column,endColumn:S.column,startRow:C,endRow:P});if(R==null)return;E={...g,top:(R==null?void 0:R.startY)||0,height:((g==null?void 0:g.height)||0)-R.endY+R.startY}}else if(I>=v&&I<=P){const R=this._skeletonManagerService.attachRangeWithCoord({startColumn:w.column,endColumn:S.column,startRow:v,endRow:I});if(R==null)return;E={...g,top:R.startY-((g==null?void 0:g.height)||0)}}else{const R=this._skeletonManagerService.attachRangeWithCoord({startColumn:w.column,endColumn:S.column,startRow:v,endRow:P});if(R==null)return;if(E={...g,height:((g==null?void 0:g.height)||0)-R.endY+R.startY},A=$(E,this._selectionRenderService),A!=null&&E!=null){o.push({...a,sheetTransform:A,transform:E});break}}if(E!=null&&(A=$(E,this._selectionRenderService)),E!=null&&A!=null){t.push({...a,sheetTransform:A,transform:E});break}else this._remainDrawingSize(g,t,a)}}}),t.length===0&&o.length===0)return{redos:[],undos:[]};const{redos:s,undos:c}=this._createUndoAndRedoMutation(i,n,t),d=[],h=[];if(o.length>0){const{redos:l,undos:a}=this._createUndoAndRedoMutation(i,n,o);d.push(...l),h.push(...a)}return{redos:s,undos:c,preRedos:d,preUndos:h}}_getDrawingUndoForRowAndColSize(i,n,r,e){const t=this._drawingManagerService.getDrawingData(i,n),o=[];return Object.keys(t).forEach(s=>{const c=t[s],{sheetTransform:d,transform:h,anchorType:l=p.SheetDrawingAnchorType.Position}=c;if(l===p.SheetDrawingAnchorType.None)this._remainDrawingSize(h,o,c);else{const{from:a,to:u}=d,{row:g,column:f}=a,{row:w,column:S}=u;for(let C=0;C<r.length;C++){const y=r[C],{startRow:I,endRow:T,startColumn:_,endColumn:M}=y;if(w<I||S<_)continue;if(l===p.SheetDrawingAnchorType.Position&&(g<=I&&w>=T||f<=_&&S>=M)){this._remainDrawingSize(h,o,c);continue}const v=V({...d},this._selectionRenderService,this._skeletonManagerService);if(v!=null){o.push({...c,transform:v});break}}}}),o.length===0?{redos:[],undos:[]}:this._createUndoAndRedoMutation(i,n,o)}_getUnitIdAndSubUnitId(i,n){let r,e;if(n==="insert")r=i.unitId,e=i.subUnitId;else{const t=D.getSheetCommandTarget(this._univerInstanceService);if(t==null)return;r=t.unitId,e=t.subUnitId}return{unitId:r,subUnitId:e}}_moveRangeInterceptor(i){var I,T;const{toRange:n,fromRange:r}=i,e=D.getSheetCommandTarget(this._univerInstanceService);if(!e)return{redos:[],undos:[]};const{unitId:t,subUnitId:o}=e,s=(T=(I=this._renderManagerService.getRenderById(t))==null?void 0:I.with(U.SheetSkeletonManagerService))==null?void 0:T.getCurrentSkeleton();if(!s)return{redos:[],undos:[]};const c=U.attachRangeWithCoord(s,r);if(!c)return{redos:[],undos:[]};const{startX:d,endX:h,startY:l,endY:a}=c,u=this._sheetDrawingService.getDrawingData(t,o),g=[];Object.keys(u).forEach(_=>{const M=u[_];if(M.anchorType!==p.SheetDrawingAnchorType.Both)return;const{transform:v}=M;if(!v)return;const{left:P=0,top:b=0,width:j=0,height:A=0}=v,{drawingStartX:E,drawingEndX:R,drawingStartY:W,drawingEndY:B}={drawingStartX:P,drawingEndX:P+j,drawingStartY:b,drawingEndY:b+A};d<=E&&R<=h&&l<=W&&B<=a&&g.push(M)});const f=[],w=[],S=n.startRow-r.startRow,C=n.startColumn-r.startColumn,y=g.map(_=>{const M=_.sheetTransform,v={to:{...M.to,row:M.to.row+S,column:M.to.column+C},from:{...M.from,row:M.from.row+S,column:M.from.column+C}},P=V(v,this._selectionRenderService,this._skeletonManagerService);return{unitId:t,subUnitId:o,drawingId:_.drawingId,transform:P,sheetTransform:v}});if(y.length){const _=this._sheetDrawingService.getBatchUpdateOp(y),{undo:M,redo:v,objects:P}=_;f.push({id:p.SetDrawingApplyMutation.id,params:{unitId:t,subUnitId:o,op:v,objects:P,type:p.DrawingApplyType.UPDATE}}),w.push({id:p.SetDrawingApplyMutation.id,params:{unitId:t,subUnitId:o,op:M,objects:P,type:p.DrawingApplyType.UPDATE}})}return{redos:f,undos:w}}_moveRowInterceptor(i,n){const r=this._getUnitIdAndSubUnitId(i,n);if(r==null)return{redos:[],undos:[]};const{unitId:e,subUnitId:t}=r,{range:o}=i,s=o.startRow,c=o.endRow,d=[],h=[],l=this._sheetDrawingService.getDrawingData(e,t),a=[],u=[];if(Object.keys(l).forEach(g=>{const f=l[g],{sheetTransform:w,transform:S,anchorType:C=p.SheetDrawingAnchorType.Position}=f;if(w==null||S==null)return;let y,I;if(n==="insert"){const _=this._expandRow(w,S,s,c,C);y=_==null?void 0:_.newSheetTransform,I=_==null?void 0:_.newTransform}else{const{from:_,to:M}=w,{row:v}=_,{row:P}=M;if(C===p.SheetDrawingAnchorType.Both&&v>=s&&P<=c)u.push({unitId:e,subUnitId:t,drawingId:g});else{const b=this._shrinkRow(w,S,s,c,C);y=b==null?void 0:b.newSheetTransform,I=b==null?void 0:b.newTransform}}if(!y||!I)return;const T={unitId:e,subUnitId:t,drawingId:g,transform:I,sheetTransform:y};a.push(T)}),a.length===0&&u.length===0)return{redos:[],undos:[]};if(a.length>0){const g=this._sheetDrawingService.getBatchUpdateOp(a),{undo:f,redo:w,objects:S}=g;d.push({id:p.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:w,objects:S,type:p.DrawingApplyType.UPDATE}}),h.push({id:p.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:f,objects:S,type:p.DrawingApplyType.UPDATE}})}if(u.length>0){const g=this._sheetDrawingService.getBatchRemoveOp(u),f=g.undo,w=g.redo,S=g.objects;d.push({id:p.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:w,objects:S,type:p.DrawingApplyType.REMOVE}}),h.push({id:p.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:f,objects:S,type:p.DrawingApplyType.INSERT}})}return d.push({id:x.id,params:[e]}),h.push({id:x.id,params:[e]}),{redos:d,undos:h}}_moveColInterceptor(i,n){const r=this._getUnitIdAndSubUnitId(i,n);if(r==null)return{redos:[],undos:[]};const{unitId:e,subUnitId:t}=r,{range:o}=i,s=o.startColumn,c=o.endColumn,d=[],h=[],l=this._sheetDrawingService.getDrawingData(e,t),a=[],u=[];if(Object.keys(l).forEach(g=>{const f=l[g],{sheetTransform:w,transform:S,anchorType:C=p.SheetDrawingAnchorType.Position}=f;if(w==null||S==null)return;let y,I;if(n==="insert"){const _=this._expandCol(w,S,s,c,C);y=_==null?void 0:_.newSheetTransform,I=_==null?void 0:_.newTransform}else{const{from:_,to:M}=w,{column:v}=_,{column:P}=M;if(C===p.SheetDrawingAnchorType.Both&&v>=s&&P<=c)u.push({unitId:e,subUnitId:t,drawingId:g});else{const b=this._shrinkCol(w,S,s,c,C);y=b==null?void 0:b.newSheetTransform,I=b==null?void 0:b.newTransform}}if(!y||!I)return;const T={unitId:e,subUnitId:t,drawingId:g,transform:I,sheetTransform:y};a.push(T)}),a.length===0&&u.length===0)return{redos:[],undos:[]};if(a.length>0){const g=this._sheetDrawingService.getBatchUpdateOp(a),{undo:f,redo:w,objects:S}=g;d.push({id:p.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:w,objects:S,type:p.DrawingApplyType.UPDATE}}),h.push({id:p.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:f,objects:S,type:p.DrawingApplyType.UPDATE}})}if(u.length>0){const g=this._sheetDrawingService.getBatchRemoveOp(u),f=g.undo,w=g.redo,S=g.objects;d.push({id:p.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:w,objects:S,type:p.DrawingApplyType.REMOVE}}),h.push({id:p.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:f,objects:S,type:p.DrawingApplyType.INSERT}})}return d.push({id:x.id,params:[e]}),h.push({id:x.id,params:[e]}),{redos:d,undos:h}}_expandCol(i,n,r,e,t=p.SheetDrawingAnchorType.Position){const o=e-r+1,{from:s,to:c}=i,{column:d}=s,{column:h}=c;if(t===p.SheetDrawingAnchorType.None)return{newSheetTransform:$({...n},this._selectionRenderService),newTransform:n};let l=null,a=null;if(d>=r){const u=this._skeletonManagerService.attachRangeWithCoord({startColumn:r,endColumn:e,startRow:s.row,endRow:c.row});if(u==null)return;a={...n,left:(n.left||0)+u.endX-u.startX},l=$(a,this._selectionRenderService)}else if(h>=e)if(t===p.SheetDrawingAnchorType.Both)l={from:{...s},to:{...c,column:h+o}},a=V(l,this._selectionRenderService,this._skeletonManagerService);else return{newSheetTransform:$({...n},this._selectionRenderService),newTransform:n};return l!=null&&a!=null?{newSheetTransform:l,newTransform:a}:null}_shrinkCol(i,n,r,e,t=p.SheetDrawingAnchorType.Position){const o=e-r+1,{from:s,to:c}=i,{column:d}=s,{column:h}=c;if(t===p.SheetDrawingAnchorType.None)return{newSheetTransform:$({...n},this._selectionRenderService),newTransform:n};let l=null,a=null;if(d>e)l={from:{...s,column:d-o},to:{...c,column:h-o}},a=V(l,this._selectionRenderService,this._skeletonManagerService);else{if(d>=r&&h<=e)return null;if(d<r&&h>e)if(t===p.SheetDrawingAnchorType.Both)l={from:{...s},to:{...c,column:h-o}},a=V(l,this._selectionRenderService,this._skeletonManagerService);else return{newSheetTransform:$({...n},this._selectionRenderService),newTransform:n};else if(d>=r&&d<=e){if(d===r)a={...n,left:(n.left||0)-i.from.columnOffset};else{const u=this._skeletonManagerService.attachRangeWithCoord({startColumn:r,endColumn:d-1,startRow:s.row,endRow:c.row});if(u==null)return;a={...n,left:(n.left||0)-u.endX+u.startX-i.from.columnOffset}}l=$(a,this._selectionRenderService)}else if(h>=r&&h<=e&&t===p.SheetDrawingAnchorType.Both){const u=this._skeletonManagerService.attachRangeWithCoord({startColumn:r-1,endColumn:r-1,startRow:s.row,endRow:c.row});if(u==null)return;l={from:{...s},to:{...c,column:r-1,columnOffset:u.endX-u.startX}},a=V(l,this._selectionRenderService,this._skeletonManagerService)}}return l!=null&&a!=null?{newSheetTransform:l,newTransform:a}:null}_expandRow(i,n,r,e,t=p.SheetDrawingAnchorType.Position){const o=e-r+1,{from:s,to:c}=i,{row:d}=s,{row:h}=c;if(t===p.SheetDrawingAnchorType.None)return{newSheetTransform:$({...n},this._selectionRenderService),newTransform:n};let l=null,a=null;if(d>=r){const u=this._skeletonManagerService.attachRangeWithCoord({startRow:r,endRow:e,startColumn:s.column,endColumn:c.column});if(u==null)return;a={...n,top:(n.top||0)+u.endY-u.startY},l=$(a,this._selectionRenderService)}else if(h>=e)if(t===p.SheetDrawingAnchorType.Both)l={from:{...s},to:{...c,row:h+o}},a=V(l,this._selectionRenderService,this._skeletonManagerService);else return{newSheetTransform:$({...n},this._selectionRenderService),newTransform:n};return l!=null&&a!=null?{newSheetTransform:l,newTransform:a}:null}_shrinkRow(i,n,r,e,t=p.SheetDrawingAnchorType.Position){const o=e-r+1,{from:s,to:c}=i,{row:d}=s,{row:h}=c;if(t===p.SheetDrawingAnchorType.None)return{newSheetTransform:$({...n},this._selectionRenderService),newTransform:n};let l=null,a=null;if(d>e)l={from:{...s,row:d-o},to:{...c,row:h-o}},a=V(l,this._selectionRenderService,this._skeletonManagerService);else{if(d>=r&&h<=e)return null;if(d<r&&h>e)if(t===p.SheetDrawingAnchorType.Both)l={from:{...s},to:{...c,row:h-o}},a=V(l,this._selectionRenderService,this._skeletonManagerService);else return{newSheetTransform:$({...n},this._selectionRenderService),newTransform:n};else if(d>=r&&d<=e){if(d===r)a={...n,top:(n.top||0)-i.from.rowOffset};else{const u=this._skeletonManagerService.attachRangeWithCoord({startRow:r,endRow:d-1,startColumn:s.column,endColumn:c.column});if(u==null)return;a={...n,top:(n.top||0)-u.endY+u.startY-i.from.rowOffset}}l=$(a,this._selectionRenderService)}else if(h>=r&&h<=e&&t===p.SheetDrawingAnchorType.Both){const u=this._skeletonManagerService.attachRangeWithCoord({startColumn:s.column,endColumn:s.column,startRow:r-1,endRow:r-1});if(u==null)return;l={from:{...s},to:{...c,row:r-1,rowOffset:u.endY-u.startY}},a=V(l,this._selectionRenderService,this._skeletonManagerService)}}return l!=null&&a!=null?{newSheetTransform:l,newTransform:a}:null}_commandListener(){this.disposeWithMe(this._commandService.onCommandExecuted(i=>{i.id===D.SetWorksheetActiveOperation.id&&setTimeout(()=>{const n=i.params,{unitId:r,subUnitId:e}=n,t=this._drawingManagerService.drawingManagerData,o=[],s=[];Object.keys(t).forEach(c=>{const d=t[c];d!=null&&Object.keys(d).forEach(h=>{const l=d[h].data;l!=null&&Object.keys(l).forEach(a=>{if(c===r&&h===e){const u=l[a];u.transform=V(u.sheetTransform,this._selectionRenderService,this._skeletonManagerService),o.push(l[a])}else s.push(l[a])})})}),this._drawingManagerService.removeNotification(s),this._drawingManagerService.addNotification(o)},0)}))}_sheetRefreshListener(){this.disposeWithMe(this._commandService.onCommandExecuted(i=>{wn.includes(i.id)&&requestIdleCallback(()=>{const n=i.params,{unitId:r,subUnitId:e,ranges:t}=n;this._refreshDrawingTransform(r,e,t)})}))}_refreshDrawingTransform(i,n,r){const e=this._drawingManagerService.getDrawingData(i,n),t=[];Object.keys(e).forEach(o=>{const s=e[o],{sheetTransform:c,transform:d,anchorType:h=p.SheetDrawingAnchorType.Position}=s;if(h===p.SheetDrawingAnchorType.None)return!0;const{from:l,to:a}=c,{row:u,column:g}=l,{row:f,column:w}=a;for(let S=0;S<r.length;S++){const C=r[S],{startRow:y,endRow:I,startColumn:T,endColumn:_}=C;if(m.Rectangle.intersects({startRow:y,endRow:I,startColumn:T,endColumn:_},{startRow:u,endRow:f,startColumn:g,endColumn:w})||u>I||g>_){const M=h===p.SheetDrawingAnchorType.Position,v=V(c,this._selectionRenderService,this._skeletonManagerService);t.push({...s,transform:{...v,width:M?d==null?void 0:d.width:v==null?void 0:v.width,height:M?d==null?void 0:d.height:v==null?void 0:v.height}});break}}}),t.length!==0&&(this._drawingManagerService.refreshTransform(t),this._commandService.syncExecuteCommand(x.id,[i]))}};Te=pn([q(1,N.IRenderManagerService),q(2,m.ICommandService),q(3,U.ISheetSelectionRenderService),q(4,m.Inject(U.SheetSkeletonManagerService)),q(5,m.Inject(D.SheetInterceptorService)),q(6,p.ISheetDrawingService),q(7,O.IDrawingManagerService),q(8,m.IUniverInstanceService)],Te);var Sn=Object.defineProperty,vn=Object.getOwnPropertyDescriptor,_n=(i,n,r,e)=>{for(var t=e>1?void 0:e?vn(n,r):n,o=i.length-1,s;o>=0;o--)(s=i[o])&&(t=(e?s(n,r,t):s(t))||t);return e&&t&&Sn(n,r,t),t},ee=(i,n)=>(r,e)=>n(r,e,i);function Dn(i,n,r,e){const{scaleX:t,scaleY:o}=n.getAncestorScale(),s=n.getViewport(N.SHEET_VIEWPORT_KEY.VIEW_MAIN),c={left:!0,top:!0};if(!s)return{...i,absolute:c};const{left:d,right:h,top:l,bottom:a}=i,u=e.getFreeze(),{startColumn:g,startRow:f,xSplit:w,ySplit:S}=u,C=r.getNoMergeCellPositionByIndexWithNoHeader(f-S,g-w),y=r.getNoMergeCellPositionByIndexWithNoHeader(f,g),{rowHeaderWidth:I,columnHeaderHeight:T}=r,_=y.startX-C.startX,M=y.startY-C.startY,{top:v,left:P,viewportScrollX:b,viewportScrollY:j}=s;let A,E;d<P?(c.left=!0,A=(_+I+(d-P))*t,E=Math.max(Math.min((_+I+(h-P))*t,(_+I)*t),(h-b)*t)):(c.left=!1,A=Math.max((d-b)*t,(_+I)*t),E=Math.max((h-b)*t,(_+I)*t));let R,W;return l<v?(c.top=!0,R=(M+T+(l-v))*o,W=Math.max(Math.min((M+T+(h-v))*o,(M+T)*o),(a-j)*o)):(c.top=!1,R=Math.max((l-j)*o,(M+T)*o),W=Math.max((a-j)*o,(M+T)*o)),{left:A,right:E,top:R,bottom:W,absolute:c}}const ye=(i,n,r,e)=>{const{scene:t}=n,{left:o,top:s,width:c,height:d,angle:h}=i,l={left:o,right:o+c,top:s,bottom:s+d},a=Dn(l,t,r,e),{scaleX:u,scaleY:g}=t.getAncestorScale();return{startX:a.left,endX:a.right,startY:a.top,endY:a.bottom,rotate:h,width:c*u,height:d*g,absolute:a.absolute}};exports.SheetCanvasFloatDomManagerService=class extends m.Disposable{constructor(r,e,t,o,s,c,d){super();Y(this,"_domLayerMap",new Map);Y(this,"_domLayerInfoMap",new Map);Y(this,"_transformChange$",new L.Subject);Y(this,"transformChange$",this._transformChange$.asObservable());Y(this,"_add$",new L.Subject);Y(this,"add$",this._add$.asObservable());Y(this,"_remove$",new L.Subject);Y(this,"remove$",this._remove$.asObservable());Y(this,"_hooks",[]);this._renderManagerService=r,this._univerInstanceService=e,this._commandService=t,this._drawingManagerService=o,this._canvasFloatDomService=s,this._sheetDrawingService=c,this._lifecycleService=d,this._drawingAddListener(),this._featureUpdateListener(),this._deleteListener(),this._bindScrollEvent()}_bindScrollEvent(){this._lifecycleService.lifecycle$.pipe(L.filter(r=>r===m.LifecycleStages.Rendered),L.take(1)).subscribe(()=>{this._scrollUpdateListener()})}_ensureMap(r,e){let t=this._domLayerMap.get(r);t||(t=new Map,this._domLayerMap.set(r,t));let o=t.get(e);return o||(o=new Map,t.set(e,o)),o}getFloatDomInfo(r){return this._domLayerInfoMap.get(r)}_getSceneAndTransformerByDrawingSearch(r){if(r==null)return;const e=this._renderManagerService.getRenderById(r),t=e==null?void 0:e.scene;if(e==null||t==null)return null;const o=t.getTransformerByCreate(),s=e.engine.getCanvasElement();return{scene:t,transformer:o,renderObject:e,canvas:s}}_getFloatDomProps(r){let e;return this._hooks.forEach(t=>{e=t.onGetFloatDomProps(r)}),e}_drawingAddListener(){this.disposeWithMe(this._drawingManagerService.add$.subscribe(r=>{r.forEach(e=>{var We,Le,xe;const{unitId:t,subUnitId:o,drawingId:s}=e,c=D.getSheetCommandTarget(this._univerInstanceService,{unitId:t,subUnitId:o}),d=this._drawingManagerService.getDrawingByParam(e),h=this._univerInstanceService.getUnit(t);if(!h)return;const l=h.getActiveSheet().getSheetId();if(!d||!c)return;const a=(We=this._renderManagerService.getRenderById(t))==null?void 0:We.with(U.SheetSkeletonManagerService).getWorksheetSkeleton(o);if(!a)return;const{transform:u,drawingType:g,data:f}=d;if(g!==O.DrawingTypeEnum.DRAWING_DOM&&g!==O.DrawingTypeEnum.DRAWING_CHART)return;const w=this._getSceneAndTransformerByDrawingSearch(t);if(w==null)return;const{scene:S,canvas:C}=w;if(u==null)return!0;if(l!==o)return;const{left:y,top:I,width:T,height:_,angle:M,flipX:v,flipY:P,skewX:b,skewY:j}=u,A=O.getDrawingShapeKeyByDrawingSearch({unitId:t,subUnitId:o,drawingId:s}),E=S.getObject(A);if(E!=null){E.transformByState({left:y,top:I,width:T,height:_,angle:M,flipX:v,flipY:P,skewX:b,skewY:j});return}const R={left:y,top:I,width:T,height:_,zIndex:this._drawingManagerService.getDrawingOrder(t,o).length-1},W=g===O.DrawingTypeEnum.DRAWING_CHART;W&&(R.fill="white",R.rotateEnabled=!1,f&&f.border&&(R.stroke=f.border),R.paintFirst="stroke",R.strokeWidth=1,R.borderEnabled=!1,R.radius=8);const B=new N.Rect(A,R);W&&B.setObjectType(N.ObjectType.CHART),S.addObject(B,N.DRAWING_OBJECT_LAYER_INDEX),d.allowTransform!==!1&&S.attachTransformerTo(B);const z=this._ensureMap(t,o),De=new m.DisposableCollection,ze=ye(B,w.renderObject,a.skeleton,c.worksheet),Ie=new L.BehaviorSubject(ze),qe={dispose:De,rect:B,position$:Ie,unitId:t,subUnitId:o};this._canvasFloatDomService.addFloatDom({position$:Ie,id:s,componentKey:d.componentKey,onPointerDown:F=>{C.dispatchEvent(new PointerEvent(F.type,F))},onPointerMove:F=>{C.dispatchEvent(new PointerEvent(F.type,F))},onPointerUp:F=>{C.dispatchEvent(new PointerEvent(F.type,F))},onWheel:F=>{C.dispatchEvent(new WheelEvent(F.type,F))},props:(xe=(Le=z.get(s))==null?void 0:Le.props)!=null?xe:this._getFloatDomProps(s),data:f,unitId:t});const je=B.onTransformChange$.subscribeEvent(()=>{const F=ye(B,w.renderObject,a.skeleton,c.worksheet);Ie.next(F)});De.add(()=>{this._canvasFloatDomService.removeFloatDom(s)}),je&&De.add(je),this._domLayerInfoMap.set(s,qe),z.set(s,{...z.get(s)})})})),this.disposeWithMe(this._drawingManagerService.remove$.subscribe(r=>{r.forEach(e=>{const{unitId:t,subUnitId:o,drawingId:s}=e,c=O.getDrawingShapeKeyByDrawingSearch({unitId:t,subUnitId:o,drawingId:s}),d=this._getSceneAndTransformerByDrawingSearch(t);if(d==null)return;const{transformer:h,scene:l}=d,a=l.getObject(c);a!=null&&a.oKey&&h.clearControlByIds([a==null?void 0:a.oKey])})}))}_scrollUpdateListener(){const r=(e,t)=>{var l;const o=this._getSceneAndTransformerByDrawingSearch(e),s=this._ensureMap(e,t),c=Array.from(s.keys()),d=D.getSheetCommandTarget(this._univerInstanceService,{unitId:e,subUnitId:t}),h=(l=this._renderManagerService.getRenderById(e))==null?void 0:l.with(U.SheetSkeletonManagerService).getWorksheetSkeleton(t);!o||!d||!h||c.forEach(a=>{const u=this._domLayerInfoMap.get(a);if(u){const g=ye(u.rect,o.renderObject,h.skeleton,d.worksheet);u.position$.next(g)}})};this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(m.UniverInstanceType.UNIVER_SHEET).pipe(L.filter(e=>!!e),L.switchMap(e=>e.activeSheet$),L.filter(e=>!!e),L.map(e=>{const t=this._renderManagerService.getRenderById(e.getUnitId());return t?{render:t,unitId:e.getUnitId(),subUnitId:e.getSheetId()}:null}),L.filter(e=>!!e),L.switchMap(e=>m.fromEventSubject(e.render.scene.getViewport(U.VIEWPORT_KEY.VIEW_MAIN).onScrollAfter$).pipe(L.map(()=>({unitId:e.unitId,subUnitId:e.subUnitId}))))).subscribe(({unitId:e,subUnitId:t})=>{r(e,t)})),this.disposeWithMe(this._commandService.onCommandExecuted(e=>{var t,o;if(e.id===U.SetZoomRatioOperation.id){const s=e.params,{unitId:c}=s;Array.from((o=(t=this._domLayerMap.get(c))==null?void 0:t.keys())!=null?o:[]).forEach(h=>{r(c,h)})}else if(e.id===D.SetFrozenMutation.id){const{unitId:s,subUnitId:c}=e.params;r(s,c)}}))}_getPosition(r,e){var g;const{startX:t,endX:o,startY:s,endY:c}=r,d=(g=this._renderManagerService.getRenderById(e))==null?void 0:g.with(U.ISheetSelectionRenderService);if(d==null)return;const h=d.getCellWithCoordByOffset(t,s);if(h==null)return;const l={column:h.actualColumn,columnOffset:t-h.startX,row:h.actualRow,rowOffset:s-h.startY},a=d.getCellWithCoordByOffset(o,c);if(a==null)return;const u={column:a.actualColumn,columnOffset:o-a.startX,row:a.actualRow,rowOffset:c-a.startY};return{from:l,to:u}}_featureUpdateListener(){this.disposeWithMe(this._drawingManagerService.update$.subscribe(r=>{r.forEach(e=>{const t=this._drawingManagerService.getDrawingByParam(e);if(!t||t.drawingType!==O.DrawingTypeEnum.DRAWING_DOM&&t.drawingType!==O.DrawingTypeEnum.DRAWING_CHART)return;const o={...t.transform};this._transformChange$.next({id:e.drawingId,value:o})})}))}_deleteListener(){this.disposeWithMe(this._drawingManagerService.remove$.subscribe(r=>{r.forEach(e=>{this._removeDom(e.drawingId)})}))}updateFloatDomProps(r,e,t,o){const s=this._domLayerInfoMap.get(t),c=this._getSceneAndTransformerByDrawingSearch(r);if(s&&c){const{scene:d}=c,h=O.getDrawingShapeKeyByDrawingSearch({unitId:r,subUnitId:e,drawingId:t}),l=d.getObject(h);l&&l instanceof N.Rect&&l.setProps(o)}}addFloatDomToPosition(r,e){const t=D.getSheetCommandTarget(this._univerInstanceService,{unitId:r.unitId,subUnitId:r.subUnitId});if(!t)throw new Error("cannot find current target!");const{unitId:o,subUnitId:s}=t,{initPosition:c,componentKey:d,data:h,allowTransform:l=!0}=r,a=e!=null?e:m.generateRandomId(),u=this._getPosition(c,o);if(u==null)return;this._ensureMap(o,s).set(a,r);const f={unitId:o,subUnitId:s,drawingId:a,drawingType:r.type||O.DrawingTypeEnum.DRAWING_DOM,componentKey:d,sheetTransform:u,transform:{left:c.startX,top:c.startY,width:c.endX-c.startX,height:c.endY-c.startY},data:h,allowTransform:l};return this._commandService.executeCommand(oe.id,{unitId:o,drawings:[f]}),this._add$.next({unitId:o,subUnitId:s,id:a}),{id:a,dispose:()=>{this._removeDom(a,!0)}}}_removeDom(r,e=!1){const t=this._domLayerInfoMap.get(r);if(!t)return;const{unitId:o,subUnitId:s}=t;this._domLayerInfoMap.delete(r),t.dispose.dispose();const c=this._getSceneAndTransformerByDrawingSearch(o);if(c&&c.scene.removeObject(t.rect),e){this._ensureMap(o,s).delete(r);const h=this._drawingManagerService.getDrawingByParam({unitId:o,subUnitId:s,drawingId:r});if(!h)return;const l=this._sheetDrawingService.getBatchRemoveOp([h]),{redo:a,objects:u}=l;this._commandService.syncExecuteCommand(p.SetDrawingApplyMutation.id,{unitId:o,subUnitId:s,op:a,objects:u,type:p.DrawingApplyType.REMOVE})}}addHook(r){return this._hooks.push(r),{dispose:()=>{const e=this._hooks.findIndex(t=>t===r);this._hooks.splice(e,1)}}}};exports.SheetCanvasFloatDomManagerService=_n([ee(0,m.Inject(N.IRenderManagerService)),ee(1,m.IUniverInstanceService),ee(2,m.Inject(m.ICommandService)),ee(3,O.IDrawingManagerService),ee(4,m.Inject(G.CanvasFloatDomService)),ee(5,p.ISheetDrawingService),ee(6,m.Inject(m.LifecycleService))],exports.SheetCanvasFloatDomManagerService);var Xe=Object.defineProperty,In=Object.getOwnPropertyDescriptor,Cn=(i,n,r)=>n in i?Xe(i,n,{enumerable:!0,configurable:!0,writable:!0,value:r}):i[n]=r,yn=(i,n,r,e)=>{for(var t=e>1?void 0:e?In(n,r):n,o=i.length-1,s;o>=0;o--)(s=i[o])&&(t=(e?s(n,r,t):s(t))||t);return e&&t&&Xe(n,r,t),t},Me=(i,n)=>(r,e)=>n(r,e,i),Ke=(i,n,r)=>Cn(i,typeof n!="symbol"?n+"":n,r);const Mn="SHEET_IMAGE_UI_PLUGIN";exports.UniverSheetsDrawingUIPlugin=class extends m.Plugin{constructor(n=et,r,e,t){super(),this._config=n,this._injector=r,this._renderManagerService=e,this._configService=t;const{menu:o,...s}=this._config;o&&this._configService.setConfig("menu",o,{merge:!0}),this._configService.setConfig(Qe,s)}onStarting(){m.registerDependencies(this._injector,[[exports.SheetCanvasFloatDomManagerService],[pe],[he],[Se],[we],[fe]]),m.touchDependencies(this._injector,[[exports.SheetCanvasFloatDomManagerService]])}onReady(){m.touchDependencies(this._injector,[[fe]])}onRendered(){this._registerRenderModules(),m.touchDependencies(this._injector,[[we],[Se],[pe]])}onSteady(){this._injector.get(he)}_registerRenderModules(){[[me],[Te],[Re]].forEach(n=>{this.disposeWithMe(this._renderManagerService.registerRenderModule(m.UniverInstanceType.UNIVER_SHEET,n))})}};Ke(exports.UniverSheetsDrawingUIPlugin,"type",m.UniverInstanceType.UNIVER_SHEET);Ke(exports.UniverSheetsDrawingUIPlugin,"pluginName",Mn);exports.UniverSheetsDrawingUIPlugin=yn([m.DependentOn(O.UniverDrawingPlugin,te.UniverDrawingUIPlugin,p.UniverSheetsDrawingPlugin),Me(1,m.Inject(m.Injector)),Me(2,N.IRenderManagerService),Me(3,m.IConfigService)],exports.UniverSheetsDrawingUIPlugin);exports.ClearSheetDrawingTransformerOperation=x;exports.DeleteDrawingsCommand=Ee;exports.EditSheetDrawingOperation=Oe;exports.GroupSheetDrawingCommand=Pe;exports.IMAGE_MENU_ID=Ne;exports.InsertFloatImageCommand=_e;exports.InsertSheetDrawingCommand=oe;exports.MoveDrawingsCommand=ne;exports.RemoveSheetDrawingCommand=ie;exports.SetDrawingArrangeCommand=Ae;exports.SetSheetDrawingCommand=se;exports.SidebarSheetDrawingOperation=be;exports.UngroupSheetDrawingCommand=Ue;
|
|
9
|
+
*/var tt=H,nt=Symbol.for("react.element"),rt=Symbol.for("react.fragment"),it=Object.prototype.hasOwnProperty,ot=tt.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,st={key:!0,ref:!0,__self:!0,__source:!0};function Ge(i,n,r){var e,t={},o=null,s=null;r!==void 0&&(o=""+r),n.key!==void 0&&(o=""+n.key),n.ref!==void 0&&(s=n.ref);for(e in n)it.call(n,e)&&!st.hasOwnProperty(e)&&(t[e]=n[e]);if(i&&i.defaultProps)for(e in n=i.defaultProps,n)t[e]===void 0&&(t[e]=n[e]);return{$$typeof:nt,type:i,key:o,ref:s,props:t,_owner:ot.current}}ve.Fragment=rt;ve.jsx=Ge;ve.jsxs=Ge;$e.exports=ve;var k=$e.exports;const at="univer-upload-loading",ct="univer-upload-loading-body",dt="univer-upload-loading-body-animation",lt="univer-UniverCircleAnimation",ut="univer-upload-loading-body-text",ce={uploadLoading:at,uploadLoadingBody:ct,uploadLoadingBodyAnimation:dt,univerCircleAnimation:lt,uploadLoadingBodyText:ut},gt=()=>{const i=m.useDependency(O.IImageIoService),n=m.useDependency(m.LocaleService),[r,e]=H.useState(0);return H.useEffect(()=>{const t=i.change$.subscribe(o=>{e(o)});return()=>{t.unsubscribe()}},[i]),k.jsx("div",{style:{display:r>0?"block":"none"},className:ce.uploadLoading,children:k.jsxs("div",{className:ce.uploadLoadingBody,children:[k.jsx("div",{className:ce.uploadLoadingBodyAnimation}),k.jsx("div",{className:ce.uploadLoadingBodyText,children:`${n.t("uploadLoading.loading")}: ${r}`})]})})};var ht=Object.defineProperty,mt=Object.getOwnPropertyDescriptor,pt=(i,n,r,e)=>{for(var t=e>1?void 0:e?mt(n,r):n,o=i.length-1,s;o>=0;o--)(s=i[o])&&(t=(e?s(n,r,t):s(t))||t);return e&&t&&ht(n,r,t),t},Q=(i,n)=>(r,e)=>n(r,e,i);let he=class extends m.RxDisposable{constructor(n,r,e,t,o,s,c){super();Y(this,"_initImagePopupMenu",new Set);this._injector=n,this._drawingManagerService=r,this._canvasPopManagerService=e,this._renderManagerService=t,this._univerInstanceService=o,this._contextService=s,this._uiPartsService=c,this._init()}_init(){this._univerInstanceService.getCurrentTypeOfUnit$(m.UniverInstanceType.UNIVER_SHEET).pipe(L.takeUntil(this.dispose$)).subscribe(n=>this._create(n)),this._univerInstanceService.getTypeOfUnitDisposed$(m.UniverInstanceType.UNIVER_SHEET).pipe(L.takeUntil(this.dispose$)).subscribe(n=>this._dispose(n)),this._univerInstanceService.getAllUnitsForType(m.UniverInstanceType.UNIVER_SHEET).forEach(n=>this._create(n)),this._uiPartsService.registerComponent(G.BuiltInUIPart.CONTENT,()=>m.connectInjector(gt,this._injector))}_dispose(n){const r=n.getUnitId();this._renderManagerService.removeRender(r)}_create(n){if(!n)return;const r=n.getUnitId();this._renderManagerService.has(r)&&!this._initImagePopupMenu.has(r)&&(this._popupMenuListener(r),this._initImagePopupMenu.add(r))}_hasCropObject(n){const r=n.getAllObjectsByOrder();for(const e of r)if(e instanceof te.ImageCropperObject)return!0;return!1}_popupMenuListener(n){var o;const r=(o=this._renderManagerService.getRenderById(n))==null?void 0:o.scene;if(!r)return;const e=r.getTransformerByCreate();if(!e)return;let t;this.disposeWithMe(m.toDisposable(e.createControl$.subscribe(()=>{if(this._contextService.setContextValue(m.FOCUSING_COMMON_DRAWINGS,!0),this._hasCropObject(r))return;const s=e.getSelectedObjectMap();if(s.size>1){t==null||t.dispose();return}const c=s.values().next().value;if(!c)return;const d=c.oKey,h=this._drawingManagerService.getDrawingOKey(d);if(!h)return;const{unitId:l,subUnitId:a,drawingId:u,drawingType:g}=h,f=h.data;if(f&&f.disablePopup)return;t==null||t.dispose();const w=this._canvasPopManagerService.getFeatureMenu(l,a,u,g);t=this.disposeWithMe(this._canvasPopManagerService.attachPopupToObject(c,{componentKey:te.COMPONENT_IMAGE_POPUP_MENU,direction:"horizontal",offset:[2,0],extraProps:{menuItems:w||this._getImageMenuItems(l,a,u,g)}})),this._drawingManagerService.focusDrawing([{unitId:l,subUnitId:a,drawingId:u}])}))),this.disposeWithMe(e.clearControl$.subscribe(()=>{t==null||t.dispose(),this._contextService.setContextValue(m.FOCUSING_COMMON_DRAWINGS,!1),this._drawingManagerService.focusDrawing(null)})),this.disposeWithMe(e.changing$.subscribe(()=>{t==null||t.dispose()}))}_getImageMenuItems(n,r,e,t){return[{label:"image-popup.edit",index:0,commandId:Oe.id,commandParams:{unitId:n,subUnitId:r,drawingId:e},disable:t===O.DrawingTypeEnum.DRAWING_DOM},{label:"image-popup.delete",index:1,commandId:ie.id,commandParams:{unitId:n,drawings:[{unitId:n,subUnitId:r,drawingId:e}]},disable:!1},{label:"image-popup.crop",index:2,commandId:te.OpenImageCropOperation.id,commandParams:{unitId:n,subUnitId:r,drawingId:e},disable:t===O.DrawingTypeEnum.DRAWING_DOM},{label:"image-popup.reset",index:3,commandId:te.ImageResetSizeOperation.id,commandParams:[{unitId:n,subUnitId:r,drawingId:e}],disable:t===O.DrawingTypeEnum.DRAWING_DOM}]}};he=pt([Q(0,m.Inject(m.Injector)),Q(1,O.IDrawingManagerService),Q(2,m.Inject(U.SheetCanvasPopManagerService)),Q(3,N.IRenderManagerService),Q(4,m.IUniverInstanceService),Q(5,m.IContextService),Q(6,m.Inject(G.IUIPartsService))],he);function V(i,n,r){const{from:e,to:t,flipY:o=!1,flipX:s=!1,angle:c=0,skewX:d=0,skewY:h=0}=i,{column:l,columnOffset:a,row:u,rowOffset:g}=e,{column:f,columnOffset:w,row:S,rowOffset:C}=t,y=r.getCurrentSkeleton(),I=U.attachRangeWithCoord(y,{startColumn:l,endColumn:l,startRow:u,endRow:u});if(I==null)return;const T=U.attachRangeWithCoord(y,{startColumn:f,endColumn:f,startRow:S,endRow:S});if(T==null)return;const{startX:_,startY:M}=I,{startX:v,startY:P}=T;let b=N.precisionTo(_+a,1),j=N.precisionTo(M+g,1),A=N.precisionTo(v+w-b,1),E=N.precisionTo(P+C-j,1);I.startX===T.endX&&(A=0),I.startY===T.endY&&(E=0);const R=y.rowHeaderWidth+y.columnTotalWidth,W=y.columnHeaderHeight+y.rowTotalHeight;return b+A>R&&(b=R-A),j+E>W&&(j=W-E),{flipY:o,flipX:s,angle:c,skewX:d,skewY:h,left:b,top:j,width:A,height:E}}function $(i,n){const{left:r=0,top:e=0,width:t=0,height:o=0,flipY:s=!1,flipX:c=!1,angle:d=0,skewX:h=0,skewY:l=0}=i,a=n.getCellWithCoordByOffset(r,e);if(a==null)return;const u={column:a.actualColumn,columnOffset:N.precisionTo(r-a.startX,1),row:a.actualRow,rowOffset:N.precisionTo(e-a.startY,1)},g=n.getCellWithCoordByOffset(r+t,e+o);if(g==null)return;const f={column:g.actualColumn,columnOffset:N.precisionTo(r+t-g.startX,1),row:g.actualRow,rowOffset:N.precisionTo(e+o-g.startY,1)};return{flipY:s,flipX:c,angle:d,skewX:h,skewY:l,from:u,to:f}}var ft=Object.defineProperty,wt=Object.getOwnPropertyDescriptor,St=(i,n,r,e)=>{for(var t=e>1?void 0:e?wt(n,r):n,o=i.length-1,s;o>=0;o--)(s=i[o])&&(t=(e?s(n,r,t):s(t))||t);return e&&t&&ft(n,r,t),t},de=(i,n)=>(r,e)=>n(r,e,i);let Re=class extends m.Disposable{constructor(i,n,r,e,t){super(),this._context=i,this._sheetDrawingService=n,this._drawingManagerService=r,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 n in i){const r=i[n];for(const e in r.data){const t=r.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)}};Re=St([de(1,p.ISheetDrawingService),de(2,O.IDrawingManagerService),de(3,m.Inject(U.ISheetSelectionRenderService)),de(4,m.Inject(U.SheetSkeletonManagerService))],Re);var X=function(){return X=Object.assign||function(i){for(var n,r=1,e=arguments.length;r<e;r++){n=arguments[r];for(var t in n)Object.prototype.hasOwnProperty.call(n,t)&&(i[t]=n[t])}return i},X.apply(this,arguments)},vt=function(i,n){var r={};for(var e in i)Object.prototype.hasOwnProperty.call(i,e)&&n.indexOf(e)<0&&(r[e]=i[e]);if(i!=null&&typeof Object.getOwnPropertySymbols=="function")for(var t=0,e=Object.getOwnPropertySymbols(i);t<e.length;t++)n.indexOf(e[t])<0&&Object.prototype.propertyIsEnumerable.call(i,e[t])&&(r[e[t]]=i[e[t]]);return r},ke=H.forwardRef(function(i,n){var r=i.icon,e=i.id,t=i.className,o=i.extend,s=vt(i,["icon","id","className","extend"]),c="univerjs-icon univerjs-icon-".concat(e," ").concat(t||"").trim(),d=H.useRef("_".concat(It()));return Ve(r,"".concat(e),{defIds:r.defIds,idSuffix:d.current},X({ref:n,className:c},s),o)});function Ve(i,n,r,e,t){return H.createElement(i.tag,X(X({key:n},_t(i,r,t)),e),(Dt(i,r).children||[]).map(function(o,s){return Ve(o,"".concat(n,"-").concat(i.tag,"-").concat(s),r,void 0,t)}))}function _t(i,n,r){var e=X({},i.attrs);r!=null&&r.colorChannel1&&e.fill==="colorChannel1"&&(e.fill=r.colorChannel1);var t=n.defIds;return!t||t.length===0||(i.tag==="use"&&e["xlink:href"]&&(e["xlink:href"]=e["xlink:href"]+n.idSuffix),Object.entries(e).forEach(function(o){var s=o[0],c=o[1];typeof c=="string"&&(e[s]=c.replace(/url\(#(.*)\)/,"url(#$1".concat(n.idSuffix,")")))})),e}function Dt(i,n){var r,e=n.defIds;return!e||e.length===0?i:i.tag==="defs"&&(!((r=i.children)===null||r===void 0)&&r.length)?X(X({},i),{children:i.children.map(function(t){return typeof t.attrs.id=="string"&&e&&e.indexOf(t.attrs.id)>-1?X(X({},t),{attrs:X(X({},t.attrs),{id:t.attrs.id+n.idSuffix})}):t})}):i}function It(){return Math.random().toString(36).substring(2,8)}ke.displayName="UniverIcon";var Ct={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"}}]},Fe=H.forwardRef(function(i,n){return H.createElement(ke,Object.assign({},i,{id:"add-image-single",ref:n,icon:Ct}))});Fe.displayName="AddImageSingle";const Ee={id:"sheet.command.delete-drawing",type:m.CommandType.COMMAND,handler:i=>{const n=i.get(m.ICommandService),e=i.get(p.ISheetDrawingService).getFocusDrawings();if(e.length===0)return!1;const t=e[0].unitId,o=e.map(s=>{const{unitId:c,subUnitId:d,drawingId:h,drawingType:l}=s;return{unitId:c,subUnitId:d,drawingId:h,drawingType:l}});return n.executeCommand(ie.id,{unitId:t,drawings:o})}};function yt(i){const n=[];return i.forEach(r=>{const{parent:e,children:t}=r,{unitId:o,subUnitId:s,drawingId:c}=e,d=N.getGroupState(0,0,t.map(a=>a.transform||{})),h=t.map(a=>{const u=a.transform||{left:0,top:0},{unitId:g,subUnitId:f,drawingId:w}=a;return{unitId:g,subUnitId:f,drawingId:w,transform:{...u,left:u.left-d.left,top:u.top-d.top},groupId:c}}),l={unitId:o,subUnitId:s,drawingId:c,drawingType:O.DrawingTypeEnum.DRAWING_GROUP,transform:d};n.push({parent:l,children:h})}),n}function Mt(i){const n=[];return i.forEach(r=>{const{parent:e,children:t}=r,{unitId:o,subUnitId:s,drawingId:c,transform:d={width:0,height:0}}=e;if(d==null)return;const h=t.map(a=>{const{transform:u}=a,{unitId:g,subUnitId:f,drawingId:w}=a,S=N.transformObjectOutOfGroup(u||{},d,d.width||0,d.height||0);return{unitId:g,subUnitId:f,drawingId:w,transform:S,groupId:void 0}}),l={unitId:o,subUnitId:s,drawingId:c,drawingType:O.DrawingTypeEnum.DRAWING_GROUP,transform:{left:0,top:0}};n.push({parent:l,children:h})}),n}const Pe={id:"sheet.command.group-sheet-image",type:m.CommandType.COMMAND,handler:(i,n)=>{const r=i.get(m.ICommandService),e=i.get(m.IUndoRedoService),t=i.get(p.ISheetDrawingService);if(!n)return!1;const o=[];n.forEach(({parent:g,children:f})=>{o.push(g.unitId),f.forEach(w=>{o.push(w.unitId)})});const s=t.getGroupDrawingOp(n),{unitId:c,subUnitId:d,undo:h,redo:l,objects:a}=s;return r.syncExecuteCommand(p.SetDrawingApplyMutation.id,{op:l,unitId:c,subUnitId:d,objects:a,type:p.DrawingApplyType.GROUP})?(e.pushUndoRedo({unitID:c,undoMutations:[{id:p.SetDrawingApplyMutation.id,params:{op:h,unitId:c,subUnitId:d,objects:Mt(a),type:p.DrawingApplyType.UNGROUP}},{id:x.id,params:o}],redoMutations:[{id:p.SetDrawingApplyMutation.id,params:{op:l,unitId:c,subUnitId:d,objects:a,type:p.DrawingApplyType.GROUP}},{id:x.id,params:o}]}),!0):!1}},oe={id:"sheet.command.insert-sheet-image",type:m.CommandType.COMMAND,handler:(i,n)=>{var y,I,T;const r=i.get(m.ICommandService),e=i.get(m.IUndoRedoService),t=i.get(p.ISheetDrawingService),o=i.get(D.SheetInterceptorService);if(!n)return!1;const s=n.drawings,c=s.map(_=>_.unitId),d=t.getBatchAddOp(s),{unitId:h,subUnitId:l,undo:a,redo:u,objects:g}=d,f=o.onCommandExecute({id:oe.id,params:n}),w={id:p.SetDrawingApplyMutation.id,params:{op:u,unitId:h,subUnitId:l,objects:g,type:p.DrawingApplyType.INSERT}},S={id:p.SetDrawingApplyMutation.id,params:{op:a,unitId:h,subUnitId:l,objects:g,type:p.DrawingApplyType.REMOVE}};return m.sequenceExecute([...(y=f.preRedos)!=null?y:[],w,...f.redos],r)?(e.pushUndoRedo({unitID:h,undoMutations:[...(I=f.preUndos)!=null?I:[],S,...f.undos,{id:x.id,params:c}],redoMutations:[...(T=f.preRedos)!=null?T:[],w,...f.redos,{id:x.id,params:c}]}),!0):!1}},Ae={id:"sheet.command.set-drawing-arrange",type:m.CommandType.COMMAND,handler:(i,n)=>{const r=i.get(m.ICommandService),e=i.get(m.IUndoRedoService);if(!n)return!1;const t=i.get(p.ISheetDrawingService),{unitId:o,subUnitId:s,drawingIds:c,arrangeType:d}=n,h={unitId:o,subUnitId:s,drawingIds:c};let l;if(d===O.ArrangeTypeEnum.forward?l=t.getForwardDrawingsOp(h):d===O.ArrangeTypeEnum.backward?l=t.getBackwardDrawingOp(h):d===O.ArrangeTypeEnum.front?l=t.getFrontDrawingsOp(h):d===O.ArrangeTypeEnum.back&&(l=t.getBackDrawingsOp(h)),l==null)return!1;const{objects:a,redo:u,undo:g}=l;return r.syncExecuteCommand(p.SetDrawingApplyMutation.id,{op:u,unitId:o,subUnitId:s,objects:a,type:p.DrawingApplyType.ARRANGE})?(e.pushUndoRedo({unitID:o,undoMutations:[{id:p.SetDrawingApplyMutation.id,params:{op:g,unitId:o,subUnitId:s,objects:a,type:p.DrawingApplyType.ARRANGE}}],redoMutations:[{id:p.SetDrawingApplyMutation.id,params:{op:u,unitId:o,subUnitId:s,objects:a,type:p.DrawingApplyType.ARRANGE}}]}),!0):!1}},se={id:"sheet.command.set-sheet-image",type:m.CommandType.COMMAND,handler:(i,n)=>{const r=i.get(m.ICommandService),e=i.get(m.IUndoRedoService),t=i.get(p.ISheetDrawingService);if(!n)return!1;const{drawings:o}=n,s=t.getBatchUpdateOp(o),{unitId:c,subUnitId:d,undo:h,redo:l,objects:a}=s;return r.syncExecuteCommand(p.SetDrawingApplyMutation.id,{unitId:c,subUnitId:d,op:l,objects:a,type:p.DrawingApplyType.UPDATE})?(e.pushUndoRedo({unitID:c,undoMutations:[{id:p.SetDrawingApplyMutation.id,params:{unitId:c,subUnitId:d,op:h,objects:a,type:p.DrawingApplyType.UPDATE}},{id:x.id,params:[c]}],redoMutations:[{id:p.SetDrawingApplyMutation.id,params:{unitId:c,subUnitId:d,op:l,objects:a,type:p.DrawingApplyType.UPDATE}},{id:x.id,params:[c]}]}),!0):!1}},Ue={id:"sheet.command.ungroup-sheet-image",type:m.CommandType.COMMAND,handler:(i,n)=>{const r=i.get(m.ICommandService),e=i.get(m.IUndoRedoService),t=i.get(p.ISheetDrawingService);if(!n)return!1;const o=[];n.forEach(({parent:g,children:f})=>{o.push(g.unitId),f.forEach(w=>{o.push(w.unitId)})});const s=t.getUngroupDrawingOp(n),{unitId:c,subUnitId:d,undo:h,redo:l,objects:a}=s;return r.syncExecuteCommand(p.SetDrawingApplyMutation.id,{op:l,unitId:c,subUnitId:d,objects:a,type:p.DrawingApplyType.UNGROUP})?(e.pushUndoRedo({unitID:c,undoMutations:[{id:p.SetDrawingApplyMutation.id,params:{op:h,unitId:c,subUnitId:d,objects:yt(a),type:p.DrawingApplyType.GROUP}},{id:x.id,params:o}],redoMutations:[{id:p.SetDrawingApplyMutation.id,params:{op:l,unitId:c,subUnitId:d,objects:a,type:p.DrawingApplyType.UNGROUP}},{id:x.id,params:o}]}),!0):!1}};var Rt=Object.defineProperty,Tt=Object.getOwnPropertyDescriptor,bt=(i,n,r,e)=>{for(var t=e>1?void 0:e?Tt(n,r):n,o=i.length-1,s;o>=0;o--)(s=i[o])&&(t=(e?s(n,r,t):s(t))||t);return e&&t&&Rt(n,r,t),t},K=(i,n)=>(r,e)=>n(r,e,i);let me=class extends m.Disposable{constructor(n,r,e,t,o,s,c,d,h,l,a,u){super();Y(this,"_workbookSelections");this._context=n,this._skeletonManagerService=r,this._commandService=e,this._selectionRenderService=t,this._imageIoService=o,this._fileOpenerService=s,this._sheetDrawingService=c,this._drawingManagerService=d,this._contextService=h,this._messageService=l,this._localeService=a,this._workbookSelections=u.getWorkbookSelections(this._context.unitId),this._updateImageListener(),this._updateOrderListener(),this._groupDrawingListener(),this._focusDrawingListener()}async insertFloatImage(){const n=await this._fileOpenerService.openFile({multiple:!0,accept:O.DRAWING_IMAGE_ALLOW_IMAGE_LIST.map(e=>`.${e.replace("image/","")}`).join(",")}),r=n.length;return r>O.DRAWING_IMAGE_COUNT_LIMIT?(this._messageService.show({type:Z.MessageType.Error,content:this._localeService.t("update-status.exceedMaxCount",String(O.DRAWING_IMAGE_COUNT_LIMIT))}),!1):r===0?!1:(n.forEach(async e=>await this._insertFloatImage(e)),!0)}async _insertFloatImage(n){let r;try{r=await this._imageIoService.saveImage(n)}catch(y){const I=y.message;I===O.ImageUploadStatusType.ERROR_EXCEED_SIZE?this._messageService.show({type:Z.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:Z.MessageType.Error,content:this._localeService.t("update-status.invalidImageType")}):I===O.ImageUploadStatusType.ERROR_IMAGE&&this._messageService.show({type:Z.MessageType.Error,content:this._localeService.t("update-status.invalidImage")})}if(r==null)return;const e=this._getUnitInfo(),{unitId:t,subUnitId:o}=e,{imageId:s,imageSourceType:c,source:d,base64Cache:h}=r,{width:l,height:a,image:u}=await O.getImageSize(h||""),{width:g,height:f}=this._context.scene;this._imageIoService.addImageSourceCache(d,c,u);let w=1;if(l>O.DRAWING_IMAGE_WIDTH_LIMIT||a>O.DRAWING_IMAGE_HEIGHT_LIMIT){const y=O.DRAWING_IMAGE_WIDTH_LIMIT/l,I=O.DRAWING_IMAGE_HEIGHT_LIMIT/a;w=Math.max(y,I)}const S=this._getImagePosition(l*w,a*w,g,f);if(S==null)return;const C={unitId:t,subUnitId:o,drawingId:s,drawingType:O.DrawingTypeEnum.DRAWING_IMAGE,imageSourceType:c,source:d,transform:V(S,this._selectionRenderService,this._skeletonManagerService),sheetTransform:S};this._commandService.executeCommand(oe.id,{unitId:t,drawings:[C]})}_getUnitInfo(){const n=this._context.unit,r=n.getActiveSheet(),e=n.getUnitId(),t=r.getSheetId();return{unitId:e,subUnitId:t}}_getImagePosition(n,r,e,t){const o=this._workbookSelections.getCurrentSelections();let s={startRow:0,endRow:0,startColumn:0,endColumn:0};o&&o.length>0&&(s=o[o.length-1].range);const c=U.attachRangeWithCoord(this._skeletonManagerService.getCurrent().skeleton,s);if(c==null)return;let{startColumn:d,startRow:h,startX:l,startY:a}=c,u=!1;if(l+n>e&&(l=e-n,l<0&&(l=0,n=e),u=!0),a+r>t&&(a=t-r,a<0&&(a=0,r=t),u=!0),u){const S=this._selectionRenderService.getCellWithCoordByOffset(l,a);if(S==null)return;l=S.startX,a=S.startY,d=S.actualColumn,h=S.actualRow}const g={column:d,columnOffset:0,row:h,rowOffset:0},f=this._selectionRenderService.getCellWithCoordByOffset(l+n,a+r);if(f==null)return;const w={column:f.actualColumn,columnOffset:l+n-f.startX,row:f.actualRow,rowOffset:a+r-f.startY};return{from:g,to:w}}_updateOrderListener(){this.disposeWithMe(this._drawingManagerService.featurePluginOrderUpdate$.subscribe(n=>{const{unitId:r,subUnitId:e,drawingIds:t,arrangeType:o}=n;this._commandService.executeCommand(Ae.id,{unitId:r,subUnitId:e,drawingIds:t,arrangeType:o})}))}_updateImageListener(){this.disposeWithMe(this._drawingManagerService.featurePluginUpdate$.subscribe(n=>{const r=[];n.length!==0&&(n.forEach(e=>{const{unitId:t,subUnitId:o,drawingId:s,drawingType:c,transform:d}=e;if(d==null)return;const h=this._sheetDrawingService.getDrawingByParam({unitId:t,subUnitId:o,drawingId:s});if(h==null||h.unitId!==this._context.unitId)return;const l=$({...h.transform,...d},this._selectionRenderService);if(l==null)return;const a={...e,transform:{...h.transform,...d,...V(l,this._selectionRenderService,this._skeletonManagerService)},sheetTransform:{...l}};r.push(a)}),r.length>0&&this._commandService.executeCommand(se.id,{unitId:n[0].unitId,drawings:r}))}))}_groupDrawingListener(){this.disposeWithMe(this._drawingManagerService.featurePluginGroupUpdate$.subscribe(n=>{this._commandService.executeCommand(Pe.id,n);const{unitId:r,subUnitId:e,drawingId:t}=n[0].parent;this._drawingManagerService.focusDrawing([{unitId:r,subUnitId:e,drawingId:t}])})),this.disposeWithMe(this._drawingManagerService.featurePluginUngroupUpdate$.subscribe(n=>{this._commandService.executeCommand(Ue.id,n)}))}_focusDrawingListener(){this.disposeWithMe(this._drawingManagerService.focus$.subscribe(n=>{n==null||n.length===0?(this._contextService.setContextValue(m.FOCUSING_COMMON_DRAWINGS,!1),this._sheetDrawingService.focusDrawing([])):(this._contextService.setContextValue(m.FOCUSING_COMMON_DRAWINGS,!0),this._sheetDrawingService.focusDrawing(n))}))}};me=bt([K(1,m.Inject(U.SheetSkeletonManagerService)),K(2,m.ICommandService),K(3,U.ISheetSelectionRenderService),K(4,O.IImageIoService),K(5,G.ILocalFileService),K(6,p.ISheetDrawingService),K(7,O.IDrawingManagerService),K(8,m.IContextService),K(9,G.IMessageService),K(10,m.Inject(m.LocaleService)),K(11,m.Inject(D.SheetsSelectionsService))],me);const _e={id:"sheet.command.insert-float-image",type:m.CommandType.COMMAND,handler:i=>{var r,e;return(e=(r=i.get(N.IRenderManagerService).getCurrentTypeOfRenderer(m.UniverInstanceType.UNIVER_SHEET))==null?void 0:r.with(me).insertFloatImage())!=null?e:!1}},ne={id:"sheet.command.move-drawing",type:m.CommandType.COMMAND,handler:(i,n)=>{const r=i.get(m.ICommandService),e=i.get(p.ISheetDrawingService),t=i.get(U.ISheetSelectionRenderService),{direction:o}=n,s=e.getFocusDrawings();if(s.length===0)return!1;const c=s[0].unitId,d=s.map(l=>{const{transform:a}=l;if(a==null)return null;const u={...a},{left:g=0,top:f=0}=a;return o===m.Direction.UP?u.top=f-1:o===m.Direction.DOWN?u.top=f+1:o===m.Direction.LEFT?u.left=g-1:o===m.Direction.RIGHT&&(u.left=g+1),{...l,transform:u,sheetTransform:$(u,t)}}).filter(l=>l!=null);return r.syncExecuteCommand(se.id,{unitId:c,drawings:d})?(r.syncExecuteCommand(x.id,[c]),!0):!1}},Ye="addition-and-subtraction-single",Ne="sheet.menu.image";function Ot(i){return{id:Ne,type:G.MenuItemType.SUBITEMS,icon:Ye,tooltip:"sheetImage.title",hidden$:G.getMenuHiddenObservable(i,m.UniverInstanceType.UNIVER_SHEET),disabled$:U.getCurrentRangeDisable$(i,{workbookTypes:[D.WorkbookEditablePermission],worksheetTypes:[D.WorksheetEditPermission],rangeTypes:[D.RangeProtectionPermissionEditPoint]})}}function Et(i){return{id:_e.id,title:"sheetImage.upload.float",type:G.MenuItemType.BUTTON,hidden$:G.getMenuHiddenObservable(i,m.UniverInstanceType.UNIVER_SHEET)}}const Pt="univer-image-common-panel",At="univer-image-common-panel-grid",Ut="univer-image-common-panel-border",Nt="univer-image-common-panel-title",jt="univer-image-common-panel-subtitle",Wt="univer-image-common-panel-row",Lt="univer-image-common-panel-row-vertical",xt="univer-image-common-panel-column",Bt="univer-image-common-panel-column-center",$t="univer-image-common-panel-inline",Gt="univer-image-common-panel-span2",kt="univer-image-common-panel-span3",Vt="univer-image-common-panel-input",Ft="univer-sheet-image-menu",Yt="univer-sheet-image-menu-input",J={imageCommonPanel:Pt,imageCommonPanelGrid:At,imageCommonPanelBorder:Ut,imageCommonPanelTitle:Nt,imageCommonPanelSubtitle:jt,imageCommonPanelRow:Wt,imageCommonPanelRowVertical:Lt,imageCommonPanelColumn:xt,imageCommonPanelColumnCenter:Bt,imageCommonPanelInline:$t,imageCommonPanelSpan2:Gt,imageCommonPanelSpan3:kt,imageCommonPanelInput:Vt,sheetImageMenu:Ft,sheetImageMenuInput:Yt};function He(i){var n,r,e="";if(typeof i=="string"||typeof i=="number")e+=i;else if(typeof i=="object")if(Array.isArray(i)){var t=i.length;for(n=0;n<t;n++)i[n]&&(r=He(i[n]))&&(e&&(e+=" "),e+=r)}else for(r in i)i[r]&&(e&&(e+=" "),e+=r);return e}function le(){for(var i,n,r=0,e="",t=arguments.length;r<t;r++)(i=arguments[r])&&(n=He(i))&&(e&&(e+=" "),e+=n);return e}const Ht=i=>{var I;const n=m.useDependency(m.ICommandService),r=m.useDependency(m.LocaleService),e=m.useDependency(O.IDrawingManagerService),t=m.useDependency(N.IRenderManagerService),{drawings:o}=i,s=o[0];if(s==null)return;const{unitId:c}=s,d=t.getRenderById(c),h=d==null?void 0:d.scene;if(h==null)return;const l=h.getTransformerByCreate(),[a,u]=H.useState(!0),g=(I=s.anchorType)!=null?I:p.SheetDrawingAnchorType.Position,[f,w]=H.useState(g);function S(T,_){const M=[];return T.forEach(v=>{const{oKey:P}=v,b=_.getDrawingOKey(P);if(b==null)return M.push(null),!0;const{unitId:j,subUnitId:A,drawingId:E,drawingType:R,anchorType:W,sheetTransform:B}=b;M.push({unitId:j,subUnitId:A,drawingId:E,anchorType:W,sheetTransform:B,drawingType:R})}),M}H.useEffect(()=>{const T=l.clearControl$.subscribe(M=>{M===!0&&u(!1)}),_=l.changeStart$.subscribe(M=>{var b;const{objects:v}=M,P=S(v,e);if(P.length===0)u(!1);else if(P.length>=1){u(!0);const j=((b=P[0])==null?void 0:b.anchorType)||p.SheetDrawingAnchorType.Position;w(j)}});return()=>{_.unsubscribe(),T.unsubscribe()}},[]);function C(T){w(T);const _=e.getFocusDrawings();if(_.length===0)return;const M=_.map(v=>({unitId:v.unitId,subUnitId:v.subUnitId,drawingId:v.drawingId,anchorType:T}));n.executeCommand(se.id,{unitId:_[0].unitId,drawings:M})}const y=T=>T?"block":"none";return k.jsxs("div",{className:le(J.imageCommonPanelGrid,J.imageCommonPanelBorder),style:{display:y(a)},children:[k.jsx("div",{className:J.imageCommonPanelRow,children:k.jsx("div",{className:le(J.imageCommonPanelColumn,J.imageCommonPanelTitle),children:k.jsx("div",{children:r.t("drawing-anchor.title")})})}),k.jsx("div",{className:le(J.imageCommonPanelRow),children:k.jsx("div",{className:le(J.imageCommonPanelColumn),children:k.jsxs(Z.RadioGroup,{value:f,onChange:C,direction:"vertical",children:[k.jsx(Z.Radio,{value:p.SheetDrawingAnchorType.Both,children:r.t("drawing-anchor.both")}),k.jsx(Z.Radio,{value:p.SheetDrawingAnchorType.Position,children:r.t("drawing-anchor.position")}),k.jsx(Z.Radio,{value:p.SheetDrawingAnchorType.None,children:r.t("drawing-anchor.none")})]})})})]})},Xt=()=>{const i=m.useDependency(O.IDrawingManagerService),n=i.getFocusDrawings(),[r,e]=H.useState(n);return H.useEffect(()=>{const t=i.focus$.subscribe(o=>{e(o)});return()=>{t.unsubscribe()}},[]),!!(r!=null&&r.length)&&k.jsxs("div",{className:J.imageCommonPanel,children:[k.jsx(te.DrawingCommonPanel,{drawings:r}),k.jsx(Ht,{drawings:r})]})},Kt={[G.RibbonStartGroup.FORMULAS_INSERT]:{[Ne]:{order:3,menuItemFactory:Ot,[_e.id]:{order:0,menuItemFactory:Et}}}};function ae(i){return!i.getContextValue(m.FOCUSING_FX_BAR_EDITOR)&&!i.getContextValue(m.EDITOR_ACTIVATED)&&!i.getContextValue(m.FOCUSING_PANEL_EDITOR)&&i.getContextValue(m.FOCUSING_COMMON_DRAWINGS)}const zt={id:ne.id,description:"shortcut.sheet.drawing-move-down",group:"4_sheet-drawing-view",binding:G.KeyCode.ARROW_DOWN,priority:100,preconditions:ae,staticParameters:{direction:m.Direction.DOWN}},qt={id:ne.id,description:"shortcut.sheet.drawing-move-up",group:"4_sheet-drawing-view",binding:G.KeyCode.ARROW_UP,priority:100,preconditions:ae,staticParameters:{direction:m.Direction.UP}},Jt={id:ne.id,description:"shortcut.sheet.drawing-move-left",group:"4_sheet-drawing-view",binding:G.KeyCode.ARROW_LEFT,priority:100,preconditions:ae,staticParameters:{direction:m.Direction.LEFT}},Zt={id:ne.id,description:"shortcut.sheet.drawing-move-right",group:"4_sheet-drawing-view",binding:G.KeyCode.ARROW_RIGHT,priority:100,preconditions:ae,staticParameters:{direction:m.Direction.RIGHT}},Qt={id:Ee.id,description:"shortcut.sheet.drawing-delete",group:"4_sheet-drawing-view",preconditions:ae,binding:G.KeyCode.DELETE,mac:G.KeyCode.BACKSPACE};var en=Object.defineProperty,tn=Object.getOwnPropertyDescriptor,nn=(i,n,r,e)=>{for(var t=e>1?void 0:e?tn(n,r):n,o=i.length-1,s;o>=0;o--)(s=i[o])&&(t=(e?s(n,r,t):s(t))||t);return e&&t&&en(n,r,t),t},ue=(i,n)=>(r,e)=>n(r,e,i);let pe=class extends m.Disposable{constructor(i,n,r,e){super(),this._componentManager=i,this._menuManagerService=n,this._commandService=r,this._shortcutService=e,this._init()}_initCustomComponents(){const i=this._componentManager;this.disposeWithMe(i.register(Ye,Fe)),this.disposeWithMe(i.register(Be,Xt))}_initMenus(){this._menuManagerService.mergeMenu(Kt)}_initCommands(){[_e,oe,ie,se,be,x,Oe,Pe,Ue,ne,Ee,Ae].forEach(i=>this.disposeWithMe(this._commandService.registerCommand(i)))}_initShortcuts(){[zt,qt,Jt,Zt,Qt].forEach(i=>{this.disposeWithMe(this._shortcutService.registerShortcut(i))})}_init(){this._initCommands(),this._initCustomComponents(),this._initMenus(),this._initShortcuts()}};pe=nn([ue(0,m.Inject(G.ComponentManager)),ue(1,G.IMenuManagerService),ue(2,m.ICommandService),ue(3,G.IShortcutService)],pe);var rn=Object.defineProperty,on=Object.getOwnPropertyDescriptor,sn=(i,n,r,e)=>{for(var t=e>1?void 0:e?on(n,r):n,o=i.length-1,s;o>=0;o--)(s=i[o])&&(t=(e?s(n,r,t):s(t))||t);return e&&t&&rn(n,r,t),t},Ce=(i,n)=>(r,e)=>n(r,e,i);let fe=class extends m.Disposable{constructor(n,r,e){super();Y(this,"_copyInfo");this._sheetClipboardService=n,this._renderManagerService=r,this._sheetDrawingService=e,this._initCopyPaste()}_initCopyPaste(){this._sheetClipboardService.addClipboardHook({id:"SHEET_IMAGE_UI_PLUGIN",onBeforeCopy:(n,r,e)=>this._collect(n,r,e),onPasteCells:(n,r,e,t)=>{const{copyType:o=U.COPY_TYPE.COPY,pasteType:s}=t,{range:c}=n||{},{range:d,unitId:h,subUnitId:l}=r;return this._generateMutations(d,{copyType:o,pasteType:s,copyRange:c,unitId:h,subUnitId:l})},onPastePlainText:(n,r)=>({undos:[],redos:[]})})}_collect(n,r,e){var u;const t=(u=this._renderManagerService.getRenderById(n))==null?void 0:u.with(U.SheetSkeletonManagerService);if(!t)return;const o=t.attachRangeWithCoord(e);if(!o)return;const{startX:s,endX:c,startY:d,endY:h}=o,l=this._sheetDrawingService.getDrawingData(n,r),a=[];Object.keys(l).forEach(g=>{const f=l[g],{transform:w}=f;if(f.anchorType!==p.SheetDrawingAnchorType.Both||!w)return;const{left:S=0,top:C=0,width:y=0,height:I=0}=w,{drawingStartX:T,drawingEndX:_,drawingStartY:M,drawingEndY:v}={drawingStartX:S,drawingEndX:S+y,drawingStartY:C,drawingEndY:C+I};s<=T&&_<=c&&d<=M&&v<=h&&a.push(f)}),a.length&&(this._copyInfo={drawings:a,unitId:n,subUnitId:r})}_generateMutations(n,r){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(r.pasteType))return{redos:[],undos:[]};const{copyRange:e}=r;if(!e)return{redos:[],undos:[]};const{drawings:t,unitId:o,subUnitId:s}=this._copyInfo,{ranges:[c,d],mapFunc:h}=U.virtualizeDiscreteRanges([e,n]),{row:l,col:a}=h(c.startRow,c.startColumn),{row:u,col:g}=h(d.startRow,d.startColumn),f=(b=this._renderManagerService.getRenderById(o))==null?void 0:b.with(U.SheetSkeletonManagerService);if(!f)return{redos:[],undos:[]};const w=f.attachRangeWithCoord({startRow:l,endRow:l,startColumn:a,endColumn:a}),S=f.attachRangeWithCoord({startRow:u,endRow:u,startColumn:g,endColumn:g});if(!w||!S)return{redos:[],undos:[]};const C=[],y=[],I=S.startX-w.startX,T=S.startY-w.startY,_=u-l,M=g-a,v=r.copyType===U.COPY_TYPE.CUT,{_sheetDrawingService:P}=this;return t.forEach(j=>{const{transform:A,sheetTransform:E}=j;if(!A)return;const R={...j,unitId:o,subUnitId:s,drawingId:v?j.drawingId:m.Tools.generateRandomId(),transform:{...A,left:A.left+I,top:A.top+T},sheetTransform:{to:{...E.to,row:E.to.row+_,column:E.to.column+M},from:{...E.from,row:E.from.row+_,column:E.from.column+M}}};if(v){const{undo:W,redo:B,objects:z}=P.getBatchUpdateOp([R]);C.push({id:p.SetDrawingApplyMutation.id,params:{unitId:o,subUnitId:s,type:p.DrawingApplyType.UPDATE,op:B,objects:z}}),y.push({id:p.SetDrawingApplyMutation.id,params:{unitId:o,subUnitId:s,type:p.DrawingApplyType.UPDATE,op:W,objects:z}})}else{const{undo:W,redo:B,objects:z}=P.getBatchAddOp([R]);C.push({id:p.SetDrawingApplyMutation.id,params:{op:B,unitId:o,subUnitId:s,objects:z,type:p.DrawingApplyType.INSERT}}),y.push({id:p.SetDrawingApplyMutation.id,params:{op:W,unitId:o,subUnitId:s,objects:z,type:p.DrawingApplyType.REMOVE}})}}),{redos:C,undos:y}}};fe=sn([Ce(0,U.ISheetClipboardService),Ce(1,N.IRenderManagerService),Ce(2,p.ISheetDrawingService)],fe);var an=Object.defineProperty,cn=Object.getOwnPropertyDescriptor,dn=(i,n,r,e)=>{for(var t=e>1?void 0:e?cn(n,r):n,o=i.length-1,s;o>=0;o--)(s=i[o])&&(t=(e?s(n,r,t):s(t))||t);return e&&t&&an(n,r,t),t},re=(i,n)=>(r,e)=>n(r,e,i);let we=class extends m.Disposable{constructor(i,n,r,e,t){super(),this._drawingManagerService=i,this._renderManagerService=n,this._permissionService=r,this._univerInstanceService=e,this._userManagerService=t,this._initDrawingVisible(),this._initDrawingEditable(),this._initViewPermissionChange(),this._initEditPermissionChange()}_initDrawingVisible(){const i=this._univerInstanceService.getCurrentTypeOfUnit$(m.UniverInstanceType.UNIVER_SHEET);this.disposeWithMe(L.combineLatest([i,this._userManagerService.currentUser$]).subscribe(([n,r])=>{if(!n){this._drawingManagerService.setDrawingVisible(!1);return}n.activeSheet$.subscribe(e=>{if(!e){this._drawingManagerService.setDrawingVisible(!1);return}const t=n.getUnitId(),o=e.getSheetId();if(this._permissionService.composePermission([new D.WorkbookViewPermission(t).id,new D.WorksheetViewPermission(t,o).id]).every(c=>c.value))this._drawingManagerService.setDrawingVisible(!0);else{this._drawingManagerService.setDrawingVisible(!1);const c=n.getUnitId(),d=e.getSheetId(),h=this._drawingManagerService.getDrawingData(c,d),l=Object.values(h),a=this._renderManagerService.getRenderById(c),u=a==null?void 0:a.scene;if(u==null)return;u.getAllObjectsByOrder().forEach(f=>{f.classType===N.RENDER_CLASS_TYPE.IMAGE&&l.some(w=>f.oKey.includes(w.drawingId))&&u.removeObject(f)})}})}))}_initDrawingEditable(){const i=this._univerInstanceService.getCurrentTypeOfUnit$(m.UniverInstanceType.UNIVER_SHEET);this.disposeWithMe(L.combineLatest([i,this._userManagerService.currentUser$]).subscribe(([n,r])=>{if(!n){this._drawingManagerService.setDrawingEditable(!1);return}n.activeSheet$.subscribe(e=>{if(!e){this._drawingManagerService.setDrawingEditable(!1);return}const t=n.getUnitId(),o=e.getSheetId();if(this._permissionService.composePermission([new D.WorkbookEditablePermission(t).id,new D.WorksheetEditPermission(t,o).id]).every(c=>c.value))this._drawingManagerService.setDrawingEditable(!0);else{this._drawingManagerService.setDrawingEditable(!1);const c=n.getUnitId(),d=e.getSheetId(),h=this._drawingManagerService.getDrawingData(c,d),l=Object.values(h),a=this._renderManagerService.getRenderById(c),u=a==null?void 0:a.scene;if(u==null)return;u.getAllObjectsByOrder().forEach(f=>{f.classType===N.RENDER_CLASS_TYPE.IMAGE&&l.some(w=>f.oKey.includes(w.drawingId))&&u.detachTransformerFrom(f)})}})}))}_initViewPermissionChange(){const i=this._univerInstanceService.getCurrentTypeOfUnit$(m.UniverInstanceType.UNIVER_SHEET);this.disposeWithMe(L.combineLatest([i,this._userManagerService.currentUser$]).subscribe(([n,r])=>{n&&n.activeSheet$.subscribe(e=>{var a;if(!e)return;const t=n.getUnitId(),o=e.getSheetId();let s=!0;const c=this._renderManagerService.getRenderById(t),d=c==null?void 0:c.scene;if(d==null)return;const h=d.getTransformerByCreate(),l=this._permissionService.composePermission$([new D.WorkbookViewPermission(t).id,new D.WorksheetViewPermission(t,o).id]).pipe(L.map(u=>u.every(g=>g.value)));l==null||l.pipe(L.filter(u=>u!==s),L.distinctUntilChanged()).subscribe({next:u=>{s=u,this._drawingManagerService.setDrawingVisible(u);const g=d.getAllObjectsByOrder(),f=this._drawingManagerService.getDrawingData(t,o),w=Object.values(f);u?this._drawingManagerService.addNotification(w):(g.forEach(S=>{S.classType===N.RENDER_CLASS_TYPE.IMAGE&&w.some(C=>S.oKey.includes(C.drawingId))&&d.removeObject(S)}),h.clearSelectedObjects())}}),(a=this._permissionService.getPermissionPoint$(new D.WorksheetViewPermission(t,o).id))==null||a.pipe(L.filter(u=>u.value!==s),L.distinctUntilChanged()).subscribe({complete:()=>{s=!0,this._drawingManagerService.setDrawingVisible(!0);const u=this._drawingManagerService.getDrawingData(t,o),g=Object.values(u);this._drawingManagerService.addNotification(g)}})})}))}_initEditPermissionChange(){const i=this._univerInstanceService.getCurrentTypeOfUnit$(m.UniverInstanceType.UNIVER_SHEET);this.disposeWithMe(L.combineLatest([i,this._userManagerService.currentUser$]).subscribe(([n,r])=>{n&&n.activeSheet$.subscribe(e=>{var a;if(!e)return;const t=n.getUnitId(),o=e.getSheetId();let s=!0;const c=this._renderManagerService.getRenderById(t),d=c==null?void 0:c.scene;if(d==null)return;const h=d.getTransformerByCreate(),l=this._permissionService.composePermission$([new D.WorkbookEditablePermission(t).id,new D.WorksheetEditPermission(t,o).id]).pipe(L.map(u=>u.every(g=>g.value)));l==null||l.pipe(L.filter(u=>u!==s),L.distinctUntilChanged()).subscribe({next:u=>{s=u,this._drawingManagerService.setDrawingEditable(u);const g=d.getAllObjectsByOrder(),f=this._drawingManagerService.getDrawingData(t,o),w=Object.values(f);u?(g.forEach(S=>{S.classType===N.RENDER_CLASS_TYPE.IMAGE&&w.some(C=>S.oKey.includes(C.drawingId))&&d.attachTransformerTo(S)}),this._drawingManagerService.addNotification(w)):(g.forEach(S=>{S.classType===N.RENDER_CLASS_TYPE.IMAGE&&w.some(C=>S.oKey.includes(C.drawingId))&&d.detachTransformerFrom(S)}),h.clearSelectedObjects())}}),(a=this._permissionService.getPermissionPoint$(new D.WorksheetEditPermission(t,o).id))==null||a.pipe(L.filter(u=>u.value!==s),L.distinctUntilChanged()).subscribe({complete:()=>{s=!0;const u=n.getUnitId(),g=e.getSheetId(),f=this._drawingManagerService.getDrawingData(u,g),w=Object.values(f),S=this._renderManagerService.getRenderById(u),C=S==null?void 0:S.scene;if(C==null)return;this._drawingManagerService.setDrawingEditable(!0),C.getAllObjectsByOrder().forEach(I=>{I.classType===N.RENDER_CLASS_TYPE.IMAGE&&w.some(T=>I.oKey.includes(T.drawingId))&&C.detachTransformerFrom(I)})}})})}))}};we=dn([re(0,O.IDrawingManagerService),re(1,N.IRenderManagerService),re(2,m.IPermissionService),re(3,m.IUniverInstanceService),re(4,m.Inject(m.UserManagerService))],we);var ln=Object.defineProperty,un=Object.getOwnPropertyDescriptor,gn=(i,n,r,e)=>{for(var t=e>1?void 0:e?un(n,r):n,o=i.length-1,s;o>=0;o--)(s=i[o])&&(t=(e?s(n,r,t):s(t))||t);return e&&t&&ln(n,r,t),t},ge=(i,n)=>(r,e)=>n(r,e,i);let Se=class extends m.Disposable{constructor(i,n,r,e){super(),this._sheetPrintInterceptorService=i,this._drawingRenderService=n,this._drawingManagerService=r,this._renderManagerService=e,this._initPrinting()}_initPrinting(){this.disposeWithMe(this._sheetPrintInterceptorService.interceptor.intercept(this._sheetPrintInterceptorService.interceptor.getInterceptPoints().PRINTING_COMPONENT_COLLECT,{handler:(i,n,r)=>{const{unitId:e,scene:t,subUnitId:o}=n,s=this._drawingManagerService.getDrawingDataForUnit(e),c=s==null?void 0:s[o];return c&&c.order.forEach(d=>{this._drawingRenderService.renderDrawing(c.data[d],t)}),r()}})),this.disposeWithMe(this._sheetPrintInterceptorService.interceptor.intercept(this._sheetPrintInterceptorService.interceptor.getInterceptPoints().PRINTING_RANGE,{handler:(i,n,r)=>{const{unitId:e,subUnitId:t}=n,o=this._renderManagerService.getRenderById(e);if(!o)return r(i);const s=o.with(U.SheetSkeletonManagerService).getWorksheetSkeleton(t);if(!s)return r(i);const c=this._drawingManagerService.getDrawingDataForUnit(e),d=c==null?void 0:c[n.subUnitId];if(!d)return r(i);const{scaleX:h,scaleY:l}=o.scene,a=i?{...i}:{startColumn:0,endColumn:0,endRow:0,startRow:0},u=d.order.map(g=>d.data[g]).filter(g=>g.drawingType!==O.DrawingTypeEnum.DRAWING_DOM);return u.length?(u.forEach(g=>{if(!g.groupId&&g.transform&&m.Tools.isDefine(g.transform.left)&&m.Tools.isDefine(g.transform.top)&&m.Tools.isDefine(g.transform.width)&&m.Tools.isDefine(g.transform.height)){const f=s.skeleton.getCellIndexByOffset(g.transform.left,g.transform.top,h,l,{x:0,y:0}),w=s.skeleton.getCellIndexByOffset(g.transform.left+g.transform.width,g.transform.top+g.transform.height,h,l,{x:0,y:0});f.column<a.startColumn&&(a.startColumn=f.column),f.row<a.startRow&&(a.startRow=f.row),a.endRow<w.row&&(a.endRow=w.row),a.endColumn<w.column&&(a.endColumn=w.column)}}),r(a)):r(i)}}))}};Se=gn([ge(0,m.Inject(U.SheetPrintInterceptorService)),ge(1,m.Inject(te.DrawingRenderService)),ge(2,O.IDrawingManagerService),ge(3,N.IRenderManagerService)],Se);var hn=Object.defineProperty,mn=Object.getOwnPropertyDescriptor,pn=(i,n,r,e)=>{for(var t=e>1?void 0:e?mn(n,r):n,o=i.length-1,s;o>=0;o--)(s=i[o])&&(t=(e?s(n,r,t):s(t))||t);return e&&t&&hn(n,r,t),t},q=(i,n)=>(r,e)=>n(r,e,i);const fn=[D.InsertRowCommand.id,D.InsertColCommand.id,D.RemoveRowCommand.id,D.RemoveColCommand.id,D.DeleteRangeMoveLeftCommand.id,D.DeleteRangeMoveUpCommand.id,D.InsertRangeMoveDownCommand.id,D.InsertRangeMoveRightCommand.id,D.DeltaRowHeightCommand.id,D.SetRowHeightCommand.id,D.DeltaColumnWidthCommand.id,D.SetColWidthCommand.id,D.SetRowHiddenCommand.id,D.SetSpecificRowsVisibleCommand.id,D.SetSpecificColsVisibleCommand.id,D.SetColHiddenCommand.id,D.MoveColsCommand.id,D.MoveRowsCommand.id,D.MoveRangeCommand.id],wn=[D.SetRowVisibleMutation.id,D.SetRowHiddenMutation.id,D.SetColVisibleMutation.id,D.SetColHiddenMutation.id,D.SetWorksheetRowHeightMutation.id,D.SetWorksheetColWidthMutation.id];let Te=class extends m.Disposable{constructor(i,n,r,e,t,o,s,c,d){super(),this._context=i,this._renderManagerService=n,this._commandService=r,this._selectionRenderService=e,this._skeletonManagerService=t,this._sheetInterceptorService=o,this._sheetDrawingService=s,this._drawingManagerService=c,this._univerInstanceService=d,this._sheetInterceptorListener(),this._commandListener(),this._sheetRefreshListener()}_sheetInterceptorListener(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:i=>{if(!fn.includes(i.id))return{redos:[],undos:[]};if(i.params==null)return{redos:[],undos:[]};const n=i.id;if(n===D.InsertRowCommand.id)return this._moveRowInterceptor(i.params,"insert");if([D.MoveColsCommand.id,D.MoveRowsCommand.id,D.MoveRangeCommand.id].includes(n))return this._moveRangeInterceptor(i.params);if(n===D.InsertColCommand.id)return this._moveColInterceptor(i.params,"insert");if(n===D.RemoveRowCommand.id)return this._moveRowInterceptor(i.params,"remove");if(n===D.RemoveColCommand.id)return this._moveColInterceptor(i.params,"remove");if(n===D.DeleteRangeMoveLeftCommand.id){const{range:r}=i.params;return this._getRangeMoveUndo(r,0)}else if(n===D.DeleteRangeMoveUpCommand.id){const{range:r}=i.params;return this._getRangeMoveUndo(r,1)}else if(n===D.InsertRangeMoveDownCommand.id){const{range:r}=i.params;return this._getRangeMoveUndo(r,2)}else if(n===D.InsertRangeMoveRightCommand.id){const{range:r}=i.params;return this._getRangeMoveUndo(r,3)}else if(n===D.SetRowHiddenCommand.id||n===D.SetSpecificRowsVisibleCommand.id){const r=i.params,{unitId:e,subUnitId:t,ranges:o}=r;return this._getDrawingUndoForRowVisible(e,t,o)}else if(n===D.SetSpecificColsVisibleCommand.id||n===D.SetColHiddenCommand.id){const r=i.params,{unitId:e,subUnitId:t,ranges:o}=r;return this._getDrawingUndoForColVisible(e,t,o)}else if(n===D.DeltaRowHeightCommand.id||n===D.SetRowHeightCommand.id||n===D.DeltaColumnWidthCommand.id||n===D.SetColWidthCommand.id){const r=i.params,{unitId:e,subUnitId:t,ranges:o}=r,s=n===D.DeltaRowHeightCommand.id||n===D.SetRowHeightCommand.id;return this._getDrawingUndoForRowAndColSize(e,t,o,s)}return{redos:[],undos:[]}}}))}_getRangeMoveUndo(i,n){const r=D.getSheetCommandTarget(this._univerInstanceService);if(r==null)return{redos:[],undos:[]};const e=r.unitId,t=r.subUnitId,o=[],s=[],c=this._sheetDrawingService.getDrawingData(e,t),d=[],h=[];if(Object.keys(c).forEach(l=>{const a=c[l],{updateDrawings:u,deleteDrawings:g}=this._getUpdateOrDeleteDrawings(i,n,a);d.push(...u),h.push(...g)}),d.length===0&&h.length===0)return{redos:[],undos:[]};if(d.length>0){const l=this._sheetDrawingService.getBatchUpdateOp(d),{undo:a,redo:u,objects:g}=l;o.push({id:p.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:u,objects:g,type:p.DrawingApplyType.UPDATE}}),s.push({id:p.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:a,objects:g,type:p.DrawingApplyType.UPDATE}})}if(h.length>0){const l=this._sheetDrawingService.getBatchRemoveOp(h),a=l.undo,u=l.redo,g=l.objects;o.push({id:p.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:u,objects:g,type:p.DrawingApplyType.REMOVE}}),s.push({id:p.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:a,objects:g,type:p.DrawingApplyType.INSERT}})}return o.push({id:x.id,params:[e]}),s.push({id:x.id,params:[e]}),{redos:o,undos:s}}_getUpdateOrDeleteDrawings(i,n,r){const e=[],t=[],{sheetTransform:o,anchorType:s=p.SheetDrawingAnchorType.Position,transform:c,unitId:d,subUnitId:h,drawingId:l}=r,{from:a,to:u}=o,{row:g,column:f}=a,{row:w,column:S}=u;if(o==null||c==null)return{updateDrawings:e,deleteDrawings:t};const{startRow:C,endRow:y,startColumn:I,endColumn:T}=i;let _=null,M=null;if(n===0&&g>=C&&w<=y)if(f>=I&&S<=T)t.push({unitId:d,subUnitId:h,drawingId:l});else{const v=this._shrinkCol(o,c,I,T,s);_=v==null?void 0:v.newSheetTransform,M=v==null?void 0:v.newTransform}else if(n===1&&f>=I&&S<=T)if(g>=C&&w<=y)t.push({unitId:d,subUnitId:h,drawingId:l});else{const v=this._shrinkRow(o,c,C,y,s);_=v==null?void 0:v.newSheetTransform,M=v==null?void 0:v.newTransform}else if(n===2){const v=this._expandRow(o,c,C,y,s);_=v==null?void 0:v.newSheetTransform,M=v==null?void 0:v.newTransform}else if(n===3){const v=this._expandCol(o,c,I,T,s);_=v==null?void 0:v.newSheetTransform,M=v==null?void 0:v.newTransform}if(_!=null&&M!=null){const v=V(_,this._selectionRenderService,this._skeletonManagerService);e.push({...r,sheetTransform:_,transform:v})}return{updateDrawings:e,deleteDrawings:t}}_remainDrawingSize(i,n,r){const e=$({...i},this._selectionRenderService);e!=null&&n.push({...r,sheetTransform:e})}_getDrawingUndoForColVisible(i,n,r){const e=this._drawingManagerService.getDrawingData(i,n),t=[],o=[];if(Object.keys(e).forEach(l=>{const a=e[l],{sheetTransform:u,transform:g,anchorType:f=p.SheetDrawingAnchorType.Position}=a;if(f===p.SheetDrawingAnchorType.None)this._remainDrawingSize(g,t,a);else{const{from:w,to:S}=u,{row:C,column:y}=w,{row:I,column:T}=S;for(let _=0;_<r.length;_++){const M=r[_],{startRow:v,endRow:P,startColumn:b,endColumn:j}=M;if(T<b)continue;if(f===p.SheetDrawingAnchorType.Position){let R=null,W=null;if(y>=b&&y<=j){const B=this._skeletonManagerService.attachRangeWithCoord({startColumn:y,endColumn:j,startRow:w.row,endRow:S.row});if(B==null)return;W={...g,left:B.startX}}if(W!=null&&(R=$(W,this._selectionRenderService),R!=null&&W!=null)){t.push({...a,sheetTransform:R,transform:W});break}this._remainDrawingSize(g,t,a);continue}if(y>=b&&T<=j)continue;let A=null,E=null;if(y>=b&&y<=j){const R=this._skeletonManagerService.attachRangeWithCoord({startColumn:y,endColumn:j,startRow:w.row,endRow:S.row});if(R==null)return;E={...g,left:(R==null?void 0:R.startX)||0,width:((g==null?void 0:g.width)||0)-R.endX+R.startX}}else if(T>=b&&T<=j){const R=this._skeletonManagerService.attachRangeWithCoord({startColumn:b,endColumn:T,startRow:w.row,endRow:S.row});if(R==null)return;E={...g,left:R.startX-((g==null?void 0:g.width)||0)}}else{const R=this._skeletonManagerService.attachRangeWithCoord({startColumn:b,endColumn:j,startRow:w.row,endRow:S.row});if(R==null)return;if(E={...g,width:((g==null?void 0:g.width)||0)-R.endX+R.startX},A=$(E,this._selectionRenderService),A!=null&&E!=null){o.push({...a,sheetTransform:A,transform:E});break}}if(E!=null&&(A=$(E,this._selectionRenderService)),E!=null&&A!=null){t.push({...a,sheetTransform:A,transform:E});break}else this._remainDrawingSize(g,t,a)}}}),t.length===0&&o.length===0)return{redos:[],undos:[]};const{redos:s,undos:c}=this._createUndoAndRedoMutation(i,n,t),d=[],h=[];if(o.length>0){const{redos:l,undos:a}=this._createUndoAndRedoMutation(i,n,o);d.push(...l),h.push(...a)}return{redos:s,undos:c,preRedos:d,preUndos:h}}_createUndoAndRedoMutation(i,n,r){const e=this._sheetDrawingService.getBatchUpdateOp(r),{undo:t,redo:o,objects:s}=e,c=[{id:p.SetDrawingApplyMutation.id,params:{unitId:i,subUnitId:n,op:o,objects:s,type:p.DrawingApplyType.UPDATE}},{id:x.id,params:[i]}],d=[{id:p.SetDrawingApplyMutation.id,params:{unitId:i,subUnitId:n,op:t,objects:s,type:p.DrawingApplyType.UPDATE}},{id:x.id,params:[i]}];return{redos:c,undos:d}}_getDrawingUndoForRowVisible(i,n,r){const e=this._drawingManagerService.getDrawingData(i,n),t=[],o=[];if(Object.keys(e).forEach(l=>{const a=e[l],{sheetTransform:u,transform:g,anchorType:f=p.SheetDrawingAnchorType.Position}=a;if(f===p.SheetDrawingAnchorType.None)this._remainDrawingSize(g,t,a);else{const{from:w,to:S}=u,{row:C,column:y}=w,{row:I,column:T}=S;for(let _=0;_<r.length;_++){const M=r[_],{startRow:v,endRow:P,startColumn:b,endColumn:j}=M;if(I<v)continue;if(f===p.SheetDrawingAnchorType.Position){let R=null,W=null;if(C>=v&&C<=P){const B=this._skeletonManagerService.attachRangeWithCoord({startColumn:w.column,endColumn:S.column,startRow:C,endRow:P});if(B==null)return;W={...g,top:B.startY}}if(W!=null&&(R=$(W,this._selectionRenderService),R!=null&&W!=null)){t.push({...a,sheetTransform:R,transform:W});break}this._remainDrawingSize(g,t,a);continue}if(C>=v&&I<=P)continue;let A=null,E=null;if(C>=v&&C<=P){const R=this._skeletonManagerService.attachRangeWithCoord({startColumn:w.column,endColumn:S.column,startRow:C,endRow:P});if(R==null)return;E={...g,top:(R==null?void 0:R.startY)||0,height:((g==null?void 0:g.height)||0)-R.endY+R.startY}}else if(I>=v&&I<=P){const R=this._skeletonManagerService.attachRangeWithCoord({startColumn:w.column,endColumn:S.column,startRow:v,endRow:I});if(R==null)return;E={...g,top:R.startY-((g==null?void 0:g.height)||0)}}else{const R=this._skeletonManagerService.attachRangeWithCoord({startColumn:w.column,endColumn:S.column,startRow:v,endRow:P});if(R==null)return;if(E={...g,height:((g==null?void 0:g.height)||0)-R.endY+R.startY},A=$(E,this._selectionRenderService),A!=null&&E!=null){o.push({...a,sheetTransform:A,transform:E});break}}if(E!=null&&(A=$(E,this._selectionRenderService)),E!=null&&A!=null){t.push({...a,sheetTransform:A,transform:E});break}else this._remainDrawingSize(g,t,a)}}}),t.length===0&&o.length===0)return{redos:[],undos:[]};const{redos:s,undos:c}=this._createUndoAndRedoMutation(i,n,t),d=[],h=[];if(o.length>0){const{redos:l,undos:a}=this._createUndoAndRedoMutation(i,n,o);d.push(...l),h.push(...a)}return{redos:s,undos:c,preRedos:d,preUndos:h}}_getDrawingUndoForRowAndColSize(i,n,r,e){const t=this._drawingManagerService.getDrawingData(i,n),o=[];return Object.keys(t).forEach(s=>{const c=t[s],{sheetTransform:d,transform:h,anchorType:l=p.SheetDrawingAnchorType.Position}=c;if(l===p.SheetDrawingAnchorType.None)this._remainDrawingSize(h,o,c);else{const{from:a,to:u}=d,{row:g,column:f}=a,{row:w,column:S}=u;for(let C=0;C<r.length;C++){const y=r[C],{startRow:I,endRow:T,startColumn:_,endColumn:M}=y;if(w<I||S<_)continue;if(l===p.SheetDrawingAnchorType.Position&&(g<=I&&w>=T||f<=_&&S>=M)){this._remainDrawingSize(h,o,c);continue}const v=V({...d},this._selectionRenderService,this._skeletonManagerService);if(v!=null){o.push({...c,transform:v});break}}}}),o.length===0?{redos:[],undos:[]}:this._createUndoAndRedoMutation(i,n,o)}_getUnitIdAndSubUnitId(i,n){let r,e;if(n==="insert")r=i.unitId,e=i.subUnitId;else{const t=D.getSheetCommandTarget(this._univerInstanceService);if(t==null)return;r=t.unitId,e=t.subUnitId}return{unitId:r,subUnitId:e}}_moveRangeInterceptor(i){var I,T;const{toRange:n,fromRange:r}=i,e=D.getSheetCommandTarget(this._univerInstanceService);if(!e)return{redos:[],undos:[]};const{unitId:t,subUnitId:o}=e,s=(T=(I=this._renderManagerService.getRenderById(t))==null?void 0:I.with(U.SheetSkeletonManagerService))==null?void 0:T.getCurrentSkeleton();if(!s)return{redos:[],undos:[]};const c=U.attachRangeWithCoord(s,r);if(!c)return{redos:[],undos:[]};const{startX:d,endX:h,startY:l,endY:a}=c,u=this._sheetDrawingService.getDrawingData(t,o),g=[];Object.keys(u).forEach(_=>{const M=u[_];if(M.anchorType!==p.SheetDrawingAnchorType.Both)return;const{transform:v}=M;if(!v)return;const{left:P=0,top:b=0,width:j=0,height:A=0}=v,{drawingStartX:E,drawingEndX:R,drawingStartY:W,drawingEndY:B}={drawingStartX:P,drawingEndX:P+j,drawingStartY:b,drawingEndY:b+A};d<=E&&R<=h&&l<=W&&B<=a&&g.push(M)});const f=[],w=[],S=n.startRow-r.startRow,C=n.startColumn-r.startColumn,y=g.map(_=>{const M=_.sheetTransform,v={to:{...M.to,row:M.to.row+S,column:M.to.column+C},from:{...M.from,row:M.from.row+S,column:M.from.column+C}},P=V(v,this._selectionRenderService,this._skeletonManagerService);return{unitId:t,subUnitId:o,drawingId:_.drawingId,transform:P,sheetTransform:v}});if(y.length){const _=this._sheetDrawingService.getBatchUpdateOp(y),{undo:M,redo:v,objects:P}=_;f.push({id:p.SetDrawingApplyMutation.id,params:{unitId:t,subUnitId:o,op:v,objects:P,type:p.DrawingApplyType.UPDATE}}),w.push({id:p.SetDrawingApplyMutation.id,params:{unitId:t,subUnitId:o,op:M,objects:P,type:p.DrawingApplyType.UPDATE}})}return{redos:f,undos:w}}_moveRowInterceptor(i,n){const r=this._getUnitIdAndSubUnitId(i,n);if(r==null)return{redos:[],undos:[]};const{unitId:e,subUnitId:t}=r,{range:o}=i,s=o.startRow,c=o.endRow,d=[],h=[],l=this._sheetDrawingService.getDrawingData(e,t),a=[],u=[];if(Object.keys(l).forEach(g=>{const f=l[g],{sheetTransform:w,transform:S,anchorType:C=p.SheetDrawingAnchorType.Position}=f;if(w==null||S==null)return;let y,I;if(n==="insert"){const _=this._expandRow(w,S,s,c,C);y=_==null?void 0:_.newSheetTransform,I=_==null?void 0:_.newTransform}else{const{from:_,to:M}=w,{row:v}=_,{row:P}=M;if(C===p.SheetDrawingAnchorType.Both&&v>=s&&P<=c)u.push({unitId:e,subUnitId:t,drawingId:g});else{const b=this._shrinkRow(w,S,s,c,C);y=b==null?void 0:b.newSheetTransform,I=b==null?void 0:b.newTransform}}if(!y||!I)return;const T={unitId:e,subUnitId:t,drawingId:g,transform:I,sheetTransform:y};a.push(T)}),a.length===0&&u.length===0)return{redos:[],undos:[]};if(a.length>0){const g=this._sheetDrawingService.getBatchUpdateOp(a),{undo:f,redo:w,objects:S}=g;d.push({id:p.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:w,objects:S,type:p.DrawingApplyType.UPDATE}}),h.push({id:p.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:f,objects:S,type:p.DrawingApplyType.UPDATE}})}if(u.length>0){const g=this._sheetDrawingService.getBatchRemoveOp(u),f=g.undo,w=g.redo,S=g.objects;d.push({id:p.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:w,objects:S,type:p.DrawingApplyType.REMOVE}}),h.push({id:p.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:f,objects:S,type:p.DrawingApplyType.INSERT}})}return d.push({id:x.id,params:[e]}),h.push({id:x.id,params:[e]}),{redos:d,undos:h}}_moveColInterceptor(i,n){const r=this._getUnitIdAndSubUnitId(i,n);if(r==null)return{redos:[],undos:[]};const{unitId:e,subUnitId:t}=r,{range:o}=i,s=o.startColumn,c=o.endColumn,d=[],h=[],l=this._sheetDrawingService.getDrawingData(e,t),a=[],u=[];if(Object.keys(l).forEach(g=>{const f=l[g],{sheetTransform:w,transform:S,anchorType:C=p.SheetDrawingAnchorType.Position}=f;if(w==null||S==null)return;let y,I;if(n==="insert"){const _=this._expandCol(w,S,s,c,C);y=_==null?void 0:_.newSheetTransform,I=_==null?void 0:_.newTransform}else{const{from:_,to:M}=w,{column:v}=_,{column:P}=M;if(C===p.SheetDrawingAnchorType.Both&&v>=s&&P<=c)u.push({unitId:e,subUnitId:t,drawingId:g});else{const b=this._shrinkCol(w,S,s,c,C);y=b==null?void 0:b.newSheetTransform,I=b==null?void 0:b.newTransform}}if(!y||!I)return;const T={unitId:e,subUnitId:t,drawingId:g,transform:I,sheetTransform:y};a.push(T)}),a.length===0&&u.length===0)return{redos:[],undos:[]};if(a.length>0){const g=this._sheetDrawingService.getBatchUpdateOp(a),{undo:f,redo:w,objects:S}=g;d.push({id:p.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:w,objects:S,type:p.DrawingApplyType.UPDATE}}),h.push({id:p.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:f,objects:S,type:p.DrawingApplyType.UPDATE}})}if(u.length>0){const g=this._sheetDrawingService.getBatchRemoveOp(u),f=g.undo,w=g.redo,S=g.objects;d.push({id:p.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:w,objects:S,type:p.DrawingApplyType.REMOVE}}),h.push({id:p.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:f,objects:S,type:p.DrawingApplyType.INSERT}})}return d.push({id:x.id,params:[e]}),h.push({id:x.id,params:[e]}),{redos:d,undos:h}}_expandCol(i,n,r,e,t=p.SheetDrawingAnchorType.Position){const o=e-r+1,{from:s,to:c}=i,{column:d}=s,{column:h}=c;if(t===p.SheetDrawingAnchorType.None)return{newSheetTransform:$({...n},this._selectionRenderService),newTransform:n};let l=null,a=null;if(d>=r){const u=this._skeletonManagerService.attachRangeWithCoord({startColumn:r,endColumn:e,startRow:s.row,endRow:c.row});if(u==null)return;a={...n,left:(n.left||0)+u.endX-u.startX},l=$(a,this._selectionRenderService)}else if(h>=e)if(t===p.SheetDrawingAnchorType.Both)l={from:{...s},to:{...c,column:h+o}},a=V(l,this._selectionRenderService,this._skeletonManagerService);else return{newSheetTransform:$({...n},this._selectionRenderService),newTransform:n};return l!=null&&a!=null?{newSheetTransform:l,newTransform:a}:null}_shrinkCol(i,n,r,e,t=p.SheetDrawingAnchorType.Position){const o=e-r+1,{from:s,to:c}=i,{column:d}=s,{column:h}=c;if(t===p.SheetDrawingAnchorType.None)return{newSheetTransform:$({...n},this._selectionRenderService),newTransform:n};let l=null,a=null;if(d>e)l={from:{...s,column:d-o},to:{...c,column:h-o}},a=V(l,this._selectionRenderService,this._skeletonManagerService);else{if(d>=r&&h<=e)return null;if(d<r&&h>e)if(t===p.SheetDrawingAnchorType.Both)l={from:{...s},to:{...c,column:h-o}},a=V(l,this._selectionRenderService,this._skeletonManagerService);else return{newSheetTransform:$({...n},this._selectionRenderService),newTransform:n};else if(d>=r&&d<=e){if(d===r)a={...n,left:(n.left||0)-i.from.columnOffset};else{const u=this._skeletonManagerService.attachRangeWithCoord({startColumn:r,endColumn:d-1,startRow:s.row,endRow:c.row});if(u==null)return;a={...n,left:(n.left||0)-u.endX+u.startX-i.from.columnOffset}}l=$(a,this._selectionRenderService)}else if(h>=r&&h<=e&&t===p.SheetDrawingAnchorType.Both){const u=this._skeletonManagerService.attachRangeWithCoord({startColumn:r-1,endColumn:r-1,startRow:s.row,endRow:c.row});if(u==null)return;l={from:{...s},to:{...c,column:r-1,columnOffset:u.endX-u.startX}},a=V(l,this._selectionRenderService,this._skeletonManagerService)}}return l!=null&&a!=null?{newSheetTransform:l,newTransform:a}:null}_expandRow(i,n,r,e,t=p.SheetDrawingAnchorType.Position){const o=e-r+1,{from:s,to:c}=i,{row:d}=s,{row:h}=c;if(t===p.SheetDrawingAnchorType.None)return{newSheetTransform:$({...n},this._selectionRenderService),newTransform:n};let l=null,a=null;if(d>=r){const u=this._skeletonManagerService.attachRangeWithCoord({startRow:r,endRow:e,startColumn:s.column,endColumn:c.column});if(u==null)return;a={...n,top:(n.top||0)+u.endY-u.startY},l=$(a,this._selectionRenderService)}else if(h>=e)if(t===p.SheetDrawingAnchorType.Both)l={from:{...s},to:{...c,row:h+o}},a=V(l,this._selectionRenderService,this._skeletonManagerService);else return{newSheetTransform:$({...n},this._selectionRenderService),newTransform:n};return l!=null&&a!=null?{newSheetTransform:l,newTransform:a}:null}_shrinkRow(i,n,r,e,t=p.SheetDrawingAnchorType.Position){const o=e-r+1,{from:s,to:c}=i,{row:d}=s,{row:h}=c;if(t===p.SheetDrawingAnchorType.None)return{newSheetTransform:$({...n},this._selectionRenderService),newTransform:n};let l=null,a=null;if(d>e)l={from:{...s,row:d-o},to:{...c,row:h-o}},a=V(l,this._selectionRenderService,this._skeletonManagerService);else{if(d>=r&&h<=e)return null;if(d<r&&h>e)if(t===p.SheetDrawingAnchorType.Both)l={from:{...s},to:{...c,row:h-o}},a=V(l,this._selectionRenderService,this._skeletonManagerService);else return{newSheetTransform:$({...n},this._selectionRenderService),newTransform:n};else if(d>=r&&d<=e){if(d===r)a={...n,top:(n.top||0)-i.from.rowOffset};else{const u=this._skeletonManagerService.attachRangeWithCoord({startRow:r,endRow:d-1,startColumn:s.column,endColumn:c.column});if(u==null)return;a={...n,top:(n.top||0)-u.endY+u.startY-i.from.rowOffset}}l=$(a,this._selectionRenderService)}else if(h>=r&&h<=e&&t===p.SheetDrawingAnchorType.Both){const u=this._skeletonManagerService.attachRangeWithCoord({startColumn:s.column,endColumn:s.column,startRow:r-1,endRow:r-1});if(u==null)return;l={from:{...s},to:{...c,row:r-1,rowOffset:u.endY-u.startY}},a=V(l,this._selectionRenderService,this._skeletonManagerService)}}return l!=null&&a!=null?{newSheetTransform:l,newTransform:a}:null}_commandListener(){this.disposeWithMe(this._commandService.onCommandExecuted(i=>{i.id===D.SetWorksheetActiveOperation.id&&setTimeout(()=>{const n=i.params,{unitId:r,subUnitId:e}=n,t=this._drawingManagerService.drawingManagerData,o=[],s=[];Object.keys(t).forEach(c=>{const d=t[c];d!=null&&Object.keys(d).forEach(h=>{const l=d[h].data;l!=null&&Object.keys(l).forEach(a=>{if(c===r&&h===e){const u=l[a];u.transform=V(u.sheetTransform,this._selectionRenderService,this._skeletonManagerService),o.push(l[a])}else s.push(l[a])})})}),this._drawingManagerService.removeNotification(s),this._drawingManagerService.addNotification(o)},0)}))}_sheetRefreshListener(){this.disposeWithMe(this._commandService.onCommandExecuted(i=>{wn.includes(i.id)&&requestIdleCallback(()=>{const n=i.params,{unitId:r,subUnitId:e,ranges:t}=n;this._refreshDrawingTransform(r,e,t)})}))}_refreshDrawingTransform(i,n,r){const e=this._drawingManagerService.getDrawingData(i,n),t=[];Object.keys(e).forEach(o=>{const s=e[o],{sheetTransform:c,transform:d,anchorType:h=p.SheetDrawingAnchorType.Position}=s;if(h===p.SheetDrawingAnchorType.None)return!0;const{from:l,to:a}=c,{row:u,column:g}=l,{row:f,column:w}=a;for(let S=0;S<r.length;S++){const C=r[S],{startRow:y,endRow:I,startColumn:T,endColumn:_}=C;if(m.Rectangle.intersects({startRow:y,endRow:I,startColumn:T,endColumn:_},{startRow:u,endRow:f,startColumn:g,endColumn:w})||u>I||g>_){const M=h===p.SheetDrawingAnchorType.Position,v=V(c,this._selectionRenderService,this._skeletonManagerService);t.push({...s,transform:{...v,width:M?d==null?void 0:d.width:v==null?void 0:v.width,height:M?d==null?void 0:d.height:v==null?void 0:v.height}});break}}}),t.length!==0&&(this._drawingManagerService.refreshTransform(t),this._commandService.syncExecuteCommand(x.id,[i]))}};Te=pn([q(1,N.IRenderManagerService),q(2,m.ICommandService),q(3,U.ISheetSelectionRenderService),q(4,m.Inject(U.SheetSkeletonManagerService)),q(5,m.Inject(D.SheetInterceptorService)),q(6,p.ISheetDrawingService),q(7,O.IDrawingManagerService),q(8,m.IUniverInstanceService)],Te);var Sn=Object.defineProperty,vn=Object.getOwnPropertyDescriptor,_n=(i,n,r,e)=>{for(var t=e>1?void 0:e?vn(n,r):n,o=i.length-1,s;o>=0;o--)(s=i[o])&&(t=(e?s(n,r,t):s(t))||t);return e&&t&&Sn(n,r,t),t},ee=(i,n)=>(r,e)=>n(r,e,i);function Dn(i,n,r,e){const{scaleX:t,scaleY:o}=n.getAncestorScale(),s=n.getViewport(N.SHEET_VIEWPORT_KEY.VIEW_MAIN),c={left:!0,top:!0};if(!s)return{...i,absolute:c};const{left:d,right:h,top:l,bottom:a}=i,u=e.getFreeze(),{startColumn:g,startRow:f,xSplit:w,ySplit:S}=u,C=r.getNoMergeCellPositionByIndexWithNoHeader(f-S,g-w),y=r.getNoMergeCellPositionByIndexWithNoHeader(f,g),{rowHeaderWidth:I,columnHeaderHeight:T}=r,_=y.startX-C.startX,M=y.startY-C.startY,{top:v,left:P,viewportScrollX:b,viewportScrollY:j}=s;let A,E;d<P?(c.left=!0,A=(_+I+(d-P))*t,E=Math.max(Math.min((_+I+(h-P))*t,(_+I)*t),(h-b)*t)):(c.left=!1,A=Math.max((d-b)*t,(_+I)*t),E=Math.max((h-b)*t,(_+I)*t));let R,W;return l<v?(c.top=!0,R=(M+T+(l-v))*o,W=Math.max(Math.min((M+T+(h-v))*o,(M+T)*o),(a-j)*o)):(c.top=!1,R=Math.max((l-j)*o,(M+T)*o),W=Math.max((a-j)*o,(M+T)*o)),{left:A,right:E,top:R,bottom:W,absolute:c}}const ye=(i,n,r,e)=>{const{scene:t}=n,{left:o,top:s,width:c,height:d,angle:h}=i,l={left:o,right:o+c,top:s,bottom:s+d},a=Dn(l,t,r,e),{scaleX:u,scaleY:g}=t.getAncestorScale();return{startX:a.left,endX:a.right,startY:a.top,endY:a.bottom,rotate:h,width:c*u,height:d*g,absolute:a.absolute}};exports.SheetCanvasFloatDomManagerService=class extends m.Disposable{constructor(r,e,t,o,s,c,d){super();Y(this,"_domLayerMap",new Map);Y(this,"_domLayerInfoMap",new Map);Y(this,"_transformChange$",new L.Subject);Y(this,"transformChange$",this._transformChange$.asObservable());Y(this,"_add$",new L.Subject);Y(this,"add$",this._add$.asObservable());Y(this,"_remove$",new L.Subject);Y(this,"remove$",this._remove$.asObservable());Y(this,"_hooks",[]);this._renderManagerService=r,this._univerInstanceService=e,this._commandService=t,this._drawingManagerService=o,this._canvasFloatDomService=s,this._sheetDrawingService=c,this._lifecycleService=d,this._drawingAddListener(),this._featureUpdateListener(),this._deleteListener(),this._bindScrollEvent()}_bindScrollEvent(){this._lifecycleService.lifecycle$.pipe(L.filter(r=>r===m.LifecycleStages.Rendered),L.take(1)).subscribe(()=>{this._scrollUpdateListener()})}_ensureMap(r,e){let t=this._domLayerMap.get(r);t||(t=new Map,this._domLayerMap.set(r,t));let o=t.get(e);return o||(o=new Map,t.set(e,o)),o}getFloatDomInfo(r){return this._domLayerInfoMap.get(r)}_getSceneAndTransformerByDrawingSearch(r){if(r==null)return;const e=this._renderManagerService.getRenderById(r),t=e==null?void 0:e.scene;if(e==null||t==null)return null;const o=t.getTransformerByCreate(),s=e.engine.getCanvasElement();return{scene:t,transformer:o,renderObject:e,canvas:s}}_getFloatDomProps(r){let e;return this._hooks.forEach(t=>{e=t.onGetFloatDomProps(r)}),e}_drawingAddListener(){this.disposeWithMe(this._drawingManagerService.add$.subscribe(r=>{r.forEach(e=>{var We,Le,xe;const{unitId:t,subUnitId:o,drawingId:s}=e,c=D.getSheetCommandTarget(this._univerInstanceService,{unitId:t,subUnitId:o}),d=this._drawingManagerService.getDrawingByParam(e),h=this._univerInstanceService.getUnit(t);if(!h)return;const l=h.getActiveSheet().getSheetId();if(!d||!c)return;const a=(We=this._renderManagerService.getRenderById(t))==null?void 0:We.with(U.SheetSkeletonManagerService).getWorksheetSkeleton(o);if(!a)return;const{transform:u,drawingType:g,data:f}=d;if(g!==O.DrawingTypeEnum.DRAWING_DOM&&g!==O.DrawingTypeEnum.DRAWING_CHART)return;const w=this._getSceneAndTransformerByDrawingSearch(t);if(w==null)return;const{scene:S,canvas:C}=w;if(u==null)return!0;if(l!==o)return;const{left:y,top:I,width:T,height:_,angle:M,flipX:v,flipY:P,skewX:b,skewY:j}=u,A=O.getDrawingShapeKeyByDrawingSearch({unitId:t,subUnitId:o,drawingId:s}),E=S.getObject(A);if(E!=null){E.transformByState({left:y,top:I,width:T,height:_,angle:M,flipX:v,flipY:P,skewX:b,skewY:j});return}const R={left:y,top:I,width:T,height:_,zIndex:this._drawingManagerService.getDrawingOrder(t,o).length-1},W=g===O.DrawingTypeEnum.DRAWING_CHART;W&&(R.fill="white",R.rotateEnabled=!1,f&&f.border&&(R.stroke=f.border),R.paintFirst="stroke",R.strokeWidth=1,R.borderEnabled=!1,R.radius=8);const B=new N.Rect(A,R);W&&B.setObjectType(N.ObjectType.CHART),S.addObject(B,N.DRAWING_OBJECT_LAYER_INDEX),d.allowTransform!==!1&&S.attachTransformerTo(B);const z=this._ensureMap(t,o),De=new m.DisposableCollection,ze=ye(B,w.renderObject,a.skeleton,c.worksheet),Ie=new L.BehaviorSubject(ze),qe={dispose:De,rect:B,position$:Ie,unitId:t,subUnitId:o};this._canvasFloatDomService.addFloatDom({position$:Ie,id:s,componentKey:d.componentKey,onPointerDown:F=>{C.dispatchEvent(new PointerEvent(F.type,F))},onPointerMove:F=>{C.dispatchEvent(new PointerEvent(F.type,F))},onPointerUp:F=>{C.dispatchEvent(new PointerEvent(F.type,F))},onWheel:F=>{C.dispatchEvent(new WheelEvent(F.type,F))},props:(xe=(Le=z.get(s))==null?void 0:Le.props)!=null?xe:this._getFloatDomProps(s),data:f,unitId:t});const je=B.onTransformChange$.subscribeEvent(()=>{const F=ye(B,w.renderObject,a.skeleton,c.worksheet);Ie.next(F)});De.add(()=>{this._canvasFloatDomService.removeFloatDom(s)}),je&&De.add(je),this._domLayerInfoMap.set(s,qe),z.set(s,{...z.get(s)})})})),this.disposeWithMe(this._drawingManagerService.remove$.subscribe(r=>{r.forEach(e=>{const{unitId:t,subUnitId:o,drawingId:s}=e,c=O.getDrawingShapeKeyByDrawingSearch({unitId:t,subUnitId:o,drawingId:s}),d=this._getSceneAndTransformerByDrawingSearch(t);if(d==null)return;const{transformer:h,scene:l}=d,a=l.getObject(c);a!=null&&a.oKey&&h.clearControlByIds([a==null?void 0:a.oKey])})}))}_scrollUpdateListener(){const r=(e,t)=>{var l;const o=this._getSceneAndTransformerByDrawingSearch(e),s=this._ensureMap(e,t),c=Array.from(s.keys()),d=D.getSheetCommandTarget(this._univerInstanceService,{unitId:e,subUnitId:t}),h=(l=this._renderManagerService.getRenderById(e))==null?void 0:l.with(U.SheetSkeletonManagerService).getWorksheetSkeleton(t);!o||!d||!h||c.forEach(a=>{const u=this._domLayerInfoMap.get(a);if(u){const g=ye(u.rect,o.renderObject,h.skeleton,d.worksheet);u.position$.next(g)}})};this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(m.UniverInstanceType.UNIVER_SHEET).pipe(L.filter(e=>!!e),L.switchMap(e=>e.activeSheet$),L.filter(e=>!!e),L.map(e=>{const t=this._renderManagerService.getRenderById(e.getUnitId());return t?{render:t,unitId:e.getUnitId(),subUnitId:e.getSheetId()}:null}),L.filter(e=>!!e),L.switchMap(e=>m.fromEventSubject(e.render.scene.getViewport(U.VIEWPORT_KEY.VIEW_MAIN).onScrollAfter$).pipe(L.map(()=>({unitId:e.unitId,subUnitId:e.subUnitId}))))).subscribe(({unitId:e,subUnitId:t})=>{r(e,t)})),this.disposeWithMe(this._commandService.onCommandExecuted(e=>{var t,o;if(e.id===U.SetZoomRatioOperation.id){const s=e.params,{unitId:c}=s;Array.from((o=(t=this._domLayerMap.get(c))==null?void 0:t.keys())!=null?o:[]).forEach(h=>{r(c,h)})}else if(e.id===D.SetFrozenMutation.id){const{unitId:s,subUnitId:c}=e.params;r(s,c)}}))}_getPosition(r,e){var g;const{startX:t,endX:o,startY:s,endY:c}=r,d=(g=this._renderManagerService.getRenderById(e))==null?void 0:g.with(U.ISheetSelectionRenderService);if(d==null)return;const h=d.getCellWithCoordByOffset(t,s);if(h==null)return;const l={column:h.actualColumn,columnOffset:t-h.startX,row:h.actualRow,rowOffset:s-h.startY},a=d.getCellWithCoordByOffset(o,c);if(a==null)return;const u={column:a.actualColumn,columnOffset:o-a.startX,row:a.actualRow,rowOffset:c-a.startY};return{from:l,to:u}}_featureUpdateListener(){this.disposeWithMe(this._drawingManagerService.update$.subscribe(r=>{r.forEach(e=>{const t=this._drawingManagerService.getDrawingByParam(e);if(!t||t.drawingType!==O.DrawingTypeEnum.DRAWING_DOM&&t.drawingType!==O.DrawingTypeEnum.DRAWING_CHART)return;const o={...t.transform};this._transformChange$.next({id:e.drawingId,value:o})})}))}_deleteListener(){this.disposeWithMe(this._drawingManagerService.remove$.subscribe(r=>{r.forEach(e=>{this._removeDom(e.drawingId)})}))}updateFloatDomProps(r,e,t,o){const s=this._domLayerInfoMap.get(t),c=this._getSceneAndTransformerByDrawingSearch(r);if(s&&c){const{scene:d}=c,h=O.getDrawingShapeKeyByDrawingSearch({unitId:r,subUnitId:e,drawingId:t}),l=d.getObject(h);l&&l instanceof N.Rect&&l.setProps(o)}}addFloatDomToPosition(r,e){const t=D.getSheetCommandTarget(this._univerInstanceService,{unitId:r.unitId,subUnitId:r.subUnitId});if(!t)throw new Error("cannot find current target!");const{unitId:o,subUnitId:s}=t,{initPosition:c,componentKey:d,data:h,allowTransform:l=!0}=r,a=e!=null?e:m.generateRandomId(),u=this._getPosition(c,o);if(u==null)return;this._ensureMap(o,s).set(a,r);const f={unitId:o,subUnitId:s,drawingId:a,drawingType:r.type||O.DrawingTypeEnum.DRAWING_DOM,componentKey:d,sheetTransform:u,transform:{left:c.startX,top:c.startY,width:c.endX-c.startX,height:c.endY-c.startY},data:h,allowTransform:l};return this._commandService.executeCommand(oe.id,{unitId:o,drawings:[f]}),this._add$.next({unitId:o,subUnitId:s,id:a}),{id:a,dispose:()=>{this._removeDom(a,!0)}}}_removeDom(r,e=!1){const t=this._domLayerInfoMap.get(r);if(!t)return;const{unitId:o,subUnitId:s}=t;this._domLayerInfoMap.delete(r),t.dispose.dispose();const c=this._getSceneAndTransformerByDrawingSearch(o);if(c&&c.scene.removeObject(t.rect),e){this._ensureMap(o,s).delete(r);const h=this._drawingManagerService.getDrawingByParam({unitId:o,subUnitId:s,drawingId:r});if(!h)return;const l=this._sheetDrawingService.getBatchRemoveOp([h]),{redo:a,objects:u}=l;this._commandService.syncExecuteCommand(p.SetDrawingApplyMutation.id,{unitId:o,subUnitId:s,op:a,objects:u,type:p.DrawingApplyType.REMOVE})}}addHook(r){return this._hooks.push(r),{dispose:()=>{const e=this._hooks.findIndex(t=>t===r);this._hooks.splice(e,1)}}}};exports.SheetCanvasFloatDomManagerService=_n([ee(0,m.Inject(N.IRenderManagerService)),ee(1,m.IUniverInstanceService),ee(2,m.Inject(m.ICommandService)),ee(3,O.IDrawingManagerService),ee(4,m.Inject(G.CanvasFloatDomService)),ee(5,p.ISheetDrawingService),ee(6,m.Inject(m.LifecycleService))],exports.SheetCanvasFloatDomManagerService);var Xe=Object.defineProperty,In=Object.getOwnPropertyDescriptor,Cn=(i,n,r)=>n in i?Xe(i,n,{enumerable:!0,configurable:!0,writable:!0,value:r}):i[n]=r,yn=(i,n,r,e)=>{for(var t=e>1?void 0:e?In(n,r):n,o=i.length-1,s;o>=0;o--)(s=i[o])&&(t=(e?s(n,r,t):s(t))||t);return e&&t&&Xe(n,r,t),t},Me=(i,n)=>(r,e)=>n(r,e,i),Ke=(i,n,r)=>Cn(i,typeof n!="symbol"?n+"":n,r);const Mn="SHEET_IMAGE_UI_PLUGIN";exports.UniverSheetsDrawingUIPlugin=class extends m.Plugin{constructor(n=et,r,e,t){super(),this._config=n,this._injector=r,this._renderManagerService=e,this._configService=t;const{menu:o,...s}=this._config;o&&this._configService.setConfig("menu",o,{merge:!0}),this._configService.setConfig(Qe,s)}onStarting(){m.registerDependencies(this._injector,[[exports.SheetCanvasFloatDomManagerService],[pe],[he],[Se],[we],[fe]]),m.touchDependencies(this._injector,[[exports.SheetCanvasFloatDomManagerService]])}onReady(){m.touchDependencies(this._injector,[[fe]])}onRendered(){this._registerRenderModules(),m.touchDependencies(this._injector,[[we],[Se],[pe]])}onSteady(){this._injector.get(he)}_registerRenderModules(){[[me],[Te],[Re]].forEach(n=>{this.disposeWithMe(this._renderManagerService.registerRenderModule(m.UniverInstanceType.UNIVER_SHEET,n))})}};Ke(exports.UniverSheetsDrawingUIPlugin,"type",m.UniverInstanceType.UNIVER_SHEET);Ke(exports.UniverSheetsDrawingUIPlugin,"pluginName",Mn);exports.UniverSheetsDrawingUIPlugin=yn([m.DependentOn(O.UniverDrawingPlugin,te.UniverDrawingUIPlugin,p.UniverSheetsDrawingPlugin),Me(1,m.Inject(m.Injector)),Me(2,N.IRenderManagerService),Me(3,m.IConfigService)],exports.UniverSheetsDrawingUIPlugin);exports.ClearSheetDrawingTransformerOperation=x;exports.DeleteDrawingsCommand=Ee;exports.EditSheetDrawingOperation=Oe;exports.GroupSheetDrawingCommand=Pe;exports.IMAGE_MENU_ID=Ne;exports.InsertFloatImageCommand=_e;exports.InsertSheetDrawingCommand=oe;exports.MoveDrawingsCommand=ne;exports.RemoveSheetDrawingCommand=ie;exports.SetDrawingArrangeCommand=Ae;exports.SetSheetDrawingCommand=se;exports.SidebarSheetDrawingOperation=be;exports.UngroupSheetDrawingCommand=Ue;
|
package/lib/es/index.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
var mn = Object.defineProperty;
|
|
2
2
|
var fn = (i, e, n) => e in i ? mn(i, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : i[e] = n;
|
|
3
3
|
var V = (i, e, n) => fn(i, typeof e != "symbol" ? e + "" : e, n);
|
|
4
|
-
import { CommandType as H, ICommandService as B, IUndoRedoService as ue, sequenceExecute as It, LocaleService as Be, IUniverInstanceService as fe, useDependency as ae, Inject as W, Injector as Rt, IContextService as Dt, RxDisposable as pn, UniverInstanceType as Y, connectInjector as wn, toDisposable as _n, FOCUSING_COMMON_DRAWINGS as me, Disposable as ie, Direction as te, FOCUSING_FX_BAR_EDITOR as vn, EDITOR_ACTIVATED as Sn, FOCUSING_PANEL_EDITOR as Cn, Tools as ge, UserManagerService as In, IPermissionService as Rn, Rectangle as Dn, LifecycleService as Mn, LifecycleStages as bn, DisposableCollection as yn, fromEventSubject as On, generateRandomId as
|
|
4
|
+
import { CommandType as H, ICommandService as B, IUndoRedoService as ue, sequenceExecute as It, LocaleService as Be, IUniverInstanceService as fe, useDependency as ae, Inject as W, Injector as Rt, IContextService as Dt, RxDisposable as pn, UniverInstanceType as Y, connectInjector as wn, toDisposable as _n, FOCUSING_COMMON_DRAWINGS as me, Disposable as ie, Direction as te, FOCUSING_FX_BAR_EDITOR as vn, EDITOR_ACTIVATED as Sn, FOCUSING_PANEL_EDITOR as Cn, Tools as ge, UserManagerService as In, IPermissionService as Rn, Rectangle as Dn, LifecycleService as Mn, LifecycleStages as bn, DisposableCollection as yn, fromEventSubject as On, generateRandomId as Pn, DependentOn as Tn, Plugin as En, registerDependencies as Un, touchDependencies as Xe, IConfigService as An } from "@univerjs/core";
|
|
5
5
|
import { IDrawingManagerService as K, IImageIoService as Mt, DrawingTypeEnum as k, ArrangeTypeEnum as ve, DRAWING_IMAGE_ALLOW_IMAGE_LIST as Nn, DRAWING_IMAGE_COUNT_LIMIT as mt, ImageUploadStatusType as He, DRAWING_IMAGE_ALLOW_SIZE as jn, getImageSize as Wn, DRAWING_IMAGE_WIDTH_LIMIT as ft, DRAWING_IMAGE_HEIGHT_LIMIT as pt, getDrawingShapeKeyByDrawingSearch as ze, UniverDrawingPlugin as xn } from "@univerjs/drawing";
|
|
6
6
|
import { ImageCropperObject as $n, COMPONENT_IMAGE_POPUP_MENU as Ln, OpenImageCropOperation as Bn, ImageResetSizeOperation as Gn, DrawingCommonPanel as Vn, DrawingRenderService as kn, UniverDrawingUIPlugin as Yn } from "@univerjs/drawing-ui";
|
|
7
7
|
import { IRenderManagerService as J, precisionTo as ne, getGroupState as Fn, transformObjectOutOfGroup as Xn, RENDER_CLASS_TYPE as de, Rect as wt, ObjectType as Hn, DRAWING_OBJECT_LAYER_INDEX as zn, SHEET_VIEWPORT_KEY as Kn } from "@univerjs/engine-render";
|
|
8
|
-
import { ISheetDrawingService as F, SetDrawingApplyMutation as
|
|
9
|
-
import { SheetCanvasPopManagerService as Zn, attachRangeWithCoord as
|
|
8
|
+
import { ISheetDrawingService as F, SetDrawingApplyMutation as P, DrawingApplyType as T, SheetDrawingAnchorType as y, UniverSheetsDrawingPlugin as Jn } from "@univerjs/sheets-drawing";
|
|
9
|
+
import { SheetCanvasPopManagerService as Zn, attachRangeWithCoord as Te, ISheetSelectionRenderService as pe, SheetSkeletonManagerService as q, getCurrentRangeDisable$ as qn, COPY_TYPE as _t, PREDEFINED_HOOK_NAME as Se, virtualizeDiscreteRanges as Qn, ISheetClipboardService as er, SheetPrintInterceptorService as tr, VIEWPORT_KEY as nr, SetZoomRatioOperation as rr } from "@univerjs/sheets-ui";
|
|
10
10
|
import { ISidebarService as ir, IUIPartsService as sr, BuiltInUIPart as or, ILocalFileService as ar, IMessageService as cr, MenuItemType as bt, getMenuHiddenObservable as yt, RibbonStartGroup as dr, KeyCode as le, ComponentManager as lr, IMenuManagerService as ur, IShortcutService as hr, CanvasFloatDomService as gr } from "@univerjs/ui";
|
|
11
11
|
import { takeUntil as vt, combineLatest as Ce, map as Ee, filter as re, distinctUntilChanged as Ie, Subject as Ke, take as mr, BehaviorSubject as fr, switchMap as St } from "rxjs";
|
|
12
|
-
import { SheetInterceptorService as at, getSheetCommandTarget as ce, SheetsSelectionsService as pr, WorkbookEditablePermission as tt, WorksheetEditPermission as
|
|
12
|
+
import { SheetInterceptorService as at, getSheetCommandTarget as ce, SheetsSelectionsService as pr, WorkbookEditablePermission as tt, WorksheetEditPermission as Pe, RangeProtectionPermissionEditPoint as wr, WorkbookViewPermission as Ct, WorksheetViewPermission as Je, InsertRowCommand as Ot, InsertColCommand as Pt, RemoveRowCommand as Tt, RemoveColCommand as Et, DeleteRangeMoveLeftCommand as Ut, DeleteRangeMoveUpCommand as At, InsertRangeMoveDownCommand as Nt, InsertRangeMoveRightCommand as jt, DeltaRowHeightCommand as nt, SetRowHeightCommand as rt, DeltaColumnWidthCommand as Wt, SetColWidthCommand as xt, SetRowHiddenCommand as $t, SetSpecificRowsVisibleCommand as Lt, SetSpecificColsVisibleCommand as Bt, SetColHiddenCommand as Gt, MoveColsCommand as Vt, MoveRowsCommand as kt, MoveRangeCommand as Yt, SetRowVisibleMutation as _r, SetRowHiddenMutation as vr, SetColVisibleMutation as Sr, SetColHiddenMutation as Cr, SetWorksheetRowHeightMutation as Ir, SetWorksheetColWidthMutation as Rr, SetWorksheetActiveOperation as Dr, SetFrozenMutation as Mr } from "@univerjs/sheets";
|
|
13
13
|
import Ft, { useEffect as ct, forwardRef as Xt, useRef as br, createElement as Ht, useState as it } from "react";
|
|
14
14
|
import { MessageType as Re, RadioGroup as yr, Radio as Ze } from "@univerjs/design";
|
|
15
|
-
const Or = "sheets-drawing-ui.config",
|
|
15
|
+
const Or = "sheets-drawing-ui.config", Pr = {}, j = {
|
|
16
16
|
id: "sheet.operation.clear-drawing-transformer",
|
|
17
17
|
type: H.MUTATION,
|
|
18
18
|
handler: (i, e) => {
|
|
@@ -34,7 +34,7 @@ const Or = "sheets-drawing-ui.config", Tr = {}, j = {
|
|
|
34
34
|
const { unitId: I } = _;
|
|
35
35
|
d.push(I);
|
|
36
36
|
});
|
|
37
|
-
const l = s.getBatchRemoveOp(o), { unitId: g, subUnitId: c, undo: a, redo: h, objects: u } = l, m = r.onCommandExecute({ id: Ge.id, params: e }), f = { id:
|
|
37
|
+
const l = s.getBatchRemoveOp(o), { unitId: g, subUnitId: c, undo: a, redo: h, objects: u } = l, m = r.onCommandExecute({ id: Ge.id, params: e }), f = { id: P.id, params: { unitId: g, subUnitId: c, op: h, objects: u, type: T.REMOVE } }, p = { id: P.id, params: { unitId: g, subUnitId: c, op: a, objects: u, type: T.INSERT } };
|
|
38
38
|
return It([...(S = m.preRedos) != null ? S : [], f, ...m.redos], n) ? (t.pushUndoRedo({
|
|
39
39
|
unitID: g,
|
|
40
40
|
undoMutations: [
|
|
@@ -93,7 +93,7 @@ var Zt = { exports: {} }, Ve = {};
|
|
|
93
93
|
* This source code is licensed under the MIT license found in the
|
|
94
94
|
* LICENSE file in the root directory of this source tree.
|
|
95
95
|
*/
|
|
96
|
-
var
|
|
96
|
+
var Tr = Ft, Er = Symbol.for("react.element"), Ur = Symbol.for("react.fragment"), Ar = Object.prototype.hasOwnProperty, Nr = Tr.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, jr = { key: !0, ref: !0, __self: !0, __source: !0 };
|
|
97
97
|
function qt(i, e, n) {
|
|
98
98
|
var t, r = {}, s = null, o = null;
|
|
99
99
|
n !== void 0 && (s = "" + n), e.key !== void 0 && (s = "" + e.key), e.ref !== void 0 && (o = e.ref);
|
|
@@ -183,18 +183,22 @@ let Ue = class extends pn {
|
|
|
183
183
|
if (!g)
|
|
184
184
|
return;
|
|
185
185
|
const { unitId: c, subUnitId: a, drawingId: h, drawingType: u } = g, m = g.data;
|
|
186
|
-
m && m.disablePopup
|
|
186
|
+
if (m && m.disablePopup)
|
|
187
|
+
return;
|
|
188
|
+
r == null || r.dispose();
|
|
189
|
+
const f = this._canvasPopManagerService.getFeatureMenu(c, a, h, u);
|
|
190
|
+
r = this.disposeWithMe(this._canvasPopManagerService.attachPopupToObject(d, {
|
|
187
191
|
componentKey: Ln,
|
|
188
192
|
direction: "horizontal",
|
|
189
193
|
offset: [2, 0],
|
|
190
194
|
extraProps: {
|
|
191
|
-
menuItems: this._getImageMenuItems(c, a, h, u)
|
|
195
|
+
menuItems: f || this._getImageMenuItems(c, a, h, u)
|
|
192
196
|
}
|
|
193
197
|
})), this._drawingManagerService.focusDrawing([{
|
|
194
198
|
unitId: c,
|
|
195
199
|
subUnitId: a,
|
|
196
200
|
drawingId: h
|
|
197
|
-
}])
|
|
201
|
+
}]);
|
|
198
202
|
})
|
|
199
203
|
)
|
|
200
204
|
), this.disposeWithMe(
|
|
@@ -250,7 +254,7 @@ Ue = Yr([
|
|
|
250
254
|
se(6, W(sr))
|
|
251
255
|
], Ue);
|
|
252
256
|
function L(i, e, n) {
|
|
253
|
-
const { from: t, to: r, flipY: s = !1, flipX: o = !1, angle: d = 0, skewX: l = 0, skewY: g = 0 } = i, { column: c, columnOffset: a, row: h, rowOffset: u } = t, { column: m, columnOffset: f, row: p, rowOffset: C } = r, S = n.getCurrentSkeleton(), v =
|
|
257
|
+
const { from: t, to: r, flipY: s = !1, flipX: o = !1, angle: d = 0, skewX: l = 0, skewY: g = 0 } = i, { column: c, columnOffset: a, row: h, rowOffset: u } = t, { column: m, columnOffset: f, row: p, rowOffset: C } = r, S = n.getCurrentSkeleton(), v = Te(S, {
|
|
254
258
|
startColumn: c,
|
|
255
259
|
endColumn: c,
|
|
256
260
|
startRow: h,
|
|
@@ -258,7 +262,7 @@ function L(i, e, n) {
|
|
|
258
262
|
});
|
|
259
263
|
if (v == null)
|
|
260
264
|
return;
|
|
261
|
-
const R =
|
|
265
|
+
const R = Te(S, {
|
|
262
266
|
startColumn: m,
|
|
263
267
|
endColumn: m,
|
|
264
268
|
startRow: p,
|
|
@@ -487,14 +491,14 @@ const rn = {
|
|
|
487
491
|
});
|
|
488
492
|
});
|
|
489
493
|
const o = r.getGroupDrawingOp(e), { unitId: d, subUnitId: l, undo: g, redo: c, objects: a } = o;
|
|
490
|
-
return n.syncExecuteCommand(
|
|
494
|
+
return n.syncExecuteCommand(P.id, { op: c, unitId: d, subUnitId: l, objects: a, type: T.GROUP }) ? (t.pushUndoRedo({
|
|
491
495
|
unitID: d,
|
|
492
496
|
undoMutations: [
|
|
493
|
-
{ id:
|
|
497
|
+
{ id: P.id, params: { op: g, unitId: d, subUnitId: l, objects: ei(a), type: T.UNGROUP } },
|
|
494
498
|
{ id: j.id, params: s }
|
|
495
499
|
],
|
|
496
500
|
redoMutations: [
|
|
497
|
-
{ id:
|
|
501
|
+
{ id: P.id, params: { op: c, unitId: d, subUnitId: l, objects: a, type: T.GROUP } },
|
|
498
502
|
{ id: j.id, params: s }
|
|
499
503
|
]
|
|
500
504
|
}), !0) : !1;
|
|
@@ -506,7 +510,7 @@ const rn = {
|
|
|
506
510
|
var S, v, R;
|
|
507
511
|
const n = i.get(B), t = i.get(ue), r = i.get(F), s = i.get(at);
|
|
508
512
|
if (!e) return !1;
|
|
509
|
-
const o = e.drawings, d = o.map((_) => _.unitId), l = r.getBatchAddOp(o), { unitId: g, subUnitId: c, undo: a, redo: h, objects: u } = l, m = s.onCommandExecute({ id: ke.id, params: e }), f = { id:
|
|
513
|
+
const o = e.drawings, d = o.map((_) => _.unitId), l = r.getBatchAddOp(o), { unitId: g, subUnitId: c, undo: a, redo: h, objects: u } = l, m = s.onCommandExecute({ id: ke.id, params: e }), f = { id: P.id, params: { op: h, unitId: g, subUnitId: c, objects: u, type: T.INSERT } }, p = { id: P.id, params: { op: a, unitId: g, subUnitId: c, objects: u, type: T.REMOVE } };
|
|
510
514
|
return It([...(S = m.preRedos) != null ? S : [], f, ...m.redos], n) ? (t.pushUndoRedo({
|
|
511
515
|
unitID: g,
|
|
512
516
|
undoMutations: [
|
|
@@ -534,13 +538,13 @@ const rn = {
|
|
|
534
538
|
if (l === ve.forward ? c = r.getForwardDrawingsOp(g) : l === ve.backward ? c = r.getBackwardDrawingOp(g) : l === ve.front ? c = r.getFrontDrawingsOp(g) : l === ve.back && (c = r.getBackDrawingsOp(g)), c == null)
|
|
535
539
|
return !1;
|
|
536
540
|
const { objects: a, redo: h, undo: u } = c;
|
|
537
|
-
return n.syncExecuteCommand(
|
|
541
|
+
return n.syncExecuteCommand(P.id, { op: h, unitId: s, subUnitId: o, objects: a, type: T.ARRANGE }) ? (t.pushUndoRedo({
|
|
538
542
|
unitID: s,
|
|
539
543
|
undoMutations: [
|
|
540
|
-
{ id:
|
|
544
|
+
{ id: P.id, params: { op: u, unitId: s, subUnitId: o, objects: a, type: T.ARRANGE } }
|
|
541
545
|
],
|
|
542
546
|
redoMutations: [
|
|
543
|
-
{ id:
|
|
547
|
+
{ id: P.id, params: { op: h, unitId: s, subUnitId: o, objects: a, type: T.ARRANGE } }
|
|
544
548
|
]
|
|
545
549
|
}), !0) : !1;
|
|
546
550
|
}
|
|
@@ -551,14 +555,14 @@ const rn = {
|
|
|
551
555
|
const n = i.get(B), t = i.get(ue), r = i.get(F);
|
|
552
556
|
if (!e) return !1;
|
|
553
557
|
const { drawings: s } = e, o = r.getBatchUpdateOp(s), { unitId: d, subUnitId: l, undo: g, redo: c, objects: a } = o;
|
|
554
|
-
return n.syncExecuteCommand(
|
|
558
|
+
return n.syncExecuteCommand(P.id, { unitId: d, subUnitId: l, op: c, objects: a, type: T.UPDATE }) ? (t.pushUndoRedo({
|
|
555
559
|
unitID: d,
|
|
556
560
|
undoMutations: [
|
|
557
|
-
{ id:
|
|
561
|
+
{ id: P.id, params: { unitId: d, subUnitId: l, op: g, objects: a, type: T.UPDATE } },
|
|
558
562
|
{ id: j.id, params: [d] }
|
|
559
563
|
],
|
|
560
564
|
redoMutations: [
|
|
561
|
-
{ id:
|
|
565
|
+
{ id: P.id, params: { unitId: d, subUnitId: l, op: c, objects: a, type: T.UPDATE } },
|
|
562
566
|
{ id: j.id, params: [d] }
|
|
563
567
|
]
|
|
564
568
|
}), !0) : !1;
|
|
@@ -576,14 +580,14 @@ const rn = {
|
|
|
576
580
|
});
|
|
577
581
|
});
|
|
578
582
|
const o = r.getUngroupDrawingOp(e), { unitId: d, subUnitId: l, undo: g, redo: c, objects: a } = o;
|
|
579
|
-
return n.syncExecuteCommand(
|
|
583
|
+
return n.syncExecuteCommand(P.id, { op: c, unitId: d, subUnitId: l, objects: a, type: T.UNGROUP }) ? (t.pushUndoRedo({
|
|
580
584
|
unitID: d,
|
|
581
585
|
undoMutations: [
|
|
582
|
-
{ id:
|
|
586
|
+
{ id: P.id, params: { op: g, unitId: d, subUnitId: l, objects: Qr(a), type: T.GROUP } },
|
|
583
587
|
{ id: j.id, params: s }
|
|
584
588
|
],
|
|
585
589
|
redoMutations: [
|
|
586
|
-
{ id:
|
|
590
|
+
{ id: P.id, params: { op: c, unitId: d, subUnitId: l, objects: a, type: T.UNGROUP } },
|
|
587
591
|
{ id: j.id, params: s }
|
|
588
592
|
]
|
|
589
593
|
}), !0) : !1;
|
|
@@ -670,7 +674,7 @@ let Ae = class extends ie {
|
|
|
670
674
|
endColumn: 0
|
|
671
675
|
};
|
|
672
676
|
s && s.length > 0 && (o = s[s.length - 1].range);
|
|
673
|
-
const d =
|
|
677
|
+
const d = Te(this._skeletonManagerService.getCurrent().skeleton, o);
|
|
674
678
|
if (d == null)
|
|
675
679
|
return;
|
|
676
680
|
let { startColumn: l, startRow: g, startX: c, startY: a } = d, h = !1;
|
|
@@ -803,7 +807,7 @@ function ii(i) {
|
|
|
803
807
|
icon: an,
|
|
804
808
|
tooltip: "sheetImage.title",
|
|
805
809
|
hidden$: yt(i, Y.UNIVER_SHEET),
|
|
806
|
-
disabled$: qn(i, { workbookTypes: [tt], worksheetTypes: [
|
|
810
|
+
disabled$: qn(i, { workbookTypes: [tt], worksheetTypes: [Pe], rangeTypes: [wr] })
|
|
807
811
|
};
|
|
808
812
|
}
|
|
809
813
|
function si(i) {
|
|
@@ -990,10 +994,10 @@ const Di = {
|
|
|
990
994
|
binding: le.DELETE,
|
|
991
995
|
mac: le.BACKSPACE
|
|
992
996
|
};
|
|
993
|
-
var
|
|
994
|
-
for (var r = t > 1 ? void 0 : t ?
|
|
997
|
+
var Pi = Object.defineProperty, Ti = Object.getOwnPropertyDescriptor, Ei = (i, e, n, t) => {
|
|
998
|
+
for (var r = t > 1 ? void 0 : t ? Ti(e, n) : e, s = i.length - 1, o; s >= 0; s--)
|
|
995
999
|
(o = i[s]) && (r = (t ? o(e, n, r) : o(r)) || r);
|
|
996
|
-
return t && r &&
|
|
1000
|
+
return t && r && Pi(e, n, r), r;
|
|
997
1001
|
}, ye = (i, e) => (n, t) => e(n, t, i);
|
|
998
1002
|
let Ne = class extends ie {
|
|
999
1003
|
constructor(i, e, n, t) {
|
|
@@ -1147,27 +1151,27 @@ let je = class extends ie {
|
|
|
1147
1151
|
if (w) {
|
|
1148
1152
|
const { undo: U, redo: x, objects: Z } = O.getBatchUpdateOp([D]);
|
|
1149
1153
|
C.push({
|
|
1150
|
-
id:
|
|
1154
|
+
id: P.id,
|
|
1151
1155
|
params: {
|
|
1152
1156
|
unitId: s,
|
|
1153
1157
|
subUnitId: o,
|
|
1154
|
-
type:
|
|
1158
|
+
type: T.UPDATE,
|
|
1155
1159
|
op: x,
|
|
1156
1160
|
objects: Z
|
|
1157
1161
|
}
|
|
1158
1162
|
}), S.push({
|
|
1159
|
-
id:
|
|
1163
|
+
id: P.id,
|
|
1160
1164
|
params: {
|
|
1161
1165
|
unitId: s,
|
|
1162
1166
|
subUnitId: o,
|
|
1163
|
-
type:
|
|
1167
|
+
type: T.UPDATE,
|
|
1164
1168
|
op: U,
|
|
1165
1169
|
objects: Z
|
|
1166
1170
|
}
|
|
1167
1171
|
});
|
|
1168
1172
|
} else {
|
|
1169
1173
|
const { undo: U, redo: x, objects: Z } = O.getBatchAddOp([D]);
|
|
1170
|
-
C.push({ id:
|
|
1174
|
+
C.push({ id: P.id, params: { op: x, unitId: s, subUnitId: o, objects: Z, type: T.INSERT } }), S.push({ id: P.id, params: { op: U, unitId: s, subUnitId: o, objects: Z, type: T.REMOVE } });
|
|
1171
1175
|
}
|
|
1172
1176
|
}), {
|
|
1173
1177
|
redos: C,
|
|
@@ -1232,7 +1236,7 @@ let We = class extends ie {
|
|
|
1232
1236
|
return;
|
|
1233
1237
|
}
|
|
1234
1238
|
const r = e.getUnitId(), s = t.getSheetId();
|
|
1235
|
-
if (this._permissionService.composePermission([new tt(r).id, new
|
|
1239
|
+
if (this._permissionService.composePermission([new tt(r).id, new Pe(r, s).id]).every((d) => d.value))
|
|
1236
1240
|
this._drawingManagerService.setDrawingEditable(!0);
|
|
1237
1241
|
else {
|
|
1238
1242
|
this._drawingManagerService.setDrawingEditable(!1);
|
|
@@ -1299,7 +1303,7 @@ let We = class extends ie {
|
|
|
1299
1303
|
const d = this._renderManagerService.getRenderById(r), l = d == null ? void 0 : d.scene;
|
|
1300
1304
|
if (l == null)
|
|
1301
1305
|
return;
|
|
1302
|
-
const g = l.getTransformerByCreate(), c = this._permissionService.composePermission$([new tt(r).id, new
|
|
1306
|
+
const g = l.getTransformerByCreate(), c = this._permissionService.composePermission$([new tt(r).id, new Pe(r, s).id]).pipe(Ee((h) => h.every((u) => u.value)));
|
|
1303
1307
|
c == null || c.pipe(
|
|
1304
1308
|
re((h) => h !== o),
|
|
1305
1309
|
Ie()
|
|
@@ -1313,7 +1317,7 @@ let We = class extends ie {
|
|
|
1313
1317
|
p.classType === de.IMAGE && f.some((C) => p.oKey.includes(C.drawingId)) && l.detachTransformerFrom(p);
|
|
1314
1318
|
}), g.clearSelectedObjects());
|
|
1315
1319
|
}
|
|
1316
|
-
}), (a = this._permissionService.getPermissionPoint$(new
|
|
1320
|
+
}), (a = this._permissionService.getPermissionPoint$(new Pe(r, s).id)) == null || a.pipe(
|
|
1317
1321
|
re((h) => h.value !== o),
|
|
1318
1322
|
Ie()
|
|
1319
1323
|
).subscribe({
|
|
@@ -1401,8 +1405,8 @@ var Gi = Object.defineProperty, Vi = Object.getOwnPropertyDescriptor, ki = (i, e
|
|
|
1401
1405
|
}, Q = (i, e) => (n, t) => e(n, t, i);
|
|
1402
1406
|
const Yi = [
|
|
1403
1407
|
Ot.id,
|
|
1404
|
-
Tt.id,
|
|
1405
1408
|
Pt.id,
|
|
1409
|
+
Tt.id,
|
|
1406
1410
|
Et.id,
|
|
1407
1411
|
Ut.id,
|
|
1408
1412
|
At.id,
|
|
@@ -1444,9 +1448,9 @@ let ot = class extends ie {
|
|
|
1444
1448
|
return this._moveRowInterceptor(i.params, "insert");
|
|
1445
1449
|
if ([Vt.id, kt.id, Yt.id].includes(e))
|
|
1446
1450
|
return this._moveRangeInterceptor(i.params);
|
|
1447
|
-
if (e === Tt.id)
|
|
1448
|
-
return this._moveColInterceptor(i.params, "insert");
|
|
1449
1451
|
if (e === Pt.id)
|
|
1452
|
+
return this._moveColInterceptor(i.params, "insert");
|
|
1453
|
+
if (e === Tt.id)
|
|
1450
1454
|
return this._moveRowInterceptor(i.params, "remove");
|
|
1451
1455
|
if (e === Et.id)
|
|
1452
1456
|
return this._moveColInterceptor(i.params, "remove");
|
|
@@ -1505,11 +1509,11 @@ let ot = class extends ie {
|
|
|
1505
1509
|
return { redos: [], undos: [] };
|
|
1506
1510
|
if (l.length > 0) {
|
|
1507
1511
|
const c = this._sheetDrawingService.getBatchUpdateOp(l), { undo: a, redo: h, objects: u } = c;
|
|
1508
|
-
s.push({ id:
|
|
1512
|
+
s.push({ id: P.id, params: { unitId: t, subUnitId: r, op: h, objects: u, type: T.UPDATE } }), o.push({ id: P.id, params: { unitId: t, subUnitId: r, op: a, objects: u, type: T.UPDATE } });
|
|
1509
1513
|
}
|
|
1510
1514
|
if (g.length > 0) {
|
|
1511
1515
|
const c = this._sheetDrawingService.getBatchRemoveOp(g), a = c.undo, h = c.redo, u = c.objects;
|
|
1512
|
-
s.push({ id:
|
|
1516
|
+
s.push({ id: P.id, params: { unitId: t, subUnitId: r, op: h, objects: u, type: T.REMOVE } }), o.push({ id: P.id, params: { unitId: t, subUnitId: r, op: a, objects: u, type: T.INSERT } });
|
|
1513
1517
|
}
|
|
1514
1518
|
return s.push({ id: j.id, params: [t] }), o.push({ id: j.id, params: [t] }), {
|
|
1515
1519
|
redos: s,
|
|
@@ -1642,10 +1646,10 @@ let ot = class extends ie {
|
|
|
1642
1646
|
}
|
|
1643
1647
|
_createUndoAndRedoMutation(i, e, n) {
|
|
1644
1648
|
const t = this._sheetDrawingService.getBatchUpdateOp(n), { undo: r, redo: s, objects: o } = t, d = [
|
|
1645
|
-
{ id:
|
|
1649
|
+
{ id: P.id, params: { unitId: i, subUnitId: e, op: s, objects: o, type: T.UPDATE } },
|
|
1646
1650
|
{ id: j.id, params: [i] }
|
|
1647
1651
|
], l = [
|
|
1648
|
-
{ id:
|
|
1652
|
+
{ id: P.id, params: { unitId: i, subUnitId: e, op: r, objects: o, type: T.UPDATE } },
|
|
1649
1653
|
{ id: j.id, params: [i] }
|
|
1650
1654
|
];
|
|
1651
1655
|
return {
|
|
@@ -1786,7 +1790,7 @@ let ot = class extends ie {
|
|
|
1786
1790
|
const { unitId: r, subUnitId: s } = t, o = (R = (v = this._renderManagerService.getRenderById(r)) == null ? void 0 : v.with(q)) == null ? void 0 : R.getCurrentSkeleton();
|
|
1787
1791
|
if (!o)
|
|
1788
1792
|
return { redos: [], undos: [] };
|
|
1789
|
-
const d =
|
|
1793
|
+
const d = Te(o, n);
|
|
1790
1794
|
if (!d)
|
|
1791
1795
|
return { redos: [], undos: [] };
|
|
1792
1796
|
const { startX: l, endX: g, startY: c, endY: a } = d, h = this._sheetDrawingService.getDrawingData(r, s), u = [];
|
|
@@ -1820,7 +1824,7 @@ let ot = class extends ie {
|
|
|
1820
1824
|
});
|
|
1821
1825
|
if (S.length) {
|
|
1822
1826
|
const _ = this._sheetDrawingService.getBatchUpdateOp(S), { undo: I, redo: w, objects: O } = _;
|
|
1823
|
-
m.push({ id:
|
|
1827
|
+
m.push({ id: P.id, params: { unitId: r, subUnitId: s, op: w, objects: O, type: T.UPDATE } }), f.push({ id: P.id, params: { unitId: r, subUnitId: s, op: I, objects: O, type: T.UPDATE } });
|
|
1824
1828
|
}
|
|
1825
1829
|
return { redos: m, undos: f };
|
|
1826
1830
|
}
|
|
@@ -1854,11 +1858,11 @@ let ot = class extends ie {
|
|
|
1854
1858
|
return { redos: [], undos: [] };
|
|
1855
1859
|
if (a.length > 0) {
|
|
1856
1860
|
const u = this._sheetDrawingService.getBatchUpdateOp(a), { undo: m, redo: f, objects: p } = u;
|
|
1857
|
-
l.push({ id:
|
|
1861
|
+
l.push({ id: P.id, params: { unitId: t, subUnitId: r, op: f, objects: p, type: T.UPDATE } }), g.push({ id: P.id, params: { unitId: t, subUnitId: r, op: m, objects: p, type: T.UPDATE } });
|
|
1858
1862
|
}
|
|
1859
1863
|
if (h.length > 0) {
|
|
1860
1864
|
const u = this._sheetDrawingService.getBatchRemoveOp(h), m = u.undo, f = u.redo, p = u.objects;
|
|
1861
|
-
l.push({ id:
|
|
1865
|
+
l.push({ id: P.id, params: { unitId: t, subUnitId: r, op: f, objects: p, type: T.REMOVE } }), g.push({ id: P.id, params: { unitId: t, subUnitId: r, op: m, objects: p, type: T.INSERT } });
|
|
1862
1866
|
}
|
|
1863
1867
|
return l.push({ id: j.id, params: [t] }), g.push({ id: j.id, params: [t] }), {
|
|
1864
1868
|
redos: l,
|
|
@@ -1895,11 +1899,11 @@ let ot = class extends ie {
|
|
|
1895
1899
|
return { redos: [], undos: [] };
|
|
1896
1900
|
if (a.length > 0) {
|
|
1897
1901
|
const u = this._sheetDrawingService.getBatchUpdateOp(a), { undo: m, redo: f, objects: p } = u;
|
|
1898
|
-
l.push({ id:
|
|
1902
|
+
l.push({ id: P.id, params: { unitId: t, subUnitId: r, op: f, objects: p, type: T.UPDATE } }), g.push({ id: P.id, params: { unitId: t, subUnitId: r, op: m, objects: p, type: T.UPDATE } });
|
|
1899
1903
|
}
|
|
1900
1904
|
if (h.length > 0) {
|
|
1901
1905
|
const u = this._sheetDrawingService.getBatchRemoveOp(h), m = u.undo, f = u.redo, p = u.objects;
|
|
1902
|
-
l.push({ id:
|
|
1906
|
+
l.push({ id: P.id, params: { unitId: t, subUnitId: r, op: f, objects: p, type: T.REMOVE } }), g.push({ id: P.id, params: { unitId: t, subUnitId: r, op: m, objects: p, type: T.INSERT } });
|
|
1903
1907
|
}
|
|
1904
1908
|
return l.push({ id: j.id, params: [t] }), g.push({ id: j.id, params: [t] }), { redos: l, undos: g };
|
|
1905
1909
|
}
|
|
@@ -2453,7 +2457,7 @@ let $e = class extends ie {
|
|
|
2453
2457
|
});
|
|
2454
2458
|
if (!t)
|
|
2455
2459
|
throw new Error("cannot find current target!");
|
|
2456
|
-
const { unitId: r, subUnitId: s } = t, { initPosition: o, componentKey: d, data: l, allowTransform: g = !0 } = e, c = n != null ? n :
|
|
2460
|
+
const { unitId: r, subUnitId: s } = t, { initPosition: o, componentKey: d, data: l, allowTransform: g = !0 } = e, c = n != null ? n : Pn(), a = this._getPosition(o, r);
|
|
2457
2461
|
if (a == null)
|
|
2458
2462
|
return;
|
|
2459
2463
|
this._ensureMap(r, s).set(c, e);
|
|
@@ -2496,7 +2500,7 @@ let $e = class extends ie {
|
|
|
2496
2500
|
if (!l)
|
|
2497
2501
|
return;
|
|
2498
2502
|
const g = this._sheetDrawingService.getBatchRemoveOp([l]), { redo: c, objects: a } = g;
|
|
2499
|
-
this._commandService.syncExecuteCommand(
|
|
2503
|
+
this._commandService.syncExecuteCommand(P.id, { unitId: r, subUnitId: s, op: c, objects: a, type: T.REMOVE });
|
|
2500
2504
|
}
|
|
2501
2505
|
}
|
|
2502
2506
|
addHook(e) {
|
|
@@ -2524,7 +2528,7 @@ var ln = Object.defineProperty, Ji = Object.getOwnPropertyDescriptor, Zi = (i, e
|
|
|
2524
2528
|
}, et = (i, e) => (n, t) => e(n, t, i), un = (i, e, n) => Zi(i, typeof e != "symbol" ? e + "" : e, n);
|
|
2525
2529
|
const Qi = "SHEET_IMAGE_UI_PLUGIN";
|
|
2526
2530
|
let Le = class extends En {
|
|
2527
|
-
constructor(i =
|
|
2531
|
+
constructor(i = Pr, e, n, t) {
|
|
2528
2532
|
super(), this._config = i, this._injector = e, this._renderManagerService = n, this._configService = t;
|
|
2529
2533
|
const { menu: r, ...s } = this._config;
|
|
2530
2534
|
r && this._configService.setConfig("menu", r, { merge: !0 }), this._configService.setConfig(Or, s);
|
|
@@ -2569,7 +2573,7 @@ let Le = class extends En {
|
|
|
2569
2573
|
un(Le, "type", Y.UNIVER_SHEET);
|
|
2570
2574
|
un(Le, "pluginName", Qi);
|
|
2571
2575
|
Le = qi([
|
|
2572
|
-
|
|
2576
|
+
Tn(xn, Yn, Jn),
|
|
2573
2577
|
et(1, W(Rt)),
|
|
2574
2578
|
et(2, J),
|
|
2575
2579
|
et(3, An)
|
package/lib/umd/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(O,p){typeof exports=="object"&&typeof module<"u"?p(exports,require("@univerjs/core"),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/design")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/drawing","@univerjs/drawing-ui","@univerjs/engine-render","@univerjs/sheets-drawing","@univerjs/sheets-ui","@univerjs/ui","rxjs","@univerjs/sheets","react","@univerjs/design"],p):(O=typeof globalThis<"u"?globalThis:O||self,p(O.UniverSheetsDrawingUi={},O.UniverCore,O.UniverDrawing,O.UniverDrawingUi,O.UniverEngineRender,O.UniverSheetsDrawing,O.UniverSheetsUi,O.UniverUi,O.rxjs,O.UniverSheets,O.React,O.UniverDesign))})(this,function(O,p,b,ee,N,h,j
|
|
1
|
+
(function(O,p){typeof exports=="object"&&typeof module<"u"?p(exports,require("@univerjs/core"),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/design")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/drawing","@univerjs/drawing-ui","@univerjs/engine-render","@univerjs/sheets-drawing","@univerjs/sheets-ui","@univerjs/ui","rxjs","@univerjs/sheets","react","@univerjs/design"],p):(O=typeof globalThis<"u"?globalThis:O||self,p(O.UniverSheetsDrawingUi={},O.UniverCore,O.UniverDrawing,O.UniverDrawingUi,O.UniverEngineRender,O.UniverSheetsDrawing,O.UniverSheetsUi,O.UniverUi,O.rxjs,O.UniverSheets,O.React,O.UniverDesign))})(this,function(O,p,b,ee,N,h,j,F,W,I,H,Z){"use strict";var on=Object.defineProperty;var an=(O,p,b)=>p in O?on(O,p,{enumerable:!0,configurable:!0,writable:!0,value:b}):O[p]=b;var X=(O,p,b)=>an(O,typeof p!="symbol"?p+"":p,b);const Je="sheets-drawing-ui.config",Ze={},G={id:"sheet.operation.clear-drawing-transformer",type:p.CommandType.MUTATION,handler:(i,n)=>{const r=i.get(N.IRenderManagerService);return n.forEach(e=>{var t,o;(o=(t=r.getRenderById(e))==null?void 0:t.scene.getTransformer())==null||o.debounceRefreshControls()}),!0}},ie={id:"sheet.command.remove-sheet-image",type:p.CommandType.COMMAND,handler:(i,n)=>{var M,C,T;const r=i.get(p.ICommandService),e=i.get(p.IUndoRedoService),t=i.get(I.SheetInterceptorService),o=i.get(h.ISheetDrawingService);if(!n)return!1;const{drawings:a}=n,c=[];a.forEach(_=>{const{unitId:D}=_;c.push(D)});const d=o.getBatchRemoveOp(a),{unitId:g,subUnitId:l,undo:s,redo:u,objects:m}=d,f=t.onCommandExecute({id:ie.id,params:n}),S={id:h.SetDrawingApplyMutation.id,params:{unitId:g,subUnitId:l,op:u,objects:m,type:h.DrawingApplyType.REMOVE}},v={id:h.SetDrawingApplyMutation.id,params:{unitId:g,subUnitId:l,op:s,objects:m,type:h.DrawingApplyType.INSERT}};return p.sequenceExecute([...(M=f.preRedos)!=null?M:[],S,...f.redos],r)?(e.pushUndoRedo({unitID:g,undoMutations:[...(C=f.preUndos)!=null?C:[],v,...f.undos,{id:G.id,params:c}],redoMutations:[...(T=f.preRedos)!=null?T:[],S,...f.redos,{id:G.id,params:c}]}),!0):!1}},We="COMPONENT_SHEET_DRAWING_PANEL",Ce={id:"sidebar.operation.sheet-image",type:p.CommandType.COMMAND,handler:async(i,n)=>{const r=i.get(F.ISidebarService),e=i.get(p.LocaleService),t=i.get(p.IUniverInstanceService),o=i.get(b.IDrawingManagerService);if(!I.getSheetCommandTarget(t))return!1;switch(n.value){case"open":r.open({header:{title:e.t("sheetImage.panel.title")},children:{label:We},onClose:()=>{o.focusDrawing(null)},width:360});break;case"close":default:r.close();break}return!0}},ye={id:"sheet.operation.edit-sheet-image",type:p.CommandType.OPERATION,handler:(i,n)=>{const r=i.get(b.IDrawingManagerService),e=i.get(p.ICommandService);return n==null?!1:(r.focusDrawing([n]),e.executeCommand(Ce.id,{value:"open"}),!0)}};var Le={exports:{}},de={};/**
|
|
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 qe=H,Qe=Symbol.for("react.element"),et=Symbol.for("react.fragment"),tt=Object.prototype.hasOwnProperty,nt=qe.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,rt={key:!0,ref:!0,__self:!0,__source:!0};function Be(i,n,r){var e,t={},o=null,a=null;r!==void 0&&(o=""+r),n.key!==void 0&&(o=""+n.key),n.ref!==void 0&&(a=n.ref);for(e in n)tt.call(n,e)&&!rt.hasOwnProperty(e)&&(t[e]=n[e]);if(i&&i.defaultProps)for(e in n=i.defaultProps,n)t[e]===void 0&&(t[e]=n[e]);return{$$typeof:Qe,type:i,key:o,ref:a,props:t,_owner:nt.current}}de.Fragment=et,de.jsx=Be,de.jsxs=Be,Le.exports=de;var F=Le.exports;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"},it=()=>{const i=p.useDependency(b.IImageIoService),n=p.useDependency(p.LocaleService),[r,e]=H.useState(0);return H.useEffect(()=>{const t=i.change$.subscribe(o=>{e(o)});return()=>{t.unsubscribe()}},[i]),F.jsx("div",{style:{display:r>0?"block":"none"},className:le.uploadLoading,children:F.jsxs("div",{className:le.uploadLoadingBody,children:[F.jsx("div",{className:le.uploadLoadingBodyAnimation}),F.jsx("div",{className:le.uploadLoadingBodyText,children:`${n.t("uploadLoading.loading")}: ${r}`})]})})};var ot=Object.defineProperty,at=Object.getOwnPropertyDescriptor,st=(i,n,r,e)=>{for(var t=e>1?void 0:e?at(n,r):n,o=i.length-1,a;o>=0;o--)(a=i[o])&&(t=(e?a(n,r,t):a(t))||t);return e&&t&&ot(n,r,t),t},te=(i,n)=>(r,e)=>n(r,e,i);let ue=class extends p.RxDisposable{constructor(n,r,e,t,o,a,c){super();X(this,"_initImagePopupMenu",new Set);this._injector=n,this._drawingManagerService=r,this._canvasPopManagerService=e,this._renderManagerService=t,this._univerInstanceService=o,this._contextService=a,this._uiPartsService=c,this._init()}_init(){this._univerInstanceService.getCurrentTypeOfUnit$(p.UniverInstanceType.UNIVER_SHEET).pipe(W.takeUntil(this.dispose$)).subscribe(n=>this._create(n)),this._univerInstanceService.getTypeOfUnitDisposed$(p.UniverInstanceType.UNIVER_SHEET).pipe(W.takeUntil(this.dispose$)).subscribe(n=>this._dispose(n)),this._univerInstanceService.getAllUnitsForType(p.UniverInstanceType.UNIVER_SHEET).forEach(n=>this._create(n)),this._uiPartsService.registerComponent($.BuiltInUIPart.CONTENT,()=>p.connectInjector(it,this._injector))}_dispose(n){const r=n.getUnitId();this._renderManagerService.removeRender(r)}_create(n){if(!n)return;const r=n.getUnitId();this._renderManagerService.has(r)&&!this._initImagePopupMenu.has(r)&&(this._popupMenuListener(r),this._initImagePopupMenu.add(r))}_hasCropObject(n){const r=n.getAllObjectsByOrder();for(const e of r)if(e instanceof ee.ImageCropperObject)return!0;return!1}_popupMenuListener(n){var o;const r=(o=this._renderManagerService.getRenderById(n))==null?void 0:o.scene;if(!r)return;const e=r.getTransformerByCreate();if(!e)return;let t;this.disposeWithMe(p.toDisposable(e.createControl$.subscribe(()=>{if(this._contextService.setContextValue(p.FOCUSING_COMMON_DRAWINGS,!0),this._hasCropObject(r))return;const a=e.getSelectedObjectMap();if(a.size>1){t==null||t.dispose();return}const c=a.values().next().value;if(!c)return;const d=c.oKey,g=this._drawingManagerService.getDrawingOKey(d);if(!g)return;const{unitId:l,subUnitId:s,drawingId:u,drawingType:m}=g,f=g.data;f&&f.disablePopup||(t==null||t.dispose(),t=this.disposeWithMe(this._canvasPopManagerService.attachPopupToObject(c,{componentKey:ee.COMPONENT_IMAGE_POPUP_MENU,direction:"horizontal",offset:[2,0],extraProps:{menuItems:this._getImageMenuItems(l,s,u,m)}})),this._drawingManagerService.focusDrawing([{unitId:l,subUnitId:s,drawingId:u}]))}))),this.disposeWithMe(e.clearControl$.subscribe(()=>{t==null||t.dispose(),this._contextService.setContextValue(p.FOCUSING_COMMON_DRAWINGS,!1),this._drawingManagerService.focusDrawing(null)})),this.disposeWithMe(e.changing$.subscribe(()=>{t==null||t.dispose()}))}_getImageMenuItems(n,r,e,t){return[{label:"image-popup.edit",index:0,commandId:ye.id,commandParams:{unitId:n,subUnitId:r,drawingId:e},disable:t===b.DrawingTypeEnum.DRAWING_DOM},{label:"image-popup.delete",index:1,commandId:ie.id,commandParams:{unitId:n,drawings:[{unitId:n,subUnitId:r,drawingId:e}]},disable:!1},{label:"image-popup.crop",index:2,commandId:ee.OpenImageCropOperation.id,commandParams:{unitId:n,subUnitId:r,drawingId:e},disable:t===b.DrawingTypeEnum.DRAWING_DOM},{label:"image-popup.reset",index:3,commandId:ee.ImageResetSizeOperation.id,commandParams:[{unitId:n,subUnitId:r,drawingId:e}],disable:t===b.DrawingTypeEnum.DRAWING_DOM}]}};ue=st([te(0,p.Inject(p.Injector)),te(1,b.IDrawingManagerService),te(2,p.Inject(j.SheetCanvasPopManagerService)),te(3,N.IRenderManagerService),te(4,p.IUniverInstanceService),te(5,p.IContextService),te(6,p.Inject($.IUIPartsService))],ue);function Y(i,n,r){const{from:e,to:t,flipY:o=!1,flipX:a=!1,angle:c=0,skewX:d=0,skewY:g=0}=i,{column:l,columnOffset:s,row:u,rowOffset:m}=e,{column:f,columnOffset:S,row:v,rowOffset:y}=t,M=r.getCurrentSkeleton(),C=j.attachRangeWithCoord(M,{startColumn:l,endColumn:l,startRow:u,endRow:u});if(C==null)return;const T=j.attachRangeWithCoord(M,{startColumn:f,endColumn:f,startRow:v,endRow:v});if(T==null)return;const{startX:_,startY:D}=C,{startX:w,startY:A}=T;let E=N.precisionTo(_+s,1),L=N.precisionTo(D+m,1),U=N.precisionTo(w+S-E,1),P=N.precisionTo(A+y-L,1);C.startX===T.endX&&(U=0),C.startY===T.endY&&(P=0);const R=M.rowHeaderWidth+M.columnTotalWidth,B=M.columnHeaderHeight+M.rowTotalHeight;return E+U>R&&(E=R-U),L+P>B&&(L=B-P),{flipY:o,flipX:a,angle:c,skewX:d,skewY:g,left:E,top:L,width:U,height:P}}function k(i,n){const{left:r=0,top:e=0,width:t=0,height:o=0,flipY:a=!1,flipX:c=!1,angle:d=0,skewX:g=0,skewY:l=0}=i,s=n.getCellWithCoordByOffset(r,e);if(s==null)return;const u={column:s.actualColumn,columnOffset:N.precisionTo(r-s.startX,1),row:s.actualRow,rowOffset:N.precisionTo(e-s.startY,1)},m=n.getCellWithCoordByOffset(r+t,e+o);if(m==null)return;const f={column:m.actualColumn,columnOffset:N.precisionTo(r+t-m.startX,1),row:m.actualRow,rowOffset:N.precisionTo(e+o-m.startY,1)};return{flipY:a,flipX:c,angle:d,skewX:g,skewY:l,from:u,to:f}}var ct=Object.defineProperty,dt=Object.getOwnPropertyDescriptor,lt=(i,n,r,e)=>{for(var t=e>1?void 0:e?dt(n,r):n,o=i.length-1,a;o>=0;o--)(a=i[o])&&(t=(e?a(n,r,t):a(t))||t);return e&&t&&ct(n,r,t),t},me=(i,n)=>(r,e)=>n(r,e,i);let Me=class extends p.Disposable{constructor(i,n,r,e,t){super(),this._context=i,this._sheetDrawingService=n,this._drawingManagerService=r,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 n in i){const r=i[n];for(const e in r.data){const t=r.data[e];t.transform=Y(t.sheetTransform,this._sheetSelectionRenderService,this._sheetSkeletonManagerService)}}this._drawingManagerService.registerDrawingData(this._context.unitId,this._sheetDrawingService.getDrawingDataForUnit(this._context.unitId)),this._drawingManagerService.initializeNotification(this._context.unitId)}};Me=lt([me(1,h.ISheetDrawingService),me(2,b.IDrawingManagerService),me(3,p.Inject(j.ISheetSelectionRenderService)),me(4,p.Inject(j.SheetSkeletonManagerService))],Me);var K=function(){return K=Object.assign||function(i){for(var n,r=1,e=arguments.length;r<e;r++){n=arguments[r];for(var t in n)Object.prototype.hasOwnProperty.call(n,t)&&(i[t]=n[t])}return i},K.apply(this,arguments)},ut=function(i,n){var r={};for(var e in i)Object.prototype.hasOwnProperty.call(i,e)&&n.indexOf(e)<0&&(r[e]=i[e]);if(i!=null&&typeof Object.getOwnPropertySymbols=="function")for(var t=0,e=Object.getOwnPropertySymbols(i);t<e.length;t++)n.indexOf(e[t])<0&&Object.prototype.propertyIsEnumerable.call(i,e[t])&&(r[e[t]]=i[e[t]]);return r},Ge=H.forwardRef(function(i,n){var r=i.icon,e=i.id,t=i.className,o=i.extend,a=ut(i,["icon","id","className","extend"]),c="univerjs-icon univerjs-icon-".concat(e," ").concat(t||"").trim(),d=H.useRef("_".concat(pt()));return ke(r,"".concat(e),{defIds:r.defIds,idSuffix:d.current},K({ref:n,className:c},a),o)});function ke(i,n,r,e,t){return H.createElement(i.tag,K(K({key:n},mt(i,r,t)),e),(gt(i,r).children||[]).map(function(o,a){return ke(o,"".concat(n,"-").concat(i.tag,"-").concat(a),r,void 0,t)}))}function mt(i,n,r){var e=K({},i.attrs);r!=null&&r.colorChannel1&&e.fill==="colorChannel1"&&(e.fill=r.colorChannel1);var t=n.defIds;return!t||t.length===0||(i.tag==="use"&&e["xlink:href"]&&(e["xlink:href"]=e["xlink:href"]+n.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(n.idSuffix,")")))})),e}function gt(i,n){var r,e=n.defIds;return!e||e.length===0?i:i.tag==="defs"&&(!((r=i.children)===null||r===void 0)&&r.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+n.idSuffix})}):t})}):i}function pt(){return Math.random().toString(36).substring(2,8)}Ge.displayName="UniverIcon";var ht={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"}}]},Ve=H.forwardRef(function(i,n){return H.createElement(Ge,Object.assign({},i,{id:"add-image-single",ref:n,icon:ht}))});Ve.displayName="AddImageSingle";const De={id:"sheet.command.delete-drawing",type:p.CommandType.COMMAND,handler:i=>{const n=i.get(p.ICommandService),e=i.get(h.ISheetDrawingService).getFocusDrawings();if(e.length===0)return!1;const t=e[0].unitId,o=e.map(a=>{const{unitId:c,subUnitId:d,drawingId:g,drawingType:l}=a;return{unitId:c,subUnitId:d,drawingId:g,drawingType:l}});return n.executeCommand(ie.id,{unitId:t,drawings:o})}};function ft(i){const n=[];return i.forEach(r=>{const{parent:e,children:t}=r,{unitId:o,subUnitId:a,drawingId:c}=e,d=N.getGroupState(0,0,t.map(s=>s.transform||{})),g=t.map(s=>{const u=s.transform||{left:0,top:0},{unitId:m,subUnitId:f,drawingId:S}=s;return{unitId:m,subUnitId:f,drawingId:S,transform:{...u,left:u.left-d.left,top:u.top-d.top},groupId:c}}),l={unitId:o,subUnitId:a,drawingId:c,drawingType:b.DrawingTypeEnum.DRAWING_GROUP,transform:d};n.push({parent:l,children:g})}),n}function St(i){const n=[];return i.forEach(r=>{const{parent:e,children:t}=r,{unitId:o,subUnitId:a,drawingId:c,transform:d={width:0,height:0}}=e;if(d==null)return;const g=t.map(s=>{const{transform:u}=s,{unitId:m,subUnitId:f,drawingId:S}=s,v=N.transformObjectOutOfGroup(u||{},d,d.width||0,d.height||0);return{unitId:m,subUnitId:f,drawingId:S,transform:v,groupId:void 0}}),l={unitId:o,subUnitId:a,drawingId:c,drawingType:b.DrawingTypeEnum.DRAWING_GROUP,transform:{left:0,top:0}};n.push({parent:l,children:g})}),n}const Re={id:"sheet.command.group-sheet-image",type:p.CommandType.COMMAND,handler:(i,n)=>{const r=i.get(p.ICommandService),e=i.get(p.IUndoRedoService),t=i.get(h.ISheetDrawingService);if(!n)return!1;const o=[];n.forEach(({parent:m,children:f})=>{o.push(m.unitId),f.forEach(S=>{o.push(S.unitId)})});const a=t.getGroupDrawingOp(n),{unitId:c,subUnitId:d,undo:g,redo:l,objects:s}=a;return r.syncExecuteCommand(h.SetDrawingApplyMutation.id,{op:l,unitId:c,subUnitId:d,objects:s,type:h.DrawingApplyType.GROUP})?(e.pushUndoRedo({unitID:c,undoMutations:[{id:h.SetDrawingApplyMutation.id,params:{op:g,unitId:c,subUnitId:d,objects:St(s),type:h.DrawingApplyType.UNGROUP}},{id:G.id,params:o}],redoMutations:[{id:h.SetDrawingApplyMutation.id,params:{op:l,unitId:c,subUnitId:d,objects:s,type:h.DrawingApplyType.GROUP}},{id:G.id,params:o}]}),!0):!1}},oe={id:"sheet.command.insert-sheet-image",type:p.CommandType.COMMAND,handler:(i,n)=>{var M,C,T;const r=i.get(p.ICommandService),e=i.get(p.IUndoRedoService),t=i.get(h.ISheetDrawingService),o=i.get(I.SheetInterceptorService);if(!n)return!1;const a=n.drawings,c=a.map(_=>_.unitId),d=t.getBatchAddOp(a),{unitId:g,subUnitId:l,undo:s,redo:u,objects:m}=d,f=o.onCommandExecute({id:oe.id,params:n}),S={id:h.SetDrawingApplyMutation.id,params:{op:u,unitId:g,subUnitId:l,objects:m,type:h.DrawingApplyType.INSERT}},v={id:h.SetDrawingApplyMutation.id,params:{op:s,unitId:g,subUnitId:l,objects:m,type:h.DrawingApplyType.REMOVE}};return p.sequenceExecute([...(M=f.preRedos)!=null?M:[],S,...f.redos],r)?(e.pushUndoRedo({unitID:g,undoMutations:[...(C=f.preUndos)!=null?C:[],v,...f.undos,{id:G.id,params:c}],redoMutations:[...(T=f.preRedos)!=null?T:[],S,...f.redos,{id:G.id,params:c}]}),!0):!1}},Te={id:"sheet.command.set-drawing-arrange",type:p.CommandType.COMMAND,handler:(i,n)=>{const r=i.get(p.ICommandService),e=i.get(p.IUndoRedoService);if(!n)return!1;const t=i.get(h.ISheetDrawingService),{unitId:o,subUnitId:a,drawingIds:c,arrangeType:d}=n,g={unitId:o,subUnitId:a,drawingIds:c};let l;if(d===b.ArrangeTypeEnum.forward?l=t.getForwardDrawingsOp(g):d===b.ArrangeTypeEnum.backward?l=t.getBackwardDrawingOp(g):d===b.ArrangeTypeEnum.front?l=t.getFrontDrawingsOp(g):d===b.ArrangeTypeEnum.back&&(l=t.getBackDrawingsOp(g)),l==null)return!1;const{objects:s,redo:u,undo:m}=l;return r.syncExecuteCommand(h.SetDrawingApplyMutation.id,{op:u,unitId:o,subUnitId:a,objects:s,type:h.DrawingApplyType.ARRANGE})?(e.pushUndoRedo({unitID:o,undoMutations:[{id:h.SetDrawingApplyMutation.id,params:{op:m,unitId:o,subUnitId:a,objects:s,type:h.DrawingApplyType.ARRANGE}}],redoMutations:[{id:h.SetDrawingApplyMutation.id,params:{op:u,unitId:o,subUnitId:a,objects:s,type:h.DrawingApplyType.ARRANGE}}]}),!0):!1}},ae={id:"sheet.command.set-sheet-image",type:p.CommandType.COMMAND,handler:(i,n)=>{const r=i.get(p.ICommandService),e=i.get(p.IUndoRedoService),t=i.get(h.ISheetDrawingService);if(!n)return!1;const{drawings:o}=n,a=t.getBatchUpdateOp(o),{unitId:c,subUnitId:d,undo:g,redo:l,objects:s}=a;return r.syncExecuteCommand(h.SetDrawingApplyMutation.id,{unitId:c,subUnitId:d,op:l,objects:s,type:h.DrawingApplyType.UPDATE})?(e.pushUndoRedo({unitID:c,undoMutations:[{id:h.SetDrawingApplyMutation.id,params:{unitId:c,subUnitId:d,op:g,objects:s,type:h.DrawingApplyType.UPDATE}},{id:G.id,params:[c]}],redoMutations:[{id:h.SetDrawingApplyMutation.id,params:{unitId:c,subUnitId:d,op:l,objects:s,type:h.DrawingApplyType.UPDATE}},{id:G.id,params:[c]}]}),!0):!1}},be={id:"sheet.command.ungroup-sheet-image",type:p.CommandType.COMMAND,handler:(i,n)=>{const r=i.get(p.ICommandService),e=i.get(p.IUndoRedoService),t=i.get(h.ISheetDrawingService);if(!n)return!1;const o=[];n.forEach(({parent:m,children:f})=>{o.push(m.unitId),f.forEach(S=>{o.push(S.unitId)})});const a=t.getUngroupDrawingOp(n),{unitId:c,subUnitId:d,undo:g,redo:l,objects:s}=a;return r.syncExecuteCommand(h.SetDrawingApplyMutation.id,{op:l,unitId:c,subUnitId:d,objects:s,type:h.DrawingApplyType.UNGROUP})?(e.pushUndoRedo({unitID:c,undoMutations:[{id:h.SetDrawingApplyMutation.id,params:{op:g,unitId:c,subUnitId:d,objects:ft(s),type:h.DrawingApplyType.GROUP}},{id:G.id,params:o}],redoMutations:[{id:h.SetDrawingApplyMutation.id,params:{op:l,unitId:c,subUnitId:d,objects:s,type:h.DrawingApplyType.UNGROUP}},{id:G.id,params:o}]}),!0):!1}};var vt=Object.defineProperty,wt=Object.getOwnPropertyDescriptor,_t=(i,n,r,e)=>{for(var t=e>1?void 0:e?wt(n,r):n,o=i.length-1,a;o>=0;o--)(a=i[o])&&(t=(e?a(n,r,t):a(t))||t);return e&&t&&vt(n,r,t),t},z=(i,n)=>(r,e)=>n(r,e,i);let ge=class extends p.Disposable{constructor(n,r,e,t,o,a,c,d,g,l,s,u){super();X(this,"_workbookSelections");this._context=n,this._skeletonManagerService=r,this._commandService=e,this._selectionRenderService=t,this._imageIoService=o,this._fileOpenerService=a,this._sheetDrawingService=c,this._drawingManagerService=d,this._contextService=g,this._messageService=l,this._localeService=s,this._workbookSelections=u.getWorkbookSelections(this._context.unitId),this._updateImageListener(),this._updateOrderListener(),this._groupDrawingListener(),this._focusDrawingListener()}async insertFloatImage(){const n=await this._fileOpenerService.openFile({multiple:!0,accept:b.DRAWING_IMAGE_ALLOW_IMAGE_LIST.map(e=>`.${e.replace("image/","")}`).join(",")}),r=n.length;return r>b.DRAWING_IMAGE_COUNT_LIMIT?(this._messageService.show({type:Z.MessageType.Error,content:this._localeService.t("update-status.exceedMaxCount",String(b.DRAWING_IMAGE_COUNT_LIMIT))}),!1):r===0?!1:(n.forEach(async e=>await this._insertFloatImage(e)),!0)}async _insertFloatImage(n){let r;try{r=await this._imageIoService.saveImage(n)}catch(M){const C=M.message;C===b.ImageUploadStatusType.ERROR_EXCEED_SIZE?this._messageService.show({type:Z.MessageType.Error,content:this._localeService.t("update-status.exceedMaxSize",String(b.DRAWING_IMAGE_ALLOW_SIZE/(1024*1024)))}):C===b.ImageUploadStatusType.ERROR_IMAGE_TYPE?this._messageService.show({type:Z.MessageType.Error,content:this._localeService.t("update-status.invalidImageType")}):C===b.ImageUploadStatusType.ERROR_IMAGE&&this._messageService.show({type:Z.MessageType.Error,content:this._localeService.t("update-status.invalidImage")})}if(r==null)return;const e=this._getUnitInfo(),{unitId:t,subUnitId:o}=e,{imageId:a,imageSourceType:c,source:d,base64Cache:g}=r,{width:l,height:s,image:u}=await b.getImageSize(g||""),{width:m,height:f}=this._context.scene;this._imageIoService.addImageSourceCache(d,c,u);let S=1;if(l>b.DRAWING_IMAGE_WIDTH_LIMIT||s>b.DRAWING_IMAGE_HEIGHT_LIMIT){const M=b.DRAWING_IMAGE_WIDTH_LIMIT/l,C=b.DRAWING_IMAGE_HEIGHT_LIMIT/s;S=Math.max(M,C)}const v=this._getImagePosition(l*S,s*S,m,f);if(v==null)return;const y={unitId:t,subUnitId:o,drawingId:a,drawingType:b.DrawingTypeEnum.DRAWING_IMAGE,imageSourceType:c,source:d,transform:Y(v,this._selectionRenderService,this._skeletonManagerService),sheetTransform:v};this._commandService.executeCommand(oe.id,{unitId:t,drawings:[y]})}_getUnitInfo(){const n=this._context.unit,r=n.getActiveSheet(),e=n.getUnitId(),t=r.getSheetId();return{unitId:e,subUnitId:t}}_getImagePosition(n,r,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=j.attachRangeWithCoord(this._skeletonManagerService.getCurrent().skeleton,a);if(c==null)return;let{startColumn:d,startRow:g,startX:l,startY:s}=c,u=!1;if(l+n>e&&(l=e-n,l<0&&(l=0,n=e),u=!0),s+r>t&&(s=t-r,s<0&&(s=0,r=t),u=!0),u){const v=this._selectionRenderService.getCellWithCoordByOffset(l,s);if(v==null)return;l=v.startX,s=v.startY,d=v.actualColumn,g=v.actualRow}const m={column:d,columnOffset:0,row:g,rowOffset:0},f=this._selectionRenderService.getCellWithCoordByOffset(l+n,s+r);if(f==null)return;const S={column:f.actualColumn,columnOffset:l+n-f.startX,row:f.actualRow,rowOffset:s+r-f.startY};return{from:m,to:S}}_updateOrderListener(){this.disposeWithMe(this._drawingManagerService.featurePluginOrderUpdate$.subscribe(n=>{const{unitId:r,subUnitId:e,drawingIds:t,arrangeType:o}=n;this._commandService.executeCommand(Te.id,{unitId:r,subUnitId:e,drawingIds:t,arrangeType:o})}))}_updateImageListener(){this.disposeWithMe(this._drawingManagerService.featurePluginUpdate$.subscribe(n=>{const r=[];n.length!==0&&(n.forEach(e=>{const{unitId:t,subUnitId:o,drawingId:a,drawingType:c,transform:d}=e;if(d==null)return;const g=this._sheetDrawingService.getDrawingByParam({unitId:t,subUnitId:o,drawingId:a});if(g==null||g.unitId!==this._context.unitId)return;const l=k({...g.transform,...d},this._selectionRenderService);if(l==null)return;const s={...e,transform:{...g.transform,...d,...Y(l,this._selectionRenderService,this._skeletonManagerService)},sheetTransform:{...l}};r.push(s)}),r.length>0&&this._commandService.executeCommand(ae.id,{unitId:n[0].unitId,drawings:r}))}))}_groupDrawingListener(){this.disposeWithMe(this._drawingManagerService.featurePluginGroupUpdate$.subscribe(n=>{this._commandService.executeCommand(Re.id,n);const{unitId:r,subUnitId:e,drawingId:t}=n[0].parent;this._drawingManagerService.focusDrawing([{unitId:r,subUnitId:e,drawingId:t}])})),this.disposeWithMe(this._drawingManagerService.featurePluginUngroupUpdate$.subscribe(n=>{this._commandService.executeCommand(be.id,n)}))}_focusDrawingListener(){this.disposeWithMe(this._drawingManagerService.focus$.subscribe(n=>{n==null||n.length===0?(this._contextService.setContextValue(p.FOCUSING_COMMON_DRAWINGS,!1),this._sheetDrawingService.focusDrawing([])):(this._contextService.setContextValue(p.FOCUSING_COMMON_DRAWINGS,!0),this._sheetDrawingService.focusDrawing(n))}))}};ge=_t([z(1,p.Inject(j.SheetSkeletonManagerService)),z(2,p.ICommandService),z(3,j.ISheetSelectionRenderService),z(4,b.IImageIoService),z(5,$.ILocalFileService),z(6,h.ISheetDrawingService),z(7,b.IDrawingManagerService),z(8,p.IContextService),z(9,$.IMessageService),z(10,p.Inject(p.LocaleService)),z(11,p.Inject(I.SheetsSelectionsService))],ge);const pe={id:"sheet.command.insert-float-image",type:p.CommandType.COMMAND,handler:i=>{var r,e;return(e=(r=i.get(N.IRenderManagerService).getCurrentTypeOfRenderer(p.UniverInstanceType.UNIVER_SHEET))==null?void 0:r.with(ge).insertFloatImage())!=null?e:!1}},re={id:"sheet.command.move-drawing",type:p.CommandType.COMMAND,handler:(i,n)=>{const r=i.get(p.ICommandService),e=i.get(h.ISheetDrawingService),t=i.get(j.ISheetSelectionRenderService),{direction:o}=n,a=e.getFocusDrawings();if(a.length===0)return!1;const c=a[0].unitId,d=a.map(l=>{const{transform:s}=l;if(s==null)return null;const u={...s},{left:m=0,top:f=0}=s;return o===p.Direction.UP?u.top=f-1:o===p.Direction.DOWN?u.top=f+1:o===p.Direction.LEFT?u.left=m-1:o===p.Direction.RIGHT&&(u.left=m+1),{...l,transform:u,sheetTransform:k(u,t)}}).filter(l=>l!=null);return r.syncExecuteCommand(ae.id,{unitId:c,drawings:d})?(r.syncExecuteCommand(G.id,[c]),!0):!1}},$e="addition-and-subtraction-single",Ee="sheet.menu.image";function It(i){return{id:Ee,type:$.MenuItemType.SUBITEMS,icon:$e,tooltip:"sheetImage.title",hidden$:$.getMenuHiddenObservable(i,p.UniverInstanceType.UNIVER_SHEET),disabled$:j.getCurrentRangeDisable$(i,{workbookTypes:[I.WorkbookEditablePermission],worksheetTypes:[I.WorksheetEditPermission],rangeTypes:[I.RangeProtectionPermissionEditPoint]})}}function Ct(i){return{id:pe.id,title:"sheetImage.upload.float",type:$.MenuItemType.BUTTON,hidden$:$.getMenuHiddenObservable(i,p.UniverInstanceType.UNIVER_SHEET)}}const q={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 Fe(i){var n,r,e="";if(typeof i=="string"||typeof i=="number")e+=i;else if(typeof i=="object")if(Array.isArray(i)){var t=i.length;for(n=0;n<t;n++)i[n]&&(r=Fe(i[n]))&&(e&&(e+=" "),e+=r)}else for(r in i)i[r]&&(e&&(e+=" "),e+=r);return e}function he(){for(var i,n,r=0,e="",t=arguments.length;r<t;r++)(i=arguments[r])&&(n=Fe(i))&&(e&&(e+=" "),e+=n);return e}const yt=i=>{var C;const n=p.useDependency(p.ICommandService),r=p.useDependency(p.LocaleService),e=p.useDependency(b.IDrawingManagerService),t=p.useDependency(N.IRenderManagerService),{drawings:o}=i,a=o[0];if(a==null)return;const{unitId:c}=a,d=t.getRenderById(c),g=d==null?void 0:d.scene;if(g==null)return;const l=g.getTransformerByCreate(),[s,u]=H.useState(!0),m=(C=a.anchorType)!=null?C:h.SheetDrawingAnchorType.Position,[f,S]=H.useState(m);function v(T,_){const D=[];return T.forEach(w=>{const{oKey:A}=w,E=_.getDrawingOKey(A);if(E==null)return D.push(null),!0;const{unitId:L,subUnitId:U,drawingId:P,drawingType:R,anchorType:B,sheetTransform:V}=E;D.push({unitId:L,subUnitId:U,drawingId:P,anchorType:B,sheetTransform:V,drawingType:R})}),D}H.useEffect(()=>{const T=l.clearControl$.subscribe(D=>{D===!0&&u(!1)}),_=l.changeStart$.subscribe(D=>{var E;const{objects:w}=D,A=v(w,e);if(A.length===0)u(!1);else if(A.length>=1){u(!0);const L=((E=A[0])==null?void 0:E.anchorType)||h.SheetDrawingAnchorType.Position;S(L)}});return()=>{_.unsubscribe(),T.unsubscribe()}},[]);function y(T){S(T);const _=e.getFocusDrawings();if(_.length===0)return;const D=_.map(w=>({unitId:w.unitId,subUnitId:w.subUnitId,drawingId:w.drawingId,anchorType:T}));n.executeCommand(ae.id,{unitId:_[0].unitId,drawings:D})}const M=T=>T?"block":"none";return F.jsxs("div",{className:he(q.imageCommonPanelGrid,q.imageCommonPanelBorder),style:{display:M(s)},children:[F.jsx("div",{className:q.imageCommonPanelRow,children:F.jsx("div",{className:he(q.imageCommonPanelColumn,q.imageCommonPanelTitle),children:F.jsx("div",{children:r.t("drawing-anchor.title")})})}),F.jsx("div",{className:he(q.imageCommonPanelRow),children:F.jsx("div",{className:he(q.imageCommonPanelColumn),children:F.jsxs(Z.RadioGroup,{value:f,onChange:y,direction:"vertical",children:[F.jsx(Z.Radio,{value:h.SheetDrawingAnchorType.Both,children:r.t("drawing-anchor.both")}),F.jsx(Z.Radio,{value:h.SheetDrawingAnchorType.Position,children:r.t("drawing-anchor.position")}),F.jsx(Z.Radio,{value:h.SheetDrawingAnchorType.None,children:r.t("drawing-anchor.none")})]})})})]})},Mt=()=>{const i=p.useDependency(b.IDrawingManagerService),n=i.getFocusDrawings(),[r,e]=H.useState(n);return H.useEffect(()=>{const t=i.focus$.subscribe(o=>{e(o)});return()=>{t.unsubscribe()}},[]),!!(r!=null&&r.length)&&F.jsxs("div",{className:q.imageCommonPanel,children:[F.jsx(ee.DrawingCommonPanel,{drawings:r}),F.jsx(yt,{drawings:r})]})},Dt={[$.RibbonStartGroup.FORMULAS_INSERT]:{[Ee]:{order:3,menuItemFactory:It,[pe.id]:{order:0,menuItemFactory:Ct}}}};function se(i){return!i.getContextValue(p.FOCUSING_FX_BAR_EDITOR)&&!i.getContextValue(p.EDITOR_ACTIVATED)&&!i.getContextValue(p.FOCUSING_PANEL_EDITOR)&&i.getContextValue(p.FOCUSING_COMMON_DRAWINGS)}const Rt={id:re.id,description:"shortcut.sheet.drawing-move-down",group:"4_sheet-drawing-view",binding:$.KeyCode.ARROW_DOWN,priority:100,preconditions:se,staticParameters:{direction:p.Direction.DOWN}},Tt={id:re.id,description:"shortcut.sheet.drawing-move-up",group:"4_sheet-drawing-view",binding:$.KeyCode.ARROW_UP,priority:100,preconditions:se,staticParameters:{direction:p.Direction.UP}},bt={id:re.id,description:"shortcut.sheet.drawing-move-left",group:"4_sheet-drawing-view",binding:$.KeyCode.ARROW_LEFT,priority:100,preconditions:se,staticParameters:{direction:p.Direction.LEFT}},Et={id:re.id,description:"shortcut.sheet.drawing-move-right",group:"4_sheet-drawing-view",binding:$.KeyCode.ARROW_RIGHT,priority:100,preconditions:se,staticParameters:{direction:p.Direction.RIGHT}},Ot={id:De.id,description:"shortcut.sheet.drawing-delete",group:"4_sheet-drawing-view",preconditions:se,binding:$.KeyCode.DELETE,mac:$.KeyCode.BACKSPACE};var Pt=Object.defineProperty,At=Object.getOwnPropertyDescriptor,Ut=(i,n,r,e)=>{for(var t=e>1?void 0:e?At(n,r):n,o=i.length-1,a;o>=0;o--)(a=i[o])&&(t=(e?a(n,r,t):a(t))||t);return e&&t&&Pt(n,r,t),t},fe=(i,n)=>(r,e)=>n(r,e,i);let Se=class extends p.Disposable{constructor(i,n,r,e){super(),this._componentManager=i,this._menuManagerService=n,this._commandService=r,this._shortcutService=e,this._init()}_initCustomComponents(){const i=this._componentManager;this.disposeWithMe(i.register($e,Ve)),this.disposeWithMe(i.register(We,Mt))}_initMenus(){this._menuManagerService.mergeMenu(Dt)}_initCommands(){[pe,oe,ie,ae,Ce,G,ye,Re,be,re,De,Te].forEach(i=>this.disposeWithMe(this._commandService.registerCommand(i)))}_initShortcuts(){[Rt,Tt,bt,Et,Ot].forEach(i=>{this.disposeWithMe(this._shortcutService.registerShortcut(i))})}_init(){this._initCommands(),this._initCustomComponents(),this._initMenus(),this._initShortcuts()}};Se=Ut([fe(0,p.Inject($.ComponentManager)),fe(1,$.IMenuManagerService),fe(2,p.ICommandService),fe(3,$.IShortcutService)],Se);var Nt=Object.defineProperty,jt=Object.getOwnPropertyDescriptor,Wt=(i,n,r,e)=>{for(var t=e>1?void 0:e?jt(n,r):n,o=i.length-1,a;o>=0;o--)(a=i[o])&&(t=(e?a(n,r,t):a(t))||t);return e&&t&&Nt(n,r,t),t},Oe=(i,n)=>(r,e)=>n(r,e,i);let ve=class extends p.Disposable{constructor(n,r,e){super();X(this,"_copyInfo");this._sheetClipboardService=n,this._renderManagerService=r,this._sheetDrawingService=e,this._initCopyPaste()}_initCopyPaste(){this._sheetClipboardService.addClipboardHook({id:"SHEET_IMAGE_UI_PLUGIN",onBeforeCopy:(n,r,e)=>this._collect(n,r,e),onPasteCells:(n,r,e,t)=>{const{copyType:o=j.COPY_TYPE.COPY,pasteType:a}=t,{range:c}=n||{},{range:d,unitId:g,subUnitId:l}=r;return this._generateMutations(d,{copyType:o,pasteType:a,copyRange:c,unitId:g,subUnitId:l})},onPastePlainText:(n,r)=>({undos:[],redos:[]})})}_collect(n,r,e){var u;const t=(u=this._renderManagerService.getRenderById(n))==null?void 0:u.with(j.SheetSkeletonManagerService);if(!t)return;const o=t.attachRangeWithCoord(e);if(!o)return;const{startX:a,endX:c,startY:d,endY:g}=o,l=this._sheetDrawingService.getDrawingData(n,r),s=[];Object.keys(l).forEach(m=>{const f=l[m],{transform:S}=f;if(f.anchorType!==h.SheetDrawingAnchorType.Both||!S)return;const{left:v=0,top:y=0,width:M=0,height:C=0}=S,{drawingStartX:T,drawingEndX:_,drawingStartY:D,drawingEndY:w}={drawingStartX:v,drawingEndX:v+M,drawingStartY:y,drawingEndY:y+C};a<=T&&_<=c&&d<=D&&w<=g&&s.push(f)}),s.length&&(this._copyInfo={drawings:s,unitId:n,subUnitId:r})}_generateMutations(n,r){var E;if(!this._copyInfo)return{redos:[],undos:[]};if([j.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_COL_WIDTH,j.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_VALUE,j.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMAT,j.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMULA].includes(r.pasteType))return{redos:[],undos:[]};const{copyRange:e}=r;if(!e)return{redos:[],undos:[]};const{drawings:t,unitId:o,subUnitId:a}=this._copyInfo,{ranges:[c,d],mapFunc:g}=j.virtualizeDiscreteRanges([e,n]),{row:l,col:s}=g(c.startRow,c.startColumn),{row:u,col:m}=g(d.startRow,d.startColumn),f=(E=this._renderManagerService.getRenderById(o))==null?void 0:E.with(j.SheetSkeletonManagerService);if(!f)return{redos:[],undos:[]};const S=f.attachRangeWithCoord({startRow:l,endRow:l,startColumn:s,endColumn:s}),v=f.attachRangeWithCoord({startRow:u,endRow:u,startColumn:m,endColumn:m});if(!S||!v)return{redos:[],undos:[]};const y=[],M=[],C=v.startX-S.startX,T=v.startY-S.startY,_=u-l,D=m-s,w=r.copyType===j.COPY_TYPE.CUT,{_sheetDrawingService:A}=this;return t.forEach(L=>{const{transform:U,sheetTransform:P}=L;if(!U)return;const R={...L,unitId:o,subUnitId:a,drawingId:w?L.drawingId:p.Tools.generateRandomId(),transform:{...U,left:U.left+C,top:U.top+T},sheetTransform:{to:{...P.to,row:P.to.row+_,column:P.to.column+D},from:{...P.from,row:P.from.row+_,column:P.from.column+D}}};if(w){const{undo:B,redo:V,objects:J}=A.getBatchUpdateOp([R]);y.push({id:h.SetDrawingApplyMutation.id,params:{unitId:o,subUnitId:a,type:h.DrawingApplyType.UPDATE,op:V,objects:J}}),M.push({id:h.SetDrawingApplyMutation.id,params:{unitId:o,subUnitId:a,type:h.DrawingApplyType.UPDATE,op:B,objects:J}})}else{const{undo:B,redo:V,objects:J}=A.getBatchAddOp([R]);y.push({id:h.SetDrawingApplyMutation.id,params:{op:V,unitId:o,subUnitId:a,objects:J,type:h.DrawingApplyType.INSERT}}),M.push({id:h.SetDrawingApplyMutation.id,params:{op:B,unitId:o,subUnitId:a,objects:J,type:h.DrawingApplyType.REMOVE}})}}),{redos:y,undos:M}}};ve=Wt([Oe(0,j.ISheetClipboardService),Oe(1,N.IRenderManagerService),Oe(2,h.ISheetDrawingService)],ve);var Lt=Object.defineProperty,Bt=Object.getOwnPropertyDescriptor,Gt=(i,n,r,e)=>{for(var t=e>1?void 0:e?Bt(n,r):n,o=i.length-1,a;o>=0;o--)(a=i[o])&&(t=(e?a(n,r,t):a(t))||t);return e&&t&&Lt(n,r,t),t},ce=(i,n)=>(r,e)=>n(r,e,i);let we=class extends p.Disposable{constructor(i,n,r,e,t){super(),this._drawingManagerService=i,this._renderManagerService=n,this._permissionService=r,this._univerInstanceService=e,this._userManagerService=t,this._initDrawingVisible(),this._initDrawingEditable(),this._initViewPermissionChange(),this._initEditPermissionChange()}_initDrawingVisible(){const i=this._univerInstanceService.getCurrentTypeOfUnit$(p.UniverInstanceType.UNIVER_SHEET);this.disposeWithMe(W.combineLatest([i,this._userManagerService.currentUser$]).subscribe(([n,r])=>{if(!n){this._drawingManagerService.setDrawingVisible(!1);return}n.activeSheet$.subscribe(e=>{if(!e){this._drawingManagerService.setDrawingVisible(!1);return}const t=n.getUnitId(),o=e.getSheetId();if(this._permissionService.composePermission([new I.WorkbookViewPermission(t).id,new I.WorksheetViewPermission(t,o).id]).every(c=>c.value))this._drawingManagerService.setDrawingVisible(!0);else{this._drawingManagerService.setDrawingVisible(!1);const c=n.getUnitId(),d=e.getSheetId(),g=this._drawingManagerService.getDrawingData(c,d),l=Object.values(g),s=this._renderManagerService.getRenderById(c),u=s==null?void 0:s.scene;if(u==null)return;u.getAllObjectsByOrder().forEach(f=>{f.classType===N.RENDER_CLASS_TYPE.IMAGE&&l.some(S=>f.oKey.includes(S.drawingId))&&u.removeObject(f)})}})}))}_initDrawingEditable(){const i=this._univerInstanceService.getCurrentTypeOfUnit$(p.UniverInstanceType.UNIVER_SHEET);this.disposeWithMe(W.combineLatest([i,this._userManagerService.currentUser$]).subscribe(([n,r])=>{if(!n){this._drawingManagerService.setDrawingEditable(!1);return}n.activeSheet$.subscribe(e=>{if(!e){this._drawingManagerService.setDrawingEditable(!1);return}const t=n.getUnitId(),o=e.getSheetId();if(this._permissionService.composePermission([new I.WorkbookEditablePermission(t).id,new I.WorksheetEditPermission(t,o).id]).every(c=>c.value))this._drawingManagerService.setDrawingEditable(!0);else{this._drawingManagerService.setDrawingEditable(!1);const c=n.getUnitId(),d=e.getSheetId(),g=this._drawingManagerService.getDrawingData(c,d),l=Object.values(g),s=this._renderManagerService.getRenderById(c),u=s==null?void 0:s.scene;if(u==null)return;u.getAllObjectsByOrder().forEach(f=>{f.classType===N.RENDER_CLASS_TYPE.IMAGE&&l.some(S=>f.oKey.includes(S.drawingId))&&u.detachTransformerFrom(f)})}})}))}_initViewPermissionChange(){const i=this._univerInstanceService.getCurrentTypeOfUnit$(p.UniverInstanceType.UNIVER_SHEET);this.disposeWithMe(W.combineLatest([i,this._userManagerService.currentUser$]).subscribe(([n,r])=>{n&&n.activeSheet$.subscribe(e=>{var s;if(!e)return;const t=n.getUnitId(),o=e.getSheetId();let a=!0;const c=this._renderManagerService.getRenderById(t),d=c==null?void 0:c.scene;if(d==null)return;const g=d.getTransformerByCreate(),l=this._permissionService.composePermission$([new I.WorkbookViewPermission(t).id,new I.WorksheetViewPermission(t,o).id]).pipe(W.map(u=>u.every(m=>m.value)));l==null||l.pipe(W.filter(u=>u!==a),W.distinctUntilChanged()).subscribe({next:u=>{a=u,this._drawingManagerService.setDrawingVisible(u);const m=d.getAllObjectsByOrder(),f=this._drawingManagerService.getDrawingData(t,o),S=Object.values(f);u?this._drawingManagerService.addNotification(S):(m.forEach(v=>{v.classType===N.RENDER_CLASS_TYPE.IMAGE&&S.some(y=>v.oKey.includes(y.drawingId))&&d.removeObject(v)}),g.clearSelectedObjects())}}),(s=this._permissionService.getPermissionPoint$(new I.WorksheetViewPermission(t,o).id))==null||s.pipe(W.filter(u=>u.value!==a),W.distinctUntilChanged()).subscribe({complete:()=>{a=!0,this._drawingManagerService.setDrawingVisible(!0);const u=this._drawingManagerService.getDrawingData(t,o),m=Object.values(u);this._drawingManagerService.addNotification(m)}})})}))}_initEditPermissionChange(){const i=this._univerInstanceService.getCurrentTypeOfUnit$(p.UniverInstanceType.UNIVER_SHEET);this.disposeWithMe(W.combineLatest([i,this._userManagerService.currentUser$]).subscribe(([n,r])=>{n&&n.activeSheet$.subscribe(e=>{var s;if(!e)return;const t=n.getUnitId(),o=e.getSheetId();let a=!0;const c=this._renderManagerService.getRenderById(t),d=c==null?void 0:c.scene;if(d==null)return;const g=d.getTransformerByCreate(),l=this._permissionService.composePermission$([new I.WorkbookEditablePermission(t).id,new I.WorksheetEditPermission(t,o).id]).pipe(W.map(u=>u.every(m=>m.value)));l==null||l.pipe(W.filter(u=>u!==a),W.distinctUntilChanged()).subscribe({next:u=>{a=u,this._drawingManagerService.setDrawingEditable(u);const m=d.getAllObjectsByOrder(),f=this._drawingManagerService.getDrawingData(t,o),S=Object.values(f);u?(m.forEach(v=>{v.classType===N.RENDER_CLASS_TYPE.IMAGE&&S.some(y=>v.oKey.includes(y.drawingId))&&d.attachTransformerTo(v)}),this._drawingManagerService.addNotification(S)):(m.forEach(v=>{v.classType===N.RENDER_CLASS_TYPE.IMAGE&&S.some(y=>v.oKey.includes(y.drawingId))&&d.detachTransformerFrom(v)}),g.clearSelectedObjects())}}),(s=this._permissionService.getPermissionPoint$(new I.WorksheetEditPermission(t,o).id))==null||s.pipe(W.filter(u=>u.value!==a),W.distinctUntilChanged()).subscribe({complete:()=>{a=!0;const u=n.getUnitId(),m=e.getSheetId(),f=this._drawingManagerService.getDrawingData(u,m),S=Object.values(f),v=this._renderManagerService.getRenderById(u),y=v==null?void 0:v.scene;if(y==null)return;this._drawingManagerService.setDrawingEditable(!0),y.getAllObjectsByOrder().forEach(C=>{C.classType===N.RENDER_CLASS_TYPE.IMAGE&&S.some(T=>C.oKey.includes(T.drawingId))&&y.detachTransformerFrom(C)})}})})}))}};we=Gt([ce(0,b.IDrawingManagerService),ce(1,N.IRenderManagerService),ce(2,p.IPermissionService),ce(3,p.IUniverInstanceService),ce(4,p.Inject(p.UserManagerService))],we);var kt=Object.defineProperty,Vt=Object.getOwnPropertyDescriptor,$t=(i,n,r,e)=>{for(var t=e>1?void 0:e?Vt(n,r):n,o=i.length-1,a;o>=0;o--)(a=i[o])&&(t=(e?a(n,r,t):a(t))||t);return e&&t&&kt(n,r,t),t},_e=(i,n)=>(r,e)=>n(r,e,i);let Ie=class extends p.Disposable{constructor(i,n,r,e){super(),this._sheetPrintInterceptorService=i,this._drawingRenderService=n,this._drawingManagerService=r,this._renderManagerService=e,this._initPrinting()}_initPrinting(){this.disposeWithMe(this._sheetPrintInterceptorService.interceptor.intercept(this._sheetPrintInterceptorService.interceptor.getInterceptPoints().PRINTING_COMPONENT_COLLECT,{handler:(i,n,r)=>{const{unitId:e,scene:t,subUnitId:o}=n,a=this._drawingManagerService.getDrawingDataForUnit(e),c=a==null?void 0:a[o];return c&&c.order.forEach(d=>{this._drawingRenderService.renderDrawing(c.data[d],t)}),r()}})),this.disposeWithMe(this._sheetPrintInterceptorService.interceptor.intercept(this._sheetPrintInterceptorService.interceptor.getInterceptPoints().PRINTING_RANGE,{handler:(i,n,r)=>{const{unitId:e,subUnitId:t}=n,o=this._renderManagerService.getRenderById(e);if(!o)return r(i);const a=o.with(j.SheetSkeletonManagerService).getWorksheetSkeleton(t);if(!a)return r(i);const c=this._drawingManagerService.getDrawingDataForUnit(e),d=c==null?void 0:c[n.subUnitId];if(!d)return r(i);const{scaleX:g,scaleY:l}=o.scene,s=i?{...i}:{startColumn:0,endColumn:0,endRow:0,startRow:0},u=d.order.map(m=>d.data[m]).filter(m=>m.drawingType!==b.DrawingTypeEnum.DRAWING_DOM);return u.length?(u.forEach(m=>{if(!m.groupId&&m.transform&&p.Tools.isDefine(m.transform.left)&&p.Tools.isDefine(m.transform.top)&&p.Tools.isDefine(m.transform.width)&&p.Tools.isDefine(m.transform.height)){const f=a.skeleton.getCellIndexByOffset(m.transform.left,m.transform.top,g,l,{x:0,y:0}),S=a.skeleton.getCellIndexByOffset(m.transform.left+m.transform.width,m.transform.top+m.transform.height,g,l,{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)}}),r(s)):r(i)}}))}};Ie=$t([_e(0,p.Inject(j.SheetPrintInterceptorService)),_e(1,p.Inject(ee.DrawingRenderService)),_e(2,b.IDrawingManagerService),_e(3,N.IRenderManagerService)],Ie);var Ft=Object.defineProperty,Yt=Object.getOwnPropertyDescriptor,Ht=(i,n,r,e)=>{for(var t=e>1?void 0:e?Yt(n,r):n,o=i.length-1,a;o>=0;o--)(a=i[o])&&(t=(e?a(n,r,t):a(t))||t);return e&&t&&Ft(n,r,t),t},Q=(i,n)=>(r,e)=>n(r,e,i);const xt=[I.InsertRowCommand.id,I.InsertColCommand.id,I.RemoveRowCommand.id,I.RemoveColCommand.id,I.DeleteRangeMoveLeftCommand.id,I.DeleteRangeMoveUpCommand.id,I.InsertRangeMoveDownCommand.id,I.InsertRangeMoveRightCommand.id,I.DeltaRowHeightCommand.id,I.SetRowHeightCommand.id,I.DeltaColumnWidthCommand.id,I.SetColWidthCommand.id,I.SetRowHiddenCommand.id,I.SetSpecificRowsVisibleCommand.id,I.SetSpecificColsVisibleCommand.id,I.SetColHiddenCommand.id,I.MoveColsCommand.id,I.MoveRowsCommand.id,I.MoveRangeCommand.id],Xt=[I.SetRowVisibleMutation.id,I.SetRowHiddenMutation.id,I.SetColVisibleMutation.id,I.SetColHiddenMutation.id,I.SetWorksheetRowHeightMutation.id,I.SetWorksheetColWidthMutation.id];let Pe=class extends p.Disposable{constructor(i,n,r,e,t,o,a,c,d){super(),this._context=i,this._renderManagerService=n,this._commandService=r,this._selectionRenderService=e,this._skeletonManagerService=t,this._sheetInterceptorService=o,this._sheetDrawingService=a,this._drawingManagerService=c,this._univerInstanceService=d,this._sheetInterceptorListener(),this._commandListener(),this._sheetRefreshListener()}_sheetInterceptorListener(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:i=>{if(!xt.includes(i.id))return{redos:[],undos:[]};if(i.params==null)return{redos:[],undos:[]};const n=i.id;if(n===I.InsertRowCommand.id)return this._moveRowInterceptor(i.params,"insert");if([I.MoveColsCommand.id,I.MoveRowsCommand.id,I.MoveRangeCommand.id].includes(n))return this._moveRangeInterceptor(i.params);if(n===I.InsertColCommand.id)return this._moveColInterceptor(i.params,"insert");if(n===I.RemoveRowCommand.id)return this._moveRowInterceptor(i.params,"remove");if(n===I.RemoveColCommand.id)return this._moveColInterceptor(i.params,"remove");if(n===I.DeleteRangeMoveLeftCommand.id){const{range:r}=i.params;return this._getRangeMoveUndo(r,0)}else if(n===I.DeleteRangeMoveUpCommand.id){const{range:r}=i.params;return this._getRangeMoveUndo(r,1)}else if(n===I.InsertRangeMoveDownCommand.id){const{range:r}=i.params;return this._getRangeMoveUndo(r,2)}else if(n===I.InsertRangeMoveRightCommand.id){const{range:r}=i.params;return this._getRangeMoveUndo(r,3)}else if(n===I.SetRowHiddenCommand.id||n===I.SetSpecificRowsVisibleCommand.id){const r=i.params,{unitId:e,subUnitId:t,ranges:o}=r;return this._getDrawingUndoForRowVisible(e,t,o)}else if(n===I.SetSpecificColsVisibleCommand.id||n===I.SetColHiddenCommand.id){const r=i.params,{unitId:e,subUnitId:t,ranges:o}=r;return this._getDrawingUndoForColVisible(e,t,o)}else if(n===I.DeltaRowHeightCommand.id||n===I.SetRowHeightCommand.id||n===I.DeltaColumnWidthCommand.id||n===I.SetColWidthCommand.id){const r=i.params,{unitId:e,subUnitId:t,ranges:o}=r,a=n===I.DeltaRowHeightCommand.id||n===I.SetRowHeightCommand.id;return this._getDrawingUndoForRowAndColSize(e,t,o,a)}return{redos:[],undos:[]}}}))}_getRangeMoveUndo(i,n){const r=I.getSheetCommandTarget(this._univerInstanceService);if(r==null)return{redos:[],undos:[]};const e=r.unitId,t=r.subUnitId,o=[],a=[],c=this._sheetDrawingService.getDrawingData(e,t),d=[],g=[];if(Object.keys(c).forEach(l=>{const s=c[l],{updateDrawings:u,deleteDrawings:m}=this._getUpdateOrDeleteDrawings(i,n,s);d.push(...u),g.push(...m)}),d.length===0&&g.length===0)return{redos:[],undos:[]};if(d.length>0){const l=this._sheetDrawingService.getBatchUpdateOp(d),{undo:s,redo:u,objects:m}=l;o.push({id:h.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:u,objects:m,type:h.DrawingApplyType.UPDATE}}),a.push({id:h.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:s,objects:m,type:h.DrawingApplyType.UPDATE}})}if(g.length>0){const l=this._sheetDrawingService.getBatchRemoveOp(g),s=l.undo,u=l.redo,m=l.objects;o.push({id:h.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:u,objects:m,type:h.DrawingApplyType.REMOVE}}),a.push({id:h.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:s,objects:m,type:h.DrawingApplyType.INSERT}})}return o.push({id:G.id,params:[e]}),a.push({id:G.id,params:[e]}),{redos:o,undos:a}}_getUpdateOrDeleteDrawings(i,n,r){const e=[],t=[],{sheetTransform:o,anchorType:a=h.SheetDrawingAnchorType.Position,transform:c,unitId:d,subUnitId:g,drawingId:l}=r,{from:s,to:u}=o,{row:m,column:f}=s,{row:S,column:v}=u;if(o==null||c==null)return{updateDrawings:e,deleteDrawings:t};const{startRow:y,endRow:M,startColumn:C,endColumn:T}=i;let _=null,D=null;if(n===0&&m>=y&&S<=M)if(f>=C&&v<=T)t.push({unitId:d,subUnitId:g,drawingId:l});else{const w=this._shrinkCol(o,c,C,T,a);_=w==null?void 0:w.newSheetTransform,D=w==null?void 0:w.newTransform}else if(n===1&&f>=C&&v<=T)if(m>=y&&S<=M)t.push({unitId:d,subUnitId:g,drawingId:l});else{const w=this._shrinkRow(o,c,y,M,a);_=w==null?void 0:w.newSheetTransform,D=w==null?void 0:w.newTransform}else if(n===2){const w=this._expandRow(o,c,y,M,a);_=w==null?void 0:w.newSheetTransform,D=w==null?void 0:w.newTransform}else if(n===3){const w=this._expandCol(o,c,C,T,a);_=w==null?void 0:w.newSheetTransform,D=w==null?void 0:w.newTransform}if(_!=null&&D!=null){const w=Y(_,this._selectionRenderService,this._skeletonManagerService);e.push({...r,sheetTransform:_,transform:w})}return{updateDrawings:e,deleteDrawings:t}}_remainDrawingSize(i,n,r){const e=k({...i},this._selectionRenderService);e!=null&&n.push({...r,sheetTransform:e})}_getDrawingUndoForColVisible(i,n,r){const e=this._drawingManagerService.getDrawingData(i,n),t=[],o=[];if(Object.keys(e).forEach(l=>{const s=e[l],{sheetTransform:u,transform:m,anchorType:f=h.SheetDrawingAnchorType.Position}=s;if(f===h.SheetDrawingAnchorType.None)this._remainDrawingSize(m,t,s);else{const{from:S,to:v}=u,{row:y,column:M}=S,{row:C,column:T}=v;for(let _=0;_<r.length;_++){const D=r[_],{startRow:w,endRow:A,startColumn:E,endColumn:L}=D;if(T<E)continue;if(f===h.SheetDrawingAnchorType.Position){let R=null,B=null;if(M>=E&&M<=L){const V=this._skeletonManagerService.attachRangeWithCoord({startColumn:M,endColumn:L,startRow:S.row,endRow:v.row});if(V==null)return;B={...m,left:V.startX}}if(B!=null&&(R=k(B,this._selectionRenderService),R!=null&&B!=null)){t.push({...s,sheetTransform:R,transform:B});break}this._remainDrawingSize(m,t,s);continue}if(M>=E&&T<=L)continue;let U=null,P=null;if(M>=E&&M<=L){const R=this._skeletonManagerService.attachRangeWithCoord({startColumn:M,endColumn:L,startRow:S.row,endRow:v.row});if(R==null)return;P={...m,left:(R==null?void 0:R.startX)||0,width:((m==null?void 0:m.width)||0)-R.endX+R.startX}}else if(T>=E&&T<=L){const R=this._skeletonManagerService.attachRangeWithCoord({startColumn:E,endColumn:T,startRow:S.row,endRow:v.row});if(R==null)return;P={...m,left:R.startX-((m==null?void 0:m.width)||0)}}else{const R=this._skeletonManagerService.attachRangeWithCoord({startColumn:E,endColumn:L,startRow:S.row,endRow:v.row});if(R==null)return;if(P={...m,width:((m==null?void 0:m.width)||0)-R.endX+R.startX},U=k(P,this._selectionRenderService),U!=null&&P!=null){o.push({...s,sheetTransform:U,transform:P});break}}if(P!=null&&(U=k(P,this._selectionRenderService)),P!=null&&U!=null){t.push({...s,sheetTransform:U,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,n,t),d=[],g=[];if(o.length>0){const{redos:l,undos:s}=this._createUndoAndRedoMutation(i,n,o);d.push(...l),g.push(...s)}return{redos:a,undos:c,preRedos:d,preUndos:g}}_createUndoAndRedoMutation(i,n,r){const e=this._sheetDrawingService.getBatchUpdateOp(r),{undo:t,redo:o,objects:a}=e,c=[{id:h.SetDrawingApplyMutation.id,params:{unitId:i,subUnitId:n,op:o,objects:a,type:h.DrawingApplyType.UPDATE}},{id:G.id,params:[i]}],d=[{id:h.SetDrawingApplyMutation.id,params:{unitId:i,subUnitId:n,op:t,objects:a,type:h.DrawingApplyType.UPDATE}},{id:G.id,params:[i]}];return{redos:c,undos:d}}_getDrawingUndoForRowVisible(i,n,r){const e=this._drawingManagerService.getDrawingData(i,n),t=[],o=[];if(Object.keys(e).forEach(l=>{const s=e[l],{sheetTransform:u,transform:m,anchorType:f=h.SheetDrawingAnchorType.Position}=s;if(f===h.SheetDrawingAnchorType.None)this._remainDrawingSize(m,t,s);else{const{from:S,to:v}=u,{row:y,column:M}=S,{row:C,column:T}=v;for(let _=0;_<r.length;_++){const D=r[_],{startRow:w,endRow:A,startColumn:E,endColumn:L}=D;if(C<w)continue;if(f===h.SheetDrawingAnchorType.Position){let R=null,B=null;if(y>=w&&y<=A){const V=this._skeletonManagerService.attachRangeWithCoord({startColumn:S.column,endColumn:v.column,startRow:y,endRow:A});if(V==null)return;B={...m,top:V.startY}}if(B!=null&&(R=k(B,this._selectionRenderService),R!=null&&B!=null)){t.push({...s,sheetTransform:R,transform:B});break}this._remainDrawingSize(m,t,s);continue}if(y>=w&&C<=A)continue;let U=null,P=null;if(y>=w&&y<=A){const R=this._skeletonManagerService.attachRangeWithCoord({startColumn:S.column,endColumn:v.column,startRow:y,endRow:A});if(R==null)return;P={...m,top:(R==null?void 0:R.startY)||0,height:((m==null?void 0:m.height)||0)-R.endY+R.startY}}else if(C>=w&&C<=A){const R=this._skeletonManagerService.attachRangeWithCoord({startColumn:S.column,endColumn:v.column,startRow:w,endRow:C});if(R==null)return;P={...m,top:R.startY-((m==null?void 0:m.height)||0)}}else{const R=this._skeletonManagerService.attachRangeWithCoord({startColumn:S.column,endColumn:v.column,startRow:w,endRow:A});if(R==null)return;if(P={...m,height:((m==null?void 0:m.height)||0)-R.endY+R.startY},U=k(P,this._selectionRenderService),U!=null&&P!=null){o.push({...s,sheetTransform:U,transform:P});break}}if(P!=null&&(U=k(P,this._selectionRenderService)),P!=null&&U!=null){t.push({...s,sheetTransform:U,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,n,t),d=[],g=[];if(o.length>0){const{redos:l,undos:s}=this._createUndoAndRedoMutation(i,n,o);d.push(...l),g.push(...s)}return{redos:a,undos:c,preRedos:d,preUndos:g}}_getDrawingUndoForRowAndColSize(i,n,r,e){const t=this._drawingManagerService.getDrawingData(i,n),o=[];return Object.keys(t).forEach(a=>{const c=t[a],{sheetTransform:d,transform:g,anchorType:l=h.SheetDrawingAnchorType.Position}=c;if(l===h.SheetDrawingAnchorType.None)this._remainDrawingSize(g,o,c);else{const{from:s,to:u}=d,{row:m,column:f}=s,{row:S,column:v}=u;for(let y=0;y<r.length;y++){const M=r[y],{startRow:C,endRow:T,startColumn:_,endColumn:D}=M;if(S<C||v<_)continue;if(l===h.SheetDrawingAnchorType.Position&&(m<=C&&S>=T||f<=_&&v>=D)){this._remainDrawingSize(g,o,c);continue}const w=Y({...d},this._selectionRenderService,this._skeletonManagerService);if(w!=null){o.push({...c,transform:w});break}}}}),o.length===0?{redos:[],undos:[]}:this._createUndoAndRedoMutation(i,n,o)}_getUnitIdAndSubUnitId(i,n){let r,e;if(n==="insert")r=i.unitId,e=i.subUnitId;else{const t=I.getSheetCommandTarget(this._univerInstanceService);if(t==null)return;r=t.unitId,e=t.subUnitId}return{unitId:r,subUnitId:e}}_moveRangeInterceptor(i){var C,T;const{toRange:n,fromRange:r}=i,e=I.getSheetCommandTarget(this._univerInstanceService);if(!e)return{redos:[],undos:[]};const{unitId:t,subUnitId:o}=e,a=(T=(C=this._renderManagerService.getRenderById(t))==null?void 0:C.with(j.SheetSkeletonManagerService))==null?void 0:T.getCurrentSkeleton();if(!a)return{redos:[],undos:[]};const c=j.attachRangeWithCoord(a,r);if(!c)return{redos:[],undos:[]};const{startX:d,endX:g,startY:l,endY:s}=c,u=this._sheetDrawingService.getDrawingData(t,o),m=[];Object.keys(u).forEach(_=>{const D=u[_];if(D.anchorType!==h.SheetDrawingAnchorType.Both)return;const{transform:w}=D;if(!w)return;const{left:A=0,top:E=0,width:L=0,height:U=0}=w,{drawingStartX:P,drawingEndX:R,drawingStartY:B,drawingEndY:V}={drawingStartX:A,drawingEndX:A+L,drawingStartY:E,drawingEndY:E+U};d<=P&&R<=g&&l<=B&&V<=s&&m.push(D)});const f=[],S=[],v=n.startRow-r.startRow,y=n.startColumn-r.startColumn,M=m.map(_=>{const D=_.sheetTransform,w={to:{...D.to,row:D.to.row+v,column:D.to.column+y},from:{...D.from,row:D.from.row+v,column:D.from.column+y}},A=Y(w,this._selectionRenderService,this._skeletonManagerService);return{unitId:t,subUnitId:o,drawingId:_.drawingId,transform:A,sheetTransform:w}});if(M.length){const _=this._sheetDrawingService.getBatchUpdateOp(M),{undo:D,redo:w,objects:A}=_;f.push({id:h.SetDrawingApplyMutation.id,params:{unitId:t,subUnitId:o,op:w,objects:A,type:h.DrawingApplyType.UPDATE}}),S.push({id:h.SetDrawingApplyMutation.id,params:{unitId:t,subUnitId:o,op:D,objects:A,type:h.DrawingApplyType.UPDATE}})}return{redos:f,undos:S}}_moveRowInterceptor(i,n){const r=this._getUnitIdAndSubUnitId(i,n);if(r==null)return{redos:[],undos:[]};const{unitId:e,subUnitId:t}=r,{range:o}=i,a=o.startRow,c=o.endRow,d=[],g=[],l=this._sheetDrawingService.getDrawingData(e,t),s=[],u=[];if(Object.keys(l).forEach(m=>{const f=l[m],{sheetTransform:S,transform:v,anchorType:y=h.SheetDrawingAnchorType.Position}=f;if(S==null||v==null)return;let M,C;if(n==="insert"){const _=this._expandRow(S,v,a,c,y);M=_==null?void 0:_.newSheetTransform,C=_==null?void 0:_.newTransform}else{const{from:_,to:D}=S,{row:w}=_,{row:A}=D;if(y===h.SheetDrawingAnchorType.Both&&w>=a&&A<=c)u.push({unitId:e,subUnitId:t,drawingId:m});else{const E=this._shrinkRow(S,v,a,c,y);M=E==null?void 0:E.newSheetTransform,C=E==null?void 0:E.newTransform}}if(!M||!C)return;const T={unitId:e,subUnitId:t,drawingId:m,transform:C,sheetTransform:M};s.push(T)}),s.length===0&&u.length===0)return{redos:[],undos:[]};if(s.length>0){const m=this._sheetDrawingService.getBatchUpdateOp(s),{undo:f,redo:S,objects:v}=m;d.push({id:h.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:S,objects:v,type:h.DrawingApplyType.UPDATE}}),g.push({id:h.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:f,objects:v,type:h.DrawingApplyType.UPDATE}})}if(u.length>0){const m=this._sheetDrawingService.getBatchRemoveOp(u),f=m.undo,S=m.redo,v=m.objects;d.push({id:h.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:S,objects:v,type:h.DrawingApplyType.REMOVE}}),g.push({id:h.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:f,objects:v,type:h.DrawingApplyType.INSERT}})}return d.push({id:G.id,params:[e]}),g.push({id:G.id,params:[e]}),{redos:d,undos:g}}_moveColInterceptor(i,n){const r=this._getUnitIdAndSubUnitId(i,n);if(r==null)return{redos:[],undos:[]};const{unitId:e,subUnitId:t}=r,{range:o}=i,a=o.startColumn,c=o.endColumn,d=[],g=[],l=this._sheetDrawingService.getDrawingData(e,t),s=[],u=[];if(Object.keys(l).forEach(m=>{const f=l[m],{sheetTransform:S,transform:v,anchorType:y=h.SheetDrawingAnchorType.Position}=f;if(S==null||v==null)return;let M,C;if(n==="insert"){const _=this._expandCol(S,v,a,c,y);M=_==null?void 0:_.newSheetTransform,C=_==null?void 0:_.newTransform}else{const{from:_,to:D}=S,{column:w}=_,{column:A}=D;if(y===h.SheetDrawingAnchorType.Both&&w>=a&&A<=c)u.push({unitId:e,subUnitId:t,drawingId:m});else{const E=this._shrinkCol(S,v,a,c,y);M=E==null?void 0:E.newSheetTransform,C=E==null?void 0:E.newTransform}}if(!M||!C)return;const T={unitId:e,subUnitId:t,drawingId:m,transform:C,sheetTransform:M};s.push(T)}),s.length===0&&u.length===0)return{redos:[],undos:[]};if(s.length>0){const m=this._sheetDrawingService.getBatchUpdateOp(s),{undo:f,redo:S,objects:v}=m;d.push({id:h.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:S,objects:v,type:h.DrawingApplyType.UPDATE}}),g.push({id:h.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:f,objects:v,type:h.DrawingApplyType.UPDATE}})}if(u.length>0){const m=this._sheetDrawingService.getBatchRemoveOp(u),f=m.undo,S=m.redo,v=m.objects;d.push({id:h.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:S,objects:v,type:h.DrawingApplyType.REMOVE}}),g.push({id:h.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:f,objects:v,type:h.DrawingApplyType.INSERT}})}return d.push({id:G.id,params:[e]}),g.push({id:G.id,params:[e]}),{redos:d,undos:g}}_expandCol(i,n,r,e,t=h.SheetDrawingAnchorType.Position){const o=e-r+1,{from:a,to:c}=i,{column:d}=a,{column:g}=c;if(t===h.SheetDrawingAnchorType.None)return{newSheetTransform:k({...n},this._selectionRenderService),newTransform:n};let l=null,s=null;if(d>=r){const u=this._skeletonManagerService.attachRangeWithCoord({startColumn:r,endColumn:e,startRow:a.row,endRow:c.row});if(u==null)return;s={...n,left:(n.left||0)+u.endX-u.startX},l=k(s,this._selectionRenderService)}else if(g>=e)if(t===h.SheetDrawingAnchorType.Both)l={from:{...a},to:{...c,column:g+o}},s=Y(l,this._selectionRenderService,this._skeletonManagerService);else return{newSheetTransform:k({...n},this._selectionRenderService),newTransform:n};return l!=null&&s!=null?{newSheetTransform:l,newTransform:s}:null}_shrinkCol(i,n,r,e,t=h.SheetDrawingAnchorType.Position){const o=e-r+1,{from:a,to:c}=i,{column:d}=a,{column:g}=c;if(t===h.SheetDrawingAnchorType.None)return{newSheetTransform:k({...n},this._selectionRenderService),newTransform:n};let l=null,s=null;if(d>e)l={from:{...a,column:d-o},to:{...c,column:g-o}},s=Y(l,this._selectionRenderService,this._skeletonManagerService);else{if(d>=r&&g<=e)return null;if(d<r&&g>e)if(t===h.SheetDrawingAnchorType.Both)l={from:{...a},to:{...c,column:g-o}},s=Y(l,this._selectionRenderService,this._skeletonManagerService);else return{newSheetTransform:k({...n},this._selectionRenderService),newTransform:n};else if(d>=r&&d<=e){if(d===r)s={...n,left:(n.left||0)-i.from.columnOffset};else{const u=this._skeletonManagerService.attachRangeWithCoord({startColumn:r,endColumn:d-1,startRow:a.row,endRow:c.row});if(u==null)return;s={...n,left:(n.left||0)-u.endX+u.startX-i.from.columnOffset}}l=k(s,this._selectionRenderService)}else if(g>=r&&g<=e&&t===h.SheetDrawingAnchorType.Both){const u=this._skeletonManagerService.attachRangeWithCoord({startColumn:r-1,endColumn:r-1,startRow:a.row,endRow:c.row});if(u==null)return;l={from:{...a},to:{...c,column:r-1,columnOffset:u.endX-u.startX}},s=Y(l,this._selectionRenderService,this._skeletonManagerService)}}return l!=null&&s!=null?{newSheetTransform:l,newTransform:s}:null}_expandRow(i,n,r,e,t=h.SheetDrawingAnchorType.Position){const o=e-r+1,{from:a,to:c}=i,{row:d}=a,{row:g}=c;if(t===h.SheetDrawingAnchorType.None)return{newSheetTransform:k({...n},this._selectionRenderService),newTransform:n};let l=null,s=null;if(d>=r){const u=this._skeletonManagerService.attachRangeWithCoord({startRow:r,endRow:e,startColumn:a.column,endColumn:c.column});if(u==null)return;s={...n,top:(n.top||0)+u.endY-u.startY},l=k(s,this._selectionRenderService)}else if(g>=e)if(t===h.SheetDrawingAnchorType.Both)l={from:{...a},to:{...c,row:g+o}},s=Y(l,this._selectionRenderService,this._skeletonManagerService);else return{newSheetTransform:k({...n},this._selectionRenderService),newTransform:n};return l!=null&&s!=null?{newSheetTransform:l,newTransform:s}:null}_shrinkRow(i,n,r,e,t=h.SheetDrawingAnchorType.Position){const o=e-r+1,{from:a,to:c}=i,{row:d}=a,{row:g}=c;if(t===h.SheetDrawingAnchorType.None)return{newSheetTransform:k({...n},this._selectionRenderService),newTransform:n};let l=null,s=null;if(d>e)l={from:{...a,row:d-o},to:{...c,row:g-o}},s=Y(l,this._selectionRenderService,this._skeletonManagerService);else{if(d>=r&&g<=e)return null;if(d<r&&g>e)if(t===h.SheetDrawingAnchorType.Both)l={from:{...a},to:{...c,row:g-o}},s=Y(l,this._selectionRenderService,this._skeletonManagerService);else return{newSheetTransform:k({...n},this._selectionRenderService),newTransform:n};else if(d>=r&&d<=e){if(d===r)s={...n,top:(n.top||0)-i.from.rowOffset};else{const u=this._skeletonManagerService.attachRangeWithCoord({startRow:r,endRow:d-1,startColumn:a.column,endColumn:c.column});if(u==null)return;s={...n,top:(n.top||0)-u.endY+u.startY-i.from.rowOffset}}l=k(s,this._selectionRenderService)}else if(g>=r&&g<=e&&t===h.SheetDrawingAnchorType.Both){const u=this._skeletonManagerService.attachRangeWithCoord({startColumn:a.column,endColumn:a.column,startRow:r-1,endRow:r-1});if(u==null)return;l={from:{...a},to:{...c,row:r-1,rowOffset:u.endY-u.startY}},s=Y(l,this._selectionRenderService,this._skeletonManagerService)}}return l!=null&&s!=null?{newSheetTransform:l,newTransform:s}:null}_commandListener(){this.disposeWithMe(this._commandService.onCommandExecuted(i=>{i.id===I.SetWorksheetActiveOperation.id&&setTimeout(()=>{const n=i.params,{unitId:r,subUnitId:e}=n,t=this._drawingManagerService.drawingManagerData,o=[],a=[];Object.keys(t).forEach(c=>{const d=t[c];d!=null&&Object.keys(d).forEach(g=>{const l=d[g].data;l!=null&&Object.keys(l).forEach(s=>{if(c===r&&g===e){const u=l[s];u.transform=Y(u.sheetTransform,this._selectionRenderService,this._skeletonManagerService),o.push(l[s])}else a.push(l[s])})})}),this._drawingManagerService.removeNotification(a),this._drawingManagerService.addNotification(o)},0)}))}_sheetRefreshListener(){this.disposeWithMe(this._commandService.onCommandExecuted(i=>{Xt.includes(i.id)&&requestIdleCallback(()=>{const n=i.params,{unitId:r,subUnitId:e,ranges:t}=n;this._refreshDrawingTransform(r,e,t)})}))}_refreshDrawingTransform(i,n,r){const e=this._drawingManagerService.getDrawingData(i,n),t=[];Object.keys(e).forEach(o=>{const a=e[o],{sheetTransform:c,transform:d,anchorType:g=h.SheetDrawingAnchorType.Position}=a;if(g===h.SheetDrawingAnchorType.None)return!0;const{from:l,to:s}=c,{row:u,column:m}=l,{row:f,column:S}=s;for(let v=0;v<r.length;v++){const y=r[v],{startRow:M,endRow:C,startColumn:T,endColumn:_}=y;if(p.Rectangle.intersects({startRow:M,endRow:C,startColumn:T,endColumn:_},{startRow:u,endRow:f,startColumn:m,endColumn:S})||u>C||m>_){const D=g===h.SheetDrawingAnchorType.Position,w=Y(c,this._selectionRenderService,this._skeletonManagerService);t.push({...a,transform:{...w,width:D?d==null?void 0:d.width:w==null?void 0:w.width,height:D?d==null?void 0:d.height:w==null?void 0:w.height}});break}}}),t.length!==0&&(this._drawingManagerService.refreshTransform(t),this._commandService.syncExecuteCommand(G.id,[i]))}};Pe=Ht([Q(1,N.IRenderManagerService),Q(2,p.ICommandService),Q(3,j.ISheetSelectionRenderService),Q(4,p.Inject(j.SheetSkeletonManagerService)),Q(5,p.Inject(I.SheetInterceptorService)),Q(6,h.ISheetDrawingService),Q(7,b.IDrawingManagerService),Q(8,p.IUniverInstanceService)],Pe);var Kt=Object.defineProperty,zt=Object.getOwnPropertyDescriptor,Jt=(i,n,r,e)=>{for(var t=e>1?void 0:e?zt(n,r):n,o=i.length-1,a;o>=0;o--)(a=i[o])&&(t=(e?a(n,r,t):a(t))||t);return e&&t&&Kt(n,r,t),t},ne=(i,n)=>(r,e)=>n(r,e,i);function Zt(i,n,r,e){const{scaleX:t,scaleY:o}=n.getAncestorScale(),a=n.getViewport(N.SHEET_VIEWPORT_KEY.VIEW_MAIN),c={left:!0,top:!0};if(!a)return{...i,absolute:c};const{left:d,right:g,top:l,bottom:s}=i,u=e.getFreeze(),{startColumn:m,startRow:f,xSplit:S,ySplit:v}=u,y=r.getNoMergeCellPositionByIndexWithNoHeader(f-v,m-S),M=r.getNoMergeCellPositionByIndexWithNoHeader(f,m),{rowHeaderWidth:C,columnHeaderHeight:T}=r,_=M.startX-y.startX,D=M.startY-y.startY,{top:w,left:A,viewportScrollX:E,viewportScrollY:L}=a;let U,P;d<A?(c.left=!0,U=(_+C+(d-A))*t,P=Math.max(Math.min((_+C+(g-A))*t,(_+C)*t),(g-E)*t)):(c.left=!1,U=Math.max((d-E)*t,(_+C)*t),P=Math.max((g-E)*t,(_+C)*t));let R,B;return l<w?(c.top=!0,R=(D+T+(l-w))*o,B=Math.max(Math.min((D+T+(g-w))*o,(D+T)*o),(s-L)*o)):(c.top=!1,R=Math.max((l-L)*o,(D+T)*o),B=Math.max((s-L)*o,(D+T)*o)),{left:U,right:P,top:R,bottom:B,absolute:c}}const Ae=(i,n,r,e)=>{const{scene:t}=n,{left:o,top:a,width:c,height:d,angle:g}=i,l={left:o,right:o+c,top:a,bottom:a+d},s=Zt(l,t,r,e),{scaleX:u,scaleY:m}=t.getAncestorScale();return{startX:s.left,endX:s.right,startY:s.top,endY:s.bottom,rotate:g,width:c*u,height:d*m,absolute:s.absolute}};O.SheetCanvasFloatDomManagerService=class extends p.Disposable{constructor(r,e,t,o,a,c,d){super();X(this,"_domLayerMap",new Map);X(this,"_domLayerInfoMap",new Map);X(this,"_transformChange$",new W.Subject);X(this,"transformChange$",this._transformChange$.asObservable());X(this,"_add$",new W.Subject);X(this,"add$",this._add$.asObservable());X(this,"_remove$",new W.Subject);X(this,"remove$",this._remove$.asObservable());X(this,"_hooks",[]);this._renderManagerService=r,this._univerInstanceService=e,this._commandService=t,this._drawingManagerService=o,this._canvasFloatDomService=a,this._sheetDrawingService=c,this._lifecycleService=d,this._drawingAddListener(),this._featureUpdateListener(),this._deleteListener(),this._bindScrollEvent()}_bindScrollEvent(){this._lifecycleService.lifecycle$.pipe(W.filter(r=>r===p.LifecycleStages.Rendered),W.take(1)).subscribe(()=>{this._scrollUpdateListener()})}_ensureMap(r,e){let t=this._domLayerMap.get(r);t||(t=new Map,this._domLayerMap.set(r,t));let o=t.get(e);return o||(o=new Map,t.set(e,o)),o}getFloatDomInfo(r){return this._domLayerInfoMap.get(r)}_getSceneAndTransformerByDrawingSearch(r){if(r==null)return;const e=this._renderManagerService.getRenderById(r),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(r){let e;return this._hooks.forEach(t=>{e=t.onGetFloatDomProps(r)}),e}_drawingAddListener(){this.disposeWithMe(this._drawingManagerService.add$.subscribe(r=>{r.forEach(e=>{var Xe,Ke,ze;const{unitId:t,subUnitId:o,drawingId:a}=e,c=I.getSheetCommandTarget(this._univerInstanceService,{unitId:t,subUnitId:o}),d=this._drawingManagerService.getDrawingByParam(e),g=this._univerInstanceService.getUnit(t);if(!g)return;const l=g.getActiveSheet().getSheetId();if(!d||!c)return;const s=(Xe=this._renderManagerService.getRenderById(t))==null?void 0:Xe.with(j.SheetSkeletonManagerService).getWorksheetSkeleton(o);if(!s)return;const{transform:u,drawingType:m,data:f}=d;if(m!==b.DrawingTypeEnum.DRAWING_DOM&&m!==b.DrawingTypeEnum.DRAWING_CHART)return;const S=this._getSceneAndTransformerByDrawingSearch(t);if(S==null)return;const{scene:v,canvas:y}=S;if(u==null)return!0;if(l!==o)return;const{left:M,top:C,width:T,height:_,angle:D,flipX:w,flipY:A,skewX:E,skewY:L}=u,U=b.getDrawingShapeKeyByDrawingSearch({unitId:t,subUnitId:o,drawingId:a}),P=v.getObject(U);if(P!=null){P.transformByState({left:M,top:C,width:T,height:_,angle:D,flipX:w,flipY:A,skewX:E,skewY:L});return}const R={left:M,top:C,width:T,height:_,zIndex:this._drawingManagerService.getDrawingOrder(t,o).length-1},B=m===b.DrawingTypeEnum.DRAWING_CHART;B&&(R.fill="white",R.rotateEnabled=!1,f&&f.border&&(R.stroke=f.border),R.paintFirst="stroke",R.strokeWidth=1,R.borderEnabled=!1,R.radius=8);const V=new N.Rect(U,R);B&&V.setObjectType(N.ObjectType.CHART),v.addObject(V,N.DRAWING_OBJECT_LAYER_INDEX),d.allowTransform!==!1&&v.attachTransformerTo(V);const J=this._ensureMap(t,o),Ne=new p.DisposableCollection,nn=Ae(V,S.renderObject,s.skeleton,c.worksheet),je=new W.BehaviorSubject(nn),rn={dispose:Ne,rect:V,position$:je,unitId:t,subUnitId:o};this._canvasFloatDomService.addFloatDom({position$:je,id:a,componentKey:d.componentKey,onPointerDown:x=>{y.dispatchEvent(new PointerEvent(x.type,x))},onPointerMove:x=>{y.dispatchEvent(new PointerEvent(x.type,x))},onPointerUp:x=>{y.dispatchEvent(new PointerEvent(x.type,x))},onWheel:x=>{y.dispatchEvent(new WheelEvent(x.type,x))},props:(ze=(Ke=J.get(a))==null?void 0:Ke.props)!=null?ze:this._getFloatDomProps(a),data:f,unitId:t});const xe=V.onTransformChange$.subscribeEvent(()=>{const x=Ae(V,S.renderObject,s.skeleton,c.worksheet);je.next(x)});Ne.add(()=>{this._canvasFloatDomService.removeFloatDom(a)}),xe&&Ne.add(xe),this._domLayerInfoMap.set(a,rn),J.set(a,{...J.get(a)})})})),this.disposeWithMe(this._drawingManagerService.remove$.subscribe(r=>{r.forEach(e=>{const{unitId:t,subUnitId:o,drawingId:a}=e,c=b.getDrawingShapeKeyByDrawingSearch({unitId:t,subUnitId:o,drawingId:a}),d=this._getSceneAndTransformerByDrawingSearch(t);if(d==null)return;const{transformer:g,scene:l}=d,s=l.getObject(c);s!=null&&s.oKey&&g.clearControlByIds([s==null?void 0:s.oKey])})}))}_scrollUpdateListener(){const r=(e,t)=>{var l;const o=this._getSceneAndTransformerByDrawingSearch(e),a=this._ensureMap(e,t),c=Array.from(a.keys()),d=I.getSheetCommandTarget(this._univerInstanceService,{unitId:e,subUnitId:t}),g=(l=this._renderManagerService.getRenderById(e))==null?void 0:l.with(j.SheetSkeletonManagerService).getWorksheetSkeleton(t);!o||!d||!g||c.forEach(s=>{const u=this._domLayerInfoMap.get(s);if(u){const m=Ae(u.rect,o.renderObject,g.skeleton,d.worksheet);u.position$.next(m)}})};this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(p.UniverInstanceType.UNIVER_SHEET).pipe(W.filter(e=>!!e),W.switchMap(e=>e.activeSheet$),W.filter(e=>!!e),W.map(e=>{const t=this._renderManagerService.getRenderById(e.getUnitId());return t?{render:t,unitId:e.getUnitId(),subUnitId:e.getSheetId()}:null}),W.filter(e=>!!e),W.switchMap(e=>p.fromEventSubject(e.render.scene.getViewport(j.VIEWPORT_KEY.VIEW_MAIN).onScrollAfter$).pipe(W.map(()=>({unitId:e.unitId,subUnitId:e.subUnitId}))))).subscribe(({unitId:e,subUnitId:t})=>{r(e,t)})),this.disposeWithMe(this._commandService.onCommandExecuted(e=>{var t,o;if(e.id===j.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(g=>{r(c,g)})}else if(e.id===I.SetFrozenMutation.id){const{unitId:a,subUnitId:c}=e.params;r(a,c)}}))}_getPosition(r,e){var m;const{startX:t,endX:o,startY:a,endY:c}=r,d=(m=this._renderManagerService.getRenderById(e))==null?void 0:m.with(j.ISheetSelectionRenderService);if(d==null)return;const g=d.getCellWithCoordByOffset(t,a);if(g==null)return;const l={column:g.actualColumn,columnOffset:t-g.startX,row:g.actualRow,rowOffset:a-g.startY},s=d.getCellWithCoordByOffset(o,c);if(s==null)return;const u={column:s.actualColumn,columnOffset:o-s.startX,row:s.actualRow,rowOffset:c-s.startY};return{from:l,to:u}}_featureUpdateListener(){this.disposeWithMe(this._drawingManagerService.update$.subscribe(r=>{r.forEach(e=>{const t=this._drawingManagerService.getDrawingByParam(e);if(!t||t.drawingType!==b.DrawingTypeEnum.DRAWING_DOM&&t.drawingType!==b.DrawingTypeEnum.DRAWING_CHART)return;const o={...t.transform};this._transformChange$.next({id:e.drawingId,value:o})})}))}_deleteListener(){this.disposeWithMe(this._drawingManagerService.remove$.subscribe(r=>{r.forEach(e=>{this._removeDom(e.drawingId)})}))}updateFloatDomProps(r,e,t,o){const a=this._domLayerInfoMap.get(t),c=this._getSceneAndTransformerByDrawingSearch(r);if(a&&c){const{scene:d}=c,g=b.getDrawingShapeKeyByDrawingSearch({unitId:r,subUnitId:e,drawingId:t}),l=d.getObject(g);l&&l instanceof N.Rect&&l.setProps(o)}}addFloatDomToPosition(r,e){const t=I.getSheetCommandTarget(this._univerInstanceService,{unitId:r.unitId,subUnitId:r.subUnitId});if(!t)throw new Error("cannot find current target!");const{unitId:o,subUnitId:a}=t,{initPosition:c,componentKey:d,data:g,allowTransform:l=!0}=r,s=e!=null?e:p.generateRandomId(),u=this._getPosition(c,o);if(u==null)return;this._ensureMap(o,a).set(s,r);const f={unitId:o,subUnitId:a,drawingId:s,drawingType:r.type||b.DrawingTypeEnum.DRAWING_DOM,componentKey:d,sheetTransform:u,transform:{left:c.startX,top:c.startY,width:c.endX-c.startX,height:c.endY-c.startY},data:g,allowTransform:l};return this._commandService.executeCommand(oe.id,{unitId:o,drawings:[f]}),this._add$.next({unitId:o,subUnitId:a,id:s}),{id:s,dispose:()=>{this._removeDom(s,!0)}}}_removeDom(r,e=!1){const t=this._domLayerInfoMap.get(r);if(!t)return;const{unitId:o,subUnitId:a}=t;this._domLayerInfoMap.delete(r),t.dispose.dispose();const c=this._getSceneAndTransformerByDrawingSearch(o);if(c&&c.scene.removeObject(t.rect),e){this._ensureMap(o,a).delete(r);const g=this._drawingManagerService.getDrawingByParam({unitId:o,subUnitId:a,drawingId:r});if(!g)return;const l=this._sheetDrawingService.getBatchRemoveOp([g]),{redo:s,objects:u}=l;this._commandService.syncExecuteCommand(h.SetDrawingApplyMutation.id,{unitId:o,subUnitId:a,op:s,objects:u,type:h.DrawingApplyType.REMOVE})}}addHook(r){return this._hooks.push(r),{dispose:()=>{const e=this._hooks.findIndex(t=>t===r);this._hooks.splice(e,1)}}}},O.SheetCanvasFloatDomManagerService=Jt([ne(0,p.Inject(N.IRenderManagerService)),ne(1,p.IUniverInstanceService),ne(2,p.Inject(p.ICommandService)),ne(3,b.IDrawingManagerService),ne(4,p.Inject($.CanvasFloatDomService)),ne(5,h.ISheetDrawingService),ne(6,p.Inject(p.LifecycleService))],O.SheetCanvasFloatDomManagerService);var Ye=Object.defineProperty,qt=Object.getOwnPropertyDescriptor,Qt=(i,n,r)=>n in i?Ye(i,n,{enumerable:!0,configurable:!0,writable:!0,value:r}):i[n]=r,en=(i,n,r,e)=>{for(var t=e>1?void 0:e?qt(n,r):n,o=i.length-1,a;o>=0;o--)(a=i[o])&&(t=(e?a(n,r,t):a(t))||t);return e&&t&&Ye(n,r,t),t},Ue=(i,n)=>(r,e)=>n(r,e,i),He=(i,n,r)=>Qt(i,typeof n!="symbol"?n+"":n,r);const tn="SHEET_IMAGE_UI_PLUGIN";O.UniverSheetsDrawingUIPlugin=class extends p.Plugin{constructor(n=Ze,r,e,t){super(),this._config=n,this._injector=r,this._renderManagerService=e,this._configService=t;const{menu:o,...a}=this._config;o&&this._configService.setConfig("menu",o,{merge:!0}),this._configService.setConfig(Je,a)}onStarting(){p.registerDependencies(this._injector,[[O.SheetCanvasFloatDomManagerService],[Se],[ue],[Ie],[we],[ve]]),p.touchDependencies(this._injector,[[O.SheetCanvasFloatDomManagerService]])}onReady(){p.touchDependencies(this._injector,[[ve]])}onRendered(){this._registerRenderModules(),p.touchDependencies(this._injector,[[we],[Ie],[Se]])}onSteady(){this._injector.get(ue)}_registerRenderModules(){[[ge],[Pe],[Me]].forEach(n=>{this.disposeWithMe(this._renderManagerService.registerRenderModule(p.UniverInstanceType.UNIVER_SHEET,n))})}},He(O.UniverSheetsDrawingUIPlugin,"type",p.UniverInstanceType.UNIVER_SHEET),He(O.UniverSheetsDrawingUIPlugin,"pluginName",tn),O.UniverSheetsDrawingUIPlugin=en([p.DependentOn(b.UniverDrawingPlugin,ee.UniverDrawingUIPlugin,h.UniverSheetsDrawingPlugin),Ue(1,p.Inject(p.Injector)),Ue(2,N.IRenderManagerService),Ue(3,p.IConfigService)],O.UniverSheetsDrawingUIPlugin),O.ClearSheetDrawingTransformerOperation=G,O.DeleteDrawingsCommand=De,O.EditSheetDrawingOperation=ye,O.GroupSheetDrawingCommand=Re,O.IMAGE_MENU_ID=Ee,O.InsertFloatImageCommand=pe,O.InsertSheetDrawingCommand=oe,O.MoveDrawingsCommand=re,O.RemoveSheetDrawingCommand=ie,O.SetDrawingArrangeCommand=Te,O.SetSheetDrawingCommand=ae,O.SidebarSheetDrawingOperation=Ce,O.UngroupSheetDrawingCommand=be,Object.defineProperty(O,Symbol.toStringTag,{value:"Module"})});
|
|
9
|
+
*/var qe=H,Qe=Symbol.for("react.element"),et=Symbol.for("react.fragment"),tt=Object.prototype.hasOwnProperty,nt=qe.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,rt={key:!0,ref:!0,__self:!0,__source:!0};function Be(i,n,r){var e,t={},o=null,a=null;r!==void 0&&(o=""+r),n.key!==void 0&&(o=""+n.key),n.ref!==void 0&&(a=n.ref);for(e in n)tt.call(n,e)&&!rt.hasOwnProperty(e)&&(t[e]=n[e]);if(i&&i.defaultProps)for(e in n=i.defaultProps,n)t[e]===void 0&&(t[e]=n[e]);return{$$typeof:Qe,type:i,key:o,ref:a,props:t,_owner:nt.current}}de.Fragment=et,de.jsx=Be,de.jsxs=Be,Le.exports=de;var $=Le.exports;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"},it=()=>{const i=p.useDependency(b.IImageIoService),n=p.useDependency(p.LocaleService),[r,e]=H.useState(0);return H.useEffect(()=>{const t=i.change$.subscribe(o=>{e(o)});return()=>{t.unsubscribe()}},[i]),$.jsx("div",{style:{display:r>0?"block":"none"},className:le.uploadLoading,children:$.jsxs("div",{className:le.uploadLoadingBody,children:[$.jsx("div",{className:le.uploadLoadingBodyAnimation}),$.jsx("div",{className:le.uploadLoadingBodyText,children:`${n.t("uploadLoading.loading")}: ${r}`})]})})};var ot=Object.defineProperty,at=Object.getOwnPropertyDescriptor,st=(i,n,r,e)=>{for(var t=e>1?void 0:e?at(n,r):n,o=i.length-1,a;o>=0;o--)(a=i[o])&&(t=(e?a(n,r,t):a(t))||t);return e&&t&&ot(n,r,t),t},te=(i,n)=>(r,e)=>n(r,e,i);let ue=class extends p.RxDisposable{constructor(n,r,e,t,o,a,c){super();X(this,"_initImagePopupMenu",new Set);this._injector=n,this._drawingManagerService=r,this._canvasPopManagerService=e,this._renderManagerService=t,this._univerInstanceService=o,this._contextService=a,this._uiPartsService=c,this._init()}_init(){this._univerInstanceService.getCurrentTypeOfUnit$(p.UniverInstanceType.UNIVER_SHEET).pipe(W.takeUntil(this.dispose$)).subscribe(n=>this._create(n)),this._univerInstanceService.getTypeOfUnitDisposed$(p.UniverInstanceType.UNIVER_SHEET).pipe(W.takeUntil(this.dispose$)).subscribe(n=>this._dispose(n)),this._univerInstanceService.getAllUnitsForType(p.UniverInstanceType.UNIVER_SHEET).forEach(n=>this._create(n)),this._uiPartsService.registerComponent(F.BuiltInUIPart.CONTENT,()=>p.connectInjector(it,this._injector))}_dispose(n){const r=n.getUnitId();this._renderManagerService.removeRender(r)}_create(n){if(!n)return;const r=n.getUnitId();this._renderManagerService.has(r)&&!this._initImagePopupMenu.has(r)&&(this._popupMenuListener(r),this._initImagePopupMenu.add(r))}_hasCropObject(n){const r=n.getAllObjectsByOrder();for(const e of r)if(e instanceof ee.ImageCropperObject)return!0;return!1}_popupMenuListener(n){var o;const r=(o=this._renderManagerService.getRenderById(n))==null?void 0:o.scene;if(!r)return;const e=r.getTransformerByCreate();if(!e)return;let t;this.disposeWithMe(p.toDisposable(e.createControl$.subscribe(()=>{if(this._contextService.setContextValue(p.FOCUSING_COMMON_DRAWINGS,!0),this._hasCropObject(r))return;const a=e.getSelectedObjectMap();if(a.size>1){t==null||t.dispose();return}const c=a.values().next().value;if(!c)return;const d=c.oKey,g=this._drawingManagerService.getDrawingOKey(d);if(!g)return;const{unitId:l,subUnitId:s,drawingId:u,drawingType:m}=g,f=g.data;if(f&&f.disablePopup)return;t==null||t.dispose();const S=this._canvasPopManagerService.getFeatureMenu(l,s,u,m);t=this.disposeWithMe(this._canvasPopManagerService.attachPopupToObject(c,{componentKey:ee.COMPONENT_IMAGE_POPUP_MENU,direction:"horizontal",offset:[2,0],extraProps:{menuItems:S||this._getImageMenuItems(l,s,u,m)}})),this._drawingManagerService.focusDrawing([{unitId:l,subUnitId:s,drawingId:u}])}))),this.disposeWithMe(e.clearControl$.subscribe(()=>{t==null||t.dispose(),this._contextService.setContextValue(p.FOCUSING_COMMON_DRAWINGS,!1),this._drawingManagerService.focusDrawing(null)})),this.disposeWithMe(e.changing$.subscribe(()=>{t==null||t.dispose()}))}_getImageMenuItems(n,r,e,t){return[{label:"image-popup.edit",index:0,commandId:ye.id,commandParams:{unitId:n,subUnitId:r,drawingId:e},disable:t===b.DrawingTypeEnum.DRAWING_DOM},{label:"image-popup.delete",index:1,commandId:ie.id,commandParams:{unitId:n,drawings:[{unitId:n,subUnitId:r,drawingId:e}]},disable:!1},{label:"image-popup.crop",index:2,commandId:ee.OpenImageCropOperation.id,commandParams:{unitId:n,subUnitId:r,drawingId:e},disable:t===b.DrawingTypeEnum.DRAWING_DOM},{label:"image-popup.reset",index:3,commandId:ee.ImageResetSizeOperation.id,commandParams:[{unitId:n,subUnitId:r,drawingId:e}],disable:t===b.DrawingTypeEnum.DRAWING_DOM}]}};ue=st([te(0,p.Inject(p.Injector)),te(1,b.IDrawingManagerService),te(2,p.Inject(j.SheetCanvasPopManagerService)),te(3,N.IRenderManagerService),te(4,p.IUniverInstanceService),te(5,p.IContextService),te(6,p.Inject(F.IUIPartsService))],ue);function Y(i,n,r){const{from:e,to:t,flipY:o=!1,flipX:a=!1,angle:c=0,skewX:d=0,skewY:g=0}=i,{column:l,columnOffset:s,row:u,rowOffset:m}=e,{column:f,columnOffset:S,row:v,rowOffset:y}=t,M=r.getCurrentSkeleton(),C=j.attachRangeWithCoord(M,{startColumn:l,endColumn:l,startRow:u,endRow:u});if(C==null)return;const T=j.attachRangeWithCoord(M,{startColumn:f,endColumn:f,startRow:v,endRow:v});if(T==null)return;const{startX:_,startY:D}=C,{startX:w,startY:A}=T;let E=N.precisionTo(_+s,1),L=N.precisionTo(D+m,1),U=N.precisionTo(w+S-E,1),P=N.precisionTo(A+y-L,1);C.startX===T.endX&&(U=0),C.startY===T.endY&&(P=0);const R=M.rowHeaderWidth+M.columnTotalWidth,B=M.columnHeaderHeight+M.rowTotalHeight;return E+U>R&&(E=R-U),L+P>B&&(L=B-P),{flipY:o,flipX:a,angle:c,skewX:d,skewY:g,left:E,top:L,width:U,height:P}}function k(i,n){const{left:r=0,top:e=0,width:t=0,height:o=0,flipY:a=!1,flipX:c=!1,angle:d=0,skewX:g=0,skewY:l=0}=i,s=n.getCellWithCoordByOffset(r,e);if(s==null)return;const u={column:s.actualColumn,columnOffset:N.precisionTo(r-s.startX,1),row:s.actualRow,rowOffset:N.precisionTo(e-s.startY,1)},m=n.getCellWithCoordByOffset(r+t,e+o);if(m==null)return;const f={column:m.actualColumn,columnOffset:N.precisionTo(r+t-m.startX,1),row:m.actualRow,rowOffset:N.precisionTo(e+o-m.startY,1)};return{flipY:a,flipX:c,angle:d,skewX:g,skewY:l,from:u,to:f}}var ct=Object.defineProperty,dt=Object.getOwnPropertyDescriptor,lt=(i,n,r,e)=>{for(var t=e>1?void 0:e?dt(n,r):n,o=i.length-1,a;o>=0;o--)(a=i[o])&&(t=(e?a(n,r,t):a(t))||t);return e&&t&&ct(n,r,t),t},me=(i,n)=>(r,e)=>n(r,e,i);let Me=class extends p.Disposable{constructor(i,n,r,e,t){super(),this._context=i,this._sheetDrawingService=n,this._drawingManagerService=r,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 n in i){const r=i[n];for(const e in r.data){const t=r.data[e];t.transform=Y(t.sheetTransform,this._sheetSelectionRenderService,this._sheetSkeletonManagerService)}}this._drawingManagerService.registerDrawingData(this._context.unitId,this._sheetDrawingService.getDrawingDataForUnit(this._context.unitId)),this._drawingManagerService.initializeNotification(this._context.unitId)}};Me=lt([me(1,h.ISheetDrawingService),me(2,b.IDrawingManagerService),me(3,p.Inject(j.ISheetSelectionRenderService)),me(4,p.Inject(j.SheetSkeletonManagerService))],Me);var K=function(){return K=Object.assign||function(i){for(var n,r=1,e=arguments.length;r<e;r++){n=arguments[r];for(var t in n)Object.prototype.hasOwnProperty.call(n,t)&&(i[t]=n[t])}return i},K.apply(this,arguments)},ut=function(i,n){var r={};for(var e in i)Object.prototype.hasOwnProperty.call(i,e)&&n.indexOf(e)<0&&(r[e]=i[e]);if(i!=null&&typeof Object.getOwnPropertySymbols=="function")for(var t=0,e=Object.getOwnPropertySymbols(i);t<e.length;t++)n.indexOf(e[t])<0&&Object.prototype.propertyIsEnumerable.call(i,e[t])&&(r[e[t]]=i[e[t]]);return r},Ge=H.forwardRef(function(i,n){var r=i.icon,e=i.id,t=i.className,o=i.extend,a=ut(i,["icon","id","className","extend"]),c="univerjs-icon univerjs-icon-".concat(e," ").concat(t||"").trim(),d=H.useRef("_".concat(pt()));return ke(r,"".concat(e),{defIds:r.defIds,idSuffix:d.current},K({ref:n,className:c},a),o)});function ke(i,n,r,e,t){return H.createElement(i.tag,K(K({key:n},mt(i,r,t)),e),(gt(i,r).children||[]).map(function(o,a){return ke(o,"".concat(n,"-").concat(i.tag,"-").concat(a),r,void 0,t)}))}function mt(i,n,r){var e=K({},i.attrs);r!=null&&r.colorChannel1&&e.fill==="colorChannel1"&&(e.fill=r.colorChannel1);var t=n.defIds;return!t||t.length===0||(i.tag==="use"&&e["xlink:href"]&&(e["xlink:href"]=e["xlink:href"]+n.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(n.idSuffix,")")))})),e}function gt(i,n){var r,e=n.defIds;return!e||e.length===0?i:i.tag==="defs"&&(!((r=i.children)===null||r===void 0)&&r.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+n.idSuffix})}):t})}):i}function pt(){return Math.random().toString(36).substring(2,8)}Ge.displayName="UniverIcon";var ht={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"}}]},Ve=H.forwardRef(function(i,n){return H.createElement(Ge,Object.assign({},i,{id:"add-image-single",ref:n,icon:ht}))});Ve.displayName="AddImageSingle";const De={id:"sheet.command.delete-drawing",type:p.CommandType.COMMAND,handler:i=>{const n=i.get(p.ICommandService),e=i.get(h.ISheetDrawingService).getFocusDrawings();if(e.length===0)return!1;const t=e[0].unitId,o=e.map(a=>{const{unitId:c,subUnitId:d,drawingId:g,drawingType:l}=a;return{unitId:c,subUnitId:d,drawingId:g,drawingType:l}});return n.executeCommand(ie.id,{unitId:t,drawings:o})}};function ft(i){const n=[];return i.forEach(r=>{const{parent:e,children:t}=r,{unitId:o,subUnitId:a,drawingId:c}=e,d=N.getGroupState(0,0,t.map(s=>s.transform||{})),g=t.map(s=>{const u=s.transform||{left:0,top:0},{unitId:m,subUnitId:f,drawingId:S}=s;return{unitId:m,subUnitId:f,drawingId:S,transform:{...u,left:u.left-d.left,top:u.top-d.top},groupId:c}}),l={unitId:o,subUnitId:a,drawingId:c,drawingType:b.DrawingTypeEnum.DRAWING_GROUP,transform:d};n.push({parent:l,children:g})}),n}function St(i){const n=[];return i.forEach(r=>{const{parent:e,children:t}=r,{unitId:o,subUnitId:a,drawingId:c,transform:d={width:0,height:0}}=e;if(d==null)return;const g=t.map(s=>{const{transform:u}=s,{unitId:m,subUnitId:f,drawingId:S}=s,v=N.transformObjectOutOfGroup(u||{},d,d.width||0,d.height||0);return{unitId:m,subUnitId:f,drawingId:S,transform:v,groupId:void 0}}),l={unitId:o,subUnitId:a,drawingId:c,drawingType:b.DrawingTypeEnum.DRAWING_GROUP,transform:{left:0,top:0}};n.push({parent:l,children:g})}),n}const Re={id:"sheet.command.group-sheet-image",type:p.CommandType.COMMAND,handler:(i,n)=>{const r=i.get(p.ICommandService),e=i.get(p.IUndoRedoService),t=i.get(h.ISheetDrawingService);if(!n)return!1;const o=[];n.forEach(({parent:m,children:f})=>{o.push(m.unitId),f.forEach(S=>{o.push(S.unitId)})});const a=t.getGroupDrawingOp(n),{unitId:c,subUnitId:d,undo:g,redo:l,objects:s}=a;return r.syncExecuteCommand(h.SetDrawingApplyMutation.id,{op:l,unitId:c,subUnitId:d,objects:s,type:h.DrawingApplyType.GROUP})?(e.pushUndoRedo({unitID:c,undoMutations:[{id:h.SetDrawingApplyMutation.id,params:{op:g,unitId:c,subUnitId:d,objects:St(s),type:h.DrawingApplyType.UNGROUP}},{id:G.id,params:o}],redoMutations:[{id:h.SetDrawingApplyMutation.id,params:{op:l,unitId:c,subUnitId:d,objects:s,type:h.DrawingApplyType.GROUP}},{id:G.id,params:o}]}),!0):!1}},oe={id:"sheet.command.insert-sheet-image",type:p.CommandType.COMMAND,handler:(i,n)=>{var M,C,T;const r=i.get(p.ICommandService),e=i.get(p.IUndoRedoService),t=i.get(h.ISheetDrawingService),o=i.get(I.SheetInterceptorService);if(!n)return!1;const a=n.drawings,c=a.map(_=>_.unitId),d=t.getBatchAddOp(a),{unitId:g,subUnitId:l,undo:s,redo:u,objects:m}=d,f=o.onCommandExecute({id:oe.id,params:n}),S={id:h.SetDrawingApplyMutation.id,params:{op:u,unitId:g,subUnitId:l,objects:m,type:h.DrawingApplyType.INSERT}},v={id:h.SetDrawingApplyMutation.id,params:{op:s,unitId:g,subUnitId:l,objects:m,type:h.DrawingApplyType.REMOVE}};return p.sequenceExecute([...(M=f.preRedos)!=null?M:[],S,...f.redos],r)?(e.pushUndoRedo({unitID:g,undoMutations:[...(C=f.preUndos)!=null?C:[],v,...f.undos,{id:G.id,params:c}],redoMutations:[...(T=f.preRedos)!=null?T:[],S,...f.redos,{id:G.id,params:c}]}),!0):!1}},Te={id:"sheet.command.set-drawing-arrange",type:p.CommandType.COMMAND,handler:(i,n)=>{const r=i.get(p.ICommandService),e=i.get(p.IUndoRedoService);if(!n)return!1;const t=i.get(h.ISheetDrawingService),{unitId:o,subUnitId:a,drawingIds:c,arrangeType:d}=n,g={unitId:o,subUnitId:a,drawingIds:c};let l;if(d===b.ArrangeTypeEnum.forward?l=t.getForwardDrawingsOp(g):d===b.ArrangeTypeEnum.backward?l=t.getBackwardDrawingOp(g):d===b.ArrangeTypeEnum.front?l=t.getFrontDrawingsOp(g):d===b.ArrangeTypeEnum.back&&(l=t.getBackDrawingsOp(g)),l==null)return!1;const{objects:s,redo:u,undo:m}=l;return r.syncExecuteCommand(h.SetDrawingApplyMutation.id,{op:u,unitId:o,subUnitId:a,objects:s,type:h.DrawingApplyType.ARRANGE})?(e.pushUndoRedo({unitID:o,undoMutations:[{id:h.SetDrawingApplyMutation.id,params:{op:m,unitId:o,subUnitId:a,objects:s,type:h.DrawingApplyType.ARRANGE}}],redoMutations:[{id:h.SetDrawingApplyMutation.id,params:{op:u,unitId:o,subUnitId:a,objects:s,type:h.DrawingApplyType.ARRANGE}}]}),!0):!1}},ae={id:"sheet.command.set-sheet-image",type:p.CommandType.COMMAND,handler:(i,n)=>{const r=i.get(p.ICommandService),e=i.get(p.IUndoRedoService),t=i.get(h.ISheetDrawingService);if(!n)return!1;const{drawings:o}=n,a=t.getBatchUpdateOp(o),{unitId:c,subUnitId:d,undo:g,redo:l,objects:s}=a;return r.syncExecuteCommand(h.SetDrawingApplyMutation.id,{unitId:c,subUnitId:d,op:l,objects:s,type:h.DrawingApplyType.UPDATE})?(e.pushUndoRedo({unitID:c,undoMutations:[{id:h.SetDrawingApplyMutation.id,params:{unitId:c,subUnitId:d,op:g,objects:s,type:h.DrawingApplyType.UPDATE}},{id:G.id,params:[c]}],redoMutations:[{id:h.SetDrawingApplyMutation.id,params:{unitId:c,subUnitId:d,op:l,objects:s,type:h.DrawingApplyType.UPDATE}},{id:G.id,params:[c]}]}),!0):!1}},be={id:"sheet.command.ungroup-sheet-image",type:p.CommandType.COMMAND,handler:(i,n)=>{const r=i.get(p.ICommandService),e=i.get(p.IUndoRedoService),t=i.get(h.ISheetDrawingService);if(!n)return!1;const o=[];n.forEach(({parent:m,children:f})=>{o.push(m.unitId),f.forEach(S=>{o.push(S.unitId)})});const a=t.getUngroupDrawingOp(n),{unitId:c,subUnitId:d,undo:g,redo:l,objects:s}=a;return r.syncExecuteCommand(h.SetDrawingApplyMutation.id,{op:l,unitId:c,subUnitId:d,objects:s,type:h.DrawingApplyType.UNGROUP})?(e.pushUndoRedo({unitID:c,undoMutations:[{id:h.SetDrawingApplyMutation.id,params:{op:g,unitId:c,subUnitId:d,objects:ft(s),type:h.DrawingApplyType.GROUP}},{id:G.id,params:o}],redoMutations:[{id:h.SetDrawingApplyMutation.id,params:{op:l,unitId:c,subUnitId:d,objects:s,type:h.DrawingApplyType.UNGROUP}},{id:G.id,params:o}]}),!0):!1}};var vt=Object.defineProperty,wt=Object.getOwnPropertyDescriptor,_t=(i,n,r,e)=>{for(var t=e>1?void 0:e?wt(n,r):n,o=i.length-1,a;o>=0;o--)(a=i[o])&&(t=(e?a(n,r,t):a(t))||t);return e&&t&&vt(n,r,t),t},z=(i,n)=>(r,e)=>n(r,e,i);let ge=class extends p.Disposable{constructor(n,r,e,t,o,a,c,d,g,l,s,u){super();X(this,"_workbookSelections");this._context=n,this._skeletonManagerService=r,this._commandService=e,this._selectionRenderService=t,this._imageIoService=o,this._fileOpenerService=a,this._sheetDrawingService=c,this._drawingManagerService=d,this._contextService=g,this._messageService=l,this._localeService=s,this._workbookSelections=u.getWorkbookSelections(this._context.unitId),this._updateImageListener(),this._updateOrderListener(),this._groupDrawingListener(),this._focusDrawingListener()}async insertFloatImage(){const n=await this._fileOpenerService.openFile({multiple:!0,accept:b.DRAWING_IMAGE_ALLOW_IMAGE_LIST.map(e=>`.${e.replace("image/","")}`).join(",")}),r=n.length;return r>b.DRAWING_IMAGE_COUNT_LIMIT?(this._messageService.show({type:Z.MessageType.Error,content:this._localeService.t("update-status.exceedMaxCount",String(b.DRAWING_IMAGE_COUNT_LIMIT))}),!1):r===0?!1:(n.forEach(async e=>await this._insertFloatImage(e)),!0)}async _insertFloatImage(n){let r;try{r=await this._imageIoService.saveImage(n)}catch(M){const C=M.message;C===b.ImageUploadStatusType.ERROR_EXCEED_SIZE?this._messageService.show({type:Z.MessageType.Error,content:this._localeService.t("update-status.exceedMaxSize",String(b.DRAWING_IMAGE_ALLOW_SIZE/(1024*1024)))}):C===b.ImageUploadStatusType.ERROR_IMAGE_TYPE?this._messageService.show({type:Z.MessageType.Error,content:this._localeService.t("update-status.invalidImageType")}):C===b.ImageUploadStatusType.ERROR_IMAGE&&this._messageService.show({type:Z.MessageType.Error,content:this._localeService.t("update-status.invalidImage")})}if(r==null)return;const e=this._getUnitInfo(),{unitId:t,subUnitId:o}=e,{imageId:a,imageSourceType:c,source:d,base64Cache:g}=r,{width:l,height:s,image:u}=await b.getImageSize(g||""),{width:m,height:f}=this._context.scene;this._imageIoService.addImageSourceCache(d,c,u);let S=1;if(l>b.DRAWING_IMAGE_WIDTH_LIMIT||s>b.DRAWING_IMAGE_HEIGHT_LIMIT){const M=b.DRAWING_IMAGE_WIDTH_LIMIT/l,C=b.DRAWING_IMAGE_HEIGHT_LIMIT/s;S=Math.max(M,C)}const v=this._getImagePosition(l*S,s*S,m,f);if(v==null)return;const y={unitId:t,subUnitId:o,drawingId:a,drawingType:b.DrawingTypeEnum.DRAWING_IMAGE,imageSourceType:c,source:d,transform:Y(v,this._selectionRenderService,this._skeletonManagerService),sheetTransform:v};this._commandService.executeCommand(oe.id,{unitId:t,drawings:[y]})}_getUnitInfo(){const n=this._context.unit,r=n.getActiveSheet(),e=n.getUnitId(),t=r.getSheetId();return{unitId:e,subUnitId:t}}_getImagePosition(n,r,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=j.attachRangeWithCoord(this._skeletonManagerService.getCurrent().skeleton,a);if(c==null)return;let{startColumn:d,startRow:g,startX:l,startY:s}=c,u=!1;if(l+n>e&&(l=e-n,l<0&&(l=0,n=e),u=!0),s+r>t&&(s=t-r,s<0&&(s=0,r=t),u=!0),u){const v=this._selectionRenderService.getCellWithCoordByOffset(l,s);if(v==null)return;l=v.startX,s=v.startY,d=v.actualColumn,g=v.actualRow}const m={column:d,columnOffset:0,row:g,rowOffset:0},f=this._selectionRenderService.getCellWithCoordByOffset(l+n,s+r);if(f==null)return;const S={column:f.actualColumn,columnOffset:l+n-f.startX,row:f.actualRow,rowOffset:s+r-f.startY};return{from:m,to:S}}_updateOrderListener(){this.disposeWithMe(this._drawingManagerService.featurePluginOrderUpdate$.subscribe(n=>{const{unitId:r,subUnitId:e,drawingIds:t,arrangeType:o}=n;this._commandService.executeCommand(Te.id,{unitId:r,subUnitId:e,drawingIds:t,arrangeType:o})}))}_updateImageListener(){this.disposeWithMe(this._drawingManagerService.featurePluginUpdate$.subscribe(n=>{const r=[];n.length!==0&&(n.forEach(e=>{const{unitId:t,subUnitId:o,drawingId:a,drawingType:c,transform:d}=e;if(d==null)return;const g=this._sheetDrawingService.getDrawingByParam({unitId:t,subUnitId:o,drawingId:a});if(g==null||g.unitId!==this._context.unitId)return;const l=k({...g.transform,...d},this._selectionRenderService);if(l==null)return;const s={...e,transform:{...g.transform,...d,...Y(l,this._selectionRenderService,this._skeletonManagerService)},sheetTransform:{...l}};r.push(s)}),r.length>0&&this._commandService.executeCommand(ae.id,{unitId:n[0].unitId,drawings:r}))}))}_groupDrawingListener(){this.disposeWithMe(this._drawingManagerService.featurePluginGroupUpdate$.subscribe(n=>{this._commandService.executeCommand(Re.id,n);const{unitId:r,subUnitId:e,drawingId:t}=n[0].parent;this._drawingManagerService.focusDrawing([{unitId:r,subUnitId:e,drawingId:t}])})),this.disposeWithMe(this._drawingManagerService.featurePluginUngroupUpdate$.subscribe(n=>{this._commandService.executeCommand(be.id,n)}))}_focusDrawingListener(){this.disposeWithMe(this._drawingManagerService.focus$.subscribe(n=>{n==null||n.length===0?(this._contextService.setContextValue(p.FOCUSING_COMMON_DRAWINGS,!1),this._sheetDrawingService.focusDrawing([])):(this._contextService.setContextValue(p.FOCUSING_COMMON_DRAWINGS,!0),this._sheetDrawingService.focusDrawing(n))}))}};ge=_t([z(1,p.Inject(j.SheetSkeletonManagerService)),z(2,p.ICommandService),z(3,j.ISheetSelectionRenderService),z(4,b.IImageIoService),z(5,F.ILocalFileService),z(6,h.ISheetDrawingService),z(7,b.IDrawingManagerService),z(8,p.IContextService),z(9,F.IMessageService),z(10,p.Inject(p.LocaleService)),z(11,p.Inject(I.SheetsSelectionsService))],ge);const pe={id:"sheet.command.insert-float-image",type:p.CommandType.COMMAND,handler:i=>{var r,e;return(e=(r=i.get(N.IRenderManagerService).getCurrentTypeOfRenderer(p.UniverInstanceType.UNIVER_SHEET))==null?void 0:r.with(ge).insertFloatImage())!=null?e:!1}},re={id:"sheet.command.move-drawing",type:p.CommandType.COMMAND,handler:(i,n)=>{const r=i.get(p.ICommandService),e=i.get(h.ISheetDrawingService),t=i.get(j.ISheetSelectionRenderService),{direction:o}=n,a=e.getFocusDrawings();if(a.length===0)return!1;const c=a[0].unitId,d=a.map(l=>{const{transform:s}=l;if(s==null)return null;const u={...s},{left:m=0,top:f=0}=s;return o===p.Direction.UP?u.top=f-1:o===p.Direction.DOWN?u.top=f+1:o===p.Direction.LEFT?u.left=m-1:o===p.Direction.RIGHT&&(u.left=m+1),{...l,transform:u,sheetTransform:k(u,t)}}).filter(l=>l!=null);return r.syncExecuteCommand(ae.id,{unitId:c,drawings:d})?(r.syncExecuteCommand(G.id,[c]),!0):!1}},Fe="addition-and-subtraction-single",Ee="sheet.menu.image";function It(i){return{id:Ee,type:F.MenuItemType.SUBITEMS,icon:Fe,tooltip:"sheetImage.title",hidden$:F.getMenuHiddenObservable(i,p.UniverInstanceType.UNIVER_SHEET),disabled$:j.getCurrentRangeDisable$(i,{workbookTypes:[I.WorkbookEditablePermission],worksheetTypes:[I.WorksheetEditPermission],rangeTypes:[I.RangeProtectionPermissionEditPoint]})}}function Ct(i){return{id:pe.id,title:"sheetImage.upload.float",type:F.MenuItemType.BUTTON,hidden$:F.getMenuHiddenObservable(i,p.UniverInstanceType.UNIVER_SHEET)}}const q={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 $e(i){var n,r,e="";if(typeof i=="string"||typeof i=="number")e+=i;else if(typeof i=="object")if(Array.isArray(i)){var t=i.length;for(n=0;n<t;n++)i[n]&&(r=$e(i[n]))&&(e&&(e+=" "),e+=r)}else for(r in i)i[r]&&(e&&(e+=" "),e+=r);return e}function he(){for(var i,n,r=0,e="",t=arguments.length;r<t;r++)(i=arguments[r])&&(n=$e(i))&&(e&&(e+=" "),e+=n);return e}const yt=i=>{var C;const n=p.useDependency(p.ICommandService),r=p.useDependency(p.LocaleService),e=p.useDependency(b.IDrawingManagerService),t=p.useDependency(N.IRenderManagerService),{drawings:o}=i,a=o[0];if(a==null)return;const{unitId:c}=a,d=t.getRenderById(c),g=d==null?void 0:d.scene;if(g==null)return;const l=g.getTransformerByCreate(),[s,u]=H.useState(!0),m=(C=a.anchorType)!=null?C:h.SheetDrawingAnchorType.Position,[f,S]=H.useState(m);function v(T,_){const D=[];return T.forEach(w=>{const{oKey:A}=w,E=_.getDrawingOKey(A);if(E==null)return D.push(null),!0;const{unitId:L,subUnitId:U,drawingId:P,drawingType:R,anchorType:B,sheetTransform:V}=E;D.push({unitId:L,subUnitId:U,drawingId:P,anchorType:B,sheetTransform:V,drawingType:R})}),D}H.useEffect(()=>{const T=l.clearControl$.subscribe(D=>{D===!0&&u(!1)}),_=l.changeStart$.subscribe(D=>{var E;const{objects:w}=D,A=v(w,e);if(A.length===0)u(!1);else if(A.length>=1){u(!0);const L=((E=A[0])==null?void 0:E.anchorType)||h.SheetDrawingAnchorType.Position;S(L)}});return()=>{_.unsubscribe(),T.unsubscribe()}},[]);function y(T){S(T);const _=e.getFocusDrawings();if(_.length===0)return;const D=_.map(w=>({unitId:w.unitId,subUnitId:w.subUnitId,drawingId:w.drawingId,anchorType:T}));n.executeCommand(ae.id,{unitId:_[0].unitId,drawings:D})}const M=T=>T?"block":"none";return $.jsxs("div",{className:he(q.imageCommonPanelGrid,q.imageCommonPanelBorder),style:{display:M(s)},children:[$.jsx("div",{className:q.imageCommonPanelRow,children:$.jsx("div",{className:he(q.imageCommonPanelColumn,q.imageCommonPanelTitle),children:$.jsx("div",{children:r.t("drawing-anchor.title")})})}),$.jsx("div",{className:he(q.imageCommonPanelRow),children:$.jsx("div",{className:he(q.imageCommonPanelColumn),children:$.jsxs(Z.RadioGroup,{value:f,onChange:y,direction:"vertical",children:[$.jsx(Z.Radio,{value:h.SheetDrawingAnchorType.Both,children:r.t("drawing-anchor.both")}),$.jsx(Z.Radio,{value:h.SheetDrawingAnchorType.Position,children:r.t("drawing-anchor.position")}),$.jsx(Z.Radio,{value:h.SheetDrawingAnchorType.None,children:r.t("drawing-anchor.none")})]})})})]})},Mt=()=>{const i=p.useDependency(b.IDrawingManagerService),n=i.getFocusDrawings(),[r,e]=H.useState(n);return H.useEffect(()=>{const t=i.focus$.subscribe(o=>{e(o)});return()=>{t.unsubscribe()}},[]),!!(r!=null&&r.length)&&$.jsxs("div",{className:q.imageCommonPanel,children:[$.jsx(ee.DrawingCommonPanel,{drawings:r}),$.jsx(yt,{drawings:r})]})},Dt={[F.RibbonStartGroup.FORMULAS_INSERT]:{[Ee]:{order:3,menuItemFactory:It,[pe.id]:{order:0,menuItemFactory:Ct}}}};function se(i){return!i.getContextValue(p.FOCUSING_FX_BAR_EDITOR)&&!i.getContextValue(p.EDITOR_ACTIVATED)&&!i.getContextValue(p.FOCUSING_PANEL_EDITOR)&&i.getContextValue(p.FOCUSING_COMMON_DRAWINGS)}const Rt={id:re.id,description:"shortcut.sheet.drawing-move-down",group:"4_sheet-drawing-view",binding:F.KeyCode.ARROW_DOWN,priority:100,preconditions:se,staticParameters:{direction:p.Direction.DOWN}},Tt={id:re.id,description:"shortcut.sheet.drawing-move-up",group:"4_sheet-drawing-view",binding:F.KeyCode.ARROW_UP,priority:100,preconditions:se,staticParameters:{direction:p.Direction.UP}},bt={id:re.id,description:"shortcut.sheet.drawing-move-left",group:"4_sheet-drawing-view",binding:F.KeyCode.ARROW_LEFT,priority:100,preconditions:se,staticParameters:{direction:p.Direction.LEFT}},Et={id:re.id,description:"shortcut.sheet.drawing-move-right",group:"4_sheet-drawing-view",binding:F.KeyCode.ARROW_RIGHT,priority:100,preconditions:se,staticParameters:{direction:p.Direction.RIGHT}},Ot={id:De.id,description:"shortcut.sheet.drawing-delete",group:"4_sheet-drawing-view",preconditions:se,binding:F.KeyCode.DELETE,mac:F.KeyCode.BACKSPACE};var Pt=Object.defineProperty,At=Object.getOwnPropertyDescriptor,Ut=(i,n,r,e)=>{for(var t=e>1?void 0:e?At(n,r):n,o=i.length-1,a;o>=0;o--)(a=i[o])&&(t=(e?a(n,r,t):a(t))||t);return e&&t&&Pt(n,r,t),t},fe=(i,n)=>(r,e)=>n(r,e,i);let Se=class extends p.Disposable{constructor(i,n,r,e){super(),this._componentManager=i,this._menuManagerService=n,this._commandService=r,this._shortcutService=e,this._init()}_initCustomComponents(){const i=this._componentManager;this.disposeWithMe(i.register(Fe,Ve)),this.disposeWithMe(i.register(We,Mt))}_initMenus(){this._menuManagerService.mergeMenu(Dt)}_initCommands(){[pe,oe,ie,ae,Ce,G,ye,Re,be,re,De,Te].forEach(i=>this.disposeWithMe(this._commandService.registerCommand(i)))}_initShortcuts(){[Rt,Tt,bt,Et,Ot].forEach(i=>{this.disposeWithMe(this._shortcutService.registerShortcut(i))})}_init(){this._initCommands(),this._initCustomComponents(),this._initMenus(),this._initShortcuts()}};Se=Ut([fe(0,p.Inject(F.ComponentManager)),fe(1,F.IMenuManagerService),fe(2,p.ICommandService),fe(3,F.IShortcutService)],Se);var Nt=Object.defineProperty,jt=Object.getOwnPropertyDescriptor,Wt=(i,n,r,e)=>{for(var t=e>1?void 0:e?jt(n,r):n,o=i.length-1,a;o>=0;o--)(a=i[o])&&(t=(e?a(n,r,t):a(t))||t);return e&&t&&Nt(n,r,t),t},Oe=(i,n)=>(r,e)=>n(r,e,i);let ve=class extends p.Disposable{constructor(n,r,e){super();X(this,"_copyInfo");this._sheetClipboardService=n,this._renderManagerService=r,this._sheetDrawingService=e,this._initCopyPaste()}_initCopyPaste(){this._sheetClipboardService.addClipboardHook({id:"SHEET_IMAGE_UI_PLUGIN",onBeforeCopy:(n,r,e)=>this._collect(n,r,e),onPasteCells:(n,r,e,t)=>{const{copyType:o=j.COPY_TYPE.COPY,pasteType:a}=t,{range:c}=n||{},{range:d,unitId:g,subUnitId:l}=r;return this._generateMutations(d,{copyType:o,pasteType:a,copyRange:c,unitId:g,subUnitId:l})},onPastePlainText:(n,r)=>({undos:[],redos:[]})})}_collect(n,r,e){var u;const t=(u=this._renderManagerService.getRenderById(n))==null?void 0:u.with(j.SheetSkeletonManagerService);if(!t)return;const o=t.attachRangeWithCoord(e);if(!o)return;const{startX:a,endX:c,startY:d,endY:g}=o,l=this._sheetDrawingService.getDrawingData(n,r),s=[];Object.keys(l).forEach(m=>{const f=l[m],{transform:S}=f;if(f.anchorType!==h.SheetDrawingAnchorType.Both||!S)return;const{left:v=0,top:y=0,width:M=0,height:C=0}=S,{drawingStartX:T,drawingEndX:_,drawingStartY:D,drawingEndY:w}={drawingStartX:v,drawingEndX:v+M,drawingStartY:y,drawingEndY:y+C};a<=T&&_<=c&&d<=D&&w<=g&&s.push(f)}),s.length&&(this._copyInfo={drawings:s,unitId:n,subUnitId:r})}_generateMutations(n,r){var E;if(!this._copyInfo)return{redos:[],undos:[]};if([j.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_COL_WIDTH,j.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_VALUE,j.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMAT,j.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMULA].includes(r.pasteType))return{redos:[],undos:[]};const{copyRange:e}=r;if(!e)return{redos:[],undos:[]};const{drawings:t,unitId:o,subUnitId:a}=this._copyInfo,{ranges:[c,d],mapFunc:g}=j.virtualizeDiscreteRanges([e,n]),{row:l,col:s}=g(c.startRow,c.startColumn),{row:u,col:m}=g(d.startRow,d.startColumn),f=(E=this._renderManagerService.getRenderById(o))==null?void 0:E.with(j.SheetSkeletonManagerService);if(!f)return{redos:[],undos:[]};const S=f.attachRangeWithCoord({startRow:l,endRow:l,startColumn:s,endColumn:s}),v=f.attachRangeWithCoord({startRow:u,endRow:u,startColumn:m,endColumn:m});if(!S||!v)return{redos:[],undos:[]};const y=[],M=[],C=v.startX-S.startX,T=v.startY-S.startY,_=u-l,D=m-s,w=r.copyType===j.COPY_TYPE.CUT,{_sheetDrawingService:A}=this;return t.forEach(L=>{const{transform:U,sheetTransform:P}=L;if(!U)return;const R={...L,unitId:o,subUnitId:a,drawingId:w?L.drawingId:p.Tools.generateRandomId(),transform:{...U,left:U.left+C,top:U.top+T},sheetTransform:{to:{...P.to,row:P.to.row+_,column:P.to.column+D},from:{...P.from,row:P.from.row+_,column:P.from.column+D}}};if(w){const{undo:B,redo:V,objects:J}=A.getBatchUpdateOp([R]);y.push({id:h.SetDrawingApplyMutation.id,params:{unitId:o,subUnitId:a,type:h.DrawingApplyType.UPDATE,op:V,objects:J}}),M.push({id:h.SetDrawingApplyMutation.id,params:{unitId:o,subUnitId:a,type:h.DrawingApplyType.UPDATE,op:B,objects:J}})}else{const{undo:B,redo:V,objects:J}=A.getBatchAddOp([R]);y.push({id:h.SetDrawingApplyMutation.id,params:{op:V,unitId:o,subUnitId:a,objects:J,type:h.DrawingApplyType.INSERT}}),M.push({id:h.SetDrawingApplyMutation.id,params:{op:B,unitId:o,subUnitId:a,objects:J,type:h.DrawingApplyType.REMOVE}})}}),{redos:y,undos:M}}};ve=Wt([Oe(0,j.ISheetClipboardService),Oe(1,N.IRenderManagerService),Oe(2,h.ISheetDrawingService)],ve);var Lt=Object.defineProperty,Bt=Object.getOwnPropertyDescriptor,Gt=(i,n,r,e)=>{for(var t=e>1?void 0:e?Bt(n,r):n,o=i.length-1,a;o>=0;o--)(a=i[o])&&(t=(e?a(n,r,t):a(t))||t);return e&&t&&Lt(n,r,t),t},ce=(i,n)=>(r,e)=>n(r,e,i);let we=class extends p.Disposable{constructor(i,n,r,e,t){super(),this._drawingManagerService=i,this._renderManagerService=n,this._permissionService=r,this._univerInstanceService=e,this._userManagerService=t,this._initDrawingVisible(),this._initDrawingEditable(),this._initViewPermissionChange(),this._initEditPermissionChange()}_initDrawingVisible(){const i=this._univerInstanceService.getCurrentTypeOfUnit$(p.UniverInstanceType.UNIVER_SHEET);this.disposeWithMe(W.combineLatest([i,this._userManagerService.currentUser$]).subscribe(([n,r])=>{if(!n){this._drawingManagerService.setDrawingVisible(!1);return}n.activeSheet$.subscribe(e=>{if(!e){this._drawingManagerService.setDrawingVisible(!1);return}const t=n.getUnitId(),o=e.getSheetId();if(this._permissionService.composePermission([new I.WorkbookViewPermission(t).id,new I.WorksheetViewPermission(t,o).id]).every(c=>c.value))this._drawingManagerService.setDrawingVisible(!0);else{this._drawingManagerService.setDrawingVisible(!1);const c=n.getUnitId(),d=e.getSheetId(),g=this._drawingManagerService.getDrawingData(c,d),l=Object.values(g),s=this._renderManagerService.getRenderById(c),u=s==null?void 0:s.scene;if(u==null)return;u.getAllObjectsByOrder().forEach(f=>{f.classType===N.RENDER_CLASS_TYPE.IMAGE&&l.some(S=>f.oKey.includes(S.drawingId))&&u.removeObject(f)})}})}))}_initDrawingEditable(){const i=this._univerInstanceService.getCurrentTypeOfUnit$(p.UniverInstanceType.UNIVER_SHEET);this.disposeWithMe(W.combineLatest([i,this._userManagerService.currentUser$]).subscribe(([n,r])=>{if(!n){this._drawingManagerService.setDrawingEditable(!1);return}n.activeSheet$.subscribe(e=>{if(!e){this._drawingManagerService.setDrawingEditable(!1);return}const t=n.getUnitId(),o=e.getSheetId();if(this._permissionService.composePermission([new I.WorkbookEditablePermission(t).id,new I.WorksheetEditPermission(t,o).id]).every(c=>c.value))this._drawingManagerService.setDrawingEditable(!0);else{this._drawingManagerService.setDrawingEditable(!1);const c=n.getUnitId(),d=e.getSheetId(),g=this._drawingManagerService.getDrawingData(c,d),l=Object.values(g),s=this._renderManagerService.getRenderById(c),u=s==null?void 0:s.scene;if(u==null)return;u.getAllObjectsByOrder().forEach(f=>{f.classType===N.RENDER_CLASS_TYPE.IMAGE&&l.some(S=>f.oKey.includes(S.drawingId))&&u.detachTransformerFrom(f)})}})}))}_initViewPermissionChange(){const i=this._univerInstanceService.getCurrentTypeOfUnit$(p.UniverInstanceType.UNIVER_SHEET);this.disposeWithMe(W.combineLatest([i,this._userManagerService.currentUser$]).subscribe(([n,r])=>{n&&n.activeSheet$.subscribe(e=>{var s;if(!e)return;const t=n.getUnitId(),o=e.getSheetId();let a=!0;const c=this._renderManagerService.getRenderById(t),d=c==null?void 0:c.scene;if(d==null)return;const g=d.getTransformerByCreate(),l=this._permissionService.composePermission$([new I.WorkbookViewPermission(t).id,new I.WorksheetViewPermission(t,o).id]).pipe(W.map(u=>u.every(m=>m.value)));l==null||l.pipe(W.filter(u=>u!==a),W.distinctUntilChanged()).subscribe({next:u=>{a=u,this._drawingManagerService.setDrawingVisible(u);const m=d.getAllObjectsByOrder(),f=this._drawingManagerService.getDrawingData(t,o),S=Object.values(f);u?this._drawingManagerService.addNotification(S):(m.forEach(v=>{v.classType===N.RENDER_CLASS_TYPE.IMAGE&&S.some(y=>v.oKey.includes(y.drawingId))&&d.removeObject(v)}),g.clearSelectedObjects())}}),(s=this._permissionService.getPermissionPoint$(new I.WorksheetViewPermission(t,o).id))==null||s.pipe(W.filter(u=>u.value!==a),W.distinctUntilChanged()).subscribe({complete:()=>{a=!0,this._drawingManagerService.setDrawingVisible(!0);const u=this._drawingManagerService.getDrawingData(t,o),m=Object.values(u);this._drawingManagerService.addNotification(m)}})})}))}_initEditPermissionChange(){const i=this._univerInstanceService.getCurrentTypeOfUnit$(p.UniverInstanceType.UNIVER_SHEET);this.disposeWithMe(W.combineLatest([i,this._userManagerService.currentUser$]).subscribe(([n,r])=>{n&&n.activeSheet$.subscribe(e=>{var s;if(!e)return;const t=n.getUnitId(),o=e.getSheetId();let a=!0;const c=this._renderManagerService.getRenderById(t),d=c==null?void 0:c.scene;if(d==null)return;const g=d.getTransformerByCreate(),l=this._permissionService.composePermission$([new I.WorkbookEditablePermission(t).id,new I.WorksheetEditPermission(t,o).id]).pipe(W.map(u=>u.every(m=>m.value)));l==null||l.pipe(W.filter(u=>u!==a),W.distinctUntilChanged()).subscribe({next:u=>{a=u,this._drawingManagerService.setDrawingEditable(u);const m=d.getAllObjectsByOrder(),f=this._drawingManagerService.getDrawingData(t,o),S=Object.values(f);u?(m.forEach(v=>{v.classType===N.RENDER_CLASS_TYPE.IMAGE&&S.some(y=>v.oKey.includes(y.drawingId))&&d.attachTransformerTo(v)}),this._drawingManagerService.addNotification(S)):(m.forEach(v=>{v.classType===N.RENDER_CLASS_TYPE.IMAGE&&S.some(y=>v.oKey.includes(y.drawingId))&&d.detachTransformerFrom(v)}),g.clearSelectedObjects())}}),(s=this._permissionService.getPermissionPoint$(new I.WorksheetEditPermission(t,o).id))==null||s.pipe(W.filter(u=>u.value!==a),W.distinctUntilChanged()).subscribe({complete:()=>{a=!0;const u=n.getUnitId(),m=e.getSheetId(),f=this._drawingManagerService.getDrawingData(u,m),S=Object.values(f),v=this._renderManagerService.getRenderById(u),y=v==null?void 0:v.scene;if(y==null)return;this._drawingManagerService.setDrawingEditable(!0),y.getAllObjectsByOrder().forEach(C=>{C.classType===N.RENDER_CLASS_TYPE.IMAGE&&S.some(T=>C.oKey.includes(T.drawingId))&&y.detachTransformerFrom(C)})}})})}))}};we=Gt([ce(0,b.IDrawingManagerService),ce(1,N.IRenderManagerService),ce(2,p.IPermissionService),ce(3,p.IUniverInstanceService),ce(4,p.Inject(p.UserManagerService))],we);var kt=Object.defineProperty,Vt=Object.getOwnPropertyDescriptor,Ft=(i,n,r,e)=>{for(var t=e>1?void 0:e?Vt(n,r):n,o=i.length-1,a;o>=0;o--)(a=i[o])&&(t=(e?a(n,r,t):a(t))||t);return e&&t&&kt(n,r,t),t},_e=(i,n)=>(r,e)=>n(r,e,i);let Ie=class extends p.Disposable{constructor(i,n,r,e){super(),this._sheetPrintInterceptorService=i,this._drawingRenderService=n,this._drawingManagerService=r,this._renderManagerService=e,this._initPrinting()}_initPrinting(){this.disposeWithMe(this._sheetPrintInterceptorService.interceptor.intercept(this._sheetPrintInterceptorService.interceptor.getInterceptPoints().PRINTING_COMPONENT_COLLECT,{handler:(i,n,r)=>{const{unitId:e,scene:t,subUnitId:o}=n,a=this._drawingManagerService.getDrawingDataForUnit(e),c=a==null?void 0:a[o];return c&&c.order.forEach(d=>{this._drawingRenderService.renderDrawing(c.data[d],t)}),r()}})),this.disposeWithMe(this._sheetPrintInterceptorService.interceptor.intercept(this._sheetPrintInterceptorService.interceptor.getInterceptPoints().PRINTING_RANGE,{handler:(i,n,r)=>{const{unitId:e,subUnitId:t}=n,o=this._renderManagerService.getRenderById(e);if(!o)return r(i);const a=o.with(j.SheetSkeletonManagerService).getWorksheetSkeleton(t);if(!a)return r(i);const c=this._drawingManagerService.getDrawingDataForUnit(e),d=c==null?void 0:c[n.subUnitId];if(!d)return r(i);const{scaleX:g,scaleY:l}=o.scene,s=i?{...i}:{startColumn:0,endColumn:0,endRow:0,startRow:0},u=d.order.map(m=>d.data[m]).filter(m=>m.drawingType!==b.DrawingTypeEnum.DRAWING_DOM);return u.length?(u.forEach(m=>{if(!m.groupId&&m.transform&&p.Tools.isDefine(m.transform.left)&&p.Tools.isDefine(m.transform.top)&&p.Tools.isDefine(m.transform.width)&&p.Tools.isDefine(m.transform.height)){const f=a.skeleton.getCellIndexByOffset(m.transform.left,m.transform.top,g,l,{x:0,y:0}),S=a.skeleton.getCellIndexByOffset(m.transform.left+m.transform.width,m.transform.top+m.transform.height,g,l,{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)}}),r(s)):r(i)}}))}};Ie=Ft([_e(0,p.Inject(j.SheetPrintInterceptorService)),_e(1,p.Inject(ee.DrawingRenderService)),_e(2,b.IDrawingManagerService),_e(3,N.IRenderManagerService)],Ie);var $t=Object.defineProperty,Yt=Object.getOwnPropertyDescriptor,Ht=(i,n,r,e)=>{for(var t=e>1?void 0:e?Yt(n,r):n,o=i.length-1,a;o>=0;o--)(a=i[o])&&(t=(e?a(n,r,t):a(t))||t);return e&&t&&$t(n,r,t),t},Q=(i,n)=>(r,e)=>n(r,e,i);const xt=[I.InsertRowCommand.id,I.InsertColCommand.id,I.RemoveRowCommand.id,I.RemoveColCommand.id,I.DeleteRangeMoveLeftCommand.id,I.DeleteRangeMoveUpCommand.id,I.InsertRangeMoveDownCommand.id,I.InsertRangeMoveRightCommand.id,I.DeltaRowHeightCommand.id,I.SetRowHeightCommand.id,I.DeltaColumnWidthCommand.id,I.SetColWidthCommand.id,I.SetRowHiddenCommand.id,I.SetSpecificRowsVisibleCommand.id,I.SetSpecificColsVisibleCommand.id,I.SetColHiddenCommand.id,I.MoveColsCommand.id,I.MoveRowsCommand.id,I.MoveRangeCommand.id],Xt=[I.SetRowVisibleMutation.id,I.SetRowHiddenMutation.id,I.SetColVisibleMutation.id,I.SetColHiddenMutation.id,I.SetWorksheetRowHeightMutation.id,I.SetWorksheetColWidthMutation.id];let Pe=class extends p.Disposable{constructor(i,n,r,e,t,o,a,c,d){super(),this._context=i,this._renderManagerService=n,this._commandService=r,this._selectionRenderService=e,this._skeletonManagerService=t,this._sheetInterceptorService=o,this._sheetDrawingService=a,this._drawingManagerService=c,this._univerInstanceService=d,this._sheetInterceptorListener(),this._commandListener(),this._sheetRefreshListener()}_sheetInterceptorListener(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:i=>{if(!xt.includes(i.id))return{redos:[],undos:[]};if(i.params==null)return{redos:[],undos:[]};const n=i.id;if(n===I.InsertRowCommand.id)return this._moveRowInterceptor(i.params,"insert");if([I.MoveColsCommand.id,I.MoveRowsCommand.id,I.MoveRangeCommand.id].includes(n))return this._moveRangeInterceptor(i.params);if(n===I.InsertColCommand.id)return this._moveColInterceptor(i.params,"insert");if(n===I.RemoveRowCommand.id)return this._moveRowInterceptor(i.params,"remove");if(n===I.RemoveColCommand.id)return this._moveColInterceptor(i.params,"remove");if(n===I.DeleteRangeMoveLeftCommand.id){const{range:r}=i.params;return this._getRangeMoveUndo(r,0)}else if(n===I.DeleteRangeMoveUpCommand.id){const{range:r}=i.params;return this._getRangeMoveUndo(r,1)}else if(n===I.InsertRangeMoveDownCommand.id){const{range:r}=i.params;return this._getRangeMoveUndo(r,2)}else if(n===I.InsertRangeMoveRightCommand.id){const{range:r}=i.params;return this._getRangeMoveUndo(r,3)}else if(n===I.SetRowHiddenCommand.id||n===I.SetSpecificRowsVisibleCommand.id){const r=i.params,{unitId:e,subUnitId:t,ranges:o}=r;return this._getDrawingUndoForRowVisible(e,t,o)}else if(n===I.SetSpecificColsVisibleCommand.id||n===I.SetColHiddenCommand.id){const r=i.params,{unitId:e,subUnitId:t,ranges:o}=r;return this._getDrawingUndoForColVisible(e,t,o)}else if(n===I.DeltaRowHeightCommand.id||n===I.SetRowHeightCommand.id||n===I.DeltaColumnWidthCommand.id||n===I.SetColWidthCommand.id){const r=i.params,{unitId:e,subUnitId:t,ranges:o}=r,a=n===I.DeltaRowHeightCommand.id||n===I.SetRowHeightCommand.id;return this._getDrawingUndoForRowAndColSize(e,t,o,a)}return{redos:[],undos:[]}}}))}_getRangeMoveUndo(i,n){const r=I.getSheetCommandTarget(this._univerInstanceService);if(r==null)return{redos:[],undos:[]};const e=r.unitId,t=r.subUnitId,o=[],a=[],c=this._sheetDrawingService.getDrawingData(e,t),d=[],g=[];if(Object.keys(c).forEach(l=>{const s=c[l],{updateDrawings:u,deleteDrawings:m}=this._getUpdateOrDeleteDrawings(i,n,s);d.push(...u),g.push(...m)}),d.length===0&&g.length===0)return{redos:[],undos:[]};if(d.length>0){const l=this._sheetDrawingService.getBatchUpdateOp(d),{undo:s,redo:u,objects:m}=l;o.push({id:h.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:u,objects:m,type:h.DrawingApplyType.UPDATE}}),a.push({id:h.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:s,objects:m,type:h.DrawingApplyType.UPDATE}})}if(g.length>0){const l=this._sheetDrawingService.getBatchRemoveOp(g),s=l.undo,u=l.redo,m=l.objects;o.push({id:h.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:u,objects:m,type:h.DrawingApplyType.REMOVE}}),a.push({id:h.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:s,objects:m,type:h.DrawingApplyType.INSERT}})}return o.push({id:G.id,params:[e]}),a.push({id:G.id,params:[e]}),{redos:o,undos:a}}_getUpdateOrDeleteDrawings(i,n,r){const e=[],t=[],{sheetTransform:o,anchorType:a=h.SheetDrawingAnchorType.Position,transform:c,unitId:d,subUnitId:g,drawingId:l}=r,{from:s,to:u}=o,{row:m,column:f}=s,{row:S,column:v}=u;if(o==null||c==null)return{updateDrawings:e,deleteDrawings:t};const{startRow:y,endRow:M,startColumn:C,endColumn:T}=i;let _=null,D=null;if(n===0&&m>=y&&S<=M)if(f>=C&&v<=T)t.push({unitId:d,subUnitId:g,drawingId:l});else{const w=this._shrinkCol(o,c,C,T,a);_=w==null?void 0:w.newSheetTransform,D=w==null?void 0:w.newTransform}else if(n===1&&f>=C&&v<=T)if(m>=y&&S<=M)t.push({unitId:d,subUnitId:g,drawingId:l});else{const w=this._shrinkRow(o,c,y,M,a);_=w==null?void 0:w.newSheetTransform,D=w==null?void 0:w.newTransform}else if(n===2){const w=this._expandRow(o,c,y,M,a);_=w==null?void 0:w.newSheetTransform,D=w==null?void 0:w.newTransform}else if(n===3){const w=this._expandCol(o,c,C,T,a);_=w==null?void 0:w.newSheetTransform,D=w==null?void 0:w.newTransform}if(_!=null&&D!=null){const w=Y(_,this._selectionRenderService,this._skeletonManagerService);e.push({...r,sheetTransform:_,transform:w})}return{updateDrawings:e,deleteDrawings:t}}_remainDrawingSize(i,n,r){const e=k({...i},this._selectionRenderService);e!=null&&n.push({...r,sheetTransform:e})}_getDrawingUndoForColVisible(i,n,r){const e=this._drawingManagerService.getDrawingData(i,n),t=[],o=[];if(Object.keys(e).forEach(l=>{const s=e[l],{sheetTransform:u,transform:m,anchorType:f=h.SheetDrawingAnchorType.Position}=s;if(f===h.SheetDrawingAnchorType.None)this._remainDrawingSize(m,t,s);else{const{from:S,to:v}=u,{row:y,column:M}=S,{row:C,column:T}=v;for(let _=0;_<r.length;_++){const D=r[_],{startRow:w,endRow:A,startColumn:E,endColumn:L}=D;if(T<E)continue;if(f===h.SheetDrawingAnchorType.Position){let R=null,B=null;if(M>=E&&M<=L){const V=this._skeletonManagerService.attachRangeWithCoord({startColumn:M,endColumn:L,startRow:S.row,endRow:v.row});if(V==null)return;B={...m,left:V.startX}}if(B!=null&&(R=k(B,this._selectionRenderService),R!=null&&B!=null)){t.push({...s,sheetTransform:R,transform:B});break}this._remainDrawingSize(m,t,s);continue}if(M>=E&&T<=L)continue;let U=null,P=null;if(M>=E&&M<=L){const R=this._skeletonManagerService.attachRangeWithCoord({startColumn:M,endColumn:L,startRow:S.row,endRow:v.row});if(R==null)return;P={...m,left:(R==null?void 0:R.startX)||0,width:((m==null?void 0:m.width)||0)-R.endX+R.startX}}else if(T>=E&&T<=L){const R=this._skeletonManagerService.attachRangeWithCoord({startColumn:E,endColumn:T,startRow:S.row,endRow:v.row});if(R==null)return;P={...m,left:R.startX-((m==null?void 0:m.width)||0)}}else{const R=this._skeletonManagerService.attachRangeWithCoord({startColumn:E,endColumn:L,startRow:S.row,endRow:v.row});if(R==null)return;if(P={...m,width:((m==null?void 0:m.width)||0)-R.endX+R.startX},U=k(P,this._selectionRenderService),U!=null&&P!=null){o.push({...s,sheetTransform:U,transform:P});break}}if(P!=null&&(U=k(P,this._selectionRenderService)),P!=null&&U!=null){t.push({...s,sheetTransform:U,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,n,t),d=[],g=[];if(o.length>0){const{redos:l,undos:s}=this._createUndoAndRedoMutation(i,n,o);d.push(...l),g.push(...s)}return{redos:a,undos:c,preRedos:d,preUndos:g}}_createUndoAndRedoMutation(i,n,r){const e=this._sheetDrawingService.getBatchUpdateOp(r),{undo:t,redo:o,objects:a}=e,c=[{id:h.SetDrawingApplyMutation.id,params:{unitId:i,subUnitId:n,op:o,objects:a,type:h.DrawingApplyType.UPDATE}},{id:G.id,params:[i]}],d=[{id:h.SetDrawingApplyMutation.id,params:{unitId:i,subUnitId:n,op:t,objects:a,type:h.DrawingApplyType.UPDATE}},{id:G.id,params:[i]}];return{redos:c,undos:d}}_getDrawingUndoForRowVisible(i,n,r){const e=this._drawingManagerService.getDrawingData(i,n),t=[],o=[];if(Object.keys(e).forEach(l=>{const s=e[l],{sheetTransform:u,transform:m,anchorType:f=h.SheetDrawingAnchorType.Position}=s;if(f===h.SheetDrawingAnchorType.None)this._remainDrawingSize(m,t,s);else{const{from:S,to:v}=u,{row:y,column:M}=S,{row:C,column:T}=v;for(let _=0;_<r.length;_++){const D=r[_],{startRow:w,endRow:A,startColumn:E,endColumn:L}=D;if(C<w)continue;if(f===h.SheetDrawingAnchorType.Position){let R=null,B=null;if(y>=w&&y<=A){const V=this._skeletonManagerService.attachRangeWithCoord({startColumn:S.column,endColumn:v.column,startRow:y,endRow:A});if(V==null)return;B={...m,top:V.startY}}if(B!=null&&(R=k(B,this._selectionRenderService),R!=null&&B!=null)){t.push({...s,sheetTransform:R,transform:B});break}this._remainDrawingSize(m,t,s);continue}if(y>=w&&C<=A)continue;let U=null,P=null;if(y>=w&&y<=A){const R=this._skeletonManagerService.attachRangeWithCoord({startColumn:S.column,endColumn:v.column,startRow:y,endRow:A});if(R==null)return;P={...m,top:(R==null?void 0:R.startY)||0,height:((m==null?void 0:m.height)||0)-R.endY+R.startY}}else if(C>=w&&C<=A){const R=this._skeletonManagerService.attachRangeWithCoord({startColumn:S.column,endColumn:v.column,startRow:w,endRow:C});if(R==null)return;P={...m,top:R.startY-((m==null?void 0:m.height)||0)}}else{const R=this._skeletonManagerService.attachRangeWithCoord({startColumn:S.column,endColumn:v.column,startRow:w,endRow:A});if(R==null)return;if(P={...m,height:((m==null?void 0:m.height)||0)-R.endY+R.startY},U=k(P,this._selectionRenderService),U!=null&&P!=null){o.push({...s,sheetTransform:U,transform:P});break}}if(P!=null&&(U=k(P,this._selectionRenderService)),P!=null&&U!=null){t.push({...s,sheetTransform:U,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,n,t),d=[],g=[];if(o.length>0){const{redos:l,undos:s}=this._createUndoAndRedoMutation(i,n,o);d.push(...l),g.push(...s)}return{redos:a,undos:c,preRedos:d,preUndos:g}}_getDrawingUndoForRowAndColSize(i,n,r,e){const t=this._drawingManagerService.getDrawingData(i,n),o=[];return Object.keys(t).forEach(a=>{const c=t[a],{sheetTransform:d,transform:g,anchorType:l=h.SheetDrawingAnchorType.Position}=c;if(l===h.SheetDrawingAnchorType.None)this._remainDrawingSize(g,o,c);else{const{from:s,to:u}=d,{row:m,column:f}=s,{row:S,column:v}=u;for(let y=0;y<r.length;y++){const M=r[y],{startRow:C,endRow:T,startColumn:_,endColumn:D}=M;if(S<C||v<_)continue;if(l===h.SheetDrawingAnchorType.Position&&(m<=C&&S>=T||f<=_&&v>=D)){this._remainDrawingSize(g,o,c);continue}const w=Y({...d},this._selectionRenderService,this._skeletonManagerService);if(w!=null){o.push({...c,transform:w});break}}}}),o.length===0?{redos:[],undos:[]}:this._createUndoAndRedoMutation(i,n,o)}_getUnitIdAndSubUnitId(i,n){let r,e;if(n==="insert")r=i.unitId,e=i.subUnitId;else{const t=I.getSheetCommandTarget(this._univerInstanceService);if(t==null)return;r=t.unitId,e=t.subUnitId}return{unitId:r,subUnitId:e}}_moveRangeInterceptor(i){var C,T;const{toRange:n,fromRange:r}=i,e=I.getSheetCommandTarget(this._univerInstanceService);if(!e)return{redos:[],undos:[]};const{unitId:t,subUnitId:o}=e,a=(T=(C=this._renderManagerService.getRenderById(t))==null?void 0:C.with(j.SheetSkeletonManagerService))==null?void 0:T.getCurrentSkeleton();if(!a)return{redos:[],undos:[]};const c=j.attachRangeWithCoord(a,r);if(!c)return{redos:[],undos:[]};const{startX:d,endX:g,startY:l,endY:s}=c,u=this._sheetDrawingService.getDrawingData(t,o),m=[];Object.keys(u).forEach(_=>{const D=u[_];if(D.anchorType!==h.SheetDrawingAnchorType.Both)return;const{transform:w}=D;if(!w)return;const{left:A=0,top:E=0,width:L=0,height:U=0}=w,{drawingStartX:P,drawingEndX:R,drawingStartY:B,drawingEndY:V}={drawingStartX:A,drawingEndX:A+L,drawingStartY:E,drawingEndY:E+U};d<=P&&R<=g&&l<=B&&V<=s&&m.push(D)});const f=[],S=[],v=n.startRow-r.startRow,y=n.startColumn-r.startColumn,M=m.map(_=>{const D=_.sheetTransform,w={to:{...D.to,row:D.to.row+v,column:D.to.column+y},from:{...D.from,row:D.from.row+v,column:D.from.column+y}},A=Y(w,this._selectionRenderService,this._skeletonManagerService);return{unitId:t,subUnitId:o,drawingId:_.drawingId,transform:A,sheetTransform:w}});if(M.length){const _=this._sheetDrawingService.getBatchUpdateOp(M),{undo:D,redo:w,objects:A}=_;f.push({id:h.SetDrawingApplyMutation.id,params:{unitId:t,subUnitId:o,op:w,objects:A,type:h.DrawingApplyType.UPDATE}}),S.push({id:h.SetDrawingApplyMutation.id,params:{unitId:t,subUnitId:o,op:D,objects:A,type:h.DrawingApplyType.UPDATE}})}return{redos:f,undos:S}}_moveRowInterceptor(i,n){const r=this._getUnitIdAndSubUnitId(i,n);if(r==null)return{redos:[],undos:[]};const{unitId:e,subUnitId:t}=r,{range:o}=i,a=o.startRow,c=o.endRow,d=[],g=[],l=this._sheetDrawingService.getDrawingData(e,t),s=[],u=[];if(Object.keys(l).forEach(m=>{const f=l[m],{sheetTransform:S,transform:v,anchorType:y=h.SheetDrawingAnchorType.Position}=f;if(S==null||v==null)return;let M,C;if(n==="insert"){const _=this._expandRow(S,v,a,c,y);M=_==null?void 0:_.newSheetTransform,C=_==null?void 0:_.newTransform}else{const{from:_,to:D}=S,{row:w}=_,{row:A}=D;if(y===h.SheetDrawingAnchorType.Both&&w>=a&&A<=c)u.push({unitId:e,subUnitId:t,drawingId:m});else{const E=this._shrinkRow(S,v,a,c,y);M=E==null?void 0:E.newSheetTransform,C=E==null?void 0:E.newTransform}}if(!M||!C)return;const T={unitId:e,subUnitId:t,drawingId:m,transform:C,sheetTransform:M};s.push(T)}),s.length===0&&u.length===0)return{redos:[],undos:[]};if(s.length>0){const m=this._sheetDrawingService.getBatchUpdateOp(s),{undo:f,redo:S,objects:v}=m;d.push({id:h.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:S,objects:v,type:h.DrawingApplyType.UPDATE}}),g.push({id:h.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:f,objects:v,type:h.DrawingApplyType.UPDATE}})}if(u.length>0){const m=this._sheetDrawingService.getBatchRemoveOp(u),f=m.undo,S=m.redo,v=m.objects;d.push({id:h.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:S,objects:v,type:h.DrawingApplyType.REMOVE}}),g.push({id:h.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:f,objects:v,type:h.DrawingApplyType.INSERT}})}return d.push({id:G.id,params:[e]}),g.push({id:G.id,params:[e]}),{redos:d,undos:g}}_moveColInterceptor(i,n){const r=this._getUnitIdAndSubUnitId(i,n);if(r==null)return{redos:[],undos:[]};const{unitId:e,subUnitId:t}=r,{range:o}=i,a=o.startColumn,c=o.endColumn,d=[],g=[],l=this._sheetDrawingService.getDrawingData(e,t),s=[],u=[];if(Object.keys(l).forEach(m=>{const f=l[m],{sheetTransform:S,transform:v,anchorType:y=h.SheetDrawingAnchorType.Position}=f;if(S==null||v==null)return;let M,C;if(n==="insert"){const _=this._expandCol(S,v,a,c,y);M=_==null?void 0:_.newSheetTransform,C=_==null?void 0:_.newTransform}else{const{from:_,to:D}=S,{column:w}=_,{column:A}=D;if(y===h.SheetDrawingAnchorType.Both&&w>=a&&A<=c)u.push({unitId:e,subUnitId:t,drawingId:m});else{const E=this._shrinkCol(S,v,a,c,y);M=E==null?void 0:E.newSheetTransform,C=E==null?void 0:E.newTransform}}if(!M||!C)return;const T={unitId:e,subUnitId:t,drawingId:m,transform:C,sheetTransform:M};s.push(T)}),s.length===0&&u.length===0)return{redos:[],undos:[]};if(s.length>0){const m=this._sheetDrawingService.getBatchUpdateOp(s),{undo:f,redo:S,objects:v}=m;d.push({id:h.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:S,objects:v,type:h.DrawingApplyType.UPDATE}}),g.push({id:h.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:f,objects:v,type:h.DrawingApplyType.UPDATE}})}if(u.length>0){const m=this._sheetDrawingService.getBatchRemoveOp(u),f=m.undo,S=m.redo,v=m.objects;d.push({id:h.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:S,objects:v,type:h.DrawingApplyType.REMOVE}}),g.push({id:h.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:f,objects:v,type:h.DrawingApplyType.INSERT}})}return d.push({id:G.id,params:[e]}),g.push({id:G.id,params:[e]}),{redos:d,undos:g}}_expandCol(i,n,r,e,t=h.SheetDrawingAnchorType.Position){const o=e-r+1,{from:a,to:c}=i,{column:d}=a,{column:g}=c;if(t===h.SheetDrawingAnchorType.None)return{newSheetTransform:k({...n},this._selectionRenderService),newTransform:n};let l=null,s=null;if(d>=r){const u=this._skeletonManagerService.attachRangeWithCoord({startColumn:r,endColumn:e,startRow:a.row,endRow:c.row});if(u==null)return;s={...n,left:(n.left||0)+u.endX-u.startX},l=k(s,this._selectionRenderService)}else if(g>=e)if(t===h.SheetDrawingAnchorType.Both)l={from:{...a},to:{...c,column:g+o}},s=Y(l,this._selectionRenderService,this._skeletonManagerService);else return{newSheetTransform:k({...n},this._selectionRenderService),newTransform:n};return l!=null&&s!=null?{newSheetTransform:l,newTransform:s}:null}_shrinkCol(i,n,r,e,t=h.SheetDrawingAnchorType.Position){const o=e-r+1,{from:a,to:c}=i,{column:d}=a,{column:g}=c;if(t===h.SheetDrawingAnchorType.None)return{newSheetTransform:k({...n},this._selectionRenderService),newTransform:n};let l=null,s=null;if(d>e)l={from:{...a,column:d-o},to:{...c,column:g-o}},s=Y(l,this._selectionRenderService,this._skeletonManagerService);else{if(d>=r&&g<=e)return null;if(d<r&&g>e)if(t===h.SheetDrawingAnchorType.Both)l={from:{...a},to:{...c,column:g-o}},s=Y(l,this._selectionRenderService,this._skeletonManagerService);else return{newSheetTransform:k({...n},this._selectionRenderService),newTransform:n};else if(d>=r&&d<=e){if(d===r)s={...n,left:(n.left||0)-i.from.columnOffset};else{const u=this._skeletonManagerService.attachRangeWithCoord({startColumn:r,endColumn:d-1,startRow:a.row,endRow:c.row});if(u==null)return;s={...n,left:(n.left||0)-u.endX+u.startX-i.from.columnOffset}}l=k(s,this._selectionRenderService)}else if(g>=r&&g<=e&&t===h.SheetDrawingAnchorType.Both){const u=this._skeletonManagerService.attachRangeWithCoord({startColumn:r-1,endColumn:r-1,startRow:a.row,endRow:c.row});if(u==null)return;l={from:{...a},to:{...c,column:r-1,columnOffset:u.endX-u.startX}},s=Y(l,this._selectionRenderService,this._skeletonManagerService)}}return l!=null&&s!=null?{newSheetTransform:l,newTransform:s}:null}_expandRow(i,n,r,e,t=h.SheetDrawingAnchorType.Position){const o=e-r+1,{from:a,to:c}=i,{row:d}=a,{row:g}=c;if(t===h.SheetDrawingAnchorType.None)return{newSheetTransform:k({...n},this._selectionRenderService),newTransform:n};let l=null,s=null;if(d>=r){const u=this._skeletonManagerService.attachRangeWithCoord({startRow:r,endRow:e,startColumn:a.column,endColumn:c.column});if(u==null)return;s={...n,top:(n.top||0)+u.endY-u.startY},l=k(s,this._selectionRenderService)}else if(g>=e)if(t===h.SheetDrawingAnchorType.Both)l={from:{...a},to:{...c,row:g+o}},s=Y(l,this._selectionRenderService,this._skeletonManagerService);else return{newSheetTransform:k({...n},this._selectionRenderService),newTransform:n};return l!=null&&s!=null?{newSheetTransform:l,newTransform:s}:null}_shrinkRow(i,n,r,e,t=h.SheetDrawingAnchorType.Position){const o=e-r+1,{from:a,to:c}=i,{row:d}=a,{row:g}=c;if(t===h.SheetDrawingAnchorType.None)return{newSheetTransform:k({...n},this._selectionRenderService),newTransform:n};let l=null,s=null;if(d>e)l={from:{...a,row:d-o},to:{...c,row:g-o}},s=Y(l,this._selectionRenderService,this._skeletonManagerService);else{if(d>=r&&g<=e)return null;if(d<r&&g>e)if(t===h.SheetDrawingAnchorType.Both)l={from:{...a},to:{...c,row:g-o}},s=Y(l,this._selectionRenderService,this._skeletonManagerService);else return{newSheetTransform:k({...n},this._selectionRenderService),newTransform:n};else if(d>=r&&d<=e){if(d===r)s={...n,top:(n.top||0)-i.from.rowOffset};else{const u=this._skeletonManagerService.attachRangeWithCoord({startRow:r,endRow:d-1,startColumn:a.column,endColumn:c.column});if(u==null)return;s={...n,top:(n.top||0)-u.endY+u.startY-i.from.rowOffset}}l=k(s,this._selectionRenderService)}else if(g>=r&&g<=e&&t===h.SheetDrawingAnchorType.Both){const u=this._skeletonManagerService.attachRangeWithCoord({startColumn:a.column,endColumn:a.column,startRow:r-1,endRow:r-1});if(u==null)return;l={from:{...a},to:{...c,row:r-1,rowOffset:u.endY-u.startY}},s=Y(l,this._selectionRenderService,this._skeletonManagerService)}}return l!=null&&s!=null?{newSheetTransform:l,newTransform:s}:null}_commandListener(){this.disposeWithMe(this._commandService.onCommandExecuted(i=>{i.id===I.SetWorksheetActiveOperation.id&&setTimeout(()=>{const n=i.params,{unitId:r,subUnitId:e}=n,t=this._drawingManagerService.drawingManagerData,o=[],a=[];Object.keys(t).forEach(c=>{const d=t[c];d!=null&&Object.keys(d).forEach(g=>{const l=d[g].data;l!=null&&Object.keys(l).forEach(s=>{if(c===r&&g===e){const u=l[s];u.transform=Y(u.sheetTransform,this._selectionRenderService,this._skeletonManagerService),o.push(l[s])}else a.push(l[s])})})}),this._drawingManagerService.removeNotification(a),this._drawingManagerService.addNotification(o)},0)}))}_sheetRefreshListener(){this.disposeWithMe(this._commandService.onCommandExecuted(i=>{Xt.includes(i.id)&&requestIdleCallback(()=>{const n=i.params,{unitId:r,subUnitId:e,ranges:t}=n;this._refreshDrawingTransform(r,e,t)})}))}_refreshDrawingTransform(i,n,r){const e=this._drawingManagerService.getDrawingData(i,n),t=[];Object.keys(e).forEach(o=>{const a=e[o],{sheetTransform:c,transform:d,anchorType:g=h.SheetDrawingAnchorType.Position}=a;if(g===h.SheetDrawingAnchorType.None)return!0;const{from:l,to:s}=c,{row:u,column:m}=l,{row:f,column:S}=s;for(let v=0;v<r.length;v++){const y=r[v],{startRow:M,endRow:C,startColumn:T,endColumn:_}=y;if(p.Rectangle.intersects({startRow:M,endRow:C,startColumn:T,endColumn:_},{startRow:u,endRow:f,startColumn:m,endColumn:S})||u>C||m>_){const D=g===h.SheetDrawingAnchorType.Position,w=Y(c,this._selectionRenderService,this._skeletonManagerService);t.push({...a,transform:{...w,width:D?d==null?void 0:d.width:w==null?void 0:w.width,height:D?d==null?void 0:d.height:w==null?void 0:w.height}});break}}}),t.length!==0&&(this._drawingManagerService.refreshTransform(t),this._commandService.syncExecuteCommand(G.id,[i]))}};Pe=Ht([Q(1,N.IRenderManagerService),Q(2,p.ICommandService),Q(3,j.ISheetSelectionRenderService),Q(4,p.Inject(j.SheetSkeletonManagerService)),Q(5,p.Inject(I.SheetInterceptorService)),Q(6,h.ISheetDrawingService),Q(7,b.IDrawingManagerService),Q(8,p.IUniverInstanceService)],Pe);var Kt=Object.defineProperty,zt=Object.getOwnPropertyDescriptor,Jt=(i,n,r,e)=>{for(var t=e>1?void 0:e?zt(n,r):n,o=i.length-1,a;o>=0;o--)(a=i[o])&&(t=(e?a(n,r,t):a(t))||t);return e&&t&&Kt(n,r,t),t},ne=(i,n)=>(r,e)=>n(r,e,i);function Zt(i,n,r,e){const{scaleX:t,scaleY:o}=n.getAncestorScale(),a=n.getViewport(N.SHEET_VIEWPORT_KEY.VIEW_MAIN),c={left:!0,top:!0};if(!a)return{...i,absolute:c};const{left:d,right:g,top:l,bottom:s}=i,u=e.getFreeze(),{startColumn:m,startRow:f,xSplit:S,ySplit:v}=u,y=r.getNoMergeCellPositionByIndexWithNoHeader(f-v,m-S),M=r.getNoMergeCellPositionByIndexWithNoHeader(f,m),{rowHeaderWidth:C,columnHeaderHeight:T}=r,_=M.startX-y.startX,D=M.startY-y.startY,{top:w,left:A,viewportScrollX:E,viewportScrollY:L}=a;let U,P;d<A?(c.left=!0,U=(_+C+(d-A))*t,P=Math.max(Math.min((_+C+(g-A))*t,(_+C)*t),(g-E)*t)):(c.left=!1,U=Math.max((d-E)*t,(_+C)*t),P=Math.max((g-E)*t,(_+C)*t));let R,B;return l<w?(c.top=!0,R=(D+T+(l-w))*o,B=Math.max(Math.min((D+T+(g-w))*o,(D+T)*o),(s-L)*o)):(c.top=!1,R=Math.max((l-L)*o,(D+T)*o),B=Math.max((s-L)*o,(D+T)*o)),{left:U,right:P,top:R,bottom:B,absolute:c}}const Ae=(i,n,r,e)=>{const{scene:t}=n,{left:o,top:a,width:c,height:d,angle:g}=i,l={left:o,right:o+c,top:a,bottom:a+d},s=Zt(l,t,r,e),{scaleX:u,scaleY:m}=t.getAncestorScale();return{startX:s.left,endX:s.right,startY:s.top,endY:s.bottom,rotate:g,width:c*u,height:d*m,absolute:s.absolute}};O.SheetCanvasFloatDomManagerService=class extends p.Disposable{constructor(r,e,t,o,a,c,d){super();X(this,"_domLayerMap",new Map);X(this,"_domLayerInfoMap",new Map);X(this,"_transformChange$",new W.Subject);X(this,"transformChange$",this._transformChange$.asObservable());X(this,"_add$",new W.Subject);X(this,"add$",this._add$.asObservable());X(this,"_remove$",new W.Subject);X(this,"remove$",this._remove$.asObservable());X(this,"_hooks",[]);this._renderManagerService=r,this._univerInstanceService=e,this._commandService=t,this._drawingManagerService=o,this._canvasFloatDomService=a,this._sheetDrawingService=c,this._lifecycleService=d,this._drawingAddListener(),this._featureUpdateListener(),this._deleteListener(),this._bindScrollEvent()}_bindScrollEvent(){this._lifecycleService.lifecycle$.pipe(W.filter(r=>r===p.LifecycleStages.Rendered),W.take(1)).subscribe(()=>{this._scrollUpdateListener()})}_ensureMap(r,e){let t=this._domLayerMap.get(r);t||(t=new Map,this._domLayerMap.set(r,t));let o=t.get(e);return o||(o=new Map,t.set(e,o)),o}getFloatDomInfo(r){return this._domLayerInfoMap.get(r)}_getSceneAndTransformerByDrawingSearch(r){if(r==null)return;const e=this._renderManagerService.getRenderById(r),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(r){let e;return this._hooks.forEach(t=>{e=t.onGetFloatDomProps(r)}),e}_drawingAddListener(){this.disposeWithMe(this._drawingManagerService.add$.subscribe(r=>{r.forEach(e=>{var Xe,Ke,ze;const{unitId:t,subUnitId:o,drawingId:a}=e,c=I.getSheetCommandTarget(this._univerInstanceService,{unitId:t,subUnitId:o}),d=this._drawingManagerService.getDrawingByParam(e),g=this._univerInstanceService.getUnit(t);if(!g)return;const l=g.getActiveSheet().getSheetId();if(!d||!c)return;const s=(Xe=this._renderManagerService.getRenderById(t))==null?void 0:Xe.with(j.SheetSkeletonManagerService).getWorksheetSkeleton(o);if(!s)return;const{transform:u,drawingType:m,data:f}=d;if(m!==b.DrawingTypeEnum.DRAWING_DOM&&m!==b.DrawingTypeEnum.DRAWING_CHART)return;const S=this._getSceneAndTransformerByDrawingSearch(t);if(S==null)return;const{scene:v,canvas:y}=S;if(u==null)return!0;if(l!==o)return;const{left:M,top:C,width:T,height:_,angle:D,flipX:w,flipY:A,skewX:E,skewY:L}=u,U=b.getDrawingShapeKeyByDrawingSearch({unitId:t,subUnitId:o,drawingId:a}),P=v.getObject(U);if(P!=null){P.transformByState({left:M,top:C,width:T,height:_,angle:D,flipX:w,flipY:A,skewX:E,skewY:L});return}const R={left:M,top:C,width:T,height:_,zIndex:this._drawingManagerService.getDrawingOrder(t,o).length-1},B=m===b.DrawingTypeEnum.DRAWING_CHART;B&&(R.fill="white",R.rotateEnabled=!1,f&&f.border&&(R.stroke=f.border),R.paintFirst="stroke",R.strokeWidth=1,R.borderEnabled=!1,R.radius=8);const V=new N.Rect(U,R);B&&V.setObjectType(N.ObjectType.CHART),v.addObject(V,N.DRAWING_OBJECT_LAYER_INDEX),d.allowTransform!==!1&&v.attachTransformerTo(V);const J=this._ensureMap(t,o),Ne=new p.DisposableCollection,nn=Ae(V,S.renderObject,s.skeleton,c.worksheet),je=new W.BehaviorSubject(nn),rn={dispose:Ne,rect:V,position$:je,unitId:t,subUnitId:o};this._canvasFloatDomService.addFloatDom({position$:je,id:a,componentKey:d.componentKey,onPointerDown:x=>{y.dispatchEvent(new PointerEvent(x.type,x))},onPointerMove:x=>{y.dispatchEvent(new PointerEvent(x.type,x))},onPointerUp:x=>{y.dispatchEvent(new PointerEvent(x.type,x))},onWheel:x=>{y.dispatchEvent(new WheelEvent(x.type,x))},props:(ze=(Ke=J.get(a))==null?void 0:Ke.props)!=null?ze:this._getFloatDomProps(a),data:f,unitId:t});const xe=V.onTransformChange$.subscribeEvent(()=>{const x=Ae(V,S.renderObject,s.skeleton,c.worksheet);je.next(x)});Ne.add(()=>{this._canvasFloatDomService.removeFloatDom(a)}),xe&&Ne.add(xe),this._domLayerInfoMap.set(a,rn),J.set(a,{...J.get(a)})})})),this.disposeWithMe(this._drawingManagerService.remove$.subscribe(r=>{r.forEach(e=>{const{unitId:t,subUnitId:o,drawingId:a}=e,c=b.getDrawingShapeKeyByDrawingSearch({unitId:t,subUnitId:o,drawingId:a}),d=this._getSceneAndTransformerByDrawingSearch(t);if(d==null)return;const{transformer:g,scene:l}=d,s=l.getObject(c);s!=null&&s.oKey&&g.clearControlByIds([s==null?void 0:s.oKey])})}))}_scrollUpdateListener(){const r=(e,t)=>{var l;const o=this._getSceneAndTransformerByDrawingSearch(e),a=this._ensureMap(e,t),c=Array.from(a.keys()),d=I.getSheetCommandTarget(this._univerInstanceService,{unitId:e,subUnitId:t}),g=(l=this._renderManagerService.getRenderById(e))==null?void 0:l.with(j.SheetSkeletonManagerService).getWorksheetSkeleton(t);!o||!d||!g||c.forEach(s=>{const u=this._domLayerInfoMap.get(s);if(u){const m=Ae(u.rect,o.renderObject,g.skeleton,d.worksheet);u.position$.next(m)}})};this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(p.UniverInstanceType.UNIVER_SHEET).pipe(W.filter(e=>!!e),W.switchMap(e=>e.activeSheet$),W.filter(e=>!!e),W.map(e=>{const t=this._renderManagerService.getRenderById(e.getUnitId());return t?{render:t,unitId:e.getUnitId(),subUnitId:e.getSheetId()}:null}),W.filter(e=>!!e),W.switchMap(e=>p.fromEventSubject(e.render.scene.getViewport(j.VIEWPORT_KEY.VIEW_MAIN).onScrollAfter$).pipe(W.map(()=>({unitId:e.unitId,subUnitId:e.subUnitId}))))).subscribe(({unitId:e,subUnitId:t})=>{r(e,t)})),this.disposeWithMe(this._commandService.onCommandExecuted(e=>{var t,o;if(e.id===j.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(g=>{r(c,g)})}else if(e.id===I.SetFrozenMutation.id){const{unitId:a,subUnitId:c}=e.params;r(a,c)}}))}_getPosition(r,e){var m;const{startX:t,endX:o,startY:a,endY:c}=r,d=(m=this._renderManagerService.getRenderById(e))==null?void 0:m.with(j.ISheetSelectionRenderService);if(d==null)return;const g=d.getCellWithCoordByOffset(t,a);if(g==null)return;const l={column:g.actualColumn,columnOffset:t-g.startX,row:g.actualRow,rowOffset:a-g.startY},s=d.getCellWithCoordByOffset(o,c);if(s==null)return;const u={column:s.actualColumn,columnOffset:o-s.startX,row:s.actualRow,rowOffset:c-s.startY};return{from:l,to:u}}_featureUpdateListener(){this.disposeWithMe(this._drawingManagerService.update$.subscribe(r=>{r.forEach(e=>{const t=this._drawingManagerService.getDrawingByParam(e);if(!t||t.drawingType!==b.DrawingTypeEnum.DRAWING_DOM&&t.drawingType!==b.DrawingTypeEnum.DRAWING_CHART)return;const o={...t.transform};this._transformChange$.next({id:e.drawingId,value:o})})}))}_deleteListener(){this.disposeWithMe(this._drawingManagerService.remove$.subscribe(r=>{r.forEach(e=>{this._removeDom(e.drawingId)})}))}updateFloatDomProps(r,e,t,o){const a=this._domLayerInfoMap.get(t),c=this._getSceneAndTransformerByDrawingSearch(r);if(a&&c){const{scene:d}=c,g=b.getDrawingShapeKeyByDrawingSearch({unitId:r,subUnitId:e,drawingId:t}),l=d.getObject(g);l&&l instanceof N.Rect&&l.setProps(o)}}addFloatDomToPosition(r,e){const t=I.getSheetCommandTarget(this._univerInstanceService,{unitId:r.unitId,subUnitId:r.subUnitId});if(!t)throw new Error("cannot find current target!");const{unitId:o,subUnitId:a}=t,{initPosition:c,componentKey:d,data:g,allowTransform:l=!0}=r,s=e!=null?e:p.generateRandomId(),u=this._getPosition(c,o);if(u==null)return;this._ensureMap(o,a).set(s,r);const f={unitId:o,subUnitId:a,drawingId:s,drawingType:r.type||b.DrawingTypeEnum.DRAWING_DOM,componentKey:d,sheetTransform:u,transform:{left:c.startX,top:c.startY,width:c.endX-c.startX,height:c.endY-c.startY},data:g,allowTransform:l};return this._commandService.executeCommand(oe.id,{unitId:o,drawings:[f]}),this._add$.next({unitId:o,subUnitId:a,id:s}),{id:s,dispose:()=>{this._removeDom(s,!0)}}}_removeDom(r,e=!1){const t=this._domLayerInfoMap.get(r);if(!t)return;const{unitId:o,subUnitId:a}=t;this._domLayerInfoMap.delete(r),t.dispose.dispose();const c=this._getSceneAndTransformerByDrawingSearch(o);if(c&&c.scene.removeObject(t.rect),e){this._ensureMap(o,a).delete(r);const g=this._drawingManagerService.getDrawingByParam({unitId:o,subUnitId:a,drawingId:r});if(!g)return;const l=this._sheetDrawingService.getBatchRemoveOp([g]),{redo:s,objects:u}=l;this._commandService.syncExecuteCommand(h.SetDrawingApplyMutation.id,{unitId:o,subUnitId:a,op:s,objects:u,type:h.DrawingApplyType.REMOVE})}}addHook(r){return this._hooks.push(r),{dispose:()=>{const e=this._hooks.findIndex(t=>t===r);this._hooks.splice(e,1)}}}},O.SheetCanvasFloatDomManagerService=Jt([ne(0,p.Inject(N.IRenderManagerService)),ne(1,p.IUniverInstanceService),ne(2,p.Inject(p.ICommandService)),ne(3,b.IDrawingManagerService),ne(4,p.Inject(F.CanvasFloatDomService)),ne(5,h.ISheetDrawingService),ne(6,p.Inject(p.LifecycleService))],O.SheetCanvasFloatDomManagerService);var Ye=Object.defineProperty,qt=Object.getOwnPropertyDescriptor,Qt=(i,n,r)=>n in i?Ye(i,n,{enumerable:!0,configurable:!0,writable:!0,value:r}):i[n]=r,en=(i,n,r,e)=>{for(var t=e>1?void 0:e?qt(n,r):n,o=i.length-1,a;o>=0;o--)(a=i[o])&&(t=(e?a(n,r,t):a(t))||t);return e&&t&&Ye(n,r,t),t},Ue=(i,n)=>(r,e)=>n(r,e,i),He=(i,n,r)=>Qt(i,typeof n!="symbol"?n+"":n,r);const tn="SHEET_IMAGE_UI_PLUGIN";O.UniverSheetsDrawingUIPlugin=class extends p.Plugin{constructor(n=Ze,r,e,t){super(),this._config=n,this._injector=r,this._renderManagerService=e,this._configService=t;const{menu:o,...a}=this._config;o&&this._configService.setConfig("menu",o,{merge:!0}),this._configService.setConfig(Je,a)}onStarting(){p.registerDependencies(this._injector,[[O.SheetCanvasFloatDomManagerService],[Se],[ue],[Ie],[we],[ve]]),p.touchDependencies(this._injector,[[O.SheetCanvasFloatDomManagerService]])}onReady(){p.touchDependencies(this._injector,[[ve]])}onRendered(){this._registerRenderModules(),p.touchDependencies(this._injector,[[we],[Ie],[Se]])}onSteady(){this._injector.get(ue)}_registerRenderModules(){[[ge],[Pe],[Me]].forEach(n=>{this.disposeWithMe(this._renderManagerService.registerRenderModule(p.UniverInstanceType.UNIVER_SHEET,n))})}},He(O.UniverSheetsDrawingUIPlugin,"type",p.UniverInstanceType.UNIVER_SHEET),He(O.UniverSheetsDrawingUIPlugin,"pluginName",tn),O.UniverSheetsDrawingUIPlugin=en([p.DependentOn(b.UniverDrawingPlugin,ee.UniverDrawingUIPlugin,h.UniverSheetsDrawingPlugin),Ue(1,p.Inject(p.Injector)),Ue(2,N.IRenderManagerService),Ue(3,p.IConfigService)],O.UniverSheetsDrawingUIPlugin),O.ClearSheetDrawingTransformerOperation=G,O.DeleteDrawingsCommand=De,O.EditSheetDrawingOperation=ye,O.GroupSheetDrawingCommand=Re,O.IMAGE_MENU_ID=Ee,O.InsertFloatImageCommand=pe,O.InsertSheetDrawingCommand=oe,O.MoveDrawingsCommand=re,O.RemoveSheetDrawingCommand=ie,O.SetDrawingArrangeCommand=Te,O.SetSheetDrawingCommand=ae,O.SidebarSheetDrawingOperation=Ce,O.UngroupSheetDrawingCommand=be,Object.defineProperty(O,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.0-nightly.
|
|
3
|
+
"version": "0.5.0-nightly.202411211606",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "",
|
|
6
6
|
"author": "DreamNum <developer@univer.ai>",
|
|
@@ -59,15 +59,15 @@
|
|
|
59
59
|
"dependencies": {
|
|
60
60
|
"@univerjs/icons": "^0.2.7",
|
|
61
61
|
"clsx": "^2.1.1",
|
|
62
|
-
"@univerjs/core": "0.5.0-nightly.
|
|
63
|
-
"@univerjs/design": "0.5.0-nightly.
|
|
64
|
-
"@univerjs/drawing": "0.5.0-nightly.
|
|
65
|
-
"@univerjs/
|
|
66
|
-
"@univerjs/
|
|
67
|
-
"@univerjs/
|
|
68
|
-
"@univerjs/sheets-drawing": "0.5.0-nightly.
|
|
69
|
-
"@univerjs/ui": "0.5.0-nightly.
|
|
70
|
-
"@univerjs/
|
|
62
|
+
"@univerjs/core": "0.5.0-nightly.202411211606",
|
|
63
|
+
"@univerjs/design": "0.5.0-nightly.202411211606",
|
|
64
|
+
"@univerjs/drawing-ui": "0.5.0-nightly.202411211606",
|
|
65
|
+
"@univerjs/sheets": "0.5.0-nightly.202411211606",
|
|
66
|
+
"@univerjs/engine-render": "0.5.0-nightly.202411211606",
|
|
67
|
+
"@univerjs/drawing": "0.5.0-nightly.202411211606",
|
|
68
|
+
"@univerjs/sheets-drawing": "0.5.0-nightly.202411211606",
|
|
69
|
+
"@univerjs/sheets-ui": "0.5.0-nightly.202411211606",
|
|
70
|
+
"@univerjs/ui": "0.5.0-nightly.202411211606"
|
|
71
71
|
},
|
|
72
72
|
"devDependencies": {
|
|
73
73
|
"less": "^4.2.0",
|