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