zoomora 1.3.0 → 1.4.0

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,50 +1,32 @@
1
- var t = (t, e, s) => () => {
2
- if (s) throw s[0];
3
- try {
4
- return t && (e = t(t = 0)), e;
5
- } catch (t) {
6
- throw s = [t], t;
7
- }
8
- }, e = (t, e) => () => (e || (t((e = { exports: {} }).exports, e), t = null), e.exports), s = t(() => {});
9
- function o(t) {
10
- return o = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(t) {
1
+ function t(e) {
2
+ return t = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(t) {
11
3
  return typeof t;
12
4
  } : function(t) {
13
5
  return t && "function" == typeof Symbol && t.constructor === Symbol && t !== Symbol.prototype ? "symbol" : typeof t;
14
- }, o(t);
6
+ }, t(e);
15
7
  }
16
- var i = t(() => {});
17
- var n = t(() => {
18
- i();
19
- });
20
- function a(t) {
21
- var e = function(t, e) {
22
- if ("object" != o(t) || !t) return t;
23
- var s = t[Symbol.toPrimitive];
24
- if (void 0 !== s) {
25
- var i = s.call(t, e || "default");
26
- if ("object" != o(i)) return i;
8
+ function e(e) {
9
+ var s = function(e, s) {
10
+ if ("object" != t(e) || !e) return e;
11
+ var o = e[Symbol.toPrimitive];
12
+ if (void 0 !== o) {
13
+ var i = o.call(e, s || "default");
14
+ if ("object" != t(i)) return i;
27
15
  throw new TypeError("@@toPrimitive must return a primitive value.");
28
16
  }
29
- return ("string" === e ? String : Number)(t);
30
- }(t, "string");
31
- return "symbol" == o(e) ? e : e + "";
17
+ return ("string" === s ? String : Number)(e);
18
+ }(e, "string");
19
+ return "symbol" == t(s) ? s : s + "";
32
20
  }
33
- var r = t(() => {
34
- i(), n();
35
- });
36
- function l(t, e, s) {
37
- return (e = a(e)) in t ? Object.defineProperty(t, e, {
38
- value: s,
21
+ function s(t, s, o) {
22
+ return (s = e(s)) in t ? Object.defineProperty(t, s, {
23
+ value: o,
39
24
  enumerable: !0,
40
25
  configurable: !0,
41
26
  writable: !0
42
- }) : t[e] = s, t;
27
+ }) : t[s] = o, t;
43
28
  }
44
- var h = t(() => {
45
- r();
46
- });
47
- function c(t, e) {
29
+ function o(t, e) {
48
30
  var s = Object.keys(t);
49
31
  if (Object.getOwnPropertySymbols) {
50
32
  var o = Object.getOwnPropertySymbols(t);
@@ -54,494 +36,501 @@ function c(t, e) {
54
36
  }
55
37
  return s;
56
38
  }
57
- function d(t) {
39
+ function i(t) {
58
40
  for (var e = 1; e < arguments.length; e++) {
59
- var s = null != arguments[e] ? arguments[e] : {};
60
- e % 2 ? c(Object(s), !0).forEach(function(e) {
61
- l(t, e, s[e]);
62
- }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(t, Object.getOwnPropertyDescriptors(s)) : c(Object(s)).forEach(function(e) {
63
- Object.defineProperty(t, e, Object.getOwnPropertyDescriptor(s, e));
41
+ var i = null != arguments[e] ? arguments[e] : {};
42
+ e % 2 ? o(Object(i), !0).forEach(function(e) {
43
+ s(t, e, i[e]);
44
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(t, Object.getOwnPropertyDescriptors(i)) : o(Object(i)).forEach(function(e) {
45
+ Object.defineProperty(t, e, Object.getOwnPropertyDescriptor(i, e));
64
46
  });
65
47
  }
66
48
  return t;
67
49
  }
68
- var u = t(() => {
69
- h();
70
- }), m = e((t, e) => {
71
- /*!
72
- * Zoomora Lightbox Plugin v1.3.0
73
- * A modern, responsive lightbox plugin with zoom, fullscreen, and gallery features
74
- *
75
- * Copyright (c) 2026 Faruk Ahmed (FrontTheme)
76
- * Licensed under MIT License
77
- */
78
- var o, i;
79
- s(), u(), o = "undefined" != typeof window ? window : t, i = function() {
80
- class t {
81
- static get defaults() {
82
- return {
83
- selector: "[data-zoomora]",
84
- showCounter: !0,
85
- showThumbnails: !0,
86
- showFullscreen: !0,
87
- showZoom: !0,
88
- transition: "fade",
89
- useHref: !1,
90
- maxZoomScale: 3,
91
- zoomStep: .1,
92
- animationDuration: 300,
93
- closeOnBackgroundClick: !0,
94
- onOpen: null,
95
- onClose: null,
96
- onNext: null,
97
- onPrev: null,
98
- showAutoHideToggle: !0,
99
- autoHideDelay: 3e3,
100
- autoHideEnabled: !1
101
- };
102
- }
103
- constructor(e = {}) {
104
- this.options = d(d({}, t.defaults), e), this.currentIndex = 0, this.items = [], this.isZoomed = !1, this.isFullscreen = !1, this.isDragging = !1, this.thumbnailsVisible = !0, this.startX = 0, this.startY = 0, this.currentX = 0, this.currentY = 0, this.currentScale = 1, this.isInitialized = !1, this.eventListeners = /* @__PURE__ */ new Map(), this.autoHideEnabled = !1, this.autoHideTimeout = null, this.autoHideDelay = 3e3, this.isControlsVisible = !0, this.lastDragTime = 0, this.boundMethods = {
105
- handleDocumentClick: this.handleDocumentClick.bind(this),
106
- handleKeydown: this.handleKeydown.bind(this),
107
- handleFullscreenChange: this.handleFullscreenChange.bind(this),
108
- handleZoomoraClick: this.handleZoomoraClick.bind(this),
109
- handleContentClick: this.handleContentClick.bind(this),
110
- handleMouseDown: this.handleMouseDown.bind(this),
111
- handleMouseMove: this.handleMouseMove.bind(this),
112
- handleMouseUp: this.handleMouseUp.bind(this),
113
- handleTouchStart: this.handleTouchStart.bind(this),
114
- handleTouchMove: this.handleTouchMove.bind(this),
115
- handleTouchEnd: this.handleTouchEnd.bind(this),
116
- handleWheel: this.handleWheel.bind(this)
117
- }, this.init();
118
- }
119
- init() {
120
- if (!this.isInitialized) try {
121
- this.createLightbox(), this.bindEvents(), this.isInitialized = !0;
122
- } catch (t) {}
123
- }
124
- static bind(e, s = {}) {
125
- return new t(d(d({}, s), {}, {
126
- selector: e,
127
- useHref: !0
128
- }));
129
- }
130
- createLightbox() {
131
- if (document.getElementById("zoomoraLightbox")) return;
132
- const t = this.options.showAutoHideToggle ? "\n <button class=\"zoomora-btn\" id=\"zoomoraAutoHideBtn\" title=\"Toggle Auto-Hide Controls\">\n <i class=\"zoomorai-controls-off\"></i>\n </button>\n " : "", e = `\n <div class="zoomora" id="zoomoraLightbox">\n <div class="zoomora-container">\n <div class="zoomora-header" id="zoomoraHeader">\n <div class="zoomora-counter" id="zoomoraCounter" ${this.options.showCounter ? "" : "style=\"opacity:0;visibility:hidden;\""}>1 / 1</div>\n <div class="zoomora-controls">\n ${this.options.showThumbnails ? "\n <button class=\"zoomora-btn\" id=\"zoomoraThumbnailBtn\" title=\"Toggle Thumbnails\">\n <i class=\"zoomorai-thumbnails\"></i>\n </button>\n " : ""}\n ${t}\n ${this.options.showZoom ? "\n <button class=\"zoomora-btn\" id=\"zoomoraZoomBtn\" title=\"Zoom\">\n <i class=\"zoomorai-zoom\"></i>\n </button>\n " : ""}\n ${this.options.showFullscreen ? "\n <button class=\"zoomora-btn\" id=\"zoomoraFullscreenBtn\" title=\"Fullscreen\">\n <i class=\"zoomorai-expand\"></i>\n </button>\n <button class=\"zoomora-btn\" id=\"zoomoraCollapseBtn\" title=\"Exit Fullscreen\" style=\"display: none;\">\n <i class=\"zoomorai-collapse\"></i>\n </button>\n " : ""}\n <button class="zoomora-btn" id="zoomoraCloseBtn" title="Close">\n <i class="zoomorai-close"></i>\n </button>\n </div>\n </div>\n \n <div class="zoomora-content" id="zoomoraContent">\n <div class="zoomora-loading" id="zoomoraLoading"></div>\n <div class="zoomora-slides-container" id="zoomoraSlidesContainer"></div>\n </div>\n \n <button class="zoomora-nav prev" id="zoomoraPrevBtn">\n <i class="zoomorai-arrow-left"></i>\n </button>\n <button class="zoomora-nav next" id="zoomoraNextBtn">\n <i class="zoomorai-arrow-right"></i>\n </button>\n \n <div class="zoomora-caption" id="zoomoraCaption" ${this.options.showThumbnails ? "" : "style=\"bottom:20px;\""}></div>\n <div class="zoomora-thumbnails" id="zoomoraThumbs" ${this.options.showThumbnails ? "" : "style=\"display:none;\""}></div>\n </div>\n </div>\n `;
133
- if (document.body.insertAdjacentHTML("beforeend", e), this.zoomora = document.getElementById("zoomoraLightbox"), this.header = document.getElementById("zoomoraHeader"), this.content = document.getElementById("zoomoraContent"), this.slidesContainer = document.getElementById("zoomoraSlidesContainer"), this.counter = document.getElementById("zoomoraCounter"), this.thumbs = document.getElementById("zoomoraThumbs"), this.loading = document.getElementById("zoomoraLoading"), this.caption = document.getElementById("zoomoraCaption"), this.prevBtn = document.getElementById("zoomoraPrevBtn"), this.nextBtn = document.getElementById("zoomoraNextBtn"), !(this.zoomora && this.content && this.counter && this.thumbs && this.loading && this.caption)) throw new Error("Failed to create required DOM elements");
134
- }
135
- bindEvents() {
136
- this.addEventListener(document, "click", this.boundMethods.handleDocumentClick), this.addEventListener(document.getElementById("zoomoraCloseBtn"), "click", () => this.close()), this.addEventListener(document.getElementById("zoomoraPrevBtn"), "click", () => this.prev()), this.addEventListener(document.getElementById("zoomoraNextBtn"), "click", () => this.next()), this.options.showZoom && this.addEventListener(document.getElementById("zoomoraZoomBtn"), "click", () => this.toggleZoom()), this.options.showFullscreen && (this.addEventListener(document.getElementById("zoomoraFullscreenBtn"), "click", () => this.toggleFullscreen()), this.addEventListener(document.getElementById("zoomoraCollapseBtn"), "click", () => this.exitFullscreen())), this.options.showThumbnails && this.addEventListener(document.getElementById("zoomoraThumbnailBtn"), "click", () => this.toggleThumbnails()), this.addEventListener(document, "fullscreenchange", this.boundMethods.handleFullscreenChange), this.addEventListener(document, "webkitfullscreenchange", this.boundMethods.handleFullscreenChange), this.addEventListener(document, "mozfullscreenchange", this.boundMethods.handleFullscreenChange), this.addEventListener(document, "MSFullscreenChange", this.boundMethods.handleFullscreenChange), this.addEventListener(document, "keydown", this.boundMethods.handleKeydown), this.addEventListener(this.zoomora, "click", this.boundMethods.handleZoomoraClick), this.addEventListener(this.content, "click", this.boundMethods.handleContentClick), this.addEventListener(this.content, "mousedown", this.boundMethods.handleMouseDown), this.addEventListener(this.content, "mousemove", this.boundMethods.handleMouseMove), this.addEventListener(this.content, "mouseup", this.boundMethods.handleMouseUp), this.addEventListener(this.content, "mouseleave", this.boundMethods.handleMouseUp), this.addEventListener(this.content, "touchstart", this.boundMethods.handleTouchStart, { passive: !1 }), this.addEventListener(this.content, "touchmove", this.boundMethods.handleTouchMove, { passive: !1 }), this.addEventListener(this.content, "touchend", this.boundMethods.handleTouchEnd), this.options.showZoom && this.addEventListener(this.content, "wheel", this.boundMethods.handleWheel, { passive: !1 }), this.options.showAutoHideToggle && (this.addEventListener(document.getElementById("zoomoraAutoHideBtn"), "click", () => this.toggleAutoHide()), this.addEventListener(this.zoomora, "mousemove", () => this.handleUserActivity()), this.addEventListener(this.zoomora, "touchstart", () => this.handleUserActivity()), this.addEventListener(this.zoomora, "keydown", () => this.handleUserActivity()));
137
- }
138
- addEventListener(t, e, s, o = {}) {
139
- if (!t) return;
140
- t.addEventListener(e, s, o);
141
- const i = `${t.constructor.name}_${e}`;
142
- this.eventListeners.has(i) || this.eventListeners.set(i, []), this.eventListeners.get(i).push({
143
- element: t,
144
- event: e,
145
- handler: s,
146
- options: o
147
- });
148
- }
149
- handleDocumentClick(t) {
150
- const e = t.target.closest(this.options.selector);
151
- e && (t.preventDefault(), this.open(e));
152
- }
153
- handleKeydown(t) {
154
- if (this.zoomora.classList.contains("active")) switch (t.key) {
155
- case "Escape":
156
- this.isFullscreen ? this.exitFullscreen() : this.close();
157
- break;
158
- case "ArrowLeft":
159
- this.prev();
160
- break;
161
- case "ArrowRight":
162
- this.next();
163
- break;
164
- case "z":
165
- case "Z":
166
- this.toggleZoom();
167
- break;
168
- case "f":
169
- case "F":
170
- this.toggleFullscreen();
171
- break;
172
- case "t":
173
- case "T": this.toggleThumbnails();
174
- }
175
- }
176
- handleFullscreenChange() {
177
- const t = !!(document.fullscreenElement || document.webkitFullscreenElement || document.mozFullScreenElement || document.msFullscreenElement);
178
- !t && this.isFullscreen ? (this.isFullscreen = !1, this.zoomora.classList.remove("fullscreen"), this.updateButtons()) : t && !this.isFullscreen && (this.isFullscreen = !0, this.zoomora.classList.add("fullscreen"), this.updateButtons());
179
- }
180
- handleZoomoraClick(t) {
181
- t.target === this.zoomora && this.options.closeOnBackgroundClick && this.close();
182
- }
183
- handleContentClick(t) {
184
- if (Date.now() - this.lastDragTime < 200) return;
185
- if (this.header && this.header.contains(t.target)) return;
186
- if (t.target.closest("button")) return;
187
- const e = t.target.closest(".zoomora-media, .zoomora-video, .zoomora-iframe");
188
- if (e) return void (e.classList.contains("zoomora-media") && !e.classList.contains("no-zoom") && this.toggleZoom());
189
- if (t.target.closest(".zoomora-video-container")) {
190
- if (t.target.closest(".zoomora-play-button")) return;
191
- this.options.closeOnBackgroundClick && this.close();
192
- return;
193
- }
194
- const s = t.target;
195
- ((s.classList.contains("zoomora-content") || s.classList.contains("zoomora-slide-container") || s.classList.contains("zoomora-slide") || s.classList.contains("zoomora-slides-container") || "zoomoraContent" === s.id || "zoomoraSlidesContainer" === s.id) && this.options.closeOnBackgroundClick || this.options.closeOnBackgroundClick) && this.close();
196
- }
197
- handleMouseDown(t) {
198
- this.startDrag(t);
199
- }
200
- handleMouseMove(t) {
201
- this.drag(t);
202
- }
203
- handleMouseUp() {
204
- this.endDrag();
205
- }
206
- handleTouchStart(t) {
207
- this.startDrag(t);
208
- }
209
- handleTouchMove(t) {
210
- this.drag(t);
211
- }
212
- handleTouchEnd() {
213
- this.endDrag();
214
- }
215
- handleWheel(t) {
216
- const e = this.content.querySelector(".zoomora-media");
217
- if (!e || "IMG" !== e.tagName) return;
218
- const s = this.calculateZoomLevels(e);
219
- if (!s.canZoom) return;
220
- t.preventDefault();
221
- const o = s.levels[s.levels.length - 1], i = this.options.zoomStep || .1, n = t.deltaY < 0 ? 1 : -1;
222
- let a = (this.currentScale || 1) + n * i * o;
223
- if (a = Math.max(1, Math.min(o, a)), a === this.currentScale) return;
224
- this.currentScale = a, this.isZoomed = a > 1, this.currentX = 0, this.currentY = 0, this.isZoomed ? (e.style.transform = `scale(${a})`, e.style.cursor = "grab", e.classList.add("zoomed")) : (e.style.transform = "", e.style.cursor = "pointer", e.classList.remove("zoomed"));
225
- let r = 0;
226
- s.levels.forEach((t, e) => {
227
- Math.abs(t - a) < Math.abs(s.levels[r] - a) && (r = e);
228
- }), e.dataset.zoomLevel = r.toString();
229
- }
230
- getImageSource(t) {
231
- const e = t.dataset.src || t.src || t.getAttribute("src");
232
- return "video" === (t.dataset.type || "image") && e ? this.convertToEmbedUrl(e) : e;
233
- }
234
- convertToEmbedUrl(t) {
235
- if (t.includes("youtube.com/embed/")) return t;
236
- let e = null, s = null;
237
- if (t.includes("youtube.com/watch")) {
238
- const o = new URLSearchParams(t.split("?")[1]);
239
- e = o.get("v");
240
- const i = o.get("t");
241
- i && (s = i.replace("s", ""));
242
- } else if (t.includes("youtu.be/")) {
243
- const o = t.split("/"), i = o[o.length - 1];
244
- if (i.includes("?")) {
245
- e = i.split("?")[0];
246
- const t = new URLSearchParams(i.split("?")[1]).get("t");
247
- t && (s = t.replace("s", ""));
248
- } else e = i;
249
- }
250
- if (e) {
251
- let t = `https://www.youtube.com/embed/${e}`;
252
- const o = new URLSearchParams();
253
- return s && o.append("start", s), o.append("rel", "0"), o.append("modestbranding", "1"), o.toString() && (t += "?" + o.toString()), t;
254
- }
255
- return t;
256
- }
257
- getThumbnailSource(t) {
258
- return "video" === (t.dataset.type || "image") ? t.src || t.getAttribute("src") : t.dataset.src || t.src || t.getAttribute("src");
259
- }
260
- getGroup(t) {
261
- return this.options.useHref ? t.dataset.lightbox || t.dataset.gallery || "default" : t.dataset.zoomora || "default";
262
- }
263
- open(t) {
264
- if (!t) return;
265
- const e = this.getGroup(t);
266
- let s;
267
- s = this.options.useHref ? t.dataset.lightbox ? `[data-lightbox="${e}"]` : t.dataset.gallery ? `[data-gallery="${e}"]` : this.options.selector : `[data-zoomora="${e}"]`, this.items = Array.from(document.querySelectorAll(s)), this.currentIndex = Math.max(0, this.items.indexOf(t)), this._activateLightbox(), "function" == typeof this.options.onOpen && this.options.onOpen(t, this.currentIndex);
268
- }
269
- openImage(t, e = {}) {
270
- const s = Array.isArray(t) ? t : [t];
271
- this.items = s.map((t) => this.createVirtualItem("string" == typeof t ? { src: t } : t)), this.currentIndex = Math.max(0, Math.min(e.startIndex || 0, this.items.length - 1)), this._activateLightbox(), "function" == typeof this.options.onOpen && this.options.onOpen(this.items[this.currentIndex], this.currentIndex);
272
- }
273
- createVirtualItem({ src: t, thumb: e, type: s = "image", caption: o = "", alt: i = "" }) {
274
- const n = e || t;
275
- return {
276
- dataset: {
277
- src: t,
278
- type: s,
279
- caption: o
280
- },
281
- src: n,
282
- alt: i,
283
- title: o,
284
- getAttribute: (t) => "src" === t ? n : null
285
- };
286
- }
287
- _activateLightbox() {
288
- this.isZoomed = !1, this.isFullscreen = !1, this.thumbnailsVisible = !0, this.currentX = 0, this.currentY = 0, this.currentScale = 1, this.zoomora.classList.add("active"), document.body.style.overflow = "hidden", this.loadContent(), this.updateThumbnails(), this.updateCounter(), this.updateNavigation(), this.updateCaption(), this.updateButtons(), this.autoHideEnabled ? this.startAutoHideTimer() : this.showControls();
289
- }
290
- close() {
291
- this.isFullscreen && this.exitFullscreen(), this.zoomora.classList.remove("active"), document.body.style.overflow = "", this.isZoomed = !1, this.isFullscreen = !1, this.currentX = 0, this.currentY = 0, this.currentScale = 1;
292
- const t = this.content.querySelector(".zoomora-media");
293
- t && (t.classList.remove("zoomed"), t.style.transform = "", t.style.cursor = ""), this.zoomora.classList.remove("fullscreen"), this.updateButtons(), this.stopAutoHideTimer(), this.showControls(), "function" == typeof this.options.onClose && this.options.onClose(this.currentIndex);
294
- }
295
- prev() {
296
- this.currentIndex > 0 && (this.currentIndex--, this.loadContent(), this.updateCounter(), this.updateThumbnails(), this.updateNavigation(), this.updateCaption(), "function" == typeof this.options.onPrev && this.options.onPrev(this.currentIndex));
297
- }
298
- next() {
299
- this.currentIndex < this.items.length - 1 && (this.currentIndex++, this.loadContent(), this.updateCounter(), this.updateThumbnails(), this.updateNavigation(), this.updateCaption(), "function" == typeof this.options.onNext && this.options.onNext(this.currentIndex));
300
- }
301
- loadContent() {
302
- if (!this.items[this.currentIndex]) return;
303
- const t = this.items[this.currentIndex], e = this.getImageSource(t), s = t.dataset.type || "image";
304
- e && (this.isZoomed = !1, this.currentX = 0, this.currentY = 0, this.currentScale = 1, this.loading.style.display = "block", this.slidesContainer && (this.slidesContainer.innerHTML = ""), setTimeout(() => {
305
- this.renderContent(e, s, t);
306
- }, 100));
307
- }
308
- renderContent(t, e, s) {
309
- const o = document.createElement("div");
310
- o.className = "zoomora-slide-container";
311
- const i = document.createElement("div");
312
- let n;
313
- i.className = "zoomora-slide " + ("slide" === this.options.transition ? "slide-effect" : "fade-effect"), i.style.opacity = "0", i.style.transform = "slide" === this.options.transition ? "translateX(100%)" : "scale(0.8)";
314
- try {
315
- switch (e) {
316
- case "video":
317
- if (t.endsWith(".mp4") || t.endsWith(".webm") || t.endsWith(".ogg")) {
318
- const e = document.createElement("div");
319
- e.className = "zoomora-video-container", n = document.createElement("video"), n.src = t, n.className = "zoomora-video", n.setAttribute("preload", "metadata");
320
- const i = s.src || s.getAttribute("src");
321
- i && n.setAttribute("poster", i);
322
- const a = document.createElement("div");
323
- a.className = "zoomora-play-button", a.innerHTML = "<svg viewBox=\"0 0 24 24\" fill=\"currentColor\"><path d=\"M8 5v14l11-7z\"/></svg>", a.addEventListener("click", () => {
324
- n.play(), a.style.display = "none", n.setAttribute("controls", "");
325
- }), n.addEventListener("ended", () => {
326
- a.style.display = "flex";
327
- }), e.appendChild(n), e.appendChild(a), o.appendChild(e);
328
- } else n = document.createElement("iframe"), n.src = t, n.className = "zoomora-video", n.setAttribute("allowfullscreen", ""), n.setAttribute("frameborder", "0"), o.appendChild(n);
329
- break;
330
- case "iframe":
331
- n = document.createElement("iframe"), n.src = t, n.className = "zoomora-iframe", n.setAttribute("frameborder", "0"), o.appendChild(n);
332
- break;
333
- default: n = document.createElement("img"), n.src = t, n.className = "zoomora-media", n.alt = s.alt || s.title || "", n.onload = () => {
334
- this.loading.style.display = "none", this.checkZoomability(n), this.animateSlideIn(i);
335
- }, n.onerror = () => {
336
- this.loading.style.display = "none", this.animateSlideIn(i);
337
- }, o.appendChild(n);
338
- }
339
- i.appendChild(o), this.slidesContainer.innerHTML = "", this.slidesContainer.appendChild(i), "image" !== e && (this.loading.style.display = "none", this.animateSlideIn(i));
340
- } catch (t) {
341
- this.loading.style.display = "none";
342
- }
343
- }
344
- animateSlideIn(t) {
345
- t.offsetHeight, t.classList.add("active"), "slide" === this.options.transition ? (t.style.transition = `transform ${this.options.animationDuration}ms ease, opacity ${this.options.animationDuration}ms ease`, t.style.transform = "translateX(0)", t.style.opacity = "1") : (t.style.transition = `transform ${this.options.animationDuration}ms ease, opacity ${this.options.animationDuration}ms ease`, t.style.transform = "scale(1)", t.style.opacity = "1");
346
- }
347
- toggleAutoHide() {
348
- this.autoHideEnabled = !this.autoHideEnabled;
349
- const t = document.getElementById("zoomoraAutoHideBtn");
350
- this.autoHideEnabled ? (t.classList.add("active"), t.title = "Disable Auto-Hide Controls", this.startAutoHideTimer()) : (t.classList.remove("active"), t.title = "Enable Auto-Hide Controls", this.stopAutoHideTimer(), this.showControls());
351
- }
352
- handleUserActivity() {
353
- this.autoHideEnabled && (this.showControls(), this.startAutoHideTimer());
354
- }
355
- startAutoHideTimer() {
356
- this.stopAutoHideTimer(), this.autoHideTimeout = setTimeout(() => {
357
- this.hideControls();
358
- }, this.options.autoHideDelay);
359
- }
360
- stopAutoHideTimer() {
361
- this.autoHideTimeout && (clearTimeout(this.autoHideTimeout), this.autoHideTimeout = null);
362
- }
363
- showControls() {
364
- this.isControlsVisible || (this.isControlsVisible = !0, this.zoomora.classList.remove("controls-hidden"), this.header && (this.header.style.transform = "translateY(0)", this.header.style.opacity = "1"), this.caption && (this.caption.style.transform = "translateX(-50%) translateY(0)", this.caption.style.opacity = "1"), this.thumbs && (this.thumbs.style.transform = "translateX(-50%) translateY(0)", this.thumbs.style.opacity = "1"), this.prevBtn && (this.prevBtn.style.transform = "translateX(0)", this.prevBtn.style.opacity = "1"), this.nextBtn && (this.nextBtn.style.transform = "translateX(0)", this.nextBtn.style.opacity = "1"));
365
- }
366
- hideControls() {
367
- this.isControlsVisible && (this.isControlsVisible = !1, this.zoomora.classList.add("controls-hidden"), this.header && (this.header.style.transform = "translateY(-100%)", this.header.style.opacity = "0"), this.caption && (this.caption.style.transform = "translateX(-50%) translateY(100%)", this.caption.style.opacity = "0"), this.thumbs && (this.thumbs.style.transform = "translateX(-50%) translateY(100%)", this.thumbs.style.opacity = "0"), this.prevBtn && (this.prevBtn.style.transform = "translateX(-100%)", this.prevBtn.style.opacity = "0"), this.nextBtn && (this.nextBtn.style.transform = "translateX(100%)", this.nextBtn.style.opacity = "0"));
368
- }
369
- checkZoomability(t) {
370
- if (!t || !t.naturalWidth || !t.naturalHeight) return;
371
- const e = t.getBoundingClientRect(), s = e.width, o = e.height, i = t.naturalWidth, n = t.naturalHeight, a = i > s || n > o, r = i / s, l = n / o, h = Math.max(r, l);
372
- t.dataset.zoomRatio = h.toString(), t.dataset.naturalWidth = i.toString(), t.dataset.naturalHeight = n.toString(), t.dataset.renderedWidth = s.toString(), t.dataset.renderedHeight = o.toString(), a && h > 1.1 ? t.classList.remove("no-zoom") : t.classList.add("no-zoom");
373
- }
374
- calculateZoomLevels(t) {
375
- if (!t || !t.naturalWidth || !t.naturalHeight) return {
376
- canZoom: !1,
377
- levels: [],
378
- currentLevel: 0
379
- };
380
- const e = this.content.getBoundingClientRect(), s = e.width, o = e.height, i = t.naturalWidth, n = t.naturalHeight, a = s / i, r = o / n, l = Math.min(a, r);
381
- if (l >= .95) return {
382
- canZoom: !1,
383
- levels: [],
384
- currentLevel: 0
385
- };
386
- const h = Number(this.options.maxZoomScale), c = Number.isFinite(h) && h > 0 ? Math.max(1, h) : 3, d = [1];
387
- [
388
- 1.5,
389
- 2,
390
- 3,
391
- 4,
392
- 5
393
- ].forEach((t) => {
394
- t <= c && l * t <= 1 && d.push(t);
395
- });
396
- const u = Math.min(1 / l, c);
397
- return u > d[d.length - 1] && d.push(u), {
398
- canZoom: d.length > 1,
399
- levels: d,
400
- currentLevel: 0,
401
- baseScale: l,
402
- naturalWidth: i,
403
- naturalHeight: n
404
- };
405
- }
406
- updateCounter() {
407
- this.options.showCounter && this.counter && (this.counter.textContent = `${this.currentIndex + 1} / ${this.items.length}`);
408
- }
409
- updateCaption() {
410
- if (!this.caption || !this.items[this.currentIndex]) return;
411
- const t = this.items[this.currentIndex], e = t.dataset.caption || t.title || "";
412
- e ? (this.caption.textContent = e, this.caption.style.transform = "translateX(-50%) translateY(0)", this.caption.style.opacity = "1", this.caption.style.pointerEvents = "auto", this.caption.style.transition = "opacity 0.3s ease, transform 0.3s ease") : (this.caption.style.transform = "translateX(-50%) translateY(100%)", this.caption.style.opacity = "0", this.caption.style.pointerEvents = "none", this.caption.style.transition = "opacity 0.3s ease, transform 0.3s ease");
413
- }
414
- updateThumbnails() {
415
- if (this.options.showThumbnails && this.thumbs) {
416
- if (1 === this.items.length) return this.caption.classList.add("single-item-thumbnail"), void (this.thumbs.style.display = "none");
417
- this.caption.classList.remove("single-item-thumbnail"), this.thumbs.style.display = "flex", this.thumbs.innerHTML = "", this.items.forEach((t, e) => {
418
- const s = document.createElement("div");
419
- s.className = "zoomora-thumb", e === this.currentIndex && s.classList.add("active");
420
- const o = document.createElement("img"), i = this.getThumbnailSource(t);
421
- i && (o.src = i, o.alt = t.alt || t.title || "", o.onerror = () => {
422
- s.style.display = "none";
423
- }), s.appendChild(o), s.addEventListener("click", () => {
424
- this.currentIndex = e, this.loadContent(), this.updateCounter(), this.updateThumbnails(), this.updateNavigation(), this.updateCaption();
425
- }), this.thumbs.appendChild(s);
426
- });
427
- }
428
- }
429
- updateNavigation() {
430
- const t = document.getElementById("zoomoraPrevBtn"), e = document.getElementById("zoomoraNextBtn");
431
- t && (t.style.display = this.currentIndex > 0 ? "flex" : "none"), e && (e.style.display = this.currentIndex < this.items.length - 1 ? "flex" : "none");
432
- }
433
- updateButtons() {
434
- const t = document.getElementById("zoomoraFullscreenBtn"), e = document.getElementById("zoomoraCollapseBtn");
435
- t && e && (this.isFullscreen ? (t.style.display = "none", e.style.display = "flex") : (t.style.display = "flex", e.style.display = "none"));
436
- }
437
- toggleZoom() {
438
- const t = this.content.querySelector(".zoomora-media");
439
- if (!t || "IMG" !== t.tagName) return;
440
- const e = this.calculateZoomLevels(t);
441
- if (!e.canZoom) return;
442
- t.dataset.zoomLevel || (t.dataset.zoomLevel = "0");
443
- let s = parseInt(t.dataset.zoomLevel) || 0;
444
- s++, s >= e.levels.length && (s = 0);
445
- const o = e.levels[s];
446
- t.dataset.zoomLevel = s.toString(), 0 === s ? (this.isZoomed = !1, this.isDragging = !1, t.classList.remove("dragging"), t.style.transform = "", t.style.cursor = "pointer", t.classList.remove("zoomed"), this.currentX = 0, this.currentY = 0, this.currentScale = 1) : (this.isZoomed = !0, this.currentScale = o, this.currentX = 0, this.currentY = 0, t.style.transform = `translate(0px, 0px) scale(${o})`, t.style.cursor = "grab", t.classList.add("zoomed"));
447
- }
448
- toggleFullscreen() {
449
- this.isFullscreen ? this.exitFullscreen() : this.enterFullscreen();
450
- }
451
- enterFullscreen() {
452
- const t = this.zoomora;
453
- try {
454
- t.requestFullscreen ? t.requestFullscreen().then(() => {
455
- this.isFullscreen = !0, this.zoomora.classList.add("fullscreen"), this.updateButtons();
456
- }).catch((t) => {
457
- this.fallbackFullscreen();
458
- }) : t.webkitRequestFullscreen ? (t.webkitRequestFullscreen(), this.isFullscreen = !0, this.zoomora.classList.add("fullscreen"), this.updateButtons()) : t.mozRequestFullScreen ? (t.mozRequestFullScreen(), this.isFullscreen = !0, this.zoomora.classList.add("fullscreen"), this.updateButtons()) : t.msRequestFullscreen ? (t.msRequestFullscreen(), this.isFullscreen = !0, this.zoomora.classList.add("fullscreen"), this.updateButtons()) : this.fallbackFullscreen();
459
- } catch (t) {
460
- this.fallbackFullscreen();
461
- }
462
- }
463
- exitFullscreen() {
464
- if (document.fullscreenElement || document.webkitFullscreenElement || document.mozFullScreenElement || document.msFullscreenElement) try {
465
- document.exitFullscreen ? document.exitFullscreen().then(() => {
466
- this.isFullscreen = !1, this.zoomora.classList.remove("fullscreen"), this.updateButtons();
467
- }).catch((t) => {
468
- this.fallbackExitFullscreen();
469
- }) : document.webkitExitFullscreen ? (document.webkitExitFullscreen(), this.isFullscreen = !1, this.zoomora.classList.remove("fullscreen"), this.updateButtons()) : document.mozCancelFullScreen ? (document.mozCancelFullScreen(), this.isFullscreen = !1, this.zoomora.classList.remove("fullscreen"), this.updateButtons()) : document.msExitFullscreen ? (document.msExitFullscreen(), this.isFullscreen = !1, this.zoomora.classList.remove("fullscreen"), this.updateButtons()) : this.fallbackExitFullscreen();
470
- } catch (t) {
471
- this.fallbackExitFullscreen();
472
- }
473
- else this.fallbackExitFullscreen();
474
- }
475
- fallbackFullscreen() {
50
+ /*!
51
+ * Zoomora Lightbox Plugin v1.4.0
52
+ * A modern, responsive lightbox plugin with zoom, fullscreen, and gallery features
53
+ *
54
+ * Copyright (c) 2026 Faruk Ahmed (FrontTheme)
55
+ * Licensed under MIT License
56
+ */ var n = class t {
57
+ static get defaults() {
58
+ return {
59
+ selector: "[data-zoomora]",
60
+ showCounter: !0,
61
+ showThumbnails: !0,
62
+ showFullscreen: !0,
63
+ showZoom: !0,
64
+ transition: "fade",
65
+ useHref: !1,
66
+ maxZoomScale: 3,
67
+ zoomStep: .1,
68
+ animationDuration: 300,
69
+ closeOnBackgroundClick: !0,
70
+ autoplayVideos: !1,
71
+ onOpen: null,
72
+ onClose: null,
73
+ onNext: null,
74
+ onPrev: null,
75
+ showAutoHideToggle: !0,
76
+ autoHideDelay: 3e3,
77
+ autoHideEnabled: !1
78
+ };
79
+ }
80
+ constructor(e = {}) {
81
+ this.options = i(i({}, t.defaults), e), this.currentIndex = 0, this.items = [], this.isZoomed = !1, this.isFullscreen = !1, this.isDragging = !1, this.thumbnailsVisible = !0, this.startX = 0, this.startY = 0, this.currentX = 0, this.currentY = 0, this.currentScale = 1, this.isInitialized = !1, this.eventListeners = /* @__PURE__ */ new Map(), this.autoHideEnabled = !1, this.autoHideTimeout = null, this.autoHideDelay = 3e3, this.isControlsVisible = !0, this.lastDragTime = 0, this.boundMethods = {
82
+ handleDocumentClick: this.handleDocumentClick.bind(this),
83
+ handleKeydown: this.handleKeydown.bind(this),
84
+ handleFullscreenChange: this.handleFullscreenChange.bind(this),
85
+ handleZoomoraClick: this.handleZoomoraClick.bind(this),
86
+ handleContentClick: this.handleContentClick.bind(this),
87
+ handleMouseDown: this.handleMouseDown.bind(this),
88
+ handleMouseMove: this.handleMouseMove.bind(this),
89
+ handleMouseUp: this.handleMouseUp.bind(this),
90
+ handleTouchStart: this.handleTouchStart.bind(this),
91
+ handleTouchMove: this.handleTouchMove.bind(this),
92
+ handleTouchEnd: this.handleTouchEnd.bind(this),
93
+ handleWheel: this.handleWheel.bind(this)
94
+ }, this.init();
95
+ }
96
+ init() {
97
+ if (!this.isInitialized) try {
98
+ this.createLightbox(), this.bindEvents(), this.isInitialized = !0;
99
+ } catch (t) {}
100
+ }
101
+ static bind(e, s = {}) {
102
+ return new t(i(i({}, s), {}, {
103
+ selector: e,
104
+ useHref: !0
105
+ }));
106
+ }
107
+ createLightbox() {
108
+ if (document.getElementById("zoomoraLightbox")) return;
109
+ const t = this.options.showAutoHideToggle ? "\n <button class=\"zoomora-btn\" id=\"zoomoraAutoHideBtn\" title=\"Toggle Auto-Hide Controls\">\n <i class=\"zoomorai-controls-off\"></i>\n </button>\n " : "", e = `\n <div class="zoomora" id="zoomoraLightbox">\n <div class="zoomora-container">\n <div class="zoomora-header" id="zoomoraHeader">\n <div class="zoomora-counter" id="zoomoraCounter" ${this.options.showCounter ? "" : "style=\"opacity:0;visibility:hidden;\""}>1 / 1</div>\n <div class="zoomora-controls">\n ${this.options.showThumbnails ? "\n <button class=\"zoomora-btn\" id=\"zoomoraThumbnailBtn\" title=\"Toggle Thumbnails\">\n <i class=\"zoomorai-thumbnails\"></i>\n </button>\n " : ""}\n ${t}\n ${this.options.showZoom ? "\n <button class=\"zoomora-btn\" id=\"zoomoraZoomBtn\" title=\"Zoom\">\n <i class=\"zoomorai-zoom\"></i>\n </button>\n " : ""}\n ${this.options.showFullscreen ? "\n <button class=\"zoomora-btn\" id=\"zoomoraFullscreenBtn\" title=\"Fullscreen\">\n <i class=\"zoomorai-expand\"></i>\n </button>\n <button class=\"zoomora-btn\" id=\"zoomoraCollapseBtn\" title=\"Exit Fullscreen\" style=\"display: none;\">\n <i class=\"zoomorai-collapse\"></i>\n </button>\n " : ""}\n <button class="zoomora-btn" id="zoomoraCloseBtn" title="Close">\n <i class="zoomorai-close"></i>\n </button>\n </div>\n </div>\n \n <div class="zoomora-content" id="zoomoraContent">\n <div class="zoomora-loading" id="zoomoraLoading"></div>\n <div class="zoomora-slides-container" id="zoomoraSlidesContainer"></div>\n </div>\n \n <button class="zoomora-nav prev" id="zoomoraPrevBtn">\n <i class="zoomorai-arrow-left"></i>\n </button>\n <button class="zoomora-nav next" id="zoomoraNextBtn">\n <i class="zoomorai-arrow-right"></i>\n </button>\n \n <div class="zoomora-caption" id="zoomoraCaption" ${this.options.showThumbnails ? "" : "style=\"bottom:20px;\""}></div>\n <div class="zoomora-thumbnails" id="zoomoraThumbs" ${this.options.showThumbnails ? "" : "style=\"display:none;\""}></div>\n </div>\n </div>\n `;
110
+ if (document.body.insertAdjacentHTML("beforeend", e), this.zoomora = document.getElementById("zoomoraLightbox"), this.header = document.getElementById("zoomoraHeader"), this.content = document.getElementById("zoomoraContent"), this.slidesContainer = document.getElementById("zoomoraSlidesContainer"), this.counter = document.getElementById("zoomoraCounter"), this.thumbs = document.getElementById("zoomoraThumbs"), this.loading = document.getElementById("zoomoraLoading"), this.caption = document.getElementById("zoomoraCaption"), this.prevBtn = document.getElementById("zoomoraPrevBtn"), this.nextBtn = document.getElementById("zoomoraNextBtn"), !(this.zoomora && this.content && this.counter && this.thumbs && this.loading && this.caption)) throw new Error("Failed to create required DOM elements");
111
+ }
112
+ bindEvents() {
113
+ this.addEventListener(document, "click", this.boundMethods.handleDocumentClick), this.addEventListener(document.getElementById("zoomoraCloseBtn"), "click", () => this.close()), this.addEventListener(document.getElementById("zoomoraPrevBtn"), "click", () => this.prev()), this.addEventListener(document.getElementById("zoomoraNextBtn"), "click", () => this.next()), this.options.showZoom && this.addEventListener(document.getElementById("zoomoraZoomBtn"), "click", () => this.toggleZoom()), this.options.showFullscreen && (this.addEventListener(document.getElementById("zoomoraFullscreenBtn"), "click", () => this.toggleFullscreen()), this.addEventListener(document.getElementById("zoomoraCollapseBtn"), "click", () => this.exitFullscreen())), this.options.showThumbnails && this.addEventListener(document.getElementById("zoomoraThumbnailBtn"), "click", () => this.toggleThumbnails()), this.addEventListener(document, "fullscreenchange", this.boundMethods.handleFullscreenChange), this.addEventListener(document, "webkitfullscreenchange", this.boundMethods.handleFullscreenChange), this.addEventListener(document, "mozfullscreenchange", this.boundMethods.handleFullscreenChange), this.addEventListener(document, "MSFullscreenChange", this.boundMethods.handleFullscreenChange), this.addEventListener(document, "keydown", this.boundMethods.handleKeydown), this.addEventListener(this.zoomora, "click", this.boundMethods.handleZoomoraClick), this.addEventListener(this.content, "click", this.boundMethods.handleContentClick), this.addEventListener(this.content, "mousedown", this.boundMethods.handleMouseDown), this.addEventListener(this.content, "mousemove", this.boundMethods.handleMouseMove), this.addEventListener(this.content, "mouseup", this.boundMethods.handleMouseUp), this.addEventListener(this.content, "mouseleave", this.boundMethods.handleMouseUp), this.addEventListener(this.content, "touchstart", this.boundMethods.handleTouchStart, { passive: !1 }), this.addEventListener(this.content, "touchmove", this.boundMethods.handleTouchMove, { passive: !1 }), this.addEventListener(this.content, "touchend", this.boundMethods.handleTouchEnd), this.options.showZoom && this.addEventListener(this.content, "wheel", this.boundMethods.handleWheel, { passive: !1 }), this.options.showAutoHideToggle && (this.addEventListener(document.getElementById("zoomoraAutoHideBtn"), "click", () => this.toggleAutoHide()), this.addEventListener(this.zoomora, "mousemove", () => this.handleUserActivity()), this.addEventListener(this.zoomora, "touchstart", () => this.handleUserActivity()), this.addEventListener(this.zoomora, "keydown", () => this.handleUserActivity()));
114
+ }
115
+ addEventListener(t, e, s, o = {}) {
116
+ if (!t) return;
117
+ t.addEventListener(e, s, o);
118
+ const i = `${t.constructor.name}_${e}`;
119
+ this.eventListeners.has(i) || this.eventListeners.set(i, []), this.eventListeners.get(i).push({
120
+ element: t,
121
+ event: e,
122
+ handler: s,
123
+ options: o
124
+ });
125
+ }
126
+ handleDocumentClick(t) {
127
+ const e = t.target.closest(this.options.selector);
128
+ e && (t.preventDefault(), this.open(e));
129
+ }
130
+ handleKeydown(t) {
131
+ if (this.zoomora.classList.contains("active")) switch (t.key) {
132
+ case "Escape":
133
+ this.isFullscreen ? this.exitFullscreen() : this.close();
134
+ break;
135
+ case "ArrowLeft":
136
+ this.prev();
137
+ break;
138
+ case "ArrowRight":
139
+ this.next();
140
+ break;
141
+ case "z":
142
+ case "Z":
143
+ this.toggleZoom();
144
+ break;
145
+ case "f":
146
+ case "F":
147
+ this.toggleFullscreen();
148
+ break;
149
+ case "t":
150
+ case "T": this.toggleThumbnails();
151
+ }
152
+ else this.handleTriggerKeydown(t);
153
+ }
154
+ handleTriggerKeydown(t) {
155
+ if ("Enter" !== t.key && " " !== t.key) return;
156
+ const e = t.target.closest(this.options.selector);
157
+ e && (t.preventDefault(), this.open(e));
158
+ }
159
+ handleFullscreenChange() {
160
+ const t = !!(document.fullscreenElement || document.webkitFullscreenElement || document.mozFullScreenElement || document.msFullscreenElement);
161
+ !t && this.isFullscreen ? (this.isFullscreen = !1, this.zoomora.classList.remove("fullscreen"), this.updateButtons()) : t && !this.isFullscreen && (this.isFullscreen = !0, this.zoomora.classList.add("fullscreen"), this.updateButtons());
162
+ }
163
+ handleZoomoraClick(t) {
164
+ t.target === this.zoomora && this.options.closeOnBackgroundClick && this.close();
165
+ }
166
+ handleContentClick(t) {
167
+ if (Date.now() - this.lastDragTime < 200) return;
168
+ if (this.header && this.header.contains(t.target)) return;
169
+ if (t.target.closest("button")) return;
170
+ const e = t.target.closest(".zoomora-media, .zoomora-video, .zoomora-iframe");
171
+ if (e) return void (e.classList.contains("zoomora-media") && !e.classList.contains("no-zoom") && this.toggleZoom());
172
+ if (t.target.closest(".zoomora-video-container")) {
173
+ if (t.target.closest(".zoomora-play-button")) return;
174
+ this.options.closeOnBackgroundClick && this.close();
175
+ return;
176
+ }
177
+ const s = t.target;
178
+ ((s.classList.contains("zoomora-content") || s.classList.contains("zoomora-slide-container") || s.classList.contains("zoomora-slide") || s.classList.contains("zoomora-slides-container") || "zoomoraContent" === s.id || "zoomoraSlidesContainer" === s.id) && this.options.closeOnBackgroundClick || this.options.closeOnBackgroundClick) && this.close();
179
+ }
180
+ handleMouseDown(t) {
181
+ this.startDrag(t);
182
+ }
183
+ handleMouseMove(t) {
184
+ this.drag(t);
185
+ }
186
+ handleMouseUp() {
187
+ this.endDrag();
188
+ }
189
+ handleTouchStart(t) {
190
+ this.startDrag(t);
191
+ }
192
+ handleTouchMove(t) {
193
+ this.drag(t);
194
+ }
195
+ handleTouchEnd() {
196
+ this.endDrag();
197
+ }
198
+ handleWheel(t) {
199
+ const e = this.content.querySelector(".zoomora-media");
200
+ if (!e || "IMG" !== e.tagName) return;
201
+ const s = this.calculateZoomLevels(e);
202
+ if (!s.canZoom) return;
203
+ t.preventDefault();
204
+ const o = s.levels[s.levels.length - 1], i = this.options.zoomStep || .1, n = t.deltaY < 0 ? 1 : -1;
205
+ let a = (this.currentScale || 1) + n * i * o;
206
+ if (a = Math.max(1, Math.min(o, a)), a === this.currentScale) return;
207
+ this.currentScale = a, this.isZoomed = a > 1, this.currentX = 0, this.currentY = 0, this.isZoomed ? (e.style.transform = `scale(${a})`, e.style.cursor = "grab", e.classList.add("zoomed")) : (e.style.transform = "", e.style.cursor = "pointer", e.classList.remove("zoomed"));
208
+ let r = 0;
209
+ s.levels.forEach((t, e) => {
210
+ Math.abs(t - a) < Math.abs(s.levels[r] - a) && (r = e);
211
+ }), e.dataset.zoomLevel = r.toString();
212
+ }
213
+ getImageSource(t) {
214
+ const e = t.dataset.src || t.getAttribute("href") || t.src || t.getAttribute("src");
215
+ return "video" === (t.dataset.type || "image") && e ? this.convertToEmbedUrl(e) : e;
216
+ }
217
+ convertToEmbedUrl(t) {
218
+ if (t.includes("youtube.com/embed/")) return t;
219
+ let e = null, s = null;
220
+ if (t.includes("youtube.com/watch")) {
221
+ const o = new URLSearchParams(t.split("?")[1]);
222
+ e = o.get("v");
223
+ const i = o.get("t");
224
+ i && (s = i.replace("s", ""));
225
+ } else if (t.includes("youtu.be/")) {
226
+ const o = t.split("/"), i = o[o.length - 1];
227
+ if (i.includes("?")) {
228
+ e = i.split("?")[0];
229
+ const t = new URLSearchParams(i.split("?")[1]).get("t");
230
+ t && (s = t.replace("s", ""));
231
+ } else e = i;
232
+ }
233
+ if (e) {
234
+ let t = `https://www.youtube.com/embed/${e}`;
235
+ const o = new URLSearchParams();
236
+ return s && o.append("start", s), o.append("rel", "0"), o.append("modestbranding", "1"), this.options.autoplayVideos && o.append("autoplay", "1"), o.toString() && (t += "?" + o.toString()), t;
237
+ }
238
+ return t;
239
+ }
240
+ getThumbnailSource(t) {
241
+ var e;
242
+ if (t.dataset.thumbnail) return t.dataset.thumbnail;
243
+ const s = null === (e = t.querySelector) || void 0 === e ? void 0 : e.call(t, "img"), o = t.getAttribute("src") || (null == s ? void 0 : s.getAttribute("src"));
244
+ return "video" === (t.dataset.type || "image") ? o : o || t.dataset.src || t.getAttribute("href");
245
+ }
246
+ getGroup(t) {
247
+ return this.options.useHref ? t.dataset.lightbox || t.dataset.gallery || "default" : t.dataset.zoomora || "default";
248
+ }
249
+ open(t) {
250
+ if (!t) return;
251
+ const e = this.getGroup(t);
252
+ let s;
253
+ s = this.options.useHref ? t.dataset.lightbox ? `[data-lightbox="${e}"]` : t.dataset.gallery ? `[data-gallery="${e}"]` : this.options.selector : `[data-zoomora="${e}"]`, this.items = Array.from(document.querySelectorAll(s)), this.currentIndex = Math.max(0, this.items.indexOf(t)), this._activateLightbox(), "function" == typeof this.options.onOpen && this.options.onOpen(t, this.currentIndex);
254
+ }
255
+ openImage(t, e = {}) {
256
+ const s = Array.isArray(t) ? t : [t];
257
+ this.items = s.map((t) => this.createVirtualItem("string" == typeof t ? { src: t } : t)), this.currentIndex = Math.max(0, Math.min(e.startIndex || 0, this.items.length - 1)), this._activateLightbox(), "function" == typeof this.options.onOpen && this.options.onOpen(this.items[this.currentIndex], this.currentIndex);
258
+ }
259
+ createVirtualItem({ src: t, thumb: e, type: s = "image", caption: o = "", alt: i = "" }) {
260
+ const n = e || t;
261
+ return {
262
+ dataset: {
263
+ src: t,
264
+ type: s,
265
+ caption: o
266
+ },
267
+ src: n,
268
+ alt: i,
269
+ title: o,
270
+ getAttribute: (t) => "src" === t ? n : null
271
+ };
272
+ }
273
+ _activateLightbox() {
274
+ this.isZoomed = !1, this.isFullscreen = !1, this.thumbnailsVisible = !0, this.currentX = 0, this.currentY = 0, this.currentScale = 1, this.zoomora.classList.add("active"), document.body.style.overflow = "hidden", this.loadContent(), this.updateThumbnails(), this.updateCounter(), this.updateNavigation(), this.updateCaption(), this.updateButtons(), this.autoHideEnabled ? this.startAutoHideTimer() : this.showControls();
275
+ }
276
+ close() {
277
+ this.isFullscreen && this.exitFullscreen(), this.zoomora.classList.remove("active"), document.body.style.overflow = "";
278
+ const t = this.content.querySelector("video");
279
+ t && t.pause();
280
+ const e = this.content.querySelector("iframe");
281
+ e && (e.src = "about:blank"), this.isZoomed = !1, this.isFullscreen = !1, this.currentX = 0, this.currentY = 0, this.currentScale = 1;
282
+ const s = this.content.querySelector(".zoomora-media");
283
+ s && (s.classList.remove("zoomed"), s.style.transform = "", s.style.cursor = ""), this.zoomora.classList.remove("fullscreen"), this.updateButtons(), this.stopAutoHideTimer(), this.showControls(), "function" == typeof this.options.onClose && this.options.onClose(this.currentIndex);
284
+ }
285
+ prev() {
286
+ this.currentIndex > 0 && (this.currentIndex--, this.loadContent(), this.updateCounter(), this.updateThumbnails(), this.updateNavigation(), this.updateCaption(), "function" == typeof this.options.onPrev && this.options.onPrev(this.currentIndex));
287
+ }
288
+ next() {
289
+ this.currentIndex < this.items.length - 1 && (this.currentIndex++, this.loadContent(), this.updateCounter(), this.updateThumbnails(), this.updateNavigation(), this.updateCaption(), "function" == typeof this.options.onNext && this.options.onNext(this.currentIndex));
290
+ }
291
+ loadContent() {
292
+ if (!this.items[this.currentIndex]) return;
293
+ const t = this.items[this.currentIndex], e = this.getImageSource(t), s = t.dataset.type || "image";
294
+ e && (this.isZoomed = !1, this.currentX = 0, this.currentY = 0, this.currentScale = 1, this.loading.style.display = "block", this.slidesContainer && (this.slidesContainer.innerHTML = ""), setTimeout(() => {
295
+ this.renderContent(e, s, t);
296
+ }, 100));
297
+ }
298
+ renderContent(t, e, s) {
299
+ const o = document.createElement("div");
300
+ o.className = "zoomora-slide-container";
301
+ const i = document.createElement("div");
302
+ let n;
303
+ i.className = "zoomora-slide " + ("slide" === this.options.transition ? "slide-effect" : "fade-effect"), i.style.opacity = "0", i.style.transform = "slide" === this.options.transition ? "translateX(100%)" : "scale(0.8)";
304
+ try {
305
+ switch (e) {
306
+ case "video":
307
+ if (t.endsWith(".mp4") || t.endsWith(".webm") || t.endsWith(".ogg")) {
308
+ const e = document.createElement("div");
309
+ e.className = "zoomora-video-container", n = document.createElement("video"), n.src = t, n.className = "zoomora-video", n.setAttribute("preload", "metadata");
310
+ const i = s.src || s.getAttribute("src");
311
+ i && n.setAttribute("poster", i);
312
+ const a = document.createElement("div");
313
+ a.className = "zoomora-play-button", a.innerHTML = "<svg viewBox=\"0 0 24 24\" fill=\"currentColor\"><path d=\"M8 5v14l11-7z\"/></svg>", a.addEventListener("click", () => {
314
+ n.play(), a.style.display = "none", n.setAttribute("controls", "");
315
+ }), n.addEventListener("ended", () => {
316
+ a.style.display = "flex";
317
+ }), e.appendChild(n), e.appendChild(a), this.options.autoplayVideos && n.play().then(() => {
318
+ a.style.display = "none", n.setAttribute("controls", "");
319
+ }).catch(() => {}), o.appendChild(e);
320
+ } else n = document.createElement("iframe"), n.src = t, n.className = "zoomora-video", n.setAttribute("allowfullscreen", ""), n.setAttribute("allow", "autoplay; fullscreen; picture-in-picture"), n.setAttribute("frameborder", "0"), o.appendChild(n);
321
+ break;
322
+ case "iframe":
323
+ n = document.createElement("iframe"), n.src = t, n.className = "zoomora-iframe", n.setAttribute("frameborder", "0"), o.appendChild(n);
324
+ break;
325
+ default: n = document.createElement("img"), n.src = t, n.className = "zoomora-media", n.alt = s.alt || s.title || "", n.onload = () => {
326
+ this.loading.style.display = "none", this.checkZoomability(n), this.animateSlideIn(i);
327
+ }, n.onerror = () => {
328
+ this.loading.style.display = "none", this.animateSlideIn(i);
329
+ }, o.appendChild(n);
330
+ }
331
+ i.appendChild(o), this.slidesContainer.innerHTML = "", this.slidesContainer.appendChild(i), "image" !== e && (this.loading.style.display = "none", this.animateSlideIn(i));
332
+ } catch (t) {
333
+ this.loading.style.display = "none";
334
+ }
335
+ }
336
+ animateSlideIn(t) {
337
+ t.offsetHeight, t.classList.add("active"), "slide" === this.options.transition ? (t.style.transition = `transform ${this.options.animationDuration}ms ease, opacity ${this.options.animationDuration}ms ease`, t.style.transform = "translateX(0)", t.style.opacity = "1") : (t.style.transition = `transform ${this.options.animationDuration}ms ease, opacity ${this.options.animationDuration}ms ease`, t.style.transform = "scale(1)", t.style.opacity = "1");
338
+ }
339
+ toggleAutoHide() {
340
+ this.autoHideEnabled = !this.autoHideEnabled;
341
+ const t = document.getElementById("zoomoraAutoHideBtn");
342
+ this.autoHideEnabled ? (t.classList.add("active"), t.title = "Disable Auto-Hide Controls", this.startAutoHideTimer()) : (t.classList.remove("active"), t.title = "Enable Auto-Hide Controls", this.stopAutoHideTimer(), this.showControls());
343
+ }
344
+ handleUserActivity() {
345
+ this.autoHideEnabled && (this.showControls(), this.startAutoHideTimer());
346
+ }
347
+ startAutoHideTimer() {
348
+ this.stopAutoHideTimer(), this.autoHideTimeout = setTimeout(() => {
349
+ this.hideControls();
350
+ }, this.options.autoHideDelay);
351
+ }
352
+ stopAutoHideTimer() {
353
+ this.autoHideTimeout && (clearTimeout(this.autoHideTimeout), this.autoHideTimeout = null);
354
+ }
355
+ showControls() {
356
+ this.isControlsVisible || (this.isControlsVisible = !0, this.zoomora.classList.remove("controls-hidden"), this.header && (this.header.style.transform = "translateY(0)", this.header.style.opacity = "1"), this.caption && (this.caption.style.transform = "translateX(-50%) translateY(0)", this.caption.style.opacity = "1"), this.thumbs && (this.thumbs.style.transform = "translateX(-50%) translateY(0)", this.thumbs.style.opacity = "1"), this.prevBtn && (this.prevBtn.style.transform = "translateX(0)", this.prevBtn.style.opacity = "1"), this.nextBtn && (this.nextBtn.style.transform = "translateX(0)", this.nextBtn.style.opacity = "1"));
357
+ }
358
+ hideControls() {
359
+ this.isControlsVisible && (this.isControlsVisible = !1, this.zoomora.classList.add("controls-hidden"), this.header && (this.header.style.transform = "translateY(-100%)", this.header.style.opacity = "0"), this.caption && (this.caption.style.transform = "translateX(-50%) translateY(100%)", this.caption.style.opacity = "0"), this.thumbs && (this.thumbs.style.transform = "translateX(-50%) translateY(100%)", this.thumbs.style.opacity = "0"), this.prevBtn && (this.prevBtn.style.transform = "translateX(-100%)", this.prevBtn.style.opacity = "0"), this.nextBtn && (this.nextBtn.style.transform = "translateX(100%)", this.nextBtn.style.opacity = "0"));
360
+ }
361
+ checkZoomability(t) {
362
+ if (!t || !t.naturalWidth || !t.naturalHeight) return;
363
+ const e = t.getBoundingClientRect(), s = e.width, o = e.height, i = t.naturalWidth, n = t.naturalHeight, a = i > s || n > o, r = i / s, l = n / o, h = Math.max(r, l);
364
+ t.dataset.zoomRatio = h.toString(), t.dataset.naturalWidth = i.toString(), t.dataset.naturalHeight = n.toString(), t.dataset.renderedWidth = s.toString(), t.dataset.renderedHeight = o.toString(), a && h > 1.1 ? t.classList.remove("no-zoom") : t.classList.add("no-zoom");
365
+ }
366
+ calculateZoomLevels(t) {
367
+ if (!t || !t.naturalWidth || !t.naturalHeight) return {
368
+ canZoom: !1,
369
+ levels: [],
370
+ currentLevel: 0
371
+ };
372
+ const e = this.content.getBoundingClientRect(), s = e.width, o = e.height, i = t.naturalWidth, n = t.naturalHeight, a = s / i, r = o / n, l = Math.min(a, r);
373
+ if (l >= .95) return {
374
+ canZoom: !1,
375
+ levels: [],
376
+ currentLevel: 0
377
+ };
378
+ const h = Number(this.options.maxZoomScale), c = Number.isFinite(h) && h > 0 ? Math.max(1, h) : 3, d = [1];
379
+ [
380
+ 1.5,
381
+ 2,
382
+ 3,
383
+ 4,
384
+ 5
385
+ ].forEach((t) => {
386
+ t <= c && l * t <= 1 && d.push(t);
387
+ });
388
+ const u = Math.min(1 / l, c);
389
+ return u > d[d.length - 1] && d.push(u), {
390
+ canZoom: d.length > 1,
391
+ levels: d,
392
+ currentLevel: 0,
393
+ baseScale: l,
394
+ naturalWidth: i,
395
+ naturalHeight: n
396
+ };
397
+ }
398
+ updateCounter() {
399
+ this.options.showCounter && this.counter && (this.counter.textContent = `${this.currentIndex + 1} / ${this.items.length}`);
400
+ }
401
+ updateCaption() {
402
+ if (!this.caption || !this.items[this.currentIndex]) return;
403
+ const t = this.items[this.currentIndex], e = t.dataset.caption || t.title || "";
404
+ e ? (this.caption.textContent = e, this.caption.style.transform = "translateX(-50%) translateY(0)", this.caption.style.opacity = "1", this.caption.style.pointerEvents = "auto", this.caption.style.transition = "opacity 0.3s ease, transform 0.3s ease") : (this.caption.style.transform = "translateX(-50%) translateY(100%)", this.caption.style.opacity = "0", this.caption.style.pointerEvents = "none", this.caption.style.transition = "opacity 0.3s ease, transform 0.3s ease");
405
+ }
406
+ updateThumbnails() {
407
+ if (this.options.showThumbnails && this.thumbs) {
408
+ if (1 === this.items.length) return this.caption.classList.add("single-item-thumbnail"), void (this.thumbs.style.display = "none");
409
+ this.caption.classList.remove("single-item-thumbnail"), this.thumbs.style.display = "flex", this.thumbs.innerHTML = "", this.items.forEach((t, e) => {
410
+ const s = document.createElement("div");
411
+ s.className = "zoomora-thumb", e === this.currentIndex && s.classList.add("active");
412
+ const o = document.createElement("img"), i = this.getThumbnailSource(t);
413
+ i && (o.src = i, o.alt = t.alt || t.title || "", o.onerror = () => {
414
+ s.style.display = "none";
415
+ }), s.appendChild(o), s.addEventListener("click", () => {
416
+ this.currentIndex = e, this.loadContent(), this.updateCounter(), this.updateThumbnails(), this.updateNavigation(), this.updateCaption();
417
+ }), this.thumbs.appendChild(s);
418
+ });
419
+ }
420
+ }
421
+ updateNavigation() {
422
+ const t = document.getElementById("zoomoraPrevBtn"), e = document.getElementById("zoomoraNextBtn");
423
+ t && (t.style.display = this.currentIndex > 0 ? "flex" : "none"), e && (e.style.display = this.currentIndex < this.items.length - 1 ? "flex" : "none");
424
+ }
425
+ updateButtons() {
426
+ const t = document.getElementById("zoomoraFullscreenBtn"), e = document.getElementById("zoomoraCollapseBtn");
427
+ t && e && (this.isFullscreen ? (t.style.display = "none", e.style.display = "flex") : (t.style.display = "flex", e.style.display = "none"));
428
+ }
429
+ toggleZoom() {
430
+ const t = this.content.querySelector(".zoomora-media");
431
+ if (!t || "IMG" !== t.tagName) return;
432
+ const e = this.calculateZoomLevels(t);
433
+ if (!e.canZoom) return;
434
+ t.dataset.zoomLevel || (t.dataset.zoomLevel = "0");
435
+ let s = parseInt(t.dataset.zoomLevel) || 0;
436
+ s++, s >= e.levels.length && (s = 0);
437
+ const o = e.levels[s];
438
+ t.dataset.zoomLevel = s.toString(), 0 === s ? (this.isZoomed = !1, this.isDragging = !1, t.classList.remove("dragging"), t.style.transform = "", t.style.cursor = "pointer", t.classList.remove("zoomed"), this.currentX = 0, this.currentY = 0, this.currentScale = 1) : (this.isZoomed = !0, this.currentScale = o, this.currentX = 0, this.currentY = 0, t.style.transform = `translate(0px, 0px) scale(${o})`, t.style.cursor = "grab", t.classList.add("zoomed"));
439
+ }
440
+ toggleFullscreen() {
441
+ this.isFullscreen ? this.exitFullscreen() : this.enterFullscreen();
442
+ }
443
+ enterFullscreen() {
444
+ const t = this.zoomora;
445
+ try {
446
+ t.requestFullscreen ? t.requestFullscreen().then(() => {
476
447
  this.isFullscreen = !0, this.zoomora.classList.add("fullscreen"), this.updateButtons();
477
- }
478
- fallbackExitFullscreen() {
448
+ }).catch((t) => {
449
+ this.fallbackFullscreen();
450
+ }) : t.webkitRequestFullscreen ? (t.webkitRequestFullscreen(), this.isFullscreen = !0, this.zoomora.classList.add("fullscreen"), this.updateButtons()) : t.mozRequestFullScreen ? (t.mozRequestFullScreen(), this.isFullscreen = !0, this.zoomora.classList.add("fullscreen"), this.updateButtons()) : t.msRequestFullscreen ? (t.msRequestFullscreen(), this.isFullscreen = !0, this.zoomora.classList.add("fullscreen"), this.updateButtons()) : this.fallbackFullscreen();
451
+ } catch (t) {
452
+ this.fallbackFullscreen();
453
+ }
454
+ }
455
+ exitFullscreen() {
456
+ if (document.fullscreenElement || document.webkitFullscreenElement || document.mozFullScreenElement || document.msFullscreenElement) try {
457
+ document.exitFullscreen ? document.exitFullscreen().then(() => {
479
458
  this.isFullscreen = !1, this.zoomora.classList.remove("fullscreen"), this.updateButtons();
480
- }
481
- toggleThumbnails() {
482
- if (1 !== this.items.length && (this.thumbnailsVisible = !this.thumbnailsVisible, this.thumbs)) {
483
- if (this.thumbs.classList.toggle("thumbs-hidden", !this.thumbnailsVisible), !this.caption || !this.items[this.currentIndex]) return;
484
- const t = this.items[this.currentIndex];
485
- (t.dataset.caption || t.title) && this.thumbs.classList.contains("thumbs-hidden") ? (this.caption.style.bottom = "20px", this.caption.style.transition = "bottom 0.3s ease, transform 0.3s ease") : this.caption.style.bottom = "120px";
486
- }
487
- }
488
- startDrag(t) {
489
- const e = this.content.querySelector(".zoomora-media");
490
- if (!e || !this.isZoomed) return;
491
- this.isDragging = !0, e.classList.add("dragging"), e.style.cursor = "grabbing", this.startX = t.clientX || t.touches && t.touches[0].clientX || 0, this.startY = t.clientY || t.touches && t.touches[0].clientY || 0;
492
- const s = window.getComputedStyle(e).transform;
493
- if (s && "none" !== s) {
494
- const t = new DOMMatrix(s);
495
- this.currentX = t.m41, this.currentY = t.m42;
496
- } else this.currentX = 0, this.currentY = 0;
497
- t.preventDefault();
498
- }
499
- drag(t) {
500
- if (!this.isDragging) return;
501
- t.preventDefault();
502
- const e = this.content.querySelector(".zoomora-media");
503
- if (!e) return;
504
- const s = t.clientX || t.touches && t.touches[0].clientX || 0, o = t.clientY || t.touches && t.touches[0].clientY || 0, i = s - this.startX, n = o - this.startY;
505
- let a = this.currentX + i, r = this.currentY + n;
506
- const l = this.content.getBoundingClientRect(), h = e.getBoundingClientRect(), c = Math.max(0, (h.width - l.width) / 2), d = Math.max(0, (h.height - l.height) / 2);
507
- a = c > 0 ? Math.max(-c, Math.min(c, a)) : 0, r = d > 0 ? Math.max(-d, Math.min(d, r)) : 0, e.style.transform = `translate(${a}px, ${r}px) scale(${this.currentScale})`, this.startX = s, this.startY = o, this.currentX = a, this.currentY = r;
508
- }
509
- endDrag() {
510
- if (!this.isDragging) return;
511
- this.isDragging = !1, this.lastDragTime = Date.now();
512
- const t = this.content.querySelector(".zoomora-media");
513
- t && (t.classList.remove("dragging"), this.isZoomed && (t.style.cursor = "grab"));
514
- }
515
- goTo(t) {
516
- t < 0 || t >= this.items.length || (this.currentIndex = t, this.loadContent(), this.updateCounter(), this.updateThumbnails(), this.updateNavigation(), this.updateCaption());
517
- }
518
- getCurrentIndex() {
519
- return this.currentIndex;
520
- }
521
- getTotalItems() {
522
- return this.items.length;
523
- }
524
- isOpen() {
525
- return this.zoomora && this.zoomora.classList.contains("active");
526
- }
527
- updateOptions(t) {
528
- this.options = d(d({}, this.options), t);
529
- }
530
- refresh() {
531
- if (this.isOpen()) {
532
- const t = this.items[this.currentIndex];
533
- t && this.open(t);
534
- }
535
- }
536
- destroy() {
537
- this.isInitialized && (this.isOpen() && this.close(), this.stopAutoHideTimer(), this.eventListeners.forEach((t, e) => {
538
- t.forEach(({ element: t, event: e, handler: s, options: o }) => {
539
- t && t.removeEventListener && t.removeEventListener(e, s, o);
540
- });
541
- }), this.eventListeners.clear(), this.zoomora && this.zoomora.parentNode && this.zoomora.parentNode.removeChild(this.zoomora), this.isInitialized = !1, this.items = [], this.currentIndex = 0, this.zoomora = null, this.content = null, this.counter = null, this.thumbs = null, this.loading = null, this.caption = null);
542
- }
459
+ }).catch((t) => {
460
+ this.fallbackExitFullscreen();
461
+ }) : document.webkitExitFullscreen ? (document.webkitExitFullscreen(), this.isFullscreen = !1, this.zoomora.classList.remove("fullscreen"), this.updateButtons()) : document.mozCancelFullScreen ? (document.mozCancelFullScreen(), this.isFullscreen = !1, this.zoomora.classList.remove("fullscreen"), this.updateButtons()) : document.msExitFullscreen ? (document.msExitFullscreen(), this.isFullscreen = !1, this.zoomora.classList.remove("fullscreen"), this.updateButtons()) : this.fallbackExitFullscreen();
462
+ } catch (t) {
463
+ this.fallbackExitFullscreen();
543
464
  }
544
- return t;
545
- }, "object" == typeof e && "object" == typeof e.exports ? e.exports = i() : "function" == typeof define && define.amd ? define(i) : o.Zoomora = i();
546
- });
547
- export default m();
465
+ else this.fallbackExitFullscreen();
466
+ }
467
+ fallbackFullscreen() {
468
+ this.isFullscreen = !0, this.zoomora.classList.add("fullscreen"), this.updateButtons();
469
+ }
470
+ fallbackExitFullscreen() {
471
+ this.isFullscreen = !1, this.zoomora.classList.remove("fullscreen"), this.updateButtons();
472
+ }
473
+ toggleThumbnails() {
474
+ if (1 !== this.items.length && (this.thumbnailsVisible = !this.thumbnailsVisible, this.thumbs)) {
475
+ if (this.thumbs.classList.toggle("thumbs-hidden", !this.thumbnailsVisible), !this.caption || !this.items[this.currentIndex]) return;
476
+ const t = this.items[this.currentIndex];
477
+ (t.dataset.caption || t.title) && this.thumbs.classList.contains("thumbs-hidden") ? (this.caption.style.bottom = "20px", this.caption.style.transition = "bottom 0.3s ease, transform 0.3s ease") : this.caption.style.bottom = "120px";
478
+ }
479
+ }
480
+ startDrag(t) {
481
+ const e = this.content.querySelector(".zoomora-media");
482
+ if (!e || !this.isZoomed) return;
483
+ this.isDragging = !0, e.classList.add("dragging"), e.style.cursor = "grabbing", this.startX = t.clientX || t.touches && t.touches[0].clientX || 0, this.startY = t.clientY || t.touches && t.touches[0].clientY || 0;
484
+ const s = window.getComputedStyle(e).transform;
485
+ if (s && "none" !== s) {
486
+ const t = new DOMMatrix(s);
487
+ this.currentX = t.m41, this.currentY = t.m42;
488
+ } else this.currentX = 0, this.currentY = 0;
489
+ t.preventDefault();
490
+ }
491
+ drag(t) {
492
+ if (!this.isDragging) return;
493
+ t.preventDefault();
494
+ const e = this.content.querySelector(".zoomora-media");
495
+ if (!e) return;
496
+ const s = t.clientX || t.touches && t.touches[0].clientX || 0, o = t.clientY || t.touches && t.touches[0].clientY || 0, i = s - this.startX, n = o - this.startY;
497
+ let a = this.currentX + i, r = this.currentY + n;
498
+ const l = this.content.getBoundingClientRect(), h = e.getBoundingClientRect(), c = Math.max(0, (h.width - l.width) / 2), d = Math.max(0, (h.height - l.height) / 2);
499
+ a = c > 0 ? Math.max(-c, Math.min(c, a)) : 0, r = d > 0 ? Math.max(-d, Math.min(d, r)) : 0, e.style.transform = `translate(${a}px, ${r}px) scale(${this.currentScale})`, this.startX = s, this.startY = o, this.currentX = a, this.currentY = r;
500
+ }
501
+ endDrag() {
502
+ if (!this.isDragging) return;
503
+ this.isDragging = !1, this.lastDragTime = Date.now();
504
+ const t = this.content.querySelector(".zoomora-media");
505
+ t && (t.classList.remove("dragging"), this.isZoomed && (t.style.cursor = "grab"));
506
+ }
507
+ goTo(t) {
508
+ t < 0 || t >= this.items.length || (this.currentIndex = t, this.loadContent(), this.updateCounter(), this.updateThumbnails(), this.updateNavigation(), this.updateCaption());
509
+ }
510
+ getCurrentIndex() {
511
+ return this.currentIndex;
512
+ }
513
+ getTotalItems() {
514
+ return this.items.length;
515
+ }
516
+ isOpen() {
517
+ return this.zoomora && this.zoomora.classList.contains("active");
518
+ }
519
+ updateOptions(t) {
520
+ this.options = i(i({}, this.options), t);
521
+ }
522
+ refresh() {
523
+ if (this.isOpen()) {
524
+ const t = this.items[this.currentIndex];
525
+ t && this.open(t);
526
+ }
527
+ }
528
+ destroy() {
529
+ this.isInitialized && (this.isOpen() && this.close(), this.stopAutoHideTimer(), this.eventListeners.forEach((t, e) => {
530
+ t.forEach(({ element: t, event: e, handler: s, options: o }) => {
531
+ t && t.removeEventListener && t.removeEventListener(e, s, o);
532
+ });
533
+ }), this.eventListeners.clear(), this.zoomora && this.zoomora.parentNode && this.zoomora.parentNode.removeChild(this.zoomora), this.isInitialized = !1, this.items = [], this.currentIndex = 0, this.zoomora = null, this.content = null, this.counter = null, this.thumbs = null, this.loading = null, this.caption = null);
534
+ }
535
+ };
536
+ export { n as default };