@gx-design-vue/image 0.2.0-alpha.0 → 0.2.0-alpha.2

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.
Files changed (69) hide show
  1. package/dist/Image.d.ts +6 -0
  2. package/dist/Image.js +322 -0
  3. package/dist/ImagePreview.d.ts +6 -0
  4. package/dist/ImagePreview.js +593 -0
  5. package/dist/g-image.esm.js +1577 -0
  6. package/dist/g-image.js +1 -0
  7. package/dist/hooks/useImageBoundary.d.ts +15 -0
  8. package/dist/hooks/useImageBoundary.js +24 -0
  9. package/dist/hooks/useImagePreview.d.ts +23 -0
  10. package/dist/hooks/useImagePreview.js +54 -0
  11. package/dist/hooks/useImageTransform.d.ts +23 -0
  12. package/dist/hooks/useImageTransform.js +92 -0
  13. package/dist/hooks/useMouseEvent.d.ts +22 -0
  14. package/dist/hooks/useMouseEvent.js +71 -0
  15. package/dist/hooks/useTouchEvent.d.ts +23 -0
  16. package/dist/{ImagePreview/hooks → hooks}/useTouchEvent.js +31 -32
  17. package/dist/index.d.ts +4 -5
  18. package/dist/index.js +3 -6
  19. package/dist/interface.d.ts +169 -0
  20. package/dist/interface.js +1 -0
  21. package/dist/style/index.d.ts +7 -0
  22. package/dist/{style.js → style/index.js} +19 -26
  23. package/dist/style/preview.d.ts +14 -0
  24. package/dist/style/preview.js +182 -0
  25. package/dist/theme/augment.d.ts +10 -0
  26. package/dist/theme/augment.js +1 -0
  27. package/dist/theme/interface/components.d.ts +10 -0
  28. package/dist/theme/interface/components.js +1 -0
  29. package/package.json +9 -8
  30. package/dist/GImage.d.ts +0 -162
  31. package/dist/GImage.js +0 -221
  32. package/dist/ImagePreview/Operations.d.ts +0 -83
  33. package/dist/ImagePreview/Operations.js +0 -71
  34. package/dist/ImagePreview/hooks/getFixScaleEleTransPosition.d.ts +0 -19
  35. package/dist/ImagePreview/hooks/getFixScaleEleTransPosition.js +0 -40
  36. package/dist/ImagePreview/hooks/useImageTransform.d.ts +0 -39
  37. package/dist/ImagePreview/hooks/useImageTransform.js +0 -105
  38. package/dist/ImagePreview/hooks/useMouseEvent.d.ts +0 -14
  39. package/dist/ImagePreview/hooks/useMouseEvent.js +0 -100
  40. package/dist/ImagePreview/hooks/useTouchEvent.d.ts +0 -12
  41. package/dist/ImagePreview/index.d.ts +0 -162
  42. package/dist/ImagePreview/index.js +0 -303
  43. package/dist/ImagePreview/props.d.ts +0 -88
  44. package/dist/ImagePreview/props.js +0 -53
  45. package/dist/ImagePreview/style.d.ts +0 -30
  46. package/dist/ImagePreview/style.js +0 -286
  47. package/dist/ImagePreview/typings.d.ts +0 -19
  48. package/dist/ImagePreview/typings.js +0 -1
  49. package/dist/ImagePreview/utils/KeyCode.d.ts +0 -438
  50. package/dist/ImagePreview/utils/KeyCode.js +0 -173
  51. package/dist/ImagePreview/utils/addEventListener.d.ts +0 -6
  52. package/dist/ImagePreview/utils/addEventListener.js +0 -22
  53. package/dist/ImagePreview/utils/util.d.ts +0 -7
  54. package/dist/ImagePreview/utils/util.js +0 -8
  55. package/dist/hooks/useFrameSetState.d.ts +0 -5
  56. package/dist/hooks/useFrameSetState.js +0 -33
  57. package/dist/image.esm.js +0 -2374
  58. package/dist/image.js +0 -1
  59. package/dist/props.d.ts +0 -84
  60. package/dist/props.js +0 -66
  61. package/dist/slots.d.ts +0 -6
  62. package/dist/slots.js +0 -21
  63. package/dist/style.d.ts +0 -9
  64. package/dist/typings.d.ts +0 -6
  65. package/dist/typings.js +0 -1
  66. package/dist/utils/aria.d.ts +0 -15
  67. package/dist/utils/aria.js +0 -16
  68. package/dist/utils/util.d.ts +0 -4
  69. package/dist/utils/util.js +0 -8
