@univerjs/preset-sheets-drawing 0.15.5 → 0.16.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/umd/index.js CHANGED
@@ -3,7 +3,7 @@
3
3
 
4
4
 
5
5
  // @univerjs/drawing-ui/index
6
- (function(y,h){typeof exports=="object"&&typeof module<"u"?h(exports,require("@univerjs/core"),require("@univerjs/drawing"),require("@univerjs/engine-render"),require("@univerjs/ui"),require("react/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):(y=typeof globalThis<"u"?globalThis:y||self,h(y.UniverDrawingUi={},y.UniverCore,y.UniverDrawing,y.UniverEngineRender,y.UniverUi,y.React,y.UniverDesign,y.React,y.rxjs))})(this,(function(y,h,M,b,H,f,B,_,te){"use strict";var Et=Object.defineProperty;var Tt=(y,h,M)=>h in y?Et(y,h,{enumerable:!0,configurable:!0,writable:!0,value:M}):y[h]=M;var Q=(y,h,M)=>Tt(y,typeof h!="symbol"?h+"":h,M);var Ee;var R=(s=>(s.default="0",s.left="1",s.center="2",s.right="3",s.top="4",s.middle="5",s.bottom="6",s.horizon="7",s.vertical="8",s))(R||{});const pe={id:"sheet.operation.set-image-align",type:h.CommandType.OPERATION,handler:(s,r)=>!0},me={id:"sheet.operation.open-image-crop",type:h.CommandType.OPERATION,handler:(s,r)=>!0},ee={id:"sheet.operation.close-image-crop",type:h.CommandType.OPERATION,handler:(s,r)=>!0};var L=(s=>(s.FREE="0",s.R1_1="1",s.R16_9="2",s.R9_16="3",s.R5_4="4",s.R4_5="5",s.R4_3="6",s.R3_4="7",s.R3_2="8",s.R2_3="9",s))(L||{});const ce={id:"sheet.operation.Auto-image-crop",type:h.CommandType.OPERATION,handler:(s,r)=>!0},De={id:"sheet.operation.image-reset-size",type:h.CommandType.OPERATION,handler:(s,r)=>!0};function Me(s,r,e,t){const n=t.getDrawingByParam(s);if(n==null)return;const i=M.getDrawingShapeKeyByDrawingSearch(s),a=e.getObject(i);if(a&&!(a instanceof b.Group))return;if(a!=null){a.addObject(r);return}const o=new b.Group(i);e.addObject(o,b.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 Oe(s,r){var i;const e=r?s.getUnit(r):s.getFocusedUnit();if(e==null)return;const t=e.getUnitId();let n;return e.type===h.UniverInstanceType.UNIVER_SHEET?n=(i=e.getActiveSheet())==null?void 0:i.getSheetId():(e.type===h.UniverInstanceType.UNIVER_DOC||e.type===h.UniverInstanceType.UNIVER_SLIDE)&&(n=t),{unitId:t,subUnitId:n,current:e}}const Ze="drawing-ui.config",Te={},Ue="COMPONENT_IMAGE_POPUP_MENU";function F({ref:s,...r}){const{icon:e,id:t,className:n,extend:i,...a}=r,o=`univerjs-icon univerjs-icon-${t} ${n||""}`.trim(),c=_.useRef(`_${Ye()}`);return Pe(e,`${t}`,{defIds:e.defIds,idSuffix:c.current},{ref:s,className:o,...a},i)}function Pe(s,r,e,t,n){return _.createElement(s.tag,{key:r,...Fe(s,e,n),...t},(ze(s,e).children||[]).map((i,a)=>Pe(i,`${r}-${s.tag}-${a}`,e,void 0,n)))}function Fe(s,r,e){const t={...s.attrs};e!=null&&e.colorChannel1&&t.fill==="colorChannel1"&&(t.fill=e.colorChannel1),s.tag==="mask"&&t.id&&(t.id=t.id+r.idSuffix),Object.entries(t).forEach(([i,a])=>{i==="mask"&&typeof a=="string"&&(t[i]=a.replace(/url\(#(.*)\)/,`url(#$1${r.idSuffix})`))});const{defIds:n}=r;return!n||n.length===0||(s.tag==="use"&&t["xlink:href"]&&(t["xlink:href"]=t["xlink:href"]+r.idSuffix),Object.entries(t).forEach(([i,a])=>{typeof a=="string"&&(t[i]=a.replace(/url\(#(.*)\)/,`url(#$1${r.idSuffix})`))})),t}function ze(s,r){var t;const{defIds:e}=r;return!e||e.length===0?s:s.tag==="defs"&&((t=s.children)!=null&&t.length)?{...s,children:s.children.map(n=>typeof n.attrs.id=="string"&&e&&e.includes(n.attrs.id)?{...n,attrs:{...n.attrs,id:n.attrs.id+r.idSuffix}}:n)}:s}function Ye(){return Math.random().toString(36).substring(2,8)}F.displayName="UniverIcon";const Xe={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(r,e){return _.createElement(F,Object.assign({},r,{id:"bottom-icon",ref:e,icon:Xe}))});Ne.displayName="BottomIcon";const qe={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{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(r,e){return _.createElement(F,Object.assign({},r,{id:"create-copy-icon",ref:e,icon:qe}))});Be.displayName="CreateCopyIcon";const Je={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"}}]},Re=_.forwardRef(function(r,e){return _.createElement(F,Object.assign({},r,{id:"group-icon",ref:e,icon:Je}))});Re.displayName="GroupIcon";const Qe={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{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"}}]},je=_.forwardRef(function(r,e){return _.createElement(F,Object.assign({},r,{id:"more-down-icon",ref:e,icon:Qe}))});je.displayName="MoreDownIcon";const 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:"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"}}]},Ae=_.forwardRef(function(r,e){return _.createElement(F,Object.assign({},r,{id:"move-down-icon",ref:e,icon:et}))});Ae.displayName="MoveDownIcon";const tt={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"}}]},Le=_.forwardRef(function(r,e){return _.createElement(F,Object.assign({},r,{id:"move-up-icon",ref:e,icon:tt}))});Le.displayName="MoveUpIcon";const rt={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"}}]},He=_.forwardRef(function(r,e){return _.createElement(F,Object.assign({},r,{id:"topmost-icon",ref:e,icon:rt}))});He.displayName="TopmostIcon";const nt={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"}}]},xe=_.forwardRef(function(r,e){return _.createElement(F,Object.assign({},r,{id:"ungroup-icon",ref:e,icon:nt}))});xe.displayName="UngroupIcon";const 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:"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"}}]},ke=_.forwardRef(function(r,e){return _.createElement(F,Object.assign({},r,{id:"autofill-double-icon",ref:e,icon:it}))});ke.displayName="AutofillDoubleIcon";function $e(s){var m;const{popup:r}=s,e=(m=r==null?void 0:r.extraProps)==null?void 0:m.menuItems;if(!e)return null;const t=H.useDependency(h.ICommandService),n=H.useDependency(h.LocaleService),[i,a]=_.useState(!1),[o,c]=_.useState(!1),u=()=>{c(!0)},l=()=>{c(!1)},g=v=>{a(v)},d=v=>{t.executeCommand(v.commandId,v.commandParams),a(!1)},p=i||o,S=e.filter(v=>!v.disable);return f.jsx("div",{onMouseEnter:u,onMouseLeave:l,children:f.jsx(B.DropdownMenu,{align:"start",items:S.map(v=>({type:"item",children:n.t(v.label),onSelect:()=>d(v)})),open:i,onOpenChange:g,children:f.jsxs("div",{className:B.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",B.borderClassName,{"univer-bg-gray-100 dark:!univer-bg-gray-800":i,"univer-bg-white dark:!univer-bg-gray-900":!i}),children:[f.jsx(ke,{className:"univer-fill-primary-600 univer-text-gray-900 dark:!univer-text-white"}),p&&f.jsx(je,{className:"dark:!univer-text-white"})]})})})}var at=Object.getOwnPropertyDescriptor,st=(s,r,e,t)=>{for(var n=t>1?void 0:t?at(r,e):r,i=s.length-1,a;i>=0;i--)(a=s[i])&&(n=a(n)||n);return n},Ge=(s,r)=>(e,t)=>r(e,t,s);let ve=class extends h.Disposable{constructor(s,r){super(),this._componentManager=s,this._commandService=r,this._init()}_initCustomComponents(){const s=this._componentManager;this.disposeWithMe(s.register(Ue,$e))}_initCommands(){[me,ee,De,pe,ce].forEach(s=>this.disposeWithMe(this._commandService.registerCommand(s)))}_init(){this._initCommands(),this._initCustomComponents()}};ve=st([Ge(0,h.Inject(H.ComponentManager)),Ge(1,h.ICommandService)],ve);function le(s,r){const e=[];return s.forEach(t=>{const{oKey:n,left:i,top:a,height:o,width:c,angle:u}=t,l=r.getDrawingOKey(n);if(l==null)return e.push(null),!0;const{unitId:g,subUnitId:d,drawingId:p,drawingType:S}=l,m={unitId:g,subUnitId:d,drawingId:p,drawingType:S,transform:{left:i,top:a,height:o,width:c,angle:u}};S===h.DrawingTypeEnum.DRAWING_IMAGE&&(m.srcRect=t.srcRect),e.push(m)}),e}var ot=Object.getOwnPropertyDescriptor,ct=(s,r,e,t)=>{for(var n=t>1?void 0:t?ot(r,e):r,i=s.length-1,a;i>=0;i--)(a=s[i])&&(n=a(n)||n);return n},we=(s,r)=>(e,t)=>r(e,t,s);let Se=class extends h.Disposable{constructor(r,e,t,n){super();Q(this,"_sceneListenerOnDrawingMap",new WeakSet);this._currentUniverService=r,this._commandService=e,this._renderManagerService=t,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,e=Oe(this._currentUniverService);if(e==null)return;const{unitId:t,subUnitId:n}=e;Object.keys(r).forEach(i=>{Object.keys(r[i]).forEach(a=>{const o=r[i][a].data;o==null||i!==t||a!==n||Object.keys(o).forEach(c=>{o[c]&&this._insertDrawing([{unitId:i,subUnitId:a,drawingId:c}])})})})}_commandExecutedListener(){this.disposeWithMe(this._commandService.onCommandExecuted(r=>{if(r.id===pe.id){const e=r.params;if(e==null)return;this._drawingAlign(e)}}))}_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 e=this._renderManagerService.getRenderById(r),t=e==null?void 0:e.scene;if(t==null)return null;const n=t.getTransformerByCreate();return{scene:t,transformer:n}}_groupDrawings(r){r.forEach(e=>{this._groupDrawing(e)})}_groupDrawing(r){const{parent:e,children:t}=r,{unitId:n,subUnitId:i,drawingId:a}=e,o=this._getSceneAndTransformerByDrawingSearch(e.unitId);if(o==null)return;const{scene:c,transformer:u}=o;this._commandService.syncExecuteCommand(ee.id);const l=[];if(t.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===b.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:i,drawingId:a}),d=new b.Group(g);c.addObject(d,b.DRAWING_OBJECT_LAYER_INDEX).attachTransformerTo(d),d.addObjects(...l),e.transform&&d.transformByState({left:e.transform.left,top:e.transform.top}),u.clearSelectedObjects(),u.setSelectedControl(d)}_ungroupDrawings(r){r.forEach(e=>{this._ungroupDrawing(e)})}_ungroupDrawing(r){const{parent:e,children:t}=r,n=this._getSceneAndTransformerByDrawingSearch(e.unitId);if(n==null)return;const{scene:i,transformer:a}=n;t.forEach(g=>{const d=M.getDrawingShapeKeyByDrawingSearch(g),p=i.getObjectIncludeInGroup(d);if(p==null)return!0;if(p==null)return;const{transform:S}=g;S!=null&&(p.classType===b.RENDER_CLASS_TYPE.GROUP?p.transformByState({left:S.left,top:S.top}):p.transformByState(S))});const o=M.getDrawingShapeKeyByDrawingSearch(e),c=i.getObject(o),{width:u,height:l}=c;c.getObjects().forEach(g=>{c.removeSelfObjectAndTransform(g.oKey,u,l)}),c.dispose(),a.clearSelectedObjects()}_drawingAlign(r){const{alignType:e}=r,t=this._drawingManagerService.getFocusDrawings();if(e===R.default)return;const n=[];let i=Number.POSITIVE_INFINITY,a=Number.POSITIVE_INFINITY,o=Number.NEGATIVE_INFINITY,c=Number.NEGATIVE_INFINITY,u=0;t.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:I=0,height:O=0}=m.transform;i=Math.min(i,v),a=Math.min(a,C),o=Math.max(o,v+I),c=Math.max(c,C+O),u++}),u!==0&&(this._sortDrawingTransform(n,e),this._applyAlignType(n,e,i,a,o,c,u))}_applyAlignType(r,e,t,n,i,a,o){const c=Math.round((i-t)/o*10)/10,u=Math.round((a-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:I,transform:O,drawingType:P}=S,{left:j=0,top:D=0,width:T=0,height:E=0}=O;let N=j,U=D;switch(e){case R.left:N=t;break;case R.center:N=t+(i-t)/2-T/2;break;case R.right:N=i-T;break;case R.top:U=n;break;case R.middle:U=n+(a-n)/2-E/2;break;case R.bottom:U=a-E;break;case R.horizon:N=t+c*m;break;case R.vertical:U=n+u*m;break}(N!==j||U!==D)&&l.push({unitId:v,subUnitId:C,drawingId:I,drawingType:P,transform:{left:N,top:U}})}),this._drawingManagerService.featurePluginUpdateNotification(l),p.refreshControls().changeNotification()}_sortDrawingTransform(r,e){r.sort((t,n)=>{const i=t.transform,a=n.transform,{left:o=0,top:c=0,width:u=0,height:l=0}=i,{left:g=0,top:d=0,width:p=0,height:S=0}=a;switch(e){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:e,subUnitId:t,drawingIds:n}=r,i=this._getSceneAndTransformerByDrawingSearch(e);if(i==null)return;const{scene:a}=i;n.forEach(o=>{const c=M.getDrawingShapeKeyByDrawingSearch({unitId:e,subUnitId:t,drawingId:o}),u=a.fuzzyMathObjects(c,!0);if(u==null||u.length===0)return;const l=this._drawingManagerService.getDrawingOrder(e,t).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 e=[];r.forEach(t=>{const{unitId:n}=t;if(this._drawingManagerService.getDrawingByParam(t)==null)return;const a=this._getSceneAndTransformerByDrawingSearch(n);if(a==null)return;const{scene:o}=a;e.includes(o)||e.push(o)}),e.forEach(t=>{this._sceneListenerOnDrawingMap.has(t)||(this._addListenerOnDrawing(t),this._sceneListenerOnDrawingMap.add(t))})}_drawingRemoveListener(){this.disposeWithMe(this._drawingManagerService.remove$.subscribe(r=>{r.forEach(e=>{var l;const{unitId:t,subUnitId:n,drawingId:i}=e,a=this._getSceneAndTransformerByDrawingSearch(t);if(a==null)return;const{scene:o}=a,c=M.getDrawingShapeKeyByDrawingSearch({unitId:t,subUnitId:n,drawingId:i}),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(e=>{var T;const{unitId:t,subUnitId:n,drawingId:i}=e,a=this._drawingManagerService.getDrawingByParam(e);if(a==null)return;const{transform:o,drawingType:c}=a,u=this._getSceneAndTransformerByDrawingSearch(t);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:I=!1,skewX:O=0,skewY:P=0}=o,j=M.getDrawingShapeKeyByDrawingSearch({unitId:t,subUnitId:n,drawingId:i}),D=l.getObject(j);if(D==null)return!0;D.transformByState({left:d,top:p,width:S,height:m,angle:v,flipX:C,flipY:I,skewX:O,skewY:P}),(T=l.getTransformer())==null||T.debounceRefreshControls()})}))}_drawingRefreshListener(){this.disposeWithMe(this._drawingManagerService.refreshTransform$.subscribe(r=>{r.forEach(e=>{const{unitId:t,subUnitId:n,drawingId:i}=e,a=this._getSceneAndTransformerByDrawingSearch(t);if(a==null)return;const o=this._drawingManagerService.getDrawingByParam(e);if(o==null)return;const{transform:c}=o,{scene:u}=a,l=M.getDrawingShapeKeyByDrawingSearch({unitId:t,subUnitId:n,drawingId:i}),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:I=!1,skewX:O=0,skewY:P=0}=c;g.transformByState({left:d,top:p,width:S,height:m,angle:v,flipX:C,flipY:I,skewX:O,skewY:P})})}))}_drawingVisibleListener(){this.disposeWithMe(this._drawingManagerService.visible$.subscribe(r=>{r.forEach(e=>{const{unitId:t,subUnitId:n,drawingId:i,visible:a}=e,o=this._getSceneAndTransformerByDrawingSearch(t);if(o==null)return;const{scene:c}=o,u=M.getDrawingShapeKeyByDrawingSearch({unitId:t,subUnitId:n,drawingId:i}),l=c.getObject(u);if(l==null)return!0;a?l.show():l.hide()})}))}_filterUpdateParams(r,e){return r.filter((t,n)=>{if(t==null)return!1;const{transform:i}=t;return h.checkIfMove(i,e==null?void 0:e[n])})}_addListenerOnDrawing(r){const e=r.getTransformerByCreate();let t=null;this.disposeWithMe(h.toDisposable(e.changeStart$.subscribe(n=>{const{objects:i}=n,a=Array.from(i.values()),o=[];t=a.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 b.Group){let C=c.ancestorGroup;if(C==null&&c instanceof b.Group&&(C=c),C==null)return null;const I=this._drawingManagerService.getDrawingOKey(C.oKey);if(I){const{unitId:O,subUnitId:P,drawingId:j}=I;o.push({unitId:O,subUnitId:P,drawingId:j});const{left:D,top:T,height:E,width:N,angle:U}=C;return{left:D,top:T,height:E,width:N,angle:U}}}else if(v!=null){const{unitId:C,subUnitId:I,drawingId:O}=v;return o.push({unitId:C,subUnitId:I,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(e.changeEnd$.subscribe(n=>{const{objects:i}=n,a=this._filterUpdateParams(le(i,this._drawingManagerService),t);a.length>0&&this._drawingManagerService.featurePluginUpdateNotification(a)})))}};Se=ct([we(0,h.IUniverInstanceService),we(1,h.ICommandService),we(2,b.IRenderManagerService),we(3,M.IDrawingManagerService)],Se);class ue extends b.Shape{constructor(e,t){t==null&&(t={}),t.transformerConfig={keepRatio:!1,isCropper:!0,anchorFill:"rgb(0, 0, 0)",anchorStroke:"rgb(255, 255, 255)",anchorSize:24};super(e,t);Q(this,"_srcRect");Q(this,"_prstGeom");Q(this,"_applyTransform");Q(this,"_dragPadding",8);Q(this,"_cacheCanvas");t!=null&&t.srcRect&&(this._srcRect=t.srcRect),t!=null&&t.prstGeom&&(this._prstGeom=t.prstGeom),t!=null&&t.applyTransform&&(this._applyTransform=t.applyTransform),t!=null&&t.dragPadding&&(this._dragPadding=t.dragPadding),this._applyProps()}refreshSrcRect(e,t){this._srcRect=e,this._applyTransform=t,this._applyProps()}get srcRect(){return this._srcRect}dispose(){var e;super.dispose(),(e=this._cacheCanvas)==null||e.dispose(),this._srcRect=null}isHit(e){const t=this.getInverseCoord(e);return t.x>=-this.strokeWidth/2&&t.x<=this.width+this.strokeWidth/2&&t.y>=-this.strokeWidth/2&&t.y<=this.height+this.strokeWidth/2&&!this._inSurround(t)}_inSurround(e){const t=this._dragPadding;return e.x>=t-this.strokeWidth/2&&e.x<=this.width+this.strokeWidth/2-t&&e.y>=t-this.strokeWidth/2&&e.y<=this.height+this.strokeWidth/2-t}render(e,t){return this.visible?(e.save(),this._draw(e),e.restore(),this.makeDirty(!1),this):(this.makeDirty(!1),this)}_draw(e){var c,u;const n=this.getScene().getEngine(),{width:i,height:a}=n;this._initialCacheCanvas(),(c=this._cacheCanvas)==null||c.clear();const o=(u=this._cacheCanvas)==null?void 0:u.getContext();o!=null&&(o.save(),b.Rect.drawWith(o,{left:0,top:0,width:i,height:a,fill:"rgba(0, 0, 0, 0.5)"}),o.setTransform(e.getTransform()),this._clipForApplyObject(o),this._applyCache(e),o.restore())}_clipForApplyObject(e){let t=0;if(this._prstGeom!=null&&(t=1),e.globalCompositeOperation="destination-out",e.beginPath(),t===0){const n=this.transform.getMatrix();e.transform(n[0],n[1],n[2],n[3],n[4],n[5]),e.rect(0,0,this.width,this.height),e.fill()}}_applyProps(){if(this._applyTransform==null)return;let e=0,t=0,n=0,i=0;const{left:a=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;e=p,t=S,n=m,i=v}const g=a+e,d=o+t;this.transformByState({left:g,top:d,width:a+c-n-g,height:o+u-i-d,angle:l})}_applyCache(e){if(!e||this._cacheCanvas==null)return;const t=this._cacheCanvas.getContext();t.save(),e.save(),e.setTransform(1,0,0,1,0,0),t.setTransform(1,0,0,1,0,0),e.drawImage(this._cacheCanvas.getCanvasEle(),0,0),e.restore(),t.restore()}_initialCacheCanvas(){if(this._cacheCanvas!=null)return;const e=this.getScene();if(e==null)return;this._cacheCanvas=new b.Canvas;const t=e.getEngine();this._cacheCanvas.setSize(t.width,t.height),t.onTransformChange$.subscribeEvent(()=>{var n;(n=this._cacheCanvas)==null||n.setSize(t.width,t.height),this.makeDirty(!0)})}}var lt=Object.getOwnPropertyDescriptor,ut=(s,r,e,t)=>{for(var n=t>1?void 0:t?lt(r,e):r,i=s.length-1,a;i>=0;i--)(a=s[i])&&(n=a(n)||n);return n},se=(s,r)=>(e,t)=>r(e,t,s);let _e=class extends h.Disposable{constructor(r,e,t,n,i,a){super();Q(this,"_sceneListenerOnImageMap",new WeakSet);this._commandService=r,this._drawingManagerService=e,this._renderManagerService=t,this._univerInstanceService=n,this._messageService=i,this._localeService=a,this._init()}_init(){this._initOpenCrop(),this._initCloseCrop(),this._initAutoCrop()}_initAutoCrop(){this.disposeWithMe(this._commandService.onCommandExecuted(r=>{if(r.id!==ce.id)return;const e=r.params;if(e==null)return;const{cropType:t}=e,n=this._drawingManagerService.getFocusDrawings();if(n.length!==1)return;const i=n[0],{unitId:a,subUnitId:o,drawingId:c}=i,u=this._renderManagerService.getRenderById(a),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:a,subUnitId:o,drawingId:c}),p=l.getObject(d);if(!(p instanceof b.Image)){this._messageService.show({type:B.MessageType.Error,content:this._localeService.t("image-cropper.error")});return}p!=null&&(this._updateCropperObject(t,p),this._commandService.executeCommand(me.id,{unitId:a,subUnitId:o,drawingId:c}))}))}_calculateSrcRectByRatio(r,e,t,n,i,a){const o=t/n,c=i/a;let u=t,l=n;o>c?u=n*c:l=t/c;const g=(t-u)/2,d=(n-l)/2;return{left:b.precisionTo(g,1),top:b.precisionTo(d,1),right:b.precisionTo(t-(g+u),1),bottom:b.precisionTo(n-(d+l),1)}}_updateCropperObject(r,e){const{left:t,top:n,width:i,height:a}=e.calculateTransformWithSrcRect();let o;switch(r){case L.R1_1:o=this._calculateSrcRectByRatio(t,n,i,a,1,1);break;case L.R16_9:o=this._calculateSrcRectByRatio(t,n,i,a,16,9);break;case L.R9_16:o=this._calculateSrcRectByRatio(t,n,i,a,9,16);break;case L.R5_4:o=this._calculateSrcRectByRatio(t,n,i,a,5,4);break;case L.R4_5:o=this._calculateSrcRectByRatio(t,n,i,a,4,5);break;case L.R4_3:o=this._calculateSrcRectByRatio(t,n,i,a,4,3);break;case L.R3_4:o=this._calculateSrcRectByRatio(t,n,i,a,3,4);break;case L.R3_2:o=this._calculateSrcRectByRatio(t,n,i,a,3,2);break;case L.R2_3:o=this._calculateSrcRectByRatio(t,n,i,a,2,3);break;case L.FREE:}if(o==null)return;e.setSrcRect(o);const{left:c=0,top:u=0,bottom:l=0,right:g=0}=o;e.transformByStateCloseCropper({left:t+c,top:n+u,width:i-g-c,height:a-l-u})}_initOpenCrop(){this.disposeWithMe(this._commandService.onCommandExecuted(r=>{if(r.id!==me.id)return;const e=r.params;if(e==null)return;const{unitId:t,subUnitId:n,drawingId:i}=e,a=this._renderManagerService.getRenderById(t),o=a==null?void 0:a.scene;if(o==null)return!0;if(this._sceneListenerOnImageMap.has(o)||(this._addListenerOnImage(o),this._sceneListenerOnImageMap.add(o)),this._drawingManagerService.getDrawingByParam({unitId:t,subUnitId:n,drawingId:i})==null)return;const u=M.getDrawingShapeKeyByDrawingSearch({unitId:t,subUnitId:n,drawingId:i}),l=o.getObject(u);if(l==null)return;if(!(l instanceof b.Image)){this._messageService.show({type:B.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(M.SetDrawingSelectedOperation.id,[{unitId:t,subUnitId:n,drawingId:i}])}))}_searchCropObject(r){const e=r.getAllObjectsByOrder();for(const t of e)if(t instanceof ue)return t}_initCloseCrop(){this.disposeWithMe(this._commandService.onCommandExecuted(e=>{if(e.id!==ee.id)return;const t=this._univerInstanceService.getFocusedUnit();if(t==null)return;const n=t.getUnitId(),i=this._renderManagerService.getRenderById(n),a=i==null?void 0:i.scene;if(a==null)return!0;const o=this._searchCropObject(a);if(o==null)return;const c=this._getApplyObjectByCropObject(o);if(c==null)return;const u=a.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(te.switchMap(e=>e?e.activeSheet$:te.of(null)));this.disposeWithMe(r.subscribe(()=>{this._commandService.syncExecuteCommand(ee.id)}))}_getApplyObjectByCropObject(r){const e=r.oKey,t=e.slice(0,e.length-5),n=r.getScene();if(!n)return null;const i=n.getObject(t);return i==null?null:i}_addListenerOnImage(r){const e=r.getTransformerByCreate();let t=null;this.disposeWithMe(e.changeStart$.subscribe(n=>{const{objects:i}=n,a=i.values().next().value;if(a==null||!(a instanceof ue))return;const{left:o,top:c,height:u,width:l,angle:g}=a;t={left:o,top:c,height:u,width:l,angle:g},e.clearCopperControl()})),this.disposeWithMe(e.changeEnd$.subscribe(n=>{const{objects:i}=n,a=i.values().next().value;if(a==null||!(a instanceof ue))return;const{left:o,top:c,height:u,width:l,angle:g}=a;if(!h.checkIfMove({left:o,top:c,height:u,width:l,angle:g},t))return;const d=this._getApplyObjectByCropObject(a);if(d==null)return;const p=this._getSrcRectByTransformState(d,a);a.refreshSrcRect(p.srcRect,d.getState()),e.createControlForCopper(a)})),this._endCropListener(r)}_addHoverForImageCopper(r){this.disposeWithMe(r.onPointerEnter$.subscribeEvent(()=>{r.cursor=b.CURSOR_TYPE.MOVE})),this.disposeWithMe(r.onPointerLeave$.subscribeEvent(()=>{r.cursor=b.CURSOR_TYPE.DEFAULT}))}_endCropListener(r){const e=r.getTransformerByCreate();this.disposeWithMe(e.clearControl$.subscribe(t=>{t===!0&&this._commandService.syncExecuteCommand(ee.id)}))}_getSrcRectByTransformState(r,e){const{left:t,top:n,height:i,width:a,strokeWidth:o,angle:c}=e,{left:u,top:l,width:g,height:d,angle:p,strokeWidth:S}=r,m=t-u,v=n-l,C={left:m,top:v,right:g-m-a,bottom:d-v-i},I={...C};if(p!==0){const O=t+a/2,P=n+i/2,j=new b.Vector2(O,P),D=g/2+u,T=d/2+l,E=new b.Vector2(D,T),N=new b.Vector2(u,l);N.rotateByPoint(b.degToRad(p),E);const U=N.clone();U.rotateByPoint(b.degToRad(-p),j);const $=t-U.x,x=n-U.y;I.left=$,I.top=x,I.right=g-$-a,I.bottom=d-x-i}return{srcRect:C,srcRectAngle:I}}};_e=ut([se(0,h.ICommandService),se(1,M.IDrawingManagerService),se(2,b.IRenderManagerService),se(3,h.IUniverInstanceService),se(4,H.IMessageService),se(5,h.Inject(h.LocaleService))],_e);var gt=Object.getOwnPropertyDescriptor,dt=(s,r,e,t)=>{for(var n=t>1?void 0:t?gt(r,e):r,i=s.length-1,a;i>=0;i--)(a=s[i])&&(n=a(n)||n);return n},ge=(s,r)=>(e,t)=>r(e,t,s);y.DrawingRenderService=class{constructor(r,e,t,n,i){this._drawingManagerService=r,this._imageIoService=e,this._galleryService=t,this._urlImageService=n,this._univerInstanceService=i}async renderImages(r,e){const{transform:t,drawingType:n,source:i,imageSourceType:a,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()||t==null)return;const m=p&&S?S:[t],v=[];for(const C of m){const{left:I,top:O,width:P,height:j,angle:D,flipX:T,flipY:E,skewX:N,skewY:U}=C,$=m.indexOf(C),x=M.getDrawingShapeKeyByDrawingSearch({unitId:l,subUnitId:g,drawingId:d},p?$:void 0),V=e.getObject(x);if(V!=null){V.transformByState({left:I,top:O,width:P,height:j,angle:D,flipX:T,flipY:E,skewX:N,skewY:U});continue}if(!this._drawingManagerService.getDrawingVisible()||g!==this._getActiveSheetId())continue;const Y=this._drawingManagerService.getDrawingOrder(l,g),oe=Y.indexOf(d),X={...C,zIndex:oe===-1?Y.length-1:oe},ne=this._imageIoService.getImageSourceCache(i,a);let ie=!1;if(ne!=null)X.image=ne;else if(a===M.ImageSourceType.UUID)try{X.url=await this._imageIoService.getImage(i)}catch(de){console.error(de);continue}else if(a===M.ImageSourceType.URL){try{X.url=await this._urlImageService.getImage(i)}catch(de){console.error(de),X.url=i}ie=!0}else X.url=i,ie=!0;if(e.getObject(x))continue;X.printable=!0;const q=new b.Image(x,X);ie&&this._imageIoService.addImageSourceCache(i,a,q.getNative()),e.addObject(q,b.DRAWING_OBJECT_LAYER_INDEX),this._drawingManagerService.getDrawingEditable()&&e.attachTransformerTo(q),u&&Me({drawingId:u,unitId:l,subUnitId:g},q,e,this._drawingManagerService),c!=null&&q.setPrstGeom(c),o!=null&&q.setSrcRect(o),v.push(q)}return v}_getActiveSheetId(){var r,e;return(e=(r=this._univerInstanceService.getCurrentUnitOfType(h.UniverInstanceType.UNIVER_SHEET))==null?void 0:r.getActiveSheet())==null?void 0:e.getSheetId()}renderFloatDom(r,e){const{transform:t,drawingType:n,groupId:i,unitId:a,subUnitId:o,drawingId:c,isMultiTransform:u,transforms:l}=r;if(n!==h.DrawingTypeEnum.DRAWING_DOM||!this._drawingManagerService.getDrawingVisible()||t==null)return;const g=u&&l?l:[t],d=[];for(const p of g){const{left:S,top:m,width:v,height:C,angle:I,flipX:O,flipY:P,skewX:j,skewY:D}=p,T=g.indexOf(p),E=M.getDrawingShapeKeyByDrawingSearch({unitId:a,subUnitId:o,drawingId:c},u?T:void 0),N=e.getObject(E);if(N!=null){N.transformByState({left:S,top:m,width:v,height:C,angle:I,flipX:O,flipY:P,skewX:j,skewY:D});continue}const U=this._drawingManagerService.getDrawingOrder(a,o),$=U.indexOf(c),x={...p,zIndex:$===-1?U.length-1:$};if(e.getObject(E))continue;x.printable=!1;const V=new b.Rect(E,x);this._drawingManagerService.getDrawingVisible()&&(e.addObject(V,b.DRAWING_OBJECT_LAYER_INDEX),this._drawingManagerService.getDrawingEditable()&&r.allowTransform!==!1&&e.attachTransformerTo(V),i&&Me({drawingId:i,unitId:a,subUnitId:o},V,e,this._drawingManagerService),d.push(V))}return d}renderDrawing(r,e){const t=this._drawingManagerService.getDrawingByParam(r);if(t!=null&&t.drawingType===h.DrawingTypeEnum.DRAWING_IMAGE)return this.renderImages(t,e)}previewImage(r,e,t,n){this._galleryService.open({images:[e],onOpenChange:i=>{i||this._galleryService.close()}})}_adjustImageSize(r,e,t,n){if(r<=t&&e<=n)return{width:r,height:e};const i=t/r,a=n/e,o=Math.min(i,a);return{width:Math.floor(r*o),height:Math.floor(e*o)}}},y.DrawingRenderService=dt([ge(0,M.IDrawingManagerService),ge(1,M.IImageIoService),ge(2,H.IGalleryService),ge(3,h.IURLImageService),ge(4,h.IUniverInstanceService)],y.DrawingRenderService);var ht=Object.getOwnPropertyDescriptor,ft=(s,r,e,t)=>{for(var n=t>1?void 0:t?ht(r,e):r,i=s.length-1,a;i>=0;i--)(a=s[i])&&(n=a(n)||n);return n},re=(s,r)=>(e,t)=>r(e,t,s);let Ce=class extends h.Disposable{constructor(s,r,e,t,n,i,a){super(),this._commandService=s,this._renderManagerService=r,this._drawingManagerService=e,this._dialogService=t,this._imageIoService=n,this._currentUniverService=i,this._drawingRenderService=a,this._initialize()}dispose(){super.dispose()}_initialize(){this._drawingAddListener(),this._commandExecutedListener(),this._imageUpdateListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.onCommandExecuted(s=>{if(s.id===De.id){const r=s.params;if(r==null)return;this._resetImageSize(r)}}))}_getSceneAndTransformerByDrawingSearch(s){if(s==null)return;const r=this._renderManagerService.getRenderById(s),e=r==null?void 0:r.scene;if(e==null)return null;const t=e.getTransformerByCreate();return{scene:e,transformer:t}}_resetImageSize(s){const r=[],e=[];s.forEach(t=>{const{unitId:n,subUnitId:i,drawingId:a}=t,o=this._getSceneAndTransformerByDrawingSearch(n);if(o==null)return;const{scene:c}=o,u=M.getDrawingShapeKeyByDrawingSearch({unitId:n,subUnitId:i,drawingId:a}),l=c.getObject(u);if(l==null)return!0;const g=this._drawingManagerService.getDrawingByParam(t);if(g==null)return!0;if(g.drawingType!==h.DrawingTypeEnum.DRAWING_IMAGE)return;l.resetSize();const{width:d,height:p}=l.getNativeSize();e.includes(c)===!1&&e.push(c),r.push({...g,transform:{...g.transform,height:p,width:d,angle:0},srcRect:null,prstGeom:null})}),this._drawingManagerService.featurePluginUpdateNotification(r),e.forEach(t=>{t.getTransformerByCreate().refreshControls().changeNotification()}),this._commandService.syncExecuteCommand(M.SetDrawingSelectedOperation.id,s)}_drawingAddListener(){this.disposeWithMe(this._drawingManagerService.add$.pipe(te.bufferTime(33),te.filter(s=>s.length>0),te.map(s=>s.flat()),te.map(s=>{const r=new Map;for(const e of s)r.set(`${e.unitId}|${e.subUnitId}|${e.drawingId}`,e);return[...r.values()]}),te.filter(s=>s.length>0)).subscribe(s=>{this._insertImages(s)}))}_insertImages(s){s.forEach(async r=>{var c;const{unitId:e,subUnitId:t}=r,n=this._getSceneAndTransformerByDrawingSearch(e),i=(c=Oe(this._currentUniverService,e))==null?void 0:c.subUnitId;if(n==null||i!==t)return;const a=this._drawingManagerService.getDrawingByParam(r);if(a==null)return;const o=await this._drawingRenderService.renderImages(a,n.scene);if(this._drawingManagerService.refreshTransform([a]),!(o==null||o.length===0))for(const u of o)this._addHoverForImage(u),this._addDialogForImage(u)})}_imageUpdateListener(){this.disposeWithMe(this._drawingManagerService.update$.subscribe(s=>{s.forEach(r=>{const{unitId:e,subUnitId:t,drawingId:n}=r,i=this._drawingManagerService.getDrawingByParam(r);if(i==null)return;const{transform:a,drawingType:o,srcRect:c,prstGeom:u,source:l,imageSourceType:g}=i;if(o!==h.DrawingTypeEnum.DRAWING_IMAGE)return;const d=this._getSceneAndTransformerByDrawingSearch(e);if(d==null)return;const{scene:p,transformer:S}=d;if(a==null)return!0;const m=M.getDrawingShapeKeyByDrawingSearch({unitId:e,subUnitId:t,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(s){this.disposeWithMe(h.toDisposable(s.onPointerEnter$.subscribeEvent(()=>{s.cursor=b.CURSOR_TYPE.GRAB}))),this.disposeWithMe(h.toDisposable(s.onPointerLeave$.subscribeEvent(()=>{s.cursor=b.CURSOR_TYPE.DEFAULT})))}_addDialogForImage(s){this.disposeWithMe(h.toDisposable(s.onDblclick$.subscribeEvent(()=>{const r=`${s.oKey}-viewer-dialog`;this._drawingRenderService.previewImage(r,s.getNative().src,s.getNativeSize().width,s.getNativeSize().height)})))}};Ce=ft([re(0,h.ICommandService),re(1,b.IRenderManagerService),re(2,M.IDrawingManagerService),re(3,H.IDialogService),re(4,M.IImageIoService),re(5,h.IUniverInstanceService),re(6,h.Inject(y.DrawingRenderService))],Ce);var pt=Object.getOwnPropertyDescriptor,mt=(s,r,e,t)=>{for(var n=t>1?void 0:t?pt(r,e):r,i=s.length-1,a;i>=0;i--)(a=s[i])&&(n=a(n)||n);return n},Ve=(s,r)=>(e,t)=>r(e,t,s);const vt="UNIVER_DRAWING_UI_PLUGIN";y.UniverDrawingUIPlugin=(Ee=class extends h.Plugin{constructor(r=Te,e,t){super(),this._config=r,this._injector=e,this._configService=t;const{menu:n,...i}=h.merge({},Te,this._config);n&&this._configService.setConfig("menu",n,{merge:!0}),this._configService.setConfig(Ze,i)}onStarting(){this._initDependencies()}onRendered(){this._injector.get(Se),this._injector.get(ve),this._injector.get(_e),this._injector.get(Ce)}_initDependencies(){[[y.DrawingRenderService],[Se],[ve],[_e],[Ce]].forEach(e=>this._injector.add(e))}},Q(Ee,"pluginName",vt),Ee),y.UniverDrawingUIPlugin=mt([Ve(1,h.Inject(h.Injector)),Ve(2,h.IConfigService)],y.UniverDrawingUIPlugin);const wt=s=>{const r=H.useDependency(h.ICommandService),e=H.useDependency(h.LocaleService),{alignShow:t}=s,[n,i]=_.useState(R.default),a=[{label:e.t("image-panel.align.default"),value:R.default},{options:[{label:e.t("image-panel.align.left"),value:R.left},{label:e.t("image-panel.align.center"),value:R.center},{label:e.t("image-panel.align.right"),value:R.right}]},{options:[{label:e.t("image-panel.align.top"),value:R.top},{label:e.t("image-panel.align.middle"),value:R.middle},{label:e.t("image-panel.align.bottom"),value:R.bottom}]},{options:[{label:e.t("image-panel.align.horizon"),value:R.horizon},{label:e.t("image-panel.align.vertical"),value:R.vertical}]}];function o(c){i(c),r.executeCommand(pe.id,{alignType:c})}return f.jsxs("div",{className:B.clsx("univer-relative univer-w-full",{"univer-hidden":!t}),children:[f.jsx("header",{className:"univer-text-gray-600 dark:!univer-text-gray-200",children:f.jsx("div",{children:e.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(B.Select,{value:n,options:a,onChange:o})})})]})},St=s=>{const{arrangeShow:r,drawings:e}=s,t=H.useDependency(h.LocaleService),n=H.useDependency(M.IDrawingManagerService),[i,a]=_.useState(e);_.useEffect(()=>{const c=n.focus$.subscribe(u=>{a(u)});return()=>{c.unsubscribe()}},[]);const o=c=>{const u=i[0].unitId,l=i[0].subUnitId,g=i.map(d=>d.drawingId);n.featurePluginOrderUpdateNotification({unitId:u,subUnitId:l,drawingIds:g,arrangeType:c})};return f.jsxs("div",{className:B.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:t.t("image-panel.arrange.title")})}),f.jsxs("div",{className:"univer-grid univer-grid-cols-2 univer-gap-2",children:[f.jsxs(B.Button,{onClick:()=>{o(h.ArrangeTypeEnum.forward)},children:[f.jsx(Le,{}),t.t("image-panel.arrange.forward")]}),f.jsxs(B.Button,{onClick:()=>{o(h.ArrangeTypeEnum.backward)},children:[f.jsx(Ae,{}),t.t("image-panel.arrange.backward")]}),f.jsxs(B.Button,{onClick:()=>{o(h.ArrangeTypeEnum.front)},children:[f.jsx(He,{}),t.t("image-panel.arrange.front")]}),f.jsxs(B.Button,{onClick:()=>{o(h.ArrangeTypeEnum.back)},children:[f.jsx(Ne,{}),t.t("image-panel.arrange.back")]})]})]})},_t=s=>{const r=H.useDependency(h.LocaleService),e=H.useDependency(b.IRenderManagerService),t=H.useDependency(M.IDrawingManagerService),{hasGroup:n,drawings:i}=s,[a,o]=_.useState(!1),[c,u]=_.useState(!0),[l,g]=_.useState(!0),d=()=>{const m=t.getFocusDrawings(),{unitId:v,subUnitId:C}=m[0],I=h.generateRandomId(10),O=b.getGroupState(0,0,m.map(D=>D.transform||{})),P={unitId:v,subUnitId:C,drawingId:I,drawingType:h.DrawingTypeEnum.DRAWING_GROUP,transform:O},j=m.map(D=>{const T=D.transform||{left:0,top:0},{unitId:E,subUnitId:N,drawingId:U}=D;return{unitId:E,subUnitId:N,drawingId:U,transform:{...T,left:T.left-O.left,top:T.top-O.top},groupId:I}});t.featurePluginGroupUpdateNotification([{parent:P,children:j}])},p=m=>{if(m.drawingType!==h.DrawingTypeEnum.DRAWING_GROUP)return;const{unitId:v,subUnitId:C,drawingId:I,transform:O={width:0,height:0}}=m;if(O==null)return;const P=t.getDrawingsByGroup({unitId:v,subUnitId:C,drawingId:I});if(P.length===0)return;const j=P.map(D=>{const{transform:T}=D,{unitId:E,subUnitId:N,drawingId:U}=D,$=b.transformObjectOutOfGroup(T||{},O,O.width||0,O.height||0);return{unitId:E,subUnitId:N,drawingId:U,transform:{...T,...$},groupId:void 0}});return{parent:m,children:j}},S=()=>{const v=t.getFocusDrawings().map(C=>p(C)).filter(C=>C!=null);v.length!==0&&t.featurePluginUngroupUpdateNotification(v)};return _.useEffect(()=>{const m=i[0];if(m==null)return;const{unitId:v}=m,C=e.getRenderById(v),I=C==null?void 0:C.scene;if(I==null)return;const O=I.getTransformerByCreate(),P=O.clearControl$.subscribe(D=>{D===!0&&o(!1)}),j=O.changeStart$.subscribe(D=>{const{objects:T}=D,E=le(T,t),N=E.filter(V=>(V==null?void 0:V.drawingType)===h.DrawingTypeEnum.DRAWING_GROUP);let U=!1,$=!1;E.length>1&&(U=!0),N.length>0&&($=!0),o(U||$),u(U),g($)});return()=>{j.unsubscribe(),P.unsubscribe()}},[]),f.jsxs("div",{className:B.clsx("univer-grid univer-gap-2 univer-py-2 univer-text-gray-400",{"univer-hidden":n===!0&&a===!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(B.Button,{className:B.clsx({"univer-hidden":!c}),onClick:d,children:[f.jsx(Re,{}),r.t("image-panel.group.group")]}),f.jsxs(B.Button,{className:B.clsx({"univer-hidden":!l}),onClick:S,children:[f.jsx(xe,{}),r.t("image-panel.group.unGroup")]})]})]})},Ie=20,ye=20,We=[-360,360],be=300,Ct=s=>{var Ke;const r=H.useDependency(h.LocaleService),e=H.useDependency(M.IDrawingManagerService),t=H.useDependency(b.IRenderManagerService),{drawings:n,transformShow:i}=s,a=n[0];if(a==null)return;const o=a.transform;if(o==null)return;const{unitId:c,subUnitId:u,drawingId:l,drawingType:g}=a,d=t.getRenderById(c),p=d==null?void 0:d.scene;if(p==null)return;const S=(Ke=p.getEngine())==null?void 0:Ke.activeScene;if(S==null)return;const m=p.getTransformerByCreate(),{width:v=0,height:C=0,left:I=0,top:O=0,angle:P=0}=o,[j,D]=_.useState(v),[T,E]=_.useState(C),[N,U]=_.useState(I),[$,x]=_.useState(O),[V,Y]=_.useState(P),[oe,X]=_.useState(m.keepRatio),ne=(w,A,G,W)=>{const{width:k,height:J}=S,{ancestorLeft:K,ancestorTop:Z}=p;let z=w,ae=A,he=G,fe=W;return w+K<0&&(z=-K),A+Z<0&&(ae=-Z),he=k-z-K,he<Ie&&(he=Ie),fe=J-ae-Z,fe<ye&&(fe=ye),w+he+K>k&&(z=k-G-K),A+fe+Z>J&&(ae=J-W-Z),{limitLeft:z,limitTop:ae,limitWidth:he,limitHeight:fe}},ie=w=>{const{objects:A}=w,G=le(A,e);if(G.length!==1)return;const W=G[0];if(W==null)return;const{transform:k}=W;if(k==null)return;const{width:J,height:K,left:Z,top:z,angle:ae}=k;J!=null&&D(J),K!=null&&E(K),Z!=null&&U(Z),z!=null&&x(z),ae!=null&&Y(ae)};_.useEffect(()=>{const w=[m.changeStart$.subscribe(A=>{ie(A)}),m.changing$.subscribe(A=>{ie(A)}),m.changeEnd$.subscribe(A=>{ie(A)}),e.focus$.subscribe(A=>{if(A.length!==1)return;const G=e.getDrawingByParam(A[0]);if(G==null)return;const W=G.transform;if(W==null)return;const{width:k,height:J,left:K,top:Z,angle:z}=W;k!=null&&D(k),J!=null&&E(J),K!=null&&U(K),Z!=null&&x(Z),z!=null&&Y(z)})];return()=>{w.forEach(A=>A.unsubscribe())}},[]);const q=h.debounce(w=>{if(w==null)return;const{limitWidth:A,limitHeight:G}=ne(N,$,w,T);w=Math.min(w,A);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,ye),k>G)return;E(k),W.transform.height=k}D(w),e.featurePluginUpdateNotification([W]),m.refreshControls().changeNotification()},be),de=h.debounce(w=>{if(w==null)return;const{limitHeight:A,limitWidth:G}=ne(N,$,j,w);w=Math.min(w,A);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,Ie),k>G)return;D(k),W.transform.width=k}E(w),e.featurePluginUpdateNotification([W]),m.refreshControls().changeNotification()},be),bt=h.debounce(w=>{if(w==null)return;const{limitLeft:A}=ne(w,$,j,T);w=A;const G={unitId:c,subUnitId:u,drawingId:l,drawingType:g,transform:{left:w}};U(w),e.featurePluginUpdateNotification([G]),m.refreshControls().changeNotification()},be),Dt=h.debounce(w=>{if(w==null)return;const{limitTop:A}=ne(N,w,j,T);w=A;const G={unitId:c,subUnitId:u,drawingId:l,drawingType:g,transform:{top:w}};x(w),e.featurePluginUpdateNotification([G]),m.refreshControls().changeNotification()},be),Mt=w=>{if(w==null)return;const A={unitId:c,subUnitId:u,drawingId:l,drawingType:g,transform:{angle:w}};Y(w),e.featurePluginUpdateNotification([A]),m.refreshControls().changeNotification()},Ot=w=>{X(w),m.keepRatio=w};return f.jsxs("div",{className:B.clsx("univer-grid univer-gap-2 univer-py-2 univer-text-gray-400",{"univer-hidden":!i}),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(B.InputNumber,{precision:1,value:j,min:Ie,onChange:w=>{q(w)}})]}),f.jsxs("div",{children:[f.jsx("span",{children:r.t("image-panel.transform.height")}),f.jsx(B.InputNumber,{precision:1,value:T,min:ye,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(B.Checkbox,{checked:oe,onChange:Ot})})]})]}),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(B.InputNumber,{precision:1,value:N,onChange:w=>{bt(w)}})]}),f.jsxs("div",{children:[f.jsx("span",{children:r.t("image-panel.transform.y")}),f.jsx(B.InputNumber,{precision:1,value:$,onChange:w=>{Dt(w)}})]}),f.jsxs("div",{children:[f.jsx("span",{children:r.t("image-panel.transform.rotate")}),f.jsx(B.InputNumber,{precision:1,value:V,min:We[0],max:We[1],onChange:Mt})]})]})]})},It=s=>{const r=H.useDependency(h.ICommandService),e=H.useDependency(h.LocaleService),{drawings:t,cropperShow:n}=s;if(t[0]==null)return;const[a,o]=_.useState(L.FREE),c=_.useRef(!1),u=[{label:e.t("image-panel.crop.mode"),value:L.FREE},{label:"1:1",value:L.R1_1},{label:"16:9",value:L.R16_9},{label:"9:16",value:L.R9_16},{label:"5:4",value:L.R5_4},{label:"4:5",value:L.R4_5},{label:"4:3",value:L.R4_3},{label:"3:4",value:L.R3_4},{label:"3:2",value:L.R3_2},{label:"2:3",value:L.R2_3}];_.useEffect(()=>{const 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(ce.id,{cropType:d})}const g=d=>{r.executeCommand(ce.id,{cropType:d}),c.current=!0};return f.jsxs("div",{className:B.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:e.t("image-panel.crop.title")})}),f.jsxs("div",{className:"univer-flex univer-items-center univer-justify-center univer-gap-2",children:[f.jsxs(B.Button,{onClick:()=>{g(a)},children:[f.jsx(Be,{}),e.t("image-panel.crop.start")]}),f.jsx(B.Select,{value:a,options:u,onChange:l})]})]})},yt=s=>{const r=H.useDependency(M.IDrawingManagerService),e=H.useDependency(b.IRenderManagerService),t=H.useDependency(h.LocaleService),{drawings:n,hasArrange:i=!0,hasTransform:a=!0,hasAlign:o=!0,hasCropper:c=!0,hasGroup:u=!0}=s,l=n[0];if(l==null)return;const{unitId:g}=l,d=e.getRenderById(g),p=d==null?void 0:d.scene;if(p==null)return;const S=p.getTransformerByCreate(),[m,v]=_.useState(!0),[C,I]=_.useState(!0),[O,P]=_.useState(!1),[j,D]=_.useState(!0),[T,E]=_.useState(!1);return _.useEffect(()=>{const N=S.clearControl$.subscribe(x=>{x===!0&&(v(!1),I(!1),P(!1),D(!1),E(!0))}),U=S.changeStart$.subscribe(x=>{const{objects:V}=x,Y=le(V,r);Y.length===0?(v(!1),I(!1),P(!1),D(!1),E(!0)):Y.length===1?(v(!0),I(!0),P(!1),D(!0),E(!1)):(v(!0),I(!1),P(!0),D(!1),E(!1))}),$=r.focus$.subscribe(x=>{x.length===0?(v(!1),I(!1),P(!1),D(!1),E(!0)):x.length===1?(v(!0),I(!0),P(!1),D(!0),E(!1)):(v(!0),I(!1),P(!0),D(!1),E(!1))});return()=>{U.unsubscribe(),N.unsubscribe(),$.unsubscribe()}},[]),f.jsxs(f.Fragment,{children:[f.jsx("div",{className:B.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:t.t("image-panel.null")})})}),f.jsx(St,{arrangeShow:i===!0?m:!1,drawings:n}),f.jsx(Ct,{transformShow:a===!0?C:!1,drawings:n}),f.jsx(wt,{alignShow:o===!0?O:!1,drawings:n}),f.jsx(It,{cropperShow:c===!0?j:!1,drawings:n}),f.jsx(_t,{hasGroup:u,drawings:n})]})};y.AutoImageCropOperation=ce,y.COMPONENT_IMAGE_POPUP_MENU=Ue,y.CloseImageCropOperation=ee,y.DrawingCommonPanel=yt,y.ImageCropperObject=ue,y.ImagePopupMenu=$e,y.ImageResetSizeOperation=De,y.OpenImageCropOperation=me,y.SetDrawingAlignOperation=pe,y.getCurrentUnitInfo=Oe,y.getUpdateParams=le,y.insertGroupObject=Me,Object.defineProperty(y,Symbol.toStringTag,{value:"Module"})}));
6
+ (function(y,d){typeof exports=="object"&&typeof module<"u"?d(exports,require("@univerjs/core"),require("@univerjs/drawing"),require("@univerjs/engine-render"),require("@univerjs/ui"),require("react/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"],d):(y=typeof globalThis<"u"?globalThis:y||self,d(y.UniverDrawingUi={},y.UniverCore,y.UniverDrawing,y.UniverEngineRender,y.UniverUi,y.React,y.UniverDesign,y.React,y.rxjs))})(this,(function(y,d,M,b,H,f,B,_,te){"use strict";var Et=Object.defineProperty;var Tt=(y,d,M)=>d in y?Et(y,d,{enumerable:!0,configurable:!0,writable:!0,value:M}):y[d]=M;var Q=(y,d,M)=>Tt(y,typeof d!="symbol"?d+"":d,M);var Ee;var R=(s=>(s.default="0",s.left="1",s.center="2",s.right="3",s.top="4",s.middle="5",s.bottom="6",s.horizon="7",s.vertical="8",s))(R||{});const pe={id:"sheet.operation.set-image-align",type:d.CommandType.OPERATION,handler:(s,r)=>!0},me={id:"sheet.operation.open-image-crop",type:d.CommandType.OPERATION,handler:(s,r)=>!0},ee={id:"sheet.operation.close-image-crop",type:d.CommandType.OPERATION,handler:(s,r)=>!0};var L=(s=>(s.FREE="0",s.R1_1="1",s.R16_9="2",s.R9_16="3",s.R5_4="4",s.R4_5="5",s.R4_3="6",s.R3_4="7",s.R3_2="8",s.R2_3="9",s))(L||{});const ce={id:"sheet.operation.Auto-image-crop",type:d.CommandType.OPERATION,handler:(s,r)=>!0},De={id:"sheet.operation.image-reset-size",type:d.CommandType.OPERATION,handler:(s,r)=>!0};function Me(s,r,e,t){const n=t.getDrawingByParam(s);if(n==null)return;const i=M.getDrawingShapeKeyByDrawingSearch(s),a=e.getObject(i);if(a&&!(a instanceof b.Group))return;if(a!=null){a.addObject(r);return}const o=new b.Group(i);e.addObject(o,b.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 Oe(s,r){var i;const e=r?s.getUnit(r):s.getFocusedUnit();if(e==null)return;const t=e.getUnitId();let n;return e.type===d.UniverInstanceType.UNIVER_SHEET?n=(i=e.getActiveSheet())==null?void 0:i.getSheetId():(e.type===d.UniverInstanceType.UNIVER_DOC||e.type===d.UniverInstanceType.UNIVER_SLIDE)&&(n=t),{unitId:t,subUnitId:n,current:e}}const Ze="drawing-ui.config",Te={},Ue="COMPONENT_IMAGE_POPUP_MENU";function F({ref:s,...r}){const{icon:e,id:t,className:n,extend:i,...a}=r,o=`univerjs-icon univerjs-icon-${t} ${n||""}`.trim(),c=_.useRef(`_${Ye()}`);return Ne(e,`${t}`,{defIds:e.defIds,idSuffix:c.current},{ref:s,className:o,...a},i)}function Ne(s,r,e,t,n){return _.createElement(s.tag,{key:r,...Fe(s,e,n),...t},(ze(s,e).children||[]).map((i,a)=>Ne(i,`${r}-${s.tag}-${a}`,e,void 0,n)))}function Fe(s,r,e){const t={...s.attrs};e!=null&&e.colorChannel1&&t.fill==="colorChannel1"&&(t.fill=e.colorChannel1),s.tag==="mask"&&t.id&&(t.id=t.id+r.idSuffix),Object.entries(t).forEach(([i,a])=>{i==="mask"&&typeof a=="string"&&(t[i]=a.replace(/url\(#(.*)\)/,`url(#$1${r.idSuffix})`))});const{defIds:n}=r;return!n||n.length===0||(s.tag==="use"&&t["xlink:href"]&&(t["xlink:href"]=t["xlink:href"]+r.idSuffix),Object.entries(t).forEach(([i,a])=>{typeof a=="string"&&(t[i]=a.replace(/url\(#(.*)\)/,`url(#$1${r.idSuffix})`))})),t}function ze(s,r){var t;const{defIds:e}=r;return!e||e.length===0?s:s.tag==="defs"&&((t=s.children)!=null&&t.length)?{...s,children:s.children.map(n=>typeof n.attrs.id=="string"&&e&&e.includes(n.attrs.id)?{...n,attrs:{...n.attrs,id:n.attrs.id+r.idSuffix}}:n)}:s}function Ye(){return Math.random().toString(36).substring(2,8)}F.displayName="UniverIcon";const Xe={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"}}]},Pe=_.forwardRef(function(r,e){return _.createElement(F,Object.assign({},r,{id:"bottom-icon",ref:e,icon:Xe}))});Pe.displayName="BottomIcon";const qe={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{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(r,e){return _.createElement(F,Object.assign({},r,{id:"create-copy-icon",ref:e,icon:qe}))});Be.displayName="CreateCopyIcon";const Je={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"}}]},Re=_.forwardRef(function(r,e){return _.createElement(F,Object.assign({},r,{id:"group-icon",ref:e,icon:Je}))});Re.displayName="GroupIcon";const Qe={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{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"}}]},je=_.forwardRef(function(r,e){return _.createElement(F,Object.assign({},r,{id:"more-down-icon",ref:e,icon:Qe}))});je.displayName="MoreDownIcon";const 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:"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"}}]},Ae=_.forwardRef(function(r,e){return _.createElement(F,Object.assign({},r,{id:"move-down-icon",ref:e,icon:et}))});Ae.displayName="MoveDownIcon";const tt={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"}}]},Le=_.forwardRef(function(r,e){return _.createElement(F,Object.assign({},r,{id:"move-up-icon",ref:e,icon:tt}))});Le.displayName="MoveUpIcon";const rt={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"}}]},He=_.forwardRef(function(r,e){return _.createElement(F,Object.assign({},r,{id:"topmost-icon",ref:e,icon:rt}))});He.displayName="TopmostIcon";const nt={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"}}]},xe=_.forwardRef(function(r,e){return _.createElement(F,Object.assign({},r,{id:"ungroup-icon",ref:e,icon:nt}))});xe.displayName="UngroupIcon";const 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:"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"}}]},ke=_.forwardRef(function(r,e){return _.createElement(F,Object.assign({},r,{id:"autofill-double-icon",ref:e,icon:it}))});ke.displayName="AutofillDoubleIcon";function $e(s){var m;const{popup:r}=s,e=(m=r==null?void 0:r.extraProps)==null?void 0:m.menuItems;if(!e)return null;const t=H.useDependency(d.ICommandService),n=H.useDependency(d.LocaleService),[i,a]=_.useState(!1),[o,c]=_.useState(!1),u=()=>{c(!0)},l=()=>{c(!1)},g=v=>{a(v)},h=v=>{t.executeCommand(v.commandId,v.commandParams),a(!1)},p=i||o,S=e.filter(v=>!v.disable);return f.jsx("div",{onMouseEnter:u,onMouseLeave:l,children:f.jsx(B.DropdownMenu,{align:"start",items:S.map(v=>({type:"item",children:n.t(v.label),onSelect:()=>h(v)})),open:i,onOpenChange:g,children:f.jsxs("div",{className:B.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",B.borderClassName,{"univer-bg-gray-100 dark:!univer-bg-gray-800":i,"univer-bg-white dark:!univer-bg-gray-900":!i}),children:[f.jsx(ke,{className:"univer-fill-primary-600 univer-text-gray-900 dark:!univer-text-white"}),p&&f.jsx(je,{className:"dark:!univer-text-white"})]})})})}var at=Object.getOwnPropertyDescriptor,st=(s,r,e,t)=>{for(var n=t>1?void 0:t?at(r,e):r,i=s.length-1,a;i>=0;i--)(a=s[i])&&(n=a(n)||n);return n},Ge=(s,r)=>(e,t)=>r(e,t,s);let ve=class extends d.Disposable{constructor(s,r){super(),this._componentManager=s,this._commandService=r,this._init()}_initCustomComponents(){const s=this._componentManager;this.disposeWithMe(s.register(Ue,$e))}_initCommands(){[me,ee,De,pe,ce].forEach(s=>this.disposeWithMe(this._commandService.registerCommand(s)))}_init(){this._initCommands(),this._initCustomComponents()}};ve=st([Ge(0,d.Inject(H.ComponentManager)),Ge(1,d.ICommandService)],ve);function le(s,r){const e=[];return s.forEach(t=>{const{oKey:n,left:i,top:a,height:o,width:c,angle:u}=t,l=r.getDrawingOKey(n);if(l==null)return e.push(null),!0;const{unitId:g,subUnitId:h,drawingId:p,drawingType:S}=l,m={unitId:g,subUnitId:h,drawingId:p,drawingType:S,transform:{left:i,top:a,height:o,width:c,angle:u}};S===d.DrawingTypeEnum.DRAWING_IMAGE&&(m.srcRect=t.srcRect),e.push(m)}),e}var ot=Object.getOwnPropertyDescriptor,ct=(s,r,e,t)=>{for(var n=t>1?void 0:t?ot(r,e):r,i=s.length-1,a;i>=0;i--)(a=s[i])&&(n=a(n)||n);return n},we=(s,r)=>(e,t)=>r(e,t,s);let Se=class extends d.Disposable{constructor(r,e,t,n){super();Q(this,"_sceneListenerOnDrawingMap",new WeakSet);this._currentUniverService=r,this._commandService=e,this._renderManagerService=t,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,e=Oe(this._currentUniverService);if(e==null)return;const{unitId:t,subUnitId:n}=e;Object.keys(r).forEach(i=>{Object.keys(r[i]).forEach(a=>{const o=r[i][a].data;o==null||i!==t||a!==n||Object.keys(o).forEach(c=>{o[c]&&this._insertDrawing([{unitId:i,subUnitId:a,drawingId:c}])})})})}_commandExecutedListener(){this.disposeWithMe(this._commandService.onCommandExecuted(r=>{if(r.id===pe.id){const e=r.params;if(e==null)return;this._drawingAlign(e)}}))}_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 e=this._renderManagerService.getRenderById(r),t=e==null?void 0:e.scene;if(t==null)return null;const n=t.getTransformerByCreate();return{scene:t,transformer:n}}_groupDrawings(r){r.forEach(e=>{this._groupDrawing(e)})}_groupDrawing(r){const{parent:e,children:t}=r,{unitId:n,subUnitId:i,drawingId:a}=e,o=this._getSceneAndTransformerByDrawingSearch(e.unitId);if(o==null)return;const{scene:c,transformer:u}=o;this._commandService.syncExecuteCommand(ee.id);const l=[];if(t.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===b.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:i,drawingId:a}),h=new b.Group(g);c.addObject(h,b.DRAWING_OBJECT_LAYER_INDEX).attachTransformerTo(h),h.addObjects(...l),e.transform&&h.transformByState({left:e.transform.left,top:e.transform.top}),u.clearSelectedObjects(),u.setSelectedControl(h)}_ungroupDrawings(r){r.forEach(e=>{this._ungroupDrawing(e)})}_ungroupDrawing(r){const{parent:e,children:t}=r,n=this._getSceneAndTransformerByDrawingSearch(e.unitId);if(n==null)return;const{scene:i,transformer:a}=n;t.forEach(g=>{const h=M.getDrawingShapeKeyByDrawingSearch(g),p=i.getObjectIncludeInGroup(h);if(p==null)return!0;if(p==null)return;const{transform:S}=g;S!=null&&(p.classType===b.RENDER_CLASS_TYPE.GROUP?p.transformByState({left:S.left,top:S.top}):p.transformByState(S))});const o=M.getDrawingShapeKeyByDrawingSearch(e),c=i.getObject(o),{width:u,height:l}=c;c.getObjects().forEach(g=>{c.removeSelfObjectAndTransform(g.oKey,u,l)}),c.dispose(),a.clearSelectedObjects()}_drawingAlign(r){const{alignType:e}=r,t=this._drawingManagerService.getFocusDrawings();if(e===R.default)return;const n=[];let i=Number.POSITIVE_INFINITY,a=Number.POSITIVE_INFINITY,o=Number.NEGATIVE_INFINITY,c=Number.NEGATIVE_INFINITY,u=0;t.forEach(l=>{const{unitId:g,subUnitId:h,drawingId:p,drawingType:S}=l,m=this._drawingManagerService.getDrawingByParam({unitId:g,subUnitId:h,drawingId:p});if(m==null||m.transform==null)return;n.push({unitId:g,subUnitId:h,drawingId:p,drawingType:S,transform:m.transform});const{left:v=0,top:C=0,width:I=0,height:O=0}=m.transform;i=Math.min(i,v),a=Math.min(a,C),o=Math.max(o,v+I),c=Math.max(c,C+O),u++}),u!==0&&(this._sortDrawingTransform(n,e),this._applyAlignType(n,e,i,a,o,c,u))}_applyAlignType(r,e,t,n,i,a,o){const c=Math.round((i-t)/o*10)/10,u=Math.round((a-n)/o*10)/10,l=[],g=this._getSceneAndTransformerByDrawingSearch(r[0].unitId);if(g==null)return;const{scene:h,transformer:p}=g;r.forEach((S,m)=>{const{unitId:v,subUnitId:C,drawingId:I,transform:O,drawingType:N}=S,{left:j=0,top:D=0,width:T=0,height:E=0}=O;let P=j,U=D;switch(e){case R.left:P=t;break;case R.center:P=t+(i-t)/2-T/2;break;case R.right:P=i-T;break;case R.top:U=n;break;case R.middle:U=n+(a-n)/2-E/2;break;case R.bottom:U=a-E;break;case R.horizon:P=t+c*m;break;case R.vertical:U=n+u*m;break}(P!==j||U!==D)&&l.push({unitId:v,subUnitId:C,drawingId:I,drawingType:N,transform:{left:P,top:U}})}),this._drawingManagerService.featurePluginUpdateNotification(l),p.refreshControls().changeNotification()}_sortDrawingTransform(r,e){r.sort((t,n)=>{const i=t.transform,a=n.transform,{left:o=0,top:c=0,width:u=0,height:l=0}=i,{left:g=0,top:h=0,width:p=0,height:S=0}=a;switch(e){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-h;case R.middle:return c+l/2-(h+S/2);case R.bottom:return c+l-(h+S);case R.horizon:return o+u/2-(g+p/2);case R.vertical:return c+l/2-(h+S/2);default:return 0}})}_drawingArrangeListener(){this.disposeWithMe(this._drawingManagerService.order$.subscribe(r=>{this._drawingArrange(r)}))}_drawingArrange(r){const{unitId:e,subUnitId:t,drawingIds:n}=r,i=this._getSceneAndTransformerByDrawingSearch(e);if(i==null)return;const{scene:a}=i;n.forEach(o=>{const c=M.getDrawingShapeKeyByDrawingSearch({unitId:e,subUnitId:t,drawingId:o}),u=a.fuzzyMathObjects(c,!0);if(u==null||u.length===0)return;const l=this._drawingManagerService.getDrawingOrder(e,t).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 e=[];r.forEach(t=>{const{unitId:n}=t;if(this._drawingManagerService.getDrawingByParam(t)==null)return;const a=this._getSceneAndTransformerByDrawingSearch(n);if(a==null)return;const{scene:o}=a;e.includes(o)||e.push(o)}),e.forEach(t=>{this._sceneListenerOnDrawingMap.has(t)||(this._addListenerOnDrawing(t),this._sceneListenerOnDrawingMap.add(t))})}_drawingRemoveListener(){this.disposeWithMe(this._drawingManagerService.remove$.subscribe(r=>{r.forEach(e=>{var l;const{unitId:t,subUnitId:n,drawingId:i}=e,a=this._getSceneAndTransformerByDrawingSearch(t);if(a==null)return;const{scene:o}=a,c=M.getDrawingShapeKeyByDrawingSearch({unitId:t,subUnitId:n,drawingId:i}),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(e=>{var T;const{unitId:t,subUnitId:n,drawingId:i}=e,a=this._drawingManagerService.getDrawingByParam(e);if(a==null)return;const{transform:o,drawingType:c}=a,u=this._getSceneAndTransformerByDrawingSearch(t);if(u==null)return;const{scene:l,transformer:g}=u;if(o==null)return!0;const{left:h=0,top:p=0,width:S=0,height:m=0,angle:v=0,flipX:C=!1,flipY:I=!1,skewX:O=0,skewY:N=0}=o,j=M.getDrawingShapeKeyByDrawingSearch({unitId:t,subUnitId:n,drawingId:i}),D=l.getObject(j);if(D==null)return!0;D.transformByState({left:h,top:p,width:S,height:m,angle:v,flipX:C,flipY:I,skewX:O,skewY:N}),(T=l.getTransformer())==null||T.debounceRefreshControls()})}))}_drawingRefreshListener(){this.disposeWithMe(this._drawingManagerService.refreshTransform$.subscribe(r=>{r.forEach(e=>{const{unitId:t,subUnitId:n,drawingId:i}=e,a=this._getSceneAndTransformerByDrawingSearch(t);if(a==null)return;const o=this._drawingManagerService.getDrawingByParam(e);if(o==null)return;const{transform:c}=o,{scene:u}=a,l=M.getDrawingShapeKeyByDrawingSearch({unitId:t,subUnitId:n,drawingId:i}),g=u.getObject(l);if(g==null||c==null)return!0;const{left:h=0,top:p=0,width:S=0,height:m=0,angle:v=0,flipX:C=!1,flipY:I=!1,skewX:O=0,skewY:N=0}=c;g.transformByState({left:h,top:p,width:S,height:m,angle:v,flipX:C,flipY:I,skewX:O,skewY:N})})}))}_drawingVisibleListener(){this.disposeWithMe(this._drawingManagerService.visible$.subscribe(r=>{r.forEach(e=>{const{unitId:t,subUnitId:n,drawingId:i,visible:a}=e,o=this._getSceneAndTransformerByDrawingSearch(t);if(o==null)return;const{scene:c}=o,u=M.getDrawingShapeKeyByDrawingSearch({unitId:t,subUnitId:n,drawingId:i}),l=c.getObject(u);if(l==null)return!0;a?l.show():l.hide()})}))}_filterUpdateParams(r,e){return r.filter((t,n)=>{if(t==null)return!1;const{transform:i}=t;return d.checkIfMove(i,e==null?void 0:e[n])})}_addListenerOnDrawing(r){const e=r.getTransformerByCreate();let t=null;this.disposeWithMe(d.toDisposable(e.changeStart$.subscribe(n=>{const{objects:i}=n,a=Array.from(i.values()),o=[];t=a.map(c=>{const{left:u,top:l,height:g,width:h,angle:p,oKey:S,isInGroup:m}=c,v=this._drawingManagerService.getDrawingOKey(S);if(m||c instanceof b.Group){let C=c.ancestorGroup;if(C==null&&c instanceof b.Group&&(C=c),C==null)return null;const I=this._drawingManagerService.getDrawingOKey(C.oKey);if(I){const{unitId:O,subUnitId:N,drawingId:j}=I;o.push({unitId:O,subUnitId:N,drawingId:j});const{left:D,top:T,height:E,width:P,angle:U}=C;return{left:D,top:T,height:E,width:P,angle:U}}}else if(v!=null){const{unitId:C,subUnitId:I,drawingId:O}=v;return o.push({unitId:C,subUnitId:I,drawingId:O}),{left:u,top:l,height:g,width:h,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(d.toDisposable(e.changeEnd$.subscribe(n=>{const{objects:i}=n,a=this._filterUpdateParams(le(i,this._drawingManagerService),t);a.length>0&&this._drawingManagerService.featurePluginUpdateNotification(a)})))}};Se=ct([we(0,d.IUniverInstanceService),we(1,d.ICommandService),we(2,b.IRenderManagerService),we(3,M.IDrawingManagerService)],Se);class ue extends b.Shape{constructor(e,t){t==null&&(t={}),t.transformerConfig={keepRatio:!1,isCropper:!0,anchorFill:"rgb(0, 0, 0)",anchorStroke:"rgb(255, 255, 255)",anchorSize:24};super(e,t);Q(this,"_srcRect");Q(this,"_prstGeom");Q(this,"_applyTransform");Q(this,"_dragPadding",8);Q(this,"_cacheCanvas");t!=null&&t.srcRect&&(this._srcRect=t.srcRect),t!=null&&t.prstGeom&&(this._prstGeom=t.prstGeom),t!=null&&t.applyTransform&&(this._applyTransform=t.applyTransform),t!=null&&t.dragPadding&&(this._dragPadding=t.dragPadding),this._applyProps()}refreshSrcRect(e,t){this._srcRect=e,this._applyTransform=t,this._applyProps()}get srcRect(){return this._srcRect}dispose(){var e;super.dispose(),(e=this._cacheCanvas)==null||e.dispose(),this._srcRect=null}isHit(e){const t=this.getInverseCoord(e);return t.x>=-this.strokeWidth/2&&t.x<=this.width+this.strokeWidth/2&&t.y>=-this.strokeWidth/2&&t.y<=this.height+this.strokeWidth/2&&!this._inSurround(t)}_inSurround(e){const t=this._dragPadding;return e.x>=t-this.strokeWidth/2&&e.x<=this.width+this.strokeWidth/2-t&&e.y>=t-this.strokeWidth/2&&e.y<=this.height+this.strokeWidth/2-t}render(e,t){return this.visible?(e.save(),this._draw(e),e.restore(),this.makeDirty(!1),this):(this.makeDirty(!1),this)}_draw(e){var c,u;const n=this.getScene().getEngine(),{width:i,height:a}=n;this._initialCacheCanvas(),(c=this._cacheCanvas)==null||c.clear();const o=(u=this._cacheCanvas)==null?void 0:u.getContext();o!=null&&(o.save(),b.Rect.drawWith(o,{left:0,top:0,width:i,height:a,fill:"rgba(0, 0, 0, 0.5)"}),o.setTransform(e.getTransform()),this._clipForApplyObject(o),this._applyCache(e),o.restore())}_clipForApplyObject(e){let t=0;if(this._prstGeom!=null&&(t=1),e.globalCompositeOperation="destination-out",e.beginPath(),t===0){const n=this.transform.getMatrix();e.transform(n[0],n[1],n[2],n[3],n[4],n[5]),e.rect(0,0,this.width,this.height),e.fill()}}_applyProps(){if(this._applyTransform==null)return;let e=0,t=0,n=0,i=0;const{left:a=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;e=p,t=S,n=m,i=v}const g=a+e,h=o+t;this.transformByState({left:g,top:h,width:a+c-n-g,height:o+u-i-h,angle:l})}_applyCache(e){if(!e||this._cacheCanvas==null)return;const t=this._cacheCanvas.getContext();t.save(),e.save(),e.setTransform(1,0,0,1,0,0),t.setTransform(1,0,0,1,0,0),e.drawImage(this._cacheCanvas.getCanvasEle(),0,0),e.restore(),t.restore()}_initialCacheCanvas(){if(this._cacheCanvas!=null)return;const e=this.getScene();if(e==null)return;this._cacheCanvas=new b.Canvas;const t=e.getEngine();this._cacheCanvas.setSize(t.width,t.height),t.onTransformChange$.subscribeEvent(()=>{var n;(n=this._cacheCanvas)==null||n.setSize(t.width,t.height),this.makeDirty(!0)})}}var lt=Object.getOwnPropertyDescriptor,ut=(s,r,e,t)=>{for(var n=t>1?void 0:t?lt(r,e):r,i=s.length-1,a;i>=0;i--)(a=s[i])&&(n=a(n)||n);return n},se=(s,r)=>(e,t)=>r(e,t,s);let _e=class extends d.Disposable{constructor(r,e,t,n,i,a){super();Q(this,"_sceneListenerOnImageMap",new WeakSet);this._commandService=r,this._drawingManagerService=e,this._renderManagerService=t,this._univerInstanceService=n,this._messageService=i,this._localeService=a,this._init()}_init(){this._initOpenCrop(),this._initCloseCrop(),this._initAutoCrop()}_initAutoCrop(){this.disposeWithMe(this._commandService.onCommandExecuted(r=>{if(r.id!==ce.id)return;const e=r.params;if(e==null)return;const{cropType:t}=e,n=this._drawingManagerService.getFocusDrawings();if(n.length!==1)return;const i=n[0],{unitId:a,subUnitId:o,drawingId:c}=i,u=this._renderManagerService.getRenderById(a),l=u==null?void 0:u.scene;if(l==null)return!0;this._searchCropObject(l)!=null&&this._commandService.syncExecuteCommand(ee.id,{isAuto:!0});const h=M.getDrawingShapeKeyByDrawingSearch({unitId:a,subUnitId:o,drawingId:c}),p=l.getObject(h);if(!(p instanceof b.Image)){this._messageService.show({type:B.MessageType.Error,content:this._localeService.t("image-cropper.error")});return}p!=null&&(this._updateCropperObject(t,p),this._commandService.executeCommand(me.id,{unitId:a,subUnitId:o,drawingId:c}))}))}_calculateSrcRectByRatio(r,e,t,n,i,a){const o=t/n,c=i/a;let u=t,l=n;o>c?u=n*c:l=t/c;const g=(t-u)/2,h=(n-l)/2;return{left:b.precisionTo(g,1),top:b.precisionTo(h,1),right:b.precisionTo(t-(g+u),1),bottom:b.precisionTo(n-(h+l),1)}}_updateCropperObject(r,e){const{left:t,top:n,width:i,height:a}=e.calculateTransformWithSrcRect();let o;switch(r){case L.R1_1:o=this._calculateSrcRectByRatio(t,n,i,a,1,1);break;case L.R16_9:o=this._calculateSrcRectByRatio(t,n,i,a,16,9);break;case L.R9_16:o=this._calculateSrcRectByRatio(t,n,i,a,9,16);break;case L.R5_4:o=this._calculateSrcRectByRatio(t,n,i,a,5,4);break;case L.R4_5:o=this._calculateSrcRectByRatio(t,n,i,a,4,5);break;case L.R4_3:o=this._calculateSrcRectByRatio(t,n,i,a,4,3);break;case L.R3_4:o=this._calculateSrcRectByRatio(t,n,i,a,3,4);break;case L.R3_2:o=this._calculateSrcRectByRatio(t,n,i,a,3,2);break;case L.R2_3:o=this._calculateSrcRectByRatio(t,n,i,a,2,3);break;case L.FREE:}if(o==null)return;e.setSrcRect(o);const{left:c=0,top:u=0,bottom:l=0,right:g=0}=o;e.transformByStateCloseCropper({left:t+c,top:n+u,width:i-g-c,height:a-l-u})}_initOpenCrop(){this.disposeWithMe(this._commandService.onCommandExecuted(r=>{if(r.id!==me.id)return;const e=r.params;if(e==null)return;const{unitId:t,subUnitId:n,drawingId:i}=e,a=this._renderManagerService.getRenderById(t),o=a==null?void 0:a.scene;if(o==null)return!0;if(this._sceneListenerOnImageMap.has(o)||(this._addListenerOnImage(o),this._sceneListenerOnImageMap.add(o)),this._drawingManagerService.getDrawingByParam({unitId:t,subUnitId:n,drawingId:i})==null)return;const u=M.getDrawingShapeKeyByDrawingSearch({unitId:t,subUnitId:n,drawingId:i}),l=o.getObject(u);if(l==null)return;if(!(l instanceof b.Image)){this._messageService.show({type:B.MessageType.Error,content:this._localeService.t("image-cropper.error")});return}const g=o.getTransformer();g==null||g.clearControls();const h=new ue(`${u}-crop`,{srcRect:l.srcRect,prstGeom:l.prstGeom,applyTransform:l.calculateTransformWithSrcRect()});o.addObject(h,l.getLayerIndex()+1).attachTransformerTo(h),g==null||g.createControlForCopper(h),this._addHoverForImageCopper(h),l.openRenderByCropper(),g==null||g.refreshControls(),h.makeDirty(!0),this._commandService.syncExecuteCommand(M.SetDrawingSelectedOperation.id,[{unitId:t,subUnitId:n,drawingId:i}])}))}_searchCropObject(r){const e=r.getAllObjectsByOrder();for(const t of e)if(t instanceof ue)return t}_initCloseCrop(){this.disposeWithMe(this._commandService.onCommandExecuted(e=>{if(e.id!==ee.id)return;const t=this._univerInstanceService.getFocusedUnit();if(t==null)return;const n=t.getUnitId(),i=this._renderManagerService.getRenderById(n),a=i==null?void 0:i.scene;if(a==null)return!0;const o=this._searchCropObject(a);if(o==null)return;const c=this._getApplyObjectByCropObject(o);if(c==null)return;const u=a.getTransformerByCreate();u.detachFrom(o),u.clearCopperControl();const l=this._getSrcRectByTransformState(c,o),g=this._drawingManagerService.getDrawingOKey(c.oKey);if(g!=null){const{left:h,top:p,height:S,width:m}=o;this._drawingManagerService.featurePluginUpdateNotification([{...g,transform:{...g.transform,left:h,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$(d.UniverInstanceType.UNIVER_SHEET).pipe(te.switchMap(e=>e?e.activeSheet$:te.of(null)));this.disposeWithMe(r.subscribe(()=>{this._commandService.syncExecuteCommand(ee.id)}))}_getApplyObjectByCropObject(r){const e=r.oKey,t=e.slice(0,e.length-5),n=r.getScene();if(!n)return null;const i=n.getObject(t);return i==null?null:i}_addListenerOnImage(r){const e=r.getTransformerByCreate();let t=null;this.disposeWithMe(e.changeStart$.subscribe(n=>{const{objects:i}=n,a=i.values().next().value;if(a==null||!(a instanceof ue))return;const{left:o,top:c,height:u,width:l,angle:g}=a;t={left:o,top:c,height:u,width:l,angle:g},e.clearCopperControl()})),this.disposeWithMe(e.changeEnd$.subscribe(n=>{const{objects:i}=n,a=i.values().next().value;if(a==null||!(a instanceof ue))return;const{left:o,top:c,height:u,width:l,angle:g}=a;if(!d.checkIfMove({left:o,top:c,height:u,width:l,angle:g},t))return;const h=this._getApplyObjectByCropObject(a);if(h==null)return;const p=this._getSrcRectByTransformState(h,a);a.refreshSrcRect(p.srcRect,h.getState()),e.createControlForCopper(a)})),this._endCropListener(r)}_addHoverForImageCopper(r){this.disposeWithMe(r.onPointerEnter$.subscribeEvent(()=>{r.cursor=b.CURSOR_TYPE.MOVE})),this.disposeWithMe(r.onPointerLeave$.subscribeEvent(()=>{r.cursor=b.CURSOR_TYPE.DEFAULT}))}_endCropListener(r){const e=r.getTransformerByCreate();this.disposeWithMe(e.clearControl$.subscribe(t=>{t===!0&&this._commandService.syncExecuteCommand(ee.id)}))}_getSrcRectByTransformState(r,e){const{left:t,top:n,height:i,width:a,strokeWidth:o,angle:c}=e,{left:u,top:l,width:g,height:h,angle:p,strokeWidth:S}=r,m=t-u,v=n-l,C={left:m,top:v,right:g-m-a,bottom:h-v-i},I={...C};if(p!==0){const O=t+a/2,N=n+i/2,j=new b.Vector2(O,N),D=g/2+u,T=h/2+l,E=new b.Vector2(D,T),P=new b.Vector2(u,l);P.rotateByPoint(b.degToRad(p),E);const U=P.clone();U.rotateByPoint(b.degToRad(-p),j);const $=t-U.x,x=n-U.y;I.left=$,I.top=x,I.right=g-$-a,I.bottom=h-x-i}return{srcRect:C,srcRectAngle:I}}};_e=ut([se(0,d.ICommandService),se(1,M.IDrawingManagerService),se(2,b.IRenderManagerService),se(3,d.IUniverInstanceService),se(4,H.IMessageService),se(5,d.Inject(d.LocaleService))],_e);var gt=Object.getOwnPropertyDescriptor,dt=(s,r,e,t)=>{for(var n=t>1?void 0:t?gt(r,e):r,i=s.length-1,a;i>=0;i--)(a=s[i])&&(n=a(n)||n);return n},ge=(s,r)=>(e,t)=>r(e,t,s);y.DrawingRenderService=class{constructor(r,e,t,n,i){this._drawingManagerService=r,this._imageIoService=e,this._galleryService=t,this._urlImageService=n,this._univerInstanceService=i}async renderImages(r,e){const{transform:t,drawingType:n,source:i,imageSourceType:a,srcRect:o,prstGeom:c,groupId:u,unitId:l,subUnitId:g,drawingId:h,isMultiTransform:p,transforms:S}=r;if(n!==d.DrawingTypeEnum.DRAWING_IMAGE||!this._drawingManagerService.getDrawingVisible()||this._univerInstanceService.getUnitType(l)===d.UniverInstanceType.UNIVER_SHEET&&g!==this._getActiveSheetId()||t==null)return;const m=p&&S?S:[t],v=[];for(const C of m){const{left:I,top:O,width:N,height:j,angle:D,flipX:T,flipY:E,skewX:P,skewY:U}=C,$=m.indexOf(C),x=M.getDrawingShapeKeyByDrawingSearch({unitId:l,subUnitId:g,drawingId:h},p?$:void 0),V=e.getObject(x);if(V!=null){V.transformByState({left:I,top:O,width:N,height:j,angle:D,flipX:T,flipY:E,skewX:P,skewY:U});continue}const Y=this._drawingManagerService.getDrawingOrder(l,g),oe=Y.indexOf(h),X={...C,zIndex:oe===-1?Y.length-1:oe},ne=this._imageIoService.getImageSourceCache(i,a);let ie=!1;if(ne!=null)X.image=ne;else if(a===M.ImageSourceType.UUID)try{X.url=await this._imageIoService.getImage(i)}catch(de){console.error(de);continue}else if(a===M.ImageSourceType.URL){try{X.url=await this._urlImageService.getImage(i)}catch(de){console.error(de),X.url=i}ie=!0}else X.url=i,ie=!0;if(e.getObject(x))continue;X.printable=!0;const q=new b.Image(x,X);ie&&this._imageIoService.addImageSourceCache(i,a,q.getNative()),e.addObject(q,b.DRAWING_OBJECT_LAYER_INDEX),this._drawingManagerService.getDrawingEditable()&&e.attachTransformerTo(q),u&&Me({drawingId:u,unitId:l,subUnitId:g},q,e,this._drawingManagerService),c!=null&&q.setPrstGeom(c),o!=null&&q.setSrcRect(o),v.push(q)}return v}_getActiveSheetId(){var r,e;return(e=(r=this._univerInstanceService.getCurrentUnitOfType(d.UniverInstanceType.UNIVER_SHEET))==null?void 0:r.getActiveSheet())==null?void 0:e.getSheetId()}renderFloatDom(r,e){const{transform:t,drawingType:n,groupId:i,unitId:a,subUnitId:o,drawingId:c,isMultiTransform:u,transforms:l}=r;if(n!==d.DrawingTypeEnum.DRAWING_DOM||!this._drawingManagerService.getDrawingVisible()||t==null)return;const g=u&&l?l:[t],h=[];for(const p of g){const{left:S,top:m,width:v,height:C,angle:I,flipX:O,flipY:N,skewX:j,skewY:D}=p,T=g.indexOf(p),E=M.getDrawingShapeKeyByDrawingSearch({unitId:a,subUnitId:o,drawingId:c},u?T:void 0),P=e.getObject(E);if(P!=null){P.transformByState({left:S,top:m,width:v,height:C,angle:I,flipX:O,flipY:N,skewX:j,skewY:D});continue}const U=this._drawingManagerService.getDrawingOrder(a,o),$=U.indexOf(c),x={...p,zIndex:$===-1?U.length-1:$};if(e.getObject(E))continue;x.printable=!1;const V=new b.Rect(E,x);this._drawingManagerService.getDrawingVisible()&&(e.addObject(V,b.DRAWING_OBJECT_LAYER_INDEX),this._drawingManagerService.getDrawingEditable()&&r.allowTransform!==!1&&e.attachTransformerTo(V),i&&Me({drawingId:i,unitId:a,subUnitId:o},V,e,this._drawingManagerService),h.push(V))}return h}renderDrawing(r,e){const t=this._drawingManagerService.getDrawingByParam(r);if(t!=null&&t.drawingType===d.DrawingTypeEnum.DRAWING_IMAGE)return this.renderImages(t,e)}previewImage(r,e,t,n){this._galleryService.open({images:[e],onOpenChange:i=>{i||this._galleryService.close()}})}_adjustImageSize(r,e,t,n){if(r<=t&&e<=n)return{width:r,height:e};const i=t/r,a=n/e,o=Math.min(i,a);return{width:Math.floor(r*o),height:Math.floor(e*o)}}},y.DrawingRenderService=dt([ge(0,M.IDrawingManagerService),ge(1,M.IImageIoService),ge(2,H.IGalleryService),ge(3,d.IURLImageService),ge(4,d.IUniverInstanceService)],y.DrawingRenderService);var ht=Object.getOwnPropertyDescriptor,ft=(s,r,e,t)=>{for(var n=t>1?void 0:t?ht(r,e):r,i=s.length-1,a;i>=0;i--)(a=s[i])&&(n=a(n)||n);return n},re=(s,r)=>(e,t)=>r(e,t,s);let Ce=class extends d.Disposable{constructor(s,r,e,t,n,i,a){super(),this._commandService=s,this._renderManagerService=r,this._drawingManagerService=e,this._dialogService=t,this._imageIoService=n,this._currentUniverService=i,this._drawingRenderService=a,this._initialize()}dispose(){super.dispose()}_initialize(){this._drawingAddListener(),this._commandExecutedListener(),this._imageUpdateListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.onCommandExecuted(s=>{if(s.id===De.id){const r=s.params;if(r==null)return;this._resetImageSize(r)}}))}_getSceneAndTransformerByDrawingSearch(s){if(s==null)return;const r=this._renderManagerService.getRenderById(s),e=r==null?void 0:r.scene;if(e==null)return null;const t=e.getTransformerByCreate();return{scene:e,transformer:t}}_resetImageSize(s){const r=[],e=[];s.forEach(t=>{const{unitId:n,subUnitId:i,drawingId:a}=t,o=this._getSceneAndTransformerByDrawingSearch(n);if(o==null)return;const{scene:c}=o,u=M.getDrawingShapeKeyByDrawingSearch({unitId:n,subUnitId:i,drawingId:a}),l=c.getObject(u);if(l==null)return!0;const g=this._drawingManagerService.getDrawingByParam(t);if(g==null)return!0;if(g.drawingType!==d.DrawingTypeEnum.DRAWING_IMAGE)return;l.resetSize();const{width:h,height:p}=l.getNativeSize();e.includes(c)===!1&&e.push(c),r.push({...g,transform:{...g.transform,height:p,width:h,angle:0},srcRect:null,prstGeom:null})}),this._drawingManagerService.featurePluginUpdateNotification(r),e.forEach(t=>{t.getTransformerByCreate().refreshControls().changeNotification()}),this._commandService.syncExecuteCommand(M.SetDrawingSelectedOperation.id,s)}_drawingAddListener(){this.disposeWithMe(this._drawingManagerService.add$.pipe(te.bufferTime(33),te.filter(s=>s.length>0),te.map(s=>s.flat()),te.map(s=>{const r=new Map;for(const e of s)r.set(`${e.unitId}|${e.subUnitId}|${e.drawingId}`,e);return[...r.values()]}),te.filter(s=>s.length>0)).subscribe(s=>{this._insertImages(s)}))}_insertImages(s){s.forEach(async r=>{var c;const{unitId:e,subUnitId:t}=r,n=this._getSceneAndTransformerByDrawingSearch(e),i=(c=Oe(this._currentUniverService,e))==null?void 0:c.subUnitId;if(n==null||i!==t)return;const a=this._drawingManagerService.getDrawingByParam(r);if(a==null)return;const o=await this._drawingRenderService.renderImages(a,n.scene);if(this._drawingManagerService.refreshTransform([a]),!(o==null||o.length===0))for(const u of o)this._addHoverForImage(u),this._addDialogForImage(u)})}_imageUpdateListener(){this.disposeWithMe(this._drawingManagerService.update$.subscribe(s=>{s.forEach(r=>{const{unitId:e,subUnitId:t,drawingId:n}=r,i=this._drawingManagerService.getDrawingByParam(r);if(i==null)return;const{transform:a,drawingType:o,srcRect:c,prstGeom:u,source:l,imageSourceType:g}=i;if(o!==d.DrawingTypeEnum.DRAWING_IMAGE)return;const h=this._getSceneAndTransformerByDrawingSearch(e);if(h==null)return;const{scene:p,transformer:S}=h;if(a==null)return!0;const m=M.getDrawingShapeKeyByDrawingSearch({unitId:e,subUnitId:t,drawingId:n}),v=p.getObject(m);if(v==null)return!0;v.setSrcRect(c),v.setPrstGeom(u),l!=null&&l.length>0&&(g===d.ImageSourceType.BASE64||g===d.ImageSourceType.URL)&&v.changeSource(l)})}))}_addHoverForImage(s){this.disposeWithMe(d.toDisposable(s.onPointerEnter$.subscribeEvent(()=>{s.cursor=b.CURSOR_TYPE.GRAB}))),this.disposeWithMe(d.toDisposable(s.onPointerLeave$.subscribeEvent(()=>{s.cursor=b.CURSOR_TYPE.DEFAULT})))}_addDialogForImage(s){this.disposeWithMe(d.toDisposable(s.onDblclick$.subscribeEvent(()=>{const r=`${s.oKey}-viewer-dialog`;this._drawingRenderService.previewImage(r,s.getNative().src,s.getNativeSize().width,s.getNativeSize().height)})))}};Ce=ft([re(0,d.ICommandService),re(1,b.IRenderManagerService),re(2,M.IDrawingManagerService),re(3,H.IDialogService),re(4,M.IImageIoService),re(5,d.IUniverInstanceService),re(6,d.Inject(y.DrawingRenderService))],Ce);var pt=Object.getOwnPropertyDescriptor,mt=(s,r,e,t)=>{for(var n=t>1?void 0:t?pt(r,e):r,i=s.length-1,a;i>=0;i--)(a=s[i])&&(n=a(n)||n);return n},Ve=(s,r)=>(e,t)=>r(e,t,s);const vt="UNIVER_DRAWING_UI_PLUGIN";y.UniverDrawingUIPlugin=(Ee=class extends d.Plugin{constructor(r=Te,e,t){super(),this._config=r,this._injector=e,this._configService=t;const{menu:n,...i}=d.merge({},Te,this._config);n&&this._configService.setConfig("menu",n,{merge:!0}),this._configService.setConfig(Ze,i)}onStarting(){this._initDependencies()}onRendered(){this._injector.get(Se),this._injector.get(ve),this._injector.get(_e),this._injector.get(Ce)}_initDependencies(){[[y.DrawingRenderService],[Se],[ve],[_e],[Ce]].forEach(e=>this._injector.add(e))}},Q(Ee,"pluginName",vt),Ee),y.UniverDrawingUIPlugin=mt([Ve(1,d.Inject(d.Injector)),Ve(2,d.IConfigService)],y.UniverDrawingUIPlugin);const wt=s=>{const r=H.useDependency(d.ICommandService),e=H.useDependency(d.LocaleService),{alignShow:t}=s,[n,i]=_.useState(R.default),a=[{label:e.t("image-panel.align.default"),value:R.default},{options:[{label:e.t("image-panel.align.left"),value:R.left},{label:e.t("image-panel.align.center"),value:R.center},{label:e.t("image-panel.align.right"),value:R.right}]},{options:[{label:e.t("image-panel.align.top"),value:R.top},{label:e.t("image-panel.align.middle"),value:R.middle},{label:e.t("image-panel.align.bottom"),value:R.bottom}]},{options:[{label:e.t("image-panel.align.horizon"),value:R.horizon},{label:e.t("image-panel.align.vertical"),value:R.vertical}]}];function o(c){i(c),r.executeCommand(pe.id,{alignType:c})}return f.jsxs("div",{className:B.clsx("univer-relative univer-w-full",{"univer-hidden":!t}),children:[f.jsx("header",{className:"univer-text-gray-600 dark:!univer-text-gray-200",children:f.jsx("div",{children:e.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(B.Select,{value:n,options:a,onChange:o})})})]})},St=s=>{const{arrangeShow:r,drawings:e}=s,t=H.useDependency(d.LocaleService),n=H.useDependency(M.IDrawingManagerService),[i,a]=_.useState(e);_.useEffect(()=>{const c=n.focus$.subscribe(u=>{a(u)});return()=>{c.unsubscribe()}},[]);const o=c=>{const u=i[0].unitId,l=i[0].subUnitId,g=i.map(h=>h.drawingId);n.featurePluginOrderUpdateNotification({unitId:u,subUnitId:l,drawingIds:g,arrangeType:c})};return f.jsxs("div",{className:B.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:t.t("image-panel.arrange.title")})}),f.jsxs("div",{className:"univer-grid univer-grid-cols-2 univer-gap-2",children:[f.jsxs(B.Button,{onClick:()=>{o(d.ArrangeTypeEnum.forward)},children:[f.jsx(Le,{}),t.t("image-panel.arrange.forward")]}),f.jsxs(B.Button,{onClick:()=>{o(d.ArrangeTypeEnum.backward)},children:[f.jsx(Ae,{}),t.t("image-panel.arrange.backward")]}),f.jsxs(B.Button,{onClick:()=>{o(d.ArrangeTypeEnum.front)},children:[f.jsx(He,{}),t.t("image-panel.arrange.front")]}),f.jsxs(B.Button,{onClick:()=>{o(d.ArrangeTypeEnum.back)},children:[f.jsx(Pe,{}),t.t("image-panel.arrange.back")]})]})]})},_t=s=>{const r=H.useDependency(d.LocaleService),e=H.useDependency(b.IRenderManagerService),t=H.useDependency(M.IDrawingManagerService),{hasGroup:n,drawings:i}=s,[a,o]=_.useState(!1),[c,u]=_.useState(!0),[l,g]=_.useState(!0),h=()=>{const m=t.getFocusDrawings(),{unitId:v,subUnitId:C}=m[0],I=d.generateRandomId(10),O=b.getGroupState(0,0,m.map(D=>D.transform||{})),N={unitId:v,subUnitId:C,drawingId:I,drawingType:d.DrawingTypeEnum.DRAWING_GROUP,transform:O},j=m.map(D=>{const T=D.transform||{left:0,top:0},{unitId:E,subUnitId:P,drawingId:U}=D;return{unitId:E,subUnitId:P,drawingId:U,transform:{...T,left:T.left-O.left,top:T.top-O.top},groupId:I}});t.featurePluginGroupUpdateNotification([{parent:N,children:j}])},p=m=>{if(m.drawingType!==d.DrawingTypeEnum.DRAWING_GROUP)return;const{unitId:v,subUnitId:C,drawingId:I,transform:O={width:0,height:0}}=m;if(O==null)return;const N=t.getDrawingsByGroup({unitId:v,subUnitId:C,drawingId:I});if(N.length===0)return;const j=N.map(D=>{const{transform:T}=D,{unitId:E,subUnitId:P,drawingId:U}=D,$=b.transformObjectOutOfGroup(T||{},O,O.width||0,O.height||0);return{unitId:E,subUnitId:P,drawingId:U,transform:{...T,...$},groupId:void 0}});return{parent:m,children:j}},S=()=>{const v=t.getFocusDrawings().map(C=>p(C)).filter(C=>C!=null);v.length!==0&&t.featurePluginUngroupUpdateNotification(v)};return _.useEffect(()=>{const m=i[0];if(m==null)return;const{unitId:v}=m,C=e.getRenderById(v),I=C==null?void 0:C.scene;if(I==null)return;const O=I.getTransformerByCreate(),N=O.clearControl$.subscribe(D=>{D===!0&&o(!1)}),j=O.changeStart$.subscribe(D=>{const{objects:T}=D,E=le(T,t),P=E.filter(V=>(V==null?void 0:V.drawingType)===d.DrawingTypeEnum.DRAWING_GROUP);let U=!1,$=!1;E.length>1&&(U=!0),P.length>0&&($=!0),o(U||$),u(U),g($)});return()=>{j.unsubscribe(),N.unsubscribe()}},[]),f.jsxs("div",{className:B.clsx("univer-grid univer-gap-2 univer-py-2 univer-text-gray-400",{"univer-hidden":n===!0&&a===!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(B.Button,{className:B.clsx({"univer-hidden":!c}),onClick:h,children:[f.jsx(Re,{}),r.t("image-panel.group.group")]}),f.jsxs(B.Button,{className:B.clsx({"univer-hidden":!l}),onClick:S,children:[f.jsx(xe,{}),r.t("image-panel.group.unGroup")]})]})]})},Ie=20,ye=20,We=[-360,360],be=300,Ct=s=>{var Ke;const r=H.useDependency(d.LocaleService),e=H.useDependency(M.IDrawingManagerService),t=H.useDependency(b.IRenderManagerService),{drawings:n,transformShow:i}=s,a=n[0];if(a==null)return;const o=a.transform;if(o==null)return;const{unitId:c,subUnitId:u,drawingId:l,drawingType:g}=a,h=t.getRenderById(c),p=h==null?void 0:h.scene;if(p==null)return;const S=(Ke=p.getEngine())==null?void 0:Ke.activeScene;if(S==null)return;const m=p.getTransformerByCreate(),{width:v=0,height:C=0,left:I=0,top:O=0,angle:N=0}=o,[j,D]=_.useState(v),[T,E]=_.useState(C),[P,U]=_.useState(I),[$,x]=_.useState(O),[V,Y]=_.useState(N),[oe,X]=_.useState(m.keepRatio),ne=(w,A,G,W)=>{const{width:k,height:J}=S,{ancestorLeft:K,ancestorTop:Z}=p;let z=w,ae=A,he=G,fe=W;return w+K<0&&(z=-K),A+Z<0&&(ae=-Z),he=k-z-K,he<Ie&&(he=Ie),fe=J-ae-Z,fe<ye&&(fe=ye),w+he+K>k&&(z=k-G-K),A+fe+Z>J&&(ae=J-W-Z),{limitLeft:z,limitTop:ae,limitWidth:he,limitHeight:fe}},ie=w=>{const{objects:A}=w,G=le(A,e);if(G.length!==1)return;const W=G[0];if(W==null)return;const{transform:k}=W;if(k==null)return;const{width:J,height:K,left:Z,top:z,angle:ae}=k;J!=null&&D(J),K!=null&&E(K),Z!=null&&U(Z),z!=null&&x(z),ae!=null&&Y(ae)};_.useEffect(()=>{const w=[m.changeStart$.subscribe(A=>{ie(A)}),m.changing$.subscribe(A=>{ie(A)}),m.changeEnd$.subscribe(A=>{ie(A)}),e.focus$.subscribe(A=>{if(A.length!==1)return;const G=e.getDrawingByParam(A[0]);if(G==null)return;const W=G.transform;if(W==null)return;const{width:k,height:J,left:K,top:Z,angle:z}=W;k!=null&&D(k),J!=null&&E(J),K!=null&&U(K),Z!=null&&x(Z),z!=null&&Y(z)})];return()=>{w.forEach(A=>A.unsubscribe())}},[]);const q=d.debounce(w=>{if(w==null)return;const{limitWidth:A,limitHeight:G}=ne(P,$,w,T);w=Math.min(w,A);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,ye),k>G)return;E(k),W.transform.height=k}D(w),e.featurePluginUpdateNotification([W]),m.refreshControls().changeNotification()},be),de=d.debounce(w=>{if(w==null)return;const{limitHeight:A,limitWidth:G}=ne(P,$,j,w);w=Math.min(w,A);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,Ie),k>G)return;D(k),W.transform.width=k}E(w),e.featurePluginUpdateNotification([W]),m.refreshControls().changeNotification()},be),bt=d.debounce(w=>{if(w==null)return;const{limitLeft:A}=ne(w,$,j,T);w=A;const G={unitId:c,subUnitId:u,drawingId:l,drawingType:g,transform:{left:w}};U(w),e.featurePluginUpdateNotification([G]),m.refreshControls().changeNotification()},be),Dt=d.debounce(w=>{if(w==null)return;const{limitTop:A}=ne(P,w,j,T);w=A;const G={unitId:c,subUnitId:u,drawingId:l,drawingType:g,transform:{top:w}};x(w),e.featurePluginUpdateNotification([G]),m.refreshControls().changeNotification()},be),Mt=w=>{if(w==null)return;const A={unitId:c,subUnitId:u,drawingId:l,drawingType:g,transform:{angle:w}};Y(w),e.featurePluginUpdateNotification([A]),m.refreshControls().changeNotification()},Ot=w=>{X(w),m.keepRatio=w};return f.jsxs("div",{className:B.clsx("univer-grid univer-gap-2 univer-py-2 univer-text-gray-400",{"univer-hidden":!i}),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(B.InputNumber,{precision:1,value:j,min:Ie,onChange:w=>{q(w)}})]}),f.jsxs("div",{children:[f.jsx("span",{children:r.t("image-panel.transform.height")}),f.jsx(B.InputNumber,{precision:1,value:T,min:ye,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(B.Checkbox,{checked:oe,onChange:Ot})})]})]}),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(B.InputNumber,{precision:1,value:P,onChange:w=>{bt(w)}})]}),f.jsxs("div",{children:[f.jsx("span",{children:r.t("image-panel.transform.y")}),f.jsx(B.InputNumber,{precision:1,value:$,onChange:w=>{Dt(w)}})]}),f.jsxs("div",{children:[f.jsx("span",{children:r.t("image-panel.transform.rotate")}),f.jsx(B.InputNumber,{precision:1,value:V,min:We[0],max:We[1],onChange:Mt})]})]})]})},It=s=>{const r=H.useDependency(d.ICommandService),e=H.useDependency(d.LocaleService),{drawings:t,cropperShow:n}=s;if(t[0]==null)return;const[a,o]=_.useState(L.FREE),c=_.useRef(!1),u=[{label:e.t("image-panel.crop.mode"),value:L.FREE},{label:"1:1",value:L.R1_1},{label:"16:9",value:L.R16_9},{label:"9:16",value:L.R9_16},{label:"5:4",value:L.R5_4},{label:"4:5",value:L.R4_5},{label:"4:3",value:L.R4_3},{label:"3:4",value:L.R3_4},{label:"3:2",value:L.R3_2},{label:"2:3",value:L.R2_3}];_.useEffect(()=>{const h=r.onCommandExecuted(p=>{if(p.id===ee.id){const S=p.params;S!=null&&S.isAuto||(c.current=!1)}});return()=>{h==null||h.dispose()}},[]);function l(h){o(h),c.current&&r.executeCommand(ce.id,{cropType:h})}const g=h=>{r.executeCommand(ce.id,{cropType:h}),c.current=!0};return f.jsxs("div",{className:B.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:e.t("image-panel.crop.title")})}),f.jsxs("div",{className:"univer-flex univer-items-center univer-justify-center univer-gap-2",children:[f.jsxs(B.Button,{onClick:()=>{g(a)},children:[f.jsx(Be,{}),e.t("image-panel.crop.start")]}),f.jsx(B.Select,{value:a,options:u,onChange:l})]})]})},yt=s=>{const r=H.useDependency(M.IDrawingManagerService),e=H.useDependency(b.IRenderManagerService),t=H.useDependency(d.LocaleService),{drawings:n,hasArrange:i=!0,hasTransform:a=!0,hasAlign:o=!0,hasCropper:c=!0,hasGroup:u=!0}=s,l=n[0];if(l==null)return;const{unitId:g}=l,h=e.getRenderById(g),p=h==null?void 0:h.scene;if(p==null)return;const S=p.getTransformerByCreate(),[m,v]=_.useState(!0),[C,I]=_.useState(!0),[O,N]=_.useState(!1),[j,D]=_.useState(!0),[T,E]=_.useState(!1);return _.useEffect(()=>{const P=S.clearControl$.subscribe(x=>{x===!0&&(v(!1),I(!1),N(!1),D(!1),E(!0))}),U=S.changeStart$.subscribe(x=>{const{objects:V}=x,Y=le(V,r);Y.length===0?(v(!1),I(!1),N(!1),D(!1),E(!0)):Y.length===1?(v(!0),I(!0),N(!1),D(!0),E(!1)):(v(!0),I(!1),N(!0),D(!1),E(!1))}),$=r.focus$.subscribe(x=>{x.length===0?(v(!1),I(!1),N(!1),D(!1),E(!0)):x.length===1?(v(!0),I(!0),N(!1),D(!0),E(!1)):(v(!0),I(!1),N(!0),D(!1),E(!1))});return()=>{U.unsubscribe(),P.unsubscribe(),$.unsubscribe()}},[]),f.jsxs(f.Fragment,{children:[f.jsx("div",{className:B.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:t.t("image-panel.null")})})}),f.jsx(St,{arrangeShow:i===!0?m:!1,drawings:n}),f.jsx(Ct,{transformShow:a===!0?C:!1,drawings:n}),f.jsx(wt,{alignShow:o===!0?O:!1,drawings:n}),f.jsx(It,{cropperShow:c===!0?j:!1,drawings:n}),f.jsx(_t,{hasGroup:u,drawings:n})]})};y.AutoImageCropOperation=ce,y.COMPONENT_IMAGE_POPUP_MENU=Ue,y.CloseImageCropOperation=ee,y.DrawingCommonPanel=yt,y.ImageCropperObject=ue,y.ImagePopupMenu=$e,y.ImageResetSizeOperation=De,y.OpenImageCropOperation=me,y.SetDrawingAlignOperation=pe,y.getCurrentUnitInfo=Oe,y.getUpdateParams=le,y.insertGroupObject=Me,Object.defineProperty(y,Symbol.toStringTag,{value:"Module"})}));
7
7
 
8
8
 
9
9
  // @univerjs/sheets-drawing/index
@@ -11,8 +11,8 @@
11
11
 
12
12
 
13
13
  // @univerjs/sheets-drawing-ui/index
14
- (function(b,P){typeof exports=="object"&&typeof module<"u"?P(exports,require("@univerjs/engine-render"),require("@univerjs/sheets-ui"),require("@univerjs/core"),require("@univerjs/sheets-drawing"),require("@univerjs/sheets"),require("@univerjs/design"),require("@univerjs/docs-ui"),require("@univerjs/drawing"),require("@univerjs/ui"),require("@univerjs/docs-drawing"),require("@univerjs/drawing-ui"),require("rxjs"),require("react/jsx-runtime"),require("react")):typeof define=="function"&&define.amd?define(["exports","@univerjs/engine-render","@univerjs/sheets-ui","@univerjs/core","@univerjs/sheets-drawing","@univerjs/sheets","@univerjs/design","@univerjs/docs-ui","@univerjs/drawing","@univerjs/ui","@univerjs/docs-drawing","@univerjs/drawing-ui","rxjs","react/jsx-runtime","react"],P):(b=typeof globalThis<"u"?globalThis:b||self,P(b.UniverSheetsDrawingUi={},b.UniverEngineRender,b.UniverSheetsUi,b.UniverCore,b.UniverSheetsDrawing,b.UniverSheets,b.UniverDesign,b.UniverDocsUi,b.UniverDrawing,b.UniverUi,b.UniverDocsDrawing,b.UniverDrawingUi,b.rxjs,b.React,b.React))})(this,(function(b,P,U,l,w,y,H,Le,B,j,Ot,he,W,$,Z){"use strict";var ir=Object.defineProperty;var or=(b,P,U)=>P in b?ir(b,P,{enumerable:!0,configurable:!0,writable:!0,value:U}):b[P]=U;var oe=(b,P,U)=>or(b,typeof P!="symbol"?P+"":P,U);function ee(i,r,e){const{from:t,to:n,flipY:o=!1,flipX:s=!1,angle:a=0,skewX:c=0,skewY:g=0}=i,u=e.getCurrent();if(u==null)return;const d=U.convertPositionSheetOverGridToAbsolute(u.unitId,u.sheetId,{from:t,to:n},e);let{left:m,top:h,width:p,height:S}=d;const f=e.getCurrentSkeleton(),v=f.rowHeaderWidth+f.columnTotalWidth,I=f.columnHeaderHeight+f.rowTotalHeight;return m+p>v&&(m=v-p),h+S>I&&(h=I-S),{flipY:o,flipX:s,angle:a,skewX:c,skewY:g,left:m,top:h,width:p,height:S}}function x(i,r){const{left:e=0,top:t=0,width:n=0,height:o=0,flipY:s=!1,flipX:a=!1,angle:c=0,skewX:g=0,skewY:u=0}=i,d=r.getCellWithCoordByOffset(e,t);if(d==null)return;const m={column:d.actualColumn,columnOffset:P.precisionTo(e-d.startX,1),row:d.actualRow,rowOffset:P.precisionTo(t-d.startY,1)},h=r.getCellWithCoordByOffset(e+n,t+o);if(h==null)return;const p={column:h.actualColumn,columnOffset:P.precisionTo(e+n-h.startX,1),row:h.actualRow,rowOffset:P.precisionTo(t+o-h.startY,1)};return{flipY:s,flipX:a,angle:c,skewX:g,skewY:u,from:m,to:p}}function G(i,r){const{left:e=0,top:t=0,width:n=0,height:o=0,angle:s=0}=i,a=(s%360+360)%360;if(!(a>=45&&a<135||a>=225&&a<315))return x(i,r);const g={...i,left:e+n/2-o/2,top:t+o/2-n/2,width:o,height:n};return x(g,r)}const V={id:"sheet.operation.clear-drawing-transformer",type:l.CommandType.MUTATION,handler:(i,r)=>{const e=i.get(P.IRenderManagerService);return r.forEach(t=>{var n,o;(o=(n=e.getRenderById(t))==null?void 0:n.scene.getTransformer())==null||o.debounceRefreshControls()}),!0}},we={id:"sheet.command.remove-sheet-image",type:l.CommandType.COMMAND,handler:(i,r)=>{var I,D,O;const e=i.get(l.ICommandService),t=i.get(l.IUndoRedoService),n=i.get(y.SheetInterceptorService),o=i.get(w.ISheetDrawingService);if(!r)return!1;const{drawings:s}=r,a=[];s.forEach(T=>{const{unitId:C}=T;a.push(C)});const c=o.getBatchRemoveOp(s),{unitId:g,subUnitId:u,undo:d,redo:m,objects:h}=c,p=n.onCommandExecute({id:we.id,params:r}),S={id:w.SetDrawingApplyMutation.id,params:{unitId:g,subUnitId:u,op:m,objects:h,type:w.DrawingApplyType.REMOVE}},f={id:w.SetDrawingApplyMutation.id,params:{unitId:g,subUnitId:u,op:d,objects:h,type:w.DrawingApplyType.INSERT}};return l.sequenceExecute([...(I=p.preRedos)!=null?I:[],S,...p.redos],e)?(t.pushUndoRedo({unitID:g,undoMutations:[...(D=p.preUndos)!=null?D:[],f,...p.undos,{id:V.id,params:a}],redoMutations:[...(O=p.preRedos)!=null?O:[],S,...p.redos,{id:V.id,params:a}]}),!0):!1}},gt={id:"sheet.command.delete-drawing",type:l.CommandType.COMMAND,handler:i=>{const r=i.get(l.ICommandService),t=i.get(w.ISheetDrawingService).getFocusDrawings();if(t.length===0)return!1;const n=t[0].unitId,o=t.map(s=>{const{unitId:a,subUnitId:c,drawingId:g,drawingType:u}=s;return{unitId:a,subUnitId:c,drawingId:g,drawingType:u}});return r.executeCommand(we.id,{unitId:n,drawings:o})}};function zt(i){const r=[];return i.forEach(e=>{const{parent:t,children:n}=e,{unitId:o,subUnitId:s,drawingId:a}=t,c=P.getGroupState(0,0,n.map(d=>d.transform||{})),g=n.map(d=>{const m=d.transform||{left:0,top:0},{unitId:h,subUnitId:p,drawingId:S}=d;return{unitId:h,subUnitId:p,drawingId:S,transform:{...m,left:m.left-c.left,top:m.top-c.top},groupId:a}}),u={unitId:o,subUnitId:s,drawingId:a,drawingType:l.DrawingTypeEnum.DRAWING_GROUP,transform:c};r.push({parent:u,children:g})}),r}function qt(i){const r=[];return i.forEach(e=>{const{parent:t,children:n}=e,{unitId:o,subUnitId:s,drawingId:a,transform:c={width:0,height:0}}=t;if(c==null)return;const g=n.map(d=>{const{transform:m}=d,{unitId:h,subUnitId:p,drawingId:S}=d,f=P.transformObjectOutOfGroup(m||{},c,c.width||0,c.height||0);return{unitId:h,subUnitId:p,drawingId:S,transform:f,groupId:void 0}}),u={unitId:o,subUnitId:s,drawingId:a,drawingType:l.DrawingTypeEnum.DRAWING_GROUP,transform:{left:0,top:0}};r.push({parent:u,children:g})}),r}const ht={id:"sheet.command.group-sheet-image",type:l.CommandType.COMMAND,handler:(i,r)=>{const e=i.get(l.ICommandService),t=i.get(l.IUndoRedoService),n=i.get(w.ISheetDrawingService);if(!r)return!1;const o=[];r.forEach(({parent:h,children:p})=>{o.push(h.unitId),p.forEach(S=>{o.push(S.unitId)})});const s=n.getGroupDrawingOp(r),{unitId:a,subUnitId:c,undo:g,redo:u,objects:d}=s;return e.syncExecuteCommand(w.SetDrawingApplyMutation.id,{op:u,unitId:a,subUnitId:c,objects:d,type:w.DrawingApplyType.GROUP})?(t.pushUndoRedo({unitID:a,undoMutations:[{id:w.SetDrawingApplyMutation.id,params:{op:g,unitId:a,subUnitId:c,objects:qt(d),type:w.DrawingApplyType.UNGROUP}},{id:V.id,params:o}],redoMutations:[{id:w.SetDrawingApplyMutation.id,params:{op:u,unitId:a,subUnitId:c,objects:d,type:w.DrawingApplyType.GROUP}},{id:V.id,params:o}]}),!0):!1}},Oe={id:"sheet.command.insert-sheet-image",type:l.CommandType.COMMAND,handler:(i,r)=>{var I,D,O;const e=i.get(l.ICommandService),t=i.get(l.IUndoRedoService),n=i.get(w.ISheetDrawingService),o=i.get(y.SheetInterceptorService);if(!r)return!1;const s=r.drawings,a=s.map(T=>T.unitId),c=n.getBatchAddOp(s),{unitId:g,subUnitId:u,undo:d,redo:m,objects:h}=c,p=o.onCommandExecute({id:Oe.id,params:r}),S={id:w.SetDrawingApplyMutation.id,params:{op:m,unitId:g,subUnitId:u,objects:h,type:w.DrawingApplyType.INSERT}},f={id:w.SetDrawingApplyMutation.id,params:{op:d,unitId:g,subUnitId:u,objects:h,type:w.DrawingApplyType.REMOVE}};return l.sequenceExecute([...(I=p.preRedos)!=null?I:[],S,...p.redos],e)?(t.pushUndoRedo({unitID:g,undoMutations:[...(D=p.preUndos)!=null?D:[],f,...p.undos,{id:V.id,params:a}],redoMutations:[...(O=p.preRedos)!=null?O:[],S,...p.redos,{id:V.id,params:a}]}),!0):!1}},mt={id:"sheet.command.set-drawing-arrange",type:l.CommandType.COMMAND,handler:(i,r)=>{const e=i.get(l.ICommandService),t=i.get(l.IUndoRedoService);if(!r)return!1;const n=i.get(w.ISheetDrawingService),{unitId:o,subUnitId:s,drawingIds:a,arrangeType:c}=r,g={unitId:o,subUnitId:s,drawingIds:a};let u;if(c===l.ArrangeTypeEnum.forward?u=n.getForwardDrawingsOp(g):c===l.ArrangeTypeEnum.backward?u=n.getBackwardDrawingOp(g):c===l.ArrangeTypeEnum.front?u=n.getFrontDrawingsOp(g):c===l.ArrangeTypeEnum.back&&(u=n.getBackDrawingsOp(g)),u==null)return!1;const{objects:d,redo:m,undo:h}=u;return e.syncExecuteCommand(w.SetDrawingApplyMutation.id,{op:m,unitId:o,subUnitId:s,objects:d,type:w.DrawingApplyType.ARRANGE})?(t.pushUndoRedo({unitID:o,undoMutations:[{id:w.SetDrawingApplyMutation.id,params:{op:h,unitId:o,subUnitId:s,objects:d,type:w.DrawingApplyType.ARRANGE}}],redoMutations:[{id:w.SetDrawingApplyMutation.id,params:{op:m,unitId:o,subUnitId:s,objects:d,type:w.DrawingApplyType.ARRANGE}}]}),!0):!1}},ve={id:"sheet.command.set-sheet-image",type:l.CommandType.COMMAND,handler:(i,r)=>{var v,I;const e=i.get(l.ICommandService),t=i.get(l.IUndoRedoService),n=i.get(w.ISheetDrawingService),o=i.get(y.SheetInterceptorService);if(!r)return!1;const{drawings:s}=r,a=n.getBatchUpdateOp(s),{unitId:c,subUnitId:g,undo:u,redo:d,objects:m}=a,h=o.onCommandExecute({id:ve.id,params:r}),p=[...(v=h.preRedos)!=null?v:[],{id:w.SetDrawingApplyMutation.id,params:{unitId:c,subUnitId:g,op:d,objects:m,type:w.DrawingApplyType.UPDATE}},...h.redos,{id:V.id,params:[c]}],S=[...(I=h.preUndos)!=null?I:[],{id:w.SetDrawingApplyMutation.id,params:{unitId:c,subUnitId:g,op:u,objects:m,type:w.DrawingApplyType.UPDATE}},...h.undos,{id:V.id,params:[c]}];return l.sequenceExecute(p,e)?(t.pushUndoRedo({unitID:c,undoMutations:S,redoMutations:p}),!0):!1}},pt={id:"sheet.command.ungroup-sheet-image",type:l.CommandType.COMMAND,handler:(i,r)=>{const e=i.get(l.ICommandService),t=i.get(l.IUndoRedoService),n=i.get(w.ISheetDrawingService);if(!r)return!1;const o=[];r.forEach(({parent:h,children:p})=>{o.push(h.unitId),p.forEach(S=>{o.push(S.unitId)})});const s=n.getUngroupDrawingOp(r),{unitId:a,subUnitId:c,undo:g,redo:u,objects:d}=s;return e.syncExecuteCommand(w.SetDrawingApplyMutation.id,{op:u,unitId:a,subUnitId:c,objects:d,type:w.DrawingApplyType.UNGROUP})?(t.pushUndoRedo({unitID:a,undoMutations:[{id:w.SetDrawingApplyMutation.id,params:{op:g,unitId:a,subUnitId:c,objects:zt(d),type:w.DrawingApplyType.GROUP}},{id:V.id,params:o}],redoMutations:[{id:w.SetDrawingApplyMutation.id,params:{op:u,unitId:a,subUnitId:c,objects:d,type:w.DrawingApplyType.UNGROUP}},{id:V.id,params:o}]}),!0):!1}};var Zt=Object.getOwnPropertyDescriptor,Jt=(i,r,e,t)=>{for(var n=t>1?void 0:t?Zt(r,e):r,o=i.length-1,s;o>=0;o--)(s=i[o])&&(n=s(n)||n);return n},ne=(i,r)=>(e,t)=>r(e,t,i);function Qt(i,r,e){const t=e*Math.PI/180,n=Math.abs(i*Math.cos(t))+Math.abs(r*Math.sin(t)),o=Math.abs(i*Math.sin(t))+Math.abs(r*Math.cos(t));return{rotatedWidth:n,rotatedHeight:o}}function St(i,r,e,t,n){var I;const{rotatedHeight:o,rotatedWidth:s}=Qt(e,t,n),c=i.get(P.IRenderManagerService).getRenderById(r.unitId);if(!c)return!1;const u=(I=c.with(U.SheetSkeletonManagerService).getSkeletonParam(r.subUnitId))==null?void 0:I.skeleton;if(u==null)return!1;const d=u.getCellByIndex(r.row,r.col),m=d.mergeInfo.endX-d.mergeInfo.startX-2,h=d.mergeInfo.endY-d.mergeInfo.startY-2,p=s/o,f=Math.ceil(Math.min(m,h*p))/s,v=!f||Number.isNaN(f)?.001:f;return{width:e*v,height:t*v}}b.SheetDrawingUpdateController=class extends l.Disposable{constructor(e,t,n,o,s,a,c,g,u,d,m,h,p,S){super();oe(this,"_workbookSelections");this._context=e,this._skeletonManagerService=t,this._commandService=n,this._selectionRenderService=o,this._imageIoService=s,this._fileOpenerService=a,this._sheetDrawingService=c,this._drawingManagerService=g,this._contextService=u,this._messageService=d,this._localeService=m,this._injector=p,this._urlImageService=S,this._workbookSelections=h.getWorkbookSelections(this._context.unitId),this._updateImageListener(),this._updateOrderListener(),this._groupDrawingListener(),this._focusDrawingListener()}async insertFloatImage(){const e=await this._fileOpenerService.openFile({multiple:!0,accept:B.DRAWING_IMAGE_ALLOW_IMAGE_LIST.map(n=>`.${n.replace("image/","")}`).join(",")}),t=e.length;return t>B.DRAWING_IMAGE_COUNT_LIMIT?(this._messageService.show({type:H.MessageType.Error,content:this._localeService.t("update-status.exceedMaxCount",String(B.DRAWING_IMAGE_COUNT_LIMIT))}),!1):t===0?!1:(e.forEach(async n=>await this.insertFloatImageByFile(n)),!0)}async insertCellImage(){const t=(await this._fileOpenerService.openFile({multiple:!1,accept:B.DRAWING_IMAGE_ALLOW_IMAGE_LIST.map(n=>`.${n.replace("image/","")}`).join(",")}))[0];return t?(await this._insertCellImage(t),!0):!1}insertCellImageByFile(e,t){return this._insertCellImage(e,t)}async insertFloatImageByFile(e){var O;let t;try{t=await this._imageIoService.saveImage(e)}catch(T){const C=T.message;C===B.ImageUploadStatusType.ERROR_EXCEED_SIZE?this._messageService.show({type:H.MessageType.Error,content:this._localeService.t("update-status.exceedMaxSize",String(B.DRAWING_IMAGE_ALLOW_SIZE/(1024*1024)))}):C===B.ImageUploadStatusType.ERROR_IMAGE_TYPE?this._messageService.show({type:H.MessageType.Error,content:this._localeService.t("update-status.invalidImageType")}):C===B.ImageUploadStatusType.ERROR_IMAGE&&this._messageService.show({type:H.MessageType.Error,content:this._localeService.t("update-status.invalidImage")})}if(t==null)return;const n=this._getUnitInfo(),{unitId:o,subUnitId:s}=n,{imageId:a,imageSourceType:c,source:g,base64Cache:u}=t,{width:d,height:m,image:h}=await B.getImageSize(u||""),{width:p,height:S}=this._context.scene;this._imageIoService.addImageSourceCache(g,c,h);let f=1;if(d>B.DRAWING_IMAGE_WIDTH_LIMIT||m>B.DRAWING_IMAGE_HEIGHT_LIMIT){const T=B.DRAWING_IMAGE_WIDTH_LIMIT/d,C=B.DRAWING_IMAGE_HEIGHT_LIMIT/m;f=Math.max(T,C)}const v=this._getImagePosition(d*f,m*f,p,S);if(v==null)return;const I=ee(v,this._selectionRenderService,this._skeletonManagerService),D={unitId:o,subUnitId:s,drawingId:a,drawingType:l.DrawingTypeEnum.DRAWING_IMAGE,imageSourceType:c,source:g,transform:I,sheetTransform:v,axisAlignSheetTransform:(O=G(I,this._selectionRenderService))!=null?O:v};return this._commandService.executeCommand(Oe.id,{unitId:o,drawings:[D]})}async _insertCellImage(e,t){var O,T;let n;try{n=await this._imageIoService.saveImage(e)}catch(C){const M=C.message;M===B.ImageUploadStatusType.ERROR_EXCEED_SIZE?this._messageService.show({type:H.MessageType.Error,content:this._localeService.t("update-status.exceedMaxSize",String(B.DRAWING_IMAGE_ALLOW_SIZE/(1024*1024)))}):M===B.ImageUploadStatusType.ERROR_IMAGE_TYPE?this._messageService.show({type:H.MessageType.Error,content:this._localeService.t("update-status.invalidImageType")}):M===B.ImageUploadStatusType.ERROR_IMAGE&&this._messageService.show({type:H.MessageType.Error,content:this._localeService.t("update-status.invalidImage")})}if(n==null)return!1;const{imageId:o,imageSourceType:s,source:a,base64Cache:c}=n,{width:g,height:u,image:d}=await B.getImageSize(c||"");this._imageIoService.addImageSourceCache(a,s,d);const m=this._workbookSelections.getCurrentLastSelection();if(!m)return!1;let h=m.primary.actualRow,p=m.primary.actualColumn;m.primary.isMerged&&(h=m.primary.startRow,p=m.primary.startColumn);const S=l.createDocumentModelWithStyle("",{}),f=St(this._injector,{unitId:this._context.unitId,subUnitId:this._context.unit.getActiveSheet().getSheetId(),row:h,col:p},g,u,0);if(!f)return!1;const v={size:{width:f.width,height:f.height},positionH:{relativeFrom:l.ObjectRelativeFromH.PAGE,posOffset:0},positionV:{relativeFrom:l.ObjectRelativeFromV.PARAGRAPH,posOffset:0},angle:0},I={unitId:S.getUnitId(),subUnitId:S.getUnitId(),drawingId:o,drawingType:l.DrawingTypeEnum.DRAWING_IMAGE,imageSourceType:s,source:a,transform:Le.docDrawingPositionToTransform(v),docTransform:v,behindDoc:l.BooleanNumber.FALSE,title:"",description:"",layoutType:l.PositionedObjectLayoutType.INLINE,wrapText:l.WrapTextType.BOTH_SIDES,distB:0,distL:0,distR:0,distT:0},D=l.BuildTextUtils.drawing.add({documentDataModel:S,drawings:[I],selection:{collapsed:!0,startOffset:0,endOffset:0}});return D?(S.apply(D),this._commandService.syncExecuteCommand(y.SetRangeValuesCommand.id,{value:{[(O=t==null?void 0:t.row)!=null?O:h]:{[(T=t==null?void 0:t.col)!=null?T:p]:{p:S.getSnapshot(),t:1}}},unitId:t==null?void 0:t.unitId,subUnitId:t==null?void 0:t.subUnitId})):!1}async insertCellImageByUrl(e,t){var p,S;let n=e;try{n=await this._urlImageService.getImage(e)}catch(f){console.error(`Failed to get image from URLImageService: ${e}`,f)}const{width:o,height:s,image:a}=await B.getImageSize(n||"");this._imageIoService.addImageSourceCache(e,l.ImageSourceType.URL,a);const c=this._workbookSelections.getCurrentLastSelection();if(!c)return!1;const g=l.createDocumentModelWithStyle("",{}),u=St(this._injector,{unitId:this._context.unitId,subUnitId:this._context.unit.getActiveSheet().getSheetId(),row:c.primary.actualRow,col:c.primary.actualColumn},o,s,0);if(!u)return!1;const d={size:{width:u.width,height:u.height},positionH:{relativeFrom:l.ObjectRelativeFromH.PAGE,posOffset:0},positionV:{relativeFrom:l.ObjectRelativeFromV.PARAGRAPH,posOffset:0},angle:0},m={unitId:g.getUnitId(),subUnitId:g.getUnitId(),drawingId:l.generateRandomId(),drawingType:l.DrawingTypeEnum.DRAWING_IMAGE,imageSourceType:l.ImageSourceType.URL,source:e,transform:Le.docDrawingPositionToTransform(d),docTransform:d,behindDoc:l.BooleanNumber.FALSE,title:"",description:"",layoutType:l.PositionedObjectLayoutType.INLINE,wrapText:l.WrapTextType.BOTH_SIDES,distB:0,distL:0,distR:0,distT:0},h=l.BuildTextUtils.drawing.add({documentDataModel:g,drawings:[m],selection:{collapsed:!0,startOffset:0,endOffset:0}});return h?(g.apply(h),this._commandService.syncExecuteCommand(y.SetRangeValuesCommand.id,{value:{[(p=t==null?void 0:t.row)!=null?p:c.primary.actualRow]:{[(S=t==null?void 0:t.col)!=null?S:c.primary.actualColumn]:{p:g.getSnapshot(),t:1}}},unitId:t==null?void 0:t.unitId,subUnitId:t==null?void 0:t.subUnitId})):!1}_getUnitInfo(){const e=this._context.unit,t=e.getActiveSheet(),n=e.getUnitId(),o=t.getSheetId();return{unitId:n,subUnitId:o}}_getImagePosition(e,t,n,o){const s=this._workbookSelections.getCurrentSelections();let a={startRow:0,endRow:0,startColumn:0,endColumn:0};s&&s.length>0&&(a=s[s.length-1].range);const c=U.attachRangeWithCoord(this._skeletonManagerService.getCurrent().skeleton,a);if(c==null)return;let{startColumn:g,startRow:u,startX:d,startY:m}=c,h=!1;if(d+e>n&&(d=n-e,d<0&&(d=0,e=n),h=!0),m+t>o&&(m=o-t,m<0&&(m=0,t=o),h=!0),h){const v=this._selectionRenderService.getCellWithCoordByOffset(d,m);if(v==null)return;d=v.startX,m=v.startY,g=v.actualColumn,u=v.actualRow}const p={column:g,columnOffset:0,row:u,rowOffset:0},S=this._selectionRenderService.getCellWithCoordByOffset(d+e,m+t);if(S==null)return;const f={column:S.actualColumn,columnOffset:d+e-S.startX,row:S.actualRow,rowOffset:m+t-S.startY};return{from:p,to:f}}_updateOrderListener(){this.disposeWithMe(this._drawingManagerService.featurePluginOrderUpdate$.subscribe(e=>{const{unitId:t,subUnitId:n,drawingIds:o,arrangeType:s}=e;this._commandService.executeCommand(mt.id,{unitId:t,subUnitId:n,drawingIds:o,arrangeType:s})}))}_updateImageListener(){this.disposeWithMe(this._drawingManagerService.featurePluginUpdate$.subscribe(e=>{const t=[];e.length!==0&&(e.forEach(n=>{const{unitId:o,subUnitId:s,drawingId:a,drawingType:c,transform:g}=n;if(g==null)return;const u=this._sheetDrawingService.getDrawingByParam({unitId:o,subUnitId:s,drawingId:a});if(u==null||u.unitId!==this._context.unitId)return;const d=x({...u.transform,...g},this._selectionRenderService),m=G({...u.transform,...g},this._selectionRenderService);if(d==null||m==null)return;const h={...n,transform:{...u.transform,...g,...ee(d,this._selectionRenderService,this._skeletonManagerService)},sheetTransform:{...d},axisAlignSheetTransform:{...m}};t.push(h)}),t.length>0&&this._commandService.executeCommand(ve.id,{unitId:e[0].unitId,drawings:t}))}))}_getSheetTransformByParam(e){const{unitId:t,subUnitId:n,drawingId:o,transform:s}=e;if(s==null)return null;const a=this._sheetDrawingService.getDrawingByParam({unitId:t,subUnitId:n,drawingId:o});if(a==null||a.unitId!==this._context.unitId)return null;const c=x({...a.transform,...s},this._selectionRenderService),g=G({...a.transform,...s},this._selectionRenderService);return c==null||g==null?null:{sheetTransform:c,axisAlignSheetTransform:g}}_groupDrawingListener(){this.disposeWithMe(this._drawingManagerService.featurePluginGroupUpdate$.subscribe(e=>{const t=[];for(const n of e){const o=this._getSheetTransformByParam(n.parent),s=[];for(const c of n.children){const g=this._getSheetTransformByParam(c);g!=null&&s.push({...c,sheetTransform:g.sheetTransform,axisAlignSheetTransform:g.axisAlignSheetTransform})}const a={parent:{...n.parent,sheetTransform:o},children:s};t.push(a)}if(t.length>0){this._commandService.executeCommand(ht.id,t);const{unitId:n,subUnitId:o,drawingId:s}=e[0].parent;this._commandService.syncExecuteCommand(B.SetDrawingSelectedOperation.id,[{unitId:n,subUnitId:o,drawingId:s}])}})),this.disposeWithMe(this._drawingManagerService.featurePluginUngroupUpdate$.subscribe(e=>{const t=[];for(const n of e){const{children:o}=n,s=[];for(const a of o){const c=this._getSheetTransformByParam(a);c!=null&&s.push({...a,sheetTransform:c})}t.push({...n,children:s})}this._commandService.executeCommand(pt.id,t)}))}_focusDrawingListener(){this.disposeWithMe(this._drawingManagerService.focus$.subscribe(e=>{e==null||e.length===0?(this._contextService.setContextValue(l.FOCUSING_COMMON_DRAWINGS,!1),this._sheetDrawingService.focusDrawing([])):(this._contextService.setContextValue(l.FOCUSING_COMMON_DRAWINGS,!0),this._sheetDrawingService.focusDrawing(e))}))}},b.SheetDrawingUpdateController=Jt([ne(1,l.Inject(U.SheetSkeletonManagerService)),ne(2,l.ICommandService),ne(3,U.ISheetSelectionRenderService),ne(4,B.IImageIoService),ne(5,j.ILocalFileService),ne(6,w.ISheetDrawingService),ne(7,B.IDrawingManagerService),ne(8,l.IContextService),ne(9,j.IMessageService),ne(10,l.Inject(l.LocaleService)),ne(11,l.Inject(y.SheetsSelectionsService)),ne(12,l.Inject(l.Injector)),ne(13,l.IURLImageService)],b.SheetDrawingUpdateController);const Ae={id:"sheet.command.insert-float-image",type:l.CommandType.COMMAND,handler:async(i,r)=>{var s,a;const e=i.get(l.IUniverInstanceService),t=i.get(P.IRenderManagerService),n=(s=P.getCurrentTypeOfRenderer(l.UniverInstanceType.UNIVER_SHEET,e,t))==null?void 0:s.with(b.SheetDrawingUpdateController);if(!n)return!1;const o=r==null?void 0:r.files;if(o){const c=o.map(g=>n.insertFloatImageByFile(g));return(await Promise.all(c)).every(g=>g)}else return(a=n.insertFloatImage())!=null?a:!1}},ft={id:"sheet.command.insert-cell-image",type:l.CommandType.COMMAND,handler:i=>{var t,n;const r=i.get(l.IUniverInstanceService),e=i.get(P.IRenderManagerService);return(n=(t=P.getCurrentTypeOfRenderer(l.UniverInstanceType.UNIVER_SHEET,r,e))==null?void 0:t.with(b.SheetDrawingUpdateController).insertCellImage())!=null?n:!1}},_e={id:"sheet.command.move-drawing",type:l.CommandType.COMMAND,handler:(i,r)=>{const e=i.get(l.ICommandService),t=i.get(w.ISheetDrawingService),n=i.get(U.ISheetSelectionRenderService),{direction:o}=r,s=t.getFocusDrawings();if(s.length===0)return!1;const a=s[0].unitId,c=s.map(u=>{const{transform:d}=u;if(d==null)return null;const m={...d},{left:h=0,top:p=0}=d;return o===l.Direction.UP?m.top=p-1:o===l.Direction.DOWN?m.top=p+1:o===l.Direction.LEFT?m.left=h-1:o===l.Direction.RIGHT&&(m.left=h+1),{...u,transform:m,sheetTransform:x(m,n),axisAlignSheetTransform:G(m,n)}}).filter(u=>u!=null);return e.syncExecuteCommand(ve.id,{unitId:a,drawings:c})?(e.syncExecuteCommand(V.id,[a]),!0):!1}};var en=Object.getOwnPropertyDescriptor,tn=(i,r,e,t)=>{for(var n=t>1?void 0:t?en(r,e):r,o=i.length-1,s;o>=0;o--)(s=i[o])&&(n=s(n)||n);return n},$e=(i,r)=>(e,t)=>r(e,t,i),me=(i=>(i.CELL_ADDRESS="cellAddress",i.COLUMN_VALUE="columnValue",i))(me||{});const Ye=l.createIdentifier("sheets-drawing-ui.batch-save-images.service");function wt(i){let r="",e=i;for(;e>=0;)r=String.fromCharCode(e%26+65)+r,e=Math.floor(e/26)-1;return r}function xe(i,r){return`${wt(r)}${i+1}`}function nn(i){const r=xe(i.startRow,i.startColumn),e=xe(i.endRow,i.endColumn);return r===e?r:`${r}:${e}`}function At(i){var r,e,t,n;return!!((e=(r=i==null?void 0:i.p)==null?void 0:r.drawingsOrder)!=null&&e.length&&((n=(t=i==null?void 0:i.p)==null?void 0:t.drawingsOrder)==null?void 0:n.length)>0)}function Ut(i){var t,n,o;if(!((n=(t=i.p)==null?void 0:t.drawingsOrder)!=null&&n.length)||!((o=i.p)!=null&&o.drawings))return null;const r=i.p.drawingsOrder[0],e=i.p.drawings[r];return!e||!("source"in e)||!("imageSourceType"in e)?null:e}function vt(i,r){if(r===l.ImageSourceType.BASE64){const e=i.match(/^data:image\/(\w+);/);if(e)return e[1]==="jpeg"?"jpg":e[1]}if(r===l.ImageSourceType.URL){const e=i.match(/\.(\w+)(?:\?|$)/);if(e)return e[1].toLowerCase()}return"png"}async function Pt(i,r){if(r===l.ImageSourceType.BASE64)return(await fetch(i)).blob();if(r===l.ImageSourceType.URL)return(await fetch(i)).blob();throw new Error("UUID image type requires additional handling")}b.BatchSaveImagesService=class extends l.Disposable{constructor(r,e,t,n){super(),this._univerInstanceService=r,this._selectionService=e,this._imageIoService=t,this._urlImageService=n}registerURLImageDownloader(r){return this._urlImageService.registerURLImageDownloader(r)}getCellImagesInSelection(){const r=this._univerInstanceService.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET);if(!r)return[];const e=r.getActiveSheet();if(!e)return[];const t=this._selectionService.getCurrentSelections();if(!t||t.length===0)return[];const n=e.getCellMatrix(),o=[];for(const s of t){const{startRow:a,endRow:c,startColumn:g,endColumn:u}=s.range;for(let d=a;d<=c;d++)for(let m=g;m<=u;m++){const h=n.getValue(d,m);if(At(h)){const p=Ut(h);p&&o.push({row:d,col:m,cellAddress:xe(d,m),source:p.source,imageSourceType:p.imageSourceType,imageId:p.drawingId})}}}return o}getCellImagesFromRanges(r,e,t){const n=this._univerInstanceService.getUnit(r,l.UniverInstanceType.UNIVER_SHEET);if(!n)return[];const o=n.getSheetBySheetId(e);if(!o)return[];const s=o.getCellMatrix(),a=[];for(const c of t){const{startRow:g,endRow:u,startColumn:d,endColumn:m}=c;for(let h=g;h<=u;h++)for(let p=d;p<=m;p++){const S=s.getValue(h,p);if(At(S)){const f=Ut(S);f&&a.push({row:h,col:p,cellAddress:xe(h,p),source:f.source,imageSourceType:f.imageSourceType,imageId:f.drawingId})}}}return a}getDataColumns(){var m,h,p,S;const r=this._univerInstanceService.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET);if(!r)return[];const e=r.getActiveSheet();if(!e)return[];const t=this._selectionService.getCurrentSelections();if(!t||t.length===0)return[];const n=e.getCellMatrix(),o=n.getDataRange();let s=1/0,a=-1/0;const c=new Set;for(const f of t){s=Math.min(s,f.range.startRow),a=Math.max(a,f.range.endRow);for(let v=f.range.startColumn;v<=f.range.endColumn;v++)c.add(v)}const g=new Set;for(let f=o.startColumn;f<=o.endColumn;f++)if(!c.has(f))for(let v=s;v<=a;v++){const I=n.getValue(v,f);if(I&&(((m=I.v)==null?void 0:m.toString())||((S=(p=(h=I.p)==null?void 0:h.body)==null?void 0:p.dataStream)==null?void 0:S.trim())||"")){g.add(f);break}}const u=[],d=Array.from(g).sort((f,v)=>f-v);for(const f of d)u.push({index:f,label:wt(f)});return u}getDataColumnsForRanges(r,e,t){var p,S,f,v;const n=this._univerInstanceService.getUnit(r,l.UniverInstanceType.UNIVER_SHEET);if(!n)return[];const o=n.getSheetBySheetId(e);if(!o)return[];const s=o.getCellMatrix(),a=s.getDataRange();let c=1/0,g=-1/0;const u=new Set;for(const I of t){c=Math.min(c,I.startRow),g=Math.max(g,I.endRow);for(let D=I.startColumn;D<=I.endColumn;D++)u.add(D)}const d=new Set;for(let I=a.startColumn;I<=a.endColumn;I++)if(!u.has(I))for(let D=c;D<=g;D++){const O=s.getValue(D,I);if(O&&(((p=O.v)==null?void 0:p.toString())||((v=(f=(S=O.p)==null?void 0:S.body)==null?void 0:f.dataStream)==null?void 0:v.trim())||"")){d.add(I);break}}const m=[],h=Array.from(d).sort((I,D)=>I-D);for(const I of h)m.push({index:I,label:wt(I)});return m}getSelectionRangeNotation(){const r=this._selectionService.getCurrentSelections();return!r||r.length===0?"":r.map(e=>nn(e.range)).join(", ")}getSelectionRowRange(){const r=this._selectionService.getCurrentSelections();if(!r||r.length===0)return null;let e=1/0,t=-1/0;for(const n of r)e=Math.min(e,n.range.startRow),t=Math.max(t,n.range.endRow);return{startRow:e,endRow:t}}getSelectionColumnIndices(){const r=this._selectionService.getCurrentSelections();if(!r||r.length===0)return new Set;const e=new Set;for(const t of r)for(let n=t.range.startColumn;n<=t.range.endColumn;n++)e.add(n);return e}generateFileName(r,e){var s,a,c,g;const t=this._univerInstanceService.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET),n=vt(r.source,r.imageSourceType),o=[];for(const u of e.fileNameParts)if(u==="cellAddress")o.push(r.cellAddress);else if(u==="columnValue"&&e.columnIndex!==void 0){const d=t==null?void 0:t.getActiveSheet();if(d){const h=d.getCellMatrix().getValue(r.row,e.columnIndex);if(h){const p=((s=h.v)==null?void 0:s.toString())||((g=(c=(a=h.p)==null?void 0:a.body)==null?void 0:c.dataStream)==null?void 0:g.trim())||"";if(p){const S=p.replace(/[<>:"/\\|?*]/g,"_").trim();S&&o.push(S)}}}}return o.length===0?`${r.cellAddress}.${n}`:`${o.join("_")}.${n}`}generateFileNameWithContext(r,e,t,n){var c,g,u,d;const o=this._univerInstanceService.getUnit(t,l.UniverInstanceType.UNIVER_SHEET),s=vt(r.source,r.imageSourceType),a=[];for(const m of e.fileNameParts)if(m==="cellAddress")a.push(r.cellAddress);else if(m==="columnValue"&&e.columnIndex!==void 0){const h=o==null?void 0:o.getSheetBySheetId(n);if(h){const S=h.getCellMatrix().getValue(r.row,e.columnIndex);if(S){const f=((c=S.v)==null?void 0:c.toString())||((d=(u=(g=S.p)==null?void 0:g.body)==null?void 0:u.dataStream)==null?void 0:d.trim())||"";if(f){const v=f.replace(/[<>:"/\\|?*]/g,"_").trim();v&&a.push(v)}}}}return a.length===0?`${r.cellAddress}.${s}`:`${a.join("_")}.${s}`}async saveImages(r,e){var o;const t=await window.showDirectoryPicker({mode:"readwrite"}),n=new Map;for(const s of r){let a=this.generateFileName(s,e);const c=a.replace(/\.\w+$/,""),g=((o=a.match(/\.\w+$/))==null?void 0:o[0])||".png",u=n.get(c)||0;u>0&&(a=`${c}_${u}${g}`),n.set(c,u+1);try{const d=await this._getImageBlob(s),h=await(await t.getFileHandle(a,{create:!0})).createWritable();await h.write(d),await h.close()}catch(d){throw console.error(`Failed to save image ${a}:`,d),d}}}async saveImagesWithContext(r,e,t,n){var a;const o=await window.showDirectoryPicker({mode:"readwrite"}),s=new Map;for(const c of r){let g=this.generateFileNameWithContext(c,e,t,n);const u=g.replace(/\.\w+$/,""),d=((a=g.match(/\.\w+$/))==null?void 0:a[0])||".png",m=s.get(u)||0;m>0&&(g=`${u}_${m}${d}`),s.set(u,m+1);try{const h=await this._getImageBlob(c),S=await(await o.getFileHandle(g,{create:!0})).createWritable();await S.write(h),await S.close()}catch(h){throw console.error(`Failed to save image ${g}:`,h),h}}}async downloadSingleImage(r){const e=vt(r.source,r.imageSourceType),t=`${r.cellAddress}.${e}`;try{const n=await this._getImageBlob(r),o=URL.createObjectURL(n),s=document.createElement("a");s.href=o,s.download=t,document.body.appendChild(s),s.click(),document.body.removeChild(s),URL.revokeObjectURL(o)}catch(n){throw console.error(`Failed to download image ${t}:`,n),n}}async _getImageBlob(r){if(r.imageSourceType===l.ImageSourceType.UUID){const e=await this._imageIoService.getImage(r.source);return Pt(e,l.ImageSourceType.URL)}return r.imageSourceType===l.ImageSourceType.URL?this._urlImageService.downloadImage(r.source):Pt(r.source,r.imageSourceType)}},b.BatchSaveImagesService=tn([$e(0,l.IUniverInstanceService),$e(1,l.Inject(y.SheetsSelectionsService)),$e(2,l.IImageIoService),$e(3,l.IURLImageService)],b.BatchSaveImagesService);const Ie="sheet.dialog.batch-save-images",ye={id:"sheet.command.save-cell-images",type:l.CommandType.COMMAND,handler:async i=>{const r=i.get(j.IDialogService),e=i.get(Ye),t=e.getCellImagesInSelection();if(t.length===1)try{return await e.downloadSingleImage(t[0]),!0}catch(a){return console.error("Failed to download image:",a),!1}const n=i.get(l.LocaleService),o=e.getSelectionRangeNotation(),s=`${n.t("sheetImage.save.title")} (${o})`;return r.open({id:Ie,draggable:!0,width:360,title:{title:s},children:{label:Ie},destroyOnClose:!0,preservePositionOnDestroy:!0,onClose:()=>r.close(Ie)}),!0}},Nt="COMPONENT_SHEET_DRAWING_PANEL",_t={id:"sidebar.operation.sheet-image",type:l.CommandType.COMMAND,handler:async(i,r)=>{const e=i.get(j.ISidebarService),t=i.get(l.LocaleService),n=i.get(l.IUniverInstanceService),o=i.get(l.ICommandService);return y.getSheetCommandTarget(n)?(r.value==="open"?e.open({header:{title:t.t("sheetImage.panel.title")},children:{label:Nt},onClose:()=>{o.syncExecuteCommand(B.SetDrawingSelectedOperation.id,[])},width:360}):e.close(),!0):!1}},It={id:"sheet.operation.edit-sheet-image",type:l.CommandType.OPERATION,handler:(i,r)=>{const e=i.get(l.ICommandService);return r==null?!1:(e.syncExecuteCommand(B.SetDrawingSelectedOperation.id,[r]),e.executeCommand(_t.id,{value:"open"}),!0)}},rn="sheets-drawing-ui.config",kt={};var on=Object.getOwnPropertyDescriptor,sn=(i,r,e,t)=>{for(var n=t>1?void 0:t?on(r,e):r,o=i.length-1,s;o>=0;o--)(s=i[o])&&(n=s(n)||n);return n},ae=(i,r)=>(e,t)=>r(e,t,i);let Ge=class extends l.RxDisposable{constructor(r,e,t,n,o,s,a,c,g,u){super();oe(this,"_initImagePopupMenu",new Set);this._injector=r,this._localeService=e,this._drawingManagerService=t,this._canvasPopManagerService=n,this._renderManagerService=o,this._univerInstanceService=s,this._messageService=a,this._contextService=c,this._ioService=g,this._commandService=u,this._init()}_init(){this._univerInstanceService.getCurrentTypeOfUnit$(l.UniverInstanceType.UNIVER_SHEET).subscribe(r=>this._create(r)),this._univerInstanceService.getTypeOfUnitDisposed$(l.UniverInstanceType.UNIVER_SHEET).subscribe(r=>this._dispose(r)),this._univerInstanceService.getAllUnitsForType(l.UniverInstanceType.UNIVER_SHEET).forEach(r=>this._create(r)),this._setupLoadingStatus()}_setupLoadingStatus(){const r="image-upload-loading";let e;this.disposeWithMe(this._ioService.change$.subscribe(t=>{t>0&&!e?e=this._messageService.show({id:r,type:H.MessageType.Loading,content:`${this._localeService.t("uploadLoading.loading")}: ${t}`,duration:0}):t===0&&(e==null||e.dispose(),e=void 0)}))}_dispose(r){super.dispose();const e=r.getUnitId();this._renderManagerService.removeRender(e),this._initImagePopupMenu.delete(e)}_create(r){if(!r)return;const e=r.getUnitId();this._renderManagerService.has(e)&&!this._initImagePopupMenu.has(e)&&(this._popupMenuListener(e),this._initImagePopupMenu.add(e))}_hasCropObject(r){const e=r.getAllObjectsByOrder();for(const t of e)if(t instanceof he.ImageCropperObject)return!0;return!1}_popupMenuListener(r){var o;const e=(o=this._renderManagerService.getRenderById(r))==null?void 0:o.scene;if(!e)return;const t=e.getTransformerByCreate();if(!t)return;let n;this.disposeWithMe(t.createControl$.subscribe(()=>{if(this._contextService.setContextValue(l.FOCUSING_COMMON_DRAWINGS,!0),this._hasCropObject(e))return;const s=t.getSelectedObjectMap();if(s.size>1){n==null||n.dispose();return}const a=s.values().next().value;if(!a)return;const c=a.oKey,g=this._drawingManagerService.getDrawingOKey(c);if(!g)return;const{unitId:u,subUnitId:d,drawingId:m,drawingType:h}=g,p=g.data;if(p&&p.disablePopup)return;n==null||n.dispose();const S=this._canvasPopManagerService.getFeatureMenu(u,d,m,h);n=this.disposeWithMe(this._canvasPopManagerService.attachPopupToObject(a,{componentKey:he.COMPONENT_IMAGE_POPUP_MENU,direction:"horizontal",offset:[2,0],extraProps:{menuItems:S||this._getImageMenuItems(u,d,m,h)}}))})),this.disposeWithMe(t.clearControl$.subscribe(()=>{n==null||n.dispose(),this._contextService.setContextValue(l.FOCUSING_COMMON_DRAWINGS,!1),this._commandService.syncExecuteCommand(B.SetDrawingSelectedOperation.id,[])})),this.disposeWithMe(this._contextService.contextChanged$.subscribe(s=>{s[l.FOCUSING_COMMON_DRAWINGS]===!1&&(n==null||n.dispose())})),this.disposeWithMe(t.changing$.subscribe(()=>{n==null||n.dispose()}))}_getImageMenuItems(r,e,t,n){return[{label:"image-popup.edit",index:0,commandId:It.id,commandParams:{unitId:r,subUnitId:e,drawingId:t},disable:n===l.DrawingTypeEnum.DRAWING_DOM},{label:"image-popup.delete",index:1,commandId:we.id,commandParams:{unitId:r,drawings:[{unitId:r,subUnitId:e,drawingId:t}]},disable:!1},{label:"image-popup.crop",index:2,commandId:he.OpenImageCropOperation.id,commandParams:{unitId:r,subUnitId:e,drawingId:t},disable:n===l.DrawingTypeEnum.DRAWING_DOM},{label:"image-popup.reset",index:3,commandId:he.ImageResetSizeOperation.id,commandParams:[{unitId:r,subUnitId:e,drawingId:t}],disable:n===l.DrawingTypeEnum.DRAWING_DOM}]}};Ge=sn([ae(0,l.Inject(l.Injector)),ae(1,l.Inject(l.LocaleService)),ae(2,B.IDrawingManagerService),ae(3,l.Inject(U.SheetCanvasPopManagerService)),ae(4,P.IRenderManagerService),ae(5,l.IUniverInstanceService),ae(6,j.IMessageService),ae(7,l.IContextService),ae(8,l.IImageIoService),ae(9,l.ICommandService)],Ge);var an=Object.getOwnPropertyDescriptor,cn=(i,r,e,t)=>{for(var n=t>1?void 0:t?an(r,e):r,o=i.length-1,s;o>=0;o--)(s=i[o])&&(n=s(n)||n);return n},He=(i,r)=>(e,t)=>r(e,t,i);let yt=class extends l.Disposable{constructor(r,e,t,n,o){super();oe(this,"_isSetCursor",!1);this._context=r,this._hoverManagerService=e,this._selectionsService=t,this._drawingRenderService=n,this._sheetSkeletonManagerService=o,this._initHover(),this._initImageClick()}_initHover(){this.disposeWithMe(this._hoverManagerService.currentRichTextNoDistinct$.pipe(W.throttleTime(33)).subscribe(r=>{var t,n;let e=[];r!==null&&(e=this._selectionsService.getWorkbookSelections(this._context.unitId).getCurrentSelections()),e.length>0&&(r==null?void 0:r.unitId)===this._context.unitId&&(r!=null&&r.drawing)&&e.length===1&&((t=e[0].primary)==null?void 0:t.actualRow)===r.row&&((n=e[0].primary)==null?void 0:n.actualColumn)===r.col?(this._isSetCursor=!0,this._context.scene.setCursor(P.CURSOR_TYPE.ZOOM_IN)):this._isSetCursor&&(this._isSetCursor=!1,this._context.scene.resetCursor())}))}_initImageClick(){this.disposeWithMe(this._hoverManagerService.currentClickedCell$.subscribe(r=>{var e;if(r!=null&&r.drawing&&this._isSetCursor){const t=r.drawing.drawing.drawingOrigin,n=(e=this._sheetSkeletonManagerService.getCurrentSkeleton())==null?void 0:e.imageCacheMap.getImage(t.imageSourceType,t.source);if(!n)return;this._drawingRenderService.previewImage("preview-cell-image",n.src,n.width,n.height),this._context.scene.resetCursor(),this._isSetCursor=!1}}))}};yt=cn([He(1,l.Inject(U.HoverManagerService)),He(2,l.Inject(y.SheetsSelectionsService)),He(3,l.Inject(he.DrawingRenderService)),He(4,l.Inject(U.SheetSkeletonManagerService))],yt);var dn=Object.getOwnPropertyDescriptor,ln=(i,r,e,t)=>{for(var n=t>1?void 0:t?dn(r,e):r,o=i.length-1,s;o>=0;o--)(s=i[o])&&(n=s(n)||n);return n},Ve=(i,r)=>(e,t)=>r(e,t,i);let Ct=class extends l.Disposable{constructor(i,r,e,t,n){super(),this._context=i,this._sheetDrawingService=r,this._drawingManagerService=e,this._sheetSelectionRenderService=t,this._sheetSkeletonManagerService=n,this._init()}_init(){this._drawingInitializeListener()}_drawingInitializeListener(){this._sheetDrawingService.initializeNotification(this._context.unitId);const i=this._sheetDrawingService.getDrawingDataForUnit(this._context.unitId);for(const r in i){const e=i[r];for(const t in e.data){const n=e.data[t];n.sheetTransform&&(n.transform=ee(n.sheetTransform,this._sheetSelectionRenderService,this._sheetSkeletonManagerService))}}this._drawingManagerService.registerDrawingData(this._context.unitId,this._sheetDrawingService.getDrawingDataForUnit(this._context.unitId)),this._drawingManagerService.initializeNotification(this._context.unitId)}};Ct=ln([Ve(1,w.ISheetDrawingService),Ve(2,B.IDrawingManagerService),Ve(3,l.Inject(U.ISheetSelectionRenderService)),Ve(4,l.Inject(U.SheetSkeletonManagerService))],Ct);var un=Object.getOwnPropertyDescriptor,gn=(i,r,e,t)=>{for(var n=t>1?void 0:t?un(r,e):r,o=i.length-1,s;o>=0;o--)(s=i[o])&&(n=s(n)||n);return n},Ce=(i,r)=>(e,t)=>r(e,t,i);function Wt(i,r,e){var t,n,o,s;if(((n=(t=e==null?void 0:e.p)==null?void 0:t.body)==null?void 0:n.dataStream.length)===3&&((s=(o=e.p)==null?void 0:o.drawingsOrder)==null?void 0:s.length)===1){const a=e.p.drawings[e.p.drawingsOrder[0]],c=St(i,{unitId:r.unitId,subUnitId:r.subUnitId,row:r.row,col:r.col},a.docTransform.size.width,a.docTransform.size.height,a.docTransform.angle);if(c)return a.transform.width=c.width,a.transform.height=c.height,a.docTransform.size.width=c.width,a.docTransform.size.height=c.height,a.transform.left=0,a.transform.top=0,a.docTransform.positionH.posOffset=0,a.docTransform.positionV.posOffset=0,e.p.documentStyle.pageSize.width=1/0,e.p.documentStyle.pageSize.height=1/0,!0}return!1}let Xe=class extends l.Disposable{constructor(i,r,e,t,n,o){super(),this._commandService=i,this._sheetInterceptorService=r,this._injector=e,this._drawingManagerService=t,this._docDrawingController=n,this._editorBridgeService=o,this._handleInitEditor(),this._initCellContentInterceptor()}_handleInitEditor(){this.disposeWithMe(this._editorBridgeService.visible$.subscribe(i=>{i.visible?i.visible&&(this._drawingManagerService.removeDrawingDataForUnit(l.DOCS_NORMAL_EDITOR_UNIT_ID_KEY),this._docDrawingController.loadDrawingDataForUnit(l.DOCS_NORMAL_EDITOR_UNIT_ID_KEY),this._drawingManagerService.initializeNotification(l.DOCS_NORMAL_EDITOR_UNIT_ID_KEY)):this._drawingManagerService.removeDrawingDataForUnit(l.DOCS_NORMAL_EDITOR_UNIT_ID_KEY)})),this.disposeWithMe(this._commandService.onCommandExecuted(i=>{i.id===Le.ReplaceSnapshotCommand.id&&i.params.unitId===l.DOCS_ZEN_EDITOR_UNIT_ID_KEY&&(this._drawingManagerService.removeDrawingDataForUnit(l.DOCS_ZEN_EDITOR_UNIT_ID_KEY),this._docDrawingController.loadDrawingDataForUnit(l.DOCS_ZEN_EDITOR_UNIT_ID_KEY),this._drawingManagerService.initializeNotification(l.DOCS_ZEN_EDITOR_UNIT_ID_KEY))}))}_initCellContentInterceptor(){this.disposeWithMe(this._sheetInterceptorService.intercept(y.INTERCEPTOR_POINT.CELL_CONTENT,{effect:l.InterceptorEffectEnum.Style,priority:y.InterceptCellContentPriority.CELL_IMAGE,handler:(i,r,e)=>{var t;return i!=null&&i.p&&((t=i.p.drawingsOrder)!=null&&t.length)&&(i===r.rawData&&(i={...r.rawData}),i.interceptorStyle||(i.interceptorStyle={}),i.interceptorStyle.tr={a:0},Wt(this._injector,{unitId:r.unitId,subUnitId:r.subUnitId,row:r.row,col:r.col},i)),e(i)}}))}};Xe=gn([Ce(0,l.ICommandService),Ce(1,l.Inject(y.SheetInterceptorService)),Ce(2,l.Inject(l.Injector)),Ce(3,B.IDrawingManagerService),Ce(4,l.Inject(Ot.DocDrawingController)),Ce(5,l.Inject(U.IEditorBridgeService))],Xe);var hn=Object.getOwnPropertyDescriptor,mn=(i,r,e,t)=>{for(var n=t>1?void 0:t?hn(r,e):r,o=i.length-1,s;o>=0;o--)(s=i[o])&&(n=s(n)||n);return n},Bt=(i,r)=>(e,t)=>r(e,t,i);let Ke=class extends l.Disposable{constructor(i,r){super(),this._autoFillService=i,this._injector=r,this._initAutoFillHooks()}_initAutoFillHooks(){this.disposeWithMe(this._autoFillService.addHook({id:"sheet-cell-image-autofill",onBeforeSubmit:(i,r,e,t)=>{new l.ObjectMatrix(t).forValue((n,o,s)=>{Wt(this._injector,{unitId:i.unitId,subUnitId:i.subUnitId,row:n,col:o},s)})}}))}};Ke=mn([Bt(0,l.Inject(y.IAutoFillService)),Bt(1,l.Inject(l.Injector))],Ke);var pn=Object.getOwnPropertyDescriptor,Sn=(i,r,e,t)=>{for(var n=t>1?void 0:t?pn(r,e):r,o=i.length-1,s;o>=0;o--)(s=i[o])&&(n=s(n)||n);return n},Ue=(i,r)=>(e,t)=>r(e,t,i);const fn=[l.DOCS_NORMAL_EDITOR_UNIT_ID_KEY,l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY,l.DOCS_ZEN_EDITOR_UNIT_ID_KEY];let ze=class extends l.Disposable{constructor(i,r,e,t,n){super(),this._commandService=i,this._univerInstanceService=r,this._dialogService=e,this._renderManagerService=t,this._localeService=n,this._initDocImageCopyPasteHooks()}_setCellImage(i){var n;const r=l.createDocumentModelWithStyle("",{}),e=(n=P.getCurrentTypeOfRenderer(l.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null?void 0:n.with(U.EditingRenderController),t=l.BuildTextUtils.drawing.add({documentDataModel:r,drawings:[i],selection:{collapsed:!0,startOffset:0,endOffset:0}});t&&(r.apply(t),e&&e.submitCellData(r))}_initDocImageCopyPasteHooks(){this.disposeWithMe(this._commandService.beforeCommandExecuted(i=>{var r,e;if(i.id===Le.InnerPasteCommand.id){const t=i.params,{doc:n}=t,o=this._univerInstanceService.getCurrentUnitOfType(l.UniverInstanceType.UNIVER_DOC);if(o==null||!Object.keys((r=n.drawings)!=null?r:{}).length)return;const s=o.getUnitId();if(fn.includes(s)){if(s!==l.DOCS_ZEN_EDITOR_UNIT_ID_KEY){const a=()=>{this._dialogService.close("sheet-cell-image-copy-paste"),this._commandService.syncExecuteCommand(U.SetCellEditVisibleOperation.id,{visible:!1})};((e=o.getBody())==null?void 0:e.dataStream)===`\r
15
- `?(this._commandService.syncExecuteCommand(U.SetCellEditVisibleOperation.id,{visible:!1}),this._setCellImage(Object.values(n.drawings)[0])):this._dialogService.open({id:"sheet-cell-image-copy-paste",title:{label:this._localeService.t("cell-image.pasteTitle")},children:{label:this._localeService.t("cell-image.pasteContent")},width:320,destroyOnClose:!0,onClose:a,showOk:!0,showCancel:!0,onOk:()=>{a(),this._setCellImage(Object.values(n.drawings)[0])},onCancel:a})}throw new Error("Sheet cell image copy paste is not supported in this unit")}}}))}};ze=Sn([Ue(0,l.ICommandService),Ue(1,l.IUniverInstanceService),Ue(2,j.IDialogService),Ue(3,P.IRenderManagerService),Ue(4,l.Inject(l.LocaleService))],ze);var wn=Object.getOwnPropertyDescriptor,vn=(i,r,e,t)=>{for(var n=t>1?void 0:t?wn(r,e):r,o=i.length-1,s;o>=0;o--)(s=i[o])&&(n=s(n)||n);return n},Pe=(i,r)=>(e,t)=>r(e,t,i);const jt="image/png";function _n(i){const r=i.split(","),e=atob(r[1]),t=e.length,n=new Uint8Array(t);for(let o=0;o<t;o++)n[o]=e.charCodeAt(o);return new Blob([n],{type:jt})}function In(i){const r=new ClipboardItem({[jt]:_n(i)});navigator.clipboard.write([r]).catch(e=>{console.error("Could not copy image using clipboard API: ",e)})}function yn(){function i(){const t=document.createElement("input");return t.style.position="absolute",t.style.height="1px",t.style.width="1px",t.style.opacity="0",t}const r=document.activeElement,e=i();return document.body.appendChild(e),e.focus(),()=>{e.blur(),document.body.removeChild(e),r instanceof HTMLElement&&r.focus()}}const Ft=[U.PREDEFINED_HOOK_NAME_PASTE.SPECIAL_PASTE_COL_WIDTH,U.PREDEFINED_HOOK_NAME_PASTE.SPECIAL_PASTE_VALUE,U.PREDEFINED_HOOK_NAME_PASTE.SPECIAL_PASTE_FORMAT,U.PREDEFINED_HOOK_NAME_PASTE.SPECIAL_PASTE_FORMULA];let qe=class extends l.Disposable{constructor(r,e,t,n,o){super();oe(this,"_copyInfo");this._sheetClipboardService=r,this._renderManagerService=e,this._drawingService=t,this._clipboardInterfaceService=n,this._commandService=o,this._initCopyPaste()}get _focusedDrawings(){return this._drawingService.getFocusDrawings()}_initCopyPaste(){this._sheetClipboardService.addClipboardHook({id:"SHEET_IMAGE_UI_PLUGIN",onBeforeCopy:(r,e,t,n)=>{this._copyInfo=null;const o=this._focusedDrawings;if(o.length>0){const[s]=o;if(s.drawingType!==l.DrawingTypeEnum.DRAWING_IMAGE)return;if(n===U.COPY_TYPE.CUT){const c={unitId:r,drawings:[s]};this._commandService.executeCommand(we.id,c)}setTimeout(()=>{const c=yn();s.drawingType===l.DrawingTypeEnum.DRAWING_IMAGE&&s.imageSourceType===B.ImageSourceType.BASE64?In(s.source):this._clipboardInterfaceService.writeText(""),c()},200);const a={unitId:s.unitId,subUnitId:s.subUnitId,drawings:[s]};this._copyInfo=a}else{const s=this._createDrawingsCopyInfoByRange(r,e,t);this._copyInfo=s}},onPasteCells:(r,e,t,n)=>{if(!this._copyInfo)return{redos:[],undos:[]};const{copyType:o=U.COPY_TYPE.COPY,pasteType:s}=n,{range:a}=r||{},{range:c,unitId:g,subUnitId:u}=e;return this._copyInfo.copyRange?this._generateRangeDrawingsPasteMutations({pasteType:s,unitId:g,subUnitId:u,pasteRange:c},{copyRange:a,copyType:o}):this._generateSingleDrawingPasteMutations({pasteTo:e,pasteType:s},U.COPY_TYPE.COPY)},onPastePlainText:(r,e)=>({undos:[],redos:[]}),onPasteUnrecognized:r=>this._copyInfo?this._generateSingleDrawingPasteMutations({pasteTo:r,pasteType:U.PREDEFINED_HOOK_NAME_PASTE.DEFAULT_PASTE},U.COPY_TYPE.COPY):{undos:[],redos:[]},onPasteFiles:(r,e)=>{if(this._copyInfo)return this._generateSingleDrawingPasteMutations({pasteTo:r,pasteType:U.PREDEFINED_HOOK_NAME_PASTE.DEFAULT_PASTE},U.COPY_TYPE.COPY);{const t=e.filter(n=>n.type.includes("image"));if(t.length)return{undos:[],redos:[{id:Ae.id,params:{files:t}}]}}return{undos:[],redos:[]}}})}_createDrawingsCopyInfoByRange(r,e,t){var m;const n=(m=this._renderManagerService.getRenderById(r))==null?void 0:m.with(U.SheetSkeletonManagerService);if(!n)return;const o=n.attachRangeWithCoord(t);if(!o)return;const{startX:s,endX:a,startY:c,endY:g}=o,u=this._drawingService.getDrawingData(r,e),d=this._focusedDrawings.slice();if(Object.keys(u).forEach(h=>{const p=u[h];if(p.drawingType!==l.DrawingTypeEnum.DRAWING_IMAGE)return;const{transform:S}=p;if(p.anchorType!==w.SheetDrawingAnchorType.Both||!S)return;const{left:f=0,top:v=0,width:I=0,height:D=0}=S,{drawingStartX:O,drawingEndX:T,drawingStartY:C,drawingEndY:M}={drawingStartX:f,drawingEndX:f+I,drawingStartY:v,drawingEndY:v+D};s<=O&&T<=a&&c<=C&&M<=g&&d.push(p)}),d.length)return{copyRange:t,drawings:d,unitId:r,subUnitId:e}}_generateSingleDrawingPasteMutations(r,e){const{pasteType:t,pasteTo:n}=r;if(Ft.includes(t))return{redos:[],undos:[]};const{unitId:o,subUnitId:s,range:a}=n,c=this._renderManagerService.getRenderById(o),g=c==null?void 0:c.with(U.SheetSkeletonManagerService),u=c==null?void 0:c.with(U.ISheetSelectionRenderService),d=this._copyInfo;if(!g||!u)return{redos:[],undos:[]};const{drawings:m}=d,h=y.discreteRangeToRange(a);return this._generateMutations(m,{unitId:o,subUnitId:s,isCut:e===U.COPY_TYPE.CUT,getTransform:(p,S)=>{var I,D;const f=g.attachRangeWithCoord({startRow:h.startRow,endRow:h.endRow,startColumn:h.startColumn,endColumn:h.endColumn}),v={...p,left:f==null?void 0:f.startX,top:f==null?void 0:f.startY};return{transform:v,sheetTransform:(I=x(v,u))!=null?I:S,axisAlignSheetTransform:(D=G(v,u))!=null?D:S}}})}_generateMutations(r,e){const{unitId:t,subUnitId:n,getTransform:o,isCut:s}=e,a=[],c=[],{_drawingService:g}=this;return r.forEach(u=>{const{transform:d,sheetTransform:m}=u;if(!d)return;const h=o(d,m),p={...u,unitId:t,subUnitId:n,drawingId:s?u.drawingId:l.generateRandomId(),transform:h.transform,sheetTransform:h.sheetTransform,axisAlignSheetTransform:h.axisAlignSheetTransform};if(s){const{undo:S,redo:f,objects:v}=g.getBatchUpdateOp([p]);a.push({id:w.SetDrawingApplyMutation.id,params:{unitId:t,subUnitId:n,type:w.DrawingApplyType.UPDATE,op:f,objects:v}}),c.push({id:w.SetDrawingApplyMutation.id,params:{unitId:t,subUnitId:n,type:w.DrawingApplyType.UPDATE,op:S,objects:v}})}else{const{undo:S,redo:f,objects:v}=g.getBatchAddOp([p]);a.push({id:w.SetDrawingApplyMutation.id,params:{op:f,unitId:t,subUnitId:n,objects:v,type:w.DrawingApplyType.INSERT}}),c.push({id:w.SetDrawingApplyMutation.id,params:{op:S,unitId:t,subUnitId:n,objects:v,type:w.DrawingApplyType.REMOVE}})}}),{redos:a,undos:c}}_generateRangeDrawingsPasteMutations(r,e){var R;const{unitId:t,subUnitId:n,pasteType:o,pasteRange:s}=r,{copyRange:a,copyType:c}=e;if(Ft.includes(o))return{redos:[],undos:[]};const g=(R=this._renderManagerService.getRenderById(t))==null?void 0:R.with(U.SheetSkeletonManagerService);if(!g||!this._copyInfo)return{redos:[],undos:[]};const{drawings:u}=this._copyInfo;if(!a)return this._generateSingleDrawingPasteMutations({pasteTo:{unitId:t,subUnitId:n,range:y.discreteRangeToRange(s)},pasteType:o},c);const{ranges:[d,m],mapFunc:h}=U.virtualizeDiscreteRanges([a,s]),{row:p,col:S}=h(d.startRow,d.startColumn),{row:f,col:v}=h(m.startRow,m.startColumn),I=g.attachRangeWithCoord({startRow:p,endRow:p,startColumn:S,endColumn:S}),D=g.attachRangeWithCoord({startRow:f,endRow:f,startColumn:v,endColumn:v});if(!I||!D||!this._copyInfo)return{redos:[],undos:[]};const O=D.startX-I.startX,T=D.startY-I.startY,C=f-p,M=v-S;return this._generateMutations(u,{unitId:t,subUnitId:n,getTransform:(k,A)=>{var F,L,Q;const N={...k,left:((F=k==null?void 0:k.left)!=null?F:0)+O,top:((L=k==null?void 0:k.top)!=null?L:0)+T},_=this._renderManagerService.getRenderById(t),E=_==null?void 0:_.with(U.ISheetSelectionRenderService);return E?{transform:N,sheetTransform:{...A,to:{...A.to,row:A.to.row+C,column:A.to.column+M},from:{...A.from,row:A.from.row+C,column:A.from.column+M}},axisAlignSheetTransform:(Q=G(N,E))!=null?Q:A}:{transform:N,sheetTransform:{...A,to:{...A.to,row:A.to.row+C,column:A.to.column+M},from:{...A.from,row:A.from.row+C,column:A.from.column+M}},axisAlignSheetTransform:{...A,to:{...A.to,row:A.to.row+C,column:A.to.column+M},from:{...A.from,row:A.from.row+C,column:A.from.column+M}}}},isCut:c===U.COPY_TYPE.CUT})}};qe=vn([Pe(0,U.ISheetClipboardService),Pe(1,P.IRenderManagerService),Pe(2,B.IDrawingManagerService),Pe(3,j.IClipboardInterfaceService),Pe(4,l.ICommandService)],qe);var Cn=Object.getOwnPropertyDescriptor,Dn=(i,r,e,t)=>{for(var n=t>1?void 0:t?Cn(r,e):r,o=i.length-1,s;o>=0;o--)(s=i[o])&&(n=s(n)||n);return n},Ne=(i,r)=>(e,t)=>r(e,t,i);let Ze=class extends l.Disposable{constructor(i,r,e,t,n){super(),this._drawingManagerService=i,this._renderManagerService=r,this._permissionService=e,this._univerInstanceService=t,this._userManagerService=n,this._initDrawingVisible(),this._initDrawingEditable(),this._initViewPermissionChange(),this._initEditPermissionChange()}_initDrawingVisible(){const i=this._univerInstanceService.getCurrentTypeOfUnit$(l.UniverInstanceType.UNIVER_SHEET),r=this._userManagerService.currentUser$,e=W.combineLatest([i,r]);this.disposeWithMe(e.pipe(W.switchMap(([t,n])=>t?t.activeSheet$.pipe(W.tap(o=>{if(!o){this._drawingManagerService.setDrawingVisible(!1);return}const s=t.getUnitId(),a=o.getSheetId();this._permissionService.composePermission([new y.WorkbookViewPermission(s).id,new y.WorksheetViewPermission(s,a).id]).every(g=>g.value)?this._drawingManagerService.setDrawingVisible(!0):this._handleDrawingVisibilityFalse(t,o)})):(this._drawingManagerService.setDrawingVisible(!1),W.EMPTY))).subscribe())}_handleDrawingVisibilityFalse(i,r){this._drawingManagerService.setDrawingVisible(!1);const e=i.getUnitId(),t=r.getSheetId(),n=this._drawingManagerService.getDrawingData(e,t),o=Object.values(n),s=this._renderManagerService.getRenderById(e),a=s==null?void 0:s.scene;if(!a)return;a.getAllObjectsByOrder().forEach(g=>{g.classType===P.RENDER_CLASS_TYPE.IMAGE&&o.some(u=>g.oKey.includes(u.drawingId))&&a.removeObject(g)})}_initDrawingEditable(){const i=this._univerInstanceService.getCurrentTypeOfUnit$(l.UniverInstanceType.UNIVER_SHEET),r=this._userManagerService.currentUser$,e=W.combineLatest([i,r]);this.disposeWithMe(e.pipe(W.switchMap(([t,n])=>t?t.activeSheet$.pipe(W.tap(o=>{if(!o){this._drawingManagerService.setDrawingEditable(!1);return}const s=t.getUnitId(),a=o.getSheetId();this._permissionService.composePermission([new y.WorkbookEditablePermission(s).id,new y.WorksheetEditPermission(s,a).id]).every(g=>g.value)?this._drawingManagerService.setDrawingEditable(!0):this._handleDrawingEditableFalse(t,o)})):(this._drawingManagerService.setDrawingEditable(!1),W.EMPTY))).subscribe())}_handleDrawingEditableFalse(i,r){this._drawingManagerService.setDrawingEditable(!1);const e=i.getUnitId(),t=r.getSheetId(),n=this._drawingManagerService.getDrawingData(e,t),o=Object.values(n),s=this._renderManagerService.getRenderById(e),a=s==null?void 0:s.scene;if(!a)return;a.getAllObjectsByOrder().forEach(g=>{g.classType===P.RENDER_CLASS_TYPE.IMAGE&&o.some(u=>g.oKey.includes(u.drawingId))&&a.detachTransformerFrom(g)})}_initViewPermissionChange(){const i=this._univerInstanceService.getCurrentTypeOfUnit$(l.UniverInstanceType.UNIVER_SHEET),r=this._userManagerService.currentUser$;this.disposeWithMe(W.combineLatest([i,r]).pipe(W.switchMap(([e,t])=>e?e.activeSheet$.pipe(W.switchMap(n=>{if(!n)return W.EMPTY;const o=e.getUnitId(),s=n.getSheetId(),a=this._renderManagerService.getRenderById(o),c=a==null?void 0:a.scene;if(!c)return W.EMPTY;const g=c.getTransformerByCreate();return this._permissionService.composePermission$([new y.WorkbookViewPermission(o).id,new y.WorksheetViewPermission(o,s).id]).pipe(W.map(d=>d.every(m=>m.value)),W.distinctUntilChanged()).pipe(W.map(d=>({permission:d,scene:c,transformer:g,unitId:o,subUnitId:s})))})):W.EMPTY)).subscribe({next:({permission:e,scene:t,transformer:n,unitId:o,subUnitId:s})=>{this._drawingManagerService.setDrawingVisible(e);const a=t.getAllObjectsByOrder(),c=this._drawingManagerService.getDrawingData(o,s),g=Object.values(c);e?this._drawingManagerService.addNotification(g):(a.forEach(u=>{u.classType===P.RENDER_CLASS_TYPE.IMAGE&&g.some(d=>u.oKey.includes(d.drawingId))&&t.removeObject(u)}),n.clearSelectedObjects())},complete:()=>{this._drawingManagerService.setDrawingVisible(!0);const e=this._univerInstanceService.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET),t=e==null?void 0:e.getActiveSheet(),n=e==null?void 0:e.getUnitId(),o=t==null?void 0:t.getSheetId();if(!n||!o)return;const s=this._drawingManagerService.getDrawingData(n,o),a=Object.values(s);this._drawingManagerService.addNotification(a)}}))}_initEditPermissionChange(){const i=this._univerInstanceService.getCurrentTypeOfUnit$(l.UniverInstanceType.UNIVER_SHEET),r=this._userManagerService.currentUser$;this.disposeWithMe(W.combineLatest([i,r]).pipe(W.switchMap(([e,t])=>e?e.activeSheet$.pipe(W.switchMap(n=>{if(!n)return W.EMPTY;const o=e.getUnitId(),s=n.getSheetId(),a=this._renderManagerService.getRenderById(o),c=a==null?void 0:a.scene;if(!c)return W.EMPTY;const g=c.getTransformerByCreate();return this._permissionService.composePermission$([new y.WorkbookEditablePermission(o).id,new y.WorksheetEditPermission(o,s).id]).pipe(W.map(d=>d.every(m=>m.value)),W.distinctUntilChanged()).pipe(W.map(d=>({permission:d,scene:c,transformer:g,unitId:o,subUnitId:s})))})):W.EMPTY)).subscribe({next:({permission:e,scene:t,transformer:n,unitId:o,subUnitId:s})=>{this._drawingManagerService.setDrawingEditable(e);const a=t.getAllObjectsByOrder(),c=this._drawingManagerService.getDrawingData(o,s),g=Object.values(c);e?(a.forEach(u=>{u.classType===P.RENDER_CLASS_TYPE.IMAGE&&g.some(d=>u.oKey.includes(d.drawingId))&&t.attachTransformerTo(u)}),this._drawingManagerService.addNotification(g)):(a.forEach(u=>{u.classType===P.RENDER_CLASS_TYPE.IMAGE&&g.some(d=>u.oKey.includes(d.drawingId))&&t.detachTransformerFrom(u)}),n.clearSelectedObjects())},complete:()=>{const e=this._univerInstanceService.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET);if(!e)return;const t=e.getUnitId(),n=e.getActiveSheet();if(!n)return;const o=n.getSheetId(),s=this._renderManagerService.getRenderById(t),a=s==null?void 0:s.scene;if(!a)return;const c=this._drawingManagerService.getDrawingData(t,o),g=Object.values(c);this._drawingManagerService.setDrawingEditable(!0),a.getAllObjectsByOrder().forEach(d=>{d.classType===P.RENDER_CLASS_TYPE.IMAGE&&g.some(m=>d.oKey.includes(m.drawingId))&&a.detachTransformerFrom(d)})}}))}};Ze=Dn([Ne(0,B.IDrawingManagerService),Ne(1,P.IRenderManagerService),Ne(2,l.IPermissionService),Ne(3,l.IUniverInstanceService),Ne(4,l.Inject(l.UserManagerService))],Ze);var Tn=Object.getOwnPropertyDescriptor,Mn=(i,r,e,t)=>{for(var n=t>1?void 0:t?Tn(r,e):r,o=i.length-1,s;o>=0;o--)(s=i[o])&&(n=s(n)||n);return n},Se=(i,r)=>(e,t)=>r(e,t,i);const Lt="univer-sheet-float-dom-";function $t(i,r,e,t,n,o=!1){const{scaleX:s,scaleY:a}=r.getAncestorScale(),c=r.getViewport(P.SHEET_VIEWPORT_KEY.VIEW_MAIN),g=t.getFreeze(),{startColumn:u,startRow:d,xSplit:m,ySplit:h}=g,p={left:!0,top:!0};if(!c)return{...i,absolute:p};const{left:S,right:f,top:v,bottom:I}=i;let{top:D,left:O,viewportScrollX:T,viewportScrollY:C}=c;const{boundsOfViewArea:M,scrollDirectionResponse:R}=n||{},{rowHeaderWidth:k,columnHeaderHeight:A}=e,N={top:o?0:A,left:o?0:k};M&&(l.Tools.isDefine(N.top)&&(N.top=M.top),l.Tools.isDefine(N.left)&&(N.left=M.left)),R==="HORIZONTAL"&&(C=0),R==="VERTICAL"&&(T=0);let _=0,E=0;const F=e.rowStartY(d-h)+A,L=e.colStartX(u-m)+k,Q=e.rowStartY(d)+A,re=e.colStartX(u)+k;if(m===0)p.left=!1,_=(S-T)*s,E=(f-T)*s;else{const q=S-(L-k),te=f-(L-k);f<re?(_=q*s,E=te*s):S<=re&&f>=re?(_=q*s,E=Math.max(O,(f-T)*s)):S>re&&(p.left=!1,_=Math.max((S-T)*s,O),E=Math.max((f-T)*s,O))}let z=0,J=0;if(h===0)p.top=!1,z=(v-C)*a,J=(I-C)*a;else{const q=v-(F-A),te=I-(F-A);I<Q?(z=q*a,J=te*a):v<=Q&&I>=Q?(z=q*a,J=Math.max(D,(I-C)*a)):v>Q&&(p.top=!1,z=Math.max((v-C)*a,D),J=Math.max((I-C)*a,D))}return _=Math.max(_,N.left),z=Math.max(z,N.top),E=Math.max(E,N.left),J=Math.max(J,N.top),{left:_,right:E,top:z,bottom:J,absolute:p}}const ce=(i,r,e,t,n)=>{const{left:o,top:s,width:a,height:c,angle:g}=i,u={left:o,right:o+a,top:s,bottom:s+c},d=$t(u,r,e,t,n),{scaleX:m,scaleY:h}=r.getAncestorScale();return{startX:d.left,endX:d.right,startY:d.top,endY:d.bottom,rotate:g,width:a*m,height:c*h,absolute:d.absolute}};b.SheetCanvasFloatDomManagerService=class extends l.Disposable{constructor(e,t,n,o,s,a,c){super();oe(this,"_domLayerInfoMap",new Map);oe(this,"_transformChange$",new W.Subject);oe(this,"transformChange$",this._transformChange$.asObservable());oe(this,"_add$",new W.Subject);oe(this,"add$",this._add$.asObservable());oe(this,"_remove$",new W.Subject);oe(this,"remove$",this._remove$.asObservable());this._renderManagerService=e,this._univerInstanceService=t,this._commandService=n,this._drawingManagerService=o,this._canvasFloatDomService=s,this._sheetDrawingService=a,this._lifecycleService=c,this._drawingAddListener(),this._featureUpdateListener(),this._deleteListener(),this._bindScrollEvent()}_bindScrollEvent(){this._lifecycleService.lifecycle$.pipe(W.filter(e=>e===l.LifecycleStages.Rendered),W.take(1)).subscribe(()=>{this._scrollUpdateListener()})}getFloatDomInfo(e){return this._domLayerInfoMap.get(e)}getFloatDomsBySubUnitId(e,t){return Array.from(this._domLayerInfoMap.values()).filter(n=>n.subUnitId===t&&n.unitId===e)}_getSceneAndTransformerByDrawingSearch(e){if(e==null)return;const t=this._renderManagerService.getRenderById(e),n=t==null?void 0:t.scene;if(t==null||n==null)return null;const o=n.getTransformerByCreate(),s=t.engine.getCanvasElement();return{scene:n,transformer:o,renderUnit:t,canvas:s}}_drawingAddListener(){this.disposeWithMe(this._drawingManagerService.add$.subscribe(e=>{e.forEach(t=>{var te;const{unitId:n,subUnitId:o,drawingId:s}=t,a=y.getSheetCommandTarget(this._univerInstanceService,{unitId:n,subUnitId:o}),c=this._drawingManagerService.getDrawingByParam(t),g=this._univerInstanceService.getUnit(n,l.UniverInstanceType.UNIVER_SHEET);if(!g)return;const u=g.getActiveSheet().getSheetId();if(!c||!a)return;const d=(te=this._renderManagerService.getRenderById(n))==null?void 0:te.with(U.SheetSkeletonManagerService).getSkeletonParam(o);if(!d)return;const{transform:m,drawingType:h,data:p}=c;if(h!==l.DrawingTypeEnum.DRAWING_DOM&&h!==l.DrawingTypeEnum.DRAWING_CHART)return;const S=this._getSceneAndTransformerByDrawingSearch(n);if(S==null)return;const{scene:f,canvas:v}=S;if(m==null)return!0;if(u!==o)return;const{left:I,top:D,width:O,height:T,angle:C,flipX:M,flipY:R,skewX:k,skewY:A}=m,N=B.getDrawingShapeKeyByDrawingSearch({unitId:n,subUnitId:o,drawingId:s}),_=f.getObject(N);if(_!=null){_.transformByState({left:I,top:D,width:O,height:T,angle:C,flipX:M,flipY:R,skewX:k,skewY:A});return}const E={left:I,top:D,width:O,height:T,zIndex:this._drawingManagerService.getDrawingOrder(n,o).length-1},F=h===l.DrawingTypeEnum.DRAWING_CHART;if(E.rotateEnabled=!1,F){const X=p?p.backgroundColor:"white";E.fill=X,p&&p.border&&(E.stroke=p.border),E.paintFirst="stroke",E.strokeWidth=1,E.borderEnabled=!1,E.radius=8}const L=new P.Rect(N,E);F&&L.setObjectType(P.ObjectType.CHART),f.addObject(L,P.DRAWING_OBJECT_LAYER_INDEX),c.allowTransform!==!1&&f.attachTransformerTo(L);const Q=new l.DisposableCollection,re=ce(L,S.renderUnit.scene,d.skeleton,a.worksheet),z=new W.BehaviorSubject(re),J=`${Lt}${l.generateRandomId(6)}`,se={dispose:Q,rect:L,position$:z,unitId:n,subUnitId:o,id:s,domId:J};this._canvasFloatDomService.addFloatDom({position$:z,id:s,domId:J,componentKey:c.componentKey,onPointerDown:X=>{v.dispatchEvent(new PointerEvent(X.type,X))},onPointerMove:X=>{v.dispatchEvent(new PointerEvent(X.type,X))},onPointerUp:X=>{v.dispatchEvent(new PointerEvent(X.type,X))},onWheel:X=>{v.dispatchEvent(new WheelEvent(X.type,X))},data:p,unitId:n});const q=L.onTransformChange$.subscribeEvent(()=>{const X=ce(L,S.renderUnit.scene,d.skeleton,a.worksheet);z.next(X)});Q.add(()=>{this._canvasFloatDomService.removeFloatDom(s)}),q&&Q.add(q),this._domLayerInfoMap.set(s,se)})})),this.disposeWithMe(this._drawingManagerService.remove$.subscribe(e=>{e.forEach(t=>{var m;const{unitId:n,subUnitId:o,drawingId:s}=t,a=B.getDrawingShapeKeyByDrawingSearch({unitId:n,subUnitId:o,drawingId:s}),c=this._getSceneAndTransformerByDrawingSearch(n);if(c==null)return;const{transformer:g,scene:u}=c,d=u.getObject(a);d!=null&&d.oKey&&(g.clearControlByIds([d==null?void 0:d.oKey]),(m=u.getTransformer())==null||m.clearSelectedObjects())})}))}_scrollUpdateListener(){const e=(t,n)=>{var g;const o=this._getSceneAndTransformerByDrawingSearch(t),s=Array.from(this._domLayerInfoMap.keys()).map(u=>({id:u,...this._domLayerInfoMap.get(u)})).filter(u=>u.subUnitId===n&&u.unitId===t).map(u=>u.id),a=y.getSheetCommandTarget(this._univerInstanceService,{unitId:t,subUnitId:n}),c=(g=this._renderManagerService.getRenderById(t))==null?void 0:g.with(U.SheetSkeletonManagerService).getSkeletonParam(n);!o||!a||!c||s.forEach(u=>{const d=this._domLayerInfoMap.get(u);if(d){const m=ce(d.rect,o.renderUnit.scene,c.skeleton,a.worksheet,d);d.position$.next(m)}})};this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(l.UniverInstanceType.UNIVER_SHEET).pipe(W.switchMap(t=>t?t.activeSheet$:W.of(null)),W.map(t=>{if(!t)return null;const n=t.getUnitId(),o=this._renderManagerService.getRenderById(n);return o?{render:o,unitId:n,subUnitId:t.getSheetId()}:null}),W.switchMap(t=>t?l.fromEventSubject(t.render.scene.getViewport(P.SHEET_VIEWPORT_KEY.VIEW_MAIN).onScrollAfter$).pipe(W.map(()=>({unitId:t.unitId,subUnitId:t.subUnitId}))):W.of(null))).subscribe(t=>{if(!t)return;const{unitId:n,subUnitId:o}=t;e(n,o)})),this.disposeWithMe(this._commandService.onCommandExecuted(t=>{if(t.id===U.SetZoomRatioOperation.id){const n=t.params,{unitId:o}=n;Array.from(this._domLayerInfoMap.values()).filter(a=>a.unitId===o).map(a=>a.subUnitId).forEach(a=>{e(o,a)})}else if(t.id===y.SetFrozenMutation.id){const{unitId:n,subUnitId:o}=t.params;e(n,o)}else if(t.id===y.SetSelectionsOperation.id){const{unitId:n,subUnitId:o}=t.params;e(n,o)}}))}updateFloatDomProps(e,t,n,o){const s=this._domLayerInfoMap.get(n),a=this._getSceneAndTransformerByDrawingSearch(e);if(s&&a){const{scene:c}=a,g=B.getDrawingShapeKeyByDrawingSearch({unitId:e,subUnitId:t,drawingId:n}),u=c.getObject(g);u&&u instanceof P.Rect&&u.setProps(o)}}_getPosition(e,t){var h;const{startX:n,endX:o,startY:s,endY:a}=e,c=(h=this._renderManagerService.getRenderById(t))==null?void 0:h.with(U.ISheetSelectionRenderService);if(c==null)return;const g=c.getCellWithCoordByOffset(n,s);if(g==null)return;const u={column:g.actualColumn,columnOffset:n-g.startX,row:g.actualRow,rowOffset:s-g.startY},d=c.getCellWithCoordByOffset(o,a);if(d==null)return;const m={column:d.actualColumn,columnOffset:o-d.startX,row:d.actualRow,rowOffset:a-d.startY};return{from:u,to:m}}_featureUpdateListener(){this.disposeWithMe(this._drawingManagerService.update$.subscribe(e=>{e.forEach(t=>{const n=this._drawingManagerService.getDrawingByParam(t);if(!n||n.drawingType!==l.DrawingTypeEnum.DRAWING_DOM&&n.drawingType!==l.DrawingTypeEnum.DRAWING_CHART)return;const o={...n.transform};this._transformChange$.next({id:t.drawingId,value:o}),this._canvasFloatDomService.updateFloatDom(t.drawingId,{...n});const s=this._getSceneAndTransformerByDrawingSearch(t.unitId);if(s&&n.drawingType!==l.DrawingTypeEnum.DRAWING_CHART){const{scene:a}=s,c=this._domLayerInfoMap.get(t.drawingId);c!=null&&c.rect&&(n.allowTransform===!1?a.detachTransformerFrom(c.rect):a.attachTransformerTo(c.rect))}})}))}_deleteListener(){this.disposeWithMe(this._drawingManagerService.remove$.subscribe(e=>{e.forEach(t=>{this._removeDom(t.drawingId)})}))}addFloatDomToPosition(e,t){const n=y.getSheetCommandTarget(this._univerInstanceService,{unitId:e.unitId,subUnitId:e.subUnitId});if(!n)throw new Error("cannot find current target!");const{unitId:o,subUnitId:s}=n,{initPosition:a,componentKey:c,data:g,allowTransform:u=!0}=e,d=t!=null?t:l.generateRandomId(),m=this._getPosition(a,o);if(m==null)return;const h={unitId:o,subUnitId:s,drawingId:d,drawingType:e.type||l.DrawingTypeEnum.DRAWING_DOM,componentKey:c,sheetTransform:m,transform:{left:a.startX,top:a.startY,width:a.endX-a.startX,height:a.endY-a.startY},axisAlignSheetTransform:m,data:g,allowTransform:u};return this._commandService.executeCommand(Oe.id,{unitId:o,drawings:[h]}),this._add$.next({unitId:o,subUnitId:s,id:d}),{id:d,dispose:()=>{this._removeDom(d,!0)}}}_removeDom(e,t=!1){const n=this._domLayerInfoMap.get(e);if(!n)return;const{unitId:o,subUnitId:s}=n;this._domLayerInfoMap.delete(e),n.dispose.dispose();const a=this._getSceneAndTransformerByDrawingSearch(o);if(a&&a.scene.removeObject(n.rect),t){const c=this._drawingManagerService.getDrawingByParam({unitId:o,subUnitId:s,drawingId:e});if(!c)return;const g=this._sheetDrawingService.getBatchRemoveOp([c]),{redo:u,objects:d}=g;this._commandService.syncExecuteCommand(w.SetDrawingApplyMutation.id,{unitId:o,subUnitId:s,op:u,objects:d,type:w.DrawingApplyType.REMOVE})}}addFloatDomToRange(e,t,n,o){var M,R,k;const s=y.getSheetCommandTarget(this._univerInstanceService,{unitId:t.unitId,subUnitId:t.subUnitId});if(!s)throw new Error("cannot find current target!");const{unitId:a,subUnitId:c}=s,g=this._getSceneAndTransformerByDrawingSearch(a);if(!g)return;const u=this._renderManagerService.getRenderById(a);if(!u)return;const d=(M=this._renderManagerService.getRenderById(a))==null?void 0:M.with(U.SheetSkeletonManagerService).getWorksheetSkeleton(c);if(!d)return;const{componentKey:m,data:h,allowTransform:p=!0}=t,S=o!=null?o:l.generateRandomId(),{position:f,position$:v}=this._createRangePositionObserver(e,u,d.skeleton);if(this._getPosition(f,a)==null)return;const D=g.scene,{scaleX:O}=D.getAncestorScale(),T=Je(f,n,O),C={unitId:a,subUnitId:c,drawingId:S,drawingType:t.type||l.DrawingTypeEnum.DRAWING_DOM,componentKey:m,transform:{left:T.startX,top:T.startY,width:T.width,height:T.height},data:h,allowTransform:p};{const{unitId:A,subUnitId:N,drawingId:_}=C,E=y.getSheetCommandTarget(this._univerInstanceService,{unitId:A,subUnitId:N}),F=C,L=this._univerInstanceService.getUnit(A,l.UniverInstanceType.UNIVER_SHEET);if(!L)return;const Q=L.getActiveSheet().getSheetId();if(!F||!E)return;const re=(R=this._renderManagerService.getRenderById(A))==null?void 0:R.with(U.SheetSkeletonManagerService);if(!re)return;const z=re.getWorksheetSkeleton(N);if(!z)return;const{transform:J,drawingType:se,data:q}=F;if(se!==l.DrawingTypeEnum.DRAWING_DOM&&se!==l.DrawingTypeEnum.DRAWING_CHART)return;const te=this._getSceneAndTransformerByDrawingSearch(A);if(te==null)return;const{scene:X,canvas:Te}=te;if(J==null||Q!==N)return;const{left:nt,top:rt,width:it,height:ot,angle:Et,flipX:bt,flipY:st,skewX:at,skewY:Me}=J,ct=B.getDrawingShapeKeyByDrawingSearch({unitId:A,subUnitId:N,drawingId:_}),de=X.getObject(ct);if(de!=null){de.transformByState({left:nt,top:rt,width:it,height:ot,angle:Et,flipX:bt,flipY:st,skewX:at,skewY:Me});return}const ie={left:nt,top:rt,width:it,height:ot,zIndex:this._drawingManagerService.getDrawingOrder(A,N).length-1},Re=se===l.DrawingTypeEnum.DRAWING_CHART;if(Re){const Y=q?q.backgroundColor:"white";ie.fill=Y,ie.rotateEnabled=!1,q&&q.border&&(ie.stroke=q.border),ie.paintFirst="stroke",ie.strokeWidth=1,ie.borderEnabled=!1,ie.radius=8}const le=new P.Rect(ct,ie);Re&&le.setObjectType(P.ObjectType.CHART),X.addObject(le,P.DRAWING_OBJECT_LAYER_INDEX),F.allowTransform!==!1&&X.attachTransformerTo(le);const ue=new l.DisposableCollection,dt=X.getMainViewport(),{rowHeaderWidth:Ee,columnHeaderHeight:Be}=z.skeleton,lt={top:Be,left:Ee,bottom:dt.bottom,right:dt.right},ge={dispose:ue,rect:le,boundsOfViewArea:lt,domAnchor:n,unitId:A,subUnitId:N},K=ce(le,te.renderUnit.scene,z.skeleton,E.worksheet,ge),be=new W.BehaviorSubject(K);ge.position$=be;let je={position$:be,id:_,componentKey:F.componentKey,onPointerDown:()=>{},onPointerMove:()=>{},onPointerUp:()=>{},onWheel:Y=>{Te.dispatchEvent(new WheelEvent(Y.type,Y))},data:q,unitId:A};t.eventPassThrough&&(je={...je,onPointerDown:Y=>{Te.dispatchEvent(new PointerEvent(Y.type,Y))},onPointerMove:Y=>{Te.dispatchEvent(new PointerEvent(Y.type,Y))},onPointerUp:Y=>{Te.dispatchEvent(new PointerEvent(Y.type,Y))}}),this._canvasFloatDomService.addFloatDom(je),this.disposeWithMe(v.subscribe(Y=>{var Ht,Vt,Xt,Kt;const Gt=Je({startX:Y.startX,startY:Y.startY,endX:Y.endX,endY:Y.endY,width:(Ht=n.width)!=null?Ht:Y.width,height:(Vt=n.height)!=null?Vt:Y.height,absolute:{left:f.absolute.left,top:f.absolute.top}},n),tr=B.getDrawingShapeKeyByDrawingSearch({unitId:A,subUnitId:N,drawingId:_}),nr=new P.Rect(tr,{left:Gt.startX,top:Gt.startY,width:(Xt=n.width)!=null?Xt:Y.width,height:(Kt=n.height)!=null?Kt:Y.height,zIndex:this._drawingManagerService.getDrawingOrder(A,N).length-1}),rr=ce(nr,te.renderUnit.scene,z.skeleton,E.worksheet,ge);be.next(rr)}));const Fe=(k=this._renderManagerService.getRenderById(A))==null?void 0:k.with(U.SheetSkeletonManagerService);Fe==null||Fe.currentSkeleton$.subscribe(Y=>{Y&&z.sheetId!==Y.sheetId&&this._removeDom(S,!0)});const ut=le.onTransformChange$.subscribeEvent(()=>{const Y=ce(le,te.renderUnit.scene,z.skeleton,E.worksheet,ge);be.next(Y)});ue.add(()=>{this._canvasFloatDomService.removeFloatDom(_)}),ut&&ue.add(ut),this._domLayerInfoMap.set(_,ge)}return{id:S,dispose:()=>{this._removeDom(S,!0)}}}addFloatDomToColumnHeader(e,t,n,o){var T,C,M;const s=y.getSheetCommandTarget(this._univerInstanceService,{unitId:t.unitId,subUnitId:t.subUnitId});if(!s)throw new Error("cannot find current target!");const{unitId:a,subUnitId:c}=s;if(!this._getSceneAndTransformerByDrawingSearch(a))return;const u=this._renderManagerService.getRenderById(a);if(!u)return;const d=(T=this._renderManagerService.getRenderById(a))==null?void 0:T.with(U.SheetSkeletonManagerService).getWorksheetSkeleton(c);if(!d)return;const{componentKey:m,data:h,allowTransform:p=!0}=t,S=o!=null?o:l.generateRandomId(),{position:f,position$:v}=this._createRangePositionObserver({startRow:0,endRow:0,startColumn:e,endColumn:e},u,d.skeleton),I=f;if(I.startY=0,this._getPosition(f,a)==null)return;const O={unitId:a,subUnitId:c,drawingId:S,drawingType:t.type||l.DrawingTypeEnum.DRAWING_DOM,componentKey:m,transform:{left:I.startX,top:I.startY,width:I.width,height:I.height},data:h,allowTransform:p};{const{unitId:R,subUnitId:k,drawingId:A}=O,N=y.getSheetCommandTarget(this._univerInstanceService,{unitId:R,subUnitId:k}),_=O,E=this._univerInstanceService.getUnit(R,l.UniverInstanceType.UNIVER_SHEET);if(!E)return;const F=E.getActiveSheet().getSheetId();if(!_||!N)return;const L=(C=this._renderManagerService.getRenderById(R))==null?void 0:C.with(U.SheetSkeletonManagerService);if(!L)return;const Q=L.getWorksheetSkeleton(k);if(!Q)return;const{transform:re,data:z}=_,J=this._getSceneAndTransformerByDrawingSearch(R);if(J==null)return;const{scene:se,canvas:q}=J;if(re==null||F!==k)return;const{left:te,top:X,width:Te,height:nt,angle:rt,flipX:it,flipY:ot,skewX:Et,skewY:bt}=re,st=B.getDrawingShapeKeyByDrawingSearch({unitId:R,subUnitId:k,drawingId:A}),at=se.getObject(st);if(at!=null){at.transformByState({left:te,top:X,width:Te,height:nt,angle:rt,flipX:it,flipY:ot,skewX:Et,skewY:bt});return}const Me=Je({startX:I.startX,startY:0,endX:f.endX,endY:f.endY,width:n.width,height:n.height,absolute:{left:f.absolute.left,top:f.absolute.top}},n),ct={left:Me.startX,top:Me.startY,width:Me.width,height:Me.height,zIndex:this._drawingManagerService.getDrawingOrder(R,k).length-1},de=new P.Rect(st,ct);se.addObject(de,P.DRAWING_OBJECT_LAYER_INDEX),_.allowTransform!==!1&&se.attachTransformerTo(de);const ie=new l.DisposableCollection,Re=se.getMainViewport(),le={top:0,left:Re.left,bottom:Re.bottom,right:Re.right},ue={dispose:ie,rect:de,unitId:R,subUnitId:k,boundsOfViewArea:le,domAnchor:n,scrollDirectionResponse:"HORIZONTAL"},dt=ce(de,J.renderUnit.scene,Q.skeleton,N.worksheet,ue),Ee=new W.BehaviorSubject(dt);ue.position$=Ee;let Be={position$:Ee,id:A,componentKey:_.componentKey,onPointerDown:()=>{},onPointerMove:()=>{},onPointerUp:()=>{},onWheel:K=>{q.dispatchEvent(new WheelEvent(K.type,K))},data:z,unitId:R};t.eventPassThrough&&(Be={...Be,onPointerDown:K=>{q.dispatchEvent(new PointerEvent(K.type,K))},onPointerMove:K=>{q.dispatchEvent(new PointerEvent(K.type,K))},onPointerUp:K=>{q.dispatchEvent(new PointerEvent(K.type,K))}}),this._canvasFloatDomService.addFloatDom(Be);const lt=de.onTransformChange$.subscribeEvent(()=>{const K=ce(de,J.renderUnit.scene,Q.skeleton,N.worksheet,ue);Ee.next(K)});this.disposeWithMe(v.subscribe(K=>{const be=Je({startX:K.startX,startY:0,endX:K.endX,endY:K.endY,width:n.width,height:n.height,absolute:{left:f.absolute.left,top:f.absolute.top}},n),je=B.getDrawingShapeKeyByDrawingSearch({unitId:R,subUnitId:k,drawingId:A}),Fe=new P.Rect(je,{left:be.startX,top:0,width:n.width,height:n.height,zIndex:this._drawingManagerService.getDrawingOrder(R,k).length-1}),ut=ce(Fe,J.renderUnit.scene,Q.skeleton,N.worksheet,ue);Ee.next(ut)}));const ge=(M=this._renderManagerService.getRenderById(R))==null?void 0:M.with(U.SheetSkeletonManagerService);ge==null||ge.currentSkeleton$.subscribe(K=>{K&&d.sheetId!==K.sheetId&&this._removeDom(S,!0)}),ie.add(()=>{this._canvasFloatDomService.removeFloatDom(A)}),lt&&ie.add(lt),this._domLayerInfoMap.set(A,ue)}return{id:S,dispose:()=>{this._removeDom(S,!0)}}}_createRangePositionObserver(e,t,n){let{startRow:o,startColumn:s}=e;const a=ke(o,s,n),c=new W.BehaviorSubject(a),g=ke(e.endRow,e.endColumn,n),u=new W.BehaviorSubject(g),d=()=>{const v=ke(o,s,n),I=ke(e.endRow,e.endColumn,n);c.next(v),u.next(I)},m=new l.DisposableCollection;m.add(t.engine.clientRect$.subscribe(()=>d())),m.add(this._commandService.onCommandExecuted(v=>{if(v.id===y.SetWorksheetRowAutoHeightMutation.id&&v.params.rowsAutoHeightInfo.findIndex(D=>D.row===o)>-1){d();return}(y.COMMAND_LISTENER_SKELETON_CHANGE.indexOf(v.id)>-1||v.id===U.SetScrollOperation.id||v.id===U.SetZoomRatioOperation.id)&&d()}));const h=(v,I)=>{o=v,s=I,d()},p=()=>({rotate:0,width:g.right-a.left,height:g.bottom-a.top,absolute:{left:!0,top:!0},startX:a.left,startY:a.top,endX:g.right,endY:g.bottom}),S=c.pipe(W.map(v=>{const I=ke(e.endRow,e.endColumn,n);return{rotate:0,width:I.right-v.left,height:I.bottom-v.top,absolute:{left:!0,top:!0},startX:v.left,startY:v.top,endX:I.right,endY:I.bottom}})),f=p();return{position$:S,position:f,updateRowCol:h,topLeftPos$:c,rightBottomPos$:u,disposable:m}}},b.SheetCanvasFloatDomManagerService=Mn([Se(0,l.Inject(P.IRenderManagerService)),Se(1,l.IUniverInstanceService),Se(2,l.Inject(l.ICommandService)),Se(3,B.IDrawingManagerService),Se(4,l.Inject(j.CanvasFloatDomService)),Se(5,w.ISheetDrawingService),Se(6,l.Inject(l.LifecycleService))],b.SheetCanvasFloatDomManagerService);function ke(i,r,e){const t=e.getCellWithCoordByIndex(i,r),n=t.isMergedMainCell?t.mergeInfo:t;return{left:n.startX,right:n.endX,top:n.startY,bottom:n.endY}}function Je(i,r,e){var g,u;e=e!=null?e:1;const t=i.endX-i.startX,n=i.endY-i.startY,o=(g=r==null?void 0:r.width)!=null?g:t,s=(u=r==null?void 0:r.height)!=null?u:n;let a=0,c=0;if(r){if(r.horizonOffsetAlign==="right"){const d=Qe(r.marginX,t*e);a=i.endX-d-o}else a=i.startX+Qe(r.marginX,t);if(r.verticalOffsetAlign==="bottom"){const d=Qe(r.marginY,n*e);c=i.endY-d-s}else c=i.startY+Qe(r.marginY,n)}return{rotate:0,startX:a,startY:c,endX:i.endX,endY:i.endY,width:o,height:s,absolute:{left:i.absolute.left,top:i.absolute.top}}}function Qe(i,r){if(i===void 0)return 0;if(typeof i=="number")return i;const e=Number.parseFloat(i);return r*e/100}const Rn=i=>{const{floatDomInfos:r,scene:e,skeleton:t,worksheet:n}=i,o=Z.useMemo(()=>r.map(s=>{const{width:a,height:c,angle:g,left:u,top:d}=s.transform,m=$t({left:u!=null?u:0,right:(u!=null?u:0)+(a!=null?a:0),top:d!=null?d:0,bottom:(d!=null?d:0)+(c!=null?c:0)},e,t,n,void 0,!0),{scaleX:h,scaleY:p}=e.getAncestorScale(),S={startX:m.left,endX:m.right,startY:m.top,endY:m.bottom,rotate:g,width:a*h,height:c*p,absolute:m.absolute},f={position$:new W.BehaviorSubject(S),position:S,id:s.drawingId,componentKey:s.componentKey,onPointerMove:()=>{},onPointerDown:()=>{},onPointerUp:()=>{},onWheel:()=>{},unitId:s.unitId,data:s.data};return[s.drawingId,f]}),[r,e,t,n]);return $.jsx("div",{style:{position:"absolute",top:0,left:0},children:o.map(([s,a])=>$.jsx(j.PrintFloatDomSingle,{layer:a,id:s,position:a.position},s))})};var En=Object.getOwnPropertyDescriptor,bn=(i,r,e,t)=>{for(var n=t>1?void 0:t?En(r,e):r,o=i.length-1,s;o>=0;o--)(s=i[o])&&(n=s(n)||n);return n},fe=(i,r)=>(e,t)=>r(e,t,i);let et=class extends l.Disposable{constructor(i,r,e,t,n,o,s){super(),this._sheetPrintInterceptorService=i,this._drawingRenderService=r,this._drawingManagerService=e,this._renderManagerService=t,this._canvasFloatDomManagerService=n,this._componetManager=o,this._injector=s,this._initPrinting(),this._initPrintingDom()}_initPrinting(){this.disposeWithMe(this._sheetPrintInterceptorService.interceptor.intercept(this._sheetPrintInterceptorService.interceptor.getInterceptPoints().PRINTING_COMPONENT_COLLECT,{handler:(i,r,e)=>{const{unitId:t,scene:n,subUnitId:o}=r,s=this._drawingManagerService.getDrawingDataForUnit(t),a=s==null?void 0:s[o];return a&&a.order.forEach(c=>{const g=a.data[c];g.drawingType!==l.DrawingTypeEnum.DRAWING_CHART&&g.drawingType!==l.DrawingTypeEnum.DRAWING_DOM&&this._drawingRenderService.renderDrawing(g,n)}),e()}})),this.disposeWithMe(this._sheetPrintInterceptorService.interceptor.intercept(this._sheetPrintInterceptorService.interceptor.getInterceptPoints().PRINTING_RANGE,{handler:(i,r,e)=>{const{unitId:t,subUnitId:n}=r,o=this._renderManagerService.getRenderById(t);if(!o)return e(i);const s=o.with(U.SheetSkeletonManagerService).getSkeletonParam(n);if(!s)return e(i);const a=this._drawingManagerService.getDrawingDataForUnit(t),c=a==null?void 0:a[r.subUnitId];if(!c)return e(i);const{scaleX:g,scaleY:u}=o.scene,d=i?{...i}:{startColumn:0,endColumn:0,endRow:0,startRow:0},m=c.order.map(h=>c.data[h]);return m.length?(m.forEach(h=>{if(!h.groupId&&h.transform&&l.Tools.isDefine(h.transform.left)&&l.Tools.isDefine(h.transform.top)&&l.Tools.isDefine(h.transform.width)&&l.Tools.isDefine(h.transform.height)){const p=s.skeleton.getCellIndexByOffset(h.transform.left,h.transform.top,g,u,{x:0,y:0}),S=s.skeleton.getCellIndexByOffset(h.transform.left+h.transform.width,h.transform.top+h.transform.height,g,u,{x:0,y:0});p.column<d.startColumn&&(d.startColumn=p.column),p.row<d.startRow&&(d.startRow=p.row),d.endRow<S.row&&(d.endRow=S.row),d.endColumn<S.column&&(d.endColumn=S.column)}}),e(d)):e(i)}}))}_initPrintingDom(){this.disposeWithMe(this._sheetPrintInterceptorService.interceptor.intercept(this._sheetPrintInterceptorService.interceptor.getInterceptPoints().PRINTING_DOM_COLLECT,{handler:(i,r,e)=>{const{unitId:t,subUnitId:n}=r,o=this._drawingManagerService.getDrawingDataForUnit(t),s=o==null?void 0:o[n];if(s){const a=s.order.map(g=>{const u=s.data[g];if(u.drawingType===l.DrawingTypeEnum.DRAWING_CHART)return{...u,componentKey:this._componetManager.get(l.PRINT_CHART_COMPONENT_KEY)};if(u.drawingType===l.DrawingTypeEnum.DRAWING_DOM){const d=this._sheetPrintInterceptorService.getPrintComponent(u.componentKey);return{...u,componentKey:this._componetManager.get(d||u.componentKey)}}return null}).filter(Boolean),c=j.connectInjector(Rn,this._injector);return H.render($.jsx(c,{floatDomInfos:a,scene:r.scene,skeleton:r.skeleton,worksheet:r.worksheet}),r.root),i==null||i.add(()=>{H.unmount(r.root)}),e(i)}}}))}};et=bn([fe(0,l.Inject(U.SheetPrintInterceptorService)),fe(1,l.Inject(he.DrawingRenderService)),fe(2,B.IDrawingManagerService),fe(3,P.IRenderManagerService),fe(4,l.Inject(b.SheetCanvasFloatDomManagerService)),fe(5,l.Inject(j.ComponentManager)),fe(6,l.Inject(l.Injector))],et);var On=Object.getOwnPropertyDescriptor,An=(i,r,e,t)=>{for(var n=t>1?void 0:t?On(r,e):r,o=i.length-1,s;o>=0;o--)(s=i[o])&&(n=s(n)||n);return n},pe=(i,r)=>(e,t)=>r(e,t,i);const Un=[y.InsertRowCommand.id,y.InsertColCommand.id,y.RemoveRowCommand.id,y.RemoveColCommand.id,y.DeleteRangeMoveLeftCommand.id,y.DeleteRangeMoveUpCommand.id,y.InsertRangeMoveDownCommand.id,y.InsertRangeMoveRightCommand.id,y.DeltaRowHeightCommand.id,y.SetRowHeightCommand.id,y.DeltaColumnWidthCommand.id,y.SetColWidthCommand.id,y.SetRowHiddenCommand.id,y.SetSpecificRowsVisibleCommand.id,y.SetSpecificColsVisibleCommand.id,y.SetColHiddenCommand.id,y.MoveColsCommand.id,y.MoveRowsCommand.id,y.MoveRangeCommand.id],Pn=[y.SetRowVisibleMutation.id,y.SetRowHiddenMutation.id,y.SetColVisibleMutation.id,y.SetColHiddenMutation.id,y.SetWorksheetRowHeightMutation.id,y.SetWorksheetRowAutoHeightMutation.id,y.SetWorksheetRowIsAutoHeightMutation.id,y.SetWorksheetColWidthMutation.id];let Dt=class extends l.Disposable{constructor(i,r,e,t,n,o,s,a,c){super(),this._context=i,this._renderManagerService=r,this._commandService=e,this._selectionRenderService=t,this._skeletonManagerService=n,this._sheetInterceptorService=o,this._sheetDrawingService=s,this._drawingManagerService=a,this._univerInstanceService=c,this._sheetInterceptorListener(),this._commandListener(),this._sheetRefreshListener()}_sheetInterceptorListener(){this.disposeWithMe(this._sheetInterceptorService.interceptAfterCommand({getMutations:i=>{if(!Un.includes(i.id))return{redos:[],undos:[]};if(i.params==null)return{redos:[],undos:[]};const r=i.id;if(r===y.InsertRowCommand.id)return this._moveRowInterceptor(i.params,"insert");if([y.MoveColsCommand.id,y.MoveRowsCommand.id,y.MoveRangeCommand.id].includes(r))return this._moveRangeInterceptor(i.params);if(r===y.InsertColCommand.id)return this._moveColInterceptor(i.params,"insert");if(r===y.RemoveRowCommand.id)return this._moveRowInterceptor(i.params,"remove");if(r===y.RemoveColCommand.id)return this._moveColInterceptor(i.params,"remove");if(r===y.DeleteRangeMoveLeftCommand.id){const{range:e}=i.params;return this._getRangeMoveUndo(e,0)}else if(r===y.DeleteRangeMoveUpCommand.id){const{range:e}=i.params;return this._getRangeMoveUndo(e,1)}else if(r===y.InsertRangeMoveDownCommand.id){const{range:e}=i.params;return this._getRangeMoveUndo(e,2)}else if(r===y.InsertRangeMoveRightCommand.id){const{range:e}=i.params;return this._getRangeMoveUndo(e,3)}else if(r===y.SetRowHiddenCommand.id||r===y.SetSpecificRowsVisibleCommand.id){const e=i.params,{unitId:t,subUnitId:n,ranges:o}=e;return this._getDrawingUndoForRowVisible(t,n,o)}else if(r===y.SetSpecificColsVisibleCommand.id||r===y.SetColHiddenCommand.id){const e=i.params,{unitId:t,subUnitId:n,ranges:o}=e;return this._getDrawingUndoForColVisible(t,n,o)}else if(r===y.DeltaRowHeightCommand.id||r===y.SetRowHeightCommand.id||r===y.DeltaColumnWidthCommand.id||r===y.SetColWidthCommand.id){const e=i.params,{unitId:t,subUnitId:n,ranges:o}=e,s=r===y.DeltaRowHeightCommand.id||r===y.SetRowHeightCommand.id;return this._getDrawingUndoForRowAndColSize(t,n,o,s)}return{redos:[],undos:[]}}}))}_getRangeMoveUndo(i,r){const e=y.getSheetCommandTarget(this._univerInstanceService);if(e==null)return{redos:[],undos:[]};const t=e.unitId,n=e.subUnitId,o=[],s=[],a=this._sheetDrawingService.getDrawingData(t,n),c=[],g=[];if(Object.keys(a).forEach(u=>{const d=a[u],{updateDrawings:m,deleteDrawings:h}=this._getUpdateOrDeleteDrawings(i,r,d);c.push(...m),g.push(...h)}),c.length===0&&g.length===0)return{redos:[],undos:[]};if(c.length>0){const u=this._sheetDrawingService.getBatchUpdateOp(c),{undo:d,redo:m,objects:h}=u;o.push({id:w.SetDrawingApplyMutation.id,params:{unitId:t,subUnitId:n,op:m,objects:h,type:w.DrawingApplyType.UPDATE}}),s.push({id:w.SetDrawingApplyMutation.id,params:{unitId:t,subUnitId:n,op:d,objects:h,type:w.DrawingApplyType.UPDATE}})}if(g.length>0){const u=this._sheetDrawingService.getBatchRemoveOp(g),d=u.undo,m=u.redo,h=u.objects;o.push({id:w.SetDrawingApplyMutation.id,params:{unitId:t,subUnitId:n,op:m,objects:h,type:w.DrawingApplyType.REMOVE}}),s.push({id:w.SetDrawingApplyMutation.id,params:{unitId:t,subUnitId:n,op:d,objects:h,type:w.DrawingApplyType.INSERT}})}return o.push({id:V.id,params:[t]}),s.push({id:V.id,params:[t]}),{redos:o,undos:s}}_getUpdateOrDeleteDrawings(i,r,e){var R,k,A,N;const t=[],n=[],{sheetTransform:o,anchorType:s=w.SheetDrawingAnchorType.Position,transform:a,unitId:c,subUnitId:g,drawingId:u}=e,{from:d,to:m}=o,{row:h,column:p}=d,{row:S,column:f}=m;if(o==null||a==null)return{updateDrawings:t,deleteDrawings:n};const{startRow:v,endRow:I,startColumn:D,endColumn:O}=i;let T=null,C=null,M;if(r===0&&h>=v&&S<=I)if(p>=D&&f<=O)n.push({unitId:c,subUnitId:g,drawingId:u});else{const _=this._shrinkCol(o,a,D,O,s);T=_==null?void 0:_.newSheetTransform,C=_==null?void 0:_.newTransform,M=(R=_==null?void 0:_.axisAlignSheetTransform)!=null?R:void 0}else if(r===1&&p>=D&&f<=O)if(h>=v&&S<=I)n.push({unitId:c,subUnitId:g,drawingId:u});else{const _=this._shrinkRow(o,a,v,I,s);T=_==null?void 0:_.newSheetTransform,C=_==null?void 0:_.newTransform,M=(k=_==null?void 0:_.axisAlignSheetTransform)!=null?k:void 0}else if(r===2){const _=this._expandRow(o,a,v,I,s);T=_==null?void 0:_.newSheetTransform,C=_==null?void 0:_.newTransform,M=(A=_==null?void 0:_.axisAlignSheetTransform)!=null?A:void 0}else if(r===3){const _=this._expandCol(o,a,D,O,s);T=_==null?void 0:_.newSheetTransform,C=_==null?void 0:_.newTransform,M=(N=_==null?void 0:_.axisAlignSheetTransform)!=null?N:void 0}if(T!=null&&C!=null){const _=ee(T,this._selectionRenderService,this._skeletonManagerService);t.push({...e,sheetTransform:T,transform:_,axisAlignSheetTransform:M})}return{updateDrawings:t,deleteDrawings:n}}_remainDrawingSize(i,r,e){const t=x({...i},this._selectionRenderService);if(t!=null){const n=G({...i},this._selectionRenderService);r.push({...e,sheetTransform:t,axisAlignSheetTransform:n})}}_getDrawingUndoForColVisible(i,r,e){const t=this._drawingManagerService.getDrawingData(i,r),n=[],o=[];if(Object.keys(t).forEach(u=>{const d=t[u],{sheetTransform:m,transform:h,anchorType:p=w.SheetDrawingAnchorType.Position}=d;if(p===w.SheetDrawingAnchorType.None)this._remainDrawingSize(h,n,d);else{const{from:S,to:f}=m,{row:v,column:I}=S,{row:D,column:O}=f;for(let T=0;T<e.length;T++){const C=e[T],{startRow:M,endRow:R,startColumn:k,endColumn:A}=C;if(O<k)continue;if(p===w.SheetDrawingAnchorType.Position){let E=null,F=null;if(I>=k&&I<=A){const L=this._skeletonManagerService.attachRangeWithCoord({startColumn:I,endColumn:A,startRow:S.row,endRow:f.row});if(L==null)return;F={...h,left:L.startX}}if(F!=null){E=x(F,this._selectionRenderService);const L=G(F,this._selectionRenderService);if(E!=null&&F!=null){n.push({...d,sheetTransform:E,transform:F,axisAlignSheetTransform:L});break}}this._remainDrawingSize(h,n,d);continue}if(I>=k&&O<=A)continue;let N=null,_=null;if(I>=k&&I<=A){const E=this._skeletonManagerService.attachRangeWithCoord({startColumn:I,endColumn:A,startRow:S.row,endRow:f.row});if(E==null)return;_={...h,left:(E==null?void 0:E.startX)||0,width:((h==null?void 0:h.width)||0)-E.endX+E.startX}}else if(O>=k&&O<=A){const E=this._skeletonManagerService.attachRangeWithCoord({startColumn:k,endColumn:O,startRow:S.row,endRow:f.row});if(E==null)return;_={...h,left:E.startX-((h==null?void 0:h.width)||0)}}else{const E=this._skeletonManagerService.attachRangeWithCoord({startColumn:k,endColumn:A,startRow:S.row,endRow:f.row});if(E==null)return;if(_={...h,width:((h==null?void 0:h.width)||0)-E.endX+E.startX},N=x(_,this._selectionRenderService),N!=null&&_!=null){const F=G(_,this._selectionRenderService);o.push({...d,sheetTransform:N,transform:_,axisAlignSheetTransform:F});break}}if(_!=null&&(N=x(_,this._selectionRenderService)),_!=null&&N!=null){const E=G(_,this._selectionRenderService);n.push({...d,sheetTransform:N,transform:_,axisAlignSheetTransform:E});break}else this._remainDrawingSize(h,n,d)}}}),n.length===0&&o.length===0)return{redos:[],undos:[]};const{redos:s,undos:a}=this._createUndoAndRedoMutation(i,r,n),c=[],g=[];if(o.length>0){const{redos:u,undos:d}=this._createUndoAndRedoMutation(i,r,o);c.push(...u),g.push(...d)}return{redos:s,undos:a,preRedos:c,preUndos:g}}_createUndoAndRedoMutation(i,r,e){const t=this._sheetDrawingService.getBatchUpdateOp(e),{undo:n,redo:o,objects:s}=t,a=[{id:w.SetDrawingApplyMutation.id,params:{unitId:i,subUnitId:r,op:o,objects:s,type:w.DrawingApplyType.UPDATE}},{id:V.id,params:[i]}],c=[{id:w.SetDrawingApplyMutation.id,params:{unitId:i,subUnitId:r,op:n,objects:s,type:w.DrawingApplyType.UPDATE}},{id:V.id,params:[i]}];return{redos:a,undos:c}}_getDrawingUndoForRowVisible(i,r,e){const t=this._drawingManagerService.getDrawingData(i,r),n=[],o=[];if(Object.keys(t).forEach(u=>{const d=t[u],{sheetTransform:m,transform:h,anchorType:p=w.SheetDrawingAnchorType.Position}=d;if(p===w.SheetDrawingAnchorType.None)this._remainDrawingSize(h,n,d);else{const{from:S,to:f}=m,{row:v,column:I}=S,{row:D,column:O}=f;for(let T=0;T<e.length;T++){const C=e[T],{startRow:M,endRow:R,startColumn:k,endColumn:A}=C;if(D<M)continue;if(p===w.SheetDrawingAnchorType.Position){let E=null,F=null;if(v>=M&&v<=R){const L=this._skeletonManagerService.attachRangeWithCoord({startColumn:S.column,endColumn:f.column,startRow:v,endRow:R});if(L==null)return;F={...h,top:L.startY}}if(F!=null){E=x(F,this._selectionRenderService);const L=G(F,this._selectionRenderService);if(E!=null&&F!=null){n.push({...d,sheetTransform:E,transform:F,axisAlignSheetTransform:L});break}}this._remainDrawingSize(h,n,d);continue}if(v>=M&&D<=R)continue;let N=null,_=null;if(v>=M&&v<=R){const E=this._skeletonManagerService.attachRangeWithCoord({startColumn:S.column,endColumn:f.column,startRow:v,endRow:R});if(E==null)return;_={...h,top:(E==null?void 0:E.startY)||0,height:((h==null?void 0:h.height)||0)-E.endY+E.startY}}else if(D>=M&&D<=R){const E=this._skeletonManagerService.attachRangeWithCoord({startColumn:S.column,endColumn:f.column,startRow:M,endRow:D});if(E==null)return;_={...h,top:E.startY-((h==null?void 0:h.height)||0)}}else{const E=this._skeletonManagerService.attachRangeWithCoord({startColumn:S.column,endColumn:f.column,startRow:M,endRow:R});if(E==null)return;if(_={...h,height:((h==null?void 0:h.height)||0)-E.endY+E.startY},N=x(_,this._selectionRenderService),N!=null&&_!=null){const F=G(_,this._selectionRenderService);o.push({...d,sheetTransform:N,transform:_,axisAlignSheetTransform:F});break}}if(_!=null&&(N=x(_,this._selectionRenderService)),_!=null&&N!=null){const E=G(_,this._selectionRenderService);n.push({...d,sheetTransform:N,transform:_,axisAlignSheetTransform:E});break}else this._remainDrawingSize(h,n,d)}}}),n.length===0&&o.length===0)return{redos:[],undos:[]};const{redos:s,undos:a}=this._createUndoAndRedoMutation(i,r,n),c=[],g=[];if(o.length>0){const{redos:u,undos:d}=this._createUndoAndRedoMutation(i,r,o);c.push(...u),g.push(...d)}return{redos:s,undos:a,preRedos:c,preUndos:g}}_getDrawingUndoForRowAndColSize(i,r,e,t){const n=this._drawingManagerService.getDrawingData(i,r),o=[];return Object.keys(n).forEach(s=>{const a=n[s],{sheetTransform:c,transform:g,anchorType:u=w.SheetDrawingAnchorType.Position}=a;if(u===w.SheetDrawingAnchorType.None)this._remainDrawingSize(g,o,a);else{const{from:d,to:m}=c,{row:h,column:p}=d,{row:S,column:f}=m;for(let v=0;v<e.length;v++){const I=e[v],{startRow:D,endRow:O,startColumn:T,endColumn:C}=I;if(S<D||f<T)continue;if(u===w.SheetDrawingAnchorType.Position&&(h<=D&&S>=O||p<=T&&f>=C)){this._remainDrawingSize(g,o,a);continue}const M=ee({...c},this._selectionRenderService,this._skeletonManagerService);if(M!=null){o.push({...a,transform:M});break}}}}),o.length===0?{redos:[],undos:[]}:this._createUndoAndRedoMutation(i,r,o)}_getUnitIdAndSubUnitId(i,r){let e,t;if(r==="insert")e=i.unitId,t=i.subUnitId;else{const n=y.getSheetCommandTarget(this._univerInstanceService);if(n==null)return;e=n.unitId,t=n.subUnitId}return{unitId:e,subUnitId:t}}_moveRangeInterceptor(i){var D,O;const{toRange:r,fromRange:e}=i,t=y.getSheetCommandTarget(this._univerInstanceService);if(!t)return{redos:[],undos:[]};const{unitId:n,subUnitId:o}=t,s=(O=(D=this._renderManagerService.getRenderById(n))==null?void 0:D.with(U.SheetSkeletonManagerService))==null?void 0:O.getCurrentSkeleton();if(!s)return{redos:[],undos:[]};const a=U.attachRangeWithCoord(s,e);if(!a)return{redos:[],undos:[]};const{startX:c,endX:g,startY:u,endY:d}=a,m=this._sheetDrawingService.getDrawingData(n,o),h=[];Object.keys(m).forEach(T=>{const C=m[T];if(C.anchorType!==w.SheetDrawingAnchorType.Both)return;const{transform:M}=C;if(!M)return;const{left:R=0,top:k=0,width:A=0,height:N=0}=M,{drawingStartX:_,drawingEndX:E,drawingStartY:F,drawingEndY:L}={drawingStartX:R,drawingEndX:R+A,drawingStartY:k,drawingEndY:k+N};c<=_&&E<=g&&u<=F&&L<=d&&h.push(C)});const p=[],S=[],f=r.startRow-e.startRow,v=r.startColumn-e.startColumn,I=h.map(T=>{const C=T.sheetTransform,M={to:{...C.to,row:C.to.row+f,column:C.to.column+v},from:{...C.from,row:C.from.row+f,column:C.from.column+v}},R=ee(M,this._selectionRenderService,this._skeletonManagerService);return{unitId:n,subUnitId:o,drawingId:T.drawingId,transform:R,sheetTransform:M}});if(I.length){const T=this._sheetDrawingService.getBatchUpdateOp(I),{undo:C,redo:M,objects:R}=T;p.push({id:w.SetDrawingApplyMutation.id,params:{unitId:n,subUnitId:o,op:M,objects:R,type:w.DrawingApplyType.UPDATE}}),S.push({id:w.SetDrawingApplyMutation.id,params:{unitId:n,subUnitId:o,op:C,objects:R,type:w.DrawingApplyType.UPDATE}})}return{redos:p,undos:S}}_moveRowInterceptor(i,r){const e=this._getUnitIdAndSubUnitId(i,r);if(e==null)return{redos:[],undos:[]};const{unitId:t,subUnitId:n}=e,{range:o}=i,s=o.startRow,a=o.endRow,c=[],g=[],u=this._sheetDrawingService.getDrawingData(t,n),d=[],m=[];if(Object.keys(u).forEach(h=>{var C,M;const p=u[h],{sheetTransform:S,transform:f,anchorType:v=w.SheetDrawingAnchorType.Position}=p;if(S==null||f==null)return;let I,D,O;if(r==="insert"){const R=this._expandRow(S,f,s,a,v);I=R==null?void 0:R.newSheetTransform,D=R==null?void 0:R.newTransform,O=(C=R==null?void 0:R.axisAlignSheetTransform)!=null?C:void 0}else{const{from:R,to:k}=S,{row:A}=R,{row:N}=k;if(v===w.SheetDrawingAnchorType.Both&&A>=s&&N<=a)m.push({unitId:t,subUnitId:n,drawingId:h});else{const _=this._shrinkRow(S,f,s,a,v);I=_==null?void 0:_.newSheetTransform,D=_==null?void 0:_.newTransform,O=(M=_==null?void 0:_.axisAlignSheetTransform)!=null?M:void 0}}if(!I||!D)return;const T={unitId:t,subUnitId:n,drawingId:h,transform:D,sheetTransform:I,axisAlignSheetTransform:O};d.push(T)}),d.length===0&&m.length===0)return{redos:[],undos:[]};if(d.length>0){const h=this._sheetDrawingService.getBatchUpdateOp(d),{undo:p,redo:S,objects:f}=h;c.push({id:w.SetDrawingApplyMutation.id,params:{unitId:t,subUnitId:n,op:S,objects:f,type:w.DrawingApplyType.UPDATE}}),g.push({id:w.SetDrawingApplyMutation.id,params:{unitId:t,subUnitId:n,op:p,objects:f,type:w.DrawingApplyType.UPDATE}})}if(m.length>0){const h=this._sheetDrawingService.getBatchRemoveOp(m),p=h.undo,S=h.redo,f=h.objects;c.push({id:w.SetDrawingApplyMutation.id,params:{unitId:t,subUnitId:n,op:S,objects:f,type:w.DrawingApplyType.REMOVE}}),g.push({id:w.SetDrawingApplyMutation.id,params:{unitId:t,subUnitId:n,op:p,objects:f,type:w.DrawingApplyType.INSERT}})}return c.push({id:V.id,params:[t]}),g.push({id:V.id,params:[t]}),{redos:c,undos:g}}_moveColInterceptor(i,r){const e=this._getUnitIdAndSubUnitId(i,r);if(e==null)return{redos:[],undos:[]};const{unitId:t,subUnitId:n}=e,{range:o}=i,s=o.startColumn,a=o.endColumn,c=[],g=[],u=this._sheetDrawingService.getDrawingData(t,n),d=[],m=[];if(Object.keys(u).forEach(h=>{var C,M;const p=u[h],{sheetTransform:S,transform:f,anchorType:v=w.SheetDrawingAnchorType.Position}=p;if(S==null||f==null)return;let I,D,O;if(r==="insert"){const R=this._expandCol(S,f,s,a,v);I=R==null?void 0:R.newSheetTransform,D=R==null?void 0:R.newTransform,O=(C=R==null?void 0:R.axisAlignSheetTransform)!=null?C:void 0}else{const{from:R,to:k}=S,{column:A}=R,{column:N}=k;if(v===w.SheetDrawingAnchorType.Both&&A>=s&&N<=a)m.push({unitId:t,subUnitId:n,drawingId:h});else{const _=this._shrinkCol(S,f,s,a,v);I=_==null?void 0:_.newSheetTransform,D=_==null?void 0:_.newTransform,O=(M=_==null?void 0:_.axisAlignSheetTransform)!=null?M:void 0}}if(!I||!D)return;const T={unitId:t,subUnitId:n,drawingId:h,transform:D,sheetTransform:I,axisAlignSheetTransform:O};d.push(T)}),d.length===0&&m.length===0)return{redos:[],undos:[]};if(d.length>0){const h=this._sheetDrawingService.getBatchUpdateOp(d),{undo:p,redo:S,objects:f}=h;c.push({id:w.SetDrawingApplyMutation.id,params:{unitId:t,subUnitId:n,op:S,objects:f,type:w.DrawingApplyType.UPDATE}}),g.push({id:w.SetDrawingApplyMutation.id,params:{unitId:t,subUnitId:n,op:p,objects:f,type:w.DrawingApplyType.UPDATE}})}if(m.length>0){const h=this._sheetDrawingService.getBatchRemoveOp(m),p=h.undo,S=h.redo,f=h.objects;c.push({id:w.SetDrawingApplyMutation.id,params:{unitId:t,subUnitId:n,op:S,objects:f,type:w.DrawingApplyType.REMOVE}}),g.push({id:w.SetDrawingApplyMutation.id,params:{unitId:t,subUnitId:n,op:p,objects:f,type:w.DrawingApplyType.INSERT}})}return c.push({id:V.id,params:[t]}),g.push({id:V.id,params:[t]}),{redos:c,undos:g}}_expandCol(i,r,e,t,n=w.SheetDrawingAnchorType.Position){const o=t-e+1,{from:s,to:a}=i,{column:c}=s,{column:g}=a;if(n===w.SheetDrawingAnchorType.None)return{newSheetTransform:x({...r},this._selectionRenderService),newTransform:r,axisAlignSheetTransform:G({...r},this._selectionRenderService)};let u=null,d=null,m=null;if(c>=e){const h=this._skeletonManagerService.attachRangeWithCoord({startColumn:e,endColumn:t,startRow:s.row,endRow:a.row});if(h==null)return;d={...r,left:(r.left||0)+h.endX-h.startX},u=x(d,this._selectionRenderService),m=G(d,this._selectionRenderService)}else if(g>=t)if(n===w.SheetDrawingAnchorType.Both)u={from:{...s},to:{...a,column:g+o}},d=ee(u,this._selectionRenderService,this._skeletonManagerService);else return{newSheetTransform:x({...r},this._selectionRenderService),newTransform:r,axisAlignSheetTransform:G({...r},this._selectionRenderService)};return u!=null&&d!=null?{newSheetTransform:u,newTransform:d,axisAlignSheetTransform:m}:null}_shrinkCol(i,r,e,t,n=w.SheetDrawingAnchorType.Position){const o=t-e+1,{from:s,to:a}=i,{column:c}=s,{column:g}=a;if(n===w.SheetDrawingAnchorType.None)return{newSheetTransform:x({...r},this._selectionRenderService),newTransform:r,axisAlignSheetTransform:G({...r},this._selectionRenderService)};let u=null,d=null,m=null;if(c>t)u={from:{...s,column:c-o},to:{...a,column:g-o}},d=ee(u,this._selectionRenderService,this._skeletonManagerService);else{if(c>=e&&g<=t)return null;if(c<e&&g>t)if(n===w.SheetDrawingAnchorType.Both)u={from:{...s},to:{...a,column:g-o}},d=ee(u,this._selectionRenderService,this._skeletonManagerService);else return{newSheetTransform:x({...r},this._selectionRenderService),newTransform:r,axisAlignSheetTransform:G({...r},this._selectionRenderService)};else if(c>=e&&c<=t){if(c===e)d={...r,left:(r.left||0)-i.from.columnOffset};else{const h=this._skeletonManagerService.attachRangeWithCoord({startColumn:e,endColumn:c-1,startRow:s.row,endRow:a.row});if(h==null)return;d={...r,left:(r.left||0)-h.endX+h.startX-i.from.columnOffset}}u=x(d,this._selectionRenderService),m=G(d,this._selectionRenderService)}else if(g>=e&&g<=t&&n===w.SheetDrawingAnchorType.Both){const h=this._skeletonManagerService.attachRangeWithCoord({startColumn:e-1,endColumn:e-1,startRow:s.row,endRow:a.row});if(h==null)return;u={from:{...s},to:{...a,column:e-1,columnOffset:h.endX-h.startX}},d=ee(u,this._selectionRenderService,this._skeletonManagerService)}}return u!=null&&d!=null?{newSheetTransform:u,newTransform:d,axisAlignSheetTransform:m}:null}_expandRow(i,r,e,t,n=w.SheetDrawingAnchorType.Position){const o=t-e+1,{from:s,to:a}=i,{row:c}=s,{row:g}=a;if(n===w.SheetDrawingAnchorType.None)return{newSheetTransform:x({...r},this._selectionRenderService),newTransform:r,axisAlignSheetTransform:G({...r},this._selectionRenderService)};let u=null,d=null,m=null;if(c>=e){const h=this._skeletonManagerService.attachRangeWithCoord({startRow:e,endRow:t,startColumn:s.column,endColumn:a.column});if(h==null)return;d={...r,top:(r.top||0)+h.endY-h.startY},u=x(d,this._selectionRenderService),m=G(d,this._selectionRenderService)}else if(g>=t)if(n===w.SheetDrawingAnchorType.Both)u={from:{...s},to:{...a,row:g+o}},d=ee(u,this._selectionRenderService,this._skeletonManagerService);else return{newSheetTransform:x({...r},this._selectionRenderService),newTransform:r,axisAlignSheetTransform:G({...r},this._selectionRenderService)};return u!=null&&d!=null?{newSheetTransform:u,newTransform:d,axisAlignSheetTransform:m}:null}_shrinkRow(i,r,e,t,n=w.SheetDrawingAnchorType.Position){const o=t-e+1,{from:s,to:a}=i,{row:c}=s,{row:g}=a;if(n===w.SheetDrawingAnchorType.None)return{newSheetTransform:x({...r},this._selectionRenderService),newTransform:r,axisAlignSheetTransform:G({...r},this._selectionRenderService)};let u=null,d=null,m=null;if(c>t)u={from:{...s,row:c-o},to:{...a,row:g-o}},d=ee(u,this._selectionRenderService,this._skeletonManagerService);else{if(c>=e&&g<=t)return null;if(c<e&&g>t)if(n===w.SheetDrawingAnchorType.Both)u={from:{...s},to:{...a,row:g-o}},d=ee(u,this._selectionRenderService,this._skeletonManagerService);else return{newSheetTransform:x({...r},this._selectionRenderService),newTransform:r,axisAlignSheetTransform:G({...r},this._selectionRenderService)};else if(c>=e&&c<=t){if(c===e)d={...r,top:(r.top||0)-i.from.rowOffset};else{const h=this._skeletonManagerService.attachRangeWithCoord({startRow:e,endRow:c-1,startColumn:s.column,endColumn:a.column});if(h==null)return;d={...r,top:(r.top||0)-h.endY+h.startY-i.from.rowOffset}}u=x(d,this._selectionRenderService),m=G(d,this._selectionRenderService)}else if(g>=e&&g<=t&&n===w.SheetDrawingAnchorType.Both){const h=this._skeletonManagerService.attachRangeWithCoord({startColumn:s.column,endColumn:s.column,startRow:e-1,endRow:e-1});if(h==null)return;u={from:{...s},to:{...a,row:e-1,rowOffset:h.endY-h.startY}},d=ee(u,this._selectionRenderService,this._skeletonManagerService)}}return u!=null&&d!=null?{newSheetTransform:u,newTransform:d,axisAlignSheetTransform:m}:null}_commandListener(){this.disposeWithMe(this._commandService.onCommandExecuted(i=>{if(i.id===y.SetWorksheetActiveOperation.id){const{unitId:r,subUnitId:e}=i.params;this._updateDrawings(r,e)}})),this.disposeWithMe(this._context.activated$.subscribe(i=>{const{unit:r,unitId:e}=this._context;if(i){const t=r.getActiveSheet().getSheetId();this._updateDrawings(e,t)}else this._clearDrawings(e)}))}_clearDrawings(i){setTimeout(()=>{const r=this._drawingManagerService.drawingManagerData,e=[];Object.keys(r).forEach(t=>{const n=r[t];n!=null&&Object.keys(n).forEach(o=>{const s=n[o].data;s!=null&&Object.keys(s).forEach(a=>{t===i&&e.push(s[a])})})}),this._sheetDrawingService.removeNotification(e),this._drawingManagerService.removeNotification(e)})}_updateDrawings(i,r){setTimeout(()=>{const e=this._drawingManagerService.drawingManagerData,t=[],n=[];Object.keys(e).forEach(o=>{const s=e[o];s!=null&&Object.keys(s).forEach(a=>{const c=s[a].data;c!=null&&Object.keys(c).forEach(g=>{if(o===i&&a===r){const u=c[g];u.transform=ee(u.sheetTransform,this._selectionRenderService,this._skeletonManagerService),t.push(c[g])}else n.push(c[g])})})}),this._sheetDrawingService.removeNotification(n),this._sheetDrawingService.addNotification(t),this._drawingManagerService.removeNotification(n),this._drawingManagerService.addNotification(t)},0)}_sheetRefreshListener(){this.disposeWithMe(this._commandService.onCommandExecuted(i=>{Pn.includes(i.id)&&requestIdleCallback(()=>{const r=i.params,e=y.getSheetCommandTarget(this._univerInstanceService,r);if(!e)return;const{unitId:t,subUnitId:n,worksheet:o}=e;let s=[];"ranges"in r?s=r.ranges:"rowsAutoHeightInfo"in r&&(s=r.rowsAutoHeightInfo.map(a=>({startRow:a.row,endRow:a.row,startColumn:0,endColumn:o.getColumnCount()-1}))),this._refreshDrawingTransform(t,n,s)})}))}_refreshDrawingTransform(i,r,e){const t=this._drawingManagerService.getDrawingData(i,r),n=[];Object.keys(t).forEach(o=>{const s=t[o],{sheetTransform:a,transform:c,anchorType:g=w.SheetDrawingAnchorType.Position}=s;if(g===w.SheetDrawingAnchorType.None)return!0;const{from:u,to:d}=a,{row:m,column:h}=u,{row:p,column:S}=d;for(let f=0;f<e.length;f++){const v=e[f],{startRow:I,endRow:D,startColumn:O,endColumn:T}=v;if(l.Rectangle.intersects({startRow:I,endRow:D,startColumn:O,endColumn:T},{startRow:m,endRow:p,startColumn:h,endColumn:S})||m>D||h>T){const C=g===w.SheetDrawingAnchorType.Position,M=ee(a,this._selectionRenderService,this._skeletonManagerService);n.push({...s,transform:{...M,width:C?c==null?void 0:c.width:M==null?void 0:M.width,height:C?c==null?void 0:c.height:M==null?void 0:M.height}});break}}}),n.length!==0&&(this._sheetDrawingService.refreshTransform(n),this._drawingManagerService.refreshTransform(n),this._commandService.syncExecuteCommand(V.id,[i]))}};Dt=An([pe(1,P.IRenderManagerService),pe(2,l.ICommandService),pe(3,U.ISheetSelectionRenderService),pe(4,l.Inject(U.SheetSkeletonManagerService)),pe(5,l.Inject(y.SheetInterceptorService)),pe(6,w.ISheetDrawingService),pe(7,B.IDrawingManagerService),pe(8,l.IUniverInstanceService)],Dt);function Nn(){const i=j.useDependency(l.LocaleService),r=j.useDependency(j.IDialogService),e=j.useDependency(Ye),[t,n]=Z.useState([me.CELL_ADDRESS]),[o,s]=Z.useState(!1),[a,c]=Z.useState(null),g=Z.useMemo(()=>e.getCellImagesInSelection(),[e]),u=Z.useMemo(()=>e.getDataColumns(),[e]),d=Z.useMemo(()=>e.getSelectionRowRange(),[e]),m=u.length>0,h=Z.useMemo(()=>u.map(C=>({label:C.label,value:String(C.index)})),[u]),[p,S]=Z.useState(()=>h.length>0?h[0].value:"0"),f=Z.useMemo(()=>{if(!t.includes(me.COLUMN_VALUE)||!d)return[];const M=Number(p);return[{startRow:d.startRow,endRow:d.endRow,startColumn:M,endColumn:M}]},[t,p,d]);U.useHighlightRange(f);const v=Z.useCallback(C=>{C.length!==0&&n(C)},[]),I=Z.useCallback(C=>{S(String(C))},[]),D=Z.useCallback(()=>{r.close(Ie)},[r]),O=Z.useCallback(async()=>{if(g.length!==0){s(!0),c(null);try{await e.saveImages(g,{fileNameParts:t,columnIndex:t.includes(me.COLUMN_VALUE)?Number(p):void 0}),r.close(Ie)}catch(C){console.error("Failed to save images:",C),c(i.t("sheetImage.save.error"))}finally{s(!1)}}},[e,g,t,p,r,i]),T=t.includes(me.COLUMN_VALUE);return $.jsxs("div",{className:"univer-flex univer-flex-col",children:[$.jsx(H.FormLayout,{label:i.t("sheetImage.save.imageCount"),children:$.jsx("div",{className:"univer-text-sm univer-text-gray-600",children:g.length})}),$.jsx(H.FormLayout,{label:i.t("sheetImage.save.fileNameConfig"),children:$.jsxs(H.CheckboxGroup,{value:t,onChange:v,direction:"vertical",children:[$.jsx(H.Checkbox,{value:me.CELL_ADDRESS,disabled:!m,children:i.t("sheetImage.save.useRowCol")}),m&&$.jsx(H.Checkbox,{value:me.COLUMN_VALUE,children:i.t("sheetImage.save.useColumnValue")})]})}),T&&$.jsx(H.FormLayout,{label:i.t("sheetImage.save.selectColumn"),children:$.jsx(H.Select,{value:p,options:h,onChange:I})}),a&&$.jsx("div",{className:"univer-text-xs univer-text-red-500",children:a}),$.jsxs("div",{className:"univer-flex univer-justify-end univer-gap-2 univer-border-t univer-border-gray-200 univer-pt-3",children:[$.jsx(H.Button,{onClick:D,disabled:o,children:i.t("sheetImage.save.cancel")}),$.jsx(H.Button,{variant:"primary",onClick:O,disabled:o||g.length===0,children:o?i.t("sheetImage.save.saving"):i.t("sheetImage.save.confirm")})]})]})}const Yt=i=>{var I;const r=j.useDependency(l.ICommandService),e=j.useDependency(l.LocaleService),t=j.useDependency(B.IDrawingManagerService),n=j.useDependency(P.IRenderManagerService),{drawings:o}=i,s=o[0];if(s==null)return;const{unitId:a}=s,c=n.getRenderById(a),g=c==null?void 0:c.scene;if(g==null)return;const u=g.getTransformerByCreate(),[d,m]=Z.useState(!0),h=(I=s.anchorType)!=null?I:w.SheetDrawingAnchorType.Position,[p,S]=Z.useState(h);function f(D,O){const T=[];return D.forEach(C=>{const{oKey:M}=C,R=O.getDrawingOKey(M);if(R==null)return T.push(null),!0;const{unitId:k,subUnitId:A,drawingId:N,drawingType:_,anchorType:E,sheetTransform:F,axisAlignSheetTransform:L}=R;T.push({unitId:k,subUnitId:A,drawingId:N,anchorType:E,sheetTransform:F,drawingType:_,axisAlignSheetTransform:L})}),T}Z.useEffect(()=>{const D=u.clearControl$.subscribe(T=>{T===!0&&m(!1)}),O=u.changeStart$.subscribe(T=>{var R;const{objects:C}=T,M=f(C,t);if(M.length===0)m(!1);else if(M.length>=1){m(!0);const k=((R=M[0])==null?void 0:R.anchorType)||w.SheetDrawingAnchorType.Position;S(k)}});return()=>{O.unsubscribe(),D.unsubscribe()}},[]);function v(D){S(D);const O=t.getFocusDrawings();if(O.length===0)return;const T=O.map(C=>({unitId:C.unitId,subUnitId:C.subUnitId,drawingId:C.drawingId,anchorType:D}));r.executeCommand(ve.id,{unitId:O[0].unitId,drawings:T})}return $.jsxs("div",{className:H.clsx("univer-grid univer-gap-2 univer-py-2 univer-text-gray-400",{"univer-hidden":!d}),children:[$.jsx("header",{className:"univer-text-gray-600 dark:!univer-text-gray-200",children:$.jsx("div",{children:e.t("drawing-anchor.title")})}),$.jsx("div",{children:$.jsxs(H.RadioGroup,{value:p,onChange:v,direction:"vertical",children:[$.jsx(H.Radio,{value:w.SheetDrawingAnchorType.Both,children:e.t("drawing-anchor.both")}),$.jsx(H.Radio,{value:w.SheetDrawingAnchorType.Position,children:e.t("drawing-anchor.position")}),$.jsx(H.Radio,{value:w.SheetDrawingAnchorType.None,children:e.t("drawing-anchor.none")})]})})]})},kn=()=>{const i=j.useDependency(B.IDrawingManagerService),r=i.getFocusDrawings(),[e,t]=Z.useState(r);return Z.useEffect(()=>{const n=i.focus$.subscribe(o=>{t(o)});return()=>{n.unsubscribe()}},[]),!!(e!=null&&e.length)&&$.jsxs("div",{className:"univer-text-sm",children:[$.jsx(he.DrawingCommonPanel,{drawings:e}),$.jsx(Yt,{drawings:e})]})},Tt="sheet.menu.image";function Wn(i){return{id:Tt,type:j.MenuItemType.SUBITEMS,icon:"AddImageIcon",tooltip:"sheetImage.title",hidden$:j.getMenuHiddenObservable(i,l.UniverInstanceType.UNIVER_SHEET),disabled$:U.getCurrentRangeDisable$(i,{workbookTypes:[y.WorkbookEditablePermission],worksheetTypes:[y.WorksheetEditPermission],rangeTypes:[y.RangeProtectionPermissionEditPoint]})}}function Bn(i){return{id:Ae.id,title:"sheetImage.upload.float",type:j.MenuItemType.BUTTON,hidden$:j.getMenuHiddenObservable(i,l.UniverInstanceType.UNIVER_SHEET)}}function jn(i){return{id:ft.id,title:"sheetImage.upload.cell",type:j.MenuItemType.BUTTON,hidden$:j.getMenuHiddenObservable(i,l.UniverInstanceType.UNIVER_SHEET)}}function Fn(i){var r,e,t,n;return!!((e=(r=i==null?void 0:i.p)==null?void 0:r.drawingsOrder)!=null&&e.length&&((n=(t=i==null?void 0:i.p)==null?void 0:t.drawingsOrder)==null?void 0:n.length)>0)}function Ln(i,r){const e=i.getActiveSheet();if(!e)return!1;const t=e.getCellMatrix(),{startRow:n,endRow:o,startColumn:s,endColumn:a}=r;for(let c=n;c<=o;c++)for(let g=s;g<=a;g++){const u=t.getValue(c,g);if(Fn(u))return!0}return!1}function $n(){return"showDirectoryPicker"in window}function Mt(i){const r=i.get(l.IUniverInstanceService),e=i.get(y.SheetsSelectionsService),t=W.combineLatest([j.getMenuHiddenObservable(i,l.UniverInstanceType.UNIVER_SHEET),r.getCurrentTypeOfUnit$(l.UniverInstanceType.UNIVER_SHEET).pipe(W.switchMap(n=>n?e.selectionMoveEnd$.pipe(W.map(()=>{if(!$n())return!0;const o=e.getCurrentSelections();if(!o||o.length===0)return!0;for(const s of o)if(Ln(n,s.range))return!1;return!0})):W.of(!0)))]).pipe(W.map(([n,o])=>n||o));return{id:ye.id,type:j.MenuItemType.BUTTON,icon:"DownloadImageIcon",title:"sheetImage.save.menuLabel",hidden$:t}}const Yn={[j.RibbonInsertGroup.MEDIA]:{[Tt]:{order:0,menuItemFactory:Wn,[Ae.id]:{order:0,menuItemFactory:Bn},[ft.id]:{order:1,menuItemFactory:jn}}},[j.ContextMenuPosition.MAIN_AREA]:{[j.ContextMenuGroup.OTHERS]:{[ye.id]:{order:10,menuItemFactory:Mt}}},[j.ContextMenuPosition.COL_HEADER]:{[j.ContextMenuGroup.OTHERS]:{[ye.id]:{order:10,menuItemFactory:Mt}}},[j.ContextMenuPosition.ROW_HEADER]:{[j.ContextMenuGroup.OTHERS]:{[ye.id]:{order:10,menuItemFactory:Mt}}}};function We(i){return i.getContextValue(l.FOCUSING_SHEET)&&!i.getContextValue(l.FOCUSING_FX_BAR_EDITOR)&&!i.getContextValue(l.FOCUSING_PANEL_EDITOR)&&i.getContextValue(l.FOCUSING_COMMON_DRAWINGS)&&!i.getContextValue(l.FOCUSING_SHAPE_TEXT_EDITOR)}const xn={id:_e.id,description:"shortcut.drawing-move-down",group:"4_drawing-view",binding:j.KeyCode.ARROW_DOWN,priority:100,preconditions:We,staticParameters:{direction:l.Direction.DOWN}},Gn={id:_e.id,description:"shortcut.drawing-move-up",group:"4_drawing-view",binding:j.KeyCode.ARROW_UP,priority:100,preconditions:We,staticParameters:{direction:l.Direction.UP}},Hn={id:_e.id,description:"shortcut.drawing-move-left",group:"4_drawing-view",binding:j.KeyCode.ARROW_LEFT,priority:100,preconditions:We,staticParameters:{direction:l.Direction.LEFT}},Vn={id:_e.id,description:"shortcut.drawing-move-right",group:"4_drawing-view",binding:j.KeyCode.ARROW_RIGHT,priority:100,preconditions:We,staticParameters:{direction:l.Direction.RIGHT}},Xn={id:gt.id,description:"shortcut.drawing-delete",group:"4_drawing-view",priority:100,preconditions:We,binding:j.KeyCode.DELETE,mac:j.KeyCode.BACKSPACE};var Kn=Object.getOwnPropertyDescriptor,zn=(i,r,e,t)=>{for(var n=t>1?void 0:t?Kn(r,e):r,o=i.length-1,s;o>=0;o--)(s=i[o])&&(n=s(n)||n);return n},De=(i,r)=>(e,t)=>r(e,t,i);let tt=class extends l.Disposable{constructor(i,r,e,t,n,o){super(),this._componentManager=i,this._menuManagerService=r,this._commandService=e,this._shortcutService=t,this._drawingManagerService=n,this._sheetsSelectionsService=o,this._init()}_initCustomComponents(){const i=this._componentManager;this.disposeWithMe(i.register(Nt,kn)),this.disposeWithMe(i.register(Ie,Nn))}_initMenus(){this._menuManagerService.mergeMenu(Yn)}_initCommands(){[Ae,ft,Oe,we,ve,_t,V,It,ht,pt,_e,gt,mt,ye].forEach(i=>this.disposeWithMe(this._commandService.registerCommand(i)))}_initShortcuts(){[xn,Gn,Hn,Vn,Xn].forEach(i=>{this.disposeWithMe(this._shortcutService.registerShortcut(i))})}_init(){this._initCommands(),this._initCustomComponents(),this._initMenus(),this._initShortcuts()}};tt=zn([De(0,l.Inject(j.ComponentManager)),De(1,j.IMenuManagerService),De(2,l.ICommandService),De(3,j.IShortcutService),De(4,B.IDrawingManagerService),De(5,l.Inject(y.SheetsSelectionsService))],tt);var qn=Object.defineProperty,Zn=Object.getOwnPropertyDescriptor,Jn=(i,r,e)=>r in i?qn(i,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[r]=e,Qn=(i,r,e,t)=>{for(var n=t>1?void 0:t?Zn(r,e):r,o=i.length-1,s;o>=0;o--)(s=i[o])&&(n=s(n)||n);return n},Rt=(i,r)=>(e,t)=>r(e,t,i),xt=(i,r,e)=>Jn(i,typeof r!="symbol"?r+"":r,e);const er="SHEET_IMAGE_UI_PLUGIN";b.UniverSheetsDrawingUIPlugin=class extends l.Plugin{constructor(r=kt,e,t,n){super(),this._config=r,this._injector=e,this._renderManagerService=t,this._configService=n;const{menu:o,...s}=l.merge({},kt,this._config);o&&this._configService.setConfig("menu",o,{merge:!0}),this._configService.setConfig(rn,s)}onStarting(){l.registerDependencies(this._injector,[[b.SheetCanvasFloatDomManagerService],[tt],[Ge],[et],[Ze],[qe],[Xe],[Ke],[ze],[Ye,{useClass:b.BatchSaveImagesService}]]),l.touchDependencies(this._injector,[[b.SheetCanvasFloatDomManagerService]])}onReady(){l.touchDependencies(this._injector,[[qe],[ze]])}onRendered(){this._registerRenderModules(),l.touchDependencies(this._injector,[[Ze],[et],[tt],[Xe],[Ke]])}onSteady(){this._injector.get(Ge)}_registerRenderModules(){[[b.SheetDrawingUpdateController],[Dt],[Ct],[yt]].forEach(r=>{this.disposeWithMe(this._renderManagerService.registerRenderModule(l.UniverInstanceType.UNIVER_SHEET,r))})}},xt(b.UniverSheetsDrawingUIPlugin,"type",l.UniverInstanceType.UNIVER_SHEET),xt(b.UniverSheetsDrawingUIPlugin,"pluginName",er),b.UniverSheetsDrawingUIPlugin=Qn([l.DependentOn(B.UniverDrawingPlugin,Ot.UniverDocsDrawingPlugin,he.UniverDrawingUIPlugin,w.UniverSheetsDrawingPlugin),Rt(1,l.Inject(l.Injector)),Rt(2,P.IRenderManagerService),Rt(3,l.IConfigService)],b.UniverSheetsDrawingUIPlugin),b.ClearSheetDrawingTransformerOperation=V,b.DeleteDrawingsCommand=gt,b.EditSheetDrawingOperation=It,b.FileNamePart=me,b.GroupSheetDrawingCommand=ht,b.IBatchSaveImagesService=Ye,b.InsertFloatImageCommand=Ae,b.InsertSheetDrawingCommand=Oe,b.MoveDrawingsCommand=_e,b.RemoveSheetDrawingCommand=we,b.SHEETS_IMAGE_MENU_ID=Tt,b.SHEET_FLOAT_DOM_PREFIX=Lt,b.SaveCellImagesCommand=ye,b.SetDrawingArrangeCommand=mt,b.SetSheetDrawingCommand=ve,b.SheetDrawingAnchor=Yt,b.SidebarSheetDrawingOperation=_t,b.UngroupSheetDrawingCommand=pt,b.calcSheetFloatDomPosition=ce,b.drawingPositionToTransform=ee,b.transformToAxisAlignPosition=G,b.transformToDrawingPosition=x,Object.defineProperty(b,Symbol.toStringTag,{value:"Module"})}));
14
+ (function(A,N){typeof exports=="object"&&typeof module<"u"?N(exports,require("@univerjs/engine-render"),require("@univerjs/sheets-ui"),require("@univerjs/core"),require("@univerjs/sheets-drawing"),require("@univerjs/sheets"),require("@univerjs/design"),require("@univerjs/docs-ui"),require("@univerjs/drawing"),require("@univerjs/ui"),require("@univerjs/docs-drawing"),require("@univerjs/drawing-ui"),require("rxjs"),require("react/jsx-runtime"),require("react")):typeof define=="function"&&define.amd?define(["exports","@univerjs/engine-render","@univerjs/sheets-ui","@univerjs/core","@univerjs/sheets-drawing","@univerjs/sheets","@univerjs/design","@univerjs/docs-ui","@univerjs/drawing","@univerjs/ui","@univerjs/docs-drawing","@univerjs/drawing-ui","rxjs","react/jsx-runtime","react"],N):(A=typeof globalThis<"u"?globalThis:A||self,N(A.UniverSheetsDrawingUi={},A.UniverEngineRender,A.UniverSheetsUi,A.UniverCore,A.UniverSheetsDrawing,A.UniverSheets,A.UniverDesign,A.UniverDocsUi,A.UniverDrawing,A.UniverUi,A.UniverDocsDrawing,A.UniverDrawingUi,A.rxjs,A.React,A.React))})(this,(function(A,N,U,l,w,y,X,Ge,B,j,At,Se,W,Y,Q){"use strict";var sr=Object.defineProperty;var ar=(A,N,U)=>N in A?sr(A,N,{enumerable:!0,configurable:!0,writable:!0,value:U}):A[N]=U;var se=(A,N,U)=>ar(A,typeof N!="symbol"?N+"":N,U);function te(i,r,e){const{from:t,to:n,flipY:o=!1,flipX:s=!1,angle:a=0,skewX:c=0,skewY:g=0}=i,u=e.getCurrent();if(u==null)return;const d=U.convertPositionSheetOverGridToAbsolute(u.unitId,u.sheetId,{from:t,to:n},e);let{left:m,top:h,width:p,height:S}=d;const f=e.getCurrentSkeleton(),v=f.rowHeaderWidth+f.columnTotalWidth,I=f.columnHeaderHeight+f.rowTotalHeight;return m+p>v&&(m=v-p),h+S>I&&(h=I-S),{flipY:o,flipX:s,angle:a,skewX:c,skewY:g,left:m,top:h,width:p,height:S}}function x(i,r){const{left:e=0,top:t=0,width:n=0,height:o=0,flipY:s=!1,flipX:a=!1,angle:c=0,skewX:g=0,skewY:u=0}=i,d=r.getCellWithCoordByOffset(e,t);if(d==null)return;const m={column:d.actualColumn,columnOffset:N.precisionTo(e-d.startX,1),row:d.actualRow,rowOffset:N.precisionTo(t-d.startY,1)},h=r.getCellWithCoordByOffset(e+n,t+o);if(h==null)return;const p={column:h.actualColumn,columnOffset:N.precisionTo(e+n-h.startX,1),row:h.actualRow,rowOffset:N.precisionTo(t+o-h.startY,1)};return{flipY:s,flipX:a,angle:c,skewX:g,skewY:u,from:m,to:p}}function G(i,r){const{left:e=0,top:t=0,width:n=0,height:o=0,angle:s=0}=i,a=(s%360+360)%360;if(!(a>=45&&a<135||a>=225&&a<315))return x(i,r);const g={...i,left:e+n/2-o/2,top:t+o/2-n/2,width:o,height:n};return x(g,r)}const K={id:"sheet.operation.clear-drawing-transformer",type:l.CommandType.MUTATION,handler:(i,r)=>{const e=i.get(N.IRenderManagerService);return r.forEach(t=>{var n,o;(o=(n=e.getRenderById(t))==null?void 0:n.scene.getTransformer())==null||o.debounceRefreshControls()}),!0}},Ce={id:"sheet.command.remove-sheet-image",type:l.CommandType.COMMAND,handler:(i,r)=>{var I,T,O;const e=i.get(l.ICommandService),t=i.get(l.IUndoRedoService),n=i.get(y.SheetInterceptorService),o=i.get(w.ISheetDrawingService);if(!r)return!1;const{drawings:s}=r,a=[];s.forEach(D=>{const{unitId:C}=D;a.push(C)});const c=o.getBatchRemoveOp(s),{unitId:g,subUnitId:u,undo:d,redo:m,objects:h}=c,p=n.onCommandExecute({id:Ce.id,params:r}),S={id:w.SetDrawingApplyMutation.id,params:{unitId:g,subUnitId:u,op:m,objects:h,type:w.DrawingApplyType.REMOVE}},f={id:w.SetDrawingApplyMutation.id,params:{unitId:g,subUnitId:u,op:d,objects:h,type:w.DrawingApplyType.INSERT}};return l.sequenceExecute([...(I=p.preRedos)!=null?I:[],S,...p.redos],e)?(t.pushUndoRedo({unitID:g,undoMutations:[...(T=p.preUndos)!=null?T:[],f,...p.undos,{id:K.id,params:a}],redoMutations:[...(O=p.preRedos)!=null?O:[],S,...p.redos,{id:K.id,params:a}]}),!0):!1}},gt={id:"sheet.command.delete-drawing",type:l.CommandType.COMMAND,handler:i=>{const r=i.get(l.ICommandService),t=i.get(w.ISheetDrawingService).getFocusDrawings();if(t.length===0)return!1;const n=t[0].unitId,o=t.map(s=>{const{unitId:a,subUnitId:c,drawingId:g,drawingType:u}=s;return{unitId:a,subUnitId:c,drawingId:g,drawingType:u}});return r.executeCommand(Ce.id,{unitId:n,drawings:o})}};function qt(i){const r=[];return i.forEach(e=>{const{parent:t,children:n}=e,{unitId:o,subUnitId:s,drawingId:a}=t,c=N.getGroupState(0,0,n.map(d=>d.transform||{})),g=n.map(d=>{const m=d.transform||{left:0,top:0},{unitId:h,subUnitId:p,drawingId:S}=d;return{unitId:h,subUnitId:p,drawingId:S,transform:{...m,left:m.left-c.left,top:m.top-c.top},groupId:a}}),u={unitId:o,subUnitId:s,drawingId:a,drawingType:l.DrawingTypeEnum.DRAWING_GROUP,transform:c};r.push({parent:u,children:g})}),r}function Zt(i){const r=[];return i.forEach(e=>{const{parent:t,children:n}=e,{unitId:o,subUnitId:s,drawingId:a,transform:c={width:0,height:0}}=t;if(c==null)return;const g=n.map(d=>{const{transform:m}=d,{unitId:h,subUnitId:p,drawingId:S}=d,f=N.transformObjectOutOfGroup(m||{},c,c.width||0,c.height||0);return{unitId:h,subUnitId:p,drawingId:S,transform:f,groupId:void 0}}),u={unitId:o,subUnitId:s,drawingId:a,drawingType:l.DrawingTypeEnum.DRAWING_GROUP,transform:{left:0,top:0}};r.push({parent:u,children:g})}),r}const ht={id:"sheet.command.group-sheet-image",type:l.CommandType.COMMAND,handler:(i,r)=>{const e=i.get(l.ICommandService),t=i.get(l.IUndoRedoService),n=i.get(w.ISheetDrawingService);if(!r)return!1;const o=[];r.forEach(({parent:h,children:p})=>{o.push(h.unitId),p.forEach(S=>{o.push(S.unitId)})});const s=n.getGroupDrawingOp(r),{unitId:a,subUnitId:c,undo:g,redo:u,objects:d}=s;return e.syncExecuteCommand(w.SetDrawingApplyMutation.id,{op:u,unitId:a,subUnitId:c,objects:d,type:w.DrawingApplyType.GROUP})?(t.pushUndoRedo({unitID:a,undoMutations:[{id:w.SetDrawingApplyMutation.id,params:{op:g,unitId:a,subUnitId:c,objects:Zt(d),type:w.DrawingApplyType.UNGROUP}},{id:K.id,params:o}],redoMutations:[{id:w.SetDrawingApplyMutation.id,params:{op:u,unitId:a,subUnitId:c,objects:d,type:w.DrawingApplyType.GROUP}},{id:K.id,params:o}]}),!0):!1}},Ne={id:"sheet.command.insert-sheet-image",type:l.CommandType.COMMAND,handler:(i,r)=>{var I,T,O;const e=i.get(l.ICommandService),t=i.get(l.IUndoRedoService),n=i.get(w.ISheetDrawingService),o=i.get(y.SheetInterceptorService);if(!r)return!1;const s=r.drawings,a=s.map(D=>D.unitId),c=n.getBatchAddOp(s),{unitId:g,subUnitId:u,undo:d,redo:m,objects:h}=c,p=o.onCommandExecute({id:Ne.id,params:r}),S={id:w.SetDrawingApplyMutation.id,params:{op:m,unitId:g,subUnitId:u,objects:h,type:w.DrawingApplyType.INSERT}},f={id:w.SetDrawingApplyMutation.id,params:{op:d,unitId:g,subUnitId:u,objects:h,type:w.DrawingApplyType.REMOVE}};return l.sequenceExecute([...(I=p.preRedos)!=null?I:[],S,...p.redos],e)?(t.pushUndoRedo({unitID:g,undoMutations:[...(T=p.preUndos)!=null?T:[],f,...p.undos,{id:K.id,params:a}],redoMutations:[...(O=p.preRedos)!=null?O:[],S,...p.redos,{id:K.id,params:a}]}),!0):!1}},mt={id:"sheet.command.set-drawing-arrange",type:l.CommandType.COMMAND,handler:(i,r)=>{const e=i.get(l.ICommandService),t=i.get(l.IUndoRedoService);if(!r)return!1;const n=i.get(w.ISheetDrawingService),{unitId:o,subUnitId:s,drawingIds:a,arrangeType:c}=r,g={unitId:o,subUnitId:s,drawingIds:a};let u;if(c===l.ArrangeTypeEnum.forward?u=n.getForwardDrawingsOp(g):c===l.ArrangeTypeEnum.backward?u=n.getBackwardDrawingOp(g):c===l.ArrangeTypeEnum.front?u=n.getFrontDrawingsOp(g):c===l.ArrangeTypeEnum.back&&(u=n.getBackDrawingsOp(g)),u==null)return!1;const{objects:d,redo:m,undo:h}=u;return e.syncExecuteCommand(w.SetDrawingApplyMutation.id,{op:m,unitId:o,subUnitId:s,objects:d,type:w.DrawingApplyType.ARRANGE})?(t.pushUndoRedo({unitID:o,undoMutations:[{id:w.SetDrawingApplyMutation.id,params:{op:h,unitId:o,subUnitId:s,objects:d,type:w.DrawingApplyType.ARRANGE}}],redoMutations:[{id:w.SetDrawingApplyMutation.id,params:{op:m,unitId:o,subUnitId:s,objects:d,type:w.DrawingApplyType.ARRANGE}}]}),!0):!1}},De={id:"sheet.command.set-sheet-image",type:l.CommandType.COMMAND,handler:(i,r)=>{var v,I;const e=i.get(l.ICommandService),t=i.get(l.IUndoRedoService),n=i.get(w.ISheetDrawingService),o=i.get(y.SheetInterceptorService);if(!r)return!1;const{drawings:s}=r,a=n.getBatchUpdateOp(s),{unitId:c,subUnitId:g,undo:u,redo:d,objects:m}=a,h=o.onCommandExecute({id:De.id,params:r}),p=[...(v=h.preRedos)!=null?v:[],{id:w.SetDrawingApplyMutation.id,params:{unitId:c,subUnitId:g,op:d,objects:m,type:w.DrawingApplyType.UPDATE}},...h.redos,{id:K.id,params:[c]}],S=[...(I=h.preUndos)!=null?I:[],{id:w.SetDrawingApplyMutation.id,params:{unitId:c,subUnitId:g,op:u,objects:m,type:w.DrawingApplyType.UPDATE}},...h.undos,{id:K.id,params:[c]}];return l.sequenceExecute(p,e)?(t.pushUndoRedo({unitID:c,undoMutations:S,redoMutations:p}),!0):!1}},pt={id:"sheet.command.ungroup-sheet-image",type:l.CommandType.COMMAND,handler:(i,r)=>{const e=i.get(l.ICommandService),t=i.get(l.IUndoRedoService),n=i.get(w.ISheetDrawingService);if(!r)return!1;const o=[];r.forEach(({parent:h,children:p})=>{o.push(h.unitId),p.forEach(S=>{o.push(S.unitId)})});const s=n.getUngroupDrawingOp(r),{unitId:a,subUnitId:c,undo:g,redo:u,objects:d}=s;return e.syncExecuteCommand(w.SetDrawingApplyMutation.id,{op:u,unitId:a,subUnitId:c,objects:d,type:w.DrawingApplyType.UNGROUP})?(t.pushUndoRedo({unitID:a,undoMutations:[{id:w.SetDrawingApplyMutation.id,params:{op:g,unitId:a,subUnitId:c,objects:qt(d),type:w.DrawingApplyType.GROUP}},{id:K.id,params:o}],redoMutations:[{id:w.SetDrawingApplyMutation.id,params:{op:u,unitId:a,subUnitId:c,objects:d,type:w.DrawingApplyType.UNGROUP}},{id:K.id,params:o}]}),!0):!1}};var Jt=Object.getOwnPropertyDescriptor,Qt=(i,r,e,t)=>{for(var n=t>1?void 0:t?Jt(r,e):r,o=i.length-1,s;o>=0;o--)(s=i[o])&&(n=s(n)||n);return n},ie=(i,r)=>(e,t)=>r(e,t,i);function en(i,r,e){const t=e*Math.PI/180,n=Math.abs(i*Math.cos(t))+Math.abs(r*Math.sin(t)),o=Math.abs(i*Math.sin(t))+Math.abs(r*Math.cos(t));return{rotatedWidth:n,rotatedHeight:o}}function St(i,r,e,t,n){var I;const{rotatedHeight:o,rotatedWidth:s}=en(e,t,n),c=i.get(N.IRenderManagerService).getRenderById(r.unitId);if(!c)return!1;const u=(I=c.with(U.SheetSkeletonManagerService).getSkeletonParam(r.subUnitId))==null?void 0:I.skeleton;if(u==null)return!1;const d=u.getCellByIndex(r.row,r.col),m=d.mergeInfo.endX-d.mergeInfo.startX-2,h=d.mergeInfo.endY-d.mergeInfo.startY-2,p=s/o,f=Math.ceil(Math.min(m,h*p))/s,v=!f||Number.isNaN(f)?.001:f;return{width:e*v,height:t*v}}A.SheetDrawingUpdateController=class extends l.Disposable{constructor(e,t,n,o,s,a,c,g,u,d,m,h,p,S){super();se(this,"_workbookSelections");this._context=e,this._skeletonManagerService=t,this._commandService=n,this._selectionRenderService=o,this._imageIoService=s,this._fileOpenerService=a,this._sheetDrawingService=c,this._drawingManagerService=g,this._contextService=u,this._messageService=d,this._localeService=m,this._injector=p,this._urlImageService=S,this._workbookSelections=h.getWorkbookSelections(this._context.unitId),this._updateImageListener(),this._updateOrderListener(),this._groupDrawingListener(),this._focusDrawingListener()}async insertFloatImage(){const e=await this._fileOpenerService.openFile({multiple:!0,accept:B.DRAWING_IMAGE_ALLOW_IMAGE_LIST.map(n=>`.${n.replace("image/","")}`).join(",")}),t=e.length;return t>B.DRAWING_IMAGE_COUNT_LIMIT?(this._messageService.show({type:X.MessageType.Error,content:this._localeService.t("update-status.exceedMaxCount",String(B.DRAWING_IMAGE_COUNT_LIMIT))}),!1):t===0?!1:(e.forEach(async n=>await this.insertFloatImageByFile(n)),!0)}async insertCellImage(){const t=(await this._fileOpenerService.openFile({multiple:!1,accept:B.DRAWING_IMAGE_ALLOW_IMAGE_LIST.map(n=>`.${n.replace("image/","")}`).join(",")}))[0];return t?(await this._insertCellImage(t),!0):!1}insertCellImageByFile(e,t){return this._insertCellImage(e,t)}async insertFloatImageByFile(e){var O;let t;try{t=await this._imageIoService.saveImage(e)}catch(D){const C=D.message;C===B.ImageUploadStatusType.ERROR_EXCEED_SIZE?this._messageService.show({type:X.MessageType.Error,content:this._localeService.t("update-status.exceedMaxSize",String(B.DRAWING_IMAGE_ALLOW_SIZE/(1024*1024)))}):C===B.ImageUploadStatusType.ERROR_IMAGE_TYPE?this._messageService.show({type:X.MessageType.Error,content:this._localeService.t("update-status.invalidImageType")}):C===B.ImageUploadStatusType.ERROR_IMAGE&&this._messageService.show({type:X.MessageType.Error,content:this._localeService.t("update-status.invalidImage")})}if(t==null)return;const n=this._getUnitInfo(),{unitId:o,subUnitId:s}=n,{imageId:a,imageSourceType:c,source:g,base64Cache:u}=t,{width:d,height:m,image:h}=await B.getImageSize(u||""),{width:p,height:S}=this._context.scene;this._imageIoService.addImageSourceCache(g,c,h);let f=1;if(d>B.DRAWING_IMAGE_WIDTH_LIMIT||m>B.DRAWING_IMAGE_HEIGHT_LIMIT){const D=B.DRAWING_IMAGE_WIDTH_LIMIT/d,C=B.DRAWING_IMAGE_HEIGHT_LIMIT/m;f=Math.max(D,C)}const v=this._getImagePosition(d*f,m*f,p,S);if(v==null)return;const I=te(v,this._selectionRenderService,this._skeletonManagerService),T={unitId:o,subUnitId:s,drawingId:a,drawingType:l.DrawingTypeEnum.DRAWING_IMAGE,imageSourceType:c,source:g,transform:I,sheetTransform:v,axisAlignSheetTransform:(O=G(I,this._selectionRenderService))!=null?O:v};return this._commandService.executeCommand(Ne.id,{unitId:o,drawings:[T]})}async _insertCellImage(e,t){var O,D;let n;try{n=await this._imageIoService.saveImage(e)}catch(C){const M=C.message;M===B.ImageUploadStatusType.ERROR_EXCEED_SIZE?this._messageService.show({type:X.MessageType.Error,content:this._localeService.t("update-status.exceedMaxSize",String(B.DRAWING_IMAGE_ALLOW_SIZE/(1024*1024)))}):M===B.ImageUploadStatusType.ERROR_IMAGE_TYPE?this._messageService.show({type:X.MessageType.Error,content:this._localeService.t("update-status.invalidImageType")}):M===B.ImageUploadStatusType.ERROR_IMAGE&&this._messageService.show({type:X.MessageType.Error,content:this._localeService.t("update-status.invalidImage")})}if(n==null)return!1;const{imageId:o,imageSourceType:s,source:a,base64Cache:c}=n,{width:g,height:u,image:d}=await B.getImageSize(c||"");this._imageIoService.addImageSourceCache(a,s,d);const m=this._workbookSelections.getCurrentLastSelection();if(!m)return!1;let h=m.primary.actualRow,p=m.primary.actualColumn;m.primary.isMerged&&(h=m.primary.startRow,p=m.primary.startColumn);const S=l.createDocumentModelWithStyle("",{}),f=St(this._injector,{unitId:this._context.unitId,subUnitId:this._context.unit.getActiveSheet().getSheetId(),row:h,col:p},g,u,0);if(!f)return!1;const v={size:{width:f.width,height:f.height},positionH:{relativeFrom:l.ObjectRelativeFromH.PAGE,posOffset:0},positionV:{relativeFrom:l.ObjectRelativeFromV.PARAGRAPH,posOffset:0},angle:0},I={unitId:S.getUnitId(),subUnitId:S.getUnitId(),drawingId:o,drawingType:l.DrawingTypeEnum.DRAWING_IMAGE,imageSourceType:s,source:a,transform:Ge.docDrawingPositionToTransform(v),docTransform:v,behindDoc:l.BooleanNumber.FALSE,title:"",description:"",layoutType:l.PositionedObjectLayoutType.INLINE,wrapText:l.WrapTextType.BOTH_SIDES,distB:0,distL:0,distR:0,distT:0},T=l.BuildTextUtils.drawing.add({documentDataModel:S,drawings:[I],selection:{collapsed:!0,startOffset:0,endOffset:0}});return T?(S.apply(T),this._commandService.syncExecuteCommand(y.SetRangeValuesCommand.id,{value:{[(O=t==null?void 0:t.row)!=null?O:h]:{[(D=t==null?void 0:t.col)!=null?D:p]:{p:S.getSnapshot(),t:1}}},unitId:t==null?void 0:t.unitId,subUnitId:t==null?void 0:t.subUnitId})):!1}async insertCellImageByUrl(e,t){var p,S;let n=e;try{n=await this._urlImageService.getImage(e)}catch(f){console.error(`Failed to get image from URLImageService: ${e}`,f)}const{width:o,height:s,image:a}=await B.getImageSize(n||"");this._imageIoService.addImageSourceCache(e,l.ImageSourceType.URL,a);const c=this._workbookSelections.getCurrentLastSelection();if(!c)return!1;const g=l.createDocumentModelWithStyle("",{}),u=St(this._injector,{unitId:this._context.unitId,subUnitId:this._context.unit.getActiveSheet().getSheetId(),row:c.primary.actualRow,col:c.primary.actualColumn},o,s,0);if(!u)return!1;const d={size:{width:u.width,height:u.height},positionH:{relativeFrom:l.ObjectRelativeFromH.PAGE,posOffset:0},positionV:{relativeFrom:l.ObjectRelativeFromV.PARAGRAPH,posOffset:0},angle:0},m={unitId:g.getUnitId(),subUnitId:g.getUnitId(),drawingId:l.generateRandomId(),drawingType:l.DrawingTypeEnum.DRAWING_IMAGE,imageSourceType:l.ImageSourceType.URL,source:e,transform:Ge.docDrawingPositionToTransform(d),docTransform:d,behindDoc:l.BooleanNumber.FALSE,title:"",description:"",layoutType:l.PositionedObjectLayoutType.INLINE,wrapText:l.WrapTextType.BOTH_SIDES,distB:0,distL:0,distR:0,distT:0},h=l.BuildTextUtils.drawing.add({documentDataModel:g,drawings:[m],selection:{collapsed:!0,startOffset:0,endOffset:0}});return h?(g.apply(h),this._commandService.syncExecuteCommand(y.SetRangeValuesCommand.id,{value:{[(p=t==null?void 0:t.row)!=null?p:c.primary.actualRow]:{[(S=t==null?void 0:t.col)!=null?S:c.primary.actualColumn]:{p:g.getSnapshot(),t:1}}},unitId:t==null?void 0:t.unitId,subUnitId:t==null?void 0:t.subUnitId})):!1}_getUnitInfo(){const e=this._context.unit,t=e.getActiveSheet(),n=e.getUnitId(),o=t.getSheetId();return{unitId:n,subUnitId:o}}_getImagePosition(e,t,n,o){const s=this._workbookSelections.getCurrentSelections();let a={startRow:0,endRow:0,startColumn:0,endColumn:0};s&&s.length>0&&(a=s[s.length-1].range);const c=U.attachRangeWithCoord(this._skeletonManagerService.getCurrent().skeleton,a);if(c==null)return;let{startColumn:g,startRow:u,startX:d,startY:m}=c,h=!1;if(d+e>n&&(d=n-e,d<0&&(d=0,e=n),h=!0),m+t>o&&(m=o-t,m<0&&(m=0,t=o),h=!0),h){const v=this._selectionRenderService.getCellWithCoordByOffset(d,m);if(v==null)return;d=v.startX,m=v.startY,g=v.actualColumn,u=v.actualRow}const p={column:g,columnOffset:0,row:u,rowOffset:0},S=this._selectionRenderService.getCellWithCoordByOffset(d+e,m+t);if(S==null)return;const f={column:S.actualColumn,columnOffset:d+e-S.startX,row:S.actualRow,rowOffset:m+t-S.startY};return{from:p,to:f}}_updateOrderListener(){this.disposeWithMe(this._drawingManagerService.featurePluginOrderUpdate$.subscribe(e=>{const{unitId:t,subUnitId:n,drawingIds:o,arrangeType:s}=e;this._commandService.executeCommand(mt.id,{unitId:t,subUnitId:n,drawingIds:o,arrangeType:s})}))}_updateImageListener(){this.disposeWithMe(this._drawingManagerService.featurePluginUpdate$.subscribe(e=>{const t=[];e.length!==0&&(e.forEach(n=>{const{unitId:o,subUnitId:s,drawingId:a,drawingType:c,transform:g}=n;if(g==null)return;const u=this._sheetDrawingService.getDrawingByParam({unitId:o,subUnitId:s,drawingId:a});if(u==null||u.unitId!==this._context.unitId)return;const d=x({...u.transform,...g},this._selectionRenderService),m=G({...u.transform,...g},this._selectionRenderService);if(d==null||m==null)return;const h={...n,transform:{...u.transform,...g,...te(d,this._selectionRenderService,this._skeletonManagerService)},sheetTransform:{...d},axisAlignSheetTransform:{...m}};t.push(h)}),t.length>0&&this._commandService.executeCommand(De.id,{unitId:e[0].unitId,drawings:t}))}))}_getSheetTransformByParam(e){const{unitId:t,subUnitId:n,drawingId:o,transform:s}=e;if(s==null)return null;const a=this._sheetDrawingService.getDrawingByParam({unitId:t,subUnitId:n,drawingId:o});if(a==null||a.unitId!==this._context.unitId)return null;const c=x({...a.transform,...s},this._selectionRenderService),g=G({...a.transform,...s},this._selectionRenderService);return c==null||g==null?null:{sheetTransform:c,axisAlignSheetTransform:g}}_groupDrawingListener(){this.disposeWithMe(this._drawingManagerService.featurePluginGroupUpdate$.subscribe(e=>{const t=[];for(const n of e){const o=this._getSheetTransformByParam(n.parent),s=[];for(const c of n.children){const g=this._getSheetTransformByParam(c);g!=null&&s.push({...c,sheetTransform:g.sheetTransform,axisAlignSheetTransform:g.axisAlignSheetTransform})}const a={parent:{...n.parent,sheetTransform:o},children:s};t.push(a)}if(t.length>0){this._commandService.executeCommand(ht.id,t);const{unitId:n,subUnitId:o,drawingId:s}=e[0].parent;this._commandService.syncExecuteCommand(B.SetDrawingSelectedOperation.id,[{unitId:n,subUnitId:o,drawingId:s}])}})),this.disposeWithMe(this._drawingManagerService.featurePluginUngroupUpdate$.subscribe(e=>{const t=[];for(const n of e){const{children:o}=n,s=[];for(const a of o){const c=this._getSheetTransformByParam(a);c!=null&&s.push({...a,sheetTransform:c})}t.push({...n,children:s})}this._commandService.executeCommand(pt.id,t)}))}_focusDrawingListener(){this.disposeWithMe(this._drawingManagerService.focus$.subscribe(e=>{e==null||e.length===0?(this._contextService.setContextValue(l.FOCUSING_COMMON_DRAWINGS,!1),this._sheetDrawingService.focusDrawing([])):(this._contextService.setContextValue(l.FOCUSING_COMMON_DRAWINGS,!0),this._sheetDrawingService.focusDrawing(e))}))}},A.SheetDrawingUpdateController=Qt([ie(1,l.Inject(U.SheetSkeletonManagerService)),ie(2,l.ICommandService),ie(3,U.ISheetSelectionRenderService),ie(4,B.IImageIoService),ie(5,j.ILocalFileService),ie(6,w.ISheetDrawingService),ie(7,B.IDrawingManagerService),ie(8,l.IContextService),ie(9,j.IMessageService),ie(10,l.Inject(l.LocaleService)),ie(11,l.Inject(y.SheetsSelectionsService)),ie(12,l.Inject(l.Injector)),ie(13,l.IURLImageService)],A.SheetDrawingUpdateController);const ke={id:"sheet.command.insert-float-image",type:l.CommandType.COMMAND,handler:async(i,r)=>{var s,a;const e=i.get(l.IUniverInstanceService),t=i.get(N.IRenderManagerService),n=(s=N.getCurrentTypeOfRenderer(l.UniverInstanceType.UNIVER_SHEET,e,t))==null?void 0:s.with(A.SheetDrawingUpdateController);if(!n)return!1;const o=r==null?void 0:r.files;if(o){const c=o.map(g=>n.insertFloatImageByFile(g));return(await Promise.all(c)).every(g=>g)}else return(a=n.insertFloatImage())!=null?a:!1}},ft={id:"sheet.command.insert-cell-image",type:l.CommandType.COMMAND,handler:i=>{var t,n;const r=i.get(l.IUniverInstanceService),e=i.get(N.IRenderManagerService);return(n=(t=N.getCurrentTypeOfRenderer(l.UniverInstanceType.UNIVER_SHEET,r,e))==null?void 0:t.with(A.SheetDrawingUpdateController).insertCellImage())!=null?n:!1}},Te={id:"sheet.command.move-drawing",type:l.CommandType.COMMAND,handler:(i,r)=>{const e=i.get(l.ICommandService),t=i.get(w.ISheetDrawingService),n=i.get(U.ISheetSelectionRenderService),{direction:o}=r,s=t.getFocusDrawings();if(s.length===0)return!1;const a=s[0].unitId,c=s.map(u=>{const{transform:d}=u;if(d==null)return null;const m={...d},{left:h=0,top:p=0}=d;return o===l.Direction.UP?m.top=p-1:o===l.Direction.DOWN?m.top=p+1:o===l.Direction.LEFT?m.left=h-1:o===l.Direction.RIGHT&&(m.left=h+1),{...u,transform:m,sheetTransform:x(m,n),axisAlignSheetTransform:G(m,n)}}).filter(u=>u!=null);return e.syncExecuteCommand(De.id,{unitId:a,drawings:c})?(e.syncExecuteCommand(K.id,[a]),!0):!1}};var tn=Object.getOwnPropertyDescriptor,nn=(i,r,e,t)=>{for(var n=t>1?void 0:t?tn(r,e):r,o=i.length-1,s;o>=0;o--)(s=i[o])&&(n=s(n)||n);return n},He=(i,r)=>(e,t)=>r(e,t,i),fe=(i=>(i.CELL_ADDRESS="cellAddress",i.COLUMN_VALUE="columnValue",i))(fe||{});const Ve=l.createIdentifier("sheets-drawing-ui.batch-save-images.service");function wt(i){let r="",e=i;for(;e>=0;)r=String.fromCharCode(e%26+65)+r,e=Math.floor(e/26)-1;return r}function Xe(i,r){return`${wt(r)}${i+1}`}function rn(i){const r=Xe(i.startRow,i.startColumn),e=Xe(i.endRow,i.endColumn);return r===e?r:`${r}:${e}`}function Ut(i){var r,e,t,n;return!!((e=(r=i==null?void 0:i.p)==null?void 0:r.drawingsOrder)!=null&&e.length&&((n=(t=i==null?void 0:i.p)==null?void 0:t.drawingsOrder)==null?void 0:n.length)>0)}function Pt(i){var t,n,o;if(!((n=(t=i.p)==null?void 0:t.drawingsOrder)!=null&&n.length)||!((o=i.p)!=null&&o.drawings))return null;const r=i.p.drawingsOrder[0],e=i.p.drawings[r];return!e||!("source"in e)||!("imageSourceType"in e)?null:e}function vt(i,r){if(r===l.ImageSourceType.BASE64){const e=i.match(/^data:image\/(\w+);/);if(e)return e[1]==="jpeg"?"jpg":e[1]}if(r===l.ImageSourceType.URL){const e=i.match(/\.(\w+)(?:\?|$)/);if(e)return e[1].toLowerCase()}return"png"}async function Nt(i,r){if(r===l.ImageSourceType.BASE64)return(await fetch(i)).blob();if(r===l.ImageSourceType.URL)return(await fetch(i)).blob();throw new Error("UUID image type requires additional handling")}A.BatchSaveImagesService=class extends l.Disposable{constructor(r,e,t,n){super(),this._univerInstanceService=r,this._selectionService=e,this._imageIoService=t,this._urlImageService=n}registerURLImageDownloader(r){return this._urlImageService.registerURLImageDownloader(r)}getCellImagesInSelection(){const r=this._univerInstanceService.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET);if(!r)return[];const e=r.getActiveSheet();if(!e)return[];const t=this._selectionService.getCurrentSelections();if(!t||t.length===0)return[];const n=e.getCellMatrix(),o=[];for(const s of t){const{startRow:a,endRow:c,startColumn:g,endColumn:u}=s.range;for(let d=a;d<=c;d++)for(let m=g;m<=u;m++){const h=n.getValue(d,m);if(Ut(h)){const p=Pt(h);p&&o.push({row:d,col:m,cellAddress:Xe(d,m),source:p.source,imageSourceType:p.imageSourceType,imageId:p.drawingId})}}}return o}getCellImagesFromRanges(r,e,t){const n=this._univerInstanceService.getUnit(r,l.UniverInstanceType.UNIVER_SHEET);if(!n)return[];const o=n.getSheetBySheetId(e);if(!o)return[];const s=o.getCellMatrix(),a=[];for(const c of t){const{startRow:g,endRow:u,startColumn:d,endColumn:m}=c;for(let h=g;h<=u;h++)for(let p=d;p<=m;p++){const S=s.getValue(h,p);if(Ut(S)){const f=Pt(S);f&&a.push({row:h,col:p,cellAddress:Xe(h,p),source:f.source,imageSourceType:f.imageSourceType,imageId:f.drawingId})}}}return a}getDataColumns(){var m,h,p,S;const r=this._univerInstanceService.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET);if(!r)return[];const e=r.getActiveSheet();if(!e)return[];const t=this._selectionService.getCurrentSelections();if(!t||t.length===0)return[];const n=e.getCellMatrix(),o=n.getDataRange();let s=1/0,a=-1/0;const c=new Set;for(const f of t){s=Math.min(s,f.range.startRow),a=Math.max(a,f.range.endRow);for(let v=f.range.startColumn;v<=f.range.endColumn;v++)c.add(v)}const g=new Set;for(let f=o.startColumn;f<=o.endColumn;f++)if(!c.has(f))for(let v=s;v<=a;v++){const I=n.getValue(v,f);if(I&&(((m=I.v)==null?void 0:m.toString())||((S=(p=(h=I.p)==null?void 0:h.body)==null?void 0:p.dataStream)==null?void 0:S.trim())||"")){g.add(f);break}}const u=[],d=Array.from(g).sort((f,v)=>f-v);for(const f of d)u.push({index:f,label:wt(f)});return u}getDataColumnsForRanges(r,e,t){var p,S,f,v;const n=this._univerInstanceService.getUnit(r,l.UniverInstanceType.UNIVER_SHEET);if(!n)return[];const o=n.getSheetBySheetId(e);if(!o)return[];const s=o.getCellMatrix(),a=s.getDataRange();let c=1/0,g=-1/0;const u=new Set;for(const I of t){c=Math.min(c,I.startRow),g=Math.max(g,I.endRow);for(let T=I.startColumn;T<=I.endColumn;T++)u.add(T)}const d=new Set;for(let I=a.startColumn;I<=a.endColumn;I++)if(!u.has(I))for(let T=c;T<=g;T++){const O=s.getValue(T,I);if(O&&(((p=O.v)==null?void 0:p.toString())||((v=(f=(S=O.p)==null?void 0:S.body)==null?void 0:f.dataStream)==null?void 0:v.trim())||"")){d.add(I);break}}const m=[],h=Array.from(d).sort((I,T)=>I-T);for(const I of h)m.push({index:I,label:wt(I)});return m}getSelectionRangeNotation(){const r=this._selectionService.getCurrentSelections();return!r||r.length===0?"":r.map(e=>rn(e.range)).join(", ")}getSelectionRowRange(){const r=this._selectionService.getCurrentSelections();if(!r||r.length===0)return null;let e=1/0,t=-1/0;for(const n of r)e=Math.min(e,n.range.startRow),t=Math.max(t,n.range.endRow);return{startRow:e,endRow:t}}getSelectionColumnIndices(){const r=this._selectionService.getCurrentSelections();if(!r||r.length===0)return new Set;const e=new Set;for(const t of r)for(let n=t.range.startColumn;n<=t.range.endColumn;n++)e.add(n);return e}generateFileName(r,e){var s,a,c,g;const t=this._univerInstanceService.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET),n=vt(r.source,r.imageSourceType),o=[];for(const u of e.fileNameParts)if(u==="cellAddress")o.push(r.cellAddress);else if(u==="columnValue"&&e.columnIndex!==void 0){const d=t==null?void 0:t.getActiveSheet();if(d){const h=d.getCellMatrix().getValue(r.row,e.columnIndex);if(h){const p=((s=h.v)==null?void 0:s.toString())||((g=(c=(a=h.p)==null?void 0:a.body)==null?void 0:c.dataStream)==null?void 0:g.trim())||"";if(p){const S=p.replace(/[<>:"/\\|?*]/g,"_").trim();S&&o.push(S)}}}}return o.length===0?`${r.cellAddress}.${n}`:`${o.join("_")}.${n}`}generateFileNameWithContext(r,e,t,n){var c,g,u,d;const o=this._univerInstanceService.getUnit(t,l.UniverInstanceType.UNIVER_SHEET),s=vt(r.source,r.imageSourceType),a=[];for(const m of e.fileNameParts)if(m==="cellAddress")a.push(r.cellAddress);else if(m==="columnValue"&&e.columnIndex!==void 0){const h=o==null?void 0:o.getSheetBySheetId(n);if(h){const S=h.getCellMatrix().getValue(r.row,e.columnIndex);if(S){const f=((c=S.v)==null?void 0:c.toString())||((d=(u=(g=S.p)==null?void 0:g.body)==null?void 0:u.dataStream)==null?void 0:d.trim())||"";if(f){const v=f.replace(/[<>:"/\\|?*]/g,"_").trim();v&&a.push(v)}}}}return a.length===0?`${r.cellAddress}.${s}`:`${a.join("_")}.${s}`}async saveImages(r,e){var o;const t=await window.showDirectoryPicker({mode:"readwrite"}),n=new Map;for(const s of r){let a=this.generateFileName(s,e);const c=a.replace(/\.\w+$/,""),g=((o=a.match(/\.\w+$/))==null?void 0:o[0])||".png",u=n.get(c)||0;u>0&&(a=`${c}_${u}${g}`),n.set(c,u+1);try{const d=await this._getImageBlob(s),h=await(await t.getFileHandle(a,{create:!0})).createWritable();await h.write(d),await h.close()}catch(d){throw console.error(`Failed to save image ${a}:`,d),d}}}async saveImagesWithContext(r,e,t,n){var a;const o=await window.showDirectoryPicker({mode:"readwrite"}),s=new Map;for(const c of r){let g=this.generateFileNameWithContext(c,e,t,n);const u=g.replace(/\.\w+$/,""),d=((a=g.match(/\.\w+$/))==null?void 0:a[0])||".png",m=s.get(u)||0;m>0&&(g=`${u}_${m}${d}`),s.set(u,m+1);try{const h=await this._getImageBlob(c),S=await(await o.getFileHandle(g,{create:!0})).createWritable();await S.write(h),await S.close()}catch(h){throw console.error(`Failed to save image ${g}:`,h),h}}}async downloadSingleImage(r){const e=vt(r.source,r.imageSourceType),t=`${r.cellAddress}.${e}`;try{const n=await this._getImageBlob(r),o=URL.createObjectURL(n),s=document.createElement("a");s.href=o,s.download=t,document.body.appendChild(s),s.click(),document.body.removeChild(s),URL.revokeObjectURL(o)}catch(n){throw console.error(`Failed to download image ${t}:`,n),n}}async _getImageBlob(r){if(r.imageSourceType===l.ImageSourceType.UUID){const e=await this._imageIoService.getImage(r.source);return Nt(e,l.ImageSourceType.URL)}return r.imageSourceType===l.ImageSourceType.URL?this._urlImageService.downloadImage(r.source):Nt(r.source,r.imageSourceType)}},A.BatchSaveImagesService=nn([He(0,l.IUniverInstanceService),He(1,l.Inject(y.SheetsSelectionsService)),He(2,l.IImageIoService),He(3,l.IURLImageService)],A.BatchSaveImagesService);const Me="sheet.dialog.batch-save-images",Re={id:"sheet.command.save-cell-images",type:l.CommandType.COMMAND,handler:async i=>{const r=i.get(j.IDialogService),e=i.get(Ve),t=e.getCellImagesInSelection();if(t.length===1)try{return await e.downloadSingleImage(t[0]),!0}catch(a){return console.error("Failed to download image:",a),!1}const n=i.get(l.LocaleService),o=e.getSelectionRangeNotation(),s=`${n.t("sheetImage.save.title")} (${o})`;return r.open({id:Me,draggable:!0,width:360,title:{title:s},children:{label:Me},destroyOnClose:!0,preservePositionOnDestroy:!0,onClose:()=>r.close(Me)}),!0}},kt="COMPONENT_SHEET_DRAWING_PANEL",_t={id:"sidebar.operation.sheet-image",type:l.CommandType.COMMAND,handler:async(i,r)=>{const e=i.get(j.ISidebarService),t=i.get(l.LocaleService),n=i.get(l.IUniverInstanceService),o=i.get(l.ICommandService);return y.getSheetCommandTarget(n)?(r.value==="open"?e.open({header:{title:t.t("sheetImage.panel.title")},children:{label:kt},onClose:()=>{o.syncExecuteCommand(B.SetDrawingSelectedOperation.id,[])},width:360}):e.close(),!0):!1}},It={id:"sheet.operation.edit-sheet-image",type:l.CommandType.OPERATION,handler:(i,r)=>{const e=i.get(l.ICommandService);return r==null?!1:(e.syncExecuteCommand(B.SetDrawingSelectedOperation.id,[r]),e.executeCommand(_t.id,{value:"open"}),!0)}},on="sheets-drawing-ui.config",Wt={},yt={id:"sheet.command.toggle-flip-drawings",type:l.CommandType.COMMAND,handler:(i,r)=>{const e=i.get(l.ICommandService),t=i.get(l.IUndoRedoService),n=i.get(w.ISheetDrawingService),o=i.get(N.IRenderManagerService);if(!r)return!1;const{drawings:s}=r,a=r.flipH,c=r.flipV,g=[],u=[];for(const O of s){const{unitId:D,subUnitId:C,drawingId:M}=O;g.push(D);const R=n.getDrawingData(D,C),k=R==null?void 0:R[M];if(!k)continue;const E={...k.transform};a&&(E.flipX=!E.flipX),c&&(E.flipY=!E.flipY);const P=o.getRenderById(D),_=P==null?void 0:P.with(U.ISheetSelectionRenderService);if(!_)continue;const b=x(E,_),F=G(E,_),L={unitId:D,subUnitId:C,drawingType:k.drawingType,drawingId:M,transform:E,sheetTransform:b,axisAlignSheetTransform:F};if(k.drawingType===l.DrawingTypeEnum.DRAWING_IMAGE){const ne=sn(i,D);if(ne){const z=B.getDrawingShapeKeyByDrawingSearch({unitId:D,subUnitId:C,drawingId:M}),q=ne.getObject(z);if(q){const re=q.srcRect;if(re){let V;const{left:J=0,top:$=0,right:ae=0,bottom:ue=0}=re;if(a){const le=J+(ae-J)/2,ve=le-(ae-J)/2,_e=le+(ae-J)/2;V={left:ve,top:$,right:_e,bottom:ue}}if(c){const le=$+(ue-$)/2,ve=le-(ue-$)/2,_e=le+(ue-$)/2;V={left:J,top:ve,right:ae,bottom:_e}}V&&(L.srcRect=V)}}}}u.push(L)}if(u.length===0)return!1;const d=n.getBatchUpdateOp(u),{unitId:m,subUnitId:h,undo:p,redo:S,objects:f}=d,v={id:w.SetDrawingApplyMutation.id,params:{unitId:m,subUnitId:h,op:S,objects:f,type:w.DrawingApplyType.UPDATE}},I={id:w.SetDrawingApplyMutation.id,params:{unitId:m,subUnitId:h,op:p,objects:f,type:w.DrawingApplyType.UPDATE}};return l.sequenceExecute([v],e)?(t.pushUndoRedo({unitID:m,undoMutations:[I,{id:K.id,params:g}],redoMutations:[v,{id:K.id,params:g}]}),!0):!1}};function sn(i,r){const t=i.get(N.IRenderManagerService).getRenderById(r);return t?t.scene:null}var an=Object.getOwnPropertyDescriptor,cn=(i,r,e,t)=>{for(var n=t>1?void 0:t?an(r,e):r,o=i.length-1,s;o>=0;o--)(s=i[o])&&(n=s(n)||n);return n},ce=(i,r)=>(e,t)=>r(e,t,i);let Ke=class extends l.RxDisposable{constructor(r,e,t,n,o,s,a,c,g,u){super();se(this,"_initImagePopupMenu",new Set);this._injector=r,this._localeService=e,this._drawingManagerService=t,this._canvasPopManagerService=n,this._renderManagerService=o,this._univerInstanceService=s,this._messageService=a,this._contextService=c,this._ioService=g,this._commandService=u,this._init()}_init(){this._univerInstanceService.getCurrentTypeOfUnit$(l.UniverInstanceType.UNIVER_SHEET).subscribe(r=>this._create(r)),this._univerInstanceService.getTypeOfUnitDisposed$(l.UniverInstanceType.UNIVER_SHEET).subscribe(r=>this._dispose(r)),this._univerInstanceService.getAllUnitsForType(l.UniverInstanceType.UNIVER_SHEET).forEach(r=>this._create(r)),this._setupLoadingStatus()}_setupLoadingStatus(){const r="image-upload-loading";let e;this.disposeWithMe(this._ioService.change$.subscribe(t=>{t>0&&!e?e=this._messageService.show({id:r,type:X.MessageType.Loading,content:`${this._localeService.t("uploadLoading.loading")}: ${t}`,duration:0}):t===0&&(e==null||e.dispose(),e=void 0)}))}_dispose(r){super.dispose();const e=r.getUnitId();this._renderManagerService.removeRender(e),this._initImagePopupMenu.delete(e)}_create(r){if(!r)return;const e=r.getUnitId();this._renderManagerService.has(e)&&!this._initImagePopupMenu.has(e)&&(this._popupMenuListener(e),this._initImagePopupMenu.add(e))}_hasCropObject(r){const e=r.getAllObjectsByOrder();for(const t of e)if(t instanceof Se.ImageCropperObject)return!0;return!1}_popupMenuListener(r){var o;const e=(o=this._renderManagerService.getRenderById(r))==null?void 0:o.scene;if(!e)return;const t=e.getTransformerByCreate();if(!t)return;let n;this.disposeWithMe(t.createControl$.subscribe(()=>{if(this._contextService.setContextValue(l.FOCUSING_COMMON_DRAWINGS,!0),this._hasCropObject(e))return;const s=t.getSelectedObjectMap();if(s.size>1){n==null||n.dispose();return}const a=s.values().next().value;if(!a)return;const c=a.oKey,g=this._drawingManagerService.getDrawingOKey(c);if(!g)return;const{unitId:u,subUnitId:d,drawingId:m,drawingType:h}=g,p=g.data;if(p&&p.disablePopup)return;n==null||n.dispose();const S=this._canvasPopManagerService.getFeatureMenu(u,d,m,h);n=this.disposeWithMe(this._canvasPopManagerService.attachPopupToObject(a,{componentKey:Se.COMPONENT_IMAGE_POPUP_MENU,direction:"horizontal",offset:[2,0],extraProps:{menuItems:S||this._getImageMenuItems(u,d,m,h)}}))})),this.disposeWithMe(t.clearControl$.subscribe(()=>{n==null||n.dispose(),this._contextService.setContextValue(l.FOCUSING_COMMON_DRAWINGS,!1),this._commandService.syncExecuteCommand(B.SetDrawingSelectedOperation.id,[])})),this.disposeWithMe(this._contextService.contextChanged$.subscribe(s=>{s[l.FOCUSING_COMMON_DRAWINGS]===!1&&(n==null||n.dispose())})),this.disposeWithMe(t.changing$.subscribe(()=>{n==null||n.dispose()}))}_getImageMenuItems(r,e,t,n){return[{label:"image-popup.edit",index:0,commandId:It.id,commandParams:{unitId:r,subUnitId:e,drawingId:t},disable:n===l.DrawingTypeEnum.DRAWING_DOM},{label:"image-popup.delete",index:1,commandId:Ce.id,commandParams:{unitId:r,drawings:[{unitId:r,subUnitId:e,drawingId:t}]},disable:!1},{label:"image-popup.crop",index:2,commandId:Se.OpenImageCropOperation.id,commandParams:{unitId:r,subUnitId:e,drawingId:t},disable:n===l.DrawingTypeEnum.DRAWING_DOM},{label:"image-popup.flipH",index:2,commandId:yt.id,commandParams:{unitId:r,flipH:!0,drawings:[{unitId:r,subUnitId:e,drawingId:t}]},disable:n===l.DrawingTypeEnum.DRAWING_DOM},{label:"image-popup.flipV",index:2,commandId:yt.id,commandParams:{unitId:r,flipV:!0,drawings:[{unitId:r,subUnitId:e,drawingId:t}]},disable:n===l.DrawingTypeEnum.DRAWING_DOM},{label:"image-popup.reset",index:3,commandId:Se.ImageResetSizeOperation.id,commandParams:[{unitId:r,subUnitId:e,drawingId:t}],disable:n===l.DrawingTypeEnum.DRAWING_DOM}]}};Ke=cn([ce(0,l.Inject(l.Injector)),ce(1,l.Inject(l.LocaleService)),ce(2,B.IDrawingManagerService),ce(3,l.Inject(U.SheetCanvasPopManagerService)),ce(4,N.IRenderManagerService),ce(5,l.IUniverInstanceService),ce(6,j.IMessageService),ce(7,l.IContextService),ce(8,l.IImageIoService),ce(9,l.ICommandService)],Ke);var dn=Object.getOwnPropertyDescriptor,ln=(i,r,e,t)=>{for(var n=t>1?void 0:t?dn(r,e):r,o=i.length-1,s;o>=0;o--)(s=i[o])&&(n=s(n)||n);return n},ze=(i,r)=>(e,t)=>r(e,t,i);let Ct=class extends l.Disposable{constructor(r,e,t,n,o){super();se(this,"_isSetCursor",!1);this._context=r,this._hoverManagerService=e,this._selectionsService=t,this._drawingRenderService=n,this._sheetSkeletonManagerService=o,this._initHover(),this._initImageClick()}_initHover(){this.disposeWithMe(this._hoverManagerService.currentRichTextNoDistinct$.pipe(W.throttleTime(33)).subscribe(r=>{var t,n;let e=[];r!==null&&(e=this._selectionsService.getWorkbookSelections(this._context.unitId).getCurrentSelections()),e.length>0&&(r==null?void 0:r.unitId)===this._context.unitId&&(r!=null&&r.drawing)&&e.length===1&&((t=e[0].primary)==null?void 0:t.actualRow)===r.row&&((n=e[0].primary)==null?void 0:n.actualColumn)===r.col?(this._isSetCursor=!0,this._context.scene.setCursor(N.CURSOR_TYPE.ZOOM_IN)):this._isSetCursor&&(this._isSetCursor=!1,this._context.scene.resetCursor())}))}_initImageClick(){this.disposeWithMe(this._hoverManagerService.currentClickedCell$.subscribe(r=>{var e;if(r!=null&&r.drawing&&this._isSetCursor){const t=r.drawing.drawing.drawingOrigin,n=(e=this._sheetSkeletonManagerService.getCurrentSkeleton())==null?void 0:e.imageCacheMap.getImage(t.imageSourceType,t.source);if(!n)return;this._drawingRenderService.previewImage("preview-cell-image",n.src,n.width,n.height),this._context.scene.resetCursor(),this._isSetCursor=!1}}))}};Ct=ln([ze(1,l.Inject(U.HoverManagerService)),ze(2,l.Inject(y.SheetsSelectionsService)),ze(3,l.Inject(Se.DrawingRenderService)),ze(4,l.Inject(U.SheetSkeletonManagerService))],Ct);var un=Object.getOwnPropertyDescriptor,gn=(i,r,e,t)=>{for(var n=t>1?void 0:t?un(r,e):r,o=i.length-1,s;o>=0;o--)(s=i[o])&&(n=s(n)||n);return n},qe=(i,r)=>(e,t)=>r(e,t,i);let Dt=class extends l.Disposable{constructor(i,r,e,t,n){super(),this._context=i,this._sheetDrawingService=r,this._drawingManagerService=e,this._sheetSelectionRenderService=t,this._sheetSkeletonManagerService=n,this._init()}_init(){this._drawingInitializeListener()}_drawingInitializeListener(){this._sheetDrawingService.initializeNotification(this._context.unitId);const i=this._sheetDrawingService.getDrawingDataForUnit(this._context.unitId);for(const r in i){const e=i[r];for(const t in e.data){const n=e.data[t];n.sheetTransform&&(n.transform=te(n.sheetTransform,this._sheetSelectionRenderService,this._sheetSkeletonManagerService))}}this._drawingManagerService.registerDrawingData(this._context.unitId,this._sheetDrawingService.getDrawingDataForUnit(this._context.unitId)),this._drawingManagerService.initializeNotification(this._context.unitId)}};Dt=gn([qe(1,w.ISheetDrawingService),qe(2,B.IDrawingManagerService),qe(3,l.Inject(U.ISheetSelectionRenderService)),qe(4,l.Inject(U.SheetSkeletonManagerService))],Dt);var hn=Object.getOwnPropertyDescriptor,mn=(i,r,e,t)=>{for(var n=t>1?void 0:t?hn(r,e):r,o=i.length-1,s;o>=0;o--)(s=i[o])&&(n=s(n)||n);return n},Ee=(i,r)=>(e,t)=>r(e,t,i);function Bt(i,r,e){var t,n,o,s;if(((n=(t=e==null?void 0:e.p)==null?void 0:t.body)==null?void 0:n.dataStream.length)===3&&((s=(o=e.p)==null?void 0:o.drawingsOrder)==null?void 0:s.length)===1){const a=e.p.drawings[e.p.drawingsOrder[0]],c=St(i,{unitId:r.unitId,subUnitId:r.subUnitId,row:r.row,col:r.col},a.docTransform.size.width,a.docTransform.size.height,a.docTransform.angle);if(c)return a.transform.width=c.width,a.transform.height=c.height,a.docTransform.size.width=c.width,a.docTransform.size.height=c.height,a.transform.left=0,a.transform.top=0,a.docTransform.positionH.posOffset=0,a.docTransform.positionV.posOffset=0,e.p.documentStyle.pageSize.width=1/0,e.p.documentStyle.pageSize.height=1/0,!0}return!1}let Ze=class extends l.Disposable{constructor(i,r,e,t,n,o){super(),this._commandService=i,this._sheetInterceptorService=r,this._injector=e,this._drawingManagerService=t,this._docDrawingController=n,this._editorBridgeService=o,this._handleInitEditor(),this._initCellContentInterceptor()}_handleInitEditor(){this.disposeWithMe(this._editorBridgeService.visible$.subscribe(i=>{i.visible?i.visible&&(this._drawingManagerService.removeDrawingDataForUnit(l.DOCS_NORMAL_EDITOR_UNIT_ID_KEY),this._docDrawingController.loadDrawingDataForUnit(l.DOCS_NORMAL_EDITOR_UNIT_ID_KEY),this._drawingManagerService.initializeNotification(l.DOCS_NORMAL_EDITOR_UNIT_ID_KEY)):this._drawingManagerService.removeDrawingDataForUnit(l.DOCS_NORMAL_EDITOR_UNIT_ID_KEY)})),this.disposeWithMe(this._commandService.onCommandExecuted(i=>{i.id===Ge.ReplaceSnapshotCommand.id&&i.params.unitId===l.DOCS_ZEN_EDITOR_UNIT_ID_KEY&&(this._drawingManagerService.removeDrawingDataForUnit(l.DOCS_ZEN_EDITOR_UNIT_ID_KEY),this._docDrawingController.loadDrawingDataForUnit(l.DOCS_ZEN_EDITOR_UNIT_ID_KEY),this._drawingManagerService.initializeNotification(l.DOCS_ZEN_EDITOR_UNIT_ID_KEY))}))}_initCellContentInterceptor(){this.disposeWithMe(this._sheetInterceptorService.intercept(y.INTERCEPTOR_POINT.CELL_CONTENT,{effect:l.InterceptorEffectEnum.Style,priority:y.InterceptCellContentPriority.CELL_IMAGE,handler:(i,r,e)=>{var t;return i!=null&&i.p&&((t=i.p.drawingsOrder)!=null&&t.length)&&(i===r.rawData&&(i={...r.rawData}),i.interceptorStyle||(i.interceptorStyle={}),i.interceptorStyle.tr={a:0},Bt(this._injector,{unitId:r.unitId,subUnitId:r.subUnitId,row:r.row,col:r.col},i)),e(i)}}))}};Ze=mn([Ee(0,l.ICommandService),Ee(1,l.Inject(y.SheetInterceptorService)),Ee(2,l.Inject(l.Injector)),Ee(3,B.IDrawingManagerService),Ee(4,l.Inject(At.DocDrawingController)),Ee(5,l.Inject(U.IEditorBridgeService))],Ze);var pn=Object.getOwnPropertyDescriptor,Sn=(i,r,e,t)=>{for(var n=t>1?void 0:t?pn(r,e):r,o=i.length-1,s;o>=0;o--)(s=i[o])&&(n=s(n)||n);return n},jt=(i,r)=>(e,t)=>r(e,t,i);let Je=class extends l.Disposable{constructor(i,r){super(),this._autoFillService=i,this._injector=r,this._initAutoFillHooks()}_initAutoFillHooks(){this.disposeWithMe(this._autoFillService.addHook({id:"sheet-cell-image-autofill",onBeforeSubmit:(i,r,e,t)=>{new l.ObjectMatrix(t).forValue((n,o,s)=>{Bt(this._injector,{unitId:i.unitId,subUnitId:i.subUnitId,row:n,col:o},s)})}}))}};Je=Sn([jt(0,l.Inject(y.IAutoFillService)),jt(1,l.Inject(l.Injector))],Je);var fn=Object.getOwnPropertyDescriptor,wn=(i,r,e,t)=>{for(var n=t>1?void 0:t?fn(r,e):r,o=i.length-1,s;o>=0;o--)(s=i[o])&&(n=s(n)||n);return n},We=(i,r)=>(e,t)=>r(e,t,i);const vn=[l.DOCS_NORMAL_EDITOR_UNIT_ID_KEY,l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY,l.DOCS_ZEN_EDITOR_UNIT_ID_KEY];let Qe=class extends l.Disposable{constructor(i,r,e,t,n){super(),this._commandService=i,this._univerInstanceService=r,this._dialogService=e,this._renderManagerService=t,this._localeService=n,this._initDocImageCopyPasteHooks()}_setCellImage(i){var n;const r=l.createDocumentModelWithStyle("",{}),e=(n=N.getCurrentTypeOfRenderer(l.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null?void 0:n.with(U.EditingRenderController),t=l.BuildTextUtils.drawing.add({documentDataModel:r,drawings:[i],selection:{collapsed:!0,startOffset:0,endOffset:0}});t&&(r.apply(t),e&&e.submitCellData(r))}_initDocImageCopyPasteHooks(){this.disposeWithMe(this._commandService.beforeCommandExecuted(i=>{var r,e;if(i.id===Ge.InnerPasteCommand.id){const t=i.params,{doc:n}=t,o=this._univerInstanceService.getCurrentUnitOfType(l.UniverInstanceType.UNIVER_DOC);if(o==null||!Object.keys((r=n.drawings)!=null?r:{}).length)return;const s=o.getUnitId();if(vn.includes(s)){if(s!==l.DOCS_ZEN_EDITOR_UNIT_ID_KEY){const a=()=>{this._dialogService.close("sheet-cell-image-copy-paste"),this._commandService.syncExecuteCommand(U.SetCellEditVisibleOperation.id,{visible:!1})};((e=o.getBody())==null?void 0:e.dataStream)===`\r
15
+ `?(this._commandService.syncExecuteCommand(U.SetCellEditVisibleOperation.id,{visible:!1}),this._setCellImage(Object.values(n.drawings)[0])):this._dialogService.open({id:"sheet-cell-image-copy-paste",title:{label:this._localeService.t("cell-image.pasteTitle")},children:{label:this._localeService.t("cell-image.pasteContent")},width:320,destroyOnClose:!0,onClose:a,showOk:!0,showCancel:!0,onOk:()=>{a(),this._setCellImage(Object.values(n.drawings)[0])},onCancel:a})}throw new Error("Sheet cell image copy paste is not supported in this unit")}}}))}};Qe=wn([We(0,l.ICommandService),We(1,l.IUniverInstanceService),We(2,j.IDialogService),We(3,N.IRenderManagerService),We(4,l.Inject(l.LocaleService))],Qe);var _n=Object.getOwnPropertyDescriptor,In=(i,r,e,t)=>{for(var n=t>1?void 0:t?_n(r,e):r,o=i.length-1,s;o>=0;o--)(s=i[o])&&(n=s(n)||n);return n},Be=(i,r)=>(e,t)=>r(e,t,i);const Ft="image/png";function yn(i){const r=i.split(","),e=atob(r[1]),t=e.length,n=new Uint8Array(t);for(let o=0;o<t;o++)n[o]=e.charCodeAt(o);return new Blob([n],{type:Ft})}function Cn(i){const r=new ClipboardItem({[Ft]:yn(i)});navigator.clipboard.write([r]).catch(e=>{console.error("Could not copy image using clipboard API: ",e)})}function Dn(){function i(){const t=document.createElement("input");return t.style.position="absolute",t.style.height="1px",t.style.width="1px",t.style.opacity="0",t}const r=document.activeElement,e=i();return document.body.appendChild(e),e.focus(),()=>{e.blur(),document.body.removeChild(e),r instanceof HTMLElement&&r.focus()}}const Lt=[U.PREDEFINED_HOOK_NAME_PASTE.SPECIAL_PASTE_COL_WIDTH,U.PREDEFINED_HOOK_NAME_PASTE.SPECIAL_PASTE_VALUE,U.PREDEFINED_HOOK_NAME_PASTE.SPECIAL_PASTE_FORMAT,U.PREDEFINED_HOOK_NAME_PASTE.SPECIAL_PASTE_FORMULA];let et=class extends l.Disposable{constructor(r,e,t,n,o){super();se(this,"_copyInfo");this._sheetClipboardService=r,this._renderManagerService=e,this._drawingService=t,this._clipboardInterfaceService=n,this._commandService=o,this._initCopyPaste()}get _focusedDrawings(){return this._drawingService.getFocusDrawings()}_initCopyPaste(){this._sheetClipboardService.addClipboardHook({id:"SHEET_IMAGE_UI_PLUGIN",onBeforeCopy:(r,e,t,n)=>{this._copyInfo=null;const o=this._focusedDrawings;if(o.length>0){const[s]=o;if(s.drawingType!==l.DrawingTypeEnum.DRAWING_IMAGE)return;if(n===U.COPY_TYPE.CUT){const c={unitId:r,drawings:[s]};this._commandService.executeCommand(Ce.id,c)}setTimeout(()=>{const c=Dn();s.drawingType===l.DrawingTypeEnum.DRAWING_IMAGE&&s.imageSourceType===B.ImageSourceType.BASE64?Cn(s.source):this._clipboardInterfaceService.writeText(""),c()},200);const a={unitId:s.unitId,subUnitId:s.subUnitId,drawings:[s]};this._copyInfo=a}else{const s=this._createDrawingsCopyInfoByRange(r,e,t);this._copyInfo=s}},onPasteCells:(r,e,t,n)=>{if(!this._copyInfo)return{redos:[],undos:[]};const{copyType:o=U.COPY_TYPE.COPY,pasteType:s}=n,{range:a}=r||{},{range:c,unitId:g,subUnitId:u}=e;return this._copyInfo.copyRange?this._generateRangeDrawingsPasteMutations({pasteType:s,unitId:g,subUnitId:u,pasteRange:c},{copyRange:a,copyType:o}):this._generateSingleDrawingPasteMutations({pasteTo:e,pasteType:s},U.COPY_TYPE.COPY)},onPastePlainText:(r,e)=>({undos:[],redos:[]}),onPasteUnrecognized:r=>this._copyInfo?this._generateSingleDrawingPasteMutations({pasteTo:r,pasteType:U.PREDEFINED_HOOK_NAME_PASTE.DEFAULT_PASTE},U.COPY_TYPE.COPY):{undos:[],redos:[]},onPasteFiles:(r,e)=>{if(this._copyInfo)return this._generateSingleDrawingPasteMutations({pasteTo:r,pasteType:U.PREDEFINED_HOOK_NAME_PASTE.DEFAULT_PASTE},U.COPY_TYPE.COPY);{const t=e.filter(n=>n.type.includes("image"));if(t.length)return{undos:[],redos:[{id:ke.id,params:{files:t}}]}}return{undos:[],redos:[]}}})}_createDrawingsCopyInfoByRange(r,e,t){var m;const n=(m=this._renderManagerService.getRenderById(r))==null?void 0:m.with(U.SheetSkeletonManagerService);if(!n)return;const o=n.attachRangeWithCoord(t);if(!o)return;const{startX:s,endX:a,startY:c,endY:g}=o,u=this._drawingService.getDrawingData(r,e),d=this._focusedDrawings.slice();if(Object.keys(u).forEach(h=>{const p=u[h];if(p.drawingType!==l.DrawingTypeEnum.DRAWING_IMAGE)return;const{transform:S}=p;if(p.anchorType!==w.SheetDrawingAnchorType.Both||!S)return;const{left:f=0,top:v=0,width:I=0,height:T=0}=S,{drawingStartX:O,drawingEndX:D,drawingStartY:C,drawingEndY:M}={drawingStartX:f,drawingEndX:f+I,drawingStartY:v,drawingEndY:v+T};s<=O&&D<=a&&c<=C&&M<=g&&d.push(p)}),d.length)return{copyRange:t,drawings:d,unitId:r,subUnitId:e}}_generateSingleDrawingPasteMutations(r,e){const{pasteType:t,pasteTo:n}=r;if(Lt.includes(t))return{redos:[],undos:[]};const{unitId:o,subUnitId:s,range:a}=n,c=this._renderManagerService.getRenderById(o),g=c==null?void 0:c.with(U.SheetSkeletonManagerService),u=c==null?void 0:c.with(U.ISheetSelectionRenderService),d=this._copyInfo;if(!g||!u)return{redos:[],undos:[]};const{drawings:m}=d,h=y.discreteRangeToRange(a);return this._generateMutations(m,{unitId:o,subUnitId:s,isCut:e===U.COPY_TYPE.CUT,getTransform:(p,S)=>{var I,T;const f=g.attachRangeWithCoord({startRow:h.startRow,endRow:h.endRow,startColumn:h.startColumn,endColumn:h.endColumn}),v={...p,left:f==null?void 0:f.startX,top:f==null?void 0:f.startY};return{transform:v,sheetTransform:(I=x(v,u))!=null?I:S,axisAlignSheetTransform:(T=G(v,u))!=null?T:S}}})}_generateMutations(r,e){const{unitId:t,subUnitId:n,getTransform:o,isCut:s}=e,a=[],c=[],{_drawingService:g}=this;return r.forEach(u=>{const{transform:d,sheetTransform:m}=u;if(!d)return;const h=o(d,m),p={...u,unitId:t,subUnitId:n,drawingId:s?u.drawingId:l.generateRandomId(),transform:h.transform,sheetTransform:h.sheetTransform,axisAlignSheetTransform:h.axisAlignSheetTransform};if(s){const{undo:S,redo:f,objects:v}=g.getBatchUpdateOp([p]);a.push({id:w.SetDrawingApplyMutation.id,params:{unitId:t,subUnitId:n,type:w.DrawingApplyType.UPDATE,op:f,objects:v}}),c.push({id:w.SetDrawingApplyMutation.id,params:{unitId:t,subUnitId:n,type:w.DrawingApplyType.UPDATE,op:S,objects:v}})}else{const{undo:S,redo:f,objects:v}=g.getBatchAddOp([p]);a.push({id:w.SetDrawingApplyMutation.id,params:{op:f,unitId:t,subUnitId:n,objects:v,type:w.DrawingApplyType.INSERT}}),c.push({id:w.SetDrawingApplyMutation.id,params:{op:S,unitId:t,subUnitId:n,objects:v,type:w.DrawingApplyType.REMOVE}})}}),{redos:a,undos:c}}_generateRangeDrawingsPasteMutations(r,e){var R;const{unitId:t,subUnitId:n,pasteType:o,pasteRange:s}=r,{copyRange:a,copyType:c}=e;if(Lt.includes(o))return{redos:[],undos:[]};const g=(R=this._renderManagerService.getRenderById(t))==null?void 0:R.with(U.SheetSkeletonManagerService);if(!g||!this._copyInfo)return{redos:[],undos:[]};const{drawings:u}=this._copyInfo;if(!a)return this._generateSingleDrawingPasteMutations({pasteTo:{unitId:t,subUnitId:n,range:y.discreteRangeToRange(s)},pasteType:o},c);const{ranges:[d,m],mapFunc:h}=U.virtualizeDiscreteRanges([a,s]),{row:p,col:S}=h(d.startRow,d.startColumn),{row:f,col:v}=h(m.startRow,m.startColumn),I=g.attachRangeWithCoord({startRow:p,endRow:p,startColumn:S,endColumn:S}),T=g.attachRangeWithCoord({startRow:f,endRow:f,startColumn:v,endColumn:v});if(!I||!T||!this._copyInfo)return{redos:[],undos:[]};const O=T.startX-I.startX,D=T.startY-I.startY,C=f-p,M=v-S;return this._generateMutations(u,{unitId:t,subUnitId:n,getTransform:(k,E)=>{var F,L,ee;const P={...k,left:((F=k==null?void 0:k.left)!=null?F:0)+O,top:((L=k==null?void 0:k.top)!=null?L:0)+D},_=this._renderManagerService.getRenderById(t),b=_==null?void 0:_.with(U.ISheetSelectionRenderService);return b?{transform:P,sheetTransform:{...E,to:{...E.to,row:E.to.row+C,column:E.to.column+M},from:{...E.from,row:E.from.row+C,column:E.from.column+M}},axisAlignSheetTransform:(ee=G(P,b))!=null?ee:E}:{transform:P,sheetTransform:{...E,to:{...E.to,row:E.to.row+C,column:E.to.column+M},from:{...E.from,row:E.from.row+C,column:E.from.column+M}},axisAlignSheetTransform:{...E,to:{...E.to,row:E.to.row+C,column:E.to.column+M},from:{...E.from,row:E.from.row+C,column:E.from.column+M}}}},isCut:c===U.COPY_TYPE.CUT})}};et=In([Be(0,U.ISheetClipboardService),Be(1,N.IRenderManagerService),Be(2,B.IDrawingManagerService),Be(3,j.IClipboardInterfaceService),Be(4,l.ICommandService)],et);var Tn=Object.getOwnPropertyDescriptor,Mn=(i,r,e,t)=>{for(var n=t>1?void 0:t?Tn(r,e):r,o=i.length-1,s;o>=0;o--)(s=i[o])&&(n=s(n)||n);return n},je=(i,r)=>(e,t)=>r(e,t,i);let tt=class extends l.Disposable{constructor(i,r,e,t,n){super(),this._drawingManagerService=i,this._renderManagerService=r,this._permissionService=e,this._univerInstanceService=t,this._userManagerService=n,this._initDrawingVisible(),this._initDrawingEditable(),this._initViewPermissionChange(),this._initEditPermissionChange()}_initDrawingVisible(){const i=this._univerInstanceService.getCurrentTypeOfUnit$(l.UniverInstanceType.UNIVER_SHEET),r=this._userManagerService.currentUser$,e=W.combineLatest([i,r]);this.disposeWithMe(e.pipe(W.switchMap(([t,n])=>t?t.activeSheet$.pipe(W.tap(o=>{if(!o){this._drawingManagerService.setDrawingVisible(!1);return}const s=t.getUnitId(),a=o.getSheetId();this._permissionService.composePermission([new y.WorkbookViewPermission(s).id,new y.WorksheetViewPermission(s,a).id]).every(g=>g.value)?this._drawingManagerService.setDrawingVisible(!0):this._handleDrawingVisibilityFalse(t,o)})):(this._drawingManagerService.setDrawingVisible(!1),W.EMPTY))).subscribe())}_handleDrawingVisibilityFalse(i,r){this._drawingManagerService.setDrawingVisible(!1);const e=i.getUnitId(),t=r.getSheetId(),n=this._drawingManagerService.getDrawingData(e,t),o=Object.values(n),s=this._renderManagerService.getRenderById(e),a=s==null?void 0:s.scene;if(!a)return;a.getAllObjectsByOrder().forEach(g=>{g.classType===N.RENDER_CLASS_TYPE.IMAGE&&o.some(u=>g.oKey.includes(u.drawingId))&&a.removeObject(g)})}_initDrawingEditable(){const i=this._univerInstanceService.getCurrentTypeOfUnit$(l.UniverInstanceType.UNIVER_SHEET),r=this._userManagerService.currentUser$,e=W.combineLatest([i,r]);this.disposeWithMe(e.pipe(W.switchMap(([t,n])=>t?t.activeSheet$.pipe(W.tap(o=>{if(!o){this._drawingManagerService.setDrawingEditable(!1);return}const s=t.getUnitId(),a=o.getSheetId();this._permissionService.composePermission([new y.WorkbookEditablePermission(s).id,new y.WorksheetEditPermission(s,a).id]).every(g=>g.value)?this._drawingManagerService.setDrawingEditable(!0):this._handleDrawingEditableFalse(t,o)})):(this._drawingManagerService.setDrawingEditable(!1),W.EMPTY))).subscribe())}_handleDrawingEditableFalse(i,r){this._drawingManagerService.setDrawingEditable(!1);const e=i.getUnitId(),t=r.getSheetId(),n=this._drawingManagerService.getDrawingData(e,t),o=Object.values(n),s=this._renderManagerService.getRenderById(e),a=s==null?void 0:s.scene;if(!a)return;a.getAllObjectsByOrder().forEach(g=>{g.classType===N.RENDER_CLASS_TYPE.IMAGE&&o.some(u=>g.oKey.includes(u.drawingId))&&a.detachTransformerFrom(g)})}_initViewPermissionChange(){const i=this._univerInstanceService.getCurrentTypeOfUnit$(l.UniverInstanceType.UNIVER_SHEET),r=this._userManagerService.currentUser$;this.disposeWithMe(W.combineLatest([i,r]).pipe(W.switchMap(([e,t])=>e?e.activeSheet$.pipe(W.switchMap(n=>{if(!n)return W.EMPTY;const o=e.getUnitId(),s=n.getSheetId(),a=this._renderManagerService.getRenderById(o),c=a==null?void 0:a.scene;if(!c)return W.EMPTY;const g=c.getTransformerByCreate();return this._permissionService.composePermission$([new y.WorkbookViewPermission(o).id,new y.WorksheetViewPermission(o,s).id]).pipe(W.map(d=>d.every(m=>m.value)),W.distinctUntilChanged()).pipe(W.map(d=>({permission:d,scene:c,transformer:g,unitId:o,subUnitId:s})))})):W.EMPTY)).subscribe({next:({permission:e,scene:t,transformer:n,unitId:o,subUnitId:s})=>{this._drawingManagerService.setDrawingVisible(e);const a=t.getAllObjectsByOrder(),c=this._drawingManagerService.getDrawingData(o,s),g=Object.values(c);e?this._drawingManagerService.addNotification(g):(a.forEach(u=>{u.classType===N.RENDER_CLASS_TYPE.IMAGE&&g.some(d=>u.oKey.includes(d.drawingId))&&t.removeObject(u)}),n.clearSelectedObjects())},complete:()=>{this._drawingManagerService.setDrawingVisible(!0);const e=this._univerInstanceService.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET),t=e==null?void 0:e.getActiveSheet(),n=e==null?void 0:e.getUnitId(),o=t==null?void 0:t.getSheetId();if(!n||!o)return;const s=this._drawingManagerService.getDrawingData(n,o),a=Object.values(s);this._drawingManagerService.addNotification(a)}}))}_initEditPermissionChange(){const i=this._univerInstanceService.getCurrentTypeOfUnit$(l.UniverInstanceType.UNIVER_SHEET),r=this._userManagerService.currentUser$;this.disposeWithMe(W.combineLatest([i,r]).pipe(W.switchMap(([e,t])=>e?e.activeSheet$.pipe(W.switchMap(n=>{if(!n)return W.EMPTY;const o=e.getUnitId(),s=n.getSheetId(),a=this._renderManagerService.getRenderById(o),c=a==null?void 0:a.scene;if(!c)return W.EMPTY;const g=c.getTransformerByCreate();return this._permissionService.composePermission$([new y.WorkbookEditablePermission(o).id,new y.WorksheetEditPermission(o,s).id]).pipe(W.map(d=>d.every(m=>m.value)),W.distinctUntilChanged()).pipe(W.map(d=>({permission:d,scene:c,transformer:g,unitId:o,subUnitId:s})))})):W.EMPTY)).subscribe({next:({permission:e,scene:t,transformer:n,unitId:o,subUnitId:s})=>{this._drawingManagerService.setDrawingEditable(e);const a=t.getAllObjectsByOrder(),c=this._drawingManagerService.getDrawingData(o,s),g=Object.values(c);e?(a.forEach(u=>{u.classType===N.RENDER_CLASS_TYPE.IMAGE&&g.some(d=>u.oKey.includes(d.drawingId))&&t.attachTransformerTo(u)}),this._drawingManagerService.addNotification(g)):(a.forEach(u=>{u.classType===N.RENDER_CLASS_TYPE.IMAGE&&g.some(d=>u.oKey.includes(d.drawingId))&&t.detachTransformerFrom(u)}),n.clearSelectedObjects())},complete:()=>{const e=this._univerInstanceService.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET);if(!e)return;const t=e.getUnitId(),n=e.getActiveSheet();if(!n)return;const o=n.getSheetId(),s=this._renderManagerService.getRenderById(t),a=s==null?void 0:s.scene;if(!a)return;const c=this._drawingManagerService.getDrawingData(t,o),g=Object.values(c);this._drawingManagerService.setDrawingEditable(!0),a.getAllObjectsByOrder().forEach(d=>{d.classType===N.RENDER_CLASS_TYPE.IMAGE&&g.some(m=>d.oKey.includes(m.drawingId))&&a.detachTransformerFrom(d)})}}))}};tt=Mn([je(0,B.IDrawingManagerService),je(1,N.IRenderManagerService),je(2,l.IPermissionService),je(3,l.IUniverInstanceService),je(4,l.Inject(l.UserManagerService))],tt);var Rn=Object.getOwnPropertyDescriptor,En=(i,r,e,t)=>{for(var n=t>1?void 0:t?Rn(r,e):r,o=i.length-1,s;o>=0;o--)(s=i[o])&&(n=s(n)||n);return n},Ie=(i,r)=>(e,t)=>r(e,t,i);const $t="univer-sheet-float-dom-";function Yt(i,r,e,t,n,o=!1){const{scaleX:s,scaleY:a}=r.getAncestorScale(),c=r.getViewport(N.SHEET_VIEWPORT_KEY.VIEW_MAIN),g=t.getFreeze(),{startColumn:u,startRow:d,xSplit:m,ySplit:h}=g,p={left:!0,top:!0};if(!c)return{...i,absolute:p};const{left:S,right:f,top:v,bottom:I}=i;let{top:T,left:O,viewportScrollX:D,viewportScrollY:C}=c;const{boundsOfViewArea:M,scrollDirectionResponse:R}=n||{},{rowHeaderWidth:k,columnHeaderHeight:E}=e,P={top:o?0:E,left:o?0:k};M&&(l.Tools.isDefine(P.top)&&(P.top=M.top),l.Tools.isDefine(P.left)&&(P.left=M.left)),R==="HORIZONTAL"&&(C=0),R==="VERTICAL"&&(D=0);let _=0,b=0;const F=e.rowStartY(d-h)+E,L=e.colStartX(u-m)+k,ee=e.rowStartY(d)+E,ne=e.colStartX(u)+k;if(m===0)p.left=!1,_=(S-D)*s,b=(f-D)*s;else{const V=S-(L-k),J=f-(L-k);f<ne?(_=V*s,b=J*s):S<=ne&&f>=ne?(_=V*s,b=Math.max(O,(f-D)*s)):S>ne&&(p.left=!1,_=Math.max((S-D)*s,O),b=Math.max((f-D)*s,O))}let z=0,q=0;if(h===0)p.top=!1,z=(v-C)*a,q=(I-C)*a;else{const V=v-(F-E),J=I-(F-E);I<ee?(z=V*a,q=J*a):v<=ee&&I>=ee?(z=V*a,q=Math.max(T,(I-C)*a)):v>ee&&(p.top=!1,z=Math.max((v-C)*a,T),q=Math.max((I-C)*a,T))}return _=Math.max(_,P.left),z=Math.max(z,P.top),b=Math.max(b,P.left),q=Math.max(q,P.top),{left:_,right:b,top:z,bottom:q,absolute:p}}const de=(i,r,e,t,n)=>{const{left:o,top:s,width:a,height:c,angle:g}=i,u={left:o,right:o+a,top:s,bottom:s+c},d=Yt(u,r,e,t,n),{scaleX:m,scaleY:h}=r.getAncestorScale();return{startX:d.left,endX:d.right,startY:d.top,endY:d.bottom,rotate:g,width:a*m,height:c*h,absolute:d.absolute}};A.SheetCanvasFloatDomManagerService=class extends l.Disposable{constructor(e,t,n,o,s,a,c){super();se(this,"_domLayerInfoMap",new Map);se(this,"_transformChange$",new W.Subject);se(this,"transformChange$",this._transformChange$.asObservable());se(this,"_add$",new W.Subject);se(this,"add$",this._add$.asObservable());se(this,"_remove$",new W.Subject);se(this,"remove$",this._remove$.asObservable());this._renderManagerService=e,this._univerInstanceService=t,this._commandService=n,this._drawingManagerService=o,this._canvasFloatDomService=s,this._sheetDrawingService=a,this._lifecycleService=c,this._drawingAddListener(),this._featureUpdateListener(),this._deleteListener(),this._bindScrollEvent()}_bindScrollEvent(){this._lifecycleService.lifecycle$.pipe(W.filter(e=>e===l.LifecycleStages.Rendered),W.take(1)).subscribe(()=>{this._scrollUpdateListener()})}getFloatDomInfo(e){return this._domLayerInfoMap.get(e)}getFloatDomsBySubUnitId(e,t){return Array.from(this._domLayerInfoMap.values()).filter(n=>n.subUnitId===t&&n.unitId===e)}_getSceneAndTransformerByDrawingSearch(e){if(e==null)return;const t=this._renderManagerService.getRenderById(e),n=t==null?void 0:t.scene;if(t==null||n==null)return null;const o=n.getTransformerByCreate(),s=t.engine.getCanvasElement();return{scene:n,transformer:o,renderUnit:t,canvas:s}}_drawingAddListener(){this.disposeWithMe(this._drawingManagerService.add$.subscribe(e=>{e.forEach(t=>{var J;const{unitId:n,subUnitId:o,drawingId:s}=t,a=y.getSheetCommandTarget(this._univerInstanceService,{unitId:n,subUnitId:o}),c=this._drawingManagerService.getDrawingByParam(t),g=this._univerInstanceService.getUnit(n,l.UniverInstanceType.UNIVER_SHEET);if(!g)return;const u=g.getActiveSheet().getSheetId();if(!c||!a)return;const d=(J=this._renderManagerService.getRenderById(n))==null?void 0:J.with(U.SheetSkeletonManagerService).getSkeletonParam(o);if(!d)return;const{transform:m,drawingType:h,data:p}=c;if(h!==l.DrawingTypeEnum.DRAWING_DOM&&h!==l.DrawingTypeEnum.DRAWING_CHART)return;const S=this._getSceneAndTransformerByDrawingSearch(n);if(S==null)return;const{scene:f,canvas:v}=S;if(m==null)return!0;if(u!==o)return;const{left:I,top:T,width:O,height:D,angle:C,flipX:M,flipY:R,skewX:k,skewY:E}=m,P=B.getDrawingShapeKeyByDrawingSearch({unitId:n,subUnitId:o,drawingId:s}),_=f.getObject(P);if(_!=null){_.transformByState({left:I,top:T,width:O,height:D,angle:C,flipX:M,flipY:R,skewX:k,skewY:E});return}const b={left:I,top:T,width:O,height:D,zIndex:this._drawingManagerService.getDrawingOrder(n,o).length-1},F=h===l.DrawingTypeEnum.DRAWING_CHART;if(b.rotateEnabled=!1,F){const $=p?p.backgroundColor:"white";b.fill=$,p&&p.border&&(b.stroke=p.border),b.paintFirst="stroke",b.strokeWidth=1,b.borderEnabled=!1,b.radius=8}const L=new N.Rect(P,b);F&&L.setObjectType(N.ObjectType.CHART),f.addObject(L,N.DRAWING_OBJECT_LAYER_INDEX),c.allowTransform!==!1&&f.attachTransformerTo(L);const ee=new l.DisposableCollection,ne=de(L,S.renderUnit.scene,d.skeleton,a.worksheet),z=new W.BehaviorSubject(ne),q=`${$t}${l.generateRandomId(6)}`,re={dispose:ee,rect:L,position$:z,unitId:n,subUnitId:o,id:s,domId:q};this._canvasFloatDomService.addFloatDom({position$:z,id:s,domId:q,componentKey:c.componentKey,onPointerDown:$=>{v.dispatchEvent(new PointerEvent($.type,$))},onPointerMove:$=>{v.dispatchEvent(new PointerEvent($.type,$))},onPointerUp:$=>{v.dispatchEvent(new PointerEvent($.type,$))},onWheel:$=>{v.dispatchEvent(new WheelEvent($.type,$))},data:p,unitId:n});const V=L.onTransformChange$.subscribeEvent(()=>{const $=de(L,S.renderUnit.scene,d.skeleton,a.worksheet);z.next($)});ee.add(()=>{this._canvasFloatDomService.removeFloatDom(s)}),V&&ee.add(V),this._domLayerInfoMap.set(s,re)})})),this.disposeWithMe(this._drawingManagerService.remove$.subscribe(e=>{e.forEach(t=>{var m;const{unitId:n,subUnitId:o,drawingId:s}=t,a=B.getDrawingShapeKeyByDrawingSearch({unitId:n,subUnitId:o,drawingId:s}),c=this._getSceneAndTransformerByDrawingSearch(n);if(c==null)return;const{transformer:g,scene:u}=c,d=u.getObject(a);d!=null&&d.oKey&&(g.clearControlByIds([d==null?void 0:d.oKey]),(m=u.getTransformer())==null||m.clearSelectedObjects())})}))}_scrollUpdateListener(){const e=(t,n)=>{var g;const o=this._getSceneAndTransformerByDrawingSearch(t),s=Array.from(this._domLayerInfoMap.keys()).map(u=>({id:u,...this._domLayerInfoMap.get(u)})).filter(u=>u.subUnitId===n&&u.unitId===t).map(u=>u.id),a=y.getSheetCommandTarget(this._univerInstanceService,{unitId:t,subUnitId:n}),c=(g=this._renderManagerService.getRenderById(t))==null?void 0:g.with(U.SheetSkeletonManagerService).getSkeletonParam(n);!o||!a||!c||s.forEach(u=>{const d=this._domLayerInfoMap.get(u);if(d){const m=de(d.rect,o.renderUnit.scene,c.skeleton,a.worksheet,d);d.position$.next(m)}})};this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(l.UniverInstanceType.UNIVER_SHEET).pipe(W.switchMap(t=>t?t.activeSheet$:W.of(null)),W.map(t=>{if(!t)return null;const n=t.getUnitId(),o=this._renderManagerService.getRenderById(n);return o?{render:o,unitId:n,subUnitId:t.getSheetId()}:null}),W.switchMap(t=>t?l.fromEventSubject(t.render.scene.getViewport(N.SHEET_VIEWPORT_KEY.VIEW_MAIN).onScrollAfter$).pipe(W.map(()=>({unitId:t.unitId,subUnitId:t.subUnitId}))):W.of(null))).subscribe(t=>{if(!t)return;const{unitId:n,subUnitId:o}=t;e(n,o)})),this.disposeWithMe(this._commandService.onCommandExecuted(t=>{if(t.id===U.SetZoomRatioOperation.id){const n=t.params,{unitId:o}=n;Array.from(this._domLayerInfoMap.values()).filter(a=>a.unitId===o).map(a=>a.subUnitId).forEach(a=>{e(o,a)})}else if(t.id===y.SetFrozenMutation.id){const{unitId:n,subUnitId:o}=t.params;e(n,o)}else if(t.id===y.SetSelectionsOperation.id){const{unitId:n,subUnitId:o}=t.params;e(n,o)}}))}updateFloatDomProps(e,t,n,o){const s=this._domLayerInfoMap.get(n),a=this._getSceneAndTransformerByDrawingSearch(e);if(s&&a){const{scene:c}=a,g=B.getDrawingShapeKeyByDrawingSearch({unitId:e,subUnitId:t,drawingId:n}),u=c.getObject(g);u&&u instanceof N.Rect&&u.setProps(o)}}_getPosition(e,t){var h;const{startX:n,endX:o,startY:s,endY:a}=e,c=(h=this._renderManagerService.getRenderById(t))==null?void 0:h.with(U.ISheetSelectionRenderService);if(c==null)return;const g=c.getCellWithCoordByOffset(n,s);if(g==null)return;const u={column:g.actualColumn,columnOffset:n-g.startX,row:g.actualRow,rowOffset:s-g.startY},d=c.getCellWithCoordByOffset(o,a);if(d==null)return;const m={column:d.actualColumn,columnOffset:o-d.startX,row:d.actualRow,rowOffset:a-d.startY};return{from:u,to:m}}_featureUpdateListener(){this.disposeWithMe(this._drawingManagerService.update$.subscribe(e=>{e.forEach(t=>{const n=this._drawingManagerService.getDrawingByParam(t);if(!n||n.drawingType!==l.DrawingTypeEnum.DRAWING_DOM&&n.drawingType!==l.DrawingTypeEnum.DRAWING_CHART)return;const o={...n.transform};this._transformChange$.next({id:t.drawingId,value:o}),this._canvasFloatDomService.updateFloatDom(t.drawingId,{...n});const s=this._getSceneAndTransformerByDrawingSearch(t.unitId);if(s&&n.drawingType!==l.DrawingTypeEnum.DRAWING_CHART){const{scene:a}=s,c=this._domLayerInfoMap.get(t.drawingId);c!=null&&c.rect&&(n.allowTransform===!1?a.detachTransformerFrom(c.rect):a.attachTransformerTo(c.rect))}})}))}_deleteListener(){this.disposeWithMe(this._drawingManagerService.remove$.subscribe(e=>{e.forEach(t=>{this._removeDom(t.drawingId)})}))}addFloatDomToPosition(e,t){const n=y.getSheetCommandTarget(this._univerInstanceService,{unitId:e.unitId,subUnitId:e.subUnitId});if(!n)throw new Error("cannot find current target!");const{unitId:o,subUnitId:s}=n,{initPosition:a,componentKey:c,data:g,allowTransform:u=!0}=e,d=t!=null?t:l.generateRandomId(),m=this._getPosition(a,o);if(m==null)return;const h={unitId:o,subUnitId:s,drawingId:d,drawingType:e.type||l.DrawingTypeEnum.DRAWING_DOM,componentKey:c,sheetTransform:m,transform:{left:a.startX,top:a.startY,width:a.endX-a.startX,height:a.endY-a.startY},axisAlignSheetTransform:m,data:g,allowTransform:u};return this._commandService.executeCommand(Ne.id,{unitId:o,drawings:[h]}),this._add$.next({unitId:o,subUnitId:s,id:d}),{id:d,dispose:()=>{this._removeDom(d,!0)}}}_removeDom(e,t=!1){const n=this._domLayerInfoMap.get(e);if(!n)return;const{unitId:o,subUnitId:s}=n;this._domLayerInfoMap.delete(e),n.dispose.dispose();const a=this._getSceneAndTransformerByDrawingSearch(o);if(a&&a.scene.removeObject(n.rect),t){const c=this._drawingManagerService.getDrawingByParam({unitId:o,subUnitId:s,drawingId:e});if(!c)return;const g=this._sheetDrawingService.getBatchRemoveOp([c]),{redo:u,objects:d}=g;this._commandService.syncExecuteCommand(w.SetDrawingApplyMutation.id,{unitId:o,subUnitId:s,op:u,objects:d,type:w.DrawingApplyType.REMOVE})}}addFloatDomToRange(e,t,n,o){var M,R,k;const s=y.getSheetCommandTarget(this._univerInstanceService,{unitId:t.unitId,subUnitId:t.subUnitId});if(!s)throw new Error("cannot find current target!");const{unitId:a,subUnitId:c}=s,g=this._getSceneAndTransformerByDrawingSearch(a);if(!g)return;const u=this._renderManagerService.getRenderById(a);if(!u)return;const d=(M=this._renderManagerService.getRenderById(a))==null?void 0:M.with(U.SheetSkeletonManagerService).getWorksheetSkeleton(c);if(!d)return;const{componentKey:m,data:h,allowTransform:p=!0}=t,S=o!=null?o:l.generateRandomId(),{position:f,position$:v}=this._createRangePositionObserver(e,u,d.skeleton);if(this._getPosition(f,a)==null)return;const T=g.scene,{scaleX:O}=T.getAncestorScale(),D=nt(f,n,O),C={unitId:a,subUnitId:c,drawingId:S,drawingType:t.type||l.DrawingTypeEnum.DRAWING_DOM,componentKey:m,transform:{left:D.startX,top:D.startY,width:D.width,height:D.height},data:h,allowTransform:p};{const{unitId:E,subUnitId:P,drawingId:_}=C,b=y.getSheetCommandTarget(this._univerInstanceService,{unitId:E,subUnitId:P}),F=C,L=this._univerInstanceService.getUnit(E,l.UniverInstanceType.UNIVER_SHEET);if(!L)return;const ee=L.getActiveSheet().getSheetId();if(!F||!b)return;const ne=(R=this._renderManagerService.getRenderById(E))==null?void 0:R.with(U.SheetSkeletonManagerService);if(!ne)return;const z=ne.getWorksheetSkeleton(P);if(!z)return;const{transform:q,drawingType:re,data:V}=F;if(re!==l.DrawingTypeEnum.DRAWING_DOM&&re!==l.DrawingTypeEnum.DRAWING_CHART)return;const J=this._getSceneAndTransformerByDrawingSearch(E);if(J==null)return;const{scene:$,canvas:ae}=J;if(q==null||ee!==P)return;const{left:ue,top:le,width:ve,height:_e,angle:bt,flipX:Ot,flipY:st,skewX:at,skewY:Oe}=q,ct=B.getDrawingShapeKeyByDrawingSearch({unitId:E,subUnitId:P,drawingId:_}),ge=$.getObject(ct);if(ge!=null){ge.transformByState({left:ue,top:le,width:ve,height:_e,angle:bt,flipX:Ot,flipY:st,skewX:at,skewY:Oe});return}const oe={left:ue,top:le,width:ve,height:_e,zIndex:this._drawingManagerService.getDrawingOrder(E,P).length-1},Ae=re===l.DrawingTypeEnum.DRAWING_CHART;if(Ae){const H=V?V.backgroundColor:"white";oe.fill=H,oe.rotateEnabled=!1,V&&V.border&&(oe.stroke=V.border),oe.paintFirst="stroke",oe.strokeWidth=1,oe.borderEnabled=!1,oe.radius=8}const he=new N.Rect(ct,oe);Ae&&he.setObjectType(N.ObjectType.CHART),$.addObject(he,N.DRAWING_OBJECT_LAYER_INDEX),F.allowTransform!==!1&&$.attachTransformerTo(he);const me=new l.DisposableCollection,dt=$.getMainViewport(),{rowHeaderWidth:Ue,columnHeaderHeight:$e}=z.skeleton,lt={top:$e,left:Ue,bottom:dt.bottom,right:dt.right},pe={dispose:me,rect:he,boundsOfViewArea:lt,domAnchor:n,unitId:E,subUnitId:P},Z=de(he,J.renderUnit.scene,z.skeleton,b.worksheet,pe),Pe=new W.BehaviorSubject(Z);pe.position$=Pe;let Ye={position$:Pe,id:_,componentKey:F.componentKey,onPointerDown:()=>{},onPointerMove:()=>{},onPointerUp:()=>{},onWheel:H=>{ae.dispatchEvent(new WheelEvent(H.type,H))},data:V,unitId:E};t.eventPassThrough&&(Ye={...Ye,onPointerDown:H=>{ae.dispatchEvent(new PointerEvent(H.type,H))},onPointerMove:H=>{ae.dispatchEvent(new PointerEvent(H.type,H))},onPointerUp:H=>{ae.dispatchEvent(new PointerEvent(H.type,H))}}),this._canvasFloatDomService.addFloatDom(Ye),this.disposeWithMe(v.subscribe(H=>{var Vt,Xt,Kt,zt;const Ht=nt({startX:H.startX,startY:H.startY,endX:H.endX,endY:H.endY,width:(Vt=n.width)!=null?Vt:H.width,height:(Xt=n.height)!=null?Xt:H.height,absolute:{left:f.absolute.left,top:f.absolute.top}},n),rr=B.getDrawingShapeKeyByDrawingSearch({unitId:E,subUnitId:P,drawingId:_}),ir=new N.Rect(rr,{left:Ht.startX,top:Ht.startY,width:(Kt=n.width)!=null?Kt:H.width,height:(zt=n.height)!=null?zt:H.height,zIndex:this._drawingManagerService.getDrawingOrder(E,P).length-1}),or=de(ir,J.renderUnit.scene,z.skeleton,b.worksheet,pe);Pe.next(or)}));const xe=(k=this._renderManagerService.getRenderById(E))==null?void 0:k.with(U.SheetSkeletonManagerService);xe==null||xe.currentSkeleton$.subscribe(H=>{H&&z.sheetId!==H.sheetId&&this._removeDom(S,!0)});const ut=he.onTransformChange$.subscribeEvent(()=>{const H=de(he,J.renderUnit.scene,z.skeleton,b.worksheet,pe);Pe.next(H)});me.add(()=>{this._canvasFloatDomService.removeFloatDom(_)}),ut&&me.add(ut),this._domLayerInfoMap.set(_,pe)}return{id:S,dispose:()=>{this._removeDom(S,!0)}}}addFloatDomToColumnHeader(e,t,n,o){var D,C,M;const s=y.getSheetCommandTarget(this._univerInstanceService,{unitId:t.unitId,subUnitId:t.subUnitId});if(!s)throw new Error("cannot find current target!");const{unitId:a,subUnitId:c}=s;if(!this._getSceneAndTransformerByDrawingSearch(a))return;const u=this._renderManagerService.getRenderById(a);if(!u)return;const d=(D=this._renderManagerService.getRenderById(a))==null?void 0:D.with(U.SheetSkeletonManagerService).getWorksheetSkeleton(c);if(!d)return;const{componentKey:m,data:h,allowTransform:p=!0}=t,S=o!=null?o:l.generateRandomId(),{position:f,position$:v}=this._createRangePositionObserver({startRow:0,endRow:0,startColumn:e,endColumn:e},u,d.skeleton),I=f;if(I.startY=0,this._getPosition(f,a)==null)return;const O={unitId:a,subUnitId:c,drawingId:S,drawingType:t.type||l.DrawingTypeEnum.DRAWING_DOM,componentKey:m,transform:{left:I.startX,top:I.startY,width:I.width,height:I.height},data:h,allowTransform:p};{const{unitId:R,subUnitId:k,drawingId:E}=O,P=y.getSheetCommandTarget(this._univerInstanceService,{unitId:R,subUnitId:k}),_=O,b=this._univerInstanceService.getUnit(R,l.UniverInstanceType.UNIVER_SHEET);if(!b)return;const F=b.getActiveSheet().getSheetId();if(!_||!P)return;const L=(C=this._renderManagerService.getRenderById(R))==null?void 0:C.with(U.SheetSkeletonManagerService);if(!L)return;const ee=L.getWorksheetSkeleton(k);if(!ee)return;const{transform:ne,data:z}=_,q=this._getSceneAndTransformerByDrawingSearch(R);if(q==null)return;const{scene:re,canvas:V}=q;if(ne==null||F!==k)return;const{left:J,top:$,width:ae,height:ue,angle:le,flipX:ve,flipY:_e,skewX:bt,skewY:Ot}=ne,st=B.getDrawingShapeKeyByDrawingSearch({unitId:R,subUnitId:k,drawingId:E}),at=re.getObject(st);if(at!=null){at.transformByState({left:J,top:$,width:ae,height:ue,angle:le,flipX:ve,flipY:_e,skewX:bt,skewY:Ot});return}const Oe=nt({startX:I.startX,startY:0,endX:f.endX,endY:f.endY,width:n.width,height:n.height,absolute:{left:f.absolute.left,top:f.absolute.top}},n),ct={left:Oe.startX,top:Oe.startY,width:Oe.width,height:Oe.height,zIndex:this._drawingManagerService.getDrawingOrder(R,k).length-1},ge=new N.Rect(st,ct);re.addObject(ge,N.DRAWING_OBJECT_LAYER_INDEX),_.allowTransform!==!1&&re.attachTransformerTo(ge);const oe=new l.DisposableCollection,Ae=re.getMainViewport(),he={top:0,left:Ae.left,bottom:Ae.bottom,right:Ae.right},me={dispose:oe,rect:ge,unitId:R,subUnitId:k,boundsOfViewArea:he,domAnchor:n,scrollDirectionResponse:"HORIZONTAL"},dt=de(ge,q.renderUnit.scene,ee.skeleton,P.worksheet,me),Ue=new W.BehaviorSubject(dt);me.position$=Ue;let $e={position$:Ue,id:E,componentKey:_.componentKey,onPointerDown:()=>{},onPointerMove:()=>{},onPointerUp:()=>{},onWheel:Z=>{V.dispatchEvent(new WheelEvent(Z.type,Z))},data:z,unitId:R};t.eventPassThrough&&($e={...$e,onPointerDown:Z=>{V.dispatchEvent(new PointerEvent(Z.type,Z))},onPointerMove:Z=>{V.dispatchEvent(new PointerEvent(Z.type,Z))},onPointerUp:Z=>{V.dispatchEvent(new PointerEvent(Z.type,Z))}}),this._canvasFloatDomService.addFloatDom($e);const lt=ge.onTransformChange$.subscribeEvent(()=>{const Z=de(ge,q.renderUnit.scene,ee.skeleton,P.worksheet,me);Ue.next(Z)});this.disposeWithMe(v.subscribe(Z=>{const Pe=nt({startX:Z.startX,startY:0,endX:Z.endX,endY:Z.endY,width:n.width,height:n.height,absolute:{left:f.absolute.left,top:f.absolute.top}},n),Ye=B.getDrawingShapeKeyByDrawingSearch({unitId:R,subUnitId:k,drawingId:E}),xe=new N.Rect(Ye,{left:Pe.startX,top:0,width:n.width,height:n.height,zIndex:this._drawingManagerService.getDrawingOrder(R,k).length-1}),ut=de(xe,q.renderUnit.scene,ee.skeleton,P.worksheet,me);Ue.next(ut)}));const pe=(M=this._renderManagerService.getRenderById(R))==null?void 0:M.with(U.SheetSkeletonManagerService);pe==null||pe.currentSkeleton$.subscribe(Z=>{Z&&d.sheetId!==Z.sheetId&&this._removeDom(S,!0)}),oe.add(()=>{this._canvasFloatDomService.removeFloatDom(E)}),lt&&oe.add(lt),this._domLayerInfoMap.set(E,me)}return{id:S,dispose:()=>{this._removeDom(S,!0)}}}_createRangePositionObserver(e,t,n){let{startRow:o,startColumn:s}=e;const a=Fe(o,s,n),c=new W.BehaviorSubject(a),g=Fe(e.endRow,e.endColumn,n),u=new W.BehaviorSubject(g),d=()=>{const v=Fe(o,s,n),I=Fe(e.endRow,e.endColumn,n);c.next(v),u.next(I)},m=new l.DisposableCollection;m.add(t.engine.clientRect$.subscribe(()=>d())),m.add(this._commandService.onCommandExecuted(v=>{if(v.id===y.SetWorksheetRowAutoHeightMutation.id&&v.params.rowsAutoHeightInfo.findIndex(T=>T.row===o)>-1){d();return}(y.COMMAND_LISTENER_SKELETON_CHANGE.indexOf(v.id)>-1||v.id===U.SetScrollOperation.id||v.id===U.SetZoomRatioOperation.id)&&d()}));const h=(v,I)=>{o=v,s=I,d()},p=()=>({rotate:0,width:g.right-a.left,height:g.bottom-a.top,absolute:{left:!0,top:!0},startX:a.left,startY:a.top,endX:g.right,endY:g.bottom}),S=c.pipe(W.map(v=>{const I=Fe(e.endRow,e.endColumn,n);return{rotate:0,width:I.right-v.left,height:I.bottom-v.top,absolute:{left:!0,top:!0},startX:v.left,startY:v.top,endX:I.right,endY:I.bottom}})),f=p();return{position$:S,position:f,updateRowCol:h,topLeftPos$:c,rightBottomPos$:u,disposable:m}}},A.SheetCanvasFloatDomManagerService=En([Ie(0,l.Inject(N.IRenderManagerService)),Ie(1,l.IUniverInstanceService),Ie(2,l.Inject(l.ICommandService)),Ie(3,B.IDrawingManagerService),Ie(4,l.Inject(j.CanvasFloatDomService)),Ie(5,w.ISheetDrawingService),Ie(6,l.Inject(l.LifecycleService))],A.SheetCanvasFloatDomManagerService);function Fe(i,r,e){const t=e.getCellWithCoordByIndex(i,r),n=t.isMergedMainCell?t.mergeInfo:t;return{left:n.startX,right:n.endX,top:n.startY,bottom:n.endY}}function nt(i,r,e){var g,u;e=e!=null?e:1;const t=i.endX-i.startX,n=i.endY-i.startY,o=(g=r==null?void 0:r.width)!=null?g:t,s=(u=r==null?void 0:r.height)!=null?u:n;let a=0,c=0;if(r){if(r.horizonOffsetAlign==="right"){const d=rt(r.marginX,t*e);a=i.endX-d-o}else a=i.startX+rt(r.marginX,t);if(r.verticalOffsetAlign==="bottom"){const d=rt(r.marginY,n*e);c=i.endY-d-s}else c=i.startY+rt(r.marginY,n)}return{rotate:0,startX:a,startY:c,endX:i.endX,endY:i.endY,width:o,height:s,absolute:{left:i.absolute.left,top:i.absolute.top}}}function rt(i,r){if(i===void 0)return 0;if(typeof i=="number")return i;const e=Number.parseFloat(i);return r*e/100}const bn=i=>{const{floatDomInfos:r,scene:e,skeleton:t,worksheet:n}=i,o=Q.useMemo(()=>r.map(s=>{const{width:a,height:c,angle:g,left:u,top:d}=s.transform,m=Yt({left:u!=null?u:0,right:(u!=null?u:0)+(a!=null?a:0),top:d!=null?d:0,bottom:(d!=null?d:0)+(c!=null?c:0)},e,t,n,void 0,!0),{scaleX:h,scaleY:p}=e.getAncestorScale(),S={startX:m.left,endX:m.right,startY:m.top,endY:m.bottom,rotate:g,width:a*h,height:c*p,absolute:m.absolute},f={position$:new W.BehaviorSubject(S),position:S,id:s.drawingId,componentKey:s.componentKey,onPointerMove:()=>{},onPointerDown:()=>{},onPointerUp:()=>{},onWheel:()=>{},unitId:s.unitId,data:s.data};return[s.drawingId,f]}),[r,e,t,n]);return Y.jsx("div",{style:{position:"absolute",top:0,left:0},children:o.map(([s,a])=>Y.jsx(j.PrintFloatDomSingle,{layer:a,id:s,position:a.position},s))})};var On=Object.getOwnPropertyDescriptor,An=(i,r,e,t)=>{for(var n=t>1?void 0:t?On(r,e):r,o=i.length-1,s;o>=0;o--)(s=i[o])&&(n=s(n)||n);return n},ye=(i,r)=>(e,t)=>r(e,t,i);let it=class extends l.Disposable{constructor(i,r,e,t,n,o,s){super(),this._sheetPrintInterceptorService=i,this._drawingRenderService=r,this._drawingManagerService=e,this._renderManagerService=t,this._canvasFloatDomManagerService=n,this._componetManager=o,this._injector=s,this._initPrinting(),this._initPrintingDom()}_initPrinting(){this.disposeWithMe(this._sheetPrintInterceptorService.interceptor.intercept(this._sheetPrintInterceptorService.interceptor.getInterceptPoints().PRINTING_COMPONENT_COLLECT,{handler:(i,r,e)=>{const{unitId:t,scene:n,subUnitId:o}=r,s=this._drawingManagerService.getDrawingDataForUnit(t),a=s==null?void 0:s[o];return a&&a.order.forEach(c=>{const g=a.data[c];g.drawingType!==l.DrawingTypeEnum.DRAWING_CHART&&g.drawingType!==l.DrawingTypeEnum.DRAWING_DOM&&this._drawingRenderService.renderDrawing(g,n)}),e()}})),this.disposeWithMe(this._sheetPrintInterceptorService.interceptor.intercept(this._sheetPrintInterceptorService.interceptor.getInterceptPoints().PRINTING_RANGE,{handler:(i,r,e)=>{const{unitId:t,subUnitId:n}=r,o=this._renderManagerService.getRenderById(t);if(!o)return e(i);const s=o.with(U.SheetSkeletonManagerService).getSkeletonParam(n);if(!s)return e(i);const a=this._drawingManagerService.getDrawingDataForUnit(t),c=a==null?void 0:a[r.subUnitId];if(!c)return e(i);const{scaleX:g,scaleY:u}=o.scene,d=i?{...i}:{startColumn:0,endColumn:0,endRow:0,startRow:0},m=c.order.map(h=>c.data[h]);return m.length?(m.forEach(h=>{if(!h.groupId&&h.transform&&l.Tools.isDefine(h.transform.left)&&l.Tools.isDefine(h.transform.top)&&l.Tools.isDefine(h.transform.width)&&l.Tools.isDefine(h.transform.height)){const p=s.skeleton.getCellIndexByOffset(h.transform.left,h.transform.top,g,u,{x:0,y:0}),S=s.skeleton.getCellIndexByOffset(h.transform.left+h.transform.width,h.transform.top+h.transform.height,g,u,{x:0,y:0});p.column<d.startColumn&&(d.startColumn=p.column),p.row<d.startRow&&(d.startRow=p.row),d.endRow<S.row&&(d.endRow=S.row),d.endColumn<S.column&&(d.endColumn=S.column)}}),e(d)):e(i)}}))}_initPrintingDom(){this.disposeWithMe(this._sheetPrintInterceptorService.interceptor.intercept(this._sheetPrintInterceptorService.interceptor.getInterceptPoints().PRINTING_DOM_COLLECT,{handler:(i,r,e)=>{const{unitId:t,subUnitId:n}=r,o=this._drawingManagerService.getDrawingDataForUnit(t),s=o==null?void 0:o[n];if(s){const a=s.order.map(g=>{const u=s.data[g];if(u.drawingType===l.DrawingTypeEnum.DRAWING_CHART)return{...u,componentKey:this._componetManager.get(l.PRINT_CHART_COMPONENT_KEY)};if(u.drawingType===l.DrawingTypeEnum.DRAWING_DOM){const d=this._sheetPrintInterceptorService.getPrintComponent(u.componentKey);return{...u,componentKey:this._componetManager.get(d||u.componentKey)}}return null}).filter(Boolean),c=j.connectInjector(bn,this._injector);return X.render(Y.jsx(c,{floatDomInfos:a,scene:r.scene,skeleton:r.skeleton,worksheet:r.worksheet}),r.root),i==null||i.add(()=>{X.unmount(r.root)}),e(i)}}}))}};it=An([ye(0,l.Inject(U.SheetPrintInterceptorService)),ye(1,l.Inject(Se.DrawingRenderService)),ye(2,B.IDrawingManagerService),ye(3,N.IRenderManagerService),ye(4,l.Inject(A.SheetCanvasFloatDomManagerService)),ye(5,l.Inject(j.ComponentManager)),ye(6,l.Inject(l.Injector))],it);var Un=Object.getOwnPropertyDescriptor,Pn=(i,r,e,t)=>{for(var n=t>1?void 0:t?Un(r,e):r,o=i.length-1,s;o>=0;o--)(s=i[o])&&(n=s(n)||n);return n},we=(i,r)=>(e,t)=>r(e,t,i);const Nn=[y.InsertRowCommand.id,y.InsertColCommand.id,y.RemoveRowCommand.id,y.RemoveColCommand.id,y.DeleteRangeMoveLeftCommand.id,y.DeleteRangeMoveUpCommand.id,y.InsertRangeMoveDownCommand.id,y.InsertRangeMoveRightCommand.id,y.DeltaRowHeightCommand.id,y.SetRowHeightCommand.id,y.DeltaColumnWidthCommand.id,y.SetColWidthCommand.id,y.SetRowHiddenCommand.id,y.SetSpecificRowsVisibleCommand.id,y.SetSpecificColsVisibleCommand.id,y.SetColHiddenCommand.id,y.MoveColsCommand.id,y.MoveRowsCommand.id,y.MoveRangeCommand.id],kn=[y.SetRowVisibleMutation.id,y.SetRowHiddenMutation.id,y.SetColVisibleMutation.id,y.SetColHiddenMutation.id,y.SetWorksheetRowHeightMutation.id,y.SetWorksheetRowAutoHeightMutation.id,y.SetWorksheetRowIsAutoHeightMutation.id,y.SetWorksheetColWidthMutation.id];let Tt=class extends l.Disposable{constructor(i,r,e,t,n,o,s,a,c){super(),this._context=i,this._renderManagerService=r,this._commandService=e,this._selectionRenderService=t,this._skeletonManagerService=n,this._sheetInterceptorService=o,this._sheetDrawingService=s,this._drawingManagerService=a,this._univerInstanceService=c,this._sheetInterceptorListener(),this._commandListener(),this._sheetRefreshListener()}_sheetInterceptorListener(){this.disposeWithMe(this._sheetInterceptorService.interceptAfterCommand({getMutations:i=>{if(!Nn.includes(i.id))return{redos:[],undos:[]};if(i.params==null)return{redos:[],undos:[]};const r=i.id;if(r===y.InsertRowCommand.id)return this._moveRowInterceptor(i.params,"insert");if([y.MoveColsCommand.id,y.MoveRowsCommand.id,y.MoveRangeCommand.id].includes(r))return this._moveRangeInterceptor(i.params);if(r===y.InsertColCommand.id)return this._moveColInterceptor(i.params,"insert");if(r===y.RemoveRowCommand.id)return this._moveRowInterceptor(i.params,"remove");if(r===y.RemoveColCommand.id)return this._moveColInterceptor(i.params,"remove");if(r===y.DeleteRangeMoveLeftCommand.id){const{range:e}=i.params;return this._getRangeMoveUndo(e,0)}else if(r===y.DeleteRangeMoveUpCommand.id){const{range:e}=i.params;return this._getRangeMoveUndo(e,1)}else if(r===y.InsertRangeMoveDownCommand.id){const{range:e}=i.params;return this._getRangeMoveUndo(e,2)}else if(r===y.InsertRangeMoveRightCommand.id){const{range:e}=i.params;return this._getRangeMoveUndo(e,3)}else if(r===y.SetRowHiddenCommand.id||r===y.SetSpecificRowsVisibleCommand.id){const e=i.params,{unitId:t,subUnitId:n,ranges:o}=e;return this._getDrawingUndoForRowVisible(t,n,o)}else if(r===y.SetSpecificColsVisibleCommand.id||r===y.SetColHiddenCommand.id){const e=i.params,{unitId:t,subUnitId:n,ranges:o}=e;return this._getDrawingUndoForColVisible(t,n,o)}else if(r===y.DeltaRowHeightCommand.id||r===y.SetRowHeightCommand.id||r===y.DeltaColumnWidthCommand.id||r===y.SetColWidthCommand.id){const e=i.params,{unitId:t,subUnitId:n,ranges:o}=e,s=r===y.DeltaRowHeightCommand.id||r===y.SetRowHeightCommand.id;return this._getDrawingUndoForRowAndColSize(t,n,o,s)}return{redos:[],undos:[]}}}))}_getRangeMoveUndo(i,r){const e=y.getSheetCommandTarget(this._univerInstanceService);if(e==null)return{redos:[],undos:[]};const t=e.unitId,n=e.subUnitId,o=[],s=[],a=this._sheetDrawingService.getDrawingData(t,n),c=[],g=[];if(Object.keys(a).forEach(u=>{const d=a[u],{updateDrawings:m,deleteDrawings:h}=this._getUpdateOrDeleteDrawings(i,r,d);c.push(...m),g.push(...h)}),c.length===0&&g.length===0)return{redos:[],undos:[]};if(c.length>0){const u=this._sheetDrawingService.getBatchUpdateOp(c),{undo:d,redo:m,objects:h}=u;o.push({id:w.SetDrawingApplyMutation.id,params:{unitId:t,subUnitId:n,op:m,objects:h,type:w.DrawingApplyType.UPDATE}}),s.push({id:w.SetDrawingApplyMutation.id,params:{unitId:t,subUnitId:n,op:d,objects:h,type:w.DrawingApplyType.UPDATE}})}if(g.length>0){const u=this._sheetDrawingService.getBatchRemoveOp(g),d=u.undo,m=u.redo,h=u.objects;o.push({id:w.SetDrawingApplyMutation.id,params:{unitId:t,subUnitId:n,op:m,objects:h,type:w.DrawingApplyType.REMOVE}}),s.push({id:w.SetDrawingApplyMutation.id,params:{unitId:t,subUnitId:n,op:d,objects:h,type:w.DrawingApplyType.INSERT}})}return o.push({id:K.id,params:[t]}),s.push({id:K.id,params:[t]}),{redos:o,undos:s}}_getUpdateOrDeleteDrawings(i,r,e){var R,k,E,P;const t=[],n=[],{sheetTransform:o,anchorType:s=w.SheetDrawingAnchorType.Position,transform:a,unitId:c,subUnitId:g,drawingId:u}=e,{from:d,to:m}=o,{row:h,column:p}=d,{row:S,column:f}=m;if(o==null||a==null)return{updateDrawings:t,deleteDrawings:n};const{startRow:v,endRow:I,startColumn:T,endColumn:O}=i;let D=null,C=null,M;if(r===0&&h>=v&&S<=I)if(p>=T&&f<=O)n.push({unitId:c,subUnitId:g,drawingId:u});else{const _=this._shrinkCol(o,a,T,O,s);D=_==null?void 0:_.newSheetTransform,C=_==null?void 0:_.newTransform,M=(R=_==null?void 0:_.axisAlignSheetTransform)!=null?R:void 0}else if(r===1&&p>=T&&f<=O)if(h>=v&&S<=I)n.push({unitId:c,subUnitId:g,drawingId:u});else{const _=this._shrinkRow(o,a,v,I,s);D=_==null?void 0:_.newSheetTransform,C=_==null?void 0:_.newTransform,M=(k=_==null?void 0:_.axisAlignSheetTransform)!=null?k:void 0}else if(r===2){const _=this._expandRow(o,a,v,I,s);D=_==null?void 0:_.newSheetTransform,C=_==null?void 0:_.newTransform,M=(E=_==null?void 0:_.axisAlignSheetTransform)!=null?E:void 0}else if(r===3){const _=this._expandCol(o,a,T,O,s);D=_==null?void 0:_.newSheetTransform,C=_==null?void 0:_.newTransform,M=(P=_==null?void 0:_.axisAlignSheetTransform)!=null?P:void 0}if(D!=null&&C!=null){const _=te(D,this._selectionRenderService,this._skeletonManagerService);t.push({...e,sheetTransform:D,transform:_,axisAlignSheetTransform:M})}return{updateDrawings:t,deleteDrawings:n}}_remainDrawingSize(i,r,e){const t=x({...i},this._selectionRenderService);if(t!=null){const n=G({...i},this._selectionRenderService);r.push({...e,sheetTransform:t,axisAlignSheetTransform:n})}}_getDrawingUndoForColVisible(i,r,e){const t=this._drawingManagerService.getDrawingData(i,r),n=[],o=[];if(Object.keys(t).forEach(u=>{const d=t[u],{sheetTransform:m,transform:h,anchorType:p=w.SheetDrawingAnchorType.Position}=d;if(p===w.SheetDrawingAnchorType.None)this._remainDrawingSize(h,n,d);else{const{from:S,to:f}=m,{row:v,column:I}=S,{row:T,column:O}=f;for(let D=0;D<e.length;D++){const C=e[D],{startRow:M,endRow:R,startColumn:k,endColumn:E}=C;if(O<k)continue;if(p===w.SheetDrawingAnchorType.Position){let b=null,F=null;if(I>=k&&I<=E){const L=this._skeletonManagerService.attachRangeWithCoord({startColumn:I,endColumn:E,startRow:S.row,endRow:f.row});if(L==null)return;F={...h,left:L.startX}}if(F!=null){b=x(F,this._selectionRenderService);const L=G(F,this._selectionRenderService);if(b!=null&&F!=null){n.push({...d,sheetTransform:b,transform:F,axisAlignSheetTransform:L});break}}this._remainDrawingSize(h,n,d);continue}if(I>=k&&O<=E)continue;let P=null,_=null;if(I>=k&&I<=E){const b=this._skeletonManagerService.attachRangeWithCoord({startColumn:I,endColumn:E,startRow:S.row,endRow:f.row});if(b==null)return;_={...h,left:(b==null?void 0:b.startX)||0,width:((h==null?void 0:h.width)||0)-b.endX+b.startX}}else if(O>=k&&O<=E){const b=this._skeletonManagerService.attachRangeWithCoord({startColumn:k,endColumn:O,startRow:S.row,endRow:f.row});if(b==null)return;_={...h,left:b.startX-((h==null?void 0:h.width)||0)}}else{const b=this._skeletonManagerService.attachRangeWithCoord({startColumn:k,endColumn:E,startRow:S.row,endRow:f.row});if(b==null)return;if(_={...h,width:((h==null?void 0:h.width)||0)-b.endX+b.startX},P=x(_,this._selectionRenderService),P!=null&&_!=null){const F=G(_,this._selectionRenderService);o.push({...d,sheetTransform:P,transform:_,axisAlignSheetTransform:F});break}}if(_!=null&&(P=x(_,this._selectionRenderService)),_!=null&&P!=null){const b=G(_,this._selectionRenderService);n.push({...d,sheetTransform:P,transform:_,axisAlignSheetTransform:b});break}else this._remainDrawingSize(h,n,d)}}}),n.length===0&&o.length===0)return{redos:[],undos:[]};const{redos:s,undos:a}=this._createUndoAndRedoMutation(i,r,n),c=[],g=[];if(o.length>0){const{redos:u,undos:d}=this._createUndoAndRedoMutation(i,r,o);c.push(...u),g.push(...d)}return{redos:s,undos:a,preRedos:c,preUndos:g}}_createUndoAndRedoMutation(i,r,e){const t=this._sheetDrawingService.getBatchUpdateOp(e),{undo:n,redo:o,objects:s}=t,a=[{id:w.SetDrawingApplyMutation.id,params:{unitId:i,subUnitId:r,op:o,objects:s,type:w.DrawingApplyType.UPDATE}},{id:K.id,params:[i]}],c=[{id:w.SetDrawingApplyMutation.id,params:{unitId:i,subUnitId:r,op:n,objects:s,type:w.DrawingApplyType.UPDATE}},{id:K.id,params:[i]}];return{redos:a,undos:c}}_getDrawingUndoForRowVisible(i,r,e){const t=this._drawingManagerService.getDrawingData(i,r),n=[],o=[];if(Object.keys(t).forEach(u=>{const d=t[u],{sheetTransform:m,transform:h,anchorType:p=w.SheetDrawingAnchorType.Position}=d;if(p===w.SheetDrawingAnchorType.None)this._remainDrawingSize(h,n,d);else{const{from:S,to:f}=m,{row:v,column:I}=S,{row:T,column:O}=f;for(let D=0;D<e.length;D++){const C=e[D],{startRow:M,endRow:R,startColumn:k,endColumn:E}=C;if(T<M)continue;if(p===w.SheetDrawingAnchorType.Position){let b=null,F=null;if(v>=M&&v<=R){const L=this._skeletonManagerService.attachRangeWithCoord({startColumn:S.column,endColumn:f.column,startRow:v,endRow:R});if(L==null)return;F={...h,top:L.startY}}if(F!=null){b=x(F,this._selectionRenderService);const L=G(F,this._selectionRenderService);if(b!=null&&F!=null){n.push({...d,sheetTransform:b,transform:F,axisAlignSheetTransform:L});break}}this._remainDrawingSize(h,n,d);continue}if(v>=M&&T<=R)continue;let P=null,_=null;if(v>=M&&v<=R){const b=this._skeletonManagerService.attachRangeWithCoord({startColumn:S.column,endColumn:f.column,startRow:v,endRow:R});if(b==null)return;_={...h,top:(b==null?void 0:b.startY)||0,height:((h==null?void 0:h.height)||0)-b.endY+b.startY}}else if(T>=M&&T<=R){const b=this._skeletonManagerService.attachRangeWithCoord({startColumn:S.column,endColumn:f.column,startRow:M,endRow:T});if(b==null)return;_={...h,top:b.startY-((h==null?void 0:h.height)||0)}}else{const b=this._skeletonManagerService.attachRangeWithCoord({startColumn:S.column,endColumn:f.column,startRow:M,endRow:R});if(b==null)return;if(_={...h,height:((h==null?void 0:h.height)||0)-b.endY+b.startY},P=x(_,this._selectionRenderService),P!=null&&_!=null){const F=G(_,this._selectionRenderService);o.push({...d,sheetTransform:P,transform:_,axisAlignSheetTransform:F});break}}if(_!=null&&(P=x(_,this._selectionRenderService)),_!=null&&P!=null){const b=G(_,this._selectionRenderService);n.push({...d,sheetTransform:P,transform:_,axisAlignSheetTransform:b});break}else this._remainDrawingSize(h,n,d)}}}),n.length===0&&o.length===0)return{redos:[],undos:[]};const{redos:s,undos:a}=this._createUndoAndRedoMutation(i,r,n),c=[],g=[];if(o.length>0){const{redos:u,undos:d}=this._createUndoAndRedoMutation(i,r,o);c.push(...u),g.push(...d)}return{redos:s,undos:a,preRedos:c,preUndos:g}}_getDrawingUndoForRowAndColSize(i,r,e,t){const n=this._drawingManagerService.getDrawingData(i,r),o=[];return Object.keys(n).forEach(s=>{const a=n[s],{sheetTransform:c,transform:g,anchorType:u=w.SheetDrawingAnchorType.Position}=a;if(u===w.SheetDrawingAnchorType.None)this._remainDrawingSize(g,o,a);else{const{from:d,to:m}=c,{row:h,column:p}=d,{row:S,column:f}=m;for(let v=0;v<e.length;v++){const I=e[v],{startRow:T,endRow:O,startColumn:D,endColumn:C}=I;if(S<T||f<D)continue;if(u===w.SheetDrawingAnchorType.Position&&(h<=T&&S>=O||p<=D&&f>=C)){this._remainDrawingSize(g,o,a);continue}const M=te({...c},this._selectionRenderService,this._skeletonManagerService);if(M!=null){o.push({...a,transform:M});break}}}}),o.length===0?{redos:[],undos:[]}:this._createUndoAndRedoMutation(i,r,o)}_getUnitIdAndSubUnitId(i,r){let e,t;if(r==="insert")e=i.unitId,t=i.subUnitId;else{const n=y.getSheetCommandTarget(this._univerInstanceService);if(n==null)return;e=n.unitId,t=n.subUnitId}return{unitId:e,subUnitId:t}}_moveRangeInterceptor(i){var T,O;const{toRange:r,fromRange:e}=i,t=y.getSheetCommandTarget(this._univerInstanceService);if(!t)return{redos:[],undos:[]};const{unitId:n,subUnitId:o}=t,s=(O=(T=this._renderManagerService.getRenderById(n))==null?void 0:T.with(U.SheetSkeletonManagerService))==null?void 0:O.getCurrentSkeleton();if(!s)return{redos:[],undos:[]};const a=U.attachRangeWithCoord(s,e);if(!a)return{redos:[],undos:[]};const{startX:c,endX:g,startY:u,endY:d}=a,m=this._sheetDrawingService.getDrawingData(n,o),h=[];Object.keys(m).forEach(D=>{const C=m[D];if(C.anchorType!==w.SheetDrawingAnchorType.Both)return;const{transform:M}=C;if(!M)return;const{left:R=0,top:k=0,width:E=0,height:P=0}=M,{drawingStartX:_,drawingEndX:b,drawingStartY:F,drawingEndY:L}={drawingStartX:R,drawingEndX:R+E,drawingStartY:k,drawingEndY:k+P};c<=_&&b<=g&&u<=F&&L<=d&&h.push(C)});const p=[],S=[],f=r.startRow-e.startRow,v=r.startColumn-e.startColumn,I=h.map(D=>{const C=D.sheetTransform,M={to:{...C.to,row:C.to.row+f,column:C.to.column+v},from:{...C.from,row:C.from.row+f,column:C.from.column+v}},R=te(M,this._selectionRenderService,this._skeletonManagerService);return{unitId:n,subUnitId:o,drawingId:D.drawingId,transform:R,sheetTransform:M}});if(I.length){const D=this._sheetDrawingService.getBatchUpdateOp(I),{undo:C,redo:M,objects:R}=D;p.push({id:w.SetDrawingApplyMutation.id,params:{unitId:n,subUnitId:o,op:M,objects:R,type:w.DrawingApplyType.UPDATE}}),S.push({id:w.SetDrawingApplyMutation.id,params:{unitId:n,subUnitId:o,op:C,objects:R,type:w.DrawingApplyType.UPDATE}})}return{redos:p,undos:S}}_moveRowInterceptor(i,r){const e=this._getUnitIdAndSubUnitId(i,r);if(e==null)return{redos:[],undos:[]};const{unitId:t,subUnitId:n}=e,{range:o}=i,s=o.startRow,a=o.endRow,c=[],g=[],u=this._sheetDrawingService.getDrawingData(t,n),d=[],m=[];if(Object.keys(u).forEach(h=>{var C,M;const p=u[h],{sheetTransform:S,transform:f,anchorType:v=w.SheetDrawingAnchorType.Position}=p;if(S==null||f==null)return;let I,T,O;if(r==="insert"){const R=this._expandRow(S,f,s,a,v);I=R==null?void 0:R.newSheetTransform,T=R==null?void 0:R.newTransform,O=(C=R==null?void 0:R.axisAlignSheetTransform)!=null?C:void 0}else{const{from:R,to:k}=S,{row:E}=R,{row:P}=k;if(v===w.SheetDrawingAnchorType.Both&&E>=s&&P<=a)m.push({unitId:t,subUnitId:n,drawingId:h});else{const _=this._shrinkRow(S,f,s,a,v);I=_==null?void 0:_.newSheetTransform,T=_==null?void 0:_.newTransform,O=(M=_==null?void 0:_.axisAlignSheetTransform)!=null?M:void 0}}if(!I||!T)return;const D={unitId:t,subUnitId:n,drawingId:h,transform:T,sheetTransform:I,axisAlignSheetTransform:O};d.push(D)}),d.length===0&&m.length===0)return{redos:[],undos:[]};if(d.length>0){const h=this._sheetDrawingService.getBatchUpdateOp(d),{undo:p,redo:S,objects:f}=h;c.push({id:w.SetDrawingApplyMutation.id,params:{unitId:t,subUnitId:n,op:S,objects:f,type:w.DrawingApplyType.UPDATE}}),g.push({id:w.SetDrawingApplyMutation.id,params:{unitId:t,subUnitId:n,op:p,objects:f,type:w.DrawingApplyType.UPDATE}})}if(m.length>0){const h=this._sheetDrawingService.getBatchRemoveOp(m),p=h.undo,S=h.redo,f=h.objects;c.push({id:w.SetDrawingApplyMutation.id,params:{unitId:t,subUnitId:n,op:S,objects:f,type:w.DrawingApplyType.REMOVE}}),g.push({id:w.SetDrawingApplyMutation.id,params:{unitId:t,subUnitId:n,op:p,objects:f,type:w.DrawingApplyType.INSERT}})}return c.push({id:K.id,params:[t]}),g.push({id:K.id,params:[t]}),{redos:c,undos:g}}_moveColInterceptor(i,r){const e=this._getUnitIdAndSubUnitId(i,r);if(e==null)return{redos:[],undos:[]};const{unitId:t,subUnitId:n}=e,{range:o}=i,s=o.startColumn,a=o.endColumn,c=[],g=[],u=this._sheetDrawingService.getDrawingData(t,n),d=[],m=[];if(Object.keys(u).forEach(h=>{var C,M;const p=u[h],{sheetTransform:S,transform:f,anchorType:v=w.SheetDrawingAnchorType.Position}=p;if(S==null||f==null)return;let I,T,O;if(r==="insert"){const R=this._expandCol(S,f,s,a,v);I=R==null?void 0:R.newSheetTransform,T=R==null?void 0:R.newTransform,O=(C=R==null?void 0:R.axisAlignSheetTransform)!=null?C:void 0}else{const{from:R,to:k}=S,{column:E}=R,{column:P}=k;if(v===w.SheetDrawingAnchorType.Both&&E>=s&&P<=a)m.push({unitId:t,subUnitId:n,drawingId:h});else{const _=this._shrinkCol(S,f,s,a,v);I=_==null?void 0:_.newSheetTransform,T=_==null?void 0:_.newTransform,O=(M=_==null?void 0:_.axisAlignSheetTransform)!=null?M:void 0}}if(!I||!T)return;const D={unitId:t,subUnitId:n,drawingId:h,transform:T,sheetTransform:I,axisAlignSheetTransform:O};d.push(D)}),d.length===0&&m.length===0)return{redos:[],undos:[]};if(d.length>0){const h=this._sheetDrawingService.getBatchUpdateOp(d),{undo:p,redo:S,objects:f}=h;c.push({id:w.SetDrawingApplyMutation.id,params:{unitId:t,subUnitId:n,op:S,objects:f,type:w.DrawingApplyType.UPDATE}}),g.push({id:w.SetDrawingApplyMutation.id,params:{unitId:t,subUnitId:n,op:p,objects:f,type:w.DrawingApplyType.UPDATE}})}if(m.length>0){const h=this._sheetDrawingService.getBatchRemoveOp(m),p=h.undo,S=h.redo,f=h.objects;c.push({id:w.SetDrawingApplyMutation.id,params:{unitId:t,subUnitId:n,op:S,objects:f,type:w.DrawingApplyType.REMOVE}}),g.push({id:w.SetDrawingApplyMutation.id,params:{unitId:t,subUnitId:n,op:p,objects:f,type:w.DrawingApplyType.INSERT}})}return c.push({id:K.id,params:[t]}),g.push({id:K.id,params:[t]}),{redos:c,undos:g}}_expandCol(i,r,e,t,n=w.SheetDrawingAnchorType.Position){const o=t-e+1,{from:s,to:a}=i,{column:c}=s,{column:g}=a;if(n===w.SheetDrawingAnchorType.None)return{newSheetTransform:x({...r},this._selectionRenderService),newTransform:r,axisAlignSheetTransform:G({...r},this._selectionRenderService)};let u=null,d=null,m=null;if(c>=e){const h=this._skeletonManagerService.attachRangeWithCoord({startColumn:e,endColumn:t,startRow:s.row,endRow:a.row});if(h==null)return;d={...r,left:(r.left||0)+h.endX-h.startX},u=x(d,this._selectionRenderService),m=G(d,this._selectionRenderService)}else if(g>=t)if(n===w.SheetDrawingAnchorType.Both)u={from:{...s},to:{...a,column:g+o}},d=te(u,this._selectionRenderService,this._skeletonManagerService);else return{newSheetTransform:x({...r},this._selectionRenderService),newTransform:r,axisAlignSheetTransform:G({...r},this._selectionRenderService)};return u!=null&&d!=null?{newSheetTransform:u,newTransform:d,axisAlignSheetTransform:m}:null}_shrinkCol(i,r,e,t,n=w.SheetDrawingAnchorType.Position){const o=t-e+1,{from:s,to:a}=i,{column:c}=s,{column:g}=a;if(n===w.SheetDrawingAnchorType.None)return{newSheetTransform:x({...r},this._selectionRenderService),newTransform:r,axisAlignSheetTransform:G({...r},this._selectionRenderService)};let u=null,d=null,m=null;if(c>t)u={from:{...s,column:c-o},to:{...a,column:g-o}},d=te(u,this._selectionRenderService,this._skeletonManagerService);else{if(c>=e&&g<=t)return null;if(c<e&&g>t)if(n===w.SheetDrawingAnchorType.Both)u={from:{...s},to:{...a,column:g-o}},d=te(u,this._selectionRenderService,this._skeletonManagerService);else return{newSheetTransform:x({...r},this._selectionRenderService),newTransform:r,axisAlignSheetTransform:G({...r},this._selectionRenderService)};else if(c>=e&&c<=t){if(c===e)d={...r,left:(r.left||0)-i.from.columnOffset};else{const h=this._skeletonManagerService.attachRangeWithCoord({startColumn:e,endColumn:c-1,startRow:s.row,endRow:a.row});if(h==null)return;d={...r,left:(r.left||0)-h.endX+h.startX-i.from.columnOffset}}u=x(d,this._selectionRenderService),m=G(d,this._selectionRenderService)}else if(g>=e&&g<=t&&n===w.SheetDrawingAnchorType.Both){const h=this._skeletonManagerService.attachRangeWithCoord({startColumn:e-1,endColumn:e-1,startRow:s.row,endRow:a.row});if(h==null)return;u={from:{...s},to:{...a,column:e-1,columnOffset:h.endX-h.startX}},d=te(u,this._selectionRenderService,this._skeletonManagerService)}}return u!=null&&d!=null?{newSheetTransform:u,newTransform:d,axisAlignSheetTransform:m}:null}_expandRow(i,r,e,t,n=w.SheetDrawingAnchorType.Position){const o=t-e+1,{from:s,to:a}=i,{row:c}=s,{row:g}=a;if(n===w.SheetDrawingAnchorType.None)return{newSheetTransform:x({...r},this._selectionRenderService),newTransform:r,axisAlignSheetTransform:G({...r},this._selectionRenderService)};let u=null,d=null,m=null;if(c>=e){const h=this._skeletonManagerService.attachRangeWithCoord({startRow:e,endRow:t,startColumn:s.column,endColumn:a.column});if(h==null)return;d={...r,top:(r.top||0)+h.endY-h.startY},u=x(d,this._selectionRenderService),m=G(d,this._selectionRenderService)}else if(g>=t)if(n===w.SheetDrawingAnchorType.Both)u={from:{...s},to:{...a,row:g+o}},d=te(u,this._selectionRenderService,this._skeletonManagerService);else return{newSheetTransform:x({...r},this._selectionRenderService),newTransform:r,axisAlignSheetTransform:G({...r},this._selectionRenderService)};return u!=null&&d!=null?{newSheetTransform:u,newTransform:d,axisAlignSheetTransform:m}:null}_shrinkRow(i,r,e,t,n=w.SheetDrawingAnchorType.Position){const o=t-e+1,{from:s,to:a}=i,{row:c}=s,{row:g}=a;if(n===w.SheetDrawingAnchorType.None)return{newSheetTransform:x({...r},this._selectionRenderService),newTransform:r,axisAlignSheetTransform:G({...r},this._selectionRenderService)};let u=null,d=null,m=null;if(c>t)u={from:{...s,row:c-o},to:{...a,row:g-o}},d=te(u,this._selectionRenderService,this._skeletonManagerService);else{if(c>=e&&g<=t)return null;if(c<e&&g>t)if(n===w.SheetDrawingAnchorType.Both)u={from:{...s},to:{...a,row:g-o}},d=te(u,this._selectionRenderService,this._skeletonManagerService);else return{newSheetTransform:x({...r},this._selectionRenderService),newTransform:r,axisAlignSheetTransform:G({...r},this._selectionRenderService)};else if(c>=e&&c<=t){if(c===e)d={...r,top:(r.top||0)-i.from.rowOffset};else{const h=this._skeletonManagerService.attachRangeWithCoord({startRow:e,endRow:c-1,startColumn:s.column,endColumn:a.column});if(h==null)return;d={...r,top:(r.top||0)-h.endY+h.startY-i.from.rowOffset}}u=x(d,this._selectionRenderService),m=G(d,this._selectionRenderService)}else if(g>=e&&g<=t&&n===w.SheetDrawingAnchorType.Both){const h=this._skeletonManagerService.attachRangeWithCoord({startColumn:s.column,endColumn:s.column,startRow:e-1,endRow:e-1});if(h==null)return;u={from:{...s},to:{...a,row:e-1,rowOffset:h.endY-h.startY}},d=te(u,this._selectionRenderService,this._skeletonManagerService)}}return u!=null&&d!=null?{newSheetTransform:u,newTransform:d,axisAlignSheetTransform:m}:null}_commandListener(){this.disposeWithMe(this._commandService.onCommandExecuted(i=>{if(i.id===y.SetWorksheetActiveOperation.id){const{unitId:r,subUnitId:e}=i.params;this._updateDrawings(r,e)}})),this.disposeWithMe(this._context.activated$.subscribe(i=>{const{unit:r,unitId:e}=this._context;if(i){const t=r.getActiveSheet().getSheetId();this._updateDrawings(e,t)}else this._clearDrawings(e)}))}_clearDrawings(i){setTimeout(()=>{const r=this._drawingManagerService.drawingManagerData,e=[];Object.keys(r).forEach(t=>{const n=r[t];n!=null&&Object.keys(n).forEach(o=>{const s=n[o].data;s!=null&&Object.keys(s).forEach(a=>{t===i&&e.push(s[a])})})}),this._sheetDrawingService.removeNotification(e),this._drawingManagerService.removeNotification(e)})}_updateDrawings(i,r){setTimeout(()=>{const e=this._drawingManagerService.drawingManagerData,t=[],n=[];Object.keys(e).forEach(o=>{const s=e[o];s!=null&&Object.keys(s).forEach(a=>{const c=s[a].data;c!=null&&Object.keys(c).forEach(g=>{if(o===i&&a===r){const u=c[g];u.transform=te(u.sheetTransform,this._selectionRenderService,this._skeletonManagerService),t.push(c[g])}else n.push(c[g])})})}),this._sheetDrawingService.removeNotification(n),this._sheetDrawingService.addNotification(t),this._drawingManagerService.removeNotification(n),this._drawingManagerService.addNotification(t)},0)}_sheetRefreshListener(){this.disposeWithMe(this._commandService.onCommandExecuted(i=>{kn.includes(i.id)&&requestIdleCallback(()=>{const r=i.params,e=y.getSheetCommandTarget(this._univerInstanceService,r);if(!e)return;const{unitId:t,subUnitId:n,worksheet:o}=e;let s=[];"ranges"in r?s=r.ranges:"rowsAutoHeightInfo"in r&&(s=r.rowsAutoHeightInfo.map(a=>({startRow:a.row,endRow:a.row,startColumn:0,endColumn:o.getColumnCount()-1}))),this._refreshDrawingTransform(t,n,s)})}))}_refreshDrawingTransform(i,r,e){const t=this._drawingManagerService.getDrawingData(i,r),n=[];Object.keys(t).forEach(o=>{const s=t[o],{sheetTransform:a,transform:c,anchorType:g=w.SheetDrawingAnchorType.Position}=s;if(g===w.SheetDrawingAnchorType.None)return!0;const{from:u,to:d}=a,{row:m,column:h}=u,{row:p,column:S}=d;for(let f=0;f<e.length;f++){const v=e[f],{startRow:I,endRow:T,startColumn:O,endColumn:D}=v;if(l.Rectangle.intersects({startRow:I,endRow:T,startColumn:O,endColumn:D},{startRow:m,endRow:p,startColumn:h,endColumn:S})||m>T||h>D){const C=g===w.SheetDrawingAnchorType.Position,M=te(a,this._selectionRenderService,this._skeletonManagerService);n.push({...s,transform:{...M,width:C?c==null?void 0:c.width:M==null?void 0:M.width,height:C?c==null?void 0:c.height:M==null?void 0:M.height}});break}}}),n.length!==0&&(this._sheetDrawingService.refreshTransform(n),this._drawingManagerService.refreshTransform(n),this._commandService.syncExecuteCommand(K.id,[i]))}};Tt=Pn([we(1,N.IRenderManagerService),we(2,l.ICommandService),we(3,U.ISheetSelectionRenderService),we(4,l.Inject(U.SheetSkeletonManagerService)),we(5,l.Inject(y.SheetInterceptorService)),we(6,w.ISheetDrawingService),we(7,B.IDrawingManagerService),we(8,l.IUniverInstanceService)],Tt);function Wn(){const i=j.useDependency(l.LocaleService),r=j.useDependency(j.IDialogService),e=j.useDependency(Ve),[t,n]=Q.useState([fe.CELL_ADDRESS]),[o,s]=Q.useState(!1),[a,c]=Q.useState(null),g=Q.useMemo(()=>e.getCellImagesInSelection(),[e]),u=Q.useMemo(()=>e.getDataColumns(),[e]),d=Q.useMemo(()=>e.getSelectionRowRange(),[e]),m=u.length>0,h=Q.useMemo(()=>u.map(C=>({label:C.label,value:String(C.index)})),[u]),[p,S]=Q.useState(()=>h.length>0?h[0].value:"0"),f=Q.useMemo(()=>{if(!t.includes(fe.COLUMN_VALUE)||!d)return[];const M=Number(p);return[{startRow:d.startRow,endRow:d.endRow,startColumn:M,endColumn:M}]},[t,p,d]);U.useHighlightRange(f);const v=Q.useCallback(C=>{C.length!==0&&n(C)},[]),I=Q.useCallback(C=>{S(String(C))},[]),T=Q.useCallback(()=>{r.close(Me)},[r]),O=Q.useCallback(async()=>{if(g.length!==0){s(!0),c(null);try{await e.saveImages(g,{fileNameParts:t,columnIndex:t.includes(fe.COLUMN_VALUE)?Number(p):void 0}),r.close(Me)}catch(C){console.error("Failed to save images:",C),c(i.t("sheetImage.save.error"))}finally{s(!1)}}},[e,g,t,p,r,i]),D=t.includes(fe.COLUMN_VALUE);return Y.jsxs("div",{className:"univer-flex univer-flex-col",children:[Y.jsx(X.FormLayout,{label:i.t("sheetImage.save.imageCount"),children:Y.jsx("div",{className:"univer-text-sm univer-text-gray-600",children:g.length})}),Y.jsx(X.FormLayout,{label:i.t("sheetImage.save.fileNameConfig"),children:Y.jsxs(X.CheckboxGroup,{value:t,onChange:v,direction:"vertical",children:[Y.jsx(X.Checkbox,{value:fe.CELL_ADDRESS,disabled:!m,children:i.t("sheetImage.save.useRowCol")}),m&&Y.jsx(X.Checkbox,{value:fe.COLUMN_VALUE,children:i.t("sheetImage.save.useColumnValue")})]})}),D&&Y.jsx(X.FormLayout,{label:i.t("sheetImage.save.selectColumn"),children:Y.jsx(X.Select,{value:p,options:h,onChange:I})}),a&&Y.jsx("div",{className:"univer-text-xs univer-text-red-500",children:a}),Y.jsxs("div",{className:"univer-flex univer-justify-end univer-gap-2 univer-border-t univer-border-gray-200 univer-pt-3",children:[Y.jsx(X.Button,{onClick:T,disabled:o,children:i.t("sheetImage.save.cancel")}),Y.jsx(X.Button,{variant:"primary",onClick:O,disabled:o||g.length===0,children:o?i.t("sheetImage.save.saving"):i.t("sheetImage.save.confirm")})]})]})}const xt=i=>{var I;const r=j.useDependency(l.ICommandService),e=j.useDependency(l.LocaleService),t=j.useDependency(B.IDrawingManagerService),n=j.useDependency(N.IRenderManagerService),{drawings:o}=i,s=o[0];if(s==null)return;const{unitId:a}=s,c=n.getRenderById(a),g=c==null?void 0:c.scene;if(g==null)return;const u=g.getTransformerByCreate(),[d,m]=Q.useState(!0),h=(I=s.anchorType)!=null?I:w.SheetDrawingAnchorType.Position,[p,S]=Q.useState(h);function f(T,O){const D=[];return T.forEach(C=>{const{oKey:M}=C,R=O.getDrawingOKey(M);if(R==null)return D.push(null),!0;const{unitId:k,subUnitId:E,drawingId:P,drawingType:_,anchorType:b,sheetTransform:F,axisAlignSheetTransform:L}=R;D.push({unitId:k,subUnitId:E,drawingId:P,anchorType:b,sheetTransform:F,drawingType:_,axisAlignSheetTransform:L})}),D}Q.useEffect(()=>{const T=u.clearControl$.subscribe(D=>{D===!0&&m(!1)}),O=u.changeStart$.subscribe(D=>{var R;const{objects:C}=D,M=f(C,t);if(M.length===0)m(!1);else if(M.length>=1){m(!0);const k=((R=M[0])==null?void 0:R.anchorType)||w.SheetDrawingAnchorType.Position;S(k)}});return()=>{O.unsubscribe(),T.unsubscribe()}},[]);function v(T){S(T);const O=t.getFocusDrawings();if(O.length===0)return;const D=O.map(C=>({unitId:C.unitId,subUnitId:C.subUnitId,drawingId:C.drawingId,anchorType:T}));r.executeCommand(De.id,{unitId:O[0].unitId,drawings:D})}return Y.jsxs("div",{className:X.clsx("univer-grid univer-gap-2 univer-py-2 univer-text-gray-400",{"univer-hidden":!d}),children:[Y.jsx("header",{className:"univer-text-gray-600 dark:!univer-text-gray-200",children:Y.jsx("div",{children:e.t("drawing-anchor.title")})}),Y.jsx("div",{children:Y.jsxs(X.RadioGroup,{value:p,onChange:v,direction:"vertical",children:[Y.jsx(X.Radio,{value:w.SheetDrawingAnchorType.Both,children:e.t("drawing-anchor.both")}),Y.jsx(X.Radio,{value:w.SheetDrawingAnchorType.Position,children:e.t("drawing-anchor.position")}),Y.jsx(X.Radio,{value:w.SheetDrawingAnchorType.None,children:e.t("drawing-anchor.none")})]})})]})},Bn=()=>{const i=j.useDependency(B.IDrawingManagerService),r=i.getFocusDrawings(),[e,t]=Q.useState(r);return Q.useEffect(()=>{const n=i.focus$.subscribe(o=>{t(o)});return()=>{n.unsubscribe()}},[]),!!(e!=null&&e.length)&&Y.jsxs("div",{className:"univer-text-sm",children:[Y.jsx(Se.DrawingCommonPanel,{drawings:e}),Y.jsx(xt,{drawings:e})]})},Mt="sheet.menu.image";function jn(i){return{id:Mt,type:j.MenuItemType.SUBITEMS,icon:"AddImageIcon",tooltip:"sheetImage.title",hidden$:j.getMenuHiddenObservable(i,l.UniverInstanceType.UNIVER_SHEET),disabled$:U.getCurrentRangeDisable$(i,{workbookTypes:[y.WorkbookEditablePermission],worksheetTypes:[y.WorksheetEditPermission],rangeTypes:[y.RangeProtectionPermissionEditPoint]})}}function Fn(i){return{id:ke.id,title:"sheetImage.upload.float",type:j.MenuItemType.BUTTON,hidden$:j.getMenuHiddenObservable(i,l.UniverInstanceType.UNIVER_SHEET)}}function Ln(i){return{id:ft.id,title:"sheetImage.upload.cell",type:j.MenuItemType.BUTTON,hidden$:j.getMenuHiddenObservable(i,l.UniverInstanceType.UNIVER_SHEET)}}function $n(i){var r,e,t,n;return!!((e=(r=i==null?void 0:i.p)==null?void 0:r.drawingsOrder)!=null&&e.length&&((n=(t=i==null?void 0:i.p)==null?void 0:t.drawingsOrder)==null?void 0:n.length)>0)}function Yn(i,r){const e=i.getActiveSheet();if(!e)return!1;const t=e.getCellMatrix(),{startRow:n,endRow:o,startColumn:s,endColumn:a}=r;for(let c=n;c<=o;c++)for(let g=s;g<=a;g++){const u=t.getValue(c,g);if($n(u))return!0}return!1}function xn(){return"showDirectoryPicker"in window}function Rt(i){const r=i.get(l.IUniverInstanceService),e=i.get(y.SheetsSelectionsService),t=W.combineLatest([j.getMenuHiddenObservable(i,l.UniverInstanceType.UNIVER_SHEET),r.getCurrentTypeOfUnit$(l.UniverInstanceType.UNIVER_SHEET).pipe(W.switchMap(n=>n?e.selectionMoveEnd$.pipe(W.map(()=>{if(!xn())return!0;const o=e.getCurrentSelections();if(!o||o.length===0)return!0;for(const s of o)if(Yn(n,s.range))return!1;return!0})):W.of(!0)))]).pipe(W.map(([n,o])=>n||o));return{id:Re.id,type:j.MenuItemType.BUTTON,icon:"DownloadImageIcon",title:"sheetImage.save.menuLabel",hidden$:t}}const Gn={[j.RibbonInsertGroup.MEDIA]:{[Mt]:{order:0,menuItemFactory:jn,[ke.id]:{order:0,menuItemFactory:Fn},[ft.id]:{order:1,menuItemFactory:Ln}}},[j.ContextMenuPosition.MAIN_AREA]:{[j.ContextMenuGroup.OTHERS]:{[Re.id]:{order:10,menuItemFactory:Rt}}},[j.ContextMenuPosition.COL_HEADER]:{[j.ContextMenuGroup.OTHERS]:{[Re.id]:{order:10,menuItemFactory:Rt}}},[j.ContextMenuPosition.ROW_HEADER]:{[j.ContextMenuGroup.OTHERS]:{[Re.id]:{order:10,menuItemFactory:Rt}}}};function Le(i){return i.getContextValue(l.FOCUSING_SHEET)&&!i.getContextValue(l.FOCUSING_FX_BAR_EDITOR)&&!i.getContextValue(l.FOCUSING_PANEL_EDITOR)&&i.getContextValue(l.FOCUSING_COMMON_DRAWINGS)&&!i.getContextValue(l.FOCUSING_SHAPE_TEXT_EDITOR)}const Hn={id:Te.id,description:"shortcut.drawing-move-down",group:"4_drawing-view",binding:j.KeyCode.ARROW_DOWN,priority:100,preconditions:Le,staticParameters:{direction:l.Direction.DOWN}},Vn={id:Te.id,description:"shortcut.drawing-move-up",group:"4_drawing-view",binding:j.KeyCode.ARROW_UP,priority:100,preconditions:Le,staticParameters:{direction:l.Direction.UP}},Xn={id:Te.id,description:"shortcut.drawing-move-left",group:"4_drawing-view",binding:j.KeyCode.ARROW_LEFT,priority:100,preconditions:Le,staticParameters:{direction:l.Direction.LEFT}},Kn={id:Te.id,description:"shortcut.drawing-move-right",group:"4_drawing-view",binding:j.KeyCode.ARROW_RIGHT,priority:100,preconditions:Le,staticParameters:{direction:l.Direction.RIGHT}},zn={id:gt.id,description:"shortcut.drawing-delete",group:"4_drawing-view",priority:100,preconditions:Le,binding:j.KeyCode.DELETE,mac:j.KeyCode.BACKSPACE};var qn=Object.getOwnPropertyDescriptor,Zn=(i,r,e,t)=>{for(var n=t>1?void 0:t?qn(r,e):r,o=i.length-1,s;o>=0;o--)(s=i[o])&&(n=s(n)||n);return n},be=(i,r)=>(e,t)=>r(e,t,i);let ot=class extends l.Disposable{constructor(i,r,e,t,n,o){super(),this._componentManager=i,this._menuManagerService=r,this._commandService=e,this._shortcutService=t,this._drawingManagerService=n,this._sheetsSelectionsService=o,this._init()}_initCustomComponents(){const i=this._componentManager;this.disposeWithMe(i.register(kt,Bn)),this.disposeWithMe(i.register(Me,Wn))}_initMenus(){this._menuManagerService.mergeMenu(Gn)}_initCommands(){[ke,ft,Ne,Ce,De,_t,K,It,ht,pt,Te,gt,mt,Re,yt].forEach(i=>this.disposeWithMe(this._commandService.registerCommand(i)))}_initShortcuts(){[Hn,Vn,Xn,Kn,zn].forEach(i=>{this.disposeWithMe(this._shortcutService.registerShortcut(i))})}_init(){this._initCommands(),this._initCustomComponents(),this._initMenus(),this._initShortcuts()}};ot=Zn([be(0,l.Inject(j.ComponentManager)),be(1,j.IMenuManagerService),be(2,l.ICommandService),be(3,j.IShortcutService),be(4,B.IDrawingManagerService),be(5,l.Inject(y.SheetsSelectionsService))],ot);var Jn=Object.defineProperty,Qn=Object.getOwnPropertyDescriptor,er=(i,r,e)=>r in i?Jn(i,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[r]=e,tr=(i,r,e,t)=>{for(var n=t>1?void 0:t?Qn(r,e):r,o=i.length-1,s;o>=0;o--)(s=i[o])&&(n=s(n)||n);return n},Et=(i,r)=>(e,t)=>r(e,t,i),Gt=(i,r,e)=>er(i,typeof r!="symbol"?r+"":r,e);const nr="SHEET_IMAGE_UI_PLUGIN";A.UniverSheetsDrawingUIPlugin=class extends l.Plugin{constructor(r=Wt,e,t,n){super(),this._config=r,this._injector=e,this._renderManagerService=t,this._configService=n;const{menu:o,...s}=l.merge({},Wt,this._config);o&&this._configService.setConfig("menu",o,{merge:!0}),this._configService.setConfig(on,s)}onStarting(){l.registerDependencies(this._injector,[[A.SheetCanvasFloatDomManagerService],[ot],[Ke],[it],[tt],[et],[Ze],[Je],[Qe],[Ve,{useClass:A.BatchSaveImagesService}]]),l.touchDependencies(this._injector,[[A.SheetCanvasFloatDomManagerService]])}onReady(){l.touchDependencies(this._injector,[[et],[Qe]])}onRendered(){this._registerRenderModules(),l.touchDependencies(this._injector,[[tt],[it],[ot],[Ze],[Je]])}onSteady(){this._injector.get(Ke)}_registerRenderModules(){[[A.SheetDrawingUpdateController],[Tt],[Dt],[Ct]].forEach(r=>{this.disposeWithMe(this._renderManagerService.registerRenderModule(l.UniverInstanceType.UNIVER_SHEET,r))})}},Gt(A.UniverSheetsDrawingUIPlugin,"type",l.UniverInstanceType.UNIVER_SHEET),Gt(A.UniverSheetsDrawingUIPlugin,"pluginName",nr),A.UniverSheetsDrawingUIPlugin=tr([l.DependentOn(B.UniverDrawingPlugin,At.UniverDocsDrawingPlugin,Se.UniverDrawingUIPlugin,w.UniverSheetsDrawingPlugin),Et(1,l.Inject(l.Injector)),Et(2,N.IRenderManagerService),Et(3,l.IConfigService)],A.UniverSheetsDrawingUIPlugin),A.ClearSheetDrawingTransformerOperation=K,A.DeleteDrawingsCommand=gt,A.EditSheetDrawingOperation=It,A.FileNamePart=fe,A.GroupSheetDrawingCommand=ht,A.IBatchSaveImagesService=Ve,A.InsertFloatImageCommand=ke,A.InsertSheetDrawingCommand=Ne,A.MoveDrawingsCommand=Te,A.RemoveSheetDrawingCommand=Ce,A.SHEETS_IMAGE_MENU_ID=Mt,A.SHEET_FLOAT_DOM_PREFIX=$t,A.SaveCellImagesCommand=Re,A.SetDrawingArrangeCommand=mt,A.SetSheetDrawingCommand=De,A.SheetDrawingAnchor=xt,A.SidebarSheetDrawingOperation=_t,A.UngroupSheetDrawingCommand=pt,A.calcSheetFloatDomPosition=de,A.drawingPositionToTransform=te,A.transformToAxisAlignPosition=G,A.transformToDrawingPosition=x,Object.defineProperty(A,Symbol.toStringTag,{value:"Module"})}));
16
16
 
17
17
 
18
18
  // @univerjs/sheets-drawing-ui/facade
@@ -3,7 +3,7 @@
3
3
 
4
4
 
5
5
  // @univerjs/sheets-drawing-ui/locale/ca-ES
6
- (function(e,a){typeof exports=="object"&&typeof module<"u"?module.exports=a():typeof define=="function"&&define.amd?define(a):(e=typeof globalThis<"u"?globalThis:e||self,e.UniverSheetsDrawingUiCaES=a())})(this,(function(){"use strict";return{sheetImage:{title:"Imatge",upload:{float:"Imatge flotant",cell:"Imatge de cel·la"},panel:{title:"Edita la imatge"},save:{title:"Desa les imatges de cel·la",menuLabel:"Desa les imatges de cel·la",imageCount:"Nombre d'imatges",fileNameConfig:"Nom del fitxer",useRowCol:"Utilitza l'adreça de la cel·la (A1, B2...)",useColumnValue:"Utilitza el valor de la columna",selectColumn:"Selecciona la columna",cancel:"Cancel·la",confirm:"Desa",saving:"Desant...",error:"No s'han pogut desar les imatges de cel·la"}},"image-popup":{replace:"Reemplaça",delete:"Elimina",edit:"Edita",crop:"Retalla",reset:"Restableix la mida"},"drawing-anchor":{title:"Propietats d’ancoratge",both:"Mou i canvia la mida amb les cel·les",position:"Mou però no canviïs la mida amb les cel·les",none:"No moguis ni canviïs la mida amb les cel·les"},"update-status":{exceedMaxSize:"La mida de la imatge supera el límit, el límit és {0}M",invalidImageType:"Tipus d’imatge no vàlid",exceedMaxCount:"Només es poden pujar {0} imatges alhora",invalidImage:"Imatge no vàlida"},"cell-image":{pasteTitle:"Enganxa com a imatge de cel·la",pasteContent:"Enganxar una imatge de cel·la sobreescriurà el contingut existent de la cel·la, continuar enganxant",pasteError:"La còpia i enganxat d’imatges de cel·la de full no està suportada en aquesta unitat"}}}));
6
+ (function(e,a){typeof exports=="object"&&typeof module<"u"?module.exports=a():typeof define=="function"&&define.amd?define(a):(e=typeof globalThis<"u"?globalThis:e||self,e.UniverSheetsDrawingUiCaES=a())})(this,(function(){"use strict";return{sheetImage:{title:"Imatge",upload:{float:"Imatge flotant",cell:"Imatge de cel·la"},panel:{title:"Edita la imatge"},save:{title:"Desa les imatges de cel·la",menuLabel:"Desa les imatges de cel·la",imageCount:"Nombre d'imatges",fileNameConfig:"Nom del fitxer",useRowCol:"Utilitza l'adreça de la cel·la (A1, B2...)",useColumnValue:"Utilitza el valor de la columna",selectColumn:"Selecciona la columna",cancel:"Cancel·la",confirm:"Desa",saving:"Desant...",error:"No s'han pogut desar les imatges de cel·la"}},"image-popup":{replace:"Reemplaça",delete:"Elimina",edit:"Edita",crop:"Retalla",reset:"Restableix la mida",flipH:"Gira horizontalmente",flipV:"Gira verticalmente"},"drawing-anchor":{title:"Propietats d’ancoratge",both:"Mou i canvia la mida amb les cel·les",position:"Mou però no canviïs la mida amb les cel·les",none:"No moguis ni canviïs la mida amb les cel·les"},"update-status":{exceedMaxSize:"La mida de la imatge supera el límit, el límit és {0}M",invalidImageType:"Tipus d’imatge no vàlid",exceedMaxCount:"Només es poden pujar {0} imatges alhora",invalidImage:"Imatge no vàlida"},"cell-image":{pasteTitle:"Enganxa com a imatge de cel·la",pasteContent:"Enganxar una imatge de cel·la sobreescriurà el contingut existent de la cel·la, continuar enganxant",pasteError:"La còpia i enganxat d’imatges de cel·la de full no està suportada en aquesta unitat"}}}));
7
7
 
8
8
 
9
9
  // locale/ca-ES
@@ -3,7 +3,7 @@
3
3
 
4
4
 
5
5
  // @univerjs/sheets-drawing-ui/locale/en-US
6
- (function(e,t){typeof exports=="object"&&typeof module<"u"?module.exports=t():typeof define=="function"&&define.amd?define(t):(e=typeof globalThis<"u"?globalThis:e||self,e.UniverSheetsDrawingUiEnUS=t())})(this,(function(){"use strict";return{sheetImage:{title:"Image",upload:{float:"Float Image",cell:"Cell Image"},panel:{title:"Edit Image"},save:{title:"Save Cell Images",menuLabel:"Save Cell Images",imageCount:"Image Count",fileNameConfig:"File Name",useRowCol:"Use Cell Address (A1, B2...)",useColumnValue:"Use Column Value",selectColumn:"Select Column",cancel:"Cancel",confirm:"Save",saving:"Saving...",error:"Failed to save cell images"}},"image-popup":{replace:"Replace",delete:"Delete",edit:"Edit",crop:"Crop",reset:"Reset Size"},"drawing-anchor":{title:"Anchor Properties",both:"Move and size with cells",position:"Move but don't size with cells",none:"Don't move or size with cells"},"update-status":{exceedMaxSize:"Image size exceeds limit, limit is {0}M",invalidImageType:"Invalid image type",exceedMaxCount:"Only {0} images can be uploaded at a time",invalidImage:"Invalid image"},"cell-image":{pasteTitle:"Paste as cell image",pasteContent:"Pasting a cell image will overwrite the existing content of the cell, continue pasting",pasteError:"Sheet cell image copy paste is not supported in this unit"}}}));
6
+ (function(e,i){typeof exports=="object"&&typeof module<"u"?module.exports=i():typeof define=="function"&&define.amd?define(i):(e=typeof globalThis<"u"?globalThis:e||self,e.UniverSheetsDrawingUiEnUS=i())})(this,(function(){"use strict";return{sheetImage:{title:"Image",upload:{float:"Float Image",cell:"Cell Image"},panel:{title:"Edit Image"},save:{title:"Save Cell Images",menuLabel:"Save Cell Images",imageCount:"Image Count",fileNameConfig:"File Name",useRowCol:"Use Cell Address (A1, B2...)",useColumnValue:"Use Column Value",selectColumn:"Select Column",cancel:"Cancel",confirm:"Save",saving:"Saving...",error:"Failed to save cell images"}},"image-popup":{replace:"Replace",delete:"Delete",edit:"Edit",crop:"Crop",reset:"Reset Size",flipH:"Flip Horizontal",flipV:"Flip Vertical"},"drawing-anchor":{title:"Anchor Properties",both:"Move and size with cells",position:"Move but don't size with cells",none:"Don't move or size with cells"},"update-status":{exceedMaxSize:"Image size exceeds limit, limit is {0}M",invalidImageType:"Invalid image type",exceedMaxCount:"Only {0} images can be uploaded at a time",invalidImage:"Invalid image"},"cell-image":{pasteTitle:"Paste as cell image",pasteContent:"Pasting a cell image will overwrite the existing content of the cell, continue pasting",pasteError:"Sheet cell image copy paste is not supported in this unit"}}}));
7
7
 
8
8
 
9
9
  // locale/en-US
@@ -3,7 +3,7 @@
3
3
 
4
4
 
5
5
  // @univerjs/sheets-drawing-ui/locale/es-ES
6
- (function(e,a){typeof exports=="object"&&typeof module<"u"?module.exports=a():typeof define=="function"&&define.amd?define(a):(e=typeof globalThis<"u"?globalThis:e||self,e.UniverSheetsDrawingUiEsES=a())})(this,(function(){"use strict";return{sheetImage:{title:"Imagen",upload:{float:"Imagen flotante",cell:"Imagen de celda"},panel:{title:"Editar imagen"},save:{title:"Guardar imágenes de celda",menuLabel:"Guardar imágenes de celda",imageCount:"Cantidad de imágenes",fileNameConfig:"Nombre del archivo",useRowCol:"Usar dirección de celda (A1, B2...)",useColumnValue:"Usar valor de columna",selectColumn:"Seleccionar columna",cancel:"Cancelar",confirm:"Guardar",saving:"Guardando...",error:"Error al guardar las imágenes de celda"}},"image-popup":{replace:"Reemplazar",delete:"Eliminar",edit:"Editar",crop:"Recortar",reset:"Restablecer tamaño"},"drawing-anchor":{title:"Propiedades de anclaje",both:"Mover y cambiar tamaño con las celdas",position:"Mover pero no cambiar tamaño con las celdas",none:"No mover ni cambiar tamaño con las celdas"},"update-status":{exceedMaxSize:"El tamaño de la imagen supera el límite, el límite es {0}M",invalidImageType:"Tipo de imagen no válido",exceedMaxCount:"Solo se pueden subir {0} imágenes a la vez",invalidImage:"Imagen no válida"},"cell-image":{pasteTitle:"Pegar como imagen de celda",pasteContent:"Pegar una imagen de celda sobrescribirá el contenido existente de la celda, continuar pegando",pasteError:"La copia y pegado de imágenes de celda de hoja no está soportada en esta unidad"}}}));
6
+ (function(e,a){typeof exports=="object"&&typeof module<"u"?module.exports=a():typeof define=="function"&&define.amd?define(a):(e=typeof globalThis<"u"?globalThis:e||self,e.UniverSheetsDrawingUiEsES=a())})(this,(function(){"use strict";return{sheetImage:{title:"Imagen",upload:{float:"Imagen flotante",cell:"Imagen de celda"},panel:{title:"Editar imagen"},save:{title:"Guardar imágenes de celda",menuLabel:"Guardar imágenes de celda",imageCount:"Cantidad de imágenes",fileNameConfig:"Nombre del archivo",useRowCol:"Usar dirección de celda (A1, B2...)",useColumnValue:"Usar valor de columna",selectColumn:"Seleccionar columna",cancel:"Cancelar",confirm:"Guardar",saving:"Guardando...",error:"Error al guardar las imágenes de celda"}},"image-popup":{replace:"Reemplazar",delete:"Eliminar",edit:"Editar",crop:"Recortar",reset:"Restablecer tamaño",flipH:"Voltear horizontalmente",flipV:"Voltear verticalmente"},"drawing-anchor":{title:"Propiedades de anclaje",both:"Mover y cambiar tamaño con las celdas",position:"Mover pero no cambiar tamaño con las celdas",none:"No mover ni cambiar tamaño con las celdas"},"update-status":{exceedMaxSize:"El tamaño de la imagen supera el límite, el límite es {0}M",invalidImageType:"Tipo de imagen no válido",exceedMaxCount:"Solo se pueden subir {0} imágenes a la vez",invalidImage:"Imagen no válida"},"cell-image":{pasteTitle:"Pegar como imagen de celda",pasteContent:"Pegar una imagen de celda sobrescribirá el contenido existente de la celda, continuar pegando",pasteError:"La copia y pegado de imágenes de celda de hoja no está soportada en esta unidad"}}}));
7
7
 
8
8
 
9
9
  // locale/es-ES
@@ -3,7 +3,7 @@
3
3
 
4
4
 
5
5
  // @univerjs/sheets-drawing-ui/locale/fa-IR
6
- (function(e,t){typeof exports=="object"&&typeof module<"u"?module.exports=t():typeof define=="function"&&define.amd?define(t):(e=typeof globalThis<"u"?globalThis:e||self,e.UniverSheetsDrawingUiFaIR=t())})(this,(function(){"use strict";return{sheetImage:{title:"تصویر",upload:{float:"شناور کردن تصویر",cell:"تصویر سلولی"},panel:{title:"ویرایش تصویر"},save:{title:"ذخیره تصاویر سلول",menuLabel:"ذخیره تصاویر سلول",imageCount:"تعداد تصاویر",fileNameConfig:"نام فایل",useRowCol:"استفاده از آدرس سلول (A1, B2...)",useColumnValue:"استفاده از مقدار ستون",selectColumn:"انتخاب ستون",cancel:"لغو",confirm:"ذخیره",saving:"در حال ذخیره...",error:"ذخیره تصاویر سلول ناموفق بود"}},"image-popup":{replace:"تعویض",delete:"حذف",edit:"ویرایش",crop:"کراپ",reset:"بازنشانی اندازه"},"drawing-anchor":{title:"خواص لنگر",both:"جابه‌جایی و تغییر اندازه با سلول‌ها",position:"جابه‌جایی اما تغییر اندازه نکردن با سلول‌ها",none:"جابه‌جایی یا تغییر اندازه نکردن با سلول‌ها"},"update-status":{exceedMaxSize:"اندازه تصویر از حد مجاز فراتر رفته است، حد مجاز {0}M است",invalidImageType:"نوع تصویر نامعتبر است",exceedMaxCount:"فقط {0} تصویر می‌توانند همزمان آپلود شوند",invalidImage:"تصویر نامعتبر است"},"cell-image":{pasteTitle:"چسباندن به عنوان تصویر سلول",pasteContent:"چسباندن تصویر سلول محتوای موجود سلول را پاک خواهد کرد، ادامه چسباندن",pasteError:"کپی و چسباندن تصویر سلول در این واحد پشتیبانی نمی‌شود"}}}));
6
+ (function(e,t){typeof exports=="object"&&typeof module<"u"?module.exports=t():typeof define=="function"&&define.amd?define(t):(e=typeof globalThis<"u"?globalThis:e||self,e.UniverSheetsDrawingUiFaIR=t())})(this,(function(){"use strict";return{sheetImage:{title:"تصویر",upload:{float:"شناور کردن تصویر",cell:"تصویر سلولی"},panel:{title:"ویرایش تصویر"},save:{title:"ذخیره تصاویر سلول",menuLabel:"ذخیره تصاویر سلول",imageCount:"تعداد تصاویر",fileNameConfig:"نام فایل",useRowCol:"استفاده از آدرس سلول (A1, B2...)",useColumnValue:"استفاده از مقدار ستون",selectColumn:"انتخاب ستون",cancel:"لغو",confirm:"ذخیره",saving:"در حال ذخیره...",error:"ذخیره تصاویر سلول ناموفق بود"}},"image-popup":{replace:"تعویض",delete:"حذف",edit:"ویرایش",crop:"کراپ",reset:"بازنشانی اندازه",flipH:"چرخش افقی",flipV:"چرخش عمودی"},"drawing-anchor":{title:"خواص لنگر",both:"جابه‌جایی و تغییر اندازه با سلول‌ها",position:"جابه‌جایی اما تغییر اندازه نکردن با سلول‌ها",none:"جابه‌جایی یا تغییر اندازه نکردن با سلول‌ها"},"update-status":{exceedMaxSize:"اندازه تصویر از حد مجاز فراتر رفته است، حد مجاز {0}M است",invalidImageType:"نوع تصویر نامعتبر است",exceedMaxCount:"فقط {0} تصویر می‌توانند همزمان آپلود شوند",invalidImage:"تصویر نامعتبر است"},"cell-image":{pasteTitle:"چسباندن به عنوان تصویر سلول",pasteContent:"چسباندن تصویر سلول محتوای موجود سلول را پاک خواهد کرد، ادامه چسباندن",pasteError:"کپی و چسباندن تصویر سلول در این واحد پشتیبانی نمی‌شود"}}}));
7
7
 
8
8
 
9
9
  // locale/fa-IR
@@ -3,7 +3,7 @@
3
3
 
4
4
 
5
5
  // @univerjs/sheets-drawing-ui/locale/fr-FR
6
- (function(e,l){typeof exports=="object"&&typeof module<"u"?module.exports=l():typeof define=="function"&&define.amd?define(l):(e=typeof globalThis<"u"?globalThis:e||self,e.UniverSheetsDrawingUiFrFR=l())})(this,(function(){"use strict";return{sheetImage:{title:"Image",upload:{float:"Image flottante",cell:"Image de cellule"},panel:{title:"Modifier l'image"},save:{title:"Enregistrer les images de cellule",menuLabel:"Enregistrer les images de cellule",imageCount:"Nombre d'images",fileNameConfig:"Nom du fichier",useRowCol:"Utiliser l'adresse de cellule (A1, B2...)",useColumnValue:"Utiliser la valeur de la colonne",selectColumn:"Sélectionner la colonne",cancel:"Annuler",confirm:"Enregistrer",saving:"Enregistrement...",error:"Échec de l'enregistrement des images de cellule"}},"image-popup":{replace:"Remplacer",delete:"Supprimer",edit:"Éditer",crop:"Rogner",reset:"Réinitialiser la taille"},"drawing-anchor":{title:"Propriétés de l'ancre",both:"Déplacer et redimensionner avec les cellules",position:"Déplacer mais ne pas redimensionner avec les cellules",none:"Ne pas déplacer ni redimensionner avec les cellules"},"update-status":{exceedMaxSize:"La taille de l'image dépasse la limite, la limite est de {0}M",invalidImageType:"Type d'image invalide",exceedMaxCount:"Seulement {0} images peuvent être téléchargées à la fois",invalidImage:"Image invalide"},"cell-image":{pasteTitle:"Coller comme image de cellule",pasteContent:"Coller une image de cellule écrasera le contenu existant de la cellule, continuer le collage",pasteError:"Le copier-coller d'image de cellule n'est pas pris en charge dans cette unité"}}}));
6
+ (function(e,l){typeof exports=="object"&&typeof module<"u"?module.exports=l():typeof define=="function"&&define.amd?define(l):(e=typeof globalThis<"u"?globalThis:e||self,e.UniverSheetsDrawingUiFrFR=l())})(this,(function(){"use strict";return{sheetImage:{title:"Image",upload:{float:"Image flottante",cell:"Image de cellule"},panel:{title:"Modifier l'image"},save:{title:"Enregistrer les images de cellule",menuLabel:"Enregistrer les images de cellule",imageCount:"Nombre d'images",fileNameConfig:"Nom du fichier",useRowCol:"Utiliser l'adresse de cellule (A1, B2...)",useColumnValue:"Utiliser la valeur de la colonne",selectColumn:"Sélectionner la colonne",cancel:"Annuler",confirm:"Enregistrer",saving:"Enregistrement...",error:"Échec de l'enregistrement des images de cellule"}},"image-popup":{replace:"Remplacer",delete:"Supprimer",edit:"Éditer",crop:"Rogner",reset:"Réinitialiser la taille",flipH:"Retournement horizontal",flipV:"Retournement vertical"},"drawing-anchor":{title:"Propriétés de l'ancre",both:"Déplacer et redimensionner avec les cellules",position:"Déplacer mais ne pas redimensionner avec les cellules",none:"Ne pas déplacer ni redimensionner avec les cellules"},"update-status":{exceedMaxSize:"La taille de l'image dépasse la limite, la limite est de {0}M",invalidImageType:"Type d'image invalide",exceedMaxCount:"Seulement {0} images peuvent être téléchargées à la fois",invalidImage:"Image invalide"},"cell-image":{pasteTitle:"Coller comme image de cellule",pasteContent:"Coller une image de cellule écrasera le contenu existant de la cellule, continuer le collage",pasteError:"Le copier-coller d'image de cellule n'est pas pris en charge dans cette unité"}}}));
7
7
 
8
8
 
9
9
  // locale/fr-FR
@@ -3,7 +3,7 @@
3
3
 
4
4
 
5
5
  // @univerjs/sheets-drawing-ui/locale/ja-JP
6
- (function(e,t){typeof exports=="object"&&typeof module<"u"?module.exports=t():typeof define=="function"&&define.amd?define(t):(e=typeof globalThis<"u"?globalThis:e||self,e.UniverSheetsDrawingUiJaJP=t())})(this,(function(){"use strict";return{sheetImage:{title:"画像",upload:{float:"セル上に配置",cell:"セル内に配置"},panel:{title:"画像の編集"},save:{title:"セル画像を保存",menuLabel:"セル画像を保存",imageCount:"画像数",fileNameConfig:"ファイル名",useRowCol:"セルアドレスを使用 (A1, B2...)",useColumnValue:"列の値を使用",selectColumn:"列を選択",cancel:"キャンセル",confirm:"保存",saving:"保存中...",error:"セル画像の保存に失敗しました"}},"image-popup":{replace:"画像の変更",delete:"削除",edit:"編集",crop:"トリミング",reset:"元のサイズに戻す"},"drawing-anchor":{title:"プロパティ",both:"セルに合わせて移動やサイズ変更をする",position:"セルに合わせて移動するがサイズ変更はしない",none:"セルに合わせて移動やサイズ変更をしない"},"update-status":{exceedMaxSize:"画像サイズが制限({0}MB)を超えています",invalidImageType:"サポートされていない画像形式です",exceedMaxCount:"一度にアップロードできるのは {0} 個までです",invalidImage:"無効な画像です"},"cell-image":{pasteTitle:"セル内画像として貼り付け",pasteContent:"セル内画像を貼り付けると、既存のセル内容が上書きされます。続行しますか?",pasteError:"この箇所では、シートのセル内画像のコピー&ペーストはサポートされていません"}}}));
6
+ (function(e,t){typeof exports=="object"&&typeof module<"u"?module.exports=t():typeof define=="function"&&define.amd?define(t):(e=typeof globalThis<"u"?globalThis:e||self,e.UniverSheetsDrawingUiJaJP=t())})(this,(function(){"use strict";return{sheetImage:{title:"画像",upload:{float:"セル上に配置",cell:"セル内に配置"},panel:{title:"画像の編集"},save:{title:"セル画像を保存",menuLabel:"セル画像を保存",imageCount:"画像数",fileNameConfig:"ファイル名",useRowCol:"セルアドレスを使用 (A1, B2...)",useColumnValue:"列の値を使用",selectColumn:"列を選択",cancel:"キャンセル",confirm:"保存",saving:"保存中...",error:"セル画像の保存に失敗しました"}},"image-popup":{replace:"画像の変更",delete:"削除",edit:"編集",crop:"トリミング",reset:"元のサイズに戻す",flipH:"左右反転",flipV:"上下反転"},"drawing-anchor":{title:"プロパティ",both:"セルに合わせて移動やサイズ変更をする",position:"セルに合わせて移動するがサイズ変更はしない",none:"セルに合わせて移動やサイズ変更をしない"},"update-status":{exceedMaxSize:"画像サイズが制限({0}MB)を超えています",invalidImageType:"サポートされていない画像形式です",exceedMaxCount:"一度にアップロードできるのは {0} 個までです",invalidImage:"無効な画像です"},"cell-image":{pasteTitle:"セル内画像として貼り付け",pasteContent:"セル内画像を貼り付けると、既存のセル内容が上書きされます。続行しますか?",pasteError:"この箇所では、シートのセル内画像のコピー&ペーストはサポートされていません"}}}));
7
7
 
8
8
 
9
9
  // locale/ja-JP
@@ -3,7 +3,7 @@
3
3
 
4
4
 
5
5
  // @univerjs/sheets-drawing-ui/locale/ko-KR
6
- (function(e,t){typeof exports=="object"&&typeof module<"u"?module.exports=t():typeof define=="function"&&define.amd?define(t):(e=typeof globalThis<"u"?globalThis:e||self,e.UniverSheetsDrawingUiKoKR=t())})(this,(function(){"use strict";return{sheetImage:{title:"이미지",upload:{float:"플로팅 이미지",cell:"셀 내 이미지"},panel:{title:"이미지 편집"},save:{title:"셀 이미지 저장",menuLabel:"셀 이미지 저장",imageCount:"이미지 수",fileNameConfig:"파일 이름",useRowCol:"셀 주소 사용 (A1, B2...)",useColumnValue:"열 값 사용",selectColumn:"열 선택",cancel:"취소",confirm:"저장",saving:"저장 중...",error:"셀 이미지 저장 실패"}},"image-popup":{replace:"바꾸기",delete:"삭제",edit:"편집",crop:"자르기",reset:"원래 크기"},"drawing-anchor":{title:"고정 위치 설정",both:"셀과 함께 이동 및 크기 조절",position:"셀과 함께 이동하되 크기 변경 안 함",none:"셀과 함께 이동 및 크기 조절 안 함"},"update-status":{exceedMaxSize:"이미지 크기가 제한({0}MB)을 초과했습니다",invalidImageType:"지원하지 않는 이미지 형식입니다",exceedMaxCount:"한 번에 {0}개까지만 업로드할 수 있습니다",invalidImage:"유효하지 않은 이미지입니다"},"cell-image":{pasteTitle:"셀 이미지로 붙여넣기",pasteContent:"셀 이미지 붙여넣기는 기존 셀 내용을 덮어씁니다. 계속 진행하시겠습니까?",pasteError:"이 단위에서는 시트 셀 이미지 복사 붙여넣기를 지원하지 않습니다"}}}));
6
+ (function(e,t){typeof exports=="object"&&typeof module<"u"?module.exports=t():typeof define=="function"&&define.amd?define(t):(e=typeof globalThis<"u"?globalThis:e||self,e.UniverSheetsDrawingUiKoKR=t())})(this,(function(){"use strict";return{sheetImage:{title:"이미지",upload:{float:"플로팅 이미지",cell:"셀 내 이미지"},panel:{title:"이미지 편집"},save:{title:"셀 이미지 저장",menuLabel:"셀 이미지 저장",imageCount:"이미지 수",fileNameConfig:"파일 이름",useRowCol:"셀 주소 사용 (A1, B2...)",useColumnValue:"열 값 사용",selectColumn:"열 선택",cancel:"취소",confirm:"저장",saving:"저장 중...",error:"셀 이미지 저장 실패"}},"image-popup":{replace:"바꾸기",delete:"삭제",edit:"편집",crop:"자르기",reset:"원래 크기",flipH:"가로 뒤집기",flipV:"세로 뒤집기"},"drawing-anchor":{title:"고정 위치 설정",both:"셀과 함께 이동 및 크기 조절",position:"셀과 함께 이동하되 크기 변경 안 함",none:"셀과 함께 이동 및 크기 조절 안 함"},"update-status":{exceedMaxSize:"이미지 크기가 제한({0}MB)을 초과했습니다",invalidImageType:"지원하지 않는 이미지 형식입니다",exceedMaxCount:"한 번에 {0}개까지만 업로드할 수 있습니다",invalidImage:"유효하지 않은 이미지입니다"},"cell-image":{pasteTitle:"셀 이미지로 붙여넣기",pasteContent:"셀 이미지 붙여넣기는 기존 셀 내용을 덮어씁니다. 계속 진행하시겠습니까?",pasteError:"이 단위에서는 시트 셀 이미지 복사 붙여넣기를 지원하지 않습니다"}}}));
7
7
 
8
8
 
9
9
  // locale/ko-KR
@@ -3,7 +3,7 @@
3
3
 
4
4
 
5
5
  // @univerjs/sheets-drawing-ui/locale/ru-RU
6
- (function(e,t){typeof exports=="object"&&typeof module<"u"?module.exports=t():typeof define=="function"&&define.amd?define(t):(e=typeof globalThis<"u"?globalThis:e||self,e.UniverSheetsDrawingUiRuRU=t())})(this,(function(){"use strict";return{sheetImage:{title:"Изображение",upload:{float:"Плавающее изображение",cell:"Изображение в ячейке"},panel:{title:"Редактировать изображение"},save:{title:"Сохранить изображения ячеек",menuLabel:"Сохранить изображения ячеек",imageCount:"Количество изображений",fileNameConfig:"Имя файла",useRowCol:"Использовать адрес ячейки (A1, B2...)",useColumnValue:"Использовать значение столбца",selectColumn:"Выбрать столбец",cancel:"Отмена",confirm:"Сохранить",saving:"Сохранение...",error:"Не удалось сохранить изображения ячеек"}},"image-popup":{replace:"Заменить",delete:"Удалить",edit:"Редактировать",crop:"Обрезать",reset:"Сбросить размер"},"drawing-anchor":{title:"Свойства привязки",both:"Перемещать и изменять размер с ячейками",position:"Перемещать, но не изменять размер с ячейками",none:"Не перемещать и не изменять размер с ячейками"},"update-status":{exceedMaxSize:"Размер изображения превышает лимит, лимит составляет {0}М",invalidImageType:"Недопустимый тип изображения",exceedMaxCount:"За один раз можно загрузить только {0} изображений",invalidImage:"Недопустимое изображение"},"cell-image":{pasteTitle:"Вставить как изображение ячейки",pasteContent:"Вставка изображения ячейки перезапишет существующее содержимое ячейки, продолжить вставку",pasteError:"Копирование и вставка изображения ячейки не поддерживается в этом блоке"}}}));
6
+ (function(e,t){typeof exports=="object"&&typeof module<"u"?module.exports=t():typeof define=="function"&&define.amd?define(t):(e=typeof globalThis<"u"?globalThis:e||self,e.UniverSheetsDrawingUiRuRU=t())})(this,(function(){"use strict";return{sheetImage:{title:"Изображение",upload:{float:"Плавающее изображение",cell:"Изображение в ячейке"},panel:{title:"Редактировать изображение"},save:{title:"Сохранить изображения ячеек",menuLabel:"Сохранить изображения ячеек",imageCount:"Количество изображений",fileNameConfig:"Имя файла",useRowCol:"Использовать адрес ячейки (A1, B2...)",useColumnValue:"Использовать значение столбца",selectColumn:"Выбрать столбец",cancel:"Отмена",confirm:"Сохранить",saving:"Сохранение...",error:"Не удалось сохранить изображения ячеек"}},"image-popup":{replace:"Заменить",delete:"Удалить",edit:"Редактировать",crop:"Обрезать",reset:"Сбросить размер",flipH:"Отразить по горизонтали",flipV:"Отразить по вертикали"},"drawing-anchor":{title:"Свойства привязки",both:"Перемещать и изменять размер с ячейками",position:"Перемещать, но не изменять размер с ячейками",none:"Не перемещать и не изменять размер с ячейками"},"update-status":{exceedMaxSize:"Размер изображения превышает лимит, лимит составляет {0}М",invalidImageType:"Недопустимый тип изображения",exceedMaxCount:"За один раз можно загрузить только {0} изображений",invalidImage:"Недопустимое изображение"},"cell-image":{pasteTitle:"Вставить как изображение ячейки",pasteContent:"Вставка изображения ячейки перезапишет существующее содержимое ячейки, продолжить вставку",pasteError:"Копирование и вставка изображения ячейки не поддерживается в этом блоке"}}}));
7
7
 
8
8
 
9
9
  // locale/ru-RU
@@ -3,7 +3,7 @@
3
3
 
4
4
 
5
5
  // @univerjs/sheets-drawing-ui/locale/sk-SK
6
- (function(e,o){typeof exports=="object"&&typeof module<"u"?module.exports=o():typeof define=="function"&&define.amd?define(o):(e=typeof globalThis<"u"?globalThis:e||self,e.UniverSheetsDrawingUiSkSK=o())})(this,(function(){"use strict";return{sheetImage:{title:"Obrázok",upload:{float:"Plávajúci obrázok",cell:"Obrázok v bunke"},panel:{title:"Upraviť obrázok"},save:{title:"Uložiť obrázky buniek",menuLabel:"Uložiť obrázky buniek",imageCount:"Počet obrázkov",fileNameConfig:"Názov súboru",useRowCol:"Použiť adresu bunky (A1, B2...)",useColumnValue:"Použiť hodnotu stĺpca",selectColumn:"Vybrať stĺpec",cancel:"Zrušiť",confirm:"Uložiť",saving:"Ukladá sa...",error:"Nepodarilo sa uložiť obrázky buniek"}},"image-popup":{replace:"Nahradiť",delete:"Odstrániť",edit:"Upraviť",crop:"Orezať",reset:"Obnoviť veľkosť"},"drawing-anchor":{title:"Vlastnosti ukotvenia",both:"Presúvať a meniť veľkosť s bunkami",position:"Presúvať, ale nemeniť veľkosť s bunkami",none:"Nepresúvať ani nemeniť veľkosť s bunkami"},"update-status":{exceedMaxSize:"Veľkosť obrázka prekračuje limit, limit je {0}M",invalidImageType:"Neplatný typ obrázka",exceedMaxCount:"Naraz možno nahrať iba {0} obrázkov",invalidImage:"Neplatný obrázok"},"cell-image":{pasteTitle:"Prilepiť ako obrázok bunky",pasteContent:"Prilepením obrázka bunky sa prepíše existujúci obsah bunky, pokračovať",pasteError:"Kopírovanie a prilepovanie obrázkov buniek v tomto module nie je podporované"}}}));
6
+ (function(e,o){typeof exports=="object"&&typeof module<"u"?module.exports=o():typeof define=="function"&&define.amd?define(o):(e=typeof globalThis<"u"?globalThis:e||self,e.UniverSheetsDrawingUiSkSK=o())})(this,(function(){"use strict";return{sheetImage:{title:"Obrázok",upload:{float:"Plávajúci obrázok",cell:"Obrázok v bunke"},panel:{title:"Upraviť obrázok"},save:{title:"Uložiť obrázky buniek",menuLabel:"Uložiť obrázky buniek",imageCount:"Počet obrázkov",fileNameConfig:"Názov súboru",useRowCol:"Použiť adresu bunky (A1, B2...)",useColumnValue:"Použiť hodnotu stĺpca",selectColumn:"Vybrať stĺpec",cancel:"Zrušiť",confirm:"Uložiť",saving:"Ukladá sa...",error:"Nepodarilo sa uložiť obrázky buniek"}},"image-popup":{replace:"Nahradiť",delete:"Odstrániť",edit:"Upraviť",crop:"Orezať",reset:"Obnoviť veľkosť",flipH:"Prevrátiť vodorovne",flipV:"Prevrátiť zvisle"},"drawing-anchor":{title:"Vlastnosti ukotvenia",both:"Presúvať a meniť veľkosť s bunkami",position:"Presúvať, ale nemeniť veľkosť s bunkami",none:"Nepresúvať ani nemeniť veľkosť s bunkami"},"update-status":{exceedMaxSize:"Veľkosť obrázka prekračuje limit, limit je {0}M",invalidImageType:"Neplatný typ obrázka",exceedMaxCount:"Naraz možno nahrať iba {0} obrázkov",invalidImage:"Neplatný obrázok"},"cell-image":{pasteTitle:"Prilepiť ako obrázok bunky",pasteContent:"Prilepením obrázka bunky sa prepíše existujúci obsah bunky, pokračovať",pasteError:"Kopírovanie a prilepovanie obrázkov buniek v tomto module nie je podporované"}}}));
7
7
 
8
8
 
9
9
  // locale/sk-SK
@@ -3,7 +3,7 @@
3
3
 
4
4
 
5
5
  // @univerjs/sheets-drawing-ui/locale/vi-VN
6
- (function(n,h){typeof exports=="object"&&typeof module<"u"?module.exports=h():typeof define=="function"&&define.amd?define(h):(n=typeof globalThis<"u"?globalThis:n||self,n.UniverSheetsDrawingUiViVN=h())})(this,(function(){"use strict";return{sheetImage:{title:"Hình ảnh",upload:{float:"Hình ảnh nổi",cell:"Hình ảnh trong ô"},panel:{title:"Chỉnh sửa hình ảnh"},save:{title:"Lưu hình ảnh ô",menuLabel:"Lưu hình ảnh ô",imageCount:"Số lượng hình ảnh",fileNameConfig:"Tên tệp",useRowCol:"Sử dụng địa chỉ ô (A1, B2...)",useColumnValue:"Sử dụng giá trị cột",selectColumn:"Chọn cột",cancel:"Hủy",confirm:"Lưu",saving:"Đang lưu...",error:"Lưu hình ảnh ô thất bại"}},"image-popup":{replace:"Thay thế",delete:"Xóa",edit:"Chỉnh sửa",crop:"Cắt",reset:"Đặt lại kích thước"},"drawing-anchor":{title:"Thuộc tính neo",both:"Di chuyển và thay đổi kích thước cùng với ô",position:"Di chuyển nhưng không thay đổi kích thước với ô",none:"Không di chuyển hoặc thay đổi kích thước với ô"},"update-status":{exceedMaxSize:"Kích thước hình ảnh vượt quá giới hạn, giới hạn là {0}M",invalidImageType:"Loại hình ảnh không hợp lệ",exceedMaxCount:"Chỉ có thể tải lên {0} hình ảnh một lần",invalidImage:"Hình ảnh không hợp lệ"},"cell-image":{pasteTitle:"Dán như hình ảnh ô",pasteContent:"Dán hình ảnh ô sẽ ghi đè lên nội dung hiện có của ô, tiếp tục dán",pasteError:"Sao chép và dán hình ảnh ô không được hỗ trợ trong đơn vị này"}}}));
6
+ (function(n,h){typeof exports=="object"&&typeof module<"u"?module.exports=h():typeof define=="function"&&define.amd?define(h):(n=typeof globalThis<"u"?globalThis:n||self,n.UniverSheetsDrawingUiViVN=h())})(this,(function(){"use strict";return{sheetImage:{title:"Hình ảnh",upload:{float:"Hình ảnh nổi",cell:"Hình ảnh trong ô"},panel:{title:"Chỉnh sửa hình ảnh"},save:{title:"Lưu hình ảnh ô",menuLabel:"Lưu hình ảnh ô",imageCount:"Số lượng hình ảnh",fileNameConfig:"Tên tệp",useRowCol:"Sử dụng địa chỉ ô (A1, B2...)",useColumnValue:"Sử dụng giá trị cột",selectColumn:"Chọn cột",cancel:"Hủy",confirm:"Lưu",saving:"Đang lưu...",error:"Lưu hình ảnh ô thất bại"}},"image-popup":{replace:"Thay thế",delete:"Xóa",edit:"Chỉnh sửa",crop:"Cắt",reset:"Đặt lại kích thước",flipH:"Lật ngang",flipV:"Lật dọc"},"drawing-anchor":{title:"Thuộc tính neo",both:"Di chuyển và thay đổi kích thước cùng với ô",position:"Di chuyển nhưng không thay đổi kích thước với ô",none:"Không di chuyển hoặc thay đổi kích thước với ô"},"update-status":{exceedMaxSize:"Kích thước hình ảnh vượt quá giới hạn, giới hạn là {0}M",invalidImageType:"Loại hình ảnh không hợp lệ",exceedMaxCount:"Chỉ có thể tải lên {0} hình ảnh một lần",invalidImage:"Hình ảnh không hợp lệ"},"cell-image":{pasteTitle:"Dán như hình ảnh ô",pasteContent:"Dán hình ảnh ô sẽ ghi đè lên nội dung hiện có của ô, tiếp tục dán",pasteError:"Sao chép và dán hình ảnh ô không được hỗ trợ trong đơn vị này"}}}));
7
7
 
8
8
 
9
9
  // locale/vi-VN
@@ -3,7 +3,7 @@
3
3
 
4
4
 
5
5
  // @univerjs/sheets-drawing-ui/locale/zh-CN
6
- (function(e,t){typeof exports=="object"&&typeof module<"u"?module.exports=t():typeof define=="function"&&define.amd?define(t):(e=typeof globalThis<"u"?globalThis:e||self,e.UniverSheetsDrawingUiZhCN=t())})(this,(function(){"use strict";return{sheetImage:{title:"图片",upload:{float:"浮动图片",cell:"单元格图片"},panel:{title:"编辑图片"},save:{title:"保存单元格图片",menuLabel:"保存单元格图片",imageCount:"图片数量",fileNameConfig:"文件名",useRowCol:"使用单元格地址 (A1, B2...)",useColumnValue:"使用某列的值",selectColumn:"选择列",cancel:"取消",confirm:"保存",saving:"保存中...",error:"保存单元格图片失败"}},"image-popup":{replace:"替换",delete:"删除",edit:"编辑",crop:"裁剪",reset:"重置大小"},"drawing-anchor":{title:"锚点属性",both:"与单元格一起移动和调整大小",position:"移动但不调整大小与单元格",none:"不要移动或调整大小与单元格"},"update-status":{exceedMaxSize:"图片大小超过限制, 限制为{0}M",invalidImageType:"图片类型错误",exceedMaxCount:"图片只能一次上传{0}张",invalidImage:"无效图片"},"cell-image":{pasteTitle:"粘贴为单元格图片",pasteContent:"粘贴单元格图片将覆盖单元格中的现有内容,继续粘贴",pasteError:"此单元中不支持单元格图片复制粘贴"}}}));
6
+ (function(e,t){typeof exports=="object"&&typeof module<"u"?module.exports=t():typeof define=="function"&&define.amd?define(t):(e=typeof globalThis<"u"?globalThis:e||self,e.UniverSheetsDrawingUiZhCN=t())})(this,(function(){"use strict";return{sheetImage:{title:"图片",upload:{float:"浮动图片",cell:"单元格图片"},panel:{title:"编辑图片"},save:{title:"保存单元格图片",menuLabel:"保存单元格图片",imageCount:"图片数量",fileNameConfig:"文件名",useRowCol:"使用单元格地址 (A1, B2...)",useColumnValue:"使用某列的值",selectColumn:"选择列",cancel:"取消",confirm:"保存",saving:"保存中...",error:"保存单元格图片失败"}},"image-popup":{replace:"替换",delete:"删除",edit:"编辑",crop:"裁剪",reset:"重置大小",flipH:"水平翻转",flipV:"垂直翻转"},"drawing-anchor":{title:"锚点属性",both:"与单元格一起移动和调整大小",position:"移动但不调整大小与单元格",none:"不要移动或调整大小与单元格"},"update-status":{exceedMaxSize:"图片大小超过限制, 限制为{0}M",invalidImageType:"图片类型错误",exceedMaxCount:"图片只能一次上传{0}张",invalidImage:"无效图片"},"cell-image":{pasteTitle:"粘贴为单元格图片",pasteContent:"粘贴单元格图片将覆盖单元格中的现有内容,继续粘贴",pasteError:"此单元中不支持单元格图片复制粘贴"}}}));
7
7
 
8
8
 
9
9
  // locale/zh-CN
@@ -3,7 +3,7 @@
3
3
 
4
4
 
5
5
  // @univerjs/sheets-drawing-ui/locale/zh-TW
6
- (function(e,t){typeof exports=="object"&&typeof module<"u"?module.exports=t():typeof define=="function"&&define.amd?define(t):(e=typeof globalThis<"u"?globalThis:e||self,e.UniverSheetsDrawingUiZhTW=t())})(this,(function(){"use strict";return{sheetImage:{title:"圖片",upload:{float:"浮動圖片",cell:"儲存格圖片"},panel:{title:"編圖"},save:{title:"儲存儲存格圖片",menuLabel:"儲存儲存格圖片",imageCount:"圖片數量",fileNameConfig:"檔案名稱",useRowCol:"使用儲存格地址 (A1, B2...)",useColumnValue:"使用某欄的值",selectColumn:"選擇欄",cancel:"取消",confirm:"儲存",saving:"儲存中...",error:"儲存儲存格圖片失敗"}},"image-popup":{replace:"替換",delete:"刪除",edit:"編輯",crop:"裁切",reset:"重置大小"},"drawing-anchor":{title:"錨點屬性",both:"與儲存格一起移動和調整大小",position:"移動但不調整大小與儲存格",none:"不要移動或調整大小與儲存格"},"update-status":{exceedMaxSize:"圖片大小超過限制, 限制為{0}M",invalidImageType:"圖片類型錯誤",exceedMaxCount:"圖片只能一次上傳{0}張",invalidImage:"無效圖片"},"cell-image":{pasteTitle:"貼上為儲存格圖片",pasteContent:"貼上儲存格圖片將覆蓋儲存格中的現有內容,繼續貼上",pasteError:"此儲存格不支援儲存格圖片複製貼上"}}}));
6
+ (function(e,t){typeof exports=="object"&&typeof module<"u"?module.exports=t():typeof define=="function"&&define.amd?define(t):(e=typeof globalThis<"u"?globalThis:e||self,e.UniverSheetsDrawingUiZhTW=t())})(this,(function(){"use strict";return{sheetImage:{title:"圖片",upload:{float:"浮動圖片",cell:"儲存格圖片"},panel:{title:"編圖"},save:{title:"儲存儲存格圖片",menuLabel:"儲存儲存格圖片",imageCount:"圖片數量",fileNameConfig:"檔案名稱",useRowCol:"使用儲存格地址 (A1, B2...)",useColumnValue:"使用某欄的值",selectColumn:"選擇欄",cancel:"取消",confirm:"儲存",saving:"儲存中...",error:"儲存儲存格圖片失敗"}},"image-popup":{replace:"替換",delete:"刪除",edit:"編輯",crop:"裁切",reset:"重置大小",flipH:"水平翻轉",flipV:"垂直翻轉"},"drawing-anchor":{title:"錨點屬性",both:"與儲存格一起移動和調整大小",position:"移動但不調整大小與儲存格",none:"不要移動或調整大小與儲存格"},"update-status":{exceedMaxSize:"圖片大小超過限制, 限制為{0}M",invalidImageType:"圖片類型錯誤",exceedMaxCount:"圖片只能一次上傳{0}張",invalidImage:"無效圖片"},"cell-image":{pasteTitle:"貼上為儲存格圖片",pasteContent:"貼上儲存格圖片將覆蓋儲存格中的現有內容,繼續貼上",pasteError:"此儲存格不支援儲存格圖片複製貼上"}}}));
7
7
 
8
8
 
9
9
  // locale/zh-TW
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@univerjs/preset-sheets-drawing",
3
- "version": "0.15.5",
3
+ "version": "0.16.1",
4
4
  "private": false,
5
5
  "description": "",
6
6
  "author": "DreamNum Co., Ltd. <developer@univer.ai>",
@@ -58,19 +58,19 @@
58
58
  "rxjs": ">=7.0.0"
59
59
  },
60
60
  "dependencies": {
61
- "@univerjs/docs-drawing": "0.15.5",
62
- "@univerjs/drawing": "0.15.5",
63
- "@univerjs/drawing-ui": "0.15.5",
64
- "@univerjs/sheets-drawing": "0.15.5",
65
- "@univerjs/sheets-drawing-ui": "0.15.5"
61
+ "@univerjs/docs-drawing": "0.16.1",
62
+ "@univerjs/drawing": "0.16.1",
63
+ "@univerjs/drawing-ui": "0.16.1",
64
+ "@univerjs/sheets-drawing": "0.16.1",
65
+ "@univerjs/sheets-drawing-ui": "0.16.1"
66
66
  },
67
67
  "devDependencies": {
68
- "@univerjs/core": "0.15.5",
68
+ "@univerjs/core": "0.16.1",
69
69
  "react": "18.3.1",
70
70
  "react-dom": "18.3.1",
71
71
  "rxjs": "7.8.2",
72
72
  "typescript": "^5.9.3",
73
- "@univerjs-infra/shared": "0.15.5"
73
+ "@univerjs-infra/shared": "0.16.1"
74
74
  },
75
75
  "scripts": {
76
76
  "prebuild:preset": "tsx prepare.ts",