@univerjs/preset-sheets-drawing 0.5.1 → 0.5.2

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 CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("@univerjs/docs-drawing"),r=require("@univerjs/drawing"),n=require("@univerjs/drawing-ui"),i=require("@univerjs/sheets-drawing"),a=require("@univerjs/sheets-drawing-ui");function l(e={}){const{collaboration:o=!1}=e;return{plugins:[[r.UniverDrawingPlugin,{override:o?[[r.IImageIoService,null]]:[]}],t.UniverDocsDrawingPlugin,n.UniverDrawingUIPlugin,i.UniverSheetsDrawingPlugin,a.UniverSheetsDrawingUIPlugin].filter(c=>!!c)}}exports.UniverSheetsDrawingPreset=l;Object.keys(t).forEach(e=>{e!=="default"&&!Object.prototype.hasOwnProperty.call(exports,e)&&Object.defineProperty(exports,e,{enumerable:!0,get:()=>t[e]})});Object.keys(r).forEach(e=>{e!=="default"&&!Object.prototype.hasOwnProperty.call(exports,e)&&Object.defineProperty(exports,e,{enumerable:!0,get:()=>r[e]})});Object.keys(n).forEach(e=>{e!=="default"&&!Object.prototype.hasOwnProperty.call(exports,e)&&Object.defineProperty(exports,e,{enumerable:!0,get:()=>n[e]})});Object.keys(i).forEach(e=>{e!=="default"&&!Object.prototype.hasOwnProperty.call(exports,e)&&Object.defineProperty(exports,e,{enumerable:!0,get:()=>i[e]})});Object.keys(a).forEach(e=>{e!=="default"&&!Object.prototype.hasOwnProperty.call(exports,e)&&Object.defineProperty(exports,e,{enumerable:!0,get:()=>a[e]})});
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("@univerjs/docs-drawing"),r=require("@univerjs/drawing"),n=require("@univerjs/drawing-ui"),i=require("@univerjs/sheets-drawing"),a=require("@univerjs/sheets-drawing-ui");require("@univerjs/sheets-drawing-ui/facade");function l(e={}){const{collaboration:o=!1}=e;return{plugins:[[r.UniverDrawingPlugin,{override:o?[[r.IImageIoService,null]]:[]}],t.UniverDocsDrawingPlugin,n.UniverDrawingUIPlugin,i.UniverSheetsDrawingPlugin,a.UniverSheetsDrawingUIPlugin].filter(c=>!!c)}}exports.UniverSheetsDrawingPreset=l;Object.keys(t).forEach(e=>{e!=="default"&&!Object.prototype.hasOwnProperty.call(exports,e)&&Object.defineProperty(exports,e,{enumerable:!0,get:()=>t[e]})});Object.keys(r).forEach(e=>{e!=="default"&&!Object.prototype.hasOwnProperty.call(exports,e)&&Object.defineProperty(exports,e,{enumerable:!0,get:()=>r[e]})});Object.keys(n).forEach(e=>{e!=="default"&&!Object.prototype.hasOwnProperty.call(exports,e)&&Object.defineProperty(exports,e,{enumerable:!0,get:()=>n[e]})});Object.keys(i).forEach(e=>{e!=="default"&&!Object.prototype.hasOwnProperty.call(exports,e)&&Object.defineProperty(exports,e,{enumerable:!0,get:()=>i[e]})});Object.keys(a).forEach(e=>{e!=="default"&&!Object.prototype.hasOwnProperty.call(exports,e)&&Object.defineProperty(exports,e,{enumerable:!0,get:()=>a[e]})});
package/lib/es/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { UniverDocsDrawingPlugin as i } from "@univerjs/docs-drawing";
1
+ import { UniverDocsDrawingPlugin as e } from "@univerjs/docs-drawing";
2
2
  export * from "@univerjs/docs-drawing";
3
3
  import { UniverDrawingPlugin as n, IImageIoService as t } from "@univerjs/drawing";
4
4
  export * from "@univerjs/drawing";
@@ -8,18 +8,19 @@ import { UniverSheetsDrawingPlugin as f } from "@univerjs/sheets-drawing";
8
8
  export * from "@univerjs/sheets-drawing";
9
9
  import { UniverSheetsDrawingUIPlugin as g } from "@univerjs/sheets-drawing-ui";
10
10
  export * from "@univerjs/sheets-drawing-ui";
11
- function v(r = {}) {
11
+ import "@univerjs/sheets-drawing-ui/facade";
12
+ function U(r = {}) {
12
13
  const { collaboration: o = !1 } = r;
13
14
  return {
14
15
  plugins: [
15
16
  [n, { override: o ? [[t, null]] : [] }],
16
- i,
17
+ e,
17
18
  m,
18
19
  f,
19
20
  g
20
- ].filter((e) => !!e)
21
+ ].filter((i) => !!i)
21
22
  };
22
23
  }
23
24
  export {
24
- v as UniverSheetsDrawingPreset
25
+ U as UniverSheetsDrawingPreset
25
26
  };
package/lib/index.css CHANGED
@@ -1 +1 @@
1
- .univer-image-popup-menu{display:grid;gap:var(--margin-xxs);align-items:center;box-sizing:border-box;margin-top:0;margin-bottom:0;padding:var(--padding-sm);font-size:var(--font-size-base);background-color:rgb(var(--bg-color-secondary));border:1px solid rgb(var(--border-color));border-radius:var(--border-radius-lg);box-shadow:var(--box-shadow-lg)}.univer-image-popup-menu li{list-style:none}.univer-image-popup-menu-item{cursor:pointer;position:relative;display:flex;align-items:center;box-sizing:border-box;height:28px;font-size:var(--font-size-base);font-style:normal;line-height:20px;text-align:left;border-radius:4px;border-radius:var(--border-radius-base);transition:background .2s}.univer-image-popup-menu-item:hover{background-color:rgb(var(--bg-color-hover))}.univer-image-popup-menu-item-icon{position:absolute;top:50%;left:var(--padding-xs);transform:translateY(-50%);display:flex;align-items:center;justify-content:center}.univer-image-popup-menu-item-title{padding:var(--padding-xs) var(--padding-xs) var(--padding-xs) 0;vertical-align:middle}.univer-image-popup-menu-item-hide{color:rgb(var(--text-color-secondary))}.univer-image-popup-menu-item:hover{background:rgb(var(--grey-100))}.univer-btn-container{display:flex;align-items:center;justify-content:center;padding:3px;background:#fff;border:1px solid rgb(var(--grey-200, #e5e5e5));border-radius:4px}.univer-btn-container:hover,.univer-btn-container.univer-btn-container-expand{background:rgb(var(--grey-100, #f5f5f5))}.univer-upload-loading{position:absolute;height:100%;width:100%;text-align:center;background-color:rgba(var(--color-black),.5);z-index:1000;user-select:none}.univer-upload-loading-body{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);background-color:rgb(var(--color-white));padding:20px 40px;display:flex;align-items:center;justify-items:center;border-radius:var(--border-radius-lg)}.univer-upload-loading-body-animation{width:30px;height:30px;border:2px solid rgb(var(--color-black));border-top-color:transparent;border-radius:100%;animation:univer-UniverCircleAnimation infinite .75s linear}.univer-upload-loading-body-text{font-size:var(--font-size-xs);color:var(--color-black);padding:10px}@keyframes univer-UniverCircleAnimation{0%{transform:rotate(0)}to{transform:rotate(360deg)}}.univer-image-common-panel{text-align:center;padding:var(--padding-sm);font-size:var(--font-size-sm)}.univer-image-common-panel-grid{position:relative;width:100%}.univer-image-common-panel-border{border-top:1px solid rgb(var(--border-color));margin-top:20px}.univer-image-common-panel-title{color:rgb(var(--text-color-secondary));text-align:left}.univer-image-common-panel-subtitle{color:rgb(var(--text-color-primary));text-align:left}.univer-image-common-panel-row{position:relative;display:flex;justify-content:flex-start;align-items:flex-start;height:100%;margin-top:10px}.univer-image-common-panel-row-vertical{justify-content:center;align-items:center;height:36px}.univer-image-common-panel-column{width:100%}.univer-image-common-panel-column-center{display:flex;justify-content:center;align-items:center}.univer-image-common-panel-inline{display:flex;align-items:center;gap:var(--margin-xxs)}.univer-image-common-panel-span2{width:50%}.univer-image-common-panel-span3{width:33.33333333%}.univer-image-common-panel-input{width:90%}.univer-sheet-image-menu{position:absolute;height:100%;width:100%;text-align:center}.univer-sheet-image-menu-input{display:none}
1
+ .univer-image-popup-menu{display:grid;gap:var(--margin-xxs);align-items:center;box-sizing:border-box;margin-top:0;margin-bottom:0;padding:var(--padding-sm);font-size:var(--font-size-base);background-color:rgb(var(--bg-color-secondary));border:1px solid rgb(var(--border-color));border-radius:var(--border-radius-lg);box-shadow:var(--box-shadow-lg)}.univer-image-popup-menu li{list-style:none}.univer-image-popup-menu-item{cursor:pointer;position:relative;display:flex;align-items:center;box-sizing:border-box;height:28px;font-size:var(--font-size-base);font-style:normal;line-height:20px;text-align:left;border-radius:4px;border-radius:var(--border-radius-base);transition:background .2s}.univer-image-popup-menu-item:hover{background-color:rgb(var(--bg-color-hover))}.univer-image-popup-menu-item-icon{position:absolute;top:50%;left:var(--padding-xs);transform:translateY(-50%);display:flex;align-items:center;justify-content:center}.univer-image-popup-menu-item-title{padding:var(--padding-xs) var(--padding-xs) var(--padding-xs) 0;vertical-align:middle}.univer-image-popup-menu-item-hide{color:rgb(var(--text-color-secondary))}.univer-image-popup-menu-item:hover{background:rgb(var(--grey-100))}.univer-btn-container{display:flex;align-items:center;justify-content:center;padding:3px;background:#fff;border:1px solid rgb(var(--grey-200, #e5e5e5));border-radius:4px}.univer-btn-container:hover,.univer-btn-container.univer-btn-container-expand{background:rgb(var(--grey-100, #f5f5f5))}*,:before,:after{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(63 131 248 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }::backdrop{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(63 131 248 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }*{scrollbar-color:initial;scrollbar-width:initial}@keyframes enter{0%{opacity:var(--tw-enter-opacity, 1);transform:translate3d(var(--tw-enter-translate-x, 0),var(--tw-enter-translate-y, 0),0) scale3d(var(--tw-enter-scale, 1),var(--tw-enter-scale, 1),var(--tw-enter-scale, 1)) rotate(var(--tw-enter-rotate, 0))}}@keyframes exit{to{opacity:var(--tw-exit-opacity, 1);transform:translate3d(var(--tw-exit-translate-x, 0),var(--tw-exit-translate-y, 0),0) scale3d(var(--tw-exit-scale, 1),var(--tw-exit-scale, 1),var(--tw-exit-scale, 1)) rotate(var(--tw-exit-rotate, 0))}}.univer-upload-loading{position:absolute;height:100%;width:100%;text-align:center;background-color:rgba(var(--color-black),.5);z-index:1000;-webkit-user-select:none;-moz-user-select:none;user-select:none}.univer-upload-loading-body{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);background-color:rgb(var(--color-white));padding:20px 40px;display:flex;align-items:center;justify-items:center;border-radius:var(--border-radius-lg)}.univer-upload-loading-body-animation{width:30px;height:30px;border:2px solid rgb(var(--color-black));border-top-color:transparent;border-radius:100%;animation:univer-UniverCircleAnimation infinite .75s linear}.univer-upload-loading-body-text{font-size:var(--font-size-xs);color:var(--color-black);padding:10px}@keyframes univer-UniverCircleAnimation{0%{transform:rotate(0)}to{transform:rotate(360deg)}}.univer-image-common-panel{text-align:center;padding:var(--padding-sm);font-size:var(--font-size-sm)}.univer-image-common-panel-grid{position:relative;width:100%}.univer-image-common-panel-border{border-top:1px solid rgb(var(--border-color));margin-top:20px}.univer-image-common-panel-title{color:rgb(var(--text-color-secondary));text-align:left}.univer-image-common-panel-subtitle{color:rgb(var(--text-color-primary));text-align:left}.univer-image-common-panel-row{position:relative;display:flex;justify-content:flex-start;align-items:flex-start;height:100%;margin-top:10px}.univer-image-common-panel-row-vertical{justify-content:center;align-items:center;height:36px}.univer-image-common-panel-column{width:100%}.univer-image-common-panel-column-center{display:flex;justify-content:center;align-items:center}.univer-image-common-panel-inline{display:flex;align-items:center;gap:var(--margin-xxs)}.univer-image-common-panel-span2{width:50%}.univer-image-common-panel-span3{width:33.33333333%}.univer-image-common-panel-input{width:90%}.univer-sheet-image-menu{position:absolute;height:100%;width:100%;text-align:center}.univer-sheet-image-menu-input{display:none}
@@ -1,12 +1,6 @@
1
- import { IPreset } from './types';
2
- import '@univerjs/drawing-ui/lib/index.css';
3
- import '@univerjs/sheets-drawing-ui/lib/index.css';
1
+ export * from './umd';
4
2
  export * from '@univerjs/docs-drawing';
5
3
  export * from '@univerjs/drawing';
6
4
  export * from '@univerjs/drawing-ui';
7
5
  export * from '@univerjs/sheets-drawing';
8
6
  export * from '@univerjs/sheets-drawing-ui';
9
- export interface IUniverSheetsDrawingPresetConfig {
10
- collaboration?: boolean;
11
- }
12
- export declare function UniverSheetsDrawingPreset(config?: Partial<IUniverSheetsDrawingPresetConfig>): IPreset;
@@ -0,0 +1,8 @@
1
+ import { IPreset } from './types';
2
+ import '@univerjs/sheets-drawing-ui/facade';
3
+ import '@univerjs/drawing-ui/lib/index.css';
4
+ import '@univerjs/sheets-drawing-ui/lib/index.css';
5
+ export interface IUniverSheetsDrawingPresetConfig {
6
+ collaboration?: boolean;
7
+ }
8
+ export declare function UniverSheetsDrawingPreset(config?: Partial<IUniverSheetsDrawingPresetConfig>): IPreset;
package/lib/umd/index.js CHANGED
@@ -1,9 +1,9 @@
1
1
  // @univerjs/docs-drawing/index
2
- (function(t,i){typeof exports=="object"&&typeof module<"u"?i(exports,require("@univerjs/core"),require("@univerjs/drawing")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/drawing"],i):(t=typeof globalThis<"u"?globalThis:t||self,i(t.UniverDocsDrawing={},t.UniverCore,t.UniverDrawing))})(this,function(t,i,D){"use strict";var j=Object.defineProperty;var y=(t,i,D)=>i in t?j(t,i,{enumerable:!0,configurable:!0,writable:!0,value:D}):t[i]=D;var f=(t,i,D)=>y(t,typeof i!="symbol"?i+"":i,D);var v;const h="docs-drawing.config",S={};class u extends D.UnitDrawingService{}const _=i.createIdentifier("univer.doc.plugin.doc-drawing.service");var U=Object.defineProperty,p=Object.getOwnPropertyDescriptor,I=(c,n,a,e)=>{for(var r=e>1?void 0:e?p(n,a):n,s=c.length-1,o;s>=0;s--)(o=c[s])&&(r=(e?o(n,a,r):o(r))||r);return e&&r&&U(n,a,r),r},g=(c,n)=>(a,e)=>n(a,e,c);const l="DOC_DRAWING_PLUGIN";t.DocDrawingController=class extends i.Disposable{constructor(n,a,e,r){super(),this._docDrawingService=n,this._drawingManagerService=a,this._resourceManagerService=e,this._univerInstanceService=r,this._init()}_init(){this._initSnapshot()}_initSnapshot(){const n=e=>{const r=this._univerInstanceService.getUnit(e,i.UniverInstanceType.UNIVER_DOC);if(r){const s=r.getSnapshot().drawings,o=r.getSnapshot().drawingsOrder,d={data:s!=null?s:{},order:o!=null?o:[]};return JSON.stringify(d)}return""},a=e=>{if(!e)return{data:{},order:[]};try{return JSON.parse(e)}catch{return{data:{},order:[]}}};this.disposeWithMe(this._resourceManagerService.registerPluginResource({pluginName:l,businesses:[i.UniverInstanceType.UNIVER_DOC],toJson:e=>n(e),parseJson:e=>a(e),onUnLoad:e=>{this._setDrawingDataForUnit(e,{data:{},order:[]})},onLoad:(e,r)=>{var s,o;this._setDrawingDataForUnit(e,{data:(s=r.data)!=null?s:{},order:(o=r.order)!=null?o:[]})}}))}_setDrawingDataForUnit(n,a){const e=this._univerInstanceService.getUnit(n);e!=null&&(e.resetDrawing(a.data,a.order),this.loadDrawingDataForUnit(n))}loadDrawingDataForUnit(n){const a=this._univerInstanceService.getUnit(n,i.UniverInstanceType.UNIVER_DOC);if(!a)return!1;const e=n,r=a.getDrawings(),s=a.getDrawingsOrder();if(!r||!s)return!1;Object.keys(r).forEach(d=>{const N=r[d];r[d]={...N}});const o={[e]:{unitId:n,subUnitId:e,data:r,order:s}};return this._docDrawingService.registerDrawingData(n,o),this._drawingManagerService.registerDrawingData(n,o),!0}},t.DocDrawingController=I([g(0,_),g(1,D.IDrawingManagerService),g(2,i.IResourceManagerService),g(3,i.IUniverInstanceService)],t.DocDrawingController);var O=Object.defineProperty,C=Object.getOwnPropertyDescriptor,P=(c,n,a,e)=>{for(var r=e>1?void 0:e?C(n,a):n,s=c.length-1,o;s>=0;s--)(o=c[s])&&(r=(e?o(n,a,r):o(r))||r);return e&&r&&O(n,a,r),r},w=(c,n)=>(a,e)=>n(a,e,c);t.UniverDocsDrawingPlugin=(v=class extends i.Plugin{constructor(n=S,a,e){super(),this._config=n,this._injector=a,this._configService=e;const{...r}=this._config;this._configService.setConfig(h,r)}onStarting(){[[t.DocDrawingController],[u],[_,{useClass:u}]].forEach(n=>this._injector.add(n)),i.touchDependencies(this._injector,[[t.DocDrawingController]])}},f(v,"pluginName",l),f(v,"type",i.UniverInstanceType.UNIVER_DOC),v),t.UniverDocsDrawingPlugin=P([w(1,i.Inject(i.Injector)),w(2,i.IConfigService)],t.UniverDocsDrawingPlugin),t.DOCS_DRAWING_PLUGIN=l,t.DocDrawingService=u,t.IDocDrawingService=_,Object.defineProperty(t,Symbol.toStringTag,{value:"Module"})});
2
+ (function(t,i){typeof exports=="object"&&typeof module<"u"?i(exports,require("@univerjs/core"),require("@univerjs/drawing")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/drawing"],i):(t=typeof globalThis<"u"?globalThis:t||self,i(t.UniverDocsDrawing={},t.UniverCore,t.UniverDrawing))})(this,function(t,i,g){"use strict";var j=Object.defineProperty;var y=(t,i,g)=>i in t?j(t,i,{enumerable:!0,configurable:!0,writable:!0,value:g}):t[i]=g;var f=(t,i,g)=>y(t,typeof i!="symbol"?i+"":i,g);var v;const S="docs-drawing.config",w={};class u extends g.UnitDrawingService{}const _=i.createIdentifier("univer.doc.plugin.doc-drawing.service");var U=Object.defineProperty,p=Object.getOwnPropertyDescriptor,I=(c,n,a,e)=>{for(var r=e>1?void 0:e?p(n,a):n,s=c.length-1,o;s>=0;s--)(o=c[s])&&(r=(e?o(n,a,r):o(r))||r);return e&&r&&U(n,a,r),r},D=(c,n)=>(a,e)=>n(a,e,c);const l="DOC_DRAWING_PLUGIN";t.DocDrawingController=class extends i.Disposable{constructor(n,a,e,r){super(),this._docDrawingService=n,this._drawingManagerService=a,this._resourceManagerService=e,this._univerInstanceService=r,this._init()}_init(){this._initSnapshot()}_initSnapshot(){const n=e=>{const r=this._univerInstanceService.getUnit(e,i.UniverInstanceType.UNIVER_DOC);if(r){const s=r.getSnapshot().drawings,o=r.getSnapshot().drawingsOrder,d={data:s!=null?s:{},order:o!=null?o:[]};return JSON.stringify(d)}return""},a=e=>{if(!e)return{data:{},order:[]};try{return JSON.parse(e)}catch{return{data:{},order:[]}}};this.disposeWithMe(this._resourceManagerService.registerPluginResource({pluginName:l,businesses:[i.UniverInstanceType.UNIVER_DOC],toJson:e=>n(e),parseJson:e=>a(e),onUnLoad:e=>{this._setDrawingDataForUnit(e,{data:{},order:[]})},onLoad:(e,r)=>{var s,o;this._setDrawingDataForUnit(e,{data:(s=r.data)!=null?s:{},order:(o=r.order)!=null?o:[]})}}))}_setDrawingDataForUnit(n,a){const e=this._univerInstanceService.getUnit(n);e!=null&&(e.resetDrawing(a.data,a.order),this.loadDrawingDataForUnit(n))}loadDrawingDataForUnit(n){const a=this._univerInstanceService.getUnit(n,i.UniverInstanceType.UNIVER_DOC);if(!a)return!1;const e=n,r=a.getDrawings(),s=a.getDrawingsOrder();if(!r||!s)return!1;Object.keys(r).forEach(d=>{const N=r[d];r[d]={...N}});const o={[e]:{unitId:n,subUnitId:e,data:r,order:s}};return this._docDrawingService.registerDrawingData(n,o),this._drawingManagerService.registerDrawingData(n,o),!0}},t.DocDrawingController=I([D(0,_),D(1,g.IDrawingManagerService),D(2,i.IResourceManagerService),D(3,i.IUniverInstanceService)],t.DocDrawingController);var O=Object.defineProperty,C=Object.getOwnPropertyDescriptor,P=(c,n,a,e)=>{for(var r=e>1?void 0:e?C(n,a):n,s=c.length-1,o;s>=0;s--)(o=c[s])&&(r=(e?o(n,a,r):o(r))||r);return e&&r&&O(n,a,r),r},h=(c,n)=>(a,e)=>n(a,e,c);t.UniverDocsDrawingPlugin=(v=class extends i.Plugin{constructor(n=w,a,e){super(),this._config=n,this._injector=a,this._configService=e;const{...r}=i.merge({},w,this._config);this._configService.setConfig(S,r)}onStarting(){[[t.DocDrawingController],[u],[_,{useClass:u}]].forEach(n=>this._injector.add(n)),i.touchDependencies(this._injector,[[t.DocDrawingController]])}},f(v,"pluginName",l),f(v,"type",i.UniverInstanceType.UNIVER_DOC),v),t.UniverDocsDrawingPlugin=P([h(1,i.Inject(i.Injector)),h(2,i.IConfigService)],t.UniverDocsDrawingPlugin),t.DOCS_DRAWING_PLUGIN=l,t.DocDrawingService=u,t.IDocDrawingService=_,Object.defineProperty(t,Symbol.toStringTag,{value:"Module"})});
3
3
 
4
4
 
5
5
  // @univerjs/drawing-ui/index
6
- (function(y,h){typeof exports=="object"&&typeof module<"u"?h(exports,require("@univerjs/core"),require("@univerjs/drawing"),require("@univerjs/engine-render"),require("@univerjs/ui"),require("react"),require("@univerjs/design"),require("rxjs")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/drawing","@univerjs/engine-render","@univerjs/ui","react","@univerjs/design","rxjs"],h):(y=typeof globalThis<"u"?globalThis:y||self,h(y.UniverDrawingUi={},y.UniverCore,y.UniverDrawing,y.UniverEngineRender,y.UniverUi,y.React,y.UniverDesign,y.rxjs))})(this,function(y,h,M,b,Ce,S,k,xe){"use strict";var Qn=Object.defineProperty;var $n=(y,h,M)=>h in y?Qn(y,h,{enumerable:!0,configurable:!0,writable:!0,value:M}):y[h]=M;var q=(y,h,M)=>$n(y,typeof h!="symbol"?h+"":h,M);var De;function qe(a,t,n,e){const r=e.getDrawingByParam(a);if(r==null)return;const s=M.getDrawingShapeKeyByDrawingSearch(a),i=n.getObject(s);if(i&&!(i instanceof b.Group))return;if(i!=null){i.addObject(t);return}const o=new b.Group(s);n.addObject(o,b.DRAWING_OBJECT_LAYER_INDEX).attachTransformerTo(o),o.addObject(t);const{transform:c}=r;c&&o.transformByState({left:c.left,top:c.top,angle:c.angle})}function Ne(a,t){var s;const n=t?a.getUnit(t):a.getFocusedUnit();if(n==null)return;const e=n.getUnitId();let r;return n.type===h.UniverInstanceType.UNIVER_SHEET?r=(s=n.getActiveSheet())==null?void 0:s.getSheetId():(n.type===h.UniverInstanceType.UNIVER_DOC||n.type===h.UniverInstanceType.UNIVER_SLIDE)&&(r=e),{unitId:e,subUnitId:r,current:n}}const Ee="COMPONENT_IMAGE_VIEWER";var en=Object.defineProperty,nn=Object.getOwnPropertyDescriptor,tn=(a,t,n,e)=>{for(var r=e>1?void 0:e?nn(t,n):t,s=a.length-1,i;s>=0;s--)(i=a[s])&&(r=(e?i(t,n,r):i(r))||r);return e&&r&&en(t,n,r),r},je=(a,t)=>(n,e)=>t(n,e,a);const Te=50;y.DrawingRenderService=class{constructor(t,n,e){this._drawingManagerService=t,this._imageIoService=n,this._dialogService=e}async renderImages(t,n){const{transform:e,drawingType:r,source:s,imageSourceType:i,srcRect:o,prstGeom:c,groupId:g,unitId:m,subUnitId:d,drawingId:f,isMultiTransform:p,transforms:_}=t;if(r!==h.DrawingTypeEnum.DRAWING_IMAGE||!this._drawingManagerService.getDrawingVisible()||e==null)return;const w=p&&_?_:[e],C=[];for(const P of w){const{left:I,top:E,width:j,height:U,angle:R,flipX:O,flipY:D,skewX:T,skewY:A}=P,V=w.indexOf(P),L=M.getDrawingShapeKeyByDrawingSearch({unitId:m,subUnitId:d,drawingId:f},p?V:void 0),re=n.getObject(L);if(re!=null){re.transformByState({left:I,top:E,width:j,height:U,angle:R,flipX:O,flipY:D,skewX:T,skewY:A});continue}const K=this._drawingManagerService.getDrawingOrder(m,d),ce=K.indexOf(f),ae={...P,zIndex:ce===-1?K.length-1:ce},ie=this._imageIoService.getImageSourceCache(s,i);let le=!1;if(ie!=null)ae.image=ie;else{if(i===M.ImageSourceType.UUID)try{ae.url=await this._imageIoService.getImage(s)}catch(Oe){console.error(Oe);continue}else ae.url=s;le=!0}if(n.getObject(L))continue;ae.printable=!0;const Q=new b.Image(L,ae);le&&this._imageIoService.addImageSourceCache(s,i,Q.getNative()),this._drawingManagerService.getDrawingVisible()&&(n.addObject(Q,b.DRAWING_OBJECT_LAYER_INDEX),this._drawingManagerService.getDrawingEditable()&&n.attachTransformerTo(Q),g&&qe({drawingId:g,unitId:m,subUnitId:d},Q,n,this._drawingManagerService),c!=null&&Q.setPrstGeom(c),o!=null&&Q.setSrcRect(o),C.push(Q))}return C}renderDrawing(t,n){const e=this._drawingManagerService.getDrawingByParam(t);if(e!=null)switch(e.drawingType){case h.DrawingTypeEnum.DRAWING_IMAGE:return this.renderImages(e,n)}}previewImage(t,n,e,r){const s=`${t}-viewer-dialog`,i=window.innerWidth-Te,o=window.innerHeight-Te,c=this._adjustImageSize(e,r,i,o),g=this._dialogService.open({width:Math.max(c.width,200),id:s,style:{margin:"0",top:"50%",left:"50%",transform:"translate(-50%, -50%)"},children:{label:{name:Ee,props:{src:n,width:c.width,height:c.height}}},destroyOnClose:!0,draggable:!1,onClose:()=>{this._dialogService.close(s),g.dispose()}})}_adjustImageSize(t,n,e,r){if(t<=e&&n<=r)return{width:t,height:n};const s=e/t,i=r/n,o=Math.min(s,i);return{width:Math.floor(t*o),height:Math.floor(n*o)}}},y.DrawingRenderService=tn([je(0,M.IDrawingManagerService),je(1,M.IImageIoService),je(2,Ce.IDialogService)],y.DrawingRenderService);function me(a,t){const n=[];return a.forEach(e=>{const{oKey:r,left:s,top:i,height:o,width:c,angle:g}=e,m=t.getDrawingOKey(r);if(m==null)return n.push(null),!0;const{unitId:d,subUnitId:f,drawingId:p,drawingType:_}=m,w={unitId:d,subUnitId:f,drawingId:p,drawingType:_,transform:{left:s,top:i,height:o,width:c,angle:g}};_===h.DrawingTypeEnum.DRAWING_IMAGE&&(w.srcRect=e.srcRect),n.push(w)}),n}var Me={exports:{}},ge={};/**
6
+ (function(y,d){typeof exports=="object"&&typeof module<"u"?d(exports,require("@univerjs/core"),require("@univerjs/drawing"),require("@univerjs/engine-render"),require("@univerjs/ui"),require("react"),require("@univerjs/design"),require("rxjs")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/drawing","@univerjs/engine-render","@univerjs/ui","react","@univerjs/design","rxjs"],d):(y=typeof globalThis<"u"?globalThis:y||self,d(y.UniverDrawingUi={},y.UniverCore,y.UniverDrawing,y.UniverEngineRender,y.UniverUi,y.React,y.UniverDesign,y.rxjs))})(this,function(y,d,M,b,Ce,S,k,xe){"use strict";var Qn=Object.defineProperty;var $n=(y,d,M)=>d in y?Qn(y,d,{enumerable:!0,configurable:!0,writable:!0,value:M}):y[d]=M;var q=(y,d,M)=>$n(y,typeof d!="symbol"?d+"":d,M);var De;function en(a,t,n,e){const r=e.getDrawingByParam(a);if(r==null)return;const s=M.getDrawingShapeKeyByDrawingSearch(a),i=n.getObject(s);if(i&&!(i instanceof b.Group))return;if(i!=null){i.addObject(t);return}const o=new b.Group(s);n.addObject(o,b.DRAWING_OBJECT_LAYER_INDEX).attachTransformerTo(o),o.addObject(t);const{transform:c}=r;c&&o.transformByState({left:c.left,top:c.top,angle:c.angle})}function Ne(a,t){var s;const n=t?a.getUnit(t):a.getFocusedUnit();if(n==null)return;const e=n.getUnitId();let r;return n.type===d.UniverInstanceType.UNIVER_SHEET?r=(s=n.getActiveSheet())==null?void 0:s.getSheetId():(n.type===d.UniverInstanceType.UNIVER_DOC||n.type===d.UniverInstanceType.UNIVER_SLIDE)&&(r=e),{unitId:e,subUnitId:r,current:n}}const Ee="COMPONENT_IMAGE_VIEWER";var nn=Object.defineProperty,tn=Object.getOwnPropertyDescriptor,rn=(a,t,n,e)=>{for(var r=e>1?void 0:e?tn(t,n):t,s=a.length-1,i;s>=0;s--)(i=a[s])&&(r=(e?i(t,n,r):i(r))||r);return e&&r&&nn(t,n,r),r},je=(a,t)=>(n,e)=>t(n,e,a);const Te=50;y.DrawingRenderService=class{constructor(t,n,e){this._drawingManagerService=t,this._imageIoService=n,this._dialogService=e}async renderImages(t,n){const{transform:e,drawingType:r,source:s,imageSourceType:i,srcRect:o,prstGeom:c,groupId:g,unitId:m,subUnitId:h,drawingId:f,isMultiTransform:p,transforms:_}=t;if(r!==d.DrawingTypeEnum.DRAWING_IMAGE||!this._drawingManagerService.getDrawingVisible()||e==null)return;const w=p&&_?_:[e],C=[];for(const P of w){const{left:I,top:E,width:j,height:U,angle:R,flipX:O,flipY:D,skewX:T,skewY:A}=P,V=w.indexOf(P),L=M.getDrawingShapeKeyByDrawingSearch({unitId:m,subUnitId:h,drawingId:f},p?V:void 0),re=n.getObject(L);if(re!=null){re.transformByState({left:I,top:E,width:j,height:U,angle:R,flipX:O,flipY:D,skewX:T,skewY:A});continue}const K=this._drawingManagerService.getDrawingOrder(m,h),ce=K.indexOf(f),ae={...P,zIndex:ce===-1?K.length-1:ce},ie=this._imageIoService.getImageSourceCache(s,i);let le=!1;if(ie!=null)ae.image=ie;else{if(i===M.ImageSourceType.UUID)try{ae.url=await this._imageIoService.getImage(s)}catch(Oe){console.error(Oe);continue}else ae.url=s;le=!0}if(n.getObject(L))continue;ae.printable=!0;const Q=new b.Image(L,ae);le&&this._imageIoService.addImageSourceCache(s,i,Q.getNative()),this._drawingManagerService.getDrawingVisible()&&(n.addObject(Q,b.DRAWING_OBJECT_LAYER_INDEX),this._drawingManagerService.getDrawingEditable()&&n.attachTransformerTo(Q),g&&en({drawingId:g,unitId:m,subUnitId:h},Q,n,this._drawingManagerService),c!=null&&Q.setPrstGeom(c),o!=null&&Q.setSrcRect(o),C.push(Q))}return C}renderDrawing(t,n){const e=this._drawingManagerService.getDrawingByParam(t);if(e!=null)switch(e.drawingType){case d.DrawingTypeEnum.DRAWING_IMAGE:return this.renderImages(e,n)}}previewImage(t,n,e,r){const s=`${t}-viewer-dialog`,i=window.innerWidth-Te,o=window.innerHeight-Te,c=this._adjustImageSize(e,r,i,o),g=this._dialogService.open({width:Math.max(c.width,200),id:s,style:{margin:"0",top:"50%",left:"50%",transform:"translate(-50%, -50%)"},children:{label:{name:Ee,props:{src:n,width:c.width,height:c.height}}},destroyOnClose:!0,draggable:!1,onClose:()=>{this._dialogService.close(s),g.dispose()}})}_adjustImageSize(t,n,e,r){if(t<=e&&n<=r)return{width:t,height:n};const s=e/t,i=r/n,o=Math.min(s,i);return{width:Math.floor(t*o),height:Math.floor(n*o)}}},y.DrawingRenderService=rn([je(0,M.IDrawingManagerService),je(1,M.IImageIoService),je(2,Ce.IDialogService)],y.DrawingRenderService);function me(a,t){const n=[];return a.forEach(e=>{const{oKey:r,left:s,top:i,height:o,width:c,angle:g}=e,m=t.getDrawingOKey(r);if(m==null)return n.push(null),!0;const{unitId:h,subUnitId:f,drawingId:p,drawingType:_}=m,w={unitId:h,subUnitId:f,drawingId:p,drawingType:_,transform:{left:s,top:i,height:o,width:c,angle:g}};_===d.DrawingTypeEnum.DRAWING_IMAGE&&(w.srcRect=e.srcRect),n.push(w)}),n}var Me={exports:{}},ge={};/**
7
7
  * @license React
8
8
  * react-jsx-runtime.production.min.js
9
9
  *
@@ -11,15 +11,15 @@
11
11
  *
12
12
  * This source code is licensed under the MIT license found in the
13
13
  * LICENSE file in the root directory of this source tree.
14
- */var Be;function rn(){if(Be)return ge;Be=1;var a=S,t=Symbol.for("react.element"),n=Symbol.for("react.fragment"),e=Object.prototype.hasOwnProperty,r=a.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,s={key:!0,ref:!0,__self:!0,__source:!0};function i(o,c,g){var m,d={},f=null,p=null;g!==void 0&&(f=""+g),c.key!==void 0&&(f=""+c.key),c.ref!==void 0&&(p=c.ref);for(m in c)e.call(c,m)&&!s.hasOwnProperty(m)&&(d[m]=c[m]);if(o&&o.defaultProps)for(m in c=o.defaultProps,c)d[m]===void 0&&(d[m]=c[m]);return{$$typeof:t,type:o,key:f,ref:p,props:d,_owner:r.current}}return ge.Fragment=n,ge.jsx=i,ge.jsxs=i,ge}var Ue;function an(){return Ue||(Ue=1,Me.exports=rn()),Me.exports}var l=an();function Ae(a){var t,n,e="";if(typeof a=="string"||typeof a=="number")e+=a;else if(typeof a=="object")if(Array.isArray(a)){var r=a.length;for(t=0;t<r;t++)a[t]&&(n=Ae(a[t]))&&(e&&(e+=" "),e+=n)}else for(n in a)a[n]&&(e&&(e+=" "),e+=n);return e}function N(){for(var a,t,n=0,e="",r=arguments.length;n<r;n++)(a=arguments[n])&&(t=Ae(a))&&(e&&(e+=" "),e+=t);return e}var x=(a=>(a.default="0",a.left="1",a.center="2",a.right="3",a.top="4",a.middle="5",a.bottom="6",a.horizon="7",a.vertical="8",a))(x||{});const ve={id:"sheet.operation.set-image-align",type:h.CommandType.OPERATION,handler:(a,t)=>!0},u={imageCommonPanel:"univer-image-common-panel",imageCommonPanelGrid:"univer-image-common-panel-grid",imageCommonPanelBorder:"univer-image-common-panel-border",imageCommonPanelTitle:"univer-image-common-panel-title",imageCommonPanelSubtitle:"univer-image-common-panel-subtitle",imageCommonPanelRow:"univer-image-common-panel-row",imageCommonPanelRowVertical:"univer-image-common-panel-row-vertical",imageCommonPanelColumn:"univer-image-common-panel-column",imageCommonPanelColumnCenter:"univer-image-common-panel-column-center",imageCommonPanelInline:"univer-image-common-panel-inline",imageCommonPanelSpan2:"univer-image-common-panel-span2",imageCommonPanelSpan3:"univer-image-common-panel-span3",imageCommonPanelInput:"univer-image-common-panel-input"},sn=a=>{const t=h.useDependency(h.ICommandService),n=h.useDependency(h.LocaleService),{alignShow:e}=a,[r,s]=S.useState(x.default),i=[{label:n.t("image-panel.align.default"),value:x.default},{options:[{label:n.t("image-panel.align.left"),value:x.left},{label:n.t("image-panel.align.center"),value:x.center},{label:n.t("image-panel.align.right"),value:x.right}]},{options:[{label:n.t("image-panel.align.top"),value:x.top},{label:n.t("image-panel.align.middle"),value:x.middle},{label:n.t("image-panel.align.bottom"),value:x.bottom}]},{options:[{label:n.t("image-panel.align.horizon"),value:x.horizon},{label:n.t("image-panel.align.vertical"),value:x.vertical}]}];function o(g){s(g),t.executeCommand(ve.id,{alignType:g})}const c=g=>g?"block":"none";return l.jsxs("div",{className:N(u.imageCommonPanelGrid,u.imageCommonPanelBorder),style:{display:c(e)},children:[l.jsx("div",{className:u.imageCommonPanelRow,children:l.jsx("div",{className:N(u.imageCommonPanelColumn,u.imageCommonPanelTitle),children:l.jsx("div",{children:n.t("image-panel.align.title")})})}),l.jsx("div",{className:u.imageCommonPanelRow,children:l.jsx("div",{className:N(u.imageCommonPanelColumn),children:l.jsx(k.Select,{value:r,options:i,onChange:o})})})]})};var F=function(){return F=Object.assign||function(a){for(var t,n=1,e=arguments.length;n<e;n++){t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(a[r]=t[r])}return a},F.apply(this,arguments)},on=function(a,t){var n={};for(var e in a)Object.prototype.hasOwnProperty.call(a,e)&&t.indexOf(e)<0&&(n[e]=a[e]);if(a!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,e=Object.getOwnPropertySymbols(a);r<e.length;r++)t.indexOf(e[r])<0&&Object.prototype.propertyIsEnumerable.call(a,e[r])&&(n[e[r]]=a[e[r]]);return n},X=S.forwardRef(function(a,t){var n=a.icon,e=a.id,r=a.className,s=a.extend,i=on(a,["icon","id","className","extend"]),o="univerjs-icon univerjs-icon-".concat(e," ").concat(r||"").trim(),c=S.useRef("_".concat(mn()));return Le(n,"".concat(e),{defIds:n.defIds,idSuffix:c.current},F({ref:t,className:o},i),s)});function Le(a,t,n,e,r){return S.createElement(a.tag,F(F({key:t},cn(a,n,r)),e),(ln(a,n).children||[]).map(function(s,i){return Le(s,"".concat(t,"-").concat(a.tag,"-").concat(i),n,void 0,r)}))}function cn(a,t,n){var e=F({},a.attrs);n!=null&&n.colorChannel1&&e.fill==="colorChannel1"&&(e.fill=n.colorChannel1);var r=t.defIds;return!r||r.length===0||(a.tag==="use"&&e["xlink:href"]&&(e["xlink:href"]=e["xlink:href"]+t.idSuffix),Object.entries(e).forEach(function(s){var i=s[0],o=s[1];typeof o=="string"&&(e[i]=o.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))})),e}function ln(a,t){var n,e=t.defIds;return!e||e.length===0?a:a.tag==="defs"&&(!((n=a.children)===null||n===void 0)&&n.length)?F(F({},a),{children:a.children.map(function(r){return typeof r.attrs.id=="string"&&e&&e.indexOf(r.attrs.id)>-1?F(F({},r),{attrs:F(F({},r.attrs),{id:r.attrs.id+t.idSuffix})}):r})}):a}function mn(){return Math.random().toString(36).substring(2,8)}X.displayName="UniverIcon";var gn={tag:"svg",attrs:{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.56377zM2.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.83647zM9.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"}}]},He=S.forwardRef(function(a,t){return S.createElement(X,Object.assign({},a,{id:"autofill",ref:t,icon:gn}))});He.displayName="Autofill";var un={tag:"svg",attrs:{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.8334 15.6045 1.94974 14.8881 1.2334 14.0045 1.2334H3.70449C2.82084 1.2334 2.10449 1.94974 2.10449 2.8334 2.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.8334 3.30449 2.61248 3.48358 2.4334 3.70449 2.4334H14.0045C14.2254 2.4334 14.4045 2.61249 14.4045 2.8334zM14.1544 8.5999C15.038 8.5999 15.7544 7.88356 15.7544 6.9999 15.7544 6.11625 15.038 5.3999 14.1544 5.3999H3.85439C2.97074 5.3999 2.25439 6.11625 2.25439 6.9999 2.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.9999 3.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.7421 6.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.56641 9.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.7421 11.6631 11.9765 11.6631 12.3564 11.4288 12.5907L9.42923 14.5902M8.57975 14.5902C8.58121 14.5917 8.58268 14.5931 8.58416 14.5946 8.64077 14.6502 8.70566 14.6923 8.77482 14.7209 8.84557 14.7502 8.92314 14.7664 9.00449 14.7664 9.08585 14.7664 9.16342 14.7502 9.23416 14.7209 9.30332 14.6923 9.36821 14.6502 9.42482 14.5946"}}]},Ge=S.forwardRef(function(a,t){return S.createElement(X,Object.assign({},a,{id:"bottom-single",ref:t,icon:un}))});Ge.displayName="BottomSingle";var dn={tag:"svg",attrs:{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.51296 9.08632 7.84433 8.81769 8.11296 8.48632 8.11296H6.57705C6.24568 8.11296 5.97705 7.84433 5.97705 7.51296zM6.57705 9.41028C6.24568 9.41028 5.97705 9.67891 5.97705 10.0103 5.97705 10.3416 6.24568 10.6103 6.57705 10.6103H10.8199C11.1512 10.6103 11.4199 10.3416 11.4199 10.0103 11.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"}}]},Ve=S.forwardRef(function(a,t){return S.createElement(X,Object.assign({},a,{id:"create-copy-single",ref:t,icon:dn}))});Ve.displayName="CreateCopySingle";var hn={tag:"svg",attrs:{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"}}]},We=S.forwardRef(function(a,t){return S.createElement(X,Object.assign({},a,{id:"group-single",ref:t,icon:hn}))});We.displayName="GroupSingle";var fn={tag:"svg",attrs:{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"}}]},ke=S.forwardRef(function(a,t){return S.createElement(X,Object.assign({},a,{id:"more-down-single",ref:t,icon:fn}))});ke.displayName="MoreDownSingle";var pn={tag:"svg",attrs:{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"}}]},ze=S.forwardRef(function(a,t){return S.createElement(X,Object.assign({},a,{id:"move-down-single",ref:t,icon:pn}))});ze.displayName="MoveDownSingle";var Cn={tag:"svg",attrs:{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"}}]},Ke=S.forwardRef(function(a,t){return S.createElement(X,Object.assign({},a,{id:"move-up-single",ref:t,icon:Cn}))});Ke.displayName="MoveUpSingle";var vn={tag:"svg",attrs:{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 9 15.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 9 2.70439 9.22091 2.88348 9.4 3.1044 9.4H13.4044C13.6253 9.4 13.8044 9.22091 13.8044 9 13.8044 8.77909 13.6253 8.6 13.4044 8.6H3.10439zM1.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.1665 15.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.1665 2.8543 13.3874 3.03338 13.5665 3.2543 13.5665H13.5543C13.7752 13.5665 13.9543 13.3874 13.9543 13.1665 13.9543 12.9456 13.7752 12.7665 13.5543 12.7665H3.2543z",fillRule:"evenodd",clipRule:"evenodd"}}]},Fe=S.forwardRef(function(a,t){return S.createElement(X,Object.assign({},a,{id:"topmost-single",ref:t,icon:vn}))});Fe.displayName="TopmostSingle";var wn={tag:"svg",attrs:{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"}}]},Ye=S.forwardRef(function(a,t){return S.createElement(X,Object.assign({},a,{id:"ungroup-single",ref:t,icon:wn}))});Ye.displayName="UngroupSingle";const Sn=a=>{const{arrangeShow:t,drawings:n}=a,e=h.useDependency(h.LocaleService),r=h.useDependency(M.IDrawingManagerService),s=g=>g?"block":"none",[i,o]=S.useState(n);S.useEffect(()=>{const g=r.focus$.subscribe(m=>{o(m)});return()=>{g.unsubscribe()}},[]);const c=g=>{const m=i[0].unitId,d=i[0].subUnitId,f=i.map(p=>p.drawingId);r.featurePluginOrderUpdateNotification({unitId:m,subUnitId:d,drawingIds:f,arrangeType:g})};return l.jsxs("div",{className:u.imageCommonPanelGrid,style:{display:s(t)},children:[l.jsx("div",{className:u.imageCommonPanelRow,children:l.jsx("div",{className:N(u.imageCommonPanelColumn,u.imageCommonPanelTitle),children:l.jsx("div",{children:e.t("image-panel.arrange.title")})})}),l.jsxs("div",{className:u.imageCommonPanelRow,children:[l.jsx("div",{className:N(u.imageCommonPanelColumn,u.imageCommonPanelSpan2),children:l.jsx(k.Button,{size:"small",onClick:()=>{c(h.ArrangeTypeEnum.forward)},children:l.jsxs("span",{className:u.imageCommonPanelInline,children:[l.jsx(Ke,{}),e.t("image-panel.arrange.forward")]})})}),l.jsx("div",{className:N(u.imageCommonPanelColumn,u.imageCommonPanelSpan2),children:l.jsx(k.Button,{size:"small",onClick:()=>{c(h.ArrangeTypeEnum.backward)},children:l.jsxs("span",{className:u.imageCommonPanelInline,children:[l.jsx(ze,{}),e.t("image-panel.arrange.backward")]})})})]}),l.jsxs("div",{className:u.imageCommonPanelRow,children:[l.jsx("div",{className:N(u.imageCommonPanelColumn,u.imageCommonPanelSpan2),children:l.jsx(k.Button,{size:"small",onClick:()=>{c(h.ArrangeTypeEnum.front)},children:l.jsxs("span",{className:u.imageCommonPanelInline,children:[l.jsx(Fe,{}),e.t("image-panel.arrange.front")]})})}),l.jsx("div",{className:N(u.imageCommonPanelColumn,u.imageCommonPanelSpan2),children:l.jsx(k.Button,{size:"small",onClick:()=>{c(h.ArrangeTypeEnum.back)},children:l.jsxs("span",{className:u.imageCommonPanelInline,children:[l.jsx(Ge,{}),e.t("image-panel.arrange.back")]})})})]})]})},_n=a=>{const t=h.useDependency(h.LocaleService),n=h.useDependency(b.IRenderManagerService),e=h.useDependency(M.IDrawingManagerService),{hasGroup:r,drawings:s}=a,[i,o]=S.useState(!1),[c,g]=S.useState(!0),[m,d]=S.useState(!0),f=C=>C?"block":"none",p=()=>{const C=e.getFocusDrawings(),{unitId:P,subUnitId:I}=C[0],E=h.Tools.generateRandomId(10),j=b.getGroupState(0,0,C.map(O=>O.transform||{})),U={unitId:P,subUnitId:I,drawingId:E,drawingType:h.DrawingTypeEnum.DRAWING_GROUP,transform:j},R=C.map(O=>{const D=O.transform||{left:0,top:0},{unitId:T,subUnitId:A,drawingId:V}=O;return{unitId:T,subUnitId:A,drawingId:V,transform:{...D,left:D.left-j.left,top:D.top-j.top},groupId:E}});e.featurePluginGroupUpdateNotification([{parent:U,children:R}])},_=C=>{if(C.drawingType!==h.DrawingTypeEnum.DRAWING_GROUP)return;const{unitId:P,subUnitId:I,drawingId:E,transform:j={width:0,height:0}}=C;if(j==null)return;const U=e.getDrawingsByGroup({unitId:P,subUnitId:I,drawingId:E});if(U.length===0)return;const R=U.map(O=>{const{transform:D}=O,{unitId:T,subUnitId:A,drawingId:V}=O,L=b.transformObjectOutOfGroup(D||{},j,j.width||0,j.height||0);return{unitId:T,subUnitId:A,drawingId:V,transform:{...D,...L},groupId:void 0}});return{parent:C,children:R}},w=()=>{const P=e.getFocusDrawings().map(I=>_(I)).filter(I=>I!=null);P.length!==0&&e.featurePluginUngroupUpdateNotification(P)};return S.useEffect(()=>{const C=s[0];if(C==null)return;const{unitId:P}=C,I=n.getRenderById(P),E=I==null?void 0:I.scene;if(E==null)return;const j=E.getTransformerByCreate(),U=j.clearControl$.subscribe(O=>{O===!0&&o(!1)}),R=j.changeStart$.subscribe(O=>{const{objects:D}=O,T=me(D,e),A=T.filter(K=>(K==null?void 0:K.drawingType)===h.DrawingTypeEnum.DRAWING_GROUP);let V=!1,L=!1;T.length>1&&(V=!0),A.length>0&&(L=!0),o(V||L),g(V),d(L)});return()=>{R.unsubscribe(),U.unsubscribe()}},[]),l.jsxs("div",{className:N(u.imageCommonPanelGrid,u.imageCommonPanelBorder),style:{display:f(r===!0?i:!1)},children:[l.jsx("div",{className:u.imageCommonPanelRow,children:l.jsx("div",{className:N(u.imageCommonPanelColumn,u.imageCommonPanelTitle),children:l.jsx("div",{children:t.t("image-panel.group.title")})})}),l.jsxs("div",{className:u.imageCommonPanelRow,children:[l.jsx("div",{className:N(u.imageCommonPanelColumn,u.imageCommonPanelSpan2,u.imageCommonPanelColumnCenter),children:l.jsx(k.Button,{size:"small",onClick:()=>{p()},style:{display:f(c)},children:l.jsxs("span",{className:u.imageCommonPanelInline,children:[l.jsx(We,{}),t.t("image-panel.group.group")]})})}),l.jsx("div",{className:N(u.imageCommonPanelColumn,u.imageCommonPanelSpan2,u.imageCommonPanelColumnCenter),children:l.jsx(k.Button,{size:"small",onClick:()=>{w()},style:{display:f(m)},children:l.jsxs("span",{className:u.imageCommonPanelInline,children:[l.jsx(Ye,{}),t.t("image-panel.group.unGroup")]})})})]})]})},ne=20,In=20,bn=[-3600,3600],we=300,yn=a=>{var $e;const t=h.useDependency(h.LocaleService),n=h.useDependency(M.IDrawingManagerService),e=h.useDependency(b.IRenderManagerService),{drawings:r,transformShow:s}=a,i=r[0];if(i==null)return;const o=i.transform;if(o==null)return;const{unitId:c,subUnitId:g,drawingId:m,drawingType:d}=i,f=e.getRenderById(c),p=f==null?void 0:f.scene;if(p==null)return;const _=($e=p.getEngine())==null?void 0:$e.activeScene;if(_==null)return;const w=p.getTransformerByCreate(),{width:C=0,height:P=0,left:I=0,top:E=0,angle:j=0}=o,[U,R]=S.useState(C),[O,D]=S.useState(P),[T,A]=S.useState(I),[V,L]=S.useState(E),[re,K]=S.useState(j),[ce,ae]=S.useState(w.keepRatio),ie=(v,B,W,z)=>{const{width:G,height:$}=_,{ancestorLeft:Y,ancestorTop:Z}=p;let J=v,se=B,fe=W,pe=z;return v+Y<0&&(J=-Y),B+Z<0&&(se=-Z),fe=G-J-Y,fe<ne&&(fe=ne),pe=$-se-Z,pe<ne&&(pe=ne),v+fe+Y>G&&(J=G-W-Y),B+pe+Z>$&&(se=$-z-Z),{limitLeft:J,limitTop:se,limitWidth:fe,limitHeight:pe}},le=v=>{const{objects:B}=v,W=me(B,n);if(W.length!==1)return;const z=W[0];if(z==null)return;const{transform:G}=z;if(G==null)return;const{width:$,height:Y,left:Z,top:J,angle:se}=G;$!=null&&R($),Y!=null&&D(Y),Z!=null&&A(Z),J!=null&&L(J),se!=null&&K(se)};S.useEffect(()=>{const v=[w.changeStart$.subscribe(B=>{le(B)}),w.changing$.subscribe(B=>{le(B)}),w.changeEnd$.subscribe(B=>{le(B)}),n.focus$.subscribe(B=>{if(B.length!==1)return;const W=n.getDrawingByParam(B[0]);if(W==null)return;const z=W.transform;if(z==null)return;const{width:G,height:$,left:Y,top:Z,angle:J}=z;G!=null&&R(G),$!=null&&D($),Y!=null&&A(Y),Z!=null&&L(Z),J!=null&&K(J)})];return()=>{v.forEach(B=>B.unsubscribe())}},[]);const Q=h.debounce(v=>{if(v==null)return;v=Math.max(v,ne);const{limitWidth:B,limitHeight:W}=ie(T,V,v,O);v=Math.min(v,B);const z={unitId:c,subUnitId:g,drawingId:m,drawingType:d,transform:{width:v}};if(ce){let G=v/U*O;if(G=Math.max(G,In),G>W)return;D(G),z.transform.height=G}R(v),n.featurePluginUpdateNotification([z]),w.refreshControls().changeNotification()},we),Oe=h.debounce(v=>{if(v==null)return;v=Math.max(v,ne);const{limitHeight:B,limitWidth:W}=ie(T,V,U,v);v=Math.min(v,B);const z={unitId:c,subUnitId:g,drawingId:m,drawingType:d,transform:{height:v}};if(ce){let G=v/O*U;if(G=Math.max(G,ne),G>W)return;R(G),z.transform.width=G}D(v),n.featurePluginUpdateNotification([z]),w.refreshControls().changeNotification()},we),Fn=h.debounce(v=>{if(v==null)return;const{limitLeft:B}=ie(v,V,U,O);v=B;const W={unitId:c,subUnitId:g,drawingId:m,drawingType:d,transform:{left:v}};A(v),n.featurePluginUpdateNotification([W]),w.refreshControls().changeNotification()},we),Yn=h.debounce(v=>{if(v==null)return;const{limitTop:B}=ie(T,v,U,O);v=B;const W={unitId:c,subUnitId:g,drawingId:m,drawingType:d,transform:{top:v}};L(v),n.featurePluginUpdateNotification([W]),w.refreshControls().changeNotification()},we),Zn=v=>{if(v==null)return;const[B,W]=bn;v<B&&(v=B),v>W&&(v=W);const z={unitId:c,subUnitId:g,drawingId:m,drawingType:d,transform:{angle:v}};K(v),n.featurePluginUpdateNotification([z]),w.refreshControls().changeNotification()},Xn=v=>{ae(v),w.keepRatio=v},Jn=v=>v?"block":"none";return l.jsxs("div",{className:N(u.imageCommonPanelGrid,u.imageCommonPanelBorder),style:{display:Jn(s)},children:[l.jsx("div",{className:u.imageCommonPanelRow,children:l.jsx("div",{className:N(u.imageCommonPanelColumn,u.imageCommonPanelTitle),children:l.jsx("div",{children:t.t("image-panel.transform.title")})})}),l.jsxs("div",{className:u.imageCommonPanelRow,children:[l.jsx("div",{className:N(u.imageCommonPanelColumn,u.imageCommonPanelSpan3),children:l.jsxs("label",{children:[l.jsx("div",{className:u.imageCommonPanelRow,children:l.jsx("div",{className:u.imageCommonPanelColumn,children:t.t("image-panel.transform.width")})}),l.jsx("div",{className:u.imageCommonPanelRow,children:l.jsx("div",{className:u.imageCommonPanelColumn,children:l.jsx(k.InputNumber,{precision:1,value:U,onChange:v=>{Q(v)},className:u.imageCommonPanelInput})})})]})}),l.jsx("div",{className:N(u.imageCommonPanelColumn,u.imageCommonPanelSpan3),children:l.jsxs("label",{children:[l.jsx("div",{className:u.imageCommonPanelRow,children:l.jsx("div",{className:u.imageCommonPanelColumn,children:t.t("image-panel.transform.height")})}),l.jsx("div",{className:u.imageCommonPanelRow,children:l.jsx("div",{className:u.imageCommonPanelColumn,children:l.jsx(k.InputNumber,{precision:1,value:O,onChange:v=>{Oe(v)},className:u.imageCommonPanelInput})})})]})}),l.jsx("div",{className:N(u.imageCommonPanelColumn,u.imageCommonPanelSpan3),children:l.jsxs("label",{children:[l.jsx("div",{className:u.imageCommonPanelRow,children:l.jsx("div",{className:u.imageCommonPanelColumn,children:t.t("image-panel.transform.lock")})}),l.jsx("div",{className:N(u.imageCommonPanelRow,u.imageCommonPanelRowVertical),children:l.jsx("div",{className:u.imageCommonPanelColumn,children:l.jsx(k.Checkbox,{checked:ce,onChange:Xn})})})]})})]}),l.jsxs("div",{className:u.imageCommonPanelRow,children:[l.jsx("div",{className:N(u.imageCommonPanelColumn,u.imageCommonPanelSpan3),children:l.jsxs("label",{children:[l.jsx("div",{className:u.imageCommonPanelRow,children:l.jsx("div",{className:u.imageCommonPanelColumn,children:t.t("image-panel.transform.x")})}),l.jsx("div",{className:u.imageCommonPanelRow,children:l.jsx("div",{className:u.imageCommonPanelColumn,children:l.jsx(k.InputNumber,{precision:1,value:T,onChange:v=>{Fn(v)},className:u.imageCommonPanelInput})})})]})}),l.jsx("div",{className:N(u.imageCommonPanelColumn,u.imageCommonPanelSpan3),children:l.jsxs("label",{children:[l.jsx("div",{className:u.imageCommonPanelRow,children:l.jsx("div",{className:u.imageCommonPanelColumn,children:t.t("image-panel.transform.y")})}),l.jsx("div",{className:u.imageCommonPanelRow,children:l.jsx("div",{className:u.imageCommonPanelColumn,children:l.jsx(k.InputNumber,{precision:1,value:V,onChange:v=>{Yn(v)},className:u.imageCommonPanelInput})})})]})}),l.jsx("div",{className:N(u.imageCommonPanelColumn,u.imageCommonPanelSpan3),children:l.jsxs("label",{children:[l.jsx("div",{className:u.imageCommonPanelRow,children:l.jsx("div",{className:u.imageCommonPanelColumn,children:t.t("image-panel.transform.rotate")})}),l.jsx("div",{className:u.imageCommonPanelRow,children:l.jsx("div",{className:u.imageCommonPanelColumn,children:l.jsx(k.InputNumber,{precision:1,value:re,onChange:Zn,className:u.imageCommonPanelInput})})})]})})]})]})},Se={id:"sheet.operation.open-image-crop",type:h.CommandType.OPERATION,handler:(a,t)=>!0},ee={id:"sheet.operation.close-image-crop",type:h.CommandType.OPERATION,handler:(a,t)=>!0};var H=(a=>(a.FREE="0",a.R1_1="1",a.R16_9="2",a.R9_16="3",a.R5_4="4",a.R4_5="5",a.R4_3="6",a.R3_4="7",a.R3_2="8",a.R2_3="9",a))(H||{});const ue={id:"sheet.operation.Auto-image-crop",type:h.CommandType.OPERATION,handler:(a,t)=>!0},Pn=a=>{const t=h.useDependency(h.ICommandService),n=h.useDependency(h.LocaleService),{drawings:e,cropperShow:r}=a;if(e[0]==null)return;const[i,o]=S.useState(H.FREE),c=S.useRef(!1),g=[{label:n.t("image-panel.crop.mode"),value:H.FREE},{label:"1:1",value:H.R1_1},{label:"16:9",value:H.R16_9},{label:"9:16",value:H.R9_16},{label:"5:4",value:H.R5_4},{label:"4:5",value:H.R4_5},{label:"4:3",value:H.R4_3},{label:"3:4",value:H.R3_4},{label:"3:2",value:H.R3_2},{label:"2:3",value:H.R2_3}];S.useEffect(()=>{const p=t.onCommandExecuted(_=>{if(_.id===ee.id){const w=_.params;w!=null&&w.isAuto||(c.current=!1)}});return()=>{p==null||p.dispose()}},[]);function m(p){o(p),c.current&&t.executeCommand(ue.id,{cropType:p})}const d=p=>p?"block":"none",f=p=>{t.executeCommand(ue.id,{cropType:p}),c.current=!0};return l.jsxs("div",{className:N(u.imageCommonPanelGrid,u.imageCommonPanelBorder),style:{display:d(r)},children:[l.jsx("div",{className:u.imageCommonPanelRow,children:l.jsx("div",{className:N(u.imageCommonPanelColumn,u.imageCommonPanelTitle),children:l.jsx("div",{children:n.t("image-panel.crop.title")})})}),l.jsxs("div",{className:N(u.imageCommonPanelRow,u.imageCommonPanelRowVertical),children:[l.jsx("div",{className:N(u.imageCommonPanelColumn,u.imageCommonPanelSpan2),children:l.jsx(k.Button,{size:"small",onClick:()=>{f(i)},children:l.jsxs("span",{className:u.imageCommonPanelInline,children:[l.jsx(Ve,{}),n.t("image-panel.crop.start")]})})}),l.jsx("div",{className:N(u.imageCommonPanelColumn,u.imageCommonPanelSpan2),children:l.jsx(k.Select,{value:i,options:g,onChange:m})})]})]})},jn=a=>{const t=h.useDependency(M.IDrawingManagerService),n=h.useDependency(b.IRenderManagerService),e=h.useDependency(h.LocaleService),{drawings:r,hasArrange:s=!0,hasTransform:i=!0,hasAlign:o=!0,hasCropper:c=!0,hasGroup:g=!0}=a,m=r[0];if(m==null)return;const{unitId:d}=m,f=n.getRenderById(d),p=f==null?void 0:f.scene;if(p==null)return;const _=p.getTransformerByCreate(),[w,C]=S.useState(!0),[P,I]=S.useState(!0),[E,j]=S.useState(!1),[U,R]=S.useState(!0),[O,D]=S.useState(!1);return S.useEffect(()=>{const T=_.clearControl$.subscribe(L=>{L===!0&&(C(!1),I(!1),j(!1),R(!1),D(!0))}),A=_.changeStart$.subscribe(L=>{const{objects:re}=L,K=me(re,t);K.length===0?(C(!1),I(!1),j(!1),R(!1),D(!0)):K.length===1?(C(!0),I(!0),j(!1),R(!0),D(!1)):(C(!0),I(!1),j(!0),R(!1),D(!1))}),V=t.focus$.subscribe(L=>{L.length===0?(C(!1),I(!1),j(!1),R(!1),D(!0)):L.length===1?(C(!0),I(!0),j(!1),R(!0),D(!1)):(C(!0),I(!1),j(!0),R(!1),D(!1))});return()=>{A.unsubscribe(),T.unsubscribe(),V.unsubscribe()}},[]),l.jsxs(l.Fragment,{children:[l.jsx("div",{style:{display:O===!0?"block":"none",height:"100%"},children:l.jsx("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",height:"100%",top:"50%",marginTop:"-100px"},children:l.jsx("span",{children:e.t("image-panel.null")})})}),l.jsx(Sn,{arrangeShow:s===!0?w:!1,drawings:r}),l.jsx(yn,{transformShow:i===!0?P:!1,drawings:r}),l.jsx(sn,{alignShow:o===!0?E:!1,drawings:r}),l.jsx(Pn,{cropperShow:c===!0?U:!1,drawings:r}),l.jsx(_n,{hasGroup:g,drawings:r})]})},de={imagePopupMenu:"univer-image-popup-menu",imagePopupMenuItem:"univer-image-popup-menu-item",imagePopupMenuItemIcon:"univer-image-popup-menu-item-icon",imagePopupMenuItemTitle:"univer-image-popup-menu-item-title",imagePopupMenuItemHide:"univer-image-popup-menu-item-hide",btnContainer:"univer-btn-container",btnContainerExpand:"univer-btn-container-expand"},Ze=a=>{var _,w;const t=(w=(_=a.popup)==null?void 0:_.extraProps)==null?void 0:w.menuItems;if(!t)return null;const n=h.useDependency(h.ICommandService),e=h.useDependency(h.LocaleService),[r,s]=S.useState(!1),[i,o]=S.useState(!1),c=()=>{o(!0)},g=()=>{o(!1)},m=C=>{s(C)},d=C=>{n.executeCommand(C.commandId,C.commandParams),s(!1)},f=r||i,p=t.filter(C=>!C.disable);return l.jsx("div",{onMouseEnter:c,onMouseLeave:g,children:l.jsx(k.Dropdown,{placement:"bottomLeft",trigger:["click"],overlay:l.jsx("ul",{className:de.imagePopupMenu,children:p.map(C=>l.jsx("li",{onClick:()=>d(C),className:de.imagePopupMenuItem,children:l.jsx("span",{className:de.imagePopupMenuItemTitle,children:e.t(C.label)})},C.index))}),visible:r,onVisibleChange:m,children:l.jsxs("div",{className:N(de.btnContainer,{[de.btnContainerExpand]:r}),children:[l.jsx(He,{style:{color:"#35322B"},extend:{colorChannel1:"rgb(var(--green-700, #409f11))"}}),f&&l.jsx(ke,{style:{color:"#CCCCCC",fontSize:"8px",marginLeft:"8px"}})]})})})},Xe="COMPONENT_IMAGE_POPUP_MENU",Mn="drawing-ui.config",Rn={},Re={id:"sheet.operation.image-reset-size",type:h.CommandType.OPERATION,handler:(a,t)=>!0},Dn=a=>{const{src:t}=a;return t?l.jsx("div",{children:l.jsx("img",{src:t,alt:"Univer Image Viewer",style:{width:"100%",height:"100%",position:"relative"}})}):null};var On=Object.defineProperty,xn=Object.getOwnPropertyDescriptor,Nn=(a,t,n,e)=>{for(var r=e>1?void 0:e?xn(t,n):t,s=a.length-1,i;s>=0;s--)(i=a[s])&&(r=(e?i(t,n,r):i(r))||r);return e&&r&&On(t,n,r),r},Je=(a,t)=>(n,e)=>t(n,e,a);let _e=class extends h.Disposable{constructor(a,t){super(),this._componentManager=a,this._commandService=t,this._init()}_initCustomComponents(){const a=this._componentManager;this.disposeWithMe(a.register(Xe,Ze)),this.disposeWithMe(a.register(Ee,Dn))}_initCommands(){[Se,ee,Re,ve,ue].forEach(a=>this.disposeWithMe(this._commandService.registerCommand(a)))}_init(){this._initCommands(),this._initCustomComponents()}};_e=Nn([Je(0,h.Inject(Ce.ComponentManager)),Je(1,h.ICommandService)],_e);var En=Object.defineProperty,Tn=Object.getOwnPropertyDescriptor,Bn=(a,t,n,e)=>{for(var r=e>1?void 0:e?Tn(t,n):t,s=a.length-1,i;s>=0;s--)(i=a[s])&&(r=(e?i(t,n,r):i(r))||r);return e&&r&&En(t,n,r),r},Ie=(a,t)=>(n,e)=>t(n,e,a);let be=class extends h.Disposable{constructor(t,n,e,r){super();q(this,"_sceneListenerOnDrawingMap",new WeakSet);this._currentUniverService=t,this._commandService=n,this._renderManagerService=e,this._drawingManagerService=r,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(){const t=this._drawingManagerService.drawingManagerData,n=Ne(this._currentUniverService);if(n==null)return;const{unitId:e,subUnitId:r}=n;Object.keys(t).forEach(s=>{Object.keys(t[s]).forEach(i=>{const o=t[s][i].data;o==null||s!==e||i!==r||Object.keys(o).forEach(c=>{o[c]&&this._insertDrawing([{unitId:s,subUnitId:i,drawingId:c}])})})})}_commandExecutedListener(){this.disposeWithMe(this._commandService.onCommandExecuted(t=>{if(t.id===ve.id){const n=t.params;if(n==null)return;this._drawingAlign(n)}}))}_drawingGroupListener(){this.disposeWithMe(this._drawingManagerService.group$.subscribe(t=>{this._groupDrawings(t)})),this.disposeWithMe(this._drawingManagerService.ungroup$.subscribe(t=>{this._ungroupDrawings(t)}))}_getSceneAndTransformerByDrawingSearch(t){if(t==null)return;const n=this._renderManagerService.getRenderById(t),e=n==null?void 0:n.scene;if(e==null)return null;const r=e.getTransformerByCreate();return{scene:e,transformer:r}}_groupDrawings(t){t.forEach(n=>{this._groupDrawing(n)})}_groupDrawing(t){const{parent:n,children:e}=t,{unitId:r,subUnitId:s,drawingId:i}=n,o=this._getSceneAndTransformerByDrawingSearch(n.unitId);if(o==null)return;const{scene:c,transformer:g}=o;this._commandService.syncExecuteCommand(ee.id);const m=[];if(e.forEach(p=>{const _=M.getDrawingShapeKeyByDrawingSearch(p),w=c.getObjectIncludeInGroup(_);if(w==null||m.includes(w))return;m.push(w);const{transform:C}=p;C!=null&&(w.classType===b.RENDER_CLASS_TYPE.GROUP?w.transformByState({left:C.left,top:C.top}):w.transformByState(C))}),m.length===0)return;const d=M.getDrawingShapeKeyByDrawingSearch({unitId:r,subUnitId:s,drawingId:i}),f=new b.Group(d);c.addObject(f,b.DRAWING_OBJECT_LAYER_INDEX).attachTransformerTo(f),f.addObjects(...m),n.transform&&f.transformByState({left:n.transform.left,top:n.transform.top}),g.clearSelectedObjects(),g.setSelectedControl(f)}_ungroupDrawings(t){t.forEach(n=>{this._ungroupDrawing(n)})}_ungroupDrawing(t){const{parent:n,children:e}=t,r=this._getSceneAndTransformerByDrawingSearch(n.unitId);if(r==null)return;const{scene:s,transformer:i}=r;e.forEach(d=>{const f=M.getDrawingShapeKeyByDrawingSearch(d),p=s.getObjectIncludeInGroup(f);if(p==null)return!0;if(p==null)return;const{transform:_}=d;_!=null&&(p.classType===b.RENDER_CLASS_TYPE.GROUP?p.transformByState({left:_.left,top:_.top}):p.transformByState(_))});const o=M.getDrawingShapeKeyByDrawingSearch(n),c=s.getObject(o),{width:g,height:m}=c;c.getObjects().forEach(d=>{c.removeSelfObjectAndTransform(d.oKey,g,m)}),c.dispose(),i.clearSelectedObjects()}_drawingAlign(t){const{alignType:n}=t,e=this._drawingManagerService.getFocusDrawings();if(n===x.default)return;const r=[];let s=Number.POSITIVE_INFINITY,i=Number.POSITIVE_INFINITY,o=Number.NEGATIVE_INFINITY,c=Number.NEGATIVE_INFINITY,g=0;e.forEach(m=>{const{unitId:d,subUnitId:f,drawingId:p,drawingType:_}=m,w=this._drawingManagerService.getDrawingByParam({unitId:d,subUnitId:f,drawingId:p});if(w==null||w.transform==null)return;r.push({unitId:d,subUnitId:f,drawingId:p,drawingType:_,transform:w.transform});const{left:C=0,top:P=0,width:I=0,height:E=0}=w.transform;s=Math.min(s,C),i=Math.min(i,P),o=Math.max(o,C+I),c=Math.max(c,P+E),g++}),g!==0&&(this._sortDrawingTransform(r,n),this._applyAlignType(r,n,s,i,o,c,g))}_applyAlignType(t,n,e,r,s,i,o){const c=Math.round((s-e)/o*10)/10,g=Math.round((i-r)/o*10)/10,m=[],d=this._getSceneAndTransformerByDrawingSearch(t[0].unitId);if(d==null)return;const{scene:f,transformer:p}=d;t.forEach((_,w)=>{const{unitId:C,subUnitId:P,drawingId:I,transform:E,drawingType:j}=_,{left:U=0,top:R=0,width:O=0,height:D=0}=E;let T=U,A=R;switch(n){case x.left:T=e;break;case x.center:T=e+(s-e)/2-O/2;break;case x.right:T=s-O;break;case x.top:A=r;break;case x.middle:A=r+(i-r)/2-D/2;break;case x.bottom:A=i-D;break;case x.horizon:T=e+c*w;break;case x.vertical:A=r+g*w;break}(T!==U||A!==R)&&m.push({unitId:C,subUnitId:P,drawingId:I,drawingType:j,transform:{left:T,top:A}})}),this._drawingManagerService.featurePluginUpdateNotification(m),p.refreshControls().changeNotification()}_sortDrawingTransform(t,n){t.sort((e,r)=>{const s=e.transform,i=r.transform,{left:o=0,top:c=0,width:g=0,height:m=0}=s,{left:d=0,top:f=0,width:p=0,height:_=0}=i;switch(n){case x.left:return o-d;case x.center:return o+g/2-(d+p/2);case x.right:return o+g-(d+p);case x.top:return c-f;case x.middle:return c+m/2-(f+_/2);case x.bottom:return c+m-(f+_);case x.horizon:return o+g/2-(d+p/2);case x.vertical:return c+m/2-(f+_/2);default:return 0}})}_drawingArrangeListener(){this.disposeWithMe(this._drawingManagerService.order$.subscribe(t=>{this._drawingArrange(t)}))}_drawingArrange(t){const{unitId:n,subUnitId:e,drawingIds:r}=t,s=this._getSceneAndTransformerByDrawingSearch(n);if(s==null)return;const{scene:i}=s;r.forEach(o=>{const c=M.getDrawingShapeKeyByDrawingSearch({unitId:n,subUnitId:e,drawingId:o}),g=i.fuzzyMathObjects(c,!0);if(g==null||g.length===0)return;const m=this._drawingManagerService.getDrawingOrder(n,e).indexOf(o);for(const d of g)d.setProps({zIndex:m}),d.makeDirty()})}_drawingAddListener(){this.disposeWithMe(this._drawingManagerService.add$.subscribe(t=>{this._insertDrawing(t)}))}_insertDrawing(t){const n=[];t.forEach(e=>{const{unitId:r}=e;if(this._drawingManagerService.getDrawingByParam(e)==null)return;const i=this._getSceneAndTransformerByDrawingSearch(r);if(i==null)return;const{scene:o}=i;n.includes(o)||n.push(o)}),n.forEach(e=>{this._sceneListenerOnDrawingMap.has(e)||(this._addListenerOnDrawing(e),this._sceneListenerOnDrawingMap.add(e))})}_drawingRemoveListener(){this.disposeWithMe(this._drawingManagerService.remove$.subscribe(t=>{t.forEach(n=>{var m;const{unitId:e,subUnitId:r,drawingId:s}=n,i=this._getSceneAndTransformerByDrawingSearch(e);if(i==null)return;const{scene:o}=i,c=M.getDrawingShapeKeyByDrawingSearch({unitId:e,subUnitId:r,drawingId:s}),g=o.fuzzyMathObjects(c,!0);if(g.length>0){for(const d of g)d.dispose();(m=o.getTransformer())==null||m.clearSelectedObjects()}})}))}_drawingUpdateListener(){this.disposeWithMe(this._drawingManagerService.update$.subscribe(t=>{t.forEach(n=>{const{unitId:e,subUnitId:r,drawingId:s}=n,i=this._drawingManagerService.getDrawingByParam(n);if(i==null)return;const{transform:o,drawingType:c}=i,g=this._getSceneAndTransformerByDrawingSearch(e);if(g==null)return;const{scene:m,transformer:d}=g;if(o==null)return!0;const{left:f=0,top:p=0,width:_=0,height:w=0,angle:C=0,flipX:P=!1,flipY:I=!1,skewX:E=0,skewY:j=0}=o,U=M.getDrawingShapeKeyByDrawingSearch({unitId:e,subUnitId:r,drawingId:s}),R=m.getObject(U);if(R==null)return!0;R.transformByState({left:f,top:p,width:_,height:w,angle:C,flipX:P,flipY:I,skewX:E,skewY:j})})}))}_drawingRefreshListener(){this.disposeWithMe(this._drawingManagerService.refreshTransform$.subscribe(t=>{t.forEach(n=>{const{unitId:e,subUnitId:r,drawingId:s}=n,i=this._getSceneAndTransformerByDrawingSearch(e);if(i==null)return;const o=this._drawingManagerService.getDrawingByParam(n);if(o==null)return;const{transform:c}=o,{scene:g}=i,m=M.getDrawingShapeKeyByDrawingSearch({unitId:e,subUnitId:r,drawingId:s}),d=g.getObject(m);if(d==null||c==null)return!0;const{left:f=0,top:p=0,width:_=0,height:w=0,angle:C=0,flipX:P=!1,flipY:I=!1,skewX:E=0,skewY:j=0}=c;d.transformByState({left:f,top:p,width:_,height:w,angle:C,flipX:P,flipY:I,skewX:E,skewY:j})})}))}_drawingVisibleListener(){this.disposeWithMe(this._drawingManagerService.visible$.subscribe(t=>{t.forEach(n=>{const{unitId:e,subUnitId:r,drawingId:s,visible:i}=n,o=this._getSceneAndTransformerByDrawingSearch(e);if(o==null)return;const{scene:c}=o,g=M.getDrawingShapeKeyByDrawingSearch({unitId:e,subUnitId:r,drawingId:s}),m=c.getObject(g);if(m==null)return!0;i?m.show():m.hide()})}))}_filterUpdateParams(t,n){return t.filter((e,r)=>{if(e==null)return!1;const{transform:s}=e;return h.checkIfMove(s,n==null?void 0:n[r])})}_addListenerOnDrawing(t){const n=t.getTransformerByCreate();let e=null;this.disposeWithMe(h.toDisposable(n.changeStart$.subscribe(r=>{const{objects:s}=r,i=Array.from(s.values()),o=[];e=i.map(c=>{const{left:g,top:m,height:d,width:f,angle:p,oKey:_,isInGroup:w}=c,C=this._drawingManagerService.getDrawingOKey(_);if(w||c instanceof b.Group){let P=c.ancestorGroup;if(P==null&&c instanceof b.Group&&(P=c),P==null)return null;const I=this._drawingManagerService.getDrawingOKey(P.oKey);if(I){const{unitId:E,subUnitId:j,drawingId:U}=I;o.push({unitId:E,subUnitId:j,drawingId:U});const{left:R,top:O,height:D,width:T,angle:A}=P;return{left:R,top:O,height:D,width:T,angle:A}}}else if(C!=null){const{unitId:P,subUnitId:I,drawingId:E}=C;return o.push({unitId:P,subUnitId:I,drawingId:E}),{left:g,top:m,height:d,width:f,angle:p}}return null}).filter(c=>c!=null),o.length>0?this._drawingManagerService.focusDrawing(o):this._drawingManagerService.focusDrawing(null)}))),this.disposeWithMe(h.toDisposable(n.changeEnd$.subscribe(r=>{const{objects:s}=r,i=this._filterUpdateParams(me(s,this._drawingManagerService),e);i.length>0&&this._drawingManagerService.featurePluginUpdateNotification(i)})))}};be=Bn([Ie(0,h.IUniverInstanceService),Ie(1,h.ICommandService),Ie(2,b.IRenderManagerService),Ie(3,M.IDrawingManagerService)],be);class he extends b.Shape{constructor(n,e){e==null&&(e={}),e.transformerConfig={keepRatio:!1,isCropper:!0,anchorFill:"rgb(0, 0, 0)",anchorStroke:"rgb(255, 255, 255)",anchorSize:24};super(n,e);q(this,"_srcRect");q(this,"_prstGeom");q(this,"_applyTransform");q(this,"_dragPadding",8);q(this,"_cacheCanvas");e!=null&&e.srcRect&&(this._srcRect=e.srcRect),e!=null&&e.prstGeom&&(this._prstGeom=e.prstGeom),e!=null&&e.applyTransform&&(this._applyTransform=e.applyTransform),e!=null&&e.dragPadding&&(this._dragPadding=e.dragPadding),this._applyProps()}refreshSrcRect(n,e){this._srcRect=n,this._applyTransform=e,this._applyProps()}get srcRect(){return this._srcRect}dispose(){var n;super.dispose(),(n=this._cacheCanvas)==null||n.dispose(),this._srcRect=null}isHit(n){const e=this.getInverseCoord(n);return e.x>=-this.strokeWidth/2&&e.x<=this.width+this.strokeWidth/2&&e.y>=-this.strokeWidth/2&&e.y<=this.height+this.strokeWidth/2&&!this._inSurround(e)}_inSurround(n){const e=this._dragPadding;return n.x>=e-this.strokeWidth/2&&n.x<=this.width+this.strokeWidth/2-e&&n.y>=e-this.strokeWidth/2&&n.y<=this.height+this.strokeWidth/2-e}render(n,e){return this.visible?(n.save(),this._draw(n),n.restore(),this.makeDirty(!1),this):(this.makeDirty(!1),this)}_draw(n){var c,g;const r=this.getScene().getEngine(),{width:s,height:i}=r;this._initialCacheCanvas(),(c=this._cacheCanvas)==null||c.clear();const o=(g=this._cacheCanvas)==null?void 0:g.getContext();o!=null&&(o.save(),b.Rect.drawWith(o,{left:0,top:0,width:s,height:i,fill:"rgba(0, 0, 0, 0.5)"}),o.setTransform(n.getTransform()),this._clipForApplyObject(o),this._applyCache(n),o.restore())}_clipForApplyObject(n){let e=0;if(this._prstGeom!=null&&(e=1),n.globalCompositeOperation="destination-out",n.beginPath(),e===0){const r=this.transform.getMatrix();n.transform(r[0],r[1],r[2],r[3],r[4],r[5]),n.rect(0,0,this.width,this.height),n.fill()}}_applyProps(){if(this._applyTransform==null)return;let n=0,e=0,r=0,s=0;const{left:i=0,top:o=0,width:c=0,height:g=0,angle:m}=this._applyTransform;if(this._srcRect!=null){const{left:p=0,top:_=0,right:w=0,bottom:C=0}=this._srcRect;n=p,e=_,r=w,s=C}const d=i+n,f=o+e;this.transformByState({left:d,top:f,width:i+c-r-d,height:o+g-s-f,angle:m})}_applyCache(n){if(!n||this._cacheCanvas==null)return;const e=this._cacheCanvas.getContext();e.save(),n.save(),n.setTransform(1,0,0,1,0,0),e.setTransform(1,0,0,1,0,0),n.drawImage(this._cacheCanvas.getCanvasEle(),0,0),n.restore(),e.restore()}_initialCacheCanvas(){if(this._cacheCanvas!=null)return;const n=this.getScene();if(n==null)return;this._cacheCanvas=new b.Canvas;const e=n.getEngine();this._cacheCanvas.setSize(e.width,e.height),e.onTransformChange$.subscribeEvent(()=>{var r;(r=this._cacheCanvas)==null||r.setSize(e.width,e.height),this.makeDirty(!0)})}}var Un=Object.defineProperty,An=Object.getOwnPropertyDescriptor,Ln=(a,t,n,e)=>{for(var r=e>1?void 0:e?An(t,n):t,s=a.length-1,i;s>=0;s--)(i=a[s])&&(r=(e?i(t,n,r):i(r))||r);return e&&r&&Un(t,n,r),r},oe=(a,t)=>(n,e)=>t(n,e,a);let ye=class extends h.Disposable{constructor(t,n,e,r,s,i){super();q(this,"_sceneListenerOnImageMap",new WeakSet);this._commandService=t,this._drawingManagerService=n,this._renderManagerService=e,this._univerInstanceService=r,this._messageService=s,this._localeService=i,this._init()}_init(){this._initOpenCrop(),this._initCloseCrop(),this._initAutoCrop()}_initAutoCrop(){this.disposeWithMe(this._commandService.onCommandExecuted(t=>{if(t.id!==ue.id)return;const n=t.params;if(n==null)return;const{cropType:e}=n,r=this._drawingManagerService.getFocusDrawings();if(r.length!==1)return;const s=r[0],{unitId:i,subUnitId:o,drawingId:c}=s,g=this._renderManagerService.getRenderById(i),m=g==null?void 0:g.scene;if(m==null)return!0;this._searchCropObject(m)!=null&&this._commandService.syncExecuteCommand(ee.id,{isAuto:!0});const f=M.getDrawingShapeKeyByDrawingSearch({unitId:i,subUnitId:o,drawingId:c}),p=m.getObject(f);if(!(p instanceof b.Image)){this._messageService.show({type:k.MessageType.Error,content:this._localeService.t("image-cropper.error")});return}p!=null&&(this._updateCropperObject(e,p),this._commandService.executeCommand(Se.id,{unitId:i,subUnitId:o,drawingId:c}))}))}_calculateSrcRectByRatio(t,n,e,r,s,i){const o=e/r,c=s/i;let g=e,m=r;o>c?g=r*c:m=e/c;const d=(e-g)/2,f=(r-m)/2;return{left:b.precisionTo(d,1),top:b.precisionTo(f,1),right:b.precisionTo(e-(d+g),1),bottom:b.precisionTo(r-(f+m),1)}}_updateCropperObject(t,n){const{left:e,top:r,width:s,height:i}=n.calculateTransformWithSrcRect();let o;switch(t){case H.R1_1:o=this._calculateSrcRectByRatio(e,r,s,i,1,1);break;case H.R16_9:o=this._calculateSrcRectByRatio(e,r,s,i,16,9);break;case H.R9_16:o=this._calculateSrcRectByRatio(e,r,s,i,9,16);break;case H.R5_4:o=this._calculateSrcRectByRatio(e,r,s,i,5,4);break;case H.R4_5:o=this._calculateSrcRectByRatio(e,r,s,i,4,5);break;case H.R4_3:o=this._calculateSrcRectByRatio(e,r,s,i,4,3);break;case H.R3_4:o=this._calculateSrcRectByRatio(e,r,s,i,3,4);break;case H.R3_2:o=this._calculateSrcRectByRatio(e,r,s,i,3,2);break;case H.R2_3:o=this._calculateSrcRectByRatio(e,r,s,i,2,3);break;case H.FREE:}if(o==null)return;n.setSrcRect(o);const{left:c=0,top:g=0,bottom:m=0,right:d=0}=o;n.transformByStateCloseCropper({left:e+c,top:r+g,width:s-d-c,height:i-m-g})}_initOpenCrop(){this.disposeWithMe(this._commandService.onCommandExecuted(t=>{if(t.id!==Se.id)return;const n=t.params;if(n==null)return;const{unitId:e,subUnitId:r,drawingId:s}=n,i=this._renderManagerService.getRenderById(e),o=i==null?void 0:i.scene;if(o==null)return!0;if(this._sceneListenerOnImageMap.has(o)||(this._addListenerOnImage(o),this._sceneListenerOnImageMap.add(o)),this._drawingManagerService.getDrawingByParam({unitId:e,subUnitId:r,drawingId:s})==null)return;const g=M.getDrawingShapeKeyByDrawingSearch({unitId:e,subUnitId:r,drawingId:s}),m=o.getObject(g);if(m==null)return;if(!(m instanceof b.Image)){this._messageService.show({type:k.MessageType.Error,content:this._localeService.t("image-cropper.error")});return}const d=o.getTransformer();d==null||d.clearControls();const f=new he(`${g}-crop`,{srcRect:m.srcRect,prstGeom:m.prstGeom,applyTransform:m.calculateTransformWithSrcRect()});o.addObject(f,m.getLayerIndex()+1).attachTransformerTo(f),d==null||d.createControlForCopper(f),this._addHoverForImageCopper(f),m.openRenderByCropper(),d==null||d.refreshControls(),f.makeDirty(!0),this._drawingManagerService.focusDrawing([{unitId:e,subUnitId:r,drawingId:s}])}))}_searchCropObject(t){const n=t.getAllObjectsByOrder();for(const e of n)if(e instanceof he)return e}_initCloseCrop(){this.disposeWithMe(this._commandService.onCommandExecuted(n=>{if(n.id!==ee.id)return;const e=this._univerInstanceService.getFocusedUnit();if(e==null)return;const r=e.getUnitId(),s=this._renderManagerService.getRenderById(r),i=s==null?void 0:s.scene;if(i==null)return!0;const o=this._searchCropObject(i);if(o==null)return;const c=this._getApplyObjectByCropObject(o);if(c==null)return;const g=i.getTransformerByCreate();g.detachFrom(o),g.clearCopperControl();const m=this._getSrcRectByTransformState(c,o),d=this._drawingManagerService.getDrawingOKey(c.oKey);if(d!=null){const{left:f,top:p,height:_,width:w}=o;this._drawingManagerService.featurePluginUpdateNotification([{...d,transform:{...d.transform,left:f,top:p,height:_,width:w},srcRect:m.srcRectAngle}])}c.setSrcRect({...m.srcRectAngle}),c.closeRenderByCropper(),c.makeDirty(!0),o==null||o.dispose()}));const t=this._univerInstanceService.getCurrentTypeOfUnit$(h.UniverInstanceType.UNIVER_SHEET).pipe(xe.filter(n=>!!n),xe.switchMap(n=>n.activeSheet$));this.disposeWithMe(t.subscribe(()=>{this._commandService.syncExecuteCommand(ee.id)}))}_getApplyObjectByCropObject(t){const n=t.oKey,e=n.slice(0,n.length-5),r=t.getScene();if(!r)return null;const s=r.getObject(e);return s==null?null:s}_addListenerOnImage(t){const n=t.getTransformerByCreate();let e=null;this.disposeWithMe(n.changeStart$.subscribe(r=>{const{objects:s}=r,i=s.values().next().value;if(i==null||!(i instanceof he))return;const{left:o,top:c,height:g,width:m,angle:d}=i;e={left:o,top:c,height:g,width:m,angle:d},n.clearCopperControl()})),this.disposeWithMe(n.changeEnd$.subscribe(r=>{const{objects:s}=r,i=s.values().next().value;if(i==null||!(i instanceof he))return;const{left:o,top:c,height:g,width:m,angle:d}=i;if(!h.checkIfMove({left:o,top:c,height:g,width:m,angle:d},e))return;const f=this._getApplyObjectByCropObject(i);if(f==null)return;const p=this._getSrcRectByTransformState(f,i);i.refreshSrcRect(p.srcRect,f.getState()),n.createControlForCopper(i)})),this._endCropListener(t)}_addHoverForImageCopper(t){this.disposeWithMe(t.onPointerEnter$.subscribeEvent(()=>{t.cursor=b.CURSOR_TYPE.MOVE})),this.disposeWithMe(t.onPointerLeave$.subscribeEvent(()=>{t.cursor=b.CURSOR_TYPE.DEFAULT}))}_endCropListener(t){const n=t.getTransformerByCreate();this.disposeWithMe(n.clearControl$.subscribe(e=>{e===!0&&this._commandService.syncExecuteCommand(ee.id)}))}_getSrcRectByTransformState(t,n){const{left:e,top:r,height:s,width:i,strokeWidth:o,angle:c}=n,{left:g,top:m,width:d,height:f,angle:p,strokeWidth:_}=t,w=e-g,C=r-m,P={left:w,top:C,right:d-w-i,bottom:f-C-s},I={...P};if(p!==0){const E=e+i/2,j=r+s/2,U=new b.Vector2(E,j),R=d/2+g,O=f/2+m,D=new b.Vector2(R,O),T=new b.Vector2(g,m);T.rotateByPoint(b.degToRad(p),D);const A=T.clone();A.rotateByPoint(b.degToRad(-p),U);const V=e-A.x,L=r-A.y;I.left=V,I.top=L,I.right=d-V-i,I.bottom=f-L-s}return{srcRect:P,srcRectAngle:I}}};ye=Ln([oe(0,h.ICommandService),oe(1,M.IDrawingManagerService),oe(2,b.IRenderManagerService),oe(3,h.IUniverInstanceService),oe(4,Ce.IMessageService),oe(5,h.Inject(h.LocaleService))],ye);var Hn=Object.defineProperty,Gn=Object.getOwnPropertyDescriptor,Vn=(a,t,n,e)=>{for(var r=e>1?void 0:e?Gn(t,n):t,s=a.length-1,i;s>=0;s--)(i=a[s])&&(r=(e?i(t,n,r):i(r))||r);return e&&r&&Hn(t,n,r),r},te=(a,t)=>(n,e)=>t(n,e,a);let Pe=class extends h.Disposable{constructor(a,t,n,e,r,s,i){super(),this._commandService=a,this._renderManagerService=t,this._drawingManagerService=n,this._dialogService=e,this._imageIoService=r,this._currentUniverService=s,this._drawingRenderService=i,this._initialize()}dispose(){super.dispose()}_initialize(){this._drawingAddListener(),this._commandExecutedListener(),this._imageUpdateListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.onCommandExecuted(a=>{if(a.id===Re.id){const t=a.params;if(t==null)return;this._resetImageSize(t)}}))}_getSceneAndTransformerByDrawingSearch(a){if(a==null)return;const t=this._renderManagerService.getRenderById(a),n=t==null?void 0:t.scene;if(n==null)return null;const e=n.getTransformerByCreate();return{scene:n,transformer:e}}_resetImageSize(a){const t=[],n=[];a.forEach(e=>{const{unitId:r,subUnitId:s,drawingId:i}=e,o=this._getSceneAndTransformerByDrawingSearch(r);if(o==null)return;const{scene:c}=o,g=M.getDrawingShapeKeyByDrawingSearch({unitId:r,subUnitId:s,drawingId:i}),m=c.getObject(g);if(m==null)return!0;const d=this._drawingManagerService.getDrawingByParam(e);if(d==null)return!0;if(d.drawingType!==h.DrawingTypeEnum.DRAWING_IMAGE)return;m.resetSize();const{width:f,height:p}=m.getNativeSize();n.includes(c)===!1&&n.push(c),t.push({...d,transform:{...d.transform,height:p,width:f,angle:0},srcRect:null,prstGeom:null})}),this._drawingManagerService.featurePluginUpdateNotification(t),n.forEach(e=>{e.getTransformerByCreate().refreshControls().changeNotification()}),this._drawingManagerService.focusDrawing(a)}_drawingAddListener(){this.disposeWithMe(this._drawingManagerService.add$.subscribe(a=>{this._insertImages(a)}))}_insertImages(a){a.forEach(async t=>{var g;const{unitId:n,subUnitId:e,drawingId:r}=t,s=this._getSceneAndTransformerByDrawingSearch(n),i=(g=Ne(this._currentUniverService,n))==null?void 0:g.subUnitId;if(s==null||i!==e)return;const o=this._drawingManagerService.getDrawingByParam(t);if(o==null)return;const c=await this._drawingRenderService.renderImages(o,s.scene);if(!(c==null||c.length===0))for(const m of c)this._addHoverForImage(m),this._addDialogForImage(m)})}_imageUpdateListener(){this.disposeWithMe(this._drawingManagerService.update$.subscribe(a=>{a.forEach(t=>{const{unitId:n,subUnitId:e,drawingId:r}=t,s=this._drawingManagerService.getDrawingByParam(t);if(s==null)return;const{transform:i,drawingType:o,srcRect:c,prstGeom:g,source:m,imageSourceType:d}=s;if(o!==h.DrawingTypeEnum.DRAWING_IMAGE)return;const f=this._getSceneAndTransformerByDrawingSearch(n);if(f==null)return;const{scene:p,transformer:_}=f;if(i==null)return!0;const w=M.getDrawingShapeKeyByDrawingSearch({unitId:n,subUnitId:e,drawingId:r}),C=p.getObject(w);if(C==null)return!0;C.setSrcRect(c),C.setPrstGeom(g)})}))}_addHoverForImage(a){this.disposeWithMe(h.toDisposable(a.onPointerEnter$.subscribeEvent(()=>{a.cursor=b.CURSOR_TYPE.GRAB}))),this.disposeWithMe(h.toDisposable(a.onPointerLeave$.subscribeEvent(()=>{a.cursor=b.CURSOR_TYPE.DEFAULT})))}_addDialogForImage(a){this.disposeWithMe(h.toDisposable(a.onDblclick$.subscribeEvent(()=>{const t=`${a.oKey}-viewer-dialog`;this._drawingRenderService.previewImage(t,a.getNative().src,a.getNativeSize().width,a.getNativeSize().height)})))}};Pe=Vn([te(0,h.ICommandService),te(1,b.IRenderManagerService),te(2,M.IDrawingManagerService),te(3,Ce.IDialogService),te(4,M.IImageIoService),te(5,h.IUniverInstanceService),te(6,h.Inject(y.DrawingRenderService))],Pe);var Wn=Object.defineProperty,kn=Object.getOwnPropertyDescriptor,zn=(a,t,n,e)=>{for(var r=e>1?void 0:e?kn(t,n):t,s=a.length-1,i;s>=0;s--)(i=a[s])&&(r=(e?i(t,n,r):i(r))||r);return e&&r&&Wn(t,n,r),r},Qe=(a,t)=>(n,e)=>t(n,e,a);const Kn="UNIVER_DRAWING_UI_PLUGIN";y.UniverDrawingUIPlugin=(De=class extends h.Plugin{constructor(t=Rn,n,e){super(),this._config=t,this._injector=n,this._configService=e;const{menu:r,...s}=this._config;r&&this._configService.setConfig("menu",r,{merge:!0}),this._configService.setConfig(Mn,s)}onStarting(){this._initDependencies()}onRendered(){this._injector.get(be),this._injector.get(_e),this._injector.get(ye),this._injector.get(Pe)}_initDependencies(){[[y.DrawingRenderService],[be],[_e],[ye],[Pe]].forEach(n=>this._injector.add(n))}},q(De,"pluginName",Kn),De),y.UniverDrawingUIPlugin=zn([Qe(1,h.Inject(h.Injector)),Qe(2,h.IConfigService)],y.UniverDrawingUIPlugin),y.AutoImageCropOperation=ue,y.COMPONENT_IMAGE_POPUP_MENU=Xe,y.CloseImageCropOperation=ee,y.DrawingCommonPanel=jn,y.ImageCropperObject=he,y.ImagePopupMenu=Ze,y.ImageResetSizeOperation=Re,y.OpenImageCropOperation=Se,y.SetDrawingAlignOperation=ve,y.getUpdateParams=me,Object.defineProperty(y,Symbol.toStringTag,{value:"Module"})});
14
+ */var Be;function an(){if(Be)return ge;Be=1;var a=S,t=Symbol.for("react.element"),n=Symbol.for("react.fragment"),e=Object.prototype.hasOwnProperty,r=a.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,s={key:!0,ref:!0,__self:!0,__source:!0};function i(o,c,g){var m,h={},f=null,p=null;g!==void 0&&(f=""+g),c.key!==void 0&&(f=""+c.key),c.ref!==void 0&&(p=c.ref);for(m in c)e.call(c,m)&&!s.hasOwnProperty(m)&&(h[m]=c[m]);if(o&&o.defaultProps)for(m in c=o.defaultProps,c)h[m]===void 0&&(h[m]=c[m]);return{$$typeof:t,type:o,key:f,ref:p,props:h,_owner:r.current}}return ge.Fragment=n,ge.jsx=i,ge.jsxs=i,ge}var Ue;function sn(){return Ue||(Ue=1,Me.exports=an()),Me.exports}var l=sn();function Ae(a){var t,n,e="";if(typeof a=="string"||typeof a=="number")e+=a;else if(typeof a=="object")if(Array.isArray(a)){var r=a.length;for(t=0;t<r;t++)a[t]&&(n=Ae(a[t]))&&(e&&(e+=" "),e+=n)}else for(n in a)a[n]&&(e&&(e+=" "),e+=n);return e}function N(){for(var a,t,n=0,e="",r=arguments.length;n<r;n++)(a=arguments[n])&&(t=Ae(a))&&(e&&(e+=" "),e+=t);return e}var x=(a=>(a.default="0",a.left="1",a.center="2",a.right="3",a.top="4",a.middle="5",a.bottom="6",a.horizon="7",a.vertical="8",a))(x||{});const ve={id:"sheet.operation.set-image-align",type:d.CommandType.OPERATION,handler:(a,t)=>!0},u={imageCommonPanel:"univer-image-common-panel",imageCommonPanelGrid:"univer-image-common-panel-grid",imageCommonPanelBorder:"univer-image-common-panel-border",imageCommonPanelTitle:"univer-image-common-panel-title",imageCommonPanelSubtitle:"univer-image-common-panel-subtitle",imageCommonPanelRow:"univer-image-common-panel-row",imageCommonPanelRowVertical:"univer-image-common-panel-row-vertical",imageCommonPanelColumn:"univer-image-common-panel-column",imageCommonPanelColumnCenter:"univer-image-common-panel-column-center",imageCommonPanelInline:"univer-image-common-panel-inline",imageCommonPanelSpan2:"univer-image-common-panel-span2",imageCommonPanelSpan3:"univer-image-common-panel-span3",imageCommonPanelInput:"univer-image-common-panel-input"},on=a=>{const t=d.useDependency(d.ICommandService),n=d.useDependency(d.LocaleService),{alignShow:e}=a,[r,s]=S.useState(x.default),i=[{label:n.t("image-panel.align.default"),value:x.default},{options:[{label:n.t("image-panel.align.left"),value:x.left},{label:n.t("image-panel.align.center"),value:x.center},{label:n.t("image-panel.align.right"),value:x.right}]},{options:[{label:n.t("image-panel.align.top"),value:x.top},{label:n.t("image-panel.align.middle"),value:x.middle},{label:n.t("image-panel.align.bottom"),value:x.bottom}]},{options:[{label:n.t("image-panel.align.horizon"),value:x.horizon},{label:n.t("image-panel.align.vertical"),value:x.vertical}]}];function o(g){s(g),t.executeCommand(ve.id,{alignType:g})}const c=g=>g?"block":"none";return l.jsxs("div",{className:N(u.imageCommonPanelGrid,u.imageCommonPanelBorder),style:{display:c(e)},children:[l.jsx("div",{className:u.imageCommonPanelRow,children:l.jsx("div",{className:N(u.imageCommonPanelColumn,u.imageCommonPanelTitle),children:l.jsx("div",{children:n.t("image-panel.align.title")})})}),l.jsx("div",{className:u.imageCommonPanelRow,children:l.jsx("div",{className:N(u.imageCommonPanelColumn),children:l.jsx(k.Select,{value:r,options:i,onChange:o})})})]})};var F=function(){return F=Object.assign||function(a){for(var t,n=1,e=arguments.length;n<e;n++){t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(a[r]=t[r])}return a},F.apply(this,arguments)},cn=function(a,t){var n={};for(var e in a)Object.prototype.hasOwnProperty.call(a,e)&&t.indexOf(e)<0&&(n[e]=a[e]);if(a!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,e=Object.getOwnPropertySymbols(a);r<e.length;r++)t.indexOf(e[r])<0&&Object.prototype.propertyIsEnumerable.call(a,e[r])&&(n[e[r]]=a[e[r]]);return n},X=S.forwardRef(function(a,t){var n=a.icon,e=a.id,r=a.className,s=a.extend,i=cn(a,["icon","id","className","extend"]),o="univerjs-icon univerjs-icon-".concat(e," ").concat(r||"").trim(),c=S.useRef("_".concat(gn()));return Le(n,"".concat(e),{defIds:n.defIds,idSuffix:c.current},F({ref:t,className:o},i),s)});function Le(a,t,n,e,r){return S.createElement(a.tag,F(F({key:t},ln(a,n,r)),e),(mn(a,n).children||[]).map(function(s,i){return Le(s,"".concat(t,"-").concat(a.tag,"-").concat(i),n,void 0,r)}))}function ln(a,t,n){var e=F({},a.attrs);n!=null&&n.colorChannel1&&e.fill==="colorChannel1"&&(e.fill=n.colorChannel1);var r=t.defIds;return!r||r.length===0||(a.tag==="use"&&e["xlink:href"]&&(e["xlink:href"]=e["xlink:href"]+t.idSuffix),Object.entries(e).forEach(function(s){var i=s[0],o=s[1];typeof o=="string"&&(e[i]=o.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))})),e}function mn(a,t){var n,e=t.defIds;return!e||e.length===0?a:a.tag==="defs"&&(!((n=a.children)===null||n===void 0)&&n.length)?F(F({},a),{children:a.children.map(function(r){return typeof r.attrs.id=="string"&&e&&e.indexOf(r.attrs.id)>-1?F(F({},r),{attrs:F(F({},r.attrs),{id:r.attrs.id+t.idSuffix})}):r})}):a}function gn(){return Math.random().toString(36).substring(2,8)}X.displayName="UniverIcon";var un={tag:"svg",attrs:{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.56377zM2.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.83647zM9.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"}}]},He=S.forwardRef(function(a,t){return S.createElement(X,Object.assign({},a,{id:"autofill",ref:t,icon:un}))});He.displayName="Autofill";var dn={tag:"svg",attrs:{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.8334 15.6045 1.94974 14.8881 1.2334 14.0045 1.2334H3.70449C2.82084 1.2334 2.10449 1.94974 2.10449 2.8334 2.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.8334 3.30449 2.61248 3.48358 2.4334 3.70449 2.4334H14.0045C14.2254 2.4334 14.4045 2.61249 14.4045 2.8334zM14.1544 8.5999C15.038 8.5999 15.7544 7.88356 15.7544 6.9999 15.7544 6.11625 15.038 5.3999 14.1544 5.3999H3.85439C2.97074 5.3999 2.25439 6.11625 2.25439 6.9999 2.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.9999 3.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.7421 6.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.56641 9.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.7421 11.6631 11.9765 11.6631 12.3564 11.4288 12.5907L9.42923 14.5902M8.57975 14.5902C8.58121 14.5917 8.58268 14.5931 8.58416 14.5946 8.64077 14.6502 8.70566 14.6923 8.77482 14.7209 8.84557 14.7502 8.92314 14.7664 9.00449 14.7664 9.08585 14.7664 9.16342 14.7502 9.23416 14.7209 9.30332 14.6923 9.36821 14.6502 9.42482 14.5946"}}]},Ge=S.forwardRef(function(a,t){return S.createElement(X,Object.assign({},a,{id:"bottom-single",ref:t,icon:dn}))});Ge.displayName="BottomSingle";var hn={tag:"svg",attrs:{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.51296 9.08632 7.84433 8.81769 8.11296 8.48632 8.11296H6.57705C6.24568 8.11296 5.97705 7.84433 5.97705 7.51296zM6.57705 9.41028C6.24568 9.41028 5.97705 9.67891 5.97705 10.0103 5.97705 10.3416 6.24568 10.6103 6.57705 10.6103H10.8199C11.1512 10.6103 11.4199 10.3416 11.4199 10.0103 11.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"}}]},Ve=S.forwardRef(function(a,t){return S.createElement(X,Object.assign({},a,{id:"create-copy-single",ref:t,icon:hn}))});Ve.displayName="CreateCopySingle";var fn={tag:"svg",attrs:{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"}}]},We=S.forwardRef(function(a,t){return S.createElement(X,Object.assign({},a,{id:"group-single",ref:t,icon:fn}))});We.displayName="GroupSingle";var pn={tag:"svg",attrs:{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"}}]},ke=S.forwardRef(function(a,t){return S.createElement(X,Object.assign({},a,{id:"more-down-single",ref:t,icon:pn}))});ke.displayName="MoreDownSingle";var Cn={tag:"svg",attrs:{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"}}]},ze=S.forwardRef(function(a,t){return S.createElement(X,Object.assign({},a,{id:"move-down-single",ref:t,icon:Cn}))});ze.displayName="MoveDownSingle";var vn={tag:"svg",attrs:{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"}}]},Ke=S.forwardRef(function(a,t){return S.createElement(X,Object.assign({},a,{id:"move-up-single",ref:t,icon:vn}))});Ke.displayName="MoveUpSingle";var wn={tag:"svg",attrs:{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 9 15.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 9 2.70439 9.22091 2.88348 9.4 3.1044 9.4H13.4044C13.6253 9.4 13.8044 9.22091 13.8044 9 13.8044 8.77909 13.6253 8.6 13.4044 8.6H3.10439zM1.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.1665 15.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.1665 2.8543 13.3874 3.03338 13.5665 3.2543 13.5665H13.5543C13.7752 13.5665 13.9543 13.3874 13.9543 13.1665 13.9543 12.9456 13.7752 12.7665 13.5543 12.7665H3.2543z",fillRule:"evenodd",clipRule:"evenodd"}}]},Fe=S.forwardRef(function(a,t){return S.createElement(X,Object.assign({},a,{id:"topmost-single",ref:t,icon:wn}))});Fe.displayName="TopmostSingle";var Sn={tag:"svg",attrs:{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"}}]},Ye=S.forwardRef(function(a,t){return S.createElement(X,Object.assign({},a,{id:"ungroup-single",ref:t,icon:Sn}))});Ye.displayName="UngroupSingle";const _n=a=>{const{arrangeShow:t,drawings:n}=a,e=d.useDependency(d.LocaleService),r=d.useDependency(M.IDrawingManagerService),s=g=>g?"block":"none",[i,o]=S.useState(n);S.useEffect(()=>{const g=r.focus$.subscribe(m=>{o(m)});return()=>{g.unsubscribe()}},[]);const c=g=>{const m=i[0].unitId,h=i[0].subUnitId,f=i.map(p=>p.drawingId);r.featurePluginOrderUpdateNotification({unitId:m,subUnitId:h,drawingIds:f,arrangeType:g})};return l.jsxs("div",{className:u.imageCommonPanelGrid,style:{display:s(t)},children:[l.jsx("div",{className:u.imageCommonPanelRow,children:l.jsx("div",{className:N(u.imageCommonPanelColumn,u.imageCommonPanelTitle),children:l.jsx("div",{children:e.t("image-panel.arrange.title")})})}),l.jsxs("div",{className:u.imageCommonPanelRow,children:[l.jsx("div",{className:N(u.imageCommonPanelColumn,u.imageCommonPanelSpan2),children:l.jsx(k.Button,{size:"small",onClick:()=>{c(d.ArrangeTypeEnum.forward)},children:l.jsxs("span",{className:u.imageCommonPanelInline,children:[l.jsx(Ke,{}),e.t("image-panel.arrange.forward")]})})}),l.jsx("div",{className:N(u.imageCommonPanelColumn,u.imageCommonPanelSpan2),children:l.jsx(k.Button,{size:"small",onClick:()=>{c(d.ArrangeTypeEnum.backward)},children:l.jsxs("span",{className:u.imageCommonPanelInline,children:[l.jsx(ze,{}),e.t("image-panel.arrange.backward")]})})})]}),l.jsxs("div",{className:u.imageCommonPanelRow,children:[l.jsx("div",{className:N(u.imageCommonPanelColumn,u.imageCommonPanelSpan2),children:l.jsx(k.Button,{size:"small",onClick:()=>{c(d.ArrangeTypeEnum.front)},children:l.jsxs("span",{className:u.imageCommonPanelInline,children:[l.jsx(Fe,{}),e.t("image-panel.arrange.front")]})})}),l.jsx("div",{className:N(u.imageCommonPanelColumn,u.imageCommonPanelSpan2),children:l.jsx(k.Button,{size:"small",onClick:()=>{c(d.ArrangeTypeEnum.back)},children:l.jsxs("span",{className:u.imageCommonPanelInline,children:[l.jsx(Ge,{}),e.t("image-panel.arrange.back")]})})})]})]})},In=a=>{const t=d.useDependency(d.LocaleService),n=d.useDependency(b.IRenderManagerService),e=d.useDependency(M.IDrawingManagerService),{hasGroup:r,drawings:s}=a,[i,o]=S.useState(!1),[c,g]=S.useState(!0),[m,h]=S.useState(!0),f=C=>C?"block":"none",p=()=>{const C=e.getFocusDrawings(),{unitId:P,subUnitId:I}=C[0],E=d.Tools.generateRandomId(10),j=b.getGroupState(0,0,C.map(O=>O.transform||{})),U={unitId:P,subUnitId:I,drawingId:E,drawingType:d.DrawingTypeEnum.DRAWING_GROUP,transform:j},R=C.map(O=>{const D=O.transform||{left:0,top:0},{unitId:T,subUnitId:A,drawingId:V}=O;return{unitId:T,subUnitId:A,drawingId:V,transform:{...D,left:D.left-j.left,top:D.top-j.top},groupId:E}});e.featurePluginGroupUpdateNotification([{parent:U,children:R}])},_=C=>{if(C.drawingType!==d.DrawingTypeEnum.DRAWING_GROUP)return;const{unitId:P,subUnitId:I,drawingId:E,transform:j={width:0,height:0}}=C;if(j==null)return;const U=e.getDrawingsByGroup({unitId:P,subUnitId:I,drawingId:E});if(U.length===0)return;const R=U.map(O=>{const{transform:D}=O,{unitId:T,subUnitId:A,drawingId:V}=O,L=b.transformObjectOutOfGroup(D||{},j,j.width||0,j.height||0);return{unitId:T,subUnitId:A,drawingId:V,transform:{...D,...L},groupId:void 0}});return{parent:C,children:R}},w=()=>{const P=e.getFocusDrawings().map(I=>_(I)).filter(I=>I!=null);P.length!==0&&e.featurePluginUngroupUpdateNotification(P)};return S.useEffect(()=>{const C=s[0];if(C==null)return;const{unitId:P}=C,I=n.getRenderById(P),E=I==null?void 0:I.scene;if(E==null)return;const j=E.getTransformerByCreate(),U=j.clearControl$.subscribe(O=>{O===!0&&o(!1)}),R=j.changeStart$.subscribe(O=>{const{objects:D}=O,T=me(D,e),A=T.filter(K=>(K==null?void 0:K.drawingType)===d.DrawingTypeEnum.DRAWING_GROUP);let V=!1,L=!1;T.length>1&&(V=!0),A.length>0&&(L=!0),o(V||L),g(V),h(L)});return()=>{R.unsubscribe(),U.unsubscribe()}},[]),l.jsxs("div",{className:N(u.imageCommonPanelGrid,u.imageCommonPanelBorder),style:{display:f(r===!0?i:!1)},children:[l.jsx("div",{className:u.imageCommonPanelRow,children:l.jsx("div",{className:N(u.imageCommonPanelColumn,u.imageCommonPanelTitle),children:l.jsx("div",{children:t.t("image-panel.group.title")})})}),l.jsxs("div",{className:u.imageCommonPanelRow,children:[l.jsx("div",{className:N(u.imageCommonPanelColumn,u.imageCommonPanelSpan2,u.imageCommonPanelColumnCenter),children:l.jsx(k.Button,{size:"small",onClick:()=>{p()},style:{display:f(c)},children:l.jsxs("span",{className:u.imageCommonPanelInline,children:[l.jsx(We,{}),t.t("image-panel.group.group")]})})}),l.jsx("div",{className:N(u.imageCommonPanelColumn,u.imageCommonPanelSpan2,u.imageCommonPanelColumnCenter),children:l.jsx(k.Button,{size:"small",onClick:()=>{w()},style:{display:f(m)},children:l.jsxs("span",{className:u.imageCommonPanelInline,children:[l.jsx(Ye,{}),t.t("image-panel.group.unGroup")]})})})]})]})},ne=20,bn=20,yn=[-3600,3600],we=300,Pn=a=>{var qe;const t=d.useDependency(d.LocaleService),n=d.useDependency(M.IDrawingManagerService),e=d.useDependency(b.IRenderManagerService),{drawings:r,transformShow:s}=a,i=r[0];if(i==null)return;const o=i.transform;if(o==null)return;const{unitId:c,subUnitId:g,drawingId:m,drawingType:h}=i,f=e.getRenderById(c),p=f==null?void 0:f.scene;if(p==null)return;const _=(qe=p.getEngine())==null?void 0:qe.activeScene;if(_==null)return;const w=p.getTransformerByCreate(),{width:C=0,height:P=0,left:I=0,top:E=0,angle:j=0}=o,[U,R]=S.useState(C),[O,D]=S.useState(P),[T,A]=S.useState(I),[V,L]=S.useState(E),[re,K]=S.useState(j),[ce,ae]=S.useState(w.keepRatio),ie=(v,B,W,z)=>{const{width:G,height:$}=_,{ancestorLeft:Y,ancestorTop:Z}=p;let J=v,se=B,fe=W,pe=z;return v+Y<0&&(J=-Y),B+Z<0&&(se=-Z),fe=G-J-Y,fe<ne&&(fe=ne),pe=$-se-Z,pe<ne&&(pe=ne),v+fe+Y>G&&(J=G-W-Y),B+pe+Z>$&&(se=$-z-Z),{limitLeft:J,limitTop:se,limitWidth:fe,limitHeight:pe}},le=v=>{const{objects:B}=v,W=me(B,n);if(W.length!==1)return;const z=W[0];if(z==null)return;const{transform:G}=z;if(G==null)return;const{width:$,height:Y,left:Z,top:J,angle:se}=G;$!=null&&R($),Y!=null&&D(Y),Z!=null&&A(Z),J!=null&&L(J),se!=null&&K(se)};S.useEffect(()=>{const v=[w.changeStart$.subscribe(B=>{le(B)}),w.changing$.subscribe(B=>{le(B)}),w.changeEnd$.subscribe(B=>{le(B)}),n.focus$.subscribe(B=>{if(B.length!==1)return;const W=n.getDrawingByParam(B[0]);if(W==null)return;const z=W.transform;if(z==null)return;const{width:G,height:$,left:Y,top:Z,angle:J}=z;G!=null&&R(G),$!=null&&D($),Y!=null&&A(Y),Z!=null&&L(Z),J!=null&&K(J)})];return()=>{v.forEach(B=>B.unsubscribe())}},[]);const Q=d.debounce(v=>{if(v==null)return;v=Math.max(v,ne);const{limitWidth:B,limitHeight:W}=ie(T,V,v,O);v=Math.min(v,B);const z={unitId:c,subUnitId:g,drawingId:m,drawingType:h,transform:{width:v}};if(ce){let G=v/U*O;if(G=Math.max(G,bn),G>W)return;D(G),z.transform.height=G}R(v),n.featurePluginUpdateNotification([z]),w.refreshControls().changeNotification()},we),Oe=d.debounce(v=>{if(v==null)return;v=Math.max(v,ne);const{limitHeight:B,limitWidth:W}=ie(T,V,U,v);v=Math.min(v,B);const z={unitId:c,subUnitId:g,drawingId:m,drawingType:h,transform:{height:v}};if(ce){let G=v/O*U;if(G=Math.max(G,ne),G>W)return;R(G),z.transform.width=G}D(v),n.featurePluginUpdateNotification([z]),w.refreshControls().changeNotification()},we),Fn=d.debounce(v=>{if(v==null)return;const{limitLeft:B}=ie(v,V,U,O);v=B;const W={unitId:c,subUnitId:g,drawingId:m,drawingType:h,transform:{left:v}};A(v),n.featurePluginUpdateNotification([W]),w.refreshControls().changeNotification()},we),Yn=d.debounce(v=>{if(v==null)return;const{limitTop:B}=ie(T,v,U,O);v=B;const W={unitId:c,subUnitId:g,drawingId:m,drawingType:h,transform:{top:v}};L(v),n.featurePluginUpdateNotification([W]),w.refreshControls().changeNotification()},we),Zn=v=>{if(v==null)return;const[B,W]=yn;v<B&&(v=B),v>W&&(v=W);const z={unitId:c,subUnitId:g,drawingId:m,drawingType:h,transform:{angle:v}};K(v),n.featurePluginUpdateNotification([z]),w.refreshControls().changeNotification()},Xn=v=>{ae(v),w.keepRatio=v},Jn=v=>v?"block":"none";return l.jsxs("div",{className:N(u.imageCommonPanelGrid,u.imageCommonPanelBorder),style:{display:Jn(s)},children:[l.jsx("div",{className:u.imageCommonPanelRow,children:l.jsx("div",{className:N(u.imageCommonPanelColumn,u.imageCommonPanelTitle),children:l.jsx("div",{children:t.t("image-panel.transform.title")})})}),l.jsxs("div",{className:u.imageCommonPanelRow,children:[l.jsx("div",{className:N(u.imageCommonPanelColumn,u.imageCommonPanelSpan3),children:l.jsxs("label",{children:[l.jsx("div",{className:u.imageCommonPanelRow,children:l.jsx("div",{className:u.imageCommonPanelColumn,children:t.t("image-panel.transform.width")})}),l.jsx("div",{className:u.imageCommonPanelRow,children:l.jsx("div",{className:u.imageCommonPanelColumn,children:l.jsx(k.InputNumber,{precision:1,value:U,onChange:v=>{Q(v)},className:u.imageCommonPanelInput})})})]})}),l.jsx("div",{className:N(u.imageCommonPanelColumn,u.imageCommonPanelSpan3),children:l.jsxs("label",{children:[l.jsx("div",{className:u.imageCommonPanelRow,children:l.jsx("div",{className:u.imageCommonPanelColumn,children:t.t("image-panel.transform.height")})}),l.jsx("div",{className:u.imageCommonPanelRow,children:l.jsx("div",{className:u.imageCommonPanelColumn,children:l.jsx(k.InputNumber,{precision:1,value:O,onChange:v=>{Oe(v)},className:u.imageCommonPanelInput})})})]})}),l.jsx("div",{className:N(u.imageCommonPanelColumn,u.imageCommonPanelSpan3),children:l.jsxs("label",{children:[l.jsx("div",{className:u.imageCommonPanelRow,children:l.jsx("div",{className:u.imageCommonPanelColumn,children:t.t("image-panel.transform.lock")})}),l.jsx("div",{className:N(u.imageCommonPanelRow,u.imageCommonPanelRowVertical),children:l.jsx("div",{className:u.imageCommonPanelColumn,children:l.jsx(k.Checkbox,{checked:ce,onChange:Xn})})})]})})]}),l.jsxs("div",{className:u.imageCommonPanelRow,children:[l.jsx("div",{className:N(u.imageCommonPanelColumn,u.imageCommonPanelSpan3),children:l.jsxs("label",{children:[l.jsx("div",{className:u.imageCommonPanelRow,children:l.jsx("div",{className:u.imageCommonPanelColumn,children:t.t("image-panel.transform.x")})}),l.jsx("div",{className:u.imageCommonPanelRow,children:l.jsx("div",{className:u.imageCommonPanelColumn,children:l.jsx(k.InputNumber,{precision:1,value:T,onChange:v=>{Fn(v)},className:u.imageCommonPanelInput})})})]})}),l.jsx("div",{className:N(u.imageCommonPanelColumn,u.imageCommonPanelSpan3),children:l.jsxs("label",{children:[l.jsx("div",{className:u.imageCommonPanelRow,children:l.jsx("div",{className:u.imageCommonPanelColumn,children:t.t("image-panel.transform.y")})}),l.jsx("div",{className:u.imageCommonPanelRow,children:l.jsx("div",{className:u.imageCommonPanelColumn,children:l.jsx(k.InputNumber,{precision:1,value:V,onChange:v=>{Yn(v)},className:u.imageCommonPanelInput})})})]})}),l.jsx("div",{className:N(u.imageCommonPanelColumn,u.imageCommonPanelSpan3),children:l.jsxs("label",{children:[l.jsx("div",{className:u.imageCommonPanelRow,children:l.jsx("div",{className:u.imageCommonPanelColumn,children:t.t("image-panel.transform.rotate")})}),l.jsx("div",{className:u.imageCommonPanelRow,children:l.jsx("div",{className:u.imageCommonPanelColumn,children:l.jsx(k.InputNumber,{precision:1,value:re,onChange:Zn,className:u.imageCommonPanelInput})})})]})})]})]})},Se={id:"sheet.operation.open-image-crop",type:d.CommandType.OPERATION,handler:(a,t)=>!0},ee={id:"sheet.operation.close-image-crop",type:d.CommandType.OPERATION,handler:(a,t)=>!0};var H=(a=>(a.FREE="0",a.R1_1="1",a.R16_9="2",a.R9_16="3",a.R5_4="4",a.R4_5="5",a.R4_3="6",a.R3_4="7",a.R3_2="8",a.R2_3="9",a))(H||{});const ue={id:"sheet.operation.Auto-image-crop",type:d.CommandType.OPERATION,handler:(a,t)=>!0},jn=a=>{const t=d.useDependency(d.ICommandService),n=d.useDependency(d.LocaleService),{drawings:e,cropperShow:r}=a;if(e[0]==null)return;const[i,o]=S.useState(H.FREE),c=S.useRef(!1),g=[{label:n.t("image-panel.crop.mode"),value:H.FREE},{label:"1:1",value:H.R1_1},{label:"16:9",value:H.R16_9},{label:"9:16",value:H.R9_16},{label:"5:4",value:H.R5_4},{label:"4:5",value:H.R4_5},{label:"4:3",value:H.R4_3},{label:"3:4",value:H.R3_4},{label:"3:2",value:H.R3_2},{label:"2:3",value:H.R2_3}];S.useEffect(()=>{const p=t.onCommandExecuted(_=>{if(_.id===ee.id){const w=_.params;w!=null&&w.isAuto||(c.current=!1)}});return()=>{p==null||p.dispose()}},[]);function m(p){o(p),c.current&&t.executeCommand(ue.id,{cropType:p})}const h=p=>p?"block":"none",f=p=>{t.executeCommand(ue.id,{cropType:p}),c.current=!0};return l.jsxs("div",{className:N(u.imageCommonPanelGrid,u.imageCommonPanelBorder),style:{display:h(r)},children:[l.jsx("div",{className:u.imageCommonPanelRow,children:l.jsx("div",{className:N(u.imageCommonPanelColumn,u.imageCommonPanelTitle),children:l.jsx("div",{children:n.t("image-panel.crop.title")})})}),l.jsxs("div",{className:N(u.imageCommonPanelRow,u.imageCommonPanelRowVertical),children:[l.jsx("div",{className:N(u.imageCommonPanelColumn,u.imageCommonPanelSpan2),children:l.jsx(k.Button,{size:"small",onClick:()=>{f(i)},children:l.jsxs("span",{className:u.imageCommonPanelInline,children:[l.jsx(Ve,{}),n.t("image-panel.crop.start")]})})}),l.jsx("div",{className:N(u.imageCommonPanelColumn,u.imageCommonPanelSpan2),children:l.jsx(k.Select,{value:i,options:g,onChange:m})})]})]})},Mn=a=>{const t=d.useDependency(M.IDrawingManagerService),n=d.useDependency(b.IRenderManagerService),e=d.useDependency(d.LocaleService),{drawings:r,hasArrange:s=!0,hasTransform:i=!0,hasAlign:o=!0,hasCropper:c=!0,hasGroup:g=!0}=a,m=r[0];if(m==null)return;const{unitId:h}=m,f=n.getRenderById(h),p=f==null?void 0:f.scene;if(p==null)return;const _=p.getTransformerByCreate(),[w,C]=S.useState(!0),[P,I]=S.useState(!0),[E,j]=S.useState(!1),[U,R]=S.useState(!0),[O,D]=S.useState(!1);return S.useEffect(()=>{const T=_.clearControl$.subscribe(L=>{L===!0&&(C(!1),I(!1),j(!1),R(!1),D(!0))}),A=_.changeStart$.subscribe(L=>{const{objects:re}=L,K=me(re,t);K.length===0?(C(!1),I(!1),j(!1),R(!1),D(!0)):K.length===1?(C(!0),I(!0),j(!1),R(!0),D(!1)):(C(!0),I(!1),j(!0),R(!1),D(!1))}),V=t.focus$.subscribe(L=>{L.length===0?(C(!1),I(!1),j(!1),R(!1),D(!0)):L.length===1?(C(!0),I(!0),j(!1),R(!0),D(!1)):(C(!0),I(!1),j(!0),R(!1),D(!1))});return()=>{A.unsubscribe(),T.unsubscribe(),V.unsubscribe()}},[]),l.jsxs(l.Fragment,{children:[l.jsx("div",{style:{display:O===!0?"block":"none",height:"100%"},children:l.jsx("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",height:"100%",top:"50%",marginTop:"-100px"},children:l.jsx("span",{children:e.t("image-panel.null")})})}),l.jsx(_n,{arrangeShow:s===!0?w:!1,drawings:r}),l.jsx(Pn,{transformShow:i===!0?P:!1,drawings:r}),l.jsx(on,{alignShow:o===!0?E:!1,drawings:r}),l.jsx(jn,{cropperShow:c===!0?U:!1,drawings:r}),l.jsx(In,{hasGroup:g,drawings:r})]})},de={imagePopupMenu:"univer-image-popup-menu",imagePopupMenuItem:"univer-image-popup-menu-item",imagePopupMenuItemIcon:"univer-image-popup-menu-item-icon",imagePopupMenuItemTitle:"univer-image-popup-menu-item-title",imagePopupMenuItemHide:"univer-image-popup-menu-item-hide",btnContainer:"univer-btn-container",btnContainerExpand:"univer-btn-container-expand"},Ze=a=>{var _,w;const t=(w=(_=a.popup)==null?void 0:_.extraProps)==null?void 0:w.menuItems;if(!t)return null;const n=d.useDependency(d.ICommandService),e=d.useDependency(d.LocaleService),[r,s]=S.useState(!1),[i,o]=S.useState(!1),c=()=>{o(!0)},g=()=>{o(!1)},m=C=>{s(C)},h=C=>{n.executeCommand(C.commandId,C.commandParams),s(!1)},f=r||i,p=t.filter(C=>!C.disable);return l.jsx("div",{onMouseEnter:c,onMouseLeave:g,children:l.jsx(k.DropdownLegacy,{placement:"bottomLeft",trigger:["click"],overlay:l.jsx("ul",{className:de.imagePopupMenu,children:p.map(C=>l.jsx("li",{onClick:()=>h(C),className:de.imagePopupMenuItem,children:l.jsx("span",{className:de.imagePopupMenuItemTitle,children:e.t(C.label)})},C.index))}),visible:r,onVisibleChange:m,children:l.jsxs("div",{className:N(de.btnContainer,{[de.btnContainerExpand]:r}),children:[l.jsx(He,{style:{color:"#35322B"},extend:{colorChannel1:"rgb(var(--green-700, #409f11))"}}),f&&l.jsx(ke,{style:{color:"#CCCCCC",fontSize:"8px",marginLeft:"8px"}})]})})})},Xe="COMPONENT_IMAGE_POPUP_MENU",Rn="drawing-ui.config",Je={},Re={id:"sheet.operation.image-reset-size",type:d.CommandType.OPERATION,handler:(a,t)=>!0},Dn=a=>{const{src:t}=a;return t?l.jsx("div",{children:l.jsx("img",{src:t,alt:"Univer Image Viewer",style:{width:"100%",height:"100%",position:"relative"}})}):null};var On=Object.defineProperty,xn=Object.getOwnPropertyDescriptor,Nn=(a,t,n,e)=>{for(var r=e>1?void 0:e?xn(t,n):t,s=a.length-1,i;s>=0;s--)(i=a[s])&&(r=(e?i(t,n,r):i(r))||r);return e&&r&&On(t,n,r),r},Qe=(a,t)=>(n,e)=>t(n,e,a);let _e=class extends d.Disposable{constructor(a,t){super(),this._componentManager=a,this._commandService=t,this._init()}_initCustomComponents(){const a=this._componentManager;this.disposeWithMe(a.register(Xe,Ze)),this.disposeWithMe(a.register(Ee,Dn))}_initCommands(){[Se,ee,Re,ve,ue].forEach(a=>this.disposeWithMe(this._commandService.registerCommand(a)))}_init(){this._initCommands(),this._initCustomComponents()}};_e=Nn([Qe(0,d.Inject(Ce.ComponentManager)),Qe(1,d.ICommandService)],_e);var En=Object.defineProperty,Tn=Object.getOwnPropertyDescriptor,Bn=(a,t,n,e)=>{for(var r=e>1?void 0:e?Tn(t,n):t,s=a.length-1,i;s>=0;s--)(i=a[s])&&(r=(e?i(t,n,r):i(r))||r);return e&&r&&En(t,n,r),r},Ie=(a,t)=>(n,e)=>t(n,e,a);let be=class extends d.Disposable{constructor(t,n,e,r){super();q(this,"_sceneListenerOnDrawingMap",new WeakSet);this._currentUniverService=t,this._commandService=n,this._renderManagerService=e,this._drawingManagerService=r,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(){const t=this._drawingManagerService.drawingManagerData,n=Ne(this._currentUniverService);if(n==null)return;const{unitId:e,subUnitId:r}=n;Object.keys(t).forEach(s=>{Object.keys(t[s]).forEach(i=>{const o=t[s][i].data;o==null||s!==e||i!==r||Object.keys(o).forEach(c=>{o[c]&&this._insertDrawing([{unitId:s,subUnitId:i,drawingId:c}])})})})}_commandExecutedListener(){this.disposeWithMe(this._commandService.onCommandExecuted(t=>{if(t.id===ve.id){const n=t.params;if(n==null)return;this._drawingAlign(n)}}))}_drawingGroupListener(){this.disposeWithMe(this._drawingManagerService.group$.subscribe(t=>{this._groupDrawings(t)})),this.disposeWithMe(this._drawingManagerService.ungroup$.subscribe(t=>{this._ungroupDrawings(t)}))}_getSceneAndTransformerByDrawingSearch(t){if(t==null)return;const n=this._renderManagerService.getRenderById(t),e=n==null?void 0:n.scene;if(e==null)return null;const r=e.getTransformerByCreate();return{scene:e,transformer:r}}_groupDrawings(t){t.forEach(n=>{this._groupDrawing(n)})}_groupDrawing(t){const{parent:n,children:e}=t,{unitId:r,subUnitId:s,drawingId:i}=n,o=this._getSceneAndTransformerByDrawingSearch(n.unitId);if(o==null)return;const{scene:c,transformer:g}=o;this._commandService.syncExecuteCommand(ee.id);const m=[];if(e.forEach(p=>{const _=M.getDrawingShapeKeyByDrawingSearch(p),w=c.getObjectIncludeInGroup(_);if(w==null||m.includes(w))return;m.push(w);const{transform:C}=p;C!=null&&(w.classType===b.RENDER_CLASS_TYPE.GROUP?w.transformByState({left:C.left,top:C.top}):w.transformByState(C))}),m.length===0)return;const h=M.getDrawingShapeKeyByDrawingSearch({unitId:r,subUnitId:s,drawingId:i}),f=new b.Group(h);c.addObject(f,b.DRAWING_OBJECT_LAYER_INDEX).attachTransformerTo(f),f.addObjects(...m),n.transform&&f.transformByState({left:n.transform.left,top:n.transform.top}),g.clearSelectedObjects(),g.setSelectedControl(f)}_ungroupDrawings(t){t.forEach(n=>{this._ungroupDrawing(n)})}_ungroupDrawing(t){const{parent:n,children:e}=t,r=this._getSceneAndTransformerByDrawingSearch(n.unitId);if(r==null)return;const{scene:s,transformer:i}=r;e.forEach(h=>{const f=M.getDrawingShapeKeyByDrawingSearch(h),p=s.getObjectIncludeInGroup(f);if(p==null)return!0;if(p==null)return;const{transform:_}=h;_!=null&&(p.classType===b.RENDER_CLASS_TYPE.GROUP?p.transformByState({left:_.left,top:_.top}):p.transformByState(_))});const o=M.getDrawingShapeKeyByDrawingSearch(n),c=s.getObject(o),{width:g,height:m}=c;c.getObjects().forEach(h=>{c.removeSelfObjectAndTransform(h.oKey,g,m)}),c.dispose(),i.clearSelectedObjects()}_drawingAlign(t){const{alignType:n}=t,e=this._drawingManagerService.getFocusDrawings();if(n===x.default)return;const r=[];let s=Number.POSITIVE_INFINITY,i=Number.POSITIVE_INFINITY,o=Number.NEGATIVE_INFINITY,c=Number.NEGATIVE_INFINITY,g=0;e.forEach(m=>{const{unitId:h,subUnitId:f,drawingId:p,drawingType:_}=m,w=this._drawingManagerService.getDrawingByParam({unitId:h,subUnitId:f,drawingId:p});if(w==null||w.transform==null)return;r.push({unitId:h,subUnitId:f,drawingId:p,drawingType:_,transform:w.transform});const{left:C=0,top:P=0,width:I=0,height:E=0}=w.transform;s=Math.min(s,C),i=Math.min(i,P),o=Math.max(o,C+I),c=Math.max(c,P+E),g++}),g!==0&&(this._sortDrawingTransform(r,n),this._applyAlignType(r,n,s,i,o,c,g))}_applyAlignType(t,n,e,r,s,i,o){const c=Math.round((s-e)/o*10)/10,g=Math.round((i-r)/o*10)/10,m=[],h=this._getSceneAndTransformerByDrawingSearch(t[0].unitId);if(h==null)return;const{scene:f,transformer:p}=h;t.forEach((_,w)=>{const{unitId:C,subUnitId:P,drawingId:I,transform:E,drawingType:j}=_,{left:U=0,top:R=0,width:O=0,height:D=0}=E;let T=U,A=R;switch(n){case x.left:T=e;break;case x.center:T=e+(s-e)/2-O/2;break;case x.right:T=s-O;break;case x.top:A=r;break;case x.middle:A=r+(i-r)/2-D/2;break;case x.bottom:A=i-D;break;case x.horizon:T=e+c*w;break;case x.vertical:A=r+g*w;break}(T!==U||A!==R)&&m.push({unitId:C,subUnitId:P,drawingId:I,drawingType:j,transform:{left:T,top:A}})}),this._drawingManagerService.featurePluginUpdateNotification(m),p.refreshControls().changeNotification()}_sortDrawingTransform(t,n){t.sort((e,r)=>{const s=e.transform,i=r.transform,{left:o=0,top:c=0,width:g=0,height:m=0}=s,{left:h=0,top:f=0,width:p=0,height:_=0}=i;switch(n){case x.left:return o-h;case x.center:return o+g/2-(h+p/2);case x.right:return o+g-(h+p);case x.top:return c-f;case x.middle:return c+m/2-(f+_/2);case x.bottom:return c+m-(f+_);case x.horizon:return o+g/2-(h+p/2);case x.vertical:return c+m/2-(f+_/2);default:return 0}})}_drawingArrangeListener(){this.disposeWithMe(this._drawingManagerService.order$.subscribe(t=>{this._drawingArrange(t)}))}_drawingArrange(t){const{unitId:n,subUnitId:e,drawingIds:r}=t,s=this._getSceneAndTransformerByDrawingSearch(n);if(s==null)return;const{scene:i}=s;r.forEach(o=>{const c=M.getDrawingShapeKeyByDrawingSearch({unitId:n,subUnitId:e,drawingId:o}),g=i.fuzzyMathObjects(c,!0);if(g==null||g.length===0)return;const m=this._drawingManagerService.getDrawingOrder(n,e).indexOf(o);for(const h of g)h.setProps({zIndex:m}),h.makeDirty()})}_drawingAddListener(){this.disposeWithMe(this._drawingManagerService.add$.subscribe(t=>{this._insertDrawing(t)}))}_insertDrawing(t){const n=[];t.forEach(e=>{const{unitId:r}=e;if(this._drawingManagerService.getDrawingByParam(e)==null)return;const i=this._getSceneAndTransformerByDrawingSearch(r);if(i==null)return;const{scene:o}=i;n.includes(o)||n.push(o)}),n.forEach(e=>{this._sceneListenerOnDrawingMap.has(e)||(this._addListenerOnDrawing(e),this._sceneListenerOnDrawingMap.add(e))})}_drawingRemoveListener(){this.disposeWithMe(this._drawingManagerService.remove$.subscribe(t=>{t.forEach(n=>{var m;const{unitId:e,subUnitId:r,drawingId:s}=n,i=this._getSceneAndTransformerByDrawingSearch(e);if(i==null)return;const{scene:o}=i,c=M.getDrawingShapeKeyByDrawingSearch({unitId:e,subUnitId:r,drawingId:s}),g=o.fuzzyMathObjects(c,!0);if(g.length>0){for(const h of g)h.dispose();(m=o.getTransformer())==null||m.clearSelectedObjects()}})}))}_drawingUpdateListener(){this.disposeWithMe(this._drawingManagerService.update$.subscribe(t=>{t.forEach(n=>{const{unitId:e,subUnitId:r,drawingId:s}=n,i=this._drawingManagerService.getDrawingByParam(n);if(i==null)return;const{transform:o,drawingType:c}=i,g=this._getSceneAndTransformerByDrawingSearch(e);if(g==null)return;const{scene:m,transformer:h}=g;if(o==null)return!0;const{left:f=0,top:p=0,width:_=0,height:w=0,angle:C=0,flipX:P=!1,flipY:I=!1,skewX:E=0,skewY:j=0}=o,U=M.getDrawingShapeKeyByDrawingSearch({unitId:e,subUnitId:r,drawingId:s}),R=m.getObject(U);if(R==null)return!0;R.transformByState({left:f,top:p,width:_,height:w,angle:C,flipX:P,flipY:I,skewX:E,skewY:j})})}))}_drawingRefreshListener(){this.disposeWithMe(this._drawingManagerService.refreshTransform$.subscribe(t=>{t.forEach(n=>{const{unitId:e,subUnitId:r,drawingId:s}=n,i=this._getSceneAndTransformerByDrawingSearch(e);if(i==null)return;const o=this._drawingManagerService.getDrawingByParam(n);if(o==null)return;const{transform:c}=o,{scene:g}=i,m=M.getDrawingShapeKeyByDrawingSearch({unitId:e,subUnitId:r,drawingId:s}),h=g.getObject(m);if(h==null||c==null)return!0;const{left:f=0,top:p=0,width:_=0,height:w=0,angle:C=0,flipX:P=!1,flipY:I=!1,skewX:E=0,skewY:j=0}=c;h.transformByState({left:f,top:p,width:_,height:w,angle:C,flipX:P,flipY:I,skewX:E,skewY:j})})}))}_drawingVisibleListener(){this.disposeWithMe(this._drawingManagerService.visible$.subscribe(t=>{t.forEach(n=>{const{unitId:e,subUnitId:r,drawingId:s,visible:i}=n,o=this._getSceneAndTransformerByDrawingSearch(e);if(o==null)return;const{scene:c}=o,g=M.getDrawingShapeKeyByDrawingSearch({unitId:e,subUnitId:r,drawingId:s}),m=c.getObject(g);if(m==null)return!0;i?m.show():m.hide()})}))}_filterUpdateParams(t,n){return t.filter((e,r)=>{if(e==null)return!1;const{transform:s}=e;return d.checkIfMove(s,n==null?void 0:n[r])})}_addListenerOnDrawing(t){const n=t.getTransformerByCreate();let e=null;this.disposeWithMe(d.toDisposable(n.changeStart$.subscribe(r=>{const{objects:s}=r,i=Array.from(s.values()),o=[];e=i.map(c=>{const{left:g,top:m,height:h,width:f,angle:p,oKey:_,isInGroup:w}=c,C=this._drawingManagerService.getDrawingOKey(_);if(w||c instanceof b.Group){let P=c.ancestorGroup;if(P==null&&c instanceof b.Group&&(P=c),P==null)return null;const I=this._drawingManagerService.getDrawingOKey(P.oKey);if(I){const{unitId:E,subUnitId:j,drawingId:U}=I;o.push({unitId:E,subUnitId:j,drawingId:U});const{left:R,top:O,height:D,width:T,angle:A}=P;return{left:R,top:O,height:D,width:T,angle:A}}}else if(C!=null){const{unitId:P,subUnitId:I,drawingId:E}=C;return o.push({unitId:P,subUnitId:I,drawingId:E}),{left:g,top:m,height:h,width:f,angle:p}}return null}).filter(c=>c!=null),o.length>0?this._drawingManagerService.focusDrawing(o):this._drawingManagerService.focusDrawing(null)}))),this.disposeWithMe(d.toDisposable(n.changeEnd$.subscribe(r=>{const{objects:s}=r,i=this._filterUpdateParams(me(s,this._drawingManagerService),e);i.length>0&&this._drawingManagerService.featurePluginUpdateNotification(i)})))}};be=Bn([Ie(0,d.IUniverInstanceService),Ie(1,d.ICommandService),Ie(2,b.IRenderManagerService),Ie(3,M.IDrawingManagerService)],be);class he extends b.Shape{constructor(n,e){e==null&&(e={}),e.transformerConfig={keepRatio:!1,isCropper:!0,anchorFill:"rgb(0, 0, 0)",anchorStroke:"rgb(255, 255, 255)",anchorSize:24};super(n,e);q(this,"_srcRect");q(this,"_prstGeom");q(this,"_applyTransform");q(this,"_dragPadding",8);q(this,"_cacheCanvas");e!=null&&e.srcRect&&(this._srcRect=e.srcRect),e!=null&&e.prstGeom&&(this._prstGeom=e.prstGeom),e!=null&&e.applyTransform&&(this._applyTransform=e.applyTransform),e!=null&&e.dragPadding&&(this._dragPadding=e.dragPadding),this._applyProps()}refreshSrcRect(n,e){this._srcRect=n,this._applyTransform=e,this._applyProps()}get srcRect(){return this._srcRect}dispose(){var n;super.dispose(),(n=this._cacheCanvas)==null||n.dispose(),this._srcRect=null}isHit(n){const e=this.getInverseCoord(n);return e.x>=-this.strokeWidth/2&&e.x<=this.width+this.strokeWidth/2&&e.y>=-this.strokeWidth/2&&e.y<=this.height+this.strokeWidth/2&&!this._inSurround(e)}_inSurround(n){const e=this._dragPadding;return n.x>=e-this.strokeWidth/2&&n.x<=this.width+this.strokeWidth/2-e&&n.y>=e-this.strokeWidth/2&&n.y<=this.height+this.strokeWidth/2-e}render(n,e){return this.visible?(n.save(),this._draw(n),n.restore(),this.makeDirty(!1),this):(this.makeDirty(!1),this)}_draw(n){var c,g;const r=this.getScene().getEngine(),{width:s,height:i}=r;this._initialCacheCanvas(),(c=this._cacheCanvas)==null||c.clear();const o=(g=this._cacheCanvas)==null?void 0:g.getContext();o!=null&&(o.save(),b.Rect.drawWith(o,{left:0,top:0,width:s,height:i,fill:"rgba(0, 0, 0, 0.5)"}),o.setTransform(n.getTransform()),this._clipForApplyObject(o),this._applyCache(n),o.restore())}_clipForApplyObject(n){let e=0;if(this._prstGeom!=null&&(e=1),n.globalCompositeOperation="destination-out",n.beginPath(),e===0){const r=this.transform.getMatrix();n.transform(r[0],r[1],r[2],r[3],r[4],r[5]),n.rect(0,0,this.width,this.height),n.fill()}}_applyProps(){if(this._applyTransform==null)return;let n=0,e=0,r=0,s=0;const{left:i=0,top:o=0,width:c=0,height:g=0,angle:m}=this._applyTransform;if(this._srcRect!=null){const{left:p=0,top:_=0,right:w=0,bottom:C=0}=this._srcRect;n=p,e=_,r=w,s=C}const h=i+n,f=o+e;this.transformByState({left:h,top:f,width:i+c-r-h,height:o+g-s-f,angle:m})}_applyCache(n){if(!n||this._cacheCanvas==null)return;const e=this._cacheCanvas.getContext();e.save(),n.save(),n.setTransform(1,0,0,1,0,0),e.setTransform(1,0,0,1,0,0),n.drawImage(this._cacheCanvas.getCanvasEle(),0,0),n.restore(),e.restore()}_initialCacheCanvas(){if(this._cacheCanvas!=null)return;const n=this.getScene();if(n==null)return;this._cacheCanvas=new b.Canvas;const e=n.getEngine();this._cacheCanvas.setSize(e.width,e.height),e.onTransformChange$.subscribeEvent(()=>{var r;(r=this._cacheCanvas)==null||r.setSize(e.width,e.height),this.makeDirty(!0)})}}var Un=Object.defineProperty,An=Object.getOwnPropertyDescriptor,Ln=(a,t,n,e)=>{for(var r=e>1?void 0:e?An(t,n):t,s=a.length-1,i;s>=0;s--)(i=a[s])&&(r=(e?i(t,n,r):i(r))||r);return e&&r&&Un(t,n,r),r},oe=(a,t)=>(n,e)=>t(n,e,a);let ye=class extends d.Disposable{constructor(t,n,e,r,s,i){super();q(this,"_sceneListenerOnImageMap",new WeakSet);this._commandService=t,this._drawingManagerService=n,this._renderManagerService=e,this._univerInstanceService=r,this._messageService=s,this._localeService=i,this._init()}_init(){this._initOpenCrop(),this._initCloseCrop(),this._initAutoCrop()}_initAutoCrop(){this.disposeWithMe(this._commandService.onCommandExecuted(t=>{if(t.id!==ue.id)return;const n=t.params;if(n==null)return;const{cropType:e}=n,r=this._drawingManagerService.getFocusDrawings();if(r.length!==1)return;const s=r[0],{unitId:i,subUnitId:o,drawingId:c}=s,g=this._renderManagerService.getRenderById(i),m=g==null?void 0:g.scene;if(m==null)return!0;this._searchCropObject(m)!=null&&this._commandService.syncExecuteCommand(ee.id,{isAuto:!0});const f=M.getDrawingShapeKeyByDrawingSearch({unitId:i,subUnitId:o,drawingId:c}),p=m.getObject(f);if(!(p instanceof b.Image)){this._messageService.show({type:k.MessageType.Error,content:this._localeService.t("image-cropper.error")});return}p!=null&&(this._updateCropperObject(e,p),this._commandService.executeCommand(Se.id,{unitId:i,subUnitId:o,drawingId:c}))}))}_calculateSrcRectByRatio(t,n,e,r,s,i){const o=e/r,c=s/i;let g=e,m=r;o>c?g=r*c:m=e/c;const h=(e-g)/2,f=(r-m)/2;return{left:b.precisionTo(h,1),top:b.precisionTo(f,1),right:b.precisionTo(e-(h+g),1),bottom:b.precisionTo(r-(f+m),1)}}_updateCropperObject(t,n){const{left:e,top:r,width:s,height:i}=n.calculateTransformWithSrcRect();let o;switch(t){case H.R1_1:o=this._calculateSrcRectByRatio(e,r,s,i,1,1);break;case H.R16_9:o=this._calculateSrcRectByRatio(e,r,s,i,16,9);break;case H.R9_16:o=this._calculateSrcRectByRatio(e,r,s,i,9,16);break;case H.R5_4:o=this._calculateSrcRectByRatio(e,r,s,i,5,4);break;case H.R4_5:o=this._calculateSrcRectByRatio(e,r,s,i,4,5);break;case H.R4_3:o=this._calculateSrcRectByRatio(e,r,s,i,4,3);break;case H.R3_4:o=this._calculateSrcRectByRatio(e,r,s,i,3,4);break;case H.R3_2:o=this._calculateSrcRectByRatio(e,r,s,i,3,2);break;case H.R2_3:o=this._calculateSrcRectByRatio(e,r,s,i,2,3);break;case H.FREE:}if(o==null)return;n.setSrcRect(o);const{left:c=0,top:g=0,bottom:m=0,right:h=0}=o;n.transformByStateCloseCropper({left:e+c,top:r+g,width:s-h-c,height:i-m-g})}_initOpenCrop(){this.disposeWithMe(this._commandService.onCommandExecuted(t=>{if(t.id!==Se.id)return;const n=t.params;if(n==null)return;const{unitId:e,subUnitId:r,drawingId:s}=n,i=this._renderManagerService.getRenderById(e),o=i==null?void 0:i.scene;if(o==null)return!0;if(this._sceneListenerOnImageMap.has(o)||(this._addListenerOnImage(o),this._sceneListenerOnImageMap.add(o)),this._drawingManagerService.getDrawingByParam({unitId:e,subUnitId:r,drawingId:s})==null)return;const g=M.getDrawingShapeKeyByDrawingSearch({unitId:e,subUnitId:r,drawingId:s}),m=o.getObject(g);if(m==null)return;if(!(m instanceof b.Image)){this._messageService.show({type:k.MessageType.Error,content:this._localeService.t("image-cropper.error")});return}const h=o.getTransformer();h==null||h.clearControls();const f=new he(`${g}-crop`,{srcRect:m.srcRect,prstGeom:m.prstGeom,applyTransform:m.calculateTransformWithSrcRect()});o.addObject(f,m.getLayerIndex()+1).attachTransformerTo(f),h==null||h.createControlForCopper(f),this._addHoverForImageCopper(f),m.openRenderByCropper(),h==null||h.refreshControls(),f.makeDirty(!0),this._drawingManagerService.focusDrawing([{unitId:e,subUnitId:r,drawingId:s}])}))}_searchCropObject(t){const n=t.getAllObjectsByOrder();for(const e of n)if(e instanceof he)return e}_initCloseCrop(){this.disposeWithMe(this._commandService.onCommandExecuted(n=>{if(n.id!==ee.id)return;const e=this._univerInstanceService.getFocusedUnit();if(e==null)return;const r=e.getUnitId(),s=this._renderManagerService.getRenderById(r),i=s==null?void 0:s.scene;if(i==null)return!0;const o=this._searchCropObject(i);if(o==null)return;const c=this._getApplyObjectByCropObject(o);if(c==null)return;const g=i.getTransformerByCreate();g.detachFrom(o),g.clearCopperControl();const m=this._getSrcRectByTransformState(c,o),h=this._drawingManagerService.getDrawingOKey(c.oKey);if(h!=null){const{left:f,top:p,height:_,width:w}=o;this._drawingManagerService.featurePluginUpdateNotification([{...h,transform:{...h.transform,left:f,top:p,height:_,width:w},srcRect:m.srcRectAngle}])}c.setSrcRect({...m.srcRectAngle}),c.closeRenderByCropper(),c.makeDirty(!0),o==null||o.dispose()}));const t=this._univerInstanceService.getCurrentTypeOfUnit$(d.UniverInstanceType.UNIVER_SHEET).pipe(xe.filter(n=>!!n),xe.switchMap(n=>n.activeSheet$));this.disposeWithMe(t.subscribe(()=>{this._commandService.syncExecuteCommand(ee.id)}))}_getApplyObjectByCropObject(t){const n=t.oKey,e=n.slice(0,n.length-5),r=t.getScene();if(!r)return null;const s=r.getObject(e);return s==null?null:s}_addListenerOnImage(t){const n=t.getTransformerByCreate();let e=null;this.disposeWithMe(n.changeStart$.subscribe(r=>{const{objects:s}=r,i=s.values().next().value;if(i==null||!(i instanceof he))return;const{left:o,top:c,height:g,width:m,angle:h}=i;e={left:o,top:c,height:g,width:m,angle:h},n.clearCopperControl()})),this.disposeWithMe(n.changeEnd$.subscribe(r=>{const{objects:s}=r,i=s.values().next().value;if(i==null||!(i instanceof he))return;const{left:o,top:c,height:g,width:m,angle:h}=i;if(!d.checkIfMove({left:o,top:c,height:g,width:m,angle:h},e))return;const f=this._getApplyObjectByCropObject(i);if(f==null)return;const p=this._getSrcRectByTransformState(f,i);i.refreshSrcRect(p.srcRect,f.getState()),n.createControlForCopper(i)})),this._endCropListener(t)}_addHoverForImageCopper(t){this.disposeWithMe(t.onPointerEnter$.subscribeEvent(()=>{t.cursor=b.CURSOR_TYPE.MOVE})),this.disposeWithMe(t.onPointerLeave$.subscribeEvent(()=>{t.cursor=b.CURSOR_TYPE.DEFAULT}))}_endCropListener(t){const n=t.getTransformerByCreate();this.disposeWithMe(n.clearControl$.subscribe(e=>{e===!0&&this._commandService.syncExecuteCommand(ee.id)}))}_getSrcRectByTransformState(t,n){const{left:e,top:r,height:s,width:i,strokeWidth:o,angle:c}=n,{left:g,top:m,width:h,height:f,angle:p,strokeWidth:_}=t,w=e-g,C=r-m,P={left:w,top:C,right:h-w-i,bottom:f-C-s},I={...P};if(p!==0){const E=e+i/2,j=r+s/2,U=new b.Vector2(E,j),R=h/2+g,O=f/2+m,D=new b.Vector2(R,O),T=new b.Vector2(g,m);T.rotateByPoint(b.degToRad(p),D);const A=T.clone();A.rotateByPoint(b.degToRad(-p),U);const V=e-A.x,L=r-A.y;I.left=V,I.top=L,I.right=h-V-i,I.bottom=f-L-s}return{srcRect:P,srcRectAngle:I}}};ye=Ln([oe(0,d.ICommandService),oe(1,M.IDrawingManagerService),oe(2,b.IRenderManagerService),oe(3,d.IUniverInstanceService),oe(4,Ce.IMessageService),oe(5,d.Inject(d.LocaleService))],ye);var Hn=Object.defineProperty,Gn=Object.getOwnPropertyDescriptor,Vn=(a,t,n,e)=>{for(var r=e>1?void 0:e?Gn(t,n):t,s=a.length-1,i;s>=0;s--)(i=a[s])&&(r=(e?i(t,n,r):i(r))||r);return e&&r&&Hn(t,n,r),r},te=(a,t)=>(n,e)=>t(n,e,a);let Pe=class extends d.Disposable{constructor(a,t,n,e,r,s,i){super(),this._commandService=a,this._renderManagerService=t,this._drawingManagerService=n,this._dialogService=e,this._imageIoService=r,this._currentUniverService=s,this._drawingRenderService=i,this._initialize()}dispose(){super.dispose()}_initialize(){this._drawingAddListener(),this._commandExecutedListener(),this._imageUpdateListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.onCommandExecuted(a=>{if(a.id===Re.id){const t=a.params;if(t==null)return;this._resetImageSize(t)}}))}_getSceneAndTransformerByDrawingSearch(a){if(a==null)return;const t=this._renderManagerService.getRenderById(a),n=t==null?void 0:t.scene;if(n==null)return null;const e=n.getTransformerByCreate();return{scene:n,transformer:e}}_resetImageSize(a){const t=[],n=[];a.forEach(e=>{const{unitId:r,subUnitId:s,drawingId:i}=e,o=this._getSceneAndTransformerByDrawingSearch(r);if(o==null)return;const{scene:c}=o,g=M.getDrawingShapeKeyByDrawingSearch({unitId:r,subUnitId:s,drawingId:i}),m=c.getObject(g);if(m==null)return!0;const h=this._drawingManagerService.getDrawingByParam(e);if(h==null)return!0;if(h.drawingType!==d.DrawingTypeEnum.DRAWING_IMAGE)return;m.resetSize();const{width:f,height:p}=m.getNativeSize();n.includes(c)===!1&&n.push(c),t.push({...h,transform:{...h.transform,height:p,width:f,angle:0},srcRect:null,prstGeom:null})}),this._drawingManagerService.featurePluginUpdateNotification(t),n.forEach(e=>{e.getTransformerByCreate().refreshControls().changeNotification()}),this._drawingManagerService.focusDrawing(a)}_drawingAddListener(){this.disposeWithMe(this._drawingManagerService.add$.subscribe(a=>{this._insertImages(a)}))}_insertImages(a){a.forEach(async t=>{var g;const{unitId:n,subUnitId:e,drawingId:r}=t,s=this._getSceneAndTransformerByDrawingSearch(n),i=(g=Ne(this._currentUniverService,n))==null?void 0:g.subUnitId;if(s==null||i!==e)return;const o=this._drawingManagerService.getDrawingByParam(t);if(o==null)return;const c=await this._drawingRenderService.renderImages(o,s.scene);if(!(c==null||c.length===0))for(const m of c)this._addHoverForImage(m),this._addDialogForImage(m)})}_imageUpdateListener(){this.disposeWithMe(this._drawingManagerService.update$.subscribe(a=>{a.forEach(t=>{const{unitId:n,subUnitId:e,drawingId:r}=t,s=this._drawingManagerService.getDrawingByParam(t);if(s==null)return;const{transform:i,drawingType:o,srcRect:c,prstGeom:g,source:m,imageSourceType:h}=s;if(o!==d.DrawingTypeEnum.DRAWING_IMAGE)return;const f=this._getSceneAndTransformerByDrawingSearch(n);if(f==null)return;const{scene:p,transformer:_}=f;if(i==null)return!0;const w=M.getDrawingShapeKeyByDrawingSearch({unitId:n,subUnitId:e,drawingId:r}),C=p.getObject(w);if(C==null)return!0;C.setSrcRect(c),C.setPrstGeom(g)})}))}_addHoverForImage(a){this.disposeWithMe(d.toDisposable(a.onPointerEnter$.subscribeEvent(()=>{a.cursor=b.CURSOR_TYPE.GRAB}))),this.disposeWithMe(d.toDisposable(a.onPointerLeave$.subscribeEvent(()=>{a.cursor=b.CURSOR_TYPE.DEFAULT})))}_addDialogForImage(a){this.disposeWithMe(d.toDisposable(a.onDblclick$.subscribeEvent(()=>{const t=`${a.oKey}-viewer-dialog`;this._drawingRenderService.previewImage(t,a.getNative().src,a.getNativeSize().width,a.getNativeSize().height)})))}};Pe=Vn([te(0,d.ICommandService),te(1,b.IRenderManagerService),te(2,M.IDrawingManagerService),te(3,Ce.IDialogService),te(4,M.IImageIoService),te(5,d.IUniverInstanceService),te(6,d.Inject(y.DrawingRenderService))],Pe);var Wn=Object.defineProperty,kn=Object.getOwnPropertyDescriptor,zn=(a,t,n,e)=>{for(var r=e>1?void 0:e?kn(t,n):t,s=a.length-1,i;s>=0;s--)(i=a[s])&&(r=(e?i(t,n,r):i(r))||r);return e&&r&&Wn(t,n,r),r},$e=(a,t)=>(n,e)=>t(n,e,a);const Kn="UNIVER_DRAWING_UI_PLUGIN";y.UniverDrawingUIPlugin=(De=class extends d.Plugin{constructor(t=Je,n,e){super(),this._config=t,this._injector=n,this._configService=e;const{menu:r,...s}=d.merge({},Je,this._config);r&&this._configService.setConfig("menu",r,{merge:!0}),this._configService.setConfig(Rn,s)}onStarting(){this._initDependencies()}onRendered(){this._injector.get(be),this._injector.get(_e),this._injector.get(ye),this._injector.get(Pe)}_initDependencies(){[[y.DrawingRenderService],[be],[_e],[ye],[Pe]].forEach(n=>this._injector.add(n))}},q(De,"pluginName",Kn),De),y.UniverDrawingUIPlugin=zn([$e(1,d.Inject(d.Injector)),$e(2,d.IConfigService)],y.UniverDrawingUIPlugin),y.AutoImageCropOperation=ue,y.COMPONENT_IMAGE_POPUP_MENU=Xe,y.CloseImageCropOperation=ee,y.DrawingCommonPanel=Mn,y.ImageCropperObject=he,y.ImagePopupMenu=Ze,y.ImageResetSizeOperation=Re,y.OpenImageCropOperation=Se,y.SetDrawingAlignOperation=ve,y.getUpdateParams=me,Object.defineProperty(y,Symbol.toStringTag,{value:"Module"})});
15
15
 
16
16
 
17
17
  // @univerjs/sheets-drawing/index
18
- (function(a,s){typeof exports=="object"&&typeof module<"u"?s(exports,require("@univerjs/core"),require("@univerjs/drawing")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/drawing"],s):(a=typeof globalThis<"u"?globalThis:a||self,s(a.UniverSheetsDrawing={},a.UniverCore,a.UniverDrawing))})(this,function(a,s,u){"use strict";const w="sheets-drawing.config",l={};var f=(e=>(e.Position="0",e.Both="1",e.None="2",e))(f||{});class m extends u.UnitDrawingService{}const v=s.createIdentifier("sheets-drawing.sheet-drawing.service");var d=(e=>(e[e.INSERT=0]="INSERT",e[e.REMOVE=1]="REMOVE",e[e.UPDATE=2]="UPDATE",e[e.ARRANGE=3]="ARRANGE",e[e.GROUP=4]="GROUP",e[e.UNGROUP=5]="UNGROUP",e))(d||{});const U={id:"sheet.mutation.set-drawing-apply",type:s.CommandType.MUTATION,handler:(e,r)=>{const i=e.get(u.IDrawingManagerService),n=e.get(v),{op:t,unitId:o,subUnitId:c,type:M,objects:g}=r;switch(i.applyJson1(o,c,t),n.applyJson1(o,c,t),M){case 0:i.addNotification(g),n.addNotification(g);break;case 1:i.removeNotification(g),n.removeNotification(g);break;case 2:i.updateNotification(g),n.updateNotification(g);break;case 3:i.orderNotification(g),n.orderNotification(g);break;case 4:i.groupUpdateNotification(g);break;case 5:i.ungroupUpdateNotification(g);break}return!0}};var E=Object.defineProperty,I=Object.getOwnPropertyDescriptor,O=(e,r,i,n)=>{for(var t=n>1?void 0:n?I(r,i):r,o=e.length-1,c;o>=0;o--)(c=e[o])&&(t=(n?c(r,i,t):c(t))||t);return n&&t&&E(r,i,t),t},h=(e,r)=>(i,n)=>r(i,n,e);const _="SHEET_DRAWING_PLUGIN";let S=class extends s.Disposable{constructor(e,r,i,n){super(),this._commandService=e,this._sheetDrawingService=r,this._drawingManagerService=i,this._resourceManagerService=n,this._initSnapshot(),this.disposeWithMe(this._commandService.registerCommand(U))}_initSnapshot(){const e=(i,n)=>{const t=n||this._sheetDrawingService.getDrawingDataForUnit(i);return t?JSON.stringify(t):""},r=i=>{if(!i)return{};try{return JSON.parse(i)}catch{return{}}};this.disposeWithMe(this._resourceManagerService.registerPluginResource({pluginName:_,businesses:[s.UniverInstanceType.UNIVER_SHEET],toJson:(i,n)=>e(i,n),parseJson:i=>r(i),onUnLoad:i=>{this._sheetDrawingService.removeDrawingDataForUnit(i),this._drawingManagerService.removeDrawingDataForUnit(i)},onLoad:(i,n)=>{this._sheetDrawingService.registerDrawingData(i,n),this._drawingManagerService.registerDrawingData(i,n)}}))}};S=O([h(0,s.ICommandService),h(1,v),h(2,u.IDrawingManagerService),h(3,s.IResourceManagerService)],S);var D=Object.defineProperty,R=Object.getOwnPropertyDescriptor,b=(e,r,i)=>r in e?D(e,r,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[r]=i,p=(e,r,i,n)=>{for(var t=n>1?void 0:n?R(r,i):r,o=e.length-1,c;o>=0;o--)(c=e[o])&&(t=(n?c(r,i,t):c(t))||t);return n&&t&&D(r,i,t),t},N=(e,r)=>(i,n)=>r(i,n,e),P=(e,r,i)=>b(e,typeof r!="symbol"?r+"":r,i);a.UniverSheetsDrawingPlugin=class extends s.Plugin{constructor(r=l,i,n){super(),this._config=r,this._injector=i,this._configService=n;const{...t}=this._config;this._configService.setConfig(w,t)}onStarting(){[[S],[v,{useClass:m}]].forEach(r=>this._injector.add(r)),this._injector.get(S)}},P(a.UniverSheetsDrawingPlugin,"pluginName",_),P(a.UniverSheetsDrawingPlugin,"type",s.UniverInstanceType.UNIVER_SHEET),a.UniverSheetsDrawingPlugin=p([s.DependentOn(u.UniverDrawingPlugin),N(1,s.Inject(s.Injector)),N(2,s.IConfigService)],a.UniverSheetsDrawingPlugin),a.DrawingApplyType=d,a.ISheetDrawingService=v,a.SHEET_DRAWING_PLUGIN=_,a.SetDrawingApplyMutation=U,a.SheetDrawingAnchorType=f,Object.defineProperty(a,Symbol.toStringTag,{value:"Module"})});
18
+ (function(a,s){typeof exports=="object"&&typeof module<"u"?s(exports,require("@univerjs/core"),require("@univerjs/drawing")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/drawing"],s):(a=typeof globalThis<"u"?globalThis:a||self,s(a.UniverSheetsDrawing={},a.UniverCore,a.UniverDrawing))})(this,function(a,s,u){"use strict";const l="sheets-drawing.config",f={};var d=(e=>(e.Position="0",e.Both="1",e.None="2",e))(d||{});class m extends u.UnitDrawingService{}const v=s.createIdentifier("sheets-drawing.sheet-drawing.service");var U=(e=>(e[e.INSERT=0]="INSERT",e[e.REMOVE=1]="REMOVE",e[e.UPDATE=2]="UPDATE",e[e.ARRANGE=3]="ARRANGE",e[e.GROUP=4]="GROUP",e[e.UNGROUP=5]="UNGROUP",e))(U||{});const D={id:"sheet.mutation.set-drawing-apply",type:s.CommandType.MUTATION,handler:(e,r)=>{const i=e.get(u.IDrawingManagerService),n=e.get(v),{op:t,unitId:o,subUnitId:c,type:M,objects:g}=r;switch(i.applyJson1(o,c,t),n.applyJson1(o,c,t),M){case 0:i.addNotification(g),n.addNotification(g);break;case 1:i.removeNotification(g),n.removeNotification(g);break;case 2:i.updateNotification(g),n.updateNotification(g);break;case 3:i.orderNotification(g),n.orderNotification(g);break;case 4:i.groupUpdateNotification(g);break;case 5:i.ungroupUpdateNotification(g);break}return!0}};var E=Object.defineProperty,I=Object.getOwnPropertyDescriptor,O=(e,r,i,n)=>{for(var t=n>1?void 0:n?I(r,i):r,o=e.length-1,c;o>=0;o--)(c=e[o])&&(t=(n?c(r,i,t):c(t))||t);return n&&t&&E(r,i,t),t},h=(e,r)=>(i,n)=>r(i,n,e);const _="SHEET_DRAWING_PLUGIN";let S=class extends s.Disposable{constructor(e,r,i,n){super(),this._commandService=e,this._sheetDrawingService=r,this._drawingManagerService=i,this._resourceManagerService=n,this._initSnapshot(),this.disposeWithMe(this._commandService.registerCommand(D))}_initSnapshot(){const e=(i,n)=>{const t=n||this._sheetDrawingService.getDrawingDataForUnit(i);return t?JSON.stringify(t):""},r=i=>{if(!i)return{};try{return JSON.parse(i)}catch{return{}}};this.disposeWithMe(this._resourceManagerService.registerPluginResource({pluginName:_,businesses:[s.UniverInstanceType.UNIVER_SHEET],toJson:(i,n)=>e(i,n),parseJson:i=>r(i),onUnLoad:i=>{this._sheetDrawingService.removeDrawingDataForUnit(i),this._drawingManagerService.removeDrawingDataForUnit(i)},onLoad:(i,n)=>{this._sheetDrawingService.registerDrawingData(i,n),this._drawingManagerService.registerDrawingData(i,n)}}))}};S=O([h(0,s.ICommandService),h(1,v),h(2,u.IDrawingManagerService),h(3,s.IResourceManagerService)],S);var N=Object.defineProperty,R=Object.getOwnPropertyDescriptor,b=(e,r,i)=>r in e?N(e,r,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[r]=i,p=(e,r,i,n)=>{for(var t=n>1?void 0:n?R(r,i):r,o=e.length-1,c;o>=0;o--)(c=e[o])&&(t=(n?c(r,i,t):c(t))||t);return n&&t&&N(r,i,t),t},P=(e,r)=>(i,n)=>r(i,n,e),w=(e,r,i)=>b(e,typeof r!="symbol"?r+"":r,i);a.UniverSheetsDrawingPlugin=class extends s.Plugin{constructor(r=f,i,n){super(),this._config=r,this._injector=i,this._configService=n;const{...t}=s.merge({},f,this._config);this._configService.setConfig(l,t)}onStarting(){[[S],[v,{useClass:m}]].forEach(r=>this._injector.add(r)),this._injector.get(S)}},w(a.UniverSheetsDrawingPlugin,"pluginName",_),w(a.UniverSheetsDrawingPlugin,"type",s.UniverInstanceType.UNIVER_SHEET),a.UniverSheetsDrawingPlugin=p([s.DependentOn(u.UniverDrawingPlugin),P(1,s.Inject(s.Injector)),P(2,s.IConfigService)],a.UniverSheetsDrawingPlugin),a.DrawingApplyType=U,a.ISheetDrawingService=v,a.SHEET_DRAWING_PLUGIN=_,a.SetDrawingApplyMutation=D,a.SheetDrawingAnchorType=d,Object.defineProperty(a,Symbol.toStringTag,{value:"Module"})});
19
19
 
20
20
 
21
21
  // @univerjs/sheets-drawing-ui/index
22
- (function(b,d){typeof exports=="object"&&typeof module<"u"?d(exports,require("@univerjs/core"),require("@univerjs/drawing"),require("@univerjs/drawing-ui"),require("@univerjs/engine-render"),require("@univerjs/sheets-drawing"),require("@univerjs/sheets-ui"),require("@univerjs/ui"),require("rxjs"),require("@univerjs/sheets"),require("react"),require("@univerjs/docs-drawing"),require("@univerjs/docs-ui"),require("@univerjs/design")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/drawing","@univerjs/drawing-ui","@univerjs/engine-render","@univerjs/sheets-drawing","@univerjs/sheets-ui","@univerjs/ui","rxjs","@univerjs/sheets","react","@univerjs/docs-drawing","@univerjs/docs-ui","@univerjs/design"],d):(b=typeof globalThis<"u"?globalThis:b||self,d(b.UniverSheetsDrawingUi={},b.UniverCore,b.UniverDrawing,b.UniverDrawingUi,b.UniverEngineRender,b.UniverSheetsDrawing,b.UniverSheetsUi,b.UniverUi,b.rxjs,b.UniverSheets,b.React,b.UniverDocsDrawing,b.UniverDocsUi,b.UniverDesign))})(this,function(b,d,P,q,U,p,N,k,W,_,x,st,Ve,J){"use strict";var Mn=Object.defineProperty;var Dn=(b,d,P)=>d in b?Mn(b,d,{enumerable:!0,configurable:!0,writable:!0,value:P}):b[d]=P;var Y=(b,d,P)=>Dn(b,typeof d!="symbol"?d+"":d,P);const ct="sheets-drawing-ui.config",dt={},G={id:"sheet.operation.clear-drawing-transformer",type:d.CommandType.MUTATION,handler:(i,r)=>{const n=i.get(U.IRenderManagerService);return r.forEach(e=>{var t,o;(o=(t=n.getRenderById(e))==null?void 0:t.scene.getTransformer())==null||o.debounceRefreshControls()}),!0}},oe={id:"sheet.command.remove-sheet-image",type:d.CommandType.COMMAND,handler:(i,r)=>{var M,y,T;const n=i.get(d.ICommandService),e=i.get(d.IUndoRedoService),t=i.get(_.SheetInterceptorService),o=i.get(p.ISheetDrawingService);if(!r)return!1;const{drawings:a}=r,c=[];a.forEach(I=>{const{unitId:D}=I;c.push(D)});const l=o.getBatchRemoveOp(a),{unitId:h,subUnitId:u,undo:s,redo:g,objects:m}=l,f=t.onCommandExecute({id:oe.id,params:r}),S={id:p.SetDrawingApplyMutation.id,params:{unitId:h,subUnitId:u,op:g,objects:m,type:p.DrawingApplyType.REMOVE}},v={id:p.SetDrawingApplyMutation.id,params:{unitId:h,subUnitId:u,op:s,objects:m,type:p.DrawingApplyType.INSERT}};return d.sequenceExecute([...(M=f.preRedos)!=null?M:[],S,...f.redos],n)?(e.pushUndoRedo({unitID:h,undoMutations:[...(y=f.preUndos)!=null?y:[],v,...f.undos,{id:G.id,params:c}],redoMutations:[...(T=f.preRedos)!=null?T:[],S,...f.redos,{id:G.id,params:c}]}),!0):!1}},Ye="COMPONENT_SHEET_DRAWING_PANEL",Te={id:"sidebar.operation.sheet-image",type:d.CommandType.COMMAND,handler:async(i,r)=>{const n=i.get(k.ISidebarService),e=i.get(d.LocaleService),t=i.get(d.IUniverInstanceService),o=i.get(P.IDrawingManagerService);if(!_.getSheetCommandTarget(t))return!1;switch(r.value){case"open":n.open({header:{title:e.t("sheetImage.panel.title")},children:{label:Ye},onClose:()=>{o.focusDrawing(null)},width:360});break;case"close":default:n.close();break}return!0}},be={id:"sheet.operation.edit-sheet-image",type:d.CommandType.OPERATION,handler:(i,r)=>{const n=i.get(P.IDrawingManagerService),e=i.get(d.ICommandService);return r==null?!1:(n.focusDrawing([r]),e.executeCommand(Te.id,{value:"open"}),!0)}};var Ee={exports:{}},ae={};/**
22
+ (function(b,d){typeof exports=="object"&&typeof module<"u"?d(exports,require("@univerjs/core"),require("@univerjs/docs-drawing"),require("@univerjs/drawing"),require("@univerjs/drawing-ui"),require("@univerjs/engine-render"),require("@univerjs/sheets-drawing"),require("@univerjs/sheets-ui"),require("@univerjs/ui"),require("rxjs"),require("@univerjs/sheets"),require("react"),require("@univerjs/docs-ui"),require("@univerjs/design")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/docs-drawing","@univerjs/drawing","@univerjs/drawing-ui","@univerjs/engine-render","@univerjs/sheets-drawing","@univerjs/sheets-ui","@univerjs/ui","rxjs","@univerjs/sheets","react","@univerjs/docs-ui","@univerjs/design"],d):(b=typeof globalThis<"u"?globalThis:b||self,d(b.UniverSheetsDrawingUi={},b.UniverCore,b.UniverDocsDrawing,b.UniverDrawing,b.UniverDrawingUi,b.UniverEngineRender,b.UniverSheetsDrawing,b.UniverSheetsUi,b.UniverUi,b.rxjs,b.UniverSheets,b.React,b.UniverDocsUi,b.UniverDesign))})(this,function(b,d,te,P,q,N,p,U,k,j,_,X,xe,J){"use strict";var Mn=Object.defineProperty;var Dn=(b,d,te)=>d in b?Mn(b,d,{enumerable:!0,configurable:!0,writable:!0,value:te}):b[d]=te;var Y=(b,d,te)=>Dn(b,typeof d!="symbol"?d+"":d,te);const dt="sheets-drawing-ui.config",Ye={},G={id:"sheet.operation.clear-drawing-transformer",type:d.CommandType.MUTATION,handler:(i,r)=>{const n=i.get(N.IRenderManagerService);return r.forEach(e=>{var t,o;(o=(t=n.getRenderById(e))==null?void 0:t.scene.getTransformer())==null||o.debounceRefreshControls()}),!0}},ae={id:"sheet.command.remove-sheet-image",type:d.CommandType.COMMAND,handler:(i,r)=>{var M,y,R;const n=i.get(d.ICommandService),e=i.get(d.IUndoRedoService),t=i.get(_.SheetInterceptorService),o=i.get(p.ISheetDrawingService);if(!r)return!1;const{drawings:a}=r,c=[];a.forEach(I=>{const{unitId:D}=I;c.push(D)});const l=o.getBatchRemoveOp(a),{unitId:h,subUnitId:u,undo:s,redo:m,objects:g}=l,f=t.onCommandExecute({id:ae.id,params:r}),S={id:p.SetDrawingApplyMutation.id,params:{unitId:h,subUnitId:u,op:m,objects:g,type:p.DrawingApplyType.REMOVE}},v={id:p.SetDrawingApplyMutation.id,params:{unitId:h,subUnitId:u,op:s,objects:g,type:p.DrawingApplyType.INSERT}};return d.sequenceExecute([...(M=f.preRedos)!=null?M:[],S,...f.redos],n)?(e.pushUndoRedo({unitID:h,undoMutations:[...(y=f.preUndos)!=null?y:[],v,...f.undos,{id:G.id,params:c}],redoMutations:[...(R=f.preRedos)!=null?R:[],S,...f.redos,{id:G.id,params:c}]}),!0):!1}},Xe="COMPONENT_SHEET_DRAWING_PANEL",be={id:"sidebar.operation.sheet-image",type:d.CommandType.COMMAND,handler:async(i,r)=>{const n=i.get(k.ISidebarService),e=i.get(d.LocaleService),t=i.get(d.IUniverInstanceService),o=i.get(P.IDrawingManagerService);if(!_.getSheetCommandTarget(t))return!1;switch(r.value){case"open":n.open({header:{title:e.t("sheetImage.panel.title")},children:{label:Xe},onClose:()=>{o.focusDrawing(null)},width:360});break;case"close":default:n.close();break}return!0}},Ee={id:"sheet.operation.edit-sheet-image",type:d.CommandType.OPERATION,handler:(i,r)=>{const n=i.get(P.IDrawingManagerService),e=i.get(d.ICommandService);return r==null?!1:(n.focusDrawing([r]),e.executeCommand(be.id,{value:"open"}),!0)}};var Oe={exports:{}},se={};/**
23
23
  * @license React
24
24
  * react-jsx-runtime.production.min.js
25
25
  *
@@ -27,12 +27,12 @@
27
27
  *
28
28
  * This source code is licensed under the MIT license found in the
29
29
  * LICENSE file in the root directory of this source tree.
30
- */var xe;function lt(){if(xe)return ae;xe=1;var i=x,r=Symbol.for("react.element"),n=Symbol.for("react.fragment"),e=Object.prototype.hasOwnProperty,t=i.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,o={key:!0,ref:!0,__self:!0,__source:!0};function a(c,l,h){var u,s={},g=null,m=null;h!==void 0&&(g=""+h),l.key!==void 0&&(g=""+l.key),l.ref!==void 0&&(m=l.ref);for(u in l)e.call(l,u)&&!o.hasOwnProperty(u)&&(s[u]=l[u]);if(c&&c.defaultProps)for(u in l=c.defaultProps,l)s[u]===void 0&&(s[u]=l[u]);return{$$typeof:r,type:c,key:g,ref:m,props:s,_owner:t.current}}return ae.Fragment=n,ae.jsx=a,ae.jsxs=a,ae}var Xe;function ut(){return Xe||(Xe=1,Ee.exports=lt()),Ee.exports}var $=ut();const ge={uploadLoading:"univer-upload-loading",uploadLoadingBody:"univer-upload-loading-body",uploadLoadingBodyAnimation:"univer-upload-loading-body-animation",univerCircleAnimation:"univer-UniverCircleAnimation",uploadLoadingBodyText:"univer-upload-loading-body-text"},gt=()=>{const i=d.useDependency(P.IImageIoService),r=d.useDependency(d.LocaleService),[n,e]=x.useState(0);return x.useEffect(()=>{const t=i.change$.subscribe(o=>{e(o)});return()=>{t.unsubscribe()}},[i]),$.jsx("div",{style:{display:n>0?"block":"none"},className:ge.uploadLoading,children:$.jsxs("div",{className:ge.uploadLoadingBody,children:[$.jsx("div",{className:ge.uploadLoadingBodyAnimation}),$.jsx("div",{className:ge.uploadLoadingBodyText,children:`${r.t("uploadLoading.loading")}: ${n}`})]})})};var mt=Object.defineProperty,ht=Object.getOwnPropertyDescriptor,pt=(i,r,n,e)=>{for(var t=e>1?void 0:e?ht(r,n):r,o=i.length-1,a;o>=0;o--)(a=i[o])&&(t=(e?a(r,n,t):a(t))||t);return e&&t&&mt(r,n,t),t},te=(i,r)=>(n,e)=>r(n,e,i);let me=class extends d.RxDisposable{constructor(r,n,e,t,o,a,c){super();Y(this,"_initImagePopupMenu",new Set);this._injector=r,this._drawingManagerService=n,this._canvasPopManagerService=e,this._renderManagerService=t,this._univerInstanceService=o,this._contextService=a,this._uiPartsService=c,this._init()}_init(){this._univerInstanceService.getCurrentTypeOfUnit$(d.UniverInstanceType.UNIVER_SHEET).pipe(W.takeUntil(this.dispose$)).subscribe(r=>this._create(r)),this._univerInstanceService.getTypeOfUnitDisposed$(d.UniverInstanceType.UNIVER_SHEET).pipe(W.takeUntil(this.dispose$)).subscribe(r=>this._dispose(r)),this._univerInstanceService.getAllUnitsForType(d.UniverInstanceType.UNIVER_SHEET).forEach(r=>this._create(r)),this._uiPartsService.registerComponent(k.BuiltInUIPart.CONTENT,()=>d.connectInjector(gt,this._injector))}_dispose(r){const n=r.getUnitId();this._renderManagerService.removeRender(n)}_create(r){if(!r)return;const n=r.getUnitId();this._renderManagerService.has(n)&&!this._initImagePopupMenu.has(n)&&(this._popupMenuListener(n),this._initImagePopupMenu.add(n))}_hasCropObject(r){const n=r.getAllObjectsByOrder();for(const e of n)if(e instanceof q.ImageCropperObject)return!0;return!1}_popupMenuListener(r){var o;const n=(o=this._renderManagerService.getRenderById(r))==null?void 0:o.scene;if(!n)return;const e=n.getTransformerByCreate();if(!e)return;let t;this.disposeWithMe(d.toDisposable(e.createControl$.subscribe(()=>{if(this._contextService.setContextValue(d.FOCUSING_COMMON_DRAWINGS,!0),this._hasCropObject(n))return;const a=e.getSelectedObjectMap();if(a.size>1){t==null||t.dispose();return}const c=a.values().next().value;if(!c)return;const l=c.oKey,h=this._drawingManagerService.getDrawingOKey(l);if(!h)return;const{unitId:u,subUnitId:s,drawingId:g,drawingType:m}=h,f=h.data;if(f&&f.disablePopup)return;t==null||t.dispose();const S=this._canvasPopManagerService.getFeatureMenu(u,s,g,m);t=this.disposeWithMe(this._canvasPopManagerService.attachPopupToObject(c,{componentKey:q.COMPONENT_IMAGE_POPUP_MENU,direction:"horizontal",offset:[2,0],extraProps:{menuItems:S||this._getImageMenuItems(u,s,g,m)}})),this._drawingManagerService.focusDrawing([{unitId:u,subUnitId:s,drawingId:g}])}))),this.disposeWithMe(e.clearControl$.subscribe(()=>{t==null||t.dispose(),this._contextService.setContextValue(d.FOCUSING_COMMON_DRAWINGS,!1),this._drawingManagerService.focusDrawing(null)})),this.disposeWithMe(e.changing$.subscribe(()=>{t==null||t.dispose()}))}_getImageMenuItems(r,n,e,t){return[{label:"image-popup.edit",index:0,commandId:be.id,commandParams:{unitId:r,subUnitId:n,drawingId:e},disable:t===d.DrawingTypeEnum.DRAWING_DOM},{label:"image-popup.delete",index:1,commandId:oe.id,commandParams:{unitId:r,drawings:[{unitId:r,subUnitId:n,drawingId:e}]},disable:!1},{label:"image-popup.crop",index:2,commandId:q.OpenImageCropOperation.id,commandParams:{unitId:r,subUnitId:n,drawingId:e},disable:t===d.DrawingTypeEnum.DRAWING_DOM},{label:"image-popup.reset",index:3,commandId:q.ImageResetSizeOperation.id,commandParams:[{unitId:r,subUnitId:n,drawingId:e}],disable:t===d.DrawingTypeEnum.DRAWING_DOM}]}};me=pt([te(0,d.Inject(d.Injector)),te(1,P.IDrawingManagerService),te(2,d.Inject(N.SheetCanvasPopManagerService)),te(3,U.IRenderManagerService),te(4,d.IUniverInstanceService),te(5,d.IContextService),te(6,d.Inject(k.IUIPartsService))],me);function V(i,r,n){const{from:e,to:t,flipY:o=!1,flipX:a=!1,angle:c=0,skewX:l=0,skewY:h=0}=i,{column:u,columnOffset:s,row:g,rowOffset:m}=e,{column:f,columnOffset:S,row:v,rowOffset:C}=t,M=n.getCurrentSkeleton(),y=N.attachRangeWithCoord(M,{startColumn:u,endColumn:u,startRow:g,endRow:g});if(y==null)return;const T=N.attachRangeWithCoord(M,{startColumn:f,endColumn:f,startRow:v,endRow:v});if(T==null)return;const{startX:I,startY:D}=y,{startX:w,startY:A}=T;let E=U.precisionTo(I+s,1),L=U.precisionTo(D+m,1),j=U.precisionTo(w+S-E,1),O=U.precisionTo(A+C-L,1);y.startX===T.endX&&(j=0),y.startY===T.endY&&(O=0);const R=M.rowHeaderWidth+M.columnTotalWidth,B=M.columnHeaderHeight+M.rowTotalHeight;return E+j>R&&(E=R-j),L+O>B&&(L=B-O),{flipY:o,flipX:a,angle:c,skewX:l,skewY:h,left:E,top:L,width:j,height:O}}function F(i,r){const{left:n=0,top:e=0,width:t=0,height:o=0,flipY:a=!1,flipX:c=!1,angle:l=0,skewX:h=0,skewY:u=0}=i,s=r.getCellWithCoordByOffset(n,e);if(s==null)return;const g={column:s.actualColumn,columnOffset:U.precisionTo(n-s.startX,1),row:s.actualRow,rowOffset:U.precisionTo(e-s.startY,1)},m=r.getCellWithCoordByOffset(n+t,e+o);if(m==null)return;const f={column:m.actualColumn,columnOffset:U.precisionTo(n+t-m.startX,1),row:m.actualRow,rowOffset:U.precisionTo(e+o-m.startY,1)};return{flipY:a,flipX:c,angle:l,skewX:h,skewY:u,from:g,to:f}}var ft=Object.defineProperty,St=Object.getOwnPropertyDescriptor,vt=(i,r,n,e)=>{for(var t=e>1?void 0:e?St(r,n):r,o=i.length-1,a;o>=0;o--)(a=i[o])&&(t=(e?a(r,n,t):a(t))||t);return e&&t&&ft(r,n,t),t},he=(i,r)=>(n,e)=>r(n,e,i);let Oe=class extends d.Disposable{constructor(i,r,n,e,t){super(),this._context=i,this._sheetDrawingService=r,this._drawingManagerService=n,this._sheetSelectionRenderService=e,this._sheetSkeletonManagerService=t,this._init()}_init(){this._drawingInitializeListener()}_drawingInitializeListener(){this._sheetDrawingService.initializeNotification(this._context.unitId);const i=this._sheetDrawingService.getDrawingDataForUnit(this._context.unitId);for(const r in i){const n=i[r];for(const e in n.data){const t=n.data[e];t.transform=V(t.sheetTransform,this._sheetSelectionRenderService,this._sheetSkeletonManagerService)}}this._drawingManagerService.registerDrawingData(this._context.unitId,this._sheetDrawingService.getDrawingDataForUnit(this._context.unitId)),this._drawingManagerService.initializeNotification(this._context.unitId)}};Oe=vt([he(1,p.ISheetDrawingService),he(2,P.IDrawingManagerService),he(3,d.Inject(N.ISheetSelectionRenderService)),he(4,d.Inject(N.SheetSkeletonManagerService))],Oe);function _t(i){const r=[];return i.forEach(n=>{const{parent:e,children:t}=n,{unitId:o,subUnitId:a,drawingId:c}=e,l=U.getGroupState(0,0,t.map(s=>s.transform||{})),h=t.map(s=>{const g=s.transform||{left:0,top:0},{unitId:m,subUnitId:f,drawingId:S}=s;return{unitId:m,subUnitId:f,drawingId:S,transform:{...g,left:g.left-l.left,top:g.top-l.top},groupId:c}}),u={unitId:o,subUnitId:a,drawingId:c,drawingType:d.DrawingTypeEnum.DRAWING_GROUP,transform:l};r.push({parent:u,children:h})}),r}function wt(i){const r=[];return i.forEach(n=>{const{parent:e,children:t}=n,{unitId:o,subUnitId:a,drawingId:c,transform:l={width:0,height:0}}=e;if(l==null)return;const h=t.map(s=>{const{transform:g}=s,{unitId:m,subUnitId:f,drawingId:S}=s,v=U.transformObjectOutOfGroup(g||{},l,l.width||0,l.height||0);return{unitId:m,subUnitId:f,drawingId:S,transform:v,groupId:void 0}}),u={unitId:o,subUnitId:a,drawingId:c,drawingType:d.DrawingTypeEnum.DRAWING_GROUP,transform:{left:0,top:0}};r.push({parent:u,children:h})}),r}const Pe={id:"sheet.command.group-sheet-image",type:d.CommandType.COMMAND,handler:(i,r)=>{const n=i.get(d.ICommandService),e=i.get(d.IUndoRedoService),t=i.get(p.ISheetDrawingService);if(!r)return!1;const o=[];r.forEach(({parent:m,children:f})=>{o.push(m.unitId),f.forEach(S=>{o.push(S.unitId)})});const a=t.getGroupDrawingOp(r),{unitId:c,subUnitId:l,undo:h,redo:u,objects:s}=a;return n.syncExecuteCommand(p.SetDrawingApplyMutation.id,{op:u,unitId:c,subUnitId:l,objects:s,type:p.DrawingApplyType.GROUP})?(e.pushUndoRedo({unitID:c,undoMutations:[{id:p.SetDrawingApplyMutation.id,params:{op:h,unitId:c,subUnitId:l,objects:wt(s),type:p.DrawingApplyType.UNGROUP}},{id:G.id,params:o}],redoMutations:[{id:p.SetDrawingApplyMutation.id,params:{op:u,unitId:c,subUnitId:l,objects:s,type:p.DrawingApplyType.GROUP}},{id:G.id,params:o}]}),!0):!1}},se={id:"sheet.command.insert-sheet-image",type:d.CommandType.COMMAND,handler:(i,r)=>{var M,y,T;const n=i.get(d.ICommandService),e=i.get(d.IUndoRedoService),t=i.get(p.ISheetDrawingService),o=i.get(_.SheetInterceptorService);if(!r)return!1;const a=r.drawings,c=a.map(I=>I.unitId),l=t.getBatchAddOp(a),{unitId:h,subUnitId:u,undo:s,redo:g,objects:m}=l,f=o.onCommandExecute({id:se.id,params:r}),S={id:p.SetDrawingApplyMutation.id,params:{op:g,unitId:h,subUnitId:u,objects:m,type:p.DrawingApplyType.INSERT}},v={id:p.SetDrawingApplyMutation.id,params:{op:s,unitId:h,subUnitId:u,objects:m,type:p.DrawingApplyType.REMOVE}};return d.sequenceExecute([...(M=f.preRedos)!=null?M:[],S,...f.redos],n)?(e.pushUndoRedo({unitID:h,undoMutations:[...(y=f.preUndos)!=null?y:[],v,...f.undos,{id:G.id,params:c}],redoMutations:[...(T=f.preRedos)!=null?T:[],S,...f.redos,{id:G.id,params:c}]}),!0):!1}},Ae={id:"sheet.command.set-drawing-arrange",type:d.CommandType.COMMAND,handler:(i,r)=>{const n=i.get(d.ICommandService),e=i.get(d.IUndoRedoService);if(!r)return!1;const t=i.get(p.ISheetDrawingService),{unitId:o,subUnitId:a,drawingIds:c,arrangeType:l}=r,h={unitId:o,subUnitId:a,drawingIds:c};let u;if(l===d.ArrangeTypeEnum.forward?u=t.getForwardDrawingsOp(h):l===d.ArrangeTypeEnum.backward?u=t.getBackwardDrawingOp(h):l===d.ArrangeTypeEnum.front?u=t.getFrontDrawingsOp(h):l===d.ArrangeTypeEnum.back&&(u=t.getBackDrawingsOp(h)),u==null)return!1;const{objects:s,redo:g,undo:m}=u;return n.syncExecuteCommand(p.SetDrawingApplyMutation.id,{op:g,unitId:o,subUnitId:a,objects:s,type:p.DrawingApplyType.ARRANGE})?(e.pushUndoRedo({unitID:o,undoMutations:[{id:p.SetDrawingApplyMutation.id,params:{op:m,unitId:o,subUnitId:a,objects:s,type:p.DrawingApplyType.ARRANGE}}],redoMutations:[{id:p.SetDrawingApplyMutation.id,params:{op:g,unitId:o,subUnitId:a,objects:s,type:p.DrawingApplyType.ARRANGE}}]}),!0):!1}},ce={id:"sheet.command.set-sheet-image",type:d.CommandType.COMMAND,handler:(i,r)=>{const n=i.get(d.ICommandService),e=i.get(d.IUndoRedoService),t=i.get(p.ISheetDrawingService);if(!r)return!1;const{drawings:o}=r,a=t.getBatchUpdateOp(o),{unitId:c,subUnitId:l,undo:h,redo:u,objects:s}=a;return n.syncExecuteCommand(p.SetDrawingApplyMutation.id,{unitId:c,subUnitId:l,op:u,objects:s,type:p.DrawingApplyType.UPDATE})?(e.pushUndoRedo({unitID:c,undoMutations:[{id:p.SetDrawingApplyMutation.id,params:{unitId:c,subUnitId:l,op:h,objects:s,type:p.DrawingApplyType.UPDATE}},{id:G.id,params:[c]}],redoMutations:[{id:p.SetDrawingApplyMutation.id,params:{unitId:c,subUnitId:l,op:u,objects:s,type:p.DrawingApplyType.UPDATE}},{id:G.id,params:[c]}]}),!0):!1}},Ue={id:"sheet.command.ungroup-sheet-image",type:d.CommandType.COMMAND,handler:(i,r)=>{const n=i.get(d.ICommandService),e=i.get(d.IUndoRedoService),t=i.get(p.ISheetDrawingService);if(!r)return!1;const o=[];r.forEach(({parent:m,children:f})=>{o.push(m.unitId),f.forEach(S=>{o.push(S.unitId)})});const a=t.getUngroupDrawingOp(r),{unitId:c,subUnitId:l,undo:h,redo:u,objects:s}=a;return n.syncExecuteCommand(p.SetDrawingApplyMutation.id,{op:u,unitId:c,subUnitId:l,objects:s,type:p.DrawingApplyType.UNGROUP})?(e.pushUndoRedo({unitID:c,undoMutations:[{id:p.SetDrawingApplyMutation.id,params:{op:h,unitId:c,subUnitId:l,objects:_t(s),type:p.DrawingApplyType.GROUP}},{id:G.id,params:o}],redoMutations:[{id:p.SetDrawingApplyMutation.id,params:{op:u,unitId:c,subUnitId:l,objects:s,type:p.DrawingApplyType.UNGROUP}},{id:G.id,params:o}]}),!0):!1}};var It=Object.defineProperty,Ct=Object.getOwnPropertyDescriptor,yt=(i,r,n,e)=>{for(var t=e>1?void 0:e?Ct(r,n):r,o=i.length-1,a;o>=0;o--)(a=i[o])&&(t=(e?a(r,n,t):a(t))||t);return e&&t&&It(r,n,t),t},z=(i,r)=>(n,e)=>r(n,e,i);function Mt(i,r,n){const e=n*Math.PI/180,t=Math.abs(i*Math.cos(e))+Math.abs(r*Math.sin(e)),o=Math.abs(i*Math.sin(e))+Math.abs(r*Math.cos(e));return{rotatedWidth:t,rotatedHeight:o}}function ze(i,r,n,e,t){var M;const{rotatedHeight:o,rotatedWidth:a}=Mt(n,e,t),l=i.get(U.IRenderManagerService).getRenderById(r.unitId);if(!l)return!1;const u=(M=l.with(N.SheetSkeletonManagerService).getWorksheetSkeleton(r.subUnitId))==null?void 0:M.skeleton;if(u==null)return!1;const s=u.getCellByIndex(r.row,r.col),g=s.mergeInfo.endX-s.mergeInfo.startX-2,m=s.mergeInfo.endY-s.mergeInfo.startY-2,f=a/o,v=Math.ceil(Math.min(g,m*f))/a,C=!v||Number.isNaN(v)?.001:v;return{width:n*C,height:e*C}}let de=class extends d.Disposable{constructor(r,n,e,t,o,a,c,l,h,u,s,g,m){super();Y(this,"_workbookSelections");this._context=r,this._skeletonManagerService=n,this._commandService=e,this._selectionRenderService=t,this._imageIoService=o,this._fileOpenerService=a,this._sheetDrawingService=c,this._drawingManagerService=l,this._contextService=h,this._messageService=u,this._localeService=s,this._injector=m,this._workbookSelections=g.getWorkbookSelections(this._context.unitId),this._updateImageListener(),this._updateOrderListener(),this._groupDrawingListener(),this._focusDrawingListener()}async insertFloatImage(){const r=await this._fileOpenerService.openFile({multiple:!0,accept:P.DRAWING_IMAGE_ALLOW_IMAGE_LIST.map(e=>`.${e.replace("image/","")}`).join(",")}),n=r.length;return n>P.DRAWING_IMAGE_COUNT_LIMIT?(this._messageService.show({type:J.MessageType.Error,content:this._localeService.t("update-status.exceedMaxCount",String(P.DRAWING_IMAGE_COUNT_LIMIT))}),!1):n===0?!1:(r.forEach(async e=>await this._insertFloatImage(e)),!0)}async insertCellImage(){const n=(await this._fileOpenerService.openFile({multiple:!1,accept:P.DRAWING_IMAGE_ALLOW_IMAGE_LIST.map(e=>`.${e.replace("image/","")}`).join(",")}))[0];return n?(await this._insertCellImage(n),!0):!1}async _insertFloatImage(r){let n;try{n=await this._imageIoService.saveImage(r)}catch(M){const y=M.message;y===P.ImageUploadStatusType.ERROR_EXCEED_SIZE?this._messageService.show({type:J.MessageType.Error,content:this._localeService.t("update-status.exceedMaxSize",String(P.DRAWING_IMAGE_ALLOW_SIZE/(1024*1024)))}):y===P.ImageUploadStatusType.ERROR_IMAGE_TYPE?this._messageService.show({type:J.MessageType.Error,content:this._localeService.t("update-status.invalidImageType")}):y===P.ImageUploadStatusType.ERROR_IMAGE&&this._messageService.show({type:J.MessageType.Error,content:this._localeService.t("update-status.invalidImage")})}if(n==null)return;const e=this._getUnitInfo(),{unitId:t,subUnitId:o}=e,{imageId:a,imageSourceType:c,source:l,base64Cache:h}=n,{width:u,height:s,image:g}=await P.getImageSize(h||""),{width:m,height:f}=this._context.scene;this._imageIoService.addImageSourceCache(l,c,g);let S=1;if(u>P.DRAWING_IMAGE_WIDTH_LIMIT||s>P.DRAWING_IMAGE_HEIGHT_LIMIT){const M=P.DRAWING_IMAGE_WIDTH_LIMIT/u,y=P.DRAWING_IMAGE_HEIGHT_LIMIT/s;S=Math.max(M,y)}const v=this._getImagePosition(u*S,s*S,m,f);if(v==null)return;const C={unitId:t,subUnitId:o,drawingId:a,drawingType:d.DrawingTypeEnum.DRAWING_IMAGE,imageSourceType:c,source:l,transform:V(v,this._selectionRenderService,this._skeletonManagerService),sheetTransform:v};this._commandService.executeCommand(se.id,{unitId:t,drawings:[C]})}async _insertCellImage(r){let n;try{n=await this._imageIoService.saveImage(r)}catch(v){const C=v.message;C===P.ImageUploadStatusType.ERROR_EXCEED_SIZE?this._messageService.show({type:J.MessageType.Error,content:this._localeService.t("update-status.exceedMaxSize",String(P.DRAWING_IMAGE_ALLOW_SIZE/(1024*1024)))}):C===P.ImageUploadStatusType.ERROR_IMAGE_TYPE?this._messageService.show({type:J.MessageType.Error,content:this._localeService.t("update-status.invalidImageType")}):C===P.ImageUploadStatusType.ERROR_IMAGE&&this._messageService.show({type:J.MessageType.Error,content:this._localeService.t("update-status.invalidImage")})}if(n==null)return;const{imageId:e,imageSourceType:t,source:o,base64Cache:a}=n,{width:c,height:l,image:h}=await P.getImageSize(a||"");this._imageIoService.addImageSourceCache(o,t,h);const u=this._workbookSelections.getCurrentLastSelection();if(!u)return!1;const s=d.createDocumentModelWithStyle("",{}),g=ze(this._injector,{unitId:this._context.unitId,subUnitId:this._context.unit.getActiveSheet().getSheetId(),row:u.primary.actualRow,col:u.primary.actualColumn},c,l,0);if(!g)return!1;const m={size:{width:g.width,height:g.height},positionH:{relativeFrom:d.ObjectRelativeFromH.PAGE,posOffset:0},positionV:{relativeFrom:d.ObjectRelativeFromV.PARAGRAPH,posOffset:0},angle:0},f={unitId:s.getUnitId(),subUnitId:s.getUnitId(),drawingId:e,drawingType:d.DrawingTypeEnum.DRAWING_IMAGE,imageSourceType:t,source:o,transform:Ve.docDrawingPositionToTransform(m),docTransform:m,behindDoc:d.BooleanNumber.FALSE,title:"",description:"",layoutType:d.PositionedObjectLayoutType.INLINE,wrapText:d.WrapTextType.BOTH_SIDES,distB:0,distL:0,distR:0,distT:0},S=d.BuildTextUtils.drawing.add({documentDataModel:s,drawings:[f],selection:{collapsed:!0,startOffset:0,endOffset:0}});return S?(s.apply(S),this._commandService.syncExecuteCommand(_.SetRangeValuesCommand.id,{value:{[u.primary.actualRow]:{[u.primary.actualColumn]:{p:s.getSnapshot(),t:1}}}})):!1}_getUnitInfo(){const r=this._context.unit,n=r.getActiveSheet(),e=r.getUnitId(),t=n.getSheetId();return{unitId:e,subUnitId:t}}_getImagePosition(r,n,e,t){const o=this._workbookSelections.getCurrentSelections();let a={startRow:0,endRow:0,startColumn:0,endColumn:0};o&&o.length>0&&(a=o[o.length-1].range);const c=N.attachRangeWithCoord(this._skeletonManagerService.getCurrent().skeleton,a);if(c==null)return;let{startColumn:l,startRow:h,startX:u,startY:s}=c,g=!1;if(u+r>e&&(u=e-r,u<0&&(u=0,r=e),g=!0),s+n>t&&(s=t-n,s<0&&(s=0,n=t),g=!0),g){const v=this._selectionRenderService.getCellWithCoordByOffset(u,s);if(v==null)return;u=v.startX,s=v.startY,l=v.actualColumn,h=v.actualRow}const m={column:l,columnOffset:0,row:h,rowOffset:0},f=this._selectionRenderService.getCellWithCoordByOffset(u+r,s+n);if(f==null)return;const S={column:f.actualColumn,columnOffset:u+r-f.startX,row:f.actualRow,rowOffset:s+n-f.startY};return{from:m,to:S}}_updateOrderListener(){this.disposeWithMe(this._drawingManagerService.featurePluginOrderUpdate$.subscribe(r=>{const{unitId:n,subUnitId:e,drawingIds:t,arrangeType:o}=r;this._commandService.executeCommand(Ae.id,{unitId:n,subUnitId:e,drawingIds:t,arrangeType:o})}))}_updateImageListener(){this.disposeWithMe(this._drawingManagerService.featurePluginUpdate$.subscribe(r=>{const n=[];r.length!==0&&(r.forEach(e=>{const{unitId:t,subUnitId:o,drawingId:a,drawingType:c,transform:l}=e;if(l==null)return;const h=this._sheetDrawingService.getDrawingByParam({unitId:t,subUnitId:o,drawingId:a});if(h==null||h.unitId!==this._context.unitId)return;const u=F({...h.transform,...l},this._selectionRenderService);if(u==null)return;const s={...e,transform:{...h.transform,...l,...V(u,this._selectionRenderService,this._skeletonManagerService)},sheetTransform:{...u}};n.push(s)}),n.length>0&&this._commandService.executeCommand(ce.id,{unitId:r[0].unitId,drawings:n}))}))}_groupDrawingListener(){this.disposeWithMe(this._drawingManagerService.featurePluginGroupUpdate$.subscribe(r=>{this._commandService.executeCommand(Pe.id,r);const{unitId:n,subUnitId:e,drawingId:t}=r[0].parent;this._drawingManagerService.focusDrawing([{unitId:n,subUnitId:e,drawingId:t}])})),this.disposeWithMe(this._drawingManagerService.featurePluginUngroupUpdate$.subscribe(r=>{this._commandService.executeCommand(Ue.id,r)}))}_focusDrawingListener(){this.disposeWithMe(this._drawingManagerService.focus$.subscribe(r=>{r==null||r.length===0?(this._contextService.setContextValue(d.FOCUSING_COMMON_DRAWINGS,!1),this._sheetDrawingService.focusDrawing([])):(this._contextService.setContextValue(d.FOCUSING_COMMON_DRAWINGS,!0),this._sheetDrawingService.focusDrawing(r))}))}};de=yt([z(1,d.Inject(N.SheetSkeletonManagerService)),z(2,d.ICommandService),z(3,N.ISheetSelectionRenderService),z(4,P.IImageIoService),z(5,k.ILocalFileService),z(6,p.ISheetDrawingService),z(7,P.IDrawingManagerService),z(8,d.IContextService),z(9,k.IMessageService),z(10,d.Inject(d.LocaleService)),z(11,d.Inject(_.SheetsSelectionsService)),z(12,d.Inject(d.Injector))],de);var Dt=Object.defineProperty,Rt=Object.getOwnPropertyDescriptor,Tt=(i,r,n,e)=>{for(var t=e>1?void 0:e?Rt(r,n):r,o=i.length-1,a;o>=0;o--)(a=i[o])&&(t=(e?a(r,n,t):a(t))||t);return e&&t&&Dt(r,n,t),t},ne=(i,r)=>(n,e)=>r(n,e,i);function Ne(i,r,n){var e,t,o,a;if(((t=(e=n==null?void 0:n.p)==null?void 0:e.body)==null?void 0:t.dataStream.length)===3&&((a=(o=n.p)==null?void 0:o.drawingsOrder)==null?void 0:a.length)===1){const c=n.p.drawings[n.p.drawingsOrder[0]],l=ze(i,{unitId:r.unitId,subUnitId:r.subUnitId,row:r.row,col:r.col},c.docTransform.size.width,c.docTransform.size.height,c.docTransform.angle);if(l)return c.transform.width=l.width,c.transform.height=l.height,c.docTransform.size.width=l.width,c.docTransform.size.height=l.height,c.transform.left=0,c.transform.top=0,c.docTransform.positionH.posOffset=0,c.docTransform.positionV.posOffset=0,n.p.documentStyle.pageSize.width=1/0,n.p.documentStyle.pageSize.height=1/0,!0}return!1}let pe=class extends d.Disposable{constructor(i,r,n,e,t,o,a){super(),this._commandService=i,this._sheetInterceptorService=r,this._univerInstanceService=n,this._injector=e,this._drawingManagerService=t,this._docDrawingController=o,this._editorBridgeService=a,this._initHandleResize(),this._handleInitEditor(),this._handleWriteCell(),this._initCellContentInterceptor()}_initHandleResize(){this.disposeWithMe(this._commandService.onCommandExecuted(i=>{let r,n=[];if(i.id===_.SetWorksheetRowHeightMutation.id){const e=i.params;n=e.ranges,r=_.getSheetCommandTarget(this._univerInstanceService,{unitId:e.unitId,subUnitId:e.subUnitId})}else if(i.id===_.SetWorksheetColWidthMutation.id){const e=i.params;n=e.ranges,r=_.getSheetCommandTarget(this._univerInstanceService,{unitId:e.unitId,subUnitId:e.subUnitId})}else if(i.id===_.SetWorksheetRowIsAutoHeightMutation.id){const e=i.params;n=e.ranges,r=_.getSheetCommandTarget(this._univerInstanceService,{unitId:e.unitId,subUnitId:e.subUnitId})}else if(i.id===_.SetWorksheetRowAutoHeightMutation.id){const e=i.params;r=_.getSheetCommandTarget(this._univerInstanceService,{unitId:e.unitId,subUnitId:e.subUnitId}),n=e.rowsAutoHeightInfo.map(t=>({startRow:t.row,endRow:t.row,startColumn:0,endColumn:9999}))}else if(i.id===_.AddWorksheetMergeMutation.id){const e=i.params;n=e.ranges,r=_.getSheetCommandTarget(this._univerInstanceService,{unitId:e.unitId,subUnitId:e.subUnitId})}else if(i.id===_.RemoveWorksheetMergeMutation.id){const e=i.params;n=e.ranges,r=_.getSheetCommandTarget(this._univerInstanceService,{unitId:e.unitId,subUnitId:e.subUnitId})}r&&n.length&&n.forEach(e=>{const t=d.Range.transformRange(e,r.worksheet);for(let o=t.startRow;o<=t.endRow;o++)for(let a=t.startColumn;a<=t.endColumn;a++)Ne(this._injector,{unitId:r.unitId,subUnitId:r.subUnitId,row:o,col:a},r.worksheet.getCellRaw(o,a))})}))}_handleInitEditor(){this.disposeWithMe(this._editorBridgeService.visible$.subscribe(i=>{i.visible?i.visible&&(this._drawingManagerService.removeDrawingDataForUnit(d.DOCS_NORMAL_EDITOR_UNIT_ID_KEY),this._docDrawingController.loadDrawingDataForUnit(d.DOCS_NORMAL_EDITOR_UNIT_ID_KEY),this._drawingManagerService.initializeNotification(d.DOCS_NORMAL_EDITOR_UNIT_ID_KEY)):this._drawingManagerService.removeDrawingDataForUnit(d.DOCS_NORMAL_EDITOR_UNIT_ID_KEY)})),this.disposeWithMe(this._commandService.onCommandExecuted(i=>{i.id===Ve.ReplaceSnapshotCommand.id&&i.params.unitId===d.DOCS_ZEN_EDITOR_UNIT_ID_KEY&&(this._drawingManagerService.removeDrawingDataForUnit(d.DOCS_ZEN_EDITOR_UNIT_ID_KEY),this._docDrawingController.loadDrawingDataForUnit(d.DOCS_ZEN_EDITOR_UNIT_ID_KEY),this._drawingManagerService.initializeNotification(d.DOCS_ZEN_EDITOR_UNIT_ID_KEY))}))}_handleWriteCell(){this.disposeWithMe(this._sheetInterceptorService.writeCellInterceptor.intercept(_.AFTER_CELL_EDIT,{priority:9999,handler:(i,r,n)=>(Ne(this._injector,{unitId:r.unitId,subUnitId:r.subUnitId,row:r.row,col:r.col},i),n(i))}))}_initCellContentInterceptor(){this.disposeWithMe(this._sheetInterceptorService.intercept(_.INTERCEPTOR_POINT.CELL_CONTENT,{effect:d.InterceptorEffectEnum.Style,priority:_.InterceptCellContentPriority.CELL_IMAGE,handler:(i,r,n)=>{var e;return i!=null&&i.p&&((e=i.p.drawingsOrder)!=null&&e.length)&&(i.interceptorStyle||(i.interceptorStyle={}),i.interceptorStyle.tr={a:0}),n(i)}}))}};pe=Tt([ne(0,d.ICommandService),ne(1,d.Inject(_.SheetInterceptorService)),ne(2,d.IUniverInstanceService),ne(3,d.Inject(d.Injector)),ne(4,P.IDrawingManagerService),ne(5,d.Inject(st.DocDrawingController)),ne(6,d.Inject(N.IEditorBridgeService))],pe);var bt=Object.defineProperty,Et=Object.getOwnPropertyDescriptor,Ot=(i,r,n,e)=>{for(var t=e>1?void 0:e?Et(r,n):r,o=i.length-1,a;o>=0;o--)(a=i[o])&&(t=(e?a(r,n,t):a(t))||t);return e&&t&&bt(r,n,t),t},Ke=(i,r)=>(n,e)=>r(n,e,i);let fe=class extends d.Disposable{constructor(i,r){super(),this._autoFillService=i,this._injector=r,this._initAutoFillHooks()}_initAutoFillHooks(){this.disposeWithMe(this._autoFillService.addHook({id:"sheet-cell-image-autofill",onBeforeSubmit:(i,r,n,e)=>{new d.ObjectMatrix(e).forValue((t,o,a)=>{Ne(this._injector,{unitId:i.unitId,subUnitId:i.subUnitId,row:t,col:o},a)})}}))}};fe=Ot([Ke(0,d.Inject(N.IAutoFillService)),Ke(1,d.Inject(d.Injector))],fe);var Pt=Object.defineProperty,At=Object.getOwnPropertyDescriptor,Ut=(i,r,n,e)=>{for(var t=e>1?void 0:e?At(r,n):r,o=i.length-1,a;o>=0;o--)(a=i[o])&&(t=(e?a(r,n,t):a(t))||t);return e&&t&&Pt(r,n,t),t},Se=(i,r)=>(n,e)=>r(n,e,i);let ve=class extends d.Disposable{constructor(r,n,e,t){super();Y(this,"_isSetCursor",!1);this._hoverManagerService=r,this._renderManagerService=n,this._selectionsService=e,this._drawingRenderService=t}_initHover(){}_initImageClick(){}};ve=Ut([Se(0,d.Inject(N.HoverManagerService)),Se(1,d.Inject(U.IRenderManagerService)),Se(2,d.Inject(_.SheetsSelectionsService)),Se(3,d.Inject(q.DrawingRenderService))],ve);var Nt=Object.defineProperty,jt=Object.getOwnPropertyDescriptor,Wt=(i,r,n,e)=>{for(var t=e>1?void 0:e?jt(r,n):r,o=i.length-1,a;o>=0;o--)(a=i[o])&&(t=(e?a(r,n,t):a(t))||t);return e&&t&&Nt(r,n,t),t},je=(i,r)=>(n,e)=>r(n,e,i);let _e=class extends d.Disposable{constructor(r,n,e){super();Y(this,"_copyInfo");this._sheetClipboardService=r,this._renderManagerService=n,this._sheetDrawingService=e,this._initCopyPaste()}_initCopyPaste(){this._sheetClipboardService.addClipboardHook({id:"SHEET_IMAGE_UI_PLUGIN",onBeforeCopy:(r,n,e)=>this._collect(r,n,e),onPasteCells:(r,n,e,t)=>{const{copyType:o=N.COPY_TYPE.COPY,pasteType:a}=t,{range:c}=r||{},{range:l,unitId:h,subUnitId:u}=n;return this._generateMutations(l,{copyType:o,pasteType:a,copyRange:c,unitId:h,subUnitId:u})},onPastePlainText:(r,n)=>({undos:[],redos:[]})})}_collect(r,n,e){var g;const t=(g=this._renderManagerService.getRenderById(r))==null?void 0:g.with(N.SheetSkeletonManagerService);if(!t)return;const o=t.attachRangeWithCoord(e);if(!o)return;const{startX:a,endX:c,startY:l,endY:h}=o,u=this._sheetDrawingService.getDrawingData(r,n),s=[];Object.keys(u).forEach(m=>{const f=u[m],{transform:S}=f;if(f.anchorType!==p.SheetDrawingAnchorType.Both||!S)return;const{left:v=0,top:C=0,width:M=0,height:y=0}=S,{drawingStartX:T,drawingEndX:I,drawingStartY:D,drawingEndY:w}={drawingStartX:v,drawingEndX:v+M,drawingStartY:C,drawingEndY:C+y};a<=T&&I<=c&&l<=D&&w<=h&&s.push(f)}),s.length&&(this._copyInfo={drawings:s,unitId:r,subUnitId:n})}_generateMutations(r,n){var E;if(!this._copyInfo)return{redos:[],undos:[]};if([N.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_COL_WIDTH,N.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_VALUE,N.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMAT,N.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMULA].includes(n.pasteType))return{redos:[],undos:[]};const{copyRange:e}=n;if(!e)return{redos:[],undos:[]};const{drawings:t,unitId:o,subUnitId:a}=this._copyInfo,{ranges:[c,l],mapFunc:h}=N.virtualizeDiscreteRanges([e,r]),{row:u,col:s}=h(c.startRow,c.startColumn),{row:g,col:m}=h(l.startRow,l.startColumn),f=(E=this._renderManagerService.getRenderById(o))==null?void 0:E.with(N.SheetSkeletonManagerService);if(!f)return{redos:[],undos:[]};const S=f.attachRangeWithCoord({startRow:u,endRow:u,startColumn:s,endColumn:s}),v=f.attachRangeWithCoord({startRow:g,endRow:g,startColumn:m,endColumn:m});if(!S||!v)return{redos:[],undos:[]};const C=[],M=[],y=v.startX-S.startX,T=v.startY-S.startY,I=g-u,D=m-s,w=n.copyType===N.COPY_TYPE.CUT,{_sheetDrawingService:A}=this;return t.forEach(L=>{const{transform:j,sheetTransform:O}=L;if(!j)return;const R={...L,unitId:o,subUnitId:a,drawingId:w?L.drawingId:d.Tools.generateRandomId(),transform:{...j,left:j.left+y,top:j.top+T},sheetTransform:{to:{...O.to,row:O.to.row+I,column:O.to.column+D},from:{...O.from,row:O.from.row+I,column:O.from.column+D}}};if(w){const{undo:B,redo:H,objects:Z}=A.getBatchUpdateOp([R]);C.push({id:p.SetDrawingApplyMutation.id,params:{unitId:o,subUnitId:a,type:p.DrawingApplyType.UPDATE,op:H,objects:Z}}),M.push({id:p.SetDrawingApplyMutation.id,params:{unitId:o,subUnitId:a,type:p.DrawingApplyType.UPDATE,op:B,objects:Z}})}else{const{undo:B,redo:H,objects:Z}=A.getBatchAddOp([R]);C.push({id:p.SetDrawingApplyMutation.id,params:{op:H,unitId:o,subUnitId:a,objects:Z,type:p.DrawingApplyType.INSERT}}),M.push({id:p.SetDrawingApplyMutation.id,params:{op:B,unitId:o,subUnitId:a,objects:Z,type:p.DrawingApplyType.REMOVE}})}}),{redos:C,undos:M}}};_e=Wt([je(0,N.ISheetClipboardService),je(1,U.IRenderManagerService),je(2,p.ISheetDrawingService)],_e);var Lt=Object.defineProperty,Bt=Object.getOwnPropertyDescriptor,Gt=(i,r,n,e)=>{for(var t=e>1?void 0:e?Bt(r,n):r,o=i.length-1,a;o>=0;o--)(a=i[o])&&(t=(e?a(r,n,t):a(t))||t);return e&&t&&Lt(r,n,t),t},le=(i,r)=>(n,e)=>r(n,e,i);let we=class extends d.Disposable{constructor(i,r,n,e,t){super(),this._drawingManagerService=i,this._renderManagerService=r,this._permissionService=n,this._univerInstanceService=e,this._userManagerService=t,this._initDrawingVisible(),this._initDrawingEditable(),this._initViewPermissionChange(),this._initEditPermissionChange()}_initDrawingVisible(){const i=this._univerInstanceService.getCurrentTypeOfUnit$(d.UniverInstanceType.UNIVER_SHEET);this.disposeWithMe(W.combineLatest([i,this._userManagerService.currentUser$]).subscribe(([r,n])=>{if(!r){this._drawingManagerService.setDrawingVisible(!1);return}r.activeSheet$.subscribe(e=>{if(!e){this._drawingManagerService.setDrawingVisible(!1);return}const t=r.getUnitId(),o=e.getSheetId();if(this._permissionService.composePermission([new _.WorkbookViewPermission(t).id,new _.WorksheetViewPermission(t,o).id]).every(c=>c.value))this._drawingManagerService.setDrawingVisible(!0);else{this._drawingManagerService.setDrawingVisible(!1);const c=r.getUnitId(),l=e.getSheetId(),h=this._drawingManagerService.getDrawingData(c,l),u=Object.values(h),s=this._renderManagerService.getRenderById(c),g=s==null?void 0:s.scene;if(g==null)return;g.getAllObjectsByOrder().forEach(f=>{f.classType===U.RENDER_CLASS_TYPE.IMAGE&&u.some(S=>f.oKey.includes(S.drawingId))&&g.removeObject(f)})}})}))}_initDrawingEditable(){const i=this._univerInstanceService.getCurrentTypeOfUnit$(d.UniverInstanceType.UNIVER_SHEET);this.disposeWithMe(W.combineLatest([i,this._userManagerService.currentUser$]).subscribe(([r,n])=>{if(!r){this._drawingManagerService.setDrawingEditable(!1);return}r.activeSheet$.subscribe(e=>{if(!e){this._drawingManagerService.setDrawingEditable(!1);return}const t=r.getUnitId(),o=e.getSheetId();if(this._permissionService.composePermission([new _.WorkbookEditablePermission(t).id,new _.WorksheetEditPermission(t,o).id]).every(c=>c.value))this._drawingManagerService.setDrawingEditable(!0);else{this._drawingManagerService.setDrawingEditable(!1);const c=r.getUnitId(),l=e.getSheetId(),h=this._drawingManagerService.getDrawingData(c,l),u=Object.values(h),s=this._renderManagerService.getRenderById(c),g=s==null?void 0:s.scene;if(g==null)return;g.getAllObjectsByOrder().forEach(f=>{f.classType===U.RENDER_CLASS_TYPE.IMAGE&&u.some(S=>f.oKey.includes(S.drawingId))&&g.detachTransformerFrom(f)})}})}))}_initViewPermissionChange(){const i=this._univerInstanceService.getCurrentTypeOfUnit$(d.UniverInstanceType.UNIVER_SHEET);this.disposeWithMe(W.combineLatest([i,this._userManagerService.currentUser$]).subscribe(([r,n])=>{r&&r.activeSheet$.subscribe(e=>{var s;if(!e)return;const t=r.getUnitId(),o=e.getSheetId();let a=!0;const c=this._renderManagerService.getRenderById(t),l=c==null?void 0:c.scene;if(l==null)return;const h=l.getTransformerByCreate(),u=this._permissionService.composePermission$([new _.WorkbookViewPermission(t).id,new _.WorksheetViewPermission(t,o).id]).pipe(W.map(g=>g.every(m=>m.value)));u==null||u.pipe(W.filter(g=>g!==a),W.distinctUntilChanged()).subscribe({next:g=>{a=g,this._drawingManagerService.setDrawingVisible(g);const m=l.getAllObjectsByOrder(),f=this._drawingManagerService.getDrawingData(t,o),S=Object.values(f);g?this._drawingManagerService.addNotification(S):(m.forEach(v=>{v.classType===U.RENDER_CLASS_TYPE.IMAGE&&S.some(C=>v.oKey.includes(C.drawingId))&&l.removeObject(v)}),h.clearSelectedObjects())}}),(s=this._permissionService.getPermissionPoint$(new _.WorksheetViewPermission(t,o).id))==null||s.pipe(W.filter(g=>g.value!==a),W.distinctUntilChanged()).subscribe({complete:()=>{a=!0,this._drawingManagerService.setDrawingVisible(!0);const g=this._drawingManagerService.getDrawingData(t,o),m=Object.values(g);this._drawingManagerService.addNotification(m)}})})}))}_initEditPermissionChange(){const i=this._univerInstanceService.getCurrentTypeOfUnit$(d.UniverInstanceType.UNIVER_SHEET);this.disposeWithMe(W.combineLatest([i,this._userManagerService.currentUser$]).subscribe(([r,n])=>{r&&r.activeSheet$.subscribe(e=>{var s;if(!e)return;const t=r.getUnitId(),o=e.getSheetId();let a=!0;const c=this._renderManagerService.getRenderById(t),l=c==null?void 0:c.scene;if(l==null)return;const h=l.getTransformerByCreate(),u=this._permissionService.composePermission$([new _.WorkbookEditablePermission(t).id,new _.WorksheetEditPermission(t,o).id]).pipe(W.map(g=>g.every(m=>m.value)));u==null||u.pipe(W.filter(g=>g!==a),W.distinctUntilChanged()).subscribe({next:g=>{a=g,this._drawingManagerService.setDrawingEditable(g);const m=l.getAllObjectsByOrder(),f=this._drawingManagerService.getDrawingData(t,o),S=Object.values(f);g?(m.forEach(v=>{v.classType===U.RENDER_CLASS_TYPE.IMAGE&&S.some(C=>v.oKey.includes(C.drawingId))&&l.attachTransformerTo(v)}),this._drawingManagerService.addNotification(S)):(m.forEach(v=>{v.classType===U.RENDER_CLASS_TYPE.IMAGE&&S.some(C=>v.oKey.includes(C.drawingId))&&l.detachTransformerFrom(v)}),h.clearSelectedObjects())}}),(s=this._permissionService.getPermissionPoint$(new _.WorksheetEditPermission(t,o).id))==null||s.pipe(W.filter(g=>g.value!==a),W.distinctUntilChanged()).subscribe({complete:()=>{a=!0;const g=r.getUnitId(),m=e.getSheetId(),f=this._drawingManagerService.getDrawingData(g,m),S=Object.values(f),v=this._renderManagerService.getRenderById(g),C=v==null?void 0:v.scene;if(C==null)return;this._drawingManagerService.setDrawingEditable(!0),C.getAllObjectsByOrder().forEach(y=>{y.classType===U.RENDER_CLASS_TYPE.IMAGE&&S.some(T=>y.oKey.includes(T.drawingId))&&C.detachTransformerFrom(y)})}})})}))}};we=Gt([le(0,P.IDrawingManagerService),le(1,U.IRenderManagerService),le(2,d.IPermissionService),le(3,d.IUniverInstanceService),le(4,d.Inject(d.UserManagerService))],we);var kt=Object.defineProperty,Ft=Object.getOwnPropertyDescriptor,Ht=(i,r,n,e)=>{for(var t=e>1?void 0:e?Ft(r,n):r,o=i.length-1,a;o>=0;o--)(a=i[o])&&(t=(e?a(r,n,t):a(t))||t);return e&&t&&kt(r,n,t),t},Ie=(i,r)=>(n,e)=>r(n,e,i);let Ce=class extends d.Disposable{constructor(i,r,n,e){super(),this._sheetPrintInterceptorService=i,this._drawingRenderService=r,this._drawingManagerService=n,this._renderManagerService=e,this._initPrinting()}_initPrinting(){this.disposeWithMe(this._sheetPrintInterceptorService.interceptor.intercept(this._sheetPrintInterceptorService.interceptor.getInterceptPoints().PRINTING_COMPONENT_COLLECT,{handler:(i,r,n)=>{const{unitId:e,scene:t,subUnitId:o}=r,a=this._drawingManagerService.getDrawingDataForUnit(e),c=a==null?void 0:a[o];return c&&c.order.forEach(l=>{this._drawingRenderService.renderDrawing(c.data[l],t)}),n()}})),this.disposeWithMe(this._sheetPrintInterceptorService.interceptor.intercept(this._sheetPrintInterceptorService.interceptor.getInterceptPoints().PRINTING_RANGE,{handler:(i,r,n)=>{const{unitId:e,subUnitId:t}=r,o=this._renderManagerService.getRenderById(e);if(!o)return n(i);const a=o.with(N.SheetSkeletonManagerService).getWorksheetSkeleton(t);if(!a)return n(i);const c=this._drawingManagerService.getDrawingDataForUnit(e),l=c==null?void 0:c[r.subUnitId];if(!l)return n(i);const{scaleX:h,scaleY:u}=o.scene,s=i?{...i}:{startColumn:0,endColumn:0,endRow:0,startRow:0},g=l.order.map(m=>l.data[m]).filter(m=>m.drawingType!==d.DrawingTypeEnum.DRAWING_DOM);return g.length?(g.forEach(m=>{if(!m.groupId&&m.transform&&d.Tools.isDefine(m.transform.left)&&d.Tools.isDefine(m.transform.top)&&d.Tools.isDefine(m.transform.width)&&d.Tools.isDefine(m.transform.height)){const f=a.skeleton.getCellIndexByOffset(m.transform.left,m.transform.top,h,u,{x:0,y:0}),S=a.skeleton.getCellIndexByOffset(m.transform.left+m.transform.width,m.transform.top+m.transform.height,h,u,{x:0,y:0});f.column<s.startColumn&&(s.startColumn=f.column),f.row<s.startRow&&(s.startRow=f.row),s.endRow<S.row&&(s.endRow=S.row),s.endColumn<S.column&&(s.endColumn=S.column)}}),n(s)):n(i)}}))}};Ce=Ht([Ie(0,d.Inject(N.SheetPrintInterceptorService)),Ie(1,d.Inject(q.DrawingRenderService)),Ie(2,P.IDrawingManagerService),Ie(3,U.IRenderManagerService)],Ce);var $t=Object.defineProperty,Vt=Object.getOwnPropertyDescriptor,Yt=(i,r,n,e)=>{for(var t=e>1?void 0:e?Vt(r,n):r,o=i.length-1,a;o>=0;o--)(a=i[o])&&(t=(e?a(r,n,t):a(t))||t);return e&&t&&$t(r,n,t),t},Q=(i,r)=>(n,e)=>r(n,e,i);const xt=[_.InsertRowCommand.id,_.InsertColCommand.id,_.RemoveRowCommand.id,_.RemoveColCommand.id,_.DeleteRangeMoveLeftCommand.id,_.DeleteRangeMoveUpCommand.id,_.InsertRangeMoveDownCommand.id,_.InsertRangeMoveRightCommand.id,_.DeltaRowHeightCommand.id,_.SetRowHeightCommand.id,_.DeltaColumnWidthCommand.id,_.SetColWidthCommand.id,_.SetRowHiddenCommand.id,_.SetSpecificRowsVisibleCommand.id,_.SetSpecificColsVisibleCommand.id,_.SetColHiddenCommand.id,_.MoveColsCommand.id,_.MoveRowsCommand.id,_.MoveRangeCommand.id],Xt=[_.SetRowVisibleMutation.id,_.SetRowHiddenMutation.id,_.SetColVisibleMutation.id,_.SetColHiddenMutation.id,_.SetWorksheetRowHeightMutation.id,_.SetWorksheetColWidthMutation.id];let We=class extends d.Disposable{constructor(i,r,n,e,t,o,a,c,l){super(),this._context=i,this._renderManagerService=r,this._commandService=n,this._selectionRenderService=e,this._skeletonManagerService=t,this._sheetInterceptorService=o,this._sheetDrawingService=a,this._drawingManagerService=c,this._univerInstanceService=l,this._sheetInterceptorListener(),this._commandListener(),this._sheetRefreshListener()}_sheetInterceptorListener(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:i=>{if(!xt.includes(i.id))return{redos:[],undos:[]};if(i.params==null)return{redos:[],undos:[]};const r=i.id;if(r===_.InsertRowCommand.id)return this._moveRowInterceptor(i.params,"insert");if([_.MoveColsCommand.id,_.MoveRowsCommand.id,_.MoveRangeCommand.id].includes(r))return this._moveRangeInterceptor(i.params);if(r===_.InsertColCommand.id)return this._moveColInterceptor(i.params,"insert");if(r===_.RemoveRowCommand.id)return this._moveRowInterceptor(i.params,"remove");if(r===_.RemoveColCommand.id)return this._moveColInterceptor(i.params,"remove");if(r===_.DeleteRangeMoveLeftCommand.id){const{range:n}=i.params;return this._getRangeMoveUndo(n,0)}else if(r===_.DeleteRangeMoveUpCommand.id){const{range:n}=i.params;return this._getRangeMoveUndo(n,1)}else if(r===_.InsertRangeMoveDownCommand.id){const{range:n}=i.params;return this._getRangeMoveUndo(n,2)}else if(r===_.InsertRangeMoveRightCommand.id){const{range:n}=i.params;return this._getRangeMoveUndo(n,3)}else if(r===_.SetRowHiddenCommand.id||r===_.SetSpecificRowsVisibleCommand.id){const n=i.params,{unitId:e,subUnitId:t,ranges:o}=n;return this._getDrawingUndoForRowVisible(e,t,o)}else if(r===_.SetSpecificColsVisibleCommand.id||r===_.SetColHiddenCommand.id){const n=i.params,{unitId:e,subUnitId:t,ranges:o}=n;return this._getDrawingUndoForColVisible(e,t,o)}else if(r===_.DeltaRowHeightCommand.id||r===_.SetRowHeightCommand.id||r===_.DeltaColumnWidthCommand.id||r===_.SetColWidthCommand.id){const n=i.params,{unitId:e,subUnitId:t,ranges:o}=n,a=r===_.DeltaRowHeightCommand.id||r===_.SetRowHeightCommand.id;return this._getDrawingUndoForRowAndColSize(e,t,o,a)}return{redos:[],undos:[]}}}))}_getRangeMoveUndo(i,r){const n=_.getSheetCommandTarget(this._univerInstanceService);if(n==null)return{redos:[],undos:[]};const e=n.unitId,t=n.subUnitId,o=[],a=[],c=this._sheetDrawingService.getDrawingData(e,t),l=[],h=[];if(Object.keys(c).forEach(u=>{const s=c[u],{updateDrawings:g,deleteDrawings:m}=this._getUpdateOrDeleteDrawings(i,r,s);l.push(...g),h.push(...m)}),l.length===0&&h.length===0)return{redos:[],undos:[]};if(l.length>0){const u=this._sheetDrawingService.getBatchUpdateOp(l),{undo:s,redo:g,objects:m}=u;o.push({id:p.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:g,objects:m,type:p.DrawingApplyType.UPDATE}}),a.push({id:p.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:s,objects:m,type:p.DrawingApplyType.UPDATE}})}if(h.length>0){const u=this._sheetDrawingService.getBatchRemoveOp(h),s=u.undo,g=u.redo,m=u.objects;o.push({id:p.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:g,objects:m,type:p.DrawingApplyType.REMOVE}}),a.push({id:p.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:s,objects:m,type:p.DrawingApplyType.INSERT}})}return o.push({id:G.id,params:[e]}),a.push({id:G.id,params:[e]}),{redos:o,undos:a}}_getUpdateOrDeleteDrawings(i,r,n){const e=[],t=[],{sheetTransform:o,anchorType:a=p.SheetDrawingAnchorType.Position,transform:c,unitId:l,subUnitId:h,drawingId:u}=n,{from:s,to:g}=o,{row:m,column:f}=s,{row:S,column:v}=g;if(o==null||c==null)return{updateDrawings:e,deleteDrawings:t};const{startRow:C,endRow:M,startColumn:y,endColumn:T}=i;let I=null,D=null;if(r===0&&m>=C&&S<=M)if(f>=y&&v<=T)t.push({unitId:l,subUnitId:h,drawingId:u});else{const w=this._shrinkCol(o,c,y,T,a);I=w==null?void 0:w.newSheetTransform,D=w==null?void 0:w.newTransform}else if(r===1&&f>=y&&v<=T)if(m>=C&&S<=M)t.push({unitId:l,subUnitId:h,drawingId:u});else{const w=this._shrinkRow(o,c,C,M,a);I=w==null?void 0:w.newSheetTransform,D=w==null?void 0:w.newTransform}else if(r===2){const w=this._expandRow(o,c,C,M,a);I=w==null?void 0:w.newSheetTransform,D=w==null?void 0:w.newTransform}else if(r===3){const w=this._expandCol(o,c,y,T,a);I=w==null?void 0:w.newSheetTransform,D=w==null?void 0:w.newTransform}if(I!=null&&D!=null){const w=V(I,this._selectionRenderService,this._skeletonManagerService);e.push({...n,sheetTransform:I,transform:w})}return{updateDrawings:e,deleteDrawings:t}}_remainDrawingSize(i,r,n){const e=F({...i},this._selectionRenderService);e!=null&&r.push({...n,sheetTransform:e})}_getDrawingUndoForColVisible(i,r,n){const e=this._drawingManagerService.getDrawingData(i,r),t=[],o=[];if(Object.keys(e).forEach(u=>{const s=e[u],{sheetTransform:g,transform:m,anchorType:f=p.SheetDrawingAnchorType.Position}=s;if(f===p.SheetDrawingAnchorType.None)this._remainDrawingSize(m,t,s);else{const{from:S,to:v}=g,{row:C,column:M}=S,{row:y,column:T}=v;for(let I=0;I<n.length;I++){const D=n[I],{startRow:w,endRow:A,startColumn:E,endColumn:L}=D;if(T<E)continue;if(f===p.SheetDrawingAnchorType.Position){let R=null,B=null;if(M>=E&&M<=L){const H=this._skeletonManagerService.attachRangeWithCoord({startColumn:M,endColumn:L,startRow:S.row,endRow:v.row});if(H==null)return;B={...m,left:H.startX}}if(B!=null&&(R=F(B,this._selectionRenderService),R!=null&&B!=null)){t.push({...s,sheetTransform:R,transform:B});break}this._remainDrawingSize(m,t,s);continue}if(M>=E&&T<=L)continue;let j=null,O=null;if(M>=E&&M<=L){const R=this._skeletonManagerService.attachRangeWithCoord({startColumn:M,endColumn:L,startRow:S.row,endRow:v.row});if(R==null)return;O={...m,left:(R==null?void 0:R.startX)||0,width:((m==null?void 0:m.width)||0)-R.endX+R.startX}}else if(T>=E&&T<=L){const R=this._skeletonManagerService.attachRangeWithCoord({startColumn:E,endColumn:T,startRow:S.row,endRow:v.row});if(R==null)return;O={...m,left:R.startX-((m==null?void 0:m.width)||0)}}else{const R=this._skeletonManagerService.attachRangeWithCoord({startColumn:E,endColumn:L,startRow:S.row,endRow:v.row});if(R==null)return;if(O={...m,width:((m==null?void 0:m.width)||0)-R.endX+R.startX},j=F(O,this._selectionRenderService),j!=null&&O!=null){o.push({...s,sheetTransform:j,transform:O});break}}if(O!=null&&(j=F(O,this._selectionRenderService)),O!=null&&j!=null){t.push({...s,sheetTransform:j,transform:O});break}else this._remainDrawingSize(m,t,s)}}}),t.length===0&&o.length===0)return{redos:[],undos:[]};const{redos:a,undos:c}=this._createUndoAndRedoMutation(i,r,t),l=[],h=[];if(o.length>0){const{redos:u,undos:s}=this._createUndoAndRedoMutation(i,r,o);l.push(...u),h.push(...s)}return{redos:a,undos:c,preRedos:l,preUndos:h}}_createUndoAndRedoMutation(i,r,n){const e=this._sheetDrawingService.getBatchUpdateOp(n),{undo:t,redo:o,objects:a}=e,c=[{id:p.SetDrawingApplyMutation.id,params:{unitId:i,subUnitId:r,op:o,objects:a,type:p.DrawingApplyType.UPDATE}},{id:G.id,params:[i]}],l=[{id:p.SetDrawingApplyMutation.id,params:{unitId:i,subUnitId:r,op:t,objects:a,type:p.DrawingApplyType.UPDATE}},{id:G.id,params:[i]}];return{redos:c,undos:l}}_getDrawingUndoForRowVisible(i,r,n){const e=this._drawingManagerService.getDrawingData(i,r),t=[],o=[];if(Object.keys(e).forEach(u=>{const s=e[u],{sheetTransform:g,transform:m,anchorType:f=p.SheetDrawingAnchorType.Position}=s;if(f===p.SheetDrawingAnchorType.None)this._remainDrawingSize(m,t,s);else{const{from:S,to:v}=g,{row:C,column:M}=S,{row:y,column:T}=v;for(let I=0;I<n.length;I++){const D=n[I],{startRow:w,endRow:A,startColumn:E,endColumn:L}=D;if(y<w)continue;if(f===p.SheetDrawingAnchorType.Position){let R=null,B=null;if(C>=w&&C<=A){const H=this._skeletonManagerService.attachRangeWithCoord({startColumn:S.column,endColumn:v.column,startRow:C,endRow:A});if(H==null)return;B={...m,top:H.startY}}if(B!=null&&(R=F(B,this._selectionRenderService),R!=null&&B!=null)){t.push({...s,sheetTransform:R,transform:B});break}this._remainDrawingSize(m,t,s);continue}if(C>=w&&y<=A)continue;let j=null,O=null;if(C>=w&&C<=A){const R=this._skeletonManagerService.attachRangeWithCoord({startColumn:S.column,endColumn:v.column,startRow:C,endRow:A});if(R==null)return;O={...m,top:(R==null?void 0:R.startY)||0,height:((m==null?void 0:m.height)||0)-R.endY+R.startY}}else if(y>=w&&y<=A){const R=this._skeletonManagerService.attachRangeWithCoord({startColumn:S.column,endColumn:v.column,startRow:w,endRow:y});if(R==null)return;O={...m,top:R.startY-((m==null?void 0:m.height)||0)}}else{const R=this._skeletonManagerService.attachRangeWithCoord({startColumn:S.column,endColumn:v.column,startRow:w,endRow:A});if(R==null)return;if(O={...m,height:((m==null?void 0:m.height)||0)-R.endY+R.startY},j=F(O,this._selectionRenderService),j!=null&&O!=null){o.push({...s,sheetTransform:j,transform:O});break}}if(O!=null&&(j=F(O,this._selectionRenderService)),O!=null&&j!=null){t.push({...s,sheetTransform:j,transform:O});break}else this._remainDrawingSize(m,t,s)}}}),t.length===0&&o.length===0)return{redos:[],undos:[]};const{redos:a,undos:c}=this._createUndoAndRedoMutation(i,r,t),l=[],h=[];if(o.length>0){const{redos:u,undos:s}=this._createUndoAndRedoMutation(i,r,o);l.push(...u),h.push(...s)}return{redos:a,undos:c,preRedos:l,preUndos:h}}_getDrawingUndoForRowAndColSize(i,r,n,e){const t=this._drawingManagerService.getDrawingData(i,r),o=[];return Object.keys(t).forEach(a=>{const c=t[a],{sheetTransform:l,transform:h,anchorType:u=p.SheetDrawingAnchorType.Position}=c;if(u===p.SheetDrawingAnchorType.None)this._remainDrawingSize(h,o,c);else{const{from:s,to:g}=l,{row:m,column:f}=s,{row:S,column:v}=g;for(let C=0;C<n.length;C++){const M=n[C],{startRow:y,endRow:T,startColumn:I,endColumn:D}=M;if(S<y||v<I)continue;if(u===p.SheetDrawingAnchorType.Position&&(m<=y&&S>=T||f<=I&&v>=D)){this._remainDrawingSize(h,o,c);continue}const w=V({...l},this._selectionRenderService,this._skeletonManagerService);if(w!=null){o.push({...c,transform:w});break}}}}),o.length===0?{redos:[],undos:[]}:this._createUndoAndRedoMutation(i,r,o)}_getUnitIdAndSubUnitId(i,r){let n,e;if(r==="insert")n=i.unitId,e=i.subUnitId;else{const t=_.getSheetCommandTarget(this._univerInstanceService);if(t==null)return;n=t.unitId,e=t.subUnitId}return{unitId:n,subUnitId:e}}_moveRangeInterceptor(i){var y,T;const{toRange:r,fromRange:n}=i,e=_.getSheetCommandTarget(this._univerInstanceService);if(!e)return{redos:[],undos:[]};const{unitId:t,subUnitId:o}=e,a=(T=(y=this._renderManagerService.getRenderById(t))==null?void 0:y.with(N.SheetSkeletonManagerService))==null?void 0:T.getCurrentSkeleton();if(!a)return{redos:[],undos:[]};const c=N.attachRangeWithCoord(a,n);if(!c)return{redos:[],undos:[]};const{startX:l,endX:h,startY:u,endY:s}=c,g=this._sheetDrawingService.getDrawingData(t,o),m=[];Object.keys(g).forEach(I=>{const D=g[I];if(D.anchorType!==p.SheetDrawingAnchorType.Both)return;const{transform:w}=D;if(!w)return;const{left:A=0,top:E=0,width:L=0,height:j=0}=w,{drawingStartX:O,drawingEndX:R,drawingStartY:B,drawingEndY:H}={drawingStartX:A,drawingEndX:A+L,drawingStartY:E,drawingEndY:E+j};l<=O&&R<=h&&u<=B&&H<=s&&m.push(D)});const f=[],S=[],v=r.startRow-n.startRow,C=r.startColumn-n.startColumn,M=m.map(I=>{const D=I.sheetTransform,w={to:{...D.to,row:D.to.row+v,column:D.to.column+C},from:{...D.from,row:D.from.row+v,column:D.from.column+C}},A=V(w,this._selectionRenderService,this._skeletonManagerService);return{unitId:t,subUnitId:o,drawingId:I.drawingId,transform:A,sheetTransform:w}});if(M.length){const I=this._sheetDrawingService.getBatchUpdateOp(M),{undo:D,redo:w,objects:A}=I;f.push({id:p.SetDrawingApplyMutation.id,params:{unitId:t,subUnitId:o,op:w,objects:A,type:p.DrawingApplyType.UPDATE}}),S.push({id:p.SetDrawingApplyMutation.id,params:{unitId:t,subUnitId:o,op:D,objects:A,type:p.DrawingApplyType.UPDATE}})}return{redos:f,undos:S}}_moveRowInterceptor(i,r){const n=this._getUnitIdAndSubUnitId(i,r);if(n==null)return{redos:[],undos:[]};const{unitId:e,subUnitId:t}=n,{range:o}=i,a=o.startRow,c=o.endRow,l=[],h=[],u=this._sheetDrawingService.getDrawingData(e,t),s=[],g=[];if(Object.keys(u).forEach(m=>{const f=u[m],{sheetTransform:S,transform:v,anchorType:C=p.SheetDrawingAnchorType.Position}=f;if(S==null||v==null)return;let M,y;if(r==="insert"){const I=this._expandRow(S,v,a,c,C);M=I==null?void 0:I.newSheetTransform,y=I==null?void 0:I.newTransform}else{const{from:I,to:D}=S,{row:w}=I,{row:A}=D;if(C===p.SheetDrawingAnchorType.Both&&w>=a&&A<=c)g.push({unitId:e,subUnitId:t,drawingId:m});else{const E=this._shrinkRow(S,v,a,c,C);M=E==null?void 0:E.newSheetTransform,y=E==null?void 0:E.newTransform}}if(!M||!y)return;const T={unitId:e,subUnitId:t,drawingId:m,transform:y,sheetTransform:M};s.push(T)}),s.length===0&&g.length===0)return{redos:[],undos:[]};if(s.length>0){const m=this._sheetDrawingService.getBatchUpdateOp(s),{undo:f,redo:S,objects:v}=m;l.push({id:p.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:S,objects:v,type:p.DrawingApplyType.UPDATE}}),h.push({id:p.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:f,objects:v,type:p.DrawingApplyType.UPDATE}})}if(g.length>0){const m=this._sheetDrawingService.getBatchRemoveOp(g),f=m.undo,S=m.redo,v=m.objects;l.push({id:p.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:S,objects:v,type:p.DrawingApplyType.REMOVE}}),h.push({id:p.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:f,objects:v,type:p.DrawingApplyType.INSERT}})}return l.push({id:G.id,params:[e]}),h.push({id:G.id,params:[e]}),{redos:l,undos:h}}_moveColInterceptor(i,r){const n=this._getUnitIdAndSubUnitId(i,r);if(n==null)return{redos:[],undos:[]};const{unitId:e,subUnitId:t}=n,{range:o}=i,a=o.startColumn,c=o.endColumn,l=[],h=[],u=this._sheetDrawingService.getDrawingData(e,t),s=[],g=[];if(Object.keys(u).forEach(m=>{const f=u[m],{sheetTransform:S,transform:v,anchorType:C=p.SheetDrawingAnchorType.Position}=f;if(S==null||v==null)return;let M,y;if(r==="insert"){const I=this._expandCol(S,v,a,c,C);M=I==null?void 0:I.newSheetTransform,y=I==null?void 0:I.newTransform}else{const{from:I,to:D}=S,{column:w}=I,{column:A}=D;if(C===p.SheetDrawingAnchorType.Both&&w>=a&&A<=c)g.push({unitId:e,subUnitId:t,drawingId:m});else{const E=this._shrinkCol(S,v,a,c,C);M=E==null?void 0:E.newSheetTransform,y=E==null?void 0:E.newTransform}}if(!M||!y)return;const T={unitId:e,subUnitId:t,drawingId:m,transform:y,sheetTransform:M};s.push(T)}),s.length===0&&g.length===0)return{redos:[],undos:[]};if(s.length>0){const m=this._sheetDrawingService.getBatchUpdateOp(s),{undo:f,redo:S,objects:v}=m;l.push({id:p.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:S,objects:v,type:p.DrawingApplyType.UPDATE}}),h.push({id:p.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:f,objects:v,type:p.DrawingApplyType.UPDATE}})}if(g.length>0){const m=this._sheetDrawingService.getBatchRemoveOp(g),f=m.undo,S=m.redo,v=m.objects;l.push({id:p.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:S,objects:v,type:p.DrawingApplyType.REMOVE}}),h.push({id:p.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:f,objects:v,type:p.DrawingApplyType.INSERT}})}return l.push({id:G.id,params:[e]}),h.push({id:G.id,params:[e]}),{redos:l,undos:h}}_expandCol(i,r,n,e,t=p.SheetDrawingAnchorType.Position){const o=e-n+1,{from:a,to:c}=i,{column:l}=a,{column:h}=c;if(t===p.SheetDrawingAnchorType.None)return{newSheetTransform:F({...r},this._selectionRenderService),newTransform:r};let u=null,s=null;if(l>=n){const g=this._skeletonManagerService.attachRangeWithCoord({startColumn:n,endColumn:e,startRow:a.row,endRow:c.row});if(g==null)return;s={...r,left:(r.left||0)+g.endX-g.startX},u=F(s,this._selectionRenderService)}else if(h>=e)if(t===p.SheetDrawingAnchorType.Both)u={from:{...a},to:{...c,column:h+o}},s=V(u,this._selectionRenderService,this._skeletonManagerService);else return{newSheetTransform:F({...r},this._selectionRenderService),newTransform:r};return u!=null&&s!=null?{newSheetTransform:u,newTransform:s}:null}_shrinkCol(i,r,n,e,t=p.SheetDrawingAnchorType.Position){const o=e-n+1,{from:a,to:c}=i,{column:l}=a,{column:h}=c;if(t===p.SheetDrawingAnchorType.None)return{newSheetTransform:F({...r},this._selectionRenderService),newTransform:r};let u=null,s=null;if(l>e)u={from:{...a,column:l-o},to:{...c,column:h-o}},s=V(u,this._selectionRenderService,this._skeletonManagerService);else{if(l>=n&&h<=e)return null;if(l<n&&h>e)if(t===p.SheetDrawingAnchorType.Both)u={from:{...a},to:{...c,column:h-o}},s=V(u,this._selectionRenderService,this._skeletonManagerService);else return{newSheetTransform:F({...r},this._selectionRenderService),newTransform:r};else if(l>=n&&l<=e){if(l===n)s={...r,left:(r.left||0)-i.from.columnOffset};else{const g=this._skeletonManagerService.attachRangeWithCoord({startColumn:n,endColumn:l-1,startRow:a.row,endRow:c.row});if(g==null)return;s={...r,left:(r.left||0)-g.endX+g.startX-i.from.columnOffset}}u=F(s,this._selectionRenderService)}else if(h>=n&&h<=e&&t===p.SheetDrawingAnchorType.Both){const g=this._skeletonManagerService.attachRangeWithCoord({startColumn:n-1,endColumn:n-1,startRow:a.row,endRow:c.row});if(g==null)return;u={from:{...a},to:{...c,column:n-1,columnOffset:g.endX-g.startX}},s=V(u,this._selectionRenderService,this._skeletonManagerService)}}return u!=null&&s!=null?{newSheetTransform:u,newTransform:s}:null}_expandRow(i,r,n,e,t=p.SheetDrawingAnchorType.Position){const o=e-n+1,{from:a,to:c}=i,{row:l}=a,{row:h}=c;if(t===p.SheetDrawingAnchorType.None)return{newSheetTransform:F({...r},this._selectionRenderService),newTransform:r};let u=null,s=null;if(l>=n){const g=this._skeletonManagerService.attachRangeWithCoord({startRow:n,endRow:e,startColumn:a.column,endColumn:c.column});if(g==null)return;s={...r,top:(r.top||0)+g.endY-g.startY},u=F(s,this._selectionRenderService)}else if(h>=e)if(t===p.SheetDrawingAnchorType.Both)u={from:{...a},to:{...c,row:h+o}},s=V(u,this._selectionRenderService,this._skeletonManagerService);else return{newSheetTransform:F({...r},this._selectionRenderService),newTransform:r};return u!=null&&s!=null?{newSheetTransform:u,newTransform:s}:null}_shrinkRow(i,r,n,e,t=p.SheetDrawingAnchorType.Position){const o=e-n+1,{from:a,to:c}=i,{row:l}=a,{row:h}=c;if(t===p.SheetDrawingAnchorType.None)return{newSheetTransform:F({...r},this._selectionRenderService),newTransform:r};let u=null,s=null;if(l>e)u={from:{...a,row:l-o},to:{...c,row:h-o}},s=V(u,this._selectionRenderService,this._skeletonManagerService);else{if(l>=n&&h<=e)return null;if(l<n&&h>e)if(t===p.SheetDrawingAnchorType.Both)u={from:{...a},to:{...c,row:h-o}},s=V(u,this._selectionRenderService,this._skeletonManagerService);else return{newSheetTransform:F({...r},this._selectionRenderService),newTransform:r};else if(l>=n&&l<=e){if(l===n)s={...r,top:(r.top||0)-i.from.rowOffset};else{const g=this._skeletonManagerService.attachRangeWithCoord({startRow:n,endRow:l-1,startColumn:a.column,endColumn:c.column});if(g==null)return;s={...r,top:(r.top||0)-g.endY+g.startY-i.from.rowOffset}}u=F(s,this._selectionRenderService)}else if(h>=n&&h<=e&&t===p.SheetDrawingAnchorType.Both){const g=this._skeletonManagerService.attachRangeWithCoord({startColumn:a.column,endColumn:a.column,startRow:n-1,endRow:n-1});if(g==null)return;u={from:{...a},to:{...c,row:n-1,rowOffset:g.endY-g.startY}},s=V(u,this._selectionRenderService,this._skeletonManagerService)}}return u!=null&&s!=null?{newSheetTransform:u,newTransform:s}:null}_commandListener(){this.disposeWithMe(this._commandService.onCommandExecuted(i=>{i.id===_.SetWorksheetActiveOperation.id&&setTimeout(()=>{const r=i.params,{unitId:n,subUnitId:e}=r,t=this._drawingManagerService.drawingManagerData,o=[],a=[];Object.keys(t).forEach(c=>{const l=t[c];l!=null&&Object.keys(l).forEach(h=>{const u=l[h].data;u!=null&&Object.keys(u).forEach(s=>{if(c===n&&h===e){const g=u[s];g.transform=V(g.sheetTransform,this._selectionRenderService,this._skeletonManagerService),o.push(u[s])}else a.push(u[s])})})}),this._drawingManagerService.removeNotification(a),this._drawingManagerService.addNotification(o)},0)}))}_sheetRefreshListener(){this.disposeWithMe(this._commandService.onCommandExecuted(i=>{Xt.includes(i.id)&&requestIdleCallback(()=>{const r=i.params,{unitId:n,subUnitId:e,ranges:t}=r;this._refreshDrawingTransform(n,e,t)})}))}_refreshDrawingTransform(i,r,n){const e=this._drawingManagerService.getDrawingData(i,r),t=[];Object.keys(e).forEach(o=>{const a=e[o],{sheetTransform:c,transform:l,anchorType:h=p.SheetDrawingAnchorType.Position}=a;if(h===p.SheetDrawingAnchorType.None)return!0;const{from:u,to:s}=c,{row:g,column:m}=u,{row:f,column:S}=s;for(let v=0;v<n.length;v++){const C=n[v],{startRow:M,endRow:y,startColumn:T,endColumn:I}=C;if(d.Rectangle.intersects({startRow:M,endRow:y,startColumn:T,endColumn:I},{startRow:g,endRow:f,startColumn:m,endColumn:S})||g>y||m>I){const D=h===p.SheetDrawingAnchorType.Position,w=V(c,this._selectionRenderService,this._skeletonManagerService);t.push({...a,transform:{...w,width:D?l==null?void 0:l.width:w==null?void 0:w.width,height:D?l==null?void 0:l.height:w==null?void 0:w.height}});break}}}),t.length!==0&&(this._drawingManagerService.refreshTransform(t),this._commandService.syncExecuteCommand(G.id,[i]))}};We=Yt([Q(1,U.IRenderManagerService),Q(2,d.ICommandService),Q(3,N.ISheetSelectionRenderService),Q(4,d.Inject(N.SheetSkeletonManagerService)),Q(5,d.Inject(_.SheetInterceptorService)),Q(6,p.ISheetDrawingService),Q(7,P.IDrawingManagerService),Q(8,d.IUniverInstanceService)],We);var K=function(){return K=Object.assign||function(i){for(var r,n=1,e=arguments.length;n<e;n++){r=arguments[n];for(var t in r)Object.prototype.hasOwnProperty.call(r,t)&&(i[t]=r[t])}return i},K.apply(this,arguments)},zt=function(i,r){var n={};for(var e in i)Object.prototype.hasOwnProperty.call(i,e)&&r.indexOf(e)<0&&(n[e]=i[e]);if(i!=null&&typeof Object.getOwnPropertySymbols=="function")for(var t=0,e=Object.getOwnPropertySymbols(i);t<e.length;t++)r.indexOf(e[t])<0&&Object.prototype.propertyIsEnumerable.call(i,e[t])&&(n[e[t]]=i[e[t]]);return n},Je=x.forwardRef(function(i,r){var n=i.icon,e=i.id,t=i.className,o=i.extend,a=zt(i,["icon","id","className","extend"]),c="univerjs-icon univerjs-icon-".concat(e," ").concat(t||"").trim(),l=x.useRef("_".concat(Zt()));return Ze(n,"".concat(e),{defIds:n.defIds,idSuffix:l.current},K({ref:r,className:c},a),o)});function Ze(i,r,n,e,t){return x.createElement(i.tag,K(K({key:r},Kt(i,n,t)),e),(Jt(i,n).children||[]).map(function(o,a){return Ze(o,"".concat(r,"-").concat(i.tag,"-").concat(a),n,void 0,t)}))}function Kt(i,r,n){var e=K({},i.attrs);n!=null&&n.colorChannel1&&e.fill==="colorChannel1"&&(e.fill=n.colorChannel1);var t=r.defIds;return!t||t.length===0||(i.tag==="use"&&e["xlink:href"]&&(e["xlink:href"]=e["xlink:href"]+r.idSuffix),Object.entries(e).forEach(function(o){var a=o[0],c=o[1];typeof c=="string"&&(e[a]=c.replace(/url\(#(.*)\)/,"url(#$1".concat(r.idSuffix,")")))})),e}function Jt(i,r){var n,e=r.defIds;return!e||e.length===0?i:i.tag==="defs"&&(!((n=i.children)===null||n===void 0)&&n.length)?K(K({},i),{children:i.children.map(function(t){return typeof t.attrs.id=="string"&&e&&e.indexOf(t.attrs.id)>-1?K(K({},t),{attrs:K(K({},t.attrs),{id:t.attrs.id+r.idSuffix})}):t})}):i}function Zt(){return Math.random().toString(36).substring(2,8)}Je.displayName="UniverIcon";var qt={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M2.2498 3.65005C2.2498 2.87685 2.87661 2.25005 3.64981 2.25005H7.9998C8.33118 2.25005 8.5998 1.98142 8.5998 1.65005C8.5998 1.31868 8.33118 1.05005 7.9998 1.05005H3.64981C2.21387 1.05005 1.0498 2.21411 1.0498 3.65005V12.35C1.0498 13.786 2.21386 14.95 3.6498 14.95H12.3498C13.7857 14.95 14.9498 13.786 14.9498 12.3501V8.00005C14.9498 7.66868 14.6812 7.40005 14.3498 7.40005C14.0184 7.40005 13.7498 7.66868 13.7498 8.00005V9.23974L12.2385 8.1063C11.7252 7.72129 11.0068 7.7723 10.5531 8.22605L9.00869 9.77041L6.73916 7.8251C6.24387 7.40055 5.5095 7.41278 5.02864 7.85359L2.2498 10.4009V3.65005ZM2.2498 12.0287V12.35C2.2498 13.1232 2.87661 13.75 3.6498 13.75H12.3498C13.123 13.75 13.7498 13.1232 13.7498 12.3501V10.7397L11.5186 9.06631C11.4829 9.03956 11.433 9.04314 11.4016 9.07458L9.92249 10.5537L11.1015 11.5642C11.3531 11.7799 11.3822 12.1587 11.1666 12.4103C10.9509 12.6619 10.5721 12.691 10.3205 12.4753L5.9582 8.7362C5.92384 8.70674 5.87288 8.70758 5.83952 8.73816L2.2498 12.0287Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M11.8097 1.14783C12.1411 1.14783 12.4097 1.41646 12.4097 1.74783V3.297H14.1541C14.4855 3.297 14.7541 3.56563 14.7541 3.897C14.7541 4.22837 14.4855 4.497 14.1541 4.497H12.4097V6.24167C12.4097 6.57304 12.1411 6.84167 11.8097 6.84167C11.4783 6.84167 11.2097 6.57304 11.2097 6.24167V4.497H9.6603C9.32893 4.497 9.0603 4.22837 9.0603 3.897C9.0603 3.56563 9.32893 3.297 9.6603 3.297H11.2097V1.74783C11.2097 1.41646 11.4783 1.14783 11.8097 1.14783Z"}}]},qe=x.forwardRef(function(i,r){return x.createElement(Je,Object.assign({},i,{id:"add-image-single",ref:r,icon:qt}))});qe.displayName="AddImageSingle";const Le={id:"sheet.command.delete-drawing",type:d.CommandType.COMMAND,handler:i=>{const r=i.get(d.ICommandService),e=i.get(p.ISheetDrawingService).getFocusDrawings();if(e.length===0)return!1;const t=e[0].unitId,o=e.map(a=>{const{unitId:c,subUnitId:l,drawingId:h,drawingType:u}=a;return{unitId:c,subUnitId:l,drawingId:h,drawingType:u}});return r.executeCommand(oe.id,{unitId:t,drawings:o})}},ye={id:"sheet.command.insert-float-image",type:d.CommandType.COMMAND,handler:i=>{var n,e;return(e=(n=i.get(U.IRenderManagerService).getCurrentTypeOfRenderer(d.UniverInstanceType.UNIVER_SHEET))==null?void 0:n.with(de).insertFloatImage())!=null?e:!1}},Be={id:"sheet.command.insert-cell-image",type:d.CommandType.COMMAND,handler:i=>{var n,e;return(e=(n=i.get(U.IRenderManagerService).getCurrentTypeOfRenderer(d.UniverInstanceType.UNIVER_SHEET))==null?void 0:n.with(de).insertCellImage())!=null?e:!1}},ie={id:"sheet.command.move-drawing",type:d.CommandType.COMMAND,handler:(i,r)=>{const n=i.get(d.ICommandService),e=i.get(p.ISheetDrawingService),t=i.get(N.ISheetSelectionRenderService),{direction:o}=r,a=e.getFocusDrawings();if(a.length===0)return!1;const c=a[0].unitId,l=a.map(u=>{const{transform:s}=u;if(s==null)return null;const g={...s},{left:m=0,top:f=0}=s;return o===d.Direction.UP?g.top=f-1:o===d.Direction.DOWN?g.top=f+1:o===d.Direction.LEFT?g.left=m-1:o===d.Direction.RIGHT&&(g.left=m+1),{...u,transform:g,sheetTransform:F(g,t)}}).filter(u=>u!=null);return n.syncExecuteCommand(ce.id,{unitId:c,drawings:l})?(n.syncExecuteCommand(G.id,[c]),!0):!1}},Qe="addition-and-subtraction-single",Ge="sheet.menu.image";function Qt(i){return{id:Ge,type:k.MenuItemType.SUBITEMS,icon:Qe,tooltip:"sheetImage.title",hidden$:k.getMenuHiddenObservable(i,d.UniverInstanceType.UNIVER_SHEET),disabled$:N.getCurrentRangeDisable$(i,{workbookTypes:[_.WorkbookEditablePermission],worksheetTypes:[_.WorksheetEditPermission],rangeTypes:[_.RangeProtectionPermissionEditPoint]})}}function en(i){return{id:ye.id,title:"sheetImage.upload.float",type:k.MenuItemType.BUTTON,hidden$:k.getMenuHiddenObservable(i,d.UniverInstanceType.UNIVER_SHEET)}}function tn(i){return{id:Be.id,title:"sheetImage.upload.cell",type:k.MenuItemType.BUTTON}}const ee={imageCommonPanel:"univer-image-common-panel",imageCommonPanelGrid:"univer-image-common-panel-grid",imageCommonPanelBorder:"univer-image-common-panel-border",imageCommonPanelTitle:"univer-image-common-panel-title",imageCommonPanelSubtitle:"univer-image-common-panel-subtitle",imageCommonPanelRow:"univer-image-common-panel-row",imageCommonPanelRowVertical:"univer-image-common-panel-row-vertical",imageCommonPanelColumn:"univer-image-common-panel-column",imageCommonPanelColumnCenter:"univer-image-common-panel-column-center",imageCommonPanelInline:"univer-image-common-panel-inline",imageCommonPanelSpan2:"univer-image-common-panel-span2",imageCommonPanelSpan3:"univer-image-common-panel-span3",imageCommonPanelInput:"univer-image-common-panel-input",sheetImageMenu:"univer-sheet-image-menu",sheetImageMenuInput:"univer-sheet-image-menu-input"};function et(i){var r,n,e="";if(typeof i=="string"||typeof i=="number")e+=i;else if(typeof i=="object")if(Array.isArray(i)){var t=i.length;for(r=0;r<t;r++)i[r]&&(n=et(i[r]))&&(e&&(e+=" "),e+=n)}else for(n in i)i[n]&&(e&&(e+=" "),e+=n);return e}function Me(){for(var i,r,n=0,e="",t=arguments.length;n<t;n++)(i=arguments[n])&&(r=et(i))&&(e&&(e+=" "),e+=r);return e}const nn=i=>{var y;const r=d.useDependency(d.ICommandService),n=d.useDependency(d.LocaleService),e=d.useDependency(P.IDrawingManagerService),t=d.useDependency(U.IRenderManagerService),{drawings:o}=i,a=o[0];if(a==null)return;const{unitId:c}=a,l=t.getRenderById(c),h=l==null?void 0:l.scene;if(h==null)return;const u=h.getTransformerByCreate(),[s,g]=x.useState(!0),m=(y=a.anchorType)!=null?y:p.SheetDrawingAnchorType.Position,[f,S]=x.useState(m);function v(T,I){const D=[];return T.forEach(w=>{const{oKey:A}=w,E=I.getDrawingOKey(A);if(E==null)return D.push(null),!0;const{unitId:L,subUnitId:j,drawingId:O,drawingType:R,anchorType:B,sheetTransform:H}=E;D.push({unitId:L,subUnitId:j,drawingId:O,anchorType:B,sheetTransform:H,drawingType:R})}),D}x.useEffect(()=>{const T=u.clearControl$.subscribe(D=>{D===!0&&g(!1)}),I=u.changeStart$.subscribe(D=>{var E;const{objects:w}=D,A=v(w,e);if(A.length===0)g(!1);else if(A.length>=1){g(!0);const L=((E=A[0])==null?void 0:E.anchorType)||p.SheetDrawingAnchorType.Position;S(L)}});return()=>{I.unsubscribe(),T.unsubscribe()}},[]);function C(T){S(T);const I=e.getFocusDrawings();if(I.length===0)return;const D=I.map(w=>({unitId:w.unitId,subUnitId:w.subUnitId,drawingId:w.drawingId,anchorType:T}));r.executeCommand(ce.id,{unitId:I[0].unitId,drawings:D})}const M=T=>T?"block":"none";return $.jsxs("div",{className:Me(ee.imageCommonPanelGrid,ee.imageCommonPanelBorder),style:{display:M(s)},children:[$.jsx("div",{className:ee.imageCommonPanelRow,children:$.jsx("div",{className:Me(ee.imageCommonPanelColumn,ee.imageCommonPanelTitle),children:$.jsx("div",{children:n.t("drawing-anchor.title")})})}),$.jsx("div",{className:Me(ee.imageCommonPanelRow),children:$.jsx("div",{className:Me(ee.imageCommonPanelColumn),children:$.jsxs(J.RadioGroup,{value:f,onChange:C,direction:"vertical",children:[$.jsx(J.Radio,{value:p.SheetDrawingAnchorType.Both,children:n.t("drawing-anchor.both")}),$.jsx(J.Radio,{value:p.SheetDrawingAnchorType.Position,children:n.t("drawing-anchor.position")}),$.jsx(J.Radio,{value:p.SheetDrawingAnchorType.None,children:n.t("drawing-anchor.none")})]})})})]})},rn=()=>{const i=d.useDependency(P.IDrawingManagerService),r=i.getFocusDrawings(),[n,e]=x.useState(r);return x.useEffect(()=>{const t=i.focus$.subscribe(o=>{e(o)});return()=>{t.unsubscribe()}},[]),!!(n!=null&&n.length)&&$.jsxs("div",{className:ee.imageCommonPanel,children:[$.jsx(q.DrawingCommonPanel,{drawings:n}),$.jsx(nn,{drawings:n})]})},on={[k.RibbonStartGroup.FORMULAS_INSERT]:{[Ge]:{order:3,menuItemFactory:Qt,[ye.id]:{order:0,menuItemFactory:en},[Be.id]:{order:1,menuItemFactory:tn}}}};function ue(i){return!i.getContextValue(d.FOCUSING_FX_BAR_EDITOR)&&!i.getContextValue(d.EDITOR_ACTIVATED)&&!i.getContextValue(d.FOCUSING_PANEL_EDITOR)&&i.getContextValue(d.FOCUSING_COMMON_DRAWINGS)}const an={id:ie.id,description:"shortcut.sheet.drawing-move-down",group:"4_sheet-drawing-view",binding:k.KeyCode.ARROW_DOWN,priority:100,preconditions:ue,staticParameters:{direction:d.Direction.DOWN}},sn={id:ie.id,description:"shortcut.sheet.drawing-move-up",group:"4_sheet-drawing-view",binding:k.KeyCode.ARROW_UP,priority:100,preconditions:ue,staticParameters:{direction:d.Direction.UP}},cn={id:ie.id,description:"shortcut.sheet.drawing-move-left",group:"4_sheet-drawing-view",binding:k.KeyCode.ARROW_LEFT,priority:100,preconditions:ue,staticParameters:{direction:d.Direction.LEFT}},dn={id:ie.id,description:"shortcut.sheet.drawing-move-right",group:"4_sheet-drawing-view",binding:k.KeyCode.ARROW_RIGHT,priority:100,preconditions:ue,staticParameters:{direction:d.Direction.RIGHT}},ln={id:Le.id,description:"shortcut.sheet.drawing-delete",group:"4_sheet-drawing-view",preconditions:ue,binding:k.KeyCode.DELETE,mac:k.KeyCode.BACKSPACE};var un=Object.defineProperty,gn=Object.getOwnPropertyDescriptor,mn=(i,r,n,e)=>{for(var t=e>1?void 0:e?gn(r,n):r,o=i.length-1,a;o>=0;o--)(a=i[o])&&(t=(e?a(r,n,t):a(t))||t);return e&&t&&un(r,n,t),t},De=(i,r)=>(n,e)=>r(n,e,i);let Re=class extends d.Disposable{constructor(i,r,n,e){super(),this._componentManager=i,this._menuManagerService=r,this._commandService=n,this._shortcutService=e,this._init()}_initCustomComponents(){const i=this._componentManager;this.disposeWithMe(i.register(Qe,qe)),this.disposeWithMe(i.register(Ye,rn))}_initMenus(){this._menuManagerService.mergeMenu(on)}_initCommands(){[ye,Be,se,oe,ce,Te,G,be,Pe,Ue,ie,Le,Ae].forEach(i=>this.disposeWithMe(this._commandService.registerCommand(i)))}_initShortcuts(){[an,sn,cn,dn,ln].forEach(i=>{this.disposeWithMe(this._shortcutService.registerShortcut(i))})}_init(){this._initCommands(),this._initCustomComponents(),this._initMenus(),this._initShortcuts()}};Re=mn([De(0,d.Inject(k.ComponentManager)),De(1,k.IMenuManagerService),De(2,d.ICommandService),De(3,k.IShortcutService)],Re);var hn=Object.defineProperty,pn=Object.getOwnPropertyDescriptor,fn=(i,r,n,e)=>{for(var t=e>1?void 0:e?pn(r,n):r,o=i.length-1,a;o>=0;o--)(a=i[o])&&(t=(e?a(r,n,t):a(t))||t);return e&&t&&hn(r,n,t),t},re=(i,r)=>(n,e)=>r(n,e,i);function Sn(i,r,n,e){const{scaleX:t,scaleY:o}=r.getAncestorScale(),a=r.getViewport(U.SHEET_VIEWPORT_KEY.VIEW_MAIN),c={left:!0,top:!0};if(!a)return{...i,absolute:c};const{left:l,right:h,top:u,bottom:s}=i,g=e.getFreeze(),{startColumn:m,startRow:f,xSplit:S,ySplit:v}=g,C=n.getNoMergeCellPositionByIndexWithNoHeader(f-v,m-S),M=n.getNoMergeCellPositionByIndexWithNoHeader(f,m),{rowHeaderWidth:y,columnHeaderHeight:T}=n,I=M.startX-C.startX,D=M.startY-C.startY,{top:w,left:A,viewportScrollX:E,viewportScrollY:L}=a;let j,O;l<A?(c.left=!0,j=(I+y+(l-A))*t,O=Math.max(Math.min((I+y+(h-A))*t,(I+y)*t),(h-E)*t)):(c.left=!1,j=Math.max((l-E)*t,(I+y)*t),O=Math.max((h-E)*t,(I+y)*t));let R,B;return u<w?(c.top=!0,R=(D+T+(u-w))*o,B=Math.max(Math.min((D+T+(h-w))*o,(D+T)*o),(s-L)*o)):(c.top=!1,R=Math.max((u-L)*o,(D+T)*o),B=Math.max((s-L)*o,(D+T)*o)),{left:j,right:O,top:R,bottom:B,absolute:c}}const ke=(i,r,n,e)=>{const{scene:t}=r,{left:o,top:a,width:c,height:l,angle:h}=i,u={left:o,right:o+c,top:a,bottom:a+l},s=Sn(u,t,n,e),{scaleX:g,scaleY:m}=t.getAncestorScale();return{startX:s.left,endX:s.right,startY:s.top,endY:s.bottom,rotate:h,width:c*g,height:l*m,absolute:s.absolute}};b.SheetCanvasFloatDomManagerService=class extends d.Disposable{constructor(n,e,t,o,a,c,l){super();Y(this,"_domLayerMap",new Map);Y(this,"_domLayerInfoMap",new Map);Y(this,"_transformChange$",new W.Subject);Y(this,"transformChange$",this._transformChange$.asObservable());Y(this,"_add$",new W.Subject);Y(this,"add$",this._add$.asObservable());Y(this,"_remove$",new W.Subject);Y(this,"remove$",this._remove$.asObservable());Y(this,"_hooks",[]);this._renderManagerService=n,this._univerInstanceService=e,this._commandService=t,this._drawingManagerService=o,this._canvasFloatDomService=a,this._sheetDrawingService=c,this._lifecycleService=l,this._drawingAddListener(),this._featureUpdateListener(),this._deleteListener(),this._bindScrollEvent()}_bindScrollEvent(){this._lifecycleService.lifecycle$.pipe(W.filter(n=>n===d.LifecycleStages.Rendered),W.take(1)).subscribe(()=>{this._scrollUpdateListener()})}_ensureMap(n,e){let t=this._domLayerMap.get(n);t||(t=new Map,this._domLayerMap.set(n,t));let o=t.get(e);return o||(o=new Map,t.set(e,o)),o}getFloatDomInfo(n){return this._domLayerInfoMap.get(n)}_getSceneAndTransformerByDrawingSearch(n){if(n==null)return;const e=this._renderManagerService.getRenderById(n),t=e==null?void 0:e.scene;if(e==null||t==null)return null;const o=t.getTransformerByCreate(),a=e.engine.getCanvasElement();return{scene:t,transformer:o,renderObject:e,canvas:a}}_getFloatDomProps(n){let e;return this._hooks.forEach(t=>{e=t.onGetFloatDomProps(n)}),e}_drawingAddListener(){this.disposeWithMe(this._drawingManagerService.add$.subscribe(n=>{n.forEach(e=>{var it,ot,at;const{unitId:t,subUnitId:o,drawingId:a}=e,c=_.getSheetCommandTarget(this._univerInstanceService,{unitId:t,subUnitId:o}),l=this._drawingManagerService.getDrawingByParam(e),h=this._univerInstanceService.getUnit(t,d.UniverInstanceType.UNIVER_SHEET);if(!h)return;const u=h.getActiveSheet().getSheetId();if(!l||!c)return;const s=(it=this._renderManagerService.getRenderById(t))==null?void 0:it.with(N.SheetSkeletonManagerService).getWorksheetSkeleton(o);if(!s)return;const{transform:g,drawingType:m,data:f}=l;if(m!==d.DrawingTypeEnum.DRAWING_DOM&&m!==d.DrawingTypeEnum.DRAWING_CHART)return;const S=this._getSceneAndTransformerByDrawingSearch(t);if(S==null)return;const{scene:v,canvas:C}=S;if(g==null)return!0;if(u!==o)return;const{left:M,top:y,width:T,height:I,angle:D,flipX:w,flipY:A,skewX:E,skewY:L}=g,j=P.getDrawingShapeKeyByDrawingSearch({unitId:t,subUnitId:o,drawingId:a}),O=v.getObject(j);if(O!=null){O.transformByState({left:M,top:y,width:T,height:I,angle:D,flipX:w,flipY:A,skewX:E,skewY:L});return}const R={left:M,top:y,width:T,height:I,zIndex:this._drawingManagerService.getDrawingOrder(t,o).length-1},B=m===d.DrawingTypeEnum.DRAWING_CHART;B&&(R.fill="white",R.rotateEnabled=!1,f&&f.border&&(R.stroke=f.border),R.paintFirst="stroke",R.strokeWidth=1,R.borderEnabled=!1,R.radius=8);const H=new U.Rect(j,R);B&&H.setObjectType(U.ObjectType.CHART),v.addObject(H,U.DRAWING_OBJECT_LAYER_INDEX),l.allowTransform!==!1&&v.attachTransformerTo(H);const Z=this._ensureMap(t,o),He=new d.DisposableCollection,Cn=ke(H,S.renderObject,s.skeleton,c.worksheet),$e=new W.BehaviorSubject(Cn),yn={dispose:He,rect:H,position$:$e,unitId:t,subUnitId:o};this._canvasFloatDomService.addFloatDom({position$:$e,id:a,componentKey:l.componentKey,onPointerDown:X=>{C.dispatchEvent(new PointerEvent(X.type,X))},onPointerMove:X=>{C.dispatchEvent(new PointerEvent(X.type,X))},onPointerUp:X=>{C.dispatchEvent(new PointerEvent(X.type,X))},onWheel:X=>{C.dispatchEvent(new WheelEvent(X.type,X))},props:(at=(ot=Z.get(a))==null?void 0:ot.props)!=null?at:this._getFloatDomProps(a),data:f,unitId:t});const rt=H.onTransformChange$.subscribeEvent(()=>{const X=ke(H,S.renderObject,s.skeleton,c.worksheet);$e.next(X)});He.add(()=>{this._canvasFloatDomService.removeFloatDom(a)}),rt&&He.add(rt),this._domLayerInfoMap.set(a,yn),Z.set(a,{...Z.get(a)})})})),this.disposeWithMe(this._drawingManagerService.remove$.subscribe(n=>{n.forEach(e=>{const{unitId:t,subUnitId:o,drawingId:a}=e,c=P.getDrawingShapeKeyByDrawingSearch({unitId:t,subUnitId:o,drawingId:a}),l=this._getSceneAndTransformerByDrawingSearch(t);if(l==null)return;const{transformer:h,scene:u}=l,s=u.getObject(c);s!=null&&s.oKey&&h.clearControlByIds([s==null?void 0:s.oKey])})}))}_scrollUpdateListener(){const n=(e,t)=>{var u;const o=this._getSceneAndTransformerByDrawingSearch(e),a=this._ensureMap(e,t),c=Array.from(a.keys()),l=_.getSheetCommandTarget(this._univerInstanceService,{unitId:e,subUnitId:t}),h=(u=this._renderManagerService.getRenderById(e))==null?void 0:u.with(N.SheetSkeletonManagerService).getWorksheetSkeleton(t);!o||!l||!h||c.forEach(s=>{const g=this._domLayerInfoMap.get(s);if(g){const m=ke(g.rect,o.renderObject,h.skeleton,l.worksheet);g.position$.next(m)}})};this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(d.UniverInstanceType.UNIVER_SHEET).pipe(W.filter(e=>!!e),W.switchMap(e=>e.activeSheet$),W.filter(e=>!!e),W.map(e=>{const t=this._renderManagerService.getRenderById(e.getUnitId());return t?{render:t,unitId:e.getUnitId(),subUnitId:e.getSheetId()}:null}),W.filter(e=>!!e),W.switchMap(e=>d.fromEventSubject(e.render.scene.getViewport(U.SHEET_VIEWPORT_KEY.VIEW_MAIN).onScrollAfter$).pipe(W.map(()=>({unitId:e.unitId,subUnitId:e.subUnitId}))))).subscribe(({unitId:e,subUnitId:t})=>{n(e,t)})),this.disposeWithMe(this._commandService.onCommandExecuted(e=>{var t,o;if(e.id===N.SetZoomRatioOperation.id){const a=e.params,{unitId:c}=a;Array.from((o=(t=this._domLayerMap.get(c))==null?void 0:t.keys())!=null?o:[]).forEach(h=>{n(c,h)})}else if(e.id===_.SetFrozenMutation.id){const{unitId:a,subUnitId:c}=e.params;n(a,c)}}))}_getPosition(n,e){var m;const{startX:t,endX:o,startY:a,endY:c}=n,l=(m=this._renderManagerService.getRenderById(e))==null?void 0:m.with(N.ISheetSelectionRenderService);if(l==null)return;const h=l.getCellWithCoordByOffset(t,a);if(h==null)return;const u={column:h.actualColumn,columnOffset:t-h.startX,row:h.actualRow,rowOffset:a-h.startY},s=l.getCellWithCoordByOffset(o,c);if(s==null)return;const g={column:s.actualColumn,columnOffset:o-s.startX,row:s.actualRow,rowOffset:c-s.startY};return{from:u,to:g}}_featureUpdateListener(){this.disposeWithMe(this._drawingManagerService.update$.subscribe(n=>{n.forEach(e=>{const t=this._drawingManagerService.getDrawingByParam(e);if(!t||t.drawingType!==d.DrawingTypeEnum.DRAWING_DOM&&t.drawingType!==d.DrawingTypeEnum.DRAWING_CHART)return;const o={...t.transform};this._transformChange$.next({id:e.drawingId,value:o})})}))}_deleteListener(){this.disposeWithMe(this._drawingManagerService.remove$.subscribe(n=>{n.forEach(e=>{this._removeDom(e.drawingId)})}))}updateFloatDomProps(n,e,t,o){const a=this._domLayerInfoMap.get(t),c=this._getSceneAndTransformerByDrawingSearch(n);if(a&&c){const{scene:l}=c,h=P.getDrawingShapeKeyByDrawingSearch({unitId:n,subUnitId:e,drawingId:t}),u=l.getObject(h);u&&u instanceof U.Rect&&u.setProps(o)}}addFloatDomToPosition(n,e){const t=_.getSheetCommandTarget(this._univerInstanceService,{unitId:n.unitId,subUnitId:n.subUnitId});if(!t)throw new Error("cannot find current target!");const{unitId:o,subUnitId:a}=t,{initPosition:c,componentKey:l,data:h,allowTransform:u=!0}=n,s=e!=null?e:d.generateRandomId(),g=this._getPosition(c,o);if(g==null)return;this._ensureMap(o,a).set(s,n);const f={unitId:o,subUnitId:a,drawingId:s,drawingType:n.type||d.DrawingTypeEnum.DRAWING_DOM,componentKey:l,sheetTransform:g,transform:{left:c.startX,top:c.startY,width:c.endX-c.startX,height:c.endY-c.startY},data:h,allowTransform:u};return this._commandService.executeCommand(se.id,{unitId:o,drawings:[f]}),this._add$.next({unitId:o,subUnitId:a,id:s}),{id:s,dispose:()=>{this._removeDom(s,!0)}}}_removeDom(n,e=!1){const t=this._domLayerInfoMap.get(n);if(!t)return;const{unitId:o,subUnitId:a}=t;this._domLayerInfoMap.delete(n),t.dispose.dispose();const c=this._getSceneAndTransformerByDrawingSearch(o);if(c&&c.scene.removeObject(t.rect),e){this._ensureMap(o,a).delete(n);const h=this._drawingManagerService.getDrawingByParam({unitId:o,subUnitId:a,drawingId:n});if(!h)return;const u=this._sheetDrawingService.getBatchRemoveOp([h]),{redo:s,objects:g}=u;this._commandService.syncExecuteCommand(p.SetDrawingApplyMutation.id,{unitId:o,subUnitId:a,op:s,objects:g,type:p.DrawingApplyType.REMOVE})}}addHook(n){return this._hooks.push(n),{dispose:()=>{const e=this._hooks.findIndex(t=>t===n);this._hooks.splice(e,1)}}}},b.SheetCanvasFloatDomManagerService=fn([re(0,d.Inject(U.IRenderManagerService)),re(1,d.IUniverInstanceService),re(2,d.Inject(d.ICommandService)),re(3,P.IDrawingManagerService),re(4,d.Inject(k.CanvasFloatDomService)),re(5,p.ISheetDrawingService),re(6,d.Inject(d.LifecycleService))],b.SheetCanvasFloatDomManagerService);var tt=Object.defineProperty,vn=Object.getOwnPropertyDescriptor,_n=(i,r,n)=>r in i?tt(i,r,{enumerable:!0,configurable:!0,writable:!0,value:n}):i[r]=n,wn=(i,r,n,e)=>{for(var t=e>1?void 0:e?vn(r,n):r,o=i.length-1,a;o>=0;o--)(a=i[o])&&(t=(e?a(r,n,t):a(t))||t);return e&&t&&tt(r,n,t),t},Fe=(i,r)=>(n,e)=>r(n,e,i),nt=(i,r,n)=>_n(i,typeof r!="symbol"?r+"":r,n);const In="SHEET_IMAGE_UI_PLUGIN";b.UniverSheetsDrawingUIPlugin=class extends d.Plugin{constructor(r=dt,n,e,t){super(),this._config=r,this._injector=n,this._renderManagerService=e,this._configService=t;const{menu:o,...a}=this._config;o&&this._configService.setConfig("menu",o,{merge:!0}),this._configService.setConfig(ct,a)}onStarting(){d.registerDependencies(this._injector,[[b.SheetCanvasFloatDomManagerService],[Re],[me],[Ce],[we],[_e],[pe],[ve],[fe]]),d.touchDependencies(this._injector,[[b.SheetCanvasFloatDomManagerService]])}onReady(){d.touchDependencies(this._injector,[[_e]])}onRendered(){this._registerRenderModules(),d.touchDependencies(this._injector,[[we],[Ce],[Re],[pe],[ve],[fe]])}onSteady(){this._injector.get(me)}_registerRenderModules(){[[de],[We],[Oe]].forEach(r=>{this.disposeWithMe(this._renderManagerService.registerRenderModule(d.UniverInstanceType.UNIVER_SHEET,r))})}},nt(b.UniverSheetsDrawingUIPlugin,"type",d.UniverInstanceType.UNIVER_SHEET),nt(b.UniverSheetsDrawingUIPlugin,"pluginName",In),b.UniverSheetsDrawingUIPlugin=wn([d.DependentOn(P.UniverDrawingPlugin,q.UniverDrawingUIPlugin,p.UniverSheetsDrawingPlugin),Fe(1,d.Inject(d.Injector)),Fe(2,U.IRenderManagerService),Fe(3,d.IConfigService)],b.UniverSheetsDrawingUIPlugin),b.ClearSheetDrawingTransformerOperation=G,b.DeleteDrawingsCommand=Le,b.EditSheetDrawingOperation=be,b.GroupSheetDrawingCommand=Pe,b.InsertFloatImageCommand=ye,b.InsertSheetDrawingCommand=se,b.MoveDrawingsCommand=ie,b.RemoveSheetDrawingCommand=oe,b.SHEETS_IMAGE_MENU_ID=Ge,b.SetDrawingArrangeCommand=Ae,b.SetSheetDrawingCommand=ce,b.SidebarSheetDrawingOperation=Te,b.UngroupSheetDrawingCommand=Ue,Object.defineProperty(b,Symbol.toStringTag,{value:"Module"})});
30
+ */var ze;function lt(){if(ze)return se;ze=1;var i=X,r=Symbol.for("react.element"),n=Symbol.for("react.fragment"),e=Object.prototype.hasOwnProperty,t=i.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,o={key:!0,ref:!0,__self:!0,__source:!0};function a(c,l,h){var u,s={},m=null,g=null;h!==void 0&&(m=""+h),l.key!==void 0&&(m=""+l.key),l.ref!==void 0&&(g=l.ref);for(u in l)e.call(l,u)&&!o.hasOwnProperty(u)&&(s[u]=l[u]);if(c&&c.defaultProps)for(u in l=c.defaultProps,l)s[u]===void 0&&(s[u]=l[u]);return{$$typeof:r,type:c,key:m,ref:g,props:s,_owner:t.current}}return se.Fragment=n,se.jsx=a,se.jsxs=a,se}var Ke;function ut(){return Ke||(Ke=1,Oe.exports=lt()),Oe.exports}var H=ut();const me={uploadLoading:"univer-upload-loading",uploadLoadingBody:"univer-upload-loading-body",uploadLoadingBodyAnimation:"univer-upload-loading-body-animation",univerCircleAnimation:"univer-UniverCircleAnimation",uploadLoadingBodyText:"univer-upload-loading-body-text"},gt=()=>{const i=d.useDependency(P.IImageIoService),r=d.useDependency(d.LocaleService),[n,e]=X.useState(0);return X.useEffect(()=>{const t=i.change$.subscribe(o=>{e(o)});return()=>{t.unsubscribe()}},[i]),H.jsx("div",{style:{display:n>0?"block":"none"},className:me.uploadLoading,children:H.jsxs("div",{className:me.uploadLoadingBody,children:[H.jsx("div",{className:me.uploadLoadingBodyAnimation}),H.jsx("div",{className:me.uploadLoadingBodyText,children:`${r.t("uploadLoading.loading")}: ${n}`})]})})};var mt=Object.defineProperty,ht=Object.getOwnPropertyDescriptor,pt=(i,r,n,e)=>{for(var t=e>1?void 0:e?ht(r,n):r,o=i.length-1,a;o>=0;o--)(a=i[o])&&(t=(e?a(r,n,t):a(t))||t);return e&&t&&mt(r,n,t),t},ne=(i,r)=>(n,e)=>r(n,e,i);let he=class extends d.RxDisposable{constructor(r,n,e,t,o,a,c){super();Y(this,"_initImagePopupMenu",new Set);this._injector=r,this._drawingManagerService=n,this._canvasPopManagerService=e,this._renderManagerService=t,this._univerInstanceService=o,this._contextService=a,this._uiPartsService=c,this._init()}_init(){this._univerInstanceService.getCurrentTypeOfUnit$(d.UniverInstanceType.UNIVER_SHEET).pipe(j.takeUntil(this.dispose$)).subscribe(r=>this._create(r)),this._univerInstanceService.getTypeOfUnitDisposed$(d.UniverInstanceType.UNIVER_SHEET).pipe(j.takeUntil(this.dispose$)).subscribe(r=>this._dispose(r)),this._univerInstanceService.getAllUnitsForType(d.UniverInstanceType.UNIVER_SHEET).forEach(r=>this._create(r)),this._uiPartsService.registerComponent(k.BuiltInUIPart.CONTENT,()=>d.connectInjector(gt,this._injector))}_dispose(r){const n=r.getUnitId();this._renderManagerService.removeRender(n)}_create(r){if(!r)return;const n=r.getUnitId();this._renderManagerService.has(n)&&!this._initImagePopupMenu.has(n)&&(this._popupMenuListener(n),this._initImagePopupMenu.add(n))}_hasCropObject(r){const n=r.getAllObjectsByOrder();for(const e of n)if(e instanceof q.ImageCropperObject)return!0;return!1}_popupMenuListener(r){var o;const n=(o=this._renderManagerService.getRenderById(r))==null?void 0:o.scene;if(!n)return;const e=n.getTransformerByCreate();if(!e)return;let t;this.disposeWithMe(d.toDisposable(e.createControl$.subscribe(()=>{if(this._contextService.setContextValue(d.FOCUSING_COMMON_DRAWINGS,!0),this._hasCropObject(n))return;const a=e.getSelectedObjectMap();if(a.size>1){t==null||t.dispose();return}const c=a.values().next().value;if(!c)return;const l=c.oKey,h=this._drawingManagerService.getDrawingOKey(l);if(!h)return;const{unitId:u,subUnitId:s,drawingId:m,drawingType:g}=h,f=h.data;if(f&&f.disablePopup)return;t==null||t.dispose();const S=this._canvasPopManagerService.getFeatureMenu(u,s,m,g);t=this.disposeWithMe(this._canvasPopManagerService.attachPopupToObject(c,{componentKey:q.COMPONENT_IMAGE_POPUP_MENU,direction:"horizontal",offset:[2,0],extraProps:{menuItems:S||this._getImageMenuItems(u,s,m,g)}})),this._drawingManagerService.focusDrawing([{unitId:u,subUnitId:s,drawingId:m}])}))),this.disposeWithMe(e.clearControl$.subscribe(()=>{t==null||t.dispose(),this._contextService.setContextValue(d.FOCUSING_COMMON_DRAWINGS,!1),this._drawingManagerService.focusDrawing(null)})),this.disposeWithMe(this._contextService.contextChanged$.subscribe(a=>{a[d.FOCUSING_COMMON_DRAWINGS]===!1&&(t==null||t.dispose())})),this.disposeWithMe(e.changing$.subscribe(()=>{t==null||t.dispose()}))}_getImageMenuItems(r,n,e,t){return[{label:"image-popup.edit",index:0,commandId:Ee.id,commandParams:{unitId:r,subUnitId:n,drawingId:e},disable:t===d.DrawingTypeEnum.DRAWING_DOM},{label:"image-popup.delete",index:1,commandId:ae.id,commandParams:{unitId:r,drawings:[{unitId:r,subUnitId:n,drawingId:e}]},disable:!1},{label:"image-popup.crop",index:2,commandId:q.OpenImageCropOperation.id,commandParams:{unitId:r,subUnitId:n,drawingId:e},disable:t===d.DrawingTypeEnum.DRAWING_DOM},{label:"image-popup.reset",index:3,commandId:q.ImageResetSizeOperation.id,commandParams:[{unitId:r,subUnitId:n,drawingId:e}],disable:t===d.DrawingTypeEnum.DRAWING_DOM}]}};he=pt([ne(0,d.Inject(d.Injector)),ne(1,P.IDrawingManagerService),ne(2,d.Inject(U.SheetCanvasPopManagerService)),ne(3,N.IRenderManagerService),ne(4,d.IUniverInstanceService),ne(5,d.IContextService),ne(6,d.Inject(k.IUIPartsService))],he);function V(i,r,n){const{from:e,to:t,flipY:o=!1,flipX:a=!1,angle:c=0,skewX:l=0,skewY:h=0}=i,u=n.getCurrent();if(u==null)return;const s=U.convertPositionSheetOverGridToAbsolute(u.unitId,u.sheetId,{from:e,to:t},n);let{left:m,top:g,width:f,height:S}=s;const v=n.getCurrentSkeleton(),C=v.rowHeaderWidth+v.columnTotalWidth,M=v.columnHeaderHeight+v.rowTotalHeight;return m+f>C&&(m=C-f),g+S>M&&(g=M-S),{flipY:o,flipX:a,angle:c,skewX:l,skewY:h,left:m,top:g,width:f,height:S}}function F(i,r){const{left:n=0,top:e=0,width:t=0,height:o=0,flipY:a=!1,flipX:c=!1,angle:l=0,skewX:h=0,skewY:u=0}=i,s=r.getCellWithCoordByOffset(n,e);if(s==null)return;const m={column:s.actualColumn,columnOffset:N.precisionTo(n-s.startX,1),row:s.actualRow,rowOffset:N.precisionTo(e-s.startY,1)},g=r.getCellWithCoordByOffset(n+t,e+o);if(g==null)return;const f={column:g.actualColumn,columnOffset:N.precisionTo(n+t-g.startX,1),row:g.actualRow,rowOffset:N.precisionTo(e+o-g.startY,1)};return{flipY:a,flipX:c,angle:l,skewX:h,skewY:u,from:m,to:f}}var ft=Object.defineProperty,St=Object.getOwnPropertyDescriptor,vt=(i,r,n,e)=>{for(var t=e>1?void 0:e?St(r,n):r,o=i.length-1,a;o>=0;o--)(a=i[o])&&(t=(e?a(r,n,t):a(t))||t);return e&&t&&ft(r,n,t),t},pe=(i,r)=>(n,e)=>r(n,e,i);let Pe=class extends d.Disposable{constructor(i,r,n,e,t){super(),this._context=i,this._sheetDrawingService=r,this._drawingManagerService=n,this._sheetSelectionRenderService=e,this._sheetSkeletonManagerService=t,this._init()}_init(){this._drawingInitializeListener()}_drawingInitializeListener(){this._sheetDrawingService.initializeNotification(this._context.unitId);const i=this._sheetDrawingService.getDrawingDataForUnit(this._context.unitId);for(const r in i){const n=i[r];for(const e in n.data){const t=n.data[e];t.transform=V(t.sheetTransform,this._sheetSelectionRenderService,this._sheetSkeletonManagerService)}}this._drawingManagerService.registerDrawingData(this._context.unitId,this._sheetDrawingService.getDrawingDataForUnit(this._context.unitId)),this._drawingManagerService.initializeNotification(this._context.unitId)}};Pe=vt([pe(1,p.ISheetDrawingService),pe(2,P.IDrawingManagerService),pe(3,d.Inject(U.ISheetSelectionRenderService)),pe(4,d.Inject(U.SheetSkeletonManagerService))],Pe);function _t(i){const r=[];return i.forEach(n=>{const{parent:e,children:t}=n,{unitId:o,subUnitId:a,drawingId:c}=e,l=N.getGroupState(0,0,t.map(s=>s.transform||{})),h=t.map(s=>{const m=s.transform||{left:0,top:0},{unitId:g,subUnitId:f,drawingId:S}=s;return{unitId:g,subUnitId:f,drawingId:S,transform:{...m,left:m.left-l.left,top:m.top-l.top},groupId:c}}),u={unitId:o,subUnitId:a,drawingId:c,drawingType:d.DrawingTypeEnum.DRAWING_GROUP,transform:l};r.push({parent:u,children:h})}),r}function wt(i){const r=[];return i.forEach(n=>{const{parent:e,children:t}=n,{unitId:o,subUnitId:a,drawingId:c,transform:l={width:0,height:0}}=e;if(l==null)return;const h=t.map(s=>{const{transform:m}=s,{unitId:g,subUnitId:f,drawingId:S}=s,v=N.transformObjectOutOfGroup(m||{},l,l.width||0,l.height||0);return{unitId:g,subUnitId:f,drawingId:S,transform:v,groupId:void 0}}),u={unitId:o,subUnitId:a,drawingId:c,drawingType:d.DrawingTypeEnum.DRAWING_GROUP,transform:{left:0,top:0}};r.push({parent:u,children:h})}),r}const Ae={id:"sheet.command.group-sheet-image",type:d.CommandType.COMMAND,handler:(i,r)=>{const n=i.get(d.ICommandService),e=i.get(d.IUndoRedoService),t=i.get(p.ISheetDrawingService);if(!r)return!1;const o=[];r.forEach(({parent:g,children:f})=>{o.push(g.unitId),f.forEach(S=>{o.push(S.unitId)})});const a=t.getGroupDrawingOp(r),{unitId:c,subUnitId:l,undo:h,redo:u,objects:s}=a;return n.syncExecuteCommand(p.SetDrawingApplyMutation.id,{op:u,unitId:c,subUnitId:l,objects:s,type:p.DrawingApplyType.GROUP})?(e.pushUndoRedo({unitID:c,undoMutations:[{id:p.SetDrawingApplyMutation.id,params:{op:h,unitId:c,subUnitId:l,objects:wt(s),type:p.DrawingApplyType.UNGROUP}},{id:G.id,params:o}],redoMutations:[{id:p.SetDrawingApplyMutation.id,params:{op:u,unitId:c,subUnitId:l,objects:s,type:p.DrawingApplyType.GROUP}},{id:G.id,params:o}]}),!0):!1}},ce={id:"sheet.command.insert-sheet-image",type:d.CommandType.COMMAND,handler:(i,r)=>{var M,y,R;const n=i.get(d.ICommandService),e=i.get(d.IUndoRedoService),t=i.get(p.ISheetDrawingService),o=i.get(_.SheetInterceptorService);if(!r)return!1;const a=r.drawings,c=a.map(I=>I.unitId),l=t.getBatchAddOp(a),{unitId:h,subUnitId:u,undo:s,redo:m,objects:g}=l,f=o.onCommandExecute({id:ce.id,params:r}),S={id:p.SetDrawingApplyMutation.id,params:{op:m,unitId:h,subUnitId:u,objects:g,type:p.DrawingApplyType.INSERT}},v={id:p.SetDrawingApplyMutation.id,params:{op:s,unitId:h,subUnitId:u,objects:g,type:p.DrawingApplyType.REMOVE}};return d.sequenceExecute([...(M=f.preRedos)!=null?M:[],S,...f.redos],n)?(e.pushUndoRedo({unitID:h,undoMutations:[...(y=f.preUndos)!=null?y:[],v,...f.undos,{id:G.id,params:c}],redoMutations:[...(R=f.preRedos)!=null?R:[],S,...f.redos,{id:G.id,params:c}]}),!0):!1}},Ue={id:"sheet.command.set-drawing-arrange",type:d.CommandType.COMMAND,handler:(i,r)=>{const n=i.get(d.ICommandService),e=i.get(d.IUndoRedoService);if(!r)return!1;const t=i.get(p.ISheetDrawingService),{unitId:o,subUnitId:a,drawingIds:c,arrangeType:l}=r,h={unitId:o,subUnitId:a,drawingIds:c};let u;if(l===d.ArrangeTypeEnum.forward?u=t.getForwardDrawingsOp(h):l===d.ArrangeTypeEnum.backward?u=t.getBackwardDrawingOp(h):l===d.ArrangeTypeEnum.front?u=t.getFrontDrawingsOp(h):l===d.ArrangeTypeEnum.back&&(u=t.getBackDrawingsOp(h)),u==null)return!1;const{objects:s,redo:m,undo:g}=u;return n.syncExecuteCommand(p.SetDrawingApplyMutation.id,{op:m,unitId:o,subUnitId:a,objects:s,type:p.DrawingApplyType.ARRANGE})?(e.pushUndoRedo({unitID:o,undoMutations:[{id:p.SetDrawingApplyMutation.id,params:{op:g,unitId:o,subUnitId:a,objects:s,type:p.DrawingApplyType.ARRANGE}}],redoMutations:[{id:p.SetDrawingApplyMutation.id,params:{op:m,unitId:o,subUnitId:a,objects:s,type:p.DrawingApplyType.ARRANGE}}]}),!0):!1}},de={id:"sheet.command.set-sheet-image",type:d.CommandType.COMMAND,handler:(i,r)=>{const n=i.get(d.ICommandService),e=i.get(d.IUndoRedoService),t=i.get(p.ISheetDrawingService);if(!r)return!1;const{drawings:o}=r,a=t.getBatchUpdateOp(o),{unitId:c,subUnitId:l,undo:h,redo:u,objects:s}=a;return n.syncExecuteCommand(p.SetDrawingApplyMutation.id,{unitId:c,subUnitId:l,op:u,objects:s,type:p.DrawingApplyType.UPDATE})?(e.pushUndoRedo({unitID:c,undoMutations:[{id:p.SetDrawingApplyMutation.id,params:{unitId:c,subUnitId:l,op:h,objects:s,type:p.DrawingApplyType.UPDATE}},{id:G.id,params:[c]}],redoMutations:[{id:p.SetDrawingApplyMutation.id,params:{unitId:c,subUnitId:l,op:u,objects:s,type:p.DrawingApplyType.UPDATE}},{id:G.id,params:[c]}]}),!0):!1}},Ne={id:"sheet.command.ungroup-sheet-image",type:d.CommandType.COMMAND,handler:(i,r)=>{const n=i.get(d.ICommandService),e=i.get(d.IUndoRedoService),t=i.get(p.ISheetDrawingService);if(!r)return!1;const o=[];r.forEach(({parent:g,children:f})=>{o.push(g.unitId),f.forEach(S=>{o.push(S.unitId)})});const a=t.getUngroupDrawingOp(r),{unitId:c,subUnitId:l,undo:h,redo:u,objects:s}=a;return n.syncExecuteCommand(p.SetDrawingApplyMutation.id,{op:u,unitId:c,subUnitId:l,objects:s,type:p.DrawingApplyType.UNGROUP})?(e.pushUndoRedo({unitID:c,undoMutations:[{id:p.SetDrawingApplyMutation.id,params:{op:h,unitId:c,subUnitId:l,objects:_t(s),type:p.DrawingApplyType.GROUP}},{id:G.id,params:o}],redoMutations:[{id:p.SetDrawingApplyMutation.id,params:{op:u,unitId:c,subUnitId:l,objects:s,type:p.DrawingApplyType.UNGROUP}},{id:G.id,params:o}]}),!0):!1}};var It=Object.defineProperty,Ct=Object.getOwnPropertyDescriptor,yt=(i,r,n,e)=>{for(var t=e>1?void 0:e?Ct(r,n):r,o=i.length-1,a;o>=0;o--)(a=i[o])&&(t=(e?a(r,n,t):a(t))||t);return e&&t&&It(r,n,t),t},z=(i,r)=>(n,e)=>r(n,e,i);function Mt(i,r,n){const e=n*Math.PI/180,t=Math.abs(i*Math.cos(e))+Math.abs(r*Math.sin(e)),o=Math.abs(i*Math.sin(e))+Math.abs(r*Math.cos(e));return{rotatedWidth:t,rotatedHeight:o}}function Je(i,r,n,e,t){var M;const{rotatedHeight:o,rotatedWidth:a}=Mt(n,e,t),l=i.get(N.IRenderManagerService).getRenderById(r.unitId);if(!l)return!1;const u=(M=l.with(U.SheetSkeletonManagerService).getWorksheetSkeleton(r.subUnitId))==null?void 0:M.skeleton;if(u==null)return!1;const s=u.getCellByIndex(r.row,r.col),m=s.mergeInfo.endX-s.mergeInfo.startX-2,g=s.mergeInfo.endY-s.mergeInfo.startY-2,f=a/o,v=Math.ceil(Math.min(m,g*f))/a,C=!v||Number.isNaN(v)?.001:v;return{width:n*C,height:e*C}}let le=class extends d.Disposable{constructor(r,n,e,t,o,a,c,l,h,u,s,m,g){super();Y(this,"_workbookSelections");this._context=r,this._skeletonManagerService=n,this._commandService=e,this._selectionRenderService=t,this._imageIoService=o,this._fileOpenerService=a,this._sheetDrawingService=c,this._drawingManagerService=l,this._contextService=h,this._messageService=u,this._localeService=s,this._injector=g,this._workbookSelections=m.getWorkbookSelections(this._context.unitId),this._updateImageListener(),this._updateOrderListener(),this._groupDrawingListener(),this._focusDrawingListener()}async insertFloatImage(){const r=await this._fileOpenerService.openFile({multiple:!0,accept:P.DRAWING_IMAGE_ALLOW_IMAGE_LIST.map(e=>`.${e.replace("image/","")}`).join(",")}),n=r.length;return n>P.DRAWING_IMAGE_COUNT_LIMIT?(this._messageService.show({type:J.MessageType.Error,content:this._localeService.t("update-status.exceedMaxCount",String(P.DRAWING_IMAGE_COUNT_LIMIT))}),!1):n===0?!1:(r.forEach(async e=>await this._insertFloatImage(e)),!0)}async insertCellImage(){const n=(await this._fileOpenerService.openFile({multiple:!1,accept:P.DRAWING_IMAGE_ALLOW_IMAGE_LIST.map(e=>`.${e.replace("image/","")}`).join(",")}))[0];return n?(await this._insertCellImage(n),!0):!1}async _insertFloatImage(r){let n;try{n=await this._imageIoService.saveImage(r)}catch(M){const y=M.message;y===P.ImageUploadStatusType.ERROR_EXCEED_SIZE?this._messageService.show({type:J.MessageType.Error,content:this._localeService.t("update-status.exceedMaxSize",String(P.DRAWING_IMAGE_ALLOW_SIZE/(1024*1024)))}):y===P.ImageUploadStatusType.ERROR_IMAGE_TYPE?this._messageService.show({type:J.MessageType.Error,content:this._localeService.t("update-status.invalidImageType")}):y===P.ImageUploadStatusType.ERROR_IMAGE&&this._messageService.show({type:J.MessageType.Error,content:this._localeService.t("update-status.invalidImage")})}if(n==null)return;const e=this._getUnitInfo(),{unitId:t,subUnitId:o}=e,{imageId:a,imageSourceType:c,source:l,base64Cache:h}=n,{width:u,height:s,image:m}=await P.getImageSize(h||""),{width:g,height:f}=this._context.scene;this._imageIoService.addImageSourceCache(l,c,m);let S=1;if(u>P.DRAWING_IMAGE_WIDTH_LIMIT||s>P.DRAWING_IMAGE_HEIGHT_LIMIT){const M=P.DRAWING_IMAGE_WIDTH_LIMIT/u,y=P.DRAWING_IMAGE_HEIGHT_LIMIT/s;S=Math.max(M,y)}const v=this._getImagePosition(u*S,s*S,g,f);if(v==null)return;const C={unitId:t,subUnitId:o,drawingId:a,drawingType:d.DrawingTypeEnum.DRAWING_IMAGE,imageSourceType:c,source:l,transform:V(v,this._selectionRenderService,this._skeletonManagerService),sheetTransform:v};this._commandService.executeCommand(ce.id,{unitId:t,drawings:[C]})}async _insertCellImage(r){let n;try{n=await this._imageIoService.saveImage(r)}catch(v){const C=v.message;C===P.ImageUploadStatusType.ERROR_EXCEED_SIZE?this._messageService.show({type:J.MessageType.Error,content:this._localeService.t("update-status.exceedMaxSize",String(P.DRAWING_IMAGE_ALLOW_SIZE/(1024*1024)))}):C===P.ImageUploadStatusType.ERROR_IMAGE_TYPE?this._messageService.show({type:J.MessageType.Error,content:this._localeService.t("update-status.invalidImageType")}):C===P.ImageUploadStatusType.ERROR_IMAGE&&this._messageService.show({type:J.MessageType.Error,content:this._localeService.t("update-status.invalidImage")})}if(n==null)return;const{imageId:e,imageSourceType:t,source:o,base64Cache:a}=n,{width:c,height:l,image:h}=await P.getImageSize(a||"");this._imageIoService.addImageSourceCache(o,t,h);const u=this._workbookSelections.getCurrentLastSelection();if(!u)return!1;const s=d.createDocumentModelWithStyle("",{}),m=Je(this._injector,{unitId:this._context.unitId,subUnitId:this._context.unit.getActiveSheet().getSheetId(),row:u.primary.actualRow,col:u.primary.actualColumn},c,l,0);if(!m)return!1;const g={size:{width:m.width,height:m.height},positionH:{relativeFrom:d.ObjectRelativeFromH.PAGE,posOffset:0},positionV:{relativeFrom:d.ObjectRelativeFromV.PARAGRAPH,posOffset:0},angle:0},f={unitId:s.getUnitId(),subUnitId:s.getUnitId(),drawingId:e,drawingType:d.DrawingTypeEnum.DRAWING_IMAGE,imageSourceType:t,source:o,transform:xe.docDrawingPositionToTransform(g),docTransform:g,behindDoc:d.BooleanNumber.FALSE,title:"",description:"",layoutType:d.PositionedObjectLayoutType.INLINE,wrapText:d.WrapTextType.BOTH_SIDES,distB:0,distL:0,distR:0,distT:0},S=d.BuildTextUtils.drawing.add({documentDataModel:s,drawings:[f],selection:{collapsed:!0,startOffset:0,endOffset:0}});return S?(s.apply(S),this._commandService.syncExecuteCommand(_.SetRangeValuesCommand.id,{value:{[u.primary.actualRow]:{[u.primary.actualColumn]:{p:s.getSnapshot(),t:1}}}})):!1}_getUnitInfo(){const r=this._context.unit,n=r.getActiveSheet(),e=r.getUnitId(),t=n.getSheetId();return{unitId:e,subUnitId:t}}_getImagePosition(r,n,e,t){const o=this._workbookSelections.getCurrentSelections();let a={startRow:0,endRow:0,startColumn:0,endColumn:0};o&&o.length>0&&(a=o[o.length-1].range);const c=U.attachRangeWithCoord(this._skeletonManagerService.getCurrent().skeleton,a);if(c==null)return;let{startColumn:l,startRow:h,startX:u,startY:s}=c,m=!1;if(u+r>e&&(u=e-r,u<0&&(u=0,r=e),m=!0),s+n>t&&(s=t-n,s<0&&(s=0,n=t),m=!0),m){const v=this._selectionRenderService.getCellWithCoordByOffset(u,s);if(v==null)return;u=v.startX,s=v.startY,l=v.actualColumn,h=v.actualRow}const g={column:l,columnOffset:0,row:h,rowOffset:0},f=this._selectionRenderService.getCellWithCoordByOffset(u+r,s+n);if(f==null)return;const S={column:f.actualColumn,columnOffset:u+r-f.startX,row:f.actualRow,rowOffset:s+n-f.startY};return{from:g,to:S}}_updateOrderListener(){this.disposeWithMe(this._drawingManagerService.featurePluginOrderUpdate$.subscribe(r=>{const{unitId:n,subUnitId:e,drawingIds:t,arrangeType:o}=r;this._commandService.executeCommand(Ue.id,{unitId:n,subUnitId:e,drawingIds:t,arrangeType:o})}))}_updateImageListener(){this.disposeWithMe(this._drawingManagerService.featurePluginUpdate$.subscribe(r=>{const n=[];r.length!==0&&(r.forEach(e=>{const{unitId:t,subUnitId:o,drawingId:a,drawingType:c,transform:l}=e;if(l==null)return;const h=this._sheetDrawingService.getDrawingByParam({unitId:t,subUnitId:o,drawingId:a});if(h==null||h.unitId!==this._context.unitId)return;const u=F({...h.transform,...l},this._selectionRenderService);if(u==null)return;const s={...e,transform:{...h.transform,...l,...V(u,this._selectionRenderService,this._skeletonManagerService)},sheetTransform:{...u}};n.push(s)}),n.length>0&&this._commandService.executeCommand(de.id,{unitId:r[0].unitId,drawings:n}))}))}_groupDrawingListener(){this.disposeWithMe(this._drawingManagerService.featurePluginGroupUpdate$.subscribe(r=>{this._commandService.executeCommand(Ae.id,r);const{unitId:n,subUnitId:e,drawingId:t}=r[0].parent;this._drawingManagerService.focusDrawing([{unitId:n,subUnitId:e,drawingId:t}])})),this.disposeWithMe(this._drawingManagerService.featurePluginUngroupUpdate$.subscribe(r=>{this._commandService.executeCommand(Ne.id,r)}))}_focusDrawingListener(){this.disposeWithMe(this._drawingManagerService.focus$.subscribe(r=>{r==null||r.length===0?(this._contextService.setContextValue(d.FOCUSING_COMMON_DRAWINGS,!1),this._sheetDrawingService.focusDrawing([])):(this._contextService.setContextValue(d.FOCUSING_COMMON_DRAWINGS,!0),this._sheetDrawingService.focusDrawing(r))}))}};le=yt([z(1,d.Inject(U.SheetSkeletonManagerService)),z(2,d.ICommandService),z(3,U.ISheetSelectionRenderService),z(4,P.IImageIoService),z(5,k.ILocalFileService),z(6,p.ISheetDrawingService),z(7,P.IDrawingManagerService),z(8,d.IContextService),z(9,k.IMessageService),z(10,d.Inject(d.LocaleService)),z(11,d.Inject(_.SheetsSelectionsService)),z(12,d.Inject(d.Injector))],le);var Dt=Object.defineProperty,Tt=Object.getOwnPropertyDescriptor,Rt=(i,r,n,e)=>{for(var t=e>1?void 0:e?Tt(r,n):r,o=i.length-1,a;o>=0;o--)(a=i[o])&&(t=(e?a(r,n,t):a(t))||t);return e&&t&&Dt(r,n,t),t},re=(i,r)=>(n,e)=>r(n,e,i);function je(i,r,n){var e,t,o,a;if(((t=(e=n==null?void 0:n.p)==null?void 0:e.body)==null?void 0:t.dataStream.length)===3&&((a=(o=n.p)==null?void 0:o.drawingsOrder)==null?void 0:a.length)===1){const c=n.p.drawings[n.p.drawingsOrder[0]],l=Je(i,{unitId:r.unitId,subUnitId:r.subUnitId,row:r.row,col:r.col},c.docTransform.size.width,c.docTransform.size.height,c.docTransform.angle);if(l)return c.transform.width=l.width,c.transform.height=l.height,c.docTransform.size.width=l.width,c.docTransform.size.height=l.height,c.transform.left=0,c.transform.top=0,c.docTransform.positionH.posOffset=0,c.docTransform.positionV.posOffset=0,n.p.documentStyle.pageSize.width=1/0,n.p.documentStyle.pageSize.height=1/0,!0}return!1}let fe=class extends d.Disposable{constructor(i,r,n,e,t,o,a){super(),this._commandService=i,this._sheetInterceptorService=r,this._univerInstanceService=n,this._injector=e,this._drawingManagerService=t,this._docDrawingController=o,this._editorBridgeService=a,this._initHandleResize(),this._handleInitEditor(),this._handleWriteCell(),this._initCellContentInterceptor()}_initHandleResize(){this.disposeWithMe(this._commandService.onCommandExecuted(i=>{let r,n=[];if(i.id===_.SetWorksheetRowHeightMutation.id){const e=i.params;n=e.ranges,r=_.getSheetCommandTarget(this._univerInstanceService,{unitId:e.unitId,subUnitId:e.subUnitId})}else if(i.id===_.SetWorksheetColWidthMutation.id){const e=i.params;n=e.ranges,r=_.getSheetCommandTarget(this._univerInstanceService,{unitId:e.unitId,subUnitId:e.subUnitId})}else if(i.id===_.SetWorksheetRowIsAutoHeightMutation.id){const e=i.params;n=e.ranges,r=_.getSheetCommandTarget(this._univerInstanceService,{unitId:e.unitId,subUnitId:e.subUnitId})}else if(i.id===_.SetWorksheetRowAutoHeightMutation.id){const e=i.params;r=_.getSheetCommandTarget(this._univerInstanceService,{unitId:e.unitId,subUnitId:e.subUnitId}),n=e.rowsAutoHeightInfo.map(t=>({startRow:t.row,endRow:t.row,startColumn:0,endColumn:9999}))}else if(i.id===_.AddWorksheetMergeMutation.id){const e=i.params;n=e.ranges,r=_.getSheetCommandTarget(this._univerInstanceService,{unitId:e.unitId,subUnitId:e.subUnitId})}else if(i.id===_.RemoveWorksheetMergeMutation.id){const e=i.params;n=e.ranges,r=_.getSheetCommandTarget(this._univerInstanceService,{unitId:e.unitId,subUnitId:e.subUnitId})}r&&n.length&&n.forEach(e=>{const t=d.Range.transformRange(e,r.worksheet);for(let o=t.startRow;o<=t.endRow;o++)for(let a=t.startColumn;a<=t.endColumn;a++)je(this._injector,{unitId:r.unitId,subUnitId:r.subUnitId,row:o,col:a},r.worksheet.getCellRaw(o,a))})}))}_handleInitEditor(){this.disposeWithMe(this._editorBridgeService.visible$.subscribe(i=>{i.visible?i.visible&&(this._drawingManagerService.removeDrawingDataForUnit(d.DOCS_NORMAL_EDITOR_UNIT_ID_KEY),this._docDrawingController.loadDrawingDataForUnit(d.DOCS_NORMAL_EDITOR_UNIT_ID_KEY),this._drawingManagerService.initializeNotification(d.DOCS_NORMAL_EDITOR_UNIT_ID_KEY)):this._drawingManagerService.removeDrawingDataForUnit(d.DOCS_NORMAL_EDITOR_UNIT_ID_KEY)})),this.disposeWithMe(this._commandService.onCommandExecuted(i=>{i.id===xe.ReplaceSnapshotCommand.id&&i.params.unitId===d.DOCS_ZEN_EDITOR_UNIT_ID_KEY&&(this._drawingManagerService.removeDrawingDataForUnit(d.DOCS_ZEN_EDITOR_UNIT_ID_KEY),this._docDrawingController.loadDrawingDataForUnit(d.DOCS_ZEN_EDITOR_UNIT_ID_KEY),this._drawingManagerService.initializeNotification(d.DOCS_ZEN_EDITOR_UNIT_ID_KEY))}))}_handleWriteCell(){this.disposeWithMe(this._sheetInterceptorService.writeCellInterceptor.intercept(_.AFTER_CELL_EDIT,{priority:9999,handler:(i,r,n)=>(je(this._injector,{unitId:r.unitId,subUnitId:r.subUnitId,row:r.row,col:r.col},i),n(i))}))}_initCellContentInterceptor(){this.disposeWithMe(this._sheetInterceptorService.intercept(_.INTERCEPTOR_POINT.CELL_CONTENT,{effect:d.InterceptorEffectEnum.Style,priority:_.InterceptCellContentPriority.CELL_IMAGE,handler:(i,r,n)=>{var e;return i!=null&&i.p&&((e=i.p.drawingsOrder)!=null&&e.length)&&(i.interceptorStyle||(i.interceptorStyle={}),i.interceptorStyle.tr={a:0}),n(i)}}))}};fe=Rt([re(0,d.ICommandService),re(1,d.Inject(_.SheetInterceptorService)),re(2,d.IUniverInstanceService),re(3,d.Inject(d.Injector)),re(4,P.IDrawingManagerService),re(5,d.Inject(te.DocDrawingController)),re(6,d.Inject(U.IEditorBridgeService))],fe);var bt=Object.defineProperty,Et=Object.getOwnPropertyDescriptor,Ot=(i,r,n,e)=>{for(var t=e>1?void 0:e?Et(r,n):r,o=i.length-1,a;o>=0;o--)(a=i[o])&&(t=(e?a(r,n,t):a(t))||t);return e&&t&&bt(r,n,t),t},Ze=(i,r)=>(n,e)=>r(n,e,i);let Se=class extends d.Disposable{constructor(i,r){super(),this._autoFillService=i,this._injector=r,this._initAutoFillHooks()}_initAutoFillHooks(){this.disposeWithMe(this._autoFillService.addHook({id:"sheet-cell-image-autofill",onBeforeSubmit:(i,r,n,e)=>{new d.ObjectMatrix(e).forValue((t,o,a)=>{je(this._injector,{unitId:i.unitId,subUnitId:i.subUnitId,row:t,col:o},a)})}}))}};Se=Ot([Ze(0,d.Inject(U.IAutoFillService)),Ze(1,d.Inject(d.Injector))],Se);var Pt=Object.defineProperty,At=Object.getOwnPropertyDescriptor,Ut=(i,r,n,e)=>{for(var t=e>1?void 0:e?At(r,n):r,o=i.length-1,a;o>=0;o--)(a=i[o])&&(t=(e?a(r,n,t):a(t))||t);return e&&t&&Pt(r,n,t),t},ve=(i,r)=>(n,e)=>r(n,e,i);let _e=class extends d.Disposable{constructor(r,n,e,t){super();Y(this,"_isSetCursor",!1);this._hoverManagerService=r,this._renderManagerService=n,this._selectionsService=e,this._drawingRenderService=t}_initHover(){}_initImageClick(){}};_e=Ut([ve(0,d.Inject(U.HoverManagerService)),ve(1,d.Inject(N.IRenderManagerService)),ve(2,d.Inject(_.SheetsSelectionsService)),ve(3,d.Inject(q.DrawingRenderService))],_e);var Nt=Object.defineProperty,jt=Object.getOwnPropertyDescriptor,Wt=(i,r,n,e)=>{for(var t=e>1?void 0:e?jt(r,n):r,o=i.length-1,a;o>=0;o--)(a=i[o])&&(t=(e?a(r,n,t):a(t))||t);return e&&t&&Nt(r,n,t),t},We=(i,r)=>(n,e)=>r(n,e,i);let we=class extends d.Disposable{constructor(r,n,e){super();Y(this,"_copyInfo");this._sheetClipboardService=r,this._renderManagerService=n,this._sheetDrawingService=e,this._initCopyPaste()}_initCopyPaste(){this._sheetClipboardService.addClipboardHook({id:"SHEET_IMAGE_UI_PLUGIN",onBeforeCopy:(r,n,e)=>this._collect(r,n,e),onPasteCells:(r,n,e,t)=>{const{copyType:o=U.COPY_TYPE.COPY,pasteType:a}=t,{range:c}=r||{},{range:l,unitId:h,subUnitId:u}=n;return this._generateMutations(l,{copyType:o,pasteType:a,copyRange:c,unitId:h,subUnitId:u})},onPastePlainText:(r,n)=>({undos:[],redos:[]})})}_collect(r,n,e){var m;const t=(m=this._renderManagerService.getRenderById(r))==null?void 0:m.with(U.SheetSkeletonManagerService);if(!t)return;const o=t.attachRangeWithCoord(e);if(!o)return;const{startX:a,endX:c,startY:l,endY:h}=o,u=this._sheetDrawingService.getDrawingData(r,n),s=[];Object.keys(u).forEach(g=>{const f=u[g],{transform:S}=f;if(f.anchorType!==p.SheetDrawingAnchorType.Both||!S)return;const{left:v=0,top:C=0,width:M=0,height:y=0}=S,{drawingStartX:R,drawingEndX:I,drawingStartY:D,drawingEndY:w}={drawingStartX:v,drawingEndX:v+M,drawingStartY:C,drawingEndY:C+y};a<=R&&I<=c&&l<=D&&w<=h&&s.push(f)}),s.length&&(this._copyInfo={drawings:s,unitId:r,subUnitId:n})}_generateMutations(r,n){var E;if(!this._copyInfo)return{redos:[],undos:[]};if([U.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_COL_WIDTH,U.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_VALUE,U.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMAT,U.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMULA].includes(n.pasteType))return{redos:[],undos:[]};const{copyRange:e}=n;if(!e)return{redos:[],undos:[]};const{drawings:t,unitId:o,subUnitId:a}=this._copyInfo,{ranges:[c,l],mapFunc:h}=U.virtualizeDiscreteRanges([e,r]),{row:u,col:s}=h(c.startRow,c.startColumn),{row:m,col:g}=h(l.startRow,l.startColumn),f=(E=this._renderManagerService.getRenderById(o))==null?void 0:E.with(U.SheetSkeletonManagerService);if(!f)return{redos:[],undos:[]};const S=f.attachRangeWithCoord({startRow:u,endRow:u,startColumn:s,endColumn:s}),v=f.attachRangeWithCoord({startRow:m,endRow:m,startColumn:g,endColumn:g});if(!S||!v)return{redos:[],undos:[]};const C=[],M=[],y=v.startX-S.startX,R=v.startY-S.startY,I=m-u,D=g-s,w=n.copyType===U.COPY_TYPE.CUT,{_sheetDrawingService:A}=this;return t.forEach(B=>{const{transform:W,sheetTransform:O}=B;if(!W)return;const T={...B,unitId:o,subUnitId:a,drawingId:w?B.drawingId:d.Tools.generateRandomId(),transform:{...W,left:W.left+y,top:W.top+R},sheetTransform:{to:{...O.to,row:O.to.row+I,column:O.to.column+D},from:{...O.from,row:O.from.row+I,column:O.from.column+D}}};if(w){const{undo:L,redo:$,objects:Z}=A.getBatchUpdateOp([T]);C.push({id:p.SetDrawingApplyMutation.id,params:{unitId:o,subUnitId:a,type:p.DrawingApplyType.UPDATE,op:$,objects:Z}}),M.push({id:p.SetDrawingApplyMutation.id,params:{unitId:o,subUnitId:a,type:p.DrawingApplyType.UPDATE,op:L,objects:Z}})}else{const{undo:L,redo:$,objects:Z}=A.getBatchAddOp([T]);C.push({id:p.SetDrawingApplyMutation.id,params:{op:$,unitId:o,subUnitId:a,objects:Z,type:p.DrawingApplyType.INSERT}}),M.push({id:p.SetDrawingApplyMutation.id,params:{op:L,unitId:o,subUnitId:a,objects:Z,type:p.DrawingApplyType.REMOVE}})}}),{redos:C,undos:M}}};we=Wt([We(0,U.ISheetClipboardService),We(1,N.IRenderManagerService),We(2,p.ISheetDrawingService)],we);var Lt=Object.defineProperty,Bt=Object.getOwnPropertyDescriptor,Gt=(i,r,n,e)=>{for(var t=e>1?void 0:e?Bt(r,n):r,o=i.length-1,a;o>=0;o--)(a=i[o])&&(t=(e?a(r,n,t):a(t))||t);return e&&t&&Lt(r,n,t),t},ue=(i,r)=>(n,e)=>r(n,e,i);let Ie=class extends d.Disposable{constructor(i,r,n,e,t){super(),this._drawingManagerService=i,this._renderManagerService=r,this._permissionService=n,this._univerInstanceService=e,this._userManagerService=t,this._initDrawingVisible(),this._initDrawingEditable(),this._initViewPermissionChange(),this._initEditPermissionChange()}_initDrawingVisible(){const i=this._univerInstanceService.getCurrentTypeOfUnit$(d.UniverInstanceType.UNIVER_SHEET);this.disposeWithMe(j.combineLatest([i,this._userManagerService.currentUser$]).subscribe(([r,n])=>{if(!r){this._drawingManagerService.setDrawingVisible(!1);return}r.activeSheet$.subscribe(e=>{if(!e){this._drawingManagerService.setDrawingVisible(!1);return}const t=r.getUnitId(),o=e.getSheetId();if(this._permissionService.composePermission([new _.WorkbookViewPermission(t).id,new _.WorksheetViewPermission(t,o).id]).every(c=>c.value))this._drawingManagerService.setDrawingVisible(!0);else{this._drawingManagerService.setDrawingVisible(!1);const c=r.getUnitId(),l=e.getSheetId(),h=this._drawingManagerService.getDrawingData(c,l),u=Object.values(h),s=this._renderManagerService.getRenderById(c),m=s==null?void 0:s.scene;if(m==null)return;m.getAllObjectsByOrder().forEach(f=>{f.classType===N.RENDER_CLASS_TYPE.IMAGE&&u.some(S=>f.oKey.includes(S.drawingId))&&m.removeObject(f)})}})}))}_initDrawingEditable(){const i=this._univerInstanceService.getCurrentTypeOfUnit$(d.UniverInstanceType.UNIVER_SHEET);this.disposeWithMe(j.combineLatest([i,this._userManagerService.currentUser$]).subscribe(([r,n])=>{if(!r){this._drawingManagerService.setDrawingEditable(!1);return}r.activeSheet$.subscribe(e=>{if(!e){this._drawingManagerService.setDrawingEditable(!1);return}const t=r.getUnitId(),o=e.getSheetId();if(this._permissionService.composePermission([new _.WorkbookEditablePermission(t).id,new _.WorksheetEditPermission(t,o).id]).every(c=>c.value))this._drawingManagerService.setDrawingEditable(!0);else{this._drawingManagerService.setDrawingEditable(!1);const c=r.getUnitId(),l=e.getSheetId(),h=this._drawingManagerService.getDrawingData(c,l),u=Object.values(h),s=this._renderManagerService.getRenderById(c),m=s==null?void 0:s.scene;if(m==null)return;m.getAllObjectsByOrder().forEach(f=>{f.classType===N.RENDER_CLASS_TYPE.IMAGE&&u.some(S=>f.oKey.includes(S.drawingId))&&m.detachTransformerFrom(f)})}})}))}_initViewPermissionChange(){const i=this._univerInstanceService.getCurrentTypeOfUnit$(d.UniverInstanceType.UNIVER_SHEET);this.disposeWithMe(j.combineLatest([i,this._userManagerService.currentUser$]).subscribe(([r,n])=>{r&&r.activeSheet$.subscribe(e=>{var s;if(!e)return;const t=r.getUnitId(),o=e.getSheetId();let a=!0;const c=this._renderManagerService.getRenderById(t),l=c==null?void 0:c.scene;if(l==null)return;const h=l.getTransformerByCreate(),u=this._permissionService.composePermission$([new _.WorkbookViewPermission(t).id,new _.WorksheetViewPermission(t,o).id]).pipe(j.map(m=>m.every(g=>g.value)));u==null||u.pipe(j.filter(m=>m!==a),j.distinctUntilChanged()).subscribe({next:m=>{a=m,this._drawingManagerService.setDrawingVisible(m);const g=l.getAllObjectsByOrder(),f=this._drawingManagerService.getDrawingData(t,o),S=Object.values(f);m?this._drawingManagerService.addNotification(S):(g.forEach(v=>{v.classType===N.RENDER_CLASS_TYPE.IMAGE&&S.some(C=>v.oKey.includes(C.drawingId))&&l.removeObject(v)}),h.clearSelectedObjects())}}),(s=this._permissionService.getPermissionPoint$(new _.WorksheetViewPermission(t,o).id))==null||s.pipe(j.filter(m=>m.value!==a),j.distinctUntilChanged()).subscribe({complete:()=>{a=!0,this._drawingManagerService.setDrawingVisible(!0);const m=this._drawingManagerService.getDrawingData(t,o),g=Object.values(m);this._drawingManagerService.addNotification(g)}})})}))}_initEditPermissionChange(){const i=this._univerInstanceService.getCurrentTypeOfUnit$(d.UniverInstanceType.UNIVER_SHEET);this.disposeWithMe(j.combineLatest([i,this._userManagerService.currentUser$]).subscribe(([r,n])=>{r&&r.activeSheet$.subscribe(e=>{var s;if(!e)return;const t=r.getUnitId(),o=e.getSheetId();let a=!0;const c=this._renderManagerService.getRenderById(t),l=c==null?void 0:c.scene;if(l==null)return;const h=l.getTransformerByCreate(),u=this._permissionService.composePermission$([new _.WorkbookEditablePermission(t).id,new _.WorksheetEditPermission(t,o).id]).pipe(j.map(m=>m.every(g=>g.value)));u==null||u.pipe(j.filter(m=>m!==a),j.distinctUntilChanged()).subscribe({next:m=>{a=m,this._drawingManagerService.setDrawingEditable(m);const g=l.getAllObjectsByOrder(),f=this._drawingManagerService.getDrawingData(t,o),S=Object.values(f);m?(g.forEach(v=>{v.classType===N.RENDER_CLASS_TYPE.IMAGE&&S.some(C=>v.oKey.includes(C.drawingId))&&l.attachTransformerTo(v)}),this._drawingManagerService.addNotification(S)):(g.forEach(v=>{v.classType===N.RENDER_CLASS_TYPE.IMAGE&&S.some(C=>v.oKey.includes(C.drawingId))&&l.detachTransformerFrom(v)}),h.clearSelectedObjects())}}),(s=this._permissionService.getPermissionPoint$(new _.WorksheetEditPermission(t,o).id))==null||s.pipe(j.filter(m=>m.value!==a),j.distinctUntilChanged()).subscribe({complete:()=>{a=!0;const m=r.getUnitId(),g=e.getSheetId(),f=this._drawingManagerService.getDrawingData(m,g),S=Object.values(f),v=this._renderManagerService.getRenderById(m),C=v==null?void 0:v.scene;if(C==null)return;this._drawingManagerService.setDrawingEditable(!0),C.getAllObjectsByOrder().forEach(y=>{y.classType===N.RENDER_CLASS_TYPE.IMAGE&&S.some(R=>y.oKey.includes(R.drawingId))&&C.detachTransformerFrom(y)})}})})}))}};Ie=Gt([ue(0,P.IDrawingManagerService),ue(1,N.IRenderManagerService),ue(2,d.IPermissionService),ue(3,d.IUniverInstanceService),ue(4,d.Inject(d.UserManagerService))],Ie);var kt=Object.defineProperty,Ft=Object.getOwnPropertyDescriptor,$t=(i,r,n,e)=>{for(var t=e>1?void 0:e?Ft(r,n):r,o=i.length-1,a;o>=0;o--)(a=i[o])&&(t=(e?a(r,n,t):a(t))||t);return e&&t&&kt(r,n,t),t},Ce=(i,r)=>(n,e)=>r(n,e,i);let ye=class extends d.Disposable{constructor(i,r,n,e){super(),this._sheetPrintInterceptorService=i,this._drawingRenderService=r,this._drawingManagerService=n,this._renderManagerService=e,this._initPrinting()}_initPrinting(){this.disposeWithMe(this._sheetPrintInterceptorService.interceptor.intercept(this._sheetPrintInterceptorService.interceptor.getInterceptPoints().PRINTING_COMPONENT_COLLECT,{handler:(i,r,n)=>{const{unitId:e,scene:t,subUnitId:o}=r,a=this._drawingManagerService.getDrawingDataForUnit(e),c=a==null?void 0:a[o];return c&&c.order.forEach(l=>{this._drawingRenderService.renderDrawing(c.data[l],t)}),n()}})),this.disposeWithMe(this._sheetPrintInterceptorService.interceptor.intercept(this._sheetPrintInterceptorService.interceptor.getInterceptPoints().PRINTING_RANGE,{handler:(i,r,n)=>{const{unitId:e,subUnitId:t}=r,o=this._renderManagerService.getRenderById(e);if(!o)return n(i);const a=o.with(U.SheetSkeletonManagerService).getWorksheetSkeleton(t);if(!a)return n(i);const c=this._drawingManagerService.getDrawingDataForUnit(e),l=c==null?void 0:c[r.subUnitId];if(!l)return n(i);const{scaleX:h,scaleY:u}=o.scene,s=i?{...i}:{startColumn:0,endColumn:0,endRow:0,startRow:0},m=l.order.map(g=>l.data[g]).filter(g=>g.drawingType!==d.DrawingTypeEnum.DRAWING_DOM);return m.length?(m.forEach(g=>{if(!g.groupId&&g.transform&&d.Tools.isDefine(g.transform.left)&&d.Tools.isDefine(g.transform.top)&&d.Tools.isDefine(g.transform.width)&&d.Tools.isDefine(g.transform.height)){const f=a.skeleton.getCellIndexByOffset(g.transform.left,g.transform.top,h,u,{x:0,y:0}),S=a.skeleton.getCellIndexByOffset(g.transform.left+g.transform.width,g.transform.top+g.transform.height,h,u,{x:0,y:0});f.column<s.startColumn&&(s.startColumn=f.column),f.row<s.startRow&&(s.startRow=f.row),s.endRow<S.row&&(s.endRow=S.row),s.endColumn<S.column&&(s.endColumn=S.column)}}),n(s)):n(i)}}))}};ye=$t([Ce(0,d.Inject(U.SheetPrintInterceptorService)),Ce(1,d.Inject(q.DrawingRenderService)),Ce(2,P.IDrawingManagerService),Ce(3,N.IRenderManagerService)],ye);var Ht=Object.defineProperty,Vt=Object.getOwnPropertyDescriptor,xt=(i,r,n,e)=>{for(var t=e>1?void 0:e?Vt(r,n):r,o=i.length-1,a;o>=0;o--)(a=i[o])&&(t=(e?a(r,n,t):a(t))||t);return e&&t&&Ht(r,n,t),t},Q=(i,r)=>(n,e)=>r(n,e,i);const Yt=[_.InsertRowCommand.id,_.InsertColCommand.id,_.RemoveRowCommand.id,_.RemoveColCommand.id,_.DeleteRangeMoveLeftCommand.id,_.DeleteRangeMoveUpCommand.id,_.InsertRangeMoveDownCommand.id,_.InsertRangeMoveRightCommand.id,_.DeltaRowHeightCommand.id,_.SetRowHeightCommand.id,_.DeltaColumnWidthCommand.id,_.SetColWidthCommand.id,_.SetRowHiddenCommand.id,_.SetSpecificRowsVisibleCommand.id,_.SetSpecificColsVisibleCommand.id,_.SetColHiddenCommand.id,_.MoveColsCommand.id,_.MoveRowsCommand.id,_.MoveRangeCommand.id],Xt=[_.SetRowVisibleMutation.id,_.SetRowHiddenMutation.id,_.SetColVisibleMutation.id,_.SetColHiddenMutation.id,_.SetWorksheetRowHeightMutation.id,_.SetWorksheetColWidthMutation.id];let Le=class extends d.Disposable{constructor(i,r,n,e,t,o,a,c,l){super(),this._context=i,this._renderManagerService=r,this._commandService=n,this._selectionRenderService=e,this._skeletonManagerService=t,this._sheetInterceptorService=o,this._sheetDrawingService=a,this._drawingManagerService=c,this._univerInstanceService=l,this._sheetInterceptorListener(),this._commandListener(),this._sheetRefreshListener()}_sheetInterceptorListener(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:i=>{if(!Yt.includes(i.id))return{redos:[],undos:[]};if(i.params==null)return{redos:[],undos:[]};const r=i.id;if(r===_.InsertRowCommand.id)return this._moveRowInterceptor(i.params,"insert");if([_.MoveColsCommand.id,_.MoveRowsCommand.id,_.MoveRangeCommand.id].includes(r))return this._moveRangeInterceptor(i.params);if(r===_.InsertColCommand.id)return this._moveColInterceptor(i.params,"insert");if(r===_.RemoveRowCommand.id)return this._moveRowInterceptor(i.params,"remove");if(r===_.RemoveColCommand.id)return this._moveColInterceptor(i.params,"remove");if(r===_.DeleteRangeMoveLeftCommand.id){const{range:n}=i.params;return this._getRangeMoveUndo(n,0)}else if(r===_.DeleteRangeMoveUpCommand.id){const{range:n}=i.params;return this._getRangeMoveUndo(n,1)}else if(r===_.InsertRangeMoveDownCommand.id){const{range:n}=i.params;return this._getRangeMoveUndo(n,2)}else if(r===_.InsertRangeMoveRightCommand.id){const{range:n}=i.params;return this._getRangeMoveUndo(n,3)}else if(r===_.SetRowHiddenCommand.id||r===_.SetSpecificRowsVisibleCommand.id){const n=i.params,{unitId:e,subUnitId:t,ranges:o}=n;return this._getDrawingUndoForRowVisible(e,t,o)}else if(r===_.SetSpecificColsVisibleCommand.id||r===_.SetColHiddenCommand.id){const n=i.params,{unitId:e,subUnitId:t,ranges:o}=n;return this._getDrawingUndoForColVisible(e,t,o)}else if(r===_.DeltaRowHeightCommand.id||r===_.SetRowHeightCommand.id||r===_.DeltaColumnWidthCommand.id||r===_.SetColWidthCommand.id){const n=i.params,{unitId:e,subUnitId:t,ranges:o}=n,a=r===_.DeltaRowHeightCommand.id||r===_.SetRowHeightCommand.id;return this._getDrawingUndoForRowAndColSize(e,t,o,a)}return{redos:[],undos:[]}}}))}_getRangeMoveUndo(i,r){const n=_.getSheetCommandTarget(this._univerInstanceService);if(n==null)return{redos:[],undos:[]};const e=n.unitId,t=n.subUnitId,o=[],a=[],c=this._sheetDrawingService.getDrawingData(e,t),l=[],h=[];if(Object.keys(c).forEach(u=>{const s=c[u],{updateDrawings:m,deleteDrawings:g}=this._getUpdateOrDeleteDrawings(i,r,s);l.push(...m),h.push(...g)}),l.length===0&&h.length===0)return{redos:[],undos:[]};if(l.length>0){const u=this._sheetDrawingService.getBatchUpdateOp(l),{undo:s,redo:m,objects:g}=u;o.push({id:p.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:m,objects:g,type:p.DrawingApplyType.UPDATE}}),a.push({id:p.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:s,objects:g,type:p.DrawingApplyType.UPDATE}})}if(h.length>0){const u=this._sheetDrawingService.getBatchRemoveOp(h),s=u.undo,m=u.redo,g=u.objects;o.push({id:p.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:m,objects:g,type:p.DrawingApplyType.REMOVE}}),a.push({id:p.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:s,objects:g,type:p.DrawingApplyType.INSERT}})}return o.push({id:G.id,params:[e]}),a.push({id:G.id,params:[e]}),{redos:o,undos:a}}_getUpdateOrDeleteDrawings(i,r,n){const e=[],t=[],{sheetTransform:o,anchorType:a=p.SheetDrawingAnchorType.Position,transform:c,unitId:l,subUnitId:h,drawingId:u}=n,{from:s,to:m}=o,{row:g,column:f}=s,{row:S,column:v}=m;if(o==null||c==null)return{updateDrawings:e,deleteDrawings:t};const{startRow:C,endRow:M,startColumn:y,endColumn:R}=i;let I=null,D=null;if(r===0&&g>=C&&S<=M)if(f>=y&&v<=R)t.push({unitId:l,subUnitId:h,drawingId:u});else{const w=this._shrinkCol(o,c,y,R,a);I=w==null?void 0:w.newSheetTransform,D=w==null?void 0:w.newTransform}else if(r===1&&f>=y&&v<=R)if(g>=C&&S<=M)t.push({unitId:l,subUnitId:h,drawingId:u});else{const w=this._shrinkRow(o,c,C,M,a);I=w==null?void 0:w.newSheetTransform,D=w==null?void 0:w.newTransform}else if(r===2){const w=this._expandRow(o,c,C,M,a);I=w==null?void 0:w.newSheetTransform,D=w==null?void 0:w.newTransform}else if(r===3){const w=this._expandCol(o,c,y,R,a);I=w==null?void 0:w.newSheetTransform,D=w==null?void 0:w.newTransform}if(I!=null&&D!=null){const w=V(I,this._selectionRenderService,this._skeletonManagerService);e.push({...n,sheetTransform:I,transform:w})}return{updateDrawings:e,deleteDrawings:t}}_remainDrawingSize(i,r,n){const e=F({...i},this._selectionRenderService);e!=null&&r.push({...n,sheetTransform:e})}_getDrawingUndoForColVisible(i,r,n){const e=this._drawingManagerService.getDrawingData(i,r),t=[],o=[];if(Object.keys(e).forEach(u=>{const s=e[u],{sheetTransform:m,transform:g,anchorType:f=p.SheetDrawingAnchorType.Position}=s;if(f===p.SheetDrawingAnchorType.None)this._remainDrawingSize(g,t,s);else{const{from:S,to:v}=m,{row:C,column:M}=S,{row:y,column:R}=v;for(let I=0;I<n.length;I++){const D=n[I],{startRow:w,endRow:A,startColumn:E,endColumn:B}=D;if(R<E)continue;if(f===p.SheetDrawingAnchorType.Position){let T=null,L=null;if(M>=E&&M<=B){const $=this._skeletonManagerService.attachRangeWithCoord({startColumn:M,endColumn:B,startRow:S.row,endRow:v.row});if($==null)return;L={...g,left:$.startX}}if(L!=null&&(T=F(L,this._selectionRenderService),T!=null&&L!=null)){t.push({...s,sheetTransform:T,transform:L});break}this._remainDrawingSize(g,t,s);continue}if(M>=E&&R<=B)continue;let W=null,O=null;if(M>=E&&M<=B){const T=this._skeletonManagerService.attachRangeWithCoord({startColumn:M,endColumn:B,startRow:S.row,endRow:v.row});if(T==null)return;O={...g,left:(T==null?void 0:T.startX)||0,width:((g==null?void 0:g.width)||0)-T.endX+T.startX}}else if(R>=E&&R<=B){const T=this._skeletonManagerService.attachRangeWithCoord({startColumn:E,endColumn:R,startRow:S.row,endRow:v.row});if(T==null)return;O={...g,left:T.startX-((g==null?void 0:g.width)||0)}}else{const T=this._skeletonManagerService.attachRangeWithCoord({startColumn:E,endColumn:B,startRow:S.row,endRow:v.row});if(T==null)return;if(O={...g,width:((g==null?void 0:g.width)||0)-T.endX+T.startX},W=F(O,this._selectionRenderService),W!=null&&O!=null){o.push({...s,sheetTransform:W,transform:O});break}}if(O!=null&&(W=F(O,this._selectionRenderService)),O!=null&&W!=null){t.push({...s,sheetTransform:W,transform:O});break}else this._remainDrawingSize(g,t,s)}}}),t.length===0&&o.length===0)return{redos:[],undos:[]};const{redos:a,undos:c}=this._createUndoAndRedoMutation(i,r,t),l=[],h=[];if(o.length>0){const{redos:u,undos:s}=this._createUndoAndRedoMutation(i,r,o);l.push(...u),h.push(...s)}return{redos:a,undos:c,preRedos:l,preUndos:h}}_createUndoAndRedoMutation(i,r,n){const e=this._sheetDrawingService.getBatchUpdateOp(n),{undo:t,redo:o,objects:a}=e,c=[{id:p.SetDrawingApplyMutation.id,params:{unitId:i,subUnitId:r,op:o,objects:a,type:p.DrawingApplyType.UPDATE}},{id:G.id,params:[i]}],l=[{id:p.SetDrawingApplyMutation.id,params:{unitId:i,subUnitId:r,op:t,objects:a,type:p.DrawingApplyType.UPDATE}},{id:G.id,params:[i]}];return{redos:c,undos:l}}_getDrawingUndoForRowVisible(i,r,n){const e=this._drawingManagerService.getDrawingData(i,r),t=[],o=[];if(Object.keys(e).forEach(u=>{const s=e[u],{sheetTransform:m,transform:g,anchorType:f=p.SheetDrawingAnchorType.Position}=s;if(f===p.SheetDrawingAnchorType.None)this._remainDrawingSize(g,t,s);else{const{from:S,to:v}=m,{row:C,column:M}=S,{row:y,column:R}=v;for(let I=0;I<n.length;I++){const D=n[I],{startRow:w,endRow:A,startColumn:E,endColumn:B}=D;if(y<w)continue;if(f===p.SheetDrawingAnchorType.Position){let T=null,L=null;if(C>=w&&C<=A){const $=this._skeletonManagerService.attachRangeWithCoord({startColumn:S.column,endColumn:v.column,startRow:C,endRow:A});if($==null)return;L={...g,top:$.startY}}if(L!=null&&(T=F(L,this._selectionRenderService),T!=null&&L!=null)){t.push({...s,sheetTransform:T,transform:L});break}this._remainDrawingSize(g,t,s);continue}if(C>=w&&y<=A)continue;let W=null,O=null;if(C>=w&&C<=A){const T=this._skeletonManagerService.attachRangeWithCoord({startColumn:S.column,endColumn:v.column,startRow:C,endRow:A});if(T==null)return;O={...g,top:(T==null?void 0:T.startY)||0,height:((g==null?void 0:g.height)||0)-T.endY+T.startY}}else if(y>=w&&y<=A){const T=this._skeletonManagerService.attachRangeWithCoord({startColumn:S.column,endColumn:v.column,startRow:w,endRow:y});if(T==null)return;O={...g,top:T.startY-((g==null?void 0:g.height)||0)}}else{const T=this._skeletonManagerService.attachRangeWithCoord({startColumn:S.column,endColumn:v.column,startRow:w,endRow:A});if(T==null)return;if(O={...g,height:((g==null?void 0:g.height)||0)-T.endY+T.startY},W=F(O,this._selectionRenderService),W!=null&&O!=null){o.push({...s,sheetTransform:W,transform:O});break}}if(O!=null&&(W=F(O,this._selectionRenderService)),O!=null&&W!=null){t.push({...s,sheetTransform:W,transform:O});break}else this._remainDrawingSize(g,t,s)}}}),t.length===0&&o.length===0)return{redos:[],undos:[]};const{redos:a,undos:c}=this._createUndoAndRedoMutation(i,r,t),l=[],h=[];if(o.length>0){const{redos:u,undos:s}=this._createUndoAndRedoMutation(i,r,o);l.push(...u),h.push(...s)}return{redos:a,undos:c,preRedos:l,preUndos:h}}_getDrawingUndoForRowAndColSize(i,r,n,e){const t=this._drawingManagerService.getDrawingData(i,r),o=[];return Object.keys(t).forEach(a=>{const c=t[a],{sheetTransform:l,transform:h,anchorType:u=p.SheetDrawingAnchorType.Position}=c;if(u===p.SheetDrawingAnchorType.None)this._remainDrawingSize(h,o,c);else{const{from:s,to:m}=l,{row:g,column:f}=s,{row:S,column:v}=m;for(let C=0;C<n.length;C++){const M=n[C],{startRow:y,endRow:R,startColumn:I,endColumn:D}=M;if(S<y||v<I)continue;if(u===p.SheetDrawingAnchorType.Position&&(g<=y&&S>=R||f<=I&&v>=D)){this._remainDrawingSize(h,o,c);continue}const w=V({...l},this._selectionRenderService,this._skeletonManagerService);if(w!=null){o.push({...c,transform:w});break}}}}),o.length===0?{redos:[],undos:[]}:this._createUndoAndRedoMutation(i,r,o)}_getUnitIdAndSubUnitId(i,r){let n,e;if(r==="insert")n=i.unitId,e=i.subUnitId;else{const t=_.getSheetCommandTarget(this._univerInstanceService);if(t==null)return;n=t.unitId,e=t.subUnitId}return{unitId:n,subUnitId:e}}_moveRangeInterceptor(i){var y,R;const{toRange:r,fromRange:n}=i,e=_.getSheetCommandTarget(this._univerInstanceService);if(!e)return{redos:[],undos:[]};const{unitId:t,subUnitId:o}=e,a=(R=(y=this._renderManagerService.getRenderById(t))==null?void 0:y.with(U.SheetSkeletonManagerService))==null?void 0:R.getCurrentSkeleton();if(!a)return{redos:[],undos:[]};const c=U.attachRangeWithCoord(a,n);if(!c)return{redos:[],undos:[]};const{startX:l,endX:h,startY:u,endY:s}=c,m=this._sheetDrawingService.getDrawingData(t,o),g=[];Object.keys(m).forEach(I=>{const D=m[I];if(D.anchorType!==p.SheetDrawingAnchorType.Both)return;const{transform:w}=D;if(!w)return;const{left:A=0,top:E=0,width:B=0,height:W=0}=w,{drawingStartX:O,drawingEndX:T,drawingStartY:L,drawingEndY:$}={drawingStartX:A,drawingEndX:A+B,drawingStartY:E,drawingEndY:E+W};l<=O&&T<=h&&u<=L&&$<=s&&g.push(D)});const f=[],S=[],v=r.startRow-n.startRow,C=r.startColumn-n.startColumn,M=g.map(I=>{const D=I.sheetTransform,w={to:{...D.to,row:D.to.row+v,column:D.to.column+C},from:{...D.from,row:D.from.row+v,column:D.from.column+C}},A=V(w,this._selectionRenderService,this._skeletonManagerService);return{unitId:t,subUnitId:o,drawingId:I.drawingId,transform:A,sheetTransform:w}});if(M.length){const I=this._sheetDrawingService.getBatchUpdateOp(M),{undo:D,redo:w,objects:A}=I;f.push({id:p.SetDrawingApplyMutation.id,params:{unitId:t,subUnitId:o,op:w,objects:A,type:p.DrawingApplyType.UPDATE}}),S.push({id:p.SetDrawingApplyMutation.id,params:{unitId:t,subUnitId:o,op:D,objects:A,type:p.DrawingApplyType.UPDATE}})}return{redos:f,undos:S}}_moveRowInterceptor(i,r){const n=this._getUnitIdAndSubUnitId(i,r);if(n==null)return{redos:[],undos:[]};const{unitId:e,subUnitId:t}=n,{range:o}=i,a=o.startRow,c=o.endRow,l=[],h=[],u=this._sheetDrawingService.getDrawingData(e,t),s=[],m=[];if(Object.keys(u).forEach(g=>{const f=u[g],{sheetTransform:S,transform:v,anchorType:C=p.SheetDrawingAnchorType.Position}=f;if(S==null||v==null)return;let M,y;if(r==="insert"){const I=this._expandRow(S,v,a,c,C);M=I==null?void 0:I.newSheetTransform,y=I==null?void 0:I.newTransform}else{const{from:I,to:D}=S,{row:w}=I,{row:A}=D;if(C===p.SheetDrawingAnchorType.Both&&w>=a&&A<=c)m.push({unitId:e,subUnitId:t,drawingId:g});else{const E=this._shrinkRow(S,v,a,c,C);M=E==null?void 0:E.newSheetTransform,y=E==null?void 0:E.newTransform}}if(!M||!y)return;const R={unitId:e,subUnitId:t,drawingId:g,transform:y,sheetTransform:M};s.push(R)}),s.length===0&&m.length===0)return{redos:[],undos:[]};if(s.length>0){const g=this._sheetDrawingService.getBatchUpdateOp(s),{undo:f,redo:S,objects:v}=g;l.push({id:p.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:S,objects:v,type:p.DrawingApplyType.UPDATE}}),h.push({id:p.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:f,objects:v,type:p.DrawingApplyType.UPDATE}})}if(m.length>0){const g=this._sheetDrawingService.getBatchRemoveOp(m),f=g.undo,S=g.redo,v=g.objects;l.push({id:p.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:S,objects:v,type:p.DrawingApplyType.REMOVE}}),h.push({id:p.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:f,objects:v,type:p.DrawingApplyType.INSERT}})}return l.push({id:G.id,params:[e]}),h.push({id:G.id,params:[e]}),{redos:l,undos:h}}_moveColInterceptor(i,r){const n=this._getUnitIdAndSubUnitId(i,r);if(n==null)return{redos:[],undos:[]};const{unitId:e,subUnitId:t}=n,{range:o}=i,a=o.startColumn,c=o.endColumn,l=[],h=[],u=this._sheetDrawingService.getDrawingData(e,t),s=[],m=[];if(Object.keys(u).forEach(g=>{const f=u[g],{sheetTransform:S,transform:v,anchorType:C=p.SheetDrawingAnchorType.Position}=f;if(S==null||v==null)return;let M,y;if(r==="insert"){const I=this._expandCol(S,v,a,c,C);M=I==null?void 0:I.newSheetTransform,y=I==null?void 0:I.newTransform}else{const{from:I,to:D}=S,{column:w}=I,{column:A}=D;if(C===p.SheetDrawingAnchorType.Both&&w>=a&&A<=c)m.push({unitId:e,subUnitId:t,drawingId:g});else{const E=this._shrinkCol(S,v,a,c,C);M=E==null?void 0:E.newSheetTransform,y=E==null?void 0:E.newTransform}}if(!M||!y)return;const R={unitId:e,subUnitId:t,drawingId:g,transform:y,sheetTransform:M};s.push(R)}),s.length===0&&m.length===0)return{redos:[],undos:[]};if(s.length>0){const g=this._sheetDrawingService.getBatchUpdateOp(s),{undo:f,redo:S,objects:v}=g;l.push({id:p.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:S,objects:v,type:p.DrawingApplyType.UPDATE}}),h.push({id:p.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:f,objects:v,type:p.DrawingApplyType.UPDATE}})}if(m.length>0){const g=this._sheetDrawingService.getBatchRemoveOp(m),f=g.undo,S=g.redo,v=g.objects;l.push({id:p.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:S,objects:v,type:p.DrawingApplyType.REMOVE}}),h.push({id:p.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:f,objects:v,type:p.DrawingApplyType.INSERT}})}return l.push({id:G.id,params:[e]}),h.push({id:G.id,params:[e]}),{redos:l,undos:h}}_expandCol(i,r,n,e,t=p.SheetDrawingAnchorType.Position){const o=e-n+1,{from:a,to:c}=i,{column:l}=a,{column:h}=c;if(t===p.SheetDrawingAnchorType.None)return{newSheetTransform:F({...r},this._selectionRenderService),newTransform:r};let u=null,s=null;if(l>=n){const m=this._skeletonManagerService.attachRangeWithCoord({startColumn:n,endColumn:e,startRow:a.row,endRow:c.row});if(m==null)return;s={...r,left:(r.left||0)+m.endX-m.startX},u=F(s,this._selectionRenderService)}else if(h>=e)if(t===p.SheetDrawingAnchorType.Both)u={from:{...a},to:{...c,column:h+o}},s=V(u,this._selectionRenderService,this._skeletonManagerService);else return{newSheetTransform:F({...r},this._selectionRenderService),newTransform:r};return u!=null&&s!=null?{newSheetTransform:u,newTransform:s}:null}_shrinkCol(i,r,n,e,t=p.SheetDrawingAnchorType.Position){const o=e-n+1,{from:a,to:c}=i,{column:l}=a,{column:h}=c;if(t===p.SheetDrawingAnchorType.None)return{newSheetTransform:F({...r},this._selectionRenderService),newTransform:r};let u=null,s=null;if(l>e)u={from:{...a,column:l-o},to:{...c,column:h-o}},s=V(u,this._selectionRenderService,this._skeletonManagerService);else{if(l>=n&&h<=e)return null;if(l<n&&h>e)if(t===p.SheetDrawingAnchorType.Both)u={from:{...a},to:{...c,column:h-o}},s=V(u,this._selectionRenderService,this._skeletonManagerService);else return{newSheetTransform:F({...r},this._selectionRenderService),newTransform:r};else if(l>=n&&l<=e){if(l===n)s={...r,left:(r.left||0)-i.from.columnOffset};else{const m=this._skeletonManagerService.attachRangeWithCoord({startColumn:n,endColumn:l-1,startRow:a.row,endRow:c.row});if(m==null)return;s={...r,left:(r.left||0)-m.endX+m.startX-i.from.columnOffset}}u=F(s,this._selectionRenderService)}else if(h>=n&&h<=e&&t===p.SheetDrawingAnchorType.Both){const m=this._skeletonManagerService.attachRangeWithCoord({startColumn:n-1,endColumn:n-1,startRow:a.row,endRow:c.row});if(m==null)return;u={from:{...a},to:{...c,column:n-1,columnOffset:m.endX-m.startX}},s=V(u,this._selectionRenderService,this._skeletonManagerService)}}return u!=null&&s!=null?{newSheetTransform:u,newTransform:s}:null}_expandRow(i,r,n,e,t=p.SheetDrawingAnchorType.Position){const o=e-n+1,{from:a,to:c}=i,{row:l}=a,{row:h}=c;if(t===p.SheetDrawingAnchorType.None)return{newSheetTransform:F({...r},this._selectionRenderService),newTransform:r};let u=null,s=null;if(l>=n){const m=this._skeletonManagerService.attachRangeWithCoord({startRow:n,endRow:e,startColumn:a.column,endColumn:c.column});if(m==null)return;s={...r,top:(r.top||0)+m.endY-m.startY},u=F(s,this._selectionRenderService)}else if(h>=e)if(t===p.SheetDrawingAnchorType.Both)u={from:{...a},to:{...c,row:h+o}},s=V(u,this._selectionRenderService,this._skeletonManagerService);else return{newSheetTransform:F({...r},this._selectionRenderService),newTransform:r};return u!=null&&s!=null?{newSheetTransform:u,newTransform:s}:null}_shrinkRow(i,r,n,e,t=p.SheetDrawingAnchorType.Position){const o=e-n+1,{from:a,to:c}=i,{row:l}=a,{row:h}=c;if(t===p.SheetDrawingAnchorType.None)return{newSheetTransform:F({...r},this._selectionRenderService),newTransform:r};let u=null,s=null;if(l>e)u={from:{...a,row:l-o},to:{...c,row:h-o}},s=V(u,this._selectionRenderService,this._skeletonManagerService);else{if(l>=n&&h<=e)return null;if(l<n&&h>e)if(t===p.SheetDrawingAnchorType.Both)u={from:{...a},to:{...c,row:h-o}},s=V(u,this._selectionRenderService,this._skeletonManagerService);else return{newSheetTransform:F({...r},this._selectionRenderService),newTransform:r};else if(l>=n&&l<=e){if(l===n)s={...r,top:(r.top||0)-i.from.rowOffset};else{const m=this._skeletonManagerService.attachRangeWithCoord({startRow:n,endRow:l-1,startColumn:a.column,endColumn:c.column});if(m==null)return;s={...r,top:(r.top||0)-m.endY+m.startY-i.from.rowOffset}}u=F(s,this._selectionRenderService)}else if(h>=n&&h<=e&&t===p.SheetDrawingAnchorType.Both){const m=this._skeletonManagerService.attachRangeWithCoord({startColumn:a.column,endColumn:a.column,startRow:n-1,endRow:n-1});if(m==null)return;u={from:{...a},to:{...c,row:n-1,rowOffset:m.endY-m.startY}},s=V(u,this._selectionRenderService,this._skeletonManagerService)}}return u!=null&&s!=null?{newSheetTransform:u,newTransform:s}:null}_commandListener(){this.disposeWithMe(this._commandService.onCommandExecuted(i=>{i.id===_.SetWorksheetActiveOperation.id&&setTimeout(()=>{const r=i.params,{unitId:n,subUnitId:e}=r,t=this._drawingManagerService.drawingManagerData,o=[],a=[];Object.keys(t).forEach(c=>{const l=t[c];l!=null&&Object.keys(l).forEach(h=>{const u=l[h].data;u!=null&&Object.keys(u).forEach(s=>{if(c===n&&h===e){const m=u[s];m.transform=V(m.sheetTransform,this._selectionRenderService,this._skeletonManagerService),o.push(u[s])}else a.push(u[s])})})}),this._drawingManagerService.removeNotification(a),this._drawingManagerService.addNotification(o)},0)}))}_sheetRefreshListener(){this.disposeWithMe(this._commandService.onCommandExecuted(i=>{Xt.includes(i.id)&&requestIdleCallback(()=>{const r=i.params,{unitId:n,subUnitId:e,ranges:t}=r;this._refreshDrawingTransform(n,e,t)})}))}_refreshDrawingTransform(i,r,n){const e=this._drawingManagerService.getDrawingData(i,r),t=[];Object.keys(e).forEach(o=>{const a=e[o],{sheetTransform:c,transform:l,anchorType:h=p.SheetDrawingAnchorType.Position}=a;if(h===p.SheetDrawingAnchorType.None)return!0;const{from:u,to:s}=c,{row:m,column:g}=u,{row:f,column:S}=s;for(let v=0;v<n.length;v++){const C=n[v],{startRow:M,endRow:y,startColumn:R,endColumn:I}=C;if(d.Rectangle.intersects({startRow:M,endRow:y,startColumn:R,endColumn:I},{startRow:m,endRow:f,startColumn:g,endColumn:S})||m>y||g>I){const D=h===p.SheetDrawingAnchorType.Position,w=V(c,this._selectionRenderService,this._skeletonManagerService);t.push({...a,transform:{...w,width:D?l==null?void 0:l.width:w==null?void 0:w.width,height:D?l==null?void 0:l.height:w==null?void 0:w.height}});break}}}),t.length!==0&&(this._drawingManagerService.refreshTransform(t),this._commandService.syncExecuteCommand(G.id,[i]))}};Le=xt([Q(1,N.IRenderManagerService),Q(2,d.ICommandService),Q(3,U.ISheetSelectionRenderService),Q(4,d.Inject(U.SheetSkeletonManagerService)),Q(5,d.Inject(_.SheetInterceptorService)),Q(6,p.ISheetDrawingService),Q(7,P.IDrawingManagerService),Q(8,d.IUniverInstanceService)],Le);var K=function(){return K=Object.assign||function(i){for(var r,n=1,e=arguments.length;n<e;n++){r=arguments[n];for(var t in r)Object.prototype.hasOwnProperty.call(r,t)&&(i[t]=r[t])}return i},K.apply(this,arguments)},zt=function(i,r){var n={};for(var e in i)Object.prototype.hasOwnProperty.call(i,e)&&r.indexOf(e)<0&&(n[e]=i[e]);if(i!=null&&typeof Object.getOwnPropertySymbols=="function")for(var t=0,e=Object.getOwnPropertySymbols(i);t<e.length;t++)r.indexOf(e[t])<0&&Object.prototype.propertyIsEnumerable.call(i,e[t])&&(n[e[t]]=i[e[t]]);return n},qe=X.forwardRef(function(i,r){var n=i.icon,e=i.id,t=i.className,o=i.extend,a=zt(i,["icon","id","className","extend"]),c="univerjs-icon univerjs-icon-".concat(e," ").concat(t||"").trim(),l=X.useRef("_".concat(Zt()));return Qe(n,"".concat(e),{defIds:n.defIds,idSuffix:l.current},K({ref:r,className:c},a),o)});function Qe(i,r,n,e,t){return X.createElement(i.tag,K(K({key:r},Kt(i,n,t)),e),(Jt(i,n).children||[]).map(function(o,a){return Qe(o,"".concat(r,"-").concat(i.tag,"-").concat(a),n,void 0,t)}))}function Kt(i,r,n){var e=K({},i.attrs);n!=null&&n.colorChannel1&&e.fill==="colorChannel1"&&(e.fill=n.colorChannel1);var t=r.defIds;return!t||t.length===0||(i.tag==="use"&&e["xlink:href"]&&(e["xlink:href"]=e["xlink:href"]+r.idSuffix),Object.entries(e).forEach(function(o){var a=o[0],c=o[1];typeof c=="string"&&(e[a]=c.replace(/url\(#(.*)\)/,"url(#$1".concat(r.idSuffix,")")))})),e}function Jt(i,r){var n,e=r.defIds;return!e||e.length===0?i:i.tag==="defs"&&(!((n=i.children)===null||n===void 0)&&n.length)?K(K({},i),{children:i.children.map(function(t){return typeof t.attrs.id=="string"&&e&&e.indexOf(t.attrs.id)>-1?K(K({},t),{attrs:K(K({},t.attrs),{id:t.attrs.id+r.idSuffix})}):t})}):i}function Zt(){return Math.random().toString(36).substring(2,8)}qe.displayName="UniverIcon";var qt={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M2.2498 3.65005C2.2498 2.87685 2.87661 2.25005 3.64981 2.25005H7.9998C8.33118 2.25005 8.5998 1.98142 8.5998 1.65005C8.5998 1.31868 8.33118 1.05005 7.9998 1.05005H3.64981C2.21387 1.05005 1.0498 2.21411 1.0498 3.65005V12.35C1.0498 13.786 2.21386 14.95 3.6498 14.95H12.3498C13.7857 14.95 14.9498 13.786 14.9498 12.3501V8.00005C14.9498 7.66868 14.6812 7.40005 14.3498 7.40005C14.0184 7.40005 13.7498 7.66868 13.7498 8.00005V9.23974L12.2385 8.1063C11.7252 7.72129 11.0068 7.7723 10.5531 8.22605L9.00869 9.77041L6.73916 7.8251C6.24387 7.40055 5.5095 7.41278 5.02864 7.85359L2.2498 10.4009V3.65005ZM2.2498 12.0287V12.35C2.2498 13.1232 2.87661 13.75 3.6498 13.75H12.3498C13.123 13.75 13.7498 13.1232 13.7498 12.3501V10.7397L11.5186 9.06631C11.4829 9.03956 11.433 9.04314 11.4016 9.07458L9.92249 10.5537L11.1015 11.5642C11.3531 11.7799 11.3822 12.1587 11.1666 12.4103C10.9509 12.6619 10.5721 12.691 10.3205 12.4753L5.9582 8.7362C5.92384 8.70674 5.87288 8.70758 5.83952 8.73816L2.2498 12.0287Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M11.8097 1.14783C12.1411 1.14783 12.4097 1.41646 12.4097 1.74783V3.297H14.1541C14.4855 3.297 14.7541 3.56563 14.7541 3.897C14.7541 4.22837 14.4855 4.497 14.1541 4.497H12.4097V6.24167C12.4097 6.57304 12.1411 6.84167 11.8097 6.84167C11.4783 6.84167 11.2097 6.57304 11.2097 6.24167V4.497H9.6603C9.32893 4.497 9.0603 4.22837 9.0603 3.897C9.0603 3.56563 9.32893 3.297 9.6603 3.297H11.2097V1.74783C11.2097 1.41646 11.4783 1.14783 11.8097 1.14783Z"}}]},et=X.forwardRef(function(i,r){return X.createElement(qe,Object.assign({},i,{id:"add-image-single",ref:r,icon:qt}))});et.displayName="AddImageSingle";const Be={id:"sheet.command.delete-drawing",type:d.CommandType.COMMAND,handler:i=>{const r=i.get(d.ICommandService),e=i.get(p.ISheetDrawingService).getFocusDrawings();if(e.length===0)return!1;const t=e[0].unitId,o=e.map(a=>{const{unitId:c,subUnitId:l,drawingId:h,drawingType:u}=a;return{unitId:c,subUnitId:l,drawingId:h,drawingType:u}});return r.executeCommand(ae.id,{unitId:t,drawings:o})}},Me={id:"sheet.command.insert-float-image",type:d.CommandType.COMMAND,handler:i=>{var n,e;return(e=(n=i.get(N.IRenderManagerService).getCurrentTypeOfRenderer(d.UniverInstanceType.UNIVER_SHEET))==null?void 0:n.with(le).insertFloatImage())!=null?e:!1}},Ge={id:"sheet.command.insert-cell-image",type:d.CommandType.COMMAND,handler:i=>{var n,e;return(e=(n=i.get(N.IRenderManagerService).getCurrentTypeOfRenderer(d.UniverInstanceType.UNIVER_SHEET))==null?void 0:n.with(le).insertCellImage())!=null?e:!1}},oe={id:"sheet.command.move-drawing",type:d.CommandType.COMMAND,handler:(i,r)=>{const n=i.get(d.ICommandService),e=i.get(p.ISheetDrawingService),t=i.get(U.ISheetSelectionRenderService),{direction:o}=r,a=e.getFocusDrawings();if(a.length===0)return!1;const c=a[0].unitId,l=a.map(u=>{const{transform:s}=u;if(s==null)return null;const m={...s},{left:g=0,top:f=0}=s;return o===d.Direction.UP?m.top=f-1:o===d.Direction.DOWN?m.top=f+1:o===d.Direction.LEFT?m.left=g-1:o===d.Direction.RIGHT&&(m.left=g+1),{...u,transform:m,sheetTransform:F(m,t)}}).filter(u=>u!=null);return n.syncExecuteCommand(de.id,{unitId:c,drawings:l})?(n.syncExecuteCommand(G.id,[c]),!0):!1}},tt="addition-and-subtraction-single",ke="sheet.menu.image";function Qt(i){return{id:ke,type:k.MenuItemType.SUBITEMS,icon:tt,tooltip:"sheetImage.title",hidden$:k.getMenuHiddenObservable(i,d.UniverInstanceType.UNIVER_SHEET),disabled$:U.getCurrentRangeDisable$(i,{workbookTypes:[_.WorkbookEditablePermission],worksheetTypes:[_.WorksheetEditPermission],rangeTypes:[_.RangeProtectionPermissionEditPoint]})}}function en(i){return{id:Me.id,title:"sheetImage.upload.float",type:k.MenuItemType.BUTTON,hidden$:k.getMenuHiddenObservable(i,d.UniverInstanceType.UNIVER_SHEET)}}function tn(i){return{id:Ge.id,title:"sheetImage.upload.cell",type:k.MenuItemType.BUTTON}}const ee={imageCommonPanel:"univer-image-common-panel",imageCommonPanelGrid:"univer-image-common-panel-grid",imageCommonPanelBorder:"univer-image-common-panel-border",imageCommonPanelTitle:"univer-image-common-panel-title",imageCommonPanelSubtitle:"univer-image-common-panel-subtitle",imageCommonPanelRow:"univer-image-common-panel-row",imageCommonPanelRowVertical:"univer-image-common-panel-row-vertical",imageCommonPanelColumn:"univer-image-common-panel-column",imageCommonPanelColumnCenter:"univer-image-common-panel-column-center",imageCommonPanelInline:"univer-image-common-panel-inline",imageCommonPanelSpan2:"univer-image-common-panel-span2",imageCommonPanelSpan3:"univer-image-common-panel-span3",imageCommonPanelInput:"univer-image-common-panel-input",sheetImageMenu:"univer-sheet-image-menu",sheetImageMenuInput:"univer-sheet-image-menu-input"};function nt(i){var r,n,e="";if(typeof i=="string"||typeof i=="number")e+=i;else if(typeof i=="object")if(Array.isArray(i)){var t=i.length;for(r=0;r<t;r++)i[r]&&(n=nt(i[r]))&&(e&&(e+=" "),e+=n)}else for(n in i)i[n]&&(e&&(e+=" "),e+=n);return e}function De(){for(var i,r,n=0,e="",t=arguments.length;n<t;n++)(i=arguments[n])&&(r=nt(i))&&(e&&(e+=" "),e+=r);return e}const nn=i=>{var y;const r=d.useDependency(d.ICommandService),n=d.useDependency(d.LocaleService),e=d.useDependency(P.IDrawingManagerService),t=d.useDependency(N.IRenderManagerService),{drawings:o}=i,a=o[0];if(a==null)return;const{unitId:c}=a,l=t.getRenderById(c),h=l==null?void 0:l.scene;if(h==null)return;const u=h.getTransformerByCreate(),[s,m]=X.useState(!0),g=(y=a.anchorType)!=null?y:p.SheetDrawingAnchorType.Position,[f,S]=X.useState(g);function v(R,I){const D=[];return R.forEach(w=>{const{oKey:A}=w,E=I.getDrawingOKey(A);if(E==null)return D.push(null),!0;const{unitId:B,subUnitId:W,drawingId:O,drawingType:T,anchorType:L,sheetTransform:$}=E;D.push({unitId:B,subUnitId:W,drawingId:O,anchorType:L,sheetTransform:$,drawingType:T})}),D}X.useEffect(()=>{const R=u.clearControl$.subscribe(D=>{D===!0&&m(!1)}),I=u.changeStart$.subscribe(D=>{var E;const{objects:w}=D,A=v(w,e);if(A.length===0)m(!1);else if(A.length>=1){m(!0);const B=((E=A[0])==null?void 0:E.anchorType)||p.SheetDrawingAnchorType.Position;S(B)}});return()=>{I.unsubscribe(),R.unsubscribe()}},[]);function C(R){S(R);const I=e.getFocusDrawings();if(I.length===0)return;const D=I.map(w=>({unitId:w.unitId,subUnitId:w.subUnitId,drawingId:w.drawingId,anchorType:R}));r.executeCommand(de.id,{unitId:I[0].unitId,drawings:D})}const M=R=>R?"block":"none";return H.jsxs("div",{className:De(ee.imageCommonPanelGrid,ee.imageCommonPanelBorder),style:{display:M(s)},children:[H.jsx("div",{className:ee.imageCommonPanelRow,children:H.jsx("div",{className:De(ee.imageCommonPanelColumn,ee.imageCommonPanelTitle),children:H.jsx("div",{children:n.t("drawing-anchor.title")})})}),H.jsx("div",{className:De(ee.imageCommonPanelRow),children:H.jsx("div",{className:De(ee.imageCommonPanelColumn),children:H.jsxs(J.RadioGroup,{value:f,onChange:C,direction:"vertical",children:[H.jsx(J.Radio,{value:p.SheetDrawingAnchorType.Both,children:n.t("drawing-anchor.both")}),H.jsx(J.Radio,{value:p.SheetDrawingAnchorType.Position,children:n.t("drawing-anchor.position")}),H.jsx(J.Radio,{value:p.SheetDrawingAnchorType.None,children:n.t("drawing-anchor.none")})]})})})]})},rn=()=>{const i=d.useDependency(P.IDrawingManagerService),r=i.getFocusDrawings(),[n,e]=X.useState(r);return X.useEffect(()=>{const t=i.focus$.subscribe(o=>{e(o)});return()=>{t.unsubscribe()}},[]),!!(n!=null&&n.length)&&H.jsxs("div",{className:ee.imageCommonPanel,children:[H.jsx(q.DrawingCommonPanel,{drawings:n}),H.jsx(nn,{drawings:n})]})},on={[k.RibbonStartGroup.FORMULAS_INSERT]:{[ke]:{order:3,menuItemFactory:Qt,[Me.id]:{order:0,menuItemFactory:en},[Ge.id]:{order:1,menuItemFactory:tn}}}};function ge(i){return!i.getContextValue(d.FOCUSING_FX_BAR_EDITOR)&&!i.getContextValue(d.EDITOR_ACTIVATED)&&!i.getContextValue(d.FOCUSING_PANEL_EDITOR)&&i.getContextValue(d.FOCUSING_COMMON_DRAWINGS)}const an={id:oe.id,description:"shortcut.sheet.drawing-move-down",group:"4_sheet-drawing-view",binding:k.KeyCode.ARROW_DOWN,priority:100,preconditions:ge,staticParameters:{direction:d.Direction.DOWN}},sn={id:oe.id,description:"shortcut.sheet.drawing-move-up",group:"4_sheet-drawing-view",binding:k.KeyCode.ARROW_UP,priority:100,preconditions:ge,staticParameters:{direction:d.Direction.UP}},cn={id:oe.id,description:"shortcut.sheet.drawing-move-left",group:"4_sheet-drawing-view",binding:k.KeyCode.ARROW_LEFT,priority:100,preconditions:ge,staticParameters:{direction:d.Direction.LEFT}},dn={id:oe.id,description:"shortcut.sheet.drawing-move-right",group:"4_sheet-drawing-view",binding:k.KeyCode.ARROW_RIGHT,priority:100,preconditions:ge,staticParameters:{direction:d.Direction.RIGHT}},ln={id:Be.id,description:"shortcut.sheet.drawing-delete",group:"4_sheet-drawing-view",preconditions:ge,binding:k.KeyCode.DELETE,mac:k.KeyCode.BACKSPACE};var un=Object.defineProperty,gn=Object.getOwnPropertyDescriptor,mn=(i,r,n,e)=>{for(var t=e>1?void 0:e?gn(r,n):r,o=i.length-1,a;o>=0;o--)(a=i[o])&&(t=(e?a(r,n,t):a(t))||t);return e&&t&&un(r,n,t),t},Te=(i,r)=>(n,e)=>r(n,e,i);let Re=class extends d.Disposable{constructor(i,r,n,e){super(),this._componentManager=i,this._menuManagerService=r,this._commandService=n,this._shortcutService=e,this._init()}_initCustomComponents(){const i=this._componentManager;this.disposeWithMe(i.register(tt,et)),this.disposeWithMe(i.register(Xe,rn))}_initMenus(){this._menuManagerService.mergeMenu(on)}_initCommands(){[Me,Ge,ce,ae,de,be,G,Ee,Ae,Ne,oe,Be,Ue].forEach(i=>this.disposeWithMe(this._commandService.registerCommand(i)))}_initShortcuts(){[an,sn,cn,dn,ln].forEach(i=>{this.disposeWithMe(this._shortcutService.registerShortcut(i))})}_init(){this._initCommands(),this._initCustomComponents(),this._initMenus(),this._initShortcuts()}};Re=mn([Te(0,d.Inject(k.ComponentManager)),Te(1,k.IMenuManagerService),Te(2,d.ICommandService),Te(3,k.IShortcutService)],Re);var hn=Object.defineProperty,pn=Object.getOwnPropertyDescriptor,fn=(i,r,n,e)=>{for(var t=e>1?void 0:e?pn(r,n):r,o=i.length-1,a;o>=0;o--)(a=i[o])&&(t=(e?a(r,n,t):a(t))||t);return e&&t&&hn(r,n,t),t},ie=(i,r)=>(n,e)=>r(n,e,i);function Sn(i,r,n,e){const{scaleX:t,scaleY:o}=r.getAncestorScale(),a=r.getViewport(N.SHEET_VIEWPORT_KEY.VIEW_MAIN),c={left:!0,top:!0};if(!a)return{...i,absolute:c};const{left:l,right:h,top:u,bottom:s}=i,m=e.getFreeze(),{startColumn:g,startRow:f,xSplit:S,ySplit:v}=m,C=n.getNoMergeCellPositionByIndexWithNoHeader(f-v,g-S),M=n.getNoMergeCellPositionByIndexWithNoHeader(f,g),{rowHeaderWidth:y,columnHeaderHeight:R}=n,I=M.startX-C.startX,D=M.startY-C.startY,{top:w,left:A,viewportScrollX:E,viewportScrollY:B}=a;let W,O;l<A?(c.left=!0,W=(I+y+(l-A))*t,O=Math.max(Math.min((I+y+(h-A))*t,(I+y)*t),(h-E)*t)):(c.left=!1,W=Math.max((l-E)*t,(I+y)*t),O=Math.max((h-E)*t,(I+y)*t));let T,L;return u<w?(c.top=!0,T=(D+R+(u-w))*o,L=Math.max(Math.min((D+R+(h-w))*o,(D+R)*o),(s-B)*o)):(c.top=!1,T=Math.max((u-B)*o,(D+R)*o),L=Math.max((s-B)*o,(D+R)*o)),{left:W,right:O,top:T,bottom:L,absolute:c}}const Fe=(i,r,n,e)=>{const{scene:t}=r,{left:o,top:a,width:c,height:l,angle:h}=i,u={left:o,right:o+c,top:a,bottom:a+l},s=Sn(u,t,n,e),{scaleX:m,scaleY:g}=t.getAncestorScale();return{startX:s.left,endX:s.right,startY:s.top,endY:s.bottom,rotate:h,width:c*m,height:l*g,absolute:s.absolute}};b.SheetCanvasFloatDomManagerService=class extends d.Disposable{constructor(n,e,t,o,a,c,l){super();Y(this,"_domLayerMap",new Map);Y(this,"_domLayerInfoMap",new Map);Y(this,"_transformChange$",new j.Subject);Y(this,"transformChange$",this._transformChange$.asObservable());Y(this,"_add$",new j.Subject);Y(this,"add$",this._add$.asObservable());Y(this,"_remove$",new j.Subject);Y(this,"remove$",this._remove$.asObservable());Y(this,"_hooks",[]);this._renderManagerService=n,this._univerInstanceService=e,this._commandService=t,this._drawingManagerService=o,this._canvasFloatDomService=a,this._sheetDrawingService=c,this._lifecycleService=l,this._drawingAddListener(),this._featureUpdateListener(),this._deleteListener(),this._bindScrollEvent()}_bindScrollEvent(){this._lifecycleService.lifecycle$.pipe(j.filter(n=>n===d.LifecycleStages.Rendered),j.take(1)).subscribe(()=>{this._scrollUpdateListener()})}_ensureMap(n,e){let t=this._domLayerMap.get(n);t||(t=new Map,this._domLayerMap.set(n,t));let o=t.get(e);return o||(o=new Map,t.set(e,o)),o}getFloatDomInfo(n){return this._domLayerInfoMap.get(n)}_getSceneAndTransformerByDrawingSearch(n){if(n==null)return;const e=this._renderManagerService.getRenderById(n),t=e==null?void 0:e.scene;if(e==null||t==null)return null;const o=t.getTransformerByCreate(),a=e.engine.getCanvasElement();return{scene:t,transformer:o,renderObject:e,canvas:a}}_getFloatDomProps(n){let e;return this._hooks.forEach(t=>{e=t.onGetFloatDomProps(n)}),e}_drawingAddListener(){this.disposeWithMe(this._drawingManagerService.add$.subscribe(n=>{n.forEach(e=>{var at,st,ct;const{unitId:t,subUnitId:o,drawingId:a}=e,c=_.getSheetCommandTarget(this._univerInstanceService,{unitId:t,subUnitId:o}),l=this._drawingManagerService.getDrawingByParam(e),h=this._univerInstanceService.getUnit(t,d.UniverInstanceType.UNIVER_SHEET);if(!h)return;const u=h.getActiveSheet().getSheetId();if(!l||!c)return;const s=(at=this._renderManagerService.getRenderById(t))==null?void 0:at.with(U.SheetSkeletonManagerService).getWorksheetSkeleton(o);if(!s)return;const{transform:m,drawingType:g,data:f}=l;if(g!==d.DrawingTypeEnum.DRAWING_DOM&&g!==d.DrawingTypeEnum.DRAWING_CHART)return;const S=this._getSceneAndTransformerByDrawingSearch(t);if(S==null)return;const{scene:v,canvas:C}=S;if(m==null)return!0;if(u!==o)return;const{left:M,top:y,width:R,height:I,angle:D,flipX:w,flipY:A,skewX:E,skewY:B}=m,W=P.getDrawingShapeKeyByDrawingSearch({unitId:t,subUnitId:o,drawingId:a}),O=v.getObject(W);if(O!=null){O.transformByState({left:M,top:y,width:R,height:I,angle:D,flipX:w,flipY:A,skewX:E,skewY:B});return}const T={left:M,top:y,width:R,height:I,zIndex:this._drawingManagerService.getDrawingOrder(t,o).length-1},L=g===d.DrawingTypeEnum.DRAWING_CHART;if(L){const x=f?f.backgroundColor:"white";T.fill=x,T.rotateEnabled=!1,f&&f.border&&(T.stroke=f.border),T.paintFirst="stroke",T.strokeWidth=1,T.borderEnabled=!1,T.radius=8}const $=new N.Rect(W,T);L&&$.setObjectType(N.ObjectType.CHART),v.addObject($,N.DRAWING_OBJECT_LAYER_INDEX),l.allowTransform!==!1&&v.attachTransformerTo($);const Z=this._ensureMap(t,o),He=new d.DisposableCollection,Cn=Fe($,S.renderObject,s.skeleton,c.worksheet),Ve=new j.BehaviorSubject(Cn),yn={dispose:He,rect:$,position$:Ve,unitId:t,subUnitId:o};this._canvasFloatDomService.addFloatDom({position$:Ve,id:a,componentKey:l.componentKey,onPointerDown:x=>{C.dispatchEvent(new PointerEvent(x.type,x))},onPointerMove:x=>{C.dispatchEvent(new PointerEvent(x.type,x))},onPointerUp:x=>{C.dispatchEvent(new PointerEvent(x.type,x))},onWheel:x=>{C.dispatchEvent(new WheelEvent(x.type,x))},props:(ct=(st=Z.get(a))==null?void 0:st.props)!=null?ct:this._getFloatDomProps(a),data:f,unitId:t});const ot=$.onTransformChange$.subscribeEvent(()=>{const x=Fe($,S.renderObject,s.skeleton,c.worksheet);Ve.next(x)});He.add(()=>{this._canvasFloatDomService.removeFloatDom(a)}),ot&&He.add(ot),this._domLayerInfoMap.set(a,yn),Z.set(a,{...Z.get(a)})})})),this.disposeWithMe(this._drawingManagerService.remove$.subscribe(n=>{n.forEach(e=>{const{unitId:t,subUnitId:o,drawingId:a}=e,c=P.getDrawingShapeKeyByDrawingSearch({unitId:t,subUnitId:o,drawingId:a}),l=this._getSceneAndTransformerByDrawingSearch(t);if(l==null)return;const{transformer:h,scene:u}=l,s=u.getObject(c);s!=null&&s.oKey&&h.clearControlByIds([s==null?void 0:s.oKey])})}))}_scrollUpdateListener(){const n=(e,t)=>{var u;const o=this._getSceneAndTransformerByDrawingSearch(e),a=this._ensureMap(e,t),c=Array.from(a.keys()),l=_.getSheetCommandTarget(this._univerInstanceService,{unitId:e,subUnitId:t}),h=(u=this._renderManagerService.getRenderById(e))==null?void 0:u.with(U.SheetSkeletonManagerService).getWorksheetSkeleton(t);!o||!l||!h||c.forEach(s=>{const m=this._domLayerInfoMap.get(s);if(m){const g=Fe(m.rect,o.renderObject,h.skeleton,l.worksheet);m.position$.next(g)}})};this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(d.UniverInstanceType.UNIVER_SHEET).pipe(j.filter(e=>!!e),j.switchMap(e=>e.activeSheet$),j.filter(e=>!!e),j.map(e=>{const t=this._renderManagerService.getRenderById(e.getUnitId());return t?{render:t,unitId:e.getUnitId(),subUnitId:e.getSheetId()}:null}),j.filter(e=>!!e),j.switchMap(e=>d.fromEventSubject(e.render.scene.getViewport(N.SHEET_VIEWPORT_KEY.VIEW_MAIN).onScrollAfter$).pipe(j.map(()=>({unitId:e.unitId,subUnitId:e.subUnitId}))))).subscribe(({unitId:e,subUnitId:t})=>{n(e,t)})),this.disposeWithMe(this._commandService.onCommandExecuted(e=>{var t,o;if(e.id===U.SetZoomRatioOperation.id){const a=e.params,{unitId:c}=a;Array.from((o=(t=this._domLayerMap.get(c))==null?void 0:t.keys())!=null?o:[]).forEach(h=>{n(c,h)})}else if(e.id===_.SetFrozenMutation.id){const{unitId:a,subUnitId:c}=e.params;n(a,c)}}))}_getPosition(n,e){var g;const{startX:t,endX:o,startY:a,endY:c}=n,l=(g=this._renderManagerService.getRenderById(e))==null?void 0:g.with(U.ISheetSelectionRenderService);if(l==null)return;const h=l.getCellWithCoordByOffset(t,a);if(h==null)return;const u={column:h.actualColumn,columnOffset:t-h.startX,row:h.actualRow,rowOffset:a-h.startY},s=l.getCellWithCoordByOffset(o,c);if(s==null)return;const m={column:s.actualColumn,columnOffset:o-s.startX,row:s.actualRow,rowOffset:c-s.startY};return{from:u,to:m}}_featureUpdateListener(){this.disposeWithMe(this._drawingManagerService.update$.subscribe(n=>{n.forEach(e=>{const t=this._drawingManagerService.getDrawingByParam(e);if(!t||t.drawingType!==d.DrawingTypeEnum.DRAWING_DOM&&t.drawingType!==d.DrawingTypeEnum.DRAWING_CHART)return;const o={...t.transform};this._transformChange$.next({id:e.drawingId,value:o})})}))}_deleteListener(){this.disposeWithMe(this._drawingManagerService.remove$.subscribe(n=>{n.forEach(e=>{this._removeDom(e.drawingId)})}))}updateFloatDomProps(n,e,t,o){const a=this._domLayerInfoMap.get(t),c=this._getSceneAndTransformerByDrawingSearch(n);if(a&&c){const{scene:l}=c,h=P.getDrawingShapeKeyByDrawingSearch({unitId:n,subUnitId:e,drawingId:t}),u=l.getObject(h);u&&u instanceof N.Rect&&u.setProps(o)}}addFloatDomToPosition(n,e){const t=_.getSheetCommandTarget(this._univerInstanceService,{unitId:n.unitId,subUnitId:n.subUnitId});if(!t)throw new Error("cannot find current target!");const{unitId:o,subUnitId:a}=t,{initPosition:c,componentKey:l,data:h,allowTransform:u=!0}=n,s=e!=null?e:d.generateRandomId(),m=this._getPosition(c,o);if(m==null)return;this._ensureMap(o,a).set(s,n);const f={unitId:o,subUnitId:a,drawingId:s,drawingType:n.type||d.DrawingTypeEnum.DRAWING_DOM,componentKey:l,sheetTransform:m,transform:{left:c.startX,top:c.startY,width:c.endX-c.startX,height:c.endY-c.startY},data:h,allowTransform:u};return this._commandService.executeCommand(ce.id,{unitId:o,drawings:[f]}),this._add$.next({unitId:o,subUnitId:a,id:s}),{id:s,dispose:()=>{this._removeDom(s,!0)}}}_removeDom(n,e=!1){const t=this._domLayerInfoMap.get(n);if(!t)return;const{unitId:o,subUnitId:a}=t;this._domLayerInfoMap.delete(n),t.dispose.dispose();const c=this._getSceneAndTransformerByDrawingSearch(o);if(c&&c.scene.removeObject(t.rect),e){this._ensureMap(o,a).delete(n);const h=this._drawingManagerService.getDrawingByParam({unitId:o,subUnitId:a,drawingId:n});if(!h)return;const u=this._sheetDrawingService.getBatchRemoveOp([h]),{redo:s,objects:m}=u;this._commandService.syncExecuteCommand(p.SetDrawingApplyMutation.id,{unitId:o,subUnitId:a,op:s,objects:m,type:p.DrawingApplyType.REMOVE})}}addHook(n){return this._hooks.push(n),{dispose:()=>{const e=this._hooks.findIndex(t=>t===n);this._hooks.splice(e,1)}}}},b.SheetCanvasFloatDomManagerService=fn([ie(0,d.Inject(N.IRenderManagerService)),ie(1,d.IUniverInstanceService),ie(2,d.Inject(d.ICommandService)),ie(3,P.IDrawingManagerService),ie(4,d.Inject(k.CanvasFloatDomService)),ie(5,p.ISheetDrawingService),ie(6,d.Inject(d.LifecycleService))],b.SheetCanvasFloatDomManagerService);var rt=Object.defineProperty,vn=Object.getOwnPropertyDescriptor,_n=(i,r,n)=>r in i?rt(i,r,{enumerable:!0,configurable:!0,writable:!0,value:n}):i[r]=n,wn=(i,r,n,e)=>{for(var t=e>1?void 0:e?vn(r,n):r,o=i.length-1,a;o>=0;o--)(a=i[o])&&(t=(e?a(r,n,t):a(t))||t);return e&&t&&rt(r,n,t),t},$e=(i,r)=>(n,e)=>r(n,e,i),it=(i,r,n)=>_n(i,typeof r!="symbol"?r+"":r,n);const In="SHEET_IMAGE_UI_PLUGIN";b.UniverSheetsDrawingUIPlugin=class extends d.Plugin{constructor(r=Ye,n,e,t){super(),this._config=r,this._injector=n,this._renderManagerService=e,this._configService=t;const{menu:o,...a}=d.merge({},Ye,this._config);o&&this._configService.setConfig("menu",o,{merge:!0}),this._configService.setConfig(dt,a)}onStarting(){d.registerDependencies(this._injector,[[b.SheetCanvasFloatDomManagerService],[Re],[he],[ye],[Ie],[we],[fe],[_e],[Se]]),d.touchDependencies(this._injector,[[b.SheetCanvasFloatDomManagerService]])}onReady(){d.touchDependencies(this._injector,[[we]])}onRendered(){this._registerRenderModules(),d.touchDependencies(this._injector,[[Ie],[ye],[Re],[fe],[_e],[Se]])}onSteady(){this._injector.get(he)}_registerRenderModules(){[[le],[Le],[Pe]].forEach(r=>{this.disposeWithMe(this._renderManagerService.registerRenderModule(d.UniverInstanceType.UNIVER_SHEET,r))})}},it(b.UniverSheetsDrawingUIPlugin,"type",d.UniverInstanceType.UNIVER_SHEET),it(b.UniverSheetsDrawingUIPlugin,"pluginName",In),b.UniverSheetsDrawingUIPlugin=wn([d.DependentOn(P.UniverDrawingPlugin,te.UniverDocsDrawingPlugin,q.UniverDrawingUIPlugin,p.UniverSheetsDrawingPlugin),$e(1,d.Inject(d.Injector)),$e(2,N.IRenderManagerService),$e(3,d.IConfigService)],b.UniverSheetsDrawingUIPlugin),b.ClearSheetDrawingTransformerOperation=G,b.DeleteDrawingsCommand=Be,b.EditSheetDrawingOperation=Ee,b.GroupSheetDrawingCommand=Ae,b.InsertFloatImageCommand=Me,b.InsertSheetDrawingCommand=ce,b.MoveDrawingsCommand=oe,b.RemoveSheetDrawingCommand=ae,b.SHEETS_IMAGE_MENU_ID=ke,b.SetDrawingArrangeCommand=Ue,b.SetSheetDrawingCommand=de,b.SidebarSheetDrawingOperation=be,b.UngroupSheetDrawingCommand=Ne,Object.defineProperty(b,Symbol.toStringTag,{value:"Module"})});
31
31
 
32
32
 
33
33
  // @univerjs/sheets-drawing-ui/facade
34
- (function(e,i){typeof exports=="object"&&typeof module<"u"?i(require("@univerjs/sheets/facade"),require("@univerjs/sheets-drawing-ui"),require("@univerjs/sheets-ui/facade"),require("@univerjs/ui")):typeof define=="function"&&define.amd?define(["@univerjs/sheets/facade","@univerjs/sheets-drawing-ui","@univerjs/sheets-ui/facade","@univerjs/ui"],i):(e=typeof globalThis<"u"?globalThis:e||self,i(e.UniverSheetsFacade,e.UniverSheetsDrawingUi,e.UniverSheetsUiFacade,e.UniverUi))})(this,function(e,i,o,r){"use strict";class d extends e.FWorksheet{addFloatDomToPosition(n,u){const a=this._workbook.getUnitId(),c=this._worksheet.getSheetId(),{key:h,disposableCollection:t}=o.transformComponentKey(n,this._injector.get(r.ComponentManager)),s=this._injector.get(i.SheetCanvasFloatDomManagerService).addFloatDomToPosition({...n,componentKey:h,unitId:a,subUnitId:c},u);return s?(t.add(s.dispose),{id:s.id,dispose:()=>{t.dispose(),s.dispose()}}):(t.dispose(),null)}}e.FWorksheet.extend(d)});
34
+ (function(s,c){typeof exports=="object"&&typeof module<"u"?c(require("@univerjs/core"),require("@univerjs/drawing"),require("@univerjs/engine-render"),require("@univerjs/sheets-drawing-ui"),require("@univerjs/sheets-ui"),require("@univerjs/sheets-drawing"),require("@univerjs/sheets-ui/facade"),require("@univerjs/sheets/facade"),require("@univerjs/ui")):typeof define=="function"&&define.amd?define(["@univerjs/core","@univerjs/drawing","@univerjs/engine-render","@univerjs/sheets-drawing-ui","@univerjs/sheets-ui","@univerjs/sheets-drawing","@univerjs/sheets-ui/facade","@univerjs/sheets/facade","@univerjs/ui"],c):(s=typeof globalThis<"u"?globalThis:s||self,c(s.UniverCore,s.UniverDrawing,s.UniverEngineRender,s.UniverSheetsDrawingUi,s.UniverSheetsUi,s.UniverSheetsDrawing,s.UniverSheetsUiFacade,s.UniverSheetsFacade,s.UniverUi))})(this,function(s,c,u,d,S,f,k,R,T){"use strict";var U=Object.defineProperty;var M=(s,c,u)=>c in s?U(s,c,{enumerable:!0,configurable:!0,writable:!0,value:u}):s[c]=u;var O=(s,c,u)=>M(s,typeof c!="symbol"?c+"":c,u);var B=Object.defineProperty,E=Object.getOwnPropertyDescriptor,b=(e,i,t,n)=>{for(var r=n>1?void 0:n?E(i,t):i,a=e.length-1,o;a>=0;a--)(o=e[a])&&(r=(n?o(i,t,r):o(r))||r);return n&&r&&B(i,t,r),r},v=(e,i)=>(t,n)=>i(t,n,e);function P(e,i){const{from:t,to:n,flipY:r=!1,flipX:a=!1,angle:o=0,skewX:g=0,skewY:h=0}=e.sheetTransform,{column:I,columnOffset:w,row:l,rowOffset:p}=t,C=S.convertPositionSheetOverGridToAbsolute(e.unitId,e.subUnitId,{from:t,to:n},i),{left:y,top:D,width:j,height:F}=C;return{...e,column:I,columnOffset:w,row:l,rowOffset:p,width:j,height:F,flipY:r,flipX:a,angle:o,skewX:g,skewY:h}}function W(e,i,t){const{column:n,columnOffset:r,row:a,rowOffset:o,flipY:g=!1,flipX:h=!1,angle:I=0,skewX:w=0,skewY:l=0,width:p,height:C}=e,y=S.convertPositionCellToSheetOverGrid(e.unitId,e.subUnitId,{column:n,columnOffset:r,row:a,rowOffset:o},p,C,i,t),{sheetTransform:D,transform:j}=y;return{...e,sheetTransform:{...D,flipY:g,flipX:h,angle:I,skewX:w,skewY:l},transform:{...j,flipY:g,flipX:h,angle:I,skewX:w,skewY:l}}}let _=class{constructor(e,i,t){O(this,"_image");this._injector=t,this._image={drawingId:s.generateRandomId(6),drawingType:s.DrawingTypeEnum.DRAWING_IMAGE,imageSourceType:s.ImageSourceType.BASE64,source:"",unitId:e,subUnitId:i,column:0,columnOffset:0,row:0,rowOffset:0,width:0,height:0}}setImage(e){const t=this._injector.get(u.IRenderManagerService).getRenderById(e.unitId);if(!t)throw new Error(`Render Unit with unitId ${e.unitId} not found`);const n=t.with(S.SheetSkeletonManagerService);return this._image=P(e,n),this}setSource(e,i){const t=i!=null?i:s.ImageSourceType.URL;return this._image.source=e,this._image.imageSourceType=t,this}getsource(){return this._image.source}getSourceType(){return this._image.imageSourceType}setColumn(e){return this._image.column=e,this}setRow(e){return this._image.row=e,this}setColumnOffset(e){return this._image.columnOffset=e,this}setRowOffset(e){return this._image.rowOffset=e,this}setWidth(e){return this._image.width=e,this}setHeight(e){return this._image.height=e,this}setAnchorType(e){return this._image.anchorType=e,this}setCropTop(e){return this._initializeSrcRect(),this._image.srcRect.top=e,this}setCropLeft(e){return this._initializeSrcRect(),this._image.srcRect.left=e,this}setCropBottom(e){return this._initializeSrcRect(),this._image.srcRect.bottom=e,this}setCropRight(e){return this._initializeSrcRect(),this._image.srcRect.right=e,this}_initializeSrcRect(){this._image.srcRect==null&&(this._image.srcRect={top:0,left:0,bottom:0,right:0})}setRotate(e){return this._image.angle=e,this}setUnitId(e){return this._image.unitId=e,this}setSubUnitId(e){return this._image.subUnitId=e,this}async build(){const i=this._injector.get(u.IRenderManagerService).getRenderById(this._image.unitId);if(!i)throw new Error(`Render Unit with unitId ${this._image.unitId} not found`);const t=i.with(S.ISheetSelectionRenderService),n=i.with(S.SheetSkeletonManagerService);if(this._image.width===0||this._image.height===0){const r=await c.getImageSize(this._image.source),a=r.width,o=r.height;this._image.width===0&&(this._image.width=a),this._image.height===0&&(this._image.height=o)}return W(this._image,t,n)}};_=b([v(2,s.Inject(s.Injector))],_);let m=class extends s.FBase{constructor(e,i,t){super(),this._image=e,this._commandService=i,this._injector=t}getId(){return this._image.drawingId}getType(){return this._image.drawingType}remove(){return this._commandService.syncExecuteCommand(d.SetSheetDrawingCommand.id,{unitId:this._image.unitId,drawings:[this._image]})}toBuilder(){const e=this._injector.createInstance(_);return e.setImage(this._image),e}setSource(e,i){const t=i!=null?i:s.ImageSourceType.URL;return this._image.source=e,this._image.imageSourceType=t,this._commandService.syncExecuteCommand(d.SetSheetDrawingCommand.id,{unitId:this._image.unitId,drawings:[this._image]})}setPosition(e,i,t,n){const r=this.toBuilder();return r.setColumn(i),r.setRow(e),t!=null&&r.setRowOffset(t),n!=null&&r.setColumnOffset(n),this._commandService.syncExecuteCommand(d.SetSheetDrawingCommand.id,{unitId:this._image.unitId,drawings:[r.build()]})}setSize(e,i){const t=this.toBuilder();return t.setWidth(e),t.setHeight(i),this._commandService.syncExecuteCommand(d.SetSheetDrawingCommand.id,{unitId:this._image.unitId,drawings:[t.build()]})}setCrop(e,i,t,n){return this._image.srcRect==null&&(this._image.srcRect={top:0,left:0,bottom:0,right:0}),e!=null&&(this._image.srcRect.top=e),i!=null&&(this._image.srcRect.left=i),t!=null&&(this._image.srcRect.bottom=t),n!=null&&(this._image.srcRect.right=n),this._commandService.syncExecuteCommand(d.SetSheetDrawingCommand.id,{unitId:this._image.unitId,drawings:[this._image]})}setRotate(e){return this._image.sheetTransform.angle=e,this._commandService.syncExecuteCommand(d.SetSheetDrawingCommand.id,{unitId:this._image.unitId,drawings:[this._image]})}};m=b([v(1,s.ICommandService),v(2,s.Inject(s.Injector))],m);class x extends R.FWorksheet{addFloatDomToPosition(i,t){const n=this._workbook.getUnitId(),r=this._worksheet.getSheetId(),{key:a,disposableCollection:o}=k.transformComponentKey(i,this._injector.get(T.ComponentManager)),h=this._injector.get(d.SheetCanvasFloatDomManagerService).addFloatDomToPosition({...i,componentKey:a,unitId:n,subUnitId:r},t);return h?(o.add(h.dispose),{id:h.id,dispose:()=>{o.dispose(),h.dispose()}}):(o.dispose(),null)}async insertImage(i,t,n,r,a){const o=this.newOverGridImage();if(typeof i=="string")o.setSource(i);else{const I=await i.getBlob().getDataAsString();o.setSource(I,s.ImageSourceType.BASE64)}t!==void 0?o.setColumn(t):o.setColumn(0),n!==void 0?o.setRow(n):o.setRow(0),r!==void 0?o.setColumnOffset(r):o.setColumnOffset(0),a!==void 0?o.setRowOffset(a):o.setRowOffset(0);const g=await o.build();return this._commandService.syncExecuteCommand(d.InsertSheetDrawingCommand.id,{unitId:this._fWorkbook.getId(),drawings:[g]})}insertImages(i){const t=i.map(n=>(n.unitId=this._fWorkbook.getId(),n.subUnitId=this.getSheetId(),n));this._commandService.syncExecuteCommand(d.InsertSheetDrawingCommand.id,{unitId:this._fWorkbook.getId(),drawings:t})}deleteImages(i){const t=i.map(n=>({unitId:this._fWorkbook.getId(),drawingId:n.getId(),subUnitId:this.getSheetId(),drawingType:n.getType()}));this._commandService.syncExecuteCommand(d.RemoveSheetDrawingCommand.id,{unitId:this._fWorkbook.getId(),drawings:t})}getImages(){const t=this._injector.get(f.ISheetDrawingService).getDrawingData(this._fWorkbook.getId(),this.getSheetId()),n=[];for(const r in t){const a=t[r];n.push(this._injector.createInstance(m,a))}return n}getImageById(i){const n=this._injector.get(f.ISheetDrawingService).getDrawingByParam({unitId:this._fWorkbook.getId(),subUnitId:this.getSheetId(),drawingId:i});return n?this._injector.createInstance(m,n):null}getActiveImages(){const t=this._injector.get(f.ISheetDrawingService).getFocusDrawings(),n=[];for(const r in t){const a=t[r];n.push(this._injector.createInstance(m,a))}return n}updateImages(i){this._commandService.syncExecuteCommand(d.SetSheetDrawingCommand.id,{unitId:this._fWorkbook.getId(),drawings:i})}onImageInserted(i){const t=this._injector.get(f.ISheetDrawingService);t.add$.subscribe(n=>{const r=n.map(a=>this._injector.createInstance(m,t.getDrawingByParam(a)));i(r)})}onImageDeleted(i){const t=this._injector.get(f.ISheetDrawingService);t.remove$.subscribe(n=>{const r=n.map(a=>this._injector.createInstance(m,t.getDrawingByParam(a)));i(r)})}onImageChanged(i){const t=this._injector.get(f.ISheetDrawingService);t.update$.subscribe(n=>{const r=n.map(a=>this._injector.createInstance(m,t.getDrawingByParam(a)));i(r)})}newOverGridImage(){const i=this._fWorkbook.getId(),t=this.getSheetId();return this._injector.createInstance(_,i,t)}}R.FWorksheet.extend(x)});
35
35
 
36
36
 
37
37
  // index
38
- (function(r,i){typeof exports=="object"&&typeof module<"u"?i(exports,require("@univerjs/docs-drawing"),require("@univerjs/drawing"),require("@univerjs/drawing-ui"),require("@univerjs/sheets-drawing"),require("@univerjs/sheets-drawing-ui")):typeof define=="function"&&define.amd?define(["exports","@univerjs/docs-drawing","@univerjs/drawing","@univerjs/drawing-ui","@univerjs/sheets-drawing","@univerjs/sheets-drawing-ui"],i):(r=typeof globalThis<"u"?globalThis:r||self,i(r.UniverPresetSheetsDrawing={},r.UniverDocsDrawing,r.UniverDrawing,r.UniverDrawingUi,r.UniverSheetsDrawing,r.UniverSheetsDrawingUi))})(this,function(r,i,n,t,u,a){"use strict";function c(e={}){const{collaboration:f=!1}=e;return{plugins:[[n.UniverDrawingPlugin,{override:f?[[n.IImageIoService,null]]:[]}],i.UniverDocsDrawingPlugin,t.UniverDrawingUIPlugin,u.UniverSheetsDrawingPlugin,a.UniverSheetsDrawingUIPlugin].filter(s=>!!s)}}r.UniverSheetsDrawingPreset=c,Object.keys(i).forEach(e=>{e!=="default"&&!Object.prototype.hasOwnProperty.call(r,e)&&Object.defineProperty(r,e,{enumerable:!0,get:()=>i[e]})}),Object.keys(n).forEach(e=>{e!=="default"&&!Object.prototype.hasOwnProperty.call(r,e)&&Object.defineProperty(r,e,{enumerable:!0,get:()=>n[e]})}),Object.keys(t).forEach(e=>{e!=="default"&&!Object.prototype.hasOwnProperty.call(r,e)&&Object.defineProperty(r,e,{enumerable:!0,get:()=>t[e]})}),Object.keys(u).forEach(e=>{e!=="default"&&!Object.prototype.hasOwnProperty.call(r,e)&&Object.defineProperty(r,e,{enumerable:!0,get:()=>u[e]})}),Object.keys(a).forEach(e=>{e!=="default"&&!Object.prototype.hasOwnProperty.call(r,e)&&Object.defineProperty(r,e,{enumerable:!0,get:()=>a[e]})}),Object.defineProperty(r,Symbol.toStringTag,{value:"Module"})});
38
+ (function(e,i){typeof exports=="object"&&typeof module<"u"?i(exports,require("@univerjs/docs-drawing"),require("@univerjs/drawing"),require("@univerjs/drawing-ui"),require("@univerjs/sheets-drawing"),require("@univerjs/sheets-drawing-ui"),require("@univerjs/sheets-drawing-ui/facade")):typeof define=="function"&&define.amd?define(["exports","@univerjs/docs-drawing","@univerjs/drawing","@univerjs/drawing-ui","@univerjs/sheets-drawing","@univerjs/sheets-drawing-ui","@univerjs/sheets-drawing-ui/facade"],i):(e=typeof globalThis<"u"?globalThis:e||self,i(e.UniverPresetSheetsDrawing={},e.UniverDocsDrawing,e.UniverDrawing,e.UniverDrawingUi,e.UniverSheetsDrawing,e.UniverSheetsDrawingUi))})(this,function(e,i,n,r,s,u){"use strict";function t(a={}){const{collaboration:g=!1}=a;return{plugins:[[n.UniverDrawingPlugin,{override:g?[[n.IImageIoService,null]]:[]}],i.UniverDocsDrawingPlugin,r.UniverDrawingUIPlugin,s.UniverSheetsDrawingPlugin,u.UniverSheetsDrawingUIPlugin].filter(v=>!!v)}}e.UniverSheetsDrawingPreset=t,Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@univerjs/preset-sheets-drawing",
3
- "version": "0.5.1",
3
+ "version": "0.5.2",
4
4
  "private": false,
5
5
  "description": "",
6
6
  "author": "DreamNum <developer@univer.ai>",
@@ -20,7 +20,9 @@
20
20
  "keywords": [
21
21
  "univer"
22
22
  ],
23
- "sideEffects": false,
23
+ "sideEffects": [
24
+ "*.css"
25
+ ],
24
26
  "exports": {
25
27
  ".": {
26
28
  "import": "./lib/es/index.js",
@@ -55,16 +57,16 @@
55
57
  "rxjs": ">=7.0.0"
56
58
  },
57
59
  "dependencies": {
58
- "@univerjs/docs-drawing": "0.5.1",
59
- "@univerjs/drawing": "0.5.1",
60
- "@univerjs/drawing-ui": "0.5.1",
61
- "@univerjs/sheets-drawing": "0.5.1",
62
- "@univerjs/sheets-drawing-ui": "0.5.1"
60
+ "@univerjs/docs-drawing": "0.5.2",
61
+ "@univerjs/drawing": "0.5.2",
62
+ "@univerjs/drawing-ui": "0.5.2",
63
+ "@univerjs/sheets-drawing": "0.5.2",
64
+ "@univerjs/sheets-drawing-ui": "0.5.2"
63
65
  },
64
66
  "devDependencies": {
65
- "@univerjs/core": "0.5.1",
67
+ "@univerjs/core": "0.5.2",
66
68
  "typescript": "^5.7.2",
67
- "@univerjs-infra/shared": "0.5.1"
69
+ "@univerjs-infra/shared": "0.5.2"
68
70
  },
69
71
  "scripts": {
70
72
  "prebuild:preset": "tsx prepare.ts",