vistaview 0.10.9 → 0.10.10

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.
@@ -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,cAAc,EACd,gCAAgC,EAEjC,MAAM,SAAS,CAAC;AAYjB,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAI5C,eAAO,MAAM,gBAAgB,EAAE;IAAE,eAAe,EAAE,SAAS,GAAG,IAAI,CAAA;CAEjE,CAAC;AAEF,qBAAa,SAAS;IACpB,OAAO,EAAE,QAAQ,CAAC;IAClB,KAAK,aAAoB;IACzB,cAAc,EAAE,WAAW,GAAG,IAAI,CAAQ;IAC1C,uBAAuB,EAAE,CAAC,CAAC,CAAC,EAAE,gCAAgC,KAAK,IAAI,CAAC,EAAE,CAAM;IAEhF,OAAO,CAAC,QAAQ,CAA4B;IAC5C,OAAO,CAAC,aAAa,CAAgC;IAErD,OAAO,CAAC,kBAAkB,CAAiC;IAC3D,OAAO,CAAC,YAAY,CAAqB;IACzC,OAAO,CAAC,YAAY,CAAqB;IACzC,OAAO,CAAC,aAAa,CAAuB;IAC5C,OAAO,CAAC,kBAAkB,CAAiC;IAE3D,OAAO,CAAC,QAAQ,CAAkB;IAClC,OAAO,CAAC,IAAI,CAA4B;IAExC,OAAO,CAAC,eAAe,CAIrB;IAEF,OAAO,CAAC,qBAAqB,CAAwD;gBAEzE,QAAQ,EAAE,MAAM,GAAG,cAAc,EAAE,EAAE,OAAO,GAAE,QAAa;IAuDvE,KAAK;IAqBL,EAAE,CAAC,CAAC,SAAS,WAAW,EAAE,QAAQ,EAAE,MAAM,GAAG,CAAC,GAAG,IAAI;IAIrD,QAAQ,CAAC,CAAC,SAAS,UAAU,CAAC,WAAW,CAAC,EAAE,QAAQ,EAAE,MAAM,GAAG,CAAC;IAIhE,uBAAuB,CAAC,QAAQ,EAAE,CAAC,CAAC,EAAE,gCAAgC,KAAK,IAAI,GAAG,IAAI;IAItF,OAAO,CAAC,gBAAgB;IAsFxB,OAAO,CAAC,YAAY,CAAK;IACzB,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,kBAAkB,CAAK;IAC/B,OAAO,CAAC,iBAAiB,CAA6B;YAExC,IAAI;IA4GlB,OAAO,CAAC,kBAAkB;IAyC1B,OAAO,CAAC,iBAAiB,CAAgB;IACzC,OAAO,CAAC,yBAAyB,CAAyB;IAC1D,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,SAAS,CAAC,EAAE,QAAQ;IAelD,OAAO,CAAC,YAAY;IAqBpB,IAAI,CAAC,UAAU,GAAE,MAAU,GAAG,IAAI;IA0H5B,KAAK,CAAC,OAAO,GAAE,OAAc,GAAG,OAAO,CAAC,IAAI,CAAC;IA6EnD,OAAO,IAAI,IAAI;IAmBf,IAAI,IAAI,IAAI;IASZ,IAAI,IAAI,IAAI;IASZ,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE;QAAE,IAAI,EAAE,OAAO,CAAC;QAAC,IAAI,EAAE,OAAO,CAAA;KAAE,GAAG,IAAI;IA+BjE,UAAU,EAAE,OAAO,CAAS;IAE5B,MAAM,IAAI,IAAI;IAed,OAAO,IAAI,IAAI;IAef,eAAe,IAAI,MAAM;CAG1B"}
1
+ {"version":3,"file":"vista-view.d.ts","sourceRoot":"","sources":["../../src/lib/vista-view.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAGV,QAAQ,EAGR,cAAc,EACd,gCAAgC,EAEjC,MAAM,SAAS,CAAC;AAYjB,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAI5C,eAAO,MAAM,gBAAgB,EAAE;IAAE,eAAe,EAAE,SAAS,GAAG,IAAI,CAAA;CAEjE,CAAC;AAEF,qBAAa,SAAS;IACpB,OAAO,EAAE,QAAQ,CAAC;IAClB,KAAK,aAAoB;IACzB,cAAc,EAAE,WAAW,GAAG,IAAI,CAAQ;IAC1C,uBAAuB,EAAE,CAAC,CAAC,CAAC,EAAE,gCAAgC,KAAK,IAAI,CAAC,EAAE,CAAM;IAEhF,OAAO,CAAC,QAAQ,CAA4B;IAC5C,OAAO,CAAC,aAAa,CAAgC;IAErD,OAAO,CAAC,kBAAkB,CAAiC;IAC3D,OAAO,CAAC,YAAY,CAAqB;IACzC,OAAO,CAAC,YAAY,CAAqB;IACzC,OAAO,CAAC,aAAa,CAAuB;IAC5C,OAAO,CAAC,kBAAkB,CAAiC;IAE3D,OAAO,CAAC,QAAQ,CAAkB;IAClC,OAAO,CAAC,IAAI,CAA4B;IAExC,OAAO,CAAC,eAAe,CAIrB;IAEF,OAAO,CAAC,qBAAqB,CAAwD;gBAEzE,QAAQ,EAAE,MAAM,GAAG,cAAc,EAAE,EAAE,OAAO,GAAE,QAAa;IAuDvE,KAAK;IAqBL,EAAE,CAAC,CAAC,SAAS,WAAW,EAAE,QAAQ,EAAE,MAAM,GAAG,CAAC,GAAG,IAAI;IAIrD,QAAQ,CAAC,CAAC,SAAS,UAAU,CAAC,WAAW,CAAC,EAAE,QAAQ,EAAE,MAAM,GAAG,CAAC;IAIhE,uBAAuB,CAAC,QAAQ,EAAE,CAAC,CAAC,EAAE,gCAAgC,KAAK,IAAI,GAAG,IAAI;IAItF,OAAO,CAAC,gBAAgB;IAsFxB,OAAO,CAAC,YAAY,CAAK;IACzB,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,kBAAkB,CAAK;IAC/B,OAAO,CAAC,iBAAiB,CAA6B;YAExC,IAAI;IA4GlB,OAAO,CAAC,kBAAkB;IAyC1B,OAAO,CAAC,iBAAiB,CAAgB;IACzC,OAAO,CAAC,yBAAyB,CAAyB;IAC1D,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,SAAS,CAAC,EAAE,QAAQ;IAelD,OAAO,CAAC,YAAY;IAqBpB,IAAI,CAAC,UAAU,GAAE,MAAU,GAAG,IAAI;IA0H5B,KAAK,CAAC,OAAO,GAAE,OAAc,GAAG,OAAO,CAAC,IAAI,CAAC;IA6EnD,OAAO,IAAI,IAAI;IAmBf,IAAI,IAAI,IAAI;IASZ,IAAI,IAAI,IAAI;IASZ,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE;QAAE,IAAI,EAAE,OAAO,CAAC;QAAC,IAAI,EAAE,OAAO,CAAA;KAAE,GAAG,IAAI;IA+BjE,UAAU,EAAE,OAAO,CAAS;IAE5B,MAAM,IAAI,IAAI;IAoBd,OAAO,IAAI,IAAI;IAoBf,eAAe,IAAI,MAAM;CAG1B"}
package/dist/vistaview.js CHANGED
@@ -1,7 +1,7 @@
1
- var z = Object.defineProperty;
2
- var T = (s, t, e) => t in s ? z(s, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : s[t] = e;
3
- var r = (s, t, e) => T(s, typeof t != "symbol" ? t + "" : t, e);
4
- import { V as D, a as L } from "./vista-box-CQvGrjln.js";
1
+ var S = Object.defineProperty;
2
+ var D = (s, t, e) => t in s ? S(s, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : s[t] = e;
3
+ var r = (s, t, e) => D(s, typeof t != "symbol" ? t + "" : t, e);
4
+ import { V as T, a as L } from "./vista-box-CQvGrjln.js";
5
5
  const I = {
6
6
  // debug, don't remove
7
7
  // animationDurationBase: 1000,
@@ -139,9 +139,9 @@ function B(s) {
139
139
  const t = s.options.preloads;
140
140
  s.imageContainer.style.width = `${(t * 2 + 1) * 100}vw`, s.imageContainer.style.left = `-${t * 100}vw`, s.imageContainer.style.display = "flex";
141
141
  }
142
- function X(s) {
142
+ function U(s) {
143
143
  }
144
- function Y({ vistaView: s, htmlElements: { to: t }, index: { from: e, to: i } }, n) {
144
+ function X({ vistaView: s, htmlElements: { to: t }, index: { from: e, to: i } }, n) {
145
145
  const { imageContainer: o, options: a } = s, { isReducedMotion: h } = s.state;
146
146
  if (!(!t || n.aborted || h || !(Math.abs(i - e) === 1 || e === 0 && i === s.state.elmLength - 1 || e === s.state.elmLength - 1 && i === 0)))
147
147
  return {
@@ -167,7 +167,7 @@ function Y({ vistaView: s, htmlElements: { to: t }, index: { from: e, to: i } },
167
167
  })
168
168
  };
169
169
  }
170
- function P(s) {
170
+ function z(s) {
171
171
  const t = window.innerWidth, e = window.innerHeight, i = s.naturalWidth, n = s.naturalHeight;
172
172
  if (!i || !n)
173
173
  throw console.error("Error", s), new Error("Image natural dimensions are zero");
@@ -183,7 +183,7 @@ function P(s) {
183
183
  height: l
184
184
  };
185
185
  }
186
- class U extends D {
186
+ class Y extends T {
187
187
  constructor(e) {
188
188
  super(e);
189
189
  r(this, "element");
@@ -217,11 +217,11 @@ class U extends D {
217
217
  if (this.isCancelled) return;
218
218
  const e = this.element;
219
219
  e.width = e.naturalWidth, e.height = e.naturalHeight, this.maxW = e.naturalWidth * this.maxZoomLevel;
220
- const { width: i, height: n } = P(e);
220
+ const { width: i, height: n } = z(e);
221
221
  this.fullH = n, this.fullW = i, this.minW = this.fullW * 0.5, this.isLoadedResolved(!0);
222
222
  }
223
223
  getFullSizeDim() {
224
- return P(this.element);
224
+ return z(this.element);
225
225
  }
226
226
  normalize() {
227
227
  super.normalize();
@@ -371,13 +371,13 @@ class j {
371
371
  r(this, "extensions", /* @__PURE__ */ new Set());
372
372
  }
373
373
  }
374
- function S(s) {
374
+ function P(s) {
375
375
  return s && !/^0(px|%|r?em|vw|vh|vmin|vmax|cm|mm|in|pt|pc|ex|ch)?$/i.test(s.trim()) && s;
376
376
  }
377
377
  function _(s) {
378
378
  const t = s instanceof HTMLAnchorElement ? s : null, e = s instanceof HTMLImageElement ? s : t == null ? void 0 : t.querySelector("img"), i = t ? getComputedStyle(t) : null, n = e ? getComputedStyle(e) : null;
379
379
  let o = "0px", a = n ? n.objectFit : "contain";
380
- return i && S(i.borderRadius) ? o = i.borderRadius : n && S(n.borderRadius) && (o = n.borderRadius), {
380
+ return i && P(i.borderRadius) ? o = i.borderRadius : n && P(n.borderRadius) && (o = n.borderRadius), {
381
381
  borderRadius: o,
382
382
  objectFit: a
383
383
  };
@@ -645,8 +645,8 @@ class tt {
645
645
  r(this, "imageSetupFunction", k);
646
646
  r(this, "initFunction", V);
647
647
  r(this, "openFunction", B);
648
- r(this, "closeFunction", X);
649
- r(this, "transitionFunction", Y);
648
+ r(this, "closeFunction", U);
649
+ r(this, "transitionFunction", X);
650
650
  r(this, "throttle", new Z());
651
651
  r(this, "root", null);
652
652
  r(this, "onClickElements", (t) => {
@@ -737,7 +737,7 @@ class tt {
737
737
  this.state.extensions.forEach((m) => {
738
738
  !u && m.onInitializeImage && (u = m.onInitializeImage(p));
739
739
  });
740
- const v = u ?? new U(p), f = document.createElement("div");
740
+ const v = u ?? new Y(p), f = document.createElement("div");
741
741
  f.className = "vvw-item", f.dataset.vvwPos = `${a}`, f.dataset.vvwIdx = `${h}`, v.thumb && f.appendChild(v.thumb), f.appendChild(v.element), i.push(v), n.push(f);
742
742
  }
743
743
  return {
@@ -929,7 +929,7 @@ class tt {
929
929
  console.warn("This VistaView instance is not opened.");
930
930
  return;
931
931
  }
932
- this.throttle.fio(
932
+ this.tempDeactivatedUi.includes("zoomIn") || this.throttle.fio(
933
933
  () => {
934
934
  const t = this.state.children.images.find((e) => e.pos === 0);
935
935
  t == null || t.animateZoom(1.68);
@@ -943,7 +943,7 @@ class tt {
943
943
  console.warn("This VistaView instance is not opened.");
944
944
  return;
945
945
  }
946
- this.throttle.fio(
946
+ this.tempDeactivatedUi.includes("zoomOut") || this.throttle.fio(
947
947
  () => {
948
948
  const t = this.state.children.images.find((e) => e.pos === 0);
949
949
  t == null || t.animateZoom(0.68);
@@ -1000,17 +1000,17 @@ function st({ elements: s, ...t }) {
1000
1000
  }
1001
1001
  export {
1002
1002
  I as DefaultOptions,
1003
- D as VistaBox,
1003
+ T as VistaBox,
1004
1004
  L as VistaHiresTransition,
1005
- U as VistaImage,
1005
+ Y as VistaImage,
1006
1006
  Q as VistaImageEvent,
1007
1007
  J as VistaPointers,
1008
1008
  j as VistaState,
1009
1009
  tt as VistaView,
1010
- X as close,
1010
+ U as close,
1011
1011
  k as imageSetup,
1012
1012
  V as init,
1013
1013
  B as open,
1014
- Y as transition,
1014
+ X as transition,
1015
1015
  st as vistaView
1016
1016
  };
@@ -1,4 +1,4 @@
1
- (function(c,y){typeof exports=="object"&&typeof module<"u"?y(exports):typeof define=="function"&&define.amd?define(["exports"],y):(c=typeof globalThis<"u"?globalThis:c||self,y(c.VistaView=c.VistaView||{}))})(this,(function(c){"use strict";var nt=Object.defineProperty;var st=(c,y,I)=>y in c?nt(c,y,{enumerable:!0,configurable:!0,writable:!0,value:I}):c[y]=I;var r=(c,y,I)=>st(c,typeof y!="symbol"?y+"":y,I);const y={animationDurationBase:333,maxZoomLevel:2,preloads:1,keyboardListeners:!0,arrowOnSmallScreens:!1,rapidLimit:222,controls:{topLeft:["indexDisplay"],topRight:["zoomIn","zoomOut","close"],bottomLeft:["description"]}},I='<svg viewBox="0 0 24 24"><path d="m15 18-6-6 6-6"/></svg>',k='<svg viewBox="0 0 24 24"><path d="m9 18 6-6-6-6"/></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="11" x2="11" y1="8" y2="14"/><line x1="8" x2="14" y1="11" y2="11"/></svg>',N='<svg viewBox="0 0 24 24"><circle cx="11" cy="11" r="8"/><line x1="21" x2="16.65" y1="21" y2="16.65"/><line x1="8" x2="14" y1="11" y2="11"/></svg>',B='<svg viewBox="0 0 24 24"><path d="M18 6 6 18"/><path d="m6 6 12 12"/></svg>';let P=null;function Z(){return P||(window.trustedTypes||(window.trustedTypes={createPolicy:(s,t)=>t}),P=window.trustedTypes.createPolicy("vistaView-policy",{createHTML:s=>s,createScript:()=>{throw new Error("Not implemented")},createScriptURL:()=>{throw new Error("Not implemented")}}),P)}function X(s){const e=Z().createHTML(s),i=document.createElement("template");i.innerHTML=e;const n=i.content;return i.remove(),n}function Y(s){if(typeof s=="string")switch(s){case"zoomIn":return`<div class="vvw-ui"><button aria-label="Zoom In" class="vvw-zoom-in">${j}</button></div>`;case"zoomOut":return`<div class="vvw-ui"><button aria-label="Zoom Out" disabled class="vvw-zoom-out">${N}</button></div>`;case"close":return`<div class="vvw-ui"><button aria-label="Close" class="vvw-close">${B}</button></div>`;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 console.warn(`Unknown default control: ${s}. Will return empty string.`),""}return`<div class="vvw-ext vvw-ui" aria-label="${s.description||s.name}" data-vvw-control="${s.name}"></div>`}function U({controls:s}){const t=i=>i?i.map(Y).join(""):"",e=X(`<div class="vvw-root" id="vvw-root">
1
+ (function(c,y){typeof exports=="object"&&typeof module<"u"?y(exports):typeof define=="function"&&define.amd?define(["exports"],y):(c=typeof globalThis<"u"?globalThis:c||self,y(c.VistaView=c.VistaView||{}))})(this,(function(c){"use strict";var nt=Object.defineProperty;var st=(c,y,I)=>y in c?nt(c,y,{enumerable:!0,configurable:!0,writable:!0,value:I}):c[y]=I;var r=(c,y,I)=>st(c,typeof y!="symbol"?y+"":y,I);const y={animationDurationBase:333,maxZoomLevel:2,preloads:1,keyboardListeners:!0,arrowOnSmallScreens:!1,rapidLimit:222,controls:{topLeft:["indexDisplay"],topRight:["zoomIn","zoomOut","close"],bottomLeft:["description"]}},I='<svg viewBox="0 0 24 24"><path d="m15 18-6-6 6-6"/></svg>',k='<svg viewBox="0 0 24 24"><path d="m9 18 6-6-6-6"/></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="11" x2="11" y1="8" y2="14"/><line x1="8" x2="14" y1="11" y2="11"/></svg>',N='<svg viewBox="0 0 24 24"><circle cx="11" cy="11" r="8"/><line x1="21" x2="16.65" y1="21" y2="16.65"/><line x1="8" x2="14" y1="11" y2="11"/></svg>',B='<svg viewBox="0 0 24 24"><path d="M18 6 6 18"/><path d="m6 6 12 12"/></svg>';let P=null;function Z(){return P||(window.trustedTypes||(window.trustedTypes={createPolicy:(s,t)=>t}),P=window.trustedTypes.createPolicy("vistaView-policy",{createHTML:s=>s,createScript:()=>{throw new Error("Not implemented")},createScriptURL:()=>{throw new Error("Not implemented")}}),P)}function U(s){const e=Z().createHTML(s),i=document.createElement("template");i.innerHTML=e;const n=i.content;return i.remove(),n}function X(s){if(typeof s=="string")switch(s){case"zoomIn":return`<div class="vvw-ui"><button aria-label="Zoom In" class="vvw-zoom-in">${j}</button></div>`;case"zoomOut":return`<div class="vvw-ui"><button aria-label="Zoom Out" disabled class="vvw-zoom-out">${N}</button></div>`;case"close":return`<div class="vvw-ui"><button aria-label="Close" class="vvw-close">${B}</button></div>`;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 console.warn(`Unknown default control: ${s}. Will return empty string.`),""}return`<div class="vvw-ext vvw-ui" aria-label="${s.description||s.name}" data-vvw-control="${s.name}"></div>`}function Y({controls:s}){const t=i=>i?i.map(X).join(""):"",e=U(`<div class="vvw-root" id="vvw-root">
2
2
  <div class="vvw-container">
3
3
  <div class="vvw-bg"></div>
4
4
  <div class="vvw-image-container"></div>
@@ -15,4 +15,4 @@
15
15
  <div class="vvw-prev vvw-ui"><button aria-label="Previous">${I}</button></div>
16
16
  <div class="vvw-next vvw-ui"><button aria-label="Next">${k}</button></div>
17
17
  </div>
18
- </div>`);return[...(s==null?void 0:s.topLeft)||[],...(s==null?void 0:s.topCenter)||[],...(s==null?void 0:s.topRight)||[],...(s==null?void 0:s.bottomLeft)||[],...(s==null?void 0:s.bottomCenter)||[],...(s==null?void 0:s.bottomRight)||[]].forEach(i=>{if(typeof i!="string"&&i.control){const n=e.querySelector(`[data-vvw-control="${i.name}"]`),o=i.control();n&&o&&n.appendChild(o)}}),e}function W(s){}function R(s){K(s)}function K(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 a=e.x-t.x,l=e.y-t.y;if(!i&&Math.abs(l)>Math.abs(a)||i==="y"){const h=l/window.innerHeight*100;s.imageContainer.style.transition="none",s.imageContainer.style.transform=`translateY(${h}vh)`,i="y"}else if(!i&&Math.abs(a)>Math.abs(l)||i==="x"&&n.state.elmLength>1){const h=a/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 a=function(l){var h;(h=s.imageContainer)==null||h.addEventListener("transitionend",function f(){var d;(d=s.imageContainer)==null||d.removeEventListener("transitionend",f),s.imageContainer.style.transition="",s.imageContainer.style.transform=""}),s.imageContainer.style.transition="transform 222ms ease",s.imageContainer.style.transform=l};if(i==="y"){const l=e.y-t.y;Math.abs(l)>144?(s.imageContainer.style.transition="transform 222ms ease",s.imageContainer.style.transform="translateY(0vh)",s.close()):a("translateY(0vh)")}if(i==="x"&&n.state.elmLength>1){const l=e.x-t.x;s.imageContainer.style.transition="",l>64?s.prev():l<-64?s.next():a("translateX(0vw)")}i=null,t={x:0,y:0},e={x:0,y:0}}}})}function z(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"}function T(s){}function H({vistaView:s,htmlElements:{to:t},index:{from:e,to:i}},n){const{imageContainer:o,options:a}=s,{isReducedMotion:l}=s.state;if(!(!t||n.aborted||l||!(Math.abs(i-e)===1||e===0&&i===s.state.elmLength-1||e===s.state.elmLength-1&&i===0)))return{cleanup:()=>{o.style.transition="",o.style.transform=""},transitionEnded:new Promise(f=>{o.addEventListener("transitionend",()=>{f()},{once:!0}),o.addEventListener("transitioncancel",()=>{n.aborted&&f()},{once:!0});const d=Math.round(a.animationDurationBase*100)/100,u=i===e+1||e===s.state.elmLength-1&&i===0?"translateX(-100vw)":"translateX(100vw)";o.style.transition=`transform ${d}ms ease`,o.style.transform=u})}}function D(s){const t=window.innerWidth,e=window.innerHeight,i=s.naturalWidth,n=s.naturalHeight;if(!i||!n)throw console.error("Error",s),new Error("Image natural dimensions are zero");if(i<t&&n<e)return{width:i,height:n};const o=i/n,a=t/e;let l,h;return o>a?(l=t,h=t/o):(h=e,l=e*o),{width:l,height:h}}class x{static ease(t,e,i){const n=e-t,o=t+n*.2;return Math.abs(n)<i?e:o}static play(t,e,i){if(i()){requestAnimationFrame(()=>{this.play(t,e,i)});return}this.map.get(t)&&(t.element.classList.contains("vvw--load-cancelled")||requestAnimationFrame(()=>{var d,u,v,p,g,m,w,b,E,S;const n=this.map.get(t);if(!n||!t.element||t.element.classList.contains("vvw--load-cancelled"))return;const{current:o,target:a,log:l}=n;let h={};a.width!==void 0&&(h.width=this.ease(o._width,a.width,1)),a.height!==void 0&&(h.height=this.ease(o._height,a.height,1)),((d=a.transform)==null?void 0:d.x)!==void 0&&(h.transform=h.transform||{},h.transform.x=this.ease(o._transform.x,a.transform.x,1)),((u=a.transform)==null?void 0:u.y)!==void 0&&(h.transform=h.transform||{},h.transform.y=this.ease(o._transform.y,a.transform.y,1)),((v=a.transform)==null?void 0:v.scale)!==void 0&&(h.transform=h.transform||{},h.transform.scale=this.ease(o._transform.scale,a.transform.scale,.005)),((p=a.translate)==null?void 0:p.x)!==void 0&&(h.translate=h.translate||{},h.translate.x=this.ease(o._translate.x,a.translate.x,1)),((g=a.translate)==null?void 0:g.y)!==void 0&&(h.translate=h.translate||{},h.translate.y=this.ease(o._translate.y,a.translate.y,1)),h.width!==void 0&&(o.width=h.width),h.height!==void 0&&(o.height=h.height),h.translate&&(o.translate={...o.translate,...h.translate}),h.transform&&(o.transform={...o.transform,...h.transform}),(a.width===void 0||o._width===a.width)&&(a.height===void 0||o._height===a.height)&&(((m=a.transform)==null?void 0:m.x)===void 0||o._transform.x===a.transform.x)&&(((w=a.transform)==null?void 0:w.y)===void 0||o._transform.y===a.transform.y)&&(((b=a.transform)==null?void 0:b.scale)===void 0||o._transform.scale===a.transform.scale)&&(((E=a.translate)==null?void 0:E.x)===void 0||o._translate.x===a.translate.x)&&(((S=a.translate)==null?void 0:S.y)===void 0||o._translate.y===a.translate.y)?(this.map.delete(t),e()):(this.map.set(t,{current:o,target:a,log:l}),this.play(t,e,i))}))}static stop(t){const e=this.map.get(t);return this.map.delete(t),e}static start({vistaImage:t,target:e,onComplete:i,shouldWait:n}){this.stop(t),this.map.set(t,{current:t.state,target:e}),this.play(t,i,n)}}r(x,"map",new Map);function M(s){const e=window.getComputedStyle(s).objectFit||"",{width:i,height:n}=s.getBoundingClientRect(),o=s.naturalWidth,a=s.naturalHeight;if(!e)return{width:i,height:n};if(!o||!a)return{width:i,height:n};const l=o/a,h=i/n;switch(e){case"fill":return{width:i,height:n};case"none":return{width:o,height:a};case"contain":return l>h?{width:i,height:i/l}:{width:n*l,height:n};case"cover":return l<h?{width:i,height:i/l}:{width:n*l,height:n};case"scale-down":{const f={width:o,height:a},d=l>h?{width:i,height:i/l}:{width:n*l,height:n};return d.width<=f.width&&d.height<=f.height?d:f}}return{width:i,height:n}}class F{constructor(t){r(this,"state");r(this,"parsedSrcSet");r(this,"isReady",!1);r(this,"isThrowing",!1);r(this,"thumb",null);r(this,"pos");r(this,"index");r(this,"config");r(this,"origin");r(this,"initH",0);r(this,"initW",0);r(this,"fullH",0);r(this,"fullW",0);r(this,"maxW",0);r(this,"minW",0);r(this,"defaultWH",200);r(this,"isZoomedIn",!1);r(this,"isCancelled",!1);r(this,"isLoadedResolved",null);r(this,"isLoadedRejected",null);r(this,"isLoaded",new Promise((t,e)=>{this.isLoadedResolved=t,this.isLoadedRejected=e}));r(this,"replacement",null);r(this,"originalParent",null);r(this,"originalNextSibling",null);r(this,"originalStyle","");r(this,"thumbImage",null);r(this,"fittedSize",null);r(this,"maxZoomLevel");r(this,"vistaView");r(this,"transitionState",null);r(this,"transitionShouldWait",()=>!1);r(this,"initPointerCenter",{x:0,y:0});r(this,"onScale");var i;this.state=this.createState(),this.pos=t.pos,this.index=t.index,this.config=t.elm.config,this.parsedSrcSet=t.elm.parsedSrcSet,this.origin=t.elm.origin,this.maxZoomLevel=t.maxZoomLevel,this.vistaView=t.vistaView,this.onScale=t.onScale,t.transitionState&&(this.transitionState=t.transitionState),t.transitionShouldWait&&(this.transitionShouldWait=t.transitionShouldWait),this.initPointerCenter={x:window.innerWidth/2,y:window.innerHeight/2};const e=this.pos===0?(i=this.origin)==null?void 0:i.image:null;if(this.originalParent=(e==null?void 0:e.parentElement)||null,this.originalNextSibling=(e==null?void 0:e.nextSibling)||null,e&&this.originalParent){this.originalStyle=e.style.cssText,this.thumbImage=e;const n=e.cloneNode(!0);this.originalParent.insertBefore(n,e),this.replacement=n,this.thumb=document.createElement("div"),this.thumb.classList.add("vvw-img-lo");const{width:o,height:a}=this.thumbImage?M(this.thumbImage):{width:0,height:0};this.fittedSize={width:o,height:a},this.thumb.appendChild(e),e.style.width="100%",e.style.height="100%",e.style.objectFit=this.origin.objectFit}}createState(){const t=this;return{_t:this,_width:0,_height:0,_transform:{x:0,y:0,scale:1},_translate:{x:0,y:0},_lessThanMinWidth:!1,get width(){return this._width},set width(e){this._width=e,t.onWidthChange(e)},get height(){return this._height},set height(e){this._height=e,t.onHeightChange(e)},get transform(){return this._transform},set transform(e){this._transform=e,t.onTransformChange(e)},get translate(){return this._translate},set translate(e){this._translate=e,t.onTranslateChange(e)},get lessThanMinWidth(){return this._lessThanMinWidth},set lessThanMinWidth(e){this._lessThanMinWidth=e,t.onLessThanMinWidthChange(e)}}}onLessThanMinWidthChange(t){t?this.element.style.opacity="0.5":this.element.style.opacity=""}onTranslateChange(t){this.element.style.translate=`calc(-50% + ${t.x}px) calc(-50% + ${t.y}px)`}onTransformChange(t){const e=`translate3d(${t.x}px, ${t.y}px, 0px) scale3d(${t.scale}, ${t.scale}, 1)`;this.element.style.transform=e}onWidthChange(t){this.element.style.width=`${t}px`}onHeightChange(t){this.element.style.height=`${t}px`}onImageReady(){}animateZoom(t,e){}scaleMove(t,e,i){}momentumThrow(t){return()=>{}}async init(){await this.isLoaded;const t=this.element;this.transitionState&&this.transitionState.current.width&&this.transitionState.current.height?(this.state.width=this.transitionState.current.width,this.state.height=this.transitionState.current.height):t.classList.contains("vvw--loaded")||(this.state.width=this.initW,this.state.height=this.initH);const e=()=>{this.isCancelled||x.start({vistaImage:this,target:{width:this.fullW,height:this.fullH},onComplete:()=>{this.isCancelled||(this.isReady=!0,t.classList.add("vvw--ready"),this.onImageReady())},shouldWait:this.transitionShouldWait})};this.pos<-1||this.pos>1?(this.state.width=this.fullW,this.state.height=this.fullH,t.classList.add("vvw--loaded"),t.classList.add("vvw--ready"),this.isReady=!0):t.classList.contains("vvw--loaded")?t.classList.contains("vvw--ready")?(this.isReady=!0,this.onImageReady()):e():(t.classList.add("vvw--loaded"),setTimeout(()=>{this.isCancelled||e()},333))}getFullSizeDim(){const{width:t,height:e}=this.thumb.getBoundingClientRect(),i=t/e;let n=window.innerWidth,o=window.innerHeight;return i>window.innerWidth/window.innerHeight?o=n/i:n=o*i,{width:n,height:o}}setSizes(t={}){var l,h,f;const{stableSize:e=!0,initDimension:i}=t;if(!this.origin)return;const n=this.thumb;let o={width:this.defaultWH,height:this.defaultWH,top:0,left:0};if(n){o=(((l=this.origin)==null?void 0:l.anchor)||this.replacement).getBoundingClientRect();const d=n.style;d.width=o.width+"px",d.height=o.height+"px",d.top="50%",d.left="50%",d.translate="-50% -50%",d.position="fixed",d.objectFit=this.origin.objectFit,d.borderRadius=this.origin.borderRadius;const u=Math.min(Math.max(o.left,-o.width),window.innerWidth+o.width)-window.innerWidth/2+o.width/2,v=Math.min(Math.max(o.top,-o.height),window.innerHeight+o.height)-window.innerHeight/2+o.height/2;d.setProperty("--vvw-init-radius",d.borderRadius),d.setProperty("--vvw-pulse-radius",`calc(1.3 * ${d.borderRadius})`),d.setProperty("--vvw-init-x",`${u}px`),d.setProperty("--vvw-init-y",`${v}px`),i&&(d.setProperty("--vvw-current-x",`${u}px`),d.setProperty("--vvw-current-y",`${v}px`))}if(!i){const{width:d,height:u}=this.thumbImage?M(this.thumbImage):{width:0,height:0};this.fittedSize={width:d,height:u}}const a=this.element;if(this.initW=Math.min(((h=this.fittedSize)==null?void 0:h.width)??0,o.width),this.initH=Math.min(((f=this.fittedSize)==null?void 0:f.height)??0,o.height),a.style.setProperty("--vvw-init-w",this.initW+"px"),a.style.setProperty("--vvw-init-h",this.initH+"px"),a.style.setProperty("--vvw-init-radius",this.origin.borderRadius),a.style.objectFit="cover",!i){if(this.isReady&&!this.isCancelled){const{width:d,height:u}=this.getFullSizeDim();this.fullH=u,this.fullW=d,this.minW=this.fullW*.5}!this.isZoomedIn&&e&&this.normalize()}}normalize(){this.state.transform={x:0,y:0,scale:1},this.state.translate={x:0,y:0},this.state.width=this.fullW,this.state.height=this.fullH,this.isZoomedIn=!1}getFromParsedSrcSet(t){if(!this.parsedSrcSet||this.parsedSrcSet.length===0)return null;const e=t*(window.devicePixelRatio||1);let i=this.parsedSrcSet[this.parsedSrcSet.length-1];for(const n of this.parsedSrcSet)if(n.width>=e){i=n;break}return i.src}prepareClose(){x.stop(this),this.setFinalTransform()}cancelPendingLoad(){var t;this.isCancelled=!0,(t=this.element)==null||t.classList.add("vvw--load-cancelled")}setInitialCenter(t){this.initPointerCenter=t}destroy(){var t,e;this.originalParent&&this.thumbImage&&(this.thumbImage.style.cssText=this.originalStyle,this.originalNextSibling?this.originalParent.insertBefore(this.thumbImage,this.originalNextSibling):this.originalParent.appendChild(this.thumbImage)),this.originalParent=null,this.originalNextSibling=null,this.originalStyle="",this.thumbImage=null,this.replacement&&(this.replacement.remove(),this.replacement=null),(t=this.thumb)==null||t.remove(),(e=this.element)==null||e.remove(),this.thumb=null,this.origin=void 0,this.config={src:"",alt:""}}cloneStyleFrom(t,e){t!=null&&t.element&&(e&&(this.transitionState=e||null),t.element.classList.contains("vvw--loaded")&&(this.element.classList.add("vvw--loaded"),this.state.width=t.state.width,this.state.height=t.state.height),t.element.classList.contains("vvw--ready")&&this.element.classList.add("vvw--ready"))}toObject(){return structuredClone({config:{src:this.config.src,alt:this.config.alt,srcSet:this.config.srcSet},origin:this.origin?{src:this.origin.src,srcSet:this.origin.srcSet,borderRadius:this.origin.borderRadius,objectFit:this.origin.objectFit}:null,parsedSrcSet:this.parsedSrcSet,element:"src"in this.element?this.element.src:this.element.toString(),thumb:void 0,index:this.index,pos:this.pos,state:{width:this.state._width,height:this.state._height,transform:this.state._transform,translate:this.state._translate}})}setFinalTransform(t={}){const{propagateEvent:e=!0}=t;if(this.isReady){if(this.state.translate.x+=this.state.transform.x,this.state.translate.y+=this.state.transform.y,this.state.width*=this.state.transform.scale,this.state.height*=this.state.transform.scale,Math.abs(this.state.width-this.fullW)<1&&(this.state.width=this.fullW,this.state.height=this.fullH),Math.abs(this.state.translate.x)<1&&(this.state.translate.x=0),Math.abs(this.state.translate.y)<1&&(this.state.translate.y=0),this.state.translate={...this.state.translate},this.state.transform={x:0,y:0,scale:1},e){const i=this.toObject();this.vistaView.options.onContentChange&&this.vistaView.options.onContentChange(i,this.vistaView),this.vistaView.state.extensions.forEach(n=>{n.onContentChange&&n.onContentChange(i,this.vistaView)})}return{close:!0,cancel:()=>{}}}}}class O extends F{constructor(e){super(e);r(this,"element");r(this,"rect",null);r(this,"animateNormalizeTimeout",null);const i=document.createElement("img");i.alt=this.config.alt||"",i.classList.add("vvw-img-hi"),this.element=i,i.onerror=n=>{this.isLoadedRejected(n)},i.src=this.config.src,i.decode().then(()=>{this.onLoad()}).catch(n=>{this.isLoadedRejected(n)}),this.setSizes({stableSize:!1,initDimension:!0})}onWidthChange(e){super.onWidthChange(e);const i=this.getFromParsedSrcSet(e);if(i&&this.element.src!==i){const n=new Image;n.onload=()=>{n.decode().then(()=>{this.isCancelled||(this.element.src=i)})},n.src=i}}onLoad(){if(this.isCancelled)return;const e=this.element;e.width=e.naturalWidth,e.height=e.naturalHeight,this.maxW=e.naturalWidth*this.maxZoomLevel;const{width:i,height:n}=D(e);this.fullH=n,this.fullW=i,this.minW=this.fullW*.5,this.isLoadedResolved(!0)}getFullSizeDim(){return D(this.element)}normalize(){super.normalize();const e=this.element;e.style.objectFit="cover",e.style.borderRadius="0"}scaleMove(e,i,n=!1){if(!this.isReady||!this.element)return;this.rect||(this.rect=this.element.getBoundingClientRect()),i||(i=this.initPointerCenter);const o=this.rect.left+this.rect.width/2,a=this.rect.top+this.rect.height/2,l=this.initPointerCenter.x-o,h=this.initPointerCenter.y-a,f=l*(1-e),d=h*(1-e),u=i.x-this.initPointerCenter.x,v=i.y-this.initPointerCenter.y;n?x.start({vistaImage:this,target:{transform:{x:f+u,y:d+v,scale:e}},onComplete:()=>{this.setFinalTransform()},shouldWait:()=>!1}):this.state.transform={x:f+u,y:d+v,scale:e};const g=this.element.getBoundingClientRect().width*e;this.isZoomedIn=g>this.fullW,this.state.lessThanMinWidth=g<=this.minW,this.onScale({vistaImage:this,scale:g/this.fullW,isMax:g>=this.maxW,isMin:g<=this.fullW})}animateZoom(e,i){this.state.width*e<this.minW||this.scaleMove(e,i,!0)}momentumThrow(e){if(!this.isReady)return()=>{};if(!this.isThrowing)return this.setFinalTransform(),()=>{};if(Math.abs(e.x)<.1&&Math.abs(e.y)<.1){const n=this.element.getBoundingClientRect();return x.start({vistaImage:this,target:{transform:{x:n.right<window.innerWidth/2?this.state.transform.x+(window.innerWidth/2-n.right):n.left>window.innerWidth/2?this.state.transform.x-(n.left-window.innerWidth/2):this.state.transform.x,y:n.bottom<window.innerHeight/2?this.state.transform.y+(window.innerHeight/2-n.bottom):n.top>window.innerHeight/2?this.state.transform.y-(n.top-window.innerHeight/2):this.state.transform.y}},onComplete:()=>{this.isThrowing=!1,this.setFinalTransform()},shouldWait:()=>!1}),()=>{}}return requestAnimationFrame(()=>{if(!this.isThrowing)return this.momentumThrow({x:0,y:0});const i=this.element,n=this.state.transform;n.x+=e.x,n.y+=e.y;const o=i.getBoundingClientRect();n.x=n.x+e.x,n.y=n.y+e.y,o.right<window.innerWidth/2&&(n.x+=(window.innerWidth/2-o.right)*.1,e.x*=.7),o.left>window.innerWidth/2&&(n.x-=(o.left-window.innerWidth/2)*.1,e.x*=.7),o.bottom<window.innerHeight/2&&(n.y+=(window.innerHeight/2-o.bottom)*.1,e.y*=.7),o.top>window.innerHeight/2&&(n.y-=(o.top-window.innerHeight/2)*.1,e.y*=.7),this.state.transform=n,this.momentumThrow({x:e.x*.9,y:e.y*.9})}),()=>{x.stop(this),this.isThrowing=!1,this.setFinalTransform()}}animateNormalize(){this.animateNormalizeTimeout&&clearTimeout(this.animateNormalizeTimeout),this.animateNormalizeTimeout=setTimeout(()=>{x.start({vistaImage:this,target:{width:this.fullW,height:this.fullH,translate:{x:0,y:0},transform:{x:0,y:0,scale:1}},onComplete:()=>{this.setFinalTransform()},shouldWait:()=>!1})},50)}setFinalTransform(){if(!this.isReady)return;this.rect=null,super.setFinalTransform({propagateEvent:!1});const e=this.state.width<=this.minW;if(this.state.width>this.maxW)this.animateZoom(this.maxW/this.state.width);else if(!e&&this.state.width<this.fullW)this.animateNormalize();else if(this.pos===0){const i=this.toObject();this.vistaView.options.onContentChange&&this.vistaView.options.onContentChange(i,this.vistaView),this.vistaView.state.extensions.forEach(n=>{n.onContentChange&&n.onContentChange(i,this.vistaView)})}return{close:e,cancel:()=>x.stop(this)}}}class G{constructor(){r(this,"fiolast",{})}fio(t,e,i=50){const o=Date.now()-(this.fiolast[e]??0),a=()=>{this.fiolast[e]=Date.now(),t()};if(!this.fiolast[e]){a();return}o>=i&&a()}}class ${constructor(){r(this,"open",!1);r(this,"settled",!1);r(this,"closing",!1);r(this,"zoomedIn",!1);r(this,"children",{htmls:[],images:[]});r(this,"currentIndex",-1);r(this,"elmLength",0);r(this,"abortController",new AbortController);r(this,"isReducedMotion",!1);r(this,"extensions",new Set)}}function q(s){return s&&!/^0(px|%|r?em|vw|vh|vmin|vmax|cm|mm|in|pt|pc|ex|ch)?$/i.test(s.trim())&&s}function J(s){const t=s instanceof HTMLAnchorElement?s:null,e=s instanceof HTMLImageElement?s:t==null?void 0:t.querySelector("img"),i=t?getComputedStyle(t):null,n=e?getComputedStyle(e):null;let o="0px",a=n?n.objectFit:"contain";return i&&q(i.borderRadius)?o=i.borderRadius:n&&q(n.borderRadius)&&(o=n.borderRadius),{borderRadius:o,objectFit:a}}function Q(s){const t=s.split(",").map(i=>i.trim()),e=[];for(const i of t){const[n,o]=i.split(" ").map(a=>a.trim());if(n&&o&&o.endsWith("w")){const a=parseInt(o.slice(0,-1),10);isNaN(a)||e.push({src:n,width:a})}}return e}function tt(s){const t=s instanceof HTMLImageElement?s:s.querySelector("img"),e=s.dataset.vistaviewSrc||s.getAttribute("href")||s.getAttribute("src")||(t==null?void 0:t.getAttribute("src"))||"",i=s.dataset.vistaviewSrcset||s.getAttribute("srcset")||(t==null?void 0:t.getAttribute("srcset"))||"";if(!e&&!i)throw console.error("VistaView Error:",s),new Error("VistaView: Element must have href, src, or srcSet");const n=i?Q(i):void 0,o=J(s);return{config:{src:e,alt:s.dataset.vistaviewAlt||s.getAttribute("alt")||(t==null?void 0:t.getAttribute("alt"))||"",srcSet:i||void 0},parsedSrcSet:n!=null&&n.length?n:void 0,origin:{anchor:s instanceof HTMLAnchorElement?s:void 0,image:t,src:e,srcSet:i,borderRadius:o.borderRadius,objectFit:o.objectFit}}}class V{constructor({elm:t,listeners:e}){r(this,"pointers",[]);r(this,"elm");r(this,"listeners",[]);r(this,"lastPointerDownId",null);r(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)}});r(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}))});r(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})))});r(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}))});r(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 _{constructor(t){r(this,"pointers",null);r(this,"lastDistance",0);r(this,"pinchMode",!1);r(this,"lastPinchEndTime",0);r(this,"PINCH_COOLDOWN",111);r(this,"cancelMove",()=>{});r(this,"pointerListeners",[]);r(this,"vvw");r(this,"imageContainer",null);r(this,"isPinching",()=>this.pinchMode||performance.now()-this.lastPinchEndTime<this.PINCH_COOLDOWN);r(this,"internalPointerListener",t=>{const e=this.vvw.state.children.images.find(i=>i.pos===0);if(t.event==="down"){if(this.cancelMove(),this.vvw.state.zoomedIn&&t.pointers.length===1&&!this.isPinching()){const i=this.pointers.getCentroid();e.setInitialCenter(i)}if(t.pointers.length>=2){this.pinchMode=!0;const i=this.pointers.getCentroid();this.lastDistance=this.pointers.getPointerDistance(t.pointers[0],t.pointers[1]),e.setInitialCenter(i)}}else if(t.event==="move"){if(this.vvw.state.zoomedIn&&t.pointers.length===1&&t.lastPointerLen===0&&!this.isPinching()){const i=this.pointers.getCentroid();e.scaleMove(1,i)}if(t.pointers.length>=2&&this.pinchMode){const i=this.pointers.getCentroid(),n=this.pointers.getPointerDistance(t.pointers[0],t.pointers[1]);e.scaleMove(n/this.lastDistance,i)}}else if((t.event==="up"||t.event==="cancel")&&(this.pinchMode||this.vvw.state.zoomedIn))if(this.pinchMode){this.lastPinchEndTime=performance.now(),this.pinchMode=!1;const i=e.setFinalTransform();i!=null&&i.cancel&&(this.cancelMove=i.cancel),i!=null&&i.close&&requestAnimationFrame(()=>{this.vvw.close()})}else this.vvw.state.zoomedIn&&t.pointers.length===0&&!this.isPinching()&&(e.isThrowing=!0,this.cancelMove=e.momentumThrow({x:t.pointer.movementX,y:t.pointer.movementY}));this.pointerListeners.forEach(i=>i({...t,state:this.vvw.state,hasInternalExecution:this.vvw.state.zoomedIn||this.isPinching(),abortController:this.vvw.state.abortController}))});r(this,"onKeyDown",t=>{const e=this.vvw;switch(t.key){case"ArrowLeft":t.preventDefault(),e.prev();break;case"ArrowRight":t.preventDefault(),e.next();break;case"ArrowUp":t.preventDefault(),e.zoomIn();break;case"ArrowDown":t.preventDefault(),e.zoomOut();break;case"Escape":t.preventDefault(),e.close();break}});r(this,"onScroll",t=>{t.preventDefault();const e=this.vvw,i=this.vvw.state.children.images.find(o=>o.pos===0),n=t.deltaY;i.setInitialCenter({x:t.clientX,y:t.clientY}),n<0?e.zoomIn():n>0&&e.zoomOut()});r(this,"onResizeHandler",()=>{this.vvw.state.children.images.forEach(t=>{t.setSizes()})});this.vvw=t}registerPointerListener(t){this.pointerListeners.push(t)}start(t){this.vvw.options.keyboardListeners&&window.addEventListener("keydown",this.onKeyDown),this.imageContainer=t,this.imageContainer.addEventListener("wheel",this.onScroll,{passive:!1}),window.addEventListener("resize",this.onResizeHandler),this.pointers=new V({elm:t,listeners:[this.internalPointerListener]})}stop(){this.vvw.options.keyboardListeners&&window.removeEventListener("keydown",this.onKeyDown),window.removeEventListener("resize",this.onResizeHandler),this.imageContainer.removeEventListener("wheel",this.onScroll),this.pointers.removeListeners(),this.pointerListeners=[]}}const C={somethingOpened:null};class A{constructor(t,e={}){r(this,"options");r(this,"state",new $);r(this,"imageContainer",null);r(this,"externalPointerListener",[]);r(this,"elements");r(this,"eventHandlers",null);r(this,"imageSetupFunction",W);r(this,"initFunction",R);r(this,"openFunction",z);r(this,"closeFunction",T);r(this,"transitionFunction",H);r(this,"throttle",new G);r(this,"root",null);r(this,"onClickElements",t=>{t.preventDefault();const e=t.currentTarget;e.dataset.vvwIdx&&this.open(parseInt(e.dataset.vvwIdx))});r(this,"defaultOnClickHandler",t=>t.preventDefault());r(this,"lastSwapTime",0);r(this,"isRapidSwap",!1);r(this,"isRapidSwapRelease",0);r(this,"transitionCleanup",null);r(this,"tempDeactivatedUi",[]);r(this,"tempDeactivationRequestBy",null);r(this,"isZoomedIn",!1);var i;this.elements=t,this.options={...y,...e,controls:{...y.controls,...e.controls}},this.options.imageSetupFunction&&(this.imageSetupFunction=this.options.imageSetupFunction),this.options.closeFunction&&(this.closeFunction=this.options.closeFunction),this.options.initFunction&&(this.initFunction=this.options.initFunction),this.options.transitionFunction&&(this.transitionFunction=this.options.transitionFunction),[...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(n=>{typeof n!="string"&&this.state.extensions.add(n)}),(i=this.options.extensions)==null||i.forEach(n=>{this.state.extensions.add(n)}),this.state.isReducedMotion=window.matchMedia("(prefers-reduced-motion: reduce)").matches,this.reset(),this.initFunction(this)}reset(){if(typeof this.elements=="string"){const t=this.qsOrigin(this.elements);this.state.elmLength=t.length,t.forEach((e,i)=>{const n=e;n.dataset.vvwIdx=i.toString(),n.removeEventListener("click",this.defaultOnClickHandler),n.removeEventListener("pointerup",this.onClickElements),n.addEventListener("click",this.defaultOnClickHandler),n.addEventListener("pointerup",this.onClickElements)})}else this.state.elmLength=this.elements.length}qs(t){return this.root?this.root.querySelector(t):null}qsOrigin(t){return document.querySelectorAll(t)}registerPointerListener(t){this.externalPointerListener.push(t)}getChildElements(t,e){const i=[],n=[],o=typeof this.elements=="string"?this.qsOrigin(this.elements):this.elements;for(let a=-t;a<=t;a++){const l=(e+a+o.length)%o.length,h=o[l],d={elm:h instanceof HTMLElement?tt(h):{config:h,origin:void 0,parsedSrcSet:void 0},pos:a,index:l,vistaView:this,maxZoomLevel:this.options.maxZoomLevel,transitionShouldWait:()=>this.isRapidSwap,onScale:({vistaImage:g,isMin:m,isMax:w})=>{var b,E,S,L;g.index===this.state.currentIndex&&(this.state.zoomedIn=!m,m?(b=this.qs(".vvw-zoom-out"))==null||b.setAttribute("disabled","true"):(E=this.qs(".vvw-zoom-out"))==null||E.removeAttribute("disabled"),w?(S=this.qs(".vvw-zoom-in"))==null||S.setAttribute("disabled","true"):(L=this.qs(".vvw-zoom-in"))==null||L.removeAttribute("disabled"))}};let u=null;this.state.extensions.forEach(g=>{!u&&g.onInitializeImage&&(u=g.onInitializeImage(d))});const v=u??new O(d),p=document.createElement("div");p.className="vvw-item",p.dataset.vvwPos=`${a}`,p.dataset.vvwIdx=`${l}`,v.thumb&&p.appendChild(v.thumb),p.appendChild(v.element),i.push(v),n.push(p)}return{htmls:n,images:i}}async swap(t,e){var p,g;this.reactivateUi();const i=this.options.preloads||0,n=this.state.currentIndex,{htmls:o,images:a}=this.getChildElements(i,n),l=this.imageContainer,h=this.state.children,f={htmlElements:{from:h.htmls,to:o},images:{from:h.images,to:a},index:{from:t,to:this.state.currentIndex},via:e||{next:!1,prev:!1},vistaView:this};this.imageSetupFunction(f),this.state.zoomedIn=!1,(p=this.qs(".vvw-zoom-out"))==null||p.setAttribute("disabled","true"),(g=this.qs(".vvw-zoom-in"))==null||g.removeAttribute("disabled");const u=performance.now()-this.lastSwapTime<this.options.rapidLimit;this.isRapidSwap=u;const{images:v}=this.state.children;if(this.state.children={htmls:o,images:a},this.displayCurrentInfo(),u)v.forEach(m=>{m.cancelPendingLoad(),m.destroy()});else{const m=this.state.abortController.signal,w=this.transitionFunction(f,m);w&&(this.transitionCleanup=w.cleanup,await w.transitionEnded),this.lastSwapTime=performance.now(),v.forEach(L=>{L.cancelPendingLoad()});const b=v.find(L=>L.index===n),E=b?x.stop(b):void 0,S=a.find(L=>L.index===n);S&&b&&S.cloneStyleFrom(b,E),v.forEach(L=>{L.destroy()})}l.innerHTML="",this.transitionCleanup&&this.transitionCleanup(),o.forEach(m=>{l.appendChild(m)}),a.forEach(m=>{m.init()}),u?(this.isRapidSwapRelease&&clearTimeout(this.isRapidSwapRelease),this.isRapidSwapRelease=setTimeout(()=>{this.isRapidSwap=!1},333)):this.isRapidSwap=!1,this.options.onImageView&&this.options.onImageView(f,this),this.state.extensions.forEach(m=>{m.onImageView&&m.onImageView(f,this)})}displayCurrentInfo(){const t=this.state.currentIndex;typeof this.elements=="string"&&this.qsOrigin(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.state.elmLength}`;e&&(e.textContent=`${i} / ${n}`);const o=this.qs(".vvw-desc");if(o){const a=this.state.children.images.find(h=>h.index===t),l=(a==null?void 0:a.config.alt)||"";l?(o.textContent=l,o.setAttribute("aria-label",`Image ${i} of ${n}: ${l}`),o.style.opacity=""):(o.textContent="",o.setAttribute("aria-label",`Image ${i} of ${n}`),o.style.opacity="0")}}deactivateUi(t,e){t.forEach(i=>{var n,o;i==="zoomIn"?(n=this.qs(".vvw-zoom-in"))==null||n.setAttribute("disabled","true"):i==="zoomOut"&&((o=this.qs(".vvw-zoom-out"))==null||o.setAttribute("disabled","true")),this.tempDeactivatedUi.push(i)}),this.tempDeactivationRequestBy=e||null,this.state.extensions.forEach(i=>{i.onDeactivateUi&&i.onDeactivateUi(t,this.tempDeactivationRequestBy,this)})}reactivateUi(){this.tempDeactivatedUi.forEach(t=>{var e,i;t==="zoomIn"?(e=this.qs(".vvw-zoom-in"))==null||e.removeAttribute("disabled"):t==="zoomOut"&&((i=this.qs(".vvw-zoom-out"))==null||i.removeAttribute("disabled"))}),this.state.extensions.forEach(t=>{t.onReactivateUi&&t.onReactivateUi(this.tempDeactivatedUi,this.tempDeactivationRequestBy,this)}),this.tempDeactivatedUi=[],this.tempDeactivationRequestBy=null}open(t=0){var h,f,d,u,v,p,g;if(C.somethingOpened){console.warn("Another VistaView instance is already opened. Close it first before opening a new one.");return}C.somethingOpened=this,this.reset(),(t<0||t>=this.state.elmLength)&&(t=(t%this.state.elmLength+this.state.elmLength)%this.state.elmLength),this.state.currentIndex=t,document.body.style.overflow="hidden";const e=U({controls:this.options.controls});if(document.body.append(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:a}=this.getChildElements(i,n),l={htmlElements:{from:null,to:a},images:{from:null,to:o},index:{from:null,to:this.state.currentIndex},via:{next:!1,prev:!1},vistaView:this};this.imageSetupFunction(l),this.state.children={htmls:a,images:o},a.forEach(m=>{this.imageContainer.appendChild(m)}),o.forEach(m=>{m.init()}),(h=this.qs(".vvw-close"))==null||h.addEventListener("click",()=>this.close()),(f=this.qs(".vvw-zoom-in"))==null||f.addEventListener("click",()=>this.zoomIn()),(d=this.qs(".vvw-zoom-out"))==null||d.addEventListener("click",()=>this.zoomOut()),(u=this.qs(".vvw-prev>button"))==null||u.addEventListener("click",()=>this.prev()),(v=this.qs(".vvw-next>button"))==null||v.addEventListener("click",()=>this.next()),this.state.elmLength<2&&((p=this.qs(".vvw-prev"))==null||p.classList.add("vvw--hidden"),(g=this.qs(".vvw-next"))==null||g.classList.add("vvw--hidden")),this.openFunction(this),this.eventHandlers=new _(this),this.externalPointerListener.forEach(m=>{this.eventHandlers.registerPointerListener(m)}),this.eventHandlers.start(this.imageContainer),requestAnimationFrame(()=>{requestAnimationFrame(()=>{var m;(m=this.root)==null||m.addEventListener("transitionend",()=>{var w;(w=this.root)==null||w.classList.add("vvw--settled")},{once:!0}),this.root.classList.add("vvw--active"),this.displayCurrentInfo(),this.options.onOpen&&this.options.onOpen(this),this.options.onImageView&&this.options.onImageView(l,this),this.state.extensions.forEach(w=>{w.onOpen&&w.onOpen(this),w.onImageView&&w.onImageView(l,this)})})})}async close(t=!0){C.somethingOpened===this&&this.root&&(this.eventHandlers.stop(),this.eventHandlers=null,this.state.children.images.forEach(e=>{e.prepareClose()}),t?await new Promise(e=>{let n=0;this.root.addEventListener("transitionend",o=>{o.target===this.root&&(n++,n===2&&typeof this.elements=="string"&&(this.state.children.images.forEach(a=>{a.destroy()}),this.qsOrigin(this.elements).forEach(a=>{a.style.opacity=""})),n===3&&e(null))}),this.root.classList.add("vvw--closing")}):typeof this.elements=="string"&&(this.state.children.images.forEach(e=>{e.destroy()}),this.qsOrigin(this.elements).forEach(e=>{e.style.opacity=""})),this.root.remove(),this.root=null,this.imageContainer=null,this.state.children={htmls:[],images:[]},this.state.currentIndex=-1,this.state.children.images.forEach(e=>{e.destroy()}),document.body.style.overflow="",C.somethingOpened=null,this.closeFunction(this),this.options.onClose&&this.options.onClose(this),this.state.extensions.forEach(e=>{e.onClose&&e.onClose(this)}))}destroy(){this.close(!1),this.externalPointerListener=[],typeof this.elements=="string"&&this.qsOrigin(this.elements).forEach(t=>{t.removeAttribute("data-vista-idx"),t.removeEventListener("click",this.defaultOnClickHandler),t.removeEventListener("pointerup",this.onClickElements)})}next(){if(C.somethingOpened!==this){console.warn("This VistaView instance is not opened.");return}const t=(this.state.currentIndex+1)%this.state.elmLength;this.view(t,{next:!0,prev:!1})}prev(){if(C.somethingOpened!==this){console.warn("This VistaView instance is not opened.");return}const t=(this.state.currentIndex-1+this.state.elmLength)%this.state.elmLength;this.view(t,{next:!1,prev:!0})}view(t,e){if(C.somethingOpened!==this){console.warn("This VistaView instance is not opened.");return}if(this.state.elmLength<2)return;(t<0||t>=this.state.elmLength)&&(t=(t%this.state.elmLength+this.state.elmLength)%this.state.elmLength);const i=this.state.currentIndex;this.state.currentIndex=t;const n=this.state.abortController;n==null||n.abort(),this.state.abortController=new AbortController,this.swap(i,e)}zoomIn(){if(C.somethingOpened!==this){console.warn("This VistaView instance is not opened.");return}this.throttle.fio(()=>{const t=this.state.children.images.find(e=>e.pos===0);t==null||t.animateZoom(1.68)},"zoom",222)}zoomOut(){if(C.somethingOpened!==this){console.warn("This VistaView instance is not opened.");return}this.throttle.fio(()=>{const t=this.state.children.images.find(e=>e.pos===0);t==null||t.animateZoom(.68)},"zoom",222)}getCurrentIndex(){return this.state.currentIndex}}function et(s){let t=null;if(typeof s=="string"){if(t=document.querySelectorAll(s),t.length===0)return new Error("No elements found in node list.").toString();for(let e=0;e<t.length;e++){const i=t[e],n=i.tagName.toLowerCase();if(n!=="img"&&n!=="a")return new Error(`Invalid element at index ${e}: expected <img>, <a>, got <${n}>`);if(n==="a"&&!(i.querySelector("img")!==null))return new Error(`Invalid <a> element at index ${e}: must contain <img>`)}}else{const e=s;for(let i=0;i<e.length;i++)if(!e[i].src)return new Error(`Invalid image data at index ${i}: must have 'src'`)}return s}function it({elements:s,...t}){if(!s)return console.error(s),console.error("no elements provided"),console.warn("VistaView: silently returning."),null;let e=et(s);if(e instanceof Error)return console.error(e),console.warn("VistaView: silently returning."),null;const i=new A(e,t);return{open:(n=0)=>i.open(n),reset:()=>i.reset(),close:()=>i.close(),next:()=>i.next(),prev:()=>i.prev(),zoomIn:()=>i.zoomIn(),zoomOut:()=>i.zoomOut(),destroy:()=>i.destroy(),getCurrentIndex:()=>i.getCurrentIndex(),view:n=>{i.view(n)}}}c.DefaultOptions=y,c.VistaBox=F,c.VistaHiresTransition=x,c.VistaImage=O,c.VistaImageEvent=_,c.VistaPointers=V,c.VistaState=$,c.VistaView=A,c.close=T,c.imageSetup=W,c.init=R,c.open=z,c.transition=H,c.vistaView=it,Object.defineProperty(c,Symbol.toStringTag,{value:"Module"})}));
18
+ </div>`);return[...(s==null?void 0:s.topLeft)||[],...(s==null?void 0:s.topCenter)||[],...(s==null?void 0:s.topRight)||[],...(s==null?void 0:s.bottomLeft)||[],...(s==null?void 0:s.bottomCenter)||[],...(s==null?void 0:s.bottomRight)||[]].forEach(i=>{if(typeof i!="string"&&i.control){const n=e.querySelector(`[data-vvw-control="${i.name}"]`),o=i.control();n&&o&&n.appendChild(o)}}),e}function z(s){}function W(s){K(s)}function K(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 a=e.x-t.x,l=e.y-t.y;if(!i&&Math.abs(l)>Math.abs(a)||i==="y"){const h=l/window.innerHeight*100;s.imageContainer.style.transition="none",s.imageContainer.style.transform=`translateY(${h}vh)`,i="y"}else if(!i&&Math.abs(a)>Math.abs(l)||i==="x"&&n.state.elmLength>1){const h=a/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 a=function(l){var h;(h=s.imageContainer)==null||h.addEventListener("transitionend",function f(){var d;(d=s.imageContainer)==null||d.removeEventListener("transitionend",f),s.imageContainer.style.transition="",s.imageContainer.style.transform=""}),s.imageContainer.style.transition="transform 222ms ease",s.imageContainer.style.transform=l};if(i==="y"){const l=e.y-t.y;Math.abs(l)>144?(s.imageContainer.style.transition="transform 222ms ease",s.imageContainer.style.transform="translateY(0vh)",s.close()):a("translateY(0vh)")}if(i==="x"&&n.state.elmLength>1){const l=e.x-t.x;s.imageContainer.style.transition="",l>64?s.prev():l<-64?s.next():a("translateX(0vw)")}i=null,t={x:0,y:0},e={x:0,y:0}}}})}function R(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"}function T(s){}function H({vistaView:s,htmlElements:{to:t},index:{from:e,to:i}},n){const{imageContainer:o,options:a}=s,{isReducedMotion:l}=s.state;if(!(!t||n.aborted||l||!(Math.abs(i-e)===1||e===0&&i===s.state.elmLength-1||e===s.state.elmLength-1&&i===0)))return{cleanup:()=>{o.style.transition="",o.style.transform=""},transitionEnded:new Promise(f=>{o.addEventListener("transitionend",()=>{f()},{once:!0}),o.addEventListener("transitioncancel",()=>{n.aborted&&f()},{once:!0});const d=Math.round(a.animationDurationBase*100)/100,u=i===e+1||e===s.state.elmLength-1&&i===0?"translateX(-100vw)":"translateX(100vw)";o.style.transition=`transform ${d}ms ease`,o.style.transform=u})}}function D(s){const t=window.innerWidth,e=window.innerHeight,i=s.naturalWidth,n=s.naturalHeight;if(!i||!n)throw console.error("Error",s),new Error("Image natural dimensions are zero");if(i<t&&n<e)return{width:i,height:n};const o=i/n,a=t/e;let l,h;return o>a?(l=t,h=t/o):(h=e,l=e*o),{width:l,height:h}}class x{static ease(t,e,i){const n=e-t,o=t+n*.2;return Math.abs(n)<i?e:o}static play(t,e,i){if(i()){requestAnimationFrame(()=>{this.play(t,e,i)});return}this.map.get(t)&&(t.element.classList.contains("vvw--load-cancelled")||requestAnimationFrame(()=>{var d,u,v,p,g,m,w,b,E,S;const n=this.map.get(t);if(!n||!t.element||t.element.classList.contains("vvw--load-cancelled"))return;const{current:o,target:a,log:l}=n;let h={};a.width!==void 0&&(h.width=this.ease(o._width,a.width,1)),a.height!==void 0&&(h.height=this.ease(o._height,a.height,1)),((d=a.transform)==null?void 0:d.x)!==void 0&&(h.transform=h.transform||{},h.transform.x=this.ease(o._transform.x,a.transform.x,1)),((u=a.transform)==null?void 0:u.y)!==void 0&&(h.transform=h.transform||{},h.transform.y=this.ease(o._transform.y,a.transform.y,1)),((v=a.transform)==null?void 0:v.scale)!==void 0&&(h.transform=h.transform||{},h.transform.scale=this.ease(o._transform.scale,a.transform.scale,.005)),((p=a.translate)==null?void 0:p.x)!==void 0&&(h.translate=h.translate||{},h.translate.x=this.ease(o._translate.x,a.translate.x,1)),((g=a.translate)==null?void 0:g.y)!==void 0&&(h.translate=h.translate||{},h.translate.y=this.ease(o._translate.y,a.translate.y,1)),h.width!==void 0&&(o.width=h.width),h.height!==void 0&&(o.height=h.height),h.translate&&(o.translate={...o.translate,...h.translate}),h.transform&&(o.transform={...o.transform,...h.transform}),(a.width===void 0||o._width===a.width)&&(a.height===void 0||o._height===a.height)&&(((m=a.transform)==null?void 0:m.x)===void 0||o._transform.x===a.transform.x)&&(((w=a.transform)==null?void 0:w.y)===void 0||o._transform.y===a.transform.y)&&(((b=a.transform)==null?void 0:b.scale)===void 0||o._transform.scale===a.transform.scale)&&(((E=a.translate)==null?void 0:E.x)===void 0||o._translate.x===a.translate.x)&&(((S=a.translate)==null?void 0:S.y)===void 0||o._translate.y===a.translate.y)?(this.map.delete(t),e()):(this.map.set(t,{current:o,target:a,log:l}),this.play(t,e,i))}))}static stop(t){const e=this.map.get(t);return this.map.delete(t),e}static start({vistaImage:t,target:e,onComplete:i,shouldWait:n}){this.stop(t),this.map.set(t,{current:t.state,target:e}),this.play(t,i,n)}}r(x,"map",new Map);function M(s){const e=window.getComputedStyle(s).objectFit||"",{width:i,height:n}=s.getBoundingClientRect(),o=s.naturalWidth,a=s.naturalHeight;if(!e)return{width:i,height:n};if(!o||!a)return{width:i,height:n};const l=o/a,h=i/n;switch(e){case"fill":return{width:i,height:n};case"none":return{width:o,height:a};case"contain":return l>h?{width:i,height:i/l}:{width:n*l,height:n};case"cover":return l<h?{width:i,height:i/l}:{width:n*l,height:n};case"scale-down":{const f={width:o,height:a},d=l>h?{width:i,height:i/l}:{width:n*l,height:n};return d.width<=f.width&&d.height<=f.height?d:f}}return{width:i,height:n}}class F{constructor(t){r(this,"state");r(this,"parsedSrcSet");r(this,"isReady",!1);r(this,"isThrowing",!1);r(this,"thumb",null);r(this,"pos");r(this,"index");r(this,"config");r(this,"origin");r(this,"initH",0);r(this,"initW",0);r(this,"fullH",0);r(this,"fullW",0);r(this,"maxW",0);r(this,"minW",0);r(this,"defaultWH",200);r(this,"isZoomedIn",!1);r(this,"isCancelled",!1);r(this,"isLoadedResolved",null);r(this,"isLoadedRejected",null);r(this,"isLoaded",new Promise((t,e)=>{this.isLoadedResolved=t,this.isLoadedRejected=e}));r(this,"replacement",null);r(this,"originalParent",null);r(this,"originalNextSibling",null);r(this,"originalStyle","");r(this,"thumbImage",null);r(this,"fittedSize",null);r(this,"maxZoomLevel");r(this,"vistaView");r(this,"transitionState",null);r(this,"transitionShouldWait",()=>!1);r(this,"initPointerCenter",{x:0,y:0});r(this,"onScale");var i;this.state=this.createState(),this.pos=t.pos,this.index=t.index,this.config=t.elm.config,this.parsedSrcSet=t.elm.parsedSrcSet,this.origin=t.elm.origin,this.maxZoomLevel=t.maxZoomLevel,this.vistaView=t.vistaView,this.onScale=t.onScale,t.transitionState&&(this.transitionState=t.transitionState),t.transitionShouldWait&&(this.transitionShouldWait=t.transitionShouldWait),this.initPointerCenter={x:window.innerWidth/2,y:window.innerHeight/2};const e=this.pos===0?(i=this.origin)==null?void 0:i.image:null;if(this.originalParent=(e==null?void 0:e.parentElement)||null,this.originalNextSibling=(e==null?void 0:e.nextSibling)||null,e&&this.originalParent){this.originalStyle=e.style.cssText,this.thumbImage=e;const n=e.cloneNode(!0);this.originalParent.insertBefore(n,e),this.replacement=n,this.thumb=document.createElement("div"),this.thumb.classList.add("vvw-img-lo");const{width:o,height:a}=this.thumbImage?M(this.thumbImage):{width:0,height:0};this.fittedSize={width:o,height:a},this.thumb.appendChild(e),e.style.width="100%",e.style.height="100%",e.style.objectFit=this.origin.objectFit}}createState(){const t=this;return{_t:this,_width:0,_height:0,_transform:{x:0,y:0,scale:1},_translate:{x:0,y:0},_lessThanMinWidth:!1,get width(){return this._width},set width(e){this._width=e,t.onWidthChange(e)},get height(){return this._height},set height(e){this._height=e,t.onHeightChange(e)},get transform(){return this._transform},set transform(e){this._transform=e,t.onTransformChange(e)},get translate(){return this._translate},set translate(e){this._translate=e,t.onTranslateChange(e)},get lessThanMinWidth(){return this._lessThanMinWidth},set lessThanMinWidth(e){this._lessThanMinWidth=e,t.onLessThanMinWidthChange(e)}}}onLessThanMinWidthChange(t){t?this.element.style.opacity="0.5":this.element.style.opacity=""}onTranslateChange(t){this.element.style.translate=`calc(-50% + ${t.x}px) calc(-50% + ${t.y}px)`}onTransformChange(t){const e=`translate3d(${t.x}px, ${t.y}px, 0px) scale3d(${t.scale}, ${t.scale}, 1)`;this.element.style.transform=e}onWidthChange(t){this.element.style.width=`${t}px`}onHeightChange(t){this.element.style.height=`${t}px`}onImageReady(){}animateZoom(t,e){}scaleMove(t,e,i){}momentumThrow(t){return()=>{}}async init(){await this.isLoaded;const t=this.element;this.transitionState&&this.transitionState.current.width&&this.transitionState.current.height?(this.state.width=this.transitionState.current.width,this.state.height=this.transitionState.current.height):t.classList.contains("vvw--loaded")||(this.state.width=this.initW,this.state.height=this.initH);const e=()=>{this.isCancelled||x.start({vistaImage:this,target:{width:this.fullW,height:this.fullH},onComplete:()=>{this.isCancelled||(this.isReady=!0,t.classList.add("vvw--ready"),this.onImageReady())},shouldWait:this.transitionShouldWait})};this.pos<-1||this.pos>1?(this.state.width=this.fullW,this.state.height=this.fullH,t.classList.add("vvw--loaded"),t.classList.add("vvw--ready"),this.isReady=!0):t.classList.contains("vvw--loaded")?t.classList.contains("vvw--ready")?(this.isReady=!0,this.onImageReady()):e():(t.classList.add("vvw--loaded"),setTimeout(()=>{this.isCancelled||e()},333))}getFullSizeDim(){const{width:t,height:e}=this.thumb.getBoundingClientRect(),i=t/e;let n=window.innerWidth,o=window.innerHeight;return i>window.innerWidth/window.innerHeight?o=n/i:n=o*i,{width:n,height:o}}setSizes(t={}){var l,h,f;const{stableSize:e=!0,initDimension:i}=t;if(!this.origin)return;const n=this.thumb;let o={width:this.defaultWH,height:this.defaultWH,top:0,left:0};if(n){o=(((l=this.origin)==null?void 0:l.anchor)||this.replacement).getBoundingClientRect();const d=n.style;d.width=o.width+"px",d.height=o.height+"px",d.top="50%",d.left="50%",d.translate="-50% -50%",d.position="fixed",d.objectFit=this.origin.objectFit,d.borderRadius=this.origin.borderRadius;const u=Math.min(Math.max(o.left,-o.width),window.innerWidth+o.width)-window.innerWidth/2+o.width/2,v=Math.min(Math.max(o.top,-o.height),window.innerHeight+o.height)-window.innerHeight/2+o.height/2;d.setProperty("--vvw-init-radius",d.borderRadius),d.setProperty("--vvw-pulse-radius",`calc(1.3 * ${d.borderRadius})`),d.setProperty("--vvw-init-x",`${u}px`),d.setProperty("--vvw-init-y",`${v}px`),i&&(d.setProperty("--vvw-current-x",`${u}px`),d.setProperty("--vvw-current-y",`${v}px`))}if(!i){const{width:d,height:u}=this.thumbImage?M(this.thumbImage):{width:0,height:0};this.fittedSize={width:d,height:u}}const a=this.element;if(this.initW=Math.min(((h=this.fittedSize)==null?void 0:h.width)??0,o.width),this.initH=Math.min(((f=this.fittedSize)==null?void 0:f.height)??0,o.height),a.style.setProperty("--vvw-init-w",this.initW+"px"),a.style.setProperty("--vvw-init-h",this.initH+"px"),a.style.setProperty("--vvw-init-radius",this.origin.borderRadius),a.style.objectFit="cover",!i){if(this.isReady&&!this.isCancelled){const{width:d,height:u}=this.getFullSizeDim();this.fullH=u,this.fullW=d,this.minW=this.fullW*.5}!this.isZoomedIn&&e&&this.normalize()}}normalize(){this.state.transform={x:0,y:0,scale:1},this.state.translate={x:0,y:0},this.state.width=this.fullW,this.state.height=this.fullH,this.isZoomedIn=!1}getFromParsedSrcSet(t){if(!this.parsedSrcSet||this.parsedSrcSet.length===0)return null;const e=t*(window.devicePixelRatio||1);let i=this.parsedSrcSet[this.parsedSrcSet.length-1];for(const n of this.parsedSrcSet)if(n.width>=e){i=n;break}return i.src}prepareClose(){x.stop(this),this.setFinalTransform()}cancelPendingLoad(){var t;this.isCancelled=!0,(t=this.element)==null||t.classList.add("vvw--load-cancelled")}setInitialCenter(t){this.initPointerCenter=t}destroy(){var t,e;this.originalParent&&this.thumbImage&&(this.thumbImage.style.cssText=this.originalStyle,this.originalNextSibling?this.originalParent.insertBefore(this.thumbImage,this.originalNextSibling):this.originalParent.appendChild(this.thumbImage)),this.originalParent=null,this.originalNextSibling=null,this.originalStyle="",this.thumbImage=null,this.replacement&&(this.replacement.remove(),this.replacement=null),(t=this.thumb)==null||t.remove(),(e=this.element)==null||e.remove(),this.thumb=null,this.origin=void 0,this.config={src:"",alt:""}}cloneStyleFrom(t,e){t!=null&&t.element&&(e&&(this.transitionState=e||null),t.element.classList.contains("vvw--loaded")&&(this.element.classList.add("vvw--loaded"),this.state.width=t.state.width,this.state.height=t.state.height),t.element.classList.contains("vvw--ready")&&this.element.classList.add("vvw--ready"))}toObject(){return structuredClone({config:{src:this.config.src,alt:this.config.alt,srcSet:this.config.srcSet},origin:this.origin?{src:this.origin.src,srcSet:this.origin.srcSet,borderRadius:this.origin.borderRadius,objectFit:this.origin.objectFit}:null,parsedSrcSet:this.parsedSrcSet,element:"src"in this.element?this.element.src:this.element.toString(),thumb:void 0,index:this.index,pos:this.pos,state:{width:this.state._width,height:this.state._height,transform:this.state._transform,translate:this.state._translate}})}setFinalTransform(t={}){const{propagateEvent:e=!0}=t;if(this.isReady){if(this.state.translate.x+=this.state.transform.x,this.state.translate.y+=this.state.transform.y,this.state.width*=this.state.transform.scale,this.state.height*=this.state.transform.scale,Math.abs(this.state.width-this.fullW)<1&&(this.state.width=this.fullW,this.state.height=this.fullH),Math.abs(this.state.translate.x)<1&&(this.state.translate.x=0),Math.abs(this.state.translate.y)<1&&(this.state.translate.y=0),this.state.translate={...this.state.translate},this.state.transform={x:0,y:0,scale:1},e){const i=this.toObject();this.vistaView.options.onContentChange&&this.vistaView.options.onContentChange(i,this.vistaView),this.vistaView.state.extensions.forEach(n=>{n.onContentChange&&n.onContentChange(i,this.vistaView)})}return{close:!0,cancel:()=>{}}}}}class O extends F{constructor(e){super(e);r(this,"element");r(this,"rect",null);r(this,"animateNormalizeTimeout",null);const i=document.createElement("img");i.alt=this.config.alt||"",i.classList.add("vvw-img-hi"),this.element=i,i.onerror=n=>{this.isLoadedRejected(n)},i.src=this.config.src,i.decode().then(()=>{this.onLoad()}).catch(n=>{this.isLoadedRejected(n)}),this.setSizes({stableSize:!1,initDimension:!0})}onWidthChange(e){super.onWidthChange(e);const i=this.getFromParsedSrcSet(e);if(i&&this.element.src!==i){const n=new Image;n.onload=()=>{n.decode().then(()=>{this.isCancelled||(this.element.src=i)})},n.src=i}}onLoad(){if(this.isCancelled)return;const e=this.element;e.width=e.naturalWidth,e.height=e.naturalHeight,this.maxW=e.naturalWidth*this.maxZoomLevel;const{width:i,height:n}=D(e);this.fullH=n,this.fullW=i,this.minW=this.fullW*.5,this.isLoadedResolved(!0)}getFullSizeDim(){return D(this.element)}normalize(){super.normalize();const e=this.element;e.style.objectFit="cover",e.style.borderRadius="0"}scaleMove(e,i,n=!1){if(!this.isReady||!this.element)return;this.rect||(this.rect=this.element.getBoundingClientRect()),i||(i=this.initPointerCenter);const o=this.rect.left+this.rect.width/2,a=this.rect.top+this.rect.height/2,l=this.initPointerCenter.x-o,h=this.initPointerCenter.y-a,f=l*(1-e),d=h*(1-e),u=i.x-this.initPointerCenter.x,v=i.y-this.initPointerCenter.y;n?x.start({vistaImage:this,target:{transform:{x:f+u,y:d+v,scale:e}},onComplete:()=>{this.setFinalTransform()},shouldWait:()=>!1}):this.state.transform={x:f+u,y:d+v,scale:e};const g=this.element.getBoundingClientRect().width*e;this.isZoomedIn=g>this.fullW,this.state.lessThanMinWidth=g<=this.minW,this.onScale({vistaImage:this,scale:g/this.fullW,isMax:g>=this.maxW,isMin:g<=this.fullW})}animateZoom(e,i){this.state.width*e<this.minW||this.scaleMove(e,i,!0)}momentumThrow(e){if(!this.isReady)return()=>{};if(!this.isThrowing)return this.setFinalTransform(),()=>{};if(Math.abs(e.x)<.1&&Math.abs(e.y)<.1){const n=this.element.getBoundingClientRect();return x.start({vistaImage:this,target:{transform:{x:n.right<window.innerWidth/2?this.state.transform.x+(window.innerWidth/2-n.right):n.left>window.innerWidth/2?this.state.transform.x-(n.left-window.innerWidth/2):this.state.transform.x,y:n.bottom<window.innerHeight/2?this.state.transform.y+(window.innerHeight/2-n.bottom):n.top>window.innerHeight/2?this.state.transform.y-(n.top-window.innerHeight/2):this.state.transform.y}},onComplete:()=>{this.isThrowing=!1,this.setFinalTransform()},shouldWait:()=>!1}),()=>{}}return requestAnimationFrame(()=>{if(!this.isThrowing)return this.momentumThrow({x:0,y:0});const i=this.element,n=this.state.transform;n.x+=e.x,n.y+=e.y;const o=i.getBoundingClientRect();n.x=n.x+e.x,n.y=n.y+e.y,o.right<window.innerWidth/2&&(n.x+=(window.innerWidth/2-o.right)*.1,e.x*=.7),o.left>window.innerWidth/2&&(n.x-=(o.left-window.innerWidth/2)*.1,e.x*=.7),o.bottom<window.innerHeight/2&&(n.y+=(window.innerHeight/2-o.bottom)*.1,e.y*=.7),o.top>window.innerHeight/2&&(n.y-=(o.top-window.innerHeight/2)*.1,e.y*=.7),this.state.transform=n,this.momentumThrow({x:e.x*.9,y:e.y*.9})}),()=>{x.stop(this),this.isThrowing=!1,this.setFinalTransform()}}animateNormalize(){this.animateNormalizeTimeout&&clearTimeout(this.animateNormalizeTimeout),this.animateNormalizeTimeout=setTimeout(()=>{x.start({vistaImage:this,target:{width:this.fullW,height:this.fullH,translate:{x:0,y:0},transform:{x:0,y:0,scale:1}},onComplete:()=>{this.setFinalTransform()},shouldWait:()=>!1})},50)}setFinalTransform(){if(!this.isReady)return;this.rect=null,super.setFinalTransform({propagateEvent:!1});const e=this.state.width<=this.minW;if(this.state.width>this.maxW)this.animateZoom(this.maxW/this.state.width);else if(!e&&this.state.width<this.fullW)this.animateNormalize();else if(this.pos===0){const i=this.toObject();this.vistaView.options.onContentChange&&this.vistaView.options.onContentChange(i,this.vistaView),this.vistaView.state.extensions.forEach(n=>{n.onContentChange&&n.onContentChange(i,this.vistaView)})}return{close:e,cancel:()=>x.stop(this)}}}class G{constructor(){r(this,"fiolast",{})}fio(t,e,i=50){const o=Date.now()-(this.fiolast[e]??0),a=()=>{this.fiolast[e]=Date.now(),t()};if(!this.fiolast[e]){a();return}o>=i&&a()}}class ${constructor(){r(this,"open",!1);r(this,"settled",!1);r(this,"closing",!1);r(this,"zoomedIn",!1);r(this,"children",{htmls:[],images:[]});r(this,"currentIndex",-1);r(this,"elmLength",0);r(this,"abortController",new AbortController);r(this,"isReducedMotion",!1);r(this,"extensions",new Set)}}function q(s){return s&&!/^0(px|%|r?em|vw|vh|vmin|vmax|cm|mm|in|pt|pc|ex|ch)?$/i.test(s.trim())&&s}function J(s){const t=s instanceof HTMLAnchorElement?s:null,e=s instanceof HTMLImageElement?s:t==null?void 0:t.querySelector("img"),i=t?getComputedStyle(t):null,n=e?getComputedStyle(e):null;let o="0px",a=n?n.objectFit:"contain";return i&&q(i.borderRadius)?o=i.borderRadius:n&&q(n.borderRadius)&&(o=n.borderRadius),{borderRadius:o,objectFit:a}}function Q(s){const t=s.split(",").map(i=>i.trim()),e=[];for(const i of t){const[n,o]=i.split(" ").map(a=>a.trim());if(n&&o&&o.endsWith("w")){const a=parseInt(o.slice(0,-1),10);isNaN(a)||e.push({src:n,width:a})}}return e}function tt(s){const t=s instanceof HTMLImageElement?s:s.querySelector("img"),e=s.dataset.vistaviewSrc||s.getAttribute("href")||s.getAttribute("src")||(t==null?void 0:t.getAttribute("src"))||"",i=s.dataset.vistaviewSrcset||s.getAttribute("srcset")||(t==null?void 0:t.getAttribute("srcset"))||"";if(!e&&!i)throw console.error("VistaView Error:",s),new Error("VistaView: Element must have href, src, or srcSet");const n=i?Q(i):void 0,o=J(s);return{config:{src:e,alt:s.dataset.vistaviewAlt||s.getAttribute("alt")||(t==null?void 0:t.getAttribute("alt"))||"",srcSet:i||void 0},parsedSrcSet:n!=null&&n.length?n:void 0,origin:{anchor:s instanceof HTMLAnchorElement?s:void 0,image:t,src:e,srcSet:i,borderRadius:o.borderRadius,objectFit:o.objectFit}}}class V{constructor({elm:t,listeners:e}){r(this,"pointers",[]);r(this,"elm");r(this,"listeners",[]);r(this,"lastPointerDownId",null);r(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)}});r(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}))});r(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})))});r(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}))});r(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 _{constructor(t){r(this,"pointers",null);r(this,"lastDistance",0);r(this,"pinchMode",!1);r(this,"lastPinchEndTime",0);r(this,"PINCH_COOLDOWN",111);r(this,"cancelMove",()=>{});r(this,"pointerListeners",[]);r(this,"vvw");r(this,"imageContainer",null);r(this,"isPinching",()=>this.pinchMode||performance.now()-this.lastPinchEndTime<this.PINCH_COOLDOWN);r(this,"internalPointerListener",t=>{const e=this.vvw.state.children.images.find(i=>i.pos===0);if(t.event==="down"){if(this.cancelMove(),this.vvw.state.zoomedIn&&t.pointers.length===1&&!this.isPinching()){const i=this.pointers.getCentroid();e.setInitialCenter(i)}if(t.pointers.length>=2){this.pinchMode=!0;const i=this.pointers.getCentroid();this.lastDistance=this.pointers.getPointerDistance(t.pointers[0],t.pointers[1]),e.setInitialCenter(i)}}else if(t.event==="move"){if(this.vvw.state.zoomedIn&&t.pointers.length===1&&t.lastPointerLen===0&&!this.isPinching()){const i=this.pointers.getCentroid();e.scaleMove(1,i)}if(t.pointers.length>=2&&this.pinchMode){const i=this.pointers.getCentroid(),n=this.pointers.getPointerDistance(t.pointers[0],t.pointers[1]);e.scaleMove(n/this.lastDistance,i)}}else if((t.event==="up"||t.event==="cancel")&&(this.pinchMode||this.vvw.state.zoomedIn))if(this.pinchMode){this.lastPinchEndTime=performance.now(),this.pinchMode=!1;const i=e.setFinalTransform();i!=null&&i.cancel&&(this.cancelMove=i.cancel),i!=null&&i.close&&requestAnimationFrame(()=>{this.vvw.close()})}else this.vvw.state.zoomedIn&&t.pointers.length===0&&!this.isPinching()&&(e.isThrowing=!0,this.cancelMove=e.momentumThrow({x:t.pointer.movementX,y:t.pointer.movementY}));this.pointerListeners.forEach(i=>i({...t,state:this.vvw.state,hasInternalExecution:this.vvw.state.zoomedIn||this.isPinching(),abortController:this.vvw.state.abortController}))});r(this,"onKeyDown",t=>{const e=this.vvw;switch(t.key){case"ArrowLeft":t.preventDefault(),e.prev();break;case"ArrowRight":t.preventDefault(),e.next();break;case"ArrowUp":t.preventDefault(),e.zoomIn();break;case"ArrowDown":t.preventDefault(),e.zoomOut();break;case"Escape":t.preventDefault(),e.close();break}});r(this,"onScroll",t=>{t.preventDefault();const e=this.vvw,i=this.vvw.state.children.images.find(o=>o.pos===0),n=t.deltaY;i.setInitialCenter({x:t.clientX,y:t.clientY}),n<0?e.zoomIn():n>0&&e.zoomOut()});r(this,"onResizeHandler",()=>{this.vvw.state.children.images.forEach(t=>{t.setSizes()})});this.vvw=t}registerPointerListener(t){this.pointerListeners.push(t)}start(t){this.vvw.options.keyboardListeners&&window.addEventListener("keydown",this.onKeyDown),this.imageContainer=t,this.imageContainer.addEventListener("wheel",this.onScroll,{passive:!1}),window.addEventListener("resize",this.onResizeHandler),this.pointers=new V({elm:t,listeners:[this.internalPointerListener]})}stop(){this.vvw.options.keyboardListeners&&window.removeEventListener("keydown",this.onKeyDown),window.removeEventListener("resize",this.onResizeHandler),this.imageContainer.removeEventListener("wheel",this.onScroll),this.pointers.removeListeners(),this.pointerListeners=[]}}const C={somethingOpened:null};class A{constructor(t,e={}){r(this,"options");r(this,"state",new $);r(this,"imageContainer",null);r(this,"externalPointerListener",[]);r(this,"elements");r(this,"eventHandlers",null);r(this,"imageSetupFunction",z);r(this,"initFunction",W);r(this,"openFunction",R);r(this,"closeFunction",T);r(this,"transitionFunction",H);r(this,"throttle",new G);r(this,"root",null);r(this,"onClickElements",t=>{t.preventDefault();const e=t.currentTarget;e.dataset.vvwIdx&&this.open(parseInt(e.dataset.vvwIdx))});r(this,"defaultOnClickHandler",t=>t.preventDefault());r(this,"lastSwapTime",0);r(this,"isRapidSwap",!1);r(this,"isRapidSwapRelease",0);r(this,"transitionCleanup",null);r(this,"tempDeactivatedUi",[]);r(this,"tempDeactivationRequestBy",null);r(this,"isZoomedIn",!1);var i;this.elements=t,this.options={...y,...e,controls:{...y.controls,...e.controls}},this.options.imageSetupFunction&&(this.imageSetupFunction=this.options.imageSetupFunction),this.options.closeFunction&&(this.closeFunction=this.options.closeFunction),this.options.initFunction&&(this.initFunction=this.options.initFunction),this.options.transitionFunction&&(this.transitionFunction=this.options.transitionFunction),[...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(n=>{typeof n!="string"&&this.state.extensions.add(n)}),(i=this.options.extensions)==null||i.forEach(n=>{this.state.extensions.add(n)}),this.state.isReducedMotion=window.matchMedia("(prefers-reduced-motion: reduce)").matches,this.reset(),this.initFunction(this)}reset(){if(typeof this.elements=="string"){const t=this.qsOrigin(this.elements);this.state.elmLength=t.length,t.forEach((e,i)=>{const n=e;n.dataset.vvwIdx=i.toString(),n.removeEventListener("click",this.defaultOnClickHandler),n.removeEventListener("pointerup",this.onClickElements),n.addEventListener("click",this.defaultOnClickHandler),n.addEventListener("pointerup",this.onClickElements)})}else this.state.elmLength=this.elements.length}qs(t){return this.root?this.root.querySelector(t):null}qsOrigin(t){return document.querySelectorAll(t)}registerPointerListener(t){this.externalPointerListener.push(t)}getChildElements(t,e){const i=[],n=[],o=typeof this.elements=="string"?this.qsOrigin(this.elements):this.elements;for(let a=-t;a<=t;a++){const l=(e+a+o.length)%o.length,h=o[l],d={elm:h instanceof HTMLElement?tt(h):{config:h,origin:void 0,parsedSrcSet:void 0},pos:a,index:l,vistaView:this,maxZoomLevel:this.options.maxZoomLevel,transitionShouldWait:()=>this.isRapidSwap,onScale:({vistaImage:g,isMin:m,isMax:w})=>{var b,E,S,L;g.index===this.state.currentIndex&&(this.state.zoomedIn=!m,m?(b=this.qs(".vvw-zoom-out"))==null||b.setAttribute("disabled","true"):(E=this.qs(".vvw-zoom-out"))==null||E.removeAttribute("disabled"),w?(S=this.qs(".vvw-zoom-in"))==null||S.setAttribute("disabled","true"):(L=this.qs(".vvw-zoom-in"))==null||L.removeAttribute("disabled"))}};let u=null;this.state.extensions.forEach(g=>{!u&&g.onInitializeImage&&(u=g.onInitializeImage(d))});const v=u??new O(d),p=document.createElement("div");p.className="vvw-item",p.dataset.vvwPos=`${a}`,p.dataset.vvwIdx=`${l}`,v.thumb&&p.appendChild(v.thumb),p.appendChild(v.element),i.push(v),n.push(p)}return{htmls:n,images:i}}async swap(t,e){var p,g;this.reactivateUi();const i=this.options.preloads||0,n=this.state.currentIndex,{htmls:o,images:a}=this.getChildElements(i,n),l=this.imageContainer,h=this.state.children,f={htmlElements:{from:h.htmls,to:o},images:{from:h.images,to:a},index:{from:t,to:this.state.currentIndex},via:e||{next:!1,prev:!1},vistaView:this};this.imageSetupFunction(f),this.state.zoomedIn=!1,(p=this.qs(".vvw-zoom-out"))==null||p.setAttribute("disabled","true"),(g=this.qs(".vvw-zoom-in"))==null||g.removeAttribute("disabled");const u=performance.now()-this.lastSwapTime<this.options.rapidLimit;this.isRapidSwap=u;const{images:v}=this.state.children;if(this.state.children={htmls:o,images:a},this.displayCurrentInfo(),u)v.forEach(m=>{m.cancelPendingLoad(),m.destroy()});else{const m=this.state.abortController.signal,w=this.transitionFunction(f,m);w&&(this.transitionCleanup=w.cleanup,await w.transitionEnded),this.lastSwapTime=performance.now(),v.forEach(L=>{L.cancelPendingLoad()});const b=v.find(L=>L.index===n),E=b?x.stop(b):void 0,S=a.find(L=>L.index===n);S&&b&&S.cloneStyleFrom(b,E),v.forEach(L=>{L.destroy()})}l.innerHTML="",this.transitionCleanup&&this.transitionCleanup(),o.forEach(m=>{l.appendChild(m)}),a.forEach(m=>{m.init()}),u?(this.isRapidSwapRelease&&clearTimeout(this.isRapidSwapRelease),this.isRapidSwapRelease=setTimeout(()=>{this.isRapidSwap=!1},333)):this.isRapidSwap=!1,this.options.onImageView&&this.options.onImageView(f,this),this.state.extensions.forEach(m=>{m.onImageView&&m.onImageView(f,this)})}displayCurrentInfo(){const t=this.state.currentIndex;typeof this.elements=="string"&&this.qsOrigin(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.state.elmLength}`;e&&(e.textContent=`${i} / ${n}`);const o=this.qs(".vvw-desc");if(o){const a=this.state.children.images.find(h=>h.index===t),l=(a==null?void 0:a.config.alt)||"";l?(o.textContent=l,o.setAttribute("aria-label",`Image ${i} of ${n}: ${l}`),o.style.opacity=""):(o.textContent="",o.setAttribute("aria-label",`Image ${i} of ${n}`),o.style.opacity="0")}}deactivateUi(t,e){t.forEach(i=>{var n,o;i==="zoomIn"?(n=this.qs(".vvw-zoom-in"))==null||n.setAttribute("disabled","true"):i==="zoomOut"&&((o=this.qs(".vvw-zoom-out"))==null||o.setAttribute("disabled","true")),this.tempDeactivatedUi.push(i)}),this.tempDeactivationRequestBy=e||null,this.state.extensions.forEach(i=>{i.onDeactivateUi&&i.onDeactivateUi(t,this.tempDeactivationRequestBy,this)})}reactivateUi(){this.tempDeactivatedUi.forEach(t=>{var e,i;t==="zoomIn"?(e=this.qs(".vvw-zoom-in"))==null||e.removeAttribute("disabled"):t==="zoomOut"&&((i=this.qs(".vvw-zoom-out"))==null||i.removeAttribute("disabled"))}),this.state.extensions.forEach(t=>{t.onReactivateUi&&t.onReactivateUi(this.tempDeactivatedUi,this.tempDeactivationRequestBy,this)}),this.tempDeactivatedUi=[],this.tempDeactivationRequestBy=null}open(t=0){var h,f,d,u,v,p,g;if(C.somethingOpened){console.warn("Another VistaView instance is already opened. Close it first before opening a new one.");return}C.somethingOpened=this,this.reset(),(t<0||t>=this.state.elmLength)&&(t=(t%this.state.elmLength+this.state.elmLength)%this.state.elmLength),this.state.currentIndex=t,document.body.style.overflow="hidden";const e=Y({controls:this.options.controls});if(document.body.append(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:a}=this.getChildElements(i,n),l={htmlElements:{from:null,to:a},images:{from:null,to:o},index:{from:null,to:this.state.currentIndex},via:{next:!1,prev:!1},vistaView:this};this.imageSetupFunction(l),this.state.children={htmls:a,images:o},a.forEach(m=>{this.imageContainer.appendChild(m)}),o.forEach(m=>{m.init()}),(h=this.qs(".vvw-close"))==null||h.addEventListener("click",()=>this.close()),(f=this.qs(".vvw-zoom-in"))==null||f.addEventListener("click",()=>this.zoomIn()),(d=this.qs(".vvw-zoom-out"))==null||d.addEventListener("click",()=>this.zoomOut()),(u=this.qs(".vvw-prev>button"))==null||u.addEventListener("click",()=>this.prev()),(v=this.qs(".vvw-next>button"))==null||v.addEventListener("click",()=>this.next()),this.state.elmLength<2&&((p=this.qs(".vvw-prev"))==null||p.classList.add("vvw--hidden"),(g=this.qs(".vvw-next"))==null||g.classList.add("vvw--hidden")),this.openFunction(this),this.eventHandlers=new _(this),this.externalPointerListener.forEach(m=>{this.eventHandlers.registerPointerListener(m)}),this.eventHandlers.start(this.imageContainer),requestAnimationFrame(()=>{requestAnimationFrame(()=>{var m;(m=this.root)==null||m.addEventListener("transitionend",()=>{var w;(w=this.root)==null||w.classList.add("vvw--settled")},{once:!0}),this.root.classList.add("vvw--active"),this.displayCurrentInfo(),this.options.onOpen&&this.options.onOpen(this),this.options.onImageView&&this.options.onImageView(l,this),this.state.extensions.forEach(w=>{w.onOpen&&w.onOpen(this),w.onImageView&&w.onImageView(l,this)})})})}async close(t=!0){C.somethingOpened===this&&this.root&&(this.eventHandlers.stop(),this.eventHandlers=null,this.state.children.images.forEach(e=>{e.prepareClose()}),t?await new Promise(e=>{let n=0;this.root.addEventListener("transitionend",o=>{o.target===this.root&&(n++,n===2&&typeof this.elements=="string"&&(this.state.children.images.forEach(a=>{a.destroy()}),this.qsOrigin(this.elements).forEach(a=>{a.style.opacity=""})),n===3&&e(null))}),this.root.classList.add("vvw--closing")}):typeof this.elements=="string"&&(this.state.children.images.forEach(e=>{e.destroy()}),this.qsOrigin(this.elements).forEach(e=>{e.style.opacity=""})),this.root.remove(),this.root=null,this.imageContainer=null,this.state.children={htmls:[],images:[]},this.state.currentIndex=-1,this.state.children.images.forEach(e=>{e.destroy()}),document.body.style.overflow="",C.somethingOpened=null,this.closeFunction(this),this.options.onClose&&this.options.onClose(this),this.state.extensions.forEach(e=>{e.onClose&&e.onClose(this)}))}destroy(){this.close(!1),this.externalPointerListener=[],typeof this.elements=="string"&&this.qsOrigin(this.elements).forEach(t=>{t.removeAttribute("data-vista-idx"),t.removeEventListener("click",this.defaultOnClickHandler),t.removeEventListener("pointerup",this.onClickElements)})}next(){if(C.somethingOpened!==this){console.warn("This VistaView instance is not opened.");return}const t=(this.state.currentIndex+1)%this.state.elmLength;this.view(t,{next:!0,prev:!1})}prev(){if(C.somethingOpened!==this){console.warn("This VistaView instance is not opened.");return}const t=(this.state.currentIndex-1+this.state.elmLength)%this.state.elmLength;this.view(t,{next:!1,prev:!0})}view(t,e){if(C.somethingOpened!==this){console.warn("This VistaView instance is not opened.");return}if(this.state.elmLength<2)return;(t<0||t>=this.state.elmLength)&&(t=(t%this.state.elmLength+this.state.elmLength)%this.state.elmLength);const i=this.state.currentIndex;this.state.currentIndex=t;const n=this.state.abortController;n==null||n.abort(),this.state.abortController=new AbortController,this.swap(i,e)}zoomIn(){if(C.somethingOpened!==this){console.warn("This VistaView instance is not opened.");return}this.tempDeactivatedUi.includes("zoomIn")||this.throttle.fio(()=>{const t=this.state.children.images.find(e=>e.pos===0);t==null||t.animateZoom(1.68)},"zoom",222)}zoomOut(){if(C.somethingOpened!==this){console.warn("This VistaView instance is not opened.");return}this.tempDeactivatedUi.includes("zoomOut")||this.throttle.fio(()=>{const t=this.state.children.images.find(e=>e.pos===0);t==null||t.animateZoom(.68)},"zoom",222)}getCurrentIndex(){return this.state.currentIndex}}function et(s){let t=null;if(typeof s=="string"){if(t=document.querySelectorAll(s),t.length===0)return new Error("No elements found in node list.").toString();for(let e=0;e<t.length;e++){const i=t[e],n=i.tagName.toLowerCase();if(n!=="img"&&n!=="a")return new Error(`Invalid element at index ${e}: expected <img>, <a>, got <${n}>`);if(n==="a"&&!(i.querySelector("img")!==null))return new Error(`Invalid <a> element at index ${e}: must contain <img>`)}}else{const e=s;for(let i=0;i<e.length;i++)if(!e[i].src)return new Error(`Invalid image data at index ${i}: must have 'src'`)}return s}function it({elements:s,...t}){if(!s)return console.error(s),console.error("no elements provided"),console.warn("VistaView: silently returning."),null;let e=et(s);if(e instanceof Error)return console.error(e),console.warn("VistaView: silently returning."),null;const i=new A(e,t);return{open:(n=0)=>i.open(n),reset:()=>i.reset(),close:()=>i.close(),next:()=>i.next(),prev:()=>i.prev(),zoomIn:()=>i.zoomIn(),zoomOut:()=>i.zoomOut(),destroy:()=>i.destroy(),getCurrentIndex:()=>i.getCurrentIndex(),view:n=>{i.view(n)}}}c.DefaultOptions=y,c.VistaBox=F,c.VistaHiresTransition=x,c.VistaImage=O,c.VistaImageEvent=_,c.VistaPointers=V,c.VistaState=$,c.VistaView=A,c.close=T,c.imageSetup=z,c.init=W,c.open=R,c.transition=H,c.vistaView=it,Object.defineProperty(c,Symbol.toStringTag,{value:"Module"})}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vistaview",
3
- "version": "0.10.9",
3
+ "version": "0.10.10",
4
4
  "description": "A lightweight, zero-dependency image lightbox library with smooth animations and touch support",
5
5
  "keywords": [
6
6
  "image",