@@ -0,0 +1,1577 @@
1
+ import { Fragment as e, Teleport as t, Transition as n, computed as r, createVNode as i, customRef as a, defineComponent as o, getCurrentInstance as s, getCurrentScope as c, hasInjectionContext as l, inject as u, isRef as d, isVNode as f, mergeDefaults as p, mergeProps as m, nextTick as h, onMounted as g, onScopeDispose as _, onUnmounted as v, readonly as y, ref as b, shallowRef as x, toRef as S, toValue as C, unref as w, watch as T, watchEffect as E } from "vue";
2
+ import { CloseOutlined as D, CopyOutlined as O, DownloadOutlined as k, EyeOutlined as A, LeftOutlined as ee, LoadingOutlined as te, RightOutlined as ne, RotateLeftOutlined as j, RotateRightOutlined as M, SwapOutlined as N, ZoomInOutlined as P, ZoomOutOutlined as re } from "@antdv-next/icons";
3
+ import { proGenStyleHooks as ie, unit as F } from "@gx-design-vue/pro-provider";
4
+ import { useBaseConfig as ae } from "antdv-next/config-provider/context";
5
+ import oe from "antdv-next/config-provider/hooks/useCSSVarCls";
6
+ import { message as I } from "antdv-next";
7
+ typeof process < "u" && process.versions != null && process.versions.node;
8
+ //#endregion
9
+ //#region ../pro-utils/dist/is/type.js
10
+ function L(e, t) {
11
+ return Object.prototype.toString.call(e) === `[object ${t}]`;
12
+ }
13
+ function R(e) {
14
+ return typeof e == "boolean";
15
+ }
16
+ function se(e) {
17
+ return typeof e == "number";
18
+ }
19
+ function z(e) {
20
+ return Array.isArray === void 0 ? Object.prototype.toString.call(e) === "[object Array]" : Array.isArray(e);
21
+ }
22
+ function B(e) {
23
+ return e !== null && L(e, "Object");
24
+ }
25
+ function ce(e) {
26
+ return typeof e == "string";
27
+ }
28
+ //#endregion
29
+ //#region ../pro-utils/dist/is/server.js
30
+ var V = typeof window > "u", le = (e) => setTimeout(e, 16), H = (e) => clearTimeout(e);
31
+ typeof window < "u" && "requestAnimationFrame" in window && (le = (e) => window.requestAnimationFrame(e), H = (e) => window.cancelAnimationFrame(e));
32
+ var ue = 0, U = /* @__PURE__ */ new Map();
33
+ function W(e) {
34
+ U.delete(e);
35
+ }
36
+ function de(e, t = 1) {
37
+ ue += 1;
38
+ let n = ue;
39
+ function r(t) {
40
+ if (t === 0) W(n), e();
41
+ else {
42
+ let e = le(() => {
43
+ r(t - 1);
44
+ });
45
+ U.set(n, e);
46
+ }
47
+ }
48
+ return r(t), n;
49
+ }
50
+ de.cancel = (e) => {
51
+ let t = U.get(e);
52
+ return W(t), H(t);
53
+ };
54
+ //#endregion
55
+ //#region ../pro-utils/dist/dom/scroll.js
56
+ function fe(e) {
57
+ return e.replace(/[-_](.)/g, (e, t) => t.toUpperCase());
58
+ }
59
+ function G(e, t) {
60
+ if (V || !e || !t) return "";
61
+ t = fe(t), t === "float" && (t = "cssFloat");
62
+ try {
63
+ let n = e.style[t];
64
+ if (n) return n;
65
+ let r = document?.defaultView?.getComputedStyle(e, "");
66
+ return r ? r[t] : "";
67
+ } catch {
68
+ return e.style[t];
69
+ }
70
+ }
71
+ function pe(e, t) {
72
+ if (!V) return (t == null ? G(e, "overflow") : t ? G(e, "overflow-y") : G(e, "overflow-x")).match(/(scroll|auto|overlay)/);
73
+ }
74
+ function me(e, t) {
75
+ if (V) return;
76
+ let n = e;
77
+ for (; n;) {
78
+ if ([
79
+ window,
80
+ document,
81
+ document.documentElement
82
+ ].includes(n)) return window;
83
+ if (pe(n, t)) return n;
84
+ n = n.parentNode;
85
+ }
86
+ return n;
87
+ }
88
+ //#endregion
89
+ //#region ../pro-utils/dist/object/classNames.js
90
+ function K(...e) {
91
+ let t = [];
92
+ for (let n = 0; n < e.length; n++) {
93
+ let r = e[n];
94
+ if (r) {
95
+ if (ce(r)) t.push(r);
96
+ else if (z(r)) for (let e = 0; e < r.length; e++) {
97
+ let n = K(r[e]);
98
+ n && t.push(n);
99
+ }
100
+ else if (B(r)) for (let e in r) r[e] && t.push(e);
101
+ }
102
+ }
103
+ return t.filter((e) => e).join(" ");
104
+ }
105
+ //#endregion
106
+ //#region ../pro-utils/dist/vue/slots.js
107
+ function he({ vnode: e, defaultVNode: t }, ...n) {
108
+ return e === !1 ? null : typeof e == "function" ? e?.(...n) : e || t;
109
+ }
110
+ function ge(e, ...t) {
111
+ let { slots: n, key: r = "default", render: i, props: a, defaultChildren: o } = e, s, c = a[r], l = n?.[r], u = typeof o == "function" ? o?.() : o;
112
+ return s = c === !1 ? !1 : c === !0 ? l ?? u : B(c) && i ? f(c) ? c : l : c || l, s === !1 ? !1 : i ? he({
113
+ vnode: s,
114
+ defaultVNode: u
115
+ }, ...t) : s;
116
+ }
117
+ function q(e, ...t) {
118
+ let { slots: n, key: r = "default", props: i, defaultChildren: a } = e, o, s = i[r], c = n?.[r]?.(...t), l = typeof a == "function" ? a?.() : a;
119
+ return o = s === !1 ? !1 : s === !0 ? c ?? l : B(s) ? f(s) ? s : c : s || c, o === !1 ? !1 : he({
120
+ vnode: o,
121
+ defaultVNode: l
122
+ }, ...t);
123
+ }
124
+ function _e(e, ...t) {
125
+ let { slots: n, props: r, keys: i, render: a, defaultVNodes: o } = e, s = {};
126
+ return i.forEach((e, i) => {
127
+ let c = o ? o[i] : null, l = a ? q({
128
+ slots: n,
129
+ props: r,
130
+ key: e,
131
+ defaultChildren: c
132
+ }, ...t) : ge({
133
+ slots: n,
134
+ props: r,
135
+ key: e,
136
+ render: !1,
137
+ defaultChildren: c
138
+ }, ...t);
139
+ (R(l) || l) && (s[e] = l);
140
+ }), s;
141
+ }
142
+ //#endregion
143
+ //#region ../../node_modules/.pnpm/@vueuse+shared@14.3.0_vue@3.5.27_typescript@6.0.3_/node_modules/@vueuse/shared/dist/index.js
144
+ function ve(e, t) {
145
+ return c() ? (_(e, t), !0) : !1;
146
+ }
147
+ var J = /* @__PURE__ */ new WeakMap(), ye = (...e) => {
148
+ let t = e[0], n = s()?.proxy ?? c();
149
+ if (n == null && !l()) throw Error("injectLocal must be called in setup");
150
+ return n && J.has(n) && t in J.get(n) ? J.get(n)[t] : u(...e);
151
+ }, Y = typeof window < "u" && typeof document < "u";
152
+ typeof WorkerGlobalScope < "u" && globalThis instanceof WorkerGlobalScope;
153
+ var be = Object.prototype.toString, xe = (e) => be.call(e) === "[object Object]", Se = () => {}, Ce = /* @__PURE__ */ we();
154
+ function we() {
155
+ var e, t;
156
+ return Y && !!(!((e = window) == null || (e = e.navigator) == null) && e.userAgent) && (/iP(?:ad|hone|od)/.test(window.navigator.userAgent) || ((t = window) == null || (t = t.navigator) == null ? void 0 : t.maxTouchPoints) > 2 && /iPad|Macintosh/.test(window?.navigator.userAgent));
157
+ }
158
+ function Te(...e) {
159
+ if (e.length !== 1) return S(...e);
160
+ let t = e[0];
161
+ return typeof t == "function" ? y(a(() => ({
162
+ get: t,
163
+ set: Se
164
+ }))) : b(t);
165
+ }
166
+ function Ee(e, t) {
167
+ function n(...n) {
168
+ return new Promise((r, i) => {
169
+ Promise.resolve(e(() => t.apply(this, n), {
170
+ fn: t,
171
+ thisArg: this,
172
+ args: n
173
+ })).then(r).catch(i);
174
+ });
175
+ }
176
+ return n;
177
+ }
178
+ function De(...e) {
179
+ let t = 0, n, r = !0, i = Se, a, o, s, c, l;
180
+ !d(e[0]) && typeof e[0] == "object" ? {delay: o, trailing: s = !0, leading: c = !0, rejectOnCancel: l = !1} = e[0] : [o, s = !0, c = !0, l = !1] = e;
181
+ let u = () => {
182
+ n && (clearTimeout(n), n = void 0, i(), i = Se);
183
+ };
184
+ return (e) => {
185
+ let d = C(o), f = Date.now() - t, p = () => a = e();
186
+ return u(), d <= 0 ? (t = Date.now(), p()) : (f > d ? (t = Date.now(), (c || !r) && p()) : s && (a = new Promise((e, a) => {
187
+ i = l ? a : e, n = setTimeout(() => {
188
+ t = Date.now(), r = !0, e(p()), u();
189
+ }, Math.max(0, d - f));
190
+ })), !c && !n && (n = setTimeout(() => r = !0, d)), r = !1, a);
191
+ };
192
+ }
193
+ function Oe(e) {
194
+ return e.endsWith("rem") ? Number.parseFloat(e) * 16 : Number.parseFloat(e);
195
+ }
196
+ function ke(e) {
197
+ return Array.isArray(e) ? e : [e];
198
+ }
199
+ function Ae(e) {
200
+ return e || s();
201
+ }
202
+ function je(e, t = 200, n = !1, r = !0, i = !1) {
203
+ return Ee(De(t, n, r, i), e);
204
+ }
205
+ function Me(e, t = !0, n) {
206
+ Ae(n) ? g(e, n) : t ? e() : h(e);
207
+ }
208
+ function Ne(e, t, n) {
209
+ return T(e, t, {
210
+ ...n,
211
+ immediate: !0
212
+ });
213
+ }
214
+ //#endregion
215
+ //#region ../../node_modules/.pnpm/@vueuse+core@14.3.0_vue@3.5.27_typescript@6.0.3_/node_modules/@vueuse/core/dist/index.js
216
+ var Pe = Y ? window : void 0;
217
+ Y && window.document, Y && window.navigator, Y && window.location;
218
+ function Fe(e) {
219
+ let t = C(e);
220
+ return t?.$el ?? t;
221
+ }
222
+ function X(...e) {
223
+ let t = (e, t, n, r) => (e.addEventListener(t, n, r), () => e.removeEventListener(t, n, r)), n = r(() => {
224
+ let t = ke(C(e[0])).filter((e) => e != null);
225
+ return t.every((e) => typeof e != "string") ? t : void 0;
226
+ });
227
+ return Ne(() => [
228
+ n.value?.map((e) => Fe(e)) ?? [Pe].filter((e) => e != null),
229
+ ke(C(n.value ? e[1] : e[0])),
230
+ ke(w(n.value ? e[2] : e[1])),
231
+ C(n.value ? e[3] : e[2])
232
+ ], ([e, n, r, i], a, o) => {
233
+ if (!e?.length || !n?.length || !r?.length) return;
234
+ let s = xe(i) ? { ...i } : i, c = e.flatMap((e) => n.flatMap((n) => r.map((r) => t(e, n, r, s))));
235
+ o(() => {
236
+ c.forEach((e) => e());
237
+ });
238
+ }, { flush: "post" });
239
+ }
240
+ function Ie() {
241
+ let e = x(!1), t = s();
242
+ return t && g(() => {
243
+ e.value = !0;
244
+ }, t), e;
245
+ }
246
+ /* @__NO_SIDE_EFFECTS__ */
247
+ function Le(e) {
248
+ let t = Ie();
249
+ return r(() => (t.value, !!e()));
250
+ }
251
+ var Re = Symbol("vueuse-ssr-width");
252
+ /* @__NO_SIDE_EFFECTS__ */
253
+ function ze() {
254
+ let e = l() ? ye(Re, null) : null;
255
+ return typeof e == "number" ? e : void 0;
256
+ }
257
+ function Be(e, t = {}) {
258
+ let { window: n = Pe, ssrWidth: i = /* @__PURE__ */ ze() } = t, a = /* @__PURE__ */ Le(() => n && "matchMedia" in n && typeof n.matchMedia == "function"), o = x(typeof i == "number"), s = x(), c = x(!1);
259
+ return E(() => {
260
+ if (o.value) {
261
+ o.value = !a.value, c.value = C(e).split(",").some((e) => {
262
+ let t = e.includes("not all"), n = e.match(/\(\s*min-width:\s*(-?\d+(?:\.\d*)?[a-z]+\s*)\)/), r = e.match(/\(\s*max-width:\s*(-?\d+(?:\.\d*)?[a-z]+\s*)\)/), a = !!(n || r);
263
+ return n && a && (a = i >= Oe(n[1])), r && a && (a = i <= Oe(r[1])), t ? !a : a;
264
+ });
265
+ return;
266
+ }
267
+ a.value && (s.value = n.matchMedia(C(e)), c.value = s.value.matches);
268
+ }), X(s, "change", (e) => {
269
+ c.value = e.matches;
270
+ }, { passive: !0 }), r(() => c.value);
271
+ }
272
+ function Ve(e) {
273
+ return typeof Window < "u" && e instanceof Window ? e.document.documentElement : typeof Document < "u" && e instanceof Document ? e.documentElement : e;
274
+ }
275
+ function He(e) {
276
+ let t = window.getComputedStyle(e);
277
+ if (t.overflowX === "scroll" || t.overflowY === "scroll" || t.overflowX === "auto" && e.clientWidth < e.scrollWidth || t.overflowY === "auto" && e.clientHeight < e.scrollHeight) return !0;
278
+ {
279
+ let t = e.parentNode;
280
+ return !t || t.tagName === "BODY" ? !1 : He(t);
281
+ }
282
+ }
283
+ function Ue(e) {
284
+ let t = e || window.event, n = t.target;
285
+ return He(n) ? !1 : t.touches.length > 1 ? !0 : (t.preventDefault && t.preventDefault(), !1);
286
+ }
287
+ var We = /* @__PURE__ */ new WeakMap();
288
+ function Ge(e, t = !1) {
289
+ let n = x(t), i = null, a = "";
290
+ T(Te(e), (e) => {
291
+ let t = Ve(C(e));
292
+ if (t) {
293
+ let e = t;
294
+ if (We.get(e) || We.set(e, e.style.overflow), e.style.overflow !== "hidden" && (a = e.style.overflow), e.style.overflow === "hidden") return n.value = !0;
295
+ if (n.value) return e.style.overflow = "hidden";
296
+ }
297
+ }, { immediate: !0 });
298
+ let o = () => {
299
+ let t = Ve(C(e));
300
+ !t || n.value || (Ce && (i = X(t, "touchmove", (e) => {
301
+ Ue(e);
302
+ }, { passive: !1 })), t.style.overflow = "hidden", n.value = !0);
303
+ }, s = () => {
304
+ let t = Ve(C(e));
305
+ !t || !n.value || (Ce && i?.(), t.style.overflow = a, We.delete(t), n.value = !1);
306
+ };
307
+ return ve(s), r({
308
+ get() {
309
+ return n.value;
310
+ },
311
+ set(e) {
312
+ e ? o() : s();
313
+ }
314
+ });
315
+ }
316
+ function Ke(e = {}) {
317
+ let { window: t = Pe, initialWidth: n = Infinity, initialHeight: r = Infinity, listenOrientation: i = !0, includeScrollbar: a = !0, type: o = "inner" } = e, s = x(n), c = x(r), l = () => {
318
+ if (t) if (o === "outer") s.value = t.outerWidth, c.value = t.outerHeight;
319
+ else if (o === "visual" && t.visualViewport) {
320
+ let { width: e, height: n, scale: r } = t.visualViewport;
321
+ s.value = Math.round(e * r), c.value = Math.round(n * r);
322
+ } else a ? (s.value = t.innerWidth, c.value = t.innerHeight) : (s.value = t.document.documentElement.clientWidth, c.value = t.document.documentElement.clientHeight);
323
+ };
324
+ l(), Me(l);
325
+ let u = { passive: !0 };
326
+ return X("resize", l, u), t && o === "visual" && t.visualViewport && X(t.visualViewport, "resize", l, u), i && T(Be("(orientation: portrait)"), () => l()), {
327
+ width: s,
328
+ height: c
329
+ };
330
+ }
331
+ //#endregion
332
+ //#region src/hooks/useImagePreview.ts
333
+ function qe(e) {
334
+ let { canPreview: t } = e, n = b(!1), r = b(null), i = Ge(document.body, !1), a;
335
+ return _(() => {
336
+ a !== void 0 && (window.cancelAnimationFrame(a), a = void 0), i.value = !1;
337
+ }), X("wheel", (e) => {
338
+ n.value && e.ctrlKey && e.preventDefault();
339
+ }, { passive: !1 }), {
340
+ showViewer: n,
341
+ mousePosition: r,
342
+ openPreview: (e) => {
343
+ t.value && (a !== void 0 && (window.cancelAnimationFrame(a), a = void 0), e ? r.value = {
344
+ x: e.clientX,
345
+ y: e.clientY
346
+ } : r.value = null, n.value = !0, a = window.requestAnimationFrame(() => {
347
+ i.value = !0, a = void 0;
348
+ }));
349
+ },
350
+ closePreview: () => {
351
+ a !== void 0 && (window.cancelAnimationFrame(a), a = void 0), n.value = !1, r.value = null, i.value = !1;
352
+ }
353
+ };
354
+ }
355
+ //#endregion
356
+ //#region ../pro-hooks/dist/core/useIsIos.js
357
+ var Je = (typeof window > "u" ? !1 : /iPad|iPhone|iPod/.test(navigator.platform) || navigator.platform === "MacIntel" && navigator.maxTouchPoints > 1) && !window.MSStream;
358
+ typeof window > "u" || Je || window.safari;
359
+ //#endregion
360
+ //#region ../pro-hooks/dist/core/useState.js
361
+ function Ye(e) {
362
+ let t = b(typeof e == "function" ? e() : e);
363
+ function n(e) {
364
+ t.value = e;
365
+ }
366
+ return [t, n];
367
+ }
368
+ //#endregion
369
+ //#region ../pro-hooks/dist/core/useMergedState.js
370
+ function Xe(e, t) {
371
+ let { defaultValue: n, value: r = b() } = t || {}, i = typeof e == "function" ? e() : e;
372
+ r.value !== void 0 && (i = w(r)), n !== void 0 && (i = typeof n == "function" ? n() : n);
373
+ let a = b(i), o = b(i), [s, c] = Ye([o.value]);
374
+ E(() => {
375
+ let e = r.value === void 0 ? a.value : r.value;
376
+ t?.postState && (e = t.postState(e, a.value)), o.value = e;
377
+ }), T(s, () => {
378
+ let e = s.value[0];
379
+ a.value !== e && t?.onChange?.(a.value, e);
380
+ }, { deep: !0 });
381
+ function l(e) {
382
+ a.value = e;
383
+ }
384
+ function u(e) {
385
+ l(e), c([o.value]);
386
+ }
387
+ return T(r, () => {
388
+ a.value = r.value;
389
+ }), [
390
+ o,
391
+ u,
392
+ a
393
+ ];
394
+ }
395
+ //#endregion
396
+ //#region src/hooks/useImageTransform.ts
397
+ var Ze = {
398
+ x: 0,
399
+ y: 0,
400
+ rotate: 0,
401
+ scale: 1,
402
+ flipX: !1,
403
+ flipY: !1
404
+ };
405
+ function Qe(e) {
406
+ let { imageRef: t, minScale: n, maxScale: r, windowWidth: i, windowHeight: a, onTransform: o } = e, s = b(null), c = b([]), [l, u] = Ye({ ...Ze }), d = (e) => {
407
+ let t = { ...l.value };
408
+ u({ ...Ze }), (t.x !== 0 || t.y !== 0 || t.scale !== 1 || t.rotate !== 0 || t.flipX || t.flipY) && o?.({
409
+ transform: { ...Ze },
410
+ action: e
411
+ });
412
+ }, f = (e, t) => {
413
+ s.value === null && (c.value = [], s.value = de(() => {
414
+ let e = { ...l.value };
415
+ for (let t of c.value) e = {
416
+ ...e,
417
+ ...t
418
+ };
419
+ s.value = null, o?.({
420
+ transform: e,
421
+ action: t
422
+ }), u(e);
423
+ })), c.value.push({
424
+ ...l.value,
425
+ ...e
426
+ });
427
+ };
428
+ return {
429
+ transform: l,
430
+ resetTransform: d,
431
+ updateTransform: f,
432
+ dispatchZoomChange: (e, o, s, c, u) => {
433
+ let d = t.value;
434
+ if (!d) return;
435
+ let { width: p, height: m, offsetWidth: h, offsetHeight: g, offsetLeft: _, offsetTop: v } = d, y = e, b = l.value.scale * e;
436
+ b > r.value ? (b = r.value, y = r.value / l.value.scale) : b < n.value && (b = u ? b : n.value, y = b / l.value.scale);
437
+ let x = s ?? i.value / 2, S = c ?? a.value / 2, C = y - 1, w = C * p * .5, T = C * m * .5, E = C * (x - l.value.x - _), D = C * (S - l.value.y - v), O = l.value.x - (E - w), k = l.value.y - (D - T);
438
+ if (e < 1 && b === 1) {
439
+ let e = h * b, t = g * b;
440
+ e <= i.value && t <= a.value && (O = 0, k = 0);
441
+ }
442
+ f({
443
+ x: O,
444
+ y: k,
445
+ scale: b
446
+ }, o);
447
+ }
448
+ };
449
+ }
450
+ //#endregion
451
+ //#region src/hooks/useImageBoundary.ts
452
+ function $e(e, t, n, r) {
453
+ let i = t + n, a = (n - r) / 2;
454
+ if (n > r) {
455
+ if (t > 0) return { [e]: a };
456
+ if (t < 0 && i < r) return { [e]: -a };
457
+ } else if (t < 0 || i > r) return { [e]: t < 0 ? a : -a };
458
+ return {};
459
+ }
460
+ function et(e) {
461
+ let { imageWidth: t, imageHeight: n, imageLeft: r, imageTop: i, windowWidth: a, windowHeight: o } = e;
462
+ return t <= a && n <= o ? {
463
+ x: 0,
464
+ y: 0
465
+ } : t > a || n > o ? {
466
+ ...$e("x", r, t, a),
467
+ ...$e("y", i, n, o)
468
+ } : null;
469
+ }
470
+ //#endregion
471
+ //#region src/hooks/useMouseEvent.ts
472
+ var tt = 1, nt = 2;
473
+ function rt(e) {
474
+ let { imageRef: t, movable: n, visible: r, scaleStep: i, transform: a, updateTransform: o, dispatchZoomChange: s, windowWidth: c, windowHeight: l } = e, u = b(!1), d = b({
475
+ diffX: 0,
476
+ diffY: 0,
477
+ transformX: 0,
478
+ transformY: 0
479
+ });
480
+ return X(window, "mouseup", () => {
481
+ if (!r.value || !u.value) return;
482
+ u.value = !1;
483
+ let { transformX: e, transformY: n } = d.value;
484
+ if (!(a.value.x !== e && a.value.y !== n)) return;
485
+ let i = t.value;
486
+ if (!i) return;
487
+ let s = i.offsetWidth * a.value.scale, f = i.offsetHeight * a.value.scale, { left: p, top: m } = i.getBoundingClientRect(), h = a.value.rotate % 180 != 0, g = et({
488
+ imageWidth: h ? f : s,
489
+ imageHeight: h ? s : f,
490
+ imageLeft: p,
491
+ imageTop: m,
492
+ windowWidth: c.value,
493
+ windowHeight: l.value
494
+ });
495
+ g && o({ ...g }, "dragRebound");
496
+ }), X(window, "mousemove", (e) => {
497
+ !r.value || !u.value || o({
498
+ x: e.pageX - d.value.diffX,
499
+ y: e.pageY - d.value.diffY
500
+ }, "move");
501
+ }), {
502
+ isMoving: u,
503
+ onMouseDown: (e) => {
504
+ !n.value || e.button !== 0 || (e.preventDefault(), e.stopPropagation(), d.value = {
505
+ diffX: e.pageX - a.value.x,
506
+ diffY: e.pageY - a.value.y,
507
+ transformX: a.value.x,
508
+ transformY: a.value.y
509
+ }, u.value = !0);
510
+ },
511
+ onWheel: (e) => {
512
+ if (!r.value || e.deltaY === 0) return;
513
+ let t = tt + Math.min(Math.abs(e.deltaY / 100), nt) * i.value;
514
+ e.deltaY > 0 && (t = tt / t), s(t, "wheel", e.clientX, e.clientY);
515
+ }
516
+ };
517
+ }
518
+ //#endregion
519
+ //#region src/hooks/useTouchEvent.ts
520
+ function it(e, t) {
521
+ return Math.hypot(e.x - t.x, e.y - t.y);
522
+ }
523
+ function at(e, t, n, r) {
524
+ let i = it(e, n), a = it(t, r);
525
+ if (i === 0 && a === 0) return [e.x, e.y];
526
+ let o = i / (i + a);
527
+ return [e.x + o * (t.x - e.x), e.y + o * (t.y - e.y)];
528
+ }
529
+ function ot(e) {
530
+ let { imageRef: t, movable: n, visible: r, minScale: i, transform: a, updateTransform: o, dispatchZoomChange: s, windowWidth: c, windowHeight: l } = e, u = b(!1), d = b({
531
+ point1: {
532
+ x: 0,
533
+ y: 0
534
+ },
535
+ point2: {
536
+ x: 0,
537
+ y: 0
538
+ },
539
+ eventType: "none"
540
+ }), f = (e) => {
541
+ d.value = {
542
+ ...d.value,
543
+ ...e
544
+ };
545
+ };
546
+ return X(window, "touchmove", (e) => {
547
+ r.value && n.value && e.preventDefault();
548
+ }, { passive: !1 }), {
549
+ isTouching: u,
550
+ onTouchStart: (e) => {
551
+ if (!n.value) return;
552
+ e.stopPropagation(), u.value = !0;
553
+ let { touches: t = [] } = e;
554
+ t.length > 1 ? f({
555
+ point1: {
556
+ x: t[0].clientX,
557
+ y: t[0].clientY
558
+ },
559
+ point2: {
560
+ x: t[1].clientX,
561
+ y: t[1].clientY
562
+ },
563
+ eventType: "touchZoom"
564
+ }) : f({
565
+ point1: {
566
+ x: t[0].clientX - a.value.x,
567
+ y: t[0].clientY - a.value.y
568
+ },
569
+ eventType: "move"
570
+ });
571
+ },
572
+ onTouchMove: (e) => {
573
+ let { touches: t = [] } = e, { point1: n, point2: r, eventType: i } = d.value;
574
+ if (t.length > 1 && i === "touchZoom") {
575
+ let e = {
576
+ x: t[0].clientX,
577
+ y: t[0].clientY
578
+ }, i = {
579
+ x: t[1].clientX,
580
+ y: t[1].clientY
581
+ }, [a, o] = at(n, r, e, i);
582
+ s(it(e, i) / it(n, r), "touchZoom", a, o, !0), f({
583
+ point1: e,
584
+ point2: i,
585
+ eventType: "touchZoom"
586
+ });
587
+ } else i === "move" && (o({
588
+ x: t[0].clientX - n.x,
589
+ y: t[0].clientY - n.y
590
+ }, "move"), f({ eventType: "move" }));
591
+ },
592
+ onTouchEnd: () => {
593
+ if (!r.value) return;
594
+ if (u.value &&= !1, f({ eventType: "none" }), i.value > a.value.scale) return o({
595
+ x: 0,
596
+ y: 0,
597
+ scale: i.value
598
+ }, "touchZoom");
599
+ let e = t.value;
600
+ if (!e) return;
601
+ let n = e.offsetWidth * a.value.scale, s = e.offsetHeight * a.value.scale, { left: d, top: p } = e.getBoundingClientRect(), m = a.value.rotate % 180 != 0, h = et({
602
+ imageWidth: m ? s : n,
603
+ imageHeight: m ? n : s,
604
+ imageLeft: d,
605
+ imageTop: p,
606
+ windowWidth: c.value,
607
+ windowHeight: l.value
608
+ });
609
+ h && o({ ...h }, "dragRebound");
610
+ }
611
+ };
612
+ }
613
+ //#endregion
614
+ //#region src/style/preview.ts
615
+ function st(e) {
616
+ return {
617
+ zIndexPopup: `calc(${e.zIndexPopupBase} + 80)`,
618
+ previewOperationColor: e.colorTextDescription,
619
+ previewOperationHoverColor: e.colorText,
620
+ previewOperationColorDisabled: e.colorTextDisabled,
621
+ imagePreviewSwitchSize: e.controlHeightLG,
622
+ previewOperationSize: e.fontSizeLG
623
+ };
624
+ }
625
+ var ct = (e) => {
626
+ let t = e.componentCls, { motionEaseOut: n, motionDurationSlow: r, previewOperationSize: i, zIndexPopup: a } = e, o = {
627
+ position: "absolute",
628
+ color: e.previewOperationColor,
629
+ backgroundColor: e.colorBgContainer,
630
+ borderRadius: "50%",
631
+ width: e.controlHeightLG,
632
+ height: e.controlHeightLG,
633
+ padding: 0,
634
+ outline: 0,
635
+ border: 0,
636
+ boxShadow: e.boxShadowTertiary,
637
+ cursor: "pointer",
638
+ transition: `all ${r}`,
639
+ display: "flex",
640
+ alignItems: "center",
641
+ justifyContent: "center",
642
+ fontSize: i,
643
+ "&:hover": {
644
+ color: e.previewOperationHoverColor,
645
+ backgroundColor: e.colorBgContainer
646
+ },
647
+ "&:active": { backgroundColor: e.colorBgContainer },
648
+ svg: { stroke: "currentColor" }
649
+ };
650
+ return { [t]: {
651
+ textAlign: "center",
652
+ inset: 0,
653
+ position: "fixed",
654
+ userSelect: "none",
655
+ zIndex: a,
656
+ [`${t}-mask`]: {
657
+ position: "absolute",
658
+ inset: 0,
659
+ background: `color-mix(in srgb, ${e.colorBgLayout} 90%, transparent)`,
660
+ backdropFilter: "blur(0px)",
661
+ transition: `background-color ${r}, backdrop-filter ${r}`,
662
+ [`&${t}-mask-blur`]: { backdropFilter: "blur(4px)" },
663
+ [`&${t}-mask-hidden`]: { display: "none" }
664
+ },
665
+ [`${t}-body`]: {
666
+ position: "absolute",
667
+ inset: 0,
668
+ overflow: "hidden",
669
+ display: "flex",
670
+ alignItems: "center",
671
+ justifyContent: "center",
672
+ pointerEvents: "none",
673
+ "> *": { pointerEvents: "auto" }
674
+ },
675
+ [`${t}-img`]: {
676
+ maxWidth: "100%",
677
+ maxHeight: "70%",
678
+ verticalAlign: "middle",
679
+ transform: "scale3d(1, 1, 1)",
680
+ transition: `transform ${r} ${n} 0s`,
681
+ userSelect: "none"
682
+ },
683
+ [`&-movable ${t}-img`]: { cursor: "grab" },
684
+ [`&-moving ${t}-img`]: { cursor: "grabbing" },
685
+ [`${t}-close`]: {
686
+ ...o,
687
+ top: e.marginSM,
688
+ insetInlineEnd: e.marginSM
689
+ },
690
+ [`${t}-switch`]: {
691
+ ...o,
692
+ top: "50%",
693
+ transform: "translateY(-50%)",
694
+ "&-disabled": { "&, &:hover, &:active": {
695
+ color: e.previewOperationColorDisabled,
696
+ backgroundColor: e.colorBgContainer,
697
+ cursor: "not-allowed"
698
+ } },
699
+ "&-prev": { insetInlineStart: e.marginSM },
700
+ "&-next": { insetInlineEnd: e.marginSM }
701
+ },
702
+ [`${t}-footer`]: {
703
+ position: "absolute",
704
+ bottom: e.marginXL,
705
+ left: {
706
+ _skip_check_: !0,
707
+ value: "50%"
708
+ },
709
+ display: "flex",
710
+ flexDirection: "column",
711
+ alignItems: "center",
712
+ color: e.previewOperationColor,
713
+ transform: "translateX(-50%)",
714
+ gap: e.marginXS
715
+ },
716
+ [`${t}-progress`]: { color: e.previewOperationColor },
717
+ [`${t}-actions`]: {
718
+ display: "flex",
719
+ alignItems: "center",
720
+ gap: e.marginXXS,
721
+ padding: e.paddingXXS,
722
+ color: e.previewOperationColor,
723
+ backgroundColor: e.colorBgContainer,
724
+ border: `${F(e.lineWidth)} ${e.lineType} ${e.colorFillTertiary}`,
725
+ borderRadius: e.borderRadiusLG,
726
+ fontSize: i,
727
+ "&-action": {
728
+ color: "inherit",
729
+ background: "transparent",
730
+ border: 0,
731
+ font: "inherit",
732
+ lineHeight: 1,
733
+ width: e.controlHeight,
734
+ height: e.controlHeight,
735
+ padding: 0,
736
+ cursor: "pointer",
737
+ transition: `all ${r}`,
738
+ display: "flex",
739
+ alignItems: "center",
740
+ justifyContent: "center",
741
+ borderRadius: e.borderRadius,
742
+ userSelect: "none",
743
+ [`&:not(${t}-actions-action-disabled):hover`]: {
744
+ color: e.colorTextSecondary,
745
+ backgroundColor: e.colorFillTertiary
746
+ },
747
+ [`&:not(${t}-actions-action-disabled):active`]: {
748
+ color: e.colorText,
749
+ backgroundColor: e.colorFillSecondary
750
+ },
751
+ "&-disabled": {
752
+ cursor: "not-allowed",
753
+ opacity: .5
754
+ },
755
+ svg: { stroke: "currentColor" }
756
+ }
757
+ }
758
+ } };
759
+ }, lt = (e) => {
760
+ let t = e.componentCls, { motionDurationSlow: n, motionEaseOut: r } = e;
761
+ return { [`${t}`]: {
762
+ "&-fade-enter-active, &-fade-leave-active": {
763
+ transition: `visibility ${n}`,
764
+ [`${t}-mask`]: { transition: `background-color ${n}, backdrop-filter ${n}` },
765
+ [`${t}-body`]: { transition: `transform ${n} ${r}` },
766
+ [`${t}-close, ${t}-switch, ${t}-footer`]: { transition: `opacity ${n}, all ${n}` }
767
+ },
768
+ "&-fade-enter-from, &-fade-leave-to": {
769
+ visibility: "visible",
770
+ [`${t}-mask`]: {
771
+ backgroundColor: "transparent",
772
+ backdropFilter: "blur(0px)"
773
+ },
774
+ [`${t}-body`]: { transform: "scale(0)" },
775
+ [`${t}-close, ${t}-switch, ${t}-footer`]: { opacity: 0 }
776
+ },
777
+ "&-fade-enter-to, &-fade-leave-from": {
778
+ [`${t}-mask`]: {
779
+ backgroundColor: `color-mix(in srgb, ${e.colorBgLayout} 90%, transparent)`,
780
+ [`&${t}-mask-blur`]: { backdropFilter: "blur(4px)" }
781
+ },
782
+ [`${t}-close, ${t}-switch, ${t}-footer`]: { opacity: 1 }
783
+ }
784
+ } };
785
+ }, ut = ie("GImagePreview", (e) => [ct(e), lt(e)], st), dt = 1, Z = {
786
+ rotateLeft: i(j, null, null),
787
+ rotateRight: i(M, null, null),
788
+ zoomIn: i(P, null, null),
789
+ zoomOut: i(re, null, null),
790
+ flipX: i(N, null, null),
791
+ flipY: i(N, { rotate: 90 }, null),
792
+ copy: i(O, null, null),
793
+ download: i(k, null, null)
794
+ }, Q = {
795
+ copySuccess: "复制成功",
796
+ copyFailed: "复制失败",
797
+ downloadSuccess: "下载成功",
798
+ downloadFailed: "下载失败"
799
+ };
800
+ function ft(e) {
801
+ try {
802
+ let t = new URL(e, window.location.href).pathname.match(/\/([^/]+)$/)?.[1];
803
+ return t ? decodeURIComponent(t) : "image";
804
+ } catch {
805
+ let t = e.split("?")[0]?.split("#")[0]?.split("/").pop();
806
+ return t ? decodeURIComponent(t) : "image";
807
+ }
808
+ }
809
+ function pt(e) {
810
+ let t = {
811
+ "image/gif": "gif",
812
+ "image/jpg": "jpg",
813
+ "image/jpeg": "jpg",
814
+ "image/png": "png",
815
+ "image/svg+xml": "svg",
816
+ "image/webp": "webp"
817
+ }, n = e?.toLowerCase();
818
+ return t[n] || n?.split("/")[1]?.split("+")[0] || "png";
819
+ }
820
+ async function mt(e) {
821
+ let t = await fetch(e, { mode: "cors" });
822
+ if (!t.ok) throw Error(`Failed to fetch image: ${t.status}`);
823
+ return t.blob();
824
+ }
825
+ async function ht(e) {
826
+ return new Promise((t, n) => {
827
+ let r = new Image(), i = URL.createObjectURL(e);
828
+ r.onload = () => {
829
+ URL.revokeObjectURL(i);
830
+ let e = document.createElement("canvas");
831
+ e.width = r.naturalWidth, e.height = r.naturalHeight;
832
+ let a = e.getContext("2d");
833
+ if (!a) {
834
+ n(/* @__PURE__ */ Error("Canvas context not available"));
835
+ return;
836
+ }
837
+ a.drawImage(r, 0, 0), e.toBlob((e) => {
838
+ e ? t(e) : n(/* @__PURE__ */ Error("Failed to convert to PNG"));
839
+ }, "image/png", 1);
840
+ }, r.onerror = () => {
841
+ URL.revokeObjectURL(i), n(/* @__PURE__ */ Error("Failed to load image for PNG conversion"));
842
+ }, r.src = i;
843
+ });
844
+ }
845
+ async function gt(e) {
846
+ let t = (e.type || "").toLowerCase();
847
+ return t === "image/png" || t === "image/svg+xml" ? { [t]: e } : { "image/png": await ht(e) };
848
+ }
849
+ function _t(e, t) {
850
+ let n = ft(e);
851
+ return n.includes(".") ? n.endsWith(".svg+xml") ? n.replace(/\.svg\+xml$/i, ".svg") : n : `${n}.${pt(t)}`;
852
+ }
853
+ function vt(e, t) {
854
+ let n = URL.createObjectURL(e), r = document.createElement("a");
855
+ r.href = n, r.download = t, r.style.display = "none", document.body.appendChild(r), r.click(), r.remove(), URL.revokeObjectURL(n);
856
+ }
857
+ var yt = /* @__PURE__ */ o((a, { emit: o, slots: s, expose: c }) => {
858
+ let { width: l, height: u } = Ke(), { prefixCls: d } = ae("pro-image-preview", a), f = oe(d), [p, m] = ut(d, f), [_, y] = Xe(a.open, {
859
+ value: S(a, "open"),
860
+ onChange: (e) => {
861
+ a.onOpenChange?.(e), o("update:open", e);
862
+ }
863
+ }), x = b(!0), C = b(), w = b(), E = b(a.current ?? 0), O = b(!1), k = b(!1), { transform: A, resetTransform: j, updateTransform: M, dispatchZoomChange: N } = Qe({
864
+ imageRef: C,
865
+ minScale: S(a, "minScale"),
866
+ maxScale: S(a, "maxScale"),
867
+ windowWidth: l,
868
+ windowHeight: u,
869
+ onTransform: a.onTransform
870
+ }), { isMoving: P, onMouseDown: re, onWheel: ie } = rt({
871
+ imageRef: C,
872
+ movable: S(a, "movable"),
873
+ visible: _,
874
+ scaleStep: S(a, "scaleStep"),
875
+ transform: A,
876
+ updateTransform: M,
877
+ dispatchZoomChange: N,
878
+ windowWidth: l,
879
+ windowHeight: u
880
+ }), { isTouching: F, onTouchStart: L, onTouchMove: R, onTouchEnd: se } = ot({
881
+ imageRef: C,
882
+ movable: S(a, "movable"),
883
+ visible: _,
884
+ minScale: S(a, "minScale"),
885
+ transform: A,
886
+ updateTransform: M,
887
+ dispatchZoomChange: N,
888
+ windowWidth: l,
889
+ windowHeight: u
890
+ }), z = r(() => a.urls[E.value]), B = r(() => a.urls.length > 1), ce = r(() => a.urls.length >= 1), V = r(() => a.mask === !1 ? {
891
+ visible: !1,
892
+ blur: !1
893
+ } : a.mask && typeof a.mask == "object" && !("type" in a.mask) ? {
894
+ visible: !0,
895
+ blur: a.mask.blur !== !1
896
+ } : {
897
+ visible: !0,
898
+ blur: !0
899
+ }), le = r(() => {
900
+ let e = {};
901
+ return a.mousePosition && (e.transformOrigin = `${a.mousePosition.x}px ${a.mousePosition.y}px`), e;
902
+ });
903
+ T(() => a.current, (e) => {
904
+ e !== void 0 && (E.value = e);
905
+ }), T(() => a.current, (e) => {
906
+ e !== void 0 && (E.value = e);
907
+ });
908
+ let H = () => {
909
+ y(!1), a.onClose?.(), o("close");
910
+ }, ue = () => {
911
+ P.value || H();
912
+ }, U = () => {
913
+ if (E.value > 0 || a.infinite) {
914
+ let e = E.value - 1 < 0 ? a.urls.length - 1 : E.value - 1;
915
+ x.value = !1, E.value = e, j("prev"), h(() => {
916
+ x.value = !0;
917
+ });
918
+ }
919
+ }, W = () => {
920
+ if (E.value < a.urls.length - 1 || a.infinite) {
921
+ let e = E.value + 1 > a.urls.length - 1 ? 0 : E.value + 1;
922
+ x.value = !1, E.value = e, j("next"), h(() => {
923
+ x.value = !0;
924
+ });
925
+ }
926
+ }, de = () => {
927
+ N(dt + (a.scaleStep ?? .5), "zoomIn");
928
+ }, fe = () => {
929
+ N(dt / (dt + (a.scaleStep ?? .5)), "zoomOut");
930
+ }, G = () => {
931
+ M({ rotate: A.value.rotate + 90 }, "rotateRight");
932
+ }, pe = () => {
933
+ M({ rotate: A.value.rotate - 90 }, "rotateLeft");
934
+ }, me = () => {
935
+ M({ flipX: !A.value.flipX }, "flipX");
936
+ }, he = () => {
937
+ M({ flipY: !A.value.flipY }, "flipY");
938
+ }, ge = async () => {
939
+ if (!(!z.value || O.value)) {
940
+ if (!navigator.clipboard || !window.ClipboardItem) {
941
+ I.error(Q.copyFailed);
942
+ return;
943
+ }
944
+ O.value = !0;
945
+ try {
946
+ let e = await gt(await mt(z.value));
947
+ await navigator.clipboard.write([new ClipboardItem(e)]), I.success(Q.copySuccess);
948
+ } catch {
949
+ I.error(Q.copyFailed);
950
+ } finally {
951
+ O.value = !1;
952
+ }
953
+ }
954
+ }, ve = async () => {
955
+ if (!(!z.value || k.value)) {
956
+ k.value = !0;
957
+ try {
958
+ let e = await mt(z.value);
959
+ vt(e, _t(z.value, e.type)), I.success(Q.downloadSuccess);
960
+ } catch {
961
+ I.error(Q.downloadFailed);
962
+ } finally {
963
+ k.value = !1;
964
+ }
965
+ }
966
+ }, J = (e) => {
967
+ _.value && (A.value.scale === 1 ? N(dt + (a.scaleStep ?? .5), "doubleClick", e.clientX, e.clientY) : M({
968
+ x: 0,
969
+ y: 0,
970
+ scale: 1
971
+ }, "doubleClick"));
972
+ }, ye = (e) => {
973
+ if (e.key === "Escape") {
974
+ H();
975
+ return;
976
+ }
977
+ !_.value || !B.value || (e.key === "ArrowLeft" ? U() : e.key === "ArrowRight" && W());
978
+ }, Y;
979
+ g(() => {
980
+ let e = (e) => ye(e);
981
+ window.addEventListener("keydown", e), Y = () => window.removeEventListener("keydown", e);
982
+ }), v(() => {
983
+ Y?.();
984
+ }), c({ setOpen: (e) => {
985
+ y(e), E.value = a.current ?? 0;
986
+ } });
987
+ let be = () => _e({
988
+ slots: s,
989
+ props: { ...a.icons },
990
+ keys: [
991
+ "flipY",
992
+ "flipX",
993
+ "rotateLeft",
994
+ "rotateRight",
995
+ "zoomOut",
996
+ "zoomIn",
997
+ "copy",
998
+ "download"
999
+ ],
1000
+ render: !0,
1001
+ defaultVNodes: [
1002
+ Z.flipY,
1003
+ Z.flipX,
1004
+ Z.rotateLeft,
1005
+ Z.rotateRight,
1006
+ Z.zoomOut,
1007
+ Z.zoomIn,
1008
+ Z.copy,
1009
+ Z.download
1010
+ ]
1011
+ }), xe = () => {
1012
+ let e = be();
1013
+ return [
1014
+ {
1015
+ icon: e.flipY,
1016
+ onClick: he,
1017
+ type: "flipY"
1018
+ },
1019
+ {
1020
+ icon: e.flipX,
1021
+ onClick: me,
1022
+ type: "flipX"
1023
+ },
1024
+ {
1025
+ icon: e.rotateLeft,
1026
+ onClick: pe,
1027
+ type: "rotateLeft"
1028
+ },
1029
+ {
1030
+ icon: e.rotateRight,
1031
+ onClick: G,
1032
+ type: "rotateRight"
1033
+ },
1034
+ {
1035
+ icon: e.zoomOut,
1036
+ onClick: fe,
1037
+ type: "zoomOut",
1038
+ disabled: r(() => A.value.scale <= (a.minScale ?? 1))
1039
+ },
1040
+ {
1041
+ icon: e.zoomIn,
1042
+ onClick: de,
1043
+ type: "zoomIn",
1044
+ disabled: r(() => A.value.scale === (a.maxScale ?? 50))
1045
+ },
1046
+ {
1047
+ icon: O.value ? i(te, { spin: !0 }, null) : e.copy,
1048
+ onClick: ge,
1049
+ type: "copy",
1050
+ disabled: r(() => O.value)
1051
+ },
1052
+ {
1053
+ icon: k.value ? i(te, { spin: !0 }, null) : e.download,
1054
+ onClick: ve,
1055
+ type: "download",
1056
+ disabled: r(() => k.value)
1057
+ }
1058
+ ];
1059
+ };
1060
+ return () => {
1061
+ let r = {
1062
+ transform: `translate3d(${A.value.x}px, ${A.value.y}px, 0) scale3d(${A.value.flipX ? "-" : ""}${A.value.scale}, ${A.value.flipY ? "-" : ""}${A.value.scale}, 1) rotate(${A.value.rotate}deg)`,
1063
+ transitionDuration: !x.value || F.value ? "0s" : void 0
1064
+ }, o = q({
1065
+ slots: s,
1066
+ props: { close: a.icons?.close },
1067
+ key: "close"
1068
+ }), c = q({
1069
+ slots: s,
1070
+ props: { left: a.icons?.left },
1071
+ key: "left"
1072
+ }), l = q({
1073
+ slots: s,
1074
+ props: { right: a.icons?.right },
1075
+ key: "right"
1076
+ }), u = `${d.value}-actions-action`, h = xe();
1077
+ return i(t, { to: a.getContainer || "body" }, { default: () => [i(n, {
1078
+ name: `${d.value}-fade`,
1079
+ appear: !0,
1080
+ onAfterLeave: () => j("close")
1081
+ }, { default: () => [_.value && i("div", {
1082
+ ref: w,
1083
+ class: K(d.value, p.value, m.value, f.value, {
1084
+ [`${d.value}-movable`]: a.movable,
1085
+ [`${d.value}-moving`]: P.value
1086
+ }),
1087
+ style: { zIndex: a.zIndex },
1088
+ role: "dialog",
1089
+ "aria-modal": "true",
1090
+ "aria-label": "Image",
1091
+ tabindex: -1
1092
+ }, [
1093
+ V.value.visible && i("div", {
1094
+ class: K(`${d.value}-mask`, a.maskClass, { [`${d.value}-mask-blur`]: V.value.blur }),
1095
+ onClick: a.onHideOnClickModal ? ue : void 0
1096
+ }, null),
1097
+ i("div", {
1098
+ class: `${d.value}-body`,
1099
+ style: le.value
1100
+ }, [i("img", {
1101
+ ref: C,
1102
+ class: `${d.value}-img`,
1103
+ src: z.value,
1104
+ alt: "Image",
1105
+ loading: "eager",
1106
+ decoding: "sync",
1107
+ style: r,
1108
+ onWheel: ie,
1109
+ onMousedown: re,
1110
+ onDblclick: J,
1111
+ onTouchstart: L,
1112
+ onTouchmove: R,
1113
+ onTouchend: se,
1114
+ onTouchcancel: se
1115
+ }, null)]),
1116
+ i("button", {
1117
+ type: "button",
1118
+ class: `${d.value}-close`,
1119
+ onClick: H
1120
+ }, [o || i(D, null, null)]),
1121
+ B.value && i(e, null, [i("button", {
1122
+ type: "button",
1123
+ class: K(`${d.value}-switch`, `${d.value}-switch-prev`, { [`${d.value}-switch-disabled`]: !a.infinite && E.value === 0 }),
1124
+ onClick: (e) => {
1125
+ e.preventDefault(), e.stopPropagation(), U();
1126
+ }
1127
+ }, [c || i(ee, null, null)]), i("button", {
1128
+ type: "button",
1129
+ class: K(`${d.value}-switch`, `${d.value}-switch-next`, { [`${d.value}-switch-disabled`]: !a.infinite && E.value === a.urls.length - 1 }),
1130
+ onClick: (e) => {
1131
+ e.preventDefault(), e.stopPropagation(), W();
1132
+ }
1133
+ }, [l || i(ne, null, null)])]),
1134
+ i("div", { class: `${d.value}-footer` }, [ce.value && i("div", { class: `${d.value}-progress` }, [a.countRender ? a.countRender(E.value + 1, a.urls.length) : `${E.value + 1} / ${a.urls.length}`]), i("div", { class: `${d.value}-actions` }, [h.map(({ icon: e, onClick: t, type: n, disabled: r }) => i("button", {
1135
+ type: "button",
1136
+ class: K(u, `${u}-${n}`, { [`${u}-disabled`]: r && r.value }),
1137
+ onClick: () => {
1138
+ r?.value || t();
1139
+ },
1140
+ disabled: r ? r.value : !1,
1141
+ "aria-label": n,
1142
+ key: n
1143
+ }, [e]))])])
1144
+ ])] })] });
1145
+ };
1146
+ }, {
1147
+ props: /* @__PURE__ */ p({
1148
+ class: {
1149
+ type: String,
1150
+ required: !1
1151
+ },
1152
+ style: {
1153
+ type: Object,
1154
+ required: !1
1155
+ },
1156
+ rootClass: {
1157
+ type: String,
1158
+ required: !1
1159
+ },
1160
+ prefixCls: {
1161
+ type: String,
1162
+ required: !1
1163
+ },
1164
+ urls: {
1165
+ type: Array,
1166
+ required: !0
1167
+ },
1168
+ open: {
1169
+ type: Boolean,
1170
+ required: !1,
1171
+ default: void 0
1172
+ },
1173
+ scaleStep: {
1174
+ type: Number,
1175
+ required: !1
1176
+ },
1177
+ minScale: {
1178
+ type: Number,
1179
+ required: !1
1180
+ },
1181
+ maxScale: {
1182
+ type: Number,
1183
+ required: !1
1184
+ },
1185
+ movable: {
1186
+ type: Boolean,
1187
+ required: !1,
1188
+ default: void 0
1189
+ },
1190
+ disabled: {
1191
+ type: Boolean,
1192
+ required: !1,
1193
+ default: void 0
1194
+ },
1195
+ zIndex: {
1196
+ type: Number,
1197
+ required: !1
1198
+ },
1199
+ current: {
1200
+ type: Number,
1201
+ required: !1
1202
+ },
1203
+ infinite: {
1204
+ type: Boolean,
1205
+ required: !1,
1206
+ default: void 0
1207
+ },
1208
+ getContainer: {
1209
+ type: String,
1210
+ required: !1
1211
+ },
1212
+ onHideOnClickModal: {
1213
+ type: Boolean,
1214
+ required: !1,
1215
+ default: void 0
1216
+ },
1217
+ mask: {
1218
+ type: [Object, Boolean],
1219
+ required: !1,
1220
+ default: void 0
1221
+ },
1222
+ maskClass: {
1223
+ type: String,
1224
+ required: !1
1225
+ },
1226
+ mousePosition: {
1227
+ type: [Object, null],
1228
+ required: !1
1229
+ },
1230
+ countRender: {
1231
+ type: [Function, Boolean],
1232
+ required: !1,
1233
+ default: void 0
1234
+ },
1235
+ icons: {
1236
+ type: Object,
1237
+ required: !1
1238
+ },
1239
+ onClose: {
1240
+ type: Function,
1241
+ required: !1
1242
+ },
1243
+ onTransform: {
1244
+ type: Function,
1245
+ required: !1
1246
+ },
1247
+ onOpenChange: {
1248
+ type: Function,
1249
+ required: !1
1250
+ },
1251
+ "onUpdate:open": {
1252
+ type: Function,
1253
+ required: !1
1254
+ }
1255
+ }, {
1256
+ open: !1,
1257
+ scaleStep: .5,
1258
+ minScale: 1,
1259
+ maxScale: 50,
1260
+ movable: !0,
1261
+ zIndex: 2e3,
1262
+ current: 0,
1263
+ infinite: !0,
1264
+ onHideOnClickModal: !0,
1265
+ urls: [],
1266
+ icons: {}
1267
+ }),
1268
+ emits: [
1269
+ "close",
1270
+ "transform",
1271
+ "update:open"
1272
+ ],
1273
+ name: "GImagePreview",
1274
+ inheritAttrs: !1
1275
+ }), bt = (e) => {
1276
+ let { motionDurationSlow: t, paddingXXS: n, marginXXS: r, colorTextLightSolid: i } = e;
1277
+ return {
1278
+ position: "absolute",
1279
+ inset: 0,
1280
+ display: "flex",
1281
+ alignItems: "center",
1282
+ justifyContent: "center",
1283
+ color: i,
1284
+ background: "rgba(0, 0, 0, 0.5)",
1285
+ cursor: "pointer",
1286
+ opacity: 0,
1287
+ transition: `opacity ${t}`,
1288
+ [`.${e.componentCls}-mask-info`]: {
1289
+ overflow: "hidden",
1290
+ whiteSpace: "nowrap",
1291
+ textOverflow: "ellipsis",
1292
+ padding: `0 ${F(n)}`,
1293
+ ".anticon": {
1294
+ marginInlineEnd: r,
1295
+ svg: { verticalAlign: "baseline" }
1296
+ }
1297
+ }
1298
+ };
1299
+ }, xt = (e) => {
1300
+ let t = {
1301
+ width: "100%",
1302
+ height: "100%"
1303
+ };
1304
+ return { [e.componentCls]: {
1305
+ display: "inline-block",
1306
+ position: "relative",
1307
+ overflow: "hidden",
1308
+ [`${e.componentCls}-img`]: {
1309
+ ...t,
1310
+ verticalAlign: "top",
1311
+ opacity: 1,
1312
+ [`&${e.componentCls}-img-preview`]: {
1313
+ userSelect: "none",
1314
+ cursor: "pointer"
1315
+ },
1316
+ "&-placeholder": {
1317
+ ...t,
1318
+ backgroundColor: e.colorBgContainerDisabled,
1319
+ backgroundImage: "url('data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHZpZXdCb3g9IjAgMCAxNiAxNiIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48cGF0aCBkPSJNMTQuNSAyLjVoLTEzQS41LjUgMCAwIDAgMSAzdjEwYS41LjUgMCAwIDAgLjUuNWgxM2EuNS41IDAgMCAwIC41LS41VjNhLjUuNSAwIDAgMC0uNS0uNXpNNS4yODEgNC43NWExIDEgMCAwIDEgMCAyIDEgMSAwIDAgMSAwLTJ6bTguMDMgNi44M2EuMTI3LjEyNyAwIDAgMS0uMDgxLjAzSDIuNzY5YS4xMjUuMTI1IDAgMCAxLS4wOTYtLjIwN2wyLjY2MS0zLjE1NmEuMTI2LjEyNiAwIDAgMSAuMTc3LS4wMTZsLjAxNi4wMTZMNy4wOCAxMC4wOWwyLjQ3LTIuOTNhLjEyNi4xMjYgMCAwIDEgLjE3Ny0uMDE2bC4wMTUuMDE2IDMuNTg4IDQuMjQ0YS4xMjcuMTI3IDAgMCAxLS4wMi4xNzV6IiBmaWxsPSIjOEM4QzhDIiBmaWxsLXJ1bGU9Im5vbnplcm8iLz48L3N2Zz4=')",
1320
+ backgroundRepeat: "no-repeat",
1321
+ backgroundPosition: "center center",
1322
+ backgroundSize: "30%"
1323
+ }
1324
+ },
1325
+ [`${e.componentCls}-error`]: {
1326
+ ...t,
1327
+ display: "flex",
1328
+ alignItems: "center",
1329
+ justifyContent: "center"
1330
+ },
1331
+ [`${e.componentCls}-placeholder`]: {
1332
+ position: "absolute",
1333
+ inset: 0
1334
+ },
1335
+ [`${e.componentCls}-mask`]: { ...bt(e) },
1336
+ [`${e.componentCls}-mask:hover`]: { opacity: 1 }
1337
+ } };
1338
+ }, St = ie("GImage", (e) => [xt(e)]), Ct = {
1339
+ src: "",
1340
+ alt: "",
1341
+ fit: "contain",
1342
+ preview: !0,
1343
+ loading: "eager"
1344
+ };
1345
+ function wt(e) {
1346
+ return e && e.nodeType === 1;
1347
+ }
1348
+ var $ = /* @__PURE__ */ o((t, { emit: n, slots: a, expose: o, attrs: s }) => {
1349
+ let c = Y && "loading" in HTMLImageElement.prototype, { prefixCls: l } = ae("pro-image", t), u = oe(l), [d, f] = St(l, u), p = b(), _ = b(!1), v = b(!0), y = b(), x = b(), S, C = r(() => t.loading === "eager" ? !1 : !c && t.loading === "lazy" || t.lazy), w = r(() => Y && t.fit ? {
1350
+ ...t.imageStyle,
1351
+ objectFit: t.fit
1352
+ } : { ...t.imageStyle }), E = r(() => typeof t.preview == "object" ? t.preview : {}), D = r(() => !!t.preview), O = r(() => {
1353
+ let { urls: e = [], current: n = 0 } = E.value;
1354
+ if (se(n)) return e.length >= n ? n : 0;
1355
+ let r = e.indexOf(t.src ?? "");
1356
+ return r >= 0 ? r : 0;
1357
+ }), k = r(() => F(t.width)), ee = r(() => F(t.height)), { showViewer: te, mousePosition: ne, openPreview: j, closePreview: M } = qe({ canPreview: D }), N = () => {
1358
+ Y && (v.value = !0, _.value = !1, p.value = t.src);
1359
+ }, P = (e) => {
1360
+ _.value || (v.value = !1, _.value = !1, t.onLoad?.(e), n("load", e));
1361
+ }, re = (e) => {
1362
+ v.value = !1, _.value = !0, t.onError?.(e), n("error", e);
1363
+ }, ie = () => {
1364
+ if (!y.value || !x.value) return !1;
1365
+ let e = y.value.getBoundingClientRect(), t = x.value.getBoundingClientRect ? x.value.getBoundingClientRect() : {
1366
+ top: 0,
1367
+ bottom: x.value.innerHeight ?? 0,
1368
+ left: 0,
1369
+ right: x.value.innerWidth ?? 0
1370
+ };
1371
+ return e.top < t.bottom && e.bottom > t.top && e.left < t.right && e.right > t.left;
1372
+ }, I = je(() => {
1373
+ ie() && (N(), S?.(), S = void 0);
1374
+ }, 200, !0), L = async () => {
1375
+ if (!Y) return;
1376
+ await h();
1377
+ let { scrollContainer: e } = t;
1378
+ wt(e) ? x.value = e : ce(e) && e !== "" ? x.value = document.querySelector(e) ?? void 0 : y.value && (x.value = me(y.value)), x.value && (S = X(x.value, "scroll", I), setTimeout(I, 100));
1379
+ }, R = (e) => {
1380
+ let r = v.value ? "loaded" : _.value ? "error" : "success";
1381
+ if (t.onClick?.(r), n("click", r), !(v.value || _.value) && D.value) {
1382
+ let t = e.currentTarget?.getBoundingClientRect();
1383
+ j(t ? {
1384
+ ...e,
1385
+ clientX: t.x + t.width / 2,
1386
+ clientY: t.y + t.height / 2
1387
+ } : e);
1388
+ }
1389
+ };
1390
+ return T(() => t.src, () => {
1391
+ C.value ? (v.value = !0, _.value = !1, S?.(), L()) : N();
1392
+ }), g(() => {
1393
+ C.value ? L() : N();
1394
+ }), o({ setOpen: (e) => {
1395
+ e ? j() : M();
1396
+ } }), () => {
1397
+ let n = {}, r = {};
1398
+ for (let [e, t] of Object.entries(s)) /^(?:data-|on[A-Z])/i.test(e) || [
1399
+ "id",
1400
+ "style",
1401
+ "class"
1402
+ ].includes(e) ? n[e] = t : r[e] = t;
1403
+ let o = _e({
1404
+ slots: a,
1405
+ props: t,
1406
+ keys: [
1407
+ "fallback",
1408
+ "mask",
1409
+ "placeholder"
1410
+ ],
1411
+ render: !0
1412
+ });
1413
+ return i("div", m({
1414
+ class: K(l.value, d.value, f.value, u.value, t.class),
1415
+ ref: y
1416
+ }, n, {
1417
+ style: {
1418
+ width: F(t.size) || k.value,
1419
+ height: F(t.size) || ee.value,
1420
+ ...n.style || {}
1421
+ },
1422
+ onClick: (e) => {
1423
+ _.value && R(e);
1424
+ }
1425
+ }), [
1426
+ _.value ? i("div", { class: K(`${l.value}-error`) }, [o.fallback]) : i(e, null, [i("img", m(r, {
1427
+ src: p.value,
1428
+ loading: t.loading,
1429
+ style: w.value,
1430
+ class: K(t.imageClass, `${l.value}-img`, {
1431
+ [`${l.value}-img-placeholder`]: t.placeholder === !0,
1432
+ [`${l.value}-img-preview`]: D.value
1433
+ }),
1434
+ crossorigin: t.crossOrigin,
1435
+ width: k.value,
1436
+ height: ee.value,
1437
+ onClick: R,
1438
+ onLoad: P,
1439
+ onError: re
1440
+ }), null), v.value && i("div", {
1441
+ class: K(`${l.value}-placeholder`),
1442
+ onClick: R
1443
+ }, [o.placeholder])]),
1444
+ E.value.mask && D.value && i("div", {
1445
+ class: K(`${l.value}-mask`, E.value.maskClass),
1446
+ style: { display: n.style?.display === "none" ? "none" : void 0 }
1447
+ }, [o.mask || i("div", { class: K(`${l.value}-mask-info`) }, [i(A, null, null)])]),
1448
+ D.value && i(yt, m(E.value, {
1449
+ urls: E.value.urls || (t.src ? [t.src] : []),
1450
+ current: O.value,
1451
+ zIndex: t.zIndex ?? E.value.zIndex,
1452
+ open: te.value,
1453
+ mousePosition: ne.value,
1454
+ onClose: () => M()
1455
+ }), a)
1456
+ ]);
1457
+ };
1458
+ }, {
1459
+ props: /* @__PURE__ */ p({
1460
+ rootClass: {
1461
+ type: String,
1462
+ required: !1
1463
+ },
1464
+ prefixCls: {
1465
+ type: String,
1466
+ required: !1
1467
+ },
1468
+ src: {
1469
+ type: String,
1470
+ required: !1
1471
+ },
1472
+ alt: {
1473
+ type: String,
1474
+ required: !1
1475
+ },
1476
+ width: {
1477
+ type: Number,
1478
+ required: !1
1479
+ },
1480
+ height: {
1481
+ type: Number,
1482
+ required: !1
1483
+ },
1484
+ size: {
1485
+ type: Number,
1486
+ required: !1
1487
+ },
1488
+ fit: {
1489
+ type: String,
1490
+ required: !1
1491
+ },
1492
+ loading: {
1493
+ type: String,
1494
+ required: !1
1495
+ },
1496
+ crossOrigin: {
1497
+ type: String,
1498
+ required: !1
1499
+ },
1500
+ imageStyle: {
1501
+ type: Object,
1502
+ required: !1
1503
+ },
1504
+ imageClass: {
1505
+ type: String,
1506
+ required: !1
1507
+ },
1508
+ preview: {
1509
+ type: [Boolean, Object],
1510
+ required: !1,
1511
+ default: void 0
1512
+ },
1513
+ zIndex: {
1514
+ type: Number,
1515
+ required: !1
1516
+ },
1517
+ lazy: {
1518
+ type: Boolean,
1519
+ required: !1,
1520
+ default: void 0
1521
+ },
1522
+ scrollContainer: { required: !1 },
1523
+ placeholder: {
1524
+ type: [
1525
+ Function,
1526
+ Object,
1527
+ String,
1528
+ Number,
1529
+ Boolean,
1530
+ null,
1531
+ Array
1532
+ ],
1533
+ required: !1,
1534
+ default: void 0
1535
+ },
1536
+ fallback: {
1537
+ type: [
1538
+ Function,
1539
+ Object,
1540
+ String,
1541
+ Number,
1542
+ Boolean,
1543
+ null,
1544
+ Array
1545
+ ],
1546
+ required: !1,
1547
+ default: void 0
1548
+ },
1549
+ onLoad: {
1550
+ type: Function,
1551
+ required: !1
1552
+ },
1553
+ onError: {
1554
+ type: Function,
1555
+ required: !1
1556
+ },
1557
+ onClick: {
1558
+ type: Function,
1559
+ required: !1
1560
+ },
1561
+ "onUpdate:open": {
1562
+ type: Function,
1563
+ required: !1
1564
+ }
1565
+ }, Ct),
1566
+ emits: [
1567
+ "click",
1568
+ "load",
1569
+ "error"
1570
+ ],
1571
+ name: "GImage",
1572
+ inheritAttrs: !1
1573
+ });
1574
+ $.isGImage = !0, $.install = (e) => (e.component($.name, $), e);
1575
+ var Tt = $;
1576
+ //#endregion
1577
+ export { Tt as GImage, yt as ImagePreview };