@alxxsck/ai-assistant 3.8.1 → 3.9.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.
Files changed (31) hide show
  1. package/dist/{Avatar-Dysajrfu.js → Avatar-CFd9Otwo.js} +1 -1
  2. package/dist/ChatWidgetContent-M0SYdZ2j.js +6859 -0
  3. package/dist/MediaVideoPlayer-BlJVnBw2.js +7695 -0
  4. package/dist/MediaVideoViewer-D6FNvdwQ.js +75 -0
  5. package/dist/ai-assistant.css +1 -1
  6. package/dist/api/messages.api.d.ts +11 -0
  7. package/dist/api/messages.api.types.d.ts +38 -2
  8. package/dist/bridge-ai-chat-widget.es.js +1 -1
  9. package/dist/config/media-sharing.d.ts +1 -0
  10. package/dist/domain/message/message.store.d.ts +13 -0
  11. package/dist/domain/support-presentation/support-presentation.types.d.ts +1 -1
  12. package/dist/i18n/media-chrome.d.ts +1 -0
  13. package/dist/i18n/messages.d.ts +14 -1
  14. package/dist/i18n/support-messages.d.ts +25 -0
  15. package/dist/{index-DmB_5CV9.js → index-_XUrpFzQ.js} +3 -3
  16. package/dist/{mount-BUOeaAtc.js → mount-DNkE0lYL.js} +8672 -7870
  17. package/dist/photoswipe.esm-Bc05x7rO.js +2952 -0
  18. package/dist/ui/components/MediaPhotoViewer.d.ts +17 -0
  19. package/dist/ui/components/MediaVideoPlayer.d.ts +9 -0
  20. package/dist/ui/components/MediaVideoViewer.d.ts +7 -0
  21. package/dist/ui/components/SupportAssignmentTimeline.d.ts +4 -0
  22. package/dist/ui/components/SupportConversationControls.d.ts +4 -0
  23. package/dist/ui/components/SupportHistory.d.ts +5 -0
  24. package/dist/ui/components/UserMediaLibrary.d.ts +4 -2
  25. package/dist/ui/components/VideoTeaser.d.ts +5 -0
  26. package/dist/ui/hooks/useSupportAssignmentEvents.d.ts +2 -0
  27. package/dist/ui/hooks/useSupportConversationSync.d.ts +1 -0
  28. package/dist/ui/hooks/useSupportReadOnly.d.ts +2 -0
  29. package/dist/ui/responder-visual-state.d.ts +1 -1
  30. package/package.json +5 -3
  31. package/dist/ChatWidgetContent-GopG0V-j.js +0 -6288
