vistaview 0.7.7 → 0.10.9

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 (164) hide show
  1. package/README.md +276 -97
  2. package/dist/extensions/dailymotion-video.d.ts +2 -0
  3. package/dist/extensions/dailymotion-video.js +80 -0
  4. package/dist/extensions/dailymotion-video.umd.js +1 -0
  5. package/dist/extensions/download.d.ts +2 -0
  6. package/dist/extensions/download.js +35 -0
  7. package/dist/extensions/download.umd.js +1 -0
  8. package/dist/extensions/google-maps.d.ts +2 -0
  9. package/dist/extensions/google-maps.js +94 -0
  10. package/dist/extensions/google-maps.umd.js +1 -0
  11. package/dist/extensions/image-story.d.ts +2 -0
  12. package/dist/extensions/image-story.js +621 -0
  13. package/dist/extensions/image-story.umd.js +2 -0
  14. package/dist/extensions/logger.d.ts +2 -0
  15. package/dist/extensions/logger.js +23 -0
  16. package/dist/extensions/logger.umd.js +1 -0
  17. package/dist/extensions/mapbox.d.ts +2 -0
  18. package/dist/extensions/mapbox.js +124 -0
  19. package/dist/extensions/mapbox.umd.js +1 -0
  20. package/dist/extensions/openstreetmap.d.ts +2 -0
  21. package/dist/extensions/openstreetmap.js +125 -0
  22. package/dist/extensions/openstreetmap.umd.js +1 -0
  23. package/dist/extensions/streamable-video.d.ts +2 -0
  24. package/dist/extensions/streamable-video.js +76 -0
  25. package/dist/extensions/streamable-video.umd.js +1 -0
  26. package/dist/extensions/vidyard-video.d.ts +2 -0
  27. package/dist/extensions/vidyard-video.js +80 -0
  28. package/dist/extensions/vidyard-video.umd.js +1 -0
  29. package/dist/extensions/vimeo-video.d.ts +2 -0
  30. package/dist/extensions/vimeo-video.js +76 -0
  31. package/dist/extensions/vimeo-video.umd.js +1 -0
  32. package/dist/extensions/wistia-video.d.ts +2 -0
  33. package/dist/extensions/wistia-video.js +85 -0
  34. package/dist/extensions/wistia-video.umd.js +1 -0
  35. package/dist/extensions/youtube-video.d.ts +2 -0
  36. package/dist/extensions/youtube-video.js +88 -0
  37. package/dist/extensions/youtube-video.umd.js +1 -0
  38. package/dist/lib/components.d.ts +1 -3
  39. package/dist/lib/components.d.ts.map +1 -1
  40. package/dist/lib/defaults/image-setup.d.ts +3 -0
  41. package/dist/lib/defaults/image-setup.d.ts.map +1 -0
  42. package/dist/lib/defaults/init.d.ts.map +1 -1
  43. package/dist/lib/defaults/open.d.ts +3 -0
  44. package/dist/lib/defaults/open.d.ts.map +1 -0
  45. package/dist/lib/defaults/options.d.ts.map +1 -1
  46. package/dist/lib/defaults/transition.d.ts +1 -1
  47. package/dist/lib/defaults/transition.d.ts.map +1 -1
  48. package/dist/lib/extensions/dailymotion-video.d.ts +34 -0
  49. package/dist/lib/extensions/dailymotion-video.d.ts.map +1 -0
  50. package/dist/lib/extensions/download.d.ts +3 -0
  51. package/dist/lib/extensions/download.d.ts.map +1 -0
  52. package/dist/lib/extensions/google-maps.d.ts +49 -0
  53. package/dist/lib/extensions/google-maps.d.ts.map +1 -0
  54. package/dist/lib/extensions/image-story.d.ts +12 -0
  55. package/dist/lib/extensions/image-story.d.ts.map +1 -0
  56. package/dist/lib/extensions/logger.d.ts +3 -0
  57. package/dist/lib/extensions/logger.d.ts.map +1 -0
  58. package/dist/lib/extensions/mapbox.d.ts +53 -0
  59. package/dist/lib/extensions/mapbox.d.ts.map +1 -0
  60. package/dist/lib/extensions/openstreetmap.d.ts +51 -0
  61. package/dist/lib/extensions/openstreetmap.d.ts.map +1 -0
  62. package/dist/lib/extensions/streamable-video.d.ts +32 -0
  63. package/dist/lib/extensions/streamable-video.d.ts.map +1 -0
  64. package/dist/lib/extensions/vidyard-video.d.ts +33 -0
  65. package/dist/lib/extensions/vidyard-video.d.ts.map +1 -0
  66. package/dist/lib/extensions/vimeo-video.d.ts +36 -0
  67. package/dist/lib/extensions/vimeo-video.d.ts.map +1 -0
  68. package/dist/lib/extensions/wistia-video.d.ts +34 -0
  69. package/dist/lib/extensions/wistia-video.d.ts.map +1 -0
  70. package/dist/lib/extensions/youtube-video.d.ts +38 -0
  71. package/dist/lib/extensions/youtube-video.d.ts.map +1 -0
  72. package/dist/lib/main.d.ts +2 -2
  73. package/dist/lib/main.d.ts.map +1 -1
  74. package/dist/lib/types.d.ts +135 -43
  75. package/dist/lib/types.d.ts.map +1 -1
  76. package/dist/lib/utils/get-fitted-size.d.ts +5 -0
  77. package/dist/lib/utils/get-fitted-size.d.ts.map +1 -0
  78. package/dist/lib/utils/get-full-size-dim.d.ts +5 -0
  79. package/dist/lib/utils/get-full-size-dim.d.ts.map +1 -0
  80. package/dist/lib/utils/get-style.d.ts +5 -0
  81. package/dist/lib/utils/get-style.d.ts.map +1 -0
  82. package/dist/lib/utils/index.d.ts +3 -0
  83. package/dist/lib/utils/index.d.ts.map +1 -0
  84. package/dist/lib/utils/is-not-zero-css.d.ts +2 -0
  85. package/dist/lib/utils/is-not-zero-css.d.ts.map +1 -0
  86. package/dist/lib/utils/parse-element.d.ts +3 -0
  87. package/dist/lib/utils/parse-element.d.ts.map +1 -0
  88. package/dist/lib/vista-box.d.ts +107 -0
  89. package/dist/lib/vista-box.d.ts.map +1 -0
  90. package/dist/lib/vista-hires-transition.d.ts +32 -0
  91. package/dist/lib/vista-hires-transition.d.ts.map +1 -0
  92. package/dist/lib/vista-image-event.d.ts +23 -0
  93. package/dist/lib/vista-image-event.d.ts.map +1 -0
  94. package/dist/lib/vista-image.d.ts +33 -0
  95. package/dist/lib/vista-image.d.ts.map +1 -0
  96. package/dist/lib/{pointers.d.ts → vista-pointers.d.ts} +1 -1
  97. package/dist/lib/vista-pointers.d.ts.map +1 -0
  98. package/dist/lib/vista-state.d.ts +18 -0
  99. package/dist/lib/vista-state.d.ts.map +1 -0
  100. package/dist/lib/vista-view.d.ts +28 -31
  101. package/dist/lib/vista-view.d.ts.map +1 -1
  102. package/dist/react.d.ts +9 -9
  103. package/dist/react.d.ts.map +1 -1
  104. package/dist/react.js +59 -49
  105. package/dist/solid.d.ts +8 -11
  106. package/dist/solid.d.ts.map +1 -1
  107. package/dist/solid.js +28 -32
  108. package/dist/style.css +1 -1
  109. package/dist/styles/autumn-amber.css +1 -0
  110. package/dist/styles/autumn-amber.d.ts +1 -0
  111. package/dist/styles/cotton-candy.css +1 -0
  112. package/dist/styles/cotton-candy.d.ts +1 -0
  113. package/dist/styles/dark-rounded.css +1 -1
  114. package/dist/styles/ember-glow.css +1 -0
  115. package/dist/styles/ember-glow.d.ts +1 -0
  116. package/dist/styles/extensions/image-story.css +1 -0
  117. package/dist/styles/extensions/image-story.d.ts +1 -0
  118. package/dist/styles/forest-moss.css +1 -0
  119. package/dist/styles/forest-moss.d.ts +1 -0
  120. package/dist/styles/green-lake.css +1 -0
  121. package/dist/styles/green-lake.d.ts +1 -0
  122. package/dist/styles/ice-crystal.css +1 -0
  123. package/dist/styles/ice-crystal.d.ts +1 -0
  124. package/dist/styles/lavender-fields.css +1 -0
  125. package/dist/styles/lavender-fields.d.ts +1 -0
  126. package/dist/styles/midnight-gold.css +1 -0
  127. package/dist/styles/midnight-gold.d.ts +1 -0
  128. package/dist/styles/midnight-ocean.css +1 -0
  129. package/dist/styles/midnight-ocean.d.ts +1 -0
  130. package/dist/styles/mint-chocolate.css +1 -0
  131. package/dist/styles/mint-chocolate.d.ts +1 -0
  132. package/dist/styles/neon-nights.css +1 -0
  133. package/dist/styles/neon-nights.d.ts +1 -0
  134. package/dist/styles/paper-light.css +1 -0
  135. package/dist/styles/paper-light.d.ts +1 -0
  136. package/dist/styles/retro-arcade.css +1 -0
  137. package/dist/styles/retro-arcade.d.ts +1 -0
  138. package/dist/styles/soft-neutral.css +1 -0
  139. package/dist/styles/soft-neutral.d.ts +1 -0
  140. package/dist/styles/stark-minimal.css +1 -0
  141. package/dist/styles/stark-minimal.d.ts +1 -0
  142. package/dist/styles/strawberry.css +1 -0
  143. package/dist/styles/strawberry.d.ts +1 -0
  144. package/dist/svelte.d.ts +11 -2
  145. package/dist/svelte.d.ts.map +1 -1
  146. package/dist/svelte.js +36 -14
  147. package/dist/vista-box-CQvGrjln.js +318 -0
  148. package/dist/vistaview.d.ts +9 -2
  149. package/dist/vistaview.d.ts.map +1 -1
  150. package/dist/vistaview.js +740 -670
  151. package/dist/vistaview.umd.js +14 -7
  152. package/dist/vue.d.ts +28 -9
  153. package/dist/vue.d.ts.map +1 -1
  154. package/dist/vue.js +43 -24
  155. package/package.json +8 -3
  156. package/dist/lib/defaults/setup.d.ts +0 -3
  157. package/dist/lib/defaults/setup.d.ts.map +0 -1
  158. package/dist/lib/errors.d.ts +0 -4
  159. package/dist/lib/errors.d.ts.map +0 -1
  160. package/dist/lib/image-state.d.ts +0 -40
  161. package/dist/lib/image-state.d.ts.map +0 -1
  162. package/dist/lib/pointers.d.ts.map +0 -1
  163. package/dist/lib/utils.d.ts +0 -27
  164. package/dist/lib/utils.d.ts.map +0 -1
