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