@univerjs/preset-sheets-drawing 0.5.0 → 0.5.1

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 e=require("@univerjs/drawing"),t=require("@univerjs/drawing-ui"),s=require("@univerjs/sheets-drawing"),g=require("@univerjs/sheets-drawing-ui");function a(r={}){const{collaboration:i=!1}=r;return{plugins:[[e.UniverDrawingPlugin,{override:i?[[e.IImageIoService,null]]:[]}],t.UniverDrawingUIPlugin,s.UniverSheetsDrawingPlugin,g.UniverSheetsDrawingUIPlugin].filter(n=>!!n)}}exports.UniverSheetsDrawingPreset=a;
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]})});
@@ -0,0 +1 @@
1
+ "use strict";const e=require("@univerjs/core"),r=require("@univerjs/drawing-ui/locale/fr-FR"),s=require("@univerjs/sheets-drawing-ui/locale/fr-FR"),i=e.Tools.deepMerge({},r,s);module.exports=i;
package/lib/es/index.js CHANGED
@@ -1,18 +1,25 @@
1
- import { UniverDrawingPlugin as n, IImageIoService as o } from "@univerjs/drawing";
2
- import { UniverDrawingUIPlugin as t } from "@univerjs/drawing-ui";
3
- import { UniverSheetsDrawingPlugin as g } from "@univerjs/sheets-drawing";
4
- import { UniverSheetsDrawingUIPlugin as l } from "@univerjs/sheets-drawing-ui";
5
- function s(r = {}) {
6
- const { collaboration: i = !1 } = r;
1
+ import { UniverDocsDrawingPlugin as i } from "@univerjs/docs-drawing";
2
+ export * from "@univerjs/docs-drawing";
3
+ import { UniverDrawingPlugin as n, IImageIoService as t } from "@univerjs/drawing";
4
+ export * from "@univerjs/drawing";
5
+ import { UniverDrawingUIPlugin as m } from "@univerjs/drawing-ui";
6
+ export * from "@univerjs/drawing-ui";
7
+ import { UniverSheetsDrawingPlugin as f } from "@univerjs/sheets-drawing";
8
+ export * from "@univerjs/sheets-drawing";
9
+ import { UniverSheetsDrawingUIPlugin as g } from "@univerjs/sheets-drawing-ui";
10
+ export * from "@univerjs/sheets-drawing-ui";
11
+ function v(r = {}) {
12
+ const { collaboration: o = !1 } = r;
7
13
  return {
8
14
  plugins: [
9
- [n, { override: i ? [[o, null]] : [] }],
10
- t,
11
- g,
12
- l
15
+ [n, { override: o ? [[t, null]] : [] }],
16
+ i,
17
+ m,
18
+ f,
19
+ g
13
20
  ].filter((e) => !!e)
14
21
  };
15
22
  }
16
23
  export {
17
- s as UniverSheetsDrawingPreset
24
+ v as UniverSheetsDrawingPreset
18
25
  };
@@ -0,0 +1,11 @@
1
+ import { Tools as r } from "@univerjs/core";
2
+ import e from "@univerjs/drawing-ui/locale/fr-FR";
3
+ import o from "@univerjs/sheets-drawing-ui/locale/fr-FR";
4
+ const m = r.deepMerge(
5
+ {},
6
+ e,
7
+ o
8
+ );
9
+ export {
10
+ m as default
11
+ };
@@ -1,6 +1,11 @@
1
1
  import { IPreset } from './types';
2
2
  import '@univerjs/drawing-ui/lib/index.css';
3
3
  import '@univerjs/sheets-drawing-ui/lib/index.css';
4
+ export * from '@univerjs/docs-drawing';
5
+ export * from '@univerjs/drawing';
6
+ export * from '@univerjs/drawing-ui';
7
+ export * from '@univerjs/sheets-drawing';
8
+ export * from '@univerjs/sheets-drawing-ui';
4
9
  export interface IUniverSheetsDrawingPresetConfig {
5
10
  collaboration?: boolean;
6
11
  }
@@ -0,0 +1,2 @@
1
+ declare const _default: any;
2
+ export default _default;
package/lib/umd/index.js CHANGED
@@ -1,9 +1,9 @@
1
- // @univerjs/drawing/index
2
- (function(Y,de){typeof exports=="object"&&typeof module<"u"?de(exports,require("@univerjs/core"),require("rxjs")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","rxjs"],de):(Y=typeof globalThis<"u"?globalThis:Y||self,de(Y.UniverDrawing={},Y.UniverCore,Y.rxjs))})(this,function(Y,de,ge){"use strict";var Zt=Object.defineProperty;var Yt=(Y,de,ge)=>de in Y?Zt(Y,de,{enumerable:!0,configurable:!0,writable:!0,value:ge}):Y[de]=ge;var x=(Y,de,ge)=>Yt(Y,typeof de!="symbol"?de+"":de,ge);var ht;const vt=["image/png","image/jpeg","image/jpg","image/gif","image/bmp"];var Ae=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},V={},Ot={},it={};Object.defineProperty(it,"__esModule",{value:!0});function Rt(n,e){if(Array.isArray(e))return!1;for(let t in n)if(!rt(n[t],e[t]))return!1;for(let t in e)if(n[t]===void 0)return!1;return!0}function kt(n,e){if(!Array.isArray(e)||n.length!==e.length)return!1;for(let t=0;t<n.length;t++)if(!rt(n[t],e[t]))return!1;return!0}function rt(n,e){return n===e?!0:n===null||e===null||typeof n!="object"||typeof e!="object"?!1:Array.isArray(n)?kt(n,e):Rt(n,e)}it.default=rt;var st={};Object.defineProperty(st,"__esModule",{value:!0});function ot(n){if(n===null)return null;if(Array.isArray(n))return n.map(ot);if(typeof n=="object"){const e={};for(let t in n)e[t]=ot(n[t]);return e}else return n}st.default=ot;var at={};(function(n){Object.defineProperty(n,"__esModule",{value:!0}),n.eachChildOf=n.advancer=n.readCursor=n.writeCursor=n.WriteCursor=n.ReadCursor=n.isValidPathItem=void 0;function e(v,o){if(!v)throw new Error(o)}const t=v=>v!=null&&typeof v=="object"&&!Array.isArray(v),i=(v,o)=>typeof v==typeof o?v>o:typeof v=="string"&&typeof o=="number";function s(v,o){for(let c in v){const h=c;o.write(h,v[h])}}n.isValidPathItem=v=>typeof v=="number"||typeof v=="string"&&v!=="__proto__";class d{constructor(o=null){this.parents=[],this.indexes=[],this.lcIdx=-1,this.idx=-1,this.container=o}ascend(){e(this.parents.length===this.indexes.length/2),this.idx===0?this.parents.length?(this.lcIdx=this.indexes.pop(),this.container=this.parents.pop(),this.idx=this.indexes.pop()):(this.lcIdx=0,this.idx=-1):(e(this.idx>0),this.idx--,t(this.container[this.idx])&&this.idx--)}getPath(){const o=[];let c=this.container,h=this.parents.length-1,T=this.idx;for(;T>=0;)o.unshift(c[T]),T===0?(T=this.indexes[h*2],c=this.parents[h--]):T-=t(c[T-1])?2:1;return o}}class a extends d{get(){return this.container?this.container.slice(this.idx+1):null}getKey(){return e(this.container!=null,"Invalid call to getKey before cursor descended"),this.container[this.idx]}getComponent(){let o;return this.container&&this.container.length>this.idx+1&&t(o=this.container[this.idx+1])?o:null}descendFirst(){let o=this.idx+1;if(!this.container||o>=this.container.length||t(this.container[o])&&o+1>=this.container.length)return!1;t(this.container[o])&&o++;const c=this.container[o];return Array.isArray(c)?(this.indexes.push(this.idx),this.parents.push(this.container),this.indexes.push(o),this.idx=0,this.container=c):this.idx=o,!0}nextSibling(){if(e(this.parents.length===this.indexes.length/2),this.idx>0||this.parents.length===0)return!1;const o=this.indexes[this.indexes.length-1]+1,c=this.parents[this.parents.length-1];return o>=c.length?!1:(e(!isNaN(o)),this.indexes[this.indexes.length-1]=o,this.container=c[o],!0)}_init(o,c,h,T){this.container=o,this.idx=c,this.parents=h.slice(),this.indexes=T.slice()}clone(){const o=new a;return o._init(this.container,this.idx,this.parents,this.indexes),o}*[Symbol.iterator](){if(this.descendFirst()){do yield this.getKey();while(this.nextSibling());this.ascend()}}traverse(o,c){const h=this.getComponent();h&&c(h,o);for(const T of this)o&&o.descend(T),this.traverse(o,c),o&&o.ascend()}eachPick(o,c){this.traverse(o,(h,T)=>{h.p!=null&&c(h.p,T)})}eachDrop(o,c){this.traverse(o,(h,T)=>{h.d!=null&&c(h.d,T)})}}n.ReadCursor=a;class l extends d{constructor(o=null){super(o),this.pendingDescent=[],this._op=o}flushDescent(){e(this.parents.length===this.indexes.length/2),this.container===null&&(this._op=this.container=[]);for(let o=0;o<this.pendingDescent.length;o++){const c=this.pendingDescent[o];let h=this.idx+1;if(h<this.container.length&&t(this.container[h])&&h++,e(h===this.container.length||!t(this.container[h])),h===this.container.length)this.container.push(c),this.idx=h;else if(this.container[h]===c)this.idx=h;else{if(!Array.isArray(this.container[h])){const T=this.container.splice(h,this.container.length-h);this.container.push(T),this.lcIdx>-1&&(this.lcIdx=h)}for(this.indexes.push(this.idx),this.parents.push(this.container),this.lcIdx!==-1&&(e(i(c,this.container[this.lcIdx][0])),h=this.lcIdx+1,this.lcIdx=-1);h<this.container.length&&i(c,this.container[h][0]);)h++;if(this.indexes.push(h),this.idx=0,h<this.container.length&&this.container[h][0]===c)this.container=this.container[h];else{const T=[c];this.container.splice(h,0,T),this.container=T}}}this.pendingDescent.length=0}reset(){this.lcIdx=-1}getComponent(){this.flushDescent();const o=this.idx+1;if(o<this.container.length&&t(this.container[o]))return this.container[o];{const c={};return this.container.splice(o,0,c),c}}write(o,c){const h=this.getComponent();e(h[o]==null||h[o]===c,"Internal consistency error: Overwritten component. File a bug"),h[o]=c}get(){return this._op}descend(o){if(!n.isValidPathItem(o))throw Error("Invalid JSON key");this.pendingDescent.push(o)}descendPath(o){return this.pendingDescent.push(...o),this}ascend(){this.pendingDescent.length?this.pendingDescent.pop():super.ascend()}mergeTree(o,c=s){if(o===null)return;if(e(Array.isArray(o)),o===this._op)throw Error("Cannot merge into my own tree");const h=this.lcIdx,T=this.parents.length;let J=0;for(let ve=0;ve<o.length;ve++){const Q=o[ve];typeof Q=="string"||typeof Q=="number"?(J++,this.descend(Q)):Array.isArray(Q)?this.mergeTree(Q,c):typeof Q=="object"&&c(Q,this)}for(;J--;)this.ascend();this.lcIdx=this.parents.length===T?h:-1}at(o,c){this.descendPath(o),c(this);for(let h=0;h<o.length;h++)this.ascend();return this}writeAtPath(o,c,h){return this.at(o,()=>this.write(c,h)),this.reset(),this}writeMove(o,c,h=0){return this.writeAtPath(o,"p",h).writeAtPath(c,"d",h)}getPath(){const o=super.getPath();return o.push(...this.pendingDescent),o}}n.WriteCursor=l,n.writeCursor=()=>new l,n.readCursor=v=>new a(v);function E(v,o,c){let h,T;T=h=v?v.descendFirst():!1;function J(ve){let Q;for(;T;){const Ee=Q=v.getKey();if(ve!=null){let Fe=!1;if(o&&typeof Ee=="number"&&(Q=o(Ee,v.getComponent()),Q<0&&(Q=~Q,Fe=!0)),i(Q,ve))return null;if(Q===ve&&!Fe)return v}c&&typeof Q=="number"&&c(Q,v.getComponent()),T=v.nextSibling()}return null}return J.end=()=>{h&&v.ascend()},J}n.advancer=E;function G(v,o,c){let h,T,J,ve;for(h=T=v&&v.descendFirst(),J=ve=o&&o.descendFirst();h||J;){let Q=h?v.getKey():null,Ee=J?o.getKey():null;Q!==null&&Ee!==null&&(i(Ee,Q)?Ee=null:Q!==Ee&&(Q=null)),c(Q==null?Ee:Q,Q!=null?v:null,Ee!=null?o:null),Q!=null&&h&&(h=v.nextSibling()),Ee!=null&&J&&(J=o.nextSibling())}T&&v.ascend(),ve&&o.ascend()}n.eachChildOf=G})(at);var lt={};(function(n){Object.defineProperty(n,"__esModule",{value:!0}),n.ConflictType=void 0,function(e){e[e.RM_UNEXPECTED_CONTENT=1]="RM_UNEXPECTED_CONTENT",e[e.DROP_COLLISION=2]="DROP_COLLISION",e[e.BLACKHOLE=3]="BLACKHOLE"}(n.ConflictType||(n.ConflictType={}))})(lt);var ct={},Ke={},yt;function ut(){return yt||(yt=1,Object.defineProperty(Ke,"__esModule",{value:!0}),Ke.uniToStrPos=Ke.strPosToUni=void 0,Ke.strPosToUni=(n,e=n.length)=>{let t=0,i=0;for(;i<e;i++){const s=n.charCodeAt(i);s>=55296&&s<=57343&&(t++,i++)}if(i!==e)throw Error("Invalid offset - splits unicode bytes");return i-t},Ke.uniToStrPos=(n,e)=>{let t=0;for(;e>0;e--){const i=n.charCodeAt(t);t+=i>=55296&&i<=57343?2:1}return t}),Ke}var dt={},bt;function ft(){return bt||(bt=1,function(n){Object.defineProperty(n,"__esModule",{value:!0}),n.uniSlice=n.dlen=n.eachOp=void 0;const e=ut(),t=f=>{if(!Array.isArray(f))throw Error("Op must be an array of components");let _=null;for(let m=0;m<f.length;m++){const H=f[m];switch(typeof H){case"object":if(typeof H.d!="number"&&typeof H.d!="string")throw Error("Delete must be number or string");if(n.dlen(H.d)<=0)throw Error("Deletes must not be empty");break;case"string":if(!(H.length>0))throw Error("Inserts cannot be empty");break;case"number":if(!(H>0))throw Error("Skip components must be >0");if(typeof _=="number")throw Error("Adjacent skip components should be combined");break}_=H}if(typeof _=="number")throw Error("Op has a trailing skip")};function i(f,_){let m=0,H=0;for(let z=0;z<f.length;z++){const K=f[z];switch(_(K,m,H),typeof K){case"object":m+=n.dlen(K.d);break;case"string":H+=e.strPosToUni(K);break;case"number":m+=K,H+=K;break}}}n.eachOp=i;function s(f,_){const m=[],H=l(m);return i(f,(z,K,Pe)=>{H(_(z,K,Pe))}),o(m)}const d=f=>f,a=f=>s(f,d);n.dlen=f=>typeof f=="number"?f:e.strPosToUni(f);const l=f=>_=>{if(!(!_||_.d===0||_.d===""))if(f.length===0)f.push(_);else if(typeof _==typeof f[f.length-1])if(typeof _=="object"){const m=f[f.length-1];m.d=typeof m.d=="string"&&typeof _.d=="string"?m.d+_.d:n.dlen(m.d)+n.dlen(_.d)}else f[f.length-1]+=_;else f.push(_)},E=f=>typeof f=="number"?f:typeof f=="string"?e.strPosToUni(f):typeof f.d=="number"?f.d:e.strPosToUni(f.d);n.uniSlice=(f,_,m)=>{const H=e.uniToStrPos(f,_),z=m==null?1/0:e.uniToStrPos(f,m);return f.slice(H,z)};const G=(f,_,m)=>typeof f=="number"?m==null?f-_:Math.min(f,m)-_:n.uniSlice(f,_,m),v=f=>{let _=0,m=0;return{take:(K,Pe)=>{if(_===f.length)return K===-1?null:K;const fe=f[_];let ie;if(typeof fe=="number")return K===-1||fe-m<=K?(ie=fe-m,++_,m=0,ie):(m+=K,K);if(typeof fe=="string"){if(K===-1||Pe==="i"||e.strPosToUni(fe.slice(m))<=K)return ie=fe.slice(m),++_,m=0,ie;{const ce=m+e.uniToStrPos(fe.slice(m),K);return ie=fe.slice(m,ce),m=ce,ie}}else{if(K===-1||Pe==="d"||n.dlen(fe.d)-m<=K)return ie={d:G(fe.d,m)},++_,m=0,ie;{let ce=G(fe.d,m,m+K);return m+=K,{d:ce}}}},peek:()=>f[_]}},o=f=>(f.length>0&&typeof f[f.length-1]=="number"&&f.pop(),f);function c(f,_,m){if(m!=="left"&&m!=="right")throw Error("side ("+m+") must be 'left' or 'right'");t(f),t(_);const H=[],z=l(H),{take:K,peek:Pe}=v(f);for(let ie=0;ie<_.length;ie++){const ce=_[ie];let Oe,Me;switch(typeof ce){case"number":for(Oe=ce;Oe>0;)Me=K(Oe,"i"),z(Me),typeof Me!="string"&&(Oe-=E(Me));break;case"string":m==="left"&&typeof Pe()=="string"&&z(K(-1)),z(e.strPosToUni(ce));break;case"object":for(Oe=n.dlen(ce.d);Oe>0;)switch(Me=K(Oe,"i"),typeof Me){case"number":Oe-=Me;break;case"string":z(Me);break;case"object":Oe-=n.dlen(Me.d)}break}}let fe;for(;fe=K(-1);)z(fe);return o(H)}function h(f,_){t(f),t(_);const m=[],H=l(m),{take:z}=v(f);for(let Pe=0;Pe<_.length;Pe++){const fe=_[Pe];let ie,ce;switch(typeof fe){case"number":for(ie=fe;ie>0;)ce=z(ie,"d"),H(ce),typeof ce!="object"&&(ie-=E(ce));break;case"string":H(fe);break;case"object":ie=n.dlen(fe.d);let Oe=0;for(;Oe<ie;)switch(ce=z(ie-Oe,"d"),typeof ce){case"number":H({d:G(fe.d,Oe,Oe+ce)}),Oe+=ce;break;case"string":Oe+=e.strPosToUni(ce);break;case"object":H(ce)}break}}let K;for(;K=z(-1);)H(K);return o(m)}const T=(f,_)=>{let m=0;for(let H=0;H<_.length&&f>m;H++){const z=_[H];switch(typeof z){case"number":{m+=z;break}case"string":const K=e.strPosToUni(z);m+=K,f+=K;break;case"object":f-=Math.min(n.dlen(z.d),f-m);break}}return f},J=(f,_)=>typeof f=="number"?T(f,_):f.map(m=>T(m,_));function ve(f,_,m){return s(f,(H,z)=>typeof H=="object"&&typeof H.d=="number"?{d:m.slice(_,z,z+H.d)}:H)}function Q(f){return s(f,_=>{switch(typeof _){case"object":if(typeof _.d=="number")throw Error("Cannot invert text op: Deleted characters missing from operation. makeInvertible must be called first.");return _.d;case"string":return{d:_};case"number":return _}})}function Ee(f){return s(f,_=>typeof _=="object"&&typeof _.d=="string"?{d:e.strPosToUni(_.d)}:_)}function Fe(f){let _=!0;return i(f,m=>{typeof m=="object"&&typeof m.d=="number"&&(_=!1)}),_}function Ie(f){return{name:"text-unicode",uri:"http://sharejs.org/types/text-unicode",trim:o,normalize:a,checkOp:t,create(_=""){if(typeof _!="string")throw Error("Initial data must be a string");return f.create(_)},apply(_,m){t(m);const H=f.builder(_);for(let z=0;z<m.length;z++){const K=m[z];switch(typeof K){case"number":H.skip(K);break;case"string":H.append(K);break;case"object":H.del(n.dlen(K.d));break}}return H.build()},transform:c,compose:h,transformPosition:T,transformSelection:J,isInvertible:Fe,makeInvertible(_,m){return ve(_,m,f)},stripInvertible:Ee,invert:Q,invertWithDoc(_,m){return Q(ve(_,m,f))},isNoop:_=>_.length===0}}n.default=Ie}(dt)),dt}var tt={},It;function jt(){if(It)return tt;It=1,Object.defineProperty(tt,"__esModule",{value:!0});const n=ft(),e=ut();function t(i,s){return{get:i,getLength(){return i().length},insert(d,a,l){const E=e.strPosToUni(i(),d);return s([E,a],l)},remove(d,a,l){const E=e.strPosToUni(i(),d);return s([E,{d:a}],l)},_onOp(d){n.eachOp(d,(a,l,E)=>{switch(typeof a){case"string":this.onInsert&&this.onInsert(E,a);break;case"object":const G=n.dlen(a.d);this.onRemove&&this.onRemove(E,G)}})},onInsert:null,onRemove:null}}return tt.default=t,t.provides={text:!0},tt}var mt;function $t(){return mt||(mt=1,function(n){var e=Ae&&Ae.__createBinding||(Object.create?function(c,h,T,J){J===void 0&&(J=T),Object.defineProperty(c,J,{enumerable:!0,get:function(){return h[T]}})}:function(c,h,T,J){J===void 0&&(J=T),c[J]=h[T]}),t=Ae&&Ae.__setModuleDefault||(Object.create?function(c,h){Object.defineProperty(c,"default",{enumerable:!0,value:h})}:function(c,h){c.default=h}),i=Ae&&Ae.__importStar||function(c){if(c&&c.__esModule)return c;var h={};if(c!=null)for(var T in c)Object.hasOwnProperty.call(c,T)&&e(h,c,T);return t(h,c),h},s=Ae&&Ae.__importDefault||function(c){return c&&c.__esModule?c:{default:c}};Object.defineProperty(n,"__esModule",{value:!0}),n.type=n.remove=n.insert=void 0;const d=ut(),a=i(ft()),l=s(jt()),E={create(c){return c},toString(c){return c},builder(c){if(typeof c!="string")throw Error("Invalid document snapshot: "+c);const h=[];return{skip(T){let J=d.uniToStrPos(c,T);if(J>c.length)throw Error("The op is too long for this document");h.push(c.slice(0,J)),c=c.slice(J)},append(T){h.push(T)},del(T){c=c.slice(d.uniToStrPos(c,T))},build(){return h.join("")+c}}},slice:a.uniSlice},G=a.default(E),v=Object.assign(Object.assign({},G),{api:l.default});n.type=v,n.insert=(c,h)=>h.length===0?[]:c===0?[h]:[c,h],n.remove=(c,h)=>a.dlen(h)===0?[]:c===0?[{d:h}]:[c,{d:h}];var o=ft();Object.defineProperty(n,"makeType",{enumerable:!0,get:function(){return o.default}})}(ct)),ct}(function(n){var e=Ae&&Ae.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(n,"__esModule",{value:!0}),n.editOp=n.replaceOp=n.insertOp=n.moveOp=n.removeOp=n.type=void 0;const t=e(it),i=e(st),s=at,d=lt;function a(r,u){if(!r)throw new Error(u)}n.type={name:"json1",uri:"http://sharejs.org/types/JSONv1",readCursor:s.readCursor,writeCursor:s.writeCursor,create:r=>r,isNoop:r=>r==null,setDebug(r){},registerSubtype:Q,checkValidOp:z,normalize:K,apply:Pe,transformPosition:fe,compose:ie,tryTransform:pt,transform:zt,makeInvertible:Me,invert:ce,invertWithDoc:qt,RM_UNEXPECTED_CONTENT:d.ConflictType.RM_UNEXPECTED_CONTENT,DROP_COLLISION:d.ConflictType.DROP_COLLISION,BLACKHOLE:d.ConflictType.BLACKHOLE,transformNoConflict:(r,u,y)=>Nt(()=>!0,r,u,y),typeAllowingConflictsPred:r=>Object.assign(Object.assign({},n.type),{transform:(u,y,A)=>Nt(r,u,y,A)})};const l=r=>r?r.getComponent():null;function E(r){return r&&typeof r=="object"&&!Array.isArray(r)}const G=r=>Array.isArray(r)?r.slice():r!==null&&typeof r=="object"?Object.assign({},r):r,v=r=>r&&(r.p!=null||r.r!==void 0),o=r=>r&&(r.d!=null||r.i!==void 0);function c(r,u){return a(r!=null),typeof u=="number"?(a(Array.isArray(r),"Invalid key - child is not an array"),(r=r.slice()).splice(u,1)):(a(E(r),"Invalid key - child is not an object"),delete(r=Object.assign({},r))[u]),r}function h(r,u,y){return typeof u=="number"?(a(r!=null,"Container is missing for key"),a(Array.isArray(r),"Cannot use numerical key for object container"),a(r.length>=u,"Cannot insert into out of bounds index"),r.splice(u,0,y)):(a(E(r),"Cannot insert into missing item"),a(r[u]===void 0,"Trying to overwrite value at key. Your op needs to remove it first"),r[u]=y),y}n.removeOp=(r,u=!0)=>s.writeCursor().writeAtPath(r,"r",u).get(),n.moveOp=(r,u)=>s.writeCursor().writeMove(r,u).get(),n.insertOp=(r,u)=>s.writeCursor().writeAtPath(r,"i",u).get(),n.replaceOp=(r,u,y)=>s.writeCursor().at(r,A=>{A.write("r",u),A.write("i",y)}).get(),n.editOp=(r,u,y,A=!1)=>s.writeCursor().at(r,b=>_(b,u,y,A)).get();const T=(r,u)=>r!=null&&(typeof u=="number"?Array.isArray(r):typeof r=="object"),J=(r,u)=>T(r,u)?r[u]:void 0,ve={};function Q(r){let u=r.type?r.type:r;u.name&&(ve[u.name]=u),u.uri&&(ve[u.uri]=u)}const Ee=r=>{const u=ve[r];if(u)return u;throw Error("Missing type: "+r)};Q($t());const Fe=(r,u)=>r+u;Q({name:"number",apply:Fe,compose:Fe,invert:r=>-r,transform:r=>r});const Ie=r=>r==null?null:r.et?Ee(r.et):r.es?ve["text-unicode"]:r.ena!=null?ve.number:null,f=r=>r.es?r.es:r.ena!=null?r.ena:r.e,_=(r,u,y,A=!1)=>{const[b,C]=typeof u=="string"?[Ee(u),u]:[u,u.name];!A&&b.isNoop&&b.isNoop(y)||(C==="number"?r.write("ena",y):C==="text-unicode"?r.write("es",y):(r.write("et",C),r.write("e",y)))};function m(r){a(typeof r=="number"),a(r>=0),a(r===(0|r))}function H(r){typeof r=="number"?m(r):a(typeof r=="string")}function z(r){if(r===null)return;const u=new Set,y=new Set,A=C=>{let $=!0,k=!1;for(let g in C){const O=C[g];if($=!1,a(g==="p"||g==="r"||g==="d"||g==="i"||g==="e"||g==="es"||g==="ena"||g==="et","Invalid component item '"+g+"'"),g==="p")m(O),a(!u.has(O)),u.add(O),a(C.r===void 0);else if(g==="d")m(O),a(!y.has(O)),y.add(O),a(C.i===void 0);else if(g==="e"||g==="es"||g==="ena"){a(!k),k=!0;const I=Ie(C);a(I,"Missing type in edit"),I.checkValidOp&&I.checkValidOp(f(C))}}a(!$)},b=(C,$,k)=>{if(!Array.isArray(C))throw Error("Op must be null or a list");if(C.length===0)throw Error("Empty descent");$||H(C[0]);let g=1,O=0,I=0;for(let w=0;w<C.length;w++){const j=C[w];if(a(j!=null),Array.isArray(j)){const W=b(j,!1);if(O){const p=typeof I,U=typeof W;p===U?a(I<W,"descent keys are not in order"):a(p==="number"&&U==="string")}I=W,O++,g=3}else typeof j=="object"?(a(g===1,`Prev not scalar - instead ${g}`),A(j),g=2):(a(g!==3),H(j),a(s.isValidPathItem(j),"Invalid path key"),g=1)}return a(O!==1,"Operation makes multiple descents. Remove some []"),a(g===2||g===3),C[0]};b(r,!0),a(u.size===y.size,"Mismatched picks and drops in op");for(let C=0;C<u.size;C++)a(u.has(C)),a(y.has(C))}function K(r){let u=0,y=[];const A=s.writeCursor();return A.mergeTree(r,(b,C)=>{const $=Ie(b);if($){const g=f(b);_(C,$,$.normalize?$.normalize(g):g)}for(const g of["r","p","i","d"])if(b[g]!==void 0){const O=g==="p"||g==="d"?(k=b[g],y[k]==null&&(y[k]=u++),y[k]):b[g];C.write(g,O)}var k}),A.get()}function Pe(r,u){if(z(u),u===null)return r;const y=[];return function A(b,C){let $=b,k=0,g={root:b},O=0,I=g,w="root";function j(){for(;O<k;O++){let W=C[O];typeof W!="object"&&(a(T(I,w)),I=I[w]=G(I[w]),w=W)}}for(;k<C.length;k++){const W=C[k];if(Array.isArray(W)){const p=A($,W);p!==$&&p!==void 0&&(j(),$=I[w]=p)}else if(typeof W=="object"){W.d!=null?(j(),$=h(I,w,y[W.d])):W.i!==void 0&&(j(),$=h(I,w,W.i));const p=Ie(W);if(p)j(),$=I[w]=p.apply($,f(W));else if(W.e!==void 0)throw Error("Subtype "+W.et+" undefined")}else $=J($,W)}return g.root}(r=function A(b,C){const $=[];let k=0;for(;k<C.length;k++){const w=C[k];if(Array.isArray(w))break;typeof w!="object"&&($.push(b),b=J(b,w))}for(let w=C.length-1;w>=k;w--)b=A(b,C[w]);for(--k;k>=0;k--){const w=C[k];if(typeof w!="object"){const j=$.pop();b=b===J(j,w)?j:b===void 0?c(j,w):(O=w,I=b,(g=G(g=j))[O]=I,g)}else v(w)&&(a(b!==void 0,"Cannot pick up or remove undefined"),w.p!=null&&(y[w.p]=b),b=void 0)}var g,O,I;return b}(r,u),u)}function fe(r,u){r=r.slice(),z(u);const y=s.readCursor(u);let A,b,C=!1;const $=[];for(let g=0;;g++){const O=r[g],I=y.getComponent();if(I&&(I.r!==void 0?C=!0:I.p!=null&&(C=!1,A=I.p,b=g)),g>=r.length)break;let w=0;const j=s.advancer(y,void 0,(p,U)=>{v(U)&&w++});$.unshift(j);const W=j(O);if(typeof O=="number"&&(r[g]-=w),!W)break}if($.forEach(g=>g.end()),C)return null;const k=()=>{let g=0;if(A!=null){const O=y.getPath();g=O.length,r=O.concat(r.slice(b))}for(;g<r.length;g++){const O=r[g],I=l(y),w=Ie(I);if(w){const p=f(I);w.transformPosition&&(r[g]=w.transformPosition(r[g],p));break}let j=0;const W=s.advancer(y,(p,U)=>o(U)?~(p-j):p-j,(p,U)=>{o(U)&&j++})(O);if(typeof O=="number"&&(r[g]+=j),!W)break}};return A!=null?y.eachDrop(null,g=>{g===A&&k()}):k(),r}function ie(r,u){if(z(r),z(u),r==null)return u;if(u==null)return r;let y=0;const A=s.readCursor(r),b=s.readCursor(u),C=s.writeCursor(),$=[],k=[],g=[],O=[],I=[],w=[],j=new Set;A.traverse(null,p=>{p.p!=null&&(g[p.p]=A.clone())}),b.traverse(null,p=>{p.d!=null&&(O[p.d]=b.clone())});const W=s.writeCursor();return function p(U,re,ne,F,oe,Ge,we,ye){a(re||ne);const ae=l(re),Se=l(ne),Ne=!!Se&&Se.r!==void 0,Ve=!!ae&&ae.i!==void 0,Ue=ae?ae.d:null,De=Se?Se.p:null,We=(Ge||Ne)&&De==null;if(De!=null)F=O[De],we=k[De]=new s.WriteCursor;else if(Se&&Se.r!==void 0)F=null;else{const P=l(F);P&&P.d!=null&&(F=null)}const ee=l(F);if(Ue!=null)if(U=g[Ue],ye=$[Ue]=new s.WriteCursor,We)Ge&&!Ne&&ye.write("r",!0);else{const P=I[Ue]=y++;we.write("d",P)}else if(ae&&ae.i!==void 0)U=null;else{const P=l(U);P&&P.p!=null&&(U=null)}let M;Ve?(a(oe===void 0),M=ae.i):M=oe;const L=(De==null?!Ve||Ge||Ne:M===void 0)?null:we.getComponent();if(De!=null){if(!(oe!==void 0||Ve)){const P=Ue!=null?I[Ue]:y++;w[De]=P,ye.write("p",P)}}else Ne&&(Ve||oe!==void 0||(Se.r,ye.write("r",Se.r)));const S=We?null:Ie(ae),D=Ie(ee);if((S||D)&&(S&&S.name,D&&D.name),S&&D){a(S===D);const P=f(ae),B=f(ee),_e=S.compose(P,B);_(we,S,_e),j.add(ee)}else S?_(we,S,f(ae)):D&&(_(we,D,f(ee)),j.add(ee));const N=typeof M=="object"&&M!=null;let X=!1,Z=0,te=0,pe=0,he=0,le=0;const me=s.advancer(F,(P,B)=>o(B)?he-P-1:P-he,(P,B)=>{o(B)&&he++}),q=s.advancer(U,(P,B)=>v(B)?Z-P-1:P-Z,(P,B)=>{v(B)&&Z++});if(s.eachChildOf(re,ne,(P,B,_e)=>{let Ce,Le,xe=P,Te=P,et=P;if(typeof P=="number"){let be=P+pe;Le=me(be),Te=be+he;let ue=P+te;Ce=q(ue),o(l(Le))&&(Ce=null),xe=ue+Z,et=P+le,a(xe>=0,"p1PickKey is negative"),a(Te>=0,"p2DropKey is negative");const Re=o(l(B)),Be=v(l(_e));(Re||Be&&!We)&&le--,Re&&te--,Be&&pe--}else Ce=q(P),Le=me(P);ye.descend(xe),we.descend(Te);const Ye=N&&!o(l(B))?M[et]:void 0,je=p(Ce,B,_e,Le,Ye,We,we,ye);var $e,R,se;N&&!We?Ye!==je&&(X||(M=Array.isArray(M)?M.slice():Object.assign({},M),X=!0),$e=M,se=je,typeof(R=et)=="number"?(a(Array.isArray($e)),a(R<$e.length)):(a(!Array.isArray($e)),a($e[R]!==void 0)),se===void 0?typeof R=="number"?$e.splice(R,1):delete $e[R]:$e[R]=se):a(je===void 0),we.ascend(),ye.ascend()}),q.end(),me.end(),L!=null)L.i=M;else if(!Ge&&!Ne&&De==null)return M}(A,A.clone(),b,b.clone(),void 0,!1,C,W),C.reset(),C.mergeTree(W.get()),C.reset(),C.get(),$.map(p=>p.get()),k.map(p=>p.get()),A.traverse(C,(p,U)=>{const re=p.p;if(re!=null){const ne=I[re];ne!=null&&U.write("p",ne);const F=$[re];F&&F.get(),F&&U.mergeTree(F.get())}else p.r!==void 0&&U.write("r",p.r)}),C.reset(),C.get(),b.traverse(C,(p,U)=>{const re=p.d;if(re!=null){const F=w[re];F!=null&&U.write("d",F);const oe=k[re];oe&&U.mergeTree(oe.get())}else p.i!==void 0&&U.write("i",p.i);const ne=Ie(p);ne&&!j.has(p)&&_(U,ne,f(p))}),C.get()}function ce(r){if(r==null)return null;const u=new s.ReadCursor(r),y=new s.WriteCursor;let A;const b=[],C=[];return function $(k,g,O){const I=k.getComponent();let w,j=!1;if(I){I.p!=null&&(g.write("d",I.p),b[I.p]=k.clone()),I.r!==void 0&&g.write("i",I.r),I.d!=null&&(g.write("p",I.d),O=void 0),I.i!==void 0&&(O=w=I.i);const p=Ie(I);p&&(O===void 0?(A||(A=new Set),A.add(I)):(f(I),O=p.apply(O,f(I)),j=!0))}let W=0;for(const p of k){g.descend(p);const U=typeof p=="number"?p-W:p,re=J(O,U);o(k.getComponent())&&W++;const ne=$(k,g,re);if(O!==void 0&&ne!==void 0){if(j||(j=!0,O=G(O)),!T(O,U))throw Error("Cannot modify child - invalid operation");O[U]=ne}g.ascend()}if(w===void 0)return j?O:void 0;g.write("r",O)}(u,y,void 0),A&&(y.reset(),function $(k,g,O){const I=g.getComponent();if(I){const p=I.d;if(p!=null&&(k=b[p],O=C[p]=s.writeCursor()),A.has(I)){const U=Ie(I);if(!U.invert)throw Error(`Cannot invert subtype ${U.name}`);_(O,U,U.invert(f(I)))}}let w=0,j=0;const W=s.advancer(k,(p,U)=>v(U)?w-p-1:p-w,(p,U)=>{v(U)&&w++});for(const p of g)if(typeof p=="number"){const U=p-j,re=W(U),ne=U+w;O.descend(ne),$(re,g,O),o(g.getComponent())&&j++,O.ascend()}else O.descend(p),$(W(p),g,O),O.ascend();W.end()}(u.clone(),u,y),C.length&&(y.reset(),u.traverse(y,($,k)=>{const g=$.p;if(g!=null){const O=C[g];O&&O.get(),O&&k.mergeTree(O.get())}}))),y.get()}const Oe=(r,u)=>r.some(y=>typeof y=="object"&&(Array.isArray(y)?Oe(y,u):u(y)));function Me(r,u){if(r==null||!Oe(r,g=>{var O;return g.r!==void 0||((O=Ie(g))===null||O===void 0?void 0:O.makeInvertible)!=null}))return r;const y=new s.ReadCursor(r),A=new s.WriteCursor;let b=!1;const C=[],$=[],k=(g,O,I)=>{const w=g.getComponent();let j=!1;if(w){w.d!=null&&O.write("d",w.d),w.i!==void 0&&O.write("i",w.i);const p=w.p;if(p!=null&&(C[p]=g.clone(),a(I!==void 0,"Operation picks up at an invalid key"),$[p]=I,O.write("p",w.p)),w.r!==void 0&&I===void 0)throw Error("Invalid doc / op in makeInvertible: removed item missing from doc");const U=Ie(w);U&&(U.makeInvertible?b=!0:_(O,U,f(w),!0))}let W=0;for(const p of g){O.descend(p);const U=typeof p=="number"?p-W:p,re=J(I,U),ne=k(g,O,re);re!==ne&&(j||(j=!0,I=G(I)),ne===void 0?(I=c(I,U),typeof p=="number"&&W++):I[U]=ne),O.ascend()}return w&&(w.r!==void 0?(O.write("r",i.default(I)),I=void 0):w.p!=null&&(I=void 0)),I};return k(y,A,u),A.get(),b&&(A.reset(),function g(O,I,w,j,W){const p=I.getComponent();if(p){p.i!==void 0?(j=p.i,W=!0):p.d!=null&&(j=$[p.d],O=C[p.d],W=!1,p.d);let F=Ie(p);if(F&&F.makeInvertible){const oe=f(p);_(w,F,F.makeInvertible(oe,j),!0)}}let U=0,re=0;const ne=s.advancer(O,(F,oe)=>v(oe)?U-F-1:F-U,(F,oe)=>{v(oe)&&U++});for(const F of I)if(typeof F=="number"){const oe=F-re,Ge=ne(oe),we=oe+U,ye=J(j,W?oe:we);w.descend(F),g(Ge,I,w,ye,W),o(I.getComponent())&&re++,w.ascend()}else{const oe=J(j,F);w.descend(F),g(ne(F),I,w,oe,W),w.ascend()}ne.end()}(y.clone(),y,A,u,!1)),A.get()}function qt(r,u){return ce(Me(r,u))}const gt=r=>{if(r==null)return null;const u=r.slice();for(let y=0;y<r.length;y++){const A=u[y];Array.isArray(A)&&(u[y]=gt(A))}return u};function pt(r,u,y){a(y==="left"||y==="right","Direction must be left or right");const A=y==="left"?0:1;if(u==null)return{ok:!0,result:r};z(r),z(u);let b=null;const C=[],$=[],k=[],g=[],O=[],I=[],w=[],j=[],W=[],p=[],U=[],re=[],ne=[],F=[],oe=[];let Ge=0;const we=s.readCursor(r),ye=s.readCursor(u),ae=s.writeCursor();if(function ee(M,L=null,S){const D=l(L);D&&(D.r!==void 0?S=L.clone():D.p!=null&&(S=null,I[D.p]=M.clone()));const N=M.getComponent();let X;N&&(X=N.p)!=null&&(O[X]=L?L.clone():null,k[X]=M.clone(),S&&(p[X]=!0,W[X]=S),D&&D.p!=null&&(F[X]=D.p));const Z=s.advancer(L);for(const te of M)ee(M,Z(te),S);Z.end()}(ye,we,null),function ee(M,L,S,D,N){const X=S.getComponent();let Z,te=!1;X&&((Z=X.d)!=null?(g[Z]=S.clone(),D!=null&&(oe[D]==null&&(oe[D]=[]),oe[D].push(Z)),M=O[Z]||null,L=k[Z]||null,p[Z]?(N&&(U[Z]=!0),N=W[Z]||null):!N||A!==1&&F[Z]!=null||b==null&&(b={type:d.ConflictType.RM_UNEXPECTED_CONTENT,op1:n.removeOp(N.getPath()),op2:n.moveOp(L.getPath(),S.getPath())}),te=!0):X.i!==void 0&&(M=L=null,te=!0,N&&b==null&&(b={type:d.ConflictType.RM_UNEXPECTED_CONTENT,op1:n.removeOp(N.getPath()),op2:n.insertOp(S.getPath(),X.i)})));const pe=l(M);pe&&(pe.r!==void 0?N=M.clone():pe.p!=null&&(pe.p,D=pe.p,N=null));const he=Ie(X);he&&N&&b==null&&(b={type:d.ConflictType.RM_UNEXPECTED_CONTENT,op1:n.removeOp(N.getPath()),op2:n.editOp(S.getPath(),he,f(X),!0)});let le=0,me=0;const q=s.advancer(L,(B,_e)=>v(_e)?le-B-1:B-le,(B,_e)=>{v(_e)&&le++}),P=s.advancer(M);for(const B of S)if(typeof B=="number"){const _e=B-me,Ce=q(_e);me+=+ee(P(_e+le),Ce,S,D,N)}else{const _e=q(B);ee(P(B),_e,S,D,N)}return q.end(),P.end(),te}(we,ye,ye.clone(),null,null),g.map(ee=>ee&&ee.get()),b)return{ok:!1,conflict:b};U.map(ee=>!!ee);const Se=[];let Ne=null;(function ee(M,L,S,D,N){let X=!1;const Z=l(L);if(v(Z)){const q=Z.p;q!=null?(S=g[q],D=re[q]=s.writeCursor(),X=!0,N=null):(S=null,N=L.clone())}else o(l(S))&&(S=null);const te=M.getComponent();if(te){const q=te.p;q!=null?(N&&(j[q]=N),Se[q]=N||A===1&&X?null:D.getComponent(),C[q]=M.clone(),S&&(w[q]=S.clone())):te.r!==void 0&&(N||D.write("r",!0),(N||X)&&(Ne==null&&(Ne=new Set),Ne.add(te)))}let pe=0,he=0;const le=s.advancer(L,void 0,(q,P)=>{v(P)&&pe++}),me=s.advancer(S,(q,P)=>o(P)?~(q-he):q-he,(q,P)=>{o(P)&&he++});if(M)for(const q of M)if(typeof q=="string"){const P=le(q),B=me(q);D.descend(q),ee(M,P,B,D,N),D.ascend()}else{const P=le(q),B=q-pe,_e=v(l(P))?null:me(B),Ce=B+he;a(Ce>=0),D.descend(Ce),ee(M,P,_e,D,N),D.ascend()}le.end(),me.end()})(we,ye,ye.clone(),ae,null),ae.reset();let Ve=[];if(function ee(M,L,S,D,N,X){a(L);const Z=L.getComponent();let te=l(D),pe=!1;const he=(R,se,be)=>R?n.moveOp(R.getPath(),se.getPath()):n.insertOp(se.getPath(),be.i);if(o(Z)){const R=Z.d;R!=null&&($[R]=L.clone());const se=R!=null?Se[R]:null;let be=!1;if(Z.i!==void 0||R!=null&&se){let ue;te&&(te.i!==void 0||(ue=te.d)!=null&&!p[ue])&&(be=ue!=null?R!=null&&R===F[ue]:t.default(te.i,Z.i),be||ue!=null&&A!==1&&F[ue]!=null||b==null&&(b={type:d.ConflictType.DROP_COLLISION,op1:he(R!=null?C[R]:null,L,Z),op2:he(ue!=null?k[ue]:null,D,te)})),be||(X?b==null&&(b={type:d.ConflictType.RM_UNEXPECTED_CONTENT,op1:he(R!=null?C[R]:null,L,Z),op2:n.removeOp(X.getPath())}):(R!=null?(Ve[Ge]=R,N.write("d",se.p=Ge++)):N.write("i",i.default(Z.i)),pe=!0))}else if(R!=null&&!se){const ue=j[R];ue&&(X=ue.clone())}R!=null?(M=C[R],S=I[R],D=w[R]):Z.i!==void 0&&(M=S=null,be||(D=null))}else v(l(M))&&(M=S=D=null);const le=l(M),me=l(S);if(v(me)){const R=me.p;me.r!==void 0&&(!le||le.r===void 0)||p[R]?(D=null,X=S.clone()):R!=null&&(D=g[R],A!==1&&F[R]!=null||((N=ne[R])||(N=ne[R]=s.writeCursor()),N.reset(),X=null))}else!o(Z)&&o(te)&&(D=null);te=D!=null?D.getComponent():null;const q=Ie(Z);if(q){const R=f(Z);if(X)b==null&&(b={type:d.ConflictType.RM_UNEXPECTED_CONTENT,op1:n.editOp(L.getPath(),q,R,!0),op2:n.removeOp(X.getPath())});else{const se=Ie(te);let be;if(se){if(q!==se)throw Error("Transforming incompatible types");const ue=f(te);be=q.transform(R,ue,y)}else be=i.default(R);_(N,q,be)}}let P=0,B=0,_e=0,Ce=0,Le=0,xe=0,Te=M!=null&&M.descendFirst(),et=Te;const Ye=s.advancer(S,void 0,(R,se)=>{v(se)&&_e++});let je=D!=null&&D.descendFirst(),$e=je;for(const R of L)if(typeof R=="number"){let se;const be=o(L.getComponent()),ue=R-B;{let He;for(;Te&&typeof(He=M.getKey())=="number";){He+=P;const ke=M.getComponent(),Je=v(ke);if(He>ue||He===ue&&(!Je||A===0&&be))break;if(Je){P--;const qe=ke.p;F.includes(qe),ke.d,l(ne[ke.d]),v(l(ne[ke.d])),(ke.r===void 0||Ne&&Ne.has(ke))&&(qe==null||!Se[qe]||A!==1&&F.includes(qe))||Le--}Te=M.nextSibling()}se=Te&&He===ue?M:null}const Re=ue-P;let Be=Ye(Re);const _t=Re-_e;let nt=null;{let He,ke;for(;je&&typeof(He=D.getKey())=="number";){ke=He-Ce;const Je=D.getComponent(),qe=o(Je);if(ke>_t)break;if(ke===_t){if(!qe){nt=D;break}{if(A===0&&be){nt=D;break}const ze=Be&&v(Be.getComponent());if(A===0&&ze)break}}if(qe){const ze=Je.d;F[ze],Je.i===void 0&&(p[ze]||F[ze]!=null&&A!==1)?(p[ze]||F[ze]!=null&&A===0)&&(Ce++,xe--):Ce++}je=D.nextSibling()}}const Tt=_t+Ce+Le+xe;a(Tt>=0,"trying to descend to a negative index"),N.descend(Tt),be&&(se=Be=nt=null,B++),ee(se,L,Be,nt,N,X)&&xe++,N.ascend()}else{let se;for(;Te&&(se=M.getKey(),typeof se!="string"||!(se>R||se===R));)Te=M.nextSibling();const be=Te&&se===R?M:null,ue=Ye(R);let Re;for(;je&&(Re=D.getKey(),typeof Re!="string"||!(Re>R||Re===R));)je=D.nextSibling();const Be=je&&Re===R?D:null;N.descend(R),ee(be,L,ue,Be,N,X),N.ascend()}return Ye.end(),et&&M.ascend(),$e&&D.ascend(),pe}(we,we.clone(),ye,ye.clone(),ae,null),b)return{ok:!1,conflict:b};ae.reset();const Ue=(ee,M,L)=>ee.traverse(M,(S,D)=>{S.d!=null&&L(S.d,ee,D)});(p.length||re.length)&&(Ue(ye,ae,(ee,M,L)=>{p[ee]&&!U[ee]&&L.write("r",!0),re[ee]&&L.mergeTree(re[ee].get())}),ae.reset());const De=[],We=[];if((ne.length||p.length)&&!b){const ee=s.readCursor(gt(ae.get()));if(Ue(ee,null,(M,L)=>{De[M]=L.clone()}),ne.forEach(M=>{M&&Ue(s.readCursor(M.get()),null,(L,S)=>{De[L]=S.clone()})}),function M(L,S,D,N,X,Z){const te=l(S);if(te&&v(te))if(te.p!=null){const P=te.p;De[P].getPath(),D=De[P],N=We[P]=s.writeCursor()}else te.r!==void 0&&(D=null);else o(l(D))&&(D=null);const pe=L.getComponent();if(pe){let P;if((P=pe.d)!=null){const B=ne[P];B&&(B.get(),N.mergeTree(B.get()),D=s.readCursor(B.get()))}}let he=0,le=0;const me=s.advancer(S,void 0,(P,B)=>{v(B)&&he--}),q=s.advancer(D,(P,B)=>o(B)?-(P-le)-1:P-le,(P,B)=>{o(B)&&le++});for(const P of L)if(typeof P=="number"){const B=me(P),_e=P+he,Ce=q(_e),Le=_e+le;N.descend(Le),M(L,B,Ce,N),N.ascend()}else N.descend(P),M(L,me(P),q(P),N),N.ascend();me.end(),q.end()}(ye,ee,ee.clone(),ae),ae.reset(),b)return{ok:!1,conflict:b};if(ae.get(),We.length){const M=We.map(S=>S?S.get():null),L=s.readCursor(gt(ae.get()));if(Ue(L,ae,(S,D,N)=>{const X=M[S];X&&(N.mergeTree(X),M[S]=null)}),M.find(S=>S)){const S=s.writeCursor(),D=s.writeCursor();let N=0,X=0;M.forEach(Z=>{Z!=null&&Ue(s.readCursor(Z),null,te=>{const pe=Ve[te];S.writeMove(C[pe].getPath(),$[pe].getPath(),N++);const he=oe[pe];he&&he.forEach(le=>{p[le]||A!==1&&F[le]!=null||D.writeMove(k[le].getPath(),g[le].getPath(),X++)})})}),b={type:d.ConflictType.BLACKHOLE,op1:S.get(),op2:D.get()}}}}return b?{ok:!1,conflict:b}:{ok:!0,result:ae.get()}}const Ut=r=>{const u=new Error("Transform detected write conflict");throw u.conflict=r,u.type=u.name="writeConflict",u};function zt(r,u,y){const A=pt(r,u,y);if(A.ok)return A.result;Ut(A.conflict)}const Ze=r=>{const u=s.writeCursor();return s.readCursor(r).traverse(u,(y,A)=>{(o(y)||Ie(y))&&A.write("r",!0)}),u.get()},Xt=(r,u)=>{const{type:y,op1:A,op2:b}=r;switch(y){case d.ConflictType.DROP_COLLISION:return u==="left"?[null,Ze(b)]:[Ze(A),null];case d.ConflictType.RM_UNEXPECTED_CONTENT:let C=!1;return s.readCursor(A).traverse(null,$=>{$.r!==void 0&&(C=!0)}),C?[null,Ze(b)]:[Ze(A),null];case d.ConflictType.BLACKHOLE:return[Ze(A),Ze(b)];default:throw Error("Unrecognised conflict: "+y)}};function Nt(r,u,y,A){let b=null;for(;;){const C=pt(u,y,A);if(C.ok)return ie(b,C.result);{const{conflict:$}=C;r($)||Ut($);const[k,g]=Xt($,A);u=ie(K(u),k),y=ie(K(y),g),b=ie(b,g)}}}})(Ot),function(n){var e=Ae&&Ae.__createBinding||(Object.create?function(d,a,l,E){E===void 0&&(E=l),Object.defineProperty(d,E,{enumerable:!0,get:function(){return a[l]}})}:function(d,a,l,E){E===void 0&&(E=l),d[E]=a[l]}),t=Ae&&Ae.__exportStar||function(d,a){for(var l in d)l!=="default"&&!a.hasOwnProperty(l)&&e(a,d,l)};Object.defineProperty(n,"__esModule",{value:!0}),t(Ot,n);var i=at;Object.defineProperty(n,"ReadCursor",{enumerable:!0,get:function(){return i.ReadCursor}}),Object.defineProperty(n,"WriteCursor",{enumerable:!0,get:function(){return i.WriteCursor}});var s=lt;Object.defineProperty(n,"ConflictType",{enumerable:!0,get:function(){return s.ConflictType}})}(V);class wt{constructor(){x(this,"drawingManagerData",{});x(this,"_oldDrawingManagerData",{});x(this,"_focusDrawings",[]);x(this,"_remove$",new ge.Subject);x(this,"remove$",this._remove$.asObservable());x(this,"_add$",new ge.Subject);x(this,"add$",this._add$.asObservable());x(this,"_update$",new ge.Subject);x(this,"update$",this._update$.asObservable());x(this,"_order$",new ge.Subject);x(this,"order$",this._order$.asObservable());x(this,"_group$",new ge.Subject);x(this,"group$",this._group$.asObservable());x(this,"_ungroup$",new ge.Subject);x(this,"ungroup$",this._ungroup$.asObservable());x(this,"_refreshTransform$",new ge.Subject);x(this,"refreshTransform$",this._refreshTransform$.asObservable());x(this,"_visible$",new ge.Subject);x(this,"visible$",this._visible$.asObservable());x(this,"_focus$",new ge.Subject);x(this,"focus$",this._focus$.asObservable());x(this,"_featurePluginUpdate$",new ge.Subject);x(this,"featurePluginUpdate$",this._featurePluginUpdate$.asObservable());x(this,"_featurePluginAdd$",new ge.Subject);x(this,"featurePluginAdd$",this._featurePluginAdd$.asObservable());x(this,"_featurePluginRemove$",new ge.Subject);x(this,"featurePluginRemove$",this._featurePluginRemove$.asObservable());x(this,"_featurePluginOrderUpdate$",new ge.Subject);x(this,"featurePluginOrderUpdate$",this._featurePluginOrderUpdate$.asObservable());x(this,"_featurePluginGroupUpdate$",new ge.Subject);x(this,"featurePluginGroupUpdate$",this._featurePluginGroupUpdate$.asObservable());x(this,"_featurePluginUngroupUpdate$",new ge.Subject);x(this,"featurePluginUngroupUpdate$",this._featurePluginUngroupUpdate$.asObservable());x(this,"_visible",!0);x(this,"_editable",!0)}dispose(){this._remove$.complete(),this._add$.complete(),this._update$.complete(),this._order$.complete(),this._focus$.complete(),this._featurePluginUpdate$.complete(),this._featurePluginAdd$.complete(),this._featurePluginRemove$.complete(),this._featurePluginOrderUpdate$.complete(),this.drawingManagerData={},this._oldDrawingManagerData={}}visibleNotification(e){this._visible$.next(e)}refreshTransform(e){e.forEach(t=>{const i=this._getCurrentBySearch(t);i!=null&&(i.transform=t.transform,i.transforms=t.transforms,i.isMultiTransform=t.isMultiTransform)}),this.refreshTransformNotification(e)}getDrawingDataForUnit(e){return this.drawingManagerData[e]||{}}removeDrawingDataForUnit(e){const t=this.drawingManagerData[e];if(t==null)return;delete this.drawingManagerData[e];const i=[];Object.keys(t).forEach(s=>{const d=t[s];(d==null?void 0:d.data)!=null&&Object.keys(d.data).forEach(a=>{i.push({unitId:e,subUnitId:s,drawingId:a})})}),i.length>0&&this.removeNotification(i)}registerDrawingData(e,t){this.drawingManagerData[e]=t}initializeNotification(e){const t=[],i=this.drawingManagerData[e];i!=null&&(Object.keys(i).forEach(s=>{this._establishDrawingMap(e,s);const d=i[s];Object.keys(d.data).forEach(a=>{const l=d.data[a];l.unitId=e,l.subUnitId=s,t.push(l)})}),t.length>0&&this.addNotification(t))}getDrawingData(e,t){return this._getDrawingData(e,t)}setDrawingData(e,t,i){this.drawingManagerData[e][t].data=i}getBatchAddOp(e){const t=[],i=[],s=[];e.forEach(G=>{const{op:v,invertOp:o}=this._addByParam(G);t.push({unitId:G.unitId,subUnitId:G.subUnitId,drawingId:G.drawingId}),i.push(v),s.push(o)});const d=i.reduce(V.type.compose,null),a=s.reduce(V.type.compose,null),{unitId:l,subUnitId:E}=e[0];return{undo:a,redo:d,unitId:l,subUnitId:E,objects:t}}getBatchRemoveOp(e){const t=[],i=[];e.forEach(E=>{const{op:G,invertOp:v}=this._removeByParam(E);t.unshift(G),i.push(v)});const s=t.reduce(V.type.compose,null),d=i.reduce(V.type.compose,null),{unitId:a,subUnitId:l}=e[0];return{undo:d,redo:s,unitId:a,subUnitId:l,objects:e}}getBatchUpdateOp(e){const t=[],i=[],s=[];e.forEach(G=>{const{op:v,invertOp:o}=this._updateByParam(G);t.push({unitId:G.unitId,subUnitId:G.subUnitId,drawingId:G.drawingId}),i.push(v),s.push(o)});const d=i.reduce(V.type.compose,null),a=s.reduce(V.type.compose,null),{unitId:l,subUnitId:E}=e[0];return{undo:a,redo:d,unitId:l,subUnitId:E,objects:t}}removeNotification(e){this._remove$.next(e)}addNotification(e){this._add$.next(e)}updateNotification(e){this._update$.next(e)}orderNotification(e){this._order$.next(e)}groupUpdateNotification(e){this._group$.next(e)}ungroupUpdateNotification(e){this._ungroup$.next(e)}refreshTransformNotification(e){this._refreshTransform$.next(e)}getGroupDrawingOp(e){const t=[],{unitId:i,subUnitId:s}=e[0].parent;e.forEach(l=>{t.push(this._getGroupDrawingOp(l))});const d=t.reduce(V.type.compose,null);return{undo:V.type.invertWithDoc(d,this.drawingManagerData),redo:d,unitId:i,subUnitId:s,objects:e}}getUngroupDrawingOp(e){const t=[],{unitId:i,subUnitId:s}=e[0].parent;e.forEach(l=>{t.push(this._getUngroupDrawingOp(l))});const d=t.reduce(V.type.compose,null);return{undo:V.type.invertWithDoc(d,this.drawingManagerData),redo:d,unitId:i,subUnitId:s,objects:e}}getDrawingsByGroup(e){const{unitId:t,subUnitId:i,drawingId:s}=e;if(this.getDrawingByParam({unitId:t,subUnitId:i,drawingId:s})==null)return[];const a=this._getDrawingData(t,i),l=[];return Object.keys(a).forEach(E=>{const G=a[E];G.groupId===s&&l.push(G)}),l}_getGroupDrawingOp(e){const{parent:t,children:i}=e,{unitId:s,subUnitId:d,drawingId:a}=t,l=[];l.push(V.insertOp([s,d,"data",a],t));let E=Number.NEGATIVE_INFINITY;return i.forEach(G=>{const{unitId:v,subUnitId:o,drawingId:c}=G,h=this._hasDrawingOrder({unitId:v,subUnitId:o,drawingId:c});E=Math.max(E,h),l.push(...this._getUpdateParamCompareOp(G,this.getDrawingByParam({unitId:v,subUnitId:o,drawingId:c})))}),E===Number.NEGATIVE_INFINITY&&(E=this._getDrawingOrder(s,d).length),l.push(V.insertOp([s,d,"order",E],a)),l.reduce(V.type.compose,null)}_getUngroupDrawingOp(e){const{parent:t,children:i}=e,{unitId:s,subUnitId:d,drawingId:a}=t,l=[];return i.forEach(E=>{const{unitId:G,subUnitId:v,drawingId:o}=E;l.push(...this._getUpdateParamCompareOp(E,this.getDrawingByParam({unitId:G,subUnitId:v,drawingId:o})))}),l.push(V.removeOp([s,d,"data",a],!0)),l.push(V.removeOp([s,d,"order",this._getDrawingOrder(s,d).indexOf(a)],!0)),l.reduce(V.type.compose,null)}applyJson1(e,t,i){this._establishDrawingMap(e,t),this._oldDrawingManagerData={...this.drawingManagerData},this.drawingManagerData=V.type.apply(this.drawingManagerData,i)}featurePluginUpdateNotification(e){this._featurePluginUpdate$.next(e)}featurePluginOrderUpdateNotification(e){this._featurePluginOrderUpdate$.next(e)}featurePluginAddNotification(e){this._featurePluginAdd$.next(e)}featurePluginRemoveNotification(e){this._featurePluginRemove$.next(e)}featurePluginGroupUpdateNotification(e){this._featurePluginGroupUpdate$.next(e)}featurePluginUngroupUpdateNotification(e){this._featurePluginUngroupUpdate$.next(e)}getDrawingByParam(e){return this._getCurrentBySearch(e)}getOldDrawingByParam(e){return this._getOldBySearch(e)}getDrawingOKey(e){const[t,i,s]=e.split("#-#");return this._getCurrentBySearch({unitId:t,subUnitId:i,drawingId:s})}focusDrawing(e){if(e==null){this._focusDrawings=[],this._focus$.next([]);return}const t=[];e.forEach(i=>{var E;const{unitId:s,subUnitId:d,drawingId:a}=i,l=(E=this._getDrawingData(s,d))==null?void 0:E[a];l!=null&&t.push(l)}),t.length>0&&(this._focusDrawings=t,this._focus$.next(t))}getFocusDrawings(){const e=[];return this._focusDrawings.forEach(t=>{var l;const{unitId:i,subUnitId:s,drawingId:d}=t,a=(l=this._getDrawingData(i,s))==null?void 0:l[d];a!=null&&e.push(a)}),e}getDrawingOrder(e,t){return this._getDrawingOrder(e,t)}setDrawingOrder(e,t,i){this.drawingManagerData[e][t].order=i}orderUpdateNotification(e){this._order$.next(e)}getForwardDrawingsOp(e){const{unitId:t,subUnitId:i,drawingIds:s}=e,d=[],a=this.getDrawingOrder(t,i),l=[...s];s.forEach(v=>{const o=this._hasDrawingOrder({unitId:t,subUnitId:i,drawingId:v});if(o===-1||o===a.length-1)return;const c=V.moveOp([t,i,"order",o],[t,i,"order",o+1]);d.push(c),l.includes(a[o+1])||l.push(a[o+1])});const E=d.reduce(V.type.compose,null);return{undo:V.type.invertWithDoc(E,this.drawingManagerData),redo:E,unitId:t,subUnitId:i,objects:{...e,drawingIds:l}}}getBackwardDrawingOp(e){const{unitId:t,subUnitId:i,drawingIds:s}=e,d=[],a=this.getDrawingOrder(t,i),l=[...s];s.forEach(v=>{const o=this._hasDrawingOrder({unitId:t,subUnitId:i,drawingId:v});if(o===-1||o===0)return;const c=V.moveOp([t,i,"order",o],[t,i,"order",o-1]);d.push(c),l.includes(a[o-1])||l.push(a[o-1])});const E=d.reduce(V.type.compose,null);return{undo:V.type.invertWithDoc(E,this.drawingManagerData),redo:E,unitId:t,subUnitId:i,objects:{...e,drawingIds:l}}}getFrontDrawingsOp(e){const{unitId:t,subUnitId:i,drawingIds:s}=e,d=this._getOrderFromSearchParams(t,i,s),a=[...s],l=this.getDrawingOrder(t,i),E=[];d.forEach(o=>{const{drawingId:c}=o,h=this._getDrawingCount(t,i)-1,T=V.moveOp([t,i,"order",this._getDrawingOrder(t,i).indexOf(c)],[t,i,"order",h]);E.push(T),a.includes(l[h])||a.push(l[h])});const G=E.reduce(V.type.compose,null);return{undo:V.type.invertWithDoc(G,this.drawingManagerData),redo:G,unitId:t,subUnitId:i,objects:{...e,drawingIds:a}}}getBackDrawingsOp(e){const{unitId:t,subUnitId:i,drawingIds:s}=e,d=this._getOrderFromSearchParams(t,i,s,!0),a=[...s],l=this.getDrawingOrder(t,i),E=[];d.forEach(o=>{const{drawingId:c}=o,h=V.moveOp([t,i,"order",this._getDrawingOrder(t,i).indexOf(c)],[t,i,"order",0]);E.push(h),a.includes(l[0])||a.push(l[0])});const G=E.reduce(V.type.compose,null);return{undo:V.type.invertWithDoc(G,this.drawingManagerData),redo:G,unitId:t,subUnitId:i,objects:{...e,drawingIds:a}}}_getDrawingCount(e,t){return this.getDrawingOrder(e,t).length||0}_getOrderFromSearchParams(e,t,i,s=!1){return i.map(d=>{const a=this._hasDrawingOrder({unitId:e,subUnitId:t,drawingId:d});return{drawingId:d,zIndex:a}}).sort(s===!1?de.sortRules:de.sortRulesByDesc)}_hasDrawingOrder(e){if(e==null)return-1;const{unitId:t,subUnitId:i,drawingId:s}=e;return this._establishDrawingMap(t,i),this._getDrawingOrder(t,i).indexOf(s)}_getCurrentBySearch(e){var d,a,l;if(e==null)return;const{unitId:t,subUnitId:i,drawingId:s}=e;return(l=(a=(d=this.drawingManagerData[t])==null?void 0:d[i])==null?void 0:a.data)==null?void 0:l[s]}_getOldBySearch(e){var d,a,l;if(e==null)return;const{unitId:t,subUnitId:i,drawingId:s}=e;return(l=(a=(d=this._oldDrawingManagerData[t])==null?void 0:d[i])==null?void 0:a.data)==null?void 0:l[s]}_establishDrawingMap(e,t,i){var s;return this.drawingManagerData[e]||(this.drawingManagerData[e]={}),this.drawingManagerData[e][t]||(this.drawingManagerData[e][t]={data:{},order:[]}),i==null?null:(s=this.drawingManagerData[e][t].data)==null?void 0:s[i]}_addByParam(e){const{unitId:t,subUnitId:i,drawingId:s}=e;this._establishDrawingMap(t,i,s);const d=V.insertOp([t,i,"data",s],e),a=V.insertOp([t,i,"order",this._getDrawingOrder(t,i).length],s),l=[d,a].reduce(V.type.compose,null),E=V.type.invertWithDoc(l,this.drawingManagerData);return{op:l,invertOp:E}}_removeByParam(e){if(e==null)return{op:[],invertOp:[]};const{unitId:t,subUnitId:i,drawingId:s}=e;if(this._establishDrawingMap(t,i,s)==null)return{op:[],invertOp:[]};const a=V.removeOp([t,i,"data",s],!0),l=V.removeOp([t,i,"order",this._getDrawingOrder(t,i).indexOf(s)],!0),E=[a,l].reduce(V.type.compose,null),G=V.type.invertWithDoc(E,this.drawingManagerData);return{op:E,invertOp:G}}_updateByParam(e){const{unitId:t,subUnitId:i,drawingId:s}=e,d=this._establishDrawingMap(t,i,s);if(d==null)return{op:[],invertOp:[]};const l=this._getUpdateParamCompareOp(e,d).reduce(V.type.compose,null),E=V.type.invertWithDoc(l,this.drawingManagerData);return{op:l,invertOp:E}}_getUpdateParamCompareOp(e,t){const{unitId:i,subUnitId:s,drawingId:d}=e,a=[];return Object.keys(e).forEach(l=>{const E=e[l],G=t[l];G!==E&&a.push(V.replaceOp([i,s,"data",d,l],G,E))}),a}_getDrawingData(e,t){var i,s;return((s=(i=this.drawingManagerData[e])==null?void 0:i[t])==null?void 0:s.data)||{}}_getDrawingOrder(e,t){var i,s;return((s=(i=this.drawingManagerData[e])==null?void 0:i[t])==null?void 0:s.order)||[]}getDrawingVisible(){return this._visible}getDrawingEditable(){return this._editable}setDrawingVisible(e){this._visible=e}setDrawingEditable(e){this._editable=e}}class Ct extends wt{}function Gt({unitId:n,subUnitId:e,drawingId:t},i){return typeof i=="number"?`${n}#-#${e}#-#${t}#-#${i}`:`${n}#-#${e}#-#${t}`}const Wt=async n=>new Promise((e,t)=>{const i=new Image;i.src=n,i.onload=()=>{e({width:i.width,height:i.height,image:i})},i.onerror=s=>{t(s)}});var Qe=(n=>(n.URL="URL",n.UUID="UUID",n.BASE64="BASE64",n))(Qe||{}),Xe=(n=>(n.SUCCUSS="0",n.ERROR_EXCEED_SIZE="1",n.ERROR_IMAGE_TYPE="2",n.ERROR_UPLOAD_COUNT_LIMIT="3",n.ERROR_IMAGE="4",n))(Xe||{});const Et=de.createIdentifier("core.image-io.service");class At{constructor(){x(this,"_waitCount",0);x(this,"_change$",new ge.Subject);x(this,"change$",this._change$);x(this,"_imageSourceCache",new Map)}setWaitCount(e){this._waitCount=e,this._change$.next(e)}getImageSourceCache(e,t){if(t===Qe.BASE64){const i=new Image;return i.src=e,i}return this._imageSourceCache.get(e)}addImageSourceCache(e,t,i){t===Qe.BASE64||i==null||this._imageSourceCache.set(e,i)}async getImage(e){return Promise.resolve(e)}async saveImage(e){return new Promise((t,i)=>{if(!vt.includes(e.type)){i(new Error(Xe.ERROR_IMAGE_TYPE)),this._decreaseWaiting();return}if(e.size>5242880){i(new Error(Xe.ERROR_EXCEED_SIZE)),this._decreaseWaiting();return}const s=new FileReader;s.readAsDataURL(e),s.onload=d=>{var E;const a=(E=d.target)==null?void 0:E.result;if(a==null){i(new Error(Xe.ERROR_IMAGE)),this._decreaseWaiting();return}const l=de.Tools.generateRandomId(6);t({imageId:l,imageSourceType:Qe.BASE64,source:a,base64Cache:a,status:Xe.SUCCUSS}),this._decreaseWaiting()}})}_decreaseWaiting(){this._waitCount-=1,this._change$.next(this._waitCount)}}const Lt="__default_document_sub_component_id20231101__";var Dt=(n=>(n[n.forward=0]="forward",n[n.backward=1]="backward",n[n.front=2]="front",n[n.back=3]="back",n))(Dt||{}),Pt=(n=>(n[n.UNRECOGNIZED=-1]="UNRECOGNIZED",n[n.DRAWING_IMAGE=0]="DRAWING_IMAGE",n[n.DRAWING_SHAPE=1]="DRAWING_SHAPE",n[n.DRAWING_CHART=2]="DRAWING_CHART",n[n.DRAWING_TABLE=3]="DRAWING_TABLE",n[n.DRAWING_SMART_ART=4]="DRAWING_SMART_ART",n[n.DRAWING_VIDEO=5]="DRAWING_VIDEO",n[n.DRAWING_GROUP=6]="DRAWING_GROUP",n[n.DRAWING_UNIT=7]="DRAWING_UNIT",n[n.DRAWING_DOM=8]="DRAWING_DOM",n))(Pt||{});const Mt=de.createIdentifier("univer.drawing-manager.service"),Bt="drawing.config",Ht={};var Kt=Object.defineProperty,Ft=Object.getOwnPropertyDescriptor,Vt=(n,e,t,i)=>{for(var s=i>1?void 0:i?Ft(e,t):e,d=n.length-1,a;d>=0;d--)(a=n[d])&&(s=(i?a(e,t,s):a(s))||s);return i&&s&&Kt(e,t,s),s},St=(n,e)=>(t,i)=>e(t,i,n);const xt="UNIVER_DRAWING_PLUGIN";Y.UniverDrawingPlugin=(ht=class extends de.Plugin{constructor(e=Ht,t,i){super(),this._config=e,this._injector=t,this._configService=i;const{...s}=this._config;this._configService.setConfig(Bt,s)}onStarting(){this._initDependencies()}_initDependencies(){var i;const e=[[Et,{useClass:At}],[Mt,{useClass:Ct}]];de.mergeOverrideWithDependencies(e,(i=this._config)==null?void 0:i.override).forEach(s=>this._injector.add(s))}},x(ht,"pluginName",xt),ht),Y.UniverDrawingPlugin=Vt([St(1,de.Inject(de.Injector)),St(2,de.IConfigService)],Y.UniverDrawingPlugin),Y.ArrangeTypeEnum=Dt,Y.DEFAULT_DOCUMENT_SUB_COMPONENT_ID=Lt,Y.DRAWING_IMAGE_ALLOW_IMAGE_LIST=vt,Y.DRAWING_IMAGE_ALLOW_SIZE=5242880,Y.DRAWING_IMAGE_COUNT_LIMIT=10,Y.DRAWING_IMAGE_HEIGHT_LIMIT=500,Y.DRAWING_IMAGE_WIDTH_LIMIT=500,Y.DrawingManagerService=Ct,Y.DrawingTypeEnum=Pt,Y.IDrawingManagerService=Mt,Y.IImageIoService=Et,Y.ImageIoService=At,Y.ImageSourceType=Qe,Y.ImageUploadStatusType=Xe,Y.UnitDrawingService=wt,Y.getDrawingShapeKeyByDrawingSearch=Gt,Y.getImageSize=Wt,Object.defineProperty(Y,Symbol.toStringTag,{value:"Module"})});
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"})});
3
3
 
4
4
 
5
5
  // @univerjs/drawing-ui/index
6
- (function(P,S){typeof exports=="object"&&typeof module<"u"?S(exports,require("@univerjs/drawing"),require("@univerjs/engine-render"),require("@univerjs/core"),require("react"),require("@univerjs/design"),require("@univerjs/ui"),require("rxjs")):typeof define=="function"&&define.amd?define(["exports","@univerjs/drawing","@univerjs/engine-render","@univerjs/core","react","@univerjs/design","@univerjs/ui","rxjs"],S):(P=typeof globalThis<"u"?globalThis:P||self,S(P.UniverDrawingUi={},P.UniverDrawing,P.UniverEngineRender,P.UniverCore,P.React,P.UniverDesign,P.UniverUi,P.rxjs))})(this,function(P,S,b,p,_,k,Pe,Re){"use strict";var et=Object.defineProperty;var nt=(P,S,b)=>S in P?et(P,S,{enumerable:!0,configurable:!0,writable:!0,value:b}):P[S]=b;var q=(P,S,b)=>nt(P,typeof S!="symbol"?S+"":S,b);var Me;function $e(a,t,n,e){const r=e.getDrawingByParam(a);if(r==null)return;const s=S.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:l}=r;l&&o.transformByState({left:l.left,top:l.top,angle:l.angle})}function Oe(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===p.UniverInstanceType.UNIVER_SHEET?r=(s=n.getActiveSheet())==null?void 0:s.getSheetId():(n.type===p.UniverInstanceType.UNIVER_DOC||n.type===p.UniverInstanceType.UNIVER_SLIDE)&&(r=e),{unitId:e,subUnitId:r,current:n}}var qe=Object.defineProperty,en=Object.getOwnPropertyDescriptor,nn=(a,t,n,e)=>{for(var r=e>1?void 0:e?en(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&&qe(t,n,r),r},xe=(a,t)=>(n,e)=>t(n,e,a);P.DrawingRenderService=class{constructor(t,n){this._drawingManagerService=t,this._imageIoService=n}async renderImages(t,n){const{transform:e,drawingType:r,source:s,imageSourceType:i,srcRect:o,prstGeom:l,groupId:g,unitId:u,subUnitId:d,drawingId:h,isMultiTransform:f,transforms:I}=t;if(r!==S.DrawingTypeEnum.DRAWING_IMAGE||!this._drawingManagerService.getDrawingVisible()||e==null)return;const w=f&&I?I:[e],C=[];for(const j of w){const{left:y,top:E,width:M,height:U,angle:D,flipX:O,flipY:R,skewX:T,skewY:A}=j,V=w.indexOf(j),L=S.getDrawingShapeKeyByDrawingSearch({unitId:u,subUnitId:d,drawingId:h},f?V:void 0),re=n.getObject(L);if(re!=null){re.transformByState({left:y,top:E,width:M,height:U,angle:D,flipX:O,flipY:R,skewX:T,skewY:A});continue}const K=this._drawingManagerService.getDrawingOrder(u,d),ce=K.indexOf(h),ae={...j,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===S.ImageSourceType.UUID)try{ae.url=await this._imageIoService.getImage(s)}catch(De){console.error(De);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&&$e({drawingId:g,unitId:u,subUnitId:d},Q,n,this._drawingManagerService),l!=null&&Q.setPrstGeom(l),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 S.DrawingTypeEnum.DRAWING_IMAGE:return this.renderImages(e,n)}}},P.DrawingRenderService=nn([xe(0,S.IDrawingManagerService),xe(1,S.IImageIoService)],P.DrawingRenderService);function me(a,t){const n=[];return a.forEach(e=>{const{oKey:r,left:s,top:i,height:o,width:l,angle:g}=e,u=t.getDrawingOKey(r);if(u==null)return n.push(null),!0;const{unitId:d,subUnitId:h,drawingId:f,drawingType:I}=u,w={unitId:d,subUnitId:h,drawingId:f,drawingType:I,transform:{left:s,top:i,height:o,width:l,angle:g}};I===S.DrawingTypeEnum.DRAWING_IMAGE&&(w.srcRect=e.srcRect),n.push(w)}),n}var Ne={exports:{}},pe={};/**
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={};/**
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 tn=_,rn=Symbol.for("react.element"),an=Symbol.for("react.fragment"),sn=Object.prototype.hasOwnProperty,on=tn.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,cn={key:!0,ref:!0,__self:!0,__source:!0};function Ee(a,t,n){var e,r={},s=null,i=null;n!==void 0&&(s=""+n),t.key!==void 0&&(s=""+t.key),t.ref!==void 0&&(i=t.ref);for(e in t)sn.call(t,e)&&!cn.hasOwnProperty(e)&&(r[e]=t[e]);if(a&&a.defaultProps)for(e in t=a.defaultProps,t)r[e]===void 0&&(r[e]=t[e]);return{$$typeof:rn,type:a,key:s,ref:i,props:r,_owner:on.current}}pe.Fragment=an,pe.jsx=Ee,pe.jsxs=Ee,Ne.exports=pe;var c=Ne.exports;function Te(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=Te(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=Te(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 Ce={id:"sheet.operation.set-image-align",type:p.CommandType.OPERATION,handler:(a,t)=>!0},m={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"},ln=a=>{const t=p.useDependency(p.ICommandService),n=p.useDependency(p.LocaleService),{alignShow:e}=a,[r,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(Ce.id,{alignType:g})}const l=g=>g?"block":"none";return c.jsxs("div",{className:N(m.imageCommonPanelGrid,m.imageCommonPanelBorder),style:{display:l(e)},children:[c.jsx("div",{className:m.imageCommonPanelRow,children:c.jsx("div",{className:N(m.imageCommonPanelColumn,m.imageCommonPanelTitle),children:c.jsx("div",{children:n.t("image-panel.align.title")})})}),c.jsx("div",{className:m.imageCommonPanelRow,children:c.jsx("div",{className:N(m.imageCommonPanelColumn),children:c.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)},mn=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=_.forwardRef(function(a,t){var n=a.icon,e=a.id,r=a.className,s=a.extend,i=mn(a,["icon","id","className","extend"]),o="univerjs-icon univerjs-icon-".concat(e," ").concat(r||"").trim(),l=_.useRef("_".concat(dn()));return Be(n,"".concat(e),{defIds:n.defIds,idSuffix:l.current},F({ref:t,className:o},i),s)});function Be(a,t,n,e,r){return _.createElement(a.tag,F(F({key:t},gn(a,n,r)),e),(un(a,n).children||[]).map(function(s,i){return Be(s,"".concat(t,"-").concat(a.tag,"-").concat(i),n,void 0,r)}))}function gn(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 un(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 dn(){return Math.random().toString(36).substring(2,8)}X.displayName="UniverIcon";var hn={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"}}]},Ue=_.forwardRef(function(a,t){return _.createElement(X,Object.assign({},a,{id:"autofill",ref:t,icon:hn}))});Ue.displayName="Autofill";var fn={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"}}]},Ae=_.forwardRef(function(a,t){return _.createElement(X,Object.assign({},a,{id:"bottom-single",ref:t,icon:fn}))});Ae.displayName="BottomSingle";var pn={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"}}]},Le=_.forwardRef(function(a,t){return _.createElement(X,Object.assign({},a,{id:"create-copy-single",ref:t,icon:pn}))});Le.displayName="CreateCopySingle";var Cn={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"}}]},He=_.forwardRef(function(a,t){return _.createElement(X,Object.assign({},a,{id:"group-single",ref:t,icon:Cn}))});He.displayName="GroupSingle";var vn={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"}}]},Ge=_.forwardRef(function(a,t){return _.createElement(X,Object.assign({},a,{id:"more-down-single",ref:t,icon:vn}))});Ge.displayName="MoreDownSingle";var wn={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"}}]},Ve=_.forwardRef(function(a,t){return _.createElement(X,Object.assign({},a,{id:"move-down-single",ref:t,icon:wn}))});Ve.displayName="MoveDownSingle";var Sn={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"}}]},We=_.forwardRef(function(a,t){return _.createElement(X,Object.assign({},a,{id:"move-up-single",ref:t,icon:Sn}))});We.displayName="MoveUpSingle";var _n={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"}}]},ke=_.forwardRef(function(a,t){return _.createElement(X,Object.assign({},a,{id:"topmost-single",ref:t,icon:_n}))});ke.displayName="TopmostSingle";var In={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"}}]},ze=_.forwardRef(function(a,t){return _.createElement(X,Object.assign({},a,{id:"ungroup-single",ref:t,icon:In}))});ze.displayName="UngroupSingle";const bn=a=>{const{arrangeShow:t,drawings:n}=a,e=p.useDependency(p.LocaleService),r=p.useDependency(S.IDrawingManagerService),s=g=>g?"block":"none",[i,o]=_.useState(n);_.useEffect(()=>{const g=r.focus$.subscribe(u=>{o(u)});return()=>{g.unsubscribe()}},[]);const l=g=>{const u=i[0].unitId,d=i[0].subUnitId,h=i.map(f=>f.drawingId);r.featurePluginOrderUpdateNotification({unitId:u,subUnitId:d,drawingIds:h,arrangeType:g})};return c.jsxs("div",{className:m.imageCommonPanelGrid,style:{display:s(t)},children:[c.jsx("div",{className:m.imageCommonPanelRow,children:c.jsx("div",{className:N(m.imageCommonPanelColumn,m.imageCommonPanelTitle),children:c.jsx("div",{children:e.t("image-panel.arrange.title")})})}),c.jsxs("div",{className:m.imageCommonPanelRow,children:[c.jsx("div",{className:N(m.imageCommonPanelColumn,m.imageCommonPanelSpan2),children:c.jsx(k.Button,{size:"small",onClick:()=>{l(S.ArrangeTypeEnum.forward)},children:c.jsxs("span",{className:m.imageCommonPanelInline,children:[c.jsx(We,{}),e.t("image-panel.arrange.forward")]})})}),c.jsx("div",{className:N(m.imageCommonPanelColumn,m.imageCommonPanelSpan2),children:c.jsx(k.Button,{size:"small",onClick:()=>{l(S.ArrangeTypeEnum.backward)},children:c.jsxs("span",{className:m.imageCommonPanelInline,children:[c.jsx(Ve,{}),e.t("image-panel.arrange.backward")]})})})]}),c.jsxs("div",{className:m.imageCommonPanelRow,children:[c.jsx("div",{className:N(m.imageCommonPanelColumn,m.imageCommonPanelSpan2),children:c.jsx(k.Button,{size:"small",onClick:()=>{l(S.ArrangeTypeEnum.front)},children:c.jsxs("span",{className:m.imageCommonPanelInline,children:[c.jsx(ke,{}),e.t("image-panel.arrange.front")]})})}),c.jsx("div",{className:N(m.imageCommonPanelColumn,m.imageCommonPanelSpan2),children:c.jsx(k.Button,{size:"small",onClick:()=>{l(S.ArrangeTypeEnum.back)},children:c.jsxs("span",{className:m.imageCommonPanelInline,children:[c.jsx(Ae,{}),e.t("image-panel.arrange.back")]})})})]})]})},yn=a=>{const t=p.useDependency(p.LocaleService),n=p.useDependency(b.IRenderManagerService),e=p.useDependency(S.IDrawingManagerService),{hasGroup:r,drawings:s}=a,[i,o]=_.useState(!1),[l,g]=_.useState(!0),[u,d]=_.useState(!0),h=C=>C?"block":"none",f=()=>{const C=e.getFocusDrawings(),{unitId:j,subUnitId:y}=C[0],E=p.Tools.generateRandomId(10),M=b.getGroupState(0,0,C.map(O=>O.transform||{})),U={unitId:j,subUnitId:y,drawingId:E,drawingType:S.DrawingTypeEnum.DRAWING_GROUP,transform:M},D=C.map(O=>{const R=O.transform||{left:0,top:0},{unitId:T,subUnitId:A,drawingId:V}=O;return{unitId:T,subUnitId:A,drawingId:V,transform:{...R,left:R.left-M.left,top:R.top-M.top},groupId:E}});e.featurePluginGroupUpdateNotification([{parent:U,children:D}])},I=C=>{if(C.drawingType!==S.DrawingTypeEnum.DRAWING_GROUP)return;const{unitId:j,subUnitId:y,drawingId:E,transform:M={width:0,height:0}}=C;if(M==null)return;const U=e.getDrawingsByGroup({unitId:j,subUnitId:y,drawingId:E});if(U.length===0)return;const D=U.map(O=>{const{transform:R}=O,{unitId:T,subUnitId:A,drawingId:V}=O,L=b.transformObjectOutOfGroup(R||{},M,M.width||0,M.height||0);return{unitId:T,subUnitId:A,drawingId:V,transform:{...R,...L},groupId:void 0}});return{parent:C,children:D}},w=()=>{const j=e.getFocusDrawings().map(y=>I(y)).filter(y=>y!=null);j.length!==0&&e.featurePluginUngroupUpdateNotification(j)};return _.useEffect(()=>{const C=s[0];if(C==null)return;const{unitId:j}=C,y=n.getRenderById(j),E=y==null?void 0:y.scene;if(E==null)return;const M=E.getTransformerByCreate(),U=M.clearControl$.subscribe(O=>{O===!0&&o(!1)}),D=M.changeStart$.subscribe(O=>{const{objects:R}=O,T=me(R,e),A=T.filter(K=>(K==null?void 0:K.drawingType)===S.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()=>{D.unsubscribe(),U.unsubscribe()}},[]),c.jsxs("div",{className:N(m.imageCommonPanelGrid,m.imageCommonPanelBorder),style:{display:h(r===!0?i:!1)},children:[c.jsx("div",{className:m.imageCommonPanelRow,children:c.jsx("div",{className:N(m.imageCommonPanelColumn,m.imageCommonPanelTitle),children:c.jsx("div",{children:t.t("image-panel.group.title")})})}),c.jsxs("div",{className:m.imageCommonPanelRow,children:[c.jsx("div",{className:N(m.imageCommonPanelColumn,m.imageCommonPanelSpan2,m.imageCommonPanelColumnCenter),children:c.jsx(k.Button,{size:"small",onClick:()=>{f()},style:{display:h(l)},children:c.jsxs("span",{className:m.imageCommonPanelInline,children:[c.jsx(He,{}),t.t("image-panel.group.group")]})})}),c.jsx("div",{className:N(m.imageCommonPanelColumn,m.imageCommonPanelSpan2,m.imageCommonPanelColumnCenter),children:c.jsx(k.Button,{size:"small",onClick:()=>{w()},style:{display:h(u)},children:c.jsxs("span",{className:m.imageCommonPanelInline,children:[c.jsx(ze,{}),t.t("image-panel.group.unGroup")]})})})]})]})},ne=20,Pn=20,jn=[-3600,3600],ve=300,Mn=a=>{var Qe;const t=p.useDependency(p.LocaleService),n=p.useDependency(S.IDrawingManagerService),e=p.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:l,subUnitId:g,drawingId:u,drawingType:d}=i,h=e.getRenderById(l),f=h==null?void 0:h.scene;if(f==null)return;const I=(Qe=f.getEngine())==null?void 0:Qe.activeScene;if(I==null)return;const w=f.getTransformerByCreate(),{width:C=0,height:j=0,left:y=0,top:E=0,angle:M=0}=o,[U,D]=_.useState(C),[O,R]=_.useState(j),[T,A]=_.useState(y),[V,L]=_.useState(E),[re,K]=_.useState(M),[ce,ae]=_.useState(w.keepRatio),ie=(v,B,W,z)=>{const{width:G,height:$}=I,{ancestorLeft:Y,ancestorTop:Z}=f;let J=v,se=B,he=W,fe=z;return v+Y<0&&(J=-Y),B+Z<0&&(se=-Z),he=G-J-Y,he<ne&&(he=ne),fe=$-se-Z,fe<ne&&(fe=ne),v+he+Y>G&&(J=G-W-Y),B+fe+Z>$&&(se=$-z-Z),{limitLeft:J,limitTop:se,limitWidth:he,limitHeight:fe}},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&&D($),Y!=null&&R(Y),Z!=null&&A(Z),J!=null&&L(J),se!=null&&K(se)};_.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&&D(G),$!=null&&R($),Y!=null&&A(Y),Z!=null&&L(Z),J!=null&&K(J)})];return()=>{v.forEach(B=>B.unsubscribe())}},[]);const Q=p.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:l,subUnitId:g,drawingId:u,drawingType:d,transform:{width:v}};if(ce){let G=v/U*O;if(G=Math.max(G,Pn),G>W)return;R(G),z.transform.height=G}D(v),n.featurePluginUpdateNotification([z]),w.refreshControls().changeNotification()},ve),De=p.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:l,subUnitId:g,drawingId:u,drawingType:d,transform:{height:v}};if(ce){let G=v/O*U;if(G=Math.max(G,ne),G>W)return;D(G),z.transform.width=G}R(v),n.featurePluginUpdateNotification([z]),w.refreshControls().changeNotification()},ve),Xn=p.debounce(v=>{if(v==null)return;const{limitLeft:B}=ie(v,V,U,O);v=B;const W={unitId:l,subUnitId:g,drawingId:u,drawingType:d,transform:{left:v}};A(v),n.featurePluginUpdateNotification([W]),w.refreshControls().changeNotification()},ve),Jn=p.debounce(v=>{if(v==null)return;const{limitTop:B}=ie(T,v,U,O);v=B;const W={unitId:l,subUnitId:g,drawingId:u,drawingType:d,transform:{top:v}};L(v),n.featurePluginUpdateNotification([W]),w.refreshControls().changeNotification()},ve),Qn=v=>{if(v==null)return;const[B,W]=jn;v<B&&(v=B),v>W&&(v=W);const z={unitId:l,subUnitId:g,drawingId:u,drawingType:d,transform:{angle:v}};K(v),n.featurePluginUpdateNotification([z]),w.refreshControls().changeNotification()},$n=v=>{ae(v),w.keepRatio=v},qn=v=>v?"block":"none";return c.jsxs("div",{className:N(m.imageCommonPanelGrid,m.imageCommonPanelBorder),style:{display:qn(s)},children:[c.jsx("div",{className:m.imageCommonPanelRow,children:c.jsx("div",{className:N(m.imageCommonPanelColumn,m.imageCommonPanelTitle),children:c.jsx("div",{children:t.t("image-panel.transform.title")})})}),c.jsxs("div",{className:m.imageCommonPanelRow,children:[c.jsx("div",{className:N(m.imageCommonPanelColumn,m.imageCommonPanelSpan3),children:c.jsxs("label",{children:[c.jsx("div",{className:m.imageCommonPanelRow,children:c.jsx("div",{className:m.imageCommonPanelColumn,children:t.t("image-panel.transform.width")})}),c.jsx("div",{className:m.imageCommonPanelRow,children:c.jsx("div",{className:m.imageCommonPanelColumn,children:c.jsx(k.InputNumber,{precision:1,value:U,onChange:v=>{Q(v)},className:m.imageCommonPanelInput})})})]})}),c.jsx("div",{className:N(m.imageCommonPanelColumn,m.imageCommonPanelSpan3),children:c.jsxs("label",{children:[c.jsx("div",{className:m.imageCommonPanelRow,children:c.jsx("div",{className:m.imageCommonPanelColumn,children:t.t("image-panel.transform.height")})}),c.jsx("div",{className:m.imageCommonPanelRow,children:c.jsx("div",{className:m.imageCommonPanelColumn,children:c.jsx(k.InputNumber,{precision:1,value:O,onChange:v=>{De(v)},className:m.imageCommonPanelInput})})})]})}),c.jsx("div",{className:N(m.imageCommonPanelColumn,m.imageCommonPanelSpan3),children:c.jsxs("label",{children:[c.jsx("div",{className:m.imageCommonPanelRow,children:c.jsx("div",{className:m.imageCommonPanelColumn,children:t.t("image-panel.transform.lock")})}),c.jsx("div",{className:N(m.imageCommonPanelRow,m.imageCommonPanelRowVertical),children:c.jsx("div",{className:m.imageCommonPanelColumn,children:c.jsx(k.Checkbox,{checked:ce,onChange:$n})})})]})})]}),c.jsxs("div",{className:m.imageCommonPanelRow,children:[c.jsx("div",{className:N(m.imageCommonPanelColumn,m.imageCommonPanelSpan3),children:c.jsxs("label",{children:[c.jsx("div",{className:m.imageCommonPanelRow,children:c.jsx("div",{className:m.imageCommonPanelColumn,children:t.t("image-panel.transform.x")})}),c.jsx("div",{className:m.imageCommonPanelRow,children:c.jsx("div",{className:m.imageCommonPanelColumn,children:c.jsx(k.InputNumber,{precision:1,value:T,onChange:v=>{Xn(v)},className:m.imageCommonPanelInput})})})]})}),c.jsx("div",{className:N(m.imageCommonPanelColumn,m.imageCommonPanelSpan3),children:c.jsxs("label",{children:[c.jsx("div",{className:m.imageCommonPanelRow,children:c.jsx("div",{className:m.imageCommonPanelColumn,children:t.t("image-panel.transform.y")})}),c.jsx("div",{className:m.imageCommonPanelRow,children:c.jsx("div",{className:m.imageCommonPanelColumn,children:c.jsx(k.InputNumber,{precision:1,value:V,onChange:v=>{Jn(v)},className:m.imageCommonPanelInput})})})]})}),c.jsx("div",{className:N(m.imageCommonPanelColumn,m.imageCommonPanelSpan3),children:c.jsxs("label",{children:[c.jsx("div",{className:m.imageCommonPanelRow,children:c.jsx("div",{className:m.imageCommonPanelColumn,children:t.t("image-panel.transform.rotate")})}),c.jsx("div",{className:m.imageCommonPanelRow,children:c.jsx("div",{className:m.imageCommonPanelColumn,children:c.jsx(k.InputNumber,{precision:1,value:re,onChange:Qn,className:m.imageCommonPanelInput})})})]})})]})]})},we={id:"sheet.operation.open-image-crop",type:p.CommandType.OPERATION,handler:(a,t)=>!0},ee={id:"sheet.operation.close-image-crop",type:p.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 ge={id:"sheet.operation.Auto-image-crop",type:p.CommandType.OPERATION,handler:(a,t)=>!0},Dn=a=>{const t=p.useDependency(p.ICommandService),n=p.useDependency(p.LocaleService),{drawings:e,cropperShow:r}=a;if(e[0]==null)return;const[i,o]=_.useState(H.FREE),l=_.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}];_.useEffect(()=>{const f=t.onCommandExecuted(I=>{if(I.id===ee.id){const w=I.params;w!=null&&w.isAuto||(l.current=!1)}});return()=>{f==null||f.dispose()}},[]);function u(f){o(f),l.current&&t.executeCommand(ge.id,{cropType:f})}const d=f=>f?"block":"none",h=f=>{t.executeCommand(ge.id,{cropType:f}),l.current=!0};return c.jsxs("div",{className:N(m.imageCommonPanelGrid,m.imageCommonPanelBorder),style:{display:d(r)},children:[c.jsx("div",{className:m.imageCommonPanelRow,children:c.jsx("div",{className:N(m.imageCommonPanelColumn,m.imageCommonPanelTitle),children:c.jsx("div",{children:n.t("image-panel.crop.title")})})}),c.jsxs("div",{className:N(m.imageCommonPanelRow,m.imageCommonPanelRowVertical),children:[c.jsx("div",{className:N(m.imageCommonPanelColumn,m.imageCommonPanelSpan2),children:c.jsx(k.Button,{size:"small",onClick:()=>{h(i)},children:c.jsxs("span",{className:m.imageCommonPanelInline,children:[c.jsx(Le,{}),n.t("image-panel.crop.start")]})})}),c.jsx("div",{className:N(m.imageCommonPanelColumn,m.imageCommonPanelSpan2),children:c.jsx(k.Select,{value:i,options:g,onChange:u})})]})]})},Rn=a=>{const t=p.useDependency(S.IDrawingManagerService),n=p.useDependency(b.IRenderManagerService),e=p.useDependency(p.LocaleService),{drawings:r,hasArrange:s=!0,hasTransform:i=!0,hasAlign:o=!0,hasCropper:l=!0,hasGroup:g=!0}=a,u=r[0];if(u==null)return;const{unitId:d}=u,h=n.getRenderById(d),f=h==null?void 0:h.scene;if(f==null)return;const I=f.getTransformerByCreate(),[w,C]=_.useState(!0),[j,y]=_.useState(!0),[E,M]=_.useState(!1),[U,D]=_.useState(!0),[O,R]=_.useState(!1);return _.useEffect(()=>{const T=I.clearControl$.subscribe(L=>{L===!0&&(C(!1),y(!1),M(!1),D(!1),R(!0))}),A=I.changeStart$.subscribe(L=>{const{objects:re}=L,K=me(re,t);K.length===0?(C(!1),y(!1),M(!1),D(!1),R(!0)):K.length===1?(C(!0),y(!0),M(!1),D(!0),R(!1)):(C(!0),y(!1),M(!0),D(!1),R(!1))}),V=t.focus$.subscribe(L=>{L.length===0?(C(!1),y(!1),M(!1),D(!1),R(!0)):L.length===1?(C(!0),y(!0),M(!1),D(!0),R(!1)):(C(!0),y(!1),M(!0),D(!1),R(!1))});return()=>{A.unsubscribe(),T.unsubscribe(),V.unsubscribe()}},[]),c.jsxs(c.Fragment,{children:[c.jsx("div",{style:{display:O===!0?"block":"none",height:"100%"},children:c.jsx("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",height:"100%",top:"50%",marginTop:"-100px"},children:c.jsx("span",{children:e.t("image-panel.null")})})}),c.jsx(bn,{arrangeShow:s===!0?w:!1,drawings:r}),c.jsx(Mn,{transformShow:i===!0?j:!1,drawings:r}),c.jsx(ln,{alignShow:o===!0?E:!1,drawings:r}),c.jsx(Dn,{cropperShow:l===!0?U:!1,drawings:r}),c.jsx(yn,{hasGroup:g,drawings:r})]})},ue={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"},Ke=a=>{var I,w;const t=(w=(I=a.popup)==null?void 0:I.extraProps)==null?void 0:w.menuItems;if(!t)return null;const n=p.useDependency(p.ICommandService),e=p.useDependency(p.LocaleService),[r,s]=_.useState(!1),[i,o]=_.useState(!1),l=()=>{o(!0)},g=()=>{o(!1)},u=C=>{s(C)},d=C=>{n.executeCommand(C.commandId,C.commandParams),s(!1)},h=r||i,f=t.filter(C=>!C.disable);return c.jsx("div",{onMouseEnter:l,onMouseLeave:g,children:c.jsx(k.Dropdown,{placement:"bottomLeft",trigger:["click"],overlay:c.jsx("ul",{className:ue.imagePopupMenu,children:f.map(C=>c.jsx("li",{onClick:()=>d(C),className:ue.imagePopupMenuItem,children:c.jsx("span",{className:ue.imagePopupMenuItemTitle,children:e.t(C.label)})},C.index))}),visible:r,onVisibleChange:u,children:c.jsxs("div",{className:N(ue.btnContainer,{[ue.btnContainerExpand]:r}),children:[c.jsx(Ue,{style:{color:"#35322B"},extend:{colorChannel1:"rgb(var(--green-700, #409f11))"}}),h&&c.jsx(Ge,{style:{color:"#CCCCCC",fontSize:"8px",marginLeft:"8px"}})]})})})},Fe="COMPONENT_IMAGE_POPUP_MENU",On="drawing-ui.config",xn={},je={id:"sheet.operation.image-reset-size",type:p.CommandType.OPERATION,handler:(a,t)=>!0},Ye="COMPONENT_IMAGE_VIEWER",Nn=a=>{const{src:t}=a;return t?c.jsx("div",{children:c.jsx("img",{src:t,alt:"Univer Image Viewer",style:{width:"100%",height:"100%",position:"relative"}})}):null};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},Ze=(a,t)=>(n,e)=>t(n,e,a);let Se=class extends p.Disposable{constructor(a,t){super(),this._componentManager=a,this._commandService=t,this._init()}_initCustomComponents(){const a=this._componentManager;this.disposeWithMe(a.register(Fe,Ke)),this.disposeWithMe(a.register(Ye,Nn))}_initCommands(){[we,ee,je,Ce,ge].forEach(a=>this.disposeWithMe(this._commandService.registerCommand(a)))}_init(){this._initCommands(),this._initCustomComponents()}};Se=Bn([Ze(0,p.Inject(Pe.ComponentManager)),Ze(1,p.ICommandService)],Se);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},_e=(a,t)=>(n,e)=>t(n,e,a);let Ie=class extends p.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=Oe(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(l=>{o[l]&&this._insertDrawing([{unitId:s,subUnitId:i,drawingId:l}])})})})}_commandExecutedListener(){this.disposeWithMe(this._commandService.onCommandExecuted(t=>{if(t.id===Ce.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:l,transformer:g}=o;this._commandService.syncExecuteCommand(ee.id);const u=[];if(e.forEach(f=>{const I=S.getDrawingShapeKeyByDrawingSearch(f),w=l.getObjectIncludeInGroup(I);if(w==null||u.includes(w))return;u.push(w);const{transform:C}=f;C!=null&&(w.classType===b.RENDER_CLASS_TYPE.GROUP?w.transformByState({left:C.left,top:C.top}):w.transformByState(C))}),u.length===0)return;const d=S.getDrawingShapeKeyByDrawingSearch({unitId:r,subUnitId:s,drawingId:i}),h=new b.Group(d);l.addObject(h,b.DRAWING_OBJECT_LAYER_INDEX).attachTransformerTo(h),h.addObjects(...u),n.transform&&h.transformByState({left:n.transform.left,top:n.transform.top}),g.clearSelectedObjects(),g.setSelectedControl(h)}_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 h=S.getDrawingShapeKeyByDrawingSearch(d),f=s.getObjectIncludeInGroup(h);if(f==null)return!0;if(f==null)return;const{transform:I}=d;I!=null&&(f.classType===b.RENDER_CLASS_TYPE.GROUP?f.transformByState({left:I.left,top:I.top}):f.transformByState(I))});const o=S.getDrawingShapeKeyByDrawingSearch(n),l=s.getObject(o),{width:g,height:u}=l;l.getObjects().forEach(d=>{l.removeSelfObjectAndTransform(d.oKey,g,u)}),l.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,l=Number.NEGATIVE_INFINITY,g=0;e.forEach(u=>{const{unitId:d,subUnitId:h,drawingId:f,drawingType:I}=u,w=this._drawingManagerService.getDrawingByParam({unitId:d,subUnitId:h,drawingId:f});if(w==null||w.transform==null)return;r.push({unitId:d,subUnitId:h,drawingId:f,drawingType:I,transform:w.transform});const{left:C=0,top:j=0,width:y=0,height:E=0}=w.transform;s=Math.min(s,C),i=Math.min(i,j),o=Math.max(o,C+y),l=Math.max(l,j+E),g++}),g!==0&&(this._sortDrawingTransform(r,n),this._applyAlignType(r,n,s,i,o,l,g))}_applyAlignType(t,n,e,r,s,i,o){const l=Math.round((s-e)/o*10)/10,g=Math.round((i-r)/o*10)/10,u=[],d=this._getSceneAndTransformerByDrawingSearch(t[0].unitId);if(d==null)return;const{scene:h,transformer:f}=d;t.forEach((I,w)=>{const{unitId:C,subUnitId:j,drawingId:y,transform:E,drawingType:M}=I,{left:U=0,top:D=0,width:O=0,height:R=0}=E;let T=U,A=D;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-R/2;break;case x.bottom:A=i-R;break;case x.horizon:T=e+l*w;break;case x.vertical:A=r+g*w;break}(T!==U||A!==D)&&u.push({unitId:C,subUnitId:j,drawingId:y,drawingType:M,transform:{left:T,top:A}})}),this._drawingManagerService.featurePluginUpdateNotification(u),f.refreshControls().changeNotification()}_sortDrawingTransform(t,n){t.sort((e,r)=>{const s=e.transform,i=r.transform,{left:o=0,top:l=0,width:g=0,height:u=0}=s,{left:d=0,top:h=0,width:f=0,height:I=0}=i;switch(n){case x.left:return o-d;case x.center:return o+g/2-(d+f/2);case x.right:return o+g-(d+f);case x.top:return l-h;case x.middle:return l+u/2-(h+I/2);case x.bottom:return l+u-(h+I);case x.horizon:return o+g/2-(d+f/2);case x.vertical:return l+u/2-(h+I/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 l=S.getDrawingShapeKeyByDrawingSearch({unitId:n,subUnitId:e,drawingId:o}),g=i.fuzzyMathObjects(l,!0);if(g==null||g.length===0)return;const u=this._drawingManagerService.getDrawingOrder(n,e).indexOf(o);for(const d of g)d.setProps({zIndex:u}),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 u;const{unitId:e,subUnitId:r,drawingId:s}=n,i=this._getSceneAndTransformerByDrawingSearch(e);if(i==null)return;const{scene:o}=i,l=S.getDrawingShapeKeyByDrawingSearch({unitId:e,subUnitId:r,drawingId:s}),g=o.fuzzyMathObjects(l,!0);if(g.length>0){for(const d of g)d.dispose();(u=o.getTransformer())==null||u.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:l}=i,g=this._getSceneAndTransformerByDrawingSearch(e);if(g==null)return;const{scene:u,transformer:d}=g;if(o==null)return!0;const{left:h=0,top:f=0,width:I=0,height:w=0,angle:C=0,flipX:j=!1,flipY:y=!1,skewX:E=0,skewY:M=0}=o,U=S.getDrawingShapeKeyByDrawingSearch({unitId:e,subUnitId:r,drawingId:s}),D=u.getObject(U);if(D==null)return!0;D.transformByState({left:h,top:f,width:I,height:w,angle:C,flipX:j,flipY:y,skewX:E,skewY:M})})}))}_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:l}=o,{scene:g}=i,u=S.getDrawingShapeKeyByDrawingSearch({unitId:e,subUnitId:r,drawingId:s}),d=g.getObject(u);if(d==null||l==null)return!0;const{left:h=0,top:f=0,width:I=0,height:w=0,angle:C=0,flipX:j=!1,flipY:y=!1,skewX:E=0,skewY:M=0}=l;d.transformByState({left:h,top:f,width:I,height:w,angle:C,flipX:j,flipY:y,skewX:E,skewY:M})})}))}_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:l}=o,g=S.getDrawingShapeKeyByDrawingSearch({unitId:e,subUnitId:r,drawingId:s}),u=l.getObject(g);if(u==null)return!0;i?u.show():u.hide()})}))}_filterUpdateParams(t,n){return t.filter((e,r)=>{if(e==null)return!1;const{transform:s}=e;return p.checkIfMove(s,n==null?void 0:n[r])})}_addListenerOnDrawing(t){const n=t.getTransformerByCreate();let e=null;this.disposeWithMe(p.toDisposable(n.changeStart$.subscribe(r=>{const{objects:s}=r,i=Array.from(s.values()),o=[];e=i.map(l=>{const{left:g,top:u,height:d,width:h,angle:f,oKey:I,isInGroup:w}=l,C=this._drawingManagerService.getDrawingOKey(I);if(w||l instanceof b.Group){let j=l.ancestorGroup;if(j==null&&l instanceof b.Group&&(j=l),j==null)return null;const y=this._drawingManagerService.getDrawingOKey(j.oKey);if(y){const{unitId:E,subUnitId:M,drawingId:U}=y;o.push({unitId:E,subUnitId:M,drawingId:U});const{left:D,top:O,height:R,width:T,angle:A}=j;return{left:D,top:O,height:R,width:T,angle:A}}}else if(C!=null){const{unitId:j,subUnitId:y,drawingId:E}=C;return o.push({unitId:j,subUnitId:y,drawingId:E}),{left:g,top:u,height:d,width:h,angle:f}}return null}).filter(l=>l!=null),o.length>0?this._drawingManagerService.focusDrawing(o):this._drawingManagerService.focusDrawing(null)}))),this.disposeWithMe(p.toDisposable(n.changeEnd$.subscribe(r=>{const{objects:s}=r,i=this._filterUpdateParams(me(s,this._drawingManagerService),e);i.length>0&&this._drawingManagerService.featurePluginUpdateNotification(i)})))}};Ie=Ln([_e(0,p.IUniverInstanceService),_e(1,p.ICommandService),_e(2,b.IRenderManagerService),_e(3,S.IDrawingManagerService)],Ie);class de 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 l,g;const r=this.getScene().getEngine(),{width:s,height:i}=r;this._initialCacheCanvas(),(l=this._cacheCanvas)==null||l.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:l=0,height:g=0,angle:u}=this._applyTransform;if(this._srcRect!=null){const{left:f=0,top:I=0,right:w=0,bottom:C=0}=this._srcRect;n=f,e=I,r=w,s=C}const d=i+n,h=o+e;this.transformByState({left:d,top:h,width:i+l-r-d,height:o+g-s-h,angle:u})}_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 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},oe=(a,t)=>(n,e)=>t(n,e,a);let be=class extends p.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!==ge.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:l}=s,g=this._renderManagerService.getRenderById(i),u=g==null?void 0:g.scene;if(u==null)return!0;this._searchCropObject(u)!=null&&this._commandService.syncExecuteCommand(ee.id,{isAuto:!0});const h=S.getDrawingShapeKeyByDrawingSearch({unitId:i,subUnitId:o,drawingId:l}),f=u.getObject(h);if(!(f instanceof b.Image)){this._messageService.show({type:k.MessageType.Error,content:this._localeService.t("image-cropper.error")});return}f!=null&&(this._updateCropperObject(e,f),this._commandService.executeCommand(we.id,{unitId:i,subUnitId:o,drawingId:l}))}))}_calculateSrcRectByRatio(t,n,e,r,s,i){const o=e/r,l=s/i;let g=e,u=r;o>l?g=r*l:u=e/l;const d=(e-g)/2,h=(r-u)/2;return{left:b.precisionTo(d,1),top:b.precisionTo(h,1),right:b.precisionTo(e-(d+g),1),bottom:b.precisionTo(r-(h+u),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:l=0,top:g=0,bottom:u=0,right:d=0}=o;n.transformByStateCloseCropper({left:e+l,top:r+g,width:s-d-l,height:i-u-g})}_initOpenCrop(){this.disposeWithMe(this._commandService.onCommandExecuted(t=>{if(t.id!==we.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=S.getDrawingShapeKeyByDrawingSearch({unitId:e,subUnitId:r,drawingId:s}),u=o.getObject(g);if(u==null)return;if(!(u 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 h=new de(`${g}-crop`,{srcRect:u.srcRect,prstGeom:u.prstGeom,applyTransform:u.calculateTransformWithSrcRect()});o.addObject(h,u.getLayerIndex()+1).attachTransformerTo(h),d==null||d.createControlForCopper(h),this._addHoverForImageCopper(h),u.openRenderByCropper(),d==null||d.refreshControls(),h.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 de)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 l=this._getApplyObjectByCropObject(o);if(l==null)return;const g=i.getTransformerByCreate();g.detachFrom(o),g.clearCopperControl();const u=this._getSrcRectByTransformState(l,o),d=this._drawingManagerService.getDrawingOKey(l.oKey);if(d!=null){const{left:h,top:f,height:I,width:w}=o;this._drawingManagerService.featurePluginUpdateNotification([{...d,transform:{...d.transform,left:h,top:f,height:I,width:w},srcRect:u.srcRectAngle}])}l.setSrcRect({...u.srcRectAngle}),l.closeRenderByCropper(),l.makeDirty(!0),o==null||o.dispose()}));const t=this._univerInstanceService.getCurrentTypeOfUnit$(p.UniverInstanceType.UNIVER_SHEET).pipe(Re.filter(n=>!!n),Re.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 de))return;const{left:o,top:l,height:g,width:u,angle:d}=i;e={left:o,top:l,height:g,width:u,angle:d},n.clearCopperControl()})),this.disposeWithMe(n.changeEnd$.subscribe(r=>{const{objects:s}=r,i=s.values().next().value;if(i==null||!(i instanceof de))return;const{left:o,top:l,height:g,width:u,angle:d}=i;if(!p.checkIfMove({left:o,top:l,height:g,width:u,angle:d},e))return;const h=this._getApplyObjectByCropObject(i);if(h==null)return;const f=this._getSrcRectByTransformState(h,i);i.refreshSrcRect(f.srcRect,h.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:l}=n,{left:g,top:u,width:d,height:h,angle:f,strokeWidth:I}=t,w=e-g,C=r-u,j={left:w,top:C,right:d-w-i,bottom:h-C-s},y={...j};if(f!==0){const E=e+i/2,M=r+s/2,U=new b.Vector2(E,M),D=d/2+g,O=h/2+u,R=new b.Vector2(D,O),T=new b.Vector2(g,u);T.rotateByPoint(b.degToRad(f),R);const A=T.clone();A.rotateByPoint(b.degToRad(-f),U);const V=e-A.x,L=r-A.y;y.left=V,y.top=L,y.right=d-V-i,y.bottom=h-L-s}return{srcRect:j,srcRectAngle:y}}};be=Vn([oe(0,p.ICommandService),oe(1,S.IDrawingManagerService),oe(2,b.IRenderManagerService),oe(3,p.IUniverInstanceService),oe(4,Pe.IMessageService),oe(5,p.Inject(p.LocaleService))],be);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},te=(a,t)=>(n,e)=>t(n,e,a);const Xe=50;let ye=class extends p.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===je.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:l}=o,g=S.getDrawingShapeKeyByDrawingSearch({unitId:r,subUnitId:s,drawingId:i}),u=l.getObject(g);if(u==null)return!0;const d=this._drawingManagerService.getDrawingByParam(e);if(d==null)return!0;if(d.drawingType!==S.DrawingTypeEnum.DRAWING_IMAGE)return;u.resetSize();const{width:h,height:f}=u.getNativeSize();n.includes(l)===!1&&n.push(l),t.push({...d,transform:{...d.transform,height:f,width:h,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=Oe(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 l=await this._drawingRenderService.renderImages(o,s.scene);if(!(l==null||l.length===0))for(const u of l)this._addHoverForImage(u),this._addDialogForImage(u)})}_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:l,prstGeom:g,source:u,imageSourceType:d}=s;if(o!==S.DrawingTypeEnum.DRAWING_IMAGE)return;const h=this._getSceneAndTransformerByDrawingSearch(n);if(h==null)return;const{scene:f,transformer:I}=h;if(i==null)return!0;const w=S.getDrawingShapeKeyByDrawingSearch({unitId:n,subUnitId:e,drawingId:r}),C=f.getObject(w);if(C==null)return!0;C.setSrcRect(l),C.setPrstGeom(g)})}))}_addHoverForImage(a){this.disposeWithMe(p.toDisposable(a.onPointerEnter$.subscribeEvent(()=>{a.cursor=b.CURSOR_TYPE.GRAB}))),this.disposeWithMe(p.toDisposable(a.onPointerLeave$.subscribeEvent(()=>{a.cursor=b.CURSOR_TYPE.DEFAULT})))}_addDialogForImage(a){this.disposeWithMe(p.toDisposable(a.onDblclick$.subscribeEvent(()=>{var o;const t=`${a.oKey}-viewer-dialog`,n=a.getNativeSize(),e=window.innerWidth-Xe,r=window.innerHeight-Xe,s=this._adjustImageSize(n.width,n.height,e,r),i=this._dialogService.open({width:s.width,id:t,style:{margin:"0",top:"50%",left:"50%",transform:"translate(-50%, -50%)"},children:{label:{name:Ye,props:{src:(o=a.getNative())==null?void 0:o.src,width:s.width,height:s.height}}},destroyOnClose:!0,draggable:!1,onClose:()=>{this._dialogService.close(t),i.dispose()}})})))}_adjustImageSize(a,t,n,e){if(a<=n&&t<=e)return{width:a,height:t};const r=n/a,s=e/t,i=Math.min(r,s);return{width:Math.floor(a*i),height:Math.floor(t*i)}}};ye=zn([te(0,p.ICommandService),te(1,b.IRenderManagerService),te(2,S.IDrawingManagerService),te(3,Pe.IDialogService),te(4,S.IImageIoService),te(5,p.IUniverInstanceService),te(6,p.Inject(P.DrawingRenderService))],ye);var Kn=Object.defineProperty,Fn=Object.getOwnPropertyDescriptor,Yn=(a,t,n,e)=>{for(var r=e>1?void 0:e?Fn(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&&Kn(t,n,r),r},Je=(a,t)=>(n,e)=>t(n,e,a);const Zn="UNIVER_DRAWING_UI_PLUGIN";P.UniverDrawingUIPlugin=(Me=class extends p.Plugin{constructor(t=xn,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(On,s)}onStarting(){this._initDependencies()}onRendered(){this._injector.get(Ie),this._injector.get(Se),this._injector.get(be),this._injector.get(ye)}_initDependencies(){[[P.DrawingRenderService],[Ie],[Se],[be],[ye]].forEach(n=>this._injector.add(n))}},q(Me,"pluginName",Zn),Me),P.UniverDrawingUIPlugin=Yn([Je(1,p.Inject(p.Injector)),Je(2,p.IConfigService)],P.UniverDrawingUIPlugin),P.AutoImageCropOperation=ge,P.COMPONENT_IMAGE_POPUP_MENU=Fe,P.CloseImageCropOperation=ee,P.DrawingCommonPanel=Rn,P.ImageCropperObject=de,P.ImagePopupMenu=Ke,P.ImageResetSizeOperation=je,P.OpenImageCropOperation=we,P.SetDrawingAlignOperation=Ce,P.getUpdateParams=me,Object.defineProperty(P,Symbol.toStringTag,{value:"Module"})});
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"})});
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 I=Object.defineProperty,E=Object.getOwnPropertyDescriptor,O=(e,r,i,n)=>{for(var t=n>1?void 0:n?E(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&&I(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 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"})});
19
19
 
20
20
 
21
21
  // @univerjs/sheets-drawing-ui/index
22
- (function(O,p){typeof exports=="object"&&typeof module<"u"?p(exports,require("@univerjs/core"),require("@univerjs/drawing"),require("@univerjs/drawing-ui"),require("@univerjs/engine-render"),require("@univerjs/sheets-drawing"),require("@univerjs/sheets-ui"),require("@univerjs/ui"),require("rxjs"),require("@univerjs/sheets"),require("react"),require("@univerjs/design")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/drawing","@univerjs/drawing-ui","@univerjs/engine-render","@univerjs/sheets-drawing","@univerjs/sheets-ui","@univerjs/ui","rxjs","@univerjs/sheets","react","@univerjs/design"],p):(O=typeof globalThis<"u"?globalThis:O||self,p(O.UniverSheetsDrawingUi={},O.UniverCore,O.UniverDrawing,O.UniverDrawingUi,O.UniverEngineRender,O.UniverSheetsDrawing,O.UniverSheetsUi,O.UniverUi,O.rxjs,O.UniverSheets,O.React,O.UniverDesign))})(this,function(O,p,b,ee,N,h,j,F,W,I,H,Z){"use strict";var on=Object.defineProperty;var an=(O,p,b)=>p in O?on(O,p,{enumerable:!0,configurable:!0,writable:!0,value:b}):O[p]=b;var X=(O,p,b)=>an(O,typeof p!="symbol"?p+"":p,b);const Je="sheets-drawing-ui.config",Ze={},G={id:"sheet.operation.clear-drawing-transformer",type:p.CommandType.MUTATION,handler:(i,n)=>{const r=i.get(N.IRenderManagerService);return n.forEach(e=>{var t,o;(o=(t=r.getRenderById(e))==null?void 0:t.scene.getTransformer())==null||o.debounceRefreshControls()}),!0}},ie={id:"sheet.command.remove-sheet-image",type:p.CommandType.COMMAND,handler:(i,n)=>{var M,C,T;const r=i.get(p.ICommandService),e=i.get(p.IUndoRedoService),t=i.get(I.SheetInterceptorService),o=i.get(h.ISheetDrawingService);if(!n)return!1;const{drawings:a}=n,c=[];a.forEach(_=>{const{unitId:D}=_;c.push(D)});const d=o.getBatchRemoveOp(a),{unitId:g,subUnitId:l,undo:s,redo:u,objects:m}=d,f=t.onCommandExecute({id:ie.id,params:n}),S={id:h.SetDrawingApplyMutation.id,params:{unitId:g,subUnitId:l,op:u,objects:m,type:h.DrawingApplyType.REMOVE}},v={id:h.SetDrawingApplyMutation.id,params:{unitId:g,subUnitId:l,op:s,objects:m,type:h.DrawingApplyType.INSERT}};return p.sequenceExecute([...(M=f.preRedos)!=null?M:[],S,...f.redos],r)?(e.pushUndoRedo({unitID:g,undoMutations:[...(C=f.preUndos)!=null?C:[],v,...f.undos,{id:G.id,params:c}],redoMutations:[...(T=f.preRedos)!=null?T:[],S,...f.redos,{id:G.id,params:c}]}),!0):!1}},We="COMPONENT_SHEET_DRAWING_PANEL",Ce={id:"sidebar.operation.sheet-image",type:p.CommandType.COMMAND,handler:async(i,n)=>{const r=i.get(F.ISidebarService),e=i.get(p.LocaleService),t=i.get(p.IUniverInstanceService),o=i.get(b.IDrawingManagerService);if(!I.getSheetCommandTarget(t))return!1;switch(n.value){case"open":r.open({header:{title:e.t("sheetImage.panel.title")},children:{label:We},onClose:()=>{o.focusDrawing(null)},width:360});break;case"close":default:r.close();break}return!0}},ye={id:"sheet.operation.edit-sheet-image",type:p.CommandType.OPERATION,handler:(i,n)=>{const r=i.get(b.IDrawingManagerService),e=i.get(p.ICommandService);return n==null?!1:(r.focusDrawing([n]),e.executeCommand(Ce.id,{value:"open"}),!0)}};var Le={exports:{}},de={};/**
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={};/**
23
23
  * @license React
24
24
  * react-jsx-runtime.production.min.js
25
25
  *
@@ -27,7 +27,7 @@
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 qe=H,Qe=Symbol.for("react.element"),et=Symbol.for("react.fragment"),tt=Object.prototype.hasOwnProperty,nt=qe.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,rt={key:!0,ref:!0,__self:!0,__source:!0};function Be(i,n,r){var e,t={},o=null,a=null;r!==void 0&&(o=""+r),n.key!==void 0&&(o=""+n.key),n.ref!==void 0&&(a=n.ref);for(e in n)tt.call(n,e)&&!rt.hasOwnProperty(e)&&(t[e]=n[e]);if(i&&i.defaultProps)for(e in n=i.defaultProps,n)t[e]===void 0&&(t[e]=n[e]);return{$$typeof:Qe,type:i,key:o,ref:a,props:t,_owner:nt.current}}de.Fragment=et,de.jsx=Be,de.jsxs=Be,Le.exports=de;var $=Le.exports;const le={uploadLoading:"univer-upload-loading",uploadLoadingBody:"univer-upload-loading-body",uploadLoadingBodyAnimation:"univer-upload-loading-body-animation",univerCircleAnimation:"univer-UniverCircleAnimation",uploadLoadingBodyText:"univer-upload-loading-body-text"},it=()=>{const i=p.useDependency(b.IImageIoService),n=p.useDependency(p.LocaleService),[r,e]=H.useState(0);return H.useEffect(()=>{const t=i.change$.subscribe(o=>{e(o)});return()=>{t.unsubscribe()}},[i]),$.jsx("div",{style:{display:r>0?"block":"none"},className:le.uploadLoading,children:$.jsxs("div",{className:le.uploadLoadingBody,children:[$.jsx("div",{className:le.uploadLoadingBodyAnimation}),$.jsx("div",{className:le.uploadLoadingBodyText,children:`${n.t("uploadLoading.loading")}: ${r}`})]})})};var ot=Object.defineProperty,at=Object.getOwnPropertyDescriptor,st=(i,n,r,e)=>{for(var t=e>1?void 0:e?at(n,r):n,o=i.length-1,a;o>=0;o--)(a=i[o])&&(t=(e?a(n,r,t):a(t))||t);return e&&t&&ot(n,r,t),t},te=(i,n)=>(r,e)=>n(r,e,i);let ue=class extends p.RxDisposable{constructor(n,r,e,t,o,a,c){super();X(this,"_initImagePopupMenu",new Set);this._injector=n,this._drawingManagerService=r,this._canvasPopManagerService=e,this._renderManagerService=t,this._univerInstanceService=o,this._contextService=a,this._uiPartsService=c,this._init()}_init(){this._univerInstanceService.getCurrentTypeOfUnit$(p.UniverInstanceType.UNIVER_SHEET).pipe(W.takeUntil(this.dispose$)).subscribe(n=>this._create(n)),this._univerInstanceService.getTypeOfUnitDisposed$(p.UniverInstanceType.UNIVER_SHEET).pipe(W.takeUntil(this.dispose$)).subscribe(n=>this._dispose(n)),this._univerInstanceService.getAllUnitsForType(p.UniverInstanceType.UNIVER_SHEET).forEach(n=>this._create(n)),this._uiPartsService.registerComponent(F.BuiltInUIPart.CONTENT,()=>p.connectInjector(it,this._injector))}_dispose(n){const r=n.getUnitId();this._renderManagerService.removeRender(r)}_create(n){if(!n)return;const r=n.getUnitId();this._renderManagerService.has(r)&&!this._initImagePopupMenu.has(r)&&(this._popupMenuListener(r),this._initImagePopupMenu.add(r))}_hasCropObject(n){const r=n.getAllObjectsByOrder();for(const e of r)if(e instanceof ee.ImageCropperObject)return!0;return!1}_popupMenuListener(n){var o;const r=(o=this._renderManagerService.getRenderById(n))==null?void 0:o.scene;if(!r)return;const e=r.getTransformerByCreate();if(!e)return;let t;this.disposeWithMe(p.toDisposable(e.createControl$.subscribe(()=>{if(this._contextService.setContextValue(p.FOCUSING_COMMON_DRAWINGS,!0),this._hasCropObject(r))return;const a=e.getSelectedObjectMap();if(a.size>1){t==null||t.dispose();return}const c=a.values().next().value;if(!c)return;const d=c.oKey,g=this._drawingManagerService.getDrawingOKey(d);if(!g)return;const{unitId:l,subUnitId:s,drawingId:u,drawingType:m}=g,f=g.data;if(f&&f.disablePopup)return;t==null||t.dispose();const S=this._canvasPopManagerService.getFeatureMenu(l,s,u,m);t=this.disposeWithMe(this._canvasPopManagerService.attachPopupToObject(c,{componentKey:ee.COMPONENT_IMAGE_POPUP_MENU,direction:"horizontal",offset:[2,0],extraProps:{menuItems:S||this._getImageMenuItems(l,s,u,m)}})),this._drawingManagerService.focusDrawing([{unitId:l,subUnitId:s,drawingId:u}])}))),this.disposeWithMe(e.clearControl$.subscribe(()=>{t==null||t.dispose(),this._contextService.setContextValue(p.FOCUSING_COMMON_DRAWINGS,!1),this._drawingManagerService.focusDrawing(null)})),this.disposeWithMe(e.changing$.subscribe(()=>{t==null||t.dispose()}))}_getImageMenuItems(n,r,e,t){return[{label:"image-popup.edit",index:0,commandId:ye.id,commandParams:{unitId:n,subUnitId:r,drawingId:e},disable:t===b.DrawingTypeEnum.DRAWING_DOM},{label:"image-popup.delete",index:1,commandId:ie.id,commandParams:{unitId:n,drawings:[{unitId:n,subUnitId:r,drawingId:e}]},disable:!1},{label:"image-popup.crop",index:2,commandId:ee.OpenImageCropOperation.id,commandParams:{unitId:n,subUnitId:r,drawingId:e},disable:t===b.DrawingTypeEnum.DRAWING_DOM},{label:"image-popup.reset",index:3,commandId:ee.ImageResetSizeOperation.id,commandParams:[{unitId:n,subUnitId:r,drawingId:e}],disable:t===b.DrawingTypeEnum.DRAWING_DOM}]}};ue=st([te(0,p.Inject(p.Injector)),te(1,b.IDrawingManagerService),te(2,p.Inject(j.SheetCanvasPopManagerService)),te(3,N.IRenderManagerService),te(4,p.IUniverInstanceService),te(5,p.IContextService),te(6,p.Inject(F.IUIPartsService))],ue);function Y(i,n,r){const{from:e,to:t,flipY:o=!1,flipX:a=!1,angle:c=0,skewX:d=0,skewY:g=0}=i,{column:l,columnOffset:s,row:u,rowOffset:m}=e,{column:f,columnOffset:S,row:v,rowOffset:y}=t,M=r.getCurrentSkeleton(),C=j.attachRangeWithCoord(M,{startColumn:l,endColumn:l,startRow:u,endRow:u});if(C==null)return;const T=j.attachRangeWithCoord(M,{startColumn:f,endColumn:f,startRow:v,endRow:v});if(T==null)return;const{startX:_,startY:D}=C,{startX:w,startY:A}=T;let E=N.precisionTo(_+s,1),L=N.precisionTo(D+m,1),U=N.precisionTo(w+S-E,1),P=N.precisionTo(A+y-L,1);C.startX===T.endX&&(U=0),C.startY===T.endY&&(P=0);const R=M.rowHeaderWidth+M.columnTotalWidth,B=M.columnHeaderHeight+M.rowTotalHeight;return E+U>R&&(E=R-U),L+P>B&&(L=B-P),{flipY:o,flipX:a,angle:c,skewX:d,skewY:g,left:E,top:L,width:U,height:P}}function k(i,n){const{left:r=0,top:e=0,width:t=0,height:o=0,flipY:a=!1,flipX:c=!1,angle:d=0,skewX:g=0,skewY:l=0}=i,s=n.getCellWithCoordByOffset(r,e);if(s==null)return;const u={column:s.actualColumn,columnOffset:N.precisionTo(r-s.startX,1),row:s.actualRow,rowOffset:N.precisionTo(e-s.startY,1)},m=n.getCellWithCoordByOffset(r+t,e+o);if(m==null)return;const f={column:m.actualColumn,columnOffset:N.precisionTo(r+t-m.startX,1),row:m.actualRow,rowOffset:N.precisionTo(e+o-m.startY,1)};return{flipY:a,flipX:c,angle:d,skewX:g,skewY:l,from:u,to:f}}var ct=Object.defineProperty,dt=Object.getOwnPropertyDescriptor,lt=(i,n,r,e)=>{for(var t=e>1?void 0:e?dt(n,r):n,o=i.length-1,a;o>=0;o--)(a=i[o])&&(t=(e?a(n,r,t):a(t))||t);return e&&t&&ct(n,r,t),t},me=(i,n)=>(r,e)=>n(r,e,i);let Me=class extends p.Disposable{constructor(i,n,r,e,t){super(),this._context=i,this._sheetDrawingService=n,this._drawingManagerService=r,this._sheetSelectionRenderService=e,this._sheetSkeletonManagerService=t,this._init()}_init(){this._drawingInitializeListener()}_drawingInitializeListener(){this._sheetDrawingService.initializeNotification(this._context.unitId);const i=this._sheetDrawingService.getDrawingDataForUnit(this._context.unitId);for(const n in i){const r=i[n];for(const e in r.data){const t=r.data[e];t.transform=Y(t.sheetTransform,this._sheetSelectionRenderService,this._sheetSkeletonManagerService)}}this._drawingManagerService.registerDrawingData(this._context.unitId,this._sheetDrawingService.getDrawingDataForUnit(this._context.unitId)),this._drawingManagerService.initializeNotification(this._context.unitId)}};Me=lt([me(1,h.ISheetDrawingService),me(2,b.IDrawingManagerService),me(3,p.Inject(j.ISheetSelectionRenderService)),me(4,p.Inject(j.SheetSkeletonManagerService))],Me);var K=function(){return K=Object.assign||function(i){for(var n,r=1,e=arguments.length;r<e;r++){n=arguments[r];for(var t in n)Object.prototype.hasOwnProperty.call(n,t)&&(i[t]=n[t])}return i},K.apply(this,arguments)},ut=function(i,n){var r={};for(var e in i)Object.prototype.hasOwnProperty.call(i,e)&&n.indexOf(e)<0&&(r[e]=i[e]);if(i!=null&&typeof Object.getOwnPropertySymbols=="function")for(var t=0,e=Object.getOwnPropertySymbols(i);t<e.length;t++)n.indexOf(e[t])<0&&Object.prototype.propertyIsEnumerable.call(i,e[t])&&(r[e[t]]=i[e[t]]);return r},Ge=H.forwardRef(function(i,n){var r=i.icon,e=i.id,t=i.className,o=i.extend,a=ut(i,["icon","id","className","extend"]),c="univerjs-icon univerjs-icon-".concat(e," ").concat(t||"").trim(),d=H.useRef("_".concat(pt()));return ke(r,"".concat(e),{defIds:r.defIds,idSuffix:d.current},K({ref:n,className:c},a),o)});function ke(i,n,r,e,t){return H.createElement(i.tag,K(K({key:n},mt(i,r,t)),e),(gt(i,r).children||[]).map(function(o,a){return ke(o,"".concat(n,"-").concat(i.tag,"-").concat(a),r,void 0,t)}))}function mt(i,n,r){var e=K({},i.attrs);r!=null&&r.colorChannel1&&e.fill==="colorChannel1"&&(e.fill=r.colorChannel1);var t=n.defIds;return!t||t.length===0||(i.tag==="use"&&e["xlink:href"]&&(e["xlink:href"]=e["xlink:href"]+n.idSuffix),Object.entries(e).forEach(function(o){var a=o[0],c=o[1];typeof c=="string"&&(e[a]=c.replace(/url\(#(.*)\)/,"url(#$1".concat(n.idSuffix,")")))})),e}function gt(i,n){var r,e=n.defIds;return!e||e.length===0?i:i.tag==="defs"&&(!((r=i.children)===null||r===void 0)&&r.length)?K(K({},i),{children:i.children.map(function(t){return typeof t.attrs.id=="string"&&e&&e.indexOf(t.attrs.id)>-1?K(K({},t),{attrs:K(K({},t.attrs),{id:t.attrs.id+n.idSuffix})}):t})}):i}function pt(){return Math.random().toString(36).substring(2,8)}Ge.displayName="UniverIcon";var ht={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M2.2498 3.65005C2.2498 2.87685 2.87661 2.25005 3.64981 2.25005H7.9998C8.33118 2.25005 8.5998 1.98142 8.5998 1.65005C8.5998 1.31868 8.33118 1.05005 7.9998 1.05005H3.64981C2.21387 1.05005 1.0498 2.21411 1.0498 3.65005V12.35C1.0498 13.786 2.21386 14.95 3.6498 14.95H12.3498C13.7857 14.95 14.9498 13.786 14.9498 12.3501V8.00005C14.9498 7.66868 14.6812 7.40005 14.3498 7.40005C14.0184 7.40005 13.7498 7.66868 13.7498 8.00005V9.23974L12.2385 8.1063C11.7252 7.72129 11.0068 7.7723 10.5531 8.22605L9.00869 9.77041L6.73916 7.8251C6.24387 7.40055 5.5095 7.41278 5.02864 7.85359L2.2498 10.4009V3.65005ZM2.2498 12.0287V12.35C2.2498 13.1232 2.87661 13.75 3.6498 13.75H12.3498C13.123 13.75 13.7498 13.1232 13.7498 12.3501V10.7397L11.5186 9.06631C11.4829 9.03956 11.433 9.04314 11.4016 9.07458L9.92249 10.5537L11.1015 11.5642C11.3531 11.7799 11.3822 12.1587 11.1666 12.4103C10.9509 12.6619 10.5721 12.691 10.3205 12.4753L5.9582 8.7362C5.92384 8.70674 5.87288 8.70758 5.83952 8.73816L2.2498 12.0287Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M11.8097 1.14783C12.1411 1.14783 12.4097 1.41646 12.4097 1.74783V3.297H14.1541C14.4855 3.297 14.7541 3.56563 14.7541 3.897C14.7541 4.22837 14.4855 4.497 14.1541 4.497H12.4097V6.24167C12.4097 6.57304 12.1411 6.84167 11.8097 6.84167C11.4783 6.84167 11.2097 6.57304 11.2097 6.24167V4.497H9.6603C9.32893 4.497 9.0603 4.22837 9.0603 3.897C9.0603 3.56563 9.32893 3.297 9.6603 3.297H11.2097V1.74783C11.2097 1.41646 11.4783 1.14783 11.8097 1.14783Z"}}]},Ve=H.forwardRef(function(i,n){return H.createElement(Ge,Object.assign({},i,{id:"add-image-single",ref:n,icon:ht}))});Ve.displayName="AddImageSingle";const De={id:"sheet.command.delete-drawing",type:p.CommandType.COMMAND,handler:i=>{const n=i.get(p.ICommandService),e=i.get(h.ISheetDrawingService).getFocusDrawings();if(e.length===0)return!1;const t=e[0].unitId,o=e.map(a=>{const{unitId:c,subUnitId:d,drawingId:g,drawingType:l}=a;return{unitId:c,subUnitId:d,drawingId:g,drawingType:l}});return n.executeCommand(ie.id,{unitId:t,drawings:o})}};function ft(i){const n=[];return i.forEach(r=>{const{parent:e,children:t}=r,{unitId:o,subUnitId:a,drawingId:c}=e,d=N.getGroupState(0,0,t.map(s=>s.transform||{})),g=t.map(s=>{const u=s.transform||{left:0,top:0},{unitId:m,subUnitId:f,drawingId:S}=s;return{unitId:m,subUnitId:f,drawingId:S,transform:{...u,left:u.left-d.left,top:u.top-d.top},groupId:c}}),l={unitId:o,subUnitId:a,drawingId:c,drawingType:b.DrawingTypeEnum.DRAWING_GROUP,transform:d};n.push({parent:l,children:g})}),n}function St(i){const n=[];return i.forEach(r=>{const{parent:e,children:t}=r,{unitId:o,subUnitId:a,drawingId:c,transform:d={width:0,height:0}}=e;if(d==null)return;const g=t.map(s=>{const{transform:u}=s,{unitId:m,subUnitId:f,drawingId:S}=s,v=N.transformObjectOutOfGroup(u||{},d,d.width||0,d.height||0);return{unitId:m,subUnitId:f,drawingId:S,transform:v,groupId:void 0}}),l={unitId:o,subUnitId:a,drawingId:c,drawingType:b.DrawingTypeEnum.DRAWING_GROUP,transform:{left:0,top:0}};n.push({parent:l,children:g})}),n}const Re={id:"sheet.command.group-sheet-image",type:p.CommandType.COMMAND,handler:(i,n)=>{const r=i.get(p.ICommandService),e=i.get(p.IUndoRedoService),t=i.get(h.ISheetDrawingService);if(!n)return!1;const o=[];n.forEach(({parent:m,children:f})=>{o.push(m.unitId),f.forEach(S=>{o.push(S.unitId)})});const a=t.getGroupDrawingOp(n),{unitId:c,subUnitId:d,undo:g,redo:l,objects:s}=a;return r.syncExecuteCommand(h.SetDrawingApplyMutation.id,{op:l,unitId:c,subUnitId:d,objects:s,type:h.DrawingApplyType.GROUP})?(e.pushUndoRedo({unitID:c,undoMutations:[{id:h.SetDrawingApplyMutation.id,params:{op:g,unitId:c,subUnitId:d,objects:St(s),type:h.DrawingApplyType.UNGROUP}},{id:G.id,params:o}],redoMutations:[{id:h.SetDrawingApplyMutation.id,params:{op:l,unitId:c,subUnitId:d,objects:s,type:h.DrawingApplyType.GROUP}},{id:G.id,params:o}]}),!0):!1}},oe={id:"sheet.command.insert-sheet-image",type:p.CommandType.COMMAND,handler:(i,n)=>{var M,C,T;const r=i.get(p.ICommandService),e=i.get(p.IUndoRedoService),t=i.get(h.ISheetDrawingService),o=i.get(I.SheetInterceptorService);if(!n)return!1;const a=n.drawings,c=a.map(_=>_.unitId),d=t.getBatchAddOp(a),{unitId:g,subUnitId:l,undo:s,redo:u,objects:m}=d,f=o.onCommandExecute({id:oe.id,params:n}),S={id:h.SetDrawingApplyMutation.id,params:{op:u,unitId:g,subUnitId:l,objects:m,type:h.DrawingApplyType.INSERT}},v={id:h.SetDrawingApplyMutation.id,params:{op:s,unitId:g,subUnitId:l,objects:m,type:h.DrawingApplyType.REMOVE}};return p.sequenceExecute([...(M=f.preRedos)!=null?M:[],S,...f.redos],r)?(e.pushUndoRedo({unitID:g,undoMutations:[...(C=f.preUndos)!=null?C:[],v,...f.undos,{id:G.id,params:c}],redoMutations:[...(T=f.preRedos)!=null?T:[],S,...f.redos,{id:G.id,params:c}]}),!0):!1}},Te={id:"sheet.command.set-drawing-arrange",type:p.CommandType.COMMAND,handler:(i,n)=>{const r=i.get(p.ICommandService),e=i.get(p.IUndoRedoService);if(!n)return!1;const t=i.get(h.ISheetDrawingService),{unitId:o,subUnitId:a,drawingIds:c,arrangeType:d}=n,g={unitId:o,subUnitId:a,drawingIds:c};let l;if(d===b.ArrangeTypeEnum.forward?l=t.getForwardDrawingsOp(g):d===b.ArrangeTypeEnum.backward?l=t.getBackwardDrawingOp(g):d===b.ArrangeTypeEnum.front?l=t.getFrontDrawingsOp(g):d===b.ArrangeTypeEnum.back&&(l=t.getBackDrawingsOp(g)),l==null)return!1;const{objects:s,redo:u,undo:m}=l;return r.syncExecuteCommand(h.SetDrawingApplyMutation.id,{op:u,unitId:o,subUnitId:a,objects:s,type:h.DrawingApplyType.ARRANGE})?(e.pushUndoRedo({unitID:o,undoMutations:[{id:h.SetDrawingApplyMutation.id,params:{op:m,unitId:o,subUnitId:a,objects:s,type:h.DrawingApplyType.ARRANGE}}],redoMutations:[{id:h.SetDrawingApplyMutation.id,params:{op:u,unitId:o,subUnitId:a,objects:s,type:h.DrawingApplyType.ARRANGE}}]}),!0):!1}},ae={id:"sheet.command.set-sheet-image",type:p.CommandType.COMMAND,handler:(i,n)=>{const r=i.get(p.ICommandService),e=i.get(p.IUndoRedoService),t=i.get(h.ISheetDrawingService);if(!n)return!1;const{drawings:o}=n,a=t.getBatchUpdateOp(o),{unitId:c,subUnitId:d,undo:g,redo:l,objects:s}=a;return r.syncExecuteCommand(h.SetDrawingApplyMutation.id,{unitId:c,subUnitId:d,op:l,objects:s,type:h.DrawingApplyType.UPDATE})?(e.pushUndoRedo({unitID:c,undoMutations:[{id:h.SetDrawingApplyMutation.id,params:{unitId:c,subUnitId:d,op:g,objects:s,type:h.DrawingApplyType.UPDATE}},{id:G.id,params:[c]}],redoMutations:[{id:h.SetDrawingApplyMutation.id,params:{unitId:c,subUnitId:d,op:l,objects:s,type:h.DrawingApplyType.UPDATE}},{id:G.id,params:[c]}]}),!0):!1}},be={id:"sheet.command.ungroup-sheet-image",type:p.CommandType.COMMAND,handler:(i,n)=>{const r=i.get(p.ICommandService),e=i.get(p.IUndoRedoService),t=i.get(h.ISheetDrawingService);if(!n)return!1;const o=[];n.forEach(({parent:m,children:f})=>{o.push(m.unitId),f.forEach(S=>{o.push(S.unitId)})});const a=t.getUngroupDrawingOp(n),{unitId:c,subUnitId:d,undo:g,redo:l,objects:s}=a;return r.syncExecuteCommand(h.SetDrawingApplyMutation.id,{op:l,unitId:c,subUnitId:d,objects:s,type:h.DrawingApplyType.UNGROUP})?(e.pushUndoRedo({unitID:c,undoMutations:[{id:h.SetDrawingApplyMutation.id,params:{op:g,unitId:c,subUnitId:d,objects:ft(s),type:h.DrawingApplyType.GROUP}},{id:G.id,params:o}],redoMutations:[{id:h.SetDrawingApplyMutation.id,params:{op:l,unitId:c,subUnitId:d,objects:s,type:h.DrawingApplyType.UNGROUP}},{id:G.id,params:o}]}),!0):!1}};var vt=Object.defineProperty,wt=Object.getOwnPropertyDescriptor,_t=(i,n,r,e)=>{for(var t=e>1?void 0:e?wt(n,r):n,o=i.length-1,a;o>=0;o--)(a=i[o])&&(t=(e?a(n,r,t):a(t))||t);return e&&t&&vt(n,r,t),t},z=(i,n)=>(r,e)=>n(r,e,i);let ge=class extends p.Disposable{constructor(n,r,e,t,o,a,c,d,g,l,s,u){super();X(this,"_workbookSelections");this._context=n,this._skeletonManagerService=r,this._commandService=e,this._selectionRenderService=t,this._imageIoService=o,this._fileOpenerService=a,this._sheetDrawingService=c,this._drawingManagerService=d,this._contextService=g,this._messageService=l,this._localeService=s,this._workbookSelections=u.getWorkbookSelections(this._context.unitId),this._updateImageListener(),this._updateOrderListener(),this._groupDrawingListener(),this._focusDrawingListener()}async insertFloatImage(){const n=await this._fileOpenerService.openFile({multiple:!0,accept:b.DRAWING_IMAGE_ALLOW_IMAGE_LIST.map(e=>`.${e.replace("image/","")}`).join(",")}),r=n.length;return r>b.DRAWING_IMAGE_COUNT_LIMIT?(this._messageService.show({type:Z.MessageType.Error,content:this._localeService.t("update-status.exceedMaxCount",String(b.DRAWING_IMAGE_COUNT_LIMIT))}),!1):r===0?!1:(n.forEach(async e=>await this._insertFloatImage(e)),!0)}async _insertFloatImage(n){let r;try{r=await this._imageIoService.saveImage(n)}catch(M){const C=M.message;C===b.ImageUploadStatusType.ERROR_EXCEED_SIZE?this._messageService.show({type:Z.MessageType.Error,content:this._localeService.t("update-status.exceedMaxSize",String(b.DRAWING_IMAGE_ALLOW_SIZE/(1024*1024)))}):C===b.ImageUploadStatusType.ERROR_IMAGE_TYPE?this._messageService.show({type:Z.MessageType.Error,content:this._localeService.t("update-status.invalidImageType")}):C===b.ImageUploadStatusType.ERROR_IMAGE&&this._messageService.show({type:Z.MessageType.Error,content:this._localeService.t("update-status.invalidImage")})}if(r==null)return;const e=this._getUnitInfo(),{unitId:t,subUnitId:o}=e,{imageId:a,imageSourceType:c,source:d,base64Cache:g}=r,{width:l,height:s,image:u}=await b.getImageSize(g||""),{width:m,height:f}=this._context.scene;this._imageIoService.addImageSourceCache(d,c,u);let S=1;if(l>b.DRAWING_IMAGE_WIDTH_LIMIT||s>b.DRAWING_IMAGE_HEIGHT_LIMIT){const M=b.DRAWING_IMAGE_WIDTH_LIMIT/l,C=b.DRAWING_IMAGE_HEIGHT_LIMIT/s;S=Math.max(M,C)}const v=this._getImagePosition(l*S,s*S,m,f);if(v==null)return;const y={unitId:t,subUnitId:o,drawingId:a,drawingType:b.DrawingTypeEnum.DRAWING_IMAGE,imageSourceType:c,source:d,transform:Y(v,this._selectionRenderService,this._skeletonManagerService),sheetTransform:v};this._commandService.executeCommand(oe.id,{unitId:t,drawings:[y]})}_getUnitInfo(){const n=this._context.unit,r=n.getActiveSheet(),e=n.getUnitId(),t=r.getSheetId();return{unitId:e,subUnitId:t}}_getImagePosition(n,r,e,t){const o=this._workbookSelections.getCurrentSelections();let a={startRow:0,endRow:0,startColumn:0,endColumn:0};o&&o.length>0&&(a=o[o.length-1].range);const c=j.attachRangeWithCoord(this._skeletonManagerService.getCurrent().skeleton,a);if(c==null)return;let{startColumn:d,startRow:g,startX:l,startY:s}=c,u=!1;if(l+n>e&&(l=e-n,l<0&&(l=0,n=e),u=!0),s+r>t&&(s=t-r,s<0&&(s=0,r=t),u=!0),u){const v=this._selectionRenderService.getCellWithCoordByOffset(l,s);if(v==null)return;l=v.startX,s=v.startY,d=v.actualColumn,g=v.actualRow}const m={column:d,columnOffset:0,row:g,rowOffset:0},f=this._selectionRenderService.getCellWithCoordByOffset(l+n,s+r);if(f==null)return;const S={column:f.actualColumn,columnOffset:l+n-f.startX,row:f.actualRow,rowOffset:s+r-f.startY};return{from:m,to:S}}_updateOrderListener(){this.disposeWithMe(this._drawingManagerService.featurePluginOrderUpdate$.subscribe(n=>{const{unitId:r,subUnitId:e,drawingIds:t,arrangeType:o}=n;this._commandService.executeCommand(Te.id,{unitId:r,subUnitId:e,drawingIds:t,arrangeType:o})}))}_updateImageListener(){this.disposeWithMe(this._drawingManagerService.featurePluginUpdate$.subscribe(n=>{const r=[];n.length!==0&&(n.forEach(e=>{const{unitId:t,subUnitId:o,drawingId:a,drawingType:c,transform:d}=e;if(d==null)return;const g=this._sheetDrawingService.getDrawingByParam({unitId:t,subUnitId:o,drawingId:a});if(g==null||g.unitId!==this._context.unitId)return;const l=k({...g.transform,...d},this._selectionRenderService);if(l==null)return;const s={...e,transform:{...g.transform,...d,...Y(l,this._selectionRenderService,this._skeletonManagerService)},sheetTransform:{...l}};r.push(s)}),r.length>0&&this._commandService.executeCommand(ae.id,{unitId:n[0].unitId,drawings:r}))}))}_groupDrawingListener(){this.disposeWithMe(this._drawingManagerService.featurePluginGroupUpdate$.subscribe(n=>{this._commandService.executeCommand(Re.id,n);const{unitId:r,subUnitId:e,drawingId:t}=n[0].parent;this._drawingManagerService.focusDrawing([{unitId:r,subUnitId:e,drawingId:t}])})),this.disposeWithMe(this._drawingManagerService.featurePluginUngroupUpdate$.subscribe(n=>{this._commandService.executeCommand(be.id,n)}))}_focusDrawingListener(){this.disposeWithMe(this._drawingManagerService.focus$.subscribe(n=>{n==null||n.length===0?(this._contextService.setContextValue(p.FOCUSING_COMMON_DRAWINGS,!1),this._sheetDrawingService.focusDrawing([])):(this._contextService.setContextValue(p.FOCUSING_COMMON_DRAWINGS,!0),this._sheetDrawingService.focusDrawing(n))}))}};ge=_t([z(1,p.Inject(j.SheetSkeletonManagerService)),z(2,p.ICommandService),z(3,j.ISheetSelectionRenderService),z(4,b.IImageIoService),z(5,F.ILocalFileService),z(6,h.ISheetDrawingService),z(7,b.IDrawingManagerService),z(8,p.IContextService),z(9,F.IMessageService),z(10,p.Inject(p.LocaleService)),z(11,p.Inject(I.SheetsSelectionsService))],ge);const pe={id:"sheet.command.insert-float-image",type:p.CommandType.COMMAND,handler:i=>{var r,e;return(e=(r=i.get(N.IRenderManagerService).getCurrentTypeOfRenderer(p.UniverInstanceType.UNIVER_SHEET))==null?void 0:r.with(ge).insertFloatImage())!=null?e:!1}},re={id:"sheet.command.move-drawing",type:p.CommandType.COMMAND,handler:(i,n)=>{const r=i.get(p.ICommandService),e=i.get(h.ISheetDrawingService),t=i.get(j.ISheetSelectionRenderService),{direction:o}=n,a=e.getFocusDrawings();if(a.length===0)return!1;const c=a[0].unitId,d=a.map(l=>{const{transform:s}=l;if(s==null)return null;const u={...s},{left:m=0,top:f=0}=s;return o===p.Direction.UP?u.top=f-1:o===p.Direction.DOWN?u.top=f+1:o===p.Direction.LEFT?u.left=m-1:o===p.Direction.RIGHT&&(u.left=m+1),{...l,transform:u,sheetTransform:k(u,t)}}).filter(l=>l!=null);return r.syncExecuteCommand(ae.id,{unitId:c,drawings:d})?(r.syncExecuteCommand(G.id,[c]),!0):!1}},Fe="addition-and-subtraction-single",Ee="sheet.menu.image";function It(i){return{id:Ee,type:F.MenuItemType.SUBITEMS,icon:Fe,tooltip:"sheetImage.title",hidden$:F.getMenuHiddenObservable(i,p.UniverInstanceType.UNIVER_SHEET),disabled$:j.getCurrentRangeDisable$(i,{workbookTypes:[I.WorkbookEditablePermission],worksheetTypes:[I.WorksheetEditPermission],rangeTypes:[I.RangeProtectionPermissionEditPoint]})}}function Ct(i){return{id:pe.id,title:"sheetImage.upload.float",type:F.MenuItemType.BUTTON,hidden$:F.getMenuHiddenObservable(i,p.UniverInstanceType.UNIVER_SHEET)}}const q={imageCommonPanel:"univer-image-common-panel",imageCommonPanelGrid:"univer-image-common-panel-grid",imageCommonPanelBorder:"univer-image-common-panel-border",imageCommonPanelTitle:"univer-image-common-panel-title",imageCommonPanelSubtitle:"univer-image-common-panel-subtitle",imageCommonPanelRow:"univer-image-common-panel-row",imageCommonPanelRowVertical:"univer-image-common-panel-row-vertical",imageCommonPanelColumn:"univer-image-common-panel-column",imageCommonPanelColumnCenter:"univer-image-common-panel-column-center",imageCommonPanelInline:"univer-image-common-panel-inline",imageCommonPanelSpan2:"univer-image-common-panel-span2",imageCommonPanelSpan3:"univer-image-common-panel-span3",imageCommonPanelInput:"univer-image-common-panel-input",sheetImageMenu:"univer-sheet-image-menu",sheetImageMenuInput:"univer-sheet-image-menu-input"};function $e(i){var n,r,e="";if(typeof i=="string"||typeof i=="number")e+=i;else if(typeof i=="object")if(Array.isArray(i)){var t=i.length;for(n=0;n<t;n++)i[n]&&(r=$e(i[n]))&&(e&&(e+=" "),e+=r)}else for(r in i)i[r]&&(e&&(e+=" "),e+=r);return e}function he(){for(var i,n,r=0,e="",t=arguments.length;r<t;r++)(i=arguments[r])&&(n=$e(i))&&(e&&(e+=" "),e+=n);return e}const yt=i=>{var C;const n=p.useDependency(p.ICommandService),r=p.useDependency(p.LocaleService),e=p.useDependency(b.IDrawingManagerService),t=p.useDependency(N.IRenderManagerService),{drawings:o}=i,a=o[0];if(a==null)return;const{unitId:c}=a,d=t.getRenderById(c),g=d==null?void 0:d.scene;if(g==null)return;const l=g.getTransformerByCreate(),[s,u]=H.useState(!0),m=(C=a.anchorType)!=null?C:h.SheetDrawingAnchorType.Position,[f,S]=H.useState(m);function v(T,_){const D=[];return T.forEach(w=>{const{oKey:A}=w,E=_.getDrawingOKey(A);if(E==null)return D.push(null),!0;const{unitId:L,subUnitId:U,drawingId:P,drawingType:R,anchorType:B,sheetTransform:V}=E;D.push({unitId:L,subUnitId:U,drawingId:P,anchorType:B,sheetTransform:V,drawingType:R})}),D}H.useEffect(()=>{const T=l.clearControl$.subscribe(D=>{D===!0&&u(!1)}),_=l.changeStart$.subscribe(D=>{var E;const{objects:w}=D,A=v(w,e);if(A.length===0)u(!1);else if(A.length>=1){u(!0);const L=((E=A[0])==null?void 0:E.anchorType)||h.SheetDrawingAnchorType.Position;S(L)}});return()=>{_.unsubscribe(),T.unsubscribe()}},[]);function y(T){S(T);const _=e.getFocusDrawings();if(_.length===0)return;const D=_.map(w=>({unitId:w.unitId,subUnitId:w.subUnitId,drawingId:w.drawingId,anchorType:T}));n.executeCommand(ae.id,{unitId:_[0].unitId,drawings:D})}const M=T=>T?"block":"none";return $.jsxs("div",{className:he(q.imageCommonPanelGrid,q.imageCommonPanelBorder),style:{display:M(s)},children:[$.jsx("div",{className:q.imageCommonPanelRow,children:$.jsx("div",{className:he(q.imageCommonPanelColumn,q.imageCommonPanelTitle),children:$.jsx("div",{children:r.t("drawing-anchor.title")})})}),$.jsx("div",{className:he(q.imageCommonPanelRow),children:$.jsx("div",{className:he(q.imageCommonPanelColumn),children:$.jsxs(Z.RadioGroup,{value:f,onChange:y,direction:"vertical",children:[$.jsx(Z.Radio,{value:h.SheetDrawingAnchorType.Both,children:r.t("drawing-anchor.both")}),$.jsx(Z.Radio,{value:h.SheetDrawingAnchorType.Position,children:r.t("drawing-anchor.position")}),$.jsx(Z.Radio,{value:h.SheetDrawingAnchorType.None,children:r.t("drawing-anchor.none")})]})})})]})},Mt=()=>{const i=p.useDependency(b.IDrawingManagerService),n=i.getFocusDrawings(),[r,e]=H.useState(n);return H.useEffect(()=>{const t=i.focus$.subscribe(o=>{e(o)});return()=>{t.unsubscribe()}},[]),!!(r!=null&&r.length)&&$.jsxs("div",{className:q.imageCommonPanel,children:[$.jsx(ee.DrawingCommonPanel,{drawings:r}),$.jsx(yt,{drawings:r})]})},Dt={[F.RibbonStartGroup.FORMULAS_INSERT]:{[Ee]:{order:3,menuItemFactory:It,[pe.id]:{order:0,menuItemFactory:Ct}}}};function se(i){return!i.getContextValue(p.FOCUSING_FX_BAR_EDITOR)&&!i.getContextValue(p.EDITOR_ACTIVATED)&&!i.getContextValue(p.FOCUSING_PANEL_EDITOR)&&i.getContextValue(p.FOCUSING_COMMON_DRAWINGS)}const Rt={id:re.id,description:"shortcut.sheet.drawing-move-down",group:"4_sheet-drawing-view",binding:F.KeyCode.ARROW_DOWN,priority:100,preconditions:se,staticParameters:{direction:p.Direction.DOWN}},Tt={id:re.id,description:"shortcut.sheet.drawing-move-up",group:"4_sheet-drawing-view",binding:F.KeyCode.ARROW_UP,priority:100,preconditions:se,staticParameters:{direction:p.Direction.UP}},bt={id:re.id,description:"shortcut.sheet.drawing-move-left",group:"4_sheet-drawing-view",binding:F.KeyCode.ARROW_LEFT,priority:100,preconditions:se,staticParameters:{direction:p.Direction.LEFT}},Et={id:re.id,description:"shortcut.sheet.drawing-move-right",group:"4_sheet-drawing-view",binding:F.KeyCode.ARROW_RIGHT,priority:100,preconditions:se,staticParameters:{direction:p.Direction.RIGHT}},Ot={id:De.id,description:"shortcut.sheet.drawing-delete",group:"4_sheet-drawing-view",preconditions:se,binding:F.KeyCode.DELETE,mac:F.KeyCode.BACKSPACE};var Pt=Object.defineProperty,At=Object.getOwnPropertyDescriptor,Ut=(i,n,r,e)=>{for(var t=e>1?void 0:e?At(n,r):n,o=i.length-1,a;o>=0;o--)(a=i[o])&&(t=(e?a(n,r,t):a(t))||t);return e&&t&&Pt(n,r,t),t},fe=(i,n)=>(r,e)=>n(r,e,i);let Se=class extends p.Disposable{constructor(i,n,r,e){super(),this._componentManager=i,this._menuManagerService=n,this._commandService=r,this._shortcutService=e,this._init()}_initCustomComponents(){const i=this._componentManager;this.disposeWithMe(i.register(Fe,Ve)),this.disposeWithMe(i.register(We,Mt))}_initMenus(){this._menuManagerService.mergeMenu(Dt)}_initCommands(){[pe,oe,ie,ae,Ce,G,ye,Re,be,re,De,Te].forEach(i=>this.disposeWithMe(this._commandService.registerCommand(i)))}_initShortcuts(){[Rt,Tt,bt,Et,Ot].forEach(i=>{this.disposeWithMe(this._shortcutService.registerShortcut(i))})}_init(){this._initCommands(),this._initCustomComponents(),this._initMenus(),this._initShortcuts()}};Se=Ut([fe(0,p.Inject(F.ComponentManager)),fe(1,F.IMenuManagerService),fe(2,p.ICommandService),fe(3,F.IShortcutService)],Se);var Nt=Object.defineProperty,jt=Object.getOwnPropertyDescriptor,Wt=(i,n,r,e)=>{for(var t=e>1?void 0:e?jt(n,r):n,o=i.length-1,a;o>=0;o--)(a=i[o])&&(t=(e?a(n,r,t):a(t))||t);return e&&t&&Nt(n,r,t),t},Oe=(i,n)=>(r,e)=>n(r,e,i);let ve=class extends p.Disposable{constructor(n,r,e){super();X(this,"_copyInfo");this._sheetClipboardService=n,this._renderManagerService=r,this._sheetDrawingService=e,this._initCopyPaste()}_initCopyPaste(){this._sheetClipboardService.addClipboardHook({id:"SHEET_IMAGE_UI_PLUGIN",onBeforeCopy:(n,r,e)=>this._collect(n,r,e),onPasteCells:(n,r,e,t)=>{const{copyType:o=j.COPY_TYPE.COPY,pasteType:a}=t,{range:c}=n||{},{range:d,unitId:g,subUnitId:l}=r;return this._generateMutations(d,{copyType:o,pasteType:a,copyRange:c,unitId:g,subUnitId:l})},onPastePlainText:(n,r)=>({undos:[],redos:[]})})}_collect(n,r,e){var u;const t=(u=this._renderManagerService.getRenderById(n))==null?void 0:u.with(j.SheetSkeletonManagerService);if(!t)return;const o=t.attachRangeWithCoord(e);if(!o)return;const{startX:a,endX:c,startY:d,endY:g}=o,l=this._sheetDrawingService.getDrawingData(n,r),s=[];Object.keys(l).forEach(m=>{const f=l[m],{transform:S}=f;if(f.anchorType!==h.SheetDrawingAnchorType.Both||!S)return;const{left:v=0,top:y=0,width:M=0,height:C=0}=S,{drawingStartX:T,drawingEndX:_,drawingStartY:D,drawingEndY:w}={drawingStartX:v,drawingEndX:v+M,drawingStartY:y,drawingEndY:y+C};a<=T&&_<=c&&d<=D&&w<=g&&s.push(f)}),s.length&&(this._copyInfo={drawings:s,unitId:n,subUnitId:r})}_generateMutations(n,r){var E;if(!this._copyInfo)return{redos:[],undos:[]};if([j.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_COL_WIDTH,j.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_VALUE,j.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMAT,j.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMULA].includes(r.pasteType))return{redos:[],undos:[]};const{copyRange:e}=r;if(!e)return{redos:[],undos:[]};const{drawings:t,unitId:o,subUnitId:a}=this._copyInfo,{ranges:[c,d],mapFunc:g}=j.virtualizeDiscreteRanges([e,n]),{row:l,col:s}=g(c.startRow,c.startColumn),{row:u,col:m}=g(d.startRow,d.startColumn),f=(E=this._renderManagerService.getRenderById(o))==null?void 0:E.with(j.SheetSkeletonManagerService);if(!f)return{redos:[],undos:[]};const S=f.attachRangeWithCoord({startRow:l,endRow:l,startColumn:s,endColumn:s}),v=f.attachRangeWithCoord({startRow:u,endRow:u,startColumn:m,endColumn:m});if(!S||!v)return{redos:[],undos:[]};const y=[],M=[],C=v.startX-S.startX,T=v.startY-S.startY,_=u-l,D=m-s,w=r.copyType===j.COPY_TYPE.CUT,{_sheetDrawingService:A}=this;return t.forEach(L=>{const{transform:U,sheetTransform:P}=L;if(!U)return;const R={...L,unitId:o,subUnitId:a,drawingId:w?L.drawingId:p.Tools.generateRandomId(),transform:{...U,left:U.left+C,top:U.top+T},sheetTransform:{to:{...P.to,row:P.to.row+_,column:P.to.column+D},from:{...P.from,row:P.from.row+_,column:P.from.column+D}}};if(w){const{undo:B,redo:V,objects:J}=A.getBatchUpdateOp([R]);y.push({id:h.SetDrawingApplyMutation.id,params:{unitId:o,subUnitId:a,type:h.DrawingApplyType.UPDATE,op:V,objects:J}}),M.push({id:h.SetDrawingApplyMutation.id,params:{unitId:o,subUnitId:a,type:h.DrawingApplyType.UPDATE,op:B,objects:J}})}else{const{undo:B,redo:V,objects:J}=A.getBatchAddOp([R]);y.push({id:h.SetDrawingApplyMutation.id,params:{op:V,unitId:o,subUnitId:a,objects:J,type:h.DrawingApplyType.INSERT}}),M.push({id:h.SetDrawingApplyMutation.id,params:{op:B,unitId:o,subUnitId:a,objects:J,type:h.DrawingApplyType.REMOVE}})}}),{redos:y,undos:M}}};ve=Wt([Oe(0,j.ISheetClipboardService),Oe(1,N.IRenderManagerService),Oe(2,h.ISheetDrawingService)],ve);var Lt=Object.defineProperty,Bt=Object.getOwnPropertyDescriptor,Gt=(i,n,r,e)=>{for(var t=e>1?void 0:e?Bt(n,r):n,o=i.length-1,a;o>=0;o--)(a=i[o])&&(t=(e?a(n,r,t):a(t))||t);return e&&t&&Lt(n,r,t),t},ce=(i,n)=>(r,e)=>n(r,e,i);let we=class extends p.Disposable{constructor(i,n,r,e,t){super(),this._drawingManagerService=i,this._renderManagerService=n,this._permissionService=r,this._univerInstanceService=e,this._userManagerService=t,this._initDrawingVisible(),this._initDrawingEditable(),this._initViewPermissionChange(),this._initEditPermissionChange()}_initDrawingVisible(){const i=this._univerInstanceService.getCurrentTypeOfUnit$(p.UniverInstanceType.UNIVER_SHEET);this.disposeWithMe(W.combineLatest([i,this._userManagerService.currentUser$]).subscribe(([n,r])=>{if(!n){this._drawingManagerService.setDrawingVisible(!1);return}n.activeSheet$.subscribe(e=>{if(!e){this._drawingManagerService.setDrawingVisible(!1);return}const t=n.getUnitId(),o=e.getSheetId();if(this._permissionService.composePermission([new I.WorkbookViewPermission(t).id,new I.WorksheetViewPermission(t,o).id]).every(c=>c.value))this._drawingManagerService.setDrawingVisible(!0);else{this._drawingManagerService.setDrawingVisible(!1);const c=n.getUnitId(),d=e.getSheetId(),g=this._drawingManagerService.getDrawingData(c,d),l=Object.values(g),s=this._renderManagerService.getRenderById(c),u=s==null?void 0:s.scene;if(u==null)return;u.getAllObjectsByOrder().forEach(f=>{f.classType===N.RENDER_CLASS_TYPE.IMAGE&&l.some(S=>f.oKey.includes(S.drawingId))&&u.removeObject(f)})}})}))}_initDrawingEditable(){const i=this._univerInstanceService.getCurrentTypeOfUnit$(p.UniverInstanceType.UNIVER_SHEET);this.disposeWithMe(W.combineLatest([i,this._userManagerService.currentUser$]).subscribe(([n,r])=>{if(!n){this._drawingManagerService.setDrawingEditable(!1);return}n.activeSheet$.subscribe(e=>{if(!e){this._drawingManagerService.setDrawingEditable(!1);return}const t=n.getUnitId(),o=e.getSheetId();if(this._permissionService.composePermission([new I.WorkbookEditablePermission(t).id,new I.WorksheetEditPermission(t,o).id]).every(c=>c.value))this._drawingManagerService.setDrawingEditable(!0);else{this._drawingManagerService.setDrawingEditable(!1);const c=n.getUnitId(),d=e.getSheetId(),g=this._drawingManagerService.getDrawingData(c,d),l=Object.values(g),s=this._renderManagerService.getRenderById(c),u=s==null?void 0:s.scene;if(u==null)return;u.getAllObjectsByOrder().forEach(f=>{f.classType===N.RENDER_CLASS_TYPE.IMAGE&&l.some(S=>f.oKey.includes(S.drawingId))&&u.detachTransformerFrom(f)})}})}))}_initViewPermissionChange(){const i=this._univerInstanceService.getCurrentTypeOfUnit$(p.UniverInstanceType.UNIVER_SHEET);this.disposeWithMe(W.combineLatest([i,this._userManagerService.currentUser$]).subscribe(([n,r])=>{n&&n.activeSheet$.subscribe(e=>{var s;if(!e)return;const t=n.getUnitId(),o=e.getSheetId();let a=!0;const c=this._renderManagerService.getRenderById(t),d=c==null?void 0:c.scene;if(d==null)return;const g=d.getTransformerByCreate(),l=this._permissionService.composePermission$([new I.WorkbookViewPermission(t).id,new I.WorksheetViewPermission(t,o).id]).pipe(W.map(u=>u.every(m=>m.value)));l==null||l.pipe(W.filter(u=>u!==a),W.distinctUntilChanged()).subscribe({next:u=>{a=u,this._drawingManagerService.setDrawingVisible(u);const m=d.getAllObjectsByOrder(),f=this._drawingManagerService.getDrawingData(t,o),S=Object.values(f);u?this._drawingManagerService.addNotification(S):(m.forEach(v=>{v.classType===N.RENDER_CLASS_TYPE.IMAGE&&S.some(y=>v.oKey.includes(y.drawingId))&&d.removeObject(v)}),g.clearSelectedObjects())}}),(s=this._permissionService.getPermissionPoint$(new I.WorksheetViewPermission(t,o).id))==null||s.pipe(W.filter(u=>u.value!==a),W.distinctUntilChanged()).subscribe({complete:()=>{a=!0,this._drawingManagerService.setDrawingVisible(!0);const u=this._drawingManagerService.getDrawingData(t,o),m=Object.values(u);this._drawingManagerService.addNotification(m)}})})}))}_initEditPermissionChange(){const i=this._univerInstanceService.getCurrentTypeOfUnit$(p.UniverInstanceType.UNIVER_SHEET);this.disposeWithMe(W.combineLatest([i,this._userManagerService.currentUser$]).subscribe(([n,r])=>{n&&n.activeSheet$.subscribe(e=>{var s;if(!e)return;const t=n.getUnitId(),o=e.getSheetId();let a=!0;const c=this._renderManagerService.getRenderById(t),d=c==null?void 0:c.scene;if(d==null)return;const g=d.getTransformerByCreate(),l=this._permissionService.composePermission$([new I.WorkbookEditablePermission(t).id,new I.WorksheetEditPermission(t,o).id]).pipe(W.map(u=>u.every(m=>m.value)));l==null||l.pipe(W.filter(u=>u!==a),W.distinctUntilChanged()).subscribe({next:u=>{a=u,this._drawingManagerService.setDrawingEditable(u);const m=d.getAllObjectsByOrder(),f=this._drawingManagerService.getDrawingData(t,o),S=Object.values(f);u?(m.forEach(v=>{v.classType===N.RENDER_CLASS_TYPE.IMAGE&&S.some(y=>v.oKey.includes(y.drawingId))&&d.attachTransformerTo(v)}),this._drawingManagerService.addNotification(S)):(m.forEach(v=>{v.classType===N.RENDER_CLASS_TYPE.IMAGE&&S.some(y=>v.oKey.includes(y.drawingId))&&d.detachTransformerFrom(v)}),g.clearSelectedObjects())}}),(s=this._permissionService.getPermissionPoint$(new I.WorksheetEditPermission(t,o).id))==null||s.pipe(W.filter(u=>u.value!==a),W.distinctUntilChanged()).subscribe({complete:()=>{a=!0;const u=n.getUnitId(),m=e.getSheetId(),f=this._drawingManagerService.getDrawingData(u,m),S=Object.values(f),v=this._renderManagerService.getRenderById(u),y=v==null?void 0:v.scene;if(y==null)return;this._drawingManagerService.setDrawingEditable(!0),y.getAllObjectsByOrder().forEach(C=>{C.classType===N.RENDER_CLASS_TYPE.IMAGE&&S.some(T=>C.oKey.includes(T.drawingId))&&y.detachTransformerFrom(C)})}})})}))}};we=Gt([ce(0,b.IDrawingManagerService),ce(1,N.IRenderManagerService),ce(2,p.IPermissionService),ce(3,p.IUniverInstanceService),ce(4,p.Inject(p.UserManagerService))],we);var kt=Object.defineProperty,Vt=Object.getOwnPropertyDescriptor,Ft=(i,n,r,e)=>{for(var t=e>1?void 0:e?Vt(n,r):n,o=i.length-1,a;o>=0;o--)(a=i[o])&&(t=(e?a(n,r,t):a(t))||t);return e&&t&&kt(n,r,t),t},_e=(i,n)=>(r,e)=>n(r,e,i);let Ie=class extends p.Disposable{constructor(i,n,r,e){super(),this._sheetPrintInterceptorService=i,this._drawingRenderService=n,this._drawingManagerService=r,this._renderManagerService=e,this._initPrinting()}_initPrinting(){this.disposeWithMe(this._sheetPrintInterceptorService.interceptor.intercept(this._sheetPrintInterceptorService.interceptor.getInterceptPoints().PRINTING_COMPONENT_COLLECT,{handler:(i,n,r)=>{const{unitId:e,scene:t,subUnitId:o}=n,a=this._drawingManagerService.getDrawingDataForUnit(e),c=a==null?void 0:a[o];return c&&c.order.forEach(d=>{this._drawingRenderService.renderDrawing(c.data[d],t)}),r()}})),this.disposeWithMe(this._sheetPrintInterceptorService.interceptor.intercept(this._sheetPrintInterceptorService.interceptor.getInterceptPoints().PRINTING_RANGE,{handler:(i,n,r)=>{const{unitId:e,subUnitId:t}=n,o=this._renderManagerService.getRenderById(e);if(!o)return r(i);const a=o.with(j.SheetSkeletonManagerService).getWorksheetSkeleton(t);if(!a)return r(i);const c=this._drawingManagerService.getDrawingDataForUnit(e),d=c==null?void 0:c[n.subUnitId];if(!d)return r(i);const{scaleX:g,scaleY:l}=o.scene,s=i?{...i}:{startColumn:0,endColumn:0,endRow:0,startRow:0},u=d.order.map(m=>d.data[m]).filter(m=>m.drawingType!==b.DrawingTypeEnum.DRAWING_DOM);return u.length?(u.forEach(m=>{if(!m.groupId&&m.transform&&p.Tools.isDefine(m.transform.left)&&p.Tools.isDefine(m.transform.top)&&p.Tools.isDefine(m.transform.width)&&p.Tools.isDefine(m.transform.height)){const f=a.skeleton.getCellIndexByOffset(m.transform.left,m.transform.top,g,l,{x:0,y:0}),S=a.skeleton.getCellIndexByOffset(m.transform.left+m.transform.width,m.transform.top+m.transform.height,g,l,{x:0,y:0});f.column<s.startColumn&&(s.startColumn=f.column),f.row<s.startRow&&(s.startRow=f.row),s.endRow<S.row&&(s.endRow=S.row),s.endColumn<S.column&&(s.endColumn=S.column)}}),r(s)):r(i)}}))}};Ie=Ft([_e(0,p.Inject(j.SheetPrintInterceptorService)),_e(1,p.Inject(ee.DrawingRenderService)),_e(2,b.IDrawingManagerService),_e(3,N.IRenderManagerService)],Ie);var $t=Object.defineProperty,Yt=Object.getOwnPropertyDescriptor,Ht=(i,n,r,e)=>{for(var t=e>1?void 0:e?Yt(n,r):n,o=i.length-1,a;o>=0;o--)(a=i[o])&&(t=(e?a(n,r,t):a(t))||t);return e&&t&&$t(n,r,t),t},Q=(i,n)=>(r,e)=>n(r,e,i);const xt=[I.InsertRowCommand.id,I.InsertColCommand.id,I.RemoveRowCommand.id,I.RemoveColCommand.id,I.DeleteRangeMoveLeftCommand.id,I.DeleteRangeMoveUpCommand.id,I.InsertRangeMoveDownCommand.id,I.InsertRangeMoveRightCommand.id,I.DeltaRowHeightCommand.id,I.SetRowHeightCommand.id,I.DeltaColumnWidthCommand.id,I.SetColWidthCommand.id,I.SetRowHiddenCommand.id,I.SetSpecificRowsVisibleCommand.id,I.SetSpecificColsVisibleCommand.id,I.SetColHiddenCommand.id,I.MoveColsCommand.id,I.MoveRowsCommand.id,I.MoveRangeCommand.id],Xt=[I.SetRowVisibleMutation.id,I.SetRowHiddenMutation.id,I.SetColVisibleMutation.id,I.SetColHiddenMutation.id,I.SetWorksheetRowHeightMutation.id,I.SetWorksheetColWidthMutation.id];let Pe=class extends p.Disposable{constructor(i,n,r,e,t,o,a,c,d){super(),this._context=i,this._renderManagerService=n,this._commandService=r,this._selectionRenderService=e,this._skeletonManagerService=t,this._sheetInterceptorService=o,this._sheetDrawingService=a,this._drawingManagerService=c,this._univerInstanceService=d,this._sheetInterceptorListener(),this._commandListener(),this._sheetRefreshListener()}_sheetInterceptorListener(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:i=>{if(!xt.includes(i.id))return{redos:[],undos:[]};if(i.params==null)return{redos:[],undos:[]};const n=i.id;if(n===I.InsertRowCommand.id)return this._moveRowInterceptor(i.params,"insert");if([I.MoveColsCommand.id,I.MoveRowsCommand.id,I.MoveRangeCommand.id].includes(n))return this._moveRangeInterceptor(i.params);if(n===I.InsertColCommand.id)return this._moveColInterceptor(i.params,"insert");if(n===I.RemoveRowCommand.id)return this._moveRowInterceptor(i.params,"remove");if(n===I.RemoveColCommand.id)return this._moveColInterceptor(i.params,"remove");if(n===I.DeleteRangeMoveLeftCommand.id){const{range:r}=i.params;return this._getRangeMoveUndo(r,0)}else if(n===I.DeleteRangeMoveUpCommand.id){const{range:r}=i.params;return this._getRangeMoveUndo(r,1)}else if(n===I.InsertRangeMoveDownCommand.id){const{range:r}=i.params;return this._getRangeMoveUndo(r,2)}else if(n===I.InsertRangeMoveRightCommand.id){const{range:r}=i.params;return this._getRangeMoveUndo(r,3)}else if(n===I.SetRowHiddenCommand.id||n===I.SetSpecificRowsVisibleCommand.id){const r=i.params,{unitId:e,subUnitId:t,ranges:o}=r;return this._getDrawingUndoForRowVisible(e,t,o)}else if(n===I.SetSpecificColsVisibleCommand.id||n===I.SetColHiddenCommand.id){const r=i.params,{unitId:e,subUnitId:t,ranges:o}=r;return this._getDrawingUndoForColVisible(e,t,o)}else if(n===I.DeltaRowHeightCommand.id||n===I.SetRowHeightCommand.id||n===I.DeltaColumnWidthCommand.id||n===I.SetColWidthCommand.id){const r=i.params,{unitId:e,subUnitId:t,ranges:o}=r,a=n===I.DeltaRowHeightCommand.id||n===I.SetRowHeightCommand.id;return this._getDrawingUndoForRowAndColSize(e,t,o,a)}return{redos:[],undos:[]}}}))}_getRangeMoveUndo(i,n){const r=I.getSheetCommandTarget(this._univerInstanceService);if(r==null)return{redos:[],undos:[]};const e=r.unitId,t=r.subUnitId,o=[],a=[],c=this._sheetDrawingService.getDrawingData(e,t),d=[],g=[];if(Object.keys(c).forEach(l=>{const s=c[l],{updateDrawings:u,deleteDrawings:m}=this._getUpdateOrDeleteDrawings(i,n,s);d.push(...u),g.push(...m)}),d.length===0&&g.length===0)return{redos:[],undos:[]};if(d.length>0){const l=this._sheetDrawingService.getBatchUpdateOp(d),{undo:s,redo:u,objects:m}=l;o.push({id:h.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:u,objects:m,type:h.DrawingApplyType.UPDATE}}),a.push({id:h.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:s,objects:m,type:h.DrawingApplyType.UPDATE}})}if(g.length>0){const l=this._sheetDrawingService.getBatchRemoveOp(g),s=l.undo,u=l.redo,m=l.objects;o.push({id:h.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:u,objects:m,type:h.DrawingApplyType.REMOVE}}),a.push({id:h.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:s,objects:m,type:h.DrawingApplyType.INSERT}})}return o.push({id:G.id,params:[e]}),a.push({id:G.id,params:[e]}),{redos:o,undos:a}}_getUpdateOrDeleteDrawings(i,n,r){const e=[],t=[],{sheetTransform:o,anchorType:a=h.SheetDrawingAnchorType.Position,transform:c,unitId:d,subUnitId:g,drawingId:l}=r,{from:s,to:u}=o,{row:m,column:f}=s,{row:S,column:v}=u;if(o==null||c==null)return{updateDrawings:e,deleteDrawings:t};const{startRow:y,endRow:M,startColumn:C,endColumn:T}=i;let _=null,D=null;if(n===0&&m>=y&&S<=M)if(f>=C&&v<=T)t.push({unitId:d,subUnitId:g,drawingId:l});else{const w=this._shrinkCol(o,c,C,T,a);_=w==null?void 0:w.newSheetTransform,D=w==null?void 0:w.newTransform}else if(n===1&&f>=C&&v<=T)if(m>=y&&S<=M)t.push({unitId:d,subUnitId:g,drawingId:l});else{const w=this._shrinkRow(o,c,y,M,a);_=w==null?void 0:w.newSheetTransform,D=w==null?void 0:w.newTransform}else if(n===2){const w=this._expandRow(o,c,y,M,a);_=w==null?void 0:w.newSheetTransform,D=w==null?void 0:w.newTransform}else if(n===3){const w=this._expandCol(o,c,C,T,a);_=w==null?void 0:w.newSheetTransform,D=w==null?void 0:w.newTransform}if(_!=null&&D!=null){const w=Y(_,this._selectionRenderService,this._skeletonManagerService);e.push({...r,sheetTransform:_,transform:w})}return{updateDrawings:e,deleteDrawings:t}}_remainDrawingSize(i,n,r){const e=k({...i},this._selectionRenderService);e!=null&&n.push({...r,sheetTransform:e})}_getDrawingUndoForColVisible(i,n,r){const e=this._drawingManagerService.getDrawingData(i,n),t=[],o=[];if(Object.keys(e).forEach(l=>{const s=e[l],{sheetTransform:u,transform:m,anchorType:f=h.SheetDrawingAnchorType.Position}=s;if(f===h.SheetDrawingAnchorType.None)this._remainDrawingSize(m,t,s);else{const{from:S,to:v}=u,{row:y,column:M}=S,{row:C,column:T}=v;for(let _=0;_<r.length;_++){const D=r[_],{startRow:w,endRow:A,startColumn:E,endColumn:L}=D;if(T<E)continue;if(f===h.SheetDrawingAnchorType.Position){let R=null,B=null;if(M>=E&&M<=L){const V=this._skeletonManagerService.attachRangeWithCoord({startColumn:M,endColumn:L,startRow:S.row,endRow:v.row});if(V==null)return;B={...m,left:V.startX}}if(B!=null&&(R=k(B,this._selectionRenderService),R!=null&&B!=null)){t.push({...s,sheetTransform:R,transform:B});break}this._remainDrawingSize(m,t,s);continue}if(M>=E&&T<=L)continue;let U=null,P=null;if(M>=E&&M<=L){const R=this._skeletonManagerService.attachRangeWithCoord({startColumn:M,endColumn:L,startRow:S.row,endRow:v.row});if(R==null)return;P={...m,left:(R==null?void 0:R.startX)||0,width:((m==null?void 0:m.width)||0)-R.endX+R.startX}}else if(T>=E&&T<=L){const R=this._skeletonManagerService.attachRangeWithCoord({startColumn:E,endColumn:T,startRow:S.row,endRow:v.row});if(R==null)return;P={...m,left:R.startX-((m==null?void 0:m.width)||0)}}else{const R=this._skeletonManagerService.attachRangeWithCoord({startColumn:E,endColumn:L,startRow:S.row,endRow:v.row});if(R==null)return;if(P={...m,width:((m==null?void 0:m.width)||0)-R.endX+R.startX},U=k(P,this._selectionRenderService),U!=null&&P!=null){o.push({...s,sheetTransform:U,transform:P});break}}if(P!=null&&(U=k(P,this._selectionRenderService)),P!=null&&U!=null){t.push({...s,sheetTransform:U,transform:P});break}else this._remainDrawingSize(m,t,s)}}}),t.length===0&&o.length===0)return{redos:[],undos:[]};const{redos:a,undos:c}=this._createUndoAndRedoMutation(i,n,t),d=[],g=[];if(o.length>0){const{redos:l,undos:s}=this._createUndoAndRedoMutation(i,n,o);d.push(...l),g.push(...s)}return{redos:a,undos:c,preRedos:d,preUndos:g}}_createUndoAndRedoMutation(i,n,r){const e=this._sheetDrawingService.getBatchUpdateOp(r),{undo:t,redo:o,objects:a}=e,c=[{id:h.SetDrawingApplyMutation.id,params:{unitId:i,subUnitId:n,op:o,objects:a,type:h.DrawingApplyType.UPDATE}},{id:G.id,params:[i]}],d=[{id:h.SetDrawingApplyMutation.id,params:{unitId:i,subUnitId:n,op:t,objects:a,type:h.DrawingApplyType.UPDATE}},{id:G.id,params:[i]}];return{redos:c,undos:d}}_getDrawingUndoForRowVisible(i,n,r){const e=this._drawingManagerService.getDrawingData(i,n),t=[],o=[];if(Object.keys(e).forEach(l=>{const s=e[l],{sheetTransform:u,transform:m,anchorType:f=h.SheetDrawingAnchorType.Position}=s;if(f===h.SheetDrawingAnchorType.None)this._remainDrawingSize(m,t,s);else{const{from:S,to:v}=u,{row:y,column:M}=S,{row:C,column:T}=v;for(let _=0;_<r.length;_++){const D=r[_],{startRow:w,endRow:A,startColumn:E,endColumn:L}=D;if(C<w)continue;if(f===h.SheetDrawingAnchorType.Position){let R=null,B=null;if(y>=w&&y<=A){const V=this._skeletonManagerService.attachRangeWithCoord({startColumn:S.column,endColumn:v.column,startRow:y,endRow:A});if(V==null)return;B={...m,top:V.startY}}if(B!=null&&(R=k(B,this._selectionRenderService),R!=null&&B!=null)){t.push({...s,sheetTransform:R,transform:B});break}this._remainDrawingSize(m,t,s);continue}if(y>=w&&C<=A)continue;let U=null,P=null;if(y>=w&&y<=A){const R=this._skeletonManagerService.attachRangeWithCoord({startColumn:S.column,endColumn:v.column,startRow:y,endRow:A});if(R==null)return;P={...m,top:(R==null?void 0:R.startY)||0,height:((m==null?void 0:m.height)||0)-R.endY+R.startY}}else if(C>=w&&C<=A){const R=this._skeletonManagerService.attachRangeWithCoord({startColumn:S.column,endColumn:v.column,startRow:w,endRow:C});if(R==null)return;P={...m,top:R.startY-((m==null?void 0:m.height)||0)}}else{const R=this._skeletonManagerService.attachRangeWithCoord({startColumn:S.column,endColumn:v.column,startRow:w,endRow:A});if(R==null)return;if(P={...m,height:((m==null?void 0:m.height)||0)-R.endY+R.startY},U=k(P,this._selectionRenderService),U!=null&&P!=null){o.push({...s,sheetTransform:U,transform:P});break}}if(P!=null&&(U=k(P,this._selectionRenderService)),P!=null&&U!=null){t.push({...s,sheetTransform:U,transform:P});break}else this._remainDrawingSize(m,t,s)}}}),t.length===0&&o.length===0)return{redos:[],undos:[]};const{redos:a,undos:c}=this._createUndoAndRedoMutation(i,n,t),d=[],g=[];if(o.length>0){const{redos:l,undos:s}=this._createUndoAndRedoMutation(i,n,o);d.push(...l),g.push(...s)}return{redos:a,undos:c,preRedos:d,preUndos:g}}_getDrawingUndoForRowAndColSize(i,n,r,e){const t=this._drawingManagerService.getDrawingData(i,n),o=[];return Object.keys(t).forEach(a=>{const c=t[a],{sheetTransform:d,transform:g,anchorType:l=h.SheetDrawingAnchorType.Position}=c;if(l===h.SheetDrawingAnchorType.None)this._remainDrawingSize(g,o,c);else{const{from:s,to:u}=d,{row:m,column:f}=s,{row:S,column:v}=u;for(let y=0;y<r.length;y++){const M=r[y],{startRow:C,endRow:T,startColumn:_,endColumn:D}=M;if(S<C||v<_)continue;if(l===h.SheetDrawingAnchorType.Position&&(m<=C&&S>=T||f<=_&&v>=D)){this._remainDrawingSize(g,o,c);continue}const w=Y({...d},this._selectionRenderService,this._skeletonManagerService);if(w!=null){o.push({...c,transform:w});break}}}}),o.length===0?{redos:[],undos:[]}:this._createUndoAndRedoMutation(i,n,o)}_getUnitIdAndSubUnitId(i,n){let r,e;if(n==="insert")r=i.unitId,e=i.subUnitId;else{const t=I.getSheetCommandTarget(this._univerInstanceService);if(t==null)return;r=t.unitId,e=t.subUnitId}return{unitId:r,subUnitId:e}}_moveRangeInterceptor(i){var C,T;const{toRange:n,fromRange:r}=i,e=I.getSheetCommandTarget(this._univerInstanceService);if(!e)return{redos:[],undos:[]};const{unitId:t,subUnitId:o}=e,a=(T=(C=this._renderManagerService.getRenderById(t))==null?void 0:C.with(j.SheetSkeletonManagerService))==null?void 0:T.getCurrentSkeleton();if(!a)return{redos:[],undos:[]};const c=j.attachRangeWithCoord(a,r);if(!c)return{redos:[],undos:[]};const{startX:d,endX:g,startY:l,endY:s}=c,u=this._sheetDrawingService.getDrawingData(t,o),m=[];Object.keys(u).forEach(_=>{const D=u[_];if(D.anchorType!==h.SheetDrawingAnchorType.Both)return;const{transform:w}=D;if(!w)return;const{left:A=0,top:E=0,width:L=0,height:U=0}=w,{drawingStartX:P,drawingEndX:R,drawingStartY:B,drawingEndY:V}={drawingStartX:A,drawingEndX:A+L,drawingStartY:E,drawingEndY:E+U};d<=P&&R<=g&&l<=B&&V<=s&&m.push(D)});const f=[],S=[],v=n.startRow-r.startRow,y=n.startColumn-r.startColumn,M=m.map(_=>{const D=_.sheetTransform,w={to:{...D.to,row:D.to.row+v,column:D.to.column+y},from:{...D.from,row:D.from.row+v,column:D.from.column+y}},A=Y(w,this._selectionRenderService,this._skeletonManagerService);return{unitId:t,subUnitId:o,drawingId:_.drawingId,transform:A,sheetTransform:w}});if(M.length){const _=this._sheetDrawingService.getBatchUpdateOp(M),{undo:D,redo:w,objects:A}=_;f.push({id:h.SetDrawingApplyMutation.id,params:{unitId:t,subUnitId:o,op:w,objects:A,type:h.DrawingApplyType.UPDATE}}),S.push({id:h.SetDrawingApplyMutation.id,params:{unitId:t,subUnitId:o,op:D,objects:A,type:h.DrawingApplyType.UPDATE}})}return{redos:f,undos:S}}_moveRowInterceptor(i,n){const r=this._getUnitIdAndSubUnitId(i,n);if(r==null)return{redos:[],undos:[]};const{unitId:e,subUnitId:t}=r,{range:o}=i,a=o.startRow,c=o.endRow,d=[],g=[],l=this._sheetDrawingService.getDrawingData(e,t),s=[],u=[];if(Object.keys(l).forEach(m=>{const f=l[m],{sheetTransform:S,transform:v,anchorType:y=h.SheetDrawingAnchorType.Position}=f;if(S==null||v==null)return;let M,C;if(n==="insert"){const _=this._expandRow(S,v,a,c,y);M=_==null?void 0:_.newSheetTransform,C=_==null?void 0:_.newTransform}else{const{from:_,to:D}=S,{row:w}=_,{row:A}=D;if(y===h.SheetDrawingAnchorType.Both&&w>=a&&A<=c)u.push({unitId:e,subUnitId:t,drawingId:m});else{const E=this._shrinkRow(S,v,a,c,y);M=E==null?void 0:E.newSheetTransform,C=E==null?void 0:E.newTransform}}if(!M||!C)return;const T={unitId:e,subUnitId:t,drawingId:m,transform:C,sheetTransform:M};s.push(T)}),s.length===0&&u.length===0)return{redos:[],undos:[]};if(s.length>0){const m=this._sheetDrawingService.getBatchUpdateOp(s),{undo:f,redo:S,objects:v}=m;d.push({id:h.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:S,objects:v,type:h.DrawingApplyType.UPDATE}}),g.push({id:h.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:f,objects:v,type:h.DrawingApplyType.UPDATE}})}if(u.length>0){const m=this._sheetDrawingService.getBatchRemoveOp(u),f=m.undo,S=m.redo,v=m.objects;d.push({id:h.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:S,objects:v,type:h.DrawingApplyType.REMOVE}}),g.push({id:h.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:f,objects:v,type:h.DrawingApplyType.INSERT}})}return d.push({id:G.id,params:[e]}),g.push({id:G.id,params:[e]}),{redos:d,undos:g}}_moveColInterceptor(i,n){const r=this._getUnitIdAndSubUnitId(i,n);if(r==null)return{redos:[],undos:[]};const{unitId:e,subUnitId:t}=r,{range:o}=i,a=o.startColumn,c=o.endColumn,d=[],g=[],l=this._sheetDrawingService.getDrawingData(e,t),s=[],u=[];if(Object.keys(l).forEach(m=>{const f=l[m],{sheetTransform:S,transform:v,anchorType:y=h.SheetDrawingAnchorType.Position}=f;if(S==null||v==null)return;let M,C;if(n==="insert"){const _=this._expandCol(S,v,a,c,y);M=_==null?void 0:_.newSheetTransform,C=_==null?void 0:_.newTransform}else{const{from:_,to:D}=S,{column:w}=_,{column:A}=D;if(y===h.SheetDrawingAnchorType.Both&&w>=a&&A<=c)u.push({unitId:e,subUnitId:t,drawingId:m});else{const E=this._shrinkCol(S,v,a,c,y);M=E==null?void 0:E.newSheetTransform,C=E==null?void 0:E.newTransform}}if(!M||!C)return;const T={unitId:e,subUnitId:t,drawingId:m,transform:C,sheetTransform:M};s.push(T)}),s.length===0&&u.length===0)return{redos:[],undos:[]};if(s.length>0){const m=this._sheetDrawingService.getBatchUpdateOp(s),{undo:f,redo:S,objects:v}=m;d.push({id:h.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:S,objects:v,type:h.DrawingApplyType.UPDATE}}),g.push({id:h.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:f,objects:v,type:h.DrawingApplyType.UPDATE}})}if(u.length>0){const m=this._sheetDrawingService.getBatchRemoveOp(u),f=m.undo,S=m.redo,v=m.objects;d.push({id:h.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:S,objects:v,type:h.DrawingApplyType.REMOVE}}),g.push({id:h.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:f,objects:v,type:h.DrawingApplyType.INSERT}})}return d.push({id:G.id,params:[e]}),g.push({id:G.id,params:[e]}),{redos:d,undos:g}}_expandCol(i,n,r,e,t=h.SheetDrawingAnchorType.Position){const o=e-r+1,{from:a,to:c}=i,{column:d}=a,{column:g}=c;if(t===h.SheetDrawingAnchorType.None)return{newSheetTransform:k({...n},this._selectionRenderService),newTransform:n};let l=null,s=null;if(d>=r){const u=this._skeletonManagerService.attachRangeWithCoord({startColumn:r,endColumn:e,startRow:a.row,endRow:c.row});if(u==null)return;s={...n,left:(n.left||0)+u.endX-u.startX},l=k(s,this._selectionRenderService)}else if(g>=e)if(t===h.SheetDrawingAnchorType.Both)l={from:{...a},to:{...c,column:g+o}},s=Y(l,this._selectionRenderService,this._skeletonManagerService);else return{newSheetTransform:k({...n},this._selectionRenderService),newTransform:n};return l!=null&&s!=null?{newSheetTransform:l,newTransform:s}:null}_shrinkCol(i,n,r,e,t=h.SheetDrawingAnchorType.Position){const o=e-r+1,{from:a,to:c}=i,{column:d}=a,{column:g}=c;if(t===h.SheetDrawingAnchorType.None)return{newSheetTransform:k({...n},this._selectionRenderService),newTransform:n};let l=null,s=null;if(d>e)l={from:{...a,column:d-o},to:{...c,column:g-o}},s=Y(l,this._selectionRenderService,this._skeletonManagerService);else{if(d>=r&&g<=e)return null;if(d<r&&g>e)if(t===h.SheetDrawingAnchorType.Both)l={from:{...a},to:{...c,column:g-o}},s=Y(l,this._selectionRenderService,this._skeletonManagerService);else return{newSheetTransform:k({...n},this._selectionRenderService),newTransform:n};else if(d>=r&&d<=e){if(d===r)s={...n,left:(n.left||0)-i.from.columnOffset};else{const u=this._skeletonManagerService.attachRangeWithCoord({startColumn:r,endColumn:d-1,startRow:a.row,endRow:c.row});if(u==null)return;s={...n,left:(n.left||0)-u.endX+u.startX-i.from.columnOffset}}l=k(s,this._selectionRenderService)}else if(g>=r&&g<=e&&t===h.SheetDrawingAnchorType.Both){const u=this._skeletonManagerService.attachRangeWithCoord({startColumn:r-1,endColumn:r-1,startRow:a.row,endRow:c.row});if(u==null)return;l={from:{...a},to:{...c,column:r-1,columnOffset:u.endX-u.startX}},s=Y(l,this._selectionRenderService,this._skeletonManagerService)}}return l!=null&&s!=null?{newSheetTransform:l,newTransform:s}:null}_expandRow(i,n,r,e,t=h.SheetDrawingAnchorType.Position){const o=e-r+1,{from:a,to:c}=i,{row:d}=a,{row:g}=c;if(t===h.SheetDrawingAnchorType.None)return{newSheetTransform:k({...n},this._selectionRenderService),newTransform:n};let l=null,s=null;if(d>=r){const u=this._skeletonManagerService.attachRangeWithCoord({startRow:r,endRow:e,startColumn:a.column,endColumn:c.column});if(u==null)return;s={...n,top:(n.top||0)+u.endY-u.startY},l=k(s,this._selectionRenderService)}else if(g>=e)if(t===h.SheetDrawingAnchorType.Both)l={from:{...a},to:{...c,row:g+o}},s=Y(l,this._selectionRenderService,this._skeletonManagerService);else return{newSheetTransform:k({...n},this._selectionRenderService),newTransform:n};return l!=null&&s!=null?{newSheetTransform:l,newTransform:s}:null}_shrinkRow(i,n,r,e,t=h.SheetDrawingAnchorType.Position){const o=e-r+1,{from:a,to:c}=i,{row:d}=a,{row:g}=c;if(t===h.SheetDrawingAnchorType.None)return{newSheetTransform:k({...n},this._selectionRenderService),newTransform:n};let l=null,s=null;if(d>e)l={from:{...a,row:d-o},to:{...c,row:g-o}},s=Y(l,this._selectionRenderService,this._skeletonManagerService);else{if(d>=r&&g<=e)return null;if(d<r&&g>e)if(t===h.SheetDrawingAnchorType.Both)l={from:{...a},to:{...c,row:g-o}},s=Y(l,this._selectionRenderService,this._skeletonManagerService);else return{newSheetTransform:k({...n},this._selectionRenderService),newTransform:n};else if(d>=r&&d<=e){if(d===r)s={...n,top:(n.top||0)-i.from.rowOffset};else{const u=this._skeletonManagerService.attachRangeWithCoord({startRow:r,endRow:d-1,startColumn:a.column,endColumn:c.column});if(u==null)return;s={...n,top:(n.top||0)-u.endY+u.startY-i.from.rowOffset}}l=k(s,this._selectionRenderService)}else if(g>=r&&g<=e&&t===h.SheetDrawingAnchorType.Both){const u=this._skeletonManagerService.attachRangeWithCoord({startColumn:a.column,endColumn:a.column,startRow:r-1,endRow:r-1});if(u==null)return;l={from:{...a},to:{...c,row:r-1,rowOffset:u.endY-u.startY}},s=Y(l,this._selectionRenderService,this._skeletonManagerService)}}return l!=null&&s!=null?{newSheetTransform:l,newTransform:s}:null}_commandListener(){this.disposeWithMe(this._commandService.onCommandExecuted(i=>{i.id===I.SetWorksheetActiveOperation.id&&setTimeout(()=>{const n=i.params,{unitId:r,subUnitId:e}=n,t=this._drawingManagerService.drawingManagerData,o=[],a=[];Object.keys(t).forEach(c=>{const d=t[c];d!=null&&Object.keys(d).forEach(g=>{const l=d[g].data;l!=null&&Object.keys(l).forEach(s=>{if(c===r&&g===e){const u=l[s];u.transform=Y(u.sheetTransform,this._selectionRenderService,this._skeletonManagerService),o.push(l[s])}else a.push(l[s])})})}),this._drawingManagerService.removeNotification(a),this._drawingManagerService.addNotification(o)},0)}))}_sheetRefreshListener(){this.disposeWithMe(this._commandService.onCommandExecuted(i=>{Xt.includes(i.id)&&requestIdleCallback(()=>{const n=i.params,{unitId:r,subUnitId:e,ranges:t}=n;this._refreshDrawingTransform(r,e,t)})}))}_refreshDrawingTransform(i,n,r){const e=this._drawingManagerService.getDrawingData(i,n),t=[];Object.keys(e).forEach(o=>{const a=e[o],{sheetTransform:c,transform:d,anchorType:g=h.SheetDrawingAnchorType.Position}=a;if(g===h.SheetDrawingAnchorType.None)return!0;const{from:l,to:s}=c,{row:u,column:m}=l,{row:f,column:S}=s;for(let v=0;v<r.length;v++){const y=r[v],{startRow:M,endRow:C,startColumn:T,endColumn:_}=y;if(p.Rectangle.intersects({startRow:M,endRow:C,startColumn:T,endColumn:_},{startRow:u,endRow:f,startColumn:m,endColumn:S})||u>C||m>_){const D=g===h.SheetDrawingAnchorType.Position,w=Y(c,this._selectionRenderService,this._skeletonManagerService);t.push({...a,transform:{...w,width:D?d==null?void 0:d.width:w==null?void 0:w.width,height:D?d==null?void 0:d.height:w==null?void 0:w.height}});break}}}),t.length!==0&&(this._drawingManagerService.refreshTransform(t),this._commandService.syncExecuteCommand(G.id,[i]))}};Pe=Ht([Q(1,N.IRenderManagerService),Q(2,p.ICommandService),Q(3,j.ISheetSelectionRenderService),Q(4,p.Inject(j.SheetSkeletonManagerService)),Q(5,p.Inject(I.SheetInterceptorService)),Q(6,h.ISheetDrawingService),Q(7,b.IDrawingManagerService),Q(8,p.IUniverInstanceService)],Pe);var Kt=Object.defineProperty,zt=Object.getOwnPropertyDescriptor,Jt=(i,n,r,e)=>{for(var t=e>1?void 0:e?zt(n,r):n,o=i.length-1,a;o>=0;o--)(a=i[o])&&(t=(e?a(n,r,t):a(t))||t);return e&&t&&Kt(n,r,t),t},ne=(i,n)=>(r,e)=>n(r,e,i);function Zt(i,n,r,e){const{scaleX:t,scaleY:o}=n.getAncestorScale(),a=n.getViewport(N.SHEET_VIEWPORT_KEY.VIEW_MAIN),c={left:!0,top:!0};if(!a)return{...i,absolute:c};const{left:d,right:g,top:l,bottom:s}=i,u=e.getFreeze(),{startColumn:m,startRow:f,xSplit:S,ySplit:v}=u,y=r.getNoMergeCellPositionByIndexWithNoHeader(f-v,m-S),M=r.getNoMergeCellPositionByIndexWithNoHeader(f,m),{rowHeaderWidth:C,columnHeaderHeight:T}=r,_=M.startX-y.startX,D=M.startY-y.startY,{top:w,left:A,viewportScrollX:E,viewportScrollY:L}=a;let U,P;d<A?(c.left=!0,U=(_+C+(d-A))*t,P=Math.max(Math.min((_+C+(g-A))*t,(_+C)*t),(g-E)*t)):(c.left=!1,U=Math.max((d-E)*t,(_+C)*t),P=Math.max((g-E)*t,(_+C)*t));let R,B;return l<w?(c.top=!0,R=(D+T+(l-w))*o,B=Math.max(Math.min((D+T+(g-w))*o,(D+T)*o),(s-L)*o)):(c.top=!1,R=Math.max((l-L)*o,(D+T)*o),B=Math.max((s-L)*o,(D+T)*o)),{left:U,right:P,top:R,bottom:B,absolute:c}}const Ae=(i,n,r,e)=>{const{scene:t}=n,{left:o,top:a,width:c,height:d,angle:g}=i,l={left:o,right:o+c,top:a,bottom:a+d},s=Zt(l,t,r,e),{scaleX:u,scaleY:m}=t.getAncestorScale();return{startX:s.left,endX:s.right,startY:s.top,endY:s.bottom,rotate:g,width:c*u,height:d*m,absolute:s.absolute}};O.SheetCanvasFloatDomManagerService=class extends p.Disposable{constructor(r,e,t,o,a,c,d){super();X(this,"_domLayerMap",new Map);X(this,"_domLayerInfoMap",new Map);X(this,"_transformChange$",new W.Subject);X(this,"transformChange$",this._transformChange$.asObservable());X(this,"_add$",new W.Subject);X(this,"add$",this._add$.asObservable());X(this,"_remove$",new W.Subject);X(this,"remove$",this._remove$.asObservable());X(this,"_hooks",[]);this._renderManagerService=r,this._univerInstanceService=e,this._commandService=t,this._drawingManagerService=o,this._canvasFloatDomService=a,this._sheetDrawingService=c,this._lifecycleService=d,this._drawingAddListener(),this._featureUpdateListener(),this._deleteListener(),this._bindScrollEvent()}_bindScrollEvent(){this._lifecycleService.lifecycle$.pipe(W.filter(r=>r===p.LifecycleStages.Rendered),W.take(1)).subscribe(()=>{this._scrollUpdateListener()})}_ensureMap(r,e){let t=this._domLayerMap.get(r);t||(t=new Map,this._domLayerMap.set(r,t));let o=t.get(e);return o||(o=new Map,t.set(e,o)),o}getFloatDomInfo(r){return this._domLayerInfoMap.get(r)}_getSceneAndTransformerByDrawingSearch(r){if(r==null)return;const e=this._renderManagerService.getRenderById(r),t=e==null?void 0:e.scene;if(e==null||t==null)return null;const o=t.getTransformerByCreate(),a=e.engine.getCanvasElement();return{scene:t,transformer:o,renderObject:e,canvas:a}}_getFloatDomProps(r){let e;return this._hooks.forEach(t=>{e=t.onGetFloatDomProps(r)}),e}_drawingAddListener(){this.disposeWithMe(this._drawingManagerService.add$.subscribe(r=>{r.forEach(e=>{var Xe,Ke,ze;const{unitId:t,subUnitId:o,drawingId:a}=e,c=I.getSheetCommandTarget(this._univerInstanceService,{unitId:t,subUnitId:o}),d=this._drawingManagerService.getDrawingByParam(e),g=this._univerInstanceService.getUnit(t);if(!g)return;const l=g.getActiveSheet().getSheetId();if(!d||!c)return;const s=(Xe=this._renderManagerService.getRenderById(t))==null?void 0:Xe.with(j.SheetSkeletonManagerService).getWorksheetSkeleton(o);if(!s)return;const{transform:u,drawingType:m,data:f}=d;if(m!==b.DrawingTypeEnum.DRAWING_DOM&&m!==b.DrawingTypeEnum.DRAWING_CHART)return;const S=this._getSceneAndTransformerByDrawingSearch(t);if(S==null)return;const{scene:v,canvas:y}=S;if(u==null)return!0;if(l!==o)return;const{left:M,top:C,width:T,height:_,angle:D,flipX:w,flipY:A,skewX:E,skewY:L}=u,U=b.getDrawingShapeKeyByDrawingSearch({unitId:t,subUnitId:o,drawingId:a}),P=v.getObject(U);if(P!=null){P.transformByState({left:M,top:C,width:T,height:_,angle:D,flipX:w,flipY:A,skewX:E,skewY:L});return}const R={left:M,top:C,width:T,height:_,zIndex:this._drawingManagerService.getDrawingOrder(t,o).length-1},B=m===b.DrawingTypeEnum.DRAWING_CHART;B&&(R.fill="white",R.rotateEnabled=!1,f&&f.border&&(R.stroke=f.border),R.paintFirst="stroke",R.strokeWidth=1,R.borderEnabled=!1,R.radius=8);const V=new N.Rect(U,R);B&&V.setObjectType(N.ObjectType.CHART),v.addObject(V,N.DRAWING_OBJECT_LAYER_INDEX),d.allowTransform!==!1&&v.attachTransformerTo(V);const J=this._ensureMap(t,o),Ne=new p.DisposableCollection,nn=Ae(V,S.renderObject,s.skeleton,c.worksheet),je=new W.BehaviorSubject(nn),rn={dispose:Ne,rect:V,position$:je,unitId:t,subUnitId:o};this._canvasFloatDomService.addFloatDom({position$:je,id:a,componentKey:d.componentKey,onPointerDown:x=>{y.dispatchEvent(new PointerEvent(x.type,x))},onPointerMove:x=>{y.dispatchEvent(new PointerEvent(x.type,x))},onPointerUp:x=>{y.dispatchEvent(new PointerEvent(x.type,x))},onWheel:x=>{y.dispatchEvent(new WheelEvent(x.type,x))},props:(ze=(Ke=J.get(a))==null?void 0:Ke.props)!=null?ze:this._getFloatDomProps(a),data:f,unitId:t});const xe=V.onTransformChange$.subscribeEvent(()=>{const x=Ae(V,S.renderObject,s.skeleton,c.worksheet);je.next(x)});Ne.add(()=>{this._canvasFloatDomService.removeFloatDom(a)}),xe&&Ne.add(xe),this._domLayerInfoMap.set(a,rn),J.set(a,{...J.get(a)})})})),this.disposeWithMe(this._drawingManagerService.remove$.subscribe(r=>{r.forEach(e=>{const{unitId:t,subUnitId:o,drawingId:a}=e,c=b.getDrawingShapeKeyByDrawingSearch({unitId:t,subUnitId:o,drawingId:a}),d=this._getSceneAndTransformerByDrawingSearch(t);if(d==null)return;const{transformer:g,scene:l}=d,s=l.getObject(c);s!=null&&s.oKey&&g.clearControlByIds([s==null?void 0:s.oKey])})}))}_scrollUpdateListener(){const r=(e,t)=>{var l;const o=this._getSceneAndTransformerByDrawingSearch(e),a=this._ensureMap(e,t),c=Array.from(a.keys()),d=I.getSheetCommandTarget(this._univerInstanceService,{unitId:e,subUnitId:t}),g=(l=this._renderManagerService.getRenderById(e))==null?void 0:l.with(j.SheetSkeletonManagerService).getWorksheetSkeleton(t);!o||!d||!g||c.forEach(s=>{const u=this._domLayerInfoMap.get(s);if(u){const m=Ae(u.rect,o.renderObject,g.skeleton,d.worksheet);u.position$.next(m)}})};this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(p.UniverInstanceType.UNIVER_SHEET).pipe(W.filter(e=>!!e),W.switchMap(e=>e.activeSheet$),W.filter(e=>!!e),W.map(e=>{const t=this._renderManagerService.getRenderById(e.getUnitId());return t?{render:t,unitId:e.getUnitId(),subUnitId:e.getSheetId()}:null}),W.filter(e=>!!e),W.switchMap(e=>p.fromEventSubject(e.render.scene.getViewport(j.VIEWPORT_KEY.VIEW_MAIN).onScrollAfter$).pipe(W.map(()=>({unitId:e.unitId,subUnitId:e.subUnitId}))))).subscribe(({unitId:e,subUnitId:t})=>{r(e,t)})),this.disposeWithMe(this._commandService.onCommandExecuted(e=>{var t,o;if(e.id===j.SetZoomRatioOperation.id){const a=e.params,{unitId:c}=a;Array.from((o=(t=this._domLayerMap.get(c))==null?void 0:t.keys())!=null?o:[]).forEach(g=>{r(c,g)})}else if(e.id===I.SetFrozenMutation.id){const{unitId:a,subUnitId:c}=e.params;r(a,c)}}))}_getPosition(r,e){var m;const{startX:t,endX:o,startY:a,endY:c}=r,d=(m=this._renderManagerService.getRenderById(e))==null?void 0:m.with(j.ISheetSelectionRenderService);if(d==null)return;const g=d.getCellWithCoordByOffset(t,a);if(g==null)return;const l={column:g.actualColumn,columnOffset:t-g.startX,row:g.actualRow,rowOffset:a-g.startY},s=d.getCellWithCoordByOffset(o,c);if(s==null)return;const u={column:s.actualColumn,columnOffset:o-s.startX,row:s.actualRow,rowOffset:c-s.startY};return{from:l,to:u}}_featureUpdateListener(){this.disposeWithMe(this._drawingManagerService.update$.subscribe(r=>{r.forEach(e=>{const t=this._drawingManagerService.getDrawingByParam(e);if(!t||t.drawingType!==b.DrawingTypeEnum.DRAWING_DOM&&t.drawingType!==b.DrawingTypeEnum.DRAWING_CHART)return;const o={...t.transform};this._transformChange$.next({id:e.drawingId,value:o})})}))}_deleteListener(){this.disposeWithMe(this._drawingManagerService.remove$.subscribe(r=>{r.forEach(e=>{this._removeDom(e.drawingId)})}))}updateFloatDomProps(r,e,t,o){const a=this._domLayerInfoMap.get(t),c=this._getSceneAndTransformerByDrawingSearch(r);if(a&&c){const{scene:d}=c,g=b.getDrawingShapeKeyByDrawingSearch({unitId:r,subUnitId:e,drawingId:t}),l=d.getObject(g);l&&l instanceof N.Rect&&l.setProps(o)}}addFloatDomToPosition(r,e){const t=I.getSheetCommandTarget(this._univerInstanceService,{unitId:r.unitId,subUnitId:r.subUnitId});if(!t)throw new Error("cannot find current target!");const{unitId:o,subUnitId:a}=t,{initPosition:c,componentKey:d,data:g,allowTransform:l=!0}=r,s=e!=null?e:p.generateRandomId(),u=this._getPosition(c,o);if(u==null)return;this._ensureMap(o,a).set(s,r);const f={unitId:o,subUnitId:a,drawingId:s,drawingType:r.type||b.DrawingTypeEnum.DRAWING_DOM,componentKey:d,sheetTransform:u,transform:{left:c.startX,top:c.startY,width:c.endX-c.startX,height:c.endY-c.startY},data:g,allowTransform:l};return this._commandService.executeCommand(oe.id,{unitId:o,drawings:[f]}),this._add$.next({unitId:o,subUnitId:a,id:s}),{id:s,dispose:()=>{this._removeDom(s,!0)}}}_removeDom(r,e=!1){const t=this._domLayerInfoMap.get(r);if(!t)return;const{unitId:o,subUnitId:a}=t;this._domLayerInfoMap.delete(r),t.dispose.dispose();const c=this._getSceneAndTransformerByDrawingSearch(o);if(c&&c.scene.removeObject(t.rect),e){this._ensureMap(o,a).delete(r);const g=this._drawingManagerService.getDrawingByParam({unitId:o,subUnitId:a,drawingId:r});if(!g)return;const l=this._sheetDrawingService.getBatchRemoveOp([g]),{redo:s,objects:u}=l;this._commandService.syncExecuteCommand(h.SetDrawingApplyMutation.id,{unitId:o,subUnitId:a,op:s,objects:u,type:h.DrawingApplyType.REMOVE})}}addHook(r){return this._hooks.push(r),{dispose:()=>{const e=this._hooks.findIndex(t=>t===r);this._hooks.splice(e,1)}}}},O.SheetCanvasFloatDomManagerService=Jt([ne(0,p.Inject(N.IRenderManagerService)),ne(1,p.IUniverInstanceService),ne(2,p.Inject(p.ICommandService)),ne(3,b.IDrawingManagerService),ne(4,p.Inject(F.CanvasFloatDomService)),ne(5,h.ISheetDrawingService),ne(6,p.Inject(p.LifecycleService))],O.SheetCanvasFloatDomManagerService);var Ye=Object.defineProperty,qt=Object.getOwnPropertyDescriptor,Qt=(i,n,r)=>n in i?Ye(i,n,{enumerable:!0,configurable:!0,writable:!0,value:r}):i[n]=r,en=(i,n,r,e)=>{for(var t=e>1?void 0:e?qt(n,r):n,o=i.length-1,a;o>=0;o--)(a=i[o])&&(t=(e?a(n,r,t):a(t))||t);return e&&t&&Ye(n,r,t),t},Ue=(i,n)=>(r,e)=>n(r,e,i),He=(i,n,r)=>Qt(i,typeof n!="symbol"?n+"":n,r);const tn="SHEET_IMAGE_UI_PLUGIN";O.UniverSheetsDrawingUIPlugin=class extends p.Plugin{constructor(n=Ze,r,e,t){super(),this._config=n,this._injector=r,this._renderManagerService=e,this._configService=t;const{menu:o,...a}=this._config;o&&this._configService.setConfig("menu",o,{merge:!0}),this._configService.setConfig(Je,a)}onStarting(){p.registerDependencies(this._injector,[[O.SheetCanvasFloatDomManagerService],[Se],[ue],[Ie],[we],[ve]]),p.touchDependencies(this._injector,[[O.SheetCanvasFloatDomManagerService]])}onReady(){p.touchDependencies(this._injector,[[ve]])}onRendered(){this._registerRenderModules(),p.touchDependencies(this._injector,[[we],[Ie],[Se]])}onSteady(){this._injector.get(ue)}_registerRenderModules(){[[ge],[Pe],[Me]].forEach(n=>{this.disposeWithMe(this._renderManagerService.registerRenderModule(p.UniverInstanceType.UNIVER_SHEET,n))})}},He(O.UniverSheetsDrawingUIPlugin,"type",p.UniverInstanceType.UNIVER_SHEET),He(O.UniverSheetsDrawingUIPlugin,"pluginName",tn),O.UniverSheetsDrawingUIPlugin=en([p.DependentOn(b.UniverDrawingPlugin,ee.UniverDrawingUIPlugin,h.UniverSheetsDrawingPlugin),Ue(1,p.Inject(p.Injector)),Ue(2,N.IRenderManagerService),Ue(3,p.IConfigService)],O.UniverSheetsDrawingUIPlugin),O.ClearSheetDrawingTransformerOperation=G,O.DeleteDrawingsCommand=De,O.EditSheetDrawingOperation=ye,O.GroupSheetDrawingCommand=Re,O.IMAGE_MENU_ID=Ee,O.InsertFloatImageCommand=pe,O.InsertSheetDrawingCommand=oe,O.MoveDrawingsCommand=re,O.RemoveSheetDrawingCommand=ie,O.SetDrawingArrangeCommand=Te,O.SetSheetDrawingCommand=ae,O.SidebarSheetDrawingOperation=Ce,O.UngroupSheetDrawingCommand=be,Object.defineProperty(O,Symbol.toStringTag,{value:"Module"})});
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"})});
31
31
 
32
32
 
33
33
  // @univerjs/sheets-drawing-ui/facade
@@ -35,4 +35,4 @@
35
35
 
36
36
 
37
37
  // index
38
- (function(e,i){typeof exports=="object"&&typeof module<"u"?i(exports,require("@univerjs/drawing"),require("@univerjs/drawing-ui"),require("@univerjs/sheets-drawing"),require("@univerjs/sheets-drawing-ui")):typeof define=="function"&&define.amd?define(["exports","@univerjs/drawing","@univerjs/drawing-ui","@univerjs/sheets-drawing","@univerjs/sheets-drawing-ui"],i):(e=typeof globalThis<"u"?globalThis:e||self,i(e.UniverPresetSheetsDrawing={},e.UniverDrawing,e.UniverDrawingUi,e.UniverSheetsDrawing,e.UniverSheetsDrawingUi))})(this,function(e,i,n,r,s){"use strict";function t(u={}){const{collaboration:g=!1}=u;return{plugins:[[i.UniverDrawingPlugin,{override:g?[[i.IImageIoService,null]]:[]}],n.UniverDrawingUIPlugin,r.UniverSheetsDrawingPlugin,s.UniverSheetsDrawingUIPlugin].filter(v=>!!v)}}e.UniverSheetsDrawingPreset=t,Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})});
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"})});
@@ -0,0 +1,10 @@
1
+ // @univerjs/drawing-ui/locale/fr-FR
2
+ (function(e,r){typeof exports=="object"&&typeof module<"u"?module.exports=r():typeof define=="function"&&define.amd?define(r):(e=typeof globalThis<"u"?globalThis:e||self,e.UniverDrawingUiFrFR=r())})(this,function(){"use strict";return{"image-popup":{replace:"Remplacer",delete:"Supprimer",edit:"Modifier",crop:"Rogner",reset:"Réinitialiser la taille"},"image-cropper":{error:"Impossible de rogner des objets non image."},"image-panel":{arrange:{title:"Arranger",forward:"Avancer",backward:"Reculer",front:"Mettre au premier plan",back:"Mettre à l'arrière-plan"},transform:{title:"Transformer",rotate:"Pivoter (°)",x:"X (px)",y:"Y (px)",width:"Largeur (px)",height:"Hauteur (px)",lock:"Verrouiller le ratio (%)"},crop:{title:"Rogner",start:"Commencer à rogner",mode:"Libre"},group:{title:"Grouper",group:"Grouper",reGroup:"Regrouper",unGroup:"Dégrouper"},align:{title:"Aligner",default:"Sélectionner le type d'alignement",left:"Aligner à gauche",center:"Aligner au centre",right:"Aligner à droite",top:"Aligner en haut",middle:"Aligner au milieu",bottom:"Aligner en bas",horizon:"Distribuer horizontalement",vertical:"Distribuer verticalement"},null:"Aucune sélection d'objet"}}});
3
+
4
+
5
+ // @univerjs/sheets-drawing-ui/locale/fr-FR
6
+ (function(e,i){typeof exports=="object"&&typeof module<"u"?module.exports=i():typeof define=="function"&&define.amd?define(i):(e=typeof globalThis<"u"?globalThis:e||self,e.UniverSheetsDrawingUiFrFR=i())})(this,function(){"use strict";return{sheetImage:{title:"Image",upload:{float:"Image flottante",cell:"Image de cellule"},panel:{title:"Modifier l'image"}},"image-popup":{replace:"Remplacer",delete:"Supprimer",edit:"Éditer",crop:"Rogner",reset:"Réinitialiser la taille"},"drawing-anchor":{title:"Propriétés de l'ancre",both:"Déplacer et redimensionner avec les cellules",position:"Déplacer mais ne pas redimensionner avec les cellules",none:"Ne pas déplacer ni redimensionner avec les cellules"},"update-status":{exceedMaxSize:"La taille de l'image dépasse la limite, la limite est de {0}M",invalidImageType:"Type d'image invalide",exceedMaxCount:"Seulement {0} images peuvent être téléchargées à la fois",invalidImage:"Image invalide"},"sheet-drawing-view":"Dessin",shortcut:{sheet:{"drawing-move-down":"Déplacer le dessin vers le bas","drawing-move-up":"Déplacer le dessin vers le haut","drawing-move-left":"Déplacer le dessin vers la gauche","drawing-move-right":"Déplacer le dessin vers la droite","drawing-delete":"Supprimer le dessin"}}}});
7
+
8
+
9
+ // locale/fr-FR
10
+ (function(e,r){typeof exports=="object"&&typeof module<"u"?module.exports=r(require("@univerjs/core"),require("@univerjs/drawing-ui/locale/fr-FR"),require("@univerjs/sheets-drawing-ui/locale/fr-FR")):typeof define=="function"&&define.amd?define(["@univerjs/core","@univerjs/drawing-ui/locale/fr-FR","@univerjs/sheets-drawing-ui/locale/fr-FR"],r):(e=typeof globalThis<"u"?globalThis:e||self,e.UniverPresetSheetsDrawingFrFR=r(e.UniverCore,e.UniverDrawingUiFrFR,e.UniverSheetsDrawingUiFrFR))})(this,function(e,r,i){"use strict";return e.Tools.deepMerge({},r,i)});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@univerjs/preset-sheets-drawing",
3
- "version": "0.5.0",
3
+ "version": "0.5.1",
4
4
  "private": false,
5
5
  "description": "",
6
6
  "author": "DreamNum <developer@univer.ai>",
@@ -20,6 +20,7 @@
20
20
  "keywords": [
21
21
  "univer"
22
22
  ],
23
+ "sideEffects": false,
23
24
  "exports": {
24
25
  ".": {
25
26
  "import": "./lib/es/index.js",
@@ -54,18 +55,19 @@
54
55
  "rxjs": ">=7.0.0"
55
56
  },
56
57
  "dependencies": {
57
- "@univerjs/drawing": "0.5.0",
58
- "@univerjs/drawing-ui": "0.5.0",
59
- "@univerjs/sheets-drawing": "0.5.0",
60
- "@univerjs/sheets-drawing-ui": "0.5.0"
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"
61
63
  },
62
64
  "devDependencies": {
63
- "@univerjs/core": "0.5.0",
64
- "typescript": "^5.6.3",
65
- "@univerjs-infra/shared": "0.5.0"
65
+ "@univerjs/core": "0.5.1",
66
+ "typescript": "^5.7.2",
67
+ "@univerjs-infra/shared": "0.5.1"
66
68
  },
67
69
  "scripts": {
68
- "prebuild": "tsx prepare.ts",
70
+ "prebuild:preset": "tsx prepare.ts",
69
71
  "build:preset": "tsx build.ts"
70
72
  },
71
73
  "module": "./lib/es/index.js"