@univerjs/preset-sheets-drawing 0.14.0 → 0.15.0
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 +3 -3
- package/package.json +8 -8
package/lib/umd/index.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
// @univerjs/drawing-ui/index
|
|
6
|
-
(function(D,h){typeof exports=="object"&&typeof module<"u"?h(exports,require("@univerjs/core"),require("@univerjs/ui"),require("react/jsx-runtime"),require("@univerjs/design"),require("react"),require("@univerjs/drawing"),require("@univerjs/engine-render"),require("rxjs")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/ui","react/jsx-runtime","@univerjs/design","react","@univerjs/drawing","@univerjs/engine-render","rxjs"],h):(D=typeof globalThis<"u"?globalThis:D||self,h(D.UniverDrawingUi={},D.UniverCore,D.UniverUi,D.React,D.UniverDesign,D.React,D.UniverDrawing,D.UniverEngineRender,D.rxjs))})(this,(function(D,h,A,f,U,C,E,y,Me){"use strict";var Et=Object.defineProperty;var Tt=(D,h,A)=>h in D?Et(D,h,{enumerable:!0,configurable:!0,writable:!0,value:A}):D[h]=A;var J=(D,h,A)=>Tt(D,typeof h!="symbol"?h+"":h,A);var be;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 de={id:"sheet.operation.set-image-align",type:h.CommandType.OPERATION,handler:(s,r)=>!0},he={id:"sheet.operation.open-image-crop",type:h.CommandType.OPERATION,handler:(s,r)=>!0},Q={id:"sheet.operation.close-image-crop",type:h.CommandType.OPERATION,handler:(s,r)=>!0};var x=(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))(x||{});const oe={id:"sheet.operation.Auto-image-crop",type:h.CommandType.OPERATION,handler:(s,r)=>!0},Ie={id:"sheet.operation.image-reset-size",type:h.CommandType.OPERATION,handler:(s,r)=>!0},Ze="drawing-ui.config",Oe={},Ee="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=C.useRef(`_${Ye()}`);return Te(e,`${t}`,{defIds:e.defIds,idSuffix:c.current},{ref:s,className:o,...a},i)}function Te(s,r,e,t,n){return C.createElement(s.tag,{key:r,...Fe(s,e,n),...t},(ze(s,e).children||[]).map((i,a)=>Te(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=C.forwardRef(function(r,e){return C.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"}}]},Ne=C.forwardRef(function(r,e){return C.createElement(F,Object.assign({},r,{id:"create-copy-icon",ref:e,icon:qe}))});Ne.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"}}]},Be=C.forwardRef(function(r,e){return C.createElement(F,Object.assign({},r,{id:"group-icon",ref:e,icon:Je}))});Be.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"}}]},Ue=C.forwardRef(function(r,e){return C.createElement(F,Object.assign({},r,{id:"more-down-icon",ref:e,icon:Qe}))});Ue.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"}}]},Re=C.forwardRef(function(r,e){return C.createElement(F,Object.assign({},r,{id:"move-down-icon",ref:e,icon:et}))});Re.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"}}]},je=C.forwardRef(function(r,e){return C.createElement(F,Object.assign({},r,{id:"move-up-icon",ref:e,icon:tt}))});je.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"}}]},Ae=C.forwardRef(function(r,e){return C.createElement(F,Object.assign({},r,{id:"topmost-icon",ref:e,icon:rt}))});Ae.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"}}]},Le=C.forwardRef(function(r,e){return C.createElement(F,Object.assign({},r,{id:"ungroup-icon",ref:e,icon:nt}))});Le.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"}}]},xe=C.forwardRef(function(r,e){return C.createElement(F,Object.assign({},r,{id:"autofill-double-icon",ref:e,icon:it}))});xe.displayName="AutofillDoubleIcon";function He(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=A.useDependency(h.ICommandService),n=A.useDependency(h.LocaleService),[i,a]=C.useState(!1),[o,c]=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(U.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:U.clsx("univer-flex univer-items-center univer-gap-2 univer-rounded univer-p-1 hover:univer-bg-gray-100 dark:hover:!univer-bg-gray-800",U.borderClassName,{"univer-bg-gray-100 dark:!univer-bg-gray-800":i,"univer-bg-white dark:!univer-bg-gray-900":!i}),children:[f.jsx(xe,{className:"univer-fill-primary-600 univer-text-gray-900 dark:!univer-text-white"}),p&&f.jsx(Ue,{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},ke=(s,r)=>(e,t)=>r(e,t,s);let fe=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(Ee,He))}_initCommands(){[he,Q,Ie,de,oe].forEach(s=>this.disposeWithMe(this._commandService.registerCommand(s)))}_init(){this._initCommands(),this._initCustomComponents()}};fe=st([ke(0,h.Inject(A.ComponentManager)),ke(1,h.ICommandService)],fe);function ce(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}function Ge(s,r,e,t){const n=t.getDrawingByParam(s);if(n==null)return;const i=E.getDrawingShapeKeyByDrawingSearch(s),a=e.getObject(i);if(a&&!(a instanceof y.Group))return;if(a!=null){a.addObject(r);return}const o=new y.Group(i);e.addObject(o,y.DRAWING_OBJECT_LAYER_INDEX).attachTransformerTo(o),o.addObject(r);const{transform:c}=n;c&&o.transformByState({left:c.left,top:c.top,angle:c.angle})}function $e(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}}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},pe=(s,r)=>(e,t)=>r(e,t,s);let me=class extends h.Disposable{constructor(r,e,t,n){super();J(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=$e(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===de.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(Q.id);const l=[];if(t.forEach(p=>{const S=E.getDrawingShapeKeyByDrawingSearch(p),m=c.getObjectIncludeInGroup(S);if(m==null||l.includes(m))return;l.push(m);const{transform:v}=p;v!=null&&(m.classType===y.RENDER_CLASS_TYPE.GROUP?m.transformByState({left:v.left,top:v.top}):m.transformByState(v))}),l.length===0)return;const g=E.getDrawingShapeKeyByDrawingSearch({unitId:n,subUnitId:i,drawingId:a}),d=new y.Group(g);c.addObject(d,y.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=E.getDrawingShapeKeyByDrawingSearch(g),p=i.getObjectIncludeInGroup(d);if(p==null)return!0;if(p==null)return;const{transform:S}=g;S!=null&&(p.classType===y.RENDER_CLASS_TYPE.GROUP?p.transformByState({left:S.left,top:S.top}):p.transformByState(S))});const o=E.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:_=0,width:I=0,height:M=0}=m.transform;i=Math.min(i,v),a=Math.min(a,_),o=Math.max(o,v+I),c=Math.max(c,_+M),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:_,drawingId:I,transform:M,drawingType:N}=S,{left:j=0,top:b=0,width:T=0,height:O=0}=M;let B=j,P=b;switch(e){case R.left:B=t;break;case R.center:B=t+(i-t)/2-T/2;break;case R.right:B=i-T;break;case R.top:P=n;break;case R.middle:P=n+(a-n)/2-O/2;break;case R.bottom:P=a-O;break;case R.horizon:B=t+c*m;break;case R.vertical:P=n+u*m;break}(B!==j||P!==b)&&l.push({unitId:v,subUnitId:_,drawingId:I,drawingType:N,transform:{left:B,top:P}})}),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=E.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=E.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:_=!1,flipY:I=!1,skewX:M=0,skewY:N=0}=o,j=E.getDrawingShapeKeyByDrawingSearch({unitId:t,subUnitId:n,drawingId:i}),b=l.getObject(j);if(b==null)return!0;b.transformByState({left:d,top:p,width:S,height:m,angle:v,flipX:_,flipY:I,skewX:M,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=E.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:_=!1,flipY:I=!1,skewX:M=0,skewY:N=0}=c;g.transformByState({left:d,top:p,width:S,height:m,angle:v,flipX:_,flipY:I,skewX:M,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=E.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 y.Group){let _=c.ancestorGroup;if(_==null&&c instanceof y.Group&&(_=c),_==null)return null;const I=this._drawingManagerService.getDrawingOKey(_.oKey);if(I){const{unitId:M,subUnitId:N,drawingId:j}=I;o.push({unitId:M,subUnitId:N,drawingId:j});const{left:b,top:T,height:O,width:B,angle:P}=_;return{left:b,top:T,height:O,width:B,angle:P}}}else if(v!=null){const{unitId:_,subUnitId:I,drawingId:M}=v;return o.push({unitId:_,subUnitId:I,drawingId:M}),{left:u,top:l,height:g,width:d,angle:p}}return null}).filter(c=>c!=null),o.length>0?this._commandService.syncExecuteCommand(E.SetDrawingSelectedOperation.id,o):this._commandService.syncExecuteCommand(E.SetDrawingSelectedOperation.id,[])}))),this.disposeWithMe(h.toDisposable(e.changeEnd$.subscribe(n=>{const{objects:i}=n,a=this._filterUpdateParams(ce(i,this._drawingManagerService),t);a.length>0&&this._drawingManagerService.featurePluginUpdateNotification(a)})))}};me=ct([pe(0,h.IUniverInstanceService),pe(1,h.ICommandService),pe(2,y.IRenderManagerService),pe(3,E.IDrawingManagerService)],me);class le extends y.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);J(this,"_srcRect");J(this,"_prstGeom");J(this,"_applyTransform");J(this,"_dragPadding",8);J(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(),y.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 y.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},ie=(s,r)=>(e,t)=>r(e,t,s);let ve=class extends h.Disposable{constructor(r,e,t,n,i,a){super();J(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!==oe.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(Q.id,{isAuto:!0});const d=E.getDrawingShapeKeyByDrawingSearch({unitId:a,subUnitId:o,drawingId:c}),p=l.getObject(d);if(!(p instanceof y.Image)){this._messageService.show({type:U.MessageType.Error,content:this._localeService.t("image-cropper.error")});return}p!=null&&(this._updateCropperObject(t,p),this._commandService.executeCommand(he.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:y.precisionTo(g,1),top:y.precisionTo(d,1),right:y.precisionTo(t-(g+u),1),bottom:y.precisionTo(n-(d+l),1)}}_updateCropperObject(r,e){const{left:t,top:n,width:i,height:a}=e.calculateTransformWithSrcRect();let o;switch(r){case x.R1_1:o=this._calculateSrcRectByRatio(t,n,i,a,1,1);break;case x.R16_9:o=this._calculateSrcRectByRatio(t,n,i,a,16,9);break;case x.R9_16:o=this._calculateSrcRectByRatio(t,n,i,a,9,16);break;case x.R5_4:o=this._calculateSrcRectByRatio(t,n,i,a,5,4);break;case x.R4_5:o=this._calculateSrcRectByRatio(t,n,i,a,4,5);break;case x.R4_3:o=this._calculateSrcRectByRatio(t,n,i,a,4,3);break;case x.R3_4:o=this._calculateSrcRectByRatio(t,n,i,a,3,4);break;case x.R3_2:o=this._calculateSrcRectByRatio(t,n,i,a,3,2);break;case x.R2_3:o=this._calculateSrcRectByRatio(t,n,i,a,2,3);break;case x.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!==he.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=E.getDrawingShapeKeyByDrawingSearch({unitId:t,subUnitId:n,drawingId:i}),l=o.getObject(u);if(l==null)return;if(!(l instanceof y.Image)){this._messageService.show({type:U.MessageType.Error,content:this._localeService.t("image-cropper.error")});return}const g=o.getTransformer();g==null||g.clearControls();const d=new le(`${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(E.SetDrawingSelectedOperation.id,[{unitId:t,subUnitId:n,drawingId:i}])}))}_searchCropObject(r){const e=r.getAllObjectsByOrder();for(const t of e)if(t instanceof le)return t}_initCloseCrop(){this.disposeWithMe(this._commandService.onCommandExecuted(e=>{if(e.id!==Q.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(Me.switchMap(e=>e?e.activeSheet$:Me.of(null)));this.disposeWithMe(r.subscribe(()=>{this._commandService.syncExecuteCommand(Q.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 le))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 le))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=y.CURSOR_TYPE.MOVE})),this.disposeWithMe(r.onPointerLeave$.subscribeEvent(()=>{r.cursor=y.CURSOR_TYPE.DEFAULT}))}_endCropListener(r){const e=r.getTransformerByCreate();this.disposeWithMe(e.clearControl$.subscribe(t=>{t===!0&&this._commandService.syncExecuteCommand(Q.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,_={left:m,top:v,right:g-m-a,bottom:d-v-i},I={..._};if(p!==0){const M=t+a/2,N=n+i/2,j=new y.Vector2(M,N),b=g/2+u,T=d/2+l,O=new y.Vector2(b,T),B=new y.Vector2(u,l);B.rotateByPoint(y.degToRad(p),O);const P=B.clone();P.rotateByPoint(y.degToRad(-p),j);const G=t-P.x,H=n-P.y;I.left=G,I.top=H,I.right=g-G-a,I.bottom=d-H-i}return{srcRect:_,srcRectAngle:I}}};ve=ut([ie(0,h.ICommandService),ie(1,E.IDrawingManagerService),ie(2,y.IRenderManagerService),ie(3,h.IUniverInstanceService),ie(4,A.IMessageService),ie(5,h.Inject(h.LocaleService))],ve);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},ye=(s,r)=>(e,t)=>r(e,t,s);D.DrawingRenderService=class{constructor(r,e,t){this._drawingManagerService=r,this._imageIoService=e,this._galleryService=t}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 _ of m){const{left:I,top:M,width:N,height:j,angle:b,flipX:T,flipY:O,skewX:B,skewY:P}=_,G=m.indexOf(_),H=E.getDrawingShapeKeyByDrawingSearch({unitId:l,subUnitId:g,drawingId:d},p?G:void 0),V=e.getObject(H);if(V!=null){V.transformByState({left:I,top:M,width:N,height:j,angle:b,flipX:T,flipY:O,skewX:B,skewY:P});continue}const Y=this._drawingManagerService.getDrawingOrder(l,g),ae=Y.indexOf(d),te={..._,zIndex:ae===-1?Y.length-1:ae},re=this._imageIoService.getImageSourceCache(i,a);let se=!1;if(re!=null)te.image=re;else{if(a===E.ImageSourceType.UUID)try{te.url=await this._imageIoService.getImage(i)}catch(De){console.error(De);continue}else te.url=i;se=!0}if(e.getObject(H))continue;te.printable=!0;const X=new y.Image(H,te);se&&this._imageIoService.addImageSourceCache(i,a,X.getNative()),this._drawingManagerService.getDrawingVisible()&&(e.addObject(X,y.DRAWING_OBJECT_LAYER_INDEX),this._drawingManagerService.getDrawingEditable()&&e.attachTransformerTo(X),u&&Ge({drawingId:u,unitId:l,subUnitId:g},X,e,this._drawingManagerService),c!=null&&X.setPrstGeom(c),o!=null&&X.setSrcRect(o),v.push(X))}return v}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:_,angle:I,flipX:M,flipY:N,skewX:j,skewY:b}=p,T=g.indexOf(p),O=E.getDrawingShapeKeyByDrawingSearch({unitId:a,subUnitId:o,drawingId:c},u?T:void 0),B=e.getObject(O);if(B!=null){B.transformByState({left:S,top:m,width:v,height:_,angle:I,flipX:M,flipY:N,skewX:j,skewY:b});continue}const P=this._drawingManagerService.getDrawingOrder(a,o),G=P.indexOf(c),H={...p,zIndex:G===-1?P.length-1:G};if(e.getObject(O))continue;H.printable=!1;const V=new y.Rect(O,H);this._drawingManagerService.getDrawingVisible()&&(e.addObject(V,y.DRAWING_OBJECT_LAYER_INDEX),this._drawingManagerService.getDrawingEditable()&&r.allowTransform!==!1&&e.attachTransformerTo(V),i&&Ge({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)switch(t.drawingType){case 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)}}},D.DrawingRenderService=dt([ye(0,E.IDrawingManagerService),ye(1,E.IImageIoService),ye(2,A.IGalleryService)],D.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},ee=(s,r)=>(e,t)=>r(e,t,s);let we=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===Ie.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=E.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(E.SetDrawingSelectedOperation.id,s)}_drawingAddListener(){this.disposeWithMe(this._drawingManagerService.add$.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=$e(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=E.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=y.CURSOR_TYPE.GRAB}))),this.disposeWithMe(h.toDisposable(s.onPointerLeave$.subscribeEvent(()=>{s.cursor=y.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)})))}};we=ft([ee(0,h.ICommandService),ee(1,y.IRenderManagerService),ee(2,E.IDrawingManagerService),ee(3,A.IDialogService),ee(4,E.IImageIoService),ee(5,h.IUniverInstanceService),ee(6,h.Inject(D.DrawingRenderService))],we);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";D.UniverDrawingUIPlugin=(be=class extends h.Plugin{constructor(r=Oe,e,t){super(),this._config=r,this._injector=e,this._configService=t;const{menu:n,...i}=h.merge({},Oe,this._config);n&&this._configService.setConfig("menu",n,{merge:!0}),this._configService.setConfig(Ze,i)}onStarting(){this._initDependencies()}onRendered(){this._injector.get(me),this._injector.get(fe),this._injector.get(ve),this._injector.get(we)}_initDependencies(){[[D.DrawingRenderService],[me],[fe],[ve],[we]].forEach(e=>this._injector.add(e))}},J(be,"pluginName",vt),be),D.UniverDrawingUIPlugin=mt([Ve(1,h.Inject(h.Injector)),Ve(2,h.IConfigService)],D.UniverDrawingUIPlugin);const wt=s=>{const r=A.useDependency(h.ICommandService),e=A.useDependency(h.LocaleService),{alignShow:t}=s,[n,i]=C.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(de.id,{alignType:c})}return f.jsxs("div",{className:U.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(U.Select,{value:n,options:a,onChange:o})})})]})},St=s=>{const{arrangeShow:r,drawings:e}=s,t=A.useDependency(h.LocaleService),n=A.useDependency(E.IDrawingManagerService),[i,a]=C.useState(e);C.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:U.clsx("univer-grid univer-gap-2 univer-py-2 univer-text-gray-400",{"univer-hidden":!r}),children:[f.jsx("header",{className:"univer-text-gray-600 dark:!univer-text-gray-200",children:f.jsx("div",{children:t.t("image-panel.arrange.title")})}),f.jsxs("div",{className:"univer-grid univer-grid-cols-2 univer-gap-2",children:[f.jsxs(U.Button,{onClick:()=>{o(h.ArrangeTypeEnum.forward)},children:[f.jsx(je,{}),t.t("image-panel.arrange.forward")]}),f.jsxs(U.Button,{onClick:()=>{o(h.ArrangeTypeEnum.backward)},children:[f.jsx(Re,{}),t.t("image-panel.arrange.backward")]}),f.jsxs(U.Button,{onClick:()=>{o(h.ArrangeTypeEnum.front)},children:[f.jsx(Ae,{}),t.t("image-panel.arrange.front")]}),f.jsxs(U.Button,{onClick:()=>{o(h.ArrangeTypeEnum.back)},children:[f.jsx(Pe,{}),t.t("image-panel.arrange.back")]})]})]})},Ct=s=>{const r=A.useDependency(h.LocaleService),e=A.useDependency(y.IRenderManagerService),t=A.useDependency(E.IDrawingManagerService),{hasGroup:n,drawings:i}=s,[a,o]=C.useState(!1),[c,u]=C.useState(!0),[l,g]=C.useState(!0),d=()=>{const m=t.getFocusDrawings(),{unitId:v,subUnitId:_}=m[0],I=h.generateRandomId(10),M=y.getGroupState(0,0,m.map(b=>b.transform||{})),N={unitId:v,subUnitId:_,drawingId:I,drawingType:h.DrawingTypeEnum.DRAWING_GROUP,transform:M},j=m.map(b=>{const T=b.transform||{left:0,top:0},{unitId:O,subUnitId:B,drawingId:P}=b;return{unitId:O,subUnitId:B,drawingId:P,transform:{...T,left:T.left-M.left,top:T.top-M.top},groupId:I}});t.featurePluginGroupUpdateNotification([{parent:N,children:j}])},p=m=>{if(m.drawingType!==h.DrawingTypeEnum.DRAWING_GROUP)return;const{unitId:v,subUnitId:_,drawingId:I,transform:M={width:0,height:0}}=m;if(M==null)return;const N=t.getDrawingsByGroup({unitId:v,subUnitId:_,drawingId:I});if(N.length===0)return;const j=N.map(b=>{const{transform:T}=b,{unitId:O,subUnitId:B,drawingId:P}=b,G=y.transformObjectOutOfGroup(T||{},M,M.width||0,M.height||0);return{unitId:O,subUnitId:B,drawingId:P,transform:{...T,...G},groupId:void 0}});return{parent:m,children:j}},S=()=>{const v=t.getFocusDrawings().map(_=>p(_)).filter(_=>_!=null);v.length!==0&&t.featurePluginUngroupUpdateNotification(v)};return C.useEffect(()=>{const m=i[0];if(m==null)return;const{unitId:v}=m,_=e.getRenderById(v),I=_==null?void 0:_.scene;if(I==null)return;const M=I.getTransformerByCreate(),N=M.clearControl$.subscribe(b=>{b===!0&&o(!1)}),j=M.changeStart$.subscribe(b=>{const{objects:T}=b,O=ce(T,t),B=O.filter(V=>(V==null?void 0:V.drawingType)===h.DrawingTypeEnum.DRAWING_GROUP);let P=!1,G=!1;O.length>1&&(P=!0),B.length>0&&(G=!0),o(P||G),u(P),g(G)});return()=>{j.unsubscribe(),N.unsubscribe()}},[]),f.jsxs("div",{className:U.clsx("univer-grid univer-gap-2 univer-py-2 univer-text-gray-400",{"univer-hidden":n===!0&&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(U.Button,{className:U.clsx({"univer-hidden":!c}),onClick:d,children:[f.jsx(Be,{}),r.t("image-panel.group.group")]}),f.jsxs(U.Button,{className:U.clsx({"univer-hidden":!l}),onClick:S,children:[f.jsx(Le,{}),r.t("image-panel.group.unGroup")]})]})]})},Se=20,Ce=20,We=[-360,360],_e=300,_t=s=>{var Ke;const r=A.useDependency(h.LocaleService),e=A.useDependency(E.IDrawingManagerService),t=A.useDependency(y.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:_=0,left:I=0,top:M=0,angle:N=0}=o,[j,b]=C.useState(v),[T,O]=C.useState(_),[B,P]=C.useState(I),[G,H]=C.useState(M),[V,Y]=C.useState(N),[ae,te]=C.useState(m.keepRatio),re=(w,L,$,W)=>{const{width:k,height:q}=S,{ancestorLeft:K,ancestorTop:Z}=p;let z=w,ne=L,ue=$,ge=W;return w+K<0&&(z=-K),L+Z<0&&(ne=-Z),ue=k-z-K,ue<Se&&(ue=Se),ge=q-ne-Z,ge<Ce&&(ge=Ce),w+ue+K>k&&(z=k-$-K),L+ge+Z>q&&(ne=q-W-Z),{limitLeft:z,limitTop:ne,limitWidth:ue,limitHeight:ge}},se=w=>{const{objects:L}=w,$=ce(L,e);if($.length!==1)return;const W=$[0];if(W==null)return;const{transform:k}=W;if(k==null)return;const{width:q,height:K,left:Z,top:z,angle:ne}=k;q!=null&&b(q),K!=null&&O(K),Z!=null&&P(Z),z!=null&&H(z),ne!=null&&Y(ne)};C.useEffect(()=>{const w=[m.changeStart$.subscribe(L=>{se(L)}),m.changing$.subscribe(L=>{se(L)}),m.changeEnd$.subscribe(L=>{se(L)}),e.focus$.subscribe(L=>{if(L.length!==1)return;const $=e.getDrawingByParam(L[0]);if($==null)return;const W=$.transform;if(W==null)return;const{width:k,height:q,left:K,top:Z,angle:z}=W;k!=null&&b(k),q!=null&&O(q),K!=null&&P(K),Z!=null&&H(Z),z!=null&&Y(z)})];return()=>{w.forEach(L=>L.unsubscribe())}},[]);const X=h.debounce(w=>{if(w==null)return;const{limitWidth:L,limitHeight:$}=re(B,G,w,T);w=Math.min(w,L);const W={unitId:c,subUnitId:u,drawingId:l,drawingType:g,transform:{width:w}};if(ae){let k=w/j*T;if(k=Math.max(k,Ce),k>$)return;O(k),W.transform.height=k}b(w),e.featurePluginUpdateNotification([W]),m.refreshControls().changeNotification()},_e),De=h.debounce(w=>{if(w==null)return;const{limitHeight:L,limitWidth:$}=re(B,G,j,w);w=Math.min(w,L);const W={unitId:c,subUnitId:u,drawingId:l,drawingType:g,transform:{height:w}};if(ae){let k=w/T*j;if(k=Math.max(k,Se),k>$)return;b(k),W.transform.width=k}O(w),e.featurePluginUpdateNotification([W]),m.refreshControls().changeNotification()},_e),bt=h.debounce(w=>{if(w==null)return;const{limitLeft:L}=re(w,G,j,T);w=L;const $={unitId:c,subUnitId:u,drawingId:l,drawingType:g,transform:{left:w}};P(w),e.featurePluginUpdateNotification([$]),m.refreshControls().changeNotification()},_e),Dt=h.debounce(w=>{if(w==null)return;const{limitTop:L}=re(B,w,j,T);w=L;const $={unitId:c,subUnitId:u,drawingId:l,drawingType:g,transform:{top:w}};H(w),e.featurePluginUpdateNotification([$]),m.refreshControls().changeNotification()},_e),Mt=w=>{if(w==null)return;const L={unitId:c,subUnitId:u,drawingId:l,drawingType:g,transform:{angle:w}};Y(w),e.featurePluginUpdateNotification([L]),m.refreshControls().changeNotification()},Ot=w=>{te(w),m.keepRatio=w};return f.jsxs("div",{className:U.clsx("univer-grid univer-gap-2 univer-py-2 univer-text-gray-400",{"univer-hidden":!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(U.InputNumber,{precision:1,value:j,min:Se,onChange:w=>{X(w)}})]}),f.jsxs("div",{children:[f.jsx("span",{children:r.t("image-panel.transform.height")}),f.jsx(U.InputNumber,{precision:1,value:T,min:Ce,onChange:w=>{De(w)}})]}),f.jsxs("div",{children:[f.jsx("span",{children:r.t("image-panel.transform.lock")}),f.jsx("div",{className:"univer-text-center",children:f.jsx(U.Checkbox,{checked:ae,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(U.InputNumber,{precision:1,value:B,onChange:w=>{bt(w)}})]}),f.jsxs("div",{children:[f.jsx("span",{children:r.t("image-panel.transform.y")}),f.jsx(U.InputNumber,{precision:1,value:G,onChange:w=>{Dt(w)}})]}),f.jsxs("div",{children:[f.jsx("span",{children:r.t("image-panel.transform.rotate")}),f.jsx(U.InputNumber,{precision:1,value:V,min:We[0],max:We[1],onChange:Mt})]})]})]})},It=s=>{const r=A.useDependency(h.ICommandService),e=A.useDependency(h.LocaleService),{drawings:t,cropperShow:n}=s;if(t[0]==null)return;const[a,o]=C.useState(x.FREE),c=C.useRef(!1),u=[{label:e.t("image-panel.crop.mode"),value:x.FREE},{label:"1:1",value:x.R1_1},{label:"16:9",value:x.R16_9},{label:"9:16",value:x.R9_16},{label:"5:4",value:x.R5_4},{label:"4:5",value:x.R4_5},{label:"4:3",value:x.R4_3},{label:"3:4",value:x.R3_4},{label:"3:2",value:x.R3_2},{label:"2:3",value:x.R2_3}];C.useEffect(()=>{const d=r.onCommandExecuted(p=>{if(p.id===Q.id){const S=p.params;S!=null&&S.isAuto||(c.current=!1)}});return()=>{d==null||d.dispose()}},[]);function l(d){o(d),c.current&&r.executeCommand(oe.id,{cropType:d})}const g=d=>{r.executeCommand(oe.id,{cropType:d}),c.current=!0};return f.jsxs("div",{className:U.clsx("univer-grid univer-gap-2 univer-py-2 univer-text-gray-400",{"univer-hidden":!n}),children:[f.jsx("header",{className:"univer-text-gray-600 dark:!univer-text-gray-200",children:f.jsx("div",{children:e.t("image-panel.crop.title")})}),f.jsxs("div",{className:"univer-flex univer-items-center univer-justify-center univer-gap-2",children:[f.jsxs(U.Button,{onClick:()=>{g(a)},children:[f.jsx(Ne,{}),e.t("image-panel.crop.start")]}),f.jsx(U.Select,{value:a,options:u,onChange:l})]})]})},yt=s=>{const r=A.useDependency(E.IDrawingManagerService),e=A.useDependency(y.IRenderManagerService),t=A.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]=C.useState(!0),[_,I]=C.useState(!0),[M,N]=C.useState(!1),[j,b]=C.useState(!0),[T,O]=C.useState(!1);return C.useEffect(()=>{const B=S.clearControl$.subscribe(H=>{H===!0&&(v(!1),I(!1),N(!1),b(!1),O(!0))}),P=S.changeStart$.subscribe(H=>{const{objects:V}=H,Y=ce(V,r);Y.length===0?(v(!1),I(!1),N(!1),b(!1),O(!0)):Y.length===1?(v(!0),I(!0),N(!1),b(!0),O(!1)):(v(!0),I(!1),N(!0),b(!1),O(!1))}),G=r.focus$.subscribe(H=>{H.length===0?(v(!1),I(!1),N(!1),b(!1),O(!0)):H.length===1?(v(!0),I(!0),N(!1),b(!0),O(!1)):(v(!0),I(!1),N(!0),b(!1),O(!1))});return()=>{P.unsubscribe(),B.unsubscribe(),G.unsubscribe()}},[]),f.jsxs(f.Fragment,{children:[f.jsx("div",{className:U.clsx("univer-h-full",{"univer-hidden":!T}),children:f.jsx("div",{className:"univer-flex univer-h-full univer-items-center univer-justify-center",children:f.jsx("span",{children:t.t("image-panel.null")})})}),f.jsx(St,{arrangeShow:i===!0?m:!1,drawings:n}),f.jsx(_t,{transformShow:a===!0?_:!1,drawings:n}),f.jsx(wt,{alignShow:o===!0?M:!1,drawings:n}),f.jsx(It,{cropperShow:c===!0?j:!1,drawings:n}),f.jsx(Ct,{hasGroup:u,drawings:n})]})};D.AutoImageCropOperation=oe,D.COMPONENT_IMAGE_POPUP_MENU=Ee,D.CloseImageCropOperation=Q,D.DrawingCommonPanel=yt,D.ImageCropperObject=le,D.ImagePopupMenu=He,D.ImageResetSizeOperation=Ie,D.OpenImageCropOperation=he,D.SetDrawingAlignOperation=de,D.getUpdateParams=ce,Object.defineProperty(D,Symbol.toStringTag,{value:"Module"})}));
|
|
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,x,f,B,C,Ee){"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 J=(y,h,M)=>Tt(y,typeof h!="symbol"?h+"":h,M);var Me;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 de={id:"sheet.operation.set-image-align",type:h.CommandType.OPERATION,handler:(s,r)=>!0},he={id:"sheet.operation.open-image-crop",type:h.CommandType.OPERATION,handler:(s,r)=>!0},Q={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 oe={id:"sheet.operation.Auto-image-crop",type:h.CommandType.OPERATION,handler:(s,r)=>!0},Ie={id:"sheet.operation.image-reset-size",type:h.CommandType.OPERATION,handler:(s,r)=>!0};function ye(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 be(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={},Pe="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=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 C.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"}}]},Ue=C.forwardRef(function(r,e){return C.createElement(F,Object.assign({},r,{id:"bottom-icon",ref:e,icon:Xe}))});Ue.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=C.forwardRef(function(r,e){return C.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=C.forwardRef(function(r,e){return C.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=C.forwardRef(function(r,e){return C.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=C.forwardRef(function(r,e){return C.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=C.forwardRef(function(r,e){return C.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"}}]},xe=C.forwardRef(function(r,e){return C.createElement(F,Object.assign({},r,{id:"topmost-icon",ref:e,icon:rt}))});xe.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"}}]},He=C.forwardRef(function(r,e){return C.createElement(F,Object.assign({},r,{id:"ungroup-icon",ref:e,icon:nt}))});He.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=C.forwardRef(function(r,e){return C.createElement(F,Object.assign({},r,{id:"autofill-double-icon",ref:e,icon:it}))});ke.displayName="AutofillDoubleIcon";function Ge(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=x.useDependency(h.ICommandService),n=x.useDependency(h.LocaleService),[i,a]=C.useState(!1),[o,c]=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},$e=(s,r)=>(e,t)=>r(e,t,s);let fe=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(Pe,Ge))}_initCommands(){[he,Q,Ie,de,oe].forEach(s=>this.disposeWithMe(this._commandService.registerCommand(s)))}_init(){this._initCommands(),this._initCustomComponents()}};fe=st([$e(0,h.Inject(x.ComponentManager)),$e(1,h.ICommandService)],fe);function ce(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},pe=(s,r)=>(e,t)=>r(e,t,s);let me=class extends h.Disposable{constructor(r,e,t,n){super();J(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=be(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===de.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(Q.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:_=0,width:I=0,height:O=0}=m.transform;i=Math.min(i,v),a=Math.min(a,_),o=Math.max(o,v+I),c=Math.max(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:_,drawingId:I,transform:O,drawingType:N}=S,{left:j=0,top:D=0,width:T=0,height:E=0}=O;let U=j,P=D;switch(e){case R.left:U=t;break;case R.center:U=t+(i-t)/2-T/2;break;case R.right:U=i-T;break;case R.top:P=n;break;case R.middle:P=n+(a-n)/2-E/2;break;case R.bottom:P=a-E;break;case R.horizon:U=t+c*m;break;case R.vertical:P=n+u*m;break}(U!==j||P!==D)&&l.push({unitId:v,subUnitId:_,drawingId:I,drawingType:N,transform:{left:U,top:P}})}),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:_=!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:d,top:p,width:S,height:m,angle:v,flipX:_,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:d=0,top:p=0,width:S=0,height:m=0,angle:v=0,flipX:_=!1,flipY:I=!1,skewX:O=0,skewY:N=0}=c;g.transformByState({left:d,top:p,width:S,height:m,angle:v,flipX:_,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 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.ancestorGroup;if(_==null&&c instanceof b.Group&&(_=c),_==null)return null;const I=this._drawingManagerService.getDrawingOKey(_.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:U,angle:P}=_;return{left:D,top:T,height:E,width:U,angle:P}}}else if(v!=null){const{unitId:_,subUnitId:I,drawingId:O}=v;return o.push({unitId:_,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(ce(i,this._drawingManagerService),t);a.length>0&&this._drawingManagerService.featurePluginUpdateNotification(a)})))}};me=ct([pe(0,h.IUniverInstanceService),pe(1,h.ICommandService),pe(2,b.IRenderManagerService),pe(3,M.IDrawingManagerService)],me);class le 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);J(this,"_srcRect");J(this,"_prstGeom");J(this,"_applyTransform");J(this,"_dragPadding",8);J(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},ie=(s,r)=>(e,t)=>r(e,t,s);let ve=class extends h.Disposable{constructor(r,e,t,n,i,a){super();J(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!==oe.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(Q.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(he.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!==he.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 le(`${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 le)return t}_initCloseCrop(){this.disposeWithMe(this._commandService.onCommandExecuted(e=>{if(e.id!==Q.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(Ee.switchMap(e=>e?e.activeSheet$:Ee.of(null)));this.disposeWithMe(r.subscribe(()=>{this._commandService.syncExecuteCommand(Q.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 le))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 le))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(Q.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,_={left:m,top:v,right:g-m-a,bottom:d-v-i},I={..._};if(p!==0){const O=t+a/2,N=n+i/2,j=new b.Vector2(O,N),D=g/2+u,T=d/2+l,E=new b.Vector2(D,T),U=new b.Vector2(u,l);U.rotateByPoint(b.degToRad(p),E);const P=U.clone();P.rotateByPoint(b.degToRad(-p),j);const G=t-P.x,H=n-P.y;I.left=G,I.top=H,I.right=g-G-a,I.bottom=d-H-i}return{srcRect:_,srcRectAngle:I}}};ve=ut([ie(0,h.ICommandService),ie(1,M.IDrawingManagerService),ie(2,b.IRenderManagerService),ie(3,h.IUniverInstanceService),ie(4,x.IMessageService),ie(5,h.Inject(h.LocaleService))],ve);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},De=(s,r)=>(e,t)=>r(e,t,s);y.DrawingRenderService=class{constructor(r,e,t){this._drawingManagerService=r,this._imageIoService=e,this._galleryService=t}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 _ of m){const{left:I,top:O,width:N,height:j,angle:D,flipX:T,flipY:E,skewX:U,skewY:P}=_,G=m.indexOf(_),H=M.getDrawingShapeKeyByDrawingSearch({unitId:l,subUnitId:g,drawingId:d},p?G:void 0),V=e.getObject(H);if(V!=null){V.transformByState({left:I,top:O,width:N,height:j,angle:D,flipX:T,flipY:E,skewX:U,skewY:P});continue}const Y=this._drawingManagerService.getDrawingOrder(l,g),ae=Y.indexOf(d),te={..._,zIndex:ae===-1?Y.length-1:ae},re=this._imageIoService.getImageSourceCache(i,a);let se=!1;if(re!=null)te.image=re;else{if(a===M.ImageSourceType.UUID)try{te.url=await this._imageIoService.getImage(i)}catch(Oe){console.error(Oe);continue}else te.url=i;se=!0}if(e.getObject(H))continue;te.printable=!0;const X=new b.Image(H,te);se&&this._imageIoService.addImageSourceCache(i,a,X.getNative()),this._drawingManagerService.getDrawingVisible()&&(e.addObject(X,b.DRAWING_OBJECT_LAYER_INDEX),this._drawingManagerService.getDrawingEditable()&&e.attachTransformerTo(X),u&&ye({drawingId:u,unitId:l,subUnitId:g},X,e,this._drawingManagerService),c!=null&&X.setPrstGeom(c),o!=null&&X.setSrcRect(o),v.push(X))}return v}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:_,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),U=e.getObject(E);if(U!=null){U.transformByState({left:S,top:m,width:v,height:_,angle:I,flipX:O,flipY:N,skewX:j,skewY:D});continue}const P=this._drawingManagerService.getDrawingOrder(a,o),G=P.indexOf(c),H={...p,zIndex:G===-1?P.length-1:G};if(e.getObject(E))continue;H.printable=!1;const V=new b.Rect(E,H);this._drawingManagerService.getDrawingVisible()&&(e.addObject(V,b.DRAWING_OBJECT_LAYER_INDEX),this._drawingManagerService.getDrawingEditable()&&r.allowTransform!==!1&&e.attachTransformerTo(V),i&&ye({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([De(0,M.IDrawingManagerService),De(1,M.IImageIoService),De(2,x.IGalleryService)],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},ee=(s,r)=>(e,t)=>r(e,t,s);let we=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===Ie.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$.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=be(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)})))}};we=ft([ee(0,h.ICommandService),ee(1,b.IRenderManagerService),ee(2,M.IDrawingManagerService),ee(3,x.IDialogService),ee(4,M.IImageIoService),ee(5,h.IUniverInstanceService),ee(6,h.Inject(y.DrawingRenderService))],we);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=(Me=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(me),this._injector.get(fe),this._injector.get(ve),this._injector.get(we)}_initDependencies(){[[y.DrawingRenderService],[me],[fe],[ve],[we]].forEach(e=>this._injector.add(e))}},J(Me,"pluginName",vt),Me),y.UniverDrawingUIPlugin=mt([Ve(1,h.Inject(h.Injector)),Ve(2,h.IConfigService)],y.UniverDrawingUIPlugin);const wt=s=>{const r=x.useDependency(h.ICommandService),e=x.useDependency(h.LocaleService),{alignShow:t}=s,[n,i]=C.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(de.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=x.useDependency(h.LocaleService),n=x.useDependency(M.IDrawingManagerService),[i,a]=C.useState(e);C.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(xe,{}),t.t("image-panel.arrange.front")]}),f.jsxs(B.Button,{onClick:()=>{o(h.ArrangeTypeEnum.back)},children:[f.jsx(Ue,{}),t.t("image-panel.arrange.back")]})]})]})},Ct=s=>{const r=x.useDependency(h.LocaleService),e=x.useDependency(b.IRenderManagerService),t=x.useDependency(M.IDrawingManagerService),{hasGroup:n,drawings:i}=s,[a,o]=C.useState(!1),[c,u]=C.useState(!0),[l,g]=C.useState(!0),d=()=>{const m=t.getFocusDrawings(),{unitId:v,subUnitId:_}=m[0],I=h.generateRandomId(10),O=b.getGroupState(0,0,m.map(D=>D.transform||{})),N={unitId:v,subUnitId:_,drawingId:I,drawingType:h.DrawingTypeEnum.DRAWING_GROUP,transform:O},j=m.map(D=>{const T=D.transform||{left:0,top:0},{unitId:E,subUnitId:U,drawingId:P}=D;return{unitId:E,subUnitId:U,drawingId:P,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!==h.DrawingTypeEnum.DRAWING_GROUP)return;const{unitId:v,subUnitId:_,drawingId:I,transform:O={width:0,height:0}}=m;if(O==null)return;const N=t.getDrawingsByGroup({unitId:v,subUnitId:_,drawingId:I});if(N.length===0)return;const j=N.map(D=>{const{transform:T}=D,{unitId:E,subUnitId:U,drawingId:P}=D,G=b.transformObjectOutOfGroup(T||{},O,O.width||0,O.height||0);return{unitId:E,subUnitId:U,drawingId:P,transform:{...T,...G},groupId:void 0}});return{parent:m,children:j}},S=()=>{const v=t.getFocusDrawings().map(_=>p(_)).filter(_=>_!=null);v.length!==0&&t.featurePluginUngroupUpdateNotification(v)};return C.useEffect(()=>{const m=i[0];if(m==null)return;const{unitId:v}=m,_=e.getRenderById(v),I=_==null?void 0:_.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=ce(T,t),U=E.filter(V=>(V==null?void 0:V.drawingType)===h.DrawingTypeEnum.DRAWING_GROUP);let P=!1,G=!1;E.length>1&&(P=!0),U.length>0&&(G=!0),o(P||G),u(P),g(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: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(He,{}),r.t("image-panel.group.unGroup")]})]})]})},Se=20,Ce=20,We=[-360,360],_e=300,_t=s=>{var Ke;const r=x.useDependency(h.LocaleService),e=x.useDependency(M.IDrawingManagerService),t=x.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:_=0,left:I=0,top:O=0,angle:N=0}=o,[j,D]=C.useState(v),[T,E]=C.useState(_),[U,P]=C.useState(I),[G,H]=C.useState(O),[V,Y]=C.useState(N),[ae,te]=C.useState(m.keepRatio),re=(w,A,$,W)=>{const{width:k,height:q}=S,{ancestorLeft:K,ancestorTop:Z}=p;let z=w,ne=A,ue=$,ge=W;return w+K<0&&(z=-K),A+Z<0&&(ne=-Z),ue=k-z-K,ue<Se&&(ue=Se),ge=q-ne-Z,ge<Ce&&(ge=Ce),w+ue+K>k&&(z=k-$-K),A+ge+Z>q&&(ne=q-W-Z),{limitLeft:z,limitTop:ne,limitWidth:ue,limitHeight:ge}},se=w=>{const{objects:A}=w,$=ce(A,e);if($.length!==1)return;const W=$[0];if(W==null)return;const{transform:k}=W;if(k==null)return;const{width:q,height:K,left:Z,top:z,angle:ne}=k;q!=null&&D(q),K!=null&&E(K),Z!=null&&P(Z),z!=null&&H(z),ne!=null&&Y(ne)};C.useEffect(()=>{const w=[m.changeStart$.subscribe(A=>{se(A)}),m.changing$.subscribe(A=>{se(A)}),m.changeEnd$.subscribe(A=>{se(A)}),e.focus$.subscribe(A=>{if(A.length!==1)return;const $=e.getDrawingByParam(A[0]);if($==null)return;const W=$.transform;if(W==null)return;const{width:k,height:q,left:K,top:Z,angle:z}=W;k!=null&&D(k),q!=null&&E(q),K!=null&&P(K),Z!=null&&H(Z),z!=null&&Y(z)})];return()=>{w.forEach(A=>A.unsubscribe())}},[]);const X=h.debounce(w=>{if(w==null)return;const{limitWidth:A,limitHeight:$}=re(U,G,w,T);w=Math.min(w,A);const W={unitId:c,subUnitId:u,drawingId:l,drawingType:g,transform:{width:w}};if(ae){let k=w/j*T;if(k=Math.max(k,Ce),k>$)return;E(k),W.transform.height=k}D(w),e.featurePluginUpdateNotification([W]),m.refreshControls().changeNotification()},_e),Oe=h.debounce(w=>{if(w==null)return;const{limitHeight:A,limitWidth:$}=re(U,G,j,w);w=Math.min(w,A);const W={unitId:c,subUnitId:u,drawingId:l,drawingType:g,transform:{height:w}};if(ae){let k=w/T*j;if(k=Math.max(k,Se),k>$)return;D(k),W.transform.width=k}E(w),e.featurePluginUpdateNotification([W]),m.refreshControls().changeNotification()},_e),bt=h.debounce(w=>{if(w==null)return;const{limitLeft:A}=re(w,G,j,T);w=A;const $={unitId:c,subUnitId:u,drawingId:l,drawingType:g,transform:{left:w}};P(w),e.featurePluginUpdateNotification([$]),m.refreshControls().changeNotification()},_e),Dt=h.debounce(w=>{if(w==null)return;const{limitTop:A}=re(U,w,j,T);w=A;const $={unitId:c,subUnitId:u,drawingId:l,drawingType:g,transform:{top:w}};H(w),e.featurePluginUpdateNotification([$]),m.refreshControls().changeNotification()},_e),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=>{te(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:Se,onChange:w=>{X(w)}})]}),f.jsxs("div",{children:[f.jsx("span",{children:r.t("image-panel.transform.height")}),f.jsx(B.InputNumber,{precision:1,value:T,min:Ce,onChange:w=>{Oe(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:ae,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:U,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:G,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=x.useDependency(h.ICommandService),e=x.useDependency(h.LocaleService),{drawings:t,cropperShow:n}=s;if(t[0]==null)return;const[a,o]=C.useState(L.FREE),c=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}];C.useEffect(()=>{const d=r.onCommandExecuted(p=>{if(p.id===Q.id){const S=p.params;S!=null&&S.isAuto||(c.current=!1)}});return()=>{d==null||d.dispose()}},[]);function l(d){o(d),c.current&&r.executeCommand(oe.id,{cropType:d})}const g=d=>{r.executeCommand(oe.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=x.useDependency(M.IDrawingManagerService),e=x.useDependency(b.IRenderManagerService),t=x.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]=C.useState(!0),[_,I]=C.useState(!0),[O,N]=C.useState(!1),[j,D]=C.useState(!0),[T,E]=C.useState(!1);return C.useEffect(()=>{const U=S.clearControl$.subscribe(H=>{H===!0&&(v(!1),I(!1),N(!1),D(!1),E(!0))}),P=S.changeStart$.subscribe(H=>{const{objects:V}=H,Y=ce(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))}),G=r.focus$.subscribe(H=>{H.length===0?(v(!1),I(!1),N(!1),D(!1),E(!0)):H.length===1?(v(!0),I(!0),N(!1),D(!0),E(!1)):(v(!0),I(!1),N(!0),D(!1),E(!1))});return()=>{P.unsubscribe(),U.unsubscribe(),G.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(_t,{transformShow:a===!0?_:!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(Ct,{hasGroup:u,drawings:n})]})};y.AutoImageCropOperation=oe,y.COMPONENT_IMAGE_POPUP_MENU=Pe,y.CloseImageCropOperation=Q,y.DrawingCommonPanel=yt,y.ImageCropperObject=le,y.ImagePopupMenu=Ge,y.ImageResetSizeOperation=Ie,y.OpenImageCropOperation=he,y.SetDrawingAlignOperation=de,y.getCurrentUnitInfo=be,y.getUpdateParams=ce,y.insertGroupObject=ye,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(R,A){typeof exports=="object"&&typeof module<"u"?A(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"],A):(R=typeof globalThis<"u"?globalThis:R||self,A(R.UniverSheetsDrawingUi={},R.UniverEngineRender,R.UniverSheetsUi,R.UniverCore,R.UniverSheetsDrawing,R.UniverSheets,R.UniverDesign,R.UniverDocsUi,R.UniverDrawing,R.UniverUi,R.UniverDocsDrawing,R.UniverDrawingUi,R.rxjs,R.React,R.React))})(this,(function(R,A,b,l,w,C,Y,$e,B,j,bt,ge,U,F,q){"use strict";var rr=Object.defineProperty;var ir=(R,A,b)=>A in R?rr(R,A,{enumerable:!0,configurable:!0,writable:!0,value:b}):R[A]=b;var ie=(R,A,b)=>ir(R,typeof A!="symbol"?A+"":A,b);function J(i,r,e){const{from:t,to:n,flipY:o=!1,flipX:s=!1,angle:a=0,skewX:d=0,skewY:g=0}=i,u=e.getCurrent();if(u==null)return;const c=b.convertPositionSheetOverGridToAbsolute(u.unitId,u.sheetId,{from:t,to:n},e);let{left:m,top:h,width:p,height:S}=c;const f=e.getCurrentSkeleton(),v=f.rowHeaderWidth+f.columnTotalWidth,_=f.columnHeaderHeight+f.rowTotalHeight;return m+p>v&&(m=v-p),h+S>_&&(h=_-S),{flipY:o,flipX:s,angle:a,skewX:d,skewY:g,left:m,top:h,width:p,height:S}}function H(i,r){const{left:e=0,top:t=0,width:n=0,height:o=0,flipY:s=!1,flipX:a=!1,angle:d=0,skewX:g=0,skewY:u=0}=i,c=r.getCellWithCoordByOffset(e,t);if(c==null)return;const m={column:c.actualColumn,columnOffset:A.precisionTo(e-c.startX,1),row:c.actualRow,rowOffset:A.precisionTo(t-c.startY,1)},h=r.getCellWithCoordByOffset(e+n,t+o);if(h==null)return;const p={column:h.actualColumn,columnOffset:A.precisionTo(e+n-h.startX,1),row:h.actualRow,rowOffset:A.precisionTo(t+o-h.startY,1)};return{flipY:s,flipX:a,angle:d,skewX:g,skewY:u,from:m,to:p}}const V={id:"sheet.operation.clear-drawing-transformer",type:l.CommandType.MUTATION,handler:(i,r)=>{const e=i.get(A.IRenderManagerService);return r.forEach(t=>{var n,o;(o=(n=e.getRenderById(t))==null?void 0:n.scene.getTransformer())==null||o.debounceRefreshControls()}),!0}},Se={id:"sheet.command.remove-sheet-image",type:l.CommandType.COMMAND,handler:(i,r)=>{var _,D,M;const e=i.get(l.ICommandService),t=i.get(l.IUndoRedoService),n=i.get(C.SheetInterceptorService),o=i.get(w.ISheetDrawingService);if(!r)return!1;const{drawings:s}=r,a=[];s.forEach(y=>{const{unitId:T}=y;a.push(T)});const d=o.getBatchRemoveOp(s),{unitId:g,subUnitId:u,undo:c,redo:m,objects:h}=d,p=n.onCommandExecute({id:Se.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:c,objects:h,type:w.DrawingApplyType.INSERT}};return l.sequenceExecute([...(_=p.preRedos)!=null?_:[],S,...p.redos],e)?(t.pushUndoRedo({unitID:g,undoMutations:[...(D=p.preUndos)!=null?D:[],f,...p.undos,{id:V.id,params:a}],redoMutations:[...(M=p.preRedos)!=null?M:[],S,...p.redos,{id:V.id,params:a}]}),!0):!1}},lt={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:d,drawingId:g,drawingType:u}=s;return{unitId:a,subUnitId:d,drawingId:g,drawingType:u}});return r.executeCommand(Se.id,{unitId:n,drawings:o})}};function xt(i){const r=[];return i.forEach(e=>{const{parent:t,children:n}=e,{unitId:o,subUnitId:s,drawingId:a}=t,d=A.getGroupState(0,0,n.map(c=>c.transform||{})),g=n.map(c=>{const m=c.transform||{left:0,top:0},{unitId:h,subUnitId:p,drawingId:S}=c;return{unitId:h,subUnitId:p,drawingId:S,transform:{...m,left:m.left-d.left,top:m.top-d.top},groupId:a}}),u={unitId:o,subUnitId:s,drawingId:a,drawingType:l.DrawingTypeEnum.DRAWING_GROUP,transform:d};r.push({parent:u,children:g})}),r}function Kt(i){const r=[];return i.forEach(e=>{const{parent:t,children:n}=e,{unitId:o,subUnitId:s,drawingId:a,transform:d={width:0,height:0}}=t;if(d==null)return;const g=n.map(c=>{const{transform:m}=c,{unitId:h,subUnitId:p,drawingId:S}=c,f=A.transformObjectOutOfGroup(m||{},d,d.width||0,d.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 ut={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:d,undo:g,redo:u,objects:c}=s;return e.syncExecuteCommand(w.SetDrawingApplyMutation.id,{op:u,unitId:a,subUnitId:d,objects:c,type:w.DrawingApplyType.GROUP})?(t.pushUndoRedo({unitID:a,undoMutations:[{id:w.SetDrawingApplyMutation.id,params:{op:g,unitId:a,subUnitId:d,objects:Kt(c),type:w.DrawingApplyType.UNGROUP}},{id:V.id,params:o}],redoMutations:[{id:w.SetDrawingApplyMutation.id,params:{op:u,unitId:a,subUnitId:d,objects:c,type:w.DrawingApplyType.GROUP}},{id:V.id,params:o}]}),!0):!1}},Ee={id:"sheet.command.insert-sheet-image",type:l.CommandType.COMMAND,handler:(i,r)=>{var _,D,M;const e=i.get(l.ICommandService),t=i.get(l.IUndoRedoService),n=i.get(w.ISheetDrawingService),o=i.get(C.SheetInterceptorService);if(!r)return!1;const s=r.drawings,a=s.map(y=>y.unitId),d=n.getBatchAddOp(s),{unitId:g,subUnitId:u,undo:c,redo:m,objects:h}=d,p=o.onCommandExecute({id:Ee.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:c,unitId:g,subUnitId:u,objects:h,type:w.DrawingApplyType.REMOVE}};return l.sequenceExecute([...(_=p.preRedos)!=null?_:[],S,...p.redos],e)?(t.pushUndoRedo({unitID:g,undoMutations:[...(D=p.preUndos)!=null?D:[],f,...p.undos,{id:V.id,params:a}],redoMutations:[...(M=p.preRedos)!=null?M:[],S,...p.redos,{id:V.id,params:a}]}),!0):!1}},gt={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:d}=r,g={unitId:o,subUnitId:s,drawingIds:a};let u;if(d===l.ArrangeTypeEnum.forward?u=n.getForwardDrawingsOp(g):d===l.ArrangeTypeEnum.backward?u=n.getBackwardDrawingOp(g):d===l.ArrangeTypeEnum.front?u=n.getFrontDrawingsOp(g):d===l.ArrangeTypeEnum.back&&(u=n.getBackDrawingsOp(g)),u==null)return!1;const{objects:c,redo:m,undo:h}=u;return e.syncExecuteCommand(w.SetDrawingApplyMutation.id,{op:m,unitId:o,subUnitId:s,objects:c,type:w.DrawingApplyType.ARRANGE})?(t.pushUndoRedo({unitID:o,undoMutations:[{id:w.SetDrawingApplyMutation.id,params:{op:h,unitId:o,subUnitId:s,objects:c,type:w.DrawingApplyType.ARRANGE}}],redoMutations:[{id:w.SetDrawingApplyMutation.id,params:{op:m,unitId:o,subUnitId:s,objects:c,type:w.DrawingApplyType.ARRANGE}}]}),!0):!1}},be={id:"sheet.command.set-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{drawings:o}=r,s=n.getBatchUpdateOp(o),{unitId:a,subUnitId:d,undo:g,redo:u,objects:c}=s;return e.syncExecuteCommand(w.SetDrawingApplyMutation.id,{unitId:a,subUnitId:d,op:u,objects:c,type:w.DrawingApplyType.UPDATE})?(t.pushUndoRedo({unitID:a,undoMutations:[{id:w.SetDrawingApplyMutation.id,params:{unitId:a,subUnitId:d,op:g,objects:c,type:w.DrawingApplyType.UPDATE}},{id:V.id,params:[a]}],redoMutations:[{id:w.SetDrawingApplyMutation.id,params:{unitId:a,subUnitId:d,op:u,objects:c,type:w.DrawingApplyType.UPDATE}},{id:V.id,params:[a]}]}),!0):!1}},ht={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:d,undo:g,redo:u,objects:c}=s;return e.syncExecuteCommand(w.SetDrawingApplyMutation.id,{op:u,unitId:a,subUnitId:d,objects:c,type:w.DrawingApplyType.UNGROUP})?(t.pushUndoRedo({unitID:a,undoMutations:[{id:w.SetDrawingApplyMutation.id,params:{op:g,unitId:a,subUnitId:d,objects:xt(c),type:w.DrawingApplyType.GROUP}},{id:V.id,params:o}],redoMutations:[{id:w.SetDrawingApplyMutation.id,params:{op:u,unitId:a,subUnitId:d,objects:c,type:w.DrawingApplyType.UNGROUP}},{id:V.id,params:o}]}),!0):!1}};var zt=Object.getOwnPropertyDescriptor,qt=(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},te=(i,r)=>(e,t)=>r(e,t,i);function Zt(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 mt(i,r,e,t,n){var _;const{rotatedHeight:o,rotatedWidth:s}=Zt(e,t,n),d=i.get(A.IRenderManagerService).getRenderById(r.unitId);if(!d)return!1;const u=(_=d.with(b.SheetSkeletonManagerService).getSkeletonParam(r.subUnitId))==null?void 0:_.skeleton;if(u==null)return!1;const c=u.getCellByIndex(r.row,r.col),m=c.mergeInfo.endX-c.mergeInfo.startX-2,h=c.mergeInfo.endY-c.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}}R.SheetDrawingUpdateController=class extends l.Disposable{constructor(e,t,n,o,s,a,d,g,u,c,m,h,p){super();ie(this,"_workbookSelections");this._context=e,this._skeletonManagerService=t,this._commandService=n,this._selectionRenderService=o,this._imageIoService=s,this._fileOpenerService=a,this._sheetDrawingService=d,this._drawingManagerService=g,this._contextService=u,this._messageService=c,this._localeService=m,this._injector=p,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:Y.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){let t;try{t=await this._imageIoService.saveImage(e)}catch(D){const M=D.message;M===B.ImageUploadStatusType.ERROR_EXCEED_SIZE?this._messageService.show({type:Y.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:Y.MessageType.Error,content:this._localeService.t("update-status.invalidImageType")}):M===B.ImageUploadStatusType.ERROR_IMAGE&&this._messageService.show({type:Y.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:d,source:g,base64Cache:u}=t,{width:c,height:m,image:h}=await B.getImageSize(u||""),{width:p,height:S}=this._context.scene;this._imageIoService.addImageSourceCache(g,d,h);let f=1;if(c>B.DRAWING_IMAGE_WIDTH_LIMIT||m>B.DRAWING_IMAGE_HEIGHT_LIMIT){const D=B.DRAWING_IMAGE_WIDTH_LIMIT/c,M=B.DRAWING_IMAGE_HEIGHT_LIMIT/m;f=Math.max(D,M)}const v=this._getImagePosition(c*f,m*f,p,S);if(v==null)return;const _={unitId:o,subUnitId:s,drawingId:a,drawingType:l.DrawingTypeEnum.DRAWING_IMAGE,imageSourceType:d,source:g,transform:J(v,this._selectionRenderService,this._skeletonManagerService),sheetTransform:v};return this._commandService.executeCommand(Ee.id,{unitId:o,drawings:[_]})}async _insertCellImage(e,t){var M,y;let n;try{n=await this._imageIoService.saveImage(e)}catch(T){const I=T.message;I===B.ImageUploadStatusType.ERROR_EXCEED_SIZE?this._messageService.show({type:Y.MessageType.Error,content:this._localeService.t("update-status.exceedMaxSize",String(B.DRAWING_IMAGE_ALLOW_SIZE/(1024*1024)))}):I===B.ImageUploadStatusType.ERROR_IMAGE_TYPE?this._messageService.show({type:Y.MessageType.Error,content:this._localeService.t("update-status.invalidImageType")}):I===B.ImageUploadStatusType.ERROR_IMAGE&&this._messageService.show({type:Y.MessageType.Error,content:this._localeService.t("update-status.invalidImage")})}if(n==null)return!1;const{imageId:o,imageSourceType:s,source:a,base64Cache:d}=n,{width:g,height:u,image:c}=await B.getImageSize(d||"");this._imageIoService.addImageSourceCache(a,s,c);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=mt(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},_={unitId:S.getUnitId(),subUnitId:S.getUnitId(),drawingId:o,drawingType:l.DrawingTypeEnum.DRAWING_IMAGE,imageSourceType:s,source:a,transform:$e.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:[_],selection:{collapsed:!0,startOffset:0,endOffset:0}});return D?(S.apply(D),this._commandService.syncExecuteCommand(C.SetRangeValuesCommand.id,{value:{[(M=t==null?void 0:t.row)!=null?M:h]:{[(y=t==null?void 0:t.col)!=null?y: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 h,p;const{width:n,height:o,image:s}=await B.getImageSize(e||"");this._imageIoService.addImageSourceCache(e,l.ImageSourceType.URL,s);const a=this._workbookSelections.getCurrentLastSelection();if(!a)return!1;const d=l.createDocumentModelWithStyle("",{}),g=mt(this._injector,{unitId:this._context.unitId,subUnitId:this._context.unit.getActiveSheet().getSheetId(),row:a.primary.actualRow,col:a.primary.actualColumn},n,o,0);if(!g)return!1;const u={size:{width:g.width,height:g.height},positionH:{relativeFrom:l.ObjectRelativeFromH.PAGE,posOffset:0},positionV:{relativeFrom:l.ObjectRelativeFromV.PARAGRAPH,posOffset:0},angle:0},c={unitId:d.getUnitId(),subUnitId:d.getUnitId(),drawingId:l.generateRandomId(),drawingType:l.DrawingTypeEnum.DRAWING_IMAGE,imageSourceType:l.ImageSourceType.URL,source:e,transform:$e.docDrawingPositionToTransform(u),docTransform:u,behindDoc:l.BooleanNumber.FALSE,title:"",description:"",layoutType:l.PositionedObjectLayoutType.INLINE,wrapText:l.WrapTextType.BOTH_SIDES,distB:0,distL:0,distR:0,distT:0},m=l.BuildTextUtils.drawing.add({documentDataModel:d,drawings:[c],selection:{collapsed:!0,startOffset:0,endOffset:0}});return m?(d.apply(m),this._commandService.syncExecuteCommand(C.SetRangeValuesCommand.id,{value:{[(h=t==null?void 0:t.row)!=null?h:a.primary.actualRow]:{[(p=t==null?void 0:t.col)!=null?p:a.primary.actualColumn]:{p:d.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 d=b.attachRangeWithCoord(this._skeletonManagerService.getCurrent().skeleton,a);if(d==null)return;let{startColumn:g,startRow:u,startX:c,startY:m}=d,h=!1;if(c+e>n&&(c=n-e,c<0&&(c=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(c,m);if(v==null)return;c=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(c+e,m+t);if(S==null)return;const f={column:S.actualColumn,columnOffset:c+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(gt.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:d,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 c=H({...u.transform,...g},this._selectionRenderService);if(c==null)return;const m={...n,transform:{...u.transform,...g,...J(c,this._selectionRenderService,this._skeletonManagerService)},sheetTransform:{...c}};t.push(m)}),t.length>0&&this._commandService.executeCommand(be.id,{unitId:e[0].unitId,drawings:t}))}))}_groupDrawingListener(){this.disposeWithMe(this._drawingManagerService.featurePluginGroupUpdate$.subscribe(e=>{this._commandService.executeCommand(ut.id,e);const{unitId:t,subUnitId:n,drawingId:o}=e[0].parent;this._commandService.syncExecuteCommand(B.SetDrawingSelectedOperation.id,[{unitId:t,subUnitId:n,drawingId:o}])})),this.disposeWithMe(this._drawingManagerService.featurePluginUngroupUpdate$.subscribe(e=>{this._commandService.executeCommand(ht.id,e)}))}_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))}))}},R.SheetDrawingUpdateController=qt([te(1,l.Inject(b.SheetSkeletonManagerService)),te(2,l.ICommandService),te(3,b.ISheetSelectionRenderService),te(4,B.IImageIoService),te(5,j.ILocalFileService),te(6,w.ISheetDrawingService),te(7,B.IDrawingManagerService),te(8,l.IContextService),te(9,j.IMessageService),te(10,l.Inject(l.LocaleService)),te(11,l.Inject(C.SheetsSelectionsService)),te(12,l.Inject(l.Injector))],R.SheetDrawingUpdateController);const Oe={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(A.IRenderManagerService),n=(s=A.getCurrentTypeOfRenderer(l.UniverInstanceType.UNIVER_SHEET,e,t))==null?void 0:s.with(R.SheetDrawingUpdateController);if(!n)return!1;const o=r==null?void 0:r.files;if(o){const d=o.map(g=>n.insertFloatImageByFile(g));return(await Promise.all(d)).every(g=>g)}else return(a=n.insertFloatImage())!=null?a:!1}},pt={id:"sheet.command.insert-cell-image",type:l.CommandType.COMMAND,handler:i=>{var t,n;const r=i.get(l.IUniverInstanceService),e=i.get(A.IRenderManagerService);return(n=(t=A.getCurrentTypeOfRenderer(l.UniverInstanceType.UNIVER_SHEET,r,e))==null?void 0:t.with(R.SheetDrawingUpdateController).insertCellImage())!=null?n:!1}},we={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(b.ISheetSelectionRenderService),{direction:o}=r,s=t.getFocusDrawings();if(s.length===0)return!1;const a=s[0].unitId,d=s.map(u=>{const{transform:c}=u;if(c==null)return null;const m={...c},{left:h=0,top:p=0}=c;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:H(m,n)}}).filter(u=>u!=null);return e.syncExecuteCommand(be.id,{unitId:a,drawings:d})?(e.syncExecuteCommand(V.id,[a]),!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},ft=(i,r)=>(e,t)=>r(e,t,i),he=(i=>(i.CELL_ADDRESS="cellAddress",i.COLUMN_VALUE="columnValue",i))(he||{});const Fe=l.createIdentifier("sheets-drawing-ui.batch-save-images.service");function St(i){let r="",e=i;for(;e>=0;)r=String.fromCharCode(e%26+65)+r,e=Math.floor(e/26)-1;return r}function Le(i,r){return`${St(r)}${i+1}`}function en(i){const r=Le(i.startRow,i.startColumn),e=Le(i.endRow,i.endColumn);return r===e?r:`${r}:${e}`}function Ot(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 At(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 wt(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 Ut(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")}R.BatchSaveImagesService=class extends l.Disposable{constructor(r,e,t){super(),this._univerInstanceService=r,this._selectionService=e,this._imageIoService=t}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:d,startColumn:g,endColumn:u}=s.range;for(let c=a;c<=d;c++)for(let m=g;m<=u;m++){const h=n.getValue(c,m);if(Ot(h)){const p=At(h);p&&o.push({row:c,col:m,cellAddress:Le(c,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 d of t){const{startRow:g,endRow:u,startColumn:c,endColumn:m}=d;for(let h=g;h<=u;h++)for(let p=c;p<=m;p++){const S=s.getValue(h,p);if(Ot(S)){const f=At(S);f&&a.push({row:h,col:p,cellAddress:Le(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 d=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++)d.add(v)}const g=new Set;for(let f=o.startColumn;f<=o.endColumn;f++)if(!d.has(f))for(let v=s;v<=a;v++){const _=n.getValue(v,f);if(_&&(((m=_.v)==null?void 0:m.toString())||((S=(p=(h=_.p)==null?void 0:h.body)==null?void 0:p.dataStream)==null?void 0:S.trim())||"")){g.add(f);break}}const u=[],c=Array.from(g).sort((f,v)=>f-v);for(const f of c)u.push({index:f,label:St(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 d=1/0,g=-1/0;const u=new Set;for(const _ of t){d=Math.min(d,_.startRow),g=Math.max(g,_.endRow);for(let D=_.startColumn;D<=_.endColumn;D++)u.add(D)}const c=new Set;for(let _=a.startColumn;_<=a.endColumn;_++)if(!u.has(_))for(let D=d;D<=g;D++){const M=s.getValue(D,_);if(M&&(((p=M.v)==null?void 0:p.toString())||((v=(f=(S=M.p)==null?void 0:S.body)==null?void 0:f.dataStream)==null?void 0:v.trim())||"")){c.add(_);break}}const m=[],h=Array.from(c).sort((_,D)=>_-D);for(const _ of h)m.push({index:_,label:St(_)});return m}getSelectionRangeNotation(){const r=this._selectionService.getCurrentSelections();return!r||r.length===0?"":r.map(e=>en(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,d,g;const t=this._univerInstanceService.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET),n=wt(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 c=t==null?void 0:t.getActiveSheet();if(c){const h=c.getCellMatrix().getValue(r.row,e.columnIndex);if(h){const p=((s=h.v)==null?void 0:s.toString())||((g=(d=(a=h.p)==null?void 0:a.body)==null?void 0:d.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 d,g,u,c;const o=this._univerInstanceService.getUnit(t,l.UniverInstanceType.UNIVER_SHEET),s=wt(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=((d=S.v)==null?void 0:d.toString())||((c=(u=(g=S.p)==null?void 0:g.body)==null?void 0:u.dataStream)==null?void 0:c.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 d=a.replace(/\.\w+$/,""),g=((o=a.match(/\.\w+$/))==null?void 0:o[0])||".png",u=n.get(d)||0;u>0&&(a=`${d}_${u}${g}`),n.set(d,u+1);try{const c=await this._getImageBlob(s),h=await(await t.getFileHandle(a,{create:!0})).createWritable();await h.write(c),await h.close()}catch(c){throw console.error(`Failed to save image ${a}:`,c),c}}}async saveImagesWithContext(r,e,t,n){var a;const o=await window.showDirectoryPicker({mode:"readwrite"}),s=new Map;for(const d of r){let g=this.generateFileNameWithContext(d,e,t,n);const u=g.replace(/\.\w+$/,""),c=((a=g.match(/\.\w+$/))==null?void 0:a[0])||".png",m=s.get(u)||0;m>0&&(g=`${u}_${m}${c}`),s.set(u,m+1);try{const h=await this._getImageBlob(d),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=wt(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 Ut(e,l.ImageSourceType.URL)}return Ut(r.source,r.imageSourceType)}},R.BatchSaveImagesService=Qt([ft(0,l.IUniverInstanceService),ft(1,l.Inject(C.SheetsSelectionsService)),ft(2,l.IImageIoService)],R.BatchSaveImagesService);const ve="sheet.dialog.batch-save-images",_e={id:"sheet.command.save-cell-images",type:l.CommandType.COMMAND,handler:async i=>{const r=i.get(j.IDialogService),e=i.get(Fe),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:ve,draggable:!0,width:360,title:{title:s},children:{label:ve},destroyOnClose:!0,preservePositionOnDestroy:!0,onClose:()=>r.close(ve)}),!0}},Pt="COMPONENT_SHEET_DRAWING_PANEL",vt={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);if(!C.getSheetCommandTarget(n))return!1;switch(r.value){case"open":e.open({header:{title:t.t("sheetImage.panel.title")},children:{label:Pt},onClose:()=>{o.syncExecuteCommand(B.SetDrawingSelectedOperation.id,[])},width:360});break;case"close":default:e.close();break}return!0}},_t={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(vt.id,{value:"open"}),!0)}},tn="sheets-drawing-ui.config",Nt={};var nn=Object.getOwnPropertyDescriptor,rn=(i,r,e,t)=>{for(var n=t>1?void 0:t?nn(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);let Ye=class extends l.RxDisposable{constructor(r,e,t,n,o,s,a,d,g,u){super();ie(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=d,this._ioService=g,this._commandService=u,this._init()}_init(){this._univerInstanceService.getCurrentTypeOfUnit$(l.UniverInstanceType.UNIVER_SHEET).pipe(U.takeUntil(this.dispose$)).subscribe(r=>this._create(r)),this._univerInstanceService.getTypeOfUnitDisposed$(l.UniverInstanceType.UNIVER_SHEET).pipe(U.takeUntil(this.dispose$)).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:Y.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)}_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 ge.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 d=a.oKey,g=this._drawingManagerService.getDrawingOKey(d);if(!g)return;const{unitId:u,subUnitId:c,drawingId:m,drawingType:h}=g,p=g.data;if(p&&p.disablePopup)return;n==null||n.dispose();const S=this._canvasPopManagerService.getFeatureMenu(u,c,m,h);n=this.disposeWithMe(this._canvasPopManagerService.attachPopupToObject(a,{componentKey:ge.COMPONENT_IMAGE_POPUP_MENU,direction:"horizontal",offset:[2,0],extraProps:{menuItems:S||this._getImageMenuItems(u,c,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:_t.id,commandParams:{unitId:r,subUnitId:e,drawingId:t},disable:n===l.DrawingTypeEnum.DRAWING_DOM},{label:"image-popup.delete",index:1,commandId:Se.id,commandParams:{unitId:r,drawings:[{unitId:r,subUnitId:e,drawingId:t}]},disable:!1},{label:"image-popup.crop",index:2,commandId:ge.OpenImageCropOperation.id,commandParams:{unitId:r,subUnitId:e,drawingId:t},disable:n===l.DrawingTypeEnum.DRAWING_DOM},{label:"image-popup.reset",index:3,commandId:ge.ImageResetSizeOperation.id,commandParams:[{unitId:r,subUnitId:e,drawingId:t}],disable:n===l.DrawingTypeEnum.DRAWING_DOM}]}};Ye=rn([se(0,l.Inject(l.Injector)),se(1,l.Inject(l.LocaleService)),se(2,B.IDrawingManagerService),se(3,l.Inject(b.SheetCanvasPopManagerService)),se(4,A.IRenderManagerService),se(5,l.IUniverInstanceService),se(6,j.IMessageService),se(7,l.IContextService),se(8,l.IImageIoService),se(9,l.ICommandService)],Ye);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},Ge=(i,r)=>(e,t)=>r(e,t,i);let It=class extends l.Disposable{constructor(r,e,t,n,o){super();ie(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(U.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(A.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}}))}};It=sn([Ge(1,l.Inject(b.HoverManagerService)),Ge(2,l.Inject(C.SheetsSelectionsService)),Ge(3,l.Inject(ge.DrawingRenderService)),Ge(4,l.Inject(b.SheetSkeletonManagerService))],It);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(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=J(n.sheetTransform,this._sheetSelectionRenderService,this._sheetSkeletonManagerService))}}this._drawingManagerService.registerDrawingData(this._context.unitId,this._sheetDrawingService.getDrawingDataForUnit(this._context.unitId)),this._drawingManagerService.initializeNotification(this._context.unitId)}};yt=cn([He(1,w.ISheetDrawingService),He(2,B.IDrawingManagerService),He(3,l.Inject(b.ISheetSelectionRenderService)),He(4,l.Inject(b.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},Ie=(i,r)=>(e,t)=>r(e,t,i);function kt(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]],d=mt(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(d)return a.transform.width=d.width,a.transform.height=d.height,a.docTransform.size.width=d.width,a.docTransform.size.height=d.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 Ve=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===$e.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(C.INTERCEPTOR_POINT.CELL_CONTENT,{effect:l.InterceptorEffectEnum.Style,priority:C.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},kt(this._injector,{unitId:r.unitId,subUnitId:r.subUnitId,row:r.row,col:r.col},i)),e(i)}}))}};Ve=ln([Ie(0,l.ICommandService),Ie(1,l.Inject(C.SheetInterceptorService)),Ie(2,l.Inject(l.Injector)),Ie(3,B.IDrawingManagerService),Ie(4,l.Inject(bt.DocDrawingController)),Ie(5,l.Inject(b.IEditorBridgeService))],Ve);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},Wt=(i,r)=>(e,t)=>r(e,t,i);let Xe=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)=>{kt(this._injector,{unitId:i.unitId,subUnitId:i.subUnitId,row:n,col:o},s)})}}))}};Xe=gn([Wt(0,l.Inject(b.IAutoFillService)),Wt(1,l.Inject(l.Injector))],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},Ae=(i,r)=>(e,t)=>r(e,t,i);const pn=[l.DOCS_NORMAL_EDITOR_UNIT_ID_KEY,l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY,l.DOCS_ZEN_EDITOR_UNIT_ID_KEY];let xe=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=A.getCurrentTypeOfRenderer(l.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null?void 0:n.with(b.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===$e.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(pn.includes(s)){if(s!==l.DOCS_ZEN_EDITOR_UNIT_ID_KEY){const a=()=>{this._dialogService.close("sheet-cell-image-copy-paste"),this._commandService.syncExecuteCommand(b.SetCellEditVisibleOperation.id,{visible:!1})};((e=o.getBody())==null?void 0:e.dataStream)===`\r
|
|
15
|
-
`?(this._commandService.syncExecuteCommand(b.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")}}}))}};xe=mn([Ae(0,l.ICommandService),Ae(1,l.IUniverInstanceService),Ae(2,j.IDialogService),Ae(3,A.IRenderManagerService),Ae(4,l.Inject(l.LocaleService))],xe);var fn=Object.getOwnPropertyDescriptor,Sn=(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},Ue=(i,r)=>(e,t)=>r(e,t,i);const Bt="image/png";function wn(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:Bt})}function vn(i){const r=new ClipboardItem({[Bt]:wn(i)});navigator.clipboard.write([r]).catch(e=>{console.error("Could not copy image using clipboard API: ",e)})}function _n(){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 jt=[b.PREDEFINED_HOOK_NAME_PASTE.SPECIAL_PASTE_COL_WIDTH,b.PREDEFINED_HOOK_NAME_PASTE.SPECIAL_PASTE_VALUE,b.PREDEFINED_HOOK_NAME_PASTE.SPECIAL_PASTE_FORMAT,b.PREDEFINED_HOOK_NAME_PASTE.SPECIAL_PASTE_FORMULA];let Ke=class extends l.Disposable{constructor(r,e,t,n,o){super();ie(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===b.COPY_TYPE.CUT){const d={unitId:r,drawings:[s]};this._commandService.executeCommand(Se.id,d)}setTimeout(()=>{const d=_n();s.drawingType===l.DrawingTypeEnum.DRAWING_IMAGE&&s.imageSourceType===B.ImageSourceType.BASE64?vn(s.source):this._clipboardInterfaceService.writeText(""),d()},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=b.COPY_TYPE.COPY,pasteType:s}=n,{range:a}=r||{},{range:d,unitId:g,subUnitId:u}=e;return this._copyInfo.copyRange?this._generateRangeDrawingsPasteMutations({pasteType:s,unitId:g,subUnitId:u,pasteRange:d},{copyRange:a,copyType:o}):this._generateSingleDrawingPasteMutations({pasteTo:e,pasteType:s},b.COPY_TYPE.COPY)},onPastePlainText:(r,e)=>({undos:[],redos:[]}),onPasteUnrecognized:r=>this._copyInfo?this._generateSingleDrawingPasteMutations({pasteTo:r,pasteType:b.PREDEFINED_HOOK_NAME_PASTE.DEFAULT_PASTE},b.COPY_TYPE.COPY):{undos:[],redos:[]},onPasteFiles:(r,e)=>{if(this._copyInfo)return this._generateSingleDrawingPasteMutations({pasteTo:r,pasteType:b.PREDEFINED_HOOK_NAME_PASTE.DEFAULT_PASTE},b.COPY_TYPE.COPY);{const t=e.filter(n=>n.type.includes("image"));if(t.length)return{undos:[],redos:[{id:Oe.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(b.SheetSkeletonManagerService);if(!n)return;const o=n.attachRangeWithCoord(t);if(!o)return;const{startX:s,endX:a,startY:d,endY:g}=o,u=this._drawingService.getDrawingData(r,e),c=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:_=0,height:D=0}=S,{drawingStartX:M,drawingEndX:y,drawingStartY:T,drawingEndY:I}={drawingStartX:f,drawingEndX:f+_,drawingStartY:v,drawingEndY:v+D};s<=M&&y<=a&&d<=T&&I<=g&&c.push(p)}),c.length)return{copyRange:t,drawings:c,unitId:r,subUnitId:e}}_generateSingleDrawingPasteMutations(r,e){const{pasteType:t,pasteTo:n}=r;if(jt.includes(t))return{redos:[],undos:[]};const{unitId:o,subUnitId:s,range:a}=n,d=this._renderManagerService.getRenderById(o),g=d==null?void 0:d.with(b.SheetSkeletonManagerService),u=d==null?void 0:d.with(b.ISheetSelectionRenderService),c=this._copyInfo;if(!g||!u)return{redos:[],undos:[]};const{drawings:m}=c,h=b.discreteRangeToRange(a);return this._generateMutations(m,{unitId:o,subUnitId:s,isCut:e===b.COPY_TYPE.CUT,getTransform:(p,S)=>{var _;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:(_=H(v,u))!=null?_:S}}})}_generateMutations(r,e){const{unitId:t,subUnitId:n,getTransform:o,isCut:s}=e,a=[],d=[],{_drawingService:g}=this;return r.forEach(u=>{const{transform:c,sheetTransform:m}=u;if(!c)return;const h=o(c,m),p={...u,unitId:t,subUnitId:n,drawingId:s?u.drawingId:l.generateRandomId(),transform:h.transform,sheetTransform:h.sheetTransform};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}}),d.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}}),d.push({id:w.SetDrawingApplyMutation.id,params:{op:S,unitId:t,subUnitId:n,objects:v,type:w.DrawingApplyType.REMOVE}})}}),{redos:a,undos:d}}_generateRangeDrawingsPasteMutations(r,e){var N;const{unitId:t,subUnitId:n,pasteType:o,pasteRange:s}=r,{copyRange:a,copyType:d}=e;if(jt.includes(o))return{redos:[],undos:[]};const g=(N=this._renderManagerService.getRenderById(t))==null?void 0:N.with(b.SheetSkeletonManagerService);if(!g||!this._copyInfo)return{redos:[],undos:[]};const{drawings:u}=this._copyInfo;if(!a)return this._generateSingleDrawingPasteMutations({pasteTo:{unitId:t,subUnitId:n,range:b.discreteRangeToRange(s)},pasteType:o},d);const{ranges:[c,m],mapFunc:h}=b.virtualizeDiscreteRanges([a,s]),{row:p,col:S}=h(c.startRow,c.startColumn),{row:f,col:v}=h(m.startRow,m.startColumn),_=g.attachRangeWithCoord({startRow:p,endRow:p,startColumn:S,endColumn:S}),D=g.attachRangeWithCoord({startRow:f,endRow:f,startColumn:v,endColumn:v});if(!_||!D||!this._copyInfo)return{redos:[],undos:[]};const M=D.startX-_.startX,y=D.startY-_.startY,T=f-p,I=v-S;return this._generateMutations(u,{unitId:t,subUnitId:n,getTransform:(O,k)=>{var W,P;return{transform:{...O,left:((W=O==null?void 0:O.left)!=null?W:0)+M,top:((P=O==null?void 0:O.top)!=null?P:0)+y},sheetTransform:{...k,to:{...k.to,row:k.to.row+T,column:k.to.column+I},from:{...k.from,row:k.from.row+T,column:k.from.column+I}}}},isCut:d===b.COPY_TYPE.CUT})}};Ke=Sn([Ue(0,b.ISheetClipboardService),Ue(1,A.IRenderManagerService),Ue(2,B.IDrawingManagerService),Ue(3,j.IClipboardInterfaceService),Ue(4,l.ICommandService)],Ke);var In=Object.getOwnPropertyDescriptor,yn=(i,r,e,t)=>{for(var n=t>1?void 0:t?In(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);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=U.combineLatest([i,r]);this.disposeWithMe(e.pipe(U.switchMap(([t,n])=>t?t.activeSheet$.pipe(U.tap(o=>{if(!o){this._drawingManagerService.setDrawingVisible(!1);return}const s=t.getUnitId(),a=o.getSheetId();this._permissionService.composePermission([new C.WorkbookViewPermission(s).id,new C.WorksheetViewPermission(s,a).id]).every(g=>g.value)?this._drawingManagerService.setDrawingVisible(!0):this._handleDrawingVisibilityFalse(t,o)})):(this._drawingManagerService.setDrawingVisible(!1),U.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===A.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=U.combineLatest([i,r]);this.disposeWithMe(e.pipe(U.switchMap(([t,n])=>t?t.activeSheet$.pipe(U.tap(o=>{if(!o){this._drawingManagerService.setDrawingEditable(!1);return}const s=t.getUnitId(),a=o.getSheetId();this._permissionService.composePermission([new C.WorkbookEditablePermission(s).id,new C.WorksheetEditPermission(s,a).id]).every(g=>g.value)?this._drawingManagerService.setDrawingEditable(!0):this._handleDrawingEditableFalse(t,o)})):(this._drawingManagerService.setDrawingEditable(!1),U.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===A.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(U.combineLatest([i,r]).pipe(U.switchMap(([e,t])=>e?e.activeSheet$.pipe(U.switchMap(n=>{if(!n)return U.EMPTY;const o=e.getUnitId(),s=n.getSheetId(),a=this._renderManagerService.getRenderById(o),d=a==null?void 0:a.scene;if(!d)return U.EMPTY;const g=d.getTransformerByCreate();return this._permissionService.composePermission$([new C.WorkbookViewPermission(o).id,new C.WorksheetViewPermission(o,s).id]).pipe(U.map(c=>c.every(m=>m.value)),U.distinctUntilChanged()).pipe(U.map(c=>({permission:c,scene:d,transformer:g,unitId:o,subUnitId:s})))})):U.EMPTY)).subscribe({next:({permission:e,scene:t,transformer:n,unitId:o,subUnitId:s})=>{this._drawingManagerService.setDrawingVisible(e);const a=t.getAllObjectsByOrder(),d=this._drawingManagerService.getDrawingData(o,s),g=Object.values(d);e?this._drawingManagerService.addNotification(g):(a.forEach(u=>{u.classType===A.RENDER_CLASS_TYPE.IMAGE&&g.some(c=>u.oKey.includes(c.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(U.combineLatest([i,r]).pipe(U.switchMap(([e,t])=>e?e.activeSheet$.pipe(U.switchMap(n=>{if(!n)return U.EMPTY;const o=e.getUnitId(),s=n.getSheetId(),a=this._renderManagerService.getRenderById(o),d=a==null?void 0:a.scene;if(!d)return U.EMPTY;const g=d.getTransformerByCreate();return this._permissionService.composePermission$([new C.WorkbookEditablePermission(o).id,new C.WorksheetEditPermission(o,s).id]).pipe(U.map(c=>c.every(m=>m.value)),U.distinctUntilChanged()).pipe(U.map(c=>({permission:c,scene:d,transformer:g,unitId:o,subUnitId:s})))})):U.EMPTY)).subscribe({next:({permission:e,scene:t,transformer:n,unitId:o,subUnitId:s})=>{this._drawingManagerService.setDrawingEditable(e);const a=t.getAllObjectsByOrder(),d=this._drawingManagerService.getDrawingData(o,s),g=Object.values(d);e?(a.forEach(u=>{u.classType===A.RENDER_CLASS_TYPE.IMAGE&&g.some(c=>u.oKey.includes(c.drawingId))&&t.attachTransformerTo(u)}),this._drawingManagerService.addNotification(g)):(a.forEach(u=>{u.classType===A.RENDER_CLASS_TYPE.IMAGE&&g.some(c=>u.oKey.includes(c.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 d=this._drawingManagerService.getDrawingData(t,o),g=Object.values(d);this._drawingManagerService.setDrawingEditable(!0),a.getAllObjectsByOrder().forEach(c=>{c.classType===A.RENDER_CLASS_TYPE.IMAGE&&g.some(m=>c.oKey.includes(m.drawingId))&&a.detachTransformerFrom(c)})}}))}};ze=yn([Pe(0,B.IDrawingManagerService),Pe(1,A.IRenderManagerService),Pe(2,l.IPermissionService),Pe(3,l.IUniverInstanceService),Pe(4,l.Inject(l.UserManagerService))],ze);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},pe=(i,r)=>(e,t)=>r(e,t,i);const $t="univer-sheet-float-dom-";function Ft(i,r,e,t,n,o=!1){const{scaleX:s,scaleY:a}=r.getAncestorScale(),d=r.getViewport(A.SHEET_VIEWPORT_KEY.VIEW_MAIN),g=t.getFreeze(),{startColumn:u,startRow:c,xSplit:m,ySplit:h}=g,p={left:!0,top:!0};if(!d)return{...i,absolute:p};const{left:S,right:f,top:v,bottom:_}=i;let{top:D,left:M,viewportScrollX:y,viewportScrollY:T}=d;const{boundsOfViewArea:I,scrollDirectionResponse:N}=n||{},{rowHeaderWidth:O,columnHeaderHeight:k}=e,W={top:o?0:k,left:o?0:O};I&&(l.Tools.isDefine(W.top)&&(W.top=I.top),l.Tools.isDefine(W.left)&&(W.left=I.left)),N==="HORIZONTAL"&&(T=0),N==="VERTICAL"&&(y=0);let P=0,E=0;const $=e.rowStartY(c-h)+k,G=e.colStartX(u-m)+O,Q=e.rowStartY(c)+k,ne=e.colStartX(u)+O;if(m===0)p.left=!1,P=(S-y)*s,E=(f-y)*s;else{const z=S-(G-O),ee=f-(G-O);f<ne?(P=z*s,E=ee*s):S<=ne&&f>=ne?(P=z*s,E=Math.max(M,(f-y)*s)):S>ne&&(p.left=!1,P=Math.max((S-y)*s,M),E=Math.max((f-y)*s,M))}let K=0,Z=0;if(h===0)p.top=!1,K=(v-T)*a,Z=(_-T)*a;else{const z=v-($-k),ee=_-($-k);_<Q?(K=z*a,Z=ee*a):v<=Q&&_>=Q?(K=z*a,Z=Math.max(D,(_-T)*a)):v>Q&&(p.top=!1,K=Math.max((v-T)*a,D),Z=Math.max((_-T)*a,D))}return P=Math.max(P,W.left),K=Math.max(K,W.top),E=Math.max(E,W.left),Z=Math.max(Z,W.top),{left:P,right:E,top:K,bottom:Z,absolute:p}}const ae=(i,r,e,t,n)=>{const{left:o,top:s,width:a,height:d,angle:g}=i,u={left:o,right:o+a,top:s,bottom:s+d},c=Ft(u,r,e,t,n),{scaleX:m,scaleY:h}=r.getAncestorScale();return{startX:c.left,endX:c.right,startY:c.top,endY:c.bottom,rotate:g,width:a*m,height:d*h,absolute:c.absolute}};R.SheetCanvasFloatDomManagerService=class extends l.Disposable{constructor(e,t,n,o,s,a,d){super();ie(this,"_domLayerInfoMap",new Map);ie(this,"_transformChange$",new U.Subject);ie(this,"transformChange$",this._transformChange$.asObservable());ie(this,"_add$",new U.Subject);ie(this,"add$",this._add$.asObservable());ie(this,"_remove$",new U.Subject);ie(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=d,this._drawingAddListener(),this._featureUpdateListener(),this._deleteListener(),this._bindScrollEvent()}_bindScrollEvent(){this._lifecycleService.lifecycle$.pipe(U.filter(e=>e===l.LifecycleStages.Rendered),U.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 ee;const{unitId:n,subUnitId:o,drawingId:s}=t,a=C.getSheetCommandTarget(this._univerInstanceService,{unitId:n,subUnitId:o}),d=this._drawingManagerService.getDrawingByParam(t),g=this._univerInstanceService.getUnit(n,l.UniverInstanceType.UNIVER_SHEET);if(!g)return;const u=g.getActiveSheet().getSheetId();if(!d||!a)return;const c=(ee=this._renderManagerService.getRenderById(n))==null?void 0:ee.with(b.SheetSkeletonManagerService).getSkeletonParam(o);if(!c)return;const{transform:m,drawingType:h,data:p}=d;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:_,top:D,width:M,height:y,angle:T,flipX:I,flipY:N,skewX:O,skewY:k}=m,W=B.getDrawingShapeKeyByDrawingSearch({unitId:n,subUnitId:o,drawingId:s}),P=f.getObject(W);if(P!=null){P.transformByState({left:_,top:D,width:M,height:y,angle:T,flipX:I,flipY:N,skewX:O,skewY:k});return}const E={left:_,top:D,width:M,height:y,zIndex:this._drawingManagerService.getDrawingOrder(n,o).length-1},$=h===l.DrawingTypeEnum.DRAWING_CHART;if(E.rotateEnabled=!1,$){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 G=new A.Rect(W,E);$&&G.setObjectType(A.ObjectType.CHART),f.addObject(G,A.DRAWING_OBJECT_LAYER_INDEX),d.allowTransform!==!1&&f.attachTransformerTo(G);const Q=new l.DisposableCollection,ne=ae(G,S.renderUnit.scene,c.skeleton,a.worksheet),K=new U.BehaviorSubject(ne),Z=`${$t}${l.generateRandomId(6)}`,oe={dispose:Q,rect:G,position$:K,unitId:n,subUnitId:o,id:s,domId:Z};this._canvasFloatDomService.addFloatDom({position$:K,id:s,domId:Z,componentKey:d.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 z=G.onTransformChange$.subscribeEvent(()=>{const X=ae(G,S.renderUnit.scene,c.skeleton,a.worksheet);K.next(X)});Q.add(()=>{this._canvasFloatDomService.removeFloatDom(s)}),z&&Q.add(z),this._domLayerInfoMap.set(s,oe)})})),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}),d=this._getSceneAndTransformerByDrawingSearch(n);if(d==null)return;const{transformer:g,scene:u}=d,c=u.getObject(a);c!=null&&c.oKey&&(g.clearControlByIds([c==null?void 0:c.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=C.getSheetCommandTarget(this._univerInstanceService,{unitId:t,subUnitId:n}),d=(g=this._renderManagerService.getRenderById(t))==null?void 0:g.with(b.SheetSkeletonManagerService).getSkeletonParam(n);!o||!a||!d||s.forEach(u=>{const c=this._domLayerInfoMap.get(u);if(c){const m=ae(c.rect,o.renderUnit.scene,d.skeleton,a.worksheet,c);c.position$.next(m)}})};this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(l.UniverInstanceType.UNIVER_SHEET).pipe(U.switchMap(t=>t?t.activeSheet$:U.of(null)),U.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}),U.switchMap(t=>t?l.fromEventSubject(t.render.scene.getViewport(A.SHEET_VIEWPORT_KEY.VIEW_MAIN).onScrollAfter$).pipe(U.map(()=>({unitId:t.unitId,subUnitId:t.subUnitId}))):U.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===b.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===C.SetFrozenMutation.id){const{unitId:n,subUnitId:o}=t.params;e(n,o)}else if(t.id===C.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:d}=a,g=B.getDrawingShapeKeyByDrawingSearch({unitId:e,subUnitId:t,drawingId:n}),u=d.getObject(g);u&&u instanceof A.Rect&&u.setProps(o)}}_getPosition(e,t){var h;const{startX:n,endX:o,startY:s,endY:a}=e,d=(h=this._renderManagerService.getRenderById(t))==null?void 0:h.with(b.ISheetSelectionRenderService);if(d==null)return;const g=d.getCellWithCoordByOffset(n,s);if(g==null)return;const u={column:g.actualColumn,columnOffset:n-g.startX,row:g.actualRow,rowOffset:s-g.startY},c=d.getCellWithCoordByOffset(o,a);if(c==null)return;const m={column:c.actualColumn,columnOffset:o-c.startX,row:c.actualRow,rowOffset:a-c.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,d=this._domLayerInfoMap.get(t.drawingId);d!=null&&d.rect&&(n.allowTransform===!1?a.detachTransformerFrom(d.rect):a.attachTransformerTo(d.rect))}})}))}_deleteListener(){this.disposeWithMe(this._drawingManagerService.remove$.subscribe(e=>{e.forEach(t=>{this._removeDom(t.drawingId)})}))}addFloatDomToPosition(e,t){const n=C.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:d,data:g,allowTransform:u=!0}=e,c=t!=null?t:l.generateRandomId(),m=this._getPosition(a,o);if(m==null)return;const h={unitId:o,subUnitId:s,drawingId:c,drawingType:e.type||l.DrawingTypeEnum.DRAWING_DOM,componentKey:d,sheetTransform:m,transform:{left:a.startX,top:a.startY,width:a.endX-a.startX,height:a.endY-a.startY},data:g,allowTransform:u};return this._commandService.executeCommand(Ee.id,{unitId:o,drawings:[h]}),this._add$.next({unitId:o,subUnitId:s,id:c}),{id:c,dispose:()=>{this._removeDom(c,!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 d=this._drawingManagerService.getDrawingByParam({unitId:o,subUnitId:s,drawingId:e});if(!d)return;const g=this._sheetDrawingService.getBatchRemoveOp([d]),{redo:u,objects:c}=g;this._commandService.syncExecuteCommand(w.SetDrawingApplyMutation.id,{unitId:o,subUnitId:s,op:u,objects:c,type:w.DrawingApplyType.REMOVE})}}addFloatDomToRange(e,t,n,o){var I,N,O;const s=C.getSheetCommandTarget(this._univerInstanceService,{unitId:t.unitId,subUnitId:t.subUnitId});if(!s)throw new Error("cannot find current target!");const{unitId:a,subUnitId:d}=s,g=this._getSceneAndTransformerByDrawingSearch(a);if(!g)return;const u=this._renderManagerService.getRenderById(a);if(!u)return;const c=(I=this._renderManagerService.getRenderById(a))==null?void 0:I.with(b.SheetSkeletonManagerService).getWorksheetSkeleton(d);if(!c)return;const{componentKey:m,data:h,allowTransform:p=!0}=t,S=o!=null?o:l.generateRandomId(),{position:f,position$:v}=this._createRangePositionObserver(e,u,c.skeleton);if(this._getPosition(f,a)==null)return;const D=g.scene,{scaleX:M}=D.getAncestorScale(),y=qe(f,n,M),T={unitId:a,subUnitId:d,drawingId:S,drawingType:t.type||l.DrawingTypeEnum.DRAWING_DOM,componentKey:m,transform:{left:y.startX,top:y.startY,width:y.width,height:y.height},data:h,allowTransform:p};{const{unitId:k,subUnitId:W,drawingId:P}=T,E=C.getSheetCommandTarget(this._univerInstanceService,{unitId:k,subUnitId:W}),$=T,G=this._univerInstanceService.getUnit(k,l.UniverInstanceType.UNIVER_SHEET);if(!G)return;const Q=G.getActiveSheet().getSheetId();if(!$||!E)return;const ne=(N=this._renderManagerService.getRenderById(k))==null?void 0:N.with(b.SheetSkeletonManagerService);if(!ne)return;const K=ne.getWorksheetSkeleton(W);if(!K)return;const{transform:Z,drawingType:oe,data:z}=$;if(oe!==l.DrawingTypeEnum.DRAWING_DOM&&oe!==l.DrawingTypeEnum.DRAWING_CHART)return;const ee=this._getSceneAndTransformerByDrawingSearch(k);if(ee==null)return;const{scene:X,canvas:Ce}=ee;if(Z==null||Q!==W)return;const{left:et,top:tt,width:nt,height:rt,angle:Rt,flipX:Et,flipY:it,skewX:ot,skewY:De}=Z,st=B.getDrawingShapeKeyByDrawingSearch({unitId:k,subUnitId:W,drawingId:P}),ce=X.getObject(st);if(ce!=null){ce.transformByState({left:et,top:tt,width:nt,height:rt,angle:Rt,flipX:Et,flipY:it,skewX:ot,skewY:De});return}const re={left:et,top:tt,width:nt,height:rt,zIndex:this._drawingManagerService.getDrawingOrder(k,W).length-1},Te=oe===l.DrawingTypeEnum.DRAWING_CHART;if(Te){const L=z?z.backgroundColor:"white";re.fill=L,re.rotateEnabled=!1,z&&z.border&&(re.stroke=z.border),re.paintFirst="stroke",re.strokeWidth=1,re.borderEnabled=!1,re.radius=8}const de=new A.Rect(st,re);Te&&de.setObjectType(A.ObjectType.CHART),X.addObject(de,A.DRAWING_OBJECT_LAYER_INDEX),$.allowTransform!==!1&&X.attachTransformerTo(de);const le=new l.DisposableCollection,at=X.getMainViewport(),{rowHeaderWidth:Me,columnHeaderHeight:We}=K.skeleton,ct={top:We,left:Me,bottom:at.bottom,right:at.right},ue={dispose:le,rect:de,boundsOfViewArea:ct,domAnchor:n,unitId:k,subUnitId:W},x=ae(de,ee.renderUnit.scene,K.skeleton,E.worksheet,ue),Re=new U.BehaviorSubject(x);ue.position$=Re;let Be={position$:Re,id:P,componentKey:$.componentKey,onPointerDown:()=>{},onPointerMove:()=>{},onPointerUp:()=>{},onWheel:L=>{Ce.dispatchEvent(new WheelEvent(L.type,L))},data:z,unitId:k};t.eventPassThrough&&(Be={...Be,onPointerDown:L=>{Ce.dispatchEvent(new PointerEvent(L.type,L))},onPointerMove:L=>{Ce.dispatchEvent(new PointerEvent(L.type,L))},onPointerUp:L=>{Ce.dispatchEvent(new PointerEvent(L.type,L))}}),this._canvasFloatDomService.addFloatDom(Be),this.disposeWithMe(v.subscribe(L=>{var Gt,Ht,Vt,Xt;const Yt=qe({startX:L.startX,startY:L.startY,endX:L.endX,endY:L.endY,width:(Gt=n.width)!=null?Gt:L.width,height:(Ht=n.height)!=null?Ht:L.height,absolute:{left:f.absolute.left,top:f.absolute.top}},n),er=B.getDrawingShapeKeyByDrawingSearch({unitId:k,subUnitId:W,drawingId:P}),tr=new A.Rect(er,{left:Yt.startX,top:Yt.startY,width:(Vt=n.width)!=null?Vt:L.width,height:(Xt=n.height)!=null?Xt:L.height,zIndex:this._drawingManagerService.getDrawingOrder(k,W).length-1}),nr=ae(tr,ee.renderUnit.scene,K.skeleton,E.worksheet,ue);Re.next(nr)}));const je=(O=this._renderManagerService.getRenderById(k))==null?void 0:O.with(b.SheetSkeletonManagerService);je==null||je.currentSkeleton$.subscribe(L=>{L&&K.sheetId!==L.sheetId&&this._removeDom(S,!0)});const dt=de.onTransformChange$.subscribeEvent(()=>{const L=ae(de,ee.renderUnit.scene,K.skeleton,E.worksheet,ue);Re.next(L)});le.add(()=>{this._canvasFloatDomService.removeFloatDom(P)}),dt&&le.add(dt),this._domLayerInfoMap.set(P,ue)}return{id:S,dispose:()=>{this._removeDom(S,!0)}}}addFloatDomToColumnHeader(e,t,n,o){var y,T,I;const s=C.getSheetCommandTarget(this._univerInstanceService,{unitId:t.unitId,subUnitId:t.subUnitId});if(!s)throw new Error("cannot find current target!");const{unitId:a,subUnitId:d}=s;if(!this._getSceneAndTransformerByDrawingSearch(a))return;const u=this._renderManagerService.getRenderById(a);if(!u)return;const c=(y=this._renderManagerService.getRenderById(a))==null?void 0:y.with(b.SheetSkeletonManagerService).getWorksheetSkeleton(d);if(!c)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,c.skeleton),_=f;if(_.startY=0,this._getPosition(f,a)==null)return;const M={unitId:a,subUnitId:d,drawingId:S,drawingType:t.type||l.DrawingTypeEnum.DRAWING_DOM,componentKey:m,transform:{left:_.startX,top:_.startY,width:_.width,height:_.height},data:h,allowTransform:p};{const{unitId:N,subUnitId:O,drawingId:k}=M,W=C.getSheetCommandTarget(this._univerInstanceService,{unitId:N,subUnitId:O}),P=M,E=this._univerInstanceService.getUnit(N,l.UniverInstanceType.UNIVER_SHEET);if(!E)return;const $=E.getActiveSheet().getSheetId();if(!P||!W)return;const G=(T=this._renderManagerService.getRenderById(N))==null?void 0:T.with(b.SheetSkeletonManagerService);if(!G)return;const Q=G.getWorksheetSkeleton(O);if(!Q)return;const{transform:ne,data:K}=P,Z=this._getSceneAndTransformerByDrawingSearch(N);if(Z==null)return;const{scene:oe,canvas:z}=Z;if(ne==null||$!==O)return;const{left:ee,top:X,width:Ce,height:et,angle:tt,flipX:nt,flipY:rt,skewX:Rt,skewY:Et}=ne,it=B.getDrawingShapeKeyByDrawingSearch({unitId:N,subUnitId:O,drawingId:k}),ot=oe.getObject(it);if(ot!=null){ot.transformByState({left:ee,top:X,width:Ce,height:et,angle:tt,flipX:nt,flipY:rt,skewX:Rt,skewY:Et});return}const De=qe({startX:_.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),st={left:De.startX,top:De.startY,width:De.width,height:De.height,zIndex:this._drawingManagerService.getDrawingOrder(N,O).length-1},ce=new A.Rect(it,st);oe.addObject(ce,A.DRAWING_OBJECT_LAYER_INDEX),P.allowTransform!==!1&&oe.attachTransformerTo(ce);const re=new l.DisposableCollection,Te=oe.getMainViewport(),de={top:0,left:Te.left,bottom:Te.bottom,right:Te.right},le={dispose:re,rect:ce,unitId:N,subUnitId:O,boundsOfViewArea:de,domAnchor:n,scrollDirectionResponse:"HORIZONTAL"},at=ae(ce,Z.renderUnit.scene,Q.skeleton,W.worksheet,le),Me=new U.BehaviorSubject(at);le.position$=Me;let We={position$:Me,id:k,componentKey:P.componentKey,onPointerDown:()=>{},onPointerMove:()=>{},onPointerUp:()=>{},onWheel:x=>{z.dispatchEvent(new WheelEvent(x.type,x))},data:K,unitId:N};t.eventPassThrough&&(We={...We,onPointerDown:x=>{z.dispatchEvent(new PointerEvent(x.type,x))},onPointerMove:x=>{z.dispatchEvent(new PointerEvent(x.type,x))},onPointerUp:x=>{z.dispatchEvent(new PointerEvent(x.type,x))}}),this._canvasFloatDomService.addFloatDom(We);const ct=ce.onTransformChange$.subscribeEvent(()=>{const x=ae(ce,Z.renderUnit.scene,Q.skeleton,W.worksheet,le);Me.next(x)});this.disposeWithMe(v.subscribe(x=>{const Re=qe({startX:x.startX,startY:0,endX:x.endX,endY:x.endY,width:n.width,height:n.height,absolute:{left:f.absolute.left,top:f.absolute.top}},n),Be=B.getDrawingShapeKeyByDrawingSearch({unitId:N,subUnitId:O,drawingId:k}),je=new A.Rect(Be,{left:Re.startX,top:0,width:n.width,height:n.height,zIndex:this._drawingManagerService.getDrawingOrder(N,O).length-1}),dt=ae(je,Z.renderUnit.scene,Q.skeleton,W.worksheet,le);Me.next(dt)}));const ue=(I=this._renderManagerService.getRenderById(N))==null?void 0:I.with(b.SheetSkeletonManagerService);ue==null||ue.currentSkeleton$.subscribe(x=>{x&&c.sheetId!==x.sheetId&&this._removeDom(S,!0)}),re.add(()=>{this._canvasFloatDomService.removeFloatDom(k)}),ct&&re.add(ct),this._domLayerInfoMap.set(k,le)}return{id:S,dispose:()=>{this._removeDom(S,!0)}}}_createRangePositionObserver(e,t,n){let{startRow:o,startColumn:s}=e;const a=Ne(o,s,n),d=new U.BehaviorSubject(a),g=Ne(e.endRow,e.endColumn,n),u=new U.BehaviorSubject(g),c=()=>{const v=Ne(o,s,n),_=Ne(e.endRow,e.endColumn,n);d.next(v),u.next(_)},m=new l.DisposableCollection;m.add(t.engine.clientRect$.subscribe(()=>c())),m.add(this._commandService.onCommandExecuted(v=>{if(v.id===C.SetWorksheetRowAutoHeightMutation.id&&v.params.rowsAutoHeightInfo.findIndex(D=>D.row===o)>-1){c();return}(C.COMMAND_LISTENER_SKELETON_CHANGE.indexOf(v.id)>-1||v.id===b.SetScrollOperation.id||v.id===b.SetZoomRatioOperation.id)&&c()}));const h=(v,_)=>{o=v,s=_,c()},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=d.pipe(U.map(v=>{const _=Ne(e.endRow,e.endColumn,n);return{rotate:0,width:_.right-v.left,height:_.bottom-v.top,absolute:{left:!0,top:!0},startX:v.left,startY:v.top,endX:_.right,endY:_.bottom}})),f=p();return{position$:S,position:f,updateRowCol:h,topLeftPos$:d,rightBottomPos$:u,disposable:m}}},R.SheetCanvasFloatDomManagerService=Dn([pe(0,l.Inject(A.IRenderManagerService)),pe(1,l.IUniverInstanceService),pe(2,l.Inject(l.ICommandService)),pe(3,B.IDrawingManagerService),pe(4,l.Inject(j.CanvasFloatDomService)),pe(5,w.ISheetDrawingService),pe(6,l.Inject(l.LifecycleService))],R.SheetCanvasFloatDomManagerService);function Ne(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 qe(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,d=0;if(r){if(r.horizonOffsetAlign==="right"){const c=Ze(r.marginX,t*e);a=i.endX-c-o}else a=i.startX+Ze(r.marginX,t);if(r.verticalOffsetAlign==="bottom"){const c=Ze(r.marginY,n*e);d=i.endY-c-s}else d=i.startY+Ze(r.marginY,n)}return{rotate:0,startX:a,startY:d,endX:i.endX,endY:i.endY,width:o,height:s,absolute:{left:i.absolute.left,top:i.absolute.top}}}function Ze(i,r){if(i===void 0)return 0;if(typeof i=="number")return i;const e=Number.parseFloat(i);return r*e/100}const Tn=i=>{const{floatDomInfos:r,scene:e,skeleton:t,worksheet:n}=i,o=q.useMemo(()=>r.map(s=>{const{width:a,height:d,angle:g,left:u,top:c}=s.transform,m=Ft({left:u!=null?u:0,right:(u!=null?u:0)+(a!=null?a:0),top:c!=null?c:0,bottom:(c!=null?c:0)+(d!=null?d: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:d*p,absolute:m.absolute},f={position$:new U.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 F.jsx("div",{style:{position:"absolute",top:0,left:0},children:o.map(([s,a])=>F.jsx(j.PrintFloatDomSingle,{layer:a,id:s,position:a.position},s))})};var Mn=Object.getOwnPropertyDescriptor,Rn=(i,r,e,t)=>{for(var n=t>1?void 0:t?Mn(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 Je=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(d=>{const g=a.data[d];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(b.SheetSkeletonManagerService).getSkeletonParam(n);if(!s)return e(i);const a=this._drawingManagerService.getDrawingDataForUnit(t),d=a==null?void 0:a[r.subUnitId];if(!d)return e(i);const{scaleX:g,scaleY:u}=o.scene,c=i?{...i}:{startColumn:0,endColumn:0,endRow:0,startRow:0},m=d.order.map(h=>d.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<c.startColumn&&(c.startColumn=p.column),p.row<c.startRow&&(c.startRow=p.row),c.endRow<S.row&&(c.endRow=S.row),c.endColumn<S.column&&(c.endColumn=S.column)}}),e(c)):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 c=this._sheetPrintInterceptorService.getPrintComponent(u.componentKey);return{...u,componentKey:this._componetManager.get(c||u.componentKey)}}return null}).filter(Boolean),d=j.connectInjector(Tn,this._injector);return Y.render(F.jsx(d,{floatDomInfos:a,scene:r.scene,skeleton:r.skeleton,worksheet:r.worksheet}),r.root),i==null||i.add(()=>{Y.unmount(r.root)}),e(i)}}}))}};Je=Rn([fe(0,l.Inject(b.SheetPrintInterceptorService)),fe(1,l.Inject(ge.DrawingRenderService)),fe(2,B.IDrawingManagerService),fe(3,A.IRenderManagerService),fe(4,l.Inject(R.SheetCanvasFloatDomManagerService)),fe(5,l.Inject(j.ComponentManager)),fe(6,l.Inject(l.Injector))],Je);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},me=(i,r)=>(e,t)=>r(e,t,i);const On=[C.InsertRowCommand.id,C.InsertColCommand.id,C.RemoveRowCommand.id,C.RemoveColCommand.id,C.DeleteRangeMoveLeftCommand.id,C.DeleteRangeMoveUpCommand.id,C.InsertRangeMoveDownCommand.id,C.InsertRangeMoveRightCommand.id,C.DeltaRowHeightCommand.id,C.SetRowHeightCommand.id,C.DeltaColumnWidthCommand.id,C.SetColWidthCommand.id,C.SetRowHiddenCommand.id,C.SetSpecificRowsVisibleCommand.id,C.SetSpecificColsVisibleCommand.id,C.SetColHiddenCommand.id,C.MoveColsCommand.id,C.MoveRowsCommand.id,C.MoveRangeCommand.id],An=[C.SetRowVisibleMutation.id,C.SetRowHiddenMutation.id,C.SetColVisibleMutation.id,C.SetColHiddenMutation.id,C.SetWorksheetRowHeightMutation.id,C.SetWorksheetColWidthMutation.id];let Ct=class extends l.Disposable{constructor(i,r,e,t,n,o,s,a,d){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=d,this._sheetInterceptorListener(),this._commandListener(),this._sheetRefreshListener()}_sheetInterceptorListener(){this.disposeWithMe(this._sheetInterceptorService.interceptAfterCommand({getMutations:i=>{if(!On.includes(i.id))return{redos:[],undos:[]};if(i.params==null)return{redos:[],undos:[]};const r=i.id;if(r===C.InsertRowCommand.id)return this._moveRowInterceptor(i.params,"insert");if([C.MoveColsCommand.id,C.MoveRowsCommand.id,C.MoveRangeCommand.id].includes(r))return this._moveRangeInterceptor(i.params);if(r===C.InsertColCommand.id)return this._moveColInterceptor(i.params,"insert");if(r===C.RemoveRowCommand.id)return this._moveRowInterceptor(i.params,"remove");if(r===C.RemoveColCommand.id)return this._moveColInterceptor(i.params,"remove");if(r===C.DeleteRangeMoveLeftCommand.id){const{range:e}=i.params;return this._getRangeMoveUndo(e,0)}else if(r===C.DeleteRangeMoveUpCommand.id){const{range:e}=i.params;return this._getRangeMoveUndo(e,1)}else if(r===C.InsertRangeMoveDownCommand.id){const{range:e}=i.params;return this._getRangeMoveUndo(e,2)}else if(r===C.InsertRangeMoveRightCommand.id){const{range:e}=i.params;return this._getRangeMoveUndo(e,3)}else if(r===C.SetRowHiddenCommand.id||r===C.SetSpecificRowsVisibleCommand.id){const e=i.params,{unitId:t,subUnitId:n,ranges:o}=e;return this._getDrawingUndoForRowVisible(t,n,o)}else if(r===C.SetSpecificColsVisibleCommand.id||r===C.SetColHiddenCommand.id){const e=i.params,{unitId:t,subUnitId:n,ranges:o}=e;return this._getDrawingUndoForColVisible(t,n,o)}else if(r===C.DeltaRowHeightCommand.id||r===C.SetRowHeightCommand.id||r===C.DeltaColumnWidthCommand.id||r===C.SetColWidthCommand.id){const e=i.params,{unitId:t,subUnitId:n,ranges:o}=e,s=r===C.DeltaRowHeightCommand.id||r===C.SetRowHeightCommand.id;return this._getDrawingUndoForRowAndColSize(t,n,o,s)}return{redos:[],undos:[]}}}))}_getRangeMoveUndo(i,r){const e=C.getSheetCommandTarget(this._univerInstanceService);if(e==null)return{redos:[],undos:[]};const t=e.unitId,n=e.subUnitId,o=[],s=[],a=this._sheetDrawingService.getDrawingData(t,n),d=[],g=[];if(Object.keys(a).forEach(u=>{const c=a[u],{updateDrawings:m,deleteDrawings:h}=this._getUpdateOrDeleteDrawings(i,r,c);d.push(...m),g.push(...h)}),d.length===0&&g.length===0)return{redos:[],undos:[]};if(d.length>0){const u=this._sheetDrawingService.getBatchUpdateOp(d),{undo:c,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:c,objects:h,type:w.DrawingApplyType.UPDATE}})}if(g.length>0){const u=this._sheetDrawingService.getBatchRemoveOp(g),c=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:c,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){const t=[],n=[],{sheetTransform:o,anchorType:s=w.SheetDrawingAnchorType.Position,transform:a,unitId:d,subUnitId:g,drawingId:u}=e,{from:c,to:m}=o,{row:h,column:p}=c,{row:S,column:f}=m;if(o==null||a==null)return{updateDrawings:t,deleteDrawings:n};const{startRow:v,endRow:_,startColumn:D,endColumn:M}=i;let y=null,T=null;if(r===0&&h>=v&&S<=_)if(p>=D&&f<=M)n.push({unitId:d,subUnitId:g,drawingId:u});else{const I=this._shrinkCol(o,a,D,M,s);y=I==null?void 0:I.newSheetTransform,T=I==null?void 0:I.newTransform}else if(r===1&&p>=D&&f<=M)if(h>=v&&S<=_)n.push({unitId:d,subUnitId:g,drawingId:u});else{const I=this._shrinkRow(o,a,v,_,s);y=I==null?void 0:I.newSheetTransform,T=I==null?void 0:I.newTransform}else if(r===2){const I=this._expandRow(o,a,v,_,s);y=I==null?void 0:I.newSheetTransform,T=I==null?void 0:I.newTransform}else if(r===3){const I=this._expandCol(o,a,D,M,s);y=I==null?void 0:I.newSheetTransform,T=I==null?void 0:I.newTransform}if(y!=null&&T!=null){const I=J(y,this._selectionRenderService,this._skeletonManagerService);t.push({...e,sheetTransform:y,transform:I})}return{updateDrawings:t,deleteDrawings:n}}_remainDrawingSize(i,r,e){const t=H({...i},this._selectionRenderService);t!=null&&r.push({...e,sheetTransform:t})}_getDrawingUndoForColVisible(i,r,e){const t=this._drawingManagerService.getDrawingData(i,r),n=[],o=[];if(Object.keys(t).forEach(u=>{const c=t[u],{sheetTransform:m,transform:h,anchorType:p=w.SheetDrawingAnchorType.Position}=c;if(p===w.SheetDrawingAnchorType.None)this._remainDrawingSize(h,n,c);else{const{from:S,to:f}=m,{row:v,column:_}=S,{row:D,column:M}=f;for(let y=0;y<e.length;y++){const T=e[y],{startRow:I,endRow:N,startColumn:O,endColumn:k}=T;if(M<O)continue;if(p===w.SheetDrawingAnchorType.Position){let E=null,$=null;if(_>=O&&_<=k){const G=this._skeletonManagerService.attachRangeWithCoord({startColumn:_,endColumn:k,startRow:S.row,endRow:f.row});if(G==null)return;$={...h,left:G.startX}}if($!=null&&(E=H($,this._selectionRenderService),E!=null&&$!=null)){n.push({...c,sheetTransform:E,transform:$});break}this._remainDrawingSize(h,n,c);continue}if(_>=O&&M<=k)continue;let W=null,P=null;if(_>=O&&_<=k){const E=this._skeletonManagerService.attachRangeWithCoord({startColumn:_,endColumn:k,startRow:S.row,endRow:f.row});if(E==null)return;P={...h,left:(E==null?void 0:E.startX)||0,width:((h==null?void 0:h.width)||0)-E.endX+E.startX}}else if(M>=O&&M<=k){const E=this._skeletonManagerService.attachRangeWithCoord({startColumn:O,endColumn:M,startRow:S.row,endRow:f.row});if(E==null)return;P={...h,left:E.startX-((h==null?void 0:h.width)||0)}}else{const E=this._skeletonManagerService.attachRangeWithCoord({startColumn:O,endColumn:k,startRow:S.row,endRow:f.row});if(E==null)return;if(P={...h,width:((h==null?void 0:h.width)||0)-E.endX+E.startX},W=H(P,this._selectionRenderService),W!=null&&P!=null){o.push({...c,sheetTransform:W,transform:P});break}}if(P!=null&&(W=H(P,this._selectionRenderService)),P!=null&&W!=null){n.push({...c,sheetTransform:W,transform:P});break}else this._remainDrawingSize(h,n,c)}}}),n.length===0&&o.length===0)return{redos:[],undos:[]};const{redos:s,undos:a}=this._createUndoAndRedoMutation(i,r,n),d=[],g=[];if(o.length>0){const{redos:u,undos:c}=this._createUndoAndRedoMutation(i,r,o);d.push(...u),g.push(...c)}return{redos:s,undos:a,preRedos:d,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]}],d=[{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:d}}_getDrawingUndoForRowVisible(i,r,e){const t=this._drawingManagerService.getDrawingData(i,r),n=[],o=[];if(Object.keys(t).forEach(u=>{const c=t[u],{sheetTransform:m,transform:h,anchorType:p=w.SheetDrawingAnchorType.Position}=c;if(p===w.SheetDrawingAnchorType.None)this._remainDrawingSize(h,n,c);else{const{from:S,to:f}=m,{row:v,column:_}=S,{row:D,column:M}=f;for(let y=0;y<e.length;y++){const T=e[y],{startRow:I,endRow:N,startColumn:O,endColumn:k}=T;if(D<I)continue;if(p===w.SheetDrawingAnchorType.Position){let E=null,$=null;if(v>=I&&v<=N){const G=this._skeletonManagerService.attachRangeWithCoord({startColumn:S.column,endColumn:f.column,startRow:v,endRow:N});if(G==null)return;$={...h,top:G.startY}}if($!=null&&(E=H($,this._selectionRenderService),E!=null&&$!=null)){n.push({...c,sheetTransform:E,transform:$});break}this._remainDrawingSize(h,n,c);continue}if(v>=I&&D<=N)continue;let W=null,P=null;if(v>=I&&v<=N){const E=this._skeletonManagerService.attachRangeWithCoord({startColumn:S.column,endColumn:f.column,startRow:v,endRow:N});if(E==null)return;P={...h,top:(E==null?void 0:E.startY)||0,height:((h==null?void 0:h.height)||0)-E.endY+E.startY}}else if(D>=I&&D<=N){const E=this._skeletonManagerService.attachRangeWithCoord({startColumn:S.column,endColumn:f.column,startRow:I,endRow:D});if(E==null)return;P={...h,top:E.startY-((h==null?void 0:h.height)||0)}}else{const E=this._skeletonManagerService.attachRangeWithCoord({startColumn:S.column,endColumn:f.column,startRow:I,endRow:N});if(E==null)return;if(P={...h,height:((h==null?void 0:h.height)||0)-E.endY+E.startY},W=H(P,this._selectionRenderService),W!=null&&P!=null){o.push({...c,sheetTransform:W,transform:P});break}}if(P!=null&&(W=H(P,this._selectionRenderService)),P!=null&&W!=null){n.push({...c,sheetTransform:W,transform:P});break}else this._remainDrawingSize(h,n,c)}}}),n.length===0&&o.length===0)return{redos:[],undos:[]};const{redos:s,undos:a}=this._createUndoAndRedoMutation(i,r,n),d=[],g=[];if(o.length>0){const{redos:u,undos:c}=this._createUndoAndRedoMutation(i,r,o);d.push(...u),g.push(...c)}return{redos:s,undos:a,preRedos:d,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:d,transform:g,anchorType:u=w.SheetDrawingAnchorType.Position}=a;if(u===w.SheetDrawingAnchorType.None)this._remainDrawingSize(g,o,a);else{const{from:c,to:m}=d,{row:h,column:p}=c,{row:S,column:f}=m;for(let v=0;v<e.length;v++){const _=e[v],{startRow:D,endRow:M,startColumn:y,endColumn:T}=_;if(S<D||f<y)continue;if(u===w.SheetDrawingAnchorType.Position&&(h<=D&&S>=M||p<=y&&f>=T)){this._remainDrawingSize(g,o,a);continue}const I=J({...d},this._selectionRenderService,this._skeletonManagerService);if(I!=null){o.push({...a,transform:I});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=C.getSheetCommandTarget(this._univerInstanceService);if(n==null)return;e=n.unitId,t=n.subUnitId}return{unitId:e,subUnitId:t}}_moveRangeInterceptor(i){var D,M;const{toRange:r,fromRange:e}=i,t=C.getSheetCommandTarget(this._univerInstanceService);if(!t)return{redos:[],undos:[]};const{unitId:n,subUnitId:o}=t,s=(M=(D=this._renderManagerService.getRenderById(n))==null?void 0:D.with(b.SheetSkeletonManagerService))==null?void 0:M.getCurrentSkeleton();if(!s)return{redos:[],undos:[]};const a=b.attachRangeWithCoord(s,e);if(!a)return{redos:[],undos:[]};const{startX:d,endX:g,startY:u,endY:c}=a,m=this._sheetDrawingService.getDrawingData(n,o),h=[];Object.keys(m).forEach(y=>{const T=m[y];if(T.anchorType!==w.SheetDrawingAnchorType.Both)return;const{transform:I}=T;if(!I)return;const{left:N=0,top:O=0,width:k=0,height:W=0}=I,{drawingStartX:P,drawingEndX:E,drawingStartY:$,drawingEndY:G}={drawingStartX:N,drawingEndX:N+k,drawingStartY:O,drawingEndY:O+W};d<=P&&E<=g&&u<=$&&G<=c&&h.push(T)});const p=[],S=[],f=r.startRow-e.startRow,v=r.startColumn-e.startColumn,_=h.map(y=>{const T=y.sheetTransform,I={to:{...T.to,row:T.to.row+f,column:T.to.column+v},from:{...T.from,row:T.from.row+f,column:T.from.column+v}},N=J(I,this._selectionRenderService,this._skeletonManagerService);return{unitId:n,subUnitId:o,drawingId:y.drawingId,transform:N,sheetTransform:I}});if(_.length){const y=this._sheetDrawingService.getBatchUpdateOp(_),{undo:T,redo:I,objects:N}=y;p.push({id:w.SetDrawingApplyMutation.id,params:{unitId:n,subUnitId:o,op:I,objects:N,type:w.DrawingApplyType.UPDATE}}),S.push({id:w.SetDrawingApplyMutation.id,params:{unitId:n,subUnitId:o,op:T,objects:N,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,d=[],g=[],u=this._sheetDrawingService.getDrawingData(t,n),c=[],m=[];if(Object.keys(u).forEach(h=>{const p=u[h],{sheetTransform:S,transform:f,anchorType:v=w.SheetDrawingAnchorType.Position}=p;if(S==null||f==null)return;let _,D;if(r==="insert"){const y=this._expandRow(S,f,s,a,v);_=y==null?void 0:y.newSheetTransform,D=y==null?void 0:y.newTransform}else{const{from:y,to:T}=S,{row:I}=y,{row:N}=T;if(v===w.SheetDrawingAnchorType.Both&&I>=s&&N<=a)m.push({unitId:t,subUnitId:n,drawingId:h});else{const O=this._shrinkRow(S,f,s,a,v);_=O==null?void 0:O.newSheetTransform,D=O==null?void 0:O.newTransform}}if(!_||!D)return;const M={unitId:t,subUnitId:n,drawingId:h,transform:D,sheetTransform:_};c.push(M)}),c.length===0&&m.length===0)return{redos:[],undos:[]};if(c.length>0){const h=this._sheetDrawingService.getBatchUpdateOp(c),{undo:p,redo:S,objects:f}=h;d.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;d.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 d.push({id:V.id,params:[t]}),g.push({id:V.id,params:[t]}),{redos:d,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,d=[],g=[],u=this._sheetDrawingService.getDrawingData(t,n),c=[],m=[];if(Object.keys(u).forEach(h=>{const p=u[h],{sheetTransform:S,transform:f,anchorType:v=w.SheetDrawingAnchorType.Position}=p;if(S==null||f==null)return;let _,D;if(r==="insert"){const y=this._expandCol(S,f,s,a,v);_=y==null?void 0:y.newSheetTransform,D=y==null?void 0:y.newTransform}else{const{from:y,to:T}=S,{column:I}=y,{column:N}=T;if(v===w.SheetDrawingAnchorType.Both&&I>=s&&N<=a)m.push({unitId:t,subUnitId:n,drawingId:h});else{const O=this._shrinkCol(S,f,s,a,v);_=O==null?void 0:O.newSheetTransform,D=O==null?void 0:O.newTransform}}if(!_||!D)return;const M={unitId:t,subUnitId:n,drawingId:h,transform:D,sheetTransform:_};c.push(M)}),c.length===0&&m.length===0)return{redos:[],undos:[]};if(c.length>0){const h=this._sheetDrawingService.getBatchUpdateOp(c),{undo:p,redo:S,objects:f}=h;d.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;d.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 d.push({id:V.id,params:[t]}),g.push({id:V.id,params:[t]}),{redos:d,undos:g}}_expandCol(i,r,e,t,n=w.SheetDrawingAnchorType.Position){const o=t-e+1,{from:s,to:a}=i,{column:d}=s,{column:g}=a;if(n===w.SheetDrawingAnchorType.None)return{newSheetTransform:H({...r},this._selectionRenderService),newTransform:r};let u=null,c=null;if(d>=e){const m=this._skeletonManagerService.attachRangeWithCoord({startColumn:e,endColumn:t,startRow:s.row,endRow:a.row});if(m==null)return;c={...r,left:(r.left||0)+m.endX-m.startX},u=H(c,this._selectionRenderService)}else if(g>=t)if(n===w.SheetDrawingAnchorType.Both)u={from:{...s},to:{...a,column:g+o}},c=J(u,this._selectionRenderService,this._skeletonManagerService);else return{newSheetTransform:H({...r},this._selectionRenderService),newTransform:r};return u!=null&&c!=null?{newSheetTransform:u,newTransform:c}:null}_shrinkCol(i,r,e,t,n=w.SheetDrawingAnchorType.Position){const o=t-e+1,{from:s,to:a}=i,{column:d}=s,{column:g}=a;if(n===w.SheetDrawingAnchorType.None)return{newSheetTransform:H({...r},this._selectionRenderService),newTransform:r};let u=null,c=null;if(d>t)u={from:{...s,column:d-o},to:{...a,column:g-o}},c=J(u,this._selectionRenderService,this._skeletonManagerService);else{if(d>=e&&g<=t)return null;if(d<e&&g>t)if(n===w.SheetDrawingAnchorType.Both)u={from:{...s},to:{...a,column:g-o}},c=J(u,this._selectionRenderService,this._skeletonManagerService);else return{newSheetTransform:H({...r},this._selectionRenderService),newTransform:r};else if(d>=e&&d<=t){if(d===e)c={...r,left:(r.left||0)-i.from.columnOffset};else{const m=this._skeletonManagerService.attachRangeWithCoord({startColumn:e,endColumn:d-1,startRow:s.row,endRow:a.row});if(m==null)return;c={...r,left:(r.left||0)-m.endX+m.startX-i.from.columnOffset}}u=H(c,this._selectionRenderService)}else if(g>=e&&g<=t&&n===w.SheetDrawingAnchorType.Both){const m=this._skeletonManagerService.attachRangeWithCoord({startColumn:e-1,endColumn:e-1,startRow:s.row,endRow:a.row});if(m==null)return;u={from:{...s},to:{...a,column:e-1,columnOffset:m.endX-m.startX}},c=J(u,this._selectionRenderService,this._skeletonManagerService)}}return u!=null&&c!=null?{newSheetTransform:u,newTransform:c}:null}_expandRow(i,r,e,t,n=w.SheetDrawingAnchorType.Position){const o=t-e+1,{from:s,to:a}=i,{row:d}=s,{row:g}=a;if(n===w.SheetDrawingAnchorType.None)return{newSheetTransform:H({...r},this._selectionRenderService),newTransform:r};let u=null,c=null;if(d>=e){const m=this._skeletonManagerService.attachRangeWithCoord({startRow:e,endRow:t,startColumn:s.column,endColumn:a.column});if(m==null)return;c={...r,top:(r.top||0)+m.endY-m.startY},u=H(c,this._selectionRenderService)}else if(g>=t)if(n===w.SheetDrawingAnchorType.Both)u={from:{...s},to:{...a,row:g+o}},c=J(u,this._selectionRenderService,this._skeletonManagerService);else return{newSheetTransform:H({...r},this._selectionRenderService),newTransform:r};return u!=null&&c!=null?{newSheetTransform:u,newTransform:c}:null}_shrinkRow(i,r,e,t,n=w.SheetDrawingAnchorType.Position){const o=t-e+1,{from:s,to:a}=i,{row:d}=s,{row:g}=a;if(n===w.SheetDrawingAnchorType.None)return{newSheetTransform:H({...r},this._selectionRenderService),newTransform:r};let u=null,c=null;if(d>t)u={from:{...s,row:d-o},to:{...a,row:g-o}},c=J(u,this._selectionRenderService,this._skeletonManagerService);else{if(d>=e&&g<=t)return null;if(d<e&&g>t)if(n===w.SheetDrawingAnchorType.Both)u={from:{...s},to:{...a,row:g-o}},c=J(u,this._selectionRenderService,this._skeletonManagerService);else return{newSheetTransform:H({...r},this._selectionRenderService),newTransform:r};else if(d>=e&&d<=t){if(d===e)c={...r,top:(r.top||0)-i.from.rowOffset};else{const m=this._skeletonManagerService.attachRangeWithCoord({startRow:e,endRow:d-1,startColumn:s.column,endColumn:a.column});if(m==null)return;c={...r,top:(r.top||0)-m.endY+m.startY-i.from.rowOffset}}u=H(c,this._selectionRenderService)}else if(g>=e&&g<=t&&n===w.SheetDrawingAnchorType.Both){const m=this._skeletonManagerService.attachRangeWithCoord({startColumn:s.column,endColumn:s.column,startRow:e-1,endRow:e-1});if(m==null)return;u={from:{...s},to:{...a,row:e-1,rowOffset:m.endY-m.startY}},c=J(u,this._selectionRenderService,this._skeletonManagerService)}}return u!=null&&c!=null?{newSheetTransform:u,newTransform:c}:null}_commandListener(){this.disposeWithMe(this._commandService.onCommandExecuted(i=>{if(i.id===C.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._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 d=s[a].data;d!=null&&Object.keys(d).forEach(g=>{if(o===i&&a===r){const u=d[g];u.transform=J(u.sheetTransform,this._selectionRenderService,this._skeletonManagerService),t.push(d[g])}else n.push(d[g])})})}),this._drawingManagerService.removeNotification(n),this._drawingManagerService.addNotification(t)},0)}_sheetRefreshListener(){this.disposeWithMe(this._commandService.onCommandExecuted(i=>{An.includes(i.id)&&requestIdleCallback(()=>{const r=i.params,{unitId:e,subUnitId:t,ranges:n}=r;this._refreshDrawingTransform(e,t,n)})}))}_refreshDrawingTransform(i,r,e){const t=this._drawingManagerService.getDrawingData(i,r),n=[];Object.keys(t).forEach(o=>{const s=t[o],{sheetTransform:a,transform:d,anchorType:g=w.SheetDrawingAnchorType.Position}=s;if(g===w.SheetDrawingAnchorType.None)return!0;const{from:u,to:c}=a,{row:m,column:h}=u,{row:p,column:S}=c;for(let f=0;f<e.length;f++){const v=e[f],{startRow:_,endRow:D,startColumn:M,endColumn:y}=v;if(l.Rectangle.intersects({startRow:_,endRow:D,startColumn:M,endColumn:y},{startRow:m,endRow:p,startColumn:h,endColumn:S})||m>D||h>y){const T=g===w.SheetDrawingAnchorType.Position,I=J(a,this._selectionRenderService,this._skeletonManagerService);n.push({...s,transform:{...I,width:T?d==null?void 0:d.width:I==null?void 0:I.width,height:T?d==null?void 0:d.height:I==null?void 0:I.height}});break}}}),n.length!==0&&(this._drawingManagerService.refreshTransform(n),this._commandService.syncExecuteCommand(V.id,[i]))}};Ct=bn([me(1,A.IRenderManagerService),me(2,l.ICommandService),me(3,b.ISheetSelectionRenderService),me(4,l.Inject(b.SheetSkeletonManagerService)),me(5,l.Inject(C.SheetInterceptorService)),me(6,w.ISheetDrawingService),me(7,B.IDrawingManagerService),me(8,l.IUniverInstanceService)],Ct);function Un(){const i=j.useDependency(l.LocaleService),r=j.useDependency(j.IDialogService),e=j.useDependency(Fe),[t,n]=q.useState([he.CELL_ADDRESS]),[o,s]=q.useState(!1),[a,d]=q.useState(null),g=q.useMemo(()=>e.getCellImagesInSelection(),[e]),u=q.useMemo(()=>e.getDataColumns(),[e]),c=q.useMemo(()=>e.getSelectionRowRange(),[e]),m=u.length>0,h=q.useMemo(()=>u.map(T=>({label:T.label,value:String(T.index)})),[u]),[p,S]=q.useState(()=>h.length>0?h[0].value:"0"),f=q.useMemo(()=>{if(!t.includes(he.COLUMN_VALUE)||!c)return[];const I=Number(p);return[{startRow:c.startRow,endRow:c.endRow,startColumn:I,endColumn:I}]},[t,p,c]);b.useHighlightRange(f);const v=q.useCallback(T=>{T.length!==0&&n(T)},[]),_=q.useCallback(T=>{S(String(T))},[]),D=q.useCallback(()=>{r.close(ve)},[r]),M=q.useCallback(async()=>{if(g.length!==0){s(!0),d(null);try{await e.saveImages(g,{fileNameParts:t,columnIndex:t.includes(he.COLUMN_VALUE)?Number(p):void 0}),r.close(ve)}catch(T){console.error("Failed to save images:",T),d(i.t("sheetImage.save.error"))}finally{s(!1)}}},[e,g,t,p,r,i]),y=t.includes(he.COLUMN_VALUE);return F.jsxs("div",{className:"univer-flex univer-flex-col",children:[F.jsx(Y.FormLayout,{label:i.t("sheetImage.save.imageCount"),children:F.jsx("div",{className:"univer-text-sm univer-text-gray-600",children:g.length})}),F.jsx(Y.FormLayout,{label:i.t("sheetImage.save.fileNameConfig"),children:F.jsxs(Y.CheckboxGroup,{value:t,onChange:v,direction:"vertical",children:[F.jsx(Y.Checkbox,{value:he.CELL_ADDRESS,disabled:!m,children:i.t("sheetImage.save.useRowCol")}),m&&F.jsx(Y.Checkbox,{value:he.COLUMN_VALUE,children:i.t("sheetImage.save.useColumnValue")})]})}),y&&F.jsx(Y.FormLayout,{label:i.t("sheetImage.save.selectColumn"),children:F.jsx(Y.Select,{value:p,options:h,onChange:_})}),a&&F.jsx("div",{className:"univer-text-xs univer-text-red-500",children:a}),F.jsxs("div",{className:"univer-flex univer-justify-end univer-gap-2 univer-border-t univer-border-gray-200 univer-pt-3",children:[F.jsx(Y.Button,{onClick:D,disabled:o,children:i.t("sheetImage.save.cancel")}),F.jsx(Y.Button,{variant:"primary",onClick:M,disabled:o||g.length===0,children:o?i.t("sheetImage.save.saving"):i.t("sheetImage.save.confirm")})]})]})}const Pn=i=>{var _;const r=j.useDependency(l.ICommandService),e=j.useDependency(l.LocaleService),t=j.useDependency(B.IDrawingManagerService),n=j.useDependency(A.IRenderManagerService),{drawings:o}=i,s=o[0];if(s==null)return;const{unitId:a}=s,d=n.getRenderById(a),g=d==null?void 0:d.scene;if(g==null)return;const u=g.getTransformerByCreate(),[c,m]=q.useState(!0),h=(_=s.anchorType)!=null?_:w.SheetDrawingAnchorType.Position,[p,S]=q.useState(h);function f(D,M){const y=[];return D.forEach(T=>{const{oKey:I}=T,N=M.getDrawingOKey(I);if(N==null)return y.push(null),!0;const{unitId:O,subUnitId:k,drawingId:W,drawingType:P,anchorType:E,sheetTransform:$}=N;y.push({unitId:O,subUnitId:k,drawingId:W,anchorType:E,sheetTransform:$,drawingType:P})}),y}q.useEffect(()=>{const D=u.clearControl$.subscribe(y=>{y===!0&&m(!1)}),M=u.changeStart$.subscribe(y=>{var N;const{objects:T}=y,I=f(T,t);if(I.length===0)m(!1);else if(I.length>=1){m(!0);const O=((N=I[0])==null?void 0:N.anchorType)||w.SheetDrawingAnchorType.Position;S(O)}});return()=>{M.unsubscribe(),D.unsubscribe()}},[]);function v(D){S(D);const M=t.getFocusDrawings();if(M.length===0)return;const y=M.map(T=>({unitId:T.unitId,subUnitId:T.subUnitId,drawingId:T.drawingId,anchorType:D}));r.executeCommand(be.id,{unitId:M[0].unitId,drawings:y})}return F.jsxs("div",{className:Y.clsx("univer-grid univer-gap-2 univer-py-2 univer-text-gray-400",{"univer-hidden":!c}),children:[F.jsx("header",{className:"univer-text-gray-600 dark:!univer-text-gray-200",children:F.jsx("div",{children:e.t("drawing-anchor.title")})}),F.jsx("div",{children:F.jsxs(Y.RadioGroup,{value:p,onChange:v,direction:"vertical",children:[F.jsx(Y.Radio,{value:w.SheetDrawingAnchorType.Both,children:e.t("drawing-anchor.both")}),F.jsx(Y.Radio,{value:w.SheetDrawingAnchorType.Position,children:e.t("drawing-anchor.position")}),F.jsx(Y.Radio,{value:w.SheetDrawingAnchorType.None,children:e.t("drawing-anchor.none")})]})})]})},Nn=()=>{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)&&F.jsxs("div",{className:"univer-text-sm",children:[F.jsx(ge.DrawingCommonPanel,{drawings:e}),F.jsx(Pn,{drawings:e})]})},Dt="sheet.menu.image";function kn(i){return{id:Dt,type:j.MenuItemType.SUBITEMS,icon:"AddImageIcon",tooltip:"sheetImage.title",hidden$:j.getMenuHiddenObservable(i,l.UniverInstanceType.UNIVER_SHEET),disabled$:b.getCurrentRangeDisable$(i,{workbookTypes:[C.WorkbookEditablePermission],worksheetTypes:[C.WorksheetEditPermission],rangeTypes:[C.RangeProtectionPermissionEditPoint]})}}function Wn(i){return{id:Oe.id,title:"sheetImage.upload.float",type:j.MenuItemType.BUTTON,hidden$:j.getMenuHiddenObservable(i,l.UniverInstanceType.UNIVER_SHEET)}}function Bn(i){return{id:pt.id,title:"sheetImage.upload.cell",type:j.MenuItemType.BUTTON,hidden$:j.getMenuHiddenObservable(i,l.UniverInstanceType.UNIVER_SHEET)}}function jn(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 $n(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 d=n;d<=o;d++)for(let g=s;g<=a;g++){const u=t.getValue(d,g);if(jn(u))return!0}return!1}function Fn(){return"showDirectoryPicker"in window}function Tt(i){const r=i.get(l.IUniverInstanceService),e=i.get(C.SheetsSelectionsService),t=U.combineLatest([j.getMenuHiddenObservable(i,l.UniverInstanceType.UNIVER_SHEET),r.getCurrentTypeOfUnit$(l.UniverInstanceType.UNIVER_SHEET).pipe(U.switchMap(n=>n?e.selectionMoveEnd$.pipe(U.map(()=>{if(!Fn())return!0;const o=e.getCurrentSelections();if(!o||o.length===0)return!0;for(const s of o)if($n(n,s.range))return!1;return!0})):U.of(!0)))]).pipe(U.map(([n,o])=>n||o));return{id:_e.id,type:j.MenuItemType.BUTTON,icon:"DownloadImageIcon",title:"sheetImage.save.menuLabel",hidden$:t}}const Ln={[j.RibbonInsertGroup.MEDIA]:{[Dt]:{order:0,menuItemFactory:kn,[Oe.id]:{order:0,menuItemFactory:Wn},[pt.id]:{order:1,menuItemFactory:Bn}}},[j.ContextMenuPosition.MAIN_AREA]:{[j.ContextMenuGroup.OTHERS]:{[_e.id]:{order:10,menuItemFactory:Tt}}},[j.ContextMenuPosition.COL_HEADER]:{[j.ContextMenuGroup.OTHERS]:{[_e.id]:{order:10,menuItemFactory:Tt}}},[j.ContextMenuPosition.ROW_HEADER]:{[j.ContextMenuGroup.OTHERS]:{[_e.id]:{order:10,menuItemFactory:Tt}}}};function ke(i){return!i.getContextValue(l.FOCUSING_FX_BAR_EDITOR)&&!i.getContextValue(l.EDITOR_ACTIVATED)&&!i.getContextValue(l.FOCUSING_PANEL_EDITOR)&&i.getContextValue(l.FOCUSING_COMMON_DRAWINGS)}const Yn={id:we.id,description:"shortcut.drawing-move-down",group:"4_drawing-view",binding:j.KeyCode.ARROW_DOWN,priority:100,preconditions:ke,staticParameters:{direction:l.Direction.DOWN}},Gn={id:we.id,description:"shortcut.drawing-move-up",group:"4_drawing-view",binding:j.KeyCode.ARROW_UP,priority:100,preconditions:ke,staticParameters:{direction:l.Direction.UP}},Hn={id:we.id,description:"shortcut.drawing-move-left",group:"4_drawing-view",binding:j.KeyCode.ARROW_LEFT,priority:100,preconditions:ke,staticParameters:{direction:l.Direction.LEFT}},Vn={id:we.id,description:"shortcut.drawing-move-right",group:"4_drawing-view",binding:j.KeyCode.ARROW_RIGHT,priority:100,preconditions:ke,staticParameters:{direction:l.Direction.RIGHT}},Xn={id:lt.id,description:"shortcut.drawing-delete",group:"4_drawing-view",preconditions:ke,binding:j.KeyCode.DELETE,mac:j.KeyCode.BACKSPACE};var xn=Object.getOwnPropertyDescriptor,Kn=(i,r,e,t)=>{for(var n=t>1?void 0:t?xn(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 Qe=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(Pt,Nn)),this.disposeWithMe(i.register(ve,Un))}_initMenus(){this._menuManagerService.mergeMenu(Ln)}_initCommands(){[Oe,pt,Ee,Se,be,vt,V,_t,ut,ht,we,lt,gt,_e].forEach(i=>this.disposeWithMe(this._commandService.registerCommand(i)))}_initShortcuts(){[Yn,Gn,Hn,Vn,Xn].forEach(i=>{this.disposeWithMe(this._shortcutService.registerShortcut(i))})}_init(){this._initCommands(),this._initCustomComponents(),this._initMenus(),this._initShortcuts()}};Qe=Kn([ye(0,l.Inject(j.ComponentManager)),ye(1,j.IMenuManagerService),ye(2,l.ICommandService),ye(3,j.IShortcutService),ye(4,B.IDrawingManagerService),ye(5,l.Inject(C.SheetsSelectionsService))],Qe);var zn=Object.defineProperty,qn=Object.getOwnPropertyDescriptor,Zn=(i,r,e)=>r in i?zn(i,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[r]=e,Jn=(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},Mt=(i,r)=>(e,t)=>r(e,t,i),Lt=(i,r,e)=>Zn(i,typeof r!="symbol"?r+"":r,e);const Qn="SHEET_IMAGE_UI_PLUGIN";R.UniverSheetsDrawingUIPlugin=class extends l.Plugin{constructor(r=Nt,e,t,n){super(),this._config=r,this._injector=e,this._renderManagerService=t,this._configService=n;const{menu:o,...s}=l.merge({},Nt,this._config);o&&this._configService.setConfig("menu",o,{merge:!0}),this._configService.setConfig(tn,s)}onStarting(){l.registerDependencies(this._injector,[[R.SheetCanvasFloatDomManagerService],[Qe],[Ye],[Je],[ze],[Ke],[Ve],[Xe],[xe],[Fe,{useClass:R.BatchSaveImagesService}]]),l.touchDependencies(this._injector,[[R.SheetCanvasFloatDomManagerService]])}onReady(){l.touchDependencies(this._injector,[[Ke],[xe]])}onRendered(){this._registerRenderModules(),l.touchDependencies(this._injector,[[ze],[Je],[Qe],[Ve],[Xe]])}onSteady(){this._injector.get(Ye)}_registerRenderModules(){[[R.SheetDrawingUpdateController],[Ct],[yt],[It]].forEach(r=>{this.disposeWithMe(this._renderManagerService.registerRenderModule(l.UniverInstanceType.UNIVER_SHEET,r))})}},Lt(R.UniverSheetsDrawingUIPlugin,"type",l.UniverInstanceType.UNIVER_SHEET),Lt(R.UniverSheetsDrawingUIPlugin,"pluginName",Qn),R.UniverSheetsDrawingUIPlugin=Jn([l.DependentOn(B.UniverDrawingPlugin,bt.UniverDocsDrawingPlugin,ge.UniverDrawingUIPlugin,w.UniverSheetsDrawingPlugin),Mt(1,l.Inject(l.Injector)),Mt(2,A.IRenderManagerService),Mt(3,l.IConfigService)],R.UniverSheetsDrawingUIPlugin),R.ClearSheetDrawingTransformerOperation=V,R.DeleteDrawingsCommand=lt,R.EditSheetDrawingOperation=_t,R.FileNamePart=he,R.GroupSheetDrawingCommand=ut,R.IBatchSaveImagesService=Fe,R.InsertFloatImageCommand=Oe,R.InsertSheetDrawingCommand=Ee,R.MoveDrawingsCommand=we,R.RemoveSheetDrawingCommand=Se,R.SHEETS_IMAGE_MENU_ID=Dt,R.SHEET_FLOAT_DOM_PREFIX=$t,R.SaveCellImagesCommand=_e,R.SetDrawingArrangeCommand=gt,R.SetSheetDrawingCommand=be,R.SidebarSheetDrawingOperation=vt,R.UngroupSheetDrawingCommand=ht,R.calcSheetFloatDomPosition=ae,R.drawingPositionToTransform=J,R.transformToDrawingPosition=H,Object.defineProperty(R,Symbol.toStringTag,{value:"Module"})}));
|
|
14
|
+
(function(M,A){typeof exports=="object"&&typeof module<"u"?A(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"],A):(M=typeof globalThis<"u"?globalThis:M||self,A(M.UniverSheetsDrawingUi={},M.UniverEngineRender,M.UniverSheetsUi,M.UniverCore,M.UniverSheetsDrawing,M.UniverSheets,M.UniverDesign,M.UniverDocsUi,M.UniverDrawing,M.UniverUi,M.UniverDocsDrawing,M.UniverDrawingUi,M.rxjs,M.React,M.React))})(this,(function(M,A,b,l,w,C,Y,$e,B,j,bt,ge,U,F,q){"use strict";var rr=Object.defineProperty;var ir=(M,A,b)=>A in M?rr(M,A,{enumerable:!0,configurable:!0,writable:!0,value:b}):M[A]=b;var ie=(M,A,b)=>ir(M,typeof A!="symbol"?A+"":A,b);function J(i,r,e){const{from:t,to:n,flipY:o=!1,flipX:s=!1,angle:a=0,skewX:d=0,skewY:g=0}=i,u=e.getCurrent();if(u==null)return;const c=b.convertPositionSheetOverGridToAbsolute(u.unitId,u.sheetId,{from:t,to:n},e);let{left:m,top:h,width:p,height:S}=c;const f=e.getCurrentSkeleton(),v=f.rowHeaderWidth+f.columnTotalWidth,_=f.columnHeaderHeight+f.rowTotalHeight;return m+p>v&&(m=v-p),h+S>_&&(h=_-S),{flipY:o,flipX:s,angle:a,skewX:d,skewY:g,left:m,top:h,width:p,height:S}}function H(i,r){const{left:e=0,top:t=0,width:n=0,height:o=0,flipY:s=!1,flipX:a=!1,angle:d=0,skewX:g=0,skewY:u=0}=i,c=r.getCellWithCoordByOffset(e,t);if(c==null)return;const m={column:c.actualColumn,columnOffset:A.precisionTo(e-c.startX,1),row:c.actualRow,rowOffset:A.precisionTo(t-c.startY,1)},h=r.getCellWithCoordByOffset(e+n,t+o);if(h==null)return;const p={column:h.actualColumn,columnOffset:A.precisionTo(e+n-h.startX,1),row:h.actualRow,rowOffset:A.precisionTo(t+o-h.startY,1)};return{flipY:s,flipX:a,angle:d,skewX:g,skewY:u,from:m,to:p}}const V={id:"sheet.operation.clear-drawing-transformer",type:l.CommandType.MUTATION,handler:(i,r)=>{const e=i.get(A.IRenderManagerService);return r.forEach(t=>{var n,o;(o=(n=e.getRenderById(t))==null?void 0:n.scene.getTransformer())==null||o.debounceRefreshControls()}),!0}},Se={id:"sheet.command.remove-sheet-image",type:l.CommandType.COMMAND,handler:(i,r)=>{var _,D,R;const e=i.get(l.ICommandService),t=i.get(l.IUndoRedoService),n=i.get(C.SheetInterceptorService),o=i.get(w.ISheetDrawingService);if(!r)return!1;const{drawings:s}=r,a=[];s.forEach(y=>{const{unitId:T}=y;a.push(T)});const d=o.getBatchRemoveOp(s),{unitId:g,subUnitId:u,undo:c,redo:m,objects:h}=d,p=n.onCommandExecute({id:Se.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:c,objects:h,type:w.DrawingApplyType.INSERT}};return l.sequenceExecute([...(_=p.preRedos)!=null?_:[],S,...p.redos],e)?(t.pushUndoRedo({unitID:g,undoMutations:[...(D=p.preUndos)!=null?D:[],f,...p.undos,{id:V.id,params:a}],redoMutations:[...(R=p.preRedos)!=null?R:[],S,...p.redos,{id:V.id,params:a}]}),!0):!1}},lt={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:d,drawingId:g,drawingType:u}=s;return{unitId:a,subUnitId:d,drawingId:g,drawingType:u}});return r.executeCommand(Se.id,{unitId:n,drawings:o})}};function Kt(i){const r=[];return i.forEach(e=>{const{parent:t,children:n}=e,{unitId:o,subUnitId:s,drawingId:a}=t,d=A.getGroupState(0,0,n.map(c=>c.transform||{})),g=n.map(c=>{const m=c.transform||{left:0,top:0},{unitId:h,subUnitId:p,drawingId:S}=c;return{unitId:h,subUnitId:p,drawingId:S,transform:{...m,left:m.left-d.left,top:m.top-d.top},groupId:a}}),u={unitId:o,subUnitId:s,drawingId:a,drawingType:l.DrawingTypeEnum.DRAWING_GROUP,transform:d};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:d={width:0,height:0}}=t;if(d==null)return;const g=n.map(c=>{const{transform:m}=c,{unitId:h,subUnitId:p,drawingId:S}=c,f=A.transformObjectOutOfGroup(m||{},d,d.width||0,d.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 ut={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:d,undo:g,redo:u,objects:c}=s;return e.syncExecuteCommand(w.SetDrawingApplyMutation.id,{op:u,unitId:a,subUnitId:d,objects:c,type:w.DrawingApplyType.GROUP})?(t.pushUndoRedo({unitID:a,undoMutations:[{id:w.SetDrawingApplyMutation.id,params:{op:g,unitId:a,subUnitId:d,objects:zt(c),type:w.DrawingApplyType.UNGROUP}},{id:V.id,params:o}],redoMutations:[{id:w.SetDrawingApplyMutation.id,params:{op:u,unitId:a,subUnitId:d,objects:c,type:w.DrawingApplyType.GROUP}},{id:V.id,params:o}]}),!0):!1}},Ee={id:"sheet.command.insert-sheet-image",type:l.CommandType.COMMAND,handler:(i,r)=>{var _,D,R;const e=i.get(l.ICommandService),t=i.get(l.IUndoRedoService),n=i.get(w.ISheetDrawingService),o=i.get(C.SheetInterceptorService);if(!r)return!1;const s=r.drawings,a=s.map(y=>y.unitId),d=n.getBatchAddOp(s),{unitId:g,subUnitId:u,undo:c,redo:m,objects:h}=d,p=o.onCommandExecute({id:Ee.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:c,unitId:g,subUnitId:u,objects:h,type:w.DrawingApplyType.REMOVE}};return l.sequenceExecute([...(_=p.preRedos)!=null?_:[],S,...p.redos],e)?(t.pushUndoRedo({unitID:g,undoMutations:[...(D=p.preUndos)!=null?D:[],f,...p.undos,{id:V.id,params:a}],redoMutations:[...(R=p.preRedos)!=null?R:[],S,...p.redos,{id:V.id,params:a}]}),!0):!1}},gt={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:d}=r,g={unitId:o,subUnitId:s,drawingIds:a};let u;if(d===l.ArrangeTypeEnum.forward?u=n.getForwardDrawingsOp(g):d===l.ArrangeTypeEnum.backward?u=n.getBackwardDrawingOp(g):d===l.ArrangeTypeEnum.front?u=n.getFrontDrawingsOp(g):d===l.ArrangeTypeEnum.back&&(u=n.getBackDrawingsOp(g)),u==null)return!1;const{objects:c,redo:m,undo:h}=u;return e.syncExecuteCommand(w.SetDrawingApplyMutation.id,{op:m,unitId:o,subUnitId:s,objects:c,type:w.DrawingApplyType.ARRANGE})?(t.pushUndoRedo({unitID:o,undoMutations:[{id:w.SetDrawingApplyMutation.id,params:{op:h,unitId:o,subUnitId:s,objects:c,type:w.DrawingApplyType.ARRANGE}}],redoMutations:[{id:w.SetDrawingApplyMutation.id,params:{op:m,unitId:o,subUnitId:s,objects:c,type:w.DrawingApplyType.ARRANGE}}]}),!0):!1}},be={id:"sheet.command.set-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{drawings:o}=r,s=n.getBatchUpdateOp(o),{unitId:a,subUnitId:d,undo:g,redo:u,objects:c}=s;return e.syncExecuteCommand(w.SetDrawingApplyMutation.id,{unitId:a,subUnitId:d,op:u,objects:c,type:w.DrawingApplyType.UPDATE})?(t.pushUndoRedo({unitID:a,undoMutations:[{id:w.SetDrawingApplyMutation.id,params:{unitId:a,subUnitId:d,op:g,objects:c,type:w.DrawingApplyType.UPDATE}},{id:V.id,params:[a]}],redoMutations:[{id:w.SetDrawingApplyMutation.id,params:{unitId:a,subUnitId:d,op:u,objects:c,type:w.DrawingApplyType.UPDATE}},{id:V.id,params:[a]}]}),!0):!1}},ht={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:d,undo:g,redo:u,objects:c}=s;return e.syncExecuteCommand(w.SetDrawingApplyMutation.id,{op:u,unitId:a,subUnitId:d,objects:c,type:w.DrawingApplyType.UNGROUP})?(t.pushUndoRedo({unitID:a,undoMutations:[{id:w.SetDrawingApplyMutation.id,params:{op:g,unitId:a,subUnitId:d,objects:Kt(c),type:w.DrawingApplyType.GROUP}},{id:V.id,params:o}],redoMutations:[{id:w.SetDrawingApplyMutation.id,params:{op:u,unitId:a,subUnitId:d,objects:c,type:w.DrawingApplyType.UNGROUP}},{id:V.id,params:o}]}),!0):!1}};var qt=Object.getOwnPropertyDescriptor,Zt=(i,r,e,t)=>{for(var n=t>1?void 0:t?qt(r,e):r,o=i.length-1,s;o>=0;o--)(s=i[o])&&(n=s(n)||n);return n},te=(i,r)=>(e,t)=>r(e,t,i);function Jt(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 mt(i,r,e,t,n){var _;const{rotatedHeight:o,rotatedWidth:s}=Jt(e,t,n),d=i.get(A.IRenderManagerService).getRenderById(r.unitId);if(!d)return!1;const u=(_=d.with(b.SheetSkeletonManagerService).getSkeletonParam(r.subUnitId))==null?void 0:_.skeleton;if(u==null)return!1;const c=u.getCellByIndex(r.row,r.col),m=c.mergeInfo.endX-c.mergeInfo.startX-2,h=c.mergeInfo.endY-c.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}}M.SheetDrawingUpdateController=class extends l.Disposable{constructor(e,t,n,o,s,a,d,g,u,c,m,h,p){super();ie(this,"_workbookSelections");this._context=e,this._skeletonManagerService=t,this._commandService=n,this._selectionRenderService=o,this._imageIoService=s,this._fileOpenerService=a,this._sheetDrawingService=d,this._drawingManagerService=g,this._contextService=u,this._messageService=c,this._localeService=m,this._injector=p,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:Y.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){let t;try{t=await this._imageIoService.saveImage(e)}catch(D){const R=D.message;R===B.ImageUploadStatusType.ERROR_EXCEED_SIZE?this._messageService.show({type:Y.MessageType.Error,content:this._localeService.t("update-status.exceedMaxSize",String(B.DRAWING_IMAGE_ALLOW_SIZE/(1024*1024)))}):R===B.ImageUploadStatusType.ERROR_IMAGE_TYPE?this._messageService.show({type:Y.MessageType.Error,content:this._localeService.t("update-status.invalidImageType")}):R===B.ImageUploadStatusType.ERROR_IMAGE&&this._messageService.show({type:Y.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:d,source:g,base64Cache:u}=t,{width:c,height:m,image:h}=await B.getImageSize(u||""),{width:p,height:S}=this._context.scene;this._imageIoService.addImageSourceCache(g,d,h);let f=1;if(c>B.DRAWING_IMAGE_WIDTH_LIMIT||m>B.DRAWING_IMAGE_HEIGHT_LIMIT){const D=B.DRAWING_IMAGE_WIDTH_LIMIT/c,R=B.DRAWING_IMAGE_HEIGHT_LIMIT/m;f=Math.max(D,R)}const v=this._getImagePosition(c*f,m*f,p,S);if(v==null)return;const _={unitId:o,subUnitId:s,drawingId:a,drawingType:l.DrawingTypeEnum.DRAWING_IMAGE,imageSourceType:d,source:g,transform:J(v,this._selectionRenderService,this._skeletonManagerService),sheetTransform:v};return this._commandService.executeCommand(Ee.id,{unitId:o,drawings:[_]})}async _insertCellImage(e,t){var R,y;let n;try{n=await this._imageIoService.saveImage(e)}catch(T){const I=T.message;I===B.ImageUploadStatusType.ERROR_EXCEED_SIZE?this._messageService.show({type:Y.MessageType.Error,content:this._localeService.t("update-status.exceedMaxSize",String(B.DRAWING_IMAGE_ALLOW_SIZE/(1024*1024)))}):I===B.ImageUploadStatusType.ERROR_IMAGE_TYPE?this._messageService.show({type:Y.MessageType.Error,content:this._localeService.t("update-status.invalidImageType")}):I===B.ImageUploadStatusType.ERROR_IMAGE&&this._messageService.show({type:Y.MessageType.Error,content:this._localeService.t("update-status.invalidImage")})}if(n==null)return!1;const{imageId:o,imageSourceType:s,source:a,base64Cache:d}=n,{width:g,height:u,image:c}=await B.getImageSize(d||"");this._imageIoService.addImageSourceCache(a,s,c);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=mt(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},_={unitId:S.getUnitId(),subUnitId:S.getUnitId(),drawingId:o,drawingType:l.DrawingTypeEnum.DRAWING_IMAGE,imageSourceType:s,source:a,transform:$e.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:[_],selection:{collapsed:!0,startOffset:0,endOffset:0}});return D?(S.apply(D),this._commandService.syncExecuteCommand(C.SetRangeValuesCommand.id,{value:{[(R=t==null?void 0:t.row)!=null?R:h]:{[(y=t==null?void 0:t.col)!=null?y: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 h,p;const{width:n,height:o,image:s}=await B.getImageSize(e||"");this._imageIoService.addImageSourceCache(e,l.ImageSourceType.URL,s);const a=this._workbookSelections.getCurrentLastSelection();if(!a)return!1;const d=l.createDocumentModelWithStyle("",{}),g=mt(this._injector,{unitId:this._context.unitId,subUnitId:this._context.unit.getActiveSheet().getSheetId(),row:a.primary.actualRow,col:a.primary.actualColumn},n,o,0);if(!g)return!1;const u={size:{width:g.width,height:g.height},positionH:{relativeFrom:l.ObjectRelativeFromH.PAGE,posOffset:0},positionV:{relativeFrom:l.ObjectRelativeFromV.PARAGRAPH,posOffset:0},angle:0},c={unitId:d.getUnitId(),subUnitId:d.getUnitId(),drawingId:l.generateRandomId(),drawingType:l.DrawingTypeEnum.DRAWING_IMAGE,imageSourceType:l.ImageSourceType.URL,source:e,transform:$e.docDrawingPositionToTransform(u),docTransform:u,behindDoc:l.BooleanNumber.FALSE,title:"",description:"",layoutType:l.PositionedObjectLayoutType.INLINE,wrapText:l.WrapTextType.BOTH_SIDES,distB:0,distL:0,distR:0,distT:0},m=l.BuildTextUtils.drawing.add({documentDataModel:d,drawings:[c],selection:{collapsed:!0,startOffset:0,endOffset:0}});return m?(d.apply(m),this._commandService.syncExecuteCommand(C.SetRangeValuesCommand.id,{value:{[(h=t==null?void 0:t.row)!=null?h:a.primary.actualRow]:{[(p=t==null?void 0:t.col)!=null?p:a.primary.actualColumn]:{p:d.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 d=b.attachRangeWithCoord(this._skeletonManagerService.getCurrent().skeleton,a);if(d==null)return;let{startColumn:g,startRow:u,startX:c,startY:m}=d,h=!1;if(c+e>n&&(c=n-e,c<0&&(c=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(c,m);if(v==null)return;c=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(c+e,m+t);if(S==null)return;const f={column:S.actualColumn,columnOffset:c+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(gt.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:d,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 c=H({...u.transform,...g},this._selectionRenderService);if(c==null)return;const m={...n,transform:{...u.transform,...g,...J(c,this._selectionRenderService,this._skeletonManagerService)},sheetTransform:{...c}};t.push(m)}),t.length>0&&this._commandService.executeCommand(be.id,{unitId:e[0].unitId,drawings:t}))}))}_groupDrawingListener(){this.disposeWithMe(this._drawingManagerService.featurePluginGroupUpdate$.subscribe(e=>{this._commandService.executeCommand(ut.id,e);const{unitId:t,subUnitId:n,drawingId:o}=e[0].parent;this._commandService.syncExecuteCommand(B.SetDrawingSelectedOperation.id,[{unitId:t,subUnitId:n,drawingId:o}])})),this.disposeWithMe(this._drawingManagerService.featurePluginUngroupUpdate$.subscribe(e=>{this._commandService.executeCommand(ht.id,e)}))}_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))}))}},M.SheetDrawingUpdateController=Zt([te(1,l.Inject(b.SheetSkeletonManagerService)),te(2,l.ICommandService),te(3,b.ISheetSelectionRenderService),te(4,B.IImageIoService),te(5,j.ILocalFileService),te(6,w.ISheetDrawingService),te(7,B.IDrawingManagerService),te(8,l.IContextService),te(9,j.IMessageService),te(10,l.Inject(l.LocaleService)),te(11,l.Inject(C.SheetsSelectionsService)),te(12,l.Inject(l.Injector))],M.SheetDrawingUpdateController);const Oe={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(A.IRenderManagerService),n=(s=A.getCurrentTypeOfRenderer(l.UniverInstanceType.UNIVER_SHEET,e,t))==null?void 0:s.with(M.SheetDrawingUpdateController);if(!n)return!1;const o=r==null?void 0:r.files;if(o){const d=o.map(g=>n.insertFloatImageByFile(g));return(await Promise.all(d)).every(g=>g)}else return(a=n.insertFloatImage())!=null?a:!1}},pt={id:"sheet.command.insert-cell-image",type:l.CommandType.COMMAND,handler:i=>{var t,n;const r=i.get(l.IUniverInstanceService),e=i.get(A.IRenderManagerService);return(n=(t=A.getCurrentTypeOfRenderer(l.UniverInstanceType.UNIVER_SHEET,r,e))==null?void 0:t.with(M.SheetDrawingUpdateController).insertCellImage())!=null?n:!1}},we={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(b.ISheetSelectionRenderService),{direction:o}=r,s=t.getFocusDrawings();if(s.length===0)return!1;const a=s[0].unitId,d=s.map(u=>{const{transform:c}=u;if(c==null)return null;const m={...c},{left:h=0,top:p=0}=c;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:H(m,n)}}).filter(u=>u!=null);return e.syncExecuteCommand(be.id,{unitId:a,drawings:d})?(e.syncExecuteCommand(V.id,[a]),!0):!1}};var Qt=Object.getOwnPropertyDescriptor,en=(i,r,e,t)=>{for(var n=t>1?void 0:t?Qt(r,e):r,o=i.length-1,s;o>=0;o--)(s=i[o])&&(n=s(n)||n);return n},ft=(i,r)=>(e,t)=>r(e,t,i),he=(i=>(i.CELL_ADDRESS="cellAddress",i.COLUMN_VALUE="columnValue",i))(he||{});const Fe=l.createIdentifier("sheets-drawing-ui.batch-save-images.service");function St(i){let r="",e=i;for(;e>=0;)r=String.fromCharCode(e%26+65)+r,e=Math.floor(e/26)-1;return r}function Le(i,r){return`${St(r)}${i+1}`}function tn(i){const r=Le(i.startRow,i.startColumn),e=Le(i.endRow,i.endColumn);return r===e?r:`${r}:${e}`}function Ot(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 At(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 wt(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 Ut(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")}M.BatchSaveImagesService=class extends l.Disposable{constructor(r,e,t){super(),this._univerInstanceService=r,this._selectionService=e,this._imageIoService=t}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:d,startColumn:g,endColumn:u}=s.range;for(let c=a;c<=d;c++)for(let m=g;m<=u;m++){const h=n.getValue(c,m);if(Ot(h)){const p=At(h);p&&o.push({row:c,col:m,cellAddress:Le(c,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 d of t){const{startRow:g,endRow:u,startColumn:c,endColumn:m}=d;for(let h=g;h<=u;h++)for(let p=c;p<=m;p++){const S=s.getValue(h,p);if(Ot(S)){const f=At(S);f&&a.push({row:h,col:p,cellAddress:Le(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 d=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++)d.add(v)}const g=new Set;for(let f=o.startColumn;f<=o.endColumn;f++)if(!d.has(f))for(let v=s;v<=a;v++){const _=n.getValue(v,f);if(_&&(((m=_.v)==null?void 0:m.toString())||((S=(p=(h=_.p)==null?void 0:h.body)==null?void 0:p.dataStream)==null?void 0:S.trim())||"")){g.add(f);break}}const u=[],c=Array.from(g).sort((f,v)=>f-v);for(const f of c)u.push({index:f,label:St(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 d=1/0,g=-1/0;const u=new Set;for(const _ of t){d=Math.min(d,_.startRow),g=Math.max(g,_.endRow);for(let D=_.startColumn;D<=_.endColumn;D++)u.add(D)}const c=new Set;for(let _=a.startColumn;_<=a.endColumn;_++)if(!u.has(_))for(let D=d;D<=g;D++){const R=s.getValue(D,_);if(R&&(((p=R.v)==null?void 0:p.toString())||((v=(f=(S=R.p)==null?void 0:S.body)==null?void 0:f.dataStream)==null?void 0:v.trim())||"")){c.add(_);break}}const m=[],h=Array.from(c).sort((_,D)=>_-D);for(const _ of h)m.push({index:_,label:St(_)});return m}getSelectionRangeNotation(){const r=this._selectionService.getCurrentSelections();return!r||r.length===0?"":r.map(e=>tn(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,d,g;const t=this._univerInstanceService.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET),n=wt(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 c=t==null?void 0:t.getActiveSheet();if(c){const h=c.getCellMatrix().getValue(r.row,e.columnIndex);if(h){const p=((s=h.v)==null?void 0:s.toString())||((g=(d=(a=h.p)==null?void 0:a.body)==null?void 0:d.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 d,g,u,c;const o=this._univerInstanceService.getUnit(t,l.UniverInstanceType.UNIVER_SHEET),s=wt(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=((d=S.v)==null?void 0:d.toString())||((c=(u=(g=S.p)==null?void 0:g.body)==null?void 0:u.dataStream)==null?void 0:c.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 d=a.replace(/\.\w+$/,""),g=((o=a.match(/\.\w+$/))==null?void 0:o[0])||".png",u=n.get(d)||0;u>0&&(a=`${d}_${u}${g}`),n.set(d,u+1);try{const c=await this._getImageBlob(s),h=await(await t.getFileHandle(a,{create:!0})).createWritable();await h.write(c),await h.close()}catch(c){throw console.error(`Failed to save image ${a}:`,c),c}}}async saveImagesWithContext(r,e,t,n){var a;const o=await window.showDirectoryPicker({mode:"readwrite"}),s=new Map;for(const d of r){let g=this.generateFileNameWithContext(d,e,t,n);const u=g.replace(/\.\w+$/,""),c=((a=g.match(/\.\w+$/))==null?void 0:a[0])||".png",m=s.get(u)||0;m>0&&(g=`${u}_${m}${c}`),s.set(u,m+1);try{const h=await this._getImageBlob(d),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=wt(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 Ut(e,l.ImageSourceType.URL)}return Ut(r.source,r.imageSourceType)}},M.BatchSaveImagesService=en([ft(0,l.IUniverInstanceService),ft(1,l.Inject(C.SheetsSelectionsService)),ft(2,l.IImageIoService)],M.BatchSaveImagesService);const ve="sheet.dialog.batch-save-images",_e={id:"sheet.command.save-cell-images",type:l.CommandType.COMMAND,handler:async i=>{const r=i.get(j.IDialogService),e=i.get(Fe),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:ve,draggable:!0,width:360,title:{title:s},children:{label:ve},destroyOnClose:!0,preservePositionOnDestroy:!0,onClose:()=>r.close(ve)}),!0}},Pt="COMPONENT_SHEET_DRAWING_PANEL",vt={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 C.getSheetCommandTarget(n)?(r.value==="open"?e.open({header:{title:t.t("sheetImage.panel.title")},children:{label:Pt},onClose:()=>{o.syncExecuteCommand(B.SetDrawingSelectedOperation.id,[])},width:360}):e.close(),!0):!1}},_t={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(vt.id,{value:"open"}),!0)}},nn="sheets-drawing-ui.config",Nt={};var rn=Object.getOwnPropertyDescriptor,on=(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},se=(i,r)=>(e,t)=>r(e,t,i);let Ye=class extends l.RxDisposable{constructor(r,e,t,n,o,s,a,d,g,u){super();ie(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=d,this._ioService=g,this._commandService=u,this._init()}_init(){this._univerInstanceService.getCurrentTypeOfUnit$(l.UniverInstanceType.UNIVER_SHEET).pipe(U.takeUntil(this.dispose$)).subscribe(r=>this._create(r)),this._univerInstanceService.getTypeOfUnitDisposed$(l.UniverInstanceType.UNIVER_SHEET).pipe(U.takeUntil(this.dispose$)).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:Y.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)}_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 ge.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 d=a.oKey,g=this._drawingManagerService.getDrawingOKey(d);if(!g)return;const{unitId:u,subUnitId:c,drawingId:m,drawingType:h}=g,p=g.data;if(p&&p.disablePopup)return;n==null||n.dispose();const S=this._canvasPopManagerService.getFeatureMenu(u,c,m,h);n=this.disposeWithMe(this._canvasPopManagerService.attachPopupToObject(a,{componentKey:ge.COMPONENT_IMAGE_POPUP_MENU,direction:"horizontal",offset:[2,0],extraProps:{menuItems:S||this._getImageMenuItems(u,c,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:_t.id,commandParams:{unitId:r,subUnitId:e,drawingId:t},disable:n===l.DrawingTypeEnum.DRAWING_DOM},{label:"image-popup.delete",index:1,commandId:Se.id,commandParams:{unitId:r,drawings:[{unitId:r,subUnitId:e,drawingId:t}]},disable:!1},{label:"image-popup.crop",index:2,commandId:ge.OpenImageCropOperation.id,commandParams:{unitId:r,subUnitId:e,drawingId:t},disable:n===l.DrawingTypeEnum.DRAWING_DOM},{label:"image-popup.reset",index:3,commandId:ge.ImageResetSizeOperation.id,commandParams:[{unitId:r,subUnitId:e,drawingId:t}],disable:n===l.DrawingTypeEnum.DRAWING_DOM}]}};Ye=on([se(0,l.Inject(l.Injector)),se(1,l.Inject(l.LocaleService)),se(2,B.IDrawingManagerService),se(3,l.Inject(b.SheetCanvasPopManagerService)),se(4,A.IRenderManagerService),se(5,l.IUniverInstanceService),se(6,j.IMessageService),se(7,l.IContextService),se(8,l.IImageIoService),se(9,l.ICommandService)],Ye);var sn=Object.getOwnPropertyDescriptor,an=(i,r,e,t)=>{for(var n=t>1?void 0:t?sn(r,e):r,o=i.length-1,s;o>=0;o--)(s=i[o])&&(n=s(n)||n);return n},Ge=(i,r)=>(e,t)=>r(e,t,i);let It=class extends l.Disposable{constructor(r,e,t,n,o){super();ie(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(U.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(A.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}}))}};It=an([Ge(1,l.Inject(b.HoverManagerService)),Ge(2,l.Inject(C.SheetsSelectionsService)),Ge(3,l.Inject(ge.DrawingRenderService)),Ge(4,l.Inject(b.SheetSkeletonManagerService))],It);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},He=(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=J(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=dn([He(1,w.ISheetDrawingService),He(2,B.IDrawingManagerService),He(3,l.Inject(b.ISheetSelectionRenderService)),He(4,l.Inject(b.SheetSkeletonManagerService))],Ct);var ln=Object.getOwnPropertyDescriptor,un=(i,r,e,t)=>{for(var n=t>1?void 0:t?ln(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 kt(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]],d=mt(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(d)return a.transform.width=d.width,a.transform.height=d.height,a.docTransform.size.width=d.width,a.docTransform.size.height=d.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 Ve=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===$e.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(C.INTERCEPTOR_POINT.CELL_CONTENT,{effect:l.InterceptorEffectEnum.Style,priority:C.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},kt(this._injector,{unitId:r.unitId,subUnitId:r.subUnitId,row:r.row,col:r.col},i)),e(i)}}))}};Ve=un([Ie(0,l.ICommandService),Ie(1,l.Inject(C.SheetInterceptorService)),Ie(2,l.Inject(l.Injector)),Ie(3,B.IDrawingManagerService),Ie(4,l.Inject(bt.DocDrawingController)),Ie(5,l.Inject(b.IEditorBridgeService))],Ve);var gn=Object.getOwnPropertyDescriptor,hn=(i,r,e,t)=>{for(var n=t>1?void 0:t?gn(r,e):r,o=i.length-1,s;o>=0;o--)(s=i[o])&&(n=s(n)||n);return n},Wt=(i,r)=>(e,t)=>r(e,t,i);let Xe=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)=>{kt(this._injector,{unitId:i.unitId,subUnitId:i.subUnitId,row:n,col:o},s)})}}))}};Xe=hn([Wt(0,l.Inject(b.IAutoFillService)),Wt(1,l.Inject(l.Injector))],Xe);var mn=Object.getOwnPropertyDescriptor,pn=(i,r,e,t)=>{for(var n=t>1?void 0:t?mn(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);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 xe=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=A.getCurrentTypeOfRenderer(l.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null?void 0:n.with(b.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===$e.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(b.SetCellEditVisibleOperation.id,{visible:!1})};((e=o.getBody())==null?void 0:e.dataStream)===`\r
|
|
15
|
+
`?(this._commandService.syncExecuteCommand(b.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")}}}))}};xe=pn([Ae(0,l.ICommandService),Ae(1,l.IUniverInstanceService),Ae(2,j.IDialogService),Ae(3,A.IRenderManagerService),Ae(4,l.Inject(l.LocaleService))],xe);var Sn=Object.getOwnPropertyDescriptor,wn=(i,r,e,t)=>{for(var n=t>1?void 0:t?Sn(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 Bt="image/png";function vn(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:Bt})}function _n(i){const r=new ClipboardItem({[Bt]:vn(i)});navigator.clipboard.write([r]).catch(e=>{console.error("Could not copy image using clipboard API: ",e)})}function In(){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 jt=[b.PREDEFINED_HOOK_NAME_PASTE.SPECIAL_PASTE_COL_WIDTH,b.PREDEFINED_HOOK_NAME_PASTE.SPECIAL_PASTE_VALUE,b.PREDEFINED_HOOK_NAME_PASTE.SPECIAL_PASTE_FORMAT,b.PREDEFINED_HOOK_NAME_PASTE.SPECIAL_PASTE_FORMULA];let Ke=class extends l.Disposable{constructor(r,e,t,n,o){super();ie(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===b.COPY_TYPE.CUT){const d={unitId:r,drawings:[s]};this._commandService.executeCommand(Se.id,d)}setTimeout(()=>{const d=In();s.drawingType===l.DrawingTypeEnum.DRAWING_IMAGE&&s.imageSourceType===B.ImageSourceType.BASE64?_n(s.source):this._clipboardInterfaceService.writeText(""),d()},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=b.COPY_TYPE.COPY,pasteType:s}=n,{range:a}=r||{},{range:d,unitId:g,subUnitId:u}=e;return this._copyInfo.copyRange?this._generateRangeDrawingsPasteMutations({pasteType:s,unitId:g,subUnitId:u,pasteRange:d},{copyRange:a,copyType:o}):this._generateSingleDrawingPasteMutations({pasteTo:e,pasteType:s},b.COPY_TYPE.COPY)},onPastePlainText:(r,e)=>({undos:[],redos:[]}),onPasteUnrecognized:r=>this._copyInfo?this._generateSingleDrawingPasteMutations({pasteTo:r,pasteType:b.PREDEFINED_HOOK_NAME_PASTE.DEFAULT_PASTE},b.COPY_TYPE.COPY):{undos:[],redos:[]},onPasteFiles:(r,e)=>{if(this._copyInfo)return this._generateSingleDrawingPasteMutations({pasteTo:r,pasteType:b.PREDEFINED_HOOK_NAME_PASTE.DEFAULT_PASTE},b.COPY_TYPE.COPY);{const t=e.filter(n=>n.type.includes("image"));if(t.length)return{undos:[],redos:[{id:Oe.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(b.SheetSkeletonManagerService);if(!n)return;const o=n.attachRangeWithCoord(t);if(!o)return;const{startX:s,endX:a,startY:d,endY:g}=o,u=this._drawingService.getDrawingData(r,e),c=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:_=0,height:D=0}=S,{drawingStartX:R,drawingEndX:y,drawingStartY:T,drawingEndY:I}={drawingStartX:f,drawingEndX:f+_,drawingStartY:v,drawingEndY:v+D};s<=R&&y<=a&&d<=T&&I<=g&&c.push(p)}),c.length)return{copyRange:t,drawings:c,unitId:r,subUnitId:e}}_generateSingleDrawingPasteMutations(r,e){const{pasteType:t,pasteTo:n}=r;if(jt.includes(t))return{redos:[],undos:[]};const{unitId:o,subUnitId:s,range:a}=n,d=this._renderManagerService.getRenderById(o),g=d==null?void 0:d.with(b.SheetSkeletonManagerService),u=d==null?void 0:d.with(b.ISheetSelectionRenderService),c=this._copyInfo;if(!g||!u)return{redos:[],undos:[]};const{drawings:m}=c,h=b.discreteRangeToRange(a);return this._generateMutations(m,{unitId:o,subUnitId:s,isCut:e===b.COPY_TYPE.CUT,getTransform:(p,S)=>{var _;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:(_=H(v,u))!=null?_:S}}})}_generateMutations(r,e){const{unitId:t,subUnitId:n,getTransform:o,isCut:s}=e,a=[],d=[],{_drawingService:g}=this;return r.forEach(u=>{const{transform:c,sheetTransform:m}=u;if(!c)return;const h=o(c,m),p={...u,unitId:t,subUnitId:n,drawingId:s?u.drawingId:l.generateRandomId(),transform:h.transform,sheetTransform:h.sheetTransform};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}}),d.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}}),d.push({id:w.SetDrawingApplyMutation.id,params:{op:S,unitId:t,subUnitId:n,objects:v,type:w.DrawingApplyType.REMOVE}})}}),{redos:a,undos:d}}_generateRangeDrawingsPasteMutations(r,e){var N;const{unitId:t,subUnitId:n,pasteType:o,pasteRange:s}=r,{copyRange:a,copyType:d}=e;if(jt.includes(o))return{redos:[],undos:[]};const g=(N=this._renderManagerService.getRenderById(t))==null?void 0:N.with(b.SheetSkeletonManagerService);if(!g||!this._copyInfo)return{redos:[],undos:[]};const{drawings:u}=this._copyInfo;if(!a)return this._generateSingleDrawingPasteMutations({pasteTo:{unitId:t,subUnitId:n,range:b.discreteRangeToRange(s)},pasteType:o},d);const{ranges:[c,m],mapFunc:h}=b.virtualizeDiscreteRanges([a,s]),{row:p,col:S}=h(c.startRow,c.startColumn),{row:f,col:v}=h(m.startRow,m.startColumn),_=g.attachRangeWithCoord({startRow:p,endRow:p,startColumn:S,endColumn:S}),D=g.attachRangeWithCoord({startRow:f,endRow:f,startColumn:v,endColumn:v});if(!_||!D||!this._copyInfo)return{redos:[],undos:[]};const R=D.startX-_.startX,y=D.startY-_.startY,T=f-p,I=v-S;return this._generateMutations(u,{unitId:t,subUnitId:n,getTransform:(O,k)=>{var W,P;return{transform:{...O,left:((W=O==null?void 0:O.left)!=null?W:0)+R,top:((P=O==null?void 0:O.top)!=null?P:0)+y},sheetTransform:{...k,to:{...k.to,row:k.to.row+T,column:k.to.column+I},from:{...k.from,row:k.from.row+T,column:k.from.column+I}}}},isCut:d===b.COPY_TYPE.CUT})}};Ke=wn([Ue(0,b.ISheetClipboardService),Ue(1,A.IRenderManagerService),Ue(2,B.IDrawingManagerService),Ue(3,j.IClipboardInterfaceService),Ue(4,l.ICommandService)],Ke);var Cn=Object.getOwnPropertyDescriptor,yn=(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},Pe=(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=U.combineLatest([i,r]);this.disposeWithMe(e.pipe(U.switchMap(([t,n])=>t?t.activeSheet$.pipe(U.tap(o=>{if(!o){this._drawingManagerService.setDrawingVisible(!1);return}const s=t.getUnitId(),a=o.getSheetId();this._permissionService.composePermission([new C.WorkbookViewPermission(s).id,new C.WorksheetViewPermission(s,a).id]).every(g=>g.value)?this._drawingManagerService.setDrawingVisible(!0):this._handleDrawingVisibilityFalse(t,o)})):(this._drawingManagerService.setDrawingVisible(!1),U.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===A.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=U.combineLatest([i,r]);this.disposeWithMe(e.pipe(U.switchMap(([t,n])=>t?t.activeSheet$.pipe(U.tap(o=>{if(!o){this._drawingManagerService.setDrawingEditable(!1);return}const s=t.getUnitId(),a=o.getSheetId();this._permissionService.composePermission([new C.WorkbookEditablePermission(s).id,new C.WorksheetEditPermission(s,a).id]).every(g=>g.value)?this._drawingManagerService.setDrawingEditable(!0):this._handleDrawingEditableFalse(t,o)})):(this._drawingManagerService.setDrawingEditable(!1),U.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===A.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(U.combineLatest([i,r]).pipe(U.switchMap(([e,t])=>e?e.activeSheet$.pipe(U.switchMap(n=>{if(!n)return U.EMPTY;const o=e.getUnitId(),s=n.getSheetId(),a=this._renderManagerService.getRenderById(o),d=a==null?void 0:a.scene;if(!d)return U.EMPTY;const g=d.getTransformerByCreate();return this._permissionService.composePermission$([new C.WorkbookViewPermission(o).id,new C.WorksheetViewPermission(o,s).id]).pipe(U.map(c=>c.every(m=>m.value)),U.distinctUntilChanged()).pipe(U.map(c=>({permission:c,scene:d,transformer:g,unitId:o,subUnitId:s})))})):U.EMPTY)).subscribe({next:({permission:e,scene:t,transformer:n,unitId:o,subUnitId:s})=>{this._drawingManagerService.setDrawingVisible(e);const a=t.getAllObjectsByOrder(),d=this._drawingManagerService.getDrawingData(o,s),g=Object.values(d);e?this._drawingManagerService.addNotification(g):(a.forEach(u=>{u.classType===A.RENDER_CLASS_TYPE.IMAGE&&g.some(c=>u.oKey.includes(c.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(U.combineLatest([i,r]).pipe(U.switchMap(([e,t])=>e?e.activeSheet$.pipe(U.switchMap(n=>{if(!n)return U.EMPTY;const o=e.getUnitId(),s=n.getSheetId(),a=this._renderManagerService.getRenderById(o),d=a==null?void 0:a.scene;if(!d)return U.EMPTY;const g=d.getTransformerByCreate();return this._permissionService.composePermission$([new C.WorkbookEditablePermission(o).id,new C.WorksheetEditPermission(o,s).id]).pipe(U.map(c=>c.every(m=>m.value)),U.distinctUntilChanged()).pipe(U.map(c=>({permission:c,scene:d,transformer:g,unitId:o,subUnitId:s})))})):U.EMPTY)).subscribe({next:({permission:e,scene:t,transformer:n,unitId:o,subUnitId:s})=>{this._drawingManagerService.setDrawingEditable(e);const a=t.getAllObjectsByOrder(),d=this._drawingManagerService.getDrawingData(o,s),g=Object.values(d);e?(a.forEach(u=>{u.classType===A.RENDER_CLASS_TYPE.IMAGE&&g.some(c=>u.oKey.includes(c.drawingId))&&t.attachTransformerTo(u)}),this._drawingManagerService.addNotification(g)):(a.forEach(u=>{u.classType===A.RENDER_CLASS_TYPE.IMAGE&&g.some(c=>u.oKey.includes(c.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 d=this._drawingManagerService.getDrawingData(t,o),g=Object.values(d);this._drawingManagerService.setDrawingEditable(!0),a.getAllObjectsByOrder().forEach(c=>{c.classType===A.RENDER_CLASS_TYPE.IMAGE&&g.some(m=>c.oKey.includes(m.drawingId))&&a.detachTransformerFrom(c)})}}))}};ze=yn([Pe(0,B.IDrawingManagerService),Pe(1,A.IRenderManagerService),Pe(2,l.IPermissionService),Pe(3,l.IUniverInstanceService),Pe(4,l.Inject(l.UserManagerService))],ze);var Dn=Object.getOwnPropertyDescriptor,Tn=(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},pe=(i,r)=>(e,t)=>r(e,t,i);const $t="univer-sheet-float-dom-";function Ft(i,r,e,t,n,o=!1){const{scaleX:s,scaleY:a}=r.getAncestorScale(),d=r.getViewport(A.SHEET_VIEWPORT_KEY.VIEW_MAIN),g=t.getFreeze(),{startColumn:u,startRow:c,xSplit:m,ySplit:h}=g,p={left:!0,top:!0};if(!d)return{...i,absolute:p};const{left:S,right:f,top:v,bottom:_}=i;let{top:D,left:R,viewportScrollX:y,viewportScrollY:T}=d;const{boundsOfViewArea:I,scrollDirectionResponse:N}=n||{},{rowHeaderWidth:O,columnHeaderHeight:k}=e,W={top:o?0:k,left:o?0:O};I&&(l.Tools.isDefine(W.top)&&(W.top=I.top),l.Tools.isDefine(W.left)&&(W.left=I.left)),N==="HORIZONTAL"&&(T=0),N==="VERTICAL"&&(y=0);let P=0,E=0;const $=e.rowStartY(c-h)+k,G=e.colStartX(u-m)+O,Q=e.rowStartY(c)+k,ne=e.colStartX(u)+O;if(m===0)p.left=!1,P=(S-y)*s,E=(f-y)*s;else{const z=S-(G-O),ee=f-(G-O);f<ne?(P=z*s,E=ee*s):S<=ne&&f>=ne?(P=z*s,E=Math.max(R,(f-y)*s)):S>ne&&(p.left=!1,P=Math.max((S-y)*s,R),E=Math.max((f-y)*s,R))}let K=0,Z=0;if(h===0)p.top=!1,K=(v-T)*a,Z=(_-T)*a;else{const z=v-($-k),ee=_-($-k);_<Q?(K=z*a,Z=ee*a):v<=Q&&_>=Q?(K=z*a,Z=Math.max(D,(_-T)*a)):v>Q&&(p.top=!1,K=Math.max((v-T)*a,D),Z=Math.max((_-T)*a,D))}return P=Math.max(P,W.left),K=Math.max(K,W.top),E=Math.max(E,W.left),Z=Math.max(Z,W.top),{left:P,right:E,top:K,bottom:Z,absolute:p}}const ae=(i,r,e,t,n)=>{const{left:o,top:s,width:a,height:d,angle:g}=i,u={left:o,right:o+a,top:s,bottom:s+d},c=Ft(u,r,e,t,n),{scaleX:m,scaleY:h}=r.getAncestorScale();return{startX:c.left,endX:c.right,startY:c.top,endY:c.bottom,rotate:g,width:a*m,height:d*h,absolute:c.absolute}};M.SheetCanvasFloatDomManagerService=class extends l.Disposable{constructor(e,t,n,o,s,a,d){super();ie(this,"_domLayerInfoMap",new Map);ie(this,"_transformChange$",new U.Subject);ie(this,"transformChange$",this._transformChange$.asObservable());ie(this,"_add$",new U.Subject);ie(this,"add$",this._add$.asObservable());ie(this,"_remove$",new U.Subject);ie(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=d,this._drawingAddListener(),this._featureUpdateListener(),this._deleteListener(),this._bindScrollEvent()}_bindScrollEvent(){this._lifecycleService.lifecycle$.pipe(U.filter(e=>e===l.LifecycleStages.Rendered),U.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 ee;const{unitId:n,subUnitId:o,drawingId:s}=t,a=C.getSheetCommandTarget(this._univerInstanceService,{unitId:n,subUnitId:o}),d=this._drawingManagerService.getDrawingByParam(t),g=this._univerInstanceService.getUnit(n,l.UniverInstanceType.UNIVER_SHEET);if(!g)return;const u=g.getActiveSheet().getSheetId();if(!d||!a)return;const c=(ee=this._renderManagerService.getRenderById(n))==null?void 0:ee.with(b.SheetSkeletonManagerService).getSkeletonParam(o);if(!c)return;const{transform:m,drawingType:h,data:p}=d;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:_,top:D,width:R,height:y,angle:T,flipX:I,flipY:N,skewX:O,skewY:k}=m,W=B.getDrawingShapeKeyByDrawingSearch({unitId:n,subUnitId:o,drawingId:s}),P=f.getObject(W);if(P!=null){P.transformByState({left:_,top:D,width:R,height:y,angle:T,flipX:I,flipY:N,skewX:O,skewY:k});return}const E={left:_,top:D,width:R,height:y,zIndex:this._drawingManagerService.getDrawingOrder(n,o).length-1},$=h===l.DrawingTypeEnum.DRAWING_CHART;if(E.rotateEnabled=!1,$){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 G=new A.Rect(W,E);$&&G.setObjectType(A.ObjectType.CHART),f.addObject(G,A.DRAWING_OBJECT_LAYER_INDEX),d.allowTransform!==!1&&f.attachTransformerTo(G);const Q=new l.DisposableCollection,ne=ae(G,S.renderUnit.scene,c.skeleton,a.worksheet),K=new U.BehaviorSubject(ne),Z=`${$t}${l.generateRandomId(6)}`,oe={dispose:Q,rect:G,position$:K,unitId:n,subUnitId:o,id:s,domId:Z};this._canvasFloatDomService.addFloatDom({position$:K,id:s,domId:Z,componentKey:d.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 z=G.onTransformChange$.subscribeEvent(()=>{const X=ae(G,S.renderUnit.scene,c.skeleton,a.worksheet);K.next(X)});Q.add(()=>{this._canvasFloatDomService.removeFloatDom(s)}),z&&Q.add(z),this._domLayerInfoMap.set(s,oe)})})),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}),d=this._getSceneAndTransformerByDrawingSearch(n);if(d==null)return;const{transformer:g,scene:u}=d,c=u.getObject(a);c!=null&&c.oKey&&(g.clearControlByIds([c==null?void 0:c.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=C.getSheetCommandTarget(this._univerInstanceService,{unitId:t,subUnitId:n}),d=(g=this._renderManagerService.getRenderById(t))==null?void 0:g.with(b.SheetSkeletonManagerService).getSkeletonParam(n);!o||!a||!d||s.forEach(u=>{const c=this._domLayerInfoMap.get(u);if(c){const m=ae(c.rect,o.renderUnit.scene,d.skeleton,a.worksheet,c);c.position$.next(m)}})};this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(l.UniverInstanceType.UNIVER_SHEET).pipe(U.switchMap(t=>t?t.activeSheet$:U.of(null)),U.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}),U.switchMap(t=>t?l.fromEventSubject(t.render.scene.getViewport(A.SHEET_VIEWPORT_KEY.VIEW_MAIN).onScrollAfter$).pipe(U.map(()=>({unitId:t.unitId,subUnitId:t.subUnitId}))):U.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===b.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===C.SetFrozenMutation.id){const{unitId:n,subUnitId:o}=t.params;e(n,o)}else if(t.id===C.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:d}=a,g=B.getDrawingShapeKeyByDrawingSearch({unitId:e,subUnitId:t,drawingId:n}),u=d.getObject(g);u&&u instanceof A.Rect&&u.setProps(o)}}_getPosition(e,t){var h;const{startX:n,endX:o,startY:s,endY:a}=e,d=(h=this._renderManagerService.getRenderById(t))==null?void 0:h.with(b.ISheetSelectionRenderService);if(d==null)return;const g=d.getCellWithCoordByOffset(n,s);if(g==null)return;const u={column:g.actualColumn,columnOffset:n-g.startX,row:g.actualRow,rowOffset:s-g.startY},c=d.getCellWithCoordByOffset(o,a);if(c==null)return;const m={column:c.actualColumn,columnOffset:o-c.startX,row:c.actualRow,rowOffset:a-c.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,d=this._domLayerInfoMap.get(t.drawingId);d!=null&&d.rect&&(n.allowTransform===!1?a.detachTransformerFrom(d.rect):a.attachTransformerTo(d.rect))}})}))}_deleteListener(){this.disposeWithMe(this._drawingManagerService.remove$.subscribe(e=>{e.forEach(t=>{this._removeDom(t.drawingId)})}))}addFloatDomToPosition(e,t){const n=C.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:d,data:g,allowTransform:u=!0}=e,c=t!=null?t:l.generateRandomId(),m=this._getPosition(a,o);if(m==null)return;const h={unitId:o,subUnitId:s,drawingId:c,drawingType:e.type||l.DrawingTypeEnum.DRAWING_DOM,componentKey:d,sheetTransform:m,transform:{left:a.startX,top:a.startY,width:a.endX-a.startX,height:a.endY-a.startY},data:g,allowTransform:u};return this._commandService.executeCommand(Ee.id,{unitId:o,drawings:[h]}),this._add$.next({unitId:o,subUnitId:s,id:c}),{id:c,dispose:()=>{this._removeDom(c,!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 d=this._drawingManagerService.getDrawingByParam({unitId:o,subUnitId:s,drawingId:e});if(!d)return;const g=this._sheetDrawingService.getBatchRemoveOp([d]),{redo:u,objects:c}=g;this._commandService.syncExecuteCommand(w.SetDrawingApplyMutation.id,{unitId:o,subUnitId:s,op:u,objects:c,type:w.DrawingApplyType.REMOVE})}}addFloatDomToRange(e,t,n,o){var I,N,O;const s=C.getSheetCommandTarget(this._univerInstanceService,{unitId:t.unitId,subUnitId:t.subUnitId});if(!s)throw new Error("cannot find current target!");const{unitId:a,subUnitId:d}=s,g=this._getSceneAndTransformerByDrawingSearch(a);if(!g)return;const u=this._renderManagerService.getRenderById(a);if(!u)return;const c=(I=this._renderManagerService.getRenderById(a))==null?void 0:I.with(b.SheetSkeletonManagerService).getWorksheetSkeleton(d);if(!c)return;const{componentKey:m,data:h,allowTransform:p=!0}=t,S=o!=null?o:l.generateRandomId(),{position:f,position$:v}=this._createRangePositionObserver(e,u,c.skeleton);if(this._getPosition(f,a)==null)return;const D=g.scene,{scaleX:R}=D.getAncestorScale(),y=qe(f,n,R),T={unitId:a,subUnitId:d,drawingId:S,drawingType:t.type||l.DrawingTypeEnum.DRAWING_DOM,componentKey:m,transform:{left:y.startX,top:y.startY,width:y.width,height:y.height},data:h,allowTransform:p};{const{unitId:k,subUnitId:W,drawingId:P}=T,E=C.getSheetCommandTarget(this._univerInstanceService,{unitId:k,subUnitId:W}),$=T,G=this._univerInstanceService.getUnit(k,l.UniverInstanceType.UNIVER_SHEET);if(!G)return;const Q=G.getActiveSheet().getSheetId();if(!$||!E)return;const ne=(N=this._renderManagerService.getRenderById(k))==null?void 0:N.with(b.SheetSkeletonManagerService);if(!ne)return;const K=ne.getWorksheetSkeleton(W);if(!K)return;const{transform:Z,drawingType:oe,data:z}=$;if(oe!==l.DrawingTypeEnum.DRAWING_DOM&&oe!==l.DrawingTypeEnum.DRAWING_CHART)return;const ee=this._getSceneAndTransformerByDrawingSearch(k);if(ee==null)return;const{scene:X,canvas:ye}=ee;if(Z==null||Q!==W)return;const{left:et,top:tt,width:nt,height:rt,angle:Rt,flipX:Et,flipY:it,skewX:ot,skewY:De}=Z,st=B.getDrawingShapeKeyByDrawingSearch({unitId:k,subUnitId:W,drawingId:P}),ce=X.getObject(st);if(ce!=null){ce.transformByState({left:et,top:tt,width:nt,height:rt,angle:Rt,flipX:Et,flipY:it,skewX:ot,skewY:De});return}const re={left:et,top:tt,width:nt,height:rt,zIndex:this._drawingManagerService.getDrawingOrder(k,W).length-1},Te=oe===l.DrawingTypeEnum.DRAWING_CHART;if(Te){const L=z?z.backgroundColor:"white";re.fill=L,re.rotateEnabled=!1,z&&z.border&&(re.stroke=z.border),re.paintFirst="stroke",re.strokeWidth=1,re.borderEnabled=!1,re.radius=8}const de=new A.Rect(st,re);Te&&de.setObjectType(A.ObjectType.CHART),X.addObject(de,A.DRAWING_OBJECT_LAYER_INDEX),$.allowTransform!==!1&&X.attachTransformerTo(de);const le=new l.DisposableCollection,at=X.getMainViewport(),{rowHeaderWidth:Me,columnHeaderHeight:We}=K.skeleton,ct={top:We,left:Me,bottom:at.bottom,right:at.right},ue={dispose:le,rect:de,boundsOfViewArea:ct,domAnchor:n,unitId:k,subUnitId:W},x=ae(de,ee.renderUnit.scene,K.skeleton,E.worksheet,ue),Re=new U.BehaviorSubject(x);ue.position$=Re;let Be={position$:Re,id:P,componentKey:$.componentKey,onPointerDown:()=>{},onPointerMove:()=>{},onPointerUp:()=>{},onWheel:L=>{ye.dispatchEvent(new WheelEvent(L.type,L))},data:z,unitId:k};t.eventPassThrough&&(Be={...Be,onPointerDown:L=>{ye.dispatchEvent(new PointerEvent(L.type,L))},onPointerMove:L=>{ye.dispatchEvent(new PointerEvent(L.type,L))},onPointerUp:L=>{ye.dispatchEvent(new PointerEvent(L.type,L))}}),this._canvasFloatDomService.addFloatDom(Be),this.disposeWithMe(v.subscribe(L=>{var Ht,Vt,Xt,xt;const Gt=qe({startX:L.startX,startY:L.startY,endX:L.endX,endY:L.endY,width:(Ht=n.width)!=null?Ht:L.width,height:(Vt=n.height)!=null?Vt:L.height,absolute:{left:f.absolute.left,top:f.absolute.top}},n),er=B.getDrawingShapeKeyByDrawingSearch({unitId:k,subUnitId:W,drawingId:P}),tr=new A.Rect(er,{left:Gt.startX,top:Gt.startY,width:(Xt=n.width)!=null?Xt:L.width,height:(xt=n.height)!=null?xt:L.height,zIndex:this._drawingManagerService.getDrawingOrder(k,W).length-1}),nr=ae(tr,ee.renderUnit.scene,K.skeleton,E.worksheet,ue);Re.next(nr)}));const je=(O=this._renderManagerService.getRenderById(k))==null?void 0:O.with(b.SheetSkeletonManagerService);je==null||je.currentSkeleton$.subscribe(L=>{L&&K.sheetId!==L.sheetId&&this._removeDom(S,!0)});const dt=de.onTransformChange$.subscribeEvent(()=>{const L=ae(de,ee.renderUnit.scene,K.skeleton,E.worksheet,ue);Re.next(L)});le.add(()=>{this._canvasFloatDomService.removeFloatDom(P)}),dt&&le.add(dt),this._domLayerInfoMap.set(P,ue)}return{id:S,dispose:()=>{this._removeDom(S,!0)}}}addFloatDomToColumnHeader(e,t,n,o){var y,T,I;const s=C.getSheetCommandTarget(this._univerInstanceService,{unitId:t.unitId,subUnitId:t.subUnitId});if(!s)throw new Error("cannot find current target!");const{unitId:a,subUnitId:d}=s;if(!this._getSceneAndTransformerByDrawingSearch(a))return;const u=this._renderManagerService.getRenderById(a);if(!u)return;const c=(y=this._renderManagerService.getRenderById(a))==null?void 0:y.with(b.SheetSkeletonManagerService).getWorksheetSkeleton(d);if(!c)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,c.skeleton),_=f;if(_.startY=0,this._getPosition(f,a)==null)return;const R={unitId:a,subUnitId:d,drawingId:S,drawingType:t.type||l.DrawingTypeEnum.DRAWING_DOM,componentKey:m,transform:{left:_.startX,top:_.startY,width:_.width,height:_.height},data:h,allowTransform:p};{const{unitId:N,subUnitId:O,drawingId:k}=R,W=C.getSheetCommandTarget(this._univerInstanceService,{unitId:N,subUnitId:O}),P=R,E=this._univerInstanceService.getUnit(N,l.UniverInstanceType.UNIVER_SHEET);if(!E)return;const $=E.getActiveSheet().getSheetId();if(!P||!W)return;const G=(T=this._renderManagerService.getRenderById(N))==null?void 0:T.with(b.SheetSkeletonManagerService);if(!G)return;const Q=G.getWorksheetSkeleton(O);if(!Q)return;const{transform:ne,data:K}=P,Z=this._getSceneAndTransformerByDrawingSearch(N);if(Z==null)return;const{scene:oe,canvas:z}=Z;if(ne==null||$!==O)return;const{left:ee,top:X,width:ye,height:et,angle:tt,flipX:nt,flipY:rt,skewX:Rt,skewY:Et}=ne,it=B.getDrawingShapeKeyByDrawingSearch({unitId:N,subUnitId:O,drawingId:k}),ot=oe.getObject(it);if(ot!=null){ot.transformByState({left:ee,top:X,width:ye,height:et,angle:tt,flipX:nt,flipY:rt,skewX:Rt,skewY:Et});return}const De=qe({startX:_.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),st={left:De.startX,top:De.startY,width:De.width,height:De.height,zIndex:this._drawingManagerService.getDrawingOrder(N,O).length-1},ce=new A.Rect(it,st);oe.addObject(ce,A.DRAWING_OBJECT_LAYER_INDEX),P.allowTransform!==!1&&oe.attachTransformerTo(ce);const re=new l.DisposableCollection,Te=oe.getMainViewport(),de={top:0,left:Te.left,bottom:Te.bottom,right:Te.right},le={dispose:re,rect:ce,unitId:N,subUnitId:O,boundsOfViewArea:de,domAnchor:n,scrollDirectionResponse:"HORIZONTAL"},at=ae(ce,Z.renderUnit.scene,Q.skeleton,W.worksheet,le),Me=new U.BehaviorSubject(at);le.position$=Me;let We={position$:Me,id:k,componentKey:P.componentKey,onPointerDown:()=>{},onPointerMove:()=>{},onPointerUp:()=>{},onWheel:x=>{z.dispatchEvent(new WheelEvent(x.type,x))},data:K,unitId:N};t.eventPassThrough&&(We={...We,onPointerDown:x=>{z.dispatchEvent(new PointerEvent(x.type,x))},onPointerMove:x=>{z.dispatchEvent(new PointerEvent(x.type,x))},onPointerUp:x=>{z.dispatchEvent(new PointerEvent(x.type,x))}}),this._canvasFloatDomService.addFloatDom(We);const ct=ce.onTransformChange$.subscribeEvent(()=>{const x=ae(ce,Z.renderUnit.scene,Q.skeleton,W.worksheet,le);Me.next(x)});this.disposeWithMe(v.subscribe(x=>{const Re=qe({startX:x.startX,startY:0,endX:x.endX,endY:x.endY,width:n.width,height:n.height,absolute:{left:f.absolute.left,top:f.absolute.top}},n),Be=B.getDrawingShapeKeyByDrawingSearch({unitId:N,subUnitId:O,drawingId:k}),je=new A.Rect(Be,{left:Re.startX,top:0,width:n.width,height:n.height,zIndex:this._drawingManagerService.getDrawingOrder(N,O).length-1}),dt=ae(je,Z.renderUnit.scene,Q.skeleton,W.worksheet,le);Me.next(dt)}));const ue=(I=this._renderManagerService.getRenderById(N))==null?void 0:I.with(b.SheetSkeletonManagerService);ue==null||ue.currentSkeleton$.subscribe(x=>{x&&c.sheetId!==x.sheetId&&this._removeDom(S,!0)}),re.add(()=>{this._canvasFloatDomService.removeFloatDom(k)}),ct&&re.add(ct),this._domLayerInfoMap.set(k,le)}return{id:S,dispose:()=>{this._removeDom(S,!0)}}}_createRangePositionObserver(e,t,n){let{startRow:o,startColumn:s}=e;const a=Ne(o,s,n),d=new U.BehaviorSubject(a),g=Ne(e.endRow,e.endColumn,n),u=new U.BehaviorSubject(g),c=()=>{const v=Ne(o,s,n),_=Ne(e.endRow,e.endColumn,n);d.next(v),u.next(_)},m=new l.DisposableCollection;m.add(t.engine.clientRect$.subscribe(()=>c())),m.add(this._commandService.onCommandExecuted(v=>{if(v.id===C.SetWorksheetRowAutoHeightMutation.id&&v.params.rowsAutoHeightInfo.findIndex(D=>D.row===o)>-1){c();return}(C.COMMAND_LISTENER_SKELETON_CHANGE.indexOf(v.id)>-1||v.id===b.SetScrollOperation.id||v.id===b.SetZoomRatioOperation.id)&&c()}));const h=(v,_)=>{o=v,s=_,c()},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=d.pipe(U.map(v=>{const _=Ne(e.endRow,e.endColumn,n);return{rotate:0,width:_.right-v.left,height:_.bottom-v.top,absolute:{left:!0,top:!0},startX:v.left,startY:v.top,endX:_.right,endY:_.bottom}})),f=p();return{position$:S,position:f,updateRowCol:h,topLeftPos$:d,rightBottomPos$:u,disposable:m}}},M.SheetCanvasFloatDomManagerService=Tn([pe(0,l.Inject(A.IRenderManagerService)),pe(1,l.IUniverInstanceService),pe(2,l.Inject(l.ICommandService)),pe(3,B.IDrawingManagerService),pe(4,l.Inject(j.CanvasFloatDomService)),pe(5,w.ISheetDrawingService),pe(6,l.Inject(l.LifecycleService))],M.SheetCanvasFloatDomManagerService);function Ne(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 qe(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,d=0;if(r){if(r.horizonOffsetAlign==="right"){const c=Ze(r.marginX,t*e);a=i.endX-c-o}else a=i.startX+Ze(r.marginX,t);if(r.verticalOffsetAlign==="bottom"){const c=Ze(r.marginY,n*e);d=i.endY-c-s}else d=i.startY+Ze(r.marginY,n)}return{rotate:0,startX:a,startY:d,endX:i.endX,endY:i.endY,width:o,height:s,absolute:{left:i.absolute.left,top:i.absolute.top}}}function Ze(i,r){if(i===void 0)return 0;if(typeof i=="number")return i;const e=Number.parseFloat(i);return r*e/100}const Mn=i=>{const{floatDomInfos:r,scene:e,skeleton:t,worksheet:n}=i,o=q.useMemo(()=>r.map(s=>{const{width:a,height:d,angle:g,left:u,top:c}=s.transform,m=Ft({left:u!=null?u:0,right:(u!=null?u:0)+(a!=null?a:0),top:c!=null?c:0,bottom:(c!=null?c:0)+(d!=null?d: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:d*p,absolute:m.absolute},f={position$:new U.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 F.jsx("div",{style:{position:"absolute",top:0,left:0},children:o.map(([s,a])=>F.jsx(j.PrintFloatDomSingle,{layer:a,id:s,position:a.position},s))})};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},fe=(i,r)=>(e,t)=>r(e,t,i);let Je=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(d=>{const g=a.data[d];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(b.SheetSkeletonManagerService).getSkeletonParam(n);if(!s)return e(i);const a=this._drawingManagerService.getDrawingDataForUnit(t),d=a==null?void 0:a[r.subUnitId];if(!d)return e(i);const{scaleX:g,scaleY:u}=o.scene,c=i?{...i}:{startColumn:0,endColumn:0,endRow:0,startRow:0},m=d.order.map(h=>d.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<c.startColumn&&(c.startColumn=p.column),p.row<c.startRow&&(c.startRow=p.row),c.endRow<S.row&&(c.endRow=S.row),c.endColumn<S.column&&(c.endColumn=S.column)}}),e(c)):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 c=this._sheetPrintInterceptorService.getPrintComponent(u.componentKey);return{...u,componentKey:this._componetManager.get(c||u.componentKey)}}return null}).filter(Boolean),d=j.connectInjector(Mn,this._injector);return Y.render(F.jsx(d,{floatDomInfos:a,scene:r.scene,skeleton:r.skeleton,worksheet:r.worksheet}),r.root),i==null||i.add(()=>{Y.unmount(r.root)}),e(i)}}}))}};Je=En([fe(0,l.Inject(b.SheetPrintInterceptorService)),fe(1,l.Inject(ge.DrawingRenderService)),fe(2,B.IDrawingManagerService),fe(3,A.IRenderManagerService),fe(4,l.Inject(M.SheetCanvasFloatDomManagerService)),fe(5,l.Inject(j.ComponentManager)),fe(6,l.Inject(l.Injector))],Je);var bn=Object.getOwnPropertyDescriptor,On=(i,r,e,t)=>{for(var n=t>1?void 0:t?bn(r,e):r,o=i.length-1,s;o>=0;o--)(s=i[o])&&(n=s(n)||n);return n},me=(i,r)=>(e,t)=>r(e,t,i);const An=[C.InsertRowCommand.id,C.InsertColCommand.id,C.RemoveRowCommand.id,C.RemoveColCommand.id,C.DeleteRangeMoveLeftCommand.id,C.DeleteRangeMoveUpCommand.id,C.InsertRangeMoveDownCommand.id,C.InsertRangeMoveRightCommand.id,C.DeltaRowHeightCommand.id,C.SetRowHeightCommand.id,C.DeltaColumnWidthCommand.id,C.SetColWidthCommand.id,C.SetRowHiddenCommand.id,C.SetSpecificRowsVisibleCommand.id,C.SetSpecificColsVisibleCommand.id,C.SetColHiddenCommand.id,C.MoveColsCommand.id,C.MoveRowsCommand.id,C.MoveRangeCommand.id],Un=[C.SetRowVisibleMutation.id,C.SetRowHiddenMutation.id,C.SetColVisibleMutation.id,C.SetColHiddenMutation.id,C.SetWorksheetRowHeightMutation.id,C.SetWorksheetRowAutoHeightMutation.id,C.SetWorksheetRowIsAutoHeightMutation.id,C.SetWorksheetColWidthMutation.id];let yt=class extends l.Disposable{constructor(i,r,e,t,n,o,s,a,d){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=d,this._sheetInterceptorListener(),this._commandListener(),this._sheetRefreshListener()}_sheetInterceptorListener(){this.disposeWithMe(this._sheetInterceptorService.interceptAfterCommand({getMutations:i=>{if(!An.includes(i.id))return{redos:[],undos:[]};if(i.params==null)return{redos:[],undos:[]};const r=i.id;if(r===C.InsertRowCommand.id)return this._moveRowInterceptor(i.params,"insert");if([C.MoveColsCommand.id,C.MoveRowsCommand.id,C.MoveRangeCommand.id].includes(r))return this._moveRangeInterceptor(i.params);if(r===C.InsertColCommand.id)return this._moveColInterceptor(i.params,"insert");if(r===C.RemoveRowCommand.id)return this._moveRowInterceptor(i.params,"remove");if(r===C.RemoveColCommand.id)return this._moveColInterceptor(i.params,"remove");if(r===C.DeleteRangeMoveLeftCommand.id){const{range:e}=i.params;return this._getRangeMoveUndo(e,0)}else if(r===C.DeleteRangeMoveUpCommand.id){const{range:e}=i.params;return this._getRangeMoveUndo(e,1)}else if(r===C.InsertRangeMoveDownCommand.id){const{range:e}=i.params;return this._getRangeMoveUndo(e,2)}else if(r===C.InsertRangeMoveRightCommand.id){const{range:e}=i.params;return this._getRangeMoveUndo(e,3)}else if(r===C.SetRowHiddenCommand.id||r===C.SetSpecificRowsVisibleCommand.id){const e=i.params,{unitId:t,subUnitId:n,ranges:o}=e;return this._getDrawingUndoForRowVisible(t,n,o)}else if(r===C.SetSpecificColsVisibleCommand.id||r===C.SetColHiddenCommand.id){const e=i.params,{unitId:t,subUnitId:n,ranges:o}=e;return this._getDrawingUndoForColVisible(t,n,o)}else if(r===C.DeltaRowHeightCommand.id||r===C.SetRowHeightCommand.id||r===C.DeltaColumnWidthCommand.id||r===C.SetColWidthCommand.id){const e=i.params,{unitId:t,subUnitId:n,ranges:o}=e,s=r===C.DeltaRowHeightCommand.id||r===C.SetRowHeightCommand.id;return this._getDrawingUndoForRowAndColSize(t,n,o,s)}return{redos:[],undos:[]}}}))}_getRangeMoveUndo(i,r){const e=C.getSheetCommandTarget(this._univerInstanceService);if(e==null)return{redos:[],undos:[]};const t=e.unitId,n=e.subUnitId,o=[],s=[],a=this._sheetDrawingService.getDrawingData(t,n),d=[],g=[];if(Object.keys(a).forEach(u=>{const c=a[u],{updateDrawings:m,deleteDrawings:h}=this._getUpdateOrDeleteDrawings(i,r,c);d.push(...m),g.push(...h)}),d.length===0&&g.length===0)return{redos:[],undos:[]};if(d.length>0){const u=this._sheetDrawingService.getBatchUpdateOp(d),{undo:c,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:c,objects:h,type:w.DrawingApplyType.UPDATE}})}if(g.length>0){const u=this._sheetDrawingService.getBatchRemoveOp(g),c=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:c,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){const t=[],n=[],{sheetTransform:o,anchorType:s=w.SheetDrawingAnchorType.Position,transform:a,unitId:d,subUnitId:g,drawingId:u}=e,{from:c,to:m}=o,{row:h,column:p}=c,{row:S,column:f}=m;if(o==null||a==null)return{updateDrawings:t,deleteDrawings:n};const{startRow:v,endRow:_,startColumn:D,endColumn:R}=i;let y=null,T=null;if(r===0&&h>=v&&S<=_)if(p>=D&&f<=R)n.push({unitId:d,subUnitId:g,drawingId:u});else{const I=this._shrinkCol(o,a,D,R,s);y=I==null?void 0:I.newSheetTransform,T=I==null?void 0:I.newTransform}else if(r===1&&p>=D&&f<=R)if(h>=v&&S<=_)n.push({unitId:d,subUnitId:g,drawingId:u});else{const I=this._shrinkRow(o,a,v,_,s);y=I==null?void 0:I.newSheetTransform,T=I==null?void 0:I.newTransform}else if(r===2){const I=this._expandRow(o,a,v,_,s);y=I==null?void 0:I.newSheetTransform,T=I==null?void 0:I.newTransform}else if(r===3){const I=this._expandCol(o,a,D,R,s);y=I==null?void 0:I.newSheetTransform,T=I==null?void 0:I.newTransform}if(y!=null&&T!=null){const I=J(y,this._selectionRenderService,this._skeletonManagerService);t.push({...e,sheetTransform:y,transform:I})}return{updateDrawings:t,deleteDrawings:n}}_remainDrawingSize(i,r,e){const t=H({...i},this._selectionRenderService);t!=null&&r.push({...e,sheetTransform:t})}_getDrawingUndoForColVisible(i,r,e){const t=this._drawingManagerService.getDrawingData(i,r),n=[],o=[];if(Object.keys(t).forEach(u=>{const c=t[u],{sheetTransform:m,transform:h,anchorType:p=w.SheetDrawingAnchorType.Position}=c;if(p===w.SheetDrawingAnchorType.None)this._remainDrawingSize(h,n,c);else{const{from:S,to:f}=m,{row:v,column:_}=S,{row:D,column:R}=f;for(let y=0;y<e.length;y++){const T=e[y],{startRow:I,endRow:N,startColumn:O,endColumn:k}=T;if(R<O)continue;if(p===w.SheetDrawingAnchorType.Position){let E=null,$=null;if(_>=O&&_<=k){const G=this._skeletonManagerService.attachRangeWithCoord({startColumn:_,endColumn:k,startRow:S.row,endRow:f.row});if(G==null)return;$={...h,left:G.startX}}if($!=null&&(E=H($,this._selectionRenderService),E!=null&&$!=null)){n.push({...c,sheetTransform:E,transform:$});break}this._remainDrawingSize(h,n,c);continue}if(_>=O&&R<=k)continue;let W=null,P=null;if(_>=O&&_<=k){const E=this._skeletonManagerService.attachRangeWithCoord({startColumn:_,endColumn:k,startRow:S.row,endRow:f.row});if(E==null)return;P={...h,left:(E==null?void 0:E.startX)||0,width:((h==null?void 0:h.width)||0)-E.endX+E.startX}}else if(R>=O&&R<=k){const E=this._skeletonManagerService.attachRangeWithCoord({startColumn:O,endColumn:R,startRow:S.row,endRow:f.row});if(E==null)return;P={...h,left:E.startX-((h==null?void 0:h.width)||0)}}else{const E=this._skeletonManagerService.attachRangeWithCoord({startColumn:O,endColumn:k,startRow:S.row,endRow:f.row});if(E==null)return;if(P={...h,width:((h==null?void 0:h.width)||0)-E.endX+E.startX},W=H(P,this._selectionRenderService),W!=null&&P!=null){o.push({...c,sheetTransform:W,transform:P});break}}if(P!=null&&(W=H(P,this._selectionRenderService)),P!=null&&W!=null){n.push({...c,sheetTransform:W,transform:P});break}else this._remainDrawingSize(h,n,c)}}}),n.length===0&&o.length===0)return{redos:[],undos:[]};const{redos:s,undos:a}=this._createUndoAndRedoMutation(i,r,n),d=[],g=[];if(o.length>0){const{redos:u,undos:c}=this._createUndoAndRedoMutation(i,r,o);d.push(...u),g.push(...c)}return{redos:s,undos:a,preRedos:d,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]}],d=[{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:d}}_getDrawingUndoForRowVisible(i,r,e){const t=this._drawingManagerService.getDrawingData(i,r),n=[],o=[];if(Object.keys(t).forEach(u=>{const c=t[u],{sheetTransform:m,transform:h,anchorType:p=w.SheetDrawingAnchorType.Position}=c;if(p===w.SheetDrawingAnchorType.None)this._remainDrawingSize(h,n,c);else{const{from:S,to:f}=m,{row:v,column:_}=S,{row:D,column:R}=f;for(let y=0;y<e.length;y++){const T=e[y],{startRow:I,endRow:N,startColumn:O,endColumn:k}=T;if(D<I)continue;if(p===w.SheetDrawingAnchorType.Position){let E=null,$=null;if(v>=I&&v<=N){const G=this._skeletonManagerService.attachRangeWithCoord({startColumn:S.column,endColumn:f.column,startRow:v,endRow:N});if(G==null)return;$={...h,top:G.startY}}if($!=null&&(E=H($,this._selectionRenderService),E!=null&&$!=null)){n.push({...c,sheetTransform:E,transform:$});break}this._remainDrawingSize(h,n,c);continue}if(v>=I&&D<=N)continue;let W=null,P=null;if(v>=I&&v<=N){const E=this._skeletonManagerService.attachRangeWithCoord({startColumn:S.column,endColumn:f.column,startRow:v,endRow:N});if(E==null)return;P={...h,top:(E==null?void 0:E.startY)||0,height:((h==null?void 0:h.height)||0)-E.endY+E.startY}}else if(D>=I&&D<=N){const E=this._skeletonManagerService.attachRangeWithCoord({startColumn:S.column,endColumn:f.column,startRow:I,endRow:D});if(E==null)return;P={...h,top:E.startY-((h==null?void 0:h.height)||0)}}else{const E=this._skeletonManagerService.attachRangeWithCoord({startColumn:S.column,endColumn:f.column,startRow:I,endRow:N});if(E==null)return;if(P={...h,height:((h==null?void 0:h.height)||0)-E.endY+E.startY},W=H(P,this._selectionRenderService),W!=null&&P!=null){o.push({...c,sheetTransform:W,transform:P});break}}if(P!=null&&(W=H(P,this._selectionRenderService)),P!=null&&W!=null){n.push({...c,sheetTransform:W,transform:P});break}else this._remainDrawingSize(h,n,c)}}}),n.length===0&&o.length===0)return{redos:[],undos:[]};const{redos:s,undos:a}=this._createUndoAndRedoMutation(i,r,n),d=[],g=[];if(o.length>0){const{redos:u,undos:c}=this._createUndoAndRedoMutation(i,r,o);d.push(...u),g.push(...c)}return{redos:s,undos:a,preRedos:d,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:d,transform:g,anchorType:u=w.SheetDrawingAnchorType.Position}=a;if(u===w.SheetDrawingAnchorType.None)this._remainDrawingSize(g,o,a);else{const{from:c,to:m}=d,{row:h,column:p}=c,{row:S,column:f}=m;for(let v=0;v<e.length;v++){const _=e[v],{startRow:D,endRow:R,startColumn:y,endColumn:T}=_;if(S<D||f<y)continue;if(u===w.SheetDrawingAnchorType.Position&&(h<=D&&S>=R||p<=y&&f>=T)){this._remainDrawingSize(g,o,a);continue}const I=J({...d},this._selectionRenderService,this._skeletonManagerService);if(I!=null){o.push({...a,transform:I});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=C.getSheetCommandTarget(this._univerInstanceService);if(n==null)return;e=n.unitId,t=n.subUnitId}return{unitId:e,subUnitId:t}}_moveRangeInterceptor(i){var D,R;const{toRange:r,fromRange:e}=i,t=C.getSheetCommandTarget(this._univerInstanceService);if(!t)return{redos:[],undos:[]};const{unitId:n,subUnitId:o}=t,s=(R=(D=this._renderManagerService.getRenderById(n))==null?void 0:D.with(b.SheetSkeletonManagerService))==null?void 0:R.getCurrentSkeleton();if(!s)return{redos:[],undos:[]};const a=b.attachRangeWithCoord(s,e);if(!a)return{redos:[],undos:[]};const{startX:d,endX:g,startY:u,endY:c}=a,m=this._sheetDrawingService.getDrawingData(n,o),h=[];Object.keys(m).forEach(y=>{const T=m[y];if(T.anchorType!==w.SheetDrawingAnchorType.Both)return;const{transform:I}=T;if(!I)return;const{left:N=0,top:O=0,width:k=0,height:W=0}=I,{drawingStartX:P,drawingEndX:E,drawingStartY:$,drawingEndY:G}={drawingStartX:N,drawingEndX:N+k,drawingStartY:O,drawingEndY:O+W};d<=P&&E<=g&&u<=$&&G<=c&&h.push(T)});const p=[],S=[],f=r.startRow-e.startRow,v=r.startColumn-e.startColumn,_=h.map(y=>{const T=y.sheetTransform,I={to:{...T.to,row:T.to.row+f,column:T.to.column+v},from:{...T.from,row:T.from.row+f,column:T.from.column+v}},N=J(I,this._selectionRenderService,this._skeletonManagerService);return{unitId:n,subUnitId:o,drawingId:y.drawingId,transform:N,sheetTransform:I}});if(_.length){const y=this._sheetDrawingService.getBatchUpdateOp(_),{undo:T,redo:I,objects:N}=y;p.push({id:w.SetDrawingApplyMutation.id,params:{unitId:n,subUnitId:o,op:I,objects:N,type:w.DrawingApplyType.UPDATE}}),S.push({id:w.SetDrawingApplyMutation.id,params:{unitId:n,subUnitId:o,op:T,objects:N,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,d=[],g=[],u=this._sheetDrawingService.getDrawingData(t,n),c=[],m=[];if(Object.keys(u).forEach(h=>{const p=u[h],{sheetTransform:S,transform:f,anchorType:v=w.SheetDrawingAnchorType.Position}=p;if(S==null||f==null)return;let _,D;if(r==="insert"){const y=this._expandRow(S,f,s,a,v);_=y==null?void 0:y.newSheetTransform,D=y==null?void 0:y.newTransform}else{const{from:y,to:T}=S,{row:I}=y,{row:N}=T;if(v===w.SheetDrawingAnchorType.Both&&I>=s&&N<=a)m.push({unitId:t,subUnitId:n,drawingId:h});else{const O=this._shrinkRow(S,f,s,a,v);_=O==null?void 0:O.newSheetTransform,D=O==null?void 0:O.newTransform}}if(!_||!D)return;const R={unitId:t,subUnitId:n,drawingId:h,transform:D,sheetTransform:_};c.push(R)}),c.length===0&&m.length===0)return{redos:[],undos:[]};if(c.length>0){const h=this._sheetDrawingService.getBatchUpdateOp(c),{undo:p,redo:S,objects:f}=h;d.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;d.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 d.push({id:V.id,params:[t]}),g.push({id:V.id,params:[t]}),{redos:d,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,d=[],g=[],u=this._sheetDrawingService.getDrawingData(t,n),c=[],m=[];if(Object.keys(u).forEach(h=>{const p=u[h],{sheetTransform:S,transform:f,anchorType:v=w.SheetDrawingAnchorType.Position}=p;if(S==null||f==null)return;let _,D;if(r==="insert"){const y=this._expandCol(S,f,s,a,v);_=y==null?void 0:y.newSheetTransform,D=y==null?void 0:y.newTransform}else{const{from:y,to:T}=S,{column:I}=y,{column:N}=T;if(v===w.SheetDrawingAnchorType.Both&&I>=s&&N<=a)m.push({unitId:t,subUnitId:n,drawingId:h});else{const O=this._shrinkCol(S,f,s,a,v);_=O==null?void 0:O.newSheetTransform,D=O==null?void 0:O.newTransform}}if(!_||!D)return;const R={unitId:t,subUnitId:n,drawingId:h,transform:D,sheetTransform:_};c.push(R)}),c.length===0&&m.length===0)return{redos:[],undos:[]};if(c.length>0){const h=this._sheetDrawingService.getBatchUpdateOp(c),{undo:p,redo:S,objects:f}=h;d.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;d.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 d.push({id:V.id,params:[t]}),g.push({id:V.id,params:[t]}),{redos:d,undos:g}}_expandCol(i,r,e,t,n=w.SheetDrawingAnchorType.Position){const o=t-e+1,{from:s,to:a}=i,{column:d}=s,{column:g}=a;if(n===w.SheetDrawingAnchorType.None)return{newSheetTransform:H({...r},this._selectionRenderService),newTransform:r};let u=null,c=null;if(d>=e){const m=this._skeletonManagerService.attachRangeWithCoord({startColumn:e,endColumn:t,startRow:s.row,endRow:a.row});if(m==null)return;c={...r,left:(r.left||0)+m.endX-m.startX},u=H(c,this._selectionRenderService)}else if(g>=t)if(n===w.SheetDrawingAnchorType.Both)u={from:{...s},to:{...a,column:g+o}},c=J(u,this._selectionRenderService,this._skeletonManagerService);else return{newSheetTransform:H({...r},this._selectionRenderService),newTransform:r};return u!=null&&c!=null?{newSheetTransform:u,newTransform:c}:null}_shrinkCol(i,r,e,t,n=w.SheetDrawingAnchorType.Position){const o=t-e+1,{from:s,to:a}=i,{column:d}=s,{column:g}=a;if(n===w.SheetDrawingAnchorType.None)return{newSheetTransform:H({...r},this._selectionRenderService),newTransform:r};let u=null,c=null;if(d>t)u={from:{...s,column:d-o},to:{...a,column:g-o}},c=J(u,this._selectionRenderService,this._skeletonManagerService);else{if(d>=e&&g<=t)return null;if(d<e&&g>t)if(n===w.SheetDrawingAnchorType.Both)u={from:{...s},to:{...a,column:g-o}},c=J(u,this._selectionRenderService,this._skeletonManagerService);else return{newSheetTransform:H({...r},this._selectionRenderService),newTransform:r};else if(d>=e&&d<=t){if(d===e)c={...r,left:(r.left||0)-i.from.columnOffset};else{const m=this._skeletonManagerService.attachRangeWithCoord({startColumn:e,endColumn:d-1,startRow:s.row,endRow:a.row});if(m==null)return;c={...r,left:(r.left||0)-m.endX+m.startX-i.from.columnOffset}}u=H(c,this._selectionRenderService)}else if(g>=e&&g<=t&&n===w.SheetDrawingAnchorType.Both){const m=this._skeletonManagerService.attachRangeWithCoord({startColumn:e-1,endColumn:e-1,startRow:s.row,endRow:a.row});if(m==null)return;u={from:{...s},to:{...a,column:e-1,columnOffset:m.endX-m.startX}},c=J(u,this._selectionRenderService,this._skeletonManagerService)}}return u!=null&&c!=null?{newSheetTransform:u,newTransform:c}:null}_expandRow(i,r,e,t,n=w.SheetDrawingAnchorType.Position){const o=t-e+1,{from:s,to:a}=i,{row:d}=s,{row:g}=a;if(n===w.SheetDrawingAnchorType.None)return{newSheetTransform:H({...r},this._selectionRenderService),newTransform:r};let u=null,c=null;if(d>=e){const m=this._skeletonManagerService.attachRangeWithCoord({startRow:e,endRow:t,startColumn:s.column,endColumn:a.column});if(m==null)return;c={...r,top:(r.top||0)+m.endY-m.startY},u=H(c,this._selectionRenderService)}else if(g>=t)if(n===w.SheetDrawingAnchorType.Both)u={from:{...s},to:{...a,row:g+o}},c=J(u,this._selectionRenderService,this._skeletonManagerService);else return{newSheetTransform:H({...r},this._selectionRenderService),newTransform:r};return u!=null&&c!=null?{newSheetTransform:u,newTransform:c}:null}_shrinkRow(i,r,e,t,n=w.SheetDrawingAnchorType.Position){const o=t-e+1,{from:s,to:a}=i,{row:d}=s,{row:g}=a;if(n===w.SheetDrawingAnchorType.None)return{newSheetTransform:H({...r},this._selectionRenderService),newTransform:r};let u=null,c=null;if(d>t)u={from:{...s,row:d-o},to:{...a,row:g-o}},c=J(u,this._selectionRenderService,this._skeletonManagerService);else{if(d>=e&&g<=t)return null;if(d<e&&g>t)if(n===w.SheetDrawingAnchorType.Both)u={from:{...s},to:{...a,row:g-o}},c=J(u,this._selectionRenderService,this._skeletonManagerService);else return{newSheetTransform:H({...r},this._selectionRenderService),newTransform:r};else if(d>=e&&d<=t){if(d===e)c={...r,top:(r.top||0)-i.from.rowOffset};else{const m=this._skeletonManagerService.attachRangeWithCoord({startRow:e,endRow:d-1,startColumn:s.column,endColumn:a.column});if(m==null)return;c={...r,top:(r.top||0)-m.endY+m.startY-i.from.rowOffset}}u=H(c,this._selectionRenderService)}else if(g>=e&&g<=t&&n===w.SheetDrawingAnchorType.Both){const m=this._skeletonManagerService.attachRangeWithCoord({startColumn:s.column,endColumn:s.column,startRow:e-1,endRow:e-1});if(m==null)return;u={from:{...s},to:{...a,row:e-1,rowOffset:m.endY-m.startY}},c=J(u,this._selectionRenderService,this._skeletonManagerService)}}return u!=null&&c!=null?{newSheetTransform:u,newTransform:c}:null}_commandListener(){this.disposeWithMe(this._commandService.onCommandExecuted(i=>{if(i.id===C.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._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 d=s[a].data;d!=null&&Object.keys(d).forEach(g=>{if(o===i&&a===r){const u=d[g];u.transform=J(u.sheetTransform,this._selectionRenderService,this._skeletonManagerService),t.push(d[g])}else n.push(d[g])})})}),this._drawingManagerService.removeNotification(n),this._drawingManagerService.addNotification(t)},0)}_sheetRefreshListener(){this.disposeWithMe(this._commandService.onCommandExecuted(i=>{Un.includes(i.id)&&requestIdleCallback(()=>{const r=i.params,e=C.getSheetCommandTarget(this._univerInstanceService,r);if(!e)return;const{unitId:t,subUnitId:n,worksheet:o}=e;let s=[];"range"in r?s=r.range:"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:d,anchorType:g=w.SheetDrawingAnchorType.Position}=s;if(g===w.SheetDrawingAnchorType.None)return!0;const{from:u,to:c}=a,{row:m,column:h}=u,{row:p,column:S}=c;for(let f=0;f<e.length;f++){const v=e[f],{startRow:_,endRow:D,startColumn:R,endColumn:y}=v;if(l.Rectangle.intersects({startRow:_,endRow:D,startColumn:R,endColumn:y},{startRow:m,endRow:p,startColumn:h,endColumn:S})||m>D||h>y){const T=g===w.SheetDrawingAnchorType.Position,I=J(a,this._selectionRenderService,this._skeletonManagerService);n.push({...s,transform:{...I,width:T?d==null?void 0:d.width:I==null?void 0:I.width,height:T?d==null?void 0:d.height:I==null?void 0:I.height}});break}}}),n.length!==0&&(this._drawingManagerService.refreshTransform(n),this._commandService.syncExecuteCommand(V.id,[i]))}};yt=On([me(1,A.IRenderManagerService),me(2,l.ICommandService),me(3,b.ISheetSelectionRenderService),me(4,l.Inject(b.SheetSkeletonManagerService)),me(5,l.Inject(C.SheetInterceptorService)),me(6,w.ISheetDrawingService),me(7,B.IDrawingManagerService),me(8,l.IUniverInstanceService)],yt);function Pn(){const i=j.useDependency(l.LocaleService),r=j.useDependency(j.IDialogService),e=j.useDependency(Fe),[t,n]=q.useState([he.CELL_ADDRESS]),[o,s]=q.useState(!1),[a,d]=q.useState(null),g=q.useMemo(()=>e.getCellImagesInSelection(),[e]),u=q.useMemo(()=>e.getDataColumns(),[e]),c=q.useMemo(()=>e.getSelectionRowRange(),[e]),m=u.length>0,h=q.useMemo(()=>u.map(T=>({label:T.label,value:String(T.index)})),[u]),[p,S]=q.useState(()=>h.length>0?h[0].value:"0"),f=q.useMemo(()=>{if(!t.includes(he.COLUMN_VALUE)||!c)return[];const I=Number(p);return[{startRow:c.startRow,endRow:c.endRow,startColumn:I,endColumn:I}]},[t,p,c]);b.useHighlightRange(f);const v=q.useCallback(T=>{T.length!==0&&n(T)},[]),_=q.useCallback(T=>{S(String(T))},[]),D=q.useCallback(()=>{r.close(ve)},[r]),R=q.useCallback(async()=>{if(g.length!==0){s(!0),d(null);try{await e.saveImages(g,{fileNameParts:t,columnIndex:t.includes(he.COLUMN_VALUE)?Number(p):void 0}),r.close(ve)}catch(T){console.error("Failed to save images:",T),d(i.t("sheetImage.save.error"))}finally{s(!1)}}},[e,g,t,p,r,i]),y=t.includes(he.COLUMN_VALUE);return F.jsxs("div",{className:"univer-flex univer-flex-col",children:[F.jsx(Y.FormLayout,{label:i.t("sheetImage.save.imageCount"),children:F.jsx("div",{className:"univer-text-sm univer-text-gray-600",children:g.length})}),F.jsx(Y.FormLayout,{label:i.t("sheetImage.save.fileNameConfig"),children:F.jsxs(Y.CheckboxGroup,{value:t,onChange:v,direction:"vertical",children:[F.jsx(Y.Checkbox,{value:he.CELL_ADDRESS,disabled:!m,children:i.t("sheetImage.save.useRowCol")}),m&&F.jsx(Y.Checkbox,{value:he.COLUMN_VALUE,children:i.t("sheetImage.save.useColumnValue")})]})}),y&&F.jsx(Y.FormLayout,{label:i.t("sheetImage.save.selectColumn"),children:F.jsx(Y.Select,{value:p,options:h,onChange:_})}),a&&F.jsx("div",{className:"univer-text-xs univer-text-red-500",children:a}),F.jsxs("div",{className:"univer-flex univer-justify-end univer-gap-2 univer-border-t univer-border-gray-200 univer-pt-3",children:[F.jsx(Y.Button,{onClick:D,disabled:o,children:i.t("sheetImage.save.cancel")}),F.jsx(Y.Button,{variant:"primary",onClick:R,disabled:o||g.length===0,children:o?i.t("sheetImage.save.saving"):i.t("sheetImage.save.confirm")})]})]})}const Lt=i=>{var _;const r=j.useDependency(l.ICommandService),e=j.useDependency(l.LocaleService),t=j.useDependency(B.IDrawingManagerService),n=j.useDependency(A.IRenderManagerService),{drawings:o}=i,s=o[0];if(s==null)return;const{unitId:a}=s,d=n.getRenderById(a),g=d==null?void 0:d.scene;if(g==null)return;const u=g.getTransformerByCreate(),[c,m]=q.useState(!0),h=(_=s.anchorType)!=null?_:w.SheetDrawingAnchorType.Position,[p,S]=q.useState(h);function f(D,R){const y=[];return D.forEach(T=>{const{oKey:I}=T,N=R.getDrawingOKey(I);if(N==null)return y.push(null),!0;const{unitId:O,subUnitId:k,drawingId:W,drawingType:P,anchorType:E,sheetTransform:$}=N;y.push({unitId:O,subUnitId:k,drawingId:W,anchorType:E,sheetTransform:$,drawingType:P})}),y}q.useEffect(()=>{const D=u.clearControl$.subscribe(y=>{y===!0&&m(!1)}),R=u.changeStart$.subscribe(y=>{var N;const{objects:T}=y,I=f(T,t);if(I.length===0)m(!1);else if(I.length>=1){m(!0);const O=((N=I[0])==null?void 0:N.anchorType)||w.SheetDrawingAnchorType.Position;S(O)}});return()=>{R.unsubscribe(),D.unsubscribe()}},[]);function v(D){S(D);const R=t.getFocusDrawings();if(R.length===0)return;const y=R.map(T=>({unitId:T.unitId,subUnitId:T.subUnitId,drawingId:T.drawingId,anchorType:D}));r.executeCommand(be.id,{unitId:R[0].unitId,drawings:y})}return F.jsxs("div",{className:Y.clsx("univer-grid univer-gap-2 univer-py-2 univer-text-gray-400",{"univer-hidden":!c}),children:[F.jsx("header",{className:"univer-text-gray-600 dark:!univer-text-gray-200",children:F.jsx("div",{children:e.t("drawing-anchor.title")})}),F.jsx("div",{children:F.jsxs(Y.RadioGroup,{value:p,onChange:v,direction:"vertical",children:[F.jsx(Y.Radio,{value:w.SheetDrawingAnchorType.Both,children:e.t("drawing-anchor.both")}),F.jsx(Y.Radio,{value:w.SheetDrawingAnchorType.Position,children:e.t("drawing-anchor.position")}),F.jsx(Y.Radio,{value:w.SheetDrawingAnchorType.None,children:e.t("drawing-anchor.none")})]})})]})},Nn=()=>{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)&&F.jsxs("div",{className:"univer-text-sm",children:[F.jsx(ge.DrawingCommonPanel,{drawings:e}),F.jsx(Lt,{drawings:e})]})},Dt="sheet.menu.image";function kn(i){return{id:Dt,type:j.MenuItemType.SUBITEMS,icon:"AddImageIcon",tooltip:"sheetImage.title",hidden$:j.getMenuHiddenObservable(i,l.UniverInstanceType.UNIVER_SHEET),disabled$:b.getCurrentRangeDisable$(i,{workbookTypes:[C.WorkbookEditablePermission],worksheetTypes:[C.WorksheetEditPermission],rangeTypes:[C.RangeProtectionPermissionEditPoint]})}}function Wn(i){return{id:Oe.id,title:"sheetImage.upload.float",type:j.MenuItemType.BUTTON,hidden$:j.getMenuHiddenObservable(i,l.UniverInstanceType.UNIVER_SHEET)}}function Bn(i){return{id:pt.id,title:"sheetImage.upload.cell",type:j.MenuItemType.BUTTON,hidden$:j.getMenuHiddenObservable(i,l.UniverInstanceType.UNIVER_SHEET)}}function jn(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 $n(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 d=n;d<=o;d++)for(let g=s;g<=a;g++){const u=t.getValue(d,g);if(jn(u))return!0}return!1}function Fn(){return"showDirectoryPicker"in window}function Tt(i){const r=i.get(l.IUniverInstanceService),e=i.get(C.SheetsSelectionsService),t=U.combineLatest([j.getMenuHiddenObservable(i,l.UniverInstanceType.UNIVER_SHEET),r.getCurrentTypeOfUnit$(l.UniverInstanceType.UNIVER_SHEET).pipe(U.switchMap(n=>n?e.selectionMoveEnd$.pipe(U.map(()=>{if(!Fn())return!0;const o=e.getCurrentSelections();if(!o||o.length===0)return!0;for(const s of o)if($n(n,s.range))return!1;return!0})):U.of(!0)))]).pipe(U.map(([n,o])=>n||o));return{id:_e.id,type:j.MenuItemType.BUTTON,icon:"DownloadImageIcon",title:"sheetImage.save.menuLabel",hidden$:t}}const Ln={[j.RibbonInsertGroup.MEDIA]:{[Dt]:{order:0,menuItemFactory:kn,[Oe.id]:{order:0,menuItemFactory:Wn},[pt.id]:{order:1,menuItemFactory:Bn}}},[j.ContextMenuPosition.MAIN_AREA]:{[j.ContextMenuGroup.OTHERS]:{[_e.id]:{order:10,menuItemFactory:Tt}}},[j.ContextMenuPosition.COL_HEADER]:{[j.ContextMenuGroup.OTHERS]:{[_e.id]:{order:10,menuItemFactory:Tt}}},[j.ContextMenuPosition.ROW_HEADER]:{[j.ContextMenuGroup.OTHERS]:{[_e.id]:{order:10,menuItemFactory:Tt}}}};function ke(i){return!i.getContextValue(l.FOCUSING_FX_BAR_EDITOR)&&!i.getContextValue(l.EDITOR_ACTIVATED)&&!i.getContextValue(l.FOCUSING_PANEL_EDITOR)&&i.getContextValue(l.FOCUSING_COMMON_DRAWINGS)}const Yn={id:we.id,description:"shortcut.drawing-move-down",group:"4_drawing-view",binding:j.KeyCode.ARROW_DOWN,priority:100,preconditions:ke,staticParameters:{direction:l.Direction.DOWN}},Gn={id:we.id,description:"shortcut.drawing-move-up",group:"4_drawing-view",binding:j.KeyCode.ARROW_UP,priority:100,preconditions:ke,staticParameters:{direction:l.Direction.UP}},Hn={id:we.id,description:"shortcut.drawing-move-left",group:"4_drawing-view",binding:j.KeyCode.ARROW_LEFT,priority:100,preconditions:ke,staticParameters:{direction:l.Direction.LEFT}},Vn={id:we.id,description:"shortcut.drawing-move-right",group:"4_drawing-view",binding:j.KeyCode.ARROW_RIGHT,priority:100,preconditions:ke,staticParameters:{direction:l.Direction.RIGHT}},Xn={id:lt.id,description:"shortcut.drawing-delete",group:"4_drawing-view",preconditions:ke,binding:j.KeyCode.DELETE,mac:j.KeyCode.BACKSPACE};var xn=Object.getOwnPropertyDescriptor,Kn=(i,r,e,t)=>{for(var n=t>1?void 0:t?xn(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 Qe=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(Pt,Nn)),this.disposeWithMe(i.register(ve,Pn))}_initMenus(){this._menuManagerService.mergeMenu(Ln)}_initCommands(){[Oe,pt,Ee,Se,be,vt,V,_t,ut,ht,we,lt,gt,_e].forEach(i=>this.disposeWithMe(this._commandService.registerCommand(i)))}_initShortcuts(){[Yn,Gn,Hn,Vn,Xn].forEach(i=>{this.disposeWithMe(this._shortcutService.registerShortcut(i))})}_init(){this._initCommands(),this._initCustomComponents(),this._initMenus(),this._initShortcuts()}};Qe=Kn([Ce(0,l.Inject(j.ComponentManager)),Ce(1,j.IMenuManagerService),Ce(2,l.ICommandService),Ce(3,j.IShortcutService),Ce(4,B.IDrawingManagerService),Ce(5,l.Inject(C.SheetsSelectionsService))],Qe);var zn=Object.defineProperty,qn=Object.getOwnPropertyDescriptor,Zn=(i,r,e)=>r in i?zn(i,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[r]=e,Jn=(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},Mt=(i,r)=>(e,t)=>r(e,t,i),Yt=(i,r,e)=>Zn(i,typeof r!="symbol"?r+"":r,e);const Qn="SHEET_IMAGE_UI_PLUGIN";M.UniverSheetsDrawingUIPlugin=class extends l.Plugin{constructor(r=Nt,e,t,n){super(),this._config=r,this._injector=e,this._renderManagerService=t,this._configService=n;const{menu:o,...s}=l.merge({},Nt,this._config);o&&this._configService.setConfig("menu",o,{merge:!0}),this._configService.setConfig(nn,s)}onStarting(){l.registerDependencies(this._injector,[[M.SheetCanvasFloatDomManagerService],[Qe],[Ye],[Je],[ze],[Ke],[Ve],[Xe],[xe],[Fe,{useClass:M.BatchSaveImagesService}]]),l.touchDependencies(this._injector,[[M.SheetCanvasFloatDomManagerService]])}onReady(){l.touchDependencies(this._injector,[[Ke],[xe]])}onRendered(){this._registerRenderModules(),l.touchDependencies(this._injector,[[ze],[Je],[Qe],[Ve],[Xe]])}onSteady(){this._injector.get(Ye)}_registerRenderModules(){[[M.SheetDrawingUpdateController],[yt],[Ct],[It]].forEach(r=>{this.disposeWithMe(this._renderManagerService.registerRenderModule(l.UniverInstanceType.UNIVER_SHEET,r))})}},Yt(M.UniverSheetsDrawingUIPlugin,"type",l.UniverInstanceType.UNIVER_SHEET),Yt(M.UniverSheetsDrawingUIPlugin,"pluginName",Qn),M.UniverSheetsDrawingUIPlugin=Jn([l.DependentOn(B.UniverDrawingPlugin,bt.UniverDocsDrawingPlugin,ge.UniverDrawingUIPlugin,w.UniverSheetsDrawingPlugin),Mt(1,l.Inject(l.Injector)),Mt(2,A.IRenderManagerService),Mt(3,l.IConfigService)],M.UniverSheetsDrawingUIPlugin),M.ClearSheetDrawingTransformerOperation=V,M.DeleteDrawingsCommand=lt,M.EditSheetDrawingOperation=_t,M.FileNamePart=he,M.GroupSheetDrawingCommand=ut,M.IBatchSaveImagesService=Fe,M.InsertFloatImageCommand=Oe,M.InsertSheetDrawingCommand=Ee,M.MoveDrawingsCommand=we,M.RemoveSheetDrawingCommand=Se,M.SHEETS_IMAGE_MENU_ID=Dt,M.SHEET_FLOAT_DOM_PREFIX=$t,M.SaveCellImagesCommand=_e,M.SetDrawingArrangeCommand=gt,M.SetSheetDrawingCommand=be,M.SheetDrawingAnchor=Lt,M.SidebarSheetDrawingOperation=vt,M.UngroupSheetDrawingCommand=ht,M.calcSheetFloatDomPosition=ae,M.drawingPositionToTransform=J,M.transformToDrawingPosition=H,Object.defineProperty(M,Symbol.toStringTag,{value:"Module"})}));
|
|
16
16
|
|
|
17
17
|
|
|
18
18
|
// @univerjs/sheets-drawing-ui/facade
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@univerjs/preset-sheets-drawing",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.15.0",
|
|
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.
|
|
62
|
-
"@univerjs/drawing": "0.
|
|
63
|
-
"@univerjs/drawing-ui": "0.
|
|
64
|
-
"@univerjs/sheets-drawing": "0.
|
|
65
|
-
"@univerjs/sheets-drawing-ui": "0.
|
|
61
|
+
"@univerjs/docs-drawing": "0.15.0",
|
|
62
|
+
"@univerjs/drawing": "0.15.0",
|
|
63
|
+
"@univerjs/drawing-ui": "0.15.0",
|
|
64
|
+
"@univerjs/sheets-drawing": "0.15.0",
|
|
65
|
+
"@univerjs/sheets-drawing-ui": "0.15.0"
|
|
66
66
|
},
|
|
67
67
|
"devDependencies": {
|
|
68
|
-
"@univerjs/core": "0.
|
|
68
|
+
"@univerjs/core": "0.15.0",
|
|
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.
|
|
73
|
+
"@univerjs-infra/shared": "0.15.0"
|
|
74
74
|
},
|
|
75
75
|
"scripts": {
|
|
76
76
|
"prebuild:preset": "tsx prepare.ts",
|