@redot-src/glare 1.2.1 → 1.3.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.
package/dist/glare.esm.js CHANGED
@@ -1,4 +1,4 @@
1
- const it = {
1
+ const ot = {
2
2
  CLOSE: "Close",
3
3
  NEXT: "Next",
4
4
  PREV: "Previous",
@@ -13,26 +13,24 @@ const it = {
13
13
  FULL_SCREEN_EXIT: "Exit full screen",
14
14
  THUMBS: "Thumbnails",
15
15
  DOWNLOAD: "Download",
16
- SHARE: "Share",
17
16
  MORE: "More options",
18
- COPY: "Copy link",
19
17
  ZOOM: "Zoom",
20
18
  ZOOM_OUT: "Zoom out"
21
19
  };
22
- function pt(e) {
20
+ function yt(e) {
23
21
  const t = e.lang ?? "en";
24
- return { ...it, ...e.i18n?.en, ...e.i18n?.[t] };
22
+ return { ...ot, ...e.i18n?.en, ...e.i18n?.[t] };
25
23
  }
26
- function y(e, t) {
24
+ function b(e, t) {
27
25
  return e.replace(/\{\{(\w+)\}\}/g, (s, i) => t[i] ?? "");
28
26
  }
29
- function mt(e) {
27
+ function vt(e) {
30
28
  return Object.entries(e).map(([t, s]) => `${encodeURIComponent(t)}=${encodeURIComponent(String(s))}`).join("&");
31
29
  }
32
- function gt(e, t) {
30
+ function xt(e, t) {
33
31
  return e.replace(/\$(\d+)/g, (s, i) => t[Number(i)] ?? "");
34
32
  }
35
- const yt = {
33
+ const wt = {
36
34
  youtube: {
37
35
  matcher: /(?:youtube\.com|youtu\.be|youtube-nocookie\.com)\/(?:watch\?(?:.*&)?v=|v\/|u\/\w\/|embed\/|shorts\/)?([\w-]{11})/i,
38
36
  type: "embed",
@@ -50,27 +48,27 @@ const yt = {
50
48
  matcher: /(?:maps\.)?google\.([a-z]{2,3}(?:\.[a-z]{2})?)\/(?:maps\/(?:place\/[^/]+\/)?@([^/]+)|maps\?q=([^&]+)|maps\/search\/([^/?]+))/i,
51
49
  type: "iframe",
52
50
  url: (e) => {
53
- const [, t, s, i, r] = e;
51
+ const [, t, s, i, n] = e;
54
52
  if (s) {
55
- const [n, a, l] = s.split(","), d = l ? Math.floor(parseFloat(l)) : 14;
56
- return `https://maps.google.${t}/maps?ll=${n},${a}&z=${d}&output=embed`;
53
+ const [r, a, l] = s.split(","), d = l ? Math.floor(parseFloat(l)) : 14;
54
+ return `https://maps.google.${t}/maps?ll=${r},${a}&z=${d}&output=embed`;
57
55
  }
58
- const o = encodeURIComponent(decodeURIComponent(i || r || ""));
56
+ const o = encodeURIComponent(decodeURIComponent(i || n || ""));
59
57
  return `https://maps.google.${t}/maps?q=${o}&output=embed`;
60
58
  }
61
59
  }
62
60
  };
63
61
  function q(e, t, s) {
64
62
  if (typeof e == "function") return e(t, s);
65
- if (typeof e == "string") return gt(e, t);
63
+ if (typeof e == "string") return xt(e, t);
66
64
  }
67
- function bt(e, t) {
65
+ function Et(e, t) {
68
66
  for (const s of Object.values(t ?? {})) {
69
67
  const i = e.match(s.matcher);
70
68
  if (!i) continue;
71
- let r = q(s.url, i, e) ?? e;
72
- return s.params && (r += (r.includes("?") ? "&" : "?") + mt(s.params)), {
73
- src: r,
69
+ let n = q(s.url, i, e) ?? e;
70
+ return s.params && (n += (n.includes("?") ? "&" : "?") + vt(s.params)), {
71
+ src: n,
74
72
  type: s.type ?? "iframe",
75
73
  thumb: q(s.thumb, i, e)
76
74
  };
@@ -84,14 +82,13 @@ const f = (e) => `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fi
84
82
  zoomIn: f('<circle cx="11" cy="11" r="8"/><path d="m21 21-4.3-4.3"/><path d="M11 8v6"/><path d="M8 11h6"/>'),
85
83
  zoomOut: f('<circle cx="11" cy="11" r="8"/><path d="m21 21-4.3-4.3"/><path d="M8 11h6"/>'),
86
84
  download: f('<path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="7 10 12 15 17 10"/><line x1="12" x2="12" y1="15" y2="3"/>'),
87
- share: f('<circle cx="18" cy="5" r="3"/><circle cx="6" cy="12" r="3"/><circle cx="18" cy="19" r="3"/><line x1="8.59" x2="15.42" y1="13.51" y2="17.49"/><line x1="15.41" x2="8.59" y1="6.51" y2="10.49"/>'),
88
85
  thumbs: f('<rect width="18" height="18" x="3" y="3" rx="2"/><path d="M3 9h18"/><path d="M9 21V9"/>'),
89
86
  play: f('<polygon points="6 3 20 12 6 21 6 3"/>'),
90
87
  pause: f('<rect width="4" height="16" x="6" y="4"/><rect width="4" height="16" x="14" y="4"/>'),
91
88
  fullscreen: f('<path d="M8 3H5a2 2 0 0 0-2 2v3"/><path d="M21 8V5a2 2 0 0 0-2-2h-3"/><path d="M3 16v3a2 2 0 0 0 2 2h3"/><path d="M16 21h3a2 2 0 0 0 2-2v-3"/>'),
92
89
  fullscreenExit: f('<path d="M8 3v3a2 2 0 0 1-2 2H3"/><path d="M21 8h-3a2 2 0 0 1-2-2V3"/><path d="M3 16h3a2 2 0 0 1 2 2v3"/><path d="M16 21v-3a2 2 0 0 1 2-2h3"/>'),
93
90
  more: f('<circle cx="5" cy="12" r="1" fill="currentColor" stroke="none"/><circle cx="12" cy="12" r="1" fill="currentColor" stroke="none"/><circle cx="19" cy="12" r="1" fill="currentColor" stroke="none"/>')
94
- }, v = (e, t, s, i = "") => `<button type="button" class="glare-button glare-button--${e}" data-glare-${e} title="{{${t}}}" aria-label="{{${t}}}"${i}>${s}</button>`, vt = `
91
+ }, v = (e, t, s, i = "") => `<button type="button" class="glare-button glare-button--${e}" data-glare-${e} title="{{${t}}}" aria-label="{{${t}}}"${i}>${s}</button>`, Tt = `
95
92
  <div class="glare-container" role="dialog" aria-modal="true" tabindex="-1">
96
93
  <div class="glare-bg"></div>
97
94
  <div class="glare-progress" hidden></div>
@@ -106,38 +103,25 @@ const f = (e) => `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fi
106
103
  <div class="glare-stage"></div>
107
104
  <div class="glare-caption"></div>
108
105
  </div>
109
- </div>`, xt = {
106
+ </div>`, St = {
110
107
  zoom: v("zoom", "ZOOM", u.zoomIn),
111
108
  slideshow: v("slideshow", "PLAY_START", u.play),
112
109
  thumbs: v("thumbs", "THUMBS", u.thumbs, ' aria-expanded="false"'),
113
- share: v("share", "SHARE", u.share),
114
110
  fullscreen: v("fullscreen", "FULL_SCREEN", u.fullscreen),
115
111
  more: v("more", "MORE", u.more, ' aria-expanded="false" aria-haspopup="true"'),
116
112
  close: v("close", "CLOSE", u.close),
117
113
  download: `<a class="glare-button glare-button--download" data-glare-download download target="_blank" rel="noopener" title="{{DOWNLOAD}}" aria-label="{{DOWNLOAD}}">${u.download}</a>`,
118
114
  smallBtn: `<button type="button" class="glare-button glare-close-small" data-glare-close title="{{CLOSE}}" aria-label="{{CLOSE}}">${u.close}</button>`
119
- }, wt = '<div class="glare-spinner" role="status" aria-label="{{LOADING}}"></div>', Et = '<div class="glare-error"><p>{{ERROR}}</p></div>', St = '<video class="glare-video" controls playsinline controlsList="nodownload" poster="{{poster}}"><source src="{{src}}" type="{{format}}"/>{{VIDEO_UNSUPPORTED}}</video>', Tt = '<iframe class="glare-iframe"></iframe>', Lt = `
120
- <div class="glare-share" role="dialog" aria-label="{{SHARE}}">
121
- <div class="glare-share-head">
122
- <h4 class="glare-share-title">{{SHARE}}</h4>
123
- <button type="button" class="glare-button glare-share-close" data-glare-share-close title="{{CLOSE}}" aria-label="{{CLOSE}}">${u.close}</button>
124
- </div>
125
- <p><a class="glare-share-link" href="{{url_facebook}}" target="_blank" rel="noopener">Facebook</a></p>
126
- <p><a class="glare-share-link" href="{{url_twitter}}" target="_blank" rel="noopener">X / Twitter</a></p>
127
- <p><a class="glare-share-link" href="{{url_pinterest}}" target="_blank" rel="noopener">Pinterest</a></p>
128
- <div class="glare-share-row">
129
- <input class="glare-share-input" type="text" value="{{url_direct}}" readonly />
130
- <button type="button" class="glare-share-copy" data-glare-share-copy>{{COPY}}</button>
131
- </div>
132
- </div>`, rt = {
115
+ }, Lt = '<div class="glare-spinner" role="status" aria-label="{{LOADING}}"></div>', Mt = '<div class="glare-error"><p>{{ERROR}}</p></div>', Ct = '<video class="glare-video" controls playsinline controlsList="nodownload" poster="{{poster}}"><source src="{{src}}" type="{{format}}"/>{{VIDEO_UNSUPPORTED}}</video>', $t = '<iframe class="glare-iframe"></iframe>', rt = {
133
116
  autoStart: !1,
134
- axis: "x"
135
- }, z = {
117
+ axis: "x",
118
+ fit: "cover"
119
+ }, _ = {
136
120
  autoStart: !1,
137
121
  speed: 3e3
138
- }, ot = {
122
+ }, at = {
139
123
  autoStart: !1
140
- }, nt = {
124
+ }, lt = {
141
125
  closeExisting: !1,
142
126
  loop: !1,
143
127
  keyboard: !0,
@@ -156,9 +140,10 @@ const f = (e) => `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fi
156
140
  infobar: !0,
157
141
  toolbar: "auto",
158
142
  smallBtn: "auto",
159
- buttons: ["zoom", "slideshow", "thumbs", "share", "download", "fullscreen", "close"],
143
+ buttons: ["zoom", "slideshow", "thumbs", "download", "fullscreen", "close"],
160
144
  animationEffect: "zoom",
161
145
  animationDuration: 366,
146
+ anchor: "trigger",
162
147
  zoomOpacity: !0,
163
148
  transitionEffect: "fade",
164
149
  transitionDuration: 366,
@@ -176,66 +161,65 @@ const f = (e) => `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fi
176
161
  dblclickSlide: (e) => e.type === "image" ? "zoom" : !1
177
162
  },
178
163
  image: { preload: !1 },
179
- video: { tpl: St, format: "", autoStart: !0 },
164
+ video: { tpl: Ct, format: "", autoStart: !0 },
180
165
  iframe: {
181
166
  preload: !0,
182
167
  css: {},
183
168
  attr: { allowfullscreen: "true", allow: "autoplay; fullscreen; picture-in-picture" },
184
- tpl: Tt
169
+ tpl: $t
185
170
  },
186
171
  ajax: { settings: { headers: { "X-Requested-With": "XMLHttpRequest" } } },
187
- media: yt,
172
+ media: wt,
188
173
  hash: !0,
189
- slideshow: z,
174
+ slideshow: _,
190
175
  thumbs: rt,
191
- fullscreen: ot,
192
- share: !0,
176
+ fullscreen: at,
193
177
  lang: "en",
194
- i18n: { en: it },
195
- baseTpl: vt,
196
- btnTpl: xt,
197
- spinnerTpl: wt,
198
- errorTpl: Et
199
- }, Ct = /\.(avif|bmp|gif|jpe?g|png|svg|webp|ico)(\?.*)?$/i, Mt = /\.(mp4|webm|ogg|ogv|mov|m4v)(\?.*)?$/i, $t = /\.pdf(\?.*)?$/i, Ot = /^(#[\w-]+|\.[\w-]+)$/;
200
- function At(e, t = "image") {
201
- return e ? Ot.test(e) ? "inline" : Ct.test(e) ? "image" : Mt.test(e) ? "video" : $t.test(e) ? "iframe" : t : "html";
202
- }
203
- function It(e) {
178
+ i18n: { en: ot },
179
+ baseTpl: Tt,
180
+ btnTpl: St,
181
+ spinnerTpl: Lt,
182
+ errorTpl: Mt
183
+ }, Ot = /\.(avif|bmp|gif|jpe?g|png|svg|webp|ico)(\?.*)?$/i, It = /\.(mp4|webm|ogg|ogv|mov|m4v)(\?.*)?$/i, At = /\.pdf(\?.*)?$/i, Dt = /^(#[\w-]+|\.[\w-]+)$/;
184
+ function kt(e, t = "image") {
185
+ return e ? Dt.test(e) ? "inline" : Ot.test(e) ? "image" : It.test(e) ? "video" : At.test(e) ? "iframe" : t : "html";
186
+ }
187
+ function Rt(e) {
204
188
  const t = e.match(/\.(\w+)(?:\?|$)/)?.[1]?.toLowerCase();
205
189
  return t ? `video/${t === "ogv" ? "ogg" : t}` : "video/mp4";
206
190
  }
207
- function at(e, t, s) {
191
+ function ct(e, t, s) {
208
192
  const i = typeof e == "string" ? { src: e } : { ...e };
209
- let r = i.src ?? "", o = i.type, n = i.thumb;
210
- const a = r ? bt(r, s.media) : null;
211
- return a && (r = a.src ?? r, o ??= a.type, n ??= a.thumb), o || (o = i.html || i.content ? "html" : At(r, s.defaultType)), {
193
+ let n = i.src ?? "", o = i.type, r = i.thumb;
194
+ const a = n ? Et(n, s.media) : null;
195
+ return a && (n = a.src ?? n, o ??= a.type, r ??= a.thumb), o || (o = i.html || i.content ? "html" : kt(n, s.defaultType)), {
212
196
  ...i,
213
197
  index: t,
214
- src: r,
198
+ src: n,
215
199
  type: o,
216
- thumb: n,
200
+ thumb: r,
217
201
  caption: i.caption ?? i.title ?? "",
218
202
  isLoaded: !1,
219
203
  hasError: !1
220
204
  };
221
205
  }
222
- const m = (e, t) => e.getAttribute(t) || void 0;
223
- function Dt(e, t) {
206
+ const p = (e, t) => e.getAttribute(t) || void 0;
207
+ function Ft(e, t) {
224
208
  return e.map((s, i) => {
225
- const r = s.querySelector("img"), o = m(s, "data-caption") ?? m(s, "title") ?? "";
226
- return at(
209
+ const n = s.querySelector("img"), o = p(s, "data-caption") ?? p(s, "title") ?? "";
210
+ return ct(
227
211
  {
228
- src: m(s, "data-src") ?? m(s, "href") ?? "",
229
- type: m(s, "data-type"),
212
+ src: p(s, "data-src") ?? p(s, "href") ?? "",
213
+ type: p(s, "data-type"),
230
214
  caption: o,
231
- alt: r?.getAttribute("alt") || o,
232
- thumb: m(s, "data-thumb") ?? r?.getAttribute("src") ?? void 0,
233
- width: m(s, "data-width"),
234
- height: m(s, "data-height"),
235
- ratio: m(s, "data-ratio"),
236
- poster: m(s, "data-poster"),
237
- downloadSrc: m(s, "data-download-src"),
238
- html: m(s, "data-html"),
215
+ alt: n?.getAttribute("alt") || o,
216
+ thumb: p(s, "data-thumb") ?? n?.getAttribute("src") ?? void 0,
217
+ width: p(s, "data-width"),
218
+ height: p(s, "data-height"),
219
+ ratio: p(s, "data-ratio"),
220
+ poster: p(s, "data-poster"),
221
+ downloadSrc: p(s, "data-download-src"),
222
+ html: p(s, "data-html"),
239
223
  $trigger: s
240
224
  },
241
225
  i,
@@ -243,8 +227,8 @@ function Dt(e, t) {
243
227
  );
244
228
  });
245
229
  }
246
- function kt(e, t) {
247
- return e.length && e[0] instanceof HTMLElement ? Dt(e, t) : e.map((s, i) => at(s, i, t));
230
+ function Ht(e, t) {
231
+ return e.length && e[0] instanceof HTMLElement ? Ft(e, t) : e.map((s, i) => ct(s, i, t));
248
232
  }
249
233
  function c(e, t = document) {
250
234
  return t.querySelector(e);
@@ -252,179 +236,212 @@ function c(e, t = document) {
252
236
  function $(e, t = document) {
253
237
  return Array.from(t.querySelectorAll(e));
254
238
  }
255
- function g(e, t = "", s = "") {
239
+ function m(e, t = "", s = "") {
256
240
  const i = document.createElement(e);
257
241
  return t && (i.className = t), s && (i.innerHTML = s), i;
258
242
  }
259
- function Rt(e) {
260
- return g("div", "", e.trim()).firstElementChild;
243
+ function Pt(e) {
244
+ return m("div", "", e.trim()).firstElementChild;
261
245
  }
262
- function O(e) {
246
+ function N(e) {
263
247
  return /[<&]/.test(e) ? new DOMParser().parseFromString(e, "text/html").body.textContent?.trim() ?? "" : e.trim();
264
248
  }
265
- function _t(e, t = document) {
249
+ function ht(e, t = document) {
266
250
  return e ? typeof e != "string" ? e : c(e, t) ?? c(e) : null;
267
251
  }
268
- function U(e) {
252
+ function j(e) {
269
253
  return typeof e == "number" ? `${e}px` : e;
270
254
  }
271
255
  function h(e, t, s, i) {
272
256
  return e.addEventListener(t, s, i), () => e.removeEventListener(t, s, i);
273
257
  }
274
- function lt(e) {
258
+ function ut(e) {
275
259
  requestAnimationFrame(() => requestAnimationFrame(e));
276
260
  }
277
- function Ft(e, t, s) {
261
+ function zt(e, t, s) {
278
262
  let i = !1;
279
- const r = () => {
280
- i || (i = !0, clearTimeout(n), e.removeEventListener("transitionend", o), s());
263
+ const n = () => {
264
+ i || (i = !0, clearTimeout(r), e.removeEventListener("transitionend", o), s());
281
265
  }, o = (a) => {
282
- a.target === e && r();
266
+ a.target === e && n();
283
267
  };
284
268
  e.addEventListener("transitionend", o);
285
- const n = setTimeout(r, t + 50);
269
+ const r = setTimeout(n, t + 50);
286
270
  }
287
- function Ht() {
271
+ function _t() {
288
272
  return navigator.maxTouchPoints > 0 && window.matchMedia("(pointer: coarse)").matches;
289
273
  }
290
- function A() {
274
+ function dt() {
291
275
  return window.matchMedia("(prefers-reduced-motion: reduce)").matches;
292
276
  }
293
- function ct() {
277
+ function ft() {
294
278
  const e = document;
295
279
  return !!(e.fullscreenEnabled ?? e.webkitFullscreenEnabled);
296
280
  }
297
- const B = "glare-lock";
298
- function W(e) {
281
+ const W = "glare-lock";
282
+ function U(e) {
299
283
  const t = document.documentElement;
300
284
  if (e) {
301
285
  const s = window.innerWidth - t.clientWidth;
302
- t.classList.add(B), s > 0 && (t.style.marginRight = `${s}px`);
286
+ t.classList.add(W), s > 0 && (t.style.marginRight = `${s}px`);
303
287
  } else
304
- t.classList.remove(B), t.style.marginRight = "";
288
+ t.classList.remove(W), t.style.marginRight = "";
305
289
  }
306
- const S = "glare-hidden";
307
- function Pt(e, t, s, i) {
308
- const r = Rt(y(e.baseTpl, t));
309
- r.dataset.glareId = String(s), e.baseClass && r.classList.add(e.baseClass), e.modal && r.classList.add("glare-is-modal");
310
- const o = c(".glare-stage", r);
290
+ const T = "glare-hidden";
291
+ function Nt(e, t, s, i) {
292
+ const n = Pt(b(e.baseTpl, t));
293
+ n.dataset.glareId = String(s), e.baseClass && n.classList.add(e.baseClass), e.modal && n.classList.add("glare-is-modal");
294
+ const o = c(".glare-stage", n);
311
295
  if (!o) throw new Error("baseTpl must contain a .glare-stage element");
312
- const n = {
313
- container: r,
314
- bg: c(".glare-bg", r),
315
- inner: c(".glare-inner", r),
296
+ const r = {
297
+ container: n,
298
+ bg: c(".glare-bg", n),
299
+ inner: c(".glare-inner", n),
316
300
  stage: o,
317
- caption: c(".glare-caption", r),
318
- toolbar: c(".glare-toolbar", r),
319
- infobar: c(".glare-infobar", r),
320
- navigation: c(".glare-navigation", r)
301
+ caption: c(".glare-caption", n),
302
+ toolbar: c(".glare-toolbar", n),
303
+ infobar: c(".glare-infobar", n),
304
+ navigation: c(".glare-navigation", n)
321
305
  }, a = i < 2;
322
- return n.navigation?.classList.toggle(S, !e.arrows || a), n.infobar?.classList.toggle(S, !e.infobar || a), n.toolbar && zt(n.toolbar, e, t, a), n;
306
+ return r.navigation?.classList.toggle(T, !e.arrows || a), r.infobar?.classList.toggle(T, !e.infobar || a), r.toolbar && Zt(r.toolbar, e, t, a), r;
323
307
  }
324
- function zt(e, t, s, i) {
308
+ function Zt(e, t, s, i) {
325
309
  if (t.toolbar === !1) {
326
- e.classList.add(S);
310
+ e.classList.add(T);
327
311
  return;
328
312
  }
329
- const r = g("div", "glare-toolbar-menu");
330
- r.id = `glare-toolbar-menu-${e.closest(".glare-container")?.dataset.glareId ?? ""}`;
313
+ const n = m("div", "glare-toolbar-menu");
314
+ n.id = `glare-toolbar-menu-${e.closest(".glare-container")?.dataset.glareId ?? ""}`;
331
315
  for (const o of t.buttons) {
332
- if (i && (o === "thumbs" || o === "slideshow") || o === "fullscreen" && !ct() || o === "more" || o === "close") continue;
333
- const n = t.btnTpl[o];
334
- n && r.insertAdjacentHTML("beforeend", y(n, s));
316
+ if (typeof o != "string") {
317
+ n.appendChild(Bt(o));
318
+ continue;
319
+ }
320
+ if (i && (o === "thumbs" || o === "slideshow") || o === "fullscreen" && !ft() || o === "more" || o === "close") continue;
321
+ const r = t.btnTpl[o];
322
+ r && n.insertAdjacentHTML("beforeend", b(r, s));
335
323
  }
336
- if (r.childElementCount) {
337
- e.appendChild(r);
324
+ if (n.childElementCount) {
325
+ e.appendChild(n);
338
326
  const o = t.btnTpl.more;
339
- o && (e.insertAdjacentHTML("beforeend", y(o, s)), e.querySelector("[data-glare-more]")?.setAttribute("aria-controls", r.id));
327
+ o && (e.insertAdjacentHTML("beforeend", b(o, s)), e.querySelector("[data-glare-more]")?.setAttribute("aria-controls", n.id));
340
328
  }
341
329
  if (t.buttons.includes("close")) {
342
330
  const o = t.btnTpl.close;
343
- o && e.insertAdjacentHTML("beforeend", y(o, s));
331
+ o && e.insertAdjacentHTML("beforeend", b(o, s));
344
332
  }
345
333
  }
346
- function Nt(e, t, s) {
347
- const i = g("div", `glare-slide glare-slide--${t.type}`);
348
- s.slideClass && i.classList.add(s.slideClass);
349
- const r = g("div", "glare-content");
350
- return i.appendChild(r), e.appendChild(i), t.$slide = i, t.$content = r, i;
334
+ function Bt({ name: e, label: t, icon: s }) {
335
+ const i = m("button", `glare-button glare-button--${e}`, s);
336
+ return i.type = "button", i.title = t, i.dataset.glareCustom = e, i.setAttribute("aria-label", t), i;
351
337
  }
352
- function Zt(e, t) {
353
- t && (e.style.transition = "none"), e.offsetWidth, e.classList.add("glare-slide--current"), t && (e.offsetWidth, e.style.transition = "");
338
+ function qt(e, t) {
339
+ let s = 0;
340
+ for (let i = e; i instanceof HTMLElement && i !== t; i = i.offsetParent)
341
+ s += i.offsetTop;
342
+ return s;
354
343
  }
355
- function qt(e, t, s) {
356
- for (const i of $(".glare-slide", e))
357
- i !== t && (i.classList.remove("glare-slide--current"), i.classList.add("glare-slide--out"), setTimeout(() => i.remove(), s));
344
+ function jt({ container: e, caption: t }) {
345
+ let s = null;
346
+ const i = () => {
347
+ if (!t) return;
348
+ e.style.setProperty("--glare-caption-inset", `${t.offsetHeight}px`);
349
+ const o = s && c(".glare-content", s);
350
+ o && Object.assign(t.style, { top: `${qt(o, t.offsetParent) + o.offsetHeight}px`, bottom: "auto" });
351
+ }, n = new ResizeObserver(i);
352
+ return t && n.observe(t), i(), {
353
+ follow(o) {
354
+ if (s)
355
+ for (const r of [s, c(".glare-content", s)]) r && n.unobserve(r);
356
+ s = o;
357
+ for (const r of [o, c(".glare-content", o)]) r && n.observe(r);
358
+ i();
359
+ },
360
+ destroy: () => n.disconnect()
361
+ };
362
+ }
363
+ function Wt(e, t, s) {
364
+ const i = m("div", `glare-slide glare-slide--${t.type}`);
365
+ s.slideClass && i.classList.add(s.slideClass);
366
+ const n = m("div", "glare-content");
367
+ return i.appendChild(n), e.appendChild(i), t.$slide = i, t.$content = n, i;
358
368
  }
359
369
  function Ut(e, t, s) {
360
- e.insertAdjacentHTML("beforeend", y(t.btnTpl.smallBtn ?? "", s));
370
+ e.style.setProperty("--glare-direction", String(s)), e.classList.add(t ? "glare-slide--opening" : "glare-slide--in"), t && (e.style.transition = "none"), e.offsetWidth, e.classList.add("glare-slide--current"), t && (e.offsetWidth, e.style.transition = "");
371
+ }
372
+ function Xt(e, t, s, i) {
373
+ for (const n of $(".glare-slide", e))
374
+ n !== t && (n.classList.contains("glare-slide--out") || n.style.setProperty("--glare-direction", String(i)), n.classList.remove("glare-slide--current", "glare-slide--in", "glare-slide--opening"), n.classList.add("glare-slide--out"), setTimeout(() => n.remove(), s));
361
375
  }
362
- function Bt(e, t, s) {
363
- e.querySelector(":scope > .glare-spinner") || e.insertAdjacentHTML("beforeend", y(t.spinnerTpl, s));
376
+ function Gt(e, t, s) {
377
+ e.insertAdjacentHTML("beforeend", b(t.btnTpl.smallBtn ?? "", s));
378
+ }
379
+ function Vt(e, t, s) {
380
+ e.querySelector(":scope > .glare-spinner") || e.insertAdjacentHTML("beforeend", b(t.spinnerTpl, s));
364
381
  }
365
- function Wt(e) {
382
+ function Yt(e) {
366
383
  e.querySelector(":scope > .glare-spinner")?.remove();
367
384
  }
368
- function jt(e, t, s, i) {
369
- e.hasError = !0, e.error = t, e.$content && (e.$content.className = "glare-content glare-content--error", e.$content.innerHTML = y(s.errorTpl, i));
385
+ function Kt(e, t, s, i) {
386
+ e.hasError = !0, e.error = t, e.$content && (e.$content.className = "glare-content glare-content--error", e.$content.innerHTML = b(s.errorTpl, i));
370
387
  }
371
- function ht(e, t) {
388
+ function pt(e, t) {
372
389
  return typeof e.toolbar == "boolean" ? e.toolbar : t.type === "image";
373
390
  }
374
- function Xt(e, t) {
375
- return typeof e.smallBtn == "boolean" ? e.smallBtn : !ht(e, t);
391
+ function Qt(e, t) {
392
+ return typeof e.smallBtn == "boolean" ? e.smallBtn : !pt(e, t);
376
393
  }
377
- function Yt(e, t, s, i, r, o) {
378
- const { container: n, toolbar: a, infobar: l } = e;
379
- ee(n, i.type), a && Gt(a, t, i), Vt(n, i), l && Kt(l, i.index, r), e.caption && Qt(e.caption, o), Jt(n, t, i.index, r), te(n, s, i, r);
394
+ function Jt(e, t, s, i, n, o) {
395
+ const { container: r, toolbar: a, infobar: l } = e;
396
+ re(r, i.type), a && te(a, t, i), ee(r, i), l && se(l, i.index, n), e.caption && ie(e.caption, o), ne(r, t, i.index, n), oe(r, s, i, n);
380
397
  }
381
- function Gt(e, t, s) {
398
+ function te(e, t, s) {
382
399
  if (t.toolbar === !1) return;
383
400
  e.classList.remove("glare-toolbar--expanded"), e.querySelector("[data-glare-more]")?.setAttribute("aria-expanded", "false");
384
- const i = ht(t, s);
385
- if (e.classList.toggle(S, !i), !i) return;
386
- const r = s.type === "image";
387
- c("[data-glare-zoom]", e)?.classList.toggle(S, !r);
401
+ const i = pt(t, s);
402
+ if (e.classList.toggle(T, !i), !i) return;
403
+ const n = s.type === "image";
404
+ c("[data-glare-zoom]", e)?.classList.toggle(T, !n);
388
405
  }
389
- function Vt(e, t) {
406
+ function ee(e, t) {
390
407
  const s = e.querySelector("[data-glare-download]");
391
408
  if (!s) return;
392
409
  const i = t.downloadSrc || (t.type === "image" ? t.src : "");
393
- s.classList.toggle(S, !i), i && (s.href = i);
410
+ s.classList.toggle(T, !i), i && (s.href = i);
394
411
  }
395
- function Kt(e, t, s) {
412
+ function se(e, t, s) {
396
413
  const i = c(".glare-infobar-index", e);
397
414
  i && (i.textContent = `${t + 1} / ${s}`);
398
415
  }
399
- function Qt(e, t) {
400
- e.innerHTML = t, e.classList.toggle(S, !t);
416
+ function ie(e, t) {
417
+ e.innerHTML = t, e.classList.toggle(T, !t);
401
418
  }
402
- function Jt(e, t, s, i) {
403
- const r = !t.loop && s === 0, o = !t.loop && s === i - 1;
404
- j(c("[data-glare-prev]", e), r), j(c("[data-glare-next]", e), o);
419
+ function ne(e, t, s, i) {
420
+ const n = !t.loop && s === 0, o = !t.loop && s === i - 1;
421
+ X(c("[data-glare-prev]", e), n), X(c("[data-glare-next]", e), o);
405
422
  }
406
- function j(e, t) {
423
+ function X(e, t) {
407
424
  e && (e.classList.toggle("glare-is-disabled", t), e.setAttribute("aria-disabled", String(t)));
408
425
  }
409
- function te(e, t, s, i) {
410
- const r = O(s.caption) || s.alt || t.LIGHTBOX, o = i > 1 ? `${r} (${s.index + 1} of ${i})` : r;
426
+ function oe(e, t, s, i) {
427
+ const n = N(s.caption) || s.alt || t.LIGHTBOX, o = i > 1 ? `${n} (${s.index + 1} of ${i})` : n;
411
428
  e.setAttribute("aria-label", o);
412
- const n = c(".glare-live", e);
413
- n && (n.textContent = o);
429
+ const r = c(".glare-live", e);
430
+ r && (r.textContent = o);
414
431
  }
415
- function ee(e, t) {
432
+ function re(e, t) {
416
433
  const s = e.dataset.type;
417
434
  s && e.classList.remove(`glare-type-${s}`), e.dataset.type = t, e.classList.add(`glare-type-${t}`);
418
435
  }
419
- function se(e, t, s, i) {
436
+ function ae(e, t, s, i) {
420
437
  e.classList.toggle("glare-can-zoom-out", s), e.classList.toggle("glare-can-zoom-in", !s && i);
421
- const r = c("[data-glare-zoom]", e), o = s ? "out" : "in";
422
- !r || r.dataset.state === o || (r.dataset.state = o, N(r, s, s ? t.ZOOM_OUT : t.ZOOM, s ? u.zoomOut : u.zoomIn));
438
+ const n = c("[data-glare-zoom]", e), o = s ? "out" : "in";
439
+ !n || n.dataset.state === o || (n.dataset.state = o, Z(n, s, s ? t.ZOOM_OUT : t.ZOOM, s ? u.zoomOut : u.zoomIn));
423
440
  }
424
- function N(e, t, s, i) {
441
+ function Z(e, t, s, i) {
425
442
  e.setAttribute("title", s), e.setAttribute("aria-label", s), e.innerHTML = i, e.classList.toggle("glare-is-active", t);
426
443
  }
427
- class ie {
444
+ class le {
428
445
  constructor(t, s, i) {
429
446
  this.glare = t, this.container = s, this.offs = [
430
447
  h(document, "fullscreenchange", () => this.sync()),
@@ -456,7 +473,7 @@ class ie {
456
473
  const s = c("[data-glare-fullscreen]", this.container);
457
474
  if (!s) return;
458
475
  const { dict: i } = this.glare;
459
- N(
476
+ Z(
460
477
  s,
461
478
  t,
462
479
  t ? i.FULL_SCREEN_EXIT : i.FULL_SCREEN,
@@ -464,7 +481,7 @@ class ie {
464
481
  );
465
482
  }
466
483
  }
467
- function X(e) {
484
+ function G(e) {
468
485
  if (typeof e != "object" || e === null) return !1;
469
486
  const t = Object.getPrototypeOf(e);
470
487
  return t === Object.prototype || t === null;
@@ -473,23 +490,23 @@ function R(...e) {
473
490
  const t = {};
474
491
  for (const s of e)
475
492
  if (s)
476
- for (const [i, r] of Object.entries(s)) {
477
- if (r === void 0) continue;
493
+ for (const [i, n] of Object.entries(s)) {
494
+ if (n === void 0) continue;
478
495
  const o = t[i];
479
- t[i] = X(r) ? R(X(o) ? o : {}, r) : r;
496
+ t[i] = G(n) ? R(G(o) ? o : {}, n) : n;
480
497
  }
481
498
  return t;
482
499
  }
483
- function E(e, t, s) {
500
+ function w(e, t, s) {
484
501
  return Math.min(s, Math.max(t, e));
485
502
  }
486
- const T = 1, _ = 5, re = 1.01;
487
- class oe {
503
+ const S = 1, F = 5, ce = 1.01;
504
+ class he {
488
505
  constructor(t) {
489
- this.target = t, this.scale = T, this.x = 0, this.y = 0;
506
+ this.target = t, this.scale = S, this.x = 0, this.y = 0;
490
507
  }
491
508
  get isZoomed() {
492
- return this.scale > re;
509
+ return this.scale > ce;
493
510
  }
494
511
  get state() {
495
512
  return { scale: this.scale, x: this.x, y: this.y };
@@ -501,37 +518,37 @@ class oe {
501
518
  const s = t.getBoundingClientRect();
502
519
  return { x: s.left + s.width / 2 - this.x, y: s.top + s.height / 2 - this.y };
503
520
  }
504
- apply(t, s, i, r = 0) {
521
+ apply(t, s, i, n = 0) {
505
522
  const o = this.target.image();
506
523
  if (!o) return;
507
- this.scale = E(t, T, _);
508
- const n = this.isZoomed ? this.bounded(s, i) : { x: 0, y: 0 };
509
- this.x = n.x, this.y = n.y, o.style.transitionDuration = `${r}ms`, o.style.transform = `translate3d(${this.x}px, ${this.y}px, 0) scale(${this.scale})`, this.target.onChange(this.isZoomed);
524
+ this.scale = w(t, S, F);
525
+ const r = this.isZoomed ? this.bounded(s, i) : { x: 0, y: 0 };
526
+ this.x = r.x, this.y = r.y, o.style.transitionDuration = `${n}ms`, o.style.transform = `translate3d(${this.x}px, ${this.y}px, 0) scale(${this.scale})`, this.target.onChange(this.isZoomed);
510
527
  }
511
528
  toFit(t = 300) {
512
- this.apply(T, 0, 0, t);
529
+ this.apply(S, 0, 0, t);
513
530
  }
514
531
  /** Zooms to the image's natural size (at least 1.5x), keeping `focus` under the pointer. */
515
532
  toActual(t, s = 300) {
516
- const i = this.target.image(), r = this.center();
517
- if (!i || !r) return;
518
- const o = i.naturalWidth / Math.max(i.offsetWidth, 1), n = E(Math.max(o, 1.5), T, _), a = t?.x ?? r.x, l = t?.y ?? r.y;
519
- this.apply(n, (r.x - a) * (n - 1), (r.y - l) * (n - 1), s);
533
+ const i = this.target.image(), n = this.center();
534
+ if (!i || !n) return;
535
+ const o = i.naturalWidth / Math.max(i.offsetWidth, 1), r = w(Math.max(o, 1.5), S, F), a = t?.x ?? n.x, l = t?.y ?? n.y;
536
+ this.apply(r, (n.x - a) * (r - 1), (n.y - l) * (r - 1), s);
520
537
  }
521
538
  reset() {
522
539
  const t = this.target.image();
523
- t && (t.style.transform = "", t.style.transitionDuration = ""), this.scale = T, this.x = 0, this.y = 0, this.target.onChange(!1);
540
+ t && (t.style.transform = "", t.style.transitionDuration = ""), this.scale = S, this.x = 0, this.y = 0, this.target.onChange(!1);
524
541
  }
525
542
  /** Keeps the scaled image from being dragged fully out of the stage. */
526
543
  bounded(t, s) {
527
- const i = this.target.image(), r = this.target.stage();
528
- if (!i || !r) return { x: t, y: s };
529
- const o = Math.max(0, (i.offsetWidth * this.scale - r.clientWidth) / 2), n = Math.max(0, (i.offsetHeight * this.scale - r.clientHeight) / 2);
530
- return { x: E(t, -o, o), y: E(s, -n, n) };
544
+ const i = this.target.image(), n = this.target.stage();
545
+ if (!i || !n) return { x: t, y: s };
546
+ const o = Math.max(0, (i.offsetWidth * this.scale - n.clientWidth) / 2), r = Math.max(0, (i.offsetHeight * this.scale - n.clientHeight) / 2);
547
+ return { x: w(t, -o, o), y: w(s, -r, r) };
531
548
  }
532
549
  }
533
- const ne = 6, Y = 120, ae = 100, le = 0.5, ce = 80, he = 0.4, ue = "a, button, input, textarea, select, video, .glare-thumbs", G = (e, t) => Math.hypot(e.x - t.x, e.y - t.y), V = (e, t) => ({ x: (e.x + t.x) / 2, y: (e.y + t.y) / 2 }), I = (e) => ({ x: e.clientX, y: e.clientY });
534
- class de {
550
+ const ue = 6, V = 120, de = 100, fe = 0.5, pe = 80, me = 0.4, ge = "a, button, input, textarea, select, video, .glare-thumbs", Y = (e, t) => Math.hypot(e.x - t.x, e.y - t.y), K = (e, t) => ({ x: (e.x + t.x) / 2, y: (e.y + t.y) / 2 }), I = (e) => ({ x: e.clientX, y: e.clientY });
551
+ class be {
535
552
  constructor(t, s) {
536
553
  this.stage = t, this.host = s, this.pointers = /* @__PURE__ */ new Map(), this.mode = "idle", this.moved = !1, this.start = [], this.startTime = 0, this.startZoom = { scale: 1, x: 0, y: 0 }, this.startMid = { x: 0, y: 0 }, this.startDistance = 0, this.offs = [
537
554
  h(t, "pointerdown", (i) => this.onDown(i)),
@@ -549,7 +566,7 @@ class de {
549
566
  return this.moved = !1, t;
550
567
  }
551
568
  onDown(t) {
552
- t.pointerType === "mouse" && t.button !== 0 || t.target.closest(ue) || (this.pointers.set(t.pointerId, I(t)), this.pointers.size <= 2 && this.begin());
569
+ t.pointerType === "mouse" && t.button !== 0 || t.target.closest(ge) || (this.pointers.set(t.pointerId, I(t)), this.pointers.size <= 2 && this.begin());
553
570
  }
554
571
  onMove(t) {
555
572
  this.pointers.has(t.pointerId) && (this.pointers.set(t.pointerId, I(t)), this.move(t));
@@ -561,7 +578,7 @@ class de {
561
578
  begin() {
562
579
  this.mode === "swipe" && this.releaseStage();
563
580
  const t = [...this.pointers.values()];
564
- this.start = t, this.startTime = performance.now(), this.startZoom = this.host.zoom.state, this.mode = t.length >= 2 ? "pinch" : "idle", t.length >= 2 && (this.startDistance = G(t[0], t[1]), this.startMid = V(t[0], t[1]));
581
+ this.start = t, this.startTime = performance.now(), this.startZoom = this.host.zoom.state, this.mode = t.length >= 2 ? "pinch" : "idle", t.length >= 2 && (this.startDistance = Y(t[0], t[1]), this.startMid = K(t[0], t[1]));
565
582
  }
566
583
  move(t) {
567
584
  const s = [...this.pointers.values()];
@@ -570,34 +587,34 @@ class de {
570
587
  t.preventDefault(), this.moved = !0, this.pinch(s[0], s[1]);
571
588
  return;
572
589
  }
573
- const i = s[0].x - this.start[0].x, r = s[0].y - this.start[0].y;
574
- if (!(!this.moved && Math.hypot(i, r) < ne)) {
590
+ const i = s[0].x - this.start[0].x, n = s[0].y - this.start[0].y;
591
+ if (!(!this.moved && Math.hypot(i, n) < ue)) {
575
592
  if (this.moved = !0, this.mode === "idle" && (this.mode = this.host.zoom.isZoomed && this.host.canPan() ? "pan" : "swipe"), this.mode === "pan")
576
- t.preventDefault(), this.host.zoom.apply(this.startZoom.scale, this.startZoom.x + i, this.startZoom.y + r);
593
+ t.preventDefault(), this.host.zoom.apply(this.startZoom.scale, this.startZoom.x + i, this.startZoom.y + n);
577
594
  else if (this.mode === "swipe") {
578
595
  const o = this.host.touch.vertical !== !1;
579
- if (!o && Math.abs(r) > Math.abs(i)) return;
580
- t.preventDefault(), this.dragStage(i, o ? r : 0);
596
+ if (!o && Math.abs(n) > Math.abs(i)) return;
597
+ t.preventDefault(), this.dragStage(i, o ? n : 0);
581
598
  }
582
599
  }
583
600
  }
584
601
  /** Scales around the pinch midpoint so the content under the fingers stays put. */
585
602
  pinch(t, s) {
586
- const { zoom: i } = this.host, r = V(t, s), o = i.center() ?? r, n = E(
587
- this.startZoom.scale * G(t, s) / (this.startDistance || 1),
588
- T,
589
- _
603
+ const { zoom: i } = this.host, n = K(t, s), o = i.center() ?? n, r = w(
604
+ this.startZoom.scale * Y(t, s) / (this.startDistance || 1),
605
+ S,
606
+ F
590
607
  ), a = (this.startMid.x - o.x - this.startZoom.x) / this.startZoom.scale, l = (this.startMid.y - o.y - this.startZoom.y) / this.startZoom.scale;
591
- i.apply(n, r.x - o.x - n * a, r.y - o.y - n * l);
608
+ i.apply(r, n.x - o.x - r * a, n.y - o.y - r * l);
592
609
  }
593
610
  end(t) {
594
611
  if (!this.start.length) return;
595
- const s = Math.max(performance.now() - this.startTime, 1), i = t.x - this.start[0].x, r = t.y - this.start[0].y, o = { x: i / s, y: r / s };
612
+ const s = Math.max(performance.now() - this.startTime, 1), i = t.x - this.start[0].x, n = t.y - this.start[0].y, o = { x: i / s, y: n / s };
596
613
  if (this.mode === "swipe")
597
- this.releaseStage(), this.finishSwipe(i, r, o);
614
+ this.releaseStage(), this.finishSwipe(i, n, o);
598
615
  else if (this.mode === "pan" && this.host.touch.momentum !== !1) {
599
- const { zoom: n } = this.host;
600
- n.apply(n.scale, n.x + o.x * Y, n.y + o.y * Y, 250);
616
+ const { zoom: r } = this.host;
617
+ r.apply(r.scale, r.x + o.x * V, r.y + o.y * V, 250);
601
618
  }
602
619
  this.mode = "idle", this.start = [], this.moved && setTimeout(() => this.moved = !1, 0);
603
620
  }
@@ -605,7 +622,7 @@ class de {
605
622
  dragStage(t, s) {
606
623
  this.stage.style.transitionDuration = "0ms", this.stage.style.transform = `translate3d(${t}px, ${s}px, 0)`;
607
624
  const { bg: i } = this.host;
608
- i && (i.style.transitionDuration = "0ms", i.style.opacity = String(E(1 - Math.abs(s) / 400, 0.35, 1)));
625
+ i && (i.style.transitionDuration = "0ms", i.style.opacity = String(w(1 - Math.abs(s) / 400, 0.35, 1)));
609
626
  }
610
627
  releaseStage() {
611
628
  this.stage.style.transitionDuration = "", this.stage.style.transform = "";
@@ -615,35 +632,35 @@ class de {
615
632
  /** A long or fast vertical swipe closes; a horizontal one navigates. */
616
633
  finishSwipe(t, s, i) {
617
634
  if (Math.abs(s) > Math.abs(t)) {
618
- (Math.abs(s) > ae || Math.abs(i.y) > le) && this.host.close();
635
+ (Math.abs(s) > de || Math.abs(i.y) > fe) && this.host.close();
619
636
  return;
620
637
  }
621
- (Math.abs(t) > ce || Math.abs(i.x) > he) && (t < 0 ? this.host.next() : this.host.prev());
638
+ (Math.abs(t) > pe || Math.abs(i.x) > me) && (t < 0 ? this.host.next() : this.host.prev());
622
639
  }
623
640
  }
624
- const fe = /^(.+)-(\d+)$/;
625
- function F(e = window.location.hash) {
626
- const t = e.replace(/^#/, "").match(fe);
641
+ const ye = /^(.+)-(\d+)$/;
642
+ function H(e = window.location.hash) {
643
+ const t = e.replace(/^#/, "").match(ye);
627
644
  return t ? { gallery: t[1], index: Math.max(0, parseInt(t[2], 10) - 1) } : null;
628
645
  }
629
- function K(e, t) {
646
+ function Q(e, t) {
630
647
  return `${e}-${t + 1}`;
631
648
  }
632
- class pe {
649
+ class ve {
633
650
  constructor(t, s) {
634
651
  this.glare = t, this.gallery = s, this.pushed = !1, this.off = h(window, "hashchange", () => this.onHashChange());
635
- const i = K(s, t.currIndex);
636
- Q() !== i && (window.history.pushState(null, "", `#${i}`), this.pushed = !0);
652
+ const i = Q(s, t.currIndex);
653
+ J() !== i && (window.history.pushState(null, "", `#${i}`), this.pushed = !0);
637
654
  }
638
655
  update(t = this.glare.currIndex) {
639
- const s = K(this.gallery, t);
640
- Q() !== s && this.replace(`#${s}`);
656
+ const s = Q(this.gallery, t);
657
+ J() !== s && this.replace(`#${s}`);
641
658
  }
642
659
  destroy() {
643
- this.off(), F()?.gallery === this.gallery && (this.pushed ? window.history.back() : this.replace(""));
660
+ this.off(), H()?.gallery === this.gallery && (this.pushed ? window.history.back() : this.replace(""));
644
661
  }
645
662
  onHashChange() {
646
- const t = F();
663
+ const t = H();
647
664
  !t || t.gallery !== this.gallery ? (this.pushed = !1, this.glare.close()) : t.index !== this.glare.currIndex && this.glare.jumpTo(t.index);
648
665
  }
649
666
  replace(t) {
@@ -651,56 +668,8 @@ class pe {
651
668
  window.history.replaceState(null, "", `${s}${i}${t}`);
652
669
  }
653
670
  }
654
- const Q = () => window.location.hash.replace(/^#/, "");
655
- class me {
656
- constructor(t, s, i) {
657
- this.glare = t, this.container = s, this.opts = i, this.overlay = null, this.off = null;
658
- }
659
- get isOpen() {
660
- return this.overlay !== null;
661
- }
662
- open() {
663
- const { current: t, dict: s } = this.glare;
664
- if (!t) return;
665
- this.close();
666
- const i = this.resolveUrl(t), r = encodeURIComponent(i), o = encodeURIComponent(t.thumb || t.src || i), n = encodeURIComponent(O(t.caption)), a = y(this.opts.tpl ?? Lt, {
667
- ...s,
668
- url_direct: i,
669
- url_facebook: `https://www.facebook.com/sharer/sharer.php?u=${r}`,
670
- url_twitter: `https://twitter.com/intent/tweet?url=${r}&text=${n}`,
671
- url_pinterest: `https://pinterest.com/pin/create/button/?url=${r}&media=${o}&description=${n}`
672
- });
673
- this.overlay = g("div", "glare-share-overlay", a), this.container.appendChild(this.overlay);
674
- const l = c(".glare-share-input", this.overlay);
675
- l?.select(), this.off = h(this.overlay, "click", (d) => {
676
- const p = d.target;
677
- p === this.overlay || p.closest("[data-glare-share-close]") ? this.close() : p.closest("[data-glare-share-copy]") && this.copy(i, l);
678
- });
679
- }
680
- close() {
681
- if (!this.overlay) return;
682
- const t = this.overlay.contains(document.activeElement);
683
- if (this.off?.(), this.off = null, this.overlay.remove(), this.overlay = null, !t) return;
684
- const s = c("[data-glare-share]", this.container);
685
- s ? s.focus() : this.glare.focus();
686
- }
687
- destroy() {
688
- this.close();
689
- }
690
- async copy(t, s) {
691
- try {
692
- await navigator.clipboard.writeText(t);
693
- } catch {
694
- s?.select(), document.execCommand("copy");
695
- }
696
- s?.select();
697
- }
698
- resolveUrl(t) {
699
- const { url: s } = this.opts;
700
- return typeof s == "function" ? s(t) : s || (/^https?:\/\//i.test(t.src) ? t.src : window.location.href);
701
- }
702
- }
703
- class ge {
671
+ const J = () => window.location.hash.replace(/^#/, "");
672
+ class xe {
704
673
  constructor(t, s, i) {
705
674
  this.glare = t, this.container = s, this.opts = i, this.timer = null, this.active = !1, this.bar = c(".glare-progress", s), this.button = c("[data-glare-slideshow]", s), i.autoStart && this.start();
706
675
  }
@@ -723,13 +692,13 @@ class ge {
723
692
  this.stop();
724
693
  }
725
694
  get speed() {
726
- return this.opts.speed ?? z.speed;
695
+ return this.opts.speed ?? _.speed;
727
696
  }
728
697
  get atEnd() {
729
698
  return !this.glare.opts.loop && this.glare.currIndex === this.glare.group.length - 1;
730
699
  }
731
700
  schedule() {
732
- this.clearTimer(), this.setProgress(0), A() || (this.bar?.offsetWidth, this.setProgress(1)), this.timer = setTimeout(() => this.atEnd ? this.stop() : this.glare.next(), this.speed);
701
+ this.clearTimer(), this.setProgress(0), dt() || (this.bar?.offsetWidth, this.setProgress(1)), this.timer = setTimeout(() => this.atEnd ? this.stop() : this.glare.next(), this.speed);
733
702
  }
734
703
  clearTimer() {
735
704
  this.timer && clearTimeout(this.timer), this.timer = null;
@@ -740,7 +709,7 @@ class ge {
740
709
  syncButton() {
741
710
  if (!this.button) return;
742
711
  const { dict: t } = this.glare;
743
- N(
712
+ Z(
744
713
  this.button,
745
714
  this.active,
746
715
  this.active ? t.PLAY_STOP : t.PLAY_START,
@@ -748,9 +717,9 @@ class ge {
748
717
  );
749
718
  }
750
719
  }
751
- class ye {
720
+ class we {
752
721
  constructor(t, s, i) {
753
- this.glare = t, this.container = s, this.opts = i, this.isActive = !1, this.offs = [], this.axis = i.axis === "y" ? "y" : "x", this.list = g("div", "glare-thumbs-list"), this.strip = g("div", `glare-thumbs glare-thumbs--${this.axis}`), this.strip.appendChild(this.list), this.build();
722
+ this.glare = t, this.container = s, this.opts = i, this.isActive = !1, this.offs = [], this.axis = i.axis === "y" ? "y" : "x", this.list = m("div", "glare-thumbs-list"), this.strip = m("div", `glare-thumbs glare-thumbs--${this.axis}`), this.strip.style.setProperty("--glare-thumbs-fit", i.fit ?? "cover"), this.strip.appendChild(this.list), this.build();
754
723
  }
755
724
  show() {
756
725
  this.setActive(!0);
@@ -779,29 +748,29 @@ class ye {
779
748
  const { group: t, dict: s } = this.glare;
780
749
  if (t.length < 2) return;
781
750
  this.container.classList.add(`glare-thumbs-axis-${this.axis}`);
782
- for (const r of t) {
783
- const o = g("button", "glare-thumbs-item");
784
- o.type = "button", o.dataset.index = String(r.index), o.setAttribute("aria-label", y(s.GO_TO_SLIDE, { index: String(r.index + 1) }));
785
- const n = r.thumb || (r.type === "image" ? r.src : "");
786
- if (n) {
787
- const a = g("img");
788
- a.src = n, a.alt = r.alt || O(r.caption), a.loading = "lazy", o.appendChild(a);
751
+ for (const n of t) {
752
+ const o = m("button", "glare-thumbs-item");
753
+ o.type = "button", o.dataset.index = String(n.index), o.setAttribute("aria-label", b(s.GO_TO_SLIDE, { index: String(n.index + 1) }));
754
+ const r = n.thumb || (n.type === "image" ? n.src : "");
755
+ if (r) {
756
+ const a = m("img");
757
+ a.src = r, a.alt = n.alt || N(n.caption), a.loading = "lazy", o.appendChild(a);
789
758
  } else
790
- o.textContent = String(r.index + 1);
791
- this.list.appendChild(o), this.offs.push(h(o, "click", () => this.glare.jumpTo(r.index)));
759
+ o.textContent = String(n.index + 1);
760
+ this.list.appendChild(o), this.offs.push(h(o, "click", () => this.glare.jumpTo(n.index)));
792
761
  }
793
- (_t(this.opts.parentEl, this.container) ?? this.container).appendChild(this.strip), this.opts.autoStart && this.show(), this.focus();
762
+ (ht(this.opts.parentEl, this.container) ?? this.container).appendChild(this.strip), this.opts.autoStart && this.show(), this.focus();
794
763
  }
795
764
  }
796
- const be = 40, ve = 150, xe = 16;
797
- class we {
765
+ const Ee = 40, Te = 150, Se = 16;
766
+ class Le {
798
767
  constructor(t, s) {
799
768
  this.distance = 0, this.fired = !1, this.settle = null, this.off = h(
800
769
  t,
801
770
  "wheel",
802
771
  (i) => {
803
- const r = s.current();
804
- !r || i.deltaY === 0 || s.mode === "auto" && r.type !== "image" || r.type === "image" && s.isZoomed() || (i.preventDefault(), this.restartSettle(), !this.fired && (this.distance += Ee(i, t), !(Math.abs(this.distance) < be) && (this.fired = !0, this.distance > 0 ? s.next() : s.prev())));
772
+ const n = s.current();
773
+ !n || i.deltaY === 0 || s.mode === "auto" && n.type !== "image" || n.type === "image" && s.isZoomed() || (i.preventDefault(), this.restartSettle(), !this.fired && (this.distance += Me(i, t), !(Math.abs(this.distance) < Ee) && (this.fired = !0, this.distance > 0 ? s.next() : s.prev())));
805
774
  },
806
775
  { passive: !1 }
807
776
  );
@@ -812,71 +781,91 @@ class we {
812
781
  restartSettle() {
813
782
  this.settle && clearTimeout(this.settle), this.settle = setTimeout(() => {
814
783
  this.distance = 0, this.fired = !1;
815
- }, ve);
784
+ }, Te);
816
785
  }
817
786
  }
818
- function Ee(e, t) {
819
- return e.deltaMode === WheelEvent.DOM_DELTA_LINE ? e.deltaY * xe : e.deltaMode === WheelEvent.DOM_DELTA_PAGE ? e.deltaY * t.clientHeight : e.deltaY;
820
- }
821
- function Se(e, t) {
822
- const s = A(), i = s ? !1 : t.animationEffect, r = s ? !1 : t.transitionEffect;
823
- e.dataset.animation = i || "none", e.style.setProperty("--glare-duration", `${i ? t.animationDuration : 0}ms`), e.style.setProperty("--glare-transition-duration", `${r ? t.transitionDuration : 0}ms`);
787
+ function Me(e, t) {
788
+ return e.deltaMode === WheelEvent.DOM_DELTA_LINE ? e.deltaY * Se : e.deltaMode === WheelEvent.DOM_DELTA_PAGE ? e.deltaY * t.clientHeight : e.deltaY;
824
789
  }
825
- function Te(e, t) {
826
- const s = A() ? !1 : t.transitionEffect;
827
- e.dataset.transition = s || "none";
790
+ function C(e) {
791
+ const t = dt(), s = t || !e.animationEffect ? 0 : Math.max(0, e.animationDuration), i = t || !e.transitionEffect ? 0 : Math.max(0, e.transitionDuration);
792
+ return {
793
+ animationEffect: s ? e.animationEffect : !1,
794
+ animationDuration: s,
795
+ transitionEffect: i ? e.transitionEffect : !1,
796
+ transitionDuration: i
797
+ };
828
798
  }
829
- function Le(e, t, s) {
830
- const i = t.$image, r = t.$trigger;
831
- if (e.dataset.animation !== "zoom" || !i || !r) return;
832
- const o = r.getBoundingClientRect(), n = i.getBoundingClientRect(), a = Math.max(o.width / Math.max(n.width, 1), o.height / Math.max(n.height, 1)), l = o.left + o.width / 2 - (n.left + n.width / 2), d = o.top + o.height / 2 - (n.top + n.height / 2);
799
+ function Ce(e, t) {
800
+ const s = C(t);
801
+ e.dataset.animation = s.animationEffect || "none", e.style.setProperty("--glare-duration", `${s.animationDuration}ms`), e.style.setProperty("--glare-transition-duration", `${s.transitionDuration}ms`);
802
+ }
803
+ function $e(e, t) {
804
+ e.dataset.transition = C(t).transitionEffect || "none";
805
+ }
806
+ const Oe = /^(top|center|bottom)-(left|center|right)$/, tt = { top: 0, left: 0, center: 0.5, bottom: 1, right: 1 };
807
+ function Ie(e, t, s) {
808
+ const i = typeof s == "string" ? Oe.exec(s) : null;
809
+ if (i) {
810
+ const r = e.getBoundingClientRect(), a = r.left + r.width * tt[i[2]], l = r.top + r.height * tt[i[1]];
811
+ return new DOMRect(a, l, 0, 0);
812
+ }
813
+ const n = (r) => r?.getClientRects().length ? r : null, o = s !== "trigger" && n(ht(s)) || n(t.$trigger);
814
+ return o ? o.getBoundingClientRect() : null;
815
+ }
816
+ function Ae(e, t, s) {
817
+ const i = t.$image;
818
+ if (e.dataset.animation !== "zoom" || !i) return;
819
+ const n = Ie(e, t, s.anchor);
820
+ if (!n) return;
821
+ const o = i.getBoundingClientRect(), r = Math.max(n.width / Math.max(o.width, 1), n.height / Math.max(o.height, 1)), a = n.left + n.width / 2 - (o.left + o.width / 2), l = n.top + n.height / 2 - (o.top + o.height / 2);
833
822
  Object.assign(i.style, {
834
- transform: `translate3d(${l}px, ${d}px, 0) scale(${a})`,
823
+ transform: `translate3d(${a}px, ${l}px, 0) scale(${r})`,
835
824
  opacity: s.zoomOpacity ? "0.2" : "1",
836
825
  transitionDuration: "0ms"
837
- }), lt(() => {
826
+ }), ut(() => {
838
827
  Object.assign(i.style, { transform: "", opacity: "", transitionDuration: "" });
839
828
  });
840
829
  }
841
- function ut(e) {
842
- const t = R(nt, e);
843
- return Ht() && t.mobile ? R(t, t.mobile) : t;
830
+ function mt(e) {
831
+ const t = R(lt, e);
832
+ return _t() && t.mobile ? R(t, t.mobile) : t;
844
833
  }
845
- function C(e, t) {
834
+ function A(e, t) {
846
835
  return e ? e === !0 ? { ...t } : { ...t, ...e } : null;
847
836
  }
848
- const M = [], H = (e) => e.getAttribute("data-glare") ?? "";
849
- function Ce(e) {
837
+ const M = [], P = (e) => e.getAttribute("data-glare") ?? "";
838
+ function De(e) {
850
839
  return typeof e == "string" ? $(e) : e instanceof HTMLElement ? [e] : Array.from(e);
851
840
  }
852
- function Me(e, t, s) {
853
- const i = Ce(e), r = (a) => {
854
- const l = H(a), d = l ? i.filter((p) => H(p) === l) : [a];
841
+ function ke(e, t, s) {
842
+ const i = De(e), n = (a) => {
843
+ const l = P(a), d = l ? i.filter((E) => P(E) === l) : [a];
855
844
  s(d, d.indexOf(a), l);
856
845
  }, o = i.map(
857
846
  (a) => h(a, "click", (l) => {
858
- l.preventDefault(), r(a);
847
+ l.preventDefault(), n(a);
859
848
  })
860
- ), n = {
849
+ ), r = {
861
850
  elements: i,
862
851
  destroy() {
863
852
  o.forEach((l) => l());
864
- const a = M.indexOf(n);
853
+ const a = M.indexOf(r);
865
854
  a >= 0 && M.splice(a, 1);
866
855
  }
867
856
  };
868
- return M.push(n), ut(t).hash && Oe(i, r), n;
857
+ return M.push(r), mt(t).hash && Fe(i, n), r;
869
858
  }
870
- function $e() {
859
+ function Re() {
871
860
  for (const e of [...M]) e.destroy();
872
861
  }
873
- function Oe(e, t) {
874
- const s = F();
862
+ function Fe(e, t) {
863
+ const s = H();
875
864
  if (!s) return;
876
- const r = e.filter((o) => H(o) === s.gallery)[s.index];
877
- r && t(r);
865
+ const n = e.filter((o) => P(o) === s.gallery)[s.index];
866
+ n && t(n);
878
867
  }
879
- class Ae {
868
+ class He {
880
869
  constructor(t, s) {
881
870
  this.seconds = t, this.onIdle = s, this.timer = null;
882
871
  }
@@ -887,91 +876,96 @@ class Ae {
887
876
  this.timer && clearTimeout(this.timer), this.timer = null;
888
877
  }
889
878
  }
890
- const x = [], b = {
879
+ const y = [], g = {
891
880
  add(e) {
892
- x.push(e);
881
+ y.push(e);
893
882
  },
894
883
  remove(e) {
895
- const t = x.indexOf(e);
896
- t >= 0 && x.splice(t, 1);
884
+ const t = y.indexOf(e);
885
+ t >= 0 && y.splice(t, 1);
897
886
  },
898
887
  top() {
899
- return x[x.length - 1] ?? null;
888
+ return y[y.length - 1] ?? null;
900
889
  },
901
890
  get(e) {
902
- return x.find((t) => t.id === e) ?? null;
891
+ return y.find((t) => t.id === e) ?? null;
903
892
  },
904
893
  all() {
905
- return [...x];
894
+ return [...y];
906
895
  },
907
896
  get size() {
908
- return x.length;
897
+ return y.length;
909
898
  }
910
- }, Ie = [
899
+ }, Pe = [
911
900
  ["[data-glare-close]", (e) => e.close()],
912
901
  ["[data-glare-next]", (e) => e.next()],
913
902
  ["[data-glare-prev]", (e) => e.prev()],
914
903
  ["[data-glare-zoom]", (e) => e.toggleZoom()],
915
904
  ["[data-glare-slideshow]", (e) => e.slideshow?.toggle()],
916
905
  ["[data-glare-thumbs]", (e) => e.thumbs?.toggle()],
917
- ["[data-glare-fullscreen]", (e) => e.fullscreen?.toggle()],
918
- ["[data-glare-share]", (e) => e.share?.open()]
919
- ], De = ".glare-content", ke = ".glare-slide, .glare-stage", Re = 'button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])', _e = /* @__PURE__ */ new Set(["INPUT", "TEXTAREA", "SELECT"]), Fe = 300;
920
- function He(e, t, s) {
906
+ ["[data-glare-fullscreen]", (e) => e.fullscreen?.toggle()]
907
+ ], ze = ".glare-content", _e = ".glare-slide, .glare-stage", Ne = 'button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])', Ze = /* @__PURE__ */ new Set(["INPUT", "TEXTAREA", "SELECT"]), Be = 300;
908
+ function qe(e, t, s) {
921
909
  let i = null;
922
- const r = () => {
910
+ const n = () => {
923
911
  i && clearTimeout(i), i = null;
924
912
  }, o = [
925
- h(t, "click", (n) => {
913
+ h(t, "click", (r) => {
926
914
  if (e.consumeGesture()) return;
927
- const a = n.target, l = a.closest("[data-glare-more]");
915
+ const a = r.target, l = a.closest("[data-glare-more]");
928
916
  if (l) {
929
- const L = l.closest(".glare-toolbar"), Z = !L?.classList.contains("glare-toolbar--expanded");
930
- L?.classList.toggle("glare-toolbar--expanded", Z), l.setAttribute("aria-expanded", String(Z));
917
+ const L = l.closest(".glare-toolbar"), B = !L?.classList.contains("glare-toolbar--expanded");
918
+ L?.classList.toggle("glare-toolbar--expanded", B), l.setAttribute("aria-expanded", String(B));
931
919
  return;
932
920
  }
933
- ft(t);
934
- const d = Ie.find(([L]) => a.closest(L));
935
- if (d) return d[1](e);
921
+ bt(t);
922
+ const d = a.closest("[data-glare-custom]");
923
+ if (d) return je(e, d.dataset.glareCustom, r);
924
+ const E = Pe.find(([L]) => a.closest(L));
925
+ if (E) return E[1](e);
936
926
  if (a.closest(".glare-button")) return;
937
- const p = D(e, a, "click");
938
- if (p) {
939
- if (!dt(e, D(e, a, "dblclick"), n))
940
- return k(e, p, n);
941
- r(), i = setTimeout(() => k(e, p, n), Fe);
927
+ const O = D(e, a, "click");
928
+ if (O) {
929
+ if (!gt(e, D(e, a, "dblclick"), r))
930
+ return k(e, O, r);
931
+ n(), i = setTimeout(() => k(e, O, r), Be);
942
932
  }
943
933
  }),
944
- h(t, "dblclick", (n) => {
945
- r();
946
- const a = n.target;
947
- a.closest(".glare-button") || k(e, D(e, a, "dblclick"), n);
934
+ h(t, "dblclick", (r) => {
935
+ n();
936
+ const a = r.target;
937
+ a.closest(".glare-button") || k(e, D(e, a, "dblclick"), r);
948
938
  }),
949
- h(document, "keydown", (n) => Pe(e, n)),
939
+ h(document, "keydown", (r) => We(e, r)),
950
940
  h(document, "keydown", s),
951
941
  h(document, "click", s, { capture: !0 }),
952
942
  h(document, "mousemove", s),
953
943
  h(document, "touchstart", s, { passive: !0 })
954
944
  ];
955
- return e.opts.trapFocus && o.push(h(t, "keydown", (n) => ze(t, n))), e.opts.protect && o.push(
956
- h(t, "contextmenu", (n) => n.preventDefault()),
957
- h(t, "dragstart", (n) => {
958
- n.target.tagName === "IMG" && n.preventDefault();
945
+ return e.opts.trapFocus && o.push(h(t, "keydown", (r) => Ue(t, r))), e.opts.protect && o.push(
946
+ h(t, "contextmenu", (r) => r.preventDefault()),
947
+ h(t, "dragstart", (r) => {
948
+ r.target.tagName === "IMG" && r.preventDefault();
959
949
  })
960
950
  ), () => {
961
- r(), o.forEach((n) => n());
951
+ n(), o.forEach((r) => r());
962
952
  };
963
953
  }
954
+ function je(e, t, s) {
955
+ const i = e.opts.buttons.find((n) => typeof n != "string" && n.name === t);
956
+ i && e.current && i.click(e, e.current, s);
957
+ }
964
958
  function D(e, t, s) {
965
959
  const { opts: i } = e;
966
- if (t.closest(De)) return s === "click" ? i.clickContent : i.dblclickContent;
967
- if (!(i.modal || !t.closest(ke)))
960
+ if (t.closest(ze)) return s === "click" ? i.clickContent : i.dblclickContent;
961
+ if (!(i.modal || !t.closest(_e)))
968
962
  return s === "click" ? i.clickSlide : i.dblclickSlide;
969
963
  }
970
- function dt(e, t, s) {
964
+ function gt(e, t, s) {
971
965
  return !t || !e.current ? !1 : typeof t == "function" ? t(e.current, s) : t;
972
966
  }
973
967
  function k(e, t, s) {
974
- switch (dt(e, t, s)) {
968
+ switch (gt(e, t, s)) {
975
969
  case "close":
976
970
  return e.close();
977
971
  case "next":
@@ -986,17 +980,15 @@ function k(e, t, s) {
986
980
  }
987
981
  }
988
982
  }
989
- function Pe(e, t) {
990
- if (b.top() !== e) return;
991
- if (t.key === "Escape" && ft(e.$refs?.container ?? null)) {
983
+ function We(e, t) {
984
+ if (g.top() !== e) return;
985
+ if (t.key === "Escape" && bt(e.$refs?.container ?? null)) {
992
986
  t.preventDefault();
993
987
  return;
994
988
  }
995
- if (t.key === "Escape" && e.share?.isOpen)
996
- return t.preventDefault(), e.share.close();
997
989
  if (!e.opts.keyboard || e.opts.modal) return;
998
990
  const s = t.target;
999
- if (!_e.has(s.tagName) && !(t.key === " " && s.closest("button")))
991
+ if (!Ze.has(s.tagName) && !(t.key === " " && s.closest("button")))
1000
992
  switch (t.key) {
1001
993
  case "Escape":
1002
994
  return t.preventDefault(), e.close();
@@ -1013,117 +1005,117 @@ function Pe(e, t) {
1013
1005
  return e.fullscreen?.toggle();
1014
1006
  }
1015
1007
  }
1016
- function ft(e) {
1008
+ function bt(e) {
1017
1009
  const t = e?.querySelector(".glare-toolbar--expanded");
1018
1010
  return t ? (t.classList.remove("glare-toolbar--expanded"), t.querySelector("[data-glare-more]")?.setAttribute("aria-expanded", "false"), !0) : !1;
1019
1011
  }
1020
- function ze(e, t) {
1012
+ function Ue(e, t) {
1021
1013
  if (t.key !== "Tab") return;
1022
- const s = $(Re, e).filter(
1014
+ const s = $(Ne, e).filter(
1023
1015
  (o) => !o.hasAttribute("disabled") && o.offsetParent !== null && getComputedStyle(o).visibility !== "hidden"
1024
1016
  );
1025
1017
  if (!s.length) return;
1026
- const i = s[0], r = s[s.length - 1];
1027
- t.shiftKey && document.activeElement === i ? (t.preventDefault(), r.focus()) : !t.shiftKey && document.activeElement === r && (t.preventDefault(), i.focus());
1018
+ const i = s[0], n = s[s.length - 1];
1019
+ t.shiftKey && document.activeElement === i ? (t.preventDefault(), n.focus()) : !t.shiftKey && document.activeElement === n && (t.preventDefault(), i.focus());
1028
1020
  }
1029
- const Ne = 1200, J = 16 / 9;
1030
- function Ze(e, t, s) {
1021
+ const Xe = 1200, et = 16 / 9;
1022
+ function Ge(e, t, s) {
1031
1023
  if (t && s) return t / s;
1032
- const i = String(e.ratio || J).replace(":", "/"), [r, o = "1"] = i.split("/").map((l) => l.trim()), n = parseFloat(r), a = parseFloat(o);
1033
- return n > 0 && a > 0 ? n / a : J;
1024
+ const i = String(e.ratio || et).replace(":", "/"), [n, o = "1"] = i.split("/").map((l) => l.trim()), r = parseFloat(n), a = parseFloat(o);
1025
+ return r > 0 && a > 0 ? r / a : et;
1034
1026
  }
1035
- function tt(e, t, s) {
1027
+ function st(e, t, s) {
1036
1028
  if (!e) return 0;
1037
1029
  if (typeof e == "number") return e;
1038
- const i = e.trim(), r = parseFloat(i);
1039
- return r > 0 ? i.endsWith("%") ? t * r / 100 : i.endsWith("vw") || i.endsWith("vh") ? s * r / 100 : r : 0;
1030
+ const i = e.trim(), n = parseFloat(i);
1031
+ return n > 0 ? i.endsWith("%") ? t * n / 100 : i.endsWith("vw") || i.endsWith("vh") ? s * n / 100 : n : 0;
1040
1032
  }
1041
- function et(e, t) {
1033
+ function it(e, t) {
1042
1034
  const s = t.parentElement;
1043
1035
  if (!s) return;
1044
- const i = getComputedStyle(s), r = s.clientWidth - parseFloat(i.paddingLeft) - parseFloat(i.paddingRight), o = s.clientHeight - parseFloat(i.paddingTop) - parseFloat(i.paddingBottom);
1045
- if (!(r > 0 && o > 0)) return;
1046
- const n = e.width !== void 0 && e.height !== void 0;
1047
- let a = n ? tt(e.width, r, innerWidth) : r, l = n ? tt(e.height, o, innerHeight) : o;
1048
- const d = Ze(e, n ? a : void 0, n ? l : void 0), p = Math.min(1, r / a, o / l);
1049
- a *= p, l *= p, l > a / d ? l = a / d : a > l * d && (a = l * d), t.style.width = `${a}px`, t.style.height = `${l}px`, t.style.aspectRatio = String(d);
1050
- }
1051
- function qe(e, t) {
1052
- if (et(e, t), typeof ResizeObserver > "u" || !t.parentElement) return;
1036
+ const i = getComputedStyle(s), n = s.clientWidth - parseFloat(i.paddingLeft) - parseFloat(i.paddingRight), o = s.clientHeight - parseFloat(i.paddingTop) - parseFloat(i.paddingBottom);
1037
+ if (!(n > 0 && o > 0)) return;
1038
+ const r = e.width !== void 0 && e.height !== void 0;
1039
+ let a = r ? st(e.width, n, innerWidth) : n, l = r ? st(e.height, o, innerHeight) : o;
1040
+ const d = Ge(e, r ? a : void 0, r ? l : void 0), E = Math.min(1, n / a, o / l);
1041
+ a *= E, l *= E, l > a / d ? l = a / d : a > l * d && (a = l * d), t.style.width = `${a}px`, t.style.height = `${l}px`, t.style.aspectRatio = String(d);
1042
+ }
1043
+ function Ve(e, t) {
1044
+ if (it(e, t), typeof ResizeObserver > "u" || !t.parentElement) return;
1053
1045
  const s = new ResizeObserver(() => {
1054
1046
  if (!t.isConnected) return s.disconnect();
1055
- et(e, t);
1047
+ it(e, t);
1056
1048
  });
1057
1049
  s.observe(t.parentElement);
1058
1050
  }
1059
- const Ue = (e, t, s) => new Promise((i, r) => {
1060
- const o = g("img", "glare-image");
1061
- o.alt = e.alt || O(e.caption), o.decoding = "async", o.draggable = !1, s.protect && (o.style.pointerEvents = "none"), o.onload = () => {
1051
+ const Ye = (e, t, s) => new Promise((i, n) => {
1052
+ const o = m("img", "glare-image");
1053
+ o.alt = e.alt || N(e.caption), o.decoding = "async", o.draggable = !1, s.protect && (o.style.pointerEvents = "none"), o.onload = () => {
1062
1054
  e.$image = o, e.contentWidth = o.naturalWidth, e.contentHeight = o.naturalHeight, t.appendChild(o), i();
1063
- }, o.onerror = () => r(new Error(`Failed to load image: ${e.src}`)), o.src = e.src;
1064
- }), Be = (e, t, s, i) => {
1065
- const r = e.format || s.video.format || It(e.src);
1066
- t.innerHTML = y(s.video.tpl, {
1055
+ }, o.onerror = () => n(new Error(`Failed to load image: ${e.src}`)), o.src = e.src;
1056
+ }), Ke = (e, t, s, i) => {
1057
+ const n = e.format || s.video.format || Rt(e.src);
1058
+ t.innerHTML = b(s.video.tpl, {
1067
1059
  ...i,
1068
1060
  src: e.src,
1069
- format: r,
1061
+ format: n,
1070
1062
  poster: e.poster ?? ""
1071
1063
  });
1072
1064
  const o = t.querySelector("video");
1073
1065
  o && (e.autoStart ?? s.video.autoStart) && o.play().catch(() => {
1074
1066
  });
1075
- }, st = (e, t, s) => new Promise((i) => {
1076
- const r = s.iframe, o = g("div", "glare-iframe-wrap", r.tpl), n = o.querySelector("iframe");
1077
- if (!n) throw new Error("Iframe template must contain an <iframe>");
1078
- for (const [a, l] of Object.entries(r.attr)) n.setAttribute(a, l);
1079
- if (Object.assign(n.style, r.css), t.appendChild(o), e.type === "embed" ? qe(e, t) : (e.width && (o.style.width = U(e.width)), e.height && (o.style.height = U(e.height))), !r.preload) {
1080
- n.src = e.src, i();
1067
+ }, nt = (e, t, s) => new Promise((i) => {
1068
+ const n = s.iframe, o = m("div", "glare-iframe-wrap", n.tpl), r = o.querySelector("iframe");
1069
+ if (!r) throw new Error("Iframe template must contain an <iframe>");
1070
+ for (const [a, l] of Object.entries(n.attr)) r.setAttribute(a, l);
1071
+ if (Object.assign(r.style, n.css), t.appendChild(o), e.type === "embed" ? Ve(e, t) : (e.width && (o.style.width = j(e.width)), e.height && (o.style.height = j(e.height))), !n.preload) {
1072
+ r.src = e.src, i();
1081
1073
  return;
1082
1074
  }
1083
- n.onload = () => i(), n.src = e.src, setTimeout(i, Ne);
1084
- }), We = (e, t) => {
1075
+ r.onload = () => i(), r.src = e.src, setTimeout(i, Xe);
1076
+ }), Qe = (e, t) => {
1085
1077
  const s = e.src ? c(e.src) : null;
1086
1078
  if (!s) throw new Error(`Inline target not found: ${e.src}`);
1087
1079
  const i = s.cloneNode(!0);
1088
1080
  i.removeAttribute("id"), i.hidden = !1, i.style.display = "", t.appendChild(i);
1089
- }, je = async (e, t, s) => {
1081
+ }, Je = async (e, t, s) => {
1090
1082
  const i = await fetch(e.src, s.ajax.settings);
1091
1083
  if (!i.ok) throw new Error(`Request failed: ${i.status} ${e.src}`);
1092
1084
  t.innerHTML = await i.text();
1093
- }, Xe = (e, t) => {
1085
+ }, ts = (e, t) => {
1094
1086
  e.content instanceof HTMLElement ? t.appendChild(e.content) : t.innerHTML = e.html ?? e.content ?? e.src;
1095
- }, Ye = { image: Ue, video: Be, embed: st, iframe: st, inline: We, ajax: je, html: Xe };
1096
- async function Ge(e, t, s, i) {
1097
- t.innerHTML = "", t.className = `glare-content glare-content--${e.type}`, await Ye[e.type](e, t, s, i), e.isLoaded = !0;
1087
+ }, es = { image: Ye, video: Ke, embed: nt, iframe: nt, inline: Qe, ajax: Je, html: ts };
1088
+ async function ss(e, t, s, i) {
1089
+ t.innerHTML = "", t.className = `glare-content glare-content--${e.type}`, await es[e.type](e, t, s, i), e.isLoaded = !0;
1098
1090
  }
1099
- function Ve(e, t) {
1091
+ function is(e, t) {
1100
1092
  for (const s of [e[t - 1], e[t + 1]])
1101
1093
  s?.type === "image" && s.src && (new Image().src = s.src);
1102
1094
  }
1103
- let Ke = 0;
1104
- const w = class w {
1105
- constructor(t, s = {}, i = 0, r = "") {
1106
- this.id = ++Ke, this.current = null, this.currIndex = 0, this.prevIndex = 0, this.isActive = !1, this.isClosing = !1, this.isIdle = !1, this.$refs = null, this.hash = null, this.gestures = null, this.wheel = null, this.cleanups = [], this.previouslyFocused = null, this.opts = ut(s), this.dict = pt(this.opts), this.group = kt(t, this.opts), this.galleryName = r, this.currIndex = this.clampIndex(i), this.zoom = new oe({
1095
+ let ns = 0;
1096
+ const x = class x {
1097
+ constructor(t, s = {}, i = 0, n = "") {
1098
+ this.id = ++ns, this.current = null, this.currIndex = 0, this.prevIndex = 0, this.isActive = !1, this.isClosing = !1, this.isIdle = !1, this.$refs = null, this.hash = null, this.gestures = null, this.wheel = null, this.cleanups = [], this.captionTracker = null, this.previouslyFocused = null, this.direction = 1, this.opts = mt(s), this.dict = yt(this.opts), this.group = Ht(t, this.opts), this.galleryName = n, this.currIndex = this.clampIndex(i), this.zoom = new he({
1107
1099
  image: () => this.current?.$image ?? null,
1108
1100
  stage: () => this.$refs?.stage ?? null,
1109
1101
  onChange: (o) => this.syncZoomState(o)
1110
- }), this.idle = new Ae(this.opts.modal ? !1 : this.opts.idleTime, () => this.toggleControls(!0));
1102
+ }), this.idle = new He(this.opts.modal ? !1 : this.opts.idleTime, () => this.toggleControls(!0));
1111
1103
  }
1112
1104
  open(t = this.currIndex) {
1113
1105
  if (this.isActive) return this.jumpTo(t);
1114
1106
  if (!this.group.length) return;
1115
- this.opts.closeExisting && w.close(!0), this.currIndex = this.clampIndex(t), this.current = this.group[this.currIndex], this.previouslyFocused = document.activeElement instanceof HTMLElement ? document.activeElement : null, this.emit("onInit");
1116
- const s = Pt(this.opts, this.dict, this.id, this.group.length), { container: i } = s;
1117
- this.$refs = s, Se(i, this.opts), this.syncChrome(), this.resolveParent().appendChild(i), this.isActive = !0, b.add(this), this.opts.hideScrollbar && W(!0), this.emit("onActivate"), this.emitSlide("beforeShow", this.current), lt(() => {
1118
- this.isActive && (i.classList.add("glare-is-open"), this.showSlide(this.currIndex, !0), this.cleanups.push(He(this, i, () => this.onActivity())), this.startModules(s), this.opts.autoFocus && this.focus(), this.idle.reset());
1107
+ this.opts.closeExisting && x.close(!0), this.currIndex = this.clampIndex(t), this.current = this.group[this.currIndex], this.previouslyFocused = document.activeElement instanceof HTMLElement ? document.activeElement : null, this.emit("onInit");
1108
+ const s = Nt(this.opts, this.dict, this.id, this.group.length), { container: i } = s;
1109
+ this.$refs = s, Ce(i, this.opts), this.syncChrome(), this.resolveParent().appendChild(i), this.captionTracker = jt(s), this.cleanups.push(() => this.captionTracker?.destroy()), this.isActive = !0, g.add(this), this.opts.hideScrollbar && U(!0), this.emit("onActivate"), this.emitSlide("beforeShow", this.current), ut(() => {
1110
+ this.isActive && (i.classList.add("glare-is-open"), this.showSlide(this.currIndex, !0), this.cleanups.push(qe(this, i, () => this.onActivity())), this.startModules(s), this.opts.autoFocus && this.focus(), this.idle.reset());
1119
1111
  });
1120
1112
  }
1121
1113
  close() {
1122
1114
  if (!this.isActive || this.isClosing || !this.current || !this.$refs || this.emitSlide("beforeClose", this.current) === !1) return;
1123
1115
  this.isClosing = !0, this.slideshow?.stop(), this.idle.stop();
1124
- const { container: t, bg: s } = this.$refs, i = A() ? 0 : this.opts.animationDuration;
1116
+ const { container: t, bg: s } = this.$refs, i = C(this.opts).animationDuration;
1125
1117
  if (i === 0) return this.teardown();
1126
- t.classList.remove("glare-is-open"), t.classList.add("glare-is-closing"), Ft(s ?? t, i, () => this.teardown());
1118
+ t.classList.remove("glare-is-open"), t.classList.add("glare-is-closing"), zt(s ?? t, i, () => this.teardown());
1127
1119
  }
1128
1120
  next() {
1129
1121
  this.jumpTo(this.currIndex + 1);
@@ -1133,8 +1125,8 @@ const w = class w {
1133
1125
  }
1134
1126
  jumpTo(t) {
1135
1127
  if (!this.isActive || this.isClosing) return;
1136
- const s = this.group.length, i = this.opts.loop ? (t % s + s) % s : E(t, 0, s - 1);
1137
- i !== this.currIndex && (this.prevIndex = this.currIndex, this.currIndex = i, this.zoom.reset(), this.current = this.group[i], this.syncChrome(), this.showSlide(i, !1), this.thumbs?.focus(i), this.hash?.update(i), this.slideshow?.onIndexChange(), this.emitSlide("onUpdate", this.current));
1128
+ const s = this.group.length, i = this.opts.loop ? (t % s + s) % s : w(t, 0, s - 1);
1129
+ i !== this.currIndex && (this.direction = t > this.currIndex ? 1 : -1, this.prevIndex = this.currIndex, this.currIndex = i, this.zoom.reset(), this.current = this.group[i], this.syncChrome(), this.showSlide(i, !1), this.thumbs?.focus(i), this.hash?.update(i), this.slideshow?.onIndexChange(), this.emitSlide("onUpdate", this.current));
1138
1130
  }
1139
1131
  toggleZoom(t) {
1140
1132
  this.current?.type === "image" && (this.zoom.isZoomed ? this.zoom.toFit() : this.zoom.toActual(t));
@@ -1155,48 +1147,46 @@ const w = class w {
1155
1147
  async showSlide(t, s) {
1156
1148
  const i = this.group[t];
1157
1149
  if (!this.$refs || !i) return;
1158
- const { container: r, stage: o } = this.$refs, n = Nt(o, i, this.opts);
1159
- Xt(this.opts, i) && Ut(n, this.opts, this.dict), Bt(o, this.opts, this.dict), this.emitSlide("beforeLoad", i), this.opts.image.preload && Ve(this.group, t);
1150
+ const { container: n, stage: o } = this.$refs, r = Wt(o, i, this.opts);
1151
+ Qt(this.opts, i) && Gt(r, this.opts, this.dict), Vt(o, this.opts, this.dict), this.emitSlide("beforeLoad", i), this.opts.image.preload && is(this.group, t);
1160
1152
  let a = !1;
1161
1153
  try {
1162
- await Ge(i, i.$content, this.opts, this.dict);
1154
+ await ss(i, i.$content, this.opts, this.dict);
1163
1155
  } catch (l) {
1164
- a = !0, jt(i, l, this.opts, this.dict), this.emitSlide("onError", i), this.opts.onError || console.warn("[glare]", l);
1156
+ a = !0, Kt(i, l, this.opts, this.dict), this.emitSlide("onError", i), this.opts.onError || console.warn("[glare]", l);
1165
1157
  }
1166
- if (!this.isActive || this.currIndex !== t) return n.remove();
1167
- a || this.emitSlide("afterLoad", i), Wt(o), s || Te(r, this.opts), Zt(n, s), qt(o, n, this.opts.transitionDuration), this.syncZoomState(this.zoom.isZoomed), !a && (s && Le(r, i, this.opts), this.emitSlide("afterShow", i));
1158
+ if (!this.isActive || this.currIndex !== t) return r.remove();
1159
+ a || this.emitSlide("afterLoad", i), Yt(o), s || $e(n, this.opts), Ut(r, s, this.direction), this.captionTracker?.follow(r), Xt(o, r, C(this.opts).transitionDuration, this.direction), this.syncZoomState(this.zoom.isZoomed), !a && (s && Ae(n, i, this.opts), this.emitSlide("afterShow", i));
1168
1160
  }
1169
1161
  syncChrome() {
1170
- !this.$refs || !this.current || (Yt(this.$refs, this.opts, this.dict, this.current, this.group.length, this.captionFor(this.current)), this.syncZoomState(this.zoom.isZoomed));
1162
+ !this.$refs || !this.current || (Jt(this.$refs, this.opts, this.dict, this.current, this.group.length, this.captionFor(this.current)), this.syncZoomState(this.zoom.isZoomed));
1171
1163
  }
1172
1164
  captionFor(t) {
1173
1165
  const { caption: s } = this.opts;
1174
1166
  return typeof s == "function" ? s(this, t) : s ?? t.caption;
1175
1167
  }
1176
1168
  syncZoomState(t) {
1177
- this.$refs && se(this.$refs.container, this.dict, t, !!this.current?.$image);
1169
+ this.$refs && ae(this.$refs.container, this.dict, t, !!this.current?.$image);
1178
1170
  }
1179
1171
  resolveParent() {
1180
1172
  const { parentEl: t } = this.opts;
1181
1173
  return (typeof t == "string" ? document.querySelector(t) : t) ?? document.body;
1182
1174
  }
1183
1175
  startModules({ container: t, stage: s, bg: i }) {
1184
- const r = this.opts, o = C(r.thumbs, rt);
1185
- o && (this.thumbs = new ye(this, t, o));
1186
- const n = C(r.slideshow, z);
1187
- n && (this.slideshow = new ge(this, t, n));
1188
- const a = C(r.fullscreen, ot);
1189
- a && ct() && (this.fullscreen = new ie(this, t, a));
1190
- const l = C(r.share, {});
1191
- l && (this.share = new me(this, t, l)), r.hash && this.galleryName && (this.hash = new pe(this, this.galleryName)), r.wheel && (this.wheel = new we(s, {
1192
- mode: r.wheel,
1176
+ const n = this.opts, o = A(n.thumbs, rt);
1177
+ o && (this.thumbs = new we(this, t, o));
1178
+ const r = A(n.slideshow, _);
1179
+ r && (this.slideshow = new xe(this, t, r));
1180
+ const a = A(n.fullscreen, at);
1181
+ a && ft() && (this.fullscreen = new le(this, t, a)), n.hash && this.galleryName && (this.hash = new ve(this, this.galleryName)), n.wheel && (this.wheel = new Le(s, {
1182
+ mode: n.wheel,
1193
1183
  current: () => this.current,
1194
1184
  isZoomed: () => this.zoom.isZoomed,
1195
1185
  next: () => this.next(),
1196
1186
  prev: () => this.prev()
1197
- })), r.touch && (this.gestures = new de(s, {
1187
+ })), n.touch && (this.gestures = new be(s, {
1198
1188
  zoom: this.zoom,
1199
- touch: r.touch,
1189
+ touch: n.touch,
1200
1190
  bg: i,
1201
1191
  canPan: () => this.current?.type === "image",
1202
1192
  close: () => this.close(),
@@ -1212,13 +1202,12 @@ const w = class w {
1212
1202
  this.gestures,
1213
1203
  this.wheel,
1214
1204
  this.hash,
1215
- this.share,
1216
1205
  this.thumbs,
1217
1206
  this.slideshow,
1218
1207
  this.fullscreen
1219
1208
  ])
1220
1209
  t?.destroy();
1221
- this.gestures = this.wheel = this.hash = null, this.share = this.thumbs = this.slideshow = this.fullscreen = void 0, this.cleanups.forEach((t) => t()), this.cleanups = [], this.$refs?.container.remove(), this.$refs = null, b.remove(this), this.opts.hideScrollbar && b.size === 0 && W(!1), this.opts.backFocus && (this.current?.$trigger ?? this.previouslyFocused)?.focus({ preventScroll: !0 }), this.isActive = !1, this.isClosing = !1, this.current && this.emitSlide("afterClose", this.current);
1210
+ this.gestures = this.wheel = this.hash = null, this.thumbs = this.slideshow = this.fullscreen = void 0, this.cleanups.forEach((t) => t()), this.cleanups = [], this.$refs?.container.remove(), this.$refs = null, g.remove(this), this.opts.hideScrollbar && g.size === 0 && U(!1), this.opts.backFocus && (this.current?.$trigger ?? this.previouslyFocused)?.focus({ preventScroll: !0 }), this.isActive = !1, this.isClosing = !1, this.current && this.emitSlide("afterClose", this.current);
1222
1211
  }
1223
1212
  emit(t) {
1224
1213
  return this.opts[t]?.(this);
@@ -1227,42 +1216,42 @@ const w = class w {
1227
1216
  return this.opts[t]?.(this, s);
1228
1217
  }
1229
1218
  clampIndex(t) {
1230
- return E(t, 0, Math.max(0, this.group.length - 1));
1219
+ return w(t, 0, Math.max(0, this.group.length - 1));
1231
1220
  }
1232
1221
  static open(t, s = {}, i = 0) {
1233
- const r = new w(t, s, i);
1234
- return r.open(), r;
1222
+ const n = new x(t, s, i);
1223
+ return n.open(), n;
1235
1224
  }
1236
1225
  static bind(t, s = {}) {
1237
- return Me(t, s, (i, r, o) => {
1238
- new w(i, s, r, o).open();
1226
+ return ke(t, s, (i, n, o) => {
1227
+ new x(i, s, n, o).open();
1239
1228
  });
1240
1229
  }
1241
1230
  static close(t = !1) {
1242
- t ? b.all().reverse().forEach((s) => s.close()) : b.top()?.close();
1231
+ t ? g.all().reverse().forEach((s) => s.close()) : g.top()?.close();
1243
1232
  }
1244
1233
  static getInstance(t) {
1245
- return t == null ? b.top() : b.get(t);
1234
+ return t == null ? g.top() : g.get(t);
1246
1235
  }
1247
1236
  static getInstances() {
1248
- return b.all();
1237
+ return g.all();
1249
1238
  }
1250
1239
  /** Closes every instance and removes all `bind()` handlers. */
1251
1240
  static destroy() {
1252
- w.close(!0), $e();
1241
+ x.close(!0), Re();
1253
1242
  }
1254
1243
  /** Binds every `[data-glare]` element once the DOM is ready. */
1255
1244
  static autoBind(t = {}) {
1256
- const s = () => w.bind("[data-glare]", t);
1245
+ const s = () => x.bind("[data-glare]", t);
1257
1246
  document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", s, { once: !0 }) : s();
1258
1247
  }
1259
1248
  };
1260
- w.defaults = nt;
1261
- let P = w;
1262
- const Qe = P.autoBind;
1249
+ x.defaults = lt;
1250
+ let z = x;
1251
+ const os = z.autoBind;
1263
1252
  export {
1264
- P as Glare,
1265
- Qe as autoBind,
1266
- P as default
1253
+ z as Glare,
1254
+ os as autoBind,
1255
+ z as default
1267
1256
  };
1268
1257
  //# sourceMappingURL=glare.esm.js.map