package/dist/vistaview.js CHANGED
@@ -1,109 +1,27 @@
1
- var F = Object.defineProperty;
2
- var A = (s, t, e) => t in s ? F(s, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : s[t] = e;
3
- var h = (s, t, e) => A(s, typeof t != "symbol" ? t + "" : t, e);
4
- function T(s) {
5
- return s && !/^0(px|%|r?em|vw|vh|vmin|vmax|cm|mm|in|pt|pc|ex|ch)?$/i.test(s.trim()) && s;
6
- }
7
- function R(s) {
8
- const e = window.getComputedStyle(s).objectFit || "", { width: i, height: n } = s.getBoundingClientRect(), r = s.naturalWidth, a = s.naturalHeight;
9
- if (!e)
10
- return { width: i, height: n };
11
- if (!r || !a)
12
- return { width: i, height: n };
13
- const o = r / a, l = i / n;
14
- switch (e) {
15
- case "fill":
16
- return { width: i, height: n };
17
- case "none":
18
- return { width: r, height: a };
19
- case "contain":
20
- return o > l ? { width: i, height: i / o } : { width: n * o, height: n };
21
- case "cover":
22
- return o < l ? { width: i, height: i / o } : { width: n * o, height: n };
23
- case "scale-down": {
24
- const c = { width: r, height: a }, d = o > l ? { width: i, height: i / o } : { width: n * o, height: n };
25
- return d.width <= c.width && d.height <= c.height ? d : c;
26
- }
1
+ var z = Object.defineProperty;
2
+ var T = (s, t, e) => t in s ? z(s, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : s[t] = e;
3
+ var r = (s, t, e) => T(s, typeof t != "symbol" ? t + "" : t, e);
4
+ import { V as D, a as L } from "./vista-box-CQvGrjln.js";
5
+ const I = {
6
+ // debug, don't remove
7
+ // animationDurationBase: 1000,
8
+ animationDurationBase: 333,
9
+ maxZoomLevel: 2,
10
+ preloads: 1,
11
+ keyboardListeners: !0,
12
+ arrowOnSmallScreens: !1,
13
+ rapidLimit: 222,
14
+ controls: {
15
+ topLeft: ["indexDisplay"],
16
+ topRight: ["zoomIn", "zoomOut", "close"],
17
+ bottomLeft: ["description"]
27
18
  }
28
- return { width: i, height: n };
29
- }
30
- function D(s) {
31
- const t = getComputedStyle(s), e = s.getBoundingClientRect();
32
- return {
33
- objectFit: t.objectFit,
34
- borderRadius: t.borderRadius,
35
- objectPosition: t.objectPosition,
36
- overflow: t.overflow,
37
- top: e.top,
38
- left: e.left,
39
- width: e.width,
40
- height: e.height,
41
- naturalWidth: s.naturalWidth,
42
- naturalHeight: s.naturalHeight
43
- };
44
- }
45
- function z(s) {
46
- const t = s.imageElm ? D(s.imageElm) : null, e = s.anchorElm ? D(s.anchorElm) : null, i = T(t == null ? void 0 : t.borderRadius), n = e && T(e == null ? void 0 : e.borderRadius), r = (n ? e == null ? void 0 : e.borderRadius : i ? t == null ? void 0 : t.borderRadius : "") || "";
47
- return {
48
- fit: (t == null ? void 0 : t.objectFit) || (e == null ? void 0 : e.objectFit) || "",
49
- pos: (t == null ? void 0 : t.objectPosition) || "",
50
- br: r,
51
- overflow: n ? e.overflow : i ? t.overflow : "",
52
- nw: (t == null ? void 0 : t.naturalWidth) || 0,
53
- nh: (t == null ? void 0 : t.naturalHeight) || 0,
54
- w: (e == null ? void 0 : e.width) || (t == null ? void 0 : t.width) || 0,
55
- h: (e == null ? void 0 : e.height) || (t == null ? void 0 : t.height) || 0,
56
- top: (e == null ? void 0 : e.top) || (t == null ? void 0 : t.top) || 0,
57
- left: (e == null ? void 0 : e.left) || (t == null ? void 0 : t.left) || 0
58
- };
59
- }
60
- function W(s, t, e, i = !1) {
61
- const {
62
- fit: n,
63
- w: r,
64
- h: a,
65
- // this ones makes things hard. not used.
66
- // pos,
67
- // overflow,
68
- nw: o,
69
- nh: l,
70
- br: c,
71
- top: d,
72
- left: p
73
- } = z(s), x = Math.min(Math.max(p, -r), window.innerWidth + r) - window.innerWidth / 2 + r / 2, g = Math.min(Math.max(d, -a), window.innerHeight + a) - window.innerHeight / 2 + a / 2, m = e.style;
74
- m.width = `${r}px`, m.height = `${a}px`, m.objectFit = n, e.width = o, e.height = l, m.setProperty("--vvw-init-radius", `${c}`), m.setProperty("--vvw-pulse-radius", `calc(1.3 * ${c})`), m.setProperty("--vvw-init-x", `${x}px`), m.setProperty("--vvw-init-y", `${g}px`), i && (m.setProperty("--vvw-current-x", `${x}px`), m.setProperty("--vvw-current-y", `${g}px`));
75
- const u = R(s.imageElm), b = Math.min(r, u.width), f = Math.min(a, u.height), v = t.style;
76
- v.setProperty("--vvw-init-radius", `${c}`), v.setProperty("--vvw-init-w", `${b}px`), v.setProperty("--vvw-init-h", `${f}px`), i && (v.setProperty("--vvw-current-radius", `${c}`), v.setProperty("--vvw-current-w", `${b}px`), v.setProperty("--vvw-current-h", `${f}px`), t.dataset.vvwWidth = b.toString(), t.dataset.vvwHeight = f.toString());
77
- }
78
- function H(s) {
79
- const t = window.innerWidth, e = window.innerHeight, i = s.naturalWidth, n = s.naturalHeight;
80
- if (!i || !n)
81
- throw new Error("Image natural dimensions are zero");
82
- if (i < t && n < e)
83
- return {
84
- width: i,
85
- height: n
86
- };
87
- const r = i / n, a = t / e;
88
- let o, l;
89
- return r > a ? (o = t, l = t / r) : (l = e, o = e * r), {
90
- width: o,
91
- height: l
92
- };
93
- }
94
- function q(s, t, e) {
95
- return Math.min(Math.max(s, t), e);
96
- }
97
- function L(s, t = 2) {
98
- const e = Math.pow(10, t);
99
- return Math.round(s * e) / e;
100
- }
101
- const k = '<svg viewBox="0 0 24 24"><path d="m15 18-6-6 6-6"/></svg>', O = '<svg viewBox="0 0 24 24"><path d="m9 18 6-6-6-6"/></svg>', Z = '<svg viewBox="0 0 24 24"><circle cx="11" cy="11" r="8"/><line x1="21" x2="16.65" y1="21" y2="16.65"/><line x1="11" x2="11" y1="8" y2="14"/><line x1="8" x2="14" y1="11" y2="11"/></svg>', N = '<svg viewBox="0 0 24 24"><circle cx="11" cy="11" r="8"/><line x1="21" x2="16.65" y1="21" y2="16.65"/><line x1="8" x2="14" y1="11" y2="11"/></svg>', X = '<svg viewBox="0 0 24 24"><path d="M18 6 6 18"/><path d="m6 6 12 12"/></svg>', Y = '<svg viewBox="0 0 24 24"><path d="M12 15V3"/><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><path d="m7 10 5 5 5-5"/></svg>';
102
- let $ = null;
103
- function B() {
104
- return $ || (window.trustedTypes || (window.trustedTypes = {
19
+ }, R = '<svg viewBox="0 0 24 24"><path d="m15 18-6-6 6-6"/></svg>', O = '<svg viewBox="0 0 24 24"><path d="m9 18 6-6-6-6"/></svg>', q = '<svg viewBox="0 0 24 24"><circle cx="11" cy="11" r="8"/><line x1="21" x2="16.65" y1="21" y2="16.65"/><line x1="11" x2="11" y1="8" y2="14"/><line x1="8" x2="14" y1="11" y2="11"/></svg>', M = '<svg viewBox="0 0 24 24"><circle cx="11" cy="11" r="8"/><line x1="21" x2="16.65" y1="21" y2="16.65"/><line x1="8" x2="14" y1="11" y2="11"/></svg>', H = '<svg viewBox="0 0 24 24"><path d="M18 6 6 18"/><path d="m6 6 12 12"/></svg>';
20
+ let E = null;
21
+ function W() {
22
+ return E || (window.trustedTypes || (window.trustedTypes = {
105
23
  createPolicy: (s, t) => t
106
- }), $ = window.trustedTypes.createPolicy("vistaView-policy", {
24
+ }), E = window.trustedTypes.createPolicy("vistaView-policy", {
107
25
  createHTML: (s) => s,
108
26
  // HTML is generated by us, not user input
109
27
  createScript: () => {
@@ -112,174 +30,404 @@ function B() {
112
30
  createScriptURL: () => {
113
31
  throw new Error("Not implemented");
114
32
  }
115
- }), $);
33
+ }), E);
116
34
  }
117
- function P(s) {
118
- const e = B().createHTML(s), i = document.createElement("template");
35
+ function F(s) {
36
+ const e = W().createHTML(s), i = document.createElement("template");
119
37
  i.innerHTML = e;
120
38
  const n = i.content;
121
39
  return i.remove(), n;
122
40
  }
123
- function j() {
124
- return {
125
- name: "download",
126
- icon: Y,
127
- onClick: async (s) => {
128
- var r;
129
- const t = await fetch(s.src), e = await t.blob(), i = t.url, n = document.createElement("a");
130
- n.href = URL.createObjectURL(e), n.download = ((r = i.split("/").pop()) == null ? void 0 : r.split("?")[0].split("#")[0]) || "download", document.body.appendChild(n), n.click(), document.body.removeChild(n);
131
- }
132
- };
133
- }
134
- function V(s) {
41
+ function A(s) {
135
42
  if (typeof s == "string")
136
43
  switch (s) {
137
44
  case "zoomIn":
138
- return `<button aria-label="Zoom In" class="vvw-zoom-in vvw-ui">${Z}</button>`;
45
+ return `<div class="vvw-ui"><button aria-label="Zoom In" class="vvw-zoom-in">${q}</button></div>`;
139
46
  case "zoomOut":
140
- return `<button aria-label="Zoom Out" disabled class="vvw-zoom-out vvw-ui">${N}</button>`;
47
+ return `<div class="vvw-ui"><button aria-label="Zoom Out" disabled class="vvw-zoom-out">${M}</button></div>`;
141
48
  case "close":
142
- return `<button aria-label="Close" class="vvw-close vvw-ui">${X}</button>`;
49
+ return `<div class="vvw-ui"><button aria-label="Close" class="vvw-close">${H}</button></div>`;
143
50
  case "indexDisplay":
144
51
  return '<div class="vvw-index vvw-ui" aria-hidden="true"></div>';
145
52
  case "description":
146
53
  return '<div class="vvw-desc vvw-ui" role="status" aria-live="polite" aria-atomic="true"></div>';
147
54
  default:
148
- return "";
55
+ return console.warn(`Unknown default control: ${s}. Will return empty string.`), "";
149
56
  }
150
- return `<button class="vvw-ui" aria-label="${s.description || s.name}" data-vvw-control="${s.name}">${s.icon}</button>`;
57
+ return `<div class="vvw-ext vvw-ui" aria-label="${s.description || s.name}" data-vvw-control="${s.name}"></div>`;
151
58
  }
152
- function U(s, t) {
153
- const e = document.createElement("div");
154
- e.className = "vvw-item", e.dataset.vvwPos = `${t !== void 0 ? t : ""}`, e.dataset.vvwIdx = s.index.toString(), e.appendChild(
155
- P(
156
- `<img class="vvw-img-lo" src="${s.thumb || s.src}" alt="${s.alt || ""}" />
157
- <img class="vvw-img-hi" src="${s.src}" alt="${s.alt || ""}" />`
158
- )
159
- );
160
- const i = e.querySelector("img.vvw-img-lo"), n = e.querySelector("img.vvw-img-hi");
161
- return W(s, n, i, t === 0), e;
162
- }
163
- function _({
59
+ function $({
164
60
  controls: s
165
61
  }) {
166
- const t = (i) => i ? i.map(V).join("") : "";
167
- return P(
62
+ const t = (i) => i ? i.map(A).join("") : "", e = F(
168
63
  `<div class="vvw-root" id="vvw-root">
169
64
  <div class="vvw-container">
170
65
  <div class="vvw-bg"></div>
171
66
  <div class="vvw-image-container"></div>
172
- <div class="vvw-top-bar"><div>${t(s == null ? void 0 : s.topLeft)}</div><div>${t(s == null ? void 0 : s.topCenter)}</div><div>${t(s == null ? void 0 : s.topRight)}</div></div>
173
- <div class="vvw-bottom-bar"><div>${t(s == null ? void 0 : s.bottomLeft)}</div><div>${t(s == null ? void 0 : s.bottomCenter)}</div><div>${t(s == null ? void 0 : s.bottomRight)}</div></div>
174
- <div class="vvw-prev vvw-ui"><button aria-label="Previous">${k}</button></div>
67
+ <div class="vvw-top-bar">
68
+ <div>${t(s == null ? void 0 : s.topLeft)}</div>
69
+ <div>${t(s == null ? void 0 : s.topCenter)}</div>
70
+ <div>${t(s == null ? void 0 : s.topRight)}</div>
71
+ </div>
72
+ <div class="vvw-bottom-bar">
73
+ <div>${t(s == null ? void 0 : s.bottomLeft)}</div>
74
+ <div>${t(s == null ? void 0 : s.bottomCenter)}</div>
75
+ <div>${t(s == null ? void 0 : s.bottomRight)}</div>
76
+ </div>
77
+ <div class="vvw-prev vvw-ui"><button aria-label="Previous">${R}</button></div>
175
78
  <div class="vvw-next vvw-ui"><button aria-label="Next">${O}</button></div>
176
79
  </div>
177
80
  </div>`
178
81
  );
82
+ return [
83
+ ...(s == null ? void 0 : s.topLeft) || [],
84
+ ...(s == null ? void 0 : s.topCenter) || [],
85
+ ...(s == null ? void 0 : s.topRight) || [],
86
+ ...(s == null ? void 0 : s.bottomLeft) || [],
87
+ ...(s == null ? void 0 : s.bottomCenter) || [],
88
+ ...(s == null ? void 0 : s.bottomRight) || []
89
+ ].forEach((i) => {
90
+ if (typeof i != "string" && i.control) {
91
+ const n = e.querySelector(`[data-vvw-control="${i.name}"]`), o = i.control();
92
+ n && o && n.appendChild(o);
93
+ }
94
+ }), e;
179
95
  }
180
- const M = {
181
- // debug, don't remove
182
- // animationDurationBase: 1000,
183
- animationDurationBase: 333,
184
- maxZoomLevel: 2,
185
- preloads: 1,
186
- keyboardListeners: !0,
187
- arrowOnSmallScreens: !1,
188
- rapidLimit: 222,
189
- controls: {
190
- topLeft: ["indexDisplay"],
191
- topRight: ["zoomIn", "zoomOut", j(), "close"],
192
- bottomLeft: ["description"]
193
- }
194
- };
195
- function K(s) {
96
+ function k(s) {
196
97
  }
197
- function G(s) {
198
- const t = s.options.preloads;
199
- s.imageContainer.style.width = `${(t * 2 + 1) * 100}vw`, s.imageContainer.style.left = `-${t * 100}vw`, s.imageContainer.style.display = "flex", J(s);
98
+ function V(s) {
99
+ N(s);
200
100
  }
201
- function J(s) {
101
+ function N(s) {
202
102
  let t = { x: 0, y: 0 }, e = { x: 0, y: 0 }, i = null;
203
103
  s.registerPointerListener((n) => {
204
- var r;
104
+ var o;
205
105
  if (!n.hasInternalExecution && !(n.pointers.length > 1)) {
206
- if (n.event === "down" && (t = { x: n.pointer.x, y: n.pointer.y }, e = { x: n.pointer.x, y: n.pointer.y }, (r = n.abortController) == null || r.abort()), n.event === "move") {
106
+ if (n.event === "down" && (t = { x: n.pointer.x, y: n.pointer.y }, e = { x: n.pointer.x, y: n.pointer.y }, (o = n.abortController) == null || o.abort()), n.event === "move") {
207
107
  e = { x: n.pointer.x, y: n.pointer.y };
208
- const a = e.x - t.x, o = e.y - t.y;
209
- if (!i && Math.abs(o) > Math.abs(a) || i === "y") {
210
- const l = o / window.innerHeight * 100;
108
+ const a = e.x - t.x, h = e.y - t.y;
109
+ if (!i && Math.abs(h) > Math.abs(a) || i === "y") {
110
+ const l = h / window.innerHeight * 100;
211
111
  s.imageContainer.style.transition = "none", s.imageContainer.style.transform = `translateY(${l}vh)`, i = "y";
212
- } else if (!i && Math.abs(a) > Math.abs(o) || i === "x") {
112
+ } else if (!i && Math.abs(a) > Math.abs(h) || i === "x" && n.state.elmLength > 1) {
213
113
  const l = a / window.innerWidth * 100;
214
114
  s.imageContainer.style.transition = "none", s.imageContainer.style.transform = `translateX(${l}vw)`, i = "x";
215
115
  }
216
116
  }
217
117
  if (n.event === "up" || n.event === "cancel") {
218
- let a = function(o) {
118
+ let a = function(h) {
219
119
  var l;
220
- (l = s.imageContainer) == null || l.addEventListener("transitionend", function c() {
221
- var d;
222
- (d = s.imageContainer) == null || d.removeEventListener("transitionend", c), s.imageContainer.style.transition = "", s.imageContainer.style.transform = "";
223
- }), s.imageContainer.style.transition = "transform 222ms ease", s.imageContainer.style.transform = o;
120
+ (l = s.imageContainer) == null || l.addEventListener("transitionend", function d() {
121
+ var p;
122
+ (p = s.imageContainer) == null || p.removeEventListener("transitionend", d), s.imageContainer.style.transition = "", s.imageContainer.style.transform = "";
123
+ }), s.imageContainer.style.transition = "transform 222ms ease", s.imageContainer.style.transform = h;
224
124
  };
225
125
  if (i === "y") {
226
- const o = e.y - t.y;
227
- Math.abs(o) > 144 ? (s.imageContainer.style.transition = "transform 222ms ease", s.imageContainer.style.transform = "translateY(0vh)", s.close()) : a("translateY(0vh)");
126
+ const h = e.y - t.y;
127
+ Math.abs(h) > 144 ? (s.imageContainer.style.transition = "transform 222ms ease", s.imageContainer.style.transform = "translateY(0vh)", s.close()) : a("translateY(0vh)");
228
128
  }
229
- if (i === "x") {
230
- const o = e.x - t.x, l = n.pointer.movementX, c = 1;
231
- s.imageContainer.style.transition = "", o > 0 && Math.abs(l) > c ? s.prev() : o < 0 && Math.abs(l) > c ? s.next() : a("translateX(0vw)");
129
+ if (i === "x" && n.state.elmLength > 1) {
130
+ const h = e.x - t.x;
131
+ s.imageContainer.style.transition = "", h > 64 ? s.prev() : h < -64 ? s.next() : a("translateX(0vw)");
232
132
  }
233
133
  i = null, t = { x: 0, y: 0 }, e = { x: 0, y: 0 };
234
134
  }
235
135
  }
236
136
  });
237
137
  }
238
- function Q(s) {
138
+ function B(s) {
139
+ const t = s.options.preloads;
140
+ s.imageContainer.style.width = `${(t * 2 + 1) * 100}vw`, s.imageContainer.style.left = `-${t * 100}vw`, s.imageContainer.style.display = "flex";
141
+ }
142
+ function X(s) {
239
143
  }
240
- function tt({
241
- vistaView: { isReducedMotion: s },
242
- htmlElements: { to: t },
243
- index: { from: e, to: i },
244
- vistaView: { elements: n, imageContainer: r, options: a }
245
- }, o) {
246
- if (!(!t || o.aborted || s || !(Math.abs(i - e) === 1 || e === 0 && i === n.length - 1 || e === n.length - 1 && i === 0)))
144
+ function Y({ vistaView: s, htmlElements: { to: t }, index: { from: e, to: i } }, n) {
145
+ const { imageContainer: o, options: a } = s, { isReducedMotion: h } = s.state;
146
+ if (!(!t || n.aborted || h || !(Math.abs(i - e) === 1 || e === 0 && i === s.state.elmLength - 1 || e === s.state.elmLength - 1 && i === 0)))
247
147
  return {
248
148
  cleanup: () => {
249
- r.style.transition = "", r.style.transform = "";
149
+ o.style.transition = "", o.style.transform = "";
250
150
  },
251
- transitionEnded: new Promise((c) => {
252
- r.addEventListener(
151
+ transitionEnded: new Promise((d) => {
152
+ o.addEventListener(
253
153
  "transitionend",
254
154
  () => {
255
- c();
155
+ d();
256
156
  },
257
157
  { once: !0 }
258
- ), r.addEventListener(
158
+ ), o.addEventListener(
259
159
  "transitioncancel",
260
160
  () => {
261
- o.aborted && c();
161
+ n.aborted && d();
262
162
  },
263
163
  { once: !0 }
264
164
  );
265
- const d = Math.round(a.animationDurationBase * 100) / 100, p = i === e + 1 || e === n.length - 1 && i === 0 ? "translateX(-100vw)" : "translateX(100vw)";
266
- r.style.transition = `transform ${d}ms ease`, r.style.transform = p;
165
+ const p = Math.round(a.animationDurationBase * 100) / 100, u = i === e + 1 || e === s.state.elmLength - 1 && i === 0 ? "translateX(-100vw)" : "translateX(100vw)";
166
+ o.style.transition = `transform ${p}ms ease`, o.style.transform = u;
267
167
  })
268
168
  };
269
169
  }
270
- class et {
170
+ function P(s) {
171
+ const t = window.innerWidth, e = window.innerHeight, i = s.naturalWidth, n = s.naturalHeight;
172
+ if (!i || !n)
173
+ throw console.error("Error", s), new Error("Image natural dimensions are zero");
174
+ if (i < t && n < e)
175
+ return {
176
+ width: i,
177
+ height: n
178
+ };
179
+ const o = i / n, a = t / e;
180
+ let h, l;
181
+ return o > a ? (h = t, l = t / o) : (l = e, h = e * o), {
182
+ width: h,
183
+ height: l
184
+ };
185
+ }
186
+ class U extends D {
187
+ constructor(e) {
188
+ super(e);
189
+ r(this, "element");
190
+ r(this, "rect", null);
191
+ r(this, "animateNormalizeTimeout", null);
192
+ const i = document.createElement("img");
193
+ i.alt = this.config.alt || "", i.classList.add("vvw-img-hi"), this.element = i, i.onerror = (n) => {
194
+ this.isLoadedRejected(n);
195
+ }, i.src = this.config.src, i.decode().then(() => {
196
+ this.onLoad();
197
+ }).catch((n) => {
198
+ this.isLoadedRejected(n);
199
+ }), this.setSizes({
200
+ stableSize: !1,
201
+ initDimension: !0
202
+ });
203
+ }
204
+ onWidthChange(e) {
205
+ super.onWidthChange(e);
206
+ const i = this.getFromParsedSrcSet(e);
207
+ if (i && this.element.src !== i) {
208
+ const n = new Image();
209
+ n.onload = () => {
210
+ n.decode().then(() => {
211
+ this.isCancelled || (this.element.src = i);
212
+ });
213
+ }, n.src = i;
214
+ }
215
+ }
216
+ onLoad() {
217
+ if (this.isCancelled) return;
218
+ const e = this.element;
219
+ e.width = e.naturalWidth, e.height = e.naturalHeight, this.maxW = e.naturalWidth * this.maxZoomLevel;
220
+ const { width: i, height: n } = P(e);
221
+ this.fullH = n, this.fullW = i, this.minW = this.fullW * 0.5, this.isLoadedResolved(!0);
222
+ }
223
+ getFullSizeDim() {
224
+ return P(this.element);
225
+ }
226
+ normalize() {
227
+ super.normalize();
228
+ const e = this.element;
229
+ e.style.objectFit = "cover", e.style.borderRadius = "0";
230
+ }
231
+ // Used by: VistaImageEvent
232
+ scaleMove(e, i, n = !1) {
233
+ if (!this.isReady || !this.element) return;
234
+ this.rect || (this.rect = this.element.getBoundingClientRect()), i || (i = this.initPointerCenter);
235
+ const o = this.rect.left + this.rect.width / 2, a = this.rect.top + this.rect.height / 2, h = this.initPointerCenter.x - o, l = this.initPointerCenter.y - a, d = h * (1 - e), p = l * (1 - e), u = i.x - this.initPointerCenter.x, v = i.y - this.initPointerCenter.y;
236
+ n ? L.start({
237
+ vistaImage: this,
238
+ target: {
239
+ transform: {
240
+ x: d + u,
241
+ y: p + v,
242
+ scale: e
243
+ }
244
+ },
245
+ onComplete: () => {
246
+ this.setFinalTransform();
247
+ },
248
+ shouldWait: () => !1
249
+ }) : this.state.transform = {
250
+ x: d + u,
251
+ y: p + v,
252
+ scale: e
253
+ };
254
+ const m = this.element.getBoundingClientRect().width * e;
255
+ this.isZoomedIn = m > this.fullW, this.state.lessThanMinWidth = m <= this.minW, this.onScale({
256
+ vistaImage: this,
257
+ scale: m / this.fullW,
258
+ isMax: m >= this.maxW,
259
+ isMin: m <= this.fullW
260
+ });
261
+ }
262
+ animateZoom(e, i) {
263
+ this.state.width * e < this.minW || this.scaleMove(e, i, !0);
264
+ }
265
+ // Used by: VistaImageEvent
266
+ momentumThrow(e) {
267
+ if (!this.isReady)
268
+ return () => {
269
+ };
270
+ if (!this.isThrowing)
271
+ return this.setFinalTransform(), () => {
272
+ };
273
+ if (Math.abs(e.x) < 0.1 && Math.abs(e.y) < 0.1) {
274
+ const n = this.element.getBoundingClientRect();
275
+ return L.start({
276
+ vistaImage: this,
277
+ target: {
278
+ transform: {
279
+ x: n.right < window.innerWidth / 2 ? this.state.transform.x + (window.innerWidth / 2 - n.right) : n.left > window.innerWidth / 2 ? this.state.transform.x - (n.left - window.innerWidth / 2) : this.state.transform.x,
280
+ y: n.bottom < window.innerHeight / 2 ? this.state.transform.y + (window.innerHeight / 2 - n.bottom) : n.top > window.innerHeight / 2 ? this.state.transform.y - (n.top - window.innerHeight / 2) : this.state.transform.y
281
+ }
282
+ },
283
+ onComplete: () => {
284
+ this.isThrowing = !1, this.setFinalTransform();
285
+ },
286
+ shouldWait: () => !1
287
+ }), () => {
288
+ };
289
+ }
290
+ return requestAnimationFrame(() => {
291
+ if (!this.isThrowing) return this.momentumThrow({ x: 0, y: 0 });
292
+ const i = this.element, n = this.state.transform;
293
+ n.x += e.x, n.y += e.y;
294
+ const o = i.getBoundingClientRect();
295
+ n.x = n.x + e.x, n.y = n.y + e.y, o.right < window.innerWidth / 2 && (n.x += (window.innerWidth / 2 - o.right) * 0.1, e.x *= 0.7), o.left > window.innerWidth / 2 && (n.x -= (o.left - window.innerWidth / 2) * 0.1, e.x *= 0.7), o.bottom < window.innerHeight / 2 && (n.y += (window.innerHeight / 2 - o.bottom) * 0.1, e.y *= 0.7), o.top > window.innerHeight / 2 && (n.y -= (o.top - window.innerHeight / 2) * 0.1, e.y *= 0.7), this.state.transform = n, this.momentumThrow({
296
+ x: e.x * 0.9,
297
+ y: e.y * 0.9
298
+ });
299
+ }), () => {
300
+ L.stop(this), this.isThrowing = !1, this.setFinalTransform();
301
+ };
302
+ }
303
+ animateNormalize() {
304
+ this.animateNormalizeTimeout && clearTimeout(this.animateNormalizeTimeout), this.animateNormalizeTimeout = setTimeout(() => {
305
+ L.start({
306
+ vistaImage: this,
307
+ target: {
308
+ width: this.fullW,
309
+ height: this.fullH,
310
+ translate: { x: 0, y: 0 },
311
+ transform: { x: 0, y: 0, scale: 1 }
312
+ },
313
+ onComplete: () => {
314
+ this.setFinalTransform();
315
+ },
316
+ shouldWait: () => !1
317
+ });
318
+ }, 50);
319
+ }
320
+ // Used by: VistaImageEvent
321
+ setFinalTransform() {
322
+ if (!this.isReady) return;
323
+ this.rect = null, super.setFinalTransform({ propagateEvent: !1 });
324
+ const e = this.state.width <= this.minW;
325
+ if (this.state.width > this.maxW)
326
+ this.animateZoom(this.maxW / this.state.width);
327
+ else if (!e && this.state.width < this.fullW)
328
+ this.animateNormalize();
329
+ else if (this.pos === 0) {
330
+ const i = this.toObject();
331
+ this.vistaView.options.onContentChange && this.vistaView.options.onContentChange(i, this.vistaView), this.vistaView.state.extensions.forEach((n) => {
332
+ n.onContentChange && n.onContentChange(i, this.vistaView);
333
+ });
334
+ }
335
+ return {
336
+ close: e,
337
+ cancel: () => L.stop(this)
338
+ };
339
+ }
340
+ }
341
+ class Z {
342
+ constructor() {
343
+ r(this, "fiolast", {});
344
+ }
345
+ // first in out
346
+ fio(t, e, i = 50) {
347
+ const o = Date.now() - (this.fiolast[e] ?? 0), a = () => {
348
+ this.fiolast[e] = Date.now(), t();
349
+ };
350
+ if (!this.fiolast[e]) {
351
+ a();
352
+ return;
353
+ }
354
+ o >= i && a();
355
+ }
356
+ }
357
+ class j {
358
+ constructor() {
359
+ r(this, "open", !1);
360
+ r(this, "settled", !1);
361
+ r(this, "closing", !1);
362
+ r(this, "zoomedIn", !1);
363
+ r(this, "children", {
364
+ htmls: [],
365
+ images: []
366
+ });
367
+ r(this, "currentIndex", -1);
368
+ r(this, "elmLength", 0);
369
+ r(this, "abortController", new AbortController());
370
+ r(this, "isReducedMotion", !1);
371
+ r(this, "extensions", /* @__PURE__ */ new Set());
372
+ }
373
+ }
374
+ function S(s) {
375
+ return s && !/^0(px|%|r?em|vw|vh|vmin|vmax|cm|mm|in|pt|pc|ex|ch)?$/i.test(s.trim()) && s;
376
+ }
377
+ function _(s) {
378
+ const t = s instanceof HTMLAnchorElement ? s : null, e = s instanceof HTMLImageElement ? s : t == null ? void 0 : t.querySelector("img"), i = t ? getComputedStyle(t) : null, n = e ? getComputedStyle(e) : null;
379
+ let o = "0px", a = n ? n.objectFit : "contain";
380
+ return i && S(i.borderRadius) ? o = i.borderRadius : n && S(n.borderRadius) && (o = n.borderRadius), {
381
+ borderRadius: o,
382
+ objectFit: a
383
+ };
384
+ }
385
+ function K(s) {
386
+ const t = s.split(",").map((i) => i.trim()), e = [];
387
+ for (const i of t) {
388
+ const [n, o] = i.split(" ").map((a) => a.trim());
389
+ if (n && o && o.endsWith("w")) {
390
+ const a = parseInt(o.slice(0, -1), 10);
391
+ isNaN(a) || e.push({ src: n, width: a });
392
+ }
393
+ }
394
+ return e;
395
+ }
396
+ function G(s) {
397
+ const t = s instanceof HTMLImageElement ? s : s.querySelector("img"), e = s.dataset.vistaviewSrc || s.getAttribute("href") || s.getAttribute("src") || (t == null ? void 0 : t.getAttribute("src")) || "", i = s.dataset.vistaviewSrcset || s.getAttribute("srcset") || (t == null ? void 0 : t.getAttribute("srcset")) || "";
398
+ if (!e && !i)
399
+ throw console.error("VistaView Error:", s), new Error("VistaView: Element must have href, src, or srcSet");
400
+ const n = i ? K(i) : void 0, o = _(s);
401
+ return {
402
+ config: {
403
+ src: e,
404
+ alt: s.dataset.vistaviewAlt || s.getAttribute("alt") || (t == null ? void 0 : t.getAttribute("alt")) || "",
405
+ srcSet: i || void 0
406
+ },
407
+ parsedSrcSet: n != null && n.length ? n : void 0,
408
+ origin: {
409
+ anchor: s instanceof HTMLAnchorElement ? s : void 0,
410
+ image: t,
411
+ src: e,
412
+ srcSet: i,
413
+ borderRadius: o.borderRadius,
414
+ objectFit: o.objectFit
415
+ }
416
+ };
417
+ }
418
+ class J {
271
419
  constructor({ elm: t, listeners: e }) {
272
- h(this, "pointers", []);
273
- h(this, "elm");
274
- h(this, "listeners", []);
275
- h(this, "lastPointerDownId", null);
276
- h(this, "removeLastPointer", () => {
420
+ r(this, "pointers", []);
421
+ r(this, "elm");
422
+ r(this, "listeners", []);
423
+ r(this, "lastPointerDownId", null);
424
+ r(this, "removeLastPointer", () => {
277
425
  if (this.pointers.length && this.lastPointerDownId !== null) {
278
426
  const t = this.pointers.findIndex((e) => e.id === this.lastPointerDownId);
279
427
  t !== -1 && this.pointers.splice(t, 1);
280
428
  }
281
429
  });
282
- h(this, "onPointerDown", (t) => {
430
+ r(this, "onPointerDown", (t) => {
283
431
  if (!this.listeners.length || t.button !== 0) return;
284
432
  t.preventDefault(), this.lastPointerDownId = t.pointerId, window.addEventListener("contextmenu", this.removeLastPointer, { once: !0 }), window.addEventListener("auxclick", this.removeLastPointer, { once: !0 });
285
433
  let e = {
@@ -298,7 +446,7 @@ class et {
298
446
  })
299
447
  );
300
448
  });
301
- h(this, "onPointerMove", (t) => {
449
+ r(this, "onPointerMove", (t) => {
302
450
  if (!this.listeners.length) return;
303
451
  t.preventDefault();
304
452
  const e = this.pointers.find((i) => i.id === t.pointerId);
@@ -311,17 +459,17 @@ class et {
311
459
  })
312
460
  ));
313
461
  });
314
- h(this, "onPointerUp", (t) => {
462
+ r(this, "onPointerUp", (t) => {
315
463
  if (!this.listeners.length || t.button !== 0 || (window.removeEventListener("contextmenu", this.removeLastPointer), window.removeEventListener("auxclick", this.removeLastPointer), t.target instanceof Node && !this.elm.contains(t.target) && t.target !== document.querySelector("html") && t.target !== document))
316
464
  return;
317
465
  t.preventDefault();
318
- const e = this.pointers.findIndex((r) => r.id === t.pointerId);
466
+ const e = this.pointers.findIndex((o) => o.id === t.pointerId);
319
467
  if (e === -1) return;
320
468
  const i = this.pointers[e];
321
469
  i.x = t.clientX, i.y = t.clientY;
322
470
  const n = this.pointers.length;
323
471
  this.pointers.splice(e, 1), this.listeners.forEach(
324
- (r) => r({
472
+ (o) => o({
325
473
  event: "up",
326
474
  pointer: i,
327
475
  pointers: this.pointers,
@@ -329,17 +477,17 @@ class et {
329
477
  })
330
478
  );
331
479
  });
332
- h(this, "onPointerCancel", (t) => {
480
+ r(this, "onPointerCancel", (t) => {
333
481
  if (!this.listeners.length || t.target instanceof Node && !this.elm.contains(t.target) && t.target !== document.querySelector("html") && t.target !== document)
334
482
  return;
335
483
  t.preventDefault();
336
- const e = this.pointers.findIndex((r) => r.id === t.pointerId);
484
+ const e = this.pointers.findIndex((o) => o.id === t.pointerId);
337
485
  if (e === -1) return;
338
486
  const i = this.pointers[e];
339
487
  i.x = t.clientX, i.y = t.clientY;
340
488
  const n = this.pointers.length;
341
489
  this.pointers.splice(e, 1), this.listeners.forEach(
342
- (r) => r({
490
+ (o) => o({
343
491
  event: "cancel",
344
492
  pointer: i,
345
493
  pointers: this.pointers,
@@ -377,557 +525,472 @@ class et {
377
525
  };
378
526
  }
379
527
  }
380
- class it {
381
- constructor(t, e) {
382
- h(this, "maxZoomLevel");
383
- h(this, "image", null);
384
- h(this, "rect", null);
385
- h(this, "initialCenter", { x: 0, y: 0 });
386
- h(this, "maxDimension", { width: 0 });
387
- h(this, "minDimension", { initialWidth: 0, initialHeight: 0, minWidth: 0, closingWidth: 0 });
388
- h(this, "accumulatedTranslate", { x: 0, y: 0 });
389
- // state
390
- h(this, "scale", 1);
391
- h(this, "translate", { x: 0, y: 0 });
392
- h(this, "onScale", null);
393
- h(this, "animationTimestamp", 0);
394
- this.maxZoomLevel = t, this.onScale = e;
395
- }
396
- clean() {
397
- this.image && (this.image.style.transform = "", this.image.style.width = "", this.image.style.height = "", this.image.style.top = "", this.image.style.left = "", this.image.style.opacity = "");
398
- }
399
- reset() {
400
- this.clean(), this.image = null, this.rect = null, this.initialCenter = { x: window.innerWidth / 2, y: window.innerHeight / 2 }, this.maxDimension = { width: 0 }, this.minDimension = { initialWidth: 0, initialHeight: 0, minWidth: 0, closingWidth: 0 }, this.accumulatedTranslate = { x: 0, y: 0 }, this.scale = 1, this.translate = { x: 0, y: 0 };
401
- }
402
- setCurrentImage(t) {
403
- if (this.rect = null, this.image = t, this.maxDimension = {
404
- width: t.naturalWidth * this.maxZoomLevel
405
- }, !t.dataset.vvwWidth || !t.dataset.vvwHeight)
406
- throw new Error("VistaImageState: Image dataset vvwWidth or vvwHeight not set.");
407
- const e = parseFloat(t.dataset.vvwWidth), i = parseFloat(t.dataset.vvwHeight);
408
- this.minDimension = {
409
- initialWidth: e,
410
- initialHeight: i,
411
- minWidth: e * 0.1,
412
- closingWidth: e * 0.5
413
- }, this.accumulatedTranslate = { x: 0, y: 0 };
414
- }
415
- setInitialCenter(t) {
416
- this.initialCenter = t || { x: window.innerWidth / 2, y: window.innerHeight / 2 };
417
- }
418
- move(t) {
419
- this.image && (this.rect || (this.rect = this.image.getBoundingClientRect()), this.translate.x = L(t.x - this.initialCenter.x), this.translate.y = L(t.y - this.initialCenter.y), this.image.style.transform = `translate3d(${this.translate.x}px, ${this.translate.y}px, 0px) scale(${this.scale})`);
420
- }
421
- snapToTargetIfClose(t, e, i = 1) {
422
- return Math.abs(t - e) <= i && (t = e), t;
423
- }
424
- scaleMove(t, e) {
425
- if (!this.image) return;
426
- this.rect || (this.rect = this.image.getBoundingClientRect()), e || (e = this.initialCenter);
427
- const i = this.snapToTargetIfClose(
428
- q(this.rect.width * t, this.minDimension.minWidth, this.maxDimension.width),
429
- this.minDimension.initialWidth
430
- );
431
- this.onScale && this.onScale({
432
- scale: i / (this.maxDimension.width / this.maxZoomLevel),
433
- isMax: i >= this.maxDimension.width,
434
- isMin: i <= this.minDimension.initialWidth
435
- }), this.scale = L(i / this.rect.width);
436
- const n = this.rect.left + this.rect.width / 2, r = this.rect.top + this.rect.height / 2, a = this.initialCenter.x - n, o = this.initialCenter.y - r, l = a * (1 - this.scale), c = o * (1 - this.scale), d = e.x - this.initialCenter.x, p = e.y - this.initialCenter.y;
437
- this.translate.x = L(l + d), this.translate.y = L(c + p), this.image.style.transform = `translate3d(${this.translate.x}px, ${this.translate.y}px, 0px) scale(${this.scale})`, i <= this.minDimension.closingWidth ? this.image.style.opacity = "0.5" : this.image.style.opacity = "";
438
- }
439
- moveAndNormalize(t) {
440
- let e = 0, i = !1;
441
- const n = ({ x: r, y: a }) => {
442
- if (i)
443
- return;
444
- if (Math.abs(r) < 1e-3 && Math.abs(a) < 1e-3)
445
- return this.normalize();
446
- r *= 0.9, a *= 0.9;
447
- const o = this.image.getBoundingClientRect();
448
- this.translate.x = L(this.translate.x + r), this.translate.y = L(this.translate.y + a), o.right < window.innerWidth / 2 && (this.translate.x += (window.innerWidth / 2 - o.right) * 0.1, r *= 0.7), o.left > window.innerWidth / 2 && (this.translate.x -= (o.left - window.innerWidth / 2) * 0.1, r *= 0.7), o.bottom < window.innerHeight / 2 && (this.translate.y += (window.innerHeight / 2 - o.bottom) * 0.1, a *= 0.7), o.top > window.innerHeight / 2 && (this.translate.y -= (o.top - window.innerHeight / 2) * 0.1, a *= 0.7), this.image.style.transform = `translate3d(${this.translate.x}px, ${this.translate.y}px, 0px) scale(${this.scale})`, e = requestAnimationFrame(() => n({ x: r, y: a }));
449
- };
450
- return n({
451
- x: t.movementX,
452
- y: t.movementY
453
- }), () => {
454
- i = !0, cancelAnimationFrame(e), this.normalize(!1);
455
- };
456
- }
457
- animateZoom(t) {
458
- if (!this.image) return;
459
- this.rect || (this.rect = this.image.getBoundingClientRect());
460
- const e = Date.now(), i = this.image;
461
- this.rect.width * t < this.minDimension.closingWidth || i.width < Math.floor(this.minDimension.initialWidth) || (i.addEventListener(
462
- "transitionend",
463
- () => {
464
- this.animationTimestamp === e && i && (i.style.transition = "", this.normalize());
465
- },
466
- { once: !0 }
467
- ), i.style.transition || (i.style.transition = "all 222ms ease"), this.animationTimestamp = e, this.scaleMove(t));
468
- }
469
- normalize(t = !0) {
470
- if (!this.image || !this.rect) return;
471
- const e = this.rect.width * this.scale, i = e <= this.minDimension.closingWidth, n = i ? e : this.snapToTargetIfClose(this.rect.width * this.scale, this.minDimension.initialWidth), r = i ? this.rect.height * this.scale : this.snapToTargetIfClose(this.rect.height * this.scale, this.minDimension.initialHeight);
472
- if (this.image.style.width = `${n}px`, this.image.style.height = `${r}px`, this.scale = 1, this.image.style.opacity = "", this.accumulatedTranslate.x += this.translate.x, this.accumulatedTranslate.y += this.translate.y, this.image.style.left = `calc(50% + ${this.accumulatedTranslate.x}px)`, this.image.style.top = `calc(50% + ${this.accumulatedTranslate.y}px)`, this.translate = { x: 0, y: 0 }, this.image.style.transform = "", this.rect = this.image.getBoundingClientRect(), i)
473
- return !0;
474
- if (n < this.minDimension.initialWidth)
475
- this.accumulatedTranslate.x = 0, this.accumulatedTranslate.y = 0, requestAnimationFrame(() => {
476
- const a = this.image;
477
- a && (a.addEventListener(
478
- "transitionend",
479
- () => {
480
- a && (this.clean(), this.rect = null);
481
- },
482
- { once: !0 }
483
- ), a.style.transition = "all 222ms ease", a.style.width = `${this.minDimension.initialWidth}px`, a.style.height = `${this.minDimension.initialHeight}px`, a.style.left = "50%", a.style.top = "50%");
484
- });
485
- else if (t) {
486
- let a = !1;
487
- if (this.rect.right < window.innerWidth / 2 && (a = !0, this.accumulatedTranslate.x += window.innerWidth / 2 - this.rect.right), this.rect.left > window.innerWidth / 2 && (a = !0, this.accumulatedTranslate.x -= this.rect.left - window.innerWidth / 2), this.rect.bottom < window.innerHeight / 2 && (a = !0, this.accumulatedTranslate.y += window.innerHeight / 2 - this.rect.bottom), this.rect.top > window.innerHeight / 2 && (a = !0, this.accumulatedTranslate.y -= this.rect.top - window.innerHeight / 2), a) {
488
- const o = this.image;
489
- o.addEventListener(
490
- "transitionend",
491
- () => {
492
- o && (o.style.transition = "", this.rect = null);
493
- },
494
- { once: !0 }
495
- ), o.style.transition = "all 222ms ease", o.style.left = `calc(50% + ${this.accumulatedTranslate.x}px)`, o.style.top = `calc(50% + ${this.accumulatedTranslate.y}px)`;
496
- } else
497
- this.rect = null;
498
- }
499
- }
500
- }
501
- class nt {
502
- constructor() {
503
- h(this, "fiolast", {});
504
- }
505
- // first in out
506
- fio(t, e, i = 50) {
507
- const r = Date.now() - (this.fiolast[e] ?? 0), a = () => {
508
- this.fiolast[e] = Date.now(), t();
509
- };
510
- if (!this.fiolast[e]) {
511
- a();
512
- return;
513
- }
514
- r >= i && a();
515
- }
516
- }
517
- const C = {
518
- somethingOpened: null
519
- };
520
- class st {
521
- constructor(t, e = {}) {
522
- h(this, "options");
523
- h(this, "elements");
524
- h(this, "isReducedMotion");
525
- h(this, "currentIndex", -1);
526
- h(this, "currentChildren", null);
527
- h(this, "setupFunction", K);
528
- h(this, "initFunction", G);
529
- h(this, "closeFunction", Q);
530
- h(this, "transitionFunction", tt);
531
- h(this, "pointers", null);
532
- h(this, "imageState");
533
- h(this, "imageTransitions", /* @__PURE__ */ new Map());
534
- h(this, "root", null);
535
- h(this, "imageContainer", null);
536
- h(this, "onClickElements", (t) => {
537
- t.preventDefault();
538
- const e = t.currentTarget;
539
- e.dataset.vistaIdx && this.open(parseInt(e.dataset.vistaIdx));
528
+ class Q {
529
+ constructor(t) {
530
+ //
531
+ r(this, "pointers", null);
532
+ // Pinch gesture state
533
+ r(this, "lastDistance", 0);
534
+ r(this, "pinchMode", !1);
535
+ r(this, "lastPinchEndTime", 0);
536
+ r(this, "PINCH_COOLDOWN", 111);
537
+ r(this, "cancelMove", () => {
538
+ });
539
+ r(this, "pointerListeners", []);
540
+ r(this, "vvw");
541
+ // private vistaImage: VistaImage;
542
+ r(this, "imageContainer", null);
543
+ r(this, "isPinching", () => this.pinchMode || performance.now() - this.lastPinchEndTime < this.PINCH_COOLDOWN);
544
+ r(this, "internalPointerListener", (t) => {
545
+ const e = this.vvw.state.children.images.find((i) => i.pos === 0);
546
+ if (t.event === "down") {
547
+ if (this.cancelMove(), this.vvw.state.zoomedIn && t.pointers.length === 1 && !this.isPinching()) {
548
+ const i = this.pointers.getCentroid();
549
+ e.setInitialCenter(i);
550
+ }
551
+ if (t.pointers.length >= 2) {
552
+ this.pinchMode = !0;
553
+ const i = this.pointers.getCentroid();
554
+ this.lastDistance = this.pointers.getPointerDistance(t.pointers[0], t.pointers[1]), e.setInitialCenter(i);
555
+ }
556
+ } else if (t.event === "move") {
557
+ if (this.vvw.state.zoomedIn && t.pointers.length === 1 && t.lastPointerLen === 0 && !this.isPinching()) {
558
+ const i = this.pointers.getCentroid();
559
+ e.scaleMove(1, i);
560
+ }
561
+ if (t.pointers.length >= 2 && this.pinchMode) {
562
+ const i = this.pointers.getCentroid(), n = this.pointers.getPointerDistance(t.pointers[0], t.pointers[1]);
563
+ e.scaleMove(n / this.lastDistance, i);
564
+ }
565
+ } else if ((t.event === "up" || t.event === "cancel") && (this.pinchMode || this.vvw.state.zoomedIn))
566
+ if (this.pinchMode) {
567
+ this.lastPinchEndTime = performance.now(), this.pinchMode = !1;
568
+ const i = e.setFinalTransform();
569
+ i != null && i.cancel && (this.cancelMove = i.cancel), i != null && i.close && requestAnimationFrame(() => {
570
+ this.vvw.close();
571
+ });
572
+ } else this.vvw.state.zoomedIn && t.pointers.length === 0 && !this.isPinching() && (e.isThrowing = !0, this.cancelMove = e.momentumThrow({
573
+ x: t.pointer.movementX,
574
+ y: t.pointer.movementY
575
+ }));
576
+ this.pointerListeners.forEach(
577
+ (i) => i({
578
+ ...t,
579
+ state: this.vvw.state,
580
+ hasInternalExecution: this.vvw.state.zoomedIn || this.isPinching(),
581
+ abortController: this.vvw.state.abortController
582
+ })
583
+ );
540
584
  });
541
- h(this, "defaultOnClickHandler", (t) => t.preventDefault());
542
- h(this, "abortController", null);
543
- h(this, "throttle", new nt());
544
- h(this, "lastSwapTime", 0);
545
- h(this, "isRapidSwap", !1);
546
- h(this, "isRapidSwapRelease", 0);
547
- h(this, "transitionCleanup", null);
548
- h(this, "isZoomedIn", !1);
549
- h(this, "onKeyDown", (t) => {
585
+ r(this, "onKeyDown", (t) => {
586
+ const e = this.vvw;
550
587
  switch (t.key) {
551
588
  case "ArrowLeft":
552
- t.preventDefault(), this.prev();
589
+ t.preventDefault(), e.prev();
553
590
  break;
554
591
  case "ArrowRight":
555
- t.preventDefault(), this.next();
592
+ t.preventDefault(), e.next();
556
593
  break;
557
594
  case "ArrowUp":
558
- t.preventDefault(), this.zoomIn();
595
+ t.preventDefault(), e.zoomIn();
559
596
  break;
560
597
  case "ArrowDown":
561
- t.preventDefault(), this.zoomOut();
598
+ t.preventDefault(), e.zoomOut();
562
599
  break;
563
600
  case "Escape":
564
- t.preventDefault(), this.close();
601
+ t.preventDefault(), e.close();
565
602
  break;
566
603
  }
567
604
  });
568
- h(this, "onScroll", (t) => {
605
+ r(this, "onScroll", (t) => {
569
606
  t.preventDefault();
570
- const e = t.deltaY;
571
- this.imageState.setInitialCenter({
607
+ const e = this.vvw, i = this.vvw.state.children.images.find((o) => o.pos === 0), n = t.deltaY;
608
+ i.setInitialCenter({
572
609
  x: t.clientX,
573
610
  y: t.clientY
574
- }), e < 0 ? this.zoomIn() : e > 0 && this.zoomOut();
611
+ }), n < 0 ? e.zoomIn() : n > 0 && e.zoomOut();
575
612
  });
576
- h(this, "onResizeHandler", () => {
577
- this.currentChildren.htmls.forEach((t, e) => {
578
- const i = this.currentChildren.images[e], n = t.querySelector("img.vvw-img-hi"), r = t.querySelector("img.vvw-img-lo");
579
- if (W(i, n, r, !1), n.classList.contains("vvw--loaded")) {
580
- const { width: a, height: o } = H(n);
581
- n.style.setProperty("--vvw-current-w", `${a}px`), n.style.setProperty("--vvw-current-h", `${o}px`), n.dataset.vvwWidth = a.toString(), n.dataset.vvwHeight = o.toString();
582
- }
613
+ r(this, "onResizeHandler", () => {
614
+ this.vvw.state.children.images.forEach((t) => {
615
+ t.setSizes();
583
616
  });
584
617
  });
585
- /// POINTERS
586
- h(this, "pointerListeners", []);
587
- h(this, "getInternalPointerListener", () => {
588
- const t = this.imageState;
589
- let e = 0, i = !1, n = 0;
590
- const r = 33;
591
- let a = () => {
592
- };
593
- function o() {
594
- return i || performance.now() - n < r;
595
- }
596
- return (l) => {
597
- if (l.event === "down") {
598
- if (a(), this.isZoomedIn && l.pointers.length === 1 && !o()) {
599
- const c = this.pointers.getCentroid();
600
- t.setInitialCenter(c);
601
- }
602
- if (l.pointers.length >= 2) {
603
- i = !0;
604
- const c = this.pointers.getCentroid();
605
- e = this.pointers.getPointerDistance(l.pointers[0], l.pointers[1]), t.setInitialCenter(c);
606
- }
607
- } else if (l.event === "move") {
608
- if (this.isZoomedIn && l.pointers.length === 1 && l.lastPointerLen === 0 && !o()) {
609
- const c = this.pointers.getCentroid();
610
- t.move(c);
611
- }
612
- if (l.pointers.length >= 2 && i) {
613
- const c = this.pointers.getCentroid(), d = this.pointers.getPointerDistance(l.pointers[0], l.pointers[1]);
614
- t.scaleMove(d / e, c);
615
- }
616
- } else (l.event === "up" || l.event === "cancel") && (i || this.isZoomedIn) && (i ? (n = performance.now(), i = !1, t.normalize() && requestAnimationFrame(() => {
617
- this.close();
618
- })) : this.isZoomedIn && l.pointers.length === 0 && !o() && (a = t.moveAndNormalize(l.pointer)));
619
- this.pointerListeners.forEach(
620
- (c) => c({
621
- ...l,
622
- hasInternalExecution: this.isZoomedIn || o(),
623
- abortController: this.abortController
624
- })
625
- );
626
- };
618
+ this.vvw = t;
619
+ }
620
+ // register external pointer listener
621
+ registerPointerListener(t) {
622
+ this.pointerListeners.push(t);
623
+ }
624
+ start(t) {
625
+ this.vvw.options.keyboardListeners && window.addEventListener("keydown", this.onKeyDown), this.imageContainer = t, this.imageContainer.addEventListener("wheel", this.onScroll, { passive: !1 }), window.addEventListener("resize", this.onResizeHandler), this.pointers = new J({
626
+ elm: t,
627
+ listeners: [this.internalPointerListener]
627
628
  });
629
+ }
630
+ stop() {
631
+ this.vvw.options.keyboardListeners && window.removeEventListener("keydown", this.onKeyDown), window.removeEventListener("resize", this.onResizeHandler), this.imageContainer.removeEventListener("wheel", this.onScroll), this.pointers.removeListeners(), this.pointerListeners = [];
632
+ }
633
+ }
634
+ const y = {
635
+ somethingOpened: null
636
+ };
637
+ class tt {
638
+ constructor(t, e = {}) {
639
+ r(this, "options");
640
+ r(this, "state", new j());
641
+ r(this, "imageContainer", null);
642
+ r(this, "externalPointerListener", []);
643
+ r(this, "elements");
644
+ r(this, "eventHandlers", null);
645
+ r(this, "imageSetupFunction", k);
646
+ r(this, "initFunction", V);
647
+ r(this, "openFunction", B);
648
+ r(this, "closeFunction", X);
649
+ r(this, "transitionFunction", Y);
650
+ r(this, "throttle", new Z());
651
+ r(this, "root", null);
652
+ r(this, "onClickElements", (t) => {
653
+ t.preventDefault();
654
+ const e = t.currentTarget;
655
+ e.dataset.vvwIdx && this.open(parseInt(e.dataset.vvwIdx));
656
+ });
657
+ r(this, "defaultOnClickHandler", (t) => t.preventDefault());
658
+ // ============================================================================
659
+ // SWAP LOGIC - handles image transitions between prev/next
660
+ // ============================================================================
661
+ r(this, "lastSwapTime", 0);
662
+ r(this, "isRapidSwap", !1);
663
+ r(this, "isRapidSwapRelease", 0);
664
+ r(this, "transitionCleanup", null);
665
+ // ============================================================================
666
+ // ACTIVATE/DEACTIVATE UI ELEMENTS
667
+ // ============================================================================
668
+ r(this, "tempDeactivatedUi", []);
669
+ r(this, "tempDeactivationRequestBy", null);
670
+ // ============================================================================
671
+ // ZOOM CONTROLS
672
+ // ============================================================================
673
+ r(this, "isZoomedIn", !1);
674
+ var i;
628
675
  this.elements = t, this.options = {
629
- ...M,
676
+ ...I,
630
677
  ...e,
631
678
  controls: {
632
- ...M.controls,
679
+ ...I.controls,
633
680
  ...e.controls
634
681
  }
635
- }, this.imageState = new it(
636
- this.options.maxZoomLevel,
637
- (i) => {
638
- var n, r, a, o;
639
- i.isMin ? (this.isZoomedIn = !1, (n = this.qs(".vvw-zoom-out")) == null || n.setAttribute("disabled", "true")) : (this.isZoomedIn = !0, (r = this.qs(".vvw-zoom-out")) == null || r.removeAttribute("disabled")), i.isMax ? (a = this.qs(".vvw-zoom-in")) == null || a.setAttribute("disabled", "true") : (o = this.qs(".vvw-zoom-in")) == null || o.removeAttribute("disabled");
640
- }
641
- ), this.options.setupFunction && (this.setupFunction = this.options.setupFunction), this.options.closeFunction && (this.closeFunction = this.options.closeFunction), this.options.initFunction && (this.initFunction = this.options.initFunction), this.options.transitionFunction && (this.transitionFunction = this.options.transitionFunction), this.isReducedMotion = window.matchMedia("(prefers-reduced-motion: reduce)").matches, this.elements instanceof NodeList && this.elements.forEach((i, n) => {
642
- i.dataset.vistaIdx = n.toString(), i.addEventListener("click", this.defaultOnClickHandler), i.addEventListener("pointerup", this.onClickElements);
643
- });
682
+ }, this.options.imageSetupFunction && (this.imageSetupFunction = this.options.imageSetupFunction), this.options.closeFunction && (this.closeFunction = this.options.closeFunction), this.options.initFunction && (this.initFunction = this.options.initFunction), this.options.transitionFunction && (this.transitionFunction = this.options.transitionFunction), [
683
+ ...this.options.controls.topLeft || [],
684
+ ...this.options.controls.topRight || [],
685
+ ...this.options.controls.topCenter || [],
686
+ ...this.options.controls.bottomCenter || [],
687
+ ...this.options.controls.bottomLeft || [],
688
+ ...this.options.controls.bottomRight || []
689
+ ].forEach((n) => {
690
+ typeof n != "string" && this.state.extensions.add(n);
691
+ }), (i = this.options.extensions) == null || i.forEach((n) => {
692
+ this.state.extensions.add(n);
693
+ }), this.state.isReducedMotion = window.matchMedia("(prefers-reduced-motion: reduce)").matches, this.reset(), this.initFunction(this);
694
+ }
695
+ reset() {
696
+ if (typeof this.elements == "string") {
697
+ const t = this.qsOrigin(this.elements);
698
+ this.state.elmLength = t.length, t.forEach((e, i) => {
699
+ const n = e;
700
+ n.dataset.vvwIdx = i.toString(), n.removeEventListener("click", this.defaultOnClickHandler), n.removeEventListener("pointerup", this.onClickElements), n.addEventListener("click", this.defaultOnClickHandler), n.addEventListener("pointerup", this.onClickElements);
701
+ });
702
+ } else
703
+ this.state.elmLength = this.elements.length;
644
704
  }
705
+ // ============================================================================
706
+ // HELPER METHODS
707
+ // ============================================================================
645
708
  qs(t) {
646
709
  return this.root ? this.root.querySelector(t) : null;
647
710
  }
648
- async swap(t, e) {
649
- const i = this.options.preloads || 0, n = this.currentIndex, { htmls: r, images: a } = this.getChildElements(i, n), o = this.imageContainer, l = this.currentChildren, c = {
650
- htmlElements: { from: l.htmls, to: r },
651
- images: { from: l.images, to: a },
652
- index: { from: t, to: this.currentIndex },
653
- via: e || { next: !1, prev: !1 },
654
- vistaView: this
655
- };
656
- this.setupFunction(c), this.currentChildren = { htmls: r, images: a }, this.displayActiveIndex();
657
- const d = this.abortController.signal, x = performance.now() - this.lastSwapTime < this.options.rapidLimit;
658
- if (this.isRapidSwap = x, o.querySelectorAll(".vvw-item img.vvw-img-hi").forEach((y) => y.classList.add("vvw--load-cancelled")), x) {
659
- this.imageState.reset(), o.innerHTML = "", this.transitionCleanup && this.transitionCleanup(), r.forEach((y) => {
660
- o.appendChild(y);
661
- }), this.lastSwapTime = performance.now(), this.waitForImagesToLoad(), this.options.onImageView && this.options.onImageView(c), this.isRapidSwapRelease && clearTimeout(this.isRapidSwapRelease), this.isRapidSwapRelease = setTimeout(() => {
662
- this.isRapidSwap = !1;
663
- }, 333);
664
- return;
665
- }
666
- const g = this.transitionFunction(c, d);
667
- g && (this.transitionCleanup = g.cleanup, await g.transitionEnded), this.lastSwapTime = performance.now();
668
- const m = r[Math.floor(r.length / 2)].dataset.vvwIdx, u = o.querySelector(
669
- `.vvw-item[data-vvw-idx="${m}"] img.vvw-img-hi`
670
- ), b = this.imageTransitions.get(u);
671
- this.imageTransitions.delete(u);
672
- const f = u.getAttribute("style") || "", v = u.classList.contains("vvw--loaded"), E = u.classList.contains("vvw--ready"), I = u.width, S = u.height;
673
- this.imageState.reset(), o.innerHTML = "", this.transitionCleanup && this.transitionCleanup(), r.forEach((y) => {
674
- const w = y.querySelector("img.vvw-img-hi");
675
- y.dataset.vvwPos === "0" && !d.aborted && f && I && S && (v && (w.classList.add("vvw--loaded"), w.dataset.vvwWidth = u.dataset.vvwWidth || "", w.dataset.vvwHeight = u.dataset.vvwHeight || ""), E && (w.classList.add("vvw--ready"), w.width = I, w.height = S), w.setAttribute("style", f)), o.appendChild(y), y.dataset.vvwPos === "0" && !d.aborted && E ? (this.imageState.setCurrentImage(w), this.imageState.setInitialCenter()) : y.dataset.vvwPos === "0" && !d.aborted && f && I && S && v && b && (this.imageTransitions.set(w, b), this.transitionImage(
676
- w,
677
- () => {
678
- this.imageState.setCurrentImage(w), this.imageState.setInitialCenter(), w.classList.add("vvw--ready");
679
- }
680
- // false
681
- ));
682
- }), this.isRapidSwap = !1, this.waitForImagesToLoad(), this.options.onImageView && this.options.onImageView(c);
711
+ qsOrigin(t) {
712
+ return document.querySelectorAll(t);
713
+ }
714
+ registerPointerListener(t) {
715
+ this.externalPointerListener.push(t);
683
716
  }
684
717
  getChildElements(t, e) {
685
- const i = [], n = [];
686
- for (let r = -t; r <= t; r++) {
687
- const a = (e + r + this.elements.length) % this.elements.length, o = this.elements[a], l = o instanceof HTMLImageElement ? o : o instanceof HTMLAnchorElement && o.querySelector("img") || void 0, c = o instanceof HTMLElement ? {
688
- index: a,
689
- imageElm: l instanceof HTMLImageElement ? l : void 0,
690
- anchorElm: o instanceof HTMLAnchorElement ? o : void 0,
691
- src: o.dataset.vistaviewSrc || o.getAttribute("href") || o.getAttribute("src") || "",
692
- thumb: o.dataset.vistaviewThumb || (l instanceof HTMLImageElement ? l.getAttribute("src") : void 0) || o.getAttribute("href") || void 0,
693
- alt: l instanceof HTMLImageElement && l.getAttribute("alt") || void 0
694
- } : {
695
- index: a,
696
- ...o
718
+ const i = [], n = [], o = typeof this.elements == "string" ? this.qsOrigin(this.elements) : this.elements;
719
+ for (let a = -t; a <= t; a++) {
720
+ const h = (e + a + o.length) % o.length, l = o[h], p = {
721
+ elm: l instanceof HTMLElement ? G(l) : { config: l, origin: void 0, parsedSrcSet: void 0 },
722
+ pos: a,
723
+ index: h,
724
+ vistaView: this,
725
+ maxZoomLevel: this.options.maxZoomLevel,
726
+ transitionShouldWait: () => this.isRapidSwap,
727
+ onScale: ({
728
+ vistaImage: m,
729
+ isMin: c,
730
+ isMax: g
731
+ }) => {
732
+ var x, b, C, w;
733
+ m.index === this.state.currentIndex && (this.state.zoomedIn = !c, c ? (x = this.qs(".vvw-zoom-out")) == null || x.setAttribute("disabled", "true") : (b = this.qs(".vvw-zoom-out")) == null || b.removeAttribute("disabled"), g ? (C = this.qs(".vvw-zoom-in")) == null || C.setAttribute("disabled", "true") : (w = this.qs(".vvw-zoom-in")) == null || w.removeAttribute("disabled"));
734
+ }
697
735
  };
698
- n.push(c), i.push(U(c, r));
736
+ let u = null;
737
+ this.state.extensions.forEach((m) => {
738
+ !u && m.onInitializeImage && (u = m.onInitializeImage(p));
739
+ });
740
+ const v = u ?? new U(p), f = document.createElement("div");
741
+ f.className = "vvw-item", f.dataset.vvwPos = `${a}`, f.dataset.vvwIdx = `${h}`, v.thumb && f.appendChild(v.thumb), f.appendChild(v.element), i.push(v), n.push(f);
699
742
  }
700
743
  return {
701
- htmls: i,
702
- images: n
744
+ htmls: n,
745
+ images: i
703
746
  };
704
747
  }
705
- zoomIn() {
706
- this.throttle.fio(
707
- () => {
708
- this.imageState.animateZoom(1.68);
709
- },
710
- "zoom",
711
- 222
712
- );
713
- }
714
- zoomOut() {
715
- this.throttle.fio(
716
- () => {
717
- this.imageState.animateZoom(0.68);
718
- },
719
- "zoom",
720
- 222
721
- );
722
- }
723
- displayActiveIndex() {
724
- var a;
725
- const t = this.currentIndex;
726
- this.elements instanceof NodeList && this.elements.forEach((o, l) => {
727
- o.style.opacity = "", l === t && (o.style.opacity = "0");
728
- });
729
- const e = this.qs(".vvw-index"), i = `${t + 1}`, n = `${this.elements.length}`;
730
- e && (e.textContent = `${i} / ${n}`);
731
- const r = this.qs(".vvw-desc");
732
- if (r) {
733
- const o = (a = this.currentChildren) == null ? void 0 : a.images.find((c) => c.index === t), l = (o == null ? void 0 : o.alt) || "";
734
- l ? (r.textContent = l, r.setAttribute("aria-label", `Image ${i} of ${n}: ${l}`)) : (r.textContent = "", r.setAttribute("aria-label", `Image ${i} of ${n}`));
735
- }
736
- }
737
- transitionImage(t, e) {
738
- if (t.classList.contains("vvw--load-cancelled")) return;
739
- if (this.isRapidSwap) {
740
- requestAnimationFrame(() => {
741
- this.transitionImage(t, e);
748
+ async swap(t, e) {
749
+ var f, m;
750
+ this.reactivateUi();
751
+ const i = this.options.preloads || 0, n = this.state.currentIndex, { htmls: o, images: a } = this.getChildElements(i, n), h = this.imageContainer, l = this.state.children, d = {
752
+ htmlElements: { from: l.htmls, to: o },
753
+ images: { from: l.images, to: a },
754
+ index: { from: t, to: this.state.currentIndex },
755
+ via: e || { next: !1, prev: !1 },
756
+ vistaView: this
757
+ };
758
+ this.imageSetupFunction(d), this.state.zoomedIn = !1, (f = this.qs(".vvw-zoom-out")) == null || f.setAttribute("disabled", "true"), (m = this.qs(".vvw-zoom-in")) == null || m.removeAttribute("disabled");
759
+ const u = performance.now() - this.lastSwapTime < this.options.rapidLimit;
760
+ this.isRapidSwap = u;
761
+ const { images: v } = this.state.children;
762
+ if (this.state.children = { htmls: o, images: a }, this.displayCurrentInfo(), u)
763
+ v.forEach((c) => {
764
+ c.cancelPendingLoad(), c.destroy();
765
+ });
766
+ else {
767
+ const c = this.state.abortController.signal, g = this.transitionFunction(d, c);
768
+ g && (this.transitionCleanup = g.cleanup, await g.transitionEnded), this.lastSwapTime = performance.now(), v.forEach((w) => {
769
+ w.cancelPendingLoad();
770
+ });
771
+ const x = v.find((w) => w.index === n), b = x ? L.stop(x) : void 0, C = a.find((w) => w.index === n);
772
+ C && x && C.cloneStyleFrom(x, b), v.forEach((w) => {
773
+ w.destroy();
742
774
  });
743
- return;
744
775
  }
745
- const i = this.imageTransitions.get(t);
746
- i && requestAnimationFrame(() => {
747
- if (t.classList.contains("vvw--load-cancelled")) return;
748
- const { current: n, target: r } = i, a = {
749
- width: n.width + (r.width - n.width) * 0.2,
750
- height: n.height + (r.height - n.height) * 0.2,
751
- radius: n.radius + (r.radius - n.radius) * 0.2
752
- };
753
- Math.abs(a.width - r.width) < 1 && Math.abs(a.height - r.height) < 1 && Math.abs(a.radius - r.radius) < 1 ? (t.style.setProperty("--vvw-current-w", `${r.width}px`), t.style.setProperty("--vvw-current-h", `${r.height}px`), t.style.setProperty("--vvw-current-radius", `${r.radius}px`), this.imageTransitions.delete(t), e()) : (t.style.setProperty("--vvw-current-w", `${a.width}px`), t.style.setProperty("--vvw-current-h", `${a.height}px`), t.style.setProperty("--vvw-current-radius", `${a.radius}px`), this.imageTransitions.set(t, { current: a, target: r }), this.transitionImage(
754
- t,
755
- e
756
- /* false */
757
- ));
776
+ h.innerHTML = "", this.transitionCleanup && this.transitionCleanup(), o.forEach((c) => {
777
+ h.appendChild(c);
778
+ }), a.forEach((c) => {
779
+ c.init();
780
+ }), u ? (this.isRapidSwapRelease && clearTimeout(this.isRapidSwapRelease), this.isRapidSwapRelease = setTimeout(() => {
781
+ this.isRapidSwap = !1;
782
+ }, 333)) : this.isRapidSwap = !1, this.options.onImageView && this.options.onImageView(d, this), this.state.extensions.forEach((c) => {
783
+ c.onImageView && c.onImageView(d, this);
758
784
  });
759
785
  }
760
- waitForImagesToLoad() {
761
- this.imageContainer.querySelectorAll("img.vvw-img-hi:not(.vvw--loaded)").forEach((i) => {
762
- const n = i;
763
- if (n.classList.contains("vvw--load-cancelled")) return;
764
- const r = () => {
765
- if (n.classList.contains("vvw--load-cancelled")) return;
766
- n.width = n.naturalWidth, n.height = n.naturalHeight;
767
- const { width: a, height: o } = H(n);
768
- n.dataset.vvwWidth = a.toString(), n.dataset.vvwHeight = o.toString(), n.classList.add("vvw--loaded"), this.imageTransitions.set(n, {
769
- current: {
770
- width: n.style.getPropertyValue("--vvw-current-w") ? parseFloat(n.style.getPropertyValue("--vvw-current-w")) : 0,
771
- height: n.style.getPropertyValue("--vvw-current-h") ? parseFloat(n.style.getPropertyValue("--vvw-current-h")) : 0,
772
- radius: n.style.getPropertyValue("--vvw-current-radius") ? parseFloat(n.style.getPropertyValue("--vvw-current-radius")) : 0
773
- },
774
- target: { width: a, height: o, radius: 0 }
775
- }), this.transitionImage(n, () => {
776
- var c;
777
- if (n.classList.contains("vvw--load-cancelled")) return;
778
- ((c = n.parentElement) == null ? void 0 : c.matches(
779
- `[data-vvw-idx="${this.currentIndex}"][data-vvw-pos="0"]`
780
- )) && (this.imageState.setCurrentImage(n), this.imageState.setInitialCenter()), n.classList.add("vvw--ready");
781
- });
782
- };
783
- if (n.complete && n.naturalWidth !== 0) {
784
- r();
785
- return;
786
- }
787
- n.addEventListener("load", () => {
788
- r();
789
- }), n.addEventListener("error", () => {
790
- var o;
791
- n.classList.add("vvw--loaderror");
792
- const a = document.createElement("p");
793
- a.className = "vvw-img-err", a.setAttribute("role", "alert"), a.textContent = "Error loading image", (o = n.parentNode) == null || o.appendChild(a);
794
- });
786
+ // ============================================================================
787
+ // UI UPDATES
788
+ // ============================================================================
789
+ displayCurrentInfo() {
790
+ const t = this.state.currentIndex;
791
+ typeof this.elements == "string" && this.qsOrigin(this.elements).forEach((a, h) => {
792
+ a.style.opacity = "", h === t && (a.style.opacity = "0");
795
793
  });
794
+ const e = this.qs(".vvw-index"), i = `${t + 1}`, n = `${this.state.elmLength}`;
795
+ e && (e.textContent = `${i} / ${n}`);
796
+ const o = this.qs(".vvw-desc");
797
+ if (o) {
798
+ const a = this.state.children.images.find((l) => l.index === t), h = (a == null ? void 0 : a.config.alt) || "";
799
+ h ? (o.textContent = h, o.setAttribute("aria-label", `Image ${i} of ${n}: ${h}`), o.style.opacity = "") : (o.textContent = "", o.setAttribute("aria-label", `Image ${i} of ${n}`), o.style.opacity = "0");
800
+ }
796
801
  }
797
- registerPointerListener(t) {
798
- this.pointerListeners.push(t);
799
- }
800
- unregisterPointerListeners() {
801
- this.pointerListeners = [];
802
+ deactivateUi(t, e) {
803
+ t.forEach((i) => {
804
+ var n, o;
805
+ i === "zoomIn" ? (n = this.qs(".vvw-zoom-in")) == null || n.setAttribute("disabled", "true") : i === "zoomOut" && ((o = this.qs(".vvw-zoom-out")) == null || o.setAttribute("disabled", "true")), this.tempDeactivatedUi.push(i);
806
+ }), this.tempDeactivationRequestBy = e || null, this.state.extensions.forEach((i) => {
807
+ i.onDeactivateUi && i.onDeactivateUi(t, this.tempDeactivationRequestBy, this);
808
+ });
802
809
  }
803
- /// OPEN
810
+ reactivateUi() {
811
+ this.tempDeactivatedUi.forEach((t) => {
812
+ var e, i;
813
+ t === "zoomIn" ? (e = this.qs(".vvw-zoom-in")) == null || e.removeAttribute("disabled") : t === "zoomOut" && ((i = this.qs(".vvw-zoom-out")) == null || i.removeAttribute("disabled"));
814
+ }), this.state.extensions.forEach((t) => {
815
+ t.onReactivateUi && t.onReactivateUi(this.tempDeactivatedUi, this.tempDeactivationRequestBy, this);
816
+ }), this.tempDeactivatedUi = [], this.tempDeactivationRequestBy = null;
817
+ }
818
+ // ============================================================================
819
+ // LIFECYCLE METHODS - open, close, destroy
820
+ // ============================================================================
821
+ // OPEN
804
822
  open(t = 0) {
805
- var c, d, p, x, g;
806
- if (C.somethingOpened)
823
+ var l, d, p, u, v, f, m;
824
+ if (y.somethingOpened) {
825
+ console.warn(
826
+ "Another VistaView instance is already opened. Close it first before opening a new one."
827
+ );
807
828
  return;
808
- C.somethingOpened = this, this.currentIndex = t, document.body.style.overflow = "hidden";
809
- const e = _({
829
+ }
830
+ y.somethingOpened = this, this.reset(), (t < 0 || t >= this.state.elmLength) && (t = (t % this.state.elmLength + this.state.elmLength) % this.state.elmLength), this.state.currentIndex = t, document.body.style.overflow = "hidden";
831
+ const e = $({
810
832
  controls: this.options.controls
811
833
  });
812
- if (document.body.prepend(e), this.root = document.body.querySelector("#vvw-root"), !this.root)
834
+ if (document.body.append(e), this.root = document.body.querySelector("#vvw-root"), !this.root)
813
835
  throw new Error("Failed to setup VistaView root element.");
814
836
  this.imageContainer = this.qs(".vvw-image-container"), this.options.animationDurationBase && this.root.style.setProperty("--vvw-anim-dur", `${this.options.animationDurationBase}`), this.options.initialZIndex !== void 0 && this.root.style.setProperty("--vvw-init-z", `${this.options.initialZIndex ?? 0}`), this.options.arrowOnSmallScreens && this.root.classList.add("vvw-arrow-sm");
815
- const i = this.options.preloads || 0, n = t, { images: r, htmls: a } = this.getChildElements(i, n), o = {
837
+ const i = this.options.preloads || 0, n = t, { images: o, htmls: a } = this.getChildElements(i, n), h = {
816
838
  htmlElements: { from: null, to: a },
817
- images: { from: null, to: r },
818
- index: { from: null, to: this.currentIndex },
839
+ images: { from: null, to: o },
840
+ index: { from: null, to: this.state.currentIndex },
819
841
  via: { next: !1, prev: !1 },
820
842
  vistaView: this
821
843
  };
822
- this.setupFunction(o), this.currentChildren = { htmls: a, images: r }, a.forEach((m) => {
823
- this.imageContainer.appendChild(m);
824
- }), (c = this.qs(".vvw-close")) == null || c.addEventListener("click", () => this.close()), (d = this.qs(".vvw-zoom-in")) == null || d.addEventListener("click", () => this.zoomIn()), (p = this.qs(".vvw-zoom-out")) == null || p.addEventListener("click", () => this.zoomOut()), (x = this.qs(".vvw-prev>button")) == null || x.addEventListener("click", () => this.prev()), (g = this.qs(".vvw-next>button")) == null || g.addEventListener("click", () => this.next()), this.options.keyboardListeners && window.addEventListener("keydown", this.onKeyDown), window.addEventListener("wheel", this.onScroll, { passive: !1 }), window.addEventListener("resize", this.onResizeHandler), this.pointers = new et({
825
- elm: this.imageContainer,
826
- listeners: [this.getInternalPointerListener()]
827
- });
828
- const l = {};
829
- [
830
- ...this.options.controls.topLeft || [],
831
- ...this.options.controls.topRight || [],
832
- ...this.options.controls.topCenter || [],
833
- ...this.options.controls.bottomCenter || [],
834
- ...this.options.controls.bottomLeft || [],
835
- ...this.options.controls.bottomRight || []
836
- ].forEach((m) => {
837
- typeof m != "string" && (l[m.name] = m);
838
- }), this.root.querySelectorAll("button[data-vvw-control]").forEach((m) => {
839
- const u = m;
840
- u.addEventListener("click", (b) => {
841
- const f = b.currentTarget.dataset.vvwControl, v = l[f], E = this.currentChildren.images.find(
842
- (I) => I.index === this.currentIndex
843
- );
844
- v && E && (v.onClick.constructor.name === "AsyncFunction" ? (u.classList.add("vvw--loading"), v.onClick(E, this).finally(() => {
845
- u.classList.remove("vvw--loading");
846
- })) : v.onClick(E, this));
847
- });
848
- }), this.initFunction(this), requestAnimationFrame(() => {
844
+ this.imageSetupFunction(h), this.state.children = { htmls: a, images: o }, a.forEach((c) => {
845
+ this.imageContainer.appendChild(c);
846
+ }), o.forEach((c) => {
847
+ c.init();
848
+ }), (l = this.qs(".vvw-close")) == null || l.addEventListener("click", () => this.close()), (d = this.qs(".vvw-zoom-in")) == null || d.addEventListener("click", () => this.zoomIn()), (p = this.qs(".vvw-zoom-out")) == null || p.addEventListener("click", () => this.zoomOut()), (u = this.qs(".vvw-prev>button")) == null || u.addEventListener("click", () => this.prev()), (v = this.qs(".vvw-next>button")) == null || v.addEventListener("click", () => this.next()), this.state.elmLength < 2 && ((f = this.qs(".vvw-prev")) == null || f.classList.add("vvw--hidden"), (m = this.qs(".vvw-next")) == null || m.classList.add("vvw--hidden")), this.openFunction(this), this.eventHandlers = new Q(this), this.externalPointerListener.forEach((c) => {
849
+ this.eventHandlers.registerPointerListener(c);
850
+ }), this.eventHandlers.start(this.imageContainer), requestAnimationFrame(() => {
849
851
  requestAnimationFrame(() => {
850
- var m;
851
- (m = this.root) == null || m.addEventListener(
852
+ var c;
853
+ (c = this.root) == null || c.addEventListener(
852
854
  "transitionend",
853
855
  () => {
854
- var u;
855
- (u = this.root) == null || u.classList.add("vvw--settled"), this.imageState.reset(), this.waitForImagesToLoad();
856
+ var g;
857
+ (g = this.root) == null || g.classList.add("vvw--settled");
856
858
  },
857
859
  { once: !0 }
858
- ), this.root.classList.add("vvw--active"), this.displayActiveIndex(), this.options.onOpen && this.options.onOpen(this), this.options.onImageView && this.options.onImageView(o);
860
+ ), this.root.classList.add("vvw--active"), this.displayCurrentInfo(), this.options.onOpen && this.options.onOpen(this), this.options.onImageView && this.options.onImageView(h, this), this.state.extensions.forEach((g) => {
861
+ g.onOpen && g.onOpen(this), g.onImageView && g.onImageView(h, this);
862
+ });
859
863
  });
860
864
  });
861
865
  }
862
866
  /// CLOSE
863
867
  async close(t = !0) {
864
- C.somethingOpened === this && this.root && (t ? await new Promise((e) => {
868
+ y.somethingOpened === this && this.root && (this.eventHandlers.stop(), this.eventHandlers = null, this.state.children.images.forEach((e) => {
869
+ e.prepareClose();
870
+ }), t ? await new Promise((e) => {
865
871
  let n = 0;
866
- this.root.addEventListener("transitionend", (r) => {
867
- r.target === this.root && (n++, n === 2 && this.elements instanceof NodeList && this.elements.forEach((a) => {
872
+ this.root.addEventListener("transitionend", (o) => {
873
+ o.target === this.root && (n++, n === 2 && typeof this.elements == "string" && (this.state.children.images.forEach((a) => {
874
+ a.destroy();
875
+ }), this.qsOrigin(this.elements).forEach((a) => {
868
876
  a.style.opacity = "";
869
- }), n === 3 && e(null));
877
+ })), n === 3 && e(null));
870
878
  }), this.root.classList.add("vvw--closing");
871
- }) : this.elements instanceof NodeList && this.elements.forEach((e) => {
879
+ }) : typeof this.elements == "string" && (this.state.children.images.forEach((e) => {
880
+ e.destroy();
881
+ }), this.qsOrigin(this.elements).forEach((e) => {
872
882
  e.style.opacity = "";
873
- }), this.options.keyboardListeners && window.removeEventListener("keydown", this.onKeyDown), window.removeEventListener("resize", this.onResizeHandler), window.removeEventListener("wheel", this.onScroll), this.unregisterPointerListeners(), this.pointers.removeListeners(), this.root.remove(), this.root = null, this.imageContainer = null, this.currentChildren = null, this.currentIndex = -1, document.body.style.overflow = "", C.somethingOpened = null, this.closeFunction(this), this.options.onClose && this.options.onClose(this));
883
+ })), this.root.remove(), this.root = null, this.imageContainer = null, this.state.children = { htmls: [], images: [] }, this.state.currentIndex = -1, this.state.children.images.forEach((e) => {
884
+ e.destroy();
885
+ }), document.body.style.overflow = "", y.somethingOpened = null, this.closeFunction(this), this.options.onClose && this.options.onClose(this), this.state.extensions.forEach((e) => {
886
+ e.onClose && e.onClose(this);
887
+ }));
874
888
  }
889
+ // DESTROY
890
+ destroy() {
891
+ this.close(!1), this.externalPointerListener = [], typeof this.elements == "string" && this.qsOrigin(this.elements).forEach((t) => {
892
+ t.removeAttribute("data-vista-idx"), t.removeEventListener("click", this.defaultOnClickHandler), t.removeEventListener("pointerup", this.onClickElements);
893
+ });
894
+ }
895
+ // ============================================================================
896
+ // NAVIGATION METHODS - next, prev, view
897
+ // ============================================================================
875
898
  next() {
876
- if (C.somethingOpened !== this)
899
+ if (y.somethingOpened !== this) {
900
+ console.warn("This VistaView instance is not opened.");
877
901
  return;
878
- const t = (this.currentIndex + 1) % this.elements.length;
902
+ }
903
+ const t = (this.state.currentIndex + 1) % this.state.elmLength;
879
904
  this.view(t, { next: !0, prev: !1 });
880
905
  }
881
906
  prev() {
882
- if (C.somethingOpened !== this)
907
+ if (y.somethingOpened !== this) {
908
+ console.warn("This VistaView instance is not opened.");
883
909
  return;
884
- const t = (this.currentIndex - 1 + this.elements.length) % this.elements.length;
910
+ }
911
+ const t = (this.state.currentIndex - 1 + this.state.elmLength) % this.state.elmLength;
885
912
  this.view(t, { next: !1, prev: !0 });
886
913
  }
887
- destroy() {
888
- this.close(!1), this.elements instanceof NodeList && this.elements.forEach((t) => {
889
- t.removeAttribute("data-vista-idx"), t.removeEventListener("click", this.defaultOnClickHandler), t.removeEventListener("pointerup", this.onClickElements);
890
- });
914
+ view(t, e) {
915
+ if (y.somethingOpened !== this) {
916
+ console.warn("This VistaView instance is not opened.");
917
+ return;
918
+ }
919
+ if (this.state.elmLength < 2)
920
+ return;
921
+ (t < 0 || t >= this.state.elmLength) && (t = (t % this.state.elmLength + this.state.elmLength) % this.state.elmLength);
922
+ const i = this.state.currentIndex;
923
+ this.state.currentIndex = t;
924
+ const n = this.state.abortController;
925
+ n == null || n.abort(), this.state.abortController = new AbortController(), this.swap(i, e);
891
926
  }
892
- getCurrentIndex() {
893
- return C.somethingOpened !== this ? -1 : this.currentIndex;
927
+ zoomIn() {
928
+ if (y.somethingOpened !== this) {
929
+ console.warn("This VistaView instance is not opened.");
930
+ return;
931
+ }
932
+ this.throttle.fio(
933
+ () => {
934
+ const t = this.state.children.images.find((e) => e.pos === 0);
935
+ t == null || t.animateZoom(1.68);
936
+ },
937
+ "zoom",
938
+ 222
939
+ );
894
940
  }
895
- view(t, e) {
896
- if (C.somethingOpened !== this || t < 0 || t >= this.elements.length)
941
+ zoomOut() {
942
+ if (y.somethingOpened !== this) {
943
+ console.warn("This VistaView instance is not opened.");
897
944
  return;
898
- const i = this.currentIndex;
899
- this.currentIndex = t;
900
- const n = this.abortController;
901
- n == null || n.abort(), this.abortController = new AbortController(), this.swap(i, e);
945
+ }
946
+ this.throttle.fio(
947
+ () => {
948
+ const t = this.state.children.images.find((e) => e.pos === 0);
949
+ t == null || t.animateZoom(0.68);
950
+ },
951
+ "zoom",
952
+ 222
953
+ );
954
+ }
955
+ getCurrentIndex() {
956
+ return this.state.currentIndex;
902
957
  }
903
958
  }
904
- function ot(s) {
959
+ function et(s) {
905
960
  let t = null;
906
- if (typeof s == "string" ? t = document.querySelectorAll(s) : s instanceof NodeList && (t = s), t)
961
+ if (typeof s == "string") {
962
+ if (t = document.querySelectorAll(s), t.length === 0)
963
+ return new Error("No elements found in node list.").toString();
907
964
  for (let e = 0; e < t.length; e++) {
908
- const i = t[e];
909
- if (!(i.dataset.vistaviewSrc || i.getAttribute("href") || i.getAttribute("src") || ""))
910
- return `Element at index ${e} is missing 'src' / 'data-vistaview-src' / 'href' attribute.`;
965
+ const i = t[e], n = i.tagName.toLowerCase();
966
+ if (n !== "img" && n !== "a")
967
+ return new Error(`Invalid element at index ${e}: expected <img>, <a>, got <${n}>`);
968
+ if (n === "a" && !(i.querySelector("img") !== null))
969
+ return new Error(`Invalid <a> element at index ${e}: must contain <img>`);
911
970
  }
912
- else {
971
+ } else {
913
972
  const e = s;
914
973
  for (let i = 0; i < e.length; i++)
915
974
  if (!e[i].src)
916
- return `Element at index ${i} is missing 'src' attribute.`;
975
+ return new Error(`Invalid image data at index ${i}: must have 'src'`);
917
976
  }
918
- return t || s;
977
+ return s;
919
978
  }
920
- function at({ elements: s, ...t }) {
921
- if (!s) throw new Error("No elements");
922
- let e = ot(s);
923
- if (typeof e == "string")
924
- return null;
925
- const i = new st(e, t);
979
+ function st({ elements: s, ...t }) {
980
+ if (!s)
981
+ return console.error(s), console.error("no elements provided"), console.warn("VistaView: silently returning."), null;
982
+ let e = et(s);
983
+ if (e instanceof Error)
984
+ return console.error(e), console.warn("VistaView: silently returning."), null;
985
+ const i = new tt(e, t);
926
986
  return {
927
987
  open: (n = 0) => i.open(n),
988
+ reset: () => i.reset(),
928
989
  close: () => i.close(),
929
990
  next: () => i.next(),
930
991
  prev: () => i.prev(),
992
+ zoomIn: () => i.zoomIn(),
993
+ zoomOut: () => i.zoomOut(),
931
994
  destroy: () => i.destroy(),
932
995
  getCurrentIndex: () => i.getCurrentIndex(),
933
996
  view: (n) => {
@@ -936,11 +999,18 @@ function at({ elements: s, ...t }) {
936
999
  };
937
1000
  }
938
1001
  export {
939
- M as DefaultOptions,
940
- Q as close,
941
- G as init,
942
- K as setup,
943
- tt as transition,
944
- at as vistaView,
945
- j as vistaViewDownload
1002
+ I as DefaultOptions,
1003
+ D as VistaBox,
1004
+ L as VistaHiresTransition,
1005
+ U as VistaImage,
1006
+ Q as VistaImageEvent,
1007
+ J as VistaPointers,
1008
+ j as VistaState,
1009
+ tt as VistaView,
1010
+ X as close,
1011
+ k as imageSetup,
1012
+ V as init,
1013
+ B as open,
1014
+ Y as transition,
1015
+ st as vistaView
946
1016
  };