@univerjs/sheets-drawing-ui 0.4.2 → 0.5.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/facade.js +1 -0
- package/lib/cjs/index.js +9 -1
- package/lib/cjs/locale/en-US.js +1 -0
- package/lib/cjs/locale/fa-IR.js +1 -0
- package/lib/cjs/locale/ru-RU.js +1 -0
- package/lib/cjs/locale/vi-VN.js +1 -0
- package/lib/cjs/locale/zh-CN.js +1 -0
- package/lib/cjs/locale/zh-TW.js +1 -0
- package/lib/es/facade.js +16 -0
- package/lib/es/index.js +1826 -1794
- package/lib/es/locale/en-US.js +44 -0
- package/lib/es/locale/fa-IR.js +44 -0
- package/lib/es/locale/ru-RU.js +44 -0
- package/lib/es/locale/vi-VN.js +44 -0
- package/lib/es/locale/zh-CN.js +44 -0
- package/lib/es/locale/zh-TW.js +44 -0
- package/lib/types/facade/f-worksheet.d.ts +22 -0
- package/lib/types/facade/index.d.ts +16 -0
- package/lib/types/index.d.ts +1 -0
- package/lib/types/services/canvas-float-dom-manager.service.d.ts +2 -3
- package/lib/umd/facade.js +1 -0
- package/lib/umd/index.js +9 -1
- package/lib/umd/locale/en-US.js +1 -0
- package/lib/umd/locale/fa-IR.js +1 -0
- package/lib/umd/locale/ru-RU.js +1 -0
- package/lib/umd/locale/vi-VN.js +1 -0
- package/lib/umd/locale/zh-CN.js +1 -0
- package/lib/umd/locale/zh-TW.js +1 -0
- package/package.json +41 -23
- package/lib/locale/en-US.json +0 -41
- package/lib/locale/fa-IR.json +0 -41
- package/lib/locale/ru-RU.json +0 -41
- package/lib/locale/vi-VN.json +0 -41
- package/lib/locale/zh-CN.json +0 -41
- package/lib/locale/zh-TW.json +0 -41
package/lib/umd/index.js
CHANGED
|
@@ -1 +1,9 @@
|
|
|
1
|
-
(function(global,factory){typeof exports=="object"&&typeof module<"u"?factory(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"],factory):(global=typeof globalThis<"u"?globalThis:global||self,factory(global.UniverSheetsDrawingUi={},global.UniverCore,global.UniverDrawing,global.UniverDrawingUi,global.UniverEngineRender,global.UniverSheetsDrawing,global.UniverSheetsUi,global.UniverUi,global.rxjs,global.UniverSheets,global.React,global.UniverDesign))})(this,function(exports2,core,drawing,drawingUi,engineRender,sheetsDrawing,sheetsUi,ui,rxjs,sheets,React,design){"use strict";var __defProp=Object.defineProperty;var __defNormalProp=(obj,key,value)=>key in obj?__defProp(obj,key,{enumerable:!0,configurable:!0,writable:!0,value}):obj[key]=value;var __name=(target,value)=>__defProp(target,"name",{value,configurable:!0});var __publicField=(obj,key,value)=>__defNormalProp(obj,typeof key!="symbol"?key+"":key,value);var _a,_b,_c,_d,_e,_f,_g,_h,_i,_j;const PLUGIN_CONFIG_KEY="sheets-drawing-ui.config",defaultPluginConfig={},ClearSheetDrawingTransformerOperation={id:"sheet.operation.clear-drawing-transformer",type:core.CommandType.MUTATION,handler:__name((accessor,params)=>{const renderManagerService=accessor.get(engineRender.IRenderManagerService);return params.forEach(unitId=>{var _a2,_b2;(_b2=(_a2=renderManagerService.getRenderById(unitId))==null?void 0:_a2.scene.getTransformer())==null||_b2.debounceRefreshControls()}),!0},"handler")},RemoveSheetDrawingCommand={id:"sheet.command.remove-sheet-image",type:core.CommandType.COMMAND,handler:__name((accessor,params)=>{const commandService=accessor.get(core.ICommandService),undoRedoService=accessor.get(core.IUndoRedoService),sheetDrawingService=accessor.get(sheetsDrawing.ISheetDrawingService);if(!params)return!1;const{drawings}=params,unitIds=[];drawings.forEach(param=>{const{unitId:unitId2}=param;unitIds.push(unitId2)});const jsonOp=sheetDrawingService.getBatchRemoveOp(drawings),{unitId,subUnitId,undo,redo,objects}=jsonOp;return commandService.syncExecuteCommand(sheetsDrawing.SetDrawingApplyMutation.id,{unitId,subUnitId,op:redo,objects,type:sheetsDrawing.DrawingApplyType.REMOVE})?(undoRedoService.pushUndoRedo({unitID:unitId,undoMutations:[{id:sheetsDrawing.SetDrawingApplyMutation.id,params:{unitId,subUnitId,op:undo,objects,type:sheetsDrawing.DrawingApplyType.INSERT}},{id:ClearSheetDrawingTransformerOperation.id,params:unitIds}],redoMutations:[{id:sheetsDrawing.SetDrawingApplyMutation.id,params:{unitId,subUnitId,op:redo,objects,type:sheetsDrawing.DrawingApplyType.REMOVE}},{id:ClearSheetDrawingTransformerOperation.id,params:unitIds}]}),!0):!1},"handler")},COMPONENT_SHEET_DRAWING_PANEL="COMPONENT_SHEET_DRAWING_PANEL",SidebarSheetDrawingOperation={id:"sidebar.operation.sheet-image",type:core.CommandType.COMMAND,handler:__name(async(accessor,params)=>{const sidebarService=accessor.get(ui.ISidebarService),localeService=accessor.get(core.LocaleService),univerInstanceService=accessor.get(core.IUniverInstanceService),drawingManagerService=accessor.get(drawing.IDrawingManagerService);if(!sheets.getSheetCommandTarget(univerInstanceService))return!1;switch(params.value){case"open":sidebarService.open({header:{title:localeService.t("sheetImage.panel.title")},children:{label:COMPONENT_SHEET_DRAWING_PANEL},onClose:__name(()=>{drawingManagerService.focusDrawing(null)},"onClose"),width:360});break;case"close":default:sidebarService.close();break}return!0},"handler")},EditSheetDrawingOperation={id:"sheet.operation.edit-sheet-image",type:core.CommandType.OPERATION,handler:__name((accessor,params)=>{const drawingManagerService=accessor.get(drawing.IDrawingManagerService),commandService=accessor.get(core.ICommandService);return params==null?!1:(drawingManagerService.focusDrawing([params]),commandService.executeCommand(SidebarSheetDrawingOperation.id,{value:"open"}),!0)},"handler")},styles$1={uploadLoading:"univer-upload-loading",uploadLoadingBody:"univer-upload-loading-body",uploadLoadingBodyAnimation:"univer-upload-loading-body-animation",univerCircleAnimation:"univer-UniverCircleAnimation",uploadLoadingBodyText:"univer-upload-loading-body-text"},UploadLoading=__name(()=>{const imageIoService=core.useDependency(drawing.IImageIoService),localeService=core.useDependency(core.LocaleService),[remain,setRemain]=React.useState(0);return React.useEffect(()=>{const sub=imageIoService.change$.subscribe(count=>{setRemain(count)});return()=>{sub.unsubscribe()}},[imageIoService]),React.createElement("div",{style:{display:remain>0?"block":"none"},className:styles$1.uploadLoading},React.createElement("div",{className:styles$1.uploadLoadingBody},React.createElement("div",{className:styles$1.uploadLoadingBodyAnimation}),React.createElement("div",{className:styles$1.uploadLoadingBodyText},`${localeService.t("uploadLoading.loading")}: ${remain}`)))},"UploadLoading");var __defProp$9=Object.defineProperty,__getOwnPropDesc$9=Object.getOwnPropertyDescriptor,__decorateClass$9=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc$9(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp$9(target,key,result),result},"__decorateClass$9"),__decorateParam$9=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam$9");let DrawingPopupMenuController=(_a=class extends core.RxDisposable{constructor(_injector,_drawingManagerService,_canvasPopManagerService,_renderManagerService,_univerInstanceService,_contextService,_uiPartsService){super();__publicField(this,"_initImagePopupMenu",new Set);this._injector=_injector,this._drawingManagerService=_drawingManagerService,this._canvasPopManagerService=_canvasPopManagerService,this._renderManagerService=_renderManagerService,this._univerInstanceService=_univerInstanceService,this._contextService=_contextService,this._uiPartsService=_uiPartsService,this._init()}_init(){this._univerInstanceService.getCurrentTypeOfUnit$(core.UniverInstanceType.UNIVER_SHEET).pipe(rxjs.takeUntil(this.dispose$)).subscribe(workbook=>this._create(workbook)),this._univerInstanceService.getTypeOfUnitDisposed$(core.UniverInstanceType.UNIVER_SHEET).pipe(rxjs.takeUntil(this.dispose$)).subscribe(workbook=>this._dispose(workbook)),this._univerInstanceService.getAllUnitsForType(core.UniverInstanceType.UNIVER_SHEET).forEach(workbook=>this._create(workbook)),this._uiPartsService.registerComponent(ui.BuiltInUIPart.CONTENT,()=>core.connectInjector(UploadLoading,this._injector))}_dispose(workbook){const unitId=workbook.getUnitId();this._renderManagerService.removeRender(unitId)}_create(workbook){if(!workbook)return;const unitId=workbook.getUnitId();this._renderManagerService.has(unitId)&&!this._initImagePopupMenu.has(unitId)&&(this._popupMenuListener(unitId),this._initImagePopupMenu.add(unitId))}_hasCropObject(scene){const objects=scene.getAllObjectsByOrder();for(const object of objects)if(object instanceof drawingUi.ImageCropperObject)return!0;return!1}_popupMenuListener(unitId){var _a2;const scene=(_a2=this._renderManagerService.getRenderById(unitId))==null?void 0:_a2.scene;if(!scene)return;const transformer=scene.getTransformerByCreate();if(!transformer)return;let singletonPopupDisposer;this.disposeWithMe(core.toDisposable(transformer.createControl$.subscribe(()=>{if(this._contextService.setContextValue(core.FOCUSING_COMMON_DRAWINGS,!0),this._hasCropObject(scene))return;const selectedObjects=transformer.getSelectedObjectMap();if(selectedObjects.size>1){singletonPopupDisposer==null||singletonPopupDisposer.dispose();return}const object=selectedObjects.values().next().value;if(!object)return;const oKey=object.oKey,drawingParam=this._drawingManagerService.getDrawingOKey(oKey);if(!drawingParam)return;const{unitId:unitId2,subUnitId,drawingId,drawingType}=drawingParam;singletonPopupDisposer==null||singletonPopupDisposer.dispose(),singletonPopupDisposer=this.disposeWithMe(this._canvasPopManagerService.attachPopupToObject(object,{componentKey:drawingUi.COMPONENT_IMAGE_POPUP_MENU,direction:"horizontal",offset:[2,0],extraProps:{menuItems:this._getImageMenuItems(unitId2,subUnitId,drawingId,drawingType)}})),this._drawingManagerService.focusDrawing([{unitId:unitId2,subUnitId,drawingId}])}))),this.disposeWithMe(transformer.clearControl$.subscribe(()=>{singletonPopupDisposer==null||singletonPopupDisposer.dispose(),this._contextService.setContextValue(core.FOCUSING_COMMON_DRAWINGS,!1),this._drawingManagerService.focusDrawing(null)})),this.disposeWithMe(transformer.changing$.subscribe(()=>{singletonPopupDisposer==null||singletonPopupDisposer.dispose()}))}_getImageMenuItems(unitId,subUnitId,drawingId,drawingType){return[{label:"image-popup.edit",index:0,commandId:EditSheetDrawingOperation.id,commandParams:{unitId,subUnitId,drawingId},disable:drawingType===drawing.DrawingTypeEnum.DRAWING_DOM},{label:"image-popup.delete",index:1,commandId:RemoveSheetDrawingCommand.id,commandParams:{unitId,drawings:[{unitId,subUnitId,drawingId}]},disable:!1},{label:"image-popup.crop",index:2,commandId:drawingUi.OpenImageCropOperation.id,commandParams:{unitId,subUnitId,drawingId},disable:drawingType===drawing.DrawingTypeEnum.DRAWING_DOM},{label:"image-popup.reset",index:3,commandId:drawingUi.ImageResetSizeOperation.id,commandParams:[{unitId,subUnitId,drawingId}],disable:drawingType===drawing.DrawingTypeEnum.DRAWING_DOM}]}},__name(_a,"DrawingPopupMenuController"),_a);DrawingPopupMenuController=__decorateClass$9([__decorateParam$9(0,core.Inject(core.Injector)),__decorateParam$9(1,drawing.IDrawingManagerService),__decorateParam$9(2,core.Inject(sheetsUi.SheetCanvasPopManagerService)),__decorateParam$9(3,engineRender.IRenderManagerService),__decorateParam$9(4,core.IUniverInstanceService),__decorateParam$9(5,core.IContextService),__decorateParam$9(6,core.Inject(ui.IUIPartsService))],DrawingPopupMenuController);function drawingPositionToTransform(position,selectionRenderService,sheetSkeletonManagerService){const{from,to,flipY=!1,flipX=!1,angle=0,skewX=0,skewY=0}=position,{column:fromColumn,columnOffset:fromColumnOffset,row:fromRow,rowOffset:fromRowOffset}=from,{column:toColumn,columnOffset:toColumnOffset,row:toRow,rowOffset:toRowOffset}=to,skeleton=sheetSkeletonManagerService.getCurrentSkeleton(),startSelectionCell=sheetsUi.attachRangeWithCoord(skeleton,{startColumn:fromColumn,endColumn:fromColumn,startRow:fromRow,endRow:fromRow});if(startSelectionCell==null)return;const endSelectionCell=sheetsUi.attachRangeWithCoord(skeleton,{startColumn:toColumn,endColumn:toColumn,startRow:toRow,endRow:toRow});if(endSelectionCell==null)return;const{startX:startSelectionX,startY:startSelectionY}=startSelectionCell,{startX:endSelectionX,startY:endSelectionY}=endSelectionCell;let left=engineRender.precisionTo(startSelectionX+fromColumnOffset,1),top=engineRender.precisionTo(startSelectionY+fromRowOffset,1),width=engineRender.precisionTo(endSelectionX+toColumnOffset-left,1),height=engineRender.precisionTo(endSelectionY+toRowOffset-top,1);startSelectionCell.startX===endSelectionCell.endX&&(width=0),startSelectionCell.startY===endSelectionCell.endY&&(height=0);const sheetWidth=skeleton.rowHeaderWidth+skeleton.columnTotalWidth,sheetHeight=skeleton.columnHeaderHeight+skeleton.rowTotalHeight;return left+width>sheetWidth&&(left=sheetWidth-width),top+height>sheetHeight&&(top=sheetHeight-height),{flipY,flipX,angle,skewX,skewY,left,top,width,height}}__name(drawingPositionToTransform,"drawingPositionToTransform");function transformToDrawingPosition(transform,selectionRenderService){const{left=0,top=0,width=0,height=0,flipY=!1,flipX=!1,angle=0,skewX=0,skewY=0}=transform,startSelectionCell=selectionRenderService.getSelectionCellByPosition(left,top);if(startSelectionCell==null)return;const from={column:startSelectionCell.actualColumn,columnOffset:engineRender.precisionTo(left-startSelectionCell.startX,1),row:startSelectionCell.actualRow,rowOffset:engineRender.precisionTo(top-startSelectionCell.startY,1)},endSelectionCell=selectionRenderService.getSelectionCellByPosition(left+width,top+height);if(endSelectionCell==null)return;const to={column:endSelectionCell.actualColumn,columnOffset:engineRender.precisionTo(left+width-endSelectionCell.startX,1),row:endSelectionCell.actualRow,rowOffset:engineRender.precisionTo(top+height-endSelectionCell.startY,1)};return{flipY,flipX,angle,skewX,skewY,from,to}}__name(transformToDrawingPosition,"transformToDrawingPosition");var __defProp$8=Object.defineProperty,__getOwnPropDesc$8=Object.getOwnPropertyDescriptor,__decorateClass$8=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc$8(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp$8(target,key,result),result},"__decorateClass$8"),__decorateParam$8=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam$8");let SheetsDrawingRenderController=(_b=class extends core.Disposable{constructor(_context,_sheetDrawingService,_drawingManagerService,_sheetSelectionRenderService,_sheetSkeletonManagerService){super(),this._context=_context,this._sheetDrawingService=_sheetDrawingService,this._drawingManagerService=_drawingManagerService,this._sheetSelectionRenderService=_sheetSelectionRenderService,this._sheetSkeletonManagerService=_sheetSkeletonManagerService,this._init()}_init(){this._drawingInitializeListener()}_drawingInitializeListener(){this._sheetDrawingService.initializeNotification(this._context.unitId);const data=this._sheetDrawingService.getDrawingDataForUnit(this._context.unitId);for(const subUnit in data){const subUnitData=data[subUnit];for(const drawingId in subUnitData.data){const drawingData=subUnitData.data[drawingId];drawingData.transform=drawingPositionToTransform(drawingData.sheetTransform,this._sheetSelectionRenderService,this._sheetSkeletonManagerService)}}this._drawingManagerService.registerDrawingData(this._context.unitId,this._sheetDrawingService.getDrawingDataForUnit(this._context.unitId)),this._drawingManagerService.initializeNotification(this._context.unitId)}},__name(_b,"SheetsDrawingRenderController"),_b);SheetsDrawingRenderController=__decorateClass$8([__decorateParam$8(1,sheetsDrawing.ISheetDrawingService),__decorateParam$8(2,drawing.IDrawingManagerService),__decorateParam$8(3,core.Inject(sheetsUi.ISheetSelectionRenderService)),__decorateParam$8(4,core.Inject(sheetsUi.SheetSkeletonManagerService))],SheetsDrawingRenderController);var __assign=function(){return __assign=Object.assign||function(t){for(var s,i=1,n=arguments.length;i<n;i++){s=arguments[i];for(var p in s)Object.prototype.hasOwnProperty.call(s,p)&&(t[p]=s[p])}return t},__assign.apply(this,arguments)},__rest=function(s,e){var t={};for(var p in s)Object.prototype.hasOwnProperty.call(s,p)&&e.indexOf(p)<0&&(t[p]=s[p]);if(s!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,p=Object.getOwnPropertySymbols(s);i<p.length;i++)e.indexOf(p[i])<0&&Object.prototype.propertyIsEnumerable.call(s,p[i])&&(t[p[i]]=s[p[i]]);return t},IconBase=React.forwardRef(function(props,ref){var icon=props.icon,id=props.id,className=props.className,extend=props.extend,restProps=__rest(props,["icon","id","className","extend"]),cls="univerjs-icon univerjs-icon-".concat(id," ").concat(className||"").trim(),idSuffix=React.useRef("_".concat(generateShortUuid()));return render(icon,"".concat(id),{defIds:icon.defIds,idSuffix:idSuffix.current},__assign({ref,className:cls},restProps),extend)});function render(node,id,runtimeProps,rootProps,extend){return React.createElement(node.tag,__assign(__assign({key:id},replaceRuntimeIdsAndExtInAttrs(node,runtimeProps,extend)),rootProps),(replaceRuntimeIdsInDefs(node,runtimeProps).children||[]).map(function(child,index){return render(child,"".concat(id,"-").concat(node.tag,"-").concat(index),runtimeProps,void 0,extend)}))}__name(render,"render");function replaceRuntimeIdsAndExtInAttrs(node,runtimeProps,extend){var attrs=__assign({},node.attrs);extend!=null&&extend.colorChannel1&&attrs.fill==="colorChannel1"&&(attrs.fill=extend.colorChannel1);var defIds=runtimeProps.defIds;return!defIds||defIds.length===0||(node.tag==="use"&&attrs["xlink:href"]&&(attrs["xlink:href"]=attrs["xlink:href"]+runtimeProps.idSuffix),Object.entries(attrs).forEach(function(_a2){var key=_a2[0],value=_a2[1];typeof value=="string"&&(attrs[key]=value.replace(/url\(#(.*)\)/,"url(#$1".concat(runtimeProps.idSuffix,")")))})),attrs}__name(replaceRuntimeIdsAndExtInAttrs,"replaceRuntimeIdsAndExtInAttrs");function replaceRuntimeIdsInDefs(node,runtimeProps){var _a2,defIds=runtimeProps.defIds;return!defIds||defIds.length===0?node:node.tag==="defs"&&(!((_a2=node.children)===null||_a2===void 0)&&_a2.length)?__assign(__assign({},node),{children:node.children.map(function(child){return typeof child.attrs.id=="string"&&defIds&&defIds.indexOf(child.attrs.id)>-1?__assign(__assign({},child),{attrs:__assign(__assign({},child.attrs),{id:child.attrs.id+runtimeProps.idSuffix})}):child})}):node}__name(replaceRuntimeIdsInDefs,"replaceRuntimeIdsInDefs");function generateShortUuid(){return Math.random().toString(36).substring(2,8)}__name(generateShortUuid,"generateShortUuid"),IconBase.displayName="UniverIcon";var element={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"}}]},AddImageSingle=React.forwardRef(function(props,ref){return React.createElement(IconBase,Object.assign({},props,{id:"add-image-single",ref,icon:element}))});AddImageSingle.displayName="AddImageSingle";const DeleteDrawingsCommand={id:"sheet.command.delete-drawing",type:core.CommandType.COMMAND,handler:__name(accessor=>{const commandService=accessor.get(core.ICommandService),drawings=accessor.get(sheetsDrawing.ISheetDrawingService).getFocusDrawings();if(drawings.length===0)return!1;const unitId=drawings[0].unitId,newDrawings=drawings.map(drawing2=>{const{unitId:unitId2,subUnitId,drawingId,drawingType}=drawing2;return{unitId:unitId2,subUnitId,drawingId,drawingType}});return commandService.executeCommand(RemoveSheetDrawingCommand.id,{unitId,drawings:newDrawings})},"handler")};function ungroupToGroup(ungroupParams){const newGroupParams=[];return ungroupParams.forEach(ungroupParam=>{const{parent,children}=ungroupParam,{unitId,subUnitId,drawingId:groupId}=parent,groupTransform=engineRender.getGroupState(0,0,children.map(o=>o.transform||{})),newChildren=children.map(drawing2=>{const transform=drawing2.transform||{left:0,top:0},{unitId:unitId2,subUnitId:subUnitId2,drawingId}=drawing2;return{unitId:unitId2,subUnitId:subUnitId2,drawingId,transform:{...transform,left:transform.left-groupTransform.left,top:transform.top-groupTransform.top},groupId}}),groupParam={unitId,subUnitId,drawingId:groupId,drawingType:drawing.DrawingTypeEnum.DRAWING_GROUP,transform:groupTransform};newGroupParams.push({parent:groupParam,children:newChildren})}),newGroupParams}__name(ungroupToGroup,"ungroupToGroup");function groupToUngroup(groupParams){const newGroupParams=[];return groupParams.forEach(groupParam=>{const{parent,children}=groupParam,{unitId,subUnitId,drawingId:groupId,transform:groupTransform={width:0,height:0}}=parent;if(groupTransform==null)return;const newChildren=children.map(object=>{const{transform}=object,{unitId:unitId2,subUnitId:subUnitId2,drawingId}=object,newTransform=engineRender.transformObjectOutOfGroup(transform||{},groupTransform,groupTransform.width||0,groupTransform.height||0);return{unitId:unitId2,subUnitId:subUnitId2,drawingId,transform:newTransform,groupId:void 0}}),ungroupParam={unitId,subUnitId,drawingId:groupId,drawingType:drawing.DrawingTypeEnum.DRAWING_GROUP,transform:{left:0,top:0}};newGroupParams.push({parent:ungroupParam,children:newChildren})}),newGroupParams}__name(groupToUngroup,"groupToUngroup");const GroupSheetDrawingCommand={id:"sheet.command.group-sheet-image",type:core.CommandType.COMMAND,handler:__name((accessor,params)=>{const commandService=accessor.get(core.ICommandService),undoRedoService=accessor.get(core.IUndoRedoService),sheetDrawingService=accessor.get(sheetsDrawing.ISheetDrawingService);if(!params)return!1;const unitIds=[];params.forEach(({parent,children})=>{unitIds.push(parent.unitId),children.forEach(child=>{unitIds.push(child.unitId)})});const jsonOp=sheetDrawingService.getGroupDrawingOp(params),{unitId,subUnitId,undo,redo,objects}=jsonOp;return commandService.syncExecuteCommand(sheetsDrawing.SetDrawingApplyMutation.id,{op:redo,unitId,subUnitId,objects,type:sheetsDrawing.DrawingApplyType.GROUP})?(undoRedoService.pushUndoRedo({unitID:unitId,undoMutations:[{id:sheetsDrawing.SetDrawingApplyMutation.id,params:{op:undo,unitId,subUnitId,objects:groupToUngroup(objects),type:sheetsDrawing.DrawingApplyType.UNGROUP}},{id:ClearSheetDrawingTransformerOperation.id,params:unitIds}],redoMutations:[{id:sheetsDrawing.SetDrawingApplyMutation.id,params:{op:redo,unitId,subUnitId,objects,type:sheetsDrawing.DrawingApplyType.GROUP}},{id:ClearSheetDrawingTransformerOperation.id,params:unitIds}]}),!0):!1},"handler")},InsertSheetDrawingCommand={id:"sheet.command.insert-sheet-image",type:core.CommandType.COMMAND,handler:__name((accessor,params)=>{const commandService=accessor.get(core.ICommandService),undoRedoService=accessor.get(core.IUndoRedoService),sheetDrawingService=accessor.get(sheetsDrawing.ISheetDrawingService);if(!params)return!1;const drawings=params.drawings,unitIds=drawings.map(param=>param.unitId),jsonOp=sheetDrawingService.getBatchAddOp(drawings),{unitId,subUnitId,undo,redo,objects}=jsonOp;return commandService.syncExecuteCommand(sheetsDrawing.SetDrawingApplyMutation.id,{op:redo,unitId,subUnitId,objects,type:sheetsDrawing.DrawingApplyType.INSERT})?(undoRedoService.pushUndoRedo({unitID:unitId,undoMutations:[{id:sheetsDrawing.SetDrawingApplyMutation.id,params:{op:undo,unitId,subUnitId,objects,type:sheetsDrawing.DrawingApplyType.REMOVE}},{id:ClearSheetDrawingTransformerOperation.id,params:unitIds}],redoMutations:[{id:sheetsDrawing.SetDrawingApplyMutation.id,params:{op:redo,unitId,subUnitId,objects,type:sheetsDrawing.DrawingApplyType.INSERT}},{id:ClearSheetDrawingTransformerOperation.id,params:unitIds}]}),!0):!1},"handler")},SetDrawingArrangeCommand={id:"sheet.command.set-drawing-arrange",type:core.CommandType.COMMAND,handler:__name((accessor,params)=>{const commandService=accessor.get(core.ICommandService),undoRedoService=accessor.get(core.IUndoRedoService);if(!params)return!1;const sheetDrawingService=accessor.get(sheetsDrawing.ISheetDrawingService),{unitId,subUnitId,drawingIds,arrangeType}=params,drawingOrderMapParam={unitId,subUnitId,drawingIds};let jsonOp;if(arrangeType===drawing.ArrangeTypeEnum.forward?jsonOp=sheetDrawingService.getForwardDrawingsOp(drawingOrderMapParam):arrangeType===drawing.ArrangeTypeEnum.backward?jsonOp=sheetDrawingService.getBackwardDrawingOp(drawingOrderMapParam):arrangeType===drawing.ArrangeTypeEnum.front?jsonOp=sheetDrawingService.getFrontDrawingsOp(drawingOrderMapParam):arrangeType===drawing.ArrangeTypeEnum.back&&(jsonOp=sheetDrawingService.getBackDrawingsOp(drawingOrderMapParam)),jsonOp==null)return!1;const{objects,redo,undo}=jsonOp;return commandService.syncExecuteCommand(sheetsDrawing.SetDrawingApplyMutation.id,{op:redo,unitId,subUnitId,objects,type:sheetsDrawing.DrawingApplyType.ARRANGE})?(undoRedoService.pushUndoRedo({unitID:unitId,undoMutations:[{id:sheetsDrawing.SetDrawingApplyMutation.id,params:{op:undo,unitId,subUnitId,objects,type:sheetsDrawing.DrawingApplyType.ARRANGE}}],redoMutations:[{id:sheetsDrawing.SetDrawingApplyMutation.id,params:{op:redo,unitId,subUnitId,objects,type:sheetsDrawing.DrawingApplyType.ARRANGE}}]}),!0):!1},"handler")},SetSheetDrawingCommand={id:"sheet.command.set-sheet-image",type:core.CommandType.COMMAND,handler:__name((accessor,params)=>{const commandService=accessor.get(core.ICommandService),undoRedoService=accessor.get(core.IUndoRedoService),sheetDrawingService=accessor.get(sheetsDrawing.ISheetDrawingService);if(!params)return!1;const{drawings}=params,jsonOp=sheetDrawingService.getBatchUpdateOp(drawings),{unitId,subUnitId,undo,redo,objects}=jsonOp;return commandService.syncExecuteCommand(sheetsDrawing.SetDrawingApplyMutation.id,{unitId,subUnitId,op:redo,objects,type:sheetsDrawing.DrawingApplyType.UPDATE})?(undoRedoService.pushUndoRedo({unitID:unitId,undoMutations:[{id:sheetsDrawing.SetDrawingApplyMutation.id,params:{unitId,subUnitId,op:undo,objects,type:sheetsDrawing.DrawingApplyType.UPDATE}},{id:ClearSheetDrawingTransformerOperation.id,params:[unitId]}],redoMutations:[{id:sheetsDrawing.SetDrawingApplyMutation.id,params:{unitId,subUnitId,op:redo,objects,type:sheetsDrawing.DrawingApplyType.UPDATE}},{id:ClearSheetDrawingTransformerOperation.id,params:[unitId]}]}),!0):!1},"handler")},UngroupSheetDrawingCommand={id:"sheet.command.ungroup-sheet-image",type:core.CommandType.COMMAND,handler:__name((accessor,params)=>{const commandService=accessor.get(core.ICommandService),undoRedoService=accessor.get(core.IUndoRedoService),sheetDrawingService=accessor.get(sheetsDrawing.ISheetDrawingService);if(!params)return!1;const unitIds=[];params.forEach(({parent,children})=>{unitIds.push(parent.unitId),children.forEach(child=>{unitIds.push(child.unitId)})});const jsonOp=sheetDrawingService.getUngroupDrawingOp(params),{unitId,subUnitId,undo,redo,objects}=jsonOp;return commandService.syncExecuteCommand(sheetsDrawing.SetDrawingApplyMutation.id,{op:redo,unitId,subUnitId,objects,type:sheetsDrawing.DrawingApplyType.UNGROUP})?(undoRedoService.pushUndoRedo({unitID:unitId,undoMutations:[{id:sheetsDrawing.SetDrawingApplyMutation.id,params:{op:undo,unitId,subUnitId,objects:ungroupToGroup(objects),type:sheetsDrawing.DrawingApplyType.GROUP}},{id:ClearSheetDrawingTransformerOperation.id,params:unitIds}],redoMutations:[{id:sheetsDrawing.SetDrawingApplyMutation.id,params:{op:redo,unitId,subUnitId,objects,type:sheetsDrawing.DrawingApplyType.UNGROUP}},{id:ClearSheetDrawingTransformerOperation.id,params:unitIds}]}),!0):!1},"handler")};var __defProp$7=Object.defineProperty,__getOwnPropDesc$7=Object.getOwnPropertyDescriptor,__decorateClass$7=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc$7(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp$7(target,key,result),result},"__decorateClass$7"),__decorateParam$7=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam$7");let SheetDrawingUpdateController=(_c=class extends core.Disposable{constructor(_context,_skeletonManagerService,_commandService,_selectionRenderService,_imageIoService,_fileOpenerService,_sheetDrawingService,_drawingManagerService,_contextService,_messageService,_localeService,selectionManagerService){super();__publicField(this,"_workbookSelections");this._context=_context,this._skeletonManagerService=_skeletonManagerService,this._commandService=_commandService,this._selectionRenderService=_selectionRenderService,this._imageIoService=_imageIoService,this._fileOpenerService=_fileOpenerService,this._sheetDrawingService=_sheetDrawingService,this._drawingManagerService=_drawingManagerService,this._contextService=_contextService,this._messageService=_messageService,this._localeService=_localeService,this._workbookSelections=selectionManagerService.getWorkbookSelections(this._context.unitId),this._updateImageListener(),this._updateOrderListener(),this._groupDrawingListener(),this._focusDrawingListener()}async insertFloatImage(){const files=await this._fileOpenerService.openFile({multiple:!0,accept:drawing.DRAWING_IMAGE_ALLOW_IMAGE_LIST.map(image=>`.${image.replace("image/","")}`).join(",")}),fileLength=files.length;return fileLength>drawing.DRAWING_IMAGE_COUNT_LIMIT?(this._messageService.show({type:design.MessageType.Error,content:this._localeService.t("update-status.exceedMaxCount",String(drawing.DRAWING_IMAGE_COUNT_LIMIT))}),!1):fileLength===0?!1:(files.forEach(async file=>await this._insertFloatImage(file)),!0)}async _insertFloatImage(file){let imageParam;try{imageParam=await this._imageIoService.saveImage(file)}catch(error){const type=error.message;type===drawing.ImageUploadStatusType.ERROR_EXCEED_SIZE?this._messageService.show({type:design.MessageType.Error,content:this._localeService.t("update-status.exceedMaxSize",String(drawing.DRAWING_IMAGE_ALLOW_SIZE/(1024*1024)))}):type===drawing.ImageUploadStatusType.ERROR_IMAGE_TYPE?this._messageService.show({type:design.MessageType.Error,content:this._localeService.t("update-status.invalidImageType")}):type===drawing.ImageUploadStatusType.ERROR_IMAGE&&this._messageService.show({type:design.MessageType.Error,content:this._localeService.t("update-status.invalidImage")})}if(imageParam==null)return;const info=this._getUnitInfo(),{unitId,subUnitId}=info,{imageId,imageSourceType,source,base64Cache}=imageParam,{width,height,image}=await drawing.getImageSize(base64Cache||""),{width:sceneWidth,height:sceneHeight}=this._context.scene;this._imageIoService.addImageSourceCache(source,imageSourceType,image);let scale=1;if(width>drawing.DRAWING_IMAGE_WIDTH_LIMIT||height>drawing.DRAWING_IMAGE_HEIGHT_LIMIT){const scaleWidth=drawing.DRAWING_IMAGE_WIDTH_LIMIT/width,scaleHeight=drawing.DRAWING_IMAGE_HEIGHT_LIMIT/height;scale=Math.max(scaleWidth,scaleHeight)}const sheetTransform=this._getImagePosition(width*scale,height*scale,sceneWidth,sceneHeight);if(sheetTransform==null)return;const sheetDrawingParam={unitId,subUnitId,drawingId:imageId,drawingType:drawing.DrawingTypeEnum.DRAWING_IMAGE,imageSourceType,source,transform:drawingPositionToTransform(sheetTransform,this._selectionRenderService,this._skeletonManagerService),sheetTransform};this._commandService.executeCommand(InsertSheetDrawingCommand.id,{unitId,drawings:[sheetDrawingParam]})}_getUnitInfo(){const workbook=this._context.unit,worksheet=workbook.getActiveSheet(),unitId=workbook.getUnitId(),subUnitId=worksheet.getSheetId();return{unitId,subUnitId}}_getImagePosition(imageWidth,imageHeight,sceneWidth,sceneHeight){const selections=this._workbookSelections.getCurrentSelections();let range={startRow:0,endRow:0,startColumn:0,endColumn:0};selections&&selections.length>0&&(range=selections[selections.length-1].range);const rangeWithCoord=sheetsUi.attachRangeWithCoord(this._skeletonManagerService.getCurrent().skeleton,range);if(rangeWithCoord==null)return;let{startColumn,startRow,startX,startY}=rangeWithCoord,isChangeStart=!1;if(startX+imageWidth>sceneWidth&&(startX=sceneWidth-imageWidth,startX<0&&(startX=0,imageWidth=sceneWidth),isChangeStart=!0),startY+imageHeight>sceneHeight&&(startY=sceneHeight-imageHeight,startY<0&&(startY=0,imageHeight=sceneHeight),isChangeStart=!0),isChangeStart){const newCoord=this._selectionRenderService.getSelectionCellByPosition(startX,startY);if(newCoord==null)return;startX=newCoord.startX,startY=newCoord.startY,startColumn=newCoord.actualColumn,startRow=newCoord.actualRow}const from={column:startColumn,columnOffset:0,row:startRow,rowOffset:0},endSelectionCell=this._selectionRenderService.getSelectionCellByPosition(startX+imageWidth,startY+imageHeight);if(endSelectionCell==null)return;const to={column:endSelectionCell.actualColumn,columnOffset:startX+imageWidth-endSelectionCell.startX,row:endSelectionCell.actualRow,rowOffset:startY+imageHeight-endSelectionCell.startY};return{from,to}}_updateOrderListener(){this._drawingManagerService.featurePluginOrderUpdate$.subscribe(params=>{const{unitId,subUnitId,drawingIds,arrangeType}=params;this._commandService.executeCommand(SetDrawingArrangeCommand.id,{unitId,subUnitId,drawingIds,arrangeType})})}_updateImageListener(){this._drawingManagerService.featurePluginUpdate$.subscribe(params=>{const drawings=[];params.length!==0&&(params.forEach(param=>{const{unitId,subUnitId,drawingId,drawingType,transform}=param;if(transform==null)return;const sheetDrawing=this._sheetDrawingService.getDrawingByParam({unitId,subUnitId,drawingId});if(sheetDrawing==null||sheetDrawing.unitId!==this._context.unitId)return;const sheetTransform=transformToDrawingPosition({...sheetDrawing.transform,...transform},this._selectionRenderService);if(sheetTransform==null)return;const newDrawing={...param,transform:{...sheetDrawing.transform,...transform,...drawingPositionToTransform(sheetTransform,this._selectionRenderService,this._skeletonManagerService)},sheetTransform:{...sheetTransform}};drawings.push(newDrawing)}),drawings.length>0&&this._commandService.executeCommand(SetSheetDrawingCommand.id,{unitId:params[0].unitId,drawings}))})}_groupDrawingListener(){this._drawingManagerService.featurePluginGroupUpdate$.subscribe(params=>{this._commandService.executeCommand(GroupSheetDrawingCommand.id,params);const{unitId,subUnitId,drawingId}=params[0].parent;this._drawingManagerService.focusDrawing([{unitId,subUnitId,drawingId}])}),this._drawingManagerService.featurePluginUngroupUpdate$.subscribe(params=>{this._commandService.executeCommand(UngroupSheetDrawingCommand.id,params)})}_focusDrawingListener(){this.disposeWithMe(this._drawingManagerService.focus$.subscribe(params=>{params==null||params.length===0?(this._contextService.setContextValue(core.FOCUSING_COMMON_DRAWINGS,!1),this._sheetDrawingService.focusDrawing([])):(this._contextService.setContextValue(core.FOCUSING_COMMON_DRAWINGS,!0),this._sheetDrawingService.focusDrawing(params))}))}},__name(_c,"SheetDrawingUpdateController"),_c);SheetDrawingUpdateController=__decorateClass$7([__decorateParam$7(1,core.Inject(sheetsUi.SheetSkeletonManagerService)),__decorateParam$7(2,core.ICommandService),__decorateParam$7(3,sheetsUi.ISheetSelectionRenderService),__decorateParam$7(4,drawing.IImageIoService),__decorateParam$7(5,ui.ILocalFileService),__decorateParam$7(6,sheetsDrawing.ISheetDrawingService),__decorateParam$7(7,drawing.IDrawingManagerService),__decorateParam$7(8,core.IContextService),__decorateParam$7(9,ui.IMessageService),__decorateParam$7(10,core.Inject(core.LocaleService)),__decorateParam$7(11,core.Inject(sheets.SheetsSelectionsService))],SheetDrawingUpdateController);const InsertFloatImageCommand={id:"sheet.command.insert-float-image",type:core.CommandType.COMMAND,handler:__name(accessor=>{var _a2,_b2;return(_b2=(_a2=accessor.get(engineRender.IRenderManagerService).getCurrentTypeOfRenderer(core.UniverInstanceType.UNIVER_SHEET))==null?void 0:_a2.with(SheetDrawingUpdateController).insertFloatImage())!=null?_b2:!1},"handler")},MoveDrawingsCommand={id:"sheet.command.move-drawing",type:core.CommandType.COMMAND,handler:__name((accessor,params)=>{const commandService=accessor.get(core.ICommandService),drawingManagerService=accessor.get(sheetsDrawing.ISheetDrawingService),selectionRenderService=accessor.get(sheetsUi.ISheetSelectionRenderService),{direction}=params,drawings=drawingManagerService.getFocusDrawings();if(drawings.length===0)return!1;const unitId=drawings[0].unitId,newDrawings=drawings.map(drawing2=>{const{transform}=drawing2;if(transform==null)return null;const newTransform={...transform},{left=0,top=0}=transform;return direction===core.Direction.UP?newTransform.top=top-1:direction===core.Direction.DOWN?newTransform.top=top+1:direction===core.Direction.LEFT?newTransform.left=left-1:direction===core.Direction.RIGHT&&(newTransform.left=left+1),{...drawing2,transform:newTransform,sheetTransform:transformToDrawingPosition(newTransform,selectionRenderService)}}).filter(drawing2=>drawing2!=null);return commandService.syncExecuteCommand(SetSheetDrawingCommand.id,{unitId,drawings:newDrawings})?(commandService.syncExecuteCommand(ClearSheetDrawingTransformerOperation.id,[unitId]),!0):!1},"handler")},IMAGE_UPLOAD_ICON="addition-and-subtraction-single",IMAGE_MENU_ID="sheet.menu.image";function ImageMenuFactory(accessor){return{id:IMAGE_MENU_ID,type:ui.MenuItemType.SUBITEMS,icon:IMAGE_UPLOAD_ICON,tooltip:"sheetImage.title",hidden$:ui.getMenuHiddenObservable(accessor,core.UniverInstanceType.UNIVER_SHEET),disabled$:sheetsUi.getCurrentRangeDisable$(accessor,{workbookTypes:[sheets.WorkbookEditablePermission],worksheetTypes:[sheets.WorksheetEditPermission],rangeTypes:[sheets.RangeProtectionPermissionEditPoint]})}}__name(ImageMenuFactory,"ImageMenuFactory");function UploadFloatImageMenuFactory(_accessor){return{id:InsertFloatImageCommand.id,title:"sheetImage.upload.float",type:ui.MenuItemType.BUTTON,hidden$:ui.getMenuHiddenObservable(_accessor,core.UniverInstanceType.UNIVER_SHEET)}}__name(UploadFloatImageMenuFactory,"UploadFloatImageMenuFactory");const styles={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 r(e){var t,f,n="";if(typeof e=="string"||typeof e=="number")n+=e;else if(typeof e=="object")if(Array.isArray(e)){var o=e.length;for(t=0;t<o;t++)e[t]&&(f=r(e[t]))&&(n&&(n+=" "),n+=f)}else for(f in e)e[f]&&(n&&(n+=" "),n+=f);return n}__name(r,"r");function clsx(){for(var e,t,f=0,n="",o=arguments.length;f<o;f++)(e=arguments[f])&&(t=r(e))&&(n&&(n+=" "),n+=t);return n}__name(clsx,"clsx");const SheetDrawingAnchor=__name(props=>{var _a2;const commandService=core.useDependency(core.ICommandService),localeService=core.useDependency(core.LocaleService),drawingManagerService=core.useDependency(drawing.IDrawingManagerService),renderManagerService=core.useDependency(engineRender.IRenderManagerService),{drawings}=props,drawingParam=drawings[0];if(drawingParam==null)return;const{unitId}=drawingParam,renderObject=renderManagerService.getRenderById(unitId),scene=renderObject==null?void 0:renderObject.scene;if(scene==null)return;const transformer=scene.getTransformerByCreate(),[anchorShow,setAnchorShow]=React.useState(!0),type=(_a2=drawingParam.anchorType)!=null?_a2:sheetsDrawing.SheetDrawingAnchorType.Position,[value,setValue]=React.useState(type);function getUpdateParams(objects,drawingManagerService2){const params=[];return objects.forEach(object=>{const{oKey}=object,searchParam=drawingManagerService2.getDrawingOKey(oKey);if(searchParam==null)return params.push(null),!0;const{unitId:unitId2,subUnitId,drawingId,drawingType,anchorType,sheetTransform}=searchParam;params.push({unitId:unitId2,subUnitId,drawingId,anchorType,sheetTransform,drawingType})}),params}__name(getUpdateParams,"getUpdateParams"),React.useEffect(()=>{const onClearControlObserver=transformer.clearControl$.subscribe(changeSelf=>{changeSelf===!0&&setAnchorShow(!1)}),onChangeStartObserver=transformer.changeStart$.subscribe(state=>{var _a3;const{objects}=state,params=getUpdateParams(objects,drawingManagerService);if(params.length===0)setAnchorShow(!1);else if(params.length>=1){setAnchorShow(!0);const anchorType=((_a3=params[0])==null?void 0:_a3.anchorType)||sheetsDrawing.SheetDrawingAnchorType.Position;setValue(anchorType)}});return()=>{onChangeStartObserver.unsubscribe(),onClearControlObserver.unsubscribe()}},[]);function handleChange(value2){setValue(value2);const focusDrawings=drawingManagerService.getFocusDrawings();if(focusDrawings.length===0)return;const updateParams=focusDrawings.map(drawing2=>({unitId:drawing2.unitId,subUnitId:drawing2.subUnitId,drawingId:drawing2.drawingId,anchorType:value2}));commandService.executeCommand(SetSheetDrawingCommand.id,{unitId:focusDrawings[0].unitId,drawings:updateParams})}__name(handleChange,"handleChange");const gridDisplay=__name(isShow=>isShow?"block":"none","gridDisplay");return React.createElement("div",{className:clsx(styles.imageCommonPanelGrid,styles.imageCommonPanelBorder),style:{display:gridDisplay(anchorShow)}},React.createElement("div",{className:styles.imageCommonPanelRow},React.createElement("div",{className:clsx(styles.imageCommonPanelColumn,styles.imageCommonPanelTitle)},React.createElement("div",null,localeService.t("drawing-anchor.title")))),React.createElement("div",{className:clsx(styles.imageCommonPanelRow)},React.createElement("div",{className:clsx(styles.imageCommonPanelColumn)},React.createElement(design.RadioGroup,{value,onChange:handleChange,direction:"vertical"},React.createElement(design.Radio,{value:sheetsDrawing.SheetDrawingAnchorType.Both},localeService.t("drawing-anchor.both")),React.createElement(design.Radio,{value:sheetsDrawing.SheetDrawingAnchorType.Position},localeService.t("drawing-anchor.position")),React.createElement(design.Radio,{value:sheetsDrawing.SheetDrawingAnchorType.None},localeService.t("drawing-anchor.none"))))))},"SheetDrawingAnchor"),SheetDrawingPanel=__name(()=>{const drawingManagerService=core.useDependency(drawing.IDrawingManagerService),focusDrawings=drawingManagerService.getFocusDrawings(),[drawings,setDrawings]=React.useState(focusDrawings);return React.useEffect(()=>{const focusDispose=drawingManagerService.focus$.subscribe(drawings2=>{setDrawings(drawings2)});return()=>{focusDispose.unsubscribe()}},[]),!!(drawings!=null&&drawings.length)&&React.createElement("div",{className:styles.imageCommonPanel},React.createElement(drawingUi.DrawingCommonPanel,{drawings}),React.createElement(SheetDrawingAnchor,{drawings}))},"SheetDrawingPanel"),menuSchema={[ui.RibbonStartGroup.FORMULAS_INSERT]:{[IMAGE_MENU_ID]:{order:3,menuItemFactory:ImageMenuFactory,[InsertFloatImageCommand.id]:{order:0,menuItemFactory:UploadFloatImageMenuFactory}}}};function whenSheetDrawingFocused(contextService){return!contextService.getContextValue(core.FOCUSING_FX_BAR_EDITOR)&&!contextService.getContextValue(core.EDITOR_ACTIVATED)&&contextService.getContextValue(core.FOCUSING_COMMON_DRAWINGS)}__name(whenSheetDrawingFocused,"whenSheetDrawingFocused");const MoveDrawingDownShortcutItem={id:MoveDrawingsCommand.id,description:"shortcut.sheet.drawing-move-down",group:"4_sheet-drawing-view",binding:ui.KeyCode.ARROW_DOWN,priority:100,preconditions:whenSheetDrawingFocused,staticParameters:{direction:core.Direction.DOWN}},MoveDrawingUpShortcutItem={id:MoveDrawingsCommand.id,description:"shortcut.sheet.drawing-move-up",group:"4_sheet-drawing-view",binding:ui.KeyCode.ARROW_UP,priority:100,preconditions:whenSheetDrawingFocused,staticParameters:{direction:core.Direction.UP}},MoveDrawingLeftShortcutItem={id:MoveDrawingsCommand.id,description:"shortcut.sheet.drawing-move-left",group:"4_sheet-drawing-view",binding:ui.KeyCode.ARROW_LEFT,priority:100,preconditions:whenSheetDrawingFocused,staticParameters:{direction:core.Direction.LEFT}},MoveDrawingRightShortcutItem={id:MoveDrawingsCommand.id,description:"shortcut.sheet.drawing-move-right",group:"4_sheet-drawing-view",binding:ui.KeyCode.ARROW_RIGHT,priority:100,preconditions:whenSheetDrawingFocused,staticParameters:{direction:core.Direction.RIGHT}},DeleteDrawingsShortcutItem={id:DeleteDrawingsCommand.id,description:"shortcut.sheet.drawing-delete",group:"4_sheet-drawing-view",preconditions:whenSheetDrawingFocused,binding:ui.KeyCode.DELETE,mac:ui.KeyCode.BACKSPACE};var __defProp$6=Object.defineProperty,__getOwnPropDesc$6=Object.getOwnPropertyDescriptor,__decorateClass$6=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc$6(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp$6(target,key,result),result},"__decorateClass$6"),__decorateParam$6=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam$6");let SheetDrawingUIController=(_d=class extends core.Disposable{constructor(_componentManager,_menuManagerService,_commandService,_shortcutService){super(),this._componentManager=_componentManager,this._menuManagerService=_menuManagerService,this._commandService=_commandService,this._shortcutService=_shortcutService,this._init()}_initCustomComponents(){const componentManager=this._componentManager;this.disposeWithMe(componentManager.register(IMAGE_UPLOAD_ICON,AddImageSingle)),this.disposeWithMe(componentManager.register(COMPONENT_SHEET_DRAWING_PANEL,SheetDrawingPanel))}_initMenus(){this._menuManagerService.mergeMenu(menuSchema)}_initCommands(){[InsertFloatImageCommand,InsertSheetDrawingCommand,RemoveSheetDrawingCommand,SetSheetDrawingCommand,SidebarSheetDrawingOperation,ClearSheetDrawingTransformerOperation,EditSheetDrawingOperation,GroupSheetDrawingCommand,UngroupSheetDrawingCommand,MoveDrawingsCommand,DeleteDrawingsCommand,SetDrawingArrangeCommand].forEach(command=>this.disposeWithMe(this._commandService.registerCommand(command)))}_initShortcuts(){[MoveDrawingDownShortcutItem,MoveDrawingUpShortcutItem,MoveDrawingLeftShortcutItem,MoveDrawingRightShortcutItem,DeleteDrawingsShortcutItem].forEach(item=>{this.disposeWithMe(this._shortcutService.registerShortcut(item))})}_init(){this._initCommands(),this._initCustomComponents(),this._initMenus(),this._initShortcuts()}},__name(_d,"SheetDrawingUIController"),_d);SheetDrawingUIController=__decorateClass$6([__decorateParam$6(0,core.Inject(ui.ComponentManager)),__decorateParam$6(1,ui.IMenuManagerService),__decorateParam$6(2,core.ICommandService),__decorateParam$6(3,ui.IShortcutService)],SheetDrawingUIController);var __defProp$5=Object.defineProperty,__getOwnPropDesc$5=Object.getOwnPropertyDescriptor,__decorateClass$5=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc$5(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp$5(target,key,result),result},"__decorateClass$5"),__decorateParam$5=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam$5");let SheetsDrawingCopyPasteController=(_e=class extends core.Disposable{constructor(_sheetClipboardService,_renderManagerService,_sheetDrawingService){super();__publicField(this,"_copyInfo");this._sheetClipboardService=_sheetClipboardService,this._renderManagerService=_renderManagerService,this._sheetDrawingService=_sheetDrawingService,this._initCopyPaste()}_initCopyPaste(){this._sheetClipboardService.addClipboardHook({id:"SHEET_IMAGE_UI_PLUGIN",onBeforeCopy:__name((unitId,subUnitId,range)=>this._collect(unitId,subUnitId,range),"onBeforeCopy"),onPasteCells:__name((pasteFrom,pasteTo,data,payload)=>{const{copyType=sheetsUi.COPY_TYPE.COPY,pasteType}=payload,{range:copyRange}=pasteFrom||{},{range:pastedRange,unitId,subUnitId}=pasteTo;return this._generateMutations(pastedRange,{copyType,pasteType,copyRange,unitId,subUnitId})},"onPasteCells"),onPastePlainText:__name((pasteTo,clipText)=>({undos:[],redos:[]}),"onPastePlainText")})}_collect(unitId,subUnitId,range){var _a2;const skeletonManagerService=(_a2=this._renderManagerService.getRenderById(unitId))==null?void 0:_a2.with(sheetsUi.SheetSkeletonManagerService);if(!skeletonManagerService)return;const selectionRect=skeletonManagerService.attachRangeWithCoord(range);if(!selectionRect)return;const{startX,endX,startY,endY}=selectionRect,drawings=this._sheetDrawingService.getDrawingData(unitId,subUnitId),containedDrawings=[];Object.keys(drawings).forEach(drawingId=>{const drawing2=drawings[drawingId],{transform}=drawing2;if(drawing2.anchorType!==sheetsDrawing.SheetDrawingAnchorType.Both||!transform)return;const{left=0,top=0,width=0,height=0}=transform,{drawingStartX,drawingEndX,drawingStartY,drawingEndY}={drawingStartX:left,drawingEndX:left+width,drawingStartY:top,drawingEndY:top+height};startX<=drawingStartX&&drawingEndX<=endX&&startY<=drawingStartY&&drawingEndY<=endY&&containedDrawings.push(drawing2)}),containedDrawings.length&&(this._copyInfo={drawings:containedDrawings,unitId,subUnitId})}_generateMutations(pastedRange,copyInfo){var _a2;if(!this._copyInfo)return{redos:[],undos:[]};if([sheetsUi.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_COL_WIDTH,sheetsUi.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_VALUE,sheetsUi.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMAT,sheetsUi.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMULA].includes(copyInfo.pasteType))return{redos:[],undos:[]};const{copyRange}=copyInfo;if(!copyRange)return{redos:[],undos:[]};const{drawings,unitId,subUnitId}=this._copyInfo,{ranges:[vCopyRange,vPastedRange],mapFunc}=sheetsUi.virtualizeDiscreteRanges([copyRange,pastedRange]),{row:copyRow,col:copyCol}=mapFunc(vCopyRange.startRow,vCopyRange.startColumn),{row:pasteRow,col:pasteCol}=mapFunc(vPastedRange.startRow,vPastedRange.startColumn),skeletonManagerService=(_a2=this._renderManagerService.getRenderById(unitId))==null?void 0:_a2.with(sheetsUi.SheetSkeletonManagerService);if(!skeletonManagerService)return{redos:[],undos:[]};const copyRect=skeletonManagerService.attachRangeWithCoord({startRow:copyRow,endRow:copyRow,startColumn:copyCol,endColumn:copyCol}),pasteRect=skeletonManagerService.attachRangeWithCoord({startRow:pasteRow,endRow:pasteRow,startColumn:pasteCol,endColumn:pasteCol});if(!copyRect||!pasteRect)return{redos:[],undos:[]};const redos=[],undos=[],leftOffset=pasteRect.startX-copyRect.startX,topOffset=pasteRect.startY-copyRect.startY,rowOffset=pasteRow-copyRow,columnOffset=pasteCol-copyCol,isCut=copyInfo.copyType===sheetsUi.COPY_TYPE.CUT,{_sheetDrawingService}=this;return drawings.forEach(drawing2=>{const{transform,sheetTransform}=drawing2;if(!transform)return;const drawingObject={...drawing2,unitId,subUnitId,drawingId:isCut?drawing2.drawingId:core.Tools.generateRandomId(),transform:{...transform,left:transform.left+leftOffset,top:transform.top+topOffset},sheetTransform:{to:{...sheetTransform.to,row:sheetTransform.to.row+rowOffset,column:sheetTransform.to.column+columnOffset},from:{...sheetTransform.from,row:sheetTransform.from.row+rowOffset,column:sheetTransform.from.column+columnOffset}}};if(isCut){const{undo,redo,objects}=_sheetDrawingService.getBatchUpdateOp([drawingObject]);redos.push({id:sheetsDrawing.SetDrawingApplyMutation.id,params:{unitId,subUnitId,type:sheetsDrawing.DrawingApplyType.UPDATE,op:redo,objects}}),undos.push({id:sheetsDrawing.SetDrawingApplyMutation.id,params:{unitId,subUnitId,type:sheetsDrawing.DrawingApplyType.UPDATE,op:undo,objects}})}else{const{undo,redo,objects}=_sheetDrawingService.getBatchAddOp([drawingObject]);redos.push({id:sheetsDrawing.SetDrawingApplyMutation.id,params:{op:redo,unitId,subUnitId,objects,type:sheetsDrawing.DrawingApplyType.INSERT}}),undos.push({id:sheetsDrawing.SetDrawingApplyMutation.id,params:{op:undo,unitId,subUnitId,objects,type:sheetsDrawing.DrawingApplyType.REMOVE}})}}),{redos,undos}}},__name(_e,"SheetsDrawingCopyPasteController"),_e);SheetsDrawingCopyPasteController=__decorateClass$5([__decorateParam$5(0,sheetsUi.ISheetClipboardService),__decorateParam$5(1,engineRender.IRenderManagerService),__decorateParam$5(2,sheetsDrawing.ISheetDrawingService)],SheetsDrawingCopyPasteController);var __defProp$4=Object.defineProperty,__getOwnPropDesc$4=Object.getOwnPropertyDescriptor,__decorateClass$4=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc$4(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp$4(target,key,result),result},"__decorateClass$4"),__decorateParam$4=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam$4");let SheetDrawingPermissionController=(_f=class extends core.Disposable{constructor(_drawingManagerService,_renderManagerService,_permissionService,_univerInstanceService,_userManagerService){super(),this._drawingManagerService=_drawingManagerService,this._renderManagerService=_renderManagerService,this._permissionService=_permissionService,this._univerInstanceService=_univerInstanceService,this._userManagerService=_userManagerService,this._initDrawingVisible(),this._initDrawingEditable(),this._initViewPermissionChange(),this._initEditPermissionChange()}_initDrawingVisible(){const workbook$=this._univerInstanceService.getCurrentTypeOfUnit$(core.UniverInstanceType.UNIVER_SHEET);this.disposeWithMe(rxjs.combineLatest([workbook$,this._userManagerService.currentUser$]).subscribe(([workbook,_])=>{if(!workbook){this._drawingManagerService.setDrawingVisible(!1);return}workbook.activeSheet$.subscribe(sheet=>{if(!sheet){this._drawingManagerService.setDrawingVisible(!1);return}const unitId=workbook.getUnitId(),subUnitId=sheet.getSheetId();if(this._permissionService.composePermission([new sheets.WorkbookViewPermission(unitId).id,new sheets.WorksheetViewPermission(unitId,subUnitId).id]).every(permission=>permission.value))this._drawingManagerService.setDrawingVisible(!0);else{this._drawingManagerService.setDrawingVisible(!1);const unitId2=workbook.getUnitId(),subUnitId2=sheet.getSheetId(),drawingData=this._drawingManagerService.getDrawingData(unitId2,subUnitId2),drawingDataValues=Object.values(drawingData),renderObject=this._renderManagerService.getRenderById(unitId2),scene=renderObject==null?void 0:renderObject.scene;if(scene==null)return;scene.getAllObjectsByOrder().forEach(object=>{object.classType===engineRender.RENDER_CLASS_TYPE.IMAGE&&drawingDataValues.some(item=>object.oKey.includes(item.drawingId))&&scene.removeObject(object)})}})}))}_initDrawingEditable(){const workbook$=this._univerInstanceService.getCurrentTypeOfUnit$(core.UniverInstanceType.UNIVER_SHEET);this.disposeWithMe(rxjs.combineLatest([workbook$,this._userManagerService.currentUser$]).subscribe(([workbook,_])=>{if(!workbook){this._drawingManagerService.setDrawingEditable(!1);return}workbook.activeSheet$.subscribe(sheet=>{if(!sheet){this._drawingManagerService.setDrawingEditable(!1);return}const unitId=workbook.getUnitId(),subUnitId=sheet.getSheetId();if(this._permissionService.composePermission([new sheets.WorkbookEditablePermission(unitId).id,new sheets.WorksheetEditPermission(unitId,subUnitId).id]).every(permission=>permission.value))this._drawingManagerService.setDrawingEditable(!0);else{this._drawingManagerService.setDrawingEditable(!1);const unitId2=workbook.getUnitId(),subUnitId2=sheet.getSheetId(),drawingData=this._drawingManagerService.getDrawingData(unitId2,subUnitId2),drawingDataValues=Object.values(drawingData),renderObject=this._renderManagerService.getRenderById(unitId2),scene=renderObject==null?void 0:renderObject.scene;if(scene==null)return;scene.getAllObjectsByOrder().forEach(object=>{object.classType===engineRender.RENDER_CLASS_TYPE.IMAGE&&drawingDataValues.some(item=>object.oKey.includes(item.drawingId))&&scene.detachTransformerFrom(object)})}})}))}_initViewPermissionChange(){const workbook$=this._univerInstanceService.getCurrentTypeOfUnit$(core.UniverInstanceType.UNIVER_SHEET);this.disposeWithMe(rxjs.combineLatest([workbook$,this._userManagerService.currentUser$]).subscribe(([workbook,_])=>{workbook&&workbook.activeSheet$.subscribe(sheet=>{var _a2;if(!sheet)return;const unitId=workbook.getUnitId(),subUnitId=sheet.getSheetId();let initialViewPermission=!0;const renderObject=this._renderManagerService.getRenderById(unitId),scene=renderObject==null?void 0:renderObject.scene;if(scene==null)return;const transformer=scene.getTransformerByCreate(),worksheetViewPermission$=this._permissionService.composePermission$([new sheets.WorkbookViewPermission(unitId).id,new sheets.WorksheetViewPermission(unitId,subUnitId).id]).pipe(rxjs.map(permissions=>permissions.every(item=>item.value)));worksheetViewPermission$==null||worksheetViewPermission$.pipe(rxjs.filter(permission=>permission!==initialViewPermission),rxjs.distinctUntilChanged()).subscribe({next:__name(permission=>{initialViewPermission=permission,this._drawingManagerService.setDrawingVisible(permission);const objects=scene.getAllObjectsByOrder(),drawingData=this._drawingManagerService.getDrawingData(unitId,subUnitId),drawingDataValues=Object.values(drawingData);permission?this._drawingManagerService.addNotification(drawingDataValues):(objects.forEach(object=>{object.classType===engineRender.RENDER_CLASS_TYPE.IMAGE&&drawingDataValues.some(item=>object.oKey.includes(item.drawingId))&&scene.removeObject(object)}),transformer.clearSelectedObjects())},"next")}),(_a2=this._permissionService.getPermissionPoint$(new sheets.WorksheetViewPermission(unitId,subUnitId).id))==null||_a2.pipe(rxjs.filter(permission=>permission.value!==initialViewPermission),rxjs.distinctUntilChanged()).subscribe({complete:__name(()=>{initialViewPermission=!0,this._drawingManagerService.setDrawingVisible(!0);const drawingData=this._drawingManagerService.getDrawingData(unitId,subUnitId),drawingDataValues=Object.values(drawingData);this._drawingManagerService.addNotification(drawingDataValues)},"complete")})})}))}_initEditPermissionChange(){const workbook$=this._univerInstanceService.getCurrentTypeOfUnit$(core.UniverInstanceType.UNIVER_SHEET);this.disposeWithMe(rxjs.combineLatest([workbook$,this._userManagerService.currentUser$]).subscribe(([workbook,_])=>{workbook&&workbook.activeSheet$.subscribe(sheet=>{var _a2;if(!sheet)return;const unitId=workbook.getUnitId(),subUnitId=sheet.getSheetId();let initialEditPermission=!0;const renderObject=this._renderManagerService.getRenderById(unitId),scene=renderObject==null?void 0:renderObject.scene;if(scene==null)return;const transformer=scene.getTransformerByCreate(),composeWorksheetEditPermission=this._permissionService.composePermission$([new sheets.WorkbookEditablePermission(unitId).id,new sheets.WorksheetEditPermission(unitId,subUnitId).id]).pipe(rxjs.map(permissions=>permissions.every(item=>item.value)));composeWorksheetEditPermission==null||composeWorksheetEditPermission.pipe(rxjs.filter(permission=>permission!==initialEditPermission),rxjs.distinctUntilChanged()).subscribe({next:__name(permission=>{initialEditPermission=permission,this._drawingManagerService.setDrawingEditable(permission);const objects=scene.getAllObjectsByOrder(),drawingData=this._drawingManagerService.getDrawingData(unitId,subUnitId),drawingDataValues=Object.values(drawingData);permission?(objects.forEach(object=>{object.classType===engineRender.RENDER_CLASS_TYPE.IMAGE&&drawingDataValues.some(item=>object.oKey.includes(item.drawingId))&&scene.attachTransformerTo(object)}),this._drawingManagerService.addNotification(drawingDataValues)):(objects.forEach(object=>{object.classType===engineRender.RENDER_CLASS_TYPE.IMAGE&&drawingDataValues.some(item=>object.oKey.includes(item.drawingId))&&scene.detachTransformerFrom(object)}),transformer.clearSelectedObjects())},"next")}),(_a2=this._permissionService.getPermissionPoint$(new sheets.WorksheetEditPermission(unitId,subUnitId).id))==null||_a2.pipe(rxjs.filter(permission=>permission.value!==initialEditPermission),rxjs.distinctUntilChanged()).subscribe({complete:__name(()=>{initialEditPermission=!0;const unitId2=workbook.getUnitId(),subUnitId2=sheet.getSheetId(),drawingData=this._drawingManagerService.getDrawingData(unitId2,subUnitId2),drawingDataValues=Object.values(drawingData),renderObject2=this._renderManagerService.getRenderById(unitId2),scene2=renderObject2==null?void 0:renderObject2.scene;if(scene2==null)return;this._drawingManagerService.setDrawingEditable(!0),scene2.getAllObjectsByOrder().forEach(object=>{object.classType===engineRender.RENDER_CLASS_TYPE.IMAGE&&drawingDataValues.some(item=>object.oKey.includes(item.drawingId))&&scene2.detachTransformerFrom(object)})},"complete")})})}))}},__name(_f,"SheetDrawingPermissionController"),_f);SheetDrawingPermissionController=__decorateClass$4([__decorateParam$4(0,drawing.IDrawingManagerService),__decorateParam$4(1,engineRender.IRenderManagerService),__decorateParam$4(2,core.IPermissionService),__decorateParam$4(3,core.IUniverInstanceService),__decorateParam$4(4,core.Inject(core.UserManagerService))],SheetDrawingPermissionController);var __defProp$3=Object.defineProperty,__getOwnPropDesc$3=Object.getOwnPropertyDescriptor,__decorateClass$3=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc$3(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp$3(target,key,result),result},"__decorateClass$3"),__decorateParam$3=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam$3");let SheetDrawingPrintingController=(_g=class extends core.Disposable{constructor(_sheetPrintInterceptorService,_drawingRenderService,_drawingManagerService,_renderManagerService){super(),this._sheetPrintInterceptorService=_sheetPrintInterceptorService,this._drawingRenderService=_drawingRenderService,this._drawingManagerService=_drawingManagerService,this._renderManagerService=_renderManagerService,this._initPrinting()}_initPrinting(){this.disposeWithMe(this._sheetPrintInterceptorService.interceptor.intercept(this._sheetPrintInterceptorService.interceptor.getInterceptPoints().PRINTING_COMPONENT_COLLECT,{handler:__name((_param,pos,next)=>{const{unitId,scene,subUnitId}=pos,unitData=this._drawingManagerService.getDrawingDataForUnit(unitId),subUnitData=unitData==null?void 0:unitData[subUnitId];return subUnitData&&subUnitData.order.forEach(id=>{this._drawingRenderService.renderDrawing(subUnitData.data[id],scene)}),next()},"handler")})),this.disposeWithMe(this._sheetPrintInterceptorService.interceptor.intercept(this._sheetPrintInterceptorService.interceptor.getInterceptPoints().PRINTING_RANGE,{handler:__name((range,pos,next)=>{const{unitId,subUnitId}=pos,renderer=this._renderManagerService.getRenderById(unitId);if(!renderer)return next(range);const skeleton=renderer.with(sheetsUi.SheetSkeletonManagerService).getWorksheetSkeleton(subUnitId);if(!skeleton)return next(range);const unitData=this._drawingManagerService.getDrawingDataForUnit(unitId),subUnitData=unitData==null?void 0:unitData[pos.subUnitId];if(!subUnitData)return next(range);const{scaleX,scaleY}=renderer.scene,newRange=range?{...range}:{startColumn:0,endColumn:0,endRow:0,startRow:0},data=subUnitData.order.map(key=>subUnitData.data[key]).filter(item=>item.drawingType!==drawing.DrawingTypeEnum.DRAWING_DOM);return data.length?(data.forEach(param=>{if(!param.groupId&¶m.transform&&core.Tools.isDefine(param.transform.left)&&core.Tools.isDefine(param.transform.top)&&core.Tools.isDefine(param.transform.width)&&core.Tools.isDefine(param.transform.height)){const start=skeleton.skeleton.getCellPositionByOffset(param.transform.left,param.transform.top,scaleX,scaleY,{x:0,y:0}),end=skeleton.skeleton.getCellPositionByOffset(param.transform.left+param.transform.width,param.transform.top+param.transform.height,scaleX,scaleY,{x:0,y:0});start.column<newRange.startColumn&&(newRange.startColumn=start.column),start.row<newRange.startRow&&(newRange.startRow=start.row),newRange.endRow<end.row&&(newRange.endRow=end.row),newRange.endColumn<end.column&&(newRange.endColumn=end.column)}}),next(newRange)):next(range)},"handler")}))}},__name(_g,"SheetDrawingPrintingController"),_g);SheetDrawingPrintingController=__decorateClass$3([__decorateParam$3(0,core.Inject(sheetsUi.SheetPrintInterceptorService)),__decorateParam$3(1,core.Inject(drawingUi.DrawingRenderService)),__decorateParam$3(2,drawing.IDrawingManagerService),__decorateParam$3(3,engineRender.IRenderManagerService)],SheetDrawingPrintingController);var __defProp$2=Object.defineProperty,__getOwnPropDesc$2=Object.getOwnPropertyDescriptor,__decorateClass$2=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc$2(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp$2(target,key,result),result},"__decorateClass$2"),__decorateParam$2=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam$2");const UPDATE_COMMANDS=[sheets.InsertRowCommand.id,sheets.InsertColCommand.id,sheets.RemoveRowCommand.id,sheets.RemoveColCommand.id,sheets.DeleteRangeMoveLeftCommand.id,sheets.DeleteRangeMoveUpCommand.id,sheets.InsertRangeMoveDownCommand.id,sheets.InsertRangeMoveRightCommand.id,sheets.DeltaRowHeightCommand.id,sheets.SetRowHeightCommand.id,sheets.DeltaColumnWidthCommand.id,sheets.SetColWidthCommand.id,sheets.SetRowHiddenCommand.id,sheets.SetSpecificRowsVisibleCommand.id,sheets.SetSpecificColsVisibleCommand.id,sheets.SetColHiddenCommand.id,sheets.MoveColsCommand.id,sheets.MoveRowsCommand.id,sheets.MoveRangeCommand.id],REFRESH_MUTATIONS=[sheets.SetRowVisibleMutation.id,sheets.SetRowHiddenMutation.id,sheets.SetColVisibleMutation.id,sheets.SetColHiddenMutation.id,sheets.SetWorksheetRowHeightMutation.id,sheets.SetWorksheetColWidthMutation.id];let SheetDrawingTransformAffectedController=(_h=class extends core.Disposable{constructor(_context,_renderManagerService,_commandService,_selectionRenderService,_skeletonManagerService,_sheetInterceptorService,_sheetDrawingService,_drawingManagerService,_univerInstanceService){super(),this._context=_context,this._renderManagerService=_renderManagerService,this._commandService=_commandService,this._selectionRenderService=_selectionRenderService,this._skeletonManagerService=_skeletonManagerService,this._sheetInterceptorService=_sheetInterceptorService,this._sheetDrawingService=_sheetDrawingService,this._drawingManagerService=_drawingManagerService,this._univerInstanceService=_univerInstanceService,this._sheetInterceptorListener(),this._commandListener(),this._sheetRefreshListener()}_sheetInterceptorListener(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:__name(commandInfo=>{if(!UPDATE_COMMANDS.includes(commandInfo.id))return{redos:[],undos:[]};if(commandInfo.params==null)return{redos:[],undos:[]};const cId=commandInfo.id;if(cId===sheets.InsertRowCommand.id)return this._moveRowInterceptor(commandInfo.params,"insert");if([sheets.MoveColsCommand.id,sheets.MoveRowsCommand.id,sheets.MoveRangeCommand.id].includes(cId))return this._moveRangeInterceptor(commandInfo.params);if(cId===sheets.InsertColCommand.id)return this._moveColInterceptor(commandInfo.params,"insert");if(cId===sheets.RemoveRowCommand.id)return this._moveRowInterceptor(commandInfo.params,"remove");if(cId===sheets.RemoveColCommand.id)return this._moveColInterceptor(commandInfo.params,"remove");if(cId===sheets.DeleteRangeMoveLeftCommand.id){const{range}=commandInfo.params;return this._getRangeMoveUndo(range,0)}else if(cId===sheets.DeleteRangeMoveUpCommand.id){const{range}=commandInfo.params;return this._getRangeMoveUndo(range,1)}else if(cId===sheets.InsertRangeMoveDownCommand.id){const{range}=commandInfo.params;return this._getRangeMoveUndo(range,2)}else if(cId===sheets.InsertRangeMoveRightCommand.id){const{range}=commandInfo.params;return this._getRangeMoveUndo(range,3)}else if(cId===sheets.SetRowHiddenCommand.id||cId===sheets.SetSpecificRowsVisibleCommand.id){const params=commandInfo.params,{unitId,subUnitId,ranges}=params;return this._getDrawingUndoForRowVisible(unitId,subUnitId,ranges)}else if(cId===sheets.SetSpecificColsVisibleCommand.id||cId===sheets.SetColHiddenCommand.id){const params=commandInfo.params,{unitId,subUnitId,ranges}=params;return this._getDrawingUndoForColVisible(unitId,subUnitId,ranges)}else if(cId===sheets.DeltaRowHeightCommand.id||cId===sheets.SetRowHeightCommand.id||cId===sheets.DeltaColumnWidthCommand.id||cId===sheets.SetColWidthCommand.id){const params=commandInfo.params,{unitId,subUnitId,ranges}=params,isRow=cId===sheets.DeltaRowHeightCommand.id||cId===sheets.SetRowHeightCommand.id;return this._getDrawingUndoForRowAndColSize(unitId,subUnitId,ranges,isRow)}return{redos:[],undos:[]}},"getMutations")}))}_getRangeMoveUndo(range,type){const newParams=sheets.getSheetCommandTarget(this._univerInstanceService);if(newParams==null)return{redos:[],undos:[]};const unitId=newParams.unitId,subUnitId=newParams.subUnitId,redos=[],undos=[],drawingData=this._sheetDrawingService.getDrawingData(unitId,subUnitId),updateDrawings=[],deleteDrawings=[];if(Object.keys(drawingData).forEach(drawingId=>{const drawing2=drawingData[drawingId],{updateDrawings:updateDrawingsPart,deleteDrawings:deleteDrawingsPart}=this._getUpdateOrDeleteDrawings(range,type,drawing2);updateDrawings.push(...updateDrawingsPart),deleteDrawings.push(...deleteDrawingsPart)}),updateDrawings.length===0&&deleteDrawings.length===0)return{redos:[],undos:[]};if(updateDrawings.length>0){const updateJsonOp=this._sheetDrawingService.getBatchUpdateOp(updateDrawings),{undo,redo,objects}=updateJsonOp;redos.push({id:sheetsDrawing.SetDrawingApplyMutation.id,params:{unitId,subUnitId,op:redo,objects,type:sheetsDrawing.DrawingApplyType.UPDATE}}),undos.push({id:sheetsDrawing.SetDrawingApplyMutation.id,params:{unitId,subUnitId,op:undo,objects,type:sheetsDrawing.DrawingApplyType.UPDATE}})}if(deleteDrawings.length>0){const deleteJsonOp=this._sheetDrawingService.getBatchRemoveOp(deleteDrawings),deleteUndo=deleteJsonOp.undo,deleteRedo=deleteJsonOp.redo,deleteObjects=deleteJsonOp.objects;redos.push({id:sheetsDrawing.SetDrawingApplyMutation.id,params:{unitId,subUnitId,op:deleteRedo,objects:deleteObjects,type:sheetsDrawing.DrawingApplyType.REMOVE}}),undos.push({id:sheetsDrawing.SetDrawingApplyMutation.id,params:{unitId,subUnitId,op:deleteUndo,objects:deleteObjects,type:sheetsDrawing.DrawingApplyType.INSERT}})}return redos.push({id:ClearSheetDrawingTransformerOperation.id,params:[unitId]}),undos.push({id:ClearSheetDrawingTransformerOperation.id,params:[unitId]}),{redos,undos}}_getUpdateOrDeleteDrawings(range,type,drawing2){const updateDrawings=[],deleteDrawings=[],{sheetTransform,anchorType=sheetsDrawing.SheetDrawingAnchorType.Position,transform,unitId,subUnitId,drawingId}=drawing2,{from,to}=sheetTransform,{row:fromRow,column:fromColumn}=from,{row:toRow,column:toColumn}=to;if(sheetTransform==null||transform==null)return{updateDrawings,deleteDrawings};const{startRow,endRow,startColumn,endColumn}=range;let newSheetTransform=null,newTransform=null;if(type===0&&fromRow>=startRow&&toRow<=endRow)if(fromColumn>=startColumn&&toColumn<=endColumn)deleteDrawings.push({unitId,subUnitId,drawingId});else{const param=this._shrinkCol(sheetTransform,transform,startColumn,endColumn,anchorType);newSheetTransform=param==null?void 0:param.newSheetTransform,newTransform=param==null?void 0:param.newTransform}else if(type===1&&fromColumn>=startColumn&&toColumn<=endColumn)if(fromRow>=startRow&&toRow<=endRow)deleteDrawings.push({unitId,subUnitId,drawingId});else{const param=this._shrinkRow(sheetTransform,transform,startRow,endRow,anchorType);newSheetTransform=param==null?void 0:param.newSheetTransform,newTransform=param==null?void 0:param.newTransform}else if(type===2){const param=this._expandRow(sheetTransform,transform,startRow,endRow,anchorType);newSheetTransform=param==null?void 0:param.newSheetTransform,newTransform=param==null?void 0:param.newTransform}else if(type===3){const param=this._expandCol(sheetTransform,transform,startColumn,endColumn,anchorType);newSheetTransform=param==null?void 0:param.newSheetTransform,newTransform=param==null?void 0:param.newTransform}if(newSheetTransform!=null&&newTransform!=null){const newTransform2=drawingPositionToTransform(newSheetTransform,this._selectionRenderService,this._skeletonManagerService);updateDrawings.push({...drawing2,sheetTransform:newSheetTransform,transform:newTransform2})}return{updateDrawings,deleteDrawings}}_remainDrawingSize(transform,updateDrawings,drawing2){const newSheetTransform=transformToDrawingPosition({...transform},this._selectionRenderService);newSheetTransform!=null&&updateDrawings.push({...drawing2,sheetTransform:newSheetTransform})}_getDrawingUndoForColVisible(unitId,subUnitId,ranges){const drawingData=this._drawingManagerService.getDrawingData(unitId,subUnitId),updateDrawings=[],preUpdateDrawings=[];if(Object.keys(drawingData).forEach(drawingId=>{const drawing2=drawingData[drawingId],{sheetTransform,transform,anchorType=sheetsDrawing.SheetDrawingAnchorType.Position}=drawing2;if(anchorType===sheetsDrawing.SheetDrawingAnchorType.None)this._remainDrawingSize(transform,updateDrawings,drawing2);else{const{from,to}=sheetTransform,{row:fromRow,column:fromColumn}=from,{row:toRow,column:toColumn}=to;for(let i=0;i<ranges.length;i++){const range=ranges[i],{startRow,endRow,startColumn,endColumn}=range;if(toColumn<startColumn)continue;if(anchorType===sheetsDrawing.SheetDrawingAnchorType.Position){let newSheetTransform2=null,newTransform2=null;if(fromColumn>=startColumn&&fromColumn<=endColumn){const selectionCell=this._skeletonManagerService.attachRangeWithCoord({startColumn:fromColumn,endColumn,startRow:from.row,endRow:to.row});if(selectionCell==null)return;newTransform2={...transform,left:selectionCell.startX}}if(newTransform2!=null&&(newSheetTransform2=transformToDrawingPosition(newTransform2,this._selectionRenderService),newSheetTransform2!=null&&newTransform2!=null)){updateDrawings.push({...drawing2,sheetTransform:newSheetTransform2,transform:newTransform2});break}this._remainDrawingSize(transform,updateDrawings,drawing2);continue}if(fromColumn>=startColumn&&toColumn<=endColumn)continue;let newSheetTransform=null,newTransform=null;if(fromColumn>=startColumn&&fromColumn<=endColumn){const selectionCell=this._skeletonManagerService.attachRangeWithCoord({startColumn:fromColumn,endColumn,startRow:from.row,endRow:to.row});if(selectionCell==null)return;newTransform={...transform,left:(selectionCell==null?void 0:selectionCell.startX)||0,width:((transform==null?void 0:transform.width)||0)-selectionCell.endX+selectionCell.startX}}else if(toColumn>=startColumn&&toColumn<=endColumn){const selectionCell=this._skeletonManagerService.attachRangeWithCoord({startColumn,endColumn:toColumn,startRow:from.row,endRow:to.row});if(selectionCell==null)return;newTransform={...transform,left:selectionCell.startX-((transform==null?void 0:transform.width)||0)}}else{const selectionCell=this._skeletonManagerService.attachRangeWithCoord({startColumn,endColumn,startRow:from.row,endRow:to.row});if(selectionCell==null)return;if(newTransform={...transform,width:((transform==null?void 0:transform.width)||0)-selectionCell.endX+selectionCell.startX},newSheetTransform=transformToDrawingPosition(newTransform,this._selectionRenderService),newSheetTransform!=null&&newTransform!=null){preUpdateDrawings.push({...drawing2,sheetTransform:newSheetTransform,transform:newTransform});break}}if(newTransform!=null&&(newSheetTransform=transformToDrawingPosition(newTransform,this._selectionRenderService)),newTransform!=null&&newSheetTransform!=null){updateDrawings.push({...drawing2,sheetTransform:newSheetTransform,transform:newTransform});break}else this._remainDrawingSize(transform,updateDrawings,drawing2)}}}),updateDrawings.length===0&&preUpdateDrawings.length===0)return{redos:[],undos:[]};const{redos,undos}=this._createUndoAndRedoMutation(unitId,subUnitId,updateDrawings),preRedos=[],preUndos=[];if(preUpdateDrawings.length>0){const{redos:redos2,undos:undos2}=this._createUndoAndRedoMutation(unitId,subUnitId,preUpdateDrawings);preRedos.push(...redos2),preUndos.push(...undos2)}return{redos,undos,preRedos,preUndos}}_createUndoAndRedoMutation(unitId,subUnitId,updateDrawings){const updateJsonOp=this._sheetDrawingService.getBatchUpdateOp(updateDrawings),{undo,redo,objects}=updateJsonOp,redos=[{id:sheetsDrawing.SetDrawingApplyMutation.id,params:{unitId,subUnitId,op:redo,objects,type:sheetsDrawing.DrawingApplyType.UPDATE}},{id:ClearSheetDrawingTransformerOperation.id,params:[unitId]}],undos=[{id:sheetsDrawing.SetDrawingApplyMutation.id,params:{unitId,subUnitId,op:undo,objects,type:sheetsDrawing.DrawingApplyType.UPDATE}},{id:ClearSheetDrawingTransformerOperation.id,params:[unitId]}];return{redos,undos}}_getDrawingUndoForRowVisible(unitId,subUnitId,ranges){const drawingData=this._drawingManagerService.getDrawingData(unitId,subUnitId),updateDrawings=[],preUpdateDrawings=[];if(Object.keys(drawingData).forEach(drawingId=>{const drawing2=drawingData[drawingId],{sheetTransform,transform,anchorType=sheetsDrawing.SheetDrawingAnchorType.Position}=drawing2;if(anchorType===sheetsDrawing.SheetDrawingAnchorType.None)this._remainDrawingSize(transform,updateDrawings,drawing2);else{const{from,to}=sheetTransform,{row:fromRow,column:fromColumn}=from,{row:toRow,column:toColumn}=to;for(let i=0;i<ranges.length;i++){const range=ranges[i],{startRow,endRow,startColumn,endColumn}=range;if(toRow<startRow)continue;if(anchorType===sheetsDrawing.SheetDrawingAnchorType.Position){let newSheetTransform2=null,newTransform2=null;if(fromRow>=startRow&&fromRow<=endRow){const selectionCell=this._skeletonManagerService.attachRangeWithCoord({startColumn:from.column,endColumn:to.column,startRow:fromRow,endRow});if(selectionCell==null)return;newTransform2={...transform,top:selectionCell.startY}}if(newTransform2!=null&&(newSheetTransform2=transformToDrawingPosition(newTransform2,this._selectionRenderService),newSheetTransform2!=null&&newTransform2!=null)){updateDrawings.push({...drawing2,sheetTransform:newSheetTransform2,transform:newTransform2});break}this._remainDrawingSize(transform,updateDrawings,drawing2);continue}if(fromRow>=startRow&&toRow<=endRow)continue;let newSheetTransform=null,newTransform=null;if(fromRow>=startRow&&fromRow<=endRow){const selectionCell=this._skeletonManagerService.attachRangeWithCoord({startColumn:from.column,endColumn:to.column,startRow:fromRow,endRow});if(selectionCell==null)return;newTransform={...transform,top:(selectionCell==null?void 0:selectionCell.startY)||0,height:((transform==null?void 0:transform.height)||0)-selectionCell.endY+selectionCell.startY}}else if(toRow>=startRow&&toRow<=endRow){const selectionCell=this._skeletonManagerService.attachRangeWithCoord({startColumn:from.column,endColumn:to.column,startRow,endRow:toRow});if(selectionCell==null)return;newTransform={...transform,top:selectionCell.startY-((transform==null?void 0:transform.height)||0)}}else{const selectionCell=this._skeletonManagerService.attachRangeWithCoord({startColumn:from.column,endColumn:to.column,startRow,endRow});if(selectionCell==null)return;if(newTransform={...transform,height:((transform==null?void 0:transform.height)||0)-selectionCell.endY+selectionCell.startY},newSheetTransform=transformToDrawingPosition(newTransform,this._selectionRenderService),newSheetTransform!=null&&newTransform!=null){preUpdateDrawings.push({...drawing2,sheetTransform:newSheetTransform,transform:newTransform});break}}if(newTransform!=null&&(newSheetTransform=transformToDrawingPosition(newTransform,this._selectionRenderService)),newTransform!=null&&newSheetTransform!=null){updateDrawings.push({...drawing2,sheetTransform:newSheetTransform,transform:newTransform});break}else this._remainDrawingSize(transform,updateDrawings,drawing2)}}}),updateDrawings.length===0&&preUpdateDrawings.length===0)return{redos:[],undos:[]};const{redos,undos}=this._createUndoAndRedoMutation(unitId,subUnitId,updateDrawings),preRedos=[],preUndos=[];if(preUpdateDrawings.length>0){const{redos:redos2,undos:undos2}=this._createUndoAndRedoMutation(unitId,subUnitId,preUpdateDrawings);preRedos.push(...redos2),preUndos.push(...undos2)}return{redos,undos,preRedos,preUndos}}_getDrawingUndoForRowAndColSize(unitId,subUnitId,ranges,isRow){const drawingData=this._drawingManagerService.getDrawingData(unitId,subUnitId),updateDrawings=[];return Object.keys(drawingData).forEach(drawingId=>{const drawing2=drawingData[drawingId],{sheetTransform,transform,anchorType=sheetsDrawing.SheetDrawingAnchorType.Position}=drawing2;if(anchorType===sheetsDrawing.SheetDrawingAnchorType.None)this._remainDrawingSize(transform,updateDrawings,drawing2);else{const{from,to}=sheetTransform,{row:fromRow,column:fromColumn}=from,{row:toRow,column:toColumn}=to;for(let i=0;i<ranges.length;i++){const range=ranges[i],{startRow,endRow,startColumn,endColumn}=range;if(toRow<startRow||toColumn<startColumn)continue;if(anchorType===sheetsDrawing.SheetDrawingAnchorType.Position&&(fromRow<=startRow&&toRow>=endRow||fromColumn<=startColumn&&toColumn>=endColumn)){this._remainDrawingSize(transform,updateDrawings,drawing2);continue}const newTransform=drawingPositionToTransform({...sheetTransform},this._selectionRenderService,this._skeletonManagerService);if(newTransform!=null){updateDrawings.push({...drawing2,transform:newTransform});break}}}}),updateDrawings.length===0?{redos:[],undos:[]}:this._createUndoAndRedoMutation(unitId,subUnitId,updateDrawings)}_getUnitIdAndSubUnitId(params,type){let unitId,subUnitId;if(type==="insert")unitId=params.unitId,subUnitId=params.subUnitId;else{const newParams=sheets.getSheetCommandTarget(this._univerInstanceService);if(newParams==null)return;unitId=newParams.unitId,subUnitId=newParams.subUnitId}return{unitId,subUnitId}}_moveRangeInterceptor(params){var _a2,_b2;const{toRange,fromRange}=params,target=sheets.getSheetCommandTarget(this._univerInstanceService);if(!target)return{redos:[],undos:[]};const{unitId,subUnitId}=target,skeleton=(_b2=(_a2=this._renderManagerService.getRenderById(unitId))==null?void 0:_a2.with(sheetsUi.SheetSkeletonManagerService))==null?void 0:_b2.getCurrentSkeleton();if(!skeleton)return{redos:[],undos:[]};const selectionRect=sheetsUi.attachRangeWithCoord(skeleton,fromRange);if(!selectionRect)return{redos:[],undos:[]};const{startX,endX,startY,endY}=selectionRect,drawings=this._sheetDrawingService.getDrawingData(unitId,subUnitId),containedDrawings=[];Object.keys(drawings).forEach(drawingId=>{const drawing2=drawings[drawingId];if(drawing2.anchorType!==sheetsDrawing.SheetDrawingAnchorType.Both)return;const{transform}=drawing2;if(!transform)return;const{left=0,top=0,width=0,height=0}=transform,{drawingStartX,drawingEndX,drawingStartY,drawingEndY}={drawingStartX:left,drawingEndX:left+width,drawingStartY:top,drawingEndY:top+height};startX<=drawingStartX&&drawingEndX<=endX&&startY<=drawingStartY&&drawingEndY<=endY&&containedDrawings.push(drawing2)});const redos=[],undos=[],rowOffset=toRange.startRow-fromRange.startRow,colOffset=toRange.startColumn-fromRange.startColumn,updateDrawings=containedDrawings.map(drawing2=>{const oldSheetTransform=drawing2.sheetTransform,sheetTransform={to:{...oldSheetTransform.to,row:oldSheetTransform.to.row+rowOffset,column:oldSheetTransform.to.column+colOffset},from:{...oldSheetTransform.from,row:oldSheetTransform.from.row+rowOffset,column:oldSheetTransform.from.column+colOffset}},transform=drawingPositionToTransform(sheetTransform,this._selectionRenderService,this._skeletonManagerService);return{unitId,subUnitId,drawingId:drawing2.drawingId,transform,sheetTransform}});if(updateDrawings.length){const updateJsonOp=this._sheetDrawingService.getBatchUpdateOp(updateDrawings),{undo,redo,objects}=updateJsonOp;redos.push({id:sheetsDrawing.SetDrawingApplyMutation.id,params:{unitId,subUnitId,op:redo,objects,type:sheetsDrawing.DrawingApplyType.UPDATE}}),undos.push({id:sheetsDrawing.SetDrawingApplyMutation.id,params:{unitId,subUnitId,op:undo,objects,type:sheetsDrawing.DrawingApplyType.UPDATE}})}return{redos,undos}}_moveRowInterceptor(params,type){const ids=this._getUnitIdAndSubUnitId(params,type);if(ids==null)return{redos:[],undos:[]};const{unitId,subUnitId}=ids,{range}=params,rowStartIndex=range.startRow,rowEndIndex=range.endRow,redos=[],undos=[],data=this._sheetDrawingService.getDrawingData(unitId,subUnitId),updateDrawings=[],deleteDrawings=[];if(Object.keys(data).forEach(drawingId=>{const drawing2=data[drawingId],{sheetTransform,transform,anchorType=sheetsDrawing.SheetDrawingAnchorType.Position}=drawing2;if(sheetTransform==null||transform==null)return;let newSheetTransform,newTransform;if(type==="insert"){const param=this._expandRow(sheetTransform,transform,rowStartIndex,rowEndIndex,anchorType);newSheetTransform=param==null?void 0:param.newSheetTransform,newTransform=param==null?void 0:param.newTransform}else{const{from,to}=sheetTransform,{row:fromRow}=from,{row:toRow}=to;if(anchorType===sheetsDrawing.SheetDrawingAnchorType.Both&&fromRow>=rowStartIndex&&toRow<=rowEndIndex)deleteDrawings.push({unitId,subUnitId,drawingId});else{const param=this._shrinkRow(sheetTransform,transform,rowStartIndex,rowEndIndex,anchorType);newSheetTransform=param==null?void 0:param.newSheetTransform,newTransform=param==null?void 0:param.newTransform}}if(!newSheetTransform||!newTransform)return;const params2={unitId,subUnitId,drawingId,transform:newTransform,sheetTransform:newSheetTransform};updateDrawings.push(params2)}),updateDrawings.length===0&&deleteDrawings.length===0)return{redos:[],undos:[]};if(updateDrawings.length>0){const updateJsonOp=this._sheetDrawingService.getBatchUpdateOp(updateDrawings),{undo,redo,objects}=updateJsonOp;redos.push({id:sheetsDrawing.SetDrawingApplyMutation.id,params:{unitId,subUnitId,op:redo,objects,type:sheetsDrawing.DrawingApplyType.UPDATE}}),undos.push({id:sheetsDrawing.SetDrawingApplyMutation.id,params:{unitId,subUnitId,op:undo,objects,type:sheetsDrawing.DrawingApplyType.UPDATE}})}if(deleteDrawings.length>0){const deleteJsonOp=this._sheetDrawingService.getBatchRemoveOp(deleteDrawings),deleteUndo=deleteJsonOp.undo,deleteRedo=deleteJsonOp.redo,deleteObjects=deleteJsonOp.objects;redos.push({id:sheetsDrawing.SetDrawingApplyMutation.id,params:{unitId,subUnitId,op:deleteRedo,objects:deleteObjects,type:sheetsDrawing.DrawingApplyType.REMOVE}}),undos.push({id:sheetsDrawing.SetDrawingApplyMutation.id,params:{unitId,subUnitId,op:deleteUndo,objects:deleteObjects,type:sheetsDrawing.DrawingApplyType.INSERT}})}return redos.push({id:ClearSheetDrawingTransformerOperation.id,params:[unitId]}),undos.push({id:ClearSheetDrawingTransformerOperation.id,params:[unitId]}),{redos,undos}}_moveColInterceptor(params,type){const ids=this._getUnitIdAndSubUnitId(params,type);if(ids==null)return{redos:[],undos:[]};const{unitId,subUnitId}=ids,{range}=params,colStartIndex=range.startColumn,colEndIndex=range.endColumn,redos=[],undos=[],data=this._sheetDrawingService.getDrawingData(unitId,subUnitId),updateDrawings=[],deleteDrawings=[];if(Object.keys(data).forEach(drawingId=>{const drawing2=data[drawingId],{sheetTransform,transform,anchorType=sheetsDrawing.SheetDrawingAnchorType.Position}=drawing2;if(sheetTransform==null||transform==null)return;let newSheetTransform,newTransform;if(type==="insert"){const param=this._expandCol(sheetTransform,transform,colStartIndex,colEndIndex,anchorType);newSheetTransform=param==null?void 0:param.newSheetTransform,newTransform=param==null?void 0:param.newTransform}else{const{from,to}=sheetTransform,{column:fromColumn}=from,{column:toColumn}=to;if(anchorType===sheetsDrawing.SheetDrawingAnchorType.Both&&fromColumn>=colStartIndex&&toColumn<=colEndIndex)deleteDrawings.push({unitId,subUnitId,drawingId});else{const param=this._shrinkCol(sheetTransform,transform,colStartIndex,colEndIndex,anchorType);newSheetTransform=param==null?void 0:param.newSheetTransform,newTransform=param==null?void 0:param.newTransform}}if(!newSheetTransform||!newTransform)return;const params2={unitId,subUnitId,drawingId,transform:newTransform,sheetTransform:newSheetTransform};updateDrawings.push(params2)}),updateDrawings.length===0&&deleteDrawings.length===0)return{redos:[],undos:[]};if(updateDrawings.length>0){const updateJsonOp=this._sheetDrawingService.getBatchUpdateOp(updateDrawings),{undo,redo,objects}=updateJsonOp;redos.push({id:sheetsDrawing.SetDrawingApplyMutation.id,params:{unitId,subUnitId,op:redo,objects,type:sheetsDrawing.DrawingApplyType.UPDATE}}),undos.push({id:sheetsDrawing.SetDrawingApplyMutation.id,params:{unitId,subUnitId,op:undo,objects,type:sheetsDrawing.DrawingApplyType.UPDATE}})}if(deleteDrawings.length>0){const deleteJsonOp=this._sheetDrawingService.getBatchRemoveOp(deleteDrawings),deleteUndo=deleteJsonOp.undo,deleteRedo=deleteJsonOp.redo,deleteObjects=deleteJsonOp.objects;redos.push({id:sheetsDrawing.SetDrawingApplyMutation.id,params:{unitId,subUnitId,op:deleteRedo,objects:deleteObjects,type:sheetsDrawing.DrawingApplyType.REMOVE}}),undos.push({id:sheetsDrawing.SetDrawingApplyMutation.id,params:{unitId,subUnitId,op:deleteUndo,objects:deleteObjects,type:sheetsDrawing.DrawingApplyType.INSERT}})}return redos.push({id:ClearSheetDrawingTransformerOperation.id,params:[unitId]}),undos.push({id:ClearSheetDrawingTransformerOperation.id,params:[unitId]}),{redos,undos}}_expandCol(sheetTransform,transform,colStartIndex,colEndIndex,anchorType=sheetsDrawing.SheetDrawingAnchorType.Position){const colCount=colEndIndex-colStartIndex+1,{from,to}=sheetTransform,{column:fromColumn}=from,{column:toColumn}=to;if(anchorType===sheetsDrawing.SheetDrawingAnchorType.None)return{newSheetTransform:transformToDrawingPosition({...transform},this._selectionRenderService),newTransform:transform};let newSheetTransform=null,newTransform=null;if(fromColumn>=colStartIndex){const selectionCell=this._skeletonManagerService.attachRangeWithCoord({startColumn:colStartIndex,endColumn:colEndIndex,startRow:from.row,endRow:to.row});if(selectionCell==null)return;newTransform={...transform,left:(transform.left||0)+selectionCell.endX-selectionCell.startX},newSheetTransform=transformToDrawingPosition(newTransform,this._selectionRenderService)}else if(toColumn>=colEndIndex)if(anchorType===sheetsDrawing.SheetDrawingAnchorType.Both)newSheetTransform={from:{...from},to:{...to,column:toColumn+colCount}},newTransform=drawingPositionToTransform(newSheetTransform,this._selectionRenderService,this._skeletonManagerService);else return{newSheetTransform:transformToDrawingPosition({...transform},this._selectionRenderService),newTransform:transform};return newSheetTransform!=null&&newTransform!=null?{newSheetTransform,newTransform}:null}_shrinkCol(sheetTransform,transform,colStartIndex,colEndIndex,anchorType=sheetsDrawing.SheetDrawingAnchorType.Position){const colCount=colEndIndex-colStartIndex+1,{from,to}=sheetTransform,{column:fromColumn}=from,{column:toColumn}=to;if(anchorType===sheetsDrawing.SheetDrawingAnchorType.None)return{newSheetTransform:transformToDrawingPosition({...transform},this._selectionRenderService),newTransform:transform};let newSheetTransform=null,newTransform=null;if(fromColumn>colEndIndex)newSheetTransform={from:{...from,column:fromColumn-colCount},to:{...to,column:toColumn-colCount}},newTransform=drawingPositionToTransform(newSheetTransform,this._selectionRenderService,this._skeletonManagerService);else{if(fromColumn>=colStartIndex&&toColumn<=colEndIndex)return null;if(fromColumn<colStartIndex&&toColumn>colEndIndex)if(anchorType===sheetsDrawing.SheetDrawingAnchorType.Both)newSheetTransform={from:{...from},to:{...to,column:toColumn-colCount}},newTransform=drawingPositionToTransform(newSheetTransform,this._selectionRenderService,this._skeletonManagerService);else return{newSheetTransform:transformToDrawingPosition({...transform},this._selectionRenderService),newTransform:transform};else if(fromColumn>=colStartIndex&&fromColumn<=colEndIndex){if(fromColumn===colStartIndex)newTransform={...transform,left:(transform.left||0)-sheetTransform.from.columnOffset};else{const selectionCell=this._skeletonManagerService.attachRangeWithCoord({startColumn:colStartIndex,endColumn:fromColumn-1,startRow:from.row,endRow:to.row});if(selectionCell==null)return;newTransform={...transform,left:(transform.left||0)-selectionCell.endX+selectionCell.startX-sheetTransform.from.columnOffset}}newSheetTransform=transformToDrawingPosition(newTransform,this._selectionRenderService)}else if(toColumn>=colStartIndex&&toColumn<=colEndIndex&&anchorType===sheetsDrawing.SheetDrawingAnchorType.Both){const selectionCell=this._skeletonManagerService.attachRangeWithCoord({startColumn:colStartIndex-1,endColumn:colStartIndex-1,startRow:from.row,endRow:to.row});if(selectionCell==null)return;newSheetTransform={from:{...from},to:{...to,column:colStartIndex-1,columnOffset:selectionCell.endX-selectionCell.startX}},newTransform=drawingPositionToTransform(newSheetTransform,this._selectionRenderService,this._skeletonManagerService)}}return newSheetTransform!=null&&newTransform!=null?{newSheetTransform,newTransform}:null}_expandRow(sheetTransform,transform,rowStartIndex,rowEndIndex,anchorType=sheetsDrawing.SheetDrawingAnchorType.Position){const rowCount=rowEndIndex-rowStartIndex+1,{from,to}=sheetTransform,{row:fromRow}=from,{row:toRow}=to;if(anchorType===sheetsDrawing.SheetDrawingAnchorType.None)return{newSheetTransform:transformToDrawingPosition({...transform},this._selectionRenderService),newTransform:transform};let newSheetTransform=null,newTransform=null;if(fromRow>=rowStartIndex){const selectionCell=this._skeletonManagerService.attachRangeWithCoord({startRow:rowStartIndex,endRow:rowEndIndex,startColumn:from.column,endColumn:to.column});if(selectionCell==null)return;newTransform={...transform,top:(transform.top||0)+selectionCell.endY-selectionCell.startY},newSheetTransform=transformToDrawingPosition(newTransform,this._selectionRenderService)}else if(toRow>=rowEndIndex)if(anchorType===sheetsDrawing.SheetDrawingAnchorType.Both)newSheetTransform={from:{...from},to:{...to,row:toRow+rowCount}},newTransform=drawingPositionToTransform(newSheetTransform,this._selectionRenderService,this._skeletonManagerService);else return{newSheetTransform:transformToDrawingPosition({...transform},this._selectionRenderService),newTransform:transform};return newSheetTransform!=null&&newTransform!=null?{newSheetTransform,newTransform}:null}_shrinkRow(sheetTransform,transform,rowStartIndex,rowEndIndex,anchorType=sheetsDrawing.SheetDrawingAnchorType.Position){const rowCount=rowEndIndex-rowStartIndex+1,{from,to}=sheetTransform,{row:fromRow}=from,{row:toRow}=to;if(anchorType===sheetsDrawing.SheetDrawingAnchorType.None)return{newSheetTransform:transformToDrawingPosition({...transform},this._selectionRenderService),newTransform:transform};let newSheetTransform=null,newTransform=null;if(fromRow>rowEndIndex)newSheetTransform={from:{...from,row:fromRow-rowCount},to:{...to,row:toRow-rowCount}},newTransform=drawingPositionToTransform(newSheetTransform,this._selectionRenderService,this._skeletonManagerService);else{if(fromRow>=rowStartIndex&&toRow<=rowEndIndex)return null;if(fromRow<rowStartIndex&&toRow>rowEndIndex)if(anchorType===sheetsDrawing.SheetDrawingAnchorType.Both)newSheetTransform={from:{...from},to:{...to,row:toRow-rowCount}},newTransform=drawingPositionToTransform(newSheetTransform,this._selectionRenderService,this._skeletonManagerService);else return{newSheetTransform:transformToDrawingPosition({...transform},this._selectionRenderService),newTransform:transform};else if(fromRow>=rowStartIndex&&fromRow<=rowEndIndex){if(fromRow===rowStartIndex)newTransform={...transform,top:(transform.top||0)-sheetTransform.from.rowOffset};else{const selectionCell=this._skeletonManagerService.attachRangeWithCoord({startRow:rowStartIndex,endRow:fromRow-1,startColumn:from.column,endColumn:to.column});if(selectionCell==null)return;newTransform={...transform,top:(transform.top||0)-selectionCell.endY+selectionCell.startY-sheetTransform.from.rowOffset}}newSheetTransform=transformToDrawingPosition(newTransform,this._selectionRenderService)}else if(toRow>=rowStartIndex&&toRow<=rowEndIndex&&anchorType===sheetsDrawing.SheetDrawingAnchorType.Both){const selectionCell=this._skeletonManagerService.attachRangeWithCoord({startColumn:from.column,endColumn:from.column,startRow:rowStartIndex-1,endRow:rowStartIndex-1});if(selectionCell==null)return;newSheetTransform={from:{...from},to:{...to,row:rowStartIndex-1,rowOffset:selectionCell.endY-selectionCell.startY}},newTransform=drawingPositionToTransform(newSheetTransform,this._selectionRenderService,this._skeletonManagerService)}}return newSheetTransform!=null&&newTransform!=null?{newSheetTransform,newTransform}:null}_commandListener(){this.disposeWithMe(this._commandService.onCommandExecuted(command=>{command.id===sheets.SetWorksheetActiveOperation.id&&setTimeout(()=>{const params=command.params,{unitId:showUnitId,subUnitId:showSubunitId}=params,drawingMap=this._drawingManagerService.drawingManagerData,insertDrawings=[],removeDrawings=[];Object.keys(drawingMap).forEach(unitId=>{const subUnitMap=drawingMap[unitId];subUnitMap!=null&&Object.keys(subUnitMap).forEach(subUnitId=>{const drawingData=subUnitMap[subUnitId].data;drawingData!=null&&Object.keys(drawingData).forEach(drawingId=>{if(unitId===showUnitId&&subUnitId===showSubunitId){const drawing2=drawingData[drawingId];drawing2.transform=drawingPositionToTransform(drawing2.sheetTransform,this._selectionRenderService,this._skeletonManagerService),insertDrawings.push(drawingData[drawingId])}else removeDrawings.push(drawingData[drawingId])})})}),this._drawingManagerService.removeNotification(removeDrawings),this._drawingManagerService.addNotification(insertDrawings)},0)}))}_sheetRefreshListener(){this.disposeWithMe(this._commandService.onCommandExecuted(command=>{REFRESH_MUTATIONS.includes(command.id)&&requestIdleCallback(()=>{const params=command.params,{unitId,subUnitId,ranges}=params;this._refreshDrawingTransform(unitId,subUnitId,ranges)})}))}_refreshDrawingTransform(unitId,subUnitId,ranges){const drawingData=this._drawingManagerService.getDrawingData(unitId,subUnitId),updateDrawings=[];Object.keys(drawingData).forEach(drawingId=>{const drawing2=drawingData[drawingId],{sheetTransform,transform,anchorType=sheetsDrawing.SheetDrawingAnchorType.Position}=drawing2;if(anchorType===sheetsDrawing.SheetDrawingAnchorType.None)return!0;const{from,to}=sheetTransform,{row:fromRow,column:fromColumn}=from,{row:toRow,column:toColumn}=to;for(let i=0;i<ranges.length;i++){const range=ranges[i],{startRow,endRow,startColumn,endColumn}=range;if(core.Rectangle.intersects({startRow,endRow,startColumn,endColumn},{startRow:fromRow,endRow:toRow,startColumn:fromColumn,endColumn:toColumn})||fromRow>endRow||fromColumn>endColumn){const isPositionAnchor=anchorType===sheetsDrawing.SheetDrawingAnchorType.Position,newTransform=drawingPositionToTransform(sheetTransform,this._selectionRenderService,this._skeletonManagerService);updateDrawings.push({...drawing2,transform:{...newTransform,width:isPositionAnchor?transform==null?void 0:transform.width:newTransform==null?void 0:newTransform.width,height:isPositionAnchor?transform==null?void 0:transform.height:newTransform==null?void 0:newTransform.height}});break}}}),updateDrawings.length!==0&&(this._drawingManagerService.refreshTransform(updateDrawings),this._commandService.syncExecuteCommand(ClearSheetDrawingTransformerOperation.id,[unitId]))}},__name(_h,"SheetDrawingTransformAffectedController"),_h);SheetDrawingTransformAffectedController=__decorateClass$2([__decorateParam$2(1,engineRender.IRenderManagerService),__decorateParam$2(2,core.ICommandService),__decorateParam$2(3,sheetsUi.ISheetSelectionRenderService),__decorateParam$2(4,core.Inject(sheetsUi.SheetSkeletonManagerService)),__decorateParam$2(5,core.Inject(sheets.SheetInterceptorService)),__decorateParam$2(6,sheetsDrawing.ISheetDrawingService),__decorateParam$2(7,drawing.IDrawingManagerService),__decorateParam$2(8,core.IUniverInstanceService)],SheetDrawingTransformAffectedController);var __defProp$1=Object.defineProperty,__getOwnPropDesc$1=Object.getOwnPropertyDescriptor,__decorateClass$1=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc$1(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp$1(target,key,result),result},"__decorateClass$1"),__decorateParam$1=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam$1");function transformBound2DOMBound(originBound,scene,skeleton,worksheet){const{scaleX,scaleY}=scene.getAncestorScale(),viewMain=scene.getViewport(engineRender.SHEET_VIEWPORT_KEY.VIEW_MAIN),absolute={left:!0,top:!0};if(!viewMain)return{...originBound,absolute};const{left,right,top,bottom}=originBound,freeze=worksheet.getFreeze(),{startColumn,startRow,xSplit,ySplit}=freeze,startSheetView=skeleton.getNoMergeCellPositionByIndexWithNoHeader(startRow-ySplit,startColumn-xSplit),endSheetView=skeleton.getNoMergeCellPositionByIndexWithNoHeader(startRow,startColumn),{rowHeaderWidth,columnHeaderHeight}=skeleton,freezeWidth=endSheetView.startX-startSheetView.startX,freezeHeight=endSheetView.startY-startSheetView.startY,{top:freezeTop,left:freezeLeft,viewportScrollX:actualScrollX,viewportScrollY:actualScrollY}=viewMain;let offsetLeft,offsetRight;left<freezeLeft?(absolute.left=!0,offsetLeft=(freezeWidth+rowHeaderWidth+(left-freezeLeft))*scaleX,offsetRight=Math.max(Math.min((freezeWidth+rowHeaderWidth+(right-freezeLeft))*scaleX,(freezeWidth+rowHeaderWidth)*scaleX),(right-actualScrollX)*scaleX)):(absolute.left=!1,offsetLeft=Math.max((left-actualScrollX)*scaleX,(freezeWidth+rowHeaderWidth)*scaleX),offsetRight=Math.max((right-actualScrollX)*scaleX,(freezeWidth+rowHeaderWidth)*scaleX));let offsetTop,offsetBottom;return top<freezeTop?(absolute.top=!0,offsetTop=(freezeHeight+columnHeaderHeight+(top-freezeTop))*scaleY,offsetBottom=Math.max(Math.min((freezeHeight+columnHeaderHeight+(right-freezeTop))*scaleY,(freezeHeight+columnHeaderHeight)*scaleY),(bottom-actualScrollY)*scaleY)):(absolute.top=!1,offsetTop=Math.max((top-actualScrollY)*scaleY,(freezeHeight+columnHeaderHeight)*scaleY),offsetBottom=Math.max((bottom-actualScrollY)*scaleY,(freezeHeight+columnHeaderHeight)*scaleY)),{left:offsetLeft,right:offsetRight,top:offsetTop,bottom:offsetBottom,absolute}}__name(transformBound2DOMBound,"transformBound2DOMBound");const calcPosition=__name((targetObject,currentRender,skeleton,worksheet)=>{const{scene}=currentRender,{left,top,width,height,angle}=targetObject,bound={left,right:left+width,top,bottom:top+height},offsetBound=transformBound2DOMBound(bound,scene,skeleton,worksheet),{scaleX,scaleY}=scene.getAncestorScale();return{startX:offsetBound.left,endX:offsetBound.right,startY:offsetBound.top,endY:offsetBound.bottom,rotate:angle,width:width*scaleX,height:height*scaleY,absolute:offsetBound.absolute}},"calcPosition");exports2.SheetCanvasFloatDomManagerService=(_i=class extends core.Disposable{constructor(_renderManagerService,_univerInstanceService,_commandService,_drawingManagerService,_canvasFloatDomService,_sheetDrawingService,_lifecycleService){super();__publicField(this,"_domLayerMap",new Map);__publicField(this,"_domLayerInfoMap",new Map);__publicField(this,"_transformChange$",new rxjs.Subject);__publicField(this,"transformChange$",this._transformChange$.asObservable());__publicField(this,"_add$",new rxjs.Subject);__publicField(this,"add$",this._add$.asObservable());__publicField(this,"_remove$",new rxjs.Subject);__publicField(this,"remove$",this._remove$.asObservable());__publicField(this,"_hooks",[]);this._renderManagerService=_renderManagerService,this._univerInstanceService=_univerInstanceService,this._commandService=_commandService,this._drawingManagerService=_drawingManagerService,this._canvasFloatDomService=_canvasFloatDomService,this._sheetDrawingService=_sheetDrawingService,this._lifecycleService=_lifecycleService,this._drawingAddListener(),this._featureUpdateListener(),this._deleteListener(),this._bindScrollEvent()}_bindScrollEvent(){this._lifecycleService.lifecycle$.pipe(rxjs.filter(s=>s===core.LifecycleStages.Rendered),rxjs.take(1)).subscribe(()=>{this._scrollUpdateListener()})}_ensureMap(unitId,subUnitId){let unitMap=this._domLayerMap.get(unitId);unitMap||(unitMap=new Map,this._domLayerMap.set(unitId,unitMap));let subUnitMap=unitMap.get(subUnitId);return subUnitMap||(subUnitMap=new Map,unitMap.set(subUnitId,subUnitMap)),subUnitMap}getFloatDomInfo(id){return this._domLayerInfoMap.get(id)}_getSceneAndTransformerByDrawingSearch(unitId){if(unitId==null)return;const renderObject=this._renderManagerService.getRenderById(unitId),scene=renderObject==null?void 0:renderObject.scene;if(renderObject==null||scene==null)return null;const transformer=scene.getTransformerByCreate(),canvas=renderObject.engine.getCanvasElement();return{scene,transformer,renderObject,canvas}}_getFloatDomProps(id){let props;return this._hooks.forEach(hook=>{props=hook.onGetFloatDomProps(id)}),props}_drawingAddListener(){this.disposeWithMe(this._drawingManagerService.add$.subscribe(params=>{params.forEach(param=>{var _a2,_b2,_c2;const{unitId,subUnitId,drawingId}=param,target=sheets.getSheetCommandTarget(this._univerInstanceService,{unitId,subUnitId}),floatDomParam=this._drawingManagerService.getDrawingByParam(param);if(!floatDomParam||!target)return;const skeleton=(_a2=this._renderManagerService.getRenderById(unitId))==null?void 0:_a2.with(sheetsUi.SheetSkeletonManagerService).getWorksheetSkeleton(subUnitId);if(!skeleton)return;const{transform,drawingType,data}=floatDomParam;if(drawingType!==drawing.DrawingTypeEnum.DRAWING_DOM&&drawingType!==drawing.DrawingTypeEnum.DRAWING_CHART)return;const renderObject=this._getSceneAndTransformerByDrawingSearch(unitId);if(renderObject==null)return;const{scene,canvas}=renderObject;if(transform==null)return!0;const{left,top,width,height,angle,flipX,flipY,skewX,skewY}=transform,rectShapeKey=drawing.getDrawingShapeKeyByDrawingSearch({unitId,subUnitId,drawingId}),rectShape=scene.getObject(rectShapeKey);if(rectShape!=null){rectShape.transformByState({left,top,width,height,angle,flipX,flipY,skewX,skewY});return}const imageConfig={left,top,width,height,zIndex:this._drawingManagerService.getDrawingOrder(unitId,subUnitId).length-1},isChart=drawingType===drawing.DrawingTypeEnum.DRAWING_CHART;isChart&&(imageConfig.fill="white",imageConfig.rotateEnabled=!1,data&&data.border&&(imageConfig.stroke=data.border),imageConfig.paintFirst="stroke",imageConfig.strokeWidth=1,imageConfig.borderEnabled=!1);const rect=new engineRender.Rect(rectShapeKey,imageConfig);isChart&&rect.setObjectType(engineRender.ObjectType.CHART),scene.addObject(rect,engineRender.DRAWING_OBJECT_LAYER_INDEX),floatDomParam.allowTransform!==!1&&scene.attachTransformerTo(rect);const map2=this._ensureMap(unitId,subUnitId),disposableCollection=new core.DisposableCollection,initPosition=calcPosition(rect,renderObject.renderObject,skeleton.skeleton,target.worksheet),position$=new rxjs.BehaviorSubject(initPosition),info={dispose:disposableCollection,rect,position$,unitId,subUnitId};this._canvasFloatDomService.addFloatDom({position$,id:drawingId,componentKey:floatDomParam.componentKey,onPointerDown:__name(evt=>{canvas.dispatchEvent(new PointerEvent(evt.type,evt))},"onPointerDown"),onPointerMove:__name(evt=>{canvas.dispatchEvent(new PointerEvent(evt.type,evt))},"onPointerMove"),onPointerUp:__name(evt=>{canvas.dispatchEvent(new PointerEvent(evt.type,evt))},"onPointerUp"),onWheel:__name(evt=>{canvas.dispatchEvent(new WheelEvent(evt.type,evt))},"onWheel"),props:(_c2=(_b2=map2.get(drawingId))==null?void 0:_b2.props)!=null?_c2:this._getFloatDomProps(drawingId),data,unitId});const listener=rect.onTransformChange$.subscribeEvent(()=>{const newPosition=calcPosition(rect,renderObject.renderObject,skeleton.skeleton,target.worksheet);position$.next(newPosition)});disposableCollection.add(()=>{this._canvasFloatDomService.removeFloatDom(drawingId)}),listener&&disposableCollection.add(listener),this._domLayerInfoMap.set(drawingId,info),map2.set(drawingId,{...map2.get(drawingId)})})})),this.disposeWithMe(this._drawingManagerService.remove$.subscribe(params=>{params.forEach(param=>{const{unitId,subUnitId,drawingId}=param,rectShapeKey=drawing.getDrawingShapeKeyByDrawingSearch({unitId,subUnitId,drawingId}),renderObject=this._getSceneAndTransformerByDrawingSearch(unitId);if(renderObject==null)return;const{transformer,scene}=renderObject,rectShape=scene.getObject(rectShapeKey);rectShape!=null&&rectShape.oKey&&transformer.clearControlByIds([rectShape==null?void 0:rectShape.oKey])})}))}_scrollUpdateListener(){const updateSheet=__name((unitId,subUnitId)=>{var _a2;const renderObject=this._getSceneAndTransformerByDrawingSearch(unitId),map2=this._ensureMap(unitId,subUnitId),ids=Array.from(map2.keys()),target=sheets.getSheetCommandTarget(this._univerInstanceService,{unitId,subUnitId}),skeleton=(_a2=this._renderManagerService.getRenderById(unitId))==null?void 0:_a2.with(sheetsUi.SheetSkeletonManagerService).getWorksheetSkeleton(subUnitId);!renderObject||!target||!skeleton||ids.forEach(id=>{const info=this._domLayerInfoMap.get(id);if(info){const position=calcPosition(info.rect,renderObject.renderObject,skeleton.skeleton,target.worksheet);info.position$.next(position)}})},"updateSheet");this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(core.UniverInstanceType.UNIVER_SHEET).pipe(rxjs.filter(sheet=>!!sheet),rxjs.map(sheet=>{const render2=this._renderManagerService.getRenderById(sheet.getUnitId());return render2?{render:render2,unitId:sheet.getUnitId(),subUnitId:sheet.getActiveSheet().getSheetId()}:null}),rxjs.filter(render2=>!!render2),rxjs.switchMap(render2=>core.fromEventSubject(render2.render.scene.getViewport(sheetsUi.VIEWPORT_KEY.VIEW_MAIN).onScrollAfter$).pipe(rxjs.map(()=>({unitId:render2.unitId,subUnitId:render2.subUnitId}))))).subscribe(({unitId,subUnitId})=>{updateSheet(unitId,subUnitId)})),this.disposeWithMe(this._commandService.onCommandExecuted(commandInfo=>{var _a2,_b2;if(commandInfo.id===sheetsUi.SetZoomRatioOperation.id){const params=commandInfo.params,{unitId}=params;Array.from((_b2=(_a2=this._domLayerMap.get(unitId))==null?void 0:_a2.keys())!=null?_b2:[]).forEach(subUnitId=>{updateSheet(unitId,subUnitId)})}else if(commandInfo.id===sheets.SetFrozenMutation.id){const{unitId,subUnitId}=commandInfo.params;updateSheet(unitId,subUnitId)}}))}_getPosition(position,unitId){var _a2;const{startX,endX,startY,endY}=position,selectionRenderService=(_a2=this._renderManagerService.getRenderById(unitId))==null?void 0:_a2.with(sheetsUi.ISheetSelectionRenderService);if(selectionRenderService==null)return;const start=selectionRenderService.getSelectionCellByPosition(startX,startY);if(start==null)return;const from={column:start.actualColumn,columnOffset:startX-start.startX,row:start.actualRow,rowOffset:startY-start.startY},end=selectionRenderService.getSelectionCellByPosition(endX,endY);if(end==null)return;const to={column:end.actualColumn,columnOffset:endX-end.startX,row:end.actualRow,rowOffset:endY-end.startY};return{from,to}}_featureUpdateListener(){this.disposeWithMe(this._drawingManagerService.update$.subscribe(params=>{params.forEach(data=>{const sheetDrawing=this._drawingManagerService.getDrawingByParam(data);if(!sheetDrawing||sheetDrawing.drawingType!==drawing.DrawingTypeEnum.DRAWING_DOM&&sheetDrawing.drawingType!==drawing.DrawingTypeEnum.DRAWING_CHART)return;const newValue={...sheetDrawing.transform};this._transformChange$.next({id:data.drawingId,value:newValue})})}))}_deleteListener(){this.disposeWithMe(this._drawingManagerService.remove$.subscribe(params=>{params.forEach(param=>{this._removeDom(param.drawingId)})}))}updateFloatDomProps(unitId,subUnitId,id,props){const info=this._domLayerInfoMap.get(id),renderObject=this._getSceneAndTransformerByDrawingSearch(unitId);if(info&&renderObject){const{scene}=renderObject,rectShapeKey=drawing.getDrawingShapeKeyByDrawingSearch({unitId,subUnitId,drawingId:id}),rectShape=scene.getObject(rectShapeKey);rectShape&&rectShape instanceof engineRender.Rect&&rectShape.setProps(props)}}addFloatDomToPosition(layer,propId,executeCommand=!0){const target=sheets.getSheetCommandTarget(this._univerInstanceService,{unitId:layer.unitId,subUnitId:layer.subUnitId});if(!target)throw new Error("cannot find current target!");const{unitId,subUnitId}=target,{initPosition,componentKey,data,allowTransform=!0}=layer,id=propId!=null?propId:core.generateRandomId(),sheetTransform=this._getPosition(initPosition,unitId);if(sheetTransform==null)return;this._ensureMap(unitId,subUnitId).set(id,layer);const sheetDrawingParam={unitId,subUnitId,drawingId:id,drawingType:layer.type||drawing.DrawingTypeEnum.DRAWING_DOM,componentKey,sheetTransform,transform:{left:initPosition.startX,top:initPosition.startY,width:initPosition.endX-initPosition.startX,height:initPosition.endY-initPosition.startY},data,allowTransform};return executeCommand&&this._commandService.executeCommand(InsertSheetDrawingCommand.id,{unitId,drawings:[sheetDrawingParam]}),this._add$.next({unitId,subUnitId,id}),{id,dispose:__name(()=>{this._removeDom(id,!0)},"dispose"),sheetDrawingParam}}_removeDom(id,removeDrawing=!1){const info=this._domLayerInfoMap.get(id);if(!info)return;const{unitId,subUnitId}=info;this._domLayerInfoMap.delete(id),info.dispose.dispose();const renderObject=this._getSceneAndTransformerByDrawingSearch(unitId);if(renderObject&&renderObject.scene.removeObject(info.rect),removeDrawing){this._ensureMap(unitId,subUnitId).delete(id);const param=this._drawingManagerService.getDrawingByParam({unitId,subUnitId,drawingId:id});if(!param)return;const jsonOp=this._sheetDrawingService.getBatchRemoveOp([param]),{redo,objects}=jsonOp;this._commandService.syncExecuteCommand(sheetsDrawing.SetDrawingApplyMutation.id,{unitId,subUnitId,op:redo,objects,type:sheetsDrawing.DrawingApplyType.REMOVE})}}addHook(hook){return this._hooks.push(hook),{dispose:__name(()=>{const index=this._hooks.findIndex(h=>h===hook);this._hooks.splice(index,1)},"dispose")}}},__name(_i,"SheetCanvasFloatDomManagerService"),_i),exports2.SheetCanvasFloatDomManagerService=__decorateClass$1([__decorateParam$1(0,core.Inject(engineRender.IRenderManagerService)),__decorateParam$1(1,core.IUniverInstanceService),__decorateParam$1(2,core.Inject(core.ICommandService)),__decorateParam$1(3,drawing.IDrawingManagerService),__decorateParam$1(4,core.Inject(ui.CanvasFloatDomService)),__decorateParam$1(5,sheetsDrawing.ISheetDrawingService),__decorateParam$1(6,core.Inject(core.LifecycleService))],exports2.SheetCanvasFloatDomManagerService);var __defProp2=Object.defineProperty,__getOwnPropDesc=Object.getOwnPropertyDescriptor,__defNormalProp2=__name((obj,key,value)=>key in obj?__defProp2(obj,key,{enumerable:!0,configurable:!0,writable:!0,value}):obj[key]=value,"__defNormalProp"),__decorateClass=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp2(target,key,result),result},"__decorateClass"),__decorateParam=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam"),__publicField2=__name((obj,key,value)=>__defNormalProp2(obj,typeof key!="symbol"?key+"":key,value),"__publicField");const PLUGIN_NAME="SHEET_IMAGE_UI_PLUGIN";exports2.UniverSheetsDrawingUIPlugin=(_j=class extends core.Plugin{constructor(_config=defaultPluginConfig,_injector,_renderManagerService,_configService){super(),this._config=_config,this._injector=_injector,this._renderManagerService=_renderManagerService,this._configService=_configService;const{menu,...rest}=this._config;menu&&this._configService.setConfig("menu",menu,{merge:!0}),this._configService.setConfig(PLUGIN_CONFIG_KEY,rest)}onStarting(){core.registerDependencies(this._injector,[[exports2.SheetCanvasFloatDomManagerService],[SheetDrawingUIController],[DrawingPopupMenuController],[SheetDrawingPrintingController],[SheetDrawingPermissionController],[SheetsDrawingCopyPasteController]]),core.touchDependencies(this._injector,[[exports2.SheetCanvasFloatDomManagerService]])}onReady(){core.touchDependencies(this._injector,[[SheetsDrawingCopyPasteController]])}onRendered(){this._registerRenderModules(),core.touchDependencies(this._injector,[[SheetDrawingPermissionController],[SheetDrawingPrintingController],[SheetDrawingUIController]])}onSteady(){this._injector.get(DrawingPopupMenuController)}_registerRenderModules(){[[SheetDrawingUpdateController],[SheetDrawingTransformAffectedController],[SheetsDrawingRenderController]].forEach(m=>{this.disposeWithMe(this._renderManagerService.registerRenderModule(core.UniverInstanceType.UNIVER_SHEET,m))})}},__name(_j,"UniverSheetsDrawingUIPlugin"),_j),__publicField2(exports2.UniverSheetsDrawingUIPlugin,"type",core.UniverInstanceType.UNIVER_SHEET),__publicField2(exports2.UniverSheetsDrawingUIPlugin,"pluginName",PLUGIN_NAME),exports2.UniverSheetsDrawingUIPlugin=__decorateClass([core.DependentOn(drawing.UniverDrawingPlugin,drawingUi.UniverDrawingUIPlugin,sheetsDrawing.UniverSheetsDrawingPlugin),__decorateParam(1,core.Inject(core.Injector)),__decorateParam(2,engineRender.IRenderManagerService),__decorateParam(3,core.IConfigService)],exports2.UniverSheetsDrawingUIPlugin),exports2.ClearSheetDrawingTransformerOperation=ClearSheetDrawingTransformerOperation,exports2.DeleteDrawingsCommand=DeleteDrawingsCommand,exports2.EditSheetDrawingOperation=EditSheetDrawingOperation,exports2.GroupSheetDrawingCommand=GroupSheetDrawingCommand,exports2.IMAGE_MENU_ID=IMAGE_MENU_ID,exports2.InsertFloatImageCommand=InsertFloatImageCommand,exports2.InsertSheetDrawingCommand=InsertSheetDrawingCommand,exports2.MoveDrawingsCommand=MoveDrawingsCommand,exports2.RemoveSheetDrawingCommand=RemoveSheetDrawingCommand,exports2.SetDrawingArrangeCommand=SetDrawingArrangeCommand,exports2.SetSheetDrawingCommand=SetSheetDrawingCommand,exports2.SidebarSheetDrawingOperation=SidebarSheetDrawingOperation,exports2.UngroupSheetDrawingCommand=UngroupSheetDrawingCommand,Object.defineProperty(exports2,Symbol.toStringTag,{value:"Module"})});
|
|
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,B,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 D,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:M}=_;c.push(M)});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([...(D=f.preRedos)!=null?D:[],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}},Le="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:Le},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 We={exports:{}},de={};/**
|
|
2
|
+
* @license React
|
|
3
|
+
* react-jsx-runtime.production.min.js
|
|
4
|
+
*
|
|
5
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
6
|
+
*
|
|
7
|
+
* This source code is licensed under the MIT license found in the
|
|
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,We.exports=de;var $=We.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(B.takeUntil(this.dispose$)).subscribe(n=>this._create(n)),this._univerInstanceService.getTypeOfUnitDisposed$(p.UniverInstanceType.UNIVER_SHEET).pipe(B.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;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(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,D=r.getCurrentSkeleton(),C=j.attachRangeWithCoord(D,{startColumn:l,endColumn:l,startRow:u,endRow:u});if(C==null)return;const T=j.attachRangeWithCoord(D,{startColumn:f,endColumn:f,startRow:v,endRow:v});if(T==null)return;const{startX:_,startY:M}=C,{startX:w,startY:A}=T;let E=N.precisionTo(_+s,1),L=N.precisionTo(M+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=D.rowHeaderWidth+D.columnTotalWidth,W=D.columnHeaderHeight+D.rowTotalHeight;return E+U>R&&(E=R-U),L+P>W&&(L=W-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.getSelectionCellByPosition(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.getSelectionCellByPosition(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 De=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)}};De=lt([me(1,h.ISheetDrawingService),me(2,b.IDrawingManagerService),me(3,p.Inject(j.ISheetSelectionRenderService)),me(4,p.Inject(j.SheetSkeletonManagerService))],De);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 Me={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 D,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([...(D=f.preRedos)!=null?D:[],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(D){const C=D.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 D=b.DRAWING_IMAGE_WIDTH_LIMIT/l,C=b.DRAWING_IMAGE_HEIGHT_LIMIT/s;S=Math.max(D,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.getSelectionCellByPosition(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.getSelectionCellByPosition(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._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._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._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._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 M=[];return T.forEach(w=>{const{oKey:A}=w,E=_.getDrawingOKey(A);if(E==null)return M.push(null),!0;const{unitId:L,subUnitId:U,drawingId:P,drawingType:R,anchorType:W,sheetTransform:V}=E;M.push({unitId:L,subUnitId:U,drawingId:P,anchorType:W,sheetTransform:V,drawingType:R})}),M}H.useEffect(()=>{const T=l.clearControl$.subscribe(M=>{M===!0&&u(!1)}),_=l.changeStart$.subscribe(M=>{var E;const{objects:w}=M,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 M=_.map(w=>({unitId:w.unitId,subUnitId:w.subUnitId,drawingId:w.drawingId,anchorType:T}));n.executeCommand(ae.id,{unitId:_[0].unitId,drawings:M})}const D=T=>T?"block":"none";return $.jsxs("div",{className:he(q.imageCommonPanelGrid,q.imageCommonPanelBorder),style:{display:D(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")})]})})})]})},Dt=()=>{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})]})},Mt={[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:Me.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(Le,Dt))}_initMenus(){this._menuManagerService.mergeMenu(Mt)}_initCommands(){[pe,oe,ie,ae,Ce,G,ye,Re,be,re,Me,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,Lt=(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:D=0,height:C=0}=S,{drawingStartX:T,drawingEndX:_,drawingStartY:M,drawingEndY:w}={drawingStartX:v,drawingEndX:v+D,drawingStartY:y,drawingEndY:y+C};a<=T&&_<=c&&d<=M&&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=[],D=[],C=v.startX-S.startX,T=v.startY-S.startY,_=u-l,M=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+M},from:{...P.from,row:P.from.row+_,column:P.from.column+M}}};if(w){const{undo:W,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}}),D.push({id:h.SetDrawingApplyMutation.id,params:{unitId:o,subUnitId:a,type:h.DrawingApplyType.UPDATE,op:W,objects:J}})}else{const{undo:W,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}}),D.push({id:h.SetDrawingApplyMutation.id,params:{op:W,unitId:o,subUnitId:a,objects:J,type:h.DrawingApplyType.REMOVE}})}}),{redos:y,undos:D}}};ve=Lt([Oe(0,j.ISheetClipboardService),Oe(1,N.IRenderManagerService),Oe(2,h.ISheetDrawingService)],ve);var Wt=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&&Wt(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(B.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(B.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(B.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(B.map(u=>u.every(m=>m.value)));l==null||l.pipe(B.filter(u=>u!==a),B.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(B.filter(u=>u.value!==a),B.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(B.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(B.map(u=>u.every(m=>m.value)));l==null||l.pipe(B.filter(u=>u!==a),B.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(B.filter(u=>u.value!==a),B.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.getCellPositionByOffset(m.transform.left,m.transform.top,g,l,{x:0,y:0}),S=a.skeleton.getCellPositionByOffset(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:D,startColumn:C,endColumn:T}=i;let _=null,M=null;if(n===0&&m>=y&&S<=D)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,M=w==null?void 0:w.newTransform}else if(n===1&&f>=C&&v<=T)if(m>=y&&S<=D)t.push({unitId:d,subUnitId:g,drawingId:l});else{const w=this._shrinkRow(o,c,y,D,a);_=w==null?void 0:w.newSheetTransform,M=w==null?void 0:w.newTransform}else if(n===2){const w=this._expandRow(o,c,y,D,a);_=w==null?void 0:w.newSheetTransform,M=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,M=w==null?void 0:w.newTransform}if(_!=null&&M!=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:D}=S,{row:C,column:T}=v;for(let _=0;_<r.length;_++){const M=r[_],{startRow:w,endRow:A,startColumn:E,endColumn:L}=M;if(T<E)continue;if(f===h.SheetDrawingAnchorType.Position){let R=null,W=null;if(D>=E&&D<=L){const V=this._skeletonManagerService.attachRangeWithCoord({startColumn:D,endColumn:L,startRow:S.row,endRow:v.row});if(V==null)return;W={...m,left:V.startX}}if(W!=null&&(R=k(W,this._selectionRenderService),R!=null&&W!=null)){t.push({...s,sheetTransform:R,transform:W});break}this._remainDrawingSize(m,t,s);continue}if(D>=E&&T<=L)continue;let U=null,P=null;if(D>=E&&D<=L){const R=this._skeletonManagerService.attachRangeWithCoord({startColumn:D,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:D}=S,{row:C,column:T}=v;for(let _=0;_<r.length;_++){const M=r[_],{startRow:w,endRow:A,startColumn:E,endColumn:L}=M;if(C<w)continue;if(f===h.SheetDrawingAnchorType.Position){let R=null,W=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;W={...m,top:V.startY}}if(W!=null&&(R=k(W,this._selectionRenderService),R!=null&&W!=null)){t.push({...s,sheetTransform:R,transform:W});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 D=r[y],{startRow:C,endRow:T,startColumn:_,endColumn:M}=D;if(S<C||v<_)continue;if(l===h.SheetDrawingAnchorType.Position&&(m<=C&&S>=T||f<=_&&v>=M)){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 M=u[_];if(M.anchorType!==h.SheetDrawingAnchorType.Both)return;const{transform:w}=M;if(!w)return;const{left:A=0,top:E=0,width:L=0,height:U=0}=w,{drawingStartX:P,drawingEndX:R,drawingStartY:W,drawingEndY:V}={drawingStartX:A,drawingEndX:A+L,drawingStartY:E,drawingEndY:E+U};d<=P&&R<=g&&l<=W&&V<=s&&m.push(M)});const f=[],S=[],v=n.startRow-r.startRow,y=n.startColumn-r.startColumn,D=m.map(_=>{const M=_.sheetTransform,w={to:{...M.to,row:M.to.row+v,column:M.to.column+y},from:{...M.from,row:M.from.row+v,column:M.from.column+y}},A=Y(w,this._selectionRenderService,this._skeletonManagerService);return{unitId:t,subUnitId:o,drawingId:_.drawingId,transform:A,sheetTransform:w}});if(D.length){const _=this._sheetDrawingService.getBatchUpdateOp(D),{undo:M,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:M,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 D,C;if(n==="insert"){const _=this._expandRow(S,v,a,c,y);D=_==null?void 0:_.newSheetTransform,C=_==null?void 0:_.newTransform}else{const{from:_,to:M}=S,{row:w}=_,{row:A}=M;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);D=E==null?void 0:E.newSheetTransform,C=E==null?void 0:E.newTransform}}if(!D||!C)return;const T={unitId:e,subUnitId:t,drawingId:m,transform:C,sheetTransform:D};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 D,C;if(n==="insert"){const _=this._expandCol(S,v,a,c,y);D=_==null?void 0:_.newSheetTransform,C=_==null?void 0:_.newTransform}else{const{from:_,to:M}=S,{column:w}=_,{column:A}=M;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);D=E==null?void 0:E.newSheetTransform,C=E==null?void 0:E.newTransform}}if(!D||!C)return;const T={unitId:e,subUnitId:t,drawingId:m,transform:C,sheetTransform:D};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:D,endRow:C,startColumn:T,endColumn:_}=y;if(p.Rectangle.intersects({startRow:D,endRow:C,startColumn:T,endColumn:_},{startRow:u,endRow:f,startColumn:m,endColumn:S})||u>C||m>_){const M=g===h.SheetDrawingAnchorType.Position,w=Y(c,this._selectionRenderService,this._skeletonManagerService);t.push({...a,transform:{...w,width:M?d==null?void 0:d.width:w==null?void 0:w.width,height:M?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),D=r.getNoMergeCellPositionByIndexWithNoHeader(f,m),{rowHeaderWidth:C,columnHeaderHeight:T}=r,_=D.startX-y.startX,M=D.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,W;return l<w?(c.top=!0,R=(M+T+(l-w))*o,W=Math.max(Math.min((M+T+(g-w))*o,(M+T)*o),(s-L)*o)):(c.top=!1,R=Math.max((l-L)*o,(M+T)*o),W=Math.max((s-L)*o,(M+T)*o)),{left:U,right:P,top:R,bottom:W,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 B.Subject);X(this,"transformChange$",this._transformChange$.asObservable());X(this,"_add$",new B.Subject);X(this,"add$",this._add$.asObservable());X(this,"_remove$",new B.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(B.filter(r=>r===p.LifecycleStages.Rendered),B.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:D,top:C,width:T,height:_,angle:M,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:D,top:C,width:T,height:_,angle:M,flipX:w,flipY:A,skewX:E,skewY:L});return}const R={left:D,top:C,width:T,height:_,zIndex:this._drawingManagerService.getDrawingOrder(t,o).length-1},W=m===b.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 V=new N.Rect(U,R);W&&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 B.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(B.filter(e=>!!e),B.map(e=>{const t=this._renderManagerService.getRenderById(e.getUnitId());return t?{render:t,unitId:e.getUnitId(),subUnitId:e.getActiveSheet().getSheetId()}:null}),B.filter(e=>!!e),B.switchMap(e=>p.fromEventSubject(e.render.scene.getViewport(j.VIEWPORT_KEY.VIEW_MAIN).onScrollAfter$).pipe(B.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.getSelectionCellByPosition(t,a);if(g==null)return;const l={column:g.actualColumn,columnOffset:t-g.startX,row:g.actualRow,rowOffset:a-g.startY},s=d.getSelectionCellByPosition(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],[De]].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=Me,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"})});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(function(e,i){typeof exports=="object"&&typeof module<"u"?module.exports=i():typeof define=="function"&&define.amd?define(i):(e=typeof globalThis<"u"?globalThis:e||self,e.UniverSheetsDrawingUiEnUS=i())})(this,function(){"use strict";return{sheetImage:{title:"Image",upload:{float:"Float Image",cell:"Cell Image"},panel:{title:"Edit Image"}},"image-popup":{replace:"Replace",delete:"Delete",edit:"Edit",crop:"Crop",reset:"Reset Size"},"drawing-anchor":{title:"Anchor Properties",both:"Move and size with cells",position:"Move but don't size with cells",none:"Don't move or size with cells"},"update-status":{exceedMaxSize:"Image size exceeds limit, limit is {0}M",invalidImageType:"Invalid image type",exceedMaxCount:"Only {0} images can be uploaded at a time",invalidImage:"Invalid image"},"sheet-drawing-view":"Drawing",shortcut:{sheet:{"drawing-move-down":"Move Drawing down","drawing-move-up":"Move Drawing up","drawing-move-left":"Move Drawing left","drawing-move-right":"Move Drawing right","drawing-delete":"Delete Drawing"}}}});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(function(e,t){typeof exports=="object"&&typeof module<"u"?module.exports=t():typeof define=="function"&&define.amd?define(t):(e=typeof globalThis<"u"?globalThis:e||self,e.UniverSheetsDrawingUiFaIR=t())})(this,function(){"use strict";return{sheetImage:{title:"تصویر",upload:{float:"شناور کردن تصویر",cell:"تصویر سلولی"},panel:{title:"ویرایش تصویر"}},"image-popup":{replace:"تعویض",delete:"حذف",edit:"ویرایش",crop:"کراپ",reset:"بازنشانی اندازه"},"drawing-anchor":{title:"خواص لنگر",both:"جابهجایی و تغییر اندازه با سلولها",position:"جابهجایی اما تغییر اندازه نکردن با سلولها",none:"جابهجایی یا تغییر اندازه نکردن با سلولها"},"update-status":{exceedMaxSize:"اندازه تصویر از حد مجاز فراتر رفته است، حد مجاز {0}M است",invalidImageType:"نوع تصویر نامعتبر است",exceedMaxCount:"فقط {0} تصویر میتوانند همزمان آپلود شوند",invalidImage:"تصویر نامعتبر است"},"sheet-drawing-view":"طراحی",shortcut:{sheet:{"drawing-move-down":"جابهجایی طراحی به پایین","drawing-move-up":"جابهجایی طراحی به بالا","drawing-move-left":"جابهجایی طراحی به چپ","drawing-move-right":"جابهجایی طراحی به راست","drawing-delete":"حذف طراحی"}}}});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(function(e,i){typeof exports=="object"&&typeof module<"u"?module.exports=i():typeof define=="function"&&define.amd?define(i):(e=typeof globalThis<"u"?globalThis:e||self,e.UniverSheetsDrawingUiRuRU=i())})(this,function(){"use strict";return{sheetImage:{title:"Изображение",upload:{float:"Плавающее изображение",cell:"Изображение в ячейке"},panel:{title:"Редактировать изображение"}},"image-popup":{replace:"Заменить",delete:"Удалить",edit:"Редактировать",crop:"Обрезать",reset:"Сбросить размер"},"drawing-anchor":{title:"Свойства привязки",both:"Перемещать и изменять размер с ячейками",position:"Перемещать, но не изменять размер с ячейками",none:"Не перемещать и не изменять размер с ячейками"},"update-status":{exceedMaxSize:"Размер изображения превышает лимит, лимит составляет {0}М",invalidImageType:"Недопустимый тип изображения",exceedMaxCount:"За один раз можно загрузить только {0} изображений",invalidImage:"Недопустимое изображение"},"sheet-drawing-view":"Drawing",shortcut:{sheet:{"drawing-move-down":"Move Drawing down","drawing-move-up":"Move Drawing up","drawing-move-left":"Move Drawing left","drawing-move-right":"Move Drawing right","drawing-delete":"Delete Drawing"}}}});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(function(e,n){typeof exports=="object"&&typeof module<"u"?module.exports=n():typeof define=="function"&&define.amd?define(n):(e=typeof globalThis<"u"?globalThis:e||self,e.UniverSheetsDrawingUiViVN=n())})(this,function(){"use strict";return{sheetImage:{title:"Hình ảnh",upload:{float:"Hình ảnh nổi",cell:"Hình ảnh trong ô"},panel:{title:"Chỉnh sửa hình ảnh"}},"image-popup":{replace:"Thay thế",delete:"Xóa",edit:"Chỉnh sửa",crop:"Cắt",reset:"Đặt lại kích thước"},"drawing-anchor":{title:"Thuộc tính neo",both:"Di chuyển và thay đổi kích thước cùng với ô",position:"Di chuyển nhưng không thay đổi kích thước với ô",none:"Không di chuyển hoặc thay đổi kích thước với ô"},"update-status":{exceedMaxSize:"Kích thước hình ảnh vượt quá giới hạn, giới hạn là {0}M",invalidImageType:"Loại hình ảnh không hợp lệ",exceedMaxCount:"Chỉ có thể tải lên {0} hình ảnh một lần",invalidImage:"Hình ảnh không hợp lệ"},"sheet-drawing-view":"Drawing",shortcut:{sheet:{"drawing-move-down":"Move Drawing down","drawing-move-up":"Move Drawing up","drawing-move-left":"Move Drawing left","drawing-move-right":"Move Drawing right","drawing-delete":"Delete Drawing"}}}});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(function(e,t){typeof exports=="object"&&typeof module<"u"?module.exports=t():typeof define=="function"&&define.amd?define(t):(e=typeof globalThis<"u"?globalThis:e||self,e.UniverSheetsDrawingUiZhCN=t())})(this,function(){"use strict";return{sheetImage:{title:"图片",upload:{float:"浮动图片",cell:"单元格图片"},panel:{title:"编辑图片"}},"image-popup":{replace:"替换",delete:"删除",edit:"编辑",crop:"裁剪",reset:"重置大小"},"drawing-anchor":{title:"锚点属性",both:"与单元格一起移动和调整大小",position:"移动但不调整大小与单元格",none:"不要移动或调整大小与单元格"},"update-status":{exceedMaxSize:"图片大小超过限制, 限制为{0}M",invalidImageType:"图片类型错误",exceedMaxCount:"图片只能一次上传{0}张",invalidImage:"无效图片"},"sheet-drawing-view":"绘图",shortcut:{sheet:{"drawing-move-down":"下移绘图","drawing-move-up":"上移绘图","drawing-move-left":"左移绘图","drawing-move-right":"下移绘图","drawing-delete":"删除绘图"}}}});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(function(e,t){typeof exports=="object"&&typeof module<"u"?module.exports=t():typeof define=="function"&&define.amd?define(t):(e=typeof globalThis<"u"?globalThis:e||self,e.UniverSheetsDrawingUiZhTW=t())})(this,function(){"use strict";return{sheetImage:{title:"圖片",upload:{float:"浮動圖片",cell:"儲存格圖片"},panel:{title:"編圖"}},"image-popup":{replace:"替換",delete:"刪除",edit:"編輯",crop:"裁切",reset:"重置大小"},"drawing-anchor":{title:"錨點屬性",both:"與儲存格一起移動和調整大小",position:"移動但不調整大小與儲存格",none:"不要移動或調整大小與單元格"},"update-status":{exceedMaxSize:"圖片大小超過限制, 限制為{0}M",invalidImageType:"圖片類型錯誤",exceedMaxCount:"圖片只能一次上傳{0}張",invalidImage:"無效圖片"},"sheet-drawing-view":"繪圖",shortcut:{sheet:{"drawing-move-down":"下移繪圖","drawing-move-up":"上移繪圖","drawing-move-left":"左移繪圖","drawing-move-right":"下移繪圖","drawing-delete":"刪除繪圖"}}}});
|