@univerjs/drawing-ui 0.8.0 → 0.8.1-nightly.202506131607
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/index.js +1 -1
- package/lib/es/index.js +1 -1
- package/lib/index.js +1 -1
- package/lib/umd/index.js +1 -1
- package/package.json +8 -8
- package/LICENSE +0 -176
package/lib/cjs/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var ze=Object.defineProperty;var Ye=(i,r,t)=>r in i?ze(i,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[r]=t;var J=(i,r,t)=>Ye(i,typeof r!="symbol"?r+"":r,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("@univerjs/core"),x=require("@univerjs/drawing"),y=require("@univerjs/engine-render"),H=require("@univerjs/ui"),h=require("react/jsx-runtime"),P=require("@univerjs/design"),_=require("react"),Re=require("rxjs");function Me(i,r,t,e){const n=e.getDrawingByParam(i);if(n==null)return;const a=x.getDrawingShapeKeyByDrawingSearch(i),s=t.getObject(a);if(s&&!(s instanceof y.Group))return;if(s!=null){s.addObject(r);return}const o=new y.Group(a);t.addObject(o,y.DRAWING_OBJECT_LAYER_INDEX).attachTransformerTo(o),o.addObject(r);const{transform:c}=n;c&&o.transformByState({left:c.left,top:c.top,angle:c.angle})}function Ee(i,r){var a;const t=r?i.getUnit(r):i.getFocusedUnit();if(t==null)return;const e=t.getUnitId();let n;return t.type===f.UniverInstanceType.UNIVER_SHEET?n=(a=t.getActiveSheet())==null?void 0:a.getSheetId():(t.type===f.UniverInstanceType.UNIVER_DOC||t.type===f.UniverInstanceType.UNIVER_SLIDE)&&(n=e),{unitId:e,subUnitId:n,current:t}}var Xe=Object.getOwnPropertyDescriptor,qe=(i,r,t,e)=>{for(var n=e>1?void 0:e?Xe(r,t):r,a=i.length-1,s;a>=0;a--)(s=i[a])&&(n=s(n)||n);return n},Ie=(i,r)=>(t,e)=>r(t,e,i);exports.DrawingRenderService=class{constructor(r,t,e){this._drawingManagerService=r,this._imageIoService=t,this._galleryService=e}async renderImages(r,t){const{transform:e,drawingType:n,source:a,imageSourceType:s,srcRect:o,prstGeom:c,groupId:u,unitId:l,subUnitId:g,drawingId:d,isMultiTransform:p,transforms:S}=r;if(n!==f.DrawingTypeEnum.DRAWING_IMAGE||!this._drawingManagerService.getDrawingVisible()||e==null)return;const m=p&&S?S:[e],w=[];for(const C of m){const{left:I,top:D,width:j,height:N,angle:b,flipX:M,flipY:R,skewX:E,skewY:O}=C,k=m.indexOf(C),A=x.getDrawingShapeKeyByDrawingSearch({unitId:l,subUnitId:g,drawingId:d},p?k:void 0),W=t.getObject(A);if(W!=null){W.transformByState({left:I,top:D,width:j,height:N,angle:b,flipX:M,flipY:R,skewX:E,skewY:O});continue}const Y=this._drawingManagerService.getDrawingOrder(l,g),ae=Y.indexOf(d),ee={...C,zIndex:ae===-1?Y.length-1:ae},te=this._imageIoService.getImageSourceCache(a,s);let se=!1;if(te!=null)ee.image=te;else{if(s===x.ImageSourceType.UUID)try{ee.url=await this._imageIoService.getImage(a)}catch(Ce){console.error(Ce);continue}else ee.url=a;se=!0}if(t.getObject(A))continue;ee.printable=!0;const X=new y.Image(A,ee);se&&this._imageIoService.addImageSourceCache(a,s,X.getNative()),this._drawingManagerService.getDrawingVisible()&&(t.addObject(X,y.DRAWING_OBJECT_LAYER_INDEX),this._drawingManagerService.getDrawingEditable()&&t.attachTransformerTo(X),u&&Me({drawingId:u,unitId:l,subUnitId:g},X,t,this._drawingManagerService),c!=null&&X.setPrstGeom(c),o!=null&&X.setSrcRect(o),w.push(X))}return w}renderFloatDom(r,t){const{transform:e,drawingType:n,groupId:a,unitId:s,subUnitId:o,drawingId:c,isMultiTransform:u,transforms:l}=r;if(n!==f.DrawingTypeEnum.DRAWING_DOM||!this._drawingManagerService.getDrawingVisible()||e==null)return;const g=u&&l?l:[e],d=[];for(const p of g){const{left:S,top:m,width:w,height:C,angle:I,flipX:D,flipY:j,skewX:N,skewY:b}=p,M=g.indexOf(p),R=x.getDrawingShapeKeyByDrawingSearch({unitId:s,subUnitId:o,drawingId:c},u?M:void 0),E=t.getObject(R);if(E!=null){E.transformByState({left:S,top:m,width:w,height:C,angle:I,flipX:D,flipY:j,skewX:N,skewY:b});continue}const O=this._drawingManagerService.getDrawingOrder(s,o),k=O.indexOf(c),A={...p,zIndex:k===-1?O.length-1:k};if(t.getObject(R))continue;A.printable=!1;const W=new y.Rect(R,A);this._drawingManagerService.getDrawingVisible()&&(t.addObject(W,y.DRAWING_OBJECT_LAYER_INDEX),this._drawingManagerService.getDrawingEditable()&&r.allowTransform!==!1&&t.attachTransformerTo(W),a&&Me({drawingId:a,unitId:s,subUnitId:o},W,t,this._drawingManagerService),d.push(W))}return d}renderDrawing(r,t){const e=this._drawingManagerService.getDrawingByParam(r);if(e!=null)switch(e.drawingType){case f.DrawingTypeEnum.DRAWING_IMAGE:return this.renderImages(e,t)}}previewImage(r,t,e,n){this._galleryService.open({images:[t],onOpenChange:a=>{a||this._galleryService.close()}})}_adjustImageSize(r,t,e,n){if(r<=e&&t<=n)return{width:r,height:t};const a=e/r,s=n/t,o=Math.min(a,s);return{width:Math.floor(r*o),height:Math.floor(t*o)}}};exports.DrawingRenderService=qe([Ie(0,x.IDrawingManagerService),Ie(1,x.IImageIoService),Ie(2,H.IGalleryService)],exports.DrawingRenderService);function de(i,r){const t=[];return i.forEach(e=>{const{oKey:n,left:a,top:s,height:o,width:c,angle:u}=e,l=r.getDrawingOKey(n);if(l==null)return t.push(null),!0;const{unitId:g,subUnitId:d,drawingId:p,drawingType:S}=l,m={unitId:g,subUnitId:d,drawingId:p,drawingType:S,transform:{left:a,top:s,height:o,width:c,angle:u}};S===f.DrawingTypeEnum.DRAWING_IMAGE&&(m.srcRect=e.srcRect),t.push(m)}),t}var T=(i=>(i.default="0",i.left="1",i.center="2",i.right="3",i.top="4",i.middle="5",i.bottom="6",i.horizon="7",i.vertical="8",i))(T||{});const _e={id:"sheet.operation.set-image-align",type:f.CommandType.OPERATION,handler:(i,r)=>!0},Je=i=>{const r=H.useDependency(f.ICommandService),t=H.useDependency(f.LocaleService),{alignShow:e}=i,[n,a]=_.useState(T.default),s=[{label:t.t("image-panel.align.default"),value:T.default},{options:[{label:t.t("image-panel.align.left"),value:T.left},{label:t.t("image-panel.align.center"),value:T.center},{label:t.t("image-panel.align.right"),value:T.right}]},{options:[{label:t.t("image-panel.align.top"),value:T.top},{label:t.t("image-panel.align.middle"),value:T.middle},{label:t.t("image-panel.align.bottom"),value:T.bottom}]},{options:[{label:t.t("image-panel.align.horizon"),value:T.horizon},{label:t.t("image-panel.align.vertical"),value:T.vertical}]}];function o(c){a(c),r.executeCommand(_e.id,{alignType:c})}return h.jsxs("div",{className:P.clsx("univer-relative univer-w-full",{"univer-hidden":!e}),children:[h.jsx("header",{className:"univer-text-gray-600 dark:!univer-text-gray-200",children:h.jsx("div",{children:t.t("image-panel.align.title")})}),h.jsx("div",{className:"univer-relative univer-mt-2.5 univer-flex univer-h-full",children:h.jsx("div",{className:"univer-w-full univer-text-gray-900 dark:!univer-text-white",children:h.jsx(P.Select,{value:n,options:s,onChange:o})})})]})};var $=function(){return $=Object.assign||function(i){for(var r,t=1,e=arguments.length;t<e;t++){r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(i[n]=r[n])}return i},$.apply(this,arguments)},Qe=function(i,r){var t={};for(var e in i)Object.prototype.hasOwnProperty.call(i,e)&&r.indexOf(e)<0&&(t[e]=i[e]);if(i!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,e=Object.getOwnPropertySymbols(i);n<e.length;n++)r.indexOf(e[n])<0&&Object.prototype.propertyIsEnumerable.call(i,e[n])&&(t[e[n]]=i[e[n]]);return t},z=_.forwardRef(function(i,r){var t=i.icon,e=i.id,n=i.className,a=i.extend,s=Qe(i,["icon","id","className","extend"]),o="univerjs-icon univerjs-icon-".concat(e," ").concat(n||"").trim(),c=_.useRef("_".concat(rt()));return Te(t,"".concat(e),{defIds:t.defIds,idSuffix:c.current},$({ref:r,className:o},s),a)});function Te(i,r,t,e,n){return _.createElement(i.tag,$($({key:r},et(i,t,n)),e),(tt(i,t).children||[]).map(function(a,s){return Te(a,"".concat(r,"-").concat(i.tag,"-").concat(s),t,void 0,n)}))}function et(i,r,t){var e=$({},i.attrs);t!=null&&t.colorChannel1&&e.fill==="colorChannel1"&&(e.fill=t.colorChannel1),i.tag==="mask"&&e.id&&(e.id=e.id+r.idSuffix),Object.entries(e).forEach(function(a){var s=a[0],o=a[1];s==="mask"&&typeof o=="string"&&(e[s]=o.replace(/url\(#(.*)\)/,"url(#$1".concat(r.idSuffix,")")))});var n=r.defIds;return!n||n.length===0||(i.tag==="use"&&e["xlink:href"]&&(e["xlink:href"]=e["xlink:href"]+r.idSuffix),Object.entries(e).forEach(function(a){var s=a[0],o=a[1];typeof o=="string"&&(e[s]=o.replace(/url\(#(.*)\)/,"url(#$1".concat(r.idSuffix,")")))})),e}function tt(i,r){var t,e=r.defIds;return!e||e.length===0?i:i.tag==="defs"&&(!((t=i.children)===null||t===void 0)&&t.length)?$($({},i),{children:i.children.map(function(n){return typeof n.attrs.id=="string"&&e&&e.includes(n.attrs.id)?$($({},n),{attrs:$($({},n.attrs),{id:n.attrs.id+r.idSuffix})}):n})}):i}function rt(){return Math.random().toString(36).substring(2,8)}z.displayName="UniverIcon";var nt={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"colorChannel1",d:"M11.0363 12.2367V14.0367C11.0363 14.3681 11.3049 14.6367 11.6363 14.6367C11.9676 14.6367 12.2363 14.3681 12.2363 14.0367V12.2367H14.0364C14.3677 12.2367 14.6364 11.9681 14.6364 11.6367C14.6364 11.3054 14.3677 11.0367 14.0364 11.0367H12.2363V9.23672C12.2363 8.90535 11.9676 8.63672 11.6363 8.63672C11.3049 8.63672 11.0363 8.90535 11.0363 9.23672V11.0367H9.23635C8.90498 11.0367 8.63635 11.3054 8.63635 11.6367C8.63635 11.9681 8.90498 12.2367 9.23635 12.2367H11.0363Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M2.56365 1.36377C1.90091 1.36377 1.36365 1.90103 1.36365 2.56377V6.16377C1.36365 6.82651 1.90091 7.36377 2.56365 7.36377H6.16365C6.82639 7.36377 7.36365 6.82651 7.36365 6.16377V2.56377C7.36365 1.90103 6.82639 1.36377 6.16365 1.36377H2.56365ZM6.16365 2.56377H2.56365L2.56365 6.16377H6.16365V2.56377Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M2.56365 8.63647C1.90091 8.63647 1.36365 9.17373 1.36365 9.83647V13.4365C1.36365 14.0992 1.90091 14.6365 2.56365 14.6365H6.16365C6.82639 14.6365 7.36365 14.0992 7.36365 13.4365V9.83647C7.36365 9.17373 6.82639 8.63647 6.16365 8.63647H2.56365ZM6.16365 9.83647H2.56365L2.56365 13.4365H6.16365V9.83647Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M9.83635 7.36377C9.17361 7.36377 8.63635 6.82651 8.63635 6.16377V2.56377C8.63635 1.90103 9.17361 1.36377 9.83635 1.36377H13.4364C14.0991 1.36377 14.6364 1.90103 14.6364 2.56377V6.16377C14.6364 6.82651 14.0991 7.36377 13.4364 7.36377H9.83635ZM9.83635 6.16377V2.56377L13.4364 2.56377V6.16377H9.83635Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Pe=_.forwardRef(function(i,r){return _.createElement(z,Object.assign({},i,{id:"autofill-double-icon",ref:r,icon:nt}))});Pe.displayName="AutofillDoubleIcon";var it={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 17 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M14.0045 4.4334C14.8881 4.4334 15.6045 3.71705 15.6045 2.8334C15.6045 1.94974 14.8881 1.2334 14.0045 1.2334H3.70449C2.82084 1.2334 2.10449 1.94974 2.10449 2.8334C2.10449 3.71705 2.82084 4.4334 3.70449 4.4334H14.0045ZM14.4045 2.8334C14.4045 3.05431 14.2254 3.2334 14.0045 3.2334H3.70449C3.48358 3.2334 3.30449 3.05431 3.30449 2.8334C3.30449 2.61248 3.48358 2.4334 3.70449 2.4334H14.0045C14.2254 2.4334 14.4045 2.61249 14.4045 2.8334Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M14.1544 8.5999C15.038 8.5999 15.7544 7.88356 15.7544 6.9999C15.7544 6.11625 15.038 5.3999 14.1544 5.3999H3.85439C2.97074 5.3999 2.25439 6.11625 2.25439 6.9999C2.25439 7.88356 2.97074 8.5999 3.85439 8.5999H14.1544ZM14.5544 6.9999C14.5544 7.22082 14.3753 7.3999 14.1544 7.3999H3.85439C3.63348 7.3999 3.45439 7.22082 3.45439 6.9999C3.45439 6.77899 3.63348 6.5999 3.85439 6.5999H14.1544C14.3753 6.5999 14.5544 6.77899 14.5544 6.9999Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M8.57975 14.5902L6.58023 12.5907C6.34591 12.3564 6.34591 11.9765 6.58023 11.7421C6.81454 11.5078 7.19444 11.5078 7.42876 11.7421L8.40449 12.7179V10.1664C8.40449 9.83504 8.67312 9.56641 9.00449 9.56641C9.33586 9.56641 9.60449 9.83504 9.60449 10.1664V12.7179L10.5802 11.7421C10.8145 11.5078 11.1944 11.5078 11.4288 11.7421C11.6631 11.9765 11.6631 12.3564 11.4288 12.5907L9.42923 14.5902"}},{tag:"path",attrs:{fill:"currentColor",d:"M8.57975 14.5902C8.58121 14.5917 8.58268 14.5931 8.58416 14.5946C8.64077 14.6502 8.70566 14.6923 8.77482 14.7209C8.84557 14.7502 8.92314 14.7664 9.00449 14.7664C9.08585 14.7664 9.16342 14.7502 9.23416 14.7209C9.30332 14.6923 9.36821 14.6502 9.42482 14.5946"}}]},Ne=_.forwardRef(function(i,r){return _.createElement(z,Object.assign({},i,{id:"bottom-icon",ref:r,icon:it}))});Ne.displayName="BottomIcon";var at={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M5.97705 7.51296C5.97705 7.18159 6.24568 6.91296 6.57705 6.91296H8.48632C8.81769 6.91296 9.08632 7.18159 9.08632 7.51296C9.08632 7.84433 8.81769 8.11296 8.48632 8.11296H6.57705C6.24568 8.11296 5.97705 7.84433 5.97705 7.51296Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M6.57705 9.41028C6.24568 9.41028 5.97705 9.67891 5.97705 10.0103C5.97705 10.3416 6.24568 10.6103 6.57705 10.6103H10.8199C11.1512 10.6103 11.4199 10.3416 11.4199 10.0103C11.4199 9.67891 11.1512 9.41028 10.8199 9.41028H6.57705Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M3.51074 2.37063C3.51074 1.48697 4.22709 0.77063 5.11074 0.77063H9.80318L9.81294 0.770708C9.97168 0.768161 10.1311 0.82824 10.2511 0.95055L14.4317 5.21408C14.5165 5.30049 14.5697 5.406 14.5917 5.51645C14.6041 5.5644 14.6106 5.61467 14.6106 5.66648V11.6406C14.6106 12.5243 13.8943 13.2406 13.0106 13.2406H5.11074C4.22709 13.2406 3.51074 12.5243 3.51074 11.6406V2.37063ZM10.4032 4.66648V2.81964L12.6063 5.06648H10.8032C10.5823 5.06648 10.4032 4.88739 10.4032 4.66648ZM5.11074 1.97063C4.88983 1.97063 4.71074 2.14972 4.71074 2.37063V11.6406C4.71074 11.8615 4.88983 12.0406 5.11074 12.0406H13.0106C13.2316 12.0406 13.4106 11.8615 13.4106 11.6406V6.26648H10.8032C9.91953 6.26648 9.20318 5.55013 9.20318 4.66648V1.97063H5.11074Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M2.58916 6.6741C2.58916 6.34273 2.32053 6.0741 1.98916 6.0741C1.65779 6.0741 1.38916 6.34273 1.38916 6.6741V12.6294C1.38916 14.0653 2.55322 15.2294 3.98916 15.2294H9.41408C9.74545 15.2294 10.0141 14.9607 10.0141 14.6294C10.0141 14.298 9.74545 14.0294 9.41408 14.0294H3.98916C3.21596 14.0294 2.58916 13.4026 2.58916 12.6294V6.6741Z"}}]},Be=_.forwardRef(function(i,r){return _.createElement(z,Object.assign({},i,{id:"create-copy-icon",ref:r,icon:at}))});Be.displayName="CreateCopyIcon";var st={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 17 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M7.38125 1.16211C6.49759 1.16211 5.78125 1.87845 5.78125 2.76211V5.6377H2.87783C1.99418 5.6377 1.27783 6.35404 1.27783 7.2377V13.2377C1.27783 14.1214 1.99418 14.8377 2.87783 14.8377H8.87783C9.76149 14.8377 10.4778 14.1214 10.4778 13.2377V10.3621H13.3813C14.2649 10.3621 14.9813 9.64577 14.9813 8.76211V2.76211C14.9813 1.87845 14.2649 1.16211 13.3813 1.16211H7.38125ZM10.4778 9.16211H13.3813C13.6022 9.16211 13.7812 8.98302 13.7812 8.76211V2.76211C13.7812 2.5412 13.6022 2.36211 13.3813 2.36211H7.38125C7.16034 2.36211 6.98125 2.5412 6.98125 2.76211V5.6377H8.87783C9.76149 5.6377 10.4778 6.35404 10.4778 7.2377V9.16211ZM6.98125 6.8377H8.87783C9.09875 6.8377 9.27783 7.01678 9.27783 7.2377V9.16211H7.38125C7.16034 9.16211 6.98125 8.98302 6.98125 8.76211V6.8377ZM5.78125 6.8377V8.76211C5.78125 9.64577 6.49759 10.3621 7.38125 10.3621H9.27783V13.2377C9.27783 13.4586 9.09875 13.6377 8.87783 13.6377H2.87783C2.65692 13.6377 2.47783 13.4586 2.47783 13.2377V7.2377C2.47783 7.01678 2.65692 6.8377 2.87783 6.8377H5.78125Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Ue=_.forwardRef(function(i,r){return _.createElement(z,Object.assign({},i,{id:"group-icon",ref:r,icon:st}))});Ue.displayName="GroupIcon";var ot={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M11.3536 6.14645C11.5488 6.34171 11.5488 6.65829 11.3536 6.85355L8.35355 9.85355C8.15829 10.0488 7.84171 10.0488 7.64645 9.85355L4.64645 6.85355C4.45118 6.65829 4.45118 6.34171 4.64645 6.14645C4.84171 5.95118 5.15829 5.95118 5.35355 6.14645L8 8.79289L10.6464 6.14645C10.8417 5.95118 11.1583 5.95118 11.3536 6.14645Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Ae=_.forwardRef(function(i,r){return _.createElement(z,Object.assign({},i,{id:"more-down-icon",ref:r,icon:ot}))});Ae.displayName="MoreDownIcon";var ct={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M1.25 2.96401C1.25 3.84767 1.96634 4.56401 2.85 4.56401H13.15C14.0337 4.56401 14.75 3.84767 14.75 2.96401C14.75 2.08036 14.0337 1.36401 13.15 1.36401H2.85C1.96635 1.36401 1.25 2.08036 1.25 2.96401ZM2.85 3.36401C2.62909 3.36401 2.45 3.18493 2.45 2.96401C2.45 2.7431 2.62909 2.56401 2.85 2.56401H13.15C13.3709 2.56401 13.55 2.7431 13.55 2.96401C13.55 3.18493 13.3709 3.36401 13.15 3.36401H2.85Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M5.57564 11.6118C5.80995 11.3774 6.18985 11.3774 6.42417 11.6118L7.3999 12.5875V6.36951C7.3999 6.03814 7.66853 5.76951 7.9999 5.76951C8.33127 5.76951 8.5999 6.03814 8.5999 6.36951V12.5875L9.57564 11.6118C9.80995 11.3774 10.1899 11.3774 10.4242 11.6118C10.6585 11.8461 10.6585 12.226 10.4242 12.4603L8.4324 14.452C8.32324 14.5655 8.16982 14.6362 7.9999 14.6362C7.82998 14.6362 7.67655 14.5655 7.56739 14.452L5.57564 12.4603C5.34132 12.226 5.34132 11.8461 5.57564 11.6118Z"}}]},Le=_.forwardRef(function(i,r){return _.createElement(z,Object.assign({},i,{id:"move-down-icon",ref:r,icon:ct}))});Le.displayName="MoveDownIcon";var lt={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"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"}}]},He=_.forwardRef(function(i,r){return _.createElement(z,Object.assign({},i,{id:"move-up-icon",ref:r,icon:lt}))});He.displayName="MoveUpIcon";var ut={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 17 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M7.82994 1.40913C7.88746 1.35161 7.95376 1.30821 8.02453 1.27893C8.09527 1.24959 8.17285 1.2334 8.2542 1.2334C8.33555 1.2334 8.41313 1.24959 8.48387 1.27893C8.55464 1.30821 8.62094 1.35161 8.67846 1.40913L10.6785 3.40913C10.9128 3.64345 10.9128 4.02335 10.6785 4.25766C10.4441 4.49198 10.0642 4.49198 9.82994 4.25766L8.8542 3.28193V5.8334C8.8542 6.16477 8.58557 6.4334 8.2542 6.4334C7.92283 6.4334 7.6542 6.16477 7.6542 5.8334V3.28193L6.67846 4.25766C6.44415 4.49198 6.06425 4.49198 5.82994 4.25766C5.59562 4.02335 5.59562 3.64345 5.82994 3.40913L7.82994 1.40913Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M1.50439 9C1.50439 8.11634 2.22074 7.4 3.10439 7.4H13.4044C14.288 7.4 15.0044 8.11634 15.0044 9C15.0044 9.88366 14.2881 10.6 13.4044 10.6H3.1044C2.22074 10.6 1.50439 9.88366 1.50439 9ZM3.10439 8.6C2.88348 8.6 2.70439 8.77909 2.70439 9C2.70439 9.22091 2.88348 9.4 3.1044 9.4H13.4044C13.6253 9.4 13.8044 9.22091 13.8044 9C13.8044 8.77909 13.6253 8.6 13.4044 8.6H3.10439Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M1.6543 13.1665C1.6543 12.2828 2.37064 11.5665 3.2543 11.5665H13.5543C14.438 11.5665 15.1543 12.2828 15.1543 13.1665C15.1543 14.0502 14.438 14.7665 13.5543 14.7665H3.2543C2.37064 14.7665 1.6543 14.0502 1.6543 13.1665ZM3.2543 12.7665C3.03338 12.7665 2.8543 12.9456 2.8543 13.1665C2.8543 13.3874 3.03338 13.5665 3.2543 13.5665H13.5543C13.7752 13.5665 13.9543 13.3874 13.9543 13.1665C13.9543 12.9456 13.7752 12.7665 13.5543 12.7665H3.2543Z",fillRule:"evenodd",clipRule:"evenodd"}}]},ke=_.forwardRef(function(i,r){return _.createElement(z,Object.assign({},i,{id:"topmost-icon",ref:r,icon:ut}))});ke.displayName="TopmostIcon";var gt={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 17 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M7.46855 2.83731C7.46855 2.61639 7.64764 2.4373 7.86855 2.4373H13.8603C14.0812 2.4373 14.2603 2.61639 14.2603 2.8373V9.5049C14.2603 9.72581 14.0812 9.90489 13.8603 9.90489H12.866C12.5346 9.90489 12.266 10.1735 12.266 10.5049C12.266 10.8363 12.5346 11.1049 12.866 11.1049H13.8603C14.7439 11.1049 15.4603 10.3886 15.4603 9.5049V2.8373C15.4603 1.95365 14.7439 1.2373 13.8603 1.2373H7.86855C6.9849 1.2373 6.26855 1.95365 6.26855 2.83731V3.48688C6.26855 3.81825 6.53718 4.08688 6.86855 4.08688C7.19993 4.08688 7.46855 3.81825 7.46855 3.48688V2.83731Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M3.19888 5.56299C2.31522 5.56299 1.59888 6.27933 1.59888 7.16299V13.163C1.59888 14.0466 2.31522 14.763 3.19888 14.763H9.19888C10.0825 14.763 10.7989 14.0466 10.7989 13.163V7.16299C10.7989 6.27933 10.0825 5.56299 9.19888 5.56299H3.19888ZM2.79888 7.16299C2.79888 6.94207 2.97796 6.76299 3.19888 6.76299H9.19888C9.41979 6.76299 9.59888 6.94207 9.59888 7.16299V13.163C9.59888 13.3839 9.41979 13.563 9.19888 13.563H3.19888C2.97796 13.563 2.79888 13.3839 2.79888 13.163V7.16299Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Ge=_.forwardRef(function(i,r){return _.createElement(z,Object.assign({},i,{id:"ungroup-icon",ref:r,icon:gt}))});Ge.displayName="UngroupIcon";const dt=i=>{const{arrangeShow:r,drawings:t}=i,e=H.useDependency(f.LocaleService),n=H.useDependency(x.IDrawingManagerService),[a,s]=_.useState(t);_.useEffect(()=>{const c=n.focus$.subscribe(u=>{s(u)});return()=>{c.unsubscribe()}},[]);const o=c=>{const u=a[0].unitId,l=a[0].subUnitId,g=a.map(d=>d.drawingId);n.featurePluginOrderUpdateNotification({unitId:u,subUnitId:l,drawingIds:g,arrangeType:c})};return h.jsxs("div",{className:P.clsx("univer-grid univer-gap-2 univer-py-2 univer-text-gray-400",{"univer-hidden":!r}),children:[h.jsx("header",{className:"univer-text-gray-600 dark:!univer-text-gray-200",children:h.jsx("div",{children:e.t("image-panel.arrange.title")})}),h.jsxs("div",{className:"univer-grid univer-grid-cols-2 univer-gap-2 univer-px-8",children:[h.jsxs(P.Button,{onClick:()=>{o(f.ArrangeTypeEnum.forward)},children:[h.jsx(He,{}),e.t("image-panel.arrange.forward")]}),h.jsxs(P.Button,{onClick:()=>{o(f.ArrangeTypeEnum.backward)},children:[h.jsx(Le,{}),e.t("image-panel.arrange.backward")]}),h.jsxs(P.Button,{onClick:()=>{o(f.ArrangeTypeEnum.front)},children:[h.jsx(ke,{}),e.t("image-panel.arrange.front")]}),h.jsxs(P.Button,{onClick:()=>{o(f.ArrangeTypeEnum.back)},children:[h.jsx(Ne,{}),e.t("image-panel.arrange.back")]})]})]})},ht=i=>{const r=H.useDependency(f.LocaleService),t=H.useDependency(y.IRenderManagerService),e=H.useDependency(x.IDrawingManagerService),{hasGroup:n,drawings:a}=i,[s,o]=_.useState(!1),[c,u]=_.useState(!0),[l,g]=_.useState(!0),d=()=>{const m=e.getFocusDrawings(),{unitId:w,subUnitId:C}=m[0],I=f.Tools.generateRandomId(10),D=y.getGroupState(0,0,m.map(b=>b.transform||{})),j={unitId:w,subUnitId:C,drawingId:I,drawingType:f.DrawingTypeEnum.DRAWING_GROUP,transform:D},N=m.map(b=>{const M=b.transform||{left:0,top:0},{unitId:R,subUnitId:E,drawingId:O}=b;return{unitId:R,subUnitId:E,drawingId:O,transform:{...M,left:M.left-D.left,top:M.top-D.top},groupId:I}});e.featurePluginGroupUpdateNotification([{parent:j,children:N}])},p=m=>{if(m.drawingType!==f.DrawingTypeEnum.DRAWING_GROUP)return;const{unitId:w,subUnitId:C,drawingId:I,transform:D={width:0,height:0}}=m;if(D==null)return;const j=e.getDrawingsByGroup({unitId:w,subUnitId:C,drawingId:I});if(j.length===0)return;const N=j.map(b=>{const{transform:M}=b,{unitId:R,subUnitId:E,drawingId:O}=b,k=y.transformObjectOutOfGroup(M||{},D,D.width||0,D.height||0);return{unitId:R,subUnitId:E,drawingId:O,transform:{...M,...k},groupId:void 0}});return{parent:m,children:N}},S=()=>{const w=e.getFocusDrawings().map(C=>p(C)).filter(C=>C!=null);w.length!==0&&e.featurePluginUngroupUpdateNotification(w)};return _.useEffect(()=>{const m=a[0];if(m==null)return;const{unitId:w}=m,C=t.getRenderById(w),I=C==null?void 0:C.scene;if(I==null)return;const D=I.getTransformerByCreate(),j=D.clearControl$.subscribe(b=>{b===!0&&o(!1)}),N=D.changeStart$.subscribe(b=>{const{objects:M}=b,R=de(M,e),E=R.filter(W=>(W==null?void 0:W.drawingType)===f.DrawingTypeEnum.DRAWING_GROUP);let O=!1,k=!1;R.length>1&&(O=!0),E.length>0&&(k=!0),o(O||k),u(O),g(k)});return()=>{N.unsubscribe(),j.unsubscribe()}},[]),h.jsxs("div",{className:P.clsx("univer-grid univer-gap-2 univer-py-2 univer-text-gray-400",{"univer-hidden":n===!0&&s===!1||n===!1}),children:[h.jsx("header",{className:"univer-text-gray-600 dark:!univer-text-gray-200",children:h.jsx("div",{children:r.t("image-panel.group.title")})}),h.jsxs("div",{className:"univer-flex univer-items-center univer-justify-center univer-gap-2",children:[h.jsxs(P.Button,{className:P.clsx({"univer-hidden":!c}),onClick:d,children:[h.jsx(Ue,{}),r.t("image-panel.group.group")]}),h.jsxs(P.Button,{className:P.clsx({"univer-hidden":!l}),onClick:S,children:[h.jsx(Ge,{}),r.t("image-panel.group.unGroup")]})]})]})},ne=20,ft=20,pt=[-3600,3600],he=300,mt=i=>{var De;const r=H.useDependency(f.LocaleService),t=H.useDependency(x.IDrawingManagerService),e=H.useDependency(y.IRenderManagerService),{drawings:n,transformShow:a}=i,s=n[0];if(s==null)return;const o=s.transform;if(o==null)return;const{unitId:c,subUnitId:u,drawingId:l,drawingType:g}=s,d=e.getRenderById(c),p=d==null?void 0:d.scene;if(p==null)return;const S=(De=p.getEngine())==null?void 0:De.activeScene;if(S==null)return;const m=p.getTransformerByCreate(),{width:w=0,height:C=0,left:I=0,top:D=0,angle:j=0}=o,[N,b]=_.useState(w),[M,R]=_.useState(C),[E,O]=_.useState(I),[k,A]=_.useState(D),[W,Y]=_.useState(j),[ae,ee]=_.useState(m.keepRatio),te=(v,B,G,V)=>{const{width:L,height:q}=S,{ancestorLeft:K,ancestorTop:Z}=p;let F=v,re=B,ce=G,le=V;return v+K<0&&(F=-K),B+Z<0&&(re=-Z),ce=L-F-K,ce<ne&&(ce=ne),le=q-re-Z,le<ne&&(le=ne),v+ce+K>L&&(F=L-G-K),B+le+Z>q&&(re=q-V-Z),{limitLeft:F,limitTop:re,limitWidth:ce,limitHeight:le}},se=v=>{const{objects:B}=v,G=de(B,t);if(G.length!==1)return;const V=G[0];if(V==null)return;const{transform:L}=V;if(L==null)return;const{width:q,height:K,left:Z,top:F,angle:re}=L;q!=null&&b(q),K!=null&&R(K),Z!=null&&O(Z),F!=null&&A(F),re!=null&&Y(re)};_.useEffect(()=>{const v=[m.changeStart$.subscribe(B=>{se(B)}),m.changing$.subscribe(B=>{se(B)}),m.changeEnd$.subscribe(B=>{se(B)}),t.focus$.subscribe(B=>{if(B.length!==1)return;const G=t.getDrawingByParam(B[0]);if(G==null)return;const V=G.transform;if(V==null)return;const{width:L,height:q,left:K,top:Z,angle:F}=V;L!=null&&b(L),q!=null&&R(q),K!=null&&O(K),Z!=null&&A(Z),F!=null&&Y(F)})];return()=>{v.forEach(B=>B.unsubscribe())}},[]);const X=f.debounce(v=>{if(v==null)return;v=Math.max(v,ne);const{limitWidth:B,limitHeight:G}=te(E,k,v,M);v=Math.min(v,B);const V={unitId:c,subUnitId:u,drawingId:l,drawingType:g,transform:{width:v}};if(ae){let L=v/N*M;if(L=Math.max(L,ft),L>G)return;R(L),V.transform.height=L}b(v),t.featurePluginUpdateNotification([V]),m.refreshControls().changeNotification()},he),Ce=f.debounce(v=>{if(v==null)return;v=Math.max(v,ne);const{limitHeight:B,limitWidth:G}=te(E,k,N,v);v=Math.min(v,B);const V={unitId:c,subUnitId:u,drawingId:l,drawingType:g,transform:{height:v}};if(ae){let L=v/M*N;if(L=Math.max(L,ne),L>G)return;b(L),V.transform.width=L}R(v),t.featurePluginUpdateNotification([V]),m.refreshControls().changeNotification()},he),$e=f.debounce(v=>{if(v==null)return;const{limitLeft:B}=te(v,k,N,M);v=B;const G={unitId:c,subUnitId:u,drawingId:l,drawingType:g,transform:{left:v}};O(v),t.featurePluginUpdateNotification([G]),m.refreshControls().changeNotification()},he),Ke=f.debounce(v=>{if(v==null)return;const{limitTop:B}=te(E,v,N,M);v=B;const G={unitId:c,subUnitId:u,drawingId:l,drawingType:g,transform:{top:v}};A(v),t.featurePluginUpdateNotification([G]),m.refreshControls().changeNotification()},he),Ze=v=>{if(v==null)return;const[B,G]=pt;v<B&&(v=B),v>G&&(v=G);const V={unitId:c,subUnitId:u,drawingId:l,drawingType:g,transform:{angle:v}};Y(v),t.featurePluginUpdateNotification([V]),m.refreshControls().changeNotification()},Fe=v=>{ee(v),m.keepRatio=v};return h.jsxs("div",{className:P.clsx("univer-grid univer-gap-2 univer-py-2 univer-text-gray-400",{"univer-hidden":!a}),children:[h.jsx("header",{className:"univer-text-gray-600 dark:!univer-text-gray-200",children:h.jsx("div",{children:r.t("image-panel.transform.title")})}),h.jsxs("div",{className:"univer-grid univer-grid-cols-3 univer-gap-2 [&>div]:univer-grid [&>div]:univer-gap-2",children:[h.jsxs("div",{children:[h.jsx("span",{children:r.t("image-panel.transform.width")}),h.jsx(P.InputNumber,{precision:1,value:N,onChange:v=>{X(v)}})]}),h.jsxs("div",{children:[h.jsx("span",{children:r.t("image-panel.transform.height")}),h.jsx(P.InputNumber,{precision:1,value:M,onChange:v=>{Ce(v)}})]}),h.jsxs("div",{children:[h.jsx("span",{children:r.t("image-panel.transform.lock")}),h.jsx("div",{className:"univer-text-center",children:h.jsx(P.Checkbox,{checked:ae,onChange:Fe})})]})]}),h.jsxs("div",{className:"univer-grid univer-grid-cols-3 univer-gap-2 [&>div]:univer-grid [&>div]:univer-gap-2",children:[h.jsxs("div",{children:[h.jsx("span",{children:r.t("image-panel.transform.x")}),h.jsx(P.InputNumber,{precision:1,value:E,onChange:v=>{$e(v)}})]}),h.jsxs("div",{children:[h.jsx("span",{children:r.t("image-panel.transform.y")}),h.jsx(P.InputNumber,{precision:1,value:k,onChange:v=>{Ke(v)}})]}),h.jsxs("div",{children:[h.jsx("span",{children:r.t("image-panel.transform.rotate")}),h.jsx(P.InputNumber,{precision:1,value:W,onChange:Ze})]})]})]})},pe={id:"sheet.operation.open-image-crop",type:f.CommandType.OPERATION,handler:(i,r)=>!0},Q={id:"sheet.operation.close-image-crop",type:f.CommandType.OPERATION,handler:(i,r)=>!0};var U=(i=>(i.FREE="0",i.R1_1="1",i.R16_9="2",i.R9_16="3",i.R5_4="4",i.R4_5="5",i.R4_3="6",i.R3_4="7",i.R3_2="8",i.R2_3="9",i))(U||{});const ge={id:"sheet.operation.Auto-image-crop",type:f.CommandType.OPERATION,handler:(i,r)=>!0},wt=i=>{const r=H.useDependency(f.ICommandService),t=H.useDependency(f.LocaleService),{drawings:e,cropperShow:n}=i;if(e[0]==null)return;const[s,o]=_.useState(U.FREE),c=_.useRef(!1),u=[{label:t.t("image-panel.crop.mode"),value:U.FREE},{label:"1:1",value:U.R1_1},{label:"16:9",value:U.R16_9},{label:"9:16",value:U.R9_16},{label:"5:4",value:U.R5_4},{label:"4:5",value:U.R4_5},{label:"4:3",value:U.R4_3},{label:"3:4",value:U.R3_4},{label:"3:2",value:U.R3_2},{label:"2:3",value:U.R2_3}];_.useEffect(()=>{const d=r.onCommandExecuted(p=>{if(p.id===Q.id){const S=p.params;S!=null&&S.isAuto||(c.current=!1)}});return()=>{d==null||d.dispose()}},[]);function l(d){o(d),c.current&&r.executeCommand(ge.id,{cropType:d})}const g=d=>{r.executeCommand(ge.id,{cropType:d}),c.current=!0};return h.jsxs("div",{className:P.clsx("univer-grid univer-gap-2 univer-py-2 univer-text-gray-400",{"univer-hidden":!n}),children:[h.jsx("header",{className:"univer-text-gray-600 dark:!univer-text-gray-200",children:h.jsx("div",{children:t.t("image-panel.crop.title")})}),h.jsxs("div",{className:"univer-flex univer-items-center univer-justify-center univer-gap-2",children:[h.jsxs(P.Button,{onClick:()=>{g(s)},children:[h.jsx(Be,{}),t.t("image-panel.crop.start")]}),h.jsx(P.Select,{value:s,options:u,onChange:l})]})]})},vt=i=>{const r=H.useDependency(x.IDrawingManagerService),t=H.useDependency(y.IRenderManagerService),e=H.useDependency(f.LocaleService),{drawings:n,hasArrange:a=!0,hasTransform:s=!0,hasAlign:o=!0,hasCropper:c=!0,hasGroup:u=!0}=i,l=n[0];if(l==null)return;const{unitId:g}=l,d=t.getRenderById(g),p=d==null?void 0:d.scene;if(p==null)return;const S=p.getTransformerByCreate(),[m,w]=_.useState(!0),[C,I]=_.useState(!0),[D,j]=_.useState(!1),[N,b]=_.useState(!0),[M,R]=_.useState(!1);return _.useEffect(()=>{const E=S.clearControl$.subscribe(A=>{A===!0&&(w(!1),I(!1),j(!1),b(!1),R(!0))}),O=S.changeStart$.subscribe(A=>{const{objects:W}=A,Y=de(W,r);Y.length===0?(w(!1),I(!1),j(!1),b(!1),R(!0)):Y.length===1?(w(!0),I(!0),j(!1),b(!0),R(!1)):(w(!0),I(!1),j(!0),b(!1),R(!1))}),k=r.focus$.subscribe(A=>{A.length===0?(w(!1),I(!1),j(!1),b(!1),R(!0)):A.length===1?(w(!0),I(!0),j(!1),b(!0),R(!1)):(w(!0),I(!1),j(!0),b(!1),R(!1))});return()=>{O.unsubscribe(),E.unsubscribe(),k.unsubscribe()}},[]),h.jsxs(h.Fragment,{children:[h.jsx("div",{className:P.clsx("univer-h-full",{"univer-hidden":!M}),children:h.jsx("div",{className:"univer-flex univer-h-full univer-items-center univer-justify-center",children:h.jsx("span",{children:e.t("image-panel.null")})})}),h.jsx(dt,{arrangeShow:a===!0?m:!1,drawings:n}),h.jsx(mt,{transformShow:s===!0?C:!1,drawings:n}),h.jsx(Je,{alignShow:o===!0?D:!1,drawings:n}),h.jsx(wt,{cropperShow:c===!0?N:!1,drawings:n}),h.jsx(ht,{hasGroup:u,drawings:n})]})};function Ve(i){var m;const{popup:r}=i,t=(m=r==null?void 0:r.extraProps)==null?void 0:m.menuItems;if(!t)return null;const e=H.useDependency(f.ICommandService),n=H.useDependency(f.LocaleService),[a,s]=_.useState(!1),[o,c]=_.useState(!1),u=()=>{c(!0)},l=()=>{c(!1)},g=w=>{s(w)},d=w=>{e.executeCommand(w.commandId,w.commandParams),s(!1)},p=a||o,S=t.filter(w=>!w.disable);return h.jsx("div",{onMouseEnter:u,onMouseLeave:l,children:h.jsx(P.DropdownMenu,{align:"start",items:S.map(w=>({type:"item",children:n.t(w.label),onSelect:()=>d(w)})),open:a,onOpenChange:g,children:h.jsxs("div",{className:P.clsx("univer-flex univer-items-center univer-gap-2 univer-rounded univer-p-1 dark:hover:!univer-bg-gray-800 hover:univer-bg-gray-100",P.borderClassName,{"univer-bg-gray-100 dark:!univer-bg-gray-800":a,"univer-bg-white dark:!univer-bg-gray-900":!a}),children:[h.jsx(Pe,{className:"univer-fill-primary-600 univer-text-gray-900 dark:!univer-text-white"}),p&&h.jsx(Ae,{className:"dark:!univer-text-white"})]})})})}const We="COMPONENT_IMAGE_POPUP_MENU",St="drawing-ui.config",Oe={},be={id:"sheet.operation.image-reset-size",type:f.CommandType.OPERATION,handler:(i,r)=>!0};var _t=Object.getOwnPropertyDescriptor,Ct=(i,r,t,e)=>{for(var n=e>1?void 0:e?_t(r,t):r,a=i.length-1,s;a>=0;a--)(s=i[a])&&(n=s(n)||n);return n},xe=(i,r)=>(t,e)=>r(t,e,i);let me=class extends f.Disposable{constructor(i,r){super(),this._componentManager=i,this._commandService=r,this._init()}_initCustomComponents(){const i=this._componentManager;this.disposeWithMe(i.register(We,Ve))}_initCommands(){[pe,Q,be,_e,ge].forEach(i=>this.disposeWithMe(this._commandService.registerCommand(i)))}_init(){this._initCommands(),this._initCustomComponents()}};me=Ct([xe(0,f.Inject(H.ComponentManager)),xe(1,f.ICommandService)],me);var It=Object.getOwnPropertyDescriptor,yt=(i,r,t,e)=>{for(var n=e>1?void 0:e?It(r,t):r,a=i.length-1,s;a>=0;a--)(s=i[a])&&(n=s(n)||n);return n},fe=(i,r)=>(t,e)=>r(t,e,i);let we=class extends f.Disposable{constructor(r,t,e,n){super();J(this,"_sceneListenerOnDrawingMap",new WeakSet);this._currentUniverService=r,this._commandService=t,this._renderManagerService=e,this._drawingManagerService=n,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 r=this._drawingManagerService.drawingManagerData,t=Ee(this._currentUniverService);if(t==null)return;const{unitId:e,subUnitId:n}=t;Object.keys(r).forEach(a=>{Object.keys(r[a]).forEach(s=>{const o=r[a][s].data;o==null||a!==e||s!==n||Object.keys(o).forEach(c=>{o[c]&&this._insertDrawing([{unitId:a,subUnitId:s,drawingId:c}])})})})}_commandExecutedListener(){this.disposeWithMe(this._commandService.onCommandExecuted(r=>{if(r.id===_e.id){const t=r.params;if(t==null)return;this._drawingAlign(t)}}))}_drawingGroupListener(){this.disposeWithMe(this._drawingManagerService.group$.subscribe(r=>{this._groupDrawings(r)})),this.disposeWithMe(this._drawingManagerService.ungroup$.subscribe(r=>{this._ungroupDrawings(r)}))}_getSceneAndTransformerByDrawingSearch(r){if(r==null)return;const t=this._renderManagerService.getRenderById(r),e=t==null?void 0:t.scene;if(e==null)return null;const n=e.getTransformerByCreate();return{scene:e,transformer:n}}_groupDrawings(r){r.forEach(t=>{this._groupDrawing(t)})}_groupDrawing(r){const{parent:t,children:e}=r,{unitId:n,subUnitId:a,drawingId:s}=t,o=this._getSceneAndTransformerByDrawingSearch(t.unitId);if(o==null)return;const{scene:c,transformer:u}=o;this._commandService.syncExecuteCommand(Q.id);const l=[];if(e.forEach(p=>{const S=x.getDrawingShapeKeyByDrawingSearch(p),m=c.getObjectIncludeInGroup(S);if(m==null||l.includes(m))return;l.push(m);const{transform:w}=p;w!=null&&(m.classType===y.RENDER_CLASS_TYPE.GROUP?m.transformByState({left:w.left,top:w.top}):m.transformByState(w))}),l.length===0)return;const g=x.getDrawingShapeKeyByDrawingSearch({unitId:n,subUnitId:a,drawingId:s}),d=new y.Group(g);c.addObject(d,y.DRAWING_OBJECT_LAYER_INDEX).attachTransformerTo(d),d.addObjects(...l),t.transform&&d.transformByState({left:t.transform.left,top:t.transform.top}),u.clearSelectedObjects(),u.setSelectedControl(d)}_ungroupDrawings(r){r.forEach(t=>{this._ungroupDrawing(t)})}_ungroupDrawing(r){const{parent:t,children:e}=r,n=this._getSceneAndTransformerByDrawingSearch(t.unitId);if(n==null)return;const{scene:a,transformer:s}=n;e.forEach(g=>{const d=x.getDrawingShapeKeyByDrawingSearch(g),p=a.getObjectIncludeInGroup(d);if(p==null)return!0;if(p==null)return;const{transform:S}=g;S!=null&&(p.classType===y.RENDER_CLASS_TYPE.GROUP?p.transformByState({left:S.left,top:S.top}):p.transformByState(S))});const o=x.getDrawingShapeKeyByDrawingSearch(t),c=a.getObject(o),{width:u,height:l}=c;c.getObjects().forEach(g=>{c.removeSelfObjectAndTransform(g.oKey,u,l)}),c.dispose(),s.clearSelectedObjects()}_drawingAlign(r){const{alignType:t}=r,e=this._drawingManagerService.getFocusDrawings();if(t===T.default)return;const n=[];let a=Number.POSITIVE_INFINITY,s=Number.POSITIVE_INFINITY,o=Number.NEGATIVE_INFINITY,c=Number.NEGATIVE_INFINITY,u=0;e.forEach(l=>{const{unitId:g,subUnitId:d,drawingId:p,drawingType:S}=l,m=this._drawingManagerService.getDrawingByParam({unitId:g,subUnitId:d,drawingId:p});if(m==null||m.transform==null)return;n.push({unitId:g,subUnitId:d,drawingId:p,drawingType:S,transform:m.transform});const{left:w=0,top:C=0,width:I=0,height:D=0}=m.transform;a=Math.min(a,w),s=Math.min(s,C),o=Math.max(o,w+I),c=Math.max(c,C+D),u++}),u!==0&&(this._sortDrawingTransform(n,t),this._applyAlignType(n,t,a,s,o,c,u))}_applyAlignType(r,t,e,n,a,s,o){const c=Math.round((a-e)/o*10)/10,u=Math.round((s-n)/o*10)/10,l=[],g=this._getSceneAndTransformerByDrawingSearch(r[0].unitId);if(g==null)return;const{scene:d,transformer:p}=g;r.forEach((S,m)=>{const{unitId:w,subUnitId:C,drawingId:I,transform:D,drawingType:j}=S,{left:N=0,top:b=0,width:M=0,height:R=0}=D;let E=N,O=b;switch(t){case T.left:E=e;break;case T.center:E=e+(a-e)/2-M/2;break;case T.right:E=a-M;break;case T.top:O=n;break;case T.middle:O=n+(s-n)/2-R/2;break;case T.bottom:O=s-R;break;case T.horizon:E=e+c*m;break;case T.vertical:O=n+u*m;break}(E!==N||O!==b)&&l.push({unitId:w,subUnitId:C,drawingId:I,drawingType:j,transform:{left:E,top:O}})}),this._drawingManagerService.featurePluginUpdateNotification(l),p.refreshControls().changeNotification()}_sortDrawingTransform(r,t){r.sort((e,n)=>{const a=e.transform,s=n.transform,{left:o=0,top:c=0,width:u=0,height:l=0}=a,{left:g=0,top:d=0,width:p=0,height:S=0}=s;switch(t){case T.left:return o-g;case T.center:return o+u/2-(g+p/2);case T.right:return o+u-(g+p);case T.top:return c-d;case T.middle:return c+l/2-(d+S/2);case T.bottom:return c+l-(d+S);case T.horizon:return o+u/2-(g+p/2);case T.vertical:return c+l/2-(d+S/2);default:return 0}})}_drawingArrangeListener(){this.disposeWithMe(this._drawingManagerService.order$.subscribe(r=>{this._drawingArrange(r)}))}_drawingArrange(r){const{unitId:t,subUnitId:e,drawingIds:n}=r,a=this._getSceneAndTransformerByDrawingSearch(t);if(a==null)return;const{scene:s}=a;n.forEach(o=>{const c=x.getDrawingShapeKeyByDrawingSearch({unitId:t,subUnitId:e,drawingId:o}),u=s.fuzzyMathObjects(c,!0);if(u==null||u.length===0)return;const l=this._drawingManagerService.getDrawingOrder(t,e).indexOf(o);for(const g of u)g.setProps({zIndex:l}),g.makeDirty()})}_drawingAddListener(){this.disposeWithMe(this._drawingManagerService.add$.subscribe(r=>{this._insertDrawing(r)}))}_insertDrawing(r){const t=[];r.forEach(e=>{const{unitId:n}=e;if(this._drawingManagerService.getDrawingByParam(e)==null)return;const s=this._getSceneAndTransformerByDrawingSearch(n);if(s==null)return;const{scene:o}=s;t.includes(o)||t.push(o)}),t.forEach(e=>{this._sceneListenerOnDrawingMap.has(e)||(this._addListenerOnDrawing(e),this._sceneListenerOnDrawingMap.add(e))})}_drawingRemoveListener(){this.disposeWithMe(this._drawingManagerService.remove$.subscribe(r=>{r.forEach(t=>{var l;const{unitId:e,subUnitId:n,drawingId:a}=t,s=this._getSceneAndTransformerByDrawingSearch(e);if(s==null)return;const{scene:o}=s,c=x.getDrawingShapeKeyByDrawingSearch({unitId:e,subUnitId:n,drawingId:a}),u=o.fuzzyMathObjects(c,!0);if(u.length>0){for(const g of u)g.dispose();(l=o.getTransformer())==null||l.clearSelectedObjects()}})}))}_drawingUpdateListener(){this.disposeWithMe(this._drawingManagerService.update$.subscribe(r=>{r.forEach(t=>{var M;const{unitId:e,subUnitId:n,drawingId:a}=t,s=this._drawingManagerService.getDrawingByParam(t);if(s==null)return;const{transform:o,drawingType:c}=s,u=this._getSceneAndTransformerByDrawingSearch(e);if(u==null)return;const{scene:l,transformer:g}=u;if(o==null)return!0;const{left:d=0,top:p=0,width:S=0,height:m=0,angle:w=0,flipX:C=!1,flipY:I=!1,skewX:D=0,skewY:j=0}=o,N=x.getDrawingShapeKeyByDrawingSearch({unitId:e,subUnitId:n,drawingId:a}),b=l.getObject(N);if(b==null)return!0;b.transformByState({left:d,top:p,width:S,height:m,angle:w,flipX:C,flipY:I,skewX:D,skewY:j}),(M=l.getTransformer())==null||M.debounceRefreshControls()})}))}_drawingRefreshListener(){this.disposeWithMe(this._drawingManagerService.refreshTransform$.subscribe(r=>{r.forEach(t=>{const{unitId:e,subUnitId:n,drawingId:a}=t,s=this._getSceneAndTransformerByDrawingSearch(e);if(s==null)return;const o=this._drawingManagerService.getDrawingByParam(t);if(o==null)return;const{transform:c}=o,{scene:u}=s,l=x.getDrawingShapeKeyByDrawingSearch({unitId:e,subUnitId:n,drawingId:a}),g=u.getObject(l);if(g==null||c==null)return!0;const{left:d=0,top:p=0,width:S=0,height:m=0,angle:w=0,flipX:C=!1,flipY:I=!1,skewX:D=0,skewY:j=0}=c;g.transformByState({left:d,top:p,width:S,height:m,angle:w,flipX:C,flipY:I,skewX:D,skewY:j})})}))}_drawingVisibleListener(){this.disposeWithMe(this._drawingManagerService.visible$.subscribe(r=>{r.forEach(t=>{const{unitId:e,subUnitId:n,drawingId:a,visible:s}=t,o=this._getSceneAndTransformerByDrawingSearch(e);if(o==null)return;const{scene:c}=o,u=x.getDrawingShapeKeyByDrawingSearch({unitId:e,subUnitId:n,drawingId:a}),l=c.getObject(u);if(l==null)return!0;s?l.show():l.hide()})}))}_filterUpdateParams(r,t){return r.filter((e,n)=>{if(e==null)return!1;const{transform:a}=e;return f.checkIfMove(a,t==null?void 0:t[n])})}_addListenerOnDrawing(r){const t=r.getTransformerByCreate();let e=null;this.disposeWithMe(f.toDisposable(t.changeStart$.subscribe(n=>{const{objects:a}=n,s=Array.from(a.values()),o=[];e=s.map(c=>{const{left:u,top:l,height:g,width:d,angle:p,oKey:S,isInGroup:m}=c,w=this._drawingManagerService.getDrawingOKey(S);if(m||c instanceof y.Group){let C=c.ancestorGroup;if(C==null&&c instanceof y.Group&&(C=c),C==null)return null;const I=this._drawingManagerService.getDrawingOKey(C.oKey);if(I){const{unitId:D,subUnitId:j,drawingId:N}=I;o.push({unitId:D,subUnitId:j,drawingId:N});const{left:b,top:M,height:R,width:E,angle:O}=C;return{left:b,top:M,height:R,width:E,angle:O}}}else if(w!=null){const{unitId:C,subUnitId:I,drawingId:D}=w;return o.push({unitId:C,subUnitId:I,drawingId:D}),{left:u,top:l,height:g,width:d,angle:p}}return null}).filter(c=>c!=null),o.length>0?this._commandService.syncExecuteCommand(x.SetDrawingSelectedOperation.id,o):this._commandService.syncExecuteCommand(x.SetDrawingSelectedOperation.id,[])}))),this.disposeWithMe(f.toDisposable(t.changeEnd$.subscribe(n=>{const{objects:a}=n,s=this._filterUpdateParams(de(a,this._drawingManagerService),e);s.length>0&&this._drawingManagerService.featurePluginUpdateNotification(s)})))}};we=yt([fe(0,f.IUniverInstanceService),fe(1,f.ICommandService),fe(2,y.IRenderManagerService),fe(3,x.IDrawingManagerService)],we);class ue extends y.Shape{constructor(t,e){e==null&&(e={}),e.transformerConfig={keepRatio:!1,isCropper:!0,anchorFill:"rgb(0, 0, 0)",anchorStroke:"rgb(255, 255, 255)",anchorSize:24};super(t,e);J(this,"_srcRect");J(this,"_prstGeom");J(this,"_applyTransform");J(this,"_dragPadding",8);J(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(t,e){this._srcRect=t,this._applyTransform=e,this._applyProps()}get srcRect(){return this._srcRect}dispose(){var t;super.dispose(),(t=this._cacheCanvas)==null||t.dispose(),this._srcRect=null}isHit(t){const e=this.getInverseCoord(t);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(t){const e=this._dragPadding;return t.x>=e-this.strokeWidth/2&&t.x<=this.width+this.strokeWidth/2-e&&t.y>=e-this.strokeWidth/2&&t.y<=this.height+this.strokeWidth/2-e}render(t,e){return this.visible?(t.save(),this._draw(t),t.restore(),this.makeDirty(!1),this):(this.makeDirty(!1),this)}_draw(t){var c,u;const n=this.getScene().getEngine(),{width:a,height:s}=n;this._initialCacheCanvas(),(c=this._cacheCanvas)==null||c.clear();const o=(u=this._cacheCanvas)==null?void 0:u.getContext();o!=null&&(o.save(),y.Rect.drawWith(o,{left:0,top:0,width:a,height:s,fill:"rgba(0, 0, 0, 0.5)"}),o.setTransform(t.getTransform()),this._clipForApplyObject(o),this._applyCache(t),o.restore())}_clipForApplyObject(t){let e=0;if(this._prstGeom!=null&&(e=1),t.globalCompositeOperation="destination-out",t.beginPath(),e===0){const n=this.transform.getMatrix();t.transform(n[0],n[1],n[2],n[3],n[4],n[5]),t.rect(0,0,this.width,this.height),t.fill()}}_applyProps(){if(this._applyTransform==null)return;let t=0,e=0,n=0,a=0;const{left:s=0,top:o=0,width:c=0,height:u=0,angle:l}=this._applyTransform;if(this._srcRect!=null){const{left:p=0,top:S=0,right:m=0,bottom:w=0}=this._srcRect;t=p,e=S,n=m,a=w}const g=s+t,d=o+e;this.transformByState({left:g,top:d,width:s+c-n-g,height:o+u-a-d,angle:l})}_applyCache(t){if(!t||this._cacheCanvas==null)return;const e=this._cacheCanvas.getContext();e.save(),t.save(),t.setTransform(1,0,0,1,0,0),e.setTransform(1,0,0,1,0,0),t.drawImage(this._cacheCanvas.getCanvasEle(),0,0),t.restore(),e.restore()}_initialCacheCanvas(){if(this._cacheCanvas!=null)return;const t=this.getScene();if(t==null)return;this._cacheCanvas=new y.Canvas;const e=t.getEngine();this._cacheCanvas.setSize(e.width,e.height),e.onTransformChange$.subscribeEvent(()=>{var n;(n=this._cacheCanvas)==null||n.setSize(e.width,e.height),this.makeDirty(!0)})}}var bt=Object.getOwnPropertyDescriptor,Dt=(i,r,t,e)=>{for(var n=e>1?void 0:e?bt(r,t):r,a=i.length-1,s;a>=0;a--)(s=i[a])&&(n=s(n)||n);return n},oe=(i,r)=>(t,e)=>r(t,e,i);let ve=class extends f.Disposable{constructor(r,t,e,n,a,s){super();J(this,"_sceneListenerOnImageMap",new WeakSet);this._commandService=r,this._drawingManagerService=t,this._renderManagerService=e,this._univerInstanceService=n,this._messageService=a,this._localeService=s,this._init()}_init(){this._initOpenCrop(),this._initCloseCrop(),this._initAutoCrop()}_initAutoCrop(){this.disposeWithMe(this._commandService.onCommandExecuted(r=>{if(r.id!==ge.id)return;const t=r.params;if(t==null)return;const{cropType:e}=t,n=this._drawingManagerService.getFocusDrawings();if(n.length!==1)return;const a=n[0],{unitId:s,subUnitId:o,drawingId:c}=a,u=this._renderManagerService.getRenderById(s),l=u==null?void 0:u.scene;if(l==null)return!0;this._searchCropObject(l)!=null&&this._commandService.syncExecuteCommand(Q.id,{isAuto:!0});const d=x.getDrawingShapeKeyByDrawingSearch({unitId:s,subUnitId:o,drawingId:c}),p=l.getObject(d);if(!(p instanceof y.Image)){this._messageService.show({type:P.MessageType.Error,content:this._localeService.t("image-cropper.error")});return}p!=null&&(this._updateCropperObject(e,p),this._commandService.executeCommand(pe.id,{unitId:s,subUnitId:o,drawingId:c}))}))}_calculateSrcRectByRatio(r,t,e,n,a,s){const o=e/n,c=a/s;let u=e,l=n;o>c?u=n*c:l=e/c;const g=(e-u)/2,d=(n-l)/2;return{left:y.precisionTo(g,1),top:y.precisionTo(d,1),right:y.precisionTo(e-(g+u),1),bottom:y.precisionTo(n-(d+l),1)}}_updateCropperObject(r,t){const{left:e,top:n,width:a,height:s}=t.calculateTransformWithSrcRect();let o;switch(r){case U.R1_1:o=this._calculateSrcRectByRatio(e,n,a,s,1,1);break;case U.R16_9:o=this._calculateSrcRectByRatio(e,n,a,s,16,9);break;case U.R9_16:o=this._calculateSrcRectByRatio(e,n,a,s,9,16);break;case U.R5_4:o=this._calculateSrcRectByRatio(e,n,a,s,5,4);break;case U.R4_5:o=this._calculateSrcRectByRatio(e,n,a,s,4,5);break;case U.R4_3:o=this._calculateSrcRectByRatio(e,n,a,s,4,3);break;case U.R3_4:o=this._calculateSrcRectByRatio(e,n,a,s,3,4);break;case U.R3_2:o=this._calculateSrcRectByRatio(e,n,a,s,3,2);break;case U.R2_3:o=this._calculateSrcRectByRatio(e,n,a,s,2,3);break;case U.FREE:}if(o==null)return;t.setSrcRect(o);const{left:c=0,top:u=0,bottom:l=0,right:g=0}=o;t.transformByStateCloseCropper({left:e+c,top:n+u,width:a-g-c,height:s-l-u})}_initOpenCrop(){this.disposeWithMe(this._commandService.onCommandExecuted(r=>{if(r.id!==pe.id)return;const t=r.params;if(t==null)return;const{unitId:e,subUnitId:n,drawingId:a}=t,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:n,drawingId:a})==null)return;const u=x.getDrawingShapeKeyByDrawingSearch({unitId:e,subUnitId:n,drawingId:a}),l=o.getObject(u);if(l==null)return;if(!(l instanceof y.Image)){this._messageService.show({type:P.MessageType.Error,content:this._localeService.t("image-cropper.error")});return}const g=o.getTransformer();g==null||g.clearControls();const d=new ue(`${u}-crop`,{srcRect:l.srcRect,prstGeom:l.prstGeom,applyTransform:l.calculateTransformWithSrcRect()});o.addObject(d,l.getLayerIndex()+1).attachTransformerTo(d),g==null||g.createControlForCopper(d),this._addHoverForImageCopper(d),l.openRenderByCropper(),g==null||g.refreshControls(),d.makeDirty(!0),this._commandService.syncExecuteCommand(x.SetDrawingSelectedOperation.id,[{unitId:e,subUnitId:n,drawingId:a}])}))}_searchCropObject(r){const t=r.getAllObjectsByOrder();for(const e of t)if(e instanceof ue)return e}_initCloseCrop(){this.disposeWithMe(this._commandService.onCommandExecuted(t=>{if(t.id!==Q.id)return;const e=this._univerInstanceService.getFocusedUnit();if(e==null)return;const n=e.getUnitId(),a=this._renderManagerService.getRenderById(n),s=a==null?void 0:a.scene;if(s==null)return!0;const o=this._searchCropObject(s);if(o==null)return;const c=this._getApplyObjectByCropObject(o);if(c==null)return;const u=s.getTransformerByCreate();u.detachFrom(o),u.clearCopperControl();const l=this._getSrcRectByTransformState(c,o),g=this._drawingManagerService.getDrawingOKey(c.oKey);if(g!=null){const{left:d,top:p,height:S,width:m}=o;this._drawingManagerService.featurePluginUpdateNotification([{...g,transform:{...g.transform,left:d,top:p,height:S,width:m},srcRect:l.srcRectAngle}])}c.setSrcRect({...l.srcRectAngle}),c.closeRenderByCropper(),c.makeDirty(!0),o==null||o.dispose()}));const r=this._univerInstanceService.getCurrentTypeOfUnit$(f.UniverInstanceType.UNIVER_SHEET).pipe(Re.switchMap(t=>t?t.activeSheet$:Re.of(null)));this.disposeWithMe(r.subscribe(()=>{this._commandService.syncExecuteCommand(Q.id)}))}_getApplyObjectByCropObject(r){const t=r.oKey,e=t.slice(0,t.length-5),n=r.getScene();if(!n)return null;const a=n.getObject(e);return a==null?null:a}_addListenerOnImage(r){const t=r.getTransformerByCreate();let e=null;this.disposeWithMe(t.changeStart$.subscribe(n=>{const{objects:a}=n,s=a.values().next().value;if(s==null||!(s instanceof ue))return;const{left:o,top:c,height:u,width:l,angle:g}=s;e={left:o,top:c,height:u,width:l,angle:g},t.clearCopperControl()})),this.disposeWithMe(t.changeEnd$.subscribe(n=>{const{objects:a}=n,s=a.values().next().value;if(s==null||!(s instanceof ue))return;const{left:o,top:c,height:u,width:l,angle:g}=s;if(!f.checkIfMove({left:o,top:c,height:u,width:l,angle:g},e))return;const d=this._getApplyObjectByCropObject(s);if(d==null)return;const p=this._getSrcRectByTransformState(d,s);s.refreshSrcRect(p.srcRect,d.getState()),t.createControlForCopper(s)})),this._endCropListener(r)}_addHoverForImageCopper(r){this.disposeWithMe(r.onPointerEnter$.subscribeEvent(()=>{r.cursor=y.CURSOR_TYPE.MOVE})),this.disposeWithMe(r.onPointerLeave$.subscribeEvent(()=>{r.cursor=y.CURSOR_TYPE.DEFAULT}))}_endCropListener(r){const t=r.getTransformerByCreate();this.disposeWithMe(t.clearControl$.subscribe(e=>{e===!0&&this._commandService.syncExecuteCommand(Q.id)}))}_getSrcRectByTransformState(r,t){const{left:e,top:n,height:a,width:s,strokeWidth:o,angle:c}=t,{left:u,top:l,width:g,height:d,angle:p,strokeWidth:S}=r,m=e-u,w=n-l,C={left:m,top:w,right:g-m-s,bottom:d-w-a},I={...C};if(p!==0){const D=e+s/2,j=n+a/2,N=new y.Vector2(D,j),b=g/2+u,M=d/2+l,R=new y.Vector2(b,M),E=new y.Vector2(u,l);E.rotateByPoint(y.degToRad(p),R);const O=E.clone();O.rotateByPoint(y.degToRad(-p),N);const k=e-O.x,A=n-O.y;I.left=k,I.top=A,I.right=g-k-s,I.bottom=d-A-a}return{srcRect:C,srcRectAngle:I}}};ve=Dt([oe(0,f.ICommandService),oe(1,x.IDrawingManagerService),oe(2,y.IRenderManagerService),oe(3,f.IUniverInstanceService),oe(4,H.IMessageService),oe(5,f.Inject(f.LocaleService))],ve);var Rt=Object.getOwnPropertyDescriptor,Mt=(i,r,t,e)=>{for(var n=e>1?void 0:e?Rt(r,t):r,a=i.length-1,s;a>=0;a--)(s=i[a])&&(n=s(n)||n);return n},ie=(i,r)=>(t,e)=>r(t,e,i);let Se=class extends f.Disposable{constructor(i,r,t,e,n,a,s){super(),this._commandService=i,this._renderManagerService=r,this._drawingManagerService=t,this._dialogService=e,this._imageIoService=n,this._currentUniverService=a,this._drawingRenderService=s,this._initialize()}dispose(){super.dispose()}_initialize(){this._drawingAddListener(),this._commandExecutedListener(),this._imageUpdateListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.onCommandExecuted(i=>{if(i.id===be.id){const r=i.params;if(r==null)return;this._resetImageSize(r)}}))}_getSceneAndTransformerByDrawingSearch(i){if(i==null)return;const r=this._renderManagerService.getRenderById(i),t=r==null?void 0:r.scene;if(t==null)return null;const e=t.getTransformerByCreate();return{scene:t,transformer:e}}_resetImageSize(i){const r=[],t=[];i.forEach(e=>{const{unitId:n,subUnitId:a,drawingId:s}=e,o=this._getSceneAndTransformerByDrawingSearch(n);if(o==null)return;const{scene:c}=o,u=x.getDrawingShapeKeyByDrawingSearch({unitId:n,subUnitId:a,drawingId:s}),l=c.getObject(u);if(l==null)return!0;const g=this._drawingManagerService.getDrawingByParam(e);if(g==null)return!0;if(g.drawingType!==f.DrawingTypeEnum.DRAWING_IMAGE)return;l.resetSize();const{width:d,height:p}=l.getNativeSize();t.includes(c)===!1&&t.push(c),r.push({...g,transform:{...g.transform,height:p,width:d,angle:0},srcRect:null,prstGeom:null})}),this._drawingManagerService.featurePluginUpdateNotification(r),t.forEach(e=>{e.getTransformerByCreate().refreshControls().changeNotification()}),this._commandService.syncExecuteCommand(x.SetDrawingSelectedOperation.id,i)}_drawingAddListener(){this.disposeWithMe(this._drawingManagerService.add$.subscribe(i=>{this._insertImages(i)}))}_insertImages(i){i.forEach(async r=>{var c;const{unitId:t,subUnitId:e}=r,n=this._getSceneAndTransformerByDrawingSearch(t),a=(c=Ee(this._currentUniverService,t))==null?void 0:c.subUnitId;if(n==null||a!==e)return;const s=this._drawingManagerService.getDrawingByParam(r);if(s==null)return;const o=await this._drawingRenderService.renderImages(s,n.scene);if(this._drawingManagerService.refreshTransform([s]),!(o==null||o.length===0))for(const u of o)this._addHoverForImage(u),this._addDialogForImage(u)})}_imageUpdateListener(){this.disposeWithMe(this._drawingManagerService.update$.subscribe(i=>{i.forEach(r=>{const{unitId:t,subUnitId:e,drawingId:n}=r,a=this._drawingManagerService.getDrawingByParam(r);if(a==null)return;const{transform:s,drawingType:o,srcRect:c,prstGeom:u,source:l,imageSourceType:g}=a;if(o!==f.DrawingTypeEnum.DRAWING_IMAGE)return;const d=this._getSceneAndTransformerByDrawingSearch(t);if(d==null)return;const{scene:p,transformer:S}=d;if(s==null)return!0;const m=x.getDrawingShapeKeyByDrawingSearch({unitId:t,subUnitId:e,drawingId:n}),w=p.getObject(m);if(w==null)return!0;w.setSrcRect(c),w.setPrstGeom(u),l!=null&&l.length>0&&(g===f.ImageSourceType.BASE64||g===f.ImageSourceType.URL)&&w.changeSource(l)})}))}_addHoverForImage(i){this.disposeWithMe(f.toDisposable(i.onPointerEnter$.subscribeEvent(()=>{i.cursor=y.CURSOR_TYPE.GRAB}))),this.disposeWithMe(f.toDisposable(i.onPointerLeave$.subscribeEvent(()=>{i.cursor=y.CURSOR_TYPE.DEFAULT})))}_addDialogForImage(i){this.disposeWithMe(f.toDisposable(i.onDblclick$.subscribeEvent(()=>{const r=`${i.oKey}-viewer-dialog`;this._drawingRenderService.previewImage(r,i.getNative().src,i.getNativeSize().width,i.getNativeSize().height)})))}};Se=Mt([ie(0,f.ICommandService),ie(1,y.IRenderManagerService),ie(2,x.IDrawingManagerService),ie(3,H.IDialogService),ie(4,x.IImageIoService),ie(5,f.IUniverInstanceService),ie(6,f.Inject(exports.DrawingRenderService))],Se);var Ot=Object.getOwnPropertyDescriptor,xt=(i,r,t,e)=>{for(var n=e>1?void 0:e?Ot(r,t):r,a=i.length-1,s;a>=0;a--)(s=i[a])&&(n=s(n)||n);return n},je=(i,r)=>(t,e)=>r(t,e,i);const jt="UNIVER_DRAWING_UI_PLUGIN";var ye;exports.UniverDrawingUIPlugin=(ye=class extends f.Plugin{constructor(r=Oe,t,e){super(),this._config=r,this._injector=t,this._configService=e;const{menu:n,...a}=f.merge({},Oe,this._config);n&&this._configService.setConfig("menu",n,{merge:!0}),this._configService.setConfig(St,a)}onStarting(){this._initDependencies()}onRendered(){this._injector.get(we),this._injector.get(me),this._injector.get(ve),this._injector.get(Se)}_initDependencies(){[[exports.DrawingRenderService],[we],[me],[ve],[Se]].forEach(t=>this._injector.add(t))}},J(ye,"pluginName",jt),ye);exports.UniverDrawingUIPlugin=xt([je(1,f.Inject(f.Injector)),je(2,f.IConfigService)],exports.UniverDrawingUIPlugin);exports.AutoImageCropOperation=ge;exports.COMPONENT_IMAGE_POPUP_MENU=We;exports.CloseImageCropOperation=Q;exports.DrawingCommonPanel=vt;exports.ImageCropperObject=ue;exports.ImagePopupMenu=Ve;exports.ImageResetSizeOperation=be;exports.OpenImageCropOperation=pe;exports.SetDrawingAlignOperation=_e;exports.getUpdateParams=de;
|
|
1
|
+
"use strict";var ze=Object.defineProperty;var Ye=(i,r,t)=>r in i?ze(i,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[r]=t;var J=(i,r,t)=>Ye(i,typeof r!="symbol"?r+"":r,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("@univerjs/core"),x=require("@univerjs/drawing"),y=require("@univerjs/engine-render"),H=require("@univerjs/ui"),h=require("react/jsx-runtime"),P=require("@univerjs/design"),_=require("react"),Re=require("rxjs");function Me(i,r,t,e){const n=e.getDrawingByParam(i);if(n==null)return;const a=x.getDrawingShapeKeyByDrawingSearch(i),s=t.getObject(a);if(s&&!(s instanceof y.Group))return;if(s!=null){s.addObject(r);return}const o=new y.Group(a);t.addObject(o,y.DRAWING_OBJECT_LAYER_INDEX).attachTransformerTo(o),o.addObject(r);const{transform:c}=n;c&&o.transformByState({left:c.left,top:c.top,angle:c.angle})}function Ee(i,r){var a;const t=r?i.getUnit(r):i.getFocusedUnit();if(t==null)return;const e=t.getUnitId();let n;return t.type===f.UniverInstanceType.UNIVER_SHEET?n=(a=t.getActiveSheet())==null?void 0:a.getSheetId():(t.type===f.UniverInstanceType.UNIVER_DOC||t.type===f.UniverInstanceType.UNIVER_SLIDE)&&(n=e),{unitId:e,subUnitId:n,current:t}}var Xe=Object.getOwnPropertyDescriptor,qe=(i,r,t,e)=>{for(var n=e>1?void 0:e?Xe(r,t):r,a=i.length-1,s;a>=0;a--)(s=i[a])&&(n=s(n)||n);return n},Ie=(i,r)=>(t,e)=>r(t,e,i);exports.DrawingRenderService=class{constructor(r,t,e){this._drawingManagerService=r,this._imageIoService=t,this._galleryService=e}async renderImages(r,t){const{transform:e,drawingType:n,source:a,imageSourceType:s,srcRect:o,prstGeom:c,groupId:u,unitId:l,subUnitId:g,drawingId:d,isMultiTransform:p,transforms:S}=r;if(n!==f.DrawingTypeEnum.DRAWING_IMAGE||!this._drawingManagerService.getDrawingVisible()||e==null)return;const m=p&&S?S:[e],w=[];for(const C of m){const{left:I,top:D,width:j,height:N,angle:b,flipX:M,flipY:R,skewX:E,skewY:O}=C,k=m.indexOf(C),A=x.getDrawingShapeKeyByDrawingSearch({unitId:l,subUnitId:g,drawingId:d},p?k:void 0),W=t.getObject(A);if(W!=null){W.transformByState({left:I,top:D,width:j,height:N,angle:b,flipX:M,flipY:R,skewX:E,skewY:O});continue}const Y=this._drawingManagerService.getDrawingOrder(l,g),ae=Y.indexOf(d),ee={...C,zIndex:ae===-1?Y.length-1:ae},te=this._imageIoService.getImageSourceCache(a,s);let se=!1;if(te!=null)ee.image=te;else{if(s===x.ImageSourceType.UUID)try{ee.url=await this._imageIoService.getImage(a)}catch(Ce){console.error(Ce);continue}else ee.url=a;se=!0}if(t.getObject(A))continue;ee.printable=!0;const X=new y.Image(A,ee);se&&this._imageIoService.addImageSourceCache(a,s,X.getNative()),this._drawingManagerService.getDrawingVisible()&&(t.addObject(X,y.DRAWING_OBJECT_LAYER_INDEX),this._drawingManagerService.getDrawingEditable()&&t.attachTransformerTo(X),u&&Me({drawingId:u,unitId:l,subUnitId:g},X,t,this._drawingManagerService),c!=null&&X.setPrstGeom(c),o!=null&&X.setSrcRect(o),w.push(X))}return w}renderFloatDom(r,t){const{transform:e,drawingType:n,groupId:a,unitId:s,subUnitId:o,drawingId:c,isMultiTransform:u,transforms:l}=r;if(n!==f.DrawingTypeEnum.DRAWING_DOM||!this._drawingManagerService.getDrawingVisible()||e==null)return;const g=u&&l?l:[e],d=[];for(const p of g){const{left:S,top:m,width:w,height:C,angle:I,flipX:D,flipY:j,skewX:N,skewY:b}=p,M=g.indexOf(p),R=x.getDrawingShapeKeyByDrawingSearch({unitId:s,subUnitId:o,drawingId:c},u?M:void 0),E=t.getObject(R);if(E!=null){E.transformByState({left:S,top:m,width:w,height:C,angle:I,flipX:D,flipY:j,skewX:N,skewY:b});continue}const O=this._drawingManagerService.getDrawingOrder(s,o),k=O.indexOf(c),A={...p,zIndex:k===-1?O.length-1:k};if(t.getObject(R))continue;A.printable=!1;const W=new y.Rect(R,A);this._drawingManagerService.getDrawingVisible()&&(t.addObject(W,y.DRAWING_OBJECT_LAYER_INDEX),this._drawingManagerService.getDrawingEditable()&&r.allowTransform!==!1&&t.attachTransformerTo(W),a&&Me({drawingId:a,unitId:s,subUnitId:o},W,t,this._drawingManagerService),d.push(W))}return d}renderDrawing(r,t){const e=this._drawingManagerService.getDrawingByParam(r);if(e!=null)switch(e.drawingType){case f.DrawingTypeEnum.DRAWING_IMAGE:return this.renderImages(e,t)}}previewImage(r,t,e,n){this._galleryService.open({images:[t],onOpenChange:a=>{a||this._galleryService.close()}})}_adjustImageSize(r,t,e,n){if(r<=e&&t<=n)return{width:r,height:t};const a=e/r,s=n/t,o=Math.min(a,s);return{width:Math.floor(r*o),height:Math.floor(t*o)}}};exports.DrawingRenderService=qe([Ie(0,x.IDrawingManagerService),Ie(1,x.IImageIoService),Ie(2,H.IGalleryService)],exports.DrawingRenderService);function de(i,r){const t=[];return i.forEach(e=>{const{oKey:n,left:a,top:s,height:o,width:c,angle:u}=e,l=r.getDrawingOKey(n);if(l==null)return t.push(null),!0;const{unitId:g,subUnitId:d,drawingId:p,drawingType:S}=l,m={unitId:g,subUnitId:d,drawingId:p,drawingType:S,transform:{left:a,top:s,height:o,width:c,angle:u}};S===f.DrawingTypeEnum.DRAWING_IMAGE&&(m.srcRect=e.srcRect),t.push(m)}),t}var T=(i=>(i.default="0",i.left="1",i.center="2",i.right="3",i.top="4",i.middle="5",i.bottom="6",i.horizon="7",i.vertical="8",i))(T||{});const _e={id:"sheet.operation.set-image-align",type:f.CommandType.OPERATION,handler:(i,r)=>!0},Je=i=>{const r=H.useDependency(f.ICommandService),t=H.useDependency(f.LocaleService),{alignShow:e}=i,[n,a]=_.useState(T.default),s=[{label:t.t("image-panel.align.default"),value:T.default},{options:[{label:t.t("image-panel.align.left"),value:T.left},{label:t.t("image-panel.align.center"),value:T.center},{label:t.t("image-panel.align.right"),value:T.right}]},{options:[{label:t.t("image-panel.align.top"),value:T.top},{label:t.t("image-panel.align.middle"),value:T.middle},{label:t.t("image-panel.align.bottom"),value:T.bottom}]},{options:[{label:t.t("image-panel.align.horizon"),value:T.horizon},{label:t.t("image-panel.align.vertical"),value:T.vertical}]}];function o(c){a(c),r.executeCommand(_e.id,{alignType:c})}return h.jsxs("div",{className:P.clsx("univer-relative univer-w-full",{"univer-hidden":!e}),children:[h.jsx("header",{className:"univer-text-gray-600 dark:!univer-text-gray-200",children:h.jsx("div",{children:t.t("image-panel.align.title")})}),h.jsx("div",{className:"univer-relative univer-mt-2.5 univer-flex univer-h-full",children:h.jsx("div",{className:"univer-w-full univer-text-gray-900 dark:!univer-text-white",children:h.jsx(P.Select,{value:n,options:s,onChange:o})})})]})};var $=function(){return $=Object.assign||function(i){for(var r,t=1,e=arguments.length;t<e;t++){r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(i[n]=r[n])}return i},$.apply(this,arguments)},Qe=function(i,r){var t={};for(var e in i)Object.prototype.hasOwnProperty.call(i,e)&&r.indexOf(e)<0&&(t[e]=i[e]);if(i!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,e=Object.getOwnPropertySymbols(i);n<e.length;n++)r.indexOf(e[n])<0&&Object.prototype.propertyIsEnumerable.call(i,e[n])&&(t[e[n]]=i[e[n]]);return t},z=_.forwardRef(function(i,r){var t=i.icon,e=i.id,n=i.className,a=i.extend,s=Qe(i,["icon","id","className","extend"]),o="univerjs-icon univerjs-icon-".concat(e," ").concat(n||"").trim(),c=_.useRef("_".concat(rt()));return Te(t,"".concat(e),{defIds:t.defIds,idSuffix:c.current},$({ref:r,className:o},s),a)});function Te(i,r,t,e,n){return _.createElement(i.tag,$($({key:r},et(i,t,n)),e),(tt(i,t).children||[]).map(function(a,s){return Te(a,"".concat(r,"-").concat(i.tag,"-").concat(s),t,void 0,n)}))}function et(i,r,t){var e=$({},i.attrs);t!=null&&t.colorChannel1&&e.fill==="colorChannel1"&&(e.fill=t.colorChannel1),i.tag==="mask"&&e.id&&(e.id=e.id+r.idSuffix),Object.entries(e).forEach(function(a){var s=a[0],o=a[1];s==="mask"&&typeof o=="string"&&(e[s]=o.replace(/url\(#(.*)\)/,"url(#$1".concat(r.idSuffix,")")))});var n=r.defIds;return!n||n.length===0||(i.tag==="use"&&e["xlink:href"]&&(e["xlink:href"]=e["xlink:href"]+r.idSuffix),Object.entries(e).forEach(function(a){var s=a[0],o=a[1];typeof o=="string"&&(e[s]=o.replace(/url\(#(.*)\)/,"url(#$1".concat(r.idSuffix,")")))})),e}function tt(i,r){var t,e=r.defIds;return!e||e.length===0?i:i.tag==="defs"&&(!((t=i.children)===null||t===void 0)&&t.length)?$($({},i),{children:i.children.map(function(n){return typeof n.attrs.id=="string"&&e&&e.includes(n.attrs.id)?$($({},n),{attrs:$($({},n.attrs),{id:n.attrs.id+r.idSuffix})}):n})}):i}function rt(){return Math.random().toString(36).substring(2,8)}z.displayName="UniverIcon";var nt={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"colorChannel1",d:"M11.0363 12.2367V14.0367C11.0363 14.3681 11.3049 14.6367 11.6363 14.6367C11.9676 14.6367 12.2363 14.3681 12.2363 14.0367V12.2367H14.0364C14.3677 12.2367 14.6364 11.9681 14.6364 11.6367C14.6364 11.3054 14.3677 11.0367 14.0364 11.0367H12.2363V9.23672C12.2363 8.90535 11.9676 8.63672 11.6363 8.63672C11.3049 8.63672 11.0363 8.90535 11.0363 9.23672V11.0367H9.23635C8.90498 11.0367 8.63635 11.3054 8.63635 11.6367C8.63635 11.9681 8.90498 12.2367 9.23635 12.2367H11.0363Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M2.56365 1.36377C1.90091 1.36377 1.36365 1.90103 1.36365 2.56377V6.16377C1.36365 6.82651 1.90091 7.36377 2.56365 7.36377H6.16365C6.82639 7.36377 7.36365 6.82651 7.36365 6.16377V2.56377C7.36365 1.90103 6.82639 1.36377 6.16365 1.36377H2.56365ZM6.16365 2.56377H2.56365L2.56365 6.16377H6.16365V2.56377Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M2.56365 8.63647C1.90091 8.63647 1.36365 9.17373 1.36365 9.83647V13.4365C1.36365 14.0992 1.90091 14.6365 2.56365 14.6365H6.16365C6.82639 14.6365 7.36365 14.0992 7.36365 13.4365V9.83647C7.36365 9.17373 6.82639 8.63647 6.16365 8.63647H2.56365ZM6.16365 9.83647H2.56365L2.56365 13.4365H6.16365V9.83647Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M9.83635 7.36377C9.17361 7.36377 8.63635 6.82651 8.63635 6.16377V2.56377C8.63635 1.90103 9.17361 1.36377 9.83635 1.36377H13.4364C14.0991 1.36377 14.6364 1.90103 14.6364 2.56377V6.16377C14.6364 6.82651 14.0991 7.36377 13.4364 7.36377H9.83635ZM9.83635 6.16377V2.56377L13.4364 2.56377V6.16377H9.83635Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Pe=_.forwardRef(function(i,r){return _.createElement(z,Object.assign({},i,{id:"autofill-double-icon",ref:r,icon:nt}))});Pe.displayName="AutofillDoubleIcon";var it={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 17 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M14.0045 4.4334C14.8881 4.4334 15.6045 3.71705 15.6045 2.8334C15.6045 1.94974 14.8881 1.2334 14.0045 1.2334H3.70449C2.82084 1.2334 2.10449 1.94974 2.10449 2.8334C2.10449 3.71705 2.82084 4.4334 3.70449 4.4334H14.0045ZM14.4045 2.8334C14.4045 3.05431 14.2254 3.2334 14.0045 3.2334H3.70449C3.48358 3.2334 3.30449 3.05431 3.30449 2.8334C3.30449 2.61248 3.48358 2.4334 3.70449 2.4334H14.0045C14.2254 2.4334 14.4045 2.61249 14.4045 2.8334Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M14.1544 8.5999C15.038 8.5999 15.7544 7.88356 15.7544 6.9999C15.7544 6.11625 15.038 5.3999 14.1544 5.3999H3.85439C2.97074 5.3999 2.25439 6.11625 2.25439 6.9999C2.25439 7.88356 2.97074 8.5999 3.85439 8.5999H14.1544ZM14.5544 6.9999C14.5544 7.22082 14.3753 7.3999 14.1544 7.3999H3.85439C3.63348 7.3999 3.45439 7.22082 3.45439 6.9999C3.45439 6.77899 3.63348 6.5999 3.85439 6.5999H14.1544C14.3753 6.5999 14.5544 6.77899 14.5544 6.9999Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M8.57975 14.5902L6.58023 12.5907C6.34591 12.3564 6.34591 11.9765 6.58023 11.7421C6.81454 11.5078 7.19444 11.5078 7.42876 11.7421L8.40449 12.7179V10.1664C8.40449 9.83504 8.67312 9.56641 9.00449 9.56641C9.33586 9.56641 9.60449 9.83504 9.60449 10.1664V12.7179L10.5802 11.7421C10.8145 11.5078 11.1944 11.5078 11.4288 11.7421C11.6631 11.9765 11.6631 12.3564 11.4288 12.5907L9.42923 14.5902"}},{tag:"path",attrs:{fill:"currentColor",d:"M8.57975 14.5902C8.58121 14.5917 8.58268 14.5931 8.58416 14.5946C8.64077 14.6502 8.70566 14.6923 8.77482 14.7209C8.84557 14.7502 8.92314 14.7664 9.00449 14.7664C9.08585 14.7664 9.16342 14.7502 9.23416 14.7209C9.30332 14.6923 9.36821 14.6502 9.42482 14.5946"}}]},Ne=_.forwardRef(function(i,r){return _.createElement(z,Object.assign({},i,{id:"bottom-icon",ref:r,icon:it}))});Ne.displayName="BottomIcon";var at={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M5.97705 7.51296C5.97705 7.18159 6.24568 6.91296 6.57705 6.91296H8.48632C8.81769 6.91296 9.08632 7.18159 9.08632 7.51296C9.08632 7.84433 8.81769 8.11296 8.48632 8.11296H6.57705C6.24568 8.11296 5.97705 7.84433 5.97705 7.51296Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M6.57705 9.41028C6.24568 9.41028 5.97705 9.67891 5.97705 10.0103C5.97705 10.3416 6.24568 10.6103 6.57705 10.6103H10.8199C11.1512 10.6103 11.4199 10.3416 11.4199 10.0103C11.4199 9.67891 11.1512 9.41028 10.8199 9.41028H6.57705Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M3.51074 2.37063C3.51074 1.48697 4.22709 0.77063 5.11074 0.77063H9.80318L9.81294 0.770708C9.97168 0.768161 10.1311 0.82824 10.2511 0.95055L14.4317 5.21408C14.5165 5.30049 14.5697 5.406 14.5917 5.51645C14.6041 5.5644 14.6106 5.61467 14.6106 5.66648V11.6406C14.6106 12.5243 13.8943 13.2406 13.0106 13.2406H5.11074C4.22709 13.2406 3.51074 12.5243 3.51074 11.6406V2.37063ZM10.4032 4.66648V2.81964L12.6063 5.06648H10.8032C10.5823 5.06648 10.4032 4.88739 10.4032 4.66648ZM5.11074 1.97063C4.88983 1.97063 4.71074 2.14972 4.71074 2.37063V11.6406C4.71074 11.8615 4.88983 12.0406 5.11074 12.0406H13.0106C13.2316 12.0406 13.4106 11.8615 13.4106 11.6406V6.26648H10.8032C9.91953 6.26648 9.20318 5.55013 9.20318 4.66648V1.97063H5.11074Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M2.58916 6.6741C2.58916 6.34273 2.32053 6.0741 1.98916 6.0741C1.65779 6.0741 1.38916 6.34273 1.38916 6.6741V12.6294C1.38916 14.0653 2.55322 15.2294 3.98916 15.2294H9.41408C9.74545 15.2294 10.0141 14.9607 10.0141 14.6294C10.0141 14.298 9.74545 14.0294 9.41408 14.0294H3.98916C3.21596 14.0294 2.58916 13.4026 2.58916 12.6294V6.6741Z"}}]},Be=_.forwardRef(function(i,r){return _.createElement(z,Object.assign({},i,{id:"create-copy-icon",ref:r,icon:at}))});Be.displayName="CreateCopyIcon";var st={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 17 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M7.38125 1.16211C6.49759 1.16211 5.78125 1.87845 5.78125 2.76211V5.6377H2.87783C1.99418 5.6377 1.27783 6.35404 1.27783 7.2377V13.2377C1.27783 14.1214 1.99418 14.8377 2.87783 14.8377H8.87783C9.76149 14.8377 10.4778 14.1214 10.4778 13.2377V10.3621H13.3813C14.2649 10.3621 14.9813 9.64577 14.9813 8.76211V2.76211C14.9813 1.87845 14.2649 1.16211 13.3813 1.16211H7.38125ZM10.4778 9.16211H13.3813C13.6022 9.16211 13.7812 8.98302 13.7812 8.76211V2.76211C13.7812 2.5412 13.6022 2.36211 13.3813 2.36211H7.38125C7.16034 2.36211 6.98125 2.5412 6.98125 2.76211V5.6377H8.87783C9.76149 5.6377 10.4778 6.35404 10.4778 7.2377V9.16211ZM6.98125 6.8377H8.87783C9.09875 6.8377 9.27783 7.01678 9.27783 7.2377V9.16211H7.38125C7.16034 9.16211 6.98125 8.98302 6.98125 8.76211V6.8377ZM5.78125 6.8377V8.76211C5.78125 9.64577 6.49759 10.3621 7.38125 10.3621H9.27783V13.2377C9.27783 13.4586 9.09875 13.6377 8.87783 13.6377H2.87783C2.65692 13.6377 2.47783 13.4586 2.47783 13.2377V7.2377C2.47783 7.01678 2.65692 6.8377 2.87783 6.8377H5.78125Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Ue=_.forwardRef(function(i,r){return _.createElement(z,Object.assign({},i,{id:"group-icon",ref:r,icon:st}))});Ue.displayName="GroupIcon";var ot={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M11.3536 6.14645C11.5488 6.34171 11.5488 6.65829 11.3536 6.85355L8.35355 9.85355C8.15829 10.0488 7.84171 10.0488 7.64645 9.85355L4.64645 6.85355C4.45118 6.65829 4.45118 6.34171 4.64645 6.14645C4.84171 5.95118 5.15829 5.95118 5.35355 6.14645L8 8.79289L10.6464 6.14645C10.8417 5.95118 11.1583 5.95118 11.3536 6.14645Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Ae=_.forwardRef(function(i,r){return _.createElement(z,Object.assign({},i,{id:"more-down-icon",ref:r,icon:ot}))});Ae.displayName="MoreDownIcon";var ct={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M1.25 2.96401C1.25 3.84767 1.96634 4.56401 2.85 4.56401H13.15C14.0337 4.56401 14.75 3.84767 14.75 2.96401C14.75 2.08036 14.0337 1.36401 13.15 1.36401H2.85C1.96635 1.36401 1.25 2.08036 1.25 2.96401ZM2.85 3.36401C2.62909 3.36401 2.45 3.18493 2.45 2.96401C2.45 2.7431 2.62909 2.56401 2.85 2.56401H13.15C13.3709 2.56401 13.55 2.7431 13.55 2.96401C13.55 3.18493 13.3709 3.36401 13.15 3.36401H2.85Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M5.57564 11.6118C5.80995 11.3774 6.18985 11.3774 6.42417 11.6118L7.3999 12.5875V6.36951C7.3999 6.03814 7.66853 5.76951 7.9999 5.76951C8.33127 5.76951 8.5999 6.03814 8.5999 6.36951V12.5875L9.57564 11.6118C9.80995 11.3774 10.1899 11.3774 10.4242 11.6118C10.6585 11.8461 10.6585 12.226 10.4242 12.4603L8.4324 14.452C8.32324 14.5655 8.16982 14.6362 7.9999 14.6362C7.82998 14.6362 7.67655 14.5655 7.56739 14.452L5.57564 12.4603C5.34132 12.226 5.34132 11.8461 5.57564 11.6118Z"}}]},Le=_.forwardRef(function(i,r){return _.createElement(z,Object.assign({},i,{id:"move-down-icon",ref:r,icon:ct}))});Le.displayName="MoveDownIcon";var lt={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"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"}}]},He=_.forwardRef(function(i,r){return _.createElement(z,Object.assign({},i,{id:"move-up-icon",ref:r,icon:lt}))});He.displayName="MoveUpIcon";var ut={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 17 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M7.82994 1.40913C7.88746 1.35161 7.95376 1.30821 8.02453 1.27893C8.09527 1.24959 8.17285 1.2334 8.2542 1.2334C8.33555 1.2334 8.41313 1.24959 8.48387 1.27893C8.55464 1.30821 8.62094 1.35161 8.67846 1.40913L10.6785 3.40913C10.9128 3.64345 10.9128 4.02335 10.6785 4.25766C10.4441 4.49198 10.0642 4.49198 9.82994 4.25766L8.8542 3.28193V5.8334C8.8542 6.16477 8.58557 6.4334 8.2542 6.4334C7.92283 6.4334 7.6542 6.16477 7.6542 5.8334V3.28193L6.67846 4.25766C6.44415 4.49198 6.06425 4.49198 5.82994 4.25766C5.59562 4.02335 5.59562 3.64345 5.82994 3.40913L7.82994 1.40913Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M1.50439 9C1.50439 8.11634 2.22074 7.4 3.10439 7.4H13.4044C14.288 7.4 15.0044 8.11634 15.0044 9C15.0044 9.88366 14.2881 10.6 13.4044 10.6H3.1044C2.22074 10.6 1.50439 9.88366 1.50439 9ZM3.10439 8.6C2.88348 8.6 2.70439 8.77909 2.70439 9C2.70439 9.22091 2.88348 9.4 3.1044 9.4H13.4044C13.6253 9.4 13.8044 9.22091 13.8044 9C13.8044 8.77909 13.6253 8.6 13.4044 8.6H3.10439Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M1.6543 13.1665C1.6543 12.2828 2.37064 11.5665 3.2543 11.5665H13.5543C14.438 11.5665 15.1543 12.2828 15.1543 13.1665C15.1543 14.0502 14.438 14.7665 13.5543 14.7665H3.2543C2.37064 14.7665 1.6543 14.0502 1.6543 13.1665ZM3.2543 12.7665C3.03338 12.7665 2.8543 12.9456 2.8543 13.1665C2.8543 13.3874 3.03338 13.5665 3.2543 13.5665H13.5543C13.7752 13.5665 13.9543 13.3874 13.9543 13.1665C13.9543 12.9456 13.7752 12.7665 13.5543 12.7665H3.2543Z",fillRule:"evenodd",clipRule:"evenodd"}}]},ke=_.forwardRef(function(i,r){return _.createElement(z,Object.assign({},i,{id:"topmost-icon",ref:r,icon:ut}))});ke.displayName="TopmostIcon";var gt={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 17 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M7.46855 2.83731C7.46855 2.61639 7.64764 2.4373 7.86855 2.4373H13.8603C14.0812 2.4373 14.2603 2.61639 14.2603 2.8373V9.5049C14.2603 9.72581 14.0812 9.90489 13.8603 9.90489H12.866C12.5346 9.90489 12.266 10.1735 12.266 10.5049C12.266 10.8363 12.5346 11.1049 12.866 11.1049H13.8603C14.7439 11.1049 15.4603 10.3886 15.4603 9.5049V2.8373C15.4603 1.95365 14.7439 1.2373 13.8603 1.2373H7.86855C6.9849 1.2373 6.26855 1.95365 6.26855 2.83731V3.48688C6.26855 3.81825 6.53718 4.08688 6.86855 4.08688C7.19993 4.08688 7.46855 3.81825 7.46855 3.48688V2.83731Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M3.19888 5.56299C2.31522 5.56299 1.59888 6.27933 1.59888 7.16299V13.163C1.59888 14.0466 2.31522 14.763 3.19888 14.763H9.19888C10.0825 14.763 10.7989 14.0466 10.7989 13.163V7.16299C10.7989 6.27933 10.0825 5.56299 9.19888 5.56299H3.19888ZM2.79888 7.16299C2.79888 6.94207 2.97796 6.76299 3.19888 6.76299H9.19888C9.41979 6.76299 9.59888 6.94207 9.59888 7.16299V13.163C9.59888 13.3839 9.41979 13.563 9.19888 13.563H3.19888C2.97796 13.563 2.79888 13.3839 2.79888 13.163V7.16299Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Ge=_.forwardRef(function(i,r){return _.createElement(z,Object.assign({},i,{id:"ungroup-icon",ref:r,icon:gt}))});Ge.displayName="UngroupIcon";const dt=i=>{const{arrangeShow:r,drawings:t}=i,e=H.useDependency(f.LocaleService),n=H.useDependency(x.IDrawingManagerService),[a,s]=_.useState(t);_.useEffect(()=>{const c=n.focus$.subscribe(u=>{s(u)});return()=>{c.unsubscribe()}},[]);const o=c=>{const u=a[0].unitId,l=a[0].subUnitId,g=a.map(d=>d.drawingId);n.featurePluginOrderUpdateNotification({unitId:u,subUnitId:l,drawingIds:g,arrangeType:c})};return h.jsxs("div",{className:P.clsx("univer-grid univer-gap-2 univer-py-2 univer-text-gray-400",{"univer-hidden":!r}),children:[h.jsx("header",{className:"univer-text-gray-600 dark:!univer-text-gray-200",children:h.jsx("div",{children:e.t("image-panel.arrange.title")})}),h.jsxs("div",{className:"univer-grid univer-grid-cols-2 univer-gap-2 univer-px-8",children:[h.jsxs(P.Button,{onClick:()=>{o(f.ArrangeTypeEnum.forward)},children:[h.jsx(He,{}),e.t("image-panel.arrange.forward")]}),h.jsxs(P.Button,{onClick:()=>{o(f.ArrangeTypeEnum.backward)},children:[h.jsx(Le,{}),e.t("image-panel.arrange.backward")]}),h.jsxs(P.Button,{onClick:()=>{o(f.ArrangeTypeEnum.front)},children:[h.jsx(ke,{}),e.t("image-panel.arrange.front")]}),h.jsxs(P.Button,{onClick:()=>{o(f.ArrangeTypeEnum.back)},children:[h.jsx(Ne,{}),e.t("image-panel.arrange.back")]})]})]})},ht=i=>{const r=H.useDependency(f.LocaleService),t=H.useDependency(y.IRenderManagerService),e=H.useDependency(x.IDrawingManagerService),{hasGroup:n,drawings:a}=i,[s,o]=_.useState(!1),[c,u]=_.useState(!0),[l,g]=_.useState(!0),d=()=>{const m=e.getFocusDrawings(),{unitId:w,subUnitId:C}=m[0],I=f.Tools.generateRandomId(10),D=y.getGroupState(0,0,m.map(b=>b.transform||{})),j={unitId:w,subUnitId:C,drawingId:I,drawingType:f.DrawingTypeEnum.DRAWING_GROUP,transform:D},N=m.map(b=>{const M=b.transform||{left:0,top:0},{unitId:R,subUnitId:E,drawingId:O}=b;return{unitId:R,subUnitId:E,drawingId:O,transform:{...M,left:M.left-D.left,top:M.top-D.top},groupId:I}});e.featurePluginGroupUpdateNotification([{parent:j,children:N}])},p=m=>{if(m.drawingType!==f.DrawingTypeEnum.DRAWING_GROUP)return;const{unitId:w,subUnitId:C,drawingId:I,transform:D={width:0,height:0}}=m;if(D==null)return;const j=e.getDrawingsByGroup({unitId:w,subUnitId:C,drawingId:I});if(j.length===0)return;const N=j.map(b=>{const{transform:M}=b,{unitId:R,subUnitId:E,drawingId:O}=b,k=y.transformObjectOutOfGroup(M||{},D,D.width||0,D.height||0);return{unitId:R,subUnitId:E,drawingId:O,transform:{...M,...k},groupId:void 0}});return{parent:m,children:N}},S=()=>{const w=e.getFocusDrawings().map(C=>p(C)).filter(C=>C!=null);w.length!==0&&e.featurePluginUngroupUpdateNotification(w)};return _.useEffect(()=>{const m=a[0];if(m==null)return;const{unitId:w}=m,C=t.getRenderById(w),I=C==null?void 0:C.scene;if(I==null)return;const D=I.getTransformerByCreate(),j=D.clearControl$.subscribe(b=>{b===!0&&o(!1)}),N=D.changeStart$.subscribe(b=>{const{objects:M}=b,R=de(M,e),E=R.filter(W=>(W==null?void 0:W.drawingType)===f.DrawingTypeEnum.DRAWING_GROUP);let O=!1,k=!1;R.length>1&&(O=!0),E.length>0&&(k=!0),o(O||k),u(O),g(k)});return()=>{N.unsubscribe(),j.unsubscribe()}},[]),h.jsxs("div",{className:P.clsx("univer-grid univer-gap-2 univer-py-2 univer-text-gray-400",{"univer-hidden":n===!0&&s===!1||n===!1}),children:[h.jsx("header",{className:"univer-text-gray-600 dark:!univer-text-gray-200",children:h.jsx("div",{children:r.t("image-panel.group.title")})}),h.jsxs("div",{className:"univer-flex univer-items-center univer-justify-center univer-gap-2",children:[h.jsxs(P.Button,{className:P.clsx({"univer-hidden":!c}),onClick:d,children:[h.jsx(Ue,{}),r.t("image-panel.group.group")]}),h.jsxs(P.Button,{className:P.clsx({"univer-hidden":!l}),onClick:S,children:[h.jsx(Ge,{}),r.t("image-panel.group.unGroup")]})]})]})},ne=20,ft=20,pt=[-3600,3600],he=300,mt=i=>{var De;const r=H.useDependency(f.LocaleService),t=H.useDependency(x.IDrawingManagerService),e=H.useDependency(y.IRenderManagerService),{drawings:n,transformShow:a}=i,s=n[0];if(s==null)return;const o=s.transform;if(o==null)return;const{unitId:c,subUnitId:u,drawingId:l,drawingType:g}=s,d=e.getRenderById(c),p=d==null?void 0:d.scene;if(p==null)return;const S=(De=p.getEngine())==null?void 0:De.activeScene;if(S==null)return;const m=p.getTransformerByCreate(),{width:w=0,height:C=0,left:I=0,top:D=0,angle:j=0}=o,[N,b]=_.useState(w),[M,R]=_.useState(C),[E,O]=_.useState(I),[k,A]=_.useState(D),[W,Y]=_.useState(j),[ae,ee]=_.useState(m.keepRatio),te=(v,B,G,V)=>{const{width:L,height:q}=S,{ancestorLeft:K,ancestorTop:Z}=p;let F=v,re=B,ce=G,le=V;return v+K<0&&(F=-K),B+Z<0&&(re=-Z),ce=L-F-K,ce<ne&&(ce=ne),le=q-re-Z,le<ne&&(le=ne),v+ce+K>L&&(F=L-G-K),B+le+Z>q&&(re=q-V-Z),{limitLeft:F,limitTop:re,limitWidth:ce,limitHeight:le}},se=v=>{const{objects:B}=v,G=de(B,t);if(G.length!==1)return;const V=G[0];if(V==null)return;const{transform:L}=V;if(L==null)return;const{width:q,height:K,left:Z,top:F,angle:re}=L;q!=null&&b(q),K!=null&&R(K),Z!=null&&O(Z),F!=null&&A(F),re!=null&&Y(re)};_.useEffect(()=>{const v=[m.changeStart$.subscribe(B=>{se(B)}),m.changing$.subscribe(B=>{se(B)}),m.changeEnd$.subscribe(B=>{se(B)}),t.focus$.subscribe(B=>{if(B.length!==1)return;const G=t.getDrawingByParam(B[0]);if(G==null)return;const V=G.transform;if(V==null)return;const{width:L,height:q,left:K,top:Z,angle:F}=V;L!=null&&b(L),q!=null&&R(q),K!=null&&O(K),Z!=null&&A(Z),F!=null&&Y(F)})];return()=>{v.forEach(B=>B.unsubscribe())}},[]);const X=f.debounce(v=>{if(v==null)return;v=Math.max(v,ne);const{limitWidth:B,limitHeight:G}=te(E,k,v,M);v=Math.min(v,B);const V={unitId:c,subUnitId:u,drawingId:l,drawingType:g,transform:{width:v}};if(ae){let L=v/N*M;if(L=Math.max(L,ft),L>G)return;R(L),V.transform.height=L}b(v),t.featurePluginUpdateNotification([V]),m.refreshControls().changeNotification()},he),Ce=f.debounce(v=>{if(v==null)return;v=Math.max(v,ne);const{limitHeight:B,limitWidth:G}=te(E,k,N,v);v=Math.min(v,B);const V={unitId:c,subUnitId:u,drawingId:l,drawingType:g,transform:{height:v}};if(ae){let L=v/M*N;if(L=Math.max(L,ne),L>G)return;b(L),V.transform.width=L}R(v),t.featurePluginUpdateNotification([V]),m.refreshControls().changeNotification()},he),$e=f.debounce(v=>{if(v==null)return;const{limitLeft:B}=te(v,k,N,M);v=B;const G={unitId:c,subUnitId:u,drawingId:l,drawingType:g,transform:{left:v}};O(v),t.featurePluginUpdateNotification([G]),m.refreshControls().changeNotification()},he),Ke=f.debounce(v=>{if(v==null)return;const{limitTop:B}=te(E,v,N,M);v=B;const G={unitId:c,subUnitId:u,drawingId:l,drawingType:g,transform:{top:v}};A(v),t.featurePluginUpdateNotification([G]),m.refreshControls().changeNotification()},he),Ze=v=>{if(v==null)return;const[B,G]=pt;v<B&&(v=B),v>G&&(v=G);const V={unitId:c,subUnitId:u,drawingId:l,drawingType:g,transform:{angle:v}};Y(v),t.featurePluginUpdateNotification([V]),m.refreshControls().changeNotification()},Fe=v=>{ee(v),m.keepRatio=v};return h.jsxs("div",{className:P.clsx("univer-grid univer-gap-2 univer-py-2 univer-text-gray-400",{"univer-hidden":!a}),children:[h.jsx("header",{className:"univer-text-gray-600 dark:!univer-text-gray-200",children:h.jsx("div",{children:r.t("image-panel.transform.title")})}),h.jsxs("div",{className:"univer-grid univer-grid-cols-3 univer-gap-2 [&>div]:univer-grid [&>div]:univer-gap-2",children:[h.jsxs("div",{children:[h.jsx("span",{children:r.t("image-panel.transform.width")}),h.jsx(P.InputNumber,{precision:1,value:N,onChange:v=>{X(v)}})]}),h.jsxs("div",{children:[h.jsx("span",{children:r.t("image-panel.transform.height")}),h.jsx(P.InputNumber,{precision:1,value:M,onChange:v=>{Ce(v)}})]}),h.jsxs("div",{children:[h.jsx("span",{children:r.t("image-panel.transform.lock")}),h.jsx("div",{className:"univer-text-center",children:h.jsx(P.Checkbox,{checked:ae,onChange:Fe})})]})]}),h.jsxs("div",{className:"univer-grid univer-grid-cols-3 univer-gap-2 [&>div]:univer-grid [&>div]:univer-gap-2",children:[h.jsxs("div",{children:[h.jsx("span",{children:r.t("image-panel.transform.x")}),h.jsx(P.InputNumber,{precision:1,value:E,onChange:v=>{$e(v)}})]}),h.jsxs("div",{children:[h.jsx("span",{children:r.t("image-panel.transform.y")}),h.jsx(P.InputNumber,{precision:1,value:k,onChange:v=>{Ke(v)}})]}),h.jsxs("div",{children:[h.jsx("span",{children:r.t("image-panel.transform.rotate")}),h.jsx(P.InputNumber,{precision:1,value:W,onChange:Ze})]})]})]})},pe={id:"sheet.operation.open-image-crop",type:f.CommandType.OPERATION,handler:(i,r)=>!0},Q={id:"sheet.operation.close-image-crop",type:f.CommandType.OPERATION,handler:(i,r)=>!0};var U=(i=>(i.FREE="0",i.R1_1="1",i.R16_9="2",i.R9_16="3",i.R5_4="4",i.R4_5="5",i.R4_3="6",i.R3_4="7",i.R3_2="8",i.R2_3="9",i))(U||{});const ge={id:"sheet.operation.Auto-image-crop",type:f.CommandType.OPERATION,handler:(i,r)=>!0},wt=i=>{const r=H.useDependency(f.ICommandService),t=H.useDependency(f.LocaleService),{drawings:e,cropperShow:n}=i;if(e[0]==null)return;const[s,o]=_.useState(U.FREE),c=_.useRef(!1),u=[{label:t.t("image-panel.crop.mode"),value:U.FREE},{label:"1:1",value:U.R1_1},{label:"16:9",value:U.R16_9},{label:"9:16",value:U.R9_16},{label:"5:4",value:U.R5_4},{label:"4:5",value:U.R4_5},{label:"4:3",value:U.R4_3},{label:"3:4",value:U.R3_4},{label:"3:2",value:U.R3_2},{label:"2:3",value:U.R2_3}];_.useEffect(()=>{const d=r.onCommandExecuted(p=>{if(p.id===Q.id){const S=p.params;S!=null&&S.isAuto||(c.current=!1)}});return()=>{d==null||d.dispose()}},[]);function l(d){o(d),c.current&&r.executeCommand(ge.id,{cropType:d})}const g=d=>{r.executeCommand(ge.id,{cropType:d}),c.current=!0};return h.jsxs("div",{className:P.clsx("univer-grid univer-gap-2 univer-py-2 univer-text-gray-400",{"univer-hidden":!n}),children:[h.jsx("header",{className:"univer-text-gray-600 dark:!univer-text-gray-200",children:h.jsx("div",{children:t.t("image-panel.crop.title")})}),h.jsxs("div",{className:"univer-flex univer-items-center univer-justify-center univer-gap-2",children:[h.jsxs(P.Button,{onClick:()=>{g(s)},children:[h.jsx(Be,{}),t.t("image-panel.crop.start")]}),h.jsx(P.Select,{value:s,options:u,onChange:l})]})]})},vt=i=>{const r=H.useDependency(x.IDrawingManagerService),t=H.useDependency(y.IRenderManagerService),e=H.useDependency(f.LocaleService),{drawings:n,hasArrange:a=!0,hasTransform:s=!0,hasAlign:o=!0,hasCropper:c=!0,hasGroup:u=!0}=i,l=n[0];if(l==null)return;const{unitId:g}=l,d=t.getRenderById(g),p=d==null?void 0:d.scene;if(p==null)return;const S=p.getTransformerByCreate(),[m,w]=_.useState(!0),[C,I]=_.useState(!0),[D,j]=_.useState(!1),[N,b]=_.useState(!0),[M,R]=_.useState(!1);return _.useEffect(()=>{const E=S.clearControl$.subscribe(A=>{A===!0&&(w(!1),I(!1),j(!1),b(!1),R(!0))}),O=S.changeStart$.subscribe(A=>{const{objects:W}=A,Y=de(W,r);Y.length===0?(w(!1),I(!1),j(!1),b(!1),R(!0)):Y.length===1?(w(!0),I(!0),j(!1),b(!0),R(!1)):(w(!0),I(!1),j(!0),b(!1),R(!1))}),k=r.focus$.subscribe(A=>{A.length===0?(w(!1),I(!1),j(!1),b(!1),R(!0)):A.length===1?(w(!0),I(!0),j(!1),b(!0),R(!1)):(w(!0),I(!1),j(!0),b(!1),R(!1))});return()=>{O.unsubscribe(),E.unsubscribe(),k.unsubscribe()}},[]),h.jsxs(h.Fragment,{children:[h.jsx("div",{className:P.clsx("univer-h-full",{"univer-hidden":!M}),children:h.jsx("div",{className:"univer-flex univer-h-full univer-items-center univer-justify-center",children:h.jsx("span",{children:e.t("image-panel.null")})})}),h.jsx(dt,{arrangeShow:a===!0?m:!1,drawings:n}),h.jsx(mt,{transformShow:s===!0?C:!1,drawings:n}),h.jsx(Je,{alignShow:o===!0?D:!1,drawings:n}),h.jsx(wt,{cropperShow:c===!0?N:!1,drawings:n}),h.jsx(ht,{hasGroup:u,drawings:n})]})};function Ve(i){var m;const{popup:r}=i,t=(m=r==null?void 0:r.extraProps)==null?void 0:m.menuItems;if(!t)return null;const e=H.useDependency(f.ICommandService),n=H.useDependency(f.LocaleService),[a,s]=_.useState(!1),[o,c]=_.useState(!1),u=()=>{c(!0)},l=()=>{c(!1)},g=w=>{s(w)},d=w=>{e.executeCommand(w.commandId,w.commandParams),s(!1)},p=a||o,S=t.filter(w=>!w.disable);return h.jsx("div",{onMouseEnter:u,onMouseLeave:l,children:h.jsx(P.DropdownMenu,{align:"start",items:S.map(w=>({type:"item",children:n.t(w.label),onSelect:()=>d(w)})),open:a,onOpenChange:g,children:h.jsxs("div",{className:P.clsx("univer-flex univer-items-center univer-gap-2 univer-rounded univer-p-1 hover:univer-bg-gray-100 dark:hover:!univer-bg-gray-800",P.borderClassName,{"univer-bg-gray-100 dark:!univer-bg-gray-800":a,"univer-bg-white dark:!univer-bg-gray-900":!a}),children:[h.jsx(Pe,{className:"univer-fill-primary-600 univer-text-gray-900 dark:!univer-text-white"}),p&&h.jsx(Ae,{className:"dark:!univer-text-white"})]})})})}const We="COMPONENT_IMAGE_POPUP_MENU",St="drawing-ui.config",Oe={},be={id:"sheet.operation.image-reset-size",type:f.CommandType.OPERATION,handler:(i,r)=>!0};var _t=Object.getOwnPropertyDescriptor,Ct=(i,r,t,e)=>{for(var n=e>1?void 0:e?_t(r,t):r,a=i.length-1,s;a>=0;a--)(s=i[a])&&(n=s(n)||n);return n},xe=(i,r)=>(t,e)=>r(t,e,i);let me=class extends f.Disposable{constructor(i,r){super(),this._componentManager=i,this._commandService=r,this._init()}_initCustomComponents(){const i=this._componentManager;this.disposeWithMe(i.register(We,Ve))}_initCommands(){[pe,Q,be,_e,ge].forEach(i=>this.disposeWithMe(this._commandService.registerCommand(i)))}_init(){this._initCommands(),this._initCustomComponents()}};me=Ct([xe(0,f.Inject(H.ComponentManager)),xe(1,f.ICommandService)],me);var It=Object.getOwnPropertyDescriptor,yt=(i,r,t,e)=>{for(var n=e>1?void 0:e?It(r,t):r,a=i.length-1,s;a>=0;a--)(s=i[a])&&(n=s(n)||n);return n},fe=(i,r)=>(t,e)=>r(t,e,i);let we=class extends f.Disposable{constructor(r,t,e,n){super();J(this,"_sceneListenerOnDrawingMap",new WeakSet);this._currentUniverService=r,this._commandService=t,this._renderManagerService=e,this._drawingManagerService=n,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 r=this._drawingManagerService.drawingManagerData,t=Ee(this._currentUniverService);if(t==null)return;const{unitId:e,subUnitId:n}=t;Object.keys(r).forEach(a=>{Object.keys(r[a]).forEach(s=>{const o=r[a][s].data;o==null||a!==e||s!==n||Object.keys(o).forEach(c=>{o[c]&&this._insertDrawing([{unitId:a,subUnitId:s,drawingId:c}])})})})}_commandExecutedListener(){this.disposeWithMe(this._commandService.onCommandExecuted(r=>{if(r.id===_e.id){const t=r.params;if(t==null)return;this._drawingAlign(t)}}))}_drawingGroupListener(){this.disposeWithMe(this._drawingManagerService.group$.subscribe(r=>{this._groupDrawings(r)})),this.disposeWithMe(this._drawingManagerService.ungroup$.subscribe(r=>{this._ungroupDrawings(r)}))}_getSceneAndTransformerByDrawingSearch(r){if(r==null)return;const t=this._renderManagerService.getRenderById(r),e=t==null?void 0:t.scene;if(e==null)return null;const n=e.getTransformerByCreate();return{scene:e,transformer:n}}_groupDrawings(r){r.forEach(t=>{this._groupDrawing(t)})}_groupDrawing(r){const{parent:t,children:e}=r,{unitId:n,subUnitId:a,drawingId:s}=t,o=this._getSceneAndTransformerByDrawingSearch(t.unitId);if(o==null)return;const{scene:c,transformer:u}=o;this._commandService.syncExecuteCommand(Q.id);const l=[];if(e.forEach(p=>{const S=x.getDrawingShapeKeyByDrawingSearch(p),m=c.getObjectIncludeInGroup(S);if(m==null||l.includes(m))return;l.push(m);const{transform:w}=p;w!=null&&(m.classType===y.RENDER_CLASS_TYPE.GROUP?m.transformByState({left:w.left,top:w.top}):m.transformByState(w))}),l.length===0)return;const g=x.getDrawingShapeKeyByDrawingSearch({unitId:n,subUnitId:a,drawingId:s}),d=new y.Group(g);c.addObject(d,y.DRAWING_OBJECT_LAYER_INDEX).attachTransformerTo(d),d.addObjects(...l),t.transform&&d.transformByState({left:t.transform.left,top:t.transform.top}),u.clearSelectedObjects(),u.setSelectedControl(d)}_ungroupDrawings(r){r.forEach(t=>{this._ungroupDrawing(t)})}_ungroupDrawing(r){const{parent:t,children:e}=r,n=this._getSceneAndTransformerByDrawingSearch(t.unitId);if(n==null)return;const{scene:a,transformer:s}=n;e.forEach(g=>{const d=x.getDrawingShapeKeyByDrawingSearch(g),p=a.getObjectIncludeInGroup(d);if(p==null)return!0;if(p==null)return;const{transform:S}=g;S!=null&&(p.classType===y.RENDER_CLASS_TYPE.GROUP?p.transformByState({left:S.left,top:S.top}):p.transformByState(S))});const o=x.getDrawingShapeKeyByDrawingSearch(t),c=a.getObject(o),{width:u,height:l}=c;c.getObjects().forEach(g=>{c.removeSelfObjectAndTransform(g.oKey,u,l)}),c.dispose(),s.clearSelectedObjects()}_drawingAlign(r){const{alignType:t}=r,e=this._drawingManagerService.getFocusDrawings();if(t===T.default)return;const n=[];let a=Number.POSITIVE_INFINITY,s=Number.POSITIVE_INFINITY,o=Number.NEGATIVE_INFINITY,c=Number.NEGATIVE_INFINITY,u=0;e.forEach(l=>{const{unitId:g,subUnitId:d,drawingId:p,drawingType:S}=l,m=this._drawingManagerService.getDrawingByParam({unitId:g,subUnitId:d,drawingId:p});if(m==null||m.transform==null)return;n.push({unitId:g,subUnitId:d,drawingId:p,drawingType:S,transform:m.transform});const{left:w=0,top:C=0,width:I=0,height:D=0}=m.transform;a=Math.min(a,w),s=Math.min(s,C),o=Math.max(o,w+I),c=Math.max(c,C+D),u++}),u!==0&&(this._sortDrawingTransform(n,t),this._applyAlignType(n,t,a,s,o,c,u))}_applyAlignType(r,t,e,n,a,s,o){const c=Math.round((a-e)/o*10)/10,u=Math.round((s-n)/o*10)/10,l=[],g=this._getSceneAndTransformerByDrawingSearch(r[0].unitId);if(g==null)return;const{scene:d,transformer:p}=g;r.forEach((S,m)=>{const{unitId:w,subUnitId:C,drawingId:I,transform:D,drawingType:j}=S,{left:N=0,top:b=0,width:M=0,height:R=0}=D;let E=N,O=b;switch(t){case T.left:E=e;break;case T.center:E=e+(a-e)/2-M/2;break;case T.right:E=a-M;break;case T.top:O=n;break;case T.middle:O=n+(s-n)/2-R/2;break;case T.bottom:O=s-R;break;case T.horizon:E=e+c*m;break;case T.vertical:O=n+u*m;break}(E!==N||O!==b)&&l.push({unitId:w,subUnitId:C,drawingId:I,drawingType:j,transform:{left:E,top:O}})}),this._drawingManagerService.featurePluginUpdateNotification(l),p.refreshControls().changeNotification()}_sortDrawingTransform(r,t){r.sort((e,n)=>{const a=e.transform,s=n.transform,{left:o=0,top:c=0,width:u=0,height:l=0}=a,{left:g=0,top:d=0,width:p=0,height:S=0}=s;switch(t){case T.left:return o-g;case T.center:return o+u/2-(g+p/2);case T.right:return o+u-(g+p);case T.top:return c-d;case T.middle:return c+l/2-(d+S/2);case T.bottom:return c+l-(d+S);case T.horizon:return o+u/2-(g+p/2);case T.vertical:return c+l/2-(d+S/2);default:return 0}})}_drawingArrangeListener(){this.disposeWithMe(this._drawingManagerService.order$.subscribe(r=>{this._drawingArrange(r)}))}_drawingArrange(r){const{unitId:t,subUnitId:e,drawingIds:n}=r,a=this._getSceneAndTransformerByDrawingSearch(t);if(a==null)return;const{scene:s}=a;n.forEach(o=>{const c=x.getDrawingShapeKeyByDrawingSearch({unitId:t,subUnitId:e,drawingId:o}),u=s.fuzzyMathObjects(c,!0);if(u==null||u.length===0)return;const l=this._drawingManagerService.getDrawingOrder(t,e).indexOf(o);for(const g of u)g.setProps({zIndex:l}),g.makeDirty()})}_drawingAddListener(){this.disposeWithMe(this._drawingManagerService.add$.subscribe(r=>{this._insertDrawing(r)}))}_insertDrawing(r){const t=[];r.forEach(e=>{const{unitId:n}=e;if(this._drawingManagerService.getDrawingByParam(e)==null)return;const s=this._getSceneAndTransformerByDrawingSearch(n);if(s==null)return;const{scene:o}=s;t.includes(o)||t.push(o)}),t.forEach(e=>{this._sceneListenerOnDrawingMap.has(e)||(this._addListenerOnDrawing(e),this._sceneListenerOnDrawingMap.add(e))})}_drawingRemoveListener(){this.disposeWithMe(this._drawingManagerService.remove$.subscribe(r=>{r.forEach(t=>{var l;const{unitId:e,subUnitId:n,drawingId:a}=t,s=this._getSceneAndTransformerByDrawingSearch(e);if(s==null)return;const{scene:o}=s,c=x.getDrawingShapeKeyByDrawingSearch({unitId:e,subUnitId:n,drawingId:a}),u=o.fuzzyMathObjects(c,!0);if(u.length>0){for(const g of u)g.dispose();(l=o.getTransformer())==null||l.clearSelectedObjects()}})}))}_drawingUpdateListener(){this.disposeWithMe(this._drawingManagerService.update$.subscribe(r=>{r.forEach(t=>{var M;const{unitId:e,subUnitId:n,drawingId:a}=t,s=this._drawingManagerService.getDrawingByParam(t);if(s==null)return;const{transform:o,drawingType:c}=s,u=this._getSceneAndTransformerByDrawingSearch(e);if(u==null)return;const{scene:l,transformer:g}=u;if(o==null)return!0;const{left:d=0,top:p=0,width:S=0,height:m=0,angle:w=0,flipX:C=!1,flipY:I=!1,skewX:D=0,skewY:j=0}=o,N=x.getDrawingShapeKeyByDrawingSearch({unitId:e,subUnitId:n,drawingId:a}),b=l.getObject(N);if(b==null)return!0;b.transformByState({left:d,top:p,width:S,height:m,angle:w,flipX:C,flipY:I,skewX:D,skewY:j}),(M=l.getTransformer())==null||M.debounceRefreshControls()})}))}_drawingRefreshListener(){this.disposeWithMe(this._drawingManagerService.refreshTransform$.subscribe(r=>{r.forEach(t=>{const{unitId:e,subUnitId:n,drawingId:a}=t,s=this._getSceneAndTransformerByDrawingSearch(e);if(s==null)return;const o=this._drawingManagerService.getDrawingByParam(t);if(o==null)return;const{transform:c}=o,{scene:u}=s,l=x.getDrawingShapeKeyByDrawingSearch({unitId:e,subUnitId:n,drawingId:a}),g=u.getObject(l);if(g==null||c==null)return!0;const{left:d=0,top:p=0,width:S=0,height:m=0,angle:w=0,flipX:C=!1,flipY:I=!1,skewX:D=0,skewY:j=0}=c;g.transformByState({left:d,top:p,width:S,height:m,angle:w,flipX:C,flipY:I,skewX:D,skewY:j})})}))}_drawingVisibleListener(){this.disposeWithMe(this._drawingManagerService.visible$.subscribe(r=>{r.forEach(t=>{const{unitId:e,subUnitId:n,drawingId:a,visible:s}=t,o=this._getSceneAndTransformerByDrawingSearch(e);if(o==null)return;const{scene:c}=o,u=x.getDrawingShapeKeyByDrawingSearch({unitId:e,subUnitId:n,drawingId:a}),l=c.getObject(u);if(l==null)return!0;s?l.show():l.hide()})}))}_filterUpdateParams(r,t){return r.filter((e,n)=>{if(e==null)return!1;const{transform:a}=e;return f.checkIfMove(a,t==null?void 0:t[n])})}_addListenerOnDrawing(r){const t=r.getTransformerByCreate();let e=null;this.disposeWithMe(f.toDisposable(t.changeStart$.subscribe(n=>{const{objects:a}=n,s=Array.from(a.values()),o=[];e=s.map(c=>{const{left:u,top:l,height:g,width:d,angle:p,oKey:S,isInGroup:m}=c,w=this._drawingManagerService.getDrawingOKey(S);if(m||c instanceof y.Group){let C=c.ancestorGroup;if(C==null&&c instanceof y.Group&&(C=c),C==null)return null;const I=this._drawingManagerService.getDrawingOKey(C.oKey);if(I){const{unitId:D,subUnitId:j,drawingId:N}=I;o.push({unitId:D,subUnitId:j,drawingId:N});const{left:b,top:M,height:R,width:E,angle:O}=C;return{left:b,top:M,height:R,width:E,angle:O}}}else if(w!=null){const{unitId:C,subUnitId:I,drawingId:D}=w;return o.push({unitId:C,subUnitId:I,drawingId:D}),{left:u,top:l,height:g,width:d,angle:p}}return null}).filter(c=>c!=null),o.length>0?this._commandService.syncExecuteCommand(x.SetDrawingSelectedOperation.id,o):this._commandService.syncExecuteCommand(x.SetDrawingSelectedOperation.id,[])}))),this.disposeWithMe(f.toDisposable(t.changeEnd$.subscribe(n=>{const{objects:a}=n,s=this._filterUpdateParams(de(a,this._drawingManagerService),e);s.length>0&&this._drawingManagerService.featurePluginUpdateNotification(s)})))}};we=yt([fe(0,f.IUniverInstanceService),fe(1,f.ICommandService),fe(2,y.IRenderManagerService),fe(3,x.IDrawingManagerService)],we);class ue extends y.Shape{constructor(t,e){e==null&&(e={}),e.transformerConfig={keepRatio:!1,isCropper:!0,anchorFill:"rgb(0, 0, 0)",anchorStroke:"rgb(255, 255, 255)",anchorSize:24};super(t,e);J(this,"_srcRect");J(this,"_prstGeom");J(this,"_applyTransform");J(this,"_dragPadding",8);J(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(t,e){this._srcRect=t,this._applyTransform=e,this._applyProps()}get srcRect(){return this._srcRect}dispose(){var t;super.dispose(),(t=this._cacheCanvas)==null||t.dispose(),this._srcRect=null}isHit(t){const e=this.getInverseCoord(t);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(t){const e=this._dragPadding;return t.x>=e-this.strokeWidth/2&&t.x<=this.width+this.strokeWidth/2-e&&t.y>=e-this.strokeWidth/2&&t.y<=this.height+this.strokeWidth/2-e}render(t,e){return this.visible?(t.save(),this._draw(t),t.restore(),this.makeDirty(!1),this):(this.makeDirty(!1),this)}_draw(t){var c,u;const n=this.getScene().getEngine(),{width:a,height:s}=n;this._initialCacheCanvas(),(c=this._cacheCanvas)==null||c.clear();const o=(u=this._cacheCanvas)==null?void 0:u.getContext();o!=null&&(o.save(),y.Rect.drawWith(o,{left:0,top:0,width:a,height:s,fill:"rgba(0, 0, 0, 0.5)"}),o.setTransform(t.getTransform()),this._clipForApplyObject(o),this._applyCache(t),o.restore())}_clipForApplyObject(t){let e=0;if(this._prstGeom!=null&&(e=1),t.globalCompositeOperation="destination-out",t.beginPath(),e===0){const n=this.transform.getMatrix();t.transform(n[0],n[1],n[2],n[3],n[4],n[5]),t.rect(0,0,this.width,this.height),t.fill()}}_applyProps(){if(this._applyTransform==null)return;let t=0,e=0,n=0,a=0;const{left:s=0,top:o=0,width:c=0,height:u=0,angle:l}=this._applyTransform;if(this._srcRect!=null){const{left:p=0,top:S=0,right:m=0,bottom:w=0}=this._srcRect;t=p,e=S,n=m,a=w}const g=s+t,d=o+e;this.transformByState({left:g,top:d,width:s+c-n-g,height:o+u-a-d,angle:l})}_applyCache(t){if(!t||this._cacheCanvas==null)return;const e=this._cacheCanvas.getContext();e.save(),t.save(),t.setTransform(1,0,0,1,0,0),e.setTransform(1,0,0,1,0,0),t.drawImage(this._cacheCanvas.getCanvasEle(),0,0),t.restore(),e.restore()}_initialCacheCanvas(){if(this._cacheCanvas!=null)return;const t=this.getScene();if(t==null)return;this._cacheCanvas=new y.Canvas;const e=t.getEngine();this._cacheCanvas.setSize(e.width,e.height),e.onTransformChange$.subscribeEvent(()=>{var n;(n=this._cacheCanvas)==null||n.setSize(e.width,e.height),this.makeDirty(!0)})}}var bt=Object.getOwnPropertyDescriptor,Dt=(i,r,t,e)=>{for(var n=e>1?void 0:e?bt(r,t):r,a=i.length-1,s;a>=0;a--)(s=i[a])&&(n=s(n)||n);return n},oe=(i,r)=>(t,e)=>r(t,e,i);let ve=class extends f.Disposable{constructor(r,t,e,n,a,s){super();J(this,"_sceneListenerOnImageMap",new WeakSet);this._commandService=r,this._drawingManagerService=t,this._renderManagerService=e,this._univerInstanceService=n,this._messageService=a,this._localeService=s,this._init()}_init(){this._initOpenCrop(),this._initCloseCrop(),this._initAutoCrop()}_initAutoCrop(){this.disposeWithMe(this._commandService.onCommandExecuted(r=>{if(r.id!==ge.id)return;const t=r.params;if(t==null)return;const{cropType:e}=t,n=this._drawingManagerService.getFocusDrawings();if(n.length!==1)return;const a=n[0],{unitId:s,subUnitId:o,drawingId:c}=a,u=this._renderManagerService.getRenderById(s),l=u==null?void 0:u.scene;if(l==null)return!0;this._searchCropObject(l)!=null&&this._commandService.syncExecuteCommand(Q.id,{isAuto:!0});const d=x.getDrawingShapeKeyByDrawingSearch({unitId:s,subUnitId:o,drawingId:c}),p=l.getObject(d);if(!(p instanceof y.Image)){this._messageService.show({type:P.MessageType.Error,content:this._localeService.t("image-cropper.error")});return}p!=null&&(this._updateCropperObject(e,p),this._commandService.executeCommand(pe.id,{unitId:s,subUnitId:o,drawingId:c}))}))}_calculateSrcRectByRatio(r,t,e,n,a,s){const o=e/n,c=a/s;let u=e,l=n;o>c?u=n*c:l=e/c;const g=(e-u)/2,d=(n-l)/2;return{left:y.precisionTo(g,1),top:y.precisionTo(d,1),right:y.precisionTo(e-(g+u),1),bottom:y.precisionTo(n-(d+l),1)}}_updateCropperObject(r,t){const{left:e,top:n,width:a,height:s}=t.calculateTransformWithSrcRect();let o;switch(r){case U.R1_1:o=this._calculateSrcRectByRatio(e,n,a,s,1,1);break;case U.R16_9:o=this._calculateSrcRectByRatio(e,n,a,s,16,9);break;case U.R9_16:o=this._calculateSrcRectByRatio(e,n,a,s,9,16);break;case U.R5_4:o=this._calculateSrcRectByRatio(e,n,a,s,5,4);break;case U.R4_5:o=this._calculateSrcRectByRatio(e,n,a,s,4,5);break;case U.R4_3:o=this._calculateSrcRectByRatio(e,n,a,s,4,3);break;case U.R3_4:o=this._calculateSrcRectByRatio(e,n,a,s,3,4);break;case U.R3_2:o=this._calculateSrcRectByRatio(e,n,a,s,3,2);break;case U.R2_3:o=this._calculateSrcRectByRatio(e,n,a,s,2,3);break;case U.FREE:}if(o==null)return;t.setSrcRect(o);const{left:c=0,top:u=0,bottom:l=0,right:g=0}=o;t.transformByStateCloseCropper({left:e+c,top:n+u,width:a-g-c,height:s-l-u})}_initOpenCrop(){this.disposeWithMe(this._commandService.onCommandExecuted(r=>{if(r.id!==pe.id)return;const t=r.params;if(t==null)return;const{unitId:e,subUnitId:n,drawingId:a}=t,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:n,drawingId:a})==null)return;const u=x.getDrawingShapeKeyByDrawingSearch({unitId:e,subUnitId:n,drawingId:a}),l=o.getObject(u);if(l==null)return;if(!(l instanceof y.Image)){this._messageService.show({type:P.MessageType.Error,content:this._localeService.t("image-cropper.error")});return}const g=o.getTransformer();g==null||g.clearControls();const d=new ue(`${u}-crop`,{srcRect:l.srcRect,prstGeom:l.prstGeom,applyTransform:l.calculateTransformWithSrcRect()});o.addObject(d,l.getLayerIndex()+1).attachTransformerTo(d),g==null||g.createControlForCopper(d),this._addHoverForImageCopper(d),l.openRenderByCropper(),g==null||g.refreshControls(),d.makeDirty(!0),this._commandService.syncExecuteCommand(x.SetDrawingSelectedOperation.id,[{unitId:e,subUnitId:n,drawingId:a}])}))}_searchCropObject(r){const t=r.getAllObjectsByOrder();for(const e of t)if(e instanceof ue)return e}_initCloseCrop(){this.disposeWithMe(this._commandService.onCommandExecuted(t=>{if(t.id!==Q.id)return;const e=this._univerInstanceService.getFocusedUnit();if(e==null)return;const n=e.getUnitId(),a=this._renderManagerService.getRenderById(n),s=a==null?void 0:a.scene;if(s==null)return!0;const o=this._searchCropObject(s);if(o==null)return;const c=this._getApplyObjectByCropObject(o);if(c==null)return;const u=s.getTransformerByCreate();u.detachFrom(o),u.clearCopperControl();const l=this._getSrcRectByTransformState(c,o),g=this._drawingManagerService.getDrawingOKey(c.oKey);if(g!=null){const{left:d,top:p,height:S,width:m}=o;this._drawingManagerService.featurePluginUpdateNotification([{...g,transform:{...g.transform,left:d,top:p,height:S,width:m},srcRect:l.srcRectAngle}])}c.setSrcRect({...l.srcRectAngle}),c.closeRenderByCropper(),c.makeDirty(!0),o==null||o.dispose()}));const r=this._univerInstanceService.getCurrentTypeOfUnit$(f.UniverInstanceType.UNIVER_SHEET).pipe(Re.switchMap(t=>t?t.activeSheet$:Re.of(null)));this.disposeWithMe(r.subscribe(()=>{this._commandService.syncExecuteCommand(Q.id)}))}_getApplyObjectByCropObject(r){const t=r.oKey,e=t.slice(0,t.length-5),n=r.getScene();if(!n)return null;const a=n.getObject(e);return a==null?null:a}_addListenerOnImage(r){const t=r.getTransformerByCreate();let e=null;this.disposeWithMe(t.changeStart$.subscribe(n=>{const{objects:a}=n,s=a.values().next().value;if(s==null||!(s instanceof ue))return;const{left:o,top:c,height:u,width:l,angle:g}=s;e={left:o,top:c,height:u,width:l,angle:g},t.clearCopperControl()})),this.disposeWithMe(t.changeEnd$.subscribe(n=>{const{objects:a}=n,s=a.values().next().value;if(s==null||!(s instanceof ue))return;const{left:o,top:c,height:u,width:l,angle:g}=s;if(!f.checkIfMove({left:o,top:c,height:u,width:l,angle:g},e))return;const d=this._getApplyObjectByCropObject(s);if(d==null)return;const p=this._getSrcRectByTransformState(d,s);s.refreshSrcRect(p.srcRect,d.getState()),t.createControlForCopper(s)})),this._endCropListener(r)}_addHoverForImageCopper(r){this.disposeWithMe(r.onPointerEnter$.subscribeEvent(()=>{r.cursor=y.CURSOR_TYPE.MOVE})),this.disposeWithMe(r.onPointerLeave$.subscribeEvent(()=>{r.cursor=y.CURSOR_TYPE.DEFAULT}))}_endCropListener(r){const t=r.getTransformerByCreate();this.disposeWithMe(t.clearControl$.subscribe(e=>{e===!0&&this._commandService.syncExecuteCommand(Q.id)}))}_getSrcRectByTransformState(r,t){const{left:e,top:n,height:a,width:s,strokeWidth:o,angle:c}=t,{left:u,top:l,width:g,height:d,angle:p,strokeWidth:S}=r,m=e-u,w=n-l,C={left:m,top:w,right:g-m-s,bottom:d-w-a},I={...C};if(p!==0){const D=e+s/2,j=n+a/2,N=new y.Vector2(D,j),b=g/2+u,M=d/2+l,R=new y.Vector2(b,M),E=new y.Vector2(u,l);E.rotateByPoint(y.degToRad(p),R);const O=E.clone();O.rotateByPoint(y.degToRad(-p),N);const k=e-O.x,A=n-O.y;I.left=k,I.top=A,I.right=g-k-s,I.bottom=d-A-a}return{srcRect:C,srcRectAngle:I}}};ve=Dt([oe(0,f.ICommandService),oe(1,x.IDrawingManagerService),oe(2,y.IRenderManagerService),oe(3,f.IUniverInstanceService),oe(4,H.IMessageService),oe(5,f.Inject(f.LocaleService))],ve);var Rt=Object.getOwnPropertyDescriptor,Mt=(i,r,t,e)=>{for(var n=e>1?void 0:e?Rt(r,t):r,a=i.length-1,s;a>=0;a--)(s=i[a])&&(n=s(n)||n);return n},ie=(i,r)=>(t,e)=>r(t,e,i);let Se=class extends f.Disposable{constructor(i,r,t,e,n,a,s){super(),this._commandService=i,this._renderManagerService=r,this._drawingManagerService=t,this._dialogService=e,this._imageIoService=n,this._currentUniverService=a,this._drawingRenderService=s,this._initialize()}dispose(){super.dispose()}_initialize(){this._drawingAddListener(),this._commandExecutedListener(),this._imageUpdateListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.onCommandExecuted(i=>{if(i.id===be.id){const r=i.params;if(r==null)return;this._resetImageSize(r)}}))}_getSceneAndTransformerByDrawingSearch(i){if(i==null)return;const r=this._renderManagerService.getRenderById(i),t=r==null?void 0:r.scene;if(t==null)return null;const e=t.getTransformerByCreate();return{scene:t,transformer:e}}_resetImageSize(i){const r=[],t=[];i.forEach(e=>{const{unitId:n,subUnitId:a,drawingId:s}=e,o=this._getSceneAndTransformerByDrawingSearch(n);if(o==null)return;const{scene:c}=o,u=x.getDrawingShapeKeyByDrawingSearch({unitId:n,subUnitId:a,drawingId:s}),l=c.getObject(u);if(l==null)return!0;const g=this._drawingManagerService.getDrawingByParam(e);if(g==null)return!0;if(g.drawingType!==f.DrawingTypeEnum.DRAWING_IMAGE)return;l.resetSize();const{width:d,height:p}=l.getNativeSize();t.includes(c)===!1&&t.push(c),r.push({...g,transform:{...g.transform,height:p,width:d,angle:0},srcRect:null,prstGeom:null})}),this._drawingManagerService.featurePluginUpdateNotification(r),t.forEach(e=>{e.getTransformerByCreate().refreshControls().changeNotification()}),this._commandService.syncExecuteCommand(x.SetDrawingSelectedOperation.id,i)}_drawingAddListener(){this.disposeWithMe(this._drawingManagerService.add$.subscribe(i=>{this._insertImages(i)}))}_insertImages(i){i.forEach(async r=>{var c;const{unitId:t,subUnitId:e}=r,n=this._getSceneAndTransformerByDrawingSearch(t),a=(c=Ee(this._currentUniverService,t))==null?void 0:c.subUnitId;if(n==null||a!==e)return;const s=this._drawingManagerService.getDrawingByParam(r);if(s==null)return;const o=await this._drawingRenderService.renderImages(s,n.scene);if(this._drawingManagerService.refreshTransform([s]),!(o==null||o.length===0))for(const u of o)this._addHoverForImage(u),this._addDialogForImage(u)})}_imageUpdateListener(){this.disposeWithMe(this._drawingManagerService.update$.subscribe(i=>{i.forEach(r=>{const{unitId:t,subUnitId:e,drawingId:n}=r,a=this._drawingManagerService.getDrawingByParam(r);if(a==null)return;const{transform:s,drawingType:o,srcRect:c,prstGeom:u,source:l,imageSourceType:g}=a;if(o!==f.DrawingTypeEnum.DRAWING_IMAGE)return;const d=this._getSceneAndTransformerByDrawingSearch(t);if(d==null)return;const{scene:p,transformer:S}=d;if(s==null)return!0;const m=x.getDrawingShapeKeyByDrawingSearch({unitId:t,subUnitId:e,drawingId:n}),w=p.getObject(m);if(w==null)return!0;w.setSrcRect(c),w.setPrstGeom(u),l!=null&&l.length>0&&(g===f.ImageSourceType.BASE64||g===f.ImageSourceType.URL)&&w.changeSource(l)})}))}_addHoverForImage(i){this.disposeWithMe(f.toDisposable(i.onPointerEnter$.subscribeEvent(()=>{i.cursor=y.CURSOR_TYPE.GRAB}))),this.disposeWithMe(f.toDisposable(i.onPointerLeave$.subscribeEvent(()=>{i.cursor=y.CURSOR_TYPE.DEFAULT})))}_addDialogForImage(i){this.disposeWithMe(f.toDisposable(i.onDblclick$.subscribeEvent(()=>{const r=`${i.oKey}-viewer-dialog`;this._drawingRenderService.previewImage(r,i.getNative().src,i.getNativeSize().width,i.getNativeSize().height)})))}};Se=Mt([ie(0,f.ICommandService),ie(1,y.IRenderManagerService),ie(2,x.IDrawingManagerService),ie(3,H.IDialogService),ie(4,x.IImageIoService),ie(5,f.IUniverInstanceService),ie(6,f.Inject(exports.DrawingRenderService))],Se);var Ot=Object.getOwnPropertyDescriptor,xt=(i,r,t,e)=>{for(var n=e>1?void 0:e?Ot(r,t):r,a=i.length-1,s;a>=0;a--)(s=i[a])&&(n=s(n)||n);return n},je=(i,r)=>(t,e)=>r(t,e,i);const jt="UNIVER_DRAWING_UI_PLUGIN";var ye;exports.UniverDrawingUIPlugin=(ye=class extends f.Plugin{constructor(r=Oe,t,e){super(),this._config=r,this._injector=t,this._configService=e;const{menu:n,...a}=f.merge({},Oe,this._config);n&&this._configService.setConfig("menu",n,{merge:!0}),this._configService.setConfig(St,a)}onStarting(){this._initDependencies()}onRendered(){this._injector.get(we),this._injector.get(me),this._injector.get(ve),this._injector.get(Se)}_initDependencies(){[[exports.DrawingRenderService],[we],[me],[ve],[Se]].forEach(t=>this._injector.add(t))}},J(ye,"pluginName",jt),ye);exports.UniverDrawingUIPlugin=xt([je(1,f.Inject(f.Injector)),je(2,f.IConfigService)],exports.UniverDrawingUIPlugin);exports.AutoImageCropOperation=ge;exports.COMPONENT_IMAGE_POPUP_MENU=We;exports.CloseImageCropOperation=Q;exports.DrawingCommonPanel=vt;exports.ImageCropperObject=ue;exports.ImagePopupMenu=Ve;exports.ImageResetSizeOperation=be;exports.OpenImageCropOperation=pe;exports.SetDrawingAlignOperation=_e;exports.getUpdateParams=de;
|
package/lib/es/index.js
CHANGED
|
@@ -939,7 +939,7 @@ function mr(i) {
|
|
|
939
939
|
children: /* @__PURE__ */ P(
|
|
940
940
|
"div",
|
|
941
941
|
{
|
|
942
|
-
className: te("univer-flex univer-items-center univer-gap-2 univer-rounded univer-p-1
|
|
942
|
+
className: te("univer-flex univer-items-center univer-gap-2 univer-rounded univer-p-1 hover:univer-bg-gray-100 dark:hover:!univer-bg-gray-800", Zt, {
|
|
943
943
|
"univer-bg-gray-100 dark:!univer-bg-gray-800": s,
|
|
944
944
|
"univer-bg-white dark:!univer-bg-gray-900": !s
|
|
945
945
|
}),
|
package/lib/index.js
CHANGED
|
@@ -939,7 +939,7 @@ function mr(i) {
|
|
|
939
939
|
children: /* @__PURE__ */ P(
|
|
940
940
|
"div",
|
|
941
941
|
{
|
|
942
|
-
className: te("univer-flex univer-items-center univer-gap-2 univer-rounded univer-p-1
|
|
942
|
+
className: te("univer-flex univer-items-center univer-gap-2 univer-rounded univer-p-1 hover:univer-bg-gray-100 dark:hover:!univer-bg-gray-800", Zt, {
|
|
943
943
|
"univer-bg-gray-100 dark:!univer-bg-gray-800": s,
|
|
944
944
|
"univer-bg-white dark:!univer-bg-gray-900": !s
|
|
945
945
|
}),
|
package/lib/umd/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(D,h){typeof exports=="object"&&typeof module<"u"?h(exports,require("@univerjs/core"),require("@univerjs/drawing"),require("@univerjs/engine-render"),require("@univerjs/ui"),require("react/jsx-runtime"),require("@univerjs/design"),require("react"),require("rxjs")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/drawing","@univerjs/engine-render","@univerjs/ui","react/jsx-runtime","@univerjs/design","react","rxjs"],h):(D=typeof globalThis<"u"?globalThis:D||self,h(D.UniverDrawingUi={},D.UniverCore,D.UniverDrawing,D.UniverEngineRender,D.UniverUi,D.React,D.UniverDesign,D.React,D.rxjs))})(this,function(D,h,M,I,L,f,U,_,Me){"use strict";var Pt=Object.defineProperty;var Nt=(D,h,M)=>h in D?Pt(D,h,{enumerable:!0,configurable:!0,writable:!0,value:M}):D[h]=M;var Q=(D,h,M)=>Nt(D,typeof h!="symbol"?h+"":h,M);var be;function Oe(i,r,t,e){const n=e.getDrawingByParam(i);if(n==null)return;const a=M.getDrawingShapeKeyByDrawingSearch(i),s=t.getObject(a);if(s&&!(s instanceof I.Group))return;if(s!=null){s.addObject(r);return}const o=new I.Group(a);t.addObject(o,I.DRAWING_OBJECT_LAYER_INDEX).attachTransformerTo(o),o.addObject(r);const{transform:c}=n;c&&o.transformByState({left:c.left,top:c.top,angle:c.angle})}function Ee(i,r){var a;const t=r?i.getUnit(r):i.getFocusedUnit();if(t==null)return;const e=t.getUnitId();let n;return t.type===h.UniverInstanceType.UNIVER_SHEET?n=(a=t.getActiveSheet())==null?void 0:a.getSheetId():(t.type===h.UniverInstanceType.UNIVER_DOC||t.type===h.UniverInstanceType.UNIVER_SLIDE)&&(n=e),{unitId:e,subUnitId:n,current:t}}var Ke=Object.getOwnPropertyDescriptor,Ze=(i,r,t,e)=>{for(var n=e>1?void 0:e?Ke(r,t):r,a=i.length-1,s;a>=0;a--)(s=i[a])&&(n=s(n)||n);return n},ye=(i,r)=>(t,e)=>r(t,e,i);D.DrawingRenderService=class{constructor(r,t,e){this._drawingManagerService=r,this._imageIoService=t,this._galleryService=e}async renderImages(r,t){const{transform:e,drawingType:n,source:a,imageSourceType:s,srcRect:o,prstGeom:c,groupId:u,unitId:l,subUnitId:g,drawingId:d,isMultiTransform:p,transforms:S}=r;if(n!==h.DrawingTypeEnum.DRAWING_IMAGE||!this._drawingManagerService.getDrawingVisible()||e==null)return;const m=p&&S?S:[e],v=[];for(const C of m){const{left:y,top:O,width:N,height:j,angle:b,flipX:T,flipY:E,skewX:B,skewY:P}=C,G=m.indexOf(C),H=M.getDrawingShapeKeyByDrawingSearch({unitId:l,subUnitId:g,drawingId:d},p?G:void 0),$=t.getObject(H);if($!=null){$.transformByState({left:y,top:O,width:N,height:j,angle:b,flipX:T,flipY:E,skewX:B,skewY:P});continue}const X=this._drawingManagerService.getDrawingOrder(l,g),oe=X.indexOf(d),ne={...C,zIndex:oe===-1?X.length-1:oe},ie=this._imageIoService.getImageSourceCache(a,s);let ce=!1;if(ie!=null)ne.image=ie;else{if(s===M.ImageSourceType.UUID)try{ne.url=await this._imageIoService.getImage(a)}catch(De){console.error(De);continue}else ne.url=a;ce=!0}if(t.getObject(H))continue;ne.printable=!0;const q=new I.Image(H,ne);ce&&this._imageIoService.addImageSourceCache(a,s,q.getNative()),this._drawingManagerService.getDrawingVisible()&&(t.addObject(q,I.DRAWING_OBJECT_LAYER_INDEX),this._drawingManagerService.getDrawingEditable()&&t.attachTransformerTo(q),u&&Oe({drawingId:u,unitId:l,subUnitId:g},q,t,this._drawingManagerService),c!=null&&q.setPrstGeom(c),o!=null&&q.setSrcRect(o),v.push(q))}return v}renderFloatDom(r,t){const{transform:e,drawingType:n,groupId:a,unitId:s,subUnitId:o,drawingId:c,isMultiTransform:u,transforms:l}=r;if(n!==h.DrawingTypeEnum.DRAWING_DOM||!this._drawingManagerService.getDrawingVisible()||e==null)return;const g=u&&l?l:[e],d=[];for(const p of g){const{left:S,top:m,width:v,height:C,angle:y,flipX:O,flipY:N,skewX:j,skewY:b}=p,T=g.indexOf(p),E=M.getDrawingShapeKeyByDrawingSearch({unitId:s,subUnitId:o,drawingId:c},u?T:void 0),B=t.getObject(E);if(B!=null){B.transformByState({left:S,top:m,width:v,height:C,angle:y,flipX:O,flipY:N,skewX:j,skewY:b});continue}const P=this._drawingManagerService.getDrawingOrder(s,o),G=P.indexOf(c),H={...p,zIndex:G===-1?P.length-1:G};if(t.getObject(E))continue;H.printable=!1;const $=new I.Rect(E,H);this._drawingManagerService.getDrawingVisible()&&(t.addObject($,I.DRAWING_OBJECT_LAYER_INDEX),this._drawingManagerService.getDrawingEditable()&&r.allowTransform!==!1&&t.attachTransformerTo($),a&&Oe({drawingId:a,unitId:s,subUnitId:o},$,t,this._drawingManagerService),d.push($))}return d}renderDrawing(r,t){const e=this._drawingManagerService.getDrawingByParam(r);if(e!=null)switch(e.drawingType){case h.DrawingTypeEnum.DRAWING_IMAGE:return this.renderImages(e,t)}}previewImage(r,t,e,n){this._galleryService.open({images:[t],onOpenChange:a=>{a||this._galleryService.close()}})}_adjustImageSize(r,t,e,n){if(r<=e&&t<=n)return{width:r,height:t};const a=e/r,s=n/t,o=Math.min(a,s);return{width:Math.floor(r*o),height:Math.floor(t*o)}}},D.DrawingRenderService=Ze([ye(0,M.IDrawingManagerService),ye(1,M.IImageIoService),ye(2,L.IGalleryService)],D.DrawingRenderService);function le(i,r){const t=[];return i.forEach(e=>{const{oKey:n,left:a,top:s,height:o,width:c,angle:u}=e,l=r.getDrawingOKey(n);if(l==null)return t.push(null),!0;const{unitId:g,subUnitId:d,drawingId:p,drawingType:S}=l,m={unitId:g,subUnitId:d,drawingId:p,drawingType:S,transform:{left:a,top:s,height:o,width:c,angle:u}};S===h.DrawingTypeEnum.DRAWING_IMAGE&&(m.srcRect=e.srcRect),t.push(m)}),t}var R=(i=>(i.default="0",i.left="1",i.center="2",i.right="3",i.top="4",i.middle="5",i.bottom="6",i.horizon="7",i.vertical="8",i))(R||{});const fe={id:"sheet.operation.set-image-align",type:h.CommandType.OPERATION,handler:(i,r)=>!0},Fe=i=>{const r=L.useDependency(h.ICommandService),t=L.useDependency(h.LocaleService),{alignShow:e}=i,[n,a]=_.useState(R.default),s=[{label:t.t("image-panel.align.default"),value:R.default},{options:[{label:t.t("image-panel.align.left"),value:R.left},{label:t.t("image-panel.align.center"),value:R.center},{label:t.t("image-panel.align.right"),value:R.right}]},{options:[{label:t.t("image-panel.align.top"),value:R.top},{label:t.t("image-panel.align.middle"),value:R.middle},{label:t.t("image-panel.align.bottom"),value:R.bottom}]},{options:[{label:t.t("image-panel.align.horizon"),value:R.horizon},{label:t.t("image-panel.align.vertical"),value:R.vertical}]}];function o(c){a(c),r.executeCommand(fe.id,{alignType:c})}return f.jsxs("div",{className:U.clsx("univer-relative univer-w-full",{"univer-hidden":!e}),children:[f.jsx("header",{className:"univer-text-gray-600 dark:!univer-text-gray-200",children:f.jsx("div",{children:t.t("image-panel.align.title")})}),f.jsx("div",{className:"univer-relative univer-mt-2.5 univer-flex univer-h-full",children:f.jsx("div",{className:"univer-w-full univer-text-gray-900 dark:!univer-text-white",children:f.jsx(U.Select,{value:n,options:s,onChange:o})})})]})};var K=function(){return K=Object.assign||function(i){for(var r,t=1,e=arguments.length;t<e;t++){r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(i[n]=r[n])}return i},K.apply(this,arguments)},ze=function(i,r){var t={};for(var e in i)Object.prototype.hasOwnProperty.call(i,e)&&r.indexOf(e)<0&&(t[e]=i[e]);if(i!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,e=Object.getOwnPropertySymbols(i);n<e.length;n++)r.indexOf(e[n])<0&&Object.prototype.propertyIsEnumerable.call(i,e[n])&&(t[e[n]]=i[e[n]]);return t},z=_.forwardRef(function(i,r){var t=i.icon,e=i.id,n=i.className,a=i.extend,s=ze(i,["icon","id","className","extend"]),o="univerjs-icon univerjs-icon-".concat(e," ").concat(n||"").trim(),c=_.useRef("_".concat(qe()));return Te(t,"".concat(e),{defIds:t.defIds,idSuffix:c.current},K({ref:r,className:o},s),a)});function Te(i,r,t,e,n){return _.createElement(i.tag,K(K({key:r},Ye(i,t,n)),e),(Xe(i,t).children||[]).map(function(a,s){return Te(a,"".concat(r,"-").concat(i.tag,"-").concat(s),t,void 0,n)}))}function Ye(i,r,t){var e=K({},i.attrs);t!=null&&t.colorChannel1&&e.fill==="colorChannel1"&&(e.fill=t.colorChannel1),i.tag==="mask"&&e.id&&(e.id=e.id+r.idSuffix),Object.entries(e).forEach(function(a){var s=a[0],o=a[1];s==="mask"&&typeof o=="string"&&(e[s]=o.replace(/url\(#(.*)\)/,"url(#$1".concat(r.idSuffix,")")))});var n=r.defIds;return!n||n.length===0||(i.tag==="use"&&e["xlink:href"]&&(e["xlink:href"]=e["xlink:href"]+r.idSuffix),Object.entries(e).forEach(function(a){var s=a[0],o=a[1];typeof o=="string"&&(e[s]=o.replace(/url\(#(.*)\)/,"url(#$1".concat(r.idSuffix,")")))})),e}function Xe(i,r){var t,e=r.defIds;return!e||e.length===0?i:i.tag==="defs"&&(!((t=i.children)===null||t===void 0)&&t.length)?K(K({},i),{children:i.children.map(function(n){return typeof n.attrs.id=="string"&&e&&e.includes(n.attrs.id)?K(K({},n),{attrs:K(K({},n.attrs),{id:n.attrs.id+r.idSuffix})}):n})}):i}function qe(){return Math.random().toString(36).substring(2,8)}z.displayName="UniverIcon";var Je={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"colorChannel1",d:"M11.0363 12.2367V14.0367C11.0363 14.3681 11.3049 14.6367 11.6363 14.6367C11.9676 14.6367 12.2363 14.3681 12.2363 14.0367V12.2367H14.0364C14.3677 12.2367 14.6364 11.9681 14.6364 11.6367C14.6364 11.3054 14.3677 11.0367 14.0364 11.0367H12.2363V9.23672C12.2363 8.90535 11.9676 8.63672 11.6363 8.63672C11.3049 8.63672 11.0363 8.90535 11.0363 9.23672V11.0367H9.23635C8.90498 11.0367 8.63635 11.3054 8.63635 11.6367C8.63635 11.9681 8.90498 12.2367 9.23635 12.2367H11.0363Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M2.56365 1.36377C1.90091 1.36377 1.36365 1.90103 1.36365 2.56377V6.16377C1.36365 6.82651 1.90091 7.36377 2.56365 7.36377H6.16365C6.82639 7.36377 7.36365 6.82651 7.36365 6.16377V2.56377C7.36365 1.90103 6.82639 1.36377 6.16365 1.36377H2.56365ZM6.16365 2.56377H2.56365L2.56365 6.16377H6.16365V2.56377Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M2.56365 8.63647C1.90091 8.63647 1.36365 9.17373 1.36365 9.83647V13.4365C1.36365 14.0992 1.90091 14.6365 2.56365 14.6365H6.16365C6.82639 14.6365 7.36365 14.0992 7.36365 13.4365V9.83647C7.36365 9.17373 6.82639 8.63647 6.16365 8.63647H2.56365ZM6.16365 9.83647H2.56365L2.56365 13.4365H6.16365V9.83647Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M9.83635 7.36377C9.17361 7.36377 8.63635 6.82651 8.63635 6.16377V2.56377C8.63635 1.90103 9.17361 1.36377 9.83635 1.36377H13.4364C14.0991 1.36377 14.6364 1.90103 14.6364 2.56377V6.16377C14.6364 6.82651 14.0991 7.36377 13.4364 7.36377H9.83635ZM9.83635 6.16377V2.56377L13.4364 2.56377V6.16377H9.83635Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Pe=_.forwardRef(function(i,r){return _.createElement(z,Object.assign({},i,{id:"autofill-double-icon",ref:r,icon:Je}))});Pe.displayName="AutofillDoubleIcon";var Qe={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 17 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M14.0045 4.4334C14.8881 4.4334 15.6045 3.71705 15.6045 2.8334C15.6045 1.94974 14.8881 1.2334 14.0045 1.2334H3.70449C2.82084 1.2334 2.10449 1.94974 2.10449 2.8334C2.10449 3.71705 2.82084 4.4334 3.70449 4.4334H14.0045ZM14.4045 2.8334C14.4045 3.05431 14.2254 3.2334 14.0045 3.2334H3.70449C3.48358 3.2334 3.30449 3.05431 3.30449 2.8334C3.30449 2.61248 3.48358 2.4334 3.70449 2.4334H14.0045C14.2254 2.4334 14.4045 2.61249 14.4045 2.8334Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M14.1544 8.5999C15.038 8.5999 15.7544 7.88356 15.7544 6.9999C15.7544 6.11625 15.038 5.3999 14.1544 5.3999H3.85439C2.97074 5.3999 2.25439 6.11625 2.25439 6.9999C2.25439 7.88356 2.97074 8.5999 3.85439 8.5999H14.1544ZM14.5544 6.9999C14.5544 7.22082 14.3753 7.3999 14.1544 7.3999H3.85439C3.63348 7.3999 3.45439 7.22082 3.45439 6.9999C3.45439 6.77899 3.63348 6.5999 3.85439 6.5999H14.1544C14.3753 6.5999 14.5544 6.77899 14.5544 6.9999Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M8.57975 14.5902L6.58023 12.5907C6.34591 12.3564 6.34591 11.9765 6.58023 11.7421C6.81454 11.5078 7.19444 11.5078 7.42876 11.7421L8.40449 12.7179V10.1664C8.40449 9.83504 8.67312 9.56641 9.00449 9.56641C9.33586 9.56641 9.60449 9.83504 9.60449 10.1664V12.7179L10.5802 11.7421C10.8145 11.5078 11.1944 11.5078 11.4288 11.7421C11.6631 11.9765 11.6631 12.3564 11.4288 12.5907L9.42923 14.5902"}},{tag:"path",attrs:{fill:"currentColor",d:"M8.57975 14.5902C8.58121 14.5917 8.58268 14.5931 8.58416 14.5946C8.64077 14.6502 8.70566 14.6923 8.77482 14.7209C8.84557 14.7502 8.92314 14.7664 9.00449 14.7664C9.08585 14.7664 9.16342 14.7502 9.23416 14.7209C9.30332 14.6923 9.36821 14.6502 9.42482 14.5946"}}]},Ne=_.forwardRef(function(i,r){return _.createElement(z,Object.assign({},i,{id:"bottom-icon",ref:r,icon:Qe}))});Ne.displayName="BottomIcon";var et={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M5.97705 7.51296C5.97705 7.18159 6.24568 6.91296 6.57705 6.91296H8.48632C8.81769 6.91296 9.08632 7.18159 9.08632 7.51296C9.08632 7.84433 8.81769 8.11296 8.48632 8.11296H6.57705C6.24568 8.11296 5.97705 7.84433 5.97705 7.51296Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M6.57705 9.41028C6.24568 9.41028 5.97705 9.67891 5.97705 10.0103C5.97705 10.3416 6.24568 10.6103 6.57705 10.6103H10.8199C11.1512 10.6103 11.4199 10.3416 11.4199 10.0103C11.4199 9.67891 11.1512 9.41028 10.8199 9.41028H6.57705Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M3.51074 2.37063C3.51074 1.48697 4.22709 0.77063 5.11074 0.77063H9.80318L9.81294 0.770708C9.97168 0.768161 10.1311 0.82824 10.2511 0.95055L14.4317 5.21408C14.5165 5.30049 14.5697 5.406 14.5917 5.51645C14.6041 5.5644 14.6106 5.61467 14.6106 5.66648V11.6406C14.6106 12.5243 13.8943 13.2406 13.0106 13.2406H5.11074C4.22709 13.2406 3.51074 12.5243 3.51074 11.6406V2.37063ZM10.4032 4.66648V2.81964L12.6063 5.06648H10.8032C10.5823 5.06648 10.4032 4.88739 10.4032 4.66648ZM5.11074 1.97063C4.88983 1.97063 4.71074 2.14972 4.71074 2.37063V11.6406C4.71074 11.8615 4.88983 12.0406 5.11074 12.0406H13.0106C13.2316 12.0406 13.4106 11.8615 13.4106 11.6406V6.26648H10.8032C9.91953 6.26648 9.20318 5.55013 9.20318 4.66648V1.97063H5.11074Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M2.58916 6.6741C2.58916 6.34273 2.32053 6.0741 1.98916 6.0741C1.65779 6.0741 1.38916 6.34273 1.38916 6.6741V12.6294C1.38916 14.0653 2.55322 15.2294 3.98916 15.2294H9.41408C9.74545 15.2294 10.0141 14.9607 10.0141 14.6294C10.0141 14.298 9.74545 14.0294 9.41408 14.0294H3.98916C3.21596 14.0294 2.58916 13.4026 2.58916 12.6294V6.6741Z"}}]},Be=_.forwardRef(function(i,r){return _.createElement(z,Object.assign({},i,{id:"create-copy-icon",ref:r,icon:et}))});Be.displayName="CreateCopyIcon";var tt={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 17 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M7.38125 1.16211C6.49759 1.16211 5.78125 1.87845 5.78125 2.76211V5.6377H2.87783C1.99418 5.6377 1.27783 6.35404 1.27783 7.2377V13.2377C1.27783 14.1214 1.99418 14.8377 2.87783 14.8377H8.87783C9.76149 14.8377 10.4778 14.1214 10.4778 13.2377V10.3621H13.3813C14.2649 10.3621 14.9813 9.64577 14.9813 8.76211V2.76211C14.9813 1.87845 14.2649 1.16211 13.3813 1.16211H7.38125ZM10.4778 9.16211H13.3813C13.6022 9.16211 13.7812 8.98302 13.7812 8.76211V2.76211C13.7812 2.5412 13.6022 2.36211 13.3813 2.36211H7.38125C7.16034 2.36211 6.98125 2.5412 6.98125 2.76211V5.6377H8.87783C9.76149 5.6377 10.4778 6.35404 10.4778 7.2377V9.16211ZM6.98125 6.8377H8.87783C9.09875 6.8377 9.27783 7.01678 9.27783 7.2377V9.16211H7.38125C7.16034 9.16211 6.98125 8.98302 6.98125 8.76211V6.8377ZM5.78125 6.8377V8.76211C5.78125 9.64577 6.49759 10.3621 7.38125 10.3621H9.27783V13.2377C9.27783 13.4586 9.09875 13.6377 8.87783 13.6377H2.87783C2.65692 13.6377 2.47783 13.4586 2.47783 13.2377V7.2377C2.47783 7.01678 2.65692 6.8377 2.87783 6.8377H5.78125Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Ue=_.forwardRef(function(i,r){return _.createElement(z,Object.assign({},i,{id:"group-icon",ref:r,icon:tt}))});Ue.displayName="GroupIcon";var rt={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"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"}}]},Re=_.forwardRef(function(i,r){return _.createElement(z,Object.assign({},i,{id:"more-down-icon",ref:r,icon:rt}))});Re.displayName="MoreDownIcon";var nt={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M1.25 2.96401C1.25 3.84767 1.96634 4.56401 2.85 4.56401H13.15C14.0337 4.56401 14.75 3.84767 14.75 2.96401C14.75 2.08036 14.0337 1.36401 13.15 1.36401H2.85C1.96635 1.36401 1.25 2.08036 1.25 2.96401ZM2.85 3.36401C2.62909 3.36401 2.45 3.18493 2.45 2.96401C2.45 2.7431 2.62909 2.56401 2.85 2.56401H13.15C13.3709 2.56401 13.55 2.7431 13.55 2.96401C13.55 3.18493 13.3709 3.36401 13.15 3.36401H2.85Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M5.57564 11.6118C5.80995 11.3774 6.18985 11.3774 6.42417 11.6118L7.3999 12.5875V6.36951C7.3999 6.03814 7.66853 5.76951 7.9999 5.76951C8.33127 5.76951 8.5999 6.03814 8.5999 6.36951V12.5875L9.57564 11.6118C9.80995 11.3774 10.1899 11.3774 10.4242 11.6118C10.6585 11.8461 10.6585 12.226 10.4242 12.4603L8.4324 14.452C8.32324 14.5655 8.16982 14.6362 7.9999 14.6362C7.82998 14.6362 7.67655 14.5655 7.56739 14.452L5.57564 12.4603C5.34132 12.226 5.34132 11.8461 5.57564 11.6118Z"}}]},je=_.forwardRef(function(i,r){return _.createElement(z,Object.assign({},i,{id:"move-down-icon",ref:r,icon:nt}))});je.displayName="MoveDownIcon";var it={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M1.25 13.036C1.25 12.1523 1.96634 11.436 2.85 11.436H13.15C14.0337 11.436 14.75 12.1523 14.75 13.036C14.75 13.9196 14.0337 14.636 13.15 14.636H2.85C1.96635 14.636 1.25 13.9196 1.25 13.036ZM2.85 12.636C2.62909 12.636 2.45 12.8151 2.45 13.036C2.45 13.2569 2.62909 13.436 2.85 13.436H13.15C13.3709 13.436 13.55 13.2569 13.55 13.036C13.55 12.8151 13.3709 12.636 13.15 12.636H2.85Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M5.57564 4.38825C5.80995 4.62256 6.18985 4.62256 6.42417 4.38825L7.3999 3.41251V9.63049C7.3999 9.96186 7.66853 10.2305 7.9999 10.2305C8.33127 10.2305 8.5999 9.96186 8.5999 9.63049V3.41251L9.57564 4.38825C9.80995 4.62256 10.1899 4.62256 10.4242 4.38825C10.6585 4.15393 10.6585 3.77403 10.4242 3.53972L8.4324 1.54796C8.32324 1.43445 8.16982 1.36382 7.9999 1.36382C7.82998 1.36382 7.67655 1.43446 7.56739 1.54797L5.57564 3.53972C5.34132 3.77403 5.34132 4.15393 5.57564 4.38825Z"}}]},xe=_.forwardRef(function(i,r){return _.createElement(z,Object.assign({},i,{id:"move-up-icon",ref:r,icon:it}))});xe.displayName="MoveUpIcon";var at={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 17 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M7.82994 1.40913C7.88746 1.35161 7.95376 1.30821 8.02453 1.27893C8.09527 1.24959 8.17285 1.2334 8.2542 1.2334C8.33555 1.2334 8.41313 1.24959 8.48387 1.27893C8.55464 1.30821 8.62094 1.35161 8.67846 1.40913L10.6785 3.40913C10.9128 3.64345 10.9128 4.02335 10.6785 4.25766C10.4441 4.49198 10.0642 4.49198 9.82994 4.25766L8.8542 3.28193V5.8334C8.8542 6.16477 8.58557 6.4334 8.2542 6.4334C7.92283 6.4334 7.6542 6.16477 7.6542 5.8334V3.28193L6.67846 4.25766C6.44415 4.49198 6.06425 4.49198 5.82994 4.25766C5.59562 4.02335 5.59562 3.64345 5.82994 3.40913L7.82994 1.40913Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M1.50439 9C1.50439 8.11634 2.22074 7.4 3.10439 7.4H13.4044C14.288 7.4 15.0044 8.11634 15.0044 9C15.0044 9.88366 14.2881 10.6 13.4044 10.6H3.1044C2.22074 10.6 1.50439 9.88366 1.50439 9ZM3.10439 8.6C2.88348 8.6 2.70439 8.77909 2.70439 9C2.70439 9.22091 2.88348 9.4 3.1044 9.4H13.4044C13.6253 9.4 13.8044 9.22091 13.8044 9C13.8044 8.77909 13.6253 8.6 13.4044 8.6H3.10439Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M1.6543 13.1665C1.6543 12.2828 2.37064 11.5665 3.2543 11.5665H13.5543C14.438 11.5665 15.1543 12.2828 15.1543 13.1665C15.1543 14.0502 14.438 14.7665 13.5543 14.7665H3.2543C2.37064 14.7665 1.6543 14.0502 1.6543 13.1665ZM3.2543 12.7665C3.03338 12.7665 2.8543 12.9456 2.8543 13.1665C2.8543 13.3874 3.03338 13.5665 3.2543 13.5665H13.5543C13.7752 13.5665 13.9543 13.3874 13.9543 13.1665C13.9543 12.9456 13.7752 12.7665 13.5543 12.7665H3.2543Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Ae=_.forwardRef(function(i,r){return _.createElement(z,Object.assign({},i,{id:"topmost-icon",ref:r,icon:at}))});Ae.displayName="TopmostIcon";var st={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 17 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M7.46855 2.83731C7.46855 2.61639 7.64764 2.4373 7.86855 2.4373H13.8603C14.0812 2.4373 14.2603 2.61639 14.2603 2.8373V9.5049C14.2603 9.72581 14.0812 9.90489 13.8603 9.90489H12.866C12.5346 9.90489 12.266 10.1735 12.266 10.5049C12.266 10.8363 12.5346 11.1049 12.866 11.1049H13.8603C14.7439 11.1049 15.4603 10.3886 15.4603 9.5049V2.8373C15.4603 1.95365 14.7439 1.2373 13.8603 1.2373H7.86855C6.9849 1.2373 6.26855 1.95365 6.26855 2.83731V3.48688C6.26855 3.81825 6.53718 4.08688 6.86855 4.08688C7.19993 4.08688 7.46855 3.81825 7.46855 3.48688V2.83731Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M3.19888 5.56299C2.31522 5.56299 1.59888 6.27933 1.59888 7.16299V13.163C1.59888 14.0466 2.31522 14.763 3.19888 14.763H9.19888C10.0825 14.763 10.7989 14.0466 10.7989 13.163V7.16299C10.7989 6.27933 10.0825 5.56299 9.19888 5.56299H3.19888ZM2.79888 7.16299C2.79888 6.94207 2.97796 6.76299 3.19888 6.76299H9.19888C9.41979 6.76299 9.59888 6.94207 9.59888 7.16299V13.163C9.59888 13.3839 9.41979 13.563 9.19888 13.563H3.19888C2.97796 13.563 2.79888 13.3839 2.79888 13.163V7.16299Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Le=_.forwardRef(function(i,r){return _.createElement(z,Object.assign({},i,{id:"ungroup-icon",ref:r,icon:st}))});Le.displayName="UngroupIcon";const ot=i=>{const{arrangeShow:r,drawings:t}=i,e=L.useDependency(h.LocaleService),n=L.useDependency(M.IDrawingManagerService),[a,s]=_.useState(t);_.useEffect(()=>{const c=n.focus$.subscribe(u=>{s(u)});return()=>{c.unsubscribe()}},[]);const o=c=>{const u=a[0].unitId,l=a[0].subUnitId,g=a.map(d=>d.drawingId);n.featurePluginOrderUpdateNotification({unitId:u,subUnitId:l,drawingIds:g,arrangeType:c})};return f.jsxs("div",{className:U.clsx("univer-grid univer-gap-2 univer-py-2 univer-text-gray-400",{"univer-hidden":!r}),children:[f.jsx("header",{className:"univer-text-gray-600 dark:!univer-text-gray-200",children:f.jsx("div",{children:e.t("image-panel.arrange.title")})}),f.jsxs("div",{className:"univer-grid univer-grid-cols-2 univer-gap-2 univer-px-8",children:[f.jsxs(U.Button,{onClick:()=>{o(h.ArrangeTypeEnum.forward)},children:[f.jsx(xe,{}),e.t("image-panel.arrange.forward")]}),f.jsxs(U.Button,{onClick:()=>{o(h.ArrangeTypeEnum.backward)},children:[f.jsx(je,{}),e.t("image-panel.arrange.backward")]}),f.jsxs(U.Button,{onClick:()=>{o(h.ArrangeTypeEnum.front)},children:[f.jsx(Ae,{}),e.t("image-panel.arrange.front")]}),f.jsxs(U.Button,{onClick:()=>{o(h.ArrangeTypeEnum.back)},children:[f.jsx(Ne,{}),e.t("image-panel.arrange.back")]})]})]})},ct=i=>{const r=L.useDependency(h.LocaleService),t=L.useDependency(I.IRenderManagerService),e=L.useDependency(M.IDrawingManagerService),{hasGroup:n,drawings:a}=i,[s,o]=_.useState(!1),[c,u]=_.useState(!0),[l,g]=_.useState(!0),d=()=>{const m=e.getFocusDrawings(),{unitId:v,subUnitId:C}=m[0],y=h.Tools.generateRandomId(10),O=I.getGroupState(0,0,m.map(b=>b.transform||{})),N={unitId:v,subUnitId:C,drawingId:y,drawingType:h.DrawingTypeEnum.DRAWING_GROUP,transform:O},j=m.map(b=>{const T=b.transform||{left:0,top:0},{unitId:E,subUnitId:B,drawingId:P}=b;return{unitId:E,subUnitId:B,drawingId:P,transform:{...T,left:T.left-O.left,top:T.top-O.top},groupId:y}});e.featurePluginGroupUpdateNotification([{parent:N,children:j}])},p=m=>{if(m.drawingType!==h.DrawingTypeEnum.DRAWING_GROUP)return;const{unitId:v,subUnitId:C,drawingId:y,transform:O={width:0,height:0}}=m;if(O==null)return;const N=e.getDrawingsByGroup({unitId:v,subUnitId:C,drawingId:y});if(N.length===0)return;const j=N.map(b=>{const{transform:T}=b,{unitId:E,subUnitId:B,drawingId:P}=b,G=I.transformObjectOutOfGroup(T||{},O,O.width||0,O.height||0);return{unitId:E,subUnitId:B,drawingId:P,transform:{...T,...G},groupId:void 0}});return{parent:m,children:j}},S=()=>{const v=e.getFocusDrawings().map(C=>p(C)).filter(C=>C!=null);v.length!==0&&e.featurePluginUngroupUpdateNotification(v)};return _.useEffect(()=>{const m=a[0];if(m==null)return;const{unitId:v}=m,C=t.getRenderById(v),y=C==null?void 0:C.scene;if(y==null)return;const O=y.getTransformerByCreate(),N=O.clearControl$.subscribe(b=>{b===!0&&o(!1)}),j=O.changeStart$.subscribe(b=>{const{objects:T}=b,E=le(T,e),B=E.filter($=>($==null?void 0:$.drawingType)===h.DrawingTypeEnum.DRAWING_GROUP);let P=!1,G=!1;E.length>1&&(P=!0),B.length>0&&(G=!0),o(P||G),u(P),g(G)});return()=>{j.unsubscribe(),N.unsubscribe()}},[]),f.jsxs("div",{className:U.clsx("univer-grid univer-gap-2 univer-py-2 univer-text-gray-400",{"univer-hidden":n===!0&&s===!1||n===!1}),children:[f.jsx("header",{className:"univer-text-gray-600 dark:!univer-text-gray-200",children:f.jsx("div",{children:r.t("image-panel.group.title")})}),f.jsxs("div",{className:"univer-flex univer-items-center univer-justify-center univer-gap-2",children:[f.jsxs(U.Button,{className:U.clsx({"univer-hidden":!c}),onClick:d,children:[f.jsx(Ue,{}),r.t("image-panel.group.group")]}),f.jsxs(U.Button,{className:U.clsx({"univer-hidden":!l}),onClick:S,children:[f.jsx(Le,{}),r.t("image-panel.group.unGroup")]})]})]})},te=20,lt=20,ut=[-3600,3600],pe=300,gt=i=>{var $e;const r=L.useDependency(h.LocaleService),t=L.useDependency(M.IDrawingManagerService),e=L.useDependency(I.IRenderManagerService),{drawings:n,transformShow:a}=i,s=n[0];if(s==null)return;const o=s.transform;if(o==null)return;const{unitId:c,subUnitId:u,drawingId:l,drawingType:g}=s,d=e.getRenderById(c),p=d==null?void 0:d.scene;if(p==null)return;const S=($e=p.getEngine())==null?void 0:$e.activeScene;if(S==null)return;const m=p.getTransformerByCreate(),{width:v=0,height:C=0,left:y=0,top:O=0,angle:N=0}=o,[j,b]=_.useState(v),[T,E]=_.useState(C),[B,P]=_.useState(y),[G,H]=_.useState(O),[$,X]=_.useState(N),[oe,ne]=_.useState(m.keepRatio),ie=(w,x,V,W)=>{const{width:k,height:J}=S,{ancestorLeft:Z,ancestorTop:F}=p;let Y=w,ae=x,de=V,he=W;return w+Z<0&&(Y=-Z),x+F<0&&(ae=-F),de=k-Y-Z,de<te&&(de=te),he=J-ae-F,he<te&&(he=te),w+de+Z>k&&(Y=k-V-Z),x+he+F>J&&(ae=J-W-F),{limitLeft:Y,limitTop:ae,limitWidth:de,limitHeight:he}},ce=w=>{const{objects:x}=w,V=le(x,t);if(V.length!==1)return;const W=V[0];if(W==null)return;const{transform:k}=W;if(k==null)return;const{width:J,height:Z,left:F,top:Y,angle:ae}=k;J!=null&&b(J),Z!=null&&E(Z),F!=null&&P(F),Y!=null&&H(Y),ae!=null&&X(ae)};_.useEffect(()=>{const w=[m.changeStart$.subscribe(x=>{ce(x)}),m.changing$.subscribe(x=>{ce(x)}),m.changeEnd$.subscribe(x=>{ce(x)}),t.focus$.subscribe(x=>{if(x.length!==1)return;const V=t.getDrawingByParam(x[0]);if(V==null)return;const W=V.transform;if(W==null)return;const{width:k,height:J,left:Z,top:F,angle:Y}=W;k!=null&&b(k),J!=null&&E(J),Z!=null&&P(Z),F!=null&&H(F),Y!=null&&X(Y)})];return()=>{w.forEach(x=>x.unsubscribe())}},[]);const q=h.debounce(w=>{if(w==null)return;w=Math.max(w,te);const{limitWidth:x,limitHeight:V}=ie(B,G,w,T);w=Math.min(w,x);const W={unitId:c,subUnitId:u,drawingId:l,drawingType:g,transform:{width:w}};if(oe){let k=w/j*T;if(k=Math.max(k,lt),k>V)return;E(k),W.transform.height=k}b(w),t.featurePluginUpdateNotification([W]),m.refreshControls().changeNotification()},pe),De=h.debounce(w=>{if(w==null)return;w=Math.max(w,te);const{limitHeight:x,limitWidth:V}=ie(B,G,j,w);w=Math.min(w,x);const W={unitId:c,subUnitId:u,drawingId:l,drawingType:g,transform:{height:w}};if(oe){let k=w/T*j;if(k=Math.max(k,te),k>V)return;b(k),W.transform.width=k}E(w),t.featurePluginUpdateNotification([W]),m.refreshControls().changeNotification()},pe),Mt=h.debounce(w=>{if(w==null)return;const{limitLeft:x}=ie(w,G,j,T);w=x;const V={unitId:c,subUnitId:u,drawingId:l,drawingType:g,transform:{left:w}};P(w),t.featurePluginUpdateNotification([V]),m.refreshControls().changeNotification()},pe),Ot=h.debounce(w=>{if(w==null)return;const{limitTop:x}=ie(B,w,j,T);w=x;const V={unitId:c,subUnitId:u,drawingId:l,drawingType:g,transform:{top:w}};H(w),t.featurePluginUpdateNotification([V]),m.refreshControls().changeNotification()},pe),Et=w=>{if(w==null)return;const[x,V]=ut;w<x&&(w=x),w>V&&(w=V);const W={unitId:c,subUnitId:u,drawingId:l,drawingType:g,transform:{angle:w}};X(w),t.featurePluginUpdateNotification([W]),m.refreshControls().changeNotification()},Tt=w=>{ne(w),m.keepRatio=w};return f.jsxs("div",{className:U.clsx("univer-grid univer-gap-2 univer-py-2 univer-text-gray-400",{"univer-hidden":!a}),children:[f.jsx("header",{className:"univer-text-gray-600 dark:!univer-text-gray-200",children:f.jsx("div",{children:r.t("image-panel.transform.title")})}),f.jsxs("div",{className:"univer-grid univer-grid-cols-3 univer-gap-2 [&>div]:univer-grid [&>div]:univer-gap-2",children:[f.jsxs("div",{children:[f.jsx("span",{children:r.t("image-panel.transform.width")}),f.jsx(U.InputNumber,{precision:1,value:j,onChange:w=>{q(w)}})]}),f.jsxs("div",{children:[f.jsx("span",{children:r.t("image-panel.transform.height")}),f.jsx(U.InputNumber,{precision:1,value:T,onChange:w=>{De(w)}})]}),f.jsxs("div",{children:[f.jsx("span",{children:r.t("image-panel.transform.lock")}),f.jsx("div",{className:"univer-text-center",children:f.jsx(U.Checkbox,{checked:oe,onChange:Tt})})]})]}),f.jsxs("div",{className:"univer-grid univer-grid-cols-3 univer-gap-2 [&>div]:univer-grid [&>div]:univer-gap-2",children:[f.jsxs("div",{children:[f.jsx("span",{children:r.t("image-panel.transform.x")}),f.jsx(U.InputNumber,{precision:1,value:B,onChange:w=>{Mt(w)}})]}),f.jsxs("div",{children:[f.jsx("span",{children:r.t("image-panel.transform.y")}),f.jsx(U.InputNumber,{precision:1,value:G,onChange:w=>{Ot(w)}})]}),f.jsxs("div",{children:[f.jsx("span",{children:r.t("image-panel.transform.rotate")}),f.jsx(U.InputNumber,{precision:1,value:$,onChange:Et})]})]})]})},me={id:"sheet.operation.open-image-crop",type:h.CommandType.OPERATION,handler:(i,r)=>!0},ee={id:"sheet.operation.close-image-crop",type:h.CommandType.OPERATION,handler:(i,r)=>!0};var A=(i=>(i.FREE="0",i.R1_1="1",i.R16_9="2",i.R9_16="3",i.R5_4="4",i.R4_5="5",i.R4_3="6",i.R3_4="7",i.R3_2="8",i.R2_3="9",i))(A||{});const ue={id:"sheet.operation.Auto-image-crop",type:h.CommandType.OPERATION,handler:(i,r)=>!0},dt=i=>{const r=L.useDependency(h.ICommandService),t=L.useDependency(h.LocaleService),{drawings:e,cropperShow:n}=i;if(e[0]==null)return;const[s,o]=_.useState(A.FREE),c=_.useRef(!1),u=[{label:t.t("image-panel.crop.mode"),value:A.FREE},{label:"1:1",value:A.R1_1},{label:"16:9",value:A.R16_9},{label:"9:16",value:A.R9_16},{label:"5:4",value:A.R5_4},{label:"4:5",value:A.R4_5},{label:"4:3",value:A.R4_3},{label:"3:4",value:A.R3_4},{label:"3:2",value:A.R3_2},{label:"2:3",value:A.R2_3}];_.useEffect(()=>{const d=r.onCommandExecuted(p=>{if(p.id===ee.id){const S=p.params;S!=null&&S.isAuto||(c.current=!1)}});return()=>{d==null||d.dispose()}},[]);function l(d){o(d),c.current&&r.executeCommand(ue.id,{cropType:d})}const g=d=>{r.executeCommand(ue.id,{cropType:d}),c.current=!0};return f.jsxs("div",{className:U.clsx("univer-grid univer-gap-2 univer-py-2 univer-text-gray-400",{"univer-hidden":!n}),children:[f.jsx("header",{className:"univer-text-gray-600 dark:!univer-text-gray-200",children:f.jsx("div",{children:t.t("image-panel.crop.title")})}),f.jsxs("div",{className:"univer-flex univer-items-center univer-justify-center univer-gap-2",children:[f.jsxs(U.Button,{onClick:()=>{g(s)},children:[f.jsx(Be,{}),t.t("image-panel.crop.start")]}),f.jsx(U.Select,{value:s,options:u,onChange:l})]})]})},ht=i=>{const r=L.useDependency(M.IDrawingManagerService),t=L.useDependency(I.IRenderManagerService),e=L.useDependency(h.LocaleService),{drawings:n,hasArrange:a=!0,hasTransform:s=!0,hasAlign:o=!0,hasCropper:c=!0,hasGroup:u=!0}=i,l=n[0];if(l==null)return;const{unitId:g}=l,d=t.getRenderById(g),p=d==null?void 0:d.scene;if(p==null)return;const S=p.getTransformerByCreate(),[m,v]=_.useState(!0),[C,y]=_.useState(!0),[O,N]=_.useState(!1),[j,b]=_.useState(!0),[T,E]=_.useState(!1);return _.useEffect(()=>{const B=S.clearControl$.subscribe(H=>{H===!0&&(v(!1),y(!1),N(!1),b(!1),E(!0))}),P=S.changeStart$.subscribe(H=>{const{objects:$}=H,X=le($,r);X.length===0?(v(!1),y(!1),N(!1),b(!1),E(!0)):X.length===1?(v(!0),y(!0),N(!1),b(!0),E(!1)):(v(!0),y(!1),N(!0),b(!1),E(!1))}),G=r.focus$.subscribe(H=>{H.length===0?(v(!1),y(!1),N(!1),b(!1),E(!0)):H.length===1?(v(!0),y(!0),N(!1),b(!0),E(!1)):(v(!0),y(!1),N(!0),b(!1),E(!1))});return()=>{P.unsubscribe(),B.unsubscribe(),G.unsubscribe()}},[]),f.jsxs(f.Fragment,{children:[f.jsx("div",{className:U.clsx("univer-h-full",{"univer-hidden":!T}),children:f.jsx("div",{className:"univer-flex univer-h-full univer-items-center univer-justify-center",children:f.jsx("span",{children:e.t("image-panel.null")})})}),f.jsx(ot,{arrangeShow:a===!0?m:!1,drawings:n}),f.jsx(gt,{transformShow:s===!0?C:!1,drawings:n}),f.jsx(Fe,{alignShow:o===!0?O:!1,drawings:n}),f.jsx(dt,{cropperShow:c===!0?j:!1,drawings:n}),f.jsx(ct,{hasGroup:u,drawings:n})]})};function He(i){var m;const{popup:r}=i,t=(m=r==null?void 0:r.extraProps)==null?void 0:m.menuItems;if(!t)return null;const e=L.useDependency(h.ICommandService),n=L.useDependency(h.LocaleService),[a,s]=_.useState(!1),[o,c]=_.useState(!1),u=()=>{c(!0)},l=()=>{c(!1)},g=v=>{s(v)},d=v=>{e.executeCommand(v.commandId,v.commandParams),s(!1)},p=a||o,S=t.filter(v=>!v.disable);return f.jsx("div",{onMouseEnter:u,onMouseLeave:l,children:f.jsx(U.DropdownMenu,{align:"start",items:S.map(v=>({type:"item",children:n.t(v.label),onSelect:()=>d(v)})),open:a,onOpenChange:g,children:f.jsxs("div",{className:U.clsx("univer-flex univer-items-center univer-gap-2 univer-rounded univer-p-1 dark:hover:!univer-bg-gray-800 hover:univer-bg-gray-100",U.borderClassName,{"univer-bg-gray-100 dark:!univer-bg-gray-800":a,"univer-bg-white dark:!univer-bg-gray-900":!a}),children:[f.jsx(Pe,{className:"univer-fill-primary-600 univer-text-gray-900 dark:!univer-text-white"}),p&&f.jsx(Re,{className:"dark:!univer-text-white"})]})})})}const ke="COMPONENT_IMAGE_POPUP_MENU",ft="drawing-ui.config",Ge={},Ie={id:"sheet.operation.image-reset-size",type:h.CommandType.OPERATION,handler:(i,r)=>!0};var pt=Object.getOwnPropertyDescriptor,mt=(i,r,t,e)=>{for(var n=e>1?void 0:e?pt(r,t):r,a=i.length-1,s;a>=0;a--)(s=i[a])&&(n=s(n)||n);return n},Ve=(i,r)=>(t,e)=>r(t,e,i);let ve=class extends h.Disposable{constructor(i,r){super(),this._componentManager=i,this._commandService=r,this._init()}_initCustomComponents(){const i=this._componentManager;this.disposeWithMe(i.register(ke,He))}_initCommands(){[me,ee,Ie,fe,ue].forEach(i=>this.disposeWithMe(this._commandService.registerCommand(i)))}_init(){this._initCommands(),this._initCustomComponents()}};ve=mt([Ve(0,h.Inject(L.ComponentManager)),Ve(1,h.ICommandService)],ve);var vt=Object.getOwnPropertyDescriptor,wt=(i,r,t,e)=>{for(var n=e>1?void 0:e?vt(r,t):r,a=i.length-1,s;a>=0;a--)(s=i[a])&&(n=s(n)||n);return n},we=(i,r)=>(t,e)=>r(t,e,i);let Se=class extends h.Disposable{constructor(r,t,e,n){super();Q(this,"_sceneListenerOnDrawingMap",new WeakSet);this._currentUniverService=r,this._commandService=t,this._renderManagerService=e,this._drawingManagerService=n,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 r=this._drawingManagerService.drawingManagerData,t=Ee(this._currentUniverService);if(t==null)return;const{unitId:e,subUnitId:n}=t;Object.keys(r).forEach(a=>{Object.keys(r[a]).forEach(s=>{const o=r[a][s].data;o==null||a!==e||s!==n||Object.keys(o).forEach(c=>{o[c]&&this._insertDrawing([{unitId:a,subUnitId:s,drawingId:c}])})})})}_commandExecutedListener(){this.disposeWithMe(this._commandService.onCommandExecuted(r=>{if(r.id===fe.id){const t=r.params;if(t==null)return;this._drawingAlign(t)}}))}_drawingGroupListener(){this.disposeWithMe(this._drawingManagerService.group$.subscribe(r=>{this._groupDrawings(r)})),this.disposeWithMe(this._drawingManagerService.ungroup$.subscribe(r=>{this._ungroupDrawings(r)}))}_getSceneAndTransformerByDrawingSearch(r){if(r==null)return;const t=this._renderManagerService.getRenderById(r),e=t==null?void 0:t.scene;if(e==null)return null;const n=e.getTransformerByCreate();return{scene:e,transformer:n}}_groupDrawings(r){r.forEach(t=>{this._groupDrawing(t)})}_groupDrawing(r){const{parent:t,children:e}=r,{unitId:n,subUnitId:a,drawingId:s}=t,o=this._getSceneAndTransformerByDrawingSearch(t.unitId);if(o==null)return;const{scene:c,transformer:u}=o;this._commandService.syncExecuteCommand(ee.id);const l=[];if(e.forEach(p=>{const S=M.getDrawingShapeKeyByDrawingSearch(p),m=c.getObjectIncludeInGroup(S);if(m==null||l.includes(m))return;l.push(m);const{transform:v}=p;v!=null&&(m.classType===I.RENDER_CLASS_TYPE.GROUP?m.transformByState({left:v.left,top:v.top}):m.transformByState(v))}),l.length===0)return;const g=M.getDrawingShapeKeyByDrawingSearch({unitId:n,subUnitId:a,drawingId:s}),d=new I.Group(g);c.addObject(d,I.DRAWING_OBJECT_LAYER_INDEX).attachTransformerTo(d),d.addObjects(...l),t.transform&&d.transformByState({left:t.transform.left,top:t.transform.top}),u.clearSelectedObjects(),u.setSelectedControl(d)}_ungroupDrawings(r){r.forEach(t=>{this._ungroupDrawing(t)})}_ungroupDrawing(r){const{parent:t,children:e}=r,n=this._getSceneAndTransformerByDrawingSearch(t.unitId);if(n==null)return;const{scene:a,transformer:s}=n;e.forEach(g=>{const d=M.getDrawingShapeKeyByDrawingSearch(g),p=a.getObjectIncludeInGroup(d);if(p==null)return!0;if(p==null)return;const{transform:S}=g;S!=null&&(p.classType===I.RENDER_CLASS_TYPE.GROUP?p.transformByState({left:S.left,top:S.top}):p.transformByState(S))});const o=M.getDrawingShapeKeyByDrawingSearch(t),c=a.getObject(o),{width:u,height:l}=c;c.getObjects().forEach(g=>{c.removeSelfObjectAndTransform(g.oKey,u,l)}),c.dispose(),s.clearSelectedObjects()}_drawingAlign(r){const{alignType:t}=r,e=this._drawingManagerService.getFocusDrawings();if(t===R.default)return;const n=[];let a=Number.POSITIVE_INFINITY,s=Number.POSITIVE_INFINITY,o=Number.NEGATIVE_INFINITY,c=Number.NEGATIVE_INFINITY,u=0;e.forEach(l=>{const{unitId:g,subUnitId:d,drawingId:p,drawingType:S}=l,m=this._drawingManagerService.getDrawingByParam({unitId:g,subUnitId:d,drawingId:p});if(m==null||m.transform==null)return;n.push({unitId:g,subUnitId:d,drawingId:p,drawingType:S,transform:m.transform});const{left:v=0,top:C=0,width:y=0,height:O=0}=m.transform;a=Math.min(a,v),s=Math.min(s,C),o=Math.max(o,v+y),c=Math.max(c,C+O),u++}),u!==0&&(this._sortDrawingTransform(n,t),this._applyAlignType(n,t,a,s,o,c,u))}_applyAlignType(r,t,e,n,a,s,o){const c=Math.round((a-e)/o*10)/10,u=Math.round((s-n)/o*10)/10,l=[],g=this._getSceneAndTransformerByDrawingSearch(r[0].unitId);if(g==null)return;const{scene:d,transformer:p}=g;r.forEach((S,m)=>{const{unitId:v,subUnitId:C,drawingId:y,transform:O,drawingType:N}=S,{left:j=0,top:b=0,width:T=0,height:E=0}=O;let B=j,P=b;switch(t){case R.left:B=e;break;case R.center:B=e+(a-e)/2-T/2;break;case R.right:B=a-T;break;case R.top:P=n;break;case R.middle:P=n+(s-n)/2-E/2;break;case R.bottom:P=s-E;break;case R.horizon:B=e+c*m;break;case R.vertical:P=n+u*m;break}(B!==j||P!==b)&&l.push({unitId:v,subUnitId:C,drawingId:y,drawingType:N,transform:{left:B,top:P}})}),this._drawingManagerService.featurePluginUpdateNotification(l),p.refreshControls().changeNotification()}_sortDrawingTransform(r,t){r.sort((e,n)=>{const a=e.transform,s=n.transform,{left:o=0,top:c=0,width:u=0,height:l=0}=a,{left:g=0,top:d=0,width:p=0,height:S=0}=s;switch(t){case R.left:return o-g;case R.center:return o+u/2-(g+p/2);case R.right:return o+u-(g+p);case R.top:return c-d;case R.middle:return c+l/2-(d+S/2);case R.bottom:return c+l-(d+S);case R.horizon:return o+u/2-(g+p/2);case R.vertical:return c+l/2-(d+S/2);default:return 0}})}_drawingArrangeListener(){this.disposeWithMe(this._drawingManagerService.order$.subscribe(r=>{this._drawingArrange(r)}))}_drawingArrange(r){const{unitId:t,subUnitId:e,drawingIds:n}=r,a=this._getSceneAndTransformerByDrawingSearch(t);if(a==null)return;const{scene:s}=a;n.forEach(o=>{const c=M.getDrawingShapeKeyByDrawingSearch({unitId:t,subUnitId:e,drawingId:o}),u=s.fuzzyMathObjects(c,!0);if(u==null||u.length===0)return;const l=this._drawingManagerService.getDrawingOrder(t,e).indexOf(o);for(const g of u)g.setProps({zIndex:l}),g.makeDirty()})}_drawingAddListener(){this.disposeWithMe(this._drawingManagerService.add$.subscribe(r=>{this._insertDrawing(r)}))}_insertDrawing(r){const t=[];r.forEach(e=>{const{unitId:n}=e;if(this._drawingManagerService.getDrawingByParam(e)==null)return;const s=this._getSceneAndTransformerByDrawingSearch(n);if(s==null)return;const{scene:o}=s;t.includes(o)||t.push(o)}),t.forEach(e=>{this._sceneListenerOnDrawingMap.has(e)||(this._addListenerOnDrawing(e),this._sceneListenerOnDrawingMap.add(e))})}_drawingRemoveListener(){this.disposeWithMe(this._drawingManagerService.remove$.subscribe(r=>{r.forEach(t=>{var l;const{unitId:e,subUnitId:n,drawingId:a}=t,s=this._getSceneAndTransformerByDrawingSearch(e);if(s==null)return;const{scene:o}=s,c=M.getDrawingShapeKeyByDrawingSearch({unitId:e,subUnitId:n,drawingId:a}),u=o.fuzzyMathObjects(c,!0);if(u.length>0){for(const g of u)g.dispose();(l=o.getTransformer())==null||l.clearSelectedObjects()}})}))}_drawingUpdateListener(){this.disposeWithMe(this._drawingManagerService.update$.subscribe(r=>{r.forEach(t=>{var T;const{unitId:e,subUnitId:n,drawingId:a}=t,s=this._drawingManagerService.getDrawingByParam(t);if(s==null)return;const{transform:o,drawingType:c}=s,u=this._getSceneAndTransformerByDrawingSearch(e);if(u==null)return;const{scene:l,transformer:g}=u;if(o==null)return!0;const{left:d=0,top:p=0,width:S=0,height:m=0,angle:v=0,flipX:C=!1,flipY:y=!1,skewX:O=0,skewY:N=0}=o,j=M.getDrawingShapeKeyByDrawingSearch({unitId:e,subUnitId:n,drawingId:a}),b=l.getObject(j);if(b==null)return!0;b.transformByState({left:d,top:p,width:S,height:m,angle:v,flipX:C,flipY:y,skewX:O,skewY:N}),(T=l.getTransformer())==null||T.debounceRefreshControls()})}))}_drawingRefreshListener(){this.disposeWithMe(this._drawingManagerService.refreshTransform$.subscribe(r=>{r.forEach(t=>{const{unitId:e,subUnitId:n,drawingId:a}=t,s=this._getSceneAndTransformerByDrawingSearch(e);if(s==null)return;const o=this._drawingManagerService.getDrawingByParam(t);if(o==null)return;const{transform:c}=o,{scene:u}=s,l=M.getDrawingShapeKeyByDrawingSearch({unitId:e,subUnitId:n,drawingId:a}),g=u.getObject(l);if(g==null||c==null)return!0;const{left:d=0,top:p=0,width:S=0,height:m=0,angle:v=0,flipX:C=!1,flipY:y=!1,skewX:O=0,skewY:N=0}=c;g.transformByState({left:d,top:p,width:S,height:m,angle:v,flipX:C,flipY:y,skewX:O,skewY:N})})}))}_drawingVisibleListener(){this.disposeWithMe(this._drawingManagerService.visible$.subscribe(r=>{r.forEach(t=>{const{unitId:e,subUnitId:n,drawingId:a,visible:s}=t,o=this._getSceneAndTransformerByDrawingSearch(e);if(o==null)return;const{scene:c}=o,u=M.getDrawingShapeKeyByDrawingSearch({unitId:e,subUnitId:n,drawingId:a}),l=c.getObject(u);if(l==null)return!0;s?l.show():l.hide()})}))}_filterUpdateParams(r,t){return r.filter((e,n)=>{if(e==null)return!1;const{transform:a}=e;return h.checkIfMove(a,t==null?void 0:t[n])})}_addListenerOnDrawing(r){const t=r.getTransformerByCreate();let e=null;this.disposeWithMe(h.toDisposable(t.changeStart$.subscribe(n=>{const{objects:a}=n,s=Array.from(a.values()),o=[];e=s.map(c=>{const{left:u,top:l,height:g,width:d,angle:p,oKey:S,isInGroup:m}=c,v=this._drawingManagerService.getDrawingOKey(S);if(m||c instanceof I.Group){let C=c.ancestorGroup;if(C==null&&c instanceof I.Group&&(C=c),C==null)return null;const y=this._drawingManagerService.getDrawingOKey(C.oKey);if(y){const{unitId:O,subUnitId:N,drawingId:j}=y;o.push({unitId:O,subUnitId:N,drawingId:j});const{left:b,top:T,height:E,width:B,angle:P}=C;return{left:b,top:T,height:E,width:B,angle:P}}}else if(v!=null){const{unitId:C,subUnitId:y,drawingId:O}=v;return o.push({unitId:C,subUnitId:y,drawingId:O}),{left:u,top:l,height:g,width:d,angle:p}}return null}).filter(c=>c!=null),o.length>0?this._commandService.syncExecuteCommand(M.SetDrawingSelectedOperation.id,o):this._commandService.syncExecuteCommand(M.SetDrawingSelectedOperation.id,[])}))),this.disposeWithMe(h.toDisposable(t.changeEnd$.subscribe(n=>{const{objects:a}=n,s=this._filterUpdateParams(le(a,this._drawingManagerService),e);s.length>0&&this._drawingManagerService.featurePluginUpdateNotification(s)})))}};Se=wt([we(0,h.IUniverInstanceService),we(1,h.ICommandService),we(2,I.IRenderManagerService),we(3,M.IDrawingManagerService)],Se);class ge extends I.Shape{constructor(t,e){e==null&&(e={}),e.transformerConfig={keepRatio:!1,isCropper:!0,anchorFill:"rgb(0, 0, 0)",anchorStroke:"rgb(255, 255, 255)",anchorSize:24};super(t,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(t,e){this._srcRect=t,this._applyTransform=e,this._applyProps()}get srcRect(){return this._srcRect}dispose(){var t;super.dispose(),(t=this._cacheCanvas)==null||t.dispose(),this._srcRect=null}isHit(t){const e=this.getInverseCoord(t);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(t){const e=this._dragPadding;return t.x>=e-this.strokeWidth/2&&t.x<=this.width+this.strokeWidth/2-e&&t.y>=e-this.strokeWidth/2&&t.y<=this.height+this.strokeWidth/2-e}render(t,e){return this.visible?(t.save(),this._draw(t),t.restore(),this.makeDirty(!1),this):(this.makeDirty(!1),this)}_draw(t){var c,u;const n=this.getScene().getEngine(),{width:a,height:s}=n;this._initialCacheCanvas(),(c=this._cacheCanvas)==null||c.clear();const o=(u=this._cacheCanvas)==null?void 0:u.getContext();o!=null&&(o.save(),I.Rect.drawWith(o,{left:0,top:0,width:a,height:s,fill:"rgba(0, 0, 0, 0.5)"}),o.setTransform(t.getTransform()),this._clipForApplyObject(o),this._applyCache(t),o.restore())}_clipForApplyObject(t){let e=0;if(this._prstGeom!=null&&(e=1),t.globalCompositeOperation="destination-out",t.beginPath(),e===0){const n=this.transform.getMatrix();t.transform(n[0],n[1],n[2],n[3],n[4],n[5]),t.rect(0,0,this.width,this.height),t.fill()}}_applyProps(){if(this._applyTransform==null)return;let t=0,e=0,n=0,a=0;const{left:s=0,top:o=0,width:c=0,height:u=0,angle:l}=this._applyTransform;if(this._srcRect!=null){const{left:p=0,top:S=0,right:m=0,bottom:v=0}=this._srcRect;t=p,e=S,n=m,a=v}const g=s+t,d=o+e;this.transformByState({left:g,top:d,width:s+c-n-g,height:o+u-a-d,angle:l})}_applyCache(t){if(!t||this._cacheCanvas==null)return;const e=this._cacheCanvas.getContext();e.save(),t.save(),t.setTransform(1,0,0,1,0,0),e.setTransform(1,0,0,1,0,0),t.drawImage(this._cacheCanvas.getCanvasEle(),0,0),t.restore(),e.restore()}_initialCacheCanvas(){if(this._cacheCanvas!=null)return;const t=this.getScene();if(t==null)return;this._cacheCanvas=new I.Canvas;const e=t.getEngine();this._cacheCanvas.setSize(e.width,e.height),e.onTransformChange$.subscribeEvent(()=>{var n;(n=this._cacheCanvas)==null||n.setSize(e.width,e.height),this.makeDirty(!0)})}}var St=Object.getOwnPropertyDescriptor,_t=(i,r,t,e)=>{for(var n=e>1?void 0:e?St(r,t):r,a=i.length-1,s;a>=0;a--)(s=i[a])&&(n=s(n)||n);return n},se=(i,r)=>(t,e)=>r(t,e,i);let _e=class extends h.Disposable{constructor(r,t,e,n,a,s){super();Q(this,"_sceneListenerOnImageMap",new WeakSet);this._commandService=r,this._drawingManagerService=t,this._renderManagerService=e,this._univerInstanceService=n,this._messageService=a,this._localeService=s,this._init()}_init(){this._initOpenCrop(),this._initCloseCrop(),this._initAutoCrop()}_initAutoCrop(){this.disposeWithMe(this._commandService.onCommandExecuted(r=>{if(r.id!==ue.id)return;const t=r.params;if(t==null)return;const{cropType:e}=t,n=this._drawingManagerService.getFocusDrawings();if(n.length!==1)return;const a=n[0],{unitId:s,subUnitId:o,drawingId:c}=a,u=this._renderManagerService.getRenderById(s),l=u==null?void 0:u.scene;if(l==null)return!0;this._searchCropObject(l)!=null&&this._commandService.syncExecuteCommand(ee.id,{isAuto:!0});const d=M.getDrawingShapeKeyByDrawingSearch({unitId:s,subUnitId:o,drawingId:c}),p=l.getObject(d);if(!(p instanceof I.Image)){this._messageService.show({type:U.MessageType.Error,content:this._localeService.t("image-cropper.error")});return}p!=null&&(this._updateCropperObject(e,p),this._commandService.executeCommand(me.id,{unitId:s,subUnitId:o,drawingId:c}))}))}_calculateSrcRectByRatio(r,t,e,n,a,s){const o=e/n,c=a/s;let u=e,l=n;o>c?u=n*c:l=e/c;const g=(e-u)/2,d=(n-l)/2;return{left:I.precisionTo(g,1),top:I.precisionTo(d,1),right:I.precisionTo(e-(g+u),1),bottom:I.precisionTo(n-(d+l),1)}}_updateCropperObject(r,t){const{left:e,top:n,width:a,height:s}=t.calculateTransformWithSrcRect();let o;switch(r){case A.R1_1:o=this._calculateSrcRectByRatio(e,n,a,s,1,1);break;case A.R16_9:o=this._calculateSrcRectByRatio(e,n,a,s,16,9);break;case A.R9_16:o=this._calculateSrcRectByRatio(e,n,a,s,9,16);break;case A.R5_4:o=this._calculateSrcRectByRatio(e,n,a,s,5,4);break;case A.R4_5:o=this._calculateSrcRectByRatio(e,n,a,s,4,5);break;case A.R4_3:o=this._calculateSrcRectByRatio(e,n,a,s,4,3);break;case A.R3_4:o=this._calculateSrcRectByRatio(e,n,a,s,3,4);break;case A.R3_2:o=this._calculateSrcRectByRatio(e,n,a,s,3,2);break;case A.R2_3:o=this._calculateSrcRectByRatio(e,n,a,s,2,3);break;case A.FREE:}if(o==null)return;t.setSrcRect(o);const{left:c=0,top:u=0,bottom:l=0,right:g=0}=o;t.transformByStateCloseCropper({left:e+c,top:n+u,width:a-g-c,height:s-l-u})}_initOpenCrop(){this.disposeWithMe(this._commandService.onCommandExecuted(r=>{if(r.id!==me.id)return;const t=r.params;if(t==null)return;const{unitId:e,subUnitId:n,drawingId:a}=t,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:n,drawingId:a})==null)return;const u=M.getDrawingShapeKeyByDrawingSearch({unitId:e,subUnitId:n,drawingId:a}),l=o.getObject(u);if(l==null)return;if(!(l instanceof I.Image)){this._messageService.show({type:U.MessageType.Error,content:this._localeService.t("image-cropper.error")});return}const g=o.getTransformer();g==null||g.clearControls();const d=new ge(`${u}-crop`,{srcRect:l.srcRect,prstGeom:l.prstGeom,applyTransform:l.calculateTransformWithSrcRect()});o.addObject(d,l.getLayerIndex()+1).attachTransformerTo(d),g==null||g.createControlForCopper(d),this._addHoverForImageCopper(d),l.openRenderByCropper(),g==null||g.refreshControls(),d.makeDirty(!0),this._commandService.syncExecuteCommand(M.SetDrawingSelectedOperation.id,[{unitId:e,subUnitId:n,drawingId:a}])}))}_searchCropObject(r){const t=r.getAllObjectsByOrder();for(const e of t)if(e instanceof ge)return e}_initCloseCrop(){this.disposeWithMe(this._commandService.onCommandExecuted(t=>{if(t.id!==ee.id)return;const e=this._univerInstanceService.getFocusedUnit();if(e==null)return;const n=e.getUnitId(),a=this._renderManagerService.getRenderById(n),s=a==null?void 0:a.scene;if(s==null)return!0;const o=this._searchCropObject(s);if(o==null)return;const c=this._getApplyObjectByCropObject(o);if(c==null)return;const u=s.getTransformerByCreate();u.detachFrom(o),u.clearCopperControl();const l=this._getSrcRectByTransformState(c,o),g=this._drawingManagerService.getDrawingOKey(c.oKey);if(g!=null){const{left:d,top:p,height:S,width:m}=o;this._drawingManagerService.featurePluginUpdateNotification([{...g,transform:{...g.transform,left:d,top:p,height:S,width:m},srcRect:l.srcRectAngle}])}c.setSrcRect({...l.srcRectAngle}),c.closeRenderByCropper(),c.makeDirty(!0),o==null||o.dispose()}));const r=this._univerInstanceService.getCurrentTypeOfUnit$(h.UniverInstanceType.UNIVER_SHEET).pipe(Me.switchMap(t=>t?t.activeSheet$:Me.of(null)));this.disposeWithMe(r.subscribe(()=>{this._commandService.syncExecuteCommand(ee.id)}))}_getApplyObjectByCropObject(r){const t=r.oKey,e=t.slice(0,t.length-5),n=r.getScene();if(!n)return null;const a=n.getObject(e);return a==null?null:a}_addListenerOnImage(r){const t=r.getTransformerByCreate();let e=null;this.disposeWithMe(t.changeStart$.subscribe(n=>{const{objects:a}=n,s=a.values().next().value;if(s==null||!(s instanceof ge))return;const{left:o,top:c,height:u,width:l,angle:g}=s;e={left:o,top:c,height:u,width:l,angle:g},t.clearCopperControl()})),this.disposeWithMe(t.changeEnd$.subscribe(n=>{const{objects:a}=n,s=a.values().next().value;if(s==null||!(s instanceof ge))return;const{left:o,top:c,height:u,width:l,angle:g}=s;if(!h.checkIfMove({left:o,top:c,height:u,width:l,angle:g},e))return;const d=this._getApplyObjectByCropObject(s);if(d==null)return;const p=this._getSrcRectByTransformState(d,s);s.refreshSrcRect(p.srcRect,d.getState()),t.createControlForCopper(s)})),this._endCropListener(r)}_addHoverForImageCopper(r){this.disposeWithMe(r.onPointerEnter$.subscribeEvent(()=>{r.cursor=I.CURSOR_TYPE.MOVE})),this.disposeWithMe(r.onPointerLeave$.subscribeEvent(()=>{r.cursor=I.CURSOR_TYPE.DEFAULT}))}_endCropListener(r){const t=r.getTransformerByCreate();this.disposeWithMe(t.clearControl$.subscribe(e=>{e===!0&&this._commandService.syncExecuteCommand(ee.id)}))}_getSrcRectByTransformState(r,t){const{left:e,top:n,height:a,width:s,strokeWidth:o,angle:c}=t,{left:u,top:l,width:g,height:d,angle:p,strokeWidth:S}=r,m=e-u,v=n-l,C={left:m,top:v,right:g-m-s,bottom:d-v-a},y={...C};if(p!==0){const O=e+s/2,N=n+a/2,j=new I.Vector2(O,N),b=g/2+u,T=d/2+l,E=new I.Vector2(b,T),B=new I.Vector2(u,l);B.rotateByPoint(I.degToRad(p),E);const P=B.clone();P.rotateByPoint(I.degToRad(-p),j);const G=e-P.x,H=n-P.y;y.left=G,y.top=H,y.right=g-G-s,y.bottom=d-H-a}return{srcRect:C,srcRectAngle:y}}};_e=_t([se(0,h.ICommandService),se(1,M.IDrawingManagerService),se(2,I.IRenderManagerService),se(3,h.IUniverInstanceService),se(4,L.IMessageService),se(5,h.Inject(h.LocaleService))],_e);var Ct=Object.getOwnPropertyDescriptor,yt=(i,r,t,e)=>{for(var n=e>1?void 0:e?Ct(r,t):r,a=i.length-1,s;a>=0;a--)(s=i[a])&&(n=s(n)||n);return n},re=(i,r)=>(t,e)=>r(t,e,i);let Ce=class extends h.Disposable{constructor(i,r,t,e,n,a,s){super(),this._commandService=i,this._renderManagerService=r,this._drawingManagerService=t,this._dialogService=e,this._imageIoService=n,this._currentUniverService=a,this._drawingRenderService=s,this._initialize()}dispose(){super.dispose()}_initialize(){this._drawingAddListener(),this._commandExecutedListener(),this._imageUpdateListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.onCommandExecuted(i=>{if(i.id===Ie.id){const r=i.params;if(r==null)return;this._resetImageSize(r)}}))}_getSceneAndTransformerByDrawingSearch(i){if(i==null)return;const r=this._renderManagerService.getRenderById(i),t=r==null?void 0:r.scene;if(t==null)return null;const e=t.getTransformerByCreate();return{scene:t,transformer:e}}_resetImageSize(i){const r=[],t=[];i.forEach(e=>{const{unitId:n,subUnitId:a,drawingId:s}=e,o=this._getSceneAndTransformerByDrawingSearch(n);if(o==null)return;const{scene:c}=o,u=M.getDrawingShapeKeyByDrawingSearch({unitId:n,subUnitId:a,drawingId:s}),l=c.getObject(u);if(l==null)return!0;const g=this._drawingManagerService.getDrawingByParam(e);if(g==null)return!0;if(g.drawingType!==h.DrawingTypeEnum.DRAWING_IMAGE)return;l.resetSize();const{width:d,height:p}=l.getNativeSize();t.includes(c)===!1&&t.push(c),r.push({...g,transform:{...g.transform,height:p,width:d,angle:0},srcRect:null,prstGeom:null})}),this._drawingManagerService.featurePluginUpdateNotification(r),t.forEach(e=>{e.getTransformerByCreate().refreshControls().changeNotification()}),this._commandService.syncExecuteCommand(M.SetDrawingSelectedOperation.id,i)}_drawingAddListener(){this.disposeWithMe(this._drawingManagerService.add$.subscribe(i=>{this._insertImages(i)}))}_insertImages(i){i.forEach(async r=>{var c;const{unitId:t,subUnitId:e}=r,n=this._getSceneAndTransformerByDrawingSearch(t),a=(c=Ee(this._currentUniverService,t))==null?void 0:c.subUnitId;if(n==null||a!==e)return;const s=this._drawingManagerService.getDrawingByParam(r);if(s==null)return;const o=await this._drawingRenderService.renderImages(s,n.scene);if(this._drawingManagerService.refreshTransform([s]),!(o==null||o.length===0))for(const u of o)this._addHoverForImage(u),this._addDialogForImage(u)})}_imageUpdateListener(){this.disposeWithMe(this._drawingManagerService.update$.subscribe(i=>{i.forEach(r=>{const{unitId:t,subUnitId:e,drawingId:n}=r,a=this._drawingManagerService.getDrawingByParam(r);if(a==null)return;const{transform:s,drawingType:o,srcRect:c,prstGeom:u,source:l,imageSourceType:g}=a;if(o!==h.DrawingTypeEnum.DRAWING_IMAGE)return;const d=this._getSceneAndTransformerByDrawingSearch(t);if(d==null)return;const{scene:p,transformer:S}=d;if(s==null)return!0;const m=M.getDrawingShapeKeyByDrawingSearch({unitId:t,subUnitId:e,drawingId:n}),v=p.getObject(m);if(v==null)return!0;v.setSrcRect(c),v.setPrstGeom(u),l!=null&&l.length>0&&(g===h.ImageSourceType.BASE64||g===h.ImageSourceType.URL)&&v.changeSource(l)})}))}_addHoverForImage(i){this.disposeWithMe(h.toDisposable(i.onPointerEnter$.subscribeEvent(()=>{i.cursor=I.CURSOR_TYPE.GRAB}))),this.disposeWithMe(h.toDisposable(i.onPointerLeave$.subscribeEvent(()=>{i.cursor=I.CURSOR_TYPE.DEFAULT})))}_addDialogForImage(i){this.disposeWithMe(h.toDisposable(i.onDblclick$.subscribeEvent(()=>{const r=`${i.oKey}-viewer-dialog`;this._drawingRenderService.previewImage(r,i.getNative().src,i.getNativeSize().width,i.getNativeSize().height)})))}};Ce=yt([re(0,h.ICommandService),re(1,I.IRenderManagerService),re(2,M.IDrawingManagerService),re(3,L.IDialogService),re(4,M.IImageIoService),re(5,h.IUniverInstanceService),re(6,h.Inject(D.DrawingRenderService))],Ce);var It=Object.getOwnPropertyDescriptor,bt=(i,r,t,e)=>{for(var n=e>1?void 0:e?It(r,t):r,a=i.length-1,s;a>=0;a--)(s=i[a])&&(n=s(n)||n);return n},We=(i,r)=>(t,e)=>r(t,e,i);const Dt="UNIVER_DRAWING_UI_PLUGIN";D.UniverDrawingUIPlugin=(be=class extends h.Plugin{constructor(r=Ge,t,e){super(),this._config=r,this._injector=t,this._configService=e;const{menu:n,...a}=h.merge({},Ge,this._config);n&&this._configService.setConfig("menu",n,{merge:!0}),this._configService.setConfig(ft,a)}onStarting(){this._initDependencies()}onRendered(){this._injector.get(Se),this._injector.get(ve),this._injector.get(_e),this._injector.get(Ce)}_initDependencies(){[[D.DrawingRenderService],[Se],[ve],[_e],[Ce]].forEach(t=>this._injector.add(t))}},Q(be,"pluginName",Dt),be),D.UniverDrawingUIPlugin=bt([We(1,h.Inject(h.Injector)),We(2,h.IConfigService)],D.UniverDrawingUIPlugin),D.AutoImageCropOperation=ue,D.COMPONENT_IMAGE_POPUP_MENU=ke,D.CloseImageCropOperation=ee,D.DrawingCommonPanel=ht,D.ImageCropperObject=ge,D.ImagePopupMenu=He,D.ImageResetSizeOperation=Ie,D.OpenImageCropOperation=me,D.SetDrawingAlignOperation=fe,D.getUpdateParams=le,Object.defineProperty(D,Symbol.toStringTag,{value:"Module"})});
|
|
1
|
+
(function(D,h){typeof exports=="object"&&typeof module<"u"?h(exports,require("@univerjs/core"),require("@univerjs/drawing"),require("@univerjs/engine-render"),require("@univerjs/ui"),require("react/jsx-runtime"),require("@univerjs/design"),require("react"),require("rxjs")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/drawing","@univerjs/engine-render","@univerjs/ui","react/jsx-runtime","@univerjs/design","react","rxjs"],h):(D=typeof globalThis<"u"?globalThis:D||self,h(D.UniverDrawingUi={},D.UniverCore,D.UniverDrawing,D.UniverEngineRender,D.UniverUi,D.React,D.UniverDesign,D.React,D.rxjs))})(this,function(D,h,M,I,L,f,U,_,Me){"use strict";var Pt=Object.defineProperty;var Nt=(D,h,M)=>h in D?Pt(D,h,{enumerable:!0,configurable:!0,writable:!0,value:M}):D[h]=M;var Q=(D,h,M)=>Nt(D,typeof h!="symbol"?h+"":h,M);var be;function Oe(i,r,t,e){const n=e.getDrawingByParam(i);if(n==null)return;const a=M.getDrawingShapeKeyByDrawingSearch(i),s=t.getObject(a);if(s&&!(s instanceof I.Group))return;if(s!=null){s.addObject(r);return}const o=new I.Group(a);t.addObject(o,I.DRAWING_OBJECT_LAYER_INDEX).attachTransformerTo(o),o.addObject(r);const{transform:c}=n;c&&o.transformByState({left:c.left,top:c.top,angle:c.angle})}function Ee(i,r){var a;const t=r?i.getUnit(r):i.getFocusedUnit();if(t==null)return;const e=t.getUnitId();let n;return t.type===h.UniverInstanceType.UNIVER_SHEET?n=(a=t.getActiveSheet())==null?void 0:a.getSheetId():(t.type===h.UniverInstanceType.UNIVER_DOC||t.type===h.UniverInstanceType.UNIVER_SLIDE)&&(n=e),{unitId:e,subUnitId:n,current:t}}var Ke=Object.getOwnPropertyDescriptor,Ze=(i,r,t,e)=>{for(var n=e>1?void 0:e?Ke(r,t):r,a=i.length-1,s;a>=0;a--)(s=i[a])&&(n=s(n)||n);return n},ye=(i,r)=>(t,e)=>r(t,e,i);D.DrawingRenderService=class{constructor(r,t,e){this._drawingManagerService=r,this._imageIoService=t,this._galleryService=e}async renderImages(r,t){const{transform:e,drawingType:n,source:a,imageSourceType:s,srcRect:o,prstGeom:c,groupId:u,unitId:l,subUnitId:g,drawingId:d,isMultiTransform:p,transforms:S}=r;if(n!==h.DrawingTypeEnum.DRAWING_IMAGE||!this._drawingManagerService.getDrawingVisible()||e==null)return;const m=p&&S?S:[e],v=[];for(const C of m){const{left:y,top:O,width:N,height:j,angle:b,flipX:T,flipY:E,skewX:B,skewY:P}=C,G=m.indexOf(C),H=M.getDrawingShapeKeyByDrawingSearch({unitId:l,subUnitId:g,drawingId:d},p?G:void 0),$=t.getObject(H);if($!=null){$.transformByState({left:y,top:O,width:N,height:j,angle:b,flipX:T,flipY:E,skewX:B,skewY:P});continue}const X=this._drawingManagerService.getDrawingOrder(l,g),oe=X.indexOf(d),ne={...C,zIndex:oe===-1?X.length-1:oe},ie=this._imageIoService.getImageSourceCache(a,s);let ce=!1;if(ie!=null)ne.image=ie;else{if(s===M.ImageSourceType.UUID)try{ne.url=await this._imageIoService.getImage(a)}catch(De){console.error(De);continue}else ne.url=a;ce=!0}if(t.getObject(H))continue;ne.printable=!0;const q=new I.Image(H,ne);ce&&this._imageIoService.addImageSourceCache(a,s,q.getNative()),this._drawingManagerService.getDrawingVisible()&&(t.addObject(q,I.DRAWING_OBJECT_LAYER_INDEX),this._drawingManagerService.getDrawingEditable()&&t.attachTransformerTo(q),u&&Oe({drawingId:u,unitId:l,subUnitId:g},q,t,this._drawingManagerService),c!=null&&q.setPrstGeom(c),o!=null&&q.setSrcRect(o),v.push(q))}return v}renderFloatDom(r,t){const{transform:e,drawingType:n,groupId:a,unitId:s,subUnitId:o,drawingId:c,isMultiTransform:u,transforms:l}=r;if(n!==h.DrawingTypeEnum.DRAWING_DOM||!this._drawingManagerService.getDrawingVisible()||e==null)return;const g=u&&l?l:[e],d=[];for(const p of g){const{left:S,top:m,width:v,height:C,angle:y,flipX:O,flipY:N,skewX:j,skewY:b}=p,T=g.indexOf(p),E=M.getDrawingShapeKeyByDrawingSearch({unitId:s,subUnitId:o,drawingId:c},u?T:void 0),B=t.getObject(E);if(B!=null){B.transformByState({left:S,top:m,width:v,height:C,angle:y,flipX:O,flipY:N,skewX:j,skewY:b});continue}const P=this._drawingManagerService.getDrawingOrder(s,o),G=P.indexOf(c),H={...p,zIndex:G===-1?P.length-1:G};if(t.getObject(E))continue;H.printable=!1;const $=new I.Rect(E,H);this._drawingManagerService.getDrawingVisible()&&(t.addObject($,I.DRAWING_OBJECT_LAYER_INDEX),this._drawingManagerService.getDrawingEditable()&&r.allowTransform!==!1&&t.attachTransformerTo($),a&&Oe({drawingId:a,unitId:s,subUnitId:o},$,t,this._drawingManagerService),d.push($))}return d}renderDrawing(r,t){const e=this._drawingManagerService.getDrawingByParam(r);if(e!=null)switch(e.drawingType){case h.DrawingTypeEnum.DRAWING_IMAGE:return this.renderImages(e,t)}}previewImage(r,t,e,n){this._galleryService.open({images:[t],onOpenChange:a=>{a||this._galleryService.close()}})}_adjustImageSize(r,t,e,n){if(r<=e&&t<=n)return{width:r,height:t};const a=e/r,s=n/t,o=Math.min(a,s);return{width:Math.floor(r*o),height:Math.floor(t*o)}}},D.DrawingRenderService=Ze([ye(0,M.IDrawingManagerService),ye(1,M.IImageIoService),ye(2,L.IGalleryService)],D.DrawingRenderService);function le(i,r){const t=[];return i.forEach(e=>{const{oKey:n,left:a,top:s,height:o,width:c,angle:u}=e,l=r.getDrawingOKey(n);if(l==null)return t.push(null),!0;const{unitId:g,subUnitId:d,drawingId:p,drawingType:S}=l,m={unitId:g,subUnitId:d,drawingId:p,drawingType:S,transform:{left:a,top:s,height:o,width:c,angle:u}};S===h.DrawingTypeEnum.DRAWING_IMAGE&&(m.srcRect=e.srcRect),t.push(m)}),t}var R=(i=>(i.default="0",i.left="1",i.center="2",i.right="3",i.top="4",i.middle="5",i.bottom="6",i.horizon="7",i.vertical="8",i))(R||{});const fe={id:"sheet.operation.set-image-align",type:h.CommandType.OPERATION,handler:(i,r)=>!0},Fe=i=>{const r=L.useDependency(h.ICommandService),t=L.useDependency(h.LocaleService),{alignShow:e}=i,[n,a]=_.useState(R.default),s=[{label:t.t("image-panel.align.default"),value:R.default},{options:[{label:t.t("image-panel.align.left"),value:R.left},{label:t.t("image-panel.align.center"),value:R.center},{label:t.t("image-panel.align.right"),value:R.right}]},{options:[{label:t.t("image-panel.align.top"),value:R.top},{label:t.t("image-panel.align.middle"),value:R.middle},{label:t.t("image-panel.align.bottom"),value:R.bottom}]},{options:[{label:t.t("image-panel.align.horizon"),value:R.horizon},{label:t.t("image-panel.align.vertical"),value:R.vertical}]}];function o(c){a(c),r.executeCommand(fe.id,{alignType:c})}return f.jsxs("div",{className:U.clsx("univer-relative univer-w-full",{"univer-hidden":!e}),children:[f.jsx("header",{className:"univer-text-gray-600 dark:!univer-text-gray-200",children:f.jsx("div",{children:t.t("image-panel.align.title")})}),f.jsx("div",{className:"univer-relative univer-mt-2.5 univer-flex univer-h-full",children:f.jsx("div",{className:"univer-w-full univer-text-gray-900 dark:!univer-text-white",children:f.jsx(U.Select,{value:n,options:s,onChange:o})})})]})};var K=function(){return K=Object.assign||function(i){for(var r,t=1,e=arguments.length;t<e;t++){r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(i[n]=r[n])}return i},K.apply(this,arguments)},ze=function(i,r){var t={};for(var e in i)Object.prototype.hasOwnProperty.call(i,e)&&r.indexOf(e)<0&&(t[e]=i[e]);if(i!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,e=Object.getOwnPropertySymbols(i);n<e.length;n++)r.indexOf(e[n])<0&&Object.prototype.propertyIsEnumerable.call(i,e[n])&&(t[e[n]]=i[e[n]]);return t},z=_.forwardRef(function(i,r){var t=i.icon,e=i.id,n=i.className,a=i.extend,s=ze(i,["icon","id","className","extend"]),o="univerjs-icon univerjs-icon-".concat(e," ").concat(n||"").trim(),c=_.useRef("_".concat(qe()));return Te(t,"".concat(e),{defIds:t.defIds,idSuffix:c.current},K({ref:r,className:o},s),a)});function Te(i,r,t,e,n){return _.createElement(i.tag,K(K({key:r},Ye(i,t,n)),e),(Xe(i,t).children||[]).map(function(a,s){return Te(a,"".concat(r,"-").concat(i.tag,"-").concat(s),t,void 0,n)}))}function Ye(i,r,t){var e=K({},i.attrs);t!=null&&t.colorChannel1&&e.fill==="colorChannel1"&&(e.fill=t.colorChannel1),i.tag==="mask"&&e.id&&(e.id=e.id+r.idSuffix),Object.entries(e).forEach(function(a){var s=a[0],o=a[1];s==="mask"&&typeof o=="string"&&(e[s]=o.replace(/url\(#(.*)\)/,"url(#$1".concat(r.idSuffix,")")))});var n=r.defIds;return!n||n.length===0||(i.tag==="use"&&e["xlink:href"]&&(e["xlink:href"]=e["xlink:href"]+r.idSuffix),Object.entries(e).forEach(function(a){var s=a[0],o=a[1];typeof o=="string"&&(e[s]=o.replace(/url\(#(.*)\)/,"url(#$1".concat(r.idSuffix,")")))})),e}function Xe(i,r){var t,e=r.defIds;return!e||e.length===0?i:i.tag==="defs"&&(!((t=i.children)===null||t===void 0)&&t.length)?K(K({},i),{children:i.children.map(function(n){return typeof n.attrs.id=="string"&&e&&e.includes(n.attrs.id)?K(K({},n),{attrs:K(K({},n.attrs),{id:n.attrs.id+r.idSuffix})}):n})}):i}function qe(){return Math.random().toString(36).substring(2,8)}z.displayName="UniverIcon";var Je={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"colorChannel1",d:"M11.0363 12.2367V14.0367C11.0363 14.3681 11.3049 14.6367 11.6363 14.6367C11.9676 14.6367 12.2363 14.3681 12.2363 14.0367V12.2367H14.0364C14.3677 12.2367 14.6364 11.9681 14.6364 11.6367C14.6364 11.3054 14.3677 11.0367 14.0364 11.0367H12.2363V9.23672C12.2363 8.90535 11.9676 8.63672 11.6363 8.63672C11.3049 8.63672 11.0363 8.90535 11.0363 9.23672V11.0367H9.23635C8.90498 11.0367 8.63635 11.3054 8.63635 11.6367C8.63635 11.9681 8.90498 12.2367 9.23635 12.2367H11.0363Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M2.56365 1.36377C1.90091 1.36377 1.36365 1.90103 1.36365 2.56377V6.16377C1.36365 6.82651 1.90091 7.36377 2.56365 7.36377H6.16365C6.82639 7.36377 7.36365 6.82651 7.36365 6.16377V2.56377C7.36365 1.90103 6.82639 1.36377 6.16365 1.36377H2.56365ZM6.16365 2.56377H2.56365L2.56365 6.16377H6.16365V2.56377Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M2.56365 8.63647C1.90091 8.63647 1.36365 9.17373 1.36365 9.83647V13.4365C1.36365 14.0992 1.90091 14.6365 2.56365 14.6365H6.16365C6.82639 14.6365 7.36365 14.0992 7.36365 13.4365V9.83647C7.36365 9.17373 6.82639 8.63647 6.16365 8.63647H2.56365ZM6.16365 9.83647H2.56365L2.56365 13.4365H6.16365V9.83647Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M9.83635 7.36377C9.17361 7.36377 8.63635 6.82651 8.63635 6.16377V2.56377C8.63635 1.90103 9.17361 1.36377 9.83635 1.36377H13.4364C14.0991 1.36377 14.6364 1.90103 14.6364 2.56377V6.16377C14.6364 6.82651 14.0991 7.36377 13.4364 7.36377H9.83635ZM9.83635 6.16377V2.56377L13.4364 2.56377V6.16377H9.83635Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Pe=_.forwardRef(function(i,r){return _.createElement(z,Object.assign({},i,{id:"autofill-double-icon",ref:r,icon:Je}))});Pe.displayName="AutofillDoubleIcon";var Qe={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 17 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M14.0045 4.4334C14.8881 4.4334 15.6045 3.71705 15.6045 2.8334C15.6045 1.94974 14.8881 1.2334 14.0045 1.2334H3.70449C2.82084 1.2334 2.10449 1.94974 2.10449 2.8334C2.10449 3.71705 2.82084 4.4334 3.70449 4.4334H14.0045ZM14.4045 2.8334C14.4045 3.05431 14.2254 3.2334 14.0045 3.2334H3.70449C3.48358 3.2334 3.30449 3.05431 3.30449 2.8334C3.30449 2.61248 3.48358 2.4334 3.70449 2.4334H14.0045C14.2254 2.4334 14.4045 2.61249 14.4045 2.8334Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M14.1544 8.5999C15.038 8.5999 15.7544 7.88356 15.7544 6.9999C15.7544 6.11625 15.038 5.3999 14.1544 5.3999H3.85439C2.97074 5.3999 2.25439 6.11625 2.25439 6.9999C2.25439 7.88356 2.97074 8.5999 3.85439 8.5999H14.1544ZM14.5544 6.9999C14.5544 7.22082 14.3753 7.3999 14.1544 7.3999H3.85439C3.63348 7.3999 3.45439 7.22082 3.45439 6.9999C3.45439 6.77899 3.63348 6.5999 3.85439 6.5999H14.1544C14.3753 6.5999 14.5544 6.77899 14.5544 6.9999Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M8.57975 14.5902L6.58023 12.5907C6.34591 12.3564 6.34591 11.9765 6.58023 11.7421C6.81454 11.5078 7.19444 11.5078 7.42876 11.7421L8.40449 12.7179V10.1664C8.40449 9.83504 8.67312 9.56641 9.00449 9.56641C9.33586 9.56641 9.60449 9.83504 9.60449 10.1664V12.7179L10.5802 11.7421C10.8145 11.5078 11.1944 11.5078 11.4288 11.7421C11.6631 11.9765 11.6631 12.3564 11.4288 12.5907L9.42923 14.5902"}},{tag:"path",attrs:{fill:"currentColor",d:"M8.57975 14.5902C8.58121 14.5917 8.58268 14.5931 8.58416 14.5946C8.64077 14.6502 8.70566 14.6923 8.77482 14.7209C8.84557 14.7502 8.92314 14.7664 9.00449 14.7664C9.08585 14.7664 9.16342 14.7502 9.23416 14.7209C9.30332 14.6923 9.36821 14.6502 9.42482 14.5946"}}]},Ne=_.forwardRef(function(i,r){return _.createElement(z,Object.assign({},i,{id:"bottom-icon",ref:r,icon:Qe}))});Ne.displayName="BottomIcon";var et={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M5.97705 7.51296C5.97705 7.18159 6.24568 6.91296 6.57705 6.91296H8.48632C8.81769 6.91296 9.08632 7.18159 9.08632 7.51296C9.08632 7.84433 8.81769 8.11296 8.48632 8.11296H6.57705C6.24568 8.11296 5.97705 7.84433 5.97705 7.51296Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M6.57705 9.41028C6.24568 9.41028 5.97705 9.67891 5.97705 10.0103C5.97705 10.3416 6.24568 10.6103 6.57705 10.6103H10.8199C11.1512 10.6103 11.4199 10.3416 11.4199 10.0103C11.4199 9.67891 11.1512 9.41028 10.8199 9.41028H6.57705Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M3.51074 2.37063C3.51074 1.48697 4.22709 0.77063 5.11074 0.77063H9.80318L9.81294 0.770708C9.97168 0.768161 10.1311 0.82824 10.2511 0.95055L14.4317 5.21408C14.5165 5.30049 14.5697 5.406 14.5917 5.51645C14.6041 5.5644 14.6106 5.61467 14.6106 5.66648V11.6406C14.6106 12.5243 13.8943 13.2406 13.0106 13.2406H5.11074C4.22709 13.2406 3.51074 12.5243 3.51074 11.6406V2.37063ZM10.4032 4.66648V2.81964L12.6063 5.06648H10.8032C10.5823 5.06648 10.4032 4.88739 10.4032 4.66648ZM5.11074 1.97063C4.88983 1.97063 4.71074 2.14972 4.71074 2.37063V11.6406C4.71074 11.8615 4.88983 12.0406 5.11074 12.0406H13.0106C13.2316 12.0406 13.4106 11.8615 13.4106 11.6406V6.26648H10.8032C9.91953 6.26648 9.20318 5.55013 9.20318 4.66648V1.97063H5.11074Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M2.58916 6.6741C2.58916 6.34273 2.32053 6.0741 1.98916 6.0741C1.65779 6.0741 1.38916 6.34273 1.38916 6.6741V12.6294C1.38916 14.0653 2.55322 15.2294 3.98916 15.2294H9.41408C9.74545 15.2294 10.0141 14.9607 10.0141 14.6294C10.0141 14.298 9.74545 14.0294 9.41408 14.0294H3.98916C3.21596 14.0294 2.58916 13.4026 2.58916 12.6294V6.6741Z"}}]},Be=_.forwardRef(function(i,r){return _.createElement(z,Object.assign({},i,{id:"create-copy-icon",ref:r,icon:et}))});Be.displayName="CreateCopyIcon";var tt={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 17 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M7.38125 1.16211C6.49759 1.16211 5.78125 1.87845 5.78125 2.76211V5.6377H2.87783C1.99418 5.6377 1.27783 6.35404 1.27783 7.2377V13.2377C1.27783 14.1214 1.99418 14.8377 2.87783 14.8377H8.87783C9.76149 14.8377 10.4778 14.1214 10.4778 13.2377V10.3621H13.3813C14.2649 10.3621 14.9813 9.64577 14.9813 8.76211V2.76211C14.9813 1.87845 14.2649 1.16211 13.3813 1.16211H7.38125ZM10.4778 9.16211H13.3813C13.6022 9.16211 13.7812 8.98302 13.7812 8.76211V2.76211C13.7812 2.5412 13.6022 2.36211 13.3813 2.36211H7.38125C7.16034 2.36211 6.98125 2.5412 6.98125 2.76211V5.6377H8.87783C9.76149 5.6377 10.4778 6.35404 10.4778 7.2377V9.16211ZM6.98125 6.8377H8.87783C9.09875 6.8377 9.27783 7.01678 9.27783 7.2377V9.16211H7.38125C7.16034 9.16211 6.98125 8.98302 6.98125 8.76211V6.8377ZM5.78125 6.8377V8.76211C5.78125 9.64577 6.49759 10.3621 7.38125 10.3621H9.27783V13.2377C9.27783 13.4586 9.09875 13.6377 8.87783 13.6377H2.87783C2.65692 13.6377 2.47783 13.4586 2.47783 13.2377V7.2377C2.47783 7.01678 2.65692 6.8377 2.87783 6.8377H5.78125Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Ue=_.forwardRef(function(i,r){return _.createElement(z,Object.assign({},i,{id:"group-icon",ref:r,icon:tt}))});Ue.displayName="GroupIcon";var rt={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"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"}}]},Re=_.forwardRef(function(i,r){return _.createElement(z,Object.assign({},i,{id:"more-down-icon",ref:r,icon:rt}))});Re.displayName="MoreDownIcon";var nt={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M1.25 2.96401C1.25 3.84767 1.96634 4.56401 2.85 4.56401H13.15C14.0337 4.56401 14.75 3.84767 14.75 2.96401C14.75 2.08036 14.0337 1.36401 13.15 1.36401H2.85C1.96635 1.36401 1.25 2.08036 1.25 2.96401ZM2.85 3.36401C2.62909 3.36401 2.45 3.18493 2.45 2.96401C2.45 2.7431 2.62909 2.56401 2.85 2.56401H13.15C13.3709 2.56401 13.55 2.7431 13.55 2.96401C13.55 3.18493 13.3709 3.36401 13.15 3.36401H2.85Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M5.57564 11.6118C5.80995 11.3774 6.18985 11.3774 6.42417 11.6118L7.3999 12.5875V6.36951C7.3999 6.03814 7.66853 5.76951 7.9999 5.76951C8.33127 5.76951 8.5999 6.03814 8.5999 6.36951V12.5875L9.57564 11.6118C9.80995 11.3774 10.1899 11.3774 10.4242 11.6118C10.6585 11.8461 10.6585 12.226 10.4242 12.4603L8.4324 14.452C8.32324 14.5655 8.16982 14.6362 7.9999 14.6362C7.82998 14.6362 7.67655 14.5655 7.56739 14.452L5.57564 12.4603C5.34132 12.226 5.34132 11.8461 5.57564 11.6118Z"}}]},je=_.forwardRef(function(i,r){return _.createElement(z,Object.assign({},i,{id:"move-down-icon",ref:r,icon:nt}))});je.displayName="MoveDownIcon";var it={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M1.25 13.036C1.25 12.1523 1.96634 11.436 2.85 11.436H13.15C14.0337 11.436 14.75 12.1523 14.75 13.036C14.75 13.9196 14.0337 14.636 13.15 14.636H2.85C1.96635 14.636 1.25 13.9196 1.25 13.036ZM2.85 12.636C2.62909 12.636 2.45 12.8151 2.45 13.036C2.45 13.2569 2.62909 13.436 2.85 13.436H13.15C13.3709 13.436 13.55 13.2569 13.55 13.036C13.55 12.8151 13.3709 12.636 13.15 12.636H2.85Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M5.57564 4.38825C5.80995 4.62256 6.18985 4.62256 6.42417 4.38825L7.3999 3.41251V9.63049C7.3999 9.96186 7.66853 10.2305 7.9999 10.2305C8.33127 10.2305 8.5999 9.96186 8.5999 9.63049V3.41251L9.57564 4.38825C9.80995 4.62256 10.1899 4.62256 10.4242 4.38825C10.6585 4.15393 10.6585 3.77403 10.4242 3.53972L8.4324 1.54796C8.32324 1.43445 8.16982 1.36382 7.9999 1.36382C7.82998 1.36382 7.67655 1.43446 7.56739 1.54797L5.57564 3.53972C5.34132 3.77403 5.34132 4.15393 5.57564 4.38825Z"}}]},xe=_.forwardRef(function(i,r){return _.createElement(z,Object.assign({},i,{id:"move-up-icon",ref:r,icon:it}))});xe.displayName="MoveUpIcon";var at={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 17 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M7.82994 1.40913C7.88746 1.35161 7.95376 1.30821 8.02453 1.27893C8.09527 1.24959 8.17285 1.2334 8.2542 1.2334C8.33555 1.2334 8.41313 1.24959 8.48387 1.27893C8.55464 1.30821 8.62094 1.35161 8.67846 1.40913L10.6785 3.40913C10.9128 3.64345 10.9128 4.02335 10.6785 4.25766C10.4441 4.49198 10.0642 4.49198 9.82994 4.25766L8.8542 3.28193V5.8334C8.8542 6.16477 8.58557 6.4334 8.2542 6.4334C7.92283 6.4334 7.6542 6.16477 7.6542 5.8334V3.28193L6.67846 4.25766C6.44415 4.49198 6.06425 4.49198 5.82994 4.25766C5.59562 4.02335 5.59562 3.64345 5.82994 3.40913L7.82994 1.40913Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M1.50439 9C1.50439 8.11634 2.22074 7.4 3.10439 7.4H13.4044C14.288 7.4 15.0044 8.11634 15.0044 9C15.0044 9.88366 14.2881 10.6 13.4044 10.6H3.1044C2.22074 10.6 1.50439 9.88366 1.50439 9ZM3.10439 8.6C2.88348 8.6 2.70439 8.77909 2.70439 9C2.70439 9.22091 2.88348 9.4 3.1044 9.4H13.4044C13.6253 9.4 13.8044 9.22091 13.8044 9C13.8044 8.77909 13.6253 8.6 13.4044 8.6H3.10439Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M1.6543 13.1665C1.6543 12.2828 2.37064 11.5665 3.2543 11.5665H13.5543C14.438 11.5665 15.1543 12.2828 15.1543 13.1665C15.1543 14.0502 14.438 14.7665 13.5543 14.7665H3.2543C2.37064 14.7665 1.6543 14.0502 1.6543 13.1665ZM3.2543 12.7665C3.03338 12.7665 2.8543 12.9456 2.8543 13.1665C2.8543 13.3874 3.03338 13.5665 3.2543 13.5665H13.5543C13.7752 13.5665 13.9543 13.3874 13.9543 13.1665C13.9543 12.9456 13.7752 12.7665 13.5543 12.7665H3.2543Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Ae=_.forwardRef(function(i,r){return _.createElement(z,Object.assign({},i,{id:"topmost-icon",ref:r,icon:at}))});Ae.displayName="TopmostIcon";var st={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 17 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M7.46855 2.83731C7.46855 2.61639 7.64764 2.4373 7.86855 2.4373H13.8603C14.0812 2.4373 14.2603 2.61639 14.2603 2.8373V9.5049C14.2603 9.72581 14.0812 9.90489 13.8603 9.90489H12.866C12.5346 9.90489 12.266 10.1735 12.266 10.5049C12.266 10.8363 12.5346 11.1049 12.866 11.1049H13.8603C14.7439 11.1049 15.4603 10.3886 15.4603 9.5049V2.8373C15.4603 1.95365 14.7439 1.2373 13.8603 1.2373H7.86855C6.9849 1.2373 6.26855 1.95365 6.26855 2.83731V3.48688C6.26855 3.81825 6.53718 4.08688 6.86855 4.08688C7.19993 4.08688 7.46855 3.81825 7.46855 3.48688V2.83731Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M3.19888 5.56299C2.31522 5.56299 1.59888 6.27933 1.59888 7.16299V13.163C1.59888 14.0466 2.31522 14.763 3.19888 14.763H9.19888C10.0825 14.763 10.7989 14.0466 10.7989 13.163V7.16299C10.7989 6.27933 10.0825 5.56299 9.19888 5.56299H3.19888ZM2.79888 7.16299C2.79888 6.94207 2.97796 6.76299 3.19888 6.76299H9.19888C9.41979 6.76299 9.59888 6.94207 9.59888 7.16299V13.163C9.59888 13.3839 9.41979 13.563 9.19888 13.563H3.19888C2.97796 13.563 2.79888 13.3839 2.79888 13.163V7.16299Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Le=_.forwardRef(function(i,r){return _.createElement(z,Object.assign({},i,{id:"ungroup-icon",ref:r,icon:st}))});Le.displayName="UngroupIcon";const ot=i=>{const{arrangeShow:r,drawings:t}=i,e=L.useDependency(h.LocaleService),n=L.useDependency(M.IDrawingManagerService),[a,s]=_.useState(t);_.useEffect(()=>{const c=n.focus$.subscribe(u=>{s(u)});return()=>{c.unsubscribe()}},[]);const o=c=>{const u=a[0].unitId,l=a[0].subUnitId,g=a.map(d=>d.drawingId);n.featurePluginOrderUpdateNotification({unitId:u,subUnitId:l,drawingIds:g,arrangeType:c})};return f.jsxs("div",{className:U.clsx("univer-grid univer-gap-2 univer-py-2 univer-text-gray-400",{"univer-hidden":!r}),children:[f.jsx("header",{className:"univer-text-gray-600 dark:!univer-text-gray-200",children:f.jsx("div",{children:e.t("image-panel.arrange.title")})}),f.jsxs("div",{className:"univer-grid univer-grid-cols-2 univer-gap-2 univer-px-8",children:[f.jsxs(U.Button,{onClick:()=>{o(h.ArrangeTypeEnum.forward)},children:[f.jsx(xe,{}),e.t("image-panel.arrange.forward")]}),f.jsxs(U.Button,{onClick:()=>{o(h.ArrangeTypeEnum.backward)},children:[f.jsx(je,{}),e.t("image-panel.arrange.backward")]}),f.jsxs(U.Button,{onClick:()=>{o(h.ArrangeTypeEnum.front)},children:[f.jsx(Ae,{}),e.t("image-panel.arrange.front")]}),f.jsxs(U.Button,{onClick:()=>{o(h.ArrangeTypeEnum.back)},children:[f.jsx(Ne,{}),e.t("image-panel.arrange.back")]})]})]})},ct=i=>{const r=L.useDependency(h.LocaleService),t=L.useDependency(I.IRenderManagerService),e=L.useDependency(M.IDrawingManagerService),{hasGroup:n,drawings:a}=i,[s,o]=_.useState(!1),[c,u]=_.useState(!0),[l,g]=_.useState(!0),d=()=>{const m=e.getFocusDrawings(),{unitId:v,subUnitId:C}=m[0],y=h.Tools.generateRandomId(10),O=I.getGroupState(0,0,m.map(b=>b.transform||{})),N={unitId:v,subUnitId:C,drawingId:y,drawingType:h.DrawingTypeEnum.DRAWING_GROUP,transform:O},j=m.map(b=>{const T=b.transform||{left:0,top:0},{unitId:E,subUnitId:B,drawingId:P}=b;return{unitId:E,subUnitId:B,drawingId:P,transform:{...T,left:T.left-O.left,top:T.top-O.top},groupId:y}});e.featurePluginGroupUpdateNotification([{parent:N,children:j}])},p=m=>{if(m.drawingType!==h.DrawingTypeEnum.DRAWING_GROUP)return;const{unitId:v,subUnitId:C,drawingId:y,transform:O={width:0,height:0}}=m;if(O==null)return;const N=e.getDrawingsByGroup({unitId:v,subUnitId:C,drawingId:y});if(N.length===0)return;const j=N.map(b=>{const{transform:T}=b,{unitId:E,subUnitId:B,drawingId:P}=b,G=I.transformObjectOutOfGroup(T||{},O,O.width||0,O.height||0);return{unitId:E,subUnitId:B,drawingId:P,transform:{...T,...G},groupId:void 0}});return{parent:m,children:j}},S=()=>{const v=e.getFocusDrawings().map(C=>p(C)).filter(C=>C!=null);v.length!==0&&e.featurePluginUngroupUpdateNotification(v)};return _.useEffect(()=>{const m=a[0];if(m==null)return;const{unitId:v}=m,C=t.getRenderById(v),y=C==null?void 0:C.scene;if(y==null)return;const O=y.getTransformerByCreate(),N=O.clearControl$.subscribe(b=>{b===!0&&o(!1)}),j=O.changeStart$.subscribe(b=>{const{objects:T}=b,E=le(T,e),B=E.filter($=>($==null?void 0:$.drawingType)===h.DrawingTypeEnum.DRAWING_GROUP);let P=!1,G=!1;E.length>1&&(P=!0),B.length>0&&(G=!0),o(P||G),u(P),g(G)});return()=>{j.unsubscribe(),N.unsubscribe()}},[]),f.jsxs("div",{className:U.clsx("univer-grid univer-gap-2 univer-py-2 univer-text-gray-400",{"univer-hidden":n===!0&&s===!1||n===!1}),children:[f.jsx("header",{className:"univer-text-gray-600 dark:!univer-text-gray-200",children:f.jsx("div",{children:r.t("image-panel.group.title")})}),f.jsxs("div",{className:"univer-flex univer-items-center univer-justify-center univer-gap-2",children:[f.jsxs(U.Button,{className:U.clsx({"univer-hidden":!c}),onClick:d,children:[f.jsx(Ue,{}),r.t("image-panel.group.group")]}),f.jsxs(U.Button,{className:U.clsx({"univer-hidden":!l}),onClick:S,children:[f.jsx(Le,{}),r.t("image-panel.group.unGroup")]})]})]})},te=20,lt=20,ut=[-3600,3600],pe=300,gt=i=>{var $e;const r=L.useDependency(h.LocaleService),t=L.useDependency(M.IDrawingManagerService),e=L.useDependency(I.IRenderManagerService),{drawings:n,transformShow:a}=i,s=n[0];if(s==null)return;const o=s.transform;if(o==null)return;const{unitId:c,subUnitId:u,drawingId:l,drawingType:g}=s,d=e.getRenderById(c),p=d==null?void 0:d.scene;if(p==null)return;const S=($e=p.getEngine())==null?void 0:$e.activeScene;if(S==null)return;const m=p.getTransformerByCreate(),{width:v=0,height:C=0,left:y=0,top:O=0,angle:N=0}=o,[j,b]=_.useState(v),[T,E]=_.useState(C),[B,P]=_.useState(y),[G,H]=_.useState(O),[$,X]=_.useState(N),[oe,ne]=_.useState(m.keepRatio),ie=(w,x,V,W)=>{const{width:k,height:J}=S,{ancestorLeft:Z,ancestorTop:F}=p;let Y=w,ae=x,de=V,he=W;return w+Z<0&&(Y=-Z),x+F<0&&(ae=-F),de=k-Y-Z,de<te&&(de=te),he=J-ae-F,he<te&&(he=te),w+de+Z>k&&(Y=k-V-Z),x+he+F>J&&(ae=J-W-F),{limitLeft:Y,limitTop:ae,limitWidth:de,limitHeight:he}},ce=w=>{const{objects:x}=w,V=le(x,t);if(V.length!==1)return;const W=V[0];if(W==null)return;const{transform:k}=W;if(k==null)return;const{width:J,height:Z,left:F,top:Y,angle:ae}=k;J!=null&&b(J),Z!=null&&E(Z),F!=null&&P(F),Y!=null&&H(Y),ae!=null&&X(ae)};_.useEffect(()=>{const w=[m.changeStart$.subscribe(x=>{ce(x)}),m.changing$.subscribe(x=>{ce(x)}),m.changeEnd$.subscribe(x=>{ce(x)}),t.focus$.subscribe(x=>{if(x.length!==1)return;const V=t.getDrawingByParam(x[0]);if(V==null)return;const W=V.transform;if(W==null)return;const{width:k,height:J,left:Z,top:F,angle:Y}=W;k!=null&&b(k),J!=null&&E(J),Z!=null&&P(Z),F!=null&&H(F),Y!=null&&X(Y)})];return()=>{w.forEach(x=>x.unsubscribe())}},[]);const q=h.debounce(w=>{if(w==null)return;w=Math.max(w,te);const{limitWidth:x,limitHeight:V}=ie(B,G,w,T);w=Math.min(w,x);const W={unitId:c,subUnitId:u,drawingId:l,drawingType:g,transform:{width:w}};if(oe){let k=w/j*T;if(k=Math.max(k,lt),k>V)return;E(k),W.transform.height=k}b(w),t.featurePluginUpdateNotification([W]),m.refreshControls().changeNotification()},pe),De=h.debounce(w=>{if(w==null)return;w=Math.max(w,te);const{limitHeight:x,limitWidth:V}=ie(B,G,j,w);w=Math.min(w,x);const W={unitId:c,subUnitId:u,drawingId:l,drawingType:g,transform:{height:w}};if(oe){let k=w/T*j;if(k=Math.max(k,te),k>V)return;b(k),W.transform.width=k}E(w),t.featurePluginUpdateNotification([W]),m.refreshControls().changeNotification()},pe),Mt=h.debounce(w=>{if(w==null)return;const{limitLeft:x}=ie(w,G,j,T);w=x;const V={unitId:c,subUnitId:u,drawingId:l,drawingType:g,transform:{left:w}};P(w),t.featurePluginUpdateNotification([V]),m.refreshControls().changeNotification()},pe),Ot=h.debounce(w=>{if(w==null)return;const{limitTop:x}=ie(B,w,j,T);w=x;const V={unitId:c,subUnitId:u,drawingId:l,drawingType:g,transform:{top:w}};H(w),t.featurePluginUpdateNotification([V]),m.refreshControls().changeNotification()},pe),Et=w=>{if(w==null)return;const[x,V]=ut;w<x&&(w=x),w>V&&(w=V);const W={unitId:c,subUnitId:u,drawingId:l,drawingType:g,transform:{angle:w}};X(w),t.featurePluginUpdateNotification([W]),m.refreshControls().changeNotification()},Tt=w=>{ne(w),m.keepRatio=w};return f.jsxs("div",{className:U.clsx("univer-grid univer-gap-2 univer-py-2 univer-text-gray-400",{"univer-hidden":!a}),children:[f.jsx("header",{className:"univer-text-gray-600 dark:!univer-text-gray-200",children:f.jsx("div",{children:r.t("image-panel.transform.title")})}),f.jsxs("div",{className:"univer-grid univer-grid-cols-3 univer-gap-2 [&>div]:univer-grid [&>div]:univer-gap-2",children:[f.jsxs("div",{children:[f.jsx("span",{children:r.t("image-panel.transform.width")}),f.jsx(U.InputNumber,{precision:1,value:j,onChange:w=>{q(w)}})]}),f.jsxs("div",{children:[f.jsx("span",{children:r.t("image-panel.transform.height")}),f.jsx(U.InputNumber,{precision:1,value:T,onChange:w=>{De(w)}})]}),f.jsxs("div",{children:[f.jsx("span",{children:r.t("image-panel.transform.lock")}),f.jsx("div",{className:"univer-text-center",children:f.jsx(U.Checkbox,{checked:oe,onChange:Tt})})]})]}),f.jsxs("div",{className:"univer-grid univer-grid-cols-3 univer-gap-2 [&>div]:univer-grid [&>div]:univer-gap-2",children:[f.jsxs("div",{children:[f.jsx("span",{children:r.t("image-panel.transform.x")}),f.jsx(U.InputNumber,{precision:1,value:B,onChange:w=>{Mt(w)}})]}),f.jsxs("div",{children:[f.jsx("span",{children:r.t("image-panel.transform.y")}),f.jsx(U.InputNumber,{precision:1,value:G,onChange:w=>{Ot(w)}})]}),f.jsxs("div",{children:[f.jsx("span",{children:r.t("image-panel.transform.rotate")}),f.jsx(U.InputNumber,{precision:1,value:$,onChange:Et})]})]})]})},me={id:"sheet.operation.open-image-crop",type:h.CommandType.OPERATION,handler:(i,r)=>!0},ee={id:"sheet.operation.close-image-crop",type:h.CommandType.OPERATION,handler:(i,r)=>!0};var A=(i=>(i.FREE="0",i.R1_1="1",i.R16_9="2",i.R9_16="3",i.R5_4="4",i.R4_5="5",i.R4_3="6",i.R3_4="7",i.R3_2="8",i.R2_3="9",i))(A||{});const ue={id:"sheet.operation.Auto-image-crop",type:h.CommandType.OPERATION,handler:(i,r)=>!0},dt=i=>{const r=L.useDependency(h.ICommandService),t=L.useDependency(h.LocaleService),{drawings:e,cropperShow:n}=i;if(e[0]==null)return;const[s,o]=_.useState(A.FREE),c=_.useRef(!1),u=[{label:t.t("image-panel.crop.mode"),value:A.FREE},{label:"1:1",value:A.R1_1},{label:"16:9",value:A.R16_9},{label:"9:16",value:A.R9_16},{label:"5:4",value:A.R5_4},{label:"4:5",value:A.R4_5},{label:"4:3",value:A.R4_3},{label:"3:4",value:A.R3_4},{label:"3:2",value:A.R3_2},{label:"2:3",value:A.R2_3}];_.useEffect(()=>{const d=r.onCommandExecuted(p=>{if(p.id===ee.id){const S=p.params;S!=null&&S.isAuto||(c.current=!1)}});return()=>{d==null||d.dispose()}},[]);function l(d){o(d),c.current&&r.executeCommand(ue.id,{cropType:d})}const g=d=>{r.executeCommand(ue.id,{cropType:d}),c.current=!0};return f.jsxs("div",{className:U.clsx("univer-grid univer-gap-2 univer-py-2 univer-text-gray-400",{"univer-hidden":!n}),children:[f.jsx("header",{className:"univer-text-gray-600 dark:!univer-text-gray-200",children:f.jsx("div",{children:t.t("image-panel.crop.title")})}),f.jsxs("div",{className:"univer-flex univer-items-center univer-justify-center univer-gap-2",children:[f.jsxs(U.Button,{onClick:()=>{g(s)},children:[f.jsx(Be,{}),t.t("image-panel.crop.start")]}),f.jsx(U.Select,{value:s,options:u,onChange:l})]})]})},ht=i=>{const r=L.useDependency(M.IDrawingManagerService),t=L.useDependency(I.IRenderManagerService),e=L.useDependency(h.LocaleService),{drawings:n,hasArrange:a=!0,hasTransform:s=!0,hasAlign:o=!0,hasCropper:c=!0,hasGroup:u=!0}=i,l=n[0];if(l==null)return;const{unitId:g}=l,d=t.getRenderById(g),p=d==null?void 0:d.scene;if(p==null)return;const S=p.getTransformerByCreate(),[m,v]=_.useState(!0),[C,y]=_.useState(!0),[O,N]=_.useState(!1),[j,b]=_.useState(!0),[T,E]=_.useState(!1);return _.useEffect(()=>{const B=S.clearControl$.subscribe(H=>{H===!0&&(v(!1),y(!1),N(!1),b(!1),E(!0))}),P=S.changeStart$.subscribe(H=>{const{objects:$}=H,X=le($,r);X.length===0?(v(!1),y(!1),N(!1),b(!1),E(!0)):X.length===1?(v(!0),y(!0),N(!1),b(!0),E(!1)):(v(!0),y(!1),N(!0),b(!1),E(!1))}),G=r.focus$.subscribe(H=>{H.length===0?(v(!1),y(!1),N(!1),b(!1),E(!0)):H.length===1?(v(!0),y(!0),N(!1),b(!0),E(!1)):(v(!0),y(!1),N(!0),b(!1),E(!1))});return()=>{P.unsubscribe(),B.unsubscribe(),G.unsubscribe()}},[]),f.jsxs(f.Fragment,{children:[f.jsx("div",{className:U.clsx("univer-h-full",{"univer-hidden":!T}),children:f.jsx("div",{className:"univer-flex univer-h-full univer-items-center univer-justify-center",children:f.jsx("span",{children:e.t("image-panel.null")})})}),f.jsx(ot,{arrangeShow:a===!0?m:!1,drawings:n}),f.jsx(gt,{transformShow:s===!0?C:!1,drawings:n}),f.jsx(Fe,{alignShow:o===!0?O:!1,drawings:n}),f.jsx(dt,{cropperShow:c===!0?j:!1,drawings:n}),f.jsx(ct,{hasGroup:u,drawings:n})]})};function He(i){var m;const{popup:r}=i,t=(m=r==null?void 0:r.extraProps)==null?void 0:m.menuItems;if(!t)return null;const e=L.useDependency(h.ICommandService),n=L.useDependency(h.LocaleService),[a,s]=_.useState(!1),[o,c]=_.useState(!1),u=()=>{c(!0)},l=()=>{c(!1)},g=v=>{s(v)},d=v=>{e.executeCommand(v.commandId,v.commandParams),s(!1)},p=a||o,S=t.filter(v=>!v.disable);return f.jsx("div",{onMouseEnter:u,onMouseLeave:l,children:f.jsx(U.DropdownMenu,{align:"start",items:S.map(v=>({type:"item",children:n.t(v.label),onSelect:()=>d(v)})),open:a,onOpenChange:g,children:f.jsxs("div",{className:U.clsx("univer-flex univer-items-center univer-gap-2 univer-rounded univer-p-1 hover:univer-bg-gray-100 dark:hover:!univer-bg-gray-800",U.borderClassName,{"univer-bg-gray-100 dark:!univer-bg-gray-800":a,"univer-bg-white dark:!univer-bg-gray-900":!a}),children:[f.jsx(Pe,{className:"univer-fill-primary-600 univer-text-gray-900 dark:!univer-text-white"}),p&&f.jsx(Re,{className:"dark:!univer-text-white"})]})})})}const ke="COMPONENT_IMAGE_POPUP_MENU",ft="drawing-ui.config",Ge={},Ie={id:"sheet.operation.image-reset-size",type:h.CommandType.OPERATION,handler:(i,r)=>!0};var pt=Object.getOwnPropertyDescriptor,mt=(i,r,t,e)=>{for(var n=e>1?void 0:e?pt(r,t):r,a=i.length-1,s;a>=0;a--)(s=i[a])&&(n=s(n)||n);return n},Ve=(i,r)=>(t,e)=>r(t,e,i);let ve=class extends h.Disposable{constructor(i,r){super(),this._componentManager=i,this._commandService=r,this._init()}_initCustomComponents(){const i=this._componentManager;this.disposeWithMe(i.register(ke,He))}_initCommands(){[me,ee,Ie,fe,ue].forEach(i=>this.disposeWithMe(this._commandService.registerCommand(i)))}_init(){this._initCommands(),this._initCustomComponents()}};ve=mt([Ve(0,h.Inject(L.ComponentManager)),Ve(1,h.ICommandService)],ve);var vt=Object.getOwnPropertyDescriptor,wt=(i,r,t,e)=>{for(var n=e>1?void 0:e?vt(r,t):r,a=i.length-1,s;a>=0;a--)(s=i[a])&&(n=s(n)||n);return n},we=(i,r)=>(t,e)=>r(t,e,i);let Se=class extends h.Disposable{constructor(r,t,e,n){super();Q(this,"_sceneListenerOnDrawingMap",new WeakSet);this._currentUniverService=r,this._commandService=t,this._renderManagerService=e,this._drawingManagerService=n,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 r=this._drawingManagerService.drawingManagerData,t=Ee(this._currentUniverService);if(t==null)return;const{unitId:e,subUnitId:n}=t;Object.keys(r).forEach(a=>{Object.keys(r[a]).forEach(s=>{const o=r[a][s].data;o==null||a!==e||s!==n||Object.keys(o).forEach(c=>{o[c]&&this._insertDrawing([{unitId:a,subUnitId:s,drawingId:c}])})})})}_commandExecutedListener(){this.disposeWithMe(this._commandService.onCommandExecuted(r=>{if(r.id===fe.id){const t=r.params;if(t==null)return;this._drawingAlign(t)}}))}_drawingGroupListener(){this.disposeWithMe(this._drawingManagerService.group$.subscribe(r=>{this._groupDrawings(r)})),this.disposeWithMe(this._drawingManagerService.ungroup$.subscribe(r=>{this._ungroupDrawings(r)}))}_getSceneAndTransformerByDrawingSearch(r){if(r==null)return;const t=this._renderManagerService.getRenderById(r),e=t==null?void 0:t.scene;if(e==null)return null;const n=e.getTransformerByCreate();return{scene:e,transformer:n}}_groupDrawings(r){r.forEach(t=>{this._groupDrawing(t)})}_groupDrawing(r){const{parent:t,children:e}=r,{unitId:n,subUnitId:a,drawingId:s}=t,o=this._getSceneAndTransformerByDrawingSearch(t.unitId);if(o==null)return;const{scene:c,transformer:u}=o;this._commandService.syncExecuteCommand(ee.id);const l=[];if(e.forEach(p=>{const S=M.getDrawingShapeKeyByDrawingSearch(p),m=c.getObjectIncludeInGroup(S);if(m==null||l.includes(m))return;l.push(m);const{transform:v}=p;v!=null&&(m.classType===I.RENDER_CLASS_TYPE.GROUP?m.transformByState({left:v.left,top:v.top}):m.transformByState(v))}),l.length===0)return;const g=M.getDrawingShapeKeyByDrawingSearch({unitId:n,subUnitId:a,drawingId:s}),d=new I.Group(g);c.addObject(d,I.DRAWING_OBJECT_LAYER_INDEX).attachTransformerTo(d),d.addObjects(...l),t.transform&&d.transformByState({left:t.transform.left,top:t.transform.top}),u.clearSelectedObjects(),u.setSelectedControl(d)}_ungroupDrawings(r){r.forEach(t=>{this._ungroupDrawing(t)})}_ungroupDrawing(r){const{parent:t,children:e}=r,n=this._getSceneAndTransformerByDrawingSearch(t.unitId);if(n==null)return;const{scene:a,transformer:s}=n;e.forEach(g=>{const d=M.getDrawingShapeKeyByDrawingSearch(g),p=a.getObjectIncludeInGroup(d);if(p==null)return!0;if(p==null)return;const{transform:S}=g;S!=null&&(p.classType===I.RENDER_CLASS_TYPE.GROUP?p.transformByState({left:S.left,top:S.top}):p.transformByState(S))});const o=M.getDrawingShapeKeyByDrawingSearch(t),c=a.getObject(o),{width:u,height:l}=c;c.getObjects().forEach(g=>{c.removeSelfObjectAndTransform(g.oKey,u,l)}),c.dispose(),s.clearSelectedObjects()}_drawingAlign(r){const{alignType:t}=r,e=this._drawingManagerService.getFocusDrawings();if(t===R.default)return;const n=[];let a=Number.POSITIVE_INFINITY,s=Number.POSITIVE_INFINITY,o=Number.NEGATIVE_INFINITY,c=Number.NEGATIVE_INFINITY,u=0;e.forEach(l=>{const{unitId:g,subUnitId:d,drawingId:p,drawingType:S}=l,m=this._drawingManagerService.getDrawingByParam({unitId:g,subUnitId:d,drawingId:p});if(m==null||m.transform==null)return;n.push({unitId:g,subUnitId:d,drawingId:p,drawingType:S,transform:m.transform});const{left:v=0,top:C=0,width:y=0,height:O=0}=m.transform;a=Math.min(a,v),s=Math.min(s,C),o=Math.max(o,v+y),c=Math.max(c,C+O),u++}),u!==0&&(this._sortDrawingTransform(n,t),this._applyAlignType(n,t,a,s,o,c,u))}_applyAlignType(r,t,e,n,a,s,o){const c=Math.round((a-e)/o*10)/10,u=Math.round((s-n)/o*10)/10,l=[],g=this._getSceneAndTransformerByDrawingSearch(r[0].unitId);if(g==null)return;const{scene:d,transformer:p}=g;r.forEach((S,m)=>{const{unitId:v,subUnitId:C,drawingId:y,transform:O,drawingType:N}=S,{left:j=0,top:b=0,width:T=0,height:E=0}=O;let B=j,P=b;switch(t){case R.left:B=e;break;case R.center:B=e+(a-e)/2-T/2;break;case R.right:B=a-T;break;case R.top:P=n;break;case R.middle:P=n+(s-n)/2-E/2;break;case R.bottom:P=s-E;break;case R.horizon:B=e+c*m;break;case R.vertical:P=n+u*m;break}(B!==j||P!==b)&&l.push({unitId:v,subUnitId:C,drawingId:y,drawingType:N,transform:{left:B,top:P}})}),this._drawingManagerService.featurePluginUpdateNotification(l),p.refreshControls().changeNotification()}_sortDrawingTransform(r,t){r.sort((e,n)=>{const a=e.transform,s=n.transform,{left:o=0,top:c=0,width:u=0,height:l=0}=a,{left:g=0,top:d=0,width:p=0,height:S=0}=s;switch(t){case R.left:return o-g;case R.center:return o+u/2-(g+p/2);case R.right:return o+u-(g+p);case R.top:return c-d;case R.middle:return c+l/2-(d+S/2);case R.bottom:return c+l-(d+S);case R.horizon:return o+u/2-(g+p/2);case R.vertical:return c+l/2-(d+S/2);default:return 0}})}_drawingArrangeListener(){this.disposeWithMe(this._drawingManagerService.order$.subscribe(r=>{this._drawingArrange(r)}))}_drawingArrange(r){const{unitId:t,subUnitId:e,drawingIds:n}=r,a=this._getSceneAndTransformerByDrawingSearch(t);if(a==null)return;const{scene:s}=a;n.forEach(o=>{const c=M.getDrawingShapeKeyByDrawingSearch({unitId:t,subUnitId:e,drawingId:o}),u=s.fuzzyMathObjects(c,!0);if(u==null||u.length===0)return;const l=this._drawingManagerService.getDrawingOrder(t,e).indexOf(o);for(const g of u)g.setProps({zIndex:l}),g.makeDirty()})}_drawingAddListener(){this.disposeWithMe(this._drawingManagerService.add$.subscribe(r=>{this._insertDrawing(r)}))}_insertDrawing(r){const t=[];r.forEach(e=>{const{unitId:n}=e;if(this._drawingManagerService.getDrawingByParam(e)==null)return;const s=this._getSceneAndTransformerByDrawingSearch(n);if(s==null)return;const{scene:o}=s;t.includes(o)||t.push(o)}),t.forEach(e=>{this._sceneListenerOnDrawingMap.has(e)||(this._addListenerOnDrawing(e),this._sceneListenerOnDrawingMap.add(e))})}_drawingRemoveListener(){this.disposeWithMe(this._drawingManagerService.remove$.subscribe(r=>{r.forEach(t=>{var l;const{unitId:e,subUnitId:n,drawingId:a}=t,s=this._getSceneAndTransformerByDrawingSearch(e);if(s==null)return;const{scene:o}=s,c=M.getDrawingShapeKeyByDrawingSearch({unitId:e,subUnitId:n,drawingId:a}),u=o.fuzzyMathObjects(c,!0);if(u.length>0){for(const g of u)g.dispose();(l=o.getTransformer())==null||l.clearSelectedObjects()}})}))}_drawingUpdateListener(){this.disposeWithMe(this._drawingManagerService.update$.subscribe(r=>{r.forEach(t=>{var T;const{unitId:e,subUnitId:n,drawingId:a}=t,s=this._drawingManagerService.getDrawingByParam(t);if(s==null)return;const{transform:o,drawingType:c}=s,u=this._getSceneAndTransformerByDrawingSearch(e);if(u==null)return;const{scene:l,transformer:g}=u;if(o==null)return!0;const{left:d=0,top:p=0,width:S=0,height:m=0,angle:v=0,flipX:C=!1,flipY:y=!1,skewX:O=0,skewY:N=0}=o,j=M.getDrawingShapeKeyByDrawingSearch({unitId:e,subUnitId:n,drawingId:a}),b=l.getObject(j);if(b==null)return!0;b.transformByState({left:d,top:p,width:S,height:m,angle:v,flipX:C,flipY:y,skewX:O,skewY:N}),(T=l.getTransformer())==null||T.debounceRefreshControls()})}))}_drawingRefreshListener(){this.disposeWithMe(this._drawingManagerService.refreshTransform$.subscribe(r=>{r.forEach(t=>{const{unitId:e,subUnitId:n,drawingId:a}=t,s=this._getSceneAndTransformerByDrawingSearch(e);if(s==null)return;const o=this._drawingManagerService.getDrawingByParam(t);if(o==null)return;const{transform:c}=o,{scene:u}=s,l=M.getDrawingShapeKeyByDrawingSearch({unitId:e,subUnitId:n,drawingId:a}),g=u.getObject(l);if(g==null||c==null)return!0;const{left:d=0,top:p=0,width:S=0,height:m=0,angle:v=0,flipX:C=!1,flipY:y=!1,skewX:O=0,skewY:N=0}=c;g.transformByState({left:d,top:p,width:S,height:m,angle:v,flipX:C,flipY:y,skewX:O,skewY:N})})}))}_drawingVisibleListener(){this.disposeWithMe(this._drawingManagerService.visible$.subscribe(r=>{r.forEach(t=>{const{unitId:e,subUnitId:n,drawingId:a,visible:s}=t,o=this._getSceneAndTransformerByDrawingSearch(e);if(o==null)return;const{scene:c}=o,u=M.getDrawingShapeKeyByDrawingSearch({unitId:e,subUnitId:n,drawingId:a}),l=c.getObject(u);if(l==null)return!0;s?l.show():l.hide()})}))}_filterUpdateParams(r,t){return r.filter((e,n)=>{if(e==null)return!1;const{transform:a}=e;return h.checkIfMove(a,t==null?void 0:t[n])})}_addListenerOnDrawing(r){const t=r.getTransformerByCreate();let e=null;this.disposeWithMe(h.toDisposable(t.changeStart$.subscribe(n=>{const{objects:a}=n,s=Array.from(a.values()),o=[];e=s.map(c=>{const{left:u,top:l,height:g,width:d,angle:p,oKey:S,isInGroup:m}=c,v=this._drawingManagerService.getDrawingOKey(S);if(m||c instanceof I.Group){let C=c.ancestorGroup;if(C==null&&c instanceof I.Group&&(C=c),C==null)return null;const y=this._drawingManagerService.getDrawingOKey(C.oKey);if(y){const{unitId:O,subUnitId:N,drawingId:j}=y;o.push({unitId:O,subUnitId:N,drawingId:j});const{left:b,top:T,height:E,width:B,angle:P}=C;return{left:b,top:T,height:E,width:B,angle:P}}}else if(v!=null){const{unitId:C,subUnitId:y,drawingId:O}=v;return o.push({unitId:C,subUnitId:y,drawingId:O}),{left:u,top:l,height:g,width:d,angle:p}}return null}).filter(c=>c!=null),o.length>0?this._commandService.syncExecuteCommand(M.SetDrawingSelectedOperation.id,o):this._commandService.syncExecuteCommand(M.SetDrawingSelectedOperation.id,[])}))),this.disposeWithMe(h.toDisposable(t.changeEnd$.subscribe(n=>{const{objects:a}=n,s=this._filterUpdateParams(le(a,this._drawingManagerService),e);s.length>0&&this._drawingManagerService.featurePluginUpdateNotification(s)})))}};Se=wt([we(0,h.IUniverInstanceService),we(1,h.ICommandService),we(2,I.IRenderManagerService),we(3,M.IDrawingManagerService)],Se);class ge extends I.Shape{constructor(t,e){e==null&&(e={}),e.transformerConfig={keepRatio:!1,isCropper:!0,anchorFill:"rgb(0, 0, 0)",anchorStroke:"rgb(255, 255, 255)",anchorSize:24};super(t,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(t,e){this._srcRect=t,this._applyTransform=e,this._applyProps()}get srcRect(){return this._srcRect}dispose(){var t;super.dispose(),(t=this._cacheCanvas)==null||t.dispose(),this._srcRect=null}isHit(t){const e=this.getInverseCoord(t);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(t){const e=this._dragPadding;return t.x>=e-this.strokeWidth/2&&t.x<=this.width+this.strokeWidth/2-e&&t.y>=e-this.strokeWidth/2&&t.y<=this.height+this.strokeWidth/2-e}render(t,e){return this.visible?(t.save(),this._draw(t),t.restore(),this.makeDirty(!1),this):(this.makeDirty(!1),this)}_draw(t){var c,u;const n=this.getScene().getEngine(),{width:a,height:s}=n;this._initialCacheCanvas(),(c=this._cacheCanvas)==null||c.clear();const o=(u=this._cacheCanvas)==null?void 0:u.getContext();o!=null&&(o.save(),I.Rect.drawWith(o,{left:0,top:0,width:a,height:s,fill:"rgba(0, 0, 0, 0.5)"}),o.setTransform(t.getTransform()),this._clipForApplyObject(o),this._applyCache(t),o.restore())}_clipForApplyObject(t){let e=0;if(this._prstGeom!=null&&(e=1),t.globalCompositeOperation="destination-out",t.beginPath(),e===0){const n=this.transform.getMatrix();t.transform(n[0],n[1],n[2],n[3],n[4],n[5]),t.rect(0,0,this.width,this.height),t.fill()}}_applyProps(){if(this._applyTransform==null)return;let t=0,e=0,n=0,a=0;const{left:s=0,top:o=0,width:c=0,height:u=0,angle:l}=this._applyTransform;if(this._srcRect!=null){const{left:p=0,top:S=0,right:m=0,bottom:v=0}=this._srcRect;t=p,e=S,n=m,a=v}const g=s+t,d=o+e;this.transformByState({left:g,top:d,width:s+c-n-g,height:o+u-a-d,angle:l})}_applyCache(t){if(!t||this._cacheCanvas==null)return;const e=this._cacheCanvas.getContext();e.save(),t.save(),t.setTransform(1,0,0,1,0,0),e.setTransform(1,0,0,1,0,0),t.drawImage(this._cacheCanvas.getCanvasEle(),0,0),t.restore(),e.restore()}_initialCacheCanvas(){if(this._cacheCanvas!=null)return;const t=this.getScene();if(t==null)return;this._cacheCanvas=new I.Canvas;const e=t.getEngine();this._cacheCanvas.setSize(e.width,e.height),e.onTransformChange$.subscribeEvent(()=>{var n;(n=this._cacheCanvas)==null||n.setSize(e.width,e.height),this.makeDirty(!0)})}}var St=Object.getOwnPropertyDescriptor,_t=(i,r,t,e)=>{for(var n=e>1?void 0:e?St(r,t):r,a=i.length-1,s;a>=0;a--)(s=i[a])&&(n=s(n)||n);return n},se=(i,r)=>(t,e)=>r(t,e,i);let _e=class extends h.Disposable{constructor(r,t,e,n,a,s){super();Q(this,"_sceneListenerOnImageMap",new WeakSet);this._commandService=r,this._drawingManagerService=t,this._renderManagerService=e,this._univerInstanceService=n,this._messageService=a,this._localeService=s,this._init()}_init(){this._initOpenCrop(),this._initCloseCrop(),this._initAutoCrop()}_initAutoCrop(){this.disposeWithMe(this._commandService.onCommandExecuted(r=>{if(r.id!==ue.id)return;const t=r.params;if(t==null)return;const{cropType:e}=t,n=this._drawingManagerService.getFocusDrawings();if(n.length!==1)return;const a=n[0],{unitId:s,subUnitId:o,drawingId:c}=a,u=this._renderManagerService.getRenderById(s),l=u==null?void 0:u.scene;if(l==null)return!0;this._searchCropObject(l)!=null&&this._commandService.syncExecuteCommand(ee.id,{isAuto:!0});const d=M.getDrawingShapeKeyByDrawingSearch({unitId:s,subUnitId:o,drawingId:c}),p=l.getObject(d);if(!(p instanceof I.Image)){this._messageService.show({type:U.MessageType.Error,content:this._localeService.t("image-cropper.error")});return}p!=null&&(this._updateCropperObject(e,p),this._commandService.executeCommand(me.id,{unitId:s,subUnitId:o,drawingId:c}))}))}_calculateSrcRectByRatio(r,t,e,n,a,s){const o=e/n,c=a/s;let u=e,l=n;o>c?u=n*c:l=e/c;const g=(e-u)/2,d=(n-l)/2;return{left:I.precisionTo(g,1),top:I.precisionTo(d,1),right:I.precisionTo(e-(g+u),1),bottom:I.precisionTo(n-(d+l),1)}}_updateCropperObject(r,t){const{left:e,top:n,width:a,height:s}=t.calculateTransformWithSrcRect();let o;switch(r){case A.R1_1:o=this._calculateSrcRectByRatio(e,n,a,s,1,1);break;case A.R16_9:o=this._calculateSrcRectByRatio(e,n,a,s,16,9);break;case A.R9_16:o=this._calculateSrcRectByRatio(e,n,a,s,9,16);break;case A.R5_4:o=this._calculateSrcRectByRatio(e,n,a,s,5,4);break;case A.R4_5:o=this._calculateSrcRectByRatio(e,n,a,s,4,5);break;case A.R4_3:o=this._calculateSrcRectByRatio(e,n,a,s,4,3);break;case A.R3_4:o=this._calculateSrcRectByRatio(e,n,a,s,3,4);break;case A.R3_2:o=this._calculateSrcRectByRatio(e,n,a,s,3,2);break;case A.R2_3:o=this._calculateSrcRectByRatio(e,n,a,s,2,3);break;case A.FREE:}if(o==null)return;t.setSrcRect(o);const{left:c=0,top:u=0,bottom:l=0,right:g=0}=o;t.transformByStateCloseCropper({left:e+c,top:n+u,width:a-g-c,height:s-l-u})}_initOpenCrop(){this.disposeWithMe(this._commandService.onCommandExecuted(r=>{if(r.id!==me.id)return;const t=r.params;if(t==null)return;const{unitId:e,subUnitId:n,drawingId:a}=t,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:n,drawingId:a})==null)return;const u=M.getDrawingShapeKeyByDrawingSearch({unitId:e,subUnitId:n,drawingId:a}),l=o.getObject(u);if(l==null)return;if(!(l instanceof I.Image)){this._messageService.show({type:U.MessageType.Error,content:this._localeService.t("image-cropper.error")});return}const g=o.getTransformer();g==null||g.clearControls();const d=new ge(`${u}-crop`,{srcRect:l.srcRect,prstGeom:l.prstGeom,applyTransform:l.calculateTransformWithSrcRect()});o.addObject(d,l.getLayerIndex()+1).attachTransformerTo(d),g==null||g.createControlForCopper(d),this._addHoverForImageCopper(d),l.openRenderByCropper(),g==null||g.refreshControls(),d.makeDirty(!0),this._commandService.syncExecuteCommand(M.SetDrawingSelectedOperation.id,[{unitId:e,subUnitId:n,drawingId:a}])}))}_searchCropObject(r){const t=r.getAllObjectsByOrder();for(const e of t)if(e instanceof ge)return e}_initCloseCrop(){this.disposeWithMe(this._commandService.onCommandExecuted(t=>{if(t.id!==ee.id)return;const e=this._univerInstanceService.getFocusedUnit();if(e==null)return;const n=e.getUnitId(),a=this._renderManagerService.getRenderById(n),s=a==null?void 0:a.scene;if(s==null)return!0;const o=this._searchCropObject(s);if(o==null)return;const c=this._getApplyObjectByCropObject(o);if(c==null)return;const u=s.getTransformerByCreate();u.detachFrom(o),u.clearCopperControl();const l=this._getSrcRectByTransformState(c,o),g=this._drawingManagerService.getDrawingOKey(c.oKey);if(g!=null){const{left:d,top:p,height:S,width:m}=o;this._drawingManagerService.featurePluginUpdateNotification([{...g,transform:{...g.transform,left:d,top:p,height:S,width:m},srcRect:l.srcRectAngle}])}c.setSrcRect({...l.srcRectAngle}),c.closeRenderByCropper(),c.makeDirty(!0),o==null||o.dispose()}));const r=this._univerInstanceService.getCurrentTypeOfUnit$(h.UniverInstanceType.UNIVER_SHEET).pipe(Me.switchMap(t=>t?t.activeSheet$:Me.of(null)));this.disposeWithMe(r.subscribe(()=>{this._commandService.syncExecuteCommand(ee.id)}))}_getApplyObjectByCropObject(r){const t=r.oKey,e=t.slice(0,t.length-5),n=r.getScene();if(!n)return null;const a=n.getObject(e);return a==null?null:a}_addListenerOnImage(r){const t=r.getTransformerByCreate();let e=null;this.disposeWithMe(t.changeStart$.subscribe(n=>{const{objects:a}=n,s=a.values().next().value;if(s==null||!(s instanceof ge))return;const{left:o,top:c,height:u,width:l,angle:g}=s;e={left:o,top:c,height:u,width:l,angle:g},t.clearCopperControl()})),this.disposeWithMe(t.changeEnd$.subscribe(n=>{const{objects:a}=n,s=a.values().next().value;if(s==null||!(s instanceof ge))return;const{left:o,top:c,height:u,width:l,angle:g}=s;if(!h.checkIfMove({left:o,top:c,height:u,width:l,angle:g},e))return;const d=this._getApplyObjectByCropObject(s);if(d==null)return;const p=this._getSrcRectByTransformState(d,s);s.refreshSrcRect(p.srcRect,d.getState()),t.createControlForCopper(s)})),this._endCropListener(r)}_addHoverForImageCopper(r){this.disposeWithMe(r.onPointerEnter$.subscribeEvent(()=>{r.cursor=I.CURSOR_TYPE.MOVE})),this.disposeWithMe(r.onPointerLeave$.subscribeEvent(()=>{r.cursor=I.CURSOR_TYPE.DEFAULT}))}_endCropListener(r){const t=r.getTransformerByCreate();this.disposeWithMe(t.clearControl$.subscribe(e=>{e===!0&&this._commandService.syncExecuteCommand(ee.id)}))}_getSrcRectByTransformState(r,t){const{left:e,top:n,height:a,width:s,strokeWidth:o,angle:c}=t,{left:u,top:l,width:g,height:d,angle:p,strokeWidth:S}=r,m=e-u,v=n-l,C={left:m,top:v,right:g-m-s,bottom:d-v-a},y={...C};if(p!==0){const O=e+s/2,N=n+a/2,j=new I.Vector2(O,N),b=g/2+u,T=d/2+l,E=new I.Vector2(b,T),B=new I.Vector2(u,l);B.rotateByPoint(I.degToRad(p),E);const P=B.clone();P.rotateByPoint(I.degToRad(-p),j);const G=e-P.x,H=n-P.y;y.left=G,y.top=H,y.right=g-G-s,y.bottom=d-H-a}return{srcRect:C,srcRectAngle:y}}};_e=_t([se(0,h.ICommandService),se(1,M.IDrawingManagerService),se(2,I.IRenderManagerService),se(3,h.IUniverInstanceService),se(4,L.IMessageService),se(5,h.Inject(h.LocaleService))],_e);var Ct=Object.getOwnPropertyDescriptor,yt=(i,r,t,e)=>{for(var n=e>1?void 0:e?Ct(r,t):r,a=i.length-1,s;a>=0;a--)(s=i[a])&&(n=s(n)||n);return n},re=(i,r)=>(t,e)=>r(t,e,i);let Ce=class extends h.Disposable{constructor(i,r,t,e,n,a,s){super(),this._commandService=i,this._renderManagerService=r,this._drawingManagerService=t,this._dialogService=e,this._imageIoService=n,this._currentUniverService=a,this._drawingRenderService=s,this._initialize()}dispose(){super.dispose()}_initialize(){this._drawingAddListener(),this._commandExecutedListener(),this._imageUpdateListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.onCommandExecuted(i=>{if(i.id===Ie.id){const r=i.params;if(r==null)return;this._resetImageSize(r)}}))}_getSceneAndTransformerByDrawingSearch(i){if(i==null)return;const r=this._renderManagerService.getRenderById(i),t=r==null?void 0:r.scene;if(t==null)return null;const e=t.getTransformerByCreate();return{scene:t,transformer:e}}_resetImageSize(i){const r=[],t=[];i.forEach(e=>{const{unitId:n,subUnitId:a,drawingId:s}=e,o=this._getSceneAndTransformerByDrawingSearch(n);if(o==null)return;const{scene:c}=o,u=M.getDrawingShapeKeyByDrawingSearch({unitId:n,subUnitId:a,drawingId:s}),l=c.getObject(u);if(l==null)return!0;const g=this._drawingManagerService.getDrawingByParam(e);if(g==null)return!0;if(g.drawingType!==h.DrawingTypeEnum.DRAWING_IMAGE)return;l.resetSize();const{width:d,height:p}=l.getNativeSize();t.includes(c)===!1&&t.push(c),r.push({...g,transform:{...g.transform,height:p,width:d,angle:0},srcRect:null,prstGeom:null})}),this._drawingManagerService.featurePluginUpdateNotification(r),t.forEach(e=>{e.getTransformerByCreate().refreshControls().changeNotification()}),this._commandService.syncExecuteCommand(M.SetDrawingSelectedOperation.id,i)}_drawingAddListener(){this.disposeWithMe(this._drawingManagerService.add$.subscribe(i=>{this._insertImages(i)}))}_insertImages(i){i.forEach(async r=>{var c;const{unitId:t,subUnitId:e}=r,n=this._getSceneAndTransformerByDrawingSearch(t),a=(c=Ee(this._currentUniverService,t))==null?void 0:c.subUnitId;if(n==null||a!==e)return;const s=this._drawingManagerService.getDrawingByParam(r);if(s==null)return;const o=await this._drawingRenderService.renderImages(s,n.scene);if(this._drawingManagerService.refreshTransform([s]),!(o==null||o.length===0))for(const u of o)this._addHoverForImage(u),this._addDialogForImage(u)})}_imageUpdateListener(){this.disposeWithMe(this._drawingManagerService.update$.subscribe(i=>{i.forEach(r=>{const{unitId:t,subUnitId:e,drawingId:n}=r,a=this._drawingManagerService.getDrawingByParam(r);if(a==null)return;const{transform:s,drawingType:o,srcRect:c,prstGeom:u,source:l,imageSourceType:g}=a;if(o!==h.DrawingTypeEnum.DRAWING_IMAGE)return;const d=this._getSceneAndTransformerByDrawingSearch(t);if(d==null)return;const{scene:p,transformer:S}=d;if(s==null)return!0;const m=M.getDrawingShapeKeyByDrawingSearch({unitId:t,subUnitId:e,drawingId:n}),v=p.getObject(m);if(v==null)return!0;v.setSrcRect(c),v.setPrstGeom(u),l!=null&&l.length>0&&(g===h.ImageSourceType.BASE64||g===h.ImageSourceType.URL)&&v.changeSource(l)})}))}_addHoverForImage(i){this.disposeWithMe(h.toDisposable(i.onPointerEnter$.subscribeEvent(()=>{i.cursor=I.CURSOR_TYPE.GRAB}))),this.disposeWithMe(h.toDisposable(i.onPointerLeave$.subscribeEvent(()=>{i.cursor=I.CURSOR_TYPE.DEFAULT})))}_addDialogForImage(i){this.disposeWithMe(h.toDisposable(i.onDblclick$.subscribeEvent(()=>{const r=`${i.oKey}-viewer-dialog`;this._drawingRenderService.previewImage(r,i.getNative().src,i.getNativeSize().width,i.getNativeSize().height)})))}};Ce=yt([re(0,h.ICommandService),re(1,I.IRenderManagerService),re(2,M.IDrawingManagerService),re(3,L.IDialogService),re(4,M.IImageIoService),re(5,h.IUniverInstanceService),re(6,h.Inject(D.DrawingRenderService))],Ce);var It=Object.getOwnPropertyDescriptor,bt=(i,r,t,e)=>{for(var n=e>1?void 0:e?It(r,t):r,a=i.length-1,s;a>=0;a--)(s=i[a])&&(n=s(n)||n);return n},We=(i,r)=>(t,e)=>r(t,e,i);const Dt="UNIVER_DRAWING_UI_PLUGIN";D.UniverDrawingUIPlugin=(be=class extends h.Plugin{constructor(r=Ge,t,e){super(),this._config=r,this._injector=t,this._configService=e;const{menu:n,...a}=h.merge({},Ge,this._config);n&&this._configService.setConfig("menu",n,{merge:!0}),this._configService.setConfig(ft,a)}onStarting(){this._initDependencies()}onRendered(){this._injector.get(Se),this._injector.get(ve),this._injector.get(_e),this._injector.get(Ce)}_initDependencies(){[[D.DrawingRenderService],[Se],[ve],[_e],[Ce]].forEach(t=>this._injector.add(t))}},Q(be,"pluginName",Dt),be),D.UniverDrawingUIPlugin=bt([We(1,h.Inject(h.Injector)),We(2,h.IConfigService)],D.UniverDrawingUIPlugin),D.AutoImageCropOperation=ue,D.COMPONENT_IMAGE_POPUP_MENU=ke,D.CloseImageCropOperation=ee,D.DrawingCommonPanel=ht,D.ImageCropperObject=ge,D.ImagePopupMenu=He,D.ImageResetSizeOperation=Ie,D.OpenImageCropOperation=me,D.SetDrawingAlignOperation=fe,D.getUpdateParams=le,Object.defineProperty(D,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@univerjs/drawing-ui",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.1-nightly.202506131607",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "",
|
|
6
6
|
"author": "DreamNum <developer@univer.ai>",
|
|
@@ -53,21 +53,21 @@
|
|
|
53
53
|
},
|
|
54
54
|
"dependencies": {
|
|
55
55
|
"@univerjs/icons": "^0.4.4",
|
|
56
|
-
"@univerjs/
|
|
57
|
-
"@univerjs/
|
|
58
|
-
"@univerjs/
|
|
59
|
-
"@univerjs/
|
|
60
|
-
"@univerjs/
|
|
56
|
+
"@univerjs/core": "0.8.1-nightly.202506131607",
|
|
57
|
+
"@univerjs/design": "0.8.1-nightly.202506131607",
|
|
58
|
+
"@univerjs/drawing": "0.8.1-nightly.202506131607",
|
|
59
|
+
"@univerjs/engine-render": "0.8.1-nightly.202506131607",
|
|
60
|
+
"@univerjs/ui": "0.8.1-nightly.202506131607"
|
|
61
61
|
},
|
|
62
62
|
"devDependencies": {
|
|
63
|
-
"postcss": "^8.5.
|
|
63
|
+
"postcss": "^8.5.4",
|
|
64
64
|
"react": "18.3.1",
|
|
65
65
|
"rxjs": "^7.8.2",
|
|
66
66
|
"tailwindcss": "^3.4.17",
|
|
67
67
|
"typescript": "^5.8.3",
|
|
68
68
|
"vite": "^6.3.5",
|
|
69
69
|
"vitest": "^3.1.4",
|
|
70
|
-
"@univerjs-infra/shared": "0.8.
|
|
70
|
+
"@univerjs-infra/shared": "0.8.1"
|
|
71
71
|
},
|
|
72
72
|
"scripts": {
|
|
73
73
|
"test": "vitest run",
|
package/LICENSE
DELETED
|
@@ -1,176 +0,0 @@
|
|
|
1
|
-
Apache License
|
|
2
|
-
Version 2.0, January 2004
|
|
3
|
-
http://www.apache.org/licenses/
|
|
4
|
-
|
|
5
|
-
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
-
|
|
7
|
-
1. Definitions.
|
|
8
|
-
|
|
9
|
-
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
-
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
-
|
|
12
|
-
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
-
the copyright owner that is granting the License.
|
|
14
|
-
|
|
15
|
-
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
-
other entities that control, are controlled by, or are under common
|
|
17
|
-
control with that entity. For the purposes of this definition,
|
|
18
|
-
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
-
direction or management of such entity, whether by contract or
|
|
20
|
-
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
-
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
-
|
|
23
|
-
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
-
exercising permissions granted by this License.
|
|
25
|
-
|
|
26
|
-
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
-
including but not limited to software source code, documentation
|
|
28
|
-
source, and configuration files.
|
|
29
|
-
|
|
30
|
-
"Object" form shall mean any form resulting from mechanical
|
|
31
|
-
transformation or translation of a Source form, including but
|
|
32
|
-
not limited to compiled object code, generated documentation,
|
|
33
|
-
and conversions to other media types.
|
|
34
|
-
|
|
35
|
-
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
-
Object form, made available under the License, as indicated by a
|
|
37
|
-
copyright notice that is included in or attached to the work
|
|
38
|
-
(an example is provided in the Appendix below).
|
|
39
|
-
|
|
40
|
-
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
-
form, that is based on (or derived from) the Work and for which the
|
|
42
|
-
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
-
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
-
of this License, Derivative Works shall not include works that remain
|
|
45
|
-
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
-
the Work and Derivative Works thereof.
|
|
47
|
-
|
|
48
|
-
"Contribution" shall mean any work of authorship, including
|
|
49
|
-
the original version of the Work and any modifications or additions
|
|
50
|
-
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
-
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
-
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
-
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
-
means any form of electronic, verbal, or written communication sent
|
|
55
|
-
to the Licensor or its representatives, including but not limited to
|
|
56
|
-
communication on electronic mailing lists, source code control systems,
|
|
57
|
-
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
-
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
-
excluding communication that is conspicuously marked or otherwise
|
|
60
|
-
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
-
|
|
62
|
-
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
-
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
-
subsequently incorporated within the Work.
|
|
65
|
-
|
|
66
|
-
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
-
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
-
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
-
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
-
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
-
Work and such Derivative Works in Source or Object form.
|
|
72
|
-
|
|
73
|
-
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
-
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
-
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
-
(except as stated in this section) patent license to make, have made,
|
|
77
|
-
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
-
where such license applies only to those patent claims licensable
|
|
79
|
-
by such Contributor that are necessarily infringed by their
|
|
80
|
-
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
-
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
-
institute patent litigation against any entity (including a
|
|
83
|
-
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
-
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
-
or contributory patent infringement, then any patent licenses
|
|
86
|
-
granted to You under this License for that Work shall terminate
|
|
87
|
-
as of the date such litigation is filed.
|
|
88
|
-
|
|
89
|
-
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
-
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
-
modifications, and in Source or Object form, provided that You
|
|
92
|
-
meet the following conditions:
|
|
93
|
-
|
|
94
|
-
(a) You must give any other recipients of the Work or
|
|
95
|
-
Derivative Works a copy of this License; and
|
|
96
|
-
|
|
97
|
-
(b) You must cause any modified files to carry prominent notices
|
|
98
|
-
stating that You changed the files; and
|
|
99
|
-
|
|
100
|
-
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
-
that You distribute, all copyright, patent, trademark, and
|
|
102
|
-
attribution notices from the Source form of the Work,
|
|
103
|
-
excluding those notices that do not pertain to any part of
|
|
104
|
-
the Derivative Works; and
|
|
105
|
-
|
|
106
|
-
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
-
distribution, then any Derivative Works that You distribute must
|
|
108
|
-
include a readable copy of the attribution notices contained
|
|
109
|
-
within such NOTICE file, excluding those notices that do not
|
|
110
|
-
pertain to any part of the Derivative Works, in at least one
|
|
111
|
-
of the following places: within a NOTICE text file distributed
|
|
112
|
-
as part of the Derivative Works; within the Source form or
|
|
113
|
-
documentation, if provided along with the Derivative Works; or,
|
|
114
|
-
within a display generated by the Derivative Works, if and
|
|
115
|
-
wherever such third-party notices normally appear. The contents
|
|
116
|
-
of the NOTICE file are for informational purposes only and
|
|
117
|
-
do not modify the License. You may add Your own attribution
|
|
118
|
-
notices within Derivative Works that You distribute, alongside
|
|
119
|
-
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
-
that such additional attribution notices cannot be construed
|
|
121
|
-
as modifying the License.
|
|
122
|
-
|
|
123
|
-
You may add Your own copyright statement to Your modifications and
|
|
124
|
-
may provide additional or different license terms and conditions
|
|
125
|
-
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
-
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
-
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
-
the conditions stated in this License.
|
|
129
|
-
|
|
130
|
-
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
-
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
-
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
-
this License, without any additional terms or conditions.
|
|
134
|
-
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
-
the terms of any separate license agreement you may have executed
|
|
136
|
-
with Licensor regarding such Contributions.
|
|
137
|
-
|
|
138
|
-
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
-
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
-
except as required for reasonable and customary use in describing the
|
|
141
|
-
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
-
|
|
143
|
-
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
-
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
-
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
-
implied, including, without limitation, any warranties or conditions
|
|
148
|
-
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
-
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
-
appropriateness of using or redistributing the Work and assume any
|
|
151
|
-
risks associated with Your exercise of permissions under this License.
|
|
152
|
-
|
|
153
|
-
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
-
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
-
unless required by applicable law (such as deliberate and grossly
|
|
156
|
-
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
-
liable to You for damages, including any direct, indirect, special,
|
|
158
|
-
incidental, or consequential damages of any character arising as a
|
|
159
|
-
result of this License or out of the use or inability to use the
|
|
160
|
-
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
-
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
-
other commercial damages or losses), even if such Contributor
|
|
163
|
-
has been advised of the possibility of such damages.
|
|
164
|
-
|
|
165
|
-
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
-
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
-
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
-
or other liability obligations and/or rights consistent with this
|
|
169
|
-
License. However, in accepting such obligations, You may act only
|
|
170
|
-
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
-
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
-
defend, and hold each Contributor harmless for any liability
|
|
173
|
-
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
-
of your accepting any such warranty or additional liability.
|
|
175
|
-
|
|
176
|
-
END OF TERMS AND CONDITIONS
|