@univerjs/drawing-ui 1.0.1 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/index.js +1 -1
- package/lib/es/index.js +1 -1
- package/lib/index.js +1 -1
- package/lib/umd/index.js +1 -1
- package/package.json +8 -8
package/lib/cjs/index.js
CHANGED
|
@@ -651,7 +651,7 @@ const menuSchema = { [_univerjs_ui.ContextMenuPosition.DRAWING]: { [_univerjs_ui
|
|
|
651
651
|
//#endregion
|
|
652
652
|
//#region package.json
|
|
653
653
|
var name = "@univerjs/drawing-ui";
|
|
654
|
-
var version = "1.0.
|
|
654
|
+
var version = "1.0.3";
|
|
655
655
|
|
|
656
656
|
//#endregion
|
|
657
657
|
//#region src/config/config.ts
|
package/lib/es/index.js
CHANGED
|
@@ -650,7 +650,7 @@ const menuSchema = { [ContextMenuPosition.DRAWING]: { [ContextMenuGroup.OTHERS]:
|
|
|
650
650
|
//#endregion
|
|
651
651
|
//#region package.json
|
|
652
652
|
var name = "@univerjs/drawing-ui";
|
|
653
|
-
var version = "1.0.
|
|
653
|
+
var version = "1.0.3";
|
|
654
654
|
|
|
655
655
|
//#endregion
|
|
656
656
|
//#region src/config/config.ts
|
package/lib/index.js
CHANGED
|
@@ -650,7 +650,7 @@ const menuSchema = { [ContextMenuPosition.DRAWING]: { [ContextMenuGroup.OTHERS]:
|
|
|
650
650
|
//#endregion
|
|
651
651
|
//#region package.json
|
|
652
652
|
var name = "@univerjs/drawing-ui";
|
|
653
|
-
var version = "1.0.
|
|
653
|
+
var version = "1.0.3";
|
|
654
654
|
|
|
655
655
|
//#endregion
|
|
656
656
|
//#region src/config/config.ts
|
package/lib/umd/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("@univerjs/core"),require("@univerjs/drawing"),require("@univerjs/engine-render"),require("@univerjs/ui"),require("rxjs"),require("react"),require("@univerjs/design"),require("react/jsx-runtime")):typeof define==`function`&&define.amd?define([`exports`,`@univerjs/core`,`@univerjs/drawing`,`@univerjs/engine-render`,`@univerjs/ui`,`rxjs`,`react`,`@univerjs/design`,`react/jsx-runtime`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.UniverDrawingUi={},e.UniverCore,e.UniverDrawing,e.UniverEngineRender,e.UniverUi,e.rxjs,e.React,e.UniverDesign,e.React))})(this,function(e,t,n,r,i,a,o,s,c){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});let l=function(e){return e.default=`0`,e.left=`1`,e.center=`2`,e.right=`3`,e.top=`4`,e.middle=`5`,e.bottom=`6`,e.horizon=`7`,e.vertical=`8`,e}({}),u={id:`sheet.operation.set-image-align`,type:t.CommandType.OPERATION,handler:(e,t)=>!0},d={id:`sheet.operation.set-drawing-align-left`,type:t.CommandType.OPERATION,handler:e=>e.get(t.ICommandService).syncExecuteCommand(u.id,{alignType:`1`})},f={id:`sheet.operation.set-drawing-align-center`,type:t.CommandType.OPERATION,handler:e=>e.get(t.ICommandService).syncExecuteCommand(u.id,{alignType:`2`})},p={id:`sheet.operation.set-drawing-align-right`,type:t.CommandType.OPERATION,handler:e=>e.get(t.ICommandService).syncExecuteCommand(u.id,{alignType:`3`})},m={id:`sheet.operation.set-drawing-align-top`,type:t.CommandType.OPERATION,handler:e=>e.get(t.ICommandService).syncExecuteCommand(u.id,{alignType:`4`})},h={id:`sheet.operation.set-drawing-align-middle`,type:t.CommandType.OPERATION,handler:e=>e.get(t.ICommandService).syncExecuteCommand(u.id,{alignType:`5`})},g={id:`sheet.operation.set-drawing-align-bottom`,type:t.CommandType.OPERATION,handler:e=>e.get(t.ICommandService).syncExecuteCommand(u.id,{alignType:`6`})},_={id:`sheet.operation.set-drawing-align-horizon`,type:t.CommandType.OPERATION,handler:e=>e.get(t.ICommandService).syncExecuteCommand(u.id,{alignType:`7`})},v={id:`sheet.operation.set-drawing-align-vertical`,type:t.CommandType.OPERATION,handler:e=>e.get(t.ICommandService).syncExecuteCommand(u.id,{alignType:`8`})},y={id:`drawing.operation.set-drawing-arrange`,type:t.CommandType.OPERATION,handler:(e,t)=>{let r=e.get(n.IDrawingManagerService),{arrangeType:i}=t,a=t.drawings||r.getFocusDrawings(),{unitId:o,subUnitId:s}=a[0],c=a.map(e=>e.drawingId);return r.featurePluginOrderUpdateNotification({unitId:o,subUnitId:s,drawingIds:c,arrangeType:i}),!0}},b={id:`drawing.operation.set-drawing-arrange-front`,type:t.CommandType.OPERATION,handler:e=>e.get(t.ICommandService).syncExecuteCommand(y.id,{arrangeType:t.ArrangeTypeEnum.front})},x={id:`drawing.operation.set-drawing-arrange-forward`,type:t.CommandType.OPERATION,handler:e=>e.get(t.ICommandService).syncExecuteCommand(y.id,{arrangeType:t.ArrangeTypeEnum.forward})},S={id:`drawing.operation.set-drawing-arrange-back`,type:t.CommandType.OPERATION,handler:e=>e.get(t.ICommandService).syncExecuteCommand(y.id,{arrangeType:t.ArrangeTypeEnum.back})},C={id:`drawing.operation.set-drawing-arrange-backward`,type:t.CommandType.OPERATION,handler:e=>e.get(t.ICommandService).syncExecuteCommand(y.id,{arrangeType:t.ArrangeTypeEnum.backward})},w=n.DRAWING_GROUPABLE_TYPES,T={id:`drawing.operation.set-drawing-group`,type:t.CommandType.OPERATION,handler:(e,i)=>{let a=e.get(n.IDrawingManagerService),o=i.drawings||a.getFocusDrawings();if(o.length<2||!o.every(e=>(0,n.isGroupableDrawingType)(e.drawingType)))return!1;let{unitId:s,subUnitId:c}=o[0],l=(0,t.generateRandomId)(10),u=(0,r.getGroupState)(0,0,o.map(e=>e.transform||{})),d={unitId:s,subUnitId:c,drawingId:l,drawingType:t.DrawingTypeEnum.DRAWING_GROUP,transform:u,groupBaseBound:{left:u.left,top:u.top,width:u.width,height:u.height}},f=o.map(e=>{let t=e.transform||{left:0,top:0},{unitId:n,subUnitId:r,drawingId:i,drawingType:a}=e;return{unitId:n,subUnitId:r,drawingId:i,drawingType:a,transform:{...t},groupId:l}});return a.featurePluginGroupUpdateNotification([{parent:d,children:f}]),!0}},E={id:`drawing.operation.cancel-drawing-group`,type:t.CommandType.OPERATION,handler:(e,i)=>{let a=e.get(n.IDrawingManagerService),o=(i.drawings||a.getFocusDrawings()).map(e=>{if(e.drawingType!==t.DrawingTypeEnum.DRAWING_GROUP)return null;let{unitId:n,subUnitId:i,drawingId:o,transform:s={width:0,height:0},groupBaseBound:c}=e;if(s===null)return null;let l=a.getDrawingsByGroup({unitId:n,subUnitId:i,drawingId:o});return l.length===0?null:{parent:e,children:l.map(e=>{let{transform:t}=e,{unitId:n,subUnitId:i,drawingId:a}=e,o=(0,r.transformObjectOutOfGroup)(t||{},s,s.width||0,s.height||0,c);return{unitId:n,subUnitId:i,drawingId:a,transform:{...t,...o},groupId:void 0}})}}).filter(e=>e!==null);return o.length!==0&&(a.featurePluginUngroupUpdateNotification(o),!0)}},D={id:`sheet.operation.open-image-crop`,type:t.CommandType.OPERATION,handler:(e,t)=>!0},O={id:`sheet.operation.close-image-crop`,type:t.CommandType.OPERATION,handler:(e,t)=>!0},k={id:`sheet.operation.Auto-image-crop`,type:t.CommandType.OPERATION,handler:(e,t)=>!0},A={id:`sheet.operation.image-reset-size`,type:t.CommandType.OPERATION,handler:(e,t)=>!0};function j(e){return e===t.DrawingTypeEnum.DRAWING_CHART}function M(e,t={}){return(0,n.resolveDrawingRotateEnabled)(e,{...t,isKnownNonRotatableType:t.isKnownNonRotatableType??j})}function N(e,t){let r=(0,n.getDrawingShapeKeyByDrawingSearch)(t);return e.getObjectIncludeInGroup(r)??null}function P(e,r){if(r.isMultiTransform===t.BooleanNumber.TRUE){let t=(0,n.getDrawingShapeKeyByDrawingSearch)(r),i=`${t}#-#`,a=e.getAllObjects().filter(e=>e.oKey===t||e.oKey.startsWith(i));return a.forEach(e=>e.dispose()),a.length>0}let i=N(e,r);return i!=null&&(i.dispose(),!0)}function F(e,t){return N(e,t)}function I(e,t,n,r,i){let a=M(t,{getChildren:e=>i&&e.drawingId===t.drawingId&&e.unitId===t.unitId&&e.subUnitId===t.subUnitId?i:r.getDrawingsByGroup(e),getRenderObject:e=>F(n,e)});e.transformerConfig={...e.transformerConfig,rotateEnabled:a}}function L(e,t,i,a,o,s=!0){var c,l;let u=a.getDrawingByParam(e);if(u==null)return;let d=(0,n.getDrawingShapeKeyByDrawingSearch)(e,o),f=i.getObjectIncludeInGroup(d);if(f&&!(f instanceof r.Group))return;if(f!=null){let e=f.getObjects();for(let n of e)if(n.oKey===t.oKey)return;f.addObject(t),I(f,u,i,a);return}let p=new r.DrawingGroupObject(d),m=a.getDrawingOrder(e.unitId,e.subUnitId);p.zIndex=Math.max(0,m.indexOf(e.drawingId));let h=i.addObject(p,((c=t.layer)==null?void 0:c.zIndex)??r.DRAWING_OBJECT_LAYER_INDEX);s&&h.attachTransformerTo(p),p.addObject(t),I(p,u,i,a);let{groupBaseBound:g}=u,_=o==null?u.transform:(l=u.transforms)==null?void 0:l[o];g&&p.setBaseBound(g),u.groupId&&(p.isInGroup=!0,L({drawingId:u.groupId,unitId:e.unitId,subUnitId:e.subUnitId},p,i,a,o,s)),_&&p.transformByState({left:_.left,top:_.top,angle:_.angle,width:_.width,height:_.height,flipX:_.flipX,flipY:_.flipY})}function R(e,n){let r=n?e.getUnit(n):e.getFocusedUnit();if(r==null)return;let i=r.getUnitId(),a;if(r.type===t.UniverInstanceType.UNIVER_SHEET){var o;a=(o=r.getActiveSheet())==null?void 0:o.getSheetId()}else(r.type===t.UniverInstanceType.UNIVER_DOC||r.type===t.UniverInstanceType.UNIVER_SLIDE)&&(a=i);return{unitId:i,subUnitId:a,current:r}}let z=e=>{let t=e.get(n.IDrawingManagerService);return new a.Observable(e=>{let n=t=>{if(!t||t.length===0||t.length<2)return e.next(!0);e.next(!1)},r=t.focus$.subscribe(t=>{if(!t||t.length===0)return e.next(!0);n(t)});return n(t.getFocusDrawings()),()=>r.unsubscribe()})},B=`contextMenu.drawing-align`;function V(e){return{id:B,type:i.MenuItemType.SUBITEMS,icon:`HorizontallyIcon`,title:`drawing-ui.image-panel.align.title`,hidden$:z(e)}}function H(){return{id:d.id,type:i.MenuItemType.BUTTON,icon:`LeftJustifyingIcon`,title:`drawing-ui.image-panel.align.left`}}function ee(){return{id:f.id,type:i.MenuItemType.BUTTON,icon:`HorizontallyIcon`,title:`drawing-ui.image-panel.align.center`}}function te(){return{id:p.id,type:i.MenuItemType.BUTTON,icon:`RightJustifyingIcon`,title:`drawing-ui.image-panel.align.right`}}function ne(){return{id:m.id,type:i.MenuItemType.BUTTON,icon:`AlignTopIcon`,title:`drawing-ui.image-panel.align.top`}}function re(){return{id:h.id,type:i.MenuItemType.BUTTON,icon:`VerticalCenterIcon`,title:`drawing-ui.image-panel.align.middle`}}function ie(){return{id:g.id,type:i.MenuItemType.BUTTON,icon:`AlignBottomIcon`,title:`drawing-ui.image-panel.align.bottom`}}function ae(){return{id:_.id,type:i.MenuItemType.BUTTON,icon:`HorizontallyIcon`,title:`drawing-ui.image-panel.align.horizon`}}function oe(){return{id:v.id,type:i.MenuItemType.BUTTON,icon:`VerticalCenterIcon`,title:`drawing-ui.image-panel.align.vertical`}}let se=`contextMenu.drawing-arrange`;function ce(e){let t=e.get(n.IDrawingManagerService);return{id:se,type:i.MenuItemType.SUBITEMS,icon:`TopmostIcon`,title:`drawing-ui.image-panel.arrange.title`,hidden$:t.focus$.pipe((0,a.startWith)(t.getFocusDrawings()),(0,a.map)(e=>e.length===0))}}function le(){return{id:b.id,type:i.MenuItemType.BUTTON,icon:`TopmostIcon`,title:`drawing-ui.image-panel.arrange.front`}}function ue(){return{id:x.id,type:i.MenuItemType.BUTTON,icon:`MoveUpIcon`,title:`drawing-ui.image-panel.arrange.forward`}}function de(){return{id:S.id,type:i.MenuItemType.BUTTON,icon:`BottomIcon`,title:`drawing-ui.image-panel.arrange.back`}}function fe(){return{id:C.id,type:i.MenuItemType.BUTTON,icon:`MoveDownIcon`,title:`drawing-ui.image-panel.arrange.backward`}}function pe(e,r){let i=e.get(n.IDrawingManagerService);return new a.Observable(e=>{let a=i=>{if(!i||i.length===0)return e.next(!0);if(r===`group`){if(i.length<2||!i.every(e=>(0,n.isGroupableDrawingType)(e.drawingType)))return e.next(!0)}else if(r===`unGroup`){if(i.filter(e=>e.drawingType===t.DrawingTypeEnum.DRAWING_GROUP).length===0)return e.next(!0)}else if(!i.every(e=>(0,n.isGroupableDrawingType)(e.drawingType)))return e.next(!0);e.next(!1)},o=i.focus$.subscribe(t=>{if(!t||t.length===0)return e.next(!0);a(t)});return a(i.getFocusDrawings()),()=>o.unsubscribe()})}let me=`contextMenu.drawing-group`;function he(e){return{id:me,type:i.MenuItemType.SUBITEMS,icon:`GroupIcon`,title:`drawing-ui.image-panel.group.title`,hidden$:pe(e)}}function ge(e){return{id:T.id,type:i.MenuItemType.BUTTON,icon:`GroupIcon`,title:`drawing-ui.image-panel.group.group`,disabled$:pe(e,`group`)}}function _e(e){return{id:E.id,type:i.MenuItemType.BUTTON,icon:`UngroupIcon`,title:`drawing-ui.image-panel.group.unGroup`,disabled$:pe(e,`unGroup`)}}let ve={[i.ContextMenuPosition.DRAWING]:{[i.ContextMenuGroup.OTHERS]:{[me]:{order:1,menuItemFactory:he,[T.id]:{order:0,menuItemFactory:ge},[E.id]:{order:1,menuItemFactory:_e}},[se]:{order:2,menuItemFactory:ce,[b.id]:{order:0,menuItemFactory:le},[x.id]:{order:1,menuItemFactory:ue},[S.id]:{order:2,menuItemFactory:de},[C.id]:{order:3,menuItemFactory:fe}},[B]:{order:3,menuItemFactory:V,[d.id]:{order:0,menuItemFactory:H},[f.id]:{order:1,menuItemFactory:ee},[p.id]:{order:2,menuItemFactory:te},[m.id]:{order:3,menuItemFactory:ne},[h.id]:{order:4,menuItemFactory:re},[g.id]:{order:5,menuItemFactory:ie},[_.id]:{order:6,menuItemFactory:ae},[v.id]:{order:7,menuItemFactory:oe}}}}};var ye=`@univerjs/drawing-ui`,be=`1.0.1`;let xe=`drawing-ui.config`,Se={};function Ce(e){"@babel/helpers - typeof";return Ce=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},Ce(e)}function we(e,t){if(Ce(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(Ce(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function Te(e){var t=we(e,`string`);return Ce(t)==`symbol`?t:t+``}function U(e,t,n){return(t=Te(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}let Ee=`sheet.image-clip.shape.picker.component`;var De=class extends t.Disposable{constructor(){super(),U(this,`_clipDelegate`,null),U(this,`_canUseShapeClip$`,new a.BehaviorSubject(!1)),U(this,`canUseShapeClip$`,this._canUseShapeClip$.asObservable())}setCanUseShapeClip(e){this._canUseShapeClip$.next(e)}registerClipDelegate(e){return this._clipDelegate=e,(0,t.toDisposable)(()=>{this._clipDelegate===e&&(this._clipDelegate=null)})}applyShapeClip(e,t,n,r,i){return this._clipDelegate?this._clipDelegate(e,t,n,r,i):!1}dispose(){this._clipDelegate=null,this._canUseShapeClip$.complete(),super.dispose()}};function W(e,t){return function(n,r){t(n,r,e)}}function G(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}function Oe(e){return e.behindText===!0||e.behindText===t.BooleanNumber.TRUE||e.layoutType===t.PositionedObjectLayoutType.WRAP_NONE&&e.behindDoc===t.BooleanNumber.TRUE?1:r.DRAWING_OBJECT_LAYER_INDEX}function ke(e,t,n){let r=Oe(n);t.layer!=null&&t.layer.zIndex!==r&&(e.removeObject(t),e.addObject(t,r))}function Ae(e){return(e==null?void 0:e.complete)===!0&&e.naturalWidth>0&&e.naturalHeight>0}let K=class{constructor(e,t,n,r,i,a){this._drawingManagerService=e,this._imageIoService=t,this._galleryService=n,this._urlImageService=r,this._univerInstanceService=i,this._drawingImageClipService=a}async renderImages(e,i,a){let{transform:o,drawingType:s,source:c,imageSourceType:l,srcRect:u,prstGeom:d,groupId:f,unitId:p,subUnitId:m,drawingId:h,isMultiTransform:g,transforms:_,adjustValues:v,hidden:y}=e,{docxHeaderFooterDrawing:b,layoutType:x}=e;if(s!==t.DrawingTypeEnum.DRAWING_IMAGE||!this._drawingManagerService.getDrawingVisible()||!(a!=null&&a.allowInactiveSheet)&&this._univerInstanceService.getUnitType(p)===t.UniverInstanceType.UNIVER_SHEET&&m!==this._getActiveSheetId()||o==null)return;let S=g&&_?_:[o],C=[];for(let a of S){let{left:o,top:s,width:_,height:T,angle:E,flipX:D,flipY:O,skewX:k,skewY:A}=a,j=S.indexOf(a),M=(0,n.getDrawingShapeKeyByDrawingSearch)({unitId:p,subUnitId:m,drawingId:h},g?j:void 0),N=i.getObject(M);if(N!=null){var w;N.transformByState({left:o,top:s,width:_,height:T,angle:E,flipX:D,flipY:O,skewX:k,skewY:A}),(w=N.setClipBounds)==null||w.call(N,a.clipBounds),`hidden`in e&&(y?N.hide():N.show()),ke(i,N,e);continue}let P=this._drawingManagerService.getDrawingOrder(p,m),F=P.indexOf(h),I={...a,zIndex:F===-1?P.length-1:F},R=this._imageIoService.getImageSourceCache(c,l),z=!1;if(Ae(R))I.image=R;else if(l===t.ImageSourceType.UUID)try{I.url=await this._imageIoService.getImage(c)}catch(e){console.error(e);continue}else if(l===t.ImageSourceType.URL){try{I.url=await this._urlImageService.getImage(c)}catch(e){console.error(e),I.url=c}z=!0}else I.url=c,z=!0;let B=b===!0&&x===t.PositionedObjectLayoutType.INLINE;if((y||B)&&(I.visible=!1),i.getObject(M))continue;I.printable=!0;let V=new r.Image(M,I);V.setClipService(this._drawingImageClipService),z&&this._imageIoService.addImageSourceCache(c,l,V.getNative()),i.addObject(V,Oe(e)),this._drawingManagerService.getDrawingEditable()&&i.attachTransformerTo(V),f&&L({drawingId:f,unitId:p,subUnitId:m},V,i,this._drawingManagerService,g?j:void 0),d!=null&&V.setPrstGeom(d),v!=null&&V.setPrstGeomAdjValues(v),u!=null&&V.setSrcRect(u),C.push(V)}return C}_getActiveSheetId(){var e;return(e=this._univerInstanceService.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_SHEET))==null||(e=e.getActiveSheet())==null?void 0:e.getSheetId()}renderFloatDom(e,i){let{transform:a,drawingType:o,groupId:s,unitId:c,subUnitId:l,drawingId:u,isMultiTransform:d,transforms:f}=e;if(o!==t.DrawingTypeEnum.DRAWING_DOM||!this._drawingManagerService.getDrawingVisible()||a==null)return;let p=d&&f?f:[a],m=[];for(let t of p){let{left:a,top:o,width:f,height:h,angle:g,flipX:_,flipY:v,skewX:y,skewY:b}=t,x=p.indexOf(t),S=(0,n.getDrawingShapeKeyByDrawingSearch)({unitId:c,subUnitId:l,drawingId:u},d?x:void 0),C=i.getObject(S);if(C!=null){C.transformByState({left:a,top:o,width:f,height:h,angle:g,flipX:_,flipY:v,skewX:y,skewY:b});continue}let w=this._drawingManagerService.getDrawingOrder(c,l),T=w.indexOf(u),E={...t,zIndex:T===-1?w.length-1:T};if(i.getObject(S))continue;E.printable=!1;let D=new r.Rect(S,E);this._drawingManagerService.getDrawingVisible()&&(i.addObject(D,r.DRAWING_OBJECT_LAYER_INDEX),this._drawingManagerService.getDrawingEditable()&&e.allowTransform!==!1&&i.attachTransformerTo(D),s&&L({drawingId:s,unitId:c,subUnitId:l},D,i,this._drawingManagerService),m.push(D))}return m}renderDrawing(e,n,r){let i=this._drawingManagerService.getDrawingByParam(e);if(i!=null)switch(i.drawingType){case t.DrawingTypeEnum.DRAWING_IMAGE:return this.renderImages(i,n,r)}}previewImage(e,t,n,r){this._galleryService.open({images:[t],onOpenChange:e=>{e||this._galleryService.close()}})}_adjustImageSize(e,t,n,r){if(e<=n&&t<=r)return{width:e,height:t};let i=n/e,a=r/t,o=Math.min(i,a);return{width:Math.floor(e*o),height:Math.floor(t*o)}}};K=G([W(0,n.IDrawingManagerService),W(1,t.IImageIoService),W(2,i.IGalleryService),W(3,t.IURLImageService),W(4,t.IUniverInstanceService),W(5,(0,t.Inject)(De))],K);function q(e,n){let r=[];return e.forEach(e=>{let{oKey:i,left:a,top:o,height:s,width:c,angle:l}=e,u=n.getDrawingOKey(i);if(u==null)return r.push(null),!0;let{unitId:d,subUnitId:f,drawingId:p,drawingType:m}=u,h={unitId:d,subUnitId:f,drawingId:p,drawingType:m,transform:{left:a,top:o,height:s,width:c,angle:l}};m===t.DrawingTypeEnum.DRAWING_IMAGE&&(h.srcRect=e.srcRect),r.push(h)}),r}function je(e){return`hidden`in e||`behindText`in e||`selectable`in e}function Me(e,t){`hidden`in t&&(t.hidden===!0?e.hide():e.show())}function Ne(e,t,n,r){var i;let a=r.getOldDrawingByParam(t);if(!(`selectable`in t)&&(!a||!(`selectable`in a)))return;let o=t.selectable!==!1;if(e.evented=o,o)return;(i=n.getTransformer())==null||i.clearControlByIds([e.oKey]);let s=r.getFocusDrawings(),c=s.filter(({unitId:e,subUnitId:n,drawingId:r})=>e!==t.unitId||n!==t.subUnitId||r!==t.drawingId);c.length!==s.length&&r.focusDrawing(c)}function Pe(e,t){return je(t)?{...e,...t}:e}let J=class extends t.Disposable{constructor(e,t,n,r){super(),this._currentUniverService=e,this._commandService=t,this._renderManagerService=n,this._drawingManagerService=r,U(this,`_sceneListenerOnDrawingMap`,new WeakSet),this._initialize()}dispose(){super.dispose()}_initialize(){this._recoveryImages(),this._drawingAddListener(),this._drawingRemoveListener(),this._drawingUpdateListener(),this._commandExecutedListener(),this._drawingArrangeListener(),this._drawingGroupListener(),this._drawingRefreshListener(),this._drawingVisibleListener()}_recoveryImages(){let e=this._drawingManagerService.drawingManagerData,t=R(this._currentUniverService);if(t==null)return;let{unitId:n,subUnitId:r}=t;Object.keys(e).forEach(t=>{Object.keys(e[t]).forEach(i=>{let a=e[t][i].data;a!=null&&t===n&&i===r&&Object.keys(a).forEach(e=>{a[e]&&this._insertDrawing([{unitId:t,subUnitId:i,drawingId:e}])})})})}_commandExecutedListener(){this.disposeWithMe(this._commandService.onCommandExecuted(e=>{if(e.id===u.id){let t=e.params;if(t==null)return;this._drawingAlign(t)}}))}_drawingGroupListener(){this.disposeWithMe(this._drawingManagerService.group$.subscribe(e=>{this._groupDrawings(e)})),this.disposeWithMe(this._drawingManagerService.ungroup$.subscribe(e=>{this._ungroupDrawings(e)}))}_getSceneAndTransformerByDrawingSearch(e){if(e==null)return;let t=this._renderManagerService.getRenderUnitById(e),n=t==null?void 0:t.scene;return n==null?null:{scene:n,transformer:n.getTransformerByCreate()}}_groupDrawings(e){e.forEach(e=>{this._groupDrawing(e)})}_groupDrawing(e){let{parent:t,children:i}=e,{unitId:a,subUnitId:o,drawingId:s}=t,c=this._getSceneAndTransformerByDrawingSearch(t.unitId);if(c==null)return;let{scene:l,transformer:u}=c;this._commandService.syncExecuteCommand(O.id);let d=[];if(i.forEach(e=>{let t=(0,n.getDrawingShapeKeyByDrawingSearch)(e),i=l.getObjectIncludeInGroup(t);if(i==null||d.includes(i))return;d.push(i);let{transform:a}=e;a!=null&&(i.classType===r.RENDER_CLASS_TYPE.GROUP?i.transformByState({left:a.left,top:a.top}):i.transformByState(a))}),d.length===0)return;let f=(0,n.getDrawingShapeKeyByDrawingSearch)({unitId:a,subUnitId:o,drawingId:s}),p=new r.DrawingGroupObject(f);l.addObject(p,r.DRAWING_OBJECT_LAYER_INDEX).attachTransformerTo(p),p.addObjects(...d),I(p,t,l,this._drawingManagerService,i),t.groupBaseBound&&p.setBaseBound(t.groupBaseBound),t.groupId&&(p.isInGroup=!0,L({drawingId:t.groupId,unitId:a,subUnitId:o},p,l,this._drawingManagerService)),t.transform&&p.transformByState({left:t.transform.left,top:t.transform.top,width:t.transform.width,height:t.transform.height,angle:t.transform.angle}),u.clearSelectedObjects(),u.setSelectedControl(p)}_ungroupDrawings(e){e.forEach(e=>{this._ungroupDrawing(e)})}_ungroupDrawing(e){let{parent:t,children:i}=e,a=this._getSceneAndTransformerByDrawingSearch(t.unitId);if(a==null)return;let{scene:o,transformer:s}=a;i.forEach(e=>{let t=(0,n.getDrawingShapeKeyByDrawingSearch)(e),i=o.getObjectIncludeInGroup(t);if(i==null)return!0;if(i==null)return;let{transform:a}=e;a!=null&&(i.classType===r.RENDER_CLASS_TYPE.GROUP?i.transformByState({left:a.left,top:a.top}):i.transformByState(a))});let c=(0,n.getDrawingShapeKeyByDrawingSearch)(t),l=o.getObject(c),{width:u,height:d}=l;l.getObjects().forEach(e=>{l.removeSelfObjectAndTransform(e.oKey,u,d)}),l.dispose(),s.clearSelectedObjects()}_drawingAlign(e){let{alignType:t}=e,n=e.drawings||this._drawingManagerService.getFocusDrawings();if(t===`0`)return;let r=[],i=1/0,a=1/0,o=-1/0,s=-1/0,c=0;n.forEach(e=>{let{unitId:t,subUnitId:n,drawingId:l,drawingType:u}=e,d=this._drawingManagerService.getDrawingByParam({unitId:t,subUnitId:n,drawingId:l});if(d==null||d.transform==null)return;r.push({unitId:t,subUnitId:n,drawingId:l,drawingType:u,transform:d.transform});let{left:f=0,top:p=0,width:m=0,height:h=0}=d.transform;i=Math.min(i,f),a=Math.min(a,p),o=Math.max(o,f+m),s=Math.max(s,p+h),c++}),c!==0&&(this._sortDrawingTransform(r,t),this._applyAlignType(r,t,i,a,o,s,c))}_applyAlignType(e,t,n,r,i,a,o){let s=Math.round((i-n)/o*10)/10,c=Math.round((a-r)/o*10)/10,l=[],u=this._getSceneAndTransformerByDrawingSearch(e[0].unitId);if(u==null)return;let{scene:d,transformer:f}=u;e.forEach((e,o)=>{let{unitId:u,subUnitId:d,drawingId:f,transform:p,drawingType:m}=e,{left:h=0,top:g=0,width:_=0,height:v=0}=p,y=h,b=g;switch(t){case`1`:y=n;break;case`2`:y=n+(i-n)/2-_/2;break;case`3`:y=i-_;break;case`4`:b=r;break;case`5`:b=r+(a-r)/2-v/2;break;case`6`:b=a-v;break;case`7`:y=n+s*o;break;case`8`:b=r+c*o}(y!==h||b!==g)&&l.push({unitId:u,subUnitId:d,drawingId:f,drawingType:m,transform:{left:y,top:b}})}),this._drawingManagerService.featurePluginUpdateNotification(l),f.refreshControls().changeNotification()}_sortDrawingTransform(e,t){e.sort((e,n)=>{let r=e.transform,i=n.transform,{left:a=0,top:o=0,width:s=0,height:c=0}=r,{left:l=0,top:u=0,width:d=0,height:f=0}=i;switch(t){case`1`:return a-l;case`2`:return a+s/2-(l+d/2);case`3`:return a+s-(l+d);case`4`:return o-u;case`5`:return o+c/2-(u+f/2);case`6`:return o+c-(u+f);case`7`:return a+s/2-(l+d/2);case`8`:return o+c/2-(u+f/2);default:return 0}})}_drawingArrangeListener(){this.disposeWithMe(this._drawingManagerService.order$.subscribe(e=>{this._drawingArrange(e)}))}_drawingArrange(e){let{unitId:t,subUnitId:r,drawingIds:i}=e,a=this._getSceneAndTransformerByDrawingSearch(t);if(a==null)return;let{scene:o}=a;i.forEach(e=>{let i=(0,n.getDrawingShapeKeyByDrawingSearch)({unitId:t,subUnitId:r,drawingId:e}),a=o.fuzzyMathObjects(i,!0);if(a==null||a.length===0)return;let s=this._drawingManagerService.getDrawingOrder(t,r).indexOf(e);for(let e of a)e.setProps({zIndex:s}),e.makeDirty()})}_drawingAddListener(){this.disposeWithMe(this._drawingManagerService.add$.subscribe(e=>{this._insertDrawing(e)}))}_insertDrawing(e){let t=[];e.forEach(e=>{let{unitId:n}=e;if(this._drawingManagerService.getDrawingByParam(e)==null)return;let r=this._getSceneAndTransformerByDrawingSearch(n);if(r==null)return;let{scene:i}=r;t.includes(i)||t.push(i)}),t.forEach(e=>{this._sceneListenerOnDrawingMap.has(e)||(this._addListenerOnDrawing(e),this._sceneListenerOnDrawingMap.add(e))})}_drawingRemoveListener(){this.disposeWithMe(this._drawingManagerService.remove$.subscribe(e=>{e.forEach(e=>{let{unitId:t}=e,n=this._getSceneAndTransformerByDrawingSearch(t);if(n==null)return;let{scene:r}=n;if(P(r,e)){var i;(i=r.getTransformer())==null||i.clearSelectedObjects()}})}))}_drawingUpdateListener(){this.disposeWithMe(this._drawingManagerService.update$.subscribe(e=>{e.forEach(e=>{var t,r;let{unitId:i,subUnitId:a,drawingId:o}=e,s=this._drawingManagerService.getDrawingByParam(e);if(s==null)return;let{transform:c,drawingType:l}=s,u=this._getSceneAndTransformerByDrawingSearch(i);if(u==null)return;let{scene:d,transformer:f}=u;if(c==null)return!0;let{left:p=0,top:m=0,width:h=0,height:g=0,angle:_=0,flipX:v=!1,flipY:y=!1,skewX:b=0,skewY:x=0}=c,S=(0,n.getDrawingShapeKeyByDrawingSearch)({unitId:i,subUnitId:a,drawingId:o}),C=d.getObjectIncludeInGroup(S);if(C==null)return!0;C.transformByState({left:p,top:m,width:h,height:g,angle:_,flipX:v,flipY:y,skewX:b,skewY:x}),(t=C.setClipBounds)==null||t.call(C,c.clipBounds),Me(C,s),Ne(C,s,d,this._drawingManagerService),ke(d,C,s),(r=d.getTransformer())==null||r.debounceRefreshControls()})}))}_drawingRefreshListener(){this.disposeWithMe(this._drawingManagerService.refreshTransform$.subscribe(e=>{e.forEach(e=>{var t;let{unitId:r,subUnitId:i,drawingId:a}=e,o=this._getSceneAndTransformerByDrawingSearch(r);if(o==null)return;let s=this._drawingManagerService.getDrawingByParam(e);if(s==null)return;let{transform:c}=s,{scene:l}=o;if(c==null)return!0;let u=(0,n.getDrawingShapeKeyByDrawingSearch)({unitId:r,subUnitId:i,drawingId:a}),d=l.getObjectIncludeInGroup(u),f=Pe(s,e);if(d==null)return f.hidden===!0||this._drawingManagerService.addNotification([{unitId:r,subUnitId:i,drawingId:a}]),!0;let{left:p=0,top:m=0,width:h=0,height:g=0,angle:_=0,flipX:v=!1,flipY:y=!1,skewX:b=0,skewY:x=0}=c;d.transformByState({left:p,top:m,width:h,height:g,angle:_,flipX:v,flipY:y,skewX:b,skewY:x}),(t=d.setClipBounds)==null||t.call(d,c.clipBounds),Me(d,f),Ne(d,f,l,this._drawingManagerService),ke(l,d,f)})}))}_drawingVisibleListener(){this.disposeWithMe(this._drawingManagerService.visible$.subscribe(e=>{e.forEach(e=>{let{unitId:t,subUnitId:r,drawingId:i,visible:a}=e,o=this._getSceneAndTransformerByDrawingSearch(t);if(o==null)return;let{scene:s}=o,c=(0,n.getDrawingShapeKeyByDrawingSearch)({unitId:t,subUnitId:r,drawingId:i}),l=s.getObjectIncludeInGroup(c);if(l==null)return!0;a?l.show():l.hide()})}))}_filterUpdateParams(e,n){return e.filter((e,r)=>{if(e==null)return!1;let{transform:i}=e;return(0,t.checkIfMove)(i,n==null?void 0:n[r])})}_addListenerOnDrawing(e){let i=e.getTransformerByCreate(),a=null;this.disposeWithMe((0,t.toDisposable)(i.changeStart$.subscribe(e=>{let{objects:t}=e,i=Array.from(t.values()),o=[];a=i.map(e=>{let{left:t,top:n,height:i,width:a,angle:s,oKey:c,isInGroup:l}=e,u=this._drawingManagerService.getDrawingOKey(c);if(l||e instanceof r.Group){let t=e.ancestorGroup;if(t==null&&e instanceof r.Group&&(t=e),t==null)return null;let n=this._drawingManagerService.getDrawingOKey(t.oKey);if(n){let{unitId:e,subUnitId:r,drawingId:i}=n;o.push({unitId:e,subUnitId:r,drawingId:i});let{left:a,top:s,height:c,width:l,angle:u}=t;return{left:a,top:s,height:c,width:l,angle:u}}}else if(u!=null){let{unitId:e,subUnitId:r,drawingId:c}=u;return o.push({unitId:e,subUnitId:r,drawingId:c}),{left:t,top:n,height:i,width:a,angle:s}}return null}).filter(e=>e!=null),o.length>0?this._commandService.syncExecuteCommand(n.SetDrawingSelectedOperation.id,o):this._commandService.syncExecuteCommand(n.SetDrawingSelectedOperation.id,[])}))),this.disposeWithMe((0,t.toDisposable)(i.changeEnd$.subscribe(e=>{let{objects:t}=e,n=this._filterUpdateParams(q(t,this._drawingManagerService),a);n.length>0&&this._drawingManagerService.featurePluginUpdateNotification(n)})))}};J=G([W(0,t.IUniverInstanceService),W(1,t.ICommandService),W(2,r.IRenderManagerService),W(3,n.IDrawingManagerService)],J);function Y({ref:e,...t}){let{preserveStrokeWidth:n,icon:r,id:i,className:a,extend:s,...c}=t,l=`univerjs-icon univerjs-icon-${i} ${a||``}`.trim(),u=`_${(0,o.useId)()}`,d=(0,o.useRef)(null);return(0,o.useImperativeHandle)(e,()=>d.current),(0,o.useLayoutEffect)(()=>{if(n&&d.current&&d.current.localName===r.tag)return Re(d.current)},[n,r]),Fe(r,`${i}`,{defIds:r.defIds,idSuffix:u},{ref:d,className:l,...c},s)}function Fe(e,t,n,r,i){return(0,o.createElement)(e.tag,{key:t,...Ie(e,n,i),...r},(Le(e,n).children||[]).map((r,a)=>Fe(r,`${t}-${e.tag}-${a}`,n,void 0,i)))}function Ie(e,t,n){let r={...e.attrs};n!=null&&n.colorChannel1&&r.fill===`colorChannel1`&&(r.fill=n.colorChannel1),n!=null&&n.colorChannel1&&r.stroke===`colorChannel1`&&(r.stroke=n.colorChannel1),e.tag===`mask`&&r.id&&(r.id+=t.idSuffix),Object.entries(r).forEach(([e,n])=>{e===`mask`&&typeof n==`string`&&(r[e]=n.replace(/url\(#(.*)\)/,`url(#$1${t.idSuffix})`))});let{defIds:i}=t;return!i||i.length===0?r:(e.tag===`use`&&r[`xlink:href`]&&(r[`xlink:href`]+=t.idSuffix),Object.entries(r).forEach(([e,n])=>{typeof n==`string`&&(r[e]=n.replace(/url\(#(.*)\)/,`url(#$1${t.idSuffix})`))}),r)}function Le(e,t){var n;let{defIds:r}=t;return!r||r.length===0?e:e.tag===`defs`&&(n=e.children)!=null&&n.length?{...e,children:e.children.map(e=>typeof e.attrs.id==`string`&&r&&r.includes(e.attrs.id)?{...e,attrs:{...e.attrs,id:e.attrs.id+t.idSuffix}}:e)}:e}function Re(e){let t=e.viewBox.baseVal,n=Math.max(t.width,t.height);if(!Number.isFinite(n)||n<=0||t.width<=0||t.height<=0)return()=>void 0;let r=16/n,i=Array.from(e.querySelectorAll(`circle, ellipse, line, path, polygon, polyline, rect, text, textPath, tspan, use`)).flatMap(e=>{let t=getComputedStyle(e),n=Number.parseFloat(t.strokeWidth);return t.stroke===`none`||Number.parseFloat(t.strokeOpacity)===0||t.vectorEffect===`non-scaling-stroke`||!Number.isFinite(n)||n<=0?[]:[{element:e,hadStyleAttribute:e.hasAttribute(`style`),originalStrokeWidth:n,strokeWidth:ze(e.style,`stroke-width`)}]}).map(e=>({appliedStrokeWidth:null,element:e.element,hadStyleAttribute:e.hadStyleAttribute,isReleased:!1,originalStrokeWidth:e.originalStrokeWidth,strokeWidth:e.strokeWidth}));if(i.length===0)return()=>void 0;let a=(e,n)=>{if(t.width<=0||t.height<=0||e<=0||n<=0)return;let a=Math.min(e/t.width,n/t.height);!Number.isFinite(a)||a<=0||i.forEach(e=>{if(e.isReleased)return;if(e.appliedStrokeWidth!==null&&(e.element.style.getPropertyValue(`stroke-width`)!==e.appliedStrokeWidth||e.element.style.getPropertyPriority(`stroke-width`)!==e.strokeWidth.priority)){e.appliedStrokeWidth=null,e.isReleased=!0;return}let t=e.originalStrokeWidth*r/a,n=`${Number(t.toFixed(12))}px`;e.element.style.setProperty(`stroke-width`,n,e.strokeWidth.priority),e.appliedStrokeWidth=n})},o=e.getBoundingClientRect();a(o.width,o.height);let s=typeof ResizeObserver>`u`?null:new ResizeObserver(t=>{if(t.some(t=>t.target===e)){let t=e.getBoundingClientRect();a(t.width,t.height)}});return s==null||s.observe(e),()=>{s==null||s.disconnect(),i.forEach(e=>{e.appliedStrokeWidth!==null&&(Be(e.element.style,`stroke-width`,e.appliedStrokeWidth,e.strokeWidth.priority,e.strokeWidth),!e.hadStyleAttribute&&e.element.style.length===0&&e.element.removeAttribute(`style`))})}}function ze(e,t){return{priority:e.getPropertyPriority(t),value:e.getPropertyValue(t)}}function Be(e,t,n,r,i){e.getPropertyValue(t)===n&&e.getPropertyPriority(t)===r&&(i.value?e.setProperty(t,i.value,i.priority):e.removeProperty(t))}Y.displayName=`UniverIcon`;let Ve={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 20 21`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M8.90467 3.99244C8.84611 4.1338 8.84611 4.31301 8.84611 4.67143V13.716L5.92068 10.7906C5.66724 10.5371 5.54052 10.4104 5.39916 10.3519C5.21067 10.2738 4.9989 10.2738 4.81041 10.3519C4.66905 10.4104 4.54233 10.5371 4.28889 10.7906C4.03545 11.044 3.90873 11.1707 3.85018 11.3121C3.77211 11.5006 3.77211 11.7124 3.85018 11.9008C3.90873 12.0422 4.03545 12.1689 4.28889 12.4224L9.03476 17.1682C9.07839 17.2127 9.12737 17.2617 9.18231 17.3166L9.18239 17.3167L9.18241 17.3167C9.40545 17.5398 9.53035 17.6647 9.65346 17.7313C9.67085 17.7408 9.6882 17.7492 9.70577 17.7564C9.89425 17.8345 10.106 17.8345 10.2945 17.7564C10.4359 17.6979 10.5626 17.5712 10.816 17.3177C10.8986 17.2352 10.9677 17.1661 11.0253 17.1056L15.7095 12.4214L15.7095 12.4213C15.963 12.1679 16.0897 12.0412 16.1482 11.8998C16.2263 11.7114 16.2263 11.4996 16.1482 11.3111C16.0897 11.1697 15.963 11.043 15.7095 10.7896C15.4561 10.5361 15.3294 10.4094 15.188 10.3509C14.9995 10.2728 14.7878 10.2728 14.5993 10.3509C14.4579 10.4094 14.3312 10.5361 14.0778 10.7896L14.0777 10.7896L11.1538 13.7135V4.67142C11.1538 4.31301 11.1538 4.1338 11.0953 3.99244C11.0172 3.80395 10.8674 3.6542 10.6789 3.57613C10.5376 3.51758 10.3584 3.51758 9.99996 3.51758C9.64154 3.51758 9.46233 3.51758 9.32097 3.57613C9.13249 3.6542 8.98274 3.80395 8.90467 3.99244Z`,fillRule:`evenodd`,clipRule:`evenodd`}}]},He=(0,o.forwardRef)(function(e,t){return(0,o.createElement)(Y,Object.assign({},e,{id:`arrow-down-icon`,ref:t,icon:Ve}))});He.displayName=`ArrowDownIcon`;let Ue={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 20 21`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M11.0936 17.3406C11.1522 17.1992 11.1522 17.02 11.1522 16.6616V7.61701L14.0776 10.5424C14.3311 10.7959 14.4578 10.9226 14.5991 10.9811C14.7876 11.0592 14.9994 11.0592 15.1879 10.9811C15.3292 10.9226 15.456 10.7959 15.7094 10.5424C15.9628 10.289 16.0896 10.1623 16.1481 10.0209C16.2262 9.83243 16.2262 9.62066 16.1481 9.43217C16.0896 9.29081 15.9628 9.16409 15.7094 8.91065L10.9645 4.16576C10.9207 4.12105 10.8714 4.07178 10.8161 4.01648L10.8159 4.0163C10.5916 3.792 10.4666 3.66696 10.3428 3.60058C10.3261 3.59154 10.3094 3.58358 10.2925 3.57658C10.104 3.49851 9.89226 3.49851 9.70378 3.57658C9.56242 3.63514 9.4357 3.76186 9.18226 4.0153C9.09955 4.09801 9.03034 4.16722 8.97258 4.22785L4.28878 8.91166C4.03534 9.1651 3.90862 9.29182 3.85006 9.43318C3.77199 9.62166 3.77199 9.83344 3.85006 10.0219C3.90862 10.1633 4.03534 10.29 4.28878 10.5434C4.54221 10.7969 4.66893 10.9236 4.8103 10.9822C4.99878 11.0602 5.21056 11.0602 5.39904 10.9822C5.5404 10.9236 5.66712 10.7969 5.92056 10.5434L5.92056 10.5434L8.84449 7.61951V16.6616C8.84449 17.02 8.84449 17.1992 8.90305 17.3406C8.98112 17.5291 9.13087 17.6788 9.31935 17.7569C9.46072 17.8154 9.63992 17.8154 9.99834 17.8154C10.3568 17.8154 10.536 17.8154 10.6773 17.7569C10.8658 17.6788 11.0156 17.5291 11.0936 17.3406Z`,fillRule:`evenodd`,clipRule:`evenodd`}}]},We=(0,o.forwardRef)(function(e,t){return(0,o.createElement)(Y,Object.assign({},e,{id:`arrow-up-icon`,ref:t,icon:Ue}))});We.displayName=`ArrowUpIcon`;let Ge={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 17 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M14.0045 4.4334C14.8881 4.4334 15.6045 3.71705 15.6045 2.8334C15.6045 1.94974 14.8881 1.2334 14.0045 1.2334H3.70449C2.82084 1.2334 2.10449 1.94974 2.10449 2.8334C2.10449 3.71705 2.82084 4.4334 3.70449 4.4334H14.0045ZM14.4045 2.8334C14.4045 3.05431 14.2254 3.2334 14.0045 3.2334H3.70449C3.48358 3.2334 3.30449 3.05431 3.30449 2.8334C3.30449 2.61248 3.48358 2.4334 3.70449 2.4334H14.0045C14.2254 2.4334 14.4045 2.61249 14.4045 2.8334Z`,fillRule:`evenodd`,clipRule:`evenodd`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M14.1544 8.5999C15.038 8.5999 15.7544 7.88356 15.7544 6.9999C15.7544 6.11625 15.038 5.3999 14.1544 5.3999H3.85439C2.97074 5.3999 2.25439 6.11625 2.25439 6.9999C2.25439 7.88356 2.97074 8.5999 3.85439 8.5999H14.1544ZM14.5544 6.9999C14.5544 7.22082 14.3753 7.3999 14.1544 7.3999H3.85439C3.63348 7.3999 3.45439 7.22082 3.45439 6.9999C3.45439 6.77899 3.63348 6.5999 3.85439 6.5999H14.1544C14.3753 6.5999 14.5544 6.77899 14.5544 6.9999Z`,fillRule:`evenodd`,clipRule:`evenodd`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M8.57975 14.5902L6.58023 12.5907C6.34591 12.3564 6.34591 11.9765 6.58023 11.7421C6.81454 11.5078 7.19444 11.5078 7.42876 11.7421L8.40449 12.7179V10.1664C8.40449 9.83504 8.67312 9.56641 9.00449 9.56641C9.33586 9.56641 9.60449 9.83504 9.60449 10.1664V12.7179L10.5802 11.7421C10.8145 11.5078 11.1944 11.5078 11.4288 11.7421C11.6631 11.9765 11.6631 12.3564 11.4288 12.5907L9.42923 14.5902`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M8.57975 14.5902C8.58121 14.5917 8.58268 14.5931 8.58416 14.5946C8.64077 14.6502 8.70566 14.6923 8.77482 14.7209C8.84557 14.7502 8.92314 14.7664 9.00449 14.7664C9.08585 14.7664 9.16342 14.7502 9.23416 14.7209C9.30332 14.6923 9.36821 14.6502 9.42482 14.5946`}}]},Ke=(0,o.forwardRef)(function(e,t){return(0,o.createElement)(Y,Object.assign({},e,{id:`bottom-icon`,ref:t,icon:Ge}))});Ke.displayName=`BottomIcon`;let qe={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{stroke:`currentColor`,d:`M1 14.4076H15`,strokeLinecap:`round`,strokeWidth:1.2}},{tag:`rect`,attrs:{width:2.6,height:5.72,x:1.94,y:6.47,stroke:`currentColor`,rx:1.3,strokeWidth:1.2}},{tag:`path`,attrs:{stroke:`currentColor`,d:`M9.29961 5.6002V10.892C9.29961 11.61 8.71758 12.192 7.99961 12.192C7.28164 12.192 6.69961 11.61 6.69961 10.892V5.6002C6.69961 4.88222 7.28164 4.3002 7.99961 4.3002C8.71758 4.3002 9.29961 4.88223 9.29961 5.6002Z`,strokeWidth:1.2}},{tag:`rect`,attrs:{width:2.6,height:10.6,x:11.46,y:1.59,stroke:`currentColor`,rx:1.3,strokeWidth:1.2}}]},Je=(0,o.forwardRef)(function(e,t){return(0,o.createElement)(Y,Object.assign({},e,{id:`chart-icon`,ref:t,icon:qe}))});Je.displayName=`ChartIcon`;let Ye={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M14.1544 3.75557C14.3887 3.98988 14.3887 4.36978 14.1544 4.6041L6.51409 12.2444C6.40157 12.3569 6.24896 12.4201 6.08983 12.4201C5.9307 12.4201 5.77808 12.3569 5.66556 12.2444L1.84541 8.42425C1.6111 8.18993 1.6111 7.81003 1.84541 7.57572C2.07973 7.34141 2.45963 7.34141 2.69394 7.57572L6.08983 10.9716L13.3059 3.75557C13.5402 3.52126 13.9201 3.52126 14.1544 3.75557Z`,fillRule:`evenodd`,clipRule:`evenodd`}}]},Xe=(0,o.forwardRef)(function(e,t){return(0,o.createElement)(Y,Object.assign({},e,{id:`check-mark-icon`,ref:t,icon:Ye}))});Xe.displayName=`CheckMarkIcon`;let Ze={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M3.71274 2.86421C3.47843 2.6299 3.09853 2.6299 2.86421 2.86421C2.6299 3.09853 2.6299 3.47843 2.86421 3.71274L7.15154 8.00007L2.86421 12.2874C2.6299 12.5217 2.6299 12.9016 2.86421 13.1359C3.09853 13.3702 3.47843 13.3702 3.71274 13.1359L8.00007 8.84859L12.2874 13.1359C12.5217 13.3702 12.9016 13.3702 13.1359 13.1359C13.3702 12.9016 13.3702 12.5217 13.1359 12.2874L8.84859 8.00007L13.1359 3.71274C13.3702 3.47843 13.3702 3.09853 13.1359 2.86421C12.9016 2.6299 12.5217 2.6299 12.2874 2.86421L8.00007 7.15154L3.71274 2.86421Z`}}]},Qe=(0,o.forwardRef)(function(e,t){return(0,o.createElement)(Y,Object.assign({},e,{id:`close-icon`,ref:t,icon:Ze}))});Qe.displayName=`CloseIcon`;let $e={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M5.97705 7.51296C5.97705 7.18159 6.24568 6.91296 6.57705 6.91296H8.48632C8.81769 6.91296 9.08632 7.18159 9.08632 7.51296C9.08632 7.84433 8.81769 8.11296 8.48632 8.11296H6.57705C6.24568 8.11296 5.97705 7.84433 5.97705 7.51296Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M6.57705 9.41028C6.24568 9.41028 5.97705 9.67891 5.97705 10.0103C5.97705 10.3416 6.24568 10.6103 6.57705 10.6103H10.8199C11.1512 10.6103 11.4199 10.3416 11.4199 10.0103C11.4199 9.67891 11.1512 9.41028 10.8199 9.41028H6.57705Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M3.51074 2.37063C3.51074 1.48697 4.22709 0.77063 5.11074 0.77063H9.80318L9.81294 0.770708C9.97168 0.768161 10.1311 0.82824 10.2511 0.95055L14.4317 5.21408C14.5165 5.30049 14.5697 5.406 14.5917 5.51645C14.6041 5.5644 14.6106 5.61467 14.6106 5.66648V11.6406C14.6106 12.5243 13.8943 13.2406 13.0106 13.2406H5.11074C4.22709 13.2406 3.51074 12.5243 3.51074 11.6406V2.37063ZM10.4032 4.66648V2.81964L12.6063 5.06648H10.8032C10.5823 5.06648 10.4032 4.88739 10.4032 4.66648ZM5.11074 1.97063C4.88983 1.97063 4.71074 2.14972 4.71074 2.37063V11.6406C4.71074 11.8615 4.88983 12.0406 5.11074 12.0406H13.0106C13.2316 12.0406 13.4106 11.8615 13.4106 11.6406V6.26648H10.8032C9.91953 6.26648 9.20318 5.55013 9.20318 4.66648V1.97063H5.11074Z`,fillRule:`evenodd`,clipRule:`evenodd`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M2.58916 6.6741C2.58916 6.34273 2.32053 6.0741 1.98916 6.0741C1.65779 6.0741 1.38916 6.34273 1.38916 6.6741V12.6294C1.38916 14.0653 2.55322 15.2294 3.98916 15.2294H9.41408C9.74545 15.2294 10.0141 14.9607 10.0141 14.6294C10.0141 14.298 9.74545 14.0294 9.41408 14.0294H3.98916C3.21596 14.0294 2.58916 13.4026 2.58916 12.6294V6.6741Z`}}]},et=(0,o.forwardRef)(function(e,t){return(0,o.createElement)(Y,Object.assign({},e,{id:`create-copy-icon`,ref:t,icon:$e}))});et.displayName=`CreateCopyIcon`;let tt={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`1.05 1.05 17.9 17.9`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{stroke:`currentColor`,d:`M5 2.8V12.5C5 13.9 6.1 15 7.5 15H17.2`,strokeLinecap:`round`,strokeWidth:1.5}},{tag:`path`,attrs:{stroke:`currentColor`,d:`M2.8 5H12.5C13.9 5 15 6.1 15 7.5V17.2`,strokeLinecap:`round`,strokeWidth:1.5}},{tag:`path`,attrs:{stroke:`currentColor`,d:`M8.3 8.3H11.7V11.7H8.3V8.3Z`,strokeWidth:1.2}}]},nt=(0,o.forwardRef)(function(e,t){return(0,o.createElement)(Y,Object.assign({},e,{id:`crop-icon`,ref:t,icon:tt}))});nt.displayName=`CropIcon`;let rt={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M5.3313 1.4667C5.3313 1.13533 5.59993 0.866699 5.9313 0.866699H10.069C10.4004 0.866699 10.669 1.13533 10.669 1.4667C10.669 1.79807 10.4004 2.0667 10.069 2.0667H5.9313C5.59993 2.0667 5.3313 1.79807 5.3313 1.4667Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M1.09985 3.64443C1.09985 3.31306 1.36848 3.04443 1.69985 3.04443H14.2999C14.6312 3.04443 14.8999 3.31306 14.8999 3.64443C14.8999 3.9758 14.6312 4.24443 14.2999 4.24443H1.69985C1.36848 4.24443 1.09985 3.9758 1.09985 3.64443Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M6.12398 8.30171C6.35829 8.0674 6.73819 8.0674 6.97251 8.30171L8.00007 9.32928L9.02764 8.30171C9.26195 8.0674 9.64185 8.0674 9.87617 8.30171C10.1105 8.53603 10.1105 8.91593 9.87617 9.15024L8.8486 10.1778L9.87617 11.2054C10.1105 11.4397 10.1105 11.8196 9.87617 12.0539C9.64185 12.2882 9.26195 12.2882 9.02764 12.0539L8.00007 11.0263L6.97251 12.0539C6.73819 12.2882 6.35829 12.2882 6.12398 12.0539C5.88966 11.8196 5.88966 11.4397 6.12398 11.2054L7.15154 10.1778L6.12398 9.15024C5.88966 8.91593 5.88966 8.53603 6.12398 8.30171Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M4.75332 5.22217C3.86966 5.22217 3.15332 5.93851 3.15332 6.82217V12.5331C3.15332 13.9691 4.31738 15.1332 5.75332 15.1332H10.2465C11.6825 15.1332 12.8465 13.9691 12.8465 12.5331V6.82217C12.8465 5.93851 12.1302 5.22217 11.2465 5.22217H4.75332ZM4.35332 6.82217C4.35332 6.60125 4.53241 6.42217 4.75332 6.42217H11.2465C11.4674 6.42217 11.6465 6.60125 11.6465 6.82217V12.5331C11.6465 13.3063 11.0197 13.9332 10.2465 13.9332H5.75332C4.98012 13.9332 4.35332 13.3063 4.35332 12.5331V6.82217Z`,fillRule:`evenodd`,clipRule:`evenodd`}}]},it=(0,o.forwardRef)(function(e,t){return(0,o.createElement)(Y,Object.assign({},e,{id:`delete-icon`,ref:t,icon:rt}))});it.displayName=`DeleteIcon`;let at={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{stroke:`currentColor`,d:`M6.18958 14.085H4.0929C2.98833 14.085 2.0929 13.1895 2.0929 12.085V3.5918C2.0929 2.48723 2.98833 1.5918 4.0929 1.5918H10.5031C11.6077 1.5918 12.5031 2.48723 12.5031 3.5918V6.41602`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:1.33}},{tag:`path`,attrs:{stroke:`currentColor`,d:`M4.73547 4.57324H9.96594M4.73547 7.08105H7.91614`,strokeLinecap:`round`,strokeWidth:1.33}},{tag:`path`,attrs:{stroke:`currentColor`,d:`M10.0255 9.17969H11.9572L13.7687 11.7939L11.9572 14.4082H10.0255L8.21399 11.7939L10.0255 9.17969Z`,strokeLinejoin:`round`,strokeWidth:1.33}},{tag:`path`,attrs:{stroke:`currentColor`,d:`M10.9913 11.7939H10.9914`,strokeLinecap:`round`,strokeWidth:1.83}}]},ot=(0,o.forwardRef)(function(e,t){return(0,o.createElement)(Y,Object.assign({},e,{id:`doc-setting-icon`,ref:t,icon:at}))});ot.displayName=`DocSettingIcon`;let st={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{stroke:`currentColor`,d:`M10 10L14 14M10 6L14 2M14 10.6667V14H10.6667M14 5.33333V2H10.6667M2 10.6667V14H5.33333M2 14L6 10M2 5.33333V2H5.33333M6 6L2 2`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:1.2}}]},ct=(0,o.forwardRef)(function(e,t){return(0,o.createElement)(Y,Object.assign({},e,{id:`expand-icon`,ref:t,icon:st}))});ct.displayName=`ExpandIcon`;let lt={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M7.46613 5.2614C7.99641 5.15377 8.54607 5.209 9.04566 5.42016C9.54527 5.63133 9.9725 5.98902 10.2732 6.44821C10.5739 6.90741 10.7345 7.44742 10.7345 7.99994C10.7345 8.74088 10.446 9.45122 9.93293 9.97475C9.41991 10.4982 8.72439 10.7921 7.99945 10.7921C7.45882 10.7921 6.93021 10.6285 6.48047 10.3219C6.03072 10.0152 5.67998 9.57922 5.47282 9.06887C5.26565 8.55852 5.21142 7.99686 5.31705 7.45498C5.42268 6.9131 5.68338 6.41554 6.06598 6.02513C6.44856 5.63474 6.93584 5.36903 7.46613 5.2614ZM7.99945 6.50637C7.70941 6.50637 7.42599 6.59414 7.18504 6.75842C6.94411 6.92269 6.75652 7.15604 6.64579 7.4288C6.53508 7.70156 6.50613 8.00161 6.56255 8.29108C6.61898 8.58055 6.7583 8.84663 6.96308 9.05559C7.16788 9.26456 7.42896 9.40703 7.7134 9.46476C7.99784 9.5225 8.29266 9.49286 8.56052 9.37964C8.82836 9.26643 9.05707 9.07481 9.21789 8.82922C9.3787 8.58364 9.46445 8.29505 9.46445 7.99994C9.46445 7.60424 9.31042 7.22449 9.03583 6.94429C8.76119 6.66405 8.38842 6.50637 7.99945 6.50637Z`,fillRule:`evenodd`,clipRule:`evenodd`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M1.06445 7.99994C1.06445 7.86432 1.111 7.68433 1.20506 7.46997C1.29865 7.25669 1.43723 7.01393 1.61634 6.75416C1.97451 6.23466 2.49209 5.65088 3.12753 5.10347C4.3995 4.00771 6.13495 3.06494 7.99945 3.06494C9.86395 3.06494 11.5994 4.00771 12.8714 5.10347C13.5068 5.65088 14.0244 6.23466 14.3826 6.75416C14.5617 7.01393 14.7003 7.25669 14.7938 7.46997C14.8879 7.68433 14.9345 7.86432 14.9345 7.99994C14.9345 8.29406 14.7859 8.75016 14.4847 9.27371C14.1847 9.79497 13.7374 10.3759 13.1495 10.9188C11.974 12.0042 10.2392 12.9349 7.99945 12.9349C5.75972 12.9349 4.02489 12.0042 2.84937 10.9188C2.26147 10.3759 1.81418 9.79497 1.51423 9.27371C1.21296 8.75016 1.06445 8.29406 1.06445 7.99994ZM7.99945 4.36351C6.48933 4.36351 5.14092 5.09788 4.14125 5.91406C3.64087 6.32258 3.22616 6.75295 2.92026 7.12521C2.61595 7.49554 2.415 7.81359 2.34753 7.99756L2.33827 8.0228L2.34954 8.0472C2.85275 9.13669 3.65354 10.055 4.65594 10.6918C5.65805 11.3283 6.81899 11.6563 7.99945 11.6364C9.17991 11.6563 10.3409 11.3283 11.343 10.6918C12.3454 10.055 13.1462 9.13669 13.6494 8.0472L13.6606 8.0228L13.6514 7.99756C13.5839 7.81359 13.383 7.49554 13.0786 7.12521C12.7727 6.75295 12.358 6.32258 11.8577 5.91406C10.858 5.09788 9.50957 4.36351 7.99945 4.36351Z`,fillRule:`evenodd`,clipRule:`evenodd`}}]},ut=(0,o.forwardRef)(function(e,t){return(0,o.createElement)(Y,Object.assign({},e,{id:`eye-icon`,ref:t,icon:lt}))});ut.displayName=`EyeIcon`;let dt={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M1.28096 4.6541C1.57489 4.50109 1.93721 4.61533 2.09022 4.90926C2.27315 5.26067 2.55999 5.60455 2.94829 5.92278C4.04628 6.82266 5.87505 7.44865 7.99828 7.44865C10.1215 7.44865 11.9503 6.82267 13.0482 5.92279C13.4366 5.60455 13.7234 5.26067 13.9063 4.90927C14.0594 4.61533 14.4217 4.50109 14.7156 4.65409C15.0095 4.8071 15.1238 5.16941 14.9708 5.46334C14.6995 5.98445 14.2981 6.44997 13.8089 6.8509C13.7298 6.91575 13.6481 6.97914 13.564 7.041L15.2245 8.70153C15.4588 8.93585 15.4588 9.31575 15.2245 9.55006C14.9902 9.78438 14.6103 9.78438 14.376 9.55006L12.5041 7.67822C11.8977 7.97568 11.2181 8.21208 10.4884 8.37706L11.0996 10.6581C11.1853 10.9782 10.9954 11.3072 10.6753 11.393C10.3552 11.4787 10.0262 11.2888 9.94045 10.9687L9.29949 8.57652C8.8758 8.62404 8.44081 8.64865 7.99828 8.64865C7.55276 8.64865 7.11487 8.62371 6.68846 8.57555L6.04723 10.9687C5.96147 11.2888 5.63247 11.4788 5.31239 11.393C4.99231 11.3073 4.80236 10.9783 4.88812 10.6582L5.49983 8.37516C4.7743 8.2105 4.09843 7.9752 3.49498 7.67947L1.62436 9.55009C1.39005 9.78441 1.01015 9.78441 0.775835 9.5501C0.54152 9.31578 0.541518 8.93588 0.775832 8.70157L2.43478 7.04261C2.34987 6.98024 2.26746 6.91632 2.18764 6.8509C1.69842 6.44997 1.29706 5.98445 1.0258 5.46335C0.872791 5.16942 0.987031 4.80711 1.28096 4.6541Z`}}]},ft=(0,o.forwardRef)(function(e,t){return(0,o.createElement)(Y,Object.assign({},e,{id:`eyelash-icon`,ref:t,icon:dt}))});ft.displayName=`EyelashIcon`;let pt={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 17 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M7.38125 1.16211C6.49759 1.16211 5.78125 1.87845 5.78125 2.76211V5.6377H2.87783C1.99418 5.6377 1.27783 6.35404 1.27783 7.2377V13.2377C1.27783 14.1214 1.99418 14.8377 2.87783 14.8377H8.87783C9.76149 14.8377 10.4778 14.1214 10.4778 13.2377V10.3621H13.3813C14.2649 10.3621 14.9813 9.64577 14.9813 8.76211V2.76211C14.9813 1.87845 14.2649 1.16211 13.3813 1.16211H7.38125ZM10.4778 9.16211H13.3813C13.6022 9.16211 13.7812 8.98302 13.7812 8.76211V2.76211C13.7812 2.5412 13.6022 2.36211 13.3813 2.36211H7.38125C7.16034 2.36211 6.98125 2.5412 6.98125 2.76211V5.6377H8.87783C9.76149 5.6377 10.4778 6.35404 10.4778 7.2377V9.16211ZM6.98125 6.8377H8.87783C9.09875 6.8377 9.27783 7.01678 9.27783 7.2377V9.16211H7.38125C7.16034 9.16211 6.98125 8.98302 6.98125 8.76211V6.8377ZM5.78125 6.8377V8.76211C5.78125 9.64577 6.49759 10.3621 7.38125 10.3621H9.27783V13.2377C9.27783 13.4586 9.09875 13.6377 8.87783 13.6377H2.87783C2.65692 13.6377 2.47783 13.4586 2.47783 13.2377V7.2377C2.47783 7.01678 2.65692 6.8377 2.87783 6.8377H5.78125Z`,fillRule:`evenodd`,clipRule:`evenodd`}}]},mt=(0,o.forwardRef)(function(e,t){return(0,o.createElement)(Y,Object.assign({},e,{id:`group-icon`,ref:t,icon:pt}))});mt.displayName=`GroupIcon`;let ht={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 20 20`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{stroke:`currentColor`,d:`M10 2.8v2.5M10 14.7v2.5M2.8 10h2.5M14.7 10h2.5`,strokeLinecap:`round`,strokeWidth:1.6}},{tag:`circle`,attrs:{cx:10,cy:10,r:4.2,stroke:`currentColor`,strokeWidth:1.6}},{tag:`circle`,attrs:{cx:10,cy:10,r:1.35,fill:`currentColor`}}]},gt=(0,o.forwardRef)(function(e,t){return(0,o.createElement)(Y,Object.assign({},e,{id:`locate-fixed-icon`,ref:t,icon:ht}))});gt.displayName=`LocateFixedIcon`;let _t={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M2.62402 7.72905C2.58427 7.72905 2.55205 7.76127 2.55205 7.80102V13.6782C2.55205 13.7179 2.58427 13.7502 2.62402 13.7502H13.3755C13.4152 13.7502 13.4474 13.7179 13.4474 13.6782V7.80102C13.4474 7.76127 13.4152 7.72905 13.3755 7.72905H2.62402ZM1.35205 7.80102C1.35205 7.09853 1.92153 6.52905 2.62402 6.52905H13.3755C14.0779 6.52905 14.6474 7.09853 14.6474 7.80102V13.6782C14.6474 14.3807 14.0779 14.9502 13.3755 14.9502H2.62402C1.92153 14.9502 1.35205 14.3807 1.35205 13.6782V7.80102Z`,fillRule:`evenodd`,clipRule:`evenodd`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M8 2.25005C6.69847 2.25003 5.64336 3.30513 5.64336 4.60666V7.12895C5.64336 7.46032 5.37473 7.72895 5.04336 7.72895C4.71199 7.72895 4.44336 7.46032 4.44336 7.12895V4.60666C4.44336 2.64239 6.04451 1.05565 8.00879 1.05566M8 2.25005L8.00879 1.05566L8 2.25005ZM8.00879 1.05566L8 2.25005C9.30154 2.25003 10.3567 3.30513 10.3567 4.60666V7.12895C10.3567 7.46032 10.6253 7.72895 10.9567 7.72895C11.288 7.72895 11.5567 7.46032 11.5567 7.12895V4.60666C11.5567 2.64239 9.97306 1.05565 8.00879 1.05566Z`,fillRule:`evenodd`,clipRule:`evenodd`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M8.00039 9.4668C8.33176 9.4668 8.60039 9.73543 8.60039 10.0668V12.0827C8.60039 12.4141 8.33176 12.6827 8.00039 12.6827C7.66902 12.6827 7.40039 12.4141 7.40039 12.0827V10.0668C7.40039 9.73543 7.66902 9.4668 8.00039 9.4668Z`,fillRule:`evenodd`,clipRule:`evenodd`}}]},vt=(0,o.forwardRef)(function(e,t){return(0,o.createElement)(Y,Object.assign({},e,{id:`lock-icon`,ref:t,icon:_t}))});vt.displayName=`LockIcon`;let yt={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M11.3536 6.14645C11.5488 6.34171 11.5488 6.65829 11.3536 6.85355L8.35355 9.85355C8.15829 10.0488 7.84171 10.0488 7.64645 9.85355L4.64645 6.85355C4.45118 6.65829 4.45118 6.34171 4.64645 6.14645C4.84171 5.95118 5.15829 5.95118 5.35355 6.14645L8 8.79289L10.6464 6.14645C10.8417 5.95118 11.1583 5.95118 11.3536 6.14645Z`,fillRule:`evenodd`,clipRule:`evenodd`}}]},X=(0,o.forwardRef)(function(e,t){return(0,o.createElement)(Y,Object.assign({},e,{id:`more-down-icon`,ref:t,icon:yt}))});X.displayName=`MoreDownIcon`;let bt={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M1.25 2.96401C1.25 3.84767 1.96634 4.56401 2.85 4.56401H13.15C14.0337 4.56401 14.75 3.84767 14.75 2.96401C14.75 2.08036 14.0337 1.36401 13.15 1.36401H2.85C1.96635 1.36401 1.25 2.08036 1.25 2.96401ZM2.85 3.36401C2.62909 3.36401 2.45 3.18493 2.45 2.96401C2.45 2.7431 2.62909 2.56401 2.85 2.56401H13.15C13.3709 2.56401 13.55 2.7431 13.55 2.96401C13.55 3.18493 13.3709 3.36401 13.15 3.36401H2.85Z`,fillRule:`evenodd`,clipRule:`evenodd`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M5.57564 11.6118C5.80995 11.3774 6.18985 11.3774 6.42417 11.6118L7.3999 12.5875V6.36951C7.3999 6.03814 7.66853 5.76951 7.9999 5.76951C8.33127 5.76951 8.5999 6.03814 8.5999 6.36951V12.5875L9.57564 11.6118C9.80995 11.3774 10.1899 11.3774 10.4242 11.6118C10.6585 11.8461 10.6585 12.226 10.4242 12.4603L8.4324 14.452C8.32324 14.5655 8.16982 14.6362 7.9999 14.6362C7.82998 14.6362 7.67655 14.5655 7.56739 14.452L5.57564 12.4603C5.34132 12.226 5.34132 11.8461 5.57564 11.6118Z`}}]},xt=(0,o.forwardRef)(function(e,t){return(0,o.createElement)(Y,Object.assign({},e,{id:`move-down-icon`,ref:t,icon:bt}))});xt.displayName=`MoveDownIcon`;let St={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M1.25 13.036C1.25 12.1523 1.96634 11.436 2.85 11.436H13.15C14.0337 11.436 14.75 12.1523 14.75 13.036C14.75 13.9196 14.0337 14.636 13.15 14.636H2.85C1.96635 14.636 1.25 13.9196 1.25 13.036ZM2.85 12.636C2.62909 12.636 2.45 12.8151 2.45 13.036C2.45 13.2569 2.62909 13.436 2.85 13.436H13.15C13.3709 13.436 13.55 13.2569 13.55 13.036C13.55 12.8151 13.3709 12.636 13.15 12.636H2.85Z`,fillRule:`evenodd`,clipRule:`evenodd`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M5.57564 4.38825C5.80995 4.62256 6.18985 4.62256 6.42417 4.38825L7.3999 3.41251V9.63049C7.3999 9.96186 7.66853 10.2305 7.9999 10.2305C8.33127 10.2305 8.5999 9.96186 8.5999 9.63049V3.41251L9.57564 4.38825C9.80995 4.62256 10.1899 4.62256 10.4242 4.38825C10.6585 4.15393 10.6585 3.77403 10.4242 3.53972L8.4324 1.54796C8.32324 1.43445 8.16982 1.36382 7.9999 1.36382C7.82998 1.36382 7.67655 1.43446 7.56739 1.54797L5.57564 3.53972C5.34132 3.77403 5.34132 4.15393 5.57564 4.38825Z`}}]},Ct=(0,o.forwardRef)(function(e,t){return(0,o.createElement)(Y,Object.assign({},e,{id:`move-up-icon`,ref:t,icon:St}))});Ct.displayName=`MoveUpIcon`;let wt={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 20 20`,width:`1em`,height:`1em`},children:[{tag:`rect`,attrs:{width:17,height:1.2,x:1.5,y:2.45,fill:`currentColor`,rx:.6}},{tag:`rect`,attrs:{width:3.25,height:1.2,x:1.5,y:6.1,fill:`currentColor`,rx:.6}},{tag:`rect`,attrs:{width:3.25,height:1.2,x:15.25,y:6.1,fill:`currentColor`,rx:.6}},{tag:`rect`,attrs:{width:3.25,height:1.2,x:1.5,y:9.4,fill:`currentColor`,rx:.6}},{tag:`rect`,attrs:{width:3.25,height:1.2,x:15.25,y:9.4,fill:`currentColor`,rx:.6}},{tag:`rect`,attrs:{width:3.25,height:1.2,x:1.5,y:12.7,fill:`currentColor`,rx:.6}},{tag:`rect`,attrs:{width:3.25,height:1.2,x:15.25,y:12.7,fill:`currentColor`,rx:.6}},{tag:`rect`,attrs:{width:17,height:1.2,x:1.5,y:16.35,fill:`currentColor`,rx:.6}},{tag:`path`,attrs:{fill:`currentColor`,d:`M7.55 5.45C6.50066 5.45 5.65 6.30066 5.65 7.35V12.65C5.65 13.6993 6.50066 14.55 7.55 14.55H12.45C13.4993 14.55 14.35 13.6993 14.35 12.65V7.35C14.35 6.30066 13.4993 5.45 12.45 5.45H7.55ZM7.8 6.75C7.24772 6.75 6.8 7.19772 6.8 7.75V12.25C6.8 12.8023 7.24772 13.25 7.8 13.25H12.2C12.7523 13.25 13.2 12.8023 13.2 12.25V7.75C13.2 7.19772 12.7523 6.75 12.2 6.75H7.8Z`,fillRule:`evenodd`,clipRule:`evenodd`}}]},Tt=(0,o.forwardRef)(function(e,t){return(0,o.createElement)(Y,Object.assign({},e,{id:`text-wrap-shape-icon`,ref:t,icon:wt}))});Tt.displayName=`TextWrapShapeIcon`;let Et={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 17 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M7.82994 1.40913C7.88746 1.35161 7.95376 1.30821 8.02453 1.27893C8.09527 1.24959 8.17285 1.2334 8.2542 1.2334C8.33555 1.2334 8.41313 1.24959 8.48387 1.27893C8.55464 1.30821 8.62094 1.35161 8.67846 1.40913L10.6785 3.40913C10.9128 3.64345 10.9128 4.02335 10.6785 4.25766C10.4441 4.49198 10.0642 4.49198 9.82994 4.25766L8.8542 3.28193V5.8334C8.8542 6.16477 8.58557 6.4334 8.2542 6.4334C7.92283 6.4334 7.6542 6.16477 7.6542 5.8334V3.28193L6.67846 4.25766C6.44415 4.49198 6.06425 4.49198 5.82994 4.25766C5.59562 4.02335 5.59562 3.64345 5.82994 3.40913L7.82994 1.40913Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M1.50439 9C1.50439 8.11634 2.22074 7.4 3.10439 7.4H13.4044C14.288 7.4 15.0044 8.11634 15.0044 9C15.0044 9.88366 14.2881 10.6 13.4044 10.6H3.1044C2.22074 10.6 1.50439 9.88366 1.50439 9ZM3.10439 8.6C2.88348 8.6 2.70439 8.77909 2.70439 9C2.70439 9.22091 2.88348 9.4 3.1044 9.4H13.4044C13.6253 9.4 13.8044 9.22091 13.8044 9C13.8044 8.77909 13.6253 8.6 13.4044 8.6H3.10439Z`,fillRule:`evenodd`,clipRule:`evenodd`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M1.6543 13.1665C1.6543 12.2828 2.37064 11.5665 3.2543 11.5665H13.5543C14.438 11.5665 15.1543 12.2828 15.1543 13.1665C15.1543 14.0502 14.438 14.7665 13.5543 14.7665H3.2543C2.37064 14.7665 1.6543 14.0502 1.6543 13.1665ZM3.2543 12.7665C3.03338 12.7665 2.8543 12.9456 2.8543 13.1665C2.8543 13.3874 3.03338 13.5665 3.2543 13.5665H13.5543C13.7752 13.5665 13.9543 13.3874 13.9543 13.1665C13.9543 12.9456 13.7752 12.7665 13.5543 12.7665H3.2543Z`,fillRule:`evenodd`,clipRule:`evenodd`}}]},Dt=(0,o.forwardRef)(function(e,t){return(0,o.createElement)(Y,Object.assign({},e,{id:`topmost-icon`,ref:t,icon:Et}))});Dt.displayName=`TopmostIcon`;let Ot={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 17 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M7.46855 2.83731C7.46855 2.61639 7.64764 2.4373 7.86855 2.4373H13.8603C14.0812 2.4373 14.2603 2.61639 14.2603 2.8373V9.5049C14.2603 9.72581 14.0812 9.90489 13.8603 9.90489H12.866C12.5346 9.90489 12.266 10.1735 12.266 10.5049C12.266 10.8363 12.5346 11.1049 12.866 11.1049H13.8603C14.7439 11.1049 15.4603 10.3886 15.4603 9.5049V2.8373C15.4603 1.95365 14.7439 1.2373 13.8603 1.2373H7.86855C6.9849 1.2373 6.26855 1.95365 6.26855 2.83731V3.48688C6.26855 3.81825 6.53718 4.08688 6.86855 4.08688C7.19993 4.08688 7.46855 3.81825 7.46855 3.48688V2.83731Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M3.19888 5.56299C2.31522 5.56299 1.59888 6.27933 1.59888 7.16299V13.163C1.59888 14.0466 2.31522 14.763 3.19888 14.763H9.19888C10.0825 14.763 10.7989 14.0466 10.7989 13.163V7.16299C10.7989 6.27933 10.0825 5.56299 9.19888 5.56299H3.19888ZM2.79888 7.16299C2.79888 6.94207 2.97796 6.76299 3.19888 6.76299H9.19888C9.41979 6.76299 9.59888 6.94207 9.59888 7.16299V13.163C9.59888 13.3839 9.41979 13.563 9.19888 13.563H3.19888C2.97796 13.563 2.79888 13.3839 2.79888 13.163V7.16299Z`,fillRule:`evenodd`,clipRule:`evenodd`}}]},kt=(0,o.forwardRef)(function(e,t){return(0,o.createElement)(Y,Object.assign({},e,{id:`ungroup-icon`,ref:t,icon:Ot}))});kt.displayName=`UngroupIcon`;let At={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M2.62402 7.72905C2.58427 7.72905 2.55205 7.76127 2.55205 7.80102V13.6782C2.55205 13.7179 2.58427 13.7502 2.62402 13.7502H13.3755C13.4152 13.7502 13.4474 13.7179 13.4474 13.6782V7.80102C13.4474 7.76127 13.4152 7.72905 13.3755 7.72905H2.62402ZM1.35205 7.80102C1.35205 7.09853 1.92153 6.52905 2.62402 6.52905H13.3755C14.0779 6.52905 14.6474 7.09853 14.6474 7.80102V13.6782C14.6474 14.3807 14.0779 14.9502 13.3755 14.9502H2.62402C1.92153 14.9502 1.35205 14.3807 1.35205 13.6782V7.80102Z`,fillRule:`evenodd`,clipRule:`evenodd`}},{tag:`path`,attrs:{stroke:`currentColor`,d:`M5.04336 7.12895V4.60666C5.04336 2.97376 6.3671 1.65005 8 1.65005C9.6329 1.65005 10.9566 2.97376 10.9566 4.60666`,strokeLinecap:`round`,strokeWidth:1.2}},{tag:`path`,attrs:{fill:`currentColor`,d:`M8.00039 9.4668C8.33176 9.4668 8.60039 9.73543 8.60039 10.0668V12.0827C8.60039 12.4141 8.33176 12.6827 8.00039 12.6827C7.66902 12.6827 7.40039 12.4141 7.40039 12.0827V10.0668C7.40039 9.73543 7.66902 9.4668 8.00039 9.4668Z`,fillRule:`evenodd`,clipRule:`evenodd`}}]},jt=(0,o.forwardRef)(function(e,t){return(0,o.createElement)(Y,Object.assign({},e,{id:`unlock-icon`,ref:t,icon:At}))});jt.displayName=`UnlockIcon`;let Mt={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`colorChannel1`,d:`M11.0363 12.2367V14.0367C11.0363 14.3681 11.3049 14.6367 11.6363 14.6367C11.9676 14.6367 12.2363 14.3681 12.2363 14.0367V12.2367H14.0364C14.3677 12.2367 14.6364 11.9681 14.6364 11.6367C14.6364 11.3054 14.3677 11.0367 14.0364 11.0367H12.2363V9.23672C12.2363 8.90535 11.9676 8.63672 11.6363 8.63672C11.3049 8.63672 11.0363 8.90535 11.0363 9.23672V11.0367H9.23635C8.90498 11.0367 8.63635 11.3054 8.63635 11.6367C8.63635 11.9681 8.90498 12.2367 9.23635 12.2367H11.0363Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M2.56365 1.36377C1.90091 1.36377 1.36365 1.90103 1.36365 2.56377V6.16377C1.36365 6.82651 1.90091 7.36377 2.56365 7.36377H6.16365C6.82639 7.36377 7.36365 6.82651 7.36365 6.16377V2.56377C7.36365 1.90103 6.82639 1.36377 6.16365 1.36377H2.56365ZM6.16365 2.56377H2.56365L2.56365 6.16377H6.16365V2.56377Z`,fillRule:`evenodd`,clipRule:`evenodd`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M2.56365 8.63647C1.90091 8.63647 1.36365 9.17373 1.36365 9.83647V13.4365C1.36365 14.0992 1.90091 14.6365 2.56365 14.6365H6.16365C6.82639 14.6365 7.36365 14.0992 7.36365 13.4365V9.83647C7.36365 9.17373 6.82639 8.63647 6.16365 8.63647H2.56365ZM6.16365 9.83647H2.56365L2.56365 13.4365H6.16365V9.83647Z`,fillRule:`evenodd`,clipRule:`evenodd`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M9.83635 7.36377C9.17361 7.36377 8.63635 6.82651 8.63635 6.16377V2.56377C8.63635 1.90103 9.17361 1.36377 9.83635 1.36377H13.4364C14.0991 1.36377 14.6364 1.90103 14.6364 2.56377V6.16377C14.6364 6.82651 14.0991 7.36377 13.4364 7.36377H9.83635ZM9.83635 6.16377V2.56377L13.4364 2.56377V6.16377H9.83635Z`,fillRule:`evenodd`,clipRule:`evenodd`}}]},Nt=(0,o.forwardRef)(function(e,t){return(0,o.createElement)(Y,Object.assign({},e,{id:`autofill-double-icon`,ref:t,icon:Mt}))});Nt.displayName=`AutofillDoubleIcon`;let Pt=`COMPONENT_IMAGE_POPUP_MENU`,Ft=`COMPONENT_MOBILE_IMAGE_POPUP_MENU`;function It({popup:e}){var n,r,o;let l=(0,i.useDependency)(t.ICommandService),u=(0,i.useDependency)(i.IDialogService),d=(0,i.useDependency)(i.IconManager),f=(0,i.useDependency)(t.LocaleService),p=((n=e.extraProps)==null?void 0:n.menuItems)??[];if(p.length===0)return null;async function m(t,n){var r,i;if(!t||t.disable||t.type===`select`&&(typeof n!=`string`||!((r=t.options)!=null&&r.some(e=>e.value===n))))return;let a=t.type===`select`&&typeof n==`string`?((i=t.commandParamsFactory)==null?void 0:i.call(t,n))??{...t.commandParams,value:n}:t.commandParams;if(await l.executeCommand(t.commandId,a),t.hideOnClick!==!1){var o,s,c;(o=e.extraProps)==null||(s=o.onClose)==null||s.call(o),(c=e.extraProps)!=null&&c.dialogId&&u.close(e.extraProps.dialogId)}}if(!((r=e.extraProps)!=null&&r.variant||p.some(e=>e.type===`select`)))return(0,c.jsx)(`div`,{className:`univer-flex univer-flex-col univer-gap-2`,children:p.map(e=>{let t=f.t(e.label),n=e.icon&&d.has(e.icon)?d.get(e.icon):null;return(0,c.jsx)(s.MobileActionRow,{title:t,"aria-label":t,icon:n?(0,c.jsx)(n,{}):void 0,variant:`subtle`,disabled:e.disable,onClick:async()=>{await m(e)}},`${e.commandId}-${e.label}`)})});let h=p.map(e=>{var t;return{key:e.commandId,order:e.index,item:e.type===`select`?{id:e.commandId,type:i.MenuItemType.SELECTOR,title:e.label,value$:(0,a.of)(e.value),disabled$:(0,a.of)(e.disable||!((t=e.options)!=null&&t.length)),selections:e.options}:{id:e.commandId,type:i.MenuItemType.BUTTON,title:e.label,disabled$:(0,a.of)(e.disable)}}});return(0,c.jsx)(i.MobileMenu,{presentation:(o=e.extraProps)!=null&&o.variant?`context-bar`:`drawer`,schemas:h,onOptionSelect:async({id:e,value:t})=>{await m(p.find(t=>t.commandId===e),t)}})}let Lt=`drawing-ui.arrange`,Rt=`drawing-ui.cropper`,zt=`drawing-ui.transform`,Bt=`drawing-ui.align`,Vt=`drawing-ui.group`;function Ht(e){let{arrangeShow:r,drawings:a}=e,o=(0,i.useDependency)(t.LocaleService),l=(0,i.useDependency)(n.IDrawingManagerService),u=(0,i.useDependency)(t.ICommandService),d=(0,i.useDependency)(i.IconManager),f=d.get(`MoveUpIcon`),p=d.get(`MoveDownIcon`),m=d.get(`TopmostIcon`),h=d.get(`BottomIcon`),g=(0,i.useObservable)(()=>l.focus$,a,!1,[l]),_=e=>{u.syncExecuteCommand(y.id,{arrangeType:e,drawings:g})};return(0,c.jsxs)(`div`,{className:(0,s.clsx)(`univer-grid univer-gap-2 univer-py-2 univer-text-gray-400`,{"univer-hidden":!r}),children:[(0,c.jsx)(`header`,{className:`univer-text-gray-600 dark:!univer-text-gray-200`,children:(0,c.jsx)(`div`,{children:o.t(`drawing-ui.image-panel.arrange.title`)})}),(0,c.jsxs)(`div`,{className:`univer-grid univer-grid-cols-2 univer-gap-2`,children:[(0,c.jsxs)(s.Button,{className:`univer-h-12 univer-w-full`,onClick:()=>_(t.ArrangeTypeEnum.forward),children:[(0,c.jsx)(f,{}),o.t(`drawing-ui.image-panel.arrange.forward`)]}),(0,c.jsxs)(s.Button,{className:`univer-h-12 univer-w-full`,onClick:()=>_(t.ArrangeTypeEnum.backward),children:[(0,c.jsx)(p,{}),o.t(`drawing-ui.image-panel.arrange.backward`)]}),(0,c.jsxs)(s.Button,{className:`univer-h-12 univer-w-full`,onClick:()=>_(t.ArrangeTypeEnum.front),children:[(0,c.jsx)(m,{}),o.t(`drawing-ui.image-panel.arrange.front`)]}),(0,c.jsxs)(s.Button,{className:`univer-h-12 univer-w-full`,onClick:()=>_(t.ArrangeTypeEnum.back),children:[(0,c.jsx)(h,{}),o.t(`drawing-ui.image-panel.arrange.back`)]})]})]})}let Ut=[-360,360];function Wt(e){return!e}function Gt(e){return t=>{if(Wt(e.rotateEnabled)||t==null)return;let{unitId:n,subUnitId:r,drawingId:i,drawingType:a}=e.drawingParam,o={unitId:n,subUnitId:r,drawingId:i,drawingType:a,transform:{angle:t}};e.setRotation(t),e.emitUpdate([o]),e.notifyChange()}}function Kt(e){return(0,c.jsx)(s.InputNumber,{...e,controls:!1,className:(0,s.clsx)(`univer-h-12 univer-w-full`,e.className),inputClassName:(0,s.clsx)(`[&_input]:!univer-h-12 [&_input]:!univer-text-base`,e.inputClassName)})}function qt(e){return(0,c.jsx)(s.Checkbox,{...e,className:(0,s.clsx)(`univer-flex univer-min-h-12 univer-items-center univer-justify-center`,e.className)})}function Jt(e){return(0,c.jsx)(s.Button,{...e,className:(0,s.clsx)(`univer-flex univer-min-h-12 univer-flex-1 univer-items-center univer-justify-center univer-gap-2 univer-text-base`,e.className)})}function Yt(e){var t,n;let a=(0,i.useDependency)(r.IRenderManagerService),o=e.drawings[0],s=o?(t=a.getRenderUnitById(o.unitId))==null?void 0:t.scene:void 0,l=s==null||(n=s.getEngine())==null?void 0:n.activeScene;return!(o!=null&&o.transform)||!s||!l?null:(0,c.jsx)(Xt,{...e})}function Xt(e){let a=(0,i.useDependency)(t.LocaleService),l=(0,i.useDependency)(n.IDrawingManagerService),u=(0,i.useDependency)(r.IRenderManagerService),{drawings:d,transformShow:f}=e,p=d[0],m=p.transform,{unitId:h,subUnitId:g,drawingId:_,drawingType:v}=p,y=u.getRenderUnitById(h).scene,b=y.getEngine().activeScene,x=y.getTransformerByCreate(),{width:S=0,height:C=0,left:w=0,top:T=0,angle:E=0}=m,[D,O]=(0,o.useState)(S),[k,A]=(0,o.useState)(C),[j,N]=(0,o.useState)(w),[P,F]=(0,o.useState)(T),[I,L]=(0,o.useState)(E),[R,z]=(0,o.useState)(x.keepRatio),B=M(p,{getChildren:e=>l.getDrawingsByGroup(e)}),V=Wt(B),H=(e,t,n,r)=>{let{width:i,height:a}=b,{ancestorLeft:o,ancestorTop:s}=y,c=e,l=t,u=n,d=r;return e+o<0&&(c=-o),t+s<0&&(l=-s),u=Math.max(i-c-o,20),d=Math.max(a-l-s,20),e+u+o>i&&(c=i-n-o),t+d+s>a&&(l=a-r-s),{limitLeft:c,limitTop:l,limitWidth:u,limitHeight:d}},ee=e=>{let t=e.transform;if(t==null)return;let{width:n,height:r,left:i,top:a,angle:o}=t;n!=null&&O(n),r!=null&&A(r),i!=null&&N(i),a!=null&&F(a),o!=null&&L(o)},te=e=>{let t=q(e.objects,l);t.length===1&&t[0]!=null&&ee(t[0])};(0,o.useEffect)(()=>{let e=[x.changeStart$.subscribe(te),x.changing$.subscribe(te),x.changeEnd$.subscribe(te),l.focus$.subscribe(e=>{if(e.length!==1)return;let t=l.getDrawingByParam(e[0]);t!=null&&ee(t)})];return()=>e.forEach(e=>e.unsubscribe())},[]);let ne=e=>{l.featurePluginUpdateNotification([e]),x.refreshControls().changeNotification()},re=(0,t.debounce)(e=>{if(e==null)return;let{limitWidth:t,limitHeight:n}=H(j,P,e,k),r=Math.min(e,t),i={unitId:h,subUnitId:g,drawingId:_,drawingType:v,transform:{width:r}};if(R){let e=Math.max(r/D*k,20);if(e>n)return;A(e),i.transform.height=e}O(r),ne(i)},300),ie=(0,t.debounce)(e=>{if(e==null)return;let{limitHeight:t,limitWidth:n}=H(j,P,D,e),r=Math.min(e,t),i={unitId:h,subUnitId:g,drawingId:_,drawingType:v,transform:{height:r}};if(R){let e=Math.max(r/k*D,20);if(e>n)return;O(e),i.transform.width=e}A(r),ne(i)},300),ae=(0,t.debounce)(e=>{if(e==null)return;let{limitLeft:t}=H(e,P,D,k);N(t),ne({unitId:h,subUnitId:g,drawingId:_,drawingType:v,transform:{left:t}})},300),oe=(0,t.debounce)(e=>{if(e==null)return;let{limitTop:t}=H(j,e,D,k);F(t),ne({unitId:h,subUnitId:g,drawingId:_,drawingType:v,transform:{top:t}})},300),se=Gt({rotateEnabled:B,drawingParam:{unitId:h,subUnitId:g,drawingId:_,drawingType:v},setRotation:L,emitUpdate:e=>l.featurePluginUpdateNotification(e),notifyChange:()=>x.refreshControls().changeNotification()});return(0,c.jsxs)(`div`,{className:(0,s.clsx)(`univer-grid univer-gap-2 univer-py-2 univer-text-gray-400`,{"univer-hidden":!f}),children:[(0,c.jsx)(`header`,{className:`univer-text-gray-600 dark:!univer-text-gray-200`,children:(0,c.jsx)(`div`,{children:a.t(`drawing-ui.image-panel.transform.title`)})}),(0,c.jsxs)(`div`,{className:`univer-grid univer-grid-cols-3 univer-gap-2 [&>div]:univer-grid [&>div]:univer-gap-2`,children:[(0,c.jsxs)(`div`,{children:[(0,c.jsx)(`span`,{children:a.t(`drawing-ui.image-panel.transform.width`)}),(0,c.jsx)(Kt,{precision:1,value:D,min:20,onChange:re})]}),(0,c.jsxs)(`div`,{children:[(0,c.jsx)(`span`,{children:a.t(`drawing-ui.image-panel.transform.height`)}),(0,c.jsx)(Kt,{precision:1,value:k,min:20,onChange:ie})]}),(0,c.jsxs)(`div`,{children:[(0,c.jsx)(`span`,{children:a.t(`drawing-ui.image-panel.transform.lock`)}),(0,c.jsx)(`div`,{className:`univer-text-center`,children:(0,c.jsx)(qt,{checked:R,onChange:e=>{typeof e==`boolean`&&(z(e),x.keepRatio=e)}})})]})]}),(0,c.jsxs)(`div`,{className:`univer-grid univer-grid-cols-3 univer-gap-2 [&>div]:univer-grid [&>div]:univer-gap-2`,children:[(0,c.jsxs)(`div`,{children:[(0,c.jsx)(`span`,{children:a.t(`drawing-ui.image-panel.transform.x`)}),(0,c.jsx)(Kt,{precision:1,value:j,onChange:ae})]}),(0,c.jsxs)(`div`,{children:[(0,c.jsx)(`span`,{children:a.t(`drawing-ui.image-panel.transform.y`)}),(0,c.jsx)(Kt,{precision:1,value:P,onChange:oe})]}),(0,c.jsxs)(`div`,{children:[(0,c.jsx)(`span`,{children:a.t(`drawing-ui.image-panel.transform.rotate`)}),(0,c.jsx)(Kt,{precision:1,value:I,min:Ut[0],max:Ut[1],disabled:V,onChange:se})]})]})]})}function Zt(e){let n=(0,i.useDependency)(t.ICommandService),r=(0,i.useDependency)(t.LocaleService),{drawings:a,alignShow:d}=e,[f,p]=(0,o.useState)(`0`),m=[{label:r.t(`drawing-ui.image-panel.align.default`),value:`0`},{options:[{label:r.t(`drawing-ui.image-panel.align.left`),value:`1`},{label:r.t(`drawing-ui.image-panel.align.center`),value:`2`},{label:r.t(`drawing-ui.image-panel.align.right`),value:`3`}]},{options:[{label:r.t(`drawing-ui.image-panel.align.top`),value:`4`},{label:r.t(`drawing-ui.image-panel.align.middle`),value:`5`},{label:r.t(`drawing-ui.image-panel.align.bottom`),value:`6`}]},{options:[{label:r.t(`drawing-ui.image-panel.align.horizon`),value:`7`},{label:r.t(`drawing-ui.image-panel.align.vertical`),value:`8`}]}];return(0,c.jsxs)(`div`,{className:(0,s.clsx)(`univer-relative univer-w-full`,{"univer-hidden":!d}),children:[(0,c.jsx)(`header`,{className:`univer-text-gray-600 dark:!univer-text-gray-200`,children:(0,c.jsx)(`div`,{children:r.t(`drawing-ui.image-panel.align.title`)})}),(0,c.jsx)(`div`,{className:`univer-relative univer-mt-2.5 univer-flex univer-h-full`,children:(0,c.jsx)(`div`,{className:`univer-w-full univer-text-gray-900 dark:!univer-text-gray-0`,children:(0,c.jsx)(s.MobileSelect,{value:f,options:m,onChange:e=>{let t=Object.values(l).find(t=>t===e);t!=null&&(p(t),n.executeCommand(u.id,{alignType:t,drawings:a}))}})})})]})}function Qt(e){var o;let l=(0,i.useDependency)(t.LocaleService),u=(0,i.useDependency)(r.IRenderManagerService),d=(0,i.useDependency)(n.IDrawingManagerService),f=(0,i.useDependency)(t.ICommandService),p=(0,i.useDependency)(i.IconManager),{hasGroup:m,drawings:h}=e,g=p.get(`GroupIcon`),_=p.get(`UngroupIcon`),v=h[0],y=v?(o=u.getRenderUnitById(v.unitId))==null||(o=o.scene)==null?void 0:o.getTransformerByCreate():void 0,{groupShow:b,groupBtnShow:x,ungroupBtnShow:S}=(0,i.useObservable)(y?()=>(0,a.merge)(y.clearControl$.pipe((0,a.filter)(e=>e===!0),(0,a.map)(()=>({groupShow:!1,groupBtnShow:!1,ungroupBtnShow:!1}))),y.changeStart$.pipe((0,a.map)(e=>{let n=q(e.objects,d),r=n.length>1,i=n.some(e=>(e==null?void 0:e.drawingType)===t.DrawingTypeEnum.DRAWING_GROUP);return{groupShow:r||i,groupBtnShow:r,ungroupBtnShow:i}}))):null,{groupShow:!1,groupBtnShow:!0,ungroupBtnShow:!0},!1,[d,y]);return(0,c.jsxs)(`div`,{className:(0,s.clsx)(`univer-grid univer-gap-2 univer-py-2 univer-text-gray-400`,{"univer-hidden":m&&!b||!m}),children:[(0,c.jsx)(`header`,{className:`univer-text-gray-600 dark:!univer-text-gray-200`,children:(0,c.jsx)(`div`,{children:l.t(`drawing-ui.image-panel.group.title`)})}),(0,c.jsxs)(`div`,{className:`univer-flex univer-items-center univer-justify-center univer-gap-2`,children:[(0,c.jsxs)(Jt,{className:(0,s.clsx)({"univer-hidden":!x}),onClick:()=>f.syncExecuteCommand(T.id,{drawings:h}),children:[(0,c.jsx)(g,{}),l.t(`drawing-ui.image-panel.group.group`)]}),(0,c.jsxs)(Jt,{className:(0,s.clsx)({"univer-hidden":!S}),onClick:()=>f.syncExecuteCommand(E.id,{drawings:h}),children:[(0,c.jsx)(_,{}),l.t(`drawing-ui.image-panel.group.unGroup`)]})]})]})}function $t(e){let n=(0,i.useDependency)(t.ICommandService),r=(0,i.useDependency)(t.LocaleService),a=(0,i.useDependency)(De),s=(0,i.useDependency)(i.ComponentManager),c=(0,i.useObservable)(a.canUseShapeClip$,!1),{drawings:l,cropperShow:u}=e,d=l[0],[f,p]=(0,o.useState)(`0`),m=(0,o.useRef)(!1),h=[{label:r.t(`drawing-ui.image-panel.crop.mode`),value:`0`},{label:`1:1`,value:`1`},{label:`16:9`,value:`2`},{label:`9:16`,value:`3`},{label:`5:4`,value:`4`},{label:`4:5`,value:`5`},{label:`4:3`,value:`6`},{label:`3:4`,value:`7`},{label:`3:2`,value:`8`},{label:`2:3`,value:`9`}];(0,o.useEffect)(()=>{let e=n.onCommandExecuted(e=>{if(e.id===O.id){let t=e.params;t!=null&&t.isAuto||(m.current=!1)}});return()=>{e==null||e.dispose()}},[n]);function g(e){var t;let r=(t=h.find(t=>t.value===e))==null?void 0:t.value;r!=null&&(p(r),m.current&&n.executeCommand(k.id,{cropType:r}))}return{drawingParam:d,cropperShow:u,localeService:r,cropValue:f,cropOptions:h,handleCropChange:g,onCropperBtnClick:async t=>{var r;await n.executeCommand(k.id,{cropType:t}),m.current=!0,(r=e.onCropStart)==null||r.call(e)},ShapeClipPicker:c?s.get(Ee):void 0}}function en(e){let n=(0,i.useDependency)(t.LocaleService);return(0,c.jsxs)(`section`,{className:`univer-grid univer-gap-3 univer-py-3`,children:[(0,c.jsx)(`h3`,{className:`univer-m-0 univer-text-sm univer-font-medium`,children:n.t(`drawing-ui.image-panel.crop.title`)}),(0,c.jsx)(`div`,{className:`univer-grid univer-grid-cols-3 univer-gap-2`,children:e.cropOptions.map(t=>(0,c.jsx)(s.MobileActionRow,{title:t.label,variant:`subtle`,"aria-pressed":e.cropValue===t.value,className:`univer-px-2 univer-text-center aria-pressed:!univer-bg-primary-50 aria-pressed:!univer-text-primary-600`,onClick:()=>e.onCropChange(t.value)},t.value))}),(0,c.jsx)(s.MobileActionRow,{icon:(0,c.jsx)(nt,{}),title:n.t(`drawing-ui.image-panel.crop.start`),className:`!univer-bg-primary-600 !univer-text-white`,onClick:e.onStartCrop}),e.children]})}function tn(e){let{drawingParam:t,cropperShow:n,cropValue:r,cropOptions:i,handleCropChange:a,onCropperBtnClick:o,ShapeClipPicker:s}=$t(e);return!t||!n?null:(0,c.jsx)(en,{cropValue:r,cropOptions:i,onCropChange:a,onStartCrop:()=>o(r),children:s&&(0,c.jsx)(s,{})})}let nn=class extends t.Disposable{constructor(e,t){super(),this.disposeWithMe(e.register(Bt,Zt)),this.disposeWithMe(e.register(Vt,Qt)),this.disposeWithMe(e.register(zt,Yt)),this.disposeWithMe(e.register(Lt,Ht)),this.disposeWithMe(e.register(Rt,tn)),this.disposeWithMe(e.register(Ft,It)),this.disposeWithMe(t.register({BottomIcon:Ke,DrawingCropIcon:nt,DrawingDeleteIcon:it,DrawingEditIcon:ot,GroupIcon:mt,MoveDownIcon:xt,MoveUpIcon:Ct,TopmostIcon:Dt,UngroupIcon:kt}))}};nn=G([W(0,(0,t.Inject)(i.ComponentManager)),W(1,(0,t.Inject)(i.IconManager))],nn);function rn(e,t){let n={left:t.left-e.left,top:t.top-e.top,right:e.left+e.width-t.left-t.width,bottom:e.top+e.height-t.top-t.height},i={...n};if(e.angle){let n=new r.Vector2(e.left,e.top);n.rotateByPoint((0,r.degToRad)(e.angle),new r.Vector2(e.left+e.width/2,e.top+e.height/2)),n.rotateByPoint((0,r.degToRad)(-e.angle),new r.Vector2(t.left+t.width/2,t.top+t.height/2)),i.left=t.left-n.x,i.top=t.top-n.y,i.right=e.width-i.left-t.width,i.bottom=e.height-i.top-t.height}return{srcRect:n,srcRectAngle:i}}var Z=class extends r.Shape{constructor(e,t){t??={},t.transformerConfig={keepRatio:!1,isCropper:!0,anchorFill:`rgb(0, 0, 0)`,anchorStroke:`rgb(255, 255, 255)`,anchorSize:24},super(e,t),U(this,`_srcRect`,void 0),U(this,`_prstGeom`,void 0),U(this,`_applyTransform`,void 0),U(this,`_dragPadding`,8),U(this,`_cacheCanvas`,void 0),t!=null&&t.srcRect&&(this._srcRect=t.srcRect),t!=null&&t.prstGeom&&(this._prstGeom=t.prstGeom),t!=null&&t.applyTransform&&(this._applyTransform=t.applyTransform),t!=null&&t.dragPadding&&(this._dragPadding=t.dragPadding),this._applyProps()}refreshSrcRect(e,t){this._srcRect=e,this._applyTransform=t,this._applyProps()}get srcRect(){return this._srcRect}dispose(){var e;super.dispose(),(e=this._cacheCanvas)==null||e.dispose(),this._srcRect=null}isHit(e){let t=this.getInverseCoord(e);return t.x>=-this.strokeWidth/2&&t.x<=this.width+this.strokeWidth/2&&t.y>=-this.strokeWidth/2&&t.y<=this.height+this.strokeWidth/2&&!this._inSurround(t)}_inSurround(e){let t=this._dragPadding;return e.x>=t-this.strokeWidth/2&&e.x<=this.width+this.strokeWidth/2-t&&e.y>=t-this.strokeWidth/2&&e.y<=this.height+this.strokeWidth/2-t}render(e,t){return this.visible?(e.save(),this._draw(e),e.restore(),this.makeDirty(!1),this):(this.makeDirty(!1),this)}_draw(e){var t,n;let{width:i,height:a}=this.getScene().getEngine();this._initialCacheCanvas(),(t=this._cacheCanvas)==null||t.clear();let o=(n=this._cacheCanvas)==null?void 0:n.getContext();o!=null&&(o.save(),r.Rect.drawWith(o,{left:0,top:0,width:i,height:a,fill:`rgba(0, 0, 0, 0.5)`}),o.setTransform(e.getTransform()),this._clipForApplyObject(o),this._applyCache(e),o.restore())}_clipForApplyObject(e){let t=0;if(this._prstGeom!=null&&(t=1),e.globalCompositeOperation=`destination-out`,e.beginPath(),t===0){let t=this.transform.getMatrix();e.transform(t[0],t[1],t[2],t[3],t[4],t[5]),e.rect(0,0,this.width,this.height),e.fill()}}_applyProps(){if(this._applyTransform==null)return;let e=0,t=0,n=0,r=0,{left:i=0,top:a=0,width:o=0,height:s=0,angle:c}=this._applyTransform;if(this._srcRect!=null){let{left:i=0,top:a=0,right:o=0,bottom:s=0}=this._srcRect;e=i,t=a,n=o,r=s}let l=i+e,u=a+t;this.transformByState({left:l,top:u,width:i+o-n-l,height:a+s-r-u,angle:c})}_applyCache(e){if(!e||this._cacheCanvas==null)return;let t=this._cacheCanvas.getContext();t.save(),e.save(),e.setTransform(1,0,0,1,0,0),t.setTransform(1,0,0,1,0,0),e.drawImage(this._cacheCanvas.getCanvasEle(),0,0),e.restore(),t.restore()}_initialCacheCanvas(){if(this._cacheCanvas!=null)return;let e=this.getScene();if(e==null)return;this._cacheCanvas=new r.Canvas;let t=e.getEngine();this._cacheCanvas.setSize(t.width,t.height),t.onTransformChange$.subscribeEvent(()=>{var e;(e=this._cacheCanvas)==null||e.setSize(t.width,t.height),this.makeDirty(!0)})}};let an=class extends t.Disposable{constructor(e,n,r,i,o,s,c,l){super(),this._commandService=e,this._drawingManagerService=n,this._renderManagerService=r,this._univerInstanceService=i,this._messageService=o,this._localeService=s,this._shortcutService=c,this._layoutService=l,U(this,`_sceneListenerOnImageMap`,new WeakSet),U(this,`_cropShortcutDisposables`,new t.DisposableCollection),U(this,`_cropSnapshots`,new WeakMap),U(this,`_pendingCropSnapshot`,null),U(this,`_activeCropSession`,null),U(this,`_cropping$`,new a.BehaviorSubject(!1)),U(this,`cropping$`,this._cropping$.asObservable()),this.disposeWithMe(this._cropShortcutDisposables),this.disposeWithMe({dispose:()=>this._cropping$.complete()}),this._init()}_init(){this._initOpenCrop(),this._initCloseCrop(),this._initAutoCrop()}_initAutoCrop(){this.disposeWithMe(this._commandService.onCommandExecuted(e=>{var t;if(e.id!==k.id)return;let i=e.params;if(i==null)return;let a=this._drawingManagerService.getFocusDrawings();if(a.length!==1)return;let{cropType:o}=i,{unitId:c,subUnitId:l,drawingId:u}=a[0],d=(t=this._renderManagerService.getRenderUnitById(c))==null?void 0:t.scene;if(d==null)return!0;this._searchCropObject(d)!=null&&this._commandService.syncExecuteCommand(O.id,{isAuto:!0});let f=(0,n.getDrawingShapeKeyByDrawingSearch)({unitId:c,subUnitId:l,drawingId:u}),p=d.getObject(f);if(!(p instanceof r.Image)){this._messageService.show({type:s.MessageType.Error,content:this._localeService.t(`drawing-ui.image-cropper.error`)});return}this._pendingCropSnapshot=this._captureCropSnapshot(p);try{this._updateCropperObject(o,p),this._commandService.syncExecuteCommand(D.id,{unitId:c,subUnitId:l,drawingId:u})}finally{this._pendingCropSnapshot=null}}))}_calculateSrcRectByRatio(e,t,n,i,a,o){let s=n/i,c=a/o,l=n,u=i;s>c?l=i*c:u=n/c;let d=(n-l)/2,f=(i-u)/2;return{left:(0,r.precisionTo)(d,1),top:(0,r.precisionTo)(f,1),right:(0,r.precisionTo)(n-(d+l),1),bottom:(0,r.precisionTo)(i-(f+u),1)}}_updateCropperObject(e,t){let{left:n,top:r,width:i,height:a}=t.calculateTransformWithSrcRect(),o;switch(e){case`1`:o=this._calculateSrcRectByRatio(n,r,i,a,1,1);break;case`2`:o=this._calculateSrcRectByRatio(n,r,i,a,16,9);break;case`3`:o=this._calculateSrcRectByRatio(n,r,i,a,9,16);break;case`4`:o=this._calculateSrcRectByRatio(n,r,i,a,5,4);break;case`5`:o=this._calculateSrcRectByRatio(n,r,i,a,4,5);break;case`6`:o=this._calculateSrcRectByRatio(n,r,i,a,4,3);break;case`7`:o=this._calculateSrcRectByRatio(n,r,i,a,3,4);break;case`8`:o=this._calculateSrcRectByRatio(n,r,i,a,3,2);break;case`9`:o=this._calculateSrcRectByRatio(n,r,i,a,2,3)}if(o==null)return;t.setSrcRect(o);let{left:s=0,top:c=0,bottom:l=0,right:u=0}=o;t.transformByStateCloseCropper({left:n+s,top:r+c,width:i-u-s,height:a-l-c})}_initOpenCrop(){this.disposeWithMe(this._commandService.onCommandExecuted(e=>{var t;if(e.id!==D.id)return;let i=e.params;if(i==null)return;this._activeCropSession!=null&&this._commandService.syncExecuteCommand(O.id,{isAuto:!0});let{unitId:a,subUnitId:o,drawingId:c}=i,l=(t=this._renderManagerService.getRenderUnitById(a))==null?void 0:t.scene;if(l==null)return!0;if(this._sceneListenerOnImageMap.has(l)||(this._addListenerOnImage(l),this._sceneListenerOnImageMap.add(l)),this._drawingManagerService.getDrawingByParam({unitId:a,subUnitId:o,drawingId:c})==null)return;let u=(0,n.getDrawingShapeKeyByDrawingSearch)({unitId:a,subUnitId:o,drawingId:c}),d=l.getObject(u);if(!(d instanceof r.Image)){this._messageService.show({type:s.MessageType.Error,content:this._localeService.t(`drawing-ui.image-cropper.error`)});return}let f=l.getTransformer();f==null||f.clearControls();let p=new Z(`${u}-crop`,{srcRect:d.srcRect,prstGeom:d.prstGeom,applyTransform:d.calculateTransformWithSrcRect()});p.transformerConfig={...p.transformerConfig,cropAnchorHitSize:44},this._cropSnapshots.set(p,this._pendingCropSnapshot??this._captureCropSnapshot(d)),this._pendingCropSnapshot=null,l.addObject(p,d.getLayerIndex()+1).attachTransformerTo(p),this._activeCropSession={scene:l,imageShape:d,imageCropperObject:p},this._cropping$.next(!0),f==null||f.createControlForCopper(p),this._addHoverForImageCopper(p),d.openRenderByCropper(),f==null||f.refreshControls(),p.makeDirty(!0),this._registerCropShortcuts(p),this._commandService.syncExecuteCommand(n.SetDrawingSelectedOperation.id,[{unitId:a,subUnitId:o,drawingId:c}]),this._layoutService.focus()}))}_searchCropObject(e){for(let t of e.getAllObjectsByOrder())if(t instanceof Z)return t}_initCloseCrop(){this.disposeWithMe(this._commandService.onCommandExecuted(e=>{if(e.id!==O.id)return;let t=this._activeCropSession;if(t==null)return;this._activeCropSession=null;let{scene:n,imageShape:r,imageCropperObject:i}=t,a=n.getTransformerByCreate();a.detachFrom(i),a.clearCopperControl();let o=e.params;if(o!=null&&o.isCancel)this._restoreCropSnapshot(r,i);else{let e=rn(r,i),t=this._drawingManagerService.getDrawingOKey(r.oKey);if(t!=null){let{left:n,top:r,height:a,width:o}=i;this._drawingManagerService.featurePluginUpdateNotification([{...t,transform:{...t.transform,left:n,top:r,height:a,width:o},srcRect:e.srcRectAngle}])}r.setSrcRect({...e.srcRectAngle})}r.closeRenderByCropper(),r.makeDirty(!0),a.refreshControls(),this._cropSnapshots.delete(i),i.dispose(),this._cropping$.next(!1),this._cropShortcutDisposables.dispose()}));let e=this._univerInstanceService.getCurrentTypeOfUnit$(t.UniverInstanceType.UNIVER_SHEET).pipe((0,a.switchMap)(e=>e?e.activeSheet$:(0,a.of)(null)));this.disposeWithMe(e.subscribe(()=>{this._activeCropSession!=null&&this._commandService.syncExecuteCommand(O.id)}))}_getApplyObjectByCropObject(e){let t=e.oKey.slice(0,e.oKey.length-5),n=e.getScene();return n?n.getObject(t)??null:null}_captureCropSnapshot(e){return{transform:e.getState(),srcRect:e.srcRect==null?e.srcRect:{...e.srcRect}}}_restoreCropSnapshot(e,t){let n=this._cropSnapshots.get(t);n&&(e.transformByStateCloseCropper(n.transform),e.setSrcRect(n.srcRect))}_registerCropShortcuts(e){this._cropShortcutDisposables.dispose(),this._cropShortcutDisposables.add(e.onDispose$.subscribeEvent(()=>{this._activeCropSession=null,this._cropping$.next(!1),this._cropShortcutDisposables.dispose()})),this._cropShortcutDisposables.add(this._shortcutService.registerShortcut({id:O.id,binding:i.KeyCode.ENTER,priority:1e3})),this._cropShortcutDisposables.add(this._shortcutService.registerShortcut({id:O.id,binding:i.KeyCode.ESC,priority:1e3,staticParameters:{isCancel:!0}}))}_addListenerOnImage(e){let n=e.getTransformerByCreate(),r=null;this.disposeWithMe(n.changeStart$.subscribe(e=>{let t=e.objects.values().next().value;if(!(t instanceof Z))return;let{left:i,top:a,height:o,width:s,angle:c}=t;r={left:i,top:a,height:o,width:s,angle:c},n.clearCopperControl()})),this.disposeWithMe(n.changeEnd$.subscribe(e=>{let i=e.objects.values().next().value;if(!(i instanceof Z))return;let{left:a,top:o,height:s,width:c,angle:l}=i;if(!(0,t.checkIfMove)({left:a,top:o,height:s,width:c,angle:l},r)){n.createControlForCopper(i);return}let u=this._getApplyObjectByCropObject(i);if(u==null)return;let d=rn(u,i);i.refreshSrcRect(d.srcRect,u.getState()),n.createControlForCopper(i)})),this._endCropListener(e)}_addHoverForImageCopper(e){this.disposeWithMe(e.onPointerEnter$.subscribeEvent(()=>{e.cursor=r.CURSOR_TYPE.MOVE})),this.disposeWithMe(e.onPointerLeave$.subscribeEvent(()=>{e.cursor=r.CURSOR_TYPE.DEFAULT}))}_endCropListener(e){let t=e.getTransformerByCreate();this.disposeWithMe(t.clearControl$.subscribe(e=>{e===!0&&this._commandService.syncExecuteCommand(O.id)}))}};an=G([W(0,t.ICommandService),W(1,n.IDrawingManagerService),W(2,r.IRenderManagerService),W(3,t.IUniverInstanceService),W(4,i.IMessageService),W(5,(0,t.Inject)(t.LocaleService)),W(6,i.IShortcutService),W(7,i.ILayoutService)],an);var on=class extends r.Rect{constructor(e,n,i,a){super(`${e.oKey}-mobile-preview`,{width:44,height:44}),this._image=e,this._scene=n,U(this,`_enabled`,!0),U(this,`_icon`,document.createElement(`img`)),U(this,`_iconContainer`,document.createElement(`div`)),U(this,`_gesture`,new t.DisposableCollection),U(this,`_pressed`,!1),U(this,`_background`,``),U(this,`_border`,``),U(this,`_pressedBackground`,``),this.cursor=r.CURSOR_TYPE.POINTER,this.disposeWithMe(this._gesture),this.disposeWithMe(e.onDispose$.subscribeEvent(()=>this.dispose())),this.disposeWithMe(e.onTransformChange$.subscribeEvent(()=>this._syncPosition())),this.disposeWithMe(n.onTransformChange$.subscribeEvent(()=>this._syncPosition())),this.disposeWithMe(n.beforeRender$.subscribe(()=>this._syncPosition())),this.disposeWithMe(i.currentTheme$.subscribe(()=>{this._background=i.getColorFromTheme(`white`),this._border=i.getColorFromTheme(`gray.200`),this._pressedBackground=i.getColorFromTheme(`gray.100`),(0,s.render)((0,o.createElement)(ct,{width:20,height:20,color:i.getColorFromTheme(`gray.900`),ref:e=>{e&&(this._icon.src=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(new XMLSerializer().serializeToString(e))}`)}}),this._iconContainer),this.makeDirty(!0)})),this._icon.onload=()=>this.makeDirty(!0),this.disposeWithMe(()=>{this._icon.onload=null,(0,s.unmount)(this._iconContainer)}),this.disposeWithMe(this.onPointerDown$.subscribeEvent(e=>{this._gesture.dispose();let t={x:e.offsetX,y:e.offsetY,time:Date.now()},r=!1;this._setPressed(!0),this._gesture.add(n.onPointerDown$.subscribeEvent(t=>{t!==e&&(r=!0,this._setPressed(!1))})),this._gesture.add(n.onPointerMove$.subscribeEvent(e=>{r||=Math.hypot(e.offsetX-t.x,e.offsetY-t.y)>=12,r&&this._setPressed(!1)})),this._gesture.add(n.onPointerCancel$.subscribeEvent(()=>{this._gesture.dispose(),this._setPressed(!1)})),this._gesture.add(n.onPointerUp$.subscribeEvent(e=>{this._gesture.dispose(),this._setPressed(!1),!r&&this.visible&&Date.now()-t.time<500&&Math.hypot(e.offsetX-t.x,e.offsetY-t.y)<12&&a()}))})),this.disposeWithMe(this.onClick$.subscribeEvent((e,t)=>t.stopPropagation())),this.disposeWithMe(this.onDblclick$.subscribeEvent((e,t)=>t.stopPropagation())),n.addObject(this,e.getLayerIndex()),this._syncPosition()}setPreviewEnabled(e){this._enabled=e,this._syncPosition()}dispose(){this._disposed||super.dispose()}_setPressed(e){this._pressed=e,this.makeDirty(!0)}_syncPosition(){let{scaleX:e,scaleY:t}=this._scene.getAncestorScale(),n=44/Math.max(e,.01),i=44/Math.max(t,.01),a=this._enabled&&this._image.visible&&!this._image.isInGroup&&this._image.width>=n&&this._image.height>=i;if(a!==this.visible&&(a?this.show():this.hide()),!a)return;this.layer&&this.getLayerIndex()!==this._image.getLayerIndex()&&(this._scene.removeObject(this),this._scene.addObject(this,this._image.getLayerIndex()));let o=this._image.ancestorTransform.applyPoint(new r.Vector2(this._image.width,0)),s=o.x-n,c=o.y;(s!==this.left||c!==this.top||n!==this.width||i!==this.height)&&this.transformByState({left:s,top:c,width:n,height:i}),this.zIndex!==this._image.zIndex+.5&&(this.zIndex=this._image.zIndex+.5)}_draw(e){e.save(),e.scale(this.width/44,this.height/44),e.translate(6,6),r.Rect.drawWith(e,{width:32,height:32,radius:8,fill:this._pressed?this._pressedBackground:this._background,stroke:this._border,strokeWidth:1}),this._icon.complete&&this._icon.naturalWidth>0&&e.drawImage(this._icon,6,6,20,20),e.restore()}};let sn=class extends t.Disposable{constructor(e,t,n,r,i,a,o){super(),this._commandService=e,this._renderManagerService=t,this._drawingManagerService=n,this._currentUniverService=r,this._drawingRenderService=i,this._themeService=a,this._imageCropperController=o,this._initialize()}_initialize(){this._drawingAddListener(),this._commandExecutedListener(),this._imageUpdateListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.onCommandExecuted(e=>{if(e.id===A.id){let t=e.params;if(t==null)return;this._resetImageSize(t)}}))}_getSceneAndTransformerByDrawingSearch(e){if(e==null)return;let t=this._renderManagerService.getRenderUnitById(e),n=t==null?void 0:t.scene;return n==null?null:{scene:n,transformer:n.getTransformerByCreate()}}_resetImageSize(e){let r=[],i=[];e.forEach(e=>{let{unitId:a,subUnitId:o,drawingId:s}=e,c=this._getSceneAndTransformerByDrawingSearch(a);if(c==null)return;let{scene:l}=c,u=(0,n.getDrawingShapeKeyByDrawingSearch)({unitId:a,subUnitId:o,drawingId:s}),d=l.getObject(u);if(d==null)return!0;let f=this._drawingManagerService.getDrawingByParam(e);if(f==null)return!0;if(f.drawingType!==t.DrawingTypeEnum.DRAWING_IMAGE)return;d.resetSize();let{width:p,height:m}=d.getNativeSize();i.includes(l)||i.push(l),r.push({...f,transform:{...f.transform,height:m,width:p,angle:0},srcRect:null,prstGeom:null})}),this._drawingManagerService.featurePluginUpdateNotification(r),i.forEach(e=>{e.getTransformerByCreate().refreshControls().changeNotification()}),this._commandService.syncExecuteCommand(n.SetDrawingSelectedOperation.id,e)}_drawingAddListener(){this.disposeWithMe(this._drawingManagerService.add$.pipe((0,a.bufferTime)(33),(0,a.filter)(e=>e.length>0),(0,a.map)(e=>e.flat()),(0,a.map)(e=>{let t=new Map;for(let n of e)t.set(`${n.unitId}|${n.subUnitId}|${n.drawingId}`,n);return[...t.values()]}),(0,a.filter)(e=>e.length>0)).subscribe(e=>{this._insertImages(e)}))}_insertImages(e){e.forEach(async e=>{var t;let{unitId:n,subUnitId:r}=e,i=this._getSceneAndTransformerByDrawingSearch(n),a=(t=R(this._currentUniverService,n))==null?void 0:t.subUnitId;if(i==null||a!==r)return;let o=this._drawingManagerService.getDrawingByParam(e);if(o==null)return;let s=await this._drawingRenderService.renderImages(o,i.scene),c=this._drawingManagerService.getDrawingByParam(e);if(c&&this._drawingManagerService.refreshTransform([c]),s!=null&&s.length!==0)for(let t of s)this._addHoverForImage(t),this._addDialogForImage(t,e)})}_imageUpdateListener(){this.disposeWithMe(this._drawingManagerService.update$.subscribe(e=>{e.forEach(e=>{var r;let{unitId:i,subUnitId:a,drawingId:o}=e,s=this._drawingManagerService.getDrawingByParam(e);if(s==null)return;let{transform:c,drawingType:l,srcRect:u,prstGeom:d,source:f,imageSourceType:p}=s;if(l!==t.DrawingTypeEnum.DRAWING_IMAGE)return;let m=this._getSceneAndTransformerByDrawingSearch(i);if(m==null)return;let{scene:h}=m;if(c==null)return!0;let g=(0,n.getDrawingShapeKeyByDrawingSearch)({unitId:i,subUnitId:a,drawingId:o}),_=h.getObject(g);if(_==null)return!0;let{left:v=0,top:y=0,width:b=0,height:x=0,angle:S=0,flipX:C=!1,flipY:w=!1,skewX:T=0,skewY:E=0}=c;_.transformByState({left:v,top:y,width:b,height:x,angle:S,flipX:C,flipY:w,skewX:T,skewY:E}),(r=_.setClipBounds)==null||r.call(_,c.clipBounds),ke(h,_,s),_.setSrcRect(u),_.setPrstGeom(d),f!=null&&f.length>0&&(p===t.ImageSourceType.BASE64||p===t.ImageSourceType.URL)&&_.changeSource(f)})}))}_addHoverForImage(e){this.disposeWithMe((0,t.toDisposable)(e.onPointerEnter$.subscribeEvent(()=>{e.cursor=r.CURSOR_TYPE.GRAB}))),this.disposeWithMe((0,t.toDisposable)(e.onPointerLeave$.subscribeEvent(()=>{e.cursor=r.CURSOR_TYPE.DEFAULT})))}_addDialogForImage(e,n){let r=()=>{let t=e.getNative();t&&this._drawingRenderService.previewImage(`${e.oKey}-viewer-dialog`,t.src,e.getNativeSize().width,e.getNativeSize().height)},i=e.getScene();if(i){let t=new on(e,i,this._themeService,r),o=this.disposeWithMe(()=>t.dispose());t.disposeWithMe(()=>o.dispose()),t.disposeWithMe((0,a.combineLatest)([this._drawingManagerService.focus$,this._imageCropperController.cropping$]).subscribe(([e,r])=>{t.setPreviewEnabled(!r&&!e.some(e=>e.unitId===n.unitId&&e.subUnitId===n.subUnitId&&e.drawingId===n.drawingId))}))}this.disposeWithMe((0,t.toDisposable)(e.onDblclick$.subscribeEvent(r)))}};sn=G([W(0,t.ICommandService),W(1,r.IRenderManagerService),W(2,n.IDrawingManagerService),W(3,t.IUniverInstanceService),W(4,(0,t.Inject)(K)),W(5,(0,t.Inject)(t.ThemeService)),W(6,(0,t.Inject)(an))],sn);function cn(){let e=(0,i.useDependency)(t.ICommandService),n=(0,i.useDependency)(t.LocaleService),r=(0,i.useDependency)(an);return(0,i.useObservable)(r.cropping$,!1)?(0,c.jsxs)(`div`,{role:`group`,"aria-label":n.t(`drawing-ui.image-panel.crop.title`),className:`univer-absolute univer-inset-x-0 univer-bottom-0 univer-z-[1200] univer-grid univer-grid-cols-2 univer-gap-3 univer-bg-gray-0 univer-p-3 univer-pb-[max(12px,env(safe-area-inset-bottom))] univer-shadow-lg dark:!univer-bg-gray-900`,children:[(0,c.jsx)(s.MobileActionRow,{icon:(0,c.jsx)(Qe,{}),title:n.t(`drawing-ui.image-panel.crop.cancel`),variant:`subtle`,onClick:()=>e.executeCommand(O.id,{isCancel:!0})}),(0,c.jsx)(s.MobileActionRow,{icon:(0,c.jsx)(Xe,{}),title:n.t(`drawing-ui.image-panel.crop.apply`),className:`!univer-bg-primary-600 !univer-text-white`,onClick:()=>e.executeCommand(O.id)})]}):null}let ln=class extends t.Disposable{constructor(e,t,n,r){super(),this._commandService=e,this._menuManagerService=t,this._uiPartsService=n,this._injector=r,this._initMenus(),this._initCommands(),this._initUiParts()}_initMenus(){this._menuManagerService.mergeMenu(ve)}_initCommands(){[D,O,A,u,d,f,p,m,h,g,_,v,k,T,E,y,b,x,S,C].forEach(e=>this.disposeWithMe(this._commandService.registerCommand(e)))}_initUiParts(){this.disposeWithMe(this._uiPartsService.registerComponent(i.BuiltInUIPart.CONTENT,()=>(0,i.connectInjector)(cn,this._injector)))}};ln=G([W(0,t.ICommandService),W(1,i.IMenuManagerService),W(2,i.IUIPartsService),W(3,(0,t.Inject)(t.Injector))],ln);let un=class extends t.Plugin{constructor(e=Se,n,r){super(),this._config=e,this._injector=n,this._configService=r;let{menu:i,...a}=(0,t.merge)({},Se,this._config);i&&this._configService.setConfig(`menu`,i,{merge:!0}),this._configService.setConfig(xe,a)}onStarting(){this._injector.add([nn]),this._injector.get(nn),this._initDependencies()}onRendered(){this._injector.get(J),this._injector.get(ln),this._injector.get(an),this._injector.get(sn)}_initDependencies(){[[De],[K],[J],[ln],[an],[sn]].forEach(e=>this._injector.add(e))}};U(un,`pluginName`,`UNIVER_DRAWING_UI_PLUGIN`),U(un,`packageName`,ye),U(un,`version`,be),un=G([(0,t.DependentOn)(n.UniverDrawingPlugin,r.UniverRenderEnginePlugin),W(1,(0,t.Inject)(t.Injector)),W(2,t.IConfigService)],un);function dn(e){var n,r,a;let{popup:l}=e,u=l==null||(n=l.extraProps)==null?void 0:n.menuItems,d=(0,i.useDependency)(t.ICommandService),f=(0,i.useDependency)(t.LocaleService),[p,m]=(0,o.useState)(!1),[h,g]=(0,o.useState)(!1);if(!u)return null;if(((r=l.extraProps)==null?void 0:r.variant)===`doc-floating-toolbar`&&l.extraProps.unitId&&l.extraProps.subUnitId&&l.extraProps.drawingId)return(0,c.jsx)(gn,{menuItems:u,unitId:l.extraProps.unitId,subUnitId:l.extraProps.subUnitId,drawingId:l.extraProps.drawingId});if(((a=l.extraProps)==null?void 0:a.variant)===`doc-chart-floating-toolbar`)return(0,c.jsx)(_n,{menuItems:u});let _=()=>{g(!0)},v=()=>{g(!1)},y=e=>{m(e)},b=e=>{d.executeCommand(e.commandId,e.commandParams),m(!1)},x=p||h;return(0,c.jsx)(`div`,{onMouseEnter:_,onMouseLeave:v,children:(0,c.jsx)(s.DropdownMenu,{align:`start`,items:u.map(e=>({type:`item`,children:f.t(e.label),disabled:e.disable,onSelect:()=>b(e)})),open:p,onOpenChange:y,children:(0,c.jsxs)(`div`,{className:(0,s.clsx)(`univer-flex univer-items-center univer-gap-2 univer-rounded univer-p-1 univer-text-gray-900 hover:univer-bg-gray-100 dark:hover:!univer-bg-gray-800`,s.borderClassName,{"univer-bg-gray-100 dark:!univer-bg-gray-800":p,"univer-bg-gray-0 dark:!univer-bg-gray-900":!p}),children:[(0,c.jsx)(Nt,{className:`univer-fill-primary-600 univer-text-gray-900 dark:!univer-text-gray-0`}),x&&(0,c.jsx)(X,{className:`dark:!univer-text-gray-0`})]})})})}function fn(e,n){var r;let i=e==null||(r=e.getSnapshot().drawings)==null?void 0:r[n];return i?i.layoutType===t.PositionedObjectLayoutType.WRAP_NONE?i.behindDoc===t.BooleanNumber.TRUE?`behindText`:`inFrontOfText`:i.layoutType===t.PositionedObjectLayoutType.WRAP_SQUARE?`wrapSquare`:i.layoutType===t.PositionedObjectLayoutType.WRAP_TOP_AND_BOTTOM?`wrapTopAndBottom`:`inline`:`inline`}function pn(e){return(0,c.jsx)(`div`,{className:`univer-flex univer-h-7 univer-items-center univer-gap-1 univer-px-1`,children:e.children})}function mn(e){return(0,c.jsx)(s.Tooltip,{className:`univer-fill-mode-backwards univer-delay-100`,title:e.title,placement:`bottom`,children:(0,c.jsx)(`button`,{type:`button`,disabled:e.disabled,onClick:e.onClick,className:(0,s.clsx)(`univer-flex univer-h-6 univer-w-6 univer-items-center univer-justify-center univer-rounded-md univer-border-none univer-bg-transparent univer-p-0 univer-text-sm univer-text-gray-700 univer-transition-colors hover:univer-bg-gray-100 disabled:univer-cursor-not-allowed disabled:univer-opacity-40 dark:!univer-text-gray-100 dark:hover:!univer-bg-gray-700`,{"univer-bg-gray-100 univer-text-primary-600 dark:!univer-bg-gray-700 dark:!univer-text-primary-300":e.active}),children:e.children})})}function hn(e){let[t,n]=(0,o.useState)(!1),r=e.options.find(t=>t.value===e.value)??e.options[0];return(0,c.jsx)(s.Dropdown,{open:t,onOpenChange:n,overlay:(0,c.jsx)(`div`,{className:`univer-min-w-32 univer-rounded-lg univer-border univer-border-solid univer-border-gray-200 univer-bg-gray-0 univer-p-1 univer-shadow-lg dark:!univer-border-gray-700 dark:!univer-bg-gray-900`,children:e.options.map(t=>(0,c.jsxs)(`button`,{type:`button`,onClick:()=>{e.onChange(t.value),n(!1)},className:(0,s.clsx)(`univer-flex univer-h-8 univer-w-full univer-items-center univer-gap-2 univer-rounded-md univer-border-none univer-bg-transparent univer-px-2 univer-text-left univer-text-sm univer-text-gray-700 univer-transition-colors hover:univer-bg-gray-100 dark:!univer-text-gray-100 dark:hover:!univer-bg-gray-800`,{"univer-bg-primary-50 univer-text-primary-600 dark:!univer-bg-gray-800 dark:!univer-text-primary-300":t.value===e.value}),children:[(0,c.jsx)(`span`,{className:`univer-flex univer-size-4 univer-items-center univer-justify-center`,children:t.icon}),(0,c.jsx)(`span`,{className:`univer-flex-1`,children:t.label})]},t.value))}),children:(0,c.jsx)(`span`,{children:(0,c.jsx)(s.Tooltip,{className:`univer-fill-mode-backwards univer-delay-100`,title:e.title,placement:`bottom`,children:(0,c.jsxs)(`button`,{type:`button`,className:(0,s.clsx)(`univer-flex univer-h-6 univer-min-w-9 univer-items-center univer-justify-center univer-gap-1 univer-rounded-md univer-border-none univer-bg-transparent univer-px-1.5 univer-text-sm univer-text-gray-700 univer-transition-colors hover:univer-bg-gray-100 dark:!univer-text-gray-100 dark:hover:!univer-bg-gray-700`,{"univer-bg-gray-100 univer-text-primary-600 dark:!univer-bg-gray-700 dark:!univer-text-primary-300":t}),children:[r.icon,(0,c.jsx)(X,{className:`univer-text-xs`})]})})})})}function gn(e){var n;let r=(0,i.useDependency)(t.ICommandService),a=(0,i.useDependency)(i.IconManager),l=(0,i.useDependency)(t.LocaleService),u=(0,i.useDependency)(t.IUniverInstanceService).getUnit(e.unitId,t.UniverInstanceType.UNIVER_DOC)??void 0,[d,f]=(0,o.useState)(()=>fn(u,e.drawingId)),[p,m]=(0,o.useState)(!1),h=e.menuItems.filter(e=>e.type!==`select`&&e.icon).sort((e,t)=>e.index-t.index),g=[{label:l.t(`drawing-ui.image-text-wrap.inline`),value:`inline`,icon:(0,c.jsx)(Tt,{})},{label:l.t(`drawing-ui.image-text-wrap.square`),value:`wrapSquare`,icon:(0,c.jsx)(Tt,{})},{label:l.t(`drawing-ui.image-text-wrap.topAndBottom`),value:`wrapTopAndBottom`,icon:(0,c.jsx)(Tt,{})},{label:l.t(`drawing-ui.image-text-wrap.behindText`),value:`behindText`,icon:(0,c.jsx)(Tt,{})},{label:l.t(`drawing-ui.image-text-wrap.inFrontText`),value:`inFrontOfText`,icon:(0,c.jsx)(Tt,{})}],_=e=>{e&&!e.disable&&(e.hideOnClick&&m(!0),r.executeCommand(e.commandId,e.commandParams))};return p?null:(0,c.jsxs)(`div`,{"data-u-comp":`doc-image-floating-toolbar`,onPointerDown:e=>e.stopPropagation(),onMouseDown:e=>{e.stopPropagation(),e.preventDefault()},className:(0,s.clsx)(`univer-box-border univer-flex univer-items-center univer-rounded univer-bg-gray-0 univer-px-1 univer-py-1 univer-shadow-sm dark:!univer-border-gray-700 dark:!univer-bg-gray-900`,s.borderClassName),children:[(0,c.jsx)(pn,{children:(0,c.jsx)(hn,{title:((n=g.find(e=>e.value===d))==null?void 0:n.label)??l.t(`drawing-ui.image-text-wrap.inline`),value:d,options:g,onChange:t=>{f(t),r.executeCommand(`doc.command.update-doc-drawing-wrapping-style`,{unitId:e.unitId,subUnitId:e.subUnitId,drawings:[{unitId:e.unitId,subUnitId:e.subUnitId,drawingId:e.drawingId}],wrappingStyle:t})}})}),h.length>0&&(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(s.Separator,{orientation:`vertical`}),(0,c.jsx)(pn,{children:h.map(e=>{let t=a.get(e.icon);return(0,c.jsx)(mn,{title:l.t(e.label),disabled:e.disable,onClick:()=>_(e),children:(0,c.jsx)(t,{})},`${e.commandId}-${e.index}`)})})]})]})}function _n(e){var n;let r=(0,i.useDependency)(t.ICommandService),a=(0,i.useDependency)(i.IconManager),l=(0,i.useDependency)(t.LocaleService),[u,d]=(0,o.useState)(!1),f=e.menuItems.find(e=>e.type===`select`),p=e.menuItems.filter(e=>e.type!==`select`&&e.icon).sort((e,t)=>e.index-t.index),m=((f==null?void 0:f.options)??[]).map(e=>{let t=e.icon?a.get(e.icon):Je;return{label:String(e.label),value:e.value,icon:(0,c.jsx)(t,{})}}),h=e=>{e&&!e.disable&&(e.hideOnClick&&d(!0),r.executeCommand(e.commandId,e.commandParams))};return u?null:(0,c.jsxs)(`div`,{"data-u-comp":`doc-chart-floating-toolbar`,onPointerDown:e=>e.stopPropagation(),onMouseDown:e=>{e.stopPropagation(),e.preventDefault()},className:(0,s.clsx)(`univer-box-border univer-flex univer-items-center univer-rounded univer-bg-gray-0 univer-px-1 univer-py-1 univer-shadow-sm dark:!univer-border-gray-700 dark:!univer-bg-gray-900`,s.borderClassName),children:[f&&(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(pn,{children:(0,c.jsx)(hn,{title:l.t(f.label),value:f.value??((n=m[0])==null?void 0:n.value)??``,options:m,onChange:e=>{if(!f.disable){var t;r.executeCommand(f.commandId,(t=f.commandParamsFactory)==null?void 0:t.call(f,e))}}})}),p.length>0&&(0,c.jsx)(s.Separator,{orientation:`vertical`})]}),p.length>0&&(0,c.jsx)(pn,{children:p.map(e=>{let t=a.get(e.icon);return(0,c.jsx)(mn,{title:l.t(e.label),disabled:e.disable,onClick:()=>h(e),children:(0,c.jsx)(t,{})},`${e.commandId}-${e.index}`)})})]})}let vn=e=>{let n=(0,i.useDependency)(t.ICommandService),r=(0,i.useDependency)(t.LocaleService),{drawings:a,alignShow:d}=e,[f,p]=(0,o.useState)(`0`),m=[{label:r.t(`drawing-ui.image-panel.align.default`),value:`0`},{options:[{label:r.t(`drawing-ui.image-panel.align.left`),value:`1`},{label:r.t(`drawing-ui.image-panel.align.center`),value:`2`},{label:r.t(`drawing-ui.image-panel.align.right`),value:`3`}]},{options:[{label:r.t(`drawing-ui.image-panel.align.top`),value:`4`},{label:r.t(`drawing-ui.image-panel.align.middle`),value:`5`},{label:r.t(`drawing-ui.image-panel.align.bottom`),value:`6`}]},{options:[{label:r.t(`drawing-ui.image-panel.align.horizon`),value:`7`},{label:r.t(`drawing-ui.image-panel.align.vertical`),value:`8`}]}];function h(e){let t=Object.values(l).find(t=>t===e);t!=null&&(p(t),n.executeCommand(u.id,{alignType:t,drawings:a}))}return(0,c.jsxs)(`div`,{className:(0,s.clsx)(`univer-relative univer-w-full`,{"univer-hidden":!d}),children:[(0,c.jsx)(`header`,{className:`univer-text-gray-600 dark:!univer-text-gray-200`,children:(0,c.jsx)(`div`,{children:r.t(`drawing-ui.image-panel.align.title`)})}),(0,c.jsx)(`div`,{className:`univer-relative univer-mt-2.5 univer-flex univer-h-full`,children:(0,c.jsx)(`div`,{className:`univer-w-full univer-text-gray-900 dark:!univer-text-gray-0`,children:(0,c.jsx)(s.Select,{value:f,options:m,onChange:h})})})]})},yn=e=>{let{arrangeShow:r,drawings:a}=e,o=(0,i.useDependency)(t.LocaleService),l=(0,i.useDependency)(n.IDrawingManagerService),u=(0,i.useDependency)(t.ICommandService),d=(0,i.useDependency)(i.IconManager),f=d.get(`MoveUpIcon`),p=d.get(`MoveDownIcon`),m=d.get(`TopmostIcon`),h=d.get(`BottomIcon`),g=(0,i.useObservable)(()=>l.focus$,a,!1,[l]),_=e=>{u.syncExecuteCommand(y.id,{arrangeType:e,drawings:g})};return(0,c.jsxs)(`div`,{className:(0,s.clsx)(`univer-grid univer-gap-2 univer-py-2 univer-text-gray-400`,{"univer-hidden":!r}),children:[(0,c.jsx)(`header`,{className:`univer-text-gray-600 dark:!univer-text-gray-200`,children:(0,c.jsx)(`div`,{children:o.t(`drawing-ui.image-panel.arrange.title`)})}),(0,c.jsxs)(`div`,{className:`univer-grid univer-grid-cols-2 univer-gap-2`,children:[(0,c.jsxs)(s.Button,{onClick:()=>{_(t.ArrangeTypeEnum.forward)},children:[(0,c.jsx)(f,{}),o.t(`drawing-ui.image-panel.arrange.forward`)]}),(0,c.jsxs)(s.Button,{onClick:()=>{_(t.ArrangeTypeEnum.backward)},children:[(0,c.jsx)(p,{}),o.t(`drawing-ui.image-panel.arrange.backward`)]}),(0,c.jsxs)(s.Button,{onClick:()=>{_(t.ArrangeTypeEnum.front)},children:[(0,c.jsx)(m,{}),o.t(`drawing-ui.image-panel.arrange.front`)]}),(0,c.jsxs)(s.Button,{onClick:()=>{_(t.ArrangeTypeEnum.back)},children:[(0,c.jsx)(h,{}),o.t(`drawing-ui.image-panel.arrange.back`)]})]})]})},bn=e=>{var o;let l=(0,i.useDependency)(t.LocaleService),u=(0,i.useDependency)(r.IRenderManagerService),d=(0,i.useDependency)(n.IDrawingManagerService),f=(0,i.useDependency)(t.ICommandService),p=(0,i.useDependency)(i.IconManager),{hasGroup:m,drawings:h}=e,g=p.get(`GroupIcon`),_=p.get(`UngroupIcon`),v=h[0],y=v?(o=u.getRenderUnitById(v.unitId))==null||(o=o.scene)==null?void 0:o.getTransformerByCreate():void 0,{groupShow:b,groupBtnShow:x,ungroupBtnShow:S}=(0,i.useObservable)(y?()=>(0,a.merge)(y.clearControl$.pipe((0,a.filter)(e=>e===!0),(0,a.map)(()=>({groupShow:!1,groupBtnShow:!1,ungroupBtnShow:!1}))),y.changeStart$.pipe((0,a.map)(e=>{let n=q(e.objects,d),r=n.length>1,i=n.some(e=>(e==null?void 0:e.drawingType)===t.DrawingTypeEnum.DRAWING_GROUP);return{groupShow:r||i,groupBtnShow:r,ungroupBtnShow:i}}))):null,{groupShow:!1,groupBtnShow:!0,ungroupBtnShow:!0},!1,[d,y]);return(0,c.jsxs)(`div`,{className:(0,s.clsx)(`univer-grid univer-gap-2 univer-py-2 univer-text-gray-400`,{"univer-hidden":m===!0&&b===!1||m===!1}),children:[(0,c.jsx)(`header`,{className:`univer-text-gray-600 dark:!univer-text-gray-200`,children:(0,c.jsx)(`div`,{children:l.t(`drawing-ui.image-panel.group.title`)})}),(0,c.jsxs)(`div`,{className:`univer-flex univer-items-center univer-justify-center univer-gap-2`,children:[(0,c.jsxs)(s.Button,{className:(0,s.clsx)({"univer-hidden":!x}),onClick:()=>{f.syncExecuteCommand(T.id,{drawings:h})},children:[(0,c.jsx)(g,{}),l.t(`drawing-ui.image-panel.group.group`)]}),(0,c.jsxs)(s.Button,{className:(0,s.clsx)({"univer-hidden":!S}),onClick:()=>{f.syncExecuteCommand(E.id,{drawings:h})},children:[(0,c.jsx)(_,{}),l.t(`drawing-ui.image-panel.group.unGroup`)]})]})]})},xn=e=>{var t,n;let a=(0,i.useDependency)(r.IRenderManagerService),o=e.drawings[0],s=o?(t=a.getRenderUnitById(o.unitId))==null?void 0:t.scene:void 0,l=s==null||(n=s.getEngine())==null?void 0:n.activeScene;return!(o!=null&&o.transform)||!s||!l?null:(0,c.jsx)(Sn,{...e})};function Sn(e){let a=(0,i.useDependency)(t.LocaleService),l=(0,i.useDependency)(n.IDrawingManagerService),u=(0,i.useDependency)(r.IRenderManagerService),{drawings:d,transformShow:f}=e,p=d[0],m=p.transform,{unitId:h,subUnitId:g,drawingId:_,drawingType:v}=p,y=u.getRenderUnitById(h).scene,b=y.getEngine().activeScene,x=y.getTransformerByCreate(),{width:S=0,height:C=0,left:w=0,top:T=0,angle:E=0}=m,[D,O]=(0,o.useState)(S),[k,A]=(0,o.useState)(C),[j,N]=(0,o.useState)(w),[P,F]=(0,o.useState)(T),[I,L]=(0,o.useState)(E),[R,z]=(0,o.useState)(x.keepRatio),B=M(p,{getChildren:e=>l.getDrawingsByGroup(e)}),V=Wt(B),H=(e,t,n,r)=>{let{width:i,height:a}=b,{ancestorLeft:o,ancestorTop:s}=y,c=e,l=t,u=n,d=r;return e+o<0&&(c=-o),t+s<0&&(l=-s),u=i-c-o,u<20&&(u=20),d=a-l-s,d<20&&(d=20),e+u+o>i&&(c=i-n-o),t+d+s>a&&(l=a-r-s),{limitLeft:c,limitTop:l,limitWidth:u,limitHeight:d}},ee=e=>{let{objects:t}=e,n=q(t,l);if(n.length!==1)return;let r=n[0];if(r==null)return;let{transform:i}=r;if(i==null)return;let{width:a,height:o,left:s,top:c,angle:u}=i;a!=null&&O(a),o!=null&&A(o),s!=null&&N(s),c!=null&&F(c),u!=null&&L(u)};(0,o.useEffect)(()=>{let e=[x.changeStart$.subscribe(e=>{ee(e)}),x.changing$.subscribe(e=>{ee(e)}),x.changeEnd$.subscribe(e=>{ee(e)}),l.focus$.subscribe(e=>{if(e.length!==1)return;let t=l.getDrawingByParam(e[0]);if(t==null)return;let n=t.transform;if(n==null)return;let{width:r,height:i,left:a,top:o,angle:s}=n;r!=null&&O(r),i!=null&&A(i),a!=null&&N(a),o!=null&&F(o),s!=null&&L(s)})];return()=>{e.forEach(e=>e.unsubscribe())}},[]);let te=(0,t.debounce)(e=>{if(e==null)return;let{limitWidth:t,limitHeight:n}=H(j,P,e,k);e=Math.min(e,t);let r={unitId:h,subUnitId:g,drawingId:_,drawingType:v,transform:{width:e}};if(R){let t=e/D*k;if(t=Math.max(t,20),t>n)return;A(t),r.transform.height=t}O(e),l.featurePluginUpdateNotification([r]),x.refreshControls().changeNotification()},300),ne=(0,t.debounce)(e=>{if(e==null)return;let{limitHeight:t,limitWidth:n}=H(j,P,D,e);e=Math.min(e,t);let r={unitId:h,subUnitId:g,drawingId:_,drawingType:v,transform:{height:e}};if(R){let t=e/k*D;if(t=Math.max(t,20),t>n)return;O(t),r.transform.width=t}A(e),l.featurePluginUpdateNotification([r]),x.refreshControls().changeNotification()},300),re=(0,t.debounce)(e=>{if(e==null)return;let{limitLeft:t}=H(e,P,D,k);e=t;let n={unitId:h,subUnitId:g,drawingId:_,drawingType:v,transform:{left:e}};N(e),l.featurePluginUpdateNotification([n]),x.refreshControls().changeNotification()},300),ie=(0,t.debounce)(e=>{if(e==null)return;let{limitTop:t}=H(j,e,D,k);e=t;let n={unitId:h,subUnitId:g,drawingId:_,drawingType:v,transform:{top:e}};F(e),l.featurePluginUpdateNotification([n]),x.refreshControls().changeNotification()},300),ae=Gt({rotateEnabled:B,drawingParam:{unitId:h,subUnitId:g,drawingId:_,drawingType:v},setRotation:L,emitUpdate:e=>l.featurePluginUpdateNotification(e),notifyChange:()=>x.refreshControls().changeNotification()});return(0,c.jsxs)(`div`,{className:(0,s.clsx)(`univer-grid univer-gap-2 univer-py-2 univer-text-gray-400`,{"univer-hidden":!f}),children:[(0,c.jsx)(`header`,{className:`univer-text-gray-600 dark:!univer-text-gray-200`,children:(0,c.jsx)(`div`,{children:a.t(`drawing-ui.image-panel.transform.title`)})}),(0,c.jsxs)(`div`,{className:`univer-grid univer-grid-cols-3 univer-gap-2 [&>div]:univer-grid [&>div]:univer-gap-2`,children:[(0,c.jsxs)(`div`,{children:[(0,c.jsx)(`span`,{children:a.t(`drawing-ui.image-panel.transform.width`)}),(0,c.jsx)(s.InputNumber,{precision:1,value:D,min:20,onChange:e=>{te(e)}})]}),(0,c.jsxs)(`div`,{children:[(0,c.jsx)(`span`,{children:a.t(`drawing-ui.image-panel.transform.height`)}),(0,c.jsx)(s.InputNumber,{precision:1,value:k,min:20,onChange:e=>{ne(e)}})]}),(0,c.jsxs)(`div`,{children:[(0,c.jsx)(`span`,{children:a.t(`drawing-ui.image-panel.transform.lock`)}),(0,c.jsx)(`div`,{className:`univer-text-center`,children:(0,c.jsx)(s.Checkbox,{checked:R,onChange:e=>{typeof e==`boolean`&&(z(e),x.keepRatio=e)}})})]})]}),(0,c.jsxs)(`div`,{className:`univer-grid univer-grid-cols-3 univer-gap-2 [&>div]:univer-grid [&>div]:univer-gap-2`,children:[(0,c.jsxs)(`div`,{children:[(0,c.jsx)(`span`,{children:a.t(`drawing-ui.image-panel.transform.x`)}),(0,c.jsx)(s.InputNumber,{precision:1,value:j,onChange:e=>{re(e)}})]}),(0,c.jsxs)(`div`,{children:[(0,c.jsx)(`span`,{children:a.t(`drawing-ui.image-panel.transform.y`)}),(0,c.jsx)(s.InputNumber,{precision:1,value:P,onChange:e=>{ie(e)}})]}),(0,c.jsxs)(`div`,{children:[(0,c.jsx)(`span`,{children:a.t(`drawing-ui.image-panel.transform.rotate`)}),(0,c.jsx)(s.InputNumber,{precision:1,value:I,min:Ut[0],max:Ut[1],disabled:V,onChange:ae})]})]})]})}let Cn=e=>{let{drawingParam:t,cropperShow:n,localeService:r,cropValue:i,cropOptions:a,handleCropChange:o,onCropperBtnClick:l,ShapeClipPicker:u}=$t(e);return t?(0,c.jsxs)(`div`,{className:(0,s.clsx)(`univer-grid univer-gap-2 univer-py-2 univer-text-gray-400`,{"univer-hidden":!n}),children:[(0,c.jsx)(`header`,{className:`univer-text-gray-600 dark:!univer-text-gray-200`,children:(0,c.jsx)(`div`,{children:r.t(`drawing-ui.image-panel.crop.title`)})}),(0,c.jsxs)(`div`,{className:`univer-flex univer-items-center univer-justify-center univer-gap-2`,children:[(0,c.jsxs)(s.Button,{onClick:()=>l(i),children:[(0,c.jsx)(et,{}),r.t(`drawing-ui.image-panel.crop.start`)]}),(0,c.jsx)(s.Select,{value:i,options:a,onChange:o})]}),u&&(0,c.jsx)(u,{})]}):null},wn=class extends t.Disposable{constructor(e,t){super(),this._componentManager=e,this._iconManager=t,this._registerComponents(),this._registerIcons()}_registerComponents(){[[Pt,dn],[Lt,yn],[Bt,vn],[Vt,bn],[zt,xn],[Rt,Cn]].forEach(([e,t])=>{this.disposeWithMe(this._componentManager.register(e,t))})}_registerIcons(){this.disposeWithMe(this._iconManager.register({BottomIcon:Ke,DrawingCropIcon:nt,DrawingDeleteIcon:it,DrawingEditIcon:ot,GroupIcon:mt,MoveDownIcon:xt,MoveUpIcon:Ct,TopmostIcon:Dt,UngroupIcon:kt}))}};wn=G([W(0,(0,t.Inject)(i.ComponentManager)),W(1,(0,t.Inject)(i.IconManager))],wn);let Tn=class extends t.Disposable{constructor(e,n,r,i,o,s,c,l){super(),this._commandService=e,this._drawingManagerService=n,this._renderManagerService=r,this._univerInstanceService=i,this._messageService=o,this._localeService=s,this._shortcutService=c,this._layoutService=l,U(this,`_sceneListenerOnImageMap`,new WeakSet),U(this,`_cropShortcutDisposables`,new t.DisposableCollection),U(this,`_cropSnapshots`,new WeakMap),U(this,`_pendingCropSnapshot`,null),U(this,`_activeCropSession`,null),U(this,`_cropping$`,new a.BehaviorSubject(!1)),U(this,`cropping$`,this._cropping$.asObservable()),this.disposeWithMe(this._cropShortcutDisposables),this.disposeWithMe({dispose:()=>this._cropping$.complete()}),this._init()}_init(){this._initOpenCrop(),this._initCloseCrop(),this._initAutoCrop()}_initAutoCrop(){this.disposeWithMe(this._commandService.onCommandExecuted(e=>{if(e.id!==k.id)return;let t=e.params;if(t==null)return;let{cropType:i}=t,a=this._drawingManagerService.getFocusDrawings();if(a.length!==1)return;let{unitId:o,subUnitId:c,drawingId:l}=a[0],u=this._renderManagerService.getRenderUnitById(o),d=u==null?void 0:u.scene;if(d==null)return!0;this._searchCropObject(d)!=null&&this._commandService.syncExecuteCommand(O.id,{isAuto:!0});let f=(0,n.getDrawingShapeKeyByDrawingSearch)({unitId:o,subUnitId:c,drawingId:l}),p=d.getObject(f);if(!(p instanceof r.Image)){this._messageService.show({type:s.MessageType.Error,content:this._localeService.t(`drawing-ui.image-cropper.error`)});return}if(p!=null){this._pendingCropSnapshot=this._captureCropSnapshot(p);try{this._updateCropperObject(i,p),this._commandService.syncExecuteCommand(D.id,{unitId:o,subUnitId:c,drawingId:l})}finally{this._pendingCropSnapshot=null}}}))}_calculateSrcRectByRatio(e,t,n,i,a,o){let s=n/i,c=a/o,l=n,u=i;s>c?l=i*c:u=n/c;let d=(n-l)/2,f=(i-u)/2;return{left:(0,r.precisionTo)(d,1),top:(0,r.precisionTo)(f,1),right:(0,r.precisionTo)(n-(d+l),1),bottom:(0,r.precisionTo)(i-(f+u),1)}}_updateCropperObject(e,t){let{left:n,top:r,width:i,height:a}=t.calculateTransformWithSrcRect(),o;switch(e){case`1`:o=this._calculateSrcRectByRatio(n,r,i,a,1,1);break;case`2`:o=this._calculateSrcRectByRatio(n,r,i,a,16,9);break;case`3`:o=this._calculateSrcRectByRatio(n,r,i,a,9,16);break;case`4`:o=this._calculateSrcRectByRatio(n,r,i,a,5,4);break;case`5`:o=this._calculateSrcRectByRatio(n,r,i,a,4,5);break;case`6`:o=this._calculateSrcRectByRatio(n,r,i,a,4,3);break;case`7`:o=this._calculateSrcRectByRatio(n,r,i,a,3,4);break;case`8`:o=this._calculateSrcRectByRatio(n,r,i,a,3,2);break;case`9`:o=this._calculateSrcRectByRatio(n,r,i,a,2,3)}if(o==null)return;t.setSrcRect(o);let{left:s=0,top:c=0,bottom:l=0,right:u=0}=o;t.transformByStateCloseCropper({left:n+s,top:r+c,width:i-u-s,height:a-l-c})}_initOpenCrop(){this.disposeWithMe(this._commandService.onCommandExecuted(e=>{if(e.id!==D.id)return;let t=e.params;if(t==null)return;this._activeCropSession!=null&&this._commandService.syncExecuteCommand(O.id,{isAuto:!0});let{unitId:i,subUnitId:a,drawingId:o}=t,c=this._renderManagerService.getRenderUnitById(i),l=c==null?void 0:c.scene;if(l==null)return!0;if(this._sceneListenerOnImageMap.has(l)||(this._addListenerOnImage(l),this._sceneListenerOnImageMap.add(l)),this._drawingManagerService.getDrawingByParam({unitId:i,subUnitId:a,drawingId:o})==null)return;let u=(0,n.getDrawingShapeKeyByDrawingSearch)({unitId:i,subUnitId:a,drawingId:o}),d=l.getObject(u);if(!(d instanceof r.Image)){this._messageService.show({type:s.MessageType.Error,content:this._localeService.t(`drawing-ui.image-cropper.error`)});return}let f=l.getTransformer();f==null||f.clearControls();let p=new Z(`${u}-crop`,{srcRect:d.srcRect,prstGeom:d.prstGeom,applyTransform:d.calculateTransformWithSrcRect()});this._cropSnapshots.set(p,this._pendingCropSnapshot??this._captureCropSnapshot(d)),this._pendingCropSnapshot=null,l.addObject(p,d.getLayerIndex()+1).attachTransformerTo(p),this._activeCropSession={scene:l,imageShape:d,imageCropperObject:p},this._cropping$.next(!0),f==null||f.createControlForCopper(p),this._addHoverForImageCopper(p),d.openRenderByCropper(),f==null||f.refreshControls(),p.makeDirty(!0),this._registerCropShortcuts(p),this._commandService.syncExecuteCommand(n.SetDrawingSelectedOperation.id,[{unitId:i,subUnitId:a,drawingId:o}]),this._layoutService.focus()}))}_searchCropObject(e){let t=e.getAllObjectsByOrder();for(let e of t)if(e instanceof Z)return e}_initCloseCrop(){this.disposeWithMe(this._commandService.onCommandExecuted(e=>{if(e.id!==O.id)return;let t=this._activeCropSession;if(t==null)return;this._activeCropSession=null;let{scene:n,imageShape:r,imageCropperObject:i}=t,a=n.getTransformerByCreate();a.detachFrom(i),a.clearCopperControl();let o=e.params;if(o!=null&&o.isCancel)this._restoreCropSnapshot(r,i);else{let e=rn(r,i),t=this._drawingManagerService.getDrawingOKey(r.oKey);if(t!=null){let{left:n,top:r,height:a,width:o}=i;this._drawingManagerService.featurePluginUpdateNotification([{...t,transform:{...t.transform,left:n,top:r,height:a,width:o},srcRect:e.srcRectAngle}])}r.setSrcRect({...e.srcRectAngle})}r.closeRenderByCropper(),r.makeDirty(!0),a.refreshControls(),this._cropSnapshots.delete(i),i.dispose(),this._cropping$.next(!1),this._cropShortcutDisposables.dispose()}));let e=this._univerInstanceService.getCurrentTypeOfUnit$(t.UniverInstanceType.UNIVER_SHEET).pipe((0,a.switchMap)(e=>e?e.activeSheet$:(0,a.of)(null)));this.disposeWithMe(e.subscribe(()=>{this._activeCropSession!=null&&this._commandService.syncExecuteCommand(O.id)}))}_getApplyObjectByCropObject(e){let t=e.oKey,n=t.slice(0,t.length-5),r=e.getScene();return r?r.getObject(n)??null:null}_captureCropSnapshot(e){return{transform:e.getState(),srcRect:e.srcRect==null?e.srcRect:{...e.srcRect}}}_restoreCropSnapshot(e,t){let n=this._cropSnapshots.get(t);n&&(e.transformByStateCloseCropper(n.transform),e.setSrcRect(n.srcRect))}_registerCropShortcuts(e){this._cropShortcutDisposables.dispose(),this._cropShortcutDisposables.add(e.onDispose$.subscribeEvent(()=>{this._activeCropSession=null,this._cropping$.next(!1),this._cropShortcutDisposables.dispose()})),this._cropShortcutDisposables.add(this._shortcutService.registerShortcut({id:O.id,binding:i.KeyCode.ENTER,priority:1e3})),this._cropShortcutDisposables.add(this._shortcutService.registerShortcut({id:O.id,binding:i.KeyCode.ESC,priority:1e3,staticParameters:{isCancel:!0}}))}_addListenerOnImage(e){let n=e.getTransformerByCreate(),r=null;this.disposeWithMe(n.changeStart$.subscribe(e=>{let{objects:t}=e,i=t.values().next().value;if(i==null||!(i instanceof Z))return;let{left:a,top:o,height:s,width:c,angle:l}=i;r={left:a,top:o,height:s,width:c,angle:l},n.clearCopperControl()})),this.disposeWithMe(n.changeEnd$.subscribe(e=>{let{objects:i}=e,a=i.values().next().value;if(a==null||!(a instanceof Z))return;let{left:o,top:s,height:c,width:l,angle:u}=a;if(!(0,t.checkIfMove)({left:o,top:s,height:c,width:l,angle:u},r)){n.createControlForCopper(a);return}let d=this._getApplyObjectByCropObject(a);if(d==null)return;let f=rn(d,a);a.refreshSrcRect(f.srcRect,d.getState()),n.createControlForCopper(a)})),this._endCropListener(e)}_addHoverForImageCopper(e){this.disposeWithMe(e.onPointerEnter$.subscribeEvent(()=>{e.cursor=r.CURSOR_TYPE.MOVE})),this.disposeWithMe(e.onPointerLeave$.subscribeEvent(()=>{e.cursor=r.CURSOR_TYPE.DEFAULT}))}_endCropListener(e){let t=e.getTransformerByCreate();this.disposeWithMe(t.clearControl$.subscribe(e=>{e===!0&&this._commandService.syncExecuteCommand(O.id)}))}};Tn=G([W(0,t.ICommandService),W(1,n.IDrawingManagerService),W(2,r.IRenderManagerService),W(3,t.IUniverInstanceService),W(4,i.IMessageService),W(5,(0,t.Inject)(t.LocaleService)),W(6,i.IShortcutService),W(7,i.ILayoutService)],Tn);let En=class extends t.Disposable{constructor(e,t,n,r,i){super(),this._commandService=e,this._renderManagerService=t,this._drawingManagerService=n,this._currentUniverService=r,this._drawingRenderService=i,this._initialize()}dispose(){super.dispose()}_initialize(){this._drawingAddListener(),this._commandExecutedListener(),this._imageUpdateListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.onCommandExecuted(e=>{if(e.id===A.id){let t=e.params;if(t==null)return;this._resetImageSize(t)}}))}_getSceneAndTransformerByDrawingSearch(e){if(e==null)return;let t=this._renderManagerService.getRenderUnitById(e),n=t==null?void 0:t.scene;return n==null?null:{scene:n,transformer:n.getTransformerByCreate()}}_resetImageSize(e){let r=[],i=[];e.forEach(e=>{let{unitId:a,subUnitId:o,drawingId:s}=e,c=this._getSceneAndTransformerByDrawingSearch(a);if(c==null)return;let{scene:l}=c,u=(0,n.getDrawingShapeKeyByDrawingSearch)({unitId:a,subUnitId:o,drawingId:s}),d=l.getObject(u);if(d==null)return!0;let f=this._drawingManagerService.getDrawingByParam(e);if(f==null)return!0;if(f.drawingType!==t.DrawingTypeEnum.DRAWING_IMAGE)return;d.resetSize();let{width:p,height:m}=d.getNativeSize();i.includes(l)===!1&&i.push(l),r.push({...f,transform:{...f.transform,height:m,width:p,angle:0},srcRect:null,prstGeom:null})}),this._drawingManagerService.featurePluginUpdateNotification(r),i.forEach(e=>{e.getTransformerByCreate().refreshControls().changeNotification()}),this._commandService.syncExecuteCommand(n.SetDrawingSelectedOperation.id,e)}_drawingAddListener(){this.disposeWithMe(this._drawingManagerService.add$.pipe((0,a.bufferTime)(33),(0,a.filter)(e=>e.length>0),(0,a.map)(e=>e.flat()),(0,a.map)(e=>{let t=new Map;for(let n of e)t.set(`${n.unitId}|${n.subUnitId}|${n.drawingId}`,n);return[...t.values()]}),(0,a.filter)(e=>e.length>0)).subscribe(e=>{this._insertImages(e)}))}_insertImages(e){e.forEach(async e=>{var t;let{unitId:n,subUnitId:r}=e,i=this._getSceneAndTransformerByDrawingSearch(n),a=(t=R(this._currentUniverService,n))==null?void 0:t.subUnitId;if(i==null||a!==r)return;let o=this._drawingManagerService.getDrawingByParam(e);if(o==null)return;let s=await this._drawingRenderService.renderImages(o,i.scene),c=this._drawingManagerService.getDrawingByParam(e);if(c&&this._drawingManagerService.refreshTransform([c]),s!=null&&s.length!==0)for(let e of s)this._addHoverForImage(e),this._addDialogForImage(e)})}_imageUpdateListener(){this.disposeWithMe(this._drawingManagerService.update$.subscribe(e=>{e.forEach(e=>{var r;let{unitId:i,subUnitId:a,drawingId:o}=e,s=this._drawingManagerService.getDrawingByParam(e);if(s==null)return;let{transform:c,drawingType:l,srcRect:u,prstGeom:d,source:f,imageSourceType:p}=s;if(l!==t.DrawingTypeEnum.DRAWING_IMAGE)return;let m=this._getSceneAndTransformerByDrawingSearch(i);if(m==null)return;let{scene:h}=m;if(c==null)return!0;let g=(0,n.getDrawingShapeKeyByDrawingSearch)({unitId:i,subUnitId:a,drawingId:o}),_=h.getObject(g);if(_==null)return!0;let{left:v=0,top:y=0,width:b=0,height:x=0,angle:S=0,flipX:C=!1,flipY:w=!1,skewX:T=0,skewY:E=0}=c;_.transformByState({left:v,top:y,width:b,height:x,angle:S,flipX:C,flipY:w,skewX:T,skewY:E}),(r=_.setClipBounds)==null||r.call(_,c.clipBounds),ke(h,_,s),_.setSrcRect(u),_.setPrstGeom(d),f!=null&&f.length>0&&(p===t.ImageSourceType.BASE64||p===t.ImageSourceType.URL)&&_.changeSource(f)})}))}_addHoverForImage(e){this.disposeWithMe((0,t.toDisposable)(e.onPointerEnter$.subscribeEvent(()=>{e.cursor=r.CURSOR_TYPE.GRAB}))),this.disposeWithMe((0,t.toDisposable)(e.onPointerLeave$.subscribeEvent(()=>{e.cursor=r.CURSOR_TYPE.DEFAULT})))}_addDialogForImage(e){this.disposeWithMe((0,t.toDisposable)(e.onDblclick$.subscribeEvent(()=>{let t=e.getNative();t&&this._drawingRenderService.previewImage(`${e.oKey}-viewer-dialog`,t.src,e.getNativeSize().width,e.getNativeSize().height)})))}};En=G([W(0,t.ICommandService),W(1,r.IRenderManagerService),W(2,n.IDrawingManagerService),W(3,t.IUniverInstanceService),W(4,(0,t.Inject)(K))],En);let Dn=class extends t.Disposable{constructor(e,t){super(),this._commandService=e,this._menuManagerService=t,this._init()}_init(){this._initMenus(),this._initCommands()}_initMenus(){this._menuManagerService.mergeMenu(ve)}_initCommands(){[D,O,A,u,d,f,p,m,h,g,_,v,k,T,E,y,b,x,S,C].forEach(e=>this.disposeWithMe(this._commandService.registerCommand(e)))}};Dn=G([W(0,t.ICommandService),W(1,i.IMenuManagerService)],Dn);let On=class extends t.Plugin{constructor(e=Se,n,r){super(),this._config=e,this._injector=n,this._configService=r;let{menu:i,...a}=(0,t.merge)({},Se,this._config);i&&this._configService.setConfig(`menu`,i,{merge:!0}),this._configService.setConfig(xe,a)}onStarting(){this._injector.add([wn]),this._injector.get(wn),this._initDependencies()}onRendered(){this._injector.get(J),this._injector.get(Dn),this._injector.get(Tn),this._injector.get(En)}_initDependencies(){[[De],[K],[J],[Dn],[Tn],[En]].forEach(e=>this._injector.add(e))}};U(On,`pluginName`,`UNIVER_DRAWING_UI_PLUGIN`),U(On,`packageName`,ye),U(On,`version`,be),On=G([(0,t.DependentOn)(n.UniverDrawingPlugin,r.UniverRenderEnginePlugin),W(1,(0,t.Inject)(t.Injector)),W(2,t.IConfigService)],On);let kn=`image/png`,Q=`image/svg+xml`,An=[kn,`image/jpeg`,`image/jpg`,`image/gif`,`image/bmp`],jn={avif:`image/avif`,bmp:`image/bmp`,gif:`image/gif`,heic:`image/heic`,ico:`image/x-icon`,jpeg:`image/jpeg`,jpg:`image/jpeg`,png:kn,svg:`image/svg+xml`,tif:`image/tiff`,tiff:`image/tiff`,webp:`image/webp`};function Mn(e){let t=Array.from(e.items??[]).filter(e=>e.kind===`file`).map(e=>e.getAsFile()).filter(e=>e!==null&&Zn(e));return t.length>0?t:Array.from(e.files??[]).filter(Zn)}function Nn(e){let t=e.trim();return/^data:image\/[a-z0-9.+-]+(?:;[^,]*)?,/i.test(t)||/^<svg(?:\s|>)/i.test(t)&&/<\/svg>$/i.test(t)}async function Pn(e){let t=e.trim();if(/^data:image\/[a-z0-9.+-]+(?:;[^,]*)?,/i.test(t))try{let e=await(await fetch(t)).blob(),n=e.type.split(`;`)[0].toLowerCase();if(n===Q){let t=qn(await e.text());return t?new File([t],`pasted-image.svg`,{type:n}):null}return n.startsWith(`image/`)?new File([e],`pasted-image.${Xn(n)}`,{type:n}):null}catch{return null}let n=qn(t);return n?new File([n],`pasted-image.svg`,{type:Q}):null}function Fn(e){let t=new DOMParser().parseFromString(e,`text/html`).body.cloneNode(!0),n=t.querySelector(`img, svg`)!==null;return t.querySelectorAll(`img, svg`).forEach(e=>e.remove()),n&&!(t.textContent??``).trim()&&!t.querySelector(`table`)}async function In(e){let t=new DOMParser().parseFromString(e,`text/html`),n=Array.from(new Set(Array.from(t.body.querySelectorAll(`img`)).filter(e=>!zn(e)).map(Ln).filter(e=>/^(?:data|blob|https?):/i.test(e)))).slice(0,32),r=await Promise.all(n.map(Rn)),i=Array.from(t.body.querySelectorAll(`svg`)).filter(e=>!zn(e)).map((e,t)=>{let n=qn(new XMLSerializer().serializeToString(e));return n?new File([n],`pasted-image-${t+1}.svg`,{type:Q}):null});return[...r,...i].filter(e=>e!==null).slice(0,32)}function Ln(e){var t;let n=e.getAttribute(`src`)||e.getAttribute(`data-src`)||e.getAttribute(`data-lazy-src`)||e.getAttribute(`data-original`);return n?n.trim():((e.getAttribute(`srcset`)||((t=e.closest(`picture`))==null||(t=t.querySelector(`source[srcset]`))==null?void 0:t.getAttribute(`srcset`))||``).trim().split(/\s+/)[0]??``).replace(/,$/,``)}async function Rn(e){let t=new AbortController,n=setTimeout(()=>t.abort(),5e3);try{let n=await fetch(e,{signal:t.signal});if(!n.ok)return null;let r=await n.blob();return r.type.startsWith(`image/`)?new File([r],`pasted-image.${Xn(r.type)}`,{type:r.type}):null}catch{return null}finally{clearTimeout(n)}}function zn(e){let t=e;for(;t;){var n;if(t.hasAttribute(`hidden`)||((n=t.getAttribute(`aria-hidden`))==null?void 0:n.toLowerCase())===`true`)return!0;let e=t.classList;if(e.contains(`sr-only`)||e.contains(`visually-hidden`)||e.contains(`screen-reader-only`))return!0;let r=t.getAttribute(`style`)??``;if(/(?:^|;)\s*display\s*:\s*none(?:\s*!important)?\s*(?:;|$)/i.test(r)||/(?:^|;)\s*visibility\s*:\s*(?:hidden|collapse)(?:\s*!important)?\s*(?:;|$)/i.test(r))return!0;t=t.parentElement}return!1}async function Bn(e){let t=Qn(e);if(!t)return null;let n=e.type.toLowerCase()===t?e:new File([e],e.name,{type:t});if(t===Q){let e=qn(await n.text());return e?new File([e],n.name||`pasted-image.svg`,{type:t}):null}if(An.includes(t))return n;try{let e=await Gn(n);return e?new File([e],`pasted-image.png`,{type:kn}):null}catch{return null}}async function Vn(e){if(Qn(e)!==Q)return null;let t=qn(await e.text());return t?`data:${Q};charset=utf-8,${encodeURIComponent(t)}`:null}async function Hn(e,t,n){var r;let i=(r=globalThis.navigator)==null?void 0:r.clipboard,a=globalThis.ClipboardItem;if(!e||!(i!=null&&i.write)||a===void 0)return!1;try{let r=Un(e,t,n);return await i.write([new a({[kn]:r})]),!0}catch{return!1}}async function Un(e,t,n){let r=await Wn(e,t,n);if(!r)throw Error(`Clipboard image source could not be resolved.`);let i=await fetch(r);if(!i.ok)throw Error(`Clipboard image source could not be loaded.`);let a=await i.blob(),o=a.type===kn?a:await Gn(a);if(!o)throw Error(`Clipboard image could not be converted to PNG.`);return o}async function Wn(e,n,r){return/^(?:data|blob|https?):/i.test(e)&&n!==t.ImageSourceType.UUID?e:r?r.getImage(e):null}async function Gn(e){if(!e.type.startsWith(`image/`))return null;let t=URL.createObjectURL(e);try{let e=await Kn(t);if(e.naturalWidth===0||e.naturalHeight===0)return null;let n=document.createElement(`canvas`);n.width=e.naturalWidth,n.height=e.naturalHeight;let r=n.getContext(`2d`);return r?(r.drawImage(e,0,0),new Promise(e=>n.toBlob(e,kn))):null}finally{URL.revokeObjectURL(t)}}function Kn(e){return new Promise((t,n)=>{let r=new Image;r.onload=()=>t(r),r.onerror=()=>n(Error(`Clipboard image could not be decoded.`)),r.src=e})}function qn(e){if(e.length>5e6||!Nn(e)||!/^<svg(?:\s|>)/i.test(e))return null;let t=new DOMParser().parseFromString(e,Q),n=t.documentElement;return n.localName.toLowerCase()!==`svg`||t.querySelector(`parsererror`)||n.querySelectorAll(`*`).length>5e4?null:(n.querySelectorAll(`script, foreignObject, iframe, object, embed, link`).forEach(e=>e.remove()),n.querySelectorAll(`style`).forEach(e=>{Yn(e.textContent??``)&&e.remove()}),[n,...Array.from(n.querySelectorAll(`*`))].forEach(e=>{Array.from(e.attributes).forEach(t=>{if(/^on/i.test(t.name)){e.removeAttribute(t.name);return}if(/^(?:href|xlink:href)$/i.test(t.name)&&!Jn(t.value)){e.removeAttribute(t.name);return}Yn(t.value)&&e.removeAttribute(t.name)})}),n.hasAttribute(`xmlns`)||n.setAttribute(`xmlns`,`http://www.w3.org/2000/svg`),new XMLSerializer().serializeToString(n))}function Jn(e){let t=e.trim();return t.startsWith(`#`)||/^data:image\/(?:png|jpe?g|gif|webp);base64,/i.test(t)}function Yn(e){return/@import/i.test(e)?!0:(e.match(/url\([^)]*\)/gi)??[]).some(e=>!/^url\(\s*['"]?#/i.test(e))}function Xn(e){let t=e.split(`/`)[1]??`png`;return t===`svg+xml`?`svg`:t}function Zn(e){return Qn(e)!==null}function Qn(e){var t;let n=e.type.toLowerCase();if(n.startsWith(`image/`))return n;let r=(t=e.name.split(`.`).pop())==null?void 0:t.toLowerCase();return r?jn[r]??null:null}let $n=`floating`,er=`canvas`;function tr(e){return e===t.DrawingTypeEnum.DRAWING_CHART||e===t.DrawingTypeEnum.DRAWING_DOM||e===t.DrawingTypeEnum.DRAWING_UNIT}function nr(e){return tr(e)?$n:er}let rr=`
|
|
1
|
+
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("@univerjs/core"),require("@univerjs/drawing"),require("@univerjs/engine-render"),require("@univerjs/ui"),require("rxjs"),require("react"),require("@univerjs/design"),require("react/jsx-runtime")):typeof define==`function`&&define.amd?define([`exports`,`@univerjs/core`,`@univerjs/drawing`,`@univerjs/engine-render`,`@univerjs/ui`,`rxjs`,`react`,`@univerjs/design`,`react/jsx-runtime`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.UniverDrawingUi={},e.UniverCore,e.UniverDrawing,e.UniverEngineRender,e.UniverUi,e.rxjs,e.React,e.UniverDesign,e.React))})(this,function(e,t,n,r,i,a,o,s,c){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});let l=function(e){return e.default=`0`,e.left=`1`,e.center=`2`,e.right=`3`,e.top=`4`,e.middle=`5`,e.bottom=`6`,e.horizon=`7`,e.vertical=`8`,e}({}),u={id:`sheet.operation.set-image-align`,type:t.CommandType.OPERATION,handler:(e,t)=>!0},d={id:`sheet.operation.set-drawing-align-left`,type:t.CommandType.OPERATION,handler:e=>e.get(t.ICommandService).syncExecuteCommand(u.id,{alignType:`1`})},f={id:`sheet.operation.set-drawing-align-center`,type:t.CommandType.OPERATION,handler:e=>e.get(t.ICommandService).syncExecuteCommand(u.id,{alignType:`2`})},p={id:`sheet.operation.set-drawing-align-right`,type:t.CommandType.OPERATION,handler:e=>e.get(t.ICommandService).syncExecuteCommand(u.id,{alignType:`3`})},m={id:`sheet.operation.set-drawing-align-top`,type:t.CommandType.OPERATION,handler:e=>e.get(t.ICommandService).syncExecuteCommand(u.id,{alignType:`4`})},h={id:`sheet.operation.set-drawing-align-middle`,type:t.CommandType.OPERATION,handler:e=>e.get(t.ICommandService).syncExecuteCommand(u.id,{alignType:`5`})},g={id:`sheet.operation.set-drawing-align-bottom`,type:t.CommandType.OPERATION,handler:e=>e.get(t.ICommandService).syncExecuteCommand(u.id,{alignType:`6`})},_={id:`sheet.operation.set-drawing-align-horizon`,type:t.CommandType.OPERATION,handler:e=>e.get(t.ICommandService).syncExecuteCommand(u.id,{alignType:`7`})},v={id:`sheet.operation.set-drawing-align-vertical`,type:t.CommandType.OPERATION,handler:e=>e.get(t.ICommandService).syncExecuteCommand(u.id,{alignType:`8`})},y={id:`drawing.operation.set-drawing-arrange`,type:t.CommandType.OPERATION,handler:(e,t)=>{let r=e.get(n.IDrawingManagerService),{arrangeType:i}=t,a=t.drawings||r.getFocusDrawings(),{unitId:o,subUnitId:s}=a[0],c=a.map(e=>e.drawingId);return r.featurePluginOrderUpdateNotification({unitId:o,subUnitId:s,drawingIds:c,arrangeType:i}),!0}},b={id:`drawing.operation.set-drawing-arrange-front`,type:t.CommandType.OPERATION,handler:e=>e.get(t.ICommandService).syncExecuteCommand(y.id,{arrangeType:t.ArrangeTypeEnum.front})},x={id:`drawing.operation.set-drawing-arrange-forward`,type:t.CommandType.OPERATION,handler:e=>e.get(t.ICommandService).syncExecuteCommand(y.id,{arrangeType:t.ArrangeTypeEnum.forward})},S={id:`drawing.operation.set-drawing-arrange-back`,type:t.CommandType.OPERATION,handler:e=>e.get(t.ICommandService).syncExecuteCommand(y.id,{arrangeType:t.ArrangeTypeEnum.back})},C={id:`drawing.operation.set-drawing-arrange-backward`,type:t.CommandType.OPERATION,handler:e=>e.get(t.ICommandService).syncExecuteCommand(y.id,{arrangeType:t.ArrangeTypeEnum.backward})},w=n.DRAWING_GROUPABLE_TYPES,T={id:`drawing.operation.set-drawing-group`,type:t.CommandType.OPERATION,handler:(e,i)=>{let a=e.get(n.IDrawingManagerService),o=i.drawings||a.getFocusDrawings();if(o.length<2||!o.every(e=>(0,n.isGroupableDrawingType)(e.drawingType)))return!1;let{unitId:s,subUnitId:c}=o[0],l=(0,t.generateRandomId)(10),u=(0,r.getGroupState)(0,0,o.map(e=>e.transform||{})),d={unitId:s,subUnitId:c,drawingId:l,drawingType:t.DrawingTypeEnum.DRAWING_GROUP,transform:u,groupBaseBound:{left:u.left,top:u.top,width:u.width,height:u.height}},f=o.map(e=>{let t=e.transform||{left:0,top:0},{unitId:n,subUnitId:r,drawingId:i,drawingType:a}=e;return{unitId:n,subUnitId:r,drawingId:i,drawingType:a,transform:{...t},groupId:l}});return a.featurePluginGroupUpdateNotification([{parent:d,children:f}]),!0}},E={id:`drawing.operation.cancel-drawing-group`,type:t.CommandType.OPERATION,handler:(e,i)=>{let a=e.get(n.IDrawingManagerService),o=(i.drawings||a.getFocusDrawings()).map(e=>{if(e.drawingType!==t.DrawingTypeEnum.DRAWING_GROUP)return null;let{unitId:n,subUnitId:i,drawingId:o,transform:s={width:0,height:0},groupBaseBound:c}=e;if(s===null)return null;let l=a.getDrawingsByGroup({unitId:n,subUnitId:i,drawingId:o});return l.length===0?null:{parent:e,children:l.map(e=>{let{transform:t}=e,{unitId:n,subUnitId:i,drawingId:a}=e,o=(0,r.transformObjectOutOfGroup)(t||{},s,s.width||0,s.height||0,c);return{unitId:n,subUnitId:i,drawingId:a,transform:{...t,...o},groupId:void 0}})}}).filter(e=>e!==null);return o.length!==0&&(a.featurePluginUngroupUpdateNotification(o),!0)}},D={id:`sheet.operation.open-image-crop`,type:t.CommandType.OPERATION,handler:(e,t)=>!0},O={id:`sheet.operation.close-image-crop`,type:t.CommandType.OPERATION,handler:(e,t)=>!0},k={id:`sheet.operation.Auto-image-crop`,type:t.CommandType.OPERATION,handler:(e,t)=>!0},A={id:`sheet.operation.image-reset-size`,type:t.CommandType.OPERATION,handler:(e,t)=>!0};function j(e){return e===t.DrawingTypeEnum.DRAWING_CHART}function M(e,t={}){return(0,n.resolveDrawingRotateEnabled)(e,{...t,isKnownNonRotatableType:t.isKnownNonRotatableType??j})}function N(e,t){let r=(0,n.getDrawingShapeKeyByDrawingSearch)(t);return e.getObjectIncludeInGroup(r)??null}function P(e,r){if(r.isMultiTransform===t.BooleanNumber.TRUE){let t=(0,n.getDrawingShapeKeyByDrawingSearch)(r),i=`${t}#-#`,a=e.getAllObjects().filter(e=>e.oKey===t||e.oKey.startsWith(i));return a.forEach(e=>e.dispose()),a.length>0}let i=N(e,r);return i!=null&&(i.dispose(),!0)}function F(e,t){return N(e,t)}function I(e,t,n,r,i){let a=M(t,{getChildren:e=>i&&e.drawingId===t.drawingId&&e.unitId===t.unitId&&e.subUnitId===t.subUnitId?i:r.getDrawingsByGroup(e),getRenderObject:e=>F(n,e)});e.transformerConfig={...e.transformerConfig,rotateEnabled:a}}function L(e,t,i,a,o,s=!0){var c,l;let u=a.getDrawingByParam(e);if(u==null)return;let d=(0,n.getDrawingShapeKeyByDrawingSearch)(e,o),f=i.getObjectIncludeInGroup(d);if(f&&!(f instanceof r.Group))return;if(f!=null){let e=f.getObjects();for(let n of e)if(n.oKey===t.oKey)return;f.addObject(t),I(f,u,i,a);return}let p=new r.DrawingGroupObject(d),m=a.getDrawingOrder(e.unitId,e.subUnitId);p.zIndex=Math.max(0,m.indexOf(e.drawingId));let h=i.addObject(p,((c=t.layer)==null?void 0:c.zIndex)??r.DRAWING_OBJECT_LAYER_INDEX);s&&h.attachTransformerTo(p),p.addObject(t),I(p,u,i,a);let{groupBaseBound:g}=u,_=o==null?u.transform:(l=u.transforms)==null?void 0:l[o];g&&p.setBaseBound(g),u.groupId&&(p.isInGroup=!0,L({drawingId:u.groupId,unitId:e.unitId,subUnitId:e.subUnitId},p,i,a,o,s)),_&&p.transformByState({left:_.left,top:_.top,angle:_.angle,width:_.width,height:_.height,flipX:_.flipX,flipY:_.flipY})}function R(e,n){let r=n?e.getUnit(n):e.getFocusedUnit();if(r==null)return;let i=r.getUnitId(),a;if(r.type===t.UniverInstanceType.UNIVER_SHEET){var o;a=(o=r.getActiveSheet())==null?void 0:o.getSheetId()}else(r.type===t.UniverInstanceType.UNIVER_DOC||r.type===t.UniverInstanceType.UNIVER_SLIDE)&&(a=i);return{unitId:i,subUnitId:a,current:r}}let z=e=>{let t=e.get(n.IDrawingManagerService);return new a.Observable(e=>{let n=t=>{if(!t||t.length===0||t.length<2)return e.next(!0);e.next(!1)},r=t.focus$.subscribe(t=>{if(!t||t.length===0)return e.next(!0);n(t)});return n(t.getFocusDrawings()),()=>r.unsubscribe()})},B=`contextMenu.drawing-align`;function V(e){return{id:B,type:i.MenuItemType.SUBITEMS,icon:`HorizontallyIcon`,title:`drawing-ui.image-panel.align.title`,hidden$:z(e)}}function H(){return{id:d.id,type:i.MenuItemType.BUTTON,icon:`LeftJustifyingIcon`,title:`drawing-ui.image-panel.align.left`}}function ee(){return{id:f.id,type:i.MenuItemType.BUTTON,icon:`HorizontallyIcon`,title:`drawing-ui.image-panel.align.center`}}function te(){return{id:p.id,type:i.MenuItemType.BUTTON,icon:`RightJustifyingIcon`,title:`drawing-ui.image-panel.align.right`}}function ne(){return{id:m.id,type:i.MenuItemType.BUTTON,icon:`AlignTopIcon`,title:`drawing-ui.image-panel.align.top`}}function re(){return{id:h.id,type:i.MenuItemType.BUTTON,icon:`VerticalCenterIcon`,title:`drawing-ui.image-panel.align.middle`}}function ie(){return{id:g.id,type:i.MenuItemType.BUTTON,icon:`AlignBottomIcon`,title:`drawing-ui.image-panel.align.bottom`}}function ae(){return{id:_.id,type:i.MenuItemType.BUTTON,icon:`HorizontallyIcon`,title:`drawing-ui.image-panel.align.horizon`}}function oe(){return{id:v.id,type:i.MenuItemType.BUTTON,icon:`VerticalCenterIcon`,title:`drawing-ui.image-panel.align.vertical`}}let se=`contextMenu.drawing-arrange`;function ce(e){let t=e.get(n.IDrawingManagerService);return{id:se,type:i.MenuItemType.SUBITEMS,icon:`TopmostIcon`,title:`drawing-ui.image-panel.arrange.title`,hidden$:t.focus$.pipe((0,a.startWith)(t.getFocusDrawings()),(0,a.map)(e=>e.length===0))}}function le(){return{id:b.id,type:i.MenuItemType.BUTTON,icon:`TopmostIcon`,title:`drawing-ui.image-panel.arrange.front`}}function ue(){return{id:x.id,type:i.MenuItemType.BUTTON,icon:`MoveUpIcon`,title:`drawing-ui.image-panel.arrange.forward`}}function de(){return{id:S.id,type:i.MenuItemType.BUTTON,icon:`BottomIcon`,title:`drawing-ui.image-panel.arrange.back`}}function fe(){return{id:C.id,type:i.MenuItemType.BUTTON,icon:`MoveDownIcon`,title:`drawing-ui.image-panel.arrange.backward`}}function pe(e,r){let i=e.get(n.IDrawingManagerService);return new a.Observable(e=>{let a=i=>{if(!i||i.length===0)return e.next(!0);if(r===`group`){if(i.length<2||!i.every(e=>(0,n.isGroupableDrawingType)(e.drawingType)))return e.next(!0)}else if(r===`unGroup`){if(i.filter(e=>e.drawingType===t.DrawingTypeEnum.DRAWING_GROUP).length===0)return e.next(!0)}else if(!i.every(e=>(0,n.isGroupableDrawingType)(e.drawingType)))return e.next(!0);e.next(!1)},o=i.focus$.subscribe(t=>{if(!t||t.length===0)return e.next(!0);a(t)});return a(i.getFocusDrawings()),()=>o.unsubscribe()})}let me=`contextMenu.drawing-group`;function he(e){return{id:me,type:i.MenuItemType.SUBITEMS,icon:`GroupIcon`,title:`drawing-ui.image-panel.group.title`,hidden$:pe(e)}}function ge(e){return{id:T.id,type:i.MenuItemType.BUTTON,icon:`GroupIcon`,title:`drawing-ui.image-panel.group.group`,disabled$:pe(e,`group`)}}function _e(e){return{id:E.id,type:i.MenuItemType.BUTTON,icon:`UngroupIcon`,title:`drawing-ui.image-panel.group.unGroup`,disabled$:pe(e,`unGroup`)}}let ve={[i.ContextMenuPosition.DRAWING]:{[i.ContextMenuGroup.OTHERS]:{[me]:{order:1,menuItemFactory:he,[T.id]:{order:0,menuItemFactory:ge},[E.id]:{order:1,menuItemFactory:_e}},[se]:{order:2,menuItemFactory:ce,[b.id]:{order:0,menuItemFactory:le},[x.id]:{order:1,menuItemFactory:ue},[S.id]:{order:2,menuItemFactory:de},[C.id]:{order:3,menuItemFactory:fe}},[B]:{order:3,menuItemFactory:V,[d.id]:{order:0,menuItemFactory:H},[f.id]:{order:1,menuItemFactory:ee},[p.id]:{order:2,menuItemFactory:te},[m.id]:{order:3,menuItemFactory:ne},[h.id]:{order:4,menuItemFactory:re},[g.id]:{order:5,menuItemFactory:ie},[_.id]:{order:6,menuItemFactory:ae},[v.id]:{order:7,menuItemFactory:oe}}}}};var ye=`@univerjs/drawing-ui`,be=`1.0.3`;let xe=`drawing-ui.config`,Se={};function Ce(e){"@babel/helpers - typeof";return Ce=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},Ce(e)}function we(e,t){if(Ce(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(Ce(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function Te(e){var t=we(e,`string`);return Ce(t)==`symbol`?t:t+``}function U(e,t,n){return(t=Te(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}let Ee=`sheet.image-clip.shape.picker.component`;var De=class extends t.Disposable{constructor(){super(),U(this,`_clipDelegate`,null),U(this,`_canUseShapeClip$`,new a.BehaviorSubject(!1)),U(this,`canUseShapeClip$`,this._canUseShapeClip$.asObservable())}setCanUseShapeClip(e){this._canUseShapeClip$.next(e)}registerClipDelegate(e){return this._clipDelegate=e,(0,t.toDisposable)(()=>{this._clipDelegate===e&&(this._clipDelegate=null)})}applyShapeClip(e,t,n,r,i){return this._clipDelegate?this._clipDelegate(e,t,n,r,i):!1}dispose(){this._clipDelegate=null,this._canUseShapeClip$.complete(),super.dispose()}};function W(e,t){return function(n,r){t(n,r,e)}}function G(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}function Oe(e){return e.behindText===!0||e.behindText===t.BooleanNumber.TRUE||e.layoutType===t.PositionedObjectLayoutType.WRAP_NONE&&e.behindDoc===t.BooleanNumber.TRUE?1:r.DRAWING_OBJECT_LAYER_INDEX}function ke(e,t,n){let r=Oe(n);t.layer!=null&&t.layer.zIndex!==r&&(e.removeObject(t),e.addObject(t,r))}function Ae(e){return(e==null?void 0:e.complete)===!0&&e.naturalWidth>0&&e.naturalHeight>0}let K=class{constructor(e,t,n,r,i,a){this._drawingManagerService=e,this._imageIoService=t,this._galleryService=n,this._urlImageService=r,this._univerInstanceService=i,this._drawingImageClipService=a}async renderImages(e,i,a){let{transform:o,drawingType:s,source:c,imageSourceType:l,srcRect:u,prstGeom:d,groupId:f,unitId:p,subUnitId:m,drawingId:h,isMultiTransform:g,transforms:_,adjustValues:v,hidden:y}=e,{docxHeaderFooterDrawing:b,layoutType:x}=e;if(s!==t.DrawingTypeEnum.DRAWING_IMAGE||!this._drawingManagerService.getDrawingVisible()||!(a!=null&&a.allowInactiveSheet)&&this._univerInstanceService.getUnitType(p)===t.UniverInstanceType.UNIVER_SHEET&&m!==this._getActiveSheetId()||o==null)return;let S=g&&_?_:[o],C=[];for(let a of S){let{left:o,top:s,width:_,height:T,angle:E,flipX:D,flipY:O,skewX:k,skewY:A}=a,j=S.indexOf(a),M=(0,n.getDrawingShapeKeyByDrawingSearch)({unitId:p,subUnitId:m,drawingId:h},g?j:void 0),N=i.getObject(M);if(N!=null){var w;N.transformByState({left:o,top:s,width:_,height:T,angle:E,flipX:D,flipY:O,skewX:k,skewY:A}),(w=N.setClipBounds)==null||w.call(N,a.clipBounds),`hidden`in e&&(y?N.hide():N.show()),ke(i,N,e);continue}let P=this._drawingManagerService.getDrawingOrder(p,m),F=P.indexOf(h),I={...a,zIndex:F===-1?P.length-1:F},R=this._imageIoService.getImageSourceCache(c,l),z=!1;if(Ae(R))I.image=R;else if(l===t.ImageSourceType.UUID)try{I.url=await this._imageIoService.getImage(c)}catch(e){console.error(e);continue}else if(l===t.ImageSourceType.URL){try{I.url=await this._urlImageService.getImage(c)}catch(e){console.error(e),I.url=c}z=!0}else I.url=c,z=!0;let B=b===!0&&x===t.PositionedObjectLayoutType.INLINE;if((y||B)&&(I.visible=!1),i.getObject(M))continue;I.printable=!0;let V=new r.Image(M,I);V.setClipService(this._drawingImageClipService),z&&this._imageIoService.addImageSourceCache(c,l,V.getNative()),i.addObject(V,Oe(e)),this._drawingManagerService.getDrawingEditable()&&i.attachTransformerTo(V),f&&L({drawingId:f,unitId:p,subUnitId:m},V,i,this._drawingManagerService,g?j:void 0),d!=null&&V.setPrstGeom(d),v!=null&&V.setPrstGeomAdjValues(v),u!=null&&V.setSrcRect(u),C.push(V)}return C}_getActiveSheetId(){var e;return(e=this._univerInstanceService.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_SHEET))==null||(e=e.getActiveSheet())==null?void 0:e.getSheetId()}renderFloatDom(e,i){let{transform:a,drawingType:o,groupId:s,unitId:c,subUnitId:l,drawingId:u,isMultiTransform:d,transforms:f}=e;if(o!==t.DrawingTypeEnum.DRAWING_DOM||!this._drawingManagerService.getDrawingVisible()||a==null)return;let p=d&&f?f:[a],m=[];for(let t of p){let{left:a,top:o,width:f,height:h,angle:g,flipX:_,flipY:v,skewX:y,skewY:b}=t,x=p.indexOf(t),S=(0,n.getDrawingShapeKeyByDrawingSearch)({unitId:c,subUnitId:l,drawingId:u},d?x:void 0),C=i.getObject(S);if(C!=null){C.transformByState({left:a,top:o,width:f,height:h,angle:g,flipX:_,flipY:v,skewX:y,skewY:b});continue}let w=this._drawingManagerService.getDrawingOrder(c,l),T=w.indexOf(u),E={...t,zIndex:T===-1?w.length-1:T};if(i.getObject(S))continue;E.printable=!1;let D=new r.Rect(S,E);this._drawingManagerService.getDrawingVisible()&&(i.addObject(D,r.DRAWING_OBJECT_LAYER_INDEX),this._drawingManagerService.getDrawingEditable()&&e.allowTransform!==!1&&i.attachTransformerTo(D),s&&L({drawingId:s,unitId:c,subUnitId:l},D,i,this._drawingManagerService),m.push(D))}return m}renderDrawing(e,n,r){let i=this._drawingManagerService.getDrawingByParam(e);if(i!=null)switch(i.drawingType){case t.DrawingTypeEnum.DRAWING_IMAGE:return this.renderImages(i,n,r)}}previewImage(e,t,n,r){this._galleryService.open({images:[t],onOpenChange:e=>{e||this._galleryService.close()}})}_adjustImageSize(e,t,n,r){if(e<=n&&t<=r)return{width:e,height:t};let i=n/e,a=r/t,o=Math.min(i,a);return{width:Math.floor(e*o),height:Math.floor(t*o)}}};K=G([W(0,n.IDrawingManagerService),W(1,t.IImageIoService),W(2,i.IGalleryService),W(3,t.IURLImageService),W(4,t.IUniverInstanceService),W(5,(0,t.Inject)(De))],K);function q(e,n){let r=[];return e.forEach(e=>{let{oKey:i,left:a,top:o,height:s,width:c,angle:l}=e,u=n.getDrawingOKey(i);if(u==null)return r.push(null),!0;let{unitId:d,subUnitId:f,drawingId:p,drawingType:m}=u,h={unitId:d,subUnitId:f,drawingId:p,drawingType:m,transform:{left:a,top:o,height:s,width:c,angle:l}};m===t.DrawingTypeEnum.DRAWING_IMAGE&&(h.srcRect=e.srcRect),r.push(h)}),r}function je(e){return`hidden`in e||`behindText`in e||`selectable`in e}function Me(e,t){`hidden`in t&&(t.hidden===!0?e.hide():e.show())}function Ne(e,t,n,r){var i;let a=r.getOldDrawingByParam(t);if(!(`selectable`in t)&&(!a||!(`selectable`in a)))return;let o=t.selectable!==!1;if(e.evented=o,o)return;(i=n.getTransformer())==null||i.clearControlByIds([e.oKey]);let s=r.getFocusDrawings(),c=s.filter(({unitId:e,subUnitId:n,drawingId:r})=>e!==t.unitId||n!==t.subUnitId||r!==t.drawingId);c.length!==s.length&&r.focusDrawing(c)}function Pe(e,t){return je(t)?{...e,...t}:e}let J=class extends t.Disposable{constructor(e,t,n,r){super(),this._currentUniverService=e,this._commandService=t,this._renderManagerService=n,this._drawingManagerService=r,U(this,`_sceneListenerOnDrawingMap`,new WeakSet),this._initialize()}dispose(){super.dispose()}_initialize(){this._recoveryImages(),this._drawingAddListener(),this._drawingRemoveListener(),this._drawingUpdateListener(),this._commandExecutedListener(),this._drawingArrangeListener(),this._drawingGroupListener(),this._drawingRefreshListener(),this._drawingVisibleListener()}_recoveryImages(){let e=this._drawingManagerService.drawingManagerData,t=R(this._currentUniverService);if(t==null)return;let{unitId:n,subUnitId:r}=t;Object.keys(e).forEach(t=>{Object.keys(e[t]).forEach(i=>{let a=e[t][i].data;a!=null&&t===n&&i===r&&Object.keys(a).forEach(e=>{a[e]&&this._insertDrawing([{unitId:t,subUnitId:i,drawingId:e}])})})})}_commandExecutedListener(){this.disposeWithMe(this._commandService.onCommandExecuted(e=>{if(e.id===u.id){let t=e.params;if(t==null)return;this._drawingAlign(t)}}))}_drawingGroupListener(){this.disposeWithMe(this._drawingManagerService.group$.subscribe(e=>{this._groupDrawings(e)})),this.disposeWithMe(this._drawingManagerService.ungroup$.subscribe(e=>{this._ungroupDrawings(e)}))}_getSceneAndTransformerByDrawingSearch(e){if(e==null)return;let t=this._renderManagerService.getRenderUnitById(e),n=t==null?void 0:t.scene;return n==null?null:{scene:n,transformer:n.getTransformerByCreate()}}_groupDrawings(e){e.forEach(e=>{this._groupDrawing(e)})}_groupDrawing(e){let{parent:t,children:i}=e,{unitId:a,subUnitId:o,drawingId:s}=t,c=this._getSceneAndTransformerByDrawingSearch(t.unitId);if(c==null)return;let{scene:l,transformer:u}=c;this._commandService.syncExecuteCommand(O.id);let d=[];if(i.forEach(e=>{let t=(0,n.getDrawingShapeKeyByDrawingSearch)(e),i=l.getObjectIncludeInGroup(t);if(i==null||d.includes(i))return;d.push(i);let{transform:a}=e;a!=null&&(i.classType===r.RENDER_CLASS_TYPE.GROUP?i.transformByState({left:a.left,top:a.top}):i.transformByState(a))}),d.length===0)return;let f=(0,n.getDrawingShapeKeyByDrawingSearch)({unitId:a,subUnitId:o,drawingId:s}),p=new r.DrawingGroupObject(f);l.addObject(p,r.DRAWING_OBJECT_LAYER_INDEX).attachTransformerTo(p),p.addObjects(...d),I(p,t,l,this._drawingManagerService,i),t.groupBaseBound&&p.setBaseBound(t.groupBaseBound),t.groupId&&(p.isInGroup=!0,L({drawingId:t.groupId,unitId:a,subUnitId:o},p,l,this._drawingManagerService)),t.transform&&p.transformByState({left:t.transform.left,top:t.transform.top,width:t.transform.width,height:t.transform.height,angle:t.transform.angle}),u.clearSelectedObjects(),u.setSelectedControl(p)}_ungroupDrawings(e){e.forEach(e=>{this._ungroupDrawing(e)})}_ungroupDrawing(e){let{parent:t,children:i}=e,a=this._getSceneAndTransformerByDrawingSearch(t.unitId);if(a==null)return;let{scene:o,transformer:s}=a;i.forEach(e=>{let t=(0,n.getDrawingShapeKeyByDrawingSearch)(e),i=o.getObjectIncludeInGroup(t);if(i==null)return!0;if(i==null)return;let{transform:a}=e;a!=null&&(i.classType===r.RENDER_CLASS_TYPE.GROUP?i.transformByState({left:a.left,top:a.top}):i.transformByState(a))});let c=(0,n.getDrawingShapeKeyByDrawingSearch)(t),l=o.getObject(c),{width:u,height:d}=l;l.getObjects().forEach(e=>{l.removeSelfObjectAndTransform(e.oKey,u,d)}),l.dispose(),s.clearSelectedObjects()}_drawingAlign(e){let{alignType:t}=e,n=e.drawings||this._drawingManagerService.getFocusDrawings();if(t===`0`)return;let r=[],i=1/0,a=1/0,o=-1/0,s=-1/0,c=0;n.forEach(e=>{let{unitId:t,subUnitId:n,drawingId:l,drawingType:u}=e,d=this._drawingManagerService.getDrawingByParam({unitId:t,subUnitId:n,drawingId:l});if(d==null||d.transform==null)return;r.push({unitId:t,subUnitId:n,drawingId:l,drawingType:u,transform:d.transform});let{left:f=0,top:p=0,width:m=0,height:h=0}=d.transform;i=Math.min(i,f),a=Math.min(a,p),o=Math.max(o,f+m),s=Math.max(s,p+h),c++}),c!==0&&(this._sortDrawingTransform(r,t),this._applyAlignType(r,t,i,a,o,s,c))}_applyAlignType(e,t,n,r,i,a,o){let s=Math.round((i-n)/o*10)/10,c=Math.round((a-r)/o*10)/10,l=[],u=this._getSceneAndTransformerByDrawingSearch(e[0].unitId);if(u==null)return;let{scene:d,transformer:f}=u;e.forEach((e,o)=>{let{unitId:u,subUnitId:d,drawingId:f,transform:p,drawingType:m}=e,{left:h=0,top:g=0,width:_=0,height:v=0}=p,y=h,b=g;switch(t){case`1`:y=n;break;case`2`:y=n+(i-n)/2-_/2;break;case`3`:y=i-_;break;case`4`:b=r;break;case`5`:b=r+(a-r)/2-v/2;break;case`6`:b=a-v;break;case`7`:y=n+s*o;break;case`8`:b=r+c*o}(y!==h||b!==g)&&l.push({unitId:u,subUnitId:d,drawingId:f,drawingType:m,transform:{left:y,top:b}})}),this._drawingManagerService.featurePluginUpdateNotification(l),f.refreshControls().changeNotification()}_sortDrawingTransform(e,t){e.sort((e,n)=>{let r=e.transform,i=n.transform,{left:a=0,top:o=0,width:s=0,height:c=0}=r,{left:l=0,top:u=0,width:d=0,height:f=0}=i;switch(t){case`1`:return a-l;case`2`:return a+s/2-(l+d/2);case`3`:return a+s-(l+d);case`4`:return o-u;case`5`:return o+c/2-(u+f/2);case`6`:return o+c-(u+f);case`7`:return a+s/2-(l+d/2);case`8`:return o+c/2-(u+f/2);default:return 0}})}_drawingArrangeListener(){this.disposeWithMe(this._drawingManagerService.order$.subscribe(e=>{this._drawingArrange(e)}))}_drawingArrange(e){let{unitId:t,subUnitId:r,drawingIds:i}=e,a=this._getSceneAndTransformerByDrawingSearch(t);if(a==null)return;let{scene:o}=a;i.forEach(e=>{let i=(0,n.getDrawingShapeKeyByDrawingSearch)({unitId:t,subUnitId:r,drawingId:e}),a=o.fuzzyMathObjects(i,!0);if(a==null||a.length===0)return;let s=this._drawingManagerService.getDrawingOrder(t,r).indexOf(e);for(let e of a)e.setProps({zIndex:s}),e.makeDirty()})}_drawingAddListener(){this.disposeWithMe(this._drawingManagerService.add$.subscribe(e=>{this._insertDrawing(e)}))}_insertDrawing(e){let t=[];e.forEach(e=>{let{unitId:n}=e;if(this._drawingManagerService.getDrawingByParam(e)==null)return;let r=this._getSceneAndTransformerByDrawingSearch(n);if(r==null)return;let{scene:i}=r;t.includes(i)||t.push(i)}),t.forEach(e=>{this._sceneListenerOnDrawingMap.has(e)||(this._addListenerOnDrawing(e),this._sceneListenerOnDrawingMap.add(e))})}_drawingRemoveListener(){this.disposeWithMe(this._drawingManagerService.remove$.subscribe(e=>{e.forEach(e=>{let{unitId:t}=e,n=this._getSceneAndTransformerByDrawingSearch(t);if(n==null)return;let{scene:r}=n;if(P(r,e)){var i;(i=r.getTransformer())==null||i.clearSelectedObjects()}})}))}_drawingUpdateListener(){this.disposeWithMe(this._drawingManagerService.update$.subscribe(e=>{e.forEach(e=>{var t,r;let{unitId:i,subUnitId:a,drawingId:o}=e,s=this._drawingManagerService.getDrawingByParam(e);if(s==null)return;let{transform:c,drawingType:l}=s,u=this._getSceneAndTransformerByDrawingSearch(i);if(u==null)return;let{scene:d,transformer:f}=u;if(c==null)return!0;let{left:p=0,top:m=0,width:h=0,height:g=0,angle:_=0,flipX:v=!1,flipY:y=!1,skewX:b=0,skewY:x=0}=c,S=(0,n.getDrawingShapeKeyByDrawingSearch)({unitId:i,subUnitId:a,drawingId:o}),C=d.getObjectIncludeInGroup(S);if(C==null)return!0;C.transformByState({left:p,top:m,width:h,height:g,angle:_,flipX:v,flipY:y,skewX:b,skewY:x}),(t=C.setClipBounds)==null||t.call(C,c.clipBounds),Me(C,s),Ne(C,s,d,this._drawingManagerService),ke(d,C,s),(r=d.getTransformer())==null||r.debounceRefreshControls()})}))}_drawingRefreshListener(){this.disposeWithMe(this._drawingManagerService.refreshTransform$.subscribe(e=>{e.forEach(e=>{var t;let{unitId:r,subUnitId:i,drawingId:a}=e,o=this._getSceneAndTransformerByDrawingSearch(r);if(o==null)return;let s=this._drawingManagerService.getDrawingByParam(e);if(s==null)return;let{transform:c}=s,{scene:l}=o;if(c==null)return!0;let u=(0,n.getDrawingShapeKeyByDrawingSearch)({unitId:r,subUnitId:i,drawingId:a}),d=l.getObjectIncludeInGroup(u),f=Pe(s,e);if(d==null)return f.hidden===!0||this._drawingManagerService.addNotification([{unitId:r,subUnitId:i,drawingId:a}]),!0;let{left:p=0,top:m=0,width:h=0,height:g=0,angle:_=0,flipX:v=!1,flipY:y=!1,skewX:b=0,skewY:x=0}=c;d.transformByState({left:p,top:m,width:h,height:g,angle:_,flipX:v,flipY:y,skewX:b,skewY:x}),(t=d.setClipBounds)==null||t.call(d,c.clipBounds),Me(d,f),Ne(d,f,l,this._drawingManagerService),ke(l,d,f)})}))}_drawingVisibleListener(){this.disposeWithMe(this._drawingManagerService.visible$.subscribe(e=>{e.forEach(e=>{let{unitId:t,subUnitId:r,drawingId:i,visible:a}=e,o=this._getSceneAndTransformerByDrawingSearch(t);if(o==null)return;let{scene:s}=o,c=(0,n.getDrawingShapeKeyByDrawingSearch)({unitId:t,subUnitId:r,drawingId:i}),l=s.getObjectIncludeInGroup(c);if(l==null)return!0;a?l.show():l.hide()})}))}_filterUpdateParams(e,n){return e.filter((e,r)=>{if(e==null)return!1;let{transform:i}=e;return(0,t.checkIfMove)(i,n==null?void 0:n[r])})}_addListenerOnDrawing(e){let i=e.getTransformerByCreate(),a=null;this.disposeWithMe((0,t.toDisposable)(i.changeStart$.subscribe(e=>{let{objects:t}=e,i=Array.from(t.values()),o=[];a=i.map(e=>{let{left:t,top:n,height:i,width:a,angle:s,oKey:c,isInGroup:l}=e,u=this._drawingManagerService.getDrawingOKey(c);if(l||e instanceof r.Group){let t=e.ancestorGroup;if(t==null&&e instanceof r.Group&&(t=e),t==null)return null;let n=this._drawingManagerService.getDrawingOKey(t.oKey);if(n){let{unitId:e,subUnitId:r,drawingId:i}=n;o.push({unitId:e,subUnitId:r,drawingId:i});let{left:a,top:s,height:c,width:l,angle:u}=t;return{left:a,top:s,height:c,width:l,angle:u}}}else if(u!=null){let{unitId:e,subUnitId:r,drawingId:c}=u;return o.push({unitId:e,subUnitId:r,drawingId:c}),{left:t,top:n,height:i,width:a,angle:s}}return null}).filter(e=>e!=null),o.length>0?this._commandService.syncExecuteCommand(n.SetDrawingSelectedOperation.id,o):this._commandService.syncExecuteCommand(n.SetDrawingSelectedOperation.id,[])}))),this.disposeWithMe((0,t.toDisposable)(i.changeEnd$.subscribe(e=>{let{objects:t}=e,n=this._filterUpdateParams(q(t,this._drawingManagerService),a);n.length>0&&this._drawingManagerService.featurePluginUpdateNotification(n)})))}};J=G([W(0,t.IUniverInstanceService),W(1,t.ICommandService),W(2,r.IRenderManagerService),W(3,n.IDrawingManagerService)],J);function Y({ref:e,...t}){let{preserveStrokeWidth:n,icon:r,id:i,className:a,extend:s,...c}=t,l=`univerjs-icon univerjs-icon-${i} ${a||``}`.trim(),u=`_${(0,o.useId)()}`,d=(0,o.useRef)(null);return(0,o.useImperativeHandle)(e,()=>d.current),(0,o.useLayoutEffect)(()=>{if(n&&d.current&&d.current.localName===r.tag)return Re(d.current)},[n,r]),Fe(r,`${i}`,{defIds:r.defIds,idSuffix:u},{ref:d,className:l,...c},s)}function Fe(e,t,n,r,i){return(0,o.createElement)(e.tag,{key:t,...Ie(e,n,i),...r},(Le(e,n).children||[]).map((r,a)=>Fe(r,`${t}-${e.tag}-${a}`,n,void 0,i)))}function Ie(e,t,n){let r={...e.attrs};n!=null&&n.colorChannel1&&r.fill===`colorChannel1`&&(r.fill=n.colorChannel1),n!=null&&n.colorChannel1&&r.stroke===`colorChannel1`&&(r.stroke=n.colorChannel1),e.tag===`mask`&&r.id&&(r.id+=t.idSuffix),Object.entries(r).forEach(([e,n])=>{e===`mask`&&typeof n==`string`&&(r[e]=n.replace(/url\(#(.*)\)/,`url(#$1${t.idSuffix})`))});let{defIds:i}=t;return!i||i.length===0?r:(e.tag===`use`&&r[`xlink:href`]&&(r[`xlink:href`]+=t.idSuffix),Object.entries(r).forEach(([e,n])=>{typeof n==`string`&&(r[e]=n.replace(/url\(#(.*)\)/,`url(#$1${t.idSuffix})`))}),r)}function Le(e,t){var n;let{defIds:r}=t;return!r||r.length===0?e:e.tag===`defs`&&(n=e.children)!=null&&n.length?{...e,children:e.children.map(e=>typeof e.attrs.id==`string`&&r&&r.includes(e.attrs.id)?{...e,attrs:{...e.attrs,id:e.attrs.id+t.idSuffix}}:e)}:e}function Re(e){let t=e.viewBox.baseVal,n=Math.max(t.width,t.height);if(!Number.isFinite(n)||n<=0||t.width<=0||t.height<=0)return()=>void 0;let r=16/n,i=Array.from(e.querySelectorAll(`circle, ellipse, line, path, polygon, polyline, rect, text, textPath, tspan, use`)).flatMap(e=>{let t=getComputedStyle(e),n=Number.parseFloat(t.strokeWidth);return t.stroke===`none`||Number.parseFloat(t.strokeOpacity)===0||t.vectorEffect===`non-scaling-stroke`||!Number.isFinite(n)||n<=0?[]:[{element:e,hadStyleAttribute:e.hasAttribute(`style`),originalStrokeWidth:n,strokeWidth:ze(e.style,`stroke-width`)}]}).map(e=>({appliedStrokeWidth:null,element:e.element,hadStyleAttribute:e.hadStyleAttribute,isReleased:!1,originalStrokeWidth:e.originalStrokeWidth,strokeWidth:e.strokeWidth}));if(i.length===0)return()=>void 0;let a=(e,n)=>{if(t.width<=0||t.height<=0||e<=0||n<=0)return;let a=Math.min(e/t.width,n/t.height);!Number.isFinite(a)||a<=0||i.forEach(e=>{if(e.isReleased)return;if(e.appliedStrokeWidth!==null&&(e.element.style.getPropertyValue(`stroke-width`)!==e.appliedStrokeWidth||e.element.style.getPropertyPriority(`stroke-width`)!==e.strokeWidth.priority)){e.appliedStrokeWidth=null,e.isReleased=!0;return}let t=e.originalStrokeWidth*r/a,n=`${Number(t.toFixed(12))}px`;e.element.style.setProperty(`stroke-width`,n,e.strokeWidth.priority),e.appliedStrokeWidth=n})},o=e.getBoundingClientRect();a(o.width,o.height);let s=typeof ResizeObserver>`u`?null:new ResizeObserver(t=>{if(t.some(t=>t.target===e)){let t=e.getBoundingClientRect();a(t.width,t.height)}});return s==null||s.observe(e),()=>{s==null||s.disconnect(),i.forEach(e=>{e.appliedStrokeWidth!==null&&(Be(e.element.style,`stroke-width`,e.appliedStrokeWidth,e.strokeWidth.priority,e.strokeWidth),!e.hadStyleAttribute&&e.element.style.length===0&&e.element.removeAttribute(`style`))})}}function ze(e,t){return{priority:e.getPropertyPriority(t),value:e.getPropertyValue(t)}}function Be(e,t,n,r,i){e.getPropertyValue(t)===n&&e.getPropertyPriority(t)===r&&(i.value?e.setProperty(t,i.value,i.priority):e.removeProperty(t))}Y.displayName=`UniverIcon`;let Ve={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 20 21`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M8.90467 3.99244C8.84611 4.1338 8.84611 4.31301 8.84611 4.67143V13.716L5.92068 10.7906C5.66724 10.5371 5.54052 10.4104 5.39916 10.3519C5.21067 10.2738 4.9989 10.2738 4.81041 10.3519C4.66905 10.4104 4.54233 10.5371 4.28889 10.7906C4.03545 11.044 3.90873 11.1707 3.85018 11.3121C3.77211 11.5006 3.77211 11.7124 3.85018 11.9008C3.90873 12.0422 4.03545 12.1689 4.28889 12.4224L9.03476 17.1682C9.07839 17.2127 9.12737 17.2617 9.18231 17.3166L9.18239 17.3167L9.18241 17.3167C9.40545 17.5398 9.53035 17.6647 9.65346 17.7313C9.67085 17.7408 9.6882 17.7492 9.70577 17.7564C9.89425 17.8345 10.106 17.8345 10.2945 17.7564C10.4359 17.6979 10.5626 17.5712 10.816 17.3177C10.8986 17.2352 10.9677 17.1661 11.0253 17.1056L15.7095 12.4214L15.7095 12.4213C15.963 12.1679 16.0897 12.0412 16.1482 11.8998C16.2263 11.7114 16.2263 11.4996 16.1482 11.3111C16.0897 11.1697 15.963 11.043 15.7095 10.7896C15.4561 10.5361 15.3294 10.4094 15.188 10.3509C14.9995 10.2728 14.7878 10.2728 14.5993 10.3509C14.4579 10.4094 14.3312 10.5361 14.0778 10.7896L14.0777 10.7896L11.1538 13.7135V4.67142C11.1538 4.31301 11.1538 4.1338 11.0953 3.99244C11.0172 3.80395 10.8674 3.6542 10.6789 3.57613C10.5376 3.51758 10.3584 3.51758 9.99996 3.51758C9.64154 3.51758 9.46233 3.51758 9.32097 3.57613C9.13249 3.6542 8.98274 3.80395 8.90467 3.99244Z`,fillRule:`evenodd`,clipRule:`evenodd`}}]},He=(0,o.forwardRef)(function(e,t){return(0,o.createElement)(Y,Object.assign({},e,{id:`arrow-down-icon`,ref:t,icon:Ve}))});He.displayName=`ArrowDownIcon`;let Ue={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 20 21`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M11.0936 17.3406C11.1522 17.1992 11.1522 17.02 11.1522 16.6616V7.61701L14.0776 10.5424C14.3311 10.7959 14.4578 10.9226 14.5991 10.9811C14.7876 11.0592 14.9994 11.0592 15.1879 10.9811C15.3292 10.9226 15.456 10.7959 15.7094 10.5424C15.9628 10.289 16.0896 10.1623 16.1481 10.0209C16.2262 9.83243 16.2262 9.62066 16.1481 9.43217C16.0896 9.29081 15.9628 9.16409 15.7094 8.91065L10.9645 4.16576C10.9207 4.12105 10.8714 4.07178 10.8161 4.01648L10.8159 4.0163C10.5916 3.792 10.4666 3.66696 10.3428 3.60058C10.3261 3.59154 10.3094 3.58358 10.2925 3.57658C10.104 3.49851 9.89226 3.49851 9.70378 3.57658C9.56242 3.63514 9.4357 3.76186 9.18226 4.0153C9.09955 4.09801 9.03034 4.16722 8.97258 4.22785L4.28878 8.91166C4.03534 9.1651 3.90862 9.29182 3.85006 9.43318C3.77199 9.62166 3.77199 9.83344 3.85006 10.0219C3.90862 10.1633 4.03534 10.29 4.28878 10.5434C4.54221 10.7969 4.66893 10.9236 4.8103 10.9822C4.99878 11.0602 5.21056 11.0602 5.39904 10.9822C5.5404 10.9236 5.66712 10.7969 5.92056 10.5434L5.92056 10.5434L8.84449 7.61951V16.6616C8.84449 17.02 8.84449 17.1992 8.90305 17.3406C8.98112 17.5291 9.13087 17.6788 9.31935 17.7569C9.46072 17.8154 9.63992 17.8154 9.99834 17.8154C10.3568 17.8154 10.536 17.8154 10.6773 17.7569C10.8658 17.6788 11.0156 17.5291 11.0936 17.3406Z`,fillRule:`evenodd`,clipRule:`evenodd`}}]},We=(0,o.forwardRef)(function(e,t){return(0,o.createElement)(Y,Object.assign({},e,{id:`arrow-up-icon`,ref:t,icon:Ue}))});We.displayName=`ArrowUpIcon`;let Ge={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 17 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M14.0045 4.4334C14.8881 4.4334 15.6045 3.71705 15.6045 2.8334C15.6045 1.94974 14.8881 1.2334 14.0045 1.2334H3.70449C2.82084 1.2334 2.10449 1.94974 2.10449 2.8334C2.10449 3.71705 2.82084 4.4334 3.70449 4.4334H14.0045ZM14.4045 2.8334C14.4045 3.05431 14.2254 3.2334 14.0045 3.2334H3.70449C3.48358 3.2334 3.30449 3.05431 3.30449 2.8334C3.30449 2.61248 3.48358 2.4334 3.70449 2.4334H14.0045C14.2254 2.4334 14.4045 2.61249 14.4045 2.8334Z`,fillRule:`evenodd`,clipRule:`evenodd`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M14.1544 8.5999C15.038 8.5999 15.7544 7.88356 15.7544 6.9999C15.7544 6.11625 15.038 5.3999 14.1544 5.3999H3.85439C2.97074 5.3999 2.25439 6.11625 2.25439 6.9999C2.25439 7.88356 2.97074 8.5999 3.85439 8.5999H14.1544ZM14.5544 6.9999C14.5544 7.22082 14.3753 7.3999 14.1544 7.3999H3.85439C3.63348 7.3999 3.45439 7.22082 3.45439 6.9999C3.45439 6.77899 3.63348 6.5999 3.85439 6.5999H14.1544C14.3753 6.5999 14.5544 6.77899 14.5544 6.9999Z`,fillRule:`evenodd`,clipRule:`evenodd`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M8.57975 14.5902L6.58023 12.5907C6.34591 12.3564 6.34591 11.9765 6.58023 11.7421C6.81454 11.5078 7.19444 11.5078 7.42876 11.7421L8.40449 12.7179V10.1664C8.40449 9.83504 8.67312 9.56641 9.00449 9.56641C9.33586 9.56641 9.60449 9.83504 9.60449 10.1664V12.7179L10.5802 11.7421C10.8145 11.5078 11.1944 11.5078 11.4288 11.7421C11.6631 11.9765 11.6631 12.3564 11.4288 12.5907L9.42923 14.5902`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M8.57975 14.5902C8.58121 14.5917 8.58268 14.5931 8.58416 14.5946C8.64077 14.6502 8.70566 14.6923 8.77482 14.7209C8.84557 14.7502 8.92314 14.7664 9.00449 14.7664C9.08585 14.7664 9.16342 14.7502 9.23416 14.7209C9.30332 14.6923 9.36821 14.6502 9.42482 14.5946`}}]},Ke=(0,o.forwardRef)(function(e,t){return(0,o.createElement)(Y,Object.assign({},e,{id:`bottom-icon`,ref:t,icon:Ge}))});Ke.displayName=`BottomIcon`;let qe={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{stroke:`currentColor`,d:`M1 14.4076H15`,strokeLinecap:`round`,strokeWidth:1.2}},{tag:`rect`,attrs:{width:2.6,height:5.72,x:1.94,y:6.47,stroke:`currentColor`,rx:1.3,strokeWidth:1.2}},{tag:`path`,attrs:{stroke:`currentColor`,d:`M9.29961 5.6002V10.892C9.29961 11.61 8.71758 12.192 7.99961 12.192C7.28164 12.192 6.69961 11.61 6.69961 10.892V5.6002C6.69961 4.88222 7.28164 4.3002 7.99961 4.3002C8.71758 4.3002 9.29961 4.88223 9.29961 5.6002Z`,strokeWidth:1.2}},{tag:`rect`,attrs:{width:2.6,height:10.6,x:11.46,y:1.59,stroke:`currentColor`,rx:1.3,strokeWidth:1.2}}]},Je=(0,o.forwardRef)(function(e,t){return(0,o.createElement)(Y,Object.assign({},e,{id:`chart-icon`,ref:t,icon:qe}))});Je.displayName=`ChartIcon`;let Ye={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M14.1544 3.75557C14.3887 3.98988 14.3887 4.36978 14.1544 4.6041L6.51409 12.2444C6.40157 12.3569 6.24896 12.4201 6.08983 12.4201C5.9307 12.4201 5.77808 12.3569 5.66556 12.2444L1.84541 8.42425C1.6111 8.18993 1.6111 7.81003 1.84541 7.57572C2.07973 7.34141 2.45963 7.34141 2.69394 7.57572L6.08983 10.9716L13.3059 3.75557C13.5402 3.52126 13.9201 3.52126 14.1544 3.75557Z`,fillRule:`evenodd`,clipRule:`evenodd`}}]},Xe=(0,o.forwardRef)(function(e,t){return(0,o.createElement)(Y,Object.assign({},e,{id:`check-mark-icon`,ref:t,icon:Ye}))});Xe.displayName=`CheckMarkIcon`;let Ze={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M3.71274 2.86421C3.47843 2.6299 3.09853 2.6299 2.86421 2.86421C2.6299 3.09853 2.6299 3.47843 2.86421 3.71274L7.15154 8.00007L2.86421 12.2874C2.6299 12.5217 2.6299 12.9016 2.86421 13.1359C3.09853 13.3702 3.47843 13.3702 3.71274 13.1359L8.00007 8.84859L12.2874 13.1359C12.5217 13.3702 12.9016 13.3702 13.1359 13.1359C13.3702 12.9016 13.3702 12.5217 13.1359 12.2874L8.84859 8.00007L13.1359 3.71274C13.3702 3.47843 13.3702 3.09853 13.1359 2.86421C12.9016 2.6299 12.5217 2.6299 12.2874 2.86421L8.00007 7.15154L3.71274 2.86421Z`}}]},Qe=(0,o.forwardRef)(function(e,t){return(0,o.createElement)(Y,Object.assign({},e,{id:`close-icon`,ref:t,icon:Ze}))});Qe.displayName=`CloseIcon`;let $e={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M5.97705 7.51296C5.97705 7.18159 6.24568 6.91296 6.57705 6.91296H8.48632C8.81769 6.91296 9.08632 7.18159 9.08632 7.51296C9.08632 7.84433 8.81769 8.11296 8.48632 8.11296H6.57705C6.24568 8.11296 5.97705 7.84433 5.97705 7.51296Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M6.57705 9.41028C6.24568 9.41028 5.97705 9.67891 5.97705 10.0103C5.97705 10.3416 6.24568 10.6103 6.57705 10.6103H10.8199C11.1512 10.6103 11.4199 10.3416 11.4199 10.0103C11.4199 9.67891 11.1512 9.41028 10.8199 9.41028H6.57705Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M3.51074 2.37063C3.51074 1.48697 4.22709 0.77063 5.11074 0.77063H9.80318L9.81294 0.770708C9.97168 0.768161 10.1311 0.82824 10.2511 0.95055L14.4317 5.21408C14.5165 5.30049 14.5697 5.406 14.5917 5.51645C14.6041 5.5644 14.6106 5.61467 14.6106 5.66648V11.6406C14.6106 12.5243 13.8943 13.2406 13.0106 13.2406H5.11074C4.22709 13.2406 3.51074 12.5243 3.51074 11.6406V2.37063ZM10.4032 4.66648V2.81964L12.6063 5.06648H10.8032C10.5823 5.06648 10.4032 4.88739 10.4032 4.66648ZM5.11074 1.97063C4.88983 1.97063 4.71074 2.14972 4.71074 2.37063V11.6406C4.71074 11.8615 4.88983 12.0406 5.11074 12.0406H13.0106C13.2316 12.0406 13.4106 11.8615 13.4106 11.6406V6.26648H10.8032C9.91953 6.26648 9.20318 5.55013 9.20318 4.66648V1.97063H5.11074Z`,fillRule:`evenodd`,clipRule:`evenodd`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M2.58916 6.6741C2.58916 6.34273 2.32053 6.0741 1.98916 6.0741C1.65779 6.0741 1.38916 6.34273 1.38916 6.6741V12.6294C1.38916 14.0653 2.55322 15.2294 3.98916 15.2294H9.41408C9.74545 15.2294 10.0141 14.9607 10.0141 14.6294C10.0141 14.298 9.74545 14.0294 9.41408 14.0294H3.98916C3.21596 14.0294 2.58916 13.4026 2.58916 12.6294V6.6741Z`}}]},et=(0,o.forwardRef)(function(e,t){return(0,o.createElement)(Y,Object.assign({},e,{id:`create-copy-icon`,ref:t,icon:$e}))});et.displayName=`CreateCopyIcon`;let tt={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`1.05 1.05 17.9 17.9`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{stroke:`currentColor`,d:`M5 2.8V12.5C5 13.9 6.1 15 7.5 15H17.2`,strokeLinecap:`round`,strokeWidth:1.5}},{tag:`path`,attrs:{stroke:`currentColor`,d:`M2.8 5H12.5C13.9 5 15 6.1 15 7.5V17.2`,strokeLinecap:`round`,strokeWidth:1.5}},{tag:`path`,attrs:{stroke:`currentColor`,d:`M8.3 8.3H11.7V11.7H8.3V8.3Z`,strokeWidth:1.2}}]},nt=(0,o.forwardRef)(function(e,t){return(0,o.createElement)(Y,Object.assign({},e,{id:`crop-icon`,ref:t,icon:tt}))});nt.displayName=`CropIcon`;let rt={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M5.3313 1.4667C5.3313 1.13533 5.59993 0.866699 5.9313 0.866699H10.069C10.4004 0.866699 10.669 1.13533 10.669 1.4667C10.669 1.79807 10.4004 2.0667 10.069 2.0667H5.9313C5.59993 2.0667 5.3313 1.79807 5.3313 1.4667Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M1.09985 3.64443C1.09985 3.31306 1.36848 3.04443 1.69985 3.04443H14.2999C14.6312 3.04443 14.8999 3.31306 14.8999 3.64443C14.8999 3.9758 14.6312 4.24443 14.2999 4.24443H1.69985C1.36848 4.24443 1.09985 3.9758 1.09985 3.64443Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M6.12398 8.30171C6.35829 8.0674 6.73819 8.0674 6.97251 8.30171L8.00007 9.32928L9.02764 8.30171C9.26195 8.0674 9.64185 8.0674 9.87617 8.30171C10.1105 8.53603 10.1105 8.91593 9.87617 9.15024L8.8486 10.1778L9.87617 11.2054C10.1105 11.4397 10.1105 11.8196 9.87617 12.0539C9.64185 12.2882 9.26195 12.2882 9.02764 12.0539L8.00007 11.0263L6.97251 12.0539C6.73819 12.2882 6.35829 12.2882 6.12398 12.0539C5.88966 11.8196 5.88966 11.4397 6.12398 11.2054L7.15154 10.1778L6.12398 9.15024C5.88966 8.91593 5.88966 8.53603 6.12398 8.30171Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M4.75332 5.22217C3.86966 5.22217 3.15332 5.93851 3.15332 6.82217V12.5331C3.15332 13.9691 4.31738 15.1332 5.75332 15.1332H10.2465C11.6825 15.1332 12.8465 13.9691 12.8465 12.5331V6.82217C12.8465 5.93851 12.1302 5.22217 11.2465 5.22217H4.75332ZM4.35332 6.82217C4.35332 6.60125 4.53241 6.42217 4.75332 6.42217H11.2465C11.4674 6.42217 11.6465 6.60125 11.6465 6.82217V12.5331C11.6465 13.3063 11.0197 13.9332 10.2465 13.9332H5.75332C4.98012 13.9332 4.35332 13.3063 4.35332 12.5331V6.82217Z`,fillRule:`evenodd`,clipRule:`evenodd`}}]},it=(0,o.forwardRef)(function(e,t){return(0,o.createElement)(Y,Object.assign({},e,{id:`delete-icon`,ref:t,icon:rt}))});it.displayName=`DeleteIcon`;let at={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{stroke:`currentColor`,d:`M6.18958 14.085H4.0929C2.98833 14.085 2.0929 13.1895 2.0929 12.085V3.5918C2.0929 2.48723 2.98833 1.5918 4.0929 1.5918H10.5031C11.6077 1.5918 12.5031 2.48723 12.5031 3.5918V6.41602`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:1.33}},{tag:`path`,attrs:{stroke:`currentColor`,d:`M4.73547 4.57324H9.96594M4.73547 7.08105H7.91614`,strokeLinecap:`round`,strokeWidth:1.33}},{tag:`path`,attrs:{stroke:`currentColor`,d:`M10.0255 9.17969H11.9572L13.7687 11.7939L11.9572 14.4082H10.0255L8.21399 11.7939L10.0255 9.17969Z`,strokeLinejoin:`round`,strokeWidth:1.33}},{tag:`path`,attrs:{stroke:`currentColor`,d:`M10.9913 11.7939H10.9914`,strokeLinecap:`round`,strokeWidth:1.83}}]},ot=(0,o.forwardRef)(function(e,t){return(0,o.createElement)(Y,Object.assign({},e,{id:`doc-setting-icon`,ref:t,icon:at}))});ot.displayName=`DocSettingIcon`;let st={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{stroke:`currentColor`,d:`M10 10L14 14M10 6L14 2M14 10.6667V14H10.6667M14 5.33333V2H10.6667M2 10.6667V14H5.33333M2 14L6 10M2 5.33333V2H5.33333M6 6L2 2`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:1.2}}]},ct=(0,o.forwardRef)(function(e,t){return(0,o.createElement)(Y,Object.assign({},e,{id:`expand-icon`,ref:t,icon:st}))});ct.displayName=`ExpandIcon`;let lt={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M7.46613 5.2614C7.99641 5.15377 8.54607 5.209 9.04566 5.42016C9.54527 5.63133 9.9725 5.98902 10.2732 6.44821C10.5739 6.90741 10.7345 7.44742 10.7345 7.99994C10.7345 8.74088 10.446 9.45122 9.93293 9.97475C9.41991 10.4982 8.72439 10.7921 7.99945 10.7921C7.45882 10.7921 6.93021 10.6285 6.48047 10.3219C6.03072 10.0152 5.67998 9.57922 5.47282 9.06887C5.26565 8.55852 5.21142 7.99686 5.31705 7.45498C5.42268 6.9131 5.68338 6.41554 6.06598 6.02513C6.44856 5.63474 6.93584 5.36903 7.46613 5.2614ZM7.99945 6.50637C7.70941 6.50637 7.42599 6.59414 7.18504 6.75842C6.94411 6.92269 6.75652 7.15604 6.64579 7.4288C6.53508 7.70156 6.50613 8.00161 6.56255 8.29108C6.61898 8.58055 6.7583 8.84663 6.96308 9.05559C7.16788 9.26456 7.42896 9.40703 7.7134 9.46476C7.99784 9.5225 8.29266 9.49286 8.56052 9.37964C8.82836 9.26643 9.05707 9.07481 9.21789 8.82922C9.3787 8.58364 9.46445 8.29505 9.46445 7.99994C9.46445 7.60424 9.31042 7.22449 9.03583 6.94429C8.76119 6.66405 8.38842 6.50637 7.99945 6.50637Z`,fillRule:`evenodd`,clipRule:`evenodd`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M1.06445 7.99994C1.06445 7.86432 1.111 7.68433 1.20506 7.46997C1.29865 7.25669 1.43723 7.01393 1.61634 6.75416C1.97451 6.23466 2.49209 5.65088 3.12753 5.10347C4.3995 4.00771 6.13495 3.06494 7.99945 3.06494C9.86395 3.06494 11.5994 4.00771 12.8714 5.10347C13.5068 5.65088 14.0244 6.23466 14.3826 6.75416C14.5617 7.01393 14.7003 7.25669 14.7938 7.46997C14.8879 7.68433 14.9345 7.86432 14.9345 7.99994C14.9345 8.29406 14.7859 8.75016 14.4847 9.27371C14.1847 9.79497 13.7374 10.3759 13.1495 10.9188C11.974 12.0042 10.2392 12.9349 7.99945 12.9349C5.75972 12.9349 4.02489 12.0042 2.84937 10.9188C2.26147 10.3759 1.81418 9.79497 1.51423 9.27371C1.21296 8.75016 1.06445 8.29406 1.06445 7.99994ZM7.99945 4.36351C6.48933 4.36351 5.14092 5.09788 4.14125 5.91406C3.64087 6.32258 3.22616 6.75295 2.92026 7.12521C2.61595 7.49554 2.415 7.81359 2.34753 7.99756L2.33827 8.0228L2.34954 8.0472C2.85275 9.13669 3.65354 10.055 4.65594 10.6918C5.65805 11.3283 6.81899 11.6563 7.99945 11.6364C9.17991 11.6563 10.3409 11.3283 11.343 10.6918C12.3454 10.055 13.1462 9.13669 13.6494 8.0472L13.6606 8.0228L13.6514 7.99756C13.5839 7.81359 13.383 7.49554 13.0786 7.12521C12.7727 6.75295 12.358 6.32258 11.8577 5.91406C10.858 5.09788 9.50957 4.36351 7.99945 4.36351Z`,fillRule:`evenodd`,clipRule:`evenodd`}}]},ut=(0,o.forwardRef)(function(e,t){return(0,o.createElement)(Y,Object.assign({},e,{id:`eye-icon`,ref:t,icon:lt}))});ut.displayName=`EyeIcon`;let dt={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M1.28096 4.6541C1.57489 4.50109 1.93721 4.61533 2.09022 4.90926C2.27315 5.26067 2.55999 5.60455 2.94829 5.92278C4.04628 6.82266 5.87505 7.44865 7.99828 7.44865C10.1215 7.44865 11.9503 6.82267 13.0482 5.92279C13.4366 5.60455 13.7234 5.26067 13.9063 4.90927C14.0594 4.61533 14.4217 4.50109 14.7156 4.65409C15.0095 4.8071 15.1238 5.16941 14.9708 5.46334C14.6995 5.98445 14.2981 6.44997 13.8089 6.8509C13.7298 6.91575 13.6481 6.97914 13.564 7.041L15.2245 8.70153C15.4588 8.93585 15.4588 9.31575 15.2245 9.55006C14.9902 9.78438 14.6103 9.78438 14.376 9.55006L12.5041 7.67822C11.8977 7.97568 11.2181 8.21208 10.4884 8.37706L11.0996 10.6581C11.1853 10.9782 10.9954 11.3072 10.6753 11.393C10.3552 11.4787 10.0262 11.2888 9.94045 10.9687L9.29949 8.57652C8.8758 8.62404 8.44081 8.64865 7.99828 8.64865C7.55276 8.64865 7.11487 8.62371 6.68846 8.57555L6.04723 10.9687C5.96147 11.2888 5.63247 11.4788 5.31239 11.393C4.99231 11.3073 4.80236 10.9783 4.88812 10.6582L5.49983 8.37516C4.7743 8.2105 4.09843 7.9752 3.49498 7.67947L1.62436 9.55009C1.39005 9.78441 1.01015 9.78441 0.775835 9.5501C0.54152 9.31578 0.541518 8.93588 0.775832 8.70157L2.43478 7.04261C2.34987 6.98024 2.26746 6.91632 2.18764 6.8509C1.69842 6.44997 1.29706 5.98445 1.0258 5.46335C0.872791 5.16942 0.987031 4.80711 1.28096 4.6541Z`}}]},ft=(0,o.forwardRef)(function(e,t){return(0,o.createElement)(Y,Object.assign({},e,{id:`eyelash-icon`,ref:t,icon:dt}))});ft.displayName=`EyelashIcon`;let pt={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 17 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M7.38125 1.16211C6.49759 1.16211 5.78125 1.87845 5.78125 2.76211V5.6377H2.87783C1.99418 5.6377 1.27783 6.35404 1.27783 7.2377V13.2377C1.27783 14.1214 1.99418 14.8377 2.87783 14.8377H8.87783C9.76149 14.8377 10.4778 14.1214 10.4778 13.2377V10.3621H13.3813C14.2649 10.3621 14.9813 9.64577 14.9813 8.76211V2.76211C14.9813 1.87845 14.2649 1.16211 13.3813 1.16211H7.38125ZM10.4778 9.16211H13.3813C13.6022 9.16211 13.7812 8.98302 13.7812 8.76211V2.76211C13.7812 2.5412 13.6022 2.36211 13.3813 2.36211H7.38125C7.16034 2.36211 6.98125 2.5412 6.98125 2.76211V5.6377H8.87783C9.76149 5.6377 10.4778 6.35404 10.4778 7.2377V9.16211ZM6.98125 6.8377H8.87783C9.09875 6.8377 9.27783 7.01678 9.27783 7.2377V9.16211H7.38125C7.16034 9.16211 6.98125 8.98302 6.98125 8.76211V6.8377ZM5.78125 6.8377V8.76211C5.78125 9.64577 6.49759 10.3621 7.38125 10.3621H9.27783V13.2377C9.27783 13.4586 9.09875 13.6377 8.87783 13.6377H2.87783C2.65692 13.6377 2.47783 13.4586 2.47783 13.2377V7.2377C2.47783 7.01678 2.65692 6.8377 2.87783 6.8377H5.78125Z`,fillRule:`evenodd`,clipRule:`evenodd`}}]},mt=(0,o.forwardRef)(function(e,t){return(0,o.createElement)(Y,Object.assign({},e,{id:`group-icon`,ref:t,icon:pt}))});mt.displayName=`GroupIcon`;let ht={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 20 20`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{stroke:`currentColor`,d:`M10 2.8v2.5M10 14.7v2.5M2.8 10h2.5M14.7 10h2.5`,strokeLinecap:`round`,strokeWidth:1.6}},{tag:`circle`,attrs:{cx:10,cy:10,r:4.2,stroke:`currentColor`,strokeWidth:1.6}},{tag:`circle`,attrs:{cx:10,cy:10,r:1.35,fill:`currentColor`}}]},gt=(0,o.forwardRef)(function(e,t){return(0,o.createElement)(Y,Object.assign({},e,{id:`locate-fixed-icon`,ref:t,icon:ht}))});gt.displayName=`LocateFixedIcon`;let _t={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M2.62402 7.72905C2.58427 7.72905 2.55205 7.76127 2.55205 7.80102V13.6782C2.55205 13.7179 2.58427 13.7502 2.62402 13.7502H13.3755C13.4152 13.7502 13.4474 13.7179 13.4474 13.6782V7.80102C13.4474 7.76127 13.4152 7.72905 13.3755 7.72905H2.62402ZM1.35205 7.80102C1.35205 7.09853 1.92153 6.52905 2.62402 6.52905H13.3755C14.0779 6.52905 14.6474 7.09853 14.6474 7.80102V13.6782C14.6474 14.3807 14.0779 14.9502 13.3755 14.9502H2.62402C1.92153 14.9502 1.35205 14.3807 1.35205 13.6782V7.80102Z`,fillRule:`evenodd`,clipRule:`evenodd`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M8 2.25005C6.69847 2.25003 5.64336 3.30513 5.64336 4.60666V7.12895C5.64336 7.46032 5.37473 7.72895 5.04336 7.72895C4.71199 7.72895 4.44336 7.46032 4.44336 7.12895V4.60666C4.44336 2.64239 6.04451 1.05565 8.00879 1.05566M8 2.25005L8.00879 1.05566L8 2.25005ZM8.00879 1.05566L8 2.25005C9.30154 2.25003 10.3567 3.30513 10.3567 4.60666V7.12895C10.3567 7.46032 10.6253 7.72895 10.9567 7.72895C11.288 7.72895 11.5567 7.46032 11.5567 7.12895V4.60666C11.5567 2.64239 9.97306 1.05565 8.00879 1.05566Z`,fillRule:`evenodd`,clipRule:`evenodd`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M8.00039 9.4668C8.33176 9.4668 8.60039 9.73543 8.60039 10.0668V12.0827C8.60039 12.4141 8.33176 12.6827 8.00039 12.6827C7.66902 12.6827 7.40039 12.4141 7.40039 12.0827V10.0668C7.40039 9.73543 7.66902 9.4668 8.00039 9.4668Z`,fillRule:`evenodd`,clipRule:`evenodd`}}]},vt=(0,o.forwardRef)(function(e,t){return(0,o.createElement)(Y,Object.assign({},e,{id:`lock-icon`,ref:t,icon:_t}))});vt.displayName=`LockIcon`;let yt={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M11.3536 6.14645C11.5488 6.34171 11.5488 6.65829 11.3536 6.85355L8.35355 9.85355C8.15829 10.0488 7.84171 10.0488 7.64645 9.85355L4.64645 6.85355C4.45118 6.65829 4.45118 6.34171 4.64645 6.14645C4.84171 5.95118 5.15829 5.95118 5.35355 6.14645L8 8.79289L10.6464 6.14645C10.8417 5.95118 11.1583 5.95118 11.3536 6.14645Z`,fillRule:`evenodd`,clipRule:`evenodd`}}]},X=(0,o.forwardRef)(function(e,t){return(0,o.createElement)(Y,Object.assign({},e,{id:`more-down-icon`,ref:t,icon:yt}))});X.displayName=`MoreDownIcon`;let bt={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M1.25 2.96401C1.25 3.84767 1.96634 4.56401 2.85 4.56401H13.15C14.0337 4.56401 14.75 3.84767 14.75 2.96401C14.75 2.08036 14.0337 1.36401 13.15 1.36401H2.85C1.96635 1.36401 1.25 2.08036 1.25 2.96401ZM2.85 3.36401C2.62909 3.36401 2.45 3.18493 2.45 2.96401C2.45 2.7431 2.62909 2.56401 2.85 2.56401H13.15C13.3709 2.56401 13.55 2.7431 13.55 2.96401C13.55 3.18493 13.3709 3.36401 13.15 3.36401H2.85Z`,fillRule:`evenodd`,clipRule:`evenodd`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M5.57564 11.6118C5.80995 11.3774 6.18985 11.3774 6.42417 11.6118L7.3999 12.5875V6.36951C7.3999 6.03814 7.66853 5.76951 7.9999 5.76951C8.33127 5.76951 8.5999 6.03814 8.5999 6.36951V12.5875L9.57564 11.6118C9.80995 11.3774 10.1899 11.3774 10.4242 11.6118C10.6585 11.8461 10.6585 12.226 10.4242 12.4603L8.4324 14.452C8.32324 14.5655 8.16982 14.6362 7.9999 14.6362C7.82998 14.6362 7.67655 14.5655 7.56739 14.452L5.57564 12.4603C5.34132 12.226 5.34132 11.8461 5.57564 11.6118Z`}}]},xt=(0,o.forwardRef)(function(e,t){return(0,o.createElement)(Y,Object.assign({},e,{id:`move-down-icon`,ref:t,icon:bt}))});xt.displayName=`MoveDownIcon`;let St={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M1.25 13.036C1.25 12.1523 1.96634 11.436 2.85 11.436H13.15C14.0337 11.436 14.75 12.1523 14.75 13.036C14.75 13.9196 14.0337 14.636 13.15 14.636H2.85C1.96635 14.636 1.25 13.9196 1.25 13.036ZM2.85 12.636C2.62909 12.636 2.45 12.8151 2.45 13.036C2.45 13.2569 2.62909 13.436 2.85 13.436H13.15C13.3709 13.436 13.55 13.2569 13.55 13.036C13.55 12.8151 13.3709 12.636 13.15 12.636H2.85Z`,fillRule:`evenodd`,clipRule:`evenodd`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M5.57564 4.38825C5.80995 4.62256 6.18985 4.62256 6.42417 4.38825L7.3999 3.41251V9.63049C7.3999 9.96186 7.66853 10.2305 7.9999 10.2305C8.33127 10.2305 8.5999 9.96186 8.5999 9.63049V3.41251L9.57564 4.38825C9.80995 4.62256 10.1899 4.62256 10.4242 4.38825C10.6585 4.15393 10.6585 3.77403 10.4242 3.53972L8.4324 1.54796C8.32324 1.43445 8.16982 1.36382 7.9999 1.36382C7.82998 1.36382 7.67655 1.43446 7.56739 1.54797L5.57564 3.53972C5.34132 3.77403 5.34132 4.15393 5.57564 4.38825Z`}}]},Ct=(0,o.forwardRef)(function(e,t){return(0,o.createElement)(Y,Object.assign({},e,{id:`move-up-icon`,ref:t,icon:St}))});Ct.displayName=`MoveUpIcon`;let wt={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 20 20`,width:`1em`,height:`1em`},children:[{tag:`rect`,attrs:{width:17,height:1.2,x:1.5,y:2.45,fill:`currentColor`,rx:.6}},{tag:`rect`,attrs:{width:3.25,height:1.2,x:1.5,y:6.1,fill:`currentColor`,rx:.6}},{tag:`rect`,attrs:{width:3.25,height:1.2,x:15.25,y:6.1,fill:`currentColor`,rx:.6}},{tag:`rect`,attrs:{width:3.25,height:1.2,x:1.5,y:9.4,fill:`currentColor`,rx:.6}},{tag:`rect`,attrs:{width:3.25,height:1.2,x:15.25,y:9.4,fill:`currentColor`,rx:.6}},{tag:`rect`,attrs:{width:3.25,height:1.2,x:1.5,y:12.7,fill:`currentColor`,rx:.6}},{tag:`rect`,attrs:{width:3.25,height:1.2,x:15.25,y:12.7,fill:`currentColor`,rx:.6}},{tag:`rect`,attrs:{width:17,height:1.2,x:1.5,y:16.35,fill:`currentColor`,rx:.6}},{tag:`path`,attrs:{fill:`currentColor`,d:`M7.55 5.45C6.50066 5.45 5.65 6.30066 5.65 7.35V12.65C5.65 13.6993 6.50066 14.55 7.55 14.55H12.45C13.4993 14.55 14.35 13.6993 14.35 12.65V7.35C14.35 6.30066 13.4993 5.45 12.45 5.45H7.55ZM7.8 6.75C7.24772 6.75 6.8 7.19772 6.8 7.75V12.25C6.8 12.8023 7.24772 13.25 7.8 13.25H12.2C12.7523 13.25 13.2 12.8023 13.2 12.25V7.75C13.2 7.19772 12.7523 6.75 12.2 6.75H7.8Z`,fillRule:`evenodd`,clipRule:`evenodd`}}]},Tt=(0,o.forwardRef)(function(e,t){return(0,o.createElement)(Y,Object.assign({},e,{id:`text-wrap-shape-icon`,ref:t,icon:wt}))});Tt.displayName=`TextWrapShapeIcon`;let Et={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 17 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M7.82994 1.40913C7.88746 1.35161 7.95376 1.30821 8.02453 1.27893C8.09527 1.24959 8.17285 1.2334 8.2542 1.2334C8.33555 1.2334 8.41313 1.24959 8.48387 1.27893C8.55464 1.30821 8.62094 1.35161 8.67846 1.40913L10.6785 3.40913C10.9128 3.64345 10.9128 4.02335 10.6785 4.25766C10.4441 4.49198 10.0642 4.49198 9.82994 4.25766L8.8542 3.28193V5.8334C8.8542 6.16477 8.58557 6.4334 8.2542 6.4334C7.92283 6.4334 7.6542 6.16477 7.6542 5.8334V3.28193L6.67846 4.25766C6.44415 4.49198 6.06425 4.49198 5.82994 4.25766C5.59562 4.02335 5.59562 3.64345 5.82994 3.40913L7.82994 1.40913Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M1.50439 9C1.50439 8.11634 2.22074 7.4 3.10439 7.4H13.4044C14.288 7.4 15.0044 8.11634 15.0044 9C15.0044 9.88366 14.2881 10.6 13.4044 10.6H3.1044C2.22074 10.6 1.50439 9.88366 1.50439 9ZM3.10439 8.6C2.88348 8.6 2.70439 8.77909 2.70439 9C2.70439 9.22091 2.88348 9.4 3.1044 9.4H13.4044C13.6253 9.4 13.8044 9.22091 13.8044 9C13.8044 8.77909 13.6253 8.6 13.4044 8.6H3.10439Z`,fillRule:`evenodd`,clipRule:`evenodd`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M1.6543 13.1665C1.6543 12.2828 2.37064 11.5665 3.2543 11.5665H13.5543C14.438 11.5665 15.1543 12.2828 15.1543 13.1665C15.1543 14.0502 14.438 14.7665 13.5543 14.7665H3.2543C2.37064 14.7665 1.6543 14.0502 1.6543 13.1665ZM3.2543 12.7665C3.03338 12.7665 2.8543 12.9456 2.8543 13.1665C2.8543 13.3874 3.03338 13.5665 3.2543 13.5665H13.5543C13.7752 13.5665 13.9543 13.3874 13.9543 13.1665C13.9543 12.9456 13.7752 12.7665 13.5543 12.7665H3.2543Z`,fillRule:`evenodd`,clipRule:`evenodd`}}]},Dt=(0,o.forwardRef)(function(e,t){return(0,o.createElement)(Y,Object.assign({},e,{id:`topmost-icon`,ref:t,icon:Et}))});Dt.displayName=`TopmostIcon`;let Ot={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 17 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M7.46855 2.83731C7.46855 2.61639 7.64764 2.4373 7.86855 2.4373H13.8603C14.0812 2.4373 14.2603 2.61639 14.2603 2.8373V9.5049C14.2603 9.72581 14.0812 9.90489 13.8603 9.90489H12.866C12.5346 9.90489 12.266 10.1735 12.266 10.5049C12.266 10.8363 12.5346 11.1049 12.866 11.1049H13.8603C14.7439 11.1049 15.4603 10.3886 15.4603 9.5049V2.8373C15.4603 1.95365 14.7439 1.2373 13.8603 1.2373H7.86855C6.9849 1.2373 6.26855 1.95365 6.26855 2.83731V3.48688C6.26855 3.81825 6.53718 4.08688 6.86855 4.08688C7.19993 4.08688 7.46855 3.81825 7.46855 3.48688V2.83731Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M3.19888 5.56299C2.31522 5.56299 1.59888 6.27933 1.59888 7.16299V13.163C1.59888 14.0466 2.31522 14.763 3.19888 14.763H9.19888C10.0825 14.763 10.7989 14.0466 10.7989 13.163V7.16299C10.7989 6.27933 10.0825 5.56299 9.19888 5.56299H3.19888ZM2.79888 7.16299C2.79888 6.94207 2.97796 6.76299 3.19888 6.76299H9.19888C9.41979 6.76299 9.59888 6.94207 9.59888 7.16299V13.163C9.59888 13.3839 9.41979 13.563 9.19888 13.563H3.19888C2.97796 13.563 2.79888 13.3839 2.79888 13.163V7.16299Z`,fillRule:`evenodd`,clipRule:`evenodd`}}]},kt=(0,o.forwardRef)(function(e,t){return(0,o.createElement)(Y,Object.assign({},e,{id:`ungroup-icon`,ref:t,icon:Ot}))});kt.displayName=`UngroupIcon`;let At={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M2.62402 7.72905C2.58427 7.72905 2.55205 7.76127 2.55205 7.80102V13.6782C2.55205 13.7179 2.58427 13.7502 2.62402 13.7502H13.3755C13.4152 13.7502 13.4474 13.7179 13.4474 13.6782V7.80102C13.4474 7.76127 13.4152 7.72905 13.3755 7.72905H2.62402ZM1.35205 7.80102C1.35205 7.09853 1.92153 6.52905 2.62402 6.52905H13.3755C14.0779 6.52905 14.6474 7.09853 14.6474 7.80102V13.6782C14.6474 14.3807 14.0779 14.9502 13.3755 14.9502H2.62402C1.92153 14.9502 1.35205 14.3807 1.35205 13.6782V7.80102Z`,fillRule:`evenodd`,clipRule:`evenodd`}},{tag:`path`,attrs:{stroke:`currentColor`,d:`M5.04336 7.12895V4.60666C5.04336 2.97376 6.3671 1.65005 8 1.65005C9.6329 1.65005 10.9566 2.97376 10.9566 4.60666`,strokeLinecap:`round`,strokeWidth:1.2}},{tag:`path`,attrs:{fill:`currentColor`,d:`M8.00039 9.4668C8.33176 9.4668 8.60039 9.73543 8.60039 10.0668V12.0827C8.60039 12.4141 8.33176 12.6827 8.00039 12.6827C7.66902 12.6827 7.40039 12.4141 7.40039 12.0827V10.0668C7.40039 9.73543 7.66902 9.4668 8.00039 9.4668Z`,fillRule:`evenodd`,clipRule:`evenodd`}}]},jt=(0,o.forwardRef)(function(e,t){return(0,o.createElement)(Y,Object.assign({},e,{id:`unlock-icon`,ref:t,icon:At}))});jt.displayName=`UnlockIcon`;let Mt={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`colorChannel1`,d:`M11.0363 12.2367V14.0367C11.0363 14.3681 11.3049 14.6367 11.6363 14.6367C11.9676 14.6367 12.2363 14.3681 12.2363 14.0367V12.2367H14.0364C14.3677 12.2367 14.6364 11.9681 14.6364 11.6367C14.6364 11.3054 14.3677 11.0367 14.0364 11.0367H12.2363V9.23672C12.2363 8.90535 11.9676 8.63672 11.6363 8.63672C11.3049 8.63672 11.0363 8.90535 11.0363 9.23672V11.0367H9.23635C8.90498 11.0367 8.63635 11.3054 8.63635 11.6367C8.63635 11.9681 8.90498 12.2367 9.23635 12.2367H11.0363Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M2.56365 1.36377C1.90091 1.36377 1.36365 1.90103 1.36365 2.56377V6.16377C1.36365 6.82651 1.90091 7.36377 2.56365 7.36377H6.16365C6.82639 7.36377 7.36365 6.82651 7.36365 6.16377V2.56377C7.36365 1.90103 6.82639 1.36377 6.16365 1.36377H2.56365ZM6.16365 2.56377H2.56365L2.56365 6.16377H6.16365V2.56377Z`,fillRule:`evenodd`,clipRule:`evenodd`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M2.56365 8.63647C1.90091 8.63647 1.36365 9.17373 1.36365 9.83647V13.4365C1.36365 14.0992 1.90091 14.6365 2.56365 14.6365H6.16365C6.82639 14.6365 7.36365 14.0992 7.36365 13.4365V9.83647C7.36365 9.17373 6.82639 8.63647 6.16365 8.63647H2.56365ZM6.16365 9.83647H2.56365L2.56365 13.4365H6.16365V9.83647Z`,fillRule:`evenodd`,clipRule:`evenodd`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M9.83635 7.36377C9.17361 7.36377 8.63635 6.82651 8.63635 6.16377V2.56377C8.63635 1.90103 9.17361 1.36377 9.83635 1.36377H13.4364C14.0991 1.36377 14.6364 1.90103 14.6364 2.56377V6.16377C14.6364 6.82651 14.0991 7.36377 13.4364 7.36377H9.83635ZM9.83635 6.16377V2.56377L13.4364 2.56377V6.16377H9.83635Z`,fillRule:`evenodd`,clipRule:`evenodd`}}]},Nt=(0,o.forwardRef)(function(e,t){return(0,o.createElement)(Y,Object.assign({},e,{id:`autofill-double-icon`,ref:t,icon:Mt}))});Nt.displayName=`AutofillDoubleIcon`;let Pt=`COMPONENT_IMAGE_POPUP_MENU`,Ft=`COMPONENT_MOBILE_IMAGE_POPUP_MENU`;function It({popup:e}){var n,r,o;let l=(0,i.useDependency)(t.ICommandService),u=(0,i.useDependency)(i.IDialogService),d=(0,i.useDependency)(i.IconManager),f=(0,i.useDependency)(t.LocaleService),p=((n=e.extraProps)==null?void 0:n.menuItems)??[];if(p.length===0)return null;async function m(t,n){var r,i;if(!t||t.disable||t.type===`select`&&(typeof n!=`string`||!((r=t.options)!=null&&r.some(e=>e.value===n))))return;let a=t.type===`select`&&typeof n==`string`?((i=t.commandParamsFactory)==null?void 0:i.call(t,n))??{...t.commandParams,value:n}:t.commandParams;if(await l.executeCommand(t.commandId,a),t.hideOnClick!==!1){var o,s,c;(o=e.extraProps)==null||(s=o.onClose)==null||s.call(o),(c=e.extraProps)!=null&&c.dialogId&&u.close(e.extraProps.dialogId)}}if(!((r=e.extraProps)!=null&&r.variant||p.some(e=>e.type===`select`)))return(0,c.jsx)(`div`,{className:`univer-flex univer-flex-col univer-gap-2`,children:p.map(e=>{let t=f.t(e.label),n=e.icon&&d.has(e.icon)?d.get(e.icon):null;return(0,c.jsx)(s.MobileActionRow,{title:t,"aria-label":t,icon:n?(0,c.jsx)(n,{}):void 0,variant:`subtle`,disabled:e.disable,onClick:async()=>{await m(e)}},`${e.commandId}-${e.label}`)})});let h=p.map(e=>{var t;return{key:e.commandId,order:e.index,item:e.type===`select`?{id:e.commandId,type:i.MenuItemType.SELECTOR,title:e.label,value$:(0,a.of)(e.value),disabled$:(0,a.of)(e.disable||!((t=e.options)!=null&&t.length)),selections:e.options}:{id:e.commandId,type:i.MenuItemType.BUTTON,title:e.label,disabled$:(0,a.of)(e.disable)}}});return(0,c.jsx)(i.MobileMenu,{presentation:(o=e.extraProps)!=null&&o.variant?`context-bar`:`drawer`,schemas:h,onOptionSelect:async({id:e,value:t})=>{await m(p.find(t=>t.commandId===e),t)}})}let Lt=`drawing-ui.arrange`,Rt=`drawing-ui.cropper`,zt=`drawing-ui.transform`,Bt=`drawing-ui.align`,Vt=`drawing-ui.group`;function Ht(e){let{arrangeShow:r,drawings:a}=e,o=(0,i.useDependency)(t.LocaleService),l=(0,i.useDependency)(n.IDrawingManagerService),u=(0,i.useDependency)(t.ICommandService),d=(0,i.useDependency)(i.IconManager),f=d.get(`MoveUpIcon`),p=d.get(`MoveDownIcon`),m=d.get(`TopmostIcon`),h=d.get(`BottomIcon`),g=(0,i.useObservable)(()=>l.focus$,a,!1,[l]),_=e=>{u.syncExecuteCommand(y.id,{arrangeType:e,drawings:g})};return(0,c.jsxs)(`div`,{className:(0,s.clsx)(`univer-grid univer-gap-2 univer-py-2 univer-text-gray-400`,{"univer-hidden":!r}),children:[(0,c.jsx)(`header`,{className:`univer-text-gray-600 dark:!univer-text-gray-200`,children:(0,c.jsx)(`div`,{children:o.t(`drawing-ui.image-panel.arrange.title`)})}),(0,c.jsxs)(`div`,{className:`univer-grid univer-grid-cols-2 univer-gap-2`,children:[(0,c.jsxs)(s.Button,{className:`univer-h-12 univer-w-full`,onClick:()=>_(t.ArrangeTypeEnum.forward),children:[(0,c.jsx)(f,{}),o.t(`drawing-ui.image-panel.arrange.forward`)]}),(0,c.jsxs)(s.Button,{className:`univer-h-12 univer-w-full`,onClick:()=>_(t.ArrangeTypeEnum.backward),children:[(0,c.jsx)(p,{}),o.t(`drawing-ui.image-panel.arrange.backward`)]}),(0,c.jsxs)(s.Button,{className:`univer-h-12 univer-w-full`,onClick:()=>_(t.ArrangeTypeEnum.front),children:[(0,c.jsx)(m,{}),o.t(`drawing-ui.image-panel.arrange.front`)]}),(0,c.jsxs)(s.Button,{className:`univer-h-12 univer-w-full`,onClick:()=>_(t.ArrangeTypeEnum.back),children:[(0,c.jsx)(h,{}),o.t(`drawing-ui.image-panel.arrange.back`)]})]})]})}let Ut=[-360,360];function Wt(e){return!e}function Gt(e){return t=>{if(Wt(e.rotateEnabled)||t==null)return;let{unitId:n,subUnitId:r,drawingId:i,drawingType:a}=e.drawingParam,o={unitId:n,subUnitId:r,drawingId:i,drawingType:a,transform:{angle:t}};e.setRotation(t),e.emitUpdate([o]),e.notifyChange()}}function Kt(e){return(0,c.jsx)(s.InputNumber,{...e,controls:!1,className:(0,s.clsx)(`univer-h-12 univer-w-full`,e.className),inputClassName:(0,s.clsx)(`[&_input]:!univer-h-12 [&_input]:!univer-text-base`,e.inputClassName)})}function qt(e){return(0,c.jsx)(s.Checkbox,{...e,className:(0,s.clsx)(`univer-flex univer-min-h-12 univer-items-center univer-justify-center`,e.className)})}function Jt(e){return(0,c.jsx)(s.Button,{...e,className:(0,s.clsx)(`univer-flex univer-min-h-12 univer-flex-1 univer-items-center univer-justify-center univer-gap-2 univer-text-base`,e.className)})}function Yt(e){var t,n;let a=(0,i.useDependency)(r.IRenderManagerService),o=e.drawings[0],s=o?(t=a.getRenderUnitById(o.unitId))==null?void 0:t.scene:void 0,l=s==null||(n=s.getEngine())==null?void 0:n.activeScene;return!(o!=null&&o.transform)||!s||!l?null:(0,c.jsx)(Xt,{...e})}function Xt(e){let a=(0,i.useDependency)(t.LocaleService),l=(0,i.useDependency)(n.IDrawingManagerService),u=(0,i.useDependency)(r.IRenderManagerService),{drawings:d,transformShow:f}=e,p=d[0],m=p.transform,{unitId:h,subUnitId:g,drawingId:_,drawingType:v}=p,y=u.getRenderUnitById(h).scene,b=y.getEngine().activeScene,x=y.getTransformerByCreate(),{width:S=0,height:C=0,left:w=0,top:T=0,angle:E=0}=m,[D,O]=(0,o.useState)(S),[k,A]=(0,o.useState)(C),[j,N]=(0,o.useState)(w),[P,F]=(0,o.useState)(T),[I,L]=(0,o.useState)(E),[R,z]=(0,o.useState)(x.keepRatio),B=M(p,{getChildren:e=>l.getDrawingsByGroup(e)}),V=Wt(B),H=(e,t,n,r)=>{let{width:i,height:a}=b,{ancestorLeft:o,ancestorTop:s}=y,c=e,l=t,u=n,d=r;return e+o<0&&(c=-o),t+s<0&&(l=-s),u=Math.max(i-c-o,20),d=Math.max(a-l-s,20),e+u+o>i&&(c=i-n-o),t+d+s>a&&(l=a-r-s),{limitLeft:c,limitTop:l,limitWidth:u,limitHeight:d}},ee=e=>{let t=e.transform;if(t==null)return;let{width:n,height:r,left:i,top:a,angle:o}=t;n!=null&&O(n),r!=null&&A(r),i!=null&&N(i),a!=null&&F(a),o!=null&&L(o)},te=e=>{let t=q(e.objects,l);t.length===1&&t[0]!=null&&ee(t[0])};(0,o.useEffect)(()=>{let e=[x.changeStart$.subscribe(te),x.changing$.subscribe(te),x.changeEnd$.subscribe(te),l.focus$.subscribe(e=>{if(e.length!==1)return;let t=l.getDrawingByParam(e[0]);t!=null&&ee(t)})];return()=>e.forEach(e=>e.unsubscribe())},[]);let ne=e=>{l.featurePluginUpdateNotification([e]),x.refreshControls().changeNotification()},re=(0,t.debounce)(e=>{if(e==null)return;let{limitWidth:t,limitHeight:n}=H(j,P,e,k),r=Math.min(e,t),i={unitId:h,subUnitId:g,drawingId:_,drawingType:v,transform:{width:r}};if(R){let e=Math.max(r/D*k,20);if(e>n)return;A(e),i.transform.height=e}O(r),ne(i)},300),ie=(0,t.debounce)(e=>{if(e==null)return;let{limitHeight:t,limitWidth:n}=H(j,P,D,e),r=Math.min(e,t),i={unitId:h,subUnitId:g,drawingId:_,drawingType:v,transform:{height:r}};if(R){let e=Math.max(r/k*D,20);if(e>n)return;O(e),i.transform.width=e}A(r),ne(i)},300),ae=(0,t.debounce)(e=>{if(e==null)return;let{limitLeft:t}=H(e,P,D,k);N(t),ne({unitId:h,subUnitId:g,drawingId:_,drawingType:v,transform:{left:t}})},300),oe=(0,t.debounce)(e=>{if(e==null)return;let{limitTop:t}=H(j,e,D,k);F(t),ne({unitId:h,subUnitId:g,drawingId:_,drawingType:v,transform:{top:t}})},300),se=Gt({rotateEnabled:B,drawingParam:{unitId:h,subUnitId:g,drawingId:_,drawingType:v},setRotation:L,emitUpdate:e=>l.featurePluginUpdateNotification(e),notifyChange:()=>x.refreshControls().changeNotification()});return(0,c.jsxs)(`div`,{className:(0,s.clsx)(`univer-grid univer-gap-2 univer-py-2 univer-text-gray-400`,{"univer-hidden":!f}),children:[(0,c.jsx)(`header`,{className:`univer-text-gray-600 dark:!univer-text-gray-200`,children:(0,c.jsx)(`div`,{children:a.t(`drawing-ui.image-panel.transform.title`)})}),(0,c.jsxs)(`div`,{className:`univer-grid univer-grid-cols-3 univer-gap-2 [&>div]:univer-grid [&>div]:univer-gap-2`,children:[(0,c.jsxs)(`div`,{children:[(0,c.jsx)(`span`,{children:a.t(`drawing-ui.image-panel.transform.width`)}),(0,c.jsx)(Kt,{precision:1,value:D,min:20,onChange:re})]}),(0,c.jsxs)(`div`,{children:[(0,c.jsx)(`span`,{children:a.t(`drawing-ui.image-panel.transform.height`)}),(0,c.jsx)(Kt,{precision:1,value:k,min:20,onChange:ie})]}),(0,c.jsxs)(`div`,{children:[(0,c.jsx)(`span`,{children:a.t(`drawing-ui.image-panel.transform.lock`)}),(0,c.jsx)(`div`,{className:`univer-text-center`,children:(0,c.jsx)(qt,{checked:R,onChange:e=>{typeof e==`boolean`&&(z(e),x.keepRatio=e)}})})]})]}),(0,c.jsxs)(`div`,{className:`univer-grid univer-grid-cols-3 univer-gap-2 [&>div]:univer-grid [&>div]:univer-gap-2`,children:[(0,c.jsxs)(`div`,{children:[(0,c.jsx)(`span`,{children:a.t(`drawing-ui.image-panel.transform.x`)}),(0,c.jsx)(Kt,{precision:1,value:j,onChange:ae})]}),(0,c.jsxs)(`div`,{children:[(0,c.jsx)(`span`,{children:a.t(`drawing-ui.image-panel.transform.y`)}),(0,c.jsx)(Kt,{precision:1,value:P,onChange:oe})]}),(0,c.jsxs)(`div`,{children:[(0,c.jsx)(`span`,{children:a.t(`drawing-ui.image-panel.transform.rotate`)}),(0,c.jsx)(Kt,{precision:1,value:I,min:Ut[0],max:Ut[1],disabled:V,onChange:se})]})]})]})}function Zt(e){let n=(0,i.useDependency)(t.ICommandService),r=(0,i.useDependency)(t.LocaleService),{drawings:a,alignShow:d}=e,[f,p]=(0,o.useState)(`0`),m=[{label:r.t(`drawing-ui.image-panel.align.default`),value:`0`},{options:[{label:r.t(`drawing-ui.image-panel.align.left`),value:`1`},{label:r.t(`drawing-ui.image-panel.align.center`),value:`2`},{label:r.t(`drawing-ui.image-panel.align.right`),value:`3`}]},{options:[{label:r.t(`drawing-ui.image-panel.align.top`),value:`4`},{label:r.t(`drawing-ui.image-panel.align.middle`),value:`5`},{label:r.t(`drawing-ui.image-panel.align.bottom`),value:`6`}]},{options:[{label:r.t(`drawing-ui.image-panel.align.horizon`),value:`7`},{label:r.t(`drawing-ui.image-panel.align.vertical`),value:`8`}]}];return(0,c.jsxs)(`div`,{className:(0,s.clsx)(`univer-relative univer-w-full`,{"univer-hidden":!d}),children:[(0,c.jsx)(`header`,{className:`univer-text-gray-600 dark:!univer-text-gray-200`,children:(0,c.jsx)(`div`,{children:r.t(`drawing-ui.image-panel.align.title`)})}),(0,c.jsx)(`div`,{className:`univer-relative univer-mt-2.5 univer-flex univer-h-full`,children:(0,c.jsx)(`div`,{className:`univer-w-full univer-text-gray-900 dark:!univer-text-gray-0`,children:(0,c.jsx)(s.MobileSelect,{value:f,options:m,onChange:e=>{let t=Object.values(l).find(t=>t===e);t!=null&&(p(t),n.executeCommand(u.id,{alignType:t,drawings:a}))}})})})]})}function Qt(e){var o;let l=(0,i.useDependency)(t.LocaleService),u=(0,i.useDependency)(r.IRenderManagerService),d=(0,i.useDependency)(n.IDrawingManagerService),f=(0,i.useDependency)(t.ICommandService),p=(0,i.useDependency)(i.IconManager),{hasGroup:m,drawings:h}=e,g=p.get(`GroupIcon`),_=p.get(`UngroupIcon`),v=h[0],y=v?(o=u.getRenderUnitById(v.unitId))==null||(o=o.scene)==null?void 0:o.getTransformerByCreate():void 0,{groupShow:b,groupBtnShow:x,ungroupBtnShow:S}=(0,i.useObservable)(y?()=>(0,a.merge)(y.clearControl$.pipe((0,a.filter)(e=>e===!0),(0,a.map)(()=>({groupShow:!1,groupBtnShow:!1,ungroupBtnShow:!1}))),y.changeStart$.pipe((0,a.map)(e=>{let n=q(e.objects,d),r=n.length>1,i=n.some(e=>(e==null?void 0:e.drawingType)===t.DrawingTypeEnum.DRAWING_GROUP);return{groupShow:r||i,groupBtnShow:r,ungroupBtnShow:i}}))):null,{groupShow:!1,groupBtnShow:!0,ungroupBtnShow:!0},!1,[d,y]);return(0,c.jsxs)(`div`,{className:(0,s.clsx)(`univer-grid univer-gap-2 univer-py-2 univer-text-gray-400`,{"univer-hidden":m&&!b||!m}),children:[(0,c.jsx)(`header`,{className:`univer-text-gray-600 dark:!univer-text-gray-200`,children:(0,c.jsx)(`div`,{children:l.t(`drawing-ui.image-panel.group.title`)})}),(0,c.jsxs)(`div`,{className:`univer-flex univer-items-center univer-justify-center univer-gap-2`,children:[(0,c.jsxs)(Jt,{className:(0,s.clsx)({"univer-hidden":!x}),onClick:()=>f.syncExecuteCommand(T.id,{drawings:h}),children:[(0,c.jsx)(g,{}),l.t(`drawing-ui.image-panel.group.group`)]}),(0,c.jsxs)(Jt,{className:(0,s.clsx)({"univer-hidden":!S}),onClick:()=>f.syncExecuteCommand(E.id,{drawings:h}),children:[(0,c.jsx)(_,{}),l.t(`drawing-ui.image-panel.group.unGroup`)]})]})]})}function $t(e){let n=(0,i.useDependency)(t.ICommandService),r=(0,i.useDependency)(t.LocaleService),a=(0,i.useDependency)(De),s=(0,i.useDependency)(i.ComponentManager),c=(0,i.useObservable)(a.canUseShapeClip$,!1),{drawings:l,cropperShow:u}=e,d=l[0],[f,p]=(0,o.useState)(`0`),m=(0,o.useRef)(!1),h=[{label:r.t(`drawing-ui.image-panel.crop.mode`),value:`0`},{label:`1:1`,value:`1`},{label:`16:9`,value:`2`},{label:`9:16`,value:`3`},{label:`5:4`,value:`4`},{label:`4:5`,value:`5`},{label:`4:3`,value:`6`},{label:`3:4`,value:`7`},{label:`3:2`,value:`8`},{label:`2:3`,value:`9`}];(0,o.useEffect)(()=>{let e=n.onCommandExecuted(e=>{if(e.id===O.id){let t=e.params;t!=null&&t.isAuto||(m.current=!1)}});return()=>{e==null||e.dispose()}},[n]);function g(e){var t;let r=(t=h.find(t=>t.value===e))==null?void 0:t.value;r!=null&&(p(r),m.current&&n.executeCommand(k.id,{cropType:r}))}return{drawingParam:d,cropperShow:u,localeService:r,cropValue:f,cropOptions:h,handleCropChange:g,onCropperBtnClick:async t=>{var r;await n.executeCommand(k.id,{cropType:t}),m.current=!0,(r=e.onCropStart)==null||r.call(e)},ShapeClipPicker:c?s.get(Ee):void 0}}function en(e){let n=(0,i.useDependency)(t.LocaleService);return(0,c.jsxs)(`section`,{className:`univer-grid univer-gap-3 univer-py-3`,children:[(0,c.jsx)(`h3`,{className:`univer-m-0 univer-text-sm univer-font-medium`,children:n.t(`drawing-ui.image-panel.crop.title`)}),(0,c.jsx)(`div`,{className:`univer-grid univer-grid-cols-3 univer-gap-2`,children:e.cropOptions.map(t=>(0,c.jsx)(s.MobileActionRow,{title:t.label,variant:`subtle`,"aria-pressed":e.cropValue===t.value,className:`univer-px-2 univer-text-center aria-pressed:!univer-bg-primary-50 aria-pressed:!univer-text-primary-600`,onClick:()=>e.onCropChange(t.value)},t.value))}),(0,c.jsx)(s.MobileActionRow,{icon:(0,c.jsx)(nt,{}),title:n.t(`drawing-ui.image-panel.crop.start`),className:`!univer-bg-primary-600 !univer-text-white`,onClick:e.onStartCrop}),e.children]})}function tn(e){let{drawingParam:t,cropperShow:n,cropValue:r,cropOptions:i,handleCropChange:a,onCropperBtnClick:o,ShapeClipPicker:s}=$t(e);return!t||!n?null:(0,c.jsx)(en,{cropValue:r,cropOptions:i,onCropChange:a,onStartCrop:()=>o(r),children:s&&(0,c.jsx)(s,{})})}let nn=class extends t.Disposable{constructor(e,t){super(),this.disposeWithMe(e.register(Bt,Zt)),this.disposeWithMe(e.register(Vt,Qt)),this.disposeWithMe(e.register(zt,Yt)),this.disposeWithMe(e.register(Lt,Ht)),this.disposeWithMe(e.register(Rt,tn)),this.disposeWithMe(e.register(Ft,It)),this.disposeWithMe(t.register({BottomIcon:Ke,DrawingCropIcon:nt,DrawingDeleteIcon:it,DrawingEditIcon:ot,GroupIcon:mt,MoveDownIcon:xt,MoveUpIcon:Ct,TopmostIcon:Dt,UngroupIcon:kt}))}};nn=G([W(0,(0,t.Inject)(i.ComponentManager)),W(1,(0,t.Inject)(i.IconManager))],nn);function rn(e,t){let n={left:t.left-e.left,top:t.top-e.top,right:e.left+e.width-t.left-t.width,bottom:e.top+e.height-t.top-t.height},i={...n};if(e.angle){let n=new r.Vector2(e.left,e.top);n.rotateByPoint((0,r.degToRad)(e.angle),new r.Vector2(e.left+e.width/2,e.top+e.height/2)),n.rotateByPoint((0,r.degToRad)(-e.angle),new r.Vector2(t.left+t.width/2,t.top+t.height/2)),i.left=t.left-n.x,i.top=t.top-n.y,i.right=e.width-i.left-t.width,i.bottom=e.height-i.top-t.height}return{srcRect:n,srcRectAngle:i}}var Z=class extends r.Shape{constructor(e,t){t??={},t.transformerConfig={keepRatio:!1,isCropper:!0,anchorFill:`rgb(0, 0, 0)`,anchorStroke:`rgb(255, 255, 255)`,anchorSize:24},super(e,t),U(this,`_srcRect`,void 0),U(this,`_prstGeom`,void 0),U(this,`_applyTransform`,void 0),U(this,`_dragPadding`,8),U(this,`_cacheCanvas`,void 0),t!=null&&t.srcRect&&(this._srcRect=t.srcRect),t!=null&&t.prstGeom&&(this._prstGeom=t.prstGeom),t!=null&&t.applyTransform&&(this._applyTransform=t.applyTransform),t!=null&&t.dragPadding&&(this._dragPadding=t.dragPadding),this._applyProps()}refreshSrcRect(e,t){this._srcRect=e,this._applyTransform=t,this._applyProps()}get srcRect(){return this._srcRect}dispose(){var e;super.dispose(),(e=this._cacheCanvas)==null||e.dispose(),this._srcRect=null}isHit(e){let t=this.getInverseCoord(e);return t.x>=-this.strokeWidth/2&&t.x<=this.width+this.strokeWidth/2&&t.y>=-this.strokeWidth/2&&t.y<=this.height+this.strokeWidth/2&&!this._inSurround(t)}_inSurround(e){let t=this._dragPadding;return e.x>=t-this.strokeWidth/2&&e.x<=this.width+this.strokeWidth/2-t&&e.y>=t-this.strokeWidth/2&&e.y<=this.height+this.strokeWidth/2-t}render(e,t){return this.visible?(e.save(),this._draw(e),e.restore(),this.makeDirty(!1),this):(this.makeDirty(!1),this)}_draw(e){var t,n;let{width:i,height:a}=this.getScene().getEngine();this._initialCacheCanvas(),(t=this._cacheCanvas)==null||t.clear();let o=(n=this._cacheCanvas)==null?void 0:n.getContext();o!=null&&(o.save(),r.Rect.drawWith(o,{left:0,top:0,width:i,height:a,fill:`rgba(0, 0, 0, 0.5)`}),o.setTransform(e.getTransform()),this._clipForApplyObject(o),this._applyCache(e),o.restore())}_clipForApplyObject(e){let t=0;if(this._prstGeom!=null&&(t=1),e.globalCompositeOperation=`destination-out`,e.beginPath(),t===0){let t=this.transform.getMatrix();e.transform(t[0],t[1],t[2],t[3],t[4],t[5]),e.rect(0,0,this.width,this.height),e.fill()}}_applyProps(){if(this._applyTransform==null)return;let e=0,t=0,n=0,r=0,{left:i=0,top:a=0,width:o=0,height:s=0,angle:c}=this._applyTransform;if(this._srcRect!=null){let{left:i=0,top:a=0,right:o=0,bottom:s=0}=this._srcRect;e=i,t=a,n=o,r=s}let l=i+e,u=a+t;this.transformByState({left:l,top:u,width:i+o-n-l,height:a+s-r-u,angle:c})}_applyCache(e){if(!e||this._cacheCanvas==null)return;let t=this._cacheCanvas.getContext();t.save(),e.save(),e.setTransform(1,0,0,1,0,0),t.setTransform(1,0,0,1,0,0),e.drawImage(this._cacheCanvas.getCanvasEle(),0,0),e.restore(),t.restore()}_initialCacheCanvas(){if(this._cacheCanvas!=null)return;let e=this.getScene();if(e==null)return;this._cacheCanvas=new r.Canvas;let t=e.getEngine();this._cacheCanvas.setSize(t.width,t.height),t.onTransformChange$.subscribeEvent(()=>{var e;(e=this._cacheCanvas)==null||e.setSize(t.width,t.height),this.makeDirty(!0)})}};let an=class extends t.Disposable{constructor(e,n,r,i,o,s,c,l){super(),this._commandService=e,this._drawingManagerService=n,this._renderManagerService=r,this._univerInstanceService=i,this._messageService=o,this._localeService=s,this._shortcutService=c,this._layoutService=l,U(this,`_sceneListenerOnImageMap`,new WeakSet),U(this,`_cropShortcutDisposables`,new t.DisposableCollection),U(this,`_cropSnapshots`,new WeakMap),U(this,`_pendingCropSnapshot`,null),U(this,`_activeCropSession`,null),U(this,`_cropping$`,new a.BehaviorSubject(!1)),U(this,`cropping$`,this._cropping$.asObservable()),this.disposeWithMe(this._cropShortcutDisposables),this.disposeWithMe({dispose:()=>this._cropping$.complete()}),this._init()}_init(){this._initOpenCrop(),this._initCloseCrop(),this._initAutoCrop()}_initAutoCrop(){this.disposeWithMe(this._commandService.onCommandExecuted(e=>{var t;if(e.id!==k.id)return;let i=e.params;if(i==null)return;let a=this._drawingManagerService.getFocusDrawings();if(a.length!==1)return;let{cropType:o}=i,{unitId:c,subUnitId:l,drawingId:u}=a[0],d=(t=this._renderManagerService.getRenderUnitById(c))==null?void 0:t.scene;if(d==null)return!0;this._searchCropObject(d)!=null&&this._commandService.syncExecuteCommand(O.id,{isAuto:!0});let f=(0,n.getDrawingShapeKeyByDrawingSearch)({unitId:c,subUnitId:l,drawingId:u}),p=d.getObject(f);if(!(p instanceof r.Image)){this._messageService.show({type:s.MessageType.Error,content:this._localeService.t(`drawing-ui.image-cropper.error`)});return}this._pendingCropSnapshot=this._captureCropSnapshot(p);try{this._updateCropperObject(o,p),this._commandService.syncExecuteCommand(D.id,{unitId:c,subUnitId:l,drawingId:u})}finally{this._pendingCropSnapshot=null}}))}_calculateSrcRectByRatio(e,t,n,i,a,o){let s=n/i,c=a/o,l=n,u=i;s>c?l=i*c:u=n/c;let d=(n-l)/2,f=(i-u)/2;return{left:(0,r.precisionTo)(d,1),top:(0,r.precisionTo)(f,1),right:(0,r.precisionTo)(n-(d+l),1),bottom:(0,r.precisionTo)(i-(f+u),1)}}_updateCropperObject(e,t){let{left:n,top:r,width:i,height:a}=t.calculateTransformWithSrcRect(),o;switch(e){case`1`:o=this._calculateSrcRectByRatio(n,r,i,a,1,1);break;case`2`:o=this._calculateSrcRectByRatio(n,r,i,a,16,9);break;case`3`:o=this._calculateSrcRectByRatio(n,r,i,a,9,16);break;case`4`:o=this._calculateSrcRectByRatio(n,r,i,a,5,4);break;case`5`:o=this._calculateSrcRectByRatio(n,r,i,a,4,5);break;case`6`:o=this._calculateSrcRectByRatio(n,r,i,a,4,3);break;case`7`:o=this._calculateSrcRectByRatio(n,r,i,a,3,4);break;case`8`:o=this._calculateSrcRectByRatio(n,r,i,a,3,2);break;case`9`:o=this._calculateSrcRectByRatio(n,r,i,a,2,3)}if(o==null)return;t.setSrcRect(o);let{left:s=0,top:c=0,bottom:l=0,right:u=0}=o;t.transformByStateCloseCropper({left:n+s,top:r+c,width:i-u-s,height:a-l-c})}_initOpenCrop(){this.disposeWithMe(this._commandService.onCommandExecuted(e=>{var t;if(e.id!==D.id)return;let i=e.params;if(i==null)return;this._activeCropSession!=null&&this._commandService.syncExecuteCommand(O.id,{isAuto:!0});let{unitId:a,subUnitId:o,drawingId:c}=i,l=(t=this._renderManagerService.getRenderUnitById(a))==null?void 0:t.scene;if(l==null)return!0;if(this._sceneListenerOnImageMap.has(l)||(this._addListenerOnImage(l),this._sceneListenerOnImageMap.add(l)),this._drawingManagerService.getDrawingByParam({unitId:a,subUnitId:o,drawingId:c})==null)return;let u=(0,n.getDrawingShapeKeyByDrawingSearch)({unitId:a,subUnitId:o,drawingId:c}),d=l.getObject(u);if(!(d instanceof r.Image)){this._messageService.show({type:s.MessageType.Error,content:this._localeService.t(`drawing-ui.image-cropper.error`)});return}let f=l.getTransformer();f==null||f.clearControls();let p=new Z(`${u}-crop`,{srcRect:d.srcRect,prstGeom:d.prstGeom,applyTransform:d.calculateTransformWithSrcRect()});p.transformerConfig={...p.transformerConfig,cropAnchorHitSize:44},this._cropSnapshots.set(p,this._pendingCropSnapshot??this._captureCropSnapshot(d)),this._pendingCropSnapshot=null,l.addObject(p,d.getLayerIndex()+1).attachTransformerTo(p),this._activeCropSession={scene:l,imageShape:d,imageCropperObject:p},this._cropping$.next(!0),f==null||f.createControlForCopper(p),this._addHoverForImageCopper(p),d.openRenderByCropper(),f==null||f.refreshControls(),p.makeDirty(!0),this._registerCropShortcuts(p),this._commandService.syncExecuteCommand(n.SetDrawingSelectedOperation.id,[{unitId:a,subUnitId:o,drawingId:c}]),this._layoutService.focus()}))}_searchCropObject(e){for(let t of e.getAllObjectsByOrder())if(t instanceof Z)return t}_initCloseCrop(){this.disposeWithMe(this._commandService.onCommandExecuted(e=>{if(e.id!==O.id)return;let t=this._activeCropSession;if(t==null)return;this._activeCropSession=null;let{scene:n,imageShape:r,imageCropperObject:i}=t,a=n.getTransformerByCreate();a.detachFrom(i),a.clearCopperControl();let o=e.params;if(o!=null&&o.isCancel)this._restoreCropSnapshot(r,i);else{let e=rn(r,i),t=this._drawingManagerService.getDrawingOKey(r.oKey);if(t!=null){let{left:n,top:r,height:a,width:o}=i;this._drawingManagerService.featurePluginUpdateNotification([{...t,transform:{...t.transform,left:n,top:r,height:a,width:o},srcRect:e.srcRectAngle}])}r.setSrcRect({...e.srcRectAngle})}r.closeRenderByCropper(),r.makeDirty(!0),a.refreshControls(),this._cropSnapshots.delete(i),i.dispose(),this._cropping$.next(!1),this._cropShortcutDisposables.dispose()}));let e=this._univerInstanceService.getCurrentTypeOfUnit$(t.UniverInstanceType.UNIVER_SHEET).pipe((0,a.switchMap)(e=>e?e.activeSheet$:(0,a.of)(null)));this.disposeWithMe(e.subscribe(()=>{this._activeCropSession!=null&&this._commandService.syncExecuteCommand(O.id)}))}_getApplyObjectByCropObject(e){let t=e.oKey.slice(0,e.oKey.length-5),n=e.getScene();return n?n.getObject(t)??null:null}_captureCropSnapshot(e){return{transform:e.getState(),srcRect:e.srcRect==null?e.srcRect:{...e.srcRect}}}_restoreCropSnapshot(e,t){let n=this._cropSnapshots.get(t);n&&(e.transformByStateCloseCropper(n.transform),e.setSrcRect(n.srcRect))}_registerCropShortcuts(e){this._cropShortcutDisposables.dispose(),this._cropShortcutDisposables.add(e.onDispose$.subscribeEvent(()=>{this._activeCropSession=null,this._cropping$.next(!1),this._cropShortcutDisposables.dispose()})),this._cropShortcutDisposables.add(this._shortcutService.registerShortcut({id:O.id,binding:i.KeyCode.ENTER,priority:1e3})),this._cropShortcutDisposables.add(this._shortcutService.registerShortcut({id:O.id,binding:i.KeyCode.ESC,priority:1e3,staticParameters:{isCancel:!0}}))}_addListenerOnImage(e){let n=e.getTransformerByCreate(),r=null;this.disposeWithMe(n.changeStart$.subscribe(e=>{let t=e.objects.values().next().value;if(!(t instanceof Z))return;let{left:i,top:a,height:o,width:s,angle:c}=t;r={left:i,top:a,height:o,width:s,angle:c},n.clearCopperControl()})),this.disposeWithMe(n.changeEnd$.subscribe(e=>{let i=e.objects.values().next().value;if(!(i instanceof Z))return;let{left:a,top:o,height:s,width:c,angle:l}=i;if(!(0,t.checkIfMove)({left:a,top:o,height:s,width:c,angle:l},r)){n.createControlForCopper(i);return}let u=this._getApplyObjectByCropObject(i);if(u==null)return;let d=rn(u,i);i.refreshSrcRect(d.srcRect,u.getState()),n.createControlForCopper(i)})),this._endCropListener(e)}_addHoverForImageCopper(e){this.disposeWithMe(e.onPointerEnter$.subscribeEvent(()=>{e.cursor=r.CURSOR_TYPE.MOVE})),this.disposeWithMe(e.onPointerLeave$.subscribeEvent(()=>{e.cursor=r.CURSOR_TYPE.DEFAULT}))}_endCropListener(e){let t=e.getTransformerByCreate();this.disposeWithMe(t.clearControl$.subscribe(e=>{e===!0&&this._commandService.syncExecuteCommand(O.id)}))}};an=G([W(0,t.ICommandService),W(1,n.IDrawingManagerService),W(2,r.IRenderManagerService),W(3,t.IUniverInstanceService),W(4,i.IMessageService),W(5,(0,t.Inject)(t.LocaleService)),W(6,i.IShortcutService),W(7,i.ILayoutService)],an);var on=class extends r.Rect{constructor(e,n,i,a){super(`${e.oKey}-mobile-preview`,{width:44,height:44}),this._image=e,this._scene=n,U(this,`_enabled`,!0),U(this,`_icon`,document.createElement(`img`)),U(this,`_iconContainer`,document.createElement(`div`)),U(this,`_gesture`,new t.DisposableCollection),U(this,`_pressed`,!1),U(this,`_background`,``),U(this,`_border`,``),U(this,`_pressedBackground`,``),this.cursor=r.CURSOR_TYPE.POINTER,this.disposeWithMe(this._gesture),this.disposeWithMe(e.onDispose$.subscribeEvent(()=>this.dispose())),this.disposeWithMe(e.onTransformChange$.subscribeEvent(()=>this._syncPosition())),this.disposeWithMe(n.onTransformChange$.subscribeEvent(()=>this._syncPosition())),this.disposeWithMe(n.beforeRender$.subscribe(()=>this._syncPosition())),this.disposeWithMe(i.currentTheme$.subscribe(()=>{this._background=i.getColorFromTheme(`white`),this._border=i.getColorFromTheme(`gray.200`),this._pressedBackground=i.getColorFromTheme(`gray.100`),(0,s.render)((0,o.createElement)(ct,{width:20,height:20,color:i.getColorFromTheme(`gray.900`),ref:e=>{e&&(this._icon.src=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(new XMLSerializer().serializeToString(e))}`)}}),this._iconContainer),this.makeDirty(!0)})),this._icon.onload=()=>this.makeDirty(!0),this.disposeWithMe(()=>{this._icon.onload=null,(0,s.unmount)(this._iconContainer)}),this.disposeWithMe(this.onPointerDown$.subscribeEvent(e=>{this._gesture.dispose();let t={x:e.offsetX,y:e.offsetY,time:Date.now()},r=!1;this._setPressed(!0),this._gesture.add(n.onPointerDown$.subscribeEvent(t=>{t!==e&&(r=!0,this._setPressed(!1))})),this._gesture.add(n.onPointerMove$.subscribeEvent(e=>{r||=Math.hypot(e.offsetX-t.x,e.offsetY-t.y)>=12,r&&this._setPressed(!1)})),this._gesture.add(n.onPointerCancel$.subscribeEvent(()=>{this._gesture.dispose(),this._setPressed(!1)})),this._gesture.add(n.onPointerUp$.subscribeEvent(e=>{this._gesture.dispose(),this._setPressed(!1),!r&&this.visible&&Date.now()-t.time<500&&Math.hypot(e.offsetX-t.x,e.offsetY-t.y)<12&&a()}))})),this.disposeWithMe(this.onClick$.subscribeEvent((e,t)=>t.stopPropagation())),this.disposeWithMe(this.onDblclick$.subscribeEvent((e,t)=>t.stopPropagation())),n.addObject(this,e.getLayerIndex()),this._syncPosition()}setPreviewEnabled(e){this._enabled=e,this._syncPosition()}dispose(){this._disposed||super.dispose()}_setPressed(e){this._pressed=e,this.makeDirty(!0)}_syncPosition(){let{scaleX:e,scaleY:t}=this._scene.getAncestorScale(),n=44/Math.max(e,.01),i=44/Math.max(t,.01),a=this._enabled&&this._image.visible&&!this._image.isInGroup&&this._image.width>=n&&this._image.height>=i;if(a!==this.visible&&(a?this.show():this.hide()),!a)return;this.layer&&this.getLayerIndex()!==this._image.getLayerIndex()&&(this._scene.removeObject(this),this._scene.addObject(this,this._image.getLayerIndex()));let o=this._image.ancestorTransform.applyPoint(new r.Vector2(this._image.width,0)),s=o.x-n,c=o.y;(s!==this.left||c!==this.top||n!==this.width||i!==this.height)&&this.transformByState({left:s,top:c,width:n,height:i}),this.zIndex!==this._image.zIndex+.5&&(this.zIndex=this._image.zIndex+.5)}_draw(e){e.save(),e.scale(this.width/44,this.height/44),e.translate(6,6),r.Rect.drawWith(e,{width:32,height:32,radius:8,fill:this._pressed?this._pressedBackground:this._background,stroke:this._border,strokeWidth:1}),this._icon.complete&&this._icon.naturalWidth>0&&e.drawImage(this._icon,6,6,20,20),e.restore()}};let sn=class extends t.Disposable{constructor(e,t,n,r,i,a,o){super(),this._commandService=e,this._renderManagerService=t,this._drawingManagerService=n,this._currentUniverService=r,this._drawingRenderService=i,this._themeService=a,this._imageCropperController=o,this._initialize()}_initialize(){this._drawingAddListener(),this._commandExecutedListener(),this._imageUpdateListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.onCommandExecuted(e=>{if(e.id===A.id){let t=e.params;if(t==null)return;this._resetImageSize(t)}}))}_getSceneAndTransformerByDrawingSearch(e){if(e==null)return;let t=this._renderManagerService.getRenderUnitById(e),n=t==null?void 0:t.scene;return n==null?null:{scene:n,transformer:n.getTransformerByCreate()}}_resetImageSize(e){let r=[],i=[];e.forEach(e=>{let{unitId:a,subUnitId:o,drawingId:s}=e,c=this._getSceneAndTransformerByDrawingSearch(a);if(c==null)return;let{scene:l}=c,u=(0,n.getDrawingShapeKeyByDrawingSearch)({unitId:a,subUnitId:o,drawingId:s}),d=l.getObject(u);if(d==null)return!0;let f=this._drawingManagerService.getDrawingByParam(e);if(f==null)return!0;if(f.drawingType!==t.DrawingTypeEnum.DRAWING_IMAGE)return;d.resetSize();let{width:p,height:m}=d.getNativeSize();i.includes(l)||i.push(l),r.push({...f,transform:{...f.transform,height:m,width:p,angle:0},srcRect:null,prstGeom:null})}),this._drawingManagerService.featurePluginUpdateNotification(r),i.forEach(e=>{e.getTransformerByCreate().refreshControls().changeNotification()}),this._commandService.syncExecuteCommand(n.SetDrawingSelectedOperation.id,e)}_drawingAddListener(){this.disposeWithMe(this._drawingManagerService.add$.pipe((0,a.bufferTime)(33),(0,a.filter)(e=>e.length>0),(0,a.map)(e=>e.flat()),(0,a.map)(e=>{let t=new Map;for(let n of e)t.set(`${n.unitId}|${n.subUnitId}|${n.drawingId}`,n);return[...t.values()]}),(0,a.filter)(e=>e.length>0)).subscribe(e=>{this._insertImages(e)}))}_insertImages(e){e.forEach(async e=>{var t;let{unitId:n,subUnitId:r}=e,i=this._getSceneAndTransformerByDrawingSearch(n),a=(t=R(this._currentUniverService,n))==null?void 0:t.subUnitId;if(i==null||a!==r)return;let o=this._drawingManagerService.getDrawingByParam(e);if(o==null)return;let s=await this._drawingRenderService.renderImages(o,i.scene),c=this._drawingManagerService.getDrawingByParam(e);if(c&&this._drawingManagerService.refreshTransform([c]),s!=null&&s.length!==0)for(let t of s)this._addHoverForImage(t),this._addDialogForImage(t,e)})}_imageUpdateListener(){this.disposeWithMe(this._drawingManagerService.update$.subscribe(e=>{e.forEach(e=>{var r;let{unitId:i,subUnitId:a,drawingId:o}=e,s=this._drawingManagerService.getDrawingByParam(e);if(s==null)return;let{transform:c,drawingType:l,srcRect:u,prstGeom:d,source:f,imageSourceType:p}=s;if(l!==t.DrawingTypeEnum.DRAWING_IMAGE)return;let m=this._getSceneAndTransformerByDrawingSearch(i);if(m==null)return;let{scene:h}=m;if(c==null)return!0;let g=(0,n.getDrawingShapeKeyByDrawingSearch)({unitId:i,subUnitId:a,drawingId:o}),_=h.getObject(g);if(_==null)return!0;let{left:v=0,top:y=0,width:b=0,height:x=0,angle:S=0,flipX:C=!1,flipY:w=!1,skewX:T=0,skewY:E=0}=c;_.transformByState({left:v,top:y,width:b,height:x,angle:S,flipX:C,flipY:w,skewX:T,skewY:E}),(r=_.setClipBounds)==null||r.call(_,c.clipBounds),ke(h,_,s),_.setSrcRect(u),_.setPrstGeom(d),f!=null&&f.length>0&&(p===t.ImageSourceType.BASE64||p===t.ImageSourceType.URL)&&_.changeSource(f)})}))}_addHoverForImage(e){this.disposeWithMe((0,t.toDisposable)(e.onPointerEnter$.subscribeEvent(()=>{e.cursor=r.CURSOR_TYPE.GRAB}))),this.disposeWithMe((0,t.toDisposable)(e.onPointerLeave$.subscribeEvent(()=>{e.cursor=r.CURSOR_TYPE.DEFAULT})))}_addDialogForImage(e,n){let r=()=>{let t=e.getNative();t&&this._drawingRenderService.previewImage(`${e.oKey}-viewer-dialog`,t.src,e.getNativeSize().width,e.getNativeSize().height)},i=e.getScene();if(i){let t=new on(e,i,this._themeService,r),o=this.disposeWithMe(()=>t.dispose());t.disposeWithMe(()=>o.dispose()),t.disposeWithMe((0,a.combineLatest)([this._drawingManagerService.focus$,this._imageCropperController.cropping$]).subscribe(([e,r])=>{t.setPreviewEnabled(!r&&!e.some(e=>e.unitId===n.unitId&&e.subUnitId===n.subUnitId&&e.drawingId===n.drawingId))}))}this.disposeWithMe((0,t.toDisposable)(e.onDblclick$.subscribeEvent(r)))}};sn=G([W(0,t.ICommandService),W(1,r.IRenderManagerService),W(2,n.IDrawingManagerService),W(3,t.IUniverInstanceService),W(4,(0,t.Inject)(K)),W(5,(0,t.Inject)(t.ThemeService)),W(6,(0,t.Inject)(an))],sn);function cn(){let e=(0,i.useDependency)(t.ICommandService),n=(0,i.useDependency)(t.LocaleService),r=(0,i.useDependency)(an);return(0,i.useObservable)(r.cropping$,!1)?(0,c.jsxs)(`div`,{role:`group`,"aria-label":n.t(`drawing-ui.image-panel.crop.title`),className:`univer-absolute univer-inset-x-0 univer-bottom-0 univer-z-[1200] univer-grid univer-grid-cols-2 univer-gap-3 univer-bg-gray-0 univer-p-3 univer-pb-[max(12px,env(safe-area-inset-bottom))] univer-shadow-lg dark:!univer-bg-gray-900`,children:[(0,c.jsx)(s.MobileActionRow,{icon:(0,c.jsx)(Qe,{}),title:n.t(`drawing-ui.image-panel.crop.cancel`),variant:`subtle`,onClick:()=>e.executeCommand(O.id,{isCancel:!0})}),(0,c.jsx)(s.MobileActionRow,{icon:(0,c.jsx)(Xe,{}),title:n.t(`drawing-ui.image-panel.crop.apply`),className:`!univer-bg-primary-600 !univer-text-white`,onClick:()=>e.executeCommand(O.id)})]}):null}let ln=class extends t.Disposable{constructor(e,t,n,r){super(),this._commandService=e,this._menuManagerService=t,this._uiPartsService=n,this._injector=r,this._initMenus(),this._initCommands(),this._initUiParts()}_initMenus(){this._menuManagerService.mergeMenu(ve)}_initCommands(){[D,O,A,u,d,f,p,m,h,g,_,v,k,T,E,y,b,x,S,C].forEach(e=>this.disposeWithMe(this._commandService.registerCommand(e)))}_initUiParts(){this.disposeWithMe(this._uiPartsService.registerComponent(i.BuiltInUIPart.CONTENT,()=>(0,i.connectInjector)(cn,this._injector)))}};ln=G([W(0,t.ICommandService),W(1,i.IMenuManagerService),W(2,i.IUIPartsService),W(3,(0,t.Inject)(t.Injector))],ln);let un=class extends t.Plugin{constructor(e=Se,n,r){super(),this._config=e,this._injector=n,this._configService=r;let{menu:i,...a}=(0,t.merge)({},Se,this._config);i&&this._configService.setConfig(`menu`,i,{merge:!0}),this._configService.setConfig(xe,a)}onStarting(){this._injector.add([nn]),this._injector.get(nn),this._initDependencies()}onRendered(){this._injector.get(J),this._injector.get(ln),this._injector.get(an),this._injector.get(sn)}_initDependencies(){[[De],[K],[J],[ln],[an],[sn]].forEach(e=>this._injector.add(e))}};U(un,`pluginName`,`UNIVER_DRAWING_UI_PLUGIN`),U(un,`packageName`,ye),U(un,`version`,be),un=G([(0,t.DependentOn)(n.UniverDrawingPlugin,r.UniverRenderEnginePlugin),W(1,(0,t.Inject)(t.Injector)),W(2,t.IConfigService)],un);function dn(e){var n,r,a;let{popup:l}=e,u=l==null||(n=l.extraProps)==null?void 0:n.menuItems,d=(0,i.useDependency)(t.ICommandService),f=(0,i.useDependency)(t.LocaleService),[p,m]=(0,o.useState)(!1),[h,g]=(0,o.useState)(!1);if(!u)return null;if(((r=l.extraProps)==null?void 0:r.variant)===`doc-floating-toolbar`&&l.extraProps.unitId&&l.extraProps.subUnitId&&l.extraProps.drawingId)return(0,c.jsx)(gn,{menuItems:u,unitId:l.extraProps.unitId,subUnitId:l.extraProps.subUnitId,drawingId:l.extraProps.drawingId});if(((a=l.extraProps)==null?void 0:a.variant)===`doc-chart-floating-toolbar`)return(0,c.jsx)(_n,{menuItems:u});let _=()=>{g(!0)},v=()=>{g(!1)},y=e=>{m(e)},b=e=>{d.executeCommand(e.commandId,e.commandParams),m(!1)},x=p||h;return(0,c.jsx)(`div`,{onMouseEnter:_,onMouseLeave:v,children:(0,c.jsx)(s.DropdownMenu,{align:`start`,items:u.map(e=>({type:`item`,children:f.t(e.label),disabled:e.disable,onSelect:()=>b(e)})),open:p,onOpenChange:y,children:(0,c.jsxs)(`div`,{className:(0,s.clsx)(`univer-flex univer-items-center univer-gap-2 univer-rounded univer-p-1 univer-text-gray-900 hover:univer-bg-gray-100 dark:hover:!univer-bg-gray-800`,s.borderClassName,{"univer-bg-gray-100 dark:!univer-bg-gray-800":p,"univer-bg-gray-0 dark:!univer-bg-gray-900":!p}),children:[(0,c.jsx)(Nt,{className:`univer-fill-primary-600 univer-text-gray-900 dark:!univer-text-gray-0`}),x&&(0,c.jsx)(X,{className:`dark:!univer-text-gray-0`})]})})})}function fn(e,n){var r;let i=e==null||(r=e.getSnapshot().drawings)==null?void 0:r[n];return i?i.layoutType===t.PositionedObjectLayoutType.WRAP_NONE?i.behindDoc===t.BooleanNumber.TRUE?`behindText`:`inFrontOfText`:i.layoutType===t.PositionedObjectLayoutType.WRAP_SQUARE?`wrapSquare`:i.layoutType===t.PositionedObjectLayoutType.WRAP_TOP_AND_BOTTOM?`wrapTopAndBottom`:`inline`:`inline`}function pn(e){return(0,c.jsx)(`div`,{className:`univer-flex univer-h-7 univer-items-center univer-gap-1 univer-px-1`,children:e.children})}function mn(e){return(0,c.jsx)(s.Tooltip,{className:`univer-fill-mode-backwards univer-delay-100`,title:e.title,placement:`bottom`,children:(0,c.jsx)(`button`,{type:`button`,disabled:e.disabled,onClick:e.onClick,className:(0,s.clsx)(`univer-flex univer-h-6 univer-w-6 univer-items-center univer-justify-center univer-rounded-md univer-border-none univer-bg-transparent univer-p-0 univer-text-sm univer-text-gray-700 univer-transition-colors hover:univer-bg-gray-100 disabled:univer-cursor-not-allowed disabled:univer-opacity-40 dark:!univer-text-gray-100 dark:hover:!univer-bg-gray-700`,{"univer-bg-gray-100 univer-text-primary-600 dark:!univer-bg-gray-700 dark:!univer-text-primary-300":e.active}),children:e.children})})}function hn(e){let[t,n]=(0,o.useState)(!1),r=e.options.find(t=>t.value===e.value)??e.options[0];return(0,c.jsx)(s.Dropdown,{open:t,onOpenChange:n,overlay:(0,c.jsx)(`div`,{className:`univer-min-w-32 univer-rounded-lg univer-border univer-border-solid univer-border-gray-200 univer-bg-gray-0 univer-p-1 univer-shadow-lg dark:!univer-border-gray-700 dark:!univer-bg-gray-900`,children:e.options.map(t=>(0,c.jsxs)(`button`,{type:`button`,onClick:()=>{e.onChange(t.value),n(!1)},className:(0,s.clsx)(`univer-flex univer-h-8 univer-w-full univer-items-center univer-gap-2 univer-rounded-md univer-border-none univer-bg-transparent univer-px-2 univer-text-left univer-text-sm univer-text-gray-700 univer-transition-colors hover:univer-bg-gray-100 dark:!univer-text-gray-100 dark:hover:!univer-bg-gray-800`,{"univer-bg-primary-50 univer-text-primary-600 dark:!univer-bg-gray-800 dark:!univer-text-primary-300":t.value===e.value}),children:[(0,c.jsx)(`span`,{className:`univer-flex univer-size-4 univer-items-center univer-justify-center`,children:t.icon}),(0,c.jsx)(`span`,{className:`univer-flex-1`,children:t.label})]},t.value))}),children:(0,c.jsx)(`span`,{children:(0,c.jsx)(s.Tooltip,{className:`univer-fill-mode-backwards univer-delay-100`,title:e.title,placement:`bottom`,children:(0,c.jsxs)(`button`,{type:`button`,className:(0,s.clsx)(`univer-flex univer-h-6 univer-min-w-9 univer-items-center univer-justify-center univer-gap-1 univer-rounded-md univer-border-none univer-bg-transparent univer-px-1.5 univer-text-sm univer-text-gray-700 univer-transition-colors hover:univer-bg-gray-100 dark:!univer-text-gray-100 dark:hover:!univer-bg-gray-700`,{"univer-bg-gray-100 univer-text-primary-600 dark:!univer-bg-gray-700 dark:!univer-text-primary-300":t}),children:[r.icon,(0,c.jsx)(X,{className:`univer-text-xs`})]})})})})}function gn(e){var n;let r=(0,i.useDependency)(t.ICommandService),a=(0,i.useDependency)(i.IconManager),l=(0,i.useDependency)(t.LocaleService),u=(0,i.useDependency)(t.IUniverInstanceService).getUnit(e.unitId,t.UniverInstanceType.UNIVER_DOC)??void 0,[d,f]=(0,o.useState)(()=>fn(u,e.drawingId)),[p,m]=(0,o.useState)(!1),h=e.menuItems.filter(e=>e.type!==`select`&&e.icon).sort((e,t)=>e.index-t.index),g=[{label:l.t(`drawing-ui.image-text-wrap.inline`),value:`inline`,icon:(0,c.jsx)(Tt,{})},{label:l.t(`drawing-ui.image-text-wrap.square`),value:`wrapSquare`,icon:(0,c.jsx)(Tt,{})},{label:l.t(`drawing-ui.image-text-wrap.topAndBottom`),value:`wrapTopAndBottom`,icon:(0,c.jsx)(Tt,{})},{label:l.t(`drawing-ui.image-text-wrap.behindText`),value:`behindText`,icon:(0,c.jsx)(Tt,{})},{label:l.t(`drawing-ui.image-text-wrap.inFrontText`),value:`inFrontOfText`,icon:(0,c.jsx)(Tt,{})}],_=e=>{e&&!e.disable&&(e.hideOnClick&&m(!0),r.executeCommand(e.commandId,e.commandParams))};return p?null:(0,c.jsxs)(`div`,{"data-u-comp":`doc-image-floating-toolbar`,onPointerDown:e=>e.stopPropagation(),onMouseDown:e=>{e.stopPropagation(),e.preventDefault()},className:(0,s.clsx)(`univer-box-border univer-flex univer-items-center univer-rounded univer-bg-gray-0 univer-px-1 univer-py-1 univer-shadow-sm dark:!univer-border-gray-700 dark:!univer-bg-gray-900`,s.borderClassName),children:[(0,c.jsx)(pn,{children:(0,c.jsx)(hn,{title:((n=g.find(e=>e.value===d))==null?void 0:n.label)??l.t(`drawing-ui.image-text-wrap.inline`),value:d,options:g,onChange:t=>{f(t),r.executeCommand(`doc.command.update-doc-drawing-wrapping-style`,{unitId:e.unitId,subUnitId:e.subUnitId,drawings:[{unitId:e.unitId,subUnitId:e.subUnitId,drawingId:e.drawingId}],wrappingStyle:t})}})}),h.length>0&&(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(s.Separator,{orientation:`vertical`}),(0,c.jsx)(pn,{children:h.map(e=>{let t=a.get(e.icon);return(0,c.jsx)(mn,{title:l.t(e.label),disabled:e.disable,onClick:()=>_(e),children:(0,c.jsx)(t,{})},`${e.commandId}-${e.index}`)})})]})]})}function _n(e){var n;let r=(0,i.useDependency)(t.ICommandService),a=(0,i.useDependency)(i.IconManager),l=(0,i.useDependency)(t.LocaleService),[u,d]=(0,o.useState)(!1),f=e.menuItems.find(e=>e.type===`select`),p=e.menuItems.filter(e=>e.type!==`select`&&e.icon).sort((e,t)=>e.index-t.index),m=((f==null?void 0:f.options)??[]).map(e=>{let t=e.icon?a.get(e.icon):Je;return{label:String(e.label),value:e.value,icon:(0,c.jsx)(t,{})}}),h=e=>{e&&!e.disable&&(e.hideOnClick&&d(!0),r.executeCommand(e.commandId,e.commandParams))};return u?null:(0,c.jsxs)(`div`,{"data-u-comp":`doc-chart-floating-toolbar`,onPointerDown:e=>e.stopPropagation(),onMouseDown:e=>{e.stopPropagation(),e.preventDefault()},className:(0,s.clsx)(`univer-box-border univer-flex univer-items-center univer-rounded univer-bg-gray-0 univer-px-1 univer-py-1 univer-shadow-sm dark:!univer-border-gray-700 dark:!univer-bg-gray-900`,s.borderClassName),children:[f&&(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(pn,{children:(0,c.jsx)(hn,{title:l.t(f.label),value:f.value??((n=m[0])==null?void 0:n.value)??``,options:m,onChange:e=>{if(!f.disable){var t;r.executeCommand(f.commandId,(t=f.commandParamsFactory)==null?void 0:t.call(f,e))}}})}),p.length>0&&(0,c.jsx)(s.Separator,{orientation:`vertical`})]}),p.length>0&&(0,c.jsx)(pn,{children:p.map(e=>{let t=a.get(e.icon);return(0,c.jsx)(mn,{title:l.t(e.label),disabled:e.disable,onClick:()=>h(e),children:(0,c.jsx)(t,{})},`${e.commandId}-${e.index}`)})})]})}let vn=e=>{let n=(0,i.useDependency)(t.ICommandService),r=(0,i.useDependency)(t.LocaleService),{drawings:a,alignShow:d}=e,[f,p]=(0,o.useState)(`0`),m=[{label:r.t(`drawing-ui.image-panel.align.default`),value:`0`},{options:[{label:r.t(`drawing-ui.image-panel.align.left`),value:`1`},{label:r.t(`drawing-ui.image-panel.align.center`),value:`2`},{label:r.t(`drawing-ui.image-panel.align.right`),value:`3`}]},{options:[{label:r.t(`drawing-ui.image-panel.align.top`),value:`4`},{label:r.t(`drawing-ui.image-panel.align.middle`),value:`5`},{label:r.t(`drawing-ui.image-panel.align.bottom`),value:`6`}]},{options:[{label:r.t(`drawing-ui.image-panel.align.horizon`),value:`7`},{label:r.t(`drawing-ui.image-panel.align.vertical`),value:`8`}]}];function h(e){let t=Object.values(l).find(t=>t===e);t!=null&&(p(t),n.executeCommand(u.id,{alignType:t,drawings:a}))}return(0,c.jsxs)(`div`,{className:(0,s.clsx)(`univer-relative univer-w-full`,{"univer-hidden":!d}),children:[(0,c.jsx)(`header`,{className:`univer-text-gray-600 dark:!univer-text-gray-200`,children:(0,c.jsx)(`div`,{children:r.t(`drawing-ui.image-panel.align.title`)})}),(0,c.jsx)(`div`,{className:`univer-relative univer-mt-2.5 univer-flex univer-h-full`,children:(0,c.jsx)(`div`,{className:`univer-w-full univer-text-gray-900 dark:!univer-text-gray-0`,children:(0,c.jsx)(s.Select,{value:f,options:m,onChange:h})})})]})},yn=e=>{let{arrangeShow:r,drawings:a}=e,o=(0,i.useDependency)(t.LocaleService),l=(0,i.useDependency)(n.IDrawingManagerService),u=(0,i.useDependency)(t.ICommandService),d=(0,i.useDependency)(i.IconManager),f=d.get(`MoveUpIcon`),p=d.get(`MoveDownIcon`),m=d.get(`TopmostIcon`),h=d.get(`BottomIcon`),g=(0,i.useObservable)(()=>l.focus$,a,!1,[l]),_=e=>{u.syncExecuteCommand(y.id,{arrangeType:e,drawings:g})};return(0,c.jsxs)(`div`,{className:(0,s.clsx)(`univer-grid univer-gap-2 univer-py-2 univer-text-gray-400`,{"univer-hidden":!r}),children:[(0,c.jsx)(`header`,{className:`univer-text-gray-600 dark:!univer-text-gray-200`,children:(0,c.jsx)(`div`,{children:o.t(`drawing-ui.image-panel.arrange.title`)})}),(0,c.jsxs)(`div`,{className:`univer-grid univer-grid-cols-2 univer-gap-2`,children:[(0,c.jsxs)(s.Button,{onClick:()=>{_(t.ArrangeTypeEnum.forward)},children:[(0,c.jsx)(f,{}),o.t(`drawing-ui.image-panel.arrange.forward`)]}),(0,c.jsxs)(s.Button,{onClick:()=>{_(t.ArrangeTypeEnum.backward)},children:[(0,c.jsx)(p,{}),o.t(`drawing-ui.image-panel.arrange.backward`)]}),(0,c.jsxs)(s.Button,{onClick:()=>{_(t.ArrangeTypeEnum.front)},children:[(0,c.jsx)(m,{}),o.t(`drawing-ui.image-panel.arrange.front`)]}),(0,c.jsxs)(s.Button,{onClick:()=>{_(t.ArrangeTypeEnum.back)},children:[(0,c.jsx)(h,{}),o.t(`drawing-ui.image-panel.arrange.back`)]})]})]})},bn=e=>{var o;let l=(0,i.useDependency)(t.LocaleService),u=(0,i.useDependency)(r.IRenderManagerService),d=(0,i.useDependency)(n.IDrawingManagerService),f=(0,i.useDependency)(t.ICommandService),p=(0,i.useDependency)(i.IconManager),{hasGroup:m,drawings:h}=e,g=p.get(`GroupIcon`),_=p.get(`UngroupIcon`),v=h[0],y=v?(o=u.getRenderUnitById(v.unitId))==null||(o=o.scene)==null?void 0:o.getTransformerByCreate():void 0,{groupShow:b,groupBtnShow:x,ungroupBtnShow:S}=(0,i.useObservable)(y?()=>(0,a.merge)(y.clearControl$.pipe((0,a.filter)(e=>e===!0),(0,a.map)(()=>({groupShow:!1,groupBtnShow:!1,ungroupBtnShow:!1}))),y.changeStart$.pipe((0,a.map)(e=>{let n=q(e.objects,d),r=n.length>1,i=n.some(e=>(e==null?void 0:e.drawingType)===t.DrawingTypeEnum.DRAWING_GROUP);return{groupShow:r||i,groupBtnShow:r,ungroupBtnShow:i}}))):null,{groupShow:!1,groupBtnShow:!0,ungroupBtnShow:!0},!1,[d,y]);return(0,c.jsxs)(`div`,{className:(0,s.clsx)(`univer-grid univer-gap-2 univer-py-2 univer-text-gray-400`,{"univer-hidden":m===!0&&b===!1||m===!1}),children:[(0,c.jsx)(`header`,{className:`univer-text-gray-600 dark:!univer-text-gray-200`,children:(0,c.jsx)(`div`,{children:l.t(`drawing-ui.image-panel.group.title`)})}),(0,c.jsxs)(`div`,{className:`univer-flex univer-items-center univer-justify-center univer-gap-2`,children:[(0,c.jsxs)(s.Button,{className:(0,s.clsx)({"univer-hidden":!x}),onClick:()=>{f.syncExecuteCommand(T.id,{drawings:h})},children:[(0,c.jsx)(g,{}),l.t(`drawing-ui.image-panel.group.group`)]}),(0,c.jsxs)(s.Button,{className:(0,s.clsx)({"univer-hidden":!S}),onClick:()=>{f.syncExecuteCommand(E.id,{drawings:h})},children:[(0,c.jsx)(_,{}),l.t(`drawing-ui.image-panel.group.unGroup`)]})]})]})},xn=e=>{var t,n;let a=(0,i.useDependency)(r.IRenderManagerService),o=e.drawings[0],s=o?(t=a.getRenderUnitById(o.unitId))==null?void 0:t.scene:void 0,l=s==null||(n=s.getEngine())==null?void 0:n.activeScene;return!(o!=null&&o.transform)||!s||!l?null:(0,c.jsx)(Sn,{...e})};function Sn(e){let a=(0,i.useDependency)(t.LocaleService),l=(0,i.useDependency)(n.IDrawingManagerService),u=(0,i.useDependency)(r.IRenderManagerService),{drawings:d,transformShow:f}=e,p=d[0],m=p.transform,{unitId:h,subUnitId:g,drawingId:_,drawingType:v}=p,y=u.getRenderUnitById(h).scene,b=y.getEngine().activeScene,x=y.getTransformerByCreate(),{width:S=0,height:C=0,left:w=0,top:T=0,angle:E=0}=m,[D,O]=(0,o.useState)(S),[k,A]=(0,o.useState)(C),[j,N]=(0,o.useState)(w),[P,F]=(0,o.useState)(T),[I,L]=(0,o.useState)(E),[R,z]=(0,o.useState)(x.keepRatio),B=M(p,{getChildren:e=>l.getDrawingsByGroup(e)}),V=Wt(B),H=(e,t,n,r)=>{let{width:i,height:a}=b,{ancestorLeft:o,ancestorTop:s}=y,c=e,l=t,u=n,d=r;return e+o<0&&(c=-o),t+s<0&&(l=-s),u=i-c-o,u<20&&(u=20),d=a-l-s,d<20&&(d=20),e+u+o>i&&(c=i-n-o),t+d+s>a&&(l=a-r-s),{limitLeft:c,limitTop:l,limitWidth:u,limitHeight:d}},ee=e=>{let{objects:t}=e,n=q(t,l);if(n.length!==1)return;let r=n[0];if(r==null)return;let{transform:i}=r;if(i==null)return;let{width:a,height:o,left:s,top:c,angle:u}=i;a!=null&&O(a),o!=null&&A(o),s!=null&&N(s),c!=null&&F(c),u!=null&&L(u)};(0,o.useEffect)(()=>{let e=[x.changeStart$.subscribe(e=>{ee(e)}),x.changing$.subscribe(e=>{ee(e)}),x.changeEnd$.subscribe(e=>{ee(e)}),l.focus$.subscribe(e=>{if(e.length!==1)return;let t=l.getDrawingByParam(e[0]);if(t==null)return;let n=t.transform;if(n==null)return;let{width:r,height:i,left:a,top:o,angle:s}=n;r!=null&&O(r),i!=null&&A(i),a!=null&&N(a),o!=null&&F(o),s!=null&&L(s)})];return()=>{e.forEach(e=>e.unsubscribe())}},[]);let te=(0,t.debounce)(e=>{if(e==null)return;let{limitWidth:t,limitHeight:n}=H(j,P,e,k);e=Math.min(e,t);let r={unitId:h,subUnitId:g,drawingId:_,drawingType:v,transform:{width:e}};if(R){let t=e/D*k;if(t=Math.max(t,20),t>n)return;A(t),r.transform.height=t}O(e),l.featurePluginUpdateNotification([r]),x.refreshControls().changeNotification()},300),ne=(0,t.debounce)(e=>{if(e==null)return;let{limitHeight:t,limitWidth:n}=H(j,P,D,e);e=Math.min(e,t);let r={unitId:h,subUnitId:g,drawingId:_,drawingType:v,transform:{height:e}};if(R){let t=e/k*D;if(t=Math.max(t,20),t>n)return;O(t),r.transform.width=t}A(e),l.featurePluginUpdateNotification([r]),x.refreshControls().changeNotification()},300),re=(0,t.debounce)(e=>{if(e==null)return;let{limitLeft:t}=H(e,P,D,k);e=t;let n={unitId:h,subUnitId:g,drawingId:_,drawingType:v,transform:{left:e}};N(e),l.featurePluginUpdateNotification([n]),x.refreshControls().changeNotification()},300),ie=(0,t.debounce)(e=>{if(e==null)return;let{limitTop:t}=H(j,e,D,k);e=t;let n={unitId:h,subUnitId:g,drawingId:_,drawingType:v,transform:{top:e}};F(e),l.featurePluginUpdateNotification([n]),x.refreshControls().changeNotification()},300),ae=Gt({rotateEnabled:B,drawingParam:{unitId:h,subUnitId:g,drawingId:_,drawingType:v},setRotation:L,emitUpdate:e=>l.featurePluginUpdateNotification(e),notifyChange:()=>x.refreshControls().changeNotification()});return(0,c.jsxs)(`div`,{className:(0,s.clsx)(`univer-grid univer-gap-2 univer-py-2 univer-text-gray-400`,{"univer-hidden":!f}),children:[(0,c.jsx)(`header`,{className:`univer-text-gray-600 dark:!univer-text-gray-200`,children:(0,c.jsx)(`div`,{children:a.t(`drawing-ui.image-panel.transform.title`)})}),(0,c.jsxs)(`div`,{className:`univer-grid univer-grid-cols-3 univer-gap-2 [&>div]:univer-grid [&>div]:univer-gap-2`,children:[(0,c.jsxs)(`div`,{children:[(0,c.jsx)(`span`,{children:a.t(`drawing-ui.image-panel.transform.width`)}),(0,c.jsx)(s.InputNumber,{precision:1,value:D,min:20,onChange:e=>{te(e)}})]}),(0,c.jsxs)(`div`,{children:[(0,c.jsx)(`span`,{children:a.t(`drawing-ui.image-panel.transform.height`)}),(0,c.jsx)(s.InputNumber,{precision:1,value:k,min:20,onChange:e=>{ne(e)}})]}),(0,c.jsxs)(`div`,{children:[(0,c.jsx)(`span`,{children:a.t(`drawing-ui.image-panel.transform.lock`)}),(0,c.jsx)(`div`,{className:`univer-text-center`,children:(0,c.jsx)(s.Checkbox,{checked:R,onChange:e=>{typeof e==`boolean`&&(z(e),x.keepRatio=e)}})})]})]}),(0,c.jsxs)(`div`,{className:`univer-grid univer-grid-cols-3 univer-gap-2 [&>div]:univer-grid [&>div]:univer-gap-2`,children:[(0,c.jsxs)(`div`,{children:[(0,c.jsx)(`span`,{children:a.t(`drawing-ui.image-panel.transform.x`)}),(0,c.jsx)(s.InputNumber,{precision:1,value:j,onChange:e=>{re(e)}})]}),(0,c.jsxs)(`div`,{children:[(0,c.jsx)(`span`,{children:a.t(`drawing-ui.image-panel.transform.y`)}),(0,c.jsx)(s.InputNumber,{precision:1,value:P,onChange:e=>{ie(e)}})]}),(0,c.jsxs)(`div`,{children:[(0,c.jsx)(`span`,{children:a.t(`drawing-ui.image-panel.transform.rotate`)}),(0,c.jsx)(s.InputNumber,{precision:1,value:I,min:Ut[0],max:Ut[1],disabled:V,onChange:ae})]})]})]})}let Cn=e=>{let{drawingParam:t,cropperShow:n,localeService:r,cropValue:i,cropOptions:a,handleCropChange:o,onCropperBtnClick:l,ShapeClipPicker:u}=$t(e);return t?(0,c.jsxs)(`div`,{className:(0,s.clsx)(`univer-grid univer-gap-2 univer-py-2 univer-text-gray-400`,{"univer-hidden":!n}),children:[(0,c.jsx)(`header`,{className:`univer-text-gray-600 dark:!univer-text-gray-200`,children:(0,c.jsx)(`div`,{children:r.t(`drawing-ui.image-panel.crop.title`)})}),(0,c.jsxs)(`div`,{className:`univer-flex univer-items-center univer-justify-center univer-gap-2`,children:[(0,c.jsxs)(s.Button,{onClick:()=>l(i),children:[(0,c.jsx)(et,{}),r.t(`drawing-ui.image-panel.crop.start`)]}),(0,c.jsx)(s.Select,{value:i,options:a,onChange:o})]}),u&&(0,c.jsx)(u,{})]}):null},wn=class extends t.Disposable{constructor(e,t){super(),this._componentManager=e,this._iconManager=t,this._registerComponents(),this._registerIcons()}_registerComponents(){[[Pt,dn],[Lt,yn],[Bt,vn],[Vt,bn],[zt,xn],[Rt,Cn]].forEach(([e,t])=>{this.disposeWithMe(this._componentManager.register(e,t))})}_registerIcons(){this.disposeWithMe(this._iconManager.register({BottomIcon:Ke,DrawingCropIcon:nt,DrawingDeleteIcon:it,DrawingEditIcon:ot,GroupIcon:mt,MoveDownIcon:xt,MoveUpIcon:Ct,TopmostIcon:Dt,UngroupIcon:kt}))}};wn=G([W(0,(0,t.Inject)(i.ComponentManager)),W(1,(0,t.Inject)(i.IconManager))],wn);let Tn=class extends t.Disposable{constructor(e,n,r,i,o,s,c,l){super(),this._commandService=e,this._drawingManagerService=n,this._renderManagerService=r,this._univerInstanceService=i,this._messageService=o,this._localeService=s,this._shortcutService=c,this._layoutService=l,U(this,`_sceneListenerOnImageMap`,new WeakSet),U(this,`_cropShortcutDisposables`,new t.DisposableCollection),U(this,`_cropSnapshots`,new WeakMap),U(this,`_pendingCropSnapshot`,null),U(this,`_activeCropSession`,null),U(this,`_cropping$`,new a.BehaviorSubject(!1)),U(this,`cropping$`,this._cropping$.asObservable()),this.disposeWithMe(this._cropShortcutDisposables),this.disposeWithMe({dispose:()=>this._cropping$.complete()}),this._init()}_init(){this._initOpenCrop(),this._initCloseCrop(),this._initAutoCrop()}_initAutoCrop(){this.disposeWithMe(this._commandService.onCommandExecuted(e=>{if(e.id!==k.id)return;let t=e.params;if(t==null)return;let{cropType:i}=t,a=this._drawingManagerService.getFocusDrawings();if(a.length!==1)return;let{unitId:o,subUnitId:c,drawingId:l}=a[0],u=this._renderManagerService.getRenderUnitById(o),d=u==null?void 0:u.scene;if(d==null)return!0;this._searchCropObject(d)!=null&&this._commandService.syncExecuteCommand(O.id,{isAuto:!0});let f=(0,n.getDrawingShapeKeyByDrawingSearch)({unitId:o,subUnitId:c,drawingId:l}),p=d.getObject(f);if(!(p instanceof r.Image)){this._messageService.show({type:s.MessageType.Error,content:this._localeService.t(`drawing-ui.image-cropper.error`)});return}if(p!=null){this._pendingCropSnapshot=this._captureCropSnapshot(p);try{this._updateCropperObject(i,p),this._commandService.syncExecuteCommand(D.id,{unitId:o,subUnitId:c,drawingId:l})}finally{this._pendingCropSnapshot=null}}}))}_calculateSrcRectByRatio(e,t,n,i,a,o){let s=n/i,c=a/o,l=n,u=i;s>c?l=i*c:u=n/c;let d=(n-l)/2,f=(i-u)/2;return{left:(0,r.precisionTo)(d,1),top:(0,r.precisionTo)(f,1),right:(0,r.precisionTo)(n-(d+l),1),bottom:(0,r.precisionTo)(i-(f+u),1)}}_updateCropperObject(e,t){let{left:n,top:r,width:i,height:a}=t.calculateTransformWithSrcRect(),o;switch(e){case`1`:o=this._calculateSrcRectByRatio(n,r,i,a,1,1);break;case`2`:o=this._calculateSrcRectByRatio(n,r,i,a,16,9);break;case`3`:o=this._calculateSrcRectByRatio(n,r,i,a,9,16);break;case`4`:o=this._calculateSrcRectByRatio(n,r,i,a,5,4);break;case`5`:o=this._calculateSrcRectByRatio(n,r,i,a,4,5);break;case`6`:o=this._calculateSrcRectByRatio(n,r,i,a,4,3);break;case`7`:o=this._calculateSrcRectByRatio(n,r,i,a,3,4);break;case`8`:o=this._calculateSrcRectByRatio(n,r,i,a,3,2);break;case`9`:o=this._calculateSrcRectByRatio(n,r,i,a,2,3)}if(o==null)return;t.setSrcRect(o);let{left:s=0,top:c=0,bottom:l=0,right:u=0}=o;t.transformByStateCloseCropper({left:n+s,top:r+c,width:i-u-s,height:a-l-c})}_initOpenCrop(){this.disposeWithMe(this._commandService.onCommandExecuted(e=>{if(e.id!==D.id)return;let t=e.params;if(t==null)return;this._activeCropSession!=null&&this._commandService.syncExecuteCommand(O.id,{isAuto:!0});let{unitId:i,subUnitId:a,drawingId:o}=t,c=this._renderManagerService.getRenderUnitById(i),l=c==null?void 0:c.scene;if(l==null)return!0;if(this._sceneListenerOnImageMap.has(l)||(this._addListenerOnImage(l),this._sceneListenerOnImageMap.add(l)),this._drawingManagerService.getDrawingByParam({unitId:i,subUnitId:a,drawingId:o})==null)return;let u=(0,n.getDrawingShapeKeyByDrawingSearch)({unitId:i,subUnitId:a,drawingId:o}),d=l.getObject(u);if(!(d instanceof r.Image)){this._messageService.show({type:s.MessageType.Error,content:this._localeService.t(`drawing-ui.image-cropper.error`)});return}let f=l.getTransformer();f==null||f.clearControls();let p=new Z(`${u}-crop`,{srcRect:d.srcRect,prstGeom:d.prstGeom,applyTransform:d.calculateTransformWithSrcRect()});this._cropSnapshots.set(p,this._pendingCropSnapshot??this._captureCropSnapshot(d)),this._pendingCropSnapshot=null,l.addObject(p,d.getLayerIndex()+1).attachTransformerTo(p),this._activeCropSession={scene:l,imageShape:d,imageCropperObject:p},this._cropping$.next(!0),f==null||f.createControlForCopper(p),this._addHoverForImageCopper(p),d.openRenderByCropper(),f==null||f.refreshControls(),p.makeDirty(!0),this._registerCropShortcuts(p),this._commandService.syncExecuteCommand(n.SetDrawingSelectedOperation.id,[{unitId:i,subUnitId:a,drawingId:o}]),this._layoutService.focus()}))}_searchCropObject(e){let t=e.getAllObjectsByOrder();for(let e of t)if(e instanceof Z)return e}_initCloseCrop(){this.disposeWithMe(this._commandService.onCommandExecuted(e=>{if(e.id!==O.id)return;let t=this._activeCropSession;if(t==null)return;this._activeCropSession=null;let{scene:n,imageShape:r,imageCropperObject:i}=t,a=n.getTransformerByCreate();a.detachFrom(i),a.clearCopperControl();let o=e.params;if(o!=null&&o.isCancel)this._restoreCropSnapshot(r,i);else{let e=rn(r,i),t=this._drawingManagerService.getDrawingOKey(r.oKey);if(t!=null){let{left:n,top:r,height:a,width:o}=i;this._drawingManagerService.featurePluginUpdateNotification([{...t,transform:{...t.transform,left:n,top:r,height:a,width:o},srcRect:e.srcRectAngle}])}r.setSrcRect({...e.srcRectAngle})}r.closeRenderByCropper(),r.makeDirty(!0),a.refreshControls(),this._cropSnapshots.delete(i),i.dispose(),this._cropping$.next(!1),this._cropShortcutDisposables.dispose()}));let e=this._univerInstanceService.getCurrentTypeOfUnit$(t.UniverInstanceType.UNIVER_SHEET).pipe((0,a.switchMap)(e=>e?e.activeSheet$:(0,a.of)(null)));this.disposeWithMe(e.subscribe(()=>{this._activeCropSession!=null&&this._commandService.syncExecuteCommand(O.id)}))}_getApplyObjectByCropObject(e){let t=e.oKey,n=t.slice(0,t.length-5),r=e.getScene();return r?r.getObject(n)??null:null}_captureCropSnapshot(e){return{transform:e.getState(),srcRect:e.srcRect==null?e.srcRect:{...e.srcRect}}}_restoreCropSnapshot(e,t){let n=this._cropSnapshots.get(t);n&&(e.transformByStateCloseCropper(n.transform),e.setSrcRect(n.srcRect))}_registerCropShortcuts(e){this._cropShortcutDisposables.dispose(),this._cropShortcutDisposables.add(e.onDispose$.subscribeEvent(()=>{this._activeCropSession=null,this._cropping$.next(!1),this._cropShortcutDisposables.dispose()})),this._cropShortcutDisposables.add(this._shortcutService.registerShortcut({id:O.id,binding:i.KeyCode.ENTER,priority:1e3})),this._cropShortcutDisposables.add(this._shortcutService.registerShortcut({id:O.id,binding:i.KeyCode.ESC,priority:1e3,staticParameters:{isCancel:!0}}))}_addListenerOnImage(e){let n=e.getTransformerByCreate(),r=null;this.disposeWithMe(n.changeStart$.subscribe(e=>{let{objects:t}=e,i=t.values().next().value;if(i==null||!(i instanceof Z))return;let{left:a,top:o,height:s,width:c,angle:l}=i;r={left:a,top:o,height:s,width:c,angle:l},n.clearCopperControl()})),this.disposeWithMe(n.changeEnd$.subscribe(e=>{let{objects:i}=e,a=i.values().next().value;if(a==null||!(a instanceof Z))return;let{left:o,top:s,height:c,width:l,angle:u}=a;if(!(0,t.checkIfMove)({left:o,top:s,height:c,width:l,angle:u},r)){n.createControlForCopper(a);return}let d=this._getApplyObjectByCropObject(a);if(d==null)return;let f=rn(d,a);a.refreshSrcRect(f.srcRect,d.getState()),n.createControlForCopper(a)})),this._endCropListener(e)}_addHoverForImageCopper(e){this.disposeWithMe(e.onPointerEnter$.subscribeEvent(()=>{e.cursor=r.CURSOR_TYPE.MOVE})),this.disposeWithMe(e.onPointerLeave$.subscribeEvent(()=>{e.cursor=r.CURSOR_TYPE.DEFAULT}))}_endCropListener(e){let t=e.getTransformerByCreate();this.disposeWithMe(t.clearControl$.subscribe(e=>{e===!0&&this._commandService.syncExecuteCommand(O.id)}))}};Tn=G([W(0,t.ICommandService),W(1,n.IDrawingManagerService),W(2,r.IRenderManagerService),W(3,t.IUniverInstanceService),W(4,i.IMessageService),W(5,(0,t.Inject)(t.LocaleService)),W(6,i.IShortcutService),W(7,i.ILayoutService)],Tn);let En=class extends t.Disposable{constructor(e,t,n,r,i){super(),this._commandService=e,this._renderManagerService=t,this._drawingManagerService=n,this._currentUniverService=r,this._drawingRenderService=i,this._initialize()}dispose(){super.dispose()}_initialize(){this._drawingAddListener(),this._commandExecutedListener(),this._imageUpdateListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.onCommandExecuted(e=>{if(e.id===A.id){let t=e.params;if(t==null)return;this._resetImageSize(t)}}))}_getSceneAndTransformerByDrawingSearch(e){if(e==null)return;let t=this._renderManagerService.getRenderUnitById(e),n=t==null?void 0:t.scene;return n==null?null:{scene:n,transformer:n.getTransformerByCreate()}}_resetImageSize(e){let r=[],i=[];e.forEach(e=>{let{unitId:a,subUnitId:o,drawingId:s}=e,c=this._getSceneAndTransformerByDrawingSearch(a);if(c==null)return;let{scene:l}=c,u=(0,n.getDrawingShapeKeyByDrawingSearch)({unitId:a,subUnitId:o,drawingId:s}),d=l.getObject(u);if(d==null)return!0;let f=this._drawingManagerService.getDrawingByParam(e);if(f==null)return!0;if(f.drawingType!==t.DrawingTypeEnum.DRAWING_IMAGE)return;d.resetSize();let{width:p,height:m}=d.getNativeSize();i.includes(l)===!1&&i.push(l),r.push({...f,transform:{...f.transform,height:m,width:p,angle:0},srcRect:null,prstGeom:null})}),this._drawingManagerService.featurePluginUpdateNotification(r),i.forEach(e=>{e.getTransformerByCreate().refreshControls().changeNotification()}),this._commandService.syncExecuteCommand(n.SetDrawingSelectedOperation.id,e)}_drawingAddListener(){this.disposeWithMe(this._drawingManagerService.add$.pipe((0,a.bufferTime)(33),(0,a.filter)(e=>e.length>0),(0,a.map)(e=>e.flat()),(0,a.map)(e=>{let t=new Map;for(let n of e)t.set(`${n.unitId}|${n.subUnitId}|${n.drawingId}`,n);return[...t.values()]}),(0,a.filter)(e=>e.length>0)).subscribe(e=>{this._insertImages(e)}))}_insertImages(e){e.forEach(async e=>{var t;let{unitId:n,subUnitId:r}=e,i=this._getSceneAndTransformerByDrawingSearch(n),a=(t=R(this._currentUniverService,n))==null?void 0:t.subUnitId;if(i==null||a!==r)return;let o=this._drawingManagerService.getDrawingByParam(e);if(o==null)return;let s=await this._drawingRenderService.renderImages(o,i.scene),c=this._drawingManagerService.getDrawingByParam(e);if(c&&this._drawingManagerService.refreshTransform([c]),s!=null&&s.length!==0)for(let e of s)this._addHoverForImage(e),this._addDialogForImage(e)})}_imageUpdateListener(){this.disposeWithMe(this._drawingManagerService.update$.subscribe(e=>{e.forEach(e=>{var r;let{unitId:i,subUnitId:a,drawingId:o}=e,s=this._drawingManagerService.getDrawingByParam(e);if(s==null)return;let{transform:c,drawingType:l,srcRect:u,prstGeom:d,source:f,imageSourceType:p}=s;if(l!==t.DrawingTypeEnum.DRAWING_IMAGE)return;let m=this._getSceneAndTransformerByDrawingSearch(i);if(m==null)return;let{scene:h}=m;if(c==null)return!0;let g=(0,n.getDrawingShapeKeyByDrawingSearch)({unitId:i,subUnitId:a,drawingId:o}),_=h.getObject(g);if(_==null)return!0;let{left:v=0,top:y=0,width:b=0,height:x=0,angle:S=0,flipX:C=!1,flipY:w=!1,skewX:T=0,skewY:E=0}=c;_.transformByState({left:v,top:y,width:b,height:x,angle:S,flipX:C,flipY:w,skewX:T,skewY:E}),(r=_.setClipBounds)==null||r.call(_,c.clipBounds),ke(h,_,s),_.setSrcRect(u),_.setPrstGeom(d),f!=null&&f.length>0&&(p===t.ImageSourceType.BASE64||p===t.ImageSourceType.URL)&&_.changeSource(f)})}))}_addHoverForImage(e){this.disposeWithMe((0,t.toDisposable)(e.onPointerEnter$.subscribeEvent(()=>{e.cursor=r.CURSOR_TYPE.GRAB}))),this.disposeWithMe((0,t.toDisposable)(e.onPointerLeave$.subscribeEvent(()=>{e.cursor=r.CURSOR_TYPE.DEFAULT})))}_addDialogForImage(e){this.disposeWithMe((0,t.toDisposable)(e.onDblclick$.subscribeEvent(()=>{let t=e.getNative();t&&this._drawingRenderService.previewImage(`${e.oKey}-viewer-dialog`,t.src,e.getNativeSize().width,e.getNativeSize().height)})))}};En=G([W(0,t.ICommandService),W(1,r.IRenderManagerService),W(2,n.IDrawingManagerService),W(3,t.IUniverInstanceService),W(4,(0,t.Inject)(K))],En);let Dn=class extends t.Disposable{constructor(e,t){super(),this._commandService=e,this._menuManagerService=t,this._init()}_init(){this._initMenus(),this._initCommands()}_initMenus(){this._menuManagerService.mergeMenu(ve)}_initCommands(){[D,O,A,u,d,f,p,m,h,g,_,v,k,T,E,y,b,x,S,C].forEach(e=>this.disposeWithMe(this._commandService.registerCommand(e)))}};Dn=G([W(0,t.ICommandService),W(1,i.IMenuManagerService)],Dn);let On=class extends t.Plugin{constructor(e=Se,n,r){super(),this._config=e,this._injector=n,this._configService=r;let{menu:i,...a}=(0,t.merge)({},Se,this._config);i&&this._configService.setConfig(`menu`,i,{merge:!0}),this._configService.setConfig(xe,a)}onStarting(){this._injector.add([wn]),this._injector.get(wn),this._initDependencies()}onRendered(){this._injector.get(J),this._injector.get(Dn),this._injector.get(Tn),this._injector.get(En)}_initDependencies(){[[De],[K],[J],[Dn],[Tn],[En]].forEach(e=>this._injector.add(e))}};U(On,`pluginName`,`UNIVER_DRAWING_UI_PLUGIN`),U(On,`packageName`,ye),U(On,`version`,be),On=G([(0,t.DependentOn)(n.UniverDrawingPlugin,r.UniverRenderEnginePlugin),W(1,(0,t.Inject)(t.Injector)),W(2,t.IConfigService)],On);let kn=`image/png`,Q=`image/svg+xml`,An=[kn,`image/jpeg`,`image/jpg`,`image/gif`,`image/bmp`],jn={avif:`image/avif`,bmp:`image/bmp`,gif:`image/gif`,heic:`image/heic`,ico:`image/x-icon`,jpeg:`image/jpeg`,jpg:`image/jpeg`,png:kn,svg:`image/svg+xml`,tif:`image/tiff`,tiff:`image/tiff`,webp:`image/webp`};function Mn(e){let t=Array.from(e.items??[]).filter(e=>e.kind===`file`).map(e=>e.getAsFile()).filter(e=>e!==null&&Zn(e));return t.length>0?t:Array.from(e.files??[]).filter(Zn)}function Nn(e){let t=e.trim();return/^data:image\/[a-z0-9.+-]+(?:;[^,]*)?,/i.test(t)||/^<svg(?:\s|>)/i.test(t)&&/<\/svg>$/i.test(t)}async function Pn(e){let t=e.trim();if(/^data:image\/[a-z0-9.+-]+(?:;[^,]*)?,/i.test(t))try{let e=await(await fetch(t)).blob(),n=e.type.split(`;`)[0].toLowerCase();if(n===Q){let t=qn(await e.text());return t?new File([t],`pasted-image.svg`,{type:n}):null}return n.startsWith(`image/`)?new File([e],`pasted-image.${Xn(n)}`,{type:n}):null}catch{return null}let n=qn(t);return n?new File([n],`pasted-image.svg`,{type:Q}):null}function Fn(e){let t=new DOMParser().parseFromString(e,`text/html`).body.cloneNode(!0),n=t.querySelector(`img, svg`)!==null;return t.querySelectorAll(`img, svg`).forEach(e=>e.remove()),n&&!(t.textContent??``).trim()&&!t.querySelector(`table`)}async function In(e){let t=new DOMParser().parseFromString(e,`text/html`),n=Array.from(new Set(Array.from(t.body.querySelectorAll(`img`)).filter(e=>!zn(e)).map(Ln).filter(e=>/^(?:data|blob|https?):/i.test(e)))).slice(0,32),r=await Promise.all(n.map(Rn)),i=Array.from(t.body.querySelectorAll(`svg`)).filter(e=>!zn(e)).map((e,t)=>{let n=qn(new XMLSerializer().serializeToString(e));return n?new File([n],`pasted-image-${t+1}.svg`,{type:Q}):null});return[...r,...i].filter(e=>e!==null).slice(0,32)}function Ln(e){var t;let n=e.getAttribute(`src`)||e.getAttribute(`data-src`)||e.getAttribute(`data-lazy-src`)||e.getAttribute(`data-original`);return n?n.trim():((e.getAttribute(`srcset`)||((t=e.closest(`picture`))==null||(t=t.querySelector(`source[srcset]`))==null?void 0:t.getAttribute(`srcset`))||``).trim().split(/\s+/)[0]??``).replace(/,$/,``)}async function Rn(e){let t=new AbortController,n=setTimeout(()=>t.abort(),5e3);try{let n=await fetch(e,{signal:t.signal});if(!n.ok)return null;let r=await n.blob();return r.type.startsWith(`image/`)?new File([r],`pasted-image.${Xn(r.type)}`,{type:r.type}):null}catch{return null}finally{clearTimeout(n)}}function zn(e){let t=e;for(;t;){var n;if(t.hasAttribute(`hidden`)||((n=t.getAttribute(`aria-hidden`))==null?void 0:n.toLowerCase())===`true`)return!0;let e=t.classList;if(e.contains(`sr-only`)||e.contains(`visually-hidden`)||e.contains(`screen-reader-only`))return!0;let r=t.getAttribute(`style`)??``;if(/(?:^|;)\s*display\s*:\s*none(?:\s*!important)?\s*(?:;|$)/i.test(r)||/(?:^|;)\s*visibility\s*:\s*(?:hidden|collapse)(?:\s*!important)?\s*(?:;|$)/i.test(r))return!0;t=t.parentElement}return!1}async function Bn(e){let t=Qn(e);if(!t)return null;let n=e.type.toLowerCase()===t?e:new File([e],e.name,{type:t});if(t===Q){let e=qn(await n.text());return e?new File([e],n.name||`pasted-image.svg`,{type:t}):null}if(An.includes(t))return n;try{let e=await Gn(n);return e?new File([e],`pasted-image.png`,{type:kn}):null}catch{return null}}async function Vn(e){if(Qn(e)!==Q)return null;let t=qn(await e.text());return t?`data:${Q};charset=utf-8,${encodeURIComponent(t)}`:null}async function Hn(e,t,n){var r;let i=(r=globalThis.navigator)==null?void 0:r.clipboard,a=globalThis.ClipboardItem;if(!e||!(i!=null&&i.write)||a===void 0)return!1;try{let r=Un(e,t,n);return await i.write([new a({[kn]:r})]),!0}catch{return!1}}async function Un(e,t,n){let r=await Wn(e,t,n);if(!r)throw Error(`Clipboard image source could not be resolved.`);let i=await fetch(r);if(!i.ok)throw Error(`Clipboard image source could not be loaded.`);let a=await i.blob(),o=a.type===kn?a:await Gn(a);if(!o)throw Error(`Clipboard image could not be converted to PNG.`);return o}async function Wn(e,n,r){return/^(?:data|blob|https?):/i.test(e)&&n!==t.ImageSourceType.UUID?e:r?r.getImage(e):null}async function Gn(e){if(!e.type.startsWith(`image/`))return null;let t=URL.createObjectURL(e);try{let e=await Kn(t);if(e.naturalWidth===0||e.naturalHeight===0)return null;let n=document.createElement(`canvas`);n.width=e.naturalWidth,n.height=e.naturalHeight;let r=n.getContext(`2d`);return r?(r.drawImage(e,0,0),new Promise(e=>n.toBlob(e,kn))):null}finally{URL.revokeObjectURL(t)}}function Kn(e){return new Promise((t,n)=>{let r=new Image;r.onload=()=>t(r),r.onerror=()=>n(Error(`Clipboard image could not be decoded.`)),r.src=e})}function qn(e){if(e.length>5e6||!Nn(e)||!/^<svg(?:\s|>)/i.test(e))return null;let t=new DOMParser().parseFromString(e,Q),n=t.documentElement;return n.localName.toLowerCase()!==`svg`||t.querySelector(`parsererror`)||n.querySelectorAll(`*`).length>5e4?null:(n.querySelectorAll(`script, foreignObject, iframe, object, embed, link`).forEach(e=>e.remove()),n.querySelectorAll(`style`).forEach(e=>{Yn(e.textContent??``)&&e.remove()}),[n,...Array.from(n.querySelectorAll(`*`))].forEach(e=>{Array.from(e.attributes).forEach(t=>{if(/^on/i.test(t.name)){e.removeAttribute(t.name);return}if(/^(?:href|xlink:href)$/i.test(t.name)&&!Jn(t.value)){e.removeAttribute(t.name);return}Yn(t.value)&&e.removeAttribute(t.name)})}),n.hasAttribute(`xmlns`)||n.setAttribute(`xmlns`,`http://www.w3.org/2000/svg`),new XMLSerializer().serializeToString(n))}function Jn(e){let t=e.trim();return t.startsWith(`#`)||/^data:image\/(?:png|jpe?g|gif|webp);base64,/i.test(t)}function Yn(e){return/@import/i.test(e)?!0:(e.match(/url\([^)]*\)/gi)??[]).some(e=>!/^url\(\s*['"]?#/i.test(e))}function Xn(e){let t=e.split(`/`)[1]??`png`;return t===`svg+xml`?`svg`:t}function Zn(e){return Qn(e)!==null}function Qn(e){var t;let n=e.type.toLowerCase();if(n.startsWith(`image/`))return n;let r=(t=e.name.split(`.`).pop())==null?void 0:t.toLowerCase();return r?jn[r]??null:null}let $n=`floating`,er=`canvas`;function tr(e){return e===t.DrawingTypeEnum.DRAWING_CHART||e===t.DrawingTypeEnum.DRAWING_DOM||e===t.DrawingTypeEnum.DRAWING_UNIT}function nr(e){return tr(e)?$n:er}let rr=`
|
|
2
2
|
univer-flex univer-size-7 univer-shrink-0 univer-items-center univer-justify-center univer-rounded-md
|
|
3
3
|
univer-border-0 univer-bg-transparent univer-p-0 univer-text-gray-500 univer-outline-none univer-transition-colors
|
|
4
4
|
hover:univer-bg-gray-100 hover:univer-text-gray-900
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@univerjs/drawing-ui",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Shared drawing UI components and services for Univer.",
|
|
6
6
|
"author": "DreamNum Co., Ltd. <developer@univer.ai>",
|
|
@@ -58,15 +58,15 @@
|
|
|
58
58
|
"rxjs": ">=7.0.0"
|
|
59
59
|
},
|
|
60
60
|
"dependencies": {
|
|
61
|
-
"@univerjs/core": "1.0.
|
|
62
|
-
"@univerjs/design": "1.0.
|
|
63
|
-
"@univerjs/drawing": "1.0.
|
|
64
|
-
"@univerjs/engine-render": "1.0.
|
|
65
|
-
"@univerjs/icons": "1.43.
|
|
66
|
-
"@univerjs/ui": "1.0.
|
|
61
|
+
"@univerjs/core": "1.0.3",
|
|
62
|
+
"@univerjs/design": "1.0.3",
|
|
63
|
+
"@univerjs/drawing": "1.0.3",
|
|
64
|
+
"@univerjs/engine-render": "1.0.3",
|
|
65
|
+
"@univerjs/icons": "1.43.1",
|
|
66
|
+
"@univerjs/ui": "1.0.3"
|
|
67
67
|
},
|
|
68
68
|
"devDependencies": {
|
|
69
|
-
"@univerjs-infra/shared": "1.0.
|
|
69
|
+
"@univerjs-infra/shared": "1.0.3",
|
|
70
70
|
"postcss": "^8.5.28",
|
|
71
71
|
"react": "18.3.1",
|
|
72
72
|
"rxjs": "^7.8.2",
|