vistaview 0.7.2 → 0.7.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -6,7 +6,7 @@ A lightweight, modern image lightbox library for the web. Zero dependencies, fra
6
6
 
7
7
  ## Features
8
8
 
9
- - ðŸŠķ **Lightweight** — ~40KB ESM (~10KB gzip), minimal footprint, zero dependencies
9
+ - ðŸŠķ **Lightweight** — ~43KB ESM (~10KB gzip), minimal footprint, zero dependencies
10
10
  - ðŸ“ą **Touch-first** — Swipe gestures for navigation and closing, pinch-to-zoom support
11
11
  - ðŸŽĻ **Customizable** — Configurable controls, animations, and styling via CSS variables
12
12
  - â™ŋ **Accessible** — Keyboard navigation, ARIA labels, reduced motion support
@@ -189,6 +189,10 @@ import {
189
189
  vistaView,
190
190
  vistaViewDownload, // Helper function for download control
191
191
  DefaultOptions, // Default configuration options
192
+ setup, // Default setup function
193
+ init, // Default init function
194
+ close, // Default close function
195
+ transition, // Default transition function
192
196
  } from 'vistaview';
193
197
 
194
198
  import type {
@@ -326,24 +330,24 @@ vite v6.4.1 building for production...
326
330
  ✓ 19 modules transformed.
327
331
 
328
332
  [vite:dts] Start generate declaration files...
329
- dist/styles/dark-rounded.css 2.15 kB │ gzip: 0.46 kB
330
- dist/style.css 7.09 kB │ gzip: 1.67 kB
331
- dist/svelte.js 0.62 kB │ gzip: 0.29 kB
332
- dist/solid.js 1.19 kB │ gzip: 0.54 kB
333
- dist/vue.js 1.36 kB │ gzip: 0.59 kB
334
- dist/react.js 1.67 kB │ gzip: 0.59 kB
335
- dist/vistaview.js 40.61 kB │ gzip: 9.86 kB
336
- [vite:dts] Declaration files built in 678ms.
337
-
338
- ✓ built in 790ms
333
+ dist/styles/dark-rounded.css 1.55 kB │ gzip: 0.41 kB
334
+ dist/style.css 6.88 kB │ gzip: 1.65 kB
335
+ dist/svelte.js 0.62 kB │ gzip: 0.29 kB
336
+ dist/solid.js 1.19 kB │ gzip: 0.54 kB
337
+ dist/vue.js 1.36 kB │ gzip: 0.59 kB
338
+ dist/react.js 1.67 kB │ gzip: 0.59 kB
339
+ dist/vistaview.js 43.30 kB │ gzip: 10.43 kB
340
+ [vite:dts] Declaration files built in 664ms.
341
+
342
+ ✓ built in 772ms
339
343
  vite v6.4.1 building for production...
340
344
  ✓ 13 modules transformed.
341
345
 
342
346
  [vite:dts] Start generate declaration files...
343
- dist/vistaview.umd.js 31.78 kB │ gzip: 8.82 kB
344
- [vite:dts] Declaration files built in 680ms.
347
+ dist/vistaview.umd.js 33.94 kB │ gzip: 9.29 kB
348
+ [vite:dts] Declaration files built in 657ms.
345
349
 
346
- ✓ built in 769ms
350
+ ✓ built in 751ms
347
351
  ```
348
352
 
349
353
  ## License
@@ -24,6 +24,8 @@ export declare class VistaView {
24
24
  private throttle;
25
25
  constructor(elements: NodeListOf<HTMLElement> | VistaImg[], options?: VistaOpt);
26
26
  private lastSwapTime;
27
+ private isRapidSwap;
28
+ private isRapidSwapRelease;
27
29
  private transitionCleanup;
28
30
  private swap;
29
31
  private getChildElements;
@@ -1 +1 @@
1
- {"version":3,"file":"vista-view.d.ts","sourceRoot":"","sources":["../../src/lib/vista-view.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAGV,QAAQ,EAGR,QAAQ,EAIR,gCAAgC,EACjC,MAAM,SAAS,CAAC;AAajB,eAAO,MAAM,gBAAgB,EAAE;IAAE,eAAe,EAAE,SAAS,GAAG,IAAI,CAAA;CAEjE,CAAC;AAEF,qBAAa,SAAS;IACpB,OAAO,EAAE,QAAQ,CAAC;IAClB,QAAQ,EAAE,UAAU,CAAC,WAAW,CAAC,GAAG,QAAQ,EAAE,CAAC;IAC/C,eAAe,EAAE,OAAO,CAAC;IAEzB,OAAO,CAAC,YAAY,CAAc;IAClC,OAAO,CAAC,eAAe,CAAmE;IAE1F,OAAO,CAAC,aAAa,CAAuB;IAC5C,OAAO,CAAC,YAAY,CAAqB;IACzC,OAAO,CAAC,aAAa,CAAuB;IAC5C,OAAO,CAAC,kBAAkB,CAAiC;IAC3D,OAAO,CAAC,QAAQ,CAA8B;IAC9C,OAAO,CAAC,UAAU,CAAkB;IACpC,OAAO,CAAC,gBAAgB,CAMV;IAEd,IAAI,EAAE,WAAW,GAAG,IAAI,CAAQ;IAChC,cAAc,EAAE,WAAW,GAAG,IAAI,CAAQ;IAC1C,EAAE,CAAC,CAAC,SAAS,WAAW,EAAE,QAAQ,EAAE,MAAM,GAAG,CAAC,GAAG,IAAI;IAIrD,OAAO,CAAC,eAAe,CAIrB;IAEF,OAAO,CAAC,qBAAqB,CAAwD;IAErF,OAAO,CAAC,eAAe,CAAgC;IAEvD,OAAO,CAAC,QAAQ,CAAkB;gBAEtB,QAAQ,EAAE,UAAU,CAAC,WAAW,CAAC,GAAG,QAAQ,EAAE,EAAE,OAAO,GAAE,QAAa;IAsElF,OAAO,CAAC,YAAY,CAAK;IACzB,OAAO,CAAC,iBAAiB,CAA6B;YACxC,IAAI;IA2HlB,OAAO,CAAC,gBAAgB;IAkDxB,UAAU,EAAE,OAAO,CAAS;IAC5B,OAAO,CAAC,MAAM;IASd,OAAO,CAAC,OAAO;IAUf,OAAO,CAAC,kBAAkB;IAmC1B,OAAO,CAAC,eAAe;IAmCvB,OAAO,CAAC,mBAAmB;IA4D3B,OAAO,CAAC,SAAS,CAuBf;IAEF,OAAO,CAAC,QAAQ,CAYd;IAEF,OAAO,CAAC,eAAe,CAkBrB;IAGF,OAAO,CAAC,gBAAgB,CAAyD;IACjF,uBAAuB,CAAC,QAAQ,EAAE,CAAC,CAAC,EAAE,gCAAgC,KAAK,IAAI,GAAG,IAAI;IAGtF,OAAO,CAAC,0BAA0B;IAIlC,OAAO,CAAC,0BAA0B,CAwDhC;IAGF,IAAI,CAAC,UAAU,GAAE,MAAU,GAAG,IAAI;IA4I5B,KAAK,CAAC,OAAO,GAAE,OAAc,GAAG,OAAO,CAAC,IAAI,CAAC;IA0DnD,IAAI,IAAI,IAAI;IASZ,IAAI,IAAI,IAAI;IASZ,OAAO,IAAI,IAAI;IAcf,eAAe,IAAI,MAAM;IAOzB,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE;QAAE,IAAI,EAAE,OAAO,CAAC;QAAC,IAAI,EAAE,OAAO,CAAA;KAAE,GAAG,IAAI;CAoBlE"}
1
+ {"version":3,"file":"vista-view.d.ts","sourceRoot":"","sources":["../../src/lib/vista-view.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAGV,QAAQ,EAGR,QAAQ,EAIR,gCAAgC,EACjC,MAAM,SAAS,CAAC;AAajB,eAAO,MAAM,gBAAgB,EAAE;IAAE,eAAe,EAAE,SAAS,GAAG,IAAI,CAAA;CAEjE,CAAC;AAEF,qBAAa,SAAS;IACpB,OAAO,EAAE,QAAQ,CAAC;IAClB,QAAQ,EAAE,UAAU,CAAC,WAAW,CAAC,GAAG,QAAQ,EAAE,CAAC;IAC/C,eAAe,EAAE,OAAO,CAAC;IAEzB,OAAO,CAAC,YAAY,CAAc;IAClC,OAAO,CAAC,eAAe,CAAmE;IAE1F,OAAO,CAAC,aAAa,CAAuB;IAC5C,OAAO,CAAC,YAAY,CAAqB;IACzC,OAAO,CAAC,aAAa,CAAuB;IAC5C,OAAO,CAAC,kBAAkB,CAAiC;IAC3D,OAAO,CAAC,QAAQ,CAA8B;IAC9C,OAAO,CAAC,UAAU,CAAkB;IACpC,OAAO,CAAC,gBAAgB,CAMV;IAEd,IAAI,EAAE,WAAW,GAAG,IAAI,CAAQ;IAChC,cAAc,EAAE,WAAW,GAAG,IAAI,CAAQ;IAC1C,EAAE,CAAC,CAAC,SAAS,WAAW,EAAE,QAAQ,EAAE,MAAM,GAAG,CAAC,GAAG,IAAI;IAIrD,OAAO,CAAC,eAAe,CAIrB;IAEF,OAAO,CAAC,qBAAqB,CAAwD;IAErF,OAAO,CAAC,eAAe,CAAgC;IAEvD,OAAO,CAAC,QAAQ,CAAkB;gBAEtB,QAAQ,EAAE,UAAU,CAAC,WAAW,CAAC,GAAG,QAAQ,EAAE,EAAE,OAAO,GAAE,QAAa;IA8DlF,OAAO,CAAC,YAAY,CAAK;IACzB,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,kBAAkB,CAAK;IAC/B,OAAO,CAAC,iBAAiB,CAA6B;YACxC,IAAI;IAyIlB,OAAO,CAAC,gBAAgB;IAkDxB,UAAU,EAAE,OAAO,CAAS;IAC5B,OAAO,CAAC,MAAM;IASd,OAAO,CAAC,OAAO;IAUf,OAAO,CAAC,kBAAkB;IAmC1B,OAAO,CAAC,eAAe;IA4CvB,OAAO,CAAC,mBAAmB;IAiE3B,OAAO,CAAC,SAAS,CAuBf;IAEF,OAAO,CAAC,QAAQ,CAYd;IAEF,OAAO,CAAC,eAAe,CAkBrB;IAGF,OAAO,CAAC,gBAAgB,CAAyD;IACjF,uBAAuB,CAAC,QAAQ,EAAE,CAAC,CAAC,EAAE,gCAAgC,KAAK,IAAI,GAAG,IAAI;IAGtF,OAAO,CAAC,0BAA0B;IAIlC,OAAO,CAAC,0BAA0B,CAwDhC;IAGF,IAAI,CAAC,UAAU,GAAE,MAAU,GAAG,IAAI;IA4I5B,KAAK,CAAC,OAAO,GAAE,OAAc,GAAG,OAAO,CAAC,IAAI,CAAC;IA0DnD,IAAI,IAAI,IAAI;IASZ,IAAI,IAAI,IAAI;IASZ,OAAO,IAAI,IAAI;IAcf,eAAe,IAAI,MAAM;IAOzB,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE;QAAE,IAAI,EAAE,OAAO,CAAC;QAAC,IAAI,EAAE,OAAO,CAAA;KAAE,GAAG,IAAI;CAoBlE"}
@@ -1 +1 @@
1
- .vvw-ui:is(button),.vvw-ui>button{background-color:#222;color:#eee}.vvw-ui.vvw-index,.vvw-ui.vvw-desc{background-color:#222;color:#eee}.vvw-bottom-bar>div:first-child button:last-child,.vvw-bottom-bar>div:first-child div:last-child{border-top-right-radius:5px}.vvw-bottom-bar>div:nth-child(2){padding:0 1rem}.vvw-bottom-bar>div:nth-child(2) button:last-child,.vvw-bottom-bar>div:nth-child(2) div:last-child{border-top-right-radius:5px}.vvw-bottom-bar>div:nth-child(2) button:first-child,.vvw-bottom-bar>div:nth-child(2) div:first-child{border-top-left-radius:5px}.vvw-bottom-bar>div:last-child button:first-child,.vvw-bottom-bar>div:last-child div:first-child{border-top-left-radius:5px}.vvw-top-bar>div:first-child button:last-child,.vvw-top-bar>div:first-child div:last-child{border-bottom-right-radius:5px}.vvw-top-bar>div:nth-child(2){padding:0 1rem}.vvw-top-bar>div:nth-child(2) button:last-child,.vvw-top-bar>div:nth-child(2) div:last-child{border-bottom-right-radius:5px}.vvw-top-bar>div:nth-child(2) button:first-child,.vvw-top-bar>div:nth-child(2) div:first-child{border-bottom-left-radius:5px}.vvw-top-bar>div:last-child button:first-child,.vvw-top-bar>div:last-child div:first-child{border-bottom-left-radius:5px}.vvw-ui{outline:2px solid #333}.vvw-ui:is(button){outline:2px solid #333}.vvw-ui:is(button) svg{width:21px;height:21px}.vvw-ui.vvw-prev{border-top-right-radius:5px;border-bottom-right-radius:5px;overflow:hidden}.vvw-ui.vvw-prev button{padding:18px 3px;transition:padding-left 333ms ease}.vvw-ui.vvw-prev button svg{transition:transform 333ms 111ms ease}.vvw-ui.vvw-prev:hover button{padding-left:8px}.vvw-ui.vvw-prev:hover button svg{transform:translate(-3px)}.vvw-ui.vvw-next{border-top-left-radius:5px;border-bottom-left-radius:5px;overflow:hidden}.vvw-ui.vvw-next button{padding:18px 3px;transition:padding-right 333ms ease}.vvw-ui.vvw-next button svg{transition:transform 333ms 111ms ease}.vvw-ui.vvw-next:hover button{padding-right:8px}.vvw-ui.vvw-next:hover button svg{transform:translate(3px)}
1
+ .vvw-ui{outline:2px solid #333}.vvw-ui:is(button),.vvw-ui>button,.vvw-ui.vvw-index,.vvw-ui.vvw-desc{background-color:#222;color:#eee}.vvw-ui:is(button){outline:2px solid #333}.vvw-ui:is(button) svg{width:21px;height:21px}.vvw-ui.vvw-prev,.vvw-ui.vvw-next{overflow:hidden}.vvw-ui.vvw-prev button,.vvw-ui.vvw-next button{padding:18px 3px;transition:padding-left 333ms ease,padding-right 333ms ease}.vvw-ui.vvw-prev button svg,.vvw-ui.vvw-next button svg{transition:transform 333ms 111ms ease}.vvw-ui.vvw-prev:hover button svg,.vvw-ui.vvw-next:hover button svg{transform:translate(-3px)}.vvw-ui.vvw-prev{border-top-right-radius:5px;border-bottom-right-radius:5px}.vvw-ui.vvw-prev:hover button{padding-left:8px}.vvw-ui.vvw-next{border-top-left-radius:5px;border-bottom-left-radius:5px}.vvw-ui.vvw-next:hover button{padding-right:8px}.vvw-ui.vvw-next:hover button svg{transform:translate(3px)}.vvw-bottom-bar>div:nth-child(2),.vvw-top-bar>div:nth-child(2){padding:0 1rem}.vvw-bottom-bar>div:first-child :is(button,div):last-child,.vvw-bottom-bar>div:nth-child(2) :is(button,div):last-child{border-top-right-radius:5px}.vvw-bottom-bar>div:nth-child(2) :is(button,div):first-child,.vvw-bottom-bar>div:last-child :is(button,div):first-child{border-top-left-radius:5px}.vvw-top-bar>div:first-child :is(button,div):last-child,.vvw-top-bar>div:nth-child(2) :is(button,div):last-child{border-bottom-right-radius:5px}.vvw-top-bar>div:nth-child(2) :is(button,div):first-child,.vvw-top-bar>div:last-child :is(button,div):first-child{border-bottom-left-radius:5px}
@@ -1,5 +1,9 @@
1
1
  export type * from './lib/types';
2
2
  export { vistaView } from './lib/main';
3
3
  export { DefaultOptions } from './lib/defaults/options';
4
+ export { setup } from './lib/defaults/setup';
5
+ export { init } from './lib/defaults/init';
6
+ export { close } from './lib/defaults/close';
7
+ export { transition } from './lib/defaults/transition';
4
8
  export { vistaViewDownload } from './lib/components';
5
9
  //# sourceMappingURL=vistaview.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"vistaview.d.ts","sourceRoot":"","sources":["../src/vistaview.ts"],"names":[],"mappings":"AAAA,mBAAmB,aAAa,CAAC;AAEjC,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC"}
1
+ {"version":3,"file":"vistaview.d.ts","sourceRoot":"","sources":["../src/vistaview.ts"],"names":[],"mappings":"AAAA,mBAAmB,aAAa,CAAC;AAEjC,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAC7C,OAAO,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAC3C,OAAO,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC"}
package/dist/vistaview.js CHANGED
@@ -1,27 +1,27 @@
1
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 S(s) {
2
+ var R = (s, t, e) => t in s ? F(s, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : s[t] = e;
3
+ var l = (s, t, e) => R(s, typeof t != "symbol" ? t + "" : t, e);
4
+ function T(s) {
5
5
  return s && !/^0(px|%|r?em|vw|vh|vmin|vmax|cm|mm|in|pt|pc|ex|ch)?$/i.test(s.trim()) && s;
6
6
  }
7
- function z(s) {
7
+ function A(s) {
8
8
  const e = window.getComputedStyle(s).objectFit || "", { width: i, height: n } = s.getBoundingClientRect(), o = s.naturalWidth, r = s.naturalHeight;
9
9
  if (!e)
10
10
  return { width: i, height: n };
11
11
  if (!o || !r)
12
12
  return { width: i, height: n };
13
- const a = o / r, l = i / n;
13
+ const a = o / r, h = i / n;
14
14
  switch (e) {
15
15
  case "fill":
16
16
  return { width: i, height: n };
17
17
  case "none":
18
18
  return { width: o, height: r };
19
19
  case "contain":
20
- return a > l ? { width: i, height: i / a } : { width: n * a, height: n };
20
+ return a > h ? { width: i, height: i / a } : { width: n * a, height: n };
21
21
  case "cover":
22
- return a < l ? { width: i, height: i / a } : { width: n * a, height: n };
22
+ return a < h ? { width: i, height: i / a } : { width: n * a, height: n };
23
23
  case "scale-down": {
24
- const c = { width: o, height: r }, m = a > l ? { width: i, height: i / a } : { width: n * a, height: n };
24
+ const c = { width: o, height: r }, m = a > h ? { width: i, height: i / a } : { width: n * a, height: n };
25
25
  return m.width <= c.width && m.height <= c.height ? m : c;
26
26
  }
27
27
  }
@@ -42,8 +42,8 @@ function D(s) {
42
42
  naturalHeight: s.naturalHeight
43
43
  };
44
44
  }
45
- function k(s) {
46
- const t = s.imageElm ? D(s.imageElm) : null, e = s.anchorElm ? D(s.anchorElm) : null, i = S(t == null ? void 0 : t.borderRadius), n = e && S(e == null ? void 0 : e.borderRadius), o = (n ? e == null ? void 0 : e.borderRadius : i ? t == null ? void 0 : t.borderRadius : "") || "";
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), o = (n ? e == null ? void 0 : e.borderRadius : i ? t == null ? void 0 : t.borderRadius : "") || "";
47
47
  return {
48
48
  fit: (t == null ? void 0 : t.objectFit) || (e == null ? void 0 : e.objectFit) || "",
49
49
  pos: (t == null ? void 0 : t.objectPosition) || "",
@@ -66,14 +66,14 @@ function W(s, t, e, i = !1) {
66
66
  // pos,
67
67
  // overflow,
68
68
  nw: a,
69
- nh: l,
69
+ nh: h,
70
70
  br: c,
71
71
  top: m,
72
72
  left: p
73
- } = k(s), x = Math.min(Math.max(p, -o), window.innerWidth + o) - window.innerWidth / 2 + o / 2, b = Math.min(Math.max(m, -r), window.innerHeight + r) - window.innerHeight / 2 + r / 2, d = e.style;
74
- d.width = `${o}px`, d.height = `${r}px`, d.objectFit = n, e.width = a, e.height = l, d.setProperty("--vvw-init-radius", `${c}`), d.setProperty("--vvw-pulse-radius", `calc(1.3 * ${c})`), d.setProperty("--vvw-init-x", `${x}px`), d.setProperty("--vvw-init-y", `${b}px`), i && (d.setProperty("--vvw-current-x", `${x}px`), d.setProperty("--vvw-current-y", `${b}px`));
75
- const u = z(s.imageElm), f = Math.min(o, u.width), g = Math.min(r, u.height), v = t.style;
76
- v.setProperty("--vvw-init-radius", `${c}`), v.setProperty("--vvw-init-w", `${f}px`), v.setProperty("--vvw-init-h", `${g}px`), i && (v.setProperty("--vvw-current-radius", `${c}`), v.setProperty("--vvw-current-w", `${f}px`), v.setProperty("--vvw-current-h", `${g}px`), t.dataset.vvwWidth = f.toString(), t.dataset.vvwHeight = g.toString());
73
+ } = z(s), x = Math.min(Math.max(p, -o), window.innerWidth + o) - window.innerWidth / 2 + o / 2, g = Math.min(Math.max(m, -r), window.innerHeight + r) - window.innerHeight / 2 + r / 2, d = e.style;
74
+ d.width = `${o}px`, d.height = `${r}px`, d.objectFit = n, e.width = a, e.height = h, d.setProperty("--vvw-init-radius", `${c}`), d.setProperty("--vvw-pulse-radius", `calc(1.3 * ${c})`), d.setProperty("--vvw-init-x", `${x}px`), d.setProperty("--vvw-init-y", `${g}px`), i && (d.setProperty("--vvw-current-x", `${x}px`), d.setProperty("--vvw-current-y", `${g}px`));
75
+ const u = A(s.imageElm), b = Math.min(o, u.width), f = Math.min(r, 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
77
  }
78
78
  function M(s) {
79
79
  const t = window.innerWidth, e = window.innerHeight, i = s.naturalWidth, n = s.naturalHeight;
@@ -85,20 +85,20 @@ function M(s) {
85
85
  height: n
86
86
  };
87
87
  const o = i / n, r = t / e;
88
- let a, l;
89
- return o > r ? (a = t, l = t / o) : (l = e, a = e * o), {
88
+ let a, h;
89
+ return o > r ? (a = t, h = t / o) : (h = e, a = e * o), {
90
90
  width: a,
91
- height: l
91
+ height: h
92
92
  };
93
93
  }
94
- function q(s, t, e) {
94
+ function k(s, t, e) {
95
95
  return Math.min(Math.max(s, t), e);
96
96
  }
97
97
  function L(s, t = 2) {
98
98
  const e = Math.pow(10, t);
99
99
  return Math.round(s * e) / e;
100
100
  }
101
- const 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>', 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>', X = '<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>', N = '<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>';
101
+ const q = '<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>', X = '<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>', N = '<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
102
  let $ = null;
103
103
  function B() {
104
104
  return $ || (window.trustedTypes || (window.trustedTypes = {
@@ -171,7 +171,7 @@ function K({
171
171
  <div class="vvw-image-container"></div>
172
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
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">${R}</button></div>
174
+ <div class="vvw-prev vvw-ui"><button aria-label="Previous">${q}</button></div>
175
175
  <div class="vvw-next vvw-ui"><button aria-label="Next">${O}</button></div>
176
176
  </div>
177
177
  </div>`
@@ -207,17 +207,17 @@ function J(s) {
207
207
  e = { x: n.pointer.x, y: n.pointer.y };
208
208
  const r = e.x - t.x, a = e.y - t.y;
209
209
  if (!i && Math.abs(a) > Math.abs(r) || i === "y") {
210
- const l = a / window.innerHeight * 100;
211
- s.imageContainer.style.transition = "none", s.imageContainer.style.transform = `translateY(${l}vh)`, i = "y";
210
+ const h = a / window.innerHeight * 100;
211
+ s.imageContainer.style.transition = "none", s.imageContainer.style.transform = `translateY(${h}vh)`, i = "y";
212
212
  } else if (!i && Math.abs(r) > Math.abs(a) || i === "x") {
213
- const l = r / window.innerWidth * 100;
214
- s.imageContainer.style.transition = "none", s.imageContainer.style.transform = `translateX(${l}vw)`, i = "x";
213
+ const h = r / window.innerWidth * 100;
214
+ s.imageContainer.style.transition = "none", s.imageContainer.style.transform = `translateX(${h}vw)`, i = "x";
215
215
  }
216
216
  }
217
217
  if (n.event === "up" || n.event === "cancel") {
218
218
  let r = function(a) {
219
- var l;
220
- (l = s.imageContainer) == null || l.addEventListener("transitionend", function c() {
219
+ var h;
220
+ (h = s.imageContainer) == null || h.addEventListener("transitionend", function c() {
221
221
  var m;
222
222
  (m = s.imageContainer) == null || m.removeEventListener("transitionend", c), s.imageContainer.style.transition = "", s.imageContainer.style.transform = "";
223
223
  }), s.imageContainer.style.transition = "transform 222ms ease", s.imageContainer.style.transform = a;
@@ -227,8 +227,8 @@ function J(s) {
227
227
  Math.abs(a) > 144 ? (s.imageContainer.style.transition = "transform 222ms ease", s.imageContainer.style.transform = "translateY(0vh)", s.close()) : r("translateY(0vh)");
228
228
  }
229
229
  if (i === "x") {
230
- const a = e.x - t.x, l = n.pointer.movementX, c = 1;
231
- s.imageContainer.style.transition = "", a > 0 && Math.abs(l) > c ? s.prev() : a < 0 && Math.abs(l) > c ? s.next() : r("translateX(0vw)");
230
+ const a = e.x - t.x, h = n.pointer.movementX, c = 1;
231
+ s.imageContainer.style.transition = "", a > 0 && Math.abs(h) > c ? s.prev() : a < 0 && Math.abs(h) > c ? s.next() : r("translateX(0vw)");
232
232
  }
233
233
  i = null, t = { x: 0, y: 0 }, e = { x: 0, y: 0 };
234
234
  }
@@ -269,17 +269,17 @@ function tt({
269
269
  }
270
270
  class et {
271
271
  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", () => {
272
+ l(this, "pointers", []);
273
+ l(this, "elm");
274
+ l(this, "listeners", []);
275
+ l(this, "lastPointerDownId", null);
276
+ l(this, "removeLastPointer", () => {
277
277
  if (this.pointers.length && this.lastPointerDownId !== null) {
278
278
  const t = this.pointers.findIndex((e) => e.id === this.lastPointerDownId);
279
279
  t !== -1 && this.pointers.splice(t, 1);
280
280
  }
281
281
  });
282
- h(this, "onPointerDown", (t) => {
282
+ l(this, "onPointerDown", (t) => {
283
283
  if (!this.listeners.length || t.button !== 0) return;
284
284
  t.preventDefault(), this.lastPointerDownId = t.pointerId, window.addEventListener("contextmenu", this.removeLastPointer, { once: !0 }), window.addEventListener("auxclick", this.removeLastPointer, { once: !0 });
285
285
  let e = {
@@ -298,7 +298,7 @@ class et {
298
298
  })
299
299
  );
300
300
  });
301
- h(this, "onPointerMove", (t) => {
301
+ l(this, "onPointerMove", (t) => {
302
302
  if (!this.listeners.length) return;
303
303
  t.preventDefault();
304
304
  const e = this.pointers.find((i) => i.id === t.pointerId);
@@ -311,7 +311,7 @@ class et {
311
311
  })
312
312
  ));
313
313
  });
314
- h(this, "onPointerUp", (t) => {
314
+ l(this, "onPointerUp", (t) => {
315
315
  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
316
  return;
317
317
  t.preventDefault();
@@ -329,7 +329,7 @@ class et {
329
329
  })
330
330
  );
331
331
  });
332
- h(this, "onPointerCancel", (t) => {
332
+ l(this, "onPointerCancel", (t) => {
333
333
  if (!this.listeners.length || t.target instanceof Node && !this.elm.contains(t.target) && t.target !== document.querySelector("html") && t.target !== document)
334
334
  return;
335
335
  t.preventDefault();
@@ -379,18 +379,18 @@ class et {
379
379
  }
380
380
  class it {
381
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 });
382
+ l(this, "maxZoomLevel");
383
+ l(this, "image", null);
384
+ l(this, "rect", null);
385
+ l(this, "initialCenter", { x: 0, y: 0 });
386
+ l(this, "maxDimension", { width: 0 });
387
+ l(this, "minDimension", { initialWidth: 0, initialHeight: 0, minWidth: 0, closingWidth: 0 });
388
+ l(this, "accumulatedTranslate", { x: 0, y: 0 });
389
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);
390
+ l(this, "scale", 1);
391
+ l(this, "translate", { x: 0, y: 0 });
392
+ l(this, "onScale", null);
393
+ l(this, "animationTimestamp", 0);
394
394
  this.maxZoomLevel = t, this.onScale = e;
395
395
  }
396
396
  clean() {
@@ -425,7 +425,7 @@ class it {
425
425
  if (!this.image) return;
426
426
  this.rect || (this.rect = this.image.getBoundingClientRect()), e || (e = this.initialCenter);
427
427
  const i = this.snapToTargetIfClose(
428
- q(this.rect.width * t, this.minDimension.minWidth, this.maxDimension.width),
428
+ k(this.rect.width * t, this.minDimension.minWidth, this.maxDimension.width),
429
429
  this.minDimension.initialWidth
430
430
  );
431
431
  this.onScale && this.onScale({
@@ -433,8 +433,8 @@ class it {
433
433
  isMax: i >= this.maxDimension.width,
434
434
  isMin: i <= this.minDimension.initialWidth
435
435
  }), this.scale = L(i / this.rect.width);
436
- const n = this.rect.left + this.rect.width / 2, o = this.rect.top + this.rect.height / 2, r = this.initialCenter.x - n, a = this.initialCenter.y - o, l = r * (1 - this.scale), c = a * (1 - this.scale), m = e.x - this.initialCenter.x, p = e.y - this.initialCenter.y;
437
- this.translate.x = L(l + m), 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 = "";
436
+ const n = this.rect.left + this.rect.width / 2, o = this.rect.top + this.rect.height / 2, r = this.initialCenter.x - n, a = this.initialCenter.y - o, h = r * (1 - this.scale), c = a * (1 - this.scale), m = e.x - this.initialCenter.x, p = e.y - this.initialCenter.y;
437
+ this.translate.x = L(h + m), 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
438
  }
439
439
  moveAndNormalize(t) {
440
440
  let e = 0, i = !1;
@@ -500,7 +500,7 @@ class it {
500
500
  }
501
501
  class nt {
502
502
  constructor() {
503
- h(this, "fiolast", {});
503
+ l(this, "fiolast", {});
504
504
  }
505
505
  // first in out
506
506
  fio(t, e, i = 50) {
@@ -514,37 +514,39 @@ class nt {
514
514
  o >= i && r();
515
515
  }
516
516
  }
517
- const y = {
517
+ const C = {
518
518
  somethingOpened: null
519
519
  };
520
520
  class st {
521
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", _);
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) => {
522
+ l(this, "options");
523
+ l(this, "elements");
524
+ l(this, "isReducedMotion");
525
+ l(this, "currentIndex", -1);
526
+ l(this, "currentChildren", null);
527
+ l(this, "setupFunction", _);
528
+ l(this, "initFunction", G);
529
+ l(this, "closeFunction", Q);
530
+ l(this, "transitionFunction", tt);
531
+ l(this, "pointers", null);
532
+ l(this, "imageState");
533
+ l(this, "imageTransitions", /* @__PURE__ */ new Map());
534
+ l(this, "root", null);
535
+ l(this, "imageContainer", null);
536
+ l(this, "onClickElements", (t) => {
537
537
  t.preventDefault();
538
538
  const e = t.currentTarget;
539
539
  e.dataset.vistaIdx && this.open(parseInt(e.dataset.vistaIdx));
540
540
  });
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, "transitionCleanup", null);
546
- h(this, "isZoomedIn", !1);
547
- h(this, "onKeyDown", (t) => {
541
+ l(this, "defaultOnClickHandler", (t) => t.preventDefault());
542
+ l(this, "abortController", null);
543
+ l(this, "throttle", new nt());
544
+ l(this, "lastSwapTime", 0);
545
+ l(this, "isRapidSwap", !1);
546
+ l(this, "isRapidSwapRelease", 0);
547
+ l(this, "transitionCleanup", null);
548
+ l(this, "isZoomedIn", !1);
549
+ l(this, "onKeyDown", (t) => {
548
550
  switch (t.key) {
549
551
  case "ArrowLeft":
550
552
  t.preventDefault(), this.prev();
@@ -563,7 +565,7 @@ class st {
563
565
  break;
564
566
  }
565
567
  });
566
- h(this, "onScroll", (t) => {
568
+ l(this, "onScroll", (t) => {
567
569
  t.preventDefault();
568
570
  const e = t.deltaY;
569
571
  this.imageState.setInitialCenter({
@@ -571,7 +573,7 @@ class st {
571
573
  y: t.clientY
572
574
  }), e < 0 ? this.zoomIn() : e > 0 && this.zoomOut();
573
575
  });
574
- h(this, "onResizeHandler", () => {
576
+ l(this, "onResizeHandler", () => {
575
577
  this.currentChildren.htmls.forEach((t, e) => {
576
578
  const i = this.currentChildren.images[e], n = t.querySelector("img.vvw-img-hi"), o = t.querySelector("img.vvw-img-lo");
577
579
  if (W(i, n, o, !1), n.classList.contains("vvw--loaded")) {
@@ -581,8 +583,8 @@ class st {
581
583
  });
582
584
  });
583
585
  /// POINTERS
584
- h(this, "pointerListeners", []);
585
- h(this, "getInternalPointerListener", () => {
586
+ l(this, "pointerListeners", []);
587
+ l(this, "getInternalPointerListener", () => {
586
588
  const t = this.imageState;
587
589
  let e = 0, i = !1, n = () => {
588
590
  };
@@ -628,14 +630,8 @@ class st {
628
630
  }, this.imageState = new it(
629
631
  this.options.maxZoomLevel,
630
632
  (i) => {
631
- var n, o, r, a, l, c;
632
- i.isMin ? (this.isZoomedIn = !1, (n = this.qs(".vvw-zoom-out")) == null || n.setAttribute("disabled", "true"), (o = this.qs('.vvw-item[data-vvw-idx="' + this.currentIndex + '"]')) == null || o.style.setProperty(
633
- "pointer-events",
634
- "none"
635
- )) : (this.isZoomedIn = !0, (r = this.qs(".vvw-zoom-out")) == null || r.removeAttribute("disabled"), (a = this.qs('.vvw-item[data-vvw-idx="' + this.currentIndex + '"]')) == null || a.style.setProperty(
636
- "pointer-events",
637
- "auto"
638
- )), i.isMax ? (l = this.qs(".vvw-zoom-in")) == null || l.setAttribute("disabled", "true") : (c = this.qs(".vvw-zoom-in")) == null || c.removeAttribute("disabled");
633
+ var n, o, r, a;
634
+ i.isMin ? (this.isZoomedIn = !1, (n = this.qs(".vvw-zoom-out")) == null || n.setAttribute("disabled", "true")) : (this.isZoomedIn = !0, (o = this.qs(".vvw-zoom-out")) == null || o.removeAttribute("disabled")), i.isMax ? (r = this.qs(".vvw-zoom-in")) == null || r.setAttribute("disabled", "true") : (a = this.qs(".vvw-zoom-in")) == null || a.removeAttribute("disabled");
639
635
  }
640
636
  ), 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) => {
641
637
  i.dataset.vistaIdx = n.toString(), i.addEventListener("click", this.defaultOnClickHandler), i.addEventListener("pointerup", this.onClickElements);
@@ -645,45 +641,51 @@ class st {
645
641
  return this.root ? this.root.querySelector(t) : null;
646
642
  }
647
643
  async swap(t, e) {
648
- const i = this.options.preloads || 0, n = this.currentIndex, { htmls: o, images: r } = this.getChildElements(i, n), a = this.imageContainer, l = this.currentChildren, c = {
649
- htmlElements: { from: l.htmls, to: o },
650
- images: { from: l.images, to: r },
644
+ const i = this.options.preloads || 0, n = this.currentIndex, { htmls: o, images: r } = this.getChildElements(i, n), a = this.imageContainer, h = this.currentChildren, c = {
645
+ htmlElements: { from: h.htmls, to: o },
646
+ images: { from: h.images, to: r },
651
647
  index: { from: t, to: this.currentIndex },
652
648
  via: e || { next: !1, prev: !1 },
653
649
  vistaView: this
654
650
  };
655
651
  this.setupFunction(c), this.currentChildren = { htmls: o, images: r }, this.displayActiveIndex();
656
- const m = this.abortController.signal, x = performance.now() - this.lastSwapTime < this.options.rapidLimit, b = o[Math.floor(o.length / 2)].dataset.vvwIdx;
657
- if (x) {
658
- this.imageState.reset(), a.innerHTML = "", this.transitionCleanup && this.transitionCleanup(), o.forEach((C) => {
659
- a.appendChild(C);
660
- }), this.lastSwapTime = performance.now(), this.waitForImagesToLoad(), this.options.onImageView && this.options.onImageView(c);
652
+ const m = this.abortController.signal, x = performance.now() - this.lastSwapTime < this.options.rapidLimit;
653
+ if (this.isRapidSwap = x, a.querySelectorAll(".vvw-item img.vvw-img-hi").forEach((y) => y.classList.add("vvw--load-cancelled")), x) {
654
+ this.imageState.reset(), a.innerHTML = "", this.transitionCleanup && this.transitionCleanup(), o.forEach((y) => {
655
+ a.appendChild(y);
656
+ }), this.lastSwapTime = performance.now(), this.waitForImagesToLoad(), this.options.onImageView && this.options.onImageView(c), this.isRapidSwapRelease && clearTimeout(this.isRapidSwapRelease), this.isRapidSwapRelease = setTimeout(() => {
657
+ this.isRapidSwap = !1;
658
+ }, 333);
661
659
  return;
662
660
  }
663
- const d = this.transitionFunction(c, m);
664
- d && (this.transitionCleanup = d.cleanup, await d.transitionEnded), this.lastSwapTime = performance.now();
665
- const u = a.querySelector(
666
- `.vvw-item[data-vvw-idx="${b}"] img.vvw-img-hi`
667
- ), f = this.imageTransitions.get(u);
661
+ const g = this.transitionFunction(c, m);
662
+ g && (this.transitionCleanup = g.cleanup, await g.transitionEnded), this.lastSwapTime = performance.now();
663
+ const d = o[Math.floor(o.length / 2)].dataset.vvwIdx, u = a.querySelector(
664
+ `.vvw-item[data-vvw-idx="${d}"] img.vvw-img-hi`
665
+ ), b = this.imageTransitions.get(u);
668
666
  this.imageTransitions.delete(u);
669
- const g = u.getAttribute("style") || "", v = u.classList.contains("vvw--loaded"), E = u.classList.contains("vvw--ready"), I = u.width, T = u.height;
670
- this.imageState.reset(), a.innerHTML = "", this.transitionCleanup && this.transitionCleanup(), o.forEach((C) => {
671
- const w = C.querySelector("img.vvw-img-hi");
672
- C.dataset.vvwPos === "0" && !m.aborted && g && I && T && (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 = T), w.setAttribute("style", g)), a.appendChild(C), C.dataset.vvwPos === "0" && !m.aborted && E ? (this.imageState.setCurrentImage(w), this.imageState.setInitialCenter()) : C.dataset.vvwPos === "0" && !m.aborted && g && I && T && v && f && (this.imageTransitions.set(w, f), this.transitionImage(w, () => {
673
- this.imageState.setCurrentImage(w), this.imageState.setInitialCenter(), w.classList.add("vvw--ready");
674
- }));
675
- }), this.waitForImagesToLoad(), this.options.onImageView && this.options.onImageView(c);
667
+ const f = u.getAttribute("style") || "", v = u.classList.contains("vvw--loaded"), E = u.classList.contains("vvw--ready"), I = u.width, S = u.height;
668
+ this.imageState.reset(), a.innerHTML = "", this.transitionCleanup && this.transitionCleanup(), o.forEach((y) => {
669
+ const w = y.querySelector("img.vvw-img-hi");
670
+ y.dataset.vvwPos === "0" && !m.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)), a.appendChild(y), y.dataset.vvwPos === "0" && !m.aborted && E ? (this.imageState.setCurrentImage(w), this.imageState.setInitialCenter()) : y.dataset.vvwPos === "0" && !m.aborted && f && I && S && v && b && (this.imageTransitions.set(w, b), this.transitionImage(
671
+ w,
672
+ () => {
673
+ this.imageState.setCurrentImage(w), this.imageState.setInitialCenter(), w.classList.add("vvw--ready");
674
+ }
675
+ // false
676
+ ));
677
+ }), this.isRapidSwap = !1, this.waitForImagesToLoad(), this.options.onImageView && this.options.onImageView(c);
676
678
  }
677
679
  getChildElements(t, e) {
678
680
  const i = [], n = [];
679
681
  for (let o = -t; o <= t; o++) {
680
- const r = (e + o + this.elements.length) % this.elements.length, a = this.elements[r], l = a instanceof HTMLImageElement ? a : a instanceof HTMLAnchorElement && a.querySelector("img") || void 0, c = a instanceof HTMLElement ? {
682
+ const r = (e + o + this.elements.length) % this.elements.length, a = this.elements[r], h = a instanceof HTMLImageElement ? a : a instanceof HTMLAnchorElement && a.querySelector("img") || void 0, c = a instanceof HTMLElement ? {
681
683
  index: r,
682
- imageElm: l instanceof HTMLImageElement ? l : void 0,
684
+ imageElm: h instanceof HTMLImageElement ? h : void 0,
683
685
  anchorElm: a instanceof HTMLAnchorElement ? a : void 0,
684
686
  src: a.dataset.vistaviewSrc || a.getAttribute("href") || a.getAttribute("src") || "",
685
- thumb: a.dataset.vistaviewThumb || (l instanceof HTMLImageElement ? l.getAttribute("src") : void 0) || a.getAttribute("href") || void 0,
686
- alt: l instanceof HTMLImageElement && l.getAttribute("alt") || void 0
687
+ thumb: a.dataset.vistaviewThumb || (h instanceof HTMLImageElement ? h.getAttribute("src") : void 0) || a.getAttribute("href") || void 0,
688
+ alt: h instanceof HTMLImageElement && h.getAttribute("alt") || void 0
687
689
  } : {
688
690
  index: r,
689
691
  ...a
@@ -716,31 +718,46 @@ class st {
716
718
  displayActiveIndex() {
717
719
  var r;
718
720
  const t = this.currentIndex;
719
- this.elements instanceof NodeList && this.elements.forEach((a, l) => {
720
- a.style.opacity = "", l === t && (a.style.opacity = "0");
721
+ this.elements instanceof NodeList && this.elements.forEach((a, h) => {
722
+ a.style.opacity = "", h === t && (a.style.opacity = "0");
721
723
  });
722
724
  const e = this.qs(".vvw-index"), i = `${t + 1}`, n = `${this.elements.length}`;
723
725
  e && (e.textContent = `${i} / ${n}`);
724
726
  const o = this.qs(".vvw-desc");
725
727
  if (o) {
726
- const a = (r = this.currentChildren) == null ? void 0 : r.images.find((c) => c.index === t), l = (a == null ? void 0 : a.alt) || "";
727
- l ? (o.textContent = l, o.setAttribute("aria-label", `Image ${i} of ${n}: ${l}`)) : (o.textContent = "", o.setAttribute("aria-label", `Image ${i} of ${n}`));
728
+ const a = (r = this.currentChildren) == null ? void 0 : r.images.find((c) => c.index === t), h = (a == null ? void 0 : a.alt) || "";
729
+ h ? (o.textContent = h, o.setAttribute("aria-label", `Image ${i} of ${n}: ${h}`)) : (o.textContent = "", o.setAttribute("aria-label", `Image ${i} of ${n}`));
728
730
  }
729
731
  }
730
732
  transitionImage(t, e) {
733
+ if (t.classList.contains("vvw--load-cancelled")) return;
734
+ if (this.isRapidSwap) {
735
+ requestAnimationFrame(() => {
736
+ this.transitionImage(t, e);
737
+ });
738
+ return;
739
+ }
731
740
  const i = this.imageTransitions.get(t);
732
741
  i && requestAnimationFrame(() => {
742
+ if (t.classList.contains("vvw--load-cancelled")) return;
733
743
  const { current: n, target: o } = i, r = {
734
744
  width: n.width + (o.width - n.width) * 0.2,
735
745
  height: n.height + (o.height - n.height) * 0.2,
736
746
  radius: n.radius + (o.radius - n.radius) * 0.2
737
747
  };
738
- Math.abs(r.width - o.width) < 1 && Math.abs(r.height - o.height) < 1 && Math.abs(r.radius - o.radius) < 1 ? (t.style.setProperty("--vvw-current-w", `${o.width}px`), t.style.setProperty("--vvw-current-h", `${o.height}px`), t.style.setProperty("--vvw-current-radius", `${o.radius}px`), this.imageTransitions.delete(t), e()) : (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.set(t, { current: r, target: o }), this.transitionImage(t, e));
748
+ Math.abs(r.width - o.width) < 1 && Math.abs(r.height - o.height) < 1 && Math.abs(r.radius - o.radius) < 1 ? (t.style.setProperty("--vvw-current-w", `${o.width}px`), t.style.setProperty("--vvw-current-h", `${o.height}px`), t.style.setProperty("--vvw-current-radius", `${o.radius}px`), this.imageTransitions.delete(t), e()) : (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.set(t, { current: r, target: o }), this.transitionImage(
749
+ t,
750
+ e
751
+ /* false */
752
+ ));
739
753
  });
740
754
  }
741
755
  waitForImagesToLoad() {
742
756
  this.imageContainer.querySelectorAll("img.vvw-img-hi:not(.vvw--loaded)").forEach((i) => {
743
- const n = i, o = () => {
757
+ const n = i;
758
+ if (n.classList.contains("vvw--load-cancelled")) return;
759
+ const o = () => {
760
+ if (n.classList.contains("vvw--load-cancelled")) return;
744
761
  n.width = n.naturalWidth, n.height = n.naturalHeight;
745
762
  const { width: r, height: a } = M(n);
746
763
  n.dataset.vvwWidth = r.toString(), n.dataset.vvwHeight = a.toString(), n.classList.add("vvw--loaded"), this.imageTransitions.set(n, {
@@ -752,6 +769,7 @@ class st {
752
769
  target: { width: r, height: a, radius: 0 }
753
770
  }), this.transitionImage(n, () => {
754
771
  var c;
772
+ if (n.classList.contains("vvw--load-cancelled")) return;
755
773
  ((c = n.parentElement) == null ? void 0 : c.matches(
756
774
  `[data-vvw-idx="${this.currentIndex}"][data-vvw-pos="0"]`
757
775
  )) && (this.imageState.setCurrentImage(n), this.imageState.setInitialCenter()), n.classList.add("vvw--ready");
@@ -779,10 +797,10 @@ class st {
779
797
  }
780
798
  /// OPEN
781
799
  open(t = 0) {
782
- var c, m, p, x, b;
783
- if (y.somethingOpened)
800
+ var c, m, p, x, g;
801
+ if (C.somethingOpened)
784
802
  return;
785
- y.somethingOpened = this, this.currentIndex = t, document.body.style.overflow = "hidden";
803
+ C.somethingOpened = this, this.currentIndex = t, document.body.style.overflow = "hidden";
786
804
  const e = K({
787
805
  controls: this.options.controls
788
806
  });
@@ -798,11 +816,11 @@ class st {
798
816
  };
799
817
  this.setupFunction(a), this.currentChildren = { htmls: r, images: o }, r.forEach((d) => {
800
818
  this.imageContainer.appendChild(d);
801
- }), (c = this.qs(".vvw-close")) == null || c.addEventListener("click", () => this.close()), (m = this.qs(".vvw-zoom-in")) == null || m.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()), (b = this.qs(".vvw-next>button")) == null || b.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({
819
+ }), (c = this.qs(".vvw-close")) == null || c.addEventListener("click", () => this.close()), (m = this.qs(".vvw-zoom-in")) == null || m.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({
802
820
  elm: this.imageContainer,
803
821
  listeners: [this.getInternalPointerListener()]
804
822
  });
805
- const l = {};
823
+ const h = {};
806
824
  [
807
825
  ...this.options.controls.topLeft || [],
808
826
  ...this.options.controls.topRight || [],
@@ -811,11 +829,11 @@ class st {
811
829
  ...this.options.controls.bottomLeft || [],
812
830
  ...this.options.controls.bottomRight || []
813
831
  ].forEach((d) => {
814
- typeof d != "string" && (l[d.name] = d);
832
+ typeof d != "string" && (h[d.name] = d);
815
833
  }), this.root.querySelectorAll("button[data-vvw-control]").forEach((d) => {
816
834
  const u = d;
817
- u.addEventListener("click", (f) => {
818
- const g = f.currentTarget.dataset.vvwControl, v = l[g], E = this.currentChildren.images.find(
835
+ u.addEventListener("click", (b) => {
836
+ const f = b.currentTarget.dataset.vvwControl, v = h[f], E = this.currentChildren.images.find(
819
837
  (I) => I.index === this.currentIndex
820
838
  );
821
839
  v && E && (v.onClick.constructor.name === "AsyncFunction" ? (u.classList.add("vvw--loading"), v.onClick(E, this).finally(() => {
@@ -836,7 +854,7 @@ class st {
836
854
  }
837
855
  /// CLOSE
838
856
  async close(t = !0) {
839
- y.somethingOpened === this && this.root && (t ? await new Promise((e) => {
857
+ C.somethingOpened === this && this.root && (t ? await new Promise((e) => {
840
858
  let n = 0;
841
859
  this.root.addEventListener("transitionend", (o) => {
842
860
  o.target === this.root && (n++, n === 2 && this.elements instanceof NodeList && this.elements.forEach((r) => {
@@ -845,16 +863,16 @@ class st {
845
863
  }), this.root.classList.add("vvw--closing");
846
864
  }) : this.elements instanceof NodeList && this.elements.forEach((e) => {
847
865
  e.style.opacity = "";
848
- }), 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 = "", y.somethingOpened = null, this.closeFunction(this), this.options.onClose && this.options.onClose(this));
866
+ }), 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));
849
867
  }
850
868
  next() {
851
- if (y.somethingOpened !== this)
869
+ if (C.somethingOpened !== this)
852
870
  return;
853
871
  const t = (this.currentIndex + 1) % this.elements.length;
854
872
  this.view(t, { next: !0, prev: !1 });
855
873
  }
856
874
  prev() {
857
- if (y.somethingOpened !== this)
875
+ if (C.somethingOpened !== this)
858
876
  return;
859
877
  const t = (this.currentIndex - 1 + this.elements.length) % this.elements.length;
860
878
  this.view(t, { next: !1, prev: !0 });
@@ -865,10 +883,10 @@ class st {
865
883
  });
866
884
  }
867
885
  getCurrentIndex() {
868
- return y.somethingOpened !== this ? -1 : this.currentIndex;
886
+ return C.somethingOpened !== this ? -1 : this.currentIndex;
869
887
  }
870
888
  view(t, e) {
871
- if (y.somethingOpened !== this || t < 0 || t >= this.elements.length)
889
+ if (C.somethingOpened !== this || t < 0 || t >= this.elements.length)
872
890
  return;
873
891
  const i = this.currentIndex;
874
892
  this.currentIndex = t;
@@ -912,6 +930,10 @@ function at({ elements: s, ...t }) {
912
930
  }
913
931
  export {
914
932
  H as DefaultOptions,
933
+ Q as close,
934
+ G as init,
935
+ _ as setup,
936
+ tt as transition,
915
937
  at as vistaView,
916
938
  j as vistaViewDownload
917
939
  };
@@ -1,11 +1,11 @@
1
- (function(v,w){typeof exports=="object"&&typeof module<"u"?w(exports):typeof define=="function"&&define.amd?define(["exports"],w):(v=typeof globalThis<"u"?globalThis:v||self,w(v.VistaView={}))})(this,(function(v){"use strict";var rt=Object.defineProperty;var at=(v,w,$)=>w in v?rt(v,w,{enumerable:!0,configurable:!0,writable:!0,value:$}):v[w]=$;var h=(v,w,$)=>at(v,typeof w!="symbol"?w+"":w,$);function w(s){return s&&!/^0(px|%|r?em|vw|vh|vmin|vmax|cm|mm|in|pt|pc|ex|ch)?$/i.test(s.trim())&&s}function $(s){const e=window.getComputedStyle(s).objectFit||"",{width:i,height:n}=s.getBoundingClientRect(),o=s.naturalWidth,r=s.naturalHeight;if(!e)return{width:i,height:n};if(!o||!r)return{width:i,height:n};const a=o/r,l=i/n;switch(e){case"fill":return{width:i,height:n};case"none":return{width:o,height:r};case"contain":return a>l?{width:i,height:i/a}:{width:n*a,height:n};case"cover":return a<l?{width:i,height:i/a}:{width:n*a,height:n};case"scale-down":{const c={width:o,height:r},m=a>l?{width:i,height:i/a}:{width:n*a,height:n};return m.width<=c.width&&m.height<=c.height?m:c}}return{width:i,height:n}}function W(s){const t=getComputedStyle(s),e=s.getBoundingClientRect();return{objectFit:t.objectFit,borderRadius:t.borderRadius,objectPosition:t.objectPosition,overflow:t.overflow,top:e.top,left:e.left,width:e.width,height:e.height,naturalWidth:s.naturalWidth,naturalHeight:s.naturalHeight}}function k(s){const t=s.imageElm?W(s.imageElm):null,e=s.anchorElm?W(s.anchorElm):null,i=w(t==null?void 0:t.borderRadius),n=e&&w(e==null?void 0:e.borderRadius),o=(n?e==null?void 0:e.borderRadius:i?t==null?void 0:t.borderRadius:"")||"";return{fit:(t==null?void 0:t.objectFit)||(e==null?void 0:e.objectFit)||"",pos:(t==null?void 0:t.objectPosition)||"",br:o,overflow:n?e.overflow:i?t.overflow:"",nw:(t==null?void 0:t.naturalWidth)||0,nh:(t==null?void 0:t.naturalHeight)||0,w:(e==null?void 0:e.width)||(t==null?void 0:t.width)||0,h:(e==null?void 0:e.height)||(t==null?void 0:t.height)||0,top:(e==null?void 0:e.top)||(t==null?void 0:t.top)||0,left:(e==null?void 0:e.left)||(t==null?void 0:t.left)||0}}function P(s,t,e,i=!1){const{fit:n,w:o,h:r,nw:a,nh:l,br:c,top:m,left:f}=k(s),L=Math.min(Math.max(f,-o),window.innerWidth+o)-window.innerWidth/2+o/2,E=Math.min(Math.max(m,-r),window.innerHeight+r)-window.innerHeight/2+r/2,d=e.style;d.width=`${o}px`,d.height=`${r}px`,d.objectFit=n,e.width=a,e.height=l,d.setProperty("--vvw-init-radius",`${c}`),d.setProperty("--vvw-pulse-radius",`calc(1.3 * ${c})`),d.setProperty("--vvw-init-x",`${L}px`),d.setProperty("--vvw-init-y",`${E}px`),i&&(d.setProperty("--vvw-current-x",`${L}px`),d.setProperty("--vvw-current-y",`${E}px`));const u=$(s.imageElm),b=Math.min(o,u.width),y=Math.min(r,u.height),p=t.style;p.setProperty("--vvw-init-radius",`${c}`),p.setProperty("--vvw-init-w",`${b}px`),p.setProperty("--vvw-init-h",`${y}px`),i&&(p.setProperty("--vvw-current-radius",`${c}`),p.setProperty("--vvw-current-w",`${b}px`),p.setProperty("--vvw-current-h",`${y}px`),t.dataset.vvwWidth=b.toString(),t.dataset.vvwHeight=y.toString())}function F(s){const t=window.innerWidth,e=window.innerHeight,i=s.naturalWidth,n=s.naturalHeight;if(!i||!n)throw new Error("Image natural dimensions are zero");if(i<t&&n<e)return{width:i,height:n};const o=i/n,r=t/e;let a,l;return o>r?(a=t,l=t/o):(l=e,a=e*o),{width:a,height:l}}function q(s,t,e){return Math.min(Math.max(s,t),e)}function C(s,t=2){const e=Math.pow(10,t);return Math.round(s*e)/e}const 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>',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>',X='<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>',N='<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>';let D=null;function B(){return D||(window.trustedTypes||(window.trustedTypes={createPolicy:(s,t)=>t}),D=window.trustedTypes.createPolicy("vistaView-policy",{createHTML:s=>s,createScript:()=>{throw new Error("Not implemented")},createScriptURL:()=>{throw new Error("Not implemented")}}),D)}function A(s){const e=B().createHTML(s),i=document.createElement("template");i.innerHTML=e;const n=i.content;return i.remove(),n}function z(){return{name:"download",icon:Y,onClick:async s=>{var o;const t=await fetch(s.src),e=await t.blob(),i=t.url,n=document.createElement("a");n.href=URL.createObjectURL(e),n.download=((o=i.split("/").pop())==null?void 0:o.split("?")[0].split("#")[0])||"download",document.body.appendChild(n),n.click(),document.body.removeChild(n)}}}function j(s){if(typeof s=="string")switch(s){case"zoomIn":return`<button aria-label="Zoom In" class="vvw-zoom-in vvw-ui">${Z}</button>`;case"zoomOut":return`<button aria-label="Zoom Out" disabled class="vvw-zoom-out vvw-ui">${X}</button>`;case"close":return`<button aria-label="Close" class="vvw-close vvw-ui">${N}</button>`;case"indexDisplay":return'<div class="vvw-index vvw-ui" aria-hidden="true"></div>';case"description":return'<div class="vvw-desc vvw-ui" role="status" aria-live="polite" aria-atomic="true"></div>';default:return""}return`<button class="vvw-ui" aria-label="${s.description||s.name}" data-vvw-control="${s.name}">${s.icon}</button>`}function V(s,t){const e=document.createElement("div");e.className="vvw-item",e.dataset.vvwPos=`${t!==void 0?t:""}`,e.dataset.vvwIdx=s.index.toString(),e.appendChild(A(`<img class="vvw-img-lo" src="${s.thumb||s.src}" alt="${s.alt||""}" />
2
- <img class="vvw-img-hi" src="${s.src}" alt="${s.alt||""}" />`));const i=e.querySelector("img.vvw-img-lo"),n=e.querySelector("img.vvw-img-hi");return P(s,n,i,t===0),e}function U({controls:s}){const t=i=>i?i.map(j).join(""):"";return A(`<div class="vvw-root" id="vvw-root">
1
+ (function(v,w){typeof exports=="object"&&typeof module<"u"?w(exports):typeof define=="function"&&define.amd?define(["exports"],w):(v=typeof globalThis<"u"?globalThis:v||self,w(v.VistaView={}))})(this,(function(v){"use strict";var rt=Object.defineProperty;var at=(v,w,$)=>w in v?rt(v,w,{enumerable:!0,configurable:!0,writable:!0,value:$}):v[w]=$;var l=(v,w,$)=>at(v,typeof w!="symbol"?w+"":w,$);function w(s){return s&&!/^0(px|%|r?em|vw|vh|vmin|vmax|cm|mm|in|pt|pc|ex|ch)?$/i.test(s.trim())&&s}function $(s){const e=window.getComputedStyle(s).objectFit||"",{width:i,height:n}=s.getBoundingClientRect(),o=s.naturalWidth,r=s.naturalHeight;if(!e)return{width:i,height:n};if(!o||!r)return{width:i,height:n};const a=o/r,h=i/n;switch(e){case"fill":return{width:i,height:n};case"none":return{width:o,height:r};case"contain":return a>h?{width:i,height:i/a}:{width:n*a,height:n};case"cover":return a<h?{width:i,height:i/a}:{width:n*a,height:n};case"scale-down":{const c={width:o,height:r},m=a>h?{width:i,height:i/a}:{width:n*a,height:n};return m.width<=c.width&&m.height<=c.height?m:c}}return{width:i,height:n}}function W(s){const t=getComputedStyle(s),e=s.getBoundingClientRect();return{objectFit:t.objectFit,borderRadius:t.borderRadius,objectPosition:t.objectPosition,overflow:t.overflow,top:e.top,left:e.left,width:e.width,height:e.height,naturalWidth:s.naturalWidth,naturalHeight:s.naturalHeight}}function Z(s){const t=s.imageElm?W(s.imageElm):null,e=s.anchorElm?W(s.anchorElm):null,i=w(t==null?void 0:t.borderRadius),n=e&&w(e==null?void 0:e.borderRadius),o=(n?e==null?void 0:e.borderRadius:i?t==null?void 0:t.borderRadius:"")||"";return{fit:(t==null?void 0:t.objectFit)||(e==null?void 0:e.objectFit)||"",pos:(t==null?void 0:t.objectPosition)||"",br:o,overflow:n?e.overflow:i?t.overflow:"",nw:(t==null?void 0:t.naturalWidth)||0,nh:(t==null?void 0:t.naturalHeight)||0,w:(e==null?void 0:e.width)||(t==null?void 0:t.width)||0,h:(e==null?void 0:e.height)||(t==null?void 0:t.height)||0,top:(e==null?void 0:e.top)||(t==null?void 0:t.top)||0,left:(e==null?void 0:e.left)||(t==null?void 0:t.left)||0}}function P(s,t,e,i=!1){const{fit:n,w:o,h:r,nw:a,nh:h,br:c,top:m,left:f}=Z(s),L=Math.min(Math.max(f,-o),window.innerWidth+o)-window.innerWidth/2+o/2,y=Math.min(Math.max(m,-r),window.innerHeight+r)-window.innerHeight/2+r/2,d=e.style;d.width=`${o}px`,d.height=`${r}px`,d.objectFit=n,e.width=a,e.height=h,d.setProperty("--vvw-init-radius",`${c}`),d.setProperty("--vvw-pulse-radius",`calc(1.3 * ${c})`),d.setProperty("--vvw-init-x",`${L}px`),d.setProperty("--vvw-init-y",`${y}px`),i&&(d.setProperty("--vvw-current-x",`${L}px`),d.setProperty("--vvw-current-y",`${y}px`));const u=$(s.imageElm),E=Math.min(o,u.width),x=Math.min(r,u.height),p=t.style;p.setProperty("--vvw-init-radius",`${c}`),p.setProperty("--vvw-init-w",`${E}px`),p.setProperty("--vvw-init-h",`${x}px`),i&&(p.setProperty("--vvw-current-radius",`${c}`),p.setProperty("--vvw-current-w",`${E}px`),p.setProperty("--vvw-current-h",`${x}px`),t.dataset.vvwWidth=E.toString(),t.dataset.vvwHeight=x.toString())}function F(s){const t=window.innerWidth,e=window.innerHeight,i=s.naturalWidth,n=s.naturalHeight;if(!i||!n)throw new Error("Image natural dimensions are zero");if(i<t&&n<e)return{width:i,height:n};const o=i/n,r=t/e;let a,h;return o>r?(a=t,h=t/o):(h=e,a=e*o),{width:a,height:h}}function X(s,t,e){return Math.min(Math.max(s,t),e)}function I(s,t=2){const e=Math.pow(10,t);return Math.round(s*e)/e}const N='<svg viewBox="0 0 24 24"><path d="m15 18-6-6 6-6"/></svg>',Y='<svg viewBox="0 0 24 24"><path d="m9 18 6-6-6-6"/></svg>',B='<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>',j='<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>',V='<svg viewBox="0 0 24 24"><path d="M18 6 6 18"/><path d="m6 6 12 12"/></svg>',U='<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>';let D=null;function K(){return D||(window.trustedTypes||(window.trustedTypes={createPolicy:(s,t)=>t}),D=window.trustedTypes.createPolicy("vistaView-policy",{createHTML:s=>s,createScript:()=>{throw new Error("Not implemented")},createScriptURL:()=>{throw new Error("Not implemented")}}),D)}function R(s){const e=K().createHTML(s),i=document.createElement("template");i.innerHTML=e;const n=i.content;return i.remove(),n}function A(){return{name:"download",icon:U,onClick:async s=>{var o;const t=await fetch(s.src),e=await t.blob(),i=t.url,n=document.createElement("a");n.href=URL.createObjectURL(e),n.download=((o=i.split("/").pop())==null?void 0:o.split("?")[0].split("#")[0])||"download",document.body.appendChild(n),n.click(),document.body.removeChild(n)}}}function _(s){if(typeof s=="string")switch(s){case"zoomIn":return`<button aria-label="Zoom In" class="vvw-zoom-in vvw-ui">${B}</button>`;case"zoomOut":return`<button aria-label="Zoom Out" disabled class="vvw-zoom-out vvw-ui">${j}</button>`;case"close":return`<button aria-label="Close" class="vvw-close vvw-ui">${V}</button>`;case"indexDisplay":return'<div class="vvw-index vvw-ui" aria-hidden="true"></div>';case"description":return'<div class="vvw-desc vvw-ui" role="status" aria-live="polite" aria-atomic="true"></div>';default:return""}return`<button class="vvw-ui" aria-label="${s.description||s.name}" data-vvw-control="${s.name}">${s.icon}</button>`}function G(s,t){const e=document.createElement("div");e.className="vvw-item",e.dataset.vvwPos=`${t!==void 0?t:""}`,e.dataset.vvwIdx=s.index.toString(),e.appendChild(R(`<img class="vvw-img-lo" src="${s.thumb||s.src}" alt="${s.alt||""}" />
2
+ <img class="vvw-img-hi" src="${s.src}" alt="${s.alt||""}" />`));const i=e.querySelector("img.vvw-img-lo"),n=e.querySelector("img.vvw-img-hi");return P(s,n,i,t===0),e}function J({controls:s}){const t=i=>i?i.map(_).join(""):"";return R(`<div class="vvw-root" id="vvw-root">
3
3
  <div class="vvw-container">
4
4
  <div class="vvw-bg"></div>
5
5
  <div class="vvw-image-container"></div>
6
6
  <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>
7
7
  <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>
8
- <div class="vvw-prev vvw-ui"><button aria-label="Previous">${R}</button></div>
9
- <div class="vvw-next vvw-ui"><button aria-label="Next">${O}</button></div>
8
+ <div class="vvw-prev vvw-ui"><button aria-label="Previous">${N}</button></div>
9
+ <div class="vvw-next vvw-ui"><button aria-label="Next">${Y}</button></div>
10
10
  </div>
11
- </div>`)}const M={animationDurationBase:333,maxZoomLevel:2,preloads:1,keyboardListeners:!0,arrowOnSmallScreens:!1,rapidLimit:222,controls:{topLeft:["indexDisplay"],topRight:["zoomIn","zoomOut",z(),"close"],bottomLeft:["description"]}};function K(s){}function _(s){const t=s.options.preloads;s.imageContainer.style.width=`${(t*2+1)*100}vw`,s.imageContainer.style.left=`-${t*100}vw`,s.imageContainer.style.display="flex",G(s)}function G(s){let t={x:0,y:0},e={x:0,y:0},i=null;s.registerPointerListener(n=>{var o;if(!n.hasInternalExecution&&!(n.pointers.length>1)){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"){e={x:n.pointer.x,y:n.pointer.y};const r=e.x-t.x,a=e.y-t.y;if(!i&&Math.abs(a)>Math.abs(r)||i==="y"){const l=a/window.innerHeight*100;s.imageContainer.style.transition="none",s.imageContainer.style.transform=`translateY(${l}vh)`,i="y"}else if(!i&&Math.abs(r)>Math.abs(a)||i==="x"){const l=r/window.innerWidth*100;s.imageContainer.style.transition="none",s.imageContainer.style.transform=`translateX(${l}vw)`,i="x"}}if(n.event==="up"||n.event==="cancel"){let r=function(a){var l;(l=s.imageContainer)==null||l.addEventListener("transitionend",function c(){var m;(m=s.imageContainer)==null||m.removeEventListener("transitionend",c),s.imageContainer.style.transition="",s.imageContainer.style.transform=""}),s.imageContainer.style.transition="transform 222ms ease",s.imageContainer.style.transform=a};if(i==="y"){const a=e.y-t.y;Math.abs(a)>144?(s.imageContainer.style.transition="transform 222ms ease",s.imageContainer.style.transform="translateY(0vh)",s.close()):r("translateY(0vh)")}if(i==="x"){const a=e.x-t.x,l=n.pointer.movementX,c=1;s.imageContainer.style.transition="",a>0&&Math.abs(l)>c?s.prev():a<0&&Math.abs(l)>c?s.next():r("translateX(0vw)")}i=null,t={x:0,y:0},e={x:0,y:0}}}})}function J(s){}function Q({vistaView:{isReducedMotion:s},htmlElements:{to:t},index:{from:e,to:i},vistaView:{elements:n,imageContainer:o,options:r}},a){if(!(!t||a.aborted||s||!(Math.abs(i-e)===1||e===0&&i===n.length-1||e===n.length-1&&i===0)))return{cleanup:()=>{o.style.transition="",o.style.transform=""},transitionEnded:new Promise(c=>{o.addEventListener("transitionend",()=>{c()},{once:!0}),o.addEventListener("transitioncancel",()=>{a.aborted&&c()},{once:!0});const m=Math.round(r.animationDurationBase*100)/100,f=i===e+1||e===n.length-1&&i===0?"translateX(-100vw)":"translateX(100vw)";o.style.transition=`transform ${m}ms ease`,o.style.transform=f})}}class tt{constructor({elm:t,listeners:e}){h(this,"pointers",[]);h(this,"elm");h(this,"listeners",[]);h(this,"lastPointerDownId",null);h(this,"removeLastPointer",()=>{if(this.pointers.length&&this.lastPointerDownId!==null){const t=this.pointers.findIndex(e=>e.id===this.lastPointerDownId);t!==-1&&this.pointers.splice(t,1)}});h(this,"onPointerDown",t=>{if(!this.listeners.length||t.button!==0)return;t.preventDefault(),this.lastPointerDownId=t.pointerId,window.addEventListener("contextmenu",this.removeLastPointer,{once:!0}),window.addEventListener("auxclick",this.removeLastPointer,{once:!0});let e={x:t.clientX,y:t.clientY,movementX:0,movementY:0,id:t.pointerId};this.pointers.push(e),this.listeners.forEach(i=>i({event:"down",pointer:e,pointers:this.pointers,lastPointerLen:this.pointers.length-1}))});h(this,"onPointerMove",t=>{if(!this.listeners.length)return;t.preventDefault();const e=this.pointers.find(i=>i.id===t.pointerId);e&&(e.movementX=t.movementX,e.movementY=t.movementY,e.x=t.clientX,e.y=t.clientY,this.listeners.forEach(i=>i({event:"move",pointer:e,pointers:this.pointers,lastPointerLen:this.pointers.length-1})))});h(this,"onPointerUp",t=>{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))return;t.preventDefault();const e=this.pointers.findIndex(o=>o.id===t.pointerId);if(e===-1)return;const i=this.pointers[e];i.x=t.clientX,i.y=t.clientY;const n=this.pointers.length;this.pointers.splice(e,1),this.listeners.forEach(o=>o({event:"up",pointer:i,pointers:this.pointers,lastPointerLen:n}))});h(this,"onPointerCancel",t=>{if(!this.listeners.length||t.target instanceof Node&&!this.elm.contains(t.target)&&t.target!==document.querySelector("html")&&t.target!==document)return;t.preventDefault();const e=this.pointers.findIndex(o=>o.id===t.pointerId);if(e===-1)return;const i=this.pointers[e];i.x=t.clientX,i.y=t.clientY;const n=this.pointers.length;this.pointers.splice(e,1),this.listeners.forEach(o=>o({event:"cancel",pointer:i,pointers:this.pointers,lastPointerLen:n}))});this.elm=t??document,e&&(this.listeners=e),this.startListeners()}startListeners(){this.elm.addEventListener("pointerdown",this.onPointerDown),this.elm.addEventListener("pointermove",this.onPointerMove),document.addEventListener("pointerup",this.onPointerUp),document.addEventListener("pointercancel",this.onPointerCancel)}removeListeners(){this.elm.removeEventListener("pointerdown",this.onPointerDown),this.elm.removeEventListener("pointermove",this.onPointerMove),document.removeEventListener("pointerup",this.onPointerUp),document.removeEventListener("pointercancel",this.onPointerCancel),this.pointers=[]}addEventListener(t){this.listeners.push(t)}removeEventListener(t){this.listeners=this.listeners.filter(e=>e!==t)}getPointerDistance(t,e){const i=t.x-e.x,n=t.y-e.y;return Math.sqrt(i*i+n*n)}getCentroid(){if(this.pointers.length===0)return null;const t=this.pointers.reduce((e,i)=>(e.x+=i.x,e.y+=i.y,e),{x:0,y:0});return{x:t.x/this.pointers.length,y:t.y/this.pointers.length}}}class et{constructor(t,e){h(this,"maxZoomLevel");h(this,"image",null);h(this,"rect",null);h(this,"initialCenter",{x:0,y:0});h(this,"maxDimension",{width:0});h(this,"minDimension",{initialWidth:0,initialHeight:0,minWidth:0,closingWidth:0});h(this,"accumulatedTranslate",{x:0,y:0});h(this,"scale",1);h(this,"translate",{x:0,y:0});h(this,"onScale",null);h(this,"animationTimestamp",0);this.maxZoomLevel=t,this.onScale=e}clean(){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="")}reset(){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}}setCurrentImage(t){if(this.rect=null,this.image=t,this.maxDimension={width:t.naturalWidth*this.maxZoomLevel},!t.dataset.vvwWidth||!t.dataset.vvwHeight)throw new Error("VistaImageState: Image dataset vvwWidth or vvwHeight not set.");const e=parseFloat(t.dataset.vvwWidth),i=parseFloat(t.dataset.vvwHeight);this.minDimension={initialWidth:e,initialHeight:i,minWidth:e*.1,closingWidth:e*.5},this.accumulatedTranslate={x:0,y:0}}setInitialCenter(t){this.initialCenter=t||{x:window.innerWidth/2,y:window.innerHeight/2}}move(t){this.image&&(this.rect||(this.rect=this.image.getBoundingClientRect()),this.translate.x=C(t.x-this.initialCenter.x),this.translate.y=C(t.y-this.initialCenter.y),this.image.style.transform=`translate3d(${this.translate.x}px, ${this.translate.y}px, 0px) scale(${this.scale})`)}snapToTargetIfClose(t,e,i=1){return Math.abs(t-e)<=i&&(t=e),t}scaleMove(t,e){if(!this.image)return;this.rect||(this.rect=this.image.getBoundingClientRect()),e||(e=this.initialCenter);const i=this.snapToTargetIfClose(q(this.rect.width*t,this.minDimension.minWidth,this.maxDimension.width),this.minDimension.initialWidth);this.onScale&&this.onScale({scale:i/(this.maxDimension.width/this.maxZoomLevel),isMax:i>=this.maxDimension.width,isMin:i<=this.minDimension.initialWidth}),this.scale=C(i/this.rect.width);const n=this.rect.left+this.rect.width/2,o=this.rect.top+this.rect.height/2,r=this.initialCenter.x-n,a=this.initialCenter.y-o,l=r*(1-this.scale),c=a*(1-this.scale),m=e.x-this.initialCenter.x,f=e.y-this.initialCenter.y;this.translate.x=C(l+m),this.translate.y=C(c+f),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=""}moveAndNormalize(t){let e=0,i=!1;const n=({x:o,y:r})=>{if(i)return;if(Math.abs(o)<.001&&Math.abs(r)<.001)return this.normalize();o*=.9,r*=.9;const a=this.image.getBoundingClientRect();this.translate.x=C(this.translate.x+o),this.translate.y=C(this.translate.y+r),a.right<window.innerWidth/2&&(this.translate.x+=(window.innerWidth/2-a.right)*.1,o*=.7),a.left>window.innerWidth/2&&(this.translate.x-=(a.left-window.innerWidth/2)*.1,o*=.7),a.bottom<window.innerHeight/2&&(this.translate.y+=(window.innerHeight/2-a.bottom)*.1,r*=.7),a.top>window.innerHeight/2&&(this.translate.y-=(a.top-window.innerHeight/2)*.1,r*=.7),this.image.style.transform=`translate3d(${this.translate.x}px, ${this.translate.y}px, 0px) scale(${this.scale})`,e=requestAnimationFrame(()=>n({x:o,y:r}))};return n({x:t.movementX,y:t.movementY}),()=>{i=!0,cancelAnimationFrame(e),this.normalize(!1)}}animateZoom(t){if(!this.image)return;this.rect||(this.rect=this.image.getBoundingClientRect());const e=Date.now(),i=this.image;this.rect.width*t<this.minDimension.closingWidth||i.width<Math.floor(this.minDimension.initialWidth)||(i.addEventListener("transitionend",()=>{this.animationTimestamp===e&&i&&(i.style.transition="",this.normalize())},{once:!0}),i.style.transition||(i.style.transition="all 222ms ease"),this.animationTimestamp=e,this.scaleMove(t))}normalize(t=!0){if(!this.image||!this.rect)return;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),o=i?this.rect.height*this.scale:this.snapToTargetIfClose(this.rect.height*this.scale,this.minDimension.initialHeight);if(this.image.style.width=`${n}px`,this.image.style.height=`${o}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)return!0;if(n<this.minDimension.initialWidth)this.accumulatedTranslate.x=0,this.accumulatedTranslate.y=0,requestAnimationFrame(()=>{const r=this.image;r&&(r.addEventListener("transitionend",()=>{r&&(this.clean(),this.rect=null)},{once:!0}),r.style.transition="all 222ms ease",r.style.width=`${this.minDimension.initialWidth}px`,r.style.height=`${this.minDimension.initialHeight}px`,r.style.left="50%",r.style.top="50%")});else if(t){let r=!1;if(this.rect.right<window.innerWidth/2&&(r=!0,this.accumulatedTranslate.x+=window.innerWidth/2-this.rect.right),this.rect.left>window.innerWidth/2&&(r=!0,this.accumulatedTranslate.x-=this.rect.left-window.innerWidth/2),this.rect.bottom<window.innerHeight/2&&(r=!0,this.accumulatedTranslate.y+=window.innerHeight/2-this.rect.bottom),this.rect.top>window.innerHeight/2&&(r=!0,this.accumulatedTranslate.y-=this.rect.top-window.innerHeight/2),r){const a=this.image;a.addEventListener("transitionend",()=>{a&&(a.style.transition="",this.rect=null)},{once:!0}),a.style.transition="all 222ms ease",a.style.left=`calc(50% + ${this.accumulatedTranslate.x}px)`,a.style.top=`calc(50% + ${this.accumulatedTranslate.y}px)`}else this.rect=null}}}class it{constructor(){h(this,"fiolast",{})}fio(t,e,i=50){const o=Date.now()-(this.fiolast[e]??0),r=()=>{this.fiolast[e]=Date.now(),t()};if(!this.fiolast[e]){r();return}o>=i&&r()}}const x={somethingOpened:null};class nt{constructor(t,e={}){h(this,"options");h(this,"elements");h(this,"isReducedMotion");h(this,"currentIndex",-1);h(this,"currentChildren",null);h(this,"setupFunction",K);h(this,"initFunction",_);h(this,"closeFunction",J);h(this,"transitionFunction",Q);h(this,"pointers",null);h(this,"imageState");h(this,"imageTransitions",new Map);h(this,"root",null);h(this,"imageContainer",null);h(this,"onClickElements",t=>{t.preventDefault();const e=t.currentTarget;e.dataset.vistaIdx&&this.open(parseInt(e.dataset.vistaIdx))});h(this,"defaultOnClickHandler",t=>t.preventDefault());h(this,"abortController",null);h(this,"throttle",new it);h(this,"lastSwapTime",0);h(this,"transitionCleanup",null);h(this,"isZoomedIn",!1);h(this,"onKeyDown",t=>{switch(t.key){case"ArrowLeft":t.preventDefault(),this.prev();break;case"ArrowRight":t.preventDefault(),this.next();break;case"ArrowUp":t.preventDefault(),this.zoomIn();break;case"ArrowDown":t.preventDefault(),this.zoomOut();break;case"Escape":t.preventDefault(),this.close();break}});h(this,"onScroll",t=>{t.preventDefault();const e=t.deltaY;this.imageState.setInitialCenter({x:t.clientX,y:t.clientY}),e<0?this.zoomIn():e>0&&this.zoomOut()});h(this,"onResizeHandler",()=>{this.currentChildren.htmls.forEach((t,e)=>{const i=this.currentChildren.images[e],n=t.querySelector("img.vvw-img-hi"),o=t.querySelector("img.vvw-img-lo");if(P(i,n,o,!1),n.classList.contains("vvw--loaded")){const{width:r,height:a}=F(n);n.style.setProperty("--vvw-current-w",`${r}px`),n.style.setProperty("--vvw-current-h",`${a}px`),n.dataset.vvwWidth=r.toString(),n.dataset.vvwHeight=a.toString()}})});h(this,"pointerListeners",[]);h(this,"getInternalPointerListener",()=>{const t=this.imageState;let e=0,i=!1,n=()=>{};return o=>{if(o.event==="down"){if(n(),this.isZoomedIn&&o.pointers.length===1){const r=this.pointers.getCentroid();t.setInitialCenter(r)}if(o.pointers.length>=2){i=!0;const r=this.pointers.getCentroid();e=this.pointers.getPointerDistance(o.pointers[0],o.pointers[1]),t.setInitialCenter(r)}}else if(o.event==="move"){if(this.isZoomedIn&&o.pointers.length===1&&o.lastPointerLen===0){const r=this.pointers.getCentroid();t.move(r)}if(o.pointers.length>=2&&i){const r=this.pointers.getCentroid(),a=this.pointers.getPointerDistance(o.pointers[0],o.pointers[1]);t.scaleMove(a/e,r)}}else(o.event==="up"||o.event==="cancel")&&(i||this.isZoomedIn)&&(i?(i=!1,t.normalize()&&requestAnimationFrame(()=>{this.close()})):this.isZoomedIn&&o.pointers.length===0&&(n=t.moveAndNormalize(o.pointer)));this.pointerListeners.forEach(r=>r({...o,hasInternalExecution:this.isZoomedIn||i,abortController:this.abortController}))}});this.elements=t,this.options={...M,...e,controls:{...M.controls,...e.controls}},this.imageState=new et(this.options.maxZoomLevel,i=>{var n,o,r,a,l,c;i.isMin?(this.isZoomedIn=!1,(n=this.qs(".vvw-zoom-out"))==null||n.setAttribute("disabled","true"),(o=this.qs('.vvw-item[data-vvw-idx="'+this.currentIndex+'"]'))==null||o.style.setProperty("pointer-events","none")):(this.isZoomedIn=!0,(r=this.qs(".vvw-zoom-out"))==null||r.removeAttribute("disabled"),(a=this.qs('.vvw-item[data-vvw-idx="'+this.currentIndex+'"]'))==null||a.style.setProperty("pointer-events","auto")),i.isMax?(l=this.qs(".vvw-zoom-in"))==null||l.setAttribute("disabled","true"):(c=this.qs(".vvw-zoom-in"))==null||c.removeAttribute("disabled")}),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)=>{i.dataset.vistaIdx=n.toString(),i.addEventListener("click",this.defaultOnClickHandler),i.addEventListener("pointerup",this.onClickElements)})}qs(t){return this.root?this.root.querySelector(t):null}async swap(t,e){const i=this.options.preloads||0,n=this.currentIndex,{htmls:o,images:r}=this.getChildElements(i,n),a=this.imageContainer,l=this.currentChildren,c={htmlElements:{from:l.htmls,to:o},images:{from:l.images,to:r},index:{from:t,to:this.currentIndex},via:e||{next:!1,prev:!1},vistaView:this};this.setupFunction(c),this.currentChildren={htmls:o,images:r},this.displayActiveIndex();const m=this.abortController.signal,L=performance.now()-this.lastSwapTime<this.options.rapidLimit,E=o[Math.floor(o.length/2)].dataset.vvwIdx;if(L){this.imageState.reset(),a.innerHTML="",this.transitionCleanup&&this.transitionCleanup(),o.forEach(I=>{a.appendChild(I)}),this.lastSwapTime=performance.now(),this.waitForImagesToLoad(),this.options.onImageView&&this.options.onImageView(c);return}const d=this.transitionFunction(c,m);d&&(this.transitionCleanup=d.cleanup,await d.transitionEnded),this.lastSwapTime=performance.now();const u=a.querySelector(`.vvw-item[data-vvw-idx="${E}"] img.vvw-img-hi`),b=this.imageTransitions.get(u);this.imageTransitions.delete(u);const y=u.getAttribute("style")||"",p=u.classList.contains("vvw--loaded"),T=u.classList.contains("vvw--ready"),S=u.width,H=u.height;this.imageState.reset(),a.innerHTML="",this.transitionCleanup&&this.transitionCleanup(),o.forEach(I=>{const g=I.querySelector("img.vvw-img-hi");I.dataset.vvwPos==="0"&&!m.aborted&&y&&S&&H&&(p&&(g.classList.add("vvw--loaded"),g.dataset.vvwWidth=u.dataset.vvwWidth||"",g.dataset.vvwHeight=u.dataset.vvwHeight||""),T&&(g.classList.add("vvw--ready"),g.width=S,g.height=H),g.setAttribute("style",y)),a.appendChild(I),I.dataset.vvwPos==="0"&&!m.aborted&&T?(this.imageState.setCurrentImage(g),this.imageState.setInitialCenter()):I.dataset.vvwPos==="0"&&!m.aborted&&y&&S&&H&&p&&b&&(this.imageTransitions.set(g,b),this.transitionImage(g,()=>{this.imageState.setCurrentImage(g),this.imageState.setInitialCenter(),g.classList.add("vvw--ready")}))}),this.waitForImagesToLoad(),this.options.onImageView&&this.options.onImageView(c)}getChildElements(t,e){const i=[],n=[];for(let o=-t;o<=t;o++){const r=(e+o+this.elements.length)%this.elements.length,a=this.elements[r],l=a instanceof HTMLImageElement?a:a instanceof HTMLAnchorElement&&a.querySelector("img")||void 0,c=a instanceof HTMLElement?{index:r,imageElm:l instanceof HTMLImageElement?l:void 0,anchorElm:a instanceof HTMLAnchorElement?a:void 0,src:a.dataset.vistaviewSrc||a.getAttribute("href")||a.getAttribute("src")||"",thumb:a.dataset.vistaviewThumb||(l instanceof HTMLImageElement?l.getAttribute("src"):void 0)||a.getAttribute("href")||void 0,alt:l instanceof HTMLImageElement&&l.getAttribute("alt")||void 0}:{index:r,...a};n.push(c),i.push(V(c,o))}return{htmls:i,images:n}}zoomIn(){this.throttle.fio(()=>{this.imageState.animateZoom(1.68)},"zoom",222)}zoomOut(){this.throttle.fio(()=>{this.imageState.animateZoom(.68)},"zoom",222)}displayActiveIndex(){var r;const t=this.currentIndex;this.elements instanceof NodeList&&this.elements.forEach((a,l)=>{a.style.opacity="",l===t&&(a.style.opacity="0")});const e=this.qs(".vvw-index"),i=`${t+1}`,n=`${this.elements.length}`;e&&(e.textContent=`${i} / ${n}`);const o=this.qs(".vvw-desc");if(o){const a=(r=this.currentChildren)==null?void 0:r.images.find(c=>c.index===t),l=(a==null?void 0:a.alt)||"";l?(o.textContent=l,o.setAttribute("aria-label",`Image ${i} of ${n}: ${l}`)):(o.textContent="",o.setAttribute("aria-label",`Image ${i} of ${n}`))}}transitionImage(t,e){const i=this.imageTransitions.get(t);i&&requestAnimationFrame(()=>{const{current:n,target:o}=i,r={width:n.width+(o.width-n.width)*.2,height:n.height+(o.height-n.height)*.2,radius:n.radius+(o.radius-n.radius)*.2};Math.abs(r.width-o.width)<1&&Math.abs(r.height-o.height)<1&&Math.abs(r.radius-o.radius)<1?(t.style.setProperty("--vvw-current-w",`${o.width}px`),t.style.setProperty("--vvw-current-h",`${o.height}px`),t.style.setProperty("--vvw-current-radius",`${o.radius}px`),this.imageTransitions.delete(t),e()):(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.set(t,{current:r,target:o}),this.transitionImage(t,e))})}waitForImagesToLoad(){this.imageContainer.querySelectorAll("img.vvw-img-hi:not(.vvw--loaded)").forEach(i=>{const n=i,o=()=>{n.width=n.naturalWidth,n.height=n.naturalHeight;const{width:r,height:a}=F(n);n.dataset.vvwWidth=r.toString(),n.dataset.vvwHeight=a.toString(),n.classList.add("vvw--loaded"),this.imageTransitions.set(n,{current:{width:n.style.getPropertyValue("--vvw-current-w")?parseFloat(n.style.getPropertyValue("--vvw-current-w")):0,height:n.style.getPropertyValue("--vvw-current-h")?parseFloat(n.style.getPropertyValue("--vvw-current-h")):0,radius:n.style.getPropertyValue("--vvw-current-radius")?parseFloat(n.style.getPropertyValue("--vvw-current-radius")):0},target:{width:r,height:a,radius:0}}),this.transitionImage(n,()=>{var c;((c=n.parentElement)==null?void 0:c.matches(`[data-vvw-idx="${this.currentIndex}"][data-vvw-pos="0"]`))&&(this.imageState.setCurrentImage(n),this.imageState.setInitialCenter()),n.classList.add("vvw--ready")})};if(n.complete&&n.naturalWidth!==0){o();return}n.addEventListener("load",()=>{o()}),n.addEventListener("error",()=>{var a;n.classList.add("vvw--loaderror");const r=document.createElement("p");r.className="vvw-img-err",r.setAttribute("role","alert"),r.textContent="Error loading image",(a=n.parentNode)==null||a.appendChild(r)})})}registerPointerListener(t){this.pointerListeners.push(t)}unregisterPointerListeners(){this.pointerListeners=[]}open(t=0){var c,m,f,L,E;if(x.somethingOpened)return;x.somethingOpened=this,this.currentIndex=t,document.body.style.overflow="hidden";const e=U({controls:this.options.controls});if(document.body.prepend(e),this.root=document.body.querySelector("#vvw-root"),!this.root)throw new Error("Failed to setup VistaView root element.");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");const i=this.options.preloads||0,n=t,{images:o,htmls:r}=this.getChildElements(i,n),a={htmlElements:{from:null,to:r},images:{from:null,to:o},index:{from:null,to:this.currentIndex},via:{next:!1,prev:!1},vistaView:this};this.setupFunction(a),this.currentChildren={htmls:r,images:o},r.forEach(d=>{this.imageContainer.appendChild(d)}),(c=this.qs(".vvw-close"))==null||c.addEventListener("click",()=>this.close()),(m=this.qs(".vvw-zoom-in"))==null||m.addEventListener("click",()=>this.zoomIn()),(f=this.qs(".vvw-zoom-out"))==null||f.addEventListener("click",()=>this.zoomOut()),(L=this.qs(".vvw-prev>button"))==null||L.addEventListener("click",()=>this.prev()),(E=this.qs(".vvw-next>button"))==null||E.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 tt({elm:this.imageContainer,listeners:[this.getInternalPointerListener()]});const l={};[...this.options.controls.topLeft||[],...this.options.controls.topRight||[],...this.options.controls.topCenter||[],...this.options.controls.bottomCenter||[],...this.options.controls.bottomLeft||[],...this.options.controls.bottomRight||[]].forEach(d=>{typeof d!="string"&&(l[d.name]=d)}),this.root.querySelectorAll("button[data-vvw-control]").forEach(d=>{const u=d;u.addEventListener("click",b=>{const y=b.currentTarget.dataset.vvwControl,p=l[y],T=this.currentChildren.images.find(S=>S.index===this.currentIndex);p&&T&&(p.onClick.constructor.name==="AsyncFunction"?(u.classList.add("vvw--loading"),p.onClick(T,this).finally(()=>{u.classList.remove("vvw--loading")})):p.onClick(T,this))})}),this.initFunction(this),requestAnimationFrame(()=>{var d;(d=this.root)==null||d.addEventListener("transitionend",()=>{var u;(u=this.root)==null||u.classList.add("vvw--settled"),this.imageState.reset(),this.waitForImagesToLoad()},{once:!0}),this.root.classList.add("vvw--active"),this.displayActiveIndex(),this.options.onOpen&&this.options.onOpen(this),this.options.onImageView&&this.options.onImageView(a)})}async close(t=!0){x.somethingOpened===this&&this.root&&(t?await new Promise(e=>{let n=0;this.root.addEventListener("transitionend",o=>{o.target===this.root&&(n++,n===2&&this.elements instanceof NodeList&&this.elements.forEach(r=>{r.style.opacity=""}),n===3&&e(null))}),this.root.classList.add("vvw--closing")}):this.elements instanceof NodeList&&this.elements.forEach(e=>{e.style.opacity=""}),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="",x.somethingOpened=null,this.closeFunction(this),this.options.onClose&&this.options.onClose(this))}next(){if(x.somethingOpened!==this)return;const t=(this.currentIndex+1)%this.elements.length;this.view(t,{next:!0,prev:!1})}prev(){if(x.somethingOpened!==this)return;const t=(this.currentIndex-1+this.elements.length)%this.elements.length;this.view(t,{next:!1,prev:!0})}destroy(){this.close(!1),this.elements instanceof NodeList&&this.elements.forEach(t=>{t.removeAttribute("data-vista-idx"),t.removeEventListener("click",this.defaultOnClickHandler),t.removeEventListener("pointerup",this.onClickElements)})}getCurrentIndex(){return x.somethingOpened!==this?-1:this.currentIndex}view(t,e){if(x.somethingOpened!==this||t<0||t>=this.elements.length)return;const i=this.currentIndex;this.currentIndex=t;const n=this.abortController;n==null||n.abort(),this.abortController=new AbortController,this.swap(i,e)}}function st(s){let t=null;if(typeof s=="string"?t=document.querySelectorAll(s):s instanceof NodeList&&(t=s),t)for(let e=0;e<t.length;e++){const i=t[e];if(!(i.dataset.vistaviewSrc||i.getAttribute("href")||i.getAttribute("src")||""))return`Element at index ${e} is missing 'src' / 'data-vistaview-src' / 'href' attribute.`}else{const e=s;for(let i=0;i<e.length;i++)if(!e[i].src)return`Element at index ${i} is missing 'src' attribute.`}return t||s}function ot({elements:s,...t}){if(!s)throw new Error("No elements");let e=st(s);if(typeof e=="string")return null;const i=new nt(e,t);return{open:(n=0)=>i.open(n),close:()=>i.close(),next:()=>i.next(),prev:()=>i.prev(),destroy:()=>i.destroy(),getCurrentIndex:()=>i.getCurrentIndex(),view:n=>{i.view(n)}}}v.DefaultOptions=M,v.vistaView=ot,v.vistaViewDownload=z,Object.defineProperty(v,Symbol.toStringTag,{value:"Module"})}));
11
+ </div>`)}const M={animationDurationBase:333,maxZoomLevel:2,preloads:1,keyboardListeners:!0,arrowOnSmallScreens:!1,rapidLimit:222,controls:{topLeft:["indexDisplay"],topRight:["zoomIn","zoomOut",A(),"close"],bottomLeft:["description"]}};function z(s){}function k(s){const t=s.options.preloads;s.imageContainer.style.width=`${(t*2+1)*100}vw`,s.imageContainer.style.left=`-${t*100}vw`,s.imageContainer.style.display="flex",Q(s)}function Q(s){let t={x:0,y:0},e={x:0,y:0},i=null;s.registerPointerListener(n=>{var o;if(!n.hasInternalExecution&&!(n.pointers.length>1)){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"){e={x:n.pointer.x,y:n.pointer.y};const r=e.x-t.x,a=e.y-t.y;if(!i&&Math.abs(a)>Math.abs(r)||i==="y"){const h=a/window.innerHeight*100;s.imageContainer.style.transition="none",s.imageContainer.style.transform=`translateY(${h}vh)`,i="y"}else if(!i&&Math.abs(r)>Math.abs(a)||i==="x"){const h=r/window.innerWidth*100;s.imageContainer.style.transition="none",s.imageContainer.style.transform=`translateX(${h}vw)`,i="x"}}if(n.event==="up"||n.event==="cancel"){let r=function(a){var h;(h=s.imageContainer)==null||h.addEventListener("transitionend",function c(){var m;(m=s.imageContainer)==null||m.removeEventListener("transitionend",c),s.imageContainer.style.transition="",s.imageContainer.style.transform=""}),s.imageContainer.style.transition="transform 222ms ease",s.imageContainer.style.transform=a};if(i==="y"){const a=e.y-t.y;Math.abs(a)>144?(s.imageContainer.style.transition="transform 222ms ease",s.imageContainer.style.transform="translateY(0vh)",s.close()):r("translateY(0vh)")}if(i==="x"){const a=e.x-t.x,h=n.pointer.movementX,c=1;s.imageContainer.style.transition="",a>0&&Math.abs(h)>c?s.prev():a<0&&Math.abs(h)>c?s.next():r("translateX(0vw)")}i=null,t={x:0,y:0},e={x:0,y:0}}}})}function q(s){}function O({vistaView:{isReducedMotion:s},htmlElements:{to:t},index:{from:e,to:i},vistaView:{elements:n,imageContainer:o,options:r}},a){if(!(!t||a.aborted||s||!(Math.abs(i-e)===1||e===0&&i===n.length-1||e===n.length-1&&i===0)))return{cleanup:()=>{o.style.transition="",o.style.transform=""},transitionEnded:new Promise(c=>{o.addEventListener("transitionend",()=>{c()},{once:!0}),o.addEventListener("transitioncancel",()=>{a.aborted&&c()},{once:!0});const m=Math.round(r.animationDurationBase*100)/100,f=i===e+1||e===n.length-1&&i===0?"translateX(-100vw)":"translateX(100vw)";o.style.transition=`transform ${m}ms ease`,o.style.transform=f})}}class tt{constructor({elm:t,listeners:e}){l(this,"pointers",[]);l(this,"elm");l(this,"listeners",[]);l(this,"lastPointerDownId",null);l(this,"removeLastPointer",()=>{if(this.pointers.length&&this.lastPointerDownId!==null){const t=this.pointers.findIndex(e=>e.id===this.lastPointerDownId);t!==-1&&this.pointers.splice(t,1)}});l(this,"onPointerDown",t=>{if(!this.listeners.length||t.button!==0)return;t.preventDefault(),this.lastPointerDownId=t.pointerId,window.addEventListener("contextmenu",this.removeLastPointer,{once:!0}),window.addEventListener("auxclick",this.removeLastPointer,{once:!0});let e={x:t.clientX,y:t.clientY,movementX:0,movementY:0,id:t.pointerId};this.pointers.push(e),this.listeners.forEach(i=>i({event:"down",pointer:e,pointers:this.pointers,lastPointerLen:this.pointers.length-1}))});l(this,"onPointerMove",t=>{if(!this.listeners.length)return;t.preventDefault();const e=this.pointers.find(i=>i.id===t.pointerId);e&&(e.movementX=t.movementX,e.movementY=t.movementY,e.x=t.clientX,e.y=t.clientY,this.listeners.forEach(i=>i({event:"move",pointer:e,pointers:this.pointers,lastPointerLen:this.pointers.length-1})))});l(this,"onPointerUp",t=>{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))return;t.preventDefault();const e=this.pointers.findIndex(o=>o.id===t.pointerId);if(e===-1)return;const i=this.pointers[e];i.x=t.clientX,i.y=t.clientY;const n=this.pointers.length;this.pointers.splice(e,1),this.listeners.forEach(o=>o({event:"up",pointer:i,pointers:this.pointers,lastPointerLen:n}))});l(this,"onPointerCancel",t=>{if(!this.listeners.length||t.target instanceof Node&&!this.elm.contains(t.target)&&t.target!==document.querySelector("html")&&t.target!==document)return;t.preventDefault();const e=this.pointers.findIndex(o=>o.id===t.pointerId);if(e===-1)return;const i=this.pointers[e];i.x=t.clientX,i.y=t.clientY;const n=this.pointers.length;this.pointers.splice(e,1),this.listeners.forEach(o=>o({event:"cancel",pointer:i,pointers:this.pointers,lastPointerLen:n}))});this.elm=t??document,e&&(this.listeners=e),this.startListeners()}startListeners(){this.elm.addEventListener("pointerdown",this.onPointerDown),this.elm.addEventListener("pointermove",this.onPointerMove),document.addEventListener("pointerup",this.onPointerUp),document.addEventListener("pointercancel",this.onPointerCancel)}removeListeners(){this.elm.removeEventListener("pointerdown",this.onPointerDown),this.elm.removeEventListener("pointermove",this.onPointerMove),document.removeEventListener("pointerup",this.onPointerUp),document.removeEventListener("pointercancel",this.onPointerCancel),this.pointers=[]}addEventListener(t){this.listeners.push(t)}removeEventListener(t){this.listeners=this.listeners.filter(e=>e!==t)}getPointerDistance(t,e){const i=t.x-e.x,n=t.y-e.y;return Math.sqrt(i*i+n*n)}getCentroid(){if(this.pointers.length===0)return null;const t=this.pointers.reduce((e,i)=>(e.x+=i.x,e.y+=i.y,e),{x:0,y:0});return{x:t.x/this.pointers.length,y:t.y/this.pointers.length}}}class et{constructor(t,e){l(this,"maxZoomLevel");l(this,"image",null);l(this,"rect",null);l(this,"initialCenter",{x:0,y:0});l(this,"maxDimension",{width:0});l(this,"minDimension",{initialWidth:0,initialHeight:0,minWidth:0,closingWidth:0});l(this,"accumulatedTranslate",{x:0,y:0});l(this,"scale",1);l(this,"translate",{x:0,y:0});l(this,"onScale",null);l(this,"animationTimestamp",0);this.maxZoomLevel=t,this.onScale=e}clean(){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="")}reset(){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}}setCurrentImage(t){if(this.rect=null,this.image=t,this.maxDimension={width:t.naturalWidth*this.maxZoomLevel},!t.dataset.vvwWidth||!t.dataset.vvwHeight)throw new Error("VistaImageState: Image dataset vvwWidth or vvwHeight not set.");const e=parseFloat(t.dataset.vvwWidth),i=parseFloat(t.dataset.vvwHeight);this.minDimension={initialWidth:e,initialHeight:i,minWidth:e*.1,closingWidth:e*.5},this.accumulatedTranslate={x:0,y:0}}setInitialCenter(t){this.initialCenter=t||{x:window.innerWidth/2,y:window.innerHeight/2}}move(t){this.image&&(this.rect||(this.rect=this.image.getBoundingClientRect()),this.translate.x=I(t.x-this.initialCenter.x),this.translate.y=I(t.y-this.initialCenter.y),this.image.style.transform=`translate3d(${this.translate.x}px, ${this.translate.y}px, 0px) scale(${this.scale})`)}snapToTargetIfClose(t,e,i=1){return Math.abs(t-e)<=i&&(t=e),t}scaleMove(t,e){if(!this.image)return;this.rect||(this.rect=this.image.getBoundingClientRect()),e||(e=this.initialCenter);const i=this.snapToTargetIfClose(X(this.rect.width*t,this.minDimension.minWidth,this.maxDimension.width),this.minDimension.initialWidth);this.onScale&&this.onScale({scale:i/(this.maxDimension.width/this.maxZoomLevel),isMax:i>=this.maxDimension.width,isMin:i<=this.minDimension.initialWidth}),this.scale=I(i/this.rect.width);const n=this.rect.left+this.rect.width/2,o=this.rect.top+this.rect.height/2,r=this.initialCenter.x-n,a=this.initialCenter.y-o,h=r*(1-this.scale),c=a*(1-this.scale),m=e.x-this.initialCenter.x,f=e.y-this.initialCenter.y;this.translate.x=I(h+m),this.translate.y=I(c+f),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=""}moveAndNormalize(t){let e=0,i=!1;const n=({x:o,y:r})=>{if(i)return;if(Math.abs(o)<.001&&Math.abs(r)<.001)return this.normalize();o*=.9,r*=.9;const a=this.image.getBoundingClientRect();this.translate.x=I(this.translate.x+o),this.translate.y=I(this.translate.y+r),a.right<window.innerWidth/2&&(this.translate.x+=(window.innerWidth/2-a.right)*.1,o*=.7),a.left>window.innerWidth/2&&(this.translate.x-=(a.left-window.innerWidth/2)*.1,o*=.7),a.bottom<window.innerHeight/2&&(this.translate.y+=(window.innerHeight/2-a.bottom)*.1,r*=.7),a.top>window.innerHeight/2&&(this.translate.y-=(a.top-window.innerHeight/2)*.1,r*=.7),this.image.style.transform=`translate3d(${this.translate.x}px, ${this.translate.y}px, 0px) scale(${this.scale})`,e=requestAnimationFrame(()=>n({x:o,y:r}))};return n({x:t.movementX,y:t.movementY}),()=>{i=!0,cancelAnimationFrame(e),this.normalize(!1)}}animateZoom(t){if(!this.image)return;this.rect||(this.rect=this.image.getBoundingClientRect());const e=Date.now(),i=this.image;this.rect.width*t<this.minDimension.closingWidth||i.width<Math.floor(this.minDimension.initialWidth)||(i.addEventListener("transitionend",()=>{this.animationTimestamp===e&&i&&(i.style.transition="",this.normalize())},{once:!0}),i.style.transition||(i.style.transition="all 222ms ease"),this.animationTimestamp=e,this.scaleMove(t))}normalize(t=!0){if(!this.image||!this.rect)return;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),o=i?this.rect.height*this.scale:this.snapToTargetIfClose(this.rect.height*this.scale,this.minDimension.initialHeight);if(this.image.style.width=`${n}px`,this.image.style.height=`${o}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)return!0;if(n<this.minDimension.initialWidth)this.accumulatedTranslate.x=0,this.accumulatedTranslate.y=0,requestAnimationFrame(()=>{const r=this.image;r&&(r.addEventListener("transitionend",()=>{r&&(this.clean(),this.rect=null)},{once:!0}),r.style.transition="all 222ms ease",r.style.width=`${this.minDimension.initialWidth}px`,r.style.height=`${this.minDimension.initialHeight}px`,r.style.left="50%",r.style.top="50%")});else if(t){let r=!1;if(this.rect.right<window.innerWidth/2&&(r=!0,this.accumulatedTranslate.x+=window.innerWidth/2-this.rect.right),this.rect.left>window.innerWidth/2&&(r=!0,this.accumulatedTranslate.x-=this.rect.left-window.innerWidth/2),this.rect.bottom<window.innerHeight/2&&(r=!0,this.accumulatedTranslate.y+=window.innerHeight/2-this.rect.bottom),this.rect.top>window.innerHeight/2&&(r=!0,this.accumulatedTranslate.y-=this.rect.top-window.innerHeight/2),r){const a=this.image;a.addEventListener("transitionend",()=>{a&&(a.style.transition="",this.rect=null)},{once:!0}),a.style.transition="all 222ms ease",a.style.left=`calc(50% + ${this.accumulatedTranslate.x}px)`,a.style.top=`calc(50% + ${this.accumulatedTranslate.y}px)`}else this.rect=null}}}class it{constructor(){l(this,"fiolast",{})}fio(t,e,i=50){const o=Date.now()-(this.fiolast[e]??0),r=()=>{this.fiolast[e]=Date.now(),t()};if(!this.fiolast[e]){r();return}o>=i&&r()}}const C={somethingOpened:null};class nt{constructor(t,e={}){l(this,"options");l(this,"elements");l(this,"isReducedMotion");l(this,"currentIndex",-1);l(this,"currentChildren",null);l(this,"setupFunction",z);l(this,"initFunction",k);l(this,"closeFunction",q);l(this,"transitionFunction",O);l(this,"pointers",null);l(this,"imageState");l(this,"imageTransitions",new Map);l(this,"root",null);l(this,"imageContainer",null);l(this,"onClickElements",t=>{t.preventDefault();const e=t.currentTarget;e.dataset.vistaIdx&&this.open(parseInt(e.dataset.vistaIdx))});l(this,"defaultOnClickHandler",t=>t.preventDefault());l(this,"abortController",null);l(this,"throttle",new it);l(this,"lastSwapTime",0);l(this,"isRapidSwap",!1);l(this,"isRapidSwapRelease",0);l(this,"transitionCleanup",null);l(this,"isZoomedIn",!1);l(this,"onKeyDown",t=>{switch(t.key){case"ArrowLeft":t.preventDefault(),this.prev();break;case"ArrowRight":t.preventDefault(),this.next();break;case"ArrowUp":t.preventDefault(),this.zoomIn();break;case"ArrowDown":t.preventDefault(),this.zoomOut();break;case"Escape":t.preventDefault(),this.close();break}});l(this,"onScroll",t=>{t.preventDefault();const e=t.deltaY;this.imageState.setInitialCenter({x:t.clientX,y:t.clientY}),e<0?this.zoomIn():e>0&&this.zoomOut()});l(this,"onResizeHandler",()=>{this.currentChildren.htmls.forEach((t,e)=>{const i=this.currentChildren.images[e],n=t.querySelector("img.vvw-img-hi"),o=t.querySelector("img.vvw-img-lo");if(P(i,n,o,!1),n.classList.contains("vvw--loaded")){const{width:r,height:a}=F(n);n.style.setProperty("--vvw-current-w",`${r}px`),n.style.setProperty("--vvw-current-h",`${a}px`),n.dataset.vvwWidth=r.toString(),n.dataset.vvwHeight=a.toString()}})});l(this,"pointerListeners",[]);l(this,"getInternalPointerListener",()=>{const t=this.imageState;let e=0,i=!1,n=()=>{};return o=>{if(o.event==="down"){if(n(),this.isZoomedIn&&o.pointers.length===1){const r=this.pointers.getCentroid();t.setInitialCenter(r)}if(o.pointers.length>=2){i=!0;const r=this.pointers.getCentroid();e=this.pointers.getPointerDistance(o.pointers[0],o.pointers[1]),t.setInitialCenter(r)}}else if(o.event==="move"){if(this.isZoomedIn&&o.pointers.length===1&&o.lastPointerLen===0){const r=this.pointers.getCentroid();t.move(r)}if(o.pointers.length>=2&&i){const r=this.pointers.getCentroid(),a=this.pointers.getPointerDistance(o.pointers[0],o.pointers[1]);t.scaleMove(a/e,r)}}else(o.event==="up"||o.event==="cancel")&&(i||this.isZoomedIn)&&(i?(i=!1,t.normalize()&&requestAnimationFrame(()=>{this.close()})):this.isZoomedIn&&o.pointers.length===0&&(n=t.moveAndNormalize(o.pointer)));this.pointerListeners.forEach(r=>r({...o,hasInternalExecution:this.isZoomedIn||i,abortController:this.abortController}))}});this.elements=t,this.options={...M,...e,controls:{...M.controls,...e.controls}},this.imageState=new et(this.options.maxZoomLevel,i=>{var n,o,r,a;i.isMin?(this.isZoomedIn=!1,(n=this.qs(".vvw-zoom-out"))==null||n.setAttribute("disabled","true")):(this.isZoomedIn=!0,(o=this.qs(".vvw-zoom-out"))==null||o.removeAttribute("disabled")),i.isMax?(r=this.qs(".vvw-zoom-in"))==null||r.setAttribute("disabled","true"):(a=this.qs(".vvw-zoom-in"))==null||a.removeAttribute("disabled")}),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)=>{i.dataset.vistaIdx=n.toString(),i.addEventListener("click",this.defaultOnClickHandler),i.addEventListener("pointerup",this.onClickElements)})}qs(t){return this.root?this.root.querySelector(t):null}async swap(t,e){const i=this.options.preloads||0,n=this.currentIndex,{htmls:o,images:r}=this.getChildElements(i,n),a=this.imageContainer,h=this.currentChildren,c={htmlElements:{from:h.htmls,to:o},images:{from:h.images,to:r},index:{from:t,to:this.currentIndex},via:e||{next:!1,prev:!1},vistaView:this};this.setupFunction(c),this.currentChildren={htmls:o,images:r},this.displayActiveIndex();const m=this.abortController.signal,L=performance.now()-this.lastSwapTime<this.options.rapidLimit;if(this.isRapidSwap=L,a.querySelectorAll(".vvw-item img.vvw-img-hi").forEach(b=>b.classList.add("vvw--load-cancelled")),L){this.imageState.reset(),a.innerHTML="",this.transitionCleanup&&this.transitionCleanup(),o.forEach(b=>{a.appendChild(b)}),this.lastSwapTime=performance.now(),this.waitForImagesToLoad(),this.options.onImageView&&this.options.onImageView(c),this.isRapidSwapRelease&&clearTimeout(this.isRapidSwapRelease),this.isRapidSwapRelease=setTimeout(()=>{this.isRapidSwap=!1},333);return}const y=this.transitionFunction(c,m);y&&(this.transitionCleanup=y.cleanup,await y.transitionEnded),this.lastSwapTime=performance.now();const d=o[Math.floor(o.length/2)].dataset.vvwIdx,u=a.querySelector(`.vvw-item[data-vvw-idx="${d}"] img.vvw-img-hi`),E=this.imageTransitions.get(u);this.imageTransitions.delete(u);const x=u.getAttribute("style")||"",p=u.classList.contains("vvw--loaded"),S=u.classList.contains("vvw--ready"),T=u.width,H=u.height;this.imageState.reset(),a.innerHTML="",this.transitionCleanup&&this.transitionCleanup(),o.forEach(b=>{const g=b.querySelector("img.vvw-img-hi");b.dataset.vvwPos==="0"&&!m.aborted&&x&&T&&H&&(p&&(g.classList.add("vvw--loaded"),g.dataset.vvwWidth=u.dataset.vvwWidth||"",g.dataset.vvwHeight=u.dataset.vvwHeight||""),S&&(g.classList.add("vvw--ready"),g.width=T,g.height=H),g.setAttribute("style",x)),a.appendChild(b),b.dataset.vvwPos==="0"&&!m.aborted&&S?(this.imageState.setCurrentImage(g),this.imageState.setInitialCenter()):b.dataset.vvwPos==="0"&&!m.aborted&&x&&T&&H&&p&&E&&(this.imageTransitions.set(g,E),this.transitionImage(g,()=>{this.imageState.setCurrentImage(g),this.imageState.setInitialCenter(),g.classList.add("vvw--ready")}))}),this.isRapidSwap=!1,this.waitForImagesToLoad(),this.options.onImageView&&this.options.onImageView(c)}getChildElements(t,e){const i=[],n=[];for(let o=-t;o<=t;o++){const r=(e+o+this.elements.length)%this.elements.length,a=this.elements[r],h=a instanceof HTMLImageElement?a:a instanceof HTMLAnchorElement&&a.querySelector("img")||void 0,c=a instanceof HTMLElement?{index:r,imageElm:h instanceof HTMLImageElement?h:void 0,anchorElm:a instanceof HTMLAnchorElement?a:void 0,src:a.dataset.vistaviewSrc||a.getAttribute("href")||a.getAttribute("src")||"",thumb:a.dataset.vistaviewThumb||(h instanceof HTMLImageElement?h.getAttribute("src"):void 0)||a.getAttribute("href")||void 0,alt:h instanceof HTMLImageElement&&h.getAttribute("alt")||void 0}:{index:r,...a};n.push(c),i.push(G(c,o))}return{htmls:i,images:n}}zoomIn(){this.throttle.fio(()=>{this.imageState.animateZoom(1.68)},"zoom",222)}zoomOut(){this.throttle.fio(()=>{this.imageState.animateZoom(.68)},"zoom",222)}displayActiveIndex(){var r;const t=this.currentIndex;this.elements instanceof NodeList&&this.elements.forEach((a,h)=>{a.style.opacity="",h===t&&(a.style.opacity="0")});const e=this.qs(".vvw-index"),i=`${t+1}`,n=`${this.elements.length}`;e&&(e.textContent=`${i} / ${n}`);const o=this.qs(".vvw-desc");if(o){const a=(r=this.currentChildren)==null?void 0:r.images.find(c=>c.index===t),h=(a==null?void 0:a.alt)||"";h?(o.textContent=h,o.setAttribute("aria-label",`Image ${i} of ${n}: ${h}`)):(o.textContent="",o.setAttribute("aria-label",`Image ${i} of ${n}`))}}transitionImage(t,e){if(t.classList.contains("vvw--load-cancelled"))return;if(this.isRapidSwap){requestAnimationFrame(()=>{this.transitionImage(t,e)});return}const i=this.imageTransitions.get(t);i&&requestAnimationFrame(()=>{if(t.classList.contains("vvw--load-cancelled"))return;const{current:n,target:o}=i,r={width:n.width+(o.width-n.width)*.2,height:n.height+(o.height-n.height)*.2,radius:n.radius+(o.radius-n.radius)*.2};Math.abs(r.width-o.width)<1&&Math.abs(r.height-o.height)<1&&Math.abs(r.radius-o.radius)<1?(t.style.setProperty("--vvw-current-w",`${o.width}px`),t.style.setProperty("--vvw-current-h",`${o.height}px`),t.style.setProperty("--vvw-current-radius",`${o.radius}px`),this.imageTransitions.delete(t),e()):(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.set(t,{current:r,target:o}),this.transitionImage(t,e))})}waitForImagesToLoad(){this.imageContainer.querySelectorAll("img.vvw-img-hi:not(.vvw--loaded)").forEach(i=>{const n=i;if(n.classList.contains("vvw--load-cancelled"))return;const o=()=>{if(n.classList.contains("vvw--load-cancelled"))return;n.width=n.naturalWidth,n.height=n.naturalHeight;const{width:r,height:a}=F(n);n.dataset.vvwWidth=r.toString(),n.dataset.vvwHeight=a.toString(),n.classList.add("vvw--loaded"),this.imageTransitions.set(n,{current:{width:n.style.getPropertyValue("--vvw-current-w")?parseFloat(n.style.getPropertyValue("--vvw-current-w")):0,height:n.style.getPropertyValue("--vvw-current-h")?parseFloat(n.style.getPropertyValue("--vvw-current-h")):0,radius:n.style.getPropertyValue("--vvw-current-radius")?parseFloat(n.style.getPropertyValue("--vvw-current-radius")):0},target:{width:r,height:a,radius:0}}),this.transitionImage(n,()=>{var c;if(n.classList.contains("vvw--load-cancelled"))return;((c=n.parentElement)==null?void 0:c.matches(`[data-vvw-idx="${this.currentIndex}"][data-vvw-pos="0"]`))&&(this.imageState.setCurrentImage(n),this.imageState.setInitialCenter()),n.classList.add("vvw--ready")})};if(n.complete&&n.naturalWidth!==0){o();return}n.addEventListener("load",()=>{o()}),n.addEventListener("error",()=>{var a;n.classList.add("vvw--loaderror");const r=document.createElement("p");r.className="vvw-img-err",r.setAttribute("role","alert"),r.textContent="Error loading image",(a=n.parentNode)==null||a.appendChild(r)})})}registerPointerListener(t){this.pointerListeners.push(t)}unregisterPointerListeners(){this.pointerListeners=[]}open(t=0){var c,m,f,L,y;if(C.somethingOpened)return;C.somethingOpened=this,this.currentIndex=t,document.body.style.overflow="hidden";const e=J({controls:this.options.controls});if(document.body.prepend(e),this.root=document.body.querySelector("#vvw-root"),!this.root)throw new Error("Failed to setup VistaView root element.");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");const i=this.options.preloads||0,n=t,{images:o,htmls:r}=this.getChildElements(i,n),a={htmlElements:{from:null,to:r},images:{from:null,to:o},index:{from:null,to:this.currentIndex},via:{next:!1,prev:!1},vistaView:this};this.setupFunction(a),this.currentChildren={htmls:r,images:o},r.forEach(d=>{this.imageContainer.appendChild(d)}),(c=this.qs(".vvw-close"))==null||c.addEventListener("click",()=>this.close()),(m=this.qs(".vvw-zoom-in"))==null||m.addEventListener("click",()=>this.zoomIn()),(f=this.qs(".vvw-zoom-out"))==null||f.addEventListener("click",()=>this.zoomOut()),(L=this.qs(".vvw-prev>button"))==null||L.addEventListener("click",()=>this.prev()),(y=this.qs(".vvw-next>button"))==null||y.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 tt({elm:this.imageContainer,listeners:[this.getInternalPointerListener()]});const h={};[...this.options.controls.topLeft||[],...this.options.controls.topRight||[],...this.options.controls.topCenter||[],...this.options.controls.bottomCenter||[],...this.options.controls.bottomLeft||[],...this.options.controls.bottomRight||[]].forEach(d=>{typeof d!="string"&&(h[d.name]=d)}),this.root.querySelectorAll("button[data-vvw-control]").forEach(d=>{const u=d;u.addEventListener("click",E=>{const x=E.currentTarget.dataset.vvwControl,p=h[x],S=this.currentChildren.images.find(T=>T.index===this.currentIndex);p&&S&&(p.onClick.constructor.name==="AsyncFunction"?(u.classList.add("vvw--loading"),p.onClick(S,this).finally(()=>{u.classList.remove("vvw--loading")})):p.onClick(S,this))})}),this.initFunction(this),requestAnimationFrame(()=>{var d;(d=this.root)==null||d.addEventListener("transitionend",()=>{var u;(u=this.root)==null||u.classList.add("vvw--settled"),this.imageState.reset(),this.waitForImagesToLoad()},{once:!0}),this.root.classList.add("vvw--active"),this.displayActiveIndex(),this.options.onOpen&&this.options.onOpen(this),this.options.onImageView&&this.options.onImageView(a)})}async close(t=!0){C.somethingOpened===this&&this.root&&(t?await new Promise(e=>{let n=0;this.root.addEventListener("transitionend",o=>{o.target===this.root&&(n++,n===2&&this.elements instanceof NodeList&&this.elements.forEach(r=>{r.style.opacity=""}),n===3&&e(null))}),this.root.classList.add("vvw--closing")}):this.elements instanceof NodeList&&this.elements.forEach(e=>{e.style.opacity=""}),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))}next(){if(C.somethingOpened!==this)return;const t=(this.currentIndex+1)%this.elements.length;this.view(t,{next:!0,prev:!1})}prev(){if(C.somethingOpened!==this)return;const t=(this.currentIndex-1+this.elements.length)%this.elements.length;this.view(t,{next:!1,prev:!0})}destroy(){this.close(!1),this.elements instanceof NodeList&&this.elements.forEach(t=>{t.removeAttribute("data-vista-idx"),t.removeEventListener("click",this.defaultOnClickHandler),t.removeEventListener("pointerup",this.onClickElements)})}getCurrentIndex(){return C.somethingOpened!==this?-1:this.currentIndex}view(t,e){if(C.somethingOpened!==this||t<0||t>=this.elements.length)return;const i=this.currentIndex;this.currentIndex=t;const n=this.abortController;n==null||n.abort(),this.abortController=new AbortController,this.swap(i,e)}}function st(s){let t=null;if(typeof s=="string"?t=document.querySelectorAll(s):s instanceof NodeList&&(t=s),t)for(let e=0;e<t.length;e++){const i=t[e];if(!(i.dataset.vistaviewSrc||i.getAttribute("href")||i.getAttribute("src")||""))return`Element at index ${e} is missing 'src' / 'data-vistaview-src' / 'href' attribute.`}else{const e=s;for(let i=0;i<e.length;i++)if(!e[i].src)return`Element at index ${i} is missing 'src' attribute.`}return t||s}function ot({elements:s,...t}){if(!s)throw new Error("No elements");let e=st(s);if(typeof e=="string")return null;const i=new nt(e,t);return{open:(n=0)=>i.open(n),close:()=>i.close(),next:()=>i.next(),prev:()=>i.prev(),destroy:()=>i.destroy(),getCurrentIndex:()=>i.getCurrentIndex(),view:n=>{i.view(n)}}}v.DefaultOptions=M,v.close=q,v.init=k,v.setup=z,v.transition=O,v.vistaView=ot,v.vistaViewDownload=A,Object.defineProperty(v,Symbol.toStringTag,{value:"Module"})}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vistaview",
3
- "version": "0.7.2",
3
+ "version": "0.7.4",
4
4
  "description": "A lightweight, zero-dependency image lightbox library with smooth animations and touch support",
5
5
  "keywords": [
6
6
  "image",