@@ -0,0 +1,2952 @@
1
+ function f(r, t, i) {
2
+ const e = document.createElement(t);
3
+ return r && (e.className = r), i && i.appendChild(e), e;
4
+ }
5
+ function p(r, t) {
6
+ return r.x = t.x, r.y = t.y, t.id !== void 0 && (r.id = t.id), r;
7
+ }
8
+ function M(r) {
9
+ r.x = Math.round(r.x), r.y = Math.round(r.y);
10
+ }
11
+ function A(r, t) {
12
+ const i = Math.abs(r.x - t.x), e = Math.abs(r.y - t.y);
13
+ return Math.sqrt(i * i + e * e);
14
+ }
15
+ function x(r, t) {
16
+ return r.x === t.x && r.y === t.y;
17
+ }
18
+ function b(r, t, i) {
19
+ return Math.min(Math.max(r, t), i);
20
+ }
21
+ function I(r, t, i) {
22
+ let e = `translate3d(${r}px,${t || 0}px,0)`;
23
+ return i !== void 0 && (e += ` scale3d(${i},${i},1)`), e;
24
+ }
25
+ function y(r, t, i, e) {
26
+ r.style.transform = I(t, i, e);
27
+ }
28
+ const $ = "cubic-bezier(.4,0,.22,1)";
29
+ function R(r, t, i, e) {
30
+ r.style.transition = t ? `${t} ${i}ms ${e || $}` : "none";
31
+ }
32
+ function L(r, t, i) {
33
+ r.style.width = typeof t == "number" ? `${t}px` : t, r.style.height = typeof i == "number" ? `${i}px` : i;
34
+ }
35
+ function U(r) {
36
+ R(r);
37
+ }
38
+ function q(r) {
39
+ return "decode" in r ? r.decode().catch(() => {
40
+ }) : r.complete ? Promise.resolve(r) : new Promise((t, i) => {
41
+ r.onload = () => t(r), r.onerror = i;
42
+ });
43
+ }
44
+ const _ = {
45
+ IDLE: "idle",
46
+ LOADING: "loading",
47
+ LOADED: "loaded",
48
+ ERROR: "error"
49
+ };
50
+ function G(r) {
51
+ return "button" in r && r.button === 1 || r.ctrlKey || r.metaKey || r.altKey || r.shiftKey;
52
+ }
53
+ function K(r, t, i = document) {
54
+ let e = [];
55
+ if (r instanceof Element)
56
+ e = [r];
57
+ else if (r instanceof NodeList || Array.isArray(r))
58
+ e = Array.from(r);
59
+ else {
60
+ const s = typeof r == "string" ? r : t;
61
+ s && (e = Array.from(i.querySelectorAll(s)));
62
+ }
63
+ return e;
64
+ }
65
+ function C() {
66
+ return !!(navigator.vendor && navigator.vendor.match(/apple/i));
67
+ }
68
+ let F = !1;
69
+ try {
70
+ window.addEventListener("test", null, Object.defineProperty({}, "passive", {
71
+ get: () => {
72
+ F = !0;
73
+ }
74
+ }));
75
+ } catch {
76
+ }
77
+ class X {
78
+ constructor() {
79
+ this._pool = [];
80
+ }
81
+ /**
82
+ * Adds event listeners
83
+ *
84
+ * @param {PoolItem['target']} target
85
+ * @param {PoolItem['type']} type Can be multiple, separated by space.
86
+ * @param {PoolItem['listener']} listener
87
+ * @param {PoolItem['passive']} [passive]
88
+ */
89
+ add(t, i, e, s) {
90
+ this._toggleListener(t, i, e, s);
91
+ }
92
+ /**
93
+ * Removes event listeners
94
+ *
95
+ * @param {PoolItem['target']} target
96
+ * @param {PoolItem['type']} type
97
+ * @param {PoolItem['listener']} listener
98
+ * @param {PoolItem['passive']} [passive]
99
+ */
100
+ remove(t, i, e, s) {
101
+ this._toggleListener(t, i, e, s, !0);
102
+ }
103
+ /**
104
+ * Removes all bound events
105
+ */
106
+ removeAll() {
107
+ this._pool.forEach((t) => {
108
+ this._toggleListener(t.target, t.type, t.listener, t.passive, !0, !0);
109
+ }), this._pool = [];
110
+ }
111
+ /**
112
+ * Adds or removes event
113
+ *
114
+ * @private
115
+ * @param {PoolItem['target']} target
116
+ * @param {PoolItem['type']} type
117
+ * @param {PoolItem['listener']} listener
118
+ * @param {PoolItem['passive']} [passive]
119
+ * @param {boolean} [unbind] Whether the event should be added or removed
120
+ * @param {boolean} [skipPool] Whether events pool should be skipped
121
+ */
122
+ _toggleListener(t, i, e, s, n, o) {
123
+ if (!t)
124
+ return;
125
+ const a = n ? "removeEventListener" : "addEventListener";
126
+ i.split(" ").forEach((l) => {
127
+ if (l) {
128
+ o || (n ? this._pool = this._pool.filter((d) => d.type !== l || d.listener !== e || d.target !== t) : this._pool.push({
129
+ target: t,
130
+ type: l,
131
+ listener: e,
132
+ passive: s
133
+ }));
134
+ const c = F ? {
135
+ passive: s || !1
136
+ } : !1;
137
+ t[a](l, e, c);
138
+ }
139
+ });
140
+ }
141
+ }
142
+ function B(r, t) {
143
+ if (r.getViewportSizeFn) {
144
+ const i = r.getViewportSizeFn(r, t);
145
+ if (i)
146
+ return i;
147
+ }
148
+ return {
149
+ x: document.documentElement.clientWidth,
150
+ // TODO: height on mobile is very incosistent due to toolbar
151
+ // find a way to improve this
152
+ //
153
+ // document.documentElement.clientHeight - doesn't seem to work well
154
+ y: window.innerHeight
155
+ };
156
+ }
157
+ function S(r, t, i, e, s) {
158
+ let n = 0;
159
+ if (t.paddingFn)
160
+ n = t.paddingFn(i, e, s)[r];
161
+ else if (t.padding)
162
+ n = t.padding[r];
163
+ else {
164
+ const o = "padding" + r[0].toUpperCase() + r.slice(1);
165
+ t[o] && (n = t[o]);
166
+ }
167
+ return Number(n) || 0;
168
+ }
169
+ function N(r, t, i, e) {
170
+ return {
171
+ x: t.x - S("left", r, t, i, e) - S("right", r, t, i, e),
172
+ y: t.y - S("top", r, t, i, e) - S("bottom", r, t, i, e)
173
+ };
174
+ }
175
+ class Y {
176
+ /**
177
+ * @param {Slide} slide
178
+ */
179
+ constructor(t) {
180
+ this.slide = t, this.currZoomLevel = 1, this.center = /** @type {Point} */
181
+ {
182
+ x: 0,
183
+ y: 0
184
+ }, this.max = /** @type {Point} */
185
+ {
186
+ x: 0,
187
+ y: 0
188
+ }, this.min = /** @type {Point} */
189
+ {
190
+ x: 0,
191
+ y: 0
192
+ };
193
+ }
194
+ /**
195
+ * _getItemBounds
196
+ *
197
+ * @param {number} currZoomLevel
198
+ */
199
+ update(t) {
200
+ this.currZoomLevel = t, this.slide.width ? (this._updateAxis("x"), this._updateAxis("y"), this.slide.pswp.dispatch("calcBounds", {
201
+ slide: this.slide
202
+ })) : this.reset();
203
+ }
204
+ /**
205
+ * _calculateItemBoundsForAxis
206
+ *
207
+ * @param {Axis} axis
208
+ */
209
+ _updateAxis(t) {
210
+ const {
211
+ pswp: i
212
+ } = this.slide, e = this.slide[t === "x" ? "width" : "height"] * this.currZoomLevel, n = S(t === "x" ? "left" : "top", i.options, i.viewportSize, this.slide.data, this.slide.index), o = this.slide.panAreaSize[t];
213
+ this.center[t] = Math.round((o - e) / 2) + n, this.max[t] = e > o ? Math.round(o - e) + n : this.center[t], this.min[t] = e > o ? n : this.center[t];
214
+ }
215
+ // _getZeroBounds
216
+ reset() {
217
+ this.center.x = 0, this.center.y = 0, this.max.x = 0, this.max.y = 0, this.min.x = 0, this.min.y = 0;
218
+ }
219
+ /**
220
+ * Correct pan position if it's beyond the bounds
221
+ *
222
+ * @param {Axis} axis x or y
223
+ * @param {number} panOffset
224
+ * @returns {number}
225
+ */
226
+ correctPan(t, i) {
227
+ return b(i, this.max[t], this.min[t]);
228
+ }
229
+ }
230
+ const T = 4e3;
231
+ class k {
232
+ /**
233
+ * @param {PhotoSwipeOptions} options PhotoSwipe options
234
+ * @param {SlideData} itemData Slide data
235
+ * @param {number} index Slide index
236
+ * @param {PhotoSwipe} [pswp] PhotoSwipe instance, can be undefined if not initialized yet
237
+ */
238
+ constructor(t, i, e, s) {
239
+ this.pswp = s, this.options = t, this.itemData = i, this.index = e, this.panAreaSize = null, this.elementSize = null, this.fit = 1, this.fill = 1, this.vFill = 1, this.initial = 1, this.secondary = 1, this.max = 1, this.min = 1;
240
+ }
241
+ /**
242
+ * Calculate initial, secondary and maximum zoom level for the specified slide.
243
+ *
244
+ * It should be called when either image or viewport size changes.
245
+ *
246
+ * @param {number} maxWidth
247
+ * @param {number} maxHeight
248
+ * @param {Point} panAreaSize
249
+ */
250
+ update(t, i, e) {
251
+ const s = {
252
+ x: t,
253
+ y: i
254
+ };
255
+ this.elementSize = s, this.panAreaSize = e;
256
+ const n = e.x / s.x, o = e.y / s.y;
257
+ this.fit = Math.min(1, n < o ? n : o), this.fill = Math.min(1, n > o ? n : o), this.vFill = Math.min(1, o), this.initial = this._getInitial(), this.secondary = this._getSecondary(), this.max = Math.max(this.initial, this.secondary, this._getMax()), this.min = Math.min(this.fit, this.initial, this.secondary), this.pswp && this.pswp.dispatch("zoomLevelsUpdate", {
258
+ zoomLevels: this,
259
+ slideData: this.itemData
260
+ });
261
+ }
262
+ /**
263
+ * Parses user-defined zoom option.
264
+ *
265
+ * @private
266
+ * @param {'initial' | 'secondary' | 'max'} optionPrefix Zoom level option prefix (initial, secondary, max)
267
+ * @returns { number | undefined }
268
+ */
269
+ _parseZoomLevelOption(t) {
270
+ const i = (
271
+ /** @type {'initialZoomLevel' | 'secondaryZoomLevel' | 'maxZoomLevel'} */
272
+ t + "ZoomLevel"
273
+ ), e = this.options[i];
274
+ if (e)
275
+ return typeof e == "function" ? e(this) : e === "fill" ? this.fill : e === "fit" ? this.fit : Number(e);
276
+ }
277
+ /**
278
+ * Get zoom level to which image will be zoomed after double-tap gesture,
279
+ * or when user clicks on zoom icon,
280
+ * or mouse-click on image itself.
281
+ * If you return 1 image will be zoomed to its original size.
282
+ *
283
+ * @private
284
+ * @return {number}
285
+ */
286
+ _getSecondary() {
287
+ let t = this._parseZoomLevelOption("secondary");
288
+ return t || (t = Math.min(1, this.fit * 3), this.elementSize && t * this.elementSize.x > T && (t = T / this.elementSize.x), t);
289
+ }
290
+ /**
291
+ * Get initial image zoom level.
292
+ *
293
+ * @private
294
+ * @return {number}
295
+ */
296
+ _getInitial() {
297
+ return this._parseZoomLevelOption("initial") || this.fit;
298
+ }
299
+ /**
300
+ * Maximum zoom level when user zooms
301
+ * via zoom/pinch gesture,
302
+ * via cmd/ctrl-wheel or via trackpad.
303
+ *
304
+ * @private
305
+ * @return {number}
306
+ */
307
+ _getMax() {
308
+ return this._parseZoomLevelOption("max") || Math.max(1, this.fit * 4);
309
+ }
310
+ }
311
+ class j {
312
+ /**
313
+ * @param {SlideData} data
314
+ * @param {number} index
315
+ * @param {PhotoSwipe} pswp
316
+ */
317
+ constructor(t, i, e) {
318
+ this.data = t, this.index = i, this.pswp = e, this.isActive = i === e.currIndex, this.currentResolution = 0, this.panAreaSize = {
319
+ x: 0,
320
+ y: 0
321
+ }, this.pan = {
322
+ x: 0,
323
+ y: 0
324
+ }, this.isFirstSlide = this.isActive && !e.opener.isOpen, this.zoomLevels = new k(e.options, t, i, e), this.pswp.dispatch("gettingData", {
325
+ slide: this,
326
+ data: this.data,
327
+ index: i
328
+ }), this.content = this.pswp.contentLoader.getContentBySlide(this), this.container = f("pswp__zoom-wrap", "div"), this.holderElement = null, this.currZoomLevel = 1, this.width = this.content.width, this.height = this.content.height, this.heavyAppended = !1, this.bounds = new Y(this), this.prevDisplayedWidth = -1, this.prevDisplayedHeight = -1, this.pswp.dispatch("slideInit", {
329
+ slide: this
330
+ });
331
+ }
332
+ /**
333
+ * If this slide is active/current/visible
334
+ *
335
+ * @param {boolean} isActive
336
+ */
337
+ setIsActive(t) {
338
+ t && !this.isActive ? this.activate() : !t && this.isActive && this.deactivate();
339
+ }
340
+ /**
341
+ * Appends slide content to DOM
342
+ *
343
+ * @param {HTMLElement} holderElement
344
+ */
345
+ append(t) {
346
+ this.holderElement = t, this.container.style.transformOrigin = "0 0", this.data && (this.calculateSize(), this.load(), this.updateContentSize(), this.appendHeavy(), this.holderElement.appendChild(this.container), this.zoomAndPanToInitial(), this.pswp.dispatch("firstZoomPan", {
347
+ slide: this
348
+ }), this.applyCurrentZoomPan(), this.pswp.dispatch("afterSetContent", {
349
+ slide: this
350
+ }), this.isActive && this.activate());
351
+ }
352
+ load() {
353
+ this.content.load(!1), this.pswp.dispatch("slideLoad", {
354
+ slide: this
355
+ });
356
+ }
357
+ /**
358
+ * Append "heavy" DOM elements
359
+ *
360
+ * This may depend on a type of slide,
361
+ * but generally these are large images.
362
+ */
363
+ appendHeavy() {
364
+ const {
365
+ pswp: t
366
+ } = this;
367
+ this.heavyAppended || !t.opener.isOpen || t.mainScroll.isShifted() || !this.isActive && !1 || this.pswp.dispatch("appendHeavy", {
368
+ slide: this
369
+ }).defaultPrevented || (this.heavyAppended = !0, this.content.append(), this.pswp.dispatch("appendHeavyContent", {
370
+ slide: this
371
+ }));
372
+ }
373
+ /**
374
+ * Triggered when this slide is active (selected).
375
+ *
376
+ * If it's part of opening/closing transition -
377
+ * activate() will trigger after the transition is ended.
378
+ */
379
+ activate() {
380
+ this.isActive = !0, this.appendHeavy(), this.content.activate(), this.pswp.dispatch("slideActivate", {
381
+ slide: this
382
+ });
383
+ }
384
+ /**
385
+ * Triggered when this slide becomes inactive.
386
+ *
387
+ * Slide can become inactive only after it was active.
388
+ */
389
+ deactivate() {
390
+ this.isActive = !1, this.content.deactivate(), this.currZoomLevel !== this.zoomLevels.initial && this.calculateSize(), this.currentResolution = 0, this.zoomAndPanToInitial(), this.applyCurrentZoomPan(), this.updateContentSize(), this.pswp.dispatch("slideDeactivate", {
391
+ slide: this
392
+ });
393
+ }
394
+ /**
395
+ * The slide should destroy itself, it will never be used again.
396
+ * (unbind all events and destroy internal components)
397
+ */
398
+ destroy() {
399
+ this.content.hasSlide = !1, this.content.remove(), this.container.remove(), this.pswp.dispatch("slideDestroy", {
400
+ slide: this
401
+ });
402
+ }
403
+ resize() {
404
+ this.currZoomLevel === this.zoomLevels.initial || !this.isActive ? (this.calculateSize(), this.currentResolution = 0, this.zoomAndPanToInitial(), this.applyCurrentZoomPan(), this.updateContentSize()) : (this.calculateSize(), this.bounds.update(this.currZoomLevel), this.panTo(this.pan.x, this.pan.y));
405
+ }
406
+ /**
407
+ * Apply size to current slide content,
408
+ * based on the current resolution and scale.
409
+ *
410
+ * @param {boolean} [force] if size should be updated even if dimensions weren't changed
411
+ */
412
+ updateContentSize(t) {
413
+ const i = this.currentResolution || this.zoomLevels.initial;
414
+ if (!i)
415
+ return;
416
+ const e = Math.round(this.width * i) || this.pswp.viewportSize.x, s = Math.round(this.height * i) || this.pswp.viewportSize.y;
417
+ !this.sizeChanged(e, s) && !t || this.content.setDisplayedSize(e, s);
418
+ }
419
+ /**
420
+ * @param {number} width
421
+ * @param {number} height
422
+ */
423
+ sizeChanged(t, i) {
424
+ return t !== this.prevDisplayedWidth || i !== this.prevDisplayedHeight ? (this.prevDisplayedWidth = t, this.prevDisplayedHeight = i, !0) : !1;
425
+ }
426
+ /** @returns {HTMLImageElement | HTMLDivElement | null | undefined} */
427
+ getPlaceholderElement() {
428
+ var t;
429
+ return (t = this.content.placeholder) === null || t === void 0 ? void 0 : t.element;
430
+ }
431
+ /**
432
+ * Zoom current slide image to...
433
+ *
434
+ * @param {number} destZoomLevel Destination zoom level.
435
+ * @param {Point} [centerPoint]
436
+ * Transform origin center point, or false if viewport center should be used.
437
+ * @param {number | false} [transitionDuration] Transition duration, may be set to 0.
438
+ * @param {boolean} [ignoreBounds] Minimum and maximum zoom levels will be ignored.
439
+ */
440
+ zoomTo(t, i, e, s) {
441
+ const {
442
+ pswp: n
443
+ } = this;
444
+ if (!this.isZoomable() || n.mainScroll.isShifted())
445
+ return;
446
+ n.dispatch("beforeZoomTo", {
447
+ destZoomLevel: t,
448
+ centerPoint: i,
449
+ transitionDuration: e
450
+ }), n.animations.stopAllPan();
451
+ const o = this.currZoomLevel;
452
+ s || (t = b(t, this.zoomLevels.min, this.zoomLevels.max)), this.setZoomLevel(t), this.pan.x = this.calculateZoomToPanOffset("x", i, o), this.pan.y = this.calculateZoomToPanOffset("y", i, o), M(this.pan);
453
+ const a = () => {
454
+ this._setResolution(t), this.applyCurrentZoomPan();
455
+ };
456
+ e ? n.animations.startTransition({
457
+ isPan: !0,
458
+ name: "zoomTo",
459
+ target: this.container,
460
+ transform: this.getCurrentTransform(),
461
+ onComplete: a,
462
+ duration: e,
463
+ easing: n.options.easing
464
+ }) : a();
465
+ }
466
+ /**
467
+ * @param {Point} [centerPoint]
468
+ */
469
+ toggleZoom(t) {
470
+ this.zoomTo(this.currZoomLevel === this.zoomLevels.initial ? this.zoomLevels.secondary : this.zoomLevels.initial, t, this.pswp.options.zoomAnimationDuration);
471
+ }
472
+ /**
473
+ * Updates zoom level property and recalculates new pan bounds,
474
+ * unlike zoomTo it does not apply transform (use applyCurrentZoomPan)
475
+ *
476
+ * @param {number} currZoomLevel
477
+ */
478
+ setZoomLevel(t) {
479
+ this.currZoomLevel = t, this.bounds.update(this.currZoomLevel);
480
+ }
481
+ /**
482
+ * Get pan position after zoom at a given `point`.
483
+ *
484
+ * Always call setZoomLevel(newZoomLevel) beforehand to recalculate
485
+ * pan bounds according to the new zoom level.
486
+ *
487
+ * @param {'x' | 'y'} axis
488
+ * @param {Point} [point]
489
+ * point based on which zoom is performed, usually refers to the current mouse position,
490
+ * if false - viewport center will be used.
491
+ * @param {number} [prevZoomLevel] Zoom level before new zoom was applied.
492
+ * @returns {number}
493
+ */
494
+ calculateZoomToPanOffset(t, i, e) {
495
+ if (this.bounds.max[t] - this.bounds.min[t] === 0)
496
+ return this.bounds.center[t];
497
+ i || (i = this.pswp.getViewportCenterPoint()), e || (e = this.zoomLevels.initial);
498
+ const n = this.currZoomLevel / e;
499
+ return this.bounds.correctPan(t, (this.pan[t] - i[t]) * n + i[t]);
500
+ }
501
+ /**
502
+ * Apply pan and keep it within bounds.
503
+ *
504
+ * @param {number} panX
505
+ * @param {number} panY
506
+ */
507
+ panTo(t, i) {
508
+ this.pan.x = this.bounds.correctPan("x", t), this.pan.y = this.bounds.correctPan("y", i), this.applyCurrentZoomPan();
509
+ }
510
+ /**
511
+ * If the slide in the current state can be panned by the user
512
+ * @returns {boolean}
513
+ */
514
+ isPannable() {
515
+ return !!this.width && this.currZoomLevel > this.zoomLevels.fit;
516
+ }
517
+ /**
518
+ * If the slide can be zoomed
519
+ * @returns {boolean}
520
+ */
521
+ isZoomable() {
522
+ return !!this.width && this.content.isZoomable();
523
+ }
524
+ /**
525
+ * Apply transform and scale based on
526
+ * the current pan position (this.pan) and zoom level (this.currZoomLevel)
527
+ */
528
+ applyCurrentZoomPan() {
529
+ this._applyZoomTransform(this.pan.x, this.pan.y, this.currZoomLevel), this === this.pswp.currSlide && this.pswp.dispatch("zoomPanUpdate", {
530
+ slide: this
531
+ });
532
+ }
533
+ zoomAndPanToInitial() {
534
+ this.currZoomLevel = this.zoomLevels.initial, this.bounds.update(this.currZoomLevel), p(this.pan, this.bounds.center), this.pswp.dispatch("initialZoomPan", {
535
+ slide: this
536
+ });
537
+ }
538
+ /**
539
+ * Set translate and scale based on current resolution
540
+ *
541
+ * @param {number} x
542
+ * @param {number} y
543
+ * @param {number} zoom
544
+ * @private
545
+ */
546
+ _applyZoomTransform(t, i, e) {
547
+ e /= this.currentResolution || this.zoomLevels.initial, y(this.container, t, i, e);
548
+ }
549
+ calculateSize() {
550
+ const {
551
+ pswp: t
552
+ } = this;
553
+ p(this.panAreaSize, N(t.options, t.viewportSize, this.data, this.index)), this.zoomLevels.update(this.width, this.height, this.panAreaSize), t.dispatch("calcSlideSize", {
554
+ slide: this
555
+ });
556
+ }
557
+ /** @returns {string} */
558
+ getCurrentTransform() {
559
+ const t = this.currZoomLevel / (this.currentResolution || this.zoomLevels.initial);
560
+ return I(this.pan.x, this.pan.y, t);
561
+ }
562
+ /**
563
+ * Set resolution and re-render the image.
564
+ *
565
+ * For example, if the real image size is 2000x1500,
566
+ * and resolution is 0.5 - it will be rendered as 1000x750.
567
+ *
568
+ * Image with zoom level 2 and resolution 0.5 is
569
+ * the same as image with zoom level 1 and resolution 1.
570
+ *
571
+ * Used to optimize animations and make
572
+ * sure that browser renders image in the highest quality.
573
+ * Also used by responsive images to load the correct one.
574
+ *
575
+ * @param {number} newResolution
576
+ */
577
+ _setResolution(t) {
578
+ t !== this.currentResolution && (this.currentResolution = t, this.updateContentSize(), this.pswp.dispatch("resolutionChanged"));
579
+ }
580
+ }
581
+ const Q = 0.35, J = 0.6, z = 0.4, E = 0.5;
582
+ function tt(r, t) {
583
+ return r * t / (1 - t);
584
+ }
585
+ class it {
586
+ /**
587
+ * @param {Gestures} gestures
588
+ */
589
+ constructor(t) {
590
+ this.gestures = t, this.pswp = t.pswp, this.startPan = {
591
+ x: 0,
592
+ y: 0
593
+ };
594
+ }
595
+ start() {
596
+ this.pswp.currSlide && p(this.startPan, this.pswp.currSlide.pan), this.pswp.animations.stopAll();
597
+ }
598
+ change() {
599
+ const {
600
+ p1: t,
601
+ prevP1: i,
602
+ dragAxis: e
603
+ } = this.gestures, {
604
+ currSlide: s
605
+ } = this.pswp;
606
+ if (e === "y" && this.pswp.options.closeOnVerticalDrag && s && s.currZoomLevel <= s.zoomLevels.fit && !this.gestures.isMultitouch) {
607
+ const n = s.pan.y + (t.y - i.y);
608
+ if (!this.pswp.dispatch("verticalDrag", {
609
+ panY: n
610
+ }).defaultPrevented) {
611
+ this._setPanWithFriction("y", n, J);
612
+ const o = 1 - Math.abs(this._getVerticalDragRatio(s.pan.y));
613
+ this.pswp.applyBgOpacity(o), s.applyCurrentZoomPan();
614
+ }
615
+ } else
616
+ this._panOrMoveMainScroll("x") || (this._panOrMoveMainScroll("y"), s && (M(s.pan), s.applyCurrentZoomPan()));
617
+ }
618
+ end() {
619
+ const {
620
+ velocity: t
621
+ } = this.gestures, {
622
+ mainScroll: i,
623
+ currSlide: e
624
+ } = this.pswp;
625
+ let s = 0;
626
+ if (this.pswp.animations.stopAll(), i.isShifted()) {
627
+ const o = (i.x - i.getCurrSlideX()) / this.pswp.viewportSize.x;
628
+ t.x < -E && o < 0 || t.x < 0.1 && o < -0.5 ? (s = 1, t.x = Math.min(t.x, 0)) : (t.x > E && o > 0 || t.x > -0.1 && o > 0.5) && (s = -1, t.x = Math.max(t.x, 0)), i.moveIndexBy(s, !0, t.x);
629
+ }
630
+ e && e.currZoomLevel > e.zoomLevels.max || this.gestures.isMultitouch ? this.gestures.zoomLevels.correctZoomPan(!0) : (this._finishPanGestureForAxis("x"), this._finishPanGestureForAxis("y"));
631
+ }
632
+ /**
633
+ * @private
634
+ * @param {'x' | 'y'} axis
635
+ */
636
+ _finishPanGestureForAxis(t) {
637
+ const {
638
+ velocity: i
639
+ } = this.gestures, {
640
+ currSlide: e
641
+ } = this.pswp;
642
+ if (!e)
643
+ return;
644
+ const {
645
+ pan: s,
646
+ bounds: n
647
+ } = e, o = s[t], a = this.pswp.bgOpacity < 1 && t === "y", l = o + tt(i[t], 0.995);
648
+ if (a) {
649
+ const v = this._getVerticalDragRatio(o), w = this._getVerticalDragRatio(l);
650
+ if (v < 0 && w < -z || v > 0 && w > z) {
651
+ this.pswp.close();
652
+ return;
653
+ }
654
+ }
655
+ const c = n.correctPan(t, l);
656
+ if (o === c)
657
+ return;
658
+ const d = c === l ? 1 : 0.82, u = this.pswp.bgOpacity, m = c - o;
659
+ this.pswp.animations.startSpring({
660
+ name: "panGesture" + t,
661
+ isPan: !0,
662
+ start: o,
663
+ end: c,
664
+ velocity: i[t],
665
+ dampingRatio: d,
666
+ onUpdate: (v) => {
667
+ if (a && this.pswp.bgOpacity < 1) {
668
+ const w = 1 - (c - v) / m;
669
+ this.pswp.applyBgOpacity(b(u + (1 - u) * w, 0, 1));
670
+ }
671
+ s[t] = Math.floor(v), e.applyCurrentZoomPan();
672
+ }
673
+ });
674
+ }
675
+ /**
676
+ * Update position of the main scroll,
677
+ * or/and update pan position of the current slide.
678
+ *
679
+ * Should return true if it changes (or can change) main scroll.
680
+ *
681
+ * @private
682
+ * @param {'x' | 'y'} axis
683
+ * @returns {boolean}
684
+ */
685
+ _panOrMoveMainScroll(t) {
686
+ const {
687
+ p1: i,
688
+ dragAxis: e,
689
+ prevP1: s,
690
+ isMultitouch: n
691
+ } = this.gestures, {
692
+ currSlide: o,
693
+ mainScroll: a
694
+ } = this.pswp, h = i[t] - s[t], l = a.x + h;
695
+ if (!h || !o)
696
+ return !1;
697
+ if (t === "x" && !o.isPannable() && !n)
698
+ return a.moveTo(l, !0), !0;
699
+ const {
700
+ bounds: c
701
+ } = o, d = o.pan[t] + h;
702
+ if (this.pswp.options.allowPanToNext && e === "x" && t === "x" && !n) {
703
+ const u = a.getCurrSlideX(), m = a.x - u, v = h > 0, w = !v;
704
+ if (d > c.min[t] && v) {
705
+ if (c.min[t] <= this.startPan[t])
706
+ return a.moveTo(l, !0), !0;
707
+ this._setPanWithFriction(t, d);
708
+ } else if (d < c.max[t] && w) {
709
+ if (this.startPan[t] <= c.max[t])
710
+ return a.moveTo(l, !0), !0;
711
+ this._setPanWithFriction(t, d);
712
+ } else if (m !== 0) {
713
+ if (m > 0)
714
+ return a.moveTo(Math.max(l, u), !0), !0;
715
+ if (m < 0)
716
+ return a.moveTo(Math.min(l, u), !0), !0;
717
+ } else
718
+ this._setPanWithFriction(t, d);
719
+ } else
720
+ t === "y" ? !a.isShifted() && c.min.y !== c.max.y && this._setPanWithFriction(t, d) : this._setPanWithFriction(t, d);
721
+ return !1;
722
+ }
723
+ // If we move above - the ratio is negative
724
+ // If we move below the ratio is positive
725
+ /**
726
+ * Relation between pan Y position and third of viewport height.
727
+ *
728
+ * When we are at initial position (center bounds) - the ratio is 0,
729
+ * if position is shifted upwards - the ratio is negative,
730
+ * if position is shifted downwards - the ratio is positive.
731
+ *
732
+ * @private
733
+ * @param {number} panY The current pan Y position.
734
+ * @returns {number}
735
+ */
736
+ _getVerticalDragRatio(t) {
737
+ var i, e;
738
+ return (t - ((i = (e = this.pswp.currSlide) === null || e === void 0 ? void 0 : e.bounds.center.y) !== null && i !== void 0 ? i : 0)) / (this.pswp.viewportSize.y / 3);
739
+ }
740
+ /**
741
+ * Set pan position of the current slide.
742
+ * Apply friction if the position is beyond the pan bounds,
743
+ * or if custom friction is defined.
744
+ *
745
+ * @private
746
+ * @param {'x' | 'y'} axis
747
+ * @param {number} potentialPan
748
+ * @param {number} [customFriction] (0.1 - 1)
749
+ */
750
+ _setPanWithFriction(t, i, e) {
751
+ const {
752
+ currSlide: s
753
+ } = this.pswp;
754
+ if (!s)
755
+ return;
756
+ const {
757
+ pan: n,
758
+ bounds: o
759
+ } = s;
760
+ if (o.correctPan(t, i) !== i || e) {
761
+ const h = Math.round(i - n[t]);
762
+ n[t] += h * (e || Q);
763
+ } else
764
+ n[t] = i;
765
+ }
766
+ }
767
+ const et = 0.05, st = 0.15;
768
+ function O(r, t, i) {
769
+ return r.x = (t.x + i.x) / 2, r.y = (t.y + i.y) / 2, r;
770
+ }
771
+ class nt {
772
+ /**
773
+ * @param {Gestures} gestures
774
+ */
775
+ constructor(t) {
776
+ this.gestures = t, this._startPan = {
777
+ x: 0,
778
+ y: 0
779
+ }, this._startZoomPoint = {
780
+ x: 0,
781
+ y: 0
782
+ }, this._zoomPoint = {
783
+ x: 0,
784
+ y: 0
785
+ }, this._wasOverFitZoomLevel = !1, this._startZoomLevel = 1;
786
+ }
787
+ start() {
788
+ const {
789
+ currSlide: t
790
+ } = this.gestures.pswp;
791
+ t && (this._startZoomLevel = t.currZoomLevel, p(this._startPan, t.pan)), this.gestures.pswp.animations.stopAllPan(), this._wasOverFitZoomLevel = !1;
792
+ }
793
+ change() {
794
+ const {
795
+ p1: t,
796
+ startP1: i,
797
+ p2: e,
798
+ startP2: s,
799
+ pswp: n
800
+ } = this.gestures, {
801
+ currSlide: o
802
+ } = n;
803
+ if (!o)
804
+ return;
805
+ const a = o.zoomLevels.min, h = o.zoomLevels.max;
806
+ if (!o.isZoomable() || n.mainScroll.isShifted())
807
+ return;
808
+ O(this._startZoomPoint, i, s), O(this._zoomPoint, t, e);
809
+ let l = 1 / A(i, s) * A(t, e) * this._startZoomLevel;
810
+ if (l > o.zoomLevels.initial + o.zoomLevels.initial / 15 && (this._wasOverFitZoomLevel = !0), l < a)
811
+ if (n.options.pinchToClose && !this._wasOverFitZoomLevel && this._startZoomLevel <= o.zoomLevels.initial) {
812
+ const c = 1 - (a - l) / (a / 1.2);
813
+ n.dispatch("pinchClose", {
814
+ bgOpacity: c
815
+ }).defaultPrevented || n.applyBgOpacity(c);
816
+ } else
817
+ l = a - (a - l) * st;
818
+ else l > h && (l = h + (l - h) * et);
819
+ o.pan.x = this._calculatePanForZoomLevel("x", l), o.pan.y = this._calculatePanForZoomLevel("y", l), o.setZoomLevel(l), o.applyCurrentZoomPan();
820
+ }
821
+ end() {
822
+ const {
823
+ pswp: t
824
+ } = this.gestures, {
825
+ currSlide: i
826
+ } = t;
827
+ (!i || i.currZoomLevel < i.zoomLevels.initial) && !this._wasOverFitZoomLevel && t.options.pinchToClose ? t.close() : this.correctZoomPan();
828
+ }
829
+ /**
830
+ * @private
831
+ * @param {'x' | 'y'} axis
832
+ * @param {number} currZoomLevel
833
+ * @returns {number}
834
+ */
835
+ _calculatePanForZoomLevel(t, i) {
836
+ const e = i / this._startZoomLevel;
837
+ return this._zoomPoint[t] - (this._startZoomPoint[t] - this._startPan[t]) * e;
838
+ }
839
+ /**
840
+ * Correct currZoomLevel and pan if they are
841
+ * beyond minimum or maximum values.
842
+ * With animation.
843
+ *
844
+ * @param {boolean} [ignoreGesture]
845
+ * Wether gesture coordinates should be ignored when calculating destination pan position.
846
+ */
847
+ correctZoomPan(t) {
848
+ const {
849
+ pswp: i
850
+ } = this.gestures, {
851
+ currSlide: e
852
+ } = i;
853
+ if (!(e != null && e.isZoomable()))
854
+ return;
855
+ this._zoomPoint.x === 0 && (t = !0);
856
+ const s = e.currZoomLevel;
857
+ let n, o = !0;
858
+ s < e.zoomLevels.initial ? n = e.zoomLevels.initial : s > e.zoomLevels.max ? n = e.zoomLevels.max : (o = !1, n = s);
859
+ const a = i.bgOpacity, h = i.bgOpacity < 1, l = p({
860
+ x: 0,
861
+ y: 0
862
+ }, e.pan);
863
+ let c = p({
864
+ x: 0,
865
+ y: 0
866
+ }, l);
867
+ t && (this._zoomPoint.x = 0, this._zoomPoint.y = 0, this._startZoomPoint.x = 0, this._startZoomPoint.y = 0, this._startZoomLevel = s, p(this._startPan, l)), o && (c = {
868
+ x: this._calculatePanForZoomLevel("x", n),
869
+ y: this._calculatePanForZoomLevel("y", n)
870
+ }), e.setZoomLevel(n), c = {
871
+ x: e.bounds.correctPan("x", c.x),
872
+ y: e.bounds.correctPan("y", c.y)
873
+ }, e.setZoomLevel(s);
874
+ const d = !x(c, l);
875
+ if (!d && !o && !h) {
876
+ e._setResolution(n), e.applyCurrentZoomPan();
877
+ return;
878
+ }
879
+ i.animations.stopAllPan(), i.animations.startSpring({
880
+ isPan: !0,
881
+ start: 0,
882
+ end: 1e3,
883
+ velocity: 0,
884
+ dampingRatio: 1,
885
+ naturalFrequency: 40,
886
+ onUpdate: (u) => {
887
+ if (u /= 1e3, d || o) {
888
+ if (d && (e.pan.x = l.x + (c.x - l.x) * u, e.pan.y = l.y + (c.y - l.y) * u), o) {
889
+ const m = s + (n - s) * u;
890
+ e.setZoomLevel(m);
891
+ }
892
+ e.applyCurrentZoomPan();
893
+ }
894
+ h && i.bgOpacity < 1 && i.applyBgOpacity(b(a + (1 - a) * u, 0, 1));
895
+ },
896
+ onComplete: () => {
897
+ e._setResolution(n), e.applyCurrentZoomPan();
898
+ }
899
+ });
900
+ }
901
+ }
902
+ function Z(r) {
903
+ return !!/** @type {HTMLElement} */
904
+ r.target.closest(".pswp__container");
905
+ }
906
+ class ot {
907
+ /**
908
+ * @param {Gestures} gestures
909
+ */
910
+ constructor(t) {
911
+ this.gestures = t;
912
+ }
913
+ /**
914
+ * @param {Point} point
915
+ * @param {PointerEvent} originalEvent
916
+ */
917
+ click(t, i) {
918
+ const e = (
919
+ /** @type {HTMLElement} */
920
+ i.target.classList
921
+ ), s = e.contains("pswp__img"), n = e.contains("pswp__item") || e.contains("pswp__zoom-wrap");
922
+ s ? this._doClickOrTapAction("imageClick", t, i) : n && this._doClickOrTapAction("bgClick", t, i);
923
+ }
924
+ /**
925
+ * @param {Point} point
926
+ * @param {PointerEvent} originalEvent
927
+ */
928
+ tap(t, i) {
929
+ Z(i) && this._doClickOrTapAction("tap", t, i);
930
+ }
931
+ /**
932
+ * @param {Point} point
933
+ * @param {PointerEvent} originalEvent
934
+ */
935
+ doubleTap(t, i) {
936
+ Z(i) && this._doClickOrTapAction("doubleTap", t, i);
937
+ }
938
+ /**
939
+ * @private
940
+ * @param {Actions} actionName
941
+ * @param {Point} point
942
+ * @param {PointerEvent} originalEvent
943
+ */
944
+ _doClickOrTapAction(t, i, e) {
945
+ var s;
946
+ const {
947
+ pswp: n
948
+ } = this.gestures, {
949
+ currSlide: o
950
+ } = n, a = (
951
+ /** @type {AddPostfix<Actions, 'Action'>} */
952
+ t + "Action"
953
+ ), h = n.options[a];
954
+ if (!n.dispatch(a, {
955
+ point: i,
956
+ originalEvent: e
957
+ }).defaultPrevented) {
958
+ if (typeof h == "function") {
959
+ h.call(n, i, e);
960
+ return;
961
+ }
962
+ switch (h) {
963
+ case "close":
964
+ case "next":
965
+ n[h]();
966
+ break;
967
+ case "zoom":
968
+ o?.toggleZoom(i);
969
+ break;
970
+ case "zoom-or-close":
971
+ o != null && o.isZoomable() && o.zoomLevels.secondary !== o.zoomLevels.initial ? o.toggleZoom(i) : n.options.clickToCloseNonZoomable && n.close();
972
+ break;
973
+ case "toggle-controls":
974
+ (s = this.gestures.pswp.element) === null || s === void 0 || s.classList.toggle("pswp--ui-visible");
975
+ break;
976
+ }
977
+ }
978
+ }
979
+ }
980
+ const rt = 10, at = 300, ht = 25;
981
+ class lt {
982
+ /**
983
+ * @param {PhotoSwipe} pswp
984
+ */
985
+ constructor(t) {
986
+ this.pswp = t, this.dragAxis = null, this.p1 = {
987
+ x: 0,
988
+ y: 0
989
+ }, this.p2 = {
990
+ x: 0,
991
+ y: 0
992
+ }, this.prevP1 = {
993
+ x: 0,
994
+ y: 0
995
+ }, this.prevP2 = {
996
+ x: 0,
997
+ y: 0
998
+ }, this.startP1 = {
999
+ x: 0,
1000
+ y: 0
1001
+ }, this.startP2 = {
1002
+ x: 0,
1003
+ y: 0
1004
+ }, this.velocity = {
1005
+ x: 0,
1006
+ y: 0
1007
+ }, this._lastStartP1 = {
1008
+ x: 0,
1009
+ y: 0
1010
+ }, this._intervalP1 = {
1011
+ x: 0,
1012
+ y: 0
1013
+ }, this._numActivePoints = 0, this._ongoingPointers = [], this._touchEventEnabled = "ontouchstart" in window, this._pointerEventEnabled = !!window.PointerEvent, this.supportsTouch = this._touchEventEnabled || this._pointerEventEnabled && navigator.maxTouchPoints > 1, this._numActivePoints = 0, this._intervalTime = 0, this._velocityCalculated = !1, this.isMultitouch = !1, this.isDragging = !1, this.isZooming = !1, this.raf = null, this._tapTimer = null, this.supportsTouch || (t.options.allowPanToNext = !1), this.drag = new it(this), this.zoomLevels = new nt(this), this.tapHandler = new ot(this), t.on("bindEvents", () => {
1014
+ t.events.add(
1015
+ t.scrollWrap,
1016
+ "click",
1017
+ /** @type EventListener */
1018
+ this._onClick.bind(this)
1019
+ ), this._pointerEventEnabled ? this._bindEvents("pointer", "down", "up", "cancel") : this._touchEventEnabled ? (this._bindEvents("touch", "start", "end", "cancel"), t.scrollWrap && (t.scrollWrap.ontouchmove = () => {
1020
+ }, t.scrollWrap.ontouchend = () => {
1021
+ })) : this._bindEvents("mouse", "down", "up");
1022
+ });
1023
+ }
1024
+ /**
1025
+ * @private
1026
+ * @param {'mouse' | 'touch' | 'pointer'} pref
1027
+ * @param {'down' | 'start'} down
1028
+ * @param {'up' | 'end'} up
1029
+ * @param {'cancel'} [cancel]
1030
+ */
1031
+ _bindEvents(t, i, e, s) {
1032
+ const {
1033
+ pswp: n
1034
+ } = this, {
1035
+ events: o
1036
+ } = n, a = s ? t + s : "";
1037
+ o.add(
1038
+ n.scrollWrap,
1039
+ t + i,
1040
+ /** @type EventListener */
1041
+ this.onPointerDown.bind(this)
1042
+ ), o.add(
1043
+ window,
1044
+ t + "move",
1045
+ /** @type EventListener */
1046
+ this.onPointerMove.bind(this)
1047
+ ), o.add(
1048
+ window,
1049
+ t + e,
1050
+ /** @type EventListener */
1051
+ this.onPointerUp.bind(this)
1052
+ ), a && o.add(
1053
+ n.scrollWrap,
1054
+ a,
1055
+ /** @type EventListener */
1056
+ this.onPointerUp.bind(this)
1057
+ );
1058
+ }
1059
+ /**
1060
+ * @param {PointerEvent} e
1061
+ */
1062
+ onPointerDown(t) {
1063
+ const i = t.type === "mousedown" || t.pointerType === "mouse";
1064
+ if (i && t.button > 0)
1065
+ return;
1066
+ const {
1067
+ pswp: e
1068
+ } = this;
1069
+ if (!e.opener.isOpen) {
1070
+ t.preventDefault();
1071
+ return;
1072
+ }
1073
+ e.dispatch("pointerDown", {
1074
+ originalEvent: t
1075
+ }).defaultPrevented || (i && (e.mouseDetected(), this._preventPointerEventBehaviour(t, "down")), e.animations.stopAll(), this._updatePoints(t, "down"), this._numActivePoints === 1 && (this.dragAxis = null, p(this.startP1, this.p1)), this._numActivePoints > 1 ? (this._clearTapTimer(), this.isMultitouch = !0) : this.isMultitouch = !1);
1076
+ }
1077
+ /**
1078
+ * @param {PointerEvent} e
1079
+ */
1080
+ onPointerMove(t) {
1081
+ this._preventPointerEventBehaviour(t, "move"), this._numActivePoints && (this._updatePoints(t, "move"), !this.pswp.dispatch("pointerMove", {
1082
+ originalEvent: t
1083
+ }).defaultPrevented && (this._numActivePoints === 1 && !this.isDragging ? (this.dragAxis || this._calculateDragDirection(), this.dragAxis && !this.isDragging && (this.isZooming && (this.isZooming = !1, this.zoomLevels.end()), this.isDragging = !0, this._clearTapTimer(), this._updateStartPoints(), this._intervalTime = Date.now(), this._velocityCalculated = !1, p(this._intervalP1, this.p1), this.velocity.x = 0, this.velocity.y = 0, this.drag.start(), this._rafStopLoop(), this._rafRenderLoop())) : this._numActivePoints > 1 && !this.isZooming && (this._finishDrag(), this.isZooming = !0, this._updateStartPoints(), this.zoomLevels.start(), this._rafStopLoop(), this._rafRenderLoop())));
1084
+ }
1085
+ /**
1086
+ * @private
1087
+ */
1088
+ _finishDrag() {
1089
+ this.isDragging && (this.isDragging = !1, this._velocityCalculated || this._updateVelocity(!0), this.drag.end(), this.dragAxis = null);
1090
+ }
1091
+ /**
1092
+ * @param {PointerEvent} e
1093
+ */
1094
+ onPointerUp(t) {
1095
+ this._numActivePoints && (this._updatePoints(t, "up"), !this.pswp.dispatch("pointerUp", {
1096
+ originalEvent: t
1097
+ }).defaultPrevented && (this._numActivePoints === 0 && (this._rafStopLoop(), this.isDragging ? this._finishDrag() : !this.isZooming && !this.isMultitouch && this._finishTap(t)), this._numActivePoints < 2 && this.isZooming && (this.isZooming = !1, this.zoomLevels.end(), this._numActivePoints === 1 && (this.dragAxis = null, this._updateStartPoints()))));
1098
+ }
1099
+ /**
1100
+ * @private
1101
+ */
1102
+ _rafRenderLoop() {
1103
+ (this.isDragging || this.isZooming) && (this._updateVelocity(), this.isDragging ? x(this.p1, this.prevP1) || this.drag.change() : (!x(this.p1, this.prevP1) || !x(this.p2, this.prevP2)) && this.zoomLevels.change(), this._updatePrevPoints(), this.raf = requestAnimationFrame(this._rafRenderLoop.bind(this)));
1104
+ }
1105
+ /**
1106
+ * Update velocity at 50ms interval
1107
+ *
1108
+ * @private
1109
+ * @param {boolean} [force]
1110
+ */
1111
+ _updateVelocity(t) {
1112
+ const i = Date.now(), e = i - this._intervalTime;
1113
+ e < 50 && !t || (this.velocity.x = this._getVelocity("x", e), this.velocity.y = this._getVelocity("y", e), this._intervalTime = i, p(this._intervalP1, this.p1), this._velocityCalculated = !0);
1114
+ }
1115
+ /**
1116
+ * @private
1117
+ * @param {PointerEvent} e
1118
+ */
1119
+ _finishTap(t) {
1120
+ const {
1121
+ mainScroll: i
1122
+ } = this.pswp;
1123
+ if (i.isShifted()) {
1124
+ i.moveIndexBy(0, !0);
1125
+ return;
1126
+ }
1127
+ if (t.type.indexOf("cancel") > 0)
1128
+ return;
1129
+ if (t.type === "mouseup" || t.pointerType === "mouse") {
1130
+ this.tapHandler.click(this.startP1, t);
1131
+ return;
1132
+ }
1133
+ const e = this.pswp.options.doubleTapAction ? at : 0;
1134
+ this._tapTimer ? (this._clearTapTimer(), A(this._lastStartP1, this.startP1) < ht && this.tapHandler.doubleTap(this.startP1, t)) : (p(this._lastStartP1, this.startP1), this._tapTimer = setTimeout(() => {
1135
+ this.tapHandler.tap(this.startP1, t), this._clearTapTimer();
1136
+ }, e));
1137
+ }
1138
+ /**
1139
+ * @private
1140
+ */
1141
+ _clearTapTimer() {
1142
+ this._tapTimer && (clearTimeout(this._tapTimer), this._tapTimer = null);
1143
+ }
1144
+ /**
1145
+ * Get velocity for axis
1146
+ *
1147
+ * @private
1148
+ * @param {'x' | 'y'} axis
1149
+ * @param {number} duration
1150
+ * @returns {number}
1151
+ */
1152
+ _getVelocity(t, i) {
1153
+ const e = this.p1[t] - this._intervalP1[t];
1154
+ return Math.abs(e) > 1 && i > 5 ? e / i : 0;
1155
+ }
1156
+ /**
1157
+ * @private
1158
+ */
1159
+ _rafStopLoop() {
1160
+ this.raf && (cancelAnimationFrame(this.raf), this.raf = null);
1161
+ }
1162
+ /**
1163
+ * @private
1164
+ * @param {PointerEvent} e
1165
+ * @param {'up' | 'down' | 'move'} pointerType Normalized pointer type
1166
+ */
1167
+ _preventPointerEventBehaviour(t, i) {
1168
+ this.pswp.applyFilters("preventPointerEvent", !0, t, i) && t.preventDefault();
1169
+ }
1170
+ /**
1171
+ * Parses and normalizes points from the touch, mouse or pointer event.
1172
+ * Updates p1 and p2.
1173
+ *
1174
+ * @private
1175
+ * @param {PointerEvent | TouchEvent} e
1176
+ * @param {'up' | 'down' | 'move'} pointerType Normalized pointer type
1177
+ */
1178
+ _updatePoints(t, i) {
1179
+ if (this._pointerEventEnabled) {
1180
+ const e = (
1181
+ /** @type {PointerEvent} */
1182
+ t
1183
+ ), s = this._ongoingPointers.findIndex((n) => n.id === e.pointerId);
1184
+ i === "up" && s > -1 ? this._ongoingPointers.splice(s, 1) : i === "down" && s === -1 ? this._ongoingPointers.push(this._convertEventPosToPoint(e, {
1185
+ x: 0,
1186
+ y: 0
1187
+ })) : s > -1 && this._convertEventPosToPoint(e, this._ongoingPointers[s]), this._numActivePoints = this._ongoingPointers.length, this._numActivePoints > 0 && p(this.p1, this._ongoingPointers[0]), this._numActivePoints > 1 && p(this.p2, this._ongoingPointers[1]);
1188
+ } else {
1189
+ const e = (
1190
+ /** @type {TouchEvent} */
1191
+ t
1192
+ );
1193
+ this._numActivePoints = 0, e.type.indexOf("touch") > -1 ? e.touches && e.touches.length > 0 && (this._convertEventPosToPoint(e.touches[0], this.p1), this._numActivePoints++, e.touches.length > 1 && (this._convertEventPosToPoint(e.touches[1], this.p2), this._numActivePoints++)) : (this._convertEventPosToPoint(
1194
+ /** @type {PointerEvent} */
1195
+ t,
1196
+ this.p1
1197
+ ), i === "up" ? this._numActivePoints = 0 : this._numActivePoints++);
1198
+ }
1199
+ }
1200
+ /** update points that were used during previous rAF tick
1201
+ * @private
1202
+ */
1203
+ _updatePrevPoints() {
1204
+ p(this.prevP1, this.p1), p(this.prevP2, this.p2);
1205
+ }
1206
+ /** update points at the start of gesture
1207
+ * @private
1208
+ */
1209
+ _updateStartPoints() {
1210
+ p(this.startP1, this.p1), p(this.startP2, this.p2), this._updatePrevPoints();
1211
+ }
1212
+ /** @private */
1213
+ _calculateDragDirection() {
1214
+ if (this.pswp.mainScroll.isShifted())
1215
+ this.dragAxis = "x";
1216
+ else {
1217
+ const t = Math.abs(this.p1.x - this.startP1.x) - Math.abs(this.p1.y - this.startP1.y);
1218
+ if (t !== 0) {
1219
+ const i = t > 0 ? "x" : "y";
1220
+ Math.abs(this.p1[i] - this.startP1[i]) >= rt && (this.dragAxis = i);
1221
+ }
1222
+ }
1223
+ }
1224
+ /**
1225
+ * Converts touch, pointer or mouse event
1226
+ * to PhotoSwipe point.
1227
+ *
1228
+ * @private
1229
+ * @param {Touch | PointerEvent} e
1230
+ * @param {Point} p
1231
+ * @returns {Point}
1232
+ */
1233
+ _convertEventPosToPoint(t, i) {
1234
+ return i.x = t.pageX - this.pswp.offset.x, i.y = t.pageY - this.pswp.offset.y, "pointerId" in t ? i.id = t.pointerId : t.identifier !== void 0 && (i.id = t.identifier), i;
1235
+ }
1236
+ /**
1237
+ * @private
1238
+ * @param {PointerEvent} e
1239
+ */
1240
+ _onClick(t) {
1241
+ this.pswp.mainScroll.isShifted() && (t.preventDefault(), t.stopPropagation());
1242
+ }
1243
+ }
1244
+ const ct = 0.35;
1245
+ class dt {
1246
+ /**
1247
+ * @param {PhotoSwipe} pswp
1248
+ */
1249
+ constructor(t) {
1250
+ this.pswp = t, this.x = 0, this.slideWidth = 0, this._currPositionIndex = 0, this._prevPositionIndex = 0, this._containerShiftIndex = -1, this.itemHolders = [];
1251
+ }
1252
+ /**
1253
+ * Position the scroller and slide containers
1254
+ * according to viewport size.
1255
+ *
1256
+ * @param {boolean} [resizeSlides] Whether slides content should resized
1257
+ */
1258
+ resize(t) {
1259
+ const {
1260
+ pswp: i
1261
+ } = this, e = Math.round(i.viewportSize.x + i.viewportSize.x * i.options.spacing), s = e !== this.slideWidth;
1262
+ s && (this.slideWidth = e, this.moveTo(this.getCurrSlideX())), this.itemHolders.forEach((n, o) => {
1263
+ s && y(n.el, (o + this._containerShiftIndex) * this.slideWidth), t && n.slide && n.slide.resize();
1264
+ });
1265
+ }
1266
+ /**
1267
+ * Reset X position of the main scroller to zero
1268
+ */
1269
+ resetPosition() {
1270
+ this._currPositionIndex = 0, this._prevPositionIndex = 0, this.slideWidth = 0, this._containerShiftIndex = -1;
1271
+ }
1272
+ /**
1273
+ * Create and append array of three items
1274
+ * that hold data about slides in DOM
1275
+ */
1276
+ appendHolders() {
1277
+ this.itemHolders = [];
1278
+ for (let t = 0; t < 3; t++) {
1279
+ const i = f("pswp__item", "div", this.pswp.container);
1280
+ i.setAttribute("role", "group"), i.setAttribute("aria-roledescription", "slide"), i.setAttribute("aria-hidden", "true"), i.style.display = t === 1 ? "block" : "none", this.itemHolders.push({
1281
+ el: i
1282
+ //index: -1
1283
+ });
1284
+ }
1285
+ }
1286
+ /**
1287
+ * Whether the main scroll can be horizontally swiped to the next or previous slide.
1288
+ * @returns {boolean}
1289
+ */
1290
+ canBeSwiped() {
1291
+ return this.pswp.getNumItems() > 1;
1292
+ }
1293
+ /**
1294
+ * Move main scroll by X amount of slides.
1295
+ * For example:
1296
+ * `-1` will move to the previous slide,
1297
+ * `0` will reset the scroll position of the current slide,
1298
+ * `3` will move three slides forward
1299
+ *
1300
+ * If loop option is enabled - index will be automatically looped too,
1301
+ * (for example `-1` will move to the last slide of the gallery).
1302
+ *
1303
+ * @param {number} diff
1304
+ * @param {boolean} [animate]
1305
+ * @param {number} [velocityX]
1306
+ * @returns {boolean} whether index was changed or not
1307
+ */
1308
+ moveIndexBy(t, i, e) {
1309
+ const {
1310
+ pswp: s
1311
+ } = this;
1312
+ let n = s.potentialIndex + t;
1313
+ const o = s.getNumItems();
1314
+ if (s.canLoop()) {
1315
+ n = s.getLoopedIndex(n);
1316
+ const h = (t + o) % o;
1317
+ h <= o / 2 ? t = h : t = h - o;
1318
+ } else
1319
+ n < 0 ? n = 0 : n >= o && (n = o - 1), t = n - s.potentialIndex;
1320
+ s.potentialIndex = n, this._currPositionIndex -= t, s.animations.stopMainScroll();
1321
+ const a = this.getCurrSlideX();
1322
+ if (!i)
1323
+ this.moveTo(a), this.updateCurrItem();
1324
+ else {
1325
+ s.animations.startSpring({
1326
+ isMainScroll: !0,
1327
+ start: this.x,
1328
+ end: a,
1329
+ velocity: e || 0,
1330
+ naturalFrequency: 30,
1331
+ dampingRatio: 1,
1332
+ //0.7,
1333
+ onUpdate: (l) => {
1334
+ this.moveTo(l);
1335
+ },
1336
+ onComplete: () => {
1337
+ this.updateCurrItem(), s.appendHeavy();
1338
+ }
1339
+ });
1340
+ let h = s.potentialIndex - s.currIndex;
1341
+ if (s.canLoop()) {
1342
+ const l = (h + o) % o;
1343
+ l <= o / 2 ? h = l : h = l - o;
1344
+ }
1345
+ Math.abs(h) > 1 && this.updateCurrItem();
1346
+ }
1347
+ return !!t;
1348
+ }
1349
+ /**
1350
+ * X position of the main scroll for the current slide
1351
+ * (ignores position during dragging)
1352
+ * @returns {number}
1353
+ */
1354
+ getCurrSlideX() {
1355
+ return this.slideWidth * this._currPositionIndex;
1356
+ }
1357
+ /**
1358
+ * Whether scroll position is shifted.
1359
+ * For example, it will return true if the scroll is being dragged or animated.
1360
+ * @returns {boolean}
1361
+ */
1362
+ isShifted() {
1363
+ return this.x !== this.getCurrSlideX();
1364
+ }
1365
+ /**
1366
+ * Update slides X positions and set their content
1367
+ */
1368
+ updateCurrItem() {
1369
+ var t;
1370
+ const {
1371
+ pswp: i
1372
+ } = this, e = this._prevPositionIndex - this._currPositionIndex;
1373
+ if (!e)
1374
+ return;
1375
+ this._prevPositionIndex = this._currPositionIndex, i.currIndex = i.potentialIndex;
1376
+ let s = Math.abs(e), n;
1377
+ s >= 3 && (this._containerShiftIndex += e + (e > 0 ? -3 : 3), s = 3, this.itemHolders.forEach((o) => {
1378
+ var a;
1379
+ (a = o.slide) === null || a === void 0 || a.destroy(), o.slide = void 0;
1380
+ }));
1381
+ for (let o = 0; o < s; o++)
1382
+ e > 0 ? (n = this.itemHolders.shift(), n && (this.itemHolders[2] = n, this._containerShiftIndex++, y(n.el, (this._containerShiftIndex + 2) * this.slideWidth), i.setContent(n, i.currIndex - s + o + 2))) : (n = this.itemHolders.pop(), n && (this.itemHolders.unshift(n), this._containerShiftIndex--, y(n.el, this._containerShiftIndex * this.slideWidth), i.setContent(n, i.currIndex + s - o - 2)));
1383
+ Math.abs(this._containerShiftIndex) > 50 && !this.isShifted() && (this.resetPosition(), this.resize()), i.animations.stopAllPan(), this.itemHolders.forEach((o, a) => {
1384
+ o.slide && o.slide.setIsActive(a === 1);
1385
+ }), i.currSlide = (t = this.itemHolders[1]) === null || t === void 0 ? void 0 : t.slide, i.contentLoader.updateLazy(e), i.currSlide && i.currSlide.applyCurrentZoomPan(), i.dispatch("change");
1386
+ }
1387
+ /**
1388
+ * Move the X position of the main scroll container
1389
+ *
1390
+ * @param {number} x
1391
+ * @param {boolean} [dragging]
1392
+ */
1393
+ moveTo(t, i) {
1394
+ if (!this.pswp.canLoop() && i) {
1395
+ let e = (this.slideWidth * this._currPositionIndex - t) / this.slideWidth;
1396
+ e += this.pswp.currIndex;
1397
+ const s = Math.round(t - this.x);
1398
+ (e < 0 && s > 0 || e >= this.pswp.getNumItems() - 1 && s < 0) && (t = this.x + s * ct);
1399
+ }
1400
+ this.x = t, this.pswp.container && y(this.pswp.container, t), this.pswp.dispatch("moveMainScroll", {
1401
+ x: t,
1402
+ dragging: i ?? !1
1403
+ });
1404
+ }
1405
+ }
1406
+ const pt = {
1407
+ Escape: 27,
1408
+ z: 90,
1409
+ ArrowLeft: 37,
1410
+ ArrowUp: 38,
1411
+ ArrowRight: 39,
1412
+ ArrowDown: 40,
1413
+ Tab: 9
1414
+ }, g = (r, t) => t ? r : pt[r];
1415
+ class ut {
1416
+ /**
1417
+ * @param {PhotoSwipe} pswp
1418
+ */
1419
+ constructor(t) {
1420
+ this.pswp = t, this._wasFocused = !1, t.on("bindEvents", () => {
1421
+ t.options.trapFocus && (t.options.initialPointerPos || this._focusRoot(), t.events.add(
1422
+ document,
1423
+ "focusin",
1424
+ /** @type EventListener */
1425
+ this._onFocusIn.bind(this)
1426
+ )), t.events.add(
1427
+ document,
1428
+ "keydown",
1429
+ /** @type EventListener */
1430
+ this._onKeyDown.bind(this)
1431
+ );
1432
+ });
1433
+ const i = (
1434
+ /** @type {HTMLElement} */
1435
+ document.activeElement
1436
+ );
1437
+ t.on("destroy", () => {
1438
+ t.options.returnFocus && i && this._wasFocused && i.focus();
1439
+ });
1440
+ }
1441
+ /** @private */
1442
+ _focusRoot() {
1443
+ !this._wasFocused && this.pswp.element && (this.pswp.element.focus(), this._wasFocused = !0);
1444
+ }
1445
+ /**
1446
+ * @private
1447
+ * @param {KeyboardEvent} e
1448
+ */
1449
+ _onKeyDown(t) {
1450
+ const {
1451
+ pswp: i
1452
+ } = this;
1453
+ if (i.dispatch("keydown", {
1454
+ originalEvent: t
1455
+ }).defaultPrevented || G(t))
1456
+ return;
1457
+ let e, s, n = !1;
1458
+ const o = "key" in t;
1459
+ switch (o ? t.key : t.keyCode) {
1460
+ case g("Escape", o):
1461
+ i.options.escKey && (e = "close");
1462
+ break;
1463
+ case g("z", o):
1464
+ e = "toggleZoom";
1465
+ break;
1466
+ case g("ArrowLeft", o):
1467
+ s = "x";
1468
+ break;
1469
+ case g("ArrowUp", o):
1470
+ s = "y";
1471
+ break;
1472
+ case g("ArrowRight", o):
1473
+ s = "x", n = !0;
1474
+ break;
1475
+ case g("ArrowDown", o):
1476
+ n = !0, s = "y";
1477
+ break;
1478
+ case g("Tab", o):
1479
+ this._focusRoot();
1480
+ break;
1481
+ }
1482
+ if (s) {
1483
+ t.preventDefault();
1484
+ const {
1485
+ currSlide: a
1486
+ } = i;
1487
+ i.options.arrowKeys && s === "x" && i.getNumItems() > 1 ? e = n ? "next" : "prev" : a && a.currZoomLevel > a.zoomLevels.fit && (a.pan[s] += n ? -80 : 80, a.panTo(a.pan.x, a.pan.y));
1488
+ }
1489
+ e && (t.preventDefault(), i[e]());
1490
+ }
1491
+ /**
1492
+ * Trap focus inside photoswipe
1493
+ *
1494
+ * @private
1495
+ * @param {FocusEvent} e
1496
+ */
1497
+ _onFocusIn(t) {
1498
+ const {
1499
+ template: i
1500
+ } = this.pswp;
1501
+ i && document !== t.target && i !== t.target && !i.contains(
1502
+ /** @type {Node} */
1503
+ t.target
1504
+ ) && i.focus();
1505
+ }
1506
+ }
1507
+ const mt = "cubic-bezier(.4,0,.22,1)";
1508
+ class ft {
1509
+ /**
1510
+ * onComplete can be unpredictable, be careful about current state
1511
+ *
1512
+ * @param {CssAnimationProps} props
1513
+ */
1514
+ constructor(t) {
1515
+ var i;
1516
+ this.props = t;
1517
+ const {
1518
+ target: e,
1519
+ onComplete: s,
1520
+ transform: n,
1521
+ onFinish: o = () => {
1522
+ },
1523
+ duration: a = 333,
1524
+ easing: h = mt
1525
+ } = t;
1526
+ this.onFinish = o;
1527
+ const l = n ? "transform" : "opacity", c = (i = t[l]) !== null && i !== void 0 ? i : "";
1528
+ this._target = e, this._onComplete = s, this._finished = !1, this._onTransitionEnd = this._onTransitionEnd.bind(this), this._helperTimeout = setTimeout(() => {
1529
+ R(e, l, a, h), this._helperTimeout = setTimeout(() => {
1530
+ e.addEventListener("transitionend", this._onTransitionEnd, !1), e.addEventListener("transitioncancel", this._onTransitionEnd, !1), this._helperTimeout = setTimeout(() => {
1531
+ this._finalizeAnimation();
1532
+ }, a + 500), e.style[l] = c;
1533
+ }, 30);
1534
+ }, 0);
1535
+ }
1536
+ /**
1537
+ * @private
1538
+ * @param {TransitionEvent} e
1539
+ */
1540
+ _onTransitionEnd(t) {
1541
+ t.target === this._target && this._finalizeAnimation();
1542
+ }
1543
+ /**
1544
+ * @private
1545
+ */
1546
+ _finalizeAnimation() {
1547
+ this._finished || (this._finished = !0, this.onFinish(), this._onComplete && this._onComplete());
1548
+ }
1549
+ // Destroy is called automatically onFinish
1550
+ destroy() {
1551
+ this._helperTimeout && clearTimeout(this._helperTimeout), U(this._target), this._target.removeEventListener("transitionend", this._onTransitionEnd, !1), this._target.removeEventListener("transitioncancel", this._onTransitionEnd, !1), this._finished || this._finalizeAnimation();
1552
+ }
1553
+ }
1554
+ const _t = 12, vt = 0.75;
1555
+ class gt {
1556
+ /**
1557
+ * @param {number} initialVelocity Initial velocity, px per ms.
1558
+ *
1559
+ * @param {number} [dampingRatio]
1560
+ * Determines how bouncy animation will be.
1561
+ * From 0 to 1, 0 - always overshoot, 1 - do not overshoot.
1562
+ * "overshoot" refers to part of animation that
1563
+ * goes beyond the final value.
1564
+ *
1565
+ * @param {number} [naturalFrequency]
1566
+ * Determines how fast animation will slow down.
1567
+ * The higher value - the stiffer the transition will be,
1568
+ * and the faster it will slow down.
1569
+ * Recommended value from 10 to 50
1570
+ */
1571
+ constructor(t, i, e) {
1572
+ this.velocity = t * 1e3, this._dampingRatio = i || vt, this._naturalFrequency = e || _t, this._dampedFrequency = this._naturalFrequency, this._dampingRatio < 1 && (this._dampedFrequency *= Math.sqrt(1 - this._dampingRatio * this._dampingRatio));
1573
+ }
1574
+ /**
1575
+ * @param {number} deltaPosition Difference between current and end position of the animation
1576
+ * @param {number} deltaTime Frame duration in milliseconds
1577
+ *
1578
+ * @returns {number} Displacement, relative to the end position.
1579
+ */
1580
+ easeFrame(t, i) {
1581
+ let e = 0, s;
1582
+ i /= 1e3;
1583
+ const n = Math.E ** (-this._dampingRatio * this._naturalFrequency * i);
1584
+ if (this._dampingRatio === 1)
1585
+ s = this.velocity + this._naturalFrequency * t, e = (t + s * i) * n, this.velocity = e * -this._naturalFrequency + s * n;
1586
+ else if (this._dampingRatio < 1) {
1587
+ s = 1 / this._dampedFrequency * (this._dampingRatio * this._naturalFrequency * t + this.velocity);
1588
+ const o = Math.cos(this._dampedFrequency * i), a = Math.sin(this._dampedFrequency * i);
1589
+ e = n * (t * o + s * a), this.velocity = e * -this._naturalFrequency * this._dampingRatio + n * (-this._dampedFrequency * t * a + this._dampedFrequency * s * o);
1590
+ }
1591
+ return e;
1592
+ }
1593
+ }
1594
+ class yt {
1595
+ /**
1596
+ * @param {SpringAnimationProps} props
1597
+ */
1598
+ constructor(t) {
1599
+ this.props = t, this._raf = 0;
1600
+ const {
1601
+ start: i,
1602
+ end: e,
1603
+ velocity: s,
1604
+ onUpdate: n,
1605
+ onComplete: o,
1606
+ onFinish: a = () => {
1607
+ },
1608
+ dampingRatio: h,
1609
+ naturalFrequency: l
1610
+ } = t;
1611
+ this.onFinish = a;
1612
+ const c = new gt(s, h, l);
1613
+ let d = Date.now(), u = i - e;
1614
+ const m = () => {
1615
+ this._raf && (u = c.easeFrame(u, Date.now() - d), Math.abs(u) < 1 && Math.abs(c.velocity) < 50 ? (n(e), o && o(), this.onFinish()) : (d = Date.now(), n(u + e), this._raf = requestAnimationFrame(m)));
1616
+ };
1617
+ this._raf = requestAnimationFrame(m);
1618
+ }
1619
+ // Destroy is called automatically onFinish
1620
+ destroy() {
1621
+ this._raf >= 0 && cancelAnimationFrame(this._raf), this._raf = 0;
1622
+ }
1623
+ }
1624
+ class wt {
1625
+ constructor() {
1626
+ this.activeAnimations = [];
1627
+ }
1628
+ /**
1629
+ * @param {SpringAnimationProps} props
1630
+ */
1631
+ startSpring(t) {
1632
+ this._start(t, !0);
1633
+ }
1634
+ /**
1635
+ * @param {CssAnimationProps} props
1636
+ */
1637
+ startTransition(t) {
1638
+ this._start(t);
1639
+ }
1640
+ /**
1641
+ * @private
1642
+ * @param {AnimationProps} props
1643
+ * @param {boolean} [isSpring]
1644
+ * @returns {Animation}
1645
+ */
1646
+ _start(t, i) {
1647
+ const e = i ? new yt(
1648
+ /** @type SpringAnimationProps */
1649
+ t
1650
+ ) : new ft(
1651
+ /** @type CssAnimationProps */
1652
+ t
1653
+ );
1654
+ return this.activeAnimations.push(e), e.onFinish = () => this.stop(e), e;
1655
+ }
1656
+ /**
1657
+ * @param {Animation} animation
1658
+ */
1659
+ stop(t) {
1660
+ t.destroy();
1661
+ const i = this.activeAnimations.indexOf(t);
1662
+ i > -1 && this.activeAnimations.splice(i, 1);
1663
+ }
1664
+ stopAll() {
1665
+ this.activeAnimations.forEach((t) => {
1666
+ t.destroy();
1667
+ }), this.activeAnimations = [];
1668
+ }
1669
+ /**
1670
+ * Stop all pan or zoom transitions
1671
+ */
1672
+ stopAllPan() {
1673
+ this.activeAnimations = this.activeAnimations.filter((t) => t.props.isPan ? (t.destroy(), !1) : !0);
1674
+ }
1675
+ stopMainScroll() {
1676
+ this.activeAnimations = this.activeAnimations.filter((t) => t.props.isMainScroll ? (t.destroy(), !1) : !0);
1677
+ }
1678
+ /**
1679
+ * Returns true if main scroll transition is running
1680
+ */
1681
+ // isMainScrollRunning() {
1682
+ // return this.activeAnimations.some((animation) => {
1683
+ // return animation.props.isMainScroll;
1684
+ // });
1685
+ // }
1686
+ /**
1687
+ * Returns true if any pan or zoom transition is running
1688
+ */
1689
+ isPanRunning() {
1690
+ return this.activeAnimations.some((t) => t.props.isPan);
1691
+ }
1692
+ }
1693
+ class Pt {
1694
+ /**
1695
+ * @param {PhotoSwipe} pswp
1696
+ */
1697
+ constructor(t) {
1698
+ this.pswp = t, t.events.add(
1699
+ t.element,
1700
+ "wheel",
1701
+ /** @type EventListener */
1702
+ this._onWheel.bind(this)
1703
+ );
1704
+ }
1705
+ /**
1706
+ * @private
1707
+ * @param {WheelEvent} e
1708
+ */
1709
+ _onWheel(t) {
1710
+ t.preventDefault();
1711
+ const {
1712
+ currSlide: i
1713
+ } = this.pswp;
1714
+ let {
1715
+ deltaX: e,
1716
+ deltaY: s
1717
+ } = t;
1718
+ if (i && !this.pswp.dispatch("wheel", {
1719
+ originalEvent: t
1720
+ }).defaultPrevented)
1721
+ if (t.ctrlKey || this.pswp.options.wheelToZoom) {
1722
+ if (i.isZoomable()) {
1723
+ let n = -s;
1724
+ t.deltaMode === 1 ? n *= 0.05 : n *= t.deltaMode ? 1 : 2e-3, n = 2 ** n;
1725
+ const o = i.currZoomLevel * n;
1726
+ i.zoomTo(o, {
1727
+ x: t.clientX,
1728
+ y: t.clientY
1729
+ });
1730
+ }
1731
+ } else
1732
+ i.isPannable() && (t.deltaMode === 1 && (e *= 18, s *= 18), i.panTo(i.pan.x - e, i.pan.y - s));
1733
+ }
1734
+ }
1735
+ function St(r) {
1736
+ if (typeof r == "string")
1737
+ return r;
1738
+ if (!r || !r.isCustomSVG)
1739
+ return "";
1740
+ const t = r;
1741
+ let i = '<svg aria-hidden="true" class="pswp__icn" viewBox="0 0 %d %d" width="%d" height="%d">';
1742
+ return i = i.split("%d").join(
1743
+ /** @type {string} */
1744
+ t.size || 32
1745
+ ), t.outlineID && (i += '<use class="pswp__icn-shadow" xlink:href="#' + t.outlineID + '"/>'), i += t.inner, i += "</svg>", i;
1746
+ }
1747
+ class xt {
1748
+ /**
1749
+ * @param {PhotoSwipe} pswp
1750
+ * @param {UIElementData} data
1751
+ */
1752
+ constructor(t, i) {
1753
+ var e;
1754
+ const s = i.name || i.className;
1755
+ let n = i.html;
1756
+ if (t.options[s] === !1)
1757
+ return;
1758
+ typeof t.options[s + "SVG"] == "string" && (n = t.options[s + "SVG"]), t.dispatch("uiElementCreate", {
1759
+ data: i
1760
+ });
1761
+ let o = "";
1762
+ i.isButton ? (o += "pswp__button ", o += i.className || `pswp__button--${i.name}`) : o += i.className || `pswp__${i.name}`;
1763
+ let a = i.isButton ? i.tagName || "button" : i.tagName || "div";
1764
+ a = /** @type {keyof HTMLElementTagNameMap} */
1765
+ a.toLowerCase();
1766
+ const h = f(o, a);
1767
+ if (i.isButton) {
1768
+ a === "button" && (h.type = "button");
1769
+ let {
1770
+ title: d
1771
+ } = i;
1772
+ const {
1773
+ ariaLabel: u
1774
+ } = i;
1775
+ typeof t.options[s + "Title"] == "string" && (d = t.options[s + "Title"]), d && (h.title = d);
1776
+ const m = u || d;
1777
+ m && h.setAttribute("aria-label", m);
1778
+ }
1779
+ h.innerHTML = St(n), i.onInit && i.onInit(h, t), i.onClick && (h.onclick = (d) => {
1780
+ typeof i.onClick == "string" ? t[i.onClick]() : typeof i.onClick == "function" && i.onClick(d, h, t);
1781
+ });
1782
+ const l = i.appendTo || "bar";
1783
+ let c = t.element;
1784
+ l === "bar" ? (t.topBar || (t.topBar = f("pswp__top-bar pswp__hide-on-close", "div", t.scrollWrap)), c = t.topBar) : (h.classList.add("pswp__hide-on-close"), l === "wrapper" && (c = t.scrollWrap)), (e = c) === null || e === void 0 || e.appendChild(t.applyFilters("uiElement", h, i));
1785
+ }
1786
+ }
1787
+ function H(r, t, i) {
1788
+ r.classList.add("pswp__button--arrow"), r.setAttribute("aria-controls", "pswp__items"), t.on("change", () => {
1789
+ t.options.loop || (i ? r.disabled = !(t.currIndex < t.getNumItems() - 1) : r.disabled = !(t.currIndex > 0));
1790
+ });
1791
+ }
1792
+ const It = {
1793
+ name: "arrowPrev",
1794
+ className: "pswp__button--arrow--prev",
1795
+ title: "Previous",
1796
+ order: 10,
1797
+ isButton: !0,
1798
+ appendTo: "wrapper",
1799
+ html: {
1800
+ isCustomSVG: !0,
1801
+ size: 60,
1802
+ inner: '<path d="M29 43l-3 3-16-16 16-16 3 3-13 13 13 13z" id="pswp__icn-arrow"/>',
1803
+ outlineID: "pswp__icn-arrow"
1804
+ },
1805
+ onClick: "prev",
1806
+ onInit: H
1807
+ }, bt = {
1808
+ name: "arrowNext",
1809
+ className: "pswp__button--arrow--next",
1810
+ title: "Next",
1811
+ order: 11,
1812
+ isButton: !0,
1813
+ appendTo: "wrapper",
1814
+ html: {
1815
+ isCustomSVG: !0,
1816
+ size: 60,
1817
+ inner: '<use xlink:href="#pswp__icn-arrow"/>',
1818
+ outlineID: "pswp__icn-arrow"
1819
+ },
1820
+ onClick: "next",
1821
+ onInit: (r, t) => {
1822
+ H(r, t, !0);
1823
+ }
1824
+ }, At = {
1825
+ name: "close",
1826
+ title: "Close",
1827
+ order: 20,
1828
+ isButton: !0,
1829
+ html: {
1830
+ isCustomSVG: !0,
1831
+ inner: '<path d="M24 10l-2-2-6 6-6-6-2 2 6 6-6 6 2 2 6-6 6 6 2-2-6-6z" id="pswp__icn-close"/>',
1832
+ outlineID: "pswp__icn-close"
1833
+ },
1834
+ onClick: "close"
1835
+ }, Lt = {
1836
+ name: "zoom",
1837
+ title: "Zoom",
1838
+ order: 10,
1839
+ isButton: !0,
1840
+ html: {
1841
+ isCustomSVG: !0,
1842
+ // eslint-disable-next-line max-len
1843
+ inner: '<path d="M17.426 19.926a6 6 0 1 1 1.5-1.5L23 22.5 21.5 24l-4.074-4.074z" id="pswp__icn-zoom"/><path fill="currentColor" class="pswp__zoom-icn-bar-h" d="M11 16v-2h6v2z"/><path fill="currentColor" class="pswp__zoom-icn-bar-v" d="M13 12h2v6h-2z"/>',
1844
+ outlineID: "pswp__icn-zoom"
1845
+ },
1846
+ onClick: "toggleZoom"
1847
+ }, Ct = {
1848
+ name: "preloader",
1849
+ appendTo: "bar",
1850
+ order: 7,
1851
+ html: {
1852
+ isCustomSVG: !0,
1853
+ // eslint-disable-next-line max-len
1854
+ inner: '<path fill-rule="evenodd" clip-rule="evenodd" d="M21.2 16a5.2 5.2 0 1 1-5.2-5.2V8a8 8 0 1 0 8 8h-2.8Z" id="pswp__icn-loading"/>',
1855
+ outlineID: "pswp__icn-loading"
1856
+ },
1857
+ onInit: (r, t) => {
1858
+ let i, e = null;
1859
+ const s = (a, h) => {
1860
+ r.classList.toggle("pswp__preloader--" + a, h);
1861
+ }, n = (a) => {
1862
+ i !== a && (i = a, s("active", a));
1863
+ }, o = () => {
1864
+ var a;
1865
+ if (!((a = t.currSlide) !== null && a !== void 0 && a.content.isLoading())) {
1866
+ n(!1), e && (clearTimeout(e), e = null);
1867
+ return;
1868
+ }
1869
+ e || (e = setTimeout(() => {
1870
+ var h;
1871
+ n(!!(!((h = t.currSlide) === null || h === void 0) && h.content.isLoading())), e = null;
1872
+ }, t.options.preloaderDelay));
1873
+ };
1874
+ t.on("change", o), t.on("loadComplete", (a) => {
1875
+ t.currSlide === a.slide && o();
1876
+ }), t.ui && (t.ui.updatePreloaderVisibility = o);
1877
+ }
1878
+ }, Tt = {
1879
+ name: "counter",
1880
+ order: 5,
1881
+ onInit: (r, t) => {
1882
+ t.on("change", () => {
1883
+ r.innerText = t.currIndex + 1 + t.options.indexIndicatorSep + t.getNumItems();
1884
+ });
1885
+ }
1886
+ };
1887
+ function D(r, t) {
1888
+ r.classList.toggle("pswp--zoomed-in", t);
1889
+ }
1890
+ class zt {
1891
+ /**
1892
+ * @param {PhotoSwipe} pswp
1893
+ */
1894
+ constructor(t) {
1895
+ this.pswp = t, this.isRegistered = !1, this.uiElementsData = [], this.items = [], this.updatePreloaderVisibility = () => {
1896
+ }, this._lastUpdatedZoomLevel = void 0;
1897
+ }
1898
+ init() {
1899
+ const {
1900
+ pswp: t
1901
+ } = this;
1902
+ this.isRegistered = !1, this.uiElementsData = [At, It, bt, Lt, Ct, Tt], t.dispatch("uiRegister"), this.uiElementsData.sort((i, e) => (i.order || 0) - (e.order || 0)), this.items = [], this.isRegistered = !0, this.uiElementsData.forEach((i) => {
1903
+ this.registerElement(i);
1904
+ }), t.on("change", () => {
1905
+ var i;
1906
+ (i = t.element) === null || i === void 0 || i.classList.toggle("pswp--one-slide", t.getNumItems() === 1);
1907
+ }), t.on("zoomPanUpdate", () => this._onZoomPanUpdate());
1908
+ }
1909
+ /**
1910
+ * @param {UIElementData} elementData
1911
+ */
1912
+ registerElement(t) {
1913
+ this.isRegistered ? this.items.push(new xt(this.pswp, t)) : this.uiElementsData.push(t);
1914
+ }
1915
+ /**
1916
+ * Fired each time zoom or pan position is changed.
1917
+ * Update classes that control visibility of zoom button and cursor icon.
1918
+ *
1919
+ * @private
1920
+ */
1921
+ _onZoomPanUpdate() {
1922
+ const {
1923
+ template: t,
1924
+ currSlide: i,
1925
+ options: e
1926
+ } = this.pswp;
1927
+ if (this.pswp.opener.isClosing || !t || !i)
1928
+ return;
1929
+ let {
1930
+ currZoomLevel: s
1931
+ } = i;
1932
+ if (this.pswp.opener.isOpen || (s = i.zoomLevels.initial), s === this._lastUpdatedZoomLevel)
1933
+ return;
1934
+ this._lastUpdatedZoomLevel = s;
1935
+ const n = i.zoomLevels.initial - i.zoomLevels.secondary;
1936
+ if (Math.abs(n) < 0.01 || !i.isZoomable()) {
1937
+ D(t, !1), t.classList.remove("pswp--zoom-allowed");
1938
+ return;
1939
+ }
1940
+ t.classList.add("pswp--zoom-allowed");
1941
+ const o = s === i.zoomLevels.initial ? i.zoomLevels.secondary : i.zoomLevels.initial;
1942
+ D(t, o <= s), (e.imageClickAction === "zoom" || e.imageClickAction === "zoom-or-close") && t.classList.add("pswp--click-to-zoom");
1943
+ }
1944
+ }
1945
+ function Et(r) {
1946
+ const t = r.getBoundingClientRect();
1947
+ return {
1948
+ x: t.left,
1949
+ y: t.top,
1950
+ w: t.width
1951
+ };
1952
+ }
1953
+ function Ot(r, t, i) {
1954
+ const e = r.getBoundingClientRect(), s = e.width / t, n = e.height / i, o = s > n ? s : n, a = (e.width - t * o) / 2, h = (e.height - i * o) / 2, l = {
1955
+ x: e.left + a,
1956
+ y: e.top + h,
1957
+ w: t * o
1958
+ };
1959
+ return l.innerRect = {
1960
+ w: e.width,
1961
+ h: e.height,
1962
+ x: a,
1963
+ y: h
1964
+ }, l;
1965
+ }
1966
+ function Zt(r, t, i) {
1967
+ const e = i.dispatch("thumbBounds", {
1968
+ index: r,
1969
+ itemData: t,
1970
+ instance: i
1971
+ });
1972
+ if (e.thumbBounds)
1973
+ return e.thumbBounds;
1974
+ const {
1975
+ element: s
1976
+ } = t;
1977
+ let n, o;
1978
+ if (s && i.options.thumbSelector !== !1) {
1979
+ const a = i.options.thumbSelector || "img";
1980
+ o = s.matches(a) ? s : (
1981
+ /** @type {HTMLElement | null} */
1982
+ s.querySelector(a)
1983
+ );
1984
+ }
1985
+ return o = i.applyFilters("thumbEl", o, t, r), o && (t.thumbCropped ? n = Ot(o, t.width || t.w || 0, t.height || t.h || 0) : n = Et(o)), i.applyFilters("thumbBounds", n, t, r);
1986
+ }
1987
+ class Dt {
1988
+ /**
1989
+ * @param {T} type
1990
+ * @param {PhotoSwipeEventsMap[T]} [details]
1991
+ */
1992
+ constructor(t, i) {
1993
+ this.type = t, this.defaultPrevented = !1, i && Object.assign(this, i);
1994
+ }
1995
+ preventDefault() {
1996
+ this.defaultPrevented = !0;
1997
+ }
1998
+ }
1999
+ class Mt {
2000
+ constructor() {
2001
+ this._listeners = {}, this._filters = {}, this.pswp = void 0, this.options = void 0;
2002
+ }
2003
+ /**
2004
+ * @template {keyof PhotoSwipeFiltersMap} T
2005
+ * @param {T} name
2006
+ * @param {PhotoSwipeFiltersMap[T]} fn
2007
+ * @param {number} priority
2008
+ */
2009
+ addFilter(t, i, e = 100) {
2010
+ var s, n, o;
2011
+ this._filters[t] || (this._filters[t] = []), (s = this._filters[t]) === null || s === void 0 || s.push({
2012
+ fn: i,
2013
+ priority: e
2014
+ }), (n = this._filters[t]) === null || n === void 0 || n.sort((a, h) => a.priority - h.priority), (o = this.pswp) === null || o === void 0 || o.addFilter(t, i, e);
2015
+ }
2016
+ /**
2017
+ * @template {keyof PhotoSwipeFiltersMap} T
2018
+ * @param {T} name
2019
+ * @param {PhotoSwipeFiltersMap[T]} fn
2020
+ */
2021
+ removeFilter(t, i) {
2022
+ this._filters[t] && (this._filters[t] = this._filters[t].filter((e) => e.fn !== i)), this.pswp && this.pswp.removeFilter(t, i);
2023
+ }
2024
+ /**
2025
+ * @template {keyof PhotoSwipeFiltersMap} T
2026
+ * @param {T} name
2027
+ * @param {Parameters<PhotoSwipeFiltersMap[T]>} args
2028
+ * @returns {Parameters<PhotoSwipeFiltersMap[T]>[0]}
2029
+ */
2030
+ applyFilters(t, ...i) {
2031
+ var e;
2032
+ return (e = this._filters[t]) === null || e === void 0 || e.forEach((s) => {
2033
+ i[0] = s.fn.apply(this, i);
2034
+ }), i[0];
2035
+ }
2036
+ /**
2037
+ * @template {keyof PhotoSwipeEventsMap} T
2038
+ * @param {T} name
2039
+ * @param {EventCallback<T>} fn
2040
+ */
2041
+ on(t, i) {
2042
+ var e, s;
2043
+ this._listeners[t] || (this._listeners[t] = []), (e = this._listeners[t]) === null || e === void 0 || e.push(i), (s = this.pswp) === null || s === void 0 || s.on(t, i);
2044
+ }
2045
+ /**
2046
+ * @template {keyof PhotoSwipeEventsMap} T
2047
+ * @param {T} name
2048
+ * @param {EventCallback<T>} fn
2049
+ */
2050
+ off(t, i) {
2051
+ var e;
2052
+ this._listeners[t] && (this._listeners[t] = this._listeners[t].filter((s) => i !== s)), (e = this.pswp) === null || e === void 0 || e.off(t, i);
2053
+ }
2054
+ /**
2055
+ * @template {keyof PhotoSwipeEventsMap} T
2056
+ * @param {T} name
2057
+ * @param {PhotoSwipeEventsMap[T]} [details]
2058
+ * @returns {AugmentedEvent<T>}
2059
+ */
2060
+ dispatch(t, i) {
2061
+ var e;
2062
+ if (this.pswp)
2063
+ return this.pswp.dispatch(t, i);
2064
+ const s = (
2065
+ /** @type {AugmentedEvent<T>} */
2066
+ new Dt(t, i)
2067
+ );
2068
+ return (e = this._listeners[t]) === null || e === void 0 || e.forEach((n) => {
2069
+ n.call(this, s);
2070
+ }), s;
2071
+ }
2072
+ }
2073
+ class Rt {
2074
+ /**
2075
+ * @param {string | false} imageSrc
2076
+ * @param {HTMLElement} container
2077
+ */
2078
+ constructor(t, i) {
2079
+ if (this.element = f("pswp__img pswp__img--placeholder", t ? "img" : "div", i), t) {
2080
+ const e = (
2081
+ /** @type {HTMLImageElement} */
2082
+ this.element
2083
+ );
2084
+ e.decoding = "async", e.alt = "", e.src = t, e.setAttribute("role", "presentation");
2085
+ }
2086
+ this.element.setAttribute("aria-hidden", "true");
2087
+ }
2088
+ /**
2089
+ * @param {number} width
2090
+ * @param {number} height
2091
+ */
2092
+ setDisplayedSize(t, i) {
2093
+ this.element && (this.element.tagName === "IMG" ? (L(this.element, 250, "auto"), this.element.style.transformOrigin = "0 0", this.element.style.transform = I(0, 0, t / 250)) : L(this.element, t, i));
2094
+ }
2095
+ destroy() {
2096
+ var t;
2097
+ (t = this.element) !== null && t !== void 0 && t.parentNode && this.element.remove(), this.element = null;
2098
+ }
2099
+ }
2100
+ class Ft {
2101
+ /**
2102
+ * @param {SlideData} itemData Slide data
2103
+ * @param {PhotoSwipeBase} instance PhotoSwipe or PhotoSwipeLightbox instance
2104
+ * @param {number} index
2105
+ */
2106
+ constructor(t, i, e) {
2107
+ this.instance = i, this.data = t, this.index = e, this.element = void 0, this.placeholder = void 0, this.slide = void 0, this.displayedImageWidth = 0, this.displayedImageHeight = 0, this.width = Number(this.data.w) || Number(this.data.width) || 0, this.height = Number(this.data.h) || Number(this.data.height) || 0, this.isAttached = !1, this.hasSlide = !1, this.isDecoding = !1, this.state = _.IDLE, this.data.type ? this.type = this.data.type : this.data.src ? this.type = "image" : this.type = "html", this.instance.dispatch("contentInit", {
2108
+ content: this
2109
+ });
2110
+ }
2111
+ removePlaceholder() {
2112
+ this.placeholder && !this.keepPlaceholder() && setTimeout(() => {
2113
+ this.placeholder && (this.placeholder.destroy(), this.placeholder = void 0);
2114
+ }, 1e3);
2115
+ }
2116
+ /**
2117
+ * Preload content
2118
+ *
2119
+ * @param {boolean} isLazy
2120
+ * @param {boolean} [reload]
2121
+ */
2122
+ load(t, i) {
2123
+ if (this.slide && this.usePlaceholder())
2124
+ if (this.placeholder) {
2125
+ const e = this.placeholder.element;
2126
+ e && !e.parentElement && this.slide.container.prepend(e);
2127
+ } else {
2128
+ const e = this.instance.applyFilters(
2129
+ "placeholderSrc",
2130
+ // use image-based placeholder only for the first slide,
2131
+ // as rendering (even small stretched thumbnail) is an expensive operation
2132
+ this.data.msrc && this.slide.isFirstSlide ? this.data.msrc : !1,
2133
+ this
2134
+ );
2135
+ this.placeholder = new Rt(e, this.slide.container);
2136
+ }
2137
+ this.element && !i || this.instance.dispatch("contentLoad", {
2138
+ content: this,
2139
+ isLazy: t
2140
+ }).defaultPrevented || (this.isImageContent() ? (this.element = f("pswp__img", "img"), this.displayedImageWidth && this.loadImage(t)) : (this.element = f("pswp__content", "div"), this.element.innerHTML = this.data.html || ""), i && this.slide && this.slide.updateContentSize(!0));
2141
+ }
2142
+ /**
2143
+ * Preload image
2144
+ *
2145
+ * @param {boolean} isLazy
2146
+ */
2147
+ loadImage(t) {
2148
+ var i, e;
2149
+ if (!this.isImageContent() || !this.element || this.instance.dispatch("contentLoadImage", {
2150
+ content: this,
2151
+ isLazy: t
2152
+ }).defaultPrevented)
2153
+ return;
2154
+ const s = (
2155
+ /** @type HTMLImageElement */
2156
+ this.element
2157
+ );
2158
+ this.updateSrcsetSizes(), this.data.srcset && (s.srcset = this.data.srcset), s.src = (i = this.data.src) !== null && i !== void 0 ? i : "", s.alt = (e = this.data.alt) !== null && e !== void 0 ? e : "", this.state = _.LOADING, s.complete ? this.onLoaded() : (s.onload = () => {
2159
+ this.onLoaded();
2160
+ }, s.onerror = () => {
2161
+ this.onError();
2162
+ });
2163
+ }
2164
+ /**
2165
+ * Assign slide to content
2166
+ *
2167
+ * @param {Slide} slide
2168
+ */
2169
+ setSlide(t) {
2170
+ this.slide = t, this.hasSlide = !0, this.instance = t.pswp;
2171
+ }
2172
+ /**
2173
+ * Content load success handler
2174
+ */
2175
+ onLoaded() {
2176
+ this.state = _.LOADED, this.slide && this.element && (this.instance.dispatch("loadComplete", {
2177
+ slide: this.slide,
2178
+ content: this
2179
+ }), this.slide.isActive && this.slide.heavyAppended && !this.element.parentNode && (this.append(), this.slide.updateContentSize(!0)), (this.state === _.LOADED || this.state === _.ERROR) && this.removePlaceholder());
2180
+ }
2181
+ /**
2182
+ * Content load error handler
2183
+ */
2184
+ onError() {
2185
+ this.state = _.ERROR, this.slide && (this.displayError(), this.instance.dispatch("loadComplete", {
2186
+ slide: this.slide,
2187
+ isError: !0,
2188
+ content: this
2189
+ }), this.instance.dispatch("loadError", {
2190
+ slide: this.slide,
2191
+ content: this
2192
+ }));
2193
+ }
2194
+ /**
2195
+ * @returns {Boolean} If the content is currently loading
2196
+ */
2197
+ isLoading() {
2198
+ return this.instance.applyFilters("isContentLoading", this.state === _.LOADING, this);
2199
+ }
2200
+ /**
2201
+ * @returns {Boolean} If the content is in error state
2202
+ */
2203
+ isError() {
2204
+ return this.state === _.ERROR;
2205
+ }
2206
+ /**
2207
+ * @returns {boolean} If the content is image
2208
+ */
2209
+ isImageContent() {
2210
+ return this.type === "image";
2211
+ }
2212
+ /**
2213
+ * Update content size
2214
+ *
2215
+ * @param {Number} width
2216
+ * @param {Number} height
2217
+ */
2218
+ setDisplayedSize(t, i) {
2219
+ if (this.element && (this.placeholder && this.placeholder.setDisplayedSize(t, i), !this.instance.dispatch("contentResize", {
2220
+ content: this,
2221
+ width: t,
2222
+ height: i
2223
+ }).defaultPrevented && (L(this.element, t, i), this.isImageContent() && !this.isError()))) {
2224
+ const e = !this.displayedImageWidth && t;
2225
+ this.displayedImageWidth = t, this.displayedImageHeight = i, e ? this.loadImage(!1) : this.updateSrcsetSizes(), this.slide && this.instance.dispatch("imageSizeChange", {
2226
+ slide: this.slide,
2227
+ width: t,
2228
+ height: i,
2229
+ content: this
2230
+ });
2231
+ }
2232
+ }
2233
+ /**
2234
+ * @returns {boolean} If the content can be zoomed
2235
+ */
2236
+ isZoomable() {
2237
+ return this.instance.applyFilters("isContentZoomable", this.isImageContent() && this.state !== _.ERROR, this);
2238
+ }
2239
+ /**
2240
+ * Update image srcset sizes attribute based on width and height
2241
+ */
2242
+ updateSrcsetSizes() {
2243
+ if (!this.isImageContent() || !this.element || !this.data.srcset)
2244
+ return;
2245
+ const t = (
2246
+ /** @type HTMLImageElement */
2247
+ this.element
2248
+ ), i = this.instance.applyFilters("srcsetSizesWidth", this.displayedImageWidth, this);
2249
+ (!t.dataset.largestUsedSize || i > parseInt(t.dataset.largestUsedSize, 10)) && (t.sizes = i + "px", t.dataset.largestUsedSize = String(i));
2250
+ }
2251
+ /**
2252
+ * @returns {boolean} If content should use a placeholder (from msrc by default)
2253
+ */
2254
+ usePlaceholder() {
2255
+ return this.instance.applyFilters("useContentPlaceholder", this.isImageContent(), this);
2256
+ }
2257
+ /**
2258
+ * Preload content with lazy-loading param
2259
+ */
2260
+ lazyLoad() {
2261
+ this.instance.dispatch("contentLazyLoad", {
2262
+ content: this
2263
+ }).defaultPrevented || this.load(!0);
2264
+ }
2265
+ /**
2266
+ * @returns {boolean} If placeholder should be kept after content is loaded
2267
+ */
2268
+ keepPlaceholder() {
2269
+ return this.instance.applyFilters("isKeepingPlaceholder", this.isLoading(), this);
2270
+ }
2271
+ /**
2272
+ * Destroy the content
2273
+ */
2274
+ destroy() {
2275
+ this.hasSlide = !1, this.slide = void 0, !this.instance.dispatch("contentDestroy", {
2276
+ content: this
2277
+ }).defaultPrevented && (this.remove(), this.placeholder && (this.placeholder.destroy(), this.placeholder = void 0), this.isImageContent() && this.element && (this.element.onload = null, this.element.onerror = null, this.element = void 0));
2278
+ }
2279
+ /**
2280
+ * Display error message
2281
+ */
2282
+ displayError() {
2283
+ if (this.slide) {
2284
+ var t, i;
2285
+ let e = f("pswp__error-msg", "div");
2286
+ e.innerText = (t = (i = this.instance.options) === null || i === void 0 ? void 0 : i.errorMsg) !== null && t !== void 0 ? t : "", e = /** @type {HTMLDivElement} */
2287
+ this.instance.applyFilters("contentErrorElement", e, this), this.element = f("pswp__content pswp__error-msg-container", "div"), this.element.appendChild(e), this.slide.container.innerText = "", this.slide.container.appendChild(this.element), this.slide.updateContentSize(!0), this.removePlaceholder();
2288
+ }
2289
+ }
2290
+ /**
2291
+ * Append the content
2292
+ */
2293
+ append() {
2294
+ if (this.isAttached || !this.element)
2295
+ return;
2296
+ if (this.isAttached = !0, this.state === _.ERROR) {
2297
+ this.displayError();
2298
+ return;
2299
+ }
2300
+ if (this.instance.dispatch("contentAppend", {
2301
+ content: this
2302
+ }).defaultPrevented)
2303
+ return;
2304
+ const t = "decode" in this.element;
2305
+ this.isImageContent() ? t && this.slide && (!this.slide.isActive || C()) ? (this.isDecoding = !0, this.element.decode().catch(() => {
2306
+ }).finally(() => {
2307
+ this.isDecoding = !1, this.appendImage();
2308
+ })) : this.appendImage() : this.slide && !this.element.parentNode && this.slide.container.appendChild(this.element);
2309
+ }
2310
+ /**
2311
+ * Activate the slide,
2312
+ * active slide is generally the current one,
2313
+ * meaning the user can see it.
2314
+ */
2315
+ activate() {
2316
+ this.instance.dispatch("contentActivate", {
2317
+ content: this
2318
+ }).defaultPrevented || !this.slide || (this.isImageContent() && this.isDecoding && !C() ? this.appendImage() : this.isError() && this.load(!1, !0), this.slide.holderElement && this.slide.holderElement.setAttribute("aria-hidden", "false"));
2319
+ }
2320
+ /**
2321
+ * Deactivate the content
2322
+ */
2323
+ deactivate() {
2324
+ this.instance.dispatch("contentDeactivate", {
2325
+ content: this
2326
+ }), this.slide && this.slide.holderElement && this.slide.holderElement.setAttribute("aria-hidden", "true");
2327
+ }
2328
+ /**
2329
+ * Remove the content from DOM
2330
+ */
2331
+ remove() {
2332
+ this.isAttached = !1, !this.instance.dispatch("contentRemove", {
2333
+ content: this
2334
+ }).defaultPrevented && (this.element && this.element.parentNode && this.element.remove(), this.placeholder && this.placeholder.element && this.placeholder.element.remove());
2335
+ }
2336
+ /**
2337
+ * Append the image content to slide container
2338
+ */
2339
+ appendImage() {
2340
+ this.isAttached && (this.instance.dispatch("contentAppendImage", {
2341
+ content: this
2342
+ }).defaultPrevented || (this.slide && this.element && !this.element.parentNode && this.slide.container.appendChild(this.element), (this.state === _.LOADED || this.state === _.ERROR) && this.removePlaceholder()));
2343
+ }
2344
+ }
2345
+ const Bt = 5;
2346
+ function W(r, t, i) {
2347
+ const e = t.createContentFromData(r, i);
2348
+ let s;
2349
+ const {
2350
+ options: n
2351
+ } = t;
2352
+ if (n) {
2353
+ s = new k(n, r, -1);
2354
+ let o;
2355
+ t.pswp ? o = t.pswp.viewportSize : o = B(n, t);
2356
+ const a = N(n, o, r, i);
2357
+ s.update(e.width, e.height, a);
2358
+ }
2359
+ return e.lazyLoad(), s && e.setDisplayedSize(Math.ceil(e.width * s.initial), Math.ceil(e.height * s.initial)), e;
2360
+ }
2361
+ function Nt(r, t) {
2362
+ const i = t.getItemData(r);
2363
+ if (!t.dispatch("lazyLoadSlide", {
2364
+ index: r,
2365
+ itemData: i
2366
+ }).defaultPrevented)
2367
+ return W(i, t, r);
2368
+ }
2369
+ class kt {
2370
+ /**
2371
+ * @param {PhotoSwipe} pswp
2372
+ */
2373
+ constructor(t) {
2374
+ this.pswp = t, this.limit = Math.max(t.options.preload[0] + t.options.preload[1] + 1, Bt), this._cachedItems = [];
2375
+ }
2376
+ /**
2377
+ * Lazy load nearby slides based on `preload` option.
2378
+ *
2379
+ * @param {number} [diff] Difference between slide indexes that was changed recently, or 0.
2380
+ */
2381
+ updateLazy(t) {
2382
+ const {
2383
+ pswp: i
2384
+ } = this;
2385
+ if (i.dispatch("lazyLoad").defaultPrevented)
2386
+ return;
2387
+ const {
2388
+ preload: e
2389
+ } = i.options, s = t === void 0 ? !0 : t >= 0;
2390
+ let n;
2391
+ for (n = 0; n <= e[1]; n++)
2392
+ this.loadSlideByIndex(i.currIndex + (s ? n : -n));
2393
+ for (n = 1; n <= e[0]; n++)
2394
+ this.loadSlideByIndex(i.currIndex + (s ? -n : n));
2395
+ }
2396
+ /**
2397
+ * @param {number} initialIndex
2398
+ */
2399
+ loadSlideByIndex(t) {
2400
+ const i = this.pswp.getLoopedIndex(t);
2401
+ let e = this.getContentByIndex(i);
2402
+ e || (e = Nt(i, this.pswp), e && this.addToCache(e));
2403
+ }
2404
+ /**
2405
+ * @param {Slide} slide
2406
+ * @returns {Content}
2407
+ */
2408
+ getContentBySlide(t) {
2409
+ let i = this.getContentByIndex(t.index);
2410
+ return i || (i = this.pswp.createContentFromData(t.data, t.index), this.addToCache(i)), i.setSlide(t), i;
2411
+ }
2412
+ /**
2413
+ * @param {Content} content
2414
+ */
2415
+ addToCache(t) {
2416
+ if (this.removeByIndex(t.index), this._cachedItems.push(t), this._cachedItems.length > this.limit) {
2417
+ const i = this._cachedItems.findIndex((e) => !e.isAttached && !e.hasSlide);
2418
+ i !== -1 && this._cachedItems.splice(i, 1)[0].destroy();
2419
+ }
2420
+ }
2421
+ /**
2422
+ * Removes an image from cache, does not destroy() it, just removes.
2423
+ *
2424
+ * @param {number} index
2425
+ */
2426
+ removeByIndex(t) {
2427
+ const i = this._cachedItems.findIndex((e) => e.index === t);
2428
+ i !== -1 && this._cachedItems.splice(i, 1);
2429
+ }
2430
+ /**
2431
+ * @param {number} index
2432
+ * @returns {Content | undefined}
2433
+ */
2434
+ getContentByIndex(t) {
2435
+ return this._cachedItems.find((i) => i.index === t);
2436
+ }
2437
+ destroy() {
2438
+ this._cachedItems.forEach((t) => t.destroy()), this._cachedItems = [];
2439
+ }
2440
+ }
2441
+ class Ht extends Mt {
2442
+ /**
2443
+ * Get total number of slides
2444
+ *
2445
+ * @returns {number}
2446
+ */
2447
+ getNumItems() {
2448
+ var t;
2449
+ let i = 0;
2450
+ const e = (t = this.options) === null || t === void 0 ? void 0 : t.dataSource;
2451
+ e && "length" in e ? i = e.length : e && "gallery" in e && (e.items || (e.items = this._getGalleryDOMElements(e.gallery)), e.items && (i = e.items.length));
2452
+ const s = this.dispatch("numItems", {
2453
+ dataSource: e,
2454
+ numItems: i
2455
+ });
2456
+ return this.applyFilters("numItems", s.numItems, e);
2457
+ }
2458
+ /**
2459
+ * @param {SlideData} slideData
2460
+ * @param {number} index
2461
+ * @returns {Content}
2462
+ */
2463
+ createContentFromData(t, i) {
2464
+ return new Ft(t, this, i);
2465
+ }
2466
+ /**
2467
+ * Get item data by index.
2468
+ *
2469
+ * "item data" should contain normalized information that PhotoSwipe needs to generate a slide.
2470
+ * For example, it may contain properties like
2471
+ * `src`, `srcset`, `w`, `h`, which will be used to generate a slide with image.
2472
+ *
2473
+ * @param {number} index
2474
+ * @returns {SlideData}
2475
+ */
2476
+ getItemData(t) {
2477
+ var i;
2478
+ const e = (i = this.options) === null || i === void 0 ? void 0 : i.dataSource;
2479
+ let s = {};
2480
+ Array.isArray(e) ? s = e[t] : e && "gallery" in e && (e.items || (e.items = this._getGalleryDOMElements(e.gallery)), s = e.items[t]);
2481
+ let n = s;
2482
+ n instanceof Element && (n = this._domElementToItemData(n));
2483
+ const o = this.dispatch("itemData", {
2484
+ itemData: n || {},
2485
+ index: t
2486
+ });
2487
+ return this.applyFilters("itemData", o.itemData, t);
2488
+ }
2489
+ /**
2490
+ * Get array of gallery DOM elements,
2491
+ * based on childSelector and gallery element.
2492
+ *
2493
+ * @param {HTMLElement} galleryElement
2494
+ * @returns {HTMLElement[]}
2495
+ */
2496
+ _getGalleryDOMElements(t) {
2497
+ var i, e;
2498
+ return (i = this.options) !== null && i !== void 0 && i.children || (e = this.options) !== null && e !== void 0 && e.childSelector ? K(this.options.children, this.options.childSelector, t) || [] : [t];
2499
+ }
2500
+ /**
2501
+ * Converts DOM element to item data object.
2502
+ *
2503
+ * @param {HTMLElement} element DOM element
2504
+ * @returns {SlideData}
2505
+ */
2506
+ _domElementToItemData(t) {
2507
+ const i = {
2508
+ element: t
2509
+ }, e = (
2510
+ /** @type {HTMLAnchorElement} */
2511
+ t.tagName === "A" ? t : t.querySelector("a")
2512
+ );
2513
+ if (e) {
2514
+ i.src = e.dataset.pswpSrc || e.href, e.dataset.pswpSrcset && (i.srcset = e.dataset.pswpSrcset), i.width = e.dataset.pswpWidth ? parseInt(e.dataset.pswpWidth, 10) : 0, i.height = e.dataset.pswpHeight ? parseInt(e.dataset.pswpHeight, 10) : 0, i.w = i.width, i.h = i.height, e.dataset.pswpType && (i.type = e.dataset.pswpType);
2515
+ const n = t.querySelector("img");
2516
+ if (n) {
2517
+ var s;
2518
+ i.msrc = n.currentSrc || n.src, i.alt = (s = n.getAttribute("alt")) !== null && s !== void 0 ? s : "";
2519
+ }
2520
+ (e.dataset.pswpCropped || e.dataset.cropped) && (i.thumbCropped = !0);
2521
+ }
2522
+ return this.applyFilters("domItemData", i, t, e);
2523
+ }
2524
+ /**
2525
+ * Lazy-load by slide data
2526
+ *
2527
+ * @param {SlideData} itemData Data about the slide
2528
+ * @param {number} index
2529
+ * @returns {Content} Image that is being decoded or false.
2530
+ */
2531
+ lazyLoadData(t, i) {
2532
+ return W(t, this, i);
2533
+ }
2534
+ }
2535
+ const P = 3e-3;
2536
+ class Wt {
2537
+ /**
2538
+ * @param {PhotoSwipe} pswp
2539
+ */
2540
+ constructor(t) {
2541
+ this.pswp = t, this.isClosed = !0, this.isOpen = !1, this.isClosing = !1, this.isOpening = !1, this._duration = void 0, this._useAnimation = !1, this._croppedZoom = !1, this._animateRootOpacity = !1, this._animateBgOpacity = !1, this._placeholder = void 0, this._opacityElement = void 0, this._cropContainer1 = void 0, this._cropContainer2 = void 0, this._thumbBounds = void 0, this._prepareOpen = this._prepareOpen.bind(this), t.on("firstZoomPan", this._prepareOpen);
2542
+ }
2543
+ open() {
2544
+ this._prepareOpen(), this._start();
2545
+ }
2546
+ close() {
2547
+ if (this.isClosed || this.isClosing || this.isOpening)
2548
+ return;
2549
+ const t = this.pswp.currSlide;
2550
+ this.isOpen = !1, this.isOpening = !1, this.isClosing = !0, this._duration = this.pswp.options.hideAnimationDuration, t && t.currZoomLevel * t.width >= this.pswp.options.maxWidthToAnimate && (this._duration = 0), this._applyStartProps(), setTimeout(() => {
2551
+ this._start();
2552
+ }, this._croppedZoom ? 30 : 0);
2553
+ }
2554
+ /** @private */
2555
+ _prepareOpen() {
2556
+ if (this.pswp.off("firstZoomPan", this._prepareOpen), !this.isOpening) {
2557
+ const t = this.pswp.currSlide;
2558
+ this.isOpening = !0, this.isClosing = !1, this._duration = this.pswp.options.showAnimationDuration, t && t.zoomLevels.initial * t.width >= this.pswp.options.maxWidthToAnimate && (this._duration = 0), this._applyStartProps();
2559
+ }
2560
+ }
2561
+ /** @private */
2562
+ _applyStartProps() {
2563
+ const {
2564
+ pswp: t
2565
+ } = this, i = this.pswp.currSlide, {
2566
+ options: e
2567
+ } = t;
2568
+ if (e.showHideAnimationType === "fade" ? (e.showHideOpacity = !0, this._thumbBounds = void 0) : e.showHideAnimationType === "none" ? (e.showHideOpacity = !1, this._duration = 0, this._thumbBounds = void 0) : this.isOpening && t._initialThumbBounds ? this._thumbBounds = t._initialThumbBounds : this._thumbBounds = this.pswp.getThumbBounds(), this._placeholder = i?.getPlaceholderElement(), t.animations.stopAll(), this._useAnimation = !!(this._duration && this._duration > 50), this._animateZoom = !!this._thumbBounds && i?.content.usePlaceholder() && (!this.isClosing || !t.mainScroll.isShifted()), !this._animateZoom)
2569
+ this._animateRootOpacity = !0, this.isOpening && i && (i.zoomAndPanToInitial(), i.applyCurrentZoomPan());
2570
+ else {
2571
+ var s;
2572
+ this._animateRootOpacity = (s = e.showHideOpacity) !== null && s !== void 0 ? s : !1;
2573
+ }
2574
+ if (this._animateBgOpacity = !this._animateRootOpacity && this.pswp.options.bgOpacity > P, this._opacityElement = this._animateRootOpacity ? t.element : t.bg, !this._useAnimation) {
2575
+ this._duration = 0, this._animateZoom = !1, this._animateBgOpacity = !1, this._animateRootOpacity = !0, this.isOpening && (t.element && (t.element.style.opacity = String(P)), t.applyBgOpacity(1));
2576
+ return;
2577
+ }
2578
+ if (this._animateZoom && this._thumbBounds && this._thumbBounds.innerRect) {
2579
+ var n;
2580
+ this._croppedZoom = !0, this._cropContainer1 = this.pswp.container, this._cropContainer2 = (n = this.pswp.currSlide) === null || n === void 0 ? void 0 : n.holderElement, t.container && (t.container.style.overflow = "hidden", t.container.style.width = t.viewportSize.x + "px");
2581
+ } else
2582
+ this._croppedZoom = !1;
2583
+ this.isOpening ? (this._animateRootOpacity ? (t.element && (t.element.style.opacity = String(P)), t.applyBgOpacity(1)) : (this._animateBgOpacity && t.bg && (t.bg.style.opacity = String(P)), t.element && (t.element.style.opacity = "1")), this._animateZoom && (this._setClosedStateZoomPan(), this._placeholder && (this._placeholder.style.willChange = "transform", this._placeholder.style.opacity = String(P)))) : this.isClosing && (t.mainScroll.itemHolders[0] && (t.mainScroll.itemHolders[0].el.style.display = "none"), t.mainScroll.itemHolders[2] && (t.mainScroll.itemHolders[2].el.style.display = "none"), this._croppedZoom && t.mainScroll.x !== 0 && (t.mainScroll.resetPosition(), t.mainScroll.resize()));
2584
+ }
2585
+ /** @private */
2586
+ _start() {
2587
+ this.isOpening && this._useAnimation && this._placeholder && this._placeholder.tagName === "IMG" ? new Promise((t) => {
2588
+ let i = !1, e = !0;
2589
+ q(
2590
+ /** @type {HTMLImageElement} */
2591
+ this._placeholder
2592
+ ).finally(() => {
2593
+ i = !0, e || t(!0);
2594
+ }), setTimeout(() => {
2595
+ e = !1, i && t(!0);
2596
+ }, 50), setTimeout(t, 250);
2597
+ }).finally(() => this._initiate()) : this._initiate();
2598
+ }
2599
+ /** @private */
2600
+ _initiate() {
2601
+ var t, i;
2602
+ (t = this.pswp.element) === null || t === void 0 || t.style.setProperty("--pswp-transition-duration", this._duration + "ms"), this.pswp.dispatch(this.isOpening ? "openingAnimationStart" : "closingAnimationStart"), this.pswp.dispatch(
2603
+ /** @type {'initialZoomIn' | 'initialZoomOut'} */
2604
+ "initialZoom" + (this.isOpening ? "In" : "Out")
2605
+ ), (i = this.pswp.element) === null || i === void 0 || i.classList.toggle("pswp--ui-visible", this.isOpening), this.isOpening ? (this._placeholder && (this._placeholder.style.opacity = "1"), this._animateToOpenState()) : this.isClosing && this._animateToClosedState(), this._useAnimation || this._onAnimationComplete();
2606
+ }
2607
+ /** @private */
2608
+ _onAnimationComplete() {
2609
+ const {
2610
+ pswp: t
2611
+ } = this;
2612
+ if (this.isOpen = this.isOpening, this.isClosed = this.isClosing, this.isOpening = !1, this.isClosing = !1, t.dispatch(this.isOpen ? "openingAnimationEnd" : "closingAnimationEnd"), t.dispatch(
2613
+ /** @type {'initialZoomInEnd' | 'initialZoomOutEnd'} */
2614
+ "initialZoom" + (this.isOpen ? "InEnd" : "OutEnd")
2615
+ ), this.isClosed)
2616
+ t.destroy();
2617
+ else if (this.isOpen) {
2618
+ var i;
2619
+ this._animateZoom && t.container && (t.container.style.overflow = "visible", t.container.style.width = "100%"), (i = t.currSlide) === null || i === void 0 || i.applyCurrentZoomPan();
2620
+ }
2621
+ }
2622
+ /** @private */
2623
+ _animateToOpenState() {
2624
+ const {
2625
+ pswp: t
2626
+ } = this;
2627
+ this._animateZoom && (this._croppedZoom && this._cropContainer1 && this._cropContainer2 && (this._animateTo(this._cropContainer1, "transform", "translate3d(0,0,0)"), this._animateTo(this._cropContainer2, "transform", "none")), t.currSlide && (t.currSlide.zoomAndPanToInitial(), this._animateTo(t.currSlide.container, "transform", t.currSlide.getCurrentTransform()))), this._animateBgOpacity && t.bg && this._animateTo(t.bg, "opacity", String(t.options.bgOpacity)), this._animateRootOpacity && t.element && this._animateTo(t.element, "opacity", "1");
2628
+ }
2629
+ /** @private */
2630
+ _animateToClosedState() {
2631
+ const {
2632
+ pswp: t
2633
+ } = this;
2634
+ this._animateZoom && this._setClosedStateZoomPan(!0), this._animateBgOpacity && t.bgOpacity > 0.01 && t.bg && this._animateTo(t.bg, "opacity", "0"), this._animateRootOpacity && t.element && this._animateTo(t.element, "opacity", "0");
2635
+ }
2636
+ /**
2637
+ * @private
2638
+ * @param {boolean} [animate]
2639
+ */
2640
+ _setClosedStateZoomPan(t) {
2641
+ if (!this._thumbBounds) return;
2642
+ const {
2643
+ pswp: i
2644
+ } = this, {
2645
+ innerRect: e
2646
+ } = this._thumbBounds, {
2647
+ currSlide: s,
2648
+ viewportSize: n
2649
+ } = i;
2650
+ if (this._croppedZoom && e && this._cropContainer1 && this._cropContainer2) {
2651
+ const o = -n.x + (this._thumbBounds.x - e.x) + e.w, a = -n.y + (this._thumbBounds.y - e.y) + e.h, h = n.x - e.w, l = n.y - e.h;
2652
+ t ? (this._animateTo(this._cropContainer1, "transform", I(o, a)), this._animateTo(this._cropContainer2, "transform", I(h, l))) : (y(this._cropContainer1, o, a), y(this._cropContainer2, h, l));
2653
+ }
2654
+ s && (p(s.pan, e || this._thumbBounds), s.currZoomLevel = this._thumbBounds.w / s.width, t ? this._animateTo(s.container, "transform", s.getCurrentTransform()) : s.applyCurrentZoomPan());
2655
+ }
2656
+ /**
2657
+ * @private
2658
+ * @param {HTMLElement} target
2659
+ * @param {'transform' | 'opacity'} prop
2660
+ * @param {string} propValue
2661
+ */
2662
+ _animateTo(t, i, e) {
2663
+ if (!this._duration) {
2664
+ t.style[i] = e;
2665
+ return;
2666
+ }
2667
+ const {
2668
+ animations: s
2669
+ } = this.pswp, n = {
2670
+ duration: this._duration,
2671
+ easing: this.pswp.options.easing,
2672
+ onComplete: () => {
2673
+ s.activeAnimations.length || this._onAnimationComplete();
2674
+ },
2675
+ target: t
2676
+ };
2677
+ n[i] = e, s.startTransition(n);
2678
+ }
2679
+ }
2680
+ const Vt = {
2681
+ allowPanToNext: !0,
2682
+ spacing: 0.1,
2683
+ loop: !0,
2684
+ pinchToClose: !0,
2685
+ closeOnVerticalDrag: !0,
2686
+ hideAnimationDuration: 333,
2687
+ showAnimationDuration: 333,
2688
+ zoomAnimationDuration: 333,
2689
+ escKey: !0,
2690
+ arrowKeys: !0,
2691
+ trapFocus: !0,
2692
+ returnFocus: !0,
2693
+ maxWidthToAnimate: 4e3,
2694
+ clickToCloseNonZoomable: !0,
2695
+ imageClickAction: "zoom-or-close",
2696
+ bgClickAction: "close",
2697
+ tapAction: "toggle-controls",
2698
+ doubleTapAction: "zoom",
2699
+ indexIndicatorSep: " / ",
2700
+ preloaderDelay: 2e3,
2701
+ bgOpacity: 0.8,
2702
+ index: 0,
2703
+ errorMsg: "The image cannot be loaded",
2704
+ preload: [1, 2],
2705
+ easing: "cubic-bezier(.4,0,.22,1)"
2706
+ };
2707
+ class $t extends Ht {
2708
+ /**
2709
+ * @param {PhotoSwipeOptions} [options]
2710
+ */
2711
+ constructor(t) {
2712
+ super(), this.options = this._prepareOptions(t || {}), this.offset = {
2713
+ x: 0,
2714
+ y: 0
2715
+ }, this._prevViewportSize = {
2716
+ x: 0,
2717
+ y: 0
2718
+ }, this.viewportSize = {
2719
+ x: 0,
2720
+ y: 0
2721
+ }, this.bgOpacity = 1, this.currIndex = 0, this.potentialIndex = 0, this.isOpen = !1, this.isDestroying = !1, this.hasMouse = !1, this._initialItemData = {}, this._initialThumbBounds = void 0, this.topBar = void 0, this.element = void 0, this.template = void 0, this.container = void 0, this.scrollWrap = void 0, this.currSlide = void 0, this.events = new X(), this.animations = new wt(), this.mainScroll = new dt(this), this.gestures = new lt(this), this.opener = new Wt(this), this.keyboard = new ut(this), this.contentLoader = new kt(this);
2722
+ }
2723
+ /** @returns {boolean} */
2724
+ init() {
2725
+ if (this.isOpen || this.isDestroying)
2726
+ return !1;
2727
+ this.isOpen = !0, this.dispatch("init"), this.dispatch("beforeOpen"), this._createMainStructure();
2728
+ let t = "pswp--open";
2729
+ return this.gestures.supportsTouch && (t += " pswp--touch"), this.options.mainClass && (t += " " + this.options.mainClass), this.element && (this.element.className += " " + t), this.currIndex = this.options.index || 0, this.potentialIndex = this.currIndex, this.dispatch("firstUpdate"), this.scrollWheel = new Pt(this), (Number.isNaN(this.currIndex) || this.currIndex < 0 || this.currIndex >= this.getNumItems()) && (this.currIndex = 0), this.gestures.supportsTouch || this.mouseDetected(), this.updateSize(), this.offset.y = window.pageYOffset, this._initialItemData = this.getItemData(this.currIndex), this.dispatch("gettingData", {
2730
+ index: this.currIndex,
2731
+ data: this._initialItemData,
2732
+ slide: void 0
2733
+ }), this._initialThumbBounds = this.getThumbBounds(), this.dispatch("initialLayout"), this.on("openingAnimationEnd", () => {
2734
+ const {
2735
+ itemHolders: i
2736
+ } = this.mainScroll;
2737
+ i[0] && (i[0].el.style.display = "block", this.setContent(i[0], this.currIndex - 1)), i[2] && (i[2].el.style.display = "block", this.setContent(i[2], this.currIndex + 1)), this.appendHeavy(), this.contentLoader.updateLazy(), this.events.add(window, "resize", this._handlePageResize.bind(this)), this.events.add(window, "scroll", this._updatePageScrollOffset.bind(this)), this.dispatch("bindEvents");
2738
+ }), this.mainScroll.itemHolders[1] && this.setContent(this.mainScroll.itemHolders[1], this.currIndex), this.dispatch("change"), this.opener.open(), this.dispatch("afterInit"), !0;
2739
+ }
2740
+ /**
2741
+ * Get looped slide index
2742
+ * (for example, -1 will return the last slide)
2743
+ *
2744
+ * @param {number} index
2745
+ * @returns {number}
2746
+ */
2747
+ getLoopedIndex(t) {
2748
+ const i = this.getNumItems();
2749
+ return this.options.loop && (t > i - 1 && (t -= i), t < 0 && (t += i)), b(t, 0, i - 1);
2750
+ }
2751
+ appendHeavy() {
2752
+ this.mainScroll.itemHolders.forEach((t) => {
2753
+ var i;
2754
+ (i = t.slide) === null || i === void 0 || i.appendHeavy();
2755
+ });
2756
+ }
2757
+ /**
2758
+ * Change the slide
2759
+ * @param {number} index New index
2760
+ */
2761
+ goTo(t) {
2762
+ this.mainScroll.moveIndexBy(this.getLoopedIndex(t) - this.potentialIndex);
2763
+ }
2764
+ /**
2765
+ * Go to the next slide.
2766
+ */
2767
+ next() {
2768
+ this.goTo(this.potentialIndex + 1);
2769
+ }
2770
+ /**
2771
+ * Go to the previous slide.
2772
+ */
2773
+ prev() {
2774
+ this.goTo(this.potentialIndex - 1);
2775
+ }
2776
+ /**
2777
+ * @see slide/slide.js zoomTo
2778
+ *
2779
+ * @param {Parameters<Slide['zoomTo']>} args
2780
+ */
2781
+ zoomTo(...t) {
2782
+ var i;
2783
+ (i = this.currSlide) === null || i === void 0 || i.zoomTo(...t);
2784
+ }
2785
+ /**
2786
+ * @see slide/slide.js toggleZoom
2787
+ */
2788
+ toggleZoom() {
2789
+ var t;
2790
+ (t = this.currSlide) === null || t === void 0 || t.toggleZoom();
2791
+ }
2792
+ /**
2793
+ * Close the gallery.
2794
+ * After closing transition ends - destroy it
2795
+ */
2796
+ close() {
2797
+ !this.opener.isOpen || this.isDestroying || (this.isDestroying = !0, this.dispatch("close"), this.events.removeAll(), this.opener.close());
2798
+ }
2799
+ /**
2800
+ * Destroys the gallery:
2801
+ * - instantly closes the gallery
2802
+ * - unbinds events,
2803
+ * - cleans intervals and timeouts
2804
+ * - removes elements from DOM
2805
+ */
2806
+ destroy() {
2807
+ var t;
2808
+ if (!this.isDestroying) {
2809
+ this.options.showHideAnimationType = "none", this.close();
2810
+ return;
2811
+ }
2812
+ this.dispatch("destroy"), this._listeners = {}, this.scrollWrap && (this.scrollWrap.ontouchmove = null, this.scrollWrap.ontouchend = null), (t = this.element) === null || t === void 0 || t.remove(), this.mainScroll.itemHolders.forEach((i) => {
2813
+ var e;
2814
+ (e = i.slide) === null || e === void 0 || e.destroy();
2815
+ }), this.contentLoader.destroy(), this.events.removeAll();
2816
+ }
2817
+ /**
2818
+ * Refresh/reload content of a slide by its index
2819
+ *
2820
+ * @param {number} slideIndex
2821
+ */
2822
+ refreshSlideContent(t) {
2823
+ this.contentLoader.removeByIndex(t), this.mainScroll.itemHolders.forEach((i, e) => {
2824
+ var s, n;
2825
+ let o = ((s = (n = this.currSlide) === null || n === void 0 ? void 0 : n.index) !== null && s !== void 0 ? s : 0) - 1 + e;
2826
+ if (this.canLoop() && (o = this.getLoopedIndex(o)), o === t && (this.setContent(i, t, !0), e === 1)) {
2827
+ var a;
2828
+ this.currSlide = i.slide, (a = i.slide) === null || a === void 0 || a.setIsActive(!0);
2829
+ }
2830
+ }), this.dispatch("change");
2831
+ }
2832
+ /**
2833
+ * Set slide content
2834
+ *
2835
+ * @param {ItemHolder} holder mainScroll.itemHolders array item
2836
+ * @param {number} index Slide index
2837
+ * @param {boolean} [force] If content should be set even if index wasn't changed
2838
+ */
2839
+ setContent(t, i, e) {
2840
+ if (this.canLoop() && (i = this.getLoopedIndex(i)), t.slide) {
2841
+ if (t.slide.index === i && !e)
2842
+ return;
2843
+ t.slide.destroy(), t.slide = void 0;
2844
+ }
2845
+ if (!this.canLoop() && (i < 0 || i >= this.getNumItems()))
2846
+ return;
2847
+ const s = this.getItemData(i);
2848
+ t.slide = new j(s, i, this), i === this.currIndex && (this.currSlide = t.slide), t.slide.append(t.el);
2849
+ }
2850
+ /** @returns {Point} */
2851
+ getViewportCenterPoint() {
2852
+ return {
2853
+ x: this.viewportSize.x / 2,
2854
+ y: this.viewportSize.y / 2
2855
+ };
2856
+ }
2857
+ /**
2858
+ * Update size of all elements.
2859
+ * Executed on init and on page resize.
2860
+ *
2861
+ * @param {boolean} [force] Update size even if size of viewport was not changed.
2862
+ */
2863
+ updateSize(t) {
2864
+ if (this.isDestroying)
2865
+ return;
2866
+ const i = B(this.options, this);
2867
+ !t && x(i, this._prevViewportSize) || (p(this._prevViewportSize, i), this.dispatch("beforeResize"), p(this.viewportSize, this._prevViewportSize), this._updatePageScrollOffset(), this.dispatch("viewportSize"), this.mainScroll.resize(this.opener.isOpen), !this.hasMouse && window.matchMedia("(any-hover: hover)").matches && this.mouseDetected(), this.dispatch("resize"));
2868
+ }
2869
+ /**
2870
+ * @param {number} opacity
2871
+ */
2872
+ applyBgOpacity(t) {
2873
+ this.bgOpacity = Math.max(t, 0), this.bg && (this.bg.style.opacity = String(this.bgOpacity * this.options.bgOpacity));
2874
+ }
2875
+ /**
2876
+ * Whether mouse is detected
2877
+ */
2878
+ mouseDetected() {
2879
+ if (!this.hasMouse) {
2880
+ var t;
2881
+ this.hasMouse = !0, (t = this.element) === null || t === void 0 || t.classList.add("pswp--has_mouse");
2882
+ }
2883
+ }
2884
+ /**
2885
+ * Page resize event handler
2886
+ *
2887
+ * @private
2888
+ */
2889
+ _handlePageResize() {
2890
+ this.updateSize(), /iPhone|iPad|iPod/i.test(window.navigator.userAgent) && setTimeout(() => {
2891
+ this.updateSize();
2892
+ }, 500);
2893
+ }
2894
+ /**
2895
+ * Page scroll offset is used
2896
+ * to get correct coordinates
2897
+ * relative to PhotoSwipe viewport.
2898
+ *
2899
+ * @private
2900
+ */
2901
+ _updatePageScrollOffset() {
2902
+ this.setScrollOffset(0, window.pageYOffset);
2903
+ }
2904
+ /**
2905
+ * @param {number} x
2906
+ * @param {number} y
2907
+ */
2908
+ setScrollOffset(t, i) {
2909
+ this.offset.x = t, this.offset.y = i, this.dispatch("updateScrollOffset");
2910
+ }
2911
+ /**
2912
+ * Create main HTML structure of PhotoSwipe,
2913
+ * and add it to DOM
2914
+ *
2915
+ * @private
2916
+ */
2917
+ _createMainStructure() {
2918
+ this.element = f("pswp", "div"), this.element.setAttribute("tabindex", "-1"), this.element.setAttribute("role", "dialog"), this.template = this.element, this.bg = f("pswp__bg", "div", this.element), this.scrollWrap = f("pswp__scroll-wrap", "section", this.element), this.container = f("pswp__container", "div", this.scrollWrap), this.scrollWrap.setAttribute("aria-roledescription", "carousel"), this.container.setAttribute("aria-live", "off"), this.container.setAttribute("id", "pswp__items"), this.mainScroll.appendHolders(), this.ui = new zt(this), this.ui.init(), (this.options.appendToEl || document.body).appendChild(this.element);
2919
+ }
2920
+ /**
2921
+ * Get position and dimensions of small thumbnail
2922
+ * {x:,y:,w:}
2923
+ *
2924
+ * Height is optional (calculated based on the large image)
2925
+ *
2926
+ * @returns {Bounds | undefined}
2927
+ */
2928
+ getThumbBounds() {
2929
+ return Zt(this.currIndex, this.currSlide ? this.currSlide.data : this._initialItemData, this);
2930
+ }
2931
+ /**
2932
+ * If the PhotoSwipe can have continuous loop
2933
+ * @returns Boolean
2934
+ */
2935
+ canLoop() {
2936
+ return this.options.loop && this.getNumItems() > 2;
2937
+ }
2938
+ /**
2939
+ * @private
2940
+ * @param {PhotoSwipeOptions} options
2941
+ * @returns {PreparedPhotoSwipeOptions}
2942
+ */
2943
+ _prepareOptions(t) {
2944
+ return window.matchMedia("(prefers-reduced-motion), (update: slow)").matches && (t.showHideAnimationType = "none", t.zoomAnimationDuration = 0), {
2945
+ ...Vt,
2946
+ ...t
2947
+ };
2948
+ }
2949
+ }
2950
+ export {
2951
+ $t as default
2952
+ };