@univerjs/drawing-ui 0.6.0 → 0.6.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";var en=Object.defineProperty;var nn=(a,t,n)=>t in a?en(a,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):a[t]=n;var Q=(a,t,n)=>nn(a,typeof t!="symbol"?t+"":t,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const C=require("@univerjs/core"),M=require("@univerjs/drawing"),y=require("@univerjs/engine-render"),G=require("@univerjs/ui"),c=require("react/jsx-runtime"),_=require("react"),W=require("@univerjs/design"),Me=require("rxjs");function tn(a,t,n,e){const r=e.getDrawingByParam(a);if(r==null)return;const i=M.getDrawingShapeKeyByDrawingSearch(a),s=n.getObject(i);if(s&&!(s instanceof y.Group))return;if(s!=null){s.addObject(t);return}const o=new y.Group(i);n.addObject(o,y.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 Te(a,t){var i;const n=t?a.getUnit(t):a.getFocusedUnit();if(n==null)return;const e=n.getUnitId();let r;return n.type===C.UniverInstanceType.UNIVER_SHEET?r=(i=n.getActiveSheet())==null?void 0:i.getSheetId():(n.type===C.UniverInstanceType.UNIVER_DOC||n.type===C.UniverInstanceType.UNIVER_SLIDE)&&(r=e),{unitId:e,subUnitId:r,current:n}}const Be="COMPONENT_IMAGE_VIEWER";var rn=Object.getOwnPropertyDescriptor,an=(a,t,n,e)=>{for(var r=e>1?void 0:e?rn(t,n):t,i=a.length-1,s;i>=0;i--)(s=a[i])&&(r=s(r)||r);return r},Pe=(a,t)=>(n,e)=>t(n,e,a);const xe=50;exports.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:i,imageSourceType:s,srcRect:o,prstGeom:l,groupId:g,unitId:d,subUnitId:u,drawingId:h,isMultiTransform:f,transforms:S}=t;if(r!==C.DrawingTypeEnum.DRAWING_IMAGE||!this._drawingManagerService.getDrawingVisible()||e==null)return;const v=f&&S?S:[e],p=[];for(const b of v){const{left:I,top:O,width:P,height:B,angle:D,flipX:R,flipY:j,skewX:N,skewY:U}=b,V=v.indexOf(b),A=M.getDrawingShapeKeyByDrawingSearch({unitId:d,subUnitId:u,drawingId:h},f?V:void 0),ne=n.getObject(A);if(ne!=null){ne.transformByState({left:I,top:O,width:P,height:B,angle:D,flipX:R,flipY:j,skewX:N,skewY:U});continue}const z=this._drawingManagerService.getDrawingOrder(d,u),oe=z.indexOf(h),te={...b,zIndex:oe===-1?z.length-1:oe},re=this._imageIoService.getImageSourceCache(i,s);let ce=!1;if(re!=null)te.image=re;else{if(s===M.ImageSourceType.UUID)try{te.url=await this._imageIoService.getImage(i)}catch(be){console.error(be);continue}else te.url=i;ce=!0}if(n.getObject(A))continue;te.printable=!0;const q=new y.Image(A,te);ce&&this._imageIoService.addImageSourceCache(i,s,q.getNative()),this._drawingManagerService.getDrawingVisible()&&(n.addObject(q,y.DRAWING_OBJECT_LAYER_INDEX),this._drawingManagerService.getDrawingEditable()&&n.attachTransformerTo(q),g&&tn({drawingId:g,unitId:d,subUnitId:u},q,n,this._drawingManagerService),l!=null&&q.setPrstGeom(l),o!=null&&q.setSrcRect(o),p.push(q))}return p}renderDrawing(t,n){const e=this._drawingManagerService.getDrawingByParam(t);if(e!=null)switch(e.drawingType){case C.DrawingTypeEnum.DRAWING_IMAGE:return this.renderImages(e,n)}}previewImage(t,n,e,r){const i=`${t}-viewer-dialog`,s=window.innerWidth-xe,o=window.innerHeight-xe,l=this._adjustImageSize(e,r,s,o),g=this._dialogService.open({width:Math.max(l.width,200),id:i,style:{margin:"0",top:"50%",left:"50%",transform:"translate(-50%, -50%)"},children:{label:{name:Be,props:{src:n,width:l.width,height:l.height}}},destroyOnClose:!0,draggable:!1,onClose:()=>{this._dialogService.close(i),g.dispose()}})}_adjustImageSize(t,n,e,r){if(t<=e&&n<=r)return{width:t,height:n};const i=e/t,s=r/n,o=Math.min(i,s);return{width:Math.floor(t*o),height:Math.floor(n*o)}}};exports.DrawingRenderService=an([Pe(0,M.IDrawingManagerService),Pe(1,M.IImageIoService),Pe(2,G.IDialogService)],exports.DrawingRenderService);function fe(a,t){const n=[];return a.forEach(e=>{const{oKey:r,left:i,top:s,height:o,width:l,angle:g}=e,d=t.getDrawingOKey(r);if(d==null)return n.push(null),!0;const{unitId:u,subUnitId:h,drawingId:f,drawingType:S}=d,v={unitId:u,subUnitId:h,drawingId:f,drawingType:S,transform:{left:i,top:s,height:o,width:l,angle:g}};S===C.DrawingTypeEnum.DRAWING_IMAGE&&(v.srcRect=e.srcRect),n.push(v)}),n}function Ue(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=Ue(a[t]))&&(e&&(e+=" "),e+=n)}else for(n in a)a[n]&&(e&&(e+=" "),e+=n);return e}function T(){for(var a,t,n=0,e="",r=arguments.length;n<r;n++)(a=arguments[n])&&(t=Ue(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 ye={id:"sheet.operation.set-image-align",type:C.CommandType.OPERATION,handler:(a,t)=>!0},sn="univer-image-common-panel-grid",on="univer-image-common-panel-border",cn="univer-image-common-panel-title",ln="univer-image-common-panel-row",gn="univer-image-common-panel-row-vertical",mn="univer-image-common-panel-column",dn="univer-image-common-panel-column-center",un="univer-image-common-panel-inline",hn="univer-image-common-panel-span2",fn="univer-image-common-panel-span3",pn="univer-image-common-panel-input",m={imageCommonPanelGrid:sn,imageCommonPanelBorder:on,imageCommonPanelTitle:cn,imageCommonPanelRow:ln,imageCommonPanelRowVertical:gn,imageCommonPanelColumn:mn,imageCommonPanelColumnCenter:dn,imageCommonPanelInline:un,imageCommonPanelSpan2:hn,imageCommonPanelSpan3:fn,imageCommonPanelInput:pn},Cn=a=>{const t=G.useDependency(C.ICommandService),n=G.useDependency(C.LocaleService),{alignShow:e}=a,[r,i]=_.useState(x.default),s=[{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){i(g),t.executeCommand(ye.id,{alignType:g})}const l=g=>g?"block":"none";return c.jsxs("div",{className:T(m.imageCommonPanelGrid,m.imageCommonPanelBorder),style:{display:l(e)},children:[c.jsx("div",{className:m.imageCommonPanelRow,children:c.jsx("div",{className:T(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:T(m.imageCommonPanelColumn),children:c.jsx(W.Select,{value:r,options:s,onChange:o})})})]})};var K=function(){return K=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},K.apply(this,arguments)},wn=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,i=a.extend,s=wn(a,["icon","id","className","extend"]),o="univerjs-icon univerjs-icon-".concat(e," ").concat(r||"").trim(),l=_.useRef("_".concat(_n()));return Ae(n,"".concat(e),{defIds:n.defIds,idSuffix:l.current},K({ref:t,className:o},s),i)});function Ae(a,t,n,e,r){return _.createElement(a.tag,K(K({key:t},vn(a,n,r)),e),(Sn(a,n).children||[]).map(function(i,s){return Ae(i,"".concat(t,"-").concat(a.tag,"-").concat(s),n,void 0,r)}))}function vn(a,t,n){var e=K({},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(i){var s=i[0],o=i[1];typeof o=="string"&&(e[s]=o.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))})),e}function Sn(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)?K(K({},a),{children:a.children.map(function(r){return typeof r.attrs.id=="string"&&e&&e.indexOf(r.attrs.id)>-1?K(K({},r),{attrs:K(K({},r.attrs),{id:r.attrs.id+t.idSuffix})}):r})}):a}function _n(){return Math.random().toString(36).substring(2,8)}X.displayName="UniverIcon";var In={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"}}]},Le=_.forwardRef(function(a,t){return _.createElement(X,Object.assign({},a,{id:"autofill",ref:t,icon:In}))});Le.displayName="Autofill";var yn={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"}}]},He=_.forwardRef(function(a,t){return _.createElement(X,Object.assign({},a,{id:"bottom-single",ref:t,icon:yn}))});He.displayName="BottomSingle";var bn={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"}}]},Ge=_.forwardRef(function(a,t){return _.createElement(X,Object.assign({},a,{id:"create-copy-single",ref:t,icon:bn}))});Ge.displayName="CreateCopySingle";var Pn={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"}}]},Ve=_.forwardRef(function(a,t){return _.createElement(X,Object.assign({},a,{id:"group-single",ref:t,icon:Pn}))});Ve.displayName="GroupSingle";var Rn={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=_.forwardRef(function(a,t){return _.createElement(X,Object.assign({},a,{id:"more-down-single",ref:t,icon:Rn}))});ke.displayName="MoreDownSingle";var Dn={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"}}]},We=_.forwardRef(function(a,t){return _.createElement(X,Object.assign({},a,{id:"move-down-single",ref:t,icon:Dn}))});We.displayName="MoveDownSingle";var jn={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"}}]},$e=_.forwardRef(function(a,t){return _.createElement(X,Object.assign({},a,{id:"move-up-single",ref:t,icon:jn}))});$e.displayName="MoveUpSingle";var Mn={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"}}]},ze=_.forwardRef(function(a,t){return _.createElement(X,Object.assign({},a,{id:"topmost-single",ref:t,icon:Mn}))});ze.displayName="TopmostSingle";var xn={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"}}]},Ke=_.forwardRef(function(a,t){return _.createElement(X,Object.assign({},a,{id:"ungroup-single",ref:t,icon:xn}))});Ke.displayName="UngroupSingle";const On=a=>{const{arrangeShow:t,drawings:n}=a,e=G.useDependency(C.LocaleService),r=G.useDependency(M.IDrawingManagerService),i=g=>g?"block":"none",[s,o]=_.useState(n);_.useEffect(()=>{const g=r.focus$.subscribe(d=>{o(d)});return()=>{g.unsubscribe()}},[]);const l=g=>{const d=s[0].unitId,u=s[0].subUnitId,h=s.map(f=>f.drawingId);r.featurePluginOrderUpdateNotification({unitId:d,subUnitId:u,drawingIds:h,arrangeType:g})};return c.jsxs("div",{className:m.imageCommonPanelGrid,style:{display:i(t)},children:[c.jsx("div",{className:m.imageCommonPanelRow,children:c.jsx("div",{className:T(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:T(m.imageCommonPanelColumn,m.imageCommonPanelSpan2),children:c.jsx(W.Button,{size:"small",onClick:()=>{l(C.ArrangeTypeEnum.forward)},children:c.jsxs("span",{className:m.imageCommonPanelInline,children:[c.jsx($e,{}),e.t("image-panel.arrange.forward")]})})}),c.jsx("div",{className:T(m.imageCommonPanelColumn,m.imageCommonPanelSpan2),children:c.jsx(W.Button,{size:"small",onClick:()=>{l(C.ArrangeTypeEnum.backward)},children:c.jsxs("span",{className:m.imageCommonPanelInline,children:[c.jsx(We,{}),e.t("image-panel.arrange.backward")]})})})]}),c.jsxs("div",{className:m.imageCommonPanelRow,children:[c.jsx("div",{className:T(m.imageCommonPanelColumn,m.imageCommonPanelSpan2),children:c.jsx(W.Button,{size:"small",onClick:()=>{l(C.ArrangeTypeEnum.front)},children:c.jsxs("span",{className:m.imageCommonPanelInline,children:[c.jsx(ze,{}),e.t("image-panel.arrange.front")]})})}),c.jsx("div",{className:T(m.imageCommonPanelColumn,m.imageCommonPanelSpan2),children:c.jsx(W.Button,{size:"small",onClick:()=>{l(C.ArrangeTypeEnum.back)},children:c.jsxs("span",{className:m.imageCommonPanelInline,children:[c.jsx(He,{}),e.t("image-panel.arrange.back")]})})})]})]})},Nn=a=>{const t=G.useDependency(C.LocaleService),n=G.useDependency(y.IRenderManagerService),e=G.useDependency(M.IDrawingManagerService),{hasGroup:r,drawings:i}=a,[s,o]=_.useState(!1),[l,g]=_.useState(!0),[d,u]=_.useState(!0),h=p=>p?"block":"none",f=()=>{const p=e.getFocusDrawings(),{unitId:b,subUnitId:I}=p[0],O=C.Tools.generateRandomId(10),P=y.getGroupState(0,0,p.map(R=>R.transform||{})),B={unitId:b,subUnitId:I,drawingId:O,drawingType:C.DrawingTypeEnum.DRAWING_GROUP,transform:P},D=p.map(R=>{const j=R.transform||{left:0,top:0},{unitId:N,subUnitId:U,drawingId:V}=R;return{unitId:N,subUnitId:U,drawingId:V,transform:{...j,left:j.left-P.left,top:j.top-P.top},groupId:O}});e.featurePluginGroupUpdateNotification([{parent:B,children:D}])},S=p=>{if(p.drawingType!==C.DrawingTypeEnum.DRAWING_GROUP)return;const{unitId:b,subUnitId:I,drawingId:O,transform:P={width:0,height:0}}=p;if(P==null)return;const B=e.getDrawingsByGroup({unitId:b,subUnitId:I,drawingId:O});if(B.length===0)return;const D=B.map(R=>{const{transform:j}=R,{unitId:N,subUnitId:U,drawingId:V}=R,A=y.transformObjectOutOfGroup(j||{},P,P.width||0,P.height||0);return{unitId:N,subUnitId:U,drawingId:V,transform:{...j,...A},groupId:void 0}});return{parent:p,children:D}},v=()=>{const b=e.getFocusDrawings().map(I=>S(I)).filter(I=>I!=null);b.length!==0&&e.featurePluginUngroupUpdateNotification(b)};return _.useEffect(()=>{const p=i[0];if(p==null)return;const{unitId:b}=p,I=n.getRenderById(b),O=I==null?void 0:I.scene;if(O==null)return;const P=O.getTransformerByCreate(),B=P.clearControl$.subscribe(R=>{R===!0&&o(!1)}),D=P.changeStart$.subscribe(R=>{const{objects:j}=R,N=fe(j,e),U=N.filter(z=>(z==null?void 0:z.drawingType)===C.DrawingTypeEnum.DRAWING_GROUP);let V=!1,A=!1;N.length>1&&(V=!0),U.length>0&&(A=!0),o(V||A),g(V),u(A)});return()=>{D.unsubscribe(),B.unsubscribe()}},[]),c.jsxs("div",{className:T(m.imageCommonPanelGrid,m.imageCommonPanelBorder),style:{display:h(r===!0?s:!1)},children:[c.jsx("div",{className:m.imageCommonPanelRow,children:c.jsx("div",{className:T(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:T(m.imageCommonPanelColumn,m.imageCommonPanelSpan2,m.imageCommonPanelColumnCenter),children:c.jsx(W.Button,{size:"small",onClick:()=>{f()},style:{display:h(l)},children:c.jsxs("span",{className:m.imageCommonPanelInline,children:[c.jsx(Ve,{}),t.t("image-panel.group.group")]})})}),c.jsx("div",{className:T(m.imageCommonPanelColumn,m.imageCommonPanelSpan2,m.imageCommonPanelColumnCenter),children:c.jsx(W.Button,{size:"small",onClick:()=>{v()},style:{display:h(d)},children:c.jsxs("span",{className:m.imageCommonPanelInline,children:[c.jsx(Ke,{}),t.t("image-panel.group.unGroup")]})})})]})]})},ie=20,En=20,Tn=[-3600,3600],pe=300,Bn=a=>{var je;const t=G.useDependency(C.LocaleService),n=G.useDependency(M.IDrawingManagerService),e=G.useDependency(y.IRenderManagerService),{drawings:r,transformShow:i}=a,s=r[0];if(s==null)return;const o=s.transform;if(o==null)return;const{unitId:l,subUnitId:g,drawingId:d,drawingType:u}=s,h=e.getRenderById(l),f=h==null?void 0:h.scene;if(f==null)return;const S=(je=f.getEngine())==null?void 0:je.activeScene;if(S==null)return;const v=f.getTransformerByCreate(),{width:p=0,height:b=0,left:I=0,top:O=0,angle:P=0}=o,[B,D]=_.useState(p),[R,j]=_.useState(b),[N,U]=_.useState(I),[V,A]=_.useState(O),[ne,z]=_.useState(P),[oe,te]=_.useState(v.keepRatio),re=(w,E,k,$)=>{const{width:H,height:J}=S,{ancestorLeft:F,ancestorTop:Y}=f;let Z=w,ae=E,ge=k,me=$;return w+F<0&&(Z=-F),E+Y<0&&(ae=-Y),ge=H-Z-F,ge<ie&&(ge=ie),me=J-ae-Y,me<ie&&(me=ie),w+ge+F>H&&(Z=H-k-F),E+me+Y>J&&(ae=J-$-Y),{limitLeft:Z,limitTop:ae,limitWidth:ge,limitHeight:me}},ce=w=>{const{objects:E}=w,k=fe(E,n);if(k.length!==1)return;const $=k[0];if($==null)return;const{transform:H}=$;if(H==null)return;const{width:J,height:F,left:Y,top:Z,angle:ae}=H;J!=null&&D(J),F!=null&&j(F),Y!=null&&U(Y),Z!=null&&A(Z),ae!=null&&z(ae)};_.useEffect(()=>{const w=[v.changeStart$.subscribe(E=>{ce(E)}),v.changing$.subscribe(E=>{ce(E)}),v.changeEnd$.subscribe(E=>{ce(E)}),n.focus$.subscribe(E=>{if(E.length!==1)return;const k=n.getDrawingByParam(E[0]);if(k==null)return;const $=k.transform;if($==null)return;const{width:H,height:J,left:F,top:Y,angle:Z}=$;H!=null&&D(H),J!=null&&j(J),F!=null&&U(F),Y!=null&&A(Y),Z!=null&&z(Z)})];return()=>{w.forEach(E=>E.unsubscribe())}},[]);const q=C.debounce(w=>{if(w==null)return;w=Math.max(w,ie);const{limitWidth:E,limitHeight:k}=re(N,V,w,R);w=Math.min(w,E);const $={unitId:l,subUnitId:g,drawingId:d,drawingType:u,transform:{width:w}};if(oe){let H=w/B*R;if(H=Math.max(H,En),H>k)return;j(H),$.transform.height=H}D(w),n.featurePluginUpdateNotification([$]),v.refreshControls().changeNotification()},pe),be=C.debounce(w=>{if(w==null)return;w=Math.max(w,ie);const{limitHeight:E,limitWidth:k}=re(N,V,B,w);w=Math.min(w,E);const $={unitId:l,subUnitId:g,drawingId:d,drawingType:u,transform:{height:w}};if(oe){let H=w/R*B;if(H=Math.max(H,ie),H>k)return;D(H),$.transform.width=H}j(w),n.featurePluginUpdateNotification([$]),v.refreshControls().changeNotification()},pe),Ze=C.debounce(w=>{if(w==null)return;const{limitLeft:E}=re(w,V,B,R);w=E;const k={unitId:l,subUnitId:g,drawingId:d,drawingType:u,transform:{left:w}};U(w),n.featurePluginUpdateNotification([k]),v.refreshControls().changeNotification()},pe),Xe=C.debounce(w=>{if(w==null)return;const{limitTop:E}=re(N,w,B,R);w=E;const k={unitId:l,subUnitId:g,drawingId:d,drawingType:u,transform:{top:w}};A(w),n.featurePluginUpdateNotification([k]),v.refreshControls().changeNotification()},pe),qe=w=>{if(w==null)return;const[E,k]=Tn;w<E&&(w=E),w>k&&(w=k);const $={unitId:l,subUnitId:g,drawingId:d,drawingType:u,transform:{angle:w}};z(w),n.featurePluginUpdateNotification([$]),v.refreshControls().changeNotification()},Je=w=>{te(w),v.keepRatio=w},Qe=w=>w?"block":"none";return c.jsxs("div",{className:T(m.imageCommonPanelGrid,m.imageCommonPanelBorder),style:{display:Qe(i)},children:[c.jsx("div",{className:m.imageCommonPanelRow,children:c.jsx("div",{className:T(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:T(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(W.InputNumber,{precision:1,value:B,onChange:w=>{q(w)},className:m.imageCommonPanelInput})})})]})}),c.jsx("div",{className:T(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(W.InputNumber,{precision:1,value:R,onChange:w=>{be(w)},className:m.imageCommonPanelInput})})})]})}),c.jsx("div",{className:T(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:T(m.imageCommonPanelRow,m.imageCommonPanelRowVertical),children:c.jsx("div",{className:m.imageCommonPanelColumn,children:c.jsx(W.Checkbox,{checked:oe,onChange:Je})})})]})})]}),c.jsxs("div",{className:m.imageCommonPanelRow,children:[c.jsx("div",{className:T(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(W.InputNumber,{precision:1,value:N,onChange:w=>{Ze(w)},className:m.imageCommonPanelInput})})})]})}),c.jsx("div",{className:T(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(W.InputNumber,{precision:1,value:V,onChange:w=>{Xe(w)},className:m.imageCommonPanelInput})})})]})}),c.jsx("div",{className:T(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(W.InputNumber,{precision:1,value:ne,onChange:qe,className:m.imageCommonPanelInput})})})]})})]})]})},we={id:"sheet.operation.open-image-crop",type:C.CommandType.OPERATION,handler:(a,t)=>!0},ee={id:"sheet.operation.close-image-crop",type:C.CommandType.OPERATION,handler:(a,t)=>!0};var L=(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))(L||{});const he={id:"sheet.operation.Auto-image-crop",type:C.CommandType.OPERATION,handler:(a,t)=>!0},Un=a=>{const t=G.useDependency(C.ICommandService),n=G.useDependency(C.LocaleService),{drawings:e,cropperShow:r}=a;if(e[0]==null)return;const[s,o]=_.useState(L.FREE),l=_.useRef(!1),g=[{label:n.t("image-panel.crop.mode"),value:L.FREE},{label:"1:1",value:L.R1_1},{label:"16:9",value:L.R16_9},{label:"9:16",value:L.R9_16},{label:"5:4",value:L.R5_4},{label:"4:5",value:L.R4_5},{label:"4:3",value:L.R4_3},{label:"3:4",value:L.R3_4},{label:"3:2",value:L.R3_2},{label:"2:3",value:L.R2_3}];_.useEffect(()=>{const f=t.onCommandExecuted(S=>{if(S.id===ee.id){const v=S.params;v!=null&&v.isAuto||(l.current=!1)}});return()=>{f==null||f.dispose()}},[]);function d(f){o(f),l.current&&t.executeCommand(he.id,{cropType:f})}const u=f=>f?"block":"none",h=f=>{t.executeCommand(he.id,{cropType:f}),l.current=!0};return c.jsxs("div",{className:T(m.imageCommonPanelGrid,m.imageCommonPanelBorder),style:{display:u(r)},children:[c.jsx("div",{className:m.imageCommonPanelRow,children:c.jsx("div",{className:T(m.imageCommonPanelColumn,m.imageCommonPanelTitle),children:c.jsx("div",{children:n.t("image-panel.crop.title")})})}),c.jsxs("div",{className:T(m.imageCommonPanelRow,m.imageCommonPanelRowVertical),children:[c.jsx("div",{className:T(m.imageCommonPanelColumn,m.imageCommonPanelSpan2),children:c.jsx(W.Button,{size:"small",onClick:()=>{h(s)},children:c.jsxs("span",{className:m.imageCommonPanelInline,children:[c.jsx(Ge,{}),n.t("image-panel.crop.start")]})})}),c.jsx("div",{className:T(m.imageCommonPanelColumn,m.imageCommonPanelSpan2),children:c.jsx(W.Select,{value:s,options:g,onChange:d})})]})]})},An=a=>{const t=G.useDependency(M.IDrawingManagerService),n=G.useDependency(y.IRenderManagerService),e=G.useDependency(C.LocaleService),{drawings:r,hasArrange:i=!0,hasTransform:s=!0,hasAlign:o=!0,hasCropper:l=!0,hasGroup:g=!0}=a,d=r[0];if(d==null)return;const{unitId:u}=d,h=n.getRenderById(u),f=h==null?void 0:h.scene;if(f==null)return;const S=f.getTransformerByCreate(),[v,p]=_.useState(!0),[b,I]=_.useState(!0),[O,P]=_.useState(!1),[B,D]=_.useState(!0),[R,j]=_.useState(!1);return _.useEffect(()=>{const N=S.clearControl$.subscribe(A=>{A===!0&&(p(!1),I(!1),P(!1),D(!1),j(!0))}),U=S.changeStart$.subscribe(A=>{const{objects:ne}=A,z=fe(ne,t);z.length===0?(p(!1),I(!1),P(!1),D(!1),j(!0)):z.length===1?(p(!0),I(!0),P(!1),D(!0),j(!1)):(p(!0),I(!1),P(!0),D(!1),j(!1))}),V=t.focus$.subscribe(A=>{A.length===0?(p(!1),I(!1),P(!1),D(!1),j(!0)):A.length===1?(p(!0),I(!0),P(!1),D(!0),j(!1)):(p(!0),I(!1),P(!0),D(!1),j(!1))});return()=>{U.unsubscribe(),N.unsubscribe(),V.unsubscribe()}},[]),c.jsxs(c.Fragment,{children:[c.jsx("div",{style:{display:R===!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(On,{arrangeShow:i===!0?v:!1,drawings:r}),c.jsx(Bn,{transformShow:s===!0?b:!1,drawings:r}),c.jsx(Cn,{alignShow:o===!0?O:!1,drawings:r}),c.jsx(Un,{cropperShow:l===!0?B:!1,drawings:r}),c.jsx(Nn,{hasGroup:g,drawings:r})]})},Ln="univer-image-popup-menu",Hn="univer-image-popup-menu-item",Gn="univer-image-popup-menu-item-title",Vn="univer-btn-container",kn="univer-btn-container-expand",de={imagePopupMenu:Ln,imagePopupMenuItem:Hn,imagePopupMenuItemTitle:Gn,btnContainer:Vn,btnContainerExpand:kn},Fe=a=>{var S,v;const t=(v=(S=a.popup)==null?void 0:S.extraProps)==null?void 0:v.menuItems;if(!t)return null;const n=G.useDependency(C.ICommandService),e=G.useDependency(C.LocaleService),[r,i]=_.useState(!1),[s,o]=_.useState(!1),l=()=>{o(!0)},g=()=>{o(!1)},d=p=>{i(p)},u=p=>{n.executeCommand(p.commandId,p.commandParams),i(!1)},h=r||s,f=t.filter(p=>!p.disable);return c.jsx("div",{onMouseEnter:l,onMouseLeave:g,children:c.jsx(W.DropdownLegacy,{placement:"bottomLeft",trigger:["click"],overlay:c.jsx("ul",{className:de.imagePopupMenu,children:f.map(p=>c.jsx("li",{onClick:()=>u(p),className:de.imagePopupMenuItem,children:c.jsx("span",{className:de.imagePopupMenuItemTitle,children:e.t(p.label)})},p.index))}),visible:r,onVisibleChange:d,children:c.jsxs("div",{className:T(de.btnContainer,{[de.btnContainerExpand]:r}),children:[c.jsx(Le,{style:{color:"#35322B"},extend:{colorChannel1:"rgb(var(--green-700, #409f11))"}}),h&&c.jsx(ke,{style:{color:"#CCCCCC",fontSize:"8px",marginLeft:"8px"}})]})})})},Ye="COMPONENT_IMAGE_POPUP_MENU",Wn="drawing-ui.config",Oe={},De={id:"sheet.operation.image-reset-size",type:C.CommandType.OPERATION,handler:(a,t)=>!0},$n=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 zn=Object.getOwnPropertyDescriptor,Kn=(a,t,n,e)=>{for(var r=e>1?void 0:e?zn(t,n):t,i=a.length-1,s;i>=0;i--)(s=a[i])&&(r=s(r)||r);return r},Ne=(a,t)=>(n,e)=>t(n,e,a);let ve=class extends C.Disposable{constructor(a,t){super(),this._componentManager=a,this._commandService=t,this._init()}_initCustomComponents(){const a=this._componentManager;this.disposeWithMe(a.register(Ye,Fe)),this.disposeWithMe(a.register(Be,$n))}_initCommands(){[we,ee,De,ye,he].forEach(a=>this.disposeWithMe(this._commandService.registerCommand(a)))}_init(){this._initCommands(),this._initCustomComponents()}};ve=Kn([Ne(0,C.Inject(G.ComponentManager)),Ne(1,C.ICommandService)],ve);var Fn=Object.getOwnPropertyDescriptor,Yn=(a,t,n,e)=>{for(var r=e>1?void 0:e?Fn(t,n):t,i=a.length-1,s;i>=0;i--)(s=a[i])&&(r=s(r)||r);return r},Ce=(a,t)=>(n,e)=>t(n,e,a);let Se=class extends C.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=Te(this._currentUniverService);if(n==null)return;const{unitId:e,subUnitId:r}=n;Object.keys(t).forEach(i=>{Object.keys(t[i]).forEach(s=>{const o=t[i][s].data;o==null||i!==e||s!==r||Object.keys(o).forEach(l=>{o[l]&&this._insertDrawing([{unitId:i,subUnitId:s,drawingId:l}])})})})}_commandExecutedListener(){this.disposeWithMe(this._commandService.onCommandExecuted(t=>{if(t.id===ye.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:i,drawingId:s}=n,o=this._getSceneAndTransformerByDrawingSearch(n.unitId);if(o==null)return;const{scene:l,transformer:g}=o;this._commandService.syncExecuteCommand(ee.id);const d=[];if(e.forEach(f=>{const S=M.getDrawingShapeKeyByDrawingSearch(f),v=l.getObjectIncludeInGroup(S);if(v==null||d.includes(v))return;d.push(v);const{transform:p}=f;p!=null&&(v.classType===y.RENDER_CLASS_TYPE.GROUP?v.transformByState({left:p.left,top:p.top}):v.transformByState(p))}),d.length===0)return;const u=M.getDrawingShapeKeyByDrawingSearch({unitId:r,subUnitId:i,drawingId:s}),h=new y.Group(u);l.addObject(h,y.DRAWING_OBJECT_LAYER_INDEX).attachTransformerTo(h),h.addObjects(...d),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:i,transformer:s}=r;e.forEach(u=>{const h=M.getDrawingShapeKeyByDrawingSearch(u),f=i.getObjectIncludeInGroup(h);if(f==null)return!0;if(f==null)return;const{transform:S}=u;S!=null&&(f.classType===y.RENDER_CLASS_TYPE.GROUP?f.transformByState({left:S.left,top:S.top}):f.transformByState(S))});const o=M.getDrawingShapeKeyByDrawingSearch(n),l=i.getObject(o),{width:g,height:d}=l;l.getObjects().forEach(u=>{l.removeSelfObjectAndTransform(u.oKey,g,d)}),l.dispose(),s.clearSelectedObjects()}_drawingAlign(t){const{alignType:n}=t,e=this._drawingManagerService.getFocusDrawings();if(n===x.default)return;const r=[];let i=Number.POSITIVE_INFINITY,s=Number.POSITIVE_INFINITY,o=Number.NEGATIVE_INFINITY,l=Number.NEGATIVE_INFINITY,g=0;e.forEach(d=>{const{unitId:u,subUnitId:h,drawingId:f,drawingType:S}=d,v=this._drawingManagerService.getDrawingByParam({unitId:u,subUnitId:h,drawingId:f});if(v==null||v.transform==null)return;r.push({unitId:u,subUnitId:h,drawingId:f,drawingType:S,transform:v.transform});const{left:p=0,top:b=0,width:I=0,height:O=0}=v.transform;i=Math.min(i,p),s=Math.min(s,b),o=Math.max(o,p+I),l=Math.max(l,b+O),g++}),g!==0&&(this._sortDrawingTransform(r,n),this._applyAlignType(r,n,i,s,o,l,g))}_applyAlignType(t,n,e,r,i,s,o){const l=Math.round((i-e)/o*10)/10,g=Math.round((s-r)/o*10)/10,d=[],u=this._getSceneAndTransformerByDrawingSearch(t[0].unitId);if(u==null)return;const{scene:h,transformer:f}=u;t.forEach((S,v)=>{const{unitId:p,subUnitId:b,drawingId:I,transform:O,drawingType:P}=S,{left:B=0,top:D=0,width:R=0,height:j=0}=O;let N=B,U=D;switch(n){case x.left:N=e;break;case x.center:N=e+(i-e)/2-R/2;break;case x.right:N=i-R;break;case x.top:U=r;break;case x.middle:U=r+(s-r)/2-j/2;break;case x.bottom:U=s-j;break;case x.horizon:N=e+l*v;break;case x.vertical:U=r+g*v;break}(N!==B||U!==D)&&d.push({unitId:p,subUnitId:b,drawingId:I,drawingType:P,transform:{left:N,top:U}})}),this._drawingManagerService.featurePluginUpdateNotification(d),f.refreshControls().changeNotification()}_sortDrawingTransform(t,n){t.sort((e,r)=>{const i=e.transform,s=r.transform,{left:o=0,top:l=0,width:g=0,height:d=0}=i,{left:u=0,top:h=0,width:f=0,height:S=0}=s;switch(n){case x.left:return o-u;case x.center:return o+g/2-(u+f/2);case x.right:return o+g-(u+f);case x.top:return l-h;case x.middle:return l+d/2-(h+S/2);case x.bottom:return l+d-(h+S);case x.horizon:return o+g/2-(u+f/2);case x.vertical:return l+d/2-(h+S/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,i=this._getSceneAndTransformerByDrawingSearch(n);if(i==null)return;const{scene:s}=i;r.forEach(o=>{const l=M.getDrawingShapeKeyByDrawingSearch({unitId:n,subUnitId:e,drawingId:o}),g=s.fuzzyMathObjects(l,!0);if(g==null||g.length===0)return;const d=this._drawingManagerService.getDrawingOrder(n,e).indexOf(o);for(const u of g)u.setProps({zIndex:d}),u.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 s=this._getSceneAndTransformerByDrawingSearch(r);if(s==null)return;const{scene:o}=s;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 d;const{unitId:e,subUnitId:r,drawingId:i}=n,s=this._getSceneAndTransformerByDrawingSearch(e);if(s==null)return;const{scene:o}=s,l=M.getDrawingShapeKeyByDrawingSearch({unitId:e,subUnitId:r,drawingId:i}),g=o.fuzzyMathObjects(l,!0);if(g.length>0){for(const u of g)u.dispose();(d=o.getTransformer())==null||d.clearSelectedObjects()}})}))}_drawingUpdateListener(){this.disposeWithMe(this._drawingManagerService.update$.subscribe(t=>{t.forEach(n=>{var R;const{unitId:e,subUnitId:r,drawingId:i}=n,s=this._drawingManagerService.getDrawingByParam(n);if(s==null)return;const{transform:o,drawingType:l}=s,g=this._getSceneAndTransformerByDrawingSearch(e);if(g==null)return;const{scene:d,transformer:u}=g;if(o==null)return!0;const{left:h=0,top:f=0,width:S=0,height:v=0,angle:p=0,flipX:b=!1,flipY:I=!1,skewX:O=0,skewY:P=0}=o,B=M.getDrawingShapeKeyByDrawingSearch({unitId:e,subUnitId:r,drawingId:i}),D=d.getObject(B);if(D==null)return!0;D.transformByState({left:h,top:f,width:S,height:v,angle:p,flipX:b,flipY:I,skewX:O,skewY:P}),(R=d.getTransformer())==null||R.debounceRefreshControls()})}))}_drawingRefreshListener(){this.disposeWithMe(this._drawingManagerService.refreshTransform$.subscribe(t=>{t.forEach(n=>{const{unitId:e,subUnitId:r,drawingId:i}=n,s=this._getSceneAndTransformerByDrawingSearch(e);if(s==null)return;const o=this._drawingManagerService.getDrawingByParam(n);if(o==null)return;const{transform:l}=o,{scene:g}=s,d=M.getDrawingShapeKeyByDrawingSearch({unitId:e,subUnitId:r,drawingId:i}),u=g.getObject(d);if(u==null||l==null)return!0;const{left:h=0,top:f=0,width:S=0,height:v=0,angle:p=0,flipX:b=!1,flipY:I=!1,skewX:O=0,skewY:P=0}=l;u.transformByState({left:h,top:f,width:S,height:v,angle:p,flipX:b,flipY:I,skewX:O,skewY:P})})}))}_drawingVisibleListener(){this.disposeWithMe(this._drawingManagerService.visible$.subscribe(t=>{t.forEach(n=>{const{unitId:e,subUnitId:r,drawingId:i,visible:s}=n,o=this._getSceneAndTransformerByDrawingSearch(e);if(o==null)return;const{scene:l}=o,g=M.getDrawingShapeKeyByDrawingSearch({unitId:e,subUnitId:r,drawingId:i}),d=l.getObject(g);if(d==null)return!0;s?d.show():d.hide()})}))}_filterUpdateParams(t,n){return t.filter((e,r)=>{if(e==null)return!1;const{transform:i}=e;return C.checkIfMove(i,n==null?void 0:n[r])})}_addListenerOnDrawing(t){const n=t.getTransformerByCreate();let e=null;this.disposeWithMe(C.toDisposable(n.changeStart$.subscribe(r=>{const{objects:i}=r,s=Array.from(i.values()),o=[];e=s.map(l=>{const{left:g,top:d,height:u,width:h,angle:f,oKey:S,isInGroup:v}=l,p=this._drawingManagerService.getDrawingOKey(S);if(v||l instanceof y.Group){let b=l.ancestorGroup;if(b==null&&l instanceof y.Group&&(b=l),b==null)return null;const I=this._drawingManagerService.getDrawingOKey(b.oKey);if(I){const{unitId:O,subUnitId:P,drawingId:B}=I;o.push({unitId:O,subUnitId:P,drawingId:B});const{left:D,top:R,height:j,width:N,angle:U}=b;return{left:D,top:R,height:j,width:N,angle:U}}}else if(p!=null){const{unitId:b,subUnitId:I,drawingId:O}=p;return o.push({unitId:b,subUnitId:I,drawingId:O}),{left:g,top:d,height:u,width:h,angle:f}}return null}).filter(l=>l!=null),o.length>0?this._commandService.syncExecuteCommand(M.SetDrawingSelectedOperation.id,o):this._commandService.syncExecuteCommand(M.SetDrawingSelectedOperation.id,[])}))),this.disposeWithMe(C.toDisposable(n.changeEnd$.subscribe(r=>{const{objects:i}=r,s=this._filterUpdateParams(fe(i,this._drawingManagerService),e);s.length>0&&this._drawingManagerService.featurePluginUpdateNotification(s)})))}};Se=Yn([Ce(0,C.IUniverInstanceService),Ce(1,C.ICommandService),Ce(2,y.IRenderManagerService),Ce(3,M.IDrawingManagerService)],Se);class ue extends y.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:i,height:s}=r;this._initialCacheCanvas(),(l=this._cacheCanvas)==null||l.clear();const o=(g=this._cacheCanvas)==null?void 0:g.getContext();o!=null&&(o.save(),y.Rect.drawWith(o,{left:0,top:0,width:i,height:s,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,i=0;const{left:s=0,top:o=0,width:l=0,height:g=0,angle:d}=this._applyTransform;if(this._srcRect!=null){const{left:f=0,top:S=0,right:v=0,bottom:p=0}=this._srcRect;n=f,e=S,r=v,i=p}const u=s+n,h=o+e;this.transformByState({left:u,top:h,width:s+l-r-u,height:o+g-i-h,angle:d})}_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 y.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 Zn=Object.getOwnPropertyDescriptor,Xn=(a,t,n,e)=>{for(var r=e>1?void 0:e?Zn(t,n):t,i=a.length-1,s;i>=0;i--)(s=a[i])&&(r=s(r)||r);return r},le=(a,t)=>(n,e)=>t(n,e,a);let _e=class extends C.Disposable{constructor(t,n,e,r,i,s){super();Q(this,"_sceneListenerOnImageMap",new WeakSet);this._commandService=t,this._drawingManagerService=n,this._renderManagerService=e,this._univerInstanceService=r,this._messageService=i,this._localeService=s,this._init()}_init(){this._initOpenCrop(),this._initCloseCrop(),this._initAutoCrop()}_initAutoCrop(){this.disposeWithMe(this._commandService.onCommandExecuted(t=>{if(t.id!==he.id)return;const n=t.params;if(n==null)return;const{cropType:e}=n,r=this._drawingManagerService.getFocusDrawings();if(r.length!==1)return;const i=r[0],{unitId:s,subUnitId:o,drawingId:l}=i,g=this._renderManagerService.getRenderById(s),d=g==null?void 0:g.scene;if(d==null)return!0;this._searchCropObject(d)!=null&&this._commandService.syncExecuteCommand(ee.id,{isAuto:!0});const h=M.getDrawingShapeKeyByDrawingSearch({unitId:s,subUnitId:o,drawingId:l}),f=d.getObject(h);if(!(f instanceof y.Image)){this._messageService.show({type:W.MessageType.Error,content:this._localeService.t("image-cropper.error")});return}f!=null&&(this._updateCropperObject(e,f),this._commandService.executeCommand(we.id,{unitId:s,subUnitId:o,drawingId:l}))}))}_calculateSrcRectByRatio(t,n,e,r,i,s){const o=e/r,l=i/s;let g=e,d=r;o>l?g=r*l:d=e/l;const u=(e-g)/2,h=(r-d)/2;return{left:y.precisionTo(u,1),top:y.precisionTo(h,1),right:y.precisionTo(e-(u+g),1),bottom:y.precisionTo(r-(h+d),1)}}_updateCropperObject(t,n){const{left:e,top:r,width:i,height:s}=n.calculateTransformWithSrcRect();let o;switch(t){case L.R1_1:o=this._calculateSrcRectByRatio(e,r,i,s,1,1);break;case L.R16_9:o=this._calculateSrcRectByRatio(e,r,i,s,16,9);break;case L.R9_16:o=this._calculateSrcRectByRatio(e,r,i,s,9,16);break;case L.R5_4:o=this._calculateSrcRectByRatio(e,r,i,s,5,4);break;case L.R4_5:o=this._calculateSrcRectByRatio(e,r,i,s,4,5);break;case L.R4_3:o=this._calculateSrcRectByRatio(e,r,i,s,4,3);break;case L.R3_4:o=this._calculateSrcRectByRatio(e,r,i,s,3,4);break;case L.R3_2:o=this._calculateSrcRectByRatio(e,r,i,s,3,2);break;case L.R2_3:o=this._calculateSrcRectByRatio(e,r,i,s,2,3);break;case L.FREE:}if(o==null)return;n.setSrcRect(o);const{left:l=0,top:g=0,bottom:d=0,right:u=0}=o;n.transformByStateCloseCropper({left:e+l,top:r+g,width:i-u-l,height:s-d-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:i}=n,s=this._renderManagerService.getRenderById(e),o=s==null?void 0:s.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:i})==null)return;const g=M.getDrawingShapeKeyByDrawingSearch({unitId:e,subUnitId:r,drawingId:i}),d=o.getObject(g);if(d==null)return;if(!(d instanceof y.Image)){this._messageService.show({type:W.MessageType.Error,content:this._localeService.t("image-cropper.error")});return}const u=o.getTransformer();u==null||u.clearControls();const h=new ue(`${g}-crop`,{srcRect:d.srcRect,prstGeom:d.prstGeom,applyTransform:d.calculateTransformWithSrcRect()});o.addObject(h,d.getLayerIndex()+1).attachTransformerTo(h),u==null||u.createControlForCopper(h),this._addHoverForImageCopper(h),d.openRenderByCropper(),u==null||u.refreshControls(),h.makeDirty(!0),this._commandService.syncExecuteCommand(M.SetDrawingSelectedOperation.id,[{unitId:e,subUnitId:r,drawingId:i}])}))}_searchCropObject(t){const n=t.getAllObjectsByOrder();for(const e of n)if(e instanceof ue)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(),i=this._renderManagerService.getRenderById(r),s=i==null?void 0:i.scene;if(s==null)return!0;const o=this._searchCropObject(s);if(o==null)return;const l=this._getApplyObjectByCropObject(o);if(l==null)return;const g=s.getTransformerByCreate();g.detachFrom(o),g.clearCopperControl();const d=this._getSrcRectByTransformState(l,o),u=this._drawingManagerService.getDrawingOKey(l.oKey);if(u!=null){const{left:h,top:f,height:S,width:v}=o;this._drawingManagerService.featurePluginUpdateNotification([{...u,transform:{...u.transform,left:h,top:f,height:S,width:v},srcRect:d.srcRectAngle}])}l.setSrcRect({...d.srcRectAngle}),l.closeRenderByCropper(),l.makeDirty(!0),o==null||o.dispose()}));const t=this._univerInstanceService.getCurrentTypeOfUnit$(C.UniverInstanceType.UNIVER_SHEET).pipe(Me.switchMap(n=>n?n.activeSheet$:Me.of(null)));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 i=r.getObject(e);return i==null?null:i}_addListenerOnImage(t){const n=t.getTransformerByCreate();let e=null;this.disposeWithMe(n.changeStart$.subscribe(r=>{const{objects:i}=r,s=i.values().next().value;if(s==null||!(s instanceof ue))return;const{left:o,top:l,height:g,width:d,angle:u}=s;e={left:o,top:l,height:g,width:d,angle:u},n.clearCopperControl()})),this.disposeWithMe(n.changeEnd$.subscribe(r=>{const{objects:i}=r,s=i.values().next().value;if(s==null||!(s instanceof ue))return;const{left:o,top:l,height:g,width:d,angle:u}=s;if(!C.checkIfMove({left:o,top:l,height:g,width:d,angle:u},e))return;const h=this._getApplyObjectByCropObject(s);if(h==null)return;const f=this._getSrcRectByTransformState(h,s);s.refreshSrcRect(f.srcRect,h.getState()),n.createControlForCopper(s)})),this._endCropListener(t)}_addHoverForImageCopper(t){this.disposeWithMe(t.onPointerEnter$.subscribeEvent(()=>{t.cursor=y.CURSOR_TYPE.MOVE})),this.disposeWithMe(t.onPointerLeave$.subscribeEvent(()=>{t.cursor=y.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:i,width:s,strokeWidth:o,angle:l}=n,{left:g,top:d,width:u,height:h,angle:f,strokeWidth:S}=t,v=e-g,p=r-d,b={left:v,top:p,right:u-v-s,bottom:h-p-i},I={...b};if(f!==0){const O=e+s/2,P=r+i/2,B=new y.Vector2(O,P),D=u/2+g,R=h/2+d,j=new y.Vector2(D,R),N=new y.Vector2(g,d);N.rotateByPoint(y.degToRad(f),j);const U=N.clone();U.rotateByPoint(y.degToRad(-f),B);const V=e-U.x,A=r-U.y;I.left=V,I.top=A,I.right=u-V-s,I.bottom=h-A-i}return{srcRect:b,srcRectAngle:I}}};_e=Xn([le(0,C.ICommandService),le(1,M.IDrawingManagerService),le(2,y.IRenderManagerService),le(3,C.IUniverInstanceService),le(4,G.IMessageService),le(5,C.Inject(C.LocaleService))],_e);var qn=Object.getOwnPropertyDescriptor,Jn=(a,t,n,e)=>{for(var r=e>1?void 0:e?qn(t,n):t,i=a.length-1,s;i>=0;i--)(s=a[i])&&(r=s(r)||r);return r},se=(a,t)=>(n,e)=>t(n,e,a);let Ie=class extends C.Disposable{constructor(a,t,n,e,r,i,s){super(),this._commandService=a,this._renderManagerService=t,this._drawingManagerService=n,this._dialogService=e,this._imageIoService=r,this._currentUniverService=i,this._drawingRenderService=s,this._initialize()}dispose(){super.dispose()}_initialize(){this._drawingAddListener(),this._commandExecutedListener(),this._imageUpdateListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.onCommandExecuted(a=>{if(a.id===De.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:i,drawingId:s}=e,o=this._getSceneAndTransformerByDrawingSearch(r);if(o==null)return;const{scene:l}=o,g=M.getDrawingShapeKeyByDrawingSearch({unitId:r,subUnitId:i,drawingId:s}),d=l.getObject(g);if(d==null)return!0;const u=this._drawingManagerService.getDrawingByParam(e);if(u==null)return!0;if(u.drawingType!==C.DrawingTypeEnum.DRAWING_IMAGE)return;d.resetSize();const{width:h,height:f}=d.getNativeSize();n.includes(l)===!1&&n.push(l),t.push({...u,transform:{...u.transform,height:f,width:h,angle:0},srcRect:null,prstGeom:null})}),this._drawingManagerService.featurePluginUpdateNotification(t),n.forEach(e=>{e.getTransformerByCreate().refreshControls().changeNotification()}),this._commandService.syncExecuteCommand(M.SetDrawingSelectedOperation.id,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,i=this._getSceneAndTransformerByDrawingSearch(n),s=(g=Te(this._currentUniverService,n))==null?void 0:g.subUnitId;if(i==null||s!==e)return;const o=this._drawingManagerService.getDrawingByParam(t);if(o==null)return;const l=await this._drawingRenderService.renderImages(o,i.scene);if(!(l==null||l.length===0))for(const d of l)this._addHoverForImage(d),this._addDialogForImage(d)})}_imageUpdateListener(){this.disposeWithMe(this._drawingManagerService.update$.subscribe(a=>{a.forEach(t=>{const{unitId:n,subUnitId:e,drawingId:r}=t,i=this._drawingManagerService.getDrawingByParam(t);if(i==null)return;const{transform:s,drawingType:o,srcRect:l,prstGeom:g,source:d,imageSourceType:u}=i;if(o!==C.DrawingTypeEnum.DRAWING_IMAGE)return;const h=this._getSceneAndTransformerByDrawingSearch(n);if(h==null)return;const{scene:f,transformer:S}=h;if(s==null)return!0;const v=M.getDrawingShapeKeyByDrawingSearch({unitId:n,subUnitId:e,drawingId:r}),p=f.getObject(v);if(p==null)return!0;p.setSrcRect(l),p.setPrstGeom(g)})}))}_addHoverForImage(a){this.disposeWithMe(C.toDisposable(a.onPointerEnter$.subscribeEvent(()=>{a.cursor=y.CURSOR_TYPE.GRAB}))),this.disposeWithMe(C.toDisposable(a.onPointerLeave$.subscribeEvent(()=>{a.cursor=y.CURSOR_TYPE.DEFAULT})))}_addDialogForImage(a){this.disposeWithMe(C.toDisposable(a.onDblclick$.subscribeEvent(()=>{const t=`${a.oKey}-viewer-dialog`;this._drawingRenderService.previewImage(t,a.getNative().src,a.getNativeSize().width,a.getNativeSize().height)})))}};Ie=Jn([se(0,C.ICommandService),se(1,y.IRenderManagerService),se(2,M.IDrawingManagerService),se(3,G.IDialogService),se(4,M.IImageIoService),se(5,C.IUniverInstanceService),se(6,C.Inject(exports.DrawingRenderService))],Ie);var Qn=Object.getOwnPropertyDescriptor,et=(a,t,n,e)=>{for(var r=e>1?void 0:e?Qn(t,n):t,i=a.length-1,s;i>=0;i--)(s=a[i])&&(r=s(r)||r);return r},Ee=(a,t)=>(n,e)=>t(n,e,a);const nt="UNIVER_DRAWING_UI_PLUGIN";var Re;exports.UniverDrawingUIPlugin=(Re=class extends C.Plugin{constructor(t=Oe,n,e){super(),this._config=t,this._injector=n,this._configService=e;const{menu:r,...i}=C.merge({},Oe,this._config);r&&this._configService.setConfig("menu",r,{merge:!0}),this._configService.setConfig(Wn,i)}onStarting(){this._initDependencies()}onRendered(){this._injector.get(Se),this._injector.get(ve),this._injector.get(_e),this._injector.get(Ie)}_initDependencies(){[[exports.DrawingRenderService],[Se],[ve],[_e],[Ie]].forEach(n=>this._injector.add(n))}},Q(Re,"pluginName",nt),Re);exports.UniverDrawingUIPlugin=et([Ee(1,C.Inject(C.Injector)),Ee(2,C.IConfigService)],exports.UniverDrawingUIPlugin);exports.AutoImageCropOperation=he;exports.COMPONENT_IMAGE_POPUP_MENU=Ye;exports.CloseImageCropOperation=ee;exports.DrawingCommonPanel=An;exports.ImageCropperObject=ue;exports.ImagePopupMenu=Fe;exports.ImageResetSizeOperation=De;exports.OpenImageCropOperation=we;exports.SetDrawingAlignOperation=ye;exports.getUpdateParams=fe;
1
+ "use strict";var en=Object.defineProperty;var nn=(a,t,n)=>t in a?en(a,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):a[t]=n;var Q=(a,t,n)=>nn(a,typeof t!="symbol"?t+"":t,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const p=require("@univerjs/core"),M=require("@univerjs/drawing"),y=require("@univerjs/engine-render"),G=require("@univerjs/ui"),c=require("react/jsx-runtime"),_=require("react"),W=require("@univerjs/design"),Me=require("rxjs");function tn(a,t,n,e){const r=e.getDrawingByParam(a);if(r==null)return;const i=M.getDrawingShapeKeyByDrawingSearch(a),s=n.getObject(i);if(s&&!(s instanceof y.Group))return;if(s!=null){s.addObject(t);return}const o=new y.Group(i);n.addObject(o,y.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 Te(a,t){var i;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=(i=n.getActiveSheet())==null?void 0:i.getSheetId():(n.type===p.UniverInstanceType.UNIVER_DOC||n.type===p.UniverInstanceType.UNIVER_SLIDE)&&(r=e),{unitId:e,subUnitId:r,current:n}}const Be="COMPONENT_IMAGE_VIEWER";var rn=Object.getOwnPropertyDescriptor,an=(a,t,n,e)=>{for(var r=e>1?void 0:e?rn(t,n):t,i=a.length-1,s;i>=0;i--)(s=a[i])&&(r=s(r)||r);return r},Pe=(a,t)=>(n,e)=>t(n,e,a);const xe=50;exports.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:i,imageSourceType:s,srcRect:o,prstGeom:l,groupId:g,unitId:u,subUnitId:d,drawingId:h,isMultiTransform:f,transforms:S}=t;if(r!==p.DrawingTypeEnum.DRAWING_IMAGE||!this._drawingManagerService.getDrawingVisible()||e==null)return;const v=f&&S?S:[e],C=[];for(const b of v){const{left:I,top:O,width:P,height:B,angle:D,flipX:R,flipY:j,skewX:N,skewY:U}=b,k=v.indexOf(b),A=M.getDrawingShapeKeyByDrawingSearch({unitId:u,subUnitId:d,drawingId:h},f?k:void 0),ne=n.getObject(A);if(ne!=null){ne.transformByState({left:I,top:O,width:P,height:B,angle:D,flipX:R,flipY:j,skewX:N,skewY:U});continue}const z=this._drawingManagerService.getDrawingOrder(u,d),oe=z.indexOf(h),te={...b,zIndex:oe===-1?z.length-1:oe},re=this._imageIoService.getImageSourceCache(i,s);let ce=!1;if(re!=null)te.image=re;else{if(s===M.ImageSourceType.UUID)try{te.url=await this._imageIoService.getImage(i)}catch(be){console.error(be);continue}else te.url=i;ce=!0}if(n.getObject(A))continue;te.printable=!0;const q=new y.Image(A,te);ce&&this._imageIoService.addImageSourceCache(i,s,q.getNative()),this._drawingManagerService.getDrawingVisible()&&(n.addObject(q,y.DRAWING_OBJECT_LAYER_INDEX),this._drawingManagerService.getDrawingEditable()&&n.attachTransformerTo(q),g&&tn({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 p.DrawingTypeEnum.DRAWING_IMAGE:return this.renderImages(e,n)}}previewImage(t,n,e,r){const i=`${t}-viewer-dialog`,s=window.innerWidth-xe,o=window.innerHeight-xe,l=this._adjustImageSize(e,r,s,o),g=this._dialogService.open({width:Math.max(l.width,200),id:i,style:{margin:"0",top:"50%",left:"50%",transform:"translate(-50%, -50%)"},children:{label:{name:Be,props:{src:n,width:l.width,height:l.height}}},destroyOnClose:!0,draggable:!1,onClose:()=>{this._dialogService.close(i),g.dispose()}})}_adjustImageSize(t,n,e,r){if(t<=e&&n<=r)return{width:t,height:n};const i=e/t,s=r/n,o=Math.min(i,s);return{width:Math.floor(t*o),height:Math.floor(n*o)}}};exports.DrawingRenderService=an([Pe(0,M.IDrawingManagerService),Pe(1,M.IImageIoService),Pe(2,G.IDialogService)],exports.DrawingRenderService);function fe(a,t){const n=[];return a.forEach(e=>{const{oKey:r,left:i,top:s,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:S}=u,v={unitId:d,subUnitId:h,drawingId:f,drawingType:S,transform:{left:i,top:s,height:o,width:l,angle:g}};S===p.DrawingTypeEnum.DRAWING_IMAGE&&(v.srcRect=e.srcRect),n.push(v)}),n}function Ue(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=Ue(a[t]))&&(e&&(e+=" "),e+=n)}else for(n in a)a[n]&&(e&&(e+=" "),e+=n);return e}function T(){for(var a,t,n=0,e="",r=arguments.length;n<r;n++)(a=arguments[n])&&(t=Ue(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 ye={id:"sheet.operation.set-image-align",type:p.CommandType.OPERATION,handler:(a,t)=>!0},sn="univer-image-common-panel-grid",on="univer-image-common-panel-border",cn="univer-image-common-panel-title",ln="univer-image-common-panel-row",gn="univer-image-common-panel-row-vertical",mn="univer-image-common-panel-column",un="univer-image-common-panel-column-center",dn="univer-image-common-panel-inline",hn="univer-image-common-panel-span2",fn="univer-image-common-panel-span3",pn="univer-image-common-panel-input",m={imageCommonPanelGrid:sn,imageCommonPanelBorder:on,imageCommonPanelTitle:cn,imageCommonPanelRow:ln,imageCommonPanelRowVertical:gn,imageCommonPanelColumn:mn,imageCommonPanelColumnCenter:un,imageCommonPanelInline:dn,imageCommonPanelSpan2:hn,imageCommonPanelSpan3:fn,imageCommonPanelInput:pn},Cn=a=>{const t=G.useDependency(p.ICommandService),n=G.useDependency(p.LocaleService),{alignShow:e}=a,[r,i]=_.useState(x.default),s=[{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){i(g),t.executeCommand(ye.id,{alignType:g})}const l=g=>g?"block":"none";return c.jsxs("div",{className:T(m.imageCommonPanelGrid,m.imageCommonPanelBorder),style:{display:l(e)},children:[c.jsx("div",{className:m.imageCommonPanelRow,children:c.jsx("div",{className:T(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:T(m.imageCommonPanelColumn),children:c.jsx(W.Select,{value:r,options:s,onChange:o})})})]})};var K=function(){return K=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},K.apply(this,arguments)},wn=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,i=a.extend,s=wn(a,["icon","id","className","extend"]),o="univerjs-icon univerjs-icon-".concat(e," ").concat(r||"").trim(),l=_.useRef("_".concat(_n()));return Ae(n,"".concat(e),{defIds:n.defIds,idSuffix:l.current},K({ref:t,className:o},s),i)});function Ae(a,t,n,e,r){return _.createElement(a.tag,K(K({key:t},vn(a,n,r)),e),(Sn(a,n).children||[]).map(function(i,s){return Ae(i,"".concat(t,"-").concat(a.tag,"-").concat(s),n,void 0,r)}))}function vn(a,t,n){var e=K({},a.attrs);n!=null&&n.colorChannel1&&e.fill==="colorChannel1"&&(e.fill=n.colorChannel1),a.tag==="mask"&&e.id&&(e.id=e.id+t.idSuffix),Object.entries(e).forEach(function(i){var s=i[0],o=i[1];s==="mask"&&typeof o=="string"&&(e[s]=o.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))});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(i){var s=i[0],o=i[1];typeof o=="string"&&(e[s]=o.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))})),e}function Sn(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)?K(K({},a),{children:a.children.map(function(r){return typeof r.attrs.id=="string"&&e&&e.indexOf(r.attrs.id)>-1?K(K({},r),{attrs:K(K({},r.attrs),{id:r.attrs.id+t.idSuffix})}):r})}):a}function _n(){return Math.random().toString(36).substring(2,8)}X.displayName="UniverIcon";var In={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"}}]},Le=_.forwardRef(function(a,t){return _.createElement(X,Object.assign({},a,{id:"autofill",ref:t,icon:In}))});Le.displayName="Autofill";var yn={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"}}]},He=_.forwardRef(function(a,t){return _.createElement(X,Object.assign({},a,{id:"bottom-single",ref:t,icon:yn}))});He.displayName="BottomSingle";var bn={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"}}]},Ge=_.forwardRef(function(a,t){return _.createElement(X,Object.assign({},a,{id:"create-copy-single",ref:t,icon:bn}))});Ge.displayName="CreateCopySingle";var Pn={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"}}]},ke=_.forwardRef(function(a,t){return _.createElement(X,Object.assign({},a,{id:"group-single",ref:t,icon:Pn}))});ke.displayName="GroupSingle";var Rn={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"}}]},Ve=_.forwardRef(function(a,t){return _.createElement(X,Object.assign({},a,{id:"more-down-single",ref:t,icon:Rn}))});Ve.displayName="MoreDownSingle";var Dn={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"}}]},We=_.forwardRef(function(a,t){return _.createElement(X,Object.assign({},a,{id:"move-down-single",ref:t,icon:Dn}))});We.displayName="MoveDownSingle";var jn={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"}}]},$e=_.forwardRef(function(a,t){return _.createElement(X,Object.assign({},a,{id:"move-up-single",ref:t,icon:jn}))});$e.displayName="MoveUpSingle";var Mn={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"}}]},ze=_.forwardRef(function(a,t){return _.createElement(X,Object.assign({},a,{id:"topmost-single",ref:t,icon:Mn}))});ze.displayName="TopmostSingle";var xn={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"}}]},Ke=_.forwardRef(function(a,t){return _.createElement(X,Object.assign({},a,{id:"ungroup-single",ref:t,icon:xn}))});Ke.displayName="UngroupSingle";const On=a=>{const{arrangeShow:t,drawings:n}=a,e=G.useDependency(p.LocaleService),r=G.useDependency(M.IDrawingManagerService),i=g=>g?"block":"none",[s,o]=_.useState(n);_.useEffect(()=>{const g=r.focus$.subscribe(u=>{o(u)});return()=>{g.unsubscribe()}},[]);const l=g=>{const u=s[0].unitId,d=s[0].subUnitId,h=s.map(f=>f.drawingId);r.featurePluginOrderUpdateNotification({unitId:u,subUnitId:d,drawingIds:h,arrangeType:g})};return c.jsxs("div",{className:m.imageCommonPanelGrid,style:{display:i(t)},children:[c.jsx("div",{className:m.imageCommonPanelRow,children:c.jsx("div",{className:T(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:T(m.imageCommonPanelColumn,m.imageCommonPanelSpan2),children:c.jsx(W.Button,{size:"small",onClick:()=>{l(p.ArrangeTypeEnum.forward)},children:c.jsxs("span",{className:m.imageCommonPanelInline,children:[c.jsx($e,{}),e.t("image-panel.arrange.forward")]})})}),c.jsx("div",{className:T(m.imageCommonPanelColumn,m.imageCommonPanelSpan2),children:c.jsx(W.Button,{size:"small",onClick:()=>{l(p.ArrangeTypeEnum.backward)},children:c.jsxs("span",{className:m.imageCommonPanelInline,children:[c.jsx(We,{}),e.t("image-panel.arrange.backward")]})})})]}),c.jsxs("div",{className:m.imageCommonPanelRow,children:[c.jsx("div",{className:T(m.imageCommonPanelColumn,m.imageCommonPanelSpan2),children:c.jsx(W.Button,{size:"small",onClick:()=>{l(p.ArrangeTypeEnum.front)},children:c.jsxs("span",{className:m.imageCommonPanelInline,children:[c.jsx(ze,{}),e.t("image-panel.arrange.front")]})})}),c.jsx("div",{className:T(m.imageCommonPanelColumn,m.imageCommonPanelSpan2),children:c.jsx(W.Button,{size:"small",onClick:()=>{l(p.ArrangeTypeEnum.back)},children:c.jsxs("span",{className:m.imageCommonPanelInline,children:[c.jsx(He,{}),e.t("image-panel.arrange.back")]})})})]})]})},Nn=a=>{const t=G.useDependency(p.LocaleService),n=G.useDependency(y.IRenderManagerService),e=G.useDependency(M.IDrawingManagerService),{hasGroup:r,drawings:i}=a,[s,o]=_.useState(!1),[l,g]=_.useState(!0),[u,d]=_.useState(!0),h=C=>C?"block":"none",f=()=>{const C=e.getFocusDrawings(),{unitId:b,subUnitId:I}=C[0],O=p.Tools.generateRandomId(10),P=y.getGroupState(0,0,C.map(R=>R.transform||{})),B={unitId:b,subUnitId:I,drawingId:O,drawingType:p.DrawingTypeEnum.DRAWING_GROUP,transform:P},D=C.map(R=>{const j=R.transform||{left:0,top:0},{unitId:N,subUnitId:U,drawingId:k}=R;return{unitId:N,subUnitId:U,drawingId:k,transform:{...j,left:j.left-P.left,top:j.top-P.top},groupId:O}});e.featurePluginGroupUpdateNotification([{parent:B,children:D}])},S=C=>{if(C.drawingType!==p.DrawingTypeEnum.DRAWING_GROUP)return;const{unitId:b,subUnitId:I,drawingId:O,transform:P={width:0,height:0}}=C;if(P==null)return;const B=e.getDrawingsByGroup({unitId:b,subUnitId:I,drawingId:O});if(B.length===0)return;const D=B.map(R=>{const{transform:j}=R,{unitId:N,subUnitId:U,drawingId:k}=R,A=y.transformObjectOutOfGroup(j||{},P,P.width||0,P.height||0);return{unitId:N,subUnitId:U,drawingId:k,transform:{...j,...A},groupId:void 0}});return{parent:C,children:D}},v=()=>{const b=e.getFocusDrawings().map(I=>S(I)).filter(I=>I!=null);b.length!==0&&e.featurePluginUngroupUpdateNotification(b)};return _.useEffect(()=>{const C=i[0];if(C==null)return;const{unitId:b}=C,I=n.getRenderById(b),O=I==null?void 0:I.scene;if(O==null)return;const P=O.getTransformerByCreate(),B=P.clearControl$.subscribe(R=>{R===!0&&o(!1)}),D=P.changeStart$.subscribe(R=>{const{objects:j}=R,N=fe(j,e),U=N.filter(z=>(z==null?void 0:z.drawingType)===p.DrawingTypeEnum.DRAWING_GROUP);let k=!1,A=!1;N.length>1&&(k=!0),U.length>0&&(A=!0),o(k||A),g(k),d(A)});return()=>{D.unsubscribe(),B.unsubscribe()}},[]),c.jsxs("div",{className:T(m.imageCommonPanelGrid,m.imageCommonPanelBorder),style:{display:h(r===!0?s:!1)},children:[c.jsx("div",{className:m.imageCommonPanelRow,children:c.jsx("div",{className:T(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:T(m.imageCommonPanelColumn,m.imageCommonPanelSpan2,m.imageCommonPanelColumnCenter),children:c.jsx(W.Button,{size:"small",onClick:()=>{f()},style:{display:h(l)},children:c.jsxs("span",{className:m.imageCommonPanelInline,children:[c.jsx(ke,{}),t.t("image-panel.group.group")]})})}),c.jsx("div",{className:T(m.imageCommonPanelColumn,m.imageCommonPanelSpan2,m.imageCommonPanelColumnCenter),children:c.jsx(W.Button,{size:"small",onClick:()=>{v()},style:{display:h(u)},children:c.jsxs("span",{className:m.imageCommonPanelInline,children:[c.jsx(Ke,{}),t.t("image-panel.group.unGroup")]})})})]})]})},ie=20,En=20,Tn=[-3600,3600],pe=300,Bn=a=>{var je;const t=G.useDependency(p.LocaleService),n=G.useDependency(M.IDrawingManagerService),e=G.useDependency(y.IRenderManagerService),{drawings:r,transformShow:i}=a,s=r[0];if(s==null)return;const o=s.transform;if(o==null)return;const{unitId:l,subUnitId:g,drawingId:u,drawingType:d}=s,h=e.getRenderById(l),f=h==null?void 0:h.scene;if(f==null)return;const S=(je=f.getEngine())==null?void 0:je.activeScene;if(S==null)return;const v=f.getTransformerByCreate(),{width:C=0,height:b=0,left:I=0,top:O=0,angle:P=0}=o,[B,D]=_.useState(C),[R,j]=_.useState(b),[N,U]=_.useState(I),[k,A]=_.useState(O),[ne,z]=_.useState(P),[oe,te]=_.useState(v.keepRatio),re=(w,E,V,$)=>{const{width:H,height:J}=S,{ancestorLeft:F,ancestorTop:Y}=f;let Z=w,ae=E,ge=V,me=$;return w+F<0&&(Z=-F),E+Y<0&&(ae=-Y),ge=H-Z-F,ge<ie&&(ge=ie),me=J-ae-Y,me<ie&&(me=ie),w+ge+F>H&&(Z=H-V-F),E+me+Y>J&&(ae=J-$-Y),{limitLeft:Z,limitTop:ae,limitWidth:ge,limitHeight:me}},ce=w=>{const{objects:E}=w,V=fe(E,n);if(V.length!==1)return;const $=V[0];if($==null)return;const{transform:H}=$;if(H==null)return;const{width:J,height:F,left:Y,top:Z,angle:ae}=H;J!=null&&D(J),F!=null&&j(F),Y!=null&&U(Y),Z!=null&&A(Z),ae!=null&&z(ae)};_.useEffect(()=>{const w=[v.changeStart$.subscribe(E=>{ce(E)}),v.changing$.subscribe(E=>{ce(E)}),v.changeEnd$.subscribe(E=>{ce(E)}),n.focus$.subscribe(E=>{if(E.length!==1)return;const V=n.getDrawingByParam(E[0]);if(V==null)return;const $=V.transform;if($==null)return;const{width:H,height:J,left:F,top:Y,angle:Z}=$;H!=null&&D(H),J!=null&&j(J),F!=null&&U(F),Y!=null&&A(Y),Z!=null&&z(Z)})];return()=>{w.forEach(E=>E.unsubscribe())}},[]);const q=p.debounce(w=>{if(w==null)return;w=Math.max(w,ie);const{limitWidth:E,limitHeight:V}=re(N,k,w,R);w=Math.min(w,E);const $={unitId:l,subUnitId:g,drawingId:u,drawingType:d,transform:{width:w}};if(oe){let H=w/B*R;if(H=Math.max(H,En),H>V)return;j(H),$.transform.height=H}D(w),n.featurePluginUpdateNotification([$]),v.refreshControls().changeNotification()},pe),be=p.debounce(w=>{if(w==null)return;w=Math.max(w,ie);const{limitHeight:E,limitWidth:V}=re(N,k,B,w);w=Math.min(w,E);const $={unitId:l,subUnitId:g,drawingId:u,drawingType:d,transform:{height:w}};if(oe){let H=w/R*B;if(H=Math.max(H,ie),H>V)return;D(H),$.transform.width=H}j(w),n.featurePluginUpdateNotification([$]),v.refreshControls().changeNotification()},pe),Ze=p.debounce(w=>{if(w==null)return;const{limitLeft:E}=re(w,k,B,R);w=E;const V={unitId:l,subUnitId:g,drawingId:u,drawingType:d,transform:{left:w}};U(w),n.featurePluginUpdateNotification([V]),v.refreshControls().changeNotification()},pe),Xe=p.debounce(w=>{if(w==null)return;const{limitTop:E}=re(N,w,B,R);w=E;const V={unitId:l,subUnitId:g,drawingId:u,drawingType:d,transform:{top:w}};A(w),n.featurePluginUpdateNotification([V]),v.refreshControls().changeNotification()},pe),qe=w=>{if(w==null)return;const[E,V]=Tn;w<E&&(w=E),w>V&&(w=V);const $={unitId:l,subUnitId:g,drawingId:u,drawingType:d,transform:{angle:w}};z(w),n.featurePluginUpdateNotification([$]),v.refreshControls().changeNotification()},Je=w=>{te(w),v.keepRatio=w},Qe=w=>w?"block":"none";return c.jsxs("div",{className:T(m.imageCommonPanelGrid,m.imageCommonPanelBorder),style:{display:Qe(i)},children:[c.jsx("div",{className:m.imageCommonPanelRow,children:c.jsx("div",{className:T(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:T(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(W.InputNumber,{precision:1,value:B,onChange:w=>{q(w)},className:m.imageCommonPanelInput})})})]})}),c.jsx("div",{className:T(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(W.InputNumber,{precision:1,value:R,onChange:w=>{be(w)},className:m.imageCommonPanelInput})})})]})}),c.jsx("div",{className:T(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:T(m.imageCommonPanelRow,m.imageCommonPanelRowVertical),children:c.jsx("div",{className:m.imageCommonPanelColumn,children:c.jsx(W.Checkbox,{checked:oe,onChange:Je})})})]})})]}),c.jsxs("div",{className:m.imageCommonPanelRow,children:[c.jsx("div",{className:T(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(W.InputNumber,{precision:1,value:N,onChange:w=>{Ze(w)},className:m.imageCommonPanelInput})})})]})}),c.jsx("div",{className:T(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(W.InputNumber,{precision:1,value:k,onChange:w=>{Xe(w)},className:m.imageCommonPanelInput})})})]})}),c.jsx("div",{className:T(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(W.InputNumber,{precision:1,value:ne,onChange:qe,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 L=(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))(L||{});const he={id:"sheet.operation.Auto-image-crop",type:p.CommandType.OPERATION,handler:(a,t)=>!0},Un=a=>{const t=G.useDependency(p.ICommandService),n=G.useDependency(p.LocaleService),{drawings:e,cropperShow:r}=a;if(e[0]==null)return;const[s,o]=_.useState(L.FREE),l=_.useRef(!1),g=[{label:n.t("image-panel.crop.mode"),value:L.FREE},{label:"1:1",value:L.R1_1},{label:"16:9",value:L.R16_9},{label:"9:16",value:L.R9_16},{label:"5:4",value:L.R5_4},{label:"4:5",value:L.R4_5},{label:"4:3",value:L.R4_3},{label:"3:4",value:L.R3_4},{label:"3:2",value:L.R3_2},{label:"2:3",value:L.R2_3}];_.useEffect(()=>{const f=t.onCommandExecuted(S=>{if(S.id===ee.id){const v=S.params;v!=null&&v.isAuto||(l.current=!1)}});return()=>{f==null||f.dispose()}},[]);function u(f){o(f),l.current&&t.executeCommand(he.id,{cropType:f})}const d=f=>f?"block":"none",h=f=>{t.executeCommand(he.id,{cropType:f}),l.current=!0};return c.jsxs("div",{className:T(m.imageCommonPanelGrid,m.imageCommonPanelBorder),style:{display:d(r)},children:[c.jsx("div",{className:m.imageCommonPanelRow,children:c.jsx("div",{className:T(m.imageCommonPanelColumn,m.imageCommonPanelTitle),children:c.jsx("div",{children:n.t("image-panel.crop.title")})})}),c.jsxs("div",{className:T(m.imageCommonPanelRow,m.imageCommonPanelRowVertical),children:[c.jsx("div",{className:T(m.imageCommonPanelColumn,m.imageCommonPanelSpan2),children:c.jsx(W.Button,{size:"small",onClick:()=>{h(s)},children:c.jsxs("span",{className:m.imageCommonPanelInline,children:[c.jsx(Ge,{}),n.t("image-panel.crop.start")]})})}),c.jsx("div",{className:T(m.imageCommonPanelColumn,m.imageCommonPanelSpan2),children:c.jsx(W.Select,{value:s,options:g,onChange:u})})]})]})},An=a=>{const t=G.useDependency(M.IDrawingManagerService),n=G.useDependency(y.IRenderManagerService),e=G.useDependency(p.LocaleService),{drawings:r,hasArrange:i=!0,hasTransform:s=!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 S=f.getTransformerByCreate(),[v,C]=_.useState(!0),[b,I]=_.useState(!0),[O,P]=_.useState(!1),[B,D]=_.useState(!0),[R,j]=_.useState(!1);return _.useEffect(()=>{const N=S.clearControl$.subscribe(A=>{A===!0&&(C(!1),I(!1),P(!1),D(!1),j(!0))}),U=S.changeStart$.subscribe(A=>{const{objects:ne}=A,z=fe(ne,t);z.length===0?(C(!1),I(!1),P(!1),D(!1),j(!0)):z.length===1?(C(!0),I(!0),P(!1),D(!0),j(!1)):(C(!0),I(!1),P(!0),D(!1),j(!1))}),k=t.focus$.subscribe(A=>{A.length===0?(C(!1),I(!1),P(!1),D(!1),j(!0)):A.length===1?(C(!0),I(!0),P(!1),D(!0),j(!1)):(C(!0),I(!1),P(!0),D(!1),j(!1))});return()=>{U.unsubscribe(),N.unsubscribe(),k.unsubscribe()}},[]),c.jsxs(c.Fragment,{children:[c.jsx("div",{style:{display:R===!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(On,{arrangeShow:i===!0?v:!1,drawings:r}),c.jsx(Bn,{transformShow:s===!0?b:!1,drawings:r}),c.jsx(Cn,{alignShow:o===!0?O:!1,drawings:r}),c.jsx(Un,{cropperShow:l===!0?B:!1,drawings:r}),c.jsx(Nn,{hasGroup:g,drawings:r})]})},Ln="univer-image-popup-menu",Hn="univer-image-popup-menu-item",Gn="univer-image-popup-menu-item-title",kn="univer-btn-container",Vn="univer-btn-container-expand",ue={imagePopupMenu:Ln,imagePopupMenuItem:Hn,imagePopupMenuItemTitle:Gn,btnContainer:kn,btnContainerExpand:Vn},Fe=a=>{var S,v;const t=(v=(S=a.popup)==null?void 0:S.extraProps)==null?void 0:v.menuItems;if(!t)return null;const n=G.useDependency(p.ICommandService),e=G.useDependency(p.LocaleService),[r,i]=_.useState(!1),[s,o]=_.useState(!1),l=()=>{o(!0)},g=()=>{o(!1)},u=C=>{i(C)},d=C=>{n.executeCommand(C.commandId,C.commandParams),i(!1)},h=r||s,f=t.filter(C=>!C.disable);return c.jsx("div",{onMouseEnter:l,onMouseLeave:g,children:c.jsx(W.DropdownLegacy,{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:T(ue.btnContainer,{[ue.btnContainerExpand]:r}),children:[c.jsx(Le,{style:{color:"#35322B"},extend:{colorChannel1:"rgb(var(--green-700, #409f11))"}}),h&&c.jsx(Ve,{style:{color:"#CCCCCC",fontSize:"8px",marginLeft:"8px"}})]})})})},Ye="COMPONENT_IMAGE_POPUP_MENU",Wn="drawing-ui.config",Oe={},De={id:"sheet.operation.image-reset-size",type:p.CommandType.OPERATION,handler:(a,t)=>!0},$n=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 zn=Object.getOwnPropertyDescriptor,Kn=(a,t,n,e)=>{for(var r=e>1?void 0:e?zn(t,n):t,i=a.length-1,s;i>=0;i--)(s=a[i])&&(r=s(r)||r);return r},Ne=(a,t)=>(n,e)=>t(n,e,a);let ve=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(Ye,Fe)),this.disposeWithMe(a.register(Be,$n))}_initCommands(){[we,ee,De,ye,he].forEach(a=>this.disposeWithMe(this._commandService.registerCommand(a)))}_init(){this._initCommands(),this._initCustomComponents()}};ve=Kn([Ne(0,p.Inject(G.ComponentManager)),Ne(1,p.ICommandService)],ve);var Fn=Object.getOwnPropertyDescriptor,Yn=(a,t,n,e)=>{for(var r=e>1?void 0:e?Fn(t,n):t,i=a.length-1,s;i>=0;i--)(s=a[i])&&(r=s(r)||r);return r},Ce=(a,t)=>(n,e)=>t(n,e,a);let Se=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=Te(this._currentUniverService);if(n==null)return;const{unitId:e,subUnitId:r}=n;Object.keys(t).forEach(i=>{Object.keys(t[i]).forEach(s=>{const o=t[i][s].data;o==null||i!==e||s!==r||Object.keys(o).forEach(l=>{o[l]&&this._insertDrawing([{unitId:i,subUnitId:s,drawingId:l}])})})})}_commandExecutedListener(){this.disposeWithMe(this._commandService.onCommandExecuted(t=>{if(t.id===ye.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:i,drawingId:s}=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 S=M.getDrawingShapeKeyByDrawingSearch(f),v=l.getObjectIncludeInGroup(S);if(v==null||u.includes(v))return;u.push(v);const{transform:C}=f;C!=null&&(v.classType===y.RENDER_CLASS_TYPE.GROUP?v.transformByState({left:C.left,top:C.top}):v.transformByState(C))}),u.length===0)return;const d=M.getDrawingShapeKeyByDrawingSearch({unitId:r,subUnitId:i,drawingId:s}),h=new y.Group(d);l.addObject(h,y.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:i,transformer:s}=r;e.forEach(d=>{const h=M.getDrawingShapeKeyByDrawingSearch(d),f=i.getObjectIncludeInGroup(h);if(f==null)return!0;if(f==null)return;const{transform:S}=d;S!=null&&(f.classType===y.RENDER_CLASS_TYPE.GROUP?f.transformByState({left:S.left,top:S.top}):f.transformByState(S))});const o=M.getDrawingShapeKeyByDrawingSearch(n),l=i.getObject(o),{width:g,height:u}=l;l.getObjects().forEach(d=>{l.removeSelfObjectAndTransform(d.oKey,g,u)}),l.dispose(),s.clearSelectedObjects()}_drawingAlign(t){const{alignType:n}=t,e=this._drawingManagerService.getFocusDrawings();if(n===x.default)return;const r=[];let i=Number.POSITIVE_INFINITY,s=Number.POSITIVE_INFINITY,o=Number.NEGATIVE_INFINITY,l=Number.NEGATIVE_INFINITY,g=0;e.forEach(u=>{const{unitId:d,subUnitId:h,drawingId:f,drawingType:S}=u,v=this._drawingManagerService.getDrawingByParam({unitId:d,subUnitId:h,drawingId:f});if(v==null||v.transform==null)return;r.push({unitId:d,subUnitId:h,drawingId:f,drawingType:S,transform:v.transform});const{left:C=0,top:b=0,width:I=0,height:O=0}=v.transform;i=Math.min(i,C),s=Math.min(s,b),o=Math.max(o,C+I),l=Math.max(l,b+O),g++}),g!==0&&(this._sortDrawingTransform(r,n),this._applyAlignType(r,n,i,s,o,l,g))}_applyAlignType(t,n,e,r,i,s,o){const l=Math.round((i-e)/o*10)/10,g=Math.round((s-r)/o*10)/10,u=[],d=this._getSceneAndTransformerByDrawingSearch(t[0].unitId);if(d==null)return;const{scene:h,transformer:f}=d;t.forEach((S,v)=>{const{unitId:C,subUnitId:b,drawingId:I,transform:O,drawingType:P}=S,{left:B=0,top:D=0,width:R=0,height:j=0}=O;let N=B,U=D;switch(n){case x.left:N=e;break;case x.center:N=e+(i-e)/2-R/2;break;case x.right:N=i-R;break;case x.top:U=r;break;case x.middle:U=r+(s-r)/2-j/2;break;case x.bottom:U=s-j;break;case x.horizon:N=e+l*v;break;case x.vertical:U=r+g*v;break}(N!==B||U!==D)&&u.push({unitId:C,subUnitId:b,drawingId:I,drawingType:P,transform:{left:N,top:U}})}),this._drawingManagerService.featurePluginUpdateNotification(u),f.refreshControls().changeNotification()}_sortDrawingTransform(t,n){t.sort((e,r)=>{const i=e.transform,s=r.transform,{left:o=0,top:l=0,width:g=0,height:u=0}=i,{left:d=0,top:h=0,width:f=0,height:S=0}=s;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+S/2);case x.bottom:return l+u-(h+S);case x.horizon:return o+g/2-(d+f/2);case x.vertical:return l+u/2-(h+S/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,i=this._getSceneAndTransformerByDrawingSearch(n);if(i==null)return;const{scene:s}=i;r.forEach(o=>{const l=M.getDrawingShapeKeyByDrawingSearch({unitId:n,subUnitId:e,drawingId:o}),g=s.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 s=this._getSceneAndTransformerByDrawingSearch(r);if(s==null)return;const{scene:o}=s;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:i}=n,s=this._getSceneAndTransformerByDrawingSearch(e);if(s==null)return;const{scene:o}=s,l=M.getDrawingShapeKeyByDrawingSearch({unitId:e,subUnitId:r,drawingId:i}),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=>{var R;const{unitId:e,subUnitId:r,drawingId:i}=n,s=this._drawingManagerService.getDrawingByParam(n);if(s==null)return;const{transform:o,drawingType:l}=s,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:S=0,height:v=0,angle:C=0,flipX:b=!1,flipY:I=!1,skewX:O=0,skewY:P=0}=o,B=M.getDrawingShapeKeyByDrawingSearch({unitId:e,subUnitId:r,drawingId:i}),D=u.getObject(B);if(D==null)return!0;D.transformByState({left:h,top:f,width:S,height:v,angle:C,flipX:b,flipY:I,skewX:O,skewY:P}),(R=u.getTransformer())==null||R.debounceRefreshControls()})}))}_drawingRefreshListener(){this.disposeWithMe(this._drawingManagerService.refreshTransform$.subscribe(t=>{t.forEach(n=>{const{unitId:e,subUnitId:r,drawingId:i}=n,s=this._getSceneAndTransformerByDrawingSearch(e);if(s==null)return;const o=this._drawingManagerService.getDrawingByParam(n);if(o==null)return;const{transform:l}=o,{scene:g}=s,u=M.getDrawingShapeKeyByDrawingSearch({unitId:e,subUnitId:r,drawingId:i}),d=g.getObject(u);if(d==null||l==null)return!0;const{left:h=0,top:f=0,width:S=0,height:v=0,angle:C=0,flipX:b=!1,flipY:I=!1,skewX:O=0,skewY:P=0}=l;d.transformByState({left:h,top:f,width:S,height:v,angle:C,flipX:b,flipY:I,skewX:O,skewY:P})})}))}_drawingVisibleListener(){this.disposeWithMe(this._drawingManagerService.visible$.subscribe(t=>{t.forEach(n=>{const{unitId:e,subUnitId:r,drawingId:i,visible:s}=n,o=this._getSceneAndTransformerByDrawingSearch(e);if(o==null)return;const{scene:l}=o,g=M.getDrawingShapeKeyByDrawingSearch({unitId:e,subUnitId:r,drawingId:i}),u=l.getObject(g);if(u==null)return!0;s?u.show():u.hide()})}))}_filterUpdateParams(t,n){return t.filter((e,r)=>{if(e==null)return!1;const{transform:i}=e;return p.checkIfMove(i,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:i}=r,s=Array.from(i.values()),o=[];e=s.map(l=>{const{left:g,top:u,height:d,width:h,angle:f,oKey:S,isInGroup:v}=l,C=this._drawingManagerService.getDrawingOKey(S);if(v||l instanceof y.Group){let b=l.ancestorGroup;if(b==null&&l instanceof y.Group&&(b=l),b==null)return null;const I=this._drawingManagerService.getDrawingOKey(b.oKey);if(I){const{unitId:O,subUnitId:P,drawingId:B}=I;o.push({unitId:O,subUnitId:P,drawingId:B});const{left:D,top:R,height:j,width:N,angle:U}=b;return{left:D,top:R,height:j,width:N,angle:U}}}else if(C!=null){const{unitId:b,subUnitId:I,drawingId:O}=C;return o.push({unitId:b,subUnitId:I,drawingId:O}),{left:g,top:u,height:d,width:h,angle:f}}return null}).filter(l=>l!=null),o.length>0?this._commandService.syncExecuteCommand(M.SetDrawingSelectedOperation.id,o):this._commandService.syncExecuteCommand(M.SetDrawingSelectedOperation.id,[])}))),this.disposeWithMe(p.toDisposable(n.changeEnd$.subscribe(r=>{const{objects:i}=r,s=this._filterUpdateParams(fe(i,this._drawingManagerService),e);s.length>0&&this._drawingManagerService.featurePluginUpdateNotification(s)})))}};Se=Yn([Ce(0,p.IUniverInstanceService),Ce(1,p.ICommandService),Ce(2,y.IRenderManagerService),Ce(3,M.IDrawingManagerService)],Se);class de extends y.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:i,height:s}=r;this._initialCacheCanvas(),(l=this._cacheCanvas)==null||l.clear();const o=(g=this._cacheCanvas)==null?void 0:g.getContext();o!=null&&(o.save(),y.Rect.drawWith(o,{left:0,top:0,width:i,height:s,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,i=0;const{left:s=0,top:o=0,width:l=0,height:g=0,angle:u}=this._applyTransform;if(this._srcRect!=null){const{left:f=0,top:S=0,right:v=0,bottom:C=0}=this._srcRect;n=f,e=S,r=v,i=C}const d=s+n,h=o+e;this.transformByState({left:d,top:h,width:s+l-r-d,height:o+g-i-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 y.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 Zn=Object.getOwnPropertyDescriptor,Xn=(a,t,n,e)=>{for(var r=e>1?void 0:e?Zn(t,n):t,i=a.length-1,s;i>=0;i--)(s=a[i])&&(r=s(r)||r);return r},le=(a,t)=>(n,e)=>t(n,e,a);let _e=class extends p.Disposable{constructor(t,n,e,r,i,s){super();Q(this,"_sceneListenerOnImageMap",new WeakSet);this._commandService=t,this._drawingManagerService=n,this._renderManagerService=e,this._univerInstanceService=r,this._messageService=i,this._localeService=s,this._init()}_init(){this._initOpenCrop(),this._initCloseCrop(),this._initAutoCrop()}_initAutoCrop(){this.disposeWithMe(this._commandService.onCommandExecuted(t=>{if(t.id!==he.id)return;const n=t.params;if(n==null)return;const{cropType:e}=n,r=this._drawingManagerService.getFocusDrawings();if(r.length!==1)return;const i=r[0],{unitId:s,subUnitId:o,drawingId:l}=i,g=this._renderManagerService.getRenderById(s),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=M.getDrawingShapeKeyByDrawingSearch({unitId:s,subUnitId:o,drawingId:l}),f=u.getObject(h);if(!(f instanceof y.Image)){this._messageService.show({type:W.MessageType.Error,content:this._localeService.t("image-cropper.error")});return}f!=null&&(this._updateCropperObject(e,f),this._commandService.executeCommand(we.id,{unitId:s,subUnitId:o,drawingId:l}))}))}_calculateSrcRectByRatio(t,n,e,r,i,s){const o=e/r,l=i/s;let g=e,u=r;o>l?g=r*l:u=e/l;const d=(e-g)/2,h=(r-u)/2;return{left:y.precisionTo(d,1),top:y.precisionTo(h,1),right:y.precisionTo(e-(d+g),1),bottom:y.precisionTo(r-(h+u),1)}}_updateCropperObject(t,n){const{left:e,top:r,width:i,height:s}=n.calculateTransformWithSrcRect();let o;switch(t){case L.R1_1:o=this._calculateSrcRectByRatio(e,r,i,s,1,1);break;case L.R16_9:o=this._calculateSrcRectByRatio(e,r,i,s,16,9);break;case L.R9_16:o=this._calculateSrcRectByRatio(e,r,i,s,9,16);break;case L.R5_4:o=this._calculateSrcRectByRatio(e,r,i,s,5,4);break;case L.R4_5:o=this._calculateSrcRectByRatio(e,r,i,s,4,5);break;case L.R4_3:o=this._calculateSrcRectByRatio(e,r,i,s,4,3);break;case L.R3_4:o=this._calculateSrcRectByRatio(e,r,i,s,3,4);break;case L.R3_2:o=this._calculateSrcRectByRatio(e,r,i,s,3,2);break;case L.R2_3:o=this._calculateSrcRectByRatio(e,r,i,s,2,3);break;case L.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:i-d-l,height:s-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:i}=n,s=this._renderManagerService.getRenderById(e),o=s==null?void 0:s.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:i})==null)return;const g=M.getDrawingShapeKeyByDrawingSearch({unitId:e,subUnitId:r,drawingId:i}),u=o.getObject(g);if(u==null)return;if(!(u instanceof y.Image)){this._messageService.show({type:W.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._commandService.syncExecuteCommand(M.SetDrawingSelectedOperation.id,[{unitId:e,subUnitId:r,drawingId:i}])}))}_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(),i=this._renderManagerService.getRenderById(r),s=i==null?void 0:i.scene;if(s==null)return!0;const o=this._searchCropObject(s);if(o==null)return;const l=this._getApplyObjectByCropObject(o);if(l==null)return;const g=s.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:S,width:v}=o;this._drawingManagerService.featurePluginUpdateNotification([{...d,transform:{...d.transform,left:h,top:f,height:S,width:v},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(Me.switchMap(n=>n?n.activeSheet$:Me.of(null)));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 i=r.getObject(e);return i==null?null:i}_addListenerOnImage(t){const n=t.getTransformerByCreate();let e=null;this.disposeWithMe(n.changeStart$.subscribe(r=>{const{objects:i}=r,s=i.values().next().value;if(s==null||!(s instanceof de))return;const{left:o,top:l,height:g,width:u,angle:d}=s;e={left:o,top:l,height:g,width:u,angle:d},n.clearCopperControl()})),this.disposeWithMe(n.changeEnd$.subscribe(r=>{const{objects:i}=r,s=i.values().next().value;if(s==null||!(s instanceof de))return;const{left:o,top:l,height:g,width:u,angle:d}=s;if(!p.checkIfMove({left:o,top:l,height:g,width:u,angle:d},e))return;const h=this._getApplyObjectByCropObject(s);if(h==null)return;const f=this._getSrcRectByTransformState(h,s);s.refreshSrcRect(f.srcRect,h.getState()),n.createControlForCopper(s)})),this._endCropListener(t)}_addHoverForImageCopper(t){this.disposeWithMe(t.onPointerEnter$.subscribeEvent(()=>{t.cursor=y.CURSOR_TYPE.MOVE})),this.disposeWithMe(t.onPointerLeave$.subscribeEvent(()=>{t.cursor=y.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:i,width:s,strokeWidth:o,angle:l}=n,{left:g,top:u,width:d,height:h,angle:f,strokeWidth:S}=t,v=e-g,C=r-u,b={left:v,top:C,right:d-v-s,bottom:h-C-i},I={...b};if(f!==0){const O=e+s/2,P=r+i/2,B=new y.Vector2(O,P),D=d/2+g,R=h/2+u,j=new y.Vector2(D,R),N=new y.Vector2(g,u);N.rotateByPoint(y.degToRad(f),j);const U=N.clone();U.rotateByPoint(y.degToRad(-f),B);const k=e-U.x,A=r-U.y;I.left=k,I.top=A,I.right=d-k-s,I.bottom=h-A-i}return{srcRect:b,srcRectAngle:I}}};_e=Xn([le(0,p.ICommandService),le(1,M.IDrawingManagerService),le(2,y.IRenderManagerService),le(3,p.IUniverInstanceService),le(4,G.IMessageService),le(5,p.Inject(p.LocaleService))],_e);var qn=Object.getOwnPropertyDescriptor,Jn=(a,t,n,e)=>{for(var r=e>1?void 0:e?qn(t,n):t,i=a.length-1,s;i>=0;i--)(s=a[i])&&(r=s(r)||r);return r},se=(a,t)=>(n,e)=>t(n,e,a);let Ie=class extends p.Disposable{constructor(a,t,n,e,r,i,s){super(),this._commandService=a,this._renderManagerService=t,this._drawingManagerService=n,this._dialogService=e,this._imageIoService=r,this._currentUniverService=i,this._drawingRenderService=s,this._initialize()}dispose(){super.dispose()}_initialize(){this._drawingAddListener(),this._commandExecutedListener(),this._imageUpdateListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.onCommandExecuted(a=>{if(a.id===De.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:i,drawingId:s}=e,o=this._getSceneAndTransformerByDrawingSearch(r);if(o==null)return;const{scene:l}=o,g=M.getDrawingShapeKeyByDrawingSearch({unitId:r,subUnitId:i,drawingId:s}),u=l.getObject(g);if(u==null)return!0;const d=this._drawingManagerService.getDrawingByParam(e);if(d==null)return!0;if(d.drawingType!==p.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._commandService.syncExecuteCommand(M.SetDrawingSelectedOperation.id,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,i=this._getSceneAndTransformerByDrawingSearch(n),s=(g=Te(this._currentUniverService,n))==null?void 0:g.subUnitId;if(i==null||s!==e)return;const o=this._drawingManagerService.getDrawingByParam(t);if(o==null)return;const l=await this._drawingRenderService.renderImages(o,i.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,i=this._drawingManagerService.getDrawingByParam(t);if(i==null)return;const{transform:s,drawingType:o,srcRect:l,prstGeom:g,source:u,imageSourceType:d}=i;if(o!==p.DrawingTypeEnum.DRAWING_IMAGE)return;const h=this._getSceneAndTransformerByDrawingSearch(n);if(h==null)return;const{scene:f,transformer:S}=h;if(s==null)return!0;const v=M.getDrawingShapeKeyByDrawingSearch({unitId:n,subUnitId:e,drawingId:r}),C=f.getObject(v);if(C==null)return!0;C.setSrcRect(l),C.setPrstGeom(g),u!=null&&u.length>0&&(d===p.ImageSourceType.BASE64||d===p.ImageSourceType.URL)&&C.changeSource(u)})}))}_addHoverForImage(a){this.disposeWithMe(p.toDisposable(a.onPointerEnter$.subscribeEvent(()=>{a.cursor=y.CURSOR_TYPE.GRAB}))),this.disposeWithMe(p.toDisposable(a.onPointerLeave$.subscribeEvent(()=>{a.cursor=y.CURSOR_TYPE.DEFAULT})))}_addDialogForImage(a){this.disposeWithMe(p.toDisposable(a.onDblclick$.subscribeEvent(()=>{const t=`${a.oKey}-viewer-dialog`;this._drawingRenderService.previewImage(t,a.getNative().src,a.getNativeSize().width,a.getNativeSize().height)})))}};Ie=Jn([se(0,p.ICommandService),se(1,y.IRenderManagerService),se(2,M.IDrawingManagerService),se(3,G.IDialogService),se(4,M.IImageIoService),se(5,p.IUniverInstanceService),se(6,p.Inject(exports.DrawingRenderService))],Ie);var Qn=Object.getOwnPropertyDescriptor,et=(a,t,n,e)=>{for(var r=e>1?void 0:e?Qn(t,n):t,i=a.length-1,s;i>=0;i--)(s=a[i])&&(r=s(r)||r);return r},Ee=(a,t)=>(n,e)=>t(n,e,a);const nt="UNIVER_DRAWING_UI_PLUGIN";var Re;exports.UniverDrawingUIPlugin=(Re=class extends p.Plugin{constructor(t=Oe,n,e){super(),this._config=t,this._injector=n,this._configService=e;const{menu:r,...i}=p.merge({},Oe,this._config);r&&this._configService.setConfig("menu",r,{merge:!0}),this._configService.setConfig(Wn,i)}onStarting(){this._initDependencies()}onRendered(){this._injector.get(Se),this._injector.get(ve),this._injector.get(_e),this._injector.get(Ie)}_initDependencies(){[[exports.DrawingRenderService],[Se],[ve],[_e],[Ie]].forEach(n=>this._injector.add(n))}},Q(Re,"pluginName",nt),Re);exports.UniverDrawingUIPlugin=et([Ee(1,p.Inject(p.Injector)),Ee(2,p.IConfigService)],exports.UniverDrawingUIPlugin);exports.AutoImageCropOperation=he;exports.COMPONENT_IMAGE_POPUP_MENU=Ye;exports.CloseImageCropOperation=ee;exports.DrawingCommonPanel=An;exports.ImageCropperObject=de;exports.ImagePopupMenu=Fe;exports.ImageResetSizeOperation=De;exports.OpenImageCropOperation=we;exports.SetDrawingAlignOperation=ye;exports.getUpdateParams=